@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.
@@ -611,6 +611,12 @@ interface SyncedTableConfig {
611
611
  /** Reflected read-only source as a safe qualified identifier: `<schema>.<table>`. */
612
612
  source: string;
613
613
  description?: string;
614
+ /**
615
+ * View dependency only: keep the reflected source and its read policy, but
616
+ * exclude direct GraphQL and SQL access. Requires a keyed source contract.
617
+ * Publish the permitted result through a managed view instead.
618
+ */
619
+ internal?: boolean;
614
620
  /**
615
621
  * Primary-key property/column names, mutually exclusive with column-level
616
622
  * `.primaryKey()`. Explicit `[]` declares a read-only bag with no row identity.
@@ -611,6 +611,12 @@ interface SyncedTableConfig {
611
611
  /** Reflected read-only source as a safe qualified identifier: `<schema>.<table>`. */
612
612
  source: string;
613
613
  description?: string;
614
+ /**
615
+ * View dependency only: keep the reflected source and its read policy, but
616
+ * exclude direct GraphQL and SQL access. Requires a keyed source contract.
617
+ * Publish the permitted result through a managed view instead.
618
+ */
619
+ internal?: boolean;
614
620
  /**
615
621
  * Primary-key property/column names, mutually exclusive with column-level
616
622
  * `.primaryKey()`. Explicit `[]` declares a read-only bag with no row identity.
package/dist/authoring.js CHANGED
@@ -384,6 +384,7 @@ function defineSyncedTable(name2, columnsOrConfig, maybeConfig) {
384
384
  if (config.primaryKey !== void 0) tableConfig.primaryKey = config.primaryKey;
385
385
  if (config.links !== void 0) tableConfig.links = config.links;
386
386
  if (config.policies !== void 0) tableConfig.policies = { read: config.policies.read };
387
+ if (config.internal === true) tableConfig.internal = true;
387
388
  const table = {
388
389
  kind: TABLE_BRAND,
389
390
  tableName: name2,
@@ -2745,6 +2746,11 @@ function serializeNamespace(input) {
2745
2746
  enumsByName.set(ref.name, ref);
2746
2747
  }
2747
2748
  const canonicalTables = tables.map((table) => buildCanonicalTable({ table, relationsByName, enumsByName }));
2749
+ for (const table of tables) {
2750
+ if (table.source !== void 0 && table.config.internal === true && config.exports && Object.hasOwn(config.exports, table.tableName)) {
2751
+ throw new OrmDefinitionError(`internal synced source "${table.tableName}" cannot be exported; export a permitted managed view instead`, table.file);
2752
+ }
2753
+ }
2748
2754
  const canonicalEnums = [...enumsByName.values()].map((ref) => ({
2749
2755
  name: ref.name,
2750
2756
  values: [...ref.values]
@@ -3078,6 +3084,9 @@ function buildCanonicalLink({
3078
3084
  if (!relationsByName.has(targetName)) {
3079
3085
  return fail(`targets ${relationKind(target)} "${targetName}" which is not part of this namespace`);
3080
3086
  }
3087
+ if (isSeqTable(target) && target.source !== void 0 && target.config.internal === true) {
3088
+ return fail(`targets internal synced source "${targetName}"; expose a permitted managed view instead`);
3089
+ }
3081
3090
  if (link.enforce && (!isSeqTable(relation) || !isSeqTable(target))) {
3082
3091
  return fail("cannot enforce a PostgreSQL foreign key involving a view");
3083
3092
  }