@tailor-platform/sdk 2.23.0 → 2.24.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.
@@ -8,6 +8,7 @@ import "../shared/tsconfig-paths-plugin.mjs";
8
8
  import "./http-adapter/bundler.mjs";
9
9
  import "./http-adapter/service.mjs";
10
10
  import "./resolver/service.mjs";
11
+ import "../shared/start-context.mjs";
11
12
  import "./workflow/bundler.mjs";
12
13
  import "./workflow/service.mjs";
13
14
  import "../shared/client.mjs";
@@ -1,3 +1,4 @@
1
1
  import "../../../configure/config/types.mjs";
2
2
  import "../../cache/bundle-cache.mjs";
3
- import "../../shared/tsconfig-paths-plugin.mjs";
3
+ import "../../shared/tsconfig-paths-plugin.mjs";
4
+ import "../../shared/start-context.mjs";
@@ -0,0 +1 @@
1
+ import "../../configure/config/types.mjs";
@@ -0,0 +1 @@
1
+ import "./tsconfig-paths-plugin.mjs";
@@ -43,7 +43,7 @@ function resolveEffectiveConfig(configFilePath, content, visited) {
43
43
  const base = resolvePath(baseDir, extendsField);
44
44
  const extendsPath = base.endsWith(".json") ? base : base + ".json";
45
45
  try {
46
- const sub = JSON.parse(readFileSync(extendsPath, "utf-8"));
46
+ const sub = JSON.parse(readFileSync(extendsPath, { encoding: "utf-8" }));
47
47
  inherited = resolveEffectiveConfig(extendsPath, sub, visited);
48
48
  } catch (e) {
49
49
  if (e?.code !== "ENOENT" && !(e instanceof SyntaxError)) throw e;
@@ -92,7 +92,7 @@ function loadTsconfigPaths(startDir, cacheGeneration) {
92
92
  while (dir !== prev) {
93
93
  try {
94
94
  const configFilePath = join(dir, "tsconfig.json");
95
- const content = JSON.parse(readFileSync(configFilePath, "utf-8"));
95
+ const content = JSON.parse(readFileSync(configFilePath, { encoding: "utf-8" }));
96
96
  collectPathsInto(paths, configFilePath, content, new Set());
97
97
  break;
98
98
  } catch (e) {
@@ -371,7 +371,7 @@ export function loadSync(url, context, nextLoad) {
371
371
  parsedUrl.search = "";
372
372
  parsedUrl.hash = "";
373
373
  const filePath = fileURLToPath(parsedUrl);
374
- const source = readFileSync(filePath, "utf-8");
374
+ const source = readFileSync(filePath, { encoding: "utf-8" });
375
375
  const { code } = transformSync(source, { mode: "transform", filename: filePath });
376
376
  return { format: "module", shortCircuit: true, source: `${code}\n//# sourceURL=${url}` };
377
377
  }
@@ -1,5 +1,5 @@
1
1
  # politty-completion-version: 1
2
- # politty-bin-sig: 1790662611
2
+ # politty-bin-sig: 1790908687
3
3
  # politty-bin-path: /home/runner/work/sdk/sdk/node_modules/.bin/tailor
4
4
  # program: tailor
5
5
  # shell: zsh
@@ -10,6 +10,43 @@ import { LogLevelEnum } from "../../types/app-config.generated.mjs";
10
10
  //#region src/configure/config/types.d.ts
11
11
  export type LogLevel = LogLevelEnum;
12
12
  export type LogLevelInput = LogLevel | (string & {});
13
+ /**
14
+ * Node-only globals that installed packages may reference without failing
15
+ * `deploy`, keyed by package name (e.g. `"@ai-sdk/gateway"`). List the globals, or set
16
+ * `true` to allow every one of them — including any the package only starts
17
+ * referencing in a later version.
18
+ */
19
+ export type AllowedRuntimeGlobals = Record<string, true | string[]>;
20
+ /** Options for how `defineConfig()` bundles functions. */
21
+ export interface BuildOptions {
22
+ /**
23
+ * Enable inline sourcemaps in bundled functions for better error stack traces.
24
+ * @default true
25
+ */
26
+ inlineSourcemap?: boolean;
27
+ /**
28
+ * Controls which `console.*` and `logger.*` (from `@tailor-platform/sdk/runtime`)
29
+ * calls remain in bundled functions. `logger.setAttributes` has no severity and
30
+ * is never dropped.
31
+ * @default "DEBUG"
32
+ */
33
+ logLevel?: LogLevelInput;
34
+ /**
35
+ * Lets `deploy` continue when an installed package bundled into a resolver,
36
+ * executor, or workflow references a Node-only global such as `process` or
37
+ * `Buffer`, which the Tailor Platform runtime does not define. Allow a global
38
+ * only after confirming that the package's code referencing it never runs for
39
+ * your use, since that code throws a `ReferenceError` at runtime. Only code
40
+ * from installed packages is affected: a reference from the project's own
41
+ * code always fails the build.
42
+ * @example
43
+ * allowedRuntimeGlobals: {
44
+ * "@ai-sdk/gateway": ["Buffer"],
45
+ * "some-trusted-package": true,
46
+ * }
47
+ */
48
+ allowedRuntimeGlobals?: AllowedRuntimeGlobals;
49
+ }
13
50
  /** Value an `env` entry resolves to at runtime. */
14
51
  export type EnvValue = string | number | boolean;
15
52
  /**
@@ -148,14 +185,17 @@ export interface AppConfig<Auth extends AuthConfig = AuthConfig, Idp extends IdP
148
185
  /**
149
186
  * Enable inline sourcemaps in bundled functions for better error stack traces.
150
187
  * @default true
188
+ * @deprecated since 2.24.0 — use `buildOptions.inlineSourcemap` instead. codemod: v3/define-config-build-options
151
189
  */
152
190
  inlineSourcemap?: boolean;
153
191
  /**
154
192
  * Controls which `console.*` and `logger.*` (from `@tailor-platform/sdk/runtime`)
155
- * calls remain in bundled functions. `logger.setAttributes` has no severity and
156
- * is never dropped.
193
+ * calls remain in bundled functions.
157
194
  * @default "DEBUG"
195
+ * @deprecated since 2.24.0 — use `buildOptions.logLevel` instead. codemod: v3/define-config-build-options
158
196
  */
159
197
  logLevel?: LogLevelInput;
198
+ /** Options for how resolvers, executors, workflow jobs, and other functions are bundled. */
199
+ buildOptions?: BuildOptions;
160
200
  }
161
201
  //#endregion
@@ -3,7 +3,7 @@ function defineAuth(e,t){return{...t,name:e}}const g={create:[{conditions:[],per
3
3
  function createResolver(e){let t=(e=>typeof e==`object`&&!!e&&`type`in e&&typeof e.type==`string`)(e.output)?e.output:h.object(e.output);return r({...e,output:t},`resolver`)}/* @__NO_SIDE_EFFECTS__ */
4
4
  function createExecutor(e){return r(e,`executor`)}const v={created:`tailordb.type_record.created`,updated:`tailordb.type_record.updated`,deleted:`tailordb.type_record.deleted`};function recordCreatedTrigger(e){let{type:t,condition:n}=e;return{kind:`tailordb`,events:[`tailordb.type_record.created`],tableName:t.name,condition:n,__args:{}}}function recordUpdatedTrigger(e){let{type:t,condition:n}=e;return{kind:`tailordb`,events:[`tailordb.type_record.updated`],tableName:t.name,condition:n,__args:{}}}function recordDeletedTrigger(e){let{type:t,condition:n}=e;return{kind:`tailordb`,events:[`tailordb.type_record.deleted`],tableName:t.name,condition:n,__args:{}}}function recordTrigger(e){let{type:t,events:n,condition:r}=e;return{kind:`tailordb`,events:n.map(e=>v[e]),tableName:t.name,condition:r,__args:{}}}function resolverExecutedTrigger(e){let{resolver:t,condition:n}=e;return{kind:`resolverExecuted`,resolverName:t.name,condition:n,__args:{}}}const y={created:`idp.user.created`,updated:`idp.user.updated`,deleted:`idp.user.deleted`};function idpUserCreatedTrigger(e){return{kind:`idpUser`,events:[`idp.user.created`],...e?.idp==null?{}:{idp:e.idp},__args:{}}}function idpUserUpdatedTrigger(e){return{kind:`idpUser`,events:[`idp.user.updated`],...e?.idp==null?{}:{idp:e.idp},__args:{}}}function idpUserDeletedTrigger(e){return{kind:`idpUser`,events:[`idp.user.deleted`],...e?.idp==null?{}:{idp:e.idp},__args:{}}}function idpUserTrigger(e){let{events:t,idp:n}=e;return{kind:`idpUser`,events:t.map(e=>y[e]),...n==null?{}:{idp:n},__args:{}}}const b={issued:`auth.access_token.issued`,refreshed:`auth.access_token.refreshed`,revoked:`auth.access_token.revoked`};function authAccessTokenIssuedTrigger(){return{kind:`authAccessToken`,events:[`auth.access_token.issued`],__args:{}}}function authAccessTokenRefreshedTrigger(){return{kind:`authAccessToken`,events:[`auth.access_token.refreshed`],__args:{}}}function authAccessTokenRevokedTrigger(){return{kind:`authAccessToken`,events:[`auth.access_token.revoked`],__args:{}}}function authAccessTokenTrigger(e){let{events:t}=e;return{kind:`authAccessToken`,events:t.map(e=>b[e]),__args:{}}}const x={started:`workflow.workflow_execution.started`,completed:`workflow.workflow_execution.completed`,retried:`workflow.workflow_execution.retried`,resumed:`workflow.workflow_execution.resumed`,wait_started:`workflow.workflow_execution.wait_started`,wait_resolved:`workflow.workflow_execution.wait_resolved`};function workflowExecutionTriggerConfig(e,t){return{kind:`workflowExecution`,events:e,workflowName:t.workflow.name,condition:t.condition,__args:{}}}function workflowExecutionStartedTrigger(e){return workflowExecutionTriggerConfig([`workflow.workflow_execution.started`],e)}function workflowExecutionCompletedTrigger(e){return workflowExecutionTriggerConfig([`workflow.workflow_execution.completed`],e)}function workflowExecutionRetriedTrigger(e){return workflowExecutionTriggerConfig([`workflow.workflow_execution.retried`],e)}function workflowExecutionResumedTrigger(e){return workflowExecutionTriggerConfig([`workflow.workflow_execution.resumed`],e)}function workflowExecutionWaitStartedTrigger(e){return workflowExecutionTriggerConfig([`workflow.workflow_execution.wait_started`],e)}function workflowExecutionWaitResolvedTrigger(e){return workflowExecutionTriggerConfig([`workflow.workflow_execution.wait_resolved`],e)}function workflowExecutionTrigger(e){let{events:t,workflow:n,condition:r}=e;return workflowExecutionTriggerConfig(t.map(e=>x[e]),{workflow:n,condition:r})}const S={started:`workflow.workflow_execution.job_execution.started`,completed:`workflow.workflow_execution.job_execution.completed`,wait_started:`workflow.workflow_execution.job_execution.wait_started`,wait_resolved:`workflow.workflow_execution.job_execution.wait_resolved`};function workflowJobExecutionTriggerConfig(e,t){return{kind:`workflowJobExecution`,events:e,workflowName:t.workflow.name,condition:t.condition,__args:{}}}function workflowJobExecutionStartedTrigger(e){return workflowJobExecutionTriggerConfig([`workflow.workflow_execution.job_execution.started`],e)}function workflowJobExecutionCompletedTrigger(e){return workflowJobExecutionTriggerConfig([`workflow.workflow_execution.job_execution.completed`],e)}function workflowJobExecutionWaitStartedTrigger(e){return workflowJobExecutionTriggerConfig([`workflow.workflow_execution.job_execution.wait_started`],e)}function workflowJobExecutionWaitResolvedTrigger(e){return workflowJobExecutionTriggerConfig([`workflow.workflow_execution.job_execution.wait_resolved`],e)}function workflowJobExecutionTrigger(e){let{events:t,workflow:n,condition:r}=e;return workflowJobExecutionTriggerConfig(t.map(e=>S[e]),{workflow:n,condition:r})}function scheduleTrigger(e){let{cron:t,timezone:n}=e;return{kind:`schedule`,cron:t,timezone:n,__args:{}}}function incomingWebhookTrigger(e){let t=typeof e?.response==`function`?{body:e.response}:e?.response;return{kind:`incomingWebhook`,...t?{response:t}:{},__args:{}}}const C=/^[a-z0-9][a-z0-9_:.-]{0,62}[a-z0-9]$/;function createExecutionPolicyInstance(e,t,n,i,a,o,s){let c=i===`prefix`,l={name:e,key:t,matchType:i,...n&&{concurrencyPolicy:n},...c&&{keyFor:e=>{let t=`${l.key}${a}${e}`;if(!C.test(t))throw Error(`Invalid execution policy key "${t}" built by keyFor("${e}"): must match [a-z0-9_:.-] (2-64 chars; must start and end with [a-z0-9]).`);return t}}};return{instance:r(l,`execution-policy`),setName:o?e=>{l.name=e}:void 0,setKey:s?e=>{l.key=e}:void 0}}/* @__NO_SIDE_EFFECTS__ */
5
5
  function defineWorkflowExecutionPolicy(e,t){return createExecutionPolicyInstance(e,t?.key??e,t?.concurrencyPolicy,t?.matchType??`exact`,t?.separator??`.`,!1,!1).instance}/* @__NO_SIDE_EFFECTS__ */
6
- function defineWorkflowExecutionPolicies(e,t){let n=t?.separator??`.`,r=/* @__PURE__ */ new Map,i=/* @__PURE__ */ new Map,a=e(e=>{let t=e?.name,a=e?.key,{instance:o,setName:s,setKey:c}=createExecutionPolicyInstance(t??`__pending__`,a??t??`__pending__`,e?.concurrencyPolicy,e?.matchType??`exact`,n,t===void 0,a===void 0&&t===void 0);return s&&r.set(o,s),c&&i.set(o,c),o});for(let e of Object.keys(a)){let t=a[e];r.get(t)?.(e),i.get(t)?.(e)}return a}function createWorkflowJob(e){let t=e.body,n=process.env.__TAILOR_PLATFORM_BUNDLE?t:(e,n)=>s(n.invoker,()=>t(e,n));process.env.__TAILOR_PLATFORM_BUNDLE||i(e.name,n);let o=process.env.__TAILOR_PLATFORM_BUNDLE?()=>{throw Error(`.start() on workflow job "${e.name}" is rewritten at build time and is unavailable in the bundle`)}:function(t,n){return arguments.length>=2?a(e.name,t,n):a(e.name,t)};return r({name:e.name,start:o,body:n,...e.publishEvents===void 0?{}:{publishEvents:e.publishEvents}},`workflow-job`)}const w=/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/;function parseKey(e){let t=e.split(`-`);return{segments:t,paramNames:t.filter(p).map(e=>e.slice(1))}}function composeKey(e,t,n){let r=t.segments.map(t=>{if(!p(t))return t;let r=t.slice(1),i=n[r];if(typeof i!=`string`)throw Error(`Wait point "${e}" needs a string for parameter "${r}" but received ${i===void 0?`undefined`:typeof i}.`);if(!w.test(i))throw Error(`Wait point "${e}" cannot use ${JSON.stringify(i)} for parameter "${r}": values may only contain [a-z0-9-] and cannot be empty or start or end with "-".`);return i}).join(`-`);if(r.length>63)throw Error(`Wait point key "${r}" built from "${e}" is ${r.length} characters; the limit is 63.`);if(!d.test(r))throw Error(`Wait point key "${r}" built from "${e}" must match ${f}.`);return r}function createBoundWaitPoint(e,t){return{wait(n){return Promise.resolve(e.wait(t(),n))},async resolve(n,r){await e.resolve(t(),n,r)}}}function createWaitPointInstance(e){let t=e,n=l(),i=r(createBoundWaitPoint(n,()=>t),`wait-point`);return u(i,n),{instance:i,setKey:e=>{t=e}}}function createParameterizedWaitPointInstance(e,t,n){let i=l(),unbound=()=>{throw Error(n===`define`?`Wait point key "${e}" has $params, so it identifies no single suspension on its own. Bind them first: waitPoint.with({ ... }).wait(...).`:`Wait point key "${e}" has $params, which createWaitPoint cannot type. Declare it through createWaitPoints instead: createWaitPoints((define) => ({ myWaitPoint: define.for("${e}")<Payload, Result>() })).`)},a=r({with(n){let r=composeKey(e,t,n);return c(createBoundWaitPoint(i,()=>r),r)},wait:unbound,resolve:unbound},`wait-point`);return u(a,i),a}function createKeyedWaitPoint(e,t){m({key:e,declaredBy:t});let n=parseKey(e);return n.paramNames.length>0?createParameterizedWaitPointInstance(e,n,t):createWaitPointInstance(e).instance}function createWaitPoint(e){return createKeyedWaitPoint(e,`createWaitPoint`)}function createWaitPoints(e){let t=/* @__PURE__ */ new Map,n=e(Object.assign(()=>{let{instance:e,setKey:n}=createWaitPointInstance(`__pending__`);return t.set(e,n),e},{for:e=>{let t=createKeyedWaitPoint(e,`define`);return()=>t}}));for(let e of Object.keys(n)){let r=t.get(n[e]);r&&(m({key:e,declaredBy:`property`}),r(e))}return n}function createWorkflow(e){return r({...e,start:process.env.__TAILOR_PLATFORM_BUNDLE?async()=>{throw Error(`workflow.start() is rewritten at build time and unavailable in the bundle`)}:async function(t,n){return arguments.length>=2?await o(e.name,t,n):await o(e.name,t)}},`workflow`)}/* @__NO_SIDE_EFFECTS__ */
6
+ function defineWorkflowExecutionPolicies(e,t){let n=t?.separator??`.`,r=/* @__PURE__ */ new Map,i=/* @__PURE__ */ new Map,a=e(e=>{let t=e?.name,a=e?.key,{instance:o,setName:s,setKey:c}=createExecutionPolicyInstance(t??`__pending__`,a??t??`__pending__`,e?.concurrencyPolicy,e?.matchType??`exact`,n,t===void 0,a===void 0&&t===void 0);return s&&r.set(o,s),c&&i.set(o,c),o});for(let e of Object.keys(a)){let t=a[e];r.get(t)?.(e),i.get(t)?.(e)}return a}function createWorkflowJob(e){let t=e.body,n=process.env.__TAILOR_PLATFORM_BUNDLE?t:(e,n)=>s(n.invoker,()=>t(e,n));process.env.__TAILOR_PLATFORM_BUNDLE||i(e.name,n);let o=process.env.__TAILOR_PLATFORM_BUNDLE?()=>{throw Error(`.start() on workflow job "${e.name}" is rewritten at build time and is unavailable in the bundle`)}:function(t,n){return arguments.length>=2?a(e.name,t,n):a(e.name,t)};return r({name:e.name,start:o,body:n,...e.publishEvents===void 0?{}:{publishEvents:e.publishEvents}},`workflow-job`)}const w=/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/;function parseKey(e){let t=e.split(`-`);return{segments:t,paramNames:t.filter(p).map(e=>e.slice(1))}}function composeKey(e,t,n){let r=t.segments.map(t=>{if(!p(t))return t;let r=t.slice(1),i=n[r];if(typeof i!=`string`)throw Error(`Wait point "${e}" needs a string for parameter "${r}" but received ${i===void 0?`undefined`:typeof i}.`);if(!w.test(i))throw Error(`Wait point "${e}" cannot use ${JSON.stringify(i)} for parameter "${r}": values may only contain [a-z0-9-] and cannot be empty or start or end with "-".`);return i}).join(`-`);if(r.length>63)throw Error(`Wait point key "${r}" built from "${e}" is ${r.length} characters; the limit is 63.`);if(!d.test(r))throw Error(`Wait point key "${r}" built from "${e}" must match ${f}.`);return r}function createBoundWaitPoint(e,t){return{wait(n){return Promise.resolve(e.wait(t(),n))},async resolve(n,r){await e.resolve(t(),n,r)}}}function createWaitPointInstance(e){let t=e,n=l(),i=r(createBoundWaitPoint(n,()=>t),`wait-point`);return u(i,n),{instance:i,setKey:e=>{t=e}}}function createParameterizedWaitPointInstance(e,t,n){let i=l(),unbound=()=>{throw Error(n===`define`?`Wait point key "${e}" has $params, so it identifies no single suspension on its own. Bind them first: waitPoint.with({ ... }).wait(...).`:`Wait point key "${e}" has $params, which createWaitPoint cannot type. Declare it through createWaitPoints instead: createWaitPoints((define) => ({ myWaitPoint: define.for("${e}")<Payload, Result>() })).`)},a=r({with(n){let r=composeKey(e,t,n);return c(createBoundWaitPoint(i,()=>r),r)},wait:unbound,resolve:unbound},`wait-point`);return u(a,i),a}function createKeyedWaitPoint(e,t){m({key:e,declaredBy:t});let n=parseKey(e);return n.paramNames.length>0?createParameterizedWaitPointInstance(e,n,t):createWaitPointInstance(e).instance}function createWaitPoint(e){return createKeyedWaitPoint(e,`createWaitPoint`)}function createWaitPoints(e){let t=/* @__PURE__ */ new Map,n=e(Object.assign(()=>{let{instance:e,setKey:n}=createWaitPointInstance(`__pending__`);return t.set(e,n),e},{for:e=>{let t=createKeyedWaitPoint(e,`define`);return()=>t}}));for(let e of Object.keys(n)){let r=t.get(n[e]);r&&(m({key:e,declaredBy:`property`}),r(e))}return n}function createWorkflow(e){return r({...e,start:process.env.__TAILOR_PLATFORM_BUNDLE?async()=>{throw Error(`.start() on workflow "${e.name}" is rewritten at build time and is unavailable in the bundle`)}:async function(t,n){return arguments.length>=2?await o(e.name,t,n):await o(e.name,t)}},`workflow`)}/* @__NO_SIDE_EFFECTS__ */
7
7
  function defineStaticWebSite(e,t){return{...t,name:e,get url(){return`${e}:url`}}}/* @__NO_SIDE_EFFECTS__ */
8
8
  function defineAIGateway(e,t){return{...t,name:e}}const T={create:[{conditions:[],permit:!0}],read:[{conditions:[],permit:!0}],update:[{conditions:[],permit:!0}],delete:[{conditions:[],permit:!0}],sendPasswordResetEmail:[{conditions:[],permit:!0}],unenrollMfa:[{conditions:[],permit:!0}]};/* @__NO_SIDE_EFFECTS__ */
9
9
  function defineIdp(e,t){return{...t,name:e,provider(t,n){return{name:t,kind:`BuiltInIdP`,namespace:e,clientName:n}}}}/* @__NO_SIDE_EFFECTS__ */