@routier/core 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/{readme.md → README.md} +2 -2
- package/dist/assertions/index.cjs +191 -0
- package/dist/assertions/index.cjs.map +1 -0
- package/dist/assertions/index.d.ts +30 -0
- package/dist/assertions/index.js +94 -30
- package/dist/assertions/index.js.map +1 -1
- package/dist/capabilities/index.cjs +820 -0
- package/dist/capabilities/index.cjs.map +1 -0
- package/dist/capabilities/index.js +580 -545
- package/dist/capabilities/index.js.map +1 -1
- package/dist/codegen/handlers/CloneHandlerBuilder.d.ts +10 -1
- package/dist/codegen/handlers/SetHandlerBuilder.d.ts +4 -0
- package/dist/codegen/handlers/clone/CloneArrayHandler.d.ts +3 -0
- package/dist/codegen/handlers/clone/CloneDateHandler.d.ts +13 -0
- package/dist/codegen/handlers/clone/CloneValueHandler.d.ts +16 -0
- package/dist/codegen/handlers/compare/CompareComputedHandler.d.ts +10 -0
- package/dist/codegen/handlers/compare/CompareFunctionHandler.d.ts +10 -0
- package/dist/codegen/handlers/deserialize/DeserializeArrayHandler.d.ts +14 -0
- package/dist/codegen/handlers/enableChangeTracking/EnableChangeTrackingArrayHandler.d.ts +11 -0
- package/dist/codegen/handlers/enrichment/EnrichmentArrayHandler.d.ts +11 -0
- package/dist/codegen/handlers/freeze/FreezeArrayHandler.d.ts +6 -0
- package/dist/codegen/handlers/hash/HashArrayHandler.d.ts +10 -0
- package/dist/codegen/handlers/hash/HashFileHandler.d.ts +24 -0
- package/dist/codegen/handlers/hash/HashObjectHandler.d.ts +10 -0
- package/dist/codegen/handlers/hash/HashTransformHandler.d.ts +23 -0
- package/dist/codegen/handlers/index.d.ts +1 -0
- package/dist/codegen/handlers/merge/MergeArrayHandler.d.ts +20 -0
- package/dist/codegen/handlers/merge/MergeObjectHandler.d.ts +10 -0
- package/dist/codegen/handlers/serialize/SerializeArrayHandler.d.ts +19 -0
- package/dist/codegen/handlers/serialize/SerializeComputedHandler.d.ts +6 -0
- package/dist/codegen/handlers/set/SetComplexHandler.d.ts +6 -0
- package/dist/codegen/handlers/strip/StripComputedHandler.d.ts +10 -0
- package/dist/codegen/handlers/strip/StripFunctionHandler.d.ts +9 -0
- package/dist/codegen/handlers/types.d.ts +55 -1
- package/dist/codegen/index.cjs +618 -0
- package/dist/codegen/index.cjs.map +1 -0
- package/dist/codegen/index.js +100 -127
- package/dist/codegen/index.js.map +1 -1
- package/dist/collections/Changes.d.ts +2 -2
- package/dist/collections/MemoryDataCollection.d.ts +15 -1
- package/dist/collections/TagCollection.d.ts +7 -8
- package/dist/collections/index.cjs +702 -0
- package/dist/collections/index.cjs.map +1 -0
- package/dist/collections/index.js +282 -276
- package/dist/collections/index.js.map +1 -1
- package/dist/errors/OptimisticConcurrencyError.d.ts +18 -0
- package/dist/errors/PluginDestroyedError.d.ts +10 -0
- package/dist/errors/index.cjs +132 -0
- package/dist/errors/index.cjs.map +1 -0
- package/dist/errors/index.d.ts +2 -0
- package/dist/errors/index.js +61 -19
- package/dist/errors/index.js.map +1 -1
- package/dist/expressions/constants.d.ts +2 -0
- package/dist/expressions/evaluate.d.ts +53 -0
- package/dist/expressions/index.cjs +2087 -0
- package/dist/expressions/index.cjs.map +1 -0
- package/dist/expressions/index.d.ts +2 -0
- package/dist/expressions/index.js +1784 -772
- package/dist/expressions/index.js.map +1 -1
- package/dist/expressions/parser.d.ts +19 -0
- package/dist/expressions/types.d.ts +87 -2
- package/dist/expressions/utils.d.ts +1 -2
- package/dist/index.cjs +13925 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.js +12094 -7049
- package/dist/index.js.map +1 -1
- package/dist/performance/index.cjs +217 -0
- package/dist/performance/index.cjs.map +1 -0
- package/dist/performance/index.js +126 -50
- package/dist/performance/index.js.map +1 -1
- package/dist/pipeline/index.cjs +576 -0
- package/dist/pipeline/index.cjs.map +1 -0
- package/dist/pipeline/index.js +229 -156
- package/dist/pipeline/index.js.map +1 -1
- package/dist/plugins/BatchingDbPlugin.d.ts +139 -0
- package/dist/plugins/CacheDbPlugin.d.ts +70 -0
- package/dist/plugins/ConcurrencyDbPlugin.d.ts +78 -0
- package/dist/plugins/EphemeralDataPlugin.d.ts +57 -1
- package/dist/plugins/RetryDbPlugin.d.ts +77 -0
- package/dist/plugins/index.cjs +6104 -0
- package/dist/plugins/index.cjs.map +1 -0
- package/dist/plugins/index.d.ts +5 -1
- package/dist/plugins/index.js +5572 -1491
- package/dist/plugins/index.js.map +1 -1
- package/dist/plugins/query/QueryOptionsCollection.d.ts +22 -0
- package/dist/plugins/query/index.d.ts +2 -0
- package/dist/plugins/query/join.d.ts +210 -0
- package/dist/plugins/query/similarity.d.ts +38 -0
- package/dist/plugins/query/types.d.ts +64 -1
- package/dist/plugins/translators/DataTranslator.d.ts +28 -0
- package/dist/plugins/translators/JsonTranslator.d.ts +27 -0
- package/dist/plugins/translators/SqlTranslator.d.ts +45 -0
- package/dist/plugins/translators/TranslatedArrayValue.d.ts +3 -1
- package/dist/plugins/translators/TranslatedGroupValue.d.ts +3 -1
- package/dist/plugins/translators/TranslatedSingleValue.d.ts +3 -1
- package/dist/plugins/translators/TupleTranslator.d.ts +45 -0
- package/dist/plugins/translators/index.d.ts +1 -0
- package/dist/plugins/translators/types.d.ts +8 -1
- package/dist/plugins/types.d.ts +87 -11
- package/dist/plugins/wire/handler.d.ts +122 -0
- package/dist/plugins/wire/index.d.ts +4 -0
- package/dist/plugins/wire/persist.d.ts +43 -0
- package/dist/plugins/wire/query.d.ts +49 -0
- package/dist/plugins/wire/types.d.ts +123 -0
- package/dist/results/Result.d.ts +2 -2
- package/dist/results/index.cjs +174 -0
- package/dist/results/index.cjs.map +1 -0
- package/dist/results/index.js +29 -44
- package/dist/results/index.js.map +1 -1
- package/dist/schema/PropertyInfo.d.ts +35 -2
- package/dist/schema/SchemaDefinition.d.ts +51 -1
- package/dist/schema/builder.d.ts +35 -1
- package/dist/schema/communication/broadcast.d.ts +17 -1
- package/dist/schema/index.cjs +6911 -0
- package/dist/schema/index.cjs.map +1 -0
- package/dist/schema/index.d.ts +4 -0
- package/dist/schema/index.js +5781 -3973
- package/dist/schema/index.js.map +1 -1
- package/dist/schema/property/base/SchemaBase.d.ts +50 -2
- package/dist/schema/property/modifiers/SchemaDeserialize.d.ts +5 -1
- package/dist/schema/property/modifiers/SchemaForeignKey.d.ts +15 -0
- package/dist/schema/property/modifiers/SchemaKey.d.ts +2 -0
- package/dist/schema/property/modifiers/SchemaNullable.d.ts +15 -1
- package/dist/schema/property/modifiers/SchemaOptional.d.ts +22 -1
- package/dist/schema/property/modifiers/SchemaSearchable.d.ts +34 -0
- package/dist/schema/property/modifiers/SchemaTag.d.ts +27 -0
- package/dist/schema/property/modifiers/SchemaTracked.d.ts +5 -1
- package/dist/schema/property/modifiers/index.d.ts +3 -0
- package/dist/schema/property/types/SchemaArray.d.ts +2 -0
- package/dist/schema/property/types/SchemaBoolean.d.ts +2 -0
- package/dist/schema/property/types/SchemaDate.d.ts +2 -0
- package/dist/schema/property/types/SchemaFile.d.ts +60 -0
- package/dist/schema/property/types/SchemaNumber.d.ts +5 -1
- package/dist/schema/property/types/SchemaObject.d.ts +2 -0
- package/dist/schema/property/types/SchemaString.d.ts +25 -1
- package/dist/schema/property/types/SchemaVector.d.ts +61 -0
- package/dist/schema/property/types/index.d.ts +2 -0
- package/dist/schema/table/SchemaTransform.d.ts +40 -0
- package/dist/schema/table/index.d.ts +1 -0
- package/dist/schema/types.d.ts +200 -32
- package/dist/schema/utils/propertyKind.d.ts +4 -0
- package/dist/schema/utils/standardJsonSchema.d.ts +90 -0
- package/dist/types/index.cjs +23 -0
- package/dist/types/index.cjs.map +1 -0
- package/dist/types/index.js +0 -14
- package/dist/types/index.js.map +1 -1
- package/dist/utilities/functions.d.ts +1 -1
- package/dist/utilities/index.cjs +982 -0
- package/dist/utilities/index.cjs.map +1 -0
- package/dist/utilities/index.js +590 -321
- package/dist/utilities/index.js.map +1 -1
- package/dist/utilities/logger.d.ts +48 -0
- package/package.json +152 -98
- package/dist/collections/Changes.test.d.ts +0 -1
- package/dist/collections/MemoryDataCollection.test.d.ts +0 -1
- package/dist/collections/TagCollection.test.d.ts +0 -1
- package/dist/expressions/parser.test.d.ts +0 -1
- package/dist/expressions/utils.test.d.ts +0 -1
- package/dist/pipeline/SyncronousQueue.test.d.ts +0 -1
- package/dist/pipeline/WorkPipeline.test.d.ts +0 -1
- package/dist/plugins/EphemeralDataPlugin.test.d.ts +0 -1
- package/dist/plugins/query/QueryOptionsCollection.test.d.ts +0 -1
- package/dist/plugins/replication/OptimisticReplicationDbPlugin.d.ts +0 -23
- package/dist/plugins/replication/ReplicationDbPlugin.d.ts +0 -22
- package/dist/plugins/replication/index.d.ts +0 -3
- package/dist/plugins/replication/types.d.ts +0 -5
- package/dist/plugins/translators/JsonTranslator.test.d.ts +0 -1
- package/dist/schema/PropertyInfo.test.d.ts +0 -1
- package/dist/schema/schemaGeneration.test.d.ts +0 -1
- package/dist/schema/testSchemas.test.d.ts +0 -314
- package/dist/utilities/arrays.test.d.ts +0 -1
- package/dist/utilities/dates.test.d.ts +0 -1
- package/dist/utilities/strings.test.d.ts +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collections/index.js","sources":["webpack://@routier/core/./src/collections/Changes.ts","webpack://@routier/core/./src/collections/IdSet.ts","webpack://@routier/core/./src/collections/MemoryDataCollection.ts","webpack://@routier/core/./src/collections/ReadonlySchemaCollection.ts","webpack://@routier/core/./src/collections/SchemaCollection.ts","webpack://@routier/core/./src/collections/TagCollection.ts","webpack://@routier/core/./src/results/Result.ts","webpack://@routier/core/./src/schema/types.ts","webpack://@routier/core/./src/utilities/uuid.ts","webpack://@routier/core/webpack/runtime/define_property_getters","webpack://@routier/core/webpack/runtime/has_own_property","webpack://@routier/core/webpack/runtime/make_namespace_object","webpack://@routier/core/./src/collections/index.ts"],"sourcesContent":["import { EntityUpdateInfo } from \"../plugins/types\";\nimport { InferCreateType, InferType, SchemaId } from \"../schema\";\nimport { TagCollection } from \"./TagCollection\";\nexport class BulkPersistResult extends Map<SchemaId, SchemaPersistResult> {\n\n resolve(schemaId: SchemaId): SchemaPersistResult {\n if (this.has(schemaId)) {\n return this.get(schemaId);\n }\n\n this.set(schemaId, new SchemaPersistResult());\n\n return this.get(schemaId);\n }\n\n override get<T extends {} = Record<string, unknown>>(schemaId: SchemaId) {\n return super.get(schemaId) as SchemaPersistResult<T>\n }\n\n get aggregate() {\n return {\n size: this.aggregateSize,\n adds: this.aggregateAddsSize,\n updates: this.aggregateUpdatesSize,\n removes: this.aggregateRemovesSize\n }\n }\n\n private get aggregateSize() {\n let count = 0;\n\n for (const [, result] of this) {\n count += result.total;\n }\n\n return count;\n }\n\n private get aggregateAddsSize() {\n let count = 0;\n\n for (const [, result] of this) {\n count += result.adds.length;\n }\n\n return count;\n }\n\n private get aggregateUpdatesSize() {\n let count = 0;\n\n for (const [, result] of this) {\n count += result.updates.length;\n }\n\n return count;\n }\n\n private get aggregateRemovesSize() {\n let count = 0;\n\n for (const [, result] of this) {\n count += result.removes.length;\n }\n\n return count;\n }\n}\n\nexport class BulkPersistChanges extends Map<SchemaId, SchemaPersistChanges> {\n\n resolve(schemaId: SchemaId): SchemaPersistChanges {\n if (this.has(schemaId)) {\n return this.get(schemaId);\n }\n\n this.set(schemaId, new SchemaPersistChanges());\n\n return this.get(schemaId);\n }\n\n override get<T extends {} = Record<string, unknown>>(schemaId: SchemaId) {\n return super.get(schemaId) as SchemaPersistChanges<T>\n }\n\n get aggregate() {\n return {\n size: this.aggregateSize,\n adds: this.aggregateAddsSize,\n updates: this.aggregateUpdatesSize,\n removes: this.aggregateRemovesSize\n }\n }\n\n private get aggregateSize() {\n let count = 0;\n\n for (const [, result] of this) {\n count += result.total;\n }\n\n return count;\n }\n\n private get aggregateAddsSize() {\n let count = 0;\n\n for (const [, result] of this) {\n count += result.adds.length;\n }\n\n return count;\n }\n\n private get aggregateUpdatesSize() {\n let count = 0;\n\n for (const [, result] of this) {\n count += result.updates.length;\n }\n\n return count;\n }\n\n private get aggregateRemovesSize() {\n let count = 0;\n\n for (const [, result] of this) {\n count += result.removes.length;\n }\n\n return count;\n }\n\n /**\n * Ensures the result has the same result sets as the change sets\n * @returns \n */\n toResult() {\n const result = new BulkPersistResult();\n\n for (const [schemaId] of this) {\n result.set(schemaId, new SchemaPersistResult());\n }\n\n return result;\n }\n}\n\nexport class SchemaPersistChanges<T extends {} = Record<string, unknown>> {\n adds: InferCreateType<T>[] = [];\n updates: EntityUpdateInfo<T>[] = [];\n removes: InferType<T>[] = [];\n tags: TagCollection = new TagCollection();\n\n get hasItems() {\n return this.total > 0;\n }\n\n get total() {\n return this.adds.length + this.updates.length + this.removes.length;\n }\n}\n\nexport class SchemaPersistResult<T extends {} = Record<string, unknown>> {\n adds: InferType<T>[] = [];\n updates: InferType<T>[] = [];\n removes: InferType<T>[] = [];\n\n get hasItems() {\n return this.total > 0;\n }\n\n get total() {\n return this.adds.length + this.updates.length + this.removes.length;\n }\n}","import { IdType } from \"../schema\";\n\nexport class IdSet {\n\n readonly ids: readonly IdType[];\n\n constructor(...ids: IdType[]) {\n this.ids = Object.freeze(ids);\n }\n\n equals(other: IdSet): boolean {\n\n if (this.ids.length === 1) {\n return this.ids[0] === other.ids[0];\n }\n\n return this.toString() === other.toString();\n }\n\n toString(): string {\n\n if (this.ids.length === 1) {\n return String(this.ids[0]);\n }\n\n return this.ids.toString();\n }\n}","import { CompiledSchema, IdType, InferType, PropertyInfo, SchemaTypes } from \"../schema\";\nimport { CallbackResult, Result } from \"../results\";\nimport { uuidv4 } from \"../utilities\";\nimport { IdSet } from \"./IdSet\";\n\nexport class MemoryDataCollection {\n\n protected readonly nextNumericalIds: Map<string, number>;\n protected readonly data: Map<string, Record<string, unknown>>;\n protected readonly schema: CompiledSchema<any>;\n protected readonly idProperties: PropertyInfo<any>[];\n\n get size() {\n return this.data.size;\n }\n\n get records() {\n return [...this.data.values()];\n }\n\n constructor(schema: CompiledSchema<any>) {\n this.data = new Map<string, Record<string, unknown>>();\n this.nextNumericalIds = new Map<string, number>();\n this.schema = schema;\n this.idProperties = schema.idProperties;\n }\n\n private _getNextId(property: PropertyInfo<any>) {\n\n let nextId = 1;\n\n if (this.nextNumericalIds.has(property.id) === true) {\n nextId = this.nextNumericalIds.get(property.id) + 1;\n }\n\n this.nextNumericalIds.set(property.id, nextId);\n\n return nextId;\n }\n\n private resolveId(property: PropertyInfo<any>, value: unknown) {\n if (typeof value !== \"number\") {\n return;\n }\n\n const currentIdForProperty = this.nextNumericalIds.get(property.id);\n\n if (value <= currentIdForProperty) {\n return;\n }\n\n this.nextNumericalIds.set(property.id, value);\n }\n\n private getAndSetId(item: Record<string, unknown>, property: PropertyInfo<any>): IdType {\n if (item[property.name] != null) {\n return item[property.name] as IdType;\n }\n\n if (property.type === SchemaTypes.String) {\n const uuid = uuidv4()\n item[property.name] = uuid;\n return uuid;\n }\n\n if (property.type === SchemaTypes.Number) {\n const id = this._getNextId(property);\n item[property.name] = id;\n return id;\n }\n\n throw new Error(`Id Property '${property.name}' must be string or number, found '${property.type}'`)\n }\n\n seed(items: Record<string, unknown>[]) {\n for (let i = 0, length = items.length; i < length; i++) {\n const id = this.resolveIdSet(items[i] as InferType<unknown>);\n this.data.set(id.toString(), items[i]);\n }\n }\n\n private resolveCurrentIdSet(item: Record<string, unknown>): IdSet {\n const idProperties = this.schema.idProperties;\n const ids: IdType[] = [];\n // ensure keys\n for (let j = 0, l = idProperties.length; j < l; j++) {\n const property = idProperties[j];\n const value = property.getValue(item);\n\n if (value == null) {\n throw new Error(`Key cannot be null. Key: ${property.name}`);\n }\n\n ids.push(value);\n }\n\n return new IdSet(...ids);\n }\n\n private resolveIdSet(item: Record<string, unknown>): IdSet {\n\n if (this.schema.hasIdentityKeys) {\n const idProperties = this.schema.idProperties;\n const ids: IdType[] = new Array<IdType>(idProperties.length);\n\n // Need to make sure we allow for seeding the collection when we call add vs seed\n // There will be an existing id, but the id type could still be identity\n if (idProperties.length === 1) {\n const value = this.getAndSetId(item, idProperties[0]);\n this.resolveId(idProperties[0], value);\n ids[0] = value;\n } else {\n for (let j = 0, l = idProperties.length; j < l; j++) {\n const value = this.getAndSetId(item, idProperties[j]);\n this.resolveId(idProperties[j], value);\n ids[j] = value;\n }\n }\n\n return new IdSet(...ids);\n }\n\n return this.resolveCurrentIdSet(item);\n }\n\n add(item: Record<string, unknown>) {\n const id = this.resolveIdSet(item);\n this.data.set(id.toString(), item);\n }\n\n remove(item: Record<string, unknown>) {\n const id = this.resolveCurrentIdSet(item);\n this.data.delete(id.toString());\n }\n\n update(item: Record<string, unknown>) {\n const id = this.resolveCurrentIdSet(item);\n this.data.set(id.toString(), item);\n }\n\n destroy(done: CallbackResult<never>) {\n this.nextNumericalIds.clear();\n this.data.clear();\n done(Result.success());\n }\n\n load(done: CallbackResult<never>) {\n done(Result.success())\n }\n\n save(done: CallbackResult<never>) {\n done(Result.success())\n }\n}","import { CompiledSchema, SchemaId } from \"../schema\";\n\n/**\n * Collection of schemas with generic typing for type-safe schema retrieval\n */\nexport class ReadonlySchemaCollection {\n\n protected data: Map<SchemaId, CompiledSchema<Record<string, unknown>>>;\n\n constructor(data?: [SchemaId, CompiledSchema<Record<string, unknown>>][]) {\n this.data = new Map<SchemaId, CompiledSchema<Record<string, unknown>>>(data);\n }\n\n get<T>(schemaId: SchemaId): CompiledSchema<T> | undefined {\n return this.data.get(schemaId) as CompiledSchema<T> | undefined;\n }\n\n has(schemaId: SchemaId): boolean {\n return this.data.has(schemaId);\n }\n\n get size(): number {\n return this.data.size;\n }\n\n keys(): IterableIterator<SchemaId> {\n return this.data.keys();\n }\n\n values(): IterableIterator<CompiledSchema<Record<string, unknown>>> {\n return this.data.values();\n }\n\n entries(): IterableIterator<[SchemaId, CompiledSchema<Record<string, unknown>>]> {\n return this.data.entries();\n }\n\n forEach(callbackfn: (value: CompiledSchema<Record<string, unknown>>, key: SchemaId, map: Map<SchemaId, CompiledSchema<Record<string, unknown>>>) => void, thisArg?: any): void {\n this.data.forEach(callbackfn, thisArg);\n }\n\n [Symbol.iterator](): IterableIterator<[SchemaId, CompiledSchema<Record<string, unknown>>]> {\n return this.data[Symbol.iterator]();\n }\n\n getByName<T>(collectionName: string): CompiledSchema<T> | undefined {\n const found = [...this.data].find(x => x[1].collectionName === collectionName);\n\n if (found != null) {\n return found[1] as CompiledSchema<T>;\n }\n\n return undefined;\n }\n}","import { CompiledSchema, SchemaId } from \"../schema\";\nimport { ReadonlySchemaCollection } from \"./ReadonlySchemaCollection\";\n\n/**\n * Collection of schemas with generic typing for type-safe schema retrieval\n */\nexport class SchemaCollection extends ReadonlySchemaCollection {\n\n set<T>(schemaId: SchemaId, schema: CompiledSchema<T>): this {\n this.data.set(schemaId, schema as CompiledSchema<Record<string, unknown>>);\n return this;\n }\n\n delete(schemaId: SchemaId): boolean {\n return this.data.delete(schemaId);\n }\n\n clear(): void {\n this.data.clear();\n }\n}","export class TagCollection implements Disposable {\n\n private data: Map<Object, unknown> = new Map<Object, unknown>();\n private _size: number = 0;\n\n get size() {\n return this._size;\n }\n\n get(key: Object) {\n return this.data.get(key);\n }\n\n has(key: Object) {\n return this.data.has(key);\n }\n\n set(key: Object, tag: unknown) {\n this._size++;\n return this.data.set(key, tag);\n }\n\n delete(key: Object) {\n const result = this.data.delete(key);\n\n if (result) {\n this._size--;\n }\n\n return result;\n }\n\n setMany(keys: Object[], tag: unknown) {\n this._size += keys.length;\n for (let i = 0, length = keys.length; i < length; i++) {\n const key = keys[i];\n this.set(key, tag);\n }\n }\n\n combine(tags: TagCollection) {\n for (const [key, value] of tags) {\n this.data.set(key, value);\n }\n }\n\n values() {\n return this.data.values();\n }\n\n keys() {\n return this.data.keys();\n }\n\n [Symbol.dispose]() {\n this.data.clear();\n }\n\n [Symbol.iterator]() {\n return this.data[Symbol.iterator]();\n }\n}","import { PartialResultType, PluginEventPartialResultType, PluginEventResultType, ResultType } from \"./types\";\n\nabstract class BaseResult {\n static ERROR = \"error\" as const;\n static SUCCESS = \"success\" as const;\n static PARTIAL = \"partial\" as const;\n\n static resolve<T>(result: ResultType<T> | PartialResultType<T>, resolve: (data: T) => void, reject: (error?: any) => void) {\n if (result.ok === BaseResult.SUCCESS) {\n resolve(result.data);\n return;\n }\n\n if (result.ok === BaseResult.PARTIAL) {\n reject({\n partial: result.data,\n error: result.error\n });\n return;\n }\n\n reject(result.error);\n }\n\n static assertSuccess<T>(result: any): asserts result is { ok: \"success\"; data: T } {\n if (result.ok !== BaseResult.SUCCESS) {\n throw new Error(`Expected success result, but got ${result.ok}: ${result.error}`);\n }\n }\n}\n\nexport class Result extends BaseResult {\n static success<T>(data: T): ResultType<T>;\n static success<T>(): ResultType<never>;\n static success<T>(data?: T): ResultType<T> {\n return {\n ok: Result.SUCCESS,\n data\n }\n }\n\n static error<T>(error: any): ResultType<T> {\n return {\n ok: Result.ERROR,\n error\n }\n }\n\n static partial<T>(data: T, error: any): PartialResultType<T> {\n return {\n ok: Result.PARTIAL,\n data,\n error\n }\n }\n}\n\nexport class PluginEventResult extends BaseResult {\n static success<T>(id: string, data: T): PluginEventResultType<T>;\n static success<T>(id: string): PluginEventResultType<never>;\n static success<T>(id: string, data?: T): PluginEventResultType<T> {\n return {\n id,\n ok: Result.SUCCESS,\n data\n }\n }\n\n static error<T>(id: string, error: any): PluginEventResultType<T> {\n return {\n id,\n ok: Result.ERROR,\n error\n }\n }\n\n static partial<T>(id: string, data: T, error: any): PluginEventPartialResultType<T> {\n return {\n id,\n ok: Result.PARTIAL,\n data,\n error\n }\n }\n\n static assertSuccess<T>(result: PluginEventResultType<T>): asserts result is { ok: \"success\"; data: T; id: string } {\n if (result.ok !== Result.SUCCESS) {\n throw new Error(`Expected success result, but got ${result.ok}: ${result.error}`);\n }\n }\n}\n","import { SchemaDefinition } from \"./SchemaDefinition\";\nimport { SchemaBase } from \"./property/base/SchemaBase\";\nimport { SchemaArray } from \"./property/types/SchemaArray\";\nimport { SchemaObject } from \"./property/types/SchemaObject\";\nimport { PropertyInfo } from \"./PropertyInfo\";\nimport { DeepPartial } from \"../types\";\nimport { SchemaFunction } from \"./table\";\nimport { SchemaOptional } from \"./property/modifiers\";\nimport { Branded } from \"../utilities/types\";\n\nexport type DefaultValue<T, I = never> = T | ((injected: I) => T);\nexport type FunctionBody<TEntity, TResult> = (entity: TEntity, collectionName: CollectionName) => TResult;\nexport type IdType = string | number;\n\nexport enum SchemaTypes {\n Array = \"Array\",\n Boolean = \"Boolean\",\n Date = \"Date\",\n Number = \"Number\",\n Object = \"Object\",\n String = \"String\",\n Definition = \"Definition\",\n Function = \"Function\",\n Computed = \"Computed\"\n}\n\nexport type ArrayShape = string | number | Date | {};\n\nexport type ExpandedProperty = ExpandedChildProperty & {\n assignmentPath: string;\n selectorPath: string;\n properties: Map<string, ExpandedChildProperty>;\n childDegree: number;\n};\n\nexport type ExpandedChildProperty = {\n propertyName: string;\n type: SchemaTypes;\n isNullableOrOptional: boolean;\n isReadonly: boolean;\n isIdentity: boolean;\n isUnmapped: boolean;\n}\n\nexport enum HashType {\n Ids = \"Ids\",\n Object = \"Object\"\n}\n\nexport type HashFunction<TEntity extends {}> = {\n (entity: InferCreateType<TEntity>, type: HashType.Object): string;\n (entity: InferType<TEntity>, type: HashType.Ids): string;\n}\n\nexport type GetHashTypeFunction<TEntity extends {}> = {\n (entity: InferCreateType<TEntity>): HashType.Object;\n (entity: InferType<TEntity>): HashType.Ids;\n}\n\nexport type ChangeTrackingType = \"proxy\" | \"diff\" | \"immutable\";\n\nexport type IndexType = \"single\" | \"compound\" | \"unique\" | \"primary-key\"\nexport type Index = {\n properties: PropertyInfo<any>[],\n type: IndexType;\n name: string;\n}\n\n/**\n * Represents changes to subscriptions, categorizing them by modifications to\n * entities (additions, updates, removals) or query-driven removals.\n * @template T - The type of the entities in the subscription.\n */\nexport type SubscriptionChanges<T extends {}> = {\n /**\n * Entities that have been added to the subscription.\n */\n adds: InferType<T>[];\n /**\n * Entities that have been updated within the subscription.\n */\n updates: InferType<T>[];\n /**\n * Entities that have been removed from the subscription.\n */\n removals: InferType<T>[];\n /**\n * Entities that have been added/updated/removed from the subscription and it is unknown \n * if the entities have been added/updated/removed.\n */\n unknown: InferType<T>[];\n}\n\nexport interface ISchemaSubscription<T extends {}> extends Disposable {\n send(changes: SubscriptionChanges<T>): void;\n onMessage(callback: (changes: SubscriptionChanges<T>) => void): void;\n}\n\ntype Enrich<TEntity extends {}> = {\n (entity: InferType<TEntity>, changeTrackingType: ChangeTrackingType): InferType<TEntity>;\n (entity: InferCreateType<TEntity>, changeTrackingType: ChangeTrackingType): InferCreateType<TEntity>;\n}\nexport type Prepare<TEntity extends {}> = {\n (entity: InferCreateType<TEntity>): InferCreateType<TEntity>;\n (entity: InferType<TEntity>): InferType<TEntity>;\n}\nexport type Preprocess<TEntity extends {}> = {\n (entity: InferCreateType<TEntity>): InferType<TEntity>;\n (entity: InferType<TEntity>): InferType<TEntity>;\n}\n\nexport type CompiledSchemaCore<TEntity extends {}> = Omit<CompiledSchema<TEntity>, \"createSubscription\">;\n\n/**\n * Represents a fully compiled schema with all utilities and metadata for an entity type.\n */\nexport type CompiledSchema<TEntity extends {}> = {\n\n deserializePartial: (item: Record<string, unknown>, properties: PropertyInfo<TEntity>[]) => DeepPartial<InferType<TEntity>>;\n\n createSubscription: (abortSignal?: AbortSignal) => ISchemaSubscription<TEntity>;\n /** Returns the property info for a given id (full path) */\n getProperty: (id: string) => PropertyInfo<TEntity>;\n /** Returns the ID of the given entity. */\n getId: (entity: InferType<TEntity>) => IdType;\n /** Returns a deep clone of the given entity. */\n clone: (entity: InferType<TEntity>) => InferType<TEntity>;\n /** Removes unmapped or extraneous properties from the entity. */\n strip: (entity: InferType<TEntity>) => InferType<TEntity>;\n /** Prepares a new entity for creation, applying defaults and transformations. */\n prepare: Prepare<TEntity>;\n /** Merges the source entity into the destination entity. */\n merge: (destination: InferType<TEntity> | InferCreateType<TEntity>, source: InferType<TEntity>) => InferType<TEntity>;\n /** Indicates if the schema has identity properties. */\n hasIdentities: boolean;\n /** List of properties that are identity keys. */\n idProperties: PropertyInfo<TEntity>[];\n /** All property metadata for the schema. */\n properties: PropertyInfo<TEntity>[],\n /** The hash type used for this schema. */\n hashType: HashType;\n /** Computes a hash for the given entity. */\n hash: HashFunction<TEntity>;\n /** Returns the hash type for the given entity. */\n getHashType: GetHashTypeFunction<TEntity>;\n /** Compares two entities for equality. */\n compare: (a: InferType<TEntity>, fromDb: InferType<TEntity>) => boolean;\n /** Deserializes an entity from storage format. */\n deserialize: (entity: InferType<TEntity>) => InferType<TEntity>;\n\n /** Combines serializing and preparing an entity for saving. */\n preprocess: Preprocess<TEntity>;\n /** Combines deserializing and enriching an entity for selection. */\n postprocess: Enrich<TEntity>;\n\n /** Serializes an entity to storage format. */\n serialize: (entity: InferType<TEntity>) => InferType<TEntity>;\n /** Unique id for the schema. */\n id: SchemaId,\n /** The name of the collection for this schema. */\n collectionName: CollectionName;\n /** Returns all IDs for the given entity (usually a single-element tuple). */\n getIds: (entity: InferType<TEntity>) => [IdType];\n /** Enriches the entity with change tracking or other metadata. */\n enrich: Enrich<TEntity>;\n /** Indicates if the schema has identity keys. */\n hasIdentityKeys: boolean;\n /** Returns a deeply frozen (immutable) version of the entity. */\n freeze: (entity: InferType<TEntity>) => InferType<TEntity>;\n /** Enables change tracking on the entity. */\n enableChangeTracking: (entity: InferType<TEntity>) => InferType<TEntity>;\n /** The schema definition object. */\n definition: SchemaDefinition<TEntity>;\n /** Returns all indexes defined for this schema. */\n getIndexes: () => Index[];\n /** Compares two entities for Id equality. */\n compareIds: (a: InferType<TEntity>, b: InferType<TEntity>) => boolean;\n}\n\nexport type PropertySerializer<T extends any> = (value: T) => string | number;\nexport type PropertyDeserializer<T extends any> = (value: string | number) => T;\n\nexport type SchemaId = Branded<number, \"SchemaId\">;\nexport type CollectionName = Branded<string, \"CollectionName\">;\n\nexport type SchemaModifiers = \"default\" | \"deserialize\" |\n \"identity\" | \"key\" |\n \"nullable\" | \"optional\" |\n \"readonly\" | \"serialize\" |\n \"unmapped\" | \"computed\" |\n \"distinct\";\n\ntype InferPrimitive<T> =\n T extends SchemaOptional<infer C, infer __> ? C extends (string | number | Date) ? C : { [K in keyof C]: InferPrimitive<C[K]> } :\n T extends SchemaArray<infer Y, infer __> ? InferPrimitive<Y>[]\n : T extends SchemaObject<infer Obj, infer _> ?\n { [K in keyof Obj]: InferPrimitive<Obj[K]> } : // Process nested objects\n T extends SchemaFunction<infer F, infer __> ? F : T extends SchemaBase<infer X, infer _> ?\n X extends Array<infer A> ? InferPrimitive<A>[] : X : // Extract the primitive type\n never;\n\nexport type InferType<T> = T extends CompiledSchema<infer R> ? InferCompiledSchema<R> : T extends {} ? InferCompiledSchema<T> : T;\nexport type InferCreateType<T> = T extends CompiledSchema<infer R> ? InferCompiledCreateSchema<R> : T extends {} ? InferCompiledCreateSchema<T> : unknown;\nexport type InferMappedType<T> = T extends SchemaBase<infer K, infer __> ? InferType<K> : InferCompiledSchema<T>;\n\ntype HasModifier<T, K extends keyof T, M extends SchemaModifiers> =\n T[K] extends SchemaBase<any, infer Mods> ?\n M extends Mods ? true : false :\n false;\n\ntype IsPlainProperty<T, K extends keyof T> =\n [\n HasModifier<T, K, \"readonly\">,\n HasModifier<T, K, \"optional\">,\n HasModifier<T, K, \"nullable\">\n ] extends [\n false,\n false,\n false\n ] ? true : false;\n\ntype IsPlainCreateProperty<T, K extends keyof T> =\n [\n HasModifier<T, K, \"identity\">,\n HasModifier<T, K, \"default\">,\n HasModifier<T, K, \"computed\">,\n HasModifier<T, K, \"unmapped\">,\n HasModifier<T, K, \"optional\">,\n HasModifier<T, K, \"nullable\">\n ] extends [\n false,\n false,\n false,\n false,\n false,\n false\n ] ? true : false;\n\ntype InferCompiledSchema<T> = CoalesceEmpty<{\n [K in keyof T as IsPlainProperty<T, K> extends true ? K : never]: InferPrimitive<T[K]>\n}, {\n readonly [K in keyof T as HasModifier<T, K, \"readonly\"> extends true ? K : never]: InferPrimitive<T[K]>\n }, {\n [K in keyof T as HasModifier<T, K, \"optional\"> extends true ? K : never]?: InferPrimitive<T[K]>\n }, {\n [K in keyof T as HasModifier<T, K, \"nullable\"> extends true ? K : never]: null | InferPrimitive<T[K]>\n }>;\n\ntype InferCompiledCreateSchema<T> = CoalesceEmpty<{\n [K in keyof T as IsPlainCreateProperty<T, K> extends true ? K : never]: InferPrimitive<T[K]>\n}, {\n [K in keyof T as HasModifier<T, K, \"optional\"> extends true ? K : never]?: InferPrimitive<T[K]>\n }, {\n [K in keyof T as HasModifier<T, K, \"default\"> extends true ? K : never]?: InferPrimitive<T[K]>\n }, {\n [K in keyof T as HasModifier<T, K, \"nullable\"> extends true ? K : never]: null | InferPrimitive<T[K]>\n }>;\n\ntype IsEmptyObject<T> = keyof T extends never ? true : false;\ntype CoalesceEmpty<T1 extends {}, T2 extends {}, T3 extends {}, T4 extends {}> = (IsEmptyObject<T1> extends true ? {} : T1) & (IsEmptyObject<T2> extends true ? {} : T2) & (IsEmptyObject<T3> extends true ? {} : T3) & (IsEmptyObject<T4> extends true ? {} : T4);\n","export const uuid = (length: number = 16): string => {\n const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';\n const charLength = chars.length;\n let result = '';\n\n for (let i = 0; i < length; i++) {\n result += chars[Math.random() * charLength | 0];\n }\n return result;\n}\n\nconst HEX_CHARS = '0123456789abcdef';\nconst UUID_TEMPLATE = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx';\n\nconst hasCrypto =\n typeof crypto !== 'undefined' && typeof crypto.getRandomValues === 'function';\n\nexport const uuidv4 = (): string => {\n let randomBytes: Uint8Array | null = null;\n if (hasCrypto) {\n randomBytes = crypto.getRandomValues(new Uint8Array(16));\n }\n\n let byteIndex = 0;\n let uuid = '';\n\n for (let i = 0; i < UUID_TEMPLATE.length; i++) {\n const c = UUID_TEMPLATE[i];\n if (c === '-') {\n uuid += '-';\n continue;\n }\n\n let r: number;\n if (hasCrypto && randomBytes) {\n // Each byte gives two hex digits (nibbles)\n r =\n (i % 2 === 0\n ? randomBytes[byteIndex] >> 4\n : randomBytes[byteIndex++] & 0x0f);\n } else {\n r = Math.floor(Math.random() * 16);\n }\n\n if (c === 'x') {\n uuid += HEX_CHARS[r];\n } else if (c === 'y') {\n // Variant bits: 8, 9, A, or B\n uuid += HEX_CHARS[(r & 0x3) | 0x8];\n } else if (c === '4') {\n uuid += '4';\n }\n }\n\n return uuid;\n};\n","__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","export * from './Changes';\nexport * from './TagCollection';\nexport * from './IdSet';\nexport * from './MemoryDataCollection';\nexport * from './SchemaCollection';\nexport * from './ReadonlySchemaCollection';"],"names":[],"mappings":";;;;;;;;;;AAEgD;AACzC,MAAM,iBAAkB,SAAQ,GAAkC;IAErE,OAAO,CAAC,QAAkB;QACtB,IAAI,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;YACrB,OAAO,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC9B,CAAC;QAED,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,mBAAmB,EAAE,CAAC,CAAC;QAE9C,OAAO,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC9B,CAAC;IAEQ,GAAG,CAAyC,QAAkB;QACnE,OAAO,KAAK,CAAC,GAAG,CAAC,QAAQ,CAA2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AS;QACb,CAAC;QAED,IAAI,CAAS,CAAC;QACd,IAAI,SAAS,IAAI,WAAW,EAAE,CAAC;YAC3B,2CAA2C;YAC3C,CAAC;gBACG,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC;oBACR,CAAC,CAAC,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC;oBAC7B,CAAC,CAAC,WAAW,CAAC,SAAS,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;QAC/C,CAAC;aAAM,CAAC;YACJ,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;QACvC,CAAC;QAED,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;YACZ,IAAI,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC;QACzB,CAAC;aAAM,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;YACnB,8BAA8B;YAC9B,IAAI,IAAI,SAAS,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC;QACvC,CAAC;aAAM,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;YACnB,IAAI,IAAI,GAAG,CAAC;QAChB,CAAC;IACL,CAAC;IAED,OAAO,IAAI,CAAC;AAChB,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACvDF;AACA;AACA;AACA,kDAAkD,wCAAwC;AAC1F;AACA;AACA,E;;;;ACNA,wF;;;;ACAA;AACA;AACA;AACA,uDAAuD,iBAAiB;AACxE;AACA,gDAAgD,aAAa;AAC7D,E;;;;;;;;;;;;;;;;;;;;;;;ACN0B;AACM;AACR;AACe;AACJ;AACQ"}
|
|
1
|
+
{"version":3,"file":"collections/index.js","sources":["webpack://@routier/core/./src/collections/Changes.ts","webpack://@routier/core/./src/collections/ReadonlySchemaCollection.ts","webpack://@routier/core/./src/collections/SchemaCollection.ts","webpack://@routier/core/./src/collections/TagCollection.ts","webpack://@routier/core/./src/results/Result.ts","webpack://@routier/core/./src/schema/types.ts","webpack://@routier/core/./src/utilities/uuid.ts","webpack://@routier/core/webpack/runtime/define_property_getters","webpack://@routier/core/webpack/runtime/has_own_property","webpack://@routier/core/./src/collections/IdSet.ts","webpack://@routier/core/./src/collections/MemoryDataCollection.ts","webpack://@routier/core/./src/collections/index.ts"],"sourcesContent":["import { EntityUpdateInfo } from \"../plugins/types\";\nimport { InferCreateType, InferType, SchemaId } from \"../schema\";\nimport { TagCollection } from \"./TagCollection\";\nexport class BulkPersistResult extends Map<SchemaId, SchemaPersistResult> {\n\n resolve<T extends {} = Record<string, unknown>>(schemaId: SchemaId): SchemaPersistResult<T> {\n if (this.has(schemaId)) {\n return this.get(schemaId);\n }\n\n this.set(schemaId, new SchemaPersistResult<T>());\n\n return this.get(schemaId);\n }\n\n override get<T extends {} = Record<string, unknown>>(schemaId: SchemaId) {\n return super.get(schemaId) as SchemaPersistResult<T>\n }\n\n get aggregate() {\n return {\n size: this.aggregateSize,\n adds: this.aggregateAddsSize,\n updates: this.aggregateUpdatesSize,\n removes: this.aggregateRemovesSize\n }\n }\n\n private get aggregateSize() {\n let count = 0;\n\n for (const [, result] of this) {\n count += result.total;\n }\n\n return count;\n }\n\n private get aggregateAddsSize() {\n let count = 0;\n\n for (const [, result] of this) {\n count += result.adds.length;\n }\n\n return count;\n }\n\n private get aggregateUpdatesSize() {\n let count = 0;\n\n for (const [, result] of this) {\n count += result.updates.length;\n }\n\n return count;\n }\n\n private get aggregateRemovesSize() {\n let count = 0;\n\n for (const [, result] of this) {\n count += result.removes.length;\n }\n\n return count;\n }\n}\n\nexport class BulkPersistChanges extends Map<SchemaId, SchemaPersistChanges> {\n\n resolve<T extends {} = Record<string, unknown>>(schemaId: SchemaId): SchemaPersistChanges<T> {\n if (this.has(schemaId)) {\n return this.get(schemaId);\n }\n\n this.set(schemaId, new SchemaPersistChanges<T>());\n\n return this.get(schemaId);\n }\n\n override get<T extends {} = Record<string, unknown>>(schemaId: SchemaId) {\n return super.get(schemaId) as SchemaPersistChanges<T>\n }\n\n get aggregate() {\n return {\n size: this.aggregateSize,\n adds: this.aggregateAddsSize,\n updates: this.aggregateUpdatesSize,\n removes: this.aggregateRemovesSize\n }\n }\n\n private get aggregateSize() {\n let count = 0;\n\n for (const [, result] of this) {\n count += result.total;\n }\n\n return count;\n }\n\n private get aggregateAddsSize() {\n let count = 0;\n\n for (const [, result] of this) {\n count += result.adds.length;\n }\n\n return count;\n }\n\n private get aggregateUpdatesSize() {\n let count = 0;\n\n for (const [, result] of this) {\n count += result.updates.length;\n }\n\n return count;\n }\n\n private get aggregateRemovesSize() {\n let count = 0;\n\n for (const [, result] of this) {\n count += result.removes.length;\n }\n\n return count;\n }\n\n /**\n * Ensures the result has the same result sets as the change sets\n * @returns \n */\n toResult() {\n const result = new BulkPersistResult();\n\n for (const [schemaId] of this) {\n result.set(schemaId, new SchemaPersistResult());\n }\n\n return result;\n }\n}\n\nexport class SchemaPersistChanges<T extends {} = Record<string, unknown>> {\n adds: InferCreateType<T>[] = [];\n updates: EntityUpdateInfo<T>[] = [];\n removes: InferType<T>[] = [];\n tags: TagCollection = new TagCollection();\n\n get hasItems() {\n return this.total > 0;\n }\n\n get total() {\n return this.adds.length + this.updates.length + this.removes.length;\n }\n}\n\nexport class SchemaPersistResult<T extends {} = Record<string, unknown>> {\n adds: InferType<T>[] = [];\n updates: InferType<T>[] = [];\n removes: InferType<T>[] = [];\n\n get hasItems() {\n return this.total > 0;\n }\n\n get total() {\n return this.adds.length + this.updates.length + this.removes.length;\n }\n}","import { CompiledSchema, SchemaId } from \"../schema\";\n\n/**\n * Collection of schemas with generic typing for type-safe schema retrieval\n */\nexport class ReadonlySchemaCollection {\n\n protected data: Map<SchemaId, CompiledSchema<Record<string, unknown>>>;\n\n constructor(data?: [SchemaId, CompiledSchema<Record<string, unknown>>][]) {\n this.data = new Map<SchemaId, CompiledSchema<Record<string, unknown>>>(data);\n }\n\n get<T>(schemaId: SchemaId): CompiledSchema<T> | undefined {\n return this.data.get(schemaId) as CompiledSchema<T> | undefined;\n }\n\n has(schemaId: SchemaId): boolean {\n return this.data.has(schemaId);\n }\n\n get size(): number {\n return this.data.size;\n }\n\n keys(): IterableIterator<SchemaId> {\n return this.data.keys();\n }\n\n values(): IterableIterator<CompiledSchema<Record<string, unknown>>> {\n return this.data.values();\n }\n\n entries(): IterableIterator<[SchemaId, CompiledSchema<Record<string, unknown>>]> {\n return this.data.entries();\n }\n\n forEach(callbackfn: (value: CompiledSchema<Record<string, unknown>>, key: SchemaId, map: Map<SchemaId, CompiledSchema<Record<string, unknown>>>) => void, thisArg?: any): void {\n this.data.forEach(callbackfn, thisArg);\n }\n\n [Symbol.iterator](): IterableIterator<[SchemaId, CompiledSchema<Record<string, unknown>>]> {\n return this.data[Symbol.iterator]();\n }\n\n getByName<T>(collectionName: string): CompiledSchema<T> | undefined {\n const found = [...this.data].find(x => x[1].collectionName === collectionName);\n\n if (found != null) {\n return found[1] as CompiledSchema<T>;\n }\n\n return undefined;\n }\n}","import { CompiledSchema, SchemaId } from \"../schema\";\nimport { ReadonlySchemaCollection } from \"./ReadonlySchemaCollection\";\n\n/**\n * Collection of schemas with generic typing for type-safe schema retrieval\n */\nexport class SchemaCollection extends ReadonlySchemaCollection {\n\n set<T>(schemaId: SchemaId, schema: CompiledSchema<T>): this {\n this.data.set(schemaId, schema as CompiledSchema<Record<string, unknown>>);\n return this;\n }\n\n delete(schemaId: SchemaId): boolean {\n return this.data.delete(schemaId);\n }\n\n clear(): void {\n this.data.clear();\n }\n}","export class TagCollection implements Disposable {\n\n private data: Map<object, unknown> = new Map<object, unknown>();\n\n // Delegated to the map rather than tracked in a counter field: every mutation path\n // (set, setMany, combine, delete, dispose) would otherwise have to maintain it, and\n // a missed path silently reports a size that disagrees with the contents.\n get size() {\n return this.data.size;\n }\n\n get(key: object) {\n return this.data.get(key);\n }\n\n has(key: object) {\n return this.data.has(key);\n }\n\n set(key: object, tag: unknown) {\n return this.data.set(key, tag);\n }\n\n delete(key: object) {\n return this.data.delete(key);\n }\n\n setMany(keys: object[], tag: unknown) {\n for (let i = 0, length = keys.length; i < length; i++) {\n const key = keys[i];\n this.set(key, tag);\n }\n }\n\n combine(tags: TagCollection) {\n for (const [key, value] of tags) {\n this.set(key, value);\n }\n }\n\n values() {\n return this.data.values();\n }\n\n keys() {\n return this.data.keys();\n }\n\n [Symbol.dispose]() {\n this.data.clear();\n }\n\n [Symbol.iterator]() {\n return this.data[Symbol.iterator]();\n }\n}","import { PartialResultType, PluginEventPartialResultType, PluginEventResultType, ResultType } from \"./types\";\n\nabstract class BaseResult {\n static ERROR = \"error\" as const;\n static SUCCESS = \"success\" as const;\n static PARTIAL = \"partial\" as const;\n\n static resolve<T>(result: ResultType<T> | PartialResultType<T>, resolve: (data: T) => void, reject: (error?: any) => void) {\n if (result.ok === BaseResult.SUCCESS) {\n resolve(result.data);\n return;\n }\n\n if (result.ok === BaseResult.PARTIAL) {\n reject({\n partial: result.data,\n error: result.error\n });\n return;\n }\n\n reject(result.error);\n }\n\n static assertSuccess<T>(result: any): asserts result is { ok: \"success\"; data: T } {\n if (result.ok !== BaseResult.SUCCESS) {\n throw new Error(`Expected success result, but got ${result.ok}: ${result.error}`);\n }\n }\n}\n\nexport class Result extends BaseResult {\n static success<T>(data: T): ResultType<T>;\n static success(): ResultType<never>;\n static success<T>(data?: T): ResultType<T> {\n return {\n ok: Result.SUCCESS,\n data\n }\n }\n\n static error<T>(error: any): ResultType<T> {\n return {\n ok: Result.ERROR,\n error\n }\n }\n\n static partial<T>(data: T, error: any): PartialResultType<T> {\n return {\n ok: Result.PARTIAL,\n data,\n error\n }\n }\n}\n\nexport class PluginEventResult extends BaseResult {\n static success<T>(id: string, data: T): PluginEventResultType<T>;\n static success(id: string): PluginEventResultType<never>;\n static success<T>(id: string, data?: T): PluginEventResultType<T> {\n return {\n id,\n ok: Result.SUCCESS,\n data\n }\n }\n\n static error<T>(id: string, error: any): PluginEventResultType<T> {\n return {\n id,\n ok: Result.ERROR,\n error\n }\n }\n\n static partial<T>(id: string, data: T, error: any): PluginEventPartialResultType<T> {\n return {\n id,\n ok: Result.PARTIAL,\n data,\n error\n }\n }\n\n static assertSuccess<T>(result: PluginEventResultType<T>): asserts result is { ok: \"success\"; data: T; id: string } {\n if (result.ok !== Result.SUCCESS) {\n throw new Error(`Expected success result, but got ${result.ok}: ${result.error}`);\n }\n }\n}\n","import type { SchemaDefinition } from \"./SchemaDefinition\";\nimport type { SchemaBase } from \"./property/base/SchemaBase\";\nimport type { SchemaArray } from \"./property/types/SchemaArray\";\nimport type { SchemaVector } from \"./property/types/SchemaVector\";\nimport type { SchemaObject } from \"./property/types/SchemaObject\";\nimport type { PropertyInfo } from \"./PropertyInfo\";\nimport type { DeepPartial } from \"../types\";\nimport type { SchemaFunction } from \"./table\";\nimport type { SchemaOptional, SchemaTag } from \"./property/modifiers\";\nimport type { Branded } from \"../utilities/types\";\nimport type { SchemaSubscriptionOptions } from \"./communication/broadcast\";\n\nexport type DefaultValue<T, I = never> = T | ((injected: I) => T);\nexport type FunctionBody<TEntity, TResult> = (entity: TEntity, collectionName: CollectionName) => TResult;\nexport type IdType = string | number;\nexport type ForeignKey<T extends {}> = { \n schema: CompiledSchema<T>, \n property: PropertyInfo<T> \n};\n\nexport enum SchemaTypes {\n Array = \"Array\",\n Boolean = \"Boolean\",\n Date = \"Date\",\n Number = \"Number\",\n Object = \"Object\",\n String = \"String\",\n Definition = \"Definition\",\n Function = \"Function\",\n Computed = \"Computed\",\n /**\n * Content in, reference out. The only type whose write shape differs from its stored\n * shape, and a leaf on purpose — see `SchemaFile`.\n */\n File = \"File\",\n /**\n * A fixed-length list of numbers, carrying its dimension count — see `SchemaVector`.\n *\n * Value-shaped exactly like `s.array(s.number())`, which is why every array codegen\n * handler accepts it. It is a distinct type only so a backend can recognise it and store\n * it natively; nothing else needs to tell the two apart.\n */\n Vector = \"Vector\"\n}\n\nexport type ArrayShape = string | number | Date | {};\n\n\n/**\n * What a file property gives back: where the bytes are and what they are.\n *\n * Declared in core so `InferType` can name it. Core never reads or writes the bytes — it only\n * carries this shape — and `@routier/blob-plugin` is what puts one here.\n */\nexport type FileReferenceValue = {\n /** Where the bytes live, content-addressed by the blob plugin. */\n key: string;\n /** Byte length. */\n size: number;\n /** Media type as supplied at upload. */\n contentType: string;\n /** SHA-256 of the bytes, lowercase hex. */\n checksum: string;\n /** The name to show a user. Not part of the key. */\n fileName: string;\n};\n\n/**\n * What a file property ACCEPTS: content, or a reference you already have.\n *\n * `Blob` covers `File`, which is what an `<input type=\"file\">` yields. A reference is accepted\n * too, so re-saving an entity that was read from the database does not have to re-upload it.\n */\nexport type FileContentValue =\n | FileReferenceValue\n | Uint8Array\n | ArrayBuffer\n | Blob\n | string;\n\n/**\n * What a vector property holds, in and out: a plain list of numbers.\n *\n * Named rather than written inline because the inference rules have to recognise it after a\n * modifier has erased which class produced it — the same problem `FileReferenceValue` solves\n * above, and for the same reason.\n */\nexport type VectorValue = number[];\n\n/**\n * What `s.string({ ... })` accepts.\n *\n * Declarations only. Core stores them and never acts on them; a backend that can use one does.\n */\nexport type StringOptions = {\n /**\n * The longest value the property is declared to hold.\n *\n * MySQL uses it for `VARCHAR(maxLength)`; without it every string column is\n * `VARCHAR(255)`, which silently truncates longer values. Other backends ignore it. Core\n * never validates a value against it — see `SchemaBase.maxLength`.\n */\n maxLength?: number;\n};\n\nexport type ExpandedProperty = ExpandedChildProperty & {\n assignmentPath: string;\n selectorPath: string;\n properties: Map<string, ExpandedChildProperty>;\n childDegree: number;\n};\n\nexport type ExpandedChildProperty = {\n propertyName: string;\n type: SchemaTypes;\n isNullableOrOptional: boolean;\n isReadonly: boolean;\n isIdentity: boolean;\n isUnmapped: boolean;\n}\n\nexport enum HashType {\n Ids = \"Ids\",\n Object = \"Object\"\n}\n\nexport type HashFunction<TEntity extends {}> = {\n (entity: InferCreateType<TEntity>, type: HashType.Object): string;\n (entity: InferType<TEntity>, type: HashType.Ids): string;\n}\n\nexport type GetHashTypeFunction<TEntity extends {}> = {\n (entity: InferCreateType<TEntity>): HashType.Object;\n (entity: InferType<TEntity>): HashType.Ids;\n}\n\nexport type ChangeTrackingType = \"proxy\" | \"diff\" | \"immutable\";\n\nexport type IndexType = \"single\" | \"compound\" | \"unique\" | \"primary-key\"\nexport type Index = {\n properties: PropertyInfo<any>[],\n type: IndexType;\n name: string;\n}\n\n/**\n * Represents changes to subscriptions, categorizing them by modifications to\n * entities (additions, updates, removals) or query-driven removals.\n * @template T - The type of the entities in the subscription.\n */\nexport type SubscriptionChanges<T extends {}> = {\n /**\n * Entities that have been added to the subscription.\n */\n adds: InferType<T>[];\n /**\n * Entities that have been updated within the subscription.\n */\n updates: InferType<T>[];\n /**\n * Entities that have been removed from the subscription.\n */\n removals: InferType<T>[];\n /**\n * Entities that have been added/updated/removed from the subscription and it is unknown \n * if the entities have been added/updated/removed.\n */\n unknown: InferType<T>[];\n}\n\nexport interface ISchemaSubscription<T extends {}> extends Disposable {\n send(changes: SubscriptionChanges<T>): void;\n onMessage(callback: (changes: SubscriptionChanges<T>) => void): void;\n}\n\nexport type Enrich<TEntity extends {}> = {\n (entity: InferType<TEntity>, changeTrackingType: ChangeTrackingType): InferType<TEntity>;\n (entity: InferCreateType<TEntity>, changeTrackingType: ChangeTrackingType): InferCreateType<TEntity>;\n}\nexport type Prepare<TEntity extends {}> = {\n (entity: InferCreateType<TEntity>): InferCreateType<TEntity>;\n (entity: InferType<TEntity>): InferType<TEntity>;\n}\nexport type Preprocess<TEntity extends {}> = {\n (entity: InferCreateType<TEntity>): InferType<TEntity>;\n (entity: InferType<TEntity>): InferType<TEntity>;\n}\n\nexport type SetProperties<TEntity extends {}> = (destination: DeepPartial<InferType<TEntity> | InferCreateType<TEntity>>, source: DeepPartial<InferType<TEntity> | InferCreateType<TEntity>>) => void;\n\nexport type CompiledSchemaCore<TEntity extends {}> = Omit<CompiledSchema<TEntity>, \"createSubscription\">;\n\nexport type CompiledSchemaWithMetadata<TEntity extends {}, TMetadata> = {\n readonly metadata: TMetadata;\n} & CompiledSchema<TEntity>;\n\n/**\n * Represents a fully compiled schema with all utilities and metadata for an entity type.\n */\nexport type CompiledSchema<TEntity extends {}> = {\n\n deserializePartial: (item: Record<string, unknown>, properties: PropertyInfo<TEntity>[]) => DeepPartial<InferType<TEntity>>;\n\n createSubscription: (abortSignal?: AbortSignal, scope?: string, options?: SchemaSubscriptionOptions) => ISchemaSubscription<TEntity>;\n /** Returns the property info for a given id (full path) */\n getProperty: (id: string) => PropertyInfo<TEntity>;\n /** Returns the ID of the given entity. */\n getId: (entity: InferType<TEntity>) => IdType;\n /** Returns a deep clone of the given entity. */\n clone: (entity: InferType<TEntity>) => InferType<TEntity>;\n /**\n * Returns a deep clone of a record that is still in the STORAGE shape — renamed properties\n * under their `from` names rather than their in-memory names.\n *\n * `clone` reads in-memory names, so it returns `undefined` for every renamed property of a\n * stored record. Use this when copying rows a store holds before they have been deserialized.\n * Generated on first call; schemas that are never cloned in storage shape never build it.\n */\n cloneStorage: (entity: InferType<TEntity>) => InferType<TEntity>;\n /** Removes unmapped or extraneous properties from the entity. */\n strip: (entity: InferType<TEntity>) => InferType<TEntity>;\n /** Prepares a new entity for creation, applying defaults and transformations. */\n prepare: Prepare<TEntity>;\n /** Merges the source entity into the destination entity. */\n merge: (destination: InferType<TEntity> | InferCreateType<TEntity>, source: InferType<TEntity>) => InferType<TEntity>;\n /** Indicates if the schema has identity properties. */\n hasIdentities: boolean;\n /** List of properties that are identity keys. */\n idProperties: PropertyInfo<TEntity>[];\n /** All property metadata for the schema. */\n properties: PropertyInfo<TEntity>[],\n /** The hash type used for this schema. */\n hashType: HashType;\n /** Computes a hash for the given entity. */\n hash: HashFunction<TEntity>;\n /** Returns the hash type for the given entity. */\n getHashType: GetHashTypeFunction<TEntity>;\n /** Compares two entities for equality. */\n compare: (a: InferType<TEntity>, fromDb: InferType<TEntity>) => boolean;\n /** Deserializes an entity from storage format. */\n deserialize: (entity: InferType<TEntity>) => InferType<TEntity>;\n /** Sets 1 or many properties from the source object onto the destination object with change tracking. */\n set: SetProperties<TEntity>;\n /** Combines serializing and preparing an entity for saving. */\n preprocess: Preprocess<TEntity>;\n /** Combines deserializing and enriching an entity for selection. */\n postprocess: Enrich<TEntity>;\n\n /** Serializes an entity to storage format. */\n serialize: (entity: InferType<TEntity>) => InferType<TEntity>;\n /** Unique id for the schema. */\n id: SchemaId,\n /** The name of the collection for this schema. */\n collectionName: CollectionName;\n /** Returns all IDs for the given entity (usually a single-element tuple). */\n getIds: (entity: InferType<TEntity>) => [IdType];\n /** Enriches the entity with change tracking or other metadata. */\n enrich: Enrich<TEntity>;\n /** Indicates if the schema has identity keys. */\n hasIdentityKeys: boolean;\n /** Returns a deeply frozen (immutable) version of the entity. */\n freeze: (entity: InferType<TEntity>) => InferType<TEntity>;\n /** Enables change tracking on the entity. */\n enableChangeTracking: (entity: InferType<TEntity>) => InferType<TEntity>;\n /** The schema definition object. */\n definition: SchemaDefinition<TEntity>;\n /** Returns all indexes defined for this schema. */\n getIndexes: () => Index[];\n /** Compares two entities for Id equality. */\n compareIds: (a: InferType<TEntity>, b: InferType<TEntity>) => boolean;\n}\n\nexport type PropertySerializer<T extends any> = (value: T) => string | number;\nexport type PropertyDeserializer<T extends any> = (value: string | number) => T;\n\n/**\n * A two-way transform between the application value and the stored value.\n *\n * Both directions may be async. Held as a live reference rather than stringified, so a\n * closure works and `injected` is a convenience rather than the only way in.\n */\nexport type PropertyTransform<T extends any> = {\n /**\n * Application value to stored value. Runs before the plugin sees it. May be async.\n *\n * `entity` is there for the one-way case: a transform with no `from` derives a value\n * rather than converting one, which is what `computed` does.\n */\n to: (value: T, entity: Record<string, unknown>) => unknown | Promise<unknown>;\n\n /**\n * Stored value back to application value. Runs after the plugin returns it.\n *\n * Optional. Leave it out and the transform is one-way: the stored value is the value.\n */\n from?: (value: unknown) => T | Promise<T>;\n\n /**\n * What the column becomes, when the stored form is not the property's own type.\n *\n * Defaults to the property's own type, so nothing changes unless you say it does. A\n * library that always produces text — a cipher, a compressor — sets this once, and the\n * caller who uses that library never writes it.\n */\n stores?: SchemaTypes;\n\n /**\n * Whether a filter on this property can still run in the database.\n *\n * Defaults to `none`, which rejects the filter rather than returning wrong rows. Set\n * `equality` only when `to` is deterministic.\n */\n comparable?: 'equality' | 'none';\n};\n\nexport type SchemaId = Branded<number, \"SchemaId\">;\nexport type CollectionName = Branded<string, \"CollectionName\">;\n\nexport type SchemaModifiers = \"default\" | \"deserialize\" |\n \"identity\" | \"key\" |\n \"nullable\" | \"optional\" |\n \"readonly\" | \"serialize\" |\n \"unmapped\" | \"computed\" |\n \"distinct\" | \"searchable\";\n\n/**\n * What a tagged property infers to.\n *\n * `tag()` is metadata and must not change a type, but `SchemaTag<T>` carries the same `T` as\n * whatever it wrapped without carrying which class that was. For a string `T` is already\n * `string`; for an object `T` is the map of child schemas, which only the `SchemaObject`\n * branch below knows how to unwrap. Falling through to the generic `SchemaBase` branch\n * therefore handed the raw map back, so `s.object({ key: s.string() }).tag('x')` typed\n * `key` as `SchemaString` instead of `string` — everything ran, and only the types lied.\n *\n * An array is distinguishable because `SchemaArray`'s parameter is the ELEMENT schema, so a\n * tagged array arrives here as a `SchemaBase` rather than a plain map.\n */\ntype InferTagged<C> = ResolveWrapped<C>;\n\n/**\n * What a wrapping modifier's inner type resolves to.\n *\n * `SchemaOptional`, `SchemaNullable` and `SchemaTag` all carry the same `C` as whatever they\n * wrapped, without carrying which class that was, so each has to work out what it is holding.\n * Three shapes are possible:\n *\n * - an already-resolved value (`string` from `s.string()`, a file reference from `s.file()`)\n * - an ELEMENT schema, which is what `SchemaArray` parameterises on\n * - a map of child schemas, which is what `SchemaObject` parameterises on\n *\n * Getting this wrong is silent. The map branch applied to an already-resolved object walks\n * its keys and infers `never` for each, so `s.file().optional()` typed as\n * `{ key: never, size: never, ... }` — which no value can satisfy and no test would catch at\n * runtime.\n */\ntype ResolveWrapped<C> =\n C extends string | number | boolean | Date | FileReferenceValue ? C :\n C extends VectorValue ? C :\n C extends SchemaBase<any, any> ? InferPrimitive<C>[] :\n { [K in keyof C]: InferPrimitive<C[K]> };\n\ntype InferPrimitive<T> =\n T extends SchemaOptional<infer C, infer __> ? ResolveWrapped<C> :\n T extends SchemaTag<infer C, infer __> ? InferTagged<C> :\n // Before the generic `SchemaBase` branch below, which would see `X = number[]` and map\n // the element through `InferPrimitive<number>` — no branch matches a bare `number`, so a\n // vector would type as `never[]`: assignable from nothing, and invisible at runtime.\n T extends SchemaVector<infer __, infer ___> ? VectorValue :\n T extends SchemaArray<infer Y, infer __> ? InferPrimitive<Y>[]\n : T extends SchemaObject<infer Obj, infer _> ?\n { [K in keyof Obj]: InferPrimitive<Obj[K]> } : // Process nested objects\n T extends SchemaFunction<infer F, infer __> ? F : T extends SchemaBase<infer X, infer _> ?\n X extends Array<infer A> ? InferPrimitive<A>[] : X : // Extract the primitive type\n never;\n\nexport type InferType<T> = T extends CompiledSchema<infer R> ? InferCompiledSchema<R> : T extends {} ? InferCompiledSchema<T> : T;\nexport type InferCreateType<T> = T extends CompiledSchema<infer R> ? InferCompiledCreateSchema<R> : T extends {} ? InferCompiledCreateSchema<T> : unknown;\nexport type InferMappedType<T> = T extends SchemaBase<infer K, infer __> ? InferType<K> : InferCompiledSchema<T>;\nexport type InferRoot<T> = T extends CompiledSchema<infer R> ? R : never;\n\ntype HasModifier<T, K extends keyof T, M extends SchemaModifiers> =\n T[K] extends SchemaBase<any, infer Mods> ?\n M extends Mods ? true : false :\n false;\n\ntype IsPlainProperty<T, K extends keyof T> =\n [\n HasModifier<T, K, \"readonly\">,\n HasModifier<T, K, \"optional\">,\n HasModifier<T, K, \"nullable\">\n ] extends [\n false,\n false,\n false\n ] ? true : false;\n\ntype IsCreateExcluded<T, K extends keyof T> =\n [\n HasModifier<T, K, \"identity\">,\n HasModifier<T, K, \"computed\">,\n HasModifier<T, K, \"unmapped\">\n ] extends [\n false,\n false,\n false\n ] ? false : true;\n\ntype IsCreateOptional<T, K extends keyof T> =\n [\n HasModifier<T, K, \"optional\">,\n HasModifier<T, K, \"default\">\n ] extends [\n false,\n false\n ] ? false : true;\n\ntype IsCreateNullable<T, K extends keyof T> =\n HasModifier<T, K, \"nullable\"> extends true ? true : false;\n\n/**\n * What a property ACCEPTS on the way in, which is not always what it gives back.\n *\n * Only a file differs today: you assign content and read a reference. Matching on the read\n * type rather than on `SchemaFile` itself is deliberate — it keeps working through every\n * modifier. `s.file().optional()` is a `SchemaOptional`, `s.file().tag('x')` is a\n * `SchemaTag`, and neither carries the original class, so a check against the class alone\n * would silently stop accepting content the moment anyone added a modifier.\n *\n * Assignability is required in BOTH directions, and the tuple wrappers are load-bearing.\n * One-way `extends` matches `never` — which is assignable to everything — so a generic\n * property over `Record<string, unknown>` resolved to file content and broke the Dexie\n * plugin's types. It also matched any object that merely happens to have these five fields\n * plus more. Mutual assignability admits the reference shape and nothing else, and the\n * tuples stop the conditional distributing over a union.\n */\ntype InferWritePrimitive<T> =\n [InferPrimitive<T>] extends [FileReferenceValue]\n ? [FileReferenceValue] extends [InferPrimitive<T>] ? FileContentValue : InferPrimitive<T>\n : InferPrimitive<T>;\n\ntype InferCreateProperty<T, K extends keyof T> =\n IsCreateNullable<T, K> extends true ? null | InferWritePrimitive<T[K]> : InferWritePrimitive<T[K]>;\n\ntype InferCompiledSchema<T> = CoalesceEmpty<{\n [K in keyof T as IsPlainProperty<T, K> extends true ? K : never]: InferPrimitive<T[K]>\n}, {\n readonly [K in keyof T as HasModifier<T, K, \"readonly\"> extends true ? K : never]: InferPrimitive<T[K]>\n }, {\n [K in keyof T as HasModifier<T, K, \"optional\"> extends true ? K : never]?: InferPrimitive<T[K]>\n }, {\n [K in keyof T as HasModifier<T, K, \"nullable\"> extends true ? K : never]: null | InferPrimitive<T[K]>\n}>;\n\ntype InferCompiledCreateSchema<T> = {\n [K in keyof T as IsCreateExcluded<T, K> extends true ? never\n : IsCreateOptional<T, K> extends true ? K : never]?: InferCreateProperty<T, K>\n} & {\n [K in keyof T as IsCreateExcluded<T, K> extends true ? never\n : IsCreateOptional<T, K> extends true ? never : K]: InferCreateProperty<T, K>\n};\n\ntype IsEmptyObject<T> = keyof T extends never ? true : false;\ntype CoalesceEmpty<T1 extends {}, T2 extends {}, T3 extends {}, T4 extends {}> = (IsEmptyObject<T1> extends true ? {} : T1) & (IsEmptyObject<T2> extends true ? {} : T2) & (IsEmptyObject<T3> extends true ? {} : T3) & (IsEmptyObject<T4> extends true ? {} : T4);\n","export const uuid = (length: number = 16): string => {\n const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';\n const charLength = chars.length;\n let result = '';\n\n for (let i = 0; i < length; i++) {\n result += chars[Math.random() * charLength | 0];\n }\n return result;\n}\n\nconst HEX_CHARS = '0123456789abcdef';\nconst UUID_TEMPLATE = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx';\n\nconst hasCrypto =\n typeof crypto !== 'undefined' && typeof crypto.getRandomValues === 'function';\n\nconst hasRandomUUID =\n typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function';\n\nexport const uuidv4 = (): string => {\n if (hasRandomUUID) {\n return crypto.randomUUID();\n }\n\n return uuidv4Fallback();\n};\n\nconst uuidv4Fallback = (): string => {\n let randomBytes: Uint8Array | null = null;\n if (hasCrypto) {\n randomBytes = crypto.getRandomValues(new Uint8Array(16));\n }\n\n let byteIndex = 0;\n let uuid = '';\n\n for (let i = 0; i < UUID_TEMPLATE.length; i++) {\n const c = UUID_TEMPLATE[i];\n if (c === '-') {\n uuid += '-';\n continue;\n }\n\n let r: number;\n if (hasCrypto && randomBytes) {\n // Each byte gives two hex digits (nibbles)\n r =\n (i % 2 === 0\n ? randomBytes[byteIndex] >> 4\n : randomBytes[byteIndex++] & 0x0f);\n } else {\n r = Math.floor(Math.random() * 16);\n }\n\n if (c === 'x') {\n uuid += HEX_CHARS[r];\n } else if (c === 'y') {\n // Variant bits: 8, 9, A, or B\n uuid += HEX_CHARS[(r & 0x3) | 0x8];\n } else if (c === '4') {\n uuid += '4';\n }\n }\n\n return uuid;\n};\n","__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","import { IdType } from \"../schema\";\n\nexport class IdSet {\n\n readonly ids: readonly IdType[];\n\n constructor(...ids: IdType[]) {\n this.ids = Object.freeze(ids);\n }\n\n equals(other: IdSet): boolean {\n\n if (this.ids.length === 1) {\n return this.ids[0] === other.ids[0];\n }\n\n return this.toString() === other.toString();\n }\n\n toString(): string {\n\n if (this.ids.length === 1) {\n return String(this.ids[0]);\n }\n\n return this.ids.toString();\n }\n}","import { CompiledSchema, IdType, InferType, PropertyInfo, SchemaTypes } from \"../schema\";\nimport { CallbackResult, Result } from \"../results\";\nimport { uuidv4 } from \"../utilities\";\nimport { IdSet } from \"./IdSet\";\n\nexport class MemoryDataCollection {\n\n protected readonly nextNumericalIds: Map<string, number>;\n protected readonly data: Map<string, Record<string, unknown>>;\n protected readonly schema: CompiledSchema<any>;\n protected readonly idProperties: PropertyInfo<any>[];\n\n get size() {\n return this.data.size;\n }\n\n get records() {\n return [...this.data.values()];\n }\n\n /** Iterates stored records without materializing them into an array. */\n values(): IterableIterator<Record<string, unknown>> {\n return this.data.values();\n }\n\n constructor(schema: CompiledSchema<any>) {\n this.data = new Map<string, Record<string, unknown>>();\n this.nextNumericalIds = new Map<string, number>();\n this.schema = schema;\n this.idProperties = schema.idProperties;\n }\n\n private _getNextId(property: PropertyInfo<any>) {\n\n let nextId = 1;\n\n if (this.nextNumericalIds.has(property.id) === true) {\n nextId = this.nextNumericalIds.get(property.id) + 1;\n }\n\n this.nextNumericalIds.set(property.id, nextId);\n\n return nextId;\n }\n\n private resolveId(property: PropertyInfo<any>, value: unknown) {\n if (typeof value !== \"number\") {\n return;\n }\n\n const currentIdForProperty = this.nextNumericalIds.get(property.id);\n\n if (value <= currentIdForProperty) {\n return;\n }\n\n this.nextNumericalIds.set(property.id, value);\n }\n\n private getAndSetId(item: Record<string, unknown>, property: PropertyInfo<any>): IdType {\n if (item[property.name] != null) {\n return item[property.name] as IdType;\n }\n\n if (property.type === SchemaTypes.String) {\n const uuid = uuidv4()\n item[property.name] = uuid;\n return uuid;\n }\n\n if (property.type === SchemaTypes.Number) {\n const id = this._getNextId(property);\n item[property.name] = id;\n return id;\n }\n\n throw new Error(`Id Property '${property.name}' must be string or number, found '${property.type}'`)\n }\n\n seed(items: Record<string, unknown>[]) {\n for (let i = 0, length = items.length; i < length; i++) {\n const id = this.resolveIdSet(items[i] as InferType<unknown>);\n this.data.set(id.toString(), items[i]);\n }\n }\n\n private resolveCurrentIdSet(item: Record<string, unknown>): IdSet {\n const idProperties = this.schema.idProperties;\n const ids: IdType[] = [];\n // ensure keys\n for (let j = 0, l = idProperties.length; j < l; j++) {\n const property = idProperties[j];\n const value = property.getValue(item);\n\n if (value == null) {\n throw new Error(`Key cannot be null. Key: ${property.name}`);\n }\n\n ids.push(value);\n }\n\n return new IdSet(...ids);\n }\n\n private resolveIdSet(item: Record<string, unknown>): IdSet {\n\n if (this.schema.hasIdentityKeys) {\n const idProperties = this.schema.idProperties;\n const ids: IdType[] = Array.from({ length: idProperties.length });\n\n // Need to make sure we allow for seeding the collection when we call add vs seed\n // There will be an existing id, but the id type could still be identity\n if (idProperties.length === 1) {\n const value = this.getAndSetId(item, idProperties[0]);\n this.resolveId(idProperties[0], value);\n ids[0] = value;\n } else {\n for (let j = 0, l = idProperties.length; j < l; j++) {\n const value = this.getAndSetId(item, idProperties[j]);\n this.resolveId(idProperties[j], value);\n ids[j] = value;\n }\n }\n\n return new IdSet(...ids);\n }\n\n return this.resolveCurrentIdSet(item);\n }\n\n add(item: Record<string, unknown>) {\n const id = this.resolveIdSet(item);\n this.data.set(id.toString(), item);\n }\n\n /**\n * Adds a record only when no record with the same key is present. Durable\n * collections use this to hydrate stored records around in-memory mutations\n * without clobbering them.\n */\n addIfAbsent(item: Record<string, unknown>) {\n const id = this.resolveIdSet(item);\n const key = id.toString();\n\n if (this.data.has(key) === false) {\n this.data.set(key, item);\n }\n }\n\n /**\n * Looks up a single record by its key values without scanning the collection.\n * @param ids Key values in schema id property order\n * @returns The matching record or undefined when no record has the given key\n */\n getByIds(ids: IdType[]): Record<string, unknown> | undefined {\n return this.data.get(new IdSet(...ids).toString());\n }\n\n remove(item: Record<string, unknown>) {\n const id = this.resolveCurrentIdSet(item);\n this.data.delete(id.toString());\n }\n\n update(item: Record<string, unknown>) {\n const id = this.resolveCurrentIdSet(item);\n this.data.set(id.toString(), item);\n }\n\n destroy(done: CallbackResult<never>) {\n this.nextNumericalIds.clear();\n this.data.clear();\n done(Result.success());\n }\n\n load(done: CallbackResult<never>) {\n done(Result.success())\n }\n\n save(done: CallbackResult<never>) {\n done(Result.success())\n }\n}","export * from './Changes';\nexport * from './TagCollection';\nexport * from './IdSet';\nexport * from './MemoryDataCollection';\nexport * from './SchemaCollection';\nexport * from './ReadonlySchemaCollection';"],"names":["TagCollection","BulkPersistResult","Map","schemaId","SchemaPersistResult","count","result","BulkPersistChanges","SchemaPersistChanges","ReadonlySchemaCollection","data","callbackfn","thisArg","Symbol","collectionName","found","x","undefined","SchemaCollection","schema","key","tag","keys","i","length","tags","value","BaseResult","resolve","reject","Error","Result","error","PluginEventResult","id","SchemaTypes","HashType","uuid","chars","charLength","Math","HEX_CHARS","UUID_TEMPLATE","hasCrypto","crypto","hasRandomUUID","uuidv4","uuidv4Fallback","randomBytes","Uint8Array","byteIndex","c","r","IdSet","ids","Object","other","String","MemoryDataCollection","property","nextId","currentIdForProperty","item","items","idProperties","j","l","Array","done"],"mappings":";;;;;;;;;AAEgD;AACzC,MAAMC,0BAA0BC;IAEnC,QAAgDC,QAAkB,EAA0B;QACxF,IAAI,IAAI,CAAC,GAAG,CAACA,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IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAACd,SAAS,OAAO;YAC9B,IAAI,CAAC,IAAI,CAAC,GAAG,CAACA,KAAK0C;QACvB;IACJ;IAEA;;;;KAIC,GACD,SAASR,GAAa,EAAuC;QACzD,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAID,KAAKA,IAAIC,KAAK,QAAQ;IACnD;IAEA,OAAOQ,IAA6B,EAAE;QAClC,MAAM5B,KAAK,IAAI,CAAC,mBAAmB,CAAC4B;QACpC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC5B,GAAG,QAAQ;IAChC;IAEA,OAAO4B,IAA6B,EAAE;QAClC,MAAM5B,KAAK,IAAI,CAAC,mBAAmB,CAAC4B;QACpC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC5B,GAAG,QAAQ,IAAI4B;IACjC;IAEA,QAAQM,IAA2B,EAAE;QACjC,IAAI,CAAC,gBAAgB,CAAC,KAAK;QAC3B,IAAI,CAAC,IAAI,CAAC,KAAK;QACfA,KAAKrC,qCAAc;IACvB;IAEA,KAAKqC,IAA2B,EAAE;QAC9BA,KAAKrC,qCAAc;IACvB;IAEA,KAAKqC,IAA2B,EAAE;QAC9BA,KAAKrC,qCAAc;IACvB;AACJ;;;;;;;ACrL0B;AACM;AACR;AACe;AACJ;AACQ"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { IdType } from "../schema";
|
|
2
|
+
/**
|
|
3
|
+
* A save was rejected because another writer changed one of its rows first.
|
|
4
|
+
*
|
|
5
|
+
* Raised when a schema declares a `.concurrency()` token and an update's expected token
|
|
6
|
+
* no longer matches the stored row. The whole save is rolled back — nothing was applied.
|
|
7
|
+
* The caller's recovery is always the same: re-read the conflicted rows (the re-read
|
|
8
|
+
* merges fresh values into the canonical instances), reapply the intent, and save again.
|
|
9
|
+
*/
|
|
10
|
+
export declare class OptimisticConcurrencyError extends Error {
|
|
11
|
+
/** The collection whose rows conflicted. */
|
|
12
|
+
readonly collectionName: string;
|
|
13
|
+
/** Ids of the rows whose stored token no longer matched the writer's read. */
|
|
14
|
+
readonly conflicts: IdType[];
|
|
15
|
+
constructor(collectionName: string, conflicts: IdType[]);
|
|
16
|
+
/** Type guard that survives errors crossing realm/serialization boundaries. */
|
|
17
|
+
static is(error: unknown): error is OptimisticConcurrencyError;
|
|
18
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A write that was accepted but never reached the database, because the plugin holding it was
|
|
3
|
+
* destroyed first — or one submitted after the destroy.
|
|
4
|
+
*
|
|
5
|
+
* Distinct from a backend failure on purpose: nothing was attempted, so a caller that retries
|
|
6
|
+
* on transient errors must not retry this one. There is no database left to retry against.
|
|
7
|
+
*/
|
|
8
|
+
export declare class PluginDestroyedError extends Error {
|
|
9
|
+
constructor(reason: string);
|
|
10
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
(() => {
|
|
2
|
+
"use strict";
|
|
3
|
+
var __webpack_modules__ = ({
|
|
4
|
+
624(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
5
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
6
|
+
V: () => (OptimisticConcurrencyError)
|
|
7
|
+
});
|
|
8
|
+
/**
|
|
9
|
+
* A save was rejected because another writer changed one of its rows first.
|
|
10
|
+
*
|
|
11
|
+
* Raised when a schema declares a `.concurrency()` token and an update's expected token
|
|
12
|
+
* no longer matches the stored row. The whole save is rolled back — nothing was applied.
|
|
13
|
+
* The caller's recovery is always the same: re-read the conflicted rows (the re-read
|
|
14
|
+
* merges fresh values into the canonical instances), reapply the intent, and save again.
|
|
15
|
+
*/ class OptimisticConcurrencyError extends Error {
|
|
16
|
+
/** The collection whose rows conflicted. */ collectionName;
|
|
17
|
+
/** Ids of the rows whose stored token no longer matched the writer's read. */ conflicts;
|
|
18
|
+
constructor(collectionName, conflicts){
|
|
19
|
+
super(`Optimistic concurrency conflict on '${collectionName}': ${conflicts.length} row(s) were changed by another writer after they were read. ` + `Nothing was saved. Re-read the rows, reapply the changes, and save again. Conflicted ids: ${conflicts.map(String).join(", ")}`);
|
|
20
|
+
this.name = "OptimisticConcurrencyError";
|
|
21
|
+
this.collectionName = collectionName;
|
|
22
|
+
this.conflicts = conflicts;
|
|
23
|
+
}
|
|
24
|
+
/** Type guard that survives errors crossing realm/serialization boundaries. */ static is(error) {
|
|
25
|
+
return error instanceof OptimisticConcurrencyError || error != null && typeof error === "object" && error.name === "OptimisticConcurrencyError";
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
},
|
|
31
|
+
850(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
32
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
33
|
+
f: () => (PluginDestroyedError)
|
|
34
|
+
});
|
|
35
|
+
/**
|
|
36
|
+
* A write that was accepted but never reached the database, because the plugin holding it was
|
|
37
|
+
* destroyed first — or one submitted after the destroy.
|
|
38
|
+
*
|
|
39
|
+
* Distinct from a backend failure on purpose: nothing was attempted, so a caller that retries
|
|
40
|
+
* on transient errors must not retry this one. There is no database left to retry against.
|
|
41
|
+
*/ class PluginDestroyedError extends Error {
|
|
42
|
+
constructor(reason){
|
|
43
|
+
super(`The plugin was destroyed: ${reason}`);
|
|
44
|
+
this.name = "PluginDestroyedError";
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
},
|
|
50
|
+
131(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
51
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
52
|
+
A: () => (SchemaError)
|
|
53
|
+
});
|
|
54
|
+
class SchemaError extends Error {
|
|
55
|
+
constructor(error, innerErrorMessage){
|
|
56
|
+
super(`Error: ${error.message}; Inner Error: ${innerErrorMessage}`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
});
|
|
64
|
+
// The module cache
|
|
65
|
+
var __webpack_module_cache__ = {};
|
|
66
|
+
|
|
67
|
+
// The require function
|
|
68
|
+
function __webpack_require__(moduleId) {
|
|
69
|
+
|
|
70
|
+
// Check if module is in cache
|
|
71
|
+
var cachedModule = __webpack_module_cache__[moduleId];
|
|
72
|
+
if (cachedModule !== undefined) {
|
|
73
|
+
return cachedModule.exports;
|
|
74
|
+
}
|
|
75
|
+
// Create a new module (and put it into the cache)
|
|
76
|
+
var module = (__webpack_module_cache__[moduleId] = {
|
|
77
|
+
exports: {}
|
|
78
|
+
});
|
|
79
|
+
// Execute the module function
|
|
80
|
+
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
81
|
+
|
|
82
|
+
// Return the exports of the module
|
|
83
|
+
return module.exports;
|
|
84
|
+
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// webpack/runtime/define_property_getters
|
|
88
|
+
(() => {
|
|
89
|
+
__webpack_require__.d = (exports, definition) => {
|
|
90
|
+
for(var key in definition) {
|
|
91
|
+
if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
|
92
|
+
Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
})();
|
|
97
|
+
// webpack/runtime/has_own_property
|
|
98
|
+
(() => {
|
|
99
|
+
__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
100
|
+
})();
|
|
101
|
+
// webpack/runtime/make_namespace_object
|
|
102
|
+
(() => {
|
|
103
|
+
// define __esModule on exports
|
|
104
|
+
__webpack_require__.r = (exports) => {
|
|
105
|
+
if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
106
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
107
|
+
}
|
|
108
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
109
|
+
};
|
|
110
|
+
})();
|
|
111
|
+
var __webpack_exports__ = {};
|
|
112
|
+
// This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk.
|
|
113
|
+
(() => {
|
|
114
|
+
__webpack_require__.r(__webpack_exports__);
|
|
115
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
116
|
+
OptimisticConcurrencyError: () => (/* reexport safe */ _OptimisticConcurrencyError__rspack_import_1.V),
|
|
117
|
+
PluginDestroyedError: () => (/* reexport safe */ _PluginDestroyedError__rspack_import_2.f),
|
|
118
|
+
SchemaError: () => (/* reexport safe */ _SchemaError__rspack_import_0.A)
|
|
119
|
+
});
|
|
120
|
+
/* import */ var _SchemaError__rspack_import_0 = __webpack_require__(131);
|
|
121
|
+
/* import */ var _OptimisticConcurrencyError__rspack_import_1 = __webpack_require__(624);
|
|
122
|
+
/* import */ var _PluginDestroyedError__rspack_import_2 = __webpack_require__(850);
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
})();
|
|
128
|
+
|
|
129
|
+
module.exports = __webpack_exports__;
|
|
130
|
+
})()
|
|
131
|
+
;
|
|
132
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors/index.cjs","sources":["webpack://@routier/core/./src/errors/OptimisticConcurrencyError.ts","webpack://@routier/core/./src/errors/PluginDestroyedError.ts","webpack://@routier/core/./src/errors/SchemaError.ts","webpack://@routier/core/webpack/runtime/define_property_getters","webpack://@routier/core/webpack/runtime/has_own_property","webpack://@routier/core/webpack/runtime/make_namespace_object","webpack://@routier/core/./src/errors/index.ts"],"sourcesContent":["import { IdType } from \"../schema\";\n\n/**\n * A save was rejected because another writer changed one of its rows first.\n *\n * Raised when a schema declares a `.concurrency()` token and an update's expected token\n * no longer matches the stored row. The whole save is rolled back — nothing was applied.\n * The caller's recovery is always the same: re-read the conflicted rows (the re-read\n * merges fresh values into the canonical instances), reapply the intent, and save again.\n */\nexport class OptimisticConcurrencyError extends Error {\n\n /** The collection whose rows conflicted. */\n readonly collectionName: string;\n /** Ids of the rows whose stored token no longer matched the writer's read. */\n readonly conflicts: IdType[];\n\n constructor(collectionName: string, conflicts: IdType[]) {\n super(\n `Optimistic concurrency conflict on '${collectionName}': ${conflicts.length} row(s) were changed by another writer after they were read. ` +\n `Nothing was saved. Re-read the rows, reapply the changes, and save again. Conflicted ids: ${conflicts.map(String).join(\", \")}`\n );\n this.name = \"OptimisticConcurrencyError\";\n this.collectionName = collectionName;\n this.conflicts = conflicts;\n }\n\n /** Type guard that survives errors crossing realm/serialization boundaries. */\n static is(error: unknown): error is OptimisticConcurrencyError {\n return error instanceof OptimisticConcurrencyError\n || (error != null && typeof error === \"object\" && (error as Error).name === \"OptimisticConcurrencyError\");\n }\n}\n","/**\n * A write that was accepted but never reached the database, because the plugin holding it was\n * destroyed first — or one submitted after the destroy.\n *\n * Distinct from a backend failure on purpose: nothing was attempted, so a caller that retries\n * on transient errors must not retry this one. There is no database left to retry against.\n */\nexport class PluginDestroyedError extends Error {\n\n constructor(reason: string) {\n super(`The plugin was destroyed: ${reason}`);\n this.name = \"PluginDestroyedError\";\n }\n}\n","export class SchemaError extends Error {\n\n constructor(error: any, innerErrorMessage: string) {\n super(`Error: ${error.message}; Inner Error: ${innerErrorMessage}`);\n }\n}","__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","export { SchemaError } from './SchemaError';\nexport { OptimisticConcurrencyError } from './OptimisticConcurrencyError';\nexport { PluginDestroyedError } from './PluginDestroyedError';\n"],"names":["OptimisticConcurrencyError","Error","collectionName","conflicts","String","error","PluginDestroyedError","reason","SchemaError","innerErrorMessage"],"mappings":";;;;;;;AAEA;;;;;;;CAOC,GACM,MAAMA,mCAAmCC;IAE5C,0CAA0C,GACjC,eAAuB;IAChC,4EAA4E,GACnE,UAAoB;IAE7B,YAAYC,cAAsB,EAAEC,SAAmB,CAAE;QACrD,KAAK,CACD,CAAC,oCAAoC,EAAED,eAAe,GAAG,EAAEC,UAAU,MAAM,CAAC,6DAA6D,CAAC,GAC1I,CAAC,0FAA0F,EAAEA,UAAU,GAAG,CAACC,QAAQ,IAAI,CAAC,OAAO;QAEnI,IAAI,CAAC,IAAI,GAAG;QACZ,IAAI,CAAC,cAAc,GAAGF;QACtB,IAAI,CAAC,SAAS,GAAGC;IACrB;IAEA,6EAA6E,GAC7E,OAAO,GAAGE,KAAc,EAAuC;QAC3D,OAAOA,iBAAiBL,8BAChBK,SAAS,QAAQ,OAAOA,UAAU,YAAaA,MAAgB,IAAI,KAAK;IACpF;AACJ;;;;;;;;AChCA;;;;;;CAMC,GACM,MAAMC,6BAA6BL;IAEtC,YAAYM,MAAc,CAAE;QACxB,KAAK,CAAC,CAAC,0BAA0B,EAAEA,QAAQ;QAC3C,IAAI,CAAC,IAAI,GAAG;IAChB;AACJ;;;;;;;;ACbO,MAAMC,oBAAoBP;IAE7B,YAAYI,KAAU,EAAEI,iBAAyB,CAAE;QAC/C,KAAK,CAAC,CAAC,OAAO,EAAEJ,MAAM,OAAO,CAAC,eAAe,EAAEI,mBAAmB;IACtE;AACJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACLA;AACA;AACA;AACA,kDAAkD,wCAAwC;AAC1F;AACA;AACA,E;;;;ACNA,wF;;;;ACAA;AACA;AACA;AACA,uDAAuD,iBAAiB;AACxE;AACA,gDAAgD,aAAa;AAC7D,E;;;;;;;;;;;;;;ACN4C;AAC8B;AACZ"}
|
package/dist/errors/index.d.ts
CHANGED
package/dist/errors/index.js
CHANGED
|
@@ -1,11 +1,56 @@
|
|
|
1
1
|
var __webpack_modules__ = ({
|
|
2
|
-
|
|
3
|
-
__webpack_require__.r(__webpack_exports__);
|
|
2
|
+
624(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
4
3
|
__webpack_require__.d(__webpack_exports__, {
|
|
5
|
-
|
|
4
|
+
V: () => (OptimisticConcurrencyError)
|
|
5
|
+
});
|
|
6
|
+
/**
|
|
7
|
+
* A save was rejected because another writer changed one of its rows first.
|
|
8
|
+
*
|
|
9
|
+
* Raised when a schema declares a `.concurrency()` token and an update's expected token
|
|
10
|
+
* no longer matches the stored row. The whole save is rolled back — nothing was applied.
|
|
11
|
+
* The caller's recovery is always the same: re-read the conflicted rows (the re-read
|
|
12
|
+
* merges fresh values into the canonical instances), reapply the intent, and save again.
|
|
13
|
+
*/ class OptimisticConcurrencyError extends Error {
|
|
14
|
+
/** The collection whose rows conflicted. */ collectionName;
|
|
15
|
+
/** Ids of the rows whose stored token no longer matched the writer's read. */ conflicts;
|
|
16
|
+
constructor(collectionName, conflicts){
|
|
17
|
+
super(`Optimistic concurrency conflict on '${collectionName}': ${conflicts.length} row(s) were changed by another writer after they were read. ` + `Nothing was saved. Re-read the rows, reapply the changes, and save again. Conflicted ids: ${conflicts.map(String).join(", ")}`);
|
|
18
|
+
this.name = "OptimisticConcurrencyError";
|
|
19
|
+
this.collectionName = collectionName;
|
|
20
|
+
this.conflicts = conflicts;
|
|
21
|
+
}
|
|
22
|
+
/** Type guard that survives errors crossing realm/serialization boundaries. */ static is(error) {
|
|
23
|
+
return error instanceof OptimisticConcurrencyError || error != null && typeof error === "object" && error.name === "OptimisticConcurrencyError";
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
},
|
|
29
|
+
850(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
30
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
31
|
+
f: () => (PluginDestroyedError)
|
|
32
|
+
});
|
|
33
|
+
/**
|
|
34
|
+
* A write that was accepted but never reached the database, because the plugin holding it was
|
|
35
|
+
* destroyed first — or one submitted after the destroy.
|
|
36
|
+
*
|
|
37
|
+
* Distinct from a backend failure on purpose: nothing was attempted, so a caller that retries
|
|
38
|
+
* on transient errors must not retry this one. There is no database left to retry against.
|
|
39
|
+
*/ class PluginDestroyedError extends Error {
|
|
40
|
+
constructor(reason){
|
|
41
|
+
super(`The plugin was destroyed: ${reason}`);
|
|
42
|
+
this.name = "PluginDestroyedError";
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
},
|
|
48
|
+
131(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
49
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
50
|
+
A: () => (SchemaError)
|
|
6
51
|
});
|
|
7
52
|
class SchemaError extends Error {
|
|
8
|
-
constructor(error, innerErrorMessage)
|
|
53
|
+
constructor(error, innerErrorMessage){
|
|
9
54
|
super(`Error: ${error.message}; Inner Error: ${innerErrorMessage}`);
|
|
10
55
|
}
|
|
11
56
|
}
|
|
@@ -51,29 +96,26 @@ __webpack_require__.d = (exports, definition) => {
|
|
|
51
96
|
(() => {
|
|
52
97
|
__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
53
98
|
})();
|
|
54
|
-
// webpack/runtime/make_namespace_object
|
|
55
|
-
(() => {
|
|
56
|
-
// define __esModule on exports
|
|
57
|
-
__webpack_require__.r = (exports) => {
|
|
58
|
-
if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
59
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
60
|
-
}
|
|
61
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
62
|
-
};
|
|
63
|
-
})();
|
|
64
99
|
var __webpack_exports__ = {};
|
|
65
100
|
// This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk.
|
|
66
101
|
(() => {
|
|
67
|
-
__webpack_require__.r(__webpack_exports__);
|
|
68
102
|
__webpack_require__.d(__webpack_exports__, {
|
|
69
|
-
|
|
103
|
+
Ar: () => (/* reexport safe */ _SchemaError__rspack_import_0.A),
|
|
104
|
+
VT: () => (/* reexport safe */ _OptimisticConcurrencyError__rspack_import_1.V),
|
|
105
|
+
fL: () => (/* reexport safe */ _PluginDestroyedError__rspack_import_2.f)
|
|
70
106
|
});
|
|
71
|
-
/* import */ var _SchemaError__rspack_import_0 = __webpack_require__(
|
|
107
|
+
/* import */ var _SchemaError__rspack_import_0 = __webpack_require__(131);
|
|
108
|
+
/* import */ var _OptimisticConcurrencyError__rspack_import_1 = __webpack_require__(624);
|
|
109
|
+
/* import */ var _PluginDestroyedError__rspack_import_2 = __webpack_require__(850);
|
|
110
|
+
|
|
111
|
+
|
|
72
112
|
|
|
73
113
|
|
|
74
114
|
})();
|
|
75
115
|
|
|
76
|
-
var
|
|
77
|
-
|
|
116
|
+
var __webpack_exports__OptimisticConcurrencyError = __webpack_exports__.VT;
|
|
117
|
+
var __webpack_exports__PluginDestroyedError = __webpack_exports__.fL;
|
|
118
|
+
var __webpack_exports__SchemaError = __webpack_exports__.Ar;
|
|
119
|
+
export { __webpack_exports__OptimisticConcurrencyError as OptimisticConcurrencyError, __webpack_exports__PluginDestroyedError as PluginDestroyedError, __webpack_exports__SchemaError as SchemaError };
|
|
78
120
|
|
|
79
121
|
//# sourceMappingURL=index.js.map
|
package/dist/errors/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors/index.js","sources":["webpack://@routier/core/./src/errors/
|
|
1
|
+
{"version":3,"file":"errors/index.js","sources":["webpack://@routier/core/./src/errors/OptimisticConcurrencyError.ts","webpack://@routier/core/./src/errors/PluginDestroyedError.ts","webpack://@routier/core/./src/errors/SchemaError.ts","webpack://@routier/core/webpack/runtime/define_property_getters","webpack://@routier/core/webpack/runtime/has_own_property","webpack://@routier/core/./src/errors/index.ts"],"sourcesContent":["import { IdType } from \"../schema\";\n\n/**\n * A save was rejected because another writer changed one of its rows first.\n *\n * Raised when a schema declares a `.concurrency()` token and an update's expected token\n * no longer matches the stored row. The whole save is rolled back — nothing was applied.\n * The caller's recovery is always the same: re-read the conflicted rows (the re-read\n * merges fresh values into the canonical instances), reapply the intent, and save again.\n */\nexport class OptimisticConcurrencyError extends Error {\n\n /** The collection whose rows conflicted. */\n readonly collectionName: string;\n /** Ids of the rows whose stored token no longer matched the writer's read. */\n readonly conflicts: IdType[];\n\n constructor(collectionName: string, conflicts: IdType[]) {\n super(\n `Optimistic concurrency conflict on '${collectionName}': ${conflicts.length} row(s) were changed by another writer after they were read. ` +\n `Nothing was saved. Re-read the rows, reapply the changes, and save again. Conflicted ids: ${conflicts.map(String).join(\", \")}`\n );\n this.name = \"OptimisticConcurrencyError\";\n this.collectionName = collectionName;\n this.conflicts = conflicts;\n }\n\n /** Type guard that survives errors crossing realm/serialization boundaries. */\n static is(error: unknown): error is OptimisticConcurrencyError {\n return error instanceof OptimisticConcurrencyError\n || (error != null && typeof error === \"object\" && (error as Error).name === \"OptimisticConcurrencyError\");\n }\n}\n","/**\n * A write that was accepted but never reached the database, because the plugin holding it was\n * destroyed first — or one submitted after the destroy.\n *\n * Distinct from a backend failure on purpose: nothing was attempted, so a caller that retries\n * on transient errors must not retry this one. There is no database left to retry against.\n */\nexport class PluginDestroyedError extends Error {\n\n constructor(reason: string) {\n super(`The plugin was destroyed: ${reason}`);\n this.name = \"PluginDestroyedError\";\n }\n}\n","export class SchemaError extends Error {\n\n constructor(error: any, innerErrorMessage: string) {\n super(`Error: ${error.message}; Inner Error: ${innerErrorMessage}`);\n }\n}","__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","export { SchemaError } from './SchemaError';\nexport { OptimisticConcurrencyError } from './OptimisticConcurrencyError';\nexport { PluginDestroyedError } from './PluginDestroyedError';\n"],"names":["OptimisticConcurrencyError","Error","collectionName","conflicts","String","error","PluginDestroyedError","reason","SchemaError","innerErrorMessage"],"mappings":";;;;;AAEA;;;;;;;CAOC,GACM,MAAMA,mCAAmCC;IAE5C,0CAA0C,GACjC,eAAuB;IAChC,4EAA4E,GACnE,UAAoB;IAE7B,YAAYC,cAAsB,EAAEC,SAAmB,CAAE;QACrD,KAAK,CACD,CAAC,oCAAoC,EAAED,eAAe,GAAG,EAAEC,UAAU,MAAM,CAAC,6DAA6D,CAAC,GAC1I,CAAC,0FAA0F,EAAEA,UAAU,GAAG,CAACC,QAAQ,IAAI,CAAC,OAAO;QAEnI,IAAI,CAAC,IAAI,GAAG;QACZ,IAAI,CAAC,cAAc,GAAGF;QACtB,IAAI,CAAC,SAAS,GAAGC;IACrB;IAEA,6EAA6E,GAC7E,OAAO,GAAGE,KAAc,EAAuC;QAC3D,OAAOA,iBAAiBL,8BAChBK,SAAS,QAAQ,OAAOA,UAAU,YAAaA,MAAgB,IAAI,KAAK;IACpF;AACJ;;;;;;;;AChCA;;;;;;CAMC,GACM,MAAMC,6BAA6BL;IAEtC,YAAYM,MAAc,CAAE;QACxB,KAAK,CAAC,CAAC,0BAA0B,EAAEA,QAAQ;QAC3C,IAAI,CAAC,IAAI,GAAG;IAChB;AACJ;;;;;;;;ACbO,MAAMC,oBAAoBP;IAE7B,YAAYI,KAAU,EAAEI,iBAAyB,CAAE;QAC/C,KAAK,CAAC,CAAC,OAAO,EAAEJ,MAAM,OAAO,CAAC,eAAe,EAAEI,mBAAmB;IACtE;AACJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACLA;AACA;AACA;AACA,kDAAkD,wCAAwC;AAC1F;AACA;AACA,E;;;;ACNA,wF;;;;;;;;;;;;;ACA4C;AAC8B;AACZ"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { UnknownRecord } from "../utilities";
|
|
2
|
+
import { Expression } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Runs a parsed expression against a row.
|
|
5
|
+
*
|
|
6
|
+
* The counterpart to `toSql` and `toMql`: those turn a tree into a backend's language, and this
|
|
7
|
+
* turns it into an answer. Needed wherever a tree exists but the closure that produced it does
|
|
8
|
+
* not — a filter split out of a larger predicate, an option rebuilt from a serialized query.
|
|
9
|
+
*
|
|
10
|
+
* ## It fails OPEN, and that is the whole safety argument
|
|
11
|
+
*
|
|
12
|
+
* `undefined` means "this tree cannot be evaluated here" — an unknown node, a transformer with no
|
|
13
|
+
* implementation, a comparison between shapes that do not compare. Callers must read that as KEEP
|
|
14
|
+
* THE ROW, never as exclude it.
|
|
15
|
+
*
|
|
16
|
+
* The reason is asymmetric cost. Every caller today uses this to NARROW something that a
|
|
17
|
+
* subsequent, authoritative predicate will check again: a semi-join prefilter, a split conjunct.
|
|
18
|
+
* Keeping a row this cannot judge costs one wasted comparison downstream. Dropping one loses data
|
|
19
|
+
* from a query result and nothing anywhere reports it. So every uncertain path returns `undefined`,
|
|
20
|
+
* and no path guesses `false`.
|
|
21
|
+
*
|
|
22
|
+
* ## Why not just reuse the caller's closure
|
|
23
|
+
*
|
|
24
|
+
* Because there often isn't one. A conjunct pulled out of `([p, m]) => p.a === 1 && m.b === 2` is
|
|
25
|
+
* source TEXT; turning it back into a callable needs `new Function`, which a
|
|
26
|
+
* Content-Security-Policy blocks — the same constraint that makes `softDeleteScope` build its tree
|
|
27
|
+
* by hand. The tree is the only representation that survives.
|
|
28
|
+
*/
|
|
29
|
+
export type EvaluationResult = boolean | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* Evaluates `expression` against `row`, or returns `undefined` when it cannot.
|
|
32
|
+
*
|
|
33
|
+
* See the note at the top of this file: `undefined` means KEEP the row.
|
|
34
|
+
*/
|
|
35
|
+
export declare const evaluate: (expression: Expression, row: UnknownRecord) => EvaluationResult;
|
|
36
|
+
/**
|
|
37
|
+
* `evaluate`, as a predicate that keeps whatever it cannot judge.
|
|
38
|
+
*
|
|
39
|
+
* The form every narrowing caller wants, with the fail-open rule applied once here rather than
|
|
40
|
+
* remembered at each call site.
|
|
41
|
+
*/
|
|
42
|
+
export declare const toPredicate: (expression: Expression) => (row: UnknownRecord) => boolean;
|
|
43
|
+
/**
|
|
44
|
+
* `evaluate`, as a predicate that THROWS on anything it cannot judge.
|
|
45
|
+
*
|
|
46
|
+
* The opposite default to `toPredicate`, and the right one when the predicate is the only thing
|
|
47
|
+
* standing between a caller and rows they asked to exclude — a filter that arrived over a wire and
|
|
48
|
+
* is being applied by the receiver. Failing open there does not cost a wasted comparison; it returns
|
|
49
|
+
* data the requester filtered out, and reports nothing.
|
|
50
|
+
*
|
|
51
|
+
* Use `toPredicate` when something authoritative re-checks the result, and this when nothing does.
|
|
52
|
+
*/
|
|
53
|
+
export declare const toStrictPredicate: (expression: Expression) => (row: UnknownRecord) => boolean;
|