@tailor-platform/sdk 0.23.3 → 0.23.4

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @tailor-platform/sdk
2
2
 
3
+ ## 0.23.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [#302](https://github.com/tailor-platform/sdk/pull/302) [`b6f952d`](https://github.com/tailor-platform/sdk/commit/b6f952d86e84af396b80928fdd0fddc897ba00e3) Thanks [@toiroakr](https://github.com/toiroakr)! - Throw an error when backward relation names conflict with other backward relations, existing fields, or files fields
8
+
3
9
  ## 0.23.3
4
10
 
5
11
  ### Patch Changes
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import "../chunk-DhYkiPYI.mjs";
3
3
  import "../config-CtRi0Lgg.mjs";
4
- import { $ as jsonArgs, A as printData, B as loadAccessToken, D as tokenCommand, G as fetchUserInfo, H as readPlatformConfig, I as loadConfig, J as readPackageJson, K as initOAuth2Client, M as generateCommand, O as listCommand$5, P as applyCommand, Q as deploymentArgs, R as apiCommand, S as listCommand$6, U as writePlatformConfig, V as loadWorkspaceId, W as fetchAll, X as commonArgs, Y as PATScope, Z as confirmationArgs, a as createCommand$3, d as listCommand$7, et as withCommonArgs, h as executionsCommand, l as startCommand, nt as logger, p as getCommand$2, q as initOperatorClient, r as deleteCommand$3, s as resumeCommand, t as listCommand$8, tt as workspaceArgs, w as getCommand$1, x as removeCommand, y as showCommand, z as fetchLatestToken } from "../list-BvYJeydE.mjs";
4
+ import { $ as jsonArgs, A as printData, B as loadAccessToken, D as tokenCommand, G as fetchUserInfo, H as readPlatformConfig, I as loadConfig, J as readPackageJson, K as initOAuth2Client, M as generateCommand, O as listCommand$5, P as applyCommand, Q as deploymentArgs, R as apiCommand, S as listCommand$6, U as writePlatformConfig, V as loadWorkspaceId, W as fetchAll, X as commonArgs, Y as PATScope, Z as confirmationArgs, a as createCommand$3, d as listCommand$7, et as withCommonArgs, h as executionsCommand, l as startCommand, nt as logger, p as getCommand$2, q as initOperatorClient, r as deleteCommand$3, s as resumeCommand, t as listCommand$8, tt as workspaceArgs, w as getCommand$1, x as removeCommand, y as showCommand, z as fetchLatestToken } from "../list-BBzbTu9X.mjs";
5
5
  import { register } from "node:module";
6
6
  import { defineCommand, runCommand, runMain } from "citty";
7
7
  import { generateCodeVerifier } from "@badgateway/oauth2-client";
package/dist/cli/lib.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import "../chunk-DhYkiPYI.mjs";
2
2
  import "../config-CtRi0Lgg.mjs";
3
- import { B as loadAccessToken, C as listOAuth2Clients, E as getMachineUserToken, F as generateUserTypes, I as loadConfig, L as apiCall, N as apply, T as getOAuth2Client, V as loadWorkspaceId, _ as listWorkflowExecutions, b as remove, c as resumeWorkflow, f as listWorkflows, g as getWorkflowExecution, i as deleteWorkspace, j as generate, k as listMachineUsers, m as getWorkflow, n as listWorkspaces, o as createWorkspace, u as startWorkflow, v as show } from "../list-BvYJeydE.mjs";
3
+ import { B as loadAccessToken, C as listOAuth2Clients, E as getMachineUserToken, F as generateUserTypes, I as loadConfig, L as apiCall, N as apply, T as getOAuth2Client, V as loadWorkspaceId, _ as listWorkflowExecutions, b as remove, c as resumeWorkflow, f as listWorkflows, g as getWorkflowExecution, i as deleteWorkspace, j as generate, k as listMachineUsers, m as getWorkflow, n as listWorkspaces, o as createWorkspace, u as startWorkflow, v as show } from "../list-BBzbTu9X.mjs";
4
4
  import { register } from "node:module";
5
5
 
6
6
  //#region src/cli/lib.ts
