@tailor-platform/sdk 1.62.0 → 1.63.0

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/cli/lib.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
 
2
2
  import { f as initOperatorClient } from "../client-CobIRHl-.mjs";
3
3
  import { t as assertDefined } from "../assert-CKfwrmCV.mjs";
4
- import { $t as INITIAL_SCHEMA_NUMBER, A as truncate, Bt as getExecutor, Cn as generateUserTypes, Ct as triggerExecutor, D as resumeWorkflow, En as apiCall, Et as getExecutorJob, Ft as getWorkflowExecution, G as organizationTree, Gt as MIGRATION_LABEL_KEY, Ht as executeScript, It as listWorkflowExecutions, J as listOrganizations, M as generate$1, Nt as getWorkflow, Ot as listExecutorJobs, Q as updateFolder, Qt as DIFF_FILE_NAME, R as show, S as listApps, Tt as listExecutors, Ut as waitForExecution, V as remove, Vt as deploy, W as updateOrganization, Wt as bundleMigrationScript, X as getOrganization, Zt as DB_TYPES_FILE_NAME, _ as getWorkspace, _n as formatMigrationDiff, _t as listFunctionRegistries, a as updateUser, an as createSnapshotFromLocalTypes, bt as listWebhookExecutors, cn as getMigrationFilePath, ct as listOAuth2Clients, d as inviteUser, dt as getMachineUserToken, en as MIGRATE_FILE_NAME, et as listFolders, gn as formatDiffSummary, h as listWorkspaces, ht as generate, in as compareSnapshots, it as deleteFolder, jt as startWorkflow, k as listWorkflows, kt as watchExecutorJob, l as listUsers, ln as getMigrationFiles, mt as listMachineUsers, n as query, nt as getFolder, on as getLatestMigrationNumber, ot as createFolder, p as restoreWorkspace, pn as reconstructSnapshotFromMigrations, rn as compareLocalTypesWithSnapshot, s as removeUser, sn as getMigrationDirPath, t as isNativeTypeScriptRuntime, tn as SCHEMA_FILE_NAME, un as getNextMigrationNumber, ut as getOAuth2Client, vn as hasChanges, w as getAppHealth, x as createWorkspace, y as deleteWorkspace, yn as getNamespacesWithMigrations, yt as getFunctionRegistry } from "../runtime-C6o4hiYq.mjs";
4
+ import { $t as INITIAL_SCHEMA_NUMBER, A as truncate, Bt as getExecutor, Ct as triggerExecutor, D as resumeWorkflow, Dn as apiCall, Et as getExecutorJob, Ft as getWorkflowExecution, G as organizationTree, Gt as MIGRATION_LABEL_KEY, Ht as executeScript, It as listWorkflowExecutions, J as listOrganizations, M as generate$1, Nt as getWorkflow, Ot as listExecutorJobs, Q as updateFolder, Qt as DIFF_FILE_NAME, R as show, S as listApps, Tt as listExecutors, Ut as waitForExecution, V as remove, Vt as deploy, W as updateOrganization, Wt as bundleMigrationScript, X as getOrganization, Zt as DB_TYPES_FILE_NAME, _ as getWorkspace, _n as formatMigrationDiff, _t as listFunctionRegistries, a as updateUser, an as createSnapshotFromLocalTypes, bt as listWebhookExecutors, cn as getMigrationFilePath, ct as listOAuth2Clients, d as inviteUser, dt as getMachineUserToken, en as MIGRATE_FILE_NAME, et as listFolders, gn as formatDiffSummary, h as listWorkspaces, ht as generate, in as compareSnapshots, it as deleteFolder, jt as startWorkflow, k as listWorkflows, kt as watchExecutorJob, l as listUsers, ln as getMigrationFiles, mt as listMachineUsers, n as query, nt as getFolder, on as getLatestMigrationNumber, ot as createFolder, p as restoreWorkspace, pn as reconstructSnapshotFromMigrations, rn as compareLocalTypesWithSnapshot, s as removeUser, sn as getMigrationDirPath, t as isNativeTypeScriptRuntime, tn as SCHEMA_FILE_NAME, un as getNextMigrationNumber, ut as getOAuth2Client, vn as hasChanges, w as getAppHealth, wn as generateUserTypes, x as createWorkspace, y as deleteWorkspace, yn as getNamespacesWithMigrations, yt as getFunctionRegistry } from "../runtime-CW3jcQCc.mjs";
5
5
  import { C as loadConfig, E as loadAccessToken, O as loadWorkspaceId, b as getDistDir, h as platformBundleDefinePlugin } from "../application-BezXGbrU.mjs";
