proto.io 0.0.224 → 0.0.226

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.
Files changed (62) hide show
  1. package/dist/adapters/file/aliyun-oss.d.ts +3 -3
  2. package/dist/adapters/file/aliyun-oss.d.ts.map +1 -1
  3. package/dist/adapters/file/aliyun-oss.js.map +1 -1
  4. package/dist/adapters/file/aliyun-oss.mjs.map +1 -1
  5. package/dist/adapters/file/database.d.ts +2 -2
  6. package/dist/adapters/file/database.d.ts.map +1 -1
  7. package/dist/adapters/file/database.js.map +1 -1
  8. package/dist/adapters/file/database.mjs +2 -2
  9. package/dist/adapters/file/database.mjs.map +1 -1
  10. package/dist/adapters/file/filesystem.d.ts +3 -3
  11. package/dist/adapters/file/filesystem.d.ts.map +1 -1
  12. package/dist/adapters/file/filesystem.js.map +1 -1
  13. package/dist/adapters/file/filesystem.mjs.map +1 -1
  14. package/dist/adapters/file/google-cloud-storage.d.ts +3 -3
  15. package/dist/adapters/file/google-cloud-storage.d.ts.map +1 -1
  16. package/dist/adapters/file/google-cloud-storage.js.map +1 -1
  17. package/dist/adapters/file/google-cloud-storage.mjs.map +1 -1
  18. package/dist/adapters/storage/progres.d.ts +1 -1
  19. package/dist/adapters/storage/progres.d.ts.map +1 -1
  20. package/dist/adapters/storage/progres.js +1 -1
  21. package/dist/adapters/storage/progres.js.map +1 -1
  22. package/dist/adapters/storage/progres.mjs +5 -5
  23. package/dist/adapters/storage/progres.mjs.map +1 -1
  24. package/dist/client.d.ts +3 -3
  25. package/dist/client.d.ts.map +1 -1
  26. package/dist/client.mjs +4 -4
  27. package/dist/index.d.ts +3 -3
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/index.js +43 -14
  30. package/dist/index.js.map +1 -1
  31. package/dist/index.mjs +48 -19
  32. package/dist/index.mjs.map +1 -1
  33. package/dist/internals/{base-NZIvB1zK.d.ts → base-DSo02iAX.d.ts} +4 -3
  34. package/dist/internals/base-DSo02iAX.d.ts.map +1 -0
  35. package/dist/internals/base-DYc1_peK.mjs.map +1 -1
  36. package/dist/internals/base-NsJYo2MG.js.map +1 -1
  37. package/dist/internals/{chunk-B9i8NMB_.d.ts → chunk-BhwfdCdq.d.ts} +3 -3
  38. package/dist/internals/chunk-BhwfdCdq.d.ts.map +1 -0
  39. package/dist/internals/chunk-BuKmyceG.js.map +1 -1
  40. package/dist/internals/chunk-bpt1C6W4.mjs.map +1 -1
  41. package/dist/internals/{const-DqPhhmor.mjs → const-68KwNmag.mjs} +2 -2
  42. package/dist/internals/{const-DqPhhmor.mjs.map → const-68KwNmag.mjs.map} +1 -1
  43. package/dist/internals/{index-BOboD1oK.d.ts → index-1ZK5N4yb.d.ts} +4 -3
  44. package/dist/internals/index-1ZK5N4yb.d.ts.map +1 -0
  45. package/dist/internals/{index-BZ79Ljis.mjs → index-BWZIV3_T.mjs} +4 -4
  46. package/dist/internals/{index-BZ79Ljis.mjs.map → index-BWZIV3_T.mjs.map} +1 -1
  47. package/dist/internals/index-CLKTEIj0.js.map +1 -1
  48. package/dist/internals/{index-gWcE22mf.mjs → index-CSOoWRr1.mjs} +2 -2
  49. package/dist/internals/{index-gWcE22mf.mjs.map → index-CSOoWRr1.mjs.map} +1 -1
  50. package/dist/internals/{index-BcNiVp-e.d.ts → index-Cj45GkKv.d.ts} +2 -2
  51. package/dist/internals/index-Cj45GkKv.d.ts.map +1 -0
  52. package/dist/internals/index-vOFh8pVc.js.map +1 -1
  53. package/dist/internals/random-CYjWDvex.mjs.map +1 -1
  54. package/dist/internals/random-nkOQ9U6S.js.map +1 -1
  55. package/dist/internals/validator-Bc1jRJfA.js.map +1 -1
  56. package/dist/internals/{validator-0I1kvhsL.mjs → validator-Boj1PUjM.mjs} +2 -2
  57. package/dist/internals/{validator-0I1kvhsL.mjs.map → validator-Boj1PUjM.mjs.map} +1 -1
  58. package/package.json +23 -23
  59. package/dist/internals/base-NZIvB1zK.d.ts.map +0 -1
  60. package/dist/internals/chunk-B9i8NMB_.d.ts.map +0 -1
  61. package/dist/internals/index-BOboD1oK.d.ts.map +0 -1
  62. package/dist/internals/index-BcNiVp-e.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index-CLKTEIj0.js","sources":["../../src/internals/schema.ts","../../src/internals/object/index.ts"],"sourcesContent":["//\n// schema.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 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 { TValueWithoutObject } from './types';\nimport { TQueryBaseOptions } from './query/base';\n\nexport namespace TSchema {\n /**\n * Access Control List (ACL).\n * \n * An array of strings representing users or roles that have access to a resource.\n */\n export type ACL = string[];\n\n /**\n * Access Control Lists for read and update operations.\n * \n * Defines separate ACLs for reading and updating an object.\n */\n export type ACLs = {\n /**\n * ACL for read operation.\n * Users or roles allowed to read the object.\n */\n read: TSchema.ACL;\n\n /**\n * ACL for update operation.\n * Users or roles allowed to update the object.\n */\n update: TSchema.ACL;\n };\n\n /**\n * Supported primitive data types.\n */\n export type Primitive =\n | 'boolean'\n | 'number'\n | 'decimal'\n | 'string'\n | 'string[]'\n | 'date'\n | 'object'\n | 'array';\n\n /**\n * Primitive type with optional default value.\n * \n * Can be a string literal (e.g., 'string') or an object specifying the type and a default value.\n */\n export type PrimitiveType =\n | Primitive\n | {\n /**\n * The primitive type.\n */\n type: Primitive;\n\n /**\n * Optional default value for the field.\n */\n default?: TValueWithoutObject;\n };\n\n /**\n * Vector type with a specified dimension and optional default value.\n * \n * Used for fields storing fixed-length numeric arrays (vectors).\n */\n export type VectorType = {\n /**\n * The type of the field. Always 'vector'.\n */\n type: 'vector';\n\n /**\n * The dimension (length) of the vector.\n */\n dimension: number;\n\n /**\n * Optional default value for the vector.\n */\n default?: number[];\n };\n\n /**\n * Shape type for nested objects.\n * \n * Allows defining complex, nested object structures with their own field types.\n */\n export type ShapeType = {\n /**\n * The type of the field. Always 'shape'.\n */\n type: 'shape';\n\n /**\n * The shape definition, mapping field names to their data types.\n */\n shape: Record<string, DataType>;\n };\n\n /**\n * Pointer type for referencing another class.\n * \n * Represents a one-to-one relationship to another object.\n */\n export type PointerType = {\n /**\n * The type of the field. Always 'pointer'.\n */\n type: 'pointer';\n\n /**\n * The name of the target class being referenced.\n */\n target: string;\n };\n\n /**\n * Relation type for referencing multiple objects in another class.\n * \n * Represents a one-to-many or many-to-many relationship.\n * - `target`: The related class name.\n * - `foreignField`: (Optional) The field in the target class that refers back to this class.\n * - `match`: (Optional) Default match query options (filter, sort, etc.) applied when querying this relation.\n * Only used if `foreignField` is set.\n */\n export type RelationType = {\n /**\n * The type of the field. Always 'relation'.\n */\n type: 'relation';\n\n /**\n * The name of the target class for this relation.\n */\n target: string;\n\n /**\n * (Optional) The field in the target class that refers back to this class.\n * If provided, the relation is managed via this foreign key.\n */\n foreignField?: string;\n\n /**\n * (Optional) Default match query options for this relation.\n * \n * These options define default query behaviors—such as filtering, sorting, limiting results, and other query parameters—\n * that will be automatically applied when querying this relation via the specified `foreignField`.\n * \n * Note: `match` is only applicable if `foreignField` is set. If `foreignField` is not provided, `match` will be ignored.\n */\n match?: TQueryBaseOptions;\n };\n\n /**\n * Data type for schema fields.\n * \n * Can be a primitive, vector, shape, pointer, or relation type.\n */\n export type DataType =\n | PrimitiveType\n | VectorType\n | ShapeType\n | PointerType\n | RelationType;\n\n /**\n * Class Level Permissions (CLPs).\n * \n * Defines access control for various operations at the class level.\n */\n export type CLPs = {\n /**\n * ACL for get (read single object) operation.\n */\n get?: TSchema.ACL;\n\n /**\n * ACL for find (query multiple objects) operation.\n */\n find?: TSchema.ACL;\n\n /**\n * ACL for count operation.\n */\n count?: TSchema.ACL;\n\n /**\n * ACL for create operation.\n */\n create?: TSchema.ACL;\n\n /**\n * ACL for update operation.\n */\n update?: TSchema.ACL;\n\n /**\n * ACL for delete operation.\n */\n delete?: TSchema.ACL;\n };\n\n /**\n * Field Level Permissions (FLPs).\n * \n * Defines access control for individual fields.\n */\n export type FLPs = {\n /**\n * ACL for reading the field.\n */\n read?: TSchema.ACL;\n\n /**\n * ACL for creating the field.\n */\n create?: TSchema.ACL;\n\n /**\n * ACL for updating the field.\n */\n update?: TSchema.ACL;\n };\n\n /**\n * Index definitions for the schema.\n * \n * Supports both basic and vector indexes.\n */\n export type Indexes = {\n /**\n * Type of the index. Default is 'basic'.\n */\n type?: 'basic';\n\n /**\n * Keys for the index, mapping field names to sort order (1 for ascending, -1 for descending).\n */\n keys: Record<string, 1 | -1>;\n\n /**\n * Whether the index is unique.\n */\n unique?: boolean;\n } | {\n /**\n * Type of the index. Must be 'vector' for vector indexes.\n */\n type: 'vector';\n\n /**\n * Keys for the vector index. Can be a single field or an array of fields.\n */\n keys: string | string[];\n\n /**\n * Method for the vector index. Supported: 'hnsw', 'ivfflat'.\n */\n method?: 'hnsw' | 'ivfflat';\n };\n}\n\nexport const _isTypeof = (x: TSchema.DataType, types: string | string[]) => {\n if (_.isString(x)) return _.includes(_.castArray(types), x);\n return _.includes(_.castArray(types), x.type);\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 /**\n * Fields of the schema, where each field is a data type.\n */\n fields: Record<string, TSchema.DataType>;\n\n /**\n * Class level permissions for the schema.\n */\n classLevelPermissions?: TSchema.CLPs;\n\n /**\n * Additional object permissions for the schema.\n */\n additionalObjectPermissions?: TSchema.ACLs;\n\n /**\n * Field level permissions for the schema, where each field can have its own permissions.\n */\n fieldLevelPermissions?: Record<string, TSchema.FLPs>;\n\n /**\n * Secure fields in the schema.\n */\n secureFields?: string[];\n\n /**\n * Indexes for the schema.\n */\n indexes?: TSchema.Indexes[];\n\n /**\n * Indicates if live query is enabled for the schema.\n */\n liveQuery?: boolean;\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: 'string[]',\n _wperm: 'string[]',\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 - 2025 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, TValueWithoutObject, TValueWithUndefined } from '../types';\nimport { TSchema, defaultObjectKeys, defaultObjectReadonlyKeys } from '../schema';\nimport { IncludePaths, PathName } from '../query/types';\nimport { TUpdateOp, TUpdateOpKeys } from './types';\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: TValueWithoutObject): TValueWithoutObject => {\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: TValueWithUndefined): TValueWithoutObject => {\n if (_.isNil(value)) return value ?? null;\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\n/**\n * Interface representing a object.\n */\nexport interface TObject {\n /**\n * Clones the object.\n * @returns A clone of the object.\n */\n clone(): this;\n\n /**\n * Gets a relation query for the specified key.\n * @param key - The key of the relation.\n * @returns A query object for the relation.\n */\n relation<T extends string>(key: PathName<T>): TQuery<string, any, boolean>;\n\n /**\n * Fetches the object with the specified keys included.\n * @param keys - The keys to include.\n * @param options - Additional options for the fetch operation.\n * @returns A promise that resolves to the fetched object.\n */\n fetchWithInclude<T extends _.RecursiveArray<string>>(keys: IncludePaths<T>, options?: ExtraOptions<boolean>): PromiseLike<this>;\n\n /**\n * Saves the object.\n * @param options - Additional options for the save operation.\n * @returns A promise that resolves to the saved object.\n */\n save(options?: ExtraOptions<boolean> & { cascadeSave?: boolean }): PromiseLike<this>;\n\n /**\n * Destroys the object.\n * @param options - Additional options for the destroy operation.\n * @returns A promise that resolves to the destroyed object.\n */\n destroy(options?: ExtraOptions<boolean>): PromiseLike<this>;\n}\n\n/**\n * Class representing a object.\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 /**\n * Gets the class name of the object.\n */\n get className(): string {\n return this[PVK].className;\n }\n\n /**\n * Gets the attributes of the object.\n */\n get attributes(): Record<string, TValue> {\n return cloneValue(this[PVK].attributes);\n }\n\n /**\n * Gets the object ID.\n */\n get id(): string | undefined {\n return this[PVK].attributes._id as string;\n }\n\n /**\n * Gets the creation date of the object.\n */\n get createdAt(): Date | undefined {\n return this[PVK].attributes._created_at as Date;\n }\n\n /**\n * Gets the last updated date of the object.\n */\n get updatedAt(): Date | undefined {\n return this[PVK].attributes._updated_at as Date;\n }\n\n /**\n * Gets the version number of the object.\n */\n get __v(): number {\n return this[PVK].attributes.__v as number;\n }\n\n /**\n * Gets the sequence number of the object.\n */\n get __i(): number {\n return this[PVK].attributes.__i as number;\n }\n\n /**\n * Gets the expiration date of the object.\n */\n get expiredAt(): Date | undefined {\n return this.get('_expired_at');\n }\n\n /**\n * Sets the expiration date of the object.\n * @param value - The expiration date.\n */\n set expiredAt(value: Date | undefined) {\n this.set('_expired_at', value);\n }\n\n /**\n * Gets the access control list (ACL) of the object.\n * @returns The ACL of the object.\n */\n acl(): TSchema.ACLs {\n return {\n read: this.get('_rperm') ?? ['*'],\n update: this.get('_wperm') ?? ['*'],\n };\n }\n\n /**\n * Sets the access control list (ACL) of the object.\n * @param value - The ACL to set.\n */\n setAcl(value: Partial<TSchema.ACLs>) {\n this.set('_rperm', value.read ?? ['*']);\n this.set('_wperm', value.update ?? ['*']);\n }\n\n /**\n * Sets the read access control list (ACL) of the object.\n * @param value - The read ACL to set.\n */\n setReadAcl(value: TSchema.ACL) {\n this.set('_rperm', value);\n }\n\n /**\n * Sets the write access control list (ACL) of the object.\n * @param value - The write ACL to set.\n */\n setWriteAcl(value: TSchema.ACL) {\n this.set('_wperm', value);\n }\n\n /**\n * Gets the keys of the object's attributes and mutated attributes.\n * @returns An array of keys.\n */\n keys(): string[] {\n return _.uniq([..._.keys(this[PVK].attributes), ..._.compact(_.map(_.keys(this[PVK].mutated), x => _.first(_.toPath(x))))]);\n }\n\n /**\n * Gets an iterator for the entries of the object's attributes.\n * @returns An iterator for the entries.\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 /**\n * Converts the object to a plain object.\n * @param replacer - An optional function to replace values during the conversion.\n * @returns The plain object representation of the object.\n */\n toObject(replacer?: (value: TObject) => any): any {\n const toObject = (value: TValue): any => {\n if (isPrimitiveValue(value)) return value;\n if (value instanceof TObject) return replacer?.(value) ?? value.toObject(replacer);\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 /**\n * Get the value of the attribute.\n * @param key - The key of the attribute.\n * @returns The value of the attribute.\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 /**\n * Set the value of the attribute.\n * @param key - The key of the attribute.\n * @param value - The value to set.\n */\n set<T extends string>(key: PathName<T>, value: TValueWithUndefined) {\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 /**\n * Is the object dirty.\n */\n get isDirty(): boolean {\n return !_.isEmpty(this[PVK].mutated);\n }\n\n /**\n * Increment the value of the attribute.\n * @param key - The key to increment.\n * @param value - The value to increment by.\n */\n increment<T extends string>(key: PathName<T>, value: number | Decimal) {\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 /**\n * Decrement the value of the attribute.\n * @param key - The key to decrement.\n * @param value - The value to decrement by.\n */\n decrement<T extends string>(key: PathName<T>, value: number | Decimal) {\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 /**\n * Multiplies the value of the specified attribute.\n * @param key - The key of the attribute to multiply.\n * @param value - The multiplier value.\n */\n multiply<T extends string>(key: PathName<T>, value: number | Decimal) {\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 /**\n * Divides the value of the specified attribute.\n * @param key - The key of the attribute to divide.\n * @param value - The divisor value.\n */\n divide<T extends string>(key: PathName<T>, value: number | Decimal) {\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 /**\n * Sets the value of the specified attribute to the maximum of the current value and the provided value.\n * @param key - The key of the attribute to compare.\n * @param value - The value to compare against.\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 /**\n * Sets the value of the specified attribute to the minimum of the current value and the provided value.\n * @param key - The key of the attribute to compare.\n * @param value - The value to compare against.\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 /**\n * Adds the specified values to the set of the specified attribute.\n * @param key - The key of the attribute.\n * @param values - The values to add to the set.\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 /**\n * Adds the values to the array of the attribute.\n * @param key - The key of the attribute.\n * @param values - The values to add.\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 /**\n * Removes the values from the array of the attribute.\n * @param key - The key of the attribute.\n * @param values - The values to remove.\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 /**\n * Removes the first elements from the array of the attribute.\n * @param key - The key of the attribute.\n * @param count - The number of elements to remove. Defaults to 1.\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 /**\n * Removes the last elements from the array of the attribute.\n * @param key - The key of the attribute.\n * @param count - The number of elements to remove. Defaults to 1.\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 /**\n * Fetches the object data.\n * @param options - Additional options for the fetch operation.\n * @returns A promise that resolves to the fetched object.\n */\n async fetch(options?: ExtraOptions<boolean>) {\n return this.fetchWithInclude(_.keys(this[PVK].attributes), options);\n }\n\n /**\n * Fetches the object data if needed.\n * @param keys - The keys of the attributes to fetch.\n * @param options - Additional options for the fetch operation.\n * @returns A promise that resolves to the fetched object.\n */\n async fetchIfNeeded<T extends _.RecursiveArray<string>>(keys: IncludePaths<T>, options?: ExtraOptions<boolean>) {\n const current = _.keys(this[PVK].attributes);\n if (_.every(keys, k => _.includes(current, k))) return this;\n return this.fetchWithInclude([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;MA2Qa,SAAS,GAAG,CAAC,CAAmB,EAAE,KAAwB,KAAI;AACzE,IAAA,IAAI,CAAC,CAAC,QAAQ,CAAC,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CAAC,MAAM,CAAC,GAAG,CAAC,CAAE,CAAC;YAAE;AACnE,QAAA,IAAI,CAACA,YAAG,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE;;AAG9C;;;;AAIG;IACH,MAAM,KAAK,CAAC,OAA+B,EAAA;AACzC,QAAA,OAAO,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAACA,YAAG,CAAC,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC;;AAGrE;;;;;AAKG;AACH,IAAA,MAAM,aAAa,CAAqC,IAAqB,EAAE,OAA+B,EAAA;AAC5G,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,OAAO,EAAE,IAAI,CAAC,EAAE,OAAO,CAAC;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index-CLKTEIj0.js","sources":["../../src/internals/schema.ts","../../src/internals/object/index.ts"],"sourcesContent":["//\n// schema.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 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 { TValueWithoutObject } from './types';\nimport { TQueryBaseOptions } from './query/base';\n\nexport namespace TSchema {\n /**\n * Access Control List (ACL).\n * \n * An array of strings representing users or roles that have access to a resource.\n */\n export type ACL = string[];\n\n /**\n * Access Control Lists for read and update operations.\n * \n * Defines separate ACLs for reading and updating an object.\n */\n export type ACLs = {\n /**\n * ACL for read operation.\n * Users or roles allowed to read the object.\n */\n read: TSchema.ACL;\n\n /**\n * ACL for update operation.\n * Users or roles allowed to update the object.\n */\n update: TSchema.ACL;\n };\n\n /**\n * Supported primitive data types.\n */\n export type Primitive =\n | 'boolean'\n | 'number'\n | 'decimal'\n | 'string'\n | 'string[]'\n | 'date'\n | 'object'\n | 'array';\n\n /**\n * Primitive type with optional default value.\n * \n * Can be a string literal (e.g., 'string') or an object specifying the type and a default value.\n */\n export type PrimitiveType =\n | Primitive\n | {\n /**\n * The primitive type.\n */\n type: Primitive;\n\n /**\n * Optional default value for the field.\n */\n default?: TValueWithoutObject;\n };\n\n /**\n * Vector type with a specified dimension and optional default value.\n * \n * Used for fields storing fixed-length numeric arrays (vectors).\n */\n export type VectorType = {\n /**\n * The type of the field. Always 'vector'.\n */\n type: 'vector';\n\n /**\n * The dimension (length) of the vector.\n */\n dimension: number;\n\n /**\n * Optional default value for the vector.\n */\n default?: number[];\n };\n\n /**\n * Shape type for nested objects.\n * \n * Allows defining complex, nested object structures with their own field types.\n */\n export type ShapeType = {\n /**\n * The type of the field. Always 'shape'.\n */\n type: 'shape';\n\n /**\n * The shape definition, mapping field names to their data types.\n */\n shape: Record<string, DataType>;\n };\n\n /**\n * Pointer type for referencing another class.\n * \n * Represents a one-to-one relationship to another object.\n */\n export type PointerType = {\n /**\n * The type of the field. Always 'pointer'.\n */\n type: 'pointer';\n\n /**\n * The name of the target class being referenced.\n */\n target: string;\n };\n\n /**\n * Relation type for referencing multiple objects in another class.\n * \n * Represents a one-to-many or many-to-many relationship.\n * - `target`: The related class name.\n * - `foreignField`: (Optional) The field in the target class that refers back to this class.\n * - `match`: (Optional) Default match query options (filter, sort, etc.) applied when querying this relation.\n * Only used if `foreignField` is set.\n */\n export type RelationType = {\n /**\n * The type of the field. Always 'relation'.\n */\n type: 'relation';\n\n /**\n * The name of the target class for this relation.\n */\n target: string;\n\n /**\n * (Optional) The field in the target class that refers back to this class.\n * If provided, the relation is managed via this foreign key.\n */\n foreignField?: string;\n\n /**\n * (Optional) Default match query options for this relation.\n * \n * These options define default query behaviors—such as filtering, sorting, limiting results, and other query parameters—\n * that will be automatically applied when querying this relation via the specified `foreignField`.\n * \n * Note: `match` is only applicable if `foreignField` is set. If `foreignField` is not provided, `match` will be ignored.\n */\n match?: TQueryBaseOptions;\n };\n\n /**\n * Data type for schema fields.\n * \n * Can be a primitive, vector, shape, pointer, or relation type.\n */\n export type DataType =\n | PrimitiveType\n | VectorType\n | ShapeType\n | PointerType\n | RelationType;\n\n /**\n * Class Level Permissions (CLPs).\n * \n * Defines access control for various operations at the class level.\n */\n export type CLPs = {\n /**\n * ACL for get (read single object) operation.\n */\n get?: TSchema.ACL;\n\n /**\n * ACL for find (query multiple objects) operation.\n */\n find?: TSchema.ACL;\n\n /**\n * ACL for count operation.\n */\n count?: TSchema.ACL;\n\n /**\n * ACL for create operation.\n */\n create?: TSchema.ACL;\n\n /**\n * ACL for update operation.\n */\n update?: TSchema.ACL;\n\n /**\n * ACL for delete operation.\n */\n delete?: TSchema.ACL;\n };\n\n /**\n * Field Level Permissions (FLPs).\n * \n * Defines access control for individual fields.\n */\n export type FLPs = {\n /**\n * ACL for reading the field.\n */\n read?: TSchema.ACL;\n\n /**\n * ACL for creating the field.\n */\n create?: TSchema.ACL;\n\n /**\n * ACL for updating the field.\n */\n update?: TSchema.ACL;\n };\n\n /**\n * Index definitions for the schema.\n * \n * Supports both basic and vector indexes.\n */\n export type Indexes = {\n /**\n * Type of the index. Default is 'basic'.\n */\n type?: 'basic';\n\n /**\n * Keys for the index, mapping field names to sort order (1 for ascending, -1 for descending).\n */\n keys: Record<string, 1 | -1>;\n\n /**\n * Whether the index is unique.\n */\n unique?: boolean;\n } | {\n /**\n * Type of the index. Must be 'vector' for vector indexes.\n */\n type: 'vector';\n\n /**\n * Keys for the vector index. Can be a single field or an array of fields.\n */\n keys: string | string[];\n\n /**\n * Method for the vector index. Supported: 'hnsw', 'ivfflat'.\n */\n method?: 'hnsw' | 'ivfflat';\n };\n}\n\nexport const _isTypeof = (x: TSchema.DataType, types: string | string[]) => {\n if (_.isString(x)) return _.includes(_.castArray(types), x);\n return _.includes(_.castArray(types), x.type);\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 /**\n * Fields of the schema, where each field is a data type.\n */\n fields: Record<string, TSchema.DataType>;\n\n /**\n * Class level permissions for the schema.\n */\n classLevelPermissions?: TSchema.CLPs;\n\n /**\n * Additional object permissions for the schema.\n */\n additionalObjectPermissions?: TSchema.ACLs;\n\n /**\n * Field level permissions for the schema, where each field can have its own permissions.\n */\n fieldLevelPermissions?: Record<string, TSchema.FLPs>;\n\n /**\n * Secure fields in the schema.\n */\n secureFields?: string[];\n\n /**\n * Indexes for the schema.\n */\n indexes?: TSchema.Indexes[];\n\n /**\n * Indicates if live query is enabled for the schema.\n */\n liveQuery?: boolean;\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: 'string[]',\n _wperm: 'string[]',\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 - 2025 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, TValueWithoutObject, TValueWithUndefined } from '../types';\nimport { TSchema, defaultObjectKeys, defaultObjectReadonlyKeys } from '../schema';\nimport { IncludePaths, PathName } from '../query/types';\nimport { TUpdateOp, TUpdateOpKeys } from './types';\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: TValueWithoutObject): TValueWithoutObject => {\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: TValueWithUndefined): TValueWithoutObject => {\n if (_.isNil(value)) return value ?? null;\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\n/**\n * Interface representing a object.\n */\nexport interface TObject {\n /**\n * Clones the object.\n * @returns A clone of the object.\n */\n clone(): this;\n\n /**\n * Gets a relation query for the specified key.\n * @param key - The key of the relation.\n * @returns A query object for the relation.\n */\n relation<T extends string>(key: PathName<T>): TQuery<string, any, boolean>;\n\n /**\n * Fetches the object with the specified keys included.\n * @param keys - The keys to include.\n * @param options - Additional options for the fetch operation.\n * @returns A promise that resolves to the fetched object.\n */\n fetchWithInclude<T extends _.RecursiveArray<string>>(keys: IncludePaths<T>, options?: ExtraOptions<boolean>): PromiseLike<this>;\n\n /**\n * Saves the object.\n * @param options - Additional options for the save operation.\n * @returns A promise that resolves to the saved object.\n */\n save(options?: ExtraOptions<boolean> & { cascadeSave?: boolean }): PromiseLike<this>;\n\n /**\n * Destroys the object.\n * @param options - Additional options for the destroy operation.\n * @returns A promise that resolves to the destroyed object.\n */\n destroy(options?: ExtraOptions<boolean>): PromiseLike<this>;\n}\n\n/**\n * Class representing a object.\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 /**\n * Gets the class name of the object.\n */\n get className(): string {\n return this[PVK].className;\n }\n\n /**\n * Gets the attributes of the object.\n */\n get attributes(): Record<string, TValue> {\n return cloneValue(this[PVK].attributes);\n }\n\n /**\n * Gets the object ID.\n */\n get id(): string | undefined {\n return this[PVK].attributes._id as string;\n }\n\n /**\n * Gets the creation date of the object.\n */\n get createdAt(): Date | undefined {\n return this[PVK].attributes._created_at as Date;\n }\n\n /**\n * Gets the last updated date of the object.\n */\n get updatedAt(): Date | undefined {\n return this[PVK].attributes._updated_at as Date;\n }\n\n /**\n * Gets the version number of the object.\n */\n get __v(): number {\n return this[PVK].attributes.__v as number;\n }\n\n /**\n * Gets the sequence number of the object.\n */\n get __i(): number {\n return this[PVK].attributes.__i as number;\n }\n\n /**\n * Gets the expiration date of the object.\n */\n get expiredAt(): Date | undefined {\n return this.get('_expired_at');\n }\n\n /**\n * Sets the expiration date of the object.\n * @param value - The expiration date.\n */\n set expiredAt(value: Date | undefined) {\n this.set('_expired_at', value);\n }\n\n /**\n * Gets the access control list (ACL) of the object.\n * @returns The ACL of the object.\n */\n acl(): TSchema.ACLs {\n return {\n read: this.get('_rperm') ?? ['*'],\n update: this.get('_wperm') ?? ['*'],\n };\n }\n\n /**\n * Sets the access control list (ACL) of the object.\n * @param value - The ACL to set.\n */\n setAcl(value: Partial<TSchema.ACLs>) {\n this.set('_rperm', value.read ?? ['*']);\n this.set('_wperm', value.update ?? ['*']);\n }\n\n /**\n * Sets the read access control list (ACL) of the object.\n * @param value - The read ACL to set.\n */\n setReadAcl(value: TSchema.ACL) {\n this.set('_rperm', value);\n }\n\n /**\n * Sets the write access control list (ACL) of the object.\n * @param value - The write ACL to set.\n */\n setWriteAcl(value: TSchema.ACL) {\n this.set('_wperm', value);\n }\n\n /**\n * Gets the keys of the object's attributes and mutated attributes.\n * @returns An array of keys.\n */\n keys(): string[] {\n return _.uniq([..._.keys(this[PVK].attributes), ..._.compact(_.map(_.keys(this[PVK].mutated), x => _.first(_.toPath(x))))]);\n }\n\n /**\n * Gets an iterator for the entries of the object's attributes.\n * @returns An iterator for the entries.\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 /**\n * Converts the object to a plain object.\n * @param replacer - An optional function to replace values during the conversion.\n * @returns The plain object representation of the object.\n */\n toObject(replacer?: (value: TObject) => any): any {\n const toObject = (value: TValue): any => {\n if (isPrimitiveValue(value)) return value;\n if (value instanceof TObject) return replacer?.(value) ?? value.toObject(replacer);\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 /**\n * Get the value of the attribute.\n * @param key - The key of the attribute.\n * @returns The value of the attribute.\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 /**\n * Set the value of the attribute.\n * @param key - The key of the attribute.\n * @param value - The value to set.\n */\n set<T extends string>(key: PathName<T>, value: TValueWithUndefined) {\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 /**\n * Is the object dirty.\n */\n get isDirty(): boolean {\n return !_.isEmpty(this[PVK].mutated);\n }\n\n /**\n * Increment the value of the attribute.\n * @param key - The key to increment.\n * @param value - The value to increment by.\n */\n increment<T extends string>(key: PathName<T>, value: number | Decimal) {\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 /**\n * Decrement the value of the attribute.\n * @param key - The key to decrement.\n * @param value - The value to decrement by.\n */\n decrement<T extends string>(key: PathName<T>, value: number | Decimal) {\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 /**\n * Multiplies the value of the specified attribute.\n * @param key - The key of the attribute to multiply.\n * @param value - The multiplier value.\n */\n multiply<T extends string>(key: PathName<T>, value: number | Decimal) {\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 /**\n * Divides the value of the specified attribute.\n * @param key - The key of the attribute to divide.\n * @param value - The divisor value.\n */\n divide<T extends string>(key: PathName<T>, value: number | Decimal) {\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 /**\n * Sets the value of the specified attribute to the maximum of the current value and the provided value.\n * @param key - The key of the attribute to compare.\n * @param value - The value to compare against.\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 /**\n * Sets the value of the specified attribute to the minimum of the current value and the provided value.\n * @param key - The key of the attribute to compare.\n * @param value - The value to compare against.\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 /**\n * Adds the specified values to the set of the specified attribute.\n * @param key - The key of the attribute.\n * @param values - The values to add to the set.\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 /**\n * Adds the values to the array of the attribute.\n * @param key - The key of the attribute.\n * @param values - The values to add.\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 /**\n * Removes the values from the array of the attribute.\n * @param key - The key of the attribute.\n * @param values - The values to remove.\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 /**\n * Removes the first elements from the array of the attribute.\n * @param key - The key of the attribute.\n * @param count - The number of elements to remove. Defaults to 1.\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 /**\n * Removes the last elements from the array of the attribute.\n * @param key - The key of the attribute.\n * @param count - The number of elements to remove. Defaults to 1.\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 /**\n * Fetches the object data.\n * @param options - Additional options for the fetch operation.\n * @returns A promise that resolves to the fetched object.\n */\n async fetch(options?: ExtraOptions<boolean>) {\n return this.fetchWithInclude(_.keys(this[PVK].attributes), options);\n }\n\n /**\n * Fetches the object data if needed.\n * @param keys - The keys of the attributes to fetch.\n * @param options - Additional options for the fetch operation.\n * @returns A promise that resolves to the fetched object.\n */\n async fetchIfNeeded<T extends _.RecursiveArray<string>>(keys: IncludePaths<T>, options?: ExtraOptions<boolean>) {\n const current = _.keys(this[PVK].attributes);\n if (_.every(keys, k => _.includes(current, k))) return this;\n return this.fetchWithInclude([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;MA2Qa,SAAS,GAAG,CAAC,CAAmB,EAAE,KAAwB,KAAI;AACzE,IAAA,IAAI,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;AAAE,QAAA,OAAO,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;AAC3D,IAAA,OAAO,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC;AAC/C;AACO,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,QAA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AAqB,EAAE,OAA+B,EAAA;AAC5G,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,OAAO,EAAE,IAAI,CAAC,EAAE,OAAO,CAAC;IACxD;;;;;;;;;;;;;;;;;;;;"}
