@sequenceholdings/orm 2.7.0 → 2.8.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.
Files changed (47) hide show
  1. package/README.md +49 -4
  2. package/dist/authoring.cjs +30 -0
  3. package/dist/authoring.cjs.map +1 -1
  4. package/dist/authoring.d.cts +7 -1
  5. package/dist/authoring.d.ts +7 -1
  6. package/dist/authoring.js +30 -0
  7. package/dist/authoring.js.map +1 -1
  8. package/dist/canonical.d.cts +71 -71
  9. package/dist/canonical.d.ts +71 -71
  10. package/dist/cli.cjs +3473 -3342
  11. package/dist/cli.cjs.map +1 -1
  12. package/dist/cli.d.cts +13 -1
  13. package/dist/cli.d.ts +13 -1
  14. package/dist/cli.js +3472 -3343
  15. package/dist/cli.js.map +1 -1
  16. package/dist/client.cjs +24 -6
  17. package/dist/client.cjs.map +1 -1
  18. package/dist/client.d.cts +12 -3
  19. package/dist/client.d.ts +12 -3
  20. package/dist/client.js +24 -6
  21. package/dist/client.js.map +1 -1
  22. package/dist/compiler.cjs +844 -15
  23. package/dist/compiler.cjs.map +1 -1
  24. package/dist/compiler.d.cts +12 -2
  25. package/dist/compiler.d.ts +12 -2
  26. package/dist/compiler.js +844 -17
  27. package/dist/compiler.js.map +1 -1
  28. package/dist/index.cjs +30 -0
  29. package/dist/index.cjs.map +1 -1
  30. package/dist/index.d.cts +57 -57
  31. package/dist/index.d.ts +57 -57
  32. package/dist/index.js +30 -0
  33. package/dist/index.js.map +1 -1
  34. package/dist/ir.d.cts +72 -72
  35. package/dist/ir.d.ts +72 -72
  36. package/dist/sdl.cjs +3 -3
  37. package/dist/sdl.cjs.map +1 -1
  38. package/dist/sdl.d.cts +2 -0
  39. package/dist/sdl.d.ts +2 -0
  40. package/dist/sdl.js +3 -3
  41. package/dist/sdl.js.map +1 -1
  42. package/package.json +1 -1
  43. package/templates/orm-namespace/graphql/example/queries.ts +52 -5
  44. package/templates/orm-namespace/schema/tables.ts +5 -2
  45. package/templates/orm-namespace/sequence.config.ts +6 -4
  46. package/dist/{definition-DjfC7Lll.d.cts → definition-B99BsOAO.d.cts} +4 -4
  47. package/dist/{definition-DjfC7Lll.d.ts → definition-B99BsOAO.d.ts} +4 -4
