@tailor-platform/sdk 1.12.0 → 1.13.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/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # @tailor-platform/sdk
2
2
 
3
+ ## 1.13.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#580](https://github.com/tailor-platform/sdk/pull/580) [`74c2dfc`](https://github.com/tailor-platform/sdk/commit/74c2dfcb3e33d8d2548d7a948e5e322745e4a54c) Thanks [@toiroakr](https://github.com/toiroakr)! - Always generate exec.mjs for seed generator and add --machine-user option
8
+
9
+ - exec.mjs is now generated regardless of whether `machineUserName` is configured
10
+ - Added `--machine-user` (`-m`) CLI option to specify machine user at runtime
11
+ - CLI argument takes precedence over config default, allowing override
12
+ - Shows clear error message when machine user is not specified and not configured
13
+
3
14
  ## 1.12.0
4
15
 
5
16
  ### Minor Changes
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import "../chunk-C3Kl5s5P.mjs";
3
3
  import "../schema-BmKdDzr1.mjs";
4
- import { $ as jobsCommand, $t as initOperatorClient, A as generateCommand, At as getMigrationFiles, C as resumeCommand, Et as formatMigrationNumber, F as removeCommand$1, G as generateCommand$1, Gt as fetchLatestToken, H as listCommand$6, I as listCommand$7, J as triggerCommand, Jt as readPlatformConfig, Kt as loadAccessToken, Mt as isValidMigrationNumber, N as showCommand, Nt as loadDiff, O as truncateCommand, Qt as initOAuth2Client, R as getCommand$2, Rt as getNamespacesWithMigrations, S as healthCommand, T as listCommand$8, V as tokenCommand, Vt as loadConfig, Wt as apiCommand, X as listCommand$5, Xt as fetchAll, Yt as writePlatformConfig, Zt as fetchUserInfo, _ as createCommand$3, a as listCommand$10, an as jsonArgs, b as listCommand$9, d as listCommand$11, en as readPackageJson, ft as applyCommand, gt as parseMigrationLabelNumber, h as deleteCommand$3, in as deploymentArgs, it as getCommand$3, j as logBetaWarning, kt as getMigrationFilePath, l as restoreCommand, lt as getCommand$1, nn as commonArgs, nt as startCommand, on as withCommonArgs, ot as executionsCommand, p as getCommand$4, q as webhookCommand, qt as loadWorkspaceId, r as removeCommand, rn as confirmationArgs, s as inviteCommand, sn as workspaceArgs, t as updateCommand$2, tn as PATScope, zt as trnPrefix } from "../update-B_W-UQnS.mjs";
4
+ import { $ as jobsCommand, $t as initOperatorClient, A as generateCommand, At as getMigrationFiles, C as resumeCommand, Et as formatMigrationNumber, F as removeCommand$1, G as generateCommand$1, Gt as fetchLatestToken, H as listCommand$6, I as listCommand$7, J as triggerCommand, Jt as readPlatformConfig, Kt as loadAccessToken, Mt as isValidMigrationNumber, N as showCommand, Nt as loadDiff, O as truncateCommand, Qt as initOAuth2Client, R as getCommand$2, Rt as getNamespacesWithMigrations, S as healthCommand, T as listCommand$8, V as tokenCommand, Vt as loadConfig, Wt as apiCommand, X as listCommand$5, Xt as fetchAll, Yt as writePlatformConfig, Zt as fetchUserInfo, _ as createCommand$3, a as listCommand$10, an as jsonArgs, b as listCommand$9, d as listCommand$11, en as readPackageJson, ft as applyCommand, gt as parseMigrationLabelNumber, h as deleteCommand$3, in as deploymentArgs, it as getCommand$3, j as logBetaWarning, kt as getMigrationFilePath, l as restoreCommand, lt as getCommand$1, nn as commonArgs, nt as startCommand, on as withCommonArgs, ot as executionsCommand, p as getCommand$4, q as webhookCommand, qt as loadWorkspaceId, r as removeCommand, rn as confirmationArgs, s as inviteCommand, sn as workspaceArgs, t as updateCommand$2, tn as PATScope, zt as trnPrefix } from "../update-CUvANRhs.mjs";
5
5
  import { d as logger, f as styles } from "../application-DnWZVbDO.mjs";
6
6
  import { createRequire, register } from "node:module";
7
7
  import { arg, defineCommand, runCommand, runMain } from "politty";
package/dist/cli/lib.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import "../chunk-C3Kl5s5P.mjs";
2
2
  import "../schema-BmKdDzr1.mjs";
