proto.io 0.0.164 → 0.0.166
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/file/database.d.ts +2 -2
- package/dist/adapters/file/database.js.map +1 -1
- package/dist/adapters/file/database.mjs +2 -2
- package/dist/adapters/file/database.mjs.map +1 -1
- package/dist/adapters/file/filesystem.d.ts +2 -2
- package/dist/adapters/file/filesystem.js.map +1 -1
- package/dist/adapters/file/filesystem.mjs.map +1 -1
- package/dist/adapters/file/google-cloud-storage.d.ts +2 -2
- package/dist/adapters/file/google-cloud-storage.js.map +1 -1
- package/dist/adapters/file/google-cloud-storage.mjs.map +1 -1
- package/dist/adapters/storage/progres.d.ts +16 -13
- package/dist/adapters/storage/progres.js +136 -81
- package/dist/adapters/storage/progres.js.map +1 -1
- package/dist/adapters/storage/progres.mjs +138 -83
- package/dist/adapters/storage/progres.mjs.map +1 -1
- package/dist/client.d.ts +3 -3
- package/dist/client.js +1 -1
- package/dist/client.mjs +3 -3
- package/dist/index.d.ts +7 -12
- package/dist/index.js +84 -47
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +87 -50
- package/dist/index.mjs.map +1 -1
- package/dist/internals/{index-Dz3jvqxZ.js → index-B-pq8xkP.js} +5 -21
- package/dist/internals/index-B-pq8xkP.js.map +1 -0
- package/dist/internals/{index-BsuUdR0W.d.ts → index-BQggoDNX.d.ts} +2 -2
- package/dist/internals/index-BQggoDNX.d.ts.map +1 -0
- package/dist/internals/{index-ByfpVHca.mjs → index-BYbMU-Ao.mjs} +2 -2
- package/dist/internals/{index-ByfpVHca.mjs.map → index-BYbMU-Ao.mjs.map} +1 -1
- package/dist/internals/{index-S5Bq-KsU.mjs → index-BejQNqvC.mjs} +2 -2
- package/dist/internals/{index-S5Bq-KsU.mjs.map → index-BejQNqvC.mjs.map} +1 -1
- package/dist/internals/index-BqFdBhFc.js.map +1 -1
- package/dist/internals/index-CSNRyhjB.js.map +1 -1
- package/dist/internals/{index-BoP4kl2R.mjs → index-CUJMde7V.mjs} +6 -22
- package/dist/internals/index-CUJMde7V.mjs.map +1 -0
- package/dist/internals/index-CVutVPmd.js.map +1 -1
- package/dist/internals/index-be1VYBY2.mjs.map +1 -1
- package/dist/internals/{index-BeV63sFw.d.ts → index-rkqvel7o.d.ts} +2 -2
- package/dist/internals/index-rkqvel7o.d.ts.map +1 -0
- package/dist/internals/{index-YdOGTHp1.d.ts → index-y8EePsDY.d.ts} +10 -6
- package/dist/internals/index-y8EePsDY.d.ts.map +1 -0
- package/dist/internals/{random-w8WDYQEe.mjs → random-DrURPPxr.mjs} +5 -10
- package/dist/internals/random-DrURPPxr.mjs.map +1 -0
- package/dist/internals/{random-uT4D0y_q.js → random-q0PeamQE.js} +3 -8
- package/dist/internals/random-q0PeamQE.js.map +1 -0
- package/package.json +20 -20
- package/dist/internals/index-BeV63sFw.d.ts.map +0 -1
- package/dist/internals/index-BoP4kl2R.mjs.map +0 -1
- package/dist/internals/index-BsuUdR0W.d.ts.map +0 -1
- package/dist/internals/index-Dz3jvqxZ.js.map +0 -1
- package/dist/internals/index-YdOGTHp1.d.ts.map +0 -1
- package/dist/internals/random-uT4D0y_q.js.map +0 -1
- package/dist/internals/random-w8WDYQEe.mjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-CUJMde7V.mjs","sources":["../../../src/internals/query/base.ts","../../../src/internals/query/index.ts","../../../src/internals/const.ts","../../../src/internals/object/user.ts","../../../src/internals/object/role.ts","../../../src/internals/object/file.ts","../../../src/internals/object/types.ts","../../../src/internals/utils.ts","../../../src/internals/object/methods.ts","../../../src/internals/proto/index.ts","../../../src/common/codec.ts","../../../src/common/index.ts","../../../src/client/query.ts","../../../src/client/request.ts","../../../src/client/proto/internal.ts","../../../src/client/proto/index.ts"],"sourcesContent":["//\n// base.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2024 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { PathName, PathNameMap } from './types';\nimport { TQuerySelector } from './types/selectors';\nimport { TValue } from '../types';\nimport { PVK } from '../private';\nimport { TExpression } from './types/expressions';\n\ninterface TQueryFilterBaseOptions {\n filter?: TQuerySelector | TQuerySelector[];\n};\n\nexport type TSortOption = {\n expr: TExpression;\n order: 1 | -1;\n};\n\nexport interface TQueryBaseOptions extends TQueryFilterBaseOptions {\n sort?: Record<string, 1 | -1> | TSortOption[];\n skip?: number;\n limit?: number;\n matches?: Record<string, TQueryBaseOptions>;\n};\n\nconst mergeOpts = (lhs: TQueryBaseOptions, rhs: TQueryBaseOptions): TQueryBaseOptions => {\n return {\n ...lhs,\n ...rhs,\n filter: [\n ..._.castArray<TQuerySelector>(lhs.filter),\n ..._.castArray<TQuerySelector>(rhs.filter)\n ],\n matches: {\n ...lhs.matches,\n ..._.mapValues(rhs.matches, (opts, key) => lhs.matches?.[key] ? mergeOpts(lhs.matches[key], opts) : opts),\n },\n };\n}\n\nclass TQueryFilterBase {\n\n /** @internal */\n [PVK]: { options: TQueryFilterBaseOptions; } = { options: {} };\n\n filter(filter: TQuerySelector) {\n if (_.isNil(this[PVK].options.filter)) {\n this[PVK].options.filter = filter;\n } else if (_.isArray(this[PVK].options.filter)) {\n this[PVK].options.filter = [...this[PVK].options.filter, filter];\n } else {\n this[PVK].options.filter = [this[PVK].options.filter, filter];\n }\n return this;\n }\n\n equalTo<T extends string>(key: PathName<T>, value: TValue | undefined) {\n return this.filter({ [key]: { $eq: value ?? null } });\n }\n\n notEqualTo<T extends string>(key: PathName<T>, value: TValue | undefined) {\n return this.filter({ [key]: { $ne: value ?? null } });\n }\n\n lessThan<T extends string>(key: PathName<T>, value: TValue | undefined) {\n return this.filter({ [key]: { $lt: value ?? null } });\n }\n\n greaterThan<T extends string>(key: PathName<T>, value: TValue | undefined) {\n return this.filter({ [key]: { $gt: value ?? null } });\n }\n\n lessThanOrEqualTo<T extends string>(key: PathName<T>, value: TValue | undefined) {\n return this.filter({ [key]: { $lte: value ?? null } });\n }\n\n greaterThanOrEqualTo<T extends string>(key: PathName<T>, value: TValue | undefined) {\n return this.filter({ [key]: { $gte: value ?? null } });\n }\n\n pattern<T extends string>(key: PathName<T>, value: RegExp | string) {\n return this.filter({ [key]: { $pattern: value ?? null } });\n }\n\n startsWith<T extends string>(key: PathName<T>, value: string) {\n return this.filter({ [key]: { $starts: value ?? null } });\n }\n\n endsWith<T extends string>(key: PathName<T>, value: string) {\n return this.filter({ [key]: { $ends: value ?? null } });\n }\n\n size<T extends string>(key: PathName<T>, value: number) {\n return this.filter({ [key]: { $size: value } });\n }\n\n empty<T extends string>(key: PathName<T>) {\n return this.filter({ [key]: { $empty: true } });\n }\n\n notEmpty<T extends string>(key: PathName<T>) {\n return this.filter({ [key]: { $empty: false } });\n }\n\n containsIn<T extends string>(key: PathName<T>, value: TValue[]) {\n return this.filter({ [key]: { $in: value } });\n }\n\n notContainsIn<T extends string>(key: PathName<T>, value: TValue[]) {\n return this.filter({ [key]: { $nin: value } });\n }\n\n isSubset<T extends string>(key: PathName<T>, value: TValue[]) {\n return this.filter({ [key]: { $subset: value } });\n }\n\n isSuperset<T extends string>(key: PathName<T>, value: TValue[]) {\n return this.filter({ [key]: { $superset: value } });\n }\n\n isDisjoint<T extends string>(key: PathName<T>, value: TValue[]) {\n return this.filter({ [key]: { $disjoint: value } });\n }\n\n isIntersect<T extends string>(key: PathName<T>, value: TValue[]) {\n return this.filter({ [key]: { $intersect: value } });\n }\n\n every<T extends string>(key: PathName<T>, callback: (query: TQueryFilterBase) => void) {\n const query = new TQueryFilterBase();\n callback(query);\n return this.filter({ [key]: { $every: { $and: _.castArray<TQuerySelector>(query[PVK].options.filter) } } });\n }\n\n some<T extends string>(key: PathName<T>, callback: (query: TQueryFilterBase) => void) {\n const query = new TQueryFilterBase();\n callback(query);\n return this.filter({ [key]: { $some: { $and: _.castArray<TQuerySelector>(query[PVK].options.filter) } } });\n }\n\n and(...callbacks: _.Many<(query: TQueryFilterBase) => void>[]) {\n return this.filter({\n $and: _.flatMap(_.flatten(callbacks), callback => {\n const query = new TQueryFilterBase();\n callback(query);\n return _.castArray<TQuerySelector>(query[PVK].options.filter);\n }),\n });\n }\n\n or(...callbacks: _.Many<(query: TQueryFilterBase) => void>[]) {\n return this.filter({\n $or: _.map(_.flatten(callbacks), callback => {\n const query = new TQueryFilterBase();\n callback(query);\n return {\n $and: _.castArray<TQuerySelector>(query[PVK].options.filter),\n };\n }),\n });\n }\n\n nor(...callbacks: _.Many<(query: TQueryFilterBase) => void>[]) {\n return this.filter({\n $nor: _.map(_.flatten(callbacks), callback => {\n const query = new TQueryFilterBase();\n callback(query);\n return {\n $and: _.castArray<TQuerySelector>(query[PVK].options.filter),\n };\n }),\n });\n }\n}\n\nexport class TQueryBase extends TQueryFilterBase {\n\n /** @internal */\n [PVK]: { options: TQueryBaseOptions; } = { options: {} };\n\n sort<T extends Record<string, 1 | -1>>(sort: PathNameMap<T> | TSortOption[]) {\n this[PVK].options.sort = sort;\n return this;\n }\n\n skip(skip: number) {\n if (!_.isSafeInteger(skip) || skip < 0) throw Error('Invalid skip number');\n this[PVK].options.skip = skip;\n return this;\n }\n\n limit(limit: number) {\n if (!_.isSafeInteger(limit) || limit < 0) throw Error('Invalid limit number');\n this[PVK].options.limit = limit;\n return this;\n }\n\n match<T extends string>(key: PathName<T>, callback: (query: TQueryBase) => void) {\n const query = new TQueryBase();\n callback(query);\n if (_.isNil(this[PVK].options.matches)) {\n this[PVK].options.matches = { [key]: query[PVK].options };\n } else if (_.isNil(this[PVK].options.matches[key])) {\n this[PVK].options.matches = { ...this[PVK].options.matches };\n this[PVK].options.matches[key] = query[PVK].options;\n } else {\n this[PVK].options.matches = { ...this[PVK].options.matches };\n this[PVK].options.matches[key] = mergeOpts(this[PVK].options.matches[key], query[PVK].options);\n }\n return this;\n }\n}\n","//\n// index.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2024 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { IncludePaths } from './types';\nimport { TValue } from '../types';\nimport { PVK } from '../private';\nimport { TObjectType } from '../object/types';\nimport { TQueryBase, TQueryBaseOptions } from './base';\nimport { TUpdateOp } from '../object/types';\nimport { ExtraOptions } from '../options';\nimport { asyncStream, Awaitable } from '@o2ter/utils-js';\n\nexport interface TQueryOptions extends TQueryBaseOptions {\n includes?: string[];\n};\n\nexport interface TQueryRandomOptions {\n weight?: string;\n};\n\nexport abstract class TQuery<T extends string, Ext, M extends boolean> extends TQueryBase {\n\n /** @internal */\n [PVK]: { options: TQueryOptions; } = { options: {} };\n\n abstract clone(options?: TQueryOptions): TQuery<T, Ext, M>;\n abstract explain(options?: ExtraOptions<M>): PromiseLike<any>;\n abstract count(options?: ExtraOptions<M>): PromiseLike<number>;\n abstract find(options?: ExtraOptions<M>): ReturnType<typeof asyncStream<TObjectType<T, Ext>>>;\n abstract random(\n opts?: TQueryRandomOptions,\n options?: ExtraOptions<M>\n ): ReturnType<typeof asyncStream<TObjectType<T, Ext>>>;\n abstract nonrefs(options?: ExtraOptions<M>): ReturnType<typeof asyncStream<TObjectType<T, Ext>>>;\n abstract insert(\n attrs: Record<string, TValue>,\n options?: ExtraOptions<M>\n ): PromiseLike<TObjectType<T, Ext>>;\n abstract insertMany(\n values: Record<string, TValue>[],\n options?: ExtraOptions<M>\n ): PromiseLike<number>;\n abstract updateOne(\n update: Record<string, TUpdateOp>,\n options?: ExtraOptions<M>\n ): PromiseLike<TObjectType<T, Ext> | undefined>;\n abstract upsertOne(\n update: Record<string, TUpdateOp>,\n setOnInsert: Record<string, TValue>,\n options?: ExtraOptions<M>\n ): PromiseLike<TObjectType<T, Ext>>;\n abstract deleteOne(options?: ExtraOptions<M>): PromiseLike<TObjectType<T, Ext> | undefined>;\n abstract deleteMany(options?: ExtraOptions<M>): PromiseLike<number>;\n\n includes<T extends string[]>(...includes: IncludePaths<T>) {\n this[PVK].options.includes = this[PVK].options.includes ? [...this[PVK].options.includes, ...includes] : includes;\n return this;\n }\n\n async get(id: string, options?: ExtraOptions<M>) {\n return _.first(await this.clone().equalTo('_id', id).limit(1).find(options));\n }\n\n async first(options?: ExtraOptions<M>) {\n return _.first(await this.clone().limit(1).find(options));\n }\n\n async randomOne(opts?: TQueryRandomOptions, options?: ExtraOptions<M>) {\n return _.first(await this.clone().limit(1).random(opts, options));\n }\n\n async exists(options?: ExtraOptions<M>) {\n const query = this.clone();\n this[PVK].options.includes = [];\n return !_.isNil(await query.limit(1).find(options));\n }\n\n async eachBatch(\n callback: (batch: TObjectType<T, Ext>[]) => Awaitable<void>,\n options?: ExtraOptions<M> & { batchSize?: number; },\n ) {\n const sorting = this[PVK].options.sort as Record<string, 1 | -1> ?? {};\n const batchSize = options?.batchSize ?? 100;\n if (!_.isPlainObject(sorting)) throw Error('Unsupported sort method');\n const is_asc = _.every(sorting, v => v === 1);\n const is_desc = _.every(sorting, v => v === -1);\n if (!is_asc && !is_desc) throw Error('Unsupported sort method');\n if (_.isNil(sorting._id)) sorting._id = is_asc ? 1 : -1;\n const query = this.clone().sort(sorting).limit(batchSize);\n const keys = _.keys(sorting);\n let batch: TObjectType<T, Ext>[] = [];\n while (true) {\n const q = _.isEmpty(batch) ? query : query.clone()\n .filter(keys.length > 1 ? {\n $expr: {\n [is_asc ? '$gt' : '$lt']: [\n { $array: _.map(keys, k => ({ $key: k })) },\n { $array: _.map(keys, k => ({ $value: _.last(batch)!.get(k) })) },\n ],\n },\n } : {\n [keys[0]]: { [is_asc ? '$gt' : '$lt']: _.last(batch)!.get(keys[0]) },\n });\n batch = await q.find(options);\n if (_.isEmpty(batch)) return;\n await callback(batch);\n }\n }\n\n async each(\n callback: (object: TObjectType<T, Ext>) => Awaitable<void>,\n options?: ExtraOptions<M> & { batchSize?: number; },\n ) {\n await this.eachBatch(async (batch) => {\n for (const object of batch) {\n await callback(object);\n }\n }, options);\n }\n};\n","//\n// index.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2024 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nexport const MASTER_USER_HEADER_NAME = 'X-PROTO-MASTER-USER';\nexport const MASTER_PASS_HEADER_NAME = 'X-PROTO-MASTER-PASS';\n\nexport const UPLOAD_TOKEN_HEADER_NAME = 'X-PROTO-UPLOAD-TOKEN';\n\nexport const AUTH_COOKIE_KEY = 'x-proto-auth';\n","//\n// user.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2024 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { TObject } from './index';\nimport { TValue } from '../types';\n\nexport class TUser extends TObject {\n\n constructor(\n attributes?: Record<string, TValue> | ((self: TObject) => Record<string, TValue>),\n ) {\n super('User', attributes);\n }\n}","//\n// role.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2024 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { TObject } from './index';\nimport { TValue } from '../types';\nimport { TUser } from './user';\n\nexport class TRole extends TObject {\n\n constructor(\n attributes?: Record<string, TValue> | ((self: TObject) => Record<string, TValue>),\n ) {\n super('Role', attributes);\n }\n\n get name(): string | undefined {\n return this.get('name');\n }\n\n get users(): TUser[] {\n return this.get('users') ?? [];\n }\n\n set users(value: TUser[]) {\n this.set('users', value);\n }\n\n get roles(): TRole[] {\n return this.get('roles') ?? [];\n }\n\n set roles(value: TRole[]) {\n this.set('roles', value);\n }\n}","//\n// file.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2024 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { TObject } from './index';\nimport { ExtraOptions } from '../options';\nimport { FileStream } from '../buffer';\nimport { TValue } from '../types';\n\nexport interface TFile {\n url: string | undefined;\n fileData(options?: ExtraOptions<boolean>): FileStream;\n save(options?: ExtraOptions<boolean> & {\n cascadeSave?: boolean;\n uploadToken?: string;\n }): PromiseLike<this>;\n}\n\nexport class TFile extends TObject {\n\n constructor(\n attributes?: Record<string, TValue> | ((self: TObject) => Record<string, TValue>),\n ) {\n super('File', attributes);\n }\n\n get filename(): string | undefined {\n return this.get('filename');\n }\n\n get size(): number | undefined {\n return this.get('size');\n }\n\n get type(): string | undefined {\n return this.get('type');\n }\n\n get token(): string | undefined {\n return this.get('token');\n }\n\n}\n","//\n// types.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2024 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport { TObject } from './index';\nimport { TUser } from './user';\nimport { TRole } from './role';\nimport { TFile } from './file';\nimport { TValue } from '../types';\nimport { ExactOneProp } from '../types';\n\nexport const TObjectTypes = {\n 'User': TUser,\n 'Role': TRole,\n 'File': TFile,\n};\n\ntype _TObjectType<K> = K extends keyof typeof TObjectTypes ? InstanceType<(typeof TObjectTypes)[K]> : TObject;\n\ntype PickBy<T, C> = {\n [P in keyof T as T[P] extends C ? P : never]: T[P];\n}\n\ntype PropertyDescriptor<T> = {\n enumerable?: boolean;\n get: () => T;\n set?: (value: T) => void;\n};\ntype ReadOnlyProperty<T> = Pick<PropertyDescriptor<T>, 'get'>;\ntype ReadWriteProperty<T> = Required<Pick<PropertyDescriptor<T>, 'get' | 'set'>>;\n\ntype PropertyMapToMethods<T> = PickBy<T, Function>\n & { [P in keyof PickBy<T, ReadWriteProperty<any>>]: T[P] extends PropertyDescriptor<infer V> ? V : never; }\n & { readonly [P in keyof PickBy<T, ReadOnlyProperty<any>>]: T[P] extends PropertyDescriptor<infer V> ? V : never; }\ntype Property<T> = T extends Function ? T | PropertyDescriptor<T> : PropertyDescriptor<T>;\ntype PropertyMap<T, O, A> = {\n [K in keyof T]: T[K] extends Property<any> ? T[K] : never;\n} & ThisType<O & PropertyMapToMethods<T> & PropertyMapToMethods<A>>;\n\nexport type TExtensions<E> = {\n [K in keyof E]: PropertyMap<E[K], _TObjectType<K>, '*' extends keyof E ? Omit<E['*'], keyof E[K]> : {}>;\n};\n\ntype _TMethods<K, E> = K extends keyof E\n ? '*' extends keyof E ? PropertyMapToMethods<Omit<E['*'], keyof E[K]> & E[K]> : PropertyMapToMethods<E[K]>\n : {};\n\ntype IfAny<T, Y, N> = 0 extends (1 & T) ? Y : N;\ntype TMethods<K, E> = IfAny<E, {}, _TMethods<K, E>>;\n\nexport type TObjectType<K, E> = _TObjectType<K> & TMethods<K, E>;\n\nexport const TUpdateOpKeys = [\n '$set',\n '$inc',\n '$dec',\n '$mul',\n '$div',\n '$max',\n '$min',\n '$addToSet',\n '$push',\n '$removeAll',\n '$popFirst',\n '$popLast',\n] as const;\n\nexport type TUpdateOp = ExactOneProp<Record<(typeof TUpdateOpKeys)[number], TValue>>;\n","//\n// utils.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2024 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\n\nexport const isObjKey = <T extends object>(key: PropertyKey, obj: T): key is keyof T => key in obj;\n","import { PathName } from './../query/types/index';\n//\n// methods.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2024 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { TObject, decodeUpdateOp } from './index';\nimport { PVK } from '../private';\nimport { ExtraOptions } from '../options';\nimport { TExtensions, TObjectType, TObjectTypes } from './types';\nimport { ProtoType } from '../proto';\nimport { TSerializable } from '../../common/codec';\nimport { TFile } from './file';\nimport { isObjKey } from '../utils';\n\nexport type TExtended<U, T extends string, E> = U extends TObject ?\n TObjectType<T, E> : U extends (infer U)[] ?\n TExtended<U, T, E>[] : U;\n\nexport const applyObjectMethods = <T extends TSerializable, E>(\n object: T,\n proto: ProtoType<E>,\n): T => {\n\n if (!(object instanceof TObject)) {\n if (_.isArray(object)) return _.map(object, x => applyObjectMethods(x, proto)) as T;\n if (_.isPlainObject(object)) return _.mapValues(object as any, x => applyObjectMethods(x, proto));\n return object;\n }\n\n object[PVK].attributes = _.mapValues(object[PVK].attributes, x => applyObjectMethods(x, proto));\n\n const className = object.className;\n const _class = isObjKey(className, TObjectTypes) ? TObjectTypes[className] : undefined;\n if (_class && Object.getPrototypeOf(object) !== _class.prototype) {\n Object.setPrototypeOf(object, _class.prototype);\n }\n\n const classExtends = proto[PVK].options.classExtends ?? {} as TExtensions<E>;\n const extensions = {\n ...classExtends['*' as keyof E] ?? {},\n ...classExtends[className as keyof E] ?? {},\n };\n const query = () => proto.Query(className);\n\n const typedMethods: Record<string, PropertyDescriptorMap & ThisType<TObject>> = {\n 'File': {\n save: {\n value(options?: ExtraOptions<boolean>) {\n return proto[PVK].saveFile(proto, this as TFile, options);\n },\n },\n destroy: {\n value(options?: ExtraOptions<boolean>) {\n return proto[PVK].deleteFile(proto, this as TFile, options);\n },\n },\n url: {\n get() {\n const filename = (this as TFile).filename;\n if (_.isNil(this.objectId) || _.isNil(filename)) return;\n const endpoint = proto[PVK].options.endpoint;\n const path = `files/${this.objectId}/${encodeURIComponent(filename)}`;\n return endpoint.endsWith('/') ? `${endpoint}${path}` : `${endpoint}/${path}`;\n }\n },\n fileData: {\n value(options?: ExtraOptions<boolean>) {\n return proto[PVK].fileData(proto, this as TFile, options);\n },\n },\n },\n };\n\n const props: PropertyDescriptorMap & ThisType<TObject> = {\n clone: {\n value() {\n const clone = proto.Object(this.className);\n clone[PVK].attributes = { ...this[PVK].attributes };\n clone[PVK].mutated = { ...this[PVK].mutated };\n clone[PVK].extra = { ...this[PVK].extra };\n return clone;\n }\n },\n relation: {\n value<T extends string>(key: PathName<T>) {\n return proto.Relation(this, key);\n }\n },\n fetchWithInclude: {\n async value(keys: string[], options?: ExtraOptions<boolean>) {\n const fetched = await query().equalTo('_id', this.objectId).includes(...keys).first(options);\n if (!fetched) throw Error('Unable to fetch document');\n this[PVK].attributes = fetched.attributes;\n return this;\n },\n },\n save: {\n async value(options?: ExtraOptions<boolean> & { cascadeSave?: boolean }) {\n const mutated = _.values(this[PVK].mutated);\n if (options?.cascadeSave !== false) {\n for (const update of _.values(mutated)) {\n const [, value] = decodeUpdateOp(update);\n if (value instanceof TObject && (_.isNil(value.objectId) || value.isDirty)) await value.save(options);\n }\n }\n if (this.objectId) {\n const updated = await query()\n .equalTo('_id', this.objectId)\n .includes(...this.keys())\n .updateOne(this[PVK].mutated, options);\n if (!updated) throw Error('Unable to save document');\n this[PVK].attributes = updated.attributes;\n this[PVK].mutated = {};\n } else {\n const created = await query()\n .includes(...this.keys())\n .insert(_.fromPairs([...this._set_entries()]), options);\n this[PVK].attributes = created.attributes;\n this[PVK].mutated = {};\n }\n return this;\n },\n },\n destroy: {\n async value(options?: ExtraOptions<boolean>) {\n const deleted = await query()\n .equalTo('_id', this.objectId)\n .includes(...this.keys())\n .deleteOne(options);\n if (!deleted) throw Error('Unable to destroy document');\n this[PVK].attributes = deleted.attributes;\n this[PVK].mutated = {};\n return this;\n },\n },\n ...typedMethods[className] ?? {},\n ..._.mapValues(extensions, value => _.isFunction(value) ? { value } : value),\n };\n\n const _props = _.pickBy(props, (_v, k) => !Object.hasOwn(object, k)) as typeof props;\n return Object.defineProperties(object, _props);\n};\n","//\n// proto.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2024 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport axios from 'axios';\nimport { PVK } from '../private';\nimport type jwt from 'jsonwebtoken';\nimport type { CookieOptions, Request } from '@o2ter/server-js';\nimport type { SignOptions } from 'jsonwebtoken';\nimport { ExtraOptions } from '../options';\nimport { TQuery } from '../query';\nimport { TExtensions, TObjectType, TObjectTypes } from '../object/types';\nimport { TFile } from '../object/file';\nimport { FileData, FileStream } from '../buffer';\nimport { isObjKey } from '../utils';\nimport { applyObjectMethods } from '../object/methods';\nimport { TValue, _TValue } from '../types';\nimport { TObject } from '../object';\nimport { TSerializable } from '../../common/codec';\nimport { TUser } from '../object/user';\nimport { ProtoFunction, ProtoFunctionOptions, ProtoTrigger } from './types';\nimport { Socket } from 'socket.io-client';\nimport { Session } from '../../server/proto/session';\nimport { asyncStream } from '@o2ter/utils-js';\nimport { PathName } from '../query/types';\nimport { TRole } from '../object/role';\n\nexport type TransactionMode = 'default' | 'committed' | 'repeatable' | 'serializable';\n\nexport type TransactionOptions = {\n mode?: TransactionMode;\n retry?: number | boolean;\n};\n\nexport type EventData = Record<string, _TValue> & {\n _id: string,\n _created_at: Date,\n _rperm: string[],\n};\n\nexport interface ProtoInternalType<Ext, P extends ProtoType<any>> {\n\n options: {\n endpoint: string;\n classExtends?: TExtensions<Ext>;\n };\n\n saveFile(proto: P, object: TFile, options?: ExtraOptions<boolean>): Promise<TFile>;\n deleteFile(proto: P, object: TFile, options?: ExtraOptions<boolean>): Promise<TFile>;\n\n fileData(proto: P, object: TFile, options?: ExtraOptions<boolean>): FileStream;\n}\n\nexport abstract class ProtoType<Ext> {\n\n /** @internal */\n abstract [PVK]: ProtoInternalType<Ext, this>;\n\n abstract config(options?: { master?: boolean; }): Promise<Record<string, _TValue>>;\n abstract configAcl(options: { master: true; }): PromiseLike<Record<string, string[]>>;\n abstract setConfig(values: Record<string, _TValue>, options: { master: true; acl?: string[]; }): Promise<void>;\n\n abstract run(name: string, data?: TSerializable, options?: ExtraOptions<boolean>): Promise<void | TSerializable>;\n abstract Query<T extends string>(className: T): TQuery<T, Ext, boolean>;\n abstract Relation<T extends string>(object: TObject, key: PathName<T>): TQuery<string, Ext, boolean>;\n\n abstract refs(object: TObject, options?: ExtraOptions<boolean>): ReturnType<typeof asyncStream<TObjectType<string, Ext>>>;\n\n async online() {\n try {\n const res = await axios({\n method: 'get',\n baseURL: this[PVK].options.endpoint,\n url: 'health',\n });\n return res.status === 200;\n } catch {\n return false;\n }\n }\n\n rebind<T extends TSerializable | undefined>(object: T): T {\n return applyObjectMethods(object, this);\n }\n\n Object<T extends string>(className: T, objectId?: string): TObjectType<T, Ext> {\n const attrs: Record<string, TValue> = objectId ? { _id: objectId } : {};\n const obj = isObjKey(className, TObjectTypes) ? new TObjectTypes[className](attrs) : new TObject(className, attrs);\n return this.rebind(obj as TObjectType<T, Ext>);\n }\n\n File(filename: string, data: FileData, type?: string) {\n const file = this.Object('File');\n file.set('filename', filename);\n file.set('type', type);\n file[PVK].extra.data = data;\n return file;\n }\n\n abstract notify(\n data: Record<string, _TValue> & { _rperm?: string[]; },\n options?: ExtraOptions<boolean>\n ): Promise<void>\n\n abstract listen(callback: (data: EventData) => void): {\n remove: VoidFunction;\n socket?: Socket;\n }\n};\n\nexport interface ProtoType<Ext> {\n\n connect<R extends Request, T extends object>(\n req: R,\n attrs?: T | ((x: this & { req: R; }) => T)\n ): this & { req: R; } & T;\n\n connectWithSessionToken<T extends object>(\n token: string,\n attrs?: T | ((x: this & { session?: Session; }) => T)\n ): Promise<this & { session?: Session; } & T>\n\n setSessionToken(token?: string): void\n\n userRoles(user: TUser): Promise<TRole[]>;\n\n becomeUser(\n req: Request,\n user: TUser,\n options?: {\n cookieOptions?: CookieOptions | undefined;\n jwtSignOptions?: SignOptions | undefined;\n }\n ): Promise<void>;\n logoutUser(\n req: Request,\n options?: {\n cookieOptions?: CookieOptions | undefined;\n jwtSignOptions?: SignOptions | undefined;\n }\n ): Promise<void>;\n\n varifyPassword(user: TUser, password: string, options: ExtraOptions<true>): Promise<boolean>;\n setPassword(user: TUser, password: string, options: ExtraOptions<true>): Promise<void>;\n unsetPassword(user: TUser, options: ExtraOptions<true>): Promise<void>;\n\n define(\n name: string,\n callback: ProtoFunction<Ext>,\n options?: Omit<ProtoFunctionOptions<Ext>, 'callback'>,\n ): void;\n\n beforeSave<T extends string>(name: T, callback: ProtoTrigger<T, Ext>): void;\n afterSave<T extends string>(name: T, callback: ProtoTrigger<T, Ext>): void;\n beforeDelete<T extends string>(name: T, callback: ProtoTrigger<T, Ext>): void;\n afterDelete<T extends string>(name: T, callback: ProtoTrigger<T, Ext>): void;\n\n lockTable(className: string | string[], update: boolean): void;\n\n withTransaction<T>(\n callback: (connection: ProtoType<Ext>) => PromiseLike<T>,\n options?: TransactionOptions,\n ): void;\n\n generateUploadToken(\n options?: { maxUploadSize?: number; }\n ): string;\n\n jwtSign(payload: any, options: jwt.SignOptions): string;\n jwtVarify(token: string, options?: jwt.VerifyOptions): jwt.JwtPayload | undefined;\n};\n","//\n// codec.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2024 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { Decimal } from 'decimal.js';\nimport { TObject } from '../internals/object';\nimport { TObjectTypes } from '../internals/object/types';\nimport { isObjKey } from '../internals/utils';\nimport { TValue } from '../internals/types';\n\nexport { Decimal };\ntype TNumber = number | Decimal | BigInt;\ntype TPrimitive = Date | string | TNumber | boolean | null | undefined;\ntype TDictionary = { [x: string]: TSerializable };\nexport type TSerializable = TDictionary | TSerializable[] | TPrimitive | TObject;\n\nexport type SerializeOptions = {\n space?: string | number;\n objAttrs?: string[];\n};\n\nexport type DeserializeOptions = {\n objAttrs?: string[];\n};\n\nconst encodeEJSON = (\n x: TSerializable,\n stack: any[],\n options: SerializeOptions,\n): any => {\n if (_.isNil(x) || _.isNumber(x) || _.isBoolean(x) || _.isString(x)) return x ?? null;\n if (_.isDate(x)) return { $date: x.valueOf() };\n if (x instanceof BigInt) return { $integer: x.toString() };\n if (x instanceof Decimal) return { $decimal: x.toString() };\n\n const found = _.indexOf(stack, x);\n if (found !== -1) return { $ref: found };\n\n if (_.isArray(x)) return x.map(v => encodeEJSON(v, [...stack, x], options));\n if (x instanceof TObject) {\n const attributes = options.objAttrs ? _.pick(x.attributes, ...options.objAttrs) : x.attributes;\n return {\n $object: {\n className: x.className,\n attributes: _.mapValues(attributes, v => encodeEJSON(v, [...stack, x], options)),\n }\n };\n }\n\n return _.transform(\n _.pick(x, Object.getOwnPropertyNames(x)),\n (r, v, k) => {\n r[k.startsWith('$') ? `$${k}` : k] = encodeEJSON(v, [...stack, x], options);\n },\n {} as TDictionary,\n );\n}\n\nconst decodeEJSON = (\n x: any,\n stack: any[],\n options: DeserializeOptions,\n): TSerializable => {\n if (_.isNil(x) || _.isNumber(x) || _.isBoolean(x) || _.isString(x)) return x ?? null;\n if (_.isArray(x)) {\n return _.transform(x, (r, v) => {\n r.push(decodeEJSON(v, [...stack, r], options));\n }, [] as TSerializable[]);\n }\n if (!_.isNil(x.$date)) return new Date(x.$date);\n if (!_.isNil(x.$integer)) return BigInt(x.$integer);\n if (!_.isNil(x.$decimal)) return new Decimal(x.$decimal);\n if (!_.isNil(x.$ref)) return stack[x.$ref];\n if (!_.isNil(x.$object)) {\n const { className, attributes } = x.$object;\n const _attributes = (self: TObject) => _.mapValues(\n options.objAttrs ? _.pick(attributes, ...options.objAttrs) : attributes,\n v => decodeEJSON(v, [...stack, self], options),\n ) as Record<string, TValue>;\n return isObjKey(className, TObjectTypes) ? new TObjectTypes[className](_attributes) : new TObject(className, _attributes);\n }\n return _.transform(x, (r, v, k) => {\n if (_.isString(k)) r[k.startsWith('$') ? k.substring(1) : k] = decodeEJSON(v, [...stack, r], options);\n }, {} as TDictionary);\n}\n\nexport const serialize = (\n x: TSerializable,\n options?: SerializeOptions,\n) => JSON.stringify(encodeEJSON(x, [], options ?? {}), undefined, options?.space);\n\nexport const deserialize = (\n buffer: string,\n options?: DeserializeOptions,\n) => decodeEJSON(JSON.parse(buffer), [], options ?? {});\n","//\n// index.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2024 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport { TObject } from '../internals/object';\nimport { TFile } from '../internals/object/file';\nimport { TRole } from '../internals/object/role';\nimport { TExtensions } from '../internals/object/types';\nimport { TUser } from '../internals/object/user';\nimport { TQuery } from '../internals/query';\n\nexport * from './codec';\nexport const classExtends = <E = {}>(x: TExtensions<E>) => x;\n\nexport const isQuery = (x: any): x is TQuery<any, any, any> => {\n return x instanceof TQuery;\n}\n\nexport const isObject = (x: any): x is TObject => {\n return x instanceof TObject;\n}\n\nexport const isUser = (x: any): x is TUser => {\n return x instanceof TUser;\n}\n\nexport const isRole = (x: any): x is TRole => {\n return x instanceof TRole;\n}\n\nexport const isFile = (x: any): x is TFile => {\n return x instanceof TFile;\n}\n","//\n// query.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2024 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { ProtoClient } from './proto';\nimport { RequestOptions } from './options';\nimport { asyncStream } from '@o2ter/utils-js';\nimport { PVK } from '../internals/private';\nimport { TQuery, TQueryOptions, TQueryRandomOptions } from '../internals/query';\nimport { TObject } from '../internals/object';\nimport { TObjectType, TUpdateOp } from '../internals/object/types';\nimport { TValue } from '../internals/types';\n\ntype _QueryOptions = {\n relatedBy?: {\n className: string;\n objectId: string;\n key: string;\n };\n};\n\nabstract class _ProtoClientQuery<T extends string, E> extends TQuery<T, E, boolean> {\n\n protected _proto: ProtoClient<E>;\n protected _opts: _QueryOptions;\n\n constructor(proto: ProtoClient<E>, opts: _QueryOptions) {\n super();\n this._proto = proto;\n this._opts = opts;\n }\n\n abstract get url(): string;\n abstract get className(): T | undefined;\n\n private get _queryOptions() {\n return {\n className: this.className,\n relatedBy: this._opts.relatedBy,\n ...this[PVK].options,\n } as any;\n }\n\n private _requestOpt(options?: RequestOptions<boolean>) {\n const { context, ...opts } = options ?? {};\n return {\n method: 'post',\n url: this.url,\n serializeOpts: {\n objAttrs: TObject.defaultReadonlyKeys,\n },\n ...opts,\n };\n }\n\n explain(options?: RequestOptions<boolean>) {\n return this._proto[PVK].request(this._proto, {\n operation: 'explain',\n context: options?.context ?? {},\n silent: options?.silent,\n ...this._queryOptions,\n }, this._requestOpt(options));\n }\n\n count(options?: RequestOptions<boolean>) {\n return this._proto[PVK].request(this._proto, {\n operation: 'count',\n context: options?.context ?? {},\n silent: options?.silent,\n ...this._queryOptions,\n }, this._requestOpt(options)) as any;\n }\n\n find(options?: RequestOptions<boolean>) {\n const request = () => this._proto[PVK].request(this._proto, {\n operation: 'find',\n context: options?.context ?? {},\n silent: options?.silent,\n ...this._queryOptions,\n }, this._requestOpt(options)) as Promise<TObjectType<T, E>[]>;\n return asyncStream(request);\n }\n\n random(\n opts?: TQueryRandomOptions,\n options?: RequestOptions<boolean>\n ) {\n const request = () => this._proto[PVK].request(this._proto, {\n operation: 'random',\n context: options?.context ?? {},\n silent: options?.silent,\n random: opts,\n ...this._queryOptions,\n }, this._requestOpt(options)) as Promise<TObjectType<T, E>[]>;\n return asyncStream(request);\n }\n\n nonrefs(options?: RequestOptions<boolean>) {\n const request = () => this._proto[PVK].request(this._proto, {\n operation: 'nonrefs',\n context: options?.context ?? {},\n silent: options?.silent,\n ...this._queryOptions,\n }, this._requestOpt(options)) as Promise<TObjectType<T, E>[]>;\n return asyncStream(request);\n }\n\n insert(\n attrs: Record<string, TValue>,\n options?: RequestOptions<boolean>\n ) {\n return this._proto[PVK].request(this._proto, {\n operation: 'insert',\n context: options?.context ?? {},\n silent: options?.silent,\n attributes: attrs,\n ...this._queryOptions,\n }, this._requestOpt(options)) as any;\n }\n\n insertMany(\n values: Record<string, TValue>[],\n options?: RequestOptions<boolean>\n ) {\n return this._proto[PVK].request(this._proto, {\n operation: 'insertMany',\n context: options?.context ?? {},\n silent: options?.silent,\n attributes: values,\n ...this._queryOptions,\n }, this._requestOpt(options)) as any;\n }\n\n updateOne(\n update: Record<string, TUpdateOp>,\n options?: RequestOptions<boolean>\n ) {\n return this._proto[PVK].request(this._proto, {\n operation: 'updateOne',\n context: options?.context ?? {},\n silent: options?.silent,\n update,\n ...this._queryOptions,\n }, this._requestOpt(options)) as any;\n }\n\n upsertOne(\n update: Record<string, TUpdateOp>,\n setOnInsert: Record<string, TValue>,\n options?: RequestOptions<boolean>\n ) {\n return this._proto[PVK].request(this._proto, {\n operation: 'upsertOne',\n context: options?.context ?? {},\n silent: options?.silent,\n update,\n setOnInsert,\n ...this._queryOptions,\n }, this._requestOpt(options)) as any;\n }\n\n deleteOne(options?: RequestOptions<boolean>) {\n return this._proto[PVK].request(this._proto, {\n operation: 'deleteOne',\n context: options?.context ?? {},\n silent: options?.silent,\n ...this._queryOptions,\n }, this._requestOpt(options)) as any;\n }\n\n deleteMany(options?: RequestOptions<boolean>) {\n return this._proto[PVK].request(this._proto, {\n operation: 'deleteMany',\n context: options?.context ?? {},\n silent: options?.silent,\n ...this._queryOptions,\n }, this._requestOpt(options)) as any;\n }\n\n}\n\nexport class ProtoClientQuery<T extends string, E> extends _ProtoClientQuery<T, E> {\n\n private _className: T;\n\n constructor(className: T, proto: ProtoClient<E>, opts: _QueryOptions) {\n super(proto, opts);\n this._className = className;\n }\n\n get url(): string {\n return `classes/${encodeURIComponent(this.className)}`;\n }\n get className(): T {\n return this._className;\n }\n\n clone(options?: TQueryOptions) {\n const clone = new ProtoClientQuery(this.className, this._proto, this._opts);\n clone[PVK].options = options ?? { ...this[PVK].options };\n return clone;\n }\n\n}\nexport class ProtoClientRelationQuery<E> extends _ProtoClientQuery<string, E> {\n\n constructor(proto: ProtoClient<E>, opts: _QueryOptions) {\n super(proto, opts);\n }\n\n get url(): string {\n return `relation`;\n }\n get className(): undefined {\n return undefined;\n }\n\n clone(options?: TQueryOptions) {\n const clone = new ProtoClientRelationQuery(this._proto, this._opts);\n clone[PVK].options = options ?? { ...this[PVK].options };\n return clone;\n }\n\n}","//\n// request.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2024 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';\nimport {\n AUTH_COOKIE_KEY,\n MASTER_PASS_HEADER_NAME,\n MASTER_USER_HEADER_NAME,\n} from '../internals/const';\nimport { RequestOptions } from './options';\nimport { ProtoClientInternal } from './proto/internal';\nimport { ProtoType } from '../internals/proto';\nimport { AxiosOptions } from './proto/types';\nimport { XSRF_COOKIE_NAME, XSRF_HEADER_NAME } from '@o2ter/server-js/dist/const';\nimport { io, Socket } from 'socket.io-client';\n\nexport default class Service<Ext, P extends ProtoType<any>> {\n\n proto: ProtoClientInternal<Ext, P>;\n service: AxiosInstance;\n\n private token?: string;\n private sockets: Socket[] = [];\n\n private retryLimit?: number;\n\n constructor(proto: ProtoClientInternal<Ext, P>, { retryLimit, ...options }: AxiosOptions = {}) {\n this.proto = proto;\n this.service = axios.create({\n xsrfCookieName: XSRF_COOKIE_NAME,\n xsrfHeaderName: XSRF_HEADER_NAME,\n withCredentials: true,\n validateStatus: status => status >= 200 && status < 500,\n ...options,\n });\n this.retryLimit = retryLimit;\n }\n\n setSessionToken(token?: string) {\n this.token = token;\n if (typeof window === 'undefined') {\n this.service.defaults.headers.Cookie = token ? `${AUTH_COOKIE_KEY}=${token}` : null;\n }\n for (const socket of this.sockets) {\n socket.emit('auth', token);\n }\n }\n\n async _request<T = any, D = any>(config: RequestOptions<boolean> & AxiosRequestConfig<D>, retry = 0): Promise<AxiosResponse<T, D>> {\n\n const { master, abortSignal, serializeOpts, context, headers, ...opts } = config ?? {};\n\n const res = await this.service.request({\n signal: abortSignal,\n headers: {\n 'Content-Type': 'application/json; charset=utf-8',\n ...master ? {\n [MASTER_USER_HEADER_NAME]: this.proto.options.masterUser?.user,\n [MASTER_PASS_HEADER_NAME]: this.proto.options.masterUser?.pass,\n } : {},\n ...headers,\n },\n ...opts,\n });\n\n if (res.headers['set-cookie']) {\n const cookies = res.headers['set-cookie'];\n const pattern = `${AUTH_COOKIE_KEY}=`;\n const token = _.findLast(_.flatMap(cookies, x => x.split(';')), x => _.startsWith(x.trim(), pattern));\n this.setSessionToken(token?.trim().slice(pattern.length));\n }\n\n if (\n (this.retryLimit ? retry < this.retryLimit : true) &&\n _.includes([412, 429], res.status)\n ) {\n return this._request(config, retry + 1);\n }\n\n if (res.status !== 200) {\n let error: Error\n try {\n const _error = JSON.parse(res.data);\n error = new Error(_error.message, { cause: _error });\n } catch {\n error = new Error(res.data);\n }\n throw error;\n }\n\n return res;\n }\n\n async request<T = any, D = any>(config: RequestOptions<boolean> & AxiosRequestConfig<D>) {\n return this._request<T, D>(config);\n }\n\n socket() {\n const endpoint = this.proto.options.socketEndpoint;\n const options = { auth: { token: this.token } };\n const socket = endpoint ? io(endpoint, options) : io(options);\n\n this.sockets.push(socket);\n\n let disconnect = false;\n let listeners: ((payload: any) => void)[] = [];\n let destroyCallbacks: VoidFunction[] = [];\n\n socket.on('connect_error', () => {\n if (!disconnect && !socket.active) socket.connect();\n });\n socket.on('disconnect', () => {\n if (!disconnect && !socket.active) socket.connect();\n });\n\n socket.on('data', (payload) => {\n for (const callback of listeners) {\n callback(payload);\n }\n });\n\n const destroy = () => {\n disconnect = true;\n this.sockets = this.sockets.filter(x => x !== socket);\n socket.disconnect();\n for (const callback of destroyCallbacks) {\n callback();\n }\n };\n\n return {\n socket,\n listen: (callback: (payload: any) => void) => {\n listeners.push(callback);\n return () => {\n listeners = listeners.filter(x => x !== callback);\n if (_.isEmpty(listeners)) destroy();\n };\n },\n onDestroy: (callback: VoidFunction) => {\n destroyCallbacks.push(callback);\n },\n };\n }\n};\n","//\n// internal.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2024 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport Service from '../request';\nimport { RequestOptions } from '../options';\nimport { ProtoOptions } from './types';\nimport { TSchema } from '../../internals/schema';\nimport { asyncStream, base64ToBuffer, isBinaryData, isBlob, isReadableStream, iterableToStream } from '@o2ter/utils-js';\nimport { TSerializable, deserialize, serialize } from '../../common';\nimport { EventData, ProtoInternalType, ProtoType } from '../../internals/proto';\nimport { TObjectType } from '../../internals/object/types';\nimport { TUser } from '../../internals/object/user';\nimport { _TValue } from '../../internals/types';\nimport { TFile } from '../../internals/object/file';\nimport { PVK } from '../../internals/private';\nimport { FileData } from '../../internals/buffer';\nimport { ExtraOptions } from '../../internals/options';\nimport { UPLOAD_TOKEN_HEADER_NAME } from '../../internals/const';\nimport { _decodeValue, TObject } from '../../internals/object';\n\nexport class ProtoClientInternal<Ext, P extends ProtoType<any>> implements ProtoInternalType<Ext, P> {\n\n options: ProtoOptions<Ext>;\n service: Service<Ext, P>;\n\n socket?: ReturnType<Service<Ext, P>['socket']>;\n\n constructor(options: ProtoOptions<Ext>) {\n this.options = options;\n this.service = new Service(this, options.axiosOptions);\n }\n\n async request(\n proto: P,\n data?: TSerializable,\n options?: Parameters<Service<Ext, P>['request']>[0]\n ) {\n\n const { serializeOpts, context, ...opts } = options ?? {};\n\n const res = await this.service.request({\n baseURL: this.options.endpoint,\n data: serialize(data, serializeOpts),\n responseType: 'text',\n ...opts,\n });\n\n return proto.rebind(deserialize(res.data));\n }\n\n setSessionToken(proto: P, token?: string) {\n this.service.setSessionToken(token);\n }\n\n async sessionInfo(\n proto: P,\n options?: RequestOptions<boolean>\n ) {\n\n const { serializeOpts, context, ...opts } = options ?? {};\n\n const res = await this.service.request({\n method: 'get',\n baseURL: this.options.endpoint,\n url: 'sessionInfo',\n responseType: 'text',\n ...opts,\n });\n\n return proto.rebind(deserialize(res.data));\n }\n\n async currentUser(\n proto: P,\n options?: RequestOptions<boolean>\n ): Promise<TObjectType<'User', Ext> | undefined> {\n\n const { serializeOpts, context, ...opts } = options ?? {};\n\n const res = await this.service.request({\n method: 'get',\n baseURL: this.options.endpoint,\n url: 'user/me',\n responseType: 'text',\n ...opts,\n });\n\n const user = proto.rebind(deserialize(res.data)) as TObjectType<'User', Ext>;\n if (!_.isNil(user) && !(user instanceof TUser)) throw Error('Unknown error');\n\n return user ?? undefined;\n }\n\n async config(options?: RequestOptions<boolean>) {\n\n const { serializeOpts, context, ...opts } = options ?? {};\n\n const res = await this.service.request({\n method: 'get',\n baseURL: this.options.endpoint,\n url: 'config',\n responseType: 'text',\n ...opts,\n });\n\n return deserialize(res.data) as Record<string, _TValue>;\n }\n async configAcl(options: RequestOptions<boolean>) {\n\n const { serializeOpts, context, ...opts } = options ?? {};\n\n const res = await this.service.request({\n method: 'get',\n baseURL: this.options.endpoint,\n url: 'configAcl',\n responseType: 'text',\n ...opts,\n });\n\n return deserialize(res.data) as Record<string, string[]>;\n }\n async setConfig(values: Record<string, _TValue>, options: RequestOptions<boolean> & { acl?: string[]; }) {\n\n const { serializeOpts, context, acl, ...opts } = options ?? {};\n\n await this.service.request({\n method: 'post',\n baseURL: this.options.endpoint,\n url: 'config',\n data: serialize({ values, acl }, serializeOpts),\n responseType: 'text',\n ...opts,\n });\n }\n\n async logout(options?: RequestOptions<boolean>) {\n\n const { serializeOpts, context, ...opts } = options ?? {};\n\n await this.service.request({\n method: 'post',\n baseURL: this.options.endpoint,\n url: 'user/logout',\n responseType: 'text',\n ...opts,\n });\n }\n\n async setPassword(user: TUser, password: string, options: RequestOptions<true>) {\n\n if (!user.objectId) throw Error('Invalid user');\n if (_.isEmpty(password)) throw Error('Invalid password');\n\n const { serializeOpts, context, ...opts } = options ?? {};\n\n await this.service.request({\n method: 'post',\n baseURL: this.options.endpoint,\n url: `user/${user.objectId}/password`,\n data: serialize({ password }, serializeOpts),\n responseType: 'text',\n ...opts,\n });\n }\n\n async unsetPassword(user: TUser, options: RequestOptions<true>) {\n\n if (!user.objectId) throw Error('Invalid user');\n\n const { serializeOpts, context, ...opts } = options ?? {};\n\n await this.service.request({\n method: 'post',\n baseURL: this.options.endpoint,\n url: `user/${user.objectId}/password`,\n responseType: 'text',\n ...opts,\n });\n }\n\n async schema(options: RequestOptions<true>): Promise<Record<string, TSchema>> {\n\n const { serializeOpts, context, ...opts } = options ?? {};\n\n const res = await this.service.request({\n method: 'get',\n baseURL: this.options.endpoint,\n url: 'schema',\n responseType: 'text',\n ...opts,\n });\n\n return deserialize(res.data) as any;\n }\n\n async updateFile(proto: P, object: TFile, options?: RequestOptions<boolean>) {\n\n const updated = await proto.Query(object.className)\n .equalTo('_id', object.objectId)\n .includes(...object.keys())\n .updateOne(object[PVK].mutated, options);\n\n if (updated) {\n object[PVK].attributes = updated.attributes;\n object[PVK].mutated = {};\n object[PVK].extra = {};\n }\n\n return object;\n }\n\n async createFile(proto: P, object: TFile, options?: RequestOptions<boolean> & { uploadToken?: string; }) {\n\n const { serializeOpts, context, uploadToken, ...opts } = options ?? {};\n const { data } = object[PVK].extra;\n if (_.isNil(data)) throw Error('Invalid file object');\n\n let buffer: FileData;\n\n if (_.isString(data) || isBinaryData(data) || isReadableStream(data) || isBlob(data)) {\n buffer = data;\n } else if ('base64' in data) {\n buffer = base64ToBuffer(data.base64);\n } else {\n throw Error('Invalid file object');\n }\n\n const res = await this.service.request({\n method: 'post',\n baseURL: this.options.endpoint,\n url: 'files',\n responseType: 'text',\n data: {\n attributes: serialize(_.fromPairs([...object._set_entries()]), serializeOpts),\n file: buffer,\n },\n headers: {\n 'Content-Type': 'multipart/form-data',\n [UPLOAD_TOKEN_HEADER_NAME]: uploadToken,\n },\n ...opts,\n });\n\n const created = deserialize(res.data);\n if (!_.isNil(created) && !(created instanceof TFile)) throw Error('Unknown error');\n\n if (created) {\n object[PVK].attributes = created.attributes;\n object[PVK].mutated = {};\n object[PVK].extra = {};\n }\n\n return object;\n }\n\n async saveFile(proto: P, object: TFile, options?: RequestOptions<boolean>) {\n return object.objectId ? this.updateFile(proto, object, options) : this.createFile(proto, object, options);\n }\n\n async deleteFile(proto: P, object: TFile, options?: ExtraOptions<boolean>) {\n\n const deleted = await proto.Query(object.className)\n .equalTo('_id', object.objectId)\n .deleteOne(options);\n\n if (deleted) {\n object[PVK].attributes = deleted.attributes;\n object[PVK].mutated = {};\n object[PVK].extra = {};\n }\n\n return object;\n }\n\n fileData(proto: P, object: TFile, options?: RequestOptions<boolean>) {\n\n const { serializeOpts, context, ...opts } = options ?? {};\n\n const filename = object.filename;\n if (_.isNil(filename)) throw Error('Invalid filename');\n\n return iterableToStream(async () => {\n const res = await this.service.request({\n method: 'get',\n baseURL: this.options.endpoint,\n url: `files/${object.objectId}/${encodeURIComponent(filename)}`,\n responseType: 'stream',\n headers: {\n 'Content-Type': 'multipart/form-data',\n },\n ...opts,\n });\n\n if (Symbol.asyncIterator in res.data) {\n return res.data;\n } else {\n throw Error('Unknown stream type');\n }\n });\n }\n\n async notify(\n proto: P,\n data: Record<string, _TValue> & { _rperm?: string[]; },\n options?: RequestOptions<boolean>\n ) {\n\n const { serializeOpts, context, ...opts } = options ?? {};\n\n await this.service.request({\n method: 'post',\n baseURL: this.options.endpoint,\n url: 'notify',\n data: serialize(data, serializeOpts),\n responseType: 'text',\n ...opts,\n });\n }\n\n listen(proto: P, callback: (data: EventData) => void) {\n const { socket, listen, onDestroy } = this.socket ?? this.service.socket();\n if (_.isNil(this.socket)) {\n this.socket = { socket, listen, onDestroy };\n onDestroy(() => { this.socket = undefined; });\n }\n return {\n socket,\n remove: listen((payload) => {\n callback(payload);\n }),\n };\n }\n\n refs(proto: P, object: TObject, options?: RequestOptions<boolean>) {\n if (!object.objectId) throw Error('Invalid object');\n const request = async () => {\n const { serializeOpts, context, ...opts } = options ?? {};\n const res = await this.service.request({\n method: 'get',\n baseURL: this.options.endpoint,\n url: `classes/${encodeURIComponent(object.className)}/${object.objectId}/refs`,\n serializeOpts: {\n objAttrs: TObject.defaultReadonlyKeys,\n },\n responseType: 'text',\n ...opts,\n });\n return proto.rebind(deserialize(res.data)) as TObjectType<string, Ext>[];\n }\n return asyncStream(request);\n }\n}\n","//\n// index.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2024 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport { ProtoClientQuery, ProtoClientRelationQuery } from '../query';\nimport { RequestOptions } from '../options';\nimport { ProtoClientInternal } from './internal';\nimport { ProtoOptions } from './types';\nimport { TSerializable } from '../../common';\nimport { EventData, ProtoType } from '../../internals/proto';\nimport { TQuery } from '../../internals/query';\nimport { PVK } from '../../internals/private';\nimport { _TValue } from '../../internals/types';\nimport { TUser } from '../../internals/object/user';\nimport { TObject } from '../../internals/object';\nimport { PathName } from '../../internals/query/types';\n\nexport class ProtoClient<Ext = any> extends ProtoType<Ext> {\n\n /** @internal */\n [PVK]: ProtoClientInternal<Ext, this>;\n\n constructor(options: ProtoOptions<Ext>) {\n super();\n this[PVK] = new ProtoClientInternal({ ...options });\n }\n\n Query<T extends string>(className: T): TQuery<T, Ext, boolean> {\n return new ProtoClientQuery<T, Ext>(className, this, {});\n }\n\n Relation<T extends string>(object: TObject, key: PathName<T>): TQuery<string, Ext, boolean> {\n const objectId = object.objectId;\n if (!objectId) throw Error('Invalid object');\n return new ProtoClientRelationQuery<Ext>(this, {\n relatedBy: {\n className: object.className,\n objectId,\n key,\n },\n });\n }\n\n config(options?: RequestOptions<boolean>): Promise<Record<string, _TValue>> {\n return this[PVK].config(options);\n }\n configAcl(options: RequestOptions<true>) {\n if (options.master !== true) throw Error('No permission');\n return this[PVK].configAcl(options);\n }\n async setConfig(values: Record<string, _TValue>, options: RequestOptions<true> & { acl?: string[]; }) {\n if (options.master !== true) throw Error('No permission');\n await this[PVK].setConfig(values, options);\n }\n\n run(\n name: string,\n data?: TSerializable,\n options?: RequestOptions<boolean>\n ): Promise<void | TSerializable> {\n return this[PVK].request(this, data, {\n method: 'post',\n url: `functions/${encodeURIComponent(name)}`,\n ...(options ?? {})\n });\n }\n\n setSessionToken(token?: string) {\n this[PVK].setSessionToken(this, token);\n }\n\n sessionInfo(options?: RequestOptions<boolean>) {\n return this[PVK].sessionInfo(this, options);\n }\n\n currentUser(options?: RequestOptions<boolean>) {\n return this[PVK].currentUser(this, options);\n }\n\n logout(options?: RequestOptions<boolean>) {\n return this[PVK].logout(options);\n }\n\n setPassword(user: TUser, password: string, options: RequestOptions<true>) {\n return this[PVK].setPassword(user, password, options);\n }\n\n unsetPassword(user: TUser, options: RequestOptions<true>) {\n return this[PVK].unsetPassword(user, options);\n }\n\n schema(options: RequestOptions<true>) {\n return this[PVK].schema(options);\n }\n\n notify(data: Record<string, _TValue> & { _rperm?: string[]; }, options?: RequestOptions<boolean>) {\n return this[PVK].notify(this, data, options);\n }\n\n listen(callback: (data: EventData) => void) {\n return this[PVK].listen(this, callback);\n }\n\n refs(object: TObject, options?: RequestOptions<boolean>) {\n return this[PVK].refs(this, object, options);\n }\n}\n"],"names":[],"mappings":";;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAyBA,MAAM,SAAS,GAAG,CAAC,GAAsB,EAAE,GAAsB,KAAuB;IACtF,OAAO;AACL,QAAA,GAAG,GAAG;AACN,QAAA,GAAG,GAAG;AACN,QAAA,MAAM,EAAE;AACN,YAAA,GAAG,CAAC,CAAC,SAAS,CAAiB,GAAG,CAAC,MAAM,CAAC;AAC1C,YAAA,GAAG,CAAC,CAAC,SAAS,CAAiB,GAAG,CAAC,MAAM;AAC1C,SAAA;AACD,QAAA,OAAO,EAAE;YACP,GAAG,GAAG,CAAC,OAAO;AACd,YAAA,GAAG,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,GAAG,CAAC,OAAO,GAAG,GAAG,CAAC,GAAG,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,GAAG,IAAI,CAAC;AAC1G,SAAA;KACF;AACH,CAAC;AAED,MAAM,gBAAgB,CAAA;;IAGpB,CAAC,GAAG,IAA2C,EAAE,OAAO,EAAE,EAAE,EAAE;AAE9D,IAAA,MAAM,CAAC,MAAsB,EAAA;AAC3B,QAAA,IAAI,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;YACrC,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,GAAG,MAAM;;AAC5B,aAAA,IAAI,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;YAC9C,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,CA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,EAAE,OAA6B,EAAA;QACtD,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,aAAa,CAAC,IAAI,EAAE,OAAO,CAAC;;AAG/C,IAAA,MAAM,CAAC,OAA6B,EAAA;QAClC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC;;IAGlC,MAAM,CAAC,IAAsD,EAAE,OAAiC,EAAA;AAC9F,QAAA,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC;;AAG9C,IAAA,MAAM,CAAC,QAAmC,EAAA;QACxC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC;;IAGzC,IAAI,CAAC,MAAe,EAAE,OAAiC,EAAA;AACrD,QAAA,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC;;AAE/C;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-CVutVPmd.js","sources":["../../../src/internals/schema.ts","../../../src/internals/object/index.ts"],"sourcesContent":["//\n// schema.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2024 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { _TValue } from './types';\n\nexport namespace TSchema {\n export type ACL = string[];\n export type ACLs = { read: TSchema.ACL; update: TSchema.ACL; };\n export type Primitive = 'boolean' | 'number' | 'decimal' | 'string' | 'date' | 'object' | 'array';\n export type PrimitiveType = Primitive | { type: Primitive; default?: _TValue; };\n export type VectorType = { type: 'vector'; dimension: number; default?: number[]; };\n export type ShapeType = { type: 'shape'; shape: Record<string, DataType>; };\n export type Relation = 'pointer' | 'relation';\n export type PointerType = { type: 'pointer'; target: string; };\n export type RelationType = { type: 'relation'; target: string; foreignField?: string; };\n export type DataType = PrimitiveType | VectorType | ShapeType | PointerType | RelationType;\n export type CLPs = {\n get?: TSchema.ACL;\n find?: TSchema.ACL;\n count?: TSchema.ACL;\n create?: TSchema.ACL;\n update?: TSchema.ACL;\n delete?: TSchema.ACL;\n };\n export type FLPs = {\n read?: TSchema.ACL;\n create?: TSchema.ACL;\n update?: TSchema.ACL;\n };\n export type Indexes = {\n type?: 'basic';\n keys: Record<string, 1 | -1>;\n unique?: boolean;\n } | {\n type: 'vector';\n keys: string | string[];\n method?: 'hnsw' | 'ivfflat';\n };\n}\n\nexport const isPrimitive = (x: TSchema.DataType): x is TSchema.PrimitiveType => _.isString(x) || (x.type !== 'pointer' && x.type !== 'relation' && x.type !== 'shape');\nexport const isVector = (x: TSchema.DataType): x is TSchema.VectorType => !_.isString(x) && x.type === 'vector';\nexport const dimensionOf = (x: TSchema.DataType) => isVector(x) ? x.dimension : 0;\nexport const isShape = (x: TSchema.DataType): x is TSchema.ShapeType => !_.isString(x) && x.type === 'shape';\nexport const isPointer = (x: TSchema.DataType): x is TSchema.PointerType => !_.isString(x) && x.type === 'pointer';\nexport const isRelation = (x: TSchema.DataType): x is TSchema.RelationType => !_.isString(x) && x.type === 'relation';\nexport const _typeof = (x: TSchema.DataType) => _.isString(x) ? x : x.type !== 'pointer' && x.type !== 'relation' ? x.type : x.target;\n\nexport const shapePaths = (x: TSchema.ShapeType): {\n path: string,\n type: Exclude<TSchema.DataType, TSchema.ShapeType>,\n}[] => _.flatMap(x.shape, (v, k) => (\n isShape(v) ? _.map(shapePaths(v), x => ({ path: `${k}.${x.path}`, type: x.type })) : { path: k, type: v }\n));\n\nexport interface TSchema {\n fields: Record<string, TSchema.DataType>;\n classLevelPermissions?: TSchema.CLPs;\n additionalObjectPermissions?: TSchema.ACLs;\n fieldLevelPermissions?: Record<string, TSchema.FLPs>;\n secureFields?: string[];\n indexes?: TSchema.Indexes[];\n}\n\nexport const defaultObjectKeyTypes: Record<string, TSchema.DataType> = {\n _id: 'string',\n __v: 'number',\n __i: 'number',\n _created_at: 'date',\n _updated_at: 'date',\n _expired_at: 'date',\n _rperm: 'array',\n _wperm: 'array',\n};\n\nexport const defaultObjectReadonlyKeys = ['_id', '__v', '__i', '_created_at', '_updated_at'];\nexport const defaultObjectKeys = [...defaultObjectReadonlyKeys, '_expired_at', '_rperm', '_wperm'];\n","//\n// object.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2024 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { PVK } from '../private';\nimport { ExtraOptions } from '../options';\nimport { Decimal } from 'decimal.js';\nimport { TPrimitiveValue, TValue, _TValue } from '../types';\nimport { TSchema, defaultObjectKeys, defaultObjectReadonlyKeys } from '../schema';\nimport { PathName } from '../query/types';\nimport { TUpdateOp, TUpdateOpKeys } from './types';\nimport { ProtoType } from '../proto';\nimport { TQuery } from '../query';\n\nexport const isPrimitiveValue = (x: any): x is TPrimitiveValue => {\n if (_.isNil(x) || _.isNumber(x) || _.isBoolean(x) || _.isString(x) || _.isDate(x)) return true;\n if (x instanceof Decimal) return true;\n return false;\n}\n\nexport const isValue = (x: any): x is TValue => {\n if (isPrimitiveValue(x) || x instanceof TObject) return true;\n if (_.isArray(x)) return _.every(x, v => isValue(v));\n if (_.isPlainObject(x)) return _.every(x, v => isValue(v));\n return false;\n}\n\nexport const cloneValue = <T extends TValue>(x: T): T => {\n if (isPrimitiveValue(x) || x instanceof TObject) return x;\n if (_.isArray(x)) return x.map(v => cloneValue(v)) as T;\n return _.mapValues(x, v => cloneValue(v)) as T;\n}\n\nexport const _decodeValue = (value: _TValue): _TValue => {\n if (isPrimitiveValue(value)) return value;\n if (_.isArray(value)) return _.map(value, x => _decodeValue(x));\n if (_.isString(value.$date)) return new Date(value.$date);\n if (_.isString(value.$decimal)) return new Decimal(value.$decimal);\n return _.transform(value, (r, v, k) => {\n r[k.startsWith('$') ? k.substring(1) : k] = _decodeValue(v);\n }, {} as any);\n};\n\nexport const _encodeValue = (value: TValue): _TValue => {\n if (value instanceof TObject) throw Error('Invalid data type');\n if (_.isDate(value)) return { $date: value.toISOString() };\n if (value instanceof Decimal) return { $decimal: value.toString() };\n if (isPrimitiveValue(value)) return value;\n if (_.isArray(value)) return _.map(value, x => _encodeValue(x));\n return _.transform(value, (r, v, k) => {\n r[k.startsWith('$') ? `$${k}` : k] = _encodeValue(v);\n }, {} as any);\n};\n\nexport const decodeUpdateOp = (update: TUpdateOp) => {\n const pairs = _.toPairs(update);\n if (pairs.length !== 1) throw Error('Invalid update operation');\n return pairs[0] as [typeof TUpdateOpKeys[number], TValue];\n}\n\nexport interface TObject {\n clone(): TObject;\n relation<T extends string>(key: PathName<T>): TQuery<string, any, boolean>;\n fetchWithInclude(keys: string[], options?: ExtraOptions<boolean>): PromiseLike<this>;\n save(options?: ExtraOptions<boolean> & { cascadeSave?: boolean }): PromiseLike<this>;\n destroy(options?: ExtraOptions<boolean>): PromiseLike<this>;\n}\n\nexport class TObject {\n\n static defaultReadonlyKeys = defaultObjectReadonlyKeys;\n static defaultKeys = defaultObjectKeys;\n\n /** @internal */\n [PVK]: {\n className: string;\n attributes: Record<string, TValue>;\n mutated: Record<string, TUpdateOp>;\n extra: Record<string, any>;\n };\n\n constructor(\n className: string,\n attributes?: Record<string, TValue> | ((self: TObject) => Record<string, TValue>),\n ) {\n const _attributes = _.isFunction(attributes) ? attributes(this) : attributes ?? {};\n this[PVK] = {\n className,\n attributes: cloneValue(_attributes),\n mutated: {},\n extra: {},\n }\n }\n\n get className(): string {\n return this[PVK].className;\n }\n\n get attributes(): Record<string, TValue> {\n return cloneValue(this[PVK].attributes);\n }\n\n get objectId(): string | undefined {\n return this[PVK].attributes._id as string;\n }\n\n get createdAt(): Date | undefined {\n return this[PVK].attributes._created_at as Date;\n }\n\n get updatedAt(): Date | undefined {\n return this[PVK].attributes._updated_at as Date;\n }\n\n get __v(): number {\n return this[PVK].attributes.__v as number;\n }\n\n get __i(): number {\n return this[PVK].attributes.__i as number;\n }\n\n get expiredAt(): Date | undefined {\n return this.get('_expired_at');\n }\n\n set expiredAt(value: Date | undefined) {\n this.set('_expired_at', value);\n }\n\n acl(): TSchema.ACLs {\n return {\n read: this.get('_rperm') ?? ['*'],\n update: this.get('_wperm') ?? ['*'],\n };\n }\n\n setAcl(value: Partial<TSchema.ACLs>) {\n this.set('_rperm', value.read ?? ['*']);\n this.set('_wperm', value.update ?? ['*']);\n }\n\n setReadAcl(value: TSchema.ACL) {\n this.set('_rperm', value);\n }\n\n setWriteAcl(value: TSchema.ACL) {\n this.set('_wperm', value);\n }\n\n keys(): string[] {\n return _.uniq([..._.keys(this[PVK].attributes), ..._.compact(_.map(_.keys(this[PVK].mutated), x => _.first(_.toPath(x))))]);\n }\n\n *entries() {\n for (const key of this.keys()) {\n yield [key, this.get(key)] as [string, any];\n }\n }\n\n /** @internal */\n *_set_entries() {\n for (const [key, op] of _.entries(this[PVK].mutated)) {\n for (const [_op, value] of _.entries(op)) {\n if (_op === '$set') yield [key, value] as [string, any];\n }\n }\n }\n\n toObject() {\n const toObject = (value: TValue): _TValue => {\n if (isPrimitiveValue(value)) return value;\n if (value instanceof TObject) return value.toObject();\n if (_.isArray(value)) return _.map(value, toObject);\n return _.mapValues(value, toObject);\n }\n return _.fromPairs(_.map(this.keys(), k => [k, toObject(this.get(k))]));\n }\n\n private _value(key: string): TValue {\n let value: TValue = this[PVK].attributes;\n for (const k of _.toPath(key)) {\n if (isPrimitiveValue(value)) return null;\n if (value instanceof TObject) {\n value = value.get(k);\n } else {\n value = _.get(value, k);\n }\n }\n return cloneValue(value);\n }\n\n get<T extends string>(key: PathName<T>): any {\n if (_.isEmpty(key)) throw Error('Invalid key');\n if (_.isNil(this[PVK].mutated[key])) return this._value(key);\n const [op, value] = decodeUpdateOp(this[PVK].mutated[key]);\n return op === '$set' ? value : this._value(key);\n }\n\n set<T extends string>(key: PathName<T>, value: TValue | undefined) {\n if (_.isEmpty(key)) throw Error('Invalid key');\n if (TObject.defaultReadonlyKeys.includes(_.first(_.toPath(key))!)) return;\n this[PVK].mutated[key] = { $set: value ?? null };\n }\n\n get isDirty(): boolean {\n return !_.isEmpty(this[PVK].mutated);\n }\n\n increment<T extends string>(key: PathName<T>, value: number) {\n if (_.isEmpty(key)) throw Error('Invalid key');\n if (TObject.defaultReadonlyKeys.includes(_.first(_.toPath(key))!)) return;\n this[PVK].mutated[key] = { $inc: value };\n }\n\n decrement<T extends string>(key: PathName<T>, value: number) {\n if (_.isEmpty(key)) throw Error('Invalid key');\n if (TObject.defaultReadonlyKeys.includes(_.first(_.toPath(key))!)) return;\n this[PVK].mutated[key] = { $dec: value };\n }\n\n multiply<T extends string>(key: PathName<T>, value: number) {\n if (_.isEmpty(key)) throw Error('Invalid key');\n if (TObject.defaultReadonlyKeys.includes(_.first(_.toPath(key))!)) return;\n this[PVK].mutated[key] = { $mul: value };\n }\n\n divide<T extends string>(key: PathName<T>, value: number) {\n if (_.isEmpty(key)) throw Error('Invalid key');\n if (TObject.defaultReadonlyKeys.includes(_.first(_.toPath(key))!)) return;\n this[PVK].mutated[key] = { $div: value };\n }\n\n max<T extends string>(key: PathName<T>, value: TValue) {\n if (_.isEmpty(key)) throw Error('Invalid key');\n if (TObject.defaultReadonlyKeys.includes(_.first(_.toPath(key))!)) return;\n this[PVK].mutated[key] = { $max: value };\n }\n\n min<T extends string>(key: PathName<T>, value: TValue) {\n if (_.isEmpty(key)) throw Error('Invalid key');\n if (TObject.defaultReadonlyKeys.includes(_.first(_.toPath(key))!)) return;\n this[PVK].mutated[key] = { $min: value };\n }\n\n addToSet<T extends string>(key: PathName<T>, values: TValue[]) {\n if (_.isEmpty(key)) throw Error('Invalid key');\n if (TObject.defaultReadonlyKeys.includes(_.first(_.toPath(key))!)) return;\n this[PVK].mutated[key] = { $addToSet: values };\n }\n\n push<T extends string>(key: PathName<T>, values: TValue[]) {\n if (_.isEmpty(key)) throw Error('Invalid key');\n if (TObject.defaultReadonlyKeys.includes(_.first(_.toPath(key))!)) return;\n this[PVK].mutated[key] = { $push: values };\n }\n\n removeAll<T extends string>(key: PathName<T>, values: TValue[]) {\n if (_.isEmpty(key)) throw Error('Invalid key');\n if (TObject.defaultReadonlyKeys.includes(_.first(_.toPath(key))!)) return;\n this[PVK].mutated[key] = { $removeAll: values };\n }\n\n popFirst<T extends string>(key: PathName<T>, count = 1) {\n if (_.isEmpty(key)) throw Error('Invalid key');\n if (TObject.defaultReadonlyKeys.includes(_.first(_.toPath(key))!)) return;\n this[PVK].mutated[key] = { $popFirst: count };\n }\n\n popLast<T extends string>(key: PathName<T>, count = 1) {\n if (_.isEmpty(key)) throw Error('Invalid key');\n if (TObject.defaultReadonlyKeys.includes(_.first(_.toPath(key))!)) return;\n this[PVK].mutated[key] = { $popLast: count };\n }\n\n async fetch(options?: ExtraOptions<boolean>) {\n return this.fetchWithInclude(_.keys(this[PVK].attributes), options);\n }\n\n async fetchIfNeeded(keys: string[], options?: ExtraOptions<boolean>) {\n const current = _.keys(this[PVK].attributes);\n if (_.every(keys, k => _.includes(current, k))) return this;\n return this.fetchWithInclude(_.uniq([...current, ...keys]), options);\n }\n\n}\n"],"names":["Decimal","PVK"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAwCO,MAAM,WAAW,GAAG,CAAC,CAAmB,KAAiC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,KAAK,SAAS,IAAI,CAAC,CAAC,IAAI,KAAK,UAAU,IAAI,CAAC,CAAC,IAAI,KAAK,OAAO,EAAE;MAC1J,QAAQ,GAAG,CAAC,CAAmB,KAA8B,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,SAAS;MACnG,WAAW,GAAG,CAAC,CAAmB,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,SAAS,GAAG,EAAE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,EAAA;AACjE,QAAA,MAAM,OAAO,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAACA,YAAG,CAAC,CAAC,UAAU,CAAC,CAAC;AAC7C,QAAA,IAAI,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;AAAE,YAAA,OAAO,IAAI,CAAC;AAC5D,QAAA,OAAO,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;KACtE;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"index-CVutVPmd.js","sources":["../../../src/internals/schema.ts","../../../src/internals/object/index.ts"],"sourcesContent":["//\n// schema.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2024 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { _TValue } from './types';\n\nexport namespace TSchema {\n export type ACL = string[];\n export type ACLs = { read: TSchema.ACL; update: TSchema.ACL; };\n export type Primitive = 'boolean' | 'number' | 'decimal' | 'string' | 'date' | 'object' | 'array';\n export type PrimitiveType = Primitive | { type: Primitive; default?: _TValue; };\n export type VectorType = { type: 'vector'; dimension: number; default?: number[]; };\n export type ShapeType = { type: 'shape'; shape: Record<string, DataType>; };\n export type Relation = 'pointer' | 'relation';\n export type PointerType = { type: 'pointer'; target: string; };\n export type RelationType = { type: 'relation'; target: string; foreignField?: string; };\n export type DataType = PrimitiveType | VectorType | ShapeType | PointerType | RelationType;\n export type CLPs = {\n get?: TSchema.ACL;\n find?: TSchema.ACL;\n count?: TSchema.ACL;\n create?: TSchema.ACL;\n update?: TSchema.ACL;\n delete?: TSchema.ACL;\n };\n export type FLPs = {\n read?: TSchema.ACL;\n create?: TSchema.ACL;\n update?: TSchema.ACL;\n };\n export type Indexes = {\n type?: 'basic';\n keys: Record<string, 1 | -1>;\n unique?: boolean;\n } | {\n type: 'vector';\n keys: string | string[];\n method?: 'hnsw' | 'ivfflat';\n };\n}\n\nexport const isPrimitive = (x: TSchema.DataType): x is TSchema.PrimitiveType => _.isString(x) || (x.type !== 'pointer' && x.type !== 'relation' && x.type !== 'shape');\nexport const isVector = (x: TSchema.DataType): x is TSchema.VectorType => !_.isString(x) && x.type === 'vector';\nexport const dimensionOf = (x: TSchema.DataType) => isVector(x) ? x.dimension : 0;\nexport const isShape = (x: TSchema.DataType): x is TSchema.ShapeType => !_.isString(x) && x.type === 'shape';\nexport const isPointer = (x: TSchema.DataType): x is TSchema.PointerType => !_.isString(x) && x.type === 'pointer';\nexport const isRelation = (x: TSchema.DataType): x is TSchema.RelationType => !_.isString(x) && x.type === 'relation';\nexport const _typeof = (x: TSchema.DataType) => _.isString(x) ? x : x.type !== 'pointer' && x.type !== 'relation' ? x.type : x.target;\n\nexport const shapePaths = (x: TSchema.ShapeType): {\n path: string,\n type: Exclude<TSchema.DataType, TSchema.ShapeType>,\n}[] => _.flatMap(x.shape, (v, k) => (\n isShape(v) ? _.map(shapePaths(v), x => ({ path: `${k}.${x.path}`, type: x.type })) : { path: k, type: v }\n));\n\nexport interface TSchema {\n fields: Record<string, TSchema.DataType>;\n classLevelPermissions?: TSchema.CLPs;\n additionalObjectPermissions?: TSchema.ACLs;\n fieldLevelPermissions?: Record<string, TSchema.FLPs>;\n secureFields?: string[];\n indexes?: TSchema.Indexes[];\n}\n\nexport const defaultObjectKeyTypes: Record<string, TSchema.DataType> = {\n _id: 'string',\n __v: 'number',\n __i: 'number',\n _created_at: 'date',\n _updated_at: 'date',\n _expired_at: 'date',\n _rperm: 'array',\n _wperm: 'array',\n};\n\nexport const defaultObjectReadonlyKeys = ['_id', '__v', '__i', '_created_at', '_updated_at'];\nexport const defaultObjectKeys = [...defaultObjectReadonlyKeys, '_expired_at', '_rperm', '_wperm'];\n","//\n// object.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2024 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { PVK } from '../private';\nimport { ExtraOptions } from '../options';\nimport { Decimal } from 'decimal.js';\nimport { TPrimitiveValue, TValue, _TValue } from '../types';\nimport { TSchema, defaultObjectKeys, defaultObjectReadonlyKeys } from '../schema';\nimport { PathName } from '../query/types';\nimport { TUpdateOp, TUpdateOpKeys } from './types';\nimport { ProtoType } from '../proto';\nimport { TQuery } from '../query';\n\nexport const isPrimitiveValue = (x: any): x is TPrimitiveValue => {\n if (_.isNil(x) || _.isNumber(x) || _.isBoolean(x) || _.isString(x) || _.isDate(x)) return true;\n if (x instanceof Decimal) return true;\n return false;\n}\n\nexport const isValue = (x: any): x is TValue => {\n if (isPrimitiveValue(x) || x instanceof TObject) return true;\n if (_.isArray(x)) return _.every(x, v => isValue(v));\n if (_.isPlainObject(x)) return _.every(x, v => isValue(v));\n return false;\n}\n\nexport const cloneValue = <T extends TValue>(x: T): T => {\n if (isPrimitiveValue(x) || x instanceof TObject) return x;\n if (_.isArray(x)) return x.map(v => cloneValue(v)) as T;\n return _.mapValues(x, v => cloneValue(v)) as T;\n}\n\nexport const _decodeValue = (value: _TValue): _TValue => {\n if (isPrimitiveValue(value)) return value;\n if (_.isArray(value)) return _.map(value, x => _decodeValue(x));\n if (_.isString(value.$date)) return new Date(value.$date);\n if (_.isString(value.$decimal)) return new Decimal(value.$decimal);\n return _.transform(value, (r, v, k) => {\n r[k.startsWith('$') ? k.substring(1) : k] = _decodeValue(v);\n }, {} as any);\n};\n\nexport const _encodeValue = (value: TValue): _TValue => {\n if (value instanceof TObject) throw Error('Invalid data type');\n if (_.isDate(value)) return { $date: value.toISOString() };\n if (value instanceof Decimal) return { $decimal: value.toString() };\n if (isPrimitiveValue(value)) return value;\n if (_.isArray(value)) return _.map(value, x => _encodeValue(x));\n return _.transform(value, (r, v, k) => {\n r[k.startsWith('$') ? `$${k}` : k] = _encodeValue(v);\n }, {} as any);\n};\n\nexport const decodeUpdateOp = (update: TUpdateOp) => {\n const pairs = _.toPairs(update);\n if (pairs.length !== 1) throw Error('Invalid update operation');\n return pairs[0] as [typeof TUpdateOpKeys[number], TValue];\n}\n\nexport interface TObject {\n clone(): TObject;\n relation<T extends string>(key: PathName<T>): TQuery<string, any, boolean>;\n fetchWithInclude(keys: string[], options?: ExtraOptions<boolean>): PromiseLike<this>;\n save(options?: ExtraOptions<boolean> & { cascadeSave?: boolean }): PromiseLike<this>;\n destroy(options?: ExtraOptions<boolean>): PromiseLike<this>;\n}\n\nexport class TObject {\n\n static defaultReadonlyKeys = defaultObjectReadonlyKeys;\n static defaultKeys = defaultObjectKeys;\n\n /** @internal */\n [PVK]: {\n className: string;\n attributes: Record<string, TValue>;\n mutated: Record<string, TUpdateOp>;\n extra: Record<string, any>;\n };\n\n constructor(\n className: string,\n attributes?: Record<string, TValue> | ((self: TObject) => Record<string, TValue>),\n ) {\n const _attributes = _.isFunction(attributes) ? attributes(this) : attributes ?? {};\n this[PVK] = {\n className,\n attributes: cloneValue(_attributes),\n mutated: {},\n extra: {},\n }\n }\n\n get className(): string {\n return this[PVK].className;\n }\n\n get attributes(): Record<string, TValue> {\n return cloneValue(this[PVK].attributes);\n }\n\n get objectId(): string | undefined {\n return this[PVK].attributes._id as string;\n }\n\n get createdAt(): Date | undefined {\n return this[PVK].attributes._created_at as Date;\n }\n\n get updatedAt(): Date | undefined {\n return this[PVK].attributes._updated_at as Date;\n }\n\n get __v(): number {\n return this[PVK].attributes.__v as number;\n }\n\n get __i(): number {\n return this[PVK].attributes.__i as number;\n }\n\n get expiredAt(): Date | undefined {\n return this.get('_expired_at');\n }\n\n set expiredAt(value: Date | undefined) {\n this.set('_expired_at', value);\n }\n\n acl(): TSchema.ACLs {\n return {\n read: this.get('_rperm') ?? ['*'],\n update: this.get('_wperm') ?? ['*'],\n };\n }\n\n setAcl(value: Partial<TSchema.ACLs>) {\n this.set('_rperm', value.read ?? ['*']);\n this.set('_wperm', value.update ?? ['*']);\n }\n\n setReadAcl(value: TSchema.ACL) {\n this.set('_rperm', value);\n }\n\n setWriteAcl(value: TSchema.ACL) {\n this.set('_wperm', value);\n }\n\n keys(): string[] {\n return _.uniq([..._.keys(this[PVK].attributes), ..._.compact(_.map(_.keys(this[PVK].mutated), x => _.first(_.toPath(x))))]);\n }\n\n *entries() {\n for (const key of this.keys()) {\n yield [key, this.get(key)] as [string, any];\n }\n }\n\n /** @internal */\n *_set_entries() {\n for (const [key, op] of _.entries(this[PVK].mutated)) {\n for (const [_op, value] of _.entries(op)) {\n if (_op === '$set') yield [key, value] as [string, any];\n }\n }\n }\n\n toObject() {\n const toObject = (value: TValue): _TValue => {\n if (isPrimitiveValue(value)) return value;\n if (value instanceof TObject) return value.toObject();\n if (_.isArray(value)) return _.map(value, toObject);\n return _.mapValues(value, toObject);\n }\n return _.fromPairs(_.map(this.keys(), k => [k, toObject(this.get(k))]));\n }\n\n private _value(key: string): TValue {\n let value: TValue = this[PVK].attributes;\n for (const k of _.toPath(key)) {\n if (isPrimitiveValue(value)) return null;\n if (value instanceof TObject) {\n value = value.get(k);\n } else {\n value = _.get(value, k);\n }\n }\n return cloneValue(value);\n }\n\n get<T extends string>(key: PathName<T>): any {\n if (_.isEmpty(key)) throw Error('Invalid key');\n if (_.isNil(this[PVK].mutated[key])) return this._value(key);\n const [op, value] = decodeUpdateOp(this[PVK].mutated[key]);\n return op === '$set' ? value : this._value(key);\n }\n\n set<T extends string>(key: PathName<T>, value: TValue | undefined) {\n if (_.isEmpty(key)) throw Error('Invalid key');\n if (TObject.defaultReadonlyKeys.includes(_.first(_.toPath(key))!)) return;\n this[PVK].mutated[key] = { $set: value ?? null };\n }\n\n get isDirty(): boolean {\n return !_.isEmpty(this[PVK].mutated);\n }\n\n increment<T extends string>(key: PathName<T>, value: number) {\n if (_.isEmpty(key)) throw Error('Invalid key');\n if (TObject.defaultReadonlyKeys.includes(_.first(_.toPath(key))!)) return;\n this[PVK].mutated[key] = { $inc: value };\n }\n\n decrement<T extends string>(key: PathName<T>, value: number) {\n if (_.isEmpty(key)) throw Error('Invalid key');\n if (TObject.defaultReadonlyKeys.includes(_.first(_.toPath(key))!)) return;\n this[PVK].mutated[key] = { $dec: value };\n }\n\n multiply<T extends string>(key: PathName<T>, value: number) {\n if (_.isEmpty(key)) throw Error('Invalid key');\n if (TObject.defaultReadonlyKeys.includes(_.first(_.toPath(key))!)) return;\n this[PVK].mutated[key] = { $mul: value };\n }\n\n divide<T extends string>(key: PathName<T>, value: number) {\n if (_.isEmpty(key)) throw Error('Invalid key');\n if (TObject.defaultReadonlyKeys.includes(_.first(_.toPath(key))!)) return;\n this[PVK].mutated[key] = { $div: value };\n }\n\n max<T extends string>(key: PathName<T>, value: TValue) {\n if (_.isEmpty(key)) throw Error('Invalid key');\n if (TObject.defaultReadonlyKeys.includes(_.first(_.toPath(key))!)) return;\n this[PVK].mutated[key] = { $max: value };\n }\n\n min<T extends string>(key: PathName<T>, value: TValue) {\n if (_.isEmpty(key)) throw Error('Invalid key');\n if (TObject.defaultReadonlyKeys.includes(_.first(_.toPath(key))!)) return;\n this[PVK].mutated[key] = { $min: value };\n }\n\n addToSet<T extends string>(key: PathName<T>, values: TValue[]) {\n if (_.isEmpty(key)) throw Error('Invalid key');\n if (TObject.defaultReadonlyKeys.includes(_.first(_.toPath(key))!)) return;\n this[PVK].mutated[key] = { $addToSet: values };\n }\n\n push<T extends string>(key: PathName<T>, values: TValue[]) {\n if (_.isEmpty(key)) throw Error('Invalid key');\n if (TObject.defaultReadonlyKeys.includes(_.first(_.toPath(key))!)) return;\n this[PVK].mutated[key] = { $push: values };\n }\n\n removeAll<T extends string>(key: PathName<T>, values: TValue[]) {\n if (_.isEmpty(key)) throw Error('Invalid key');\n if (TObject.defaultReadonlyKeys.includes(_.first(_.toPath(key))!)) return;\n this[PVK].mutated[key] = { $removeAll: values };\n }\n\n popFirst<T extends string>(key: PathName<T>, count = 1) {\n if (_.isEmpty(key)) throw Error('Invalid key');\n if (TObject.defaultReadonlyKeys.includes(_.first(_.toPath(key))!)) return;\n this[PVK].mutated[key] = { $popFirst: count };\n }\n\n popLast<T extends string>(key: PathName<T>, count = 1) {\n if (_.isEmpty(key)) throw Error('Invalid key');\n if (TObject.defaultReadonlyKeys.includes(_.first(_.toPath(key))!)) return;\n this[PVK].mutated[key] = { $popLast: count };\n }\n\n async fetch(options?: ExtraOptions<boolean>) {\n return this.fetchWithInclude(_.keys(this[PVK].attributes), options);\n }\n\n async fetchIfNeeded(keys: string[], options?: ExtraOptions<boolean>) {\n const current = _.keys(this[PVK].attributes);\n if (_.every(keys, k => _.includes(current, k))) return this;\n return this.fetchWithInclude(_.uniq([...current, ...keys]), options);\n }\n\n}\n"],"names":["Decimal","PVK"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAwCO,MAAM,WAAW,GAAG,CAAC,CAAmB,KAAiC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,KAAK,SAAS,IAAI,CAAC,CAAC,IAAI,KAAK,UAAU,IAAI,CAAC,CAAC,IAAI,KAAK,OAAO;MACxJ,QAAQ,GAAG,CAAC,CAAmB,KAA8B,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK;MAC1F,WAAW,GAAG,CAAC,CAAmB,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,SAAS,GAAG;MACnE,OAAO,GAAG,CAAC,CAAmB,KAA6B,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK;MACxF,SAAS,GAAG,CAAC,CAAmB,KAA+B,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK;MAC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QAAA,OAAO,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAACA,YAAG,CAAC,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC;;AAGrE,IAAA,MAAM,aAAa,CAAC,IAAc,EAAE,OAA+B,EAAA;AACjE,QAAA,MAAM,OAAO,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAACA,YAAG,CAAC,CAAC,UAAU,CAAC;AAC5C,QAAA,IAAI,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;AAAE,YAAA,OAAO,IAAI;AAC3D,QAAA,OAAO,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC,EAAE,OAAO,CAAC;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-be1VYBY2.mjs","sources":["../../../src/adapters/file/base/index.ts"],"sourcesContent":["//\n// index.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2024 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { promisify } from 'util';\nimport { deflate as _deflate, unzip as _unzip } from 'zlib';\nimport { TFileInfo, TFileStorage } from '../../../server/file';\nimport { ProtoService } from '../../../server/proto';\nimport { TSchema } from '../../../internals/schema';\nimport { BinaryData, binaryStreamChunk, parallelEach, parallelMap } from '@o2ter/utils-js';\nimport { PVK } from '../../../internals/private';\n\nconst deflate = promisify(_deflate);\nconst unzip = promisify(_unzip);\n\nexport type FileStorageOptions = {\n chunkSize?: number;\n parallel?: number;\n};\n\nexport abstract class FileStorageBase implements TFileStorage {\n\n options: Required<FileStorageOptions>;\n\n constructor(options: FileStorageOptions) {\n this.options = {\n chunkSize: 16 * 1024,\n parallel: 8,\n ..._.pickBy(options, v => !_.isNil(v)),\n };\n }\n\n get schema(): Record<string, TSchema> {\n return {}\n }\n\n abstract createChunk<E>(proto: ProtoService<E>, token: string, start: number, end: number, compressed: Buffer): PromiseLike<void>;\n abstract readChunks<E>(proto: ProtoService<E>, token: string, start?: number, end?: number): AsyncGenerator<{\n start: number;\n data: Buffer | Uint8Array | PromiseLike<Buffer | Uint8Array>;\n }, void>;\n abstract destroy<E>(proto: ProtoService<E>, id: string): PromiseLike<void>;\n\n async create<E>(\n proto: ProtoService<E>,\n stream: BinaryData | AsyncIterable<BinaryData>,\n info: TFileInfo,\n maxUploadSize: number,\n ) {\n\n const token = proto[PVK].generateId();\n\n let size = 0;\n const _stream = async function* (stream: AsyncIterable<Buffer>) {\n for await (const data of stream) {\n yield { data, offset: size };\n size += data.byteLength;\n }\n };\n\n await parallelEach(\n _stream(binaryStreamChunk(stream, this.options.chunkSize)),\n this.options.parallel,\n async ({ data, offset }) => {\n const chunkSize = data.byteLength;\n await this.createChunk(proto, token, offset, offset + chunkSize, await deflate(data));\n if (offset + chunkSize > maxUploadSize) throw Error('Payload too large');\n }\n );\n\n return { _id: token, size };\n }\n\n async* fileData<E>(proto: ProtoService<E>, id: string, start?: number, end?: number) {\n\n const _stream = parallelMap(\n this.readChunks(proto, id, start, end),\n this.options.parallel,\n async chunk => ({\n start: chunk.start,\n data: await unzip(await chunk.data),\n })\n );\n\n for await (const { start: startBytes, data } of _stream) {\n\n if (!_.isNumber(start) && !_.isNumber(end)) {\n\n yield data;\n\n } else {\n\n const endBytes = startBytes + data.length;\n const _start = _.isNumber(start) && start > startBytes ? start - startBytes : 0;\n const _end = _.isNumber(end) && end < endBytes ? end - startBytes : undefined;\n\n yield data.subarray(_start, _end);\n }\n }\n }\n};\n\nexport default FileStorageBase;"],"names":["_deflate","_unzip"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAWA,MAAM,OAAO,GAAG,SAAS,CAACA,SAAQ,CAAC
|
|
1
|
+
{"version":3,"file":"index-be1VYBY2.mjs","sources":["../../../src/adapters/file/base/index.ts"],"sourcesContent":["//\n// index.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2024 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { promisify } from 'util';\nimport { deflate as _deflate, unzip as _unzip } from 'zlib';\nimport { TFileInfo, TFileStorage } from '../../../server/file';\nimport { ProtoService } from '../../../server/proto';\nimport { TSchema } from '../../../internals/schema';\nimport { BinaryData, binaryStreamChunk, parallelEach, parallelMap } from '@o2ter/utils-js';\nimport { PVK } from '../../../internals/private';\n\nconst deflate = promisify(_deflate);\nconst unzip = promisify(_unzip);\n\nexport type FileStorageOptions = {\n chunkSize?: number;\n parallel?: number;\n};\n\nexport abstract class FileStorageBase implements TFileStorage {\n\n options: Required<FileStorageOptions>;\n\n constructor(options: FileStorageOptions) {\n this.options = {\n chunkSize: 16 * 1024,\n parallel: 8,\n ..._.pickBy(options, v => !_.isNil(v)),\n };\n }\n\n get schema(): Record<string, TSchema> {\n return {}\n }\n\n abstract createChunk<E>(proto: ProtoService<E>, token: string, start: number, end: number, compressed: Buffer): PromiseLike<void>;\n abstract readChunks<E>(proto: ProtoService<E>, token: string, start?: number, end?: number): AsyncGenerator<{\n start: number;\n data: Buffer | Uint8Array | PromiseLike<Buffer | Uint8Array>;\n }, void>;\n abstract destroy<E>(proto: ProtoService<E>, id: string): PromiseLike<void>;\n\n async create<E>(\n proto: ProtoService<E>,\n stream: BinaryData | AsyncIterable<BinaryData>,\n info: TFileInfo,\n maxUploadSize: number,\n ) {\n\n const token = proto[PVK].generateId();\n\n let size = 0;\n const _stream = async function* (stream: AsyncIterable<Buffer>) {\n for await (const data of stream) {\n yield { data, offset: size };\n size += data.byteLength;\n }\n };\n\n await parallelEach(\n _stream(binaryStreamChunk(stream, this.options.chunkSize)),\n this.options.parallel,\n async ({ data, offset }) => {\n const chunkSize = data.byteLength;\n await this.createChunk(proto, token, offset, offset + chunkSize, await deflate(data));\n if (offset + chunkSize > maxUploadSize) throw Error('Payload too large');\n }\n );\n\n return { _id: token, size };\n }\n\n async* fileData<E>(proto: ProtoService<E>, id: string, start?: number, end?: number) {\n\n const _stream = parallelMap(\n this.readChunks(proto, id, start, end),\n this.options.parallel,\n async chunk => ({\n start: chunk.start,\n data: await unzip(await chunk.data),\n })\n );\n\n for await (const { start: startBytes, data } of _stream) {\n\n if (!_.isNumber(start) && !_.isNumber(end)) {\n\n yield data;\n\n } else {\n\n const endBytes = startBytes + data.length;\n const _start = _.isNumber(start) && start > startBytes ? start - startBytes : 0;\n const _end = _.isNumber(end) && end < endBytes ? end - startBytes : undefined;\n\n yield data.subarray(_start, _end);\n }\n }\n }\n};\n\nexport default FileStorageBase;"],"names":["_deflate","_unzip"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAWA,MAAM,OAAO,GAAG,SAAS,CAACA,SAAQ,CAAC;AACnC,MAAM,KAAK,GAAG,SAAS,CAACC,OAAM,CAAC;MAOT,eAAe,CAAA;AAEnC,IAAA,OAAO;AAEP,IAAA,WAAA,CAAY,OAA2B,EAAA;QACrC,IAAI,CAAC,OAAO,GAAG;YACb,SAAS,EAAE,EAAE,GAAG,IAAI;AACpB,YAAA,QAAQ,EAAE,CAAC;AACX,YAAA,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;SACvC;;AAGH,IAAA,IAAI,MAAM,GAAA;AACR,QAAA,OAAO,EAAE;;IAUX,MAAM,MAAM,CACV,KAAsB,EACtB,MAA8C,EAC9C,IAAe,EACf,aAAqB,EAAA;QAGrB,MAAM,KAAK,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AAA,WAAW,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,OAAO,EAAE;AAEvD,YAAA,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;AAE1C,gBAAA,MAAM,IAAI;;iBAEL;AAEL,gBAAA,MAAM,QAAQ,GAAG,UAAU,GAAG,IAAI,CAAC,MAAM;gBACzC,MAAM,MAAM,GAAG,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,UAAU,GAAG,KAAK,GAAG,UAAU,GAAG,CAAC;gBAC/E,MAAM,IAAI,GAAG,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,GAAG,GAAG,QAAQ,GAAG,GAAG,GAAG,UAAU,GAAG,SAAS;gBAE7E,MAAM,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC;;;;AAIxC;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as TFileStorage, T as TSchema, P as ProtoService, B as TFileInfo } from './index-
|
|
1
|
+
import { c as TFileStorage, T as TSchema, P as ProtoService, B as TFileInfo } from './index-y8EePsDY.js';
|
|
2
2
|
import { BinaryData } from '@o2ter/utils-js';
|
|
3
3
|
|
|
4
4
|
type FileStorageOptions = {
|
|
@@ -23,4 +23,4 @@ declare abstract class FileStorageBase implements TFileStorage {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
export { FileStorageBase as F, type FileStorageOptions as a };
|
|
26
|
-
//# sourceMappingURL=index-
|
|
26
|
+
//# sourceMappingURL=index-rkqvel7o.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-rkqvel7o.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -205,9 +205,9 @@ declare class TQueryFilterBase {
|
|
|
205
205
|
isIntersect<T extends string>(key: PathName<T>, value: TValue[]): this;
|
|
206
206
|
every<T extends string>(key: PathName<T>, callback: (query: TQueryFilterBase) => void): this;
|
|
207
207
|
some<T extends string>(key: PathName<T>, callback: (query: TQueryFilterBase) => void): this;
|
|
208
|
-
and(...callbacks: (
|
|
209
|
-
or(...callbacks: (
|
|
210
|
-
nor(...callbacks: (
|
|
208
|
+
and(...callbacks: _.Many<(query: TQueryFilterBase) => void>[]): this;
|
|
209
|
+
or(...callbacks: _.Many<(query: TQueryFilterBase) => void>[]): this;
|
|
210
|
+
nor(...callbacks: _.Many<(query: TQueryFilterBase) => void>[]): this;
|
|
211
211
|
}
|
|
212
212
|
declare class TQueryBase extends TQueryFilterBase {
|
|
213
213
|
sort<T extends Record<string, 1 | -1>>(sort: PathNameMap<T> | TSortOption[]): this;
|
|
@@ -302,7 +302,6 @@ declare abstract class ProtoType<Ext> {
|
|
|
302
302
|
rebind<T extends TSerializable | undefined>(object: T): T;
|
|
303
303
|
Object<T extends string>(className: T, objectId?: string): TObjectType<T, Ext>;
|
|
304
304
|
File(filename: string, data: FileData, type?: string): TObjectType<"File", Ext>;
|
|
305
|
-
userRoles(user: TUser): Promise<TObjectType<"Role", Ext>[]>;
|
|
306
305
|
abstract notify(data: Record<string, _TValue> & {
|
|
307
306
|
_rperm?: string[];
|
|
308
307
|
}, options?: ExtraOptions<boolean>): Promise<void>;
|
|
@@ -323,6 +322,7 @@ interface ProtoType<Ext> {
|
|
|
323
322
|
session?: Session;
|
|
324
323
|
} & T>;
|
|
325
324
|
setSessionToken(token?: string): void;
|
|
325
|
+
userRoles(user: TUser): Promise<TRole[]>;
|
|
326
326
|
becomeUser(req: Request, user: TUser, options?: {
|
|
327
327
|
cookieOptions?: CookieOptions | undefined;
|
|
328
328
|
jwtSignOptions?: SignOptions | undefined;
|
|
@@ -535,7 +535,7 @@ type DecodedSortOption = {
|
|
|
535
535
|
order: 1 | -1;
|
|
536
536
|
};
|
|
537
537
|
type DecodedBaseQuery = Decoded<TQueryBaseOptions, {
|
|
538
|
-
filter
|
|
538
|
+
filter?: QuerySelector;
|
|
539
539
|
matches: Record<string, DecodedBaseQuery>;
|
|
540
540
|
sort?: Record<string, 1 | -1> | DecodedSortOption[];
|
|
541
541
|
}>;
|
|
@@ -545,6 +545,7 @@ type DecodedQuery<T> = Decoded<T, {
|
|
|
545
545
|
includes: string[];
|
|
546
546
|
objectIdSize: number;
|
|
547
547
|
sort?: Record<string, 1 | -1> | DecodedSortOption[];
|
|
548
|
+
extraFilter?: (className: string) => QuerySelector;
|
|
548
549
|
}>;
|
|
549
550
|
type InsertOptions = {
|
|
550
551
|
className: string;
|
|
@@ -605,6 +606,7 @@ interface TPubSub {
|
|
|
605
606
|
type ProtoServiceOptions<Ext> = {
|
|
606
607
|
endpoint: string;
|
|
607
608
|
schema: Record<string, TSchema>;
|
|
609
|
+
roleInheritKeys?: string[];
|
|
608
610
|
storage: TStorage;
|
|
609
611
|
fileStorage: TFileStorage;
|
|
610
612
|
pubsub?: TPubSub;
|
|
@@ -668,6 +670,7 @@ declare class ProtoService<Ext = any> extends ProtoType<Ext> {
|
|
|
668
670
|
}) => T)): Promise<this & {
|
|
669
671
|
session?: Session;
|
|
670
672
|
} & T>;
|
|
673
|
+
userRoles(user: TUser): Promise<TObjectType<"Role", Ext>[]>;
|
|
671
674
|
becomeUser(req: Request, user: TUser, options?: {
|
|
672
675
|
cookieOptions?: CookieOptions | undefined;
|
|
673
676
|
jwtSignOptions?: jwt.SignOptions | undefined;
|
|
@@ -713,7 +716,8 @@ declare class ProtoService<Ext = any> extends ProtoType<Ext> {
|
|
|
713
716
|
remove: VoidFunction;
|
|
714
717
|
};
|
|
715
718
|
refs(object: TObject, options?: ExtraOptions<boolean>): _o2ter_utils_js.AsyncStream<TObjectType<string, Ext>>;
|
|
719
|
+
gc(classNames?: string | string[]): Promise<void>;
|
|
716
720
|
}
|
|
717
721
|
|
|
718
722
|
export { type TPubSub as A, type TFileInfo as B, type DeserializeOptions as D, type ExtraOptions as E, type FindOptions as F, type InsertOptions as I, ProtoService as P, QuerySelector as Q, type RelationOptions as R, type SerializeOptions as S, TSchema as T, type _TValue as _, type ProtoServiceOptions as a, type ProtoServiceKeyOptions as b, type TFileStorage as c, type TSerializable as d, deserialize as e, type TExtensions as f, TQuery as g, TObject as h, TUser as i, TRole as j, TFile as k, ProtoType as l, type PathName as m, type TObjectType as n, type EventData as o, type DecodedQuery as p, type DecodedSortOption as q, type TValue as r, serialize as s, type FindOneOptions as t, type TUpdateOp as u, FieldSelectorExpression as v, QueryExpression as w, type TStorage as x, type TransactionOptions as y, type TQueryRandomOptions as z };
|
|
719
|
-
//# sourceMappingURL=index-
|
|
723
|
+
//# sourceMappingURL=index-y8EePsDY.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-y8EePsDY.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|