@sequenceholdings/orm 2.7.0 → 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.
package/dist/index.cjs CHANGED
@@ -423,6 +423,7 @@ function defineSyncedTable(name2, columnsOrConfig, maybeConfig) {
423
423
  if (config.primaryKey !== void 0) tableConfig.primaryKey = config.primaryKey;
424
424
  if (config.links !== void 0) tableConfig.links = config.links;
425
425
  if (config.policies !== void 0) tableConfig.policies = { read: config.policies.read };
426
+ if (config.internal === true) tableConfig.internal = true;
426
427
  const table = {
427
428
  kind: TABLE_BRAND,
428
429
  tableName: name2,
@@ -2889,6 +2890,11 @@ function serializeNamespace(input) {
2889
2890
  enumsByName.set(ref.name, ref);
2890
2891
  }
2891
2892
  const canonicalTables = tables.map((table) => buildCanonicalTable({ table, relationsByName, enumsByName }));
2893
+ for (const table of tables) {
2894
+ if (table.source !== void 0 && table.config.internal === true && config.exports && Object.hasOwn(config.exports, table.tableName)) {
2895
+ throw new OrmDefinitionError(`internal synced source "${table.tableName}" cannot be exported; export a permitted managed view instead`, table.file);
2896
+ }
2897
+ }
2892
2898
  const canonicalEnums = [...enumsByName.values()].map((ref) => ({
2893
2899
  name: ref.name,
2894
2900
  values: [...ref.values]
@@ -3222,6 +3228,9 @@ function buildCanonicalLink({
3222
3228
  if (!relationsByName.has(targetName)) {
3223
3229
  return fail3(`targets ${relationKind(target)} "${targetName}" which is not part of this namespace`);
3224
3230
  }
3231
+ if (isSeqTable(target) && target.source !== void 0 && target.config.internal === true) {
3232
+ return fail3(`targets internal synced source "${targetName}"; expose a permitted managed view instead`);
3233
+ }
3225
3234
  if (link.enforce && (!isSeqTable(relation) || !isSeqTable(target))) {
3226
3235
  return fail3("cannot enforce a PostgreSQL foreign key involving a view");
3227
3236
  }