@sequenceholdings/orm 2.8.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/cli.js CHANGED
@@ -6004,7 +6004,7 @@ function generateSqlOperations({ artifact }) {
6004
6004
  lines.push(
6005
6005
  `export type ${prefix}Variables = SqlQueryVariables`,
6006
6006
  `export type ${prefix}Result = SqlQueryResult`,
6007
- `export const ${prefix}: OperationReference<${prefix}Variables, ${prefix}Result> = ${JSON.stringify({ namespace: artifact.namespace, hash: operation.opHash })}`,
6007
+ `export const ${prefix}: OperationReference<${prefix}Variables, ${prefix}Result> = ${JSON.stringify({ namespace: artifact.namespace, name: operation.name, kind: operation.kind })}`,
6008
6008
  ""
6009
6009
  );
6010
6010
  continue;
@@ -6019,7 +6019,7 @@ function generateSqlOperations({ artifact }) {
6019
6019
  ${variables}
6020
6020
  }`,
6021
6021
  `export type ${prefix}Result = { columns: Array<{ name: string; type: string; nullable: boolean }>; rows: Array<[${row}]>; truncated: boolean }`,
6022
- `export const ${prefix}: OperationReference<${prefix}Variables, ${prefix}Result> = ${JSON.stringify({ namespace: artifact.namespace, hash: operation.opHash })}`,
6022
+ `export const ${prefix}: OperationReference<${prefix}Variables, ${prefix}Result> = ${JSON.stringify({ namespace: artifact.namespace, name: operation.name, kind: operation.kind })}`,
6023
6023
  ""
6024
6024
  );
6025
6025
  }
@@ -6809,29 +6809,23 @@ var CodegenGqlError = class extends Error {
6809
6809
  this.name = "CodegenGqlError";
6810
6810
  }
6811
6811
  };
6812
- var MANIFEST_VERSION = 1;
6813
- var OP_HASH_RE = /^sha256:[0-9a-f]{64}$/;
6812
+ var MANIFEST_VERSION = 2;
6814
6813
  var GRAPHQL_NAME_RE = /^[_A-Za-z][_0-9A-Za-z]*$/;
6815
6814
  var manifestRequiresSchema = z.object({
6816
6815
  capability: z.string().min(1).optional(),
6817
6816
  role: z.string().min(1).optional()
6818
6817
  }).nullable();
6819
6818
  var manifestOperationSchema = z.object({
6820
- hash: z.string().regex(OP_HASH_RE),
6821
6819
  kind: z.enum(["query", "mutation"]),
6822
6820
  requires: manifestRequiresSchema
6823
6821
  });
6824
6822
  var operationsManifestSchema = z.object({
6825
- manifestVersion: z.literal(MANIFEST_VERSION),
6826
- schemaHash: z.string().min(1),
6827
- opsHash: z.string().regex(OP_HASH_RE),
6823
+ manifestVersion: z.union([z.literal(1), z.literal(MANIFEST_VERSION)]),
6828
6824
  operations: z.record(z.string().regex(GRAPHQL_NAME_RE), manifestOperationSchema)
6829
6825
  });
6830
6826
  function buildOperationsManifest({
6831
- schemaHash,
6832
6827
  operations
6833
6828
  }) {
6834
- if (schemaHash.length === 0) throw new CodegenGqlError("schemaHash must be a non-empty string.");
6835
6829
  const sorted = [...operations].sort((a, b) => a.name.localeCompare(b.name));
6836
6830
  const seen = /* @__PURE__ */ new Set();
6837
6831
  const entries = sorted.map((op) => {
@@ -6842,20 +6836,14 @@ function buildOperationsManifest({
6842
6836
  throw new CodegenGqlError(`Duplicate operation name "${op.name}" \u2014 operation names must be unique per namespace.`);
6843
6837
  }
6844
6838
  seen.add(op.name);
6845
- if (!OP_HASH_RE.test(op.hash)) {
6846
- throw new CodegenGqlError(`Operation "${op.name}" has malformed hash "${op.hash}" (expected sha256:<64 hex>).`);
6847
- }
6848
- return { name: op.name, hash: op.hash, kind: op.kind, requires: normalizeRequires(op.requires) };
6839
+ return { name: op.name, kind: op.kind, requires: normalizeRequires(op.requires) };
6849
6840
  });
6850
- const opsHash = `sha256:${createHash("sha256").update(stableJson(entries)).digest("hex")}`;
6851
6841
  const operationsRecord = {};
6852
6842
  for (const entry of entries) {
6853
- operationsRecord[entry.name] = { hash: entry.hash, kind: entry.kind, requires: entry.requires };
6843
+ operationsRecord[entry.name] = { kind: entry.kind, requires: entry.requires };
6854
6844
  }
6855
6845
  return {
6856
6846
  manifestVersion: MANIFEST_VERSION,
6857
- schemaHash,
6858
- opsHash,
6859
6847
  operations: operationsRecord
6860
6848
  };
6861
6849
  }
@@ -11685,11 +11673,10 @@ async function writeGenerateOutputs(dir, project) {
11685
11673
  `);
