@prisma/orm-postgres 8.0.0-rc.17-dev.12 → 8.0.0-rc.17-dev.13

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.
@@ -1,9 +1,10 @@
1
1
  import { PG_ENUM_CODEC_ID } from "@prisma/orm-target-postgres/target/codec-ids";
2
2
  import postgresPackRef from "@prisma/orm-target-postgres/target/pack";
3
3
  import { PostgresNativeEnum, RlsPolicyOperation } from "@prisma/orm-target-postgres/target/types";
4
- import { CheckNode, ColumnRef, ComposedAuthoringHelpers, ComposedAuthoringHelpers as ComposedAuthoringHelpers$1, ContractDefinition, ContractInput, ContractInput as ContractInput$1, ContractModelBuilder, EnumMember, EnumTypeHandle, EnumTypeHandle as EnumTypeHandle$1, FieldNode, ForeignKeyNode, IndexConstraint, IndexNode, MergeEnums, ModelLike, ModelNode, PrimaryKeyNode, RelationNode, ScalarFieldBuilder, ScalarFieldBuilder as ScalarFieldBuilder$1, UniqueConstraintNode, autoincrement, buildBoundContract, buildSqlContractFromDefinition, check, member, model, now, rel, sql } from "@prisma/orm-family-sql/contract-ts/contract-builder";
4
+ import { CheckNode, ColumnRef, ComposedAuthoringHelpers, ComposedAuthoringHelpers as ComposedAuthoringHelpers$1, ContractDefinition, ContractInput, ContractInput as ContractInput$1, ContractModelBuilder, EnumMember, EnumTypeHandle, EnumTypeHandle as EnumTypeHandle$1, FieldNode, ForeignKeyNode, IndexConstraint, IndexNode, MergeEnums, ModelLike, ModelNode, PrimaryKeyNode, RelationNode, ScalarFieldBuilder, ScalarFieldBuilder as ScalarFieldBuilder$1, SqlExpression, UniqueConstraintNode, autoincrement, buildBoundContract, buildSqlContractFromDefinition, check, member, model, now, rel, sql } from "@prisma/orm-family-sql/contract-ts/contract-builder";
5
5
  import sqlFamilyPack from "@prisma/orm-family-sql/family/pack";
6
6
  import { CodecLookupWithDescriptors, ColumnTypeDescriptor, DataTypeLookup } from "@prisma/orm-framework/components/codec";
7
+ import { SqlExpression as SqlExpression$1 } from "@prisma/orm-family-sql/contract/sql-expression";
7
8
  import { FullTextFieldsInput } from "@prisma/orm-target-postgres/target/full-text-index-authoring";
8
9
  import "@prisma/orm-framework/contract/types";
9
10
  import "@prisma/orm-framework/components/authoring";
@@ -57,8 +58,8 @@ interface RlsPolicyHandle<Operation extends RlsPolicyOperation = RlsPolicyOperat
57
58
  readonly target: RlsTargetModel;
58
59
  };
59
60
  readonly roles: readonly RlsRoleHandle[];
60
- readonly using?: string;
61
- readonly withCheck?: string;
61
+ readonly using?: SqlExpression$1;
62
+ readonly withCheck?: SqlExpression$1;
62
63
  }
63
64
  /**
64
65
  * The handle vocabulary `defineContract({ entities })` accepts: policies,
@@ -72,11 +73,11 @@ interface RlsPolicyDescriptorBase {
72
73
  }
73
74
  /** Descriptor for the USING-only operations: SELECT and DELETE. */
74
75
  interface RlsUsingPolicyDescriptor extends RlsPolicyDescriptorBase {
75
- readonly using: string;
76
+ readonly using: SqlExpression$1;
76
77
  }
77
78
  /** Descriptor for the WITH CHECK-only operation: INSERT. */
78
79
  interface RlsWithCheckPolicyDescriptor extends RlsPolicyDescriptorBase {
79
- readonly withCheck: string;
80
+ readonly withCheck: SqlExpression$1;
80
81
  }
81
82
  /**
82
83
  * Descriptor for the operations taking both predicates: UPDATE and ALL. At
@@ -86,11 +87,11 @@ interface RlsWithCheckPolicyDescriptor extends RlsPolicyDescriptorBase {
86
87
  * predicate is omitted from the content hash, byte-identical to PSL.
87
88
  */
88
89
  type RlsUsingWithCheckPolicyDescriptor = (RlsPolicyDescriptorBase & {
89
- readonly using: string;
90
- readonly withCheck?: string;
90
+ readonly using: SqlExpression$1;
91
+ readonly withCheck?: SqlExpression$1;
91
92
  }) | (RlsPolicyDescriptorBase & {
92
- readonly using?: string;
93
- readonly withCheck: string;
93
+ readonly using?: SqlExpression$1;
94
+ readonly withCheck: SqlExpression$1;
94
95
  });
95
96
  /**
96
97
  * Declares a Postgres role by name, mirroring PSL's bare role identifiers.
@@ -500,7 +501,7 @@ declare const field: ComposedAuthoringHelpers$1<typeof sqlFamilyPack, typeof pos
500
501
  type FullTextIndexOptionsBase = {
501
502
  readonly language?: FullTextSearchLanguage;
502
503
  /** The SQL predicate restricting rows included in a partial index. */
503
- readonly where?: string;
504
+ readonly where?: SqlExpression$1;
504
505
  };
