@tailor-platform/sdk 2.2.0 → 2.3.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.
Files changed (55) hide show
  1. package/CHANGELOG.md +115 -0
  2. package/dist/application-BZfk4HKm.mjs +3 -0
  3. package/dist/{application-BpLeawBg.mjs → application-F-nl107y.mjs} +118 -24
  4. package/dist/application-F-nl107y.mjs.map +1 -0
  5. package/dist/cli/commands/tailordb/migrate/diff-calculator.d.mts +43 -20
  6. package/dist/cli/commands/tailordb/migrate/generate.d.mts +6 -0
  7. package/dist/cli/commands/tailordb/migrate/rename-detection.d.mts +22 -0
  8. package/dist/cli/commands/tailordb/migrate/snapshot-types.d.mts +1 -1
  9. package/dist/cli/commands/tailordb/migrate/snapshot.d.mts +26 -7
  10. package/dist/cli/lib.mjs +2 -2
  11. package/dist/cli/main.mjs +203 -42
  12. package/dist/cli/main.mjs.map +1 -1
  13. package/dist/cli/ts-hook.mjs +52 -7
  14. package/dist/completion/zsh-worker.zsh +23 -3
  15. package/dist/configure/index.d.mts +2 -2
  16. package/dist/configure/index.mjs +90 -23
  17. package/dist/configure/index.mjs.map +1 -1
  18. package/dist/configure/services/index.d.mts +2 -2
  19. package/dist/configure/services/workflow/index.d.mts +2 -2
  20. package/dist/configure/services/workflow/wait-point.d.mts +72 -13
  21. package/dist/{errors-CWj21238.mjs → errors-BVb6vYGy.mjs} +16 -2
  22. package/dist/{errors-CWj21238.mjs.map → errors-BVb6vYGy.mjs.map} +1 -1
  23. package/dist/kysely/index.d.mts +2 -1
  24. package/dist/kysely/index.mjs.map +1 -1
  25. package/dist/{register-ts-hook-CTth1eqj.mjs → register-ts-hook-ClI226n2.mjs} +2034 -511
  26. package/dist/register-ts-hook-ClI226n2.mjs.map +1 -0
  27. package/dist/{service-goqlJJgA.mjs → service-C_WpbKHu.mjs} +38 -4
  28. package/dist/service-C_WpbKHu.mjs.map +1 -0
  29. package/dist/service-D1RCdzIL.mjs +3 -0
  30. package/dist/{service-CCwl3Avt.mjs → service-hZskxZmg.mjs} +2 -2
  31. package/dist/{service-CCwl3Avt.mjs.map → service-hZskxZmg.mjs.map} +1 -1
  32. package/dist/vitest/index.mjs +83 -1
  33. package/dist/vitest/index.mjs.map +1 -1
  34. package/dist/vitest/mocks/file.d.mts +1 -1
  35. package/dist/vitest/mocks/workflow.d.mts +13 -1
  36. package/dist/wait-point-invoker-__oE88_P.mjs +148 -0
  37. package/dist/wait-point-invoker-__oE88_P.mjs.map +1 -0
  38. package/dist/wait-point-registry-TL99zotw.mjs +47 -0
  39. package/dist/wait-point-registry-TL99zotw.mjs.map +1 -0
  40. package/docs/cli/setup.md +14 -1
  41. package/docs/cli/tailordb.md +9 -6
  42. package/docs/cli-reference.md +2 -1
  43. package/docs/github-actions.md +73 -28
  44. package/docs/migration/v2.md +54 -0
  45. package/docs/services/tailordb-migration.md +137 -35
  46. package/docs/services/workflow.md +52 -2
  47. package/docs/testing.md +12 -0
  48. package/package.json +4 -4
  49. package/dist/application-BpLeawBg.mjs.map +0 -1
  50. package/dist/application-BxLLiLsr.mjs +0 -3
  51. package/dist/register-ts-hook-CTth1eqj.mjs.map +0 -1
  52. package/dist/service-_XmjSEGr.mjs +0 -3
  53. package/dist/service-goqlJJgA.mjs.map +0 -1
  54. package/dist/test-env-key-D7UkZp99.mjs +0 -75
  55. package/dist/test-env-key-D7UkZp99.mjs.map +0 -1
@@ -80,8 +80,11 @@ function collectPathsInto(out, configFilePath, content, visited) {
80
80
  }
81
81
  }
82
82
 