@@ -98195,7 +98195,7 @@ function normalizeActionPermission(permission) {
98195
98195
  function parseTypes(rawTypes, namespace, typeSourceInfo) {
98196
98196
  const types$2 = {};
98197
98197
  for (const [typeName, type] of Object.entries(rawTypes)) types$2[typeName] = parseTailorDBType(type);
98198
- buildBackwardRelationships(types$2);
98198
+ buildBackwardRelationships(types$2, namespace, typeSourceInfo);
98199
98199
  validatePluralFormUniqueness(types$2, namespace, typeSourceInfo);
98200
98200
  return types$2;
98201
98201
  }
@@ -98255,14 +98255,22 @@ function parseTailorDBType(type) {
98255
98255
  }
98256
98256
  /**
98257
98257
  * Build backward relationships between parsed types.
98258
+ * Also validates that backward relation names are unique within each type.
98258
98259
  */
98259
- function buildBackwardRelationships(types$2) {
98260
+ function buildBackwardRelationships(types$2, namespace, typeSourceInfo) {
98261
+ const backwardNameSources = {};
98262
+ for (const typeName of Object.keys(types$2)) backwardNameSources[typeName] = {};
98260
98263
  for (const [typeName, type] of Object.entries(types$2)) for (const [otherTypeName, otherType] of Object.entries(types$2)) for (const [fieldName, field] of Object.entries(otherType.fields)) if (field.relation && field.relation.targetType === typeName) {
98261
98264
  let backwardName = field.relation.backwardName;
98262
98265
  if (!backwardName) {
98263
98266
  const lowerName = inflection.camelize(otherTypeName, true);
98264
98267
  backwardName = field.relation.unique ? inflection.singularize(lowerName) : inflection.pluralize(lowerName);
98265
98268
  }
98269
+ if (!backwardNameSources[typeName][backwardName]) backwardNameSources[typeName][backwardName] = [];
98270
+ backwardNameSources[typeName][backwardName].push({
98271
+ sourceType: otherTypeName,
98272
+ fieldName
98273
+ });
98266
98274
  type.backwardRelationships[backwardName] = {
98267
98275
  name: backwardName,
98268
98276
  targetType: otherTypeName,
@@ -98272,6 +98280,35 @@ function buildBackwardRelationships(types$2) {
98272
98280
  description: otherType.description || ""
98273
98281
  };
98274
98282
  }
98283
+ const errors = [];
98284
+ for (const [targetTypeName, backwardNames] of Object.entries(backwardNameSources)) {
98285
+ const targetType = types$2[targetTypeName];
98286
+ const targetTypeSourceInfo = typeSourceInfo?.[targetTypeName];
98287
+ const targetLocation = targetTypeSourceInfo ? ` (${targetTypeSourceInfo.filePath})` : "";
98288
+ for (const [backwardName, sources] of Object.entries(backwardNames)) {
98289
+ if (sources.length > 1) {
98290
+ const sourceList = sources.map((s) => {
98291
+ const sourceInfo = typeSourceInfo?.[s.sourceType];
98292
+ const location = sourceInfo ? ` (${sourceInfo.filePath})` : "";
98293
+ return `${s.sourceType}.${s.fieldName}${location}`;
98294
+ }).join(", ");
98295
+ errors.push(`Backward relation name "${backwardName}" on type "${targetTypeName}" is duplicated from: ${sourceList}. Use the "backward" option in .relation() to specify unique names.`);
98296
+ }
98297
+ if (backwardName in targetType.fields) {
98298
+ const source = sources[0];
98299
+ const sourceInfo = typeSourceInfo?.[source.sourceType];
98300
+ const sourceLocation = sourceInfo ? ` (${sourceInfo.filePath})` : "";
98301
+ errors.push(`Backward relation name "${backwardName}" from ${source.sourceType}.${source.fieldName}${sourceLocation} conflicts with existing field "${backwardName}" on type "${targetTypeName}"${targetLocation}. Use the "backward" option in .relation() to specify a different name.`);
98302
+ }
98303
+ if (targetType.files && backwardName in targetType.files) {
98304
+ const source = sources[0];
98305
+ const sourceInfo = typeSourceInfo?.[source.sourceType];
98306
+ const sourceLocation = sourceInfo ? ` (${sourceInfo.filePath})` : "";
98307
+ errors.push(`Backward relation name "${backwardName}" from ${source.sourceType}.${source.fieldName}${sourceLocation} conflicts with files field "${backwardName}" on type "${targetTypeName}"${targetLocation}. Use the "backward" option in .relation() to specify a different name.`);
98308
+ }
98309
+ }
98310
+ }
98311
+ if (errors.length > 0) throw new Error(`Backward relation name conflicts detected in TailorDB service "${namespace}".\n${errors.map((e) => ` - ${e}`).join("\n")}`);
98275
98312
  }
98276
98313
  /**
98277
98314
  * Validate GraphQL query field name uniqueness.
@@ -105602,4 +105639,4 @@ const listCommand = defineCommand({
105602
105639
 
105603
105640
  //#endregion
105604
105641
  export { jsonArgs as $, printData as A, loadAccessToken as B, listOAuth2Clients as C, tokenCommand as D, getMachineUserToken as E, generateUserTypes as F, fetchUserInfo as G, readPlatformConfig as H, loadConfig as I, readPackageJson as J, initOAuth2Client as K, apiCall as L, generateCommand as M, apply as N, listCommand$3 as O, applyCommand as P, deploymentArgs as Q, apiCommand as R, listCommand$2 as S, getOAuth2Client as T, writePlatformConfig as U, loadWorkspaceId as V, fetchAll as W, commonArgs as X, PATScope as Y, confirmationArgs as Z, listWorkflowExecutions as _, createCommand as a, remove as b, resumeWorkflow as c, listCommand$1 as d, withCommonArgs as et, listWorkflows as f, getWorkflowExecution as g, executionsCommand as h, deleteWorkspace as i, generate as j, listMachineUsers as k, startCommand as l, getWorkflow as m, listWorkspaces as n, logger as nt, createWorkspace as o, getCommand as p, initOperatorClient as q, deleteCommand as r, resumeCommand as s, listCommand as t, workspaceArgs as tt, startWorkflow as u, show as v, getCommand$1 as w, removeCommand as x, showCommand as y, fetchLatestToken as z };
105605
- //# sourceMappingURL=list-BvYJeydE.mjs.map
105642
+ //# sourceMappingURL=list-BBzbTu9X.mjs.map