505
506
  /**
506
507
  * The wire-named form. `Name` stays literal so the model's `sql()` stage sees the
@@ -610,5 +611,5 @@ declare const pg: {
610
611
  readonly enum: typeof pgEnumColumn;
611
612
  };
612
613
  //#endregion
613
- export { type CheckNode, type ComposedAuthoringHelpers, type ContractDefinition, type ContractInput, type ContractModelBuilder, type EnumMember, type EnumTypeHandle, type FieldNode, type ForeignKeyNode, type IndexNode, type ModelNode, type NativeEnumHandle, type PrimaryKeyNode, type RelationNode, type RlsEnablementHandle, type RlsEntityHandle, type RlsPolicyHandle, type RlsRoleHandle, type RlsTargetModel, type RlsUsingPolicyDescriptor, type RlsUsingWithCheckPolicyDescriptor, type RlsWithCheckPolicyDescriptor, type ScalarFieldBuilder, type UniqueConstraintNode, autoincrement, buildSqlContractFromDefinition, check, defineContract, enumType, field, fullTextIndex, member, model, nativeEnum, now, pg, policyAll, policyDelete, policyInsert, policySelect, policyUpdate, rel, rlsEnabled, role, sql };
614
+ export { type CheckNode, type ComposedAuthoringHelpers, type ContractDefinition, type ContractInput, type ContractModelBuilder, type EnumMember, type EnumTypeHandle, type FieldNode, type ForeignKeyNode, type IndexNode, type ModelNode, type NativeEnumHandle, type PrimaryKeyNode, type RelationNode, type RlsEnablementHandle, type RlsEntityHandle, type RlsPolicyHandle, type RlsRoleHandle, type RlsTargetModel, type RlsUsingPolicyDescriptor, type RlsUsingWithCheckPolicyDescriptor, type RlsWithCheckPolicyDescriptor, type ScalarFieldBuilder, type SqlExpression, type UniqueConstraintNode, autoincrement, buildSqlContractFromDefinition, check, defineContract, enumType, field, fullTextIndex, member, model, nativeEnum, now, pg, policyAll, policyDelete, policyInsert, policySelect, policyUpdate, rel, rlsEnabled, role, sql };
614
615
  //# sourceMappingURL=contract-builder.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"contract-builder.d.mts","names":[],"sources":["../../../../3-extensions/postgres/dist/contract-builder.d.mts"],"mappings":";;;;;;;;;;;;;;;;;;;;UAmBU;WACC;aACE;aACA;aACA,QAAQ,eAAe;;;;;;;;UAQ1B,cAAc;WACb;WACA,MAAM;;;UAGP;WACC;;WAEA;aACE,QAAQ;;;;;;;;UAQX,gBAAgB,kBAAkB,qBAAqB;WACtD;WACA,WAAW;;WAEX;;WAEA;aACE,QAAQ;;WAEV,gBAAgB;WAChB;WACA;;;;;;KAMN,kBAAkB,kBAAkB,gBAAgB;UAC/C;;WAEC;WACA,gBAAgB;;;UAGjB,iCAAiC;WAChC;;;UAGD,qCAAqC;WACpC;;;;;;;;;KASN,qCAAqC;WAC/B;WACA;MACL;WACK;WACA;;;;;;;;iBAQM,WAAW,qBAAqB,MAAM,OAAO,cAAc;;;;;;iBAM3D,WAAW,OAAO,iBAAiB;;iBAEnC,aAAa,OAAO,gBAAgB,YAAY,2BAA2B;;iBAE3E,aAAa,OAAO,gBAAgB,YAAY,+BAA+B;;iBAE/E,aAAa,OAAO,gBAAgB,YAAY,oCAAoC;;iBAEpF,aAAa,OAAO,gBAAgB,YAAY,2BAA2B;;iBAE3E,UAAU,OAAO,gBAAgB,YAAY,oCAAoC;;;KAG7F,mBAAmB;KACnB,sBAAsB;KACtB,kBAAkB,eAAe;KACjC,mBAAmB,eAAe;KAClC,kBAAkB,eAAe;KACjC,eAAe,cAAc,iBAAiB,eAAe,kBAAkB,mBAAmB,eAAe,8CAA8C,cAAc,mBAAmB,kBAAkB,mBAAmB,WAAW;WAC1O,QAAQ;WACR,SAAS;WACT,aAAa;WACb,QAAQ;WACR,kBAAkB,OAAO,sBAAsB;WAC/C,aAAa;WACb,gBAAgB;;KAEtB,qBAAqB,mBAAmB,eAAe,gDAAgD,KAAK,gBAAgB,WAAW,cAAc,sBAAsB,sBA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;;WAEF,aAAa;aACX;aACA;aACA,yCAAyC;aACzC;;WAEF,iBAAiB;aACf,kDAAkD;aAClD,mDAAmD;aACnD,yCAAyC;aACzC;;WAEF,aAAa;aACX,0CAA0C;aAC1C,2CAA2C;aAC3C,yCAAyC;aACzC;;WAEF,cAAc;aACZ,0CAA0C;aAC1C,2CAA2C;aAC3C,yCAAyC;aACzC;;WAEF,gBAAgB;aACd;eACE;;aAEF;eACE;;aAEF,yCAAyC;aACzC;;;;;;;;cAQC,OAAO,kCAAkC,sBAAsB;;;KAGxE;WACM,WAAW;;WAEX,QAAQ;;;;;;KAMd,yBAAyB,gCAAgC;WACnD,MAAM;WACN;;;KAGN,0BAA0B;WACpB;WACA;;;;;;;;;;;;;;;iBAeM,oBAAoB,qBAAqB,QAAQ,oBAAoB,YAAY,SAAS,yBAAyB,QAAQ,mCAAmC;iBAC9J,cAAc,QAAQ,oBAAoB,YAAY,SAAS,0BAA0B;;;;;;;;;;;;;UAahG,iBAAiB,8BAA8B,kCAAkC;WAChF;WACA,MAAM;WACN,UAAU;WACV,SAAS;WACT,QAAQ,mBAAmB;;;;;;EAMpC,UAAU,+BAA+B,UAAU,iBAAiB,iBAAiB,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA4B5F,iBAAiB,2BAA2B,gDAAgD,MAAM,SAAS,SAAS,UAAU,iBAAiB,MAAM,MAAM;;;;;;KAMvK,uBAAuB,kDAAkD,4BAA4B;WAC/F;aACE;aACA;aACA,QAAQ,mBAAmB;;;;;;;;;;;;;iBAavB,mBAAmB,2BAA2B,+BAA+B,gDAAgD,QAAQ,iBAAiB,MAAM,UAAU,WAAW,uBAAuB;;cAE3M;WACH,aAAa"}
@@ -7,6 +7,7 @@ import { autoincrement, bindEnumType, buildBoundContract, buildSqlContractFromDe
7
7
  import sqlFamilyPack from "@prisma/orm-family-sql/family/pack";
8
8
  import { assembleDataTypes } from "@prisma/orm-framework/components/codec";
9
9
  import { assemblePostgresCodecRegistryWithBuiltins, pgEnumDescriptor } from "@prisma/orm-target-postgres/target/codecs";
10
+ import { requireSqlExpression } from "@prisma/orm-family-sql/contract/sql-expression";
10
11
  import { FULL_TEXT_INDEX_TYPE, describeFullTextIndexProblem, fullTextIndexProblems, postgresCodecTraitsOf, weightGroupsOf } from "@prisma/orm-target-postgres/target/full-text-index-authoring";
11
12
  import { DEFAULT_FULL_TEXT_SEARCH_LANGUAGE } from "@prisma/orm-target-postgres/target/sql-utils";
12
13
  import { assertDefined } from "@prisma/orm-framework/utils/assertions";
@@ -78,11 +79,15 @@ function fullTextIndex(fields, options) {
78
79
  language
79
80
  };
80
81
  },
81
- ...options.where !== void 0 ? { where: options.where } : {},
82
+ ...options.where !== void 0 ? { where: requireSqlExpression(options.where, `${fullTextIndexOwner(fieldNames, options)} where`) } : {},
82
83
  ...options.name !== void 0 ? { name: options.name } : {},
83
84
  ...options.map !== void 0 ? { map: options.map } : {}
84
85
  };
85
86
  }
87
+ function fullTextIndexOwner(fieldNames, options) {
88
+ const name = options.name ?? options.map;
89
+ return name === void 0 ? `Full-text index on fields ${fieldNames.map((fieldName) => `"${fieldName}"`).join(", ")}` : `Full-text index "${name}"`;
90
+ }
86
91
  function refuseInvalid(candidate) {
87
92
  const [problem] = fullTextIndexProblems(candidate);
88
93
  if (problem === void 0) return;
@@ -1 +1 @@
1
- {"version":3,"file":"contract-builder.mjs","names":[],"sources":["../../../../3-extensions/postgres/dist/contract-builder.mjs"],"sourcesContent":["import { t as postgresError } from \"./errors-DfWK9xep.mjs\";\nimport { PG_ENUM_CODEC_ID } from \"@internal/target-postgres/codec-ids\";\nimport postgresPackRef from \"@internal/target-postgres/pack\";\nimport { PostgresNativeEnum, postgresCreateNamespace } from \"@internal/target-postgres/types\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { autoincrement, bindEnumType, buildBoundContract, buildSqlContractFromDefinition, check, createComposedAuthoringHelpers, member, model, now, rel, sql } from \"@internal/sql-contract-ts/contract-builder\";\nimport sqlFamilyPack from \"@internal/family-sql/pack\";\nimport { assembleDataTypes } from \"@internal/framework-components/codec\";\nimport { assemblePostgresCodecRegistryWithBuiltins, pgEnumDescriptor } from \"@internal/target-postgres/codecs\";\nimport { FULL_TEXT_INDEX_TYPE, describeFullTextIndexProblem, fullTextIndexProblems, postgresCodecTraitsOf, weightGroupsOf } from \"@internal/target-postgres/full-text-index-authoring\";\nimport { DEFAULT_FULL_TEXT_SEARCH_LANGUAGE } from \"@internal/target-postgres/sql-utils\";\nimport { assertDefined } from \"@internal/utils/assertions\";\nimport { InternalError } from \"@internal/utils/internal-error\";\nimport { POLICY_OPERATION_PREDICATES } from \"@internal/target-postgres/rls-canonicalize\";\n//#region src/contract/define-contract.ts\nfunction defineContract(definition, factory) {\n\tconst extensions = Object.values(definition.extensions ?? {});\n\tconst dataTypeLookup = definition.dataTypeLookup ?? assembleDataTypes([postgresPackRef, ...extensions]).lookup;\n\tconst bound = {\n\t\t...definition,\n\t\tcreateNamespace: postgresCreateNamespace,\n\t\tcodecLookup: definition.codecLookup ?? assemblePostgresCodecRegistryWithBuiltins(extensions, dataTypeLookup),\n\t\tdataTypeLookup\n\t};\n\tif (factory !== void 0) return buildBoundContract(sqlFamilyPack, postgresPackRef, bound, factory);\n\treturn buildBoundContract(sqlFamilyPack, postgresPackRef, bound);\n}\n//#endregion\n//#region src/contract/enum-type.ts\n/**\n* The `enumType` authors call when building a Postgres contract (re-exported\n* from `@internal/postgres/contract-builder`).\n*\n* `bindEnumType` is the core, codec-agnostic `enumType` factory; calling it with\n* the Postgres pack's codec typemap fixes which member-value type each codec\n* permits, so `member()` values are checked against the column's codec at\n* authoring time: `pg/text@1` requires `string`, `pg/int4@1` requires `number`,\n* and a mismatch is a compile error. The core `enumType` can't know the codec\n* set, which is why the binding happens here, per target.\n*/\nconst enumType = bindEnumType();\n//#endregion\n//#region src/contract/field.ts\nconst dataTypeLookup = assembleDataTypes([postgresPackRef]).lookup;\n/**\n* The field builders of the `defineContract` callback for Postgres, without extensions: `field.text()`, `field.temporal.timestamptz()`, `field.uuidString()`, and `field.column(columnType)`. Use it outside a contract, for example to declare the fields of a query fragment.\n*/\nconst field = createComposedAuthoringHelpers({\n\tfamily: sqlFamilyPack,\n\ttarget: postgresPackRef,\n\tcodecLookup: assemblePostgresCodecRegistryWithBuiltins([], dataTypeLookup),\n\tdataTypeLookup\n}).field;\n//#endregion\n//#region src/contract/full-text-index.ts\nfunction isColumnRef(value) {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\nfunction fullTextIndex(fields, options) {\n\tconst fieldGroups = weightGroupsOf(fields, isColumnRef).map((group) => group.map((ref) => ref.fieldName));\n\trefuseInvalid({ weightGroups: fieldGroups });\n\tconst language = options.language ?? DEFAULT_FULL_TEXT_SEARCH_LANGUAGE;\n\tconst fieldNames = fieldGroups.flat();\n\treturn {\n\t\tkind: \"index\",\n\t\tfields: fieldNames,\n\t\ttype: FULL_TEXT_INDEX_TYPE,\n\t\toptions: (columns) => {\n\t\t\tconst columnOf = new Map(fieldNames.map((fieldName, i) => [fieldName, columns[i]]));\n\t\t\trefuseInvalid({\n\t\t\t\tweightGroups: fieldGroups,\n\t\t\t\tcodecs: {\n\t\t\t\t\tcodecIdOf: (fieldName) => columnOf.get(fieldName)?.codecId,\n\t\t\t\t\ttraitsOf: postgresCodecTraitsOf\n\t\t\t\t}\n\t\t\t});\n\t\t\tconst columnNameOf = (fieldName) => {\n\t\t\t\tconst column = columnOf.get(fieldName);\n\t\t\t\tassertDefined(column, `fullTextIndex field \"${fieldName}\" was resolved to a column`);\n\t\t\t\treturn column.name;\n\t\t\t};\n\t\t\treturn {\n\t\t\t\tweightGroups: fieldGroups.map((group) => group.map(columnNameOf)),\n\t\t\t\tlanguage\n\t\t\t};\n\t\t},\n\t\t...options.where !== void 0 ? { where: options.where } : {},\n\t\t...options.name !== void 0 ? { name: options.name } : {},\n\t\t...options.map !== void 0 ? { map: options.map } : {}\n\t};\n}\nfunction refuseInvalid(candidate) {\n\tconst [problem] = fullTextIndexProblems(candidate);\n\tif (problem === void 0) return;\n\tthrow postgresError(\"CONTRACT.INDEX_INVALID\", describeFullTextIndexProblem(\"fullTextIndex\", problem), {\n\t\twhy: \"Each top-level item of the fields is one weight group; Postgres has four weights, A to D, each field belongs to one group, and to_tsvector takes text.\",\n\t\tfix: \"List each text field once, in at most four non-empty groups.\",\n\t\tmeta: {\n\t\t\thelper: \"fullTextIndex\",\n\t\t\tfields: candidate.weightGroups\n\t\t}\n\t});\n}\n//#endregion\n//#region src/contract/native-enum.ts\nfunction buildNativeEnumHandle(name, typeName, members) {\n\tif (typeName.trim().length === 0) throw postgresError(\"CONTRACT.ENUM_INVALID\", `nativeEnum(\"${name}\"): the Postgres type name must be a non-empty string.`, {\n\t\tfix: \"Pass a non-empty Postgres type name to .map(typeName).\",\n\t\tmeta: {\n\t\t\tenumName: name,\n\t\t\treason: \"empty type name\"\n\t\t}\n\t});\n\treturn {\n\t\tentityKind: \"native_enum\",\n\t\tname,\n\t\ttypeName,\n\t\tmembers,\n\t\tentity: new PostgresNativeEnum({\n\t\t\ttypeName,\n\t\t\tmembers\n\t\t}),\n\t\tmap: (mappedTypeName) => buildNativeEnumHandle(name, mappedTypeName, members)\n\t};\n}\n/**\n* Declares a native Postgres enum type for use with {@link pg}'s `.enum()`\n* column helper. Mirrors PSL's `native_enum <Name> { … }` lowering\n* (`lowerNativeEnumFromBlock`): validates a non-empty, duplicate-free member\n* list and builds the same {@link PostgresNativeEnum} entity. Its value-set is\n* derived generically at contract-build time — the same\n* `deriveValueSetFromEntity` fold PSL's native enums go through — once\n* `pg.enum(handle)` lands the entity in the field's owning namespace.\n*\n* The first argument is the entity `name` (the `entries.native_enum` /\n* `entries.valueSet` key). The Postgres type name defaults to `name`; use\n* `.map(typeName)` to override it (PSL's `@@map`).\n*\n* A handle referenced by columns in N different namespaces materialises N\n* native enum types (one per namespace) — by design: a Postgres type lives in\n* exactly one schema, and PSL can't share a type across schemas either.\n*\n* @example\n* ```ts\n* // name === Postgres type name\n* const Role = nativeEnum('Role', 'user', 'admin');\n* // entity name `AalLevel`, Postgres type `aal_level` (Supabase's auth.aal_level)\n* const AalLevel = nativeEnum('AalLevel', 'aal1', 'aal2', 'aal3').map('aal_level');\n* model('Session', { fields: { aal: field.column(pg.enum(AalLevel)).optional() } });\n* ```\n*/\nfunction nativeEnum(name, ...members) {\n\tif (name.trim().length === 0) throw postgresError(\"CONTRACT.ENUM_INVALID\", \"nativeEnum(): name must be a non-empty string.\", {\n\t\tfix: \"Pass a non-empty entity name as the first argument to nativeEnum().\",\n\t\tmeta: {\n\t\t\tenumName: name,\n\t\t\treason: \"empty name\"\n\t\t}\n\t});\n\tif (members.length === 0) throw postgresError(\"CONTRACT.ENUM_INVALID\", `nativeEnum(\"${name}\"): must have at least one member.`, {\n\t\twhy: \"Postgres rejects CREATE TYPE ... AS ENUM () with no labels.\",\n\t\tfix: \"Declare at least one member value after the name.\",\n\t\tmeta: {\n\t\t\tenumName: name,\n\t\t\treason: \"zero members\"\n\t\t}\n\t});\n\tconst seenValues = /* @__PURE__ */ new Set();\n\tfor (const value of members) {\n\t\tif (seenValues.has(value)) throw postgresError(\"CONTRACT.ENUM_INVALID\", `nativeEnum(\"${name}\"): duplicate member value \"${value}\". Member values must be unique.`, {\n\t\t\tfix: \"Remove the duplicate member value.\",\n\t\t\tmeta: {\n\t\t\t\tenumName: name,\n\t\t\t\tmember: value,\n\t\t\t\treason: \"duplicate member value\"\n\t\t\t}\n\t\t});\n\t\tseenValues.add(value);\n\t}\n\treturn buildNativeEnumHandle(name, name, members);\n}\n/**\n* Builds the deferred column descriptor for `handle`: its `typeParams` come from `pgEnumDescriptor.columnFromEntity` (the same\n* authoring hook the PSL `pg.enum(Ref)` type constructor resolves through),\n* carrying `handle.entity` as the descriptor's `entityRef` keyed by the entity\n* `name` (not the Postgres type name — they differ when `.map()` was used).\n* Schema qualification and the storage `valueSet` ref are NOT computed here — a\n* `field.column(pg.enum(handle))` call runs before the enclosing `model(...)`\n* associates a namespace, so `buildSqlContractFromDefinition` resolves both\n* once the field's namespace is known.\n*/\nfunction pgEnumColumn(handle) {\n\tconst resolved = pgEnumDescriptor.columnFromEntity(handle.entity);\n\tif (resolved === void 0) throw new InternalError(`pg.enum(\"${handle.name}\"): handle.entity is not a PostgresNativeEnum. This is an authoring-surface bug — nativeEnum() must always produce one.`);\n\treturn {\n\t\tcodecId: PG_ENUM_CODEC_ID,\n\t\ttypeParams: resolved.typeParams,\n\t\tentityRef: {\n\t\t\tentityKind: handle.entityKind,\n\t\t\tentityName: handle.name,\n\t\t\tentity: handle.entity\n\t\t}\n\t};\n}\n/** Postgres-specific TS type-constructor namespace, mirroring the PSL `pg.` prefix. */\nconst pg = { enum: pgEnumColumn };\n//#endregion\n//#region src/contract/rls.ts\nfunction assertNonEmptyName(helper, name) {\n\tif (name.trim().length === 0) throw postgresError(\"CONTRACT.POLICY_INVALID\", `${helper}: name must be a non-empty string.`, {\n\t\tfix: \"Pass a non-empty policy name.\",\n\t\tmeta: {\n\t\t\tpolicyName: name,\n\t\t\treason: \"empty name\"\n\t\t}\n\t});\n}\n/** The user-facing helper name per operation, for runtime error messages. */\nconst HELPER_NAMES = {\n\tselect: \"policySelect\",\n\tinsert: \"policyInsert\",\n\tupdate: \"policyUpdate\",\n\tdelete: \"policyDelete\",\n\tall: \"policyAll\"\n};\nfunction buildPolicyHandle(operation, model, descriptor) {\n\tconst helper = HELPER_NAMES[operation];\n\tconst support = POLICY_OPERATION_PREDICATES[operation];\n\tassertNonEmptyName(`${helper}(\"${descriptor.name}\")`, descriptor.name);\n\tconst supported = support.using && support.withCheck ? \"`using` and `withCheck`\" : support.using ? \"`using` only\" : \"`withCheck` only\";\n\tconst rejectPredicate = (predicate) => {\n\t\tthrow postgresError(\"CONTRACT.POLICY_INVALID\", `${helper}: policy \"${descriptor.name}\" does not take a \\`${predicate}\\` predicate; the ${operation.toUpperCase()} operation uses ${supported}.`, {\n\t\t\tfix: `Use only the predicates the ${operation.toUpperCase()} operation supports: ${supported}.`,\n\t\t\tmeta: {\n\t\t\t\tpolicyName: descriptor.name,\n\t\t\t\treason: `unsupported \\`${predicate}\\` predicate`\n\t\t\t}\n\t\t});\n\t};\n\tif (descriptor.using !== void 0 && !support.using) rejectPredicate(\"using\");\n\tif (descriptor.withCheck !== void 0 && !support.withCheck) rejectPredicate(\"withCheck\");\n\tif (descriptor.using === void 0 && descriptor.withCheck === void 0) throw postgresError(\"CONTRACT.POLICY_INVALID\", `${helper}: policy \"${descriptor.name}\" requires at least one predicate; the ${operation.toUpperCase()} operation uses ${supported}.`, {\n\t\tfix: `Provide at least one predicate: ${supported}.`,\n\t\tmeta: {\n\t\t\tpolicyName: descriptor.name,\n\t\t\treason: \"no predicate given\"\n\t\t}\n\t});\n\treturn Object.freeze({\n\t\tentityKind: \"policy\",\n\t\toperation,\n\t\tname: descriptor.name,\n\t\trefs: Object.freeze({ target: model }),\n\t\troles: Object.freeze([...descriptor.roles]),\n\t\t...ifDefined(\"using\", descriptor.using),\n\t\t...ifDefined(\"withCheck\", descriptor.withCheck)\n\t});\n}\n/**\n* Declares a Postgres role by name, mirroring PSL's bare role identifiers.\n* Returns an inert handle: referenced in a policy's `roles` it contributes\n* the bare name; placed in the `entities` list it declares the role\n* (`entries.role`), making it subject to the existence verify.\n*/\nfunction role(name) {\n\tassertNonEmptyName(`role(\"${name}\")`, name);\n\treturn Object.freeze({\n\t\tentityKind: \"role\",\n\t\tname\n\t});\n}\n/**\n* Marks a model's table RLS-controlled, mirroring PSL's `@@rls`. The\n* enablement marker (never the policy set) drives `ENABLE`/`DISABLE ROW\n* LEVEL SECURITY` planning.\n*/\nfunction rlsEnabled(model) {\n\treturn Object.freeze({\n\t\tentityKind: \"rls\",\n\t\trefs: Object.freeze({ target: model })\n\t});\n}\n/** Authors a `FOR SELECT` policy (PSL `policy_select`): row visibility via `using`. */\nfunction policySelect(model, descriptor) {\n\treturn buildPolicyHandle(\"select\", model, descriptor);\n}\n/** Authors a `FOR INSERT` policy (PSL `policy_insert`): new-row validation via `withCheck`. */\nfunction policyInsert(model, descriptor) {\n\treturn buildPolicyHandle(\"insert\", model, descriptor);\n}\n/** Authors a `FOR UPDATE` policy (PSL `policy_update`): takes `using` and `withCheck`. */\nfunction policyUpdate(model, descriptor) {\n\treturn buildPolicyHandle(\"update\", model, descriptor);\n}\n/** Authors a `FOR DELETE` policy (PSL `policy_delete`): row eligibility via `using`. */\nfunction policyDelete(model, descriptor) {\n\treturn buildPolicyHandle(\"delete\", model, descriptor);\n}\n/** Authors a `FOR ALL` policy (PSL `policy_all`): takes `using` and `withCheck`. */\nfunction policyAll(model, descriptor) {\n\treturn buildPolicyHandle(\"all\", model, descriptor);\n}\n//#endregion\nexport { autoincrement, buildSqlContractFromDefinition, check, defineContract, enumType, field, fullTextIndex, member, model, nativeEnum, now, pg, policyAll, policyDelete, policyInsert, policySelect, policyUpdate, rel, rlsEnabled, role, sql };\n\n//# sourceMappingURL=contract-builder.mjs.map"],"mappings":";;;;;;;;;;;;;;;AAeA,SAAS,eAAe,YAAY,SAAS;CAC5C,MAAM,aAAa,OAAO,OAAO,WAAW,cAAc,CAAC,CAAC;CAC5D,MAAM,iBAAiB,WAAW,kBAAkB,kBAAkB,CAAC,iBAAiB,GAAG,UAAU,CAAC,CAAC,CAAC;CACxG,MAAM,QAAQ;EACb,GAAG;EACH,iBAAiB;EACjB,aAAa,WAAW,eAAe,0CAA0C,YAAY,cAAc;EAC3G;CACD;CACA,IAAI,YAAY,KAAK,GAAG,OAAO,mBAAmB,eAAe,iBAAiB,OAAO,OAAO;CAChG,OAAO,mBAAmB,eAAe,iBAAiB,KAAK;AAChE;;;;;;;;;;;;AAcA,MAAM,WAAW,aAAa;AAG9B,MAAM,iBAAiB,kBAAkB,CAAC,eAAe,CAAC,CAAC,CAAC;;;;AAI5D,MAAM,QAAQ,+BAA+B;CAC5C,QAAQ;CACR,QAAQ;CACR,aAAa,0CAA0C,CAAC,GAAG,cAAc;CACzE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C,UAAU;EAClD,MAAM;GACL,YAAY,WAAW;GACvB,QAAQ;EACT;CACD,CAAC;CACD,OAAO,OAAO,OAAO;EACpB,YAAY;EACZ;EACA,MAAM,WAAW;EACjB,MAAM,OAAO,OAAO,EAAE,QAAQ,MAAM,CAAC;EACrC,OAAO,OAAO,OAAO,CAAC,GAAG,WAAW,KAAK,CAAC;EAC1C,GAAG,UAAU,SAAS,WAAW,KAAK;EACtC,GAAG,UAAU,aAAa,WAAW,SAAS;CAC/C,CAAC;AACF;;;;;;;AAOA,SAAS,KAAK,MAAM;CACnB,mBAAmB,SAAS,KAAK,KAAK,IAAI;CAC1C,OAAO,OAAO,OAAO;EACpB,YAAY;EACZ;CACD,CAAC;AACF;;;;;;AAMA,SAAS,WAAW,OAAO;CAC1B,OAAO,OAAO,OAAO;EACpB,YAAY;EACZ,MAAM,OAAO,OAAO,EAAE,QAAQ,MAAM,CAAC;CACtC,CAAC;AACF;;AAEA,SAAS,aAAa,OAAO,YAAY;CACxC,OAAO,kBAAkB,UAAU,OAAO,UAAU;AACrD;;AAEA,SAAS,aAAa,OAAO,YAAY;CACxC,OAAO,kBAAkB,UAAU,OAAO,UAAU;AACrD;;AAEA,SAAS,aAAa,OAAO,YAAY;CACxC,OAAO,kBAAkB,UAAU,OAAO,UAAU;AACrD;;AAEA,SAAS,aAAa,OAAO,YAAY;CACxC,OAAO,kBAAkB,UAAU,OAAO,UAAU;AACrD;;AAEA,SAAS,UAAU,OAAO,YAAY;CACrC,OAAO,kBAAkB,OAAO,OAAO,UAAU;AAClD"}
1
+ {"version":3,"file":"contract-builder.mjs","names":[],"sources":["../../../../3-extensions/postgres/dist/contract-builder.mjs"],"sourcesContent":["import { t as postgresError } from \"./errors-DfWK9xep.mjs\";\nimport { PG_ENUM_CODEC_ID } from \"@internal/target-postgres/codec-ids\";\nimport postgresPackRef from \"@internal/target-postgres/pack\";\nimport { PostgresNativeEnum, postgresCreateNamespace } from \"@internal/target-postgres/types\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { autoincrement, bindEnumType, buildBoundContract, buildSqlContractFromDefinition, check, createComposedAuthoringHelpers, member, model, now, rel, sql } from \"@internal/sql-contract-ts/contract-builder\";\nimport sqlFamilyPack from \"@internal/family-sql/pack\";\nimport { assembleDataTypes } from \"@internal/framework-components/codec\";\nimport { assemblePostgresCodecRegistryWithBuiltins, pgEnumDescriptor } from \"@internal/target-postgres/codecs\";\nimport { requireSqlExpression } from \"@internal/sql-contract/sql-expression\";\nimport { FULL_TEXT_INDEX_TYPE, describeFullTextIndexProblem, fullTextIndexProblems, postgresCodecTraitsOf, weightGroupsOf } from \"@internal/target-postgres/full-text-index-authoring\";\nimport { DEFAULT_FULL_TEXT_SEARCH_LANGUAGE } from \"@internal/target-postgres/sql-utils\";\nimport { assertDefined } from \"@internal/utils/assertions\";\nimport { InternalError } from \"@internal/utils/internal-error\";\nimport { POLICY_OPERATION_PREDICATES } from \"@internal/target-postgres/rls-canonicalize\";\n//#region src/contract/define-contract.ts\nfunction defineContract(definition, factory) {\n\tconst extensions = Object.values(definition.extensions ?? {});\n\tconst dataTypeLookup = definition.dataTypeLookup ?? assembleDataTypes([postgresPackRef, ...extensions]).lookup;\n\tconst bound = {\n\t\t...definition,\n\t\tcreateNamespace: postgresCreateNamespace,\n\t\tcodecLookup: definition.codecLookup ?? assemblePostgresCodecRegistryWithBuiltins(extensions, dataTypeLookup),\n\t\tdataTypeLookup\n\t};\n\tif (factory !== void 0) return buildBoundContract(sqlFamilyPack, postgresPackRef, bound, factory);\n\treturn buildBoundContract(sqlFamilyPack, postgresPackRef, bound);\n}\n//#endregion\n//#region src/contract/enum-type.ts\n/**\n* The `enumType` authors call when building a Postgres contract (re-exported\n* from `@internal/postgres/contract-builder`).\n*\n* `bindEnumType` is the core, codec-agnostic `enumType` factory; calling it with\n* the Postgres pack's codec typemap fixes which member-value type each codec\n* permits, so `member()` values are checked against the column's codec at\n* authoring time: `pg/text@1` requires `string`, `pg/int4@1` requires `number`,\n* and a mismatch is a compile error. The core `enumType` can't know the codec\n* set, which is why the binding happens here, per target.\n*/\nconst enumType = bindEnumType();\n//#endregion\n//#region src/contract/field.ts\nconst dataTypeLookup = assembleDataTypes([postgresPackRef]).lookup;\n/**\n* The field builders of the `defineContract` callback for Postgres, without extensions: `field.text()`, `field.temporal.timestamptz()`, `field.uuidString()`, and `field.column(columnType)`. Use it outside a contract, for example to declare the fields of a query fragment.\n*/\nconst field = createComposedAuthoringHelpers({\n\tfamily: sqlFamilyPack,\n\ttarget: postgresPackRef,\n\tcodecLookup: assemblePostgresCodecRegistryWithBuiltins([], dataTypeLookup),\n\tdataTypeLookup\n}).field;\n//#endregion\n//#region src/contract/full-text-index.ts\nfunction isColumnRef(value) {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\nfunction fullTextIndex(fields, options) {\n\tconst fieldGroups = weightGroupsOf(fields, isColumnRef).map((group) => group.map((ref) => ref.fieldName));\n\trefuseInvalid({ weightGroups: fieldGroups });\n\tconst language = options.language ?? DEFAULT_FULL_TEXT_SEARCH_LANGUAGE;\n\tconst fieldNames = fieldGroups.flat();\n\treturn {\n\t\tkind: \"index\",\n\t\tfields: fieldNames,\n\t\ttype: FULL_TEXT_INDEX_TYPE,\n\t\toptions: (columns) => {\n\t\t\tconst columnOf = new Map(fieldNames.map((fieldName, i) => [fieldName, columns[i]]));\n\t\t\trefuseInvalid({\n\t\t\t\tweightGroups: fieldGroups,\n\t\t\t\tcodecs: {\n\t\t\t\t\tcodecIdOf: (fieldName) => columnOf.get(fieldName)?.codecId,\n\t\t\t\t\ttraitsOf: postgresCodecTraitsOf\n\t\t\t\t}\n\t\t\t});\n\t\t\tconst columnNameOf = (fieldName) => {\n\t\t\t\tconst column = columnOf.get(fieldName);\n\t\t\t\tassertDefined(column, `fullTextIndex field \"${fieldName}\" was resolved to a column`);\n\t\t\t\treturn column.name;\n\t\t\t};\n\t\t\treturn {\n\t\t\t\tweightGroups: fieldGroups.map((group) => group.map(columnNameOf)),\n\t\t\t\tlanguage\n\t\t\t};\n\t\t},\n\t\t...options.where !== void 0 ? { where: requireSqlExpression(options.where, `${fullTextIndexOwner(fieldNames, options)} where`) } : {},\n\t\t...options.name !== void 0 ? { name: options.name } : {},\n\t\t...options.map !== void 0 ? { map: options.map } : {}\n\t};\n}\nfunction fullTextIndexOwner(fieldNames, options) {\n\tconst name = options.name ?? options.map;\n\treturn name === void 0 ? `Full-text index on fields ${fieldNames.map((fieldName) => `\"${fieldName}\"`).join(\", \")}` : `Full-text index \"${name}\"`;\n}\nfunction refuseInvalid(candidate) {\n\tconst [problem] = fullTextIndexProblems(candidate);\n\tif (problem === void 0) return;\n\tthrow postgresError(\"CONTRACT.INDEX_INVALID\", describeFullTextIndexProblem(\"fullTextIndex\", problem), {\n\t\twhy: \"Each top-level item of the fields is one weight group; Postgres has four weights, A to D, each field belongs to one group, and to_tsvector takes text.\",\n\t\tfix: \"List each text field once, in at most four non-empty groups.\",\n\t\tmeta: {\n\t\t\thelper: \"fullTextIndex\",\n\t\t\tfields: candidate.weightGroups\n\t\t}\n\t});\n}\n//#endregion\n//#region src/contract/native-enum.ts\nfunction buildNativeEnumHandle(name, typeName, members) {\n\tif (typeName.trim().length === 0) throw postgresError(\"CONTRACT.ENUM_INVALID\", `nativeEnum(\"${name}\"): the Postgres type name must be a non-empty string.`, {\n\t\tfix: \"Pass a non-empty Postgres type name to .map(typeName).\",\n\t\tmeta: {\n\t\t\tenumName: name,\n\t\t\treason: \"empty type name\"\n\t\t}\n\t});\n\treturn {\n\t\tentityKind: \"native_enum\",\n\t\tname,\n\t\ttypeName,\n\t\tmembers,\n\t\tentity: new PostgresNativeEnum({\n\t\t\ttypeName,\n\t\t\tmembers\n\t\t}),\n\t\tmap: (mappedTypeName) => buildNativeEnumHandle(name, mappedTypeName, members)\n\t};\n}\n/**\n* Declares a native Postgres enum type for use with {@link pg}'s `.enum()`\n* column helper. Mirrors PSL's `native_enum <Name> { … }` lowering\n* (`lowerNativeEnumFromBlock`): validates a non-empty, duplicate-free member\n* list and builds the same {@link PostgresNativeEnum} entity. Its value-set is\n* derived generically at contract-build time — the same\n* `deriveValueSetFromEntity` fold PSL's native enums go through — once\n* `pg.enum(handle)` lands the entity in the field's owning namespace.\n*\n* The first argument is the entity `name` (the `entries.native_enum` /\n* `entries.valueSet` key). The Postgres type name defaults to `name`; use\n* `.map(typeName)` to override it (PSL's `@@map`).\n*\n* A handle referenced by columns in N different namespaces materialises N\n* native enum types (one per namespace) — by design: a Postgres type lives in\n* exactly one schema, and PSL can't share a type across schemas either.\n*\n* @example\n* ```ts\n* // name === Postgres type name\n* const Role = nativeEnum('Role', 'user', 'admin');\n* // entity name `AalLevel`, Postgres type `aal_level` (Supabase's auth.aal_level)\n* const AalLevel = nativeEnum('AalLevel', 'aal1', 'aal2', 'aal3').map('aal_level');\n* model('Session', { fields: { aal: field.column(pg.enum(AalLevel)).optional() } });\n* ```\n*/\nfunction nativeEnum(name, ...members) {\n\tif (name.trim().length === 0) throw postgresError(\"CONTRACT.ENUM_INVALID\", \"nativeEnum(): name must be a non-empty string.\", {\n\t\tfix: \"Pass a non-empty entity name as the first argument to nativeEnum().\",\n\t\tmeta: {\n\t\t\tenumName: name,\n\t\t\treason: \"empty name\"\n\t\t}\n\t});\n\tif (members.length === 0) throw postgresError(\"CONTRACT.ENUM_INVALID\", `nativeEnum(\"${name}\"): must have at least one member.`, {\n\t\twhy: \"Postgres rejects CREATE TYPE ... AS ENUM () with no labels.\",\n\t\tfix: \"Declare at least one member value after the name.\",\n\t\tmeta: {\n\t\t\tenumName: name,\n\t\t\treason: \"zero members\"\n\t\t}\n\t});\n\tconst seenValues = /* @__PURE__ */ new Set();\n\tfor (const value of members) {\n\t\tif (seenValues.has(value)) throw postgresError(\"CONTRACT.ENUM_INVALID\", `nativeEnum(\"${name}\"): duplicate member value \"${value}\". Member values must be unique.`, {\n\t\t\tfix: \"Remove the duplicate member value.\",\n\t\t\tmeta: {\n\t\t\t\tenumName: name,\n\t\t\t\tmember: value,\n\t\t\t\treason: \"duplicate member value\"\n\t\t\t}\n\t\t});\n\t\tseenValues.add(value);\n\t}\n\treturn buildNativeEnumHandle(name, name, members);\n}\n/**\n* Builds the deferred column descriptor for `handle`: its `typeParams` come from `pgEnumDescriptor.columnFromEntity` (the same\n* authoring hook the PSL `pg.enum(Ref)` type constructor resolves through),\n* carrying `handle.entity` as the descriptor's `entityRef` keyed by the entity\n* `name` (not the Postgres type name — they differ when `.map()` was used).\n* Schema qualification and the storage `valueSet` ref are NOT computed here — a\n* `field.column(pg.enum(handle))` call runs before the enclosing `model(...)`\n* associates a namespace, so `buildSqlContractFromDefinition` resolves both\n* once the field's namespace is known.\n*/\nfunction pgEnumColumn(handle) {\n\tconst resolved = pgEnumDescriptor.columnFromEntity(handle.entity);\n\tif (resolved === void 0) throw new InternalError(`pg.enum(\"${handle.name}\"): handle.entity is not a PostgresNativeEnum. This is an authoring-surface bug — nativeEnum() must always produce one.`);\n\treturn {\n\t\tcodecId: PG_ENUM_CODEC_ID,\n\t\ttypeParams: resolved.typeParams,\n\t\tentityRef: {\n\t\t\tentityKind: handle.entityKind,\n\t\t\tentityName: handle.name,\n\t\t\tentity: handle.entity\n\t\t}\n\t};\n}\n/** Postgres-specific TS type-constructor namespace, mirroring the PSL `pg.` prefix. */\nconst pg = { enum: pgEnumColumn };\n//#endregion\n//#region src/contract/rls.ts\nfunction assertNonEmptyName(helper, name) {\n\tif (name.trim().length === 0) throw postgresError(\"CONTRACT.POLICY_INVALID\", `${helper}: name must be a non-empty string.`, {\n\t\tfix: \"Pass a non-empty policy name.\",\n\t\tmeta: {\n\t\t\tpolicyName: name,\n\t\t\treason: \"empty name\"\n\t\t}\n\t});\n}\n/** The user-facing helper name per operation, for runtime error messages. */\nconst HELPER_NAMES = {\n\tselect: \"policySelect\",\n\tinsert: \"policyInsert\",\n\tupdate: \"policyUpdate\",\n\tdelete: \"policyDelete\",\n\tall: \"policyAll\"\n};\nfunction buildPolicyHandle(operation, model, descriptor) {\n\tconst helper = HELPER_NAMES[operation];\n\tconst support = POLICY_OPERATION_PREDICATES[operation];\n\tassertNonEmptyName(`${helper}(\"${descriptor.name}\")`, descriptor.name);\n\tconst supported = support.using && support.withCheck ? \"`using` and `withCheck`\" : support.using ? \"`using` only\" : \"`withCheck` only\";\n\tconst rejectPredicate = (predicate) => {\n\t\tthrow postgresError(\"CONTRACT.POLICY_INVALID\", `${helper}: policy \"${descriptor.name}\" does not take a \\`${predicate}\\` predicate; the ${operation.toUpperCase()} operation uses ${supported}.`, {\n\t\t\tfix: `Use only the predicates the ${operation.toUpperCase()} operation supports: ${supported}.`,\n\t\t\tmeta: {\n\t\t\t\tpolicyName: descriptor.name,\n\t\t\t\treason: `unsupported \\`${predicate}\\` predicate`\n\t\t\t}\n\t\t});\n\t};\n\tif (descriptor.using !== void 0 && !support.using) rejectPredicate(\"using\");\n\tif (descriptor.withCheck !== void 0 && !support.withCheck) rejectPredicate(\"withCheck\");\n\tif (descriptor.using === void 0 && descriptor.withCheck === void 0) throw postgresError(\"CONTRACT.POLICY_INVALID\", `${helper}: policy \"${descriptor.name}\" requires at least one predicate; the ${operation.toUpperCase()} operation uses ${supported}.`, {\n\t\tfix: `Provide at least one predicate: ${supported}.`,\n\t\tmeta: {\n\t\t\tpolicyName: descriptor.name,\n\t\t\treason: \"no predicate given\"\n\t\t}\n\t});\n\treturn Object.freeze({\n\t\tentityKind: \"policy\",\n\t\toperation,\n\t\tname: descriptor.name,\n\t\trefs: Object.freeze({ target: model }),\n\t\troles: Object.freeze([...descriptor.roles]),\n\t\t...ifDefined(\"using\", descriptor.using),\n\t\t...ifDefined(\"withCheck\", descriptor.withCheck)\n\t});\n}\n/**\n* Declares a Postgres role by name, mirroring PSL's bare role identifiers.\n* Returns an inert handle: referenced in a policy's `roles` it contributes\n* the bare name; placed in the `entities` list it declares the role\n* (`entries.role`), making it subject to the existence verify.\n*/\nfunction role(name) {\n\tassertNonEmptyName(`role(\"${name}\")`, name);\n\treturn Object.freeze({\n\t\tentityKind: \"role\",\n\t\tname\n\t});\n}\n/**\n* Marks a model's table RLS-controlled, mirroring PSL's `@@rls`. The\n* enablement marker (never the policy set) drives `ENABLE`/`DISABLE ROW\n* LEVEL SECURITY` planning.\n*/\nfunction rlsEnabled(model) {\n\treturn Object.freeze({\n\t\tentityKind: \"rls\",\n\t\trefs: Object.freeze({ target: model })\n\t});\n}\n/** Authors a `FOR SELECT` policy (PSL `policy_select`): row visibility via `using`. */\nfunction policySelect(model, descriptor) {\n\treturn buildPolicyHandle(\"select\", model, descriptor);\n}\n/** Authors a `FOR INSERT` policy (PSL `policy_insert`): new-row validation via `withCheck`. */\nfunction policyInsert(model, descriptor) {\n\treturn buildPolicyHandle(\"insert\", model, descriptor);\n}\n/** Authors a `FOR UPDATE` policy (PSL `policy_update`): takes `using` and `withCheck`. */\nfunction policyUpdate(model, descriptor) {\n\treturn buildPolicyHandle(\"update\", model, descriptor);\n}\n/** Authors a `FOR DELETE` policy (PSL `policy_delete`): row eligibility via `using`. */\nfunction policyDelete(model, descriptor) {\n\treturn buildPolicyHandle(\"delete\", model, descriptor);\n}\n/** Authors a `FOR ALL` policy (PSL `policy_all`): takes `using` and `withCheck`. */\nfunction policyAll(model, descriptor) {\n\treturn buildPolicyHandle(\"all\", model, descriptor);\n}\n//#endregion\nexport { autoincrement, buildSqlContractFromDefinition, check, defineContract, enumType, field, fullTextIndex, member, model, nativeEnum, now, pg, policyAll, policyDelete, policyInsert, policySelect, policyUpdate, rel, rlsEnabled, role, sql };\n\n//# sourceMappingURL=contract-builder.mjs.map"],"mappings":";;;;;;;;;;;;;;;;AAgBA,SAAS,eAAe,YAAY,SAAS;CAC5C,MAAM,aAAa,OAAO,OAAO,WAAW,cAAc,CAAC,CAAC;CAC5D,MAAM,iBAAiB,WAAW,kBAAkB,kBAAkB,CAAC,iBAAiB,GAAG,UAAU,CAAC,CAAC,CAAC;CACxG,MAAM,QAAQ;EACb,GAAG;EACH,iBAAiB;EACjB,a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OAAO,kBAAkB,UAAU,OAAO,UAAU;AACrD;;AAEA,SAAS,aAAa,OAAO,YAAY;CACxC,OAAO,kBAAkB,UAAU,OAAO,UAAU;AACrD;;AAEA,SAAS,aAAa,OAAO,YAAY;CACxC,OAAO,kBAAkB,UAAU,OAAO,UAAU;AACrD;;AAEA,SAAS,aAAa,OAAO,YAAY;CACxC,OAAO,kBAAkB,UAAU,OAAO,UAAU;AACrD;;AAEA,SAAS,UAAU,OAAO,YAAY;CACrC,OAAO,kBAAkB,OAAO,OAAO,UAAU;AAClD"}
@@ -1,4 +1,4 @@
1
- import { n as PostgresStaticContext, r as PostgresTargetId, t as NamespacedNativeEnums } from "./postgres-static-Q_C_AoOf-DNC79LUR.mjs";
1
+ import { n as PostgresStaticContext, r as PostgresTargetId, t as NamespacedNativeEnums } from "./postgres-static-Crd_bF1a-DLqHzv91.mjs";
2
2
  import { BindSiteParams, Declaration, ParamsFromDeclaration, Runtime, SqlExecutionStackWithDriver, SqlMiddleware, SqlRuntimeExtensionDescriptor, TransactionContext, VerifyMarkerOption } from "@prisma/orm-family-sql/runtime";
