@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,521 @@
|
|
|
1
|
+
import { PG_ENUM_CODEC_ID } from "@prisma/orm-target-postgres/target/codec-ids";
|
|
2
|
+
import postgresPackRef from "@prisma/orm-target-postgres/target/pack";
|
|
3
|
+
import { PostgresNativeEnum, RlsPolicyOperation } from "@prisma/orm-target-postgres/target/types";
|
|
4
|
+
import { ComposedAuthoringHelpers, ComposedAuthoringHelpers as ComposedAuthoringHelpers$1, ContractDefinition, ContractInput, ContractInput as ContractInput$1, ContractModelBuilder, EnumMember, EnumTypeHandle, EnumTypeHandle as EnumTypeHandle$1, FieldNode, ForeignKeyNode, IndexNode, MergeEnums, ModelLike, ModelNode, PrimaryKeyNode, RelationNode, ScalarFieldBuilder, ScalarFieldBuilder as ScalarFieldBuilder$1, UniqueConstraintNode, buildBoundContract, buildSqlContractFromDefinition, field, member, model, rel } from "@prisma/orm-family-sql/contract-ts/contract-builder";
|
|
5
|
+
import sqlFamilyPack from "@prisma/orm-family-sql/family/pack";
|
|
6
|
+
import "@prisma/orm-framework/components/authoring";
|
|
7
|
+
import { ColumnTypeDescriptor } from "@prisma/orm-framework/components/codec";
|
|
8
|
+
import { ExtensionPackRef } from "@prisma/orm-framework/components/components";
|
|
9
|
+
import { SqlNamespaceBase, SqlNamespaceInput, StorageTypeInstance } from "@prisma/orm-family-sql/contract/types";
|
|
10
|
+
//#region ../../../3-extensions/postgres/dist/contract-builder.d.mts
|
|
11
|
+
//#region src/contract/rls.d.ts
|
|
12
|
+
/**
|
|
13
|
+
* Structural shape of the model handles the RLS helpers accept: any named
|
|
14
|
+
* `model(...)` builder from the contract DSL, including cross-space
|
|
15
|
+
* `extensionModel` handles. Helpers capture the handle by reference; nothing
|
|
16
|
+
* is read from it until `defineContract` lowers the entities list.
|
|
17
|
+
*/
|
|
18
|
+
interface RlsTargetModel {
|
|
19
|
+
readonly stageOne: {
|
|
20
|
+
readonly modelName?: string;
|
|
21
|
+
readonly namespace?: string;
|
|
22
|
+
readonly fields: Record<string, ScalarFieldBuilder$1>;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Role handle produced by {@link role}. Usable as a reference in a policy's
|
|
27
|
+
* `roles` list and as a declaration in the `entities` list (which lowers it
|
|
28
|
+
* to a `PostgresRole` entity).
|
|
29
|
+
*/
|
|
30
|
+
interface RlsRoleHandle<Name extends string = string> {
|
|
31
|
+
readonly entityKind: 'role';
|
|
32
|
+
readonly name: Name;
|
|
33
|
+
}
|
|
34
|
+
/** Enablement handle produced by {@link rlsEnabled}. */
|
|
35
|
+
interface RlsEnablementHandle {
|
|
36
|
+
readonly entityKind: 'rls';
|
|
37
|
+
/** Declared model refs, resolved to table coordinates by the generic contract build. */
|
|
38
|
+
readonly refs: {
|
|
39
|
+
readonly target: RlsTargetModel;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Policy handle produced by the five `policy*` helpers. An inert value
|
|
44
|
+
* capturing the authoring inputs; wire-name hashing and table-name resolution
|
|
45
|
+
* happen when the handle is lowered by `defineContract`.
|
|
46
|
+
*/
|
|
47
|
+
interface RlsPolicyHandle<Operation extends RlsPolicyOperation = RlsPolicyOperation> {
|
|
48
|
+
readonly entityKind: 'policy';
|
|
49
|
+
readonly operation: Operation;
|
|
50
|
+
/** The policy name prefix (PSL's block name); the wire name appends a content hash. */
|
|
51
|
+
readonly name: string;
|
|
52
|
+
/** Declared model refs, resolved to table coordinates by the generic contract build. */
|
|
53
|
+
readonly refs: {
|
|
54
|
+
readonly target: RlsTargetModel;
|
|
55
|
+
};
|
|
56
|
+
readonly roles: readonly RlsRoleHandle[];
|
|
57
|
+
readonly using?: string;
|
|
58
|
+
readonly withCheck?: string;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* The handle vocabulary `defineContract({ entities })` accepts: policies,
|
|
62
|
+
* role declarations, and RLS enablement markers.
|
|
63
|
+
*/
|
|
64
|
+
type RlsEntityHandle = RlsPolicyHandle | RlsRoleHandle | RlsEnablementHandle;
|
|
65
|
+
interface RlsPolicyDescriptorBase {
|
|
66
|
+
/** The policy name prefix (PSL's block name); the wire name appends a content hash. */
|
|
67
|
+
readonly name: string;
|
|
68
|
+
readonly roles: readonly RlsRoleHandle[];
|
|
69
|
+
}
|
|
70
|
+
/** Descriptor for the USING-only operations: SELECT and DELETE. */
|
|
71
|
+
interface RlsUsingPolicyDescriptor extends RlsPolicyDescriptorBase {
|
|
72
|
+
readonly using: string;
|
|
73
|
+
}
|
|
74
|
+
/** Descriptor for the WITH CHECK-only operation: INSERT. */
|
|
75
|
+
interface RlsWithCheckPolicyDescriptor extends RlsPolicyDescriptorBase {
|
|
76
|
+
readonly withCheck: string;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Descriptor for the operations taking both predicates: UPDATE and ALL. At
|
|
80
|
+
* least one of `using`/`withCheck` is required; zero predicates is a compile
|
|
81
|
+
* error. Both stay individually optional because PSL's lowering accepts
|
|
82
|
+
* either alone, and the handle carries only what was authored — an omitted
|
|
83
|
+
* predicate is omitted from the content hash, byte-identical to PSL.
|
|
84
|
+
*/
|
|
85
|
+
type RlsUsingWithCheckPolicyDescriptor = (RlsPolicyDescriptorBase & {
|
|
86
|
+
readonly using: string;
|
|
87
|
+
readonly withCheck?: string;
|
|
88
|
+
}) | (RlsPolicyDescriptorBase & {
|
|
89
|
+
readonly using?: string;
|
|
90
|
+
readonly withCheck: string;
|
|
91
|
+
});
|
|
92
|
+
/**
|
|
93
|
+
* Declares a Postgres role by name, mirroring PSL's bare role identifiers.
|
|
94
|
+
* Returns an inert handle: referenced in a policy's `roles` it contributes
|
|
95
|
+
* the bare name; placed in the `entities` list it declares the role
|
|
96
|
+
* (`entries.role`), making it subject to the existence verify.
|
|
97
|
+
*/
|
|
98
|
+
declare function role<const Name extends string>(name: Name): RlsRoleHandle<Name>;
|
|
99
|
+
/**
|
|
100
|
+
* Marks a model's table RLS-controlled, mirroring PSL's `@@rls`. The
|
|
101
|
+
* enablement marker (never the policy set) drives `ENABLE`/`DISABLE ROW
|
|
102
|
+
* LEVEL SECURITY` planning.
|
|
103
|
+
*/
|
|
104
|
+
declare function rlsEnabled(model: RlsTargetModel): RlsEnablementHandle;
|
|
105
|
+
/** Authors a `FOR SELECT` policy (PSL `policy_select`): row visibility via `using`. */
|
|
106
|
+
declare function policySelect(model: RlsTargetModel, descriptor: RlsUsingPolicyDescriptor): RlsPolicyHandle<'select'>;
|
|
107
|
+
/** Authors a `FOR INSERT` policy (PSL `policy_insert`): new-row validation via `withCheck`. */
|
|
108
|
+
declare function policyInsert(model: RlsTargetModel, descriptor: RlsWithCheckPolicyDescriptor): RlsPolicyHandle<'insert'>;
|
|
109
|
+
/** Authors a `FOR UPDATE` policy (PSL `policy_update`): takes `using` and `withCheck`. */
|
|
110
|
+
declare function policyUpdate(model: RlsTargetModel, descriptor: RlsUsingWithCheckPolicyDescriptor): RlsPolicyHandle<'update'>;
|
|
111
|
+
/** Authors a `FOR DELETE` policy (PSL `policy_delete`): row eligibility via `using`. */
|
|
112
|
+
declare function policyDelete(model: RlsTargetModel, descriptor: RlsUsingPolicyDescriptor): RlsPolicyHandle<'delete'>;
|
|
113
|
+
/** Authors a `FOR ALL` policy (PSL `policy_all`): takes `using` and `withCheck`. */
|
|
114
|
+
declare function policyAll(model: RlsTargetModel, descriptor: RlsUsingWithCheckPolicyDescriptor): RlsPolicyHandle<'all'>;
|
|
115
|
+
//#endregion
|
|
116
|
+
//#region src/contract/define-contract.d.ts
|
|
117
|
+
type SqlFamily = typeof sqlFamilyPack;
|
|
118
|
+
type PostgresPack = typeof postgresPackRef;
|
|
119
|
+
type TypesConstraint = Record<string, StorageTypeInstance>;
|
|
120
|
+
type ModelsConstraint = Record<string, ModelLike>;
|
|
121
|
+
type EnumsConstraint = Record<string, EnumTypeHandle$1>;
|
|
122
|
+
type PostgresResult<Types extends TypesConstraint, Models extends ModelsConstraint, Extensions extends Record<string, ExtensionPackRef<'sql', string>> | undefined, Enums extends EnumsConstraint> = ReturnType<typeof buildBoundContract<SqlFamily, PostgresPack, {
|
|
123
|
+
readonly types?: Types;
|
|
124
|
+
readonly models?: Models;
|
|
125
|
+
readonly extensions?: Extensions;
|
|
126
|
+
readonly enums?: Enums;
|
|
127
|
+
readonly createNamespace: (input: SqlNamespaceInput) => SqlNamespaceBase;
|
|
128
|
+
}>>;
|
|
129
|
+
type PostgresBaseScaffold<Extensions extends Record<string, ExtensionPackRef<'sql', string>> | undefined> = Omit<ContractInput$1<SqlFamily, PostgresPack, Record<never, never>, Record<never, never>, Extensions>, 'family' | 'target' | 'types' | 'models' | 'enums' | 'createNamespace' | 'entities'> & {
|
|
130
|
+
/**
|
|
131
|
+
* RLS handles (`policy*`, `rlsEnabled`, `role`), lowered by the generic
|
|
132
|
+
* contract build through the postgres pack's entity-handle hook —
|
|
133
|
+
* mirroring the PSL `policy_*` / `@@rls` lowering key-for-key and
|
|
134
|
+
* wire-name-for-wire-name. This wrapper only narrows the element type;
|
|
135
|
+
* it contains no entity-kind logic.
|
|
136
|
+
*/
|
|
137
|
+
readonly entities?: readonly RlsEntityHandle[];
|
|
138
|
+
};
|
|
139
|
+
type PostgresDefinition<Types extends TypesConstraint, Models extends ModelsConstraint, Extensions extends Record<string, ExtensionPackRef<'sql', string>> | undefined, Enums extends EnumsConstraint> = PostgresBaseScaffold<Extensions> & {
|
|
140
|
+
readonly types?: Types;
|
|
141
|
+
readonly models?: Models;
|
|
142
|
+
readonly enums?: Enums;
|
|
143
|
+
};
|
|
144
|
+
type PostgresScaffold<Extensions extends Record<string, ExtensionPackRef<'sql', string>> | undefined, Enums extends EnumsConstraint> = PostgresBaseScaffold<Extensions> & {
|
|
145
|
+
readonly types?: never;
|
|
146
|
+
readonly models?: never;
|
|
147
|
+
readonly enums?: Enums;
|
|
148
|
+
};
|
|
149
|
+
declare function defineContract<const Types extends TypesConstraint = Record<never, never>, const Models extends ModelsConstraint = Record<never, never>, const Extensions extends Record<string, ExtensionPackRef<'sql', string>> | undefined = undefined, const Enums extends EnumsConstraint = Record<never, never>>(definition: PostgresDefinition<Types, Models, Extensions, Enums>): PostgresResult<Types, Models, Extensions, Enums>;
|
|
150
|
+
declare function defineContract<const Types extends TypesConstraint = Record<never, never>, const Models extends ModelsConstraint = Record<never, never>, const Extensions extends Record<string, ExtensionPackRef<'sql', string>> | undefined = undefined, const ScaffoldEnums extends EnumsConstraint = Record<never, never>, const FactoryEnums extends EnumsConstraint = Record<never, never>>(scaffold: PostgresScaffold<Extensions, ScaffoldEnums>, factory: (helpers: ComposedAuthoringHelpers$1<SqlFamily, PostgresPack, Extensions>) => {
|
|
151
|
+
readonly types?: Types;
|
|
152
|
+
readonly models?: Models;
|
|
153
|
+
readonly enums?: FactoryEnums;
|
|
154
|
+
}): PostgresResult<Types, Models, Extensions, MergeEnums<ScaffoldEnums, FactoryEnums>>;
|
|
155
|
+
//#endregion
|
|
156
|
+
//#region ../../1-framework/2-authoring/contract/dist/index.d.mts
|
|
157
|
+
//#endregion
|
|
158
|
+
//#region src/enum-type.d.ts
|
|
159
|
+
/**
|
|
160
|
+
* A single enum member produced by `member()`. The `Name` and `Value` generics
|
|
161
|
+
* are preserved as literal types so `enumType()` can carry the ordered value
|
|
162
|
+
* tuple in its return type. `Value` is whatever the codec dictates — its type
|
|
163
|
+
* is constrained at `enumType` against the codec's input type, not here.
|
|
164
|
+
*/
|
|
165
|
+
interface EnumMember$1<Name extends string, Value> {
|
|
166
|
+
readonly name: Name;
|
|
167
|
+
readonly value: Value;
|
|
168
|
+
}
|
|
169
|
+
type MembersToValues<Members extends readonly EnumMember$1<string, unknown>[]> = { readonly [K in keyof Members]: Members[K] extends EnumMember$1<string, infer V> ? V : never; };
|
|
170
|
+
type MembersToNames<Members extends readonly EnumMember$1<string, unknown>[]> = { readonly [K in keyof Members]: Members[K] extends EnumMember$1<infer N, unknown> ? N : never; };
|
|
171
|
+
type MembersAccessorMap<Members extends readonly EnumMember$1<string, unknown>[]> = { readonly [M in Members[number] as M['name']]: M['value']; };
|
|
172
|
+
declare const ENUM_TYPE_HANDLE_BRAND = "__prismaNextEnumTypeHandle__";
|
|
173
|
+
/** Authoring handle returned by `enumType()`. Generic over the ordered value tuple so `const Role = enumType(...)` retains literal types. */
|
|
174
|
+
interface EnumTypeHandle$2<Name extends string = string, Values extends readonly unknown[] = readonly unknown[], Names extends readonly string[] = readonly string[], MembersMap extends Record<string, unknown> = Record<string, unknown>> {
|
|
175
|
+
/** Internal brand for lowering-pipeline detection. */
|
|
176
|
+
readonly [ENUM_TYPE_HANDLE_BRAND]: true;
|
|
177
|
+
/** The enum's declared name (used as the key in domain `enum` / storage `valueSet`). */
|
|
178
|
+
readonly enumName: Name;
|
|
179
|
+
/** codecId from the codec passed to `enumType`. */
|
|
180
|
+
readonly codecId: string;
|
|
181
|
+
/** nativeType from the codec passed to `enumType`. */
|
|
182
|
+
readonly nativeType: string;
|
|
183
|
+
/** Ordered member list for lowering (name + value pairs). */
|
|
184
|
+
readonly enumMembers: readonly {
|
|
185
|
+
readonly name: string;
|
|
186
|
+
readonly value: Values[number];
|
|
187
|
+
}[];
|
|
188
|
+
/** Ordered literal value tuple. Declaration order is preserved. */
|
|
189
|
+
readonly values: Values;
|
|
190
|
+
/** Ordered literal name tuple. Declaration order is preserved. */
|
|
191
|
+
readonly names: Names;
|
|
192
|
+
/**
|
|
193
|
+
* Namespaced accessor map: `Role.members.User === 'user'`.
|
|
194
|
+
* Namespaced under `.members` to avoid collisions with `.values` / `.has`.
|
|
195
|
+
*/
|
|
196
|
+
readonly members: MembersMap;
|
|
197
|
+
/** Returns `true` if `v` is a declared member value. */
|
|
198
|
+
has(v: Values[number]): boolean;
|
|
199
|
+
/** Returns the member name for a value, or `undefined` if not found. */
|
|
200
|
+
nameOf(v: Values[number]): string | undefined;
|
|
201
|
+
/** Returns the zero-based declaration index of a value, or `-1` if not found. */
|
|
202
|
+
ordinalOf(v: Values[number]): number;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* A codec typemap: codecId → `{ input, output }`, the same shape the query
|
|
206
|
+
* lanes consume. The bound `enumType` wrappers supply the target pack's
|
|
207
|
+
* typemap; the core defaults to an empty map (no codec is known), so member
|
|
208
|
+
* values stay unconstrained.
|
|
209
|
+
*/
|
|
210
|
+
type CodecTypeMap = Record<string, {
|
|
211
|
+
readonly input?: unknown;
|
|
212
|
+
}>;
|
|
213
|
+
/**
|
|
214
|
+
* The application input type the codec dictates for an enum's member values:
|
|
215
|
+
* looks `Codec['codecId']` up in the supplied codec typemap. When the codecId
|
|
216
|
+
* isn't in the map the input is unconstrained, so any member-value literal is
|
|
217
|
+
* accepted and inferred verbatim.
|
|
218
|
+
*/
|
|
219
|
+
type CodecInput<CodecTypes extends CodecTypeMap, Codec extends {
|
|
220
|
+
readonly codecId: string;
|
|
221
|
+
}> = Codec['codecId'] extends keyof CodecTypes ? CodecTypes[Codec['codecId']] extends {
|
|
222
|
+
readonly input: infer In;
|
|
223
|
+
} ? In : unknown : unknown;
|
|
224
|
+
/**
|
|
225
|
+
* The signature of an `enumType` whose codec typemap is already bound — the
|
|
226
|
+
* shape a target-bound wrapper (e.g. `@internal/postgres/contract-builder`)
|
|
227
|
+
* exposes. The member values are constrained to the codec's input type drawn
|
|
228
|
+
* from `CodecTypes`, while `Name`, `Codec`, and the member tuple still infer
|
|
229
|
+
* from the call.
|
|
230
|
+
*/
|
|
231
|
+
type BoundEnumType<CodecTypes extends CodecTypeMap> = <const Name extends string, const Codec extends Pick<ColumnTypeDescriptor, 'codecId' | 'nativeType'>, const Members extends readonly [EnumMember$1<string, CodecInput<CodecTypes, Codec>>, ...EnumMember$1<string, CodecInput<CodecTypes, Codec>>[]]>(name: Name, codec: Codec, ...members: Members) => EnumTypeHandle$2<Name, MembersToValues<[...Members]>, MembersToNames<[...Members]>, MembersAccessorMap<[...Members]>>;
|
|
232
|
+
//#endregion
|
|
233
|
+
//#region src/contract/enum-type.d.ts
|
|
234
|
+
/**
|
|
235
|
+
* The `enumType` authors call when building a Postgres contract (re-exported
|
|
236
|
+
* from `@internal/postgres/contract-builder`).
|
|
237
|
+
*
|
|
238
|
+
* `bindEnumType` is the core, codec-agnostic `enumType` factory; calling it with
|
|
239
|
+
* the Postgres pack's codec typemap fixes which member-value type each codec
|
|
240
|
+
* permits, so `member()` values are checked against the column's codec at
|
|
241
|
+
* authoring time: `pg/text@1` requires `string`, `pg/int4@1` requires `number`,
|
|
242
|
+
* and a mismatch is a compile error. The core `enumType` can't know the codec
|
|
243
|
+
* set, which is why the binding happens here, per target.
|
|
244
|
+
*/
|
|
245
|
+
declare const enumType: BoundEnumType<{
|
|
246
|
+
readonly "sql/char@1": Pick<{
|
|
247
|
+
readonly input: string;
|
|
248
|
+
readonly output: string;
|
|
249
|
+
readonly json: import("@prisma/orm-framework/contract/types").JsonValue;
|
|
250
|
+
readonly traits: "equality" | "order" | "textual";
|
|
251
|
+
}, "traits" | "output" | "input">;
|
|
252
|
+
readonly "sql/varchar@1": Pick<{
|
|
253
|
+
readonly input: string;
|
|
254
|
+
readonly output: string;
|
|
255
|
+
readonly json: import("@prisma/orm-framework/contract/types").JsonValue;
|
|
256
|
+
readonly traits: "equality" | "order" | "textual";
|
|
257
|
+
}, "traits" | "output" | "input">;
|
|
258
|
+
readonly "sql/int@1": Pick<{
|
|
259
|
+
readonly input: number;
|
|
260
|
+
readonly output: number;
|
|
261
|
+
readonly json: import("@prisma/orm-framework/contract/types").JsonValue;
|
|
262
|
+
readonly traits: "numeric" | "equality" | "order";
|
|
263
|
+
}, "traits" | "output" | "input">;
|
|
264
|
+
readonly "sql/float@1": Pick<{
|
|
265
|
+
readonly input: number;
|
|
266
|
+
readonly output: number;
|
|
267
|
+
readonly json: import("@prisma/orm-framework/contract/types").JsonValue;
|
|
268
|
+
readonly traits: "numeric" | "equality" | "order";
|
|
269
|
+
}, "traits" | "output" | "input">;
|
|
270
|
+
readonly "sql/text@1": Pick<{
|
|
271
|
+
readonly input: string;
|
|
272
|
+
readonly output: string;
|
|
273
|
+
readonly json: import("@prisma/orm-framework/contract/types").JsonValue;
|
|
274
|
+
readonly traits: "equality" | "order" | "textual";
|
|
275
|
+
}, "traits" | "output" | "input">;
|
|
276
|
+
readonly "sql/timestamp@1": Pick<{
|
|
277
|
+
readonly input: Date;
|
|
278
|
+
readonly output: Date;
|
|
279
|
+
readonly json: import("@prisma/orm-framework/contract/types").JsonValue;
|
|
280
|
+
readonly traits: "equality" | "order";
|
|
281
|
+
}, "traits" | "output" | "input">;
|
|
282
|
+
readonly "pg/text@1": Pick<{
|
|
283
|
+
readonly input: string;
|
|
284
|
+
readonly output: string;
|
|
285
|
+
readonly json: import("@prisma/orm-framework/contract/types").JsonValue;
|
|
286
|
+
readonly traits: "equality" | "order" | "textual";
|
|
287
|
+
}, "traits" | "output" | "input">;
|
|
288
|
+
readonly "pg/enum@1": Pick<{
|
|
289
|
+
readonly input: string;
|
|
290
|
+
readonly output: string;
|
|
291
|
+
readonly json: import("@prisma/orm-framework/contract/types").JsonValue;
|
|
292
|
+
readonly traits: "equality" | "order" | "textual";
|
|
293
|
+
}, "traits" | "output" | "input">;
|
|
294
|
+
readonly "pg/char@1": Pick<{
|
|
295
|
+
readonly input: string;
|
|
296
|
+
readonly output: string;
|
|
297
|
+
readonly json: import("@prisma/orm-framework/contract/types").JsonValue;
|
|
298
|
+
readonly traits: "equality" | "order" | "textual";
|
|
299
|
+
}, "traits" | "output" | "input">;
|
|
300
|
+
readonly "pg/varchar@1": Pick<{
|
|
301
|
+
readonly input: string;
|
|
302
|
+
readonly output: string;
|
|
303
|
+
readonly json: import("@prisma/orm-framework/contract/types").JsonValue;
|
|
304
|
+
readonly traits: "equality" | "order" | "textual";
|
|
305
|
+
}, "traits" | "output" | "input">;
|
|
306
|
+
readonly "pg/int@1": Pick<{
|
|
307
|
+
readonly input: number;
|
|
308
|
+
readonly output: number;
|
|
309
|
+
readonly json: import("@prisma/orm-framework/contract/types").JsonValue;
|
|
310
|
+
readonly traits: "numeric" | "equality" | "order";
|
|
311
|
+
}, "traits" | "output" | "input">;
|
|
312
|
+
readonly "pg/float@1": Pick<{
|
|
313
|
+
readonly input: number;
|
|
314
|
+
readonly output: number;
|
|
315
|
+
readonly json: import("@prisma/orm-framework/contract/types").JsonValue;
|
|
316
|
+
readonly traits: "numeric" | "equality" | "order";
|
|
317
|
+
}, "traits" | "output" | "input">;
|
|
318
|
+
readonly "pg/int4@1": Pick<{
|
|
319
|
+
readonly input: number;
|
|
320
|
+
readonly output: number;
|
|
321
|
+
readonly json: import("@prisma/orm-framework/contract/types").JsonValue;
|
|
322
|
+
readonly traits: "numeric" | "equality" | "order";
|
|
323
|
+
}, "traits" | "output" | "input">;
|
|
324
|
+
readonly "pg/int2@1": Pick<{
|
|
325
|
+
readonly input: number;
|
|
326
|
+
readonly output: number;
|
|
327
|
+
readonly json: import("@prisma/orm-framework/contract/types").JsonValue;
|
|
328
|
+
readonly traits: "numeric" | "equality" | "order";
|
|
329
|
+
}, "traits" | "output" | "input">;
|
|
330
|
+
readonly "pg/int8@1": Pick<{
|
|
331
|
+
readonly input: bigint;
|
|
332
|
+
readonly output: bigint;
|
|
333
|
+
readonly json: import("@prisma/orm-framework/contract/types").JsonValue;
|
|
334
|
+
readonly traits: "numeric" | "equality" | "order";
|
|
335
|
+
}, "traits" | "output" | "input">;
|
|
336
|
+
readonly "pg/float4@1": Pick<{
|
|
337
|
+
readonly input: number;
|
|
338
|
+
readonly output: number;
|
|
339
|
+
readonly json: import("@prisma/orm-framework/contract/types").JsonValue;
|
|
340
|
+
readonly traits: "numeric" | "equality" | "order";
|
|
341
|
+
}, "traits" | "output" | "input">;
|
|
342
|
+
readonly "pg/float8@1": Pick<{
|
|
343
|
+
readonly input: number;
|
|
344
|
+
readonly output: number;
|
|
345
|
+
readonly json: import("@prisma/orm-framework/contract/types").JsonValue;
|
|
346
|
+
readonly traits: "numeric" | "equality" | "order";
|
|
347
|
+
}, "traits" | "output" | "input">;
|
|
348
|
+
readonly "pg/numeric@1": Pick<{
|
|
349
|
+
readonly input: string;
|
|
350
|
+
readonly output: string;
|
|
351
|
+
readonly json: import("@prisma/orm-framework/contract/types").JsonValue;
|
|
352
|
+
readonly traits: "numeric" | "equality" | "order";
|
|
353
|
+
}, "traits" | "output" | "input">;
|
|
354
|
+
readonly "pg/date@1": Pick<{
|
|
355
|
+
readonly input: Date;
|
|
356
|
+
readonly output: Date;
|
|
357
|
+
readonly json: import("@prisma/orm-framework/contract/types").JsonValue;
|
|
358
|
+
readonly traits: "equality" | "order";
|
|
359
|
+
}, "traits" | "output" | "input">;
|
|
360
|
+
readonly "pg/timestamp@1": Pick<{
|
|
361
|
+
readonly input: Date;
|
|
362
|
+
readonly output: Date;
|
|
363
|
+
readonly json: import("@prisma/orm-framework/contract/types").JsonValue;
|
|
364
|
+
readonly traits: "equality" | "order";
|
|
365
|
+
}, "traits" | "output" | "input">;
|
|
366
|
+
readonly "pg/timestamptz@1": Pick<{
|
|
367
|
+
readonly input: Date;
|
|
368
|
+
readonly output: Date;
|
|
369
|
+
readonly json: import("@prisma/orm-framework/contract/types").JsonValue;
|
|
370
|
+
readonly traits: "equality" | "order";
|
|
371
|
+
}, "traits" | "output" | "input">;
|
|
372
|
+
readonly "pg/time@1": Pick<{
|
|
373
|
+
readonly input: string;
|
|
374
|
+
readonly output: string;
|
|
375
|
+
readonly json: import("@prisma/orm-framework/contract/types").JsonValue;
|
|
376
|
+
readonly traits: "equality" | "order";
|
|
377
|
+
}, "traits" | "output" | "input">;
|
|
378
|
+
readonly "pg/timetz@1": Pick<{
|
|
379
|
+
readonly input: string;
|
|
380
|
+
readonly output: string;
|
|
381
|
+
readonly json: import("@prisma/orm-framework/contract/types").JsonValue;
|
|
382
|
+
readonly traits: "equality" | "order";
|
|
383
|
+
}, "traits" | "output" | "input">;
|
|
384
|
+
readonly "pg/bool@1": Pick<{
|
|
385
|
+
readonly input: boolean;
|
|
386
|
+
readonly output: boolean;
|
|
387
|
+
readonly json: import("@prisma/orm-framework/contract/types").JsonValue;
|
|
388
|
+
readonly traits: "boolean" | "equality";
|
|
389
|
+
}, "traits" | "output" | "input">;
|
|
390
|
+
readonly "pg/bit@1": Pick<{
|
|
391
|
+
readonly input: string;
|
|
392
|
+
readonly output: string;
|
|
393
|
+
readonly json: import("@prisma/orm-framework/contract/types").JsonValue;
|
|
394
|
+
readonly traits: "equality" | "order";
|
|
395
|
+
}, "traits" | "output" | "input">;
|
|
396
|
+
readonly "pg/varbit@1": Pick<{
|
|
397
|
+
readonly input: string;
|
|
398
|
+
readonly output: string;
|
|
399
|
+
readonly json: import("@prisma/orm-framework/contract/types").JsonValue;
|
|
400
|
+
readonly traits: "equality" | "order";
|
|
401
|
+
}, "traits" | "output" | "input">;
|
|
402
|
+
readonly "pg/bytea@1": Pick<{
|
|
403
|
+
readonly input: Uint8Array<ArrayBufferLike>;
|
|
404
|
+
readonly output: Uint8Array<ArrayBufferLike>;
|
|
405
|
+
readonly json: import("@prisma/orm-framework/contract/types").JsonValue;
|
|
406
|
+
readonly traits: "equality";
|
|
407
|
+
}, "traits" | "output" | "input">;
|
|
408
|
+
readonly "pg/uuid@1": Pick<{
|
|
409
|
+
readonly input: string;
|
|
410
|
+
readonly output: string;
|
|
411
|
+
readonly json: import("@prisma/orm-framework/contract/types").JsonValue;
|
|
412
|
+
readonly traits: "equality" | "order";
|
|
413
|
+
}, "traits" | "output" | "input">;
|
|
414
|
+
readonly "pg/inet@1": Pick<{
|
|
415
|
+
readonly input: string;
|
|
416
|
+
readonly output: string;
|
|
417
|
+
readonly json: import("@prisma/orm-framework/contract/types").JsonValue;
|
|
418
|
+
readonly traits: "equality" | "order";
|
|
419
|
+
}, "traits" | "output" | "input">;
|
|
420
|
+
readonly "pg/interval@1": Pick<{
|
|
421
|
+
readonly input: import("@prisma/orm-target-postgres/target/codecs").PgInterval;
|
|
422
|
+
readonly output: import("@prisma/orm-target-postgres/target/codecs").PgInterval;
|
|
423
|
+
readonly json: import("@prisma/orm-framework/contract/types").JsonValue;
|
|
424
|
+
readonly traits: "equality" | "order";
|
|
425
|
+
}, "traits" | "output" | "input">;
|
|
426
|
+
readonly "pg/json@1": Pick<{
|
|
427
|
+
readonly input: import("@prisma/orm-framework/contract/types").JsonValue;
|
|
428
|
+
readonly output: import("@prisma/orm-framework/contract/types").JsonValue;
|
|
429
|
+
readonly json: import("@prisma/orm-framework/contract/types").JsonValue;
|
|
430
|
+
readonly traits: never;
|
|
431
|
+
}, "traits" | "output" | "input">;
|
|
432
|
+
readonly "pg/jsonb@1": Pick<{
|
|
433
|
+
readonly input: import("@prisma/orm-framework/contract/types").JsonValue;
|
|
434
|
+
readonly output: import("@prisma/orm-framework/contract/types").JsonValue;
|
|
435
|
+
readonly json: import("@prisma/orm-framework/contract/types").JsonValue;
|
|
436
|
+
readonly traits: "equality";
|
|
437
|
+
}, "traits" | "output" | "input">;
|
|
438
|
+
}>;
|
|
439
|
+
//#endregion
|
|
440
|
+
//#region src/contract/native-enum.d.ts
|
|
441
|
+
/**
|
|
442
|
+
* Handle returned by {@link nativeEnum}. Mirrors PSL's two distinct strings for
|
|
443
|
+
* a `native_enum <Name> { … @@map("type_name") }` block:
|
|
444
|
+
*
|
|
445
|
+
* - `name` — the entity name: the key in `entries.native_enum` /
|
|
446
|
+
* `entries.valueSet`, and the column's `valueSet` ref `entityName`.
|
|
447
|
+
* - `typeName` — the Postgres type name (`CREATE TYPE <typeName> AS ENUM (…)`
|
|
448
|
+
* and the `$N::<typeName>` cast). Defaults to `name`; override with
|
|
449
|
+
* {@link NativeEnumHandle.map}.
|
|
450
|
+
*/
|
|
451
|
+
interface NativeEnumHandle<Name extends string = string, TypeName extends string = string, Members extends readonly [string, ...string[]] = readonly [string, ...string[]]> {
|
|
452
|
+
readonly entityKind: 'native_enum';
|
|
453
|
+
readonly name: Name;
|
|
454
|
+
readonly typeName: TypeName;
|
|
455
|
+
readonly members: Members;
|
|
456
|
+
readonly entity: PostgresNativeEnum<Members>;
|
|
457
|
+
/**
|
|
458
|
+
* Overrides the Postgres type name (PSL's `@@map("type_name")`), keeping the
|
|
459
|
+
* entity `name` unchanged. `nativeEnum('AalLevel', …).map('aal_level')` →
|
|
460
|
+
* entity name `AalLevel`, Postgres type `aal_level`.
|
|
461
|
+
*/
|
|
462
|
+
map<const MappedTypeName extends string>(typeName: MappedTypeName): NativeEnumHandle<Name, MappedTypeName, Members>;
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* Declares a native Postgres enum type for use with {@link pg}'s `.enum()`
|
|
466
|
+
* column helper. Mirrors PSL's `native_enum <Name> { … }` lowering
|
|
467
|
+
* (`lowerNativeEnumFromBlock`): validates a non-empty, duplicate-free member
|
|
468
|
+
* list and builds the same {@link PostgresNativeEnum} entity. Its value-set is
|
|
469
|
+
* derived generically at contract-build time — the same
|
|
470
|
+
* `deriveValueSetFromEntity` fold PSL's native enums go through — once
|
|
471
|
+
* `pg.enum(handle)` lands the entity in the field's owning namespace.
|
|
472
|
+
*
|
|
473
|
+
* The first argument is the entity `name` (the `entries.native_enum` /
|
|
474
|
+
* `entries.valueSet` key). The Postgres type name defaults to `name`; use
|
|
475
|
+
* `.map(typeName)` to override it (PSL's `@@map`).
|
|
476
|
+
*
|
|
477
|
+
* A handle referenced by columns in N different namespaces materialises N
|
|
478
|
+
* native enum types (one per namespace) — by design: a Postgres type lives in
|
|
479
|
+
* exactly one schema, and PSL can't share a type across schemas either.
|
|
480
|
+
*
|
|
481
|
+
* @example
|
|
482
|
+
* ```ts
|
|
483
|
+
* // name === Postgres type name
|
|
484
|
+
* const Role = nativeEnum('Role', 'user', 'admin');
|
|
485
|
+
* // entity name `AalLevel`, Postgres type `aal_level` (Supabase's auth.aal_level)
|
|
486
|
+
* const AalLevel = nativeEnum('AalLevel', 'aal1', 'aal2', 'aal3').map('aal_level');
|
|
487
|
+
* model('Session', { fields: { aal: field.column(pg.enum(AalLevel)).optional() } });
|
|
488
|
+
* ```
|
|
489
|
+
*/
|
|
490
|
+
declare function nativeEnum<const Name extends string, const Members extends readonly [string, ...string[]]>(name: Name, ...members: Members): NativeEnumHandle<Name, Name, Members>;
|
|
491
|
+
/**
|
|
492
|
+
* The descriptor `pg.enum(handle)` returns: an `entityRef.entity` typed to the
|
|
493
|
+
* handle's own `PostgresNativeEnum<Members>`, so the member-value literal
|
|
494
|
+
* tuple survives on the descriptor type instead of widening to `unknown`.
|
|
495
|
+
*/
|
|
496
|
+
type PgEnumColumnDescriptor<Members extends readonly [string, ...string[]]> = ColumnTypeDescriptor<typeof PG_ENUM_CODEC_ID> & {
|
|
497
|
+
readonly entityRef: {
|
|
498
|
+
readonly entityKind: 'native_enum';
|
|
499
|
+
readonly entityName: string;
|
|
500
|
+
readonly entity: PostgresNativeEnum<Members>;
|
|
501
|
+
};
|
|
502
|
+
};
|
|
503
|
+
/**
|
|
504
|
+
* Builds the deferred column descriptor for `handle`: the bare Postgres type
|
|
505
|
+
* name and `typeParams` come from `pgEnumDescriptor.columnFromEntity` (the same
|
|
506
|
+
* authoring hook the PSL `pg.enum(Ref)` type constructor resolves through),
|
|
507
|
+
* carrying `handle.entity` as the descriptor's `entityRef` keyed by the entity
|
|
508
|
+
* `name` (not the Postgres type name — they differ when `.map()` was used).
|
|
509
|
+
* Schema qualification and the storage `valueSet` ref are NOT computed here — a
|
|
510
|
+
* `field.column(pg.enum(handle))` call runs before the enclosing `model(...)`
|
|
511
|
+
* associates a namespace, so `buildSqlContractFromDefinition` resolves both
|
|
512
|
+
* once the field's namespace is known.
|
|
513
|
+
*/
|
|
514
|
+
declare function pgEnumColumn<const Name extends string, const TypeName extends string, const Members extends readonly [string, ...string[]]>(handle: NativeEnumHandle<Name, TypeName, Members>): PgEnumColumnDescriptor<Members>;
|
|
515
|
+
/** Postgres-specific TS type-constructor namespace, mirroring the PSL `pg.` prefix. */
|
|
516
|
+
declare const pg: {
|
|
517
|
+
readonly enum: typeof pgEnumColumn;
|
|
518
|
+
};
|
|
519
|
+
//#endregion
|
|
520
|
+
export { type ComposedAuthoringHelpers, type ContractDefinition, type ContractInput, type ContractModelBuilder, type EnumMember, type EnumTypeHandle, type FieldNode, type ForeignKeyNode, type IndexNode, type ModelNode, type NativeEnumHandle, type PrimaryKeyNode, type RelationNode, type RlsEnablementHandle, type RlsEntityHandle, type RlsPolicyHandle, type RlsRoleHandle, type RlsTargetModel, type RlsUsingPolicyDescriptor, type RlsUsingWithCheckPolicyDescriptor, type RlsWithCheckPolicyDescriptor, type ScalarFieldBuilder, type UniqueConstraintNode, buildSqlContractFromDefinition, defineContract, enumType, field, member, model, nativeEnum, pg, policyAll, policyDelete, policyInsert, policySelect, policyUpdate, rel, rlsEnabled, role };
|
|
521
|
+
//# sourceMappingURL=contract-builder.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract-builder.d.mts","names":[],"sources":["../../../../3-extensions/postgres/dist/contract-builder.d.mts"],"mappings":";;;;;;;;;;;;;;;;;UAgBU;WACC;aACE;aACA;aACA,QAAQ,eAAe;;;;;;;;UAQ1B,cAAc;WACb;WACA,MAAM;;;UAGP;WACC;;WAEA;aACE,QAAQ;;;;;;;;UAQX,gBAAgB,kBAAkB,qBAAqB;WACtD;WACA,WAAW;;WAEX;;WAEA;aACE,QAAQ;;WAEV,gBAAgB;WAChB;WACA;;;;;;KAMN,kBAAkB,kBAAkB,gBAAgB;UAC/C;;WAEC;WACA,gBAAgB;;;UAGjB,iCAAiC;WAChC;;;UAGD,qCAAqC;WACpC;;;;;;;;;KASN,qCAAqC;WAC/B;WACA;MACL;WACK;WACA;;;;;;;;iBAQM,WAAW,qBAAqB,MAAM,OAAO,cAAc;;;;;;iBAM3D,WAAW,OAAO,iBAAiB;;iBAEnC,aAAa,OAAO,gBAAgB,YAAY,2BAA2B;;iBAE3E,aAAa,OAAO,gBAAgB,YAAY,+BAA+B;;iBAE/E,aAAa,OAAO,gBAAgB,YAAY,oCAAoC;;iBAEpF,aAAa,OAAO,gBAAgB,YAAY,2BAA2B;;iBAE3E,UAAU,OAAO,gBAAgB,YAAY,oCAAoC;;;KAG7F,mBAAmB;KACnB,sBAAsB;KACtB,kBAAkB,eAAe;KACjC,mBAAmB,eAAe;KAClC,kBAAkB,eAAe;KACjC,eAAe,cAAc,iBAAiB,eAAe,kBAAkB,mBAAmB,eAAe,8CAA8C,cAAc,mBAAmB,kBAAkB,mBAAmB,WAAW;WAC1O,QAAQ;WACR,SAAS;WACT,aAAa;WACb,QAAQ;WACR,kBAAkB,OAAO,sBAAsB;;KAErD,qBAAqB,mBAAmB,eAAe,gDAAgD,KAAK,gBAAgB,WAAW,cAAc,sBAAsB,sBAA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