3
- import { $t as initOperatorClient, At as getMigrationFiles, B as getMachineUserToken, Bt as generateUserTypes, Ct as compareLocalTypesWithSnapshot, D as truncate, Dt as getLatestMigrationNumber, E as listWorkflows, Ft as formatDiffSummary, Ht as getDistDir, It as formatMigrationDiff, K as listWebhookExecutors, Kt as loadAccessToken, L as listOAuth2Clients, Lt as hasChanges, M as show, Ot as getMigrationDirPath, P as remove, Pt as reconstructSnapshotFromMigrations, Q as getExecutorJob, Rt as getNamespacesWithMigrations, St as SCHEMA_FILE_NAME, Tt as createSnapshotFromLocalTypes, U as listMachineUsers, Ut as apiCall, Vt as loadConfig, W as generate, Y as triggerExecutor, Z as listExecutors, _t as bundleMigrationScript, at as getWorkflow, bt as INITIAL_SCHEMA_NUMBER, c as inviteUser, ct as listWorkflowExecutions, dt as apply, et as listExecutorJobs, f as listWorkspaces, g as deleteWorkspace, ht as MIGRATION_LABEL_KEY, i as removeUser, jt as getNextMigrationNumber, k as generate$1, kt as getMigrationFilePath, m as getWorkspace, mt as waitForExecution, n as updateUser, o as listUsers, pt as executeScript, qt as loadWorkspaceId, rt as startWorkflow, st as getWorkflowExecution, tt as watchExecutorJob, u as restoreWorkspace, ut as getExecutor, v as createWorkspace, vt as DB_TYPES_FILE_NAME, w as resumeWorkflow, wt as compareSnapshots, x as getAppHealth, xt as MIGRATE_FILE_NAME, y as listApps, yt as DIFF_FILE_NAME, z as getOAuth2Client } from "../update-B_W-UQnS.mjs";
3
+ import { $t as initOperatorClient, At as getMigrationFiles, B as getMachineUserToken, Bt as generateUserTypes, Ct as compareLocalTypesWithSnapshot, D as truncate, Dt as getLatestMigrationNumber, E as listWorkflows, Ft as formatDiffSummary, Ht as getDistDir, It as formatMigrationDiff, K as listWebhookExecutors, Kt as loadAccessToken, L as listOAuth2Clients, Lt as hasChanges, M as show, Ot as getMigrationDirPath, P as remove, Pt as reconstructSnapshotFromMigrations, Q as getExecutorJob, Rt as getNamespacesWithMigrations, St as SCHEMA_FILE_NAME, Tt as createSnapshotFromLocalTypes, U as listMachineUsers, Ut as apiCall, Vt as loadConfig, W as generate, Y as triggerExecutor, Z as listExecutors, _t as bundleMigrationScript, at as getWorkflow, bt as INITIAL_SCHEMA_NUMBER, c as inviteUser, ct as listWorkflowExecutions, dt as apply, et as listExecutorJobs, f as listWorkspaces, g as deleteWorkspace, ht as MIGRATION_LABEL_KEY, i as removeUser, jt as getNextMigrationNumber, k as generate$1, kt as getMigrationFilePath, m as getWorkspace, mt as waitForExecution, n as updateUser, o as listUsers, pt as executeScript, qt as loadWorkspaceId, rt as startWorkflow, st as getWorkflowExecution, tt as watchExecutorJob, u as restoreWorkspace, ut as getExecutor, v as createWorkspace, vt as DB_TYPES_FILE_NAME, w as resumeWorkflow, wt as compareSnapshots, x as getAppHealth, xt as MIGRATE_FILE_NAME, y as listApps, yt as DIFF_FILE_NAME, z as getOAuth2Client } from "../update-CUvANRhs.mjs";
4
4
  import { d as logger } from "../application-DnWZVbDO.mjs";
5
5
  import { createRequire, register } from "node:module";
6
6
  import * as fs$1 from "node:fs";
