@tailor-platform/sdk 1.69.0 → 1.70.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.
Files changed (52) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/dist/application-BakHtldG.mjs +4 -0
  3. package/dist/{application-Cr-limKC.mjs → application-Df5_I83n.mjs} +318 -78
  4. package/dist/application-Df5_I83n.mjs.map +1 -0
  5. package/dist/cli/erd-viewer-assets/app.js +279 -36
  6. package/dist/cli/erd-viewer-assets/index.html +4 -0
  7. package/dist/cli/erd-viewer-assets/styles.css +252 -5
  8. package/dist/cli/index.mjs +641 -90
  9. package/dist/cli/index.mjs.map +1 -1
  10. package/dist/cli/lib.d.mts +14 -8
  11. package/dist/cli/lib.mjs +2 -2
  12. package/dist/completion/zsh-worker.zsh +153 -2
  13. package/dist/configure/index.d.mts +5 -5
  14. package/dist/configure/index.mjs +8 -6
  15. package/dist/configure/index.mjs.map +1 -1
  16. package/dist/{index-B7VbJm0_.d.mts → index-BAEaAqmz.d.mts} +90 -40
  17. package/dist/{index-CklcVeMG.d.mts → index-C-vsbx27.d.mts} +2 -2
  18. package/dist/{index-hXoO-AOC.d.mts → index-CKI0eZP6.d.mts} +2 -2
  19. package/dist/{index-DYhnxXYR.d.mts → index-CrqOgUF2.d.mts} +2 -2
  20. package/dist/{index-DlDRSzFZ.d.mts → index-DESLU9kI.d.mts} +2 -2
  21. package/dist/plugin/builtin/enum-constants/index.d.mts +1 -1
  22. package/dist/plugin/builtin/file-utils/index.d.mts +1 -1
  23. package/dist/plugin/builtin/kysely-type/index.d.mts +1 -1
  24. package/dist/plugin/builtin/seed/index.d.mts +1 -1
  25. package/dist/plugin/index.d.mts +1 -1
  26. package/dist/{runtime-jowoN6qC.mjs → runtime-CSY0eD4_.mjs} +330 -190
  27. package/dist/runtime-CSY0eD4_.mjs.map +1 -0
  28. package/dist/{schema-1msIhXwA.mjs → schema-C4fkpWV_.mjs} +9 -15
  29. package/dist/schema-C4fkpWV_.mjs.map +1 -0
  30. package/dist/{types-2Be3wSMc.mjs → types-32lUMToj.mjs} +1 -1
  31. package/dist/{types-CmzfQP_m.mjs → types-D4QMmNWh.mjs} +1 -12
  32. package/dist/types-D4QMmNWh.mjs.map +1 -0
  33. package/dist/{types-Bzr0RQME.d.mts → types-Dynq4AJv.d.mts} +2 -2
  34. package/dist/{types-DZrtN6-H.d.mts → types-rj8YJcEe.d.mts} +5 -2
  35. package/dist/utils/test/index.d.mts +2 -2
  36. package/dist/{workflow.generated-Br9bmLdX.d.mts → workflow.generated-DJULCuRr.d.mts} +177 -172
  37. package/docs/cli/application.md +37 -2
  38. package/docs/cli/setup.md +1 -0
  39. package/docs/cli/tailordb.md +24 -0
  40. package/docs/cli/user.md +11 -1
  41. package/docs/cli/workspace.md +13 -7
  42. package/docs/cli-reference.md +6 -0
  43. package/docs/github-actions.md +27 -0
  44. package/docs/multi-environment.md +22 -0
  45. package/docs/services/aigateway.md +4 -2
  46. package/docs/services/http-adapter.md +16 -1
  47. package/package.json +1 -1
  48. package/dist/application-Br48NXBD.mjs +0 -4
  49. package/dist/application-Cr-limKC.mjs.map +0 -1
  50. package/dist/runtime-jowoN6qC.mjs.map +0 -1
  51. package/dist/schema-1msIhXwA.mjs.map +0 -1
  52. package/dist/types-CmzfQP_m.mjs.map +0 -1
@@ -1,9 +1,9 @@
1
1
 
2
- import { t as db } from "./schema-1msIhXwA.mjs";
2
+ import { t as db } from "./schema-C4fkpWV_.mjs";
3
3
  import { $ as CreateUserProfileConfigRequestSchema, A as UpdatePipelineServiceRequestSchema, At as PageDirection, B as UpdateExecutorExecutorRequestSchema, Ct as GetApplicationSchemaHealthResponse_ApplicationSchemaHealthStatus, D as CreatePipelineResolverRequestSchema, Dt as ConditionSchema, E as UpdateSecretManagerSecretRequestSchema, Et as Subgraph_ServiceType, F as IdPPermissionOperator, G as CreateAuthHookRequestSchema, H as ExecutorTargetType, I as IdPPermissionPermit, J as CreateAuthOAuth2ClientRequestSchema, K as CreateAuthIDPConfigRequestSchema, L as FunctionExecution_Status, M as CreateIdPServiceRequestSchema, N as UpdateIdPServiceRequestSchema, O as CreatePipelineServiceRequestSchema, Ot as Condition_Operator, P as IdPLang, Q as CreateTenantConfigRequestSchema, S as UpdateStaticWebsiteRequestSchema, St as CreateApplicationRequestSchema, T as CreateSecretManagerVaultRequestSchema, Tt as ApplicationSchemaUpdateAttemptStatus, U as ExecutorTriggerType, V as ExecutorJobStatus, W as CreateAuthConnectionRequestSchema, X as CreateAuthSCIMResourceRequestSchema, Y as CreateAuthSCIMConfigRequestSchema, Z as CreateAuthServiceRequestSchema, _ as TailorDBType_Permission_Operator, _t as AuthSCIMAttribute_Uniqueness, a as WorkspacePlatformUserRole, at as UpdateAuthSCIMResourceRequestSchema, b as AddCustomDomainRequestSchema, bt as TenantProviderConfig_TenantProviderType, c as UpdateWorkflowRequestSchema, ct as UpdateUserProfileConfigRequestSchema, d as CreateTailorDBServiceRequestSchema, dt as AuthIDPConfig_AuthType, et as UpdateAuthHookRequestSchema, f as CreateTailorDBTypeRequestSchema, ft as AuthInvokerSchema, g as TailorDBGQLPermission_Permit, gt as AuthSCIMAttribute_Type, h as TailorDBGQLPermission_Operator, ht as AuthSCIMAttribute_Mutability, it as UpdateAuthSCIMConfigRequestSchema, j as PipelineResolver_OperationType, k as UpdatePipelineResolverRequestSchema, kt as FilterSchema, l as WorkflowExecution_Status, lt as AuthConnection_Type, m as TailorDBGQLPermission_Action, mt as AuthOAuth2Client_GrantType, nt as UpdateAuthMachineUserRequestSchema, o as CreateWorkflowJobFunctionRequestSchema, ot as UpdateAuthServiceRequestSchema, p as UpdateTailorDBTypeRequestSchema, pt as AuthOAuth2Client_ClientType, q as CreateAuthMachineUserRequestSchema, rt as UpdateAuthOAuth2ClientRequestSchema, s as CreateWorkflowRequestSchema, st as UpdateTenantConfigRequestSchema, t as OperatorService, tt as UpdateAuthIDPConfigRequestSchema, u as WorkflowJobExecution_Status, ut as AuthHookPoint, v as TailorDBType_Permission_Permit, vt as AuthSCIMConfig_AuthorizationType, w as CreateSecretManagerSecretRequestSchema, wt as UpdateApplicationRequestSchema, x as CreateStaticWebsiteRequestSchema, xt as UserProfileProviderConfig_UserProfileProviderType, y as TailorDBType_PermitAction, z as CreateExecutorExecutorRequestSchema } from "./service_pb-DSNjrcbW.mjs";
4
4
  import { t as assertDefined } from "./assert-CKfwrmCV.mjs";
