@tailor-platform/sdk 1.10.1 → 1.11.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.
@@ -1,6 +1,6 @@
1
1
  import { a as OAuth2ClientSchema, c as tailorUserMap, d as styles, f as symbols, i as ExecutorSchema, l as loadFilesWithIgnores, n as WorkflowJobSchema, o as ResolverSchema, r as WorkflowSchema, s as stringifyFunction, t as defineApplication, u as logger } from "./application-BKBo5tGD.mjs";
2
2
  import { createRequire } from "node:module";
3
- import { arg, defineCommand } from "politty";
3
+ import { arg, defineCommand, runCommand } from "politty";
4
4
  import { z } from "zod";
5
5
  import * as fs$2 from "node:fs";
6
6
  import { parseEnv } from "node:util";
@@ -972,14 +972,24 @@ function parseMethodName(methodName) {
972
972
  };
973
973
  }
974
974
  /**
975
+ * JSON.stringify replacer that converts BigInt values to strings.
976
+ * @param _key - Object key (unused)
977
+ * @param value - Value to serialize
978
+ * @returns Serializable value
979
+ */
980
+ function bigIntReplacer(_key, value) {
981
+ if (typeof value === "bigint") return value.toString();
982
+ return value;
983
+ }
984
+ /**
975
985
  * @internal
976
986
  * @param message - Request message to format
977
987
  * @returns Pretty-printed JSON or error placeholder
978
988
  */
979
989
  function formatRequestParams(message) {
980
990
  try {
981
- if (message && typeof message === "object" && "toJson" in message) return JSON.stringify(message.toJson(), null, 2);
982
- return JSON.stringify(message, null, 2);
991
+ if (message && typeof message === "object" && "toJson" in message) return JSON.stringify(message.toJson(), bigIntReplacer, 2);
992
+ return JSON.stringify(message, bigIntReplacer, 2);
983
993
  } catch {
984
994
  return "(unable to serialize request)";
985
995
  }
@@ -9060,6 +9070,340 @@ const applyCommand = defineCommand({
9060
9070
  })
9061
9071
  });
9062
9072
 
