@tailor-platform/sdk 0.22.4 → 0.23.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.
@@ -1610,11 +1610,11 @@ const AuthConfigSchema = z.object({
1610
1610
  //#region src/cli/application/auth/service.ts
1611
1611
  var AuthService = class {
1612
1612
  _userProfile;
1613
- _tenantProvider;
1614
1613
  _parsedConfig;
1615
- constructor(config, tailorDBServices) {
1614
+ constructor(config, tailorDBServices, externalTailorDBNamespaces) {
1616
1615
  this.config = config;
1617
1616
  this.tailorDBServices = tailorDBServices;
1617
+ this.externalTailorDBNamespaces = externalTailorDBNamespaces;
1618
1618
  this._parsedConfig = {
1619
1619
  ...config,
1620
1620
  idProvider: IdProviderSchema.optional().parse(config.idProvider)
@@ -1623,46 +1623,45 @@ var AuthService = class {
1623
1623
  get userProfile() {
1624
1624
  return this._userProfile;
1625
1625
  }
1626
- get tenantProvider() {
1627
- return this._tenantProvider;
1628
- }
1629
1626
  get parsedConfig() {
1630
1627
  return this._parsedConfig;
1631
1628
  }
1629
+ /**
1630
+ * Resolves namespace for userProfile.
1631
+ *
1632
+ * Resolution priority:
1633
+ * 1. Explicit namespace in config
1634
+ * 2. Single TailorDB (regular or external) → use that namespace
1635
+ * 3. Multiple TailorDBs → search by type name (external cannot be searched)
1636
+ */
1632
1637
  async resolveNamespaces() {
1633
- await Promise.all(this.tailorDBServices.map((service) => service.loadTypes()));
1634
- if (this.tailorDBServices.length === 1) {
1635
- const singleNamespace = this.tailorDBServices[0].namespace;
1636
- this._userProfile = this.config.userProfile ? {
1638
+ if (!this.config.userProfile) return;
1639
+ if (this.config.userProfile.namespace) {
1640
+ this._userProfile = {
1637
1641
  ...this.config.userProfile,
1638
- namespace: singleNamespace
1639
- } : void 0;
1640
- this._tenantProvider = this.config.tenantProvider ? {
1641
- ...this.config.tenantProvider,
1642
- namespace: singleNamespace
1643
- } : void 0;
1642
+ namespace: this.config.userProfile.namespace
1643
+ };
1644
1644
  return;
1645
1645
  }
1646
- const userProfileTypeName = this.config.userProfile?.type && typeof this.config.userProfile.type === "object" && "name" in this.config.userProfile.type ? this.config.userProfile.type.name : void 0;
1647
- const tenantProviderTypeName = typeof this.config.tenantProvider?.type === "string" ? this.config.tenantProvider.type : void 0;
1646
+ const totalNamespaceCount = this.tailorDBServices.length + this.externalTailorDBNamespaces.length;
1648
1647
  let userProfileNamespace;
1649
- let tenantProviderNamespace;
1650
- for (const service of this.tailorDBServices) {
1651
- const types$2 = service.getTypes();
1652
- if (userProfileTypeName && !userProfileNamespace && Object.prototype.hasOwnProperty.call(types$2, userProfileTypeName)) userProfileNamespace = service.namespace;
1653
- if (tenantProviderTypeName && !tenantProviderNamespace && Object.prototype.hasOwnProperty.call(types$2, tenantProviderTypeName)) tenantProviderNamespace = service.namespace;
1654
- if (userProfileNamespace && tenantProviderNamespace) break;
1655
- }
1656
- if (this.config.userProfile && !userProfileNamespace) throw new Error(`userProfile type "${this.config.userProfile.type.name}" not found in any TailorDB namespace`);
1657
- if (this.config.tenantProvider && !tenantProviderNamespace) throw new Error(`tenantProvider type "${this.config.tenantProvider.type}" not found in any TailorDB namespace`);
1658
- this._userProfile = this.config.userProfile ? {
1648
+ if (totalNamespaceCount === 1) userProfileNamespace = this.tailorDBServices[0]?.namespace ?? this.externalTailorDBNamespaces[0];
1649
+ else {
1650
+ await Promise.all(this.tailorDBServices.map((service) => service.loadTypes()));
1651
+ const userProfileTypeName = typeof this.config.userProfile.type === "object" && "name" in this.config.userProfile.type ? this.config.userProfile.type.name : void 0;
1652
+ if (userProfileTypeName) for (const service of this.tailorDBServices) {
1653
+ const types$2 = service.getTypes();
1654
+ if (Object.prototype.hasOwnProperty.call(types$2, userProfileTypeName)) {
1655
+ userProfileNamespace = service.namespace;
1656
+ break;
1657
+ }
1658
+ }
1659
+ if (!userProfileNamespace) throw new Error(`userProfile type "${this.config.userProfile.type.name}" not found in any TailorDB namespace`);
1660
+ }
1661
+ this._userProfile = {
1659
1662
  ...this.config.userProfile,
1660
1663
  namespace: userProfileNamespace
1661
- } : void 0;
1662
- this._tenantProvider = this.config.tenantProvider ? {
1663
- ...this.config.tenantProvider,
1664
- namespace: tenantProviderNamespace
1665
- } : void 0;
1664
+ };
1666
1665
  }
1667
1666
  };
1668
1667
 
@@ -98423,6 +98422,7 @@ const StaticWebsiteSchema = z.object({
98423
98422
  //#region src/cli/application/index.ts
98424
98423
  var Application = class {
98425
98424
  _tailorDBServices = [];
98425
+ _externalTailorDBNamespaces = [];
98426
98426
  _resolverServices = [];
98427
98427
  _idpServices = [];
98428
98428
  _authService = void 0;
@@ -98448,6 +98448,9 @@ var Application = class {
98448
98448
  get tailorDBServices() {
98449
98449
  return this._tailorDBServices;
98450
98450
  }
98451
+ get externalTailorDBNamespaces() {
98452
+ return this._externalTailorDBNamespaces;
98453
+ }
98451
98454
  get resolverServices() {
98452
98455
  return this._resolverServices;
98453
98456
  }
@@ -98475,7 +98478,8 @@ var Application = class {
98475
98478
  defineTailorDB(config) {
98476
98479
  if (!config) return;
98477
98480
  for (const [namespace, serviceConfig] of Object.entries(config)) {
98478
- if (!("external" in serviceConfig)) {
98481
+ if ("external" in serviceConfig) this._externalTailorDBNamespaces.push(namespace);
98482
+ else {
98479
98483
  const tailorDB = new TailorDBService(namespace, serviceConfig);
98480
98484
  this._tailorDBServices.push(tailorDB);
98481
98485
  }
@@ -98508,7 +98512,7 @@ var Application = class {
98508
98512
  }
98509
98513
  defineAuth(config) {
98510
98514
  if (!config) return;
98511
- if (!("external" in config)) this._authService = new AuthService(config, this.tailorDBServices);
98515
+ if (!("external" in config)) this._authService = new AuthService(config, this.tailorDBServices, this.externalTailorDBNamespaces);
98512
98516
  this.addSubgraph("auth", config.name);
98513
98517
  }
98514
98518
  defineExecutor(config) {
@@ -101536,24 +101540,24 @@ async function planTenantConfigs(client, workspaceId, auths, deletedServices) {
101536
101540
  });
101537
101541
  } catch (error) {
101538
101542
  if (error instanceof ConnectError && error.code === Code.NotFound) {
101539
- if (auth.tenantProvider) changeSet.creates.push({
101543
+ if (config.tenantProvider) changeSet.creates.push({
101540
101544
  name: name$1,
101541
101545
  request: {
101542
101546
  workspaceId,
101543
101547
  namespaceName: config.name,
101544
- tenantProviderConfig: protoTenantConfig(auth.tenantProvider)
101548
+ tenantProviderConfig: protoTenantConfig(config.tenantProvider)
101545
101549
  }
101546
101550
  });
101547
101551
  continue;
101548
101552
  }
101549
101553
  throw error;
101550
101554
  }
101551
- if (auth.tenantProvider) changeSet.updates.push({
101555
+ if (config.tenantProvider) changeSet.updates.push({
101552
101556
  name: name$1,
101553
101557
  request: {
101554
101558
  workspaceId,
101555
101559
  namespaceName: config.name,
101556
- tenantProviderConfig: protoTenantConfig(auth.tenantProvider)
101560
+ tenantProviderConfig: protoTenantConfig(config.tenantProvider)
101557
101561
  }
101558
101562
  });
101559
101563
  else changeSet.deletes.push({
@@ -103528,7 +103532,7 @@ const applyCommand = defineCommand({
103528
103532
  "dry-run": {
103529
103533
  type: "boolean",
103530
103534
  description: "Run the command without making any changes",
103531
- alias: "n"
103535
+ alias: "d"
103532
103536
  },
103533
103537
  yes: {
103534
103538
  type: "boolean",
@@ -105448,7 +105452,7 @@ const createCommand = defineCommand({
105448
105452
  type: "string",
105449
105453
  description: "Workspace name",
105450
105454
  required: true,
105451
- alias: "N"
105455
+ alias: "n"
105452
105456
  },
105453
105457
  region: {
105454
105458
  type: "string",
@@ -105459,7 +105463,7 @@ const createCommand = defineCommand({
105459
105463
  "delete-protection": {
105460
105464
  type: "boolean",
105461
105465
  description: "Enable delete protection",
105462
- alias: "D",
105466
+ alias: "d",
105463
105467
  default: false
105464
105468
  },
105465
105469
  "organization-id": {
@@ -105596,4 +105600,4 @@ const listCommand = defineCommand({
105596
105600
 
105597
105601
  //#endregion
105598
105602
  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 };
105599
- //# sourceMappingURL=list-BSi-MJbT.mjs.map
105603
+ //# sourceMappingURL=list-CW_wMSAo.mjs.map