83
- function loadTsconfigPaths(startDir) {
84
- if (tsconfigPathsCache.has(startDir)) return tsconfigPathsCache.get(startDir);
83
+ // cacheGeneration partitions the cache per import-nonce run, so a tsconfig
84
+ // edited between two in-process runs is re-read instead of served stale.
85
+ function loadTsconfigPaths(startDir, cacheGeneration) {
86
+ const cacheKey = `${cacheGeneration}\u0000${startDir}`;
87
+ if (tsconfigPathsCache.has(cacheKey)) return tsconfigPathsCache.get(cacheKey);
85
88
 
86
89
  const paths = Object.create(null);
87
90
  let dir = startDir;
@@ -100,7 +103,7 @@ function loadTsconfigPaths(startDir) {
100
103
  dir = dirname(dir);
101
104
  }
102
105
 
103
- tsconfigPathsCache.set(startDir, paths);
106
+ tsconfigPathsCache.set(cacheKey, paths);
104
107
  return paths;
105
108
  }
106
109
 
@@ -163,9 +166,44 @@ function tryResolveWithExtensionsSync(base, context, nextResolve) {
163
166
  return null;
164
167
  }
165
168
 
169
+ // --- import-nonce propagation ---
170
+
171
+ const IMPORT_NONCE_PARAM = "tailorImportNonce";
172
+
173
+ // Carries a parent's cache-busting nonce onto project-local resolutions, so a
174
+ // nonce'd entry module gets a fresh evaluation of its whole project subgraph.
175
+ // Bare specifiers are left alone: node_modules packages (and workspace-linked
176
+ // ones resolving outside node_modules) must stay singletons.
177
+ function propagateImportNonce(resolved, context) {
178
+ if (!resolved?.url?.startsWith("file:")) return resolved;
179
+ if (!context.parentURL?.startsWith("file:")) return resolved;
180
+ const nonce = new URL(context.parentURL).searchParams.get(IMPORT_NONCE_PARAM);
181
+ if (!nonce) return resolved;
182
+ const url = new URL(resolved.url);
183
+ if (url.searchParams.has(IMPORT_NONCE_PARAM) || url.pathname.includes("/node_modules/")) {
184
+ return resolved;
185
+ }
186
+ url.searchParams.set(IMPORT_NONCE_PARAM, nonce);
187
+ return { ...resolved, url: url.href };
188
+ }
189
+
190
+ function isProjectLocalSpecifier(specifier) {
191
+ return (
192
+ specifier.startsWith(".") ||
193
+ specifier.startsWith("/") ||
194
+ specifier.startsWith("file:") ||
195
+ specifier.startsWith("#")
196
+ );
197
+ }
198
+
166
199
  // --- module hooks ---
167
200
 
168
201
  export async function resolve(specifier, context, nextResolve) {
202
+ const resolved = await resolveTs(specifier, context, nextResolve);
203
+ return isProjectLocalSpecifier(specifier) ? propagateImportNonce(resolved, context) : resolved;
204
+ }
205
+
206
+ async function resolveTs(specifier, context, nextResolve) {
169
207
  try {
170
208
  return await nextResolve(specifier, context);
171
209
  } catch (err) {
@@ -189,15 +227,16 @@ export async function resolve(specifier, context, nextResolve) {
189
227
  // Non-relative: try tsconfig path aliases
190
228
  if (context.parentURL?.startsWith("file://")) {
191
229
  const parentParsed = new URL(context.parentURL);
230
+ const parentNonce = parentParsed.searchParams.get(IMPORT_NONCE_PARAM) ?? "";
192
231
  parentParsed.search = "";
193
232
  parentParsed.hash = "";
194
233
  const parentDir = dirname(fileURLToPath(parentParsed));
195
- const tsconfigPaths = loadTsconfigPaths(parentDir);
234
+ const tsconfigPaths = loadTsconfigPaths(parentDir, parentNonce);
196
235
  const candidates = matchTsconfigPaths(specifier, tsconfigPaths);
197
236
  if (candidates) {
198
237
  for (const candidate of candidates) {
199
238
  const result = await tryResolveWithExtensions(candidate, context, nextResolve);
200
- if (result) return result;
239
+ if (result) return propagateImportNonce(result, context);
201
240
  }
202
241
  }
203
242
  }
@@ -250,6 +289,11 @@ export async function load(url, context, nextLoad) {
250
289
 
251
290
  // Sync hooks for module.registerHooks() (Node >= 22.15.0).
252
291
  export function resolveSync(specifier, context, nextResolve) {
292
+ const resolved = resolveTsSync(specifier, context, nextResolve);
293
+ return isProjectLocalSpecifier(specifier) ? propagateImportNonce(resolved, context) : resolved;
294
+ }
295
+
296
+ function resolveTsSync(specifier, context, nextResolve) {
253
297
  try {
254
298
  return nextResolve(specifier, context);
255
299
  } catch (err) {
@@ -273,15 +317,16 @@ export function resolveSync(specifier, context, nextResolve) {
273
317
  // Non-relative: try tsconfig path aliases
274
318
  if (context.parentURL?.startsWith("file://")) {
275
319
  const parentParsed = new URL(context.parentURL);
320
+ const parentNonce = parentParsed.searchParams.get(IMPORT_NONCE_PARAM) ?? "";
276
321
  parentParsed.search = "";
277
322
  parentParsed.hash = "";
278
323
  const parentDir = dirname(fileURLToPath(parentParsed));
279
- const tsconfigPaths = loadTsconfigPaths(parentDir);
324
+ const tsconfigPaths = loadTsconfigPaths(parentDir, parentNonce);
280
325
  const candidates = matchTsconfigPaths(specifier, tsconfigPaths);
281
326
  if (candidates) {
282
327
  for (const candidate of candidates) {
283
328
  const result = tryResolveWithExtensionsSync(candidate, context, nextResolve);
284
- if (result) return result;
329
+ if (result) return propagateImportNonce(result, context);
285
330
  }
286
331
  }
287
332
  }
@@ -1,5 +1,5 @@
1
1
  # politty-completion-version: 1
2
- # politty-bin-sig: 1786155894
2
+ # politty-bin-sig: 1786713018
3
3
  # politty-bin-path: /home/runner/work/sdk/sdk/node_modules/.bin/tailor
4
4
  # program: tailor
5
5
  # shell: zsh
@@ -739,6 +739,9 @@ __tailor_worker_opt_takes_value() {
739
739
  tailordb:truncate:--namespace|tailordb:truncate:-n|tailordb:truncate:--n) return 0 ;;
740
740
  tailordb:migration:generate:--config|tailordb:migration:generate:-c|tailordb:migration:generate:--c) return 0 ;;
741
741
  tailordb:migration:generate:--name|tailordb:migration:generate:-n|tailordb:migration:generate:--n) return 0 ;;
742
+ tailordb:migration:generate:--rename) return 0 ;;
743
+ tailordb:migration:generate:--drop) return 0 ;;
744
+ tailordb:migration:generate:--expand-contract|tailordb:migration:generate:--expandContract) return 0 ;;
742
745
  tailordb:migration:rebaseline:--workspace-id|tailordb:migration:rebaseline:--workspaceId|tailordb:migration:rebaseline:-w|tailordb:migration:rebaseline:--w) return 0 ;;
743
746
  tailordb:migration:rebaseline:--profile|tailordb:migration:rebaseline:-p|tailordb:migration:rebaseline:--p) return 0 ;;
744
747
  tailordb:migration:rebaseline:--config|tailordb:migration:rebaseline:-c|tailordb:migration:rebaseline:--c) return 0 ;;
