@sequenceholdings/orm 2.6.2 → 2.7.1

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.
@@ -1103,8 +1103,15 @@ var GUARDED_IR_VERSION = 2;
1103
1103
  var COMPOSED_IR_VERSION = 3;
1104
1104
  var SQL_IR_VERSION = 4;
1105
1105
  var RUNTIME_SQL_IR_VERSION = 5;
1106
- var irVersionSchema = zod.z.union([zod.z.literal(LEGACY_IR_VERSION), zod.z.literal(GUARDED_IR_VERSION), zod.z.literal(COMPOSED_IR_VERSION), zod.z.literal(SQL_IR_VERSION), zod.z.literal(RUNTIME_SQL_IR_VERSION)]);
1106
+ var SERVICE_PRINCIPAL_IR_VERSION = 6;
1107
+ var irVersionSchema = zod.z.union([zod.z.literal(LEGACY_IR_VERSION), zod.z.literal(GUARDED_IR_VERSION), zod.z.literal(COMPOSED_IR_VERSION), zod.z.literal(SQL_IR_VERSION), zod.z.literal(RUNTIME_SQL_IR_VERSION), zod.z.literal(SERVICE_PRINCIPAL_IR_VERSION)]);
1107
1108
  zod.z.object({ irVersion: irVersionSchema });
1109
+ function usesServicePrincipal(value) {
1110
+ if (value === null || typeof value !== "object") return false;
1111
+ if (Array.isArray(value)) return value.some(usesServicePrincipal);
1112
+ const row = value;
1113
+ return row.kind === "servicePrincipal" || Object.values(row).some(usesServicePrincipal);
1114
+ }
1108
1115
  var CLAIMS_CONTRACT = {
1109
1116
  sub: "string",
1110
1117
  org: "string?",
@@ -1156,6 +1163,7 @@ var predIrSchema = zod.z.lazy(
1156
1163
  zod.z.object({ kind: zod.z.literal("capability"), key: zod.z.string(), namespace: zod.z.string().optional() }),
1157
1164
  zod.z.object({ kind: zod.z.literal("role"), key: zod.z.string(), namespace: zod.z.string().optional() }),
1158
1165
  zod.z.object({ kind: zod.z.literal("dynamicFilter"), slot: zod.z.string() }),
1166
+ zod.z.object({ kind: zod.z.literal("servicePrincipal") }).strict(),
1159
1167
  zod.z.object({ kind: zod.z.literal("const"), value: zod.z.boolean() })
1160
1168
  ])
1161
1169
  );
@@ -1381,7 +1389,7 @@ var variableIrSchema = zod.z.object({
1381
1389
  /** Absent = no default declared; see {@link variableDefaultIrSchema}. */
1382
1390
  defaultValue: variableDefaultIrSchema.optional()
1383
1391
  });
1384
- var sqlColumnSchema = zod.z.object({ name: zod.z.string(), type: zod.z.enum(["text", "boolean", "integer", "bigint", "numeric", "double", "uuid", "date", "timestamptz"]), nullable: zod.z.boolean() });
1392
+ var sqlColumnSchema = zod.z.object({ name: zod.z.string(), type: zod.z.enum(["text", "boolean", "integer", "bigint", "numeric", "double", "uuid", "date", "timestamptz", "jsonb"]), nullable: zod.z.boolean() });
1385
1393
  var compiledOperationSchema = zod.z.object({
1386
1394
  language: zod.z.literal("sql").optional(),
1387
1395
  /** Server-compiled object catalog and permission ceiling, never caller SQL. */
@@ -1419,6 +1427,9 @@ var compiledOperationSchema = zod.z.object({
1419
1427
  tableSet: zod.z.array(zod.z.string()).min(1),
1420
1428
  roots: zod.z.array(rootIrSchema)
1421
1429
  }).superRefine((operation, ctx) => {
1430
+ if (operation.irVersion < SERVICE_PRINCIPAL_IR_VERSION && usesServicePrincipal(operation.roots)) {
1431
+ ctx.addIssue({ code: "custom", message: "servicePrincipal() requires IR v6" });
1432
+ }
1422
1433
  if (operation.language === "sql") {
1423
1434
  const validPlan = operation.sqlQuery ? !operation.sql && operation.irVersion === RUNTIME_SQL_IR_VERSION : !!operation.sql && operation.irVersion === SQL_IR_VERSION;
1424
1435
  const builtin = operation.name === "BuiltinSqlRead" && operation.opHash === BUILTIN_SQL_READ_HASH && operation.requires === null;
@@ -1551,6 +1562,9 @@ zod.z.object({
1551
1562
  tables: zod.z.record(zod.z.string(), tableMetaIrSchema),
1552
1563
  operations: zod.z.record(zod.z.string(), compiledOperationSchema)
1553
1564
  }).superRefine((artifact, ctx) => {
1565
+ if (artifact.irVersion < SERVICE_PRINCIPAL_IR_VERSION && usesServicePrincipal(artifact)) {
1566
+ ctx.addIssue({ code: "custom", message: "servicePrincipal() requires IR v6" });
1567
+ }
1554
1568
  if (Object.keys(artifact.dependencies ?? {}).length > 0 && artifact.irVersion < COMPOSED_IR_VERSION) {
1555
1569
  ctx.addIssue({ code: "custom", path: ["irVersion"], message: "cross-namespace dependencies require IR v3" });
1556
1570
  }
@@ -1692,6 +1706,12 @@ var Parser2 = class {
1692
1706
  }
1693
1707
  return node;
1694
1708
  }
1709
+ if (this.peekKeyword("servicePrincipal") && this.tokens[this.index + 1]?.kind === "lparen") {
1710
+ this.advance();
1711
+ this.expect("lparen", "'(' after servicePrincipal");
1712
+ this.expect("rparen", "')' closing servicePrincipal()");
1713
+ return { kind: "servicePrincipal" };
1714
+ }
1695
1715
  if (this.peekKeyword("exists")) return this.parseExists();
1696
1716
  if (this.peekKeyword("visible") && this.tokens[this.index + 1]?.kind === "lparen") return this.parseVisible();
1697
1717
  return this.parseComparison();
@@ -1904,6 +1924,8 @@ var PolicyCompiler = class _PolicyCompiler {
1904
1924
  return { kind: "capability", key: node.key };
1905
1925
  case "role":
1906
1926
  return { kind: "role", key: node.key };
1927
+ case "servicePrincipal":
1928
+ return { kind: "servicePrincipal" };
1907
1929
  case "exists":
1908
1930
  return this.compileExists(node.path, node.where, table, depth);
1909
1931
  case "visible":