@prisma/orm-target-postgres 8.0.0-rc.13 → 8.0.0-rc.13-dev.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/dist/adapter__control.mjs +1 -1
  2. package/dist/adapter__runtime.mjs +1 -1
  3. package/dist/authoring-CLNoGwgA-DPDmJeBt.d.mts +52 -0
  4. package/dist/authoring-CLNoGwgA-DPDmJeBt.d.mts.map +1 -0
  5. package/dist/{authoring-CSC0-DjI-CA5cgVmB.mjs → authoring-D8lRxnKQ-CJP-7ASF.mjs} +89 -225
  6. package/dist/authoring-D8lRxnKQ-CJP-7ASF.mjs.map +1 -0
  7. package/dist/{control-BPA8oU8O.mjs → control-ClhIahnP.mjs} +12 -31
  8. package/dist/control-ClhIahnP.mjs.map +1 -0
  9. package/dist/{descriptor-meta--zYVau3w-D-q8Cvf0.mjs → descriptor-meta-CNe-Xkn_-BR3WQtmD.mjs} +3 -3
  10. package/dist/{descriptor-meta--zYVau3w-D-q8Cvf0.mjs.map → descriptor-meta-CNe-Xkn_-BR3WQtmD.mjs.map} +1 -1
  11. package/dist/{infer-psl-contract-Daj0b_Vd-DOd6cTZN.mjs → infer-psl-contract-DXB7BQ4V-g-i8P-wc.mjs} +9 -27
  12. package/dist/infer-psl-contract-DXB7BQ4V-g-i8P-wc.mjs.map +1 -0
  13. package/dist/migration-PTHAY9Cv.mjs.map +1 -1
  14. package/dist/{pack-DA1QroSM.d.mts → pack-B8SM_MTs.d.mts} +75 -225
  15. package/dist/{pack-DA1QroSM.d.mts.map → pack-B8SM_MTs.d.mts.map} +1 -1
  16. package/dist/{planner-CuyOgsjG-DefGza6Z.mjs → planner-DdWm8AJC-CLW9TNtL.mjs} +3 -3
  17. package/dist/{planner-CuyOgsjG-DefGza6Z.mjs.map → planner-DdWm8AJC-CLW9TNtL.mjs.map} +1 -1
  18. package/dist/{planner-produced-postgres-migration-Ceuww3Cw-CMC3g395.mjs → planner-produced-postgres-migration-BU2DZGV1-Bj4JVSrc.mjs} +3 -3
  19. package/dist/{planner-produced-postgres-migration-Ceuww3Cw-CMC3g395.mjs.map → planner-produced-postgres-migration-BU2DZGV1-Bj4JVSrc.mjs.map} +1 -1
  20. package/dist/{postgres-contract-view-BTNJukLn-QzZysnih.mjs → postgres-contract-view-CY6NUSLi-q2kLuFu4.mjs} +3 -3
  21. package/dist/{postgres-contract-view-BTNJukLn-QzZysnih.mjs.map → postgres-contract-view-CY6NUSLi-q2kLuFu4.mjs.map} +1 -1
  22. package/dist/{postgres-migration-4s6yFwMP-lBYUEAjj.mjs → postgres-migration-C7tFhMAi-Dg-TebAo.mjs} +3 -3
  23. package/dist/{postgres-migration-4s6yFwMP-lBYUEAjj.mjs.map → postgres-migration-C7tFhMAi-Dg-TebAo.mjs.map} +1 -1
  24. package/dist/{prisma7-binding-CMFQU93Y.d.mts → prisma7-binding-1CMtcbOk.d.mts} +75 -225
  25. package/dist/{prisma7-binding-CMFQU93Y.d.mts.map → prisma7-binding-1CMtcbOk.d.mts.map} +1 -1
  26. package/dist/{prisma7-binding-CRgYmsCN.mjs → prisma7-binding-kjuIBeL6.mjs} +4 -4
  27. package/dist/{prisma7-binding-CRgYmsCN.mjs.map → prisma7-binding-kjuIBeL6.mjs.map} +1 -1
  28. package/dist/target.d.mts +2 -2
  29. package/dist/target.mjs +7 -7
  30. package/dist/target__control.mjs +2 -2
  31. package/dist/target__migration.mjs +1 -1
  32. package/dist/target__pack.d.mts +1 -1
  33. package/dist/target__pack.mjs +1 -1
  34. package/dist/target__planner-produced-postgres-migration.mjs +1 -1
  35. package/dist/target__planner.mjs +1 -1
  36. package/dist/target__prisma7-binding.d.mts +1 -1
  37. package/dist/target__prisma7-binding.mjs +1 -1
  38. package/dist/target__runtime.mjs +2 -2
  39. package/dist/target__runtime.mjs.map +1 -1
  40. package/package.json +9 -9
  41. package/dist/authoring-C5lR7WpE-dyB-FeYD.d.mts +0 -36
  42. package/dist/authoring-C5lR7WpE-dyB-FeYD.d.mts.map +0 -1
  43. package/dist/authoring-CSC0-DjI-CA5cgVmB.mjs.map +0 -1
  44. package/dist/control-BPA8oU8O.mjs.map +0 -1
  45. package/dist/infer-psl-contract-Daj0b_Vd-DOd6cTZN.mjs.map +0 -1
@@ -2,7 +2,7 @@ import { C as PG_TIMESTAMPTZ_DATE_CODEC_ID } from "./codec-ids-Cb0yO-IS--e0P2rfI
2
2
  import { i as createPostgresCodecRegistryWithBuiltins, r as createPostgresBuiltinCodecLookup, t as assemblePostgresCodecRegistry } from "./codecs-D3WwIWZp.mjs";
3
3
  import { n as qualifyName, r as quoteIdentifier, t as escapeLiteral } from "./sql-utils-Bh-mnsSY-D6hnFPrP.mjs";
4
4
  import { t as parsePostgresDefault } from "./default-normalizer-Bp3IhMR9-D0uYVRLZ.mjs";
5
- import { a as instantNowControlDescriptor, s as plainDateTimeNowControlDescriptor } from "./authoring-CSC0-DjI-CA5cgVmB.mjs";
5
+ import { a as instantNowControlDescriptor, s as plainDateTimeNowControlDescriptor } from "./authoring-D8lRxnKQ-CJP-7ASF.mjs";
6
6
  import { t as postgresDataTypeEntries } from "./data-type-entries-Fxm2HDZk-D4AAd63w.mjs";
7
7
  import { t as normalizeSchemaNativeType } from "./native-type-normalizer-yvd3tqv-.mjs";
8
8
  import { t as PostgresControlAdapter } from "./control-adapter-CEhnRpI1-D0-PjR_O.mjs";
@@ -1,6 +1,6 @@
1
1
  import { n as postgresCodecRegistry } from "./registry-Bf5BvREu-DJ7g3REJ.mjs";
2
2
  import { t as assemblePostgresCodecRegistry } from "./codecs-D3WwIWZp.mjs";
3
- import { i as instantNow, n as PLAIN_DATE_TIME_NOW_GENERATOR_ID, o as plainDateTimeNow, t as INSTANT_NOW_GENERATOR_ID } from "./authoring-CSC0-DjI-CA5cgVmB.mjs";
3
+ import { i as instantNow, n as PLAIN_DATE_TIME_NOW_GENERATOR_ID, o as plainDateTimeNow, t as INSTANT_NOW_GENERATOR_ID } from "./authoring-D8lRxnKQ-CJP-7ASF.mjs";
4
4
  import { n as createPostgresAdapterWithCodecRegistry, r as postgresRawCodecInferer } from "./adapter-C2dMP6ky-DJ4qd297.mjs";
5
5
  import { t as postgresAdapterDescriptorMeta } from "./descriptor-meta-F1wsOtt2-BFm3bVJ6.mjs";
6
6
  import { builtinGeneratorIds } from "@prisma/orm-framework/ids";
