@routier/core 0.6.0 → 0.7.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.
Files changed (52) hide show
  1. package/dist/assertions/index.cjs +19 -8
  2. package/dist/assertions/index.cjs.map +1 -1
  3. package/dist/assertions/index.d.ts +5 -1
  4. package/dist/assertions/index.js +21 -9
  5. package/dist/assertions/index.js.map +1 -1
  6. package/dist/collections/MemoryDataCollection.d.ts +10 -0
  7. package/dist/collections/index.cjs +29 -4
  8. package/dist/collections/index.cjs.map +1 -1
  9. package/dist/collections/index.js +29 -4
  10. package/dist/collections/index.js.map +1 -1
  11. package/dist/expressions/callSource.d.ts +41 -0
  12. package/dist/expressions/evaluate.d.ts +3 -0
  13. package/dist/expressions/fold.d.ts +7 -0
  14. package/dist/expressions/index.cjs +1754 -233
  15. package/dist/expressions/index.cjs.map +1 -1
  16. package/dist/expressions/index.d.ts +2 -0
  17. package/dist/expressions/index.js +1765 -234
  18. package/dist/expressions/index.js.map +1 -1
  19. package/dist/expressions/types.d.ts +45 -26
  20. package/dist/expressions/utils.d.ts +19 -1
  21. package/dist/index.cjs +2415 -364
  22. package/dist/index.cjs.map +1 -1
  23. package/dist/index.js +2755 -684
  24. package/dist/index.js.map +1 -1
  25. package/dist/performance/index.cjs +6 -4
  26. package/dist/performance/index.cjs.map +1 -1
  27. package/dist/performance/index.js +6 -4
  28. package/dist/performance/index.js.map +1 -1
  29. package/dist/pipeline/index.cjs +6 -4
  30. package/dist/pipeline/index.cjs.map +1 -1
  31. package/dist/pipeline/index.js +6 -4
  32. package/dist/pipeline/index.js.map +1 -1
  33. package/dist/plugins/index.cjs +2309 -316
  34. package/dist/plugins/index.cjs.map +1 -1
  35. package/dist/plugins/index.js +2313 -311
  36. package/dist/plugins/index.js.map +1 -1
  37. package/dist/plugins/query/QueryOptionsCollection.d.ts +38 -10
  38. package/dist/plugins/query/describeFilter.d.ts +83 -0
  39. package/dist/plugins/query/explain.d.ts +71 -9
  40. package/dist/plugins/query/index.d.ts +1 -0
  41. package/dist/plugins/query/join.d.ts +4 -1
  42. package/dist/plugins/query/types.d.ts +36 -4
  43. package/dist/schema/PropertyInfo.d.ts +0 -1
  44. package/dist/schema/index.cjs +7 -14
  45. package/dist/schema/index.cjs.map +1 -1
  46. package/dist/schema/index.js +7 -14
  47. package/dist/schema/index.js.map +1 -1
  48. package/dist/utilities/index.cjs +242 -49
  49. package/dist/utilities/index.cjs.map +1 -1
  50. package/dist/utilities/index.js +242 -49
  51. package/dist/utilities/index.js.map +1 -1
  52. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"schema/index.cjs","sources":["webpack://@routier/core/./src/codegen/blocks.ts","webpack://@routier/core/./src/errors/SchemaError.ts","webpack://@routier/core/./src/performance/index.ts","webpack://@routier/core/./src/schema/types.ts","webpack://@routier/core/./src/utilities/logger.ts","webpack://@routier/core/./src/utilities/strings.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/schema/property/base/SchemaBase.ts","webpack://@routier/core/./src/schema/property/modifiers/SchemaDistinct.ts","webpack://@routier/core/./src/schema/property/modifiers/SchemaIdentity.ts","webpack://@routier/core/./src/schema/property/modifiers/SchemaSearchable.ts","webpack://@routier/core/./src/schema/property/modifiers/SchemaOptional.ts","webpack://@routier/core/./src/schema/property/modifiers/SchemaNullable.ts","webpack://@routier/core/./src/schema/property/modifiers/SchemaSerialize.ts","webpack://@routier/core/./src/schema/property/modifiers/SchemaReadonly.ts","webpack://@routier/core/./src/schema/property/modifiers/SchemaFrom.ts","webpack://@routier/core/./src/schema/property/modifiers/SchemaDeserialize.ts","webpack://@routier/core/./src/schema/property/modifiers/SchemaDefault.ts","webpack://@routier/core/./src/schema/property/modifiers/SchemaIndex.ts","webpack://@routier/core/./src/schema/property/modifiers/SchemaTag.ts","webpack://@routier/core/./src/schema/property/types/SchemaArray.ts","webpack://@routier/core/./src/schema/property/types/SchemaBoolean.ts","webpack://@routier/core/./src/schema/property/types/SchemaDate.ts","webpack://@routier/core/./src/schema/table/SchemaFunction.ts","webpack://@routier/core/./src/schema/table/SchemaTransform.ts","webpack://@routier/core/./src/schema/property/modifiers/SchemaForeignKey.ts","webpack://@routier/core/./src/schema/property/modifiers/SchemaKey.ts","webpack://@routier/core/./src/schema/property/modifiers/SchemaTracked.ts","webpack://@routier/core/./src/schema/table/SchemaComputed.ts","webpack://@routier/core/./src/schema/PropertyInfo.ts","webpack://@routier/core/./src/codegen/SlotPath.ts","webpack://@routier/core/./src/codegen/utils.ts","webpack://@routier/core/./src/codegen/handlers/types.ts","webpack://@routier/core/./src/codegen/handlers/enrichment/EnrichmentNullableObjectHandler.ts","webpack://@routier/core/./src/codegen/handlers/enrichment/EnrichmentObjectHandler.ts","webpack://@routier/core/./src/codegen/handlers/enrichment/EnrichmentObjectIdentityHandler.ts","webpack://@routier/core/./src/codegen/handlers/enrichment/EnrichmentPrimitiveIdentityHandler.ts","webpack://@routier/core/./src/codegen/handlers/enrichment/EnrichmentPrimitiveHandler.ts","webpack://@routier/core/./src/codegen/handlers/enrichment/EnrichmentFunctionHandler.ts","webpack://@routier/core/./src/codegen/handlers/enrichment/EnrichmentDefaultValueHandler.ts","webpack://@routier/core/./src/codegen/handlers/enrichment/EnrichmentDefaultFunctionHandler.ts","webpack://@routier/core/./src/codegen/handlers/enrichment/EnrichmentComputedValueHandler.ts","webpack://@routier/core/./src/schema/utils/propertyKind.ts","webpack://@routier/core/./src/codegen/handlers/enrichment/EnrichmentArrayHandler.ts","webpack://@routier/core/./src/codegen/handlers/EnrichmentHandlerBuilder.ts","webpack://@routier/core/./src/codegen/handlers/merge/MergeDefaultFunctionHandler.ts","webpack://@routier/core/./src/codegen/handlers/merge/MergeObjectHandler.ts","webpack://@routier/core/./src/codegen/handlers/merge/MergePrimitiveHandler.ts","webpack://@routier/core/./src/codegen/handlers/merge/MergeComputedValueHandler.ts","webpack://@routier/core/./src/codegen/handlers/merge/MergeDefaultValueHandler.ts","webpack://@routier/core/./src/codegen/handlers/merge/MergeFunctionHandler.ts","webpack://@routier/core/./src/codegen/handlers/merge/MergeArrayHandler.ts","webpack://@routier/core/./src/codegen/handlers/MergeHandlerBuilder.ts","webpack://@routier/core/./src/codegen/handlers/prepare/PrepareIdentityHandler.ts","webpack://@routier/core/./src/codegen/handlers/prepare/PrepareKeyHandler.ts","webpack://@routier/core/./src/codegen/handlers/prepare/PrepareValueHandler.ts","webpack://@routier/core/./src/codegen/handlers/prepare/PrepareObjectHandler.ts","webpack://@routier/core/./src/codegen/handlers/prepare/PrepareComputedValueHandler.ts","webpack://@routier/core/./src/codegen/handlers/prepare/PrepareFunctionHandler.ts","webpack://@routier/core/./src/codegen/handlers/PrepareHandlerBuilder.ts","webpack://@routier/core/./src/codegen/handlers/strip/StripObjectHandler.ts","webpack://@routier/core/./src/codegen/handlers/strip/StripValueHandler.ts","webpack://@routier/core/./src/codegen/handlers/strip/StripKeyHandler.ts","webpack://@routier/core/./src/codegen/handlers/strip/StripIdentityHandler.ts","webpack://@routier/core/./src/codegen/handlers/strip/StripFunctionHandler.ts","webpack://@routier/core/./src/codegen/handlers/strip/StripComputedHandler.ts","webpack://@routier/core/./src/codegen/handlers/StripHandlerBuilder.ts","webpack://@routier/core/./src/codegen/handlers/clone/CloneArrayHandler.ts","webpack://@routier/core/./src/codegen/handlers/clone/CloneDateHandler.ts","webpack://@routier/core/./src/codegen/handlers/clone/CloneObjectHandler.ts","webpack://@routier/core/./src/codegen/handlers/clone/CloneValueHandler.ts","webpack://@routier/core/./src/codegen/handlers/CloneHandlerBuilder.ts","webpack://@routier/core/./src/codegen/handlers/compare/CompareArrayHandler.ts","webpack://@routier/core/./src/codegen/handlers/compare/CompareComputedHandler.ts","webpack://@routier/core/./src/codegen/handlers/compare/CompareDateHandler.ts","webpack://@routier/core/./src/codegen/handlers/compare/CompareFunctionHandler.ts","webpack://@routier/core/./src/codegen/handlers/compare/CompareObjectHandler.ts","webpack://@routier/core/./src/codegen/handlers/compare/CompareValueHandler.ts","webpack://@routier/core/./src/codegen/handlers/CompareHandlerBuilder.ts","webpack://@routier/core/./src/codegen/handlers/deserialize/DeserializeObjectHandler.ts","webpack://@routier/core/./src/codegen/handlers/deserialize/DeserializeValueHandler.ts","webpack://@routier/core/./src/codegen/handlers/deserialize/DeserializeDateHandler.ts","webpack://@routier/core/./src/codegen/handlers/deserialize/DeserializeComputedValueHandler.ts","webpack://@routier/core/./src/codegen/handlers/deserialize/DeserializeFunctionHandler.ts","webpack://@routier/core/./src/codegen/handlers/deserialize/DeserializeDeserializerHandler.ts","webpack://@routier/core/./src/codegen/handlers/deserialize/DeserializeArrayHandler.ts","webpack://@routier/core/./src/codegen/handlers/DeserializeHandlerBuilder.ts","webpack://@routier/core/./src/codegen/handlers/hashType/HashTypeValueHandler.ts","webpack://@routier/core/./src/codegen/handlers/HashTypeHandlerBuilder.ts","webpack://@routier/core/./src/codegen/handlers/idSelector/IdSelectorValueHandler.ts","webpack://@routier/core/./src/codegen/handlers/IdSelectorHandlerBuilder.ts","webpack://@routier/core/./src/codegen/handlers/hash/HashKeyHandler.ts","webpack://@routier/core/./src/codegen/handlers/hash/HashValueHandler.ts","webpack://@routier/core/./src/codegen/handlers/hash/HashDateHandler.ts","webpack://@routier/core/./src/codegen/handlers/hash/HashIdentityHandler.ts","webpack://@routier/core/./src/codegen/handlers/hash/HashFunctionHandler.ts","webpack://@routier/core/./src/codegen/handlers/hash/HashComputedValueHandler.ts","webpack://@routier/core/./src/codegen/handlers/hash/HashArrayHandler.ts","webpack://@routier/core/./src/codegen/handlers/hash/HashObjectHandler.ts","webpack://@routier/core/./src/codegen/handlers/hash/HashFileHandler.ts","webpack://@routier/core/./src/codegen/handlers/hash/HashTransformHandler.ts","webpack://@routier/core/./src/codegen/handlers/HashHandlerBuilder.ts","webpack://@routier/core/./src/codegen/handlers/enableChangeTracking/EnableChangeTrackingObjectHandler.ts","webpack://@routier/core/./src/codegen/handlers/enableChangeTracking/EnableChangeTrackingArrayHandler.ts","webpack://@routier/core/./src/codegen/handlers/enableChangeTracking/EnableChangeTrackingPrimitiveValueHandler.ts","webpack://@routier/core/./src/codegen/handlers/EnableChangeTrackingHandlerBuilder.ts","webpack://@routier/core/./src/codegen/handlers/freeze/FreezePrimitiveValueHandler.ts","webpack://@routier/core/./src/codegen/handlers/freeze/FreezeObjectHandler.ts","webpack://@routier/core/./src/codegen/handlers/freeze/FreezeArrayHandler.ts","webpack://@routier/core/./src/codegen/handlers/FreezeHandlerBuilder.ts","webpack://@routier/core/./src/codegen/handlers/serialize/SerializeDateHandler.ts","webpack://@routier/core/./src/codegen/handlers/serialize/SerializeObjectHandler.ts","webpack://@routier/core/./src/codegen/handlers/serialize/SerializeValueHandler.ts","webpack://@routier/core/./src/codegen/handlers/serialize/SerializeSerializerHandler.ts","webpack://@routier/core/./src/codegen/handlers/serialize/SerializeFunctionHandler.ts","webpack://@routier/core/./src/codegen/handlers/serialize/SerializeComputedHandler.ts","webpack://@routier/core/./src/codegen/handlers/serialize/SerializeArrayHandler.ts","webpack://@routier/core/./src/codegen/handlers/SerializeHandlerBuilder.ts","webpack://@routier/core/./src/schema/communication/broadcast.ts","webpack://@routier/core/./src/codegen/handlers/compareIds/CompareIdsKeyHandler.ts","webpack://@routier/core/./src/codegen/handlers/CompareIdsHandlerBuilder.ts","webpack://@routier/core/./src/schema/utils/standardJsonSchema.ts","webpack://@routier/core/./src/codegen/handlers/set/SetComplexHandler.ts","webpack://@routier/core/./src/codegen/handlers/SetHandlerBuilder.ts","webpack://@routier/core/./src/schema/SchemaDefinition.ts","webpack://@routier/core/./src/schema/property/types/SchemaNumber.ts","webpack://@routier/core/./src/schema/property/types/SchemaObject.ts","webpack://@routier/core/./src/schema/property/types/SchemaFile.ts","webpack://@routier/core/./src/schema/property/types/SchemaString.ts","webpack://@routier/core/./src/schema/property/types/SchemaVector.ts","webpack://@routier/core/./src/schema/builder.ts","webpack://@routier/core/./src/schema/table/index.ts","webpack://@routier/core/./src/schema/property/base/index.ts","webpack://@routier/core/./src/schema/property/modifiers/index.ts","webpack://@routier/core/./src/schema/property/types/index.ts","webpack://@routier/core/./src/schema/index.ts"],"sourcesContent":["import { uuid } from \"../utilities\";\nimport { CreateBlockOptions } from \"./types\";\n\ntype Line = string | Block;\n\ntype Param = { name: string, value: any };\ntype GenericParam = { name: string, callName: string };\n\n\nexport abstract class Block {\n readonly name: string;\n protected _lines: Line[] = [];\n protected _indent: string = \"\";\n protected _parent?: Block;\n\n constructor(name?: string, parentIndent: string = \"\", parent?: Block) {\n this.name = name != null ? name : uuid();\n this._indent = parentIndent;\n this._parent = parent;\n }\n\n indexOf(name: string) {\n return this._lines.findIndex(w => typeof w !== \"string\" && w.name === name);\n }\n\n getLines() {\n return this._lines;\n }\n\n getParent() {\n return this._parent;\n }\n\n getIndent() {\n return this._indent;\n }\n\n setLines(lines: Line[]) {\n this._lines = lines;\n }\n\n setParent(block: Block) {\n this._parent = block;\n }\n\n setIndent(indent: string) {\n this._indent = indent;\n }\n\n getOrDefault<T extends Block>(name: string): T | undefined {\n\n if (name.includes('.') === false) {\n return this._lines.find(w => typeof w !== \"string\" && w.name === name) as T | undefined;\n }\n\n const split = name.match(/(\\[[^\\]]+\\]|[^.]+)/g);\n // oxlint-disable-next-line no-this-alias\n let result: Block = this;\n\n for (const item of split) {\n const found = result._lines.find(w => typeof w !== \"string\" && w.name === item) as Block;\n\n if (found == null) {\n\n if (\"getValue\" in result && result.getValue instanceof Block && result.getValue.name === item) {\n result = result.getValue;\n continue;\n }\n\n return undefined;\n }\n\n result = found;\n }\n\n return result as T;\n }\n\n get<T extends Block>(name: string): T {\n const found = this.getOrDefault(name);\n\n if (found == null) {\n throw new Error(`Error finding code block for given path. Path: ${name}`)\n }\n\n return found as T;\n }\n\n has(name: string) {\n return this._lines.some(w => typeof w !== \"string\" && w.name === name);\n }\n\n remove(name: string) {\n this._lines = this._lines.filter(x => typeof x === \"object\" && typeof x.name === \"string\" && x.name !== name);\n }\n\n replace(name: string, line: Block) {\n\n const foundIndex = this._lines.findIndex(x => typeof x !== \"string\" && x.name === name);\n\n if (foundIndex === -1) {\n throw new Error(`Cannot find line by name. Name: ${name}`)\n }\n\n const found = this._lines[foundIndex];\n\n if (typeof found === \"string\") {\n // Replace the line\n this._lines.splice(foundIndex, 1, line);\n return;\n }\n\n line.setLines(found.getLines());\n line.setIndent(found.getIndent());\n line.setParent(found.getParent());\n\n // Replace the line\n this._lines.splice(foundIndex, 1, line);\n\n return;\n }\n\n protected push(line: Line) {\n this._lines.push(line);\n }\n\n protected unshift(line: Line) {\n this._lines.unshift(line);\n }\n\n protected indent(text: string): string {\n return this._indent + text;\n }\n\n\n abstract toString(): string;\n}\n\nexport abstract class ContainerBlock extends Block {\n if(condition: string, options?: CreateBlockOptions): IfBuilder {\n const builder = new IfBuilder(condition, options?.name, this._indent + \" \", this);\n if (options?.unshift === true) {\n this.unshift(builder);\n } else {\n this.push(builder);\n }\n\n return builder;\n }\n\n raw(raw: string, options?: CreateBlockOptions): RawBuilder {\n const builder = new RawBuilder(raw, options?.name, this._indent + \" \", this);\n this.push(builder);\n return builder;\n }\n\n function(name?: string, options?: CreateBlockOptions): FunctionBuilder {\n const builder = new FunctionBuilder(name, options?.name, this._indent + \" \", this);\n this.push(builder);\n return builder;\n }\n\n factory(name?: string, options?: CreateBlockOptions): FunctionFactoryBuilder {\n const builder = new FunctionFactoryBuilder(name, options?.name, this._indent + \" \", this);\n this.push(builder);\n return builder;\n }\n\n variable(declaration: string, options?: CreateBlockOptions): VariableBuilder {\n const builder = new VariableBuilder(declaration, options?.name, this._indent + \" \", this);\n this.push(builder);\n return builder;\n }\n\n assign(variableName: string, options?: CreateBlockOptions): AssignmentBuilder {\n const builder = new AssignmentBuilder(variableName, options?.name, this._indent + \" \", this);\n this.push(builder);\n return builder;\n }\n\n object(options?: CreateBlockOptions): ObjectBuilder {\n const builder = new ObjectBuilder(options?.name, this._indent + \" \", this);\n this.push(builder);\n return builder;\n }\n\n slot(name: string) {\n const builder = new SlotBlock(name, this._indent + \" \", this);\n this.push(builder);\n return builder;\n }\n\n array(accessor: string, options?: CreateBlockOptions) {\n const builder = new ArrayBuilder(accessor, options?.name, this._indent + \" \", this);\n this.push(builder);\n return builder;\n }\n}\n\nexport type StringType = \"template\" | \"default\";\n\nexport class StringBuilder extends Block {\n\n private _type: StringType;\n\n constructor(type: StringType, name?: string, parentIndent: string = \"\", parent?: Block) {\n super(name, parentIndent, parent);\n this._type = type;\n }\n\n append(value: string) {\n this._lines.push(value);\n return this;\n }\n\n toString() {\n if (this._type === \"template\") {\n return \"`\" + this._lines.join(\"\") + \"`\";\n }\n\n return `\"${this._lines.join(\"\")}\"`;\n }\n}\n\nexport class SlotBlock extends ContainerBlock {\n\n constructor(name: string, parentIndent: string = \"\", parent?: Block) {\n super(name, parentIndent, parent);\n }\n\n insert(line: string | Block) {\n this.push(line);\n }\n\n toString(): string {\n return this._lines.map(line =>\n typeof line === 'string'\n ? this.indent(line)\n : line.toString()\n ).join('\\n\\n');\n }\n}\n\nexport class AssignmentBuilder extends ContainerBlock {\n protected _variableName: string;\n protected _value?: string | Block;\n protected _functionName?: string;\n\n get getValue() {\n return this._value;\n }\n\n constructor(variableName: string, name?: string, parentIndent: string = \"\", parent?: Block) {\n super(name, parentIndent, parent);\n this._variableName = variableName;\n }\n\n value(value: string): this {\n this._value = value;\n return this;\n }\n\n and(and: string, options?: CreateBlockOptions): this {\n this._value = new AndBuilder(and, options?.name, this._indent, this);\n return this;\n }\n\n object(options?: CreateBlockOptions): ObjectBuilder {\n const objectBuilder = new ObjectBuilder(options?.name, this._indent, this);\n\n this._value = objectBuilder;\n\n return objectBuilder;\n }\n\n call(functionName: string, options?: CreateBlockOptions): ObjectBuilder {\n this._functionName = functionName;\n const objectBuilder = new ObjectBuilder(options?.name, this._indent, this);\n\n this._value = objectBuilder;\n\n return objectBuilder;\n }\n\n string(type: StringType, options?: CreateBlockOptions) {\n const stringBuilder = new StringBuilder(type, options?.name, this._indent, this);\n\n this._value = stringBuilder;\n\n return stringBuilder;\n }\n\n toString(): string {\n\n if (this._value == null) {\n throw new Error(\"Value cannot be null for AssignmentBuilder Builder\")\n }\n\n if (this._functionName != null) {\n return this.indent(`${this._variableName} = ${this._functionName}(${this._value.toString()});`);\n }\n\n return this.indent(`${this._variableName} = ${this._value.toString()};`);\n }\n}\n\nexport class AndBuilder extends ContainerBlock {\n\n constructor(and: string, name?: string, parentIndent: string = \"\", parent?: Block) {\n super(name, parentIndent, parent);\n this._lines.push(and);\n }\n\n and(and: string) {\n this._lines.push(and);\n }\n\n toString() {\n return this._lines.join(\" && \")\n }\n}\n\nexport class VariableBuilder extends Block {\n protected _declaration: string;\n protected _value?: string | Block;\n\n get getValue() {\n return this._value;\n }\n\n constructor(declaration: string, name?: string, parentIndent: string = \"\", parent?: Block) {\n super(name, parentIndent, parent);\n this._declaration = declaration;\n }\n\n value(value: string): this {\n this._value = value;\n return this;\n }\n\n object(options?: CreateBlockOptions): ObjectBuilder {\n const objectBuilder = new ObjectBuilder(options?.name, this._indent, this);\n\n this._value = objectBuilder;\n\n return objectBuilder;\n }\n\n array(accessor: string, options?: CreateBlockOptions): ArrayBuilder {\n const arrayBuilder = new ArrayBuilder(accessor, options?.name, this._indent, this);\n\n this._value = arrayBuilder;\n\n return arrayBuilder;\n }\n\n toString(): string {\n\n if (this._value == null) {\n throw new Error(\"Value cannot be null for Variable Builder\")\n }\n\n return this.indent(`const ${this._declaration} = ${this._value.toString()};`);\n }\n}\n\nexport class RawBuilder extends ContainerBlock {\n private _raw: string;\n\n constructor(raw: string, name?: string, parentIndent: string = \"\", parent?: Block) {\n super(name, parentIndent, parent);\n this._raw = raw;\n }\n\n toString(): string {\n return `${this._raw}\\n`;\n }\n}\n\nexport class ObjectBuilder extends Block {\n\n property(line: string) {\n // Add comma to previous line if it exists and isn't a brace\n if (this._lines.length > 0) {\n const lastLine = this._lines[this._lines.length - 1];\n if (typeof lastLine === 'string' && !lastLine.endsWith(\"{\")) {\n this._lines[this._lines.length - 1] = lastLine + \",\";\n }\n }\n this.push(line);\n return this;\n }\n\n nested(propertyName: string, name?: string) {\n const builder = new ObjectBuilder(name, this._indent + \" \", this);\n // Add comma to previous line if it exists and isn't a brace\n if (this._lines.length > 0) {\n const lastLine = this._lines[this._lines.length - 1];\n if (typeof lastLine === 'string' && !lastLine.endsWith(\"{\")) {\n this._lines[this._lines.length - 1] = lastLine + \",\";\n }\n }\n // Add the property name and opening brace\n this.push(`${propertyName}: {`);\n // Add the nested builder\n this.push(builder);\n // Add the closing brace\n this.push(\"}\");\n return builder;\n }\n\n toString(): string {\n // Check if this is a nested object's content\n const isNestedContent = this._parent instanceof ObjectBuilder;\n\n if (isNestedContent) {\n // For nested object contents, just return the lines\n return this._lines.map(line =>\n typeof line === 'string'\n ? this.indent(\" \" + line)\n : line.toString()\n ).join('\\n');\n }\n\n // For root objects, include the braces\n const lines = [\n \"{\",\n ...this._lines.map(line =>\n typeof line === 'string'\n ? this.indent(\" \" + line)\n : line.toString()\n ),\n this.indent(\"}\")\n ];\n\n return lines.join('\\n');\n }\n}\n\nexport class FunctionFactoryBuilder extends ContainerBlock {\n private _functionName?: string;\n private _params: Param[] = [];\n private _return: boolean = false;\n\n constructor(functionName?: string, sectionName?: string, parentIndent: string = \"\", parent?: Block) {\n super(sectionName, parentIndent, parent);\n this._functionName = functionName;\n }\n\n getParameters() {\n return [...this._params];\n }\n\n createParameter(value: any): Param {\n const name = `injection${this._params.length}`;\n return {\n name,\n value\n }\n }\n\n parameters(...params: Param[]): this {\n this._params.push(...params);\n return this;\n }\n\n return() {\n this._return = true;\n return this;\n }\n\n appendBody(line: string): this {\n this.push(line);\n return this;\n }\n\n invoke() {\n const body = this.toString();\n const parameterNames = this._getParameterNames();\n const parameterValues = this._getParameterValues();\n\n return Function(...parameterNames, body)(...parameterValues)\n }\n\n private _getParameterNames() {\n return this._params.map(w => w.name).join(\", \")\n }\n\n private _getParameterValues() {\n return this._params.map(w => w.value);\n }\n\n toString(): string {\n const r = this._return === true ? \"return \" : \"\";\n const signature = this._functionName\n ? `${r}function ${this._functionName}(${this._getParameterNames()})`\n : `${r}function(${this._getParameterNames()})`;\n\n const lines = [\n this.indent(signature + \" {\"),\n ...this._lines.map(line =>\n typeof line === 'string'\n ? this.indent(\" \" + line)\n : line.toString()\n ),\n this.indent(\"}\")\n ];\n\n return lines.join('\\n');\n }\n}\n\nexport class FunctionBuilder extends ContainerBlock {\n private _functionName?: string;\n private _params: (string | GenericParam)[] = [];\n private _return: boolean = false;\n\n constructor(functionName?: string, sectionName?: string, parentIndent: string = \"\", parent?: Block) {\n super(sectionName, parentIndent, parent);\n this._functionName = functionName;\n }\n\n parameters(...params: (string | GenericParam)[]): this {\n this._params.push(...params);\n return this;\n }\n\n return() {\n this._return = true;\n return this;\n }\n\n appendBody(line: string): this {\n this.push(line);\n return this;\n }\n\n private _getParameterKeys() {\n return this._params.map(w => typeof w === \"object\" ? w.name : w).join(\", \")\n }\n\n toCallable() {\n return `${this._functionName}(${this._params.map(w => typeof w === \"object\" ? w.callName : w).join(\", \")})`\n }\n\n toString(): string {\n const r = this._return === true ? \"return \" : \"\";\n const signature = this._functionName\n ? `${r}function ${this._functionName}(${this._getParameterKeys()})`\n : `${r}function(${this._getParameterKeys()})`;\n\n const lines = [\n this.indent(signature + \" {\"),\n ...this._lines.map(line =>\n typeof line === 'string'\n ? this.indent(\" \" + line)\n : line.toString()\n ),\n this.indent(\"}\")\n ];\n\n return lines.join('\\n');\n }\n}\n\nexport class ArrayBuilder extends Block {\n constructor(accessor: string, name?: string, parentIndent: string = \"\", parent?: Block) {\n super(name, parentIndent, parent);\n this._lines.push(accessor);\n }\n\n append(accessor: string) {\n this._lines.push(accessor);\n return this;\n }\n\n toString() {\n return `[${this._lines.join(\",\")}]`\n }\n}\n\nexport class IfBuilder extends ContainerBlock {\n private _condition: string;\n\n constructor(condition: string, name?: string, parentIndent: string = \"\", parent?: Block) {\n super(name, parentIndent, parent);\n this._condition = condition;\n }\n\n appendBody(line: string): this {\n this.push(line);\n return this;\n }\n\n unshiftBody(line: string): this {\n this.unshift(line);\n return this;\n }\n\n private stringifyLine(line: Line) {\n if (typeof line === 'string') {\n return this.indent(\" \" + line);\n }\n\n if (Array.isArray(line)) {\n return line.join(\"\\r\\n\")\n }\n\n return line.toString();\n }\n\n toString(): string {\n // need to join with \\r\\n because we are not an object\n const lines = [\n this.indent(`if (${this._condition}) {`),\n this._lines.map(x => this.stringifyLine(x)).join(\"\\r\\n\"),\n this.indent(\"}\")\n ]\n\n return lines.join(\"\\n\\n\");\n }\n}\n\nexport class CodeBuilder extends ContainerBlock {\n\n toString(): string {\n return this._lines.map(line =>\n typeof line === 'string'\n ? this.indent(line)\n : line.toString()\n ).join('\\n\\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}","import { logger } from \"../utilities\";\n\nconst measurements: Record<string, number> = {}\n\nexport const now = (): number => {\n if (typeof performance !== 'undefined' && performance.now) {\n // Browser or modern Node.js\n return performance.now();\n }\n\n // Fallback for older environments\n return Date.now();\n}\n\nexport const measure = {\n start: (name: string): void => {\n measurements[name] = now();\n },\n end: (name: string): void => {\n const start = measurements[name];\n\n delete measurements[name];\n\n const delta = now() - start;\n\n logger.log(`[ROUTIER] - Performance: ${name} took ${delta}`);\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","/**\n * Levelled logging, resolved once.\n *\n * Three things about the previous implementation drove this shape:\n *\n * - **There was no way to turn logging off.** `globalThis.__ROUTIER_DEBUG__` was only ever\n * compared against `true`, so setting it to `false` did nothing — while\n * `docs/how-to/debug-logging.md` documented exactly that as the way to force logging off.\n * A documented switch that silently does nothing is worse than no switch.\n * - **`NODE_ENV === 'test'` enabled it.** Every Jest run therefore logged, because Jest always\n * sets `NODE_ENV=test`. Measured on the S7 stress scenario, which drives ~2,000 saves through\n * a plugin that logs three lines per query: 12.4s with logging, ~6s without. Test runners also\n * capture console output by snapshotting a stack trace per call, so the cost is far above what\n * writing to a terminal would suggest — and the output buries whatever the failure was.\n * - **It was all-or-nothing, and re-resolved per call.** An error could not be kept while debug\n * was dropped, and every one of the ~97 call sites re-read `globalThis` and `process.env`.\n *\n * Levels are compared numerically against a value cached at module load. Measured against a\n * no-op console at 200k calls: an enabled call costs ~70ns, a call rejected by the gate ~3ns.\n * Building the arguments the call site passes in accounts for ~0.2ns of that 3ns, which is why\n * this keeps the ordinary `logger.debug(msg, payload)` signature instead of taking a thunk —\n * a lazy API would recover 0.3% of an enabled call's cost and would have to change every call\n * site to do it.\n */\n\n/** Ordered from most severe to most verbose. `silent` discards everything. */\nexport const LOG_LEVELS = ['silent', 'error', 'warn', 'info', 'debug'] as const;\n\nexport type LogLevel = (typeof LOG_LEVELS)[number];\n\n/** Numeric rank, so a gate is one integer comparison. */\nconst RANK: Record<LogLevel, number> = {\n silent: 0,\n error: 1,\n warn: 2,\n info: 3,\n debug: 4,\n};\n\nconst isLogLevel = (value: unknown): value is LogLevel =>\n typeof value === 'string' && (LOG_LEVELS as readonly string[]).includes(value);\n\n/**\n * Resolves the configured level, in precedence order.\n *\n * Ordered most specific first: an explicit level beats a boolean flag, a boolean flag beats an\n * environment variable, and an environment variable beats an inference from `NODE_ENV`. Anything\n * unrecognised is ignored rather than treated as an error — a typo'd level should not take down\n * an application, and `silent` is the safe direction to fall back to.\n */\nconst resolveLevel = (): LogLevel => {\n if (typeof globalThis !== 'undefined') {\n const g = globalThis as { __ROUTIER_LOG_LEVEL__?: unknown; __ROUTIER_DEBUG__?: unknown };\n\n if (isLogLevel(g.__ROUTIER_LOG_LEVEL__)) {\n return g.__ROUTIER_LOG_LEVEL__;\n }\n\n // Both directions honoured. `=== false` used to fall through to the NODE_ENV checks\n // below and re-enable the logging it was asked to suppress.\n if (g.__ROUTIER_DEBUG__ === true) return 'debug';\n if (g.__ROUTIER_DEBUG__ === false) return 'silent';\n }\n\n // There is deliberately no `import.meta.env` branch, although the documentation used to\n // promise one. It could never work: this package is bundled with rspack, which replaces\n // `import.meta` with `undefined`, so the check would read the *library's* build-time\n // environment rather than the application's — and referencing `import.meta` at all is a parse\n // error under a CommonJS build target, which is how the test suite loads this file. Vite and\n // similar apps set `__ROUTIER_LOG_LEVEL__` or `__ROUTIER_DEBUG__` from their own\n // `import.meta.env`, which is what the docs now describe.\n if (typeof process !== 'undefined' && process.env != null) {\n if (isLogLevel(process.env.ROUTIER_LOG_LEVEL)) {\n return process.env.ROUTIER_LOG_LEVEL as LogLevel;\n }\n\n const debug = process.env.DEBUG;\n if (debug === 'routier' || debug === '*') return 'debug';\n\n const env = process.env.NODE_ENV?.toLowerCase();\n\n // `test` is deliberately absent. It used to be here, which meant no test suite anywhere\n // could run Routier quietly. Opt in with DEBUG=routier or ROUTIER_LOG_LEVEL when a test\n // needs the output.\n if (env === 'dev' || env === 'development') return 'debug';\n }\n\n return 'silent';\n};\n\nlet level: LogLevel = resolveLevel();\nlet rank = RANK[level];\n\n/**\n * Overrides the level for the rest of the process.\n *\n * The configuration above is read once, at import, which is what makes the gate cheap — but it\n * also means an application that decides its verbosity after startup, or a test that wants to\n * assert on output, has no way in. This is that way in.\n */\nexport const setLogLevel = (next: LogLevel): void => {\n if (isLogLevel(next) === false) {\n throw new Error(`Unknown log level \"${next}\". Expected one of: ${LOG_LEVELS.join(', ')}`);\n }\n\n level = next;\n rank = RANK[next];\n};\n\nexport const getLogLevel = (): LogLevel => level;\n\n/** Re-reads the environment. For tests that change it after this module was imported. */\nexport const resetLogLevel = (): void => {\n level = resolveLevel();\n rank = RANK[level];\n};\n\n/**\n * Whether a message at this level would be emitted.\n *\n * For the rare call site whose *arguments* are expensive to build — a serialization, a deep\n * clone, a join over a large collection. An ordinary payload object is not worth guarding; see\n * the measurement in the header.\n */\nexport const isLogLevelEnabled = (at: LogLevel): boolean => rank >= RANK[at];\n\ntype ConsoleMethod = 'log' | 'info' | 'warn' | 'error' | 'debug' | 'table';\n\nconst emit = (at: LogLevel, method: ConsoleMethod, args: unknown[]) => {\n if (rank < RANK[at]) {\n return;\n }\n\n // Resolved at call time rather than captured once: test harnesses and browser devtools both\n // replace console methods after modules have loaded, and a captured reference would keep\n // writing past the replacement.\n (console[method] as (...a: unknown[]) => void)(...args);\n};\n\nexport const logger = {\n /** General-purpose output. Carried at `info`, since `log` names a console method, not a level. */\n log: (...args: unknown[]): void => emit('info', 'log', args),\n info: (...args: unknown[]): void => emit('info', 'info', args),\n warn: (...args: unknown[]): void => emit('warn', 'warn', args),\n error: (...args: unknown[]): void => emit('error', 'error', args),\n debug: (...args: unknown[]): void => emit('debug', 'debug', args),\n /** Diagnostic tabular output; verbose by nature, so it sits at `debug`. */\n table: (...args: unknown[]): void => emit('debug', 'table', args),\n};\n","export const hash = (value: string, seed: number = 0) => {\n // From Stack Overflow\n // https://stackoverflow.com/a/52171480/3329760\n let h1 = 0xdeadbeef ^ seed, h2 = 0x41c6ce57 ^ seed;\n\n for (let i = 0, ch: number; i < value.length; i++) {\n ch = value.charCodeAt(i);\n h1 = Math.imul(h1 ^ ch, 2654435761);\n h2 = Math.imul(h2 ^ ch, 1597334677);\n }\n\n h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507);\n h1 ^= Math.imul(h2 ^ (h2 >>> 13), 3266489909);\n h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507);\n h2 ^= Math.imul(h1 ^ (h1 >>> 13), 3266489909);\n\n return 4294967296 * (2097151 & h2) + (h1 >>> 0);\n}\n\n/**\n * Fast string hash optimized for comparisons.\n * Uses djb2 algorithm - very fast and good distribution for short to medium strings.\n * Same input always produces same output (deterministic).\n * \n * @param value - The string to hash\n * @param seed - Optional seed value (default: 5381)\n * @returns A positive 32-bit integer hash value\n * \n * @example\n * ```ts\n * fastHash(\"test\") === fastHash(\"test\") // true\n * fastHash(\"test\") !== fastHash(\"test2\") // true\n * ```\n */\nexport const fastHash = (value: string, seed: number = 5381): number => {\n let hash = seed;\n for (let i = 0; i < value.length; i++) {\n hash = ((hash << 5) + hash) + value.charCodeAt(i);\n }\n return hash >>> 0; // Convert to unsigned 32-bit integer\n}\n\n/**\n * Converts any value to a readable string representation.\n * Handles primitives, objects, arrays, classes, dates, errors, and functions.\n * Supports depth limiting to prevent infinite recursion on circular references.\n * \n * @param obj - The value to stringify\n * @param maxDepth - Maximum depth for nested objects (default: 3)\n * @param currentDepth - Current recursion depth (default: 0)\n * @returns String representation of the value\n * \n * @example\n * ```ts\n * stringifyObject({ name: \"test\", count: 5 }) // '{ name: \"test\", count: 5 }'\n * stringifyObject([1, 2, 3]) // '[1, 2, 3]'\n * stringifyObject(new Date()) // 'Date(2024-01-01T00:00:00.000Z)'\n * ```\n */\nexport function stringifyObject(obj: unknown, maxDepth: number = 3, currentDepth: number = 0): string {\n if (obj === null) return 'null';\n if (obj === undefined) return 'undefined';\n\n const type = typeof obj;\n\n switch (type) {\n case 'string':\n return `\"${obj}\"`;\n case 'number':\n case 'boolean':\n return String(obj);\n case 'function':\n return `[Function: ${getFunctionName(obj as Function)}]`;\n case 'object':\n if (currentDepth >= maxDepth) {\n return '[Max Depth Reached]';\n }\n return stringifyObjectValue(obj, maxDepth, currentDepth);\n default:\n return `[${type}]`;\n }\n}\n\nfunction getFunctionName(fn: Function): string {\n const name = fn.name;\n return name || 'anonymous';\n}\n\nfunction getObjectProperties(obj: any): Record<string, any> {\n const properties: Record<string, any> = {};\n\n for (const key in obj) {\n if (obj.hasOwnProperty(key)) {\n properties[key] = obj[key];\n }\n }\n\n return properties;\n}\n\nfunction stringifyObjectValue(obj: any, maxDepth: number, currentDepth: number): string {\n if (obj === null) return 'null';\n\n if (obj instanceof Date) {\n return `Date(${obj.toISOString()})`;\n }\n\n if (obj instanceof Error) {\n return `Error(${obj.message})`;\n }\n\n if (obj instanceof RegExp) {\n return obj.toString();\n }\n\n if (Array.isArray(obj)) {\n return stringifyArray(obj, maxDepth, currentDepth);\n }\n\n if (obj.constructor && obj.constructor.name !== 'Object') {\n return stringifyClassInstance(obj, maxDepth, currentDepth);\n }\n\n return stringifyPlainObject(obj, maxDepth, currentDepth);\n}\n\nfunction stringifyArray(arr: any[], maxDepth: number, currentDepth: number): string {\n if (arr.length === 0) return '[]';\n\n const items = arr.slice(0, 5).map(item =>\n stringifyObject(item, maxDepth, currentDepth + 1)\n );\n\n const suffix = arr.length > 5 ? `... (+${arr.length - 5} more)` : '';\n return `[${items.join(', ')}${suffix}]`;\n}\n\nfunction stringifyClassInstance(obj: any, maxDepth: number, currentDepth: number): string {\n const className = obj.constructor.name;\n const properties = getObjectProperties(obj);\n\n if (Object.keys(properties).length === 0) {\n return `${className} {}`;\n }\n\n const props = Object.entries(properties)\n .slice(0, 5)\n .map(([key, value]) => {\n const isPrimitive = value === null || value === undefined ||\n (typeof value !== 'object' && typeof value !== 'function');\n const depth = isPrimitive ? currentDepth : currentDepth + 1;\n return `${key}: ${stringifyObject(value, maxDepth, depth)}`;\n });\n\n const suffix = Object.keys(properties).length > 5 ?\n `... (+${Object.keys(properties).length - 5} more)` : '';\n\n return `${className} { ${props.join(', ')}${suffix} }`;\n}\n\nfunction stringifyPlainObject(obj: any, maxDepth: number, currentDepth: number): string {\n const properties = getObjectProperties(obj);\n\n if (Object.keys(properties).length === 0) {\n return '{}';\n }\n\n const props = Object.entries(properties)\n .slice(0, 5)\n .map(([key, value]) => {\n const isPrimitive = value === null || value === undefined ||\n (typeof value !== 'object' && typeof value !== 'function');\n const depth = isPrimitive ? currentDepth : currentDepth + 1;\n return `${key}: ${stringifyObject(value, maxDepth, depth)}`;\n });\n\n const suffix = Object.keys(properties).length > 5 ?\n `... (+${Object.keys(properties).length - 5} more)` : '';\n\n return `{ ${props.join(', ')}${suffix} }`;\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))","// 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};","import { DefaultValue, ForeignKey, FunctionBody, PropertyDeserializer, PropertySerializer, SchemaModifiers, SchemaTypes, PropertyTransform } from \"../../types\";\n\nexport abstract class SchemaBase<T extends any, TModifiers extends SchemaModifiers> {\n\n abstract instance: T;\n modifiers: TModifiers;\n\n isNullable: boolean = false;\n isUnmapped: boolean = false;\n isOptional: boolean = false;\n isKey: boolean = false;\n isIdentity: boolean = false;\n isReadonly: boolean = false;\n isDistinct: boolean = false;\n /**\n * Set by `.modify(x => x.transform(...))`. A live reference, never stringified.\n * `null` when the property is stored as it is.\n */\n transform: PropertyTransform<unknown> | null = null;\n indexes: string[] = [];\n fromPropertyName: string | null = null;\n /**\n * How many numbers a vector holds. `null` for every other type.\n *\n * Declared here rather than on `SchemaVector` because a modifier WRAPS rather than\n * extends: `s.vector(1536).optional()` is a `SchemaOptional`, and anything reachable only\n * through the original class is lost the moment a modifier is added. `type` survives for\n * exactly this reason — the copy constructor below carries it — and a dimension count has\n * to travel with it, or an optional vector reaches a backend as a vector of unknown width\n * and cannot be given a column.\n *\n * `innerSchema` is the cautionary example: it lives on `SchemaArray` alone, so a modified\n * array arrives with no element type and clones through the slow path.\n */\n dimensions: number | null = null;\n /**\n * The longest string the property is declared to hold. `null` for every other type, and\n * for a string that declares nothing.\n *\n * Declared here rather than on `SchemaString` for the same reason as `dimensions` above:\n * `s.string({ maxLength: 4000 }).optional()` is a `SchemaOptional`, so anything reachable\n * only through `SchemaString` is lost the moment a modifier is added.\n *\n * A declaration, never a validation. Core does not check a value against it and does not\n * truncate. The backend that can use the number does: MySQL gives the column\n * `VARCHAR(maxLength)` instead of the blanket `VARCHAR(255)`. Every other backend ignores\n * it, because a string column that is already unbounded cannot be made more correct by\n * knowing a bound.\n */\n maxLength: number | null = null;\n /**\n * Whether this string may be tokenised into a full-text search index.\n *\n * Set by `.searchable()`, and only ever true on a string. Eligibility, not membership: a\n * collection that never declares `.searchIndex()` indexes nothing regardless.\n *\n * Copied by the constructor below, so `s.string().searchable().optional()` stays searchable.\n * Every flag on this class is copied for the same reason: a modifier WRAPS rather than\n * extends, so anything the constructor forgets is silently dropped the moment a property\n * gains one more modifier.\n */\n isSearchable: boolean = false;\n\n foreignKeyDefinition: ForeignKey<unknown> | null = null;\n tags: string[] = [];\n injected: any = null;\n defaultValue: DefaultValue<T> | null = null;\n valueSerializer: PropertySerializer<T> | null = null;\n valueDeserializer: PropertyDeserializer<T> | null = null;\n type: SchemaTypes;\n functionBody: FunctionBody<any, T> | null;\n private _schemaBase = true;\n readonly literals: T[] = [];\n\n constructor(entity?: SchemaBase<T, TModifiers>, literals?: T[]) {\n\n if (entity != null) {\n this.valueSerializer = entity.valueSerializer;\n this.valueDeserializer = entity.valueDeserializer;\n this.functionBody = entity.functionBody;\n this.isNullable = entity.isNullable;\n this.isOptional = entity.isOptional;\n this.isKey = entity.isKey;\n this.isIdentity = entity.isIdentity;\n this.isReadonly = entity.isReadonly;\n this.defaultValue = entity.defaultValue;\n this.type = entity.type;\n this.injected = entity.injected;\n this.indexes = entity.indexes;\n this.fromPropertyName = entity.fromPropertyName;\n this.tags = entity.tags;\n this.transform = entity.transform;\n this.dimensions = entity.dimensions;\n this.maxLength = entity.maxLength;\n this.isSearchable = entity.isSearchable;\n this.isDistinct = entity.isDistinct;\n }\n\n if (literals) {\n this.literals = literals;\n }\n }\n}","import { SchemaModifiers } from \"../../types\";\nimport { SchemaBase } from \"../base/SchemaBase\";\n\nexport class SchemaDistinct<T extends any, TModifiers extends SchemaModifiers> extends SchemaBase<T, TModifiers> {\n\n instance: T;\n private _schemaDistinct = true;\n\n constructor(current: SchemaBase<T, TModifiers>) {\n super(current);\n this.instance = current.instance;\n this.isDistinct = true;\n }\n}","import { SchemaModifiers } from \"../../types\";\nimport { SchemaBase } from \"../base/SchemaBase\";\n\nexport class SchemaIdentity<T, TModifiers extends SchemaModifiers> extends SchemaBase<T, TModifiers> {\n instance: T;\n private _schemaIdentity = true;\n\n constructor(current: SchemaBase<T, TModifiers>) {\n super(current);\n this.instance = current.instance;\n this.isIdentity = true;\n }\n}","import { SchemaModifiers } from \"../../types\";\nimport { SchemaBase } from \"../base/SchemaBase\";\nimport { SchemaNullable } from \"./SchemaNullable\";\nimport { SchemaOptional } from \"./SchemaOptional\";\n\n/**\n * Marks a string property as eligible for a full-text search index.\n *\n * Eligible, not indexed. The schema says what COULD be indexed; the collection builder's\n * `.searchIndex()` says that it IS. A property marked here on a collection that never declares\n * an index costs nothing at all — no rows, no write amplification, no storage.\n *\n * Like `s.vector()`, this exists to be RECOGNISED rather than to behave. It changes nothing\n * about how the property is stored, cloned, compared, serialized or queried. The datastore\n * reads the flag off the compiled schema to decide which values to tokenise; every plugin is\n * unaware the property is any different from another string.\n *\n * Declared on `SchemaString` only, so `s.number().searchable()` is a compile error rather than\n * a runtime surprise. The one case the type system cannot catch — a searchable string nested\n * inside an `s.object()` — is rejected when the schema compiles: v1 indexes root-level string\n * properties only.\n */\nexport class SchemaSearchable<T extends any, TModifiers extends SchemaModifiers> extends SchemaBase<T, TModifiers> {\n\n instance: T;\n private _schemaSearchable = true;\n\n constructor(current: SchemaBase<T, TModifiers>) {\n super(current);\n this.instance = current.instance;\n this.isSearchable = true;\n }\n\n /**\n * Declared here so `.searchable()` composes in BOTH senses — `.searchable().optional()` and\n * `.optional().searchable()` mean the same thing and both keep the flag. `SchemaDistinct`\n * exposes neither, which is why `.distinct().optional()` is unwritable and its copy-loss\n * (see `SchemaBase.isSearchable`) has never been noticed.\n */\n optional() {\n return new SchemaOptional<T, TModifiers | \"optional\">(this);\n }\n\n nullable() {\n return new SchemaNullable<T, TModifiers | \"nullable\">(this);\n }\n}\n","import { PropertyDeserializer, SchemaModifiers } from \"../../types\";\nimport { SchemaBase } from \"../base/SchemaBase\";\nimport { SchemaDeserialize } from \"./SchemaDeserialize\";\nimport { SchemaNullable } from \"./SchemaNullable\";\nimport { SchemaSearchable } from \"./SchemaSearchable\";\n\nexport class SchemaOptional<T extends any, TModifiers extends SchemaModifiers> extends SchemaBase<T, TModifiers> {\n\n instance: T;\n private _schemaOptional = true;\n\n constructor(current: SchemaBase<T, TModifiers>) {\n super(current);\n this.instance = current.instance;\n this.isOptional = true;\n }\n\n nullable() {\n return new SchemaNullable<T, TModifiers | \"nullable\">(this);\n }\n\n /**\n * Only callable when the property underneath is a string.\n *\n * A wrapper does not know what it wraps at runtime, but the type does: `T` is the value\n * type, so `s.number().optional()` is a `SchemaOptional<number>` and fails this `this`\n * constraint. That is the gate — there is no runtime check, because a builder that offers\n * a method it will then reject has already failed at its job.\n *\n * Constrained on `instance` alone rather than the whole class. `SchemaBase` holds `T` in\n * contravariant positions too (`valueSerializer`, `defaultValue`), so requiring the full\n * `SchemaOptional<string, ...>` would reject a literal union like\n * `s.string(\"draft\", \"published\")`, which is a perfectly good searchable string.\n *\n * An absent value contributes no tokens.\n */\n searchable(this: { instance: string }) {\n return new SchemaSearchable<T, TModifiers | \"searchable\">(this as unknown as SchemaBase<T, TModifiers>);\n }\n\n deserialize(deserializer: PropertyDeserializer<T | undefined>) {\n return new SchemaDeserialize<T | undefined, TModifiers | \"deserialize\">(deserializer, this);\n }\n\n\n}","import { DefaultValue, PropertyDeserializer, SchemaModifiers } from \"../../types\";\nimport { SchemaBase } from \"../base/SchemaBase\";\nimport { SchemaDefault } from \"./SchemaDefault\";\nimport { SchemaDeserialize } from \"./SchemaDeserialize\";\nimport { SchemaOptional } from \"./SchemaOptional\";\nimport { SchemaSearchable } from \"./SchemaSearchable\";\n\nexport class SchemaNullable<T extends any, TModifiers extends SchemaModifiers> extends SchemaBase<T, TModifiers> {\n instance: T;\n private _schemaNullable = true;\n\n constructor(current: SchemaBase<T, TModifiers>) {\n super(current);\n this.instance = current.instance;\n this.isNullable = true;\n }\n\n optional() {\n return new SchemaOptional<T, TModifiers | \"optional\">(this);\n }\n\n /**\n * Only callable when the property underneath is a string — see the same method on\n * `SchemaOptional` for why the constraint is on `instance` rather than the whole class.\n *\n * A null value contributes no tokens.\n */\n searchable(this: { instance: string }) {\n return new SchemaSearchable<T, TModifiers | \"searchable\">(this as unknown as SchemaBase<T, TModifiers>);\n }\n\n default<I = never>(value: DefaultValue<T | null, I>, injected?: I) {\n return new SchemaDefault<T | null, I, TModifiers | \"default\">(value, injected, this);\n }\n\n deserialize(deserializer: PropertyDeserializer<T | null>) {\n return new SchemaDeserialize<T | null, TModifiers | \"deserialize\">(deserializer, this);\n }\n\n\n}","import { PropertyDeserializer, PropertySerializer, SchemaModifiers } from \"../../types\";\nimport { SchemaBase } from \"../base/SchemaBase\";\nimport { SchemaDeserialize } from \"./SchemaDeserialize\";\n\nexport class SchemaSerialize<T extends any, TModifiers extends SchemaModifiers> extends SchemaBase<T, TModifiers> {\n instance: T;\n private _schemaSerialize = true;\n\n constructor(serializer: PropertySerializer<T>, current: SchemaBase<T, TModifiers>) {\n super(current);\n this.instance = current.instance;\n this.valueSerializer = serializer;\n }\n\n deserialize(deserializer: PropertyDeserializer<T>) {\n return new SchemaDeserialize<T, TModifiers | \"deserialize\">(deserializer, this);\n }\n}","import { DefaultValue, PropertyDeserializer, PropertySerializer, SchemaModifiers } from \"../../types\";\nimport { SchemaBase } from \"../base/SchemaBase\";\nimport { SchemaDefault } from \"./SchemaDefault\";\nimport { SchemaDeserialize } from \"./SchemaDeserialize\";\nimport { SchemaFrom } from \"./SchemaFrom\";\nimport { SchemaSerialize } from \"./SchemaSerialize\";\n\nexport class SchemaReadonly<T extends any, TModifiers extends SchemaModifiers> extends SchemaBase<T, TModifiers> {\n\n instance: T;\n private _schemaReadonly = true;\n\n constructor(current: SchemaBase<T, TModifiers>) {\n super(current);\n this.instance = current.instance;\n this.isReadonly = true;\n }\n\n default<I = never>(value: DefaultValue<T, I>, injected?: I) {\n return new SchemaDefault<T, I, TModifiers | \"default\">(value, injected, this);\n }\n\n deserializer(deserializer: PropertyDeserializer<T>) {\n return new SchemaDeserialize<T, TModifiers | \"deserialize\">(deserializer, this);\n }\n\n serializer(serializer: PropertySerializer<T>) {\n return new SchemaSerialize<T, TModifiers | \"deserialize\">(serializer, this);\n }\n\n from(propertyName: string) {\n return new SchemaFrom<T, TModifiers>(propertyName, this);\n }\n}","import { DefaultValue, PropertyDeserializer, PropertySerializer, SchemaModifiers } from \"../../types\";\nimport { SchemaBase } from \"../base/SchemaBase\";\nimport { SchemaDefault } from \"./SchemaDefault\";\nimport { SchemaDeserialize } from \"./SchemaDeserialize\";\nimport { SchemaDistinct } from \"./SchemaDistinct\";\nimport { SchemaIdentity } from \"./SchemaIdentity\";\nimport { SchemaNullable } from \"./SchemaNullable\";\nimport { SchemaOptional } from \"./SchemaOptional\";\nimport { SchemaReadonly } from \"./SchemaReadonly\";\nimport { SchemaSerialize } from \"./SchemaSerialize\";\n\nexport class SchemaFrom<T extends any, TModifiers extends SchemaModifiers> extends SchemaBase<T, TModifiers> {\n instance: T;\n private _schemaFrom = true;\n\n constructor(propertyName: string, current: SchemaBase<T, TModifiers>) {\n super(current);\n this.instance = current.instance;\n this.fromPropertyName = propertyName;\n }\n\n default<I = never>(value: DefaultValue<T, I>, injected?: I) {\n return new SchemaDefault<T, I, TModifiers | \"default\">(value, injected, this);\n }\n\n deserialize(deserializer: PropertyDeserializer<T>) {\n return new SchemaDeserialize<T, TModifiers | \"deserialize\">(deserializer, this);\n }\n\n distinct() {\n return new SchemaDistinct<T, TModifiers | \"distinct\">(this);\n }\n\n identity() {\n return new SchemaIdentity<T, TModifiers | \"identity\" | \"readonly\">(this);\n }\n\n optional() {\n return new SchemaOptional<T, TModifiers | \"optional\">(this);\n }\n\n nullable() {\n return new SchemaNullable<T, TModifiers | \"nullable\">(this);\n }\n\n readonly() {\n return new SchemaReadonly<T, TModifiers | \"readonly\">(this);\n }\n\n serialize(serializer: PropertySerializer<T>) {\n return new SchemaSerialize<T, TModifiers | \"serialize\">(serializer, this);\n }\n\n\n}","import { DefaultValue, PropertyDeserializer, PropertySerializer, SchemaModifiers } from \"../../types\";\nimport { SchemaBase } from \"../base/SchemaBase\";\nimport { SchemaDefault } from \"./SchemaDefault\";\nimport { SchemaFrom } from \"./SchemaFrom\";\nimport { SchemaOptional } from \"./SchemaOptional\";\nimport { SchemaSerialize } from \"./SchemaSerialize\";\n\nexport class SchemaDeserialize<T extends any, TModifiers extends SchemaModifiers> extends SchemaBase<T, TModifiers> {\n instance: T;\n private _schemaDeserialize = true;\n\n constructor(deserializer: PropertyDeserializer<T>, current: SchemaBase<T, TModifiers>) {\n super(current);\n this.instance = current.instance;\n this.valueDeserializer = deserializer;\n }\n\n serialize(serializer: PropertySerializer<T>) {\n return new SchemaSerialize<T, TModifiers | \"serialize\">(serializer, this);\n }\n\n from(propertyName: string) {\n return new SchemaFrom<T, TModifiers>(propertyName, this);\n }\n\n optional() {\n return new SchemaOptional<T, TModifiers | \"optional\">(this);\n }\n\n default<I = never>(value: DefaultValue<T | null, I>, injected?: I) {\n return new SchemaDefault<T | null, I, TModifiers | \"default\">(value, injected, this);\n }\n\n}","import { logger } from \"../../../utilities\";\nimport { DefaultValue, PropertyDeserializer, PropertySerializer, SchemaModifiers } from \"../../types\";\nimport { SchemaBase } from \"../base/SchemaBase\";\nimport { SchemaDeserialize } from \"./SchemaDeserialize\";\nimport { SchemaFrom } from \"./SchemaFrom\";\nimport { SchemaSerialize } from \"./SchemaSerialize\";\n\nexport class SchemaDefault<T extends any, I, TModifiers extends SchemaModifiers> extends SchemaBase<T, TModifiers> {\n instance: T;\n private _schemaDefault = true;\n\n constructor(defaultValue: DefaultValue<T, I>, injected: I, current: SchemaBase<T, TModifiers>) {\n super(current);\n\n if (defaultValue == null) {\n logger.warn(\"Do not use `.default(null)` in your schema, please use `.default(() => null)`\")\n }\n\n this.instance = current.instance;\n this.injected = injected;\n this.defaultValue = defaultValue;\n }\n\n serialize(serializer: PropertySerializer<T>) {\n return new SchemaSerialize<T, TModifiers | \"serialize\">(serializer, this);\n }\n\n deserialize(deserializer: PropertyDeserializer<T>) {\n return new SchemaDeserialize<T, TModifiers | \"deserialize\">(deserializer, this);\n }\n\n from(propertyName: string) {\n return new SchemaFrom<T, TModifiers>(propertyName, this);\n }\n}","import { uuidv4 } from \"../../../utilities\";\nimport { DefaultValue, PropertyDeserializer, PropertySerializer, SchemaModifiers } from \"../../types\";\nimport { SchemaBase } from \"../base/SchemaBase\";\nimport { SchemaDefault } from \"./SchemaDefault\";\nimport { SchemaDeserialize } from \"./SchemaDeserialize\";\nimport { SchemaDistinct } from \"./SchemaDistinct\";\nimport { SchemaFrom } from \"./SchemaFrom\";\nimport { SchemaNullable } from \"./SchemaNullable\";\nimport { SchemaOptional } from \"./SchemaOptional\";\nimport { SchemaReadonly } from \"./SchemaReadonly\";\nimport { SchemaSerialize } from \"./SchemaSerialize\";\n\nexport class SchemaIndex<T extends any, TModifiers extends SchemaModifiers> extends SchemaBase<T, TModifiers> {\n\n instance: T;\n private _schemaIndex = true;\n\n constructor(current: SchemaBase<T, TModifiers>, ...indexes: string[]) {\n super(current);\n this.instance = current.instance;\n\n if (indexes.length === 0) {\n indexes.push(uuidv4()); // Create our own unique index identifier\n }\n\n this.indexes = indexes;\n }\n\n optional() {\n return new SchemaOptional<T, TModifiers | \"optional\">(this);\n }\n\n nullable() {\n return new SchemaNullable<T, TModifiers | \"nullable\">(this);\n }\n\n default<I = never>(value: DefaultValue<T, I>, injected?: I) {\n return new SchemaDefault<T, I, TModifiers | \"default\">(value, injected, this);\n }\n\n readonly() {\n return new SchemaReadonly<T, TModifiers | \"readonly\">(this);\n }\n\n deserialize(deserializer: PropertyDeserializer<T>) {\n return new SchemaDeserialize<T, TModifiers | \"deserialize\">(deserializer, this);\n }\n\n serialize(serializer: PropertySerializer<T>) {\n return new SchemaSerialize<T, TModifiers | \"serialize\">(serializer, this);\n }\n\n distinct() {\n return new SchemaDistinct<T, TModifiers | \"distinct\">(this);\n }\n\n from(propertyName: string) {\n return new SchemaFrom<T, TModifiers>(propertyName, this);\n }\n}","import { DefaultValue, PropertyDeserializer, PropertySerializer, SchemaModifiers } from \"../../types\";\nimport { SchemaBase } from \"../base/SchemaBase\";\nimport { SchemaArray } from \"../types\";\nimport { SchemaDefault } from \"./SchemaDefault\";\nimport { SchemaDeserialize } from \"./SchemaDeserialize\";\nimport { SchemaDistinct } from \"./SchemaDistinct\";\nimport { SchemaFrom } from \"./SchemaFrom\";\nimport { SchemaIndex } from \"./SchemaIndex\";\nimport { SchemaNullable } from \"./SchemaNullable\";\nimport { SchemaOptional } from \"./SchemaOptional\";\nimport { SchemaReadonly } from \"./SchemaReadonly\";\nimport { SchemaSerialize } from \"./SchemaSerialize\";\n\nexport class SchemaTag<T extends any, TModifiers extends SchemaModifiers> extends SchemaBase<T, TModifiers> {\n instance: T;\n private _schemaTag = true;\n\n constructor(tags: string[], current: SchemaBase<T, TModifiers>) {\n super(current);\n this.tags = tags;\n this.instance = current.instance;\n }\n\n from(propertyName: string) {\n return new SchemaFrom<T, TModifiers>(propertyName, this);\n }\n\n optional() {\n return new SchemaOptional<T, TModifiers | \"optional\">(this);\n }\n\n nullable() {\n return new SchemaNullable<T, TModifiers | \"nullable\">(this);\n }\n\n default<I = never>(value: DefaultValue<T, I>, injected?: I) {\n return new SchemaDefault<T, I, TModifiers | \"default\">(value, injected, this);\n }\n\n readonly() {\n return new SchemaReadonly<T, TModifiers | \"readonly\">(this);\n }\n\n deserialize(deserializer: PropertyDeserializer<T>) {\n return new SchemaDeserialize<T, TModifiers | \"deserialize\">(deserializer, this);\n }\n\n serialize(serializer: PropertySerializer<T>) {\n return new SchemaSerialize<T, TModifiers | \"serialize\">(serializer, this);\n }\n\n array() {\n return new SchemaArray<typeof this, TModifiers>(this as unknown as SchemaArray<typeof this, TModifiers>);\n }\n\n index(...indexes: string[]) {\n return new SchemaIndex<T, TModifiers>(this, ...indexes);\n }\n\n distinct() {\n return new SchemaDistinct<T, TModifiers | \"distinct\">(this);\n }\n}","import { SchemaBase } from \"../base/SchemaBase\";\nimport { SchemaDefault } from \"../modifiers/SchemaDefault\";\nimport { SchemaNullable } from \"../modifiers/SchemaNullable\";\nimport { SchemaOptional } from \"../modifiers/SchemaOptional\";\nimport { SchemaDeserialize } from '../modifiers/SchemaDeserialize';\nimport { SchemaSerialize } from '../modifiers/SchemaSerialize';\nimport { SchemaIndex } from \"../modifiers/SchemaIndex\";\nimport { DefaultValue, PropertyDeserializer, PropertySerializer, SchemaModifiers, SchemaTypes } from \"../../types\";\nimport { SchemaFrom } from \"../modifiers/SchemaFrom\";\nimport { SchemaTag } from \"../modifiers/SchemaTag\";\n\nexport class SchemaArray<T extends any, TModifiers extends SchemaModifiers> extends SchemaBase<T[], TModifiers> {\n\n instance: T[];\n type = SchemaTypes.Array;\n private _schemaArray = true;\n readonly innerSchema?: SchemaBase<any, any>; // we need to know the type of the array, that is what this is for\n\n constructor(entity?: SchemaBase<T[], TModifiers>, literals?: T[][]) {\n super(entity, literals);\n this.innerSchema = entity;\n }\n\n from(propertyName: string) {\n return new SchemaFrom<T[], TModifiers>(propertyName, this);\n }\n\n optional() {\n return new SchemaOptional<T[], TModifiers | \"optional\">(this);\n }\n\n nullable() {\n return new SchemaNullable<T[], TModifiers | \"nullable\">(this);\n }\n\n default<I = never>(value: DefaultValue<T[], I>, injected?: I) {\n return new SchemaDefault<T[], I, TModifiers | \"default\">(value, injected, this);\n }\n\n deserialize(deserializer: PropertyDeserializer<T[]>) {\n return new SchemaDeserialize<T[], TModifiers | \"deserialize\">(deserializer, this);\n }\n\n serialize(serializer: PropertySerializer<T[]>) {\n return new SchemaSerialize<T[], TModifiers | \"serialize\">(serializer, this);\n }\n\n index(...indexes: string[]) {\n return new SchemaIndex<T[], TModifiers>(this, ...indexes);\n }\n\n tag(...tags: string[]) {\n return new SchemaTag<T[], TModifiers>(tags, this);\n }\n\n\n}","import { DefaultValue, PropertyDeserializer, PropertySerializer, SchemaModifiers, SchemaTypes } from \"../../types\";\nimport { SchemaBase } from \"../base/SchemaBase\";\nimport { SchemaDefault } from \"../modifiers/SchemaDefault\";\nimport { SchemaDeserialize } from \"../modifiers/SchemaDeserialize\";\nimport { SchemaDistinct } from \"../modifiers/SchemaDistinct\";\nimport { SchemaFrom } from \"../modifiers/SchemaFrom\";\nimport { SchemaIndex } from \"../modifiers/SchemaIndex\";\nimport { SchemaNullable } from \"../modifiers/SchemaNullable\";\nimport { SchemaOptional } from \"../modifiers/SchemaOptional\";\nimport { SchemaReadonly } from \"../modifiers/SchemaReadonly\";\nimport { SchemaSerialize } from \"../modifiers/SchemaSerialize\";\nimport { SchemaTag } from \"../modifiers/SchemaTag\";\nimport { SchemaArray } from \"./SchemaArray\";\n\nexport class SchemaBoolean<T extends boolean, TModifiers extends SchemaModifiers> extends SchemaBase<T, TModifiers> {\n\n instance: T;\n type = SchemaTypes.Boolean;\n private _schemaBoolean = true;\n\n from(propertyName: string) {\n return new SchemaFrom<T, TModifiers>(propertyName, this);\n }\n\n optional() {\n return new SchemaOptional<T, TModifiers | \"optional\">(this);\n }\n\n nullable() {\n return new SchemaNullable<T, TModifiers | \"nullable\">(this);\n }\n\n default<I = never>(value: DefaultValue<T, I>, injected?: I) {\n return new SchemaDefault<T, I, TModifiers | \"default\">(value, injected, this);\n }\n\n readonly() {\n return new SchemaReadonly<T, TModifiers | \"readonly\">(this);\n }\n\n deserialize(deserializer: PropertyDeserializer<T>) {\n return new SchemaDeserialize<T, TModifiers | \"deserialize\">(deserializer, this);\n }\n\n serialize(serializer: PropertySerializer<T>) {\n return new SchemaSerialize<T, TModifiers | \"serialize\">(serializer, this);\n }\n\n array() {\n return new SchemaArray<typeof this, TModifiers>(this as unknown as SchemaArray<typeof this, TModifiers>);\n }\n\n index(...indexes: string[]) {\n return new SchemaIndex<T, TModifiers>(this, ...indexes);\n }\n\n distinct() {\n return new SchemaDistinct<T, TModifiers | \"distinct\">(this);\n }\n\n tag(...tags: string[]) {\n return new SchemaTag<T, TModifiers>(tags, this);\n }\n\n\n}","import { DefaultValue, PropertyDeserializer, PropertySerializer, SchemaModifiers, SchemaTypes } from \"../../types\";\nimport { SchemaBase } from \"../base/SchemaBase\";\nimport { SchemaDefault } from \"../modifiers/SchemaDefault\";\nimport { SchemaDeserialize } from \"../modifiers/SchemaDeserialize\";\nimport { SchemaDistinct } from \"../modifiers/SchemaDistinct\";\nimport { SchemaFrom } from \"../modifiers/SchemaFrom\";\nimport { SchemaIndex } from \"../modifiers/SchemaIndex\";\nimport { SchemaNullable } from \"../modifiers/SchemaNullable\";\nimport { SchemaOptional } from \"../modifiers/SchemaOptional\";\nimport { SchemaReadonly } from \"../modifiers/SchemaReadonly\";\nimport { SchemaSerialize } from \"../modifiers/SchemaSerialize\";\nimport { SchemaTag } from \"../modifiers/SchemaTag\";\nimport { SchemaArray } from \"./SchemaArray\";\n\nexport class SchemaDate<T extends Date, TModifiers extends SchemaModifiers> extends SchemaBase<T, TModifiers> {\n\n instance: T;\n type = SchemaTypes.Date;\n private _schemaDate = true;\n\n from(propertyName: string) {\n return new SchemaFrom<T, TModifiers>(propertyName, this);\n }\n\n optional() {\n return new SchemaOptional<T, TModifiers | \"optional\">(this);\n }\n\n nullable() {\n return new SchemaNullable<T, TModifiers | \"nullable\">(this);\n }\n\n default<I = never>(value: DefaultValue<T, I>, injected?: I) {\n return new SchemaDefault<T, I, TModifiers | \"default\">(value, injected, this);\n }\n readonly() {\n return new SchemaReadonly<T, TModifiers | \"readonly\">(this);\n }\n\n deserialize(deserializer: PropertyDeserializer<T>) {\n return new SchemaDeserialize<T, TModifiers | \"deserialize\">(deserializer, this);\n }\n\n serialize(serializer: PropertySerializer<T>) {\n return new SchemaSerialize<T, TModifiers | \"serialize\">(serializer, this);\n }\n\n array() {\n return new SchemaArray<typeof this, TModifiers>(this as unknown as SchemaArray<typeof this, TModifiers>);\n }\n\n index(...indexes: string[]) {\n return new SchemaIndex<T, TModifiers>(this, ...indexes);\n }\n\n distinct() {\n return new SchemaDistinct<T, TModifiers | \"distinct\">(this);\n }\n\n tag(...tags: string[]) {\n return new SchemaTag<T, TModifiers>(tags, this);\n }\n\n\n}","import { SchemaBase } from \"../property/base/SchemaBase\";\nimport { SchemaModifiers, SchemaTypes } from \"../types\";\n\nexport class SchemaFunction<T extends any, I, TModifiers extends SchemaModifiers = \"unmapped\"> extends SchemaBase<() => T, TModifiers> {\n instance: () => T;\n type = SchemaTypes.Function;\n private _schemaFunction = true;\n\n constructor(fn: (injected: I) => T, injected: I, current?: SchemaBase<() => T, TModifiers>) {\n super(current);\n this.injected = injected;\n this.isUnmapped = true;\n this.functionBody = fn as any;\n }\n}","import { SchemaBase } from \"../property/base/SchemaBase\";\nimport { PropertyTransform, SchemaModifiers } from \"../types\";\n\n/**\n * A two-way transform between the value your application holds and the value that is stored.\n *\n * Declared in `.modify()`, beside `computed` and `function`, because it belongs to the same\n * family: a property whose stored form is derived rather than assigned. `computed` derives one\n * way and cannot come back; a transform declares both directions.\n *\n * ```ts\n * const cipher = myEncryption(keyring); // whatever you use — {} with `to` and `from`\n *\n * const userSchema = s.define('users', {\n * id: s.string().key().identity(),\n * ssn: s.string(),\n * }).modify(x => ({\n * ssn: x.transform(cipher),\n * })).compile();\n * ```\n *\n * `to` and `from` may be async, and they are held as LIVE references — never stringified into\n * generated code the way `computed` is. So they close over whatever they need, which is why\n * there is no `injected` argument to pass and no property to repeat.\n *\n * Nothing about this is encryption. Encryption is one thing a caller might write here;\n * compression, redaction, unit conversion and a custom codec are others. The library ships no\n * behaviour of its own for this — it only carries what you supply.\n */\nexport class SchemaTransform<T extends any, TModifiers extends SchemaModifiers = never> extends SchemaBase<T, TModifiers> {\n\n instance: T;\n private _schemaTransform = true;\n\n /**\n * Bound to the property it replaces when the schema is assembled.\n *\n * You do not pass the property in. `.modify()` already knows which one you mean — it is\n * the key you assigned to — so repeating `s.string()` would be ceremony for nothing.\n */\n bindTo(underlying: SchemaBase<T, TModifiers>) {\n // The underlying property keeps its type, its key and identity flags, and its\n // modifiers. A transform changes how a value is STORED, never what it is: an\n // encrypted number is still a number, so `InferType` must not shift.\n Object.assign(this, underlying, { transform: this.transform, _schemaTransform: true });\n\n this.instance = underlying.instance;\n this.type = underlying.type;\n\n return this;\n }\n\n constructor(transform: PropertyTransform<T>) {\n super();\n this.instance = null as T;\n this.transform = transform as PropertyTransform<unknown>;\n }\n}\n\n\n","import { SchemaBase } from \"../base/SchemaBase\";\nimport { SchemaIdentity } from \"./SchemaIdentity\";\nimport { SchemaDefault } from \"./SchemaDefault\";\nimport { CompiledSchema, DefaultValue, InferType, SchemaModifiers } from \"../../types\";\nimport { SchemaFrom } from \"./SchemaFrom\";\nimport { SchemaTag } from \"./SchemaTag\";\n\nexport class SchemaForeignKey<T extends any, TModifiers extends SchemaModifiers, K extends {}> extends SchemaBase<T, TModifiers> {\n instance: T;\n private _schemaForeignKey = true;\n\n constructor(current: SchemaBase<T, TModifiers>, relatingSchema: CompiledSchema<K>, property: keyof InferType<CompiledSchema<K>>) {\n super(current);\n this.instance = current.instance;\n this.foreignKeyDefinition = {\n schema: relatingSchema,\n property: relatingSchema.getProperty(String(property))\n };\n }\n\n identity() {\n return new SchemaIdentity<T, TModifiers | \"identity\">(this);\n }\n\n default<I = never>(value: DefaultValue<T, I>, injected?: I) {\n return new SchemaDefault<T, I, TModifiers | \"default\">(value, injected, this);\n }\n\n from(propertyName: string) {\n return new SchemaFrom<T, TModifiers>(propertyName, this);\n }\n\n tag(...tags: string[]) {\n return new SchemaTag<T, TModifiers>(tags, this);\n }\n}","import { SchemaBase } from \"../base/SchemaBase\";\nimport { SchemaIdentity } from \"./SchemaIdentity\";\nimport { SchemaDefault } from \"./SchemaDefault\";\nimport { DefaultValue, IdType, SchemaModifiers } from \"../../types\";\nimport { SchemaFrom } from \"./SchemaFrom\";\nimport { SchemaTag } from \"./SchemaTag\";\n\nexport class SchemaKey<T extends IdType, TModifiers extends SchemaModifiers> extends SchemaBase<T, TModifiers> {\n instance: T;\n private _schemaKey = true;\n\n constructor(current: SchemaBase<T, TModifiers>) {\n super(current);\n this.instance = current.instance;\n this.isKey = true;\n }\n\n identity() {\n return new SchemaIdentity<T, TModifiers | \"identity\">(this);\n }\n\n default<I = never>(value: DefaultValue<T, I>, injected?: I) {\n return new SchemaDefault<T, I, TModifiers | \"default\">(value, injected, this);\n }\n\n from(propertyName: string) {\n return new SchemaFrom<T, TModifiers>(propertyName, this);\n }\n\n tag(...tags: string[]) {\n return new SchemaTag<T, TModifiers>(tags, this);\n }\n}","import { CompiledSchema, IdType, InferType, SchemaModifiers } from \"../../types\";\nimport { SchemaBase } from \"../base/SchemaBase\";\nimport { SchemaForeignKey } from \"./SchemaForeignKey\";\nimport { SchemaKey } from \"./SchemaKey\";\nimport { SchemaTag } from \"./SchemaTag\";\n\nexport class SchemaTracked<T extends any, TModifiers extends SchemaModifiers> extends SchemaBase<T, TModifiers> {\n\n instance: T;\n private _schemaTracked = true;\n\n constructor(current: SchemaBase<T, TModifiers>) {\n super(current);\n this.instance = current.instance;\n this.isUnmapped = false;\n }\n\n key(): T extends IdType ? SchemaKey<T, TModifiers | \"key\"> : never {\n return new SchemaKey(this as SchemaBase<T & IdType, TModifiers>) as T extends IdType ? SchemaKey<T, TModifiers | \"key\"> : never;\n }\n\n foreignKey<K extends {}>(relatingSchema: CompiledSchema<K>, property: keyof InferType<CompiledSchema<K>>) {\n return new SchemaForeignKey<T, TModifiers, K>(this, relatingSchema, property);\n }\n\n tag(...tags: string[]) {\n return new SchemaTag<T, TModifiers>(tags, this);\n }\n}","import { SchemaBase } from \"../property/base/SchemaBase\";\nimport { SchemaTracked } from '../property/modifiers/SchemaTracked';\nimport { SchemaModifiers, SchemaTypes } from \"../types\";\n\nexport class SchemaComputed<T extends any, I, TModifiers extends SchemaModifiers = \"computed\"> extends SchemaBase<T, TModifiers> {\n instance: T;\n type = SchemaTypes.Computed;\n private _schemaComputed = true;\n\n constructor(fn: T, injected: I, current?: SchemaBase<T, TModifiers>) {\n super(current);\n this.injected = injected;\n this.isUnmapped = true;\n this.functionBody = fn as any;\n }\n\n tracked() {\n return new SchemaTracked<T, Exclude<TModifiers, \"unmapped\">>(this as unknown as SchemaBase<T, Exclude<TModifiers, \"unmapped\">>);\n }\n}","import { UnknownRecord } from '../utilities';\nimport { SchemaBase } from './property/base/SchemaBase';\nimport { SchemaArray } from './property/types/SchemaArray';\nimport { DefaultValue, ForeignKey, FunctionBody, PropertyDeserializer, PropertySerializer, SchemaTypes, PropertyTransform } from './types';\n\nconst SUPPORTED_DESERIALIZATION_TYPES = new Set<SchemaTypes>([\n SchemaTypes.Boolean,\n SchemaTypes.Date,\n SchemaTypes.Number,\n SchemaTypes.String,\n]);\n\n/**\n * Represents metadata and utilities for a property in a schema, including its type, name, parent, children, and serialization details.\n */\nexport class PropertyInfo<T extends {}> {\n\n get id() {\n if (this._idCache) {\n return this._idCache;\n }\n this._idCache = this.getPathArray().join(\".\");\n return this._idCache;\n }\n\n /** The name of the property. */\n readonly name: string;\n /** The name of the property we need to map from. */\n readonly from: string | null = null;\n /** The schema type of the property. */\n readonly type: SchemaTypes;\n\n /** Whether the property can be null. */\n readonly isNullable: boolean;\n /** Whether the property is optional. */\n readonly isOptional: boolean;\n /** Whether the property is a key. */\n readonly isKey: boolean;\n /** Foreign key schema and property */\n readonly foreignKeyDefinition: ForeignKey<unknown> | null;\n /** Whether the property is an identity property. */\n readonly isIdentity: boolean;\n /** Whether the property is readonly. */\n readonly isReadonly: boolean;\n /** Whether the property is unmapped. */\n readonly isUnmapped: boolean;\n /** Whether the property is distinct. */\n readonly isDistinct: boolean;\n\n\n /**\n * A two-way transform between the application value and the stored value, or `null`.\n *\n * A LIVE reference. Unlike `computed`, which is stringified into generated code, this is\n * held as-is so it can close over a key, a client, or anything else a caller needs — and\n * so it can be async, which generated code cannot be.\n */\n readonly transform: PropertyTransform<unknown> | null;\n /** Indexes associated with the property. */\n readonly indexes: string[];\n\n /** Any injected value for the property. */\n readonly injected: any | null = null;\n /** The default value for the property, if any. */\n readonly defaultValue: DefaultValue<any> | null = null;\n /** Serializer for the property value, if any. */\n readonly valueSerializer: PropertySerializer<T> | null = null;\n /** Deserializer for the property value, if any. */\n readonly valueDeserializer: PropertyDeserializer<T> | null = null;\n /** Function body for computed properties, if any. */\n readonly functionBody: FunctionBody<any, T> | null;\n /** Child properties of this property. */\n readonly children: PropertyInfo<T>[] = [];\n /** The schema this property belongs to. */\n readonly schema: SchemaBase<T, any>;\n /** The inner schema if this property is an array. */\n readonly innerSchema?: SchemaBase<unknown, any>;\n /** How many numbers this property holds if it is a vector, `null` otherwise. */\n readonly dimensions: number | null;\n /** The longest value this property is declared to hold, `null` if it declares none. */\n readonly maxLength: number | null;\n /**\n * Whether this property may be tokenised into a full-text search index.\n *\n * True only for a string. See the constructor — this is derived from the declaration and\n * the type together, not copied.\n */\n readonly isSearchable: boolean;\n /** Literal values allowed for this property. */\n readonly literals: T[];\n /** Tags passed from the schema */\n readonly tags: string[];\n\n /** The parent property, if any. */\n readonly parent?: PropertyInfo<T>;\n\n // Cached computed values for performance\n private _propertyChainCache?: PropertyInfo<T>[];\n private _pathArrayCache?: string[];\n private _parentPathArrayCache?: string[];\n private _idCache?: string;\n private _levelCache?: number;\n private _hasNullableParentsCache?: boolean;\n private _hasRenamedSegmentsCache?: boolean;\n\n constructor(schema: SchemaBase<T, any>, name: string, parent?: PropertyInfo<T> | null) {\n this.schema = schema;\n this.name = name;\n this.type = schema.type;\n this.literals = schema.literals;\n this.dimensions = schema.dimensions;\n this.maxLength = schema.maxLength;\n // Both, always. The builder already refuses `.searchable()` on anything but a string,\n // but that gate is a type and types do not exist at runtime — a schema rebuilt from\n // hand-written JSON can set the raw flag on a number. Deriving the answer here means\n // every reader gets a searchable property that is definitely a string, rather than each\n // one having to remember to check.\n this.isSearchable = schema.isSearchable && schema.type === SchemaTypes.String;\n\n if (schema instanceof SchemaArray) {\n this.innerSchema = schema.innerSchema;\n }\n\n this.isNullable = schema.isNullable;\n this.isOptional = schema.isOptional;\n this.isKey = schema.isKey;\n this.isIdentity = schema.isIdentity;\n this.isReadonly = schema.isReadonly;\n this.isUnmapped = schema.isUnmapped;\n this.injected = schema.injected;\n this.isDistinct = schema.isDistinct;\n this.transform = schema.transform;\n this.indexes = schema.indexes;\n this.from = schema.fromPropertyName;\n this.tags = schema.tags;\n this.foreignKeyDefinition = schema.foreignKeyDefinition;\n\n this.defaultValue = schema.defaultValue;\n this.valueSerializer = schema.valueSerializer;\n this.valueDeserializer = schema.valueDeserializer;\n this.functionBody = schema.functionBody;\n\n this.parent = parent;\n }\n\n /**\n * Returns the depth (level) of this property in the property tree.\n *\n * The root property has a level of 0. Each child property increases the level by 1.\n * Traverses up the parent chain, incrementing the level for each parent until the root is reached.\n * \n * @returns {number} The number of parent properties above this property (0 for root).\n */\n get level() {\n if (this._levelCache !== undefined) {\n return this._levelCache;\n }\n\n let level = 0;\n // oxlint-disable-next-line no-this-alias\n let current: PropertyInfo<T> | undefined = this;\n\n while (current) {\n if (current.parent == null) {\n this._levelCache = level;\n return level;\n }\n\n current = current.parent;\n level++;\n }\n\n this._levelCache = level;\n return level;\n }\n\n get isRenamed() {\n return !!this.from;\n }\n\n get supportsDeserialization() {\n return this.valueDeserializer != null || SUPPORTED_DESERIALIZATION_TYPES.has(this.type);\n }\n\n private _getPropertyChain(): PropertyInfo<T>[] {\n if (this._propertyChainCache) {\n return this._propertyChainCache;\n }\n\n const chain: PropertyInfo<T>[] = [];\n // oxlint-disable-next-line no-this-alias\n let current: PropertyInfo<T> | undefined = this;\n\n while (current) {\n chain.unshift(current);\n current = current.parent;\n }\n\n this._propertyChainCache = chain;\n return chain;\n }\n\n private _needsOptionalChaining(precedingProp: PropertyInfo<T> | null, assignmentType?: AssignmentType): boolean {\n if (assignmentType === \"ASSIGNMENT\") {\n return false;\n }\n\n if (assignmentType === \"FORCE_NULLABLE_OR_OPTIONAL\") {\n return true;\n }\n\n // The accessor guards the value it follows: entity.a?.c is safe when `a`\n // is nullable, entity?.a.c is not. The root can never be null.\n if (precedingProp == null) {\n return false;\n }\n\n return precedingProp.isNullable || precedingProp.isOptional;\n }\n\n private _resolvePathArray(options?: {\n root?: string,\n assignmentType?: AssignmentType\n useFromPropertyName?: boolean,\n }) {\n const propertyChain = this._getPropertyChain();\n const hasRoot = options?.root != null;\n const path: string[] = hasRoot ? [options!.root!] : [];\n let precedingProp: PropertyInfo<T> | null = null;\n\n for (const prop of propertyChain) {\n const accessor = this._needsOptionalChaining(precedingProp, options?.assignmentType) ? '?.' : '.';\n // Storage-side paths use `from` per segment; segments that were never\n // renamed keep their property name\n path.push(accessor, options?.useFromPropertyName ? (prop.from ?? prop.name) : prop.name);\n precedingProp = prop;\n }\n\n return path;\n }\n\n getResolvedName() {\n return this.from ?? this.name;\n }\n\n /**\n * Returns an array of property names representing the path from the root to this property.\n *\n * @returns {string[]} The property path as an array of names.\n */\n getPathArray() {\n if (this._pathArrayCache) {\n return this._pathArrayCache;\n }\n\n const path: string[] = [];\n const propertyChain = this._getPropertyChain();\n\n for (const prop of propertyChain) {\n path.push(prop.name);\n }\n\n this._pathArrayCache = path;\n return path;\n }\n\n /**\n * Returns an array of property names representing the path from the root to the parent of this property.\n *\n * @returns {string[]} The property path as an array of names, excluding this property.\n */\n getParentPathArray(options?: { useFromPropertyName?: boolean }) {\n if (options?.useFromPropertyName === true) {\n // Storage-side variant is uncached: `from` falls back to the property\n // name per segment\n const fromPath: string[] = [];\n const chain = this._getPropertyChain();\n\n for (let i = 0; i < chain.length - 1; i++) {\n const prop = chain[i];\n fromPath.push(prop.from ?? prop.name);\n }\n\n return fromPath;\n }\n\n if (this._parentPathArrayCache) {\n return this._parentPathArrayCache;\n }\n\n const path: string[] = [];\n const propertyChain = this._getPropertyChain();\n\n for (let i = 0; i < propertyChain.length - 1; i++) {\n const prop = propertyChain[i];\n path.push(prop.name);\n }\n\n this._parentPathArrayCache = path;\n return path;\n }\n\n /**\n * Returns true if any parent property is nullable or optional.\n *\n * @returns {boolean} True if any parent is nullable or optional, false otherwise.\n */\n get hasNullableParents() {\n if (this._hasNullableParentsCache !== undefined) {\n return this._hasNullableParentsCache;\n }\n\n let parent = this.parent;\n while (parent != null) {\n if (parent.isNullable || parent.isOptional) {\n this._hasNullableParentsCache = true;\n return true;\n }\n parent = parent.parent;\n }\n\n this._hasNullableParentsCache = false;\n return false;\n }\n\n /**\n * Returns true if this property or any parent is renamed with from().\n * Storage paths for such properties differ from their in-memory paths.\n *\n * @returns {boolean} True if any segment of the path is renamed, false otherwise.\n */\n get hasRenamedSegments(): boolean {\n if (this._hasRenamedSegmentsCache !== undefined) {\n return this._hasRenamedSegmentsCache;\n }\n\n // oxlint-disable-next-line no-this-alias\n let current: PropertyInfo<T> | undefined = this;\n while (current != null) {\n if (current.from != null) {\n this._hasRenamedSegmentsCache = true;\n return true;\n }\n current = current.parent;\n }\n\n this._hasRenamedSegmentsCache = false;\n return false;\n }\n\n /**\n * Returns true if any child property (recursively) is an identity property.\n *\n * @returns {boolean} True if any child is an identity property, false otherwise.\n */\n get hasIdentityChildren() {\n const children = [...this.children];\n for (let i = 0; i < children.length; i++) {\n const child = children[i];\n if (child.isIdentity === true) {\n return true;\n }\n if (child.children.length > 0) {\n children.push(...child.children)\n }\n }\n return false;\n }\n\n /**\n * Gets the value of this property from the given instance, following the property path.\n *\n * @param instance The object instance to retrieve the value from.\n * @returns The value of the property, or null if not found.\n */\n getValue(instance: UnknownRecord) {\n if (instance == null) {\n return null;\n }\n const pathArray = this.getPathArray();\n const length = pathArray.length;\n // Fast path for single level properties\n if (length === 1) {\n return instance[pathArray[0]];\n }\n let current: any = instance;\n for (let i = 0; i < length; i++) {\n if (current == null) {\n return null;\n }\n current = current[pathArray[i]];\n }\n return current;\n }\n\n /**\n * Sets the value of this property on the given instance, creating intermediate objects as needed.\n *\n * @param instance The object instance to set the value on.\n * @param value The value to set.\n */\n setValue(instance: UnknownRecord, value: unknown) {\n if (instance == null) {\n throw new Error('Cannot set value on null or undefined instance');\n }\n const pathArray = this.getPathArray();\n const length = pathArray.length;\n // Fast path for single level properties\n if (length === 1) {\n instance[pathArray[0]] = value;\n return;\n }\n let current: any = instance;\n let i = 0;\n // Navigate to the parent of the target property\n while (i < length - 1) {\n const prop = pathArray[i];\n const next = current[prop];\n // Only create new object if next level doesn't exist\n if (next == null) {\n current[prop] = {};\n }\n current = current[prop];\n i++;\n }\n // Set the value on the final property\n current[pathArray[length - 1]] = value;\n }\n\n /**\n * Returns a selector path string for this property, starting from the given parent variable name.\n *\n * @param options.parent The root variable name.\n * @param options.assignmentType Optional assignment type for path resolution.\n * @returns {string} The selector path string (e.g., 'parent.prop1.prop2').\n */\n getSelectrorPath(options: { parent: string, assignmentType?: AssignmentType, useFromPropertyName?: boolean, useRemappedName?: boolean }) {\n const parts = this._resolvePathArray({\n root: options.parent,\n assignmentType: options?.assignmentType,\n useFromPropertyName: options?.useFromPropertyName\n });\n return parts.join(\"\");\n }\n\n /**\n * Returns an assignment path string for this property, optionally starting from a parent variable name.\n *\n * @param options.parent Optional root variable name.\n * @returns {string} The assignment path string (e.g., 'prop1.prop2').\n */\n getAssignmentPath(options?: { parent?: string, useFromPropertyName?: boolean }) {\n const parts = this._resolvePathArray({\n root: options?.parent,\n assignmentType: \"ASSIGNMENT\",\n useFromPropertyName: options?.useFromPropertyName\n });\n\n if (options?.parent == null) {\n return parts.slice(1).join(\"\");\n }\n\n return parts.join(\"\");\n }\n\n deserialize(value: string | number) {\n\n if (this.valueDeserializer != null) {\n return this.valueDeserializer(value);\n }\n\n if (this.type === SchemaTypes.Date) {\n return new Date(value);\n }\n\n if (this.type === SchemaTypes.String) {\n return String(value);\n }\n\n if (this.type === SchemaTypes.Number) {\n return Number(value);\n }\n\n if (this.type === SchemaTypes.Boolean) {\n return Boolean(value);\n }\n\n throw new Error(`Unsupported deserialization for type. Type: ${this.type}`);\n }\n}\n\ntype AssignmentType = \"FORCE_NULLABLE_OR_OPTIONAL\" | \"ASSIGNMENT\";","export class SlotPath {\n\n private _path: string[];\n\n get path() {\n return [...this._path]\n }\n\n constructor(...pathLike: string[]) {\n this._path = pathLike;\n }\n\n push(...pathLike: string[]) {\n this._path.push(...pathLike);\n }\n\n get(up: number = 0) {\n return this._path.slice(0, this._path.length - up).join(\".\")\n }\n}","/**\n * Counts non-overlapping occurrences of a term in text.\n *\n * Behavior:\n * - Case-sensitive matching\n * - If the search term is composed entirely of word characters (A–Z, a–z, 0–9, _),\n * enforce whole-word boundaries so \"red\" does not match inside \"redder\".\n * - If the search term contains any non-word character (e.g. \"=>\", \"()\", \"::\"),\n * match anywhere without boundary checks (useful for symbols).\n * - Non-overlapping matches (after a hit, advances by term length)\n * - Optimized single-character fast path; otherwise uses indexOf loop\n *\n * Examples:\n * - countWordOccurance(\"red redder red\", \"red\") => 2\n * - countWordOccurance(\"()=>{}\", \"=>\") => 1\n * - countWordOccurance(\"aaaa\", \"aa\") => 2 (non-overlapping)\n *\n * @param text The source text to scan\n * @param word The term to match (must be non-empty)\n * @returns The number of occurrences found\n */\nexport const countWordOccurance = (text: string, word: string) => {\n const wl = word.length;\n const tl = text.length;\n\n if (wl === 0 || wl > tl) return 0;\n\n // Fast path for single-character words\n if (wl === 1) {\n let c = 0;\n const code = word.charCodeAt(0);\n for (let i = 0; i < tl; i++) if (text.charCodeAt(i) === code) c++;\n return c;\n }\n\n let count = 0;\n let i = 0;\n\n function isWordCharCode(c: number): boolean {\n return (c >= 48 && c <= 57) // 0-9\n || (c >= 65 && c <= 90) // A-Z\n || (c >= 97 && c <= 122) // a-z\n || c === 95; // _\n }\n\n // Decide whether to enforce word boundaries based on the search term\n let enforceWordBoundaries = true;\n for (let k = 0; k < wl; k++) {\n const cc = word.charCodeAt(k);\n if (!isWordCharCode(cc)) {\n enforceWordBoundaries = false;\n break;\n }\n }\n\n while (true) {\n i = text.indexOf(word, i);\n if (i === -1) break;\n\n if (enforceWordBoundaries) {\n const left = i - 1;\n const right = i + wl;\n const leftOk = left < 0 || !isWordCharCode(text.charCodeAt(left));\n const rightOk = right >= tl || !isWordCharCode(text.charCodeAt(right));\n if (leftOk && rightOk) count++;\n } else {\n // No boundary enforcement for symbol-containing terms\n count++;\n }\n i += wl; // non-overlapping word matches\n }\n\n return count;\n}","import { CodeBuilder, ContainerBlock, IfBuilder, ObjectBuilder, SlotBlock } from '..';\nimport { PropertyInfo } from '../../schema/PropertyInfo';\nimport { SlotPath } from '../SlotPath';\nimport { SchemaError } from '../../errors/SchemaError';\nimport { uuid } from '../../utilities/uuid';\nimport { countWordOccurance } from '../utils';\n\nexport interface IHandler {\n setNext(handler: IHandler): IHandler;\n\n handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null;\n}\n\n/**\n * Terminal link for chains that apply only to a subset of properties (keys,\n * identities). Returning the builder marks every other property as\n * deliberately skipped, so a null return from any chain always means a real\n * coverage gap.\n */\nexport class NotApplicableHandler implements IHandler {\n\n setNext(handler: IHandler): IHandler {\n return handler;\n }\n\n handle(_: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n return builder;\n }\n}\n\nexport abstract class PropertyInfoHandler implements IHandler {\n\n private _next: IHandler | null;\n\n setNext(handler: IHandler): IHandler {\n this._next = handler;\n\n return handler;\n }\n\n handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n try {\n if (this._next) {\n return this._next.handle(property, builder);\n }\n\n return null;\n } catch (e: any) {\n throw new SchemaError(e, `Error handling property: ${property.name}`);\n }\n }\n\n protected buildSlotPath(property: PropertyInfo<any>, path: SlotPath) {\n\n const result = new SlotPath(...path.path);\n const items: string[] = []\n let p = property;\n\n while (p.parent != null) {\n items.unshift(p.name);\n p = p.parent;\n }\n\n items.unshift(p.name);\n\n result.push(...items);\n\n return result\n }\n\n /**\n * Dotted property path from the root entity (e.g. `nested.inner`), used as the\n * change-tracking path prefix so nested writes record against the root's\n * `__tracking__` under their full path.\n */\n protected getTrackingPath(property: PropertyInfo<any>): string {\n const names: string[] = [];\n let p: PropertyInfo<any> | null = property;\n\n while (p != null) {\n names.unshift(p.name);\n p = p.parent;\n }\n\n return names.join(\".\");\n }\n\n /**\n * Emits `if (<root>.a == null) <root>.a = {};` for every ancestor of a\n * nested property, so assignments through the target object never throw when a\n * parent object is absent. The guards run root-down, so grandparents are\n * materialized before their children.\n */\n protected emitDestinationAncestorGuards(property: PropertyInfo<any>, block: IfBuilder, options?: { root?: string, useFromPropertyName?: boolean }) {\n if (property.parent == null) {\n return;\n }\n\n const root = options?.root ?? \"destination\";\n const parentPathArray = property.getParentPathArray({ useFromPropertyName: options?.useFromPropertyName });\n\n for (let i = 0; i < parentPathArray.length; i++) {\n const pathSoFar = [root, ...parentPathArray.slice(0, i + 1)].join(\".\");\n block.appendBody(`if (${pathSoFar} == null) ${pathSoFar} = {};`);\n }\n }\n\n /**\n * Emits the guarded nested-property assignment shared by the serialize handlers:\n * reads the parent through an optional-chained selector (the entity may be a\n * partial — a delta payload or a create payload with absent nested parents),\n * materializes every `result` ancestor, then assigns `valueExpression` to the\n * property's storage-side path.\n */\n protected emitSerializeNestedAssignment(property: PropertyInfo<any>, slot: SlotBlock, valueExpression: string) {\n const parentSelectPath = property.parent!.getSelectrorPath({ parent: \"entity\", assignmentType: \"FORCE_NULLABLE_OR_OPTIONAL\" });\n const resultSelectorPath = property.getAssignmentPath({ parent: \"result\", useFromPropertyName: true });\n\n const ifSlot = slot.if(`${parentSelectPath} != null && Object.hasOwn(${parentSelectPath}, \"${property.name}\")`);\n\n this.emitDestinationAncestorGuards(property, ifSlot, { root: \"result\", useFromPropertyName: true });\n\n ifSlot.appendBody(`${resultSelectorPath} = ${valueExpression}`);\n }\n\n /**\n * Emits the source → destination copy for one property in the merge generator,\n * materializing destination ancestors first.\n *\n * With `onlyWhenChanged`, the assignment is skipped when both sides already hold\n * the same value (compared via `valueOf`, so equal Dates match). This preserves\n * reference identity on the destination when a merge carries no new information —\n * callers hold on to entity instances (e.g. a Date returned from add) and must not\n * see them silently replaced by an equal copy.\n */\n protected emitMergeCopy(property: PropertyInfo<any>, builder: CodeBuilder, options?: { onlyWhenChanged?: boolean }) {\n const selectorPath = property.getSelectrorPath({ parent: \"source\", assignmentType: \"FORCE_NULLABLE_OR_OPTIONAL\" });\n const slot = builder.get<SlotBlock>(\"factory.function.assignments\");\n const sourcePath = property.getAssignmentPath({ parent: \"source\" });\n const destinationPath = property.getAssignmentPath({ parent: \"destination\" });\n\n const ifBlock = slot.if(`${selectorPath} != null`);\n this.emitDestinationAncestorGuards(property, ifBlock);\n\n if (options?.onlyWhenChanged === true) {\n ifBlock.appendBody(`if (${destinationPath} == null || ${destinationPath}.valueOf() !== ${sourcePath}.valueOf()) { ${destinationPath} = ${sourcePath} }`);\n return;\n }\n\n ifBlock.appendBody(`${destinationPath} = ${sourcePath}`);\n }\n\n /**\n * Slot path of the ObjectBuilder that renders `property` inside the enriched\n * literal. Builders are registered as `[enriched.<path>]` under their parent\n * builder, so the lookup path must include every ancestor segment — a flat\n * root-level lookup only works for depth-1 properties.\n */\n protected buildEnrichedObjectSlotPath(property: PropertyInfo<any>, base: SlotPath): SlotPath {\n const result = new SlotPath(...base.path);\n const chain: PropertyInfo<any>[] = [];\n let p: PropertyInfo<any> | null = property;\n\n while (p != null) {\n chain.unshift(p);\n p = p.parent;\n }\n\n for (const item of chain) {\n result.push(`[${item.getAssignmentPath({ parent: \"enriched\" })}]`);\n }\n\n return result;\n }\n\n protected setEnrichedProperty(property: PropertyInfo<any>, root: CodeBuilder) {\n const entitySelectorPath = property.getAssignmentPath({ parent: \"entity\" });\n\n if (property.parent != null) {\n const slotPath = new SlotPath(\"factory\", \"function\", \"enriched\", \"object\", \"enriched\");\n const parentSlotPath = this.buildEnrichedObjectSlotPath(property.parent, slotPath);\n const objectBuilder = root.get<ObjectBuilder>(parentSlotPath.get());\n // Guarded read: the entity may be sparse (e.g. enrich on a create payload),\n // so the parent object cannot be assumed to exist\n const childEntityPathSelector = property.getSelectrorPath({ parent: \"entity\", assignmentType: \"FORCE_NULLABLE_OR_OPTIONAL\" });\n objectBuilder.property(`${property.name}: ${childEntityPathSelector}`);\n return;\n }\n\n const slotPath = new SlotPath(\"factory\", \"function\", \"enriched\", \"object\", \"enriched\");\n let enriched = root.getOrDefault<ObjectBuilder>(slotPath.get());\n\n if (enriched == null) {\n const enrichedSlot = root.get<SlotBlock>(\"factory.function.enriched\");\n enriched = enrichedSlot.variable(\"enriched\", { name: \"object\" }).object({ name: \"enriched\" });\n }\n\n enriched.property(`${property.name}: ${entitySelectorPath}`);\n }\n\n protected toNamedFunction(stringifiedFunction: string, parent: ContainerBlock) {\n const name = `_${uuid()}`;\n\n const builder = parent.function(name);\n const occurences = countWordOccurance(stringifiedFunction, \"=>\")\n\n if (occurences > 0) {\n\n const split = stringifiedFunction.split(\"=>\").map(w => w.trim());\n const parameters = split[0].replace(/\\(|\\)/g, \"\").split(\",\");\n let body = split[1];\n\n if (occurences > 1) {\n // we have a function that returns a function\n const index = stringifiedFunction.indexOf(\"=>\");\n body = stringifiedFunction.slice(index + 2, stringifiedFunction.length)\n }\n\n if (body.startsWith(\"{\") === true && body.endsWith(\"}\")) {\n\n // Remove brackets, wrapping function will have them\n builder.appendBody(body.slice(1, body.length - 1));\n\n return {\n builder,\n parameters\n };\n }\n\n builder.appendBody(`return ${body};`);\n return {\n builder,\n parameters\n }\n }\n\n throw new Error(\"Only arrow functions are allowed in the schema definition: function () {} ---> () => {}\");\n }\n}","import { CodeBuilder, ObjectBuilder, SlotBlock } from '../../blocks';\nimport { SlotPath } from '../../SlotPath';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\nexport class EnrichmentNullableObjectHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.type === SchemaTypes.Object && (property.isNullable || property.isOptional)) {\n\n const slotPath = new SlotPath(\"factory\", \"function\", \"enriched\", \"object\", \"enriched\");\n const nestedSlotPath = this.buildEnrichedObjectSlotPath(property, slotPath);\n\n // Generate null check for current level using parent relationships\n const entityPath = property.getSelectrorPath({ parent: \"entity\", assignmentType: \"FORCE_NULLABLE_OR_OPTIONAL\" });\n const enrichedPath = property.getAssignmentPath({ parent: \"enriched\" });\n\n const ifsSlot = builder.get<SlotBlock>(\"factory.function.ifs\");\n\n if (ifsSlot == null) {\n throw new Error(\"Error building enricher, could not find slot for factory.function.ifs\")\n }\n\n\n // Pass the root as parent so nested writes mark the root entity dirty,\n // and the full dotted path so the change is recorded under it\n ifsSlot.if(`${entityPath} != null`).appendBody(`${enrichedPath} = enableChangeTracking(${enrichedPath} || {}, \"${this.getTrackingPath(property)}\", enriched);`);\n\n let enriched = builder.getOrDefault<ObjectBuilder>(nestedSlotPath.get());\n\n if (enriched == null) {\n if (property.parent != null) {\n // Nested object: attach to the parent's ObjectBuilder (registered as\n // `[enriched.<parentPath>]`), never to the root — attaching to the root\n // hoists the subtree to the top level of the literal\n const parentSlotPath = this.buildEnrichedObjectSlotPath(property.parent, slotPath);\n const parentBuilder = builder.get<ObjectBuilder>(parentSlotPath.get());\n enriched = parentBuilder.nested(property.name, `[${enrichedPath}]`);\n } else {\n // Create the enriched result object when this is the first property\n // iterated — handler output cannot depend on schema property order\n let enrichedRoot = builder.getOrDefault<ObjectBuilder>(slotPath.get());\n\n if (enrichedRoot == null) {\n const enrichedSlot = builder.get<SlotBlock>(\"factory.function.enriched\");\n enrichedRoot = enrichedSlot.variable(\"enriched\", { name: \"object\" }).object({ name: \"enriched\" });\n }\n\n enriched = enrichedRoot.nested(property.name, `[${enrichedPath}]`);\n }\n }\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder, ObjectBuilder, SlotBlock } from '../../blocks';\nimport { SlotPath } from '../../SlotPath';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\nexport class EnrichmentObjectHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.type === SchemaTypes.Object && (property.isNullable || property.isOptional) === false) {\n\n const slotPath = new SlotPath(\"factory\", \"function\", \"enriched\", \"object\", \"enriched\");\n const nestedSlotPath = this.buildEnrichedObjectSlotPath(property, slotPath);\n\n // Generate null check for current level using parent relationships\n const enrichedPath = property.getAssignmentPath({ parent: \"enriched\" });\n\n const slot = builder.get<SlotBlock>(\"factory.function.assignment\");\n\n // Pass the root as parent so nested writes mark the root entity dirty,\n // and the full dotted path so the change is recorded under it\n slot.assign(enrichedPath).value(`enableChangeTracking(${enrichedPath} || {}, \"${this.getTrackingPath(property)}\", enriched)`)\n\n let enriched = builder.getOrDefault<ObjectBuilder>(nestedSlotPath.get());\n\n if (enriched == null) {\n if (property.parent != null) {\n // Nested object: attach to the parent's ObjectBuilder (registered as\n // `[enriched.<parentPath>]`), never to the root — attaching to the root\n // hoists the subtree to the top level of the literal\n const parentSlotPath = this.buildEnrichedObjectSlotPath(property.parent, slotPath);\n const parentBuilder = builder.get<ObjectBuilder>(parentSlotPath.get());\n enriched = parentBuilder.nested(property.name, `[${enrichedPath}]`);\n } else {\n // Create the enriched result object when this is the first property\n // iterated — handler output cannot depend on schema property order\n let enrichedRoot = builder.getOrDefault<ObjectBuilder>(slotPath.get());\n\n if (enrichedRoot == null) {\n const enrichedSlot = builder.get<SlotBlock>(\"factory.function.enriched\");\n enrichedRoot = enrichedSlot.variable(\"enriched\", { name: \"object\" }).object({ name: \"enriched\" });\n }\n\n enriched = enrichedRoot.nested(property.name, `[${enrichedPath}]`);\n }\n }\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\nexport class EnrichmentObjectIdentityHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.isIdentity === true && property.type == SchemaTypes.Object) {\n // do nothing right now\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder, SlotBlock } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\nexport class EnrichmentPrimitiveIdentityHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n // Computed identity props are NOT plain identities: the database cannot run the\n // compute function, so they fall through to EnrichmentComputedValueHandler,\n // which computes them once (when absent) over the fully-built entity\n if (property.isIdentity === true && property.type != SchemaTypes.Object && property.type != SchemaTypes.Computed) {\n const selectorPath = property.getSelectrorPath({ parent: \"entity\", assignmentType: \"FORCE_NULLABLE_OR_OPTIONAL\" });\n const slot = builder.get<SlotBlock>(\"factory.function.ifs\");\n const entitySelectorPath = property.getAssignmentPath({ parent: \"entity\" });\n const enrichedAssignmentPath = property.getAssignmentPath({ parent: \"enriched\" });\n\n slot.if(`${selectorPath} != null`).appendBody(`${enrichedAssignmentPath} = ${entitySelectorPath}`);\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo } from \"../../../schema\";\n\nexport class EnrichmentPrimitiveHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n this.setEnrichedProperty(property, builder);\n\n return builder;\n }\n}","import { CodeBuilder, FunctionFactoryBuilder, SlotBlock } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\nexport class EnrichmentFunctionHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.functionBody != null && property.type === SchemaTypes.Function) {\n\n const parameterNames: string[] = [\"enriched\", \"collectionName\"];\n\n if (property.injected != null) {\n\n const factory = builder.get<FunctionFactoryBuilder>(\"factory\");\n const parameter = factory.createParameter(property.injected);\n factory.parameters(parameter);\n\n parameterNames.push(parameter.name);\n }\n\n\n const declarationsSlot = builder.get<SlotBlock>(\"factory.function.declarations\");\n // Unwrap the functions to removing currying\n const defaultFunctionWithParameters = this.toNamedFunction(property.functionBody.toString(), declarationsSlot);\n\n defaultFunctionWithParameters.builder.parameters(...parameterNames.map((w, i) => ({ name: defaultFunctionWithParameters.parameters[i], callName: w })));\n\n const slot = builder.get<SlotBlock>(\"factory.function.assignment\");\n const enrichedAssignmentPath = property.getAssignmentPath({ parent: \"enriched\" });\n\n slot.assign(enrichedAssignmentPath).value(defaultFunctionWithParameters.builder.toCallable());\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder, SlotBlock } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo } from \"../../../schema\";\n\nexport class EnrichmentDefaultValueHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.defaultValue != null && typeof property.defaultValue !== \"function\") {\n\n this.setEnrichedProperty(property, builder);\n\n // Apply the literal default when no value came in, mirroring\n // EnrichmentDefaultFunctionHandler's if-block for function defaults\n const ifsSlot = builder.get<SlotBlock>(\"factory.function.ifs\");\n const checkPath = property.getSelectrorPath({ parent: \"enriched\", assignmentType: \"FORCE_NULLABLE_OR_OPTIONAL\" });\n const assignmentPath = property.getAssignmentPath({ parent: \"enriched\" });\n const ifBlock = ifsSlot.if(`${checkPath} == null`);\n\n // Nested property: ensure every ancestor object exists before the assignment\n if (property.parent != null) {\n const parentPathArray = property.getParentPathArray();\n\n for (let i = 0; i < parentPathArray.length; i++) {\n const pathSoFar = [\"enriched\", ...parentPathArray.slice(0, i + 1)].join(\".\");\n ifBlock.appendBody(`if (${pathSoFar} == null) ${pathSoFar} = {};`);\n }\n }\n\n ifBlock.appendBody(`${assignmentPath} = ${renderDefaultLiteral(property.defaultValue)}`);\n\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}\n\nconst renderDefaultLiteral = (value: unknown) => {\n\n if (value instanceof Date) {\n return `new Date(${value.getTime()})`;\n }\n\n // JSON covers strings (with escaping), numbers, booleans, plain objects and arrays\n return JSON.stringify(value);\n}","import { CodeBuilder, FunctionFactoryBuilder, SlotBlock } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo } from \"../../../schema\";\n\nexport class EnrichmentDefaultFunctionHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.defaultValue != null && typeof property.defaultValue === \"function\") {\n\n this.setEnrichedProperty(property, builder);\n\n // we need to add the call for this function too, want to create an if\n const declarationsSlot = builder.get<SlotBlock>(\"factory.function.declarations\");\n\n if (property.injected != null) {\n\n const factory = builder.get<FunctionFactoryBuilder>(\"factory\");\n\n if (factory == null) {\n throw new Error(\"Error building enricher, could not find slot for factory\")\n }\n\n const parameter = factory.createParameter(property.injected);\n factory.parameters(parameter);\n\n const defaultFunctionWithParameters = this.toNamedFunction(property.defaultValue.toString(), declarationsSlot);\n // This is ok, defaults can only inject one parameter anyways\n defaultFunctionWithParameters.builder.parameters(...defaultFunctionWithParameters.parameters.map(w => ({ name: w, callName: parameter.name })));\n\n\n const ifsSlot = builder.get<SlotBlock>(\"factory.function.ifs\");\n const enrichedAssignmentPath = property.getAssignmentPath({ parent: \"enriched\" });\n ifsSlot.if(`${enrichedAssignmentPath} == null`).appendBody(`${enrichedAssignmentPath} = ${defaultFunctionWithParameters.builder.toCallable()}`);\n\n return builder;\n }\n\n const defaultFunction = this.toNamedFunction(property.defaultValue.toString(), declarationsSlot);\n\n const ifsSlot = builder.get<SlotBlock>(\"factory.function.ifs\");\n const enrichedAssignmentPath = property.getAssignmentPath({ parent: \"enriched\" });\n ifsSlot.if(`${enrichedAssignmentPath} == null`).appendBody(`${enrichedAssignmentPath} = ${defaultFunction.builder.toCallable()}`);\n\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder, FunctionFactoryBuilder, SlotBlock } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\nexport class EnrichmentComputedValueHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.functionBody != null && property.type === SchemaTypes.Computed) {\n\n const parameterNames: string[] = [\"enriched\", \"collectionName\"];\n\n if (property.injected != null) {\n\n const factory = builder.get<FunctionFactoryBuilder>(\"factory\");\n const parameter = factory.createParameter(property.injected);\n factory.parameters(parameter);\n\n parameterNames.push(parameter.name);\n }\n\n const declarationsSlot = builder.get<SlotBlock>(\"factory.function.declarations\");\n const defaultFunctionWithParameters = this.toNamedFunction(property.functionBody.toString(), declarationsSlot);\n\n defaultFunctionWithParameters.builder.parameters(...parameterNames.map((w, i) => ({ name: defaultFunctionWithParameters.parameters[i], callName: w })));\n\n\n // Compute-once semantics for computed keys/identities: an existing value is\n // carried into the enriched literal and never recomputed — a key must stay\n // stable once assigned (content-hash ids would otherwise churn as the\n // entity's shape moves through pipeline stages). Non-key computed props keep\n // recompute-per-enrich behavior: their value is derived presentation data\n if (property.isKey === true || property.isIdentity === true) {\n this.setEnrichedProperty(property, builder);\n }\n\n const ifsSlot = builder.get<SlotBlock>(\"factory.function.ifs\");\n const enrichedAssignmentPath = property.getAssignmentPath({ parent: \"enriched\" });\n ifsSlot.if(`${enrichedAssignmentPath} == null`).appendBody(`${enrichedAssignmentPath} = ${defaultFunctionWithParameters.builder.toCallable()}`);\n\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { SchemaTypes } from \"../types\";\n\n/**\n * Types whose runtime value is a JS array.\n *\n * `Array` and `Vector` are the same thing to every layer that copies, compares, hashes or\n * freezes a value — a vector is a list of numbers and nothing more. They differ only where a\n * backend chooses storage, which is the one place that should ask for `SchemaTypes.Vector` by\n * name.\n *\n * This exists so adding a third array-shaped type is one edit rather than a hunt through\n * twelve handlers. Missing one of those is silent in the worst way: a vector that clones by\n * reference is shared with the change tracker's copy, so overwriting an embedding produces no\n * diff and the save reports nothing to do.\n */\nconst ARRAY_VALUED_TYPES = new Set<SchemaTypes>([\n SchemaTypes.Array,\n SchemaTypes.Vector,\n]);\n\n/** True when the property's value is a JS array and needs value rather than reference semantics. */\nexport const isArrayValued = (type: SchemaTypes) => ARRAY_VALUED_TYPES.has(type);\n\n/**\n * True when the property's elements are primitives, so a spread is a sufficient copy.\n *\n * A vector is always numbers, so it never needs the per-element deep copy an array of objects\n * or dates does.\n */\nconst PRIMITIVE_ELEMENT_TYPES = new Set<SchemaTypes | undefined>([\n SchemaTypes.String,\n SchemaTypes.Number,\n SchemaTypes.Boolean,\n]);\n\nexport const hasPrimitiveElements = (type: SchemaTypes, elementType: SchemaTypes | undefined) =>\n type === SchemaTypes.Vector || PRIMITIVE_ELEMENT_TYPES.has(elementType);\n","import { CodeBuilder, SlotBlock } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { isArrayValued, PropertyInfo } from \"../../../schema\";\n\n/**\n * Arrays participate in change tracking: the array itself is wrapped in the tracking\n * proxy (with the root as parent) so in-place mutations — push/splice/index writes —\n * mark the root entity dirty instead of being silently lost on save.\n */\nexport class EnrichmentArrayHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (isArrayValued(property.type)) {\n\n // Place the property in the enriched literal like any other leaf\n this.setEnrichedProperty(property, builder);\n\n const enrichedPath = property.getAssignmentPath({ parent: \"enriched\" });\n const ifsSlot = builder.get<SlotBlock>(\"factory.function.ifs\");\n\n ifsSlot.if(`${enrichedPath} != null`).appendBody(`${enrichedPath} = enableChangeTracking(${enrichedPath}, \"${this.getTrackingPath(property)}\", enriched);`);\n\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}\n","import { EnrichmentNullableObjectHandler } from \"./enrichment/EnrichmentNullableObjectHandler\";\nimport { EnrichmentObjectHandler } from \"./enrichment/EnrichmentObjectHandler\";\nimport { EnrichmentObjectIdentityHandler } from \"./enrichment/EnrichmentObjectIdentityHandler\";\nimport { EnrichmentPrimitiveIdentityHandler } from \"./enrichment/EnrichmentPrimitiveIdentityHandler\";\nimport { EnrichmentPrimitiveHandler } from './enrichment/EnrichmentPrimitiveHandler';\nimport { EnrichmentFunctionHandler } from './enrichment/EnrichmentFunctionHandler';\nimport { EnrichmentDefaultValueHandler } from './enrichment/EnrichmentDefaultValueHandler';\nimport { EnrichmentDefaultFunctionHandler } from './enrichment/EnrichmentDefaultFunctionHandler';\nimport { EnrichmentComputedValueHandler } from './enrichment/EnrichmentComputedValueHandler';\nimport { EnrichmentArrayHandler } from './enrichment/EnrichmentArrayHandler';\n\n/// Purpose: \nexport class EnrichmentHandlerBuilder {\n\n build() {\n const handler = new EnrichmentPrimitiveIdentityHandler();\n\n handler.setNext(new EnrichmentObjectIdentityHandler())\n .setNext(new EnrichmentObjectHandler())\n .setNext(new EnrichmentNullableObjectHandler())\n .setNext(new EnrichmentFunctionHandler())\n .setNext(new EnrichmentDefaultValueHandler())\n .setNext(new EnrichmentDefaultFunctionHandler())\n .setNext(new EnrichmentComputedValueHandler())\n .setNext(new EnrichmentArrayHandler())\n .setNext(new EnrichmentPrimitiveHandler());\n\n return handler;\n }\n}","import { CodeBuilder, FunctionFactoryBuilder, SlotBlock } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo } from \"../../../schema\";\n\nexport class MergeDefaultFunctionHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n // we only want this to run if the value for the property is null\n // we are changing merge to be more like enrich so we can handle injections\n // we may need to change more. Need to move towards factories\n if (property.defaultValue != null && typeof property.defaultValue === \"function\") {\n const defaultFunctionParameters: string[] = [];\n\n if (property.injected != null) {\n const factory = builder.get<FunctionFactoryBuilder>(\"factory\");\n const parameter = factory.createParameter(property.injected);\n factory.parameters(parameter);\n\n defaultFunctionParameters.push(parameter.name);\n }\n\n // A defaulted property still merges from the source; the default only fills\n // the gap when neither side has a value\n this.emitMergeCopy(property, builder, { onlyWhenChanged: true });\n\n const ifsSlot = builder.get<SlotBlock>(\"factory.function.ifs\");\n // we only want to run if the destination is null; the guarded selector keeps\n // the check from throwing when a destination ancestor is absent\n const selectorPath = property.getSelectrorPath({ parent: \"destination\", assignmentType: \"FORCE_NULLABLE_OR_OPTIONAL\" });\n const assignmentPath = property.getAssignmentPath({ parent: \"destination\" });\n\n const declarationsSlot = builder.get<SlotBlock>(\"factory.function.header\");\n const defaultFunctionWithParameters = this.toNamedFunction(property.defaultValue.toString(), declarationsSlot);\n\n defaultFunctionWithParameters.builder.parameters(...defaultFunctionParameters.map((w, i) => ({ name: defaultFunctionWithParameters.parameters[i], callName: w })));\n\n const defaultIf = ifsSlot.if(`${selectorPath} == null`);\n this.emitDestinationAncestorGuards(property, defaultIf);\n defaultIf.appendBody(`${assignmentPath} = ${defaultFunctionWithParameters.builder.toCallable()}`);\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\n/**\n * Object containers are not merged directly — their child properties merge\n * individually and materialize the destination ancestors they need.\n */\nexport class MergeObjectHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.type === SchemaTypes.Object) {\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}\n","import { CodeBuilder } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\nexport class MergePrimitiveHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.type != SchemaTypes.Object) {\n this.emitMergeCopy(property, builder);\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder, FunctionFactoryBuilder, SlotBlock } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\nexport class MergeComputedValueHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.functionBody != null && property.type === SchemaTypes.Computed) {\n const parameterNames: string[] = [\"source\", \"collectionName\"];\n\n if (property.injected != null) {\n\n const factory = builder.get<FunctionFactoryBuilder>(\"factory\");\n const parameter = factory.createParameter(property.injected);\n factory.parameters(parameter);\n\n parameterNames.push(parameter.name);\n }\n\n const declarationsSlot = builder.get<SlotBlock>(\"factory.function.header\");\n const defaultFunctionWithParameters = this.toNamedFunction(property.functionBody.toString(), declarationsSlot);\n\n defaultFunctionWithParameters.builder.parameters(...parameterNames.map((w, i) => ({ name: defaultFunctionWithParameters.parameters[i], callName: w })));\n\n const slot = builder.get<SlotBlock>(\"factory.function.assignments\");\n const enrichedAssignmentPath = property.getAssignmentPath({ parent: \"destination\" });\n\n // We want to recompute the value always in case there are changes\n slot.assign(enrichedAssignmentPath).value(defaultFunctionWithParameters.builder.toCallable());\n\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder, FunctionFactoryBuilder, SlotBlock } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo } from \"../../../schema\";\n\nexport class MergeDefaultValueHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.defaultValue != null && typeof property.defaultValue !== \"function\") {\n const defaultFunctionParameters: string[] = [];\n\n if (property.injected != null) {\n const factory = builder.get<FunctionFactoryBuilder>(\"factory\");\n const parameter = factory.createParameter(property.injected);\n factory.parameters(parameter);\n\n defaultFunctionParameters.push(parameter.name);\n }\n\n // A defaulted property still merges from the source; the default only fills\n // the gap when neither side has a value\n this.emitMergeCopy(property, builder, { onlyWhenChanged: true });\n\n const ifsSlot = builder.get<SlotBlock>(\"factory.function.ifs\");\n // we only want to run if the destination is null; the guarded selector keeps\n // the check from throwing when a destination ancestor is absent\n const selectorPath = property.getSelectrorPath({ parent: \"destination\", assignmentType: \"FORCE_NULLABLE_OR_OPTIONAL\" });\n const assignmentPath = property.getAssignmentPath({ parent: \"destination\" });\n\n const defaultIf = ifsSlot.if(`${selectorPath} == null`);\n this.emitDestinationAncestorGuards(property, defaultIf);\n defaultIf.appendBody(`${assignmentPath} = ${typeof property.defaultValue === \"string\" ? `\"${property.defaultValue}\"` : property.defaultValue}`);\n\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\nexport class MergeFunctionHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.functionBody != null && property.type === SchemaTypes.Function) {\n\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder, SlotBlock } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { isArrayValued, PropertyInfo } from \"../../../schema\";\n\n/**\n * Merges an array by copying elements INTO the destination's existing array instead of\n * replacing the reference.\n *\n * The reference matters: a change-tracked entity holds its array wrapped in a tracking\n * proxy, and merge runs paused — a plain `destination.values = source.values` discards\n * that proxy silently, so every in-place mutation made after the entity's first save\n * (afterPersist merges the plugin's echo into the canonical) was no longer tracked and\n * vanished on the next save (defect #12). Copying in place keeps the caller's array\n * reference stable and the proxy installed, and shares no reference with the source.\n *\n * When the destination has no array yet there is nothing to preserve, so the source\n * reference is adopted as-is — same as the primitive copy this replaces.\n */\nexport class MergeArrayHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (isArrayValued(property.type)) {\n const selectorPath = property.getSelectrorPath({ parent: \"source\", assignmentType: \"FORCE_NULLABLE_OR_OPTIONAL\" });\n const slot = builder.get<SlotBlock>(\"factory.function.assignments\");\n const sourcePath = property.getAssignmentPath({ parent: \"source\" });\n const destinationPath = property.getAssignmentPath({ parent: \"destination\" });\n\n const ifBlock = slot.if(`${selectorPath} != null`);\n this.emitDestinationAncestorGuards(property, ifBlock);\n\n ifBlock.appendBody(`if (${destinationPath} == null) { ${destinationPath} = ${sourcePath} } else if (${destinationPath} !== ${sourcePath}) { ${destinationPath}.length = 0; for (let i = 0; i < ${sourcePath}.length; i++) { ${destinationPath}[i] = ${sourcePath}[i]; } }`);\n\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}\n","import { MergeDefaultFunctionHandler } from \"./merge/MergeDefaultFunctionHandler\";\nimport { MergeObjectHandler } from \"./merge/MergeObjectHandler\";\nimport { MergePrimitiveHandler } from \"./merge/MergePrimitiveHandler\";\nimport { MergeComputedValueHandler } from \"./merge/MergeComputedValueHandler\";\nimport { MergeDefaultValueHandler } from \"./merge/MergeDefaultValueHandler\";\nimport { MergeFunctionHandler } from \"./merge/MergeFunctionHandler\";\nimport { MergeArrayHandler } from \"./merge/MergeArrayHandler\";\n\n/// Purpose: Should recompute computed properties\nexport class MergeHandlerBuilder {\n\n build() {\n const handler = new MergeDefaultFunctionHandler();\n handler.setNext(new MergeDefaultValueHandler())\n .setNext(new MergeFunctionHandler())\n .setNext(new MergeComputedValueHandler())\n // Before the primitive handler: arrays would otherwise fall through to its\n // reference copy, which discards the destination array's tracking proxy\n .setNext(new MergeArrayHandler())\n .setNext(new MergePrimitiveHandler())\n .setNext(new MergeObjectHandler());\n\n return handler;\n }\n}","import { CodeBuilder, SlotBlock } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo } from \"../../../schema\";\n\nexport class PrepareIdentityHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.isIdentity === true) {\n const selectorPath = property.getSelectrorPath({ parent: \"entity\", assignmentType: \"FORCE_NULLABLE_OR_OPTIONAL\" });\n const slot = builder.get<SlotBlock>(\"assignments\");\n const entitySelectorPath = property.getAssignmentPath({ parent: \"entity\" });\n const enrichedAssignmentPath = property.getAssignmentPath({ parent: \"result\" });\n\n slot.if(`${selectorPath} != null`).appendBody(`${enrichedAssignmentPath} = ${entitySelectorPath}`);\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder, SlotBlock } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo } from \"../../../schema\";\n\nexport class PrepareKeyHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.isKey === true) {\n const selectorPath = property.getSelectrorPath({ parent: \"entity\", assignmentType: \"FORCE_NULLABLE_OR_OPTIONAL\" });\n const slot = builder.get<SlotBlock>(\"assignments\");\n const entitySelectorPath = property.getAssignmentPath({ parent: \"entity\" });\n const enrichedAssignmentPath = property.getAssignmentPath({ parent: \"result\" });\n\n slot.if(`${selectorPath} != null`).appendBody(`${enrichedAssignmentPath} = ${entitySelectorPath}`);\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder, ObjectBuilder, SlotBlock } from '../../blocks';\nimport { SlotPath } from '../../SlotPath';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\nexport class PrepareValueHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.type != SchemaTypes.Object) {\n let objectBuilder = builder.getOrDefault<ObjectBuilder>(\"result.variable.object\");\n const entitySelectorPath = property.getAssignmentPath({ parent: \"entity\" });\n\n if (objectBuilder == null) {\n objectBuilder = builder.get<SlotBlock>(\"result\")\n .assign(\"const result\", { name: \"variable\" })\n .object({ name: \"object\" });\n }\n\n // Remap the property to the name in the database if from is set\n const name = property.from != null ? property.from : property.name;\n\n if (property.parent == null) {\n objectBuilder.property(`${name}: ${entitySelectorPath}`);\n return builder;\n }\n\n const slotPath = new SlotPath(...property.getParentPathArray());\n objectBuilder = objectBuilder.get<ObjectBuilder>(slotPath.get());\n objectBuilder.property(`${name}: ${entitySelectorPath}`);\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder, ObjectBuilder, SlotBlock } from '../../blocks';\nimport { SlotPath } from '../../SlotPath';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\nexport class PrepareObjectHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.type === SchemaTypes.Object) {\n const slotPath = new SlotPath(\"result\", \"variable\", \"object\");\n let objectBuilder = builder.getOrDefault<ObjectBuilder>(slotPath.get());\n\n // There is a chance this is the first property we handle,\n // if that is the case, the main result variable will not be\n // constructed yet\n if (objectBuilder == null) {\n objectBuilder = builder.get<SlotBlock>(\"result\")\n .assign(\"const result\", { name: \"variable\" })\n .object({ name: \"object\" });\n }\n\n // Prepare emits the storage shape — renamed object containers keep\n // their `from` (storage) key; the block name stays the property name\n // so child lookups by name still resolve\n if (property.parent == null) {\n objectBuilder.nested(property.getResolvedName(), property.name)\n\n return builder;\n }\n\n slotPath.push(...property.getParentPathArray());\n const nestedObjectBuilder = builder.get<ObjectBuilder>(slotPath.get());\n nestedObjectBuilder.nested(property.getResolvedName(), property.name)\n\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\n// Do nothing with the value\nexport class PrepareComputedValueHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.functionBody != null && property.type === SchemaTypes.Computed && property.isUnmapped === true) {\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\nexport class PrepareFunctionHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.functionBody != null && property.type === SchemaTypes.Function) {\n // Functions are always unmapped\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { PrepareIdentityHandler } from \"./prepare/PrepareIdentityHandler\";\nimport { PrepareKeyHandler } from \"./prepare/PrepareKeyHandler\";\nimport { PrepareValueHandler } from \"./prepare/PrepareValueHandler\";\nimport { PrepareObjectHandler } from \"./prepare/PrepareObjectHandler\";\nimport { PrepareComputedValueHandler } from \"./prepare/PrepareComputedValueHandler\";\nimport { PrepareFunctionHandler } from \"./prepare/PrepareFunctionHandler\";\n\n/// Purpose: Called before we save entities to the database. Responsible for cleaning up\n/// an entity before it is sent to the plugin\nexport class PrepareHandlerBuilder {\n\n build() {\n const handler = new PrepareIdentityHandler();\n handler\n .setNext(new PrepareFunctionHandler())\n .setNext(new PrepareComputedValueHandler())\n .setNext(new PrepareKeyHandler())\n .setNext(new PrepareObjectHandler())\n .setNext(new PrepareValueHandler());\n\n return handler;\n }\n}","import { CodeBuilder, ObjectBuilder, SlotBlock } from '../../blocks';\nimport { SlotPath } from '../../SlotPath';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\nexport class StripObjectHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.type === SchemaTypes.Object) {\n const slotPath = new SlotPath(\"result.variable.object\");\n let objectBuilder = builder.getOrDefault<ObjectBuilder>(slotPath.get());\n\n if (objectBuilder == null) {\n objectBuilder = builder.get<SlotBlock>(\"result\")\n .assign(\"const result\", { name: \"variable\" })\n .object({ name: \"object\" });\n }\n\n if (property.parent == null) {\n objectBuilder.nested(property.name, property.name)\n\n return builder;\n }\n\n slotPath.push(...property.getParentPathArray());\n const nestedObjectBuilder = builder.get<ObjectBuilder>(slotPath.get());\n nestedObjectBuilder.nested(property.name, property.name)\n\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { PropertyInfo, SchemaTypes } from \"../../../schema\";\nimport { PropertyInfoHandler } from \"../types\";\nimport { CodeBuilder, ObjectBuilder, SlotBlock } from '../../blocks';\nimport { SlotPath } from '../../SlotPath';\n\nexport class StripValueHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.type != SchemaTypes.Object) {\n let objectBuilder = builder.getOrDefault<ObjectBuilder>(\"result.variable.object\");\n const entitySelectorPath = property.getAssignmentPath({ parent: \"entity\" });\n\n // There is a chance this is the first property we handle,\n // if that is the case, the main result variable will not be\n // constructed yet\n if (objectBuilder == null) {\n objectBuilder = builder.get<SlotBlock>(\"result\")\n .assign(\"const result\", { name: \"variable\" })\n .object({ name: \"object\" });\n }\n\n if (property.parent == null) {\n objectBuilder.property(`${property.name}: ${entitySelectorPath}`);\n return builder;\n }\n\n const slotPath = new SlotPath(...property.getParentPathArray());\n objectBuilder = objectBuilder.get<ObjectBuilder>(slotPath.get());\n objectBuilder.property(`${property.name}: ${entitySelectorPath}`);\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo } from \"../../../schema\";\n\nexport class StripKeyHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.isKey === true) {\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo } from \"../../../schema\";\n\nexport class StripIdentityHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.isIdentity === true) {\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\n/**\n * Functions never persist — strip removes them along with keys and identities.\n */\nexport class StripFunctionHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.type === SchemaTypes.Function) {\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}\n","import { CodeBuilder } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\n/**\n * Unmapped computed properties never persist — strip removes them along with\n * keys and identities.\n */\nexport class StripComputedHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.type === SchemaTypes.Computed && property.isUnmapped === true) {\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}\n","import { StripObjectHandler } from \"./strip/StripObjectHandler\";\nimport { StripValueHandler } from \"./strip/StripValueHandler\";\nimport { StripKeyHandler } from \"./strip/StripKeyHandler\";\nimport { StripIdentityHandler } from \"./strip/StripIdentityHandler\";\nimport { StripFunctionHandler } from \"./strip/StripFunctionHandler\";\nimport { StripComputedHandler } from \"./strip/StripComputedHandler\";\n\n/// Purpose: builds the strip function, which returns an entity without its\n/// keys, identities, and unmapped properties\nexport class StripHandlerBuilder {\n\n build() {\n const handler = new StripIdentityHandler();\n\n handler.setNext(new StripKeyHandler())\n .setNext(new StripFunctionHandler())\n .setNext(new StripComputedHandler())\n .setNext(new StripObjectHandler())\n .setNext(new StripValueHandler());\n\n return handler;\n }\n}","import { CodeBuilder, SlotBlock } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { hasPrimitiveElements, isArrayValued, PropertyInfo, SchemaTypes } from \"../../../schema\";\n\nexport class CloneArrayHandler extends PropertyInfoHandler {\n\n /** See `CloneValueHandler`. */\n constructor(private readonly useFromPropertyName: boolean = false) {\n super();\n }\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (isArrayValued(property.type)) {\n\n // Arrays are leaf properties — they have no child PropertyInfos, so the\n // copy must happen here for every array, including nullable/optional ones.\n // The `!== undefined` guard below covers absent values; an explicit null is copied as\n // null (see CloneValueHandler and known-defects #66), which is why every copy\n // expression is wrapped rather than applied directly — `[...null]` throws.\n const useFromPropertyName = this.useFromPropertyName;\n const entitySelectorPath = property.getSelectrorPath({ parent: \"entity\", useFromPropertyName });\n\n const slot = builder.get<SlotBlock>(\"if\");\n const resultAssignmentPath = property.getAssignmentPath({ parent: \"result\", useFromPropertyName });\n\n // Primitive elements copy with a spread; anything that can hold nested\n // references (objects, dates, nested arrays) needs a deep copy or the\n // clone shares element references with the source. Dates get an explicit\n // per-element copy rather than structuredClone: structuredClone can return\n // Dates from a foreign realm (e.g. under jest), which fail `instanceof Date`.\n // Deep copies go per ELEMENT, never structuredClone on the array itself: a\n // change-tracked entity's array is wrapped in a Proxy (and stays wrapped\n // across merges), and a Proxy cannot pass a structured-clone boundary.\n const elementType = property.innerSchema?.type;\n let copyExpression: string;\n if (hasPrimitiveElements(property.type, elementType)) {\n copyExpression = `[...${entitySelectorPath}]`;\n } else if (elementType === SchemaTypes.Date) {\n copyExpression = `${entitySelectorPath}.map(function (v) { return v == null ? v : new Date(v); })`;\n } else {\n copyExpression = `${entitySelectorPath}.map(function (v) { return v == null ? v : structuredClone(v); })`;\n }\n\n // A null array is still a null, not an empty one, and neither spread nor map survives it\n const nullSafeCopy = `${entitySelectorPath} === null ? null : ${copyExpression}`;\n\n if (property.parent == null) {\n slot.if(`${entitySelectorPath} !== undefined`).appendBody(`${resultAssignmentPath} = ${nullSafeCopy}`);\n return builder;\n }\n\n // Nested array: ensure parent exists, then assign the copy (same pattern as CloneValueHandler)\n const parentPathArray = property.getParentPathArray({ useFromPropertyName });\n const ifSlot = slot.if(`${entitySelectorPath} !== undefined`);\n\n for (let i = 0; i < parentPathArray.length; i++) {\n const pathSoFar = [\"result\", ...parentPathArray.slice(0, i + 1)].join(\".\");\n ifSlot.appendBody(`if (${pathSoFar} == null) ${pathSoFar} = {};`);\n }\n ifSlot.appendBody(`${resultAssignmentPath} = ${nullSafeCopy};`);\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder, SlotBlock } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\n/**\n * Copies Date properties by value. A reference copy would let a mutation of the\n * clone's Date (e.g. setHours) silently change the source entity.\n */\n// See CloneValueHandler for why the guard is `!== undefined` (known-defects #66).\nexport class CloneDateHandler extends PropertyInfoHandler {\n\n /** See `CloneValueHandler`. */\n constructor(private readonly useFromPropertyName: boolean = false) {\n super();\n }\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.type === SchemaTypes.Date) {\n const slot = builder.get<SlotBlock>(\"if\");\n const useFromPropertyName = this.useFromPropertyName;\n const entitySelectorPath = property.getSelectrorPath({ parent: \"entity\", useFromPropertyName });\n const resultAssignmentPath = property.getAssignmentPath({ parent: \"result\", useFromPropertyName });\n\n // Stored values can still be serialized strings; only wrap real Dates. A null falls\n // through this expression unchanged, which is what the `!== undefined` guard wants.\n const copyExpression = `${entitySelectorPath} instanceof Date ? new Date(${entitySelectorPath}.getTime()) : ${entitySelectorPath}`;\n\n if (property.parent == null) {\n slot.if(`${entitySelectorPath} !== undefined`).appendBody(`${resultAssignmentPath} = ${copyExpression}`);\n return builder;\n }\n\n // Nested property: ensure every ancestor object exists, then assign (same pattern as CloneValueHandler)\n const parentPathArray = property.getParentPathArray({ useFromPropertyName });\n const ifSlot = slot.if(`${entitySelectorPath} !== undefined`);\n\n for (let i = 0; i < parentPathArray.length; i++) {\n const pathSoFar = [\"result\", ...parentPathArray.slice(0, i + 1)].join(\".\");\n ifSlot.appendBody(`if (${pathSoFar} == null) ${pathSoFar} = {};`);\n }\n ifSlot.appendBody(`${resultAssignmentPath} = ${copyExpression};`);\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}\n","import { CodeBuilder } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\nexport class CloneObjectHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.type === SchemaTypes.Object) {\n\n // Child properties will take care of this\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder, SlotBlock } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { isArrayValued, PropertyInfo, SchemaTypes } from \"../../../schema\";\n\n/**\n * `!== undefined`, not `!= null`.\n *\n * An explicit `null` is a VALUE and has to survive the copy; an absent or `undefined` property is\n * not there and must not be invented. The loose guard conflated the two and dropped every null,\n * which is how a `s.string().nullable()` written as `null` came back as `undefined` from the\n * memory family — see known-defects #66. It was invisible for a long time because the change\n * tracker merges a read into the canonical entity the caller still holds, so the null appeared to\n * survive right up until something read storage without one (a join).\n */\nexport class CloneValueHandler extends PropertyInfoHandler {\n\n /**\n * When true, emit reads and writes under the STORAGE name (`from`) instead of the\n * in-memory name. See `CloneHandlerBuilder.build`.\n */\n constructor(private readonly useFromPropertyName: boolean = false) {\n super();\n }\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n // Anything that copies by assignment. An array-valued property must not land here:\n // assigning the reference shares it with the source, which is the whole point of\n // CloneArrayHandler.\n if (property.type != SchemaTypes.Object && isArrayValued(property.type) === false) {\n const slot = builder.get<SlotBlock>(\"if\");\n const useFromPropertyName = this.useFromPropertyName;\n const entitySelectorPath = property.getSelectrorPath({ parent: \"entity\", useFromPropertyName });\n const resultAssignmentPath = property.getAssignmentPath({ parent: \"result\", useFromPropertyName });\n\n if (property.parent == null) {\n // we are a first level property\n slot.if(`${entitySelectorPath} !== undefined`).appendBody(`${resultAssignmentPath} = ${entitySelectorPath}`);\n return builder;\n }\n\n // Nested property: ensure every ancestor object exists, then assign (handles depth > 2)\n const parentPathArray = property.getParentPathArray({ useFromPropertyName });\n const ifSlot = slot.if(`${entitySelectorPath} !== undefined`);\n\n for (let i = 0; i < parentPathArray.length; i++) {\n const pathSoFar = [\"result\", ...parentPathArray.slice(0, i + 1)].join(\".\");\n ifSlot.appendBody(`if (${pathSoFar} == null) ${pathSoFar} = {};`);\n }\n ifSlot.appendBody(`${resultAssignmentPath} = ${entitySelectorPath}`);\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CloneArrayHandler } from \"./clone/CloneArrayHandler\";\nimport { CloneDateHandler } from \"./clone/CloneDateHandler\";\nimport { CloneObjectHandler } from \"./clone/CloneObjectHandler\";\nimport { CloneValueHandler } from \"./clone/CloneValueHandler\";\n\n/// Purpose: builds the handler chain for the generated clone function, which\n/// deep-copies an entity so callers can never mutate stored data by reference\nexport class CloneHandlerBuilder {\n\n /**\n * @param useFromPropertyName Emit the STORAGE shape rather than the in-memory shape.\n *\n * A record that has not been read back into memory yet still carries its `from` names, so a\n * cloner generated from in-memory names would read `undefined` for every renamed property and\n * silently drop it. Passing true swaps both the reads and the writes to the storage name, which\n * gives a copier for records in that shape. Everything else about the chain is identical —\n * the same handlers, in the same order, with the same null and Date semantics.\n */\n build(useFromPropertyName: boolean = false) {\n const handler = new CloneObjectHandler();\n handler\n .setNext(new CloneDateHandler(useFromPropertyName))\n .setNext(new CloneValueHandler(useFromPropertyName))\n .setNext(new CloneArrayHandler(useFromPropertyName));\n\n return handler;\n }\n}\n","import { AndBuilder, CodeBuilder, SlotBlock } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { isArrayValued, PropertyInfo } from \"../../../schema\";\n\nexport class CompareArrayHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (isArrayValued(property.type)) {\n let compare = builder.getOrDefault<AndBuilder>(\"result.variable.compare\");\n const leftCompare = property.getSelectrorPath({ parent: \"a\" });\n const rightCompare = property.getSelectrorPath({ parent: \"b\" });\n\n if (compare == null) {\n compare = builder.get<SlotBlock>(\"result\")\n .assign(\"const result\", { name: \"variable\" })\n // Named \"compare\" so every compare handler finds the same block\n // regardless of which property type is iterated first\n .and(`JSON.stringify(${leftCompare}) === JSON.stringify(${rightCompare})`, { name: \"compare\" });\n return builder;\n }\n\n compare.and(`JSON.stringify(${leftCompare}) === JSON.stringify(${rightCompare})`);\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\n/**\n * Unmapped computed properties are excluded from comparison — they derive from\n * other properties, which are compared directly.\n */\nexport class CompareComputedHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.type === SchemaTypes.Computed && property.isUnmapped === true) {\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}\n","import { AndBuilder, CodeBuilder, SlotBlock } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\nexport class CompareDateHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.type === SchemaTypes.Date) {\n let compare = builder.getOrDefault<AndBuilder>(\"result.variable.compare\");\n const leftCompare = property.getSelectrorPath({ parent: \"a\" });\n const rightCompare = property.getSelectrorPath({ parent: \"b\" });\n\n if (compare == null) {\n compare = builder.get<SlotBlock>(\"result\")\n .assign(\"const result\", { name: \"variable\" })\n // Named \"compare\" so every compare handler finds the same block\n // regardless of which property type is iterated first\n .and(`${leftCompare}?.toISOString() === ${rightCompare}?.toISOString()`, { name: \"compare\" });\n return builder;\n }\n\n compare.and(`${leftCompare}?.toISOString() === ${rightCompare}?.toISOString()`);\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\n/**\n * Functions are excluded from comparison — enrichment assigns a fresh closure\n * per entity, so a reference comparison would report every pair as different.\n */\nexport class CompareFunctionHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.type === SchemaTypes.Function) {\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}\n","import { CodeBuilder } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\nexport class CompareObjectHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.type === SchemaTypes.Object) {\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { AndBuilder, CodeBuilder, SlotBlock } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\nexport class CompareValueHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.type != SchemaTypes.Object) {\n let compare = builder.getOrDefault<AndBuilder>(\"result.variable.compare\");\n const leftCompare = property.getSelectrorPath({ parent: \"a\" });\n const rightCompare = property.getSelectrorPath({ parent: \"b\" });\n\n if (compare == null) {\n compare = builder.get<SlotBlock>(\"result\")\n .assign(\"const result\", { name: \"variable\" })\n .and(`${leftCompare} === ${rightCompare}`, { name: \"compare\" });\n return builder;\n }\n\n compare.and(`${leftCompare} === ${rightCompare}`);\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CompareArrayHandler } from \"./compare/CompareArrayHandler\";\nimport { CompareComputedHandler } from \"./compare/CompareComputedHandler\";\nimport { CompareDateHandler } from \"./compare/CompareDateHandler\";\nimport { CompareFunctionHandler } from \"./compare/CompareFunctionHandler\";\nimport { CompareObjectHandler } from \"./compare/CompareObjectHandler\";\nimport { CompareValueHandler } from \"./compare/CompareValueHandler\";\n\nexport class CompareHandlerBuilder {\n\n build() {\n const handler = new CompareObjectHandler();\n handler.setNext(new CompareFunctionHandler())\n .setNext(new CompareComputedHandler())\n .setNext(new CompareArrayHandler())\n .setNext(new CompareDateHandler())\n .setNext(new CompareValueHandler());\n\n return handler;\n }\n}","import { CodeBuilder, ObjectBuilder, SlotBlock } from '../../blocks';\nimport { SlotPath } from '../../SlotPath';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\nexport class DeserializeObjectHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.type === SchemaTypes.Object) {\n const slotPath = new SlotPath(\"result.variable.object\");\n\n // Create the result object when this is the first property iterated —\n // handler output cannot depend on schema property order\n let objectBuilder = builder.getOrDefault<ObjectBuilder>(slotPath.get());\n\n if (objectBuilder == null) {\n objectBuilder = builder.get<SlotBlock>(\"result\")\n .assign(\"const entity\", { name: \"variable\" })\n .object({ name: \"object\" });\n }\n\n // The output entity is the in-memory shape — its keys are property\n // names; `from` names only appear on the unserialized (read) side\n if (property.parent == null) {\n objectBuilder.nested(property.name, property.name)\n\n return builder;\n }\n\n slotPath.push(...property.getParentPathArray());\n const nestedObjectBuilder = builder.get<ObjectBuilder>(slotPath.get());\n nestedObjectBuilder.nested(property.name, property.name)\n\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder, ObjectBuilder, SlotBlock } from '../../blocks';\nimport { SlotPath } from '../../SlotPath';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\nexport class DeserializeValueHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.type != SchemaTypes.Object && property.type != SchemaTypes.Date) {\n let objectBuilder = builder.getOrDefault<ObjectBuilder>(\"result.variable.object\");\n // Deserialize maps storage shape -> in-memory shape: read the incoming\n // record by `from` (storage) name; the selector path adds `?.` so\n // absent nullable parents read as undefined instead of throwing\n const entitySelectorPath = property.getSelectrorPath({ parent: \"unserialized\", useFromPropertyName: true });\n\n if (objectBuilder == null) {\n objectBuilder = builder.get<SlotBlock>(\"result\")\n .assign(\"const entity\", { name: \"variable\" })\n .object({ name: \"object\" });\n }\n\n if (property.parent == null) {\n objectBuilder.property(`${property.name}: ${entitySelectorPath}`);\n return builder;\n }\n\n const slotPath = new SlotPath(...property.getParentPathArray());\n objectBuilder = objectBuilder.get<ObjectBuilder>(slotPath.get());\n objectBuilder.property(`${property.name}: ${entitySelectorPath}`);\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder, ContainerBlock, ObjectBuilder, SlotBlock } from '../../blocks';\nimport { SlotPath } from '../../SlotPath';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\n/**\n * Handles converting a string value from a database to a Date value\n */\nexport class DeserializeDateHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.type === SchemaTypes.Date) {\n const slotPath = new SlotPath(\"result.variable.object\");\n\n // Create the result object when this is the first property iterated —\n // handler output cannot depend on schema property order\n let objectBuilder = builder.getOrDefault<ObjectBuilder>(slotPath.get());\n\n if (objectBuilder == null) {\n objectBuilder = builder.get<SlotBlock>(\"result\")\n .assign(\"const entity\", { name: \"variable\" })\n .object({ name: \"object\" });\n }\n // Deserialize maps storage shape -> in-memory shape: read the incoming\n // record by `from` (storage) name, write the entity by property name\n const entitySelectorPath = property.getSelectrorPath({ parent: \"unserialized\", useFromPropertyName: true });\n const entityAssignmentPath = property.getAssignmentPath({ parent: \"entity\" });\n const assignment = `${property.name}: typeof ${entitySelectorPath} === \"string\" ? new Date(${entitySelectorPath}) : ${entitySelectorPath}`;\n\n // if it is nullable or optional, assign in an if block, otherwise we\n // could unintentionally assign a property that does not exist. An explicit null IS\n // assigned — a stored null is a value, and dropping it is known-defects #66. The\n // expression passes null through, since null is not a string.\n if (property.isOptional || property.isNullable) {\n const ifAssignment = `${entityAssignmentPath} = typeof ${entitySelectorPath} === \"string\" ? new Date(${entitySelectorPath}) : ${entitySelectorPath}`;\n const rootPath = new SlotPath(\"if\");\n builder.get<ContainerBlock>(rootPath.get()).if(`${entitySelectorPath} !== undefined`).appendBody(ifAssignment);\n return builder;\n }\n\n // A date cannot be a nested object, just do the assignment\n if (property.parent == null) {\n objectBuilder.property(assignment);\n\n return builder;\n }\n\n slotPath.push(...property.getParentPathArray());\n const nestedObjectBuilder = builder.get<ObjectBuilder>(slotPath.get());\n nestedObjectBuilder.property(assignment)\n\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\nexport class DeserializeComputedValueHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n // Do nothing with the value\n if (property.functionBody != null && property.type === SchemaTypes.Computed && property.isUnmapped === true) {\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\nexport class DeserializeFunctionHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.functionBody != null && property.type === SchemaTypes.Function) {\n // Functions are always unmapped\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder, ObjectBuilder, SlotBlock } from '../../blocks';\nimport { SlotPath } from '../../SlotPath';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo } from \"../../../schema\";\n\nexport class DeserializeDeserializerHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.valueDeserializer != null) {\n let objectBuilder = builder.getOrDefault<ObjectBuilder>(\"result.variable.object\");\n const assignmentBuilder = builder.getOrDefault<SlotBlock>(\"functions\");\n // Read the incoming record by `from` (storage) name\n const entitySelectorPath = property.getSelectrorPath({ parent: \"unserialized\", useFromPropertyName: true });\n\n if (objectBuilder == null) {\n objectBuilder = builder.get<SlotBlock>(\"result\")\n .assign(\"const entity\", { name: \"variable\" })\n .object({ name: \"object\" });\n }\n\n const defaultFunctionWithParameters = this.toNamedFunction(property.valueDeserializer.toString(), assignmentBuilder);\n defaultFunctionWithParameters.builder.parameters(...defaultFunctionWithParameters.parameters.map((_, i) => ({ name: defaultFunctionWithParameters.parameters[i], callName: entitySelectorPath })));\n\n if (property.parent == null) {\n objectBuilder.property(`${property.name}: ${defaultFunctionWithParameters.builder.toCallable()}`);\n return builder;\n }\n\n const slotPath = new SlotPath(...property.getParentPathArray());\n objectBuilder = objectBuilder.get<ObjectBuilder>(slotPath.get());\n objectBuilder.property(`${property.name}: ${defaultFunctionWithParameters.builder.toCallable()}`);\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder, ContainerBlock, ObjectBuilder, SlotBlock } from '../../blocks';\nimport { SlotPath } from '../../SlotPath';\nimport { PropertyInfoHandler } from \"../types\";\nimport { isArrayValued, PropertyInfo, SchemaTypes } from \"../../../schema\";\n\n/**\n * Deserializes arrays per element instead of copying the reference:\n *\n * - Date elements are revived from strings (same convention as DeserializeDateHandler).\n * - Everything else is copied with a spread, so the entity shares no references with\n * the storage record.\n */\nexport class DeserializeArrayHandler extends PropertyInfoHandler {\n\n private copyExpression(property: PropertyInfo<any>, selector: string): string {\n const elementType = property.innerSchema?.type;\n\n if (elementType === SchemaTypes.Date) {\n return `${selector}.map(function (v) { return typeof v === \"string\" ? new Date(v) : v; })`;\n }\n\n return `[...${selector}]`;\n }\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (isArrayValued(property.type)) {\n const slotPath = new SlotPath(\"result.variable.object\");\n\n // Create the result object when this is the first property iterated —\n // handler output cannot depend on schema property order\n let objectBuilder = builder.getOrDefault<ObjectBuilder>(slotPath.get());\n\n if (objectBuilder == null) {\n objectBuilder = builder.get<SlotBlock>(\"result\")\n .assign(\"const entity\", { name: \"variable\" })\n .object({ name: \"object\" });\n }\n\n // Deserialize maps storage shape -> in-memory shape: read the incoming\n // record by `from` (storage) name, write the entity by property name\n const entitySelectorPath = property.getSelectrorPath({ parent: \"unserialized\", useFromPropertyName: true });\n const entityAssignmentPath = property.getAssignmentPath({ parent: \"entity\" });\n const valueExpression = `${entitySelectorPath} == null ? ${entitySelectorPath} : ${this.copyExpression(property, entitySelectorPath)}`;\n\n // if it is nullable or optional, assign in an if block, otherwise we\n // could unintentionally assign a property that does not exist. An explicit null IS\n // assigned — a stored null is a value, and dropping it is known-defects #66.\n // `valueExpression` rather than the bare copy: neither a spread nor a map survives a\n // null, so the copy has to stay behind its own null check.\n if (property.isOptional || property.isNullable) {\n const rootPath = new SlotPath(\"if\");\n builder.get<ContainerBlock>(rootPath.get()).if(`${entitySelectorPath} !== undefined`).appendBody(`${entityAssignmentPath} = ${valueExpression}`);\n return builder;\n }\n\n if (property.parent == null) {\n objectBuilder.property(`${property.name}: ${valueExpression}`);\n return builder;\n }\n\n const nestedSlotPath = new SlotPath(...property.getParentPathArray());\n const nestedObjectBuilder = objectBuilder.get<ObjectBuilder>(nestedSlotPath.get());\n nestedObjectBuilder.property(`${property.name}: ${valueExpression}`);\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}\n","import { DeserializeObjectHandler } from \"./deserialize/DeserializeObjectHandler\";\nimport { DeserializeValueHandler } from \"./deserialize/DeserializeValueHandler\";\nimport { DeserializeDateHandler } from \"./deserialize/DeserializeDateHandler\";\nimport { DeserializeComputedValueHandler } from \"./deserialize/DeserializeComputedValueHandler\";\nimport { DeserializeFunctionHandler } from \"./deserialize/DeserializeFunctionHandler\";\nimport { DeserializeDeserializerHandler } from \"./deserialize/DeserializeDeserializerHandler\";\nimport { DeserializeArrayHandler } from \"./deserialize/DeserializeArrayHandler\";\n\n/// Purpose:\nexport class DeserializeHandlerBuilder {\n\n build() {\n const handler = new DeserializeObjectHandler();\n handler\n .setNext(new DeserializeDeserializerHandler())\n .setNext(new DeserializeComputedValueHandler())\n .setNext(new DeserializeFunctionHandler())\n .setNext(new DeserializeArrayHandler())\n .setNext(new DeserializeValueHandler())\n .setNext(new DeserializeDateHandler());\n\n return handler;\n }\n}","import { CodeBuilder, SlotBlock } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo } from \"../../../schema\";\n\nexport class HashTypeValueHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.isKey && property.isIdentity) {\n const slot = builder.get<SlotBlock>(\"ifs\");\n const entitySelectorPath = property.getSelectrorPath({ parent: \"entity\" });\n\n slot.if(`${entitySelectorPath} == null`).appendBody(`return \"Object\"`);\n\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { NotApplicableHandler } from \"./types\";\nimport { HashTypeValueHandler } from \"./hashType/HashTypeValueHandler\";\n\n/// Purpose: \nexport class HashTypeHandlerBuilder {\n\n build() {\n const handler = new HashTypeValueHandler();\n\n handler.setNext(new NotApplicableHandler());\n\n return handler;\n }\n}","import { ArrayBuilder, CodeBuilder, SlotBlock } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo } from \"../../../schema\";\n\nexport class IdSelectorValueHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.isKey) {\n let arrayBuilder = builder.getOrDefault<ArrayBuilder>(\"result.variable.array\");\n const entitySelectorPath = property.getAssignmentPath({ parent: \"entity\" });\n\n if (arrayBuilder == null) {\n arrayBuilder = builder.get<SlotBlock>(\"result\")\n .variable(\"result\", { name: \"variable\" })\n .array(`${entitySelectorPath}`, { name: \"array\" });\n\n return builder;\n }\n\n\n arrayBuilder.append(`${entitySelectorPath}`);\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { NotApplicableHandler } from \"./types\";\nimport { IdSelectorValueHandler } from \"./idSelector/IdSelectorValueHandler\";\n/// Purpose: \nexport class IdSelectorHandlerBuilder {\n\n build() {\n const handler = new IdSelectorValueHandler();\n\n handler.setNext(new NotApplicableHandler());\n\n return handler;\n }\n}","import { CodeBuilder, SlotBlock, StringBuilder } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo } from \"../../../schema\";\n\nexport class HashKeyHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.isKey === true) {\n let stringBuilder = builder.getOrDefault<StringBuilder>(\"hash-id-if.if-body.variable.string\");\n const entitySelectorPath = property.getSelectrorPath({ parent: \"entity\" });\n\n if (stringBuilder == null) {\n stringBuilder = builder.get<SlotBlock>(\"hash-id-if.if-body\")\n .assign(\"const result\", { name: \"variable\" })\n .string(\"template\", { name: \"string\" });\n }\n\n stringBuilder.append(\"${\" + entitySelectorPath + \"}\")\n\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder, SlotBlock, StringBuilder } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\nexport class HashValueHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.type !== SchemaTypes.Object) {\n let stringBuilder = builder.getOrDefault<StringBuilder>(\"hash-object-return.variable.string\");\n const entitySelectorPath = property.getSelectrorPath({ parent: \"entity\" });\n\n if (stringBuilder == null) {\n stringBuilder = builder.get<SlotBlock>(\"hash-object-return\")\n .assign(\"const result\", { name: \"variable\" })\n .string(\"template\", { name: \"string\" });\n }\n\n stringBuilder.append(\"${\" + entitySelectorPath + \"}\")\n\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder, SlotBlock, StringBuilder } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\nexport class HashDateHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.type === SchemaTypes.Date) {\n let stringBuilder = builder.getOrDefault<StringBuilder>(\"hash-object-return.variable.string\");\n const entitySelectorPath = property.getSelectrorPath({ parent: \"entity\" });\n\n if (stringBuilder == null) {\n stringBuilder = builder.get<SlotBlock>(\"hash-object-return\")\n .assign(\"const result\", { name: \"variable\" })\n .string(\"template\", { name: \"string\" });\n }\n\n stringBuilder.append(\"${stringifyDate(\" + entitySelectorPath + \")}\")\n\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo } from \"../../../schema\";\n\nexport class HashIdentityHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.isIdentity === true) {\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\nexport class HashFunctionHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.functionBody != null && property.type === SchemaTypes.Function) {\n // Functions are always unmapped\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\nexport class HashComputedValueHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.functionBody != null && property.type === SchemaTypes.Computed && property.isUnmapped === true) {\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder, SlotBlock, StringBuilder } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { isArrayValued, PropertyInfo } from \"../../../schema\";\n\n/**\n * Hashes array contents via JSON — template interpolation of an array of\n * objects would collapse every value to \"[object Object]\" and collide.\n */\nexport class HashArrayHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (isArrayValued(property.type)) {\n let stringBuilder = builder.getOrDefault<StringBuilder>(\"hash-object-return.variable.string\");\n const entitySelectorPath = property.getSelectrorPath({ parent: \"entity\" });\n\n if (stringBuilder == null) {\n stringBuilder = builder.get<SlotBlock>(\"hash-object-return\")\n .assign(\"const result\", { name: \"variable\" })\n .string(\"template\", { name: \"string\" });\n }\n\n stringBuilder.append(\"${JSON.stringify(\" + entitySelectorPath + \")}\")\n\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}\n","import { CodeBuilder } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\n/**\n * Object containers are not hashed directly — their child properties hash\n * individually, which keeps the hash stable across key insertion order.\n */\nexport class HashObjectHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.type === SchemaTypes.Object) {\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}\n","import { CodeBuilder, SlotBlock, StringBuilder } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\n/**\n * A file takes no part in the hash that correlates an addition with what came back.\n *\n * The hash exists to match a submitted entity against the row the database echoed, which is\n * why identity values are already excluded: the database assigns them, so they differ on the\n * two sides by design.\n *\n * A file is the same situation one step out. What is submitted is content; what is stored, and\n * echoed, is a reference. Hashing the VALUE produced two different hashes for the same\n * addition and the change tracker reported \"Cannot find internal addition\" on every save with\n * a file.\n *\n * It contributes a constant rather than nothing at all. The `result` string is created by\n * whichever handler runs first, so a schema whose only non-identity properties are files —\n * an assets row holding an original and a thumbnail, say — would emit no declaration and then\n * return it: `ReferenceError: result is not defined` at the first add. A constant keeps the\n * hash stable across the content-to-reference swap while still declaring the variable.\n */\nexport class HashFileHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.type === SchemaTypes.File) {\n let stringBuilder = builder.getOrDefault<StringBuilder>(\"hash-object-return.variable.string\");\n\n if (stringBuilder == null) {\n stringBuilder = builder.get<SlotBlock>(\"hash-object-return\")\n .assign(\"const result\", { name: \"variable\" })\n .string(\"template\", { name: \"string\" });\n }\n\n // The property's NAME, not its value: stable on both sides of the swap, and still\n // distinct from a schema that does not have this file at all.\n stringBuilder.append(`file:${property.name}`);\n\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}\n","import { CodeBuilder, SlotBlock, StringBuilder } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo } from \"../../../schema\";\n\n/**\n * A transformed property takes no part in the hash that correlates an addition with its echo.\n *\n * The hash matches a submitted entity against the row the database echoed, which is why\n * identity values are already excluded: the database assigns them, so the two sides differ by\n * design.\n *\n * A transform is the same situation. What is submitted is the application value and what is\n * stored is the transformed one, and a ONE-WAY transform — no `from` — never converts back, so\n * the echo legitimately differs and every save reported \"Cannot find internal addition\". A\n * two-way transform happens to restore the value before the comparison, but relying on that\n * would make correlation depend on whether a caller supplied `from`.\n *\n * It contributes the property NAME rather than nothing, so a schema whose only non-identity\n * properties are transformed still declares the `result` string the generated function\n * returns.\n */\nexport class HashTransformHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.transform != null) {\n let stringBuilder = builder.getOrDefault<StringBuilder>(\"hash-object-return.variable.string\");\n\n if (stringBuilder == null) {\n stringBuilder = builder.get<SlotBlock>(\"hash-object-return\")\n .assign(\"const result\", { name: \"variable\" })\n .string(\"template\", { name: \"string\" });\n }\n\n stringBuilder.append(`transform:${property.name}`);\n\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}\n","import { HashKeyHandler } from \"./hash/HashKeyHandler\";\nimport { HashValueHandler } from \"./hash/HashValueHandler\";\nimport { HashDateHandler } from \"./hash/HashDateHandler\";\nimport { HashIdentityHandler } from \"./hash/HashIdentityHandler\";\nimport { HashFunctionHandler } from \"./hash/HashFunctionHandler\";\nimport { HashComputedValueHandler } from \"./hash/HashComputedValueHandler\";\nimport { HashArrayHandler } from \"./hash/HashArrayHandler\";\nimport { HashObjectHandler } from \"./hash/HashObjectHandler\";\nimport { HashFileHandler } from \"./hash/HashFileHandler\";\nimport { HashTransformHandler } from \"./hash/HashTransformHandler\";\n\n/// Purpose:\n// Should ignore Id's and Identities for type Object because we want\n// to comare a new addition with what was saved in the database.\n// Files are ignored for the same reason: content goes in, a reference comes back.\n// So are transformed properties, whose stored form differs from the value submitted.\nexport class HashHandlerBuilder {\n\n build() {\n const handler = new HashKeyHandler();\n\n handler\n .setNext(new HashComputedValueHandler())\n .setNext(new HashFunctionHandler())\n .setNext(new HashIdentityHandler())\n .setNext(new HashFileHandler())\n .setNext(new HashTransformHandler())\n .setNext(new HashDateHandler())\n .setNext(new HashArrayHandler())\n .setNext(new HashObjectHandler())\n .setNext(new HashValueHandler());\n\n return handler;\n }\n}","import { CodeBuilder, SlotBlock } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\nexport class EnableChangeTrackingObjectHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.type === SchemaTypes.Object) {\n const assignmentSlot = builder.get<SlotBlock>(\"assignment\");\n const childSelectorPath = property.getSelectrorPath({ parent: \"entity\" });\n const childAssignmentPath = property.getAssignmentPath({ parent: \"entity\" });\n\n // Pass the root as parent so nested writes mark the root entity dirty,\n // and the full dotted path so the change is recorded under it\n assignmentSlot.if(`${childSelectorPath} != null`).appendBody(`${childAssignmentPath} = enableChangeTracking(${childAssignmentPath}, \"${this.getTrackingPath(property)}\", entity);`);\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder, SlotBlock } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { isArrayValued, PropertyInfo } from \"../../../schema\";\n\n/**\n * Arrays participate in change tracking: the array itself is wrapped in the tracking\n * proxy (with the root as parent) so in-place mutations — push/splice/index writes —\n * mark the root entity dirty instead of being silently lost on save.\n */\nexport class EnableChangeTrackingArrayHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (isArrayValued(property.type)) {\n const assignmentSlot = builder.get<SlotBlock>(\"assignment\");\n const childSelectorPath = property.getSelectrorPath({ parent: \"entity\" });\n const childAssignmentPath = property.getAssignmentPath({ parent: \"entity\" });\n\n assignmentSlot.if(`${childSelectorPath} != null`).appendBody(`${childAssignmentPath} = enableChangeTracking(${childAssignmentPath}, \"${this.getTrackingPath(property)}\", entity);`);\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}\n","import { CodeBuilder } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\nexport class EnableChangeTrackingPrimitiveValueHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.type !== SchemaTypes.Object) {\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { EnableChangeTrackingObjectHandler } from \"./enableChangeTracking/EnableChangeTrackingObjectHandler\";\nimport { EnableChangeTrackingArrayHandler } from \"./enableChangeTracking/EnableChangeTrackingArrayHandler\";\nimport { EnableChangeTrackingPrimitiveValueHandler } from \"./enableChangeTracking/EnableChangeTrackingPrimitiveValueHandler\";\n\n/// Purpose:\nexport class EnableChangeTrackingHandlerBuilder {\n\n build() {\n const handler = new EnableChangeTrackingObjectHandler();\n handler.setNext(new EnableChangeTrackingArrayHandler()).setNext(new EnableChangeTrackingPrimitiveValueHandler());\n\n return handler;\n }\n}","import { CodeBuilder } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\nexport class FreezePrimitiveValueHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.type !== SchemaTypes.Object) {\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder, SlotBlock } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\nexport class FreezeObjectHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.type === SchemaTypes.Object) {\n const assignmentSlot = builder.get<SlotBlock>(\"assignment\");\n const childSelectorPath = property.getSelectrorPath({ parent: \"entity\" });\n const childAssignmentPath = property.getAssignmentPath({ parent: \"entity\" });\n\n assignmentSlot.if(`${childSelectorPath} != null`).unshiftBody(`${childAssignmentPath} = Object.freeze(${childAssignmentPath});`);\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder, SlotBlock } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { isArrayValued, PropertyInfo } from \"../../../schema\";\n\nexport class FreezeArrayHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (isArrayValued(property.type)) {\n const assignmentSlot = builder.get<SlotBlock>(\"assignment\");\n const childSelectorPath = property.getSelectrorPath({ parent: \"entity\" });\n const childAssignmentPath = property.getAssignmentPath({ parent: \"entity\" });\n\n assignmentSlot.if(`${childSelectorPath} != null`).unshiftBody(`${childAssignmentPath} = Object.freeze(${childAssignmentPath});`);\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}\n","import { FreezePrimitiveValueHandler } from \"./freeze/FreezePrimitiveValueHandler\";\nimport { FreezeObjectHandler } from \"./freeze/FreezeObjectHandler\";\nimport { FreezeArrayHandler } from \"./freeze/FreezeArrayHandler\";\n\n/// Purpose:\nexport class FreezeHandlerBuilder {\n\n build() {\n const handler = new FreezeObjectHandler();\n handler.setNext(new FreezeArrayHandler()).setNext(new FreezePrimitiveValueHandler());\n\n return handler;\n }\n}","import { CodeBuilder, ContainerBlock, SlotBlock } from '../../blocks';\nimport { SlotPath } from '../../SlotPath';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\n/**\n * Handles converting a Date value from JavaScript to a string value. Should handle remapping here because it is the lowest level in the code here.\n * Remapping higher up could break lower level code\n */\nexport class SerializeDateHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.type === SchemaTypes.Date) {\n let objectBuilder = builder.get<SlotBlock>(\"if\");\n // Serialize maps in-memory shape -> storage shape: read the entity by\n // property name, write the result by `from` (storage) name\n const entitySelectorPath = property.getSelectrorPath({ parent: \"entity\" });\n const entityAssignmentPath = property.getAssignmentPath({\n parent: \"result\",\n useFromPropertyName: true\n });\n\n // if it is nullable or optional, assign in an if block, otherwise we\n // could unintentionally assign a property that does not exist. An explicit null IS\n // assigned — it is a legal value, and dropping it here is known-defects #66. The\n // expression already passes null through, since null is not `instanceof Date`.\n if (property.isOptional || property.isNullable) {\n const ifAssignment = `${entityAssignmentPath} = ${entitySelectorPath} instanceof Date ? ${entitySelectorPath}.toISOString() : ${entitySelectorPath}`;\n const rootPath = new SlotPath(\"if\");\n builder.get<ContainerBlock>(rootPath.get()).if(`${entitySelectorPath} !== undefined`).appendBody(ifAssignment);\n return builder;\n }\n\n if (property.parent == null) {\n const dateExpr = `${entitySelectorPath} instanceof Date ? ${entitySelectorPath}.toISOString() : ${entitySelectorPath}`;\n objectBuilder.if(`Object.hasOwn(entity, \"${property.name}\")`).appendBody(`${entityAssignmentPath} = ${dateExpr}`);\n return builder;\n }\n\n // Nested date: same pattern as SerializeValueHandler — if block for parent existence, then assign with toISOString\n const dateExprNested = `${entitySelectorPath} instanceof Date ? ${entitySelectorPath}.toISOString() : ${entitySelectorPath}`;\n this.emitSerializeNestedAssignment(property, objectBuilder, dateExprNested);\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder, SlotBlock } from '../../blocks';\nimport { SlotPath } from '../../SlotPath';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\nexport class SerializeObjectHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.type === SchemaTypes.Object) {\n const slotPath = new SlotPath(\"assignments\");\n // The result is the storage shape — materialize the container under\n // its `from` (storage) name\n const childPath = property.getAssignmentPath({\n parent: \"result\",\n useFromPropertyName: true\n });\n\n if (property.isNullable || property.isOptional) {\n // Do nothing if it's nullable or optional as property assignments will check\n // and create if it does not exist. This way we can handle null/optional\n return builder;\n }\n\n const slot = builder.get<SlotBlock>(slotPath.get());\n slot.assign(`${childPath}`, { name: `[${childPath}]` }).value(\"{}\");\n\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder, SlotBlock } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\nexport class SerializeValueHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.type != SchemaTypes.Object && property.type != SchemaTypes.Date) {\n const slot = builder.getOrDefault<SlotBlock>(\"if\");\n // Serialize maps in-memory shape -> storage shape: read the entity by\n // property name, write the result by `from` (storage) name\n const entitySelectorPath = property.getAssignmentPath({ parent: \"entity\" });\n const resultSelectorPath = property.getAssignmentPath({ parent: \"result\", useFromPropertyName: true });\n\n if (property.parent == null) {\n // Only assign if the incoming entity has the property, this allows partial serialization\n // Basically only serialize what is there\n slot.if(`Object.hasOwn(entity, \"${property.name}\")`).appendBody(`${resultSelectorPath} = ${entitySelectorPath}`);\n return builder;\n }\n\n this.emitSerializeNestedAssignment(property, slot, entitySelectorPath);\n\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder, SlotBlock } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo } from \"../../../schema\";\n\nexport class SerializeSerializerHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.valueSerializer != null) {\n const slot = builder.getOrDefault<SlotBlock>(\"if\");\n const assignmentBuilder = builder.getOrDefault<SlotBlock>(\"functions\");\n // Serialize maps in-memory shape -> storage shape: read the entity by\n // property name, write the result by `from` (storage) name\n const entitySelectorPath = property.getSelectrorPath({ parent: \"entity\" });\n const resultSelectorPath = property.getAssignmentPath({ parent: \"result\", useFromPropertyName: true });\n\n const defaultFunctionWithParameters = this.toNamedFunction(property.valueSerializer.toString(), assignmentBuilder);\n defaultFunctionWithParameters.builder.parameters(...defaultFunctionWithParameters.parameters.map((_, i) => ({ name: defaultFunctionWithParameters.parameters[i], callName: entitySelectorPath })));\n\n if (property.parent == null) {\n slot.if(`Object.hasOwn(entity, \"${property.name}\")`).appendBody(`${resultSelectorPath} = ${defaultFunctionWithParameters.builder.toCallable()}`);\n return builder;\n }\n\n // Nested serializer: same pattern as SerializeValueHandler — if block for parent existence, then assign via serializer\n this.emitSerializeNestedAssignment(property, slot, defaultFunctionWithParameters.builder.toCallable());\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\nexport class SerializeFunctionHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.functionBody != null && property.type === SchemaTypes.Function) {\n // Functions should not be serialized\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\nexport class SerializeComputedHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.type === SchemaTypes.Computed && property.isUnmapped === true) {\n // Do not serialize computed properties that are unmapped\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder, SlotBlock } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { isArrayValued, PropertyInfo, SchemaTypes } from \"../../../schema\";\n\n/**\n * Serializes arrays per element instead of copying the reference:\n *\n * - Date elements become ISO strings (same convention as SerializeDateHandler).\n * - Object elements are deep-copied so the storage payload shares no references\n * with the entity.\n * - Primitive elements are copied with a spread.\n *\n * Producing a NEW array also matters for change tracking: tracked entities hold\n * arrays wrapped in a Proxy, which cannot pass a structured-clone boundary\n * (BroadcastChannel.postMessage) — the serialized payload must be plain data.\n */\nexport class SerializeArrayHandler extends PropertyInfoHandler {\n\n private copyExpression(property: PropertyInfo<any>, selector: string): string {\n const elementType = property.innerSchema?.type;\n\n if (elementType === SchemaTypes.Date) {\n return `${selector}.map(function (v) { return v instanceof Date ? v.toISOString() : v; })`;\n }\n\n if (elementType === SchemaTypes.Object || elementType === SchemaTypes.Array || elementType === SchemaTypes.Definition) {\n return `${selector}.map(function (v) { return v == null ? v : structuredClone(v); })`;\n }\n\n return `[...${selector}]`;\n }\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (isArrayValued(property.type)) {\n const slot = builder.get<SlotBlock>(\"if\");\n // Serialize maps in-memory shape -> storage shape: read the entity by\n // property name, write the result by `from` (storage) name\n const entitySelectorPath = property.getAssignmentPath({ parent: \"entity\" });\n const resultSelectorPath = property.getAssignmentPath({ parent: \"result\", useFromPropertyName: true });\n\n // Null propagates as-is (nullable arrays); only real arrays are copied\n const valueExpression = `${entitySelectorPath} == null ? ${entitySelectorPath} : ${this.copyExpression(property, entitySelectorPath)}`;\n\n if (property.parent == null) {\n // Only assign if the incoming entity has the property, this allows partial\n // serialization (delta payloads carry only changed keys)\n slot.if(`Object.hasOwn(entity, \"${property.name}\")`).appendBody(`${resultSelectorPath} = ${valueExpression}`);\n return builder;\n }\n\n this.emitSerializeNestedAssignment(property, slot, valueExpression);\n\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}\n","import { SerializeDateHandler } from \"./serialize/SerializeDateHandler\";\nimport { SerializeObjectHandler } from \"./serialize/SerializeObjectHandler\";\nimport { SerializeValueHandler } from \"./serialize/SerializeValueHandler\";\nimport { SerializeSerializerHandler } from \"./serialize/SerializeSerializerHandler\";\nimport { SerializeFunctionHandler } from \"./serialize/SerializeFunctionHandler\";\nimport { SerializeComputedHandler } from \"./serialize/SerializeComputedHandler\";\nimport { SerializeArrayHandler } from \"./serialize/SerializeArrayHandler\";\n\n/// Purpose:\nexport class SerializeHandlerBuilder {\n\n build() {\n const handler = new SerializeSerializerHandler();\n handler\n .setNext(new SerializeComputedHandler())\n .setNext(new SerializeFunctionHandler())\n .setNext(new SerializeDateHandler())\n .setNext(new SerializeArrayHandler())\n .setNext(new SerializeValueHandler())\n .setNext(new SerializeObjectHandler());\n\n return handler;\n }\n}","import { now } from \"../../performance\";\nimport { Branded, uuid } from \"../../utilities\";\nimport { CompiledSchemaCore, ISchemaSubscription, SchemaId, SubscriptionChanges } from \"../types\";\n\ntype BroadcastChannelReceiverId = Branded<string, \"BroadcastChannelReceiverId\">;\ntype SubscriptionListenerCallback<T> = (changes: StampedChanges<T>) => void;\ntype BroadcastChannelType = InstanceType<typeof BroadcastChannel>;\ninterface ISubscriptionAction<T> {\n action(changes: StampedChanges<T>): void\n}\ntype StampedChanges<T> = { data: SubscriptionChanges<T>, timestamp: number };\n\nexport type SchemaSubscriptionOptions = {\n /**\n * Whether changes must reach listeners OUTSIDE this process — another browser tab, or\n * another worker thread in Node. Default `true`, which is the historical behaviour.\n *\n * It cannot be inferred. A BroadcastChannel gives a sender no way to ask who is on the\n * other end, so `send` can only count the listeners registered in THIS process. When\n * this is `true`, `send` must assume a listener it cannot see and always publish. When\n * a caller sets it to `false`, it promises there is no such listener, and `send` skips\n * the whole preprocess-and-post step whenever nobody local is listening.\n */\n crossTabSync?: boolean;\n};\n\nconst registry: Record<string, SchemaChannel<unknown>> = {};\n\n/**\n * Channels are scoped by schema AND database: two databases holding the same schema must not\n * see each other's change notifications, while instances of the same database (another tab, a\n * worker) share a scope and stay connected.\n *\n * Every datastore path supplies a scope — `IDbPlugin.databaseName` is required, so there is no\n * longer a plugin that leaves it out. The unscoped key remains for callers who create a\n * subscription directly off a schema without a database in hand; it is a channel per schema\n * across the whole process, which is what asking for no scope means. A SENDER that omits the\n * scope will not reach datastore listeners, because they are on `schema|databaseName`.\n */\nconst getChannelKey = (schemaId: SchemaId, scope?: string) => scope == null ? String(schemaId) : `${schemaId}|${scope}`;\n\nconst getChannelRegistry = <T>(schemaId: SchemaId, scope?: string): SchemaChannel<T> => {\n\n const key = getChannelKey(schemaId, scope);\n\n if (registry[key]) {\n return registry[key] as SchemaChannel<T>;\n }\n\n const channel = new SchemaChannel<T>(key);\n\n registry[key] = channel;\n\n return channel;\n}\n\n// Must have a sender and receiver. Sender cannot listen for it's own message\nclass SchemaChannel<T> {\n\n readonly sender: SchemaChannelSender<T>;\n readonly receiver: SchemaChannelReceiver<T>;\n\n // An open BroadcastChannel keeps the event loop alive. Channels are shared per schema,\n // so the pair can only close once every subscription using them has been disposed —\n // hence a count rather than a boolean.\n private subscribers: number = 0;\n\n constructor(channelKey: string) {\n this.sender = new SchemaChannelSender<T>(channelKey);\n this.receiver = new SchemaChannelReceiver<T>(channelKey);\n }\n\n /**\n * How many callbacks in THIS process are waiting on the channel.\n *\n * Deliberately not `subscribers`: that counts SchemaSubscription instances, and a\n * DataStore constructs one per collection up front purely to SEND from, so it never\n * reaches zero. Only `onMessage` registers a listener, which is the thing a sender\n * can be skipped for. See `SchemaSubscription.send`.\n */\n get listenerCount() {\n return this.receiver.listenerCount;\n }\n\n retain() {\n this.subscribers++;\n }\n\n /** Returns true when the last subscriber released the channel. */\n release() {\n this.subscribers--;\n return this.subscribers <= 0;\n }\n\n close() {\n this.sender.close();\n this.receiver.close();\n }\n}\n\n/**\n * Stops a channel from holding the process open.\n *\n * A DataStore opens a sender and a receiver per collection, and in Node an open\n * BroadcastChannel is a referenced handle. Without this, any script that builds a store and\n * does not call `destroyAsync()` runs to the end of its code and then hangs forever with two\n * live MessagePorts per collection — including the example in the README.\n *\n * `unref` is Node-only; the browser's BroadcastChannel has no such method and needs none.\n * A channel that is unreferenced still sends and receives normally. It only stops being a\n * reason for the process to stay alive, which is the correct default for a library: a program\n * with no work left should exit.\n */\nconst unreference = (channel: BroadcastChannelType) => {\n const maybeUnref = (channel as { unref?: () => void }).unref;\n\n if (typeof maybeUnref === 'function') {\n maybeUnref.call(channel);\n }\n};\n\nclass SchemaChannelSender<T> {\n\n private readonly broadcastChannel: BroadcastChannelType;\n\n constructor(channelKey: string) {\n this.broadcastChannel = new BroadcastChannel(`__routier-schema-subscription-channel:${channelKey}`);\n unreference(this.broadcastChannel);\n }\n\n send(changes: StampedChanges<T>) {\n this.broadcastChannel.postMessage(changes)\n }\n\n close() {\n this.broadcastChannel.close();\n }\n}\n\nclass SchemaChannelReceiver<T> {\n\n private readonly broadcastChannel: BroadcastChannelType;\n private subscriptions: SubscriptionListener<T>[] = [];\n\n constructor(channelKey: string) {\n this.broadcastChannel = new BroadcastChannel(`__routier-schema-subscription-channel:${channelKey}`);\n unreference(this.broadcastChannel);\n\n this.broadcastChannel.onmessage = (e) => {\n\n // We can't send to the same instance it is not possbile\n const stampedChanges = e.data as StampedChanges<T>;\n\n for (let i = 0, length = this.subscriptions.length; i < length; i++) {\n const subscription = this.subscriptions[i];\n\n subscription.action(stampedChanges);\n }\n };\n }\n\n get listenerCount() {\n return this.subscriptions.length;\n }\n\n addListener(id: BroadcastChannelReceiverId, listener: SubscriptionListenerCallback<T>) {\n this.subscriptions.push(new SubscriptionListener<T>(id, listener));\n }\n\n removeListeners(id: BroadcastChannelReceiverId) {\n this.subscriptions = this.subscriptions.filter(w => w.id !== id);\n }\n\n close() {\n this.subscriptions = [];\n this.broadcastChannel.onmessage = null;\n this.broadcastChannel.close();\n }\n}\n\nclass SubscriptionListener<T> implements ISubscriptionAction<T> {\n\n readonly id: BroadcastChannelReceiverId;\n private readonly listener: SubscriptionListenerCallback<T>;\n\n constructor(id: BroadcastChannelReceiverId, listener: SubscriptionListenerCallback<T>) {\n this.id = id;\n this.listener = listener;\n }\n\n action(changes: StampedChanges<T>) {\n this.listener(changes);\n }\n}\n\nexport class SchemaSubscription<T extends {}> implements ISchemaSubscription<T> {\n\n private readonly id: BroadcastChannelReceiverId;\n private readonly schema: CompiledSchemaCore<T>;\n private readonly scope?: string;\n private readonly createdAt: number;\n private readonly crossTabSync: boolean;\n private isDisposed: boolean = false;\n\n constructor(schema: CompiledSchemaCore<T>, signal?: AbortSignal, scope?: string, options?: SchemaSubscriptionOptions) {\n this.createdAt = now();\n this.id = uuid(8) as BroadcastChannelReceiverId;\n this.schema = schema;\n this.scope = scope;\n this.crossTabSync = options?.crossTabSync ?? true;\n\n getChannelRegistry<T>(schema.id, scope).retain();\n\n signal?.addEventListener(\"abort\", () => {\n this.dispose();\n }, { once: true });\n }\n\n send(changes: SubscriptionChanges<T>) {\n const regisry = getChannelRegistry<T>(this.schema.id, this.scope);\n\n // Preprocessing runs over every add, update, removal and unknown, and it ran on every\n // saveChanges even when the message had nowhere to go. Measured on this branch, skipping\n // it is worth ~18% on diff-update-1000 and ~10% on insert-1000.\n //\n // The guard lives here rather than at the call sites so every caller — CollectionBase,\n // View, and anything added later — gets it without repeating the condition.\n if (this.crossTabSync === false && regisry.listenerCount === 0) {\n return;\n }\n\n // cannot send raw data, needs to be preprocessed\n const preprocessedChanges: SubscriptionChanges<T> = {\n adds: Array.from({ length: changes.adds.length }),\n removals: Array.from({ length: changes.removals.length }),\n unknown: Array.from({ length: changes.unknown.length }),\n updates: Array.from({ length: changes.updates.length }),\n };\n\n for (let i = 0, length = changes.adds.length; i < length; i++) {\n preprocessedChanges.adds[i] = this.schema.preprocess(changes.adds[i]);\n }\n\n for (let i = 0, length = changes.removals.length; i < length; i++) {\n preprocessedChanges.removals[i] = this.schema.preprocess(changes.removals[i]);\n }\n\n for (let i = 0, length = changes.unknown.length; i < length; i++) {\n preprocessedChanges.unknown[i] = this.schema.preprocess(changes.unknown[i]);\n }\n\n for (let i = 0, length = changes.updates.length; i < length; i++) {\n preprocessedChanges.updates[i] = this.schema.preprocess(changes.updates[i]);\n }\n\n // Send message to all listeners.\n // Since we create a new listener when we do onMessage,\n // we don't need to worry about sending to ourselves, it \n // can't happen\n regisry.sender.send({\n data: preprocessedChanges,\n timestamp: now()\n });\n }\n\n onMessage(callback: (changes: SubscriptionChanges<T>) => void) {\n\n const regisry = getChannelRegistry<T>(this.schema.id, this.scope);\n\n // Link the callback to an instance\n regisry.receiver.addListener(this.id, ({ data, timestamp }) => {\n\n if (timestamp < this.createdAt) {\n // Sent before the receiver was even created\n return;\n }\n\n // Changes were preprocessed before they were sent, need to postprocess them.\n // \"diff\" enriches and deserializes without attaching a change-tracking proxy\n // or freezing: these entities belong to another instance's unit of work, and\n // subscribers only read them (or reseed them to re-run a query), never persist\n // mutations through them.\n const postProcessedChanges: SubscriptionChanges<T> = {\n adds: Array.from({ length: data.adds.length }),\n removals: Array.from({ length: data.removals.length }),\n unknown: Array.from({ length: data.unknown.length }),\n updates: Array.from({ length: data.updates.length }),\n };\n\n for (let i = 0, length = data.adds.length; i < length; i++) {\n postProcessedChanges.adds[i] = this.schema.postprocess(data.adds[i], \"diff\");\n }\n\n for (let i = 0, length = data.removals.length; i < length; i++) {\n postProcessedChanges.removals[i] = this.schema.postprocess(data.removals[i], \"diff\");\n }\n\n for (let i = 0, length = data.unknown.length; i < length; i++) {\n postProcessedChanges.unknown[i] = this.schema.postprocess(data.unknown[i], \"diff\");\n }\n\n for (let i = 0, length = data.updates.length; i < length; i++) {\n postProcessedChanges.updates[i] = this.schema.postprocess(data.updates[i], \"diff\");\n }\n\n callback(postProcessedChanges);\n });\n }\n\n dispose() {\n this[Symbol.dispose]();\n }\n\n [Symbol.dispose](): void {\n // Dispose is idempotent, and it must be: a second release would drop the shared\n // channel's count below zero and close it out from under live subscriptions.\n if (this.isDisposed) {\n return;\n }\n this.isDisposed = true;\n\n const regisry = getChannelRegistry<T>(this.schema.id, this.scope);\n\n // Remove listeners for this instance only\n regisry.receiver.removeListeners(this.id);\n\n // An open BroadcastChannel holds the event loop open, so the last subscription out\n // closes the pair and drops it from the registry.\n if (regisry.release()) {\n regisry.close();\n delete registry[getChannelKey(this.schema.id, this.scope)];\n }\n }\n}","import { CodeBuilder, SlotBlock } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo } from \"../../../schema\";\n\nexport class CompareIdsKeyHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<unknown>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.isKey) {\n const slot = builder.get<SlotBlock>(\"ifs\");\n const leftCompare = property.getSelectrorPath({ parent: \"a\" });\n const rightCompare = property.getSelectrorPath({ parent: \"b\" });\n\n slot.if(`${leftCompare} != ${rightCompare}`).appendBody(\"return false;\");\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { NotApplicableHandler } from \"./types\";\nimport { CompareIdsKeyHandler } from \"./compareIds/CompareIdsKeyHandler\";\n\nexport class CompareIdsHandlerBuilder {\n\n build() {\n const handler = new CompareIdsKeyHandler();\n\n handler.setNext(new NotApplicableHandler());\n\n return handler;\n }\n}","import { PropertyInfo } from '../PropertyInfo';\nimport { CompiledSchema, InferCreateType, InferType, SchemaTypes } from '../types';\nimport { SchemaBase } from '../property/base/SchemaBase';\nimport { SchemaArray } from '../property/types/SchemaArray';\nimport { SchemaDefinition } from '../SchemaDefinition';\nimport { s } from '../builder';\n\n/**\n * Standard JSON Schema V1 interface types\n * Based on https://standardschema.dev/json-schema\n */\nexport interface StandardTypedV1<Input = unknown, Output = Input> {\n readonly '~standard': StandardTypedV1.Props<Input, Output>;\n}\n\nexport declare namespace StandardTypedV1 {\n export interface Props<Input = unknown, Output = Input> {\n readonly version: 1;\n readonly vendor: string;\n readonly types?: Types<Input, Output> | undefined;\n }\n\n export interface Types<Input = unknown, Output = Input> {\n readonly input: Input;\n readonly output: Output;\n }\n}\n\nexport interface StandardJSONSchemaV1<Input = unknown, Output = Input> {\n readonly '~standard': StandardJSONSchemaV1.Props<Input, Output>;\n}\n\nexport declare namespace StandardJSONSchemaV1 {\n export interface Props<Input = unknown, Output = Input>\n extends StandardTypedV1.Props<Input, Output> {\n readonly jsonSchema: StandardJSONSchemaV1.Converter;\n }\n\n export interface Converter {\n readonly input: (\n options: StandardJSONSchemaV1.Options\n ) => Record<string, unknown>;\n readonly output: (\n options: StandardJSONSchemaV1.Options\n ) => Record<string, unknown>;\n }\n\n export type Target =\n | 'draft-2020-12'\n | 'draft-07'\n | 'openapi-3.0'\n | ({} & string);\n\n export interface Options {\n readonly target: Target;\n readonly libraryOptions?: Record<string, unknown> | undefined;\n }\n}\n\n/**\n * Context for property conversion\n */\ninterface ConversionContext {\n target: StandardJSONSchemaV1.Target;\n visited: Set<string>;\n useOutputType: boolean;\n convertProperty: (property: PropertyInfo<any>) => Record<string, unknown>;\n}\n\n/**\n * Strategy interface for converting property types to JSON Schema\n */\ntype PropertyConverter = (\n property: PropertyInfo<any>,\n context: ConversionContext\n) => Record<string, unknown>;\n\n/**\n * Converts a primitive property with optional enum/literals\n */\nfunction createPrimitiveConverter(\n jsonType: 'string' | 'number' | 'boolean'\n): PropertyConverter {\n return (property, _context) => {\n const jsonSchema: Record<string, unknown> = { type: jsonType };\n if (property.literals && property.literals.length > 0) {\n jsonSchema.enum = property.literals;\n }\n return jsonSchema;\n };\n}\n\n/**\n * Converts a Date property to JSON Schema\n */\nconst dateConverter: PropertyConverter = (_property, _context) => {\n return {\n type: 'string',\n format: 'date-time'\n };\n};\n\n/**\n * Converts an Object property to JSON Schema\n */\nconst objectConverter: PropertyConverter = (property, context) => {\n const jsonSchema: Record<string, unknown> = { type: 'object' };\n\n if (property.children && property.children.length > 0) {\n const properties: Record<string, unknown> = {};\n const required: string[] = [];\n\n for (const child of property.children) {\n // Skip computed and function properties for input schemas\n // Include them in output schemas as they represent derived values\n if (!context.useOutputType && (child.type === SchemaTypes.Computed || child.type === SchemaTypes.Function)) {\n continue;\n }\n\n const childSchema = context.convertProperty(child);\n\n // Skip empty schemas (e.g., computed properties that return empty for input)\n if (Object.keys(childSchema).length === 0) {\n continue;\n }\n\n const propertyName = child.from || child.name;\n properties[propertyName] = childSchema;\n\n // Add to required if not optional and not nullable\n // Computed/function properties are never required in JSON Schema\n if (!child.isOptional && !child.isNullable &&\n child.type !== SchemaTypes.Computed && child.type !== SchemaTypes.Function) {\n required.push(propertyName);\n }\n }\n\n if (Object.keys(properties).length > 0) {\n jsonSchema.properties = properties;\n }\n if (required.length > 0) {\n jsonSchema.required = required;\n }\n } else {\n // Empty object or unknown structure\n jsonSchema.properties = {};\n }\n\n return jsonSchema;\n};\n\n/**\n * Converts array inner schema to JSON Schema items\n * Attempts to fully recurse into object schemas when possible\n */\nfunction convertArrayItems(\n innerSchema: SchemaBase<any, any>,\n context: ConversionContext\n): Record<string, unknown> {\n const innerType = innerSchema.type;\n\n switch (innerType) {\n case SchemaTypes.String:\n return { type: 'string' };\n case SchemaTypes.Number:\n return { type: 'number' };\n case SchemaTypes.Boolean:\n return { type: 'boolean' };\n case SchemaTypes.Date:\n return { type: 'string', format: 'date-time' };\n case SchemaTypes.Object:\n // Try to extract object structure from innerSchema.instance\n // For SchemaObject, instance contains the property definitions\n if (innerSchema.instance && typeof innerSchema.instance === 'object') {\n const properties: Record<string, unknown> = {};\n const required: string[] = [];\n\n // Iterate through the instance properties\n for (const [key, value] of Object.entries(innerSchema.instance)) {\n if (value && typeof value === 'object' && 'type' in value) {\n // This is a SchemaBase - try to convert it\n const schemaBase = value as SchemaBase<any, any>;\n const tempProperty = new PropertyInfo(schemaBase, key);\n\n // Skip computed/function for input schemas\n if (!context.useOutputType &&\n (tempProperty.type === SchemaTypes.Computed || tempProperty.type === SchemaTypes.Function)) {\n continue;\n }\n\n const itemSchema = context.convertProperty(tempProperty);\n if (Object.keys(itemSchema).length > 0) {\n properties[key] = itemSchema;\n if (!tempProperty.isOptional && !tempProperty.isNullable &&\n tempProperty.type !== SchemaTypes.Computed && tempProperty.type !== SchemaTypes.Function) {\n required.push(key);\n }\n }\n }\n }\n\n if (Object.keys(properties).length > 0) {\n return {\n type: 'object',\n properties,\n ...(required.length > 0 ? { required } : {})\n };\n }\n }\n // Fallback for unknown object structure\n return {\n type: 'object',\n properties: {},\n description: 'Array item object schema'\n };\n case SchemaTypes.Array:\n // Nested arrays - recursively handle\n if (innerSchema instanceof SchemaArray && innerSchema.innerSchema) {\n return {\n type: 'array',\n items: convertArrayItems(innerSchema.innerSchema, context)\n };\n }\n return {\n type: 'array',\n items: { type: 'object' } // Simplified fallback\n };\n default:\n return { type: 'object' };\n }\n}\n\n/**\n * Converts an Array property to JSON Schema\n */\n/**\n * Converts a Vector property to JSON Schema.\n *\n * The dimension count is expressible here in a way it is not in the type system, so it is\n * emitted: a consumer validating against this schema rejects a wrong-width embedding, which\n * is the earliest anything can.\n */\nconst vectorConverter: PropertyConverter = (property, _context) => {\n const jsonSchema: Record<string, unknown> = {\n type: 'array',\n items: { type: 'number' }\n };\n\n if (property.dimensions != null) {\n jsonSchema.minItems = property.dimensions;\n jsonSchema.maxItems = property.dimensions;\n }\n\n return jsonSchema;\n};\n\nconst arrayConverter: PropertyConverter = (property, context) => {\n const jsonSchema: Record<string, unknown> = { type: 'array' };\n\n if (property.innerSchema) {\n jsonSchema.items = convertArrayItems(property.innerSchema, context);\n } else {\n jsonSchema.items = { type: 'object' };\n }\n\n return jsonSchema;\n};\n\n/**\n * Converts computed/function properties to JSON Schema\n * For input schemas, these return empty (should be skipped)\n * For output schemas, we include them with a generic object type\n */\nconst computedConverter: PropertyConverter = (property, context) => {\n // For input schemas, computed/function properties are not part of the data shape\n if (!context.useOutputType) {\n return {};\n }\n\n // For output schemas, include computed properties\n // We can't know the exact return type without executing the function,\n // so we use a generic object type with a note\n const routierMeta: Record<string, unknown> = {\n isComputed: property.type === SchemaTypes.Computed,\n isFunction: property.type === SchemaTypes.Function\n };\n\n // Store function source code for rehydration\n if (property.functionBody) {\n try {\n routierMeta.functionSource = property.functionBody.toString();\n } catch {\n // If function can't be serialized, store a placeholder\n routierMeta.functionSource = null;\n }\n }\n\n // Store injected value if it's serializable\n if (property.injected !== null && property.injected !== undefined) {\n try {\n // Try to serialize the injected value\n JSON.stringify(property.injected);\n routierMeta.injected = property.injected;\n } catch {\n // If injected value can't be serialized, store null\n routierMeta.injected = null;\n }\n } else {\n routierMeta.injected = null;\n }\n\n return {\n type: 'object',\n description: property.type === SchemaTypes.Computed\n ? 'Computed property (derived value)'\n : 'Function property (derived value)',\n 'x-routier': routierMeta\n };\n};\n\n/**\n * Default converter for unknown types\n */\nconst defaultConverter: PropertyConverter = () => {\n return { type: 'object' };\n};\n\n/**\n * Factory registry mapping SchemaTypes to converters\n */\nconst converterRegistry = new Map<SchemaTypes, PropertyConverter>([\n [SchemaTypes.String, createPrimitiveConverter('string')],\n [SchemaTypes.Number, createPrimitiveConverter('number')],\n [SchemaTypes.Boolean, createPrimitiveConverter('boolean')],\n [SchemaTypes.Date, dateConverter],\n [SchemaTypes.Object, objectConverter],\n [SchemaTypes.Array, arrayConverter],\n [SchemaTypes.Vector, vectorConverter],\n [SchemaTypes.Computed, computedConverter],\n [SchemaTypes.Function, computedConverter],\n]);\n\n/**\n * Applies nullable handling to a JSON Schema based on the target draft version\n */\nfunction applyNullable(\n jsonSchema: Record<string, unknown>,\n property: PropertyInfo<any>,\n target: StandardJSONSchemaV1.Target\n): void {\n if (!property.isNullable) {\n return;\n }\n\n if (target === 'draft-2020-12') {\n if (Array.isArray(jsonSchema.type)) {\n (jsonSchema.type as string[]).push('null');\n } else {\n jsonSchema.type = [jsonSchema.type as string, 'null'];\n }\n } else {\n jsonSchema.nullable = true;\n }\n}\n\n/**\n * Applies Routier-specific metadata to a JSON Schema\n */\nfunction applyRoutierMetadata(\n jsonSchema: Record<string, unknown>,\n property: PropertyInfo<any>\n): void {\n // Don't overwrite existing x-routier metadata (e.g., from computed properties)\n if (!jsonSchema['x-routier']) {\n jsonSchema['x-routier'] = {};\n }\n const routierMeta = jsonSchema['x-routier'] as Record<string, unknown>;\n\n // Only add metadata if it doesn't already exist (to preserve computed property metadata)\n if (property.isKey && !routierMeta.isKey) {\n routierMeta.isKey = true;\n }\n if (property.isIdentity && !routierMeta.isIdentity) {\n routierMeta.isIdentity = true;\n }\n if (property.isReadonly && !routierMeta.isReadonly) {\n routierMeta.isReadonly = true;\n }\n if (property.isDistinct && !routierMeta.isDistinct) {\n routierMeta.isDistinct = true;\n }\n if (property.isSearchable && !routierMeta.isSearchable) {\n routierMeta.isSearchable = true;\n }\n if (property.indexes && property.indexes.length > 0 && !routierMeta.indexes) {\n routierMeta.indexes = property.indexes;\n }\n if ((property.valueSerializer || property.valueDeserializer) && !routierMeta.hasCustomSerialization) {\n routierMeta.hasCustomSerialization = true;\n }\n if (property.defaultValue != null && !routierMeta.hasDefault) {\n routierMeta.hasDefault = true;\n // Note: We can't serialize function defaults, only note their presence\n if (typeof property.defaultValue === 'function') {\n routierMeta.defaultIsFunction = true;\n } else {\n // For static defaults, we can include the actual value\n // Note: This includes falsy values like 0, false, empty string, etc.\n routierMeta.defaultValue = property.defaultValue;\n }\n }\n // Store the Routier property name in metadata (may differ from JSON Schema key if from() is used)\n if (!routierMeta.propertyName) {\n routierMeta.propertyName = property.name;\n }\n if (property.from != null && !routierMeta.from) {\n routierMeta.from = property.from;\n }\n}\n\n/**\n * Converts a Routier PropertyInfo to a JSON Schema property definition.\n */\nexport function propertyInfoToJsonSchema(\n property: PropertyInfo<any>,\n target: StandardJSONSchemaV1.Target,\n visited: Set<string> = new Set(),\n useOutputType: boolean = false\n): Record<string, unknown> {\n // Create conversion context with recursive converter\n const context: ConversionContext = {\n target,\n visited,\n useOutputType,\n convertProperty: (prop) => propertyInfoToJsonSchema(prop, target, visited, useOutputType)\n };\n\n // Get converter from factory registry\n const converter = converterRegistry.get(property.type) ?? defaultConverter;\n\n // Convert the property\n const jsonSchema = converter(property, context);\n\n // Apply nullable handling\n applyNullable(jsonSchema, property, target);\n\n // Apply Routier-specific metadata\n applyRoutierMetadata(jsonSchema, property);\n\n return jsonSchema;\n}\n\n/**\n * Converts a CompiledSchema to a JSON Schema object schema.\n */\nexport function compiledSchemaToJsonSchema<T extends {}>(\n compiledSchema: CompiledSchema<T>,\n target: StandardJSONSchemaV1.Target,\n useOutputType: boolean = false\n): Record<string, unknown> {\n const jsonSchema: Record<string, unknown> = {\n $schema: target === 'draft-2020-12'\n ? 'https://json-schema.org/draft/2020-12/schema'\n : target === 'draft-07'\n ? 'http://json-schema.org/draft-07/schema#'\n : 'http://json-schema.org/draft-04/schema#',\n type: 'object',\n properties: {} as Record<string, unknown>,\n required: [] as string[]\n };\n\n const properties: Record<string, unknown> = {};\n const required: string[] = [];\n\n // Iterate through all properties\n for (const property of compiledSchema.properties) {\n // Skip computed and function properties for input schema\n // For output schema, we include computed properties\n if (!useOutputType && (property.type === SchemaTypes.Computed || property.type === SchemaTypes.Function)) {\n continue;\n }\n\n // Skip unmapped properties (except computed/function properties in output schema)\n if (property.isUnmapped && !(useOutputType && (property.type === SchemaTypes.Computed || property.type === SchemaTypes.Function))) {\n continue;\n }\n\n const propertySchema = propertyInfoToJsonSchema(property, target, new Set(), useOutputType);\n\n // Skip empty schemas (e.g., computed properties that return empty)\n if (Object.keys(propertySchema).length === 0) {\n continue;\n }\n\n const propertyName = property.from || property.name;\n properties[propertyName] = propertySchema;\n\n // Add to required if not optional and not nullable\n if (!property.isOptional && !property.isNullable) {\n required.push(propertyName);\n }\n }\n\n jsonSchema.properties = properties;\n if (required.length > 0) {\n jsonSchema.required = required;\n }\n\n // Add Routier-specific metadata\n jsonSchema['x-routier'] = {\n collectionName: compiledSchema.collectionName,\n idProperties: compiledSchema.idProperties.map(p => p.name),\n hasIdentities: compiledSchema.hasIdentities,\n hasIdentityKeys: compiledSchema.hasIdentityKeys\n };\n\n return jsonSchema;\n}\n\n/**\n * Creates Standard JSON Schema V1 props for a compiled schema.\n */\nexport function createStandardJsonSchemaProps<T extends {}>(\n compiledSchema: CompiledSchema<T>\n): StandardJSONSchemaV1.Props<InferCreateType<T>, InferType<T>> {\n return {\n version: 1,\n vendor: 'routier',\n types: {\n input: undefined as any as InferCreateType<T>,\n output: undefined as any as InferType<T>\n },\n jsonSchema: {\n input: (options: StandardJSONSchemaV1.Options): Record<string, unknown> => {\n return compiledSchemaToJsonSchema(compiledSchema, options.target, false);\n },\n output: (options: StandardJSONSchemaV1.Options): Record<string, unknown> => {\n return compiledSchemaToJsonSchema(compiledSchema, options.target, true);\n }\n }\n };\n}\n\n/**\n * Parses a JSON string containing a JSON Schema and rehydrates it into a Routier SchemaDefinition.\n * This is a convenience wrapper around `rehydrateSchemaFromJsonSchema` that handles JSON parsing.\n * \n * @param jsonString - The JSON string containing the JSON Schema\n * @param collectionName - The collection name for the schema (if not in x-routier metadata)\n * @returns A SchemaDefinition that can be compiled\n * @throws Error if the JSON string is invalid or doesn't contain a valid JSON Schema\n */\nexport function rehydrateSchemaFromJsonString(\n jsonString: string,\n collectionName?: string\n): SchemaDefinition<any> {\n try {\n const jsonSchema = JSON.parse(jsonString) as Record<string, unknown>;\n return rehydrateSchemaFromJsonSchema(jsonSchema, collectionName);\n } catch (error) {\n if (error instanceof SyntaxError) {\n throw new Error(`Invalid JSON string: ${error.message}`);\n }\n throw error;\n }\n}\n\n/**\n * Rehydrates a JSON Schema back into a Routier SchemaDefinition.\n * This parses the JSON Schema structure and reconstructs the schema using Routier's builder API.\n * \n * @param jsonSchema - The JSON Schema object to rehydrate\n * @param collectionName - The collection name for the schema (if not in x-routier metadata)\n * @returns A SchemaDefinition that can be compiled\n */\nexport function rehydrateSchemaFromJsonSchema(\n jsonSchema: Record<string, unknown>,\n collectionName?: string\n): SchemaDefinition<any> {\n // Extract collection name - provided collectionName takes precedence over metadata\n const routierMeta = jsonSchema['x-routier'] as Record<string, unknown> | undefined;\n const finalCollectionName = collectionName || (routierMeta?.collectionName as string) || 'unknown';\n\n if (!jsonSchema.properties || typeof jsonSchema.properties !== 'object') {\n throw new Error('JSON Schema must have a properties object');\n }\n\n const properties = jsonSchema.properties as Record<string, unknown>;\n const required = (jsonSchema.required as string[] | undefined) || [];\n const schemaDefinition: Record<string, any> = {};\n const computedProperties: Array<{ name: string; isComputed: boolean; functionSource: string | null; injected: any }> = [];\n\n // Get idProperties from schema-level metadata as fallback\n const idProperties = (routierMeta?.idProperties as string[] | undefined) || [];\n\n for (const [propName, propSchema] of Object.entries(properties)) {\n const prop = propSchema as Record<string, unknown>;\n const isRequired = required.includes(propName);\n const routierPropMeta = prop['x-routier'] as Record<string, unknown> | undefined;\n\n // Use Routier property name from metadata if available, otherwise use JSON Schema property name\n const routierPropName = (routierPropMeta?.propertyName as string | undefined) || propName;\n\n // Check if this is a computed or function property\n if (routierPropMeta?.isComputed || routierPropMeta?.isFunction) {\n computedProperties.push({\n name: routierPropName,\n isComputed: routierPropMeta.isComputed === true,\n functionSource: (routierPropMeta.functionSource as string | null) || null,\n injected: routierPropMeta.injected !== undefined ? routierPropMeta.injected : null\n });\n continue;\n }\n\n // Convert JSON Schema property to Routier schema\n let schemaBuilder: any = convertJsonSchemaPropertyToRoutier(prop);\n\n // Apply Routier-specific modifiers (using type assertion for method chaining)\n // Note: Apply key() first as it's required for schema compilation\n // Check both property-level metadata and schema-level idProperties list\n const isKey = routierPropMeta?.isKey === true || idProperties.includes(routierPropName);\n if (isKey && typeof schemaBuilder.key === 'function') {\n schemaBuilder = schemaBuilder.key();\n }\n // Apply from() mapping early, as it's a fundamental property mapping\n if (routierPropMeta?.from && typeof schemaBuilder.from === 'function') {\n schemaBuilder = schemaBuilder.from(routierPropMeta.from as string);\n }\n if (routierPropMeta?.isIdentity && typeof schemaBuilder.identity === 'function') {\n schemaBuilder = schemaBuilder.identity();\n }\n if (routierPropMeta?.isReadonly && typeof schemaBuilder.readonly === 'function') {\n schemaBuilder = schemaBuilder.readonly();\n }\n if (routierPropMeta?.isDistinct && typeof schemaBuilder.distinct === 'function') {\n schemaBuilder = schemaBuilder.distinct();\n }\n // Before `.optional()` below, which is safe because `isSearchable` survives a wrapping\n // modifier — see `SchemaBase.isSearchable`. Rebuilding a schema that silently dropped\n // this would take a property's terms out of the index and change what queries match.\n if (routierPropMeta?.isSearchable && typeof schemaBuilder.searchable === 'function') {\n schemaBuilder = schemaBuilder.searchable();\n }\n // Apply optional if property is not required (nullable and optional are independent)\n if (!isRequired && typeof schemaBuilder.optional === 'function') {\n schemaBuilder = schemaBuilder.optional();\n }\n // Apply nullable if property allows null (nullable and optional are independent)\n if (prop.nullable === true || (Array.isArray(prop.type) && prop.type.includes('null'))) {\n if (typeof schemaBuilder.nullable === 'function') {\n schemaBuilder = schemaBuilder.nullable();\n }\n }\n if (routierPropMeta?.indexes && Array.isArray(routierPropMeta.indexes)) {\n if (typeof schemaBuilder.index === 'function') {\n schemaBuilder = schemaBuilder.index(...(routierPropMeta.indexes as string[]));\n }\n }\n\n // Apply default value if present (only static defaults, not function defaults)\n // hasDefault=true and defaultIsFunction=false means we have a static default value stored\n if (routierPropMeta?.hasDefault && !routierPropMeta.defaultIsFunction && routierPropMeta.hasOwnProperty('defaultValue')) {\n if (typeof schemaBuilder.default === 'function') {\n schemaBuilder = schemaBuilder.default(routierPropMeta.defaultValue);\n }\n }\n\n schemaDefinition[routierPropName] = schemaBuilder;\n }\n\n // Build base schema\n let schema = s.define(finalCollectionName, schemaDefinition);\n\n // Add computed properties via modify()\n if (computedProperties.length > 0) {\n schema = schema.modify(x => {\n const computedDefs: Record<string, any> = {};\n\n for (const computedProp of computedProperties) {\n if (computedProp.functionSource) {\n // Recreate the function from source code\n // The function signature is: (entity, collectionName, injected) => result\n // We use new Function() to create the function, but wrap it so toString() returns the arrow function\n let recreatedFn: any;\n try {\n const functionSource = computedProp.functionSource;\n\n // Parse the arrow function to extract parameters and body\n const arrowMatch = functionSource.match(/^\\(([^)]*)\\)\\s*=>\\s*(.+)$/s);\n\n if (!arrowMatch) {\n throw new Error('Function source is not an arrow function');\n }\n\n // Parse parameters\n const paramsStr = arrowMatch[1].trim();\n const params = paramsStr ? paramsStr.split(',').map(p => p.trim()).filter(p => p) : [];\n const body = arrowMatch[2].trim();\n\n // Create function body - if it's a block (starts with {), use as-is, otherwise wrap in return\n const functionBody = body.startsWith('{')\n ? body.slice(1, -1) // Remove outer braces\n : `return ${body}`;\n\n // Create the function using new Function()\n // If no parameters, call with just the body; otherwise spread the params\n const fn = params.length > 0\n ? new Function(...params, functionBody)\n : new Function(functionBody);\n\n // Wrap it so toString() returns the original arrow function string\n // This is needed because the schema system validates that functions are arrow functions\n recreatedFn = Object.assign(fn, {\n toString: () => functionSource\n });\n } catch (e) {\n // If we can't recreate the function, create a placeholder arrow function that throws\n recreatedFn = () => {\n throw new Error(`Cannot recreate computed property ${computedProp.name}: ${e instanceof Error ? e.message : 'unknown error'}`);\n };\n // Ensure toString returns an arrow function for validation\n Object.assign(recreatedFn, {\n toString: () => `() => { throw new Error(\"Cannot recreate computed property ${computedProp.name}\"); }`\n });\n }\n\n // Add computed property with optional injected value\n if (computedProp.isComputed) {\n computedDefs[computedProp.name] = x.computed(recreatedFn, computedProp.injected);\n } else {\n computedDefs[computedProp.name] = x.function(recreatedFn, computedProp.injected);\n }\n } else {\n // No function source available - create a placeholder\n computedDefs[computedProp.name] = computedProp.isComputed\n ? x.computed(() => {\n throw new Error(`Computed property ${computedProp.name} could not be rehydrated: function source not available`);\n })\n : x.function(() => {\n throw new Error(`Function property ${computedProp.name} could not be rehydrated: function source not available`);\n });\n }\n }\n\n return computedDefs;\n });\n }\n\n return schema;\n}\n\n/**\n * Converts a JSON Schema property definition to a Routier schema builder.\n */\nfunction convertJsonSchemaPropertyToRoutier(\n prop: Record<string, unknown>\n): SchemaBase<any, any> {\n const type = Array.isArray(prop.type)\n ? (prop.type as string[]).find(t => t !== 'null') || prop.type[0]\n : prop.type as string;\n\n // Check for date type - dates are serialized as string with format 'date-time'\n if (type === 'string' && prop.format === 'date-time') {\n return s.date();\n }\n\n switch (type) {\n case 'string':\n if (prop.enum && Array.isArray(prop.enum)) {\n return s.string(...(prop.enum as string[]));\n }\n return s.string();\n\n case 'number':\n case 'integer':\n if (prop.enum && Array.isArray(prop.enum)) {\n return s.number(...(prop.enum as number[]));\n }\n return s.number();\n\n case 'boolean':\n return s.boolean();\n\n case 'object':\n // Recurse into object properties\n if (prop.properties && typeof prop.properties === 'object') {\n const objectProps = prop.properties as Record<string, unknown>;\n const objectSchema: Record<string, any> = {};\n\n for (const [key, value] of Object.entries(objectProps)) {\n objectSchema[key] = convertJsonSchemaPropertyToRoutier(value as Record<string, unknown>);\n }\n\n return s.object(objectSchema);\n }\n return s.object({});\n\n case 'array':\n // Handle array items\n if (prop.items && typeof prop.items === 'object') {\n const itemsSchema = convertJsonSchemaPropertyToRoutier(prop.items as Record<string, unknown>);\n return s.array(itemsSchema as any);\n }\n return s.array(s.object({}) as any);\n\n default:\n // Fallback to object for unknown types\n return s.object({});\n }\n}\n\n/**\n * Attempts to extract type information from a compiled schema for better type inference.\n * \n * Note: TypeScript types are compile-time only, so we can't extract actual type information at runtime.\n * The Standard JSON Schema spec allows libraries to advertise their inferred types via the `types` property,\n * but this requires compile-time type information that isn't available at runtime.\n * \n * For proper type inference, consumers should use TypeScript's type system:\n * ```typescript\n * const schema = s.define(\"users\", { ... }).compile();\n * type User = InferType<typeof schema>;\n * type CreateUser = InferCreateType<typeof schema>;\n * ```\n * \n * @param compiledSchema - The compiled schema to extract type info from\n * @returns A description of the type names (for documentation purposes only)\n */\nexport function extractTypeInfo<T extends {}>(\n compiledSchema: CompiledSchema<T>\n): { inputType: string; outputType: string } {\n return {\n inputType: `InferCreateType<${compiledSchema.collectionName}>`,\n outputType: `InferType<${compiledSchema.collectionName}>`\n };\n}\n","import { CodeBuilder, SlotBlock } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo } from \"../../../schema/PropertyInfo\";\nimport { SchemaTypes } from \"../../../schema/types\";\n\nconst allowedTypes = new Set<SchemaTypes>([\n SchemaTypes.Array,\n SchemaTypes.Boolean,\n SchemaTypes.Date,\n SchemaTypes.Number,\n SchemaTypes.Object,\n SchemaTypes.String,\n SchemaTypes.Vector\n]);\n\nexport class SetComplexHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (allowedTypes.has(property.type)) {\n const selectorPath = property.getSelectrorPath({ parent: \"source\", assignmentType: \"FORCE_NULLABLE_OR_OPTIONAL\" });\n const slot = builder.get<SlotBlock>(\"assignments\");\n const entitySelectorPath = property.getAssignmentPath({ parent: \"source\" });\n const enrichedAssignmentPath = property.getAssignmentPath({ parent: \"destination\" });\n\n slot.if(`${selectorPath} != null`).appendBody(`${enrichedAssignmentPath} = ${entitySelectorPath}`);\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { NotApplicableHandler } from \"./types\";\nimport { SetComplexHandler } from \"./set/SetComplexHandler\";\n\nexport class SetHandlerBuilder {\n\n build() {\n const handler = new SetComplexHandler();\n\n handler.setNext(new NotApplicableHandler());\n\n return handler;\n }\n}","import { SchemaFunction } from './table/SchemaFunction';\nimport { SchemaTransform } from './table/SchemaTransform';\nimport { SchemaComputed } from './table/SchemaComputed';\nimport { SchemaBase } from \"./property/base/SchemaBase\";\nimport { PropertyInfo } from './PropertyInfo';\nimport { CodeBuilder, FunctionBuilder, SlotBlock } from '../codegen';\nimport { EnrichmentHandlerBuilder } from '../codegen/handlers/EnrichmentHandlerBuilder';\nimport { MergeHandlerBuilder } from '../codegen/handlers/MergeHandlerBuilder';\nimport { PrepareHandlerBuilder } from '../codegen/handlers/PrepareHandlerBuilder';\nimport { StripHandlerBuilder } from '../codegen/handlers/StripHandlerBuilder';\nimport { CloneHandlerBuilder } from '../codegen/handlers/CloneHandlerBuilder';\nimport { CompareHandlerBuilder } from '../codegen/handlers/CompareHandlerBuilder';\nimport { DeserializeHandlerBuilder } from '../codegen/handlers/DeserializeHandlerBuilder';\nimport { HashTypeHandlerBuilder } from '../codegen/handlers/HashTypeHandlerBuilder';\nimport { IdSelectorHandlerBuilder } from '../codegen/handlers/IdSelectorHandlerBuilder';\nimport { HashHandlerBuilder } from '../codegen/handlers/HashHandlerBuilder';\nimport { EnableChangeTrackingHandlerBuilder } from '../codegen/handlers/EnableChangeTrackingHandlerBuilder';\nimport { FreezeHandlerBuilder } from '../codegen/handlers/FreezeHandlerBuilder';\nimport { SchemaError } from '../errors/SchemaError';\nimport { SerializeHandlerBuilder } from \"../codegen/handlers/SerializeHandlerBuilder\";\nimport { hash, logger } from \"../utilities\";\nimport { CollectionName, CompiledSchema, CompiledSchemaCore, CompiledSchemaWithMetadata, GetHashTypeFunction, HashFunction, HashType, IdType, Index, InferCreateType, InferType, Prepare, Preprocess, SchemaId, SchemaTypes, SetProperties, PropertyTransform } from './types';\nimport { DeepPartial } from '../types';\nimport { SchemaSubscription, SchemaSubscriptionOptions } from './communication/broadcast';\nimport { CompareIdsHandlerBuilder } from '../codegen/handlers/CompareIdsHandlerBuilder';\nimport { StandardJSONSchemaV1, createStandardJsonSchemaProps, rehydrateSchemaFromJsonString } from './utils/standardJsonSchema';\nimport { SetHandlerBuilder } from '../codegen/handlers';\n\nfunction assertPropertyHandled(generatorName: string, property: PropertyInfo<any>, result: unknown): asserts result is {} {\n if (result == null) {\n throw new Error(`Schema compilation failed: no '${generatorName}' code generator handles property '${property.getAssignmentPath()}' (type: ${property.type}). Add a handler for this property shape or mark it not applicable in the ${generatorName} chain.`);\n }\n}\n\nfunction createChangeTracker() {\n const DIRTY_ENTITY_MARKER: string = \"isDirty\";\n const CHANGES_ENTITY_KEY: string = \"changes\";\n const ORIGINAL_ENTITY_KEY: string = \"original\";\n const PAUSED_ENTITY_KEY: string = \"isPaused\";\n const TRACKING_KEY: string = \"__tracking__\";\n const PROXY_MARKER: string = \"__isProxy__\";\n\n return <TEntity extends {}>(entity: TEntity, path?: string, parent?: TEntity) => {\n\n const proxyHandler: ProxyHandler<TEntity> = {\n set(entity, property, value) {\n const indexableEntity: { [key: string]: any } = entity;\n\n // if values are the same, do nothing\n //\n // Checked before `String(property)` on purpose. A write that changes\n // nothing is the common case, not the exception: `schema.merge` copies\n // every property of a re-read row into the attached entity, and on an\n // unchanged row every one of those writes lands here and returns.\n // Building the string key first made that path cost 156ns a write, of\n // which 125ns was the `String()` call alone; checking first takes it to\n // 31ns, against a 14ns floor for the same writes on a plain object.\n // Indexing by `property` rather than by `key` reads the same slot for\n // string keys, and the correct one for symbols (which `String()` would\n // have mangled into a \"Symbol(x)\" lookup).\n const originalValue = indexableEntity[property as string];\n\n if (originalValue === value) {\n return true;\n }\n\n const key = String(property);\n const resolvedParent: { [key: string]: any } = parent ?? entity;\n\n if (resolvedParent[TRACKING_KEY] == null) {\n // defineProperty, not assignment: a plain assignment creates an ENUMERABLE\n // property, and this is the lazy path that runs on the first tracked write —\n // so every entity the caller had edited came back from a query with\n // `__tracking__` visible to Object.entries, JSON.stringify and any deep\n // compare (defect #26). Both bootstrap paths below already define it\n // non-enumerable; this one was the outlier.\n Object.defineProperty(resolvedParent, TRACKING_KEY, {\n value: {\n [CHANGES_ENTITY_KEY]: {},\n [DIRTY_ENTITY_MARKER]: false,\n [ORIGINAL_ENTITY_KEY]: {},\n [PAUSED_ENTITY_KEY]: false\n },\n configurable: true,\n writable: true,\n enumerable: false\n });\n }\n\n if (key == TRACKING_KEY) {\n return true;\n }\n\n if (resolvedParent[TRACKING_KEY] != null && resolvedParent[TRACKING_KEY][PAUSED_ENTITY_KEY] === true) {\n Reflect.set(indexableEntity, property, value);\n return true;\n }\n\n const resolvedPath = path == null ? key : `${path}.${key}`;\n const changes = resolvedParent[TRACKING_KEY];\n\n if (changes[CHANGES_ENTITY_KEY][resolvedPath] != null) {\n\n if (changes[ORIGINAL_ENTITY_KEY][resolvedPath] === value) {\n // we are changing the value back to the original value, remove the change\n //\n // These two stay `delete`, unlike the `__tracking__` sites on the entity\n // itself. Assigning undefined here would be read as \"still changed\" by\n // the isDirty count below, which asks Object.keys — and a key assigned\n // undefined is still a key. Counting only defined values does not rescue\n // it either: an original value of undefined is legitimate (a property\n // that was unset and then given a value), so a defined-value count would\n // report a genuinely dirty entity as clean. Removing the key is the only\n // representation that keeps \"present\" and \"changed\" the same question.\n //\n // The cost is bounded in a way the entity sites are not: these bags hold\n // one key per changed path, they are internal to the tracking record, and\n // this branch only runs when a value is set BACK to its original.\n delete changes[ORIGINAL_ENTITY_KEY][resolvedPath];\n delete changes[CHANGES_ENTITY_KEY][resolvedPath];\n } else {\n // track the change\n changes[CHANGES_ENTITY_KEY][resolvedPath] = value;\n }\n\n } else if (changes[CHANGES_ENTITY_KEY][resolvedPath] == null) {\n // don't keep updating, keep the original value\n changes[CHANGES_ENTITY_KEY][resolvedPath] = value;\n changes[ORIGINAL_ENTITY_KEY][resolvedPath] = originalValue;\n }\n\n const isDirty = Object.keys(changes[ORIGINAL_ENTITY_KEY]).length > 0;\n changes[DIRTY_ENTITY_MARKER] = isDirty;\n\n Reflect.set(indexableEntity, property, value);\n\n return true;\n },\n get(target, property, receiver) {\n\n if (property === PROXY_MARKER) {\n return true;\n }\n\n return Reflect.get(target, property, receiver);\n }\n }\n\n return new Proxy(entity, proxyHandler) as TEntity;\n }\n}\n\n\nexport class SchemaDefinition<T extends {}> extends SchemaBase<T, any> {\n\n instance: T;\n type = SchemaTypes.Definition;\n collectionName: CollectionName;\n\n constructor(collectionName: CollectionName, schema: T) {\n super();\n this.collectionName = collectionName;\n this.instance = schema;\n this.isNullable = false;\n this.isOptional = false;\n }\n\n /**\n * Creates a SchemaDefinition from a JSON string containing a JSON Schema.\n * Parses the JSON string, rehydrates the schema structure, and compiles it.\n * \n * @param jsonString - The JSON string containing the JSON Schema (typically from `schema['~standard'].jsonSchema.input()` or `output()`)\n * @param collectionName - Optional collection name override (if not present in JSON Schema metadata)\n * @returns A compiled schema ready to use\n * @throws Error if the JSON string is invalid or doesn't contain a valid JSON Schema\n * \n * @example\n * ```typescript\n * // Serialize a schema to JSON\n * const jsonSchema = mySchema['~standard'].jsonSchema.input({ target: 'draft-2020-12' });\n * const jsonString = JSON.stringify(jsonSchema);\n * \n * // Rehydrate from JSON string\n * const rehydratedSchema = SchemaDefinition.fromJson(jsonString);\n * // Schema is already compiled and ready to use\n * ```\n */\n static fromJson(jsonString: string, collectionName?: string): CompiledSchema<any> {\n const schemaDefinition = rehydrateSchemaFromJsonString(jsonString, collectionName);\n return schemaDefinition.compile();\n }\n\n /**\n * Standard JSON Schema V1 implementation.\n * Provides JSON Schema conversion for Routier schemas.\n */\n get '~standard'(): StandardJSONSchemaV1.Props<InferCreateType<T>, InferType<T>> {\n const schema = this.compile();\n\n return createStandardJsonSchemaProps(schema);\n }\n\n private createReturnFunction<TResult>(builder: CodeBuilder): TResult {\n const body = builder.toString();\n try {\n return Function(`return ${body}`) as TResult;\n } catch (e) {\n logger.error(`Error compiling schema function. Function Body: ${body}`)\n throw e;\n }\n }\n\n private createFunction<TResult>(builder: CodeBuilder, ...fnArgs: string[]): TResult {\n const body = builder.toString();\n\n try {\n return Function(...fnArgs, body) as TResult;\n } catch (e) {\n logger.error(`Error compiling schema function. Function Body: ${body}`)\n throw e;\n }\n }\n\n modify<R>(builder: (d: {\n function: <UU, I = never>(fn: (entity: InferType<CompiledSchema<T>>, collectionName: CollectionName, injected: I) => UU, injected?: I) => SchemaFunction<UU, I, \"unmapped\">;\n computed: <UU, I = never>(fn: (entity: InferType<CompiledSchema<T>>, collectionName: CollectionName, injected: I) => UU, injected?: I) => SchemaComputed<UU, I, \"computed\" | \"unmapped\">;\n /**\n * Replaces a property with a transformed version of itself.\n *\n * `computed` derives a value one way and cannot come back. A transform declares both\n * directions, so the property keeps its type and only its STORED form changes.\n *\n * ```ts\n * .modify(x => ({\n * ssn: x.transform(s.string(), {\n * to: (value, keys) => myEncrypt(value, keys),\n * from: (text, keys) => myDecrypt(text, keys),\n * stores: SchemaTypes.String,\n * }, myKeys),\n * }))\n * ```\n *\n * `to` and `from` may be async and are held as live references, so they can close\n * over whatever they need. `injected` is there for when passing it explicitly reads\n * better than capturing it.\n */\n transform: <UU>(transform: PropertyTransform<UU>) => SchemaTransform<UU>;\n }) => R) {\n\n const b = {\n function: <UU, I = never>(fn: (entity: InferType<CompiledSchema<T>>, collectionName: CollectionName, injected?: I) => UU, injected?: I) => new SchemaFunction<UU, I, \"unmapped\">(fn as any, injected),\n computed: <UU, I = never>(fn: (entity: InferType<CompiledSchema<T>>, collectionName: CollectionName, injected?: I) => UU, injected?: I) => new SchemaComputed<UU, I, \"computed\" | \"unmapped\">(fn as any, injected),\n transform: <UU>(transform: PropertyTransform<UU>) => new SchemaTransform<UU>(transform)\n }\n\n const r = builder(b) as Record<string, unknown>;\n\n /**\n * A transform replaces the property it was assigned to, so it is bound here rather\n * than being handed its own property to repeat. `.modify()` already knows which one\n * is meant — it is the key.\n */\n for (const [name, value] of Object.entries(r)) {\n if (value instanceof SchemaTransform) {\n const underlying = (this.instance as Record<string, unknown>)[name];\n\n if (underlying == null) {\n throw new Error(\n `transform() was assigned to '${name}', which is not a property of ` +\n `'${this.collectionName}'. A transform replaces an existing property; ` +\n 'to add a new one, use computed().'\n );\n }\n\n value.bindTo(underlying as never);\n }\n }\n\n return new SchemaDefinition<R & T>(this.collectionName, { ...this.instance, ...r } as R & T);\n }\n\n private _iterate(\n instance: SchemaBase<any, any>,\n callback: (property: PropertyInfo<any>) => void\n ) {\n const explore: {\n path: string | null;\n instance:\n | SchemaBase<any, any>\n | { [key: string]: SchemaBase<any, any> };\n parents: {\n schema: { [key: string]: SchemaBase<any, any> };\n propertyInfo: PropertyInfo<any>;\n }[];\n propertyInfo: PropertyInfo<any> | null;\n }[] = [\n { path: null, instance, parents: [], propertyInfo: null }\n ];\n const properties: PropertyInfo<any>[] = [];\n\n for (let i = 0; i < explore.length; i++) {\n const item = explore[i];\n\n if (item.instance.type === SchemaTypes.Definition) {\n explore.push({\n path: null,\n instance: item.instance.instance,\n parents: [],\n propertyInfo: null\n });\n continue;\n }\n\n const instanceObj = item.instance as {\n [key: string]: SchemaBase<any, any>;\n };\n for (const key in instanceObj) {\n const propertyInstance = instanceObj[key] as SchemaBase<any, any>;\n const previousParent =\n item.parents.length === 0\n ? null\n : item.parents[item.parents.length - 1].propertyInfo;\n\n if (propertyInstance.type === SchemaTypes.Object) {\n const propertyInfo = new PropertyInfo<any>(\n propertyInstance,\n key,\n previousParent\n );\n explore.push({\n path: [item.path, key].filter((w) => w != null).join(\".\"),\n instance: propertyInstance.instance,\n parents: [\n ...item.parents,\n { schema: instanceObj, propertyInfo: propertyInfo }\n ],\n propertyInfo\n });\n\n if (previousParent === null) {\n properties.push(propertyInfo);\n continue;\n }\n\n previousParent.children.push(propertyInfo);\n continue;\n }\n\n const childPrimitivePropertyInfo = new PropertyInfo<any>(\n (item.instance as any)[key],\n key,\n previousParent\n );\n if (previousParent === null) {\n properties.push(childPrimitivePropertyInfo);\n continue;\n }\n\n previousParent.children.push(childPrimitivePropertyInfo);\n }\n }\n\n // Recursively trigger callbacks on properties and their children\n function recursiveCallback(prop: PropertyInfo<any>) {\n callback(prop);\n for (const child of prop.children) {\n recursiveCallback(child);\n }\n }\n\n for (const prop of properties) {\n recursiveCallback(prop);\n }\n }\n\n compile<TMetadata>(metadata: TMetadata): CompiledSchemaWithMetadata<T, TMetadata>\n compile(): CompiledSchema<T>;\n compile<TMetadata>(metadata?: TMetadata): CompiledSchema<T> | CompiledSchemaWithMetadata<T, TMetadata> {\n\n try {\n const properties: PropertyInfo<T>[] = [];\n const propertyMap: Map<string, PropertyInfo<T>> = new Map<string, PropertyInfo<T>>();\n\n const enrichmentHandlerBuilder = new EnrichmentHandlerBuilder();\n const mergeHandlerFactory = new MergeHandlerBuilder();\n const prepareHandlerBuilder = new PrepareHandlerBuilder();\n const stripHandlerBuilder = new StripHandlerBuilder();\n const cloneHandlerBuilder = new CloneHandlerBuilder();\n const compareHandlerBuilder = new CompareHandlerBuilder();\n const deserializeHandlerBuilder = new DeserializeHandlerBuilder();\n const hashTypeHandlerBuilder = new HashTypeHandlerBuilder();\n const idSelectorHandlerBuilder = new IdSelectorHandlerBuilder();\n const hashHandlerBuilder = new HashHandlerBuilder();\n const enableChangeTrackingHandlerBuilder = new EnableChangeTrackingHandlerBuilder();\n const freezeHandlerBuilder = new FreezeHandlerBuilder();\n const serializeHandlerBuilder = new SerializeHandlerBuilder();\n const compareIdsHandlerBuilder = new CompareIdsHandlerBuilder();\n const setHandlerBuilder = new SetHandlerBuilder();\n\n const enricher = enrichmentHandlerBuilder.build();\n const merge = mergeHandlerFactory.build();\n const prepare = prepareHandlerBuilder.build();\n const strip = stripHandlerBuilder.build();\n const clone = cloneHandlerBuilder.build();\n const compare = compareHandlerBuilder.build();\n const deserialize = deserializeHandlerBuilder.build();\n const hashTypeHandler = hashTypeHandlerBuilder.build();\n const idSelectorHandler = idSelectorHandlerBuilder.build();\n const hashHandler = hashHandlerBuilder.build();\n const enableChangeTrackingHandler = enableChangeTrackingHandlerBuilder.build();\n const freezeHandler = freezeHandlerBuilder.build();\n const serializeHandler = serializeHandlerBuilder.build();\n const compareIdsHandler = compareIdsHandlerBuilder.build();\n const setHandlerHanlder = setHandlerBuilder.build();\n\n const changeTrackingCodeBuilder = new CodeBuilder();\n changeTrackingCodeBuilder.raw(`${createChangeTracker.toString()}`);\n changeTrackingCodeBuilder.slot(\"declarations\").variable(\"enableChangeTracking\").value('createChangeTracker()');\n // Nested proxies are installed by assigning through already-proxied parents;\n // pause tracking during setup so those writes don't register as changes\n changeTrackingCodeBuilder.slot(\"pause\").raw('\\tconst hadTracking = entity.__tracking__ != null;\\n\\tif (!hadTracking) { Object.defineProperty(entity, \"__tracking__\", { value: { changes: {}, isDirty: false, original: {}, isPaused: false }, configurable: true, writable: true, enumerable: false }); }\\n\\tconst wasPaused = entity.__tracking__.isPaused;\\n\\tentity.__tracking__.isPaused = true;');\n changeTrackingCodeBuilder.slot(\"assignment\");\n // Tracking metadata is created lazily on the first real write; only restore\n // what already existed, never leave the bootstrap behind.\n //\n // Cleared by redefining the property, not by `delete`. `delete` moves the object\n // into V8 dictionary mode permanently — it never returns to fast properties, so\n // every later read of every property on the entity pays a dictionary lookup,\n // measured at ~43% slower reads.\n //\n // defineProperty rather than plain assignment because `entity` here is whatever\n // the caller passed, and enableChangeTracking is public API, so it may already be\n // a change-tracking proxy. That proxy's set trap answers writes to `__tracking__`\n // with a bare `return true` and drops them, which would leave this bootstrap\n // behind. The handler defines no defineProperty trap, so this reaches the target,\n // and repeating the descriptor keeps the property non-enumerable.\n changeTrackingCodeBuilder.slot(\"return\").raw('\\tif (hadTracking) { entity.__tracking__.isPaused = wasPaused; } else { delete entity.__tracking__; }\\n\\treturn enableChangeTracking(entity);');\n\n const freezeCodeBuilder = new CodeBuilder();\n freezeCodeBuilder.slot(\"assignment\");\n freezeCodeBuilder.slot(\"return\").raw('\\treturn Object.freeze(entity);');\n\n const enricherCodeBuilder = new CodeBuilder();\n\n const enricherFunctionRoot = enricherCodeBuilder.factory(\"factory\", { name: \"factory\" }).parameters({ name: \"collectionName\", value: this.collectionName });\n enricherFunctionRoot.slot(\"changeTracker\").raw(`${createChangeTracker.toString()}`);\n enricherFunctionRoot.slot(\"changeTrackerFunction\").raw(`\\tconst changeTracker = createChangeTracker();`);\n const enricherFunctionBody = enricherFunctionRoot.function(undefined, { name: \"function\" }).parameters(\"entity\", \"changeTrackingType\").return();\n\n enricherFunctionBody.slot(\"enableChangeTracking\")\n .variable(\"enableChangeTracking\")\n .value('changeTrackingType === \"proxy\" ? changeTracker : e => e');\n\n enricherFunctionBody.slot(\"append\");\n enricherFunctionBody.slot(\"enriched\");\n // Nested proxies are installed by assigning through already-proxied parents;\n // pause tracking during setup so those writes don't register as changes.\n // Non-enumerable: computed properties run after this and may JSON.stringify\n // the entity (e.g. content-hash ids) — the bootstrap must not change their input\n enricherFunctionBody.slot(\"declarations\").raw('\\tif (changeTrackingType === \"proxy\") { Object.defineProperty(enriched, \"__tracking__\", { value: { changes: {}, isDirty: false, original: {}, isPaused: true }, configurable: true, writable: true, enumerable: false }); }');\n enricherFunctionBody.slot(\"assignment\");\n enricherFunctionBody.slot(\"ifs\");\n enricherFunctionBody.slot(\"tracking\").if('changeTrackingType === \"immutable\"', { name: \"freeze\" });\n // The paused bootstrap tracking is removed rather than unpaused: tracking\n // metadata is created lazily on the first real write, and callers assert\n // an untouched entity carries none. Proxy mode recreates it on the first\n // tracked write (see defect #2).\n //\n // Cleared by assignment rather than `delete`, because `delete` drops the entity\n // into V8 dictionary mode for the rest of its life — and this line runs on EVERY\n // entity that comes off a read. Assignment keeps the non-enumerable descriptor\n // installed above, so the property still stays out of Object.keys and JSON.\n //\n // The condition is now \"proxy\" rather than \"not immutable\", which is the same set\n // of entities in practice: `enriched` is a fresh object literal built from schema\n // properties, so ONLY the proxy branch above ever puts `__tracking__` on it. Under\n // `delete` the wider condition was harmless because deleting an absent property is\n // a no-op; under assignment it would CREATE an enumerable `__tracking__` on every\n // diff- and readonly-tracked entity and leak it into persistence. Defect #16's\n // stray `{ isPaused: false }` residue stays fixed — nothing is left behind here.\n enricherFunctionBody.slot(\"return\").raw('\\tif (changeTrackingType === \"proxy\") { enriched.__tracking__ = undefined; }\\n\\treturn enableChangeTracking(enriched);');\n\n const preprocessCodeBuilder = new CodeBuilder();\n preprocessCodeBuilder.slot(\"main\");\n preprocessCodeBuilder.slot(\"return\").raw(` return result;`);\n\n const postprocessCodeBuilder = new CodeBuilder();\n postprocessCodeBuilder.slot(\"main\");\n postprocessCodeBuilder.slot(\"return\").raw(` return result;`);\n\n const setCodeBuilder = new CodeBuilder();\n setCodeBuilder.slot(\"assignments\");\n setCodeBuilder.slot(\"ifs\");\n\n const mergeCodeBuilder = new CodeBuilder();\n\n const mergeFunctionRoot = mergeCodeBuilder.factory(\"factory\", { name: \"factory\" }).parameters({ name: \"collectionName\", value: this.collectionName });\n const mergeFunctionBody = mergeFunctionRoot.function(undefined, { name: \"function\" }).parameters(\"destination\", \"source\").return();\n\n // The pause bootstrap exists so a PROXIED destination does not record the\n // merge's own writes as changes. A destination with no tracking (diff and\n // immutable modes) gets a temporary bootstrap so the same generated code runs —\n // and unpause() DELETES it again, because leaving it behind is the\n // `{ isPaused: false }` residue of defect #16, this time on the merge path.\n const pauseFunctionBody = mergeFunctionBody.function(\"pause\")\n .appendBody(\"// initiate change tracking if needed\");\n\n pauseFunctionBody.if(\"destination.__tracking__ == null\")\n // Non-enumerable for the same reason the enricher's bootstrap is: computed\n // properties can JSON.stringify the entity while this is installed, and the\n // bootstrap must not change their input. It is removed again below either way.\n .appendBody('Object.defineProperty(destination, \"__tracking__\", { value: {}, configurable: true, writable: true, enumerable: false });')\n .appendBody(\"installedTrackingBootstrap = true;\");\n\n pauseFunctionBody.appendBody(\"destination.__tracking__.isPaused = true;\");\n\n const unpauseFunctionBody = mergeFunctionBody.function(\"unpause\")\n .appendBody(\"// unpause change tracking, removing a bootstrap this merge installed\");\n\n // Redefined to undefined rather than deleted, so the merged entity keeps its fast\n // properties — `delete` would put it in dictionary mode for good.\n //\n // It must be defineProperty and NOT assignment. `destination` is an attached,\n // proxied entity, and the change tracker's set trap answers writes to\n // `__tracking__` with a bare `return true`, dropping them. Assigning here is\n // therefore a silent no-op that leaves the `{}` bootstrap installed by pause() in\n // place — and the next write through the proxy reads `changes.changes` off that\n // bootstrap and throws. defineProperty is not intercepted, because the handler\n // declares no defineProperty trap.\n unpauseFunctionBody.if(\"installedTrackingBootstrap === true\")\n .appendBody(\"delete destination.__tracking__;\")\n .appendBody(\"return;\");\n\n unpauseFunctionBody.if(\"destination.__tracking__ != null\")\n .appendBody(\"destination.__tracking__.isPaused = false;\");\n\n mergeFunctionBody.slot(\"header\").raw(`let installedTrackingBootstrap = false;\n pause()`);\n mergeFunctionBody.slot(\"assignments\");\n mergeFunctionBody.slot(\"ifs\");\n mergeFunctionBody.slot(\"return\").raw(`\n unpause();\n\n return destination;`);\n\n const prepareCodeBuilder = new CodeBuilder();\n prepareCodeBuilder.slot(\"result\");\n prepareCodeBuilder.slot(\"assignments\");\n prepareCodeBuilder.slot(\"return\").raw(` return result;`);\n\n const stripCodeBuilder = new CodeBuilder();\n stripCodeBuilder.slot(\"result\");\n stripCodeBuilder.slot(\"return\").raw(` return result;`);\n\n const cloneCodeBuilder = new CodeBuilder();\n cloneCodeBuilder.slot(\"result\").raw(\"const result = {};\");;\n cloneCodeBuilder.slot(\"assignments\");\n cloneCodeBuilder.slot(\"if\");\n cloneCodeBuilder.slot(\"return\").raw(` return result;`);\n\n const compareCodeBuilder = new CodeBuilder();\n compareCodeBuilder.slot(\"result\");\n compareCodeBuilder.slot(\"return\").raw(` return result;`);\n\n const compareIdsCodeBuilder = new CodeBuilder();\n compareIdsCodeBuilder.slot(\"ifs\");\n compareIdsCodeBuilder.slot(\"return\").raw(` return true;`);\n\n const deserializeCodeBuilder = new CodeBuilder();\n deserializeCodeBuilder.slot(\"functions\");\n deserializeCodeBuilder.slot(\"result\");\n deserializeCodeBuilder.slot(\"if\");\n deserializeCodeBuilder.slot(\"return\").raw(` return entity;`);\n\n const serializeCodeBuilder = new CodeBuilder();\n serializeCodeBuilder.slot(\"result\").raw(\"const result = {};\");\n serializeCodeBuilder.slot(\"assignments\");\n serializeCodeBuilder.slot(\"functions\");\n serializeCodeBuilder.slot(\"if\");\n serializeCodeBuilder.slot(\"return\").raw(` return result;`);\n\n const idSelectorCodeBuilder = new CodeBuilder();\n idSelectorCodeBuilder.slot(\"result\");\n idSelectorCodeBuilder.slot(\"return\").raw(` return result;`);\n\n const hashTypeCodeBuilder = new CodeBuilder();\n hashTypeCodeBuilder.slot(\"ifs\");\n hashTypeCodeBuilder.slot(\"return\").raw(` return \"Ids\";`);\n\n const hashCodeBuilder = new CodeBuilder();\n hashCodeBuilder.slot(\"functions\").raw(`\n function stringifyDate(d) {\n\n if (d == null) {\n return \"\";\n }\n\n if (typeof d === \"string\") {\n return d;\n }\n\n if (d.getTime != null) {\n return \"\" + d.getTime();\n }\n\n return d.toString();\n } \n`);\n const hashCodeBuilderIfBlock = hashCodeBuilder.if(`type === \"Ids\"`, { name: \"hash-id-if\" });\n hashCodeBuilderIfBlock.slot(\"if-body\");\n hashCodeBuilderIfBlock.appendBody(\"return result\");\n hashCodeBuilder.slot(\"hash-object-return\");\n hashCodeBuilder.raw(` return result;`)\n\n const idProperties: PropertyInfo<any>[] = [];\n const allPropertyNamesAndPaths: string[] = [];\n let hashType: HashType = HashType.Ids;\n let hasIdentities = false;\n let hasIdentityKeys = false;\n\n this._iterate(this, (property) => {\n\n properties.push(property);\n propertyMap.set(property.id, property);\n allPropertyNamesAndPaths.push(property.getSelectrorPath({ parent: \"entity\" }));\n\n if (property.isIdentity === true) {\n hasIdentities = true;\n }\n\n if (property.isKey === true) {\n idProperties.push(property);\n }\n\n if (property.isKey === true && property.isIdentity === true) {\n hasIdentityKeys = true;\n }\n\n // Every chain must claim every property. A null return means no\n // handler matched, and silently omitting the property from the\n // generated function corrupts data — fail the compile instead.\n assertPropertyHandled(\"enrich\", property, enricher.handle(property, enricherCodeBuilder));\n assertPropertyHandled(\"merge\", property, merge.handle(property, mergeCodeBuilder));\n assertPropertyHandled(\"prepare\", property, prepare.handle(property, prepareCodeBuilder));\n assertPropertyHandled(\"strip\", property, strip.handle(property, stripCodeBuilder));\n assertPropertyHandled(\"clone\", property, clone.handle(property, cloneCodeBuilder));\n assertPropertyHandled(\"compare\", property, compare.handle(property, compareCodeBuilder));\n assertPropertyHandled(\"deserialize\", property, deserialize.handle(property, deserializeCodeBuilder));\n assertPropertyHandled(\"serialize\", property, serializeHandler.handle(property, serializeCodeBuilder))\n assertPropertyHandled(\"hashType\", property, hashTypeHandler.handle(property, hashTypeCodeBuilder));\n assertPropertyHandled(\"idSelector\", property, idSelectorHandler.handle(property, idSelectorCodeBuilder));\n assertPropertyHandled(\"hash\", property, hashHandler.handle(property, hashCodeBuilder));\n assertPropertyHandled(\"enableChangeTracking\", property, enableChangeTrackingHandler.handle(property, changeTrackingCodeBuilder));\n assertPropertyHandled(\"freeze\", property, freezeHandler.handle(property, freezeCodeBuilder));\n assertPropertyHandled(\"compareIds\", property, compareIdsHandler.handle(property, compareIdsCodeBuilder));\n assertPropertyHandled(\"set\", property, setHandlerHanlder.handle(property, setCodeBuilder));\n });\n\n if (idProperties.length === 0) {\n throw new Error(`Schema must have a key. Use .key() to mark a property as a key. Collection Name: ${this.collectionName}`)\n }\n\n /**\n * The two things `.searchable()` cannot express in its own type.\n *\n * It is NOT checked here that the property is a string. The builder gates that:\n * `searchable()` exists on `SchemaString`, and on `SchemaOptional`/`SchemaNullable`\n * only when their `instance` is a string, so `s.number().optional().searchable()`\n * does not compile. A builder that offers a method and then throws has gated\n * nothing.\n *\n * A string nested in an `s.object()` does type-check, and cannot be indexed: v1\n * keys index rows by a ROOT property name, so a nested one has nowhere to be\n * recorded. Rejected rather than ignored — a silently unindexed property returns no\n * rows for a query the caller believes is covered.\n *\n * A property NAME longer than 100 characters breaks the index key's length budget.\n * The key is `${term}|${field}|${sourceId}` in a column declared `VARCHAR(255)`, and\n * the field name is the only unbounded part of it. See \"The index collection\" in\n * specs/full-text-search.md.\n */\n for (const property of properties) {\n\n if (property.isSearchable === false) {\n continue;\n }\n\n if (property.parent != null) {\n throw new Error(\n `searchable() is declared on '${property.getAssignmentPath()}', which is nested inside another property. ` +\n `Full-text search indexes root-level string properties only. Collection Name: ${this.collectionName}`\n );\n }\n\n if (property.name.length > 100) {\n throw new Error(\n `searchable() is declared on '${property.name}', whose name is ${property.name.length} characters. ` +\n `A searchable property name must be 100 characters or fewer, so the search index key fits its column. ` +\n `Collection Name: ${this.collectionName}`\n );\n }\n\n // The index key is `${term}|${field}|${sourceId}`, and it is only unambiguous\n // because no part of it can contain the separator. The default tokenizer cannot\n // emit one — it splits on anything that is not a letter or digit — so the field\n // name is the only piece that could.\n if (property.name.includes(\"|\")) {\n throw new Error(\n `searchable() is declared on '${property.name}', whose name contains '|'. ` +\n `That character separates the parts of a search index key and cannot appear in a field name. ` +\n `Collection Name: ${this.collectionName}`\n );\n }\n }\n\n const enrichParams = enricherFunctionRoot.getParameters();\n const mergeParams = mergeFunctionRoot.getParameters();\n\n const enrichGenerator = this.createReturnFunction<Function>(enricherCodeBuilder);\n const mergeGenerator = this.createReturnFunction<Function>(mergeCodeBuilder);\n\n // After enricher is used, we modify it to be deserialize and enrich\n enricherFunctionBody.get<SlotBlock>(\"append\").insert(deserializeCodeBuilder.get<SlotBlock>(\"functions\"));\n enricherFunctionBody.get<SlotBlock>(\"append\").insert(deserializeCodeBuilder.get<SlotBlock>(\"result\"));\n enricherFunctionBody.get<SlotBlock>(\"append\").insert(deserializeCodeBuilder.get<SlotBlock>(\"if\"));\n enricherFunctionRoot.replace(\"function\", new FunctionBuilder(undefined).parameters(\"unserialized\", \"changeTrackingType\").return());\n\n const postProcessGenerator = this.createReturnFunction<Function>(enricherCodeBuilder);\n const postProcessParams = enricherFunctionRoot.getParameters();\n\n // Combine prepare and serialize\n preprocessCodeBuilder.get<SlotBlock>(\"main\").insert(prepareCodeBuilder.get<SlotBlock>(\"result\"));\n preprocessCodeBuilder.get<SlotBlock>(\"main\").insert(prepareCodeBuilder.get<SlotBlock>(\"assignments\"));\n\n preprocessCodeBuilder.get<SlotBlock>(\"main\").insert(serializeCodeBuilder.get<SlotBlock>(\"assignments\"));\n preprocessCodeBuilder.get<SlotBlock>(\"main\").insert(serializeCodeBuilder.get<SlotBlock>(\"functions\"));\n preprocessCodeBuilder.get<SlotBlock>(\"main\").insert(serializeCodeBuilder.get<SlotBlock>(\"if\"));\n\n const getIdsFunction = this.createFunction<(entity: InferType<T>) => [IdType]>(idSelectorCodeBuilder, \"entity\");\n const getHashTypeFunction = this.createFunction<GetHashTypeFunction<T>>(hashTypeCodeBuilder, \"entity\");\n const prepareFunction = this.createFunction<Prepare<T>>(prepareCodeBuilder, \"entity\");\n const cloneFunction = this.createFunction<(entity: InferType<T>) => InferType<T>>(cloneCodeBuilder, \"entity\");\n\n /**\n * `clone`, but for records that are still in the STORAGE shape.\n *\n * Built on first use rather than at compile time. Generating it costs a full pass over\n * the property tree plus a `Function` compile, and only stores that hold records in\n * storage shape ever ask for it, so a schema that is never read through one pays\n * nothing. After the first call it is the same generated function as `clone`.\n */\n let storageCloneFunction: ((entity: InferType<T>) => InferType<T>) | null = null;\n const cloneStorageFunction = (entity: InferType<T>): InferType<T> => {\n\n if (storageCloneFunction == null) {\n const storageCloneCodeBuilder = new CodeBuilder();\n\n // Undeclared columns are carried across; declared ones are left to the\n // generated deep-copy code below. This is the one place this differs from\n // `clone`, and both halves of it matter.\n //\n // Carrying them at all: a stored record can hold columns the schema never\n // declared, and this copier replaces `structuredClone`, which kept them.\n // ConcurrencyDbPlugin depends on exactly that — it appends a synthetic\n // `__version` property carrying a `from` name for the express purpose of\n // pushing reads onto this path, so its hidden column survives the copy and the\n // wrapper can observe the row's version. Drop the token and every read looks\n // unversioned, so optimistic concurrency stops detecting conflicts silently.\n //\n // Skipping the declared ones: a blanket `{ ...entity }` would seed the result\n // with the SOURCE's nested objects, and the child handlers then write their\n // copies into those shared references — mutating the record the caller was\n // copying to get away from.\n // Compared inline rather than against a Set: the set would be rebuilt on every\n // call, and this runs once per record on every read.\n const isDeclared = properties\n .filter(property => property.parent == null)\n .map(property => `key === ${JSON.stringify(property.getResolvedName())}`)\n .join(\" || \");\n\n const skipDeclared = isDeclared.length === 0 ? \"\" : `if (${isDeclared}) { continue; }\\n `;\n\n storageCloneCodeBuilder.slot(\"result\").raw(\n `const result = {};\\n` +\n ` for (const key in entity) {\\n` +\n ` if (Object.hasOwn(entity, key) === false) { continue; }\\n` +\n ` ${skipDeclared}result[key] = entity[key];\\n` +\n ` }`\n );\n storageCloneCodeBuilder.slot(\"assignments\");\n storageCloneCodeBuilder.slot(\"if\");\n storageCloneCodeBuilder.slot(\"return\").raw(` return result;`);\n\n const storageClone = cloneHandlerBuilder.build(true);\n\n for (let i = 0, length = properties.length; i < length; i++) {\n assertPropertyHandled(\"cloneStorage\", properties[i], storageClone.handle(properties[i], storageCloneCodeBuilder));\n }\n\n storageCloneFunction = this.createFunction<(entity: InferType<T>) => InferType<T>>(storageCloneCodeBuilder, \"entity\");\n }\n\n return storageCloneFunction(entity);\n };\n const deserializeFunction = this.createFunction<(entity: InferType<T>) => InferType<T>>(deserializeCodeBuilder, \"unserialized\");\n const serializeFunction = this.createFunction<(entity: InferType<T>) => InferType<T>>(serializeCodeBuilder, \"entity\");\n const compareFunction = this.createFunction<(a: InferType<T>, b: InferType<T>) => boolean>(compareCodeBuilder, \"a\", \"b\");\n const stripFunction = this.createFunction<(entity: InferType<T>) => InferType<T>>(stripCodeBuilder, \"entity\");\n const hashFunction = this.createFunction<HashFunction<T>>(hashCodeBuilder, \"entity\", \"type\");\n const enableChangeTrackingFunction = this.createFunction<(entity: InferType<T>) => InferType<T>>(changeTrackingCodeBuilder, \"entity\");\n const freezeFunction = this.createFunction<(entity: InferType<T>) => InferType<T>>(freezeCodeBuilder, \"entity\");\n const compareIdsFunction = this.createFunction<(a: InferType<T>, b: InferType<T>) => boolean>(compareIdsCodeBuilder, \"a\", \"b\");\n const preprocessFunction = this.createFunction<Preprocess<T>>(preprocessCodeBuilder, \"entity\");\n const setFunction = this.createFunction<SetProperties<T>>(setCodeBuilder, \"destination\", \"source\");\n\n const enricherFactoryFunction = enrichGenerator();\n const postProcessFactoryFunction = postProcessGenerator();\n const mergeFactoryFunction = mergeGenerator();\n const postProcessFunction = postProcessFactoryFunction(...postProcessParams.map(w => w.value))\n const enricherFunction = enricherFactoryFunction(...enrichParams.map(w => w.value));\n const mergeFunction = mergeFactoryFunction(...mergeParams.map(w => w.value));\n\n const idPropertyNames = idProperties.map(w => w.name);\n const getId = (entity: InferType<T>) => {\n if (idPropertyNames.length > 1) {\n return hashFunction(entity, HashType.Ids) as IdType;\n }\n\n return getIdsFunction(entity as any)[0] as IdType;\n }\n\n const getProperty = (id: string) => propertyMap.get(id);\n const id = hash([...allPropertyNamesAndPaths, this.collectionName].join(\",\")) as SchemaId;\n\n // memoize this by the validProperties\n // TODO: See if we can generate a function to do this and eliminate loops\n const deserializePartial = (item: Record<string, unknown>, properties: PropertyInfo<T>[]) => {\n\n for (let i = 0, length = properties.length; i < length; i++) {\n const property = properties[i];\n const value = property.getValue(item);\n\n if (value == null) {\n continue;\n }\n\n const deserialized = property.deserialize(value);\n property.setValue(item, deserialized);\n }\n\n return item as DeepPartial<InferType<T>>;\n }\n\n const result: CompiledSchemaCore<T> = {\n preprocess: preprocessFunction,\n postprocess: postProcessFunction,\n set: setFunction,\n getId,\n getProperty,\n properties,\n idProperties,\n hasIdentities,\n hashType,\n getHashType: getHashTypeFunction,\n merge: mergeFunction,\n prepare: prepareFunction,\n clone: cloneFunction,\n cloneStorage: cloneStorageFunction,\n deserializePartial,\n deserialize: deserializeFunction,\n serialize: serializeFunction,\n compare: compareFunction,\n compareIds: compareIdsFunction,\n strip: stripFunction,\n hash: hashFunction,\n id,\n getIds: getIdsFunction,\n enrich: enricherFunction,\n collectionName: this.collectionName,\n hasIdentityKeys,\n freeze: freezeFunction,\n enableChangeTracking: enableChangeTrackingFunction,\n definition: this,\n getIndexes: () => {\n\n const indexes: Index[] = [];\n\n for (let i = 0, length = properties.length; i < length; i++) {\n const property = properties[i];\n\n if (property.indexes.length === 0) {\n continue; // No Index\n }\n\n for (let j = 0, l = property.indexes.length; j < l; j++) {\n const indexName = property.indexes[j];\n\n // Test for compound indexes\n const connections = properties.filter(w =>\n w !== property && // Don't match with self\n w.indexes.some(index => index === indexName)\n );\n\n const indexedProperties = [property, ...connections];\n\n if (indexedProperties.length === 1) {\n // Not a compound property\n if (indexedProperties[0].isKey) {\n indexes.push({\n properties: indexedProperties,\n type: \"primary-key\",\n name: indexName\n });\n continue;\n }\n\n if (indexedProperties[0].isDistinct) {\n indexes.push({\n properties: indexedProperties,\n type: \"unique\",\n name: indexName\n });\n continue;\n }\n\n indexes.push({\n properties: indexedProperties,\n type: \"single\",\n name: indexName\n });\n continue;\n }\n\n if (indexes.some(w => w.name === indexName)) {\n continue; // Already in a compound index\n }\n\n indexes.push({\n properties: indexedProperties,\n type: \"compound\",\n name: indexName\n });\n }\n }\n\n return indexes;\n }\n };\n\n if (metadata != null) {\n\n const compiledSchemaWithMetadata: CompiledSchemaWithMetadata<T, TMetadata> = {\n ...result,\n createSubscription: (signal?: AbortSignal, scope?: string, options?: SchemaSubscriptionOptions) => new SchemaSubscription(result, signal, scope, options),\n metadata\n };\n\n return compiledSchemaWithMetadata;\n }\n\n const compiledSchema = {\n createSubscription: (signal?: AbortSignal, scope?: string, options?: SchemaSubscriptionOptions) => new SchemaSubscription(result, signal, scope, options),\n ...result\n };\n\n return compiledSchema;\n } catch (e) {\n throw new SchemaError(e, `Error compiling schema for collection: ${this.collectionName}`);\n }\n }\n}\n","import { CompiledSchema, DefaultValue, InferType, PropertyDeserializer, PropertySerializer, SchemaModifiers, SchemaTypes } from \"../../types\";\nimport { SchemaBase } from \"../base/SchemaBase\";\nimport { SchemaDefault } from \"../modifiers/SchemaDefault\";\nimport { SchemaDeserialize } from \"../modifiers/SchemaDeserialize\";\nimport { SchemaDistinct } from \"../modifiers/SchemaDistinct\";\nimport { SchemaForeignKey } from \"../modifiers/SchemaForeignKey\";\nimport { SchemaFrom } from \"../modifiers/SchemaFrom\";\nimport { SchemaIdentity } from \"../modifiers/SchemaIdentity\";\nimport { SchemaIndex } from \"../modifiers/SchemaIndex\";\nimport { SchemaKey } from \"../modifiers/SchemaKey\";\nimport { SchemaNullable } from \"../modifiers/SchemaNullable\";\nimport { SchemaOptional } from \"../modifiers/SchemaOptional\";\nimport { SchemaReadonly } from \"../modifiers/SchemaReadonly\";\nimport { SchemaSerialize } from \"../modifiers/SchemaSerialize\";\nimport { SchemaTag } from \"../modifiers/SchemaTag\";\nimport { SchemaArray } from \"./SchemaArray\";\n\nexport class SchemaNumber<T extends number, TModifiers extends SchemaModifiers> extends SchemaBase<T, TModifiers> {\n\n instance: T;\n type = SchemaTypes.Number;\n private _schemaNumber = true;\n\n constrain<K extends T>() {\n return new SchemaNumber<K, TModifiers>(this as unknown as SchemaBase<K, TModifiers>);\n }\n\n from(propertyName: string) {\n return new SchemaFrom<T, TModifiers>(propertyName, this);\n }\n\n optional() {\n return new SchemaOptional<T, TModifiers | \"optional\">(this);\n }\n\n nullable() {\n return new SchemaNullable<T, TModifiers | \"nullable\">(this);\n }\n\n key() {\n return new SchemaKey<T, TModifiers | \"key\">(this);\n }\n\n foreignKey<K extends {}>(relatingSchema: CompiledSchema<K>, property: keyof InferType<CompiledSchema<K>>) {\n return new SchemaForeignKey<T, TModifiers, K>(this, relatingSchema, property);\n }\n\n default<I = never>(value: DefaultValue<T, I>, injected?: I) {\n return new SchemaDefault<T, I, TModifiers | \"default\">(value, injected, this);\n }\n\n readonly() {\n return new SchemaReadonly<T, TModifiers | \"readonly\">(this);\n }\n\n deserialize(deserializer: PropertyDeserializer<T>) {\n return new SchemaDeserialize<T, TModifiers | \"deserialize\">(deserializer, this);\n }\n\n serialize(serializer: PropertySerializer<T>) {\n return new SchemaSerialize<T, TModifiers | \"serialize\">(serializer, this);\n }\n\n identity() {\n return new SchemaIdentity<T, TModifiers | \"identity\" | \"readonly\">(this);\n }\n\n array() {\n return new SchemaArray<typeof this, TModifiers>(this as unknown as SchemaArray<typeof this, TModifiers>);\n }\n\n index(...indexes: string[]) {\n return new SchemaIndex<T, TModifiers>(this, ...indexes);\n }\n\n distinct() {\n return new SchemaDistinct<T, TModifiers | \"distinct\">(this);\n }\n\n tag(...tags: string[]) {\n return new SchemaTag<T, TModifiers>(tags, this);\n }\n\n\n}","import { DefaultValue, SchemaModifiers, SchemaTypes } from \"../../types\";\nimport { SchemaBase } from \"../base/SchemaBase\";\nimport { SchemaDefault } from \"../modifiers/SchemaDefault\";\nimport { SchemaFrom } from \"../modifiers/SchemaFrom\";\nimport { SchemaIdentity } from \"../modifiers/SchemaIdentity\";\nimport { SchemaNullable } from \"../modifiers/SchemaNullable\";\nimport { SchemaOptional } from \"../modifiers/SchemaOptional\";\nimport { SchemaTag } from \"../modifiers/SchemaTag\";\nimport { SchemaArray } from \"./SchemaArray\";\n\nexport class SchemaObject<T extends {}, TModifiers extends SchemaModifiers> extends SchemaBase<T, TModifiers> {\n\n instance: T;\n type = SchemaTypes.Object;\n private _schemaObject = true;\n\n constructor(schema: T) {\n super();\n this.instance = schema;\n }\n\n from(propertyName: string) {\n return new SchemaFrom<T, TModifiers>(propertyName, this);\n }\n\n optional() {\n return new SchemaOptional<T, TModifiers | \"optional\">(this);\n }\n\n nullable() {\n return new SchemaNullable<T, TModifiers | \"nullable\">(this);\n }\n\n default<I = never>(value: DefaultValue<T, I>, injected?: I) {\n return new SchemaDefault<T, I, TModifiers | \"default\">(value, injected, this);\n }\n\n identity() {\n return new SchemaIdentity<T, TModifiers | \"identity\" | \"readonly\">(this);\n }\n\n array() {\n return new SchemaArray<typeof this, TModifiers>(this as unknown as SchemaArray<typeof this, TModifiers>);\n }\n\n tag(...tags: string[]) {\n return new SchemaTag<T, TModifiers>(tags, this);\n }\n\n\n}","import { DefaultValue, SchemaModifiers, SchemaTypes } from \"../../types\";\nimport { SchemaBase } from \"../base/SchemaBase\";\nimport { SchemaDefault } from \"../modifiers/SchemaDefault\";\nimport { SchemaFrom } from \"../modifiers/SchemaFrom\";\nimport { SchemaNullable } from \"../modifiers/SchemaNullable\";\nimport { SchemaOptional } from \"../modifiers/SchemaOptional\";\nimport { SchemaReadonly } from \"../modifiers/SchemaReadonly\";\nimport { SchemaTag } from \"../modifiers/SchemaTag\";\n\n/**\n * A file: content on the way in, a reference on the way out.\n *\n * This is the one property type whose write shape differs from its stored shape. You assign\n * a `File`, a `Blob`, a `Uint8Array` or a string; what is stored, and what a query gives\n * back, is a reference — where the bytes live and what they are.\n *\n * ```ts\n * const documentSchema = s.define('documents', {\n * id: s.string().key().identity(),\n * title: s.string(),\n * file: s.file(),\n * }).compile();\n *\n * await store.documents.addAsync({ title: 'Q3', file: fileFromInput });\n * await store.saveChangesAsync();\n *\n * doc.file.size // 2_400_112\n * doc.file.contentType // 'application/pdf'\n * ```\n *\n * ## Why this cannot be `s.object({ key, size, ... })`\n *\n * The generated `preprocess` rebuilds an object property field by field from its declared\n * children — `result.file = {}` and then one assignment per child. Content assigned there is\n * therefore discarded by construction, before any plugin sees the entity: the property does\n * not arrive mangled, it does not arrive at all.\n *\n * A file is a LEAF here, with no child properties, so the generated code passes it through\n * untouched. The bytes survive as far as the plugin, which is the only place an upload can\n * happen — `preprocess` is synchronous and is called from the change tracker and the\n * broadcast path, so it cannot await one.\n *\n * ## What actually stores it\n *\n * Nothing in core uploads anything. `@routier/blob-plugin` wraps your real plugin, swaps\n * pending content for a reference during `bulkPersist`, and hands the reference down. Without\n * that wrapper a file property stores whatever you assigned, which is a mistake this type\n * cannot detect on its own.\n */\nexport class SchemaFile<T extends any, TModifiers extends SchemaModifiers> extends SchemaBase<T, TModifiers> {\n\n instance: T;\n type = SchemaTypes.File;\n private _schemaFile = true;\n\n constructor() {\n super();\n this.instance = null as T;\n }\n\n from(propertyName: string) {\n return new SchemaFrom<T, TModifiers>(propertyName, this);\n }\n\n optional() {\n return new SchemaOptional<T, TModifiers | \"optional\">(this);\n }\n\n nullable() {\n return new SchemaNullable<T, TModifiers | \"nullable\">(this);\n }\n\n readonly() {\n return new SchemaReadonly<T, TModifiers | \"readonly\">(this);\n }\n\n default<I = never>(value: DefaultValue<T, I>, injected?: I) {\n return new SchemaDefault<T, I, TModifiers | \"default\">(value, injected, this);\n }\n\n tag(...tags: string[]) {\n return new SchemaTag<T, TModifiers>(tags, this);\n }\n}\n","import { CompiledSchema, DefaultValue, InferType, PropertyDeserializer, PropertySerializer, SchemaModifiers, SchemaTypes, StringOptions } from \"../../types\";\nimport { SchemaBase } from \"../base/SchemaBase\";\nimport { SchemaDefault } from \"../modifiers/SchemaDefault\";\nimport { SchemaDeserialize } from \"../modifiers/SchemaDeserialize\";\nimport { SchemaDistinct } from \"../modifiers/SchemaDistinct\";\nimport { SchemaForeignKey } from \"../modifiers/SchemaForeignKey\";\nimport { SchemaFrom } from \"../modifiers/SchemaFrom\";\nimport { SchemaIdentity } from \"../modifiers/SchemaIdentity\";\nimport { SchemaIndex } from \"../modifiers/SchemaIndex\";\nimport { SchemaKey } from \"../modifiers/SchemaKey\";\nimport { SchemaNullable } from \"../modifiers/SchemaNullable\";\nimport { SchemaOptional } from \"../modifiers/SchemaOptional\";\nimport { SchemaReadonly } from \"../modifiers/SchemaReadonly\";\nimport { SchemaSearchable } from \"../modifiers/SchemaSearchable\";\nimport { SchemaSerialize } from \"../modifiers/SchemaSerialize\";\nimport { SchemaTag } from \"../modifiers/SchemaTag\";\nimport { SchemaArray } from \"./SchemaArray\";\n\nexport class SchemaString<T extends string, TModifiers extends SchemaModifiers> extends SchemaBase<T, TModifiers> {\n\n instance: T;\n type = SchemaTypes.String;\n private _schemaString = true;\n\n /**\n * @param entity Copied from when a modifier wraps this property.\n * @param literals The allowed values, when the string is a literal union.\n * @param options Declarations a backend may use. See `StringOptions`.\n */\n constructor(entity?: SchemaBase<T, TModifiers> | null, literals?: T[], options?: StringOptions) {\n super(entity, literals);\n\n if (options?.maxLength != null) {\n\n if (Number.isInteger(options.maxLength) === false || options.maxLength <= 0) {\n // Thrown at schema construction rather than at the first save, matching\n // `s.vector()`: a bad length is a typo in a declaration, and the stack is only\n // useful next to it.\n throw new Error(`A string's maxLength must be a positive whole number. Received: ${options.maxLength}`);\n }\n\n this.maxLength = options.maxLength;\n }\n }\n\n from(propertyName: string) {\n return new SchemaFrom<T, TModifiers>(propertyName, this);\n }\n\n constrain<K extends T>() {\n return new SchemaString<K, TModifiers>(this as unknown as SchemaBase<K, TModifiers>);\n }\n\n optional() {\n return new SchemaOptional<T, TModifiers | \"optional\">(this);\n }\n\n nullable() {\n return new SchemaNullable<T, TModifiers | \"nullable\">(this);\n }\n\n key() {\n return new SchemaKey<T, TModifiers | \"key\">(this);\n }\n\n foreignKey<K extends {}>(relatingSchema: CompiledSchema<K>, property: keyof InferType<CompiledSchema<K>>) {\n return new SchemaForeignKey<T, TModifiers, K>(this, relatingSchema, property);\n }\n\n default<I = never>(value: DefaultValue<T, I>, injected?: I) {\n return new SchemaDefault<T, I, TModifiers | \"default\">(value, injected, this);\n }\n\n readonly() {\n return new SchemaReadonly<T, TModifiers | \"readonly\">(this);\n }\n\n deserialize(deserializer: PropertyDeserializer<T>) {\n return new SchemaDeserialize<T, TModifiers | \"deserialize\">(deserializer, this);\n }\n\n serialize(serializer: PropertySerializer<T>) {\n return new SchemaSerialize<T, TModifiers | \"serialize\">(serializer, this);\n }\n\n identity() {\n return new SchemaIdentity<T, TModifiers | \"identity\" | \"readonly\">(this);\n }\n\n array() {\n return new SchemaArray<typeof this, TModifiers>(this as unknown as SchemaArray<typeof this, TModifiers>);\n }\n\n index(...indexes: string[]) {\n return new SchemaIndex<T, TModifiers>(this, ...indexes);\n }\n\n distinct() {\n return new SchemaDistinct<T, TModifiers | \"distinct\">(this);\n }\n\n /**\n * Marks this string as eligible for the collection's full-text search index.\n *\n * ```ts\n * title: s.string().searchable(),\n * body: s.string({ maxLength: 4000 }).searchable(),\n * ```\n *\n * Nothing is indexed until the collection declares `.searchIndex()`. Combines with\n * `.optional()` and `.nullable()` in either sense — an absent or null value contributes no\n * tokens.\n */\n searchable() {\n return new SchemaSearchable<T, TModifiers | \"searchable\">(this);\n }\n\n tag(...tags: string[]) {\n return new SchemaTag<T, TModifiers>(tags, this);\n }\n\n\n}","import { DefaultValue, SchemaModifiers, SchemaTypes } from \"../../types\";\nimport { SchemaBase } from \"../base/SchemaBase\";\nimport { SchemaDefault } from \"../modifiers/SchemaDefault\";\nimport { SchemaFrom } from \"../modifiers/SchemaFrom\";\nimport { SchemaNullable } from \"../modifiers/SchemaNullable\";\nimport { SchemaOptional } from \"../modifiers/SchemaOptional\";\nimport { SchemaReadonly } from \"../modifiers/SchemaReadonly\";\nimport { SchemaTag } from \"../modifiers/SchemaTag\";\n\n/**\n * An embedding: a fixed-length list of numbers you can search by similarity.\n *\n * ```ts\n * const documentSchema = s.define('documents', {\n * id: s.string().key().identity(),\n * title: s.string(),\n * embedding: s.vector(1536),\n * }).compile();\n *\n * const similar = await store.documents\n * .nearest(x => x.embedding, queryEmbedding, 10)\n * .toArrayAsync();\n * ```\n *\n * ## Why this is not `s.array(s.number())`\n *\n * By value it is exactly that, and every codegen handler treats the two the same on purpose —\n * a vector clones with a spread, compares by JSON and freezes like any other array. What an\n * array cannot carry is the DIMENSION COUNT, and a backend that stores vectors natively needs\n * it at DDL time: pgvector's column type is `vector(1536)`, not `vector`.\n *\n * So this exists to be RECOGNISED, not to behave differently. A backend that knows what a\n * vector is stores one; every other backend sees a list of numbers and stores JSON, which is\n * why the feature works everywhere rather than only on PostgreSQL.\n *\n * ## Dimensions are not enforced here\n *\n * `dimensions` is a declaration, and core never checks a value against it. The check belongs\n * where the cost of being wrong is paid: a backend with a native `vector(n)` column rejects a\n * mismatched write itself, with an error naming the column. Validating in core would duplicate\n * that on the backends that already do it and add a per-save array scan to the ones that\n * cannot use the information at all.\n *\n * ## Similarity is cosine, and it is not a filter\n *\n * `.nearest()` is an ordering plus a limit — it returns the closest rows, not the matching\n * ones. Distance itself is not exposed: the entity shape is fixed, and the ordering is what\n * callers act on. A backend with no vector support scores in memory, so the answer is the\n * same everywhere; only the amount of data read differs.\n */\nexport class SchemaVector<T extends any, TModifiers extends SchemaModifiers> extends SchemaBase<T, TModifiers> {\n\n instance: T;\n type = SchemaTypes.Vector;\n private _schemaVector = true;\n\n constructor(dimensions: number) {\n super();\n\n if (Number.isInteger(dimensions) === false || dimensions <= 0) {\n // Thrown at schema construction rather than at the first save: a bad dimension\n // count is a typo in a declaration, and the stack is only useful next to it.\n throw new Error(`A vector needs a positive whole number of dimensions. Received: ${dimensions}`);\n }\n\n this.dimensions = dimensions;\n this.instance = null as T;\n }\n\n from(propertyName: string) {\n return new SchemaFrom<T, TModifiers>(propertyName, this);\n }\n\n optional() {\n return new SchemaOptional<T, TModifiers | \"optional\">(this);\n }\n\n nullable() {\n return new SchemaNullable<T, TModifiers | \"nullable\">(this);\n }\n\n readonly() {\n return new SchemaReadonly<T, TModifiers | \"readonly\">(this);\n }\n\n default<I = never>(value: DefaultValue<T, I>, injected?: I) {\n return new SchemaDefault<T, I, TModifiers | \"default\">(value, injected, this);\n }\n\n tag(...tags: string[]) {\n return new SchemaTag<T, TModifiers>(tags, this);\n }\n}\n","import { SchemaArray } from \"./property/types/SchemaArray\";\nimport { SchemaBase } from \"./property/base/SchemaBase\";\nimport { SchemaBoolean } from \"./property/types/SchemaBoolean\";\nimport { SchemaDate } from \"./property/types/SchemaDate\";\nimport { SchemaDefinition } from \"./SchemaDefinition\";\nimport { SchemaNumber } from \"./property/types/SchemaNumber\";\nimport { SchemaObject } from \"./property/types/SchemaObject\";\nimport { SchemaFile } from \"./property/types/SchemaFile\";\nimport { SchemaString } from \"./property/types/SchemaString\";\nimport { SchemaVector } from \"./property/types/SchemaVector\";\nimport { CollectionName, FileReferenceValue, StringOptions, VectorValue } from \"./types\";\n\n/**\n * A string, optionally declaring how long it can be and which values it may take.\n *\n * ```ts\n * s.string() // any string\n * s.string(\"draft\", \"published\") // a literal union\n * s.string({ maxLength: 4000 }) // any string, declared long\n * s.string({ maxLength: 8 }, \"a\", \"b\") // both\n * ```\n *\n * The options object is a leading parameter rather than a `.maxLength()` modifier so the\n * declaration stays on the factory, next to the literals. A modifier would also have to survive\n * being wrapped by another modifier, which is the trap `SchemaBase.maxLength` documents.\n */\nfunction string<T extends string[] = string[]>(...literals: T): SchemaString<T[number] extends never ? string : T[number], never>;\nfunction string<T extends string[] = string[]>(options: StringOptions, ...literals: T): SchemaString<T[number] extends never ? string : T[number], never>;\nfunction string(optionsOrLiteral?: StringOptions | string, ...rest: string[]) {\n\n // A literal is a string and options is an object, so the first argument decides which\n // overload was called. Nothing else can be passed, which is why this needs no flag and no\n // second factory.\n if (typeof optionsOrLiteral === \"string\") {\n return new SchemaString<string, never>(null, [optionsOrLiteral, ...rest]);\n }\n\n if (optionsOrLiteral == null) {\n return new SchemaString<string, never>(null, []);\n }\n\n return new SchemaString<string, never>(null, rest, optionsOrLiteral);\n}\n\nexport const s = {\n number: <T extends number[] = number[]>(...literals: T) => new SchemaNumber<T[number] extends never ? number : T[number], never>(null, literals),\n string,\n boolean: <T extends boolean = boolean>() => new SchemaBoolean<T, never>(),\n date: <T extends Date = Date>() => new SchemaDate<T, never>(),\n array: <T extends any>(schema: SchemaBase<T, never>) => new SchemaArray<SchemaBase<T, never>, never>(schema as any),\n object: <T extends {} = {}>(schema: T) => new SchemaObject<T, never>(schema),\n /**\n * A file. Assign content, read back a reference.\n *\n * Needs `@routier/blob-plugin` wrapping your plugin to turn the one into the other; core\n * only carries the value through untouched.\n */\n file: () => new SchemaFile<FileReferenceValue, never>(),\n /**\n * An embedding of `dimensions` numbers, searchable with `.nearest()`.\n *\n * Every backend supports it. One with a native vector column uses it; the rest store the\n * numbers as JSON and score the search in memory, which returns the same rows.\n */\n vector: (dimensions: number) => new SchemaVector<VectorValue, never>(dimensions),\n define: <T extends {}>(collectionName: string, schema: T) => new SchemaDefinition<T>(collectionName as CollectionName, schema),\n}","export * from './SchemaComputed';\nexport * from './SchemaFunction';\nexport * from './SchemaTransform';\n","export * from './SchemaBase';","export * from './SchemaDefault';\nexport * from './SchemaDeserialize';\nexport * from './SchemaDistinct';\nexport * from './SchemaIdentity';\nexport * from './SchemaIndex';\nexport * from './SchemaKey';\nexport * from './SchemaNullable';\nexport * from './SchemaOptional';\nexport * from './SchemaReadonly';\nexport * from './SchemaSearchable';\nexport * from './SchemaSerialize';\nexport * from './SchemaTracked';\nexport * from './SchemaFrom';\nexport * from './SchemaTag';\nexport * from './SchemaForeignKey';\n","export * from './SchemaArray';\nexport * from './SchemaBoolean';\nexport * from './SchemaDate';\nexport * from './SchemaNumber';\nexport * from './SchemaObject';\nexport * from './SchemaString';\nexport * from './SchemaFile';\nexport * from './SchemaVector';\n","export * from './builder';\nexport * from './table';\nexport * from './property/base';\nexport * from './property/modifiers';\nexport * from './property/types';\nexport * from './PropertyInfo';\nexport * from './types';\nexport type { SchemaSubscriptionOptions } from './communication/broadcast';\nexport * from './utils/standardJsonSchema';\nexport * from './utils/propertyKind';\nexport * from './SchemaDefinition';"],"names":["uuid","Block","name","parentIndent","parent","w","lines","block","indent","split","result","item","found","undefined","Error","x","line","foundIndex","text","ContainerBlock","condition","options","builder","IfBuilder","raw","RawBuilder","FunctionBuilder","FunctionFactoryBuilder","declaration","VariableBuilder","variableName","AssignmentBuilder","ObjectBuilder","SlotBlock","accessor","ArrayBuilder","StringBuilder","type","value","and","AndBuilder","objectBuilder","functionName","stringBuilder","arrayBuilder","lastLine","propertyName","isNestedContent","sectionName","params","body","parameterNames","parameterValues","Function","r","signature","Array","CodeBuilder","SchemaError","error","innerErrorMessage","logger","measurements","now","performance","Date","measure","start","delta","SchemaTypes","HashType","LOG_LEVELS","RANK","isLogLevel","resolveLevel","globalThis","g","process","debug","env","level","rank","setLogLevel","next","getLogLevel","resetLogLevel","isLogLevelEnabled","at","emit","method","args","console","hash","seed","h1","h2","i","ch","Math","fastHash","stringifyObject","obj","maxDepth","currentDepth","String","getFunctionName","stringifyObjectValue","fn","getObjectProperties","properties","key","RegExp","stringifyArray","stringifyClassInstance","stringifyPlainObject","arr","items","suffix","className","Object","props","isPrimitive","depth","length","chars","charLength","HEX_CHARS","UUID_TEMPLATE","hasCrypto","crypto","hasRandomUUID","uuidv4","uuidv4Fallback","randomBytes","Uint8Array","byteIndex","c","SchemaBase","entity","literals","SchemaDistinct","current","SchemaIdentity","SchemaNullable","SchemaOptional","SchemaSearchable","SchemaDeserialize","deserializer","SchemaDefault","injected","SchemaSerialize","serializer","SchemaFrom","SchemaReadonly","defaultValue","SchemaIndex","indexes","SchemaArray","SchemaTag","tags","SchemaBoolean","SchemaDate","SchemaFunction","SchemaTransform","underlying","transform","SchemaForeignKey","relatingSchema","property","SchemaKey","SchemaTracked","SchemaComputed","SUPPORTED_DESERIALIZATION_TYPES","Set","PropertyInfo","schema","chain","precedingProp","assignmentType","propertyChain","hasRoot","path","prop","fromPath","children","child","instance","pathArray","parts","Number","Boolean","SlotPath","pathLike","up","countWordOccurance","word","wl","tl","code","count","isWordCharCode","enforceWordBoundaries","k","cc","left","right","leftOk","rightOk","NotApplicableHandler","handler","_","PropertyInfoHandler","e","p","names","root","parentPathArray","pathSoFar","slot","valueExpression","parentSelectPath","resultSelectorPath","ifSlot","selectorPath","sourcePath","destinationPath","ifBlock","base","entitySelectorPath","slotPath","parentSlotPath","childEntityPathSelector","enriched","enrichedSlot","stringifiedFunction","occurences","parameters","index","EnrichmentNullableObjectHandler","nestedSlotPath","entityPath","enrichedPath","ifsSlot","parentBuilder","enrichedRoot","EnrichmentObjectHandler","EnrichmentObjectIdentityHandler","EnrichmentPrimitiveIdentityHandler","enrichedAssignmentPath","EnrichmentPrimitiveHandler","EnrichmentFunctionHandler","factory","parameter","declarationsSlot","defaultFunctionWithParameters","EnrichmentDefaultValueHandler","checkPath","assignmentPath","renderDefaultLiteral","JSON","EnrichmentDefaultFunctionHandler","defaultFunction","EnrichmentComputedValueHandler","ARRAY_VALUED_TYPES","isArrayValued","PRIMITIVE_ELEMENT_TYPES","hasPrimitiveElements","elementType","EnrichmentArrayHandler","EnrichmentHandlerBuilder","MergeDefaultFunctionHandler","defaultFunctionParameters","defaultIf","MergeObjectHandler","MergePrimitiveHandler","MergeComputedValueHandler","MergeDefaultValueHandler","MergeFunctionHandler","MergeArrayHandler","MergeHandlerBuilder","PrepareIdentityHandler","PrepareKeyHandler","PrepareValueHandler","PrepareObjectHandler","nestedObjectBuilder","PrepareComputedValueHandler","PrepareFunctionHandler","PrepareHandlerBuilder","StripObjectHandler","StripValueHandler","StripKeyHandler","StripIdentityHandler","StripFunctionHandler","StripComputedHandler","StripHandlerBuilder","CloneArrayHandler","useFromPropertyName","resultAssignmentPath","copyExpression","nullSafeCopy","CloneDateHandler","CloneObjectHandler","CloneValueHandler","CloneHandlerBuilder","CompareArrayHandler","compare","leftCompare","rightCompare","CompareComputedHandler","CompareDateHandler","CompareFunctionHandler","CompareObjectHandler","CompareValueHandler","CompareHandlerBuilder","DeserializeObjectHandler","DeserializeValueHandler","DeserializeDateHandler","entityAssignmentPath","assignment","ifAssignment","rootPath","DeserializeComputedValueHandler","DeserializeFunctionHandler","DeserializeDeserializerHandler","assignmentBuilder","DeserializeArrayHandler","selector","DeserializeHandlerBuilder","HashTypeValueHandler","HashTypeHandlerBuilder","IdSelectorValueHandler","IdSelectorHandlerBuilder","HashKeyHandler","HashValueHandler","HashDateHandler","HashIdentityHandler","HashFunctionHandler","HashComputedValueHandler","HashArrayHandler","HashObjectHandler","HashFileHandler","HashTransformHandler","HashHandlerBuilder","EnableChangeTrackingObjectHandler","assignmentSlot","childSelectorPath","childAssignmentPath","EnableChangeTrackingArrayHandler","EnableChangeTrackingPrimitiveValueHandler","EnableChangeTrackingHandlerBuilder","FreezePrimitiveValueHandler","FreezeObjectHandler","FreezeArrayHandler","FreezeHandlerBuilder","SerializeDateHandler","dateExpr","dateExprNested","SerializeObjectHandler","childPath","SerializeValueHandler","SerializeSerializerHandler","SerializeFunctionHandler","SerializeComputedHandler","SerializeArrayHandler","SerializeHandlerBuilder","registry","getChannelKey","schemaId","scope","getChannelRegistry","channel","SchemaChannel","channelKey","SchemaChannelSender","SchemaChannelReceiver","unreference","maybeUnref","BroadcastChannel","changes","stampedChanges","subscription","id","listener","SubscriptionListener","SchemaSubscription","signal","regisry","preprocessedChanges","callback","data","timestamp","postProcessedChanges","Symbol","CompareIdsKeyHandler","CompareIdsHandlerBuilder","s","createPrimitiveConverter","jsonType","_context","jsonSchema","dateConverter","_property","objectConverter","context","required","childSchema","convertArrayItems","innerSchema","innerType","schemaBase","tempProperty","itemSchema","vectorConverter","arrayConverter","computedConverter","routierMeta","defaultConverter","converterRegistry","Map","applyNullable","target","applyRoutierMetadata","propertyInfoToJsonSchema","visited","useOutputType","converter","compiledSchemaToJsonSchema","compiledSchema","propertySchema","createStandardJsonSchemaProps","rehydrateSchemaFromJsonString","jsonString","collectionName","rehydrateSchemaFromJsonSchema","SyntaxError","finalCollectionName","schemaDefinition","computedProperties","idProperties","propName","propSchema","isRequired","routierPropMeta","routierPropName","schemaBuilder","convertJsonSchemaPropertyToRoutier","isKey","computedDefs","computedProp","recreatedFn","functionSource","arrowMatch","paramsStr","functionBody","t","objectProps","objectSchema","itemsSchema","extractTypeInfo","allowedTypes","SetComplexHandler","SetHandlerBuilder","assertPropertyHandled","generatorName","createChangeTracker","DIRTY_ENTITY_MARKER","CHANGES_ENTITY_KEY","ORIGINAL_ENTITY_KEY","PAUSED_ENTITY_KEY","TRACKING_KEY","PROXY_MARKER","proxyHandler","indexableEntity","originalValue","resolvedParent","Reflect","resolvedPath","isDirty","receiver","Proxy","SchemaDefinition","fnArgs","b","explore","instanceObj","propertyInstance","previousParent","propertyInfo","childPrimitivePropertyInfo","recursiveCallback","metadata","propertyMap","enrichmentHandlerBuilder","mergeHandlerFactory","prepareHandlerBuilder","stripHandlerBuilder","cloneHandlerBuilder","compareHandlerBuilder","deserializeHandlerBuilder","hashTypeHandlerBuilder","idSelectorHandlerBuilder","hashHandlerBuilder","enableChangeTrackingHandlerBuilder","freezeHandlerBuilder","serializeHandlerBuilder","compareIdsHandlerBuilder","setHandlerBuilder","enricher","merge","prepare","strip","clone","deserialize","hashTypeHandler","idSelectorHandler","hashHandler","enableChangeTrackingHandler","freezeHandler","serializeHandler","compareIdsHandler","setHandlerHanlder","changeTrackingCodeBuilder","freezeCodeBuilder","enricherCodeBuilder","enricherFunctionRoot","enricherFunctionBody","preprocessCodeBuilder","postprocessCodeBuilder","setCodeBuilder","mergeCodeBuilder","mergeFunctionRoot","mergeFunctionBody","pauseFunctionBody","unpauseFunctionBody","prepareCodeBuilder","stripCodeBuilder","cloneCodeBuilder","compareCodeBuilder","compareIdsCodeBuilder","deserializeCodeBuilder","serializeCodeBuilder","idSelectorCodeBuilder","hashTypeCodeBuilder","hashCodeBuilder","hashCodeBuilderIfBlock","allPropertyNamesAndPaths","hashType","hasIdentities","hasIdentityKeys","enrichParams","mergeParams","enrichGenerator","mergeGenerator","postProcessGenerator","postProcessParams","getIdsFunction","getHashTypeFunction","prepareFunction","cloneFunction","storageCloneFunction","cloneStorageFunction","storageCloneCodeBuilder","isDeclared","skipDeclared","storageClone","deserializeFunction","serializeFunction","compareFunction","stripFunction","hashFunction","enableChangeTrackingFunction","freezeFunction","compareIdsFunction","preprocessFunction","setFunction","enricherFactoryFunction","postProcessFactoryFunction","mergeFactoryFunction","postProcessFunction","enricherFunction","mergeFunction","idPropertyNames","getId","getProperty","deserializePartial","deserialized","j","l","indexName","connections","indexedProperties","compiledSchemaWithMetadata","SchemaNumber","SchemaObject","SchemaFile","SchemaString","SchemaVector","dimensions","string","optionsOrLiteral","rest"],"mappings":";;;;;;;;;AAAoC;AAS7B,MAAeC;IACT,KAAa;IACZ,SAAiB,EAAE,CAAC;IACpB,UAAkB,GAAG;IACrB,QAAgB;IAE1B,YAAYC,IAAa,EAAEC,eAAuB,EAAE,EAAEC,MAAc,CAAE;QAClE,IAAI,CAAC,I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C,IAAc;IAExE,sFAAsF;IACtF,0FAA0F;IAC1F,kBAAkB;IAClB,IAAI,OAAOD,qBAAqB,UAAU;QACtC,OAAO,IAAIJ,YAAYA,CAAgB,MAAM;YAACI;eAAqBC;SAAK;IAC5E;IAEA,IAAID,oBAAoB,MAAM;QAC1B,OAAO,IAAIJ,YAAYA,CAAgB,MAAM,EAAE;IACnD;IAEA,OAAO,IAAIA,YAAYA,CAAgB,MAAMK,MAAMD;AACvD;AAEO,MAAM5M,IAAI;IACb,QAAQ,CAAgC,GAAGhQ,WAAgB,IAAIqc,YAAYA,CAAsD,MAAMrc;IACvI2c;IACA,SAAS,IAAmC,IAAItb,aAAaA;IAC7D,MAAM,IAA6B,IAAIC,UAAUA;IACjD,OAAO,CAAgBc,SAAiC,IAAIlB,WAAWA,CAA8BkB;IACrG,QAAQ,CAAoBA,SAAc,IAAIka,YAAYA,CAAWla;IACrE;;;;;KAKC,GACD,MAAM,IAAM,IAAIma,UAAUA;IAC1B;;;;;KAKC,GACD,QAAQ,CAACG,aAAuB,IAAID,YAAYA,CAAqBC;IACrE,QAAQ,CAAerK,gBAAwBjQ,SAAc,IAAIiT,gBAAgBA,CAAIhD,gBAAkCjQ;AAC3H,EAAC;;;AClEgC;AACA;AACC;;;ACFL;;;ACAG;AACI;AACH;AACA;AACH;AACF;AACK;AACA;AACA;AACE;AACD;AACF;AACH;AACD;AACO;;;ACdL;AACE;AACH;AACE;AACA;AACA;AACF;AACE;;;ACPL;AACF;AACQ;AACK;AACJ;AACF;AACP;AAEmB;AACN;AACF"}
1
+ {"version":3,"file":"schema/index.cjs","sources":["webpack://@routier/core/./src/codegen/blocks.ts","webpack://@routier/core/./src/errors/SchemaError.ts","webpack://@routier/core/./src/performance/index.ts","webpack://@routier/core/./src/schema/types.ts","webpack://@routier/core/./src/utilities/logger.ts","webpack://@routier/core/./src/utilities/strings.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/schema/property/base/SchemaBase.ts","webpack://@routier/core/./src/schema/property/modifiers/SchemaDistinct.ts","webpack://@routier/core/./src/schema/property/modifiers/SchemaIdentity.ts","webpack://@routier/core/./src/schema/property/modifiers/SchemaSearchable.ts","webpack://@routier/core/./src/schema/property/modifiers/SchemaOptional.ts","webpack://@routier/core/./src/schema/property/modifiers/SchemaNullable.ts","webpack://@routier/core/./src/schema/property/modifiers/SchemaSerialize.ts","webpack://@routier/core/./src/schema/property/modifiers/SchemaReadonly.ts","webpack://@routier/core/./src/schema/property/modifiers/SchemaFrom.ts","webpack://@routier/core/./src/schema/property/modifiers/SchemaDeserialize.ts","webpack://@routier/core/./src/schema/property/modifiers/SchemaDefault.ts","webpack://@routier/core/./src/schema/property/modifiers/SchemaIndex.ts","webpack://@routier/core/./src/schema/property/modifiers/SchemaTag.ts","webpack://@routier/core/./src/schema/property/types/SchemaArray.ts","webpack://@routier/core/./src/schema/property/types/SchemaBoolean.ts","webpack://@routier/core/./src/schema/property/types/SchemaDate.ts","webpack://@routier/core/./src/schema/table/SchemaFunction.ts","webpack://@routier/core/./src/schema/table/SchemaTransform.ts","webpack://@routier/core/./src/schema/property/modifiers/SchemaForeignKey.ts","webpack://@routier/core/./src/schema/property/modifiers/SchemaKey.ts","webpack://@routier/core/./src/schema/property/modifiers/SchemaTracked.ts","webpack://@routier/core/./src/schema/table/SchemaComputed.ts","webpack://@routier/core/./src/schema/PropertyInfo.ts","webpack://@routier/core/./src/codegen/SlotPath.ts","webpack://@routier/core/./src/codegen/utils.ts","webpack://@routier/core/./src/codegen/handlers/types.ts","webpack://@routier/core/./src/codegen/handlers/enrichment/EnrichmentNullableObjectHandler.ts","webpack://@routier/core/./src/codegen/handlers/enrichment/EnrichmentObjectHandler.ts","webpack://@routier/core/./src/codegen/handlers/enrichment/EnrichmentObjectIdentityHandler.ts","webpack://@routier/core/./src/codegen/handlers/enrichment/EnrichmentPrimitiveIdentityHandler.ts","webpack://@routier/core/./src/codegen/handlers/enrichment/EnrichmentPrimitiveHandler.ts","webpack://@routier/core/./src/codegen/handlers/enrichment/EnrichmentFunctionHandler.ts","webpack://@routier/core/./src/codegen/handlers/enrichment/EnrichmentDefaultValueHandler.ts","webpack://@routier/core/./src/codegen/handlers/enrichment/EnrichmentDefaultFunctionHandler.ts","webpack://@routier/core/./src/codegen/handlers/enrichment/EnrichmentComputedValueHandler.ts","webpack://@routier/core/./src/schema/utils/propertyKind.ts","webpack://@routier/core/./src/codegen/handlers/enrichment/EnrichmentArrayHandler.ts","webpack://@routier/core/./src/codegen/handlers/EnrichmentHandlerBuilder.ts","webpack://@routier/core/./src/codegen/handlers/merge/MergeDefaultFunctionHandler.ts","webpack://@routier/core/./src/codegen/handlers/merge/MergeObjectHandler.ts","webpack://@routier/core/./src/codegen/handlers/merge/MergePrimitiveHandler.ts","webpack://@routier/core/./src/codegen/handlers/merge/MergeComputedValueHandler.ts","webpack://@routier/core/./src/codegen/handlers/merge/MergeDefaultValueHandler.ts","webpack://@routier/core/./src/codegen/handlers/merge/MergeFunctionHandler.ts","webpack://@routier/core/./src/codegen/handlers/merge/MergeArrayHandler.ts","webpack://@routier/core/./src/codegen/handlers/MergeHandlerBuilder.ts","webpack://@routier/core/./src/codegen/handlers/prepare/PrepareIdentityHandler.ts","webpack://@routier/core/./src/codegen/handlers/prepare/PrepareKeyHandler.ts","webpack://@routier/core/./src/codegen/handlers/prepare/PrepareValueHandler.ts","webpack://@routier/core/./src/codegen/handlers/prepare/PrepareObjectHandler.ts","webpack://@routier/core/./src/codegen/handlers/prepare/PrepareComputedValueHandler.ts","webpack://@routier/core/./src/codegen/handlers/prepare/PrepareFunctionHandler.ts","webpack://@routier/core/./src/codegen/handlers/PrepareHandlerBuilder.ts","webpack://@routier/core/./src/codegen/handlers/strip/StripObjectHandler.ts","webpack://@routier/core/./src/codegen/handlers/strip/StripValueHandler.ts","webpack://@routier/core/./src/codegen/handlers/strip/StripKeyHandler.ts","webpack://@routier/core/./src/codegen/handlers/strip/StripIdentityHandler.ts","webpack://@routier/core/./src/codegen/handlers/strip/StripFunctionHandler.ts","webpack://@routier/core/./src/codegen/handlers/strip/StripComputedHandler.ts","webpack://@routier/core/./src/codegen/handlers/StripHandlerBuilder.ts","webpack://@routier/core/./src/codegen/handlers/clone/CloneArrayHandler.ts","webpack://@routier/core/./src/codegen/handlers/clone/CloneDateHandler.ts","webpack://@routier/core/./src/codegen/handlers/clone/CloneObjectHandler.ts","webpack://@routier/core/./src/codegen/handlers/clone/CloneValueHandler.ts","webpack://@routier/core/./src/codegen/handlers/CloneHandlerBuilder.ts","webpack://@routier/core/./src/codegen/handlers/compare/CompareArrayHandler.ts","webpack://@routier/core/./src/codegen/handlers/compare/CompareComputedHandler.ts","webpack://@routier/core/./src/codegen/handlers/compare/CompareDateHandler.ts","webpack://@routier/core/./src/codegen/handlers/compare/CompareFunctionHandler.ts","webpack://@routier/core/./src/codegen/handlers/compare/CompareObjectHandler.ts","webpack://@routier/core/./src/codegen/handlers/compare/CompareValueHandler.ts","webpack://@routier/core/./src/codegen/handlers/CompareHandlerBuilder.ts","webpack://@routier/core/./src/codegen/handlers/deserialize/DeserializeObjectHandler.ts","webpack://@routier/core/./src/codegen/handlers/deserialize/DeserializeValueHandler.ts","webpack://@routier/core/./src/codegen/handlers/deserialize/DeserializeDateHandler.ts","webpack://@routier/core/./src/codegen/handlers/deserialize/DeserializeComputedValueHandler.ts","webpack://@routier/core/./src/codegen/handlers/deserialize/DeserializeFunctionHandler.ts","webpack://@routier/core/./src/codegen/handlers/deserialize/DeserializeDeserializerHandler.ts","webpack://@routier/core/./src/codegen/handlers/deserialize/DeserializeArrayHandler.ts","webpack://@routier/core/./src/codegen/handlers/DeserializeHandlerBuilder.ts","webpack://@routier/core/./src/codegen/handlers/hashType/HashTypeValueHandler.ts","webpack://@routier/core/./src/codegen/handlers/HashTypeHandlerBuilder.ts","webpack://@routier/core/./src/codegen/handlers/idSelector/IdSelectorValueHandler.ts","webpack://@routier/core/./src/codegen/handlers/IdSelectorHandlerBuilder.ts","webpack://@routier/core/./src/codegen/handlers/hash/HashKeyHandler.ts","webpack://@routier/core/./src/codegen/handlers/hash/HashValueHandler.ts","webpack://@routier/core/./src/codegen/handlers/hash/HashDateHandler.ts","webpack://@routier/core/./src/codegen/handlers/hash/HashIdentityHandler.ts","webpack://@routier/core/./src/codegen/handlers/hash/HashFunctionHandler.ts","webpack://@routier/core/./src/codegen/handlers/hash/HashComputedValueHandler.ts","webpack://@routier/core/./src/codegen/handlers/hash/HashArrayHandler.ts","webpack://@routier/core/./src/codegen/handlers/hash/HashObjectHandler.ts","webpack://@routier/core/./src/codegen/handlers/hash/HashFileHandler.ts","webpack://@routier/core/./src/codegen/handlers/hash/HashTransformHandler.ts","webpack://@routier/core/./src/codegen/handlers/HashHandlerBuilder.ts","webpack://@routier/core/./src/codegen/handlers/enableChangeTracking/EnableChangeTrackingObjectHandler.ts","webpack://@routier/core/./src/codegen/handlers/enableChangeTracking/EnableChangeTrackingArrayHandler.ts","webpack://@routier/core/./src/codegen/handlers/enableChangeTracking/EnableChangeTrackingPrimitiveValueHandler.ts","webpack://@routier/core/./src/codegen/handlers/EnableChangeTrackingHandlerBuilder.ts","webpack://@routier/core/./src/codegen/handlers/freeze/FreezePrimitiveValueHandler.ts","webpack://@routier/core/./src/codegen/handlers/freeze/FreezeObjectHandler.ts","webpack://@routier/core/./src/codegen/handlers/freeze/FreezeArrayHandler.ts","webpack://@routier/core/./src/codegen/handlers/FreezeHandlerBuilder.ts","webpack://@routier/core/./src/codegen/handlers/serialize/SerializeDateHandler.ts","webpack://@routier/core/./src/codegen/handlers/serialize/SerializeObjectHandler.ts","webpack://@routier/core/./src/codegen/handlers/serialize/SerializeValueHandler.ts","webpack://@routier/core/./src/codegen/handlers/serialize/SerializeSerializerHandler.ts","webpack://@routier/core/./src/codegen/handlers/serialize/SerializeFunctionHandler.ts","webpack://@routier/core/./src/codegen/handlers/serialize/SerializeComputedHandler.ts","webpack://@routier/core/./src/codegen/handlers/serialize/SerializeArrayHandler.ts","webpack://@routier/core/./src/codegen/handlers/SerializeHandlerBuilder.ts","webpack://@routier/core/./src/schema/communication/broadcast.ts","webpack://@routier/core/./src/codegen/handlers/compareIds/CompareIdsKeyHandler.ts","webpack://@routier/core/./src/codegen/handlers/CompareIdsHandlerBuilder.ts","webpack://@routier/core/./src/schema/utils/standardJsonSchema.ts","webpack://@routier/core/./src/codegen/handlers/set/SetComplexHandler.ts","webpack://@routier/core/./src/codegen/handlers/SetHandlerBuilder.ts","webpack://@routier/core/./src/schema/SchemaDefinition.ts","webpack://@routier/core/./src/schema/property/types/SchemaNumber.ts","webpack://@routier/core/./src/schema/property/types/SchemaObject.ts","webpack://@routier/core/./src/schema/property/types/SchemaFile.ts","webpack://@routier/core/./src/schema/property/types/SchemaString.ts","webpack://@routier/core/./src/schema/property/types/SchemaVector.ts","webpack://@routier/core/./src/schema/builder.ts","webpack://@routier/core/./src/schema/table/index.ts","webpack://@routier/core/./src/schema/property/base/index.ts","webpack://@routier/core/./src/schema/property/modifiers/index.ts","webpack://@routier/core/./src/schema/property/types/index.ts","webpack://@routier/core/./src/schema/index.ts"],"sourcesContent":["import { uuid } from \"../utilities\";\nimport { CreateBlockOptions } from \"./types\";\n\ntype Line = string | Block;\n\ntype Param = { name: string, value: any };\ntype GenericParam = { name: string, callName: string };\n\n\nexport abstract class Block {\n readonly name: string;\n protected _lines: Line[] = [];\n protected _indent: string = \"\";\n protected _parent?: Block;\n\n constructor(name?: string, parentIndent: string = \"\", parent?: Block) {\n this.name = name != null ? name : uuid();\n this._indent = parentIndent;\n this._parent = parent;\n }\n\n indexOf(name: string) {\n return this._lines.findIndex(w => typeof w !== \"string\" && w.name === name);\n }\n\n getLines() {\n return this._lines;\n }\n\n getParent() {\n return this._parent;\n }\n\n getIndent() {\n return this._indent;\n }\n\n setLines(lines: Line[]) {\n this._lines = lines;\n }\n\n setParent(block: Block) {\n this._parent = block;\n }\n\n setIndent(indent: string) {\n this._indent = indent;\n }\n\n getOrDefault<T extends Block>(name: string): T | undefined {\n\n if (name.includes('.') === false) {\n return this._lines.find(w => typeof w !== \"string\" && w.name === name) as T | undefined;\n }\n\n const split = name.match(/(\\[[^\\]]+\\]|[^.]+)/g);\n // oxlint-disable-next-line no-this-alias\n let result: Block = this;\n\n for (const item of split) {\n const found = result._lines.find(w => typeof w !== \"string\" && w.name === item) as Block;\n\n if (found == null) {\n\n if (\"getValue\" in result && result.getValue instanceof Block && result.getValue.name === item) {\n result = result.getValue;\n continue;\n }\n\n return undefined;\n }\n\n result = found;\n }\n\n return result as T;\n }\n\n get<T extends Block>(name: string): T {\n const found = this.getOrDefault(name);\n\n if (found == null) {\n throw new Error(`Error finding code block for given path. Path: ${name}`)\n }\n\n return found as T;\n }\n\n has(name: string) {\n return this._lines.some(w => typeof w !== \"string\" && w.name === name);\n }\n\n remove(name: string) {\n this._lines = this._lines.filter(x => typeof x === \"object\" && typeof x.name === \"string\" && x.name !== name);\n }\n\n replace(name: string, line: Block) {\n\n const foundIndex = this._lines.findIndex(x => typeof x !== \"string\" && x.name === name);\n\n if (foundIndex === -1) {\n throw new Error(`Cannot find line by name. Name: ${name}`)\n }\n\n const found = this._lines[foundIndex];\n\n if (typeof found === \"string\") {\n // Replace the line\n this._lines.splice(foundIndex, 1, line);\n return;\n }\n\n line.setLines(found.getLines());\n line.setIndent(found.getIndent());\n line.setParent(found.getParent());\n\n // Replace the line\n this._lines.splice(foundIndex, 1, line);\n\n return;\n }\n\n protected push(line: Line) {\n this._lines.push(line);\n }\n\n protected unshift(line: Line) {\n this._lines.unshift(line);\n }\n\n protected indent(text: string): string {\n return this._indent + text;\n }\n\n\n abstract toString(): string;\n}\n\nexport abstract class ContainerBlock extends Block {\n if(condition: string, options?: CreateBlockOptions): IfBuilder {\n const builder = new IfBuilder(condition, options?.name, this._indent + \" \", this);\n if (options?.unshift === true) {\n this.unshift(builder);\n } else {\n this.push(builder);\n }\n\n return builder;\n }\n\n raw(raw: string, options?: CreateBlockOptions): RawBuilder {\n const builder = new RawBuilder(raw, options?.name, this._indent + \" \", this);\n this.push(builder);\n return builder;\n }\n\n function(name?: string, options?: CreateBlockOptions): FunctionBuilder {\n const builder = new FunctionBuilder(name, options?.name, this._indent + \" \", this);\n this.push(builder);\n return builder;\n }\n\n factory(name?: string, options?: CreateBlockOptions): FunctionFactoryBuilder {\n const builder = new FunctionFactoryBuilder(name, options?.name, this._indent + \" \", this);\n this.push(builder);\n return builder;\n }\n\n variable(declaration: string, options?: CreateBlockOptions): VariableBuilder {\n const builder = new VariableBuilder(declaration, options?.name, this._indent + \" \", this);\n this.push(builder);\n return builder;\n }\n\n assign(variableName: string, options?: CreateBlockOptions): AssignmentBuilder {\n const builder = new AssignmentBuilder(variableName, options?.name, this._indent + \" \", this);\n this.push(builder);\n return builder;\n }\n\n object(options?: CreateBlockOptions): ObjectBuilder {\n const builder = new ObjectBuilder(options?.name, this._indent + \" \", this);\n this.push(builder);\n return builder;\n }\n\n slot(name: string) {\n const builder = new SlotBlock(name, this._indent + \" \", this);\n this.push(builder);\n return builder;\n }\n\n array(accessor: string, options?: CreateBlockOptions) {\n const builder = new ArrayBuilder(accessor, options?.name, this._indent + \" \", this);\n this.push(builder);\n return builder;\n }\n}\n\nexport type StringType = \"template\" | \"default\";\n\nexport class StringBuilder extends Block {\n\n private _type: StringType;\n\n constructor(type: StringType, name?: string, parentIndent: string = \"\", parent?: Block) {\n super(name, parentIndent, parent);\n this._type = type;\n }\n\n append(value: string) {\n this._lines.push(value);\n return this;\n }\n\n toString() {\n if (this._type === \"template\") {\n return \"`\" + this._lines.join(\"\") + \"`\";\n }\n\n return `\"${this._lines.join(\"\")}\"`;\n }\n}\n\nexport class SlotBlock extends ContainerBlock {\n\n constructor(name: string, parentIndent: string = \"\", parent?: Block) {\n super(name, parentIndent, parent);\n }\n\n insert(line: string | Block) {\n this.push(line);\n }\n\n toString(): string {\n return this._lines.map(line =>\n typeof line === 'string'\n ? this.indent(line)\n : line.toString()\n ).join('\\n\\n');\n }\n}\n\nexport class AssignmentBuilder extends ContainerBlock {\n protected _variableName: string;\n protected _value?: string | Block;\n protected _functionName?: string;\n\n get getValue() {\n return this._value;\n }\n\n constructor(variableName: string, name?: string, parentIndent: string = \"\", parent?: Block) {\n super(name, parentIndent, parent);\n this._variableName = variableName;\n }\n\n value(value: string): this {\n this._value = value;\n return this;\n }\n\n and(and: string, options?: CreateBlockOptions): this {\n this._value = new AndBuilder(and, options?.name, this._indent, this);\n return this;\n }\n\n object(options?: CreateBlockOptions): ObjectBuilder {\n const objectBuilder = new ObjectBuilder(options?.name, this._indent, this);\n\n this._value = objectBuilder;\n\n return objectBuilder;\n }\n\n call(functionName: string, options?: CreateBlockOptions): ObjectBuilder {\n this._functionName = functionName;\n const objectBuilder = new ObjectBuilder(options?.name, this._indent, this);\n\n this._value = objectBuilder;\n\n return objectBuilder;\n }\n\n string(type: StringType, options?: CreateBlockOptions) {\n const stringBuilder = new StringBuilder(type, options?.name, this._indent, this);\n\n this._value = stringBuilder;\n\n return stringBuilder;\n }\n\n toString(): string {\n\n if (this._value == null) {\n throw new Error(\"Value cannot be null for AssignmentBuilder Builder\")\n }\n\n if (this._functionName != null) {\n return this.indent(`${this._variableName} = ${this._functionName}(${this._value.toString()});`);\n }\n\n return this.indent(`${this._variableName} = ${this._value.toString()};`);\n }\n}\n\nexport class AndBuilder extends ContainerBlock {\n\n constructor(and: string, name?: string, parentIndent: string = \"\", parent?: Block) {\n super(name, parentIndent, parent);\n this._lines.push(and);\n }\n\n and(and: string) {\n this._lines.push(and);\n }\n\n toString() {\n return this._lines.join(\" && \")\n }\n}\n\nexport class VariableBuilder extends Block {\n protected _declaration: string;\n protected _value?: string | Block;\n\n get getValue() {\n return this._value;\n }\n\n constructor(declaration: string, name?: string, parentIndent: string = \"\", parent?: Block) {\n super(name, parentIndent, parent);\n this._declaration = declaration;\n }\n\n value(value: string): this {\n this._value = value;\n return this;\n }\n\n object(options?: CreateBlockOptions): ObjectBuilder {\n const objectBuilder = new ObjectBuilder(options?.name, this._indent, this);\n\n this._value = objectBuilder;\n\n return objectBuilder;\n }\n\n array(accessor: string, options?: CreateBlockOptions): ArrayBuilder {\n const arrayBuilder = new ArrayBuilder(accessor, options?.name, this._indent, this);\n\n this._value = arrayBuilder;\n\n return arrayBuilder;\n }\n\n toString(): string {\n\n if (this._value == null) {\n throw new Error(\"Value cannot be null for Variable Builder\")\n }\n\n return this.indent(`const ${this._declaration} = ${this._value.toString()};`);\n }\n}\n\nexport class RawBuilder extends ContainerBlock {\n private _raw: string;\n\n constructor(raw: string, name?: string, parentIndent: string = \"\", parent?: Block) {\n super(name, parentIndent, parent);\n this._raw = raw;\n }\n\n toString(): string {\n return `${this._raw}\\n`;\n }\n}\n\nexport class ObjectBuilder extends Block {\n\n property(line: string) {\n // Add comma to previous line if it exists and isn't a brace\n if (this._lines.length > 0) {\n const lastLine = this._lines[this._lines.length - 1];\n if (typeof lastLine === 'string' && !lastLine.endsWith(\"{\")) {\n this._lines[this._lines.length - 1] = lastLine + \",\";\n }\n }\n this.push(line);\n return this;\n }\n\n nested(propertyName: string, name?: string) {\n const builder = new ObjectBuilder(name, this._indent + \" \", this);\n // Add comma to previous line if it exists and isn't a brace\n if (this._lines.length > 0) {\n const lastLine = this._lines[this._lines.length - 1];\n if (typeof lastLine === 'string' && !lastLine.endsWith(\"{\")) {\n this._lines[this._lines.length - 1] = lastLine + \",\";\n }\n }\n // Add the property name and opening brace\n this.push(`${propertyName}: {`);\n // Add the nested builder\n this.push(builder);\n // Add the closing brace\n this.push(\"}\");\n return builder;\n }\n\n toString(): string {\n // Check if this is a nested object's content\n const isNestedContent = this._parent instanceof ObjectBuilder;\n\n if (isNestedContent) {\n // For nested object contents, just return the lines\n return this._lines.map(line =>\n typeof line === 'string'\n ? this.indent(\" \" + line)\n : line.toString()\n ).join('\\n');\n }\n\n // For root objects, include the braces\n const lines = [\n \"{\",\n ...this._lines.map(line =>\n typeof line === 'string'\n ? this.indent(\" \" + line)\n : line.toString()\n ),\n this.indent(\"}\")\n ];\n\n return lines.join('\\n');\n }\n}\n\nexport class FunctionFactoryBuilder extends ContainerBlock {\n private _functionName?: string;\n private _params: Param[] = [];\n private _return: boolean = false;\n\n constructor(functionName?: string, sectionName?: string, parentIndent: string = \"\", parent?: Block) {\n super(sectionName, parentIndent, parent);\n this._functionName = functionName;\n }\n\n getParameters() {\n return [...this._params];\n }\n\n createParameter(value: any): Param {\n const name = `injection${this._params.length}`;\n return {\n name,\n value\n }\n }\n\n parameters(...params: Param[]): this {\n this._params.push(...params);\n return this;\n }\n\n return() {\n this._return = true;\n return this;\n }\n\n appendBody(line: string): this {\n this.push(line);\n return this;\n }\n\n invoke() {\n const body = this.toString();\n const parameterNames = this._getParameterNames();\n const parameterValues = this._getParameterValues();\n\n return Function(...parameterNames, body)(...parameterValues)\n }\n\n private _getParameterNames() {\n return this._params.map(w => w.name).join(\", \")\n }\n\n private _getParameterValues() {\n return this._params.map(w => w.value);\n }\n\n toString(): string {\n const r = this._return === true ? \"return \" : \"\";\n const signature = this._functionName\n ? `${r}function ${this._functionName}(${this._getParameterNames()})`\n : `${r}function(${this._getParameterNames()})`;\n\n const lines = [\n this.indent(signature + \" {\"),\n ...this._lines.map(line =>\n typeof line === 'string'\n ? this.indent(\" \" + line)\n : line.toString()\n ),\n this.indent(\"}\")\n ];\n\n return lines.join('\\n');\n }\n}\n\nexport class FunctionBuilder extends ContainerBlock {\n private _functionName?: string;\n private _params: (string | GenericParam)[] = [];\n private _return: boolean = false;\n\n constructor(functionName?: string, sectionName?: string, parentIndent: string = \"\", parent?: Block) {\n super(sectionName, parentIndent, parent);\n this._functionName = functionName;\n }\n\n parameters(...params: (string | GenericParam)[]): this {\n this._params.push(...params);\n return this;\n }\n\n return() {\n this._return = true;\n return this;\n }\n\n appendBody(line: string): this {\n this.push(line);\n return this;\n }\n\n private _getParameterKeys() {\n return this._params.map(w => typeof w === \"object\" ? w.name : w).join(\", \")\n }\n\n toCallable() {\n return `${this._functionName}(${this._params.map(w => typeof w === \"object\" ? w.callName : w).join(\", \")})`\n }\n\n toString(): string {\n const r = this._return === true ? \"return \" : \"\";\n const signature = this._functionName\n ? `${r}function ${this._functionName}(${this._getParameterKeys()})`\n : `${r}function(${this._getParameterKeys()})`;\n\n const lines = [\n this.indent(signature + \" {\"),\n ...this._lines.map(line =>\n typeof line === 'string'\n ? this.indent(\" \" + line)\n : line.toString()\n ),\n this.indent(\"}\")\n ];\n\n return lines.join('\\n');\n }\n}\n\nexport class ArrayBuilder extends Block {\n constructor(accessor: string, name?: string, parentIndent: string = \"\", parent?: Block) {\n super(name, parentIndent, parent);\n this._lines.push(accessor);\n }\n\n append(accessor: string) {\n this._lines.push(accessor);\n return this;\n }\n\n toString() {\n return `[${this._lines.join(\",\")}]`\n }\n}\n\nexport class IfBuilder extends ContainerBlock {\n private _condition: string;\n\n constructor(condition: string, name?: string, parentIndent: string = \"\", parent?: Block) {\n super(name, parentIndent, parent);\n this._condition = condition;\n }\n\n appendBody(line: string): this {\n this.push(line);\n return this;\n }\n\n unshiftBody(line: string): this {\n this.unshift(line);\n return this;\n }\n\n private stringifyLine(line: Line) {\n if (typeof line === 'string') {\n return this.indent(\" \" + line);\n }\n\n if (Array.isArray(line)) {\n return line.join(\"\\r\\n\")\n }\n\n return line.toString();\n }\n\n toString(): string {\n // need to join with \\r\\n because we are not an object\n const lines = [\n this.indent(`if (${this._condition}) {`),\n this._lines.map(x => this.stringifyLine(x)).join(\"\\r\\n\"),\n this.indent(\"}\")\n ]\n\n return lines.join(\"\\n\\n\");\n }\n}\n\nexport class CodeBuilder extends ContainerBlock {\n\n toString(): string {\n return this._lines.map(line =>\n typeof line === 'string'\n ? this.indent(line)\n : line.toString()\n ).join('\\n\\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}","import { logger } from \"../utilities\";\n\nconst measurements: Record<string, number> = {}\n\nexport const now = (): number => {\n if (typeof performance !== 'undefined' && performance.now) {\n // Browser or modern Node.js\n return performance.now();\n }\n\n // Fallback for older environments\n return Date.now();\n}\n\nexport const measure = {\n start: (name: string): void => {\n measurements[name] = now();\n },\n end: (name: string): void => {\n const start = measurements[name];\n\n delete measurements[name];\n\n const delta = now() - start;\n\n logger.log(`[ROUTIER] - Performance: ${name} took ${delta}`);\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","/**\n * Levelled logging, resolved once.\n *\n * Three things about the previous implementation drove this shape:\n *\n * - **There was no way to turn logging off.** `globalThis.__ROUTIER_DEBUG__` was only ever\n * compared against `true`, so setting it to `false` did nothing — while\n * `docs/how-to/debug-logging.md` documented exactly that as the way to force logging off.\n * A documented switch that silently does nothing is worse than no switch.\n * - **`NODE_ENV === 'test'` enabled it.** Every Jest run therefore logged, because Jest always\n * sets `NODE_ENV=test`. Measured on the S7 stress scenario, which drives ~2,000 saves through\n * a plugin that logs three lines per query: 12.4s with logging, ~6s without. Test runners also\n * capture console output by snapshotting a stack trace per call, so the cost is far above what\n * writing to a terminal would suggest — and the output buries whatever the failure was.\n * - **It was all-or-nothing, and re-resolved per call.** An error could not be kept while debug\n * was dropped, and every one of the ~97 call sites re-read `globalThis` and `process.env`.\n *\n * Levels are compared numerically against a value cached at module load. Measured against a\n * no-op console at 200k calls: an enabled call costs ~70ns, a call rejected by the gate ~3ns.\n * Building the arguments the call site passes in accounts for ~0.2ns of that 3ns, which is why\n * this keeps the ordinary `logger.debug(msg, payload)` signature instead of taking a thunk —\n * a lazy API would recover 0.3% of an enabled call's cost and would have to change every call\n * site to do it.\n */\n\n/** Ordered from most severe to most verbose. `silent` discards everything. */\nexport const LOG_LEVELS = ['silent', 'error', 'warn', 'info', 'debug'] as const;\n\nexport type LogLevel = (typeof LOG_LEVELS)[number];\n\n/** Numeric rank, so a gate is one integer comparison. */\nconst RANK: Record<LogLevel, number> = {\n silent: 0,\n error: 1,\n warn: 2,\n info: 3,\n debug: 4,\n};\n\nconst isLogLevel = (value: unknown): value is LogLevel =>\n typeof value === 'string' && (LOG_LEVELS as readonly string[]).includes(value);\n\n/**\n * Resolves the configured level, in precedence order.\n *\n * Ordered most specific first: an explicit level beats a boolean flag, a boolean flag beats an\n * environment variable, and an environment variable beats an inference from `NODE_ENV`. Anything\n * unrecognised is ignored rather than treated as an error — a typo'd level should not take down\n * an application, and `silent` is the safe direction to fall back to.\n */\nconst resolveLevel = (): LogLevel => {\n if (typeof globalThis !== 'undefined') {\n const g = globalThis as { __ROUTIER_LOG_LEVEL__?: unknown; __ROUTIER_DEBUG__?: unknown };\n\n if (isLogLevel(g.__ROUTIER_LOG_LEVEL__)) {\n return g.__ROUTIER_LOG_LEVEL__;\n }\n\n // Both directions honoured. `=== false` used to fall through to the NODE_ENV checks\n // below and re-enable the logging it was asked to suppress.\n if (g.__ROUTIER_DEBUG__ === true) return 'debug';\n if (g.__ROUTIER_DEBUG__ === false) return 'silent';\n }\n\n // There is deliberately no `import.meta.env` branch, although the documentation used to\n // promise one. It could never work: this package is bundled with rspack, which replaces\n // `import.meta` with `undefined`, so the check would read the *library's* build-time\n // environment rather than the application's — and referencing `import.meta` at all is a parse\n // error under a CommonJS build target, which is how the test suite loads this file. Vite and\n // similar apps set `__ROUTIER_LOG_LEVEL__` or `__ROUTIER_DEBUG__` from their own\n // `import.meta.env`, which is what the docs now describe.\n if (typeof process !== 'undefined' && process.env != null) {\n if (isLogLevel(process.env.ROUTIER_LOG_LEVEL)) {\n return process.env.ROUTIER_LOG_LEVEL as LogLevel;\n }\n\n const debug = process.env.DEBUG;\n if (debug === 'routier' || debug === '*') return 'debug';\n\n const env = process.env.NODE_ENV?.toLowerCase();\n\n if (env === 'dev' || env === 'development') return 'debug';\n }\n\n // Warnings are on unless something turns them off.\n //\n // Routier warns when a query returns correct rows a slower way than it could, or when a filter\n // compares types that can never match. Both are the caller's to act on, and a default of\n // `silent` meant the only people who ever saw them were the ones who already knew to look.\n return 'warn';\n};\n\nlet level: LogLevel = resolveLevel();\nlet rank = RANK[level];\n\n/**\n * Overrides the level for the rest of the process.\n *\n * The configuration above is read once, at import, which is what makes the gate cheap — but it\n * also means an application that decides its verbosity after startup, or a test that wants to\n * assert on output, has no way in. This is that way in.\n */\nexport const setLogLevel = (next: LogLevel): void => {\n if (isLogLevel(next) === false) {\n throw new Error(`Unknown log level \"${next}\". Expected one of: ${LOG_LEVELS.join(', ')}`);\n }\n\n level = next;\n rank = RANK[next];\n};\n\nexport const getLogLevel = (): LogLevel => level;\n\n/** Re-reads the environment. For tests that change it after this module was imported. */\nexport const resetLogLevel = (): void => {\n level = resolveLevel();\n rank = RANK[level];\n};\n\n/**\n * Whether a message at this level would be emitted.\n *\n * For the rare call site whose *arguments* are expensive to build — a serialization, a deep\n * clone, a join over a large collection. An ordinary payload object is not worth guarding; see\n * the measurement in the header.\n */\nexport const isLogLevelEnabled = (at: LogLevel): boolean => rank >= RANK[at];\n\ntype ConsoleMethod = 'log' | 'info' | 'warn' | 'error' | 'debug' | 'table';\n\nconst emit = (at: LogLevel, method: ConsoleMethod, args: unknown[]) => {\n if (rank < RANK[at]) {\n return;\n }\n\n // Resolved at call time rather than captured once: test harnesses and browser devtools both\n // replace console methods after modules have loaded, and a captured reference would keep\n // writing past the replacement.\n (console[method] as (...a: unknown[]) => void)(...args);\n};\n\nexport const logger = {\n /** General-purpose output. Carried at `info`, since `log` names a console method, not a level. */\n log: (...args: unknown[]): void => emit('info', 'log', args),\n info: (...args: unknown[]): void => emit('info', 'info', args),\n warn: (...args: unknown[]): void => emit('warn', 'warn', args),\n error: (...args: unknown[]): void => emit('error', 'error', args),\n debug: (...args: unknown[]): void => emit('debug', 'debug', args),\n /** Diagnostic tabular output; verbose by nature, so it sits at `debug`. */\n table: (...args: unknown[]): void => emit('debug', 'table', args),\n};\n","export const hash = (value: string, seed: number = 0) => {\n // From Stack Overflow\n // https://stackoverflow.com/a/52171480/3329760\n let h1 = 0xdeadbeef ^ seed, h2 = 0x41c6ce57 ^ seed;\n\n for (let i = 0, ch: number; i < value.length; i++) {\n ch = value.charCodeAt(i);\n h1 = Math.imul(h1 ^ ch, 2654435761);\n h2 = Math.imul(h2 ^ ch, 1597334677);\n }\n\n h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507);\n h1 ^= Math.imul(h2 ^ (h2 >>> 13), 3266489909);\n h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507);\n h2 ^= Math.imul(h1 ^ (h1 >>> 13), 3266489909);\n\n return 4294967296 * (2097151 & h2) + (h1 >>> 0);\n}\n\n/**\n * Fast string hash optimized for comparisons.\n * Uses djb2 algorithm - very fast and good distribution for short to medium strings.\n * Same input always produces same output (deterministic).\n * \n * @param value - The string to hash\n * @param seed - Optional seed value (default: 5381)\n * @returns A positive 32-bit integer hash value\n * \n * @example\n * ```ts\n * fastHash(\"test\") === fastHash(\"test\") // true\n * fastHash(\"test\") !== fastHash(\"test2\") // true\n * ```\n */\nexport const fastHash = (value: string, seed: number = 5381): number => {\n let hash = seed;\n for (let i = 0; i < value.length; i++) {\n hash = ((hash << 5) + hash) + value.charCodeAt(i);\n }\n return hash >>> 0; // Convert to unsigned 32-bit integer\n}\n\n/**\n * Converts any value to a readable string representation.\n * Handles primitives, objects, arrays, classes, dates, errors, and functions.\n * Supports depth limiting to prevent infinite recursion on circular references.\n * \n * @param obj - The value to stringify\n * @param maxDepth - Maximum depth for nested objects (default: 3)\n * @param currentDepth - Current recursion depth (default: 0)\n * @returns String representation of the value\n * \n * @example\n * ```ts\n * stringifyObject({ name: \"test\", count: 5 }) // '{ name: \"test\", count: 5 }'\n * stringifyObject([1, 2, 3]) // '[1, 2, 3]'\n * stringifyObject(new Date()) // 'Date(2024-01-01T00:00:00.000Z)'\n * ```\n */\nexport function stringifyObject(obj: unknown, maxDepth: number = 3, currentDepth: number = 0): string {\n if (obj === null) return 'null';\n if (obj === undefined) return 'undefined';\n\n const type = typeof obj;\n\n switch (type) {\n case 'string':\n return `\"${obj}\"`;\n case 'number':\n case 'boolean':\n return String(obj);\n case 'function':\n return `[Function: ${getFunctionName(obj as Function)}]`;\n case 'object':\n if (currentDepth >= maxDepth) {\n return '[Max Depth Reached]';\n }\n return stringifyObjectValue(obj, maxDepth, currentDepth);\n default:\n return `[${type}]`;\n }\n}\n\nfunction getFunctionName(fn: Function): string {\n const name = fn.name;\n return name || 'anonymous';\n}\n\nfunction getObjectProperties(obj: any): Record<string, any> {\n const properties: Record<string, any> = {};\n\n for (const key in obj) {\n if (obj.hasOwnProperty(key)) {\n properties[key] = obj[key];\n }\n }\n\n return properties;\n}\n\nfunction stringifyObjectValue(obj: any, maxDepth: number, currentDepth: number): string {\n if (obj === null) return 'null';\n\n if (obj instanceof Date) {\n return `Date(${obj.toISOString()})`;\n }\n\n if (obj instanceof Error) {\n return `Error(${obj.message})`;\n }\n\n if (obj instanceof RegExp) {\n return obj.toString();\n }\n\n if (Array.isArray(obj)) {\n return stringifyArray(obj, maxDepth, currentDepth);\n }\n\n if (obj.constructor && obj.constructor.name !== 'Object') {\n return stringifyClassInstance(obj, maxDepth, currentDepth);\n }\n\n return stringifyPlainObject(obj, maxDepth, currentDepth);\n}\n\nfunction stringifyArray(arr: any[], maxDepth: number, currentDepth: number): string {\n if (arr.length === 0) return '[]';\n\n const items = arr.slice(0, 5).map(item =>\n stringifyObject(item, maxDepth, currentDepth + 1)\n );\n\n const suffix = arr.length > 5 ? `... (+${arr.length - 5} more)` : '';\n return `[${items.join(', ')}${suffix}]`;\n}\n\nfunction stringifyClassInstance(obj: any, maxDepth: number, currentDepth: number): string {\n const className = obj.constructor.name;\n const properties = getObjectProperties(obj);\n\n if (Object.keys(properties).length === 0) {\n return `${className} {}`;\n }\n\n const props = Object.entries(properties)\n .slice(0, 5)\n .map(([key, value]) => {\n const isPrimitive = value === null || value === undefined ||\n (typeof value !== 'object' && typeof value !== 'function');\n const depth = isPrimitive ? currentDepth : currentDepth + 1;\n return `${key}: ${stringifyObject(value, maxDepth, depth)}`;\n });\n\n const suffix = Object.keys(properties).length > 5 ?\n `... (+${Object.keys(properties).length - 5} more)` : '';\n\n return `${className} { ${props.join(', ')}${suffix} }`;\n}\n\nfunction stringifyPlainObject(obj: any, maxDepth: number, currentDepth: number): string {\n const properties = getObjectProperties(obj);\n\n if (Object.keys(properties).length === 0) {\n return '{}';\n }\n\n const props = Object.entries(properties)\n .slice(0, 5)\n .map(([key, value]) => {\n const isPrimitive = value === null || value === undefined ||\n (typeof value !== 'object' && typeof value !== 'function');\n const depth = isPrimitive ? currentDepth : currentDepth + 1;\n return `${key}: ${stringifyObject(value, maxDepth, depth)}`;\n });\n\n const suffix = Object.keys(properties).length > 5 ?\n `... (+${Object.keys(properties).length - 5} more)` : '';\n\n return `{ ${props.join(', ')}${suffix} }`;\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))","// 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};","import { DefaultValue, ForeignKey, FunctionBody, PropertyDeserializer, PropertySerializer, SchemaModifiers, SchemaTypes, PropertyTransform } from \"../../types\";\n\nexport abstract class SchemaBase<T extends any, TModifiers extends SchemaModifiers> {\n\n abstract instance: T;\n modifiers: TModifiers;\n\n isNullable: boolean = false;\n isUnmapped: boolean = false;\n isOptional: boolean = false;\n isKey: boolean = false;\n isIdentity: boolean = false;\n isReadonly: boolean = false;\n isDistinct: boolean = false;\n /**\n * Set by `.modify(x => x.transform(...))`. A live reference, never stringified.\n * `null` when the property is stored as it is.\n */\n transform: PropertyTransform<unknown> | null = null;\n indexes: string[] = [];\n fromPropertyName: string | null = null;\n /**\n * How many numbers a vector holds. `null` for every other type.\n *\n * Declared here rather than on `SchemaVector` because a modifier WRAPS rather than\n * extends: `s.vector(1536).optional()` is a `SchemaOptional`, and anything reachable only\n * through the original class is lost the moment a modifier is added. `type` survives for\n * exactly this reason — the copy constructor below carries it — and a dimension count has\n * to travel with it, or an optional vector reaches a backend as a vector of unknown width\n * and cannot be given a column.\n *\n * `innerSchema` is the cautionary example: it lives on `SchemaArray` alone, so a modified\n * array arrives with no element type and clones through the slow path.\n */\n dimensions: number | null = null;\n /**\n * The longest string the property is declared to hold. `null` for every other type, and\n * for a string that declares nothing.\n *\n * Declared here rather than on `SchemaString` for the same reason as `dimensions` above:\n * `s.string({ maxLength: 4000 }).optional()` is a `SchemaOptional`, so anything reachable\n * only through `SchemaString` is lost the moment a modifier is added.\n *\n * A declaration, never a validation. Core does not check a value against it and does not\n * truncate. The backend that can use the number does: MySQL gives the column\n * `VARCHAR(maxLength)` instead of the blanket `VARCHAR(255)`. Every other backend ignores\n * it, because a string column that is already unbounded cannot be made more correct by\n * knowing a bound.\n */\n maxLength: number | null = null;\n /**\n * Whether this string may be tokenised into a full-text search index.\n *\n * Set by `.searchable()`, and only ever true on a string. Eligibility, not membership: a\n * collection that never declares `.searchIndex()` indexes nothing regardless.\n *\n * Copied by the constructor below, so `s.string().searchable().optional()` stays searchable.\n * Every flag on this class is copied for the same reason: a modifier WRAPS rather than\n * extends, so anything the constructor forgets is silently dropped the moment a property\n * gains one more modifier.\n */\n isSearchable: boolean = false;\n\n foreignKeyDefinition: ForeignKey<unknown> | null = null;\n tags: string[] = [];\n injected: any = null;\n defaultValue: DefaultValue<T> | null = null;\n valueSerializer: PropertySerializer<T> | null = null;\n valueDeserializer: PropertyDeserializer<T> | null = null;\n type: SchemaTypes;\n functionBody: FunctionBody<any, T> | null;\n private _schemaBase = true;\n readonly literals: T[] = [];\n\n constructor(entity?: SchemaBase<T, TModifiers>, literals?: T[]) {\n\n if (entity != null) {\n this.valueSerializer = entity.valueSerializer;\n this.valueDeserializer = entity.valueDeserializer;\n this.functionBody = entity.functionBody;\n this.isNullable = entity.isNullable;\n this.isOptional = entity.isOptional;\n this.isKey = entity.isKey;\n this.isIdentity = entity.isIdentity;\n this.isReadonly = entity.isReadonly;\n this.defaultValue = entity.defaultValue;\n this.type = entity.type;\n this.injected = entity.injected;\n this.indexes = entity.indexes;\n this.fromPropertyName = entity.fromPropertyName;\n this.tags = entity.tags;\n this.transform = entity.transform;\n this.dimensions = entity.dimensions;\n this.maxLength = entity.maxLength;\n this.isSearchable = entity.isSearchable;\n this.isDistinct = entity.isDistinct;\n }\n\n if (literals) {\n this.literals = literals;\n }\n }\n}","import { SchemaModifiers } from \"../../types\";\nimport { SchemaBase } from \"../base/SchemaBase\";\n\nexport class SchemaDistinct<T extends any, TModifiers extends SchemaModifiers> extends SchemaBase<T, TModifiers> {\n\n instance: T;\n private _schemaDistinct = true;\n\n constructor(current: SchemaBase<T, TModifiers>) {\n super(current);\n this.instance = current.instance;\n this.isDistinct = true;\n }\n}","import { SchemaModifiers } from \"../../types\";\nimport { SchemaBase } from \"../base/SchemaBase\";\n\nexport class SchemaIdentity<T, TModifiers extends SchemaModifiers> extends SchemaBase<T, TModifiers> {\n instance: T;\n private _schemaIdentity = true;\n\n constructor(current: SchemaBase<T, TModifiers>) {\n super(current);\n this.instance = current.instance;\n this.isIdentity = true;\n }\n}","import { SchemaModifiers } from \"../../types\";\nimport { SchemaBase } from \"../base/SchemaBase\";\nimport { SchemaNullable } from \"./SchemaNullable\";\nimport { SchemaOptional } from \"./SchemaOptional\";\n\n/**\n * Marks a string property as eligible for a full-text search index.\n *\n * Eligible, not indexed. The schema says what COULD be indexed; the collection builder's\n * `.searchIndex()` says that it IS. A property marked here on a collection that never declares\n * an index costs nothing at all — no rows, no write amplification, no storage.\n *\n * Like `s.vector()`, this exists to be RECOGNISED rather than to behave. It changes nothing\n * about how the property is stored, cloned, compared, serialized or queried. The datastore\n * reads the flag off the compiled schema to decide which values to tokenise; every plugin is\n * unaware the property is any different from another string.\n *\n * Declared on `SchemaString` only, so `s.number().searchable()` is a compile error rather than\n * a runtime surprise. The one case the type system cannot catch — a searchable string nested\n * inside an `s.object()` — is rejected when the schema compiles: v1 indexes root-level string\n * properties only.\n */\nexport class SchemaSearchable<T extends any, TModifiers extends SchemaModifiers> extends SchemaBase<T, TModifiers> {\n\n instance: T;\n private _schemaSearchable = true;\n\n constructor(current: SchemaBase<T, TModifiers>) {\n super(current);\n this.instance = current.instance;\n this.isSearchable = true;\n }\n\n /**\n * Declared here so `.searchable()` composes in BOTH senses — `.searchable().optional()` and\n * `.optional().searchable()` mean the same thing and both keep the flag. `SchemaDistinct`\n * exposes neither, which is why `.distinct().optional()` is unwritable and its copy-loss\n * (see `SchemaBase.isSearchable`) has never been noticed.\n */\n optional() {\n return new SchemaOptional<T, TModifiers | \"optional\">(this);\n }\n\n nullable() {\n return new SchemaNullable<T, TModifiers | \"nullable\">(this);\n }\n}\n","import { PropertyDeserializer, SchemaModifiers } from \"../../types\";\nimport { SchemaBase } from \"../base/SchemaBase\";\nimport { SchemaDeserialize } from \"./SchemaDeserialize\";\nimport { SchemaNullable } from \"./SchemaNullable\";\nimport { SchemaSearchable } from \"./SchemaSearchable\";\n\nexport class SchemaOptional<T extends any, TModifiers extends SchemaModifiers> extends SchemaBase<T, TModifiers> {\n\n instance: T;\n private _schemaOptional = true;\n\n constructor(current: SchemaBase<T, TModifiers>) {\n super(current);\n this.instance = current.instance;\n this.isOptional = true;\n }\n\n nullable() {\n return new SchemaNullable<T, TModifiers | \"nullable\">(this);\n }\n\n /**\n * Only callable when the property underneath is a string.\n *\n * A wrapper does not know what it wraps at runtime, but the type does: `T` is the value\n * type, so `s.number().optional()` is a `SchemaOptional<number>` and fails this `this`\n * constraint. That is the gate — there is no runtime check, because a builder that offers\n * a method it will then reject has already failed at its job.\n *\n * Constrained on `instance` alone rather than the whole class. `SchemaBase` holds `T` in\n * contravariant positions too (`valueSerializer`, `defaultValue`), so requiring the full\n * `SchemaOptional<string, ...>` would reject a literal union like\n * `s.string(\"draft\", \"published\")`, which is a perfectly good searchable string.\n *\n * An absent value contributes no tokens.\n */\n searchable(this: { instance: string }) {\n return new SchemaSearchable<T, TModifiers | \"searchable\">(this as unknown as SchemaBase<T, TModifiers>);\n }\n\n deserialize(deserializer: PropertyDeserializer<T | undefined>) {\n return new SchemaDeserialize<T | undefined, TModifiers | \"deserialize\">(deserializer, this);\n }\n\n\n}","import { DefaultValue, PropertyDeserializer, SchemaModifiers } from \"../../types\";\nimport { SchemaBase } from \"../base/SchemaBase\";\nimport { SchemaDefault } from \"./SchemaDefault\";\nimport { SchemaDeserialize } from \"./SchemaDeserialize\";\nimport { SchemaOptional } from \"./SchemaOptional\";\nimport { SchemaSearchable } from \"./SchemaSearchable\";\n\nexport class SchemaNullable<T extends any, TModifiers extends SchemaModifiers> extends SchemaBase<T, TModifiers> {\n instance: T;\n private _schemaNullable = true;\n\n constructor(current: SchemaBase<T, TModifiers>) {\n super(current);\n this.instance = current.instance;\n this.isNullable = true;\n }\n\n optional() {\n return new SchemaOptional<T, TModifiers | \"optional\">(this);\n }\n\n /**\n * Only callable when the property underneath is a string — see the same method on\n * `SchemaOptional` for why the constraint is on `instance` rather than the whole class.\n *\n * A null value contributes no tokens.\n */\n searchable(this: { instance: string }) {\n return new SchemaSearchable<T, TModifiers | \"searchable\">(this as unknown as SchemaBase<T, TModifiers>);\n }\n\n default<I = never>(value: DefaultValue<T | null, I>, injected?: I) {\n return new SchemaDefault<T | null, I, TModifiers | \"default\">(value, injected, this);\n }\n\n deserialize(deserializer: PropertyDeserializer<T | null>) {\n return new SchemaDeserialize<T | null, TModifiers | \"deserialize\">(deserializer, this);\n }\n\n\n}","import { PropertyDeserializer, PropertySerializer, SchemaModifiers } from \"../../types\";\nimport { SchemaBase } from \"../base/SchemaBase\";\nimport { SchemaDeserialize } from \"./SchemaDeserialize\";\n\nexport class SchemaSerialize<T extends any, TModifiers extends SchemaModifiers> extends SchemaBase<T, TModifiers> {\n instance: T;\n private _schemaSerialize = true;\n\n constructor(serializer: PropertySerializer<T>, current: SchemaBase<T, TModifiers>) {\n super(current);\n this.instance = current.instance;\n this.valueSerializer = serializer;\n }\n\n deserialize(deserializer: PropertyDeserializer<T>) {\n return new SchemaDeserialize<T, TModifiers | \"deserialize\">(deserializer, this);\n }\n}","import { DefaultValue, PropertyDeserializer, PropertySerializer, SchemaModifiers } from \"../../types\";\nimport { SchemaBase } from \"../base/SchemaBase\";\nimport { SchemaDefault } from \"./SchemaDefault\";\nimport { SchemaDeserialize } from \"./SchemaDeserialize\";\nimport { SchemaFrom } from \"./SchemaFrom\";\nimport { SchemaSerialize } from \"./SchemaSerialize\";\n\nexport class SchemaReadonly<T extends any, TModifiers extends SchemaModifiers> extends SchemaBase<T, TModifiers> {\n\n instance: T;\n private _schemaReadonly = true;\n\n constructor(current: SchemaBase<T, TModifiers>) {\n super(current);\n this.instance = current.instance;\n this.isReadonly = true;\n }\n\n default<I = never>(value: DefaultValue<T, I>, injected?: I) {\n return new SchemaDefault<T, I, TModifiers | \"default\">(value, injected, this);\n }\n\n deserializer(deserializer: PropertyDeserializer<T>) {\n return new SchemaDeserialize<T, TModifiers | \"deserialize\">(deserializer, this);\n }\n\n serializer(serializer: PropertySerializer<T>) {\n return new SchemaSerialize<T, TModifiers | \"deserialize\">(serializer, this);\n }\n\n from(propertyName: string) {\n return new SchemaFrom<T, TModifiers>(propertyName, this);\n }\n}","import { DefaultValue, PropertyDeserializer, PropertySerializer, SchemaModifiers } from \"../../types\";\nimport { SchemaBase } from \"../base/SchemaBase\";\nimport { SchemaDefault } from \"./SchemaDefault\";\nimport { SchemaDeserialize } from \"./SchemaDeserialize\";\nimport { SchemaDistinct } from \"./SchemaDistinct\";\nimport { SchemaIdentity } from \"./SchemaIdentity\";\nimport { SchemaNullable } from \"./SchemaNullable\";\nimport { SchemaOptional } from \"./SchemaOptional\";\nimport { SchemaReadonly } from \"./SchemaReadonly\";\nimport { SchemaSerialize } from \"./SchemaSerialize\";\n\nexport class SchemaFrom<T extends any, TModifiers extends SchemaModifiers> extends SchemaBase<T, TModifiers> {\n instance: T;\n private _schemaFrom = true;\n\n constructor(propertyName: string, current: SchemaBase<T, TModifiers>) {\n super(current);\n this.instance = current.instance;\n this.fromPropertyName = propertyName;\n }\n\n default<I = never>(value: DefaultValue<T, I>, injected?: I) {\n return new SchemaDefault<T, I, TModifiers | \"default\">(value, injected, this);\n }\n\n deserialize(deserializer: PropertyDeserializer<T>) {\n return new SchemaDeserialize<T, TModifiers | \"deserialize\">(deserializer, this);\n }\n\n distinct() {\n return new SchemaDistinct<T, TModifiers | \"distinct\">(this);\n }\n\n identity() {\n return new SchemaIdentity<T, TModifiers | \"identity\" | \"readonly\">(this);\n }\n\n optional() {\n return new SchemaOptional<T, TModifiers | \"optional\">(this);\n }\n\n nullable() {\n return new SchemaNullable<T, TModifiers | \"nullable\">(this);\n }\n\n readonly() {\n return new SchemaReadonly<T, TModifiers | \"readonly\">(this);\n }\n\n serialize(serializer: PropertySerializer<T>) {\n return new SchemaSerialize<T, TModifiers | \"serialize\">(serializer, this);\n }\n\n\n}","import { DefaultValue, PropertyDeserializer, PropertySerializer, SchemaModifiers } from \"../../types\";\nimport { SchemaBase } from \"../base/SchemaBase\";\nimport { SchemaDefault } from \"./SchemaDefault\";\nimport { SchemaFrom } from \"./SchemaFrom\";\nimport { SchemaOptional } from \"./SchemaOptional\";\nimport { SchemaSerialize } from \"./SchemaSerialize\";\n\nexport class SchemaDeserialize<T extends any, TModifiers extends SchemaModifiers> extends SchemaBase<T, TModifiers> {\n instance: T;\n private _schemaDeserialize = true;\n\n constructor(deserializer: PropertyDeserializer<T>, current: SchemaBase<T, TModifiers>) {\n super(current);\n this.instance = current.instance;\n this.valueDeserializer = deserializer;\n }\n\n serialize(serializer: PropertySerializer<T>) {\n return new SchemaSerialize<T, TModifiers | \"serialize\">(serializer, this);\n }\n\n from(propertyName: string) {\n return new SchemaFrom<T, TModifiers>(propertyName, this);\n }\n\n optional() {\n return new SchemaOptional<T, TModifiers | \"optional\">(this);\n }\n\n default<I = never>(value: DefaultValue<T | null, I>, injected?: I) {\n return new SchemaDefault<T | null, I, TModifiers | \"default\">(value, injected, this);\n }\n\n}","import { logger } from \"../../../utilities\";\nimport { DefaultValue, PropertyDeserializer, PropertySerializer, SchemaModifiers } from \"../../types\";\nimport { SchemaBase } from \"../base/SchemaBase\";\nimport { SchemaDeserialize } from \"./SchemaDeserialize\";\nimport { SchemaFrom } from \"./SchemaFrom\";\nimport { SchemaSerialize } from \"./SchemaSerialize\";\n\nexport class SchemaDefault<T extends any, I, TModifiers extends SchemaModifiers> extends SchemaBase<T, TModifiers> {\n instance: T;\n private _schemaDefault = true;\n\n constructor(defaultValue: DefaultValue<T, I>, injected: I, current: SchemaBase<T, TModifiers>) {\n super(current);\n\n if (defaultValue == null) {\n logger.warn(\"Do not use `.default(null)` in your schema, please use `.default(() => null)`\")\n }\n\n this.instance = current.instance;\n this.injected = injected;\n this.defaultValue = defaultValue;\n }\n\n serialize(serializer: PropertySerializer<T>) {\n return new SchemaSerialize<T, TModifiers | \"serialize\">(serializer, this);\n }\n\n deserialize(deserializer: PropertyDeserializer<T>) {\n return new SchemaDeserialize<T, TModifiers | \"deserialize\">(deserializer, this);\n }\n\n from(propertyName: string) {\n return new SchemaFrom<T, TModifiers>(propertyName, this);\n }\n}","import { uuidv4 } from \"../../../utilities\";\nimport { DefaultValue, PropertyDeserializer, PropertySerializer, SchemaModifiers } from \"../../types\";\nimport { SchemaBase } from \"../base/SchemaBase\";\nimport { SchemaDefault } from \"./SchemaDefault\";\nimport { SchemaDeserialize } from \"./SchemaDeserialize\";\nimport { SchemaDistinct } from \"./SchemaDistinct\";\nimport { SchemaFrom } from \"./SchemaFrom\";\nimport { SchemaNullable } from \"./SchemaNullable\";\nimport { SchemaOptional } from \"./SchemaOptional\";\nimport { SchemaReadonly } from \"./SchemaReadonly\";\nimport { SchemaSerialize } from \"./SchemaSerialize\";\n\nexport class SchemaIndex<T extends any, TModifiers extends SchemaModifiers> extends SchemaBase<T, TModifiers> {\n\n instance: T;\n private _schemaIndex = true;\n\n constructor(current: SchemaBase<T, TModifiers>, ...indexes: string[]) {\n super(current);\n this.instance = current.instance;\n\n if (indexes.length === 0) {\n indexes.push(uuidv4()); // Create our own unique index identifier\n }\n\n this.indexes = indexes;\n }\n\n optional() {\n return new SchemaOptional<T, TModifiers | \"optional\">(this);\n }\n\n nullable() {\n return new SchemaNullable<T, TModifiers | \"nullable\">(this);\n }\n\n default<I = never>(value: DefaultValue<T, I>, injected?: I) {\n return new SchemaDefault<T, I, TModifiers | \"default\">(value, injected, this);\n }\n\n readonly() {\n return new SchemaReadonly<T, TModifiers | \"readonly\">(this);\n }\n\n deserialize(deserializer: PropertyDeserializer<T>) {\n return new SchemaDeserialize<T, TModifiers | \"deserialize\">(deserializer, this);\n }\n\n serialize(serializer: PropertySerializer<T>) {\n return new SchemaSerialize<T, TModifiers | \"serialize\">(serializer, this);\n }\n\n distinct() {\n return new SchemaDistinct<T, TModifiers | \"distinct\">(this);\n }\n\n from(propertyName: string) {\n return new SchemaFrom<T, TModifiers>(propertyName, this);\n }\n}","import { DefaultValue, PropertyDeserializer, PropertySerializer, SchemaModifiers } from \"../../types\";\nimport { SchemaBase } from \"../base/SchemaBase\";\nimport { SchemaArray } from \"../types\";\nimport { SchemaDefault } from \"./SchemaDefault\";\nimport { SchemaDeserialize } from \"./SchemaDeserialize\";\nimport { SchemaDistinct } from \"./SchemaDistinct\";\nimport { SchemaFrom } from \"./SchemaFrom\";\nimport { SchemaIndex } from \"./SchemaIndex\";\nimport { SchemaNullable } from \"./SchemaNullable\";\nimport { SchemaOptional } from \"./SchemaOptional\";\nimport { SchemaReadonly } from \"./SchemaReadonly\";\nimport { SchemaSerialize } from \"./SchemaSerialize\";\n\nexport class SchemaTag<T extends any, TModifiers extends SchemaModifiers> extends SchemaBase<T, TModifiers> {\n instance: T;\n private _schemaTag = true;\n\n constructor(tags: string[], current: SchemaBase<T, TModifiers>) {\n super(current);\n this.tags = tags;\n this.instance = current.instance;\n }\n\n from(propertyName: string) {\n return new SchemaFrom<T, TModifiers>(propertyName, this);\n }\n\n optional() {\n return new SchemaOptional<T, TModifiers | \"optional\">(this);\n }\n\n nullable() {\n return new SchemaNullable<T, TModifiers | \"nullable\">(this);\n }\n\n default<I = never>(value: DefaultValue<T, I>, injected?: I) {\n return new SchemaDefault<T, I, TModifiers | \"default\">(value, injected, this);\n }\n\n readonly() {\n return new SchemaReadonly<T, TModifiers | \"readonly\">(this);\n }\n\n deserialize(deserializer: PropertyDeserializer<T>) {\n return new SchemaDeserialize<T, TModifiers | \"deserialize\">(deserializer, this);\n }\n\n serialize(serializer: PropertySerializer<T>) {\n return new SchemaSerialize<T, TModifiers | \"serialize\">(serializer, this);\n }\n\n array() {\n return new SchemaArray<typeof this, TModifiers>(this as unknown as SchemaArray<typeof this, TModifiers>);\n }\n\n index(...indexes: string[]) {\n return new SchemaIndex<T, TModifiers>(this, ...indexes);\n }\n\n distinct() {\n return new SchemaDistinct<T, TModifiers | \"distinct\">(this);\n }\n}","import { SchemaBase } from \"../base/SchemaBase\";\nimport { SchemaDefault } from \"../modifiers/SchemaDefault\";\nimport { SchemaNullable } from \"../modifiers/SchemaNullable\";\nimport { SchemaOptional } from \"../modifiers/SchemaOptional\";\nimport { SchemaDeserialize } from '../modifiers/SchemaDeserialize';\nimport { SchemaSerialize } from '../modifiers/SchemaSerialize';\nimport { SchemaIndex } from \"../modifiers/SchemaIndex\";\nimport { DefaultValue, PropertyDeserializer, PropertySerializer, SchemaModifiers, SchemaTypes } from \"../../types\";\nimport { SchemaFrom } from \"../modifiers/SchemaFrom\";\nimport { SchemaTag } from \"../modifiers/SchemaTag\";\n\nexport class SchemaArray<T extends any, TModifiers extends SchemaModifiers> extends SchemaBase<T[], TModifiers> {\n\n instance: T[];\n type = SchemaTypes.Array;\n private _schemaArray = true;\n readonly innerSchema?: SchemaBase<any, any>; // we need to know the type of the array, that is what this is for\n\n constructor(entity?: SchemaBase<T[], TModifiers>, literals?: T[][]) {\n super(entity, literals);\n this.innerSchema = entity;\n }\n\n from(propertyName: string) {\n return new SchemaFrom<T[], TModifiers>(propertyName, this);\n }\n\n optional() {\n return new SchemaOptional<T[], TModifiers | \"optional\">(this);\n }\n\n nullable() {\n return new SchemaNullable<T[], TModifiers | \"nullable\">(this);\n }\n\n default<I = never>(value: DefaultValue<T[], I>, injected?: I) {\n return new SchemaDefault<T[], I, TModifiers | \"default\">(value, injected, this);\n }\n\n deserialize(deserializer: PropertyDeserializer<T[]>) {\n return new SchemaDeserialize<T[], TModifiers | \"deserialize\">(deserializer, this);\n }\n\n serialize(serializer: PropertySerializer<T[]>) {\n return new SchemaSerialize<T[], TModifiers | \"serialize\">(serializer, this);\n }\n\n index(...indexes: string[]) {\n return new SchemaIndex<T[], TModifiers>(this, ...indexes);\n }\n\n tag(...tags: string[]) {\n return new SchemaTag<T[], TModifiers>(tags, this);\n }\n\n\n}","import { DefaultValue, PropertyDeserializer, PropertySerializer, SchemaModifiers, SchemaTypes } from \"../../types\";\nimport { SchemaBase } from \"../base/SchemaBase\";\nimport { SchemaDefault } from \"../modifiers/SchemaDefault\";\nimport { SchemaDeserialize } from \"../modifiers/SchemaDeserialize\";\nimport { SchemaDistinct } from \"../modifiers/SchemaDistinct\";\nimport { SchemaFrom } from \"../modifiers/SchemaFrom\";\nimport { SchemaIndex } from \"../modifiers/SchemaIndex\";\nimport { SchemaNullable } from \"../modifiers/SchemaNullable\";\nimport { SchemaOptional } from \"../modifiers/SchemaOptional\";\nimport { SchemaReadonly } from \"../modifiers/SchemaReadonly\";\nimport { SchemaSerialize } from \"../modifiers/SchemaSerialize\";\nimport { SchemaTag } from \"../modifiers/SchemaTag\";\nimport { SchemaArray } from \"./SchemaArray\";\n\nexport class SchemaBoolean<T extends boolean, TModifiers extends SchemaModifiers> extends SchemaBase<T, TModifiers> {\n\n instance: T;\n type = SchemaTypes.Boolean;\n private _schemaBoolean = true;\n\n from(propertyName: string) {\n return new SchemaFrom<T, TModifiers>(propertyName, this);\n }\n\n optional() {\n return new SchemaOptional<T, TModifiers | \"optional\">(this);\n }\n\n nullable() {\n return new SchemaNullable<T, TModifiers | \"nullable\">(this);\n }\n\n default<I = never>(value: DefaultValue<T, I>, injected?: I) {\n return new SchemaDefault<T, I, TModifiers | \"default\">(value, injected, this);\n }\n\n readonly() {\n return new SchemaReadonly<T, TModifiers | \"readonly\">(this);\n }\n\n deserialize(deserializer: PropertyDeserializer<T>) {\n return new SchemaDeserialize<T, TModifiers | \"deserialize\">(deserializer, this);\n }\n\n serialize(serializer: PropertySerializer<T>) {\n return new SchemaSerialize<T, TModifiers | \"serialize\">(serializer, this);\n }\n\n array() {\n return new SchemaArray<typeof this, TModifiers>(this as unknown as SchemaArray<typeof this, TModifiers>);\n }\n\n index(...indexes: string[]) {\n return new SchemaIndex<T, TModifiers>(this, ...indexes);\n }\n\n distinct() {\n return new SchemaDistinct<T, TModifiers | \"distinct\">(this);\n }\n\n tag(...tags: string[]) {\n return new SchemaTag<T, TModifiers>(tags, this);\n }\n\n\n}","import { DefaultValue, PropertyDeserializer, PropertySerializer, SchemaModifiers, SchemaTypes } from \"../../types\";\nimport { SchemaBase } from \"../base/SchemaBase\";\nimport { SchemaDefault } from \"../modifiers/SchemaDefault\";\nimport { SchemaDeserialize } from \"../modifiers/SchemaDeserialize\";\nimport { SchemaDistinct } from \"../modifiers/SchemaDistinct\";\nimport { SchemaFrom } from \"../modifiers/SchemaFrom\";\nimport { SchemaIndex } from \"../modifiers/SchemaIndex\";\nimport { SchemaNullable } from \"../modifiers/SchemaNullable\";\nimport { SchemaOptional } from \"../modifiers/SchemaOptional\";\nimport { SchemaReadonly } from \"../modifiers/SchemaReadonly\";\nimport { SchemaSerialize } from \"../modifiers/SchemaSerialize\";\nimport { SchemaTag } from \"../modifiers/SchemaTag\";\nimport { SchemaArray } from \"./SchemaArray\";\n\nexport class SchemaDate<T extends Date, TModifiers extends SchemaModifiers> extends SchemaBase<T, TModifiers> {\n\n instance: T;\n type = SchemaTypes.Date;\n private _schemaDate = true;\n\n from(propertyName: string) {\n return new SchemaFrom<T, TModifiers>(propertyName, this);\n }\n\n optional() {\n return new SchemaOptional<T, TModifiers | \"optional\">(this);\n }\n\n nullable() {\n return new SchemaNullable<T, TModifiers | \"nullable\">(this);\n }\n\n default<I = never>(value: DefaultValue<T, I>, injected?: I) {\n return new SchemaDefault<T, I, TModifiers | \"default\">(value, injected, this);\n }\n readonly() {\n return new SchemaReadonly<T, TModifiers | \"readonly\">(this);\n }\n\n deserialize(deserializer: PropertyDeserializer<T>) {\n return new SchemaDeserialize<T, TModifiers | \"deserialize\">(deserializer, this);\n }\n\n serialize(serializer: PropertySerializer<T>) {\n return new SchemaSerialize<T, TModifiers | \"serialize\">(serializer, this);\n }\n\n array() {\n return new SchemaArray<typeof this, TModifiers>(this as unknown as SchemaArray<typeof this, TModifiers>);\n }\n\n index(...indexes: string[]) {\n return new SchemaIndex<T, TModifiers>(this, ...indexes);\n }\n\n distinct() {\n return new SchemaDistinct<T, TModifiers | \"distinct\">(this);\n }\n\n tag(...tags: string[]) {\n return new SchemaTag<T, TModifiers>(tags, this);\n }\n\n\n}","import { SchemaBase } from \"../property/base/SchemaBase\";\nimport { SchemaModifiers, SchemaTypes } from \"../types\";\n\nexport class SchemaFunction<T extends any, I, TModifiers extends SchemaModifiers = \"unmapped\"> extends SchemaBase<() => T, TModifiers> {\n instance: () => T;\n type = SchemaTypes.Function;\n private _schemaFunction = true;\n\n constructor(fn: (injected: I) => T, injected: I, current?: SchemaBase<() => T, TModifiers>) {\n super(current);\n this.injected = injected;\n this.isUnmapped = true;\n this.functionBody = fn as any;\n }\n}","import { SchemaBase } from \"../property/base/SchemaBase\";\nimport { PropertyTransform, SchemaModifiers } from \"../types\";\n\n/**\n * A two-way transform between the value your application holds and the value that is stored.\n *\n * Declared in `.modify()`, beside `computed` and `function`, because it belongs to the same\n * family: a property whose stored form is derived rather than assigned. `computed` derives one\n * way and cannot come back; a transform declares both directions.\n *\n * ```ts\n * const cipher = myEncryption(keyring); // whatever you use — {} with `to` and `from`\n *\n * const userSchema = s.define('users', {\n * id: s.string().key().identity(),\n * ssn: s.string(),\n * }).modify(x => ({\n * ssn: x.transform(cipher),\n * })).compile();\n * ```\n *\n * `to` and `from` may be async, and they are held as LIVE references — never stringified into\n * generated code the way `computed` is. So they close over whatever they need, which is why\n * there is no `injected` argument to pass and no property to repeat.\n *\n * Nothing about this is encryption. Encryption is one thing a caller might write here;\n * compression, redaction, unit conversion and a custom codec are others. The library ships no\n * behaviour of its own for this — it only carries what you supply.\n */\nexport class SchemaTransform<T extends any, TModifiers extends SchemaModifiers = never> extends SchemaBase<T, TModifiers> {\n\n instance: T;\n private _schemaTransform = true;\n\n /**\n * Bound to the property it replaces when the schema is assembled.\n *\n * You do not pass the property in. `.modify()` already knows which one you mean — it is\n * the key you assigned to — so repeating `s.string()` would be ceremony for nothing.\n */\n bindTo(underlying: SchemaBase<T, TModifiers>) {\n // The underlying property keeps its type, its key and identity flags, and its\n // modifiers. A transform changes how a value is STORED, never what it is: an\n // encrypted number is still a number, so `InferType` must not shift.\n Object.assign(this, underlying, { transform: this.transform, _schemaTransform: true });\n\n this.instance = underlying.instance;\n this.type = underlying.type;\n\n return this;\n }\n\n constructor(transform: PropertyTransform<T>) {\n super();\n this.instance = null as T;\n this.transform = transform as PropertyTransform<unknown>;\n }\n}\n\n\n","import { SchemaBase } from \"../base/SchemaBase\";\nimport { SchemaIdentity } from \"./SchemaIdentity\";\nimport { SchemaDefault } from \"./SchemaDefault\";\nimport { CompiledSchema, DefaultValue, InferType, SchemaModifiers } from \"../../types\";\nimport { SchemaFrom } from \"./SchemaFrom\";\nimport { SchemaTag } from \"./SchemaTag\";\n\nexport class SchemaForeignKey<T extends any, TModifiers extends SchemaModifiers, K extends {}> extends SchemaBase<T, TModifiers> {\n instance: T;\n private _schemaForeignKey = true;\n\n constructor(current: SchemaBase<T, TModifiers>, relatingSchema: CompiledSchema<K>, property: keyof InferType<CompiledSchema<K>>) {\n super(current);\n this.instance = current.instance;\n this.foreignKeyDefinition = {\n schema: relatingSchema,\n property: relatingSchema.getProperty(String(property))\n };\n }\n\n identity() {\n return new SchemaIdentity<T, TModifiers | \"identity\">(this);\n }\n\n default<I = never>(value: DefaultValue<T, I>, injected?: I) {\n return new SchemaDefault<T, I, TModifiers | \"default\">(value, injected, this);\n }\n\n from(propertyName: string) {\n return new SchemaFrom<T, TModifiers>(propertyName, this);\n }\n\n tag(...tags: string[]) {\n return new SchemaTag<T, TModifiers>(tags, this);\n }\n}","import { SchemaBase } from \"../base/SchemaBase\";\nimport { SchemaIdentity } from \"./SchemaIdentity\";\nimport { SchemaDefault } from \"./SchemaDefault\";\nimport { DefaultValue, IdType, SchemaModifiers } from \"../../types\";\nimport { SchemaFrom } from \"./SchemaFrom\";\nimport { SchemaTag } from \"./SchemaTag\";\n\nexport class SchemaKey<T extends IdType, TModifiers extends SchemaModifiers> extends SchemaBase<T, TModifiers> {\n instance: T;\n private _schemaKey = true;\n\n constructor(current: SchemaBase<T, TModifiers>) {\n super(current);\n this.instance = current.instance;\n this.isKey = true;\n }\n\n identity() {\n return new SchemaIdentity<T, TModifiers | \"identity\">(this);\n }\n\n default<I = never>(value: DefaultValue<T, I>, injected?: I) {\n return new SchemaDefault<T, I, TModifiers | \"default\">(value, injected, this);\n }\n\n from(propertyName: string) {\n return new SchemaFrom<T, TModifiers>(propertyName, this);\n }\n\n tag(...tags: string[]) {\n return new SchemaTag<T, TModifiers>(tags, this);\n }\n}","import { CompiledSchema, IdType, InferType, SchemaModifiers } from \"../../types\";\nimport { SchemaBase } from \"../base/SchemaBase\";\nimport { SchemaForeignKey } from \"./SchemaForeignKey\";\nimport { SchemaKey } from \"./SchemaKey\";\nimport { SchemaTag } from \"./SchemaTag\";\n\nexport class SchemaTracked<T extends any, TModifiers extends SchemaModifiers> extends SchemaBase<T, TModifiers> {\n\n instance: T;\n private _schemaTracked = true;\n\n constructor(current: SchemaBase<T, TModifiers>) {\n super(current);\n this.instance = current.instance;\n this.isUnmapped = false;\n }\n\n key(): T extends IdType ? SchemaKey<T, TModifiers | \"key\"> : never {\n return new SchemaKey(this as SchemaBase<T & IdType, TModifiers>) as T extends IdType ? SchemaKey<T, TModifiers | \"key\"> : never;\n }\n\n foreignKey<K extends {}>(relatingSchema: CompiledSchema<K>, property: keyof InferType<CompiledSchema<K>>) {\n return new SchemaForeignKey<T, TModifiers, K>(this, relatingSchema, property);\n }\n\n tag(...tags: string[]) {\n return new SchemaTag<T, TModifiers>(tags, this);\n }\n}","import { SchemaBase } from \"../property/base/SchemaBase\";\nimport { SchemaTracked } from '../property/modifiers/SchemaTracked';\nimport { SchemaModifiers, SchemaTypes } from \"../types\";\n\nexport class SchemaComputed<T extends any, I, TModifiers extends SchemaModifiers = \"computed\"> extends SchemaBase<T, TModifiers> {\n instance: T;\n type = SchemaTypes.Computed;\n private _schemaComputed = true;\n\n constructor(fn: T, injected: I, current?: SchemaBase<T, TModifiers>) {\n super(current);\n this.injected = injected;\n this.isUnmapped = true;\n this.functionBody = fn as any;\n }\n\n tracked() {\n return new SchemaTracked<T, Exclude<TModifiers, \"unmapped\">>(this as unknown as SchemaBase<T, Exclude<TModifiers, \"unmapped\">>);\n }\n}","import { UnknownRecord } from '../utilities';\nimport { SchemaBase } from './property/base/SchemaBase';\nimport { SchemaArray } from './property/types/SchemaArray';\nimport { DefaultValue, ForeignKey, FunctionBody, PropertyDeserializer, PropertySerializer, SchemaTypes, PropertyTransform } from './types';\n\n/**\n * Represents metadata and utilities for a property in a schema, including its type, name, parent, children, and serialization details.\n */\nexport class PropertyInfo<T extends {}> {\n\n get id() {\n if (this._idCache) {\n return this._idCache;\n }\n this._idCache = this.getPathArray().join(\".\");\n return this._idCache;\n }\n\n /** The name of the property. */\n readonly name: string;\n /** The name of the property we need to map from. */\n readonly from: string | null = null;\n /** The schema type of the property. */\n readonly type: SchemaTypes;\n\n /** Whether the property can be null. */\n readonly isNullable: boolean;\n /** Whether the property is optional. */\n readonly isOptional: boolean;\n /** Whether the property is a key. */\n readonly isKey: boolean;\n /** Foreign key schema and property */\n readonly foreignKeyDefinition: ForeignKey<unknown> | null;\n /** Whether the property is an identity property. */\n readonly isIdentity: boolean;\n /** Whether the property is readonly. */\n readonly isReadonly: boolean;\n /** Whether the property is unmapped. */\n readonly isUnmapped: boolean;\n /** Whether the property is distinct. */\n readonly isDistinct: boolean;\n\n\n /**\n * A two-way transform between the application value and the stored value, or `null`.\n *\n * A LIVE reference. Unlike `computed`, which is stringified into generated code, this is\n * held as-is so it can close over a key, a client, or anything else a caller needs — and\n * so it can be async, which generated code cannot be.\n */\n readonly transform: PropertyTransform<unknown> | null;\n /** Indexes associated with the property. */\n readonly indexes: string[];\n\n /** Any injected value for the property. */\n readonly injected: any | null = null;\n /** The default value for the property, if any. */\n readonly defaultValue: DefaultValue<any> | null = null;\n /** Serializer for the property value, if any. */\n readonly valueSerializer: PropertySerializer<T> | null = null;\n /** Deserializer for the property value, if any. */\n readonly valueDeserializer: PropertyDeserializer<T> | null = null;\n /** Function body for computed properties, if any. */\n readonly functionBody: FunctionBody<any, T> | null;\n /** Child properties of this property. */\n readonly children: PropertyInfo<T>[] = [];\n /** The schema this property belongs to. */\n readonly schema: SchemaBase<T, any>;\n /** The inner schema if this property is an array. */\n readonly innerSchema?: SchemaBase<unknown, any>;\n /** How many numbers this property holds if it is a vector, `null` otherwise. */\n readonly dimensions: number | null;\n /** The longest value this property is declared to hold, `null` if it declares none. */\n readonly maxLength: number | null;\n /**\n * Whether this property may be tokenised into a full-text search index.\n *\n * True only for a string. See the constructor — this is derived from the declaration and\n * the type together, not copied.\n */\n readonly isSearchable: boolean;\n /** Literal values allowed for this property. */\n readonly literals: T[];\n /** Tags passed from the schema */\n readonly tags: string[];\n\n /** The parent property, if any. */\n readonly parent?: PropertyInfo<T>;\n\n // Cached computed values for performance\n private _propertyChainCache?: PropertyInfo<T>[];\n private _pathArrayCache?: string[];\n private _parentPathArrayCache?: string[];\n private _idCache?: string;\n private _levelCache?: number;\n private _hasNullableParentsCache?: boolean;\n private _hasRenamedSegmentsCache?: boolean;\n\n constructor(schema: SchemaBase<T, any>, name: string, parent?: PropertyInfo<T> | null) {\n this.schema = schema;\n this.name = name;\n this.type = schema.type;\n this.literals = schema.literals;\n this.dimensions = schema.dimensions;\n this.maxLength = schema.maxLength;\n // Both, always. The builder already refuses `.searchable()` on anything but a string,\n // but that gate is a type and types do not exist at runtime — a schema rebuilt from\n // hand-written JSON can set the raw flag on a number. Deriving the answer here means\n // every reader gets a searchable property that is definitely a string, rather than each\n // one having to remember to check.\n this.isSearchable = schema.isSearchable && schema.type === SchemaTypes.String;\n\n if (schema instanceof SchemaArray) {\n this.innerSchema = schema.innerSchema;\n }\n\n this.isNullable = schema.isNullable;\n this.isOptional = schema.isOptional;\n this.isKey = schema.isKey;\n this.isIdentity = schema.isIdentity;\n this.isReadonly = schema.isReadonly;\n this.isUnmapped = schema.isUnmapped;\n this.injected = schema.injected;\n this.isDistinct = schema.isDistinct;\n this.transform = schema.transform;\n this.indexes = schema.indexes;\n this.from = schema.fromPropertyName;\n this.tags = schema.tags;\n this.foreignKeyDefinition = schema.foreignKeyDefinition;\n\n this.defaultValue = schema.defaultValue;\n this.valueSerializer = schema.valueSerializer;\n this.valueDeserializer = schema.valueDeserializer;\n this.functionBody = schema.functionBody;\n\n this.parent = parent;\n }\n\n /**\n * Returns the depth (level) of this property in the property tree.\n *\n * The root property has a level of 0. Each child property increases the level by 1.\n * Traverses up the parent chain, incrementing the level for each parent until the root is reached.\n * \n * @returns {number} The number of parent properties above this property (0 for root).\n */\n get level() {\n if (this._levelCache !== undefined) {\n return this._levelCache;\n }\n\n let level = 0;\n // oxlint-disable-next-line no-this-alias\n let current: PropertyInfo<T> | undefined = this;\n\n while (current) {\n if (current.parent == null) {\n this._levelCache = level;\n return level;\n }\n\n current = current.parent;\n level++;\n }\n\n this._levelCache = level;\n return level;\n }\n\n get isRenamed() {\n return !!this.from;\n }\n\n private _getPropertyChain(): PropertyInfo<T>[] {\n if (this._propertyChainCache) {\n return this._propertyChainCache;\n }\n\n const chain: PropertyInfo<T>[] = [];\n // oxlint-disable-next-line no-this-alias\n let current: PropertyInfo<T> | undefined = this;\n\n while (current) {\n chain.unshift(current);\n current = current.parent;\n }\n\n this._propertyChainCache = chain;\n return chain;\n }\n\n private _needsOptionalChaining(precedingProp: PropertyInfo<T> | null, assignmentType?: AssignmentType): boolean {\n if (assignmentType === \"ASSIGNMENT\") {\n return false;\n }\n\n if (assignmentType === \"FORCE_NULLABLE_OR_OPTIONAL\") {\n return true;\n }\n\n // The accessor guards the value it follows: entity.a?.c is safe when `a`\n // is nullable, entity?.a.c is not. The root can never be null.\n if (precedingProp == null) {\n return false;\n }\n\n return precedingProp.isNullable || precedingProp.isOptional;\n }\n\n private _resolvePathArray(options?: {\n root?: string,\n assignmentType?: AssignmentType\n useFromPropertyName?: boolean,\n }) {\n const propertyChain = this._getPropertyChain();\n const hasRoot = options?.root != null;\n const path: string[] = hasRoot ? [options!.root!] : [];\n let precedingProp: PropertyInfo<T> | null = null;\n\n for (const prop of propertyChain) {\n const accessor = this._needsOptionalChaining(precedingProp, options?.assignmentType) ? '?.' : '.';\n // Storage-side paths use `from` per segment; segments that were never\n // renamed keep their property name\n path.push(accessor, options?.useFromPropertyName ? (prop.from ?? prop.name) : prop.name);\n precedingProp = prop;\n }\n\n return path;\n }\n\n getResolvedName() {\n return this.from ?? this.name;\n }\n\n /**\n * Returns an array of property names representing the path from the root to this property.\n *\n * @returns {string[]} The property path as an array of names.\n */\n getPathArray() {\n if (this._pathArrayCache) {\n return this._pathArrayCache;\n }\n\n const path: string[] = [];\n const propertyChain = this._getPropertyChain();\n\n for (const prop of propertyChain) {\n path.push(prop.name);\n }\n\n this._pathArrayCache = path;\n return path;\n }\n\n /**\n * Returns an array of property names representing the path from the root to the parent of this property.\n *\n * @returns {string[]} The property path as an array of names, excluding this property.\n */\n getParentPathArray(options?: { useFromPropertyName?: boolean }) {\n if (options?.useFromPropertyName === true) {\n // Storage-side variant is uncached: `from` falls back to the property\n // name per segment\n const fromPath: string[] = [];\n const chain = this._getPropertyChain();\n\n for (let i = 0; i < chain.length - 1; i++) {\n const prop = chain[i];\n fromPath.push(prop.from ?? prop.name);\n }\n\n return fromPath;\n }\n\n if (this._parentPathArrayCache) {\n return this._parentPathArrayCache;\n }\n\n const path: string[] = [];\n const propertyChain = this._getPropertyChain();\n\n for (let i = 0; i < propertyChain.length - 1; i++) {\n const prop = propertyChain[i];\n path.push(prop.name);\n }\n\n this._parentPathArrayCache = path;\n return path;\n }\n\n /**\n * Returns true if any parent property is nullable or optional.\n *\n * @returns {boolean} True if any parent is nullable or optional, false otherwise.\n */\n get hasNullableParents() {\n if (this._hasNullableParentsCache !== undefined) {\n return this._hasNullableParentsCache;\n }\n\n let parent = this.parent;\n while (parent != null) {\n if (parent.isNullable || parent.isOptional) {\n this._hasNullableParentsCache = true;\n return true;\n }\n parent = parent.parent;\n }\n\n this._hasNullableParentsCache = false;\n return false;\n }\n\n /**\n * Returns true if this property or any parent is renamed with from().\n * Storage paths for such properties differ from their in-memory paths.\n *\n * @returns {boolean} True if any segment of the path is renamed, false otherwise.\n */\n get hasRenamedSegments(): boolean {\n if (this._hasRenamedSegmentsCache !== undefined) {\n return this._hasRenamedSegmentsCache;\n }\n\n // oxlint-disable-next-line no-this-alias\n let current: PropertyInfo<T> | undefined = this;\n while (current != null) {\n if (current.from != null) {\n this._hasRenamedSegmentsCache = true;\n return true;\n }\n current = current.parent;\n }\n\n this._hasRenamedSegmentsCache = false;\n return false;\n }\n\n /**\n * Returns true if any child property (recursively) is an identity property.\n *\n * @returns {boolean} True if any child is an identity property, false otherwise.\n */\n get hasIdentityChildren() {\n const children = [...this.children];\n for (let i = 0; i < children.length; i++) {\n const child = children[i];\n if (child.isIdentity === true) {\n return true;\n }\n if (child.children.length > 0) {\n children.push(...child.children)\n }\n }\n return false;\n }\n\n /**\n * Gets the value of this property from the given instance, following the property path.\n *\n * @param instance The object instance to retrieve the value from.\n * @returns The value of the property, or null if not found.\n */\n getValue(instance: UnknownRecord) {\n if (instance == null) {\n return null;\n }\n const pathArray = this.getPathArray();\n const length = pathArray.length;\n // Fast path for single level properties\n if (length === 1) {\n return instance[pathArray[0]];\n }\n let current: any = instance;\n for (let i = 0; i < length; i++) {\n if (current == null) {\n return null;\n }\n current = current[pathArray[i]];\n }\n return current;\n }\n\n /**\n * Sets the value of this property on the given instance, creating intermediate objects as needed.\n *\n * @param instance The object instance to set the value on.\n * @param value The value to set.\n */\n setValue(instance: UnknownRecord, value: unknown) {\n if (instance == null) {\n throw new Error('Cannot set value on null or undefined instance');\n }\n const pathArray = this.getPathArray();\n const length = pathArray.length;\n // Fast path for single level properties\n if (length === 1) {\n instance[pathArray[0]] = value;\n return;\n }\n let current: any = instance;\n let i = 0;\n // Navigate to the parent of the target property\n while (i < length - 1) {\n const prop = pathArray[i];\n const next = current[prop];\n // Only create new object if next level doesn't exist\n if (next == null) {\n current[prop] = {};\n }\n current = current[prop];\n i++;\n }\n // Set the value on the final property\n current[pathArray[length - 1]] = value;\n }\n\n /**\n * Returns a selector path string for this property, starting from the given parent variable name.\n *\n * @param options.parent The root variable name.\n * @param options.assignmentType Optional assignment type for path resolution.\n * @returns {string} The selector path string (e.g., 'parent.prop1.prop2').\n */\n getSelectrorPath(options: { parent: string, assignmentType?: AssignmentType, useFromPropertyName?: boolean, useRemappedName?: boolean }) {\n const parts = this._resolvePathArray({\n root: options.parent,\n assignmentType: options?.assignmentType,\n useFromPropertyName: options?.useFromPropertyName\n });\n return parts.join(\"\");\n }\n\n /**\n * Returns an assignment path string for this property, optionally starting from a parent variable name.\n *\n * @param options.parent Optional root variable name.\n * @returns {string} The assignment path string (e.g., 'prop1.prop2').\n */\n getAssignmentPath(options?: { parent?: string, useFromPropertyName?: boolean }) {\n const parts = this._resolvePathArray({\n root: options?.parent,\n assignmentType: \"ASSIGNMENT\",\n useFromPropertyName: options?.useFromPropertyName\n });\n\n if (options?.parent == null) {\n return parts.slice(1).join(\"\");\n }\n\n return parts.join(\"\");\n }\n\n deserialize(value: string | number) {\n\n if (this.valueDeserializer != null) {\n return this.valueDeserializer(value);\n }\n\n if (this.type === SchemaTypes.Date) {\n return new Date(value);\n }\n\n if (this.type === SchemaTypes.String) {\n return String(value);\n }\n\n if (this.type === SchemaTypes.Number) {\n return Number(value);\n }\n\n if (this.type === SchemaTypes.Boolean) {\n return Boolean(value);\n }\n\n return value;\n }\n}\n\ntype AssignmentType = \"FORCE_NULLABLE_OR_OPTIONAL\" | \"ASSIGNMENT\";","export class SlotPath {\n\n private _path: string[];\n\n get path() {\n return [...this._path]\n }\n\n constructor(...pathLike: string[]) {\n this._path = pathLike;\n }\n\n push(...pathLike: string[]) {\n this._path.push(...pathLike);\n }\n\n get(up: number = 0) {\n return this._path.slice(0, this._path.length - up).join(\".\")\n }\n}","/**\n * Counts non-overlapping occurrences of a term in text.\n *\n * Behavior:\n * - Case-sensitive matching\n * - If the search term is composed entirely of word characters (A–Z, a–z, 0–9, _),\n * enforce whole-word boundaries so \"red\" does not match inside \"redder\".\n * - If the search term contains any non-word character (e.g. \"=>\", \"()\", \"::\"),\n * match anywhere without boundary checks (useful for symbols).\n * - Non-overlapping matches (after a hit, advances by term length)\n * - Optimized single-character fast path; otherwise uses indexOf loop\n *\n * Examples:\n * - countWordOccurance(\"red redder red\", \"red\") => 2\n * - countWordOccurance(\"()=>{}\", \"=>\") => 1\n * - countWordOccurance(\"aaaa\", \"aa\") => 2 (non-overlapping)\n *\n * @param text The source text to scan\n * @param word The term to match (must be non-empty)\n * @returns The number of occurrences found\n */\nexport const countWordOccurance = (text: string, word: string) => {\n const wl = word.length;\n const tl = text.length;\n\n if (wl === 0 || wl > tl) return 0;\n\n // Fast path for single-character words\n if (wl === 1) {\n let c = 0;\n const code = word.charCodeAt(0);\n for (let i = 0; i < tl; i++) if (text.charCodeAt(i) === code) c++;\n return c;\n }\n\n let count = 0;\n let i = 0;\n\n function isWordCharCode(c: number): boolean {\n return (c >= 48 && c <= 57) // 0-9\n || (c >= 65 && c <= 90) // A-Z\n || (c >= 97 && c <= 122) // a-z\n || c === 95; // _\n }\n\n // Decide whether to enforce word boundaries based on the search term\n let enforceWordBoundaries = true;\n for (let k = 0; k < wl; k++) {\n const cc = word.charCodeAt(k);\n if (!isWordCharCode(cc)) {\n enforceWordBoundaries = false;\n break;\n }\n }\n\n while (true) {\n i = text.indexOf(word, i);\n if (i === -1) break;\n\n if (enforceWordBoundaries) {\n const left = i - 1;\n const right = i + wl;\n const leftOk = left < 0 || !isWordCharCode(text.charCodeAt(left));\n const rightOk = right >= tl || !isWordCharCode(text.charCodeAt(right));\n if (leftOk && rightOk) count++;\n } else {\n // No boundary enforcement for symbol-containing terms\n count++;\n }\n i += wl; // non-overlapping word matches\n }\n\n return count;\n}","import { CodeBuilder, ContainerBlock, IfBuilder, ObjectBuilder, SlotBlock } from '..';\nimport { PropertyInfo } from '../../schema/PropertyInfo';\nimport { SlotPath } from '../SlotPath';\nimport { SchemaError } from '../../errors/SchemaError';\nimport { uuid } from '../../utilities/uuid';\nimport { countWordOccurance } from '../utils';\n\nexport interface IHandler {\n setNext(handler: IHandler): IHandler;\n\n handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null;\n}\n\n/**\n * Terminal link for chains that apply only to a subset of properties (keys,\n * identities). Returning the builder marks every other property as\n * deliberately skipped, so a null return from any chain always means a real\n * coverage gap.\n */\nexport class NotApplicableHandler implements IHandler {\n\n setNext(handler: IHandler): IHandler {\n return handler;\n }\n\n handle(_: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n return builder;\n }\n}\n\nexport abstract class PropertyInfoHandler implements IHandler {\n\n private _next: IHandler | null;\n\n setNext(handler: IHandler): IHandler {\n this._next = handler;\n\n return handler;\n }\n\n handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n try {\n if (this._next) {\n return this._next.handle(property, builder);\n }\n\n return null;\n } catch (e: any) {\n throw new SchemaError(e, `Error handling property: ${property.name}`);\n }\n }\n\n protected buildSlotPath(property: PropertyInfo<any>, path: SlotPath) {\n\n const result = new SlotPath(...path.path);\n const items: string[] = []\n let p = property;\n\n while (p.parent != null) {\n items.unshift(p.name);\n p = p.parent;\n }\n\n items.unshift(p.name);\n\n result.push(...items);\n\n return result\n }\n\n /**\n * Dotted property path from the root entity (e.g. `nested.inner`), used as the\n * change-tracking path prefix so nested writes record against the root's\n * `__tracking__` under their full path.\n */\n protected getTrackingPath(property: PropertyInfo<any>): string {\n const names: string[] = [];\n let p: PropertyInfo<any> | null = property;\n\n while (p != null) {\n names.unshift(p.name);\n p = p.parent;\n }\n\n return names.join(\".\");\n }\n\n /**\n * Emits `if (<root>.a == null) <root>.a = {};` for every ancestor of a\n * nested property, so assignments through the target object never throw when a\n * parent object is absent. The guards run root-down, so grandparents are\n * materialized before their children.\n */\n protected emitDestinationAncestorGuards(property: PropertyInfo<any>, block: IfBuilder, options?: { root?: string, useFromPropertyName?: boolean }) {\n if (property.parent == null) {\n return;\n }\n\n const root = options?.root ?? \"destination\";\n const parentPathArray = property.getParentPathArray({ useFromPropertyName: options?.useFromPropertyName });\n\n for (let i = 0; i < parentPathArray.length; i++) {\n const pathSoFar = [root, ...parentPathArray.slice(0, i + 1)].join(\".\");\n block.appendBody(`if (${pathSoFar} == null) ${pathSoFar} = {};`);\n }\n }\n\n /**\n * Emits the guarded nested-property assignment shared by the serialize handlers:\n * reads the parent through an optional-chained selector (the entity may be a\n * partial — a delta payload or a create payload with absent nested parents),\n * materializes every `result` ancestor, then assigns `valueExpression` to the\n * property's storage-side path.\n */\n protected emitSerializeNestedAssignment(property: PropertyInfo<any>, slot: SlotBlock, valueExpression: string) {\n const parentSelectPath = property.parent!.getSelectrorPath({ parent: \"entity\", assignmentType: \"FORCE_NULLABLE_OR_OPTIONAL\" });\n const resultSelectorPath = property.getAssignmentPath({ parent: \"result\", useFromPropertyName: true });\n\n const ifSlot = slot.if(`${parentSelectPath} != null && Object.hasOwn(${parentSelectPath}, \"${property.name}\")`);\n\n this.emitDestinationAncestorGuards(property, ifSlot, { root: \"result\", useFromPropertyName: true });\n\n ifSlot.appendBody(`${resultSelectorPath} = ${valueExpression}`);\n }\n\n /**\n * Emits the source → destination copy for one property in the merge generator,\n * materializing destination ancestors first.\n *\n * With `onlyWhenChanged`, the assignment is skipped when both sides already hold\n * the same value (compared via `valueOf`, so equal Dates match). This preserves\n * reference identity on the destination when a merge carries no new information —\n * callers hold on to entity instances (e.g. a Date returned from add) and must not\n * see them silently replaced by an equal copy.\n */\n protected emitMergeCopy(property: PropertyInfo<any>, builder: CodeBuilder, options?: { onlyWhenChanged?: boolean }) {\n const selectorPath = property.getSelectrorPath({ parent: \"source\", assignmentType: \"FORCE_NULLABLE_OR_OPTIONAL\" });\n const slot = builder.get<SlotBlock>(\"factory.function.assignments\");\n const sourcePath = property.getAssignmentPath({ parent: \"source\" });\n const destinationPath = property.getAssignmentPath({ parent: \"destination\" });\n\n const ifBlock = slot.if(`${selectorPath} != null`);\n this.emitDestinationAncestorGuards(property, ifBlock);\n\n if (options?.onlyWhenChanged === true) {\n ifBlock.appendBody(`if (${destinationPath} == null || ${destinationPath}.valueOf() !== ${sourcePath}.valueOf()) { ${destinationPath} = ${sourcePath} }`);\n return;\n }\n\n ifBlock.appendBody(`${destinationPath} = ${sourcePath}`);\n }\n\n /**\n * Slot path of the ObjectBuilder that renders `property` inside the enriched\n * literal. Builders are registered as `[enriched.<path>]` under their parent\n * builder, so the lookup path must include every ancestor segment — a flat\n * root-level lookup only works for depth-1 properties.\n */\n protected buildEnrichedObjectSlotPath(property: PropertyInfo<any>, base: SlotPath): SlotPath {\n const result = new SlotPath(...base.path);\n const chain: PropertyInfo<any>[] = [];\n let p: PropertyInfo<any> | null = property;\n\n while (p != null) {\n chain.unshift(p);\n p = p.parent;\n }\n\n for (const item of chain) {\n result.push(`[${item.getAssignmentPath({ parent: \"enriched\" })}]`);\n }\n\n return result;\n }\n\n protected setEnrichedProperty(property: PropertyInfo<any>, root: CodeBuilder) {\n const entitySelectorPath = property.getAssignmentPath({ parent: \"entity\" });\n\n if (property.parent != null) {\n const slotPath = new SlotPath(\"factory\", \"function\", \"enriched\", \"object\", \"enriched\");\n const parentSlotPath = this.buildEnrichedObjectSlotPath(property.parent, slotPath);\n const objectBuilder = root.get<ObjectBuilder>(parentSlotPath.get());\n // Guarded read: the entity may be sparse (e.g. enrich on a create payload),\n // so the parent object cannot be assumed to exist\n const childEntityPathSelector = property.getSelectrorPath({ parent: \"entity\", assignmentType: \"FORCE_NULLABLE_OR_OPTIONAL\" });\n objectBuilder.property(`${property.name}: ${childEntityPathSelector}`);\n return;\n }\n\n const slotPath = new SlotPath(\"factory\", \"function\", \"enriched\", \"object\", \"enriched\");\n let enriched = root.getOrDefault<ObjectBuilder>(slotPath.get());\n\n if (enriched == null) {\n const enrichedSlot = root.get<SlotBlock>(\"factory.function.enriched\");\n enriched = enrichedSlot.variable(\"enriched\", { name: \"object\" }).object({ name: \"enriched\" });\n }\n\n enriched.property(`${property.name}: ${entitySelectorPath}`);\n }\n\n protected toNamedFunction(stringifiedFunction: string, parent: ContainerBlock) {\n const name = `_${uuid()}`;\n\n const builder = parent.function(name);\n const occurences = countWordOccurance(stringifiedFunction, \"=>\")\n\n if (occurences > 0) {\n\n const split = stringifiedFunction.split(\"=>\").map(w => w.trim());\n const parameters = split[0].replace(/\\(|\\)/g, \"\").split(\",\");\n let body = split[1];\n\n if (occurences > 1) {\n // we have a function that returns a function\n const index = stringifiedFunction.indexOf(\"=>\");\n body = stringifiedFunction.slice(index + 2, stringifiedFunction.length)\n }\n\n if (body.startsWith(\"{\") === true && body.endsWith(\"}\")) {\n\n // Remove brackets, wrapping function will have them\n builder.appendBody(body.slice(1, body.length - 1));\n\n return {\n builder,\n parameters\n };\n }\n\n builder.appendBody(`return ${body};`);\n return {\n builder,\n parameters\n }\n }\n\n throw new Error(\"Only arrow functions are allowed in the schema definition: function () {} ---> () => {}\");\n }\n}","import { CodeBuilder, ObjectBuilder, SlotBlock } from '../../blocks';\nimport { SlotPath } from '../../SlotPath';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\nexport class EnrichmentNullableObjectHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.type === SchemaTypes.Object && (property.isNullable || property.isOptional)) {\n\n const slotPath = new SlotPath(\"factory\", \"function\", \"enriched\", \"object\", \"enriched\");\n const nestedSlotPath = this.buildEnrichedObjectSlotPath(property, slotPath);\n\n // Generate null check for current level using parent relationships\n const entityPath = property.getSelectrorPath({ parent: \"entity\", assignmentType: \"FORCE_NULLABLE_OR_OPTIONAL\" });\n const enrichedPath = property.getAssignmentPath({ parent: \"enriched\" });\n\n const ifsSlot = builder.get<SlotBlock>(\"factory.function.ifs\");\n\n if (ifsSlot == null) {\n throw new Error(\"Error building enricher, could not find slot for factory.function.ifs\")\n }\n\n\n // Pass the root as parent so nested writes mark the root entity dirty,\n // and the full dotted path so the change is recorded under it\n ifsSlot.if(`${entityPath} != null`).appendBody(`${enrichedPath} = enableChangeTracking(${enrichedPath} || {}, \"${this.getTrackingPath(property)}\", enriched);`);\n\n let enriched = builder.getOrDefault<ObjectBuilder>(nestedSlotPath.get());\n\n if (enriched == null) {\n if (property.parent != null) {\n // Nested object: attach to the parent's ObjectBuilder (registered as\n // `[enriched.<parentPath>]`), never to the root — attaching to the root\n // hoists the subtree to the top level of the literal\n const parentSlotPath = this.buildEnrichedObjectSlotPath(property.parent, slotPath);\n const parentBuilder = builder.get<ObjectBuilder>(parentSlotPath.get());\n enriched = parentBuilder.nested(property.name, `[${enrichedPath}]`);\n } else {\n // Create the enriched result object when this is the first property\n // iterated — handler output cannot depend on schema property order\n let enrichedRoot = builder.getOrDefault<ObjectBuilder>(slotPath.get());\n\n if (enrichedRoot == null) {\n const enrichedSlot = builder.get<SlotBlock>(\"factory.function.enriched\");\n enrichedRoot = enrichedSlot.variable(\"enriched\", { name: \"object\" }).object({ name: \"enriched\" });\n }\n\n enriched = enrichedRoot.nested(property.name, `[${enrichedPath}]`);\n }\n }\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder, ObjectBuilder, SlotBlock } from '../../blocks';\nimport { SlotPath } from '../../SlotPath';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\nexport class EnrichmentObjectHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.type === SchemaTypes.Object && (property.isNullable || property.isOptional) === false) {\n\n const slotPath = new SlotPath(\"factory\", \"function\", \"enriched\", \"object\", \"enriched\");\n const nestedSlotPath = this.buildEnrichedObjectSlotPath(property, slotPath);\n\n // Generate null check for current level using parent relationships\n const enrichedPath = property.getAssignmentPath({ parent: \"enriched\" });\n\n const slot = builder.get<SlotBlock>(\"factory.function.assignment\");\n\n // Pass the root as parent so nested writes mark the root entity dirty,\n // and the full dotted path so the change is recorded under it\n slot.assign(enrichedPath).value(`enableChangeTracking(${enrichedPath} || {}, \"${this.getTrackingPath(property)}\", enriched)`)\n\n let enriched = builder.getOrDefault<ObjectBuilder>(nestedSlotPath.get());\n\n if (enriched == null) {\n if (property.parent != null) {\n // Nested object: attach to the parent's ObjectBuilder (registered as\n // `[enriched.<parentPath>]`), never to the root — attaching to the root\n // hoists the subtree to the top level of the literal\n const parentSlotPath = this.buildEnrichedObjectSlotPath(property.parent, slotPath);\n const parentBuilder = builder.get<ObjectBuilder>(parentSlotPath.get());\n enriched = parentBuilder.nested(property.name, `[${enrichedPath}]`);\n } else {\n // Create the enriched result object when this is the first property\n // iterated — handler output cannot depend on schema property order\n let enrichedRoot = builder.getOrDefault<ObjectBuilder>(slotPath.get());\n\n if (enrichedRoot == null) {\n const enrichedSlot = builder.get<SlotBlock>(\"factory.function.enriched\");\n enrichedRoot = enrichedSlot.variable(\"enriched\", { name: \"object\" }).object({ name: \"enriched\" });\n }\n\n enriched = enrichedRoot.nested(property.name, `[${enrichedPath}]`);\n }\n }\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\nexport class EnrichmentObjectIdentityHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.isIdentity === true && property.type == SchemaTypes.Object) {\n // do nothing right now\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder, SlotBlock } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\nexport class EnrichmentPrimitiveIdentityHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n // Computed identity props are NOT plain identities: the database cannot run the\n // compute function, so they fall through to EnrichmentComputedValueHandler,\n // which computes them once (when absent) over the fully-built entity\n if (property.isIdentity === true && property.type != SchemaTypes.Object && property.type != SchemaTypes.Computed) {\n const selectorPath = property.getSelectrorPath({ parent: \"entity\", assignmentType: \"FORCE_NULLABLE_OR_OPTIONAL\" });\n const slot = builder.get<SlotBlock>(\"factory.function.ifs\");\n const entitySelectorPath = property.getAssignmentPath({ parent: \"entity\" });\n const enrichedAssignmentPath = property.getAssignmentPath({ parent: \"enriched\" });\n\n slot.if(`${selectorPath} != null`).appendBody(`${enrichedAssignmentPath} = ${entitySelectorPath}`);\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo } from \"../../../schema\";\n\nexport class EnrichmentPrimitiveHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n this.setEnrichedProperty(property, builder);\n\n return builder;\n }\n}","import { CodeBuilder, FunctionFactoryBuilder, SlotBlock } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\nexport class EnrichmentFunctionHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.functionBody != null && property.type === SchemaTypes.Function) {\n\n const parameterNames: string[] = [\"enriched\", \"collectionName\"];\n\n if (property.injected != null) {\n\n const factory = builder.get<FunctionFactoryBuilder>(\"factory\");\n const parameter = factory.createParameter(property.injected);\n factory.parameters(parameter);\n\n parameterNames.push(parameter.name);\n }\n\n\n const declarationsSlot = builder.get<SlotBlock>(\"factory.function.declarations\");\n // Unwrap the functions to removing currying\n const defaultFunctionWithParameters = this.toNamedFunction(property.functionBody.toString(), declarationsSlot);\n\n defaultFunctionWithParameters.builder.parameters(...parameterNames.map((w, i) => ({ name: defaultFunctionWithParameters.parameters[i], callName: w })));\n\n const slot = builder.get<SlotBlock>(\"factory.function.assignment\");\n const enrichedAssignmentPath = property.getAssignmentPath({ parent: \"enriched\" });\n\n slot.assign(enrichedAssignmentPath).value(defaultFunctionWithParameters.builder.toCallable());\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder, SlotBlock } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo } from \"../../../schema\";\n\nexport class EnrichmentDefaultValueHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.defaultValue != null && typeof property.defaultValue !== \"function\") {\n\n this.setEnrichedProperty(property, builder);\n\n // Apply the literal default when no value came in, mirroring\n // EnrichmentDefaultFunctionHandler's if-block for function defaults\n const ifsSlot = builder.get<SlotBlock>(\"factory.function.ifs\");\n const checkPath = property.getSelectrorPath({ parent: \"enriched\", assignmentType: \"FORCE_NULLABLE_OR_OPTIONAL\" });\n const assignmentPath = property.getAssignmentPath({ parent: \"enriched\" });\n const ifBlock = ifsSlot.if(`${checkPath} == null`);\n\n // Nested property: ensure every ancestor object exists before the assignment\n if (property.parent != null) {\n const parentPathArray = property.getParentPathArray();\n\n for (let i = 0; i < parentPathArray.length; i++) {\n const pathSoFar = [\"enriched\", ...parentPathArray.slice(0, i + 1)].join(\".\");\n ifBlock.appendBody(`if (${pathSoFar} == null) ${pathSoFar} = {};`);\n }\n }\n\n ifBlock.appendBody(`${assignmentPath} = ${renderDefaultLiteral(property.defaultValue)}`);\n\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}\n\nconst renderDefaultLiteral = (value: unknown) => {\n\n if (value instanceof Date) {\n return `new Date(${value.getTime()})`;\n }\n\n // JSON covers strings (with escaping), numbers, booleans, plain objects and arrays\n return JSON.stringify(value);\n}","import { CodeBuilder, FunctionFactoryBuilder, SlotBlock } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo } from \"../../../schema\";\n\nexport class EnrichmentDefaultFunctionHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.defaultValue != null && typeof property.defaultValue === \"function\") {\n\n this.setEnrichedProperty(property, builder);\n\n // we need to add the call for this function too, want to create an if\n const declarationsSlot = builder.get<SlotBlock>(\"factory.function.declarations\");\n\n if (property.injected != null) {\n\n const factory = builder.get<FunctionFactoryBuilder>(\"factory\");\n\n if (factory == null) {\n throw new Error(\"Error building enricher, could not find slot for factory\")\n }\n\n const parameter = factory.createParameter(property.injected);\n factory.parameters(parameter);\n\n const defaultFunctionWithParameters = this.toNamedFunction(property.defaultValue.toString(), declarationsSlot);\n // This is ok, defaults can only inject one parameter anyways\n defaultFunctionWithParameters.builder.parameters(...defaultFunctionWithParameters.parameters.map(w => ({ name: w, callName: parameter.name })));\n\n\n const ifsSlot = builder.get<SlotBlock>(\"factory.function.ifs\");\n const enrichedAssignmentPath = property.getAssignmentPath({ parent: \"enriched\" });\n ifsSlot.if(`${enrichedAssignmentPath} == null`).appendBody(`${enrichedAssignmentPath} = ${defaultFunctionWithParameters.builder.toCallable()}`);\n\n return builder;\n }\n\n const defaultFunction = this.toNamedFunction(property.defaultValue.toString(), declarationsSlot);\n\n const ifsSlot = builder.get<SlotBlock>(\"factory.function.ifs\");\n const enrichedAssignmentPath = property.getAssignmentPath({ parent: \"enriched\" });\n ifsSlot.if(`${enrichedAssignmentPath} == null`).appendBody(`${enrichedAssignmentPath} = ${defaultFunction.builder.toCallable()}`);\n\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder, FunctionFactoryBuilder, SlotBlock } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\nexport class EnrichmentComputedValueHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.functionBody != null && property.type === SchemaTypes.Computed) {\n\n const parameterNames: string[] = [\"enriched\", \"collectionName\"];\n\n if (property.injected != null) {\n\n const factory = builder.get<FunctionFactoryBuilder>(\"factory\");\n const parameter = factory.createParameter(property.injected);\n factory.parameters(parameter);\n\n parameterNames.push(parameter.name);\n }\n\n const declarationsSlot = builder.get<SlotBlock>(\"factory.function.declarations\");\n const defaultFunctionWithParameters = this.toNamedFunction(property.functionBody.toString(), declarationsSlot);\n\n defaultFunctionWithParameters.builder.parameters(...parameterNames.map((w, i) => ({ name: defaultFunctionWithParameters.parameters[i], callName: w })));\n\n\n // Compute-once semantics for computed keys/identities: an existing value is\n // carried into the enriched literal and never recomputed — a key must stay\n // stable once assigned (content-hash ids would otherwise churn as the\n // entity's shape moves through pipeline stages). Non-key computed props keep\n // recompute-per-enrich behavior: their value is derived presentation data\n if (property.isKey === true || property.isIdentity === true) {\n this.setEnrichedProperty(property, builder);\n }\n\n const ifsSlot = builder.get<SlotBlock>(\"factory.function.ifs\");\n const enrichedAssignmentPath = property.getAssignmentPath({ parent: \"enriched\" });\n ifsSlot.if(`${enrichedAssignmentPath} == null`).appendBody(`${enrichedAssignmentPath} = ${defaultFunctionWithParameters.builder.toCallable()}`);\n\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { SchemaTypes } from \"../types\";\n\n/**\n * Types whose runtime value is a JS array.\n *\n * `Array` and `Vector` are the same thing to every layer that copies, compares, hashes or\n * freezes a value — a vector is a list of numbers and nothing more. They differ only where a\n * backend chooses storage, which is the one place that should ask for `SchemaTypes.Vector` by\n * name.\n *\n * This exists so adding a third array-shaped type is one edit rather than a hunt through\n * twelve handlers. Missing one of those is silent in the worst way: a vector that clones by\n * reference is shared with the change tracker's copy, so overwriting an embedding produces no\n * diff and the save reports nothing to do.\n */\nconst ARRAY_VALUED_TYPES = new Set<SchemaTypes>([\n SchemaTypes.Array,\n SchemaTypes.Vector,\n]);\n\n/** True when the property's value is a JS array and needs value rather than reference semantics. */\nexport const isArrayValued = (type: SchemaTypes) => ARRAY_VALUED_TYPES.has(type);\n\n/**\n * True when the property's elements are primitives, so a spread is a sufficient copy.\n *\n * A vector is always numbers, so it never needs the per-element deep copy an array of objects\n * or dates does.\n */\nconst PRIMITIVE_ELEMENT_TYPES = new Set<SchemaTypes | undefined>([\n SchemaTypes.String,\n SchemaTypes.Number,\n SchemaTypes.Boolean,\n]);\n\nexport const hasPrimitiveElements = (type: SchemaTypes, elementType: SchemaTypes | undefined) =>\n type === SchemaTypes.Vector || PRIMITIVE_ELEMENT_TYPES.has(elementType);\n","import { CodeBuilder, SlotBlock } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { isArrayValued, PropertyInfo } from \"../../../schema\";\n\n/**\n * Arrays participate in change tracking: the array itself is wrapped in the tracking\n * proxy (with the root as parent) so in-place mutations — push/splice/index writes —\n * mark the root entity dirty instead of being silently lost on save.\n */\nexport class EnrichmentArrayHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (isArrayValued(property.type)) {\n\n // Place the property in the enriched literal like any other leaf\n this.setEnrichedProperty(property, builder);\n\n const enrichedPath = property.getAssignmentPath({ parent: \"enriched\" });\n const ifsSlot = builder.get<SlotBlock>(\"factory.function.ifs\");\n\n ifsSlot.if(`${enrichedPath} != null`).appendBody(`${enrichedPath} = enableChangeTracking(${enrichedPath}, \"${this.getTrackingPath(property)}\", enriched);`);\n\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}\n","import { EnrichmentNullableObjectHandler } from \"./enrichment/EnrichmentNullableObjectHandler\";\nimport { EnrichmentObjectHandler } from \"./enrichment/EnrichmentObjectHandler\";\nimport { EnrichmentObjectIdentityHandler } from \"./enrichment/EnrichmentObjectIdentityHandler\";\nimport { EnrichmentPrimitiveIdentityHandler } from \"./enrichment/EnrichmentPrimitiveIdentityHandler\";\nimport { EnrichmentPrimitiveHandler } from './enrichment/EnrichmentPrimitiveHandler';\nimport { EnrichmentFunctionHandler } from './enrichment/EnrichmentFunctionHandler';\nimport { EnrichmentDefaultValueHandler } from './enrichment/EnrichmentDefaultValueHandler';\nimport { EnrichmentDefaultFunctionHandler } from './enrichment/EnrichmentDefaultFunctionHandler';\nimport { EnrichmentComputedValueHandler } from './enrichment/EnrichmentComputedValueHandler';\nimport { EnrichmentArrayHandler } from './enrichment/EnrichmentArrayHandler';\n\n/// Purpose: \nexport class EnrichmentHandlerBuilder {\n\n build() {\n const handler = new EnrichmentPrimitiveIdentityHandler();\n\n handler.setNext(new EnrichmentObjectIdentityHandler())\n .setNext(new EnrichmentObjectHandler())\n .setNext(new EnrichmentNullableObjectHandler())\n .setNext(new EnrichmentFunctionHandler())\n .setNext(new EnrichmentDefaultValueHandler())\n .setNext(new EnrichmentDefaultFunctionHandler())\n .setNext(new EnrichmentComputedValueHandler())\n .setNext(new EnrichmentArrayHandler())\n .setNext(new EnrichmentPrimitiveHandler());\n\n return handler;\n }\n}","import { CodeBuilder, FunctionFactoryBuilder, SlotBlock } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo } from \"../../../schema\";\n\nexport class MergeDefaultFunctionHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n // we only want this to run if the value for the property is null\n // we are changing merge to be more like enrich so we can handle injections\n // we may need to change more. Need to move towards factories\n if (property.defaultValue != null && typeof property.defaultValue === \"function\") {\n const defaultFunctionParameters: string[] = [];\n\n if (property.injected != null) {\n const factory = builder.get<FunctionFactoryBuilder>(\"factory\");\n const parameter = factory.createParameter(property.injected);\n factory.parameters(parameter);\n\n defaultFunctionParameters.push(parameter.name);\n }\n\n // A defaulted property still merges from the source; the default only fills\n // the gap when neither side has a value\n this.emitMergeCopy(property, builder, { onlyWhenChanged: true });\n\n const ifsSlot = builder.get<SlotBlock>(\"factory.function.ifs\");\n // we only want to run if the destination is null; the guarded selector keeps\n // the check from throwing when a destination ancestor is absent\n const selectorPath = property.getSelectrorPath({ parent: \"destination\", assignmentType: \"FORCE_NULLABLE_OR_OPTIONAL\" });\n const assignmentPath = property.getAssignmentPath({ parent: \"destination\" });\n\n const declarationsSlot = builder.get<SlotBlock>(\"factory.function.header\");\n const defaultFunctionWithParameters = this.toNamedFunction(property.defaultValue.toString(), declarationsSlot);\n\n defaultFunctionWithParameters.builder.parameters(...defaultFunctionParameters.map((w, i) => ({ name: defaultFunctionWithParameters.parameters[i], callName: w })));\n\n const defaultIf = ifsSlot.if(`${selectorPath} == null`);\n this.emitDestinationAncestorGuards(property, defaultIf);\n defaultIf.appendBody(`${assignmentPath} = ${defaultFunctionWithParameters.builder.toCallable()}`);\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\n/**\n * Object containers are not merged directly — their child properties merge\n * individually and materialize the destination ancestors they need.\n */\nexport class MergeObjectHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.type === SchemaTypes.Object) {\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}\n","import { CodeBuilder } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\nexport class MergePrimitiveHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.type != SchemaTypes.Object) {\n this.emitMergeCopy(property, builder);\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder, FunctionFactoryBuilder, SlotBlock } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\nexport class MergeComputedValueHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.functionBody != null && property.type === SchemaTypes.Computed) {\n const parameterNames: string[] = [\"source\", \"collectionName\"];\n\n if (property.injected != null) {\n\n const factory = builder.get<FunctionFactoryBuilder>(\"factory\");\n const parameter = factory.createParameter(property.injected);\n factory.parameters(parameter);\n\n parameterNames.push(parameter.name);\n }\n\n const declarationsSlot = builder.get<SlotBlock>(\"factory.function.header\");\n const defaultFunctionWithParameters = this.toNamedFunction(property.functionBody.toString(), declarationsSlot);\n\n defaultFunctionWithParameters.builder.parameters(...parameterNames.map((w, i) => ({ name: defaultFunctionWithParameters.parameters[i], callName: w })));\n\n const slot = builder.get<SlotBlock>(\"factory.function.assignments\");\n const enrichedAssignmentPath = property.getAssignmentPath({ parent: \"destination\" });\n\n // We want to recompute the value always in case there are changes\n slot.assign(enrichedAssignmentPath).value(defaultFunctionWithParameters.builder.toCallable());\n\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder, FunctionFactoryBuilder, SlotBlock } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo } from \"../../../schema\";\n\nexport class MergeDefaultValueHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.defaultValue != null && typeof property.defaultValue !== \"function\") {\n const defaultFunctionParameters: string[] = [];\n\n if (property.injected != null) {\n const factory = builder.get<FunctionFactoryBuilder>(\"factory\");\n const parameter = factory.createParameter(property.injected);\n factory.parameters(parameter);\n\n defaultFunctionParameters.push(parameter.name);\n }\n\n // A defaulted property still merges from the source; the default only fills\n // the gap when neither side has a value\n this.emitMergeCopy(property, builder, { onlyWhenChanged: true });\n\n const ifsSlot = builder.get<SlotBlock>(\"factory.function.ifs\");\n // we only want to run if the destination is null; the guarded selector keeps\n // the check from throwing when a destination ancestor is absent\n const selectorPath = property.getSelectrorPath({ parent: \"destination\", assignmentType: \"FORCE_NULLABLE_OR_OPTIONAL\" });\n const assignmentPath = property.getAssignmentPath({ parent: \"destination\" });\n\n const defaultIf = ifsSlot.if(`${selectorPath} == null`);\n this.emitDestinationAncestorGuards(property, defaultIf);\n defaultIf.appendBody(`${assignmentPath} = ${typeof property.defaultValue === \"string\" ? `\"${property.defaultValue}\"` : property.defaultValue}`);\n\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\nexport class MergeFunctionHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.functionBody != null && property.type === SchemaTypes.Function) {\n\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder, SlotBlock } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { isArrayValued, PropertyInfo } from \"../../../schema\";\n\n/**\n * Merges an array by copying elements INTO the destination's existing array instead of\n * replacing the reference.\n *\n * The reference matters: a change-tracked entity holds its array wrapped in a tracking\n * proxy, and merge runs paused — a plain `destination.values = source.values` discards\n * that proxy silently, so every in-place mutation made after the entity's first save\n * (afterPersist merges the plugin's echo into the canonical) was no longer tracked and\n * vanished on the next save (defect #12). Copying in place keeps the caller's array\n * reference stable and the proxy installed, and shares no reference with the source.\n *\n * When the destination has no array yet there is nothing to preserve, so the source\n * reference is adopted as-is — same as the primitive copy this replaces.\n */\nexport class MergeArrayHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (isArrayValued(property.type)) {\n const selectorPath = property.getSelectrorPath({ parent: \"source\", assignmentType: \"FORCE_NULLABLE_OR_OPTIONAL\" });\n const slot = builder.get<SlotBlock>(\"factory.function.assignments\");\n const sourcePath = property.getAssignmentPath({ parent: \"source\" });\n const destinationPath = property.getAssignmentPath({ parent: \"destination\" });\n\n const ifBlock = slot.if(`${selectorPath} != null`);\n this.emitDestinationAncestorGuards(property, ifBlock);\n\n ifBlock.appendBody(`if (${destinationPath} == null) { ${destinationPath} = ${sourcePath} } else if (${destinationPath} !== ${sourcePath}) { ${destinationPath}.length = 0; for (let i = 0; i < ${sourcePath}.length; i++) { ${destinationPath}[i] = ${sourcePath}[i]; } }`);\n\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}\n","import { MergeDefaultFunctionHandler } from \"./merge/MergeDefaultFunctionHandler\";\nimport { MergeObjectHandler } from \"./merge/MergeObjectHandler\";\nimport { MergePrimitiveHandler } from \"./merge/MergePrimitiveHandler\";\nimport { MergeComputedValueHandler } from \"./merge/MergeComputedValueHandler\";\nimport { MergeDefaultValueHandler } from \"./merge/MergeDefaultValueHandler\";\nimport { MergeFunctionHandler } from \"./merge/MergeFunctionHandler\";\nimport { MergeArrayHandler } from \"./merge/MergeArrayHandler\";\n\n/// Purpose: Should recompute computed properties\nexport class MergeHandlerBuilder {\n\n build() {\n const handler = new MergeDefaultFunctionHandler();\n handler.setNext(new MergeDefaultValueHandler())\n .setNext(new MergeFunctionHandler())\n .setNext(new MergeComputedValueHandler())\n // Before the primitive handler: arrays would otherwise fall through to its\n // reference copy, which discards the destination array's tracking proxy\n .setNext(new MergeArrayHandler())\n .setNext(new MergePrimitiveHandler())\n .setNext(new MergeObjectHandler());\n\n return handler;\n }\n}","import { CodeBuilder, SlotBlock } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo } from \"../../../schema\";\n\nexport class PrepareIdentityHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.isIdentity === true) {\n const selectorPath = property.getSelectrorPath({ parent: \"entity\", assignmentType: \"FORCE_NULLABLE_OR_OPTIONAL\" });\n const slot = builder.get<SlotBlock>(\"assignments\");\n const entitySelectorPath = property.getAssignmentPath({ parent: \"entity\" });\n const enrichedAssignmentPath = property.getAssignmentPath({ parent: \"result\" });\n\n slot.if(`${selectorPath} != null`).appendBody(`${enrichedAssignmentPath} = ${entitySelectorPath}`);\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder, SlotBlock } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo } from \"../../../schema\";\n\nexport class PrepareKeyHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.isKey === true) {\n const selectorPath = property.getSelectrorPath({ parent: \"entity\", assignmentType: \"FORCE_NULLABLE_OR_OPTIONAL\" });\n const slot = builder.get<SlotBlock>(\"assignments\");\n const entitySelectorPath = property.getAssignmentPath({ parent: \"entity\" });\n const enrichedAssignmentPath = property.getAssignmentPath({ parent: \"result\" });\n\n slot.if(`${selectorPath} != null`).appendBody(`${enrichedAssignmentPath} = ${entitySelectorPath}`);\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder, ObjectBuilder, SlotBlock } from '../../blocks';\nimport { SlotPath } from '../../SlotPath';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\nexport class PrepareValueHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.type != SchemaTypes.Object) {\n let objectBuilder = builder.getOrDefault<ObjectBuilder>(\"result.variable.object\");\n const entitySelectorPath = property.getAssignmentPath({ parent: \"entity\" });\n\n if (objectBuilder == null) {\n objectBuilder = builder.get<SlotBlock>(\"result\")\n .assign(\"const result\", { name: \"variable\" })\n .object({ name: \"object\" });\n }\n\n // Remap the property to the name in the database if from is set\n const name = property.from != null ? property.from : property.name;\n\n if (property.parent == null) {\n objectBuilder.property(`${name}: ${entitySelectorPath}`);\n return builder;\n }\n\n const slotPath = new SlotPath(...property.getParentPathArray());\n objectBuilder = objectBuilder.get<ObjectBuilder>(slotPath.get());\n objectBuilder.property(`${name}: ${entitySelectorPath}`);\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder, ObjectBuilder, SlotBlock } from '../../blocks';\nimport { SlotPath } from '../../SlotPath';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\nexport class PrepareObjectHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.type === SchemaTypes.Object) {\n const slotPath = new SlotPath(\"result\", \"variable\", \"object\");\n let objectBuilder = builder.getOrDefault<ObjectBuilder>(slotPath.get());\n\n // There is a chance this is the first property we handle,\n // if that is the case, the main result variable will not be\n // constructed yet\n if (objectBuilder == null) {\n objectBuilder = builder.get<SlotBlock>(\"result\")\n .assign(\"const result\", { name: \"variable\" })\n .object({ name: \"object\" });\n }\n\n // Prepare emits the storage shape — renamed object containers keep\n // their `from` (storage) key; the block name stays the property name\n // so child lookups by name still resolve\n if (property.parent == null) {\n objectBuilder.nested(property.getResolvedName(), property.name)\n\n return builder;\n }\n\n slotPath.push(...property.getParentPathArray());\n const nestedObjectBuilder = builder.get<ObjectBuilder>(slotPath.get());\n nestedObjectBuilder.nested(property.getResolvedName(), property.name)\n\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\n// Do nothing with the value\nexport class PrepareComputedValueHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.functionBody != null && property.type === SchemaTypes.Computed && property.isUnmapped === true) {\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\nexport class PrepareFunctionHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.functionBody != null && property.type === SchemaTypes.Function) {\n // Functions are always unmapped\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { PrepareIdentityHandler } from \"./prepare/PrepareIdentityHandler\";\nimport { PrepareKeyHandler } from \"./prepare/PrepareKeyHandler\";\nimport { PrepareValueHandler } from \"./prepare/PrepareValueHandler\";\nimport { PrepareObjectHandler } from \"./prepare/PrepareObjectHandler\";\nimport { PrepareComputedValueHandler } from \"./prepare/PrepareComputedValueHandler\";\nimport { PrepareFunctionHandler } from \"./prepare/PrepareFunctionHandler\";\n\n/// Purpose: Called before we save entities to the database. Responsible for cleaning up\n/// an entity before it is sent to the plugin\nexport class PrepareHandlerBuilder {\n\n build() {\n const handler = new PrepareIdentityHandler();\n handler\n .setNext(new PrepareFunctionHandler())\n .setNext(new PrepareComputedValueHandler())\n .setNext(new PrepareKeyHandler())\n .setNext(new PrepareObjectHandler())\n .setNext(new PrepareValueHandler());\n\n return handler;\n }\n}","import { CodeBuilder, ObjectBuilder, SlotBlock } from '../../blocks';\nimport { SlotPath } from '../../SlotPath';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\nexport class StripObjectHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.type === SchemaTypes.Object) {\n const slotPath = new SlotPath(\"result.variable.object\");\n let objectBuilder = builder.getOrDefault<ObjectBuilder>(slotPath.get());\n\n if (objectBuilder == null) {\n objectBuilder = builder.get<SlotBlock>(\"result\")\n .assign(\"const result\", { name: \"variable\" })\n .object({ name: \"object\" });\n }\n\n if (property.parent == null) {\n objectBuilder.nested(property.name, property.name)\n\n return builder;\n }\n\n slotPath.push(...property.getParentPathArray());\n const nestedObjectBuilder = builder.get<ObjectBuilder>(slotPath.get());\n nestedObjectBuilder.nested(property.name, property.name)\n\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { PropertyInfo, SchemaTypes } from \"../../../schema\";\nimport { PropertyInfoHandler } from \"../types\";\nimport { CodeBuilder, ObjectBuilder, SlotBlock } from '../../blocks';\nimport { SlotPath } from '../../SlotPath';\n\nexport class StripValueHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.type != SchemaTypes.Object) {\n let objectBuilder = builder.getOrDefault<ObjectBuilder>(\"result.variable.object\");\n const entitySelectorPath = property.getAssignmentPath({ parent: \"entity\" });\n\n // There is a chance this is the first property we handle,\n // if that is the case, the main result variable will not be\n // constructed yet\n if (objectBuilder == null) {\n objectBuilder = builder.get<SlotBlock>(\"result\")\n .assign(\"const result\", { name: \"variable\" })\n .object({ name: \"object\" });\n }\n\n if (property.parent == null) {\n objectBuilder.property(`${property.name}: ${entitySelectorPath}`);\n return builder;\n }\n\n const slotPath = new SlotPath(...property.getParentPathArray());\n objectBuilder = objectBuilder.get<ObjectBuilder>(slotPath.get());\n objectBuilder.property(`${property.name}: ${entitySelectorPath}`);\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo } from \"../../../schema\";\n\nexport class StripKeyHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.isKey === true) {\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo } from \"../../../schema\";\n\nexport class StripIdentityHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.isIdentity === true) {\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\n/**\n * Functions never persist — strip removes them along with keys and identities.\n */\nexport class StripFunctionHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.type === SchemaTypes.Function) {\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}\n","import { CodeBuilder } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\n/**\n * Unmapped computed properties never persist — strip removes them along with\n * keys and identities.\n */\nexport class StripComputedHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.type === SchemaTypes.Computed && property.isUnmapped === true) {\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}\n","import { StripObjectHandler } from \"./strip/StripObjectHandler\";\nimport { StripValueHandler } from \"./strip/StripValueHandler\";\nimport { StripKeyHandler } from \"./strip/StripKeyHandler\";\nimport { StripIdentityHandler } from \"./strip/StripIdentityHandler\";\nimport { StripFunctionHandler } from \"./strip/StripFunctionHandler\";\nimport { StripComputedHandler } from \"./strip/StripComputedHandler\";\n\n/// Purpose: builds the strip function, which returns an entity without its\n/// keys, identities, and unmapped properties\nexport class StripHandlerBuilder {\n\n build() {\n const handler = new StripIdentityHandler();\n\n handler.setNext(new StripKeyHandler())\n .setNext(new StripFunctionHandler())\n .setNext(new StripComputedHandler())\n .setNext(new StripObjectHandler())\n .setNext(new StripValueHandler());\n\n return handler;\n }\n}","import { CodeBuilder, SlotBlock } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { hasPrimitiveElements, isArrayValued, PropertyInfo, SchemaTypes } from \"../../../schema\";\n\nexport class CloneArrayHandler extends PropertyInfoHandler {\n\n /** See `CloneValueHandler`. */\n constructor(private readonly useFromPropertyName: boolean = false) {\n super();\n }\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (isArrayValued(property.type)) {\n\n // Arrays are leaf properties — they have no child PropertyInfos, so the\n // copy must happen here for every array, including nullable/optional ones.\n // The `!== undefined` guard below covers absent values; an explicit null is copied as\n // null (see CloneValueHandler and known-defects #66), which is why every copy\n // expression is wrapped rather than applied directly — `[...null]` throws.\n const useFromPropertyName = this.useFromPropertyName;\n const entitySelectorPath = property.getSelectrorPath({ parent: \"entity\", useFromPropertyName });\n\n const slot = builder.get<SlotBlock>(\"if\");\n const resultAssignmentPath = property.getAssignmentPath({ parent: \"result\", useFromPropertyName });\n\n // Primitive elements copy with a spread; anything that can hold nested\n // references (objects, dates, nested arrays) needs a deep copy or the\n // clone shares element references with the source. Dates get an explicit\n // per-element copy rather than structuredClone: structuredClone can return\n // Dates from a foreign realm (e.g. under jest), which fail `instanceof Date`.\n // Deep copies go per ELEMENT, never structuredClone on the array itself: a\n // change-tracked entity's array is wrapped in a Proxy (and stays wrapped\n // across merges), and a Proxy cannot pass a structured-clone boundary.\n const elementType = property.innerSchema?.type;\n let copyExpression: string;\n if (hasPrimitiveElements(property.type, elementType)) {\n copyExpression = `[...${entitySelectorPath}]`;\n } else if (elementType === SchemaTypes.Date) {\n copyExpression = `${entitySelectorPath}.map(function (v) { return v == null ? v : new Date(v); })`;\n } else {\n copyExpression = `${entitySelectorPath}.map(function (v) { return v == null ? v : structuredClone(v); })`;\n }\n\n // A null array is still a null, not an empty one, and neither spread nor map survives it\n const nullSafeCopy = `${entitySelectorPath} === null ? null : ${copyExpression}`;\n\n if (property.parent == null) {\n slot.if(`${entitySelectorPath} !== undefined`).appendBody(`${resultAssignmentPath} = ${nullSafeCopy}`);\n return builder;\n }\n\n // Nested array: ensure parent exists, then assign the copy (same pattern as CloneValueHandler)\n const parentPathArray = property.getParentPathArray({ useFromPropertyName });\n const ifSlot = slot.if(`${entitySelectorPath} !== undefined`);\n\n for (let i = 0; i < parentPathArray.length; i++) {\n const pathSoFar = [\"result\", ...parentPathArray.slice(0, i + 1)].join(\".\");\n ifSlot.appendBody(`if (${pathSoFar} == null) ${pathSoFar} = {};`);\n }\n ifSlot.appendBody(`${resultAssignmentPath} = ${nullSafeCopy};`);\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder, SlotBlock } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\n/**\n * Copies Date properties by value. A reference copy would let a mutation of the\n * clone's Date (e.g. setHours) silently change the source entity.\n */\n// See CloneValueHandler for why the guard is `!== undefined` (known-defects #66).\nexport class CloneDateHandler extends PropertyInfoHandler {\n\n /** See `CloneValueHandler`. */\n constructor(private readonly useFromPropertyName: boolean = false) {\n super();\n }\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.type === SchemaTypes.Date) {\n const slot = builder.get<SlotBlock>(\"if\");\n const useFromPropertyName = this.useFromPropertyName;\n const entitySelectorPath = property.getSelectrorPath({ parent: \"entity\", useFromPropertyName });\n const resultAssignmentPath = property.getAssignmentPath({ parent: \"result\", useFromPropertyName });\n\n // Stored values can still be serialized strings; only wrap real Dates. A null falls\n // through this expression unchanged, which is what the `!== undefined` guard wants.\n const copyExpression = `${entitySelectorPath} instanceof Date ? new Date(${entitySelectorPath}.getTime()) : ${entitySelectorPath}`;\n\n if (property.parent == null) {\n slot.if(`${entitySelectorPath} !== undefined`).appendBody(`${resultAssignmentPath} = ${copyExpression}`);\n return builder;\n }\n\n // Nested property: ensure every ancestor object exists, then assign (same pattern as CloneValueHandler)\n const parentPathArray = property.getParentPathArray({ useFromPropertyName });\n const ifSlot = slot.if(`${entitySelectorPath} !== undefined`);\n\n for (let i = 0; i < parentPathArray.length; i++) {\n const pathSoFar = [\"result\", ...parentPathArray.slice(0, i + 1)].join(\".\");\n ifSlot.appendBody(`if (${pathSoFar} == null) ${pathSoFar} = {};`);\n }\n ifSlot.appendBody(`${resultAssignmentPath} = ${copyExpression};`);\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}\n","import { CodeBuilder } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\nexport class CloneObjectHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.type === SchemaTypes.Object) {\n\n // Child properties will take care of this\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder, SlotBlock } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { isArrayValued, PropertyInfo, SchemaTypes } from \"../../../schema\";\n\n/**\n * `!== undefined`, not `!= null`.\n *\n * An explicit `null` is a VALUE and has to survive the copy; an absent or `undefined` property is\n * not there and must not be invented. The loose guard conflated the two and dropped every null,\n * which is how a `s.string().nullable()` written as `null` came back as `undefined` from the\n * memory family — see known-defects #66. It was invisible for a long time because the change\n * tracker merges a read into the canonical entity the caller still holds, so the null appeared to\n * survive right up until something read storage without one (a join).\n */\nexport class CloneValueHandler extends PropertyInfoHandler {\n\n /**\n * When true, emit reads and writes under the STORAGE name (`from`) instead of the\n * in-memory name. See `CloneHandlerBuilder.build`.\n */\n constructor(private readonly useFromPropertyName: boolean = false) {\n super();\n }\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n // Anything that copies by assignment. An array-valued property must not land here:\n // assigning the reference shares it with the source, which is the whole point of\n // CloneArrayHandler.\n if (property.type != SchemaTypes.Object && isArrayValued(property.type) === false) {\n const slot = builder.get<SlotBlock>(\"if\");\n const useFromPropertyName = this.useFromPropertyName;\n const entitySelectorPath = property.getSelectrorPath({ parent: \"entity\", useFromPropertyName });\n const resultAssignmentPath = property.getAssignmentPath({ parent: \"result\", useFromPropertyName });\n\n if (property.parent == null) {\n // we are a first level property\n slot.if(`${entitySelectorPath} !== undefined`).appendBody(`${resultAssignmentPath} = ${entitySelectorPath}`);\n return builder;\n }\n\n // Nested property: ensure every ancestor object exists, then assign (handles depth > 2)\n const parentPathArray = property.getParentPathArray({ useFromPropertyName });\n const ifSlot = slot.if(`${entitySelectorPath} !== undefined`);\n\n for (let i = 0; i < parentPathArray.length; i++) {\n const pathSoFar = [\"result\", ...parentPathArray.slice(0, i + 1)].join(\".\");\n ifSlot.appendBody(`if (${pathSoFar} == null) ${pathSoFar} = {};`);\n }\n ifSlot.appendBody(`${resultAssignmentPath} = ${entitySelectorPath}`);\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CloneArrayHandler } from \"./clone/CloneArrayHandler\";\nimport { CloneDateHandler } from \"./clone/CloneDateHandler\";\nimport { CloneObjectHandler } from \"./clone/CloneObjectHandler\";\nimport { CloneValueHandler } from \"./clone/CloneValueHandler\";\n\n/// Purpose: builds the handler chain for the generated clone function, which\n/// deep-copies an entity so callers can never mutate stored data by reference\nexport class CloneHandlerBuilder {\n\n /**\n * @param useFromPropertyName Emit the STORAGE shape rather than the in-memory shape.\n *\n * A record that has not been read back into memory yet still carries its `from` names, so a\n * cloner generated from in-memory names would read `undefined` for every renamed property and\n * silently drop it. Passing true swaps both the reads and the writes to the storage name, which\n * gives a copier for records in that shape. Everything else about the chain is identical —\n * the same handlers, in the same order, with the same null and Date semantics.\n */\n build(useFromPropertyName: boolean = false) {\n const handler = new CloneObjectHandler();\n handler\n .setNext(new CloneDateHandler(useFromPropertyName))\n .setNext(new CloneValueHandler(useFromPropertyName))\n .setNext(new CloneArrayHandler(useFromPropertyName));\n\n return handler;\n }\n}\n","import { AndBuilder, CodeBuilder, SlotBlock } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { isArrayValued, PropertyInfo } from \"../../../schema\";\n\nexport class CompareArrayHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (isArrayValued(property.type)) {\n let compare = builder.getOrDefault<AndBuilder>(\"result.variable.compare\");\n const leftCompare = property.getSelectrorPath({ parent: \"a\" });\n const rightCompare = property.getSelectrorPath({ parent: \"b\" });\n\n if (compare == null) {\n compare = builder.get<SlotBlock>(\"result\")\n .assign(\"const result\", { name: \"variable\" })\n // Named \"compare\" so every compare handler finds the same block\n // regardless of which property type is iterated first\n .and(`JSON.stringify(${leftCompare}) === JSON.stringify(${rightCompare})`, { name: \"compare\" });\n return builder;\n }\n\n compare.and(`JSON.stringify(${leftCompare}) === JSON.stringify(${rightCompare})`);\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\n/**\n * Unmapped computed properties are excluded from comparison — they derive from\n * other properties, which are compared directly.\n */\nexport class CompareComputedHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.type === SchemaTypes.Computed && property.isUnmapped === true) {\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}\n","import { AndBuilder, CodeBuilder, SlotBlock } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\nexport class CompareDateHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.type === SchemaTypes.Date) {\n let compare = builder.getOrDefault<AndBuilder>(\"result.variable.compare\");\n const leftCompare = property.getSelectrorPath({ parent: \"a\" });\n const rightCompare = property.getSelectrorPath({ parent: \"b\" });\n\n if (compare == null) {\n compare = builder.get<SlotBlock>(\"result\")\n .assign(\"const result\", { name: \"variable\" })\n // Named \"compare\" so every compare handler finds the same block\n // regardless of which property type is iterated first\n .and(`${leftCompare}?.toISOString() === ${rightCompare}?.toISOString()`, { name: \"compare\" });\n return builder;\n }\n\n compare.and(`${leftCompare}?.toISOString() === ${rightCompare}?.toISOString()`);\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\n/**\n * Functions are excluded from comparison — enrichment assigns a fresh closure\n * per entity, so a reference comparison would report every pair as different.\n */\nexport class CompareFunctionHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.type === SchemaTypes.Function) {\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}\n","import { CodeBuilder } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\nexport class CompareObjectHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.type === SchemaTypes.Object) {\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { AndBuilder, CodeBuilder, SlotBlock } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\nexport class CompareValueHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.type != SchemaTypes.Object) {\n let compare = builder.getOrDefault<AndBuilder>(\"result.variable.compare\");\n const leftCompare = property.getSelectrorPath({ parent: \"a\" });\n const rightCompare = property.getSelectrorPath({ parent: \"b\" });\n\n if (compare == null) {\n compare = builder.get<SlotBlock>(\"result\")\n .assign(\"const result\", { name: \"variable\" })\n .and(`${leftCompare} === ${rightCompare}`, { name: \"compare\" });\n return builder;\n }\n\n compare.and(`${leftCompare} === ${rightCompare}`);\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CompareArrayHandler } from \"./compare/CompareArrayHandler\";\nimport { CompareComputedHandler } from \"./compare/CompareComputedHandler\";\nimport { CompareDateHandler } from \"./compare/CompareDateHandler\";\nimport { CompareFunctionHandler } from \"./compare/CompareFunctionHandler\";\nimport { CompareObjectHandler } from \"./compare/CompareObjectHandler\";\nimport { CompareValueHandler } from \"./compare/CompareValueHandler\";\n\nexport class CompareHandlerBuilder {\n\n build() {\n const handler = new CompareObjectHandler();\n handler.setNext(new CompareFunctionHandler())\n .setNext(new CompareComputedHandler())\n .setNext(new CompareArrayHandler())\n .setNext(new CompareDateHandler())\n .setNext(new CompareValueHandler());\n\n return handler;\n }\n}","import { CodeBuilder, ObjectBuilder, SlotBlock } from '../../blocks';\nimport { SlotPath } from '../../SlotPath';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\nexport class DeserializeObjectHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.type === SchemaTypes.Object) {\n const slotPath = new SlotPath(\"result.variable.object\");\n\n // Create the result object when this is the first property iterated —\n // handler output cannot depend on schema property order\n let objectBuilder = builder.getOrDefault<ObjectBuilder>(slotPath.get());\n\n if (objectBuilder == null) {\n objectBuilder = builder.get<SlotBlock>(\"result\")\n .assign(\"const entity\", { name: \"variable\" })\n .object({ name: \"object\" });\n }\n\n // The output entity is the in-memory shape — its keys are property\n // names; `from` names only appear on the unserialized (read) side\n if (property.parent == null) {\n objectBuilder.nested(property.name, property.name)\n\n return builder;\n }\n\n slotPath.push(...property.getParentPathArray());\n const nestedObjectBuilder = builder.get<ObjectBuilder>(slotPath.get());\n nestedObjectBuilder.nested(property.name, property.name)\n\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder, ObjectBuilder, SlotBlock } from '../../blocks';\nimport { SlotPath } from '../../SlotPath';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\nexport class DeserializeValueHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.type != SchemaTypes.Object && property.type != SchemaTypes.Date) {\n let objectBuilder = builder.getOrDefault<ObjectBuilder>(\"result.variable.object\");\n // Deserialize maps storage shape -> in-memory shape: read the incoming\n // record by `from` (storage) name; the selector path adds `?.` so\n // absent nullable parents read as undefined instead of throwing\n const entitySelectorPath = property.getSelectrorPath({ parent: \"unserialized\", useFromPropertyName: true });\n\n if (objectBuilder == null) {\n objectBuilder = builder.get<SlotBlock>(\"result\")\n .assign(\"const entity\", { name: \"variable\" })\n .object({ name: \"object\" });\n }\n\n if (property.parent == null) {\n objectBuilder.property(`${property.name}: ${entitySelectorPath}`);\n return builder;\n }\n\n const slotPath = new SlotPath(...property.getParentPathArray());\n objectBuilder = objectBuilder.get<ObjectBuilder>(slotPath.get());\n objectBuilder.property(`${property.name}: ${entitySelectorPath}`);\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder, ContainerBlock, ObjectBuilder, SlotBlock } from '../../blocks';\nimport { SlotPath } from '../../SlotPath';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\n/**\n * Handles converting a string value from a database to a Date value\n */\nexport class DeserializeDateHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.type === SchemaTypes.Date) {\n const slotPath = new SlotPath(\"result.variable.object\");\n\n // Create the result object when this is the first property iterated —\n // handler output cannot depend on schema property order\n let objectBuilder = builder.getOrDefault<ObjectBuilder>(slotPath.get());\n\n if (objectBuilder == null) {\n objectBuilder = builder.get<SlotBlock>(\"result\")\n .assign(\"const entity\", { name: \"variable\" })\n .object({ name: \"object\" });\n }\n // Deserialize maps storage shape -> in-memory shape: read the incoming\n // record by `from` (storage) name, write the entity by property name\n const entitySelectorPath = property.getSelectrorPath({ parent: \"unserialized\", useFromPropertyName: true });\n const entityAssignmentPath = property.getAssignmentPath({ parent: \"entity\" });\n const assignment = `${property.name}: typeof ${entitySelectorPath} === \"string\" ? new Date(${entitySelectorPath}) : ${entitySelectorPath}`;\n\n // if it is nullable or optional, assign in an if block, otherwise we\n // could unintentionally assign a property that does not exist. An explicit null IS\n // assigned — a stored null is a value, and dropping it is known-defects #66. The\n // expression passes null through, since null is not a string.\n if (property.isOptional || property.isNullable) {\n const ifAssignment = `${entityAssignmentPath} = typeof ${entitySelectorPath} === \"string\" ? new Date(${entitySelectorPath}) : ${entitySelectorPath}`;\n const rootPath = new SlotPath(\"if\");\n builder.get<ContainerBlock>(rootPath.get()).if(`${entitySelectorPath} !== undefined`).appendBody(ifAssignment);\n return builder;\n }\n\n // A date cannot be a nested object, just do the assignment\n if (property.parent == null) {\n objectBuilder.property(assignment);\n\n return builder;\n }\n\n slotPath.push(...property.getParentPathArray());\n const nestedObjectBuilder = builder.get<ObjectBuilder>(slotPath.get());\n nestedObjectBuilder.property(assignment)\n\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\nexport class DeserializeComputedValueHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n // Do nothing with the value\n if (property.functionBody != null && property.type === SchemaTypes.Computed && property.isUnmapped === true) {\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\nexport class DeserializeFunctionHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.functionBody != null && property.type === SchemaTypes.Function) {\n // Functions are always unmapped\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder, ObjectBuilder, SlotBlock } from '../../blocks';\nimport { SlotPath } from '../../SlotPath';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo } from \"../../../schema\";\n\nexport class DeserializeDeserializerHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.valueDeserializer != null) {\n let objectBuilder = builder.getOrDefault<ObjectBuilder>(\"result.variable.object\");\n const assignmentBuilder = builder.getOrDefault<SlotBlock>(\"functions\");\n // Read the incoming record by `from` (storage) name\n const entitySelectorPath = property.getSelectrorPath({ parent: \"unserialized\", useFromPropertyName: true });\n\n if (objectBuilder == null) {\n objectBuilder = builder.get<SlotBlock>(\"result\")\n .assign(\"const entity\", { name: \"variable\" })\n .object({ name: \"object\" });\n }\n\n const defaultFunctionWithParameters = this.toNamedFunction(property.valueDeserializer.toString(), assignmentBuilder);\n defaultFunctionWithParameters.builder.parameters(...defaultFunctionWithParameters.parameters.map((_, i) => ({ name: defaultFunctionWithParameters.parameters[i], callName: entitySelectorPath })));\n\n if (property.parent == null) {\n objectBuilder.property(`${property.name}: ${defaultFunctionWithParameters.builder.toCallable()}`);\n return builder;\n }\n\n const slotPath = new SlotPath(...property.getParentPathArray());\n objectBuilder = objectBuilder.get<ObjectBuilder>(slotPath.get());\n objectBuilder.property(`${property.name}: ${defaultFunctionWithParameters.builder.toCallable()}`);\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder, ContainerBlock, ObjectBuilder, SlotBlock } from '../../blocks';\nimport { SlotPath } from '../../SlotPath';\nimport { PropertyInfoHandler } from \"../types\";\nimport { isArrayValued, PropertyInfo, SchemaTypes } from \"../../../schema\";\n\n/**\n * Deserializes arrays per element instead of copying the reference:\n *\n * - Date elements are revived from strings (same convention as DeserializeDateHandler).\n * - Everything else is copied with a spread, so the entity shares no references with\n * the storage record.\n */\nexport class DeserializeArrayHandler extends PropertyInfoHandler {\n\n private copyExpression(property: PropertyInfo<any>, selector: string): string {\n const elementType = property.innerSchema?.type;\n\n if (elementType === SchemaTypes.Date) {\n return `${selector}.map(function (v) { return typeof v === \"string\" ? new Date(v) : v; })`;\n }\n\n return `[...${selector}]`;\n }\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (isArrayValued(property.type)) {\n const slotPath = new SlotPath(\"result.variable.object\");\n\n // Create the result object when this is the first property iterated —\n // handler output cannot depend on schema property order\n let objectBuilder = builder.getOrDefault<ObjectBuilder>(slotPath.get());\n\n if (objectBuilder == null) {\n objectBuilder = builder.get<SlotBlock>(\"result\")\n .assign(\"const entity\", { name: \"variable\" })\n .object({ name: \"object\" });\n }\n\n // Deserialize maps storage shape -> in-memory shape: read the incoming\n // record by `from` (storage) name, write the entity by property name\n const entitySelectorPath = property.getSelectrorPath({ parent: \"unserialized\", useFromPropertyName: true });\n const entityAssignmentPath = property.getAssignmentPath({ parent: \"entity\" });\n const valueExpression = `${entitySelectorPath} == null ? ${entitySelectorPath} : ${this.copyExpression(property, entitySelectorPath)}`;\n\n // if it is nullable or optional, assign in an if block, otherwise we\n // could unintentionally assign a property that does not exist. An explicit null IS\n // assigned — a stored null is a value, and dropping it is known-defects #66.\n // `valueExpression` rather than the bare copy: neither a spread nor a map survives a\n // null, so the copy has to stay behind its own null check.\n if (property.isOptional || property.isNullable) {\n const rootPath = new SlotPath(\"if\");\n builder.get<ContainerBlock>(rootPath.get()).if(`${entitySelectorPath} !== undefined`).appendBody(`${entityAssignmentPath} = ${valueExpression}`);\n return builder;\n }\n\n if (property.parent == null) {\n objectBuilder.property(`${property.name}: ${valueExpression}`);\n return builder;\n }\n\n const nestedSlotPath = new SlotPath(...property.getParentPathArray());\n const nestedObjectBuilder = objectBuilder.get<ObjectBuilder>(nestedSlotPath.get());\n nestedObjectBuilder.property(`${property.name}: ${valueExpression}`);\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}\n","import { DeserializeObjectHandler } from \"./deserialize/DeserializeObjectHandler\";\nimport { DeserializeValueHandler } from \"./deserialize/DeserializeValueHandler\";\nimport { DeserializeDateHandler } from \"./deserialize/DeserializeDateHandler\";\nimport { DeserializeComputedValueHandler } from \"./deserialize/DeserializeComputedValueHandler\";\nimport { DeserializeFunctionHandler } from \"./deserialize/DeserializeFunctionHandler\";\nimport { DeserializeDeserializerHandler } from \"./deserialize/DeserializeDeserializerHandler\";\nimport { DeserializeArrayHandler } from \"./deserialize/DeserializeArrayHandler\";\n\n/// Purpose:\nexport class DeserializeHandlerBuilder {\n\n build() {\n const handler = new DeserializeObjectHandler();\n handler\n .setNext(new DeserializeDeserializerHandler())\n .setNext(new DeserializeComputedValueHandler())\n .setNext(new DeserializeFunctionHandler())\n .setNext(new DeserializeArrayHandler())\n .setNext(new DeserializeValueHandler())\n .setNext(new DeserializeDateHandler());\n\n return handler;\n }\n}","import { CodeBuilder, SlotBlock } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo } from \"../../../schema\";\n\nexport class HashTypeValueHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.isKey && property.isIdentity) {\n const slot = builder.get<SlotBlock>(\"ifs\");\n const entitySelectorPath = property.getSelectrorPath({ parent: \"entity\" });\n\n slot.if(`${entitySelectorPath} == null`).appendBody(`return \"Object\"`);\n\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { NotApplicableHandler } from \"./types\";\nimport { HashTypeValueHandler } from \"./hashType/HashTypeValueHandler\";\n\n/// Purpose: \nexport class HashTypeHandlerBuilder {\n\n build() {\n const handler = new HashTypeValueHandler();\n\n handler.setNext(new NotApplicableHandler());\n\n return handler;\n }\n}","import { ArrayBuilder, CodeBuilder, SlotBlock } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo } from \"../../../schema\";\n\nexport class IdSelectorValueHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.isKey) {\n let arrayBuilder = builder.getOrDefault<ArrayBuilder>(\"result.variable.array\");\n const entitySelectorPath = property.getAssignmentPath({ parent: \"entity\" });\n\n if (arrayBuilder == null) {\n arrayBuilder = builder.get<SlotBlock>(\"result\")\n .variable(\"result\", { name: \"variable\" })\n .array(`${entitySelectorPath}`, { name: \"array\" });\n\n return builder;\n }\n\n\n arrayBuilder.append(`${entitySelectorPath}`);\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { NotApplicableHandler } from \"./types\";\nimport { IdSelectorValueHandler } from \"./idSelector/IdSelectorValueHandler\";\n/// Purpose: \nexport class IdSelectorHandlerBuilder {\n\n build() {\n const handler = new IdSelectorValueHandler();\n\n handler.setNext(new NotApplicableHandler());\n\n return handler;\n }\n}","import { CodeBuilder, SlotBlock, StringBuilder } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo } from \"../../../schema\";\n\nexport class HashKeyHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.isKey === true) {\n let stringBuilder = builder.getOrDefault<StringBuilder>(\"hash-id-if.if-body.variable.string\");\n const entitySelectorPath = property.getSelectrorPath({ parent: \"entity\" });\n\n if (stringBuilder == null) {\n stringBuilder = builder.get<SlotBlock>(\"hash-id-if.if-body\")\n .assign(\"const result\", { name: \"variable\" })\n .string(\"template\", { name: \"string\" });\n }\n\n stringBuilder.append(\"${\" + entitySelectorPath + \"}\")\n\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder, SlotBlock, StringBuilder } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\nexport class HashValueHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.type !== SchemaTypes.Object) {\n let stringBuilder = builder.getOrDefault<StringBuilder>(\"hash-object-return.variable.string\");\n const entitySelectorPath = property.getSelectrorPath({ parent: \"entity\" });\n\n if (stringBuilder == null) {\n stringBuilder = builder.get<SlotBlock>(\"hash-object-return\")\n .assign(\"const result\", { name: \"variable\" })\n .string(\"template\", { name: \"string\" });\n }\n\n stringBuilder.append(\"${\" + entitySelectorPath + \"}\")\n\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder, SlotBlock, StringBuilder } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\nexport class HashDateHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.type === SchemaTypes.Date) {\n let stringBuilder = builder.getOrDefault<StringBuilder>(\"hash-object-return.variable.string\");\n const entitySelectorPath = property.getSelectrorPath({ parent: \"entity\" });\n\n if (stringBuilder == null) {\n stringBuilder = builder.get<SlotBlock>(\"hash-object-return\")\n .assign(\"const result\", { name: \"variable\" })\n .string(\"template\", { name: \"string\" });\n }\n\n stringBuilder.append(\"${stringifyDate(\" + entitySelectorPath + \")}\")\n\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo } from \"../../../schema\";\n\nexport class HashIdentityHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.isIdentity === true) {\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\nexport class HashFunctionHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.functionBody != null && property.type === SchemaTypes.Function) {\n // Functions are always unmapped\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\nexport class HashComputedValueHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.functionBody != null && property.type === SchemaTypes.Computed && property.isUnmapped === true) {\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder, SlotBlock, StringBuilder } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { isArrayValued, PropertyInfo } from \"../../../schema\";\n\n/**\n * Hashes array contents via JSON — template interpolation of an array of\n * objects would collapse every value to \"[object Object]\" and collide.\n */\nexport class HashArrayHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (isArrayValued(property.type)) {\n let stringBuilder = builder.getOrDefault<StringBuilder>(\"hash-object-return.variable.string\");\n const entitySelectorPath = property.getSelectrorPath({ parent: \"entity\" });\n\n if (stringBuilder == null) {\n stringBuilder = builder.get<SlotBlock>(\"hash-object-return\")\n .assign(\"const result\", { name: \"variable\" })\n .string(\"template\", { name: \"string\" });\n }\n\n stringBuilder.append(\"${JSON.stringify(\" + entitySelectorPath + \")}\")\n\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}\n","import { CodeBuilder } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\n/**\n * Object containers are not hashed directly — their child properties hash\n * individually, which keeps the hash stable across key insertion order.\n */\nexport class HashObjectHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.type === SchemaTypes.Object) {\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}\n","import { CodeBuilder, SlotBlock, StringBuilder } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\n/**\n * A file takes no part in the hash that correlates an addition with what came back.\n *\n * The hash exists to match a submitted entity against the row the database echoed, which is\n * why identity values are already excluded: the database assigns them, so they differ on the\n * two sides by design.\n *\n * A file is the same situation one step out. What is submitted is content; what is stored, and\n * echoed, is a reference. Hashing the VALUE produced two different hashes for the same\n * addition and the change tracker reported \"Cannot find internal addition\" on every save with\n * a file.\n *\n * It contributes a constant rather than nothing at all. The `result` string is created by\n * whichever handler runs first, so a schema whose only non-identity properties are files —\n * an assets row holding an original and a thumbnail, say — would emit no declaration and then\n * return it: `ReferenceError: result is not defined` at the first add. A constant keeps the\n * hash stable across the content-to-reference swap while still declaring the variable.\n */\nexport class HashFileHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.type === SchemaTypes.File) {\n let stringBuilder = builder.getOrDefault<StringBuilder>(\"hash-object-return.variable.string\");\n\n if (stringBuilder == null) {\n stringBuilder = builder.get<SlotBlock>(\"hash-object-return\")\n .assign(\"const result\", { name: \"variable\" })\n .string(\"template\", { name: \"string\" });\n }\n\n // The property's NAME, not its value: stable on both sides of the swap, and still\n // distinct from a schema that does not have this file at all.\n stringBuilder.append(`file:${property.name}`);\n\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}\n","import { CodeBuilder, SlotBlock, StringBuilder } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo } from \"../../../schema\";\n\n/**\n * A transformed property takes no part in the hash that correlates an addition with its echo.\n *\n * The hash matches a submitted entity against the row the database echoed, which is why\n * identity values are already excluded: the database assigns them, so the two sides differ by\n * design.\n *\n * A transform is the same situation. What is submitted is the application value and what is\n * stored is the transformed one, and a ONE-WAY transform — no `from` — never converts back, so\n * the echo legitimately differs and every save reported \"Cannot find internal addition\". A\n * two-way transform happens to restore the value before the comparison, but relying on that\n * would make correlation depend on whether a caller supplied `from`.\n *\n * It contributes the property NAME rather than nothing, so a schema whose only non-identity\n * properties are transformed still declares the `result` string the generated function\n * returns.\n */\nexport class HashTransformHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.transform != null) {\n let stringBuilder = builder.getOrDefault<StringBuilder>(\"hash-object-return.variable.string\");\n\n if (stringBuilder == null) {\n stringBuilder = builder.get<SlotBlock>(\"hash-object-return\")\n .assign(\"const result\", { name: \"variable\" })\n .string(\"template\", { name: \"string\" });\n }\n\n stringBuilder.append(`transform:${property.name}`);\n\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}\n","import { HashKeyHandler } from \"./hash/HashKeyHandler\";\nimport { HashValueHandler } from \"./hash/HashValueHandler\";\nimport { HashDateHandler } from \"./hash/HashDateHandler\";\nimport { HashIdentityHandler } from \"./hash/HashIdentityHandler\";\nimport { HashFunctionHandler } from \"./hash/HashFunctionHandler\";\nimport { HashComputedValueHandler } from \"./hash/HashComputedValueHandler\";\nimport { HashArrayHandler } from \"./hash/HashArrayHandler\";\nimport { HashObjectHandler } from \"./hash/HashObjectHandler\";\nimport { HashFileHandler } from \"./hash/HashFileHandler\";\nimport { HashTransformHandler } from \"./hash/HashTransformHandler\";\n\n/// Purpose:\n// Should ignore Id's and Identities for type Object because we want\n// to comare a new addition with what was saved in the database.\n// Files are ignored for the same reason: content goes in, a reference comes back.\n// So are transformed properties, whose stored form differs from the value submitted.\nexport class HashHandlerBuilder {\n\n build() {\n const handler = new HashKeyHandler();\n\n handler\n .setNext(new HashComputedValueHandler())\n .setNext(new HashFunctionHandler())\n .setNext(new HashIdentityHandler())\n .setNext(new HashFileHandler())\n .setNext(new HashTransformHandler())\n .setNext(new HashDateHandler())\n .setNext(new HashArrayHandler())\n .setNext(new HashObjectHandler())\n .setNext(new HashValueHandler());\n\n return handler;\n }\n}","import { CodeBuilder, SlotBlock } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\nexport class EnableChangeTrackingObjectHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.type === SchemaTypes.Object) {\n const assignmentSlot = builder.get<SlotBlock>(\"assignment\");\n const childSelectorPath = property.getSelectrorPath({ parent: \"entity\" });\n const childAssignmentPath = property.getAssignmentPath({ parent: \"entity\" });\n\n // Pass the root as parent so nested writes mark the root entity dirty,\n // and the full dotted path so the change is recorded under it\n assignmentSlot.if(`${childSelectorPath} != null`).appendBody(`${childAssignmentPath} = enableChangeTracking(${childAssignmentPath}, \"${this.getTrackingPath(property)}\", entity);`);\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder, SlotBlock } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { isArrayValued, PropertyInfo } from \"../../../schema\";\n\n/**\n * Arrays participate in change tracking: the array itself is wrapped in the tracking\n * proxy (with the root as parent) so in-place mutations — push/splice/index writes —\n * mark the root entity dirty instead of being silently lost on save.\n */\nexport class EnableChangeTrackingArrayHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (isArrayValued(property.type)) {\n const assignmentSlot = builder.get<SlotBlock>(\"assignment\");\n const childSelectorPath = property.getSelectrorPath({ parent: \"entity\" });\n const childAssignmentPath = property.getAssignmentPath({ parent: \"entity\" });\n\n assignmentSlot.if(`${childSelectorPath} != null`).appendBody(`${childAssignmentPath} = enableChangeTracking(${childAssignmentPath}, \"${this.getTrackingPath(property)}\", entity);`);\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}\n","import { CodeBuilder } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\nexport class EnableChangeTrackingPrimitiveValueHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.type !== SchemaTypes.Object) {\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { EnableChangeTrackingObjectHandler } from \"./enableChangeTracking/EnableChangeTrackingObjectHandler\";\nimport { EnableChangeTrackingArrayHandler } from \"./enableChangeTracking/EnableChangeTrackingArrayHandler\";\nimport { EnableChangeTrackingPrimitiveValueHandler } from \"./enableChangeTracking/EnableChangeTrackingPrimitiveValueHandler\";\n\n/// Purpose:\nexport class EnableChangeTrackingHandlerBuilder {\n\n build() {\n const handler = new EnableChangeTrackingObjectHandler();\n handler.setNext(new EnableChangeTrackingArrayHandler()).setNext(new EnableChangeTrackingPrimitiveValueHandler());\n\n return handler;\n }\n}","import { CodeBuilder } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\nexport class FreezePrimitiveValueHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.type !== SchemaTypes.Object) {\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder, SlotBlock } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\nexport class FreezeObjectHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.type === SchemaTypes.Object) {\n const assignmentSlot = builder.get<SlotBlock>(\"assignment\");\n const childSelectorPath = property.getSelectrorPath({ parent: \"entity\" });\n const childAssignmentPath = property.getAssignmentPath({ parent: \"entity\" });\n\n assignmentSlot.if(`${childSelectorPath} != null`).unshiftBody(`${childAssignmentPath} = Object.freeze(${childAssignmentPath});`);\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder, SlotBlock } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { isArrayValued, PropertyInfo } from \"../../../schema\";\n\nexport class FreezeArrayHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (isArrayValued(property.type)) {\n const assignmentSlot = builder.get<SlotBlock>(\"assignment\");\n const childSelectorPath = property.getSelectrorPath({ parent: \"entity\" });\n const childAssignmentPath = property.getAssignmentPath({ parent: \"entity\" });\n\n assignmentSlot.if(`${childSelectorPath} != null`).unshiftBody(`${childAssignmentPath} = Object.freeze(${childAssignmentPath});`);\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}\n","import { FreezePrimitiveValueHandler } from \"./freeze/FreezePrimitiveValueHandler\";\nimport { FreezeObjectHandler } from \"./freeze/FreezeObjectHandler\";\nimport { FreezeArrayHandler } from \"./freeze/FreezeArrayHandler\";\n\n/// Purpose:\nexport class FreezeHandlerBuilder {\n\n build() {\n const handler = new FreezeObjectHandler();\n handler.setNext(new FreezeArrayHandler()).setNext(new FreezePrimitiveValueHandler());\n\n return handler;\n }\n}","import { CodeBuilder, ContainerBlock, SlotBlock } from '../../blocks';\nimport { SlotPath } from '../../SlotPath';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\n/**\n * Handles converting a Date value from JavaScript to a string value. Should handle remapping here because it is the lowest level in the code here.\n * Remapping higher up could break lower level code\n */\nexport class SerializeDateHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.type === SchemaTypes.Date) {\n let objectBuilder = builder.get<SlotBlock>(\"if\");\n // Serialize maps in-memory shape -> storage shape: read the entity by\n // property name, write the result by `from` (storage) name\n const entitySelectorPath = property.getSelectrorPath({ parent: \"entity\" });\n const entityAssignmentPath = property.getAssignmentPath({\n parent: \"result\",\n useFromPropertyName: true\n });\n\n // if it is nullable or optional, assign in an if block, otherwise we\n // could unintentionally assign a property that does not exist. An explicit null IS\n // assigned — it is a legal value, and dropping it here is known-defects #66. The\n // expression already passes null through, since null is not `instanceof Date`.\n if (property.isOptional || property.isNullable) {\n const ifAssignment = `${entityAssignmentPath} = ${entitySelectorPath} instanceof Date ? ${entitySelectorPath}.toISOString() : ${entitySelectorPath}`;\n const rootPath = new SlotPath(\"if\");\n builder.get<ContainerBlock>(rootPath.get()).if(`${entitySelectorPath} !== undefined`).appendBody(ifAssignment);\n return builder;\n }\n\n if (property.parent == null) {\n const dateExpr = `${entitySelectorPath} instanceof Date ? ${entitySelectorPath}.toISOString() : ${entitySelectorPath}`;\n objectBuilder.if(`Object.hasOwn(entity, \"${property.name}\")`).appendBody(`${entityAssignmentPath} = ${dateExpr}`);\n return builder;\n }\n\n // Nested date: same pattern as SerializeValueHandler — if block for parent existence, then assign with toISOString\n const dateExprNested = `${entitySelectorPath} instanceof Date ? ${entitySelectorPath}.toISOString() : ${entitySelectorPath}`;\n this.emitSerializeNestedAssignment(property, objectBuilder, dateExprNested);\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder, SlotBlock } from '../../blocks';\nimport { SlotPath } from '../../SlotPath';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\nexport class SerializeObjectHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.type === SchemaTypes.Object) {\n const slotPath = new SlotPath(\"assignments\");\n // The result is the storage shape — materialize the container under\n // its `from` (storage) name\n const childPath = property.getAssignmentPath({\n parent: \"result\",\n useFromPropertyName: true\n });\n\n if (property.isNullable || property.isOptional) {\n // Do nothing if it's nullable or optional as property assignments will check\n // and create if it does not exist. This way we can handle null/optional\n return builder;\n }\n\n const slot = builder.get<SlotBlock>(slotPath.get());\n slot.assign(`${childPath}`, { name: `[${childPath}]` }).value(\"{}\");\n\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder, SlotBlock } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\nexport class SerializeValueHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.type != SchemaTypes.Object && property.type != SchemaTypes.Date) {\n const slot = builder.getOrDefault<SlotBlock>(\"if\");\n // Serialize maps in-memory shape -> storage shape: read the entity by\n // property name, write the result by `from` (storage) name\n const entitySelectorPath = property.getAssignmentPath({ parent: \"entity\" });\n const resultSelectorPath = property.getAssignmentPath({ parent: \"result\", useFromPropertyName: true });\n\n if (property.parent == null) {\n // Only assign if the incoming entity has the property, this allows partial serialization\n // Basically only serialize what is there\n slot.if(`Object.hasOwn(entity, \"${property.name}\")`).appendBody(`${resultSelectorPath} = ${entitySelectorPath}`);\n return builder;\n }\n\n this.emitSerializeNestedAssignment(property, slot, entitySelectorPath);\n\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder, SlotBlock } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo } from \"../../../schema\";\n\nexport class SerializeSerializerHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.valueSerializer != null) {\n const slot = builder.getOrDefault<SlotBlock>(\"if\");\n const assignmentBuilder = builder.getOrDefault<SlotBlock>(\"functions\");\n // Serialize maps in-memory shape -> storage shape: read the entity by\n // property name, write the result by `from` (storage) name\n const entitySelectorPath = property.getSelectrorPath({ parent: \"entity\" });\n const resultSelectorPath = property.getAssignmentPath({ parent: \"result\", useFromPropertyName: true });\n\n const defaultFunctionWithParameters = this.toNamedFunction(property.valueSerializer.toString(), assignmentBuilder);\n defaultFunctionWithParameters.builder.parameters(...defaultFunctionWithParameters.parameters.map((_, i) => ({ name: defaultFunctionWithParameters.parameters[i], callName: entitySelectorPath })));\n\n if (property.parent == null) {\n slot.if(`Object.hasOwn(entity, \"${property.name}\")`).appendBody(`${resultSelectorPath} = ${defaultFunctionWithParameters.builder.toCallable()}`);\n return builder;\n }\n\n // Nested serializer: same pattern as SerializeValueHandler — if block for parent existence, then assign via serializer\n this.emitSerializeNestedAssignment(property, slot, defaultFunctionWithParameters.builder.toCallable());\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\nexport class SerializeFunctionHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.functionBody != null && property.type === SchemaTypes.Function) {\n // Functions should not be serialized\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo, SchemaTypes } from \"../../../schema\";\n\nexport class SerializeComputedHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.type === SchemaTypes.Computed && property.isUnmapped === true) {\n // Do not serialize computed properties that are unmapped\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { CodeBuilder, SlotBlock } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { isArrayValued, PropertyInfo, SchemaTypes } from \"../../../schema\";\n\n/**\n * Serializes arrays per element instead of copying the reference:\n *\n * - Date elements become ISO strings (same convention as SerializeDateHandler).\n * - Object elements are deep-copied so the storage payload shares no references\n * with the entity.\n * - Primitive elements are copied with a spread.\n *\n * Producing a NEW array also matters for change tracking: tracked entities hold\n * arrays wrapped in a Proxy, which cannot pass a structured-clone boundary\n * (BroadcastChannel.postMessage) — the serialized payload must be plain data.\n */\nexport class SerializeArrayHandler extends PropertyInfoHandler {\n\n private copyExpression(property: PropertyInfo<any>, selector: string): string {\n const elementType = property.innerSchema?.type;\n\n if (elementType === SchemaTypes.Date) {\n return `${selector}.map(function (v) { return v instanceof Date ? v.toISOString() : v; })`;\n }\n\n if (elementType === SchemaTypes.Object || elementType === SchemaTypes.Array || elementType === SchemaTypes.Definition) {\n return `${selector}.map(function (v) { return v == null ? v : structuredClone(v); })`;\n }\n\n return `[...${selector}]`;\n }\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (isArrayValued(property.type)) {\n const slot = builder.get<SlotBlock>(\"if\");\n // Serialize maps in-memory shape -> storage shape: read the entity by\n // property name, write the result by `from` (storage) name\n const entitySelectorPath = property.getAssignmentPath({ parent: \"entity\" });\n const resultSelectorPath = property.getAssignmentPath({ parent: \"result\", useFromPropertyName: true });\n\n // Null propagates as-is (nullable arrays); only real arrays are copied\n const valueExpression = `${entitySelectorPath} == null ? ${entitySelectorPath} : ${this.copyExpression(property, entitySelectorPath)}`;\n\n if (property.parent == null) {\n // Only assign if the incoming entity has the property, this allows partial\n // serialization (delta payloads carry only changed keys)\n slot.if(`Object.hasOwn(entity, \"${property.name}\")`).appendBody(`${resultSelectorPath} = ${valueExpression}`);\n return builder;\n }\n\n this.emitSerializeNestedAssignment(property, slot, valueExpression);\n\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}\n","import { SerializeDateHandler } from \"./serialize/SerializeDateHandler\";\nimport { SerializeObjectHandler } from \"./serialize/SerializeObjectHandler\";\nimport { SerializeValueHandler } from \"./serialize/SerializeValueHandler\";\nimport { SerializeSerializerHandler } from \"./serialize/SerializeSerializerHandler\";\nimport { SerializeFunctionHandler } from \"./serialize/SerializeFunctionHandler\";\nimport { SerializeComputedHandler } from \"./serialize/SerializeComputedHandler\";\nimport { SerializeArrayHandler } from \"./serialize/SerializeArrayHandler\";\n\n/// Purpose:\nexport class SerializeHandlerBuilder {\n\n build() {\n const handler = new SerializeSerializerHandler();\n handler\n .setNext(new SerializeComputedHandler())\n .setNext(new SerializeFunctionHandler())\n .setNext(new SerializeDateHandler())\n .setNext(new SerializeArrayHandler())\n .setNext(new SerializeValueHandler())\n .setNext(new SerializeObjectHandler());\n\n return handler;\n }\n}","import { now } from \"../../performance\";\nimport { Branded, uuid } from \"../../utilities\";\nimport { CompiledSchemaCore, ISchemaSubscription, SchemaId, SubscriptionChanges } from \"../types\";\n\ntype BroadcastChannelReceiverId = Branded<string, \"BroadcastChannelReceiverId\">;\ntype SubscriptionListenerCallback<T> = (changes: StampedChanges<T>) => void;\ntype BroadcastChannelType = InstanceType<typeof BroadcastChannel>;\ninterface ISubscriptionAction<T> {\n action(changes: StampedChanges<T>): void\n}\ntype StampedChanges<T> = { data: SubscriptionChanges<T>, timestamp: number };\n\nexport type SchemaSubscriptionOptions = {\n /**\n * Whether changes must reach listeners OUTSIDE this process — another browser tab, or\n * another worker thread in Node. Default `true`, which is the historical behaviour.\n *\n * It cannot be inferred. A BroadcastChannel gives a sender no way to ask who is on the\n * other end, so `send` can only count the listeners registered in THIS process. When\n * this is `true`, `send` must assume a listener it cannot see and always publish. When\n * a caller sets it to `false`, it promises there is no such listener, and `send` skips\n * the whole preprocess-and-post step whenever nobody local is listening.\n */\n crossTabSync?: boolean;\n};\n\nconst registry: Record<string, SchemaChannel<unknown>> = {};\n\n/**\n * Channels are scoped by schema AND database: two databases holding the same schema must not\n * see each other's change notifications, while instances of the same database (another tab, a\n * worker) share a scope and stay connected.\n *\n * Every datastore path supplies a scope — `IDbPlugin.databaseName` is required, so there is no\n * longer a plugin that leaves it out. The unscoped key remains for callers who create a\n * subscription directly off a schema without a database in hand; it is a channel per schema\n * across the whole process, which is what asking for no scope means. A SENDER that omits the\n * scope will not reach datastore listeners, because they are on `schema|databaseName`.\n */\nconst getChannelKey = (schemaId: SchemaId, scope?: string) => scope == null ? String(schemaId) : `${schemaId}|${scope}`;\n\nconst getChannelRegistry = <T>(schemaId: SchemaId, scope?: string): SchemaChannel<T> => {\n\n const key = getChannelKey(schemaId, scope);\n\n if (registry[key]) {\n return registry[key] as SchemaChannel<T>;\n }\n\n const channel = new SchemaChannel<T>(key);\n\n registry[key] = channel;\n\n return channel;\n}\n\n// Must have a sender and receiver. Sender cannot listen for it's own message\nclass SchemaChannel<T> {\n\n readonly sender: SchemaChannelSender<T>;\n readonly receiver: SchemaChannelReceiver<T>;\n\n // An open BroadcastChannel keeps the event loop alive. Channels are shared per schema,\n // so the pair can only close once every subscription using them has been disposed —\n // hence a count rather than a boolean.\n private subscribers: number = 0;\n\n constructor(channelKey: string) {\n this.sender = new SchemaChannelSender<T>(channelKey);\n this.receiver = new SchemaChannelReceiver<T>(channelKey);\n }\n\n /**\n * How many callbacks in THIS process are waiting on the channel.\n *\n * Deliberately not `subscribers`: that counts SchemaSubscription instances, and a\n * DataStore constructs one per collection up front purely to SEND from, so it never\n * reaches zero. Only `onMessage` registers a listener, which is the thing a sender\n * can be skipped for. See `SchemaSubscription.send`.\n */\n get listenerCount() {\n return this.receiver.listenerCount;\n }\n\n retain() {\n this.subscribers++;\n }\n\n /** Returns true when the last subscriber released the channel. */\n release() {\n this.subscribers--;\n return this.subscribers <= 0;\n }\n\n close() {\n this.sender.close();\n this.receiver.close();\n }\n}\n\n/**\n * Stops a channel from holding the process open.\n *\n * A DataStore opens a sender and a receiver per collection, and in Node an open\n * BroadcastChannel is a referenced handle. Without this, any script that builds a store and\n * does not call `destroyAsync()` runs to the end of its code and then hangs forever with two\n * live MessagePorts per collection — including the example in the README.\n *\n * `unref` is Node-only; the browser's BroadcastChannel has no such method and needs none.\n * A channel that is unreferenced still sends and receives normally. It only stops being a\n * reason for the process to stay alive, which is the correct default for a library: a program\n * with no work left should exit.\n */\nconst unreference = (channel: BroadcastChannelType) => {\n const maybeUnref = (channel as { unref?: () => void }).unref;\n\n if (typeof maybeUnref === 'function') {\n maybeUnref.call(channel);\n }\n};\n\nclass SchemaChannelSender<T> {\n\n private readonly broadcastChannel: BroadcastChannelType;\n\n constructor(channelKey: string) {\n this.broadcastChannel = new BroadcastChannel(`__routier-schema-subscription-channel:${channelKey}`);\n unreference(this.broadcastChannel);\n }\n\n send(changes: StampedChanges<T>) {\n this.broadcastChannel.postMessage(changes)\n }\n\n close() {\n this.broadcastChannel.close();\n }\n}\n\nclass SchemaChannelReceiver<T> {\n\n private readonly broadcastChannel: BroadcastChannelType;\n private subscriptions: SubscriptionListener<T>[] = [];\n\n constructor(channelKey: string) {\n this.broadcastChannel = new BroadcastChannel(`__routier-schema-subscription-channel:${channelKey}`);\n unreference(this.broadcastChannel);\n\n this.broadcastChannel.onmessage = (e) => {\n\n // We can't send to the same instance it is not possbile\n const stampedChanges = e.data as StampedChanges<T>;\n\n for (let i = 0, length = this.subscriptions.length; i < length; i++) {\n const subscription = this.subscriptions[i];\n\n subscription.action(stampedChanges);\n }\n };\n }\n\n get listenerCount() {\n return this.subscriptions.length;\n }\n\n addListener(id: BroadcastChannelReceiverId, listener: SubscriptionListenerCallback<T>) {\n this.subscriptions.push(new SubscriptionListener<T>(id, listener));\n }\n\n removeListeners(id: BroadcastChannelReceiverId) {\n this.subscriptions = this.subscriptions.filter(w => w.id !== id);\n }\n\n close() {\n this.subscriptions = [];\n this.broadcastChannel.onmessage = null;\n this.broadcastChannel.close();\n }\n}\n\nclass SubscriptionListener<T> implements ISubscriptionAction<T> {\n\n readonly id: BroadcastChannelReceiverId;\n private readonly listener: SubscriptionListenerCallback<T>;\n\n constructor(id: BroadcastChannelReceiverId, listener: SubscriptionListenerCallback<T>) {\n this.id = id;\n this.listener = listener;\n }\n\n action(changes: StampedChanges<T>) {\n this.listener(changes);\n }\n}\n\nexport class SchemaSubscription<T extends {}> implements ISchemaSubscription<T> {\n\n private readonly id: BroadcastChannelReceiverId;\n private readonly schema: CompiledSchemaCore<T>;\n private readonly scope?: string;\n private readonly createdAt: number;\n private readonly crossTabSync: boolean;\n private isDisposed: boolean = false;\n\n constructor(schema: CompiledSchemaCore<T>, signal?: AbortSignal, scope?: string, options?: SchemaSubscriptionOptions) {\n this.createdAt = now();\n this.id = uuid(8) as BroadcastChannelReceiverId;\n this.schema = schema;\n this.scope = scope;\n this.crossTabSync = options?.crossTabSync ?? true;\n\n getChannelRegistry<T>(schema.id, scope).retain();\n\n signal?.addEventListener(\"abort\", () => {\n this.dispose();\n }, { once: true });\n }\n\n send(changes: SubscriptionChanges<T>) {\n const regisry = getChannelRegistry<T>(this.schema.id, this.scope);\n\n // Preprocessing runs over every add, update, removal and unknown, and it ran on every\n // saveChanges even when the message had nowhere to go. Measured on this branch, skipping\n // it is worth ~18% on diff-update-1000 and ~10% on insert-1000.\n //\n // The guard lives here rather than at the call sites so every caller — CollectionBase,\n // View, and anything added later — gets it without repeating the condition.\n if (this.crossTabSync === false && regisry.listenerCount === 0) {\n return;\n }\n\n // cannot send raw data, needs to be preprocessed\n const preprocessedChanges: SubscriptionChanges<T> = {\n adds: Array.from({ length: changes.adds.length }),\n removals: Array.from({ length: changes.removals.length }),\n unknown: Array.from({ length: changes.unknown.length }),\n updates: Array.from({ length: changes.updates.length }),\n };\n\n for (let i = 0, length = changes.adds.length; i < length; i++) {\n preprocessedChanges.adds[i] = this.schema.preprocess(changes.adds[i]);\n }\n\n for (let i = 0, length = changes.removals.length; i < length; i++) {\n preprocessedChanges.removals[i] = this.schema.preprocess(changes.removals[i]);\n }\n\n for (let i = 0, length = changes.unknown.length; i < length; i++) {\n preprocessedChanges.unknown[i] = this.schema.preprocess(changes.unknown[i]);\n }\n\n for (let i = 0, length = changes.updates.length; i < length; i++) {\n preprocessedChanges.updates[i] = this.schema.preprocess(changes.updates[i]);\n }\n\n // Send message to all listeners.\n // Since we create a new listener when we do onMessage,\n // we don't need to worry about sending to ourselves, it \n // can't happen\n regisry.sender.send({\n data: preprocessedChanges,\n timestamp: now()\n });\n }\n\n onMessage(callback: (changes: SubscriptionChanges<T>) => void) {\n\n const regisry = getChannelRegistry<T>(this.schema.id, this.scope);\n\n // Link the callback to an instance\n regisry.receiver.addListener(this.id, ({ data, timestamp }) => {\n\n if (timestamp < this.createdAt) {\n // Sent before the receiver was even created\n return;\n }\n\n // Changes were preprocessed before they were sent, need to postprocess them.\n // \"diff\" enriches and deserializes without attaching a change-tracking proxy\n // or freezing: these entities belong to another instance's unit of work, and\n // subscribers only read them (or reseed them to re-run a query), never persist\n // mutations through them.\n const postProcessedChanges: SubscriptionChanges<T> = {\n adds: Array.from({ length: data.adds.length }),\n removals: Array.from({ length: data.removals.length }),\n unknown: Array.from({ length: data.unknown.length }),\n updates: Array.from({ length: data.updates.length }),\n };\n\n for (let i = 0, length = data.adds.length; i < length; i++) {\n postProcessedChanges.adds[i] = this.schema.postprocess(data.adds[i], \"diff\");\n }\n\n for (let i = 0, length = data.removals.length; i < length; i++) {\n postProcessedChanges.removals[i] = this.schema.postprocess(data.removals[i], \"diff\");\n }\n\n for (let i = 0, length = data.unknown.length; i < length; i++) {\n postProcessedChanges.unknown[i] = this.schema.postprocess(data.unknown[i], \"diff\");\n }\n\n for (let i = 0, length = data.updates.length; i < length; i++) {\n postProcessedChanges.updates[i] = this.schema.postprocess(data.updates[i], \"diff\");\n }\n\n callback(postProcessedChanges);\n });\n }\n\n dispose() {\n this[Symbol.dispose]();\n }\n\n [Symbol.dispose](): void {\n // Dispose is idempotent, and it must be: a second release would drop the shared\n // channel's count below zero and close it out from under live subscriptions.\n if (this.isDisposed) {\n return;\n }\n this.isDisposed = true;\n\n const regisry = getChannelRegistry<T>(this.schema.id, this.scope);\n\n // Remove listeners for this instance only\n regisry.receiver.removeListeners(this.id);\n\n // An open BroadcastChannel holds the event loop open, so the last subscription out\n // closes the pair and drops it from the registry.\n if (regisry.release()) {\n regisry.close();\n delete registry[getChannelKey(this.schema.id, this.scope)];\n }\n }\n}","import { CodeBuilder, SlotBlock } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo } from \"../../../schema\";\n\nexport class CompareIdsKeyHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<unknown>, builder: CodeBuilder): CodeBuilder | null {\n\n if (property.isKey) {\n const slot = builder.get<SlotBlock>(\"ifs\");\n const leftCompare = property.getSelectrorPath({ parent: \"a\" });\n const rightCompare = property.getSelectrorPath({ parent: \"b\" });\n\n slot.if(`${leftCompare} != ${rightCompare}`).appendBody(\"return false;\");\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { NotApplicableHandler } from \"./types\";\nimport { CompareIdsKeyHandler } from \"./compareIds/CompareIdsKeyHandler\";\n\nexport class CompareIdsHandlerBuilder {\n\n build() {\n const handler = new CompareIdsKeyHandler();\n\n handler.setNext(new NotApplicableHandler());\n\n return handler;\n }\n}","import { PropertyInfo } from '../PropertyInfo';\nimport { CompiledSchema, InferCreateType, InferType, SchemaTypes } from '../types';\nimport { SchemaBase } from '../property/base/SchemaBase';\nimport { SchemaArray } from '../property/types/SchemaArray';\nimport { SchemaDefinition } from '../SchemaDefinition';\nimport { s } from '../builder';\n\n/**\n * Standard JSON Schema V1 interface types\n * Based on https://standardschema.dev/json-schema\n */\nexport interface StandardTypedV1<Input = unknown, Output = Input> {\n readonly '~standard': StandardTypedV1.Props<Input, Output>;\n}\n\nexport declare namespace StandardTypedV1 {\n export interface Props<Input = unknown, Output = Input> {\n readonly version: 1;\n readonly vendor: string;\n readonly types?: Types<Input, Output> | undefined;\n }\n\n export interface Types<Input = unknown, Output = Input> {\n readonly input: Input;\n readonly output: Output;\n }\n}\n\nexport interface StandardJSONSchemaV1<Input = unknown, Output = Input> {\n readonly '~standard': StandardJSONSchemaV1.Props<Input, Output>;\n}\n\nexport declare namespace StandardJSONSchemaV1 {\n export interface Props<Input = unknown, Output = Input>\n extends StandardTypedV1.Props<Input, Output> {\n readonly jsonSchema: StandardJSONSchemaV1.Converter;\n }\n\n export interface Converter {\n readonly input: (\n options: StandardJSONSchemaV1.Options\n ) => Record<string, unknown>;\n readonly output: (\n options: StandardJSONSchemaV1.Options\n ) => Record<string, unknown>;\n }\n\n export type Target =\n | 'draft-2020-12'\n | 'draft-07'\n | 'openapi-3.0'\n | ({} & string);\n\n export interface Options {\n readonly target: Target;\n readonly libraryOptions?: Record<string, unknown> | undefined;\n }\n}\n\n/**\n * Context for property conversion\n */\ninterface ConversionContext {\n target: StandardJSONSchemaV1.Target;\n visited: Set<string>;\n useOutputType: boolean;\n convertProperty: (property: PropertyInfo<any>) => Record<string, unknown>;\n}\n\n/**\n * Strategy interface for converting property types to JSON Schema\n */\ntype PropertyConverter = (\n property: PropertyInfo<any>,\n context: ConversionContext\n) => Record<string, unknown>;\n\n/**\n * Converts a primitive property with optional enum/literals\n */\nfunction createPrimitiveConverter(\n jsonType: 'string' | 'number' | 'boolean'\n): PropertyConverter {\n return (property, _context) => {\n const jsonSchema: Record<string, unknown> = { type: jsonType };\n if (property.literals && property.literals.length > 0) {\n jsonSchema.enum = property.literals;\n }\n return jsonSchema;\n };\n}\n\n/**\n * Converts a Date property to JSON Schema\n */\nconst dateConverter: PropertyConverter = (_property, _context) => {\n return {\n type: 'string',\n format: 'date-time'\n };\n};\n\n/**\n * Converts an Object property to JSON Schema\n */\nconst objectConverter: PropertyConverter = (property, context) => {\n const jsonSchema: Record<string, unknown> = { type: 'object' };\n\n if (property.children && property.children.length > 0) {\n const properties: Record<string, unknown> = {};\n const required: string[] = [];\n\n for (const child of property.children) {\n // Skip computed and function properties for input schemas\n // Include them in output schemas as they represent derived values\n if (!context.useOutputType && (child.type === SchemaTypes.Computed || child.type === SchemaTypes.Function)) {\n continue;\n }\n\n const childSchema = context.convertProperty(child);\n\n // Skip empty schemas (e.g., computed properties that return empty for input)\n if (Object.keys(childSchema).length === 0) {\n continue;\n }\n\n const propertyName = child.from || child.name;\n properties[propertyName] = childSchema;\n\n // Add to required if not optional and not nullable\n // Computed/function properties are never required in JSON Schema\n if (!child.isOptional && !child.isNullable &&\n child.type !== SchemaTypes.Computed && child.type !== SchemaTypes.Function) {\n required.push(propertyName);\n }\n }\n\n if (Object.keys(properties).length > 0) {\n jsonSchema.properties = properties;\n }\n if (required.length > 0) {\n jsonSchema.required = required;\n }\n } else {\n // Empty object or unknown structure\n jsonSchema.properties = {};\n }\n\n return jsonSchema;\n};\n\n/**\n * Converts array inner schema to JSON Schema items\n * Attempts to fully recurse into object schemas when possible\n */\nfunction convertArrayItems(\n innerSchema: SchemaBase<any, any>,\n context: ConversionContext\n): Record<string, unknown> {\n const innerType = innerSchema.type;\n\n switch (innerType) {\n case SchemaTypes.String:\n return { type: 'string' };\n case SchemaTypes.Number:\n return { type: 'number' };\n case SchemaTypes.Boolean:\n return { type: 'boolean' };\n case SchemaTypes.Date:\n return { type: 'string', format: 'date-time' };\n case SchemaTypes.Object:\n // Try to extract object structure from innerSchema.instance\n // For SchemaObject, instance contains the property definitions\n if (innerSchema.instance && typeof innerSchema.instance === 'object') {\n const properties: Record<string, unknown> = {};\n const required: string[] = [];\n\n // Iterate through the instance properties\n for (const [key, value] of Object.entries(innerSchema.instance)) {\n if (value && typeof value === 'object' && 'type' in value) {\n // This is a SchemaBase - try to convert it\n const schemaBase = value as SchemaBase<any, any>;\n const tempProperty = new PropertyInfo(schemaBase, key);\n\n // Skip computed/function for input schemas\n if (!context.useOutputType &&\n (tempProperty.type === SchemaTypes.Computed || tempProperty.type === SchemaTypes.Function)) {\n continue;\n }\n\n const itemSchema = context.convertProperty(tempProperty);\n if (Object.keys(itemSchema).length > 0) {\n properties[key] = itemSchema;\n if (!tempProperty.isOptional && !tempProperty.isNullable &&\n tempProperty.type !== SchemaTypes.Computed && tempProperty.type !== SchemaTypes.Function) {\n required.push(key);\n }\n }\n }\n }\n\n if (Object.keys(properties).length > 0) {\n return {\n type: 'object',\n properties,\n ...(required.length > 0 ? { required } : {})\n };\n }\n }\n // Fallback for unknown object structure\n return {\n type: 'object',\n properties: {},\n description: 'Array item object schema'\n };\n case SchemaTypes.Array:\n // Nested arrays - recursively handle\n if (innerSchema instanceof SchemaArray && innerSchema.innerSchema) {\n return {\n type: 'array',\n items: convertArrayItems(innerSchema.innerSchema, context)\n };\n }\n return {\n type: 'array',\n items: { type: 'object' } // Simplified fallback\n };\n default:\n return { type: 'object' };\n }\n}\n\n/**\n * Converts an Array property to JSON Schema\n */\n/**\n * Converts a Vector property to JSON Schema.\n *\n * The dimension count is expressible here in a way it is not in the type system, so it is\n * emitted: a consumer validating against this schema rejects a wrong-width embedding, which\n * is the earliest anything can.\n */\nconst vectorConverter: PropertyConverter = (property, _context) => {\n const jsonSchema: Record<string, unknown> = {\n type: 'array',\n items: { type: 'number' }\n };\n\n if (property.dimensions != null) {\n jsonSchema.minItems = property.dimensions;\n jsonSchema.maxItems = property.dimensions;\n }\n\n return jsonSchema;\n};\n\nconst arrayConverter: PropertyConverter = (property, context) => {\n const jsonSchema: Record<string, unknown> = { type: 'array' };\n\n if (property.innerSchema) {\n jsonSchema.items = convertArrayItems(property.innerSchema, context);\n } else {\n jsonSchema.items = { type: 'object' };\n }\n\n return jsonSchema;\n};\n\n/**\n * Converts computed/function properties to JSON Schema\n * For input schemas, these return empty (should be skipped)\n * For output schemas, we include them with a generic object type\n */\nconst computedConverter: PropertyConverter = (property, context) => {\n // For input schemas, computed/function properties are not part of the data shape\n if (!context.useOutputType) {\n return {};\n }\n\n // For output schemas, include computed properties\n // We can't know the exact return type without executing the function,\n // so we use a generic object type with a note\n const routierMeta: Record<string, unknown> = {\n isComputed: property.type === SchemaTypes.Computed,\n isFunction: property.type === SchemaTypes.Function\n };\n\n // Store function source code for rehydration\n if (property.functionBody) {\n try {\n routierMeta.functionSource = property.functionBody.toString();\n } catch {\n // If function can't be serialized, store a placeholder\n routierMeta.functionSource = null;\n }\n }\n\n // Store injected value if it's serializable\n if (property.injected !== null && property.injected !== undefined) {\n try {\n // Try to serialize the injected value\n JSON.stringify(property.injected);\n routierMeta.injected = property.injected;\n } catch {\n // If injected value can't be serialized, store null\n routierMeta.injected = null;\n }\n } else {\n routierMeta.injected = null;\n }\n\n return {\n type: 'object',\n description: property.type === SchemaTypes.Computed\n ? 'Computed property (derived value)'\n : 'Function property (derived value)',\n 'x-routier': routierMeta\n };\n};\n\n/**\n * Default converter for unknown types\n */\nconst defaultConverter: PropertyConverter = () => {\n return { type: 'object' };\n};\n\n/**\n * Factory registry mapping SchemaTypes to converters\n */\nconst converterRegistry = new Map<SchemaTypes, PropertyConverter>([\n [SchemaTypes.String, createPrimitiveConverter('string')],\n [SchemaTypes.Number, createPrimitiveConverter('number')],\n [SchemaTypes.Boolean, createPrimitiveConverter('boolean')],\n [SchemaTypes.Date, dateConverter],\n [SchemaTypes.Object, objectConverter],\n [SchemaTypes.Array, arrayConverter],\n [SchemaTypes.Vector, vectorConverter],\n [SchemaTypes.Computed, computedConverter],\n [SchemaTypes.Function, computedConverter],\n]);\n\n/**\n * Applies nullable handling to a JSON Schema based on the target draft version\n */\nfunction applyNullable(\n jsonSchema: Record<string, unknown>,\n property: PropertyInfo<any>,\n target: StandardJSONSchemaV1.Target\n): void {\n if (!property.isNullable) {\n return;\n }\n\n if (target === 'draft-2020-12') {\n if (Array.isArray(jsonSchema.type)) {\n (jsonSchema.type as string[]).push('null');\n } else {\n jsonSchema.type = [jsonSchema.type as string, 'null'];\n }\n } else {\n jsonSchema.nullable = true;\n }\n}\n\n/**\n * Applies Routier-specific metadata to a JSON Schema\n */\nfunction applyRoutierMetadata(\n jsonSchema: Record<string, unknown>,\n property: PropertyInfo<any>\n): void {\n // Don't overwrite existing x-routier metadata (e.g., from computed properties)\n if (!jsonSchema['x-routier']) {\n jsonSchema['x-routier'] = {};\n }\n const routierMeta = jsonSchema['x-routier'] as Record<string, unknown>;\n\n // Only add metadata if it doesn't already exist (to preserve computed property metadata)\n if (property.isKey && !routierMeta.isKey) {\n routierMeta.isKey = true;\n }\n if (property.isIdentity && !routierMeta.isIdentity) {\n routierMeta.isIdentity = true;\n }\n if (property.isReadonly && !routierMeta.isReadonly) {\n routierMeta.isReadonly = true;\n }\n if (property.isDistinct && !routierMeta.isDistinct) {\n routierMeta.isDistinct = true;\n }\n if (property.isSearchable && !routierMeta.isSearchable) {\n routierMeta.isSearchable = true;\n }\n if (property.indexes && property.indexes.length > 0 && !routierMeta.indexes) {\n routierMeta.indexes = property.indexes;\n }\n if ((property.valueSerializer || property.valueDeserializer) && !routierMeta.hasCustomSerialization) {\n routierMeta.hasCustomSerialization = true;\n }\n if (property.defaultValue != null && !routierMeta.hasDefault) {\n routierMeta.hasDefault = true;\n // Note: We can't serialize function defaults, only note their presence\n if (typeof property.defaultValue === 'function') {\n routierMeta.defaultIsFunction = true;\n } else {\n // For static defaults, we can include the actual value\n // Note: This includes falsy values like 0, false, empty string, etc.\n routierMeta.defaultValue = property.defaultValue;\n }\n }\n // Store the Routier property name in metadata (may differ from JSON Schema key if from() is used)\n if (!routierMeta.propertyName) {\n routierMeta.propertyName = property.name;\n }\n if (property.from != null && !routierMeta.from) {\n routierMeta.from = property.from;\n }\n}\n\n/**\n * Converts a Routier PropertyInfo to a JSON Schema property definition.\n */\nexport function propertyInfoToJsonSchema(\n property: PropertyInfo<any>,\n target: StandardJSONSchemaV1.Target,\n visited: Set<string> = new Set(),\n useOutputType: boolean = false\n): Record<string, unknown> {\n // Create conversion context with recursive converter\n const context: ConversionContext = {\n target,\n visited,\n useOutputType,\n convertProperty: (prop) => propertyInfoToJsonSchema(prop, target, visited, useOutputType)\n };\n\n // Get converter from factory registry\n const converter = converterRegistry.get(property.type) ?? defaultConverter;\n\n // Convert the property\n const jsonSchema = converter(property, context);\n\n // Apply nullable handling\n applyNullable(jsonSchema, property, target);\n\n // Apply Routier-specific metadata\n applyRoutierMetadata(jsonSchema, property);\n\n return jsonSchema;\n}\n\n/**\n * Converts a CompiledSchema to a JSON Schema object schema.\n */\nexport function compiledSchemaToJsonSchema<T extends {}>(\n compiledSchema: CompiledSchema<T>,\n target: StandardJSONSchemaV1.Target,\n useOutputType: boolean = false\n): Record<string, unknown> {\n const jsonSchema: Record<string, unknown> = {\n $schema: target === 'draft-2020-12'\n ? 'https://json-schema.org/draft/2020-12/schema'\n : target === 'draft-07'\n ? 'http://json-schema.org/draft-07/schema#'\n : 'http://json-schema.org/draft-04/schema#',\n type: 'object',\n properties: {} as Record<string, unknown>,\n required: [] as string[]\n };\n\n const properties: Record<string, unknown> = {};\n const required: string[] = [];\n\n // Iterate through all properties\n for (const property of compiledSchema.properties) {\n // Skip computed and function properties for input schema\n // For output schema, we include computed properties\n if (!useOutputType && (property.type === SchemaTypes.Computed || property.type === SchemaTypes.Function)) {\n continue;\n }\n\n // Skip unmapped properties (except computed/function properties in output schema)\n if (property.isUnmapped && !(useOutputType && (property.type === SchemaTypes.Computed || property.type === SchemaTypes.Function))) {\n continue;\n }\n\n const propertySchema = propertyInfoToJsonSchema(property, target, new Set(), useOutputType);\n\n // Skip empty schemas (e.g., computed properties that return empty)\n if (Object.keys(propertySchema).length === 0) {\n continue;\n }\n\n const propertyName = property.from || property.name;\n properties[propertyName] = propertySchema;\n\n // Add to required if not optional and not nullable\n if (!property.isOptional && !property.isNullable) {\n required.push(propertyName);\n }\n }\n\n jsonSchema.properties = properties;\n if (required.length > 0) {\n jsonSchema.required = required;\n }\n\n // Add Routier-specific metadata\n jsonSchema['x-routier'] = {\n collectionName: compiledSchema.collectionName,\n idProperties: compiledSchema.idProperties.map(p => p.name),\n hasIdentities: compiledSchema.hasIdentities,\n hasIdentityKeys: compiledSchema.hasIdentityKeys\n };\n\n return jsonSchema;\n}\n\n/**\n * Creates Standard JSON Schema V1 props for a compiled schema.\n */\nexport function createStandardJsonSchemaProps<T extends {}>(\n compiledSchema: CompiledSchema<T>\n): StandardJSONSchemaV1.Props<InferCreateType<T>, InferType<T>> {\n return {\n version: 1,\n vendor: 'routier',\n types: {\n input: undefined as any as InferCreateType<T>,\n output: undefined as any as InferType<T>\n },\n jsonSchema: {\n input: (options: StandardJSONSchemaV1.Options): Record<string, unknown> => {\n return compiledSchemaToJsonSchema(compiledSchema, options.target, false);\n },\n output: (options: StandardJSONSchemaV1.Options): Record<string, unknown> => {\n return compiledSchemaToJsonSchema(compiledSchema, options.target, true);\n }\n }\n };\n}\n\n/**\n * Parses a JSON string containing a JSON Schema and rehydrates it into a Routier SchemaDefinition.\n * This is a convenience wrapper around `rehydrateSchemaFromJsonSchema` that handles JSON parsing.\n * \n * @param jsonString - The JSON string containing the JSON Schema\n * @param collectionName - The collection name for the schema (if not in x-routier metadata)\n * @returns A SchemaDefinition that can be compiled\n * @throws Error if the JSON string is invalid or doesn't contain a valid JSON Schema\n */\nexport function rehydrateSchemaFromJsonString(\n jsonString: string,\n collectionName?: string\n): SchemaDefinition<any> {\n try {\n const jsonSchema = JSON.parse(jsonString) as Record<string, unknown>;\n return rehydrateSchemaFromJsonSchema(jsonSchema, collectionName);\n } catch (error) {\n if (error instanceof SyntaxError) {\n throw new Error(`Invalid JSON string: ${error.message}`);\n }\n throw error;\n }\n}\n\n/**\n * Rehydrates a JSON Schema back into a Routier SchemaDefinition.\n * This parses the JSON Schema structure and reconstructs the schema using Routier's builder API.\n * \n * @param jsonSchema - The JSON Schema object to rehydrate\n * @param collectionName - The collection name for the schema (if not in x-routier metadata)\n * @returns A SchemaDefinition that can be compiled\n */\nexport function rehydrateSchemaFromJsonSchema(\n jsonSchema: Record<string, unknown>,\n collectionName?: string\n): SchemaDefinition<any> {\n // Extract collection name - provided collectionName takes precedence over metadata\n const routierMeta = jsonSchema['x-routier'] as Record<string, unknown> | undefined;\n const finalCollectionName = collectionName || (routierMeta?.collectionName as string) || 'unknown';\n\n if (!jsonSchema.properties || typeof jsonSchema.properties !== 'object') {\n throw new Error('JSON Schema must have a properties object');\n }\n\n const properties = jsonSchema.properties as Record<string, unknown>;\n const required = (jsonSchema.required as string[] | undefined) || [];\n const schemaDefinition: Record<string, any> = {};\n const computedProperties: Array<{ name: string; isComputed: boolean; functionSource: string | null; injected: any }> = [];\n\n // Get idProperties from schema-level metadata as fallback\n const idProperties = (routierMeta?.idProperties as string[] | undefined) || [];\n\n for (const [propName, propSchema] of Object.entries(properties)) {\n const prop = propSchema as Record<string, unknown>;\n const isRequired = required.includes(propName);\n const routierPropMeta = prop['x-routier'] as Record<string, unknown> | undefined;\n\n // Use Routier property name from metadata if available, otherwise use JSON Schema property name\n const routierPropName = (routierPropMeta?.propertyName as string | undefined) || propName;\n\n // Check if this is a computed or function property\n if (routierPropMeta?.isComputed || routierPropMeta?.isFunction) {\n computedProperties.push({\n name: routierPropName,\n isComputed: routierPropMeta.isComputed === true,\n functionSource: (routierPropMeta.functionSource as string | null) || null,\n injected: routierPropMeta.injected !== undefined ? routierPropMeta.injected : null\n });\n continue;\n }\n\n // Convert JSON Schema property to Routier schema\n let schemaBuilder: any = convertJsonSchemaPropertyToRoutier(prop);\n\n // Apply Routier-specific modifiers (using type assertion for method chaining)\n // Note: Apply key() first as it's required for schema compilation\n // Check both property-level metadata and schema-level idProperties list\n const isKey = routierPropMeta?.isKey === true || idProperties.includes(routierPropName);\n if (isKey && typeof schemaBuilder.key === 'function') {\n schemaBuilder = schemaBuilder.key();\n }\n // Apply from() mapping early, as it's a fundamental property mapping\n if (routierPropMeta?.from && typeof schemaBuilder.from === 'function') {\n schemaBuilder = schemaBuilder.from(routierPropMeta.from as string);\n }\n if (routierPropMeta?.isIdentity && typeof schemaBuilder.identity === 'function') {\n schemaBuilder = schemaBuilder.identity();\n }\n if (routierPropMeta?.isReadonly && typeof schemaBuilder.readonly === 'function') {\n schemaBuilder = schemaBuilder.readonly();\n }\n if (routierPropMeta?.isDistinct && typeof schemaBuilder.distinct === 'function') {\n schemaBuilder = schemaBuilder.distinct();\n }\n // Before `.optional()` below, which is safe because `isSearchable` survives a wrapping\n // modifier — see `SchemaBase.isSearchable`. Rebuilding a schema that silently dropped\n // this would take a property's terms out of the index and change what queries match.\n if (routierPropMeta?.isSearchable && typeof schemaBuilder.searchable === 'function') {\n schemaBuilder = schemaBuilder.searchable();\n }\n // Apply optional if property is not required (nullable and optional are independent)\n if (!isRequired && typeof schemaBuilder.optional === 'function') {\n schemaBuilder = schemaBuilder.optional();\n }\n // Apply nullable if property allows null (nullable and optional are independent)\n if (prop.nullable === true || (Array.isArray(prop.type) && prop.type.includes('null'))) {\n if (typeof schemaBuilder.nullable === 'function') {\n schemaBuilder = schemaBuilder.nullable();\n }\n }\n if (routierPropMeta?.indexes && Array.isArray(routierPropMeta.indexes)) {\n if (typeof schemaBuilder.index === 'function') {\n schemaBuilder = schemaBuilder.index(...(routierPropMeta.indexes as string[]));\n }\n }\n\n // Apply default value if present (only static defaults, not function defaults)\n // hasDefault=true and defaultIsFunction=false means we have a static default value stored\n if (routierPropMeta?.hasDefault && !routierPropMeta.defaultIsFunction && routierPropMeta.hasOwnProperty('defaultValue')) {\n if (typeof schemaBuilder.default === 'function') {\n schemaBuilder = schemaBuilder.default(routierPropMeta.defaultValue);\n }\n }\n\n schemaDefinition[routierPropName] = schemaBuilder;\n }\n\n // Build base schema\n let schema = s.define(finalCollectionName, schemaDefinition);\n\n // Add computed properties via modify()\n if (computedProperties.length > 0) {\n schema = schema.modify(x => {\n const computedDefs: Record<string, any> = {};\n\n for (const computedProp of computedProperties) {\n if (computedProp.functionSource) {\n // Recreate the function from source code\n // The function signature is: (entity, collectionName, injected) => result\n // We use new Function() to create the function, but wrap it so toString() returns the arrow function\n let recreatedFn: any;\n try {\n const functionSource = computedProp.functionSource;\n\n // Parse the arrow function to extract parameters and body\n const arrowMatch = functionSource.match(/^\\(([^)]*)\\)\\s*=>\\s*(.+)$/s);\n\n if (!arrowMatch) {\n throw new Error('Function source is not an arrow function');\n }\n\n // Parse parameters\n const paramsStr = arrowMatch[1].trim();\n const params = paramsStr ? paramsStr.split(',').map(p => p.trim()).filter(p => p) : [];\n const body = arrowMatch[2].trim();\n\n // Create function body - if it's a block (starts with {), use as-is, otherwise wrap in return\n const functionBody = body.startsWith('{')\n ? body.slice(1, -1) // Remove outer braces\n : `return ${body}`;\n\n // Create the function using new Function()\n // If no parameters, call with just the body; otherwise spread the params\n const fn = params.length > 0\n ? new Function(...params, functionBody)\n : new Function(functionBody);\n\n // Wrap it so toString() returns the original arrow function string\n // This is needed because the schema system validates that functions are arrow functions\n recreatedFn = Object.assign(fn, {\n toString: () => functionSource\n });\n } catch (e) {\n // If we can't recreate the function, create a placeholder arrow function that throws\n recreatedFn = () => {\n throw new Error(`Cannot recreate computed property ${computedProp.name}: ${e instanceof Error ? e.message : 'unknown error'}`);\n };\n // Ensure toString returns an arrow function for validation\n Object.assign(recreatedFn, {\n toString: () => `() => { throw new Error(\"Cannot recreate computed property ${computedProp.name}\"); }`\n });\n }\n\n // Add computed property with optional injected value\n if (computedProp.isComputed) {\n computedDefs[computedProp.name] = x.computed(recreatedFn, computedProp.injected);\n } else {\n computedDefs[computedProp.name] = x.function(recreatedFn, computedProp.injected);\n }\n } else {\n // No function source available - create a placeholder\n computedDefs[computedProp.name] = computedProp.isComputed\n ? x.computed(() => {\n throw new Error(`Computed property ${computedProp.name} could not be rehydrated: function source not available`);\n })\n : x.function(() => {\n throw new Error(`Function property ${computedProp.name} could not be rehydrated: function source not available`);\n });\n }\n }\n\n return computedDefs;\n });\n }\n\n return schema;\n}\n\n/**\n * Converts a JSON Schema property definition to a Routier schema builder.\n */\nfunction convertJsonSchemaPropertyToRoutier(\n prop: Record<string, unknown>\n): SchemaBase<any, any> {\n const type = Array.isArray(prop.type)\n ? (prop.type as string[]).find(t => t !== 'null') || prop.type[0]\n : prop.type as string;\n\n // Check for date type - dates are serialized as string with format 'date-time'\n if (type === 'string' && prop.format === 'date-time') {\n return s.date();\n }\n\n switch (type) {\n case 'string':\n if (prop.enum && Array.isArray(prop.enum)) {\n return s.string(...(prop.enum as string[]));\n }\n return s.string();\n\n case 'number':\n case 'integer':\n if (prop.enum && Array.isArray(prop.enum)) {\n return s.number(...(prop.enum as number[]));\n }\n return s.number();\n\n case 'boolean':\n return s.boolean();\n\n case 'object':\n // Recurse into object properties\n if (prop.properties && typeof prop.properties === 'object') {\n const objectProps = prop.properties as Record<string, unknown>;\n const objectSchema: Record<string, any> = {};\n\n for (const [key, value] of Object.entries(objectProps)) {\n objectSchema[key] = convertJsonSchemaPropertyToRoutier(value as Record<string, unknown>);\n }\n\n return s.object(objectSchema);\n }\n return s.object({});\n\n case 'array':\n // Handle array items\n if (prop.items && typeof prop.items === 'object') {\n const itemsSchema = convertJsonSchemaPropertyToRoutier(prop.items as Record<string, unknown>);\n return s.array(itemsSchema as any);\n }\n return s.array(s.object({}) as any);\n\n default:\n // Fallback to object for unknown types\n return s.object({});\n }\n}\n\n/**\n * Attempts to extract type information from a compiled schema for better type inference.\n * \n * Note: TypeScript types are compile-time only, so we can't extract actual type information at runtime.\n * The Standard JSON Schema spec allows libraries to advertise their inferred types via the `types` property,\n * but this requires compile-time type information that isn't available at runtime.\n * \n * For proper type inference, consumers should use TypeScript's type system:\n * ```typescript\n * const schema = s.define(\"users\", { ... }).compile();\n * type User = InferType<typeof schema>;\n * type CreateUser = InferCreateType<typeof schema>;\n * ```\n * \n * @param compiledSchema - The compiled schema to extract type info from\n * @returns A description of the type names (for documentation purposes only)\n */\nexport function extractTypeInfo<T extends {}>(\n compiledSchema: CompiledSchema<T>\n): { inputType: string; outputType: string } {\n return {\n inputType: `InferCreateType<${compiledSchema.collectionName}>`,\n outputType: `InferType<${compiledSchema.collectionName}>`\n };\n}\n","import { CodeBuilder, SlotBlock } from '../../blocks';\nimport { PropertyInfoHandler } from \"../types\";\nimport { PropertyInfo } from \"../../../schema/PropertyInfo\";\nimport { SchemaTypes } from \"../../../schema/types\";\n\nconst allowedTypes = new Set<SchemaTypes>([\n SchemaTypes.Array,\n SchemaTypes.Boolean,\n SchemaTypes.Date,\n SchemaTypes.Number,\n SchemaTypes.Object,\n SchemaTypes.String,\n SchemaTypes.Vector\n]);\n\nexport class SetComplexHandler extends PropertyInfoHandler {\n\n override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {\n\n if (allowedTypes.has(property.type)) {\n const selectorPath = property.getSelectrorPath({ parent: \"source\", assignmentType: \"FORCE_NULLABLE_OR_OPTIONAL\" });\n const slot = builder.get<SlotBlock>(\"assignments\");\n const entitySelectorPath = property.getAssignmentPath({ parent: \"source\" });\n const enrichedAssignmentPath = property.getAssignmentPath({ parent: \"destination\" });\n\n slot.if(`${selectorPath} != null`).appendBody(`${enrichedAssignmentPath} = ${entitySelectorPath}`);\n return builder;\n }\n\n return super.handle(property, builder);\n }\n}","import { NotApplicableHandler } from \"./types\";\nimport { SetComplexHandler } from \"./set/SetComplexHandler\";\n\nexport class SetHandlerBuilder {\n\n build() {\n const handler = new SetComplexHandler();\n\n handler.setNext(new NotApplicableHandler());\n\n return handler;\n }\n}","import { SchemaFunction } from './table/SchemaFunction';\nimport { SchemaTransform } from './table/SchemaTransform';\nimport { SchemaComputed } from './table/SchemaComputed';\nimport { SchemaBase } from \"./property/base/SchemaBase\";\nimport { PropertyInfo } from './PropertyInfo';\nimport { CodeBuilder, FunctionBuilder, SlotBlock } from '../codegen';\nimport { EnrichmentHandlerBuilder } from '../codegen/handlers/EnrichmentHandlerBuilder';\nimport { MergeHandlerBuilder } from '../codegen/handlers/MergeHandlerBuilder';\nimport { PrepareHandlerBuilder } from '../codegen/handlers/PrepareHandlerBuilder';\nimport { StripHandlerBuilder } from '../codegen/handlers/StripHandlerBuilder';\nimport { CloneHandlerBuilder } from '../codegen/handlers/CloneHandlerBuilder';\nimport { CompareHandlerBuilder } from '../codegen/handlers/CompareHandlerBuilder';\nimport { DeserializeHandlerBuilder } from '../codegen/handlers/DeserializeHandlerBuilder';\nimport { HashTypeHandlerBuilder } from '../codegen/handlers/HashTypeHandlerBuilder';\nimport { IdSelectorHandlerBuilder } from '../codegen/handlers/IdSelectorHandlerBuilder';\nimport { HashHandlerBuilder } from '../codegen/handlers/HashHandlerBuilder';\nimport { EnableChangeTrackingHandlerBuilder } from '../codegen/handlers/EnableChangeTrackingHandlerBuilder';\nimport { FreezeHandlerBuilder } from '../codegen/handlers/FreezeHandlerBuilder';\nimport { SchemaError } from '../errors/SchemaError';\nimport { SerializeHandlerBuilder } from \"../codegen/handlers/SerializeHandlerBuilder\";\nimport { hash, logger } from \"../utilities\";\nimport { CollectionName, CompiledSchema, CompiledSchemaCore, CompiledSchemaWithMetadata, GetHashTypeFunction, HashFunction, HashType, IdType, Index, InferCreateType, InferType, Prepare, Preprocess, SchemaId, SchemaTypes, SetProperties, PropertyTransform } from './types';\nimport { DeepPartial } from '../types';\nimport { SchemaSubscription, SchemaSubscriptionOptions } from './communication/broadcast';\nimport { CompareIdsHandlerBuilder } from '../codegen/handlers/CompareIdsHandlerBuilder';\nimport { StandardJSONSchemaV1, createStandardJsonSchemaProps, rehydrateSchemaFromJsonString } from './utils/standardJsonSchema';\nimport { SetHandlerBuilder } from '../codegen/handlers';\n\nfunction assertPropertyHandled(generatorName: string, property: PropertyInfo<any>, result: unknown): asserts result is {} {\n if (result == null) {\n throw new Error(`Schema compilation failed: no '${generatorName}' code generator handles property '${property.getAssignmentPath()}' (type: ${property.type}). Add a handler for this property shape or mark it not applicable in the ${generatorName} chain.`);\n }\n}\n\nfunction createChangeTracker() {\n const DIRTY_ENTITY_MARKER: string = \"isDirty\";\n const CHANGES_ENTITY_KEY: string = \"changes\";\n const ORIGINAL_ENTITY_KEY: string = \"original\";\n const PAUSED_ENTITY_KEY: string = \"isPaused\";\n const TRACKING_KEY: string = \"__tracking__\";\n const PROXY_MARKER: string = \"__isProxy__\";\n\n return <TEntity extends {}>(entity: TEntity, path?: string, parent?: TEntity) => {\n\n const proxyHandler: ProxyHandler<TEntity> = {\n set(entity, property, value) {\n const indexableEntity: { [key: string]: any } = entity;\n\n // if values are the same, do nothing\n //\n // Checked before `String(property)` on purpose. A write that changes\n // nothing is the common case, not the exception: `schema.merge` copies\n // every property of a re-read row into the attached entity, and on an\n // unchanged row every one of those writes lands here and returns.\n // Building the string key first made that path cost 156ns a write, of\n // which 125ns was the `String()` call alone; checking first takes it to\n // 31ns, against a 14ns floor for the same writes on a plain object.\n // Indexing by `property` rather than by `key` reads the same slot for\n // string keys, and the correct one for symbols (which `String()` would\n // have mangled into a \"Symbol(x)\" lookup).\n const originalValue = indexableEntity[property as string];\n\n if (originalValue === value) {\n return true;\n }\n\n const key = String(property);\n const resolvedParent: { [key: string]: any } = parent ?? entity;\n\n if (resolvedParent[TRACKING_KEY] == null) {\n // defineProperty, not assignment: a plain assignment creates an ENUMERABLE\n // property, and this is the lazy path that runs on the first tracked write —\n // so every entity the caller had edited came back from a query with\n // `__tracking__` visible to Object.entries, JSON.stringify and any deep\n // compare (defect #26). Both bootstrap paths below already define it\n // non-enumerable; this one was the outlier.\n Object.defineProperty(resolvedParent, TRACKING_KEY, {\n value: {\n [CHANGES_ENTITY_KEY]: {},\n [DIRTY_ENTITY_MARKER]: false,\n [ORIGINAL_ENTITY_KEY]: {},\n [PAUSED_ENTITY_KEY]: false\n },\n configurable: true,\n writable: true,\n enumerable: false\n });\n }\n\n if (key == TRACKING_KEY) {\n return true;\n }\n\n if (resolvedParent[TRACKING_KEY] != null && resolvedParent[TRACKING_KEY][PAUSED_ENTITY_KEY] === true) {\n Reflect.set(indexableEntity, property, value);\n return true;\n }\n\n const resolvedPath = path == null ? key : `${path}.${key}`;\n const changes = resolvedParent[TRACKING_KEY];\n\n if (changes[CHANGES_ENTITY_KEY][resolvedPath] != null) {\n\n if (changes[ORIGINAL_ENTITY_KEY][resolvedPath] === value) {\n // we are changing the value back to the original value, remove the change\n //\n // These two stay `delete`, unlike the `__tracking__` sites on the entity\n // itself. Assigning undefined here would be read as \"still changed\" by\n // the isDirty count below, which asks Object.keys — and a key assigned\n // undefined is still a key. Counting only defined values does not rescue\n // it either: an original value of undefined is legitimate (a property\n // that was unset and then given a value), so a defined-value count would\n // report a genuinely dirty entity as clean. Removing the key is the only\n // representation that keeps \"present\" and \"changed\" the same question.\n //\n // The cost is bounded in a way the entity sites are not: these bags hold\n // one key per changed path, they are internal to the tracking record, and\n // this branch only runs when a value is set BACK to its original.\n delete changes[ORIGINAL_ENTITY_KEY][resolvedPath];\n delete changes[CHANGES_ENTITY_KEY][resolvedPath];\n } else {\n // track the change\n changes[CHANGES_ENTITY_KEY][resolvedPath] = value;\n }\n\n } else if (changes[CHANGES_ENTITY_KEY][resolvedPath] == null) {\n // don't keep updating, keep the original value\n changes[CHANGES_ENTITY_KEY][resolvedPath] = value;\n changes[ORIGINAL_ENTITY_KEY][resolvedPath] = originalValue;\n }\n\n const isDirty = Object.keys(changes[ORIGINAL_ENTITY_KEY]).length > 0;\n changes[DIRTY_ENTITY_MARKER] = isDirty;\n\n Reflect.set(indexableEntity, property, value);\n\n return true;\n },\n get(target, property, receiver) {\n\n if (property === PROXY_MARKER) {\n return true;\n }\n\n return Reflect.get(target, property, receiver);\n }\n }\n\n return new Proxy(entity, proxyHandler) as TEntity;\n }\n}\n\n\nexport class SchemaDefinition<T extends {}> extends SchemaBase<T, any> {\n\n instance: T;\n type = SchemaTypes.Definition;\n collectionName: CollectionName;\n\n constructor(collectionName: CollectionName, schema: T) {\n super();\n this.collectionName = collectionName;\n this.instance = schema;\n this.isNullable = false;\n this.isOptional = false;\n }\n\n /**\n * Creates a SchemaDefinition from a JSON string containing a JSON Schema.\n * Parses the JSON string, rehydrates the schema structure, and compiles it.\n * \n * @param jsonString - The JSON string containing the JSON Schema (typically from `schema['~standard'].jsonSchema.input()` or `output()`)\n * @param collectionName - Optional collection name override (if not present in JSON Schema metadata)\n * @returns A compiled schema ready to use\n * @throws Error if the JSON string is invalid or doesn't contain a valid JSON Schema\n * \n * @example\n * ```typescript\n * // Serialize a schema to JSON\n * const jsonSchema = mySchema['~standard'].jsonSchema.input({ target: 'draft-2020-12' });\n * const jsonString = JSON.stringify(jsonSchema);\n * \n * // Rehydrate from JSON string\n * const rehydratedSchema = SchemaDefinition.fromJson(jsonString);\n * // Schema is already compiled and ready to use\n * ```\n */\n static fromJson(jsonString: string, collectionName?: string): CompiledSchema<any> {\n const schemaDefinition = rehydrateSchemaFromJsonString(jsonString, collectionName);\n return schemaDefinition.compile();\n }\n\n /**\n * Standard JSON Schema V1 implementation.\n * Provides JSON Schema conversion for Routier schemas.\n */\n get '~standard'(): StandardJSONSchemaV1.Props<InferCreateType<T>, InferType<T>> {\n const schema = this.compile();\n\n return createStandardJsonSchemaProps(schema);\n }\n\n private createReturnFunction<TResult>(builder: CodeBuilder): TResult {\n const body = builder.toString();\n try {\n return Function(`return ${body}`) as TResult;\n } catch (e) {\n logger.error(`Error compiling schema function. Function Body: ${body}`)\n throw e;\n }\n }\n\n private createFunction<TResult>(builder: CodeBuilder, ...fnArgs: string[]): TResult {\n const body = builder.toString();\n\n try {\n return Function(...fnArgs, body) as TResult;\n } catch (e) {\n logger.error(`Error compiling schema function. Function Body: ${body}`)\n throw e;\n }\n }\n\n modify<R>(builder: (d: {\n function: <UU, I = never>(fn: (entity: InferType<CompiledSchema<T>>, collectionName: CollectionName, injected: I) => UU, injected?: I) => SchemaFunction<UU, I, \"unmapped\">;\n computed: <UU, I = never>(fn: (entity: InferType<CompiledSchema<T>>, collectionName: CollectionName, injected: I) => UU, injected?: I) => SchemaComputed<UU, I, \"computed\" | \"unmapped\">;\n /**\n * Replaces a property with a transformed version of itself.\n *\n * `computed` derives a value one way and cannot come back. A transform declares both\n * directions, so the property keeps its type and only its STORED form changes.\n *\n * ```ts\n * .modify(x => ({\n * ssn: x.transform(s.string(), {\n * to: (value, keys) => myEncrypt(value, keys),\n * from: (text, keys) => myDecrypt(text, keys),\n * stores: SchemaTypes.String,\n * }, myKeys),\n * }))\n * ```\n *\n * `to` and `from` may be async and are held as live references, so they can close\n * over whatever they need. `injected` is there for when passing it explicitly reads\n * better than capturing it.\n */\n transform: <UU>(transform: PropertyTransform<UU>) => SchemaTransform<UU>;\n }) => R) {\n\n const b = {\n function: <UU, I = never>(fn: (entity: InferType<CompiledSchema<T>>, collectionName: CollectionName, injected?: I) => UU, injected?: I) => new SchemaFunction<UU, I, \"unmapped\">(fn as any, injected),\n computed: <UU, I = never>(fn: (entity: InferType<CompiledSchema<T>>, collectionName: CollectionName, injected?: I) => UU, injected?: I) => new SchemaComputed<UU, I, \"computed\" | \"unmapped\">(fn as any, injected),\n transform: <UU>(transform: PropertyTransform<UU>) => new SchemaTransform<UU>(transform)\n }\n\n const r = builder(b) as Record<string, unknown>;\n\n /**\n * A transform replaces the property it was assigned to, so it is bound here rather\n * than being handed its own property to repeat. `.modify()` already knows which one\n * is meant — it is the key.\n */\n for (const [name, value] of Object.entries(r)) {\n if (value instanceof SchemaTransform) {\n const underlying = (this.instance as Record<string, unknown>)[name];\n\n if (underlying == null) {\n throw new Error(\n `transform() was assigned to '${name}', which is not a property of ` +\n `'${this.collectionName}'. A transform replaces an existing property; ` +\n 'to add a new one, use computed().'\n );\n }\n\n value.bindTo(underlying as never);\n }\n }\n\n return new SchemaDefinition<R & T>(this.collectionName, { ...this.instance, ...r } as R & T);\n }\n\n private _iterate(\n instance: SchemaBase<any, any>,\n callback: (property: PropertyInfo<any>) => void\n ) {\n const explore: {\n path: string | null;\n instance:\n | SchemaBase<any, any>\n | { [key: string]: SchemaBase<any, any> };\n parents: {\n schema: { [key: string]: SchemaBase<any, any> };\n propertyInfo: PropertyInfo<any>;\n }[];\n propertyInfo: PropertyInfo<any> | null;\n }[] = [\n { path: null, instance, parents: [], propertyInfo: null }\n ];\n const properties: PropertyInfo<any>[] = [];\n\n for (let i = 0; i < explore.length; i++) {\n const item = explore[i];\n\n if (item.instance.type === SchemaTypes.Definition) {\n explore.push({\n path: null,\n instance: item.instance.instance,\n parents: [],\n propertyInfo: null\n });\n continue;\n }\n\n const instanceObj = item.instance as {\n [key: string]: SchemaBase<any, any>;\n };\n for (const key in instanceObj) {\n const propertyInstance = instanceObj[key] as SchemaBase<any, any>;\n const previousParent =\n item.parents.length === 0\n ? null\n : item.parents[item.parents.length - 1].propertyInfo;\n\n if (propertyInstance.type === SchemaTypes.Object) {\n const propertyInfo = new PropertyInfo<any>(\n propertyInstance,\n key,\n previousParent\n );\n explore.push({\n path: [item.path, key].filter((w) => w != null).join(\".\"),\n instance: propertyInstance.instance,\n parents: [\n ...item.parents,\n { schema: instanceObj, propertyInfo: propertyInfo }\n ],\n propertyInfo\n });\n\n if (previousParent === null) {\n properties.push(propertyInfo);\n continue;\n }\n\n previousParent.children.push(propertyInfo);\n continue;\n }\n\n const childPrimitivePropertyInfo = new PropertyInfo<any>(\n (item.instance as any)[key],\n key,\n previousParent\n );\n if (previousParent === null) {\n properties.push(childPrimitivePropertyInfo);\n continue;\n }\n\n previousParent.children.push(childPrimitivePropertyInfo);\n }\n }\n\n // Recursively trigger callbacks on properties and their children\n function recursiveCallback(prop: PropertyInfo<any>) {\n callback(prop);\n for (const child of prop.children) {\n recursiveCallback(child);\n }\n }\n\n for (const prop of properties) {\n recursiveCallback(prop);\n }\n }\n\n compile<TMetadata>(metadata: TMetadata): CompiledSchemaWithMetadata<T, TMetadata>\n compile(): CompiledSchema<T>;\n compile<TMetadata>(metadata?: TMetadata): CompiledSchema<T> | CompiledSchemaWithMetadata<T, TMetadata> {\n\n try {\n const properties: PropertyInfo<T>[] = [];\n const propertyMap: Map<string, PropertyInfo<T>> = new Map<string, PropertyInfo<T>>();\n\n const enrichmentHandlerBuilder = new EnrichmentHandlerBuilder();\n const mergeHandlerFactory = new MergeHandlerBuilder();\n const prepareHandlerBuilder = new PrepareHandlerBuilder();\n const stripHandlerBuilder = new StripHandlerBuilder();\n const cloneHandlerBuilder = new CloneHandlerBuilder();\n const compareHandlerBuilder = new CompareHandlerBuilder();\n const deserializeHandlerBuilder = new DeserializeHandlerBuilder();\n const hashTypeHandlerBuilder = new HashTypeHandlerBuilder();\n const idSelectorHandlerBuilder = new IdSelectorHandlerBuilder();\n const hashHandlerBuilder = new HashHandlerBuilder();\n const enableChangeTrackingHandlerBuilder = new EnableChangeTrackingHandlerBuilder();\n const freezeHandlerBuilder = new FreezeHandlerBuilder();\n const serializeHandlerBuilder = new SerializeHandlerBuilder();\n const compareIdsHandlerBuilder = new CompareIdsHandlerBuilder();\n const setHandlerBuilder = new SetHandlerBuilder();\n\n const enricher = enrichmentHandlerBuilder.build();\n const merge = mergeHandlerFactory.build();\n const prepare = prepareHandlerBuilder.build();\n const strip = stripHandlerBuilder.build();\n const clone = cloneHandlerBuilder.build();\n const compare = compareHandlerBuilder.build();\n const deserialize = deserializeHandlerBuilder.build();\n const hashTypeHandler = hashTypeHandlerBuilder.build();\n const idSelectorHandler = idSelectorHandlerBuilder.build();\n const hashHandler = hashHandlerBuilder.build();\n const enableChangeTrackingHandler = enableChangeTrackingHandlerBuilder.build();\n const freezeHandler = freezeHandlerBuilder.build();\n const serializeHandler = serializeHandlerBuilder.build();\n const compareIdsHandler = compareIdsHandlerBuilder.build();\n const setHandlerHanlder = setHandlerBuilder.build();\n\n const changeTrackingCodeBuilder = new CodeBuilder();\n changeTrackingCodeBuilder.raw(`${createChangeTracker.toString()}`);\n changeTrackingCodeBuilder.slot(\"declarations\").variable(\"enableChangeTracking\").value('createChangeTracker()');\n // Nested proxies are installed by assigning through already-proxied parents;\n // pause tracking during setup so those writes don't register as changes\n changeTrackingCodeBuilder.slot(\"pause\").raw('\\tconst hadTracking = entity.__tracking__ != null;\\n\\tif (!hadTracking) { Object.defineProperty(entity, \"__tracking__\", { value: { changes: {}, isDirty: false, original: {}, isPaused: false }, configurable: true, writable: true, enumerable: false }); }\\n\\tconst wasPaused = entity.__tracking__.isPaused;\\n\\tentity.__tracking__.isPaused = true;');\n changeTrackingCodeBuilder.slot(\"assignment\");\n // Tracking metadata is created lazily on the first real write; only restore\n // what already existed, never leave the bootstrap behind.\n //\n // Cleared by redefining the property, not by `delete`. `delete` moves the object\n // into V8 dictionary mode permanently — it never returns to fast properties, so\n // every later read of every property on the entity pays a dictionary lookup,\n // measured at ~43% slower reads.\n //\n // defineProperty rather than plain assignment because `entity` here is whatever\n // the caller passed, and enableChangeTracking is public API, so it may already be\n // a change-tracking proxy. That proxy's set trap answers writes to `__tracking__`\n // with a bare `return true` and drops them, which would leave this bootstrap\n // behind. The handler defines no defineProperty trap, so this reaches the target,\n // and repeating the descriptor keeps the property non-enumerable.\n changeTrackingCodeBuilder.slot(\"return\").raw('\\tif (hadTracking) { entity.__tracking__.isPaused = wasPaused; } else { delete entity.__tracking__; }\\n\\treturn enableChangeTracking(entity);');\n\n const freezeCodeBuilder = new CodeBuilder();\n freezeCodeBuilder.slot(\"assignment\");\n freezeCodeBuilder.slot(\"return\").raw('\\treturn Object.freeze(entity);');\n\n const enricherCodeBuilder = new CodeBuilder();\n\n const enricherFunctionRoot = enricherCodeBuilder.factory(\"factory\", { name: \"factory\" }).parameters({ name: \"collectionName\", value: this.collectionName });\n enricherFunctionRoot.slot(\"changeTracker\").raw(`${createChangeTracker.toString()}`);\n enricherFunctionRoot.slot(\"changeTrackerFunction\").raw(`\\tconst changeTracker = createChangeTracker();`);\n const enricherFunctionBody = enricherFunctionRoot.function(undefined, { name: \"function\" }).parameters(\"entity\", \"changeTrackingType\").return();\n\n enricherFunctionBody.slot(\"enableChangeTracking\")\n .variable(\"enableChangeTracking\")\n .value('changeTrackingType === \"proxy\" ? changeTracker : e => e');\n\n enricherFunctionBody.slot(\"append\");\n enricherFunctionBody.slot(\"enriched\");\n // Nested proxies are installed by assigning through already-proxied parents;\n // pause tracking during setup so those writes don't register as changes.\n // Non-enumerable: computed properties run after this and may JSON.stringify\n // the entity (e.g. content-hash ids) — the bootstrap must not change their input\n enricherFunctionBody.slot(\"declarations\").raw('\\tif (changeTrackingType === \"proxy\") { Object.defineProperty(enriched, \"__tracking__\", { value: { changes: {}, isDirty: false, original: {}, isPaused: true }, configurable: true, writable: true, enumerable: false }); }');\n enricherFunctionBody.slot(\"assignment\");\n enricherFunctionBody.slot(\"ifs\");\n enricherFunctionBody.slot(\"tracking\").if('changeTrackingType === \"immutable\"', { name: \"freeze\" });\n // The paused bootstrap tracking is removed rather than unpaused: tracking\n // metadata is created lazily on the first real write, and callers assert\n // an untouched entity carries none. Proxy mode recreates it on the first\n // tracked write (see defect #2).\n //\n // Cleared by assignment rather than `delete`, because `delete` drops the entity\n // into V8 dictionary mode for the rest of its life — and this line runs on EVERY\n // entity that comes off a read. Assignment keeps the non-enumerable descriptor\n // installed above, so the property still stays out of Object.keys and JSON.\n //\n // The condition is now \"proxy\" rather than \"not immutable\", which is the same set\n // of entities in practice: `enriched` is a fresh object literal built from schema\n // properties, so ONLY the proxy branch above ever puts `__tracking__` on it. Under\n // `delete` the wider condition was harmless because deleting an absent property is\n // a no-op; under assignment it would CREATE an enumerable `__tracking__` on every\n // diff- and readonly-tracked entity and leak it into persistence. Defect #16's\n // stray `{ isPaused: false }` residue stays fixed — nothing is left behind here.\n enricherFunctionBody.slot(\"return\").raw('\\tif (changeTrackingType === \"proxy\") { enriched.__tracking__ = undefined; }\\n\\treturn enableChangeTracking(enriched);');\n\n const preprocessCodeBuilder = new CodeBuilder();\n preprocessCodeBuilder.slot(\"main\");\n preprocessCodeBuilder.slot(\"return\").raw(` return result;`);\n\n const postprocessCodeBuilder = new CodeBuilder();\n postprocessCodeBuilder.slot(\"main\");\n postprocessCodeBuilder.slot(\"return\").raw(` return result;`);\n\n const setCodeBuilder = new CodeBuilder();\n setCodeBuilder.slot(\"assignments\");\n setCodeBuilder.slot(\"ifs\");\n\n const mergeCodeBuilder = new CodeBuilder();\n\n const mergeFunctionRoot = mergeCodeBuilder.factory(\"factory\", { name: \"factory\" }).parameters({ name: \"collectionName\", value: this.collectionName });\n const mergeFunctionBody = mergeFunctionRoot.function(undefined, { name: \"function\" }).parameters(\"destination\", \"source\").return();\n\n // The pause bootstrap exists so a PROXIED destination does not record the\n // merge's own writes as changes. A destination with no tracking (diff and\n // immutable modes) gets a temporary bootstrap so the same generated code runs —\n // and unpause() DELETES it again, because leaving it behind is the\n // `{ isPaused: false }` residue of defect #16, this time on the merge path.\n const pauseFunctionBody = mergeFunctionBody.function(\"pause\")\n .appendBody(\"// initiate change tracking if needed\");\n\n pauseFunctionBody.if(\"destination.__tracking__ == null\")\n // Non-enumerable for the same reason the enricher's bootstrap is: computed\n // properties can JSON.stringify the entity while this is installed, and the\n // bootstrap must not change their input. It is removed again below either way.\n .appendBody('Object.defineProperty(destination, \"__tracking__\", { value: {}, configurable: true, writable: true, enumerable: false });')\n .appendBody(\"installedTrackingBootstrap = true;\");\n\n pauseFunctionBody.appendBody(\"destination.__tracking__.isPaused = true;\");\n\n const unpauseFunctionBody = mergeFunctionBody.function(\"unpause\")\n .appendBody(\"// unpause change tracking, removing a bootstrap this merge installed\");\n\n // Redefined to undefined rather than deleted, so the merged entity keeps its fast\n // properties — `delete` would put it in dictionary mode for good.\n //\n // It must be defineProperty and NOT assignment. `destination` is an attached,\n // proxied entity, and the change tracker's set trap answers writes to\n // `__tracking__` with a bare `return true`, dropping them. Assigning here is\n // therefore a silent no-op that leaves the `{}` bootstrap installed by pause() in\n // place — and the next write through the proxy reads `changes.changes` off that\n // bootstrap and throws. defineProperty is not intercepted, because the handler\n // declares no defineProperty trap.\n unpauseFunctionBody.if(\"installedTrackingBootstrap === true\")\n .appendBody(\"delete destination.__tracking__;\")\n .appendBody(\"return;\");\n\n unpauseFunctionBody.if(\"destination.__tracking__ != null\")\n .appendBody(\"destination.__tracking__.isPaused = false;\");\n\n mergeFunctionBody.slot(\"header\").raw(`let installedTrackingBootstrap = false;\n pause()`);\n mergeFunctionBody.slot(\"assignments\");\n mergeFunctionBody.slot(\"ifs\");\n mergeFunctionBody.slot(\"return\").raw(`\n unpause();\n\n return destination;`);\n\n const prepareCodeBuilder = new CodeBuilder();\n prepareCodeBuilder.slot(\"result\");\n prepareCodeBuilder.slot(\"assignments\");\n prepareCodeBuilder.slot(\"return\").raw(` return result;`);\n\n const stripCodeBuilder = new CodeBuilder();\n stripCodeBuilder.slot(\"result\");\n stripCodeBuilder.slot(\"return\").raw(` return result;`);\n\n const cloneCodeBuilder = new CodeBuilder();\n cloneCodeBuilder.slot(\"result\").raw(\"const result = {};\");;\n cloneCodeBuilder.slot(\"assignments\");\n cloneCodeBuilder.slot(\"if\");\n cloneCodeBuilder.slot(\"return\").raw(` return result;`);\n\n const compareCodeBuilder = new CodeBuilder();\n compareCodeBuilder.slot(\"result\");\n compareCodeBuilder.slot(\"return\").raw(` return result;`);\n\n const compareIdsCodeBuilder = new CodeBuilder();\n compareIdsCodeBuilder.slot(\"ifs\");\n compareIdsCodeBuilder.slot(\"return\").raw(` return true;`);\n\n const deserializeCodeBuilder = new CodeBuilder();\n deserializeCodeBuilder.slot(\"functions\");\n deserializeCodeBuilder.slot(\"result\");\n deserializeCodeBuilder.slot(\"if\");\n deserializeCodeBuilder.slot(\"return\").raw(` return entity;`);\n\n const serializeCodeBuilder = new CodeBuilder();\n serializeCodeBuilder.slot(\"result\").raw(\"const result = {};\");\n serializeCodeBuilder.slot(\"assignments\");\n serializeCodeBuilder.slot(\"functions\");\n serializeCodeBuilder.slot(\"if\");\n serializeCodeBuilder.slot(\"return\").raw(` return result;`);\n\n const idSelectorCodeBuilder = new CodeBuilder();\n idSelectorCodeBuilder.slot(\"result\");\n idSelectorCodeBuilder.slot(\"return\").raw(` return result;`);\n\n const hashTypeCodeBuilder = new CodeBuilder();\n hashTypeCodeBuilder.slot(\"ifs\");\n hashTypeCodeBuilder.slot(\"return\").raw(` return \"Ids\";`);\n\n const hashCodeBuilder = new CodeBuilder();\n hashCodeBuilder.slot(\"functions\").raw(`\n function stringifyDate(d) {\n\n if (d == null) {\n return \"\";\n }\n\n if (typeof d === \"string\") {\n return d;\n }\n\n if (d.getTime != null) {\n return \"\" + d.getTime();\n }\n\n return d.toString();\n } \n`);\n const hashCodeBuilderIfBlock = hashCodeBuilder.if(`type === \"Ids\"`, { name: \"hash-id-if\" });\n hashCodeBuilderIfBlock.slot(\"if-body\");\n hashCodeBuilderIfBlock.appendBody(\"return result\");\n hashCodeBuilder.slot(\"hash-object-return\");\n hashCodeBuilder.raw(` return result;`)\n\n const idProperties: PropertyInfo<any>[] = [];\n const allPropertyNamesAndPaths: string[] = [];\n let hashType: HashType = HashType.Ids;\n let hasIdentities = false;\n let hasIdentityKeys = false;\n\n this._iterate(this, (property) => {\n\n properties.push(property);\n propertyMap.set(property.id, property);\n allPropertyNamesAndPaths.push(property.getSelectrorPath({ parent: \"entity\" }));\n\n if (property.isIdentity === true) {\n hasIdentities = true;\n }\n\n if (property.isKey === true) {\n idProperties.push(property);\n }\n\n if (property.isKey === true && property.isIdentity === true) {\n hasIdentityKeys = true;\n }\n\n // Every chain must claim every property. A null return means no\n // handler matched, and silently omitting the property from the\n // generated function corrupts data — fail the compile instead.\n assertPropertyHandled(\"enrich\", property, enricher.handle(property, enricherCodeBuilder));\n assertPropertyHandled(\"merge\", property, merge.handle(property, mergeCodeBuilder));\n assertPropertyHandled(\"prepare\", property, prepare.handle(property, prepareCodeBuilder));\n assertPropertyHandled(\"strip\", property, strip.handle(property, stripCodeBuilder));\n assertPropertyHandled(\"clone\", property, clone.handle(property, cloneCodeBuilder));\n assertPropertyHandled(\"compare\", property, compare.handle(property, compareCodeBuilder));\n assertPropertyHandled(\"deserialize\", property, deserialize.handle(property, deserializeCodeBuilder));\n assertPropertyHandled(\"serialize\", property, serializeHandler.handle(property, serializeCodeBuilder))\n assertPropertyHandled(\"hashType\", property, hashTypeHandler.handle(property, hashTypeCodeBuilder));\n assertPropertyHandled(\"idSelector\", property, idSelectorHandler.handle(property, idSelectorCodeBuilder));\n assertPropertyHandled(\"hash\", property, hashHandler.handle(property, hashCodeBuilder));\n assertPropertyHandled(\"enableChangeTracking\", property, enableChangeTrackingHandler.handle(property, changeTrackingCodeBuilder));\n assertPropertyHandled(\"freeze\", property, freezeHandler.handle(property, freezeCodeBuilder));\n assertPropertyHandled(\"compareIds\", property, compareIdsHandler.handle(property, compareIdsCodeBuilder));\n assertPropertyHandled(\"set\", property, setHandlerHanlder.handle(property, setCodeBuilder));\n });\n\n if (idProperties.length === 0) {\n throw new Error(`Schema must have a key. Use .key() to mark a property as a key. Collection Name: ${this.collectionName}`)\n }\n\n /**\n * The two things `.searchable()` cannot express in its own type.\n *\n * It is NOT checked here that the property is a string. The builder gates that:\n * `searchable()` exists on `SchemaString`, and on `SchemaOptional`/`SchemaNullable`\n * only when their `instance` is a string, so `s.number().optional().searchable()`\n * does not compile. A builder that offers a method and then throws has gated\n * nothing.\n *\n * A string nested in an `s.object()` does type-check, and cannot be indexed: v1\n * keys index rows by a ROOT property name, so a nested one has nowhere to be\n * recorded. Rejected rather than ignored — a silently unindexed property returns no\n * rows for a query the caller believes is covered.\n *\n * A property NAME longer than 100 characters breaks the index key's length budget.\n * The key is `${term}|${field}|${sourceId}` in a column declared `VARCHAR(255)`, and\n * the field name is the only unbounded part of it. See \"The index collection\" in\n * specs/full-text-search.md.\n */\n for (const property of properties) {\n\n if (property.isSearchable === false) {\n continue;\n }\n\n if (property.parent != null) {\n throw new Error(\n `searchable() is declared on '${property.getAssignmentPath()}', which is nested inside another property. ` +\n `Full-text search indexes root-level string properties only. Collection Name: ${this.collectionName}`\n );\n }\n\n if (property.name.length > 100) {\n throw new Error(\n `searchable() is declared on '${property.name}', whose name is ${property.name.length} characters. ` +\n `A searchable property name must be 100 characters or fewer, so the search index key fits its column. ` +\n `Collection Name: ${this.collectionName}`\n );\n }\n\n // The index key is `${term}|${field}|${sourceId}`, and it is only unambiguous\n // because no part of it can contain the separator. The default tokenizer cannot\n // emit one — it splits on anything that is not a letter or digit — so the field\n // name is the only piece that could.\n if (property.name.includes(\"|\")) {\n throw new Error(\n `searchable() is declared on '${property.name}', whose name contains '|'. ` +\n `That character separates the parts of a search index key and cannot appear in a field name. ` +\n `Collection Name: ${this.collectionName}`\n );\n }\n }\n\n const enrichParams = enricherFunctionRoot.getParameters();\n const mergeParams = mergeFunctionRoot.getParameters();\n\n const enrichGenerator = this.createReturnFunction<Function>(enricherCodeBuilder);\n const mergeGenerator = this.createReturnFunction<Function>(mergeCodeBuilder);\n\n // After enricher is used, we modify it to be deserialize and enrich\n enricherFunctionBody.get<SlotBlock>(\"append\").insert(deserializeCodeBuilder.get<SlotBlock>(\"functions\"));\n enricherFunctionBody.get<SlotBlock>(\"append\").insert(deserializeCodeBuilder.get<SlotBlock>(\"result\"));\n enricherFunctionBody.get<SlotBlock>(\"append\").insert(deserializeCodeBuilder.get<SlotBlock>(\"if\"));\n enricherFunctionRoot.replace(\"function\", new FunctionBuilder(undefined).parameters(\"unserialized\", \"changeTrackingType\").return());\n\n const postProcessGenerator = this.createReturnFunction<Function>(enricherCodeBuilder);\n const postProcessParams = enricherFunctionRoot.getParameters();\n\n // Combine prepare and serialize\n preprocessCodeBuilder.get<SlotBlock>(\"main\").insert(prepareCodeBuilder.get<SlotBlock>(\"result\"));\n preprocessCodeBuilder.get<SlotBlock>(\"main\").insert(prepareCodeBuilder.get<SlotBlock>(\"assignments\"));\n\n preprocessCodeBuilder.get<SlotBlock>(\"main\").insert(serializeCodeBuilder.get<SlotBlock>(\"assignments\"));\n preprocessCodeBuilder.get<SlotBlock>(\"main\").insert(serializeCodeBuilder.get<SlotBlock>(\"functions\"));\n preprocessCodeBuilder.get<SlotBlock>(\"main\").insert(serializeCodeBuilder.get<SlotBlock>(\"if\"));\n\n const getIdsFunction = this.createFunction<(entity: InferType<T>) => [IdType]>(idSelectorCodeBuilder, \"entity\");\n const getHashTypeFunction = this.createFunction<GetHashTypeFunction<T>>(hashTypeCodeBuilder, \"entity\");\n const prepareFunction = this.createFunction<Prepare<T>>(prepareCodeBuilder, \"entity\");\n const cloneFunction = this.createFunction<(entity: InferType<T>) => InferType<T>>(cloneCodeBuilder, \"entity\");\n\n /**\n * `clone`, but for records that are still in the STORAGE shape.\n *\n * Built on first use rather than at compile time. Generating it costs a full pass over\n * the property tree plus a `Function` compile, and only stores that hold records in\n * storage shape ever ask for it, so a schema that is never read through one pays\n * nothing. After the first call it is the same generated function as `clone`.\n */\n let storageCloneFunction: ((entity: InferType<T>) => InferType<T>) | null = null;\n const cloneStorageFunction = (entity: InferType<T>): InferType<T> => {\n\n if (storageCloneFunction == null) {\n const storageCloneCodeBuilder = new CodeBuilder();\n\n // Undeclared columns are carried across; declared ones are left to the\n // generated deep-copy code below. This is the one place this differs from\n // `clone`, and both halves of it matter.\n //\n // Carrying them at all: a stored record can hold columns the schema never\n // declared, and this copier replaces `structuredClone`, which kept them.\n // ConcurrencyDbPlugin depends on exactly that — it appends a synthetic\n // `__version` property carrying a `from` name for the express purpose of\n // pushing reads onto this path, so its hidden column survives the copy and the\n // wrapper can observe the row's version. Drop the token and every read looks\n // unversioned, so optimistic concurrency stops detecting conflicts silently.\n //\n // Skipping the declared ones: a blanket `{ ...entity }` would seed the result\n // with the SOURCE's nested objects, and the child handlers then write their\n // copies into those shared references — mutating the record the caller was\n // copying to get away from.\n // Compared inline rather than against a Set: the set would be rebuilt on every\n // call, and this runs once per record on every read.\n const isDeclared = properties\n .filter(property => property.parent == null)\n .map(property => `key === ${JSON.stringify(property.getResolvedName())}`)\n .join(\" || \");\n\n const skipDeclared = isDeclared.length === 0 ? \"\" : `if (${isDeclared}) { continue; }\\n `;\n\n storageCloneCodeBuilder.slot(\"result\").raw(\n `const result = {};\\n` +\n ` for (const key in entity) {\\n` +\n ` if (Object.hasOwn(entity, key) === false) { continue; }\\n` +\n ` ${skipDeclared}result[key] = entity[key];\\n` +\n ` }`\n );\n storageCloneCodeBuilder.slot(\"assignments\");\n storageCloneCodeBuilder.slot(\"if\");\n storageCloneCodeBuilder.slot(\"return\").raw(` return result;`);\n\n const storageClone = cloneHandlerBuilder.build(true);\n\n for (let i = 0, length = properties.length; i < length; i++) {\n assertPropertyHandled(\"cloneStorage\", properties[i], storageClone.handle(properties[i], storageCloneCodeBuilder));\n }\n\n storageCloneFunction = this.createFunction<(entity: InferType<T>) => InferType<T>>(storageCloneCodeBuilder, \"entity\");\n }\n\n return storageCloneFunction(entity);\n };\n const deserializeFunction = this.createFunction<(entity: InferType<T>) => InferType<T>>(deserializeCodeBuilder, \"unserialized\");\n const serializeFunction = this.createFunction<(entity: InferType<T>) => InferType<T>>(serializeCodeBuilder, \"entity\");\n const compareFunction = this.createFunction<(a: InferType<T>, b: InferType<T>) => boolean>(compareCodeBuilder, \"a\", \"b\");\n const stripFunction = this.createFunction<(entity: InferType<T>) => InferType<T>>(stripCodeBuilder, \"entity\");\n const hashFunction = this.createFunction<HashFunction<T>>(hashCodeBuilder, \"entity\", \"type\");\n const enableChangeTrackingFunction = this.createFunction<(entity: InferType<T>) => InferType<T>>(changeTrackingCodeBuilder, \"entity\");\n const freezeFunction = this.createFunction<(entity: InferType<T>) => InferType<T>>(freezeCodeBuilder, \"entity\");\n const compareIdsFunction = this.createFunction<(a: InferType<T>, b: InferType<T>) => boolean>(compareIdsCodeBuilder, \"a\", \"b\");\n const preprocessFunction = this.createFunction<Preprocess<T>>(preprocessCodeBuilder, \"entity\");\n const setFunction = this.createFunction<SetProperties<T>>(setCodeBuilder, \"destination\", \"source\");\n\n const enricherFactoryFunction = enrichGenerator();\n const postProcessFactoryFunction = postProcessGenerator();\n const mergeFactoryFunction = mergeGenerator();\n const postProcessFunction = postProcessFactoryFunction(...postProcessParams.map(w => w.value))\n const enricherFunction = enricherFactoryFunction(...enrichParams.map(w => w.value));\n const mergeFunction = mergeFactoryFunction(...mergeParams.map(w => w.value));\n\n const idPropertyNames = idProperties.map(w => w.name);\n const getId = (entity: InferType<T>) => {\n if (idPropertyNames.length > 1) {\n return hashFunction(entity, HashType.Ids) as IdType;\n }\n\n return getIdsFunction(entity as any)[0] as IdType;\n }\n\n const getProperty = (id: string) => propertyMap.get(id);\n const id = hash([...allPropertyNamesAndPaths, this.collectionName].join(\",\")) as SchemaId;\n\n // memoize this by the validProperties\n // TODO: See if we can generate a function to do this and eliminate loops\n const deserializePartial = (item: Record<string, unknown>, properties: PropertyInfo<T>[]) => {\n\n for (let i = 0, length = properties.length; i < length; i++) {\n const property = properties[i];\n const value = property.getValue(item);\n\n if (value == null) {\n continue;\n }\n\n const deserialized = property.deserialize(value);\n property.setValue(item, deserialized);\n }\n\n return item as DeepPartial<InferType<T>>;\n }\n\n const result: CompiledSchemaCore<T> = {\n preprocess: preprocessFunction,\n postprocess: postProcessFunction,\n set: setFunction,\n getId,\n getProperty,\n properties,\n idProperties,\n hasIdentities,\n hashType,\n getHashType: getHashTypeFunction,\n merge: mergeFunction,\n prepare: prepareFunction,\n clone: cloneFunction,\n cloneStorage: cloneStorageFunction,\n deserializePartial,\n deserialize: deserializeFunction,\n serialize: serializeFunction,\n compare: compareFunction,\n compareIds: compareIdsFunction,\n strip: stripFunction,\n hash: hashFunction,\n id,\n getIds: getIdsFunction,\n enrich: enricherFunction,\n collectionName: this.collectionName,\n hasIdentityKeys,\n freeze: freezeFunction,\n enableChangeTracking: enableChangeTrackingFunction,\n definition: this,\n getIndexes: () => {\n\n const indexes: Index[] = [];\n\n for (let i = 0, length = properties.length; i < length; i++) {\n const property = properties[i];\n\n if (property.indexes.length === 0) {\n continue; // No Index\n }\n\n for (let j = 0, l = property.indexes.length; j < l; j++) {\n const indexName = property.indexes[j];\n\n // Test for compound indexes\n const connections = properties.filter(w =>\n w !== property && // Don't match with self\n w.indexes.some(index => index === indexName)\n );\n\n const indexedProperties = [property, ...connections];\n\n if (indexedProperties.length === 1) {\n // Not a compound property\n if (indexedProperties[0].isKey) {\n indexes.push({\n properties: indexedProperties,\n type: \"primary-key\",\n name: indexName\n });\n continue;\n }\n\n if (indexedProperties[0].isDistinct) {\n indexes.push({\n properties: indexedProperties,\n type: \"unique\",\n name: indexName\n });\n continue;\n }\n\n indexes.push({\n properties: indexedProperties,\n type: \"single\",\n name: indexName\n });\n continue;\n }\n\n if (indexes.some(w => w.name === indexName)) {\n continue; // Already in a compound index\n }\n\n indexes.push({\n properties: indexedProperties,\n type: \"compound\",\n name: indexName\n });\n }\n }\n\n return indexes;\n }\n };\n\n if (metadata != null) {\n\n const compiledSchemaWithMetadata: CompiledSchemaWithMetadata<T, TMetadata> = {\n ...result,\n createSubscription: (signal?: AbortSignal, scope?: string, options?: SchemaSubscriptionOptions) => new SchemaSubscription(result, signal, scope, options),\n metadata\n };\n\n return compiledSchemaWithMetadata;\n }\n\n const compiledSchema = {\n createSubscription: (signal?: AbortSignal, scope?: string, options?: SchemaSubscriptionOptions) => new SchemaSubscription(result, signal, scope, options),\n ...result\n };\n\n return compiledSchema;\n } catch (e) {\n throw new SchemaError(e, `Error compiling schema for collection: ${this.collectionName}`);\n }\n }\n}\n","import { CompiledSchema, DefaultValue, InferType, PropertyDeserializer, PropertySerializer, SchemaModifiers, SchemaTypes } from \"../../types\";\nimport { SchemaBase } from \"../base/SchemaBase\";\nimport { SchemaDefault } from \"../modifiers/SchemaDefault\";\nimport { SchemaDeserialize } from \"../modifiers/SchemaDeserialize\";\nimport { SchemaDistinct } from \"../modifiers/SchemaDistinct\";\nimport { SchemaForeignKey } from \"../modifiers/SchemaForeignKey\";\nimport { SchemaFrom } from \"../modifiers/SchemaFrom\";\nimport { SchemaIdentity } from \"../modifiers/SchemaIdentity\";\nimport { SchemaIndex } from \"../modifiers/SchemaIndex\";\nimport { SchemaKey } from \"../modifiers/SchemaKey\";\nimport { SchemaNullable } from \"../modifiers/SchemaNullable\";\nimport { SchemaOptional } from \"../modifiers/SchemaOptional\";\nimport { SchemaReadonly } from \"../modifiers/SchemaReadonly\";\nimport { SchemaSerialize } from \"../modifiers/SchemaSerialize\";\nimport { SchemaTag } from \"../modifiers/SchemaTag\";\nimport { SchemaArray } from \"./SchemaArray\";\n\nexport class SchemaNumber<T extends number, TModifiers extends SchemaModifiers> extends SchemaBase<T, TModifiers> {\n\n instance: T;\n type = SchemaTypes.Number;\n private _schemaNumber = true;\n\n constrain<K extends T>() {\n return new SchemaNumber<K, TModifiers>(this as unknown as SchemaBase<K, TModifiers>);\n }\n\n from(propertyName: string) {\n return new SchemaFrom<T, TModifiers>(propertyName, this);\n }\n\n optional() {\n return new SchemaOptional<T, TModifiers | \"optional\">(this);\n }\n\n nullable() {\n return new SchemaNullable<T, TModifiers | \"nullable\">(this);\n }\n\n key() {\n return new SchemaKey<T, TModifiers | \"key\">(this);\n }\n\n foreignKey<K extends {}>(relatingSchema: CompiledSchema<K>, property: keyof InferType<CompiledSchema<K>>) {\n return new SchemaForeignKey<T, TModifiers, K>(this, relatingSchema, property);\n }\n\n default<I = never>(value: DefaultValue<T, I>, injected?: I) {\n return new SchemaDefault<T, I, TModifiers | \"default\">(value, injected, this);\n }\n\n readonly() {\n return new SchemaReadonly<T, TModifiers | \"readonly\">(this);\n }\n\n deserialize(deserializer: PropertyDeserializer<T>) {\n return new SchemaDeserialize<T, TModifiers | \"deserialize\">(deserializer, this);\n }\n\n serialize(serializer: PropertySerializer<T>) {\n return new SchemaSerialize<T, TModifiers | \"serialize\">(serializer, this);\n }\n\n identity() {\n return new SchemaIdentity<T, TModifiers | \"identity\" | \"readonly\">(this);\n }\n\n array() {\n return new SchemaArray<typeof this, TModifiers>(this as unknown as SchemaArray<typeof this, TModifiers>);\n }\n\n index(...indexes: string[]) {\n return new SchemaIndex<T, TModifiers>(this, ...indexes);\n }\n\n distinct() {\n return new SchemaDistinct<T, TModifiers | \"distinct\">(this);\n }\n\n tag(...tags: string[]) {\n return new SchemaTag<T, TModifiers>(tags, this);\n }\n\n\n}","import { DefaultValue, SchemaModifiers, SchemaTypes } from \"../../types\";\nimport { SchemaBase } from \"../base/SchemaBase\";\nimport { SchemaDefault } from \"../modifiers/SchemaDefault\";\nimport { SchemaFrom } from \"../modifiers/SchemaFrom\";\nimport { SchemaIdentity } from \"../modifiers/SchemaIdentity\";\nimport { SchemaNullable } from \"../modifiers/SchemaNullable\";\nimport { SchemaOptional } from \"../modifiers/SchemaOptional\";\nimport { SchemaTag } from \"../modifiers/SchemaTag\";\nimport { SchemaArray } from \"./SchemaArray\";\n\nexport class SchemaObject<T extends {}, TModifiers extends SchemaModifiers> extends SchemaBase<T, TModifiers> {\n\n instance: T;\n type = SchemaTypes.Object;\n private _schemaObject = true;\n\n constructor(schema: T) {\n super();\n this.instance = schema;\n }\n\n from(propertyName: string) {\n return new SchemaFrom<T, TModifiers>(propertyName, this);\n }\n\n optional() {\n return new SchemaOptional<T, TModifiers | \"optional\">(this);\n }\n\n nullable() {\n return new SchemaNullable<T, TModifiers | \"nullable\">(this);\n }\n\n default<I = never>(value: DefaultValue<T, I>, injected?: I) {\n return new SchemaDefault<T, I, TModifiers | \"default\">(value, injected, this);\n }\n\n identity() {\n return new SchemaIdentity<T, TModifiers | \"identity\" | \"readonly\">(this);\n }\n\n array() {\n return new SchemaArray<typeof this, TModifiers>(this as unknown as SchemaArray<typeof this, TModifiers>);\n }\n\n tag(...tags: string[]) {\n return new SchemaTag<T, TModifiers>(tags, this);\n }\n\n\n}","import { DefaultValue, SchemaModifiers, SchemaTypes } from \"../../types\";\nimport { SchemaBase } from \"../base/SchemaBase\";\nimport { SchemaDefault } from \"../modifiers/SchemaDefault\";\nimport { SchemaFrom } from \"../modifiers/SchemaFrom\";\nimport { SchemaNullable } from \"../modifiers/SchemaNullable\";\nimport { SchemaOptional } from \"../modifiers/SchemaOptional\";\nimport { SchemaReadonly } from \"../modifiers/SchemaReadonly\";\nimport { SchemaTag } from \"../modifiers/SchemaTag\";\n\n/**\n * A file: content on the way in, a reference on the way out.\n *\n * This is the one property type whose write shape differs from its stored shape. You assign\n * a `File`, a `Blob`, a `Uint8Array` or a string; what is stored, and what a query gives\n * back, is a reference — where the bytes live and what they are.\n *\n * ```ts\n * const documentSchema = s.define('documents', {\n * id: s.string().key().identity(),\n * title: s.string(),\n * file: s.file(),\n * }).compile();\n *\n * await store.documents.addAsync({ title: 'Q3', file: fileFromInput });\n * await store.saveChangesAsync();\n *\n * doc.file.size // 2_400_112\n * doc.file.contentType // 'application/pdf'\n * ```\n *\n * ## Why this cannot be `s.object({ key, size, ... })`\n *\n * The generated `preprocess` rebuilds an object property field by field from its declared\n * children — `result.file = {}` and then one assignment per child. Content assigned there is\n * therefore discarded by construction, before any plugin sees the entity: the property does\n * not arrive mangled, it does not arrive at all.\n *\n * A file is a LEAF here, with no child properties, so the generated code passes it through\n * untouched. The bytes survive as far as the plugin, which is the only place an upload can\n * happen — `preprocess` is synchronous and is called from the change tracker and the\n * broadcast path, so it cannot await one.\n *\n * ## What actually stores it\n *\n * Nothing in core uploads anything. `@routier/blob-plugin` wraps your real plugin, swaps\n * pending content for a reference during `bulkPersist`, and hands the reference down. Without\n * that wrapper a file property stores whatever you assigned, which is a mistake this type\n * cannot detect on its own.\n */\nexport class SchemaFile<T extends any, TModifiers extends SchemaModifiers> extends SchemaBase<T, TModifiers> {\n\n instance: T;\n type = SchemaTypes.File;\n private _schemaFile = true;\n\n constructor() {\n super();\n this.instance = null as T;\n }\n\n from(propertyName: string) {\n return new SchemaFrom<T, TModifiers>(propertyName, this);\n }\n\n optional() {\n return new SchemaOptional<T, TModifiers | \"optional\">(this);\n }\n\n nullable() {\n return new SchemaNullable<T, TModifiers | \"nullable\">(this);\n }\n\n readonly() {\n return new SchemaReadonly<T, TModifiers | \"readonly\">(this);\n }\n\n default<I = never>(value: DefaultValue<T, I>, injected?: I) {\n return new SchemaDefault<T, I, TModifiers | \"default\">(value, injected, this);\n }\n\n tag(...tags: string[]) {\n return new SchemaTag<T, TModifiers>(tags, this);\n }\n}\n","import { CompiledSchema, DefaultValue, InferType, PropertyDeserializer, PropertySerializer, SchemaModifiers, SchemaTypes, StringOptions } from \"../../types\";\nimport { SchemaBase } from \"../base/SchemaBase\";\nimport { SchemaDefault } from \"../modifiers/SchemaDefault\";\nimport { SchemaDeserialize } from \"../modifiers/SchemaDeserialize\";\nimport { SchemaDistinct } from \"../modifiers/SchemaDistinct\";\nimport { SchemaForeignKey } from \"../modifiers/SchemaForeignKey\";\nimport { SchemaFrom } from \"../modifiers/SchemaFrom\";\nimport { SchemaIdentity } from \"../modifiers/SchemaIdentity\";\nimport { SchemaIndex } from \"../modifiers/SchemaIndex\";\nimport { SchemaKey } from \"../modifiers/SchemaKey\";\nimport { SchemaNullable } from \"../modifiers/SchemaNullable\";\nimport { SchemaOptional } from \"../modifiers/SchemaOptional\";\nimport { SchemaReadonly } from \"../modifiers/SchemaReadonly\";\nimport { SchemaSearchable } from \"../modifiers/SchemaSearchable\";\nimport { SchemaSerialize } from \"../modifiers/SchemaSerialize\";\nimport { SchemaTag } from \"../modifiers/SchemaTag\";\nimport { SchemaArray } from \"./SchemaArray\";\n\nexport class SchemaString<T extends string, TModifiers extends SchemaModifiers> extends SchemaBase<T, TModifiers> {\n\n instance: T;\n type = SchemaTypes.String;\n private _schemaString = true;\n\n /**\n * @param entity Copied from when a modifier wraps this property.\n * @param literals The allowed values, when the string is a literal union.\n * @param options Declarations a backend may use. See `StringOptions`.\n */\n constructor(entity?: SchemaBase<T, TModifiers> | null, literals?: T[], options?: StringOptions) {\n super(entity, literals);\n\n if (options?.maxLength != null) {\n\n if (Number.isInteger(options.maxLength) === false || options.maxLength <= 0) {\n // Thrown at schema construction rather than at the first save, matching\n // `s.vector()`: a bad length is a typo in a declaration, and the stack is only\n // useful next to it.\n throw new Error(`A string's maxLength must be a positive whole number. Received: ${options.maxLength}`);\n }\n\n this.maxLength = options.maxLength;\n }\n }\n\n from(propertyName: string) {\n return new SchemaFrom<T, TModifiers>(propertyName, this);\n }\n\n constrain<K extends T>() {\n return new SchemaString<K, TModifiers>(this as unknown as SchemaBase<K, TModifiers>);\n }\n\n optional() {\n return new SchemaOptional<T, TModifiers | \"optional\">(this);\n }\n\n nullable() {\n return new SchemaNullable<T, TModifiers | \"nullable\">(this);\n }\n\n key() {\n return new SchemaKey<T, TModifiers | \"key\">(this);\n }\n\n foreignKey<K extends {}>(relatingSchema: CompiledSchema<K>, property: keyof InferType<CompiledSchema<K>>) {\n return new SchemaForeignKey<T, TModifiers, K>(this, relatingSchema, property);\n }\n\n default<I = never>(value: DefaultValue<T, I>, injected?: I) {\n return new SchemaDefault<T, I, TModifiers | \"default\">(value, injected, this);\n }\n\n readonly() {\n return new SchemaReadonly<T, TModifiers | \"readonly\">(this);\n }\n\n deserialize(deserializer: PropertyDeserializer<T>) {\n return new SchemaDeserialize<T, TModifiers | \"deserialize\">(deserializer, this);\n }\n\n serialize(serializer: PropertySerializer<T>) {\n return new SchemaSerialize<T, TModifiers | \"serialize\">(serializer, this);\n }\n\n identity() {\n return new SchemaIdentity<T, TModifiers | \"identity\" | \"readonly\">(this);\n }\n\n array() {\n return new SchemaArray<typeof this, TModifiers>(this as unknown as SchemaArray<typeof this, TModifiers>);\n }\n\n index(...indexes: string[]) {\n return new SchemaIndex<T, TModifiers>(this, ...indexes);\n }\n\n distinct() {\n return new SchemaDistinct<T, TModifiers | \"distinct\">(this);\n }\n\n /**\n * Marks this string as eligible for the collection's full-text search index.\n *\n * ```ts\n * title: s.string().searchable(),\n * body: s.string({ maxLength: 4000 }).searchable(),\n * ```\n *\n * Nothing is indexed until the collection declares `.searchIndex()`. Combines with\n * `.optional()` and `.nullable()` in either sense — an absent or null value contributes no\n * tokens.\n */\n searchable() {\n return new SchemaSearchable<T, TModifiers | \"searchable\">(this);\n }\n\n tag(...tags: string[]) {\n return new SchemaTag<T, TModifiers>(tags, this);\n }\n\n\n}","import { DefaultValue, SchemaModifiers, SchemaTypes } from \"../../types\";\nimport { SchemaBase } from \"../base/SchemaBase\";\nimport { SchemaDefault } from \"../modifiers/SchemaDefault\";\nimport { SchemaFrom } from \"../modifiers/SchemaFrom\";\nimport { SchemaNullable } from \"../modifiers/SchemaNullable\";\nimport { SchemaOptional } from \"../modifiers/SchemaOptional\";\nimport { SchemaReadonly } from \"../modifiers/SchemaReadonly\";\nimport { SchemaTag } from \"../modifiers/SchemaTag\";\n\n/**\n * An embedding: a fixed-length list of numbers you can search by similarity.\n *\n * ```ts\n * const documentSchema = s.define('documents', {\n * id: s.string().key().identity(),\n * title: s.string(),\n * embedding: s.vector(1536),\n * }).compile();\n *\n * const similar = await store.documents\n * .nearest(x => x.embedding, queryEmbedding, 10)\n * .toArrayAsync();\n * ```\n *\n * ## Why this is not `s.array(s.number())`\n *\n * By value it is exactly that, and every codegen handler treats the two the same on purpose —\n * a vector clones with a spread, compares by JSON and freezes like any other array. What an\n * array cannot carry is the DIMENSION COUNT, and a backend that stores vectors natively needs\n * it at DDL time: pgvector's column type is `vector(1536)`, not `vector`.\n *\n * So this exists to be RECOGNISED, not to behave differently. A backend that knows what a\n * vector is stores one; every other backend sees a list of numbers and stores JSON, which is\n * why the feature works everywhere rather than only on PostgreSQL.\n *\n * ## Dimensions are not enforced here\n *\n * `dimensions` is a declaration, and core never checks a value against it. The check belongs\n * where the cost of being wrong is paid: a backend with a native `vector(n)` column rejects a\n * mismatched write itself, with an error naming the column. Validating in core would duplicate\n * that on the backends that already do it and add a per-save array scan to the ones that\n * cannot use the information at all.\n *\n * ## Similarity is cosine, and it is not a filter\n *\n * `.nearest()` is an ordering plus a limit — it returns the closest rows, not the matching\n * ones. Distance itself is not exposed: the entity shape is fixed, and the ordering is what\n * callers act on. A backend with no vector support scores in memory, so the answer is the\n * same everywhere; only the amount of data read differs.\n */\nexport class SchemaVector<T extends any, TModifiers extends SchemaModifiers> extends SchemaBase<T, TModifiers> {\n\n instance: T;\n type = SchemaTypes.Vector;\n private _schemaVector = true;\n\n constructor(dimensions: number) {\n super();\n\n if (Number.isInteger(dimensions) === false || dimensions <= 0) {\n // Thrown at schema construction rather than at the first save: a bad dimension\n // count is a typo in a declaration, and the stack is only useful next to it.\n throw new Error(`A vector needs a positive whole number of dimensions. Received: ${dimensions}`);\n }\n\n this.dimensions = dimensions;\n this.instance = null as T;\n }\n\n from(propertyName: string) {\n return new SchemaFrom<T, TModifiers>(propertyName, this);\n }\n\n optional() {\n return new SchemaOptional<T, TModifiers | \"optional\">(this);\n }\n\n nullable() {\n return new SchemaNullable<T, TModifiers | \"nullable\">(this);\n }\n\n readonly() {\n return new SchemaReadonly<T, TModifiers | \"readonly\">(this);\n }\n\n default<I = never>(value: DefaultValue<T, I>, injected?: I) {\n return new SchemaDefault<T, I, TModifiers | \"default\">(value, injected, this);\n }\n\n tag(...tags: string[]) {\n return new SchemaTag<T, TModifiers>(tags, this);\n }\n}\n","import { SchemaArray } from \"./property/types/SchemaArray\";\nimport { SchemaBase } from \"./property/base/SchemaBase\";\nimport { SchemaBoolean } from \"./property/types/SchemaBoolean\";\nimport { SchemaDate } from \"./property/types/SchemaDate\";\nimport { SchemaDefinition } from \"./SchemaDefinition\";\nimport { SchemaNumber } from \"./property/types/SchemaNumber\";\nimport { SchemaObject } from \"./property/types/SchemaObject\";\nimport { SchemaFile } from \"./property/types/SchemaFile\";\nimport { SchemaString } from \"./property/types/SchemaString\";\nimport { SchemaVector } from \"./property/types/SchemaVector\";\nimport { CollectionName, FileReferenceValue, StringOptions, VectorValue } from \"./types\";\n\n/**\n * A string, optionally declaring how long it can be and which values it may take.\n *\n * ```ts\n * s.string() // any string\n * s.string(\"draft\", \"published\") // a literal union\n * s.string({ maxLength: 4000 }) // any string, declared long\n * s.string({ maxLength: 8 }, \"a\", \"b\") // both\n * ```\n *\n * The options object is a leading parameter rather than a `.maxLength()` modifier so the\n * declaration stays on the factory, next to the literals. A modifier would also have to survive\n * being wrapped by another modifier, which is the trap `SchemaBase.maxLength` documents.\n */\nfunction string<T extends string[] = string[]>(...literals: T): SchemaString<T[number] extends never ? string : T[number], never>;\nfunction string<T extends string[] = string[]>(options: StringOptions, ...literals: T): SchemaString<T[number] extends never ? string : T[number], never>;\nfunction string(optionsOrLiteral?: StringOptions | string, ...rest: string[]) {\n\n // A literal is a string and options is an object, so the first argument decides which\n // overload was called. Nothing else can be passed, which is why this needs no flag and no\n // second factory.\n if (typeof optionsOrLiteral === \"string\") {\n return new SchemaString<string, never>(null, [optionsOrLiteral, ...rest]);\n }\n\n if (optionsOrLiteral == null) {\n return new SchemaString<string, never>(null, []);\n }\n\n return new SchemaString<string, never>(null, rest, optionsOrLiteral);\n}\n\nexport const s = {\n number: <T extends number[] = number[]>(...literals: T) => new SchemaNumber<T[number] extends never ? number : T[number], never>(null, literals),\n string,\n boolean: <T extends boolean = boolean>() => new SchemaBoolean<T, never>(),\n date: <T extends Date = Date>() => new SchemaDate<T, never>(),\n array: <T extends any>(schema: SchemaBase<T, never>) => new SchemaArray<SchemaBase<T, never>, never>(schema as any),\n object: <T extends {} = {}>(schema: T) => new SchemaObject<T, never>(schema),\n /**\n * A file. Assign content, read back a reference.\n *\n * Needs `@routier/blob-plugin` wrapping your plugin to turn the one into the other; core\n * only carries the value through untouched.\n */\n file: () => new SchemaFile<FileReferenceValue, never>(),\n /**\n * An embedding of `dimensions` numbers, searchable with `.nearest()`.\n *\n * Every backend supports it. One with a native vector column uses it; the rest store the\n * numbers as JSON and score the search in memory, which returns the same rows.\n */\n vector: (dimensions: number) => new SchemaVector<VectorValue, never>(dimensions),\n define: <T extends {}>(collectionName: string, schema: T) => new SchemaDefinition<T>(collectionName as CollectionName, schema),\n}","export * from './SchemaComputed';\nexport * from './SchemaFunction';\nexport * from './SchemaTransform';\n","export * from './SchemaBase';","export * from './SchemaDefault';\nexport * from './SchemaDeserialize';\nexport * from './SchemaDistinct';\nexport * from './SchemaIdentity';\nexport * from './SchemaIndex';\nexport * from './SchemaKey';\nexport * from './SchemaNullable';\nexport * from './SchemaOptional';\nexport * from './SchemaReadonly';\nexport * from './SchemaSearchable';\nexport * from './SchemaSerialize';\nexport * from './SchemaTracked';\nexport * from './SchemaFrom';\nexport * from './SchemaTag';\nexport * from './SchemaForeignKey';\n","export * from './SchemaArray';\nexport * from './SchemaBoolean';\nexport * from './SchemaDate';\nexport * from './SchemaNumber';\nexport * from './SchemaObject';\nexport * from './SchemaString';\nexport * from './SchemaFile';\nexport * from './SchemaVector';\n","export * from './builder';\nexport * from './table';\nexport * from './property/base';\nexport * from './property/modifiers';\nexport * from './property/types';\nexport * from './PropertyInfo';\nexport * from './types';\nexport type { SchemaSubscriptionOptions } from './communication/broadcast';\nexport * from './utils/standardJsonSchema';\nexport * from './utils/propertyKind';\nexport * from './SchemaDefinition';"],"names":["uuid","Block","name","parentIndent","parent","w","lines","block","indent","split","result","item","found","undefined","Error","x","line","foundIndex","text","ContainerBlock","condition","options","builder","IfBuilder","raw","RawBuilder","FunctionBuilder","FunctionFactoryBuilder","declaration","VariableBuilder","variableName","AssignmentBuilder","ObjectBuilder","SlotBlock","accessor","ArrayBuilder","StringBuilder","type","value","and","AndBuilder","objectBuilder","functionName","stringBuilder","arrayBuilder","lastLine","propertyName","isNestedContent","sectionName","params","body","parameterNames","parameterValues","Function","r","signature","Array","CodeBuilder","SchemaError","error","innerErrorMessage","logger","measurements","now","performance","Date","measure","start","delta","SchemaTypes","HashType","LOG_LEVELS","RANK","isLogLevel","resolveLevel","globalThis","g","process","debug","env","level","rank","setLogLevel","next","getLogLevel","resetLogLevel","isLogLevelEnabled","at","emit","method","args","console","hash","seed","h1","h2","i","ch","Math","fastHash","stringifyObject","obj","maxDepth","currentDepth","String","getFunctionName","stringifyObjectValue","fn","getObjectProperties","properties","key","RegExp","stringifyArray","stringifyClassInstance","stringifyPlainObject","arr","items","suffix","className","Object","props","isPrimitive","depth","length","chars","charLength","HEX_CHARS","UUID_TEMPLATE","hasCrypto","crypto","hasRandomUUID","uuidv4","uuidv4Fallback","randomBytes","Uint8Array","byteIndex","c","SchemaBase","entity","literals","SchemaDistinct","current","SchemaIdentity","SchemaNullable","SchemaOptional","SchemaSearchable","SchemaDeserialize","deserializer","SchemaDefault","injected","SchemaSerialize","serializer","SchemaFrom","SchemaReadonly","defaultValue","SchemaIndex","indexes","SchemaArray","SchemaTag","tags","SchemaBoolean","SchemaDate","SchemaFunction","SchemaTransform","underlying","transform","SchemaForeignKey","relatingSchema","property","SchemaKey","SchemaTracked","SchemaComputed","PropertyInfo","schema","chain","precedingProp","assignmentType","propertyChain","hasRoot","path","prop","fromPath","children","child","instance","pathArray","parts","Number","Boolean","SlotPath","pathLike","up","countWordOccurance","word","wl","tl","code","count","isWordCharCode","enforceWordBoundaries","k","cc","left","right","leftOk","rightOk","NotApplicableHandler","handler","_","PropertyInfoHandler","e","p","names","root","parentPathArray","pathSoFar","slot","valueExpression","parentSelectPath","resultSelectorPath","ifSlot","selectorPath","sourcePath","destinationPath","ifBlock","base","entitySelectorPath","slotPath","parentSlotPath","childEntityPathSelector","enriched","enrichedSlot","stringifiedFunction","occurences","parameters","index","EnrichmentNullableObjectHandler","nestedSlotPath","entityPath","enrichedPath","ifsSlot","parentBuilder","enrichedRoot","EnrichmentObjectHandler","EnrichmentObjectIdentityHandler","EnrichmentPrimitiveIdentityHandler","enrichedAssignmentPath","EnrichmentPrimitiveHandler","EnrichmentFunctionHandler","factory","parameter","declarationsSlot","defaultFunctionWithParameters","EnrichmentDefaultValueHandler","checkPath","assignmentPath","renderDefaultLiteral","JSON","EnrichmentDefaultFunctionHandler","defaultFunction","EnrichmentComputedValueHandler","ARRAY_VALUED_TYPES","Set","isArrayValued","PRIMITIVE_ELEMENT_TYPES","hasPrimitiveElements","elementType","EnrichmentArrayHandler","EnrichmentHandlerBuilder","MergeDefaultFunctionHandler","defaultFunctionParameters","defaultIf","MergeObjectHandler","MergePrimitiveHandler","MergeComputedValueHandler","MergeDefaultValueHandler","MergeFunctionHandler","MergeArrayHandler","MergeHandlerBuilder","PrepareIdentityHandler","PrepareKeyHandler","PrepareValueHandler","PrepareObjectHandler","nestedObjectBuilder","PrepareComputedValueHandler","PrepareFunctionHandler","PrepareHandlerBuilder","StripObjectHandler","StripValueHandler","StripKeyHandler","StripIdentityHandler","StripFunctionHandler","StripComputedHandler","StripHandlerBuilder","CloneArrayHandler","useFromPropertyName","resultAssignmentPath","copyExpression","nullSafeCopy","CloneDateHandler","CloneObjectHandler","CloneValueHandler","CloneHandlerBuilder","CompareArrayHandler","compare","leftCompare","rightCompare","CompareComputedHandler","CompareDateHandler","CompareFunctionHandler","CompareObjectHandler","CompareValueHandler","CompareHandlerBuilder","DeserializeObjectHandler","DeserializeValueHandler","DeserializeDateHandler","entityAssignmentPath","assignment","ifAssignment","rootPath","DeserializeComputedValueHandler","DeserializeFunctionHandler","DeserializeDeserializerHandler","assignmentBuilder","DeserializeArrayHandler","selector","DeserializeHandlerBuilder","HashTypeValueHandler","HashTypeHandlerBuilder","IdSelectorValueHandler","IdSelectorHandlerBuilder","HashKeyHandler","HashValueHandler","HashDateHandler","HashIdentityHandler","HashFunctionHandler","HashComputedValueHandler","HashArrayHandler","HashObjectHandler","HashFileHandler","HashTransformHandler","HashHandlerBuilder","EnableChangeTrackingObjectHandler","assignmentSlot","childSelectorPath","childAssignmentPath","EnableChangeTrackingArrayHandler","EnableChangeTrackingPrimitiveValueHandler","EnableChangeTrackingHandlerBuilder","FreezePrimitiveValueHandler","FreezeObjectHandler","FreezeArrayHandler","FreezeHandlerBuilder","SerializeDateHandler","dateExpr","dateExprNested","SerializeObjectHandler","childPath","SerializeValueHandler","SerializeSerializerHandler","SerializeFunctionHandler","SerializeComputedHandler","SerializeArrayHandler","SerializeHandlerBuilder","registry","getChannelKey","schemaId","scope","getChannelRegistry","channel","SchemaChannel","channelKey","SchemaChannelSender","SchemaChannelReceiver","unreference","maybeUnref","BroadcastChannel","changes","stampedChanges","subscription","id","listener","SubscriptionListener","SchemaSubscription","signal","regisry","preprocessedChanges","callback","data","timestamp","postProcessedChanges","Symbol","CompareIdsKeyHandler","CompareIdsHandlerBuilder","s","createPrimitiveConverter","jsonType","_context","jsonSchema","dateConverter","_property","objectConverter","context","required","childSchema","convertArrayItems","innerSchema","innerType","schemaBase","tempProperty","itemSchema","vectorConverter","arrayConverter","computedConverter","routierMeta","defaultConverter","converterRegistry","Map","applyNullable","target","applyRoutierMetadata","propertyInfoToJsonSchema","visited","useOutputType","converter","compiledSchemaToJsonSchema","compiledSchema","propertySchema","createStandardJsonSchemaProps","rehydrateSchemaFromJsonString","jsonString","collectionName","rehydrateSchemaFromJsonSchema","SyntaxError","finalCollectionName","schemaDefinition","computedProperties","idProperties","propName","propSchema","isRequired","routierPropMeta","routierPropName","schemaBuilder","convertJsonSchemaPropertyToRoutier","isKey","computedDefs","computedProp","recreatedFn","functionSource","arrowMatch","paramsStr","functionBody","t","objectProps","objectSchema","itemsSchema","extractTypeInfo","allowedTypes","SetComplexHandler","SetHandlerBuilder","assertPropertyHandled","generatorName","createChangeTracker","DIRTY_ENTITY_MARKER","CHANGES_ENTITY_KEY","ORIGINAL_ENTITY_KEY","PAUSED_ENTITY_KEY","TRACKING_KEY","PROXY_MARKER","proxyHandler","indexableEntity","originalValue","resolvedParent","Reflect","resolvedPath","isDirty","receiver","Proxy","SchemaDefinition","fnArgs","b","explore","instanceObj","propertyInstance","previousParent","propertyInfo","childPrimitivePropertyInfo","recursiveCallback","metadata","propertyMap","enrichmentHandlerBuilder","mergeHandlerFactory","prepareHandlerBuilder","stripHandlerBuilder","cloneHandlerBuilder","compareHandlerBuilder","deserializeHandlerBuilder","hashTypeHandlerBuilder","idSelectorHandlerBuilder","hashHandlerBuilder","enableChangeTrackingHandlerBuilder","freezeHandlerBuilder","serializeHandlerBuilder","compareIdsHandlerBuilder","setHandlerBuilder","enricher","merge","prepare","strip","clone","deserialize","hashTypeHandler","idSelectorHandler","hashHandler","enableChangeTrackingHandler","freezeHandler","serializeHandler","compareIdsHandler","setHandlerHanlder","changeTrackingCodeBuilder","freezeCodeBuilder","enricherCodeBuilder","enricherFunctionRoot","enricherFunctionBody","preprocessCodeBuilder","postprocessCodeBuilder","setCodeBuilder","mergeCodeBuilder","mergeFunctionRoot","mergeFunctionBody","pauseFunctionBody","unpauseFunctionBody","prepareCodeBuilder","stripCodeBuilder","cloneCodeBuilder","compareCodeBuilder","compareIdsCodeBuilder","deserializeCodeBuilder","serializeCodeBuilder","idSelectorCodeBuilder","hashTypeCodeBuilder","hashCodeBuilder","hashCodeBuilderIfBlock","allPropertyNamesAndPaths","hashType","hasIdentities","hasIdentityKeys","enrichParams","mergeParams","enrichGenerator","mergeGenerator","postProcessGenerator","postProcessParams","getIdsFunction","getHashTypeFunction","prepareFunction","cloneFunction","storageCloneFunction","cloneStorageFunction","storageCloneCodeBuilder","isDeclared","skipDeclared","storageClone","deserializeFunction","serializeFunction","compareFunction","stripFunction","hashFunction","enableChangeTrackingFunction","freezeFunction","compareIdsFunction","preprocessFunction","setFunction","enricherFactoryFunction","postProcessFactoryFunction","mergeFactoryFunction","postProcessFunction","enricherFunction","mergeFunction","idPropertyNames","getId","getProperty","deserializePartial","deserialized","j","l","indexName","connections","indexedProperties","compiledSchemaWithMetadata","SchemaNumber","SchemaObject","SchemaFile","SchemaString","SchemaVector","dimensions","string","optionsOrLiteral","rest"],"mappings":";;;;;;;;;AAAoC;AAS7B,MAAeC;IACT,KAAa;IACZ,SAAiB,EAAE,CAAC;IACpB,UAAkB,GAAG;IACrB,QAAgB;IAE1B,YAAYC,IAAa,EAAEC,eAAuB,EAAE,EAAEC,MAAc,CAAE;QAClE,IAAI,CAAC,IAAI,GAAGF,QAAQ,OAAOA,OAAOF,4CAAIA;QACtC,IAAI,CAAC,OAAO,GAAGG;QACf,IAAI,CAAC,OAAO,GAAGC;IACnB;IAEA,QAAQF,IAAY,EAAE;QAClB,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAACG,CAAAA,IAAK,OAAOA,MAAM,YAAYA,EAAE,IAAI,KAAKH;IAC1E;IAEA,WAAW;QACP,OAAO,IAAI,CAAC,MAAM;IACtB;IAEA,YAAY;QACR,OAAO,IAAI,CAAC,OAAO;IACvB;IAEA,YAAY;QACR,OAAO,IAAI,CAAC,OAAO;IACvB;IAEA,SAASI,KAAa,EAAE;QACpB,IAAI,CAAC,MAAM,GAAGA;IAClB;IAEA,UAAUC,KAAY,EAAE;QACpB,IAAI,CAAC,OAAO,GAAGA;IACnB;IAEA,UAAUC,MAAc,EAAE;QACtB,IAAI,CAAC,OAAO,GAAGA;IACnB;IAEA,aAA8BN,IAAY,EAAiB;QAEvD,IAAIA,KAAK,QAAQ,CAAC,SAAS,OAAO;YAC9B,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAACG,CAAAA,IAAK,OAAOA,MAAM,YAAYA,EAAE,IAAI,KAAKH;QACrE;QAEA,MAAMO,QAAQP,KAAK,KAAK,CAAC;QACzB,yCAAyC;QACzC,IAAIQ,SAAgB,IAAI;QAExB,KAAK,MAAMC,QAAQF,MAAO;YACtB,MAAMG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