@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.
@@ -45,6 +45,10 @@ type PolicyNode = {
45
45
  kind: 'role';
46
46
  key: string;
47
47
  }
48
+ /** Verified machine identity, independent of role or subject spelling. */
49
+ | {
50
+ kind: 'servicePrincipal';
51
+ }
48
52
  /** `exists(<link-path>, <pred>)` — the inner predicate runs against the final target. */
49
53
  | {
50
54
  kind: 'exists';
@@ -45,6 +45,10 @@ type PolicyNode = {
45
45
  kind: 'role';
46
46
  key: string;
47
47
  }
48
+ /** Verified machine identity, independent of role or subject spelling. */
49
+ | {
50
+ kind: 'servicePrincipal';
51
+ }
48
52
  /** `exists(<link-path>, <pred>)` — the inner predicate runs against the final target. */
49
53
  | {
50
54
  kind: 'exists';
@@ -1101,8 +1101,15 @@ var GUARDED_IR_VERSION = 2;
1101
1101
  var COMPOSED_IR_VERSION = 3;
1102
1102
  var SQL_IR_VERSION = 4;
1103
1103
  var RUNTIME_SQL_IR_VERSION = 5;
1104
- var irVersionSchema = z.union([z.literal(LEGACY_IR_VERSION), z.literal(GUARDED_IR_VERSION), z.literal(COMPOSED_IR_VERSION), z.literal(SQL_IR_VERSION), z.literal(RUNTIME_SQL_IR_VERSION)]);
1104
+ var SERVICE_PRINCIPAL_IR_VERSION = 6;
1105
+ var irVersionSchema = z.union([z.literal(LEGACY_IR_VERSION), z.literal(GUARDED_IR_VERSION), z.literal(COMPOSED_IR_VERSION), z.literal(SQL_IR_VERSION), z.literal(RUNTIME_SQL_IR_VERSION), z.literal(SERVICE_PRINCIPAL_IR_VERSION)]);
1105
1106
  z.object({ irVersion: irVersionSchema });
1107
+ function usesServicePrincipal(value) {
1108
+ if (value === null || typeof value !== "object") return false;
1109
+ if (Array.isArray(value)) return value.some(usesServicePrincipal);
1110
+ const row = value;
1111
+ return row.kind === "servicePrincipal" || Object.values(row).some(usesServicePrincipal);
1112
+ }
1106
1113
  var CLAIMS_CONTRACT = {
1107
1114
  sub: "string",
1108
1115
  org: "string?",
@@ -1154,6 +1161,7 @@ var predIrSchema = z.lazy(
1154
1161
  z.object({ kind: z.literal("capability"), key: z.string(), namespace: z.string().optional() }),
1155
1162
  z.object({ kind: z.literal("role"), key: z.string(), namespace: z.string().optional() }),
1156
1163
  z.object({ kind: z.literal("dynamicFilter"), slot: z.string() }),
1164
+ z.object({ kind: z.literal("servicePrincipal") }).strict(),
1157
1165
  z.object({ kind: z.literal("const"), value: z.boolean() })
1158
1166
  ])
1159
1167
  );
@@ -1379,7 +1387,7 @@ var variableIrSchema = z.object({
1379
1387
  /** Absent = no default declared; see {@link variableDefaultIrSchema}. */
1380
1388
  defaultValue: variableDefaultIrSchema.optional()
1381
1389
  });
1382
- var sqlColumnSchema = z.object({ name: z.string(), type: z.enum(["text", "boolean", "integer", "bigint", "numeric", "double", "uuid", "date", "timestamptz"]), nullable: z.boolean() });
1390
+ var sqlColumnSchema = z.object({ name: z.string(), type: z.enum(["text", "boolean", "integer", "bigint", "numeric", "double", "uuid", "date", "timestamptz", "jsonb"]), nullable: z.boolean() });
1383
1391
  var compiledOperationSchema = z.object({
1384
1392
  language: z.literal("sql").optional(),
1385
1393
  /** Server-compiled object catalog and permission ceiling, never caller SQL. */
@@ -1417,6 +1425,9 @@ var compiledOperationSchema = z.object({
1417
1425
  tableSet: z.array(z.string()).min(1),
1418
1426
  roots: z.array(rootIrSchema)
1419
1427
  }).superRefine((operation, ctx) => {
1428
+ if (operation.irVersion < SERVICE_PRINCIPAL_IR_VERSION && usesServicePrincipal(operation.roots)) {
1429
+ ctx.addIssue({ code: "custom", message: "servicePrincipal() requires IR v6" });
1430
+ }
1420
1431
  if (operation.language === "sql") {
1421
1432
  const validPlan = operation.sqlQuery ? !operation.sql && operation.irVersion === RUNTIME_SQL_IR_VERSION : !!operation.sql && operation.irVersion === SQL_IR_VERSION;
1422
1433
  const builtin = operation.name === "BuiltinSqlRead" && operation.opHash === BUILTIN_SQL_READ_HASH && operation.requires === null;
@@ -1549,6 +1560,9 @@ z.object({
1549
1560
  tables: z.record(z.string(), tableMetaIrSchema),
1550
1561
  operations: z.record(z.string(), compiledOperationSchema)
1551
1562
  }).superRefine((artifact, ctx) => {
1563
+ if (artifact.irVersion < SERVICE_PRINCIPAL_IR_VERSION && usesServicePrincipal(artifact)) {
1564
+ ctx.addIssue({ code: "custom", message: "servicePrincipal() requires IR v6" });
1565
+ }
1552
1566
  if (Object.keys(artifact.dependencies ?? {}).length > 0 && artifact.irVersion < COMPOSED_IR_VERSION) {
1553
1567
  ctx.addIssue({ code: "custom", path: ["irVersion"], message: "cross-namespace dependencies require IR v3" });
1554
1568
  }
@@ -1690,6 +1704,12 @@ var Parser2 = class {
1690
1704
  }
1691
1705
  return node;
1692
1706
  }
1707
+ if (this.peekKeyword("servicePrincipal") && this.tokens[this.index + 1]?.kind === "lparen") {
1708
+ this.advance();
1709
+ this.expect("lparen", "'(' after servicePrincipal");
1710
+ this.expect("rparen", "')' closing servicePrincipal()");
1711
+ return { kind: "servicePrincipal" };
1712
+ }
1693
1713
  if (this.peekKeyword("exists")) return this.parseExists();
1694
1714
  if (this.peekKeyword("visible") && this.tokens[this.index + 1]?.kind === "lparen") return this.parseVisible();
1695
1715
  return this.parseComparison();
@@ -1902,6 +1922,8 @@ var PolicyCompiler = class _PolicyCompiler {
1902
1922
  return { kind: "capability", key: node.key };
1903
1923
  case "role":
1904
1924
  return { kind: "role", key: node.key };
1925
+ case "servicePrincipal":
1926
+ return { kind: "servicePrincipal" };
1905
1927
  case "exists":
1906
1928
  return this.compileExists(node.path, node.where, table, depth);
1907
1929
  case "visible":