@@ -0,0 +1,52 @@
1
+ import "./postgres-rls-policy-CnDxf3z9-C3LIHAIG.mjs";
2
+ import "./postgres-schema-Xsjt3RKO-Buv2X8ai.mjs";
3
+ import { ParsedPslExtensionBlock } from "@prisma/orm-framework/components/authoring";
4
+ import { InferBlock } from "@prisma/orm-framework/psl-parser";
5
+ import { EntityHandleLoweringInput, LoweredPackEntity, ResolvedPslModelRefs } from "@prisma/orm-family-sql/contract/entity-handle-lowering-hook";
6
+ //#region ../../../3-targets/3-targets/postgres/dist/authoring-CLNoGwgA.d.mts
7
+ //#region src/core/authoring.d.ts
8
+ declare function policyUsingOnlySpec(): import("@prisma/orm-framework/psl-parser").StructBlockSpec<{
9
+ readonly target: import("@prisma/orm-framework/psl-parser").ResolvedEntityReference<import("@prisma/orm-framework/psl-parser").ModelSymbol>;
10
+ readonly roles?: (string | import("@prisma/orm-framework/psl-parser").ResolvedEntityReference<import("@prisma/orm-framework/psl-parser").BlockSymbol>)[];
11
+ readonly using?: string;
12
+ readonly permissive?: boolean;
13
+ }>;
14
+ declare function policyWithCheckOnlySpec(): import("@prisma/orm-framework/psl-parser").StructBlockSpec<{
15
+ readonly target: import("@prisma/orm-framework/psl-parser").ResolvedEntityReference<import("@prisma/orm-framework/psl-parser").ModelSymbol>;
16
+ readonly roles?: (string | import("@prisma/orm-framework/psl-parser").ResolvedEntityReference<import("@prisma/orm-framework/psl-parser").BlockSymbol>)[];
17
+ readonly withCheck?: string;
18
+ readonly permissive?: boolean;
19
+ }>;
20
+ declare function policyBothPredicatesSpec(): import("@prisma/orm-framework/psl-parser").StructBlockSpec<{
21
+ readonly target: import("@prisma/orm-framework/psl-parser").ResolvedEntityReference<import("@prisma/orm-framework/psl-parser").ModelSymbol>;
22
+ readonly roles?: (string | import("@prisma/orm-framework/psl-parser").ResolvedEntityReference<import("@prisma/orm-framework/psl-parser").BlockSymbol>)[];
23
+ readonly using?: string;
24
+ readonly withCheck?: string;
25
+ readonly permissive?: boolean;
26
+ }>;
27
+ type PolicyBlockValues = InferBlock<ReturnType<typeof policyBothPredicatesSpec>>;
28
+ interface RlsPolicyExtensionBlock extends ParsedPslExtensionBlock<PolicyBlockValues> {
29
+ readonly namespaceId: string;
30
+ readonly resolvedModelRefs?: ResolvedPslModelRefs;
31
+ }
32
+ declare function roleSpec(): import("@prisma/orm-framework/psl-parser").StructBlockSpec<{}>;
33
+ declare function nativeEnumSpec(): import("@prisma/orm-framework/psl-parser").MapBlockSpec<Record<string, string>>;
34
+ /** A parsed `role` block annotated with its lexical namespace id by the interpreter. */
35
+ interface RoleExtensionBlock extends ParsedPslExtensionBlock {
36
+ readonly namespaceId: string;
37
+ }
38
+ /**
39
+ * The SQL-family entity-handle batch lowering hook for the Postgres pack
40
+ * (`SqlEntityHandleLoweringContribution`). Receives every `entities` handle
41
+ * whose kind this pack registered — batch, so the cross-entity diagnostics
42
+ * (duplicate prefix, policy without rlsEnabled, duplicate role) can see
43
+ * sibling handles — and lowers them with the same keying and hash assembly
44
+ * as the PSL path: `policy` keyed by prefix (wire name via
45
+ * {@link buildRlsPolicyEntity}), `rls` keyed by table name, `role` keyed by
46
+ * name and filed under the default namespace (roles are declared
47
+ * contract-wide; PSL has no role block to set a precedent).
48
+ */
49
+ declare function postgresLowerEntityHandles(input: EntityHandleLoweringInput): readonly LoweredPackEntity[];
50
+ //#endregion
51
+ export { policyUsingOnlySpec as a, roleSpec as c, policyBothPredicatesSpec as i, RoleExtensionBlock as n, policyWithCheckOnlySpec as o, nativeEnumSpec as r, postgresLowerEntityHandles as s, RlsPolicyExtensionBlock as t };
52
+ //# sourceMappingURL=authoring-CLNoGwgA-DPDmJeBt.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authoring-CLNoGwgA-DPDmJeBt.d.mts","names":[],"sources":["../../../../3-targets/3-targets/postgres/dist/authoring-CLNoGwgA.d.mts"],"mappings":";;;;;;;iBAMiB,sDAAsD;WAC5D,uCAAuC,uDAAuD;WAC9F,iDAAiD,uDAAuD;WACxG;WACA;;iBAEM,0DAA0D;WAChE,uCAAuC,uDAAuD;WAC9F,iDAAiD,uDAAuD;WACxG;WACA;;iBAEM,2DAA2D;WACjE,uCAAuC,uDAAuD;WAC9F,iDAAiD,uDAAuD;WACxG;WACA;WACA;;KAEN,oBAAoB,WAAW,kBAAkB;UAC5C,gCAAgC,wBAAwB;WACvD;WACA,oBAAoB;;iBAEd,2CAA2C;iBAC3C,iDAAiD,aAAa;;UAErE,2BAA2B;WAC1B;;;;;;;;;;;;;iBAaM,2BAA2B,OAAO,qCAAqC"}
@@ -3,7 +3,7 @@ import { i as errorTemporalUnavailableForDefault, s as postgresError } from "./e
3
3
  import { t as PostgresNativeEnum } from "./postgres-native-enum-CdP3b_-R-Cgz9KEKx.mjs";
4
4
  import { a as PostgresRlsPolicySchema, i as PostgresRlsPolicy, n as PostgresRlsEnablement, o as PostgresRole, r as PostgresRlsEnablementSchema, s as PostgresRoleSchema, t as PostgresNativeEnumSchema } from "./postgres-schema-MIh_qSUu-gKCH4OhS.mjs";
5
5
  import { n as renderFullTextIndexExpression, t as isFullTextIndexableCodec } from "./full-text-index-expression-ix6TNfZZ-Ct96i2ZE.mjs";
6
- import { n as computeContentHash, t as POLICY_OPERATION_PREDICATES } from "./canonicalize-CrN3u_xM-D4MrOqcB.mjs";
6
+ import { n as computeContentHash } from "./canonicalize-CrN3u_xM-D4MrOqcB.mjs";
7
7
  import { n as POSTGRES_TEXT_SEARCH_LANGUAGES } from "./text-search-languages-RO0HiUDm-CeJ7P8gS.mjs";
8
8
  import { blindCast } from "@prisma/orm-framework/utils/casts";
9
9
  import { UNBOUND_NAMESPACE_ID } from "@prisma/orm-framework/components/ir";
@@ -12,9 +12,9 @@ import { assertWireNamePrefixLength, normalizeSqlBody } from "@prisma/orm-family
12
12
  import { assertDefined, invariant } from "@prisma/orm-framework/utils/assertions";
13
13
  import { temporalCodecPresetWithPrecision, temporalStringAuthoringPresets } from "@prisma/orm-family-sql/family/control";
14
14
  import { TIMESTAMP_NOW_GENERATOR_ID, temporalAuthoringPresets } from "@prisma/orm-framework/components/authoring";
15
- import { blockAttribute, fieldRef, leafDiagnostic, list, modelAttribute, oneOf, optional, str } from "@prisma/orm-framework/psl-parser";
15
+ import { blockAttribute, bool, entityRef, fieldRef, identifier, leafDiagnostic, list, mapBlock, modelAttribute, oneOf, optional, str, structBlock } from "@prisma/orm-framework/psl-parser";
16
16
  import { exactNameBodyWarning } from "@prisma/orm-family-sql/contract/index-naming";
17
- //#region ../../../3-targets/3-targets/postgres/dist/authoring-CSC0-DjI.mjs
17
+ //#region ../../../3-targets/3-targets/postgres/dist/authoring-D8lRxnKQ.mjs
18
18
  const INSTANT_NOW_GENERATOR_ID = "instantNow";
19
19
  function instantNowControlDescriptor() {
20
20
  return {
@@ -72,14 +72,11 @@ const nowGeneratorIdByCodecId = new Map(Object.entries(postgresNowGeneratorIds))
72
72
  function postgresNowGeneratorIdFor(codecId) {
73
73
  return nowGeneratorIdByCodecId.get(codecId);
74
74
  }
75
- const PSL_RLS_PREDICATE_NOT_FOR_OPERATION = "PSL_RLS_PREDICATE_NOT_FOR_OPERATION";
76
75
  const PSL_POLICY_INVALID_MAP = "PSL_POLICY_INVALID_MAP";
77
76
  const PSL_FULL_TEXT_INDEX_ONE_FIELD = "PSL_FULL_TEXT_INDEX_ONE_FIELD";
78
77
  const PSL_FULL_TEXT_INDEX_REQUIRES_NAME = "PSL_FULL_TEXT_INDEX_REQUIRES_NAME";
79
78
  const PSL_FULL_TEXT_INDEX_NAME_XOR_MAP = "PSL_FULL_TEXT_INDEX_NAME_XOR_MAP";
80
79
  const PSL_FULL_TEXT_INDEX_TEXT_FIELD = "PSL_FULL_TEXT_INDEX_TEXT_FIELD";
81
- const PSL_NATIVE_ENUM_BARE_MEMBER = "PSL_NATIVE_ENUM_BARE_MEMBER";
82
- const PSL_EXTENSION_INVALID_VALUE = "PSL_EXTENSION_INVALID_VALUE";
83
80
  const PSL_NATIVE_ENUM_DUPLICATE_MEMBER_VALUE = "PSL_NATIVE_ENUM_DUPLICATE_MEMBER_VALUE";
84
81
  const PSL_NATIVE_ENUM_MISSING_MEMBERS = "PSL_NATIVE_ENUM_MISSING_MEMBERS";
85
82
  const PSL_ROLE_BLOCK_OUTSIDE_UNBOUND_NAMESPACE = "PSL_ROLE_BLOCK_OUTSIDE_UNBOUND_NAMESPACE";
@@ -117,6 +114,63 @@ const postgresAuthoringTypes = {
117
114
  output: { codecId: PG_ENUM_CODEC_ID }
118
115
  } }
119
116
  };