@@ -945,6 +948,7 @@ __tailor_worker_is_subcmd() {
945
948
  setup:preview) return 0 ;;
946
949
  setup:action) return 0 ;;
947
950
  setup:coordinate) return 0 ;;
951
+ setup:renovate) return 0 ;;
948
952
  setup:check) return 0 ;;
949
953
  setup:delete) return 0 ;;
950
954
  :setup) return 0 ;;
@@ -2705,6 +2709,18 @@ __tailor_worker_complete_setup_coordinate() {
2705
2709
  fi
2706
2710
  }
2707
2711
 
2712
+ __tailor_worker_complete_setup_renovate() {
2713
+ local -a _vals=()
2714
+ if __tailor_worker_opt_takes_value "setup:renovate" "${words[CURRENT-1]}"; then return 0; fi
2715
+ if (( _after_dd )); then return 0; fi
2716
+ if [[ "${words[CURRENT]}" == -* ]]; then
2717
+ local -a _opts=()
2718
+ __tailor_worker_not_used "--help" && _opts+=("--help:Show help")
2719
+ __tailor_worker_cdescribe 'options' _opts
2720
+ return 0
2721
+ fi
2722
+ }
2723
+
2708
2724
  __tailor_worker_complete_setup_check() {
2709
2725
  local -a _vals=()
2710
2726
  if __tailor_worker_opt_takes_value "setup:check" "${words[CURRENT-1]}"; then return 0; fi
@@ -2751,7 +2767,7 @@ __tailor_worker_complete_setup() {
2751
2767
  __tailor_worker_cdescribe 'options' _opts
2752
2768
  return 0
2753
2769
  fi
2754
- local -a _subs=("branch:Generate a branch-target deploy workflow (push to branch triggers deploy)." "tag:Generate a tag-target deploy workflow (tag push triggers deploy)." "preview:Generate a preview workflow (PR open/sync triggers deploy to a per-PR workspace)." "action:Generate a per-app composite action for use with setup coordinate (monorepo multi-app deploys)." "coordinate:Generate a coordinator workflow that orchestrates multiple --action-generated composite actions." "check:Audit generated workflows for drift against the current config/repo (read-only)." "delete:Delete managed workflow/action file(s) and their .github/tailor.lock entries.")
2770
+ local -a _subs=("branch:Generate a branch-target deploy workflow (push to branch triggers deploy)." "tag:Generate a tag-target deploy workflow (tag push triggers deploy)." "preview:Generate a preview workflow (PR open/sync triggers deploy to a per-PR workspace)." "action:Generate a per-app composite action for use with setup coordinate (monorepo multi-app deploys)." "coordinate:Generate a coordinator workflow that orchestrates multiple --action-generated composite actions." "renovate:Generate a Renovate config for Tailor dependency and workflow updates." "check:Audit generated workflows for drift against the current config/repo (read-only)." "delete:Delete managed workflow/action file(s) and their .github/tailor.lock entries.")
2755
2771
  __tailor_worker_cdescribe 'subcommands' _subs
2756
2772
  }
2757
2773
 
@@ -3035,6 +3051,9 @@ __tailor_worker_complete_tailordb_migration_generate() {
3035
3051
  __tailor_worker_not_used "--config" "-c" "--c" && _opts+=("--config:Path to Tailor config file")
3036
3052
  __tailor_worker_not_used "--name" "-n" "--n" && _opts+=("--name:Optional description for the migration")
3037
3053
  __tailor_worker_not_used "--init" && _opts+=("--init:Delete existing migrations and start fresh")
3054
+ _opts+=("--rename:Record a field or type rename instead of remove + add (format\: \"Type.oldField\:newField\" or \"OldType\:NewType\"; repeatable). Renames require a migration script that copies the data.")
3055
+ _opts+=("--drop:Confirm that a removed field or type is a genuine removal, not a rename (format\: \"Type.field\" or \"Type\"; repeatable). Required in non-interactive runs for a removal with rename candidates.")
3056
+ _opts+=("--expand-contract:Convert a field type through a temporary field (format\: \"Type.field\"; repeatable). Generates two migrations.")
3038
3057
  __tailor_worker_not_used "--help" && _opts+=("--help:Show help")
3039
3058
  __tailor_worker_cdescribe 'options' _opts
3040
3059
  return 0
@@ -4241,7 +4260,7 @@ __tailor_worker_complete_root() {
4241
4260
  __tailor_worker_not_used "--help" && _opts+=("--help:Show help")
4242
4261
  __tailor_worker_cdescribe 'options' _opts
4243
4262
  else
4244
- local -a _subs=("api:Call Tailor Platform API endpoints directly." "auth:Authentication helpers for scripts and plugins." "authconnection:Manage auth connections." "crashreport:Manage crash reports." "deploy:Deploy your application by applying the Tailor configuration." "executor:Manage executors" "function:Manage functions" "generate:Generate files using Tailor configuration." "init:Initialize a new project using create-sdk." "login:Login to Tailor Platform." "logout:Logout from Tailor Platform." "machineuser:Manage machine users in your Tailor Platform application." "oauth2client:Manage OAuth2 clients in your Tailor Platform application." "open:Open Tailor Platform Console." "organization:Manage Tailor Platform organizations." "plugin:Manage and inspect CLI plugins (beta)." "profile:Manage workspace profiles (user + workspace combinations)." "query:Run SQL/GraphQL query." "remove:Remove all resources managed by the application from the workspace." "secret:Manage Secret Manager vaults and secrets." "setup:Generate CI deploy workflows for your project. (beta)" "show:Show information about the deployed application." "staticwebsite:Manage static websites in your workspace." "tailordb:Manage TailorDB tables and data." "upgrade:Run codemods to upgrade your project to a newer SDK version." "user:Manage Tailor Platform users." "workflow:Manage workflows and workflow executions." "workspace:Manage Tailor Platform workspaces." "skills:Manage Tailor SDK agent skills." "completion:Generate shell completion script")
4263
+ local -a _subs=("api:Call Tailor Platform API endpoints directly." "auth:Authentication helpers for scripts and plugins." "authconnection:Manage auth connections." "crashreport:Manage crash reports." "deploy:Deploy your application by applying the Tailor configuration." "executor:Manage executors" "function:Manage functions" "generate:Generate files using Tailor configuration." "init:Initialize a new project using create-sdk." "login:Login to Tailor Platform." "logout:Logout from Tailor Platform." "machineuser:Manage machine users in your Tailor Platform application." "oauth2client:Manage OAuth2 clients in your Tailor Platform application." "open:Open Tailor Platform Console." "organization:Manage Tailor Platform organizations." "plugin:Manage and inspect CLI plugins (beta)." "profile:Manage workspace profiles (user + workspace combinations)." "query:Run SQL/GraphQL query." "remove:Remove all resources managed by the application from the workspace." "secret:Manage Secret Manager vaults and secrets." "setup:Set up repository automation for your project. (beta)" "show:Show information about the deployed application." "staticwebsite:Manage static websites in your workspace." "tailordb:Manage TailorDB tables and data." "upgrade:Run codemods to upgrade your project to a newer SDK version." "user:Manage Tailor Platform users." "workflow:Manage workflows and workflow executions." "workspace:Manage Tailor Platform workspaces." "skills:Manage Tailor SDK agent skills." "completion:Generate shell completion script")
4245
4264
  __tailor_worker_cdescribe 'subcommands' _subs
4246
4265
  fi
4247
4266
  }
@@ -4360,6 +4379,7 @@ _tailor_worker_completions() {
4360
4379
  setup:preview) __tailor_worker_complete_setup_preview ;;
4361
4380
  setup:action) __tailor_worker_complete_setup_action ;;
4362
4381
  setup:coordinate) __tailor_worker_complete_setup_coordinate ;;
