@prisma/orm-postgres 0.16.0-dev.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +56 -0
- package/dist/adapter.d.mts +1 -0
- package/dist/adapter.mjs +2 -0
- package/dist/adapter__adapter.d.mts +1 -0
- package/dist/adapter__adapter.mjs +2 -0
- package/dist/adapter__column-types.d.mts +1 -0
- package/dist/adapter__column-types.mjs +2 -0
- package/dist/adapter__control.d.mts +3 -0
- package/dist/adapter__control.mjs +3 -0
- package/dist/adapter__operation-types.d.mts +1 -0
- package/dist/adapter__operation-types.mjs +2 -0
- package/dist/adapter__runtime.d.mts +3 -0
- package/dist/adapter__runtime.mjs +3 -0
- package/dist/adapter__types.d.mts +1 -0
- package/dist/adapter__types.mjs +2 -0
- package/dist/bin__prisma-next.mjs +3 -0
- package/dist/builder.d.mts +1 -0
- package/dist/builder.mjs +2 -0
- package/dist/builder__runtime.d.mts +1 -0
- package/dist/builder__runtime.mjs +2 -0
- package/dist/builder__types.d.mts +1 -0
- package/dist/builder__types.mjs +2 -0
- package/dist/components.d.mts +1 -0
- package/dist/components.mjs +2 -0
- package/dist/components__authoring.d.mts +1 -0
- package/dist/components__authoring.mjs +2 -0
- package/dist/components__codec.d.mts +1 -0
- package/dist/components__codec.mjs +2 -0
- package/dist/components__components.d.mts +1 -0
- package/dist/components__components.mjs +2 -0
- package/dist/components__control.d.mts +1 -0
- package/dist/components__control.mjs +2 -0
- package/dist/components__emission.d.mts +1 -0
- package/dist/components__emission.mjs +2 -0
- package/dist/components__execution.d.mts +1 -0
- package/dist/components__execution.mjs +2 -0
- package/dist/components__ir.d.mts +1 -0
- package/dist/components__ir.mjs +2 -0
- package/dist/components__psl-ast.d.mts +1 -0
- package/dist/components__psl-ast.mjs +2 -0
- package/dist/components__runtime.d.mts +1 -0
- package/dist/components__runtime.mjs +2 -0
- package/dist/components__utils.d.mts +1 -0
- package/dist/components__utils.mjs +2 -0
- package/dist/config.d.mts +19 -0
- package/dist/config.d.mts.map +1 -0
- package/dist/config.mjs +44 -0
- package/dist/config.mjs.map +1 -0
- package/dist/contract-builder.d.mts +521 -0
- package/dist/contract-builder.d.mts.map +1 -0
- package/dist/contract-builder.mjs +232 -0
- package/dist/contract-builder.mjs.map +1 -0
- package/dist/contract.d.mts +1 -0
- package/dist/contract.mjs +2 -0
- package/dist/contract__apply-specifier-default-control-policy.d.mts +1 -0
- package/dist/contract__apply-specifier-default-control-policy.mjs +2 -0
- package/dist/contract__contract-validation-error.d.mts +1 -0
- package/dist/contract__contract-validation-error.mjs +2 -0
- package/dist/contract__default-namespace.d.mts +1 -0
- package/dist/contract__default-namespace.mjs +2 -0
- package/dist/contract__enum-accessor.d.mts +1 -0
- package/dist/contract__enum-accessor.mjs +2 -0
- package/dist/contract__hashing-utils.d.mts +1 -0
- package/dist/contract__hashing-utils.mjs +2 -0
- package/dist/contract__hashing.d.mts +1 -0
- package/dist/contract__hashing.mjs +2 -0
- package/dist/contract__is-plain-record.d.mts +1 -0
- package/dist/contract__is-plain-record.mjs +2 -0
- package/dist/contract__resolve-domain-model.d.mts +1 -0
- package/dist/contract__resolve-domain-model.mjs +2 -0
- package/dist/contract__types.d.mts +1 -0
- package/dist/contract__types.mjs +2 -0
- package/dist/contract__validate-domain.d.mts +1 -0
- package/dist/contract__validate-domain.mjs +2 -0
- package/dist/control.d.mts +20 -0
- package/dist/control.d.mts.map +1 -0
- package/dist/control.mjs +29 -0
- package/dist/control.mjs.map +1 -0
- package/dist/driver.d.mts +1 -0
- package/dist/driver.mjs +2 -0
- package/dist/driver__control.d.mts +3 -0
- package/dist/driver__control.mjs +3 -0
- package/dist/driver__runtime.d.mts +3 -0
- package/dist/driver__runtime.mjs +3 -0
- package/dist/errors-DfWK9xep-CYOOg0sB.mjs +9 -0
- package/dist/errors-DfWK9xep-CYOOg0sB.mjs.map +1 -0
- package/dist/family-contract.d.mts +1 -0
- package/dist/family-contract.mjs +2 -0
- package/dist/family-contract__canonicalization-hooks.d.mts +1 -0
- package/dist/family-contract__canonicalization-hooks.mjs +2 -0
- package/dist/family-contract__contract-view.d.mts +1 -0
- package/dist/family-contract__contract-view.mjs +2 -0
- package/dist/family-contract__entity-handle-lowering-hook.d.mts +1 -0
- package/dist/family-contract__entity-handle-lowering-hook.mjs +2 -0
- package/dist/family-contract__entity-kinds.d.mts +1 -0
- package/dist/family-contract__entity-kinds.mjs +2 -0
- package/dist/family-contract__factories.d.mts +1 -0
- package/dist/family-contract__factories.mjs +2 -0
- package/dist/family-contract__foreign-key-materialization.d.mts +1 -0
- package/dist/family-contract__foreign-key-materialization.mjs +2 -0
- package/dist/family-contract__index-naming.d.mts +1 -0
- package/dist/family-contract__index-naming.mjs +2 -0
- package/dist/family-contract__index-type-validation.d.mts +1 -0
- package/dist/family-contract__index-type-validation.mjs +2 -0
- package/dist/family-contract__index-types.d.mts +1 -0
- package/dist/family-contract__index-types.mjs +2 -0
- package/dist/family-contract__pack-types.d.mts +1 -0
- package/dist/family-contract__pack-types.mjs +2 -0
- package/dist/family-contract__referential-action-sql.d.mts +1 -0
- package/dist/family-contract__referential-action-sql.mjs +2 -0
- package/dist/family-contract__resolve-storage-table.d.mts +1 -0
- package/dist/family-contract__resolve-storage-table.mjs +2 -0
- package/dist/family-contract__types.d.mts +1 -0
- package/dist/family-contract__types.mjs +2 -0
- package/dist/family-contract__validators.d.mts +1 -0
- package/dist/family-contract__validators.mjs +2 -0
- package/dist/family-contract__value-set-derivation-hook.d.mts +1 -0
- package/dist/family-contract__value-set-derivation-hook.mjs +2 -0
- package/dist/family-runtime.d.mts +1 -0
- package/dist/family-runtime.mjs +2 -0
- package/dist/family.d.mts +2 -0
- package/dist/family.mjs +2 -0
- package/dist/family__control-adapter.d.mts +1 -0
- package/dist/family__control-adapter.mjs +2 -0
- package/dist/family__control.d.mts +3 -0
- package/dist/family__control.mjs +3 -0
- package/dist/family__diff.d.mts +1 -0
- package/dist/family__diff.mjs +2 -0
- package/dist/family__ir.d.mts +1 -0
- package/dist/family__ir.mjs +2 -0
- package/dist/family__migration.d.mts +1 -0
- package/dist/family__migration.mjs +2 -0
- package/dist/family__pack.d.mts +3 -0
- package/dist/family__pack.mjs +3 -0
- package/dist/family__psl-infer.d.mts +1 -0
- package/dist/family__psl-infer.mjs +2 -0
- package/dist/family__runtime.d.mts +3 -0
- package/dist/family__runtime.mjs +3 -0
- package/dist/family__verify.d.mts +1 -0
- package/dist/family__verify.mjs +2 -0
- package/dist/migration-tools__aggregate.d.mts +1 -0
- package/dist/migration-tools__aggregate.mjs +2 -0
- package/dist/migration-tools__contract-snapshot-store.d.mts +1 -0
- package/dist/migration-tools__contract-snapshot-store.mjs +2 -0
- package/dist/migration-tools__hash.d.mts +1 -0
- package/dist/migration-tools__hash.mjs +2 -0
- package/dist/migration-tools__io.d.mts +1 -0
- package/dist/migration-tools__io.mjs +2 -0
- package/dist/migration-tools__spaces.d.mts +1 -0
- package/dist/migration-tools__spaces.mjs +2 -0
- package/dist/migration.d.mts +1 -0
- package/dist/migration.mjs +2 -0
- package/dist/orm-client.d.mts +1 -0
- package/dist/orm-client.mjs +2 -0
- package/dist/postgres-DfqgVPdF-DhNG3N-h.d.mts +133 -0
- package/dist/postgres-DfqgVPdF-DhNG3N-h.d.mts.map +1 -0
- package/dist/postgres-runtime-GybTEgP4-DpGY305_.mjs +7 -0
- package/dist/postgres-runtime-GybTEgP4-DpGY305_.mjs.map +1 -0
- package/dist/postgres-static-CRl91mRo-Dw1sFrog.mjs +74 -0
- package/dist/postgres-static-CRl91mRo-Dw1sFrog.mjs.map +1 -0
- package/dist/relational-core.d.mts +1 -0
- package/dist/relational-core.mjs +2 -0
- package/dist/relational-core__ast.d.mts +1 -0
- package/dist/relational-core__ast.mjs +2 -0
- package/dist/relational-core__codec-descriptor-registry.d.mts +1 -0
- package/dist/relational-core__codec-descriptor-registry.mjs +2 -0
- package/dist/relational-core__contract-free.d.mts +1 -0
- package/dist/relational-core__contract-free.mjs +2 -0
- package/dist/relational-core__expression.d.mts +1 -0
- package/dist/relational-core__expression.mjs +2 -0
- package/dist/relational-core__middleware.d.mts +1 -0
- package/dist/relational-core__middleware.mjs +2 -0
- package/dist/relational-core__plan.d.mts +1 -0
- package/dist/relational-core__plan.mjs +2 -0
- package/dist/relational-core__query-lane-context.d.mts +1 -0
- package/dist/relational-core__query-lane-context.mjs +2 -0
- package/dist/relational-core__types.d.mts +1 -0
- package/dist/relational-core__types.mjs +2 -0
- package/dist/runtime.d.mts +18 -0
- package/dist/runtime.d.mts.map +1 -0
- package/dist/runtime.mjs +239 -0
- package/dist/runtime.mjs.map +1 -0
- package/dist/schema-ir__types.d.mts +1 -0
- package/dist/schema-ir__types.mjs +2 -0
- package/dist/serverless.d.mts +62 -0
- package/dist/serverless.d.mts.map +1 -0
- package/dist/serverless.mjs +86 -0
- package/dist/serverless.mjs.map +1 -0
- package/dist/static.d.mts +24 -0
- package/dist/static.d.mts.map +1 -0
- package/dist/static.mjs +2 -0
- package/dist/target.d.mts +2 -0
- package/dist/target.mjs +2 -0
- package/dist/target__codec-descriptor.d.mts +1 -0
- package/dist/target__codec-descriptor.mjs +2 -0
- package/dist/target__codec-ids.d.mts +1 -0
- package/dist/target__codec-ids.mjs +2 -0
- package/dist/target__codec-types.d.mts +1 -0
- package/dist/target__codec-types.mjs +2 -0
- package/dist/target__codecs.d.mts +1 -0
- package/dist/target__codecs.mjs +2 -0
- package/dist/target__contract-free.d.mts +1 -0
- package/dist/target__contract-free.mjs +2 -0
- package/dist/target__control.d.mts +3 -0
- package/dist/target__control.mjs +3 -0
- package/dist/target__data-transform.d.mts +1 -0
- package/dist/target__data-transform.mjs +2 -0
- package/dist/target__ddl.d.mts +1 -0
- package/dist/target__ddl.mjs +2 -0
- package/dist/target__default-normalizer.d.mts +1 -0
- package/dist/target__default-normalizer.mjs +2 -0
- package/dist/target__diff-database-schema.d.mts +1 -0
- package/dist/target__diff-database-schema.mjs +2 -0
- package/dist/target__errors.d.mts +1 -0
- package/dist/target__errors.mjs +2 -0
- package/dist/target__issue-planner.d.mts +1 -0
- package/dist/target__issue-planner.mjs +2 -0
- package/dist/target__migration.d.mts +1 -0
- package/dist/target__migration.mjs +2 -0
- package/dist/target__native-type-normalizer.d.mts +1 -0
- package/dist/target__native-type-normalizer.mjs +2 -0
- package/dist/target__op-factory-call.d.mts +1 -0
- package/dist/target__op-factory-call.mjs +2 -0
- package/dist/target__pack.d.mts +3 -0
- package/dist/target__pack.mjs +3 -0
- package/dist/target__planner-ddl-builders.d.mts +1 -0
- package/dist/target__planner-ddl-builders.mjs +2 -0
- package/dist/target__planner-identity-values.d.mts +1 -0
- package/dist/target__planner-identity-values.mjs +2 -0
- package/dist/target__planner-produced-postgres-migration.d.mts +1 -0
- package/dist/target__planner-produced-postgres-migration.mjs +2 -0
- package/dist/target__planner-schema-lookup.d.mts +1 -0
- package/dist/target__planner-schema-lookup.mjs +2 -0
- package/dist/target__planner-sql-checks.d.mts +1 -0
- package/dist/target__planner-sql-checks.mjs +2 -0
- package/dist/target__planner-target-details.d.mts +1 -0
- package/dist/target__planner-target-details.mjs +2 -0
- package/dist/target__planner.d.mts +1 -0
- package/dist/target__planner.mjs +2 -0
- package/dist/target__render-ops.d.mts +1 -0
- package/dist/target__render-ops.mjs +2 -0
- package/dist/target__render-typescript.d.mts +1 -0
- package/dist/target__render-typescript.mjs +2 -0
- package/dist/target__rls-canonicalize.d.mts +1 -0
- package/dist/target__rls-canonicalize.mjs +2 -0
- package/dist/target__runtime.d.mts +3 -0
- package/dist/target__runtime.mjs +3 -0
- package/dist/target__schema-ir-annotations.d.mts +1 -0
- package/dist/target__schema-ir-annotations.mjs +2 -0
- package/dist/target__sql-utils.d.mts +1 -0
- package/dist/target__sql-utils.mjs +2 -0
- package/dist/target__types.d.mts +1 -0
- package/dist/target__types.mjs +2 -0
- package/dist/utils.d.mts +1 -0
- package/dist/utils.mjs +2 -0
- package/dist/utils__abortable.d.mts +1 -0
- package/dist/utils__abortable.mjs +2 -0
- package/dist/utils__array-equal.d.mts +1 -0
- package/dist/utils__array-equal.mjs +2 -0
- package/dist/utils__assertions.d.mts +1 -0
- package/dist/utils__assertions.mjs +2 -0
- package/dist/utils__canonical-stringify.d.mts +1 -0
- package/dist/utils__canonical-stringify.mjs +2 -0
- package/dist/utils__casts.d.mts +1 -0
- package/dist/utils__casts.mjs +2 -0
- package/dist/utils__defined.d.mts +1 -0
- package/dist/utils__defined.mjs +2 -0
- package/dist/utils__hash-content.d.mts +1 -0
- package/dist/utils__hash-content.mjs +2 -0
- package/dist/utils__internal-error.d.mts +1 -0
- package/dist/utils__internal-error.mjs +2 -0
- package/dist/utils__json.d.mts +1 -0
- package/dist/utils__json.mjs +2 -0
- package/dist/utils__promise.d.mts +1 -0
- package/dist/utils__promise.mjs +2 -0
- package/dist/utils__redact-db-url.d.mts +1 -0
- package/dist/utils__redact-db-url.mjs +2 -0
- package/dist/utils__result.d.mts +1 -0
- package/dist/utils__result.mjs +2 -0
- package/dist/utils__simplify-deep.d.mts +1 -0
- package/dist/utils__simplify-deep.mjs +2 -0
- package/dist/utils__structured-error.d.mts +1 -0
- package/dist/utils__structured-error.mjs +2 -0
- package/dist/utils__types.d.mts +1 -0
- package/dist/utils__types.mjs +2 -0
- package/dist/vite-plugin-contract-emit.d.mts +1 -0
- package/dist/vite-plugin-contract-emit.mjs +2 -0
- package/package.json +188 -0
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import { t as postgresError } from "./errors-DfWK9xep-CYOOg0sB.mjs";
|
|
2
|
+
import { PG_ENUM_CODEC_ID } from "@prisma/orm-target-postgres/target/codec-ids";
|
|
3
|
+
import postgresPackRef from "@prisma/orm-target-postgres/target/pack";
|
|
4
|
+
import { PostgresNativeEnum, postgresCreateNamespace } from "@prisma/orm-target-postgres/target/types";
|
|
5
|
+
import { ifDefined } from "@prisma/orm-framework/utils/defined";
|
|
6
|
+
import { bindEnumType, buildBoundContract, buildSqlContractFromDefinition, field, member, model, rel } from "@prisma/orm-family-sql/contract-ts/contract-builder";
|
|
7
|
+
import sqlFamilyPack from "@prisma/orm-family-sql/family/pack";
|
|
8
|
+
import { pgEnumDescriptor } from "@prisma/orm-target-postgres/target/codecs";
|
|
9
|
+
import { InternalError } from "@prisma/orm-framework/utils/internal-error";
|
|
10
|
+
import { POLICY_OPERATION_PREDICATES } from "@prisma/orm-target-postgres/target/rls-canonicalize";
|
|
11
|
+
//#region ../../../3-extensions/postgres/dist/contract-builder.mjs
|
|
12
|
+
function defineContract(definition, factory) {
|
|
13
|
+
const bound = {
|
|
14
|
+
...definition,
|
|
15
|
+
createNamespace: postgresCreateNamespace
|
|
16
|
+
};
|
|
17
|
+
if (factory !== void 0) return buildBoundContract(sqlFamilyPack, postgresPackRef, bound, factory);
|
|
18
|
+
return buildBoundContract(sqlFamilyPack, postgresPackRef, bound);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The `enumType` authors call when building a Postgres contract (re-exported
|
|
22
|
+
* from `@internal/postgres/contract-builder`).
|
|
23
|
+
*
|
|
24
|
+
* `bindEnumType` is the core, codec-agnostic `enumType` factory; calling it with
|
|
25
|
+
* the Postgres pack's codec typemap fixes which member-value type each codec
|
|
26
|
+
* permits, so `member()` values are checked against the column's codec at
|
|
27
|
+
* authoring time: `pg/text@1` requires `string`, `pg/int4@1` requires `number`,
|
|
28
|
+
* and a mismatch is a compile error. The core `enumType` can't know the codec
|
|
29
|
+
* set, which is why the binding happens here, per target.
|
|
30
|
+
*/
|
|
31
|
+
const enumType = bindEnumType();
|
|
32
|
+
function buildNativeEnumHandle(name, typeName, members) {
|
|
33
|
+
if (typeName.trim().length === 0) throw postgresError("CONTRACT.ENUM_INVALID", `nativeEnum("${name}"): the Postgres type name must be a non-empty string.`, {
|
|
34
|
+
fix: "Pass a non-empty Postgres type name to .map(typeName).",
|
|
35
|
+
meta: {
|
|
36
|
+
enumName: name,
|
|
37
|
+
reason: "empty type name"
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
return {
|
|
41
|
+
entityKind: "native_enum",
|
|
42
|
+
name,
|
|
43
|
+
typeName,
|
|
44
|
+
members,
|
|
45
|
+
entity: new PostgresNativeEnum({
|
|
46
|
+
typeName,
|
|
47
|
+
members
|
|
48
|
+
}),
|
|
49
|
+
map: (mappedTypeName) => buildNativeEnumHandle(name, mappedTypeName, members)
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Declares a native Postgres enum type for use with {@link pg}'s `.enum()`
|
|
54
|
+
* column helper. Mirrors PSL's `native_enum <Name> { … }` lowering
|
|
55
|
+
* (`lowerNativeEnumFromBlock`): validates a non-empty, duplicate-free member
|
|
56
|
+
* list and builds the same {@link PostgresNativeEnum} entity. Its value-set is
|
|
57
|
+
* derived generically at contract-build time — the same
|
|
58
|
+
* `deriveValueSetFromEntity` fold PSL's native enums go through — once
|
|
59
|
+
* `pg.enum(handle)` lands the entity in the field's owning namespace.
|
|
60
|
+
*
|
|
61
|
+
* The first argument is the entity `name` (the `entries.native_enum` /
|
|
62
|
+
* `entries.valueSet` key). The Postgres type name defaults to `name`; use
|
|
63
|
+
* `.map(typeName)` to override it (PSL's `@@map`).
|
|
64
|
+
*
|
|
65
|
+
* A handle referenced by columns in N different namespaces materialises N
|
|
66
|
+
* native enum types (one per namespace) — by design: a Postgres type lives in
|
|
67
|
+
* exactly one schema, and PSL can't share a type across schemas either.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```ts
|
|
71
|
+
* // name === Postgres type name
|
|
72
|
+
* const Role = nativeEnum('Role', 'user', 'admin');
|
|
73
|
+
* // entity name `AalLevel`, Postgres type `aal_level` (Supabase's auth.aal_level)
|
|
74
|
+
* const AalLevel = nativeEnum('AalLevel', 'aal1', 'aal2', 'aal3').map('aal_level');
|
|
75
|
+
* model('Session', { fields: { aal: field.column(pg.enum(AalLevel)).optional() } });
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
function nativeEnum(name, ...members) {
|
|
79
|
+
if (name.trim().length === 0) throw postgresError("CONTRACT.ENUM_INVALID", "nativeEnum(): name must be a non-empty string.", {
|
|
80
|
+
fix: "Pass a non-empty entity name as the first argument to nativeEnum().",
|
|
81
|
+
meta: {
|
|
82
|
+
enumName: name,
|
|
83
|
+
reason: "empty name"
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
if (members.length === 0) throw postgresError("CONTRACT.ENUM_INVALID", `nativeEnum("${name}"): must have at least one member.`, {
|
|
87
|
+
why: "Postgres rejects CREATE TYPE ... AS ENUM () with no labels.",
|
|
88
|
+
fix: "Declare at least one member value after the name.",
|
|
89
|
+
meta: {
|
|
90
|
+
enumName: name,
|
|
91
|
+
reason: "zero members"
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
const seenValues = /* @__PURE__ */ new Set();
|
|
95
|
+
for (const value of members) {
|
|
96
|
+
if (seenValues.has(value)) throw postgresError("CONTRACT.ENUM_INVALID", `nativeEnum("${name}"): duplicate member value "${value}". Member values must be unique.`, {
|
|
97
|
+
fix: "Remove the duplicate member value.",
|
|
98
|
+
meta: {
|
|
99
|
+
enumName: name,
|
|
100
|
+
member: value,
|
|
101
|
+
reason: "duplicate member value"
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
seenValues.add(value);
|
|
105
|
+
}
|
|
106
|
+
return buildNativeEnumHandle(name, name, members);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Builds the deferred column descriptor for `handle`: the bare Postgres type
|
|
110
|
+
* name and `typeParams` come from `pgEnumDescriptor.columnFromEntity` (the same
|
|
111
|
+
* authoring hook the PSL `pg.enum(Ref)` type constructor resolves through),
|
|
112
|
+
* carrying `handle.entity` as the descriptor's `entityRef` keyed by the entity
|
|
113
|
+
* `name` (not the Postgres type name — they differ when `.map()` was used).
|
|
114
|
+
* Schema qualification and the storage `valueSet` ref are NOT computed here — a
|
|
115
|
+
* `field.column(pg.enum(handle))` call runs before the enclosing `model(...)`
|
|
116
|
+
* associates a namespace, so `buildSqlContractFromDefinition` resolves both
|
|
117
|
+
* once the field's namespace is known.
|
|
118
|
+
*/
|
|
119
|
+
function pgEnumColumn(handle) {
|
|
120
|
+
const resolved = pgEnumDescriptor.columnFromEntity(handle.entity);
|
|
121
|
+
if (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.`);
|
|
122
|
+
return {
|
|
123
|
+
codecId: PG_ENUM_CODEC_ID,
|
|
124
|
+
nativeType: resolved.nativeType,
|
|
125
|
+
typeParams: resolved.typeParams,
|
|
126
|
+
entityRef: {
|
|
127
|
+
entityKind: handle.entityKind,
|
|
128
|
+
entityName: handle.name,
|
|
129
|
+
entity: handle.entity
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
/** Postgres-specific TS type-constructor namespace, mirroring the PSL `pg.` prefix. */
|
|
134
|
+
const pg = { enum: pgEnumColumn };
|
|
135
|
+
function assertNonEmptyName(helper, name) {
|
|
136
|
+
if (name.trim().length === 0) throw postgresError("CONTRACT.POLICY_INVALID", `${helper}: name must be a non-empty string.`, {
|
|
137
|
+
fix: "Pass a non-empty policy name.",
|
|
138
|
+
meta: {
|
|
139
|
+
policyName: name,
|
|
140
|
+
reason: "empty name"
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
/** The user-facing helper name per operation, for runtime error messages. */
|
|
145
|
+
const HELPER_NAMES = {
|
|
146
|
+
select: "policySelect",
|
|
147
|
+
insert: "policyInsert",
|
|
148
|
+
update: "policyUpdate",
|
|
149
|
+
delete: "policyDelete",
|
|
150
|
+
all: "policyAll"
|
|
151
|
+
};
|
|
152
|
+
function buildPolicyHandle(operation, model, descriptor) {
|
|
153
|
+
const helper = HELPER_NAMES[operation];
|
|
154
|
+
const support = POLICY_OPERATION_PREDICATES[operation];
|
|
155
|
+
assertNonEmptyName(`${helper}("${descriptor.name}")`, descriptor.name);
|
|
156
|
+
const supported = support.using && support.withCheck ? "`using` and `withCheck`" : support.using ? "`using` only" : "`withCheck` only";
|
|
157
|
+
const rejectPredicate = (predicate) => {
|
|
158
|
+
throw postgresError("CONTRACT.POLICY_INVALID", `${helper}: policy "${descriptor.name}" does not take a \`${predicate}\` predicate; the ${operation.toUpperCase()} operation uses ${supported}.`, {
|
|
159
|
+
fix: `Use only the predicates the ${operation.toUpperCase()} operation supports: ${supported}.`,
|
|
160
|
+
meta: {
|
|
161
|
+
policyName: descriptor.name,
|
|
162
|
+
reason: `unsupported \`${predicate}\` predicate`
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
};
|
|
166
|
+
if (descriptor.using !== void 0 && !support.using) rejectPredicate("using");
|
|
167
|
+
if (descriptor.withCheck !== void 0 && !support.withCheck) rejectPredicate("withCheck");
|
|
168
|
+
if (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}.`, {
|
|
169
|
+
fix: `Provide at least one predicate: ${supported}.`,
|
|
170
|
+
meta: {
|
|
171
|
+
policyName: descriptor.name,
|
|
172
|
+
reason: "no predicate given"
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
return Object.freeze({
|
|
176
|
+
entityKind: "policy",
|
|
177
|
+
operation,
|
|
178
|
+
name: descriptor.name,
|
|
179
|
+
refs: Object.freeze({ target: model }),
|
|
180
|
+
roles: Object.freeze([...descriptor.roles]),
|
|
181
|
+
...ifDefined("using", descriptor.using),
|
|
182
|
+
...ifDefined("withCheck", descriptor.withCheck)
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Declares a Postgres role by name, mirroring PSL's bare role identifiers.
|
|
187
|
+
* Returns an inert handle: referenced in a policy's `roles` it contributes
|
|
188
|
+
* the bare name; placed in the `entities` list it declares the role
|
|
189
|
+
* (`entries.role`), making it subject to the existence verify.
|
|
190
|
+
*/
|
|
191
|
+
function role(name) {
|
|
192
|
+
assertNonEmptyName(`role("${name}")`, name);
|
|
193
|
+
return Object.freeze({
|
|
194
|
+
entityKind: "role",
|
|
195
|
+
name
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Marks a model's table RLS-controlled, mirroring PSL's `@@rls`. The
|
|
200
|
+
* enablement marker (never the policy set) drives `ENABLE`/`DISABLE ROW
|
|
201
|
+
* LEVEL SECURITY` planning.
|
|
202
|
+
*/
|
|
203
|
+
function rlsEnabled(model) {
|
|
204
|
+
return Object.freeze({
|
|
205
|
+
entityKind: "rls",
|
|
206
|
+
refs: Object.freeze({ target: model })
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
/** Authors a `FOR SELECT` policy (PSL `policy_select`): row visibility via `using`. */
|
|
210
|
+
function policySelect(model, descriptor) {
|
|
211
|
+
return buildPolicyHandle("select", model, descriptor);
|
|
212
|
+
}
|
|
213
|
+
/** Authors a `FOR INSERT` policy (PSL `policy_insert`): new-row validation via `withCheck`. */
|
|
214
|
+
function policyInsert(model, descriptor) {
|
|
215
|
+
return buildPolicyHandle("insert", model, descriptor);
|
|
216
|
+
}
|
|
217
|
+
/** Authors a `FOR UPDATE` policy (PSL `policy_update`): takes `using` and `withCheck`. */
|
|
218
|
+
function policyUpdate(model, descriptor) {
|
|
219
|
+
return buildPolicyHandle("update", model, descriptor);
|
|
220
|
+
}
|
|
221
|
+
/** Authors a `FOR DELETE` policy (PSL `policy_delete`): row eligibility via `using`. */
|
|
222
|
+
function policyDelete(model, descriptor) {
|
|
223
|
+
return buildPolicyHandle("delete", model, descriptor);
|
|
224
|
+
}
|
|
225
|
+
/** Authors a `FOR ALL` policy (PSL `policy_all`): takes `using` and `withCheck`. */
|
|
226
|
+
function policyAll(model, descriptor) {
|
|
227
|
+
return buildPolicyHandle("all", model, descriptor);
|
|
228
|
+
}
|
|
229
|
+
//#endregion
|
|
230
|
+
export { buildSqlContractFromDefinition, defineContract, enumType, field, member, model, nativeEnum, pg, policyAll, policyDelete, policyInsert, policySelect, policyUpdate, rel, rlsEnabled, role };
|
|
231
|
+
|
|
232
|
+
//# sourceMappingURL=contract-builder.mjs.map
|
|
@@ -0,0 +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 { bindEnumType, buildBoundContract, buildSqlContractFromDefinition, field, member, model, rel } from \"@internal/sql-contract-ts/contract-builder\";\nimport sqlFamilyPack from \"@internal/family-sql/pack\";\nimport { pgEnumDescriptor } from \"@internal/target-postgres/codecs\";\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 bound = {\n\t\t...definition,\n\t\tcreateNamespace: postgresCreateNamespace\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/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`: the bare Postgres type\n* name and `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\tnativeType: resolved.nativeType,\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 { buildSqlContractFromDefinition, defineContract, enumType, field, member, model, nativeEnum, pg, policyAll, policyDelete, policyInsert, policySelect, policyUpdate, rel, rlsEnabled, role };\n\n//# sourceMappingURL=contract-builder.mjs.map"],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@prisma/orm-framework/contract";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@prisma/orm-framework/contract/apply-specifier-default-control-policy";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@prisma/orm-framework/contract/contract-validation-error";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@prisma/orm-framework/contract/default-namespace";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@prisma/orm-framework/contract/enum-accessor";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@prisma/orm-framework/contract/hashing-utils";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@prisma/orm-framework/contract/hashing";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@prisma/orm-framework/contract/is-plain-record";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@prisma/orm-framework/contract/resolve-domain-model";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@prisma/orm-framework/contract/types";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@prisma/orm-framework/contract/validate-domain";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ControlClient, ControlClientOptions } from "@prisma/orm-toolchain/cli/control-api";
|
|
2
|
+
//#region ../../../3-extensions/postgres/dist/control.d.mts
|
|
3
|
+
//#region src/exports/control.d.ts
|
|
4
|
+
interface PostgresControlClientOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Default Postgres connection string. When set, operations like `dbInit`
|
|
7
|
+
* auto-connect without an explicit `connect()` call. Equivalent to the
|
|
8
|
+
* `connection` field on the underlying `ControlClientOptions`.
|
|
9
|
+
*/
|
|
10
|
+
readonly connection?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Composed extension descriptors. Pass the same descriptors here that
|
|
13
|
+
* the contract was authored against.
|
|
14
|
+
*/
|
|
15
|
+
readonly extensions?: ControlClientOptions['extensions'];
|
|
16
|
+
}
|
|
17
|
+
declare function createPostgresControlClient(options?: PostgresControlClientOptions): ControlClient;
|
|
18
|
+
//#endregion
|
|
19
|
+
export { type ControlClient, PostgresControlClientOptions, createPostgresControlClient };
|
|
20
|
+
//# sourceMappingURL=control.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"control.d.mts","names":[],"sources":["../../../../3-extensions/postgres/dist/control.d.mts"],"mappings":";;;UAEU;;;;;;WAMC;;;;;WAKA,aAAa;;iBAEP,4BAA4B,UAAU,+BAA+B"}
|
package/dist/control.mjs
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import postgresAdapter from "@prisma/orm-target-postgres/adapter/control";
|
|
2
|
+
import postgresDriver from "@prisma/orm-target-postgres/driver/control";
|
|
3
|
+
import sql from "@prisma/orm-family-sql/family/control";
|
|
4
|
+
import postgres from "@prisma/orm-target-postgres/target/control";
|
|
5
|
+
import { ifDefined } from "@prisma/orm-framework/utils/defined";
|
|
6
|
+
import { createControlClient } from "@prisma/orm-toolchain/cli/control-api";
|
|
7
|
+
//#region ../../../3-extensions/postgres/dist/control.mjs
|
|
8
|
+
/**
|
|
9
|
+
* Control-API facade for Postgres.
|
|
10
|
+
*
|
|
11
|
+
* Collapses the five-package wiring required to drive control-side
|
|
12
|
+
* operations (`dbInit`, `dbUpdate`, `dbVerify`, `migrate`, …) into
|
|
13
|
+
* a single `createPostgresControlClient()` call. Mirrors what
|
|
14
|
+
* `@internal/postgres/runtime` did for the query side.
|
|
15
|
+
*/
|
|
16
|
+
function createPostgresControlClient(options = {}) {
|
|
17
|
+
return createControlClient({
|
|
18
|
+
family: sql,
|
|
19
|
+
target: postgres,
|
|
20
|
+
adapter: postgresAdapter,
|
|
21
|
+
driver: postgresDriver,
|
|
22
|
+
...ifDefined("connection", options.connection),
|
|
23
|
+
...ifDefined("extensions", options.extensions)
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
export { createPostgresControlClient };
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=control.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"control.mjs","names":[],"sources":["../../../../3-extensions/postgres/dist/control.mjs"],"sourcesContent":["import postgresAdapter from \"@internal/adapter-postgres/control\";\nimport postgresDriver from \"@internal/driver-postgres/control\";\nimport sql from \"@internal/family-sql/control\";\nimport postgres from \"@internal/target-postgres/control\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { createControlClient } from \"@internal/cli/control-api\";\n//#region src/exports/control.ts\n/**\n* Control-API facade for Postgres.\n*\n* Collapses the five-package wiring required to drive control-side\n* operations (`dbInit`, `dbUpdate`, `dbVerify`, `migrate`, …) into\n* a single `createPostgresControlClient()` call. Mirrors what\n* `@internal/postgres/runtime` did for the query side.\n*/\nfunction createPostgresControlClient(options = {}) {\n\treturn createControlClient({\n\t\tfamily: sql,\n\t\ttarget: postgres,\n\t\tadapter: postgresAdapter,\n\t\tdriver: postgresDriver,\n\t\t...ifDefined(\"connection\", options.connection),\n\t\t...ifDefined(\"extensions\", options.extensions)\n\t});\n}\n//#endregion\nexport { createPostgresControlClient };\n\n//# sourceMappingURL=control.mjs.map"],"mappings":";;;;;;;;;;;;;;;AAeA,SAAS,4BAA4B,UAAU,CAAC,GAAG;CAClD,OAAO,oBAAoB;EAC1B,QAAQ;EACR,QAAQ;EACR,SAAS;EACT,QAAQ;EACR,GAAG,UAAU,cAAc,QAAQ,UAAU;EAC7C,GAAG,UAAU,cAAc,QAAQ,UAAU;CAC9C,CAAC;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@prisma/orm-target-postgres/driver";
|
package/dist/driver.mjs
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { structuredError } from "@prisma/orm-framework/utils/structured-error";
|
|
2
|
+
//#region ../../../3-extensions/postgres/dist/errors-DfWK9xep.mjs
|
|
3
|
+
function postgresError(code, message, options) {
|
|
4
|
+
return structuredError(code, message, options);
|
|
5
|
+
}
|
|
6
|
+
//#endregion
|
|
7
|
+
export { postgresError as t };
|
|
8
|
+
|
|
9
|
+
//# sourceMappingURL=errors-DfWK9xep-CYOOg0sB.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors-DfWK9xep-CYOOg0sB.mjs","names":[],"sources":["../../../../3-extensions/postgres/dist/errors-DfWK9xep.mjs"],"sourcesContent":["import { structuredError } from \"@internal/utils/structured-error\";\n//#region src/errors.ts\nfunction postgresError(code, message, options) {\n\treturn structuredError(code, message, options);\n}\n//#endregion\nexport { postgresError as t };\n\n//# sourceMappingURL=errors-DfWK9xep.mjs.map"],"mappings":";;AAEA,SAAS,cAAc,MAAM,SAAS,SAAS;CAC9C,OAAO,gBAAgB,MAAM,SAAS,OAAO;AAC9C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@prisma/orm-family-sql/contract";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@prisma/orm-family-sql/contract/canonicalization-hooks";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@prisma/orm-family-sql/contract/contract-view";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@prisma/orm-family-sql/contract/entity-handle-lowering-hook";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@prisma/orm-family-sql/contract/entity-kinds";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@prisma/orm-family-sql/contract/factories";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@prisma/orm-family-sql/contract/foreign-key-materialization";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@prisma/orm-family-sql/contract/index-naming";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@prisma/orm-family-sql/contract/index-type-validation";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@prisma/orm-family-sql/contract/index-types";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@prisma/orm-family-sql/contract/pack-types";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@prisma/orm-family-sql/contract/referential-action-sql";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@prisma/orm-family-sql/contract/resolve-storage-table";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@prisma/orm-family-sql/contract/types";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@prisma/orm-family-sql/contract/validators";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@prisma/orm-family-sql/contract/value-set-derivation-hook";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@prisma/orm-family-sql/runtime";
|
package/dist/family.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@prisma/orm-family-sql/family/control-adapter";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@prisma/orm-family-sql/family/diff";
|