117
+ const policyTargetParam = {
118
+ type: entityRef({ kind: "model" }),
119
+ documentation: "The model protected by this policy; it must declare @@rls."
120
+ };
121
+ const policyRolesParam = {
122
+ type: optional(list(oneOf(entityRef({
123
+ kind: "block",
124
+ keyword: "role"
125
+ }), identifier()))),
126
+ documentation: "The database roles to which this policy applies."
127
+ };
128
+ const policyUsingParam = {
129
+ type: optional(str()),
130
+ documentation: "A SQL predicate controlling which rows this policy permits."
131
+ };
132
+ const policyWithCheckParam = {
133
+ type: optional(str()),
134
+ documentation: "A SQL predicate checking rows being written by this policy."
135
+ };
136
+ const policyPermissiveParam = {
137
+ type: optional(bool()),
138
+ documentation: "Whether the policy is permissive (combined with OR) rather than restrictive (combined with AND)."
139
+ };
140
+ function policyUsingOnlySpec() {
141
+ return structBlock({ parameters: {
142
+ target: policyTargetParam,
143
+ roles: policyRolesParam,
144
+ using: policyUsingParam,
145
+ permissive: policyPermissiveParam
146
+ } });
147
+ }
148
+ function policyWithCheckOnlySpec() {
149
+ return structBlock({ parameters: {
150
+ target: policyTargetParam,
151
+ roles: policyRolesParam,
152
+ withCheck: policyWithCheckParam,
153
+ permissive: policyPermissiveParam
154
+ } });
155
+ }
156
+ function policyBothPredicatesSpec() {
157
+ return structBlock({ parameters: {
158
+ target: policyTargetParam,
159
+ roles: policyRolesParam,
160
+ using: policyUsingParam,
161
+ withCheck: policyWithCheckParam,
162
+ permissive: policyPermissiveParam
163
+ } });
164
+ }
165
+ function roleSpec() {
166
+ return structBlock({ parameters: {} });
167
+ }
168
+ function nativeEnumSpec() {
169
+ return mapBlock({ value: {
170
+ type: str(),
171
+ documentation: "The member value stored in the database enum type."
172
+ } });
173
+ }
120
174
  /**
121
175
  * The block keyword that authors each row-level security operation. The keyword is the operation, so
122
176
  * a policy block has no `operation` parameter. The reader looks a block's operation up here, and
@@ -136,55 +190,6 @@ function isRlsPolicyOperation(value) {
136
190
  function policyOperationOfKeyword(keyword) {
137
191
  return Object.keys(POLICY_BLOCK_KEYWORDS).filter(isRlsPolicyOperation).find((operation) => POLICY_BLOCK_KEYWORDS[operation] === keyword);
138
192
  }
139
- function readValueParam(block, key) {
140
- const param = block.parameters[key];
141
- return param?.kind === "value" ? param.raw : void 0;
142
- }
143
- function readListRefParams(block, key) {
144
- const param = block.parameters[key];
145
- if (param?.kind !== "list") return [];
146
- return param.items.flatMap((item) => item.kind === "ref" ? [item.identifier] : []);
147
- }
148
- const JSON_STRING_ESCAPES = /* @__PURE__ */ new Map([
149
- ["\"", "\""],
150
- ["\\", "\\"],
151
- ["/", "/"],
152
- ["b", "\b"],
153
- ["f", "\f"],
154
- ["n", "\n"],
155
- ["r", "\r"],
156
- ["t", " "]
157
- ]);
158
- /**
159
- * Unwraps a quoted policy expression. The PSL printer writes a block value as a JSON string, so
160
- * each JSON escape is decoded, `\uXXXX` included. The PSL tokenizer lets a backslash escape any
161
- * character; a backslash sequence that is not a JSON escape is kept as written.
162
- */
163
- function unwrapQuotedString(raw) {
164
- if (!(raw.startsWith("\"") && raw.endsWith("\"") && raw.length >= 2)) return raw;
165
- const inner = raw.slice(1, -1);
166
- let result = "";
167
- for (let i = 0; i < inner.length; i++) {
168
- if (inner[i] !== "\\" || i + 1 >= inner.length) {
169
- result += inner[i];
170
- continue;
171
- }
172
- const next = inner.charAt(i + 1);
173
- const escaped = JSON_STRING_ESCAPES.get(next);
174
- const hex = inner.slice(i + 2, i + 6);
175
- if (escaped !== void 0) {
176
- result += escaped;
177
- i++;
178
- } else if (next === "u" && /^[0-9a-fA-F]{4}$/.test(hex)) {
179
- result += String.fromCharCode(Number.parseInt(hex, 16));
180
- i += 5;
181
- } else {
182
- result += `\\${next}`;
183
- i++;
184
- }
185
- }
186
- return result;
187
- }
188
193
  /**
189
194
  * Assembles a {@link PostgresRlsPolicy} from lowered inputs: normalizes the
190
195
  * predicates, computes the content-hash wire name, and constructs the frozen
@@ -219,35 +224,12 @@ function buildRlsPolicyEntity(input) {
219
224
  function lowerRlsPolicyFromBlock(block, ctx) {
220
225
  const prefix = block.name;
221
226
  const operation = policyOperationOfKeyword(block.keyword) ?? "select";
222
- const tableName = block.resolvedModelRefs?.["target"]?.tableName;
223
- assertDefined(tableName, `lowerRlsPolicyFromBlock: policy "${block.name}" reached the factory without a resolved \`target\` ref; the interpreter resolves same-namespace model refs before invoking entity factories.`);
224
- const roles = [...readListRefParams(block, "roles")].sort();
225
- const usingRaw = readValueParam(block, "using");
226
- const withCheckRaw = readValueParam(block, "withCheck");
227
- const support = POLICY_OPERATION_PREDICATES[operation];
228
- const rejectPredicate = (predicate) => {
229
- ctx.diagnostics?.push({
230
- code: PSL_RLS_PREDICATE_NOT_FOR_OPERATION,
231
- message: `\`${block.keyword}\` policy "${block.name}" does not take a \`${predicate}\` predicate; the ${operation.toUpperCase()} operation uses ${support.using ? "`using`" : "`withCheck`"}${support.using && support.withCheck ? " and `withCheck`" : " only"}.`,
232
- sourceId: ctx.sourceId ?? "unknown",
233
- span: block.parameters[predicate]?.span ?? block.span
234
- });
235
- };
236
- if (usingRaw !== void 0 && !support.using) return rejectPredicate("using");
237
- if (withCheckRaw !== void 0 && !support.withCheck) return rejectPredicate("withCheck");
238
- const using = usingRaw !== void 0 ? unwrapQuotedString(usingRaw) : void 0;
239
- const withCheck = withCheckRaw !== void 0 ? unwrapQuotedString(withCheckRaw) : void 0;
240
- const permissiveRaw = readValueParam(block, "permissive");
241
- if (permissiveRaw !== void 0 && permissiveRaw !== "true" && permissiveRaw !== "false") {
242
- ctx.diagnostics?.push({
243
- code: PSL_EXTENSION_INVALID_VALUE,
244
- message: `\`${block.keyword}\` policy "${block.name}" \`permissive\` must be \`true\` or \`false\`, got ${permissiveRaw}.`,
245
- sourceId: ctx.sourceId ?? "unknown",
246
- span: block.parameters["permissive"]?.span ?? block.span
247
- });
248
- return;
249
- }
250
- const permissive = permissiveRaw !== "false";
227
+ const target = block.resolvedModelRefs?.["target"];
228
+ assertDefined(target, `lowerRlsPolicyFromBlock: policy "${block.name}" reached the factory without a projected \`target\` coordinate; the interpreter projects checked model references before invoking entity factories.`);
229
+ const roles = block.values.roles === void 0 ? [] : block.values.roles.map((role) => typeof role === "string" ? role : role.declaration.name).sort();
230
+ const using = block.values.using;
231
+ const withCheck = block.values.withCheck;
232
+ const permissive = block.values.permissive ?? true;
251
233
  const mapAttr = block.attributes["map"];
252
234
  if (mapAttr !== void 0) {
253
235
  const exactName = mapAttr.args["name"];
@@ -258,8 +240,8 @@ function lowerRlsPolicyFromBlock(block, ctx) {
258
240
  kind: "exact",
259
241
  name: exactName
260
242
  },
261
- tableName,
262
- namespaceId: block.namespaceId,
243
+ tableName: target.tableName,
244
+ namespaceId: target.namespaceId,
263
245
  operation,
264
246
  roles,
265
247
  using,
@@ -269,8 +251,8 @@ function lowerRlsPolicyFromBlock(block, ctx) {
269
251
  }
270
252
  return buildRlsPolicyEntity({
271
253
  prefix,
272
- tableName,
273
- namespaceId: block.namespaceId,
254
+ tableName: target.tableName,
255
+ namespaceId: target.namespaceId,
274
256
  operation,
275
257
  roles,
276
258
  ...ifDefined("using", using),
@@ -278,16 +260,10 @@ function lowerRlsPolicyFromBlock(block, ctx) {
278
260
  permissive
279
261
  });
280
262
  }
281
- /**
282
- * Lowers a `native_enum { memberName = "value" … @@map("type_name") }` block
283
- * into a {@link PostgresNativeEnum}. Members must be authored as explicit
284
- * `key = "value"` pairs — a bare (value-less) member is a diagnostic, not
285
- * accepted (authoring-design.md §2.1). The parsed `memberName` is only used
286
- * to duplicate-check and report diagnostics; the lowered entity carries just
287
- * the member values (a native enum is value-only — the member "name" isn't
288
- * a separate authoring concept from the value). `typeName` comes from
289
- * `@@map` or defaults to the block name verbatim.
290
- */
263
+ const policyEntityTypeOutput = {
264
+ factory: lowerRlsPolicyFromBlock,
265
+ pslPlacement: (entity) => ({ namespaceId: entity.namespaceId })
266
+ };
291
267
  function lowerNativeEnumFromBlock(block, ctx) {
292
268
  const sourceId = ctx.sourceId ?? "unknown";
293
269
  const diagnostics = ctx.diagnostics;
@@ -301,53 +277,19 @@ function lowerNativeEnumFromBlock(block, ctx) {
301
277
  let memberError = false;
302
278
  const seenValues = /* @__PURE__ */ new Set();
303
279
  const members = [];
304
- for (const [memberName, paramValue] of Object.entries(block.parameters)) {
305
- if (paramValue.kind === "bare") {
306
- diagnostics?.push({
307
- code: PSL_NATIVE_ENUM_BARE_MEMBER,
308
- message: `native_enum "${block.name}" member "${memberName}" has no value; members must be authored as "${memberName} = \\"value\\""`,
309
- sourceId,
310
- span: paramValue.span
311
- });
312
- memberError = true;
313
- continue;
314
- }
315
- if (paramValue.kind !== "value") continue;
316
- let jsonValue;
317
- try {
318
- jsonValue = JSON.parse(paramValue.raw);
319
- } catch {
320
- diagnostics?.push({
321
- code: PSL_EXTENSION_INVALID_VALUE,
322
- message: `native_enum "${block.name}" member "${memberName}" value "${paramValue.raw}" is not valid JSON`,
323
- sourceId,
324
- span: paramValue.span
325
- });
326
- memberError = true;
327
- continue;
328
- }
329
- if (typeof jsonValue !== "string") {
330
- diagnostics?.push({
331
- code: PSL_EXTENSION_INVALID_VALUE,
332
- message: `native_enum "${block.name}" member "${memberName}" value must be a string`,
333
- sourceId,
334
- span: paramValue.span
335
- });
336
- memberError = true;
337
- continue;
338
- }
339
- if (seenValues.has(jsonValue)) {
280
+ for (const [memberName, value] of Object.entries(block.values)) {
281
+ if (seenValues.has(value)) {
340
282
  diagnostics?.push({
341
283
  code: PSL_NATIVE_ENUM_DUPLICATE_MEMBER_VALUE,
342
- message: `native_enum "${block.name}": duplicate member value "${jsonValue}"`,
284
+ message: `native_enum "${block.name}": duplicate member value "${value}"`,
343
285
  sourceId,
344
- span: paramValue.span
286
+ span: block.parameterSpans[memberName] ?? block.span
345
287
  });
346
288
  memberError = true;
347
289
  continue;
348
290
  }
349
- seenValues.add(jsonValue);
350
- members.push(jsonValue);
291
+ seenValues.add(value);
292
+ members.push(value);
351
293
  }
352
294
  if (memberError) return void 0;
353
295
  if (members.length === 0) {
@@ -419,7 +361,7 @@ const postgresAuthoringEntityTypes = {
419
361
  kind: "entity",
420
362
  discriminator: "policy",
421
363
  validatorSchema: PostgresRlsPolicySchema,
422
- output: { factory: lowerRlsPolicyFromBlock }
364
+ output: policyEntityTypeOutput
423
365
  },
424
366
  native_enum: {
425
367
  kind: "entity",
@@ -441,46 +383,6 @@ const postgresAuthoringEntityTypes = {
441
383
  * portability use `uuidString` / `id.uuidv4String` / `id.uuidv7String` from
442
384
  * the family pack instead.
443
385
  */
444
- /**
445
- * Shared parameter descriptors for the five `policy_<op>` PSL block
446
- * keywords. All five share the `policy` discriminator — the parser
447
- * dispatches by keyword (see the framework's PSL-block SPI), and every
448
- * keyword's factory lowers to `PostgresRlsPolicy` via `lowerRlsPolicyFromBlock`.
449
- *
450
- * The `roles` list uses `scope:'cross-space'` because same-namespace
451
- * role ref resolution requires PSL namespace entries keyed by `refKind`
452
- * (i.e. `'role'`), which in turn requires the role block discriminator to
453
- * equal `'role'`. Aligning discriminator with refKind is tracked for
454
- * slice 4 (cross-space roles). Until then cross-space passes validation
455
- * unconditionally and the authored role names flow through unchanged.
456
- */
457
- const policyTargetParam = {
458
- kind: "ref",
459
- documentation: "The model protected by this policy; it must declare @@rls.",
460
- refKind: "model",
461
- scope: "same-namespace",
462
- required: true
463
- };
464
- const policyRolesParam = {
465
- kind: "list",
466
- documentation: "The database roles to which this policy applies.",
467
- of: {
468
- kind: "ref",
469
- refKind: "role",
470
- scope: "cross-space"
471
- }
472
- };
473
- const policyPredicateParam = {
474
- kind: "value",
475
- codecId: "pg/text@1",
476
- required: true,
477
- documentation: "A SQL predicate controlling which rows this policy permits."
478
- };
479
- const policyPermissiveParam = {
480
- kind: "value",
481
- codecId: "pg/bool@1",
482
- documentation: "Whether the policy is permissive (combined with OR) rather than restrictive (combined with AND)."
483
- };
484
386
  const policyRequiresRls = {
485
387
  parameter: "target",
486
388
  attribute: "rls"
@@ -510,12 +412,7 @@ const postgresAuthoringPslBlockDescriptors = {
510
412
  documentation: "Defines a row-level security policy controlling which rows can be selected.",
511
413
  discriminator: "policy",
512
414
  name: { required: true },
513
- parameters: {
514
- target: policyTargetParam,
515
- roles: policyRolesParam,
516
- using: policyPredicateParam,
517
- permissive: policyPermissiveParam
518
- },
415
+ spec: policyUsingOnlySpec,
519
416
  requiresModelAttribute: policyRequiresRls,
520
417
  attributes: policyBlockAttributes
521
418
  },
@@ -525,12 +422,7 @@ const postgresAuthoringPslBlockDescriptors = {
525
422
  documentation: "Defines a row-level security policy controlling which rows can be deleted.",
526
423
  discriminator: "policy",
527
424
  name: { required: true },
528
- parameters: {
529
- target: policyTargetParam,
530
- roles: policyRolesParam,
531
- using: policyPredicateParam,
532
- permissive: policyPermissiveParam
533
- },
425
+ spec: policyUsingOnlySpec,
534
426
  requiresModelAttribute: policyRequiresRls,
535
427
  attributes: policyBlockAttributes
536
428
  },
@@ -540,12 +432,7 @@ const postgresAuthoringPslBlockDescriptors = {
540
432
  documentation: "Defines a row-level security policy checking rows being inserted.",
541
433
  discriminator: "policy",
542
434
  name: { required: true },
543
- parameters: {
544
- target: policyTargetParam,
545
- roles: policyRolesParam,
546
- withCheck: policyPredicateParam,
547
- permissive: policyPermissiveParam
548
- },
435
+ spec: policyWithCheckOnlySpec,
549
436
  requiresModelAttribute: policyRequiresRls,
550
437
  attributes: policyBlockAttributes
551
438
  },
@@ -555,13 +442,7 @@ const postgresAuthoringPslBlockDescriptors = {
555
442
  documentation: "Defines a row-level security policy controlling row visibility and checks for updates.",
556
443
  discriminator: "policy",
557
444
  name: { required: true },
558
- parameters: {
559
- target: policyTargetParam,
560
- roles: policyRolesParam,
561
- using: policyPredicateParam,
562
- withCheck: policyPredicateParam,
563
- permissive: policyPermissiveParam
564
- },
445
+ spec: policyBothPredicatesSpec,
565
446
  requiresModelAttribute: policyRequiresRls,
566
447
  attributes: policyBlockAttributes
567
448
  },
@@ -571,34 +452,17 @@ const postgresAuthoringPslBlockDescriptors = {
571
452
  documentation: "Defines a row-level security policy applying to all operations.",
572
453
  discriminator: "policy",
573
454
  name: { required: true },
574
- parameters: {
575
- target: policyTargetParam,
576
- roles: policyRolesParam,
577
- using: policyPredicateParam,
578
- withCheck: policyPredicateParam,
579
- permissive: policyPermissiveParam
580
- },
455
+ spec: policyBothPredicatesSpec,
581
456
  requiresModelAttribute: policyRequiresRls,
582
457
  attributes: policyBlockAttributes
583
458
  },
584
- /**
585
- * PSL block descriptor for `native_enum`.
586
- *
587
- * Reuses the existing variadic-block mechanism (the same shape the SQL
588
- * family's `enum` block ships): the body is an open `memberName = "value"`
589
- * list. `variadicParameters: true` opens the block to arbitrary keys
590
- * beyond the declared (empty) `parameters` set — the lowering factory
591
- * (`lowerNativeEnumFromBlock`) turns the variadic entries into ordered
592
- * members and rejects a bare (value-less) member.
593
- */
594
459
  native_enum: {
595
460
  kind: "pslBlock",
596
461
  keyword: "native_enum",
597
462
  documentation: "Defines a PostgreSQL enum type with named string-valued members.",
598
463
  discriminator: "native_enum",
599
464
  name: { required: true },
600
- parameters: {},
601
- variadicParameters: true,
465
+ spec: nativeEnumSpec,
602
466
  attributes: { map: () => nativeEnumMapAttribute }
603
467
  },
604
468
  /**
@@ -613,7 +477,7 @@ const postgresAuthoringPslBlockDescriptors = {
613
477
  documentation: "Declares an existing database role in namespace unbound for use in security policies.",
614
478
  discriminator: "role",
615
479
  name: { required: true },
616
- parameters: {}
480
+ spec: roleSpec
617
481
  }
618
482
  };
619
483
  const postgresRlsSpec = modelAttribute("rls", { documentation: "Enables PostgreSQL row-level security on this model’s table." });
@@ -976,4 +840,4 @@ function postgresLowerEntityHandles(input) {
976
840
  //#endregion
977
841
  export { instantNowControlDescriptor as a, postgresAuthoringEntityTypes as c, postgresAuthoringPslBlockDescriptors as d, postgresAuthoringTypes as f, instantNow as i, postgresAuthoringFieldPresets as l, postgresNowGeneratorIdFor as m, PLAIN_DATE_TIME_NOW_GENERATOR_ID as n, plainDateTimeNow as o, postgresLowerEntityHandles as p, POLICY_BLOCK_KEYWORDS as r, plainDateTimeNowControlDescriptor as s, INSTANT_NOW_GENERATOR_ID as t, postgresAuthoringModelAttributes as u };
978
842
 
979
- //# sourceMappingURL=authoring-CSC0-DjI-CA5cgVmB.mjs.map
843
+ //# sourceMappingURL=authoring-D8lRxnKQ-CJP-7ASF.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authoring-D8lRxnKQ-CJP-7ASF.mjs","names":[],"sources":["../../../../3-targets/3-targets/postgres/dist/authoring-D8lRxnKQ.mjs"],"sourcesContent":["import { C as PG_TIMESTAMPTZ_DATE_CODEC_ID, D as PG_TIMESTAMP_TEMPORAL_CODEC_ID, E as PG_TIMESTAMP_STRING_CODEC_ID, T as PG_TIMESTAMPTZ_TEMPORAL_CODEC_ID, s as PG_ENUM_CODEC_ID, w as PG_TIMESTAMPTZ_STRING_CODEC_ID } from \"./codec-ids-Cb0yO-IS.mjs\";\nimport { i as errorTemporalUnavailableForDefault, s as postgresError } from \"./errors-DYyzTYzE.mjs\";\nimport { t as PostgresNativeEnum } from \"./postgres-native-enum-CdP3b_-R.mjs\";\nimport { n as renderFullTextIndexExpression, t as isFullTextIndexableCodec } from \"./full-text-index-expression-ix6TNfZZ.mjs\";\nimport { _ as PostgresRlsPolicy, d as PostgresNativeEnumSchema, f as PostgresRlsEnablementSchema, h as PostgresRole, m as PostgresRoleSchema, p as PostgresRlsPolicySchema, v as PostgresRlsEnablement } from \"./postgres-schema-MIh_qSUu.mjs\";\nimport { n as computeContentHash } from \"./canonicalize-CrN3u_xM.mjs\";\nimport { n as POSTGRES_TEXT_SEARCH_LANGUAGES } from \"./text-search-languages-RO0HiUDm.mjs\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { UNBOUND_NAMESPACE_ID } from \"@internal/framework-components/ir\";\nimport { temporalCodecPresetWithPrecision, temporalStringAuthoringPresets } from \"@internal/family-sql/control\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { TIMESTAMP_NOW_GENERATOR_ID, temporalAuthoringPresets } from \"@internal/framework-components/authoring\";\nimport { blockAttribute, bool, entityRef, fieldRef, identifier, leafDiagnostic, list, mapBlock, modelAttribute, oneOf, optional, str, structBlock } from \"@internal/psl-parser\";\nimport { exactNameBodyWarning } from \"@internal/sql-contract/index-naming\";\nimport { assertWireNamePrefixLength, normalizeSqlBody } from \"@internal/sql-schema-ir/naming\";\nimport { assertDefined, invariant } from \"@internal/utils/assertions\";\n//#region src/core/instant-now-generator.ts\nconst INSTANT_NOW_GENERATOR_ID = \"instantNow\";\nfunction instantNowControlDescriptor() {\n\treturn {\n\t\tid: INSTANT_NOW_GENERATOR_ID,\n\t\tbuildPhases: () => ({\n\t\t\tonCreate: {\n\t\t\t\tkind: \"generator\",\n\t\t\t\tid: INSTANT_NOW_GENERATOR_ID\n\t\t\t},\n\t\t\tonUpdate: {\n\t\t\t\tkind: \"generator\",\n\t\t\t\tid: INSTANT_NOW_GENERATOR_ID\n\t\t\t}\n\t\t})\n\t};\n}\nfunction instantNow() {\n\tif (typeof Temporal === \"undefined\") throw errorTemporalUnavailableForDefault(INSTANT_NOW_GENERATOR_ID);\n\treturn Temporal.Now.instant();\n}\n//#endregion\n//#region src/core/plain-date-time-now-generator.ts\n/**\n* The \"now\" generator for `timestamp` (without time zone) columns: the current\n* moment as a UTC wall-clock `Temporal.PlainDateTime`, the representation\n* `pg/timestamp-temporal@1` encodes. `timestamptz` columns use `instantNow`.\n*/\nconst PLAIN_DATE_TIME_NOW_GENERATOR_ID = \"plainDateTimeNow\";\nfunction plainDateTimeNowControlDescriptor() {\n\treturn {\n\t\tid: PLAIN_DATE_TIME_NOW_GENERATOR_ID,\n\t\tbuildPhases: () => ({\n\t\t\tonCreate: {\n\t\t\t\tkind: \"generator\",\n\t\t\t\tid: PLAIN_DATE_TIME_NOW_GENERATOR_ID\n\t\t\t},\n\t\t\tonUpdate: {\n\t\t\t\tkind: \"generator\",\n\t\t\t\tid: PLAIN_DATE_TIME_NOW_GENERATOR_ID\n\t\t\t}\n\t\t})\n\t};\n}\nfunction plainDateTimeNow() {\n\tif (typeof Temporal === \"undefined\") throw errorTemporalUnavailableForDefault(PLAIN_DATE_TIME_NOW_GENERATOR_ID);\n\treturn Temporal.Now.plainDateTimeISO(\"UTC\");\n}\n//#endregion\n//#region src/core/now-generators.ts\n/** The \"now\" generator for each codec that has one. The `temporal` field presets read it. */\nconst postgresNowGeneratorIds = {\n\t[PG_TIMESTAMP_TEMPORAL_CODEC_ID]: PLAIN_DATE_TIME_NOW_GENERATOR_ID,\n\t[PG_TIMESTAMPTZ_TEMPORAL_CODEC_ID]: INSTANT_NOW_GENERATOR_ID,\n\t[PG_TIMESTAMPTZ_DATE_CODEC_ID]: TIMESTAMP_NOW_GENERATOR_ID,\n\t[PG_TIMESTAMP_STRING_CODEC_ID]: TIMESTAMP_NOW_GENERATOR_ID,\n\t[PG_TIMESTAMPTZ_STRING_CODEC_ID]: TIMESTAMP_NOW_GENERATOR_ID\n};\nconst nowGeneratorIdByCodecId = new Map(Object.entries(postgresNowGeneratorIds));\nfunction postgresNowGeneratorIdFor(codecId) {\n\treturn nowGeneratorIdByCodecId.get(codecId);\n}\n//#endregion\n//#region src/core/authoring.ts\nconst PSL_POLICY_INVALID_MAP = \"PSL_POLICY_INVALID_MAP\";\nconst PSL_FULL_TEXT_INDEX_ONE_FIELD = \"PSL_FULL_TEXT_INDEX_ONE_FIELD\";\nconst PSL_FULL_TEXT_INDEX_REQUIRES_NAME = \"PSL_FULL_TEXT_INDEX_REQUIRES_NAME\";\nconst PSL_FULL_TEXT_INDEX_NAME_XOR_MAP = \"PSL_FULL_TEXT_INDEX_NAME_XOR_MAP\";\nconst PSL_FULL_TEXT_INDEX_TEXT_FIELD = \"PSL_FULL_TEXT_INDEX_TEXT_FIELD\";\nconst PSL_NATIVE_ENUM_DUPLICATE_MEMBER_VALUE = \"PSL_NATIVE_ENUM_DUPLICATE_MEMBER_VALUE\";\nconst PSL_NATIVE_ENUM_MISSING_MEMBERS = \"PSL_NATIVE_ENUM_MISSING_MEMBERS\";\nconst PSL_ROLE_BLOCK_OUTSIDE_UNBOUND_NAMESPACE = \"PSL_ROLE_BLOCK_OUTSIDE_UNBOUND_NAMESPACE\";\n/**\n* `pg.enum(<ref>)` registers as an ordinary type constructor whose sole\n* positional argument names a `native_enum` entity instead of carrying a\n* literal value. The interpreter resolves the ref to the `native_enum`\n* entity generically (driven by `entityRefArg`); the `pg/enum@1` codec\n* descriptor's `columnFromEntity` hook (see `codecs.ts`) converts that\n* entity into the column's `typeParams` and native type.\n*/\nconst postgresAuthoringTypes = {\n\tBigIntNumber: {\n\t\tkind: \"typeConstructor\",\n\t\tdocumentation: \"A PostgreSQL 64-bit integer represented as a JavaScript number within its safe integer range.\",\n\t\toutput: {\n\t\t\tcodecId: \"pg/int8number@1\",\n\t\t\tnativeType: \"int8\"\n\t\t}\n\t},\n\tUnboundedInt: {\n\t\tkind: \"typeConstructor\",\n\t\tdocumentation: \"An arbitrary-precision integer stored as PostgreSQL numeric and represented as bigint.\",\n\t\toutput: {\n\t\t\tcodecId: \"pg/unboundedint@1\",\n\t\t\tnativeType: \"numeric\"\n\t\t}\n\t},\n\tpg: { enum: {\n\t\tkind: \"typeConstructor\",\n\t\tentityRefArg: {\n\t\t\tindex: 0,\n\t\t\tentityKind: \"native_enum\"\n\t\t},\n\t\toutput: { codecId: PG_ENUM_CODEC_ID }\n\t} }\n};\nconst policyTargetParam = {\n\ttype: entityRef({ kind: \"model\" }),\n\tdocumentation: \"The model protected by this policy; it must declare @@rls.\"\n};\nconst policyRolesParam = {\n\ttype: optional(list(oneOf(entityRef({\n\t\tkind: \"block\",\n\t\tkeyword: \"role\"\n\t}), identifier()))),\n\tdocumentation: \"The database roles to which this policy applies.\"\n};\nconst policyUsingParam = {\n\ttype: optional(str()),\n\tdocumentation: \"A SQL predicate controlling which rows this policy permits.\"\n};\nconst policyWithCheckParam = {\n\ttype: optional(str()),\n\tdocumentation: \"A SQL predicate checking rows being written by this policy.\"\n};\nconst policyPermissiveParam = {\n\ttype: optional(bool()),\n\tdocumentation: \"Whether the policy is permissive (combined with OR) rather than restrictive (combined with AND).\"\n};\nfunction policyUsingOnlySpec() {\n\treturn structBlock({ parameters: {\n\t\ttarget: policyTargetParam,\n\t\troles: policyRolesParam,\n\t\tusing: policyUsingParam,\n\t\tpermissive: policyPermissiveParam\n\t} });\n}\nfunction policyWithCheckOnlySpec() {\n\treturn structBlock({ parameters: {\n\t\ttarget: policyTargetParam,\n\t\troles: policyRolesParam,\n\t\twithCheck: policyWithCheckParam,\n\t\tpermissive: policyPermissiveParam\n\t} });\n}\nfunction policyBothPredicatesSpec() {\n\treturn structBlock({ parameters: {\n\t\ttarget: policyTargetParam,\n\t\troles: policyRolesParam,\n\t\tusing: policyUsingParam,\n\t\twithCheck: policyWithCheckParam,\n\t\tpermissive: policyPermissiveParam\n\t} });\n}\nfunction roleSpec() {\n\treturn structBlock({ parameters: {} });\n}\nfunction nativeEnumSpec() {\n\treturn mapBlock({ value: {\n\t\ttype: str(),\n\t\tdocumentation: \"The member value stored in the database enum type.\"\n\t} });\n}\n/**\n* The block keyword that authors each row-level security operation. The keyword is the operation, so\n* a policy block has no `operation` parameter. The reader looks a block's operation up here, and\n* `contract infer` and `contract print` look up the keyword to write.\n*/\nconst POLICY_BLOCK_KEYWORDS = {\n\tselect: \"policy_select\",\n\tinsert: \"policy_insert\",\n\tupdate: \"policy_update\",\n\tdelete: \"policy_delete\",\n\tall: \"policy_all\"\n};\nfunction isRlsPolicyOperation(value) {\n\treturn Object.hasOwn(POLICY_BLOCK_KEYWORDS, value);\n}\n/** The operation a `policy_<operation>` block keyword authors, or `undefined` for another keyword. */\nfunction policyOperationOfKeyword(keyword) {\n\treturn Object.keys(POLICY_BLOCK_KEYWORDS).filter(isRlsPolicyOperation).find((operation) => POLICY_BLOCK_KEYWORDS[operation] === keyword);\n}\n/**\n* Assembles a {@link PostgresRlsPolicy} from lowered inputs: normalizes the\n* predicates, computes the content-hash wire name, and constructs the frozen\n* entity. The single hash-assembly body shared by the PSL block lowering\n* ({@link lowerRlsPolicyFromBlock}) and the TS entity-handle lowering\n* ({@link postgresLowerEntityHandles}) so the two surfaces cannot drift.\n*/\nfunction buildRlsPolicyEntity(input) {\n\tconst permissive = input.permissive ?? true;\n\tconst wireHash = computeContentHash({\n\t\t...ifDefined(\"using\", input.using !== void 0 ? normalizeSqlBody(input.using) : void 0),\n\t\t...ifDefined(\"withCheck\", input.withCheck !== void 0 ? normalizeSqlBody(input.withCheck) : void 0),\n\t\troles: input.roles,\n\t\toperation: input.operation,\n\t\tpermissive\n\t});\n\treturn new PostgresRlsPolicy({\n\t\tnaming: {\n\t\t\tkind: \"wire\",\n\t\t\tprefix: input.prefix,\n\t\t\thash: wireHash\n\t\t},\n\t\ttableName: input.tableName,\n\t\tnamespaceId: input.namespaceId,\n\t\toperation: input.operation,\n\t\troles: input.roles,\n\t\tusing: input.using,\n\t\twithCheck: input.withCheck,\n\t\tpermissive\n\t});\n}\nfunction lowerRlsPolicyFromBlock(block, ctx) {\n\tconst prefix = block.name;\n\tconst operation = policyOperationOfKeyword(block.keyword) ?? \"select\";\n\tconst target = block.resolvedModelRefs?.[\"target\"];\n\tassertDefined(target, `lowerRlsPolicyFromBlock: policy \"${block.name}\" reached the factory without a projected \\`target\\` coordinate; the interpreter projects checked model references before invoking entity factories.`);\n\tconst roles = block.values.roles === void 0 ? [] : block.values.roles.map((role) => typeof role === \"string\" ? role : role.declaration.name).sort();\n\tconst using = block.values.using;\n\tconst withCheck = block.values.withCheck;\n\tconst permissive = block.values.permissive ?? true;\n\tconst mapAttr = block.attributes[\"map\"];\n\tif (mapAttr !== void 0) {\n\t\tconst exactName = mapAttr.args[\"name\"];\n\t\tinvariant(typeof exactName === \"string\", \"@@map on a policy block parses one string argument\");\n\t\tctx.warnings?.push(exactNameBodyWarning(\"policy\", exactName));\n\t\treturn new PostgresRlsPolicy({\n\t\t\tnaming: {\n\t\t\t\tkind: \"exact\",\n\t\t\t\tname: exactName\n\t\t\t},\n\t\t\ttableName: target.tableName,\n\t\t\tnamespaceId: target.namespaceId,\n\t\t\toperation,\n\t\t\troles,\n\t\t\tusing,\n\t\t\twithCheck,\n\t\t\tpermissive\n\t\t});\n\t}\n\treturn buildRlsPolicyEntity({\n\t\tprefix,\n\t\ttableName: target.tableName,\n\t\tnamespaceId: target.namespaceId,\n\t\toperation,\n\t\troles,\n\t\t...ifDefined(\"using\", using),\n\t\t...ifDefined(\"withCheck\", withCheck),\n\t\tpermissive\n\t});\n}\nconst policyEntityTypeOutput = {\n\tfactory: lowerRlsPolicyFromBlock,\n\tpslPlacement: (entity) => ({ namespaceId: entity.namespaceId })\n};\nfunction lowerNativeEnumFromBlock(block, ctx) {\n\tconst sourceId = ctx.sourceId ?? \"unknown\";\n\tconst diagnostics = ctx.diagnostics;\n\tconst mapAttr = block.attributes[\"map\"];\n\tlet typeName = block.name;\n\tif (mapAttr !== void 0) {\n\t\tconst mapped = mapAttr.args[\"name\"];\n\t\tinvariant(typeof mapped === \"string\", \"@@map on a native_enum block parses one string argument\");\n\t\ttypeName = mapped;\n\t}\n\tlet memberError = false;\n\tconst seenValues = /* @__PURE__ */ new Set();\n\tconst members = [];\n\tfor (const [memberName, value] of Object.entries(block.values)) {\n\t\tif (seenValues.has(value)) {\n\t\t\tdiagnostics?.push({\n\t\t\t\tcode: PSL_NATIVE_ENUM_DUPLICATE_MEMBER_VALUE,\n\t\t\t\tmessage: `native_enum \"${block.name}\": duplicate member value \"${value}\"`,\n\t\t\t\tsourceId,\n\t\t\t\tspan: block.parameterSpans[memberName] ?? block.span\n\t\t\t});\n\t\t\tmemberError = true;\n\t\t\tcontinue;\n\t\t}\n\t\tseenValues.add(value);\n\t\tmembers.push(value);\n\t}\n\tif (memberError) return void 0;\n\tif (members.length === 0) {\n\t\tdiagnostics?.push({\n\t\t\tcode: PSL_NATIVE_ENUM_MISSING_MEMBERS,\n\t\t\tmessage: `native_enum \"${block.name}\" must have at least one member`,\n\t\t\tsourceId,\n\t\t\tspan: block.span\n\t\t});\n\t\treturn;\n\t}\n\treturn new PostgresNativeEnum({\n\t\ttypeName,\n\t\tmembers\n\t});\n}\n/**\n* `native_enum`'s entity-type factory output, checked separately from the assembled\n* `postgresAuthoringEntityTypes` map below: `deriveValueSet` is SQL-family surface\n* ({@link SqlValueSetDerivingEntityTypeOutput}), not part of the framework\n* `AuthoringEntityTypeFactoryOutput` shape, so folding it directly into the map's single\n* `satisfies AuthoringEntityTypeNamespace` check would trip an excess-property error. Checking it\n* here against the intersection of both shapes keeps it structurally valid against each without\n* widening the map's own check.\n*/\nconst nativeEnumEntityTypeOutput = {\n\tfactory: lowerNativeEnumFromBlock,\n\tderiveValueSet: (entity) => ({\n\t\tkind: \"valueSet\",\n\t\tvalues: [...entity.members]\n\t})\n};\n/**\n* Lowers a `role <name> {}` block into a {@link PostgresRole}. Roles are\n* cluster-scoped in Postgres, so the block must be declared inside\n* `namespace unbound { … }` — any other lexical namespace (a named schema,\n* or the default bucket top-level declarations resolve to) is a load-time\n* diagnostic. The lowered entity carries the unbound coordinate.\n*/\nfunction lowerRoleFromBlock(block, ctx) {\n\tif (block.namespaceId !== UNBOUND_NAMESPACE_ID) {\n\t\tctx.diagnostics?.push({\n\t\t\tcode: PSL_ROLE_BLOCK_OUTSIDE_UNBOUND_NAMESPACE,\n\t\t\tmessage: `\\`role\\` block \"${block.name}\" must be declared inside \\`namespace unbound { }\\`, not in namespace \"${block.namespaceId}\"`,\n\t\t\tsourceId: ctx.sourceId ?? \"unknown\",\n\t\t\tspan: block.span\n\t\t});\n\t\treturn;\n\t}\n\treturn new PostgresRole({\n\t\tname: block.name,\n\t\tnamespaceId: UNBOUND_NAMESPACE_ID\n\t});\n}\nconst postgresAuthoringEntityTypes = {\n\trole: {\n\t\tkind: \"entity\",\n\t\tdiscriminator: \"role\",\n\t\tvalidatorSchema: PostgresRoleSchema,\n\t\toutput: { factory: lowerRoleFromBlock }\n\t},\n\trls: {\n\t\tkind: \"entity\",\n\t\tdiscriminator: \"rls\",\n\t\tvalidatorSchema: PostgresRlsEnablementSchema,\n\t\toutput: { factory: (input) => new PostgresRlsEnablement(input) }\n\t},\n\tpolicy: {\n\t\tkind: \"entity\",\n\t\tdiscriminator: \"policy\",\n\t\tvalidatorSchema: PostgresRlsPolicySchema,\n\t\toutput: policyEntityTypeOutput\n\t},\n\tnative_enum: {\n\t\tkind: \"entity\",\n\t\tdiscriminator: \"native_enum\",\n\t\tvalidatorSchema: PostgresNativeEnumSchema,\n\t\toutput: nativeEnumEntityTypeOutput\n\t}\n};\n/**\n* Field presets contributed by the Postgres target pack.\n*\n* These mirror the PSL scalar-to-codec mapping used by the Postgres adapter\n* (see `createPostgresPslScalarTypeDescriptors`), so that authoring a field\n* via the TS callback surface (e.g. `field.int()`) and via the PSL scalar\n* surface (e.g. `Int`) lowers to byte-identical contracts.\n*\n* The `uuidNative` / `id.uuidv4Native` / `id.uuidv7Native` presets use the\n* native Postgres `uuid` type (codecId `pg/uuid@1`). For cross-target\n* portability use `uuidString` / `id.uuidv4String` / `id.uuidv7String` from\n* the family pack instead.\n*/\nconst policyRequiresRls = {\n\tparameter: \"target\",\n\tattribute: \"rls\"\n};\nconst policyMapAttribute = blockAttribute(\"map\", {\n\tdocumentation: \"Maps this row-level security policy to its PostgreSQL policy name.\",\n\tpositional: [{\n\t\tkey: \"name\",\n\t\ttype: str(),\n\t\tdocumentation: \"The nonempty PostgreSQL policy name.\"\n\t}],\n\trefine: (parsed, ctx, attributeNode) => parsed.name === \"\" ? [leafDiagnostic(ctx, attributeNode, \"@@map policy name must be a non-empty string\", PSL_POLICY_INVALID_MAP)] : []\n});\nconst policyBlockAttributes = { map: () => policyMapAttribute };\nconst nativeEnumMapAttribute = blockAttribute(\"map\", {\n\tdocumentation: \"Maps this native enum to its PostgreSQL type name.\",\n\tpositional: [{\n\t\tkey: \"name\",\n\t\ttype: str(),\n\t\tdocumentation: \"The PostgreSQL enum type name.\"\n\t}]\n});\nconst postgresAuthoringPslBlockDescriptors = {\n\t[POLICY_BLOCK_KEYWORDS.select]: {\n\t\tkind: \"pslBlock\",\n\t\tkeyword: POLICY_BLOCK_KEYWORDS.select,\n\t\tdocumentation: \"Defines a row-level security policy controlling which rows can be selected.\",\n\t\tdiscriminator: \"policy\",\n\t\tname: { required: true },\n\t\tspec: policyUsingOnlySpec,\n\t\trequiresModelAttribute: policyRequiresRls,\n\t\tattributes: policyBlockAttributes\n\t},\n\t[POLICY_BLOCK_KEYWORDS.delete]: {\n\t\tkind: \"pslBlock\",\n\t\tkeyword: POLICY_BLOCK_KEYWORDS.delete,\n\t\tdocumentation: \"Defines a row-level security policy controlling which rows can be deleted.\",\n\t\tdiscriminator: \"policy\",\n\t\tname: { required: true },\n\t\tspec: policyUsingOnlySpec,\n\t\trequiresModelAttribute: policyRequiresRls,\n\t\tattributes: policyBlockAttributes\n\t},\n\t[POLICY_BLOCK_KEYWORDS.insert]: {\n\t\tkind: \"pslBlock\",\n\t\tkeyword: POLICY_BLOCK_KEYWORDS.insert,\n\t\tdocumentation: \"Defines a row-level security policy checking rows being inserted.\",\n\t\tdiscriminator: \"policy\",\n\t\tname: { required: true },\n\t\tspec: policyWithCheckOnlySpec,\n\t\trequiresModelAttribute: policyRequiresRls,\n\t\tattributes: policyBlockAttributes\n\t},\n\t[POLICY_BLOCK_KEYWORDS.update]: {\n\t\tkind: \"pslBlock\",\n\t\tkeyword: POLICY_BLOCK_KEYWORDS.update,\n\t\tdocumentation: \"Defines a row-level security policy controlling row visibility and checks for updates.\",\n\t\tdiscriminator: \"policy\",\n\t\tname: { required: true },\n\t\tspec: policyBothPredicatesSpec,\n\t\trequiresModelAttribute: policyRequiresRls,\n\t\tattributes: policyBlockAttributes\n\t},\n\t[POLICY_BLOCK_KEYWORDS.all]: {\n\t\tkind: \"pslBlock\",\n\t\tkeyword: POLICY_BLOCK_KEYWORDS.all,\n\t\tdocumentation: \"Defines a row-level security policy applying to all operations.\",\n\t\tdiscriminator: \"policy\",\n\t\tname: { required: true },\n\t\tspec: policyBothPredicatesSpec,\n\t\trequiresModelAttribute: policyRequiresRls,\n\t\tattributes: policyBlockAttributes\n\t},\n\tnative_enum: {\n\t\tkind: \"pslBlock\",\n\t\tkeyword: \"native_enum\",\n\t\tdocumentation: \"Defines a PostgreSQL enum type with named string-valued members.\",\n\t\tdiscriminator: \"native_enum\",\n\t\tname: { required: true },\n\t\tspec: nativeEnumSpec,\n\t\tattributes: { map: () => nativeEnumMapAttribute }\n\t},\n\t/**\n\t* PSL block descriptor for `role` (e.g. `role anon {}`). Name-only, no\n\t* parameters and no body content. Declared inside `namespace unbound { }`\n\t* — see {@link lowerRoleFromBlock} for the placement check and the\n\t* coordinate the lowered entity carries.\n\t*/\n\trole: {\n\t\tkind: \"pslBlock\",\n\t\tkeyword: \"role\",\n\t\tdocumentation: \"Declares an existing database role in namespace unbound for use in security policies.\",\n\t\tdiscriminator: \"role\",\n\t\tname: { required: true },\n\t\tspec: roleSpec\n\t}\n};\nconst postgresRlsSpec = modelAttribute(\"rls\", { documentation: \"Enables PostgreSQL row-level security on this model’s table.\" });\nconst postgresRlsSpecFactory = () => postgresRlsSpec;\nconst [firstLanguage, ...remainingLanguages] = POSTGRES_TEXT_SEARCH_LANGUAGES;\nconst postgresFullTextIndexSpec = modelAttribute(\"fullTextIndex\", {\n\tdocumentation: \"Indexes one text column for full-text search, rendering the expression `fullTextMatches`, `fullTextRank` and `fullTextHeadline` lower to.\",\n\tpositional: [{\n\t\tkey: \"fields\",\n\t\ttype: list(fieldRef(), {\n\t\t\tallowEmpty: false,\n\t\t\tunique: true\n\t\t}),\n\t\tdocumentation: \"The single field to index.\"\n\t}],\n\tnamed: {\n\t\tlanguage: {\n\t\t\ttype: optional(oneOf(str(firstLanguage), ...remainingLanguages.map((language) => str(language)))),\n\t\t\tdocumentation: \"The text-search configuration. Defaults to `english`, and must match the language the query operations are given.\"\n\t\t},\n\t\tname: {\n\t\t\ttype: optional(str()),\n\t\t\tdocumentation: \"The index name. Mutually exclusive with `map`.\"\n\t\t},\n\t\tmap: {\n\t\t\ttype: optional(str()),\n\t\t\tdocumentation: \"The database index name. Mutually exclusive with `name`.\"\n\t\t},\n\t\twhere: {\n\t\t\ttype: optional(str()),\n\t\t\tdocumentation: \"The SQL predicate restricting rows included in a partial index.\"\n\t\t}\n\t},\n\trefine: (value, ctx, attributeNode) => {\n\t\tconst diagnostics = [];\n\t\tif (value.fields.length !== 1) diagnostics.push(leafDiagnostic(ctx, attributeNode, \"The full-text operations work on one column; declare one `@@fullTextIndex` per column\", PSL_FULL_TEXT_INDEX_ONE_FIELD));\n\t\tif (value.name === void 0 && value.map === void 0) diagnostics.push(leafDiagnostic(ctx, attributeNode, \"`@@fullTextIndex` requires a `name` or `map` argument (a default name cannot be derived from an expression)\", PSL_FULL_TEXT_INDEX_REQUIRES_NAME));\n\t\tif (value.name !== void 0 && value.map !== void 0) diagnostics.push(leafDiagnostic(ctx, attributeNode, \"`@@fullTextIndex` takes at most one of `name` and `map`\", PSL_FULL_TEXT_INDEX_NAME_XOR_MAP));\n\t\treturn diagnostics;\n\t}\n});\nconst postgresFullTextIndexSpecFactory = () => postgresFullTextIndexSpec;\n/**\n* `@@` model attributes contributed by the Postgres target pack.\n*\n* `@@rls` is argument-less: presence marks the model's table\n* RLS-controlled. It lowers to a {@link PostgresRlsEnablement} marker in\n* the namespace's `entries.rls`, keyed by the model's table name — the\n* marker (never the policy set) is what drives\n* `ENABLE`/`DISABLE ROW LEVEL SECURITY` planning.\n*/\nconst postgresAuthoringModelAttributes = {\n\trls: {\n\t\tkind: \"modelAttribute\",\n\t\tattribute: \"rls\",\n\t\tspec: postgresRlsSpecFactory,\n\t\tlower: (_parsed, ctx) => ({\n\t\t\tkey: ctx.storageName,\n\t\t\tentity: new PostgresRlsEnablement({\n\t\t\t\ttableName: ctx.storageName,\n\t\t\t\tnamespaceId: ctx.namespaceId\n\t\t\t})\n\t\t})\n\t},\n\tfullTextIndex: {\n\t\tkind: \"modelAttribute\",\n\t\tattribute: \"fullTextIndex\",\n\t\tspec: postgresFullTextIndexSpecFactory,\n\t\trepeatable: true,\n\t\tlower: (parsed, ctx) => {\n\t\t\tconst fieldName = parsed.fields[0];\n\t\t\tinvariant(fieldName !== void 0 && parsed.fields.length === 1, `@@fullTextIndex on \"${ctx.modelName}\" lowered with ${parsed.fields.length} fields`);\n\t\t\tconst columnName = ctx.fieldStorageName(fieldName);\n\t\t\tconst codecId = ctx.fieldCodecId(fieldName);\n\t\t\tif (columnName === void 0 || codecId === void 0 || !isFullTextIndexableCodec(codecId)) {\n\t\t\t\tctx.diagnostics?.push({\n\t\t\t\t\tcode: PSL_FULL_TEXT_INDEX_TEXT_FIELD,\n\t\t\t\t\tmessage: `\\`@@fullTextIndex\\` indexes a text column, but \"${ctx.modelName}.${fieldName}\" is ${codecId === void 0 ? \"not a stored scalar field\" : `stored as \\`${codecId}\\``}.`,\n\t\t\t\t\tsourceId: ctx.sourceId ?? \"unknown\"\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\t\t\treturn { index: {\n\t\t\t\texpression: renderFullTextIndexExpression(parsed.language ?? \"english\", columnName),\n\t\t\t\ttype: \"gin\",\n\t\t\t\toptions: void 0,\n\t\t\t\twhere: parsed.where,\n\t\t\t\tunique: void 0,\n\t\t\t\tname: parsed.name,\n\t\t\t\tmap: parsed.map\n\t\t\t} };\n\t\t}\n\t}\n};\nconst postgresAuthoringFieldPresets = {\n\ttext: {\n\t\tkind: \"fieldPreset\",\n\t\toutput: {\n\t\t\tcodecId: \"pg/text@1\",\n\t\t\tnativeType: \"text\"\n\t\t}\n\t},\n\tint: {\n\t\tkind: \"fieldPreset\",\n\t\toutput: {\n\t\t\tcodecId: \"pg/int4@1\",\n\t\t\tnativeType: \"int4\"\n\t\t}\n\t},\n\tbigint: {\n\t\tkind: \"fieldPreset\",\n\t\toutput: {\n\t\t\tcodecId: \"pg/int8@1\",\n\t\t\tnativeType: \"int8\"\n\t\t}\n\t},\n\tfloat: {\n\t\tkind: \"fieldPreset\",\n\t\toutput: {\n\t\t\tcodecId: \"pg/float8@1\",\n\t\t\tnativeType: \"float8\"\n\t\t}\n\t},\n\tdecimal: {\n\t\tkind: \"fieldPreset\",\n\t\toutput: {\n\t\t\tcodecId: \"pg/numeric@1\",\n\t\t\tnativeType: \"numeric\"\n\t\t}\n\t},\n\tboolean: {\n\t\tkind: \"fieldPreset\",\n\t\toutput: {\n\t\t\tcodecId: \"pg/bool@1\",\n\t\t\tnativeType: \"bool\"\n\t\t}\n\t},\n\tjson: {\n\t\tkind: \"fieldPreset\",\n\t\toutput: {\n\t\t\tcodecId: \"pg/jsonb@1\",\n\t\t\tnativeType: \"jsonb\"\n\t\t}\n\t},\n\tbytes: {\n\t\tkind: \"fieldPreset\",\n\t\toutput: {\n\t\t\tcodecId: \"pg/bytea@1\",\n\t\t\tnativeType: \"bytea\"\n\t\t}\n\t},\n\tdateTime: {\n\t\tkind: \"fieldPreset\",\n\t\toutput: {\n\t\t\tcodecId: \"pg/timestamptz-temporal@1\",\n\t\t\tnativeType: \"timestamptz\"\n\t\t}\n\t},\n\ttemporal: {\n\t\tcreatedAtJsDate: (/* @__PURE__ */ temporalAuthoringPresets({\n\t\t\tcodecId: PG_TIMESTAMPTZ_DATE_CODEC_ID,\n\t\t\tnativeType: \"timestamptz\",\n\t\t\tgeneratorId: postgresNowGeneratorIds[PG_TIMESTAMPTZ_DATE_CODEC_ID]\n\t\t})).createdAt,\n\t\tupdatedAtJsDate: (/* @__PURE__ */ temporalAuthoringPresets({\n\t\t\tcodecId: PG_TIMESTAMPTZ_DATE_CODEC_ID,\n\t\t\tnativeType: \"timestamptz\",\n\t\t\tgeneratorId: postgresNowGeneratorIds[PG_TIMESTAMPTZ_DATE_CODEC_ID]\n\t\t})).updatedAt,\n\t\ttimestamptzJsDate: /* @__PURE__ */ temporalCodecPresetWithPrecision({\n\t\t\tcodecId: PG_TIMESTAMPTZ_DATE_CODEC_ID,\n\t\t\tnativeType: \"timestamptz\",\n\t\t\tgeneratorId: postgresNowGeneratorIds[PG_TIMESTAMPTZ_DATE_CODEC_ID]\n\t\t}),\n\t\t.../* @__PURE__ */ temporalAuthoringPresets({\n\t\t\tcodecId: PG_TIMESTAMPTZ_TEMPORAL_CODEC_ID,\n\t\t\tnativeType: \"timestamptz\",\n\t\t\tgeneratorId: postgresNowGeneratorIds[PG_TIMESTAMPTZ_TEMPORAL_CODEC_ID]\n\t\t}),\n\t\t.../* @__PURE__ */ temporalStringAuthoringPresets({\n\t\t\tcodecId: PG_TIMESTAMPTZ_STRING_CODEC_ID,\n\t\t\tnativeType: \"timestamptz\",\n\t\t\tgeneratorId: postgresNowGeneratorIds[PG_TIMESTAMPTZ_STRING_CODEC_ID]\n\t\t}),\n\t\ttimestamp: /* @__PURE__ */ temporalCodecPresetWithPrecision({\n\t\t\tcodecId: PG_TIMESTAMP_TEMPORAL_CODEC_ID,\n\t\t\tnativeType: \"timestamp\",\n\t\t\tgeneratorId: postgresNowGeneratorIds[PG_TIMESTAMP_TEMPORAL_CODEC_ID]\n\t\t}),\n\t\ttimestamptz: /* @__PURE__ */ temporalCodecPresetWithPrecision({\n\t\t\tcodecId: PG_TIMESTAMPTZ_TEMPORAL_CODEC_ID,\n\t\t\tnativeType: \"timestamptz\",\n\t\t\tgeneratorId: postgresNowGeneratorIds[PG_TIMESTAMPTZ_TEMPORAL_CODEC_ID]\n\t\t}),\n\t\ttimestampString: /* @__PURE__ */ temporalCodecPresetWithPrecision({\n\t\t\tcodecId: PG_TIMESTAMP_STRING_CODEC_ID,\n\t\t\tnativeType: \"timestamp\",\n\t\t\tgeneratorId: postgresNowGeneratorIds[PG_TIMESTAMP_STRING_CODEC_ID]\n\t\t}),\n\t\ttimestamptzString: /* @__PURE__ */ temporalCodecPresetWithPrecision({\n\t\t\tcodecId: PG_TIMESTAMPTZ_STRING_CODEC_ID,\n\t\t\tnativeType: \"timestamptz\",\n\t\t\tgeneratorId: postgresNowGeneratorIds[PG_TIMESTAMPTZ_STRING_CODEC_ID]\n\t\t})\n\t},\n\tuuidNative: {\n\t\tkind: \"fieldPreset\",\n\t\toutput: {\n\t\t\tcodecId: \"pg/uuid@1\",\n\t\t\tnativeType: \"uuid\"\n\t\t}\n\t},\n\tid: {\n\t\tuuidv4Native: {\n\t\t\tkind: \"fieldPreset\",\n\t\t\toutput: {\n\t\t\t\tcodecId: \"pg/uuid@1\",\n\t\t\t\tnativeType: \"uuid\",\n\t\t\t\texecutionDefaults: { onCreate: {\n\t\t\t\t\tkind: \"generator\",\n\t\t\t\t\tid: \"uuidv4\"\n\t\t\t\t} },\n\t\t\t\tid: true\n\t\t\t}\n\t\t},\n\t\tuuidv7Native: {\n\t\t\tkind: \"fieldPreset\",\n\t\t\toutput: {\n\t\t\t\tcodecId: \"pg/uuid@1\",\n\t\t\t\tnativeType: \"uuid\",\n\t\t\t\texecutionDefaults: { onCreate: {\n\t\t\t\t\tkind: \"generator\",\n\t\t\t\t\tid: \"uuidv7\"\n\t\t\t\t} },\n\t\t\t\tid: true\n\t\t\t}\n\t\t}\n\t}\n};\n/**\n* Resolves an entity handle's `target` ref to a table coordinate of this\n* contract, or throws the load-time diagnostic naming the handle: a\n* cross-space target is rejected (you cannot CREATE POLICY on a table\n* another space owns) and an unresolved target names the model.\n*/\nfunction requireLocalTarget(refs, subject) {\n\tconst target = refs[\"target\"];\n\tif (target !== void 0 && target.kind === \"resolved\") return {\n\t\tnamespaceId: target.namespaceId,\n\t\ttableName: target.tableName\n\t};\n\tif (target !== void 0 && target.kind === \"cross-space\") throw postgresError(\"CONTRACT.POLICY_INVALID\", `defineContract: ${subject} targets model \"${target.modelName ?? target.tableName}\", which lives in another contract space. Policies and rlsEnabled entries must target a model declared in this contract.`, { meta: {\n\t\tmodel: target.modelName ?? target.tableName,\n\t\treason: \"cross-space-target\"\n\t} });\n\tthrow postgresError(\"CONTRACT.MODEL_UNKNOWN\", `defineContract: ${subject} targets model \"${target?.modelName ?? \"<anonymous>\"}\", which is not in the contract's models. Add the model to \\`models\\`.`, { meta: { model: target?.modelName ?? \"<anonymous>\" } });\n}\n/**\n* The SQL-family entity-handle batch lowering hook for the Postgres pack\n* (`SqlEntityHandleLoweringContribution`). Receives every `entities` handle\n* whose kind this pack registered — batch, so the cross-entity diagnostics\n* (duplicate prefix, policy without rlsEnabled, duplicate role) can see\n* sibling handles — and lowers them with the same keying and hash assembly\n* as the PSL path: `policy` keyed by prefix (wire name via\n* {@link buildRlsPolicyEntity}), `rls` keyed by table name, `role` keyed by\n* name and filed under the default namespace (roles are declared\n* contract-wide; PSL has no role block to set a precedent).\n*/\nfunction postgresLowerEntityHandles(input) {\n\tconst enablements = /* @__PURE__ */ new Map();\n\tconst roles = /* @__PURE__ */ new Map();\n\tconst policies = [];\n\tconst coordinateKey = (coordinate) => `${coordinate.namespaceId} ${coordinate.tableName}`;\n\tfor (const { handle, refs } of input.handles) switch (handle.entityKind) {\n\t\tcase \"rls\": {\n\t\t\tconst coordinate = requireLocalTarget(refs, \"an rlsEnabled entry\");\n\t\t\tconst key = coordinateKey(coordinate);\n\t\t\tif (!enablements.has(key)) enablements.set(key, {\n\t\t\t\tcoordinate,\n\t\t\t\tentity: new PostgresRlsEnablement({\n\t\t\t\t\ttableName: coordinate.tableName,\n\t\t\t\t\tnamespaceId: coordinate.namespaceId\n\t\t\t\t})\n\t\t\t});\n\t\t\tbreak;\n\t\t}\n\t\tcase \"role\": {\n\t\t\tconst roleHandle = blindCast(handle);\n\t\t\tif (roles.has(roleHandle.name)) throw postgresError(\"CONTRACT.ROLE_INVALID\", `defineContract: role \"${roleHandle.name}\" is declared more than once in the entities list.`, { meta: {\n\t\t\t\trole: roleHandle.name,\n\t\t\t\treason: \"duplicate\"\n\t\t\t} });\n\t\t\troles.set(roleHandle.name, new PostgresRole({\n\t\t\t\tname: roleHandle.name,\n\t\t\t\tnamespaceId: UNBOUND_NAMESPACE_ID\n\t\t\t}));\n\t\t\tbreak;\n\t\t}\n\t\tcase \"policy\": {\n\t\t\tconst policyHandle = blindCast(handle);\n\t\t\tpolicies.push({\n\t\t\t\thandle: policyHandle,\n\t\t\t\trefs\n\t\t\t});\n\t\t\tbreak;\n\t\t}\n\t\tdefault: throw postgresError(\"CONTRACT.ENTITY_KIND_INVALID\", `defineContract: the postgres pack does not lower \"${handle.entityKind}\" handles from the entities list.`, { meta: { entityKind: handle.entityKind } });\n\t}\n\tconst rows = [];\n\tconst seenPrefixes = /* @__PURE__ */ new Set();\n\tfor (const { handle: policy, refs } of policies) {\n\t\tconst prefix = policy.name;\n\t\tassertWireNamePrefixLength(prefix, \"defineContract: policy prefix\");\n\t\tconst coordinate = requireLocalTarget(refs, `policy \"${prefix}\"`);\n\t\tif (!enablements.has(coordinateKey(coordinate))) {\n\t\t\tconst target = refs[\"target\"];\n\t\t\tthrow postgresError(\"CONTRACT.POLICY_INVALID\", `defineContract: policy \"${prefix}\" targets model \"${target?.modelName ?? coordinate.tableName}\", whose table is not RLS-enabled. Add rlsEnabled(<model>) to the entities list.`, { meta: {\n\t\t\t\tprefix,\n\t\t\t\tmodel: target?.modelName ?? coordinate.tableName,\n\t\t\t\treason: \"target-not-rls-enabled\"\n\t\t\t} });\n\t\t}\n\t\tconst prefixKey = `${coordinate.namespaceId} ${prefix}`;\n\t\tif (seenPrefixes.has(prefixKey)) throw postgresError(\"CONTRACT.POLICY_INVALID\", `defineContract: policy prefix \"${prefix}\" is declared more than once in namespace \"${coordinate.namespaceId}\". Policy prefixes must be unique per namespace.`, { meta: {\n\t\t\tprefix,\n\t\t\tnamespaceId: coordinate.namespaceId,\n\t\t\treason: \"duplicate-prefix\"\n\t\t} });\n\t\tseenPrefixes.add(prefixKey);\n\t\tconst roleNames = [...new Set(policy.roles.map((roleHandle) => roleHandle.name))].sort();\n\t\trows.push({\n\t\t\tnamespaceId: coordinate.namespaceId,\n\t\t\tentityKind: \"policy\",\n\t\t\tkey: prefix,\n\t\t\tentity: buildRlsPolicyEntity({\n\t\t\t\tprefix,\n\t\t\t\ttableName: coordinate.tableName,\n\t\t\t\tnamespaceId: coordinate.namespaceId,\n\t\t\t\toperation: policy.operation,\n\t\t\t\troles: roleNames,\n\t\t\t\t...ifDefined(\"using\", policy.using),\n\t\t\t\t...ifDefined(\"withCheck\", policy.withCheck)\n\t\t\t})\n\t\t});\n\t}\n\tfor (const { coordinate, entity } of enablements.values()) rows.push({\n\t\tnamespaceId: coordinate.namespaceId,\n\t\tentityKind: \"rls\",\n\t\tkey: coordinate.tableName,\n\t\tentity\n\t});\n\tfor (const [name, entity] of roles) rows.push({\n\t\tnamespaceId: UNBOUND_NAMESPACE_ID,\n\t\tentityKind: \"role\",\n\t\tkey: name,\n\t\tentity\n\t});\n\treturn rows;\n}\n//#endregion\nexport { postgresAuthoringPslBlockDescriptors as a, postgresNowGeneratorIdFor as c, plainDateTimeNowControlDescriptor as d, INSTANT_NOW_GENERATOR_ID as f, postgresAuthoringModelAttributes as i, PLAIN_DATE_TIME_NOW_GENERATOR_ID as l, instantNowControlDescriptor as m, postgresAuthoringEntityTypes as n, postgresAuthoringTypes as o, instantNow as p, postgresAuthoringFieldPresets as r, postgresLowerEntityHandles as s, POLICY_BLOCK_KEYWORDS as t, plainDateTimeNow as u };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