@tailor-platform/sdk 1.1.3 → 1.2.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,52 @@
1
1
  # @tailor-platform/sdk
2
2
 
3
+ ## 1.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#353](https://github.com/tailor-platform/sdk/pull/353) [`2f5e2bf`](https://github.com/tailor-platform/sdk/commit/2f5e2bf80174e48c6e7ffd4e057d740a88b178e7) Thanks [@riku99](https://github.com/riku99)! - Use oxlint and oxfmt in example and create-sdk/templates
8
+
9
+ - [#363](https://github.com/tailor-platform/sdk/pull/363) [`71fdaa9`](https://github.com/tailor-platform/sdk/commit/71fdaa97ae80db62e1bd4778721baee849f0412f) Thanks [@toiroakr](https://github.com/toiroakr)! - chore: remove rolldown override (upstream issues resolved)
10
+
11
+ - [#358](https://github.com/tailor-platform/sdk/pull/358) [`90618d1`](https://github.com/tailor-platform/sdk/commit/90618d10bd543ddbe57ace65b80c007247865737) Thanks [@renovate](https://github.com/apps/renovate)! - fix(deps): update dependency zod to v4.3.4
12
+
13
+ ## 1.2.0
14
+
15
+ ### Minor Changes
16
+
17
+ - [#343](https://github.com/tailor-platform/sdk/pull/343) [`7264ef6`](https://github.com/tailor-platform/sdk/commit/7264ef6a1fbbb53c69aacccb2e50d500ab0e61c8) Thanks [@toiroakr](https://github.com/toiroakr)! - Add typed fields to `resolverExecutedTrigger` and `env` support for all executor args
18
+ - Add `success`, `result`, `error` fields to `ResolverExecutedArgs` with tagged union type
19
+ - Add `env: TailorEnv` to all trigger Args types and operation args
20
+
21
+ ### Patch Changes
22
+
23
+ - [#342](https://github.com/tailor-platform/sdk/pull/342) [`ec710be`](https://github.com/tailor-platform/sdk/commit/ec710be1aa2ff6f9b8f5d6816010340a95b6835e) Thanks [@toiroakr](https://github.com/toiroakr)! - fix(cli): unify table border style to single-line across all CLI commands
24
+
25
+ - Add `formatTable`, `formatKeyValueTable`, `formatTableWithHeaders` utility functions
26
+ - Add `formatValue` function for proper object/array formatting in tables
27
+ - Add ESLint rule to restrict direct `table` import
28
+ - Add tests for format utilities
29
+
30
+ - [#346](https://github.com/tailor-platform/sdk/pull/346) [`a8355bb`](https://github.com/tailor-platform/sdk/commit/a8355bb9aafbf6ea1da5167939cc429b4010462a) Thanks [@toiroakr](https://github.com/toiroakr)! - refactor(cli): improve stdout/stderr separation following clig.dev guidelines
31
+
32
+ - Add custom reporters (`IconReporter`, `PlainReporter`) to prevent extra newlines in piped environments
33
+ - All log methods (`info`, `success`, `warn`, `error`, `log`, `debug`) now output to stderr
34
+ - Rename `logger.data()` to `logger.out()` for primary program output to stdout
35
+ - `logger.out()` now accepts strings in addition to objects for table output
36
+
37
+ This separation allows clean command composition where stdout carries data output and stderr handles all messaging.
38
+
39
+ - [#345](https://github.com/tailor-platform/sdk/pull/345) [`f92d582`](https://github.com/tailor-platform/sdk/commit/f92d582c6b4c23163ba6d750251f7ed4fad4677b) Thanks [@toiroakr](https://github.com/toiroakr)! - fix: e2e tests incorrectly counting resources when multiple apps exist in workspace
40
+
41
+ Fixed an issue where e2e tests counted resources from other applications in the same workspace.
42
+
43
+ - Add metadata filtering by `sdk-name` label in e2e tests
44
+ - Set metadata on JobFunctions during apply and remove when no longer used
45
+
46
+ - [#355](https://github.com/tailor-platform/sdk/pull/355) [`c41a004`](https://github.com/tailor-platform/sdk/commit/c41a0044652f2c28d64ccd1f5af5a6db7a0450b8) Thanks [@renovate](https://github.com/apps/renovate)! - chore(deps): update dependency aquaproj/aqua-registry to v4.451.1
47
+
48
+ - [#357](https://github.com/tailor-platform/sdk/pull/357) [`7bf2782`](https://github.com/tailor-platform/sdk/commit/7bf2782db414ba22e5e756fe7c72f4507815924c) Thanks [@renovate](https://github.com/apps/renovate)! - chore(deps): update pnpm to v10.27.0
49
+
3
50
  ## 1.1.3
4
51
 
5
52
  ### Patch Changes
@@ -91,7 +138,7 @@
91
138
 
92
139
  ```ts
93
140
  export function getDB<const N extends keyof Namespace>(
94
- namespace: N,
141
+ namespace: N
95
142
  ): Kysely<Namespace[N]> {
96
143
  const client = new tailordb.Client({ namespace });
97
144
  return new Kysely<Namespace[N]>({ dialect: new TailordbDialect(client) });
@@ -105,7 +152,7 @@
105
152
  ```ts
106
153
  export function getDB<const N extends keyof Namespace>(
107
154
  namespace: N,
108
- kyselyConfig?: Omit<KyselyConfig, "dialect">,
155
+ kyselyConfig?: Omit<KyselyConfig, "dialect">
109
156
  ): Kysely<Namespace[N]> {
110
157
  const client = new tailordb.Client({ namespace });
111
158
  return new Kysely<Namespace[N]>({
@@ -148,6 +195,7 @@
148
195
  When deleting subgraph services (TailorDB, Pipeline, Auth, IdP), the deletion would fail with an error like "Failed to delete AuthService: auth xxx is used by gateway(s)" because the Application was still referencing them.
149
196
 
150
197
  This fix separates the deletion phases:
198
+
151
199
  - `delete-resources`: Deletes resources (types, resolvers, clients, etc.) before Application update
152
200
  - `delete-services`: Deletes services after Application is deleted
153
201
 
@@ -168,6 +216,7 @@
168
216
  - [#286](https://github.com/tailor-platform/sdk/pull/286) [`3409d66`](https://github.com/tailor-platform/sdk/commit/3409d66e6c6944292a3933e055d80c178efa7786) Thanks [@toiroakr](https://github.com/toiroakr)! - Unify CLI option short flags for consistency
169
217
 
170
218
  **Breaking Changes:**
219
+
171
220
  - `apply --dry-run`: Changed short flag from `-n` to `-d`
172
221
  - `workspace create --name`: Changed short flag from `-N` to `-n`
173
222
  - `workspace create --delete-protection`: Changed short flag from `-D` to `-d`
@@ -176,10 +225,12 @@
176
225
  - `secret delete --name`: Changed short flag from `-N` to `-n`
177
226
 
178
227
  **Documentation:**
228
+
179
229
  - Updated CLI documentation to reflect the new short flags
180
230
  - Added missing `staticwebsite` CLI documentation
181
231
 
182
232
  **New Unified Rules:**
233
+
183
234
  - `--name`: Always uses `-n`
184
235
  - `--namespace`: Always uses `-n` (no conflict as it's in different commands)
185
236
  - `--dry-run`: Uses `-d` (apply command)
@@ -248,6 +299,7 @@
248
299
  When a TailorDB type is created (e.g., `User`), the system auto-generates resolvers like `deleteUser`, `createUser`, etc. If a user created a custom resolver with the same name, it could not be deleted because the Application update (SDL composition) failed before the deletion phase.
249
300
 
250
301
  This fix reorders the apply phases to delete subgraph services before updating the Application:
302
+
251
303
  1. Create/Update services that Application depends on (subgraphs + StaticWebsite)
252
304
  2. Delete subgraph services (before Application update to avoid SDL conflicts)
253
305
  3. Create/Update Application
@@ -259,6 +311,7 @@
259
311
  ### Patch Changes
260
312
 
261
313
  - [#238](https://github.com/tailor-platform/sdk/pull/238) [`36639c6`](https://github.com/tailor-platform/sdk/commit/36639c6e1efee873eff89e61c59c60b8b22531a8) Thanks [@toiroakr](https://github.com/toiroakr)! - Improve Connect error messages in CLI
314
+
262
315
  - Add `errorHandlingInterceptor` to enhance error messages from Connect protocol
263
316
  - Error messages now include operation type, resource type, and request parameters
264
317
  - Makes it easier to identify which resource caused validation errors
@@ -350,6 +403,7 @@
350
403
  ### Minor Changes
351
404
 
352
405
  - [#158](https://github.com/tailor-platform/sdk/pull/158) [`cde0a0a`](https://github.com/tailor-platform/sdk/commit/cde0a0a3e1d517e8036f799ce2a0b8958f7e18c4) Thanks [@riku99](https://github.com/riku99)! - CLI changes:
406
+
353
407
  - Replace `--format` with `--json` for all list/detail commands. `--format` is no longer supported.
354
408
  - Change default table layout for list output and humanize `createdAt` / `updatedAt` in table format (JSON remains ISO strings).
355
409
  - `workspace list`: hide `updatedAt` in table output and add `--limit=<number>` to cap the number of workspaces shown.
@@ -407,6 +461,7 @@
407
461
  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.
408
462
 
409
463
  Now the SDK fetches the actual list of existing job function names via `listWorkflowJobFunctions` API and correctly uses:
464
+
410
465
  - `createWorkflowJobFunction` for new job names (including renamed jobs)
411
466
  - `updateWorkflowJobFunction` for existing job names
412
467
 
@@ -464,10 +519,12 @@
464
519
  ### Minor Changes
465
520
 
466
521
  - [#124](https://github.com/tailor-platform/sdk/pull/124) [`6d96fdb`](https://github.com/tailor-platform/sdk/commit/6d96fdbbecc225e9906b9c0b2225a733dd8fc4d8) Thanks [@toiroakr](https://github.com/toiroakr)! - Add workflow trigger functionality
522
+
467
523
  - Add `trigger` method to `Workflow` type that allows triggering workflows from resolvers and executors
468
524
  - Support `authInvoker` option for authentication when triggering workflows
469
525
 
470
526
  **Breaking Changes**
527
+
471
528
  - AuthInvoker field names changed:
472
529
  - `authName` → `namespace`
473
530
  - `machineUser` → `machineUserName`
@@ -485,6 +542,7 @@
485
542
  - [#121](https://github.com/tailor-platform/sdk/pull/121) [`bc7a3e9`](https://github.com/tailor-platform/sdk/commit/bc7a3e96b4805e75fcb153220d286abaced26368) Thanks [@toiroakr](https://github.com/toiroakr)! - Streamline workflow job function registration and trigger handling
486
543
 
487
544
  **Breaking Changes:**
545
+
488
546
  - Removed `deps` property from `createWorkflowJob()` - jobs no longer declare dependencies explicitly
489
547
  - Removed `jobs` object from `WorkflowJobContext` - use `.trigger()` method instead
490
548
  - Changed the way workflow jobs call other jobs: from `jobs.job_name()` to `otherJob.trigger()`
@@ -535,6 +593,7 @@
535
593
  ```
536
594
 
537
595
  **Key Changes:**
596
+
538
597
  - Dependencies are now automatically detected via AST analysis of `.trigger()` calls at bundle time
539
598
  - The `.trigger()` method is transformed to `tailor.workflow.triggerJobFunction()` during bundling
540
599
  - Job function registration is optimized - all job functions are registered once and shared across workflows
@@ -625,6 +684,7 @@
625
684
  ```
626
685
 
627
686
  **Options:**
687
+
628
688
  - `-w, --workspace-id` - ID of the workspace to remove resources from
629
689
  - `-p, --profile` - Workspace profile to use
630
690
  - `-c, --config` - Path to the SDK config file (default: `tailor.config.ts`)
@@ -938,7 +998,7 @@
938
998
  ```typescript
939
999
  defineGenerators(
940
1000
  ["@tailor/kysely-type", { distPath: "./generated/kysely.ts" }],
941
- ["@tailor/db-type", { distPath: "./generated/db.ts" }],
1001
+ ["@tailor/db-type", { distPath: "./generated/db.ts" }]
942
1002
  );
943
1003
  ```
944
1004
 
@@ -958,6 +1018,7 @@
958
1018
  - [#691](https://github.com/tailor-platform/sdk/pull/691) [`4e949b6`](https://github.com/tailor-platform/sdk/commit/4e949b67291ce8775c189a793a99f768ab8904db) Thanks [@toiroakr](https://github.com/toiroakr)! - feat: add seed generator
959
1019
 
960
1020
  Added `@tailor-platform/seed` generator that automatically generates seed data files from TailorDB type definitions. This generator creates:
1021
+
961
1022
  - GraphQL Ingest mapping files (`mappings/*.json`) and GraphQL files for bulk data loading via [gql-ingest](https://github.com/jackchuka/gql-ingest)
962
1023
  - lines-db schema files (`data/*.schema.ts`) for validation via [lines-db](https://github.com/toiroakr/lines-db)
963
1024
  - Configuration file (`config.yaml`) defining entity dependencies
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import "../chunk-CIV_ash9.mjs";
3
3
  import "../config-Bc_PBkyF.mjs";
4
- import { $ as jsonArgs, A as printData, B as loadAccessToken, D as tokenCommand, G as fetchUserInfo, H as readPlatformConfig, I as loadConfig, J as readPackageJson, K as initOAuth2Client, M as generateCommand, O as listCommand$5, P as applyCommand, Q as deploymentArgs, R as apiCommand, S as listCommand$6, U as writePlatformConfig, V as loadWorkspaceId, W as fetchAll, X as commonArgs, Y as PATScope, Z as confirmationArgs, a as createCommand$3, d as listCommand$7, et as withCommonArgs, h as executionsCommand, l as startCommand, nt as logger, p as getCommand$2, q as initOperatorClient, r as deleteCommand$3, s as resumeCommand, t as listCommand$8, tt as workspaceArgs, w as getCommand$1, x as removeCommand, y as showCommand, z as fetchLatestToken } from "../list-BticEhbi.mjs";
4
+ import { $ as withCommonArgs, B as loadWorkspaceId, D as tokenCommand, F as loadConfig, G as initOAuth2Client, H as writePlatformConfig, J as PATScope, K as initOperatorClient, L as apiCommand, N as applyCommand, O as listCommand$5, Q as jsonArgs, R as fetchLatestToken, S as listCommand$6, U as fetchAll, V as readPlatformConfig, W as fetchUserInfo, X as confirmationArgs, Y as commonArgs, Z as deploymentArgs, a as createCommand$3, d as listCommand$7, et as workspaceArgs, h as executionsCommand, j as generateCommand, l as startCommand, p as getCommand$2, q as readPackageJson, r as deleteCommand$3, s as resumeCommand, t as listCommand$8, tt as logger, w as getCommand$1, x as removeCommand, y as showCommand, z as loadAccessToken } from "../list-9sLkfPfn.mjs";
5
5
  import { register } from "node:module";
6
6
  import { defineCommand, runCommand, runMain } from "citty";
7
7
  import { generateCodeVerifier } from "@badgateway/oauth2-client";
@@ -254,11 +254,12 @@ const createCommand$2 = defineCommand({
254
254
  };
255
255
  writePlatformConfig(config);
256
256
  if (!args.json) logger.success(`Profile "${args.name}" created successfully.`);
257
- printData({
257
+ const profileInfo = {
258
258
  name: args.name,
259
259
  user: args.user,
260
260
  workspaceId: args["workspace-id"]
261
- }, args.json);
261
+ };
262
+ logger.out(profileInfo);
262
263
  })
263
264
  });
264
265
 
@@ -297,7 +298,7 @@ const listCommand$4 = defineCommand({
297
298
  ...commonArgs,
298
299
  ...jsonArgs
299
300
  },
300
- run: withCommonArgs(async (args) => {
301
+ run: withCommonArgs(async () => {
301
302
  const config = readPlatformConfig();
302
303
  const profiles = Object.entries(config.profiles);
303
304
  if (profiles.length === 0) {
@@ -307,11 +308,12 @@ const listCommand$4 = defineCommand({
307
308
  `);
308
309
  return;
309
310
  }
310
- printData(profiles.map(([name, profile]) => ({
311
+ const profileInfos = profiles.map(([name, profile]) => ({
311
312
  name,
312
313
  user: profile.user,
313
314
  workspaceId: profile.workspace_id
314
- })), args.json);
315
+ }));
316
+ logger.out(profileInfos);
315
317
  })
316
318
  });
317
319
 
@@ -359,11 +361,12 @@ const updateCommand$1 = defineCommand({
359
361
  profile.workspace_id = newWorkspaceId;
360
362
  writePlatformConfig(config);
361
363
  if (!args.json) logger.success(`Profile "${args.name}" updated successfully`);
362
- printData({
364
+ const profileInfo = {
363
365
  name: args.name,
364
366
  user: newUser,
365
367
  workspaceId: newWorkspaceId
366
- }, args.json);
368
+ };
369
+ logger.out(profileInfo);
367
370
  })
368
371
  });
369
372
 
@@ -542,11 +545,12 @@ const listSecretCommand = defineCommand({
542
545
  },
543
546
  run: withCommonArgs(async (args) => {
544
547
  try {
545
- printData(await secretList({
548
+ const secrets = await secretList({
546
549
  workspaceId: args["workspace-id"],
547
550
  profile: args.profile,
548
551
  vaultName: args["vault-name"]
549
- }), args.json);
552
+ });
553
+ logger.out(secrets);
550
554
  } catch (error) {
551
555
  if (error instanceof ConnectError && error.code === Code.NotFound) throw new Error(`Vault "${args["vault-name"]}" not found.`);
552
556
  throw error;
@@ -710,10 +714,11 @@ const listCommand$3 = defineCommand({
710
714
  ...workspaceArgs
711
715
  },
712
716
  run: withCommonArgs(async (args) => {
713
- printData(await vaultList({
717
+ const vaults = await vaultList({
714
718
  workspaceId: args["workspace-id"],
715
719
  profile: args.profile
716
- }), args.json);
720
+ });
721
+ logger.out(vaults);
717
722
  })
718
723
  });
719
724
 
@@ -760,10 +765,10 @@ function createProgress(label, total) {
760
765
  const update = () => {
761
766
  current += 1;
762
767
  const percent = Math.round(current / total * 100);
763
- process.stdout.write(`\r${label} ${current}/${total} (${percent}%)`);
768
+ process.stderr.write(`\r${label} ${current}/${total} (${percent}%)`);
764
769
  };
765
770
  const finish = () => {
766
- process.stdout.write("\n");
771
+ process.stderr.write("\n");
767
772
  };
768
773
  return {
769
774
  update,
@@ -914,12 +919,12 @@ const deployCommand = defineCommand({
914
919
  });
915
920
  if (!fs.existsSync(dir) || !fs.statSync(dir).isDirectory()) throw new Error(`Directory not found or not a directory: ${dir}`);
916
921
  const { url, skippedFiles } = await withTimeout(deployStaticWebsite(client, workspaceId, name, dir, !args.json), 10 * 6e4, "Deployment timed out after 10 minutes.");
917
- if (args.json) printData({
922
+ if (args.json) logger.out({
918
923
  name,
919
924
  workspaceId,
920
925
  url,
921
926
  skippedFiles
922
- }, true);
927
+ });
923
928
  else {
924
929
  logger.success(`Static website "${name}" deployed successfully. URL: ${url}`);
925
930
  logSkippedFiles(skippedFiles);
@@ -960,13 +965,14 @@ const getCommand = defineCommand({
960
965
  name: args.name
961
966
  });
962
967
  if (!staticwebsite) throw new Error(notFoundErrorMessage);
963
- printData({
968
+ const info = {
964
969
  workspaceId,
965
970
  name: staticwebsite.name,
966
971
  description: staticwebsite.description,
967
972
  url: staticwebsite.url,
968
973
  allowedIpAddresses: args.json ? staticwebsite.allowedIpAddresses : staticwebsite.allowedIpAddresses.join("\n")
969
- }, args.json);
974
+ };
975
+ logger.out(info);
970
976
  } catch (error) {
971
977
  if (error instanceof ConnectError && error.code === Code.NotFound) throw new Error(notFoundErrorMessage);
972
978
  throw error;
@@ -1014,7 +1020,7 @@ const listCommand$2 = defineCommand({
1014
1020
  workspaceId: args["workspace-id"],
1015
1021
  profile: args.profile
1016
1022
  });
1017
- printData(args.json ? websites : websites.map(({ allowedIpAddresses, ...rest }) => {
1023
+ const formatted = args.json ? websites : websites.map(({ allowedIpAddresses, ...rest }) => {
1018
1024
  if (allowedIpAddresses.length === 0) return {
1019
1025
  ...rest,
1020
1026
  allowedIpAddresses: "No allowed IP addresses"
@@ -1025,7 +1031,8 @@ const listCommand$2 = defineCommand({
1025
1031
  ...rest,
1026
1032
  allowedIpAddresses: label
1027
1033
  };
1028
- }), args.json);
1034
+ });
1035
+ logger.out(formatted);
1029
1036
  })
1030
1037
  });
1031
1038
 
@@ -1266,7 +1273,7 @@ const listCommand$1 = defineCommand({
1266
1273
  return;
1267
1274
  }
1268
1275
  if (args.json) {
1269
- printData(users, args.json);
1276
+ logger.out(users);
1270
1277
  return;
1271
1278
  }
1272
1279
  users.forEach((user) => {
@@ -1297,13 +1304,13 @@ function getScopesFromWriteFlag(write) {
1297
1304
  function getScopeStringsFromWriteFlag(write) {
1298
1305
  return write ? ["read", "write"] : ["read"];
1299
1306
  }
1300
- function printCreatedToken(name, token, write, action, json) {
1307
+ function printCreatedToken(name, token, write, action) {
1301
1308
  const scopes = getScopeStringsFromWriteFlag(write);
1302
- if (json) printData({
1309
+ if (logger.jsonMode) logger.out({
1303
1310
  name,
1304
1311
  scopes,
1305
1312
  token
1306
- }, json);
1313
+ });
1307
1314
  else logger.log(ml`
1308
1315
  Personal access token ${action} successfully.
1309
1316
 
@@ -1350,7 +1357,7 @@ const createCommand = defineCommand({
1350
1357
  scopes
1351
1358
  });
1352
1359
  if (!result.accessToken) throw new Error("Failed to create personal access token");
1353
- printCreatedToken(args.name, result.accessToken, args.write, "created", args.json);
1360
+ printCreatedToken(args.name, result.accessToken, args.write, "created");
1354
1361
  })
1355
1362
  });
1356
1363
 
@@ -1410,7 +1417,8 @@ const listCommand = defineCommand({
1410
1417
  return;
1411
1418
  }
1412
1419
  if (args.json) {
1413
- printData(pats.map(transformPersonalAccessToken), args.json);
1420
+ const patInfos = pats.map(transformPersonalAccessToken);
1421
+ logger.out(patInfos);
1414
1422
  return;
1415
1423
  }
1416
1424
  const maxNameLength = Math.max(...pats.map((pat) => pat.name.length));
@@ -1458,7 +1466,7 @@ const updateCommand = defineCommand({
1458
1466
  scopes
1459
1467
  });
1460
1468
  if (!result.accessToken) throw new Error("Failed to create personal access token");
1461
- printCreatedToken(args.name, result.accessToken, args.write, "updated", args.json);
1469
+ printCreatedToken(args.name, result.accessToken, args.write, "updated");
1462
1470
  })
1463
1471
  });
1464
1472