4382
+ setup:renovate) __tailor_worker_complete_setup_renovate ;;
4363
4383
  setup:check) __tailor_worker_complete_setup_check ;;
4364
4384
  setup:delete) __tailor_worker_complete_setup_delete ;;
4365
4385
  setup) __tailor_worker_complete_setup ;;
@@ -38,7 +38,7 @@ import { IncomingWebhookArgs, IncomingWebhookRequest, IncomingWebhookResponse, I
38
38
  import { Trigger } from "./services/executor/trigger/index.mjs";
39
39
  import { createExecutor } from "./services/executor/executor.mjs";
40
40
  import { defineWorkflowExecutionPolicies, defineWorkflowExecutionPolicy } from "./services/workflow/execution-policy.mjs";
41
- import { WaitPointInstance, createWaitPoint, createWaitPoints } from "./services/workflow/wait-point.mjs";
41
+ import { ParameterizedWaitPointInstance, WaitPointInstance, createWaitPoint, createWaitPoints } from "./services/workflow/wait-point.mjs";
42
42
  import { defineStaticWebSite } from "./services/staticwebsite/index.mjs";
43
43
  import { defineAIGateway } from "./services/aigateway/index.mjs";
44
44
  import { defineIdp } from "./services/idp/index.mjs";
@@ -132,4 +132,4 @@ declare namespace t {
132
132
  type infer<T> = TailorOutput<T>;
133
133
  }
134
134
  //#endregion
135
- export { type AIGatewayConfig, type AIGatewayName, type AIGatewayNameRegistry, type AttributeList, type Attributes, AuthAccessTokenArgs, AuthAccessTokenIssuedArgs, AuthAccessTokenRefreshedArgs, AuthAccessTokenRevokedArgs, AuthAccessTokenTrigger, type AuthConfig, type AuthConnectionConfig, type AuthConnectionOAuth2Config, type AuthConnectionTokenResult, type AuthExternalConfig, type AuthOwnConfig, type AuthServiceInput, type BeforeLoginClaims, type BeforeLoginHookArgs, type BuiltinIdP, type ConcurrencyPolicy, type ConnectionName, type ConnectionNameRegistry, type DefinedAuth, type Env, type ExecutionPolicyConcurrency, type ExecutionPolicyDefInput, type ExecutionPolicyExactInstance, type ExecutionPolicyGroupOptions, type ExecutionPolicyInstance, type ExecutionPolicyWildcardInstance, type ExecutorReadyContext, type ExecutorServiceConfig, type ExecutorServiceInput, type FederatedIdentity, type FederatedIdentityClaims, type FederatedIdentityProvider, FunctionOperation, type GeneratorResult, GqlOperation, HttpAdapter, HttpAdapterGraphQLQuery, HttpAdapterGraphQLRequest, HttpAdapterGraphQLResponse, HttpAdapterInput, HttpAdapterInputFn, HttpAdapterOutputFn, HttpAdapterRequest, HttpAdapterResponse, HttpAdapterTypedDocumentNode, type IDToken, type IdPConfig, type IdPEmailConfig, type IdPExternalConfig, type IdPGqlOperations, type IdPGqlOperationsInput as IdPGqlOperationsConfig, type IdPPermission, type IdPPermissionCondition, type IdProvider as IdProviderConfig, type IdpName, type IdpNameRegistry, IdpUserArgs, IdpUserCreatedArgs, IdpUserDeletedArgs, IdpUserTrigger, IdpUserUpdatedArgs, IncomingWebhookArgs, IncomingWebhookRequest, IncomingWebhookResponse, IncomingWebhookResponseConfig, IncomingWebhookTrigger, IncomingWebhookTriggerOptions, type IsAutoFilledDBField, type IsReadOnlyDBField, type MachineUserName, type MachineUserNameRegistry, type NamespacePluginOutput, type OAuth2ClientInput as OAuth2Client, type OAuth2ClientGrantType, type OIDC, Operation, type PermissionCondition, type Plugin, type PluginAttachment, type PluginConfigs, type PluginExecutorContext, type PluginExecutorContextBase, type PluginGeneratedExecutor, type PluginGeneratedExecutorWithFile, type PluginGeneratedResolver, type PluginGeneratedType, type PluginNamespaceProcessContext, type PluginOutput, type PluginProcessContext, type QueryType, RecordCreatedArgs, RecordDeletedArgs, RecordUpdatedArgs, type ResolvedExecutionPolicyInstance, type Resolver, ResolverExecutedArgs, ResolverExecutedTrigger, type ResolverExternalConfig, type ResolverNamespaceData, type ResolverPermission, type ResolverPermissionCondition, type ResolverPermissionPolicy, type ResolverReadyContext, type ResolverServiceConfig, type ResolverServiceInput, type RetryPolicy, type SAML, type SCIMAttribute, type SCIMAttributeMapping, type SCIMAttributeType, type SCIMAuthorization, type SCIMConfig, type SCIMResource, ScheduleArgs, ScheduleTrigger, type SecretsConfig, type StaticWebsiteConfig, type TailorAnyDBField, type TailorAnyDBType, type TailorDBField, type TailorDBInstance, type TailorDBNamespaceData, type TailorDBReadyContext, TailorDBTrigger, type TailorDBType, type TailorDBTypeForPlugin, type TailorField, type TailorPrincipal, type TailorTypeGqlPermission, type TailorTypePermission, type TenantProvider as TenantProviderConfig, Trigger, type TypePluginOutput, type UserAttributeKey, type UserAttributeListKey, type UserAttributes, type UsernameFieldKey, type ValueOperand, WaitPointInstance, WebhookOperation, Workflow, WorkflowConfig, WorkflowExecutionArgs, WorkflowExecutionCompletedArgs, WorkflowExecutionResumedArgs, WorkflowExecutionRetriedArgs, WorkflowExecutionStartedArgs, WorkflowExecutionTrigger, WorkflowExecutionWaitResolvedArgs, WorkflowExecutionWaitStartedArgs, WorkflowJob, WorkflowJobContext, WorkflowJobExecutionArgs, WorkflowJobExecutionCompletedArgs, WorkflowJobExecutionStartedArgs, WorkflowJobExecutionTrigger, WorkflowJobExecutionWaitResolvedArgs, WorkflowJobExecutionWaitStartedArgs, WorkflowOperation, type WorkflowServiceConfig, type WorkflowServiceInput, authAccessTokenIssuedTrigger, authAccessTokenRefreshedTrigger, authAccessTokenRevokedTrigger, authAccessTokenTrigger, createExecutor, createHttpAdapter, createResolver, createWaitPoint, createWaitPoints, createWorkflow, createWorkflowJob, db, defineAIGateway, defineAuth, defineConfig, defineIdp, definePlugins, defineSecretManager, defineStaticWebSite, defineWorkflowExecutionPolicies, defineWorkflowExecutionPolicy, idpUserCreatedTrigger, idpUserDeletedTrigger, idpUserTrigger, idpUserUpdatedTrigger, incomingWebhookTrigger, infer, output, recordCreatedTrigger, recordDeletedTrigger, recordTrigger, recordUpdatedTrigger, resolverExecutedTrigger, scheduleTrigger, t, unsafeAllowAllGqlPermission, unsafeAllowAllIdPPermission, unsafeAllowAllTypePermission, workflowExecutionCompletedTrigger, workflowExecutionResumedTrigger, workflowExecutionRetriedTrigger, workflowExecutionStartedTrigger, workflowExecutionTrigger, workflowExecutionWaitResolvedTrigger, workflowExecutionWaitStartedTrigger, workflowJobExecutionCompletedTrigger, workflowJobExecutionStartedTrigger, workflowJobExecutionTrigger, workflowJobExecutionWaitResolvedTrigger, workflowJobExecutionWaitStartedTrigger };
135
+ export { type AIGatewayConfig, type AIGatewayName, type AIGatewayNameRegistry, type AttributeList, type Attributes, AuthAccessTokenArgs, AuthAccessTokenIssuedArgs, AuthAccessTokenRefreshedArgs, AuthAccessTokenRevokedArgs, AuthAccessTokenTrigger, type AuthConfig, type AuthConnectionConfig, type AuthConnectionOAuth2Config, type AuthConnectionTokenResult, type AuthExternalConfig, type AuthOwnConfig, type AuthServiceInput, type BeforeLoginClaims, type BeforeLoginHookArgs, type BuiltinIdP, type ConcurrencyPolicy, type ConnectionName, type ConnectionNameRegistry, type DefinedAuth, type Env, type ExecutionPolicyConcurrency, type ExecutionPolicyDefInput, type ExecutionPolicyExactInstance, type ExecutionPolicyGroupOptions, type ExecutionPolicyInstance, type ExecutionPolicyWildcardInstance, type ExecutorReadyContext, type ExecutorServiceConfig, type ExecutorServiceInput, type FederatedIdentity, type FederatedIdentityClaims, type FederatedIdentityProvider, FunctionOperation, type GeneratorResult, GqlOperation, HttpAdapter, HttpAdapterGraphQLQuery, HttpAdapterGraphQLRequest, HttpAdapterGraphQLResponse, HttpAdapterInput, HttpAdapterInputFn, HttpAdapterOutputFn, HttpAdapterRequest, HttpAdapterResponse, HttpAdapterTypedDocumentNode, type IDToken, type IdPConfig, type IdPEmailConfig, type IdPExternalConfig, type IdPGqlOperations, type IdPGqlOperationsInput as IdPGqlOperationsConfig, type IdPPermission, type IdPPermissionCondition, type IdProvider as IdProviderConfig, type IdpName, type IdpNameRegistry, IdpUserArgs, IdpUserCreatedArgs, IdpUserDeletedArgs, IdpUserTrigger, IdpUserUpdatedArgs, IncomingWebhookArgs, IncomingWebhookRequest, IncomingWebhookResponse, IncomingWebhookResponseConfig, IncomingWebhookTrigger, IncomingWebhookTriggerOptions, type IsAutoFilledDBField, type IsReadOnlyDBField, type MachineUserName, type MachineUserNameRegistry, type NamespacePluginOutput, type OAuth2ClientInput as OAuth2Client, type OAuth2ClientGrantType, type OIDC, Operation, ParameterizedWaitPointInstance, type PermissionCondition, type Plugin, type PluginAttachment, type PluginConfigs, type PluginExecutorContext, type PluginExecutorContextBase, type PluginGeneratedExecutor, type PluginGeneratedExecutorWithFile, type PluginGeneratedResolver, type PluginGeneratedType, type PluginNamespaceProcessContext, type PluginOutput, type PluginProcessContext, type QueryType, RecordCreatedArgs, RecordDeletedArgs, RecordUpdatedArgs, type ResolvedExecutionPolicyInstance, type Resolver, ResolverExecutedArgs, ResolverExecutedTrigger, type ResolverExternalConfig, type ResolverNamespaceData, type ResolverPermission, type ResolverPermissionCondition, type ResolverPermissionPolicy, type ResolverReadyContext, type ResolverServiceConfig, type ResolverServiceInput, type RetryPolicy, type SAML, type SCIMAttribute, type SCIMAttributeMapping, type SCIMAttributeType, type SCIMAuthorization, type SCIMConfig, type SCIMResource, ScheduleArgs, ScheduleTrigger, type SecretsConfig, type StaticWebsiteConfig, type TailorAnyDBField, type TailorAnyDBType, type TailorDBField, type TailorDBInstance, type TailorDBNamespaceData, type TailorDBReadyContext, TailorDBTrigger, type TailorDBType, type TailorDBTypeForPlugin, type TailorField, type TailorPrincipal, type TailorTypeGqlPermission, type TailorTypePermission, type TenantProvider as TenantProviderConfig, Trigger, type TypePluginOutput, type UserAttributeKey, type UserAttributeListKey, type UserAttributes, type UsernameFieldKey, type ValueOperand, WaitPointInstance, WebhookOperation, Workflow, WorkflowConfig, WorkflowExecutionArgs, WorkflowExecutionCompletedArgs, WorkflowExecutionResumedArgs, WorkflowExecutionRetriedArgs, WorkflowExecutionStartedArgs, WorkflowExecutionTrigger, WorkflowExecutionWaitResolvedArgs, WorkflowExecutionWaitStartedArgs, WorkflowJob, WorkflowJobContext, WorkflowJobExecutionArgs, WorkflowJobExecutionCompletedArgs, WorkflowJobExecutionStartedArgs, WorkflowJobExecutionTrigger, WorkflowJobExecutionWaitResolvedArgs, WorkflowJobExecutionWaitStartedArgs, WorkflowOperation, type WorkflowServiceConfig, type WorkflowServiceInput, authAccessTokenIssuedTrigger, authAccessTokenRefreshedTrigger, authAccessTokenRevokedTrigger, authAccessTokenTrigger, createExecutor, createHttpAdapter, createResolver, createWaitPoint, createWaitPoints, createWorkflow, createWorkflowJob, db, defineAIGateway, defineAuth, defineConfig, defineIdp, definePlugins, defineSecretManager, defineStaticWebSite, defineWorkflowExecutionPolicies, defineWorkflowExecutionPolicy, idpUserCreatedTrigger, idpUserDeletedTrigger, idpUserTrigger, idpUserUpdatedTrigger, incomingWebhookTrigger, infer, output, recordCreatedTrigger, recordDeletedTrigger, recordTrigger, recordUpdatedTrigger, resolverExecutedTrigger, scheduleTrigger, t, unsafeAllowAllGqlPermission, unsafeAllowAllIdPPermission, unsafeAllowAllTypePermission, workflowExecutionCompletedTrigger, workflowExecutionResumedTrigger, workflowExecutionRetriedTrigger, workflowExecutionStartedTrigger, workflowExecutionTrigger, workflowExecutionWaitResolvedTrigger, workflowExecutionWaitStartedTrigger, workflowJobExecutionCompletedTrigger, workflowJobExecutionStartedTrigger, workflowJobExecutionTrigger, workflowJobExecutionWaitResolvedTrigger, workflowJobExecutionWaitStartedTrigger };
@@ -1,7 +1,8 @@
1
1
  import { i as parseInternal, n as mapAllowedValues, t as db } from "../schema--xYWRGfe.mjs";
2
2
  import { t as brandValue } from "../brand-Eo4pLXPJ.mjs";
3
3
  import { a as registerJob, n as dispatchStartJob, r as dispatchStartWorkflow } from "../registry-BIGVUrMB.mjs";
4
- import { i as withWorkflowTestInvoker } from "../test-env-key-D7UkZp99.mjs";
4
+ import { l as withWorkflowTestInvoker, n as attachWaitPointKey, r as createWaitPointInvoker, t as attachWaitPointInvoker } from "../wait-point-invoker-__oE88_P.mjs";
5
+ import { r as registerWaitPoint } from "../wait-point-registry-TL99zotw.mjs";
5
6
 
6
7
  //#region src/configure/types/type.ts
7
8
  function createTailorField(type, options, fields, values, metadata) {
@@ -880,10 +881,39 @@ function createWorkflowJob(config) {
880
881
 
881
882
  //#endregion
882
883
  //#region src/configure/services/workflow/wait-point.ts
883
- function getPlatformWorkflow() {
884
- const workflow = globalThis.tailor?.workflow;
885
- if (!workflow) throw new Error("tailor.workflow is not available. Run tests in the `tailor-runtime` Vitest environment, or acquire mockWorkflow() from @tailor-platform/sdk/vitest and set a wait/resolve handler.");
886
- return workflow;
884
+ const KEY_REGEX = /^[a-z0-9][a-z0-9-]{1,61}[a-z0-9]$/;
885
+ const PARAM_VALUE_REGEX = /^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/;
886
+ const MAX_KEY_LENGTH = 63;
887
+ const KEY_GRAMMAR = "[a-z0-9-] (3-63 characters; must start and end with [a-z0-9])";
888
+ function parseKey(key) {
889
+ const segments = key.split("-");
890
+ return {
891
+ segments,
892
+ paramNames: segments.filter((s) => s.startsWith("$") && s.length > 1).map((s) => s.slice(1))
893
+ };
894
+ }
895
+ function composeKey(key, parsed, params) {
896
+ const composed = parsed.segments.map((segment) => {
897
+ if (!segment.startsWith("$") || segment.length === 1) return segment;
898
+ const name = segment.slice(1);
899
+ const value = params[name];
900
+ if (typeof value !== "string") throw new Error(`Wait point "${key}" needs a string for parameter "${name}" but received ${value === void 0 ? "undefined" : typeof value}.`);
901
+ if (!PARAM_VALUE_REGEX.test(value)) throw new Error(`Wait point "${key}" cannot use ${JSON.stringify(value)} for parameter "${name}": values may only contain [a-z0-9-] and cannot be empty or start or end with "-".`);
902
+ return value;
903
+ }).join("-");
904
+ if (composed.length > MAX_KEY_LENGTH) throw new Error(`Wait point key "${composed}" built from "${key}" is ${composed.length} characters; the limit is ${MAX_KEY_LENGTH}.`);
905
+ if (!KEY_REGEX.test(composed)) throw new Error(`Wait point key "${composed}" built from "${key}" must match ${KEY_GRAMMAR}.`);
906
+ return composed;
907
+ }
908
+ function createBoundWaitPoint(invoker, readKey) {
909
+ return {
910
+ wait(payload) {
911
+ return Promise.resolve(invoker.wait(readKey(), payload));
912
+ },
913
+ async resolve(executionId, callback) {
914
+ await invoker.resolve(readKey(), executionId, callback);
915
+ }
916
+ };
887
917
  }
888
918
  /**
889
919
  * Create a WaitPointInstance that delegates to the platform runtime.
@@ -894,22 +924,47 @@ function getPlatformWorkflow() {
894
924
  */
895
925
  function createWaitPointInstance(initialKey) {
896
926
  let key = initialKey;
927
+ const invoker = createWaitPointInvoker();
928
+ const instance = brandValue(createBoundWaitPoint(invoker, () => key), "wait-point");
929
+ attachWaitPointInvoker(instance, invoker);
897
930
  return {
898
- instance: brandValue({
899
- wait(payload) {
900
- return Promise.resolve(getPlatformWorkflow().wait(key, payload));
901
- },
902
- async resolve(executionId, callback) {
903
- await getPlatformWorkflow().resolve(executionId, key, callback);
904
- }
905
- }, "wait-point"),
931
+ instance,
906
932
  setKey: (k) => {
907
933
  key = k;
908
934
  }
909
935
  };
910
936
  }
937
+ function createParameterizedWaitPointInstance(key, parsed, declaredBy) {
938
+ const invoker = createWaitPointInvoker();
939
+ const unbound = () => {
940
+ throw new Error(declaredBy === "define" ? `Wait point key "${key}" has $params, so it identifies no single suspension on its own. Bind them first: waitPoint.with({ ... }).wait(...).` : `Wait point key "${key}" has $params, which createWaitPoint cannot type. Declare it through createWaitPoints instead: createWaitPoints((define) => ({ myWaitPoint: define.for("${key}")<Payload, Result>() })).`);
941
+ };
942
+ const instance = brandValue({
943
+ with(params) {
944
+ const composed = composeKey(key, parsed, params);
945
+ return attachWaitPointKey(createBoundWaitPoint(invoker, () => composed), composed);
946
+ },
947
+ wait: unbound,
948
+ resolve: unbound
949
+ }, "wait-point");
950
+ attachWaitPointInvoker(instance, invoker);
951
+ return instance;
952
+ }
953
+ function createKeyedWaitPoint(key, declaredBy) {
954
+ registerWaitPoint({
955
+ key,
956
+ declaredBy
957
+ });
958
+ const parsed = parseKey(key);
959
+ return parsed.paramNames.length > 0 ? createParameterizedWaitPointInstance(key, parsed, declaredBy) : createWaitPointInstance(key).instance;
960
+ }
911
961
  /**
912
- * Create a single typed wait point with an explicit key.
962
+ * Create a single typed wait point with a fixed key.
963
+ *
964
+ * The key must match `[a-z0-9-]` (3-63 characters, starting and ending with
965
+ * `[a-z0-9]`), which `deploy` reports on. For a key with `$params`, use
966
+ * {@link createWaitPoints}: binding params needs the key inferred as a literal
967
+ * type, which only its `define` offers.
913
968
  *
914
969
  * `Payload` and `Result` must be JsonValue-compatible.
915
970
  * Functions and objects with a `toJSON` method are rejected at the type level;
@@ -921,13 +976,14 @@ function createWaitPointInstance(initialKey) {
921
976
  *
922
977
  * await approval.wait({ message: "Please approve" });
923
978
  */
924
- /* @__NO_SIDE_EFFECTS__ */
925
979
  function createWaitPoint(key) {
926
- return createWaitPointInstance(key).instance;
980
+ return createKeyedWaitPoint(key, "createWaitPoint");
927
981
  }
928
982
  /**
929
983
  * Create a group of typed wait points for human-in-the-loop workflows.
930
- * Property names become the wait point keys.
984
+ * Property names become the wait point keys, so they must match
985
+ * `[a-z0-9-]`, which `deploy` reports on — pass an explicit key to `define`
986
+ * when they do not.
931
987
  *
932
988
  * The return type is the same as the builder's return type, so JSDoc on each
933
989
  * property is preserved and visible in IDE autocompletion.
@@ -941,23 +997,34 @@ function createWaitPoint(key) {
941
997
  * export const waitPoints = createWaitPoints(define => ({
942
998
  * // Preceding JSDoc on this property is shown in IDE autocompletion
943
999
  * approval: define<{ message: string }, { approved: boolean }>(),
1000
+ * // A key with $params is bound per call through `.with()`
1001
+ * lineApproval: define.for("line-approval-$lineId")<{ message: string }, { approved: boolean }>(),
944
1002
  * }));
945
1003
  *
946
- * // IDE shows the JSDoc when typing `waitPoints.`
947
1004
  * await waitPoints.approval.wait({ message: "Please approve" });
1005
+ * await waitPoints.lineApproval.with({ lineId: line.id }).wait({ message: "Please approve" });
948
1006
  *
949
1007
  * // For 2-level access, use destructured export with JSDoc attached to the export itself.
950
1008
  */
951
- /* @__NO_SIDE_EFFECTS__ */
952
1009
  function createWaitPoints(builder) {
953
1010
  const setters = /* @__PURE__ */ new Map();
954
- const define = (() => {
1011
+ const result = builder(Object.assign(() => {
955
1012
  const { instance, setKey } = createWaitPointInstance("__pending__");
956
1013
  setters.set(instance, setKey);
957
1014
  return instance;
958
- });
959
- const result = builder(define);
960
- for (const key of Object.keys(result)) setters.get(result[key])?.(key);
1015
+ }, { for: (key) => {
1016
+ const instance = createKeyedWaitPoint(key, "define");
1017
+ return () => instance;
1018
+ } }));
1019
+ for (const propName of Object.keys(result)) {
1020
+ const setter = setters.get(result[propName]);
1021
+ if (!setter) continue;
1022
+ registerWaitPoint({
1023
+ key: propName,
1024
+ declaredBy: "property"
1025
+ });
1026
+ setter(propName);
1027
+ }
961
1028
  return result;
962
1029
  }
963
1030