6
6
  import { n as enumConstantsPlugin } from "../enum-constants-C7DaWeQo.mjs";
7
7
  import { t as multiline } from "../multiline-Cf9ODpr1.mjs";
@@ -4677,6 +4677,72 @@ async function ensureConfigId(configPath) {
4677
4677
  injected: true
4678
4678
  };
4679
4679
  }
4680
+ /**
4681
+ * Read the resolved `defineConfig({...})` `id` from a config file without
4682
+ * mutating it. Returns null when the file has no inline `defineConfig()` call
4683
+ * (wrapper/re-export config), and `{ id: null }` when the call exists but has
4684
+ * no usable `id` property.
4685
+ * @param configPath - Absolute path to the config file
4686
+ * @returns The existing id (or null when absent), or null for wrapper configs
4687
+ */
4688
+ async function readConfigId(configPath) {
4689
+ const { program } = parseSync(configPath, await fs$1.promises.readFile(configPath, "utf-8"));
4690
+ const calls = [];
4691
+ findDefineConfigCalls(program, calls);
4692
+ if (calls.length === 0) return null;
4693
+ if (calls.length > 1) throw new Error(`Multiple defineConfig() calls found in ${configPath}. Only one is supported.`);
4694
+ const { configObj } = assertDefined(calls[0], "defineConfig call site missing");
4695
+ if (!configObj) throw new Error(`defineConfig() argument must be an inline object literal in ${configPath} so the SDK can manage the 'id' field.`);
4696
+ const idProp = findIdProperty(configObj);
4697
+ if (!idProp || idProp.value.type !== "Literal") return { id: null };
4698
+ const value = idProp.value.value;
4699
+ return { id: typeof value === "string" && value !== "" ? value : null };
4700
+ }
4701
+ /**
4702
+ * Read-only CI check: the config must already carry a valid app id.
4703
+ * Wrapper/re-export configs (no inline defineConfig call) are exempt,
4704
+ * mirroring the local behavior where {@link ensureConfigId} no-ops.
4705
+ * @param configPath - Absolute path to the config file
4706
+ */
4707
+ async function assertConfigIdInCI(configPath) {
4708
+ const result = await readConfigId(configPath);
4709
+ if (result === null) return;
4710
+ if (!result.id) throw new Error("tailor.config.ts is missing an 'id'. CI does not auto-generate one (each run would be treated as a separate app and break resource ownership). Run 'tailor-sdk setup github' or 'tailor-sdk apply' locally and commit the injected id.");
4711
+ if (!uuidRegex.test(result.id)) throw new Error(`'id' in ${configPath} must be a UUID. To use this config for a separate app, delete it.`);
4712
+ }
4713
+ /**
4714
+ * Ensure the config has an app id for a deploy run.
4715
+ *
4716
+ * Locally, the id is auto-injected when missing (via {@link ensureConfigId}).
4717
+ * In CI, the id is never auto-injected — a missing id is a hard error, because
4718
+ * generating one per run would create a fresh app each time and break resource
4719
+ * ownership. CI dry-runs (plan) perform the same check read-only, so a
4720
+ * forgotten id fails at PR time instead of at deploy. Ephemeral pipelines that
4721
+ * intentionally deploy a fresh app per run (such as e2e harnesses) can opt
4722
+ * back into injection with `TAILOR_PLATFORM_SDK_ALLOW_CI_ID_INJECTION=true`.
4723
+ * Local dry-run and build-only flows skip both injection and the check (no
4724
+ * on-disk side effects are expected, and build-only never talks to the
4725
+ * platform).
4726
+ * @param obj - Inputs
4727
+ * @param obj.configPath - Absolute path to the config file
4728
+ * @param obj.dryRun - Whether this is a dry-run
4729
+ * @param obj.buildOnly - Whether this is a build-only run
4730
+ */
4731
+ async function ensureConfigIdForDeploy(obj) {
4732
+ const { configPath, dryRun, buildOnly } = obj;
4733
+ if (buildOnly) return;
4734
+ const allowCIInjection = parseBoolean(process.env.TAILOR_PLATFORM_SDK_ALLOW_CI_ID_INJECTION) === true;
4735
+ const strictCI = isCI && !allowCIInjection;
4736
+ if (dryRun) {
4737
+ if (strictCI) await assertConfigIdInCI(configPath);
4738
+ return;
4739
+ }
4740
+ if (strictCI) {
4741
+ await assertConfigIdInCI(configPath);
4742
+ return;
4743
+ }
4744
+ await ensureConfigId(configPath);
4745
+ }
4680
4746
  const idComment = "// SDK-managed app id — do not edit, except when copying this config to a separate app.";