@@ -3749,13 +3749,19 @@ function generateIdpUserSeedCall(hasIdpUser) {
3749
3749
  /**
3750
3750
  * Generates the exec.mjs script content using testExecScript API for TailorDB types
3751
3751
  * and GraphQL mutation for _User (IdP managed)
3752
- * @param machineUserName - Machine user name for token retrieval
3752
+ * @param defaultMachineUserName - Default machine user name from generator config (can be overridden at runtime)
3753
3753
  * @param relativeConfigPath - Config path relative to exec script
3754
3754
  * @param namespaceConfigs - Namespace configurations with types and dependencies
3755
3755
  * @param hasIdpUser - Whether _User is included
3756
3756
  * @returns exec.mjs file contents
3757
3757
  */
3758
- function generateExecScript(machineUserName, relativeConfigPath, namespaceConfigs, hasIdpUser) {
3758
+ function generateExecScript(defaultMachineUserName, relativeConfigPath, namespaceConfigs, hasIdpUser) {
3759
+ const namespaceEntitiesEntries = namespaceConfigs.map(({ namespace, types }) => {
3760
+ return ` "${namespace}": [\n${types.map((e) => ` "${e}",`).join("\n")}\n ]`;
3761
+ }).join(",\n");
3762
+ const namespaceDepsEntries = namespaceConfigs.map(({ namespace, dependencies }) => {
3763
+ return ` "${namespace}": {\n${Object.entries(dependencies).map(([type, deps]) => ` "${type}": [${deps.map((d) => `"${d}"`).join(", ")}]`).join(",\n")}\n }`;
3764
+ }).join(",\n");
3759
3765
  return ml`
3760
3766
  import { readFileSync } from "node:fs";
3761
3767
  import { join } from "node:path";
@@ -3776,6 +3782,7 @@ function generateExecScript(machineUserName, relativeConfigPath, namespaceConfig
3776
3782
  // Parse command-line arguments
3777
3783
  const { values, positionals } = parseArgs({
3778
3784
  options: {
3785
+ "machine-user": { type: "string", short: "m" },
3779
3786
  namespace: { type: "string", short: "n" },
3780
3787
  "skip-idp": { type: "boolean", default: false },
3781
3788
  truncate: { type: "boolean", default: false },
@@ -3791,15 +3798,16 @@ function generateExecScript(machineUserName, relativeConfigPath, namespaceConfig
3791
3798
  Usage: node exec.mjs [options] [types...]
3792
3799
 
3793
3800
  Options:
3794
- -n, --namespace <ns> Process all types in specified namespace (excludes _User)
3795
- --skip-idp Skip IdP user (_User) entity
3796
- --truncate Truncate tables before seeding
3797
- --yes Skip confirmation prompts (for truncate)
3798
- -p, --profile <name> Workspace profile name
3799
- -h, --help Show help
3801
+ -m, --machine-user <name> Machine user name for authentication (required if not configured)
3802
+ -n, --namespace <ns> Process all types in specified namespace (excludes _User)
3803
+ --skip-idp Skip IdP user (_User) entity
3804
+ --truncate Truncate tables before seeding
3805
+ --yes Skip confirmation prompts (for truncate)
3806
+ -p, --profile <name> Workspace profile name
3807
+ -h, --help Show help
3800
3808
 
3801
3809
  Examples:
3802
- node exec.mjs # Process all types (default)
3810
+ node exec.mjs -m admin # Process all types with machine user
3803
3811
  node exec.mjs --namespace <namespace> # Process tailordb namespace only (no _User)
3804
3812
  node exec.mjs User Order # Process specific types only
3805
3813
  node exec.mjs --skip-idp # Process all except _User
@@ -3829,16 +3837,22 @@ function generateExecScript(machineUserName, relativeConfigPath, namespaceConfig
3829
3837
  const configDir = import.meta.dirname;
3830
3838
  const configPath = join(configDir, "${relativeConfigPath}");
3831
3839
 
3840
+ // Determine machine user name (CLI argument takes precedence over config default)
3841
+ const defaultMachineUser = ${defaultMachineUserName ? `"${defaultMachineUserName}"` : "undefined"};
3842
+ const machineUserName = values["machine-user"] || defaultMachineUser;
3843
+
3844
+ if (!machineUserName) {
3845
+ console.error(styleText("red", "Error: Machine user name is required."));
3846
+ console.error(styleText("yellow", "Specify --machine-user <name> or configure machineUserName in generator options."));
3847
+ process.exit(1);
3848
+ }
3849
+
3832
3850
  // Entity configuration
3833
3851
  const namespaceEntities = {
3834
- ${namespaceConfigs.map(({ namespace, types }) => {
3835
- return ` "${namespace}": [\n${types.map((e) => ` "${e}",`).join("\n")}\n ]`;
3836
- }).join(",\n")}
3852
+ ${namespaceEntitiesEntries}
3837
3853
  };
3838
3854
  const namespaceDeps = {
3839
- ${namespaceConfigs.map(({ namespace, dependencies }) => {
3840
- return ` "${namespace}": {\n${Object.entries(dependencies).map(([type, deps]) => ` "${type}": [${deps.map((d) => `"${d}"`).join(", ")}]`).join(",\n")}\n }`;
3841
- }).join(",\n")}
3855
+ ${namespaceDepsEntries}
3842
3856
  };
3843
3857
  const entities = Object.values(namespaceEntities).flat();
3844
3858
  const hasIdpUser = ${String(hasIdpUser)};
@@ -3963,7 +3977,7 @@ ${namespaceConfigs.map(({ namespace, dependencies }) => {
3963
3977
 
3964
3978
  // Get machine user token
3965
3979
  const tokenInfo = await getMachineUserToken({
3966
- name: "${machineUserName}",
3980
+ name: machineUserName,
3967
3981
  configPath,
3968
3982
  profile: values.profile,
3969
3983
  });
@@ -4071,7 +4085,7 @@ ${namespaceConfigs.map(({ namespace, dependencies }) => {
4071
4085
  arg: JSON.stringify({ data: chunk.data, order: chunk.order }),
4072
4086
  invoker: {
4073
4087
  namespace: authNamespace,
4074
- machineUserName: "${machineUserName}",
4088
+ machineUserName,
4075
4089
  },
4076
4090
  });
4077
4091
 
@@ -4251,13 +4265,11 @@ function createSeedGenerator(options) {
4251
4265
  content: generateIdpUserSchemaFile(idpUser.schema.usernameField, idpUser.schema.userTypeName)
4252
4266
  });
4253
4267
  }
4254
- if (options.machineUserName) {
4255
- const relativeConfigPath = path.relative(options.distPath, configPath);
4256
- files.push({
4257
- path: path.join(options.distPath, "exec.mjs"),
4258
- content: generateExecScript(options.machineUserName, relativeConfigPath, namespaceConfigs, hasIdpUser)
4259
- });
4260
- }
4268
+ const relativeConfigPath = path.relative(options.distPath, configPath);
4269
+ files.push({
4270
+ path: path.join(options.distPath, "exec.mjs"),
4271
+ content: generateExecScript(options.machineUserName, relativeConfigPath, namespaceConfigs, hasIdpUser)
4272
+ });
4261
4273
  return { files };
4262
4274
  }
4263
4275
  };
@@ -14871,4 +14883,4 @@ const updateCommand = defineCommand({
14871
14883
 
14872
14884
  //#endregion
14873
14885
  export { jobsCommand as $, initOperatorClient as $t, generateCommand as A, getMigrationFiles as At, getMachineUserToken as B, generateUserTypes as Bt, resumeCommand as C, compareLocalTypesWithSnapshot as Ct, truncate as D, getLatestMigrationNumber as Dt, listWorkflows as E, formatMigrationNumber as Et, removeCommand$1 as F, formatDiffSummary as Ft, generateCommand$1 as G, fetchLatestToken as Gt, listCommand$5 as H, getDistDir as Ht, listCommand$4 as I, formatMigrationDiff as It, triggerCommand as J, readPlatformConfig as Jt, listWebhookExecutors as K, loadAccessToken as Kt, listOAuth2Clients as L, hasChanges as Lt, show as M, isValidMigrationNumber as Mt, showCommand as N, loadDiff as Nt, truncateCommand as O, getMigrationDirPath as Ot, remove as P, reconstructSnapshotFromMigrations as Pt, getExecutorJob as Q, initOAuth2Client as Qt, getCommand$1 as R, getNamespacesWithMigrations as Rt, healthCommand as S, SCHEMA_FILE_NAME as St, listCommand$3 as T, createSnapshotFromLocalTypes as Tt, listMachineUsers as U, apiCall as Ut, tokenCommand as V, loadConfig as Vt, generate$1 as W, apiCommand as Wt, listCommand$6 as X, fetchAll as Xt, triggerExecutor as Y, writePlatformConfig as Yt, listExecutors as Z, fetchUserInfo as Zt, createCommand as _, bundleMigrationScript as _t, listCommand as a, jsonArgs as an, getWorkflow as at, listCommand$2 as b, INITIAL_SCHEMA_NUMBER as bt, inviteUser as c, listWorkflowExecutions as ct, listCommand$1 as d, apply as dt, readPackageJson as en, listExecutorJobs as et, listWorkspaces as f, applyCommand as ft, deleteWorkspace as g, parseMigrationLabelNumber as gt, deleteCommand as h, MIGRATION_LABEL_KEY as ht, removeUser as i, deploymentArgs as in, getCommand$2 as it, logBetaWarning as j, getNextMigrationNumber as jt, generate as k, getMigrationFilePath as kt, restoreCommand as l, getCommand$3 as lt, getWorkspace as m, waitForExecution$1 as mt, updateUser as n, commonArgs as nn, startCommand as nt, listUsers as o, withCommonArgs as on, executionsCommand as ot, getCommand as p, executeScript as pt, webhookCommand as q, loadWorkspaceId as qt, removeCommand as r, confirmationArgs as rn, startWorkflow as rt, inviteCommand as s, workspaceArgs as sn, getWorkflowExecution as st, updateCommand as t, PATScope as tn, watchExecutorJob as tt, restoreWorkspace as u, getExecutor as ut, createWorkspace as v, DB_TYPES_FILE_NAME as vt, resumeWorkflow as w, compareSnapshots as wt, getAppHealth as x, MIGRATE_FILE_NAME as xt, listApps as y, DIFF_FILE_NAME as yt, getOAuth2Client as z, trnPrefix as zt };
14874
- //# sourceMappingURL=update-B_W-UQnS.mjs.map
14886
+ //# sourceMappingURL=update-CUvANRhs.mjs.map