9073
+ //#endregion
9074
+ //#region src/cli/executor/status.ts
9075
+ /**
9076
+ * Colorize executor job status string.
9077
+ * @param status - Executor job status string
9078
+ * @returns Colorized status string
9079
+ */
9080
+ function colorizeExecutorJobStatus(status) {
9081
+ switch (status) {
9082
+ case "PENDING": return styles.dim(status);
9083
+ case "RUNNING": return styles.info(status);
9084
+ case "SUCCESS": return styles.success(status);
9085
+ case "FAILED": return styles.error(status);
9086
+ case "CANCELED": return styles.warning(status);
9087
+ default: return status;
9088
+ }
9089
+ }
9090
+ /**
9091
+ * Check if executor job status is terminal.
9092
+ * @param status - Executor job status enum value
9093
+ * @returns True if status is terminal
9094
+ */
9095
+ function isExecutorJobTerminalStatus(status) {
9096
+ return status === ExecutorJobStatus.SUCCESS || status === ExecutorJobStatus.FAILED || status === ExecutorJobStatus.CANCELED;
9097
+ }
9098
+ /**
9099
+ * Parse executor job status string to enum.
9100
+ * @param status - Status string to parse
9101
+ * @returns ExecutorJobStatus enum value
9102
+ */
9103
+ function parseExecutorJobStatus(status) {
9104
+ switch (status.toUpperCase()) {
9105
+ case "PENDING": return ExecutorJobStatus.PENDING;
9106
+ case "RUNNING": return ExecutorJobStatus.RUNNING;
9107
+ case "SUCCESS": return ExecutorJobStatus.SUCCESS;
9108
+ case "FAILED": return ExecutorJobStatus.FAILED;
9109
+ case "CANCELED": return ExecutorJobStatus.CANCELED;
9110
+ default: throw new Error(`Invalid status: ${status}. Valid values: PENDING, RUNNING, SUCCESS, FAILED, CANCELED`);
9111
+ }
9112
+ }
9113
+ /**
9114
+ * Colorize function execution status string.
9115
+ * @param status - Function execution status string
9116
+ * @returns Colorized status string
9117
+ */
9118
+ function colorizeFunctionExecutionStatus(status) {
9119
+ switch (status) {
9120
+ case "RUNNING": return styles.info(status);
9121
+ case "SUCCESS": return styles.success(status);
9122
+ case "FAILED": return styles.error(status);
9123
+ default: return status;
9124
+ }
9125
+ }
9126
+ /**
9127
+ * Check if function execution status is terminal.
9128
+ * @param status - Function execution status enum value
9129
+ * @returns True if status is terminal
9130
+ */
9131
+ function isFunctionExecutionTerminalStatus(status) {
9132
+ return status === FunctionExecution_Status.SUCCESS || status === FunctionExecution_Status.FAILED;
9133
+ }
9134
+ /**
9135
+ * Convert function execution status enum to string.
9136
+ * @param status - Function execution status enum value
9137
+ * @returns Status string representation
9138
+ */
9139
+ function functionExecutionStatusToString(status) {
9140
+ switch (status) {
9141
+ case FunctionExecution_Status.RUNNING: return "RUNNING";
9142
+ case FunctionExecution_Status.SUCCESS: return "SUCCESS";
9143
+ case FunctionExecution_Status.FAILED: return "FAILED";
9144
+ default: return "UNSPECIFIED";
9145
+ }
9146
+ }
9147
+ /**
9148
+ * Convert executor target type enum to string.
9149
+ * @param targetType - Executor target type enum value
9150
+ * @returns Target type string representation
9151
+ */
9152
+ function executorTargetTypeToString(targetType) {
9153
+ switch (targetType) {
9154
+ case ExecutorTargetType.WEBHOOK: return "WEBHOOK";
9155
+ case ExecutorTargetType.TAILOR_GRAPHQL: return "GRAPHQL";
9156
+ case ExecutorTargetType.FUNCTION: return "FUNCTION";
9157
+ case ExecutorTargetType.JOB_FUNCTION: return "JOB_FUNCTION";
9158
+ case ExecutorTargetType.WORKFLOW: return "WORKFLOW";
9159
+ default: return "UNSPECIFIED";
9160
+ }
9161
+ }
9162
+ /**
9163
+ * Convert executor trigger type enum to string.
9164
+ * @param triggerType - Executor trigger type enum value
9165
+ * @returns Trigger type string representation
9166
+ */
9167
+ function executorTriggerTypeToString(triggerType) {
9168
+ switch (triggerType) {
9169
+ case ExecutorTriggerType.SCHEDULE: return "SCHEDULE";
9170
+ case ExecutorTriggerType.EVENT: return "EVENT";
9171
+ case ExecutorTriggerType.INCOMING_WEBHOOK: return "INCOMING_WEBHOOK";
9172
+ default: return "UNSPECIFIED";
9173
+ }
9174
+ }
9175
+
9176
+ //#endregion
9177
+ //#region src/cli/executor/transform.ts
9178
+ function executorJobStatusToString(status) {
9179
+ switch (status) {
9180
+ case ExecutorJobStatus.PENDING: return "PENDING";
9181
+ case ExecutorJobStatus.RUNNING: return "RUNNING";
9182
+ case ExecutorJobStatus.SUCCESS: return "SUCCESS";
9183
+ case ExecutorJobStatus.FAILED: return "FAILED";
9184
+ case ExecutorJobStatus.CANCELED: return "CANCELED";
9185
+ default: return "UNSPECIFIED";
9186
+ }
9187
+ }
9188
+ /**
9189
+ * Transform ExecutorJob to ExecutorJobListInfo for list display.
9190
+ * @param job - ExecutorJob from proto
9191
+ * @returns Executor job list info
9192
+ */
9193
+ function toExecutorJobListInfo(job) {
9194
+ return {
9195
+ id: job.id,
9196
+ executorName: job.executorName,
9197
+ status: executorJobStatusToString(job.status),
9198
+ createdAt: job.createdAt ? timestampDate(job.createdAt).toISOString() : "N/A"
9199
+ };
9200
+ }
9201
+ /**
9202
+ * Transform ExecutorJob to ExecutorJobInfo for detail display.
9203
+ * @param job - ExecutorJob from proto
9204
+ * @returns Executor job info
9205
+ */
9206
+ function toExecutorJobInfo(job) {
9207
+ return {
9208
+ id: job.id,
9209
+ executorName: job.executorName,
9210
+ status: executorJobStatusToString(job.status),
9211
+ scheduledAt: job.scheduledAt ? timestampDate(job.scheduledAt).toISOString() : "N/A",
9212
+ createdAt: job.createdAt ? timestampDate(job.createdAt).toISOString() : "N/A",
9213
+ updatedAt: job.updatedAt ? timestampDate(job.updatedAt).toISOString() : "N/A"
9214
+ };
9215
+ }
9216
+ /**
9217
+ * Transform ExecutorJobAttempt to ExecutorJobAttemptInfo.
9218
+ * @param attempt - ExecutorJobAttempt from proto
9219
+ * @returns Executor job attempt info
9220
+ */
9221
+ function toExecutorJobAttemptInfo(attempt) {
9222
+ return {
9223
+ id: attempt.id,
9224
+ jobId: attempt.jobId,
9225
+ status: executorJobStatusToString(attempt.status),
9226
+ error: attempt.error || "",
9227
+ startedAt: attempt.startedAt ? timestampDate(attempt.startedAt).toISOString() : "N/A",
9228
+ finishedAt: attempt.finishedAt ? timestampDate(attempt.finishedAt).toISOString() : "N/A",
9229
+ operationReference: attempt.operationReference || ""
9230
+ };
9231
+ }
9232
+ /**
9233
+ * Format trigger type for human-readable display.
9234
+ * Examples:
9235
+ * - event with typeName "User" and action "created" → "event: User created"
9236
+ * - event with resolverName "myResolver" → "event: myResolver executed"
9237
+ * - schedule with frequency "0 12 * * *" and timezone "UTC" → "schedule: 0 12 * * * (UTC)"
9238
+ * - incomingWebhook → "webhook"
9239
+ * @param executor - Executor from proto
9240
+ * @returns Formatted trigger type string
9241
+ */
9242
+ function formatTriggerType(executor) {
9243
+ const config = executor.triggerConfig?.config;
9244
+ if (!config || config.case === void 0) return executorTriggerTypeToString(executor.triggerType);
9245
+ switch (config.case) {
9246
+ case "schedule": return `schedule: ${config.value.frequency} (${config.value.timezone})`;
9247
+ case "event": return formatEventTrigger(config.value.eventType, config.value.condition?.expr);
9248
+ case "incomingWebhook": return "webhook";
9249
+ default: return executorTriggerTypeToString(executor.triggerType);
9250
+ }
9251
+ }
9252
+ /**
9253
+ * Format event trigger for display by parsing condition to extract type/resolver name.
9254
+ * @param eventType - Event type string (e.g., "tailordb.type_record.created")
9255
+ * @param condition - Condition expression that may contain args.typeName or args.resolverName
9256
+ * @returns Formatted string (e.g., "event: User created")
9257
+ */
9258
+ function formatEventTrigger(eventType, condition) {
9259
+ const parts = eventType.split(".");
9260
+ if (parts.length < 3) return `event: ${eventType}`;
9261
+ const [service, resource, action] = parts;
9262
+ if (condition) {
9263
+ const typeNameMatch = condition.match(/args\.typeName\s*===?\s*["']([^"']+)["']/);
9264
+ if (typeNameMatch) return `event: ${typeNameMatch[1]} ${action}`;
9265
+ const resolverNameMatch = condition.match(/args\.resolverName\s*===?\s*["']([^"']+)["']/);
9266
+ if (resolverNameMatch) return `event: ${resolverNameMatch[1]} ${action}`;
9267
+ }
9268
+ return `event: ${service} ${resource} ${action}`;
9269
+ }
9270
+ /**
9271
+ * Format trigger config for display.
9272
+ * @param executor - Executor from proto
9273
+ * @returns Formatted trigger config
9274
+ */
9275
+ function formatTriggerConfig(executor) {
9276
+ const config = executor.triggerConfig?.config;
9277
+ if (!config || config.case === void 0) return {};
9278
+ switch (config.case) {
9279
+ case "schedule": return {
9280
+ timezone: config.value.timezone,
9281
+ frequency: config.value.frequency
9282
+ };
9283
+ case "event": return {
9284
+ eventType: config.value.eventType,
9285
+ condition: config.value.condition?.expr || ""
9286
+ };
9287
+ case "incomingWebhook": return { secret: config.value.secret ? "***" : "" };
9288
+ default: return {};
9289
+ }
9290
+ }
9291
+ /**
9292
+ * Format target config for display.
9293
+ * @param executor - Executor from proto
9294
+ * @returns Formatted target config
9295
+ */
9296
+ function formatTargetConfig(executor) {
9297
+ const config = executor.targetConfig?.config;
9298
+ if (!config || config.case === void 0) return {};
9299
+ switch (config.case) {
9300
+ case "webhook": return {
9301
+ url: config.value.url?.expr || "",
9302
+ headers: config.value.headers.length
9303
+ };
9304
+ case "tailorGraphql": return {
9305
+ appName: config.value.appName,
9306
+ query: config.value.query
9307
+ };
9308
+ case "function": return { name: config.value.name };
9309
+ case "workflow": return { workflowName: config.value.workflowName };
9310
+ default: return {};
9311
+ }
9312
+ }
9313
+ /**
9314
+ * Transform ExecutorExecutor to ExecutorListInfo for list display.
9315
+ * @param executor - Executor from proto
9316
+ * @returns Executor list info
9317
+ */
9318
+ function toExecutorListInfo(executor) {
9319
+ return {
9320
+ name: executor.name,
9321
+ triggerType: formatTriggerType(executor),
9322
+ targetType: executorTargetTypeToString(executor.targetType),
9323
+ disabled: executor.disabled
9324
+ };
9325
+ }
9326
+ /**
9327
+ * Transform ExecutorExecutor to ExecutorInfo for detail display.
9328
+ * @param executor - Executor from proto
9329
+ * @returns Executor info
9330
+ */
9331
+ function toExecutorInfo(executor) {
9332
+ return {
9333
+ name: executor.name,
9334
+ description: executor.description,
9335
+ triggerType: formatTriggerType(executor),
9336
+ targetType: executorTargetTypeToString(executor.targetType),
9337
+ disabled: executor.disabled,
9338
+ triggerConfig: JSON.stringify(formatTriggerConfig(executor), null, 2),
9339
+ targetConfig: JSON.stringify(formatTargetConfig(executor), null, 2)
9340
+ };
9341
+ }
9342
+
9343
+ //#endregion
9344
+ //#region src/cli/executor/get.ts
9345
+ const nameArgs$1 = { name: arg(z.string(), {
9346
+ positional: true,
9347
+ description: "Executor name"
9348
+ }) };
9349
+ /**
9350
+ * Resolve an executor by name.
9351
+ * @param client - Operator client
9352
+ * @param workspaceId - Workspace ID
9353
+ * @param name - Executor name
9354
+ * @returns Resolved executor
9355
+ */
9356
+ async function resolveExecutor(client, workspaceId, name) {
9357
+ const { executor } = await client.getExecutorExecutor({
9358
+ workspaceId,
9359
+ name
9360
+ });
9361
+ if (!executor) throw new Error(`Executor '${name}' not found.`);
9362
+ return executor;
9363
+ }
9364
+ /**
9365
+ * Get an executor by name and return CLI-friendly info.
9366
+ * @param options - Executor lookup options
9367
+ * @returns Executor information
9368
+ */
9369
+ async function getExecutor(options) {
9370
+ const client = await initOperatorClient(await loadAccessToken({
9371
+ useProfile: true,
9372
+ profile: options.profile
9373
+ }));
9374
+ const workspaceId = loadWorkspaceId({
9375
+ workspaceId: options.workspaceId,
9376
+ profile: options.profile
9377
+ });
9378
+ try {
9379
+ return toExecutorInfo(await resolveExecutor(client, workspaceId, options.name));
9380
+ } catch (error) {
9381
+ if (error instanceof ConnectError && error.code === Code.NotFound) throw new Error(`Executor '${options.name}' not found.`);
9382
+ throw error;
9383
+ }
9384
+ }
9385
+ const getCommand$3 = defineCommand({
9386
+ name: "get",
9387
+ description: "Get executor details",
9388
+ args: z.object({
9389
+ ...commonArgs,
9390
+ ...jsonArgs,
9391
+ ...workspaceArgs,
9392
+ ...nameArgs$1
9393
+ }),
9394
+ run: withCommonArgs(async (args) => {
9395
+ const executor = await getExecutor({
9396
+ name: args.name,
9397
+ workspaceId: args["workspace-id"],
9398
+ profile: args.profile
9399
+ });
9400
+ logger.out(executor, { display: {
9401
+ triggerConfig: null,
9402
+ targetConfig: null
9403
+ } });
9404
+ })
9405
+ });
9406
+
9063
9407
  //#endregion
