@tailor-platform/sdk 1.39.1 → 1.40.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.
Files changed (54) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/README.md +7 -10
  3. package/dist/{actor-Bb4OVq1j.d.mts → actor-B2oEmlTc.d.mts} +2 -2
  4. package/dist/application-CE2s_a6w.mjs +4 -0
  5. package/dist/{application-BHu8YE-g.mjs → application-EvhIIVg0.mjs} +2 -2
  6. package/dist/{application-BHu8YE-g.mjs.map → application-EvhIIVg0.mjs.map} +1 -1
  7. package/dist/cli/index.mjs +153 -32
  8. package/dist/cli/index.mjs.map +1 -1
  9. package/dist/cli/lib.d.mts +40 -6
  10. package/dist/cli/lib.mjs +3 -3
  11. package/dist/cli/skills.mjs +13 -43
  12. package/dist/cli/skills.mjs.map +1 -1
  13. package/dist/{client-B2K45RvK.mjs → client-CcV6Jjds.mjs} +38 -7
  14. package/dist/{client-B2K45RvK.mjs.map → client-CcV6Jjds.mjs.map} +1 -1
  15. package/dist/client-Cn9SqhZT.mjs +4 -0
  16. package/dist/configure/index.d.mts +4 -4
  17. package/dist/{crash-report-CPUF3T5d.mjs → crash-report-CSYupJ0T.mjs} +1 -1
  18. package/dist/{crash-report-CACiemAr.mjs → crash-report-CUbm1ErM.mjs} +2 -2
  19. package/dist/{crash-report-CACiemAr.mjs.map → crash-report-CUbm1ErM.mjs.map} +1 -1
  20. package/dist/{index-Cx1RYDbu.d.mts → index-BtXZdz-F.d.mts} +2 -2
  21. package/dist/{index-CeFwhUkX.d.mts → index-Chvw1Eod.d.mts} +2 -2
  22. package/dist/{index-Ch8Em3nz.d.mts → index-CiNNNpuH.d.mts} +2 -2
  23. package/dist/{index-BYmdVno1.d.mts → index-D_ezppY7.d.mts} +4 -4
  24. package/dist/{index-DLO_XvLi.d.mts → index-reFAYSX7.d.mts} +2 -2
  25. package/dist/{interceptor-B5bKVwgq.mjs → interceptor-4UC-KTno.mjs} +1 -1
  26. package/dist/{interceptor-B5bKVwgq.mjs.map → interceptor-4UC-KTno.mjs.map} +1 -1
  27. package/dist/plugin/builtin/enum-constants/index.d.mts +1 -1
  28. package/dist/plugin/builtin/file-utils/index.d.mts +1 -1
  29. package/dist/plugin/builtin/kysely-type/index.d.mts +1 -1
  30. package/dist/plugin/builtin/seed/index.d.mts +1 -1
  31. package/dist/plugin/index.d.mts +2 -2
  32. package/dist/repl-editor-DjycioU-.mjs +255 -0
  33. package/dist/repl-editor-DjycioU-.mjs.map +1 -0
  34. package/dist/{runtime-2xqzvkQv.mjs → runtime-B9R1TzLD.mjs} +234 -172
  35. package/dist/runtime-B9R1TzLD.mjs.map +1 -0
  36. package/dist/{tailor-db-field-B99RnR2N.d.mts → tailor-db-field-CoFKRCYW.d.mts} +1 -1
  37. package/dist/utils/test/index.d.mts +2 -2
  38. package/dist/{workflow.generated-DSwr-k57.d.mts → workflow.generated-Btz6srLR.d.mts} +2 -2
  39. package/docs/cli/auth.md +20 -14
  40. package/docs/cli/executor.md +17 -14
  41. package/docs/cli/function.md +6 -4
  42. package/docs/cli/query.md +45 -0
  43. package/docs/cli/secret.md +13 -9
  44. package/docs/cli/skills.md +75 -0
  45. package/docs/cli/staticwebsite.md +6 -4
  46. package/docs/cli/user.md +9 -1
  47. package/docs/cli/workflow.md +17 -13
  48. package/docs/cli-reference.md +16 -0
  49. package/docs/services/idp.md +85 -64
  50. package/docs/services/workflow.md +1 -1
  51. package/package.json +17 -14
  52. package/dist/application-C8Lr37AM.mjs +0 -4
  53. package/dist/client-CEVmv94H.mjs +0 -4
  54. package/dist/runtime-2xqzvkQv.mjs.map +0 -1
@@ -1,9 +1,9 @@
1
1
 