5
5
  import { a as parseBoolean, i as symbols, n as logger, r as styles, t as CIPromptError } from "./logger-DKF-JsAK.mjs";
6
- import { A as loadMachineUserName, F as writePlatformConfig, G as resolveStaticWebsiteUrls, K as byName, L as fetchAll, M as readPlatformConfig, O as loadAccessToken, R as fetchMachineUserToken, S as getDistDir, T as loadConfig, U as initOperatorClient, W as platformBaseUrl, b as hasGenerationHooks, d as assertUniqueLocalTailorDBTypeNames, f as assertUniqueTailorDBTypeNamesWithExternal, h as platformBundleDefinePlugin, j as loadWorkspaceId, k as loadConfigPath, l as buildExecutorArgsExpr, m as stringifyFunction, n as generatePluginFilesIfNeeded, p as TailorDBTypeSchema, r as loadApplication, s as HTTP_METHODS, t as defineApplication, u as buildResolverOperationHookExpr, w as hashFile, x as createBundleCache, y as getPluginGenerationDependencies, z as fetchPaged } from "./application-Cr-limKC.mjs";
6
+ import { $ as initOperatorClient, A as loadAccessToken, G as fetchMachineUserToken, I as loadWorkspaceId, K as fetchPaged, L as platformConfigFromProfile, N as loadMachineUserName, P as loadPlatformClientConfig, R as readPlatformConfig, S as getDistDir, T as loadConfig, V as writePlatformConfig, W as fetchAll, X as getOAuth2ClientId, Y as getConsoleBaseUrl, Z as getPlatformBaseUrl, b as hasGenerationHooks, d as assertUniqueLocalTailorDBTypeNames, et as isDefaultPlatform, f as assertUniqueTailorDBTypeNamesWithExternal, h as platformBundleDefinePlugin, j as loadConfigPath, k as hasUserTokenEntry, l as buildExecutorArgsExpr, m as stringifyFunction, n as generatePluginFilesIfNeeded, nt as byName, p as TailorDBTypeSchema, r as loadApplication, s as HTTP_METHODS, t as defineApplication, tt as resolveStaticWebsiteUrls, u as buildResolverOperationHookExpr, w as hashFile, x as createBundleCache, y as getPluginGenerationDependencies } from "./application-Df5_I83n.mjs";
7
7
  import { o as loadFilesWithIgnores, t as createExecutorService } from "./service-B2Jd9CxS.mjs";
8
8
  import { t as multiline } from "./multiline-Cf9ODpr1.mjs";
9
9
  import { t as readPackageJson } from "./package-json-DcQApfPQ.mjs";
