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