2
- import { $ as Subgraph_ServiceType, B as AuthSCIMAttribute_Mutability, C as TailorDBType_Permission_Permit, D as IdPPermissionOperator, E as IdPLang, F as AuthHookPoint, G as TenantProviderConfig_TenantProviderType, H as AuthSCIMAttribute_Uniqueness, I as AuthIDPConfig_AuthType, J as ConditionSchema, K as UserProfileProviderConfig_UserProfileProviderType, L as AuthInvokerSchema, M as ExecutorTargetType, N as ExecutorTriggerType, O as IdPPermissionPermit, P as AuthConnection_Type, Q as ApplicationSchemaUpdateAttemptStatus, R as AuthOAuth2Client_ClientType, S as TailorDBType_Permission_Operator, T as PipelineResolver_OperationType, U as AuthSCIMConfig_AuthorizationType, V as AuthSCIMAttribute_Type, X as FilterSchema, Y as Condition_Operator, Z as PageDirection, _ as WorkflowExecution_Status, a as fetchMachineUserToken, b as TailorDBGQLPermission_Operator, f as platformBaseUrl, g as WorkspacePlatformUserRole, h as OperatorService, i as fetchAll, j as ExecutorJobStatus, k as FunctionExecution_Status, m as userAgent, p as resolveStaticWebsiteUrls, q as GetApplicationSchemaHealthResponse_ApplicationSchemaHealthStatus, u as initOperatorClient, v as WorkflowJobExecution_Status, w as TailorDBType_PermitAction, x as TailorDBGQLPermission_Permit, y as TailorDBGQLPermission_Action, z as AuthOAuth2Client_GrantType } from "./client-B2K45RvK.mjs";
2
+ import { $ as ApplicationSchemaUpdateAttemptStatus, A as FunctionExecution_Status, B as AuthOAuth2Client_GrantType, C as TailorDBType_Permission_Operator, D as IdPLang, E as PipelineResolver_OperationType, F as AuthConnection_Type, H as AuthSCIMAttribute_Type, I as AuthHookPoint, J as GetApplicationSchemaHealthResponse_ApplicationSchemaHealthStatus, K as TenantProviderConfig_TenantProviderType, L as AuthIDPConfig_AuthType, M as ExecutorJobStatus, N as ExecutorTargetType, O as IdPPermissionOperator, P as ExecutorTriggerType, Q as PageDirection, R as AuthInvokerSchema, S as TailorDBGQLPermission_Permit, T as TailorDBType_PermitAction, U as AuthSCIMAttribute_Uniqueness, V as AuthSCIMAttribute_Mutability, W as AuthSCIMConfig_AuthorizationType, X as Condition_Operator, Y as ConditionSchema, Z as FilterSchema, _ as WorkspacePlatformUserRole, a as fetchMachineUserToken, b as TailorDBGQLPermission_Action, d as initOperatorClient, et as Subgraph_ServiceType, g as OperatorService, h as userAgent, i as fetchAll, k as IdPPermissionPermit, m as resolveStaticWebsiteUrls, o as fetchPaged, p as platformBaseUrl, q as UserProfileProviderConfig_UserProfileProviderType, v as WorkflowExecution_Status, w as TailorDBType_Permission_Permit, x as TailorDBGQLPermission_Operator, y as WorkflowJobExecution_Status, z as AuthOAuth2Client_ClientType } from "./client-CcV6Jjds.mjs";
3
3
  import { t as db } from "./schema-CEcfEyPN.mjs";
4
4
  import { a as parseBoolean, i as symbols, n as logger, r as styles, t as CIPromptError } from "./logger-DTNAMYGy.mjs";
5
5
  import { t as readPackageJson } from "./package-json-CWp8s9dE.mjs";
6
- import { S as readPlatformConfig, T as writePlatformConfig, _ as loadConfig, b as loadAccessToken, d as stringifyFunction, f as tailorUserMap, g as hashFile, h as getDistDir, l as OAuth2ClientSchema, m as createBundleCache, n as generatePluginFilesIfNeeded, p as loadFilesWithIgnores, r as loadApplication, s as createExecutorService, t as defineApplication, u as TailorDBTypeSchema, x as loadWorkspaceId } from "./application-BHu8YE-g.mjs";
6
+ import { S as readPlatformConfig, T as writePlatformConfig, _ as loadConfig, b as loadAccessToken, d as stringifyFunction, f as tailorUserMap, g as hashFile, h as getDistDir, l as OAuth2ClientSchema, m as createBundleCache, n as generatePluginFilesIfNeeded, p as loadFilesWithIgnores, r as loadApplication, s as createExecutorService, t as defineApplication, u as TailorDBTypeSchema, x as loadWorkspaceId } from "./application-EvhIIVg0.mjs";
7
7
  import { r as withSpan } from "./telemetry-BuDto_2q.mjs";
8
8
  import { n as isCLIError, t as createCLIError } from "./errors-ChWX5ZG8.mjs";
9
9
  import { arg, createDefineCommand, defineCommand, runCommand } from "politty";
@@ -23,6 +23,7 @@ import { resolveTSConfig } from "pkg-types";
23
23
  import ml from "multiline-ts";
24
24
  import { tmpdir } from "node:os";
25
25
  import { findUpSync } from "find-up-simple";
26
+ import { xdgConfig } from "xdg-basedir";
26
27
  import * as rolldown from "rolldown";
27
28
  import * as fs from "node:fs/promises";
28
29
  import { glob } from "node:fs/promises";
@@ -36,7 +37,7 @@ import { setTimeout as setTimeout$1 } from "timers/promises";
36
37
  import { spawn } from "node:child_process";
37
38
  import { watch } from "chokidar";
38
39
  import * as madgeModule from "madge";
39
- import { createInterface } from "node:readline/promises";
40
+ import { createPrompt } from "@toiroakr/read-multiline";
40
41
  import { astVisitor, parse } from "pgsql-ast-parser";
41
42
  import { parse as parse$1 } from "@0no-co/graphql.web";
42
43
 