4681
4747
  function insertIdProperty(source, configObj, id) {
4682
4748
  const idLiteral = `id: ${JSON.stringify(id)}`;
@@ -4684,6 +4750,7 @@ function insertIdProperty(source, configObj, id) {
4684
4750
  const firstProp = assertDefined(configObj.properties[0], "first property missing");
4685
4751
  const lineStart = source.lastIndexOf("\n", firstProp.start - 1) + 1;
4686
4752
  const indent = source.slice(lineStart, firstProp.start);
4753
+ if (!/^[\t ]*$/.test(indent)) return source.slice(0, firstProp.start) + `${idLiteral}, ` + source.slice(firstProp.start);
4687
4754
  const insertion = `${idComment}\n${indent}${idLiteral},\n${indent}`;
4688
4755
  return source.slice(0, firstProp.start) + insertion + source.slice(firstProp.start);
4689
4756
  }
@@ -10322,9 +10389,13 @@ async function deploy(options) {
10322
10389
  const buildOnly = options?.buildOnly ?? parseBoolean(process.env.TAILOR_PLATFORM_SDK_BUILD_ONLY) === true;
10323
10390
  const { config, plugins } = await withSpan("build.loadConfig", async () => {
10324
10391
  const foundPath = loadConfigPath(options?.configPath);
10325
- if (foundPath && !dryRun && !buildOnly) {
10392
+ if (foundPath) {
10326
10393
  const resolvedPath = path.resolve(process.cwd(), foundPath);
10327
- if (fs$1.existsSync(resolvedPath)) await ensureConfigId(resolvedPath);
10394
+ if (fs$1.existsSync(resolvedPath)) await ensureConfigIdForDeploy({
10395
+ configPath: resolvedPath,
10396
+ dryRun,
10397
+ buildOnly
10398
+ });
10328
10399
  }
10329
10400
  return loadConfig(options?.configPath);
10330
10401
  });
@@ -17078,5 +17149,5 @@ function isDeno() {
17078
17149
  }
17079
17150
 
17080
17151
  //#endregion
17081
- export { listCommand$5 as $, INITIAL_SCHEMA_NUMBER as $t, truncate as A, configArg as An, startCommand as At, logBetaWarning as B, getExecutor as Bt, listCommand$2 as C, generateUserTypes as Cn, triggerExecutor as Ct, resumeWorkflow as D, assertWritable as Dn, jobsCommand as Dt, resumeCommand as E, apiCall as En, getExecutorJob as Et, writeDbTypesFile as F, paginationArgs as Fn, getWorkflowExecution as Ft, organizationTree as G, MIGRATION_LABEL_KEY as Gt, removeCommand$1 as H, executeScript as Ht, getConfiguredEditorCommand as I, toPageDirection as In, listWorkflowExecutions as It, listOrganizations as J, compareSnapshotWithRemote as Jt, treeCommand as K, handleOptionalToRequiredError as Kt, openInConfiguredEditor as L, workspaceArgs as Ln, functionExecutionStatusToString as Lt, generate as M, deploymentArgs as Mn, getCommand$5 as Mt, generateCommand as N, isVerbose as Nn, getWorkflow as Nt, listCommand$3 as O, defineAppCommand as On, listExecutorJobs as Ot, generateMigrationScript as P, pagedLogArgs as Pn, executionsCommand as Pt, updateFolder as Q, DIFF_FILE_NAME as Qt, show as R, formatKeyValueTable as Rt, listApps as S, PluginManager as Sn, triggerCommand as St, healthCommand as T, apiCommand as Tn, listExecutors as Tt, updateCommand$1 as U, waitForExecution$1 as Ut, remove as V, deploy as Vt, updateOrganization as W, bundleMigrationScript as Wt, getOrganization as X, protoGqlPermission as Xt, getCommand$1 as Y, generateAllTypeManifestsFromSnapshot as Yt, updateCommand$2 as Z, DB_TYPES_FILE_NAME as Zt, getWorkspace as _, formatMigrationDiff as _n, listFunctionRegistries as _t, updateUser as a, createSnapshotFromLocalTypes as an, createCommand$1 as at, createCommand as b, resourceTrn as bn, listWebhookExecutors as bt, listCommand as c, getMigrationFilePath as cn, listOAuth2Clients as ct, inviteUser as d, isValidMigrationNumber as dn, getMachineUserToken as dt, MIGRATE_FILE_NAME as en, listFolders as et, restoreCommand as f, loadDiff as fn, tokenCommand as ft, getCommand as g, formatDiffSummary as gn, listCommand$8 as gt, listWorkspaces as h, parseMigrationNumberArg as hn, generate$1 as ht, updateCommand as i, compareSnapshots as in, deleteFolder as it, truncateCommand as j, confirmationArgs as jn, startWorkflow as jt, listWorkflows as k, commonArgs as kn, watchExecutorJob as kt, listUsers as l, getMigrationFiles as ln, getCommand$3 as lt, listCommand$1 as m, formatMigrationNumber as mn, listMachineUsers as mt, query as n, assertValidMigrationFiles as nn, getFolder as nt, removeCommand as o, getLatestMigrationNumber as on, createFolder as ot, restoreWorkspace as p, reconstructSnapshotFromMigrations as pn, listCommand$7 as pt, listCommand$4 as q, parseMigrationLabelNumber as qt, queryCommand as r, compareLocalTypesWithSnapshot as rn, deleteCommand$1 as rt, removeUser as s, getMigrationDirPath as sn, listCommand$6 as st, isNativeTypeScriptRuntime as t, SCHEMA_FILE_NAME as tn, getCommand$2 as tt, inviteCommand as u, getNextMigrationNumber as un, getOAuth2Client as ut, deleteCommand as v, hasChanges as vn, getCommand$4 as vt, getAppHealth as w, prompt as wn, listCommand$9 as wt, createWorkspace as x, sdkNameLabelKey as xn, webhookCommand as xt, deleteWorkspace as y, getNamespacesWithMigrations as yn, getFunctionRegistry as yt, showCommand as z, getCommand$6 as zt };
17082
- //# sourceMappingURL=runtime-C6o4hiYq.mjs.map
17152
+ export { listCommand$5 as $, INITIAL_SCHEMA_NUMBER as $t, truncate as A, commonArgs as An, startCommand as At, logBetaWarning as B, getExecutor as Bt, listCommand$2 as C, PluginManager as Cn, triggerExecutor as Ct, resumeWorkflow as D, apiCall as Dn, jobsCommand as Dt, resumeCommand as E, apiCommand as En, getExecutorJob as Et, writeDbTypesFile as F, pagedLogArgs as Fn, getWorkflowExecution as Ft, organizationTree as G, MIGRATION_LABEL_KEY as Gt, removeCommand$1 as H, executeScript as Ht, getConfiguredEditorCommand as I, paginationArgs as In, listWorkflowExecutions as It, listOrganizations as J, compareSnapshotWithRemote as Jt, treeCommand as K, handleOptionalToRequiredError as Kt, openInConfiguredEditor as L, toPageDirection as Ln, functionExecutionStatusToString as Lt, generate as M, confirmationArgs as Mn, getCommand$5 as Mt, generateCommand as N, deploymentArgs as Nn, getWorkflow as Nt, listCommand$3 as O, assertWritable as On, listExecutorJobs as Ot, generateMigrationScript as P, isVerbose as Pn, executionsCommand as Pt, updateFolder as Q, DIFF_FILE_NAME as Qt, show as R, workspaceArgs as Rn, formatKeyValueTable as Rt, listApps as S, sdkNameLabelKey as Sn, triggerCommand as St, healthCommand as T, prompt as Tn, listExecutors as Tt, updateCommand$1 as U, waitForExecution$1 as Ut, remove as V, deploy as Vt, updateOrganization as W, bundleMigrationScript as Wt, getOrganization as X, protoGqlPermission as Xt, getCommand$1 as Y, generateAllTypeManifestsFromSnapshot as Yt, updateCommand$2 as Z, DB_TYPES_FILE_NAME as Zt, getWorkspace as _, formatMigrationDiff as _n, listFunctionRegistries as _t, updateUser as a, createSnapshotFromLocalTypes as an, createCommand$1 as at, createCommand as b, ensureConfigId as bn, listWebhookExecutors as bt, listCommand as c, getMigrationFilePath as cn, listOAuth2Clients as ct, inviteUser as d, isValidMigrationNumber as dn, getMachineUserToken as dt, MIGRATE_FILE_NAME as en, listFolders as et, restoreCommand as f, loadDiff as fn, tokenCommand as ft, getCommand as g, formatDiffSummary as gn, listCommand$8 as gt, listWorkspaces as h, parseMigrationNumberArg as hn, generate$1 as ht, updateCommand as i, compareSnapshots as in, deleteFolder as it, truncateCommand as j, configArg as jn, startWorkflow as jt, listWorkflows as k, defineAppCommand as kn, watchExecutorJob as kt, listUsers as l, getMigrationFiles as ln, getCommand$3 as lt, listCommand$1 as m, formatMigrationNumber as mn, listMachineUsers as mt, query as n, assertValidMigrationFiles as nn, getFolder as nt, removeCommand as o, getLatestMigrationNumber as on, createFolder as ot, restoreWorkspace as p, reconstructSnapshotFromMigrations as pn, listCommand$7 as pt, listCommand$4 as q, parseMigrationLabelNumber as qt, queryCommand as r, compareLocalTypesWithSnapshot as rn, deleteCommand$1 as rt, removeUser as s, getMigrationDirPath as sn, listCommand$6 as st, isNativeTypeScriptRuntime as t, SCHEMA_FILE_NAME as tn, getCommand$2 as tt, inviteCommand as u, getNextMigrationNumber as un, getOAuth2Client as ut, deleteCommand as v, hasChanges as vn, getCommand$4 as vt, getAppHealth as w, generateUserTypes as wn, listCommand$9 as wt, createWorkspace as x, resourceTrn as xn, webhookCommand as xt, deleteWorkspace as y, getNamespacesWithMigrations as yn, getFunctionRegistry as yt, showCommand as z, getCommand$6 as zt };
17153
+ //# sourceMappingURL=runtime-CW3jcQCc.mjs.map