@sequenceholdings/orm 2.7.1 → 2.8.2

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/dist/sdl.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var zod = require('zod');
4
- var crypto = require('crypto');
4
+ require('crypto');
5
5
 
6
6
  // src/canonical/v2.ts
7
7
  var quoteIdentifier = (name) => `"${name.replaceAll('"', '""')}"`;
@@ -1802,7 +1802,7 @@ var PLATFORM_USER_FIELDS = [
1802
1802
  ];
1803
1803
  function generateSdl(canonical, options = {}) {
1804
1804
  const def = composeNamespace(normalizeCanonical(canonicalDefinitionSchema.parse(canonical))).definition;
1805
- const exposed = canonicalRelations(def).filter((table) => table.source === void 0 && table.internal !== true);
1805
+ const exposed = canonicalRelations(def).filter((table) => table.internal !== true && (table.source === void 0 || options.includeSyncedReads === true && (table.primaryKey?.length ?? 0) > 0));
1806
1806
  const cellsByTable = new Map(exposed.map((table) => [table.table, trackedCells(table)]));
1807
1807
  const tables = exposed.map((table) => ({ ...table, columns: table.columns.filter((column) => column.cell === void 0) }));
1808
1808
  if (tables.length === 0) {
@@ -2112,10 +2112,10 @@ function renderResolvedMutationFields(table, names) {
2112
2112
  return lines;
2113
2113
  }
2114
2114
  function allowsInsert(table) {
2115
- return table.policies.write !== void 0 || table.policies.insert !== void 0;
2115
+ return table.source === void 0 && (table.policies.write !== void 0 || table.policies.insert !== void 0);
2116
2116
  }
2117
2117
  function allowsUpdate(table) {
2118
- return table.policies.write !== void 0 || table.policies.update !== void 0;
2118
+ return table.source === void 0 && (table.policies.write !== void 0 || table.policies.update !== void 0);
2119
2119
  }
2120
2120
  function allowsOnConflict(table) {
2121
2121
  if (!allowsInsert(table) || !allowsUpdate(table)) return false;
@@ -2459,29 +2459,23 @@ var CodegenGqlError = class extends Error {
2459
2459
  };
2460
2460
 
2461
2461
  // src/codegen-gql/manifest.ts
2462
- var MANIFEST_VERSION = 1;
2463
- var OP_HASH_RE = /^sha256:[0-9a-f]{64}$/;
2462
+ var MANIFEST_VERSION = 2;
2464
2463
  var GRAPHQL_NAME_RE2 = /^[_A-Za-z][_0-9A-Za-z]*$/;
2465
2464
  var manifestRequiresSchema = zod.z.object({
2466
2465
  capability: zod.z.string().min(1).optional(),
2467
2466
  role: zod.z.string().min(1).optional()
2468
2467
  }).nullable();
2469
2468
  var manifestOperationSchema = zod.z.object({
2470
- hash: zod.z.string().regex(OP_HASH_RE),
2471
2469
  kind: zod.z.enum(["query", "mutation"]),
2472
2470
  requires: manifestRequiresSchema
2473
2471
  });
2474
2472
  var operationsManifestSchema = zod.z.object({
2475
- manifestVersion: zod.z.literal(MANIFEST_VERSION),
2476
- schemaHash: zod.z.string().min(1),
2477
- opsHash: zod.z.string().regex(OP_HASH_RE),
2473
+ manifestVersion: zod.z.union([zod.z.literal(1), zod.z.literal(MANIFEST_VERSION)]),
2478
2474
  operations: zod.z.record(zod.z.string().regex(GRAPHQL_NAME_RE2), manifestOperationSchema)
2479
2475
  });
2480
2476
  function buildOperationsManifest({
2481
- schemaHash,
2482
2477
  operations
2483
2478
  }) {
2484
- if (schemaHash.length === 0) throw new CodegenGqlError("schemaHash must be a non-empty string.");
2485
2479
  const sorted = [...operations].sort((a, b) => a.name.localeCompare(b.name));
2486
2480
  const seen = /* @__PURE__ */ new Set();
2487
2481
  const entries = sorted.map((op) => {
@@ -2492,20 +2486,14 @@ function buildOperationsManifest({
2492
2486
  throw new CodegenGqlError(`Duplicate operation name "${op.name}" \u2014 operation names must be unique per namespace.`);
2493
2487
  }
2494
2488
  seen.add(op.name);
2495
- if (!OP_HASH_RE.test(op.hash)) {
2496
- throw new CodegenGqlError(`Operation "${op.name}" has malformed hash "${op.hash}" (expected sha256:<64 hex>).`);
2497
- }
2498
- return { name: op.name, hash: op.hash, kind: op.kind, requires: normalizeRequires(op.requires) };
2489
+ return { name: op.name, kind: op.kind, requires: normalizeRequires(op.requires) };
2499
2490
  });
2500
- const opsHash = `sha256:${crypto.createHash("sha256").update(stableJson(entries)).digest("hex")}`;
2501
2491
  const operationsRecord = {};
2502
2492
  for (const entry of entries) {
2503
- operationsRecord[entry.name] = { hash: entry.hash, kind: entry.kind, requires: entry.requires };
2493
+ operationsRecord[entry.name] = { kind: entry.kind, requires: entry.requires };
2504
2494
  }
2505
2495
  return {
2506
2496
  manifestVersion: MANIFEST_VERSION,
2507
- schemaHash,
2508
- opsHash,
2509
2497
  operations: operationsRecord
2510
2498
  };
2511
2499
  }