@@ -70,6 +71,26 @@ function parseDuration(duration) {
70
71
  */
71
72
  const positiveIntArg = z.coerce.number().int().positive();
72
73
  /**
74
+ * Schema for non-negative integer validation (from string input).
75
+ * Accepts 0 (used for `--limit 0` to disable the limit).
76
+ */
77
+ const nonNegativeIntArg = z.coerce.number().int().nonnegative();
78
+ /**
79
+ * Schema for sort order (`asc` or `desc`).
80
+ */
81
+ const orderArg = z.enum(["asc", "desc"]);
82
+ /**
83
+ * Translate a CLI `--order` value into the proto `PageDirection` enum.
84
+ * Returns `undefined` when the user did not specify an order so that
85
+ * callers can omit the field and fall back to the server default.
86
+ * @param order - Order string from CLI args (`"asc"` | `"desc"` | undefined)
87
+ * @returns PageDirection, or undefined when `order` is undefined
88
+ */
89
+ function toPageDirection(order) {
90
+ if (order === void 0) return void 0;
91
+ return order === "asc" ? PageDirection.ASC : PageDirection.DESC;
92
+ }
93
+ /**
73
94
  * Load env files from parsed arguments.
74
95
  * Processes --env-file first, then --env-file-if-exists.
75
96
  *
@@ -191,6 +212,34 @@ const organizationArgs = { "organization-id": arg(z.string(), {
191
212
  completion: { type: "none" }
192
213
  }) };
193
214
  /**
215
+ * Arguments for list commands that accept `--order` / `--limit`. Sort
216
+ * order defaults to `desc` (newest first) because most callers want the
217
+ * latest items; pass `--order asc` to opt in to ascending order. The
218
+ * limit is unbounded by default so existing invocations keep returning
219
+ * every item; pass `--limit N` to cap the result size.
220
+ * @param defaultOrder - Default value for `--order` (defaults to `"desc"`)
221
+ * @returns Argument shape suitable for spreading into a command schema
222
+ */
223
+ const paginationArgs = (defaultOrder = "desc") => ({
224
+ order: arg(orderArg.default(defaultOrder), { description: "Sort order (asc or desc)" }),
225
+ limit: arg(nonNegativeIntArg.optional(), {
226
+ alias: "l",
227
+ description: "Maximum number of items to return (0 or omit: unlimited)"
228
+ })
229
+ });
230
+ /**
231
+ * Arguments for time-series log list commands. Defaults to newest-first
232
+ * (`desc`) and a 50-item cap so that listing stays responsive on busy
233
+ * workspaces. Pass `--limit 0` to disable the cap and fetch all entries.
234
+ */
235
+ const pagedLogArgs = {
236
+ order: arg(orderArg.default("desc"), { description: "Sort order (asc or desc)" }),
237
+ limit: arg(nonNegativeIntArg.default(50), {
238
+ alias: "l",
239
+ description: "Maximum number of items to return (0: unlimited)"
240
+ })
241
+ };
242
+ /**
194
243
  * Arguments for commands that require folder context
195
244
  */
196
245
  const folderArgs = { "folder-id": arg(z.string(), {
@@ -914,7 +963,8 @@ var PluginManager = class {
914
963
  generatePluginFiles(params) {
915
964
  const { outputDir, sourceTypeInfoMap, configPath, typeGenerator, executorGenerator } = params;
916
965
  const typeGenerationResult = typeGenerator(this.generatedTypes, outputDir);
917
- this.pluginExecutorFiles = executorGenerator(this.getPluginGeneratedExecutorsWithImportPath(), outputDir, typeGenerationResult, sourceTypeInfoMap, configPath);
966
+ const pluginExecutors = this.getPluginGeneratedExecutorsWithImportPath();
967
+ this.pluginExecutorFiles = executorGenerator(pluginExecutors, outputDir, typeGenerationResult, sourceTypeInfoMap, configPath);
918
968
  return this.pluginExecutorFiles;
919
969
  }
920
970
  /**
@@ -2361,6 +2411,7 @@ function normalizeComparableIdPService(input) {
2361
2411
  }
2362
2412
  function normalizeComparablePermission(permission) {
2363
2413
  if (!permission) return;
2414
+ if (permission.create.length === 0 && permission.read.length === 0 && permission.update.length === 0 && permission.delete.length === 0 && permission.sendPasswordResetEmail.length === 0) return;
2364
2415
  const normalizePolicy = (policy) => ({
2365
2416
  conditions: policy.conditions.map((c) => ({
2366
2417
  left: c.left ? { kind: c.left.kind } : void 0,
@@ -9174,17 +9225,18 @@ async function listWorkflowExecutions(options) {
9174
9225
  }) }));
9175
9226
  }
9176
9227
  const filter = filters.length > 0 ? create(FilterSchema, { and: filters }) : void 0;
9177
- return (await fetchAll(async (pageToken, maxPageSize) => {
9228
+ const pageDirection = toPageDirection(options?.order ?? "desc");
9229
+ return (await fetchPaged(async (pageToken, pageSize) => {
9178
9230
  const { executions, nextPageToken } = await client.listWorkflowExecutions({
9179
9231
  workspaceId,
9180
9232
  workflowName: workflowName ?? "",
9181
9233
  pageToken,
9182
- pageSize: maxPageSize,
9183
- pageDirection: PageDirection.DESC,
9234
+ pageSize,
9235
+ pageDirection,
9184
9236
  filter
9185
9237
  });
9186
9238
  return [executions, nextPageToken];
9187
- })).map(toWorkflowExecutionInfo);
9239
+ }, { limit: options?.limit })).map(toWorkflowExecutionInfo);
9188
9240
  }
9189
9241
  /**
9190
9242
  * Get a single workflow execution with optional logs.
@@ -9317,6 +9369,7 @@ const executionsCommand = defineAppCommand({
9317
9369
  description: "List or get workflow executions.",
9318
9370
  args: z.object({
9319
9371
  ...workspaceArgs,
9372
+ ...pagedLogArgs,
9320
9373
  executionId: arg(z.string().optional(), {
9321
9374
  positional: true,
9322
9375
  description: "Execution ID (if provided, shows details)"
@@ -9351,7 +9404,9 @@ const executionsCommand = defineAppCommand({
9351
9404
  workspaceId: args["workspace-id"],
9352
9405
  profile: args.profile,
9353
9406
  workflowName: args["workflow-name"],
9354
- status: args.status
9407
+ status: args.status,
9408
+ order: args.order,
9409
+ limit: args.limit
9355
9410
  });
9356
9411
  logger.out(executions);
9357
9412
  }
@@ -9639,15 +9694,19 @@ async function listExecutorJobs(options) {
9639
9694
  }) }));
9640
9695
  }
9641
9696
  const filter = filters.length > 0 ? create(FilterSchema, { and: filters }) : void 0;
9697
+ const pageDirection = toPageDirection(options.order ?? "desc");
9642
9698
  try {
9643
- const { jobs } = await client.listExecutorJobs({
9644
- workspaceId,
9645
- executorName,
9646
- pageSize: options.limit,
9647
- pageDirection: PageDirection.DESC,
9648
- filter
9649
- });
9650
- return jobs.map(toExecutorJobListInfo);
9699
+ return (await fetchPaged(async (pageToken, pageSize) => {
9700
+ const { jobs, nextPageToken } = await client.listExecutorJobs({
9701
+ workspaceId,
9702
+ executorName,
9703
+ pageToken,
9704
+ pageSize,
9705
+ pageDirection,
9706
+ filter
9707
+ });
9708
+ return [jobs, nextPageToken];
9709
+ }, { limit: options.limit })).map(toExecutorJobListInfo);
9651
9710
  } catch (error) {
9652
9711
  if (error instanceof ConnectError && error.code === Code.NotFound) throw new Error(`Executor '${executorName}' not found.`, { cause: error });
9653
9712
  throw error;
@@ -9911,11 +9970,12 @@ const jobsCommand = defineAppCommand({
9911
9970
  alias: "i",
9912
9971
  description: "Polling interval when using --wait (e.g., '3s', '500ms', '1m')"
9913
9972
  }),
9973
+ ...pagedLogArgs,
9974
+ limit: arg(nonNegativeIntArg.default(50), { description: "Maximum number of jobs to list (0: unlimited, default: 50) (list mode only)" }),
9914
9975
  logs: arg(z.boolean().default(false), {
9915
9976
  alias: "l",
9916
9977
  description: "Display function execution logs after completion (requires --wait)"
9917
- }),
9918
- limit: arg(positiveIntArg.optional(), { description: "Maximum number of jobs to list (default: 50, max: 1000) (list mode only)" })
9978
+ })
9919
9979
  }).strict(),
9920
9980
  run: async (args) => {
9921
9981
  if (args.jobId) {
@@ -9979,6 +10039,7 @@ const jobsCommand = defineAppCommand({
9979
10039
  const jobs = await listExecutorJobs({
9980
10040
  executorName: args.executorName,
9981
10041
  status: args.status,
10042
+ order: args.order,
9982
10043
  limit: args.limit,
9983
10044
  workspaceId: args["workspace-id"],
9984
10045
  profile: args.profile
@@ -10004,23 +10065,30 @@ async function listExecutors(options) {
10004
10065
  workspaceId: options?.workspaceId,
10005
10066
  profile: options?.profile
10006
10067
  });
10007
- return (await fetchAll(async (pageToken, maxPageSize) => {
10068
+ const pageDirection = toPageDirection(options?.order);
10069
+ return (await fetchPaged(async (pageToken, pageSize) => {
10008
10070
  const { executors, nextPageToken } = await client.listExecutorExecutors({
10009
10071
  workspaceId,
10010
10072
  pageToken,
10011
- pageSize: maxPageSize
10073
+ pageSize,
10074
+ pageDirection
10012
10075
  });
10013
10076
  return [executors, nextPageToken];
10014
- })).map((e) => toExecutorListInfo(e));
10077
+ }, { limit: options?.limit })).map((e) => toExecutorListInfo(e));
10015
10078
  }
10016
10079
  const listCommand$8 = defineAppCommand({
10017
10080
  name: "list",
10018
10081
  description: "List all executors",
10019
- args: z.object({ ...workspaceArgs }).strict(),
10082
+ args: z.object({
10083
+ ...workspaceArgs,
10084
+ ...paginationArgs()
10085
+ }).strict(),
10020
10086
  run: async (args) => {
10021
10087
  const executors = await listExecutors({
10022
10088
  workspaceId: args["workspace-id"],
10023
- profile: args.profile
10089
+ profile: args.profile,
10090
+ order: args.order,
10091
+ limit: args.limit
10024
10092
  });
10025
10093
  if (executors.length === 0) {
10026
10094
  logger.info("No executors found.");
@@ -10247,15 +10315,6 @@ The \`--logs\` option displays logs from the downstream execution when available
10247
10315
  //#endregion
10248
10316
  //#region src/cli/commands/executor/webhook.ts
10249
10317
  /**
10250
- * Build the webhook URL for an executor.
10251
- * @param workspaceId - Workspace ID
10252
- * @param executorName - Executor name
10253
- * @returns Webhook URL
10254
- */
10255
- function buildWebhookUrl(workspaceId, executorName) {
10256
- return `${platformBaseUrl}/webhook/v1/${workspaceId}/executor/${executorName}`;
10257
- }
10258
- /**
10259
10318
  * List executors with incoming webhook triggers and return CLI-friendly info.
10260
10319
  * @param options - Listing options
10261
10320
  * @returns List of webhook executors with URLs
@@ -10270,16 +10329,16 @@ async function listWebhookExecutors(options) {
10270
10329
  profile: options?.profile
10271
10330
  });
10272
10331
  return (await fetchAll(async (pageToken, maxPageSize) => {
10273
- const { executors, nextPageToken } = await client.listExecutorExecutors({
10332
+ const { webhooks, nextPageToken } = await client.listExecutorIncomingWebhooks({
10274
10333
  workspaceId,
10275
10334
  pageToken,
10276
10335
  pageSize: maxPageSize
10277
10336
  });
10278
- return [executors, nextPageToken];
10279
- })).filter((e) => e.triggerType === ExecutorTriggerType.INCOMING_WEBHOOK).map((e) => ({
10280
- name: e.name,
10281
- webhookUrl: buildWebhookUrl(workspaceId, e.name),
10282
- disabled: e.disabled
10337
+ return [webhooks, nextPageToken];
10338
+ })).map((w) => ({
10339
+ name: w.executorName,
10340
+ webhookUrl: w.url,
10341
+ disabled: w.disabled
10283
10342
  }));
10284
10343
  }
10285
10344
  const listWebhookCommand = defineAppCommand({
@@ -11204,25 +11263,32 @@ async function listMachineUsers(options) {
11204
11263
  applicationName: config.name
11205
11264
  });
11206
11265
  if (!application?.authNamespace) throw new Error(`Application ${config.name} does not have an auth configuration.`);
11207
- return (await fetchAll(async (pageToken, maxPageSize) => {
11266
+ const pageDirection = toPageDirection(options?.order);
11267
+ return (await fetchPaged(async (pageToken, pageSize) => {
11208
11268
  const { machineUsers, nextPageToken } = await client.listAuthMachineUsers({
11209
11269
  workspaceId,
11210
11270
  pageToken,
11211
- pageSize: maxPageSize,
11212
- authNamespace: application.authNamespace
11271
+ pageSize,
11272
+ authNamespace: application.authNamespace,
11273
+ pageDirection
11213
11274
  });
11214
11275
  return [machineUsers, nextPageToken];
11215
- })).map(machineUserInfo);
11276
+ }, { limit: options?.limit })).map(machineUserInfo);
11216
11277
  }
11217
11278
  const listCommand$7 = defineAppCommand({
11218
11279
  name: "list",
11219
11280
  description: "List all machine users in the application.",
11220
- args: z.object({ ...deploymentArgs }).strict(),
11281
+ args: z.object({
11282
+ ...deploymentArgs,
11283
+ ...paginationArgs()
11284
+ }).strict(),
11221
11285
  run: async (args) => {
11222
11286
  const machineUsers = await listMachineUsers({
11223
11287
  workspaceId: args["workspace-id"],
11224
11288
  profile: args.profile,
11225
- configPath: args.config
11289
+ configPath: args.config,
11290
+ order: args.order,
11291
+ limit: args.limit
11226
11292
  });
11227
11293
  logger.out(machineUsers, { display: {
11228
11294
  createdAt: null,
@@ -11412,25 +11478,32 @@ async function listOAuth2Clients(options) {
11412
11478
  applicationName: config.name
11413
11479
  });
11414
11480
  if (!application?.authNamespace) throw new Error(`Application ${config.name} does not have an auth configuration.`);
11415
- return (await fetchAll(async (pageToken, maxPageSize) => {
11481
+ const pageDirection = toPageDirection(options?.order);
11482
+ return (await fetchPaged(async (pageToken, pageSize) => {
11416
11483
  const { oauth2Clients, nextPageToken } = await client.listAuthOAuth2Clients({
11417
11484
  workspaceId,
11418
11485
  pageToken,
11419
- pageSize: maxPageSize,
11420
- namespaceName: application.authNamespace
11486
+ pageSize,
11487
+ namespaceName: application.authNamespace,
11488
+ pageDirection
11421
11489
  });
11422
11490
  return [oauth2Clients, nextPageToken];
11423
- })).map(toOAuth2ClientInfo);
11491
+ }, { limit: options?.limit })).map(toOAuth2ClientInfo);
11424
11492
  }
11425
11493
  const listCommand$6 = defineAppCommand({
11426
11494
  name: "list",
11427
11495
  description: "List all OAuth2 clients in the application.",
11428
- args: z.object({ ...deploymentArgs }).strict(),
11496
+ args: z.object({
11497
+ ...deploymentArgs,
11498
+ ...paginationArgs()
11499
+ }).strict(),
11429
11500
  run: async (args) => {
11430
11501
  const oauth2Clients = await listOAuth2Clients({
11431
11502
  workspaceId: args["workspace-id"],
11432
11503
  profile: args.profile,
11433
- configPath: args.config
11504
+ configPath: args.config,
11505
+ order: args.order,
11506
+ limit: args.limit
11434
11507
  });
11435
11508
  logger.out(oauth2Clients);
11436
11509
  }
@@ -12689,7 +12762,7 @@ async function generate(options) {
12689
12762
  if (options.init) await handleInitOption(namespacesWithMigrations, options.yes);
12690
12763
  let pluginManager;
12691
12764
  if (plugins.length > 0) pluginManager = new PluginManager(plugins);
12692
- const { defineApplication } = await import("./application-C8Lr37AM.mjs");
12765
+ const { defineApplication } = await import("./application-CE2s_a6w.mjs");
12693
12766
  const application = defineApplication({
12694
12767
  config,
12695
12768
  pluginManager
@@ -13048,23 +13121,30 @@ async function listWorkflows(options) {
13048
13121
  workspaceId: options?.workspaceId,
13049
13122
  profile: options?.profile
13050
13123
  });
13051
- return (await fetchAll(async (pageToken, maxPageSize) => {
13124
+ const pageDirection = toPageDirection(options?.order);
13125
+ return (await fetchPaged(async (pageToken, pageSize) => {
13052
13126
  const { workflows, nextPageToken } = await client.listWorkflows({
13053
13127
  workspaceId,
13054
13128
  pageToken,
13055
- pageSize: maxPageSize
13129
+ pageSize,
13130
+ pageDirection
13056
13131
  });
13057
13132
  return [workflows, nextPageToken];
13058
- })).map(toWorkflowListInfo);
13133
+ }, { limit: options?.limit })).map(toWorkflowListInfo);
13059
13134
  }
13060
13135
  const listCommand$3 = defineAppCommand({
13061
13136
  name: "list",
13062
13137
  description: "List all workflows in the workspace.",
13063
- args: z.object({ ...workspaceArgs }).strict(),
13138
+ args: z.object({
13139
+ ...workspaceArgs,
13140
+ ...paginationArgs()
13141
+ }).strict(),
13064
13142
  run: async (args) => {
13065
13143
  const workflows = await listWorkflows({
13066
13144
  workspaceId: args["workspace-id"],
13067
- profile: args.profile
13145
+ profile: args.profile,
13146
+ order: args.order,
13147
+ limit: args.limit
13068
13148
  });
13069
13149
  if (workflows.length === 0 && !args.json) {
13070
13150
  logger.info("No workflows found.");
@@ -14461,10 +14541,6 @@ async function prepareQueryExecutor(options) {
14461
14541
  }
14462
14542
  };
14463
14543
  }
14464
- function isReadlineTerminationError(error) {
14465
- if (!(error instanceof Error) || !("code" in error)) return false;
14466
- return error.code === "ABORT_ERR" || error.code === "ERR_USE_AFTER_CLOSE";
14467
- }
14468
14544
  /**
14469
14545
  * Resolve a backslash REPL command into its normalized action.
14470
14546
  * @param input - Raw user input
@@ -14479,131 +14555,114 @@ function resolveReplCommand(input) {
14479
14555
  return "unknown";
14480
14556
  }
14481
14557
  /**
14482
- * Decide how REPL should react to Ctrl+C based on current buffered input.
14483
- * @param bufferedLines - Previously accepted lines in the current statement buffer
14484
- * @param currentLine - In-progress line currently being edited
14485
- * @returns Whether to clear the buffer or exit the REPL
14486
- */
14487
- function resolveReplInterruptAction(bufferedLines, currentLine) {
14488
- if (bufferedLines.length === 0 && currentLine.length === 0) return "exit";
14489
- return "clear";
14490
- }
14491
- /**
14492
14558
  * Clear the interactive terminal screen and move the cursor to the top-left.
14493
14559
  */
14494
14560
  function clearReplScreen() {
14495
14561
  process.stdout.write("\x1Bc");
14496
14562
  }
14563
+ function sanitizeHistoryScope(value) {
14564
+ return value.replace(/[^a-zA-Z0-9._-]/g, "_");
14565
+ }
14566
+ function getReplHistoryPath(engine, profile, workspaceId) {
14567
+ if (!xdgConfig) return;
14568
+ const scope = [profile, workspaceId].filter((value) => Boolean(value)).map(sanitizeHistoryScope).join("-");
14569
+ const engineSlug = engine === "sql" ? "sql" : "gql";
14570
+ const suffix = scope ? `-${scope}` : "";
14571
+ return path.join(xdgConfig, "tailor-platform", `query-history-${engineSlug}${suffix}.json`);
14572
+ }
14573
+ function createReplValidator(engine) {
14574
+ return (value) => {
14575
+ const trimmed = value.trim();
14576
+ if (trimmed === "") return;
14577
+ if (resolveReplCommand(trimmed) !== null) return;
14578
+ if (engine === "sql") return isSqlInputComplete(value) ? void 0 : "SQL statement is incomplete (missing ';').";
14579
+ return isGraphQLInputComplete(value) ? void 0 : "GraphQL document is incomplete.";
14580
+ };
14581
+ }
14497
14582
  async function runRepl(options) {
14498
14583
  if (!process.stdin.isTTY || !process.stdout.isTTY) throw new Error("Non-interactive terminals are not supported. Pass -q/--query or -f/--file to run a query.");
14499
14584
  const execute = await prepareQueryExecutor(options);
14500
- const rl = createInterface({
14501
- input: process.stdin,
14502
- output: process.stdout
14585
+ const historyPath = getReplHistoryPath(options.engine, options.profile, options.workspaceId);
14586
+ const validate = createReplValidator(options.engine);
14587
+ const { highlightSqlLine, highlightGraphqlLine, replTransform } = await import("./repl-editor-DjycioU-.mjs");
14588
+ const highlight = options.engine === "sql" ? highlightSqlLine : highlightGraphqlLine;
14589
+ const prompt = createPrompt({
14590
+ prefix: "",
14591
+ preferNewlineOnEnter: options.newlineOnEnter,
14592
+ validate,
14593
+ highlight,
14594
+ transform: replTransform,
14595
+ clearAfterSubmit: false,
14596
+ history: historyPath ? {
14597
+ filePath: historyPath,
14598
+ maxEntries: 100
14599
+ } : [],
14600
+ helpFooter: {
14601
+ items: ["submit", "newline"],
14602
+ maxLines: 1
14603
+ }
14503
14604
  });
14504
14605
  logger.info(`Entering ${options.engine.toUpperCase()} REPL mode.`);
14505
14606
  logger.info("Type \\help for usage, \\q to quit.");
14506
- const lines = [];
14507
- try {
14508
- while (true) {
14509
- const prompt = lines.length === 0 ? `${options.engine}> ` : " ";
14510
- let line;
14511
- let interruptAction = null;
14512
- const controller = new AbortController();
14513
- const handleSigint = () => {
14514
- interruptAction = resolveReplInterruptAction(lines, rl.line);
14515
- if (interruptAction === "clear") {
14516
- lines.length = 0;
14517
- rl.write(null, {
14518
- ctrl: true,
14519
- name: "u"
14520
- });
14521
- process.stdout.write("\n");
14522
- } else rl.close();
14523
- controller.abort();
14524
- };
14525
- rl.once("SIGINT", handleSigint);
14526
- try {
14527
- line = await rl.question(prompt, { signal: controller.signal });
14528
- } catch (error) {
14529
- rl.off("SIGINT", handleSigint);
14530
- if (controller.signal.aborted) {
14531
- if (interruptAction === "exit") return;
14532
- continue;
14533
- }
14534
- if (isReadlineTerminationError(error)) return;
14535
- throw error;
14536
- } finally {
14537
- rl.off("SIGINT", handleSigint);
14538
- }
14539
- const trimmed = line.trim();
14540
- if (lines.length === 0 && trimmed === "") continue;
14541
- if (lines.length === 0) {
14542
- const command = resolveReplCommand(trimmed);
14543
- if (command === "quit") return;
14544
- if (command === "help") {
14545
- printReplHelp(options.engine);
14546
- continue;
14547
- }
14548
- if (command === "clear") {
14549
- clearReplScreen();
14550
- continue;
14551
- }
14552
- if (command === "unknown") {
14553
- logger.warn(`Unknown command: ${trimmed}`);
14554
- continue;
14555
- }
14607
+ while (true) {
14608
+ const [value, error] = await prompt(`${options.engine}> `);
14609
+ if (error?.kind === "cancel") {
14610
+ if (value.length === 0) return;
14611
+ continue;
14612
+ }
14613
+ if (error?.kind === "eof") return;
14614
+ const trimmed = value.trim();
14615
+ if (trimmed === "") continue;
14616
+ const command = resolveReplCommand(trimmed);
14617
+ if (command === "quit") return;
14618
+ if (command === "help") {
14619
+ printReplHelp(options.engine);
14620
+ continue;
14621
+ }
14622
+ if (command === "clear") {
14623
+ clearReplScreen();
14624
+ continue;
14625
+ }
14626
+ if (command === "unknown") {
14627
+ logger.warn(`Unknown command: ${trimmed}`);
14628
+ continue;
14629
+ }
14630
+ try {
14631
+ const result = await execute(trimmed);
14632
+ if (result.engine === "sql") printSqlResult(result, { json: options.json });
14633
+ else printGqlResult(result, { json: options.json });
14634
+ } catch (error) {
14635
+ if (isCLIError(error)) {
14636
+ logger.log(error.format());
14637
+ continue;
14556
14638
  }
14557
- lines.push(line);
14558
- if (options.engine === "sql") {
14559
- if (!isSqlInputComplete(lines.join("\n"))) continue;
14560
- } else if (!isGraphQLInputComplete(lines.join("\n"))) continue;
14561
- const statement = getReplStatement(lines, options.engine);
14562
- lines.length = 0;
14563
- if (statement.length === 0) continue;
14564
- try {
14565
- if (options.engine === "sql") {
14566
- const result = await execute(statement);
14567
- if (result.engine !== "sql") throw new Error(`Expected sql engine result but got: ${result.engine}`);
14568
- printSqlResult(result, { json: options.json });
14569
- continue;
14570
- }
14571
- const result = await execute(statement);
14572
- if (result.engine !== "gql") throw new Error(`Expected gql engine result but got: ${result.engine}`);
14573
- printGqlResult(result, { json: options.json });
14574
- } catch (error) {
14575
- if (isCLIError(error)) {
14576
- logger.log(error.format());
14577
- continue;
14578
- }
14579
- if (error instanceof Error) {
14580
- logger.error(error.message);
14581
- continue;
14582
- }
14583
- logger.error(String(error));
14639
+ if (error instanceof Error) {
14640
+ logger.error(error.message);
14641
+ continue;
14584
14642
  }
14643
+ logger.error(String(error));
14585
14644
  }
14586
- } finally {
14587
- rl.close();
14588
14645
  }
14589
14646
  }
14590
- function getReplStatement(lines, engine) {
14591
- if (engine === "sql") return lines.join("\n").trim();
14592
- let end = lines.length;
14593
- while (end > 0 && lines[end - 1].trim() === "") end -= 1;
14594
- return lines.slice(0, end).join("\n").trim();
14595
- }
14596
14647
  function printReplHelp(engine) {
14597
14648
  logger.log("REPL commands:");
14598
- logger.log(" \\help, \\h, \\? Show this help");
14599
- logger.log(" Ctrl+C Clear current input");
14600
- logger.log(" \\q, \\quit, Ctrl+D Exit REPL");
14601
- logger.log(" \\clear, \\c Clear the screen");
14602
- if (engine === "sql") {
14603
- logger.log("SQL execution: statement ending with ';' runs immediately.");
14604
- return;
14605
- }
14606
- logger.log("GraphQL execution: a complete GraphQL document runs immediately.");
14649
+ logger.log(" \\help, \\h, \\? Show this help");
14650
+ logger.log(" \\q, \\quit Exit REPL");
14651
+ logger.log(" \\clear, \\c Clear the screen");
14652
+ logger.log("");
14653
+ logger.log("Key bindings (see footer for terminal-specific submit/newline keys):");
14654
+ logger.log(" Ctrl+J Insert newline (always available)");
14655
+ logger.log(" Ctrl+C Cancel current input");
14656
+ logger.log(" Ctrl+D Exit REPL (on empty input)");
14657
+ logger.log(" Ctrl+Z / Ctrl+Y Undo / Redo");
14658
+ logger.log(" Up/Down (first/last line) Navigate history");
14659
+ logger.log("");
14660
+ logger.log("Editing aids:");
14661
+ logger.log(" Syntax highlighting Enabled for the current engine");
14662
+ logger.log(" ( [ { Auto-inserts the matching closing bracket");
14663
+ logger.log(" Enter after open bracket Adds one indent level and closes the block");
14664
+ logger.log("");
14665
+ logger.log(engine === "sql" ? "Input must end with ';' to submit." : "Input must be a complete GraphQL document to submit.");
14607
14666
  }
14608
14667
  /**
14609
14668
  * Execute SQL query directly.
@@ -14696,7 +14755,8 @@ const queryCommand = defineAppCommand({
14696
14755
  hiddenAlias: "machineuser",
14697
14756
  description: "Machine user name for query execution",
14698
14757
  env: "TAILOR_PLATFORM_MACHINE_USER_NAME"
14699
- })
14758
+ }),
14759
+ "newline-on-enter": arg(z.boolean().optional(), { description: "REPL: when true, Enter inserts a newline and Shift+Enter submits. Use --no-newline-on-enter to swap." })
14700
14760
  }).superRefine((args, ctx) => {
14701
14761
  if (args.query != null && args.file != null) ctx.addIssue({
14702
14762
  code: "custom",
@@ -14733,9 +14793,11 @@ const queryCommand = defineAppCommand({
14733
14793
  return;
14734
14794
  }
14735
14795
  if (mode.mode === "repl") {
14796
+ const newlineOnEnter = args["newline-on-enter"] ?? parseBoolean(process.env.TAILOR_PLATFORM_QUERY_NEWLINE_ON_ENTER) ?? true;
14736
14797
  await runRepl({
14737
14798
  ...sharedOptions,
14738
- json: args.json
14799
+ json: args.json,
14800
+ newlineOnEnter
14739
14801
  });
14740
14802
  return;
14741
14803
  }
@@ -14855,5 +14917,5 @@ function isDeno() {
14855
14917
  }
14856
14918
 
14857
14919
  //#endregion
14858
- export { deleteCommand$1 as $, isValidMigrationNumber as $t, truncate as A, formatKeyValueTable as At, updateOrganization as B, DIFF_FILE_NAME as Bt, listCommand$2 as C, startWorkflow as Ct, resumeWorkflow as D, getWorkflowExecution as Dt, resumeCommand as E, executionsCommand as Et, showCommand as F, waitForExecution$1 as Ft, getCommand$1 as G, compareSnapshots as Gt, treeCommand as H, MIGRATE_FILE_NAME as Ht, logBetaWarning as I, MIGRATION_LABEL_KEY as It, updateFolder as J, getLatestMigrationNumber as Jt, getOrganization as K, createSnapshotFromLocalTypes as Kt, remove as L, parseMigrationLabelNumber as Lt, generate as M, getExecutor as Mt, generateCommand as N, apply as Nt, listCommand$3 as O, listWorkflowExecutions as Ot, show as P, executeScript as Pt, getFolder as Q, getNextMigrationNumber as Qt, removeCommand$1 as R, bundleMigrationScript as Rt, listApps as S, startCommand as St, healthCommand as T, getWorkflow as Tt, listCommand$4 as U, SCHEMA_FILE_NAME as Ut, organizationTree as V, INITIAL_SCHEMA_NUMBER as Vt, listOrganizations as W, compareLocalTypesWithSnapshot as Wt, listFolders as X, getMigrationFilePath as Xt, listCommand$5 as Y, getMigrationDirPath as Yt, getCommand$2 as Z, getMigrationFiles as Zt, getWorkspace as _, workspaceArgs as _n, listExecutors as _t, updateUser as a, getNamespacesWithMigrations as an, getCommand$3 as at, createCommand as b, listExecutorJobs as bt, listCommand as c, trnPrefix as cn, tokenCommand as ct, inviteUser as d, apiCommand as dn, generate$1 as dt, loadDiff as en, deleteFolder as et, restoreCommand as f, defineAppCommand as fn, listWebhookExecutors as ft, getCommand as g, isVerbose as gn, listCommand$8 as gt, listWorkspaces as h, deploymentArgs as hn, triggerExecutor as ht, updateCommand as i, hasChanges as in, listOAuth2Clients as it, truncateCommand as j, getCommand$5 as jt, listWorkflows as k, functionExecutionStatusToString as kt, listUsers as l, generateUserTypes as ln, listCommand$7 as lt, listCommand$1 as m, confirmationArgs as mn, triggerCommand as mt, query as n, formatDiffSummary as nn, createFolder as nt, removeCommand as o, prompt as on, getOAuth2Client as ot, restoreWorkspace as p, commonArgs as pn, webhookCommand as pt, updateCommand$2 as q, formatMigrationNumber as qt, queryCommand as r, formatMigrationDiff as rn, listCommand$6 as rt, removeUser as s, sdkNameLabelKey as sn, getMachineUserToken as st, isNativeTypeScriptRuntime as t, reconstructSnapshotFromMigrations as tn, createCommand$1 as tt, inviteCommand as u, apiCall as un, listMachineUsers as ut, deleteCommand as v, getExecutorJob as vt, getAppHealth as w, getCommand$4 as wt, createWorkspace as x, watchExecutorJob as xt, deleteWorkspace as y, jobsCommand as yt, updateCommand$1 as z, DB_TYPES_FILE_NAME as zt };
14859
- //# sourceMappingURL=runtime-2xqzvkQv.mjs.map
14920
+ export { deleteCommand$1 as $, isValidMigrationNumber as $t, truncate as A, formatKeyValueTable as At, updateOrganization as B, DIFF_FILE_NAME as Bt, listCommand$2 as C, startWorkflow as Ct, resumeWorkflow as D, getWorkflowExecution as Dt, resumeCommand as E, executionsCommand as Et, showCommand as F, waitForExecution$1 as Ft, getCommand$1 as G, compareSnapshots as Gt, treeCommand as H, MIGRATE_FILE_NAME as Ht, logBetaWarning as I, MIGRATION_LABEL_KEY as It, updateFolder as J, getLatestMigrationNumber as Jt, getOrganization as K, createSnapshotFromLocalTypes as Kt, remove as L, parseMigrationLabelNumber as Lt, generate as M, getExecutor as Mt, generateCommand as N, apply as Nt, listCommand$3 as O, listWorkflowExecutions as Ot, show as P, executeScript as Pt, getFolder as Q, getNextMigrationNumber as Qt, removeCommand$1 as R, bundleMigrationScript as Rt, listApps as S, startCommand as St, healthCommand as T, getWorkflow as Tt, listCommand$4 as U, SCHEMA_FILE_NAME as Ut, organizationTree as V, INITIAL_SCHEMA_NUMBER as Vt, listOrganizations as W, compareLocalTypesWithSnapshot as Wt, listFolders as X, getMigrationFilePath as Xt, listCommand$5 as Y, getMigrationDirPath as Yt, getCommand$2 as Z, getMigrationFiles as Zt, getWorkspace as _, pagedLogArgs as _n, listExecutors as _t, updateUser as a, getNamespacesWithMigrations as an, getCommand$3 as at, createCommand as b, workspaceArgs as bn, listExecutorJobs as bt, listCommand as c, trnPrefix as cn, tokenCommand as ct, inviteUser as d, apiCommand as dn, generate$1 as dt, loadDiff as en, deleteFolder as et, restoreCommand as f, defineAppCommand as fn, listWebhookExecutors as ft, getCommand as g, isVerbose as gn, listCommand$8 as gt, listWorkspaces as h, deploymentArgs as hn, triggerExecutor as ht, updateCommand as i, hasChanges as in, listOAuth2Clients as it, truncateCommand as j, getCommand$5 as jt, listWorkflows as k, functionExecutionStatusToString as kt, listUsers as l, generateUserTypes as ln, listCommand$7 as lt, listCommand$1 as m, confirmationArgs as mn, triggerCommand as mt, query as n, formatDiffSummary as nn, createFolder as nt, removeCommand as o, prompt as on, getOAuth2Client as ot, restoreWorkspace as p, commonArgs as pn, webhookCommand as pt, updateCommand$2 as q, formatMigrationNumber as qt, queryCommand as r, formatMigrationDiff as rn, listCommand$6 as rt, removeUser as s, sdkNameLabelKey as sn, getMachineUserToken as st, isNativeTypeScriptRuntime as t, reconstructSnapshotFromMigrations as tn, createCommand$1 as tt, inviteCommand as u, apiCall as un, listMachineUsers as ut, deleteCommand as v, paginationArgs as vn, getExecutorJob as vt, getAppHealth as w, getCommand$4 as wt, createWorkspace as x, watchExecutorJob as xt, deleteWorkspace as y, toPageDirection as yn, jobsCommand as yt, updateCommand$1 as z, DB_TYPES_FILE_NAME as zt };
14921
+ //# sourceMappingURL=runtime-B9R1TzLD.mjs.map