9064
9408
  //#region src/cli/utils/format.ts
9065
9409
  /**
@@ -9131,7 +9475,7 @@ const waitArgs = {
9131
9475
  //#region src/cli/workflow/status.ts
9132
9476
  /**
9133
9477
  * Check if workflow execution status is terminal.
9134
- * @param status - Workflow execution status enum
9478
+ * @param status - Workflow execution status enum value
9135
9479
  * @returns True if status is terminal
9136
9480
  */
9137
9481
  function isWorkflowExecutionTerminalStatus(status) {
@@ -9563,7 +9907,7 @@ async function waitForExecution(options) {
9563
9907
  const { client, workspaceId, executionId, interval, showProgress, trackJobs } = options;
9564
9908
  let lastStatus;
9565
9909
  let lastRunningJobs;
9566
- const spinner = showProgress ? ora().start("Waiting for workflow to complete...") : null;
9910
+ const spinner = showProgress ? ora({ indent: 2 }).start("Waiting for workflow to complete...") : null;
9567
9911
  try {
9568
9912
  while (true) {
9569
9913
  const { execution } = await client.getWorkflowExecution({
@@ -9579,7 +9923,10 @@ async function waitForExecution(options) {
9579
9923
  if (execution.status !== lastStatus) {
9580
9924
  if (showProgress) {
9581
9925
  spinner?.stop();
9582
- logger.info(`Status: ${coloredStatus}`, { mode: "stream" });
9926
+ logger.info(`Status: ${coloredStatus}`, {
9927
+ mode: "stream",
9928
+ indent: 2
9929
+ });
9583
9930
  spinner?.start(`Waiting for workflow to complete...`);
9584
9931
  }
9585
9932
  lastStatus = execution.status;
@@ -9589,7 +9936,10 @@ async function waitForExecution(options) {
9589
9936
  if (runningJobs && runningJobs !== lastRunningJobs) {
9590
9937
  if (showProgress) {
9591
9938
  spinner?.stop();
9592
- logger.info(`Job | ${runningJobs}: ${coloredStatus}`, { mode: "stream" });
9939
+ logger.info(`Job | ${runningJobs}: ${coloredStatus}`, {
9940
+ mode: "stream",
9941
+ indent: 2
9942
+ });
9593
9943
  spinner?.start(`Waiting for workflow to complete...`);
9594
9944
  }
9595
9945
  lastRunningJobs = runningJobs;
@@ -9708,166 +10058,6 @@ const startCommand = defineCommand({
9708
10058
  })
9709
10059
  });
9710
10060
 
9711
- //#endregion
9712
- //#region src/cli/executor/status.ts
9713
- /**
9714
- * Colorize executor job status for display.
9715
- * @param status - Executor job status string
9716
- * @returns Colorized status string
9717
- */
9718
- function colorizeExecutorJobStatus(status) {
9719
- switch (status) {
9720
- case "PENDING": return styles.dim(status);
9721
- case "RUNNING": return styles.info(status);
9722
- case "SUCCESS": return styles.success(status);
9723
- case "FAILED": return styles.error(status);
9724
- case "CANCELED": return styles.warning(status);
9725
- default: return status;
9726
- }
9727
- }
9728
- /**
9729
- * Check if executor job status is terminal.
9730
- * @param status - Executor job status enum
9731
- * @returns True if status is terminal
9732
- */
9733
- function isExecutorJobTerminalStatus(status) {
9734
- return status === ExecutorJobStatus.SUCCESS || status === ExecutorJobStatus.FAILED || status === ExecutorJobStatus.CANCELED;
9735
- }
9736
- /**
9737
- * Parse executor job status string to enum.
9738
- * @param status - Status string to parse
9739
- * @returns Parsed ExecutorJobStatus enum value
9740
- */
9741
- function parseExecutorJobStatus(status) {
9742
- switch (status.toUpperCase()) {
9743
- case "PENDING": return ExecutorJobStatus.PENDING;
9744
- case "RUNNING": return ExecutorJobStatus.RUNNING;
9745
- case "SUCCESS": return ExecutorJobStatus.SUCCESS;
9746
- case "FAILED": return ExecutorJobStatus.FAILED;
9747
- case "CANCELED": return ExecutorJobStatus.CANCELED;
9748
- default: throw new Error(`Invalid status: ${status}. Valid values: PENDING, RUNNING, SUCCESS, FAILED, CANCELED`);
9749
- }
9750
- }
9751
- /**
9752
- * Colorize function execution status for display.
9753
- * @param status - Function execution status string
9754
- * @returns Colorized status string
9755
- */
9756
- function colorizeFunctionExecutionStatus(status) {
9757
- switch (status) {
9758
- case "RUNNING": return styles.info(status);
9759
- case "SUCCESS": return styles.success(status);
9760
- case "FAILED": return styles.error(status);
9761
- default: return status;
9762
- }
9763
- }
9764
- /**
9765
- * Check if function execution status is terminal.
9766
- * @param status - Function execution status enum
9767
- * @returns True if status is terminal
9768
- */
9769
- function isFunctionExecutionTerminalStatus(status) {
9770
- return status === FunctionExecution_Status.SUCCESS || status === FunctionExecution_Status.FAILED;
9771
- }
9772
- /**
9773
- * Convert function execution status enum to string.
9774
- * @param status - Function execution status enum
9775
- * @returns Status string
9776
- */
9777
- function functionExecutionStatusToString(status) {
9778
- switch (status) {
9779
- case FunctionExecution_Status.RUNNING: return "RUNNING";
9780
- case FunctionExecution_Status.SUCCESS: return "SUCCESS";
9781
- case FunctionExecution_Status.FAILED: return "FAILED";
9782
- default: return "UNSPECIFIED";
9783
- }
9784
- }
9785
- /**
9786
- * Convert executor target type enum to string.
9787
- * @param targetType - Executor target type enum
9788
- * @returns Target type string
9789
- */
9790
- function executorTargetTypeToString(targetType) {
9791
- switch (targetType) {
9792
- case ExecutorTargetType.WEBHOOK: return "WEBHOOK";
9793
- case ExecutorTargetType.TAILOR_GRAPHQL: return "GRAPHQL";
9794
- case ExecutorTargetType.FUNCTION: return "FUNCTION";
9795
- case ExecutorTargetType.JOB_FUNCTION: return "JOB_FUNCTION";
9796
- case ExecutorTargetType.WORKFLOW: return "WORKFLOW";
9797
- default: return "UNSPECIFIED";
9798
- }
9799
- }
9800
- /**
9801
- * Convert executor trigger type enum to string.
9802
- * @param triggerType - Executor trigger type enum
9803
- * @returns Trigger type string
9804
- */
9805
- function executorTriggerTypeToString(triggerType) {
9806
- switch (triggerType) {
9807
- case ExecutorTriggerType.SCHEDULE: return "schedule";
9808
- case ExecutorTriggerType.EVENT: return "event";
9809
- case ExecutorTriggerType.INCOMING_WEBHOOK: return "incomingWebhook";
9810
- default: return "unspecified";
9811
- }
9812
- }
9813
-
9814
- //#endregion
9815
- //#region src/cli/executor/transform.ts
9816
- function executorJobStatusToString(status) {
9817
- switch (status) {
9818
- case ExecutorJobStatus.PENDING: return "PENDING";
9819
- case ExecutorJobStatus.RUNNING: return "RUNNING";
9820
- case ExecutorJobStatus.SUCCESS: return "SUCCESS";
9821
- case ExecutorJobStatus.FAILED: return "FAILED";
9822
- case ExecutorJobStatus.CANCELED: return "CANCELED";
9823
- default: return "UNSPECIFIED";
9824
- }
9825
- }
9826
- /**
9827
- * Transform ExecutorJob to ExecutorJobListInfo for list display.
9828
- * @param job - Executor job from proto
9829
- * @returns Executor job list info
9830
- */
9831
- function toExecutorJobListInfo(job) {
9832
- return {
9833
- id: job.id,
9834
- executorName: job.executorName,
9835
- status: executorJobStatusToString(job.status),
9836
- createdAt: job.createdAt ? timestampDate(job.createdAt).toISOString() : "N/A"
9837
- };
9838
- }
9839
- /**
9840
- * Transform ExecutorJob to ExecutorJobInfo for detail display.
9841
- * @param job - Executor job from proto
9842
- * @returns Executor job info
9843
- */
9844
- function toExecutorJobInfo(job) {
9845
- return {
9846
- id: job.id,
9847
- executorName: job.executorName,
9848
- status: executorJobStatusToString(job.status),
9849
- scheduledAt: job.scheduledAt ? timestampDate(job.scheduledAt).toISOString() : "N/A",
9850
- createdAt: job.createdAt ? timestampDate(job.createdAt).toISOString() : "N/A",
9851
- updatedAt: job.updatedAt ? timestampDate(job.updatedAt).toISOString() : "N/A"
9852
- };
9853
- }
9854
- /**
9855
- * Transform ExecutorJobAttempt to ExecutorJobAttemptInfo for display.
9856
- * @param attempt - Executor job attempt from proto
9857
- * @returns Executor job attempt info
9858
- */
9859
- function toExecutorJobAttemptInfo(attempt) {
9860
- return {
9861
- id: attempt.id,
9862
- jobId: attempt.jobId,
9863
- status: executorJobStatusToString(attempt.status),
9864
- error: attempt.error || "",
9865
- startedAt: attempt.startedAt ? timestampDate(attempt.startedAt).toISOString() : "N/A",
9866
- finishedAt: attempt.finishedAt ? timestampDate(attempt.finishedAt).toISOString() : "N/A",
9867
- operationReference: attempt.operationReference || ""
9868
- };
9869
- }
9870
-
9871
10061
  //#endregion
9872
10062
  //#region src/cli/executor/jobs.ts
9873
10063
  function formatTime(date) {
@@ -10125,6 +10315,36 @@ function printJobWithAttempts(job) {
10125
10315
  const jobsCommand = defineCommand({
10126
10316
  name: "jobs",
10127
10317
  description: "List or get executor jobs.",
10318
+ examples: [
10319
+ {
10320
+ cmd: "tailor-sdk executor jobs my-executor",
10321
+ desc: "List jobs for an executor (default: 50 jobs)"
10322
+ },
10323
+ {
10324
+ cmd: "tailor-sdk executor jobs my-executor --limit 10",
10325
+ desc: "Limit the number of jobs"
10326
+ },
10327
+ {
10328
+ cmd: "tailor-sdk executor jobs my-executor -s RUNNING",
10329
+ desc: "Filter by status"
10330
+ },
10331
+ {
10332
+ cmd: "tailor-sdk executor jobs my-executor <job-id>",
10333
+ desc: "Get job details"
10334
+ },
10335
+ {
10336
+ cmd: "tailor-sdk executor jobs my-executor <job-id> --attempts",
10337
+ desc: "Get job details with attempts"
10338
+ },
10339
+ {
10340
+ cmd: "tailor-sdk executor jobs my-executor <job-id> -W",
10341
+ desc: "Wait for job to complete"
10342
+ },
10343
+ {
10344
+ cmd: "tailor-sdk executor jobs my-executor <job-id> -W -l",
10345
+ desc: "Wait for job with logs"
10346
+ }
10347
+ ],
10128
10348
  args: z.object({
10129
10349
  ...commonArgs,
10130
10350
  ...jsonArgs,
@@ -10227,6 +10447,54 @@ const jobsCommand = defineCommand({
10227
10447
  })
10228
10448
  });
10229
10449
 
10450
+ //#endregion
10451
+ //#region src/cli/executor/list.ts
10452
+ /**
10453
+ * List executors in the workspace and return CLI-friendly info.
10454
+ * @param options - Executor listing options
10455
+ * @returns List of executors
10456
+ */
10457
+ async function listExecutors(options) {
10458
+ const client = await initOperatorClient(await loadAccessToken({
10459
+ useProfile: true,
10460
+ profile: options?.profile
10461
+ }));
10462
+ const workspaceId = loadWorkspaceId({
10463
+ workspaceId: options?.workspaceId,
10464
+ profile: options?.profile
10465
+ });
10466
+ return (await fetchAll(async (pageToken) => {
10467
+ const { executors, nextPageToken } = await client.listExecutorExecutors({
10468
+ workspaceId,
10469
+ pageToken
10470
+ });
10471
+ return [executors, nextPageToken];
10472
+ })).map((e) => toExecutorListInfo(e));
10473
+ }
10474
+ const listCommand$6 = defineCommand({
10475
+ name: "list",
10476
+ description: "List all executors",
10477
+ args: z.object({
10478
+ ...commonArgs,
10479
+ ...jsonArgs,
10480
+ ...workspaceArgs
10481
+ }),
10482
+ run: withCommonArgs(async (args) => {
10483
+ const executors = await listExecutors({
10484
+ workspaceId: args["workspace-id"],
10485
+ profile: args.profile
10486
+ });
10487
+ if (executors.length === 0) {
10488
+ logger.info("No executors found.");
10489
+ return;
10490
+ }
10491
+ logger.out(executors, { display: { disabled: (v) => v ? styles.warning("true") : styles.dim("false") } });
10492
+ if (!args.json) {
10493
+ if (executors.some((e) => e.triggerType === "webhook")) logger.info("To see webhook URLs, run: tailor-sdk executor webhook list");
10494
+ }
10495
+ })
10496
+ });
10497
+
10230
10498
  //#endregion
10231
10499
  //#region src/cli/executor/trigger.ts
10232
10500
  /**
@@ -10285,6 +10553,42 @@ async function triggerExecutor(options) {
10285
10553
  const triggerCommand = defineCommand({
10286
10554
  name: "trigger",
10287
10555
  description: "Trigger an executor manually.",
10556
+ notes: `Only executors with \`INCOMING_WEBHOOK\` or \`SCHEDULE\` trigger types can be triggered manually.
10557
+ Executors with \`EVENT\` trigger types (such as \`recordCreated\`, \`recordUpdated\`, \`recordDeleted\`) cannot be triggered manually.
10558
+
10559
+ The \`--data\` and \`--header\` options are only available for \`INCOMING_WEBHOOK\` trigger type.
10560
+
10561
+ **Downstream Execution Tracking**
10562
+
10563
+ When using \`--wait\`, the CLI tracks not only the executor job but also any downstream executions:
10564
+
10565
+ - **Workflow targets**: Waits for the workflow execution to complete (SUCCESS, FAILED, or PENDING_RESUME). Shows real-time status changes and currently running job names during execution (same output as \`workflow start --wait\`).
10566
+ - **Function targets**: Waits for the function execution to complete
10567
+ - **Webhook/GraphQL targets**: Only waits for the executor job itself
10568
+
10569
+ The \`--logs\` option displays logs from the downstream execution when available.`,
10570
+ examples: [
10571
+ {
10572
+ cmd: "tailor-sdk executor trigger my-executor",
10573
+ desc: "Trigger an executor"
10574
+ },
10575
+ {
10576
+ cmd: "tailor-sdk executor trigger my-executor -d '{\"message\": \"hello\"}'",
10577
+ desc: "Trigger with data"
10578
+ },
10579
+ {
10580
+ cmd: "tailor-sdk executor trigger my-executor -d '{\"message\": \"hello\"}' -H \"X-Custom: value\" -H \"X-Another: value2\"",
10581
+ desc: "Trigger with data and headers"
10582
+ },
10583
+ {
10584
+ cmd: "tailor-sdk executor trigger my-executor -W",
10585
+ desc: "Trigger and wait for completion"
10586
+ },
10587
+ {
10588
+ cmd: "tailor-sdk executor trigger my-executor -W -l",
10589
+ desc: "Trigger, wait, and show logs"
10590
+ }
10591
+ ],
10288
10592
  args: z.object({
10289
10593
  ...commonArgs,
10290
10594
  ...jsonArgs,
@@ -10329,8 +10633,8 @@ const triggerCommand = defineCommand({
10329
10633
  name: args.executorName
10330
10634
  });
10331
10635
  if (!executor) throw new Error(`Executor '${args.executorName}' not found.`);
10332
- if (executor.triggerType === ExecutorTriggerType.EVENT) throw new Error(`Executor '${args.executorName}' has '${executorTriggerTypeToString(executor.triggerType)}' trigger type and cannot be triggered manually. Only executors with 'incomingWebhook' or 'schedule' triggers can be triggered manually.`);
10333
- if (executor.triggerType === ExecutorTriggerType.SCHEDULE && (args.data || args.header)) throw new Error(`Executor '${args.executorName}' has 'schedule' trigger type. The --data and --header options are only available for 'incomingWebhook' trigger type.`);
10636
+ if (executor.triggerType === ExecutorTriggerType.EVENT) throw new Error(`Executor '${args.executorName}' has '${executorTriggerTypeToString(executor.triggerType)}' trigger type and cannot be triggered manually. Only executors with 'INCOMING_WEBHOOK' or 'SCHEDULE' triggers can be triggered manually.`);
10637
+ if (executor.triggerType === ExecutorTriggerType.SCHEDULE && (args.data || args.header)) throw new Error(`Executor '${args.executorName}' has 'SCHEDULE' trigger type. The --data and --header options are only available for 'INCOMING_WEBHOOK' trigger type.`);
10334
10638
  let payload;
10335
10639
  const body = args.data;
10336
10640
  const headers = {};
@@ -10399,6 +10703,73 @@ const triggerCommand = defineCommand({
10399
10703
  })
10400
10704
  });
10401
10705
 
10706
+ //#endregion
10707
+ //#region src/cli/executor/webhook.ts
10708
+ /**
10709
+ * Build the webhook URL for an executor.
10710
+ * @param workspaceId - Workspace ID
10711
+ * @param executorName - Executor name
10712
+ * @returns Webhook URL
10713
+ */
10714
+ function buildWebhookUrl(workspaceId, executorName) {
10715
+ return `${platformBaseUrl}/webhook/v1/${workspaceId}/executor/${executorName}`;
10716
+ }
10717
+ /**
10718
+ * List executors with incoming webhook triggers and return CLI-friendly info.
10719
+ * @param options - Listing options
10720
+ * @returns List of webhook executors with URLs
10721
+ */
10722
+ async function listWebhookExecutors(options) {
10723
+ const client = await initOperatorClient(await loadAccessToken({
10724
+ useProfile: true,
10725
+ profile: options?.profile
10726
+ }));
10727
+ const workspaceId = loadWorkspaceId({
10728
+ workspaceId: options?.workspaceId,
10729
+ profile: options?.profile
10730
+ });
10731
+ return (await fetchAll(async (pageToken) => {
10732
+ const { executors, nextPageToken } = await client.listExecutorExecutors({
10733
+ workspaceId,
10734
+ pageToken
10735
+ });
10736
+ return [executors, nextPageToken];
10737
+ })).filter((e) => e.triggerType === ExecutorTriggerType.INCOMING_WEBHOOK).map((e) => ({
10738
+ name: e.name,
10739
+ webhookUrl: buildWebhookUrl(workspaceId, e.name),
10740
+ disabled: e.disabled
10741
+ }));
10742
+ }
10743
+ const listWebhookCommand = defineCommand({
10744
+ name: "list",
10745
+ description: "List executors with incoming webhook triggers",
10746
+ args: z.object({
10747
+ ...commonArgs,
10748
+ ...jsonArgs,
10749
+ ...workspaceArgs
10750
+ }),
10751
+ run: withCommonArgs(async (args) => {
10752
+ const executors = await listWebhookExecutors({
10753
+ workspaceId: args["workspace-id"],
10754
+ profile: args.profile
10755
+ });
10756
+ if (executors.length === 0) {
10757
+ logger.info("No webhook executors found.");
10758
+ return;
10759
+ }
10760
+ logger.out(executors, { display: { disabled: (v) => v ? styles.warning("true") : styles.dim("false") } });
10761
+ if (!args.json) logger.info("To test a webhook, run: tailor-sdk executor trigger <name> -d '{\"key\":\"value\"}'");
10762
+ })
10763
+ });
10764
+ const webhookCommand = defineCommand({
10765
+ name: "webhook",
10766
+ description: "Manage executor webhooks",
10767
+ subCommands: { list: listWebhookCommand },
10768
+ async run() {
10769
+ await runCommand(listWebhookCommand, []);
10770
+ }
10771
+ });
10772
+
10402
10773
  //#endregion
10403
10774
  //#region src/cli/generator/watch/index.ts
10404
10775
  /**
@@ -13263,5 +13634,5 @@ const updateCommand = defineCommand({
13263
13634
  });
13264
13635
 
13265
13636
  //#endregion
13266
- export { startWorkflow as $, withCommonArgs as $t, generateCommand as A, hasChanges as At, getMachineUserToken as B, loadWorkspaceId as Bt, resumeCommand as C, getMigrationFiles as Ct, truncate as D, reconstructSnapshotFromMigrations as Dt, listWorkflows as E, loadDiff as Et, removeCommand$1 as F, getDistDir as Ft, generateCommand$1 as G, initOAuth2Client as Gt, listCommand$5 as H, writePlatformConfig as Ht, listCommand$4 as I, apiCall as It, getExecutorJob as J, PATScope as Jt, triggerCommand as K, initOperatorClient as Kt, listOAuth2Clients as L, apiCommand as Lt, show as M, trnPrefix as Mt, showCommand as N, generateUserTypes as Nt, truncateCommand as O, formatDiffSummary as Ot, remove as P, loadConfig as Pt, startCommand as Q, jsonArgs as Qt, getCommand$1 as R, fetchLatestToken as Rt, healthCommand as S, getMigrationFilePath as St, listCommand$3 as T, isValidMigrationNumber as Tt, listMachineUsers as U, fetchAll as Ut, tokenCommand as V, readPlatformConfig as Vt, generate$1 as W, fetchUserInfo as Wt, listExecutorJobs as X, confirmationArgs as Xt, jobsCommand as Y, commonArgs as Yt, watchExecutorJob as Z, deploymentArgs as Zt, createCommand as _, compareSnapshots as _t, listCommand as a, apply as at, listCommand$2 as b, getLatestMigrationNumber as bt, inviteUser as c, waitForExecution$1 as ct, listCommand$1 as d, DB_TYPES_FILE_NAME as dt, workspaceArgs as en, getCommand$2 as et, listWorkspaces as f, DIFF_FILE_NAME as ft, deleteWorkspace as g, compareLocalTypesWithSnapshot as gt, deleteCommand as h, SCHEMA_FILE_NAME as ht, removeUser as i, listWorkflowExecutions as it, logBetaWarning as j, getNamespacesWithMigrations as jt, generate as k, formatMigrationDiff as kt, restoreCommand as l, MIGRATION_LABEL_KEY as lt, getWorkspace as m, MIGRATE_FILE_NAME as mt, updateUser as n, executionsCommand as nt, listUsers as o, applyCommand as ot, getCommand as p, INITIAL_SCHEMA_NUMBER as pt, triggerExecutor as q, readPackageJson as qt, removeCommand as r, getWorkflowExecution as rt, inviteCommand as s, executeScript as st, updateCommand as t, getWorkflow as tt, restoreWorkspace as u, parseMigrationLabelNumber as ut, createWorkspace as v, createSnapshotFromLocalTypes as vt, resumeWorkflow as w, getNextMigrationNumber as wt, getAppHealth as x, getMigrationDirPath as xt, listApps as y, formatMigrationNumber as yt, getOAuth2Client as z, loadAccessToken as zt };
13267
- //# sourceMappingURL=update-Exhc9AkY.mjs.map
13637
+ export { jobsCommand as $, readPackageJson as $t, generateCommand as A, getNextMigrationNumber as At, getMachineUserToken as B, loadConfig as Bt, resumeCommand as C, compareSnapshots as Ct, truncate as D, getMigrationDirPath as Dt, listWorkflows as E, getLatestMigrationNumber as Et, removeCommand$1 as F, formatMigrationDiff as Ft, generateCommand$1 as G, loadAccessToken as Gt, listCommand$5 as H, apiCall as Ht, listCommand$4 as I, hasChanges as It, triggerCommand as J, writePlatformConfig as Jt, listWebhookExecutors as K, loadWorkspaceId as Kt, listOAuth2Clients as L, getNamespacesWithMigrations as Lt, show as M, loadDiff as Mt, showCommand as N, reconstructSnapshotFromMigrations as Nt, truncateCommand as O, getMigrationFilePath as Ot, remove as P, formatDiffSummary as Pt, getExecutorJob as Q, initOperatorClient as Qt, getCommand$1 as R, trnPrefix as Rt, healthCommand as S, compareLocalTypesWithSnapshot as St, listCommand$3 as T, formatMigrationNumber as Tt, listMachineUsers as U, apiCommand as Ut, tokenCommand as V, getDistDir as Vt, generate$1 as W, fetchLatestToken as Wt, listCommand$6 as X, fetchUserInfo as Xt, triggerExecutor as Y, fetchAll as Yt, listExecutors as Z, initOAuth2Client as Zt, createCommand as _, DB_TYPES_FILE_NAME as _t, listCommand as a, withCommonArgs as an, getWorkflow as at, listCommand$2 as b, MIGRATE_FILE_NAME as bt, inviteUser as c, listWorkflowExecutions as ct, listCommand$1 as d, apply as dt, PATScope 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, jsonArgs as in, getCommand$2 as it, logBetaWarning as j, isValidMigrationNumber as jt, generate as k, getMigrationFiles as kt, restoreCommand as l, getCommand$3 as lt, getWorkspace as m, waitForExecution$1 as mt, updateUser as n, confirmationArgs as nn, startCommand as nt, listUsers as o, workspaceArgs as on, executionsCommand as ot, getCommand as p, executeScript as pt, webhookCommand as q, readPlatformConfig as qt, removeCommand as r, deploymentArgs as rn, startWorkflow as rt, inviteCommand as s, getWorkflowExecution as st, updateCommand as t, commonArgs as tn, watchExecutorJob as tt, restoreWorkspace as u, getExecutor as ut, createWorkspace as v, DIFF_FILE_NAME as vt, resumeWorkflow as w, createSnapshotFromLocalTypes as wt, getAppHealth as x, SCHEMA_FILE_NAME as xt, listApps as y, INITIAL_SCHEMA_NUMBER as yt, getOAuth2Client as z, generateUserTypes as zt };
13638
+ //# sourceMappingURL=update-D0muqqOP.mjs.map