@prisma/orm-postgres 8.0.0-rc.22-dev.13 → 8.0.0-rc.22-dev.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/contract-builder.d.mts +4 -4
- package/dist/contract-builder.d.mts.map +1 -1
- package/dist/contract-builder.mjs +18 -4
- package/dist/contract-builder.mjs.map +1 -1
- package/dist/{contract-from-json-C2-GZKqY-BvVhrSB9.mjs → contract-from-json-DrxFlDIH-BD2r2f5C.mjs} +3 -3
- package/dist/{contract-from-json-C2-GZKqY-BvVhrSB9.mjs.map → contract-from-json-DrxFlDIH-BD2r2f5C.mjs.map} +1 -1
- package/dist/internal__static-context.mjs +1 -1
- package/dist/internal__validate-contract.mjs +1 -1
- package/dist/{postgres-static-xbcqtiDZ-BhN7RVCW.mjs → postgres-static-DhakhOz--B__mNgdA.mjs} +3 -3
- package/dist/{postgres-static-xbcqtiDZ-BhN7RVCW.mjs.map → postgres-static-DhakhOz--B__mNgdA.mjs.map} +1 -1
- package/dist/runtime.mjs +2 -2
- package/dist/runtime.mjs.map +1 -1
- package/dist/serverless.mjs +2 -2
- package/dist/serverless.mjs.map +1 -1
- package/dist/static.mjs +2 -2
- package/package.json +8 -8
- package/skills/prisma-8/SKILL.md +1 -1
- package/skills/prisma-8/references/upgrade-extension.md +1 -1
- package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.21-to-8.0.0-rc.22/instructions.md +2 -2
|
@@ -2,7 +2,7 @@ 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
4
|
import "@prisma/orm-framework/utils/structured-error";
|
|
5
|
-
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, IndexOptionsFunction, 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
|
+
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, IndexOptionsFunction, MergeEnums, ModelLike, ModelNode, PrimaryKeyNode, RelationNode, ScalarFieldBuilder, ScalarFieldBuilder as ScalarFieldBuilder$1, SqlExpression, UniqueConstraintNode, autoincrement, buildBoundContract, buildSqlContractFromDefinition, check, member, model, now, rel, sql, unbound, unbound as unbound$1 } from "@prisma/orm-family-sql/contract-ts/contract-builder";
|
|
6
6
|
import { postgresAdapterContractContributions } from "@prisma/orm-target-postgres/adapter/adapter";
|
|
7
7
|
import sqlFamilyPack from "@prisma/orm-family-sql/family/pack";
|
|
8
8
|
import "@prisma/orm-framework/components/authoring";
|
|
@@ -23,10 +23,10 @@ interface ExtensionHandle<Name extends string = string> {
|
|
|
23
23
|
readonly namespace?: string;
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
|
-
* Declares a Postgres extension the database must have installed, mirroring PSL's `extension <name> {}`. Place it in the `entities` list; `namespace` names the namespace whose schema holds the extension's objects, the default namespace when omitted.
|
|
26
|
+
* Declares a Postgres extension the database must have installed, mirroring PSL's `extension <name> {}`. Place it in the `entities` list; `namespace` names the namespace whose schema holds the extension's objects, the default namespace when omitted. Pass `unbound` to have the extension found through the connection's `search_path`.
|
|
27
27
|
*/
|
|
28
28
|
declare function extension<const Name extends string>(name: Name, options?: {
|
|
29
|
-
readonly namespace?: string;
|
|
29
|
+
readonly namespace?: string | typeof unbound$1;
|
|
30
30
|
}): ExtensionHandle<Name>;
|
|
31
31
|
//#endregion
|
|
32
32
|
//#region src/contract/rls.d.ts
|
|
@@ -714,5 +714,5 @@ declare const pg: {
|
|
|
714
714
|
readonly enum: typeof pgEnumColumn;
|
|
715
715
|
};
|
|
716
716
|
//#endregion
|
|
717
|
-
export { type Bit, type Char, type CheckNode, type ComposedAuthoringHelpers, type ContractDefinition, type ContractInput, type ContractModelBuilder, type EnumMember, type EnumTypeHandle, type ExtensionHandle, type FieldNode, type ForeignKeyNode, type IndexNode, type ModelNode, type NativeEnumHandle, type Numeric, 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 TimeString, type TimestampString, type TimestamptzString, type Timetz, type UniqueConstraintNode, type VarBit, type Varchar, autoincrement, buildSqlContractFromDefinition, check, defineContract, enumType, extension, field, fullTextIndex, gen, member, model, nativeEnum, now, pg, policyAll, policyDelete, policyInsert, policySelect, policyUpdate, rel, rlsEnabled, role, sql, type };
|
|
717
|
+
export { type Bit, type Char, type CheckNode, type ComposedAuthoringHelpers, type ContractDefinition, type ContractInput, type ContractModelBuilder, type EnumMember, type EnumTypeHandle, type ExtensionHandle, type FieldNode, type ForeignKeyNode, type IndexNode, type ModelNode, type NativeEnumHandle, type Numeric, 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 TimeString, type TimestampString, type TimestamptzString, type Timetz, type UniqueConstraintNode, type VarBit, type Varchar, autoincrement, buildSqlContractFromDefinition, check, defineContract, enumType, extension, field, fullTextIndex, gen, member, model, nativeEnum, now, pg, policyAll, policyDelete, policyInsert, policySelect, policyUpdate, rel, rlsEnabled, role, sql, type, unbound };
|
|
718
718
|
//# sourceMappingURL=contract-builder.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract-builder.d.mts","names":[],"sources":["../../../../3-targets/postgres/9-facade/dist/contract-builder.d.mts"],"mappings":";;;;;;;;;;;;;;;;;;;UAkBU,gBAAgB;WACf;WACA,MAAM;WACN;;;;;iBAKM,gBAAgB,qBAAqB,MAAM,MAAM;WACvD;
|
|
1
|
+
{"version":3,"file":"contract-builder.d.mts","names":[],"sources":["../../../../3-targets/postgres/9-facade/dist/contract-builder.d.mts"],"mappings":";;;;;;;;;;;;;;;;;;;UAkBU,gBAAgB;WACf;WACA,MAAM;WACN;;;;;iBAKM,gBAAgB,qBAAqB,MAAM,MAAM;WACvD,4BAA4B;IACnC,gBAAgB;;;;;;;;;UASV;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,QAAQ;WACR,YAAY;;;;;;KAMlB,kBAAkB,kBAAkB,gBAAgB;UAC/C;;WAEC;WACA,gBAAgB;;;UAGjB,iCAAiC;WAChC,OAAO;;;UAGR,qCAAqC;WACpC,WAAW;;;;;;;;;KASjB,qCAAqC;WAC/B,OAAO;WACP,YAAY;MACjB;WACK,QAAQ;WACR,WAAW;;;;;;;;iBAQL,WAAW,qBAAqB,MAAM,OAAO,cAAc;;;;;;iBAM3D,WAAW,OAAO,iBA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;;;;;;UAajV,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"}
|
|
@@ -3,11 +3,13 @@ import { PG_ENUM_CODEC_ID } from "@prisma/orm-target-postgres/target/codec-ids";
|
|
|
3
3
|
import postgresPackRef from "@prisma/orm-target-postgres/target/pack";
|
|
4
4
|
import { PostgresNativeEnum, postgresCreateNamespace } from "@prisma/orm-target-postgres/target/types";
|
|
5
5
|
import { ifDefined } from "@prisma/orm-framework/utils/defined";
|
|
6
|
-
import { autoincrement, bindEnumType, buildBoundContract, buildSqlContractFromDefinition, check, createComposedAuthoringHelpers, member, model, now, rel, sql } from "@prisma/orm-family-sql/contract-ts/contract-builder";
|
|
6
|
+
import { autoincrement, bindEnumType, buildBoundContract, buildSqlContractFromDefinition, check, createComposedAuthoringHelpers, member, model, now, rel, sql, unbound, unbound as unbound$1 } from "@prisma/orm-family-sql/contract-ts/contract-builder";
|
|
7
7
|
import { postgresAdapterContractContributions } from "@prisma/orm-target-postgres/adapter/adapter";
|
|
8
8
|
import sqlFamilyPack from "@prisma/orm-family-sql/family/pack";
|
|
9
9
|
import { assembleDataTypeSupport } from "@prisma/orm-framework/components/authoring";
|
|
10
10
|
import { assemblePostgresCodecRegistryWithBuiltins, pgEnumDescriptor } from "@prisma/orm-target-postgres/target/codecs";
|
|
11
|
+
import { UNBOUND_NAMESPACE_ID } from "@prisma/orm-framework/components/ir";
|
|
12
|
+
import { UNBOUND_PSL_NAMESPACE_NAME } from "@prisma/orm-framework/components/psl-ast";
|
|
11
13
|
import { requireSqlExpression } from "@prisma/orm-family-sql/contract/sql-expression";
|
|
12
14
|
import { FULL_TEXT_INDEX_TYPE, describeFullTextIndexProblem, fullTextIndexProblems, postgresCodecTraitsOf, weightGroupsOf } from "@prisma/orm-target-postgres/target/full-text-index-authoring";
|
|
13
15
|
import { DEFAULT_FULL_TEXT_SEARCH_LANGUAGE } from "@prisma/orm-target-postgres/target/sql-utils";
|
|
@@ -46,19 +48,31 @@ function defineContract(definition, factory) {
|
|
|
46
48
|
*/
|
|
47
49
|
const enumType = bindEnumType();
|
|
48
50
|
/**
|
|
49
|
-
* Declares a Postgres extension the database must have installed, mirroring PSL's `extension <name> {}`. Place it in the `entities` list; `namespace` names the namespace whose schema holds the extension's objects, the default namespace when omitted.
|
|
51
|
+
* Declares a Postgres extension the database must have installed, mirroring PSL's `extension <name> {}`. Place it in the `entities` list; `namespace` names the namespace whose schema holds the extension's objects, the default namespace when omitted. Pass `unbound` to have the extension found through the connection's `search_path`.
|
|
50
52
|
*/
|
|
51
53
|
function extension(name, options) {
|
|
52
54
|
if (name.trim().length === 0) throw postgresError("CONTRACT.ARGUMENT_INVALID", `extension("${name}"): name must be a non-empty string.`, {
|
|
53
55
|
fix: "Pass the extension name, such as \"pg_trgm\".",
|
|
54
56
|
meta: { extensionName: name }
|
|
55
57
|
});
|
|
58
|
+
const namespace = namespaceIdOf(name, options?.namespace);
|
|
56
59
|
return Object.freeze({
|
|
57
60
|
entityKind: "extension",
|
|
58
61
|
name,
|
|
59
|
-
...
|
|
62
|
+
...namespace === void 0 ? {} : { namespace }
|
|
60
63
|
});
|
|
61
64
|
}
|
|
65
|
+
function namespaceIdOf(name, namespace) {
|
|
66
|
+
if (namespace === unbound$1) return UNBOUND_NAMESPACE_ID;
|
|
67
|
+
if (namespace === UNBOUND_PSL_NAMESPACE_NAME || namespace === UNBOUND_NAMESPACE_ID) throw postgresError("CONTRACT.ARGUMENT_INVALID", `extension("${name}"): namespace "${namespace}" is reserved; pass the unbound symbol to declare the extension in the unbound namespace.`, {
|
|
68
|
+
fix: "Import `unbound` from the contract builder and pass `{ namespace: unbound }`.",
|
|
69
|
+
meta: {
|
|
70
|
+
extensionName: name,
|
|
71
|
+
namespace
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
return namespace;
|
|
75
|
+
}
|
|
62
76
|
const { support } = assembleDataTypeSupport([sqlFamilyPack, postgresPackRef], () => void 0);
|
|
63
77
|
const helpers = createComposedAuthoringHelpers({
|
|
64
78
|
family: sqlFamilyPack,
|
|
@@ -325,6 +339,6 @@ function policyAll(model, descriptor) {
|
|
|
325
339
|
return buildPolicyHandle("all", model, descriptor);
|
|
326
340
|
}
|
|
327
341
|
//#endregion
|
|
328
|
-
export { autoincrement, buildSqlContractFromDefinition, check, defineContract, enumType, extension, field, fullTextIndex, gen, member, model, nativeEnum, now, pg, policyAll, policyDelete, policyInsert, policySelect, policyUpdate, rel, rlsEnabled, role, sql, type };
|
|
342
|
+
export { autoincrement, buildSqlContractFromDefinition, check, defineContract, enumType, extension, field, fullTextIndex, gen, member, model, nativeEnum, now, pg, policyAll, policyDelete, policyInsert, policySelect, policyUpdate, rel, rlsEnabled, role, sql, type, unbound };
|
|
329
343
|
|
|
330
344
|
//# sourceMappingURL=contract-builder.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract-builder.mjs","names":[],"sources":["../../../../3-targets/postgres/9-facade/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 { postgresAdapterContractContributions } from \"@internal/adapter-postgres/adapter\";\nimport sqlFamilyPack from \"@internal/family-sql/pack\";\nimport { assembleDataTypeSupport } from \"@internal/framework-components/authoring\";\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\nconst adapter = postgresAdapterContractContributions;\nfunction defineContract(definition, factory) {\n\tconst extensions = Object.values(definition.extensions ?? {});\n\tconst dataTypeLookup = definition.dataTypeLookup ?? assembleDataTypeSupport([\n\t\tsqlFamilyPack,\n\t\tpostgresPackRef,\n\t\t...extensions\n\t], () => void 0).support.lookup;\n\tconst bound = {\n\t\t...definition,\n\t\tadapter,\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/extension.ts\n/**\n* Declares a Postgres extension the database must have installed, mirroring PSL's `extension <name> {}`. Place it in the `entities` list; `namespace` names the namespace whose schema holds the extension's objects, the default namespace when omitted.\n*/\nfunction extension(name, options) {\n\tif (name.trim().length === 0) throw postgresError(\"CONTRACT.ARGUMENT_INVALID\", `extension(\"${name}\"): name must be a non-empty string.`, {\n\t\tfix: \"Pass the extension name, such as \\\"pg_trgm\\\".\",\n\t\tmeta: { extensionName: name }\n\t});\n\treturn Object.freeze({\n\t\tentityKind: \"extension\",\n\t\tname,\n\t\t...options?.namespace === void 0 ? {} : { namespace: options.namespace }\n\t});\n}\n//#endregion\n//#region src/contract/field.ts\nconst { support } = assembleDataTypeSupport([sqlFamilyPack, postgresPackRef], () => void 0);\nconst helpers = createComposedAuthoringHelpers({\n\tfamily: sqlFamilyPack,\n\ttarget: postgresPackRef,\n\tcodecLookup: assemblePostgresCodecRegistryWithBuiltins([], support.lookup)\n});\n/**\n* The field builders of the `defineContract` callback for Postgres, without extensions: `field.column(type.TimestamptzTemporal())`. Use it outside a contract, for example to declare the fields of a query fragment.\n*/\nconst field = helpers.field;\n/**\n* The generator function calls of the `defineContract` callback for Postgres, without extensions, for `.onCreate(...)` and `.onUpdate(...)`: `gen.now()`, `gen.uuid(7)`, `gen.cuid(2)`, `gen.ulid()`, `gen.nanoid(16)` and `gen.ksuid()`.\n*/\nconst gen = helpers.gen;\n/**\n* The type constructors and type aliases of the `defineContract` callback for Postgres, without extensions, for `field.column(...)`: `type.TimestamptzTemporal()`, `type.Ulid()`, `type.temporal.CreatedAt()`.\n*/\nconst type = helpers.type;\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.valueSet` key). The\n* Postgres type name, the `entries.native_enum` key, 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, extension, field, fullTextIndex, gen, member, model, nativeEnum, now, pg, policyAll, policyDelete, policyInsert, policySelect, policyUpdate, rel, rlsEnabled, role, sql, type };\n\n//# sourceMappingURL=contract-builder.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,MAAM,UAAU;AAChB,SAAS,eAAe,YAAY,SAAS;CAC5C,MAAM,aAAa,OAAO,OAAO,WAAW,cAAc,CAAC,CAAC;CAC5D,MAAM,iBAAiB,WAAW,kBAAkB,wBAAwB;EAC3E;EACA;EACA,GAAG;CACJ,SAAS,KAAK,CAAC,CAAC,CAAC,QAAQ;CACzB,MAAM,QAAQ;EACb,GAAG;EACH;EACA,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;;;;AAM9B,SAAS,UAAU,MAAM,SAAS;CACjC,IAAI,KAAK,KAAK,CAAC,CAAC,WAAW,GAAG,MAAM,cAAc,6BAA6B,cAAc,KAAK,uCAAuC;EACxI,KAAK;EACL,MAAM,EAAE,eAAe,KAAK;CAC7B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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-targets/postgres/9-facade/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, unbound, unbound as unbound$1 } from \"@internal/sql-contract-ts/contract-builder\";\nimport { postgresAdapterContractContributions } from \"@internal/adapter-postgres/adapter\";\nimport sqlFamilyPack from \"@internal/family-sql/pack\";\nimport { assembleDataTypeSupport } from \"@internal/framework-components/authoring\";\nimport { assemblePostgresCodecRegistryWithBuiltins, pgEnumDescriptor } from \"@internal/target-postgres/codecs\";\nimport { UNBOUND_NAMESPACE_ID } from \"@internal/framework-components/ir\";\nimport { UNBOUND_PSL_NAMESPACE_NAME } from \"@internal/framework-components/psl-ast\";\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\nconst adapter = postgresAdapterContractContributions;\nfunction defineContract(definition, factory) {\n\tconst extensions = Object.values(definition.extensions ?? {});\n\tconst dataTypeLookup = definition.dataTypeLookup ?? assembleDataTypeSupport([\n\t\tsqlFamilyPack,\n\t\tpostgresPackRef,\n\t\t...extensions\n\t], () => void 0).support.lookup;\n\tconst bound = {\n\t\t...definition,\n\t\tadapter,\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/extension.ts\n/**\n* Declares a Postgres extension the database must have installed, mirroring PSL's `extension <name> {}`. Place it in the `entities` list; `namespace` names the namespace whose schema holds the extension's objects, the default namespace when omitted. Pass `unbound` to have the extension found through the connection's `search_path`.\n*/\nfunction extension(name, options) {\n\tif (name.trim().length === 0) throw postgresError(\"CONTRACT.ARGUMENT_INVALID\", `extension(\"${name}\"): name must be a non-empty string.`, {\n\t\tfix: \"Pass the extension name, such as \\\"pg_trgm\\\".\",\n\t\tmeta: { extensionName: name }\n\t});\n\tconst namespace = namespaceIdOf(name, options?.namespace);\n\treturn Object.freeze({\n\t\tentityKind: \"extension\",\n\t\tname,\n\t\t...namespace === void 0 ? {} : { namespace }\n\t});\n}\nfunction namespaceIdOf(name, namespace) {\n\tif (namespace === unbound$1) return UNBOUND_NAMESPACE_ID;\n\tif (namespace === UNBOUND_PSL_NAMESPACE_NAME || namespace === UNBOUND_NAMESPACE_ID) throw postgresError(\"CONTRACT.ARGUMENT_INVALID\", `extension(\"${name}\"): namespace \"${namespace}\" is reserved; pass the unbound symbol to declare the extension in the unbound namespace.`, {\n\t\tfix: \"Import `unbound` from the contract builder and pass `{ namespace: unbound }`.\",\n\t\tmeta: {\n\t\t\textensionName: name,\n\t\t\tnamespace\n\t\t}\n\t});\n\treturn namespace;\n}\n//#endregion\n//#region src/contract/field.ts\nconst { support } = assembleDataTypeSupport([sqlFamilyPack, postgresPackRef], () => void 0);\nconst helpers = createComposedAuthoringHelpers({\n\tfamily: sqlFamilyPack,\n\ttarget: postgresPackRef,\n\tcodecLookup: assemblePostgresCodecRegistryWithBuiltins([], support.lookup)\n});\n/**\n* The field builders of the `defineContract` callback for Postgres, without extensions: `field.column(type.TimestamptzTemporal())`. Use it outside a contract, for example to declare the fields of a query fragment.\n*/\nconst field = helpers.field;\n/**\n* The generator function calls of the `defineContract` callback for Postgres, without extensions, for `.onCreate(...)` and `.onUpdate(...)`: `gen.now()`, `gen.uuid(7)`, `gen.cuid(2)`, `gen.ulid()`, `gen.nanoid(16)` and `gen.ksuid()`.\n*/\nconst gen = helpers.gen;\n/**\n* The type constructors and type aliases of the `defineContract` callback for Postgres, without extensions, for `field.column(...)`: `type.TimestamptzTemporal()`, `type.Ulid()`, `type.temporal.CreatedAt()`.\n*/\nconst type = helpers.type;\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.valueSet` key). The\n* Postgres type name, the `entries.native_enum` key, 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, extension, field, fullTextIndex, gen, member, model, nativeEnum, now, pg, policyAll, policyDelete, policyInsert, policySelect, policyUpdate, rel, rlsEnabled, role, sql, type, unbound };\n\n//# sourceMappingURL=contract-builder.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;;;AAmBA,MAAM,UAAU;AAChB,SAAS,eAAe,YAAY,SAAS;CAC5C,MAAM,aAAa,OAAO,OAAO,WAAW,cAAc,CAAC,CAAC;CAC5D,MAAM,iBAAiB,WAAW,kBAAkB,wBAAwB;EAC3E;EACA;EACA,GAAG;CACJ,SAAS,KAAK,CAAC,CAAC,CAAC,QAAQ;CACzB,MAAM,QAAQ;EACb,GAAG;EACH;EACA,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;;;;AAM9B,SAAS,UAAU,MAAM,SAAS;CACjC,IAAI,KAAK,KAAK,CAAC,CAAC,WAAW,GAAG,MAAM,cAAc,6BAA6B,cAAc,KAAK,uCAAuC;EACxI,KAAK;EACL,MAAM,EAAE,eAAe,KAAK;CAC7B,CAAC;CACD,MAAM,YAAY,c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K,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"}
|
package/dist/{contract-from-json-C2-GZKqY-BvVhrSB9.mjs → contract-from-json-DrxFlDIH-BD2r2f5C.mjs}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import postgresTarget, { PostgresContractSerializer } from "@prisma/orm-target-postgres/target/runtime";
|
|
2
2
|
import { validateContractOnce } from "@prisma/orm-framework/contract/validate-once";
|
|
3
|
-
//#region ../../../3-targets/postgres/9-facade/dist/contract-from-json-
|
|
4
|
-
var version = "8.0.0-rc.22-dev.
|
|
3
|
+
//#region ../../../3-targets/postgres/9-facade/dist/contract-from-json-DrxFlDIH.mjs
|
|
4
|
+
var version = "8.0.0-rc.22-dev.15";
|
|
5
5
|
const serializer = new PostgresContractSerializer();
|
|
6
6
|
const validator = `${postgresTarget.targetId}@${version}`;
|
|
7
7
|
/**
|
|
@@ -30,4 +30,4 @@ function validatePostgresContract(contract) {
|
|
|
30
30
|
//#endregion
|
|
31
31
|
export { validatePostgresContract as n, contractFromJson as t };
|
|
32
32
|
|
|
33
|
-
//# sourceMappingURL=contract-from-json-
|
|
33
|
+
//# sourceMappingURL=contract-from-json-DrxFlDIH-BD2r2f5C.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract-from-json-
|
|
1
|
+
{"version":3,"file":"contract-from-json-DrxFlDIH-BD2r2f5C.mjs","names":[],"sources":["../../../../3-targets/postgres/9-facade/dist/contract-from-json-DrxFlDIH.mjs"],"sourcesContent":["import postgresTarget, { PostgresContractSerializer } from \"@internal/target-postgres/runtime\";\nimport { validateContractOnce } from \"@internal/contract/validate-once\";\n//#region package.json\nvar version = \"8.0.0-rc.22-dev.15\";\n//#endregion\n//#region src/static/contract-from-json.ts\nconst serializer = new PostgresContractSerializer();\nconst validator = `${postgresTarget.targetId}@${version}`;\n/**\n* Validates an emitted Postgres `contract.json` and returns it as the contract type the\n* application names, ready to pass to `postgres({ contract })` and the other Postgres clients.\n* Clients built from the result do not validate it again.\n*\n* The returned value's top level is frozen; its nested objects are not. Do not change `json` or the\n* returned value after the call: clients built from the value later do not validate it again.\n*\n* @example\n* ```ts\n* import type { Contract } from './contract.d';\n* import contractJson from './contract.json' with { type: 'json' };\n*\n* export const contract = contractFromJson<Contract>(contractJson);\n* ```\n*/\nfunction contractFromJson(json) {\n\treturn validateContractOnce(json, validator, (input) => serializer.deserializeContract(input));\n}\n/** Validates a contract value for a Postgres client, once per value. */\nfunction validatePostgresContract(contract) {\n\treturn validateContractOnce(contract, validator, () => serializer.deserializeContract(serializer.serializeContract(contract)));\n}\n//#endregion\nexport { validatePostgresContract as n, contractFromJson as t };\n\n//# sourceMappingURL=contract-from-json-DrxFlDIH.mjs.map"],"mappings":";;;AAGA,IAAI,UAAU;AAGd,MAAM,aAAa,IAAI,2BAA2B;AAClD,MAAM,YAAY,GAAG,eAAe,SAAS,GAAG;;;;;;;;;;;;;;;;;AAiBhD,SAAS,iBAAiB,MAAM;CAC/B,OAAO,qBAAqB,MAAM,YAAY,UAAU,WAAW,oBAAoB,KAAK,CAAC;AAC9F;;AAEA,SAAS,yBAAyB,UAAU;CAC3C,OAAO,qBAAqB,UAAU,iBAAiB,WAAW,oBAAoB,WAAW,kBAAkB,QAAQ,CAAC,CAAC;AAC9H"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as buildPostgresStaticContext } from "./postgres-static-
|
|
1
|
+
import { n as buildPostgresStaticContext } from "./postgres-static-DhakhOz--B__mNgdA.mjs";
|
|
2
2
|
export { buildPostgresStaticContext };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as validatePostgresContract } from "./contract-from-json-
|
|
1
|
+
import { n as validatePostgresContract } from "./contract-from-json-DrxFlDIH-BD2r2f5C.mjs";
|
|
2
2
|
export { validatePostgresContract };
|
package/dist/{postgres-static-xbcqtiDZ-BhN7RVCW.mjs → postgres-static-DhakhOz--B__mNgdA.mjs}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as validatePostgresContract } from "./contract-from-json-
|
|
1
|
+
import { n as validatePostgresContract } from "./contract-from-json-DrxFlDIH-BD2r2f5C.mjs";
|
|
2
2
|
import { PG_ENUM_CODEC_ID } from "@prisma/orm-target-postgres/target/codec-ids";
|
|
3
3
|
import postgresTarget from "@prisma/orm-target-postgres/target/runtime";
|
|
4
4
|
import { blindCast } from "@prisma/orm-framework/utils/casts";
|
|
@@ -6,7 +6,7 @@ import { buildNamespacedEnums, createEnumAccessor } from "@prisma/orm-framework/
|
|
|
6
6
|
import postgresAdapter from "@prisma/orm-target-postgres/adapter/runtime";
|
|
7
7
|
import { createExecutionContext, createSqlExecutionStack, createToSql } from "@prisma/orm-family-sql/runtime";
|
|
8
8
|
import { createRawLane, sql } from "@prisma/orm-family-sql/builder/runtime";
|
|
9
|
-
//#region ../../../3-targets/postgres/9-facade/dist/postgres-static-
|
|
9
|
+
//#region ../../../3-targets/postgres/9-facade/dist/postgres-static-DhakhOz-.mjs
|
|
10
10
|
/**
|
|
11
11
|
* 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.
|
|
12
12
|
*/
|
|
@@ -77,4 +77,4 @@ function postgresStatic(options) {
|
|
|
77
77
|
//#endregion
|
|
78
78
|
export { buildPostgresStaticContext as n, postgresStatic as r, buildNamespacedNativeEnums as t };
|
|
79
79
|
|
|
80
|
-
//# sourceMappingURL=postgres-static-
|
|
80
|
+
//# sourceMappingURL=postgres-static-DhakhOz--B__mNgdA.mjs.map
|
package/dist/{postgres-static-xbcqtiDZ-BhN7RVCW.mjs.map → postgres-static-DhakhOz--B__mNgdA.mjs.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postgres-static-
|
|
1
|
+
{"version":3,"file":"postgres-static-DhakhOz--B__mNgdA.mjs","names":[],"sources":["../../../../3-targets/postgres/9-facade/dist/postgres-static-DhakhOz-.mjs"],"sourcesContent":["import { n as validatePostgresContract } from \"./contract-from-json-DrxFlDIH.mjs\";\nimport { PG_ENUM_CODEC_ID } from \"@internal/target-postgres/codec-ids\";\nimport postgresTarget from \"@internal/target-postgres/runtime\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { buildNamespacedEnums, createEnumAccessor } from \"@internal/contract/enum-accessor\";\nimport postgresAdapter from \"@internal/adapter-postgres/runtime\";\nimport { createExecutionContext, createSqlExecutionStack, createToSql } from \"@internal/sql-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(contract, context, stack) {\n\tconst { rawCodecInferer } = stack.adapter;\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\treturn {\n\t\tcontext,\n\t\tcontract,\n\t\tenums: Object.freeze(buildNamespacedEnums(context.contract.domain, (codecId) => context.contractCodecs.forCodecRef({ codecId }))),\n\t\tnativeEnums: blindCast(Object.freeze(buildNamespacedNativeEnums(context.contract.storage, context.contract.domain))),\n\t\tsql: sqlDb,\n\t\traw,\n\t\ttoSql: createToSql(stack, contract)\n\t};\n}\n/**\n* The query surfaces of a Postgres client without a driver: `sql`, `raw`, `enums`, `nativeEnums`\n* and `toSql`. Use it where loading `pg` is not wanted, for example in browser code that reads\n* enums.\n*\n* @example\n* ```ts\n* const { enums } = postgresStatic({ contract: contractFromJson<Contract>(contractJson) });\n* ```\n*/\nfunction postgresStatic(options) {\n\tconst contract = validatePostgresContract(options.contract);\n\tconst stack = createSqlExecutionStack({\n\t\ttarget: postgresTarget,\n\t\tadapter: postgresAdapter,\n\t\textensions: options.extensions ?? []\n\t});\n\treturn buildPostgresStaticContext(contract, createExecutionContext({\n\t\tcontract,\n\t\tstack\n\t}), stack);\n}\n//#endregion\nexport { postgresStatic as n, buildNamespacedNativeEnums as r, buildPostgresStaticContext as t };\n\n//# sourceMappingURL=postgres-static-DhakhOz-.mjs.map"],"mappings":";;;;;;;;;;;;AAYA,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,UAAU,SAAS,OAAO;CAC7D,MAAM,EAAE,oBAAoB,MAAM;CAClC,MAAM,QAAQ,IAAI;EACjB;EACA;CACD,CAAC;CACD,MAAM,MAAM,cAAc;EACzB;EACA;CACD,CAAC;CACD,OAAO;EACN;EACA;EACA,OAAO,OAAO,OAAO,qBAAqB,QAAQ,SAAS,SAAS,YAAY,QAAQ,eAAe,YAAY,EAAE,QAAQ,CAAC,CAAC,CAAC;EAChI,aAAa,UAAU,OAAO,OAAO,2BAA2B,QAAQ,SAAS,SAAS,QAAQ,SAAS,MAAM,CAAC,CAAC;EACnH,KAAK;EACL;EACA,OAAO,YAAY,OAAO,QAAQ;CACnC;AACD;;;;;;;;;;;AAWA,SAAS,eAAe,SAAS;CAChC,MAAM,WAAW,yBAAyB,QAAQ,QAAQ;CAC1D,MAAM,QAAQ,wBAAwB;EACrC,QAAQ;EACR,SAAS;EACT,YAAY,QAAQ,cAAc,CAAC;CACpC,CAAC;CACD,OAAO,2BAA2B,UAAU,uBAAuB;EAClE;EACA;CACD,CAAC,GAAG,KAAK;AACV"}
|
package/dist/runtime.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as postgresError } from "./errors-DfWK9xep-CB07krZF.mjs";
|
|
2
2
|
import { a as postgresBindingRules, c as toDriverCursorOptions, i as isPgPool, l as validateCursorOptions, n as connectWithBinding, o as resolveOptionalPostgresBinding, r as isPgClient, s as resolvePostgresBinding } from "./binding-DgumIe5f-BPV5_73g.mjs";
|
|
3
|
-
import { n as validatePostgresContract } from "./contract-from-json-
|
|
4
|
-
import { n as buildPostgresStaticContext, t as buildNamespacedNativeEnums } from "./postgres-static-
|
|
3
|
+
import { n as validatePostgresContract } from "./contract-from-json-DrxFlDIH-BD2r2f5C.mjs";
|
|
4
|
+
import { n as buildPostgresStaticContext, t as buildNamespacedNativeEnums } from "./postgres-static-DhakhOz--B__mNgdA.mjs";
|
|
5
5
|
import { n as buildPostgresRuntimeBoundMembers } from "./postgres-members-Bwcngc1q-HwIhD-Fq.mjs";
|
|
6
6
|
import { t as PostgresRuntimeImpl } from "./postgres-runtime-BKdag6p9-gHVB2jfC.mjs";
|
|
7
7
|
import { InternalError } from "@prisma/orm-framework/utils/internal-error";
|
package/dist/runtime.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.mjs","names":[],"sources":["../../../../3-targets/postgres/9-facade/dist/runtime.mjs"],"sourcesContent":["import { t as postgresError } from \"./errors-DfWK9xep.mjs\";\nimport { a as resolveOptionalPostgresBinding, i as postgresBindingRules, l as toDriverCursorOptions, n as isPgClient, o as resolvePostgresBinding, r as isPgPool, t as connectWithBinding, u as validateCursorOptions } from \"./binding-DgumIe5f.mjs\";\nimport { r as buildNamespacedNativeEnums, t as buildPostgresStaticContext } from \"./postgres-static-
|
|
1
|
+
{"version":3,"file":"runtime.mjs","names":[],"sources":["../../../../3-targets/postgres/9-facade/dist/runtime.mjs"],"sourcesContent":["import { t as postgresError } from \"./errors-DfWK9xep.mjs\";\nimport { a as resolveOptionalPostgresBinding, i as postgresBindingRules, l as toDriverCursorOptions, n as isPgClient, o as resolvePostgresBinding, r as isPgPool, t as connectWithBinding, u as validateCursorOptions } from \"./binding-DgumIe5f.mjs\";\nimport { r as buildNamespacedNativeEnums, t as buildPostgresStaticContext } from \"./postgres-static-DhakhOz-.mjs\";\nimport { n as validatePostgresContract } from \"./contract-from-json-DrxFlDIH.mjs\";\nimport { n as buildPostgresRuntimeBoundMembers } from \"./postgres-members-Bwcngc1q.mjs\";\nimport { t as PostgresRuntimeImpl } from \"./postgres-runtime-BKdag6p9.mjs\";\nimport { InternalError } from \"@internal/utils/internal-error\";\nimport postgresDriver from \"@internal/driver-postgres/runtime\";\nimport postgresTarget from \"@internal/target-postgres/runtime\";\nimport postgresAdapter from \"@internal/adapter-postgres/runtime\";\nimport { createExecutionContext, createSqlExecutionStack, toRuntimeOptions } from \"@internal/sql-runtime\";\n//#region src/runtime/postgres.ts\n/**\n* Creates a lazy Postgres client. The client infers its contract type from `contract`: a value from\n* `contractFromJson` for an emitted contract, or a TypeScript-authored contract. A contract is\n* validated once, however many clients are built from it. The static query surfaces are available\n* at once; the pool is created on the first query or `connect()`.\n*\n* @example\n* ```ts\n* import { contractFromJson } from '@prisma/orm-postgres/static';\n* import postgres from '@prisma/orm-postgres/runtime';\n* import type { Contract } from './contract.d';\n* import contractJson from './contract.json' with { type: 'json' };\n*\n* export const contract = contractFromJson<Contract>(contractJson);\n* export const db = postgres({ contract, url: process.env['DATABASE_URL']! });\n* ```\n*/\nfunction postgres(options) {\n\tconst cursor = validateCursorOptions(options.cursor, \"postgres\");\n\tconst contract = validatePostgresContract(options.contract);\n\tlet binding = resolveOptionalPostgresBinding(options, postgresBindingRules);\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, toSql } = buildPostgresStaticContext(contract, context, stack);\n\tlet runtimeInstance;\n\tlet runtimeDriver;\n\tlet driverConnected = false;\n\tlet connectPromise;\n\tlet backgroundConnectError;\n\tlet closePromise;\n\tconst closedError = () => postgresError(\"DRIVER.NOT_CONNECTED\", \"Postgres client is closed\", {\n\t\twhy: \"close() was called on this client.\",\n\t\tfix: \"Create a new postgres(...) client.\",\n\t\tmeta: { extension: \"postgres\" }\n\t});\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\tconnectPromise = connectWithBinding(runtimeDriver, resolvedBinding, options).then(() => {\n\t\t\tdriverConnected = true;\n\t\t}).catch((err) => {\n\t\t\tbackgroundConnectError = err;\n\t\t\tconnectPromise = 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 closedError();\n\t\tif (backgroundConnectError !== void 0) throw backgroundConnectError;\n\t\tif (runtimeInstance) return runtimeInstance;\n\t\tconst adapter = stack.adapter.create(stack);\n\t\tconst driver = stack.driver.create({ cursor: toDriverCursorOptions(cursor) });\n\t\truntimeDriver = driver;\n\t\tconst runtime = new PostgresRuntimeImpl({\n\t\t\tcontext,\n\t\t\tadapter,\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 closeRuntime = async () => {\n\t\tif (!driverConnected) await connectPromise?.catch(() => void 0);\n\t\tawait runtimeInstance?.close();\n\t};\n\treturn {\n\t\tsql,\n\t\t...buildPostgresRuntimeBoundMembers({\n\t\t\tcontext,\n\t\t\tcollections: options.collections,\n\t\t\tsql,\n\t\t\traw: rawSqlTag,\n\t\t\tenums,\n\t\t\tnativeEnums,\n\t\t\ttoSql,\n\t\t\tgetRuntime,\n\t\t\tgetRuntimeForWork: getRuntime\n\t\t}),\n\t\tenums,\n\t\tnativeEnums,\n\t\traw: rawSqlTag,\n\t\ttoSql,\n\t\tcontext,\n\t\tcontract,\n\t\tstack,\n\t\tasync connect(bindingInput) {\n\t\t\tif (closePromise !== void 0) throw closedError();\n\t\t\tif (driverConnected || connectPromise) {\n\t\t\t\tif (bindingInput !== void 0) throw postgresError(\"DRIVER.ALREADY_CONNECTED\", \"Postgres client is already bound\", {\n\t\t\t\t\twhy: \"connect() was given options after the client was bound to a database.\",\n\t\t\t\t\tfix: \"Call connect() without options, or create a new client for another database.\",\n\t\t\t\t\tmeta: { extension: \"postgres\" }\n\t\t\t\t});\n\t\t\t\tconst runtime = getRuntime();\n\t\t\t\tawait connectPromise;\n\t\t\t\tif (closePromise !== void 0) throw closedError();\n\t\t\t\treturn runtime;\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\tif (closePromise !== void 0) throw closedError();\n\t\t\treturn runtime;\n\t\t},\n\t\tclose() {\n\t\t\tclosePromise ??= closeRuntime();\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,SAAS,SAAS,SAAS;CAC1B,MAAM,SAAS,sBAAsB,QAAQ,QAAQ,UAAU;CAC/D,MAAM,WAAW,yBAAyB,QAAQ,QAAQ;CAC1D,IAAI,UAAU,+BAA+B,SAAS,oBAAoB;CAC1E,MAAM,QAAQ,wBAAwB;EACrC,QAAQ;EACR,SAAS;EACT,QAAQ;EACR,YAAY,QAAQ,cAAc,CAAC;CACpC,CAAC;CACD,MAAM,UAAU,uBAAuB;EACtC;EACA;EACA,QAAQ;CACT,CAAC;CACD,MAAM,EAAE,KAAK,KAAK,WAAW,OAAO,aAAa,UAAU,2BAA2B,UAAU,SAAS,KAAK;CAC9G,IAAI;CACJ,IAAI;CACJ,IAAI,kBAAkB;CACtB,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,MAAM,oBAAoB,cAAc,wBAAwB,6BAA6B;EAC5F,KAAK;EACL,KAAK;EACL,MAAM,EAAE,WAAW,WAAW;CAC/B,CAAC;CACD,MAAM,gBAAgB,OAAO,oBAAoB;EAChD,IAAI,iBAAiB;EACrB,IAAI,CAAC,eAAe,MAAM,IAAI,cAAc,iCAAiC;EAC7E,IAAI,gBAAgB,OAAO;EAC3B,iBAAiB,mBAAmB,eAAe,iBAAiB,OAAO,CAAC,CAAC,WAAW;GACvF,kBAAkB;EACnB,CAAC,CAAC,CAAC,OAAO,QAAQ;GACjB,yBAAyB;GACzB,iBAAiB,KAAK;GACtB,MAAM;EACP,CAAC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,CAAC;GAChN,MAAM,UAAU,WAAW;GAC3B,IAAI,iBAAiB,OAAO;GAC5B,MAAM,cAAc,OAAO;GAC3B,IAAI,iBAAiB,KAAK,GAAG,MAAM,YAAY;GAC/C,OAAO;EACR;EACA,QAAQ;GACP,iBAAiB,aAAa;GAC9B,OAAO;EACR;EACA,CAAC,OAAO,gBAAgB;GACvB,OAAO,KAAK,MAAM;EACnB;CACD;AACD"}
|
package/dist/serverless.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as postgresError } from "./errors-DfWK9xep-CB07krZF.mjs";
|
|
2
2
|
import { c as toDriverCursorOptions, l as validateCursorOptions, t as DEFAULT_CONNECT_TIMEOUT_MILLIS, u as validatePostgresUrl } from "./binding-DgumIe5f-BPV5_73g.mjs";
|
|
3
|
-
import { n as validatePostgresContract } from "./contract-from-json-
|
|
4
|
-
import { n as buildPostgresStaticContext } from "./postgres-static-
|
|
3
|
+
import { n as validatePostgresContract } from "./contract-from-json-DrxFlDIH-BD2r2f5C.mjs";
|
|
4
|
+
import { n as buildPostgresStaticContext } from "./postgres-static-DhakhOz--B__mNgdA.mjs";
|
|
5
5
|
import { n as buildPostgresRuntimeBoundMembers } from "./postgres-members-Bwcngc1q-HwIhD-Fq.mjs";
|
|
6
6
|
import { t as PostgresRuntimeImpl } from "./postgres-runtime-BKdag6p9-gHVB2jfC.mjs";
|
|
7
7
|
import { InternalError } from "@prisma/orm-framework/utils/internal-error";
|
package/dist/serverless.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serverless.mjs","names":[],"sources":["../../../../3-targets/postgres/9-facade/dist/serverless.mjs"],"sourcesContent":["import { t as postgresError } from \"./errors-DfWK9xep.mjs\";\nimport { c as DEFAULT_CONNECT_TIMEOUT_MILLIS, l as toDriverCursorOptions, s as validatePostgresUrl, u as validateCursorOptions } from \"./binding-DgumIe5f.mjs\";\nimport { t as buildPostgresStaticContext } from \"./postgres-static-
|
|
1
|
+
{"version":3,"file":"serverless.mjs","names":[],"sources":["../../../../3-targets/postgres/9-facade/dist/serverless.mjs"],"sourcesContent":["import { t as postgresError } from \"./errors-DfWK9xep.mjs\";\nimport { c as DEFAULT_CONNECT_TIMEOUT_MILLIS, l as toDriverCursorOptions, s as validatePostgresUrl, u as validateCursorOptions } from \"./binding-DgumIe5f.mjs\";\nimport { t as buildPostgresStaticContext } from \"./postgres-static-DhakhOz-.mjs\";\nimport { n as validatePostgresContract } from \"./contract-from-json-DrxFlDIH.mjs\";\nimport { n as buildPostgresRuntimeBoundMembers } from \"./postgres-members-Bwcngc1q.mjs\";\nimport { t as PostgresRuntimeImpl } from \"./postgres-runtime-BKdag6p9.mjs\";\nimport { InternalError } from \"@internal/utils/internal-error\";\nimport postgresDriver, { createPgClient, suppressIdleConnectionErrors } from \"@internal/driver-postgres/runtime\";\nimport postgresTarget from \"@internal/target-postgres/runtime\";\nimport postgresAdapter from \"@internal/adapter-postgres/runtime\";\nimport { createExecutionContext, createSqlExecutionStack, toRuntimeOptions } from \"@internal/sql-runtime\";\nimport { redactDatabaseUrl } from \"@internal/utils/redact-db-url\";\n//#region src/runtime/postgres-serverless.ts\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}\n/**\n* Creates a serverless client for serverless and edge runtimes (Cloudflare Workers + Hyperdrive,\n* AWS Lambda, Vercel, Deno Deploy).\n*\n* The serverless client holds no database connection and has the static members. Each\n* `connect({ url })` opens one database connection, a fresh `pg.Client`, and returns a connection\n* with the members of a `postgres()` client except `connect`. It rejects with\n* `DRIVER.CONNECTION_FAILED` when the database refuses the connection, rejects the credentials,\n* or does not answer within 20 seconds. Close the connection with `await using` or `close()`.\n*\n* The client infers its contract type from `contract` and validates it once, when the client is\n* created; connections reuse it.\n*\n* @example\n* ```ts\n* const postgres = postgresServerless({ contract: contractFromJson<Contract>(contractJson) });\n*\n* export default {\n* async fetch(_req: Request, env: Env): Promise<Response> {\n* await using db = await postgres.connect({ url: env.HYPERDRIVE.connectionString });\n* const users = await db.orm.public.User.all();\n* return Response.json(users);\n* },\n* };\n* ```\n*/\nfunction postgresServerless(options) {\n\tconst cursor = validateCursorOptions(options.cursor, \"postgresServerless\");\n\tconst contract = validatePostgresContract(options.contract);\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, enums, nativeEnums, toSql } = buildPostgresStaticContext(contract, context, stack);\n\tconst buildRuntimeBoundMembers = (getRuntime, getRuntimeForWork) => buildPostgresRuntimeBoundMembers({\n\t\tcontext,\n\t\tcollections: options.collections,\n\t\tsql,\n\t\traw,\n\t\tenums,\n\t\tnativeEnums,\n\t\ttoSql,\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\ttoSql,\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\ttoSql,\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\tconst adapter = stack.adapter.create(stack);\n\t\t\tconst driver = driverDescriptor.create({ cursor: toDriverCursorOptions(cursor) });\n\t\t\tconst pgClient = suppressIdleConnectionErrors(createPgClient({\n\t\t\t\tconnectionString: url,\n\t\t\t\tconnectionTimeoutMillis: DEFAULT_CONNECT_TIMEOUT_MILLIS\n\t\t\t}, stack.target.sessionSettings ?? {}));\n\t\t\tawait driver.connect({\n\t\t\t\tkind: \"pgClient\",\n\t\t\t\tclient: pgClient,\n\t\t\t\townedByDriver: true\n\t\t\t});\n\t\t\tconst runtime = new PostgresRuntimeImpl({\n\t\t\t\tcontext,\n\t\t\t\tadapter,\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\tawait driver.close().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,wBAAwB;C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A;EACA;EACA;EACA,MAAM,QAAQ,SAAS;GACtB,MAAM,MAAM,oBAAoB,QAAQ,GAAG;GAC3C,MAAM,mBAAmB,MAAM;GAC/B,MAAM,UAAU,MAAM,QAAQ,OAAO,KAAK;GAC1C,MAAM,SAAS,iBAAiB,OAAO,EAAE,QAAQ,sBAAsB,MAAM,EAAE,CAAC;GAChF,MAAM,WAAW,6BAA6B,eAAe;IAC5D,kBAAkB;IAClB,yBAAyB;GAC1B,GAAG,MAAM,OAAO,mBAAmB,CAAC,CAAC,CAAC;GACtC,MAAM,OAAO,QAAQ;IACpB,MAAM;IACN,QAAQ;IACR,eAAe;GAChB,CAAC;GACD,MAAM,UAAU,IAAI,oBAAoB;IACvC;IACA;IACA;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,MAAM,OAAO,MAAM,CAAC,CAAC,YAAY,KAAK,CAAC;IACvC,MAAM,sBAAsB,KAAK,GAAG;GACrC;GACA,OAAO;EACR;CACD;AACD"}
|
package/dist/static.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { t as contractFromJson } from "./contract-from-json-
|
|
2
|
-
import { r as postgresStatic } from "./postgres-static-
|
|
1
|
+
import { t as contractFromJson } from "./contract-from-json-DrxFlDIH-BD2r2f5C.mjs";
|
|
2
|
+
import { r as postgresStatic } from "./postgres-static-DhakhOz--B__mNgdA.mjs";
|
|
3
3
|
export { contractFromJson, 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.22-dev.
|
|
3
|
+
"version": "8.0.0-rc.22-dev.15",
|
|
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.22-dev.
|
|
14
|
-
"@prisma/orm-framework": "8.0.0-rc.22-dev.
|
|
15
|
-
"@prisma/orm-target-postgres": "8.0.0-rc.22-dev.
|
|
16
|
-
"@prisma/orm-toolchain": "8.0.0-rc.22-dev.
|
|
13
|
+
"@prisma/orm-family-sql": "8.0.0-rc.22-dev.15",
|
|
14
|
+
"@prisma/orm-framework": "8.0.0-rc.22-dev.15",
|
|
15
|
+
"@prisma/orm-target-postgres": "8.0.0-rc.22-dev.15",
|
|
16
|
+
"@prisma/orm-toolchain": "8.0.0-rc.22-dev.15",
|
|
17
17
|
"@types/node": "26.1.2",
|
|
18
18
|
"@types/pg": "8.20.4",
|
|
19
19
|
"arktype": "^2.2.2",
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
"tinyglobby": "^0.2.17"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@internal/postgres": "8.0.0-rc.22-dev.
|
|
27
|
-
"@repo/tsconfig": "8.0.0-rc.22-dev.
|
|
28
|
-
"@repo/tsdown": "8.0.0-rc.22-dev.
|
|
26
|
+
"@internal/postgres": "8.0.0-rc.22-dev.15",
|
|
27
|
+
"@repo/tsconfig": "8.0.0-rc.22-dev.15",
|
|
28
|
+
"@repo/tsdown": "8.0.0-rc.22-dev.15",
|
|
29
29
|
"tsdown": "0.22.14",
|
|
30
30
|
"typescript": "5.9.3"
|
|
31
31
|
},
|
package/skills/prisma-8/SKILL.md
CHANGED
|
@@ -91,7 +91,7 @@ Move on to the next step. Repeat.
|
|
|
91
91
|
|
|
92
92
|
Prisma 8 extensions pin every `@prisma/orm-*` SPI dependency (everything except `@prisma/orm-extension-*`) to a single **exact** version (no `^`, no `~`, no range, no wildcard, no `workspace:` specifier in the published `package.json`). All of those entries share the same version. The pin advances after each successful upgrade step, release-candidate steps included.
|
|
93
93
|
|
|
94
|
-
The version is the one the application's database package (`@prisma/orm-postgres`, `@prisma/orm-mongo`, …) uses.
|
|
94
|
+
The version is the one the application's database package (`@prisma/orm-postgres`, `@prisma/orm-mongo`, …) uses. Values and registries made by one copy of Prisma ORM are not recognised by another, so they must never cross between copies. A host may load two copies on purpose, as Prisma Composer's boot wrapper does beside the application bundle, but the application, its extensions and the `prisma` CLI must share one. When an extension pins a different version, the package manager installs a second copy beside the application's, and the extension's values then cross between copies. The target package (such as `@prisma/orm-target-postgres`) is therefore a **peer dependency**, so npm refuses a mismatched install instead of adding a copy. The framework and family packages are ordinary dependencies at the same version. pnpm and bun only warn about a mismatched peer, so a second copy can still be installed. `npm ls @prisma/orm-framework`, `pnpm why @prisma/orm-framework` or `bun why @prisma/orm-framework` lists every copy and the package that brought it.
|
|
95
95
|
|
|
96
96
|
The one-line check in step 3 of the per-step flow enforces the rule; the `prisma-8-check-pins` guard the monorepo uses for its own extensions is not published. Wire the check into the extension's CI alongside the build/test step so an accidental range pin fails the PR before it lands.
|
|
97
97
|
|
|
@@ -4,7 +4,7 @@ to: "8.0.0-rc.22"
|
|
|
4
4
|
changes:
|
|
5
5
|
- id: one-orm-version
|
|
6
6
|
summary: |
|
|
7
|
-
Every `@prisma/orm-*` package and the `prisma` CLI must run one version of Prisma ORM.
|
|
7
|
+
Every `@prisma/orm-*` package and the `prisma` CLI must run one version of Prisma ORM. In 8.0.0-rc.22, commands and clients stop with `RUNTIME.MULTIPLE_ORM_COPIES` when more than one copy is installed; later releases remove that check, but a second copy still breaks values that cross between copies.
|
|
8
8
|
detection:
|
|
9
9
|
glob: "package.json"
|
|
10
10
|
matches:
|
|
@@ -175,7 +175,7 @@ Do the steps in this order, and skip a step that does not apply to the project:
|
|
|
175
175
|
|
|
176
176
|
## One version of Prisma ORM
|
|
177
177
|
|
|
178
|
-
|
|
178
|
+
In 8.0.0-rc.22, commands and clients refuse to start when Prisma ORM is loaded from more than one folder. Later releases remove that check, because a host that loads the ORM in two module instances cannot satisfy it. A project with mismatched versions can still fail with an internal error, for example on the first literal `@default` in `prisma contract emit`.
|
|
179
179
|
|
|
180
180
|
After upgrading, check that one copy is installed:
|
|
181
181
|
|