@@ -480,5 +480,5 @@ class TObject {
480
480
  }
481
481
  }
482
482
 
483
- export { TObject as T, _encodeValue as _, isRelation as a, isShape as b, isPrimitive as c, defaultObjectKeyTypes as d, decodeUpdateOp as e, dimensionOf as f, _decodeValue as g, _typeof as h, isPointer as i, isVector as j, _isTypeof as k, isPrimitiveValue as l, isValue as m, shapePaths as s };
484
- //# sourceMappingURL=index-gWcE22mf.mjs.map
483
+ export { TObject as T, _decodeValue as _, isRelation as a, isShape as b, isPrimitive as c, defaultObjectKeyTypes as d, decodeUpdateOp as e, _encodeValue as f, dimensionOf as g, _typeof as h, isPointer as i, isVector as j, _isTypeof as k, isPrimitiveValue as l, isValue as m, shapePaths as s };
484
+ //# sourceMappingURL=index-CSOoWRr1.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index-gWcE22mf.mjs","sources":["../../src/internals/schema.ts","../../src/internals/object/index.ts"],"sourcesContent":["//\n// schema.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 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 { TValueWithoutObject } from './types';\nimport { TQueryBaseOptions } from './query/base';\n\nexport namespace TSchema {\n /**\n * Access Control List (ACL).\n * \n * An array of strings representing users or roles that have access to a resource.\n */\n export type ACL = string[];\n\n /**\n * Access Control Lists for read and update operations.\n * \n * Defines separate ACLs for reading and updating an object.\n */\n export type ACLs = {\n /**\n * ACL for read operation.\n * Users or roles allowed to read the object.\n */\n read: TSchema.ACL;\n\n /**\n * ACL for update operation.\n * Users or roles allowed to update the object.\n */\n update: TSchema.ACL;\n };\n\n /**\n * Supported primitive data types.\n */\n export type Primitive =\n | 'boolean'\n | 'number'\n | 'decimal'\n | 'string'\n | 'string[]'\n | 'date'\n | 'object'\n | 'array';\n\n /**\n * Primitive type with optional default value.\n * \n * Can be a string literal (e.g., 'string') or an object specifying the type and a default value.\n */\n export type PrimitiveType =\n | Primitive\n | {\n /**\n * The primitive type.\n */\n type: Primitive;\n\n /**\n * Optional default value for the field.\n */\n default?: TValueWithoutObject;\n };\n\n /**\n * Vector type with a specified dimension and optional default value.\n * \n * Used for fields storing fixed-length numeric arrays (vectors).\n */\n export type VectorType = {\n /**\n * The type of the field. Always 'vector'.\n */\n type: 'vector';\n\n /**\n * The dimension (length) of the vector.\n */\n dimension: number;\n\n /**\n * Optional default value for the vector.\n */\n default?: number[];\n };\n\n /**\n * Shape type for nested objects.\n * \n * Allows defining complex, nested object structures with their own field types.\n */\n export type ShapeType = {\n /**\n * The type of the field. Always 'shape'.\n */\n type: 'shape';\n\n /**\n * The shape definition, mapping field names to their data types.\n */\n shape: Record<string, DataType>;\n };\n\n /**\n * Pointer type for referencing another class.\n * \n * Represents a one-to-one relationship to another object.\n */\n export type PointerType = {\n /**\n * The type of the field. Always 'pointer'.\n */\n type: 'pointer';\n\n /**\n * The name of the target class being referenced.\n */\n target: string;\n };\n\n /**\n * Relation type for referencing multiple objects in another class.\n * \n * Represents a one-to-many or many-to-many relationship.\n * - `target`: The related class name.\n * - `foreignField`: (Optional) The field in the target class that refers back to this class.\n * - `match`: (Optional) Default match query options (filter, sort, etc.) applied when querying this relation.\n * Only used if `foreignField` is set.\n */\n export type RelationType = {\n /**\n * The type of the field. Always 'relation'.\n */\n type: 'relation';\n\n /**\n * The name of the target class for this relation.\n */\n target: string;\n\n /**\n * (Optional) The field in the target class that refers back to this class.\n * If provided, the relation is managed via this foreign key.\n */\n foreignField?: string;\n\n /**\n * (Optional) Default match query options for this relation.\n * \n * These options define default query behaviors—such as filtering, sorting, limiting results, and other query parameters—\n * that will be automatically applied when querying this relation via the specified `foreignField`.\n * \n * Note: `match` is only applicable if `foreignField` is set. If `foreignField` is not provided, `match` will be ignored.\n */\n match?: TQueryBaseOptions;\n };\n\n /**\n * Data type for schema fields.\n * \n * Can be a primitive, vector, shape, pointer, or relation type.\n */\n export type DataType =\n | PrimitiveType\n | VectorType\n | ShapeType\n | PointerType\n | RelationType;\n\n /**\n * Class Level Permissions (CLPs).\n * \n * Defines access control for various operations at the class level.\n */\n export type CLPs = {\n /**\n * ACL for get (read single object) operation.\n */\n get?: TSchema.ACL;\n\n /**\n * ACL for find (query multiple objects) operation.\n */\n find?: TSchema.ACL;\n\n /**\n * ACL for count operation.\n */\n count?: TSchema.ACL;\n\n /**\n * ACL for create operation.\n */\n create?: TSchema.ACL;\n\n /**\n * ACL for update operation.\n */\n update?: TSchema.ACL;\n\n /**\n * ACL for delete operation.\n */\n delete?: TSchema.ACL;\n };\n\n /**\n * Field Level Permissions (FLPs).\n * \n * Defines access control for individual fields.\n */\n export type FLPs = {\n /**\n * ACL for reading the field.\n */\n read?: TSchema.ACL;\n\n /**\n * ACL for creating the field.\n */\n create?: TSchema.ACL;\n\n /**\n * ACL for updating the field.\n */\n update?: TSchema.ACL;\n };\n\n /**\n * Index definitions for the schema.\n * \n * Supports both basic and vector indexes.\n */\n export type Indexes = {\n /**\n * Type of the index. Default is 'basic'.\n */\n type?: 'basic';\n\n /**\n * Keys for the index, mapping field names to sort order (1 for ascending, -1 for descending).\n */\n keys: Record<string, 1 | -1>;\n\n /**\n * Whether the index is unique.\n */\n unique?: boolean;\n } | {\n /**\n * Type of the index. Must be 'vector' for vector indexes.\n */\n type: 'vector';\n\n /**\n * Keys for the vector index. Can be a single field or an array of fields.\n */\n keys: string | string[];\n\n /**\n * Method for the vector index. Supported: 'hnsw', 'ivfflat'.\n */\n method?: 'hnsw' | 'ivfflat';\n };\n}\n\nexport const _isTypeof = (x: TSchema.DataType, types: string | string[]) => {\n if (_.isString(x)) return _.includes(_.castArray(types), x);\n return _.includes(_.castArray(types), x.type);\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 /**\n * Fields of the schema, where each field is a data type.\n */\n fields: Record<string, TSchema.DataType>;\n\n /**\n * Class level permissions for the schema.\n */\n classLevelPermissions?: TSchema.CLPs;\n\n /**\n * Additional object permissions for the schema.\n */\n additionalObjectPermissions?: TSchema.ACLs;\n\n /**\n * Field level permissions for the schema, where each field can have its own permissions.\n */\n fieldLevelPermissions?: Record<string, TSchema.FLPs>;\n\n /**\n * Secure fields in the schema.\n */\n secureFields?: string[];\n\n /**\n * Indexes for the schema.\n */\n indexes?: TSchema.Indexes[];\n\n /**\n * Indicates if live query is enabled for the schema.\n */\n liveQuery?: boolean;\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: 'string[]',\n _wperm: 'string[]',\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 - 2025 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, TValueWithoutObject, TValueWithUndefined } from '../types';\nimport { TSchema, defaultObjectKeys, defaultObjectReadonlyKeys } from '../schema';\nimport { IncludePaths, PathName } from '../query/types';\nimport { TUpdateOp, TUpdateOpKeys } from './types';\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: TValueWithoutObject): TValueWithoutObject => {\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: TValueWithUndefined): TValueWithoutObject => {\n if (_.isNil(value)) return value ?? null;\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\n/**\n * Interface representing a object.\n */\nexport interface TObject {\n /**\n * Clones the object.\n * @returns A clone of the object.\n */\n clone(): this;\n\n /**\n * Gets a relation query for the specified key.\n * @param key - The key of the relation.\n * @returns A query object for the relation.\n */\n relation<T extends string>(key: PathName<T>): TQuery<string, any, boolean>;\n\n /**\n * Fetches the object with the specified keys included.\n * @param keys - The keys to include.\n * @param options - Additional options for the fetch operation.\n * @returns A promise that resolves to the fetched object.\n */\n fetchWithInclude<T extends _.RecursiveArray<string>>(keys: IncludePaths<T>, options?: ExtraOptions<boolean>): PromiseLike<this>;\n\n /**\n * Saves the object.\n * @param options - Additional options for the save operation.\n * @returns A promise that resolves to the saved object.\n */\n save(options?: ExtraOptions<boolean> & { cascadeSave?: boolean }): PromiseLike<this>;\n\n /**\n * Destroys the object.\n * @param options - Additional options for the destroy operation.\n * @returns A promise that resolves to the destroyed object.\n */\n destroy(options?: ExtraOptions<boolean>): PromiseLike<this>;\n}\n\n/**\n * Class representing a object.\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 /**\n * Gets the class name of the object.\n */\n get className(): string {\n return this[PVK].className;\n }\n\n /**\n * Gets the attributes of the object.\n */\n get attributes(): Record<string, TValue> {\n return cloneValue(this[PVK].attributes);\n }\n\n /**\n * Gets the object ID.\n */\n get id(): string | undefined {\n return this[PVK].attributes._id as string;\n }\n\n /**\n * Gets the creation date of the object.\n */\n get createdAt(): Date | undefined {\n return this[PVK].attributes._created_at as Date;\n }\n\n /**\n * Gets the last updated date of the object.\n */\n get updatedAt(): Date | undefined {\n return this[PVK].attributes._updated_at as Date;\n }\n\n /**\n * Gets the version number of the object.\n */\n get __v(): number {\n return this[PVK].attributes.__v as number;\n }\n\n /**\n * Gets the sequence number of the object.\n */\n get __i(): number {\n return this[PVK].attributes.__i as number;\n }\n\n /**\n * Gets the expiration date of the object.\n */\n get expiredAt(): Date | undefined {\n return this.get('_expired_at');\n }\n\n /**\n * Sets the expiration date of the object.\n * @param value - The expiration date.\n */\n set expiredAt(value: Date | undefined) {\n this.set('_expired_at', value);\n }\n\n /**\n * Gets the access control list (ACL) of the object.\n * @returns The ACL of the object.\n */\n acl(): TSchema.ACLs {\n return {\n read: this.get('_rperm') ?? ['*'],\n update: this.get('_wperm') ?? ['*'],\n };\n }\n\n /**\n * Sets the access control list (ACL) of the object.\n * @param value - The ACL to set.\n */\n setAcl(value: Partial<TSchema.ACLs>) {\n this.set('_rperm', value.read ?? ['*']);\n this.set('_wperm', value.update ?? ['*']);\n }\n\n /**\n * Sets the read access control list (ACL) of the object.\n * @param value - The read ACL to set.\n */\n setReadAcl(value: TSchema.ACL) {\n this.set('_rperm', value);\n }\n\n /**\n * Sets the write access control list (ACL) of the object.\n * @param value - The write ACL to set.\n */\n setWriteAcl(value: TSchema.ACL) {\n this.set('_wperm', value);\n }\n\n /**\n * Gets the keys of the object's attributes and mutated attributes.\n * @returns An array of keys.\n */\n keys(): string[] {\n return _.uniq([..._.keys(this[PVK].attributes), ..._.compact(_.map(_.keys(this[PVK].mutated), x => _.first(_.toPath(x))))]);\n }\n\n /**\n * Gets an iterator for the entries of the object's attributes.\n * @returns An iterator for the entries.\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 /**\n * Converts the object to a plain object.\n * @param replacer - An optional function to replace values during the conversion.\n * @returns The plain object representation of the object.\n */\n toObject(replacer?: (value: TObject) => any): any {\n const toObject = (value: TValue): any => {\n if (isPrimitiveValue(value)) return value;\n if (value instanceof TObject) return replacer?.(value) ?? value.toObject(replacer);\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 /**\n * Get the value of the attribute.\n * @param key - The key of the attribute.\n * @returns The value of the attribute.\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 /**\n * Set the value of the attribute.\n * @param key - The key of the attribute.\n * @param value - The value to set.\n */\n set<T extends string>(key: PathName<T>, value: TValueWithUndefined) {\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 /**\n * Is the object dirty.\n */\n get isDirty(): boolean {\n return !_.isEmpty(this[PVK].mutated);\n }\n\n /**\n * Increment the value of the attribute.\n * @param key - The key to increment.\n * @param value - The value to increment by.\n */\n increment<T extends string>(key: PathName<T>, value: number | Decimal) {\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 /**\n * Decrement the value of the attribute.\n * @param key - The key to decrement.\n * @param value - The value to decrement by.\n */\n decrement<T extends string>(key: PathName<T>, value: number | Decimal) {\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 /**\n * Multiplies the value of the specified attribute.\n * @param key - The key of the attribute to multiply.\n * @param value - The multiplier value.\n */\n multiply<T extends string>(key: PathName<T>, value: number | Decimal) {\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 /**\n * Divides the value of the specified attribute.\n * @param key - The key of the attribute to divide.\n * @param value - The divisor value.\n */\n divide<T extends string>(key: PathName<T>, value: number | Decimal) {\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 /**\n * Sets the value of the specified attribute to the maximum of the current value and the provided value.\n * @param key - The key of the attribute to compare.\n * @param value - The value to compare against.\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 /**\n * Sets the value of the specified attribute to the minimum of the current value and the provided value.\n * @param key - The key of the attribute to compare.\n * @param value - The value to compare against.\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 /**\n * Adds the specified values to the set of the specified attribute.\n * @param key - The key of the attribute.\n * @param values - The values to add to the set.\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 /**\n * Adds the values to the array of the attribute.\n * @param key - The key of the attribute.\n * @param values - The values to add.\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 /**\n * Removes the values from the array of the attribute.\n * @param key - The key of the attribute.\n * @param values - The values to remove.\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 /**\n * Removes the first elements from the array of the attribute.\n * @param key - The key of the attribute.\n * @param count - The number of elements to remove. Defaults to 1.\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 /**\n * Removes the last elements from the array of the attribute.\n * @param key - The key of the attribute.\n * @param count - The number of elements to remove. Defaults to 1.\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 /**\n * Fetches the object data.\n * @param options - Additional options for the fetch operation.\n * @returns A promise that resolves to the fetched object.\n */\n async fetch(options?: ExtraOptions<boolean>) {\n return this.fetchWithInclude(_.keys(this[PVK].attributes), options);\n }\n\n /**\n * Fetches the object data if needed.\n * @param keys - The keys of the attributes to fetch.\n * @param options - Additional options for the fetch operation.\n * @returns A promise that resolves to the fetched object.\n */\n async fetchIfNeeded<T extends _.RecursiveArray<string>>(keys: IncludePaths<T>, options?: ExtraOptions<boolean>) {\n const current = _.keys(this[PVK].attributes);\n if (_.every(keys, k => _.includes(current, k))) return this;\n return this.fetchWithInclude([current, keys], options);\n }\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;MA2Qa,SAAS,GAAG,CAAC,CAAmB,EAAE,KAAwB,KAAI;AACzE,IAAA,IAAI,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;AAAE,QAAA,OAAO,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;AAC3D,IAAA,OAAO,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC;AAC/C;AACO,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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AAC,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,OAAO,EAAE,IAAI,CAAC,EAAE,OAAO,CAAC;;;;;;"}
1
+ {"version":3,"file":"index-CSOoWRr1.mjs","sources":["../../src/internals/schema.ts","../../src/internals/object/index.ts"],"sourcesContent":["//\n// schema.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 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 { TValueWithoutObject } from './types';\nimport { TQueryBaseOptions } from './query/base';\n\nexport namespace TSchema {\n /**\n * Access Control List (ACL).\n * \n * An array of strings representing users or roles that have access to a resource.\n */\n export type ACL = string[];\n\n /**\n * Access Control Lists for read and update operations.\n * \n * Defines separate ACLs for reading and updating an object.\n */\n export type ACLs = {\n /**\n * ACL for read operation.\n * Users or roles allowed to read the object.\n */\n read: TSchema.ACL;\n\n /**\n * ACL for update operation.\n * Users or roles allowed to update the object.\n */\n update: TSchema.ACL;\n };\n\n /**\n * Supported primitive data types.\n */\n export type Primitive =\n | 'boolean'\n | 'number'\n | 'decimal'\n | 'string'\n | 'string[]'\n | 'date'\n | 'object'\n | 'array';\n\n /**\n * Primitive type with optional default value.\n * \n * Can be a string literal (e.g., 'string') or an object specifying the type and a default value.\n */\n export type PrimitiveType =\n | Primitive\n | {\n /**\n * The primitive type.\n */\n type: Primitive;\n\n /**\n * Optional default value for the field.\n */\n default?: TValueWithoutObject;\n };\n\n /**\n * Vector type with a specified dimension and optional default value.\n * \n * Used for fields storing fixed-length numeric arrays (vectors).\n */\n export type VectorType = {\n /**\n * The type of the field. Always 'vector'.\n */\n type: 'vector';\n\n /**\n * The dimension (length) of the vector.\n */\n dimension: number;\n\n /**\n * Optional default value for the vector.\n */\n default?: number[];\n };\n\n /**\n * Shape type for nested objects.\n * \n * Allows defining complex, nested object structures with their own field types.\n */\n export type ShapeType = {\n /**\n * The type of the field. Always 'shape'.\n */\n type: 'shape';\n\n /**\n * The shape definition, mapping field names to their data types.\n */\n shape: Record<string, DataType>;\n };\n\n /**\n * Pointer type for referencing another class.\n * \n * Represents a one-to-one relationship to another object.\n */\n export type PointerType = {\n /**\n * The type of the field. Always 'pointer'.\n */\n type: 'pointer';\n\n /**\n * The name of the target class being referenced.\n */\n target: string;\n };\n\n /**\n * Relation type for referencing multiple objects in another class.\n * \n * Represents a one-to-many or many-to-many relationship.\n * - `target`: The related class name.\n * - `foreignField`: (Optional) The field in the target class that refers back to this class.\n * - `match`: (Optional) Default match query options (filter, sort, etc.) applied when querying this relation.\n * Only used if `foreignField` is set.\n */\n export type RelationType = {\n /**\n * The type of the field. Always 'relation'.\n */\n type: 'relation';\n\n /**\n * The name of the target class for this relation.\n */\n target: string;\n\n /**\n * (Optional) The field in the target class that refers back to this class.\n * If provided, the relation is managed via this foreign key.\n */\n foreignField?: string;\n\n /**\n * (Optional) Default match query options for this relation.\n * \n * These options define default query behaviors—such as filtering, sorting, limiting results, and other query parameters—\n * that will be automatically applied when querying this relation via the specified `foreignField`.\n * \n * Note: `match` is only applicable if `foreignField` is set. If `foreignField` is not provided, `match` will be ignored.\n */\n match?: TQueryBaseOptions;\n };\n\n /**\n * Data type for schema fields.\n * \n * Can be a primitive, vector, shape, pointer, or relation type.\n */\n export type DataType =\n | PrimitiveType\n | VectorType\n | ShapeType\n | PointerType\n | RelationType;\n\n /**\n * Class Level Permissions (CLPs).\n * \n * Defines access control for various operations at the class level.\n */\n export type CLPs = {\n /**\n * ACL for get (read single object) operation.\n */\n get?: TSchema.ACL;\n\n /**\n * ACL for find (query multiple objects) operation.\n */\n find?: TSchema.ACL;\n\n /**\n * ACL for count operation.\n */\n count?: TSchema.ACL;\n\n /**\n * ACL for create operation.\n */\n create?: TSchema.ACL;\n\n /**\n * ACL for update operation.\n */\n update?: TSchema.ACL;\n\n /**\n * ACL for delete operation.\n */\n delete?: TSchema.ACL;\n };\n\n /**\n * Field Level Permissions (FLPs).\n * \n * Defines access control for individual fields.\n */\n export type FLPs = {\n /**\n * ACL for reading the field.\n */\n read?: TSchema.ACL;\n\n /**\n * ACL for creating the field.\n */\n create?: TSchema.ACL;\n\n /**\n * ACL for updating the field.\n */\n update?: TSchema.ACL;\n };\n\n /**\n * Index definitions for the schema.\n * \n * Supports both basic and vector indexes.\n */\n export type Indexes = {\n /**\n * Type of the index. Default is 'basic'.\n */\n type?: 'basic';\n\n /**\n * Keys for the index, mapping field names to sort order (1 for ascending, -1 for descending).\n */\n keys: Record<string, 1 | -1>;\n\n /**\n * Whether the index is unique.\n */\n unique?: boolean;\n } | {\n /**\n * Type of the index. Must be 'vector' for vector indexes.\n */\n type: 'vector';\n\n /**\n * Keys for the vector index. Can be a single field or an array of fields.\n */\n keys: string | string[];\n\n /**\n * Method for the vector index. Supported: 'hnsw', 'ivfflat'.\n */\n method?: 'hnsw' | 'ivfflat';\n };\n}\n\nexport const _isTypeof = (x: TSchema.DataType, types: string | string[]) => {\n if (_.isString(x)) return _.includes(_.castArray(types), x);\n return _.includes(_.castArray(types), x.type);\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 /**\n * Fields of the schema, where each field is a data type.\n */\n fields: Record<string, TSchema.DataType>;\n\n /**\n * Class level permissions for the schema.\n */\n classLevelPermissions?: TSchema.CLPs;\n\n /**\n * Additional object permissions for the schema.\n */\n additionalObjectPermissions?: TSchema.ACLs;\n\n /**\n * Field level permissions for the schema, where each field can have its own permissions.\n */\n fieldLevelPermissions?: Record<string, TSchema.FLPs>;\n\n /**\n * Secure fields in the schema.\n */\n secureFields?: string[];\n\n /**\n * Indexes for the schema.\n */\n indexes?: TSchema.Indexes[];\n\n /**\n * Indicates if live query is enabled for the schema.\n */\n liveQuery?: boolean;\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: 'string[]',\n _wperm: 'string[]',\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 - 2025 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, TValueWithoutObject, TValueWithUndefined } from '../types';\nimport { TSchema, defaultObjectKeys, defaultObjectReadonlyKeys } from '../schema';\nimport { IncludePaths, PathName } from '../query/types';\nimport { TUpdateOp, TUpdateOpKeys } from './types';\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: TValueWithoutObject): TValueWithoutObject => {\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: TValueWithUndefined): TValueWithoutObject => {\n if (_.isNil(value)) return value ?? null;\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\n/**\n * Interface representing a object.\n */\nexport interface TObject {\n /**\n * Clones the object.\n * @returns A clone of the object.\n */\n clone(): this;\n\n /**\n * Gets a relation query for the specified key.\n * @param key - The key of the relation.\n * @returns A query object for the relation.\n */\n relation<T extends string>(key: PathName<T>): TQuery<string, any, boolean>;\n\n /**\n * Fetches the object with the specified keys included.\n * @param keys - The keys to include.\n * @param options - Additional options for the fetch operation.\n * @returns A promise that resolves to the fetched object.\n */\n fetchWithInclude<T extends _.RecursiveArray<string>>(keys: IncludePaths<T>, options?: ExtraOptions<boolean>): PromiseLike<this>;\n\n /**\n * Saves the object.\n * @param options - Additional options for the save operation.\n * @returns A promise that resolves to the saved object.\n */\n save(options?: ExtraOptions<boolean> & { cascadeSave?: boolean }): PromiseLike<this>;\n\n /**\n * Destroys the object.\n * @param options - Additional options for the destroy operation.\n * @returns A promise that resolves to the destroyed object.\n */\n destroy(options?: ExtraOptions<boolean>): PromiseLike<this>;\n}\n\n/**\n * Class representing a object.\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 /**\n * Gets the class name of the object.\n */\n get className(): string {\n return this[PVK].className;\n }\n\n /**\n * Gets the attributes of the object.\n */\n get attributes(): Record<string, TValue> {\n return cloneValue(this[PVK].attributes);\n }\n\n /**\n * Gets the object ID.\n */\n get id(): string | undefined {\n return this[PVK].attributes._id as string;\n }\n\n /**\n * Gets the creation date of the object.\n */\n get createdAt(): Date | undefined {\n return this[PVK].attributes._created_at as Date;\n }\n\n /**\n * Gets the last updated date of the object.\n */\n get updatedAt(): Date | undefined {\n return this[PVK].attributes._updated_at as Date;\n }\n\n /**\n * Gets the version number of the object.\n */\n get __v(): number {\n return this[PVK].attributes.__v as number;\n }\n\n /**\n * Gets the sequence number of the object.\n */\n get __i(): number {\n return this[PVK].attributes.__i as number;\n }\n\n /**\n * Gets the expiration date of the object.\n */\n get expiredAt(): Date | undefined {\n return this.get('_expired_at');\n }\n\n /**\n * Sets the expiration date of the object.\n * @param value - The expiration date.\n */\n set expiredAt(value: Date | undefined) {\n this.set('_expired_at', value);\n }\n\n /**\n * Gets the access control list (ACL) of the object.\n * @returns The ACL of the object.\n */\n acl(): TSchema.ACLs {\n return {\n read: this.get('_rperm') ?? ['*'],\n update: this.get('_wperm') ?? ['*'],\n };\n }\n\n /**\n * Sets the access control list (ACL) of the object.\n * @param value - The ACL to set.\n */\n setAcl(value: Partial<TSchema.ACLs>) {\n this.set('_rperm', value.read ?? ['*']);\n this.set('_wperm', value.update ?? ['*']);\n }\n\n /**\n * Sets the read access control list (ACL) of the object.\n * @param value - The read ACL to set.\n */\n setReadAcl(value: TSchema.ACL) {\n this.set('_rperm', value);\n }\n\n /**\n * Sets the write access control list (ACL) of the object.\n * @param value - The write ACL to set.\n */\n setWriteAcl(value: TSchema.ACL) {\n this.set('_wperm', value);\n }\n\n /**\n * Gets the keys of the object's attributes and mutated attributes.\n * @returns An array of keys.\n */\n keys(): string[] {\n return _.uniq([..._.keys(this[PVK].attributes), ..._.compact(_.map(_.keys(this[PVK].mutated), x => _.first(_.toPath(x))))]);\n }\n\n /**\n * Gets an iterator for the entries of the object's attributes.\n * @returns An iterator for the entries.\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 /**\n * Converts the object to a plain object.\n * @param replacer - An optional function to replace values during the conversion.\n * @returns The plain object representation of the object.\n */\n toObject(replacer?: (value: TObject) => any): any {\n const toObject = (value: TValue): any => {\n if (isPrimitiveValue(value)) return value;\n if (value instanceof TObject) return replacer?.(value) ?? value.toObject(replacer);\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 /**\n * Get the value of the attribute.\n * @param key - The key of the attribute.\n * @returns The value of the attribute.\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 /**\n * Set the value of the attribute.\n * @param key - The key of the attribute.\n * @param value - The value to set.\n */\n set<T extends string>(key: PathName<T>, value: TValueWithUndefined) {\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 /**\n * Is the object dirty.\n */\n get isDirty(): boolean {\n return !_.isEmpty(this[PVK].mutated);\n }\n\n /**\n * Increment the value of the attribute.\n * @param key - The key to increment.\n * @param value - The value to increment by.\n */\n increment<T extends string>(key: PathName<T>, value: number | Decimal) {\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 /**\n * Decrement the value of the attribute.\n * @param key - The key to decrement.\n * @param value - The value to decrement by.\n */\n decrement<T extends string>(key: PathName<T>, value: number | Decimal) {\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 /**\n * Multiplies the value of the specified attribute.\n * @param key - The key of the attribute to multiply.\n * @param value - The multiplier value.\n */\n multiply<T extends string>(key: PathName<T>, value: number | Decimal) {\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 /**\n * Divides the value of the specified attribute.\n * @param key - The key of the attribute to divide.\n * @param value - The divisor value.\n */\n divide<T extends string>(key: PathName<T>, value: number | Decimal) {\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 /**\n * Sets the value of the specified attribute to the maximum of the current value and the provided value.\n * @param key - The key of the attribute to compare.\n * @param value - The value to compare against.\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 /**\n * Sets the value of the specified attribute to the minimum of the current value and the provided value.\n * @param key - The key of the attribute to compare.\n * @param value - The value to compare against.\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 /**\n * Adds the specified values to the set of the specified attribute.\n * @param key - The key of the attribute.\n * @param values - The values to add to the set.\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 /**\n * Adds the values to the array of the attribute.\n * @param key - The key of the attribute.\n * @param values - The values to add.\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 /**\n * Removes the values from the array of the attribute.\n * @param key - The key of the attribute.\n * @param values - The values to remove.\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 /**\n * Removes the first elements from the array of the attribute.\n * @param key - The key of the attribute.\n * @param count - The number of elements to remove. Defaults to 1.\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 /**\n * Removes the last elements from the array of the attribute.\n * @param key - The key of the attribute.\n * @param count - The number of elements to remove. Defaults to 1.\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 /**\n * Fetches the object data.\n * @param options - Additional options for the fetch operation.\n * @returns A promise that resolves to the fetched object.\n */\n async fetch(options?: ExtraOptions<boolean>) {\n return this.fetchWithInclude(_.keys(this[PVK].attributes), options);\n }\n\n /**\n * Fetches the object data if needed.\n * @param keys - The keys of the attributes to fetch.\n * @param options - Additional options for the fetch operation.\n * @returns A promise that resolves to the fetched object.\n */\n async fetchIfNeeded<T extends _.RecursiveArray<string>>(keys: IncludePaths<T>, options?: ExtraOptions<boolean>) {\n const current = _.keys(this[PVK].attributes);\n if (_.every(keys, k => _.includes(current, k))) return this;\n return this.fetchWithInclude([current, keys], options);\n }\n\n}\n"],"names":[],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA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AC,GAAG,CAAC,GAAG,EAAE,SAAS,EAAE,KAAK,EAAE;IAC/C;AAEA;;;;AAIG;AACH,IAAA,OAAO,CAAmB,GAAgB,EAAE,KAAK,GAAG,CAAC,EAAA;AACnD,QAAA,IAAI,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC;AAAE,YAAA,MAAM,KAAK,CAAC,aAAa,CAAC;AAC9C,QAAA,IAAI,OAAO,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAE,CAAC;YAAE;AACnE,QAAA,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE;IAC9C;AAEA;;;;AAIG;IACH,MAAM,KAAK,CAAC,OAA+B,EAAA;AACzC,QAAA,OAAO,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrE;AAEA;;;;;AAKG;AACH,IAAA,MAAM,aAAa,CAAqC,IAAqB,EAAE,OAA+B,EAAA;AAC5G,QAAA,MAAM,OAAO,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,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,OAAO,EAAE,IAAI,CAAC,EAAE,OAAO,CAAC;IACxD;;;;;"}
@@ -1,4 +1,4 @@
1
- import { h as TExtensions, E as ExtraOptions, S as SerializeOptions, i as ProtoType, j as TQuery, k as TObject, l as PathName, a as TValueWithoutObject, f as TSerializable, m as TObjectType, n as TUser, T as TSchema, o as EventData, p as TQuerySelector } from './index-BOboD1oK.js';
1
+ import { h as TExtensions, E as ExtraOptions, S as SerializeOptions, i as ProtoType, j as TQuery, k as TObject, l as PathName, c as TValueWithoutObject, f as TSerializable, m as TObjectType, n as TUser, T as TSchema, o as EventData, p as TQuerySelector } from './index-1ZK5N4yb.js';
2
2
  import * as _o2ter_utils_js from '@o2ter/utils-js';
3
3
  import * as socket_io_client from 'socket.io-client';
4
4
  import * as _socket_io_component_emitter from '@socket.io/component-emitter';
@@ -89,4 +89,4 @@ declare class ProtoClient<Ext = any> extends ProtoType<Ext> {
89
89
  }
90
90
 
91
91
  export { ProtoClient as P, classExtends as c };
92
- //# sourceMappingURL=index-BcNiVp-e.d.ts.map
92
+ //# sourceMappingURL=index-Cj45GkKv.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-Cj45GkKv.d.ts","sources":["../../src/internals/utils.ts","../../src/client/options.ts","../../src/client/proto/types.ts","../../src/client/proto/index.ts"],"sourcesContent":["//\n// index.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 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 './object';\nimport { TFile } from './object/file';\nimport { TJob } from './object/job';\nimport { TRole } from './object/role';\nimport { TExtensions } from './object/types';\nimport { TUser } from './object/user';\nimport { TQuery } from './query';\n\nexport const isObjKey = <T extends object>(key: PropertyKey, obj: T): key is keyof T => key in obj;\n\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\nexport const isJob = (x: any): x is TJob => {\n return x instanceof TJob;\n}\n","//\n// options.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 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 { SerializeOptions } from '../internals/codec';\nimport { ExtraOptions } from '../internals/options';\n\nexport type RequestOptions<M extends boolean> = ExtraOptions<M> & {\n serializeOpts?: SerializeOptions;\n};\n","//\n// types.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 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 { TExtensions } from '../../internals/object/types';\n\n/**\n * Options for configuring Axios requests.\n */\nexport type AxiosOptions = {\n /**\n * The name of the XSRF cookie.\n */\n xsrfCookieName?: string;\n\n /**\n * The name of the XSRF header.\n */\n xsrfHeaderName?: string;\n\n /**\n * The limit for retry attempts.\n */\n retryLimit?: number;\n\n /**\n * The key for storing cookies.\n */\n cookieKey?: string;\n};\n\n/**\n * Options for configuring the Proto client.\n */\nexport type ProtoOptions<Ext> = {\n /**\n * The endpoint URL for the Proto client.\n */\n endpoint: string;\n\n /**\n * The socket endpoint URL for the Proto client.\n */\n socketEndpoint?: string;\n\n /**\n * The master user credentials.\n */\n masterUser?: { user: string; pass: string; };\n\n /**\n * The class extensions.\n */\n classExtends?: TExtensions<Ext>;\n\n /**\n * The Axios configuration options.\n */\n axiosOptions?: AxiosOptions;\n};\n","//\n// index.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 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 '../../internals/codec';\nimport { EventData, ProtoType } from '../../internals/proto';\nimport { TQuery } from '../../internals/query';\nimport { PVK } from '../../internals/private';\nimport { TValueWithoutObject } from '../../internals/types';\nimport { TUser } from '../../internals/object/user';\nimport { TObject } from '../../internals/object';\nimport { PathName } from '../../internals/query/types';\nimport { TQuerySelector } from '../../internals/query/types/selectors';\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 id = object.id;\n if (!id) throw Error('Invalid object');\n return new ProtoClientRelationQuery<Ext>(this, {\n relatedBy: {\n className: object.className,\n id,\n key,\n },\n });\n }\n\n config(options?: RequestOptions<boolean>): Promise<Record<string, TValueWithoutObject>> {\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, TValueWithoutObject>, 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<R extends TSerializable | void = any>(\n name: string,\n data?: TSerializable,\n options?: RequestOptions<boolean>\n ) {\n return this[PVK].request(this, data, {\n method: 'post',\n url: `functions/${encodeURIComponent(name)}`,\n ...(options ?? {})\n }) as Promise<R>;\n }\n\n scheduleJob(\n name: string,\n data?: TValueWithoutObject,\n options?: RequestOptions<boolean>\n ) {\n return this[PVK].request(this, data, {\n method: 'post',\n url: `jobs/${encodeURIComponent(name)}`,\n ...(options ?? {})\n }) as any;\n }\n\n refreshSocketSession() {\n this[PVK].refreshSocketSession();\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, TValueWithoutObject> & { _rperm?: string[]; }, options?: RequestOptions<boolean>) {\n return this[PVK].notify(this, data, options);\n }\n\n listen(\n callback: (data: EventData) => void,\n selector?: TQuerySelector\n ) {\n return this[PVK].listen(this, callback, selector);\n }\n\n refs(object: TObject, options?: RequestOptions<boolean>) {\n return this[PVK].refs(this, object, options);\n }\n}\n"],"names":[],"mappings":";;;;;AAQO;;ACNA;AACP;AACA;;ACHA;AACA;AACA;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACvCO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;"}