3
3
  import { PreparedFrom, orm } from "@prisma/orm-family-sql/orm-client";
4
4
  import { NamespacedEnums } from "@prisma/orm-framework/contract/enum-accessor";
@@ -8,7 +8,7 @@ import { ExtractCodecTypes, SqlStorage } from "@prisma/orm-family-sql/contract/t
8
8
  import { Db } from "@prisma/orm-family-sql/builder/types";
9
9
  import { CodecTypesBase } from "@prisma/orm-family-sql/relational-core/expression";
10
10
  import { Preparable, SqlQueryPlan } from "@prisma/orm-family-sql/relational-core/plan";
11
- //#region ../../../3-extensions/postgres/dist/postgres-options-2XQhW8Fe.d.mts
11
+ //#region ../../../3-extensions/postgres/dist/postgres-options-BX1KZFGn.d.mts
12
12
  //#region src/runtime/postgres-members.d.ts
13
13
  type OrmClient<TContract extends Contract<SqlStorage>> = ReturnType<typeof orm<TContract>>;
14
14
  interface PostgresTransactionContext<TContract extends Contract<SqlStorage>> extends TransactionContext {
@@ -52,4 +52,4 @@ interface PostgresExecutionOptions {
52
52
  }
53
53
  //#endregion
54
54
  export { PostgresStaticMembers as a, PostgresRuntimeBoundMembers as i, PostgresExecutionOptions as n, PostgresLifecycleMembers as r, PostgresCursorOptions as t };
55
- //# sourceMappingURL=postgres-options-2XQhW8Fe-C3jEHTDJ.d.mts.map
55
+ //# sourceMappingURL=postgres-options-BX1KZFGn-BKLDkV4w.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"postgres-options-2XQhW8Fe-C3jEHTDJ.d.mts","names":[],"sources":["../../../../3-extensions/postgres/dist/postgres-options-2XQhW8Fe.d.mts"],"mappings":";;;;;;;;;;;;KAWK,UAAU,kBAAkB,SAAS,eAAe,kBAAkB,IAAI;UACrE,2BAA2B,kBAAkB,SAAS,qBAAqB;WAC1E,KAAK,GAAG;WACR,KAAK,UAAU;WACf,OAAO,gBAAgB;WACvB,aAAa,sBAAsB;;UAEpC,sBAAsB,kBAAkB,SAAS,qBAAqB,sBAAsB;WAC3F,OAAO,4BAA4B;;UAEpC,4BAA4B,kBAAkB,SAAS;WACtD,KAAK,UAAU;EACxB,WAAW;EACX,YAAY,GAAG,KAAK,IAAI,2BAA2B,eAAe,YAAY,KAAK,QAAQ;EAC3F,QAAQ,UAAU,YAAY,KAAK,UAAU,eAAe,8BAA8B,WAAW,iBAAiB,kBAAkB,YAAY,aAAa,GAAG,WAAW,QAAQ,eAAe,OAAO,IAAI,QAAQ,aAAa,sBAAsB,GAAG,KAAK;;UAE5P;EACR,SAAS;GACR,OAAO,iBAAiB;;;;;;;;;UASjB;WACC;;;;;;UAMD;WACC,sBAAsB,8BAA8B;WACpD,sBAAsB;WACtB,eAAe;WACf,SAAS"}
1
+ {"version":3,"file":"postgres-options-BX1KZFGn-BKLDkV4w.d.mts","names":[],"sources":["../../../../3-extensions/postgres/dist/postgres-options-BX1KZFGn.d.mts"],"mappings":";;;;;;;;;;;;KAWK,UAAU,kBAAkB,SAAS,eAAe,kBAAkB,IAAI;UACrE,2BAA2B,kBAAkB,SAAS,qBAAqB;WAC1E,KAAK,GAAG;WACR,KAAK,UAAU;WACf,OAAO,gBAAgB;WACvB,aAAa,sBAAsB;;UAEpC,sBAAsB,kBAAkB,SAAS,qBAAqB,sBAAsB;WAC3F,OAAO,4BAA4B;;UAEpC,4BAA4B,kBAAkB,SAAS;WACtD,KAAK,UAAU;EACxB,WAAW;EACX,YAAY,GAAG,KAAK,IAAI,2BAA2B,eAAe,YAAY,KAAK,QAAQ;EAC3F,QAAQ,UAAU,YAAY,KAAK,UAAU,eAAe,8BAA8B,WAAW,iBAAiB,kBAAkB,YAAY,aAAa,GAAG,WAAW,QAAQ,eAAe,OAAO,IAAI,QAAQ,aAAa,sBAAsB,GAAG,KAAK;;UAE5P;EACR,SAAS;GACR,OAAO,iBAAiB;;;;;;;;;UASjB;WACC;;;;;;UAMD;WACC,sBAAsB,8BAA8B;WACpD,sBAAsB;WACtB,eAAe;WACf,SAAS"}
@@ -4,9 +4,9 @@ import { Contract } from "@prisma/orm-framework/contract/types";
4
4
  import { SqlStorage } from "@prisma/orm-family-sql/contract/types";
5
5
  import { Db, RawLane } from "@prisma/orm-family-sql/builder/types";
6
6
  import "@prisma/orm-family-sql/relational-core/expression";
7
- //#region ../../../3-extensions/postgres/dist/postgres-static-Q_C_AoOf.d.mts
7
+ //#region ../../../3-extensions/postgres/dist/postgres-static-Crd_bF1a.d.mts
8
8
  //#region src/runtime/native-enums.d.ts
9
- declare function buildNamespacedNativeEnums(storage: SqlStorage): Record<string, Record<string, EnumAccessor>>;
9
+ declare function buildNamespacedNativeEnums(storage: SqlStorage, domain: Contract['domain']): Record<string, Record<string, EnumAccessor>>;
10
10
  type Present<T> = Exclude<T, undefined>;
11
11
  type NamespaceValueSetEntries<TNs> = TNs extends {
12
12
  readonly entries: {
@@ -29,16 +29,14 @@ type ValueSetMembers<Values extends readonly unknown[]> = { readonly [I in keyof
29
29
  type ValueSetToEnumEntry<Entry extends ValueSetEntry> = {
30
30
  readonly members: ValueSetMembers<Entry['values']>;
31
31
  };
32
- type ValueSetEntriesToEnumEntries<Entries> = { readonly [K in keyof Entries]: Entries[K] extends ValueSetEntry ? ValueSetToEnumEntry<Entries[K]> : never; };
32
+ type ValueSetEntriesToEnumEntries<Entries, DomainEnumNames> = { readonly [K in keyof Entries as Exclude<K, DomainEnumNames>]: Entries[K] extends ValueSetEntry ? ValueSetToEnumEntry<Entries[K]> : never; };
33
+ type DomainEnumNames<TContract extends Contract, Ns> = Ns extends keyof TContract['domain']['namespaces'] ? TContract['domain']['namespaces'][Ns] extends {
34
+ readonly enum?: infer E;
35
+ } ? string extends keyof Present<E> ? never : keyof Present<E> : never : never;
33
36
  /**
34
- * Accessor type for `db.nativeEnums`. Types off the namespace's `valueSet`
35
- * entries — the same generic surface that types `db.enums` and column value
36
- * unions — not a raw `native_enum` entity slot; `contract.d.ts` no longer
37
- * emits one. For a no-emit (`typeof contract`) contract the storage type is
38
- * non-literal and this degrades to the structural shape — the same
39
- * emit/no-emit boundary column typing has (TML-2960).
37
+ * Accessor type for `db.nativeEnums`. Types off the namespace's `valueSet` entries, the same surface that types column value unions, leaving out each one the namespace's domain `enum` entries name, as the runtime does. For a no-emit (`typeof contract`) contract the storage type is non-literal and this degrades to the structural shape, the same emit/no-emit boundary column typing has (TML-2960).
40
38
  */
41
- type NamespacedNativeEnums<TContract extends Contract> = { readonly [Ns in keyof TContract['storage']['namespaces']]: EnumEntriesToAccessors<ValueSetEntriesToEnumEntries<NamespaceValueSetEntries<TContract['storage']['namespaces'][Ns]>>>; };
39
+ type NamespacedNativeEnums<TContract extends Contract> = { readonly [Ns in keyof TContract['storage']['namespaces']]: EnumEntriesToAccessors<ValueSetEntriesToEnumEntries<NamespaceValueSetEntries<TContract['storage']['namespaces'][Ns]>, DomainEnumNames<TContract, Ns>>>; };
42
40
  //#endregion
43
41
  //#region src/runtime/postgres-target-id.d.ts
44
42
  type PostgresTargetId = 'postgres';
@@ -58,4 +56,4 @@ declare function postgresStatic<TContract extends Contract<SqlStorage>>(options:
58
56
  }): PostgresStaticContext<TContract>;
59
57
  //#endregion
60
58
  export { postgresStatic as a, buildNamespacedNativeEnums as i, PostgresStaticContext as n, PostgresTargetId as r, NamespacedNativeEnums as t };
61
- //# sourceMappingURL=postgres-static-Q_C_AoOf-DNC79LUR.d.mts.map
59
+ //# sourceMappingURL=postgres-static-Crd_bF1a-DLqHzv91.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres-static-Crd_bF1a-DLqHzv91.d.mts","names":[],"sources":["../../../../3-extensions/postgres/dist/postgres-static-Crd_bF1a.d.mts"],"mappings":";;;;;;;;iBAOiB,2BAA2B,SAAS,YAAY,QAAQ,qBAAqB,eAAe,eAAe;KACvH,QAAQ,KAAK,QAAQ;KACrB,yBAAyB,OAAO;WAC1B;aACE,iBAAiB;;oBAEV,IAAI,uBAAuB,QAAQ,KAAK;KACvD;WACM;;KAEN,gBAAgB,iDAAiD,WAAW;WACtE,MAAM,QAAQ,OAAO;WACrB,OAAO,OAAO;;;;;;;;KAQpB,oBAAoB,cAAc;WAC5B,SAAS,gBAAgB;;KAE/B,6BAA6B,SAAS,+BAA+B,WAAW,WAAW,QAAQ,GAAG,mBAAmB,QAAQ,WAAW,gBAAgB,oBAAoB,QAAQ;KACxL,gBAAgB,kBAAkB,UAAU,MAAM,iBAAiB,oCAAoC,kCAAkC;WACnI,aAAa;yBACC,QAAQ,mBAAmB,QAAQ;;;;KAIvD,sBAAsB,kBAAkB,wBAAwB,YAAY,qCAAqC,uBAAuB,6BAA6B,yBAAyB,mCAAmC,MAAM,gBAAgB,WAAW;;;KAGlQ;;;UAGK,sBAAsB,kBAAkB,SAAS;WAChD,SAAS,iBAAiB;WAC1B,UAAU;WACV,OAAO,gBAAgB;WACvB,aAAa,sBAAsB;WACnC,KAAK,GAAG;WACR,KAAK,QAAQ;;iBAEP,eAAe,kBAAkB,SAAS,aAAa;WAC7D;WACA,sBAAsB,8BAA8B;IAC3D,sBAAsB"}
@@ -5,37 +5,30 @@ import postgresTarget, { PostgresContractSerializer } from "@prisma/orm-target-p
5
5
  import { createRawLane, sql } from "@prisma/orm-family-sql/builder/runtime";
6
6
  import { buildNamespacedEnums, createEnumAccessor } from "@prisma/orm-framework/contract/enum-accessor";
7
7
  import postgresAdapter from "@prisma/orm-target-postgres/adapter/runtime";
8
- //#region ../../../3-extensions/postgres/dist/postgres-static-Das4il9X.mjs
8
+ //#region ../../../3-extensions/postgres/dist/postgres-static-DzefaBeX.mjs
9
9
  /**
10
- * Reads the namespace's `valueSet` entries directly off the plain contract
11
- * shape (`storage.namespaces[id].entries.valueSet`), not through a hydrated
12
- * `PostgresSchema` class instance — the same plain-data path `db.enums`
13
- * reads `domain.namespaces[id].enum` through. Works on a `validateContract`'d
14
- * JSON contract as well as one produced by `PostgresContractSerializer`.
15
- *
16
- * A native enum is never re-emitted as its own entity: once `native_enum` is
17
- * lowered, its member values live on in the `valueSet` entry it derives (the
18
- * SQL family's generic `deriveValueSet` mechanism) — the same slot
19
- * `column.valueSet`-typed columns read. A member is a value, not a
20
- * name→value pair (matching `CREATE TYPE … AS ENUM ('a', 'b')`), so each
21
- * value doubles as its own accessor name.
10
+ * The accessors for one namespace's value sets, leaving out each value set whose name is a domain enum's in the same namespace: a domain enum's value set takes its enum's name and namespace, and `db.enums` holds that enum. The rest are native enum types, because `native_enum` is the only pack entity that derives a value set today. Reads plain contract data, so a `validateContract`'d JSON contract works as well as a hydrated one. A member is a value, as in `CREATE TYPE … AS ENUM ('a', 'b')`, so each value is also its own name.
22
11
  */
23
- function buildNativeEnumsMapForNamespace(storage, namespaceId) {
12
+ function buildNativeEnumsMapForNamespace(storage, domain, namespaceId) {
24
13
  const result = {};
25
14
  const valueSets = storage.namespaces[namespaceId]?.entries.valueSet;
26
15
  if (!valueSets) return result;
27
- for (const [name, valueSet] of Object.entries(valueSets)) result[name] = createEnumAccessor({
28
- codecId: PG_ENUM_CODEC_ID,
29
- members: valueSet.values.map((value) => ({
30
- name: String(value),
31
- value
32
- }))
33
- });
16
+ const domainEnums = domain.namespaces[namespaceId]?.enum ?? {};
17
+ for (const [name, valueSet] of Object.entries(valueSets)) {
18
+ if (Object.hasOwn(domainEnums, name)) continue;
19
+ result[name] = createEnumAccessor({
20
+ codecId: PG_ENUM_CODEC_ID,
21
+ members: valueSet.values.map((value) => ({
22
+ name: String(value),
23
+ value
24
+ }))
25
+ });
26
+ }
34
27
  return result;
35
28
  }
36
- function buildNamespacedNativeEnums(storage) {
29
+ function buildNamespacedNativeEnums(storage, domain) {
37
30
  const result = {};
38
- for (const namespaceId of Object.keys(storage.namespaces)) result[namespaceId] = buildNativeEnumsMapForNamespace(storage, namespaceId);
31
+ for (const namespaceId of Object.keys(storage.namespaces)) result[namespaceId] = buildNativeEnumsMapForNamespace(storage, domain, namespaceId);
39
32
  return result;
40
33
  }
41
34
  function buildPostgresStaticContext(context, rawCodecInferer) {
@@ -48,7 +41,7 @@ function buildPostgresStaticContext(context, rawCodecInferer) {
48
41
  rawCodecInferer
49
42
  });
50
43
  const enums = Object.freeze(buildNamespacedEnums(context.contract.domain, (codecId) => context.contractCodecs.forCodecRef({ codecId })));
51
- const nativeEnums = blindCast(Object.freeze(buildNamespacedNativeEnums(context.contract.storage)));
44
+ const nativeEnums = blindCast(Object.freeze(buildNamespacedNativeEnums(context.contract.storage, context.contract.domain)));
52
45
  return {
53
46
  context,
54
47
  contract: context.contract,
@@ -73,4 +66,4 @@ function postgresStatic(options) {
73
66
  //#endregion
74
67
  export { buildPostgresStaticContext as n, postgresStatic as r, buildNamespacedNativeEnums as t };
75
68
 
76
- //# sourceMappingURL=postgres-static-Das4il9X-CUGTqJra.mjs.map
69
+ //# sourceMappingURL=postgres-static-DzefaBeX-Cz36Sz8Q.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres-static-DzefaBeX-Cz36Sz8Q.mjs","names":[],"sources":["../../../../3-extensions/postgres/dist/postgres-static-DzefaBeX.mjs"],"sourcesContent":["import { PG_ENUM_CODEC_ID } from \"@internal/target-postgres/codec-ids\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { buildNamespacedEnums, createEnumAccessor } from \"@internal/contract/enum-accessor\";\nimport postgresAdapter from \"@internal/adapter-postgres/runtime\";\nimport { createExecutionContext, createSqlExecutionStack } from \"@internal/sql-runtime\";\nimport postgresTarget, { PostgresContractSerializer } from \"@internal/target-postgres/runtime\";\nimport { createRawLane, sql } from \"@internal/sql-builder/runtime\";\n//#region src/runtime/native-enums.ts\n/**\n* The accessors for one namespace's value sets, leaving out each value set whose name is a domain enum's in the same namespace: a domain enum's value set takes its enum's name and namespace, and `db.enums` holds that enum. The rest are native enum types, because `native_enum` is the only pack entity that derives a value set today. Reads plain contract data, so a `validateContract`'d JSON contract works as well as a hydrated one. A member is a value, as in `CREATE TYPE … AS ENUM ('a', 'b')`, so each value is also its own name.\n*/\nfunction buildNativeEnumsMapForNamespace(storage, domain, namespaceId) {\n\tconst result = {};\n\tconst valueSets = storage.namespaces[namespaceId]?.entries.valueSet;\n\tif (!valueSets) return result;\n\tconst domainEnums = domain.namespaces[namespaceId]?.enum ?? {};\n\tfor (const [name, valueSet] of Object.entries(valueSets)) {\n\t\tif (Object.hasOwn(domainEnums, name)) continue;\n\t\tresult[name] = createEnumAccessor({\n\t\t\tcodecId: PG_ENUM_CODEC_ID,\n\t\t\tmembers: valueSet.values.map((value) => ({\n\t\t\t\tname: String(value),\n\t\t\t\tvalue\n\t\t\t}))\n\t\t});\n\t}\n\treturn result;\n}\nfunction buildNamespacedNativeEnums(storage, domain) {\n\tconst result = {};\n\tfor (const namespaceId of Object.keys(storage.namespaces)) result[namespaceId] = buildNativeEnumsMapForNamespace(storage, domain, namespaceId);\n\treturn result;\n}\n//#endregion\n//#region src/static/postgres-static.ts\nfunction buildPostgresStaticContext(context, rawCodecInferer) {\n\tconst sqlDb = sql({\n\t\tcontext,\n\t\trawCodecInferer\n\t});\n\tconst raw = createRawLane({\n\t\tcontext,\n\t\trawCodecInferer\n\t});\n\tconst enums = Object.freeze(buildNamespacedEnums(context.contract.domain, (codecId) => context.contractCodecs.forCodecRef({ codecId })));\n\tconst nativeEnums = blindCast(Object.freeze(buildNamespacedNativeEnums(context.contract.storage, context.contract.domain)));\n\treturn {\n\t\tcontext,\n\t\tcontract: context.contract,\n\t\tenums,\n\t\tnativeEnums,\n\t\tsql: sqlDb,\n\t\traw\n\t};\n}\nfunction postgresStatic(options) {\n\tconst contract = blindCast(new PostgresContractSerializer().deserializeContract(options.contractJson));\n\tconst stack = createSqlExecutionStack({\n\t\ttarget: postgresTarget,\n\t\tadapter: postgresAdapter,\n\t\textensions: options.extensions ?? []\n\t});\n\treturn buildPostgresStaticContext(createExecutionContext({\n\t\tcontract,\n\t\tstack\n\t}), stack.adapter.rawCodecInferer);\n}\n//#endregion\nexport { postgresStatic as n, buildNamespacedNativeEnums as r, buildPostgresStaticContext as t };\n\n//# sourceMappingURL=postgres-static-DzefaBeX.mjs.map"],"mappings":";;;;;;;;;;;AAWA,SAAS,gCAAgC,SAAS,QAAQ,aAAa;CACtE,MAAM,SAAS,CAAC;CAChB,MAAM,YAAY,QAAQ,WAAW,YAAY,EAAE,QAAQ;CAC3D,IAAI,CAAC,WAAW,OAAO;CACvB,MAAM,cAAc,OAAO,WAAW,YAAY,EAAE,QAAQ,CAAC;CAC7D,KAAK,MAAM,CAAC,MAAM,aAAa,OAAO,QAAQ,SAAS,GAAG;EACzD,IAAI,OAAO,OAAO,aAAa,IAAI,GAAG;EACtC,OAAO,QAAQ,mBAAmB;GACjC,SAAS;GACT,SAAS,SAAS,OAAO,KAAK,WAAW;IACxC,MAAM,OAAO,KAAK;IAClB;GACD,EAAE;EACH,CAAC;CACF;CACA,OAAO;AACR;AACA,SAAS,2BAA2B,SAAS,QAAQ;CACpD,MAAM,SAAS,CAAC;CAChB,KAAK,MAAM,eAAe,OAAO,KAAK,QAAQ,UAAU,GAAG,OAAO,eAAe,gCAAgC,SAAS,QAAQ,WAAW;CAC7I,OAAO;AACR;AAGA,SAAS,2BAA2B,SAAS,iBAAiB;CAC7D,MAAM,QAAQ,IAAI;EACjB;EACA;CACD,CAAC;CACD,MAAM,MAAM,cAAc;EACzB;EACA;CACD,CAAC;CACD,MAAM,QAAQ,OAAO,OAAO,qBAAqB,QAAQ,SAAS,SAAS,YAAY,QAAQ,eAAe,YAAY,EAAE,QAAQ,CAAC,CAAC,CAAC;CACvI,MAAM,cAAc,UAAU,OAAO,OAAO,2BAA2B,QAAQ,SAAS,SAAS,QAAQ,SAAS,MAAM,CAAC,CAAC;CAC1H,OAAO;EACN;EACA,UAAU,QAAQ;EAClB;EACA;EACA,KAAK;EACL;CACD;AACD;AACA,SAAS,eAAe,SAAS;CAChC,MAAM,WAAW,UAAU,IAAI,2BAA2B,CAAC,CAAC,oBAAoB,QAAQ,YAAY,CAAC;CACrG,MAAM,QAAQ,wBAAwB;EACrC,QAAQ;EACR,SAAS;EACT,YAAY,QAAQ,cAAc,CAAC;CACpC,CAAC;CACD,OAAO,2BAA2B,uBAAuB;EACxD;EACA;CACD,CAAC,GAAG,MAAM,QAAQ,eAAe;AAClC"}
@@ -1,5 +1,5 @@
1
- import { i as buildNamespacedNativeEnums, t as NamespacedNativeEnums } from "./postgres-static-Q_C_AoOf-DNC79LUR.mjs";
2
- import { a as PostgresStaticMembers, i as PostgresRuntimeBoundMembers, n as PostgresExecutionOptions, r as PostgresLifecycleMembers, t as PostgresCursorOptions } from "./postgres-options-2XQhW8Fe-C3jEHTDJ.mjs";
1
+ import { i as buildNamespacedNativeEnums, t as NamespacedNativeEnums } from "./postgres-static-Crd_bF1a-DLqHzv91.mjs";
2
+ import { a as PostgresStaticMembers, i as PostgresRuntimeBoundMembers, n as PostgresExecutionOptions, r as PostgresLifecycleMembers, t as PostgresCursorOptions } from "./postgres-options-BX1KZFGn-BKLDkV4w.mjs";
3
3
  import { Runtime, SqlRuntimeBase } from "@prisma/orm-family-sql/runtime";
4
4
  import { Client, Pool } from "pg";
5
5
  import { Contract } from "@prisma/orm-framework/contract/types";
package/dist/runtime.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { t as postgresError } from "./errors-DfWK9xep-CYOOg0sB.mjs";
2
2
  import { a as isPgPool, c as toDriverCursorOptions, i as isPgClient, l as toRuntimeOptions, n as PostgresRuntimeImpl, o as resolveOptionalPostgresBinding, r as buildPostgresRuntimeBoundMembers, s as resolvePostgresBinding, u as validateCursorOptions } from "./postgres-runtime-B3lGmB9G-Blyx29Cy.mjs";
3
- import { n as buildPostgresStaticContext, t as buildNamespacedNativeEnums } from "./postgres-static-Das4il9X-CUGTqJra.mjs";
3
+ import { n as buildPostgresStaticContext, t as buildNamespacedNativeEnums } from "./postgres-static-DzefaBeX-Cz36Sz8Q.mjs";
4
4
  import { InternalError } from "@prisma/orm-framework/utils/internal-error";
5
5
  import { blindCast } from "@prisma/orm-framework/utils/casts";
6
6
  import { createExecutionContext, createSqlExecutionStack } from "@prisma/orm-family-sql/runtime";
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.mjs","names":[],"sources":["../../../../3-extensions/postgres/dist/runtime.mjs"],"sourcesContent":["import { t as postgresError } from \"./errors-DfWK9xep.mjs\";\nimport { a as validateCursorOptions, c as isPgPool, i as toRuntimeOptions, l as resolveOptionalPostgresBinding, o as buildPostgresRuntimeBoundMembers, r as toDriverCursorOptions, s as isPgClient, t as PostgresRuntimeImpl, u as resolvePostgresBinding } from \"./postgres-runtime-B3lGmB9G.mjs\";\nimport { r as buildNamespacedNativeEnums, t as buildPostgresStaticContext } from \"./postgres-static-Das4il9X.mjs\";\nimport { InternalError } from \"@internal/utils/internal-error\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport postgresAdapter from \"@internal/adapter-postgres/runtime\";\nimport postgresDriver, { suppressIdleConnectionErrors } from \"@internal/driver-postgres/runtime\";\nimport { instantiateExecutionStack } from \"@internal/framework-components/execution\";\nimport { createExecutionContext, createSqlExecutionStack } from \"@internal/sql-runtime\";\nimport postgresTarget, { PostgresContractSerializer } from \"@internal/target-postgres/runtime\";\nimport { Pool } from \"pg\";\n//#region src/runtime/postgres.ts\nfunction hasContractJson(options) {\n\treturn \"contractJson\" in options;\n}\nconst contractSerializer = new PostgresContractSerializer();\nfunction resolveContract(options) {\n\tconst contractJson = hasContractJson(options) ? options.contractJson : contractSerializer.serializeContract(options.contract);\n\treturn blindCast(contractSerializer.deserializeContract(contractJson));\n}\nfunction toRuntimeBinding(binding, options) {\n\tif (binding.kind !== \"url\") return binding;\n\treturn {\n\t\tkind: \"pgPool\",\n\t\tpool: suppressIdleConnectionErrors(new Pool({\n\t\t\tconnectionString: binding.url,\n\t\t\tconnectionTimeoutMillis: options.poolOptions?.connectionTimeoutMillis ?? 2e4,\n\t\t\tidleTimeoutMillis: options.poolOptions?.idleTimeoutMillis ?? 3e4\n\t\t}))\n\t};\n}\nfunction postgres(options) {\n\tconst cursor = validateCursorOptions(options.cursor, \"postgres\");\n\tconst contract = resolveContract(options);\n\tlet binding = resolveOptionalPostgresBinding(options);\n\tconst stack = createSqlExecutionStack({\n\t\ttarget: postgresTarget,\n\t\tadapter: postgresAdapter,\n\t\tdriver: postgresDriver,\n\t\textensions: options.extensions ?? []\n\t});\n\tconst context = createExecutionContext({\n\t\tcontract,\n\t\tstack,\n\t\tdriver: postgresDriver\n\t});\n\tconst { sql, raw: rawSqlTag, enums, nativeEnums } = buildPostgresStaticContext(context, stack.adapter.rawCodecInferer);\n\tlet runtimeInstance;\n\tlet runtimeDriver;\n\tlet driverConnected = false;\n\tlet connectPromise;\n\tlet backgroundConnectError;\n\tlet closePromise;\n\tlet ownsPool = false;\n\tconst connectDriver = async (resolvedBinding) => {\n\t\tif (driverConnected) return;\n\t\tif (!runtimeDriver) throw new InternalError(\"Postgres runtime driver missing\");\n\t\tif (connectPromise) return connectPromise;\n\t\tconst runtimeBinding = toRuntimeBinding(resolvedBinding, options);\n\t\tconst ownedPool = resolvedBinding.kind === \"url\" && runtimeBinding.kind === \"pgPool\" ? runtimeBinding.pool : void 0;\n\t\tconnectPromise = runtimeDriver.connect(runtimeBinding).then(() => {\n\t\t\tdriverConnected = true;\n\t\t\townsPool = ownedPool !== void 0;\n\t\t}).catch(async (err) => {\n\t\t\tbackgroundConnectError = err;\n\t\t\tconnectPromise = void 0;\n\t\t\tawait ownedPool?.end().catch(() => void 0);\n\t\t\tthrow err;\n\t\t});\n\t\treturn connectPromise;\n\t};\n\tconst getRuntime = () => {\n\t\tif (closePromise !== void 0) throw postgresError(\"DRIVER.NOT_CONNECTED\", \"Postgres client is closed\", {\n\t\t\twhy: \"close() was called on this client.\",\n\t\t\tfix: \"Create a new postgres(...) client.\",\n\t\t\tmeta: { extension: \"postgres\" }\n\t\t});\n\t\tif (backgroundConnectError !== void 0) throw backgroundConnectError;\n\t\tif (runtimeInstance) return runtimeInstance;\n\t\tconst stackInstance = instantiateExecutionStack(stack);\n\t\tconst driverDescriptor = stack.driver;\n\t\tif (!driverDescriptor) throw new InternalError(\"Driver descriptor missing from execution stack\");\n\t\tconst driver = driverDescriptor.create({ cursor: toDriverCursorOptions(cursor) });\n\t\truntimeDriver = driver;\n\t\tconst runtime = new PostgresRuntimeImpl({\n\t\t\tcontext,\n\t\t\tadapter: stackInstance.adapter,\n\t\t\tdriver,\n\t\t\t...toRuntimeOptions(options),\n\t\t\tcloseRefusal: \"at-once\"\n\t\t});\n\t\truntimeInstance = runtime;\n\t\tif (binding !== void 0) connectDriver(binding).catch(() => void 0);\n\t\treturn runtime;\n\t};\n\tconst closeOwnedRuntime = async () => {\n\t\tif (!driverConnected) await connectPromise?.catch(() => void 0);\n\t\tif (ownsPool) await runtimeInstance?.close();\n\t};\n\treturn {\n\t\tsql,\n\t\t...buildPostgresRuntimeBoundMembers({\n\t\t\tcontext,\n\t\t\trawCodecInferer: stack.adapter.rawCodecInferer,\n\t\t\tenums,\n\t\t\tnativeEnums,\n\t\t\tgetRuntime,\n\t\t\tgetRuntimeForWork: getRuntime\n\t\t}),\n\t\tenums,\n\t\tnativeEnums,\n\t\traw: rawSqlTag,\n\t\tcontext,\n\t\tcontract,\n\t\tstack,\n\t\tasync connect(bindingInput) {\n\t\t\tif (closePromise !== void 0) throw postgresError(\"DRIVER.NOT_CONNECTED\", \"Postgres client is closed\", {\n\t\t\t\twhy: \"close() was called on this client.\",\n\t\t\t\tfix: \"Create a new postgres(...) client.\",\n\t\t\t\tmeta: { extension: \"postgres\" }\n\t\t\t});\n\t\t\tif (driverConnected || connectPromise) throw postgresError(\"DRIVER.ALREADY_CONNECTED\", \"Postgres client already connected\", {\n\t\t\t\tfix: \"Call connect() at most once per client.\",\n\t\t\t\tmeta: { extension: \"postgres\" }\n\t\t\t});\n\t\t\tif (bindingInput !== void 0) binding = resolvePostgresBinding(bindingInput);\n\t\t\tif (binding === void 0) throw postgresError(\"RUNTIME.BINDING_MISSING\", \"Postgres binding not configured. Pass url/pg/binding to postgres(...) or call db.connect({ ... }).\", { meta: { extension: \"postgres\" } });\n\t\t\tconst runtime = getRuntime();\n\t\t\tif (driverConnected) return runtime;\n\t\t\tawait connectDriver(binding);\n\t\t\treturn runtime;\n\t\t},\n\t\tclose() {\n\t\t\tclosePromise ??= closeOwnedRuntime();\n\t\t\treturn closePromise;\n\t\t},\n\t\t[Symbol.asyncDispose]() {\n\t\t\treturn this.close();\n\t\t}\n\t};\n}\n//#endregion\nexport { PostgresRuntimeImpl, buildNamespacedNativeEnums, postgres as default, isPgClient, isPgPool };\n\n//# sourceMappingURL=runtime.mjs.map"],"mappings":";;;;;;;;;;;;AAYA,SAAS,gBAAgB,SAAS;CACjC,OAAO,kBAAkB;AAC1B;AACA,MAAM,qBAAqB,IAAI,2BAA2B;AAC1D,SAAS,gBAAgB,SAAS;CACjC,MAAM,eAAe,gBAAgB,OAAO,IAAI,QAAQ,eAAe,mBAAmB,kBAAkB,QAAQ,QAAQ;CAC5H,OAAO,UAAU,mBAAmB,oBAAoB,YAAY,CAAC;AACtE;AACA,SAAS,iBAAiB,SAAS,SAAS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G,MAAM,cAAc,2BAA2B,sGAAsG,EAAE,MAAM,EAAE,WAAW,WAAW,EAAE,CAAC;GAChN,MAAM,UAAU,WAAW;GAC3B,IAAI,iBAAiB,OAAO;GAC5B,MAAM,cAAc,OAAO;GAC3B,OAAO;EACR;EACA,QAAQ;GACP,iBAAiB,kBAAkB;GACnC,OAAO;EACR;EACA,CAAC,OAAO,gBAAgB;GACvB,OAAO,KAAK,MAAM;EACnB;CACD;AACD"}
1
+ {"version":3,"file":"runtime.mjs","names":[],"sources":["../../../../3-extensions/postgres/dist/runtime.mjs"],"sourcesContent":["import { t as postgresError } from \"./errors-DfWK9xep.mjs\";\nimport { a as validateCursorOptions, c as isPgPool, i as toRuntimeOptions, l as resolveOptionalPostgresBinding, o as buildPostgresRuntimeBoundMembers, r as toDriverCursorOptions, s as isPgClient, t as PostgresRuntimeImpl, u as resolvePostgresBinding } from \"./postgres-runtime-B3lGmB9G.mjs\";\nimport { r as buildNamespacedNativeEnums, t as buildPostgresStaticContext } from \"./postgres-static-DzefaBeX.mjs\";\nimport { InternalError } from \"@internal/utils/internal-error\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport postgresAdapter from \"@internal/adapter-postgres/runtime\";\nimport postgresDriver, { suppressIdleConnectionErrors } from \"@internal/driver-postgres/runtime\";\nimport { instantiateExecutionStack } from \"@internal/framework-components/execution\";\nimport { createExecutionContext, createSqlExecutionStack } from \"@internal/sql-runtime\";\nimport postgresTarget, { PostgresContractSerializer } from \"@internal/target-postgres/runtime\";\nimport { Pool } from \"pg\";\n//#region src/runtime/postgres.ts\nfunction hasContractJson(options) {\n\treturn \"contractJson\" in options;\n}\nconst contractSerializer = new PostgresContractSerializer();\nfunction resolveContract(options) {\n\tconst contractJson = hasContractJson(options) ? options.contractJson : contractSerializer.serializeContract(options.contract);\n\treturn blindCast(contractSerializer.deserializeContract(contractJson));\n}\nfunction toRuntimeBinding(binding, options) {\n\tif (binding.kind !== \"url\") return binding;\n\treturn {\n\t\tkind: \"pgPool\",\n\t\tpool: suppressIdleConnectionErrors(new Pool({\n\t\t\tconnectionString: binding.url,\n\t\t\tconnectionTimeoutMillis: options.poolOptions?.connectionTimeoutMillis ?? 2e4,\n\t\t\tidleTimeoutMillis: options.poolOptions?.idleTimeoutMillis ?? 3e4\n\t\t}))\n\t};\n}\nfunction postgres(options) {\n\tconst cursor = validateCursorOptions(options.cursor, \"postgres\");\n\tconst contract = resolveContract(options);\n\tlet binding = resolveOptionalPostgresBinding(options);\n\tconst stack = createSqlExecutionStack({\n\t\ttarget: postgresTarget,\n\t\tadapter: postgresAdapter,\n\t\tdriver: postgresDriver,\n\t\textensions: options.extensions ?? []\n\t});\n\tconst context = createExecutionContext({\n\t\tcontract,\n\t\tstack,\n\t\tdriver: postgresDriver\n\t});\n\tconst { sql, raw: rawSqlTag, enums, nativeEnums } = buildPostgresStaticContext(context, stack.adapter.rawCodecInferer);\n\tlet runtimeInstance;\n\tlet runtimeDriver;\n\tlet driverConnected = false;\n\tlet connectPromise;\n\tlet backgroundConnectError;\n\tlet closePromise;\n\tlet ownsPool = false;\n\tconst connectDriver = async (resolvedBinding) => {\n\t\tif (driverConnected) return;\n\t\tif (!runtimeDriver) throw new InternalError(\"Postgres runtime driver missing\");\n\t\tif (connectPromise) return connectPromise;\n\t\tconst runtimeBinding = toRuntimeBinding(resolvedBinding, options);\n\t\tconst ownedPool = resolvedBinding.kind === \"url\" && runtimeBinding.kind === \"pgPool\" ? runtimeBinding.pool : void 0;\n\t\tconnectPromise = runtimeDriver.connect(runtimeBinding).then(() => {\n\t\t\tdriverConnected = true;\n\t\t\townsPool = ownedPool !== void 0;\n\t\t}).catch(async (err) => {\n\t\t\tbackgroundConnectError = err;\n\t\t\tconnectPromise = void 0;\n\t\t\tawait ownedPool?.end().catch(() => void 0);\n\t\t\tthrow err;\n\t\t});\n\t\treturn connectPromise;\n\t};\n\tconst getRuntime = () => {\n\t\tif (closePromise !== void 0) throw postgresError(\"DRIVER.NOT_CONNECTED\", \"Postgres client is closed\", {\n\t\t\twhy: \"close() was called on this client.\",\n\t\t\tfix: \"Create a new postgres(...) client.\",\n\t\t\tmeta: { extension: \"postgres\" }\n\t\t});\n\t\tif (backgroundConnectError !== void 0) throw backgroundConnectError;\n\t\tif (runtimeInstance) return runtimeInstance;\n\t\tconst stackInstance = instantiateExecutionStack(stack);\n\t\tconst driverDescriptor = stack.driver;\n\t\tif (!driverDescriptor) throw new InternalError(\"Driver descriptor missing from execution stack\");\n\t\tconst driver = driverDescriptor.create({ cursor: toDriverCursorOptions(cursor) });\n\t\truntimeDriver = driver;\n\t\tconst runtime = new PostgresRuntimeImpl({\n\t\t\tcontext,\n\t\t\tadapter: stackInstance.adapter,\n\t\t\tdriver,\n\t\t\t...toRuntimeOptions(options),\n\t\t\tcloseRefusal: \"at-once\"\n\t\t});\n\t\truntimeInstance = runtime;\n\t\tif (binding !== void 0) connectDriver(binding).catch(() => void 0);\n\t\treturn runtime;\n\t};\n\tconst closeOwnedRuntime = async () => {\n\t\tif (!driverConnected) await connectPromise?.catch(() => void 0);\n\t\tif (ownsPool) await runtimeInstance?.close();\n\t};\n\treturn {\n\t\tsql,\n\t\t...buildPostgresRuntimeBoundMembers({\n\t\t\tcontext,\n\t\t\trawCodecInferer: stack.adapter.rawCodecInferer,\n\t\t\tenums,\n\t\t\tnativeEnums,\n\t\t\tgetRuntime,\n\t\t\tgetRuntimeForWork: getRuntime\n\t\t}),\n\t\tenums,\n\t\tnativeEnums,\n\t\traw: rawSqlTag,\n\t\tcontext,\n\t\tcontract,\n\t\tstack,\n\t\tasync connect(bindingInput) {\n\t\t\tif (closePromise !== void 0) throw postgresError(\"DRIVER.NOT_CONNECTED\", \"Postgres client is closed\", {\n\t\t\t\twhy: \"close() was called on this client.\",\n\t\t\t\tfix: \"Create a new postgres(...) client.\",\n\t\t\t\tmeta: { extension: \"postgres\" }\n\t\t\t});\n\t\t\tif (driverConnected || connectPromise) throw postgresError(\"DRIVER.ALREADY_CONNECTED\", \"Postgres client already connected\", {\n\t\t\t\tfix: \"Call connect() at most once per client.\",\n\t\t\t\tmeta: { extension: \"postgres\" }\n\t\t\t});\n\t\t\tif (bindingInput !== void 0) binding = resolvePostgresBinding(bindingInput);\n\t\t\tif (binding === void 0) throw postgresError(\"RUNTIME.BINDING_MISSING\", \"Postgres binding not configured. Pass url/pg/binding to postgres(...) or call db.connect({ ... }).\", { meta: { extension: \"postgres\" } });\n\t\t\tconst runtime = getRuntime();\n\t\t\tif (driverConnected) return runtime;\n\t\t\tawait connectDriver(binding);\n\t\t\treturn runtime;\n\t\t},\n\t\tclose() {\n\t\t\tclosePromise ??= closeOwnedRuntime();\n\t\t\treturn closePromise;\n\t\t},\n\t\t[Symbol.asyncDispose]() {\n\t\t\treturn this.close();\n\t\t}\n\t};\n}\n//#endregion\nexport { PostgresRuntimeImpl, buildNamespacedNativeEnums, postgres as default, isPgClient, isPgPool };\n\n//# sourceMappingURL=runtime.mjs.map"],"mappings":";;;;;;;;;;;;AAYA,SAAS,gBAAgB,SAAS;CACjC,OAAO,kBAAkB;AAC1B;AACA,MAAM,qBAAqB,IAAI,2BAA2B;AAC1D,SAAS,gBAAgB,SAAS;CACjC,MAAM,eAAe,gBAAgB,OAAO,IAAI,QAAQ,eAAe,mBAAmB,kBAAkB,QAAQ,QAAQ;CAC5H,OAAO,UAAU,mBAAmB,oBAAoB,YAAY,CAAC;AACtE;AACA,SAAS,iBAAiB,SAAS,SAAS;CAC3C,IAAI,QAAQ,SAAS,OAAO,OAAO;CACnC,OAAO;EACN,MAAM;EACN,MAAM,6BAA6B,IAAI,KAAK;GAC3C,kBAAkB,QAAQ;GAC1B,yBAAyB,QAAQ,aAAa,2BAA2B;GACzE,mBAAmB,QAAQ,aAAa,qBAAqB;EAC9D,CAAC,CAAC;CACH;AACD;AACA,SAAS,SAAS,SAAS;CAC1B,MAAM,SAAS,sBAAsB,QAAQ,QAAQ,UAAU;CAC/D,MAAM,WAAW,gBAAgB,OAAO;CACxC,IAAI,UAAU,+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undMembers, n as PostgresExecutionOptions, r as PostgresLifecycleMembers, t as PostgresCursorOptions } from "./postgres-options-2XQhW8Fe-C3jEHTDJ.mjs";
1
+ import { a as PostgresStaticMembers, i as PostgresRuntimeBoundMembers, n as PostgresExecutionOptions, r as PostgresLifecycleMembers, t as PostgresCursorOptions } from "./postgres-options-BX1KZFGn-BKLDkV4w.mjs";
2
2
  import { Contract } from "@prisma/orm-framework/contract/types";
3
3
  import { SqlStorage } from "@prisma/orm-family-sql/contract/types";
4
4
  //#region ../../../3-extensions/postgres/dist/serverless.d.mts
@@ -1,6 +1,6 @@
1
1
  import { t as postgresError } from "./errors-DfWK9xep-CYOOg0sB.mjs";
2
2
  import { c as toDriverCursorOptions, d as validatePostgresUrl, l as toRuntimeOptions, n as PostgresRuntimeImpl, r as buildPostgresRuntimeBoundMembers, t as DEFAULT_CONNECT_TIMEOUT_MILLIS, u as validateCursorOptions } from "./postgres-runtime-B3lGmB9G-Blyx29Cy.mjs";
3
- import { n as buildPostgresStaticContext } from "./postgres-static-Das4il9X-CUGTqJra.mjs";
3
+ import { n as buildPostgresStaticContext } from "./postgres-static-DzefaBeX-Cz36Sz8Q.mjs";
4
4
  import { InternalError } from "@prisma/orm-framework/utils/internal-error";
5
5
  import { blindCast } from "@prisma/orm-framework/utils/casts";
6
6
  import { createExecutionContext, createSqlExecutionStack } from "@prisma/orm-family-sql/runtime";
@@ -1 +1 @@
1
- {"version":3,"file":"serverless.mjs","names":[],"sources":["../../../../3-extensions/postgres/dist/serverless.mjs"],"sourcesContent":["import { t as postgresError } from \"./errors-DfWK9xep.mjs\";\nimport { a as validateCursorOptions, d as validatePostgresUrl, i as toRuntimeOptions, n as DEFAULT_CONNECT_TIMEOUT_MILLIS, o as buildPostgresRuntimeBoundMembers, r as toDriverCursorOptions, t as PostgresRuntimeImpl } from \"./postgres-runtime-B3lGmB9G.mjs\";\nimport { t as buildPostgresStaticContext } from \"./postgres-static-Das4il9X.mjs\";\nimport { InternalError } from \"@internal/utils/internal-error\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport postgresAdapter from \"@internal/adapter-postgres/runtime\";\nimport postgresDriver, { suppressIdleConnectionErrors } from \"@internal/driver-postgres/runtime\";\nimport { instantiateExecutionStack } from \"@internal/framework-components/execution\";\nimport { createExecutionContext, createSqlExecutionStack } from \"@internal/sql-runtime\";\nimport postgresTarget, { PostgresContractSerializer } from \"@internal/target-postgres/runtime\";\nimport { Client } from \"pg\";\nimport { redactDatabaseUrl } from \"@internal/utils/redact-db-url\";\n//#region src/runtime/postgres-serverless.ts\nfunction hasContractJson(options) {\n\treturn \"contractJson\" in options;\n}\nconst contractSerializer = new PostgresContractSerializer();\nfunction resolveContract(options) {\n\tconst contractJson = hasContractJson(options) ? options.contractJson : contractSerializer.serializeContract(options.contract);\n\treturn blindCast(contractSerializer.deserializeContract(contractJson));\n}\nfunction closedConnectionError() {\n\treturn postgresError(\"DRIVER.NOT_CONNECTED\", \"Postgres connection is closed\", {\n\t\twhy: \"close() was called on this connection, or the await using scope that held it has ended.\",\n\t\tfix: \"Call connect({ url }) again to open a new connection.\",\n\t\tmeta: { extension: \"postgres\" }\n\t});\n}\nfunction connectionFailedError(url, cause) {\n\treturn postgresError(\"DRIVER.CONNECTION_FAILED\", \"Database connection failed\", {\n\t\twhy: cause instanceof Error ? cause.message : String(cause),\n\t\tfix: \"Verify the database URL, ensure the database is reachable, and confirm credentials/permissions\",\n\t\tmeta: {\n\t\t\textension: \"postgres\",\n\t\t\t...redactDatabaseUrl(url)\n\t\t},\n\t\tcause\n\t});\n}\nfunction postgresServerless(options) {\n\tconst cursor = validateCursorOptions(options.cursor, \"postgresServerless\");\n\tconst contract = resolveContract(options);\n\tconst stack = createSqlExecutionStack({\n\t\ttarget: postgresTarget,\n\t\tadapter: postgresAdapter,\n\t\tdriver: postgresDriver,\n\t\textensions: options.extensions ?? []\n\t});\n\tconst context = createExecutionContext({\n\t\tcontract,\n\t\tstack,\n\t\tdriver: postgresDriver\n\t});\n\tconst rawCodecInferer = stack.adapter.rawCodecInferer;\n\tconst { sql, raw, enums, nativeEnums } = buildPostgresStaticContext(context, rawCodecInferer);\n\tconst buildRuntimeBoundMembers = (getRuntime, getRuntimeForWork) => buildPostgresRuntimeBoundMembers({\n\t\tcontext,\n\t\trawCodecInferer,\n\t\tenums,\n\t\tnativeEnums,\n\t\tgetRuntime,\n\t\tgetRuntimeForWork\n\t});\n\tconst noRuntime = () => {\n\t\tthrow new InternalError(\"The serverless client has no runtime\");\n\t};\n\tbuildRuntimeBoundMembers(noRuntime, noRuntime);\n\tconst createConnection = (runtime) => {\n\t\tlet closing;\n\t\tconst close = () => {\n\t\t\tclosing ??= runtime.close();\n\t\t\treturn closing;\n\t\t};\n\t\tconst runtimeBoundMembers = buildRuntimeBoundMembers(() => {\n\t\t\tif (closing !== void 0) throw closedConnectionError();\n\t\t\treturn runtime;\n\t\t}, () => runtime);\n\t\treturn {\n\t\t\tsql,\n\t\t\traw,\n\t\t\tenums,\n\t\t\tnativeEnums,\n\t\t\tcontext,\n\t\t\tcontract,\n\t\t\tstack,\n\t\t\t...runtimeBoundMembers,\n\t\t\tclose,\n\t\t\t[Symbol.asyncDispose]: close\n\t\t};\n\t};\n\treturn {\n\t\tsql,\n\t\traw,\n\t\tenums,\n\t\tnativeEnums,\n\t\tcontext,\n\t\tstack,\n\t\tcontract,\n\t\tasync connect(binding) {\n\t\t\tconst url = validatePostgresUrl(binding.url);\n\t\t\tconst driverDescriptor = stack.driver;\n\t\t\tif (!driverDescriptor) throw new InternalError(\"Driver descriptor missing from execution stack\");\n\t\t\tconst stackInstance = instantiateExecutionStack(stack);\n\t\t\tconst driver = driverDescriptor.create({ cursor: toDriverCursorOptions(cursor) });\n\t\t\tconst pgClient = suppressIdleConnectionErrors(new Client({\n\t\t\t\tconnectionString: url,\n\t\t\t\tconnectionTimeoutMillis: DEFAULT_CONNECT_TIMEOUT_MILLIS\n\t\t\t}));\n\t\t\tawait driver.connect({\n\t\t\t\tkind: \"pgClient\",\n\t\t\t\tclient: pgClient\n\t\t\t});\n\t\t\tconst runtime = new PostgresRuntimeImpl({\n\t\t\t\tcontext,\n\t\t\t\tadapter: stackInstance.adapter,\n\t\t\t\tdriver,\n\t\t\t\t...toRuntimeOptions(options),\n\t\t\t\tcloseRefusal: \"when-idle\"\n\t\t\t});\n\t\t\tconst connection = createConnection(runtime);\n\t\t\ttry {\n\t\t\t\tawait (await driver.acquireConnection()).release();\n\t\t\t} catch (err) {\n\t\t\t\tpgClient.end().catch(() => void 0);\n\t\t\t\tthrow connectionFailedError(url, err);\n\t\t\t}\n\t\t\treturn connection;\n\t\t}\n\t};\n}\n//#endregion\nexport { postgresServerless as default };\n\n//# sourceMappingURL=serverless.mjs.map"],"mappings":";;;;;;;;;;;;;AAaA,SAAS,gBAAgB,SAAS;CACjC,OAAO,kBAAkB;AAC1B;AACA,MAAM,qBAAqB,IAAI,2BAA2B;AAC1D,SAAS,gBAAgB,SAAS;CACjC,MAAM,eAAe,gBAAgB,OAAO,IAAI,QAAQ,eAAe,mBAAmB,kBAAkB,QAAQ,QAAQ;CAC5H,OAAO,UAAU,mBAAmB,oBAAoB,YAAY,CAAC;AACtE;AACA,SAAS,wBAAwB;CAChC,OAAO,cAAc,wBAAwB,iCAAiC;EAC7E,KAAK;EACL,KAAK;EACL,MAAM,EAAE,WAAW,WAAW;CAC/B,CAAC;AACF;AACA,SAAS,sBAAsB,KAAK,OAAO;CAC1C,OAAO,cAAc,4BAA4B,8BAA8B;EAC9E,KAAK,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;EAC1D,KAAK;EACL,MAAM;GACL,WAAW;GACX,GAAG,kBAAkB,GAAG;EACzB;EACA;CACD,CAAC;AACF;AACA,SAAS,mBAAmB,SAAS;CACpC,MAAM,SAAS,sBAAsB,QAAQ,QAAQ,oBAAoB;CACzE,MAAM,WAAW,gBAAgB,OAAO;CACxC,MAAM,QAAQ,wBAAwB;EACrC,QAAQ;EACR,SAAS;EACT,QAAQ;E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AAiB,OAAO;GAC3C,IAAI;IACH,OAAO,MAAM,OAAO,kBAAkB,EAAA,CAAG,QAAQ;GAClD,SAAS,KAAK;IACb,SAAS,IAAI,CAAC,CAAC,YAAY,KAAK,CAAC;IACjC,MAAM,sBAAsB,KAAK,GAAG;GACrC;GACA,OAAO;EACR;CACD;AACD"}
1
+ {"version":3,"file":"serverless.mjs","names":[],"sources":["../../../../3-extensions/postgres/dist/serverless.mjs"],"sourcesContent":["import { t as postgresError } from \"./errors-DfWK9xep.mjs\";\nimport { a as validateCursorOptions, d as validatePostgresUrl, i as toRuntimeOptions, n as DEFAULT_CONNECT_TIMEOUT_MILLIS, o as buildPostgresRuntimeBoundMembers, r as toDriverCursorOptions, t as PostgresRuntimeImpl } from \"./postgres-runtime-B3lGmB9G.mjs\";\nimport { t as buildPostgresStaticContext } from \"./postgres-static-DzefaBeX.mjs\";\nimport { InternalError } from \"@internal/utils/internal-error\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport postgresAdapter from \"@internal/adapter-postgres/runtime\";\nimport postgresDriver, { suppressIdleConnectionErrors } from \"@internal/driver-postgres/runtime\";\nimport { instantiateExecutionStack } from \"@internal/framework-components/execution\";\nimport { createExecutionContext, createSqlExecutionStack } from \"@internal/sql-runtime\";\nimport postgresTarget, { PostgresContractSerializer } from \"@internal/target-postgres/runtime\";\nimport { Client } from \"pg\";\nimport { redactDatabaseUrl } from \"@internal/utils/redact-db-url\";\n//#region src/runtime/postgres-serverless.ts\nfunction hasContractJson(options) {\n\treturn \"contractJson\" in options;\n}\nconst contractSerializer = new PostgresContractSerializer();\nfunction resolveContract(options) {\n\tconst contractJson = hasContractJson(options) ? options.contractJson : contractSerializer.serializeContract(options.contract);\n\treturn blindCast(contractSerializer.deserializeContract(contractJson));\n}\nfunction closedConnectionError() {\n\treturn postgresError(\"DRIVER.NOT_CONNECTED\", \"Postgres connection is closed\", {\n\t\twhy: \"close() was called on this connection, or the await using scope that held it has ended.\",\n\t\tfix: \"Call connect({ url }) again to open a new connection.\",\n\t\tmeta: { extension: \"postgres\" }\n\t});\n}\nfunction connectionFailedError(url, cause) {\n\treturn postgresError(\"DRIVER.CONNECTION_FAILED\", \"Database connection failed\", {\n\t\twhy: cause instanceof Error ? cause.message : String(cause),\n\t\tfix: \"Verify the database URL, ensure the database is reachable, and confirm credentials/permissions\",\n\t\tmeta: {\n\t\t\textension: \"postgres\",\n\t\t\t...redactDatabaseUrl(url)\n\t\t},\n\t\tcause\n\t});\n}\nfunction postgresServerless(options) {\n\tconst cursor = validateCursorOptions(options.cursor, \"postgresServerless\");\n\tconst contract = resolveContract(options);\n\tconst stack = createSqlExecutionStack({\n\t\ttarget: postgresTarget,\n\t\tadapter: postgresAdapter,\n\t\tdriver: postgresDriver,\n\t\textensions: options.extensions ?? []\n\t});\n\tconst context = createExecutionContext({\n\t\tcontract,\n\t\tstack,\n\t\tdriver: postgresDriver\n\t});\n\tconst rawCodecInferer = stack.adapter.rawCodecInferer;\n\tconst { sql, raw, enums, nativeEnums } = buildPostgresStaticContext(context, rawCodecInferer);\n\tconst buildRuntimeBoundMembers = (getRuntime, getRuntimeForWork) => buildPostgresRuntimeBoundMembers({\n\t\tcontext,\n\t\trawCodecInferer,\n\t\tenums,\n\t\tnativeEnums,\n\t\tgetRuntime,\n\t\tgetRuntimeForWork\n\t});\n\tconst noRuntime = () => {\n\t\tthrow new InternalError(\"The serverless client has no runtime\");\n\t};\n\tbuildRuntimeBoundMembers(noRuntime, noRuntime);\n\tconst createConnection = (runtime) => {\n\t\tlet closing;\n\t\tconst close = () => {\n\t\t\tclosing ??= runtime.close();\n\t\t\treturn closing;\n\t\t};\n\t\tconst runtimeBoundMembers = buildRuntimeBoundMembers(() => {\n\t\t\tif (closing !== void 0) throw closedConnectionError();\n\t\t\treturn runtime;\n\t\t}, () => runtime);\n\t\treturn {\n\t\t\tsql,\n\t\t\traw,\n\t\t\tenums,\n\t\t\tnativeEnums,\n\t\t\tcontext,\n\t\t\tcontract,\n\t\t\tstack,\n\t\t\t...runtimeBoundMembers,\n\t\t\tclose,\n\t\t\t[Symbol.asyncDispose]: close\n\t\t};\n\t};\n\treturn {\n\t\tsql,\n\t\traw,\n\t\tenums,\n\t\tnativeEnums,\n\t\tcontext,\n\t\tstack,\n\t\tcontract,\n\t\tasync connect(binding) {\n\t\t\tconst url = validatePostgresUrl(binding.url);\n\t\t\tconst driverDescriptor = stack.driver;\n\t\t\tif (!driverDescriptor) throw new InternalError(\"Driver descriptor missing from execution stack\");\n\t\t\tconst stackInstance = instantiateExecutionStack(stack);\n\t\t\tconst driver = driverDescriptor.create({ cursor: toDriverCursorOptions(cursor) });\n\t\t\tconst pgClient = suppressIdleConnectionErrors(new Client({\n\t\t\t\tconnectionString: url,\n\t\t\t\tconnectionTimeoutMillis: DEFAULT_CONNECT_TIMEOUT_MILLIS\n\t\t\t}));\n\t\t\tawait driver.connect({\n\t\t\t\tkind: \"pgClient\",\n\t\t\t\tclient: pgClient\n\t\t\t});\n\t\t\tconst runtime = new PostgresRuntimeImpl({\n\t\t\t\tcontext,\n\t\t\t\tadapter: stackInstance.adapter,\n\t\t\t\tdriver,\n\t\t\t\t...toRuntimeOptions(options),\n\t\t\t\tcloseRefusal: \"when-idle\"\n\t\t\t});\n\t\t\tconst connection = createConnection(runtime);\n\t\t\ttry {\n\t\t\t\tawait (await driver.acquireConnection()).release();\n\t\t\t} catch (err) {\n\t\t\t\tpgClient.end().catch(() => void 0);\n\t\t\t\tthrow connectionFailedError(url, err);\n\t\t\t}\n\t\t\treturn connection;\n\t\t}\n\t};\n}\n//#endregion\nexport { postgresServerless as default };\n\n//# sourceMappingURL=serverless.mjs.map"],"mappings":";;;;;;;;;;;;;AAaA,SAAS,gBAAgB,SAAS;CACjC,OAAO,kBAAkB;AAC1B;AACA,MAAM,qBAAqB,IAAI,2BAA2B;AAC1D,SAAS,gBAAgB,SAAS;CACjC,MAAM,eAAe,gBAAgB,OAAO,IAAI,QAAQ,eAAe,mBAAmB,kBAAkB,QAAQ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AAO;EACN;EACA;EACA;EACA;EACA;EACA;EACA;EACA,MAAM,QAAQ,SAAS;GACtB,MAAM,MAAM,oBAAoB,QAAQ,GAAG;GAC3C,MAAM,mBAAmB,MAAM;GAC/B,IAAI,CAAC,kBAAkB,MAAM,IAAI,cAAc,gDAAgD;GAC/F,MAAM,gBAAgB,0BAA0B,KAAK;GACrD,MAAM,SAAS,iBAAiB,OAAO,EAAE,QAAQ,sBAAsB,MAAM,EAAE,CAAC;GAChF,MAAM,WAAW,6BAA6B,IAAI,OAAO;IACxD,kBAAkB;IAClB,yBAAyB;GAC1B,CAAC,CAAC;GACF,MAAM,OAAO,QAAQ;IACpB,MAAM;IACN,QAAQ;GACT,CAAC;GACD,MAAM,UAAU,IAAI,oBAAoB;IACvC;IACA,SAAS,cAAc;IACvB;IACA,GAAG,iBAAiB,OAAO;IAC3B,cAAc;GACf,CAAC;GACD,MAAM,aAAa,iBAAiB,OAAO;GAC3C,IAAI;IACH,OAAO,MAAM,OAAO,kBAAkB,EAAA,CAAG,QAAQ;GAClD,SAAS,KAAK;IACb,SAAS,IAAI,CAAC,CAAC,YAAY,KAAK,CAAC;IACjC,MAAM,sBAAsB,KAAK,GAAG;GACrC;GACA,OAAO;EACR;CACD;AACD"}
package/dist/static.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { a as postgresStatic, n as PostgresStaticContext } from "./postgres-static-Q_C_AoOf-DNC79LUR.mjs";
1
+ import { a as postgresStatic, n as PostgresStaticContext } from "./postgres-static-Crd_bF1a-DLqHzv91.mjs";
2
2
  export { type PostgresStaticContext, postgresStatic as default };
package/dist/static.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { r as postgresStatic } from "./postgres-static-Das4il9X-CUGTqJra.mjs";
1
+ import { r as postgresStatic } from "./postgres-static-DzefaBeX-Cz36Sz8Q.mjs";
2
2
  export { postgresStatic as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prisma/orm-postgres",
3
- "version": "8.0.0-rc.17-dev.12",
3
+ "version": "8.0.0-rc.17-dev.13",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -10,10 +10,10 @@
10
10
  "skills"
11
11
  ],
12
12
  "dependencies": {
13
- "@prisma/orm-family-sql": "8.0.0-rc.17-dev.12",
14
- "@prisma/orm-framework": "8.0.0-rc.17-dev.12",
15
- "@prisma/orm-target-postgres": "8.0.0-rc.17-dev.12",
16
- "@prisma/orm-toolchain": "8.0.0-rc.17-dev.12",
13
+ "@prisma/orm-family-sql": "8.0.0-rc.17-dev.13",
14
+ "@prisma/orm-framework": "8.0.0-rc.17-dev.13",
15
+ "@prisma/orm-target-postgres": "8.0.0-rc.17-dev.13",
16
+ "@prisma/orm-toolchain": "8.0.0-rc.17-dev.13",
17
17
  "@types/node": "26.1.2",
18
18
  "@types/pg": "8.20.4",
19
19
  "arktype": "^2.2.2",
@@ -22,9 +22,9 @@
22
22
  "tinyglobby": "^0.2.17"
23
23
  },
24
24
  "devDependencies": {
25
- "@internal/postgres": "8.0.0-rc.17-dev.12",
26
- "@repo/tsconfig": "8.0.0-rc.17-dev.12",
27
- "@repo/tsdown": "8.0.0-rc.17-dev.12",
25
+ "@internal/postgres": "8.0.0-rc.17-dev.13",
26
+ "@repo/tsconfig": "8.0.0-rc.17-dev.13",
27
+ "@repo/tsdown": "8.0.0-rc.17-dev.13",
28
28
  "tsdown": "0.22.14",
29
29
  "typescript": "5.9.3"
30
30
  },
@@ -15,7 +15,7 @@ description: >-
15
15
  ORM 7 or earlier (schema.prisma + @prisma/client).
16
16
  metadata:
17
17
  library: '@prisma/orm-postgres'
18
- library_version: '8.0.0-rc.17-dev.12'
18
+ library_version: '8.0.0-rc.17-dev.13'
19
19
  version: '2026-09-12'
20
20
  ---
21
21
 
@@ -125,7 +125,7 @@ Then run `pnpm prisma contract emit` (or rely on the Vite plugin — see `refere
125
125
  @@index([authorId], where: sql`(archived_at IS NULL)`, name: "posts_author_active")
126
126
  ```
127
127
 
128
- `name:` declares a wire-named index (physical name `<name>_<8-hex hash>`, renames plan as `ALTER INDEX … RENAME`); `map:` adopts an exact physical name verbatim (for infer-captured objects — combining it with a SQL body warns, because drift detection byte-compares the authored text against Postgres's reprint). An `expression:` requires `name:` or `map:`. The TS builder mirrors this via `constraints.index([cols.x], {...})` / `constraints.index({ expression, ... })` — see `packages/2-sql/2-authoring/contract-ts/README.md`.
128
+ `name:` declares a wire-named index (physical name `<name>_<8-hex hash>`, renames plan as `ALTER INDEX … RENAME`); `map:` adopts an exact physical name verbatim (for infer-captured objects — combining it with a SQL body warns, because drift detection byte-compares the authored text against Postgres's reprint). An `expression:` requires `name:` or `map:`. The TS builder mirrors this via `constraints.index([cols.x], {...})` / `constraints.index({ expression, ... })`, where `expression` and `where` are `sql` values such as ``sql`lower(email)` `` (a string does not compile) — see `packages/2-sql/2-authoring/contract-ts/README.md`.
129
129
 
130
130
  **Full-text search indexes (PostgreSQL).** Do not hand-write the `to_tsvector` expression — Postgres only uses the index when the query carries the same search document: the same columns, configuration and weights. Declare `@@fullTextIndex`, and the index and the queries `fullTextMatches` / `fullTextRank` / `fullTextHeadline` build are rendered from the same definition (see `references/queries-postgres.md`):
131
131
 
@@ -138,7 +138,7 @@ Then run `pnpm prisma contract emit` (or rely on the Vite plugin — see `refere
138
138
 
139
139
  The fields are one field, or a list whose items are fields or lists of fields. Each top-level item is a weight group, strongest first (`A` to `D`, so at most four groups); fields in a nested list share a weight. `[title, body]` is two groups, `[[title, body]]` one. A single field has no weight. Diagnostics refuse more than four groups, an empty group, a field named twice, an unknown field and a field that is not text.
140
140
 
141
- The TS builder has the same helper: `fullTextIndex(cols.text, { name: 'message_text_search' })` or `fullTextIndex([[cols.title, cols.subtitle], cols.body], { name: 'post_search' })`, from `@prisma/orm-postgres/contract-builder`, inside the model's `sql({ indexes: [...] })`. Both take an optional `language` (default `english`, from the same allowlist the operations accept), an optional `where:` for a partial index, and `name:` xor `map:`. Both are repeatable. In the SQL builder, pass the index itself, `table.indexes.<name>`, to `fullTextMatches` and `fullTextRank`, which then search its document with its groups and language. A column or a `fullTextDocument` given other groups or another `language` than the index is silent, costing the index and falling back to a sequential scan. The parser that builds the query (`websearchToTsquery` and the others) takes its own `language` for the query side; it does not affect index use. With `map:` the index keeps the exact database name you give it, and `db verify` compares the rendered search document with the text Postgres prints back for the index exactly, character for character. Postgres prints it in its own form (`to_tsvector('english'::regconfig, title)`), so a `map:` full-text index reports drift; `@@fullTextIndex` and `fullTextIndex` warn about this with `PN_EXACT_NAME_BODY_COMPARISON`. Use `name:` unless the database already has the index under that name.
141
+ The TS builder has the same helper: `fullTextIndex(cols.text, { name: 'message_text_search' })` or `fullTextIndex([[cols.title, cols.subtitle], cols.body], { name: 'post_search' })`, from `@prisma/orm-postgres/contract-builder`, inside the model's `sql({ indexes: [...] })`. Both take an optional `language` (default `english`, from the same allowlist the operations accept), an optional `where:` for a partial index (a `sql` value, ``where: sql`archived_at IS NULL` ``), and `name:` xor `map:`. Both are repeatable. In the SQL builder, pass the index itself, `table.indexes.<name>`, to `fullTextMatches` and `fullTextRank`, which then search its document with its groups and language. A column or a `fullTextDocument` given other groups or another `language` than the index is silent, costing the index and falling back to a sequential scan. The parser that builds the query (`websearchToTsquery` and the others) takes its own `language` for the query side; it does not affect index use. With `map:` the index keeps the exact database name you give it, and `db verify` compares the rendered search document with the text Postgres prints back for the index exactly, character for character. Postgres prints it in its own form (`to_tsvector('english'::regconfig, title)`), so a `map:` full-text index reports drift; `@@fullTextIndex` and `fullTextIndex` warn about this with `PN_EXACT_NAME_BODY_COMPARISON`. Use `name:` unless the database already has the index under that name.
142
142
 
143
143
  The contract stores the index as data, not SQL: an index of type `fullText` whose `columns` are the covered storage columns and whose `options` are `{ weightGroups, language }`, the weight groups as storage column names. The DDL is a GIN index over the rendered document, `to_tsvector('<language>', "<column>")` for one field, and `setweight(...) || ...` with every column wrapped in `coalesce` for several. `@@index(expression: …)` remains only for expressions this attribute does not cover.
144
144
 
@@ -335,7 +335,7 @@ model Order {
335
335
  - **`name:`** — declaring a new rule. Prisma 8 picks the physical constraint name and future plans compare by that name, so Postgres's own reprint of your predicate (which rarely matches what you typed byte-for-byte) never causes false drift.
336
336
  - **`map:`** — adopting a rule that already exists. Give the constraint's exact physical name and Prisma 8 compares the predicate byte-for-byte against what's live. This is the form `contract infer` writes for you (see *Workflow — Brownfield introspection* below) when it finds a hand-written check in the database. Every `map:` body warns at emit time (`PN_EXACT_NAME_BODY_COMPARISON`) — the warning fires on the text, not on who wrote it, so the check `contract infer` just wrote warns again on your next `contract emit` too. That is expected, not a defect: the comparison is still sound because both sides are Postgres's own reprint. Prefer `name:` for anything you're authoring fresh: your text and Postgres's reprint of it rarely match character-for-character, and a byte comparison reports that as drift even when both mean exactly the same thing. Reserve `map:` for adopting what's already there, where both sides are the database's own reprint and so do match.
337
337
 
338
- A model can carry any number of `@@check` attributes. The TS builder mirrors this with `check({ expression, name })` / `check({ expression, map })` on a model's `.sql({ checks: [...] })`, next to `index()`.
338
+ A model can carry any number of `@@check` attributes. The TS builder mirrors this with `check({ expression, name })` / `check({ expression, map })` on a model's `.sql({ checks: [...] })`, next to `index()`; `expression` is a `sql` value, as in ``check({ expression: sql`total > 0`, name: 'order_total_positive' })``. The `sql` tag, from the same contract-builder module, may interpolate other `sql` values: ``sql`${owner} AND deleted_at IS NULL` ``.
339
339
 
340
340
  Check constraints need the target's `checkConstraint` capability. Postgres has it; SQLite does not. `@@check` on a SQLite contract is rejected at authoring time; `check()` on a SQLite contract isn't caught until migration DDL is rendered, but either way you get a refusal, never a silently-dropped constraint.
341
341
 
@@ -442,7 +442,10 @@ node <skill>/upgrading/app/upgrades/8.0.0-rc.14-to-8.0.0-rc.15/scripts/data-type
442
442
 
443
443
  `<skill>` is the directory of the synced `prisma-8` skill. Node 24 or later runs the TypeScript script directly; it needs no `tsx`. It reads and writes files only and needs no database. It rewrites every `*.json` file under the root that parses as a SQL contract in the old format (a column or `storage.types` entry that stores `nativeType`), skipping `node_modules`, `.git`, `dist` and `build`. That includes a test fixture of an old-format contract: if you keep such a fixture on purpose, restore it with git afterwards (`git restore <file>`), or keep it outside the project root. In each contract it rewrites, it also writes lists in this release's new form (`reemit-explicit-list-cardinality`): a list column or field stored as `many: true` becomes `many: { elementNullable: false }`, and `contract.d.ts` declares `many` on every column. This is the SQL part of `refresh-historical-list-contracts`.
444
444
 
445
- On PostgreSQL, a list column of an enum keeps the membership check its database has, because the database still holds that check. Run `prisma db sign` before you emit the contract again. The next `prisma contract emit` writes the check as `array_remove(…) <@ ARRAY[…]` under a new name; `prisma migration plan` then writes a migration that drops the old check and adds the new one, and `prisma db migrate` applies it. The plan warns that dropping the old check may lose data; it does not, because only the check changes, not the column. If you already emitted before signing, `db sign` reports the new check as missing: sign each database with the storage hash the script printed instead (`prisma db sign <new hash>`), then plan and migrate as above.
445
+ On PostgreSQL, a list column of an enum keeps the membership check its database has, because the database still holds that check. Run `prisma db sign` before you emit the contract again. The next `prisma contract emit` writes the check as `array_remove(…) <@ ARRAY[…]` under a new name; `prisma migration plan` then writes a migration that drops the old check and adds the new one, and `prisma db migrate` applies it. The plan warns that dropping the old check may lose data; it does not, because only the check changes, not the column. If you already emitted before signing, `db sign` reports the new check as missing:
446
+
447
+ - In a project with migrations, sign each database with the storage hash the script printed (`prisma db sign <new hash>`), then plan and migrate as above.
448
+ - In a project without migrations, kept with `db init` or `db update`, run `prisma db update` and type the database name when it asks; where nobody can answer, run `prisma db update --no-interactive --confirm <database>`. It drops the old check and adds the new one, and `prisma db verify` then passes. `prisma db sign <new hash>` fails there with `MIGRATION.REF_NOT_FOUND`, because no migration holds that hash.
446
449
 
447
450
  If the script stops on an error, for example on a full disk, it prints the error and `the upgrade stopped partway, run the script again to finish it`, and exits 1. After an error, Ctrl-C or a crash, run it again: it finishes the upgrade. A file the script was writing at that moment is either unchanged or complete, and it removes its own temporary files (ending in `.data-type-in-contract-tmp`) on the next run.
448
451
 
@@ -1 +0,0 @@
1
- {"version":3,"file":"postgres-static-Das4il9X-CUGTqJra.mjs","names":[],"sources":["../../../../3-extensions/postgres/dist/postgres-static-Das4il9X.mjs"],"sourcesContent":["import { PG_ENUM_CODEC_ID } from \"@internal/target-postgres/codec-ids\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { buildNamespacedEnums, createEnumAccessor } from \"@internal/contract/enum-accessor\";\nimport postgresAdapter from \"@internal/adapter-postgres/runtime\";\nimport { createExecutionContext, createSqlExecutionStack } from \"@internal/sql-runtime\";\nimport postgresTarget, { PostgresContractSerializer } from \"@internal/target-postgres/runtime\";\nimport { createRawLane, sql } from \"@internal/sql-builder/runtime\";\n//#region src/runtime/native-enums.ts\n/**\n* Reads the namespace's `valueSet` entries directly off the plain contract\n* shape (`storage.namespaces[id].entries.valueSet`), not through a hydrated\n* `PostgresSchema` class instance — the same plain-data path `db.enums`\n* reads `domain.namespaces[id].enum` through. Works on a `validateContract`'d\n* JSON contract as well as one produced by `PostgresContractSerializer`.\n*\n* A native enum is never re-emitted as its own entity: once `native_enum` is\n* lowered, its member values live on in the `valueSet` entry it derives (the\n* SQL family's generic `deriveValueSet` mechanism) — the same slot\n* `column.valueSet`-typed columns read. A member is a value, not a\n* name→value pair (matching `CREATE TYPE … AS ENUM ('a', 'b')`), so each\n* value doubles as its own accessor name.\n*/\nfunction buildNativeEnumsMapForNamespace(storage, namespaceId) {\n\tconst result = {};\n\tconst valueSets = storage.namespaces[namespaceId]?.entries.valueSet;\n\tif (!valueSets) return result;\n\tfor (const [name, valueSet] of Object.entries(valueSets)) result[name] = createEnumAccessor({\n\t\tcodecId: PG_ENUM_CODEC_ID,\n\t\tmembers: valueSet.values.map((value) => ({\n\t\t\tname: String(value),\n\t\t\tvalue\n\t\t}))\n\t});\n\treturn result;\n}\nfunction buildNamespacedNativeEnums(storage) {\n\tconst result = {};\n\tfor (const namespaceId of Object.keys(storage.namespaces)) result[namespaceId] = buildNativeEnumsMapForNamespace(storage, namespaceId);\n\treturn result;\n}\n//#endregion\n//#region src/static/postgres-static.ts\nfunction buildPostgresStaticContext(context, rawCodecInferer) {\n\tconst sqlDb = sql({\n\t\tcontext,\n\t\trawCodecInferer\n\t});\n\tconst raw = createRawLane({\n\t\tcontext,\n\t\trawCodecInferer\n\t});\n\tconst enums = Object.freeze(buildNamespacedEnums(context.contract.domain, (codecId) => context.contractCodecs.forCodecRef({ codecId })));\n\tconst nativeEnums = blindCast(Object.freeze(buildNamespacedNativeEnums(context.contract.storage)));\n\treturn {\n\t\tcontext,\n\t\tcontract: context.contract,\n\t\tenums,\n\t\tnativeEnums,\n\t\tsql: sqlDb,\n\t\traw\n\t};\n}\nfunction postgresStatic(options) {\n\tconst contract = blindCast(new PostgresContractSerializer().deserializeContract(options.contractJson));\n\tconst stack = createSqlExecutionStack({\n\t\ttarget: postgresTarget,\n\t\tadapter: postgresAdapter,\n\t\textensions: options.extensions ?? []\n\t});\n\treturn buildPostgresStaticContext(createExecutionContext({\n\t\tcontract,\n\t\tstack\n\t}), stack.adapter.rawCodecInferer);\n}\n//#endregion\nexport { postgresStatic as n, buildNamespacedNativeEnums as r, buildPostgresStaticContext as t };\n\n//# sourceMappingURL=postgres-static-Das4il9X.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAsBA,SAAS,gCAAgC,SAAS,aAAa;CAC9D,MAAM,SAAS,CAAC;CAChB,MAAM,YAAY,QAAQ,WAAW,YAAY,EAAE,QAAQ;CAC3D,IAAI,CAAC,WAAW,OAAO;CACvB,KAAK,MAAM,CAAC,MAAM,aAAa,OAAO,QAAQ,SAAS,GAAG,OAAO,QAAQ,mBAAmB;EAC3F,SAAS;EACT,SAAS,SAAS,OAAO,KAAK,WAAW;GACxC,MAAM,OAAO,KAAK;GAClB;EACD,EAAE;CACH,CAAC;CACD,OAAO;AACR;AACA,SAAS,2BAA2B,SAAS;CAC5C,MAAM,SAAS,CAAC;CAChB,KAAK,MAAM,eAAe,OAAO,KAAK,QAAQ,UAAU,GAAG,OAAO,eAAe,g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