Closed github-actions[bot] closed 3 years ago
'access-content', repository, add permissions
label: tech-debt
https://github.com/zorko-io/zorko-platform/blob/8873ccabdeeaa3991ad718315a151ba2fe7d8c23/packages/access-content/lib/mongo/MongoRepositoryAccess.mjs#L29
import {RepositoryAccess} from '../core' export class MongoRepositoryAccess extends RepositoryAccess { static prefix = 'repository' static toCollectionName = (owner, space) => { return `${MongoRepositoryAccess.prefix}.${owner}.${space}` } #context = null #deps = null #db = null #log = null #collection = null /** * * @param {Object} context * @param {Object} deps * @param {Function} deps.createContentAccess */ constructor(context = {}, deps = {}) { super(); assert(context.doc) // TODO: 'access-content', repository, add permissions // label: tech-debt assert(deps.log) assert(deps.db) assert(deps.createContentAccess) assert(deps.createResourceAccess) this.#deps = deps this.#context = context this.#db = deps.db this.#log= deps.log let name = MongoRepositoryAccess.toCollectionName( this.#context.owner, this.#context.name ) this.#collection = this.#db.collection(name) } get properties() { return { id: this.#context.doc._id.toString(), owner: this.#context.doc.owner, name: this.#context.doc.name } } async add(params) { // TODO: 'access-content', need to check path on existence and uniq names in that folder // label: tech-debt const contentAccess = this.#createContentAccess() const content = await contentAccess.add({ content: params.content, permission: params.permission }) const result = await this.#collection.insertOne({ parent: params.path, name: params.name, content: content.properties.id, mime: params.mime, preview: params.preview }) const doc = result.ops.pop() return this.#createResourceAccess({doc}) } #createContentAccess = () => { let deps = this.#deps return deps.createContentAccess({doc: this.#context}, deps) } #createResourceAccess = (options) => { let deps = this.#deps; return deps.createResourceAccess(options, deps) } } No newline at end of file ew file mode 100644 ndex 0000000..230856b ++ b/packages/access-content/lib/mongo/MongoResourceAccess.mjs
63dc2140ad448bf2ede61176414e392ca69fdecf
Closed in 8e5dbe3835c8a3f41dd74b6dd42c30bce222c919
'access-content', repository, add permissions
label: tech-debt
https://github.com/zorko-io/zorko-platform/blob/8873ccabdeeaa3991ad718315a151ba2fe7d8c23/packages/access-content/lib/mongo/MongoRepositoryAccess.mjs#L29
63dc2140ad448bf2ede61176414e392ca69fdecf