@tailor-platform/sdk 0.16.0 → 0.16.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @tailor-platform/sdk
2
2
 
3
+ ## 0.16.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#160](https://github.com/tailor-platform/sdk/pull/160) [`1406523`](https://github.com/tailor-platform/sdk/commit/14065237e5f0b05cf898c0fff196e1eb599fb96f) Thanks [@toiroakr](https://github.com/toiroakr)! - fix: correctly determine create/update for workflow job functions
8
+
9
+ Previously, the SDK used `hasExistingWorkflows` (based on workflow updates) to decide whether to use `createWorkflowJobFunction` or `updateWorkflowJobFunction`. This caused errors when renaming job functions, as renamed jobs were incorrectly sent to the update API which requires the job to already exist.
10
+
11
+ Now the SDK fetches the actual list of existing job function names via `listWorkflowJobFunctions` API and correctly uses:
12
+ - `createWorkflowJobFunction` for new job names (including renamed jobs)
13
+ - `updateWorkflowJobFunction` for existing job names
14
+
3
15
  ## 0.16.0
4
16
 
5
17
  ### Minor Changes
package/README.md CHANGED
@@ -10,3 +10,4 @@ You can also view the documentation on [our website](https://docs.tailor.tech/re
10
10
  - [App Configuration](./docs/configuration.md)
11
11
  - [Core Concepts](./docs/core-concepts.md)
12
12
  - [CLI Reference](./docs/cli-reference.md)
13
+ - [Testing Guide](./docs/testing.md)
package/dist/cli/api.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { apply, generate, generateUserTypes, loadAccessToken, loadConfig, loadWorkspaceId, machineUserList, machineUserToken, oauth2ClientGet, oauth2ClientList, remove, show, workflowExecutionGet, workflowExecutionsList, workflowGet, workflowList, workflowResume, workflowStart, workspaceCreate, workspaceDelete, workspaceList } from "../resume-ar5nEitS.mjs";
1
+ import { apply, generate, generateUserTypes, loadAccessToken, loadConfig, loadWorkspaceId, machineUserList, machineUserToken, oauth2ClientGet, oauth2ClientList, remove, show, workflowExecutionGet, workflowExecutionsList, workflowGet, workflowList, workflowResume, workflowStart, workspaceCreate, workspaceDelete, workspaceList } from "../resume-DvbIclRU.mjs";
2
2
  import "../job-CL8myeqs.mjs";
3
3
  import { register } from "node:module";
4
4
 
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { PATScope, applyCommand, commonArgs, createCommand, deleteCommand, executionsCommand, fetchAll, fetchLatestToken, fetchUserInfo, formatArgs, generateCommand, getCommand, getCommand$1, initOAuth2Client, initOperatorClient, listCommand as listCommand$1, listCommand$1 as listCommand$6, listCommand$2 as listCommand$7, listCommand$3 as listCommand, loadAccessToken, loadConfig, loadWorkspaceId, parseFormat, printWithFormat, readPackageJson, readPlatformConfig, removeCommand, resumeCommand, showCommand, startCommand, tokenCommand, withCommonArgs, writePlatformConfig } from "../resume-ar5nEitS.mjs";
2
+ import { PATScope, applyCommand, commonArgs, createCommand, deleteCommand, executionsCommand, fetchAll, fetchLatestToken, fetchUserInfo, formatArgs, generateCommand, getCommand, getCommand$1, initOAuth2Client, initOperatorClient, listCommand as listCommand$1, listCommand$1 as listCommand$6, listCommand$2 as listCommand$7, listCommand$3 as listCommand, loadAccessToken, loadConfig, loadWorkspaceId, parseFormat, printWithFormat, readPackageJson, readPlatformConfig, removeCommand, resumeCommand, showCommand, startCommand, tokenCommand, withCommonArgs, writePlatformConfig } from "../resume-DvbIclRU.mjs";
3
3
  import "../job-CL8myeqs.mjs";
4
4
  import { register } from "node:module";
5
5
  import { defineCommand, runCommand, runMain } from "citty";
@@ -147487,7 +147487,7 @@ function filterJobFunctionVersions(allVersions, usedJobNames) {
147487
147487
  /**
147488
147488
  * Register job functions used by any workflow.
147489
147489
  * Only registers jobs that are actually used (based on usedJobNames in changeSet).
147490
- * Uses update for existing workflows, create for new workflows.
147490
+ * Uses create for new jobs and update for existing jobs.
147491
147491
  */
147492
147492
  async function registerJobFunctions(client, changeSet) {
147493
147493
  const jobFunctionVersions = {};
@@ -147496,11 +147496,18 @@ async function registerJobFunctions(client, changeSet) {
147496
147496
  const { workspaceId, scripts } = firstWorkflow;
147497
147497
  const allUsedJobNames = /* @__PURE__ */ new Set();
147498
147498
  for (const item of [...changeSet.creates, ...changeSet.updates]) for (const jobName of item.usedJobNames) allUsedJobNames.add(jobName);
147499
- const hasExistingWorkflows = changeSet.updates.length > 0;
147499
+ const existingJobNames = await fetchAll(async (pageToken) => {
147500
+ const response = await client.listWorkflowJobFunctions({
147501
+ workspaceId,
147502
+ pageToken
147503
+ });
147504
+ return [response.jobFunctions.map((j) => j.name), response.nextPageToken];
147505
+ });
147506
+ const existingJobNamesSet = new Set(existingJobNames);
147500
147507
  const results = await Promise.all(Array.from(allUsedJobNames).map(async (jobName) => {
147501
147508
  const script = scripts.get(jobName);
147502
147509
  if (!script) throw new Error(`No bundled script found for job "${jobName}". Please run "generate" command before "apply".`);
147503
- const response = hasExistingWorkflows ? await client.updateWorkflowJobFunction({
147510
+ const response = existingJobNamesSet.has(jobName) ? await client.updateWorkflowJobFunction({
147504
147511
  workspaceId,
147505
147512
  jobFunctionName: jobName,
147506
147513
  script
@@ -149946,4 +149953,4 @@ const resumeCommand = defineCommand({
149946
149953
 
149947
149954
  //#endregion
149948
149955
  export { PATScope, apply, applyCommand, commonArgs, createCommand, deleteCommand, executionsCommand, fetchAll, fetchLatestToken, fetchUserInfo, formatArgs, generate, generateCommand, generateUserTypes, getCommand, getCommand$1, initOAuth2Client, initOperatorClient, listCommand, listCommand$1, listCommand$2, listCommand$3, loadAccessToken, loadConfig, loadWorkspaceId, machineUserList, machineUserToken, oauth2ClientGet, oauth2ClientList, parseFormat, printWithFormat, readPackageJson, readPlatformConfig, remove, removeCommand, resumeCommand, show, showCommand, startCommand, tokenCommand, withCommonArgs, workflowExecutionGet, workflowExecutionsList, workflowGet, workflowList, workflowResume, workflowStart, workspaceCreate, workspaceDelete, workspaceList, writePlatformConfig };
149949
- //# sourceMappingURL=resume-ar5nEitS.mjs.map
149956
+ //# sourceMappingURL=resume-DvbIclRU.mjs.map