package/README.md CHANGED
@@ -38,7 +38,7 @@ seq-studio orm apply . -e <environment-name>
38
38
  ```
39
39
 
40
40
  `generate` writes `schema.graphql`, `operations.manifest.json`, cache policies,
41
- and typed consumer modules. Generated SDL may contain up to 16 MiB of UTF-8
41
+ typed operation modules. Generated SDL may contain up to 16 MiB of UTF-8
42
42
  text for the complete namespace; individual authored files retain a 1 MiB cap.
43
43
  Registration and reviewed migration exports are bounded to 64 MiB including
44
44
  canonical metadata, snapshots, documents, and migration statements.
@@ -127,9 +127,43 @@ seq-studio orm execute GetOpenDeals . \
127
127
  `variables.json` must contain a JSON object. The platform validates variables,
128
128
  operation requirements, and row policies as the signed-in caller.
129
129
 
130
- Execute uses the `/_data/v2` endpoint by default. Set
131
- `SEQUENCE_ORM_ATLAS_EXECUTE_V2=1` to opt into Atlas's `/api/data/v2` endpoint.
132
- This client rollout switch does not bypass server feature flags or authorization.
130
+ Execute posts to Atlas's `/api/data/v2` endpoint. The hash comes from this
131
+ checkout's `operations.manifest.json`, so when the deployed version hashes the
132
+ operation differently the server answers 404. Execute then reports the local
133
+ and deployed hashes and the deployed version. `seq-studio orm execute
134
+ <namespace> <operation>` runs the deployed version's operation by name without a
135
+ checkout.
136
+
137
+ ## Internal synced dependencies
138
+
139
+ Use `internal: true` on a typed, keyed `defineSyncedTable` when its rows are
140
+ inputs to a managed view and must not be queried directly. The reflected source
141
+ and its read policy remain available inside the view. Internal sources are
142
+ excluded from GraphQL roots and links, default SQL, and registered SQL object
143
+ ceilings. A missing persisted operation alone does not make a source private.
144
+ Authoring rejects declared links targeting an internal synced source and
145
+ rejects exporting it. This also prevents dynamic predicates from reaching it
146
+ through hidden intermediate relations or cross-namespace links.
147
+
148
+ ```ts
149
+ const privacy = defineSyncedTable("privacy", {
150
+ uid: t.text().primaryKey(),
151
+ restricted: t.boolean().notNull(),
152
+ }, { source: "gold.customer_privacy", internal: true, policies: { read: "true" } });
153
+ if (privacy.config.internal !== true) {
154
+ throw new Error("Upgrade the ORM SDK: internal synced dependencies are required.");
155
+ }
156
+ ```
157
+
158
+ Publish only the permitted projection through `defineView`, with its own read
159
+ policy. Declaring `internal` does not grant access to the source or change row
160
+ policies. The existing unkeyed-source restrictions remain in force.
161
+
162
+ This authoring addition needs a released SDK containing the option. The existing
163
+ Atlas internal-object exclusion remains the runtime boundary; do not replace
164
+ the declaration with casts or edits to generated canonical JSON. ORM releases
165
+ use the separate [Studio CLI chain release workflow](https://github.com/sequenceholdings/studio/blob/main/.changeset/README.md#studio-cli-chain-releases);
166
+ chain packages do not use Changesets.
133
167
 
134
168
  ## Default read-only SQL (introduced in 2.6.0)
135
169
 
@@ -251,3 +285,14 @@ provider to wire a generated client.
251
285
  Affected namespaces require IR v6, including namespaces that only declare a write policy and have no operations. `orm apply` first checks the authenticated target's `/api/orm/runtime-capabilities` response; a missing or older endpoint blocks registration. The compiler and executor also reject an incompatible IR version. Publish the matching ORM and deploy its runtime before activating these policies. Service identity does not grant namespace access, operation capability, declared data scope or row access by itself.
252
286
 
253
287
  ORM 2.7.0 and downstream Artifact Studio 0.10.0, Managed Functions 0.4.4, Pipeline Spec 0.2.6 and Studio CLI 0.6.6 remain prepared for the separate chain-release workflow and awaiting publication. Their workspace dependencies are pinned to this ORM version when packed; no candidate build constitutes registry evidence.
288
+
289
+ ## Default object operations
290
+
291
+ Discover object-specific `GetCustomer`, `ListCustomers`, `CreateCustomer`,
292
+ `UpdateCustomer`, and `DeleteCustomer` contracts through the ORM catalog, then
293
+ execute their current hashes through the existing Data API. Read-only objects
294
+ expose reads; writes retain the existing schema and policy requirements.
295
+ Authored operations with matching names take precedence. No default count or
296
+ link-traversal operation is added. TypeScript wrappers remain deferred.
297
+
298
+ See [default object operations](../../../docs/platform/orm-default-operations.md).
@@ -281,6 +281,22 @@ function toPlatformUser(options) {
281
281
  function isSeqLink(value) {
282
282
  return typeof value === "object" && value !== null && value.kind === LINK_BRAND;
283
283
  }
284
+ var TABLE_CONFIG_KEYS = /* @__PURE__ */ new Set([
285
+ "displayName",
286
+ "description",
287
+ "renamedFrom",
288
+ "primaryKey",
289
+ "indexes",
290
+ "checks",
291
+ "foreignKeys",
292
+ "links",
293
+ "policies",
294
+ "cowMutations",
295
+ "cellMetadata",
296
+ "cellRevisions",
297
+ "materializes",
298
+ "internal"
299
+ ]);
284
300
  function isSeqTable(value) {
285
301
  return typeof value === "object" && value !== null && value.kind === TABLE_BRAND;
286
302
  }
@@ -295,6 +311,11 @@ function assertIdentifier({ value, what, file, pattern = IDENTIFIER_PATTERN }) {
295
311
  function defineTable(name2, columns, config = {}) {
296
312
  const file = activeAuthoringContext()?.currentFile;
297
313
  assertIdentifier({ value: name2, what: "table name", file });
314
+ for (const key of Object.keys(config)) {
315
+ if (!TABLE_CONFIG_KEYS.has(key)) {
316
+ throw new OrmDefinitionError(`table "${name2}": unknown defineTable option "${key}"`, file);
317
+ }
318
+ }
298
319
  const entries = Object.entries(columns);
299
320
  if (entries.length === 0) {
300
321
  throw new OrmDefinitionError(`table "${name2}" declares no columns`, file);
@@ -387,6 +408,7 @@ function defineSyncedTable(name2, columnsOrConfig, maybeConfig) {
387
408
  if (config.primaryKey !== void 0) tableConfig.primaryKey = config.primaryKey;
388
409
  if (config.links !== void 0) tableConfig.links = config.links;
389
410
  if (config.policies !== void 0) tableConfig.policies = { read: config.policies.read };
411
+ if (config.internal === true) tableConfig.internal = true;
390
412
  const table = {
391
413
  kind: TABLE_BRAND,
392
414
  tableName: name2,
@@ -2748,6 +2770,11 @@ function serializeNamespace(input) {
2748
2770
  enumsByName.set(ref.name, ref);
2749
2771
  }
2750
2772
  const canonicalTables = tables.map((table) => buildCanonicalTable({ table, relationsByName, enumsByName }));
2773
+ for (const table of tables) {
2774
+ if (table.source !== void 0 && table.config.internal === true && config.exports && Object.hasOwn(config.exports, table.tableName)) {
2775
+ throw new OrmDefinitionError(`internal synced source "${table.tableName}" cannot be exported; export a permitted managed view instead`, table.file);
2776
+ }
2777
+ }
2751
2778
  const canonicalEnums = [...enumsByName.values()].map((ref) => ({
2752
2779
  name: ref.name,
2753
2780
  values: [...ref.values]
@@ -3081,6 +3108,9 @@ function buildCanonicalLink({
3081
3108
  if (!relationsByName.has(targetName)) {
3082
3109
  return fail(`targets ${relationKind(target)} "${targetName}" which is not part of this namespace`);
3083
3110
  }
3111
+ if (isSeqTable(target) && target.source !== void 0 && target.config.internal === true) {
3112
+ return fail(`targets internal synced source "${targetName}"; expose a permitted managed view instead`);
3113
+ }
3084
3114
  if (link.enforce && (!isSeqTable(relation) || !isSeqTable(target))) {
3085
3115
  return fail("cannot enforce a PostgreSQL foreign key involving a view");
3086
3116
  }