@@ -310,6 +310,10 @@ async function assertWritable(opts) {
310
310
 
311
311
  //#endregion
312
312
  //#region src/cli/commands/api/api-call.ts
313
+ function hasEnvAccessToken() {
314
+ const envToken = process.env.TAILOR_PLATFORM_TOKEN ?? process.env.TAILOR_TOKEN;
315
+ return Boolean(envToken);
316
+ }
313
317
  /**
314
318
  * Call Tailor Platform API endpoints directly.
315
319
  * If the endpoint doesn't contain "/", it defaults to `tailor.v1.OperatorService/{endpoint}`.
@@ -318,10 +322,16 @@ async function assertWritable(opts) {
318
322
  */
319
323
  async function apiCall(options) {
320
324
  const accessToken = await loadAccessToken({ profile: options.profile });
325
+ let platformConfig;
326
+ try {
327
+ platformConfig = await loadPlatformClientConfig({ profile: options.profile });
328
+ } catch (error) {
329
+ if (!hasEnvAccessToken()) throw error;
330
+ }
321
331
  let endpointPath;
322
332
  if (options.endpoint.includes("/")) endpointPath = options.endpoint;
323
333
  else endpointPath = `tailor.v1.OperatorService/${options.endpoint}`;
324
- const url = new URL(endpointPath, platformBaseUrl);
334
+ const url = new URL(endpointPath, getPlatformBaseUrl(platformConfig));
325
335
  const response = await fetch(url.toString(), {
326
336
  method: "POST",
327
337
  headers: {
@@ -1594,7 +1604,7 @@ function copyMetadataToExtendedType(original, extended) {
1594
1604
  /**
1595
1605
  * Create a new ChangeSet for tracking resource changes.
1596
1606
  * @param title - Title for the change set
1597
- * @returns Empty ChangeSet instance with isEmpty() and print() methods
1607
+ * @returns Empty ChangeSet instance with isEmpty() and lines() methods
1598
1608
  */
1599
1609
  function createChangeSet(title) {
1600
1610
  const creates = [];
@@ -1611,17 +1621,16 @@ function createChangeSet(title) {
1611
1621
  replaces,
1612
1622
  unchanged,
1613
1623
  isEmpty,
1614
- print: () => {
1615
- if (isEmpty()) return;
1616
- logger.log(styles.bold(`${title}:`));
1617
- const printItem = (symbol, item) => {
1618
- logger.log(` ${symbol} ${item.name}`);
1619
- for (const detail of item.details ?? []) logger.log(` ${detail}`);
1620
- };
1621
- creates.forEach((item) => printItem(symbols.create, item));
1622
- deletes.forEach((item) => printItem(symbols.delete, item));
1623
- updates.forEach((item) => printItem(symbols.update, item));
1624
- replaces.forEach((item) => printItem(symbols.replace, item));
1624
+ lines: () => {
1625
+ if (isEmpty()) return [];
1626
+ const itemLines = (symbol) => (item) => [` ${symbol} ${item.name}`, ...(item.details ?? []).map((d) => ` ${d}`)];
1627
+ return [
1628
+ styles.bold(`${title}:`),
1629
+ ...creates.flatMap(itemLines(symbols.create)),
1630
+ ...deletes.flatMap(itemLines(symbols.delete)),
1631
+ ...updates.flatMap(itemLines(symbols.update)),
1632
+ ...replaces.flatMap(itemLines(symbols.replace))
1633
+ ];
1625
1634
  }
1626
1635
  };
1627
1636
  }
@@ -1635,15 +1644,13 @@ function summarizeChangeSets(changeSets) {
1635
1644
  create: 0,
1636
1645
  update: 0,
1637
1646
  delete: 0,
1638
- replace: 0,
1639
- unchanged: 0
1647
+ replace: 0
1640
1648
  };
1641
1649
  for (const changeSet of changeSets) {
1642
1650
  summary.create += changeSet.creates.length;
1643
1651
  summary.update += changeSet.updates.length;
1644
1652
  summary.delete += changeSet.deletes.length;
1645
1653
  summary.replace += changeSet.replaces.length;
1646
- summary.unchanged += changeSet.unchanged.length;
1647
1654
  }
1648
1655
  return summary;
1649
1656
  }
@@ -3047,18 +3054,19 @@ function extractServiceActions(changeSet) {
3047
3054
  ];
3048
3055
  }
3049
3056
  /**
3050
- * Print a titled section of grouped display entries, nesting by namespace.
3057
+ * Build display lines for a titled section of grouped entries, nesting by namespace.
3051
3058
  * Service-level changes are shown as the namespace header symbol.
3052
3059
  * Services without child entries are shown as flat entries.
3053
3060
  * @param title - Section title
3054
- * @param entries - Entries to print (should NOT include service entries)
3061
+ * @param entries - Entries to render (should NOT include service entries)
3055
3062
  * @param serviceActions - Optional service-level actions to merge into namespace headers
3063
+ * @returns Lines ready for output; empty array when there is nothing to show
3056
3064
  */
3057
- function printGroupedDisplaySection(title, entries, serviceActions) {
3065
+ function buildGroupedDisplayLines(title, entries, serviceActions) {
3058
3066
  const serviceMap = /* @__PURE__ */ new Map();
3059
3067
  if (serviceActions) for (const sa of serviceActions) serviceMap.set(sa.name, sa.action);
3060
- if (entries.length === 0 && serviceMap.size === 0) return;
3061
- logger.log(styles.bold(`${title}:`));
3068
+ if (entries.length === 0 && serviceMap.size === 0) return [];
3069
+ const out = [styles.bold(`${title}:`)];
3062
3070
  const namespaceOrder = [];
3063
3071
  const byNamespace = /* @__PURE__ */ new Map();
3064
3072
  for (const entry of entries) {
@@ -3075,12 +3083,13 @@ function printGroupedDisplaySection(title, entries, serviceActions) {
3075
3083
  if (ns) {
3076
3084
  const svcAction = serviceMap.get(ns);
3077
3085
  const prefix = svcAction ? `${ACTION_SYMBOLS[svcAction]} ` : "";
3078
- logger.log(` ${prefix}${styles.bold(`${ns}:`)}`);
3086
+ out.push(` ${prefix}${styles.bold(`${ns}:`)}`);
3079
3087
  printedServices.add(ns);
3080
- for (const entry of group) logger.log(` ${formatGroupedDisplayLine(entry)}`);
3081
- } else for (const entry of group) logger.log(` ${formatGroupedDisplayLine(entry)}`);
3088
+ for (const entry of group) out.push(` ${formatGroupedDisplayLine(entry)}`);
3089
+ } else for (const entry of group) out.push(` ${formatGroupedDisplayLine(entry)}`);
3082
3090
  }
3083
- for (const [name, action] of serviceMap) if (!printedServices.has(name)) logger.log(` ${ACTION_SYMBOLS[action]} ${name}`);
3091
+ for (const [name, action] of serviceMap) if (!printedServices.has(name)) out.push(` ${ACTION_SYMBOLS[action]} ${name}`);
3092
+ return out;
3084
3093
  }
3085
3094
 
3086
3095
  //#endregion
@@ -9370,7 +9379,8 @@ async function applyTailorDB(client, result, phase = "create-update") {
9370
9379
  await client.setMetadata(create.metaRequest);
9371
9380
  }), ...changeSet.service.updates.map((update) => client.setMetadata(update.metaRequest))]);
9372
9381
  try {
9373
- await Promise.all([...changeSet.type.creates.map((create) => client.createTailorDBType(create.request)), ...changeSet.type.updates.map((update) => client.updateTailorDBType(update.request))]);
9382
+ for (const create of changeSet.type.creates) await client.createTailorDBType(create.request);
9383
+ for (const update of changeSet.type.updates) await client.updateTailorDBType(update.request);
9374
9384
  } catch (error) {
9375
9385
  handleOptionalToRequiredError(error, ["Run 'tailor-sdk tailordb migration generate' to create migration files.", "Migration scripts allow you to handle existing data before applying the schema change."]);
9376
9386
  }
@@ -9495,53 +9505,45 @@ async function executeSingleMigrationPrePhase(client, changeSet, migration, tail
9495
9505
  const preMigrationChanges = buildPreMigrationChangesMap([migration]);
9496
9506
  const affectedTypes = getAffectedTypeNames(migration);
9497
9507
  const createdBeforeMigration = new Set(processedTypes.created);
9498
- await awaitAllSettledOrThrow([
9499
- ...changeSet.type.creates.filter((create) => {
9500
- const typeName = create.request.tailordbType?.name;
9501
- return typeName && affectedTypes.has(typeName) && !createdBeforeMigration.has(typeName);
9502
- }).map((create) => {
9503
- const typeName = create.request.tailordbType?.name;
9504
- const snapshotType = typeName ? buildSnapshotTypeManifest(migration, typeName, tailorDBInputs, executorUsedTypes) : void 0;
9505
- if (!snapshotType) return void 0;
9506
- if (typeName) processedTypes.created.add(typeName);
9507
- const clonedRequest = structuredClone(create.request);
9508
- clonedRequest.tailordbType = snapshotType;
9509
- const typeChanges = typeName ? preMigrationChanges.get(typeName) : void 0;
9510
- if (typeChanges && typeChanges.size > 0 && clonedRequest.tailordbType.schema?.fields) applyPreMigrationFieldAdjustments(clonedRequest.tailordbType.schema.fields, typeChanges);
9511
- return client.createTailorDBType(clonedRequest);
9512
- }),
9513
- ...changeSet.type.creates.filter((create) => {
9514
- const typeName = create.request.tailordbType?.name;
9515
- return typeName && affectedTypes.has(typeName) && createdBeforeMigration.has(typeName);
9516
- }).map((create) => {
9517
- const typeName = create.request.tailordbType?.name;
9518
- const snapshotType = typeName ? buildSnapshotTypeManifest(migration, typeName, tailorDBInputs, executorUsedTypes) : void 0;
9519
- if (!snapshotType) return void 0;
9520
- if (typeName) processedTypes.updated.add(typeName);
9521
- const clonedTypeRequest = structuredClone(snapshotType);
9522
- const typeChanges = typeName ? preMigrationChanges.get(typeName) : void 0;
9523
- if (typeChanges && typeChanges.size > 0 && clonedTypeRequest.schema?.fields) applyPreMigrationFieldAdjustments(clonedTypeRequest.schema.fields, typeChanges);
9524
- return client.updateTailorDBType({
9525
- workspaceId: create.request.workspaceId,
9526
- namespaceName: create.request.namespaceName,
9527
- tailordbType: clonedTypeRequest
9528
- });
9529
- }),
9530
- ...changeSet.type.updates.filter((update) => {
9531
- const typeName = update.request.tailordbType?.name;
9532
- return typeName && affectedTypes.has(typeName);
9533
- }).map((update) => {
9534
- const typeName = update.request.tailordbType?.name;
9535
- const snapshotType = typeName ? buildSnapshotTypeManifest(migration, typeName, tailorDBInputs, executorUsedTypes) : void 0;
9536
- if (!snapshotType) return void 0;
9537
- if (typeName) processedTypes.updated.add(typeName);
9538
- const clonedRequest = structuredClone(update.request);
9539
- clonedRequest.tailordbType = snapshotType;
9540
- const typeChanges = typeName ? preMigrationChanges.get(typeName) : void 0;
9541
- if (typeChanges && typeChanges.size > 0 && clonedRequest.tailordbType.schema?.fields) applyPreMigrationFieldAdjustments(clonedRequest.tailordbType.schema.fields, typeChanges);
9542
- return client.updateTailorDBType(clonedRequest);
9543
- })
9544
- ]);
9508
+ for (const create of changeSet.type.creates) {
9509
+ const typeName = create.request.tailordbType?.name;
9510
+ if (!typeName || !affectedTypes.has(typeName) || createdBeforeMigration.has(typeName)) continue;
9511
+ const snapshotType = buildSnapshotTypeManifest(migration, typeName, tailorDBInputs, executorUsedTypes);
9512
+ if (!snapshotType) continue;
9513
+ const clonedRequest = structuredClone(create.request);
9514
+ clonedRequest.tailordbType = snapshotType;
9515
+ const typeChanges = preMigrationChanges.get(typeName);
9516
+ if (typeChanges && typeChanges.size > 0 && clonedRequest.tailordbType.schema?.fields) applyPreMigrationFieldAdjustments(clonedRequest.tailordbType.schema.fields, typeChanges);
9517
+ processedTypes.created.add(typeName);
9518
+ await client.createTailorDBType(clonedRequest);
9519
+ }
9520
+ for (const create of changeSet.type.creates) {
9521
+ const typeName = create.request.tailordbType?.name;
9522
+ if (!typeName || !affectedTypes.has(typeName) || !createdBeforeMigration.has(typeName)) continue;
9523
+ const snapshotType = buildSnapshotTypeManifest(migration, typeName, tailorDBInputs, executorUsedTypes);
9524
+ if (!snapshotType) continue;
9525
+ const clonedTypeRequest = structuredClone(snapshotType);
9526
+ const typeChanges = preMigrationChanges.get(typeName);
9527
+ if (typeChanges && typeChanges.size > 0 && clonedTypeRequest.schema?.fields) applyPreMigrationFieldAdjustments(clonedTypeRequest.schema.fields, typeChanges);
9528
+ processedTypes.updated.add(typeName);
9529
+ await client.updateTailorDBType({
9530
+ workspaceId: create.request.workspaceId,
9531
+ namespaceName: create.request.namespaceName,
9532
+ tailordbType: clonedTypeRequest
9533
+ });
9534
+ }
9535
+ for (const update of changeSet.type.updates) {
9536
+ const typeName = update.request.tailordbType?.name;
9537
+ if (!typeName || !affectedTypes.has(typeName)) continue;
9538
+ const snapshotType = buildSnapshotTypeManifest(migration, typeName, tailorDBInputs, executorUsedTypes);
9539
+ if (!snapshotType) continue;
9540
+ const clonedRequest = structuredClone(update.request);
9541
+ clonedRequest.tailordbType = snapshotType;
9542
+ const typeChanges = preMigrationChanges.get(typeName);
9543
+ if (typeChanges && typeChanges.size > 0 && clonedRequest.tailordbType.schema?.fields) applyPreMigrationFieldAdjustments(clonedRequest.tailordbType.schema.fields, typeChanges);
9544
+ processedTypes.updated.add(typeName);
9545
+ await client.updateTailorDBType(clonedRequest);
9546
+ }
9545
9547
  if (!processedTypes.gqlPermissionsProcessed.has(migration.namespace)) {
9546
9548
  const gqlPermissionCreatesForNamespace = changeSet.gqlPermission.creates.filter((create) => create.request.namespaceName === migration.namespace);
9547
9549
  const gqlPermissionUpdatesForNamespace = changeSet.gqlPermission.updates.filter((update) => update.request.namespaceName === migration.namespace);
@@ -9550,11 +9552,11 @@ async function executeSingleMigrationPrePhase(client, changeSet, migration, tail
9550
9552
  const typeName = create.request.tailordbType?.name;
9551
9553
  return create.request.namespaceName === migration.namespace && typeName && gqlPermissionTypeNames.has(typeName) && !processedTypes.created.has(typeName);
9552
9554
  });
9553
- if (missingTypeCreates.length > 0) await awaitAllSettledOrThrow(missingTypeCreates.map((create) => {
9555
+ if (missingTypeCreates.length > 0) for (const create of missingTypeCreates) {
9554
9556
  const typeName = create.request.tailordbType?.name;
9555
9557
  if (typeName) processedTypes.created.add(typeName);
9556
- return client.createTailorDBType(create.request);
9557
- }));
9558
+ await client.createTailorDBType(create.request);
9559
+ }
9558
9560
  processedTypes.gqlPermissionsProcessed.add(migration.namespace);
9559
9561
  await awaitAllSettledOrThrow([...gqlPermissionCreatesForNamespace.map((create) => client.createTailorDBGQLPermission(create.request)), ...gqlPermissionUpdatesForNamespace.map((update) => client.updateTailorDBGQLPermission(update.request))]);
9560
9562
  }
@@ -9584,31 +9586,28 @@ async function executeSingleMigrationPostPhase(client, changeSet, migration, tai
9584
9586
  const affectedTypes = getAffectedTypeNames(migration);
9585
9587
  const deletedTypeNames = getDeletedTypeNames(migration);
9586
9588
  try {
9587
- await Promise.all([...changeSet.type.creates.filter((create) => {
9588
- const typeName = create.request.tailordbType?.name;
9589
- return typeName && affectedTypes.has(typeName) && preMigrationChanges.has(typeName);
9590
- }).map((create) => {
9589
+ for (const create of changeSet.type.creates) {
9591
9590
  const typeName = create.request.tailordbType?.name;
9592
- const snapshotType = typeName ? buildSnapshotTypeManifest(migration, typeName, tailorDBInputs, executorUsedTypes) : void 0;
9593
- if (!snapshotType) return void 0;
9594
- return client.updateTailorDBType({
9591
+ if (!typeName || !affectedTypes.has(typeName) || !preMigrationChanges.has(typeName)) continue;
9592
+ const snapshotType = buildSnapshotTypeManifest(migration, typeName, tailorDBInputs, executorUsedTypes);
9593
+ if (!snapshotType) continue;
9594
+ await client.updateTailorDBType({
9595
9595
  workspaceId: create.request.workspaceId,
9596
9596
  namespaceName: create.request.namespaceName,
9597
9597
  tailordbType: snapshotType
9598
9598
  });
9599
- }), ...changeSet.type.updates.filter((update) => {
9600
- const typeName = update.request.tailordbType?.name;
9601
- return typeName && affectedTypes.has(typeName) && preMigrationChanges.has(typeName);
9602
- }).map((update) => {
9599
+ }
9600
+ for (const update of changeSet.type.updates) {
9603
9601
  const typeName = update.request.tailordbType?.name;
9604
- const snapshotType = typeName ? buildSnapshotTypeManifest(migration, typeName, tailorDBInputs, executorUsedTypes) : void 0;
9605
- if (!snapshotType) return void 0;
9606
- return client.updateTailorDBType({
9602
+ if (!typeName || !affectedTypes.has(typeName) || !preMigrationChanges.has(typeName)) continue;
9603
+ const snapshotType = buildSnapshotTypeManifest(migration, typeName, tailorDBInputs, executorUsedTypes);
9604
+ if (!snapshotType) continue;
9605
+ await client.updateTailorDBType({
9607
9606
  workspaceId: update.request.workspaceId,
9608
9607
  namespaceName: update.request.namespaceName,
9609
9608
  tailordbType: snapshotType
9610
9609
  });
9611
- })]);
9610
+ }
9612
9611
  } catch (error) {
9613
9612
  handleOptionalToRequiredError(error, ["This error occurred during post-migration phase. Please check your migration script.", "Ensure all existing records have values for fields being changed to required."]);
9614
9613
  }
@@ -10825,7 +10824,15 @@ function computeRenamedAppDeletions(params) {
10825
10824
  const { conflicts, resourceOwners, targetAppName } = params;
10826
10825
  return [...new Set(conflicts.map((c) => c.currentOwner))].filter((owner) => !resourceOwners.has(owner) && owner !== targetAppName);
10827
10826
  }
10828
- function printPlanResults(results) {
10827
+ /**
10828
+ * Format and output the plan results, then return a summary of change counts.
10829
+ * In JSON dry-run mode a JSON payload is written to stdout. In all other modes
10830
+ * the human-readable diff goes to stdout (dry-run) or stderr (apply).
10831
+ * @param results - Planned results across all services
10832
+ * @param opts - Output options (dry-run mode flag)
10833
+ * @returns Aggregated plan summary counts
10834
+ */
10835
+ function printPlanResults(results, opts) {
10829
10836
  const executorEntries = formatExecutorChangeEntries(results.executor.changeSet, buildPlannedExecutorsByName(results.executor.changeSet), results.functionRegistry.executorFunctionChanges);
10830
10837
  const resolverEntries = formatResolverChangeEntries(results.pipeline.changeSet.resolver, results.functionRegistry.resolverFunctionChanges);
10831
10838
  const workflowEntries = formatWorkflowChangeEntries(results.workflow.changeSet, results.functionRegistry.workflowJobChanges);
@@ -10850,41 +10857,142 @@ function printPlanResults(results) {
10850
10857
  ...formatChangeSetEntries(results.auth.changeSet.connection, ["connection"], namespaceOf)
10851
10858
  ];
10852
10859
  const { otherChanges: otherFunctionRegistryChanges } = splitFunctionRegistryChanges(results.functionRegistry.changeSet);
10853
- printGroupedDisplaySection(results.functionRegistry.changeSet.title, formatChangeSetEntries(otherFunctionRegistryChanges));
10854
10860
  const tailorDBServiceActions = extractServiceActions(results.tailorDB.changeSet.service);
10855
10861
  const pipelineServiceActions = extractServiceActions(results.pipeline.changeSet.service);
10856
10862
  const idpServiceActions = extractServiceActions(results.idp.changeSet.service);
10857
10863
  const authServiceActions = extractServiceActions(results.auth.changeSet.service);
10858
- results.staticWebsite.changeSet.print();
10859
- results.staticWebsite.customDomainChangeSet.print();
10860
- results.aiGateway.changeSet.print();
10861
- results.app.print();
10862
- printGroupedDisplaySection("TailorDB", tailorDBEntries, tailorDBServiceActions);
10863
- printGroupedDisplaySection("Resolver", pipelineEntries, pipelineServiceActions);
10864
- printGroupedDisplaySection("Executor", executorEntries);
10865
- printGroupedDisplaySection("Workflow", workflowEntries);
10866
- printGroupedDisplaySection("IdP", idpEntries, idpServiceActions);
10867
- printGroupedDisplaySection("Auth", authEntries, authServiceActions);
10868
- results.secretManager.vaultChangeSet.print();
10869
- results.secretManager.secretChangeSet.print();
10870
- if (results.secretManager.skippedSecrets.length > 0) {
10871
- logger.log(styles.bold("Secret Manager secrets (skipped - no value provided):"));
10872
- for (const name of results.secretManager.skippedSecrets) logger.log(` ${styles.dim("○")} ${name}`);
10873
- }
10874
- const summary = summarizePlanResults(results, [
10864
+ const allDisplayEntries = [
10875
10865
  ...tailorDBEntries,
10876
10866
  ...pipelineEntries,
10877
10867
  ...executorEntries,
10878
10868
  ...workflowEntries,
10879
10869
  ...idpEntries,
10880
10870
  ...authEntries
10881
- ], [
10871
+ ];
10872
+ const summary = summarizePlanResults(results, allDisplayEntries, [
10882
10873
  ...tailorDBServiceActions,
10883
10874
  ...pipelineServiceActions,
10884
10875
  ...idpServiceActions,
10885
10876
  ...authServiceActions
10886
10877
  ]);
10887
- logger.log(formatPlanSummary(summary));
10878
+ const allUnmanaged = [
10879
+ ...results.functionRegistry.unmanaged,
10880
+ ...results.tailorDB.unmanaged,
10881
+ ...results.staticWebsite.unmanaged,
10882
+ ...results.aiGateway.unmanaged,
10883
+ ...results.idp.unmanaged,
10884
+ ...results.auth.unmanaged,
10885
+ ...results.pipeline.unmanaged,
10886
+ ...results.executor.unmanaged,
10887
+ ...results.workflow.unmanaged,
10888
+ ...results.secretManager.unmanaged
10889
+ ];
10890
+ const allConflicts = [
10891
+ ...results.functionRegistry.conflicts,
10892
+ ...results.tailorDB.conflicts,
10893
+ ...results.staticWebsite.conflicts,
10894
+ ...results.aiGateway.conflicts,
10895
+ ...results.idp.conflicts,
10896
+ ...results.auth.conflicts,
10897
+ ...results.pipeline.conflicts,
10898
+ ...results.executor.conflicts,
10899
+ ...results.workflow.conflicts,
10900
+ ...results.secretManager.conflicts
10901
+ ];
10902
+ if (logger.jsonMode && opts?.dryRun) {
10903
+ const changes = [
10904
+ ...allDisplayEntries,
10905
+ ...tailorDBServiceActions.map(({ action, name }) => ({
10906
+ action,
10907
+ name,
10908
+ labels: ["tailorDB"],
10909
+ namespace: void 0
10910
+ })),
10911
+ ...pipelineServiceActions.map(({ action, name }) => ({
10912
+ action,
10913
+ name,
10914
+ labels: ["pipeline"],
10915
+ namespace: void 0
10916
+ })),
10917
+ ...idpServiceActions.map(({ action, name }) => ({
10918
+ action,
10919
+ name,
10920
+ labels: ["idp"],
10921
+ namespace: void 0
10922
+ })),
10923
+ ...authServiceActions.map(({ action, name }) => ({
10924
+ action,
10925
+ name,
10926
+ labels: ["auth"],
10927
+ namespace: void 0
10928
+ })),
10929
+ ...formatChangeSetEntries(otherFunctionRegistryChanges),
10930
+ ...formatChangeSetEntries(results.staticWebsite.changeSet, ["staticWebsite"]),
10931
+ ...formatChangeSetEntries(results.staticWebsite.customDomainChangeSet, ["customDomain"]),
10932
+ ...formatChangeSetEntries(results.aiGateway.changeSet, ["aiGateway"]),
10933
+ ...formatChangeSetEntries(results.app, ["application"]),
10934
+ ...formatChangeSetEntries(results.secretManager.vaultChangeSet, ["vault"]),
10935
+ ...formatChangeSetEntries(results.secretManager.secretChangeSet, ["secret"])
10936
+ ].map(({ action, name, labels, namespace }) => ({
10937
+ action,
10938
+ name,
10939
+ labels,
10940
+ namespace
10941
+ }));
10942
+ const warnings = [...allUnmanaged.map(({ resourceType, resourceName }) => ({
10943
+ type: "unmanaged",
10944
+ resourceType,
10945
+ name: resourceName
10946
+ })), ...results.secretManager.skippedSecrets.map((name) => ({
10947
+ type: "skippedSecret",
10948
+ resourceType: "secret",
10949
+ name
10950
+ }))];
10951
+ const conflicts = allConflicts.map(({ resourceType, resourceName, currentOwner }) => ({
10952
+ resourceType,
10953
+ name: resourceName,
10954
+ currentOwner
10955
+ }));
10956
+ logger.out({
10957
+ summary,
10958
+ changes,
10959
+ warnings,
10960
+ conflicts
10961
+ });
10962
+ return summary;
10963
+ }
10964
+ const allLines = [
10965
+ ...buildGroupedDisplayLines(results.functionRegistry.changeSet.title, formatChangeSetEntries(otherFunctionRegistryChanges)),
10966
+ ...results.staticWebsite.changeSet.lines(),
10967
+ ...results.staticWebsite.customDomainChangeSet.lines(),
10968
+ ...results.aiGateway.changeSet.lines(),
10969
+ ...results.app.lines(),
10970
+ ...buildGroupedDisplayLines("TailorDB", tailorDBEntries, tailorDBServiceActions),
10971
+ ...buildGroupedDisplayLines("Resolver", pipelineEntries, pipelineServiceActions),
10972
+ ...buildGroupedDisplayLines("Executor", executorEntries),
10973
+ ...buildGroupedDisplayLines("Workflow", workflowEntries),
10974
+ ...buildGroupedDisplayLines("IdP", idpEntries, idpServiceActions),
10975
+ ...buildGroupedDisplayLines("Auth", authEntries, authServiceActions),
10976
+ ...results.secretManager.vaultChangeSet.lines(),
10977
+ ...results.secretManager.secretChangeSet.lines()
10978
+ ];
10979
+ if (allUnmanaged.length > 0) {
10980
+ allLines.push(styles.bold("Unmanaged resources (not in config):"));
10981
+ for (const { resourceType, resourceName } of allUnmanaged) allLines.push(` ${styles.warning("⚠")} ${styles.bold(resourceType)} "${resourceName}"`);
10982
+ }
10983
+ if (results.secretManager.skippedSecrets.length > 0) {
10984
+ allLines.push(styles.bold("Secret Manager secrets (skipped - no value provided):"));
10985
+ for (const name of results.secretManager.skippedSecrets) allLines.push(` ${styles.dim("○")} ${name}`);
10986
+ }
10987
+ if (allConflicts.length > 0) {
10988
+ allLines.push(styles.bold("Owner conflicts (will require confirmation on apply):"));
10989
+ for (const { resourceType, resourceName, currentOwner } of allConflicts) allLines.push(` ${styles.warning("!")} ${styles.bold(resourceType)} "${resourceName}" — owned by "${currentOwner}"`);
10990
+ }
10991
+ allLines.push(formatPlanSummary(summary));
10992
+ const output = allLines.join("\n");
10993
+ if (opts?.dryRun) logger.out(output);
10994
+ else logger.log(output);
10995
+ return summary;
10888
10996
  }
10889
10997
  /**
10890
10998
  * Summarize plan counts from display entries, service actions, and non-grouped changesets.
@@ -10898,8 +11006,7 @@ function summarizePlanResults(results, displayEntries, serviceActions) {
10898
11006
  create: 0,
10899
11007
  update: 0,
10900
11008
  delete: 0,
10901
- replace: 0,
10902
- unchanged: 0
11009
+ replace: 0
10903
11010
  };
10904
11011
  for (const entry of displayEntries) summary[entry.action] += 1;
10905
11012
  for (const sa of serviceActions) summary[sa.action] += 1;
@@ -11137,7 +11244,7 @@ async function deploy(options) {
11137
11244
  }
11138
11245
  });
11139
11246
  });
11140
- printPlanResults({
11247
+ const planSummary = printPlanResults({
11141
11248
  functionRegistry,
11142
11249
  tailorDB,
11143
11250
  staticWebsite,
@@ -11149,7 +11256,7 @@ async function deploy(options) {
11149
11256
  executor,
11150
11257
  workflow,
11151
11258
  secretManager
11152
- });
11259
+ }, { dryRun: options?.dryRun });
11153
11260
  if (options?.noValidate) logger.warn("Client-side validation skipped (--no-validate).");
11154
11261
  else await validatePlan({
11155
11262
  functionRegistry,
@@ -11202,7 +11309,11 @@ async function deploy(options) {
11202
11309
  await applyTailorDB(client, tailorDB, "delete-services");
11203
11310
  });
11204
11311
  await withSpan("apply.cleanup", () => applyFunctionRegistry(client, workspaceId, functionRegistry, "delete"));
11205
- logger.success("Successfully applied changes.");
11312
+ if (logger.jsonMode) logger.out({
11313
+ summary: planSummary,
11314
+ status: "applied"
11315
+ });
11316
+ else logger.success("Successfully applied changes.");
11206
11317
  });
11207
11318
  }
11208
11319
 
@@ -15161,31 +15272,34 @@ async function execRemove(client, workspaceId, application, config, confirm) {
15161
15272
  const workflow = await planWorkflow(client, workspaceId, application.name, application.id, {}, {});
15162
15273
  const functionRegistry = await planFunctionRegistry(client, workspaceId, application.name, application.id, []);
15163
15274
  const secretManager = await planSecretManager(ctx);
15164
- functionRegistry.changeSet.print();
15165
- staticWebsite.changeSet.print();
15166
- aiGateway.changeSet.print();
15167
- app.print();
15168
- tailorDB.changeSet.service.print();
15169
- tailorDB.changeSet.type.print();
15170
- tailorDB.changeSet.gqlPermission.print();
15171
- pipeline.changeSet.service.print();
15172
- pipeline.changeSet.resolver.print();
15173
- executor.changeSet.print();
15174
- workflow.changeSet.print();
15175
- idp.changeSet.service.print();
15176
- idp.changeSet.client.print();
15177
- auth.changeSet.service.print();
15178
- auth.changeSet.idpConfig.print();
15179
- auth.changeSet.userProfileConfig.print();
15180
- auth.changeSet.tenantConfig.print();
15181
- auth.changeSet.machineUser.print();
15182
- auth.changeSet.oauth2Client.print();
15183
- auth.changeSet.authHook.print();
15184
- auth.changeSet.scim.print();
15185
- auth.changeSet.scimResource.print();
15186
- auth.changeSet.connection.print();
15187
- secretManager.vaultChangeSet.print();
15188
- secretManager.secretChangeSet.print();
15275
+ const removeLines = [
15276
+ ...functionRegistry.changeSet.lines(),
15277
+ ...staticWebsite.changeSet.lines(),
15278
+ ...aiGateway.changeSet.lines(),
15279
+ ...app.lines(),
15280
+ ...tailorDB.changeSet.service.lines(),
15281
+ ...tailorDB.changeSet.type.lines(),
15282
+ ...tailorDB.changeSet.gqlPermission.lines(),
15283
+ ...pipeline.changeSet.service.lines(),
15284
+ ...pipeline.changeSet.resolver.lines(),
15285
+ ...executor.changeSet.lines(),
15286
+ ...workflow.changeSet.lines(),
15287
+ ...idp.changeSet.service.lines(),
15288
+ ...idp.changeSet.client.lines(),
15289
+ ...auth.changeSet.service.lines(),
15290
+ ...auth.changeSet.idpConfig.lines(),
15291
+ ...auth.changeSet.userProfileConfig.lines(),
15292
+ ...auth.changeSet.tenantConfig.lines(),
15293
+ ...auth.changeSet.machineUser.lines(),
15294
+ ...auth.changeSet.oauth2Client.lines(),
15295
+ ...auth.changeSet.authHook.lines(),
15296
+ ...auth.changeSet.scim.lines(),
15297
+ ...auth.changeSet.scimResource.lines(),
15298
+ ...auth.changeSet.connection.lines(),
15299
+ ...secretManager.vaultChangeSet.lines(),
15300
+ ...secretManager.secretChangeSet.lines()
15301
+ ];
15302
+ if (removeLines.length > 0) logger.log(removeLines.join("\n"));
15189
15303
  if (tailorDB.changeSet.service.deletes.length === 0 && staticWebsite.changeSet.deletes.length === 0 && aiGateway.changeSet.deletes.length === 0 && idp.changeSet.service.deletes.length === 0 && auth.changeSet.service.deletes.length === 0 && pipeline.changeSet.service.deletes.length === 0 && app.deletes.length === 0 && executor.changeSet.deletes.length === 0 && workflow.changeSet.deletes.length === 0 && functionRegistry.changeSet.deletes.length === 0 && secretManager.vaultChangeSet.deletes.length === 0 && secretManager.secretChangeSet.deletes.length === 0) return;
15190
15304
  if (confirm) await confirm();
15191
15305
  await applyWorkflow(client, workflow, "delete");
@@ -15255,6 +15369,36 @@ function logBetaWarning(featureName) {
15255
15369
  logger.newline();
15256
15370
  }
15257
15371
 
15372
+ //#endregion
15373
+ //#region src/cli/shared/config.ts
15374
+ /**
15375
+ * Extracts every namespace key declared under `config.db`, including those
15376
+ * declared with `{ external: true }`.
15377
+ * @param config - Loaded application configuration.
15378
+ * @returns Namespace names in insertion order.
15379
+ */
15380
+ function extractAllNamespaces(config) {
15381
+ const namespaces = /* @__PURE__ */ new Set();
15382
+ if (config.db) for (const namespaceName of Object.keys(config.db)) namespaces.add(namespaceName);
15383
+ return Array.from(namespaces);
15384
+ }
15385
+ /**
15386
+ * Extracts namespace keys under `config.db` that this app owns
15387
+ * (i.e. not declared with `{ external: true }`). Use this for destructive
15388
+ * operations like `tailordb truncate --all` to avoid touching namespaces
15389
+ * owned by other apps.
15390
+ * @param config - Loaded application configuration.
15391
+ * @returns Owned namespace names in insertion order.
15392
+ */
15393
+ function extractOwnedNamespaces(config) {
15394
+ const namespaces = /* @__PURE__ */ new Set();
15395
+ if (config.db) for (const [namespaceName, nsConfig] of Object.entries(config.db)) {
15396
+ if ("external" in nsConfig) continue;
15397
+ namespaces.add(namespaceName);
15398
+ }
15399
+ return Array.from(namespaces);
15400
+ }
15401
+
15258
15402
  //#endregion
15259
15403
  //#region src/cli/commands/workspace/transform.ts
15260
15404
  const workspaceInfo = (workspace, folderName) => {
@@ -15978,7 +16122,7 @@ async function generate(options) {
15978
16122
  if (options.init) await handleInitOption(namespacesWithMigrations, options.yes);
15979
16123
  let pluginManager;
15980
16124
  if (plugins.length > 0) pluginManager = new PluginManager(plugins);
15981
- const { defineApplication } = await import("./application-Br48NXBD.mjs");
16125
+ const { defineApplication } = await import("./application-BakHtldG.mjs");
15982
16126
  const application = defineApplication({
15983
16127
  config,
15984
16128
  pluginManager
@@ -16122,36 +16266,6 @@ const generateCommand = defineAppCommand({
16122
16266
  }
16123
16267
  });
16124
16268
 
16125
- //#endregion
16126
- //#region src/cli/shared/config.ts
16127
- /**
16128
- * Extracts every namespace key declared under `config.db`, including those
16129
- * declared with `{ external: true }`.
16130
- * @param config - Loaded application configuration.
16131
- * @returns Namespace names in insertion order.
16132
- */
16133
- function extractAllNamespaces(config) {
16134
- const namespaces = /* @__PURE__ */ new Set();
16135
- if (config.db) for (const namespaceName of Object.keys(config.db)) namespaces.add(namespaceName);
16136
- return Array.from(namespaces);
16137
- }
16138
- /**
16139
- * Extracts namespace keys under `config.db` that this app owns
16140
- * (i.e. not declared with `{ external: true }`). Use this for destructive
16141
- * operations like `tailordb truncate --all` to avoid touching namespaces
16142
- * owned by other apps.
16143
- * @param config - Loaded application configuration.
16144
- * @returns Owned namespace names in insertion order.
16145
- */
16146
- function extractOwnedNamespaces(config) {
16147
- const namespaces = /* @__PURE__ */ new Set();
16148
- if (config.db) for (const [namespaceName, nsConfig] of Object.entries(config.db)) {
16149
- if ("external" in nsConfig) continue;
16150
- namespaces.add(namespaceName);
16151
- }
16152
- return Array.from(namespaces);
16153
- }
16154
-
16155
16269
  //#endregion
16156
16270
  //#region src/cli/shared/tailordb-namespace.ts
16157
16271
  /**
@@ -16742,6 +16856,15 @@ const validateRegion = async (region, client) => {
16742
16856
  const availableRegions = await client.listAvailableWorkspaceRegions({});
16743
16857
  if (!availableRegions.regions.includes(region)) throw new Error(`Region must be one of: ${availableRegions.regions.join(", ")}.`);
16744
16858
  };
16859
+ function profilePlatformSettings(platformConfig) {
16860
+ const hasOAuth2ClientId = platformConfig?.oauth2ClientId || process.env.TAILOR_PLATFORM_OAUTH2_CLIENT_ID;
16861
+ const hasConsoleUrl = platformConfig?.consoleUrl || process.env.TAILOR_PLATFORM_CONSOLE_URL;
16862
+ return {
16863
+ ...isDefaultPlatform(platformConfig) ? {} : { platform_url: getPlatformBaseUrl(platformConfig) },
16864
+ ...hasOAuth2ClientId ? { oauth2_client_id: getOAuth2ClientId(platformConfig) } : {},
16865
+ ...hasConsoleUrl ? { console_url: getConsoleBaseUrl(platformConfig) } : {}
16866
+ };
16867
+ }
16745
16868
  /**
16746
16869
  * Create a new workspace with the given options.
16747
16870
  * @param options - Workspace creation options
@@ -16796,6 +16919,23 @@ const createCommand = defineAppCommand({
16796
16919
  }).strict(),
16797
16920
  run: async (args) => {
16798
16921
  await assertWritable();
16922
+ const profileName = args["profile-name"];
16923
+ let profileSetup;
16924
+ if (profileName) {
16925
+ const config = await readPlatformConfig();
16926
+ if (config.profiles[profileName]) throw new Error(`Profile "${profileName}" already exists.`);
16927
+ const activeProfileName = process.env.TAILOR_PLATFORM_PROFILE;
16928
+ const activeProfileEntry = activeProfileName ? config.profiles[activeProfileName] : void 0;
16929
+ const platformConfig = activeProfileEntry ? platformConfigFromProfile(activeProfileEntry) : void 0;
16930
+ const profileUser = args["profile-user"] || activeProfileEntry?.user || config.current_user;
16931
+ if (!profileUser) throw new Error("Current user not found. Please login or specify --profile-user to create a profile.");
16932
+ if (!hasUserTokenEntry(config, profileUser, platformConfig)) throw new Error(`User "${profileUser}" not found.\nPlease verify your user name and login using 'tailor-sdk login' command.`);
16933
+ profileSetup = {
16934
+ name: profileName,
16935
+ user: profileUser,
16936
+ platformSettings: profilePlatformSettings(platformConfig)
16937
+ };
16938
+ }
16799
16939
  const workspace = await createWorkspace({
16800
16940
  name: args.name,
16801
16941
  region: args.region,
@@ -16804,26 +16944,26 @@ const createCommand = defineAppCommand({
16804
16944
  folderId: args["folder-id"]
16805
16945
  });
16806
16946
  let profileInfo;
16807
- const profileName = args["profile-name"];
16808
- if (profileName) {
16947
+ if (profileSetup) {
16809
16948
  const config = await readPlatformConfig();
16810
- if (config.profiles[profileName]) throw new Error(`Profile "${profileName}" already exists.`);
16811
- const profileUser = args["profile-user"] || config.current_user;
16812
- if (!profileUser) throw new Error("Current user not found. Please login or specify --profile-user to create a profile.");
16813
- if (!config.users[profileUser]) throw new Error(`User "${profileUser}" not found.\nPlease verify your user name and login using 'tailor-sdk login' command.`);
16814
- config.profiles[profileName] = {
16815
- user: profileUser,
16949
+ const platformSettings = profileSetup.platformSettings;
16950
+ config.profiles[profileSetup.name] = {
16951
+ user: profileSetup.user,
16816
16952
  workspace_id: workspace.id,
16817
- ...args.permission === "read" ? { readonly: true } : {}
16953
+ ...args.permission === "read" ? { readonly: true } : {},
16954
+ ...platformSettings
16818
16955
  };
16819
16956
  writePlatformConfig(config);
16820
16957
  profileInfo = {
16821
- name: profileName,
16822
- user: profileUser,
16958
+ name: profileSetup.name,
16959
+ user: profileSetup.user,
16823
16960
  workspaceId: workspace.id,
16824
- permission: args.permission
16961
+ permission: args.permission,
16962
+ ...platformSettings.platform_url ? { platformUrl: platformSettings.platform_url } : {},
16963
+ ...platformSettings.oauth2_client_id ? { oauth2ClientId: platformSettings.oauth2_client_id } : {},
16964
+ ...platformSettings.console_url ? { consoleUrl: platformSettings.console_url } : {}
16825
16965
  };
16826
- if (!args.json) logger.success(`Profile "${profileName}" created successfully.`);
16966
+ if (!args.json) logger.success(`Profile "${profileSetup.name}" created successfully.`);
16827
16967
  }
16828
16968
  if (!args.json) logger.success(`Workspace "${workspaceDisplayName(workspace)}" created successfully.`);
16829
16969
  if (args.json && profileInfo) {
@@ -18246,5 +18386,5 @@ function isDeno() {
18246
18386
  }
18247
18387
 
18248
18388
  //#endregion
18249
- export { updateCommand$2 as $, protoGqlPermission as $t, listCommand$3 as A, apiCall as An, jobsCommand as At, show as B, toPageDirection as Bn, functionExecutionStatusToString as Bt, listCommand$2 as C, ensureConfigId as Cn, webhookCommand as Ct, waitWorkflowExecution as D, generateUserTypes as Dn, listExecutors as Dt, waitCommand as E, PluginManager as En, listCommand$9 as Et, generateCommand as F, confirmationArgs as Fn, getCommand$5 as Ft, updateCommand$1 as G, executeScript as Gt, logBetaWarning as H, getCommand$6 as Ht, generateMigrationScript as I, deploymentArgs as In, getWorkflow as It, treeCommand as J, MIGRATION_LABEL_KEY as Jt, updateOrganization as K, waitForExecution as Kt, writeDbTypesFile as L, isVerbose as Ln, executionsCommand as Lt, truncate as M, defineAppCommand as Mn, watchExecutorJob as Mt, truncateCommand as N, commonArgs as Nn, startCommand as Nt, resumeCommand as O, prompt as On, getExecutorJob as Ot, generate as P, configArg as Pn, startWorkflow as Pt, getOrganization as Q, generateAllTypeManifestsFromSnapshot as Qt, getConfiguredEditorCommand as R, pagedLogArgs as Rn, getWorkflowExecution as Rt, listApps as S, getNamespacesWithMigrations as Sn, listWebhookExecutors as St, healthCommand as T, sdkNameLabelKey as Tn, triggerExecutor as Tt, remove as U, getExecutor as Ut, showCommand as V, workspaceArgs as Vn, formatKeyValueTable as Vt, removeCommand$1 as W, deploy as Wt, listOrganizations as X, parseMigrationLabelNumber as Xt, listCommand$4 as Y, handleOptionalToRequiredError as Yt, getCommand$1 as Z, compareSnapshotWithRemote as Zt, getWorkspace as _, formatMigrationNumber as _n, generate$1 as _t, updateUser as a, assertValidMigrationFiles as an, deleteCommand$1 as at, createCommand as b, formatMigrationDiff as bn, getCommand$4 as bt, listCommand as c, createSnapshotFromLocalTypes as cn, createFolder as ct, inviteUser as d, getMigrationFilePath as dn, getCommand$3 as dt, DB_TYPES_FILE_NAME as en, updateFolder as et, restoreCommand as f, getMigrationFiles as fn, getOAuth2Client as ft, getCommand as g, reconstructSnapshotFromMigrations as gn, listMachineUsers as gt, listWorkspaces as h, loadDiff as hn, listCommand$7 as ht, updateCommand as i, SCHEMA_FILE_NAME as in, getFolder as it, listWorkflows as j, assertWritable as jn, listExecutorJobs as jt, resumeWorkflow as k, apiCommand as kn, getExecutorWaitFailureMessage as kt, listUsers as l, getLatestMigrationNumber as ln, listCommand$6 as lt, listCommand$1 as m, isValidMigrationNumber as mn, tokenCommand as mt, query as n, INITIAL_SCHEMA_NUMBER as nn, listFolders as nt, removeCommand as o, compareLocalTypesWithSnapshot as on, deleteFolder as ot, restoreWorkspace as p, getNextMigrationNumber as pn, getMachineUserToken as pt, organizationTree as q, bundleMigrationScript as qt, queryCommand as r, MIGRATE_FILE_NAME as rn, getCommand$2 as rt, removeUser as s, compareSnapshots as sn, createCommand$1 as st, isNativeTypeScriptRuntime as t, DIFF_FILE_NAME as tn, listCommand$5 as tt, inviteCommand as u, getMigrationDirPath as un, listOAuth2Clients as ut, deleteCommand as v, parseMigrationNumberArg as vn, listCommand$8 as vt, getAppHealth as w, resourceTrn as wn, triggerCommand as wt, createWorkspace as x, hasChanges as xn, getFunctionRegistry as xt, deleteWorkspace as y, formatDiffSummary as yn, listFunctionRegistries as yt, openInConfiguredEditor as z, paginationArgs as zn, listWorkflowExecutions as zt };
18250
- //# sourceMappingURL=runtime-jowoN6qC.mjs.map
18389
+ export { getOrganization as $, generateAllTypeManifestsFromSnapshot as $t, listCommand$3 as A, apiCommand as An, getExecutorWaitFailureMessage as At, show as B, paginationArgs as Bn, listWorkflowExecutions as Bt, listCommand$2 as C, getNamespacesWithMigrations as Cn, listWebhookExecutors as Ct, waitWorkflowExecution as D, PluginManager as Dn, listCommand$9 as Dt, waitCommand as E, sdkNameLabelKey as En, triggerExecutor as Et, generateCommand as F, configArg as Fn, startWorkflow as Ft, removeCommand$1 as G, deploy as Gt, extractOwnedNamespaces as H, workspaceArgs as Hn, formatKeyValueTable as Ht, generateMigrationScript as I, confirmationArgs as In, getCommand$5 as It, organizationTree as J, bundleMigrationScript as Jt, updateCommand$1 as K, executeScript as Kt, writeDbTypesFile as L, deploymentArgs as Ln, getWorkflow as Lt, truncate as M, assertWritable as Mn, listExecutorJobs as Mt, truncateCommand as N, defineAppCommand as Nn, watchExecutorJob as Nt, resumeCommand as O, generateUserTypes as On, listExecutors as Ot, generate as P, commonArgs as Pn, startCommand as Pt, getCommand$1 as Q, compareSnapshotWithRemote as Qt, getConfiguredEditorCommand as R, isVerbose as Rn, executionsCommand as Rt, listApps as S, hasChanges as Sn, getFunctionRegistry as St, healthCommand as T, resourceTrn as Tn, triggerCommand as Tt, logBetaWarning as U, getCommand$6 as Ut, showCommand as V, toPageDirection as Vn, functionExecutionStatusToString as Vt, remove as W, getExecutor as Wt, listCommand$4 as X, handleOptionalToRequiredError as Xt, treeCommand as Y, MIGRATION_LABEL_KEY as Yt, listOrganizations as Z, parseMigrationLabelNumber as Zt, getWorkspace as _, reconstructSnapshotFromMigrations as _n, listMachineUsers as _t, updateUser as a, SCHEMA_FILE_NAME as an, getFolder as at, createCommand as b, formatDiffSummary as bn, listFunctionRegistries as bt, listCommand as c, compareSnapshots as cn, createCommand$1 as ct, inviteUser as d, getMigrationDirPath as dn, listOAuth2Clients as dt, protoGqlPermission as en, updateCommand$2 as et, restoreCommand as f, getMigrationFilePath as fn, getCommand$3 as ft, getCommand as g, loadDiff as gn, listCommand$7 as gt, listWorkspaces as h, isValidMigrationNumber as hn, tokenCommand as ht, updateCommand as i, MIGRATE_FILE_NAME as in, getCommand$2 as it, listWorkflows as j, apiCall as jn, jobsCommand as jt, resumeWorkflow as k, prompt as kn, getExecutorJob as kt, listUsers as l, createSnapshotFromLocalTypes as ln, createFolder as lt, listCommand$1 as m, getNextMigrationNumber as mn, getMachineUserToken as mt, query as n, DIFF_FILE_NAME as nn, listCommand$5 as nt, removeCommand as o, assertValidMigrationFiles as on, deleteCommand$1 as ot, restoreWorkspace as p, getMigrationFiles as pn, getOAuth2Client as pt, updateOrganization as q, waitForExecution as qt, queryCommand as r, INITIAL_SCHEMA_NUMBER as rn, listFolders as rt, removeUser as s, compareLocalTypesWithSnapshot as sn, deleteFolder as st, isNativeTypeScriptRuntime as t, DB_TYPES_FILE_NAME as tn, updateFolder as tt, inviteCommand as u, getLatestMigrationNumber as un, listCommand$6 as ut, deleteCommand as v, formatMigrationNumber as vn, generate$1 as vt, getAppHealth as w, ensureConfigId as wn, webhookCommand as wt, createWorkspace as x, formatMigrationDiff as xn, getCommand$4 as xt, deleteWorkspace as y, parseMigrationNumberArg as yn, listCommand$8 as yt, openInConfiguredEditor as z, pagedLogArgs as zn, getWorkflowExecution as zt };
18390
+ //# sourceMappingURL=runtime-CSY0eD4_.mjs.map