@prisma/orm-family-sql 8.0.0-rc.22-dev.8 → 8.0.0-rc.22-dev.10

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 (47) hide show
  1. package/dist/{canonicalization-hooks-Ce1v_TDl.mjs → canonicalization-hooks-BeJHD713.mjs} +18 -1
  2. package/dist/canonicalization-hooks-BeJHD713.mjs.map +1 -0
  3. package/dist/{check-expressions-DuWjvG4h.d.mts → check-expressions-Bh5KC2X5.d.mts} +8 -2
  4. package/dist/{check-expressions-DuWjvG4h.d.mts.map → check-expressions-Bh5KC2X5.d.mts.map} +1 -1
  5. package/dist/{check-expressions-BDsLvzqN.mjs → check-expressions-Mmzgx0XE.mjs} +4 -3
  6. package/dist/check-expressions-Mmzgx0XE.mjs.map +1 -0
  7. package/dist/{config-types-BCXwEBZH.mjs → config-types-YRGsoUT7.mjs} +2 -2
  8. package/dist/{config-types-BCXwEBZH.mjs.map → config-types-YRGsoUT7.mjs.map} +1 -1
  9. package/dist/{contract-builder-Y2rB4xMf.mjs → contract-builder-BwPOolrg.mjs} +2 -2
  10. package/dist/{contract-builder-Y2rB4xMf.mjs.map → contract-builder-BwPOolrg.mjs.map} +1 -1
  11. package/dist/contract-prisma7__provider.mjs +4 -4
  12. package/dist/contract-psl.mjs +1 -1
  13. package/dist/contract-psl__attribute-specs.mjs +1 -1
  14. package/dist/contract-psl__provider.mjs +2 -2
  15. package/dist/contract-ts.mjs +3 -3
  16. package/dist/contract-ts__config-types.mjs +1 -1
  17. package/dist/contract-ts__contract-builder.mjs +2 -2
  18. package/dist/contract.d.mts +2 -2
  19. package/dist/contract.mjs +3 -3
  20. package/dist/contract__canonicalization-hooks.mjs +1 -1
  21. package/dist/contract__check-expressions.d.mts +2 -2
  22. package/dist/contract__check-expressions.mjs +2 -2
  23. package/dist/{control-CdumaQYh.d.mts → control-CyJM0mMS.d.mts} +372 -26
  24. package/dist/control-CyJM0mMS.d.mts.map +1 -0
  25. package/dist/{control-BSX7UWk2.mjs → control-Ltpja41u.mjs} +1159 -59
  26. package/dist/control-Ltpja41u.mjs.map +1 -0
  27. package/dist/{derived-checks-D__agoFB-Boa1MHcA.mjs → derived-checks-D__agoFB-DxuPwZ7v.mjs} +3 -3
  28. package/dist/{derived-checks-D__agoFB-Boa1MHcA.mjs.map → derived-checks-D__agoFB-DxuPwZ7v.mjs.map} +1 -1
  29. package/dist/family.d.mts +2 -2
  30. package/dist/family.mjs +4 -4
  31. package/dist/family__control.d.mts +2 -2
  32. package/dist/family__control.mjs +2 -2
  33. package/dist/family__ir.mjs +1 -1
  34. package/dist/family__pack.mjs +2 -2
  35. package/dist/{generator-functions-Hy4pDDr9-HEQuSSaK.mjs → generator-functions-Hy4pDDr9-DlmTbI_c.mjs} +2 -2
  36. package/dist/{generator-functions-Hy4pDDr9-HEQuSSaK.mjs.map → generator-functions-Hy4pDDr9-DlmTbI_c.mjs.map} +1 -1
  37. package/dist/{interpreter-Ct1zWXKw-CRkWwRAw.mjs → interpreter-Ct1zWXKw-CLQnlWhR.mjs} +4 -4
  38. package/dist/{interpreter-Ct1zWXKw-CRkWwRAw.mjs.map → interpreter-Ct1zWXKw-CLQnlWhR.mjs.map} +1 -1
  39. package/dist/{psl-field-resolution-BnusQmZy-CX0b0mPk.mjs → psl-field-resolution-BnusQmZy-_QYc6Ywf.mjs} +2 -2
  40. package/dist/{psl-field-resolution-BnusQmZy-CX0b0mPk.mjs.map → psl-field-resolution-BnusQmZy-_QYc6Ywf.mjs.map} +1 -1
  41. package/dist/{sql-contract-serializer-sMY3prTx-CBHrlt9O.mjs → sql-contract-serializer-sMY3prTx-BfYfhVR_.mjs} +2 -2
  42. package/dist/{sql-contract-serializer-sMY3prTx-CBHrlt9O.mjs.map → sql-contract-serializer-sMY3prTx-BfYfhVR_.mjs.map} +1 -1
  43. package/package.json +18 -18
  44. package/dist/canonicalization-hooks-Ce1v_TDl.mjs.map +0 -1
  45. package/dist/check-expressions-BDsLvzqN.mjs.map +0 -1
  46. package/dist/control-BSX7UWk2.mjs.map +0 -1
  47. package/dist/control-CdumaQYh.d.mts.map +0 -1
@@ -1,4 +1,4 @@
1
- import { t as sqlContractCanonicalizationHooks } from "./canonicalization-hooks-Ce1v_TDl.mjs";
1
+ import { t as sqlContractCanonicalizationHooks } from "./canonicalization-hooks-BeJHD713.mjs";
2
2
  import { f as composeSqlEntityKinds } from "./entity-kinds-CgEwK0hH-D1NKoKE5.mjs";
3
3
  import { c as isMaterializedSqlNamespace, o as SqlStorage } from "./types-CISwoRED.mjs";
4
4
  import { f as validateSqlContractFully, i as createSqlContractSchema, s as resolveSqlToOneRelationStorage } from "./validators-qcQteqs2.mjs";