11686
11674
  const operations = Object.entries(manifest.operations).map(([name2, op]) => ({
11687
11675
  name: name2,
11688
- hash: op.opHash,
11689
11676
  kind: op.kind,
11690
11677
  requires: op.requires
11691
11678
  }));
11692
- const manifestFile = buildOperationsManifest({ schemaHash: manifest.schemaHash, operations });
11679
+ const manifestFile = buildOperationsManifest({ operations });
11693
11680
  await writeFile(join(dir, OPERATIONS_MANIFEST_FILE), `${JSON.stringify(manifestFile, null, 2)}
11694
11681
  `);
11695
11682
  await writeFile(join(dir, TYPE_POLICIES_FILE), generateTypePolicies(loaded.canonical));
@@ -11802,13 +11789,12 @@ async function executeV2Command(rest) {
11802
11789
  const namespace = loaded.canonical.namespace;
11803
11790
  let response;
11804
11791
  try {
11805
- response = await apiRequestStrict("POST", `${DATA_ENDPOINT_PREFIX}/${namespace}`, { op: selected.hash, variables });
11792
+ response = await apiRequestStrict("POST", `${DATA_ENDPOINT_PREFIX}/${namespace}`, { op: `${selected.kind}:${operation}`, expectedKind: selected.kind, variables });
11806
11793
  } catch (error) {
11807
11794
  if (!(error instanceof AtlasRequestError) || error.status !== 404) throw error;
11808
11795
  const diagnosis = await diagnoseUnknownOperation({
11809
11796
  namespace,
11810
11797
  operation,
11811
- localHash: selected.hash,
11812
11798
  retry: `seq-studio orm execute ${namespace} ${operation}${env ? ` -e ${env}` : ""} --variables-file ${variablesFile}`
11813
11799
  }).catch(() => null);
11814
11800
  throw diagnosis ? new OrmDefinitionError(diagnosis) : error;
@@ -11816,7 +11802,7 @@ async function executeV2Command(rest) {
11816
11802
  console.log(JSON.stringify(response, null, 2));
11817
11803
  return 0;
11818
11804
  }
11819
- async function diagnoseUnknownOperation({ namespace, operation, localHash, retry }) {
11805
+ async function diagnoseUnknownOperation({ namespace, operation, retry }) {
11820
11806
  const encoded = encodeURIComponent(namespace);
11821
11807
  const listing = await apiRequest(
11822
11808
  "GET",
@@ -11839,15 +11825,10 @@ async function diagnoseUnknownOperation({ namespace, operation, localHash, retry
11839
11825
  if (!deployed) {
11840
11826
  return `operation ${operation} is not in ${namespace}'s deployed version ${listing.schema_version_id}. Apply this checkout to deploy it (seq-studio orm apply), or list the deployed operations: seq-studio orm describe ${namespace} --operations`;
11841
11827
  }
11842
- if (deployed.op_hash === localHash) return null;
11843
11828
  return [
11844
- `operation ${operation}: this checkout's ${OPERATIONS_MANIFEST_FILE} does not match ${namespace}'s deployed version.`,
11845
- ` local hash: ${localHash}`,
11846
- ` deployed hash: ${deployed.op_hash}`,
11847
- ` deployed version: ${listing.schema_version_id}`,
11848
- "Run the deployed operation by name (no checkout needed):",
11849
- ` ${retry}`,
11850
- "Or bring the checkout up to date (git pull, then seq-studio orm generate) and retry."
11829
+ `operation ${operation} exists in ${namespace}'s deployed version ${listing.schema_version_id}, but its guarded name was refused.`,
11830
+ "Update Atlas to a runtime that supports guarded operation names, or retry if the operation set changed during lookup.",
11831
+ ` ${retry}`
11851
11832
  ].join("\n");
11852
11833
  }
11853
11834
  async function validateV2Command(dir) {