@@ -193,4 +193,4 @@ var SqlContractSerializer = class extends SqlContractSerializerBase {
193
193
  //#endregion
194
194
  export { SqlContractSerializerBase as n, SqlContractSerializer as t };
195
195
 
196
- //# sourceMappingURL=sql-contract-serializer-sMY3prTx-CBHrlt9O.mjs.map
196
+ //# sourceMappingURL=sql-contract-serializer-sMY3prTx-BfYfhVR_.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"sql-contract-serializer-sMY3prTx-CBHrlt9O.mjs","names":[],"sources":["../../../../2-sql-family/9-family/dist/sql-contract-serializer-sMY3prTx.mjs"],"sourcesContent":["import { t as sqlFamilyError } from \"./errors-B5g0xWro.mjs\";\nimport { hydrateNamespaceEntities } from \"@internal/framework-components/ir\";\nimport { sqlContractCanonicalizationHooks } from \"@internal/sql-contract/canonicalization-hooks\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { ContractValidationError } from \"@internal/contract/contract-validation-error\";\nimport { SqlStorage, isMaterializedSqlNamespace } from \"@internal/sql-contract/types\";\nimport { createSqlContractSchema, resolveSqlToOneRelationStorage, validateSqlContractFully } from \"@internal/sql-contract/validators\";\nimport { isPlainRecord as isPlainRecord$1 } from \"@internal/contract/is-plain-record\";\nimport { withDerivedToOneRelationNullability } from \"@internal/contract-authoring\";\nimport { composeSqlEntityKinds } from \"@internal/sql-contract/entity-kinds\";\nimport { type } from \"arktype\";\n//#region src/core/ir/sql-contract-serializer-base.ts\nconst NamespaceRawSchema = type({\n\tid: \"string\",\n\t\"kind?\": \"string\",\n\tentries: type({ \"+\": \"ignore\" })\n});\n/**\n* A `contract.json` written before to-one relations recorded `nullable` (rc.9 and earlier)\n* loads with the flag derived from storage: nullable when any local FK column is nullable or\n* cannot be resolved.\n*/\nfunction withSqlToOneRelationNullability(contract) {\n\tconst domain = withDerivedToOneRelationNullability(contract.domain, ({ model, relation }) => {\n\t\tconst { ownsForeignKey, columns } = resolveSqlToOneRelationStorage(contract, blindCast(model.storage), relation);\n\t\treturn {\n\t\t\townsReference: ownsForeignKey,\n\t\t\tlocalFieldNullability: columns.map((column) => column.nullable)\n\t\t};\n\t});\n\treturn {\n\t\t...contract,\n\t\tdomain\n\t};\n}\n/**\n* SQL family `ContractSerializer` abstract base. Carries the SQL-shared\n* deserialization pipeline:\n*\n* 1. `parseSqlContractStructure` validates the on-disk JSON envelope\n* against the SQL contract arktype schema (`validateSqlContractFully`)\n* and returns the validated flat-data shape.\n* 2. `hydrateSqlStorage` walks the validated `storage` subtree and\n* constructs the family-shared SQL Contract IR class hierarchy\n* (`SqlStorage` -> `StorageTable` -> `StorageColumn` / `PrimaryKey`\n* / …). The rest of the contract envelope is JSON-clean primitive\n* data and passes through unchanged.\n* 3. `constructTargetContract` is the target-specific extension hook;\n* defaults to identity. Targets that need to attach target-only\n* fields (e.g. target-specific derived storage fields) override it.\n*\n* Default `serializeContract` is identity over the contract — concrete\n* SQL targets ship JSON-clean class instances, so the contract value\n* can be stringified directly. The non-enumerable family-level `kind`\n* discriminator on `SqlNode` instances stays out of the persisted\n* envelope automatically. Targets that need to canonicalize on the way\n* out (key ordering, dropping computed-only fields) override\n* `serializeContract` directly.\n*/\nvar SqlContractSerializerBase = class {\n\tentityHydrationRegistry;\n\tdataTypes;\n\tcontractSchema;\n\tentryKinds;\n\tconstructor(entityHydrationRegistry = /* @__PURE__ */ new Map(), packEntityKinds = [], dataTypes = void 0) {\n\t\tthis.entityHydrationRegistry = entityHydrationRegistry;\n\t\tthis.dataTypes = dataTypes;\n\t\tthis.entryKinds = composeSqlEntityKinds(packEntityKinds);\n\t\tthis.contractSchema = packEntityKinds.length > 0 ? createSqlContractSchema(this.entryKinds) : void 0;\n\t}\n\tdeserializeContract(json) {\n\t\tconst validated = withSqlToOneRelationNullability(this.parseSqlContractStructure(json));\n\t\tconst hydrated = this.hydrateSqlStorage(validated);\n\t\treturn blindCast(this.constructTargetContract(hydrated));\n\t}\n\tserializeContract(contract) {\n\t\treturn blindCast(contract);\n\t}\n\tshouldPreserveEmpty = sqlContractCanonicalizationHooks.shouldPreserveEmpty;\n\tsortStorage = sqlContractCanonicalizationHooks.sortStorage;\n\thashCanonicalizationHooks = sqlContractCanonicalizationHooks;\n\tparseSqlContractStructure(json) {\n\t\treturn validateSqlContractFully(json, {\n\t\t\t...ifDefined(\"contractSchema\", this.contractSchema),\n\t\t\t...ifDefined(\"dataTypes\", this.dataTypes)\n\t\t});\n\t}\n\thydrateSqlStorage(validated) {\n\t\tconst types = validated.storage.types;\n\t\tconst hydratedTypes = types !== void 0 ? Object.fromEntries(Object.entries(types).map(([name, entry]) => [name, this.hydrateStorageTypeEntry(entry)])) : void 0;\n\t\tconst rawNamespaces = validated.storage.namespaces;\n\t\tif (rawNamespaces === void 0) throw new ContractValidationError(\"Contract storage.namespaces is required after structural validation\", \"structural\");\n\t\tconst hydratedNamespaces = this.hydrateSqlNamespaceMap(blindCast(rawNamespaces));\n\t\treturn {\n\t\t\t...validated,\n\t\t\tstorage: new SqlStorage({\n\t\t\t\tstorageHash: validated.storage.storageHash,\n\t\t\t\t...ifDefined(\"types\", hydratedTypes),\n\t\t\t\tnamespaces: blindCast(hydratedNamespaces)\n\t\t\t})\n\t\t};\n\t}\n\thydrateSqlNamespaceMap(namespaces) {\n\t\treturn Object.fromEntries(Object.entries(namespaces).map(([nsId, namespaceEntryRaw]) => {\n\t\t\tconst namespaceHydrated = this.hydrateSqlNamespaceEntry(nsId, namespaceEntryRaw);\n\t\t\tif (!isMaterializedSqlNamespace(namespaceHydrated)) throw sqlFamilyError(\"CONTRACT.PACK_CONTRIBUTION_INVALID\", `Target serializer bug: hydrateSqlNamespaceEntry for namespace \"${nsId}\" returned a non-NamespaceBase value. Override hydrateSqlNamespaceEntry to produce a target namespace concretion.`, {\n\t\t\t\twhy: \"The target contract serializer hydrated a namespace into a value that is not a materialized namespace concretion.\",\n\t\t\t\tfix: \"Fix the target package: its hydrateSqlNamespaceEntry override must return a target namespace concretion.\",\n\t\t\t\tmeta: { namespaceId: nsId }\n\t\t\t});\n\t\t\treturn [nsId, namespaceHydrated];\n\t\t}));\n\t}\n\thydrateSqlNamespaceEntry(nsId, raw) {\n\t\tconst id = typeof raw[\"id\"] === \"string\" ? raw[\"id\"] : nsId;\n\t\tconst parsed = NamespaceRawSchema({\n\t\t\t...raw,\n\t\t\tid\n\t\t});\n\t\tif (parsed instanceof type.errors) throw new ContractValidationError(`Namespace hydration failed: ${parsed.map((p) => p.message).join(\"; \")}`, \"structural\");\n\t\tconst entriesRaw = parsed.entries;\n\t\tconst rawEntriesMap = isPlainRecord$1(entriesRaw) ? entriesRaw : {};\n\t\tconst entriesInput = {};\n\t\tfor (const [key, innerMap] of Object.entries(rawEntriesMap)) entriesInput[key] = isPlainRecord$1(innerMap) ? innerMap : Object.freeze({});\n\t\tconst entriesOutput = hydrateNamespaceEntities(entriesInput, this.entryKinds, \"fail\", id);\n\t\tif (!Object.hasOwn(entriesOutput, \"table\")) entriesOutput[\"table\"] = {};\n\t\treturn blindCast({\n\t\t\tid,\n\t\t\tentries: entriesOutput\n\t\t});\n\t}\n\thydrateStorageTypeEntry(entry) {\n\t\tif (typeof entry !== \"object\" || entry === null) return entry;\n\t\tconst kind = isPlainRecord$1(entry) && \"kind\" in entry ? entry.kind : void 0;\n\t\tif (typeof kind !== \"string\") return entry;\n\t\tconst factory = this.entityHydrationRegistry.get(kind);\n\t\tif (factory === void 0) return entry;\n\t\treturn blindCast(factory(entry));\n\t}\n\tconstructTargetContract(hydrated) {\n\t\treturn blindCast(hydrated);\n\t}\n\t/**\n\t* Serializes a namespace's `entries` dict by walking every enumerable\n\t* kind — no kind is named here, mirroring the generic hydrate walk in\n\t* `hydrateSqlNamespaceEntry` above. `table` is the SQL family's one\n\t* universal base kind (every namespace carries it), so it is always\n\t* emitted, even when empty; every other kind — target- or\n\t* pack-contributed — is emitted only when it holds at least one entry.\n\t* A kind carried non-enumerable on `entries` is excluded here for free,\n\t* since `Object.entries` honors enumerability.\n\t*/\n\tserializeNamespaceEntries(entries) {\n\t\tconst out = { table: this.serializeEntries(entries[\"table\"] ?? {}) };\n\t\tfor (const [kind, record] of Object.entries(entries)) {\n\t\t\tif (kind === \"table\" || record == null || Object.keys(record).length === 0) continue;\n\t\t\tout[kind] = this.serializeEntries(record);\n\t\t}\n\t\treturn out;\n\t}\n\tserializeEntries(entries) {\n\t\tconst out = {};\n\t\tfor (const [name, entry] of Object.entries(entries)) out[name] = this.serializeJsonObject(entry);\n\t\treturn out;\n\t}\n\tserializeJsonObject(value) {\n\t\treturn blindCast(this.serializeJsonValue(value));\n\t}\n\tserializeJsonValue(value) {\n\t\treturn blindCast(JSON.parse(JSON.stringify(value)));\n\t}\n};\n//#endregion\n//#region src/core/ir/sql-contract-serializer.ts\n/**\n* Default SQL family `ContractSerializer` concretion. Inherits the\n* full SQL-shared deserialization pipeline (structural validation +\n* IR-class hydration) without pack-registered `storage.types`\n* hydration factories — targets that emit polymorphic JSON outside the\n* codec-typed envelope wire a target-specific subclass with a populated\n* registry (see Postgres). Family-level call sites instantiate this\n* default directly when no target serializer is supplied.\n*\n* Because this serializer has no target concretion, deserialization of\n* contracts that include namespace entries from JSON will throw unless\n* the caller provides pre-hydrated `NamespaceBase` instances. Production\n* paths always supply a target-specific serializer.\n*/\nvar SqlContractSerializer = class extends SqlContractSerializerBase {\n\tconstructor() {\n\t\tsuper(/* @__PURE__ */ new Map());\n\t}\n};\n//#endregion\nexport { SqlContractSerializerBase as n, SqlContractSerializer as t };\n\n//# sourceMappingURL=sql-contract-serializer-sMY3prTx.mjs.map"],"mappings":";;;;;;;;;;;;;AAaA,MAAM,qBAAqB,KAAK;CAC/B,IAAI;CACJ,SAAS;CACT,SAAS,KAAK,EAAE,KAAK,SAAS,CAAC;AAChC,CAAC;;;;;;AAMD,SAAS,gCAAgC,UAAU;CAClD,MAAM,SAAS,oCAAoC,SAAS,SAAS,EAAE,OAAO,eAAe;EAC5F,MAAM,EAAE,gBAAgB,YAAY,+BAA+B,UAAU,UAAU,MAAM,OAAO,GAAG,QAAQ;EAC/G,OAAO;GACN,eAAe;GACf,uBAAuB,QAAQ,KAAK,WAAW,OAAO,QAAQ;EAC/D;CACD,CAAC;CACD,OAAO;EACN,GAAG;EACH;CACD;AACD;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,IAAI,4BAA4B,MAAM;CACrC;CACA;CACA;CACA;CACA,YAAY,0CAA0C,IAAI,IAAI,GAAG,kBAAkB,CAAC,GAAG,YAAY,KAAK,GAAG;EAC1G,KAAK,0BAA0B;EAC/B,KAAK,YAAY;EACjB,KAAK,aAAa,sBAAsB,eAAe;EACvD,KAAK,iBAAiB,gBAAgB,SAAS,IAAI,wBAAwB,KAAK,UAAU,IAAI,KAAK;CACpG;CACA,oBAAoB,MAAM;EACzB,MAAM,YAAY,gCAAgC,KAAK,0BAA0B,IAAI,CAAC;EACtF,MAAM,WAAW,KAAK,kBAAkB,SAAS;EACjD,OAAO,UAAU,KAAK,wBAAwB,QAAQ,CAAC;CACxD;CACA,kBAAkB,UAAU;EAC3B,OAAO,UAAU,QAAQ;CAC1B;CACA,sBAAsB,iCAAiC;CACvD,cAAc,iCAAiC;CAC/C,4BAA4B;CAC5B,0BAA0B,MAAM;EAC/B,OAAO,yBAAyB,MAAM;GACrC,GAAG,UAAU,kBA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1B,OAAO,UAAU,KAAK,mBAAmB,KAAK,CAAC;CAChD;CACA,mBAAmB,OAAO;EACzB,OAAO,UAAU,KAAK,MAAM,KAAK,UAAU,KAAK,CAAC,CAAC;CACnD;AACD;;;;;;;;;;;;;;;AAiBA,IAAI,wBAAwB,cAAc,0BAA0B;CACnE,cAAc;EACb,sBAAsB,IAAI,IAAI,CAAC;CAChC;AACD"}
1
+ {"version":3,"file":"sql-contract-serializer-sMY3prTx-BfYfhVR_.mjs","names":[],"sources":["../../../../2-sql-family/9-family/dist/sql-contract-serializer-sMY3prTx.mjs"],"sourcesContent":["import { t as sqlFamilyError } from \"./errors-B5g0xWro.mjs\";\nimport { hydrateNamespaceEntities } from \"@internal/framework-components/ir\";\nimport { sqlContractCanonicalizationHooks } from \"@internal/sql-contract/canonicalization-hooks\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { ContractValidationError } from \"@internal/contract/contract-validation-error\";\nimport { SqlStorage, isMaterializedSqlNamespace } from \"@internal/sql-contract/types\";\nimport { createSqlContractSchema, resolveSqlToOneRelationStorage, validateSqlContractFully } from \"@internal/sql-contract/validators\";\nimport { isPlainRecord as isPlainRecord$1 } from \"@internal/contract/is-plain-record\";\nimport { withDerivedToOneRelationNullability } from \"@internal/contract-authoring\";\nimport { composeSqlEntityKinds } from \"@internal/sql-contract/entity-kinds\";\nimport { type } from \"arktype\";\n//#region src/core/ir/sql-contract-serializer-base.ts\nconst NamespaceRawSchema = type({\n\tid: \"string\",\n\t\"kind?\": \"string\",\n\tentries: type({ \"+\": \"ignore\" })\n});\n/**\n* A `contract.json` written before to-one relations recorded `nullable` (rc.9 and earlier)\n* loads with the flag derived from storage: nullable when any local FK column is nullable or\n* cannot be resolved.\n*/\nfunction withSqlToOneRelationNullability(contract) {\n\tconst domain = withDerivedToOneRelationNullability(contract.domain, ({ model, relation }) => {\n\t\tconst { ownsForeignKey, columns } = resolveSqlToOneRelationStorage(contract, blindCast(model.storage), relation);\n\t\treturn {\n\t\t\townsReference: ownsForeignKey,\n\t\t\tlocalFieldNullability: columns.map((column) => column.nullable)\n\t\t};\n\t});\n\treturn {\n\t\t...contract,\n\t\tdomain\n\t};\n}\n/**\n* SQL family `ContractSerializer` abstract base. Carries the SQL-shared\n* deserialization pipeline:\n*\n* 1. `parseSqlContractStructure` validates the on-disk JSON envelope\n* against the SQL contract arktype schema (`validateSqlContractFully`)\n* and returns the validated flat-data shape.\n* 2. `hydrateSqlStorage` walks the validated `storage` subtree and\n* constructs the family-shared SQL Contract IR class hierarchy\n* (`SqlStorage` -> `StorageTable` -> `StorageColumn` / `PrimaryKey`\n* / …). The rest of the contract envelope is JSON-clean primitive\n* data and passes through unchanged.\n* 3. `constructTargetContract` is the target-specific extension hook;\n* defaults to identity. Targets that need to attach target-only\n* fields (e.g. target-specific derived storage fields) override it.\n*\n* Default `serializeContract` is identity over the contract — concrete\n* SQL targets ship JSON-clean class instances, so the contract value\n* can be stringified directly. The non-enumerable family-level `kind`\n* discriminator on `SqlNode` instances stays out of the persisted\n* envelope automatically. Targets that need to canonicalize on the way\n* out (key ordering, dropping computed-only fields) override\n* `serializeContract` directly.\n*/\nvar SqlContractSerializerBase = class {\n\tentityHydrationRegistry;\n\tdataTypes;\n\tcontractSchema;\n\tentryKinds;\n\tconstructor(entityHydrationRegistry = /* @__PURE__ */ new Map(), packEntityKinds = [], dataTypes = void 0) {\n\t\tthis.entityHydrationRegistry = entityHydrationRegistry;\n\t\tthis.dataTypes = dataTypes;\n\t\tthis.entryKinds = composeSqlEntityKinds(packEntityKinds);\n\t\tthis.contractSchema = packEntityKinds.length > 0 ? createSqlContractSchema(this.entryKinds) : void 0;\n\t}\n\tdeserializeContract(json) {\n\t\tconst validated = withSqlToOneRelationNullability(this.parseSqlContractStructure(json));\n\t\tconst hydrated = this.hydrateSqlStorage(validated);\n\t\treturn blindCast(this.constructTargetContract(hydrated));\n\t}\n\tserializeContract(contract) {\n\t\treturn blindCast(contract);\n\t}\n\tshouldPreserveEmpty = sqlContractCanonicalizationHooks.shouldPreserveEmpty;\n\tsortStorage = sqlContractCanonicalizationHooks.sortStorage;\n\thashCanonicalizationHooks = sqlContractCanonicalizationHooks;\n\tparseSqlContractStructure(json) {\n\t\treturn validateSqlContractFully(json, {\n\t\t\t...ifDefined(\"contractSchema\", this.contractSchema),\n\t\t\t...ifDefined(\"dataTypes\", this.dataTypes)\n\t\t});\n\t}\n\thydrateSqlStorage(validated) {\n\t\tconst types = validated.storage.types;\n\t\tconst hydratedTypes = types !== void 0 ? Object.fromEntries(Object.entries(types).map(([name, entry]) => [name, this.hydrateStorageTypeEntry(entry)])) : void 0;\n\t\tconst rawNamespaces = validated.storage.namespaces;\n\t\tif (rawNamespaces === void 0) throw new ContractValidationError(\"Contract storage.namespaces is required after structural validation\", \"structural\");\n\t\tconst hydratedNamespaces = this.hydrateSqlNamespaceMap(blindCast(rawNamespaces));\n\t\treturn {\n\t\t\t...validated,\n\t\t\tstorage: new SqlStorage({\n\t\t\t\tstorageHash: validated.storage.storageHash,\n\t\t\t\t...ifDefined(\"types\", hydratedTypes),\n\t\t\t\tnamespaces: blindCast(hydratedNamespaces)\n\t\t\t})\n\t\t};\n\t}\n\thydrateSqlNamespaceMap(namespaces) {\n\t\treturn Object.fromEntries(Object.entries(namespaces).map(([nsId, namespaceEntryRaw]) => {\n\t\t\tconst namespaceHydrated = this.hydrateSqlNamespaceEntry(nsId, namespaceEntryRaw);\n\t\t\tif (!isMaterializedSqlNamespace(namespaceHydrated)) throw sqlFamilyError(\"CONTRACT.PACK_CONTRIBUTION_INVALID\", `Target serializer bug: hydrateSqlNamespaceEntry for namespace \"${nsId}\" returned a non-NamespaceBase value. Override hydrateSqlNamespaceEntry to produce a target namespace concretion.`, {\n\t\t\t\twhy: \"The target contract serializer hydrated a namespace into a value that is not a materialized namespace concretion.\",\n\t\t\t\tfix: \"Fix the target package: its hydrateSqlNamespaceEntry override must return a target namespace concretion.\",\n\t\t\t\tmeta: { namespaceId: nsId }\n\t\t\t});\n\t\t\treturn [nsId, namespaceHydrated];\n\t\t}));\n\t}\n\thydrateSqlNamespaceEntry(nsId, raw) {\n\t\tconst id = typeof raw[\"id\"] === \"string\" ? raw[\"id\"] : nsId;\n\t\tconst parsed = NamespaceRawSchema({\n\t\t\t...raw,\n\t\t\tid\n\t\t});\n\t\tif (parsed instanceof type.errors) throw new ContractValidationError(`Namespace hydration failed: ${parsed.map((p) => p.message).join(\"; \")}`, \"structural\");\n\t\tconst entriesRaw = parsed.entries;\n\t\tconst rawEntriesMap = isPlainRecord$1(entriesRaw) ? entriesRaw : {};\n\t\tconst entriesInput = {};\n\t\tfor (const [key, innerMap] of Object.entries(rawEntriesMap)) entriesInput[key] = isPlainRecord$1(innerMap) ? innerMap : Object.freeze({});\n\t\tconst entriesOutput = hydrateNamespaceEntities(entriesInput, this.entryKinds, \"fail\", id);\n\t\tif (!Object.hasOwn(entriesOutput, \"table\")) entriesOutput[\"table\"] = {};\n\t\treturn blindCast({\n\t\t\tid,\n\t\t\tentries: entriesOutput\n\t\t});\n\t}\n\thydrateStorageTypeEntry(entry) {\n\t\tif (typeof entry !== \"object\" || entry === null) return entry;\n\t\tconst kind = isPlainRecord$1(entry) && \"kind\" in entry ? entry.kind : void 0;\n\t\tif (typeof kind !== \"string\") return entry;\n\t\tconst factory = this.entityHydrationRegistry.get(kind);\n\t\tif (factory === void 0) return entry;\n\t\treturn blindCast(factory(entry));\n\t}\n\tconstructTargetContract(hydrated) {\n\t\treturn blindCast(hydrated);\n\t}\n\t/**\n\t* Serializes a namespace's `entries` dict by walking every enumerable\n\t* kind — no kind is named here, mirroring the generic hydrate walk in\n\t* `hydrateSqlNamespaceEntry` above. `table` is the SQL family's one\n\t* universal base kind (every namespace carries it), so it is always\n\t* emitted, even when empty; every other kind — target- or\n\t* pack-contributed — is emitted only when it holds at least one entry.\n\t* A kind carried non-enumerable on `entries` is excluded here for free,\n\t* since `Object.entries` honors enumerability.\n\t*/\n\tserializeNamespaceEntries(entries) {\n\t\tconst out = { table: this.serializeEntries(entries[\"table\"] ?? {}) };\n\t\tfor (const [kind, record] of Object.entries(entries)) {\n\t\t\tif (kind === \"table\" || record == null || Object.keys(record).length === 0) continue;\n\t\t\tout[kind] = this.serializeEntries(record);\n\t\t}\n\t\treturn out;\n\t}\n\tserializeEntries(entries) {\n\t\tconst out = {};\n\t\tfor (const [name, entry] of Object.entries(entries)) out[name] = this.serializeJsonObject(entry);\n\t\treturn out;\n\t}\n\tserializeJsonObject(value) {\n\t\treturn blindCast(this.serializeJsonValue(value));\n\t}\n\tserializeJsonValue(value) {\n\t\treturn blindCast(JSON.parse(JSON.stringify(value)));\n\t}\n};\n//#endregion\n//#region src/core/ir/sql-contract-serializer.ts\n/**\n* Default SQL family `ContractSerializer` concretion. Inherits the\n* full SQL-shared deserialization pipeline (structural validation +\n* IR-class hydration) without pack-registered `storage.types`\n* hydration factories — targets that emit polymorphic JSON outside the\n* codec-typed envelope wire a target-specific subclass with a populated\n* registry (see Postgres). Family-level call sites instantiate this\n* default directly when no target serializer is supplied.\n*\n* Because this serializer has no target concretion, deserialization of\n* contracts that include namespace entries from JSON will throw unless\n* the caller provides pre-hydrated `NamespaceBase` instances. Production\n* paths always supply a target-specific serializer.\n*/\nvar SqlContractSerializer = class extends SqlContractSerializerBase {\n\tconstructor() {\n\t\tsuper(/* @__PURE__ */ new Map());\n\t}\n};\n//#endregion\nexport { SqlContractSerializerBase as n, SqlContractSerializer as t };\n\n//# sourceMappingURL=sql-contract-serializer-sMY3prTx.mjs.map"],"mappings":";;;;;;;;;;;;;AAaA,MAAM,qBAAqB,KAAK;CAC/B,IAAI;CACJ,SAAS;CACT,SAAS,KAAK,EAAE,KAAK,SAAS,CAAC;AAChC,CAAC;;;;;;AAMD,SAAS,gCAAgC,UAAU;CAClD,MAAM,SAAS,oCAAoC,SAAS,SAAS,EAAE,OAAO,eAAe;EAC5F,MAAM,EAAE,gBAAgB,YAAY,+BAA+B,UAAU,UA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AAU,YAAY,UAAU,MAAM,OAAO;EACxD,MAAM,OAAO,gBAAgB,KAAK,KAAK,UAAU,QAAQ,MAAM,OAAO,KAAK;EAC3E,IAAI,OAAO,SAAS,UAAU,OAAO;EACrC,MAAM,UAAU,KAAK,wBAAwB,IAAI,IAAI;EACrD,IAAI,YAAY,KAAK,GAAG,OAAO;EAC/B,OAAO,UAAU,QAAQ,KAAK,CAAC;CAChC;CACA,wBAAwB,UAAU;EACjC,OAAO,UAAU,QAAQ;CAC1B;;;;;;;;;;;CAWA,0BAA0B,SAAS;EAClC,MAAM,MAAM,EAAE,OAAO,KAAK,iBAAiB,QAAQ,YAAY,CAAC,CAAC,EAAE;EACnE,KAAK,MAAM,CAAC,MAAM,WAAW,OAAO,QAAQ,OAAO,GAAG;GACrD,IAAI,SAAS,WAAW,UAAU,QAAQ,OAAO,KAAK,MAAM,CAAC,CAAC,WAAW,GAAG;GAC5E,IAAI,QAAQ,KAAK,iBAAiB,MAAM;EACzC;EACA,OAAO;CACR;CACA,iBAAiB,SAAS;EACzB,MAAM,MAAM,CAAC;EACb,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAQ,OAAO,GAAG,IAAI,QAAQ,KAAK,oBAAoB,KAAK;EAC/F,OAAO;CACR;CACA,oBAAoB,OAAO;EAC1B,OAAO,UAAU,KAAK,mBAAmB,KAAK,CAAC;CAChD;CACA,mBAAmB,OAAO;EACzB,OAAO,UAAU,KAAK,MAAM,KAAK,UAAU,KAAK,CAAC,CAAC;CACnD;AACD;;;;;;;;;;;;;;;AAiBA,IAAI,wBAAwB,cAAc,0BAA0B;CACnE,cAAc;EACb,sBAAsB,IAAI,IAAI,CAAC;CAChC;AACD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prisma/orm-family-sql",
3
- "version": "8.0.0-rc.22-dev.8",
3
+ "version": "8.0.0-rc.22-dev.10",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -9,8 +9,8 @@
9
9
  "dist"
10
10
  ],
11
11
  "dependencies": {
12
- "@prisma/orm-framework": "8.0.0-rc.22-dev.8",
13
- "@prisma/orm-toolchain": "8.0.0-rc.22-dev.8",
12
+ "@prisma/orm-framework": "8.0.0-rc.22-dev.10",
13
+ "@prisma/orm-toolchain": "8.0.0-rc.22-dev.10",
14
14
  "@standard-schema/spec": "^1.1.0",
15
15
  "arktype": "^2.2.2",
16
16
  "pathe": "^2.0.3",
@@ -19,21 +19,21 @@
19
19
  "ts-toolbelt": "^9.6.0"
20
20
  },
21
21
  "devDependencies": {
22
- "@internal/family-sql": "8.0.0-rc.22-dev.8",
23
- "@internal/sql-builder": "8.0.0-rc.22-dev.8",
24
- "@internal/sql-contract": "8.0.0-rc.22-dev.8",
25
- "@internal/sql-contract-emitter": "8.0.0-rc.22-dev.8",
26
- "@internal/sql-contract-prisma7": "8.0.0-rc.22-dev.8",
27
- "@internal/sql-contract-psl": "8.0.0-rc.22-dev.8",
28
- "@internal/sql-contract-ts": "8.0.0-rc.22-dev.8",
29
- "@internal/sql-errors": "8.0.0-rc.22-dev.8",
30
- "@internal/sql-operations": "8.0.0-rc.22-dev.8",
31
- "@internal/sql-orm-client": "8.0.0-rc.22-dev.8",
32
- "@internal/sql-relational-core": "8.0.0-rc.22-dev.8",
33
- "@internal/sql-runtime": "8.0.0-rc.22-dev.8",
34
- "@internal/sql-schema-ir": "8.0.0-rc.22-dev.8",
35
- "@repo/tsconfig": "8.0.0-rc.22-dev.8",
36
- "@repo/tsdown": "8.0.0-rc.22-dev.8",
22
+ "@internal/family-sql": "8.0.0-rc.22-dev.10",
23
+ "@internal/sql-builder": "8.0.0-rc.22-dev.10",
24
+ "@internal/sql-contract": "8.0.0-rc.22-dev.10",
25
+ "@internal/sql-contract-emitter": "8.0.0-rc.22-dev.10",
26
+ "@internal/sql-contract-prisma7": "8.0.0-rc.22-dev.10",
27
+ "@internal/sql-contract-psl": "8.0.0-rc.22-dev.10",
28
+ "@internal/sql-contract-ts": "8.0.0-rc.22-dev.10",
29
+ "@internal/sql-errors": "8.0.0-rc.22-dev.10",
30
+ "@internal/sql-operations": "8.0.0-rc.22-dev.10",
31
+ "@internal/sql-orm-client": "8.0.0-rc.22-dev.10",
32
+ "@internal/sql-relational-core": "8.0.0-rc.22-dev.10",
33
+ "@internal/sql-runtime": "8.0.0-rc.22-dev.10",
34
+ "@internal/sql-schema-ir": "8.0.0-rc.22-dev.10",
35
+ "@repo/tsconfig": "8.0.0-rc.22-dev.10",
36
+ "@repo/tsdown": "8.0.0-rc.22-dev.10",
37
37
  "tsdown": "0.22.14",
38
38
  "typescript": "5.9.3"
39
39
  },
@@ -1 +0,0 @@
1
- {"version":3,"file":"canonicalization-hooks-Ce1v_TDl.mjs","names":[],"sources":["../../../../2-sql-family/1-core/contract/dist/canonicalization-hooks.mjs"],"sourcesContent":["import { createPreserveEmptyPredicate, createStorageSort, matchesPathPattern } from \"@internal/contract/hashing-utils\";\n//#region src/canonicalization-hooks.ts\nconst preserveEmptyPatterns = [\n\t[\n\t\t\"storage\",\n\t\t\"namespaces\",\n\t\t\"*\",\n\t\t\"entries\",\n\t\t\"table\"\n\t],\n\t[\n\t\t\"storage\",\n\t\t\"namespaces\",\n\t\t\"*\",\n\t\t\"entries\",\n\t\t\"table\",\n\t\t\"*\"\n\t],\n\t[\n\t\t\"storage\",\n\t\t\"namespaces\",\n\t\t\"*\",\n\t\t\"entries\",\n\t\t\"table\",\n\t\t\"*\",\n\t\t[\n\t\t\t\"uniques\",\n\t\t\t\"indexes\",\n\t\t\t\"foreignKeys\"\n\t\t]\n\t],\n\t[\n\t\t\"storage\",\n\t\t\"namespaces\",\n\t\t\"*\",\n\t\t\"entries\",\n\t\t\"table\",\n\t\t\"*\",\n\t\t\"indexes\",\n\t\t\"unique\"\n\t],\n\t[\n\t\t\"storage\",\n\t\t\"namespaces\",\n\t\t\"*\",\n\t\t\"entries\",\n\t\t\"table\",\n\t\t\"*\",\n\t\t\"columns\",\n\t\t\"*\",\n\t\t\"default\",\n\t\t\"value\"\n\t]\n];\nconst columnDefaultValuePrefix = [\n\t\"storage\",\n\t\"namespaces\",\n\t\"*\",\n\t\"entries\",\n\t\"table\",\n\t\"*\",\n\t\"columns\",\n\t\"*\",\n\t\"default\",\n\t\"value\"\n];\nconst isColumnDefaultValuePath = (path) => path.length >= columnDefaultValuePrefix.length && matchesPathPattern(path.slice(0, columnDefaultValuePrefix.length), columnDefaultValuePrefix);\nconst sortTargets = [{\n\tpath: [\n\t\t\"namespaces\",\n\t\t\"*\",\n\t\t\"entries\",\n\t\t\"table\",\n\t\t\"*\"\n\t],\n\tarrayKeys: [\n\t\t\"checks\",\n\t\t\"indexes\",\n\t\t\"uniques\"\n\t]\n}];\nconst matchesPreserveEmptyPattern = createPreserveEmptyPredicate(preserveEmptyPatterns);\nconst shouldPreserveEmpty = (path) => isColumnDefaultValuePath(path) || matchesPreserveEmptyPattern(path);\nconst sqlContractCanonicalizationHooks = {\n\tshouldPreserveEmpty,\n\tsortStorage: createStorageSort(sortTargets)\n};\n//#endregion\nexport { sqlContractCanonicalizationHooks };\n\n//# sourceMappingURL=canonicalization-hooks.mjs.map"],"mappings":";;AAEA,MAAM,wBAAwB;CAC7B;EACC;EACA;EACA;EACA;EACA;CACD;CACA;EACC;EACA;EACA;EACA;EACA;EACA;CACD;CACA;EACC;EACA;EACA;EACA;EACA;EACA;EACA;GACC;GACA;GACA;EACD;CACD;CACA;EACC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACD;CACA;EACC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACD;AACD;AACA,MAAM,2BAA2B;CAChC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD;AACA,MAAM,4BAA4B,SAAS,KAAK,UAAU,yBAAyB,UAAU,mBAAmB,KAAK,MAAM,GAAG,yBAAyB,MAAM,GAAG,wBAAwB;AACxL,MAAM,cAAc,CAAC;CACpB,MAAM;EACL;EACA;EACA;EACA;EACA;CACD;CACA,WAAW;EACV;EACA;EACA;CACD;AACD,CAAC;AACD,MAAM,8BAA8B,6BAA6B,qBAAqB;AACtF,MAAM,uBAAuB,SAAS,yBAAyB,IAAI,KAAK,4BAA4B,IAAI;AACxG,MAAM,mCAAmC;CACxC;CACA,aAAa,kBAAkB,WAAW;AAC3C"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"check-expressions-BDsLvzqN.mjs","names":[],"sources":["../../../../2-sql-family/1-core/contract/dist/check-expressions.mjs"],"sourcesContent":["import { t as contractError } from \"./contract-errors-BCN6RVI5.mjs\";\nimport { n as declaredJsonType } from \"./codec-json-type-DUWyBtJk.mjs\";\nimport { n as isStorageValueSet } from \"./storage-value-set-uGUEBAMJ.mjs\";\nimport { valueObjectAt } from \"@internal/contract/types\";\nimport { invariant } from \"@internal/utils/assertions\";\n//#region src/check-expressions.ts\n/**\n* What the check of a column that holds a value object reads. The contract build and `contract print` both derive it here, so print recognises exactly the check the build writes.\n*/\nfunction resolveColumnValueObject(storage, column, codecs) {\n\treturn {\n\t\tnullable: column.nullable,\n\t\tmany: column.many,\n\t\tvalueObject: resolveValueObject(storage, column.reference, codecs)\n\t};\n}\n/**\n* The value set a discriminator column names (ADR 309): keyed `<Base>.<field>`, and holding the variants' values sorted, so the order variants are declared in does not change the storage hash. The contract build writes it and `contract print` compares a contract's value set with it.\n*/\nfunction discriminatorValueSet(baseModelName, discriminatorField, variantValues) {\n\treturn {\n\t\tname: `${baseModelName}.${discriminatorField}`,\n\t\tvalues: [...variantValues].sort()\n\t};\n}\n/**\n* The value object a reference names, with nested value objects inlined, enum members' values read from their storage value sets, and each scalar member's JSON type read from its codec.\n*/\nfunction resolveValueObject(storage, reference, codecs) {\n\treturn resolveEntered(storage, reference, [referenceKey(reference)], codecs);\n}\nfunction resolveEntered(storage, reference, path, codecs) {\n\tconst valueObject = requiredValueObject(storage, reference);\n\treturn { fields: Object.fromEntries(Object.entries(valueObject.fields).map(([name, field]) => [name, {\n\t\tnullable: field.nullable,\n\t\tmany: field.many ?? false,\n\t\ttype: resolveFieldType(storage, {\n\t\t\treference,\n\t\t\tname,\n\t\t\tfield\n\t\t}, path, codecs)\n\t}])) };\n}\nfunction resolveFieldType(storage, member, path, codecs) {\n\tconst { field } = member;\n\tconst { type } = field;\n\tinvariant(type.kind !== \"union\" && field.dict !== true, \"a SQL value object member is never a union or a dictionary\");\n\tif (type.kind === \"scalar\") return {\n\t\tkind: \"scalar\",\n\t\tjsonType: memberJsonType(member, type.codecId, codecs),\n\t\tvalues: field.valueSet === void 0 ? void 0 : valueSetValues(storage, field.valueSet)\n\t};\n\tconst key = referenceKey(type);\n\tif (reachesAny(storage, type, new Set(path))) return { kind: \"anyObject\" };\n\treturn {\n\t\tkind: \"valueObject\",\n\t\tvalueObject: resolveEntered(storage, type, [...path, key], codecs)\n\t};\n}\nfunction memberJsonType(member, codecId, codecs) {\n\tconst descriptor = codecs.descriptorFor(codecId);\n\tinvariant(descriptor !== void 0, `value object member codec \"${codecId}\" is not a codec of the stack; the contract validators refuse a codec the stack does not register`);\n\tconst jsonType = declaredJsonType(descriptor);\n\tif (jsonType !== void 0) return jsonType;\n\tconst valueObject = `${member.reference.namespaceId}:${member.reference.entityName}`;\n\tthrow contractError(\"CONTRACT.CODEC_JSON_TYPE_MISSING\", `The codec \"${codecId}\" of value object \"${valueObject}\" member \"${member.name}\" declares no jsonType, so the check of the value object cannot be derived.`, {\n\t\twhy: \"The check of a value object column requires each member to be of the JSON type its codec declares, and this codec declares none.\",\n\t\tfix: `The author of the codec \"${codecId}\" adds a jsonType to its descriptor, the JSON type its value is written as inside a JSON document.`,\n\t\tmeta: {\n\t\t\tcodecId,\n\t\t\tvalueObject,\n\t\t\tmember: member.name,\n\t\t\tproperty: \"jsonType\"\n\t\t}\n\t});\n}\n/**\n* Whether `from` refers, through its own fields or nested ones, to a value object on the path being resolved. Each value object on the path refers to `from`, so this holds exactly when `from` is in a group of value objects that contain each other which the path has already entered.\n*/\nfunction reachesAny(storage, from, targets) {\n\tconst seen = /* @__PURE__ */ new Set();\n\tconst pending = [from];\n\tfor (let next = pending.pop(); next !== void 0; next = pending.pop()) {\n\t\tconst key = referenceKey(next);\n\t\tif (targets.has(key)) return true;\n\t\tif (seen.has(key)) continue;\n\t\tseen.add(key);\n\t\tfor (const field of Object.values(requiredValueObject(storage, next).fields)) if (field.type.kind === \"valueObject\") pending.push(field.type);\n\t}\n\treturn false;\n}\nfunction requiredValueObject(storage, reference) {\n\tconst valueObject = valueObjectAt(storage, reference);\n\tinvariant(valueObject !== void 0, `value object \"${reference.entityName}\" in namespace \"${reference.namespaceId}\" is not in storage; the contract validators refuse a reference to a missing value object`);\n\treturn valueObject;\n}\nfunction valueSetValues(storage, reference) {\n\tconst valueSet = Object.hasOwn(storage.namespaces, reference.namespaceId) ? storage.namespaces[reference.namespaceId]?.entries?.[\"valueSet\"]?.[reference.entityName] : void 0;\n\tinvariant(isStorageValueSet(valueSet), `value set \"${reference.entityName}\" in namespace \"${reference.namespaceId}\" is not in storage; the contract validators refuse a value object member whose value set is missing`);\n\treturn valueSet.values.filter((value) => typeof value === \"string\" || typeof value === \"number\");\n}\nfunction referenceKey(reference) {\n\treturn JSON.stringify([reference.namespaceId, reference.entityName]);\n}\n//#endregion\nexport { discriminatorValueSet, resolveColumnValueObject, resolveValueObject };\n\n//# sourceMappingURL=check-expressions.mjs.map"],"mappings":";;;;;;;;;AASA,SAAS,yBAAyB,SAAS,QAAQ,QAAQ;CAC1D,OAAO;EACN,UAAU,OAAO;EACjB,MAAM,OAAO;EACb,aAAa,mBAAmB,SAAS,OAAO,WAAW,MAAM;CAClE;AACD;;;;AAIA,SAAS,sBAAsB,eAAe,oBAAoB,eAAe;CAChF,OAAO;EACN,MAAM,GAAG,cAAc,GAAG;EAC1B,QAAQ,CAAC,GAAG,aAAa,CAAC,CAAC,KAAK;CACjC;AACD;;;;AAIA,SAAS,mBAAmB,SAAS,WAAW,QAAQ;CACvD,OAAO,eA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