@tailor-platform/sdk 2.0.0-next.3 → 2.0.0-next.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +45 -0
- package/dist/aigateway-DR4Kwuik.mjs +9 -0
- package/dist/{aigateway-B3oZZE6v.mjs.map → aigateway-DR4Kwuik.mjs.map} +1 -1
- package/dist/application-BO4ZF8wP.mjs +3 -0
- package/dist/{application-eHp9jXld.mjs → application-BX13RArL.mjs} +293 -17
- package/dist/application-BX13RArL.mjs.map +1 -0
- package/dist/authconnection-CZvi9ANm.mjs +9 -0
- package/dist/authconnection-CZvi9ANm.mjs.map +1 -0
- package/dist/brand-Eo4pLXPJ.mjs.map +1 -1
- package/dist/cli/commands/deploy/workflow-execution-policy.d.mts +1 -0
- package/dist/cli/index.mjs +138 -38
- package/dist/cli/index.mjs.map +1 -1
- package/dist/cli/lib.mjs +4 -4
- package/dist/cli/query/index.d.mts +4 -0
- package/dist/cli/ts-hook.mjs +43 -13
- package/dist/completion/zsh-worker.zsh +10 -10
- package/dist/configure/config/types.d.mts +3 -1
- package/dist/configure/index.d.mts +3 -1
- package/dist/configure/index.mjs +114 -4
- package/dist/configure/index.mjs.map +1 -1
- package/dist/configure/services/index.d.mts +3 -1
- package/dist/configure/services/tailordb/schema.d.mts +20 -20
- package/dist/configure/services/workflow/execution-policy.d.mts +71 -0
- package/dist/configure/services/workflow/execution-policy.types.d.mts +104 -0
- package/dist/configure/services/workflow/index.d.mts +3 -1
- package/dist/configure/services/workflow/job.d.mts +7 -2
- package/dist/{context-Bd266-ru.mjs → context-DYQVYWqZ.mjs} +4 -5
- package/dist/{context-Bd266-ru.mjs.map → context-DYQVYWqZ.mjs.map} +1 -1
- package/dist/{file-BbdFGdMV.mjs → file-BUcmVIH2.mjs} +12 -14
- package/dist/file-BUcmVIH2.mjs.map +1 -0
- package/dist/{file-utils-CYZnO1pX.mjs → file-utils-yEiIS4nJ.mjs} +2 -2
- package/dist/file-utils-yEiIS4nJ.mjs.map +1 -0
- package/dist/{globals-DhwZj0RB.mjs → globals-BjhJJ2dN.mjs} +2 -2
- package/dist/globals-BjhJJ2dN.mjs.map +1 -0
- package/dist/iconv-QWaZh0TT.mjs +38 -0
- package/dist/iconv-QWaZh0TT.mjs.map +1 -0
- package/dist/{idp-Bx25ZBdN.mjs → idp-RA_swu-h.mjs} +4 -5
- package/dist/idp-RA_swu-h.mjs.map +1 -0
- package/dist/{kysely-type-5eAChaHO.mjs → kysely-type-D-zflMGf.mjs} +1 -3
- package/dist/kysely-type-D-zflMGf.mjs.map +1 -0
- package/dist/plugin/builtin/file-utils/index.mjs +1 -1
- package/dist/plugin/builtin/kysely-type/index.mjs +1 -1
- package/dist/{register-ts-hook-ZpBacA07.mjs → register-ts-hook-BM1caLT0.mjs} +255 -256
- package/dist/register-ts-hook-BM1caLT0.mjs.map +1 -0
- package/dist/{registry-DH4m7eYo.mjs → registry-BSbq6SPo.mjs} +4 -3
- package/dist/registry-BSbq6SPo.mjs.map +1 -0
- package/dist/resource_pb-BRv7AMXK.mjs +49 -0
- package/dist/resource_pb-BRv7AMXK.mjs.map +1 -0
- package/dist/runtime/aigateway.d.mts +5 -14
- package/dist/runtime/aigateway.mjs +2 -2
- package/dist/runtime/authconnection.d.mts +5 -14
- package/dist/runtime/authconnection.mjs +2 -2
- package/dist/runtime/context.d.mts +14 -5
- package/dist/runtime/context.mjs +2 -2
- package/dist/runtime/file.d.mts +14 -54
- package/dist/runtime/file.mjs +2 -2
- package/dist/runtime/globals.d.mts +1 -1
- package/dist/runtime/iconv.d.mts +5 -53
- package/dist/runtime/iconv.mjs +2 -2
- package/dist/runtime/idp.d.mts +13 -70
- package/dist/runtime/idp.mjs +2 -2
- package/dist/runtime/index.d.mts +11 -11
- package/dist/runtime/index.mjs +9 -9
- package/dist/runtime/secretmanager.d.mts +7 -20
- package/dist/runtime/secretmanager.mjs +2 -2
- package/dist/runtime/workflow.d.mts +42 -41
- package/dist/runtime/workflow.mjs +2 -2
- package/dist/{schema-89dYxNC2.mjs → schema-C4LYbXVG.mjs} +5 -5
- package/dist/{schema-89dYxNC2.mjs.map → schema-C4LYbXVG.mjs.map} +1 -1
- package/dist/secretmanager-CYlpffsz.mjs +13 -0
- package/dist/secretmanager-CYlpffsz.mjs.map +1 -0
- package/dist/{service_pb-DjwIn4jO.mjs → service_pb-B2FF59sP.mjs} +1 -1
- package/dist/{service_pb-CIrhGwHk.mjs → service_pb-B5w9rjPY.mjs} +17 -50
- package/dist/service_pb-B5w9rjPY.mjs.map +1 -0
- package/dist/tailor-proto/src/tailor/v1/service_pb.d.mts +1 -1
- package/dist/tailor-proto/src/tailor/v1/workflow_pb.d.mts +29 -9
- package/dist/tailor-proto/src/tailor/v1/workflow_resource_pb.d.mts +35 -1
- package/dist/utils/test/index.mjs.map +1 -1
- package/dist/vitest/environment.mjs +1 -1
- package/dist/vitest/index.mjs +11 -11
- package/dist/vitest/index.mjs.map +1 -1
- package/dist/vitest/mocks/workflow.d.mts +5 -3
- package/dist/vitest/setup.mjs +1 -1
- package/dist/workflow-GNuSnsTx.mjs +22 -0
- package/dist/workflow-GNuSnsTx.mjs.map +1 -0
- package/docs/cli/auth.md +3 -3
- package/docs/cli/setup.md +8 -8
- package/docs/configuration.md +24 -0
- package/docs/migration/v2.md +111 -0
- package/docs/plugin/custom.md +4 -4
- package/docs/plugin/index.md +2 -2
- package/docs/runtime.md +4 -2
- package/docs/services/auth.md +2 -2
- package/docs/services/resolver.md +1 -1
- package/docs/services/tailordb-migration.md +1 -1
- package/docs/services/tailordb.md +31 -31
- package/docs/services/workflow.md +78 -0
- package/package.json +1 -1
- package/dist/aigateway-B3oZZE6v.mjs +0 -15
- package/dist/application-D2hSK1ZL.mjs +0 -3
- package/dist/application-eHp9jXld.mjs.map +0 -1
- package/dist/authconnection-BGQM8FZI.mjs +0 -15
- package/dist/authconnection-BGQM8FZI.mjs.map +0 -1
- package/dist/file-BbdFGdMV.mjs.map +0 -1
- package/dist/file-utils-CYZnO1pX.mjs.map +0 -1
- package/dist/globals-DhwZj0RB.mjs.map +0 -1
- package/dist/iconv-D2vi8G36.mjs +0 -63
- package/dist/iconv-D2vi8G36.mjs.map +0 -1
- package/dist/idp-Bx25ZBdN.mjs.map +0 -1
- package/dist/kysely-type-5eAChaHO.mjs.map +0 -1
- package/dist/register-ts-hook-ZpBacA07.mjs.map +0 -1
- package/dist/registry-DH4m7eYo.mjs.map +0 -1
- package/dist/rolldown-runtime-DXywRVcq.mjs +0 -20
- package/dist/secretmanager-BVxw3ih_.mjs +0 -24
- package/dist/secretmanager-BVxw3ih_.mjs.map +0 -1
- package/dist/service_pb-CIrhGwHk.mjs.map +0 -1
- package/dist/workflow-Bo59B75H.mjs +0 -50
- package/dist/workflow-Bo59B75H.mjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,44 @@
|
|
|
1
1
|
# @tailor-platform/sdk
|
|
2
2
|
|
|
3
|
+
## 2.0.0-next.4
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [#1693](https://github.com/tailor-platform/sdk/pull/1693) [`4751214`](https://github.com/tailor-platform/sdk/commit/4751214c0923e094a844f9ce322279a47e871075) Thanks [@dqn](https://github.com/dqn)! - Rename the TailorDB schema builder from `db.type()` to `db.table()`.
|
|
8
|
+
|
|
9
|
+
Update TailorDB definitions:
|
|
10
|
+
|
|
11
|
+
```diff
|
|
12
|
+
import { db } from "@tailor-platform/sdk";
|
|
13
|
+
|
|
14
|
+
-export const user = db.type("User", {
|
|
15
|
+
+export const user = db.table("User", {
|
|
16
|
+
name: db.string(),
|
|
17
|
+
});
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
- [#1704](https://github.com/tailor-platform/sdk/pull/1704) [`9c81d9c`](https://github.com/tailor-platform/sdk/commit/9c81d9c18b1d29b3e9307ea17fe54c8ce55f4dda) Thanks [@dqn](https://github.com/dqn)! - Remove flat value and default exports from `@tailor-platform/sdk/runtime/*` subpath modules. Import each subpath through its self-named namespace export instead, for example `import { iconv } from "@tailor-platform/sdk/runtime/iconv"`.
|
|
21
|
+
|
|
22
|
+
The aggregate `@tailor-platform/sdk/runtime` entry remains named-only, and its deprecated `file.deleteFile` alias is removed in favor of `file.delete`. The v2 codemod rewrites straightforward namespace-star subpath imports, flat named value imports, and aggregate `file.deleteFile` calls to the new namespace-object style.
|
|
23
|
+
|
|
24
|
+
`TailorContextAPI` and `TailorWorkflowAPI` now describe the SDK wrapper objects. Code that types the platform-provided `globalThis.tailor.context` or `globalThis.tailor.workflow` objects directly must use `PlatformContextAPI` or `PlatformWorkflowAPI` instead.
|
|
25
|
+
|
|
26
|
+
### Minor Changes
|
|
27
|
+
|
|
28
|
+
- [#1699](https://github.com/tailor-platform/sdk/pull/1699) [`f6a8d07`](https://github.com/tailor-platform/sdk/commit/f6a8d0779f94c2de5502dfdc68348e4a41ceee47) Thanks [@dqn](https://github.com/dqn)! - Allow `setup coordinate --action` values to group multiple generated actions into one multi-config deploy by separating action names with commas.
|
|
29
|
+
|
|
30
|
+
### Patch Changes
|
|
31
|
+
|
|
32
|
+
- [#1702](https://github.com/tailor-platform/sdk/pull/1702) [`03143f5`](https://github.com/tailor-platform/sdk/commit/03143f5213d9fa9d3c7697de78f2376994716679) Thanks [@dqn](https://github.com/dqn)! - Clarify the setup delete warning for coordinator action references so grouped `--action` values tell users to remove the action name from the relevant value.
|
|
33
|
+
|
|
34
|
+
- [#1691](https://github.com/tailor-platform/sdk/pull/1691) [`2f3dbab`](https://github.com/tailor-platform/sdk/commit/2f3dbab7ed3cf40fa174a82053d70c23c356204d) Thanks [@dqn](https://github.com/dqn)! - Clarify when profile machine user override errors are caused by `TAILOR_PLATFORM_MACHINE_USER_NAME`.
|
|
35
|
+
|
|
36
|
+
- [#1700](https://github.com/tailor-platform/sdk/pull/1700) [`0063115`](https://github.com/tailor-platform/sdk/commit/0063115f567ba7e73c0b679a392d5983869e8ac4) Thanks [@toiroakr](https://github.com/toiroakr)! - Fix `tailor` CLI failing with `ERR_MODULE_NOT_FOUND` when resolving extensionless relative imports of files whose basename contains a dot (e.g. `./permissions.generated`).
|
|
37
|
+
|
|
38
|
+
- [#1705](https://github.com/tailor-platform/sdk/pull/1705) [`958d571`](https://github.com/tailor-platform/sdk/commit/958d571555a5c66e2e3b9beb3d2247f63cbb8f2c) Thanks [@toiroakr](https://github.com/toiroakr)! - Fix `tailor` CLI failing with `ERR_MODULE_NOT_FOUND` when resolving `tsconfig.json` path aliases (`compilerOptions.paths`) in projects that omit `baseUrl`, which is the standard style since TypeScript 5.0. Also fix path alias resolution to match TypeScript's `extends` behavior: a child config's `baseUrl` is now correctly inherited from an extended config, and a child config's own `paths` now replaces (rather than merges with) inherited `paths`.
|
|
39
|
+
|
|
40
|
+
- [#1703](https://github.com/tailor-platform/sdk/pull/1703) [`4681778`](https://github.com/tailor-platform/sdk/commit/46817786354665cb97d0de63b78fa83e64096e03) Thanks [@toiroakr](https://github.com/toiroakr)! - Fix generated Kysely types for `db.date()` fields to use `Timestamp` instead of `string`, matching `db.datetime()` and allowing `insertInto`/`updateTable` calls to accept a `Date` value.
|
|
41
|
+
|
|
3
42
|
## 2.0.0-next.3
|
|
4
43
|
|
|
5
44
|
### Major Changes
|
|
@@ -226,6 +265,12 @@
|
|
|
226
265
|
|
|
227
266
|
- [#1421](https://github.com/tailor-platform/sdk/pull/1421) [`b933f47`](https://github.com/tailor-platform/sdk/commit/b933f474d65f8dfed56f3991aae3a52589368b10) Thanks [@dqn](https://github.com/dqn)! - Corrupted or hand-edited TailorDB migration snapshot/diff files now fail with a clear validation error when loaded, instead of causing undefined behavior later.
|
|
228
267
|
|
|
268
|
+
## 1.75.0
|
|
269
|
+
|
|
270
|
+
### Minor Changes
|
|
271
|
+
|
|
272
|
+
- [#1679](https://github.com/tailor-platform/sdk/pull/1679) [`4ff2b23`](https://github.com/tailor-platform/sdk/commit/4ff2b23d84c5dd5f1692cc3b3f7b32b273b4d550) Thanks [@k1LoW](https://github.com/k1LoW)! - Add workflow job function execution policies. Declare them with `defineWorkflowExecutionPolicies` (or the single-key `defineWorkflowExecutionPolicy`), register them via `workflow.executionPolicies` on `defineConfig`, and pass the policy's `key` (or, for wildcard policies declared with `matchType: "prefix"`, the value returned by `keyFor(suffix)`) through the new `executionPolicyKey` option on `triggerJobFunction` / `job.trigger()` to apply the platform-side concurrency cap. `executionPolicyKey` only accepts values produced by a declared policy. `keyFor` joins the prefix and suffix with `.` by default; override it with `separator`, passed as the second argument to `defineWorkflowExecutionPolicies` (applies to every policy in the group) or as a `def` field on a single `defineWorkflowExecutionPolicy`.
|
|
273
|
+
|
|
229
274
|
## 1.74.1
|
|
230
275
|
|
|
231
276
|
### Patch Changes
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region src/runtime/aigateway.ts
|
|
2
|
+
const api = () => globalThis.tailor.aigateway;
|
|
3
|
+
const get = (...args) => api().get(...args);
|
|
4
|
+
/** Runtime wrapper namespace for `tailor.aigateway`. */
|
|
5
|
+
const aigateway = { get };
|
|
6
|
+
|
|
7
|
+
//#endregion
|
|
8
|
+
export { aigateway as t };
|
|
9
|
+
//# sourceMappingURL=aigateway-DR4Kwuik.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aigateway-
|
|
1
|
+
{"version":3,"file":"aigateway-DR4Kwuik.mjs","names":[],"sources":["../src/runtime/aigateway.ts"],"sourcesContent":["/**\n * AI Gateway utilities.\n *\n * Thin typed wrapper around the platform-provided `tailor.aigateway` runtime API.\n * At runtime this delegates to `globalThis.tailor.aigateway`. Use `mockAigateway`\n * from `@tailor-platform/sdk/vitest` to mock these calls in unit tests.\n *\n * `name` is narrowed to the AI Gateway names defined via `defineAIGateway()`\n * once `tailor.d.ts` has been generated (via `tailor deploy`/`generate`).\n * @example\n * import { aigateway } from \"@tailor-platform/sdk/runtime\";\n *\n * const { url } = await aigateway.get(\"my-aigateway\");\n */\n\n// Import from the public entry (not `#/configure/types/aigateway-name`) so this d.ts\n// references `@tailor-platform/sdk` externally instead of inlining the registry — the\n// same generated `declare module \"@tailor-platform/sdk\"` that narrows\n// `authconnection.getConnectionToken` then also narrows this entry.\nimport type { AIGatewayName } from \"@tailor-platform/sdk\";\n\n/** Result of {@link TailorAigatewayAPI.get}. */\nexport interface GetAIGatewayResult {\n /** The platform-assigned URL of the AI Gateway. */\n url: string;\n}\n\n/**\n * Platform API surface for `tailor.aigateway`. Describes the shape the\n * platform runtime injects on `globalThis.tailor.aigateway`.\n */\nexport interface TailorAigatewayAPI {\n /**\n * Resolves an AI Gateway defined in the caller's own workspace.\n * @param name - AI Gateway name, as passed to `defineAIGateway()`\n * @returns The resolved AI Gateway's platform-assigned URL\n */\n get(name: AIGatewayName): Promise<GetAIGatewayResult>;\n}\n\nconst api = (): TailorAigatewayAPI =>\n (globalThis as unknown as { tailor: { aigateway: TailorAigatewayAPI } }).tailor.aigateway;\n\nconst get: TailorAigatewayAPI[\"get\"] = (...args) => api().get(...args);\n\n/** Runtime wrapper namespace for `tailor.aigateway`. */\nexport const aigateway = { get } as const satisfies TailorAigatewayAPI;\n"],"mappings":";AAwCA,MAAM,YACH,WAAwE,OAAO;AAElF,MAAM,OAAkC,GAAG,SAAS,IAAI,CAAC,CAAC,IAAI,GAAG,IAAI;;AAGrE,MAAa,YAAY,EAAE,IAAI"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { n as isSdkBranded } from "./brand-Eo4pLXPJ.mjs";
|
|
2
|
+
import { i as PageDirection } from "./resource_pb-BRv7AMXK.mjs";
|
|
2
3
|
import { t as assertDefined } from "./assert-DBxo8jPo.mjs";
|
|
3
4
|
import { a as parseBoolean, n as logger, r as styles } from "./logger-BEiZZ3qT.mjs";
|
|
4
5
|
import { a as AuthConfigSchema, c as stripTailorDBTypeBuilderHelpers, d as applyRelationMetadataToFieldConfig, f as buildRelationInfo, g as functionSchema, h as loadFilesWithIgnores, l as TailorDBServiceConfigSchema, m as validateRelationConfig, n as loadExecutor, o as AuthInvokerSchema, p as processRelationMetadata, s as TailorFieldSchema, t as createExecutorService, u as TailorDBTypeSchema } from "./service-ufH7sS8o.mjs";
|
|
@@ -11,10 +12,12 @@ import { builtinModules, createRequire } from "node:module";
|
|
|
11
12
|
import * as path from "pathe";
|
|
12
13
|
import { join, resolve } from "pathe";
|
|
13
14
|
import { resolveTSConfig } from "pkg-types";
|
|
15
|
+
import { arg } from "politty";
|
|
14
16
|
import { z } from "zod";
|
|
15
17
|
import { create } from "@bufbuild/protobuf";
|
|
16
18
|
import * as fs$1 from "node:fs";
|
|
17
19
|
import { mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
20
|
+
import { parseEnv } from "node:util";
|
|
18
21
|
import { MethodOptions_IdempotencyLevel } from "@bufbuild/protobuf/wkt";
|
|
19
22
|
import { pathToFileURL } from "node:url";
|
|
20
23
|
import { parseYAML, stringifyYAML } from "confbox";
|
|
@@ -33,6 +36,256 @@ import * as inflection from "inflection";
|
|
|
33
36
|
import * as globals from "globals";
|
|
34
37
|
import * as os from "node:os";
|
|
35
38
|
|
|
39
|
+
//#region src/cli/shared/args.ts
|
|
40
|
+
const unitToMs = {
|
|
41
|
+
ms: 1,
|
|
42
|
+
s: 1e3,
|
|
43
|
+
m: 60 * 1e3
|
|
44
|
+
};
|
|
45
|
+
const durationPattern = /^(\d+)(ms|s|m)$/;
|
|
46
|
+
/**
|
|
47
|
+
* Schema for duration string validation (e.g., "3s", "500ms", "1m")
|
|
48
|
+
* Only validates format; use parseDuration() to convert to milliseconds
|
|
49
|
+
*/
|
|
50
|
+
const durationArg = z.string().refine((val) => durationPattern.test(val), { message: "Invalid duration format. Expected format: '3s', '500ms', '1m'" }).refine((val) => {
|
|
51
|
+
const match = val.match(durationPattern);
|
|
52
|
+
if (!match) return false;
|
|
53
|
+
const digits = match[1];
|
|
54
|
+
return digits !== void 0 && parseInt(digits, 10) > 0;
|
|
55
|
+
}, { message: "Duration must be greater than 0" });
|
|
56
|
+
/**
|
|
57
|
+
* Parse a validated duration string into milliseconds
|
|
58
|
+
* @param duration - Duration string (e.g., "3s", "500ms", "1m")
|
|
59
|
+
* @returns Duration in milliseconds
|
|
60
|
+
*/
|
|
61
|
+
function parseDuration(duration) {
|
|
62
|
+
const match = assertDefined(duration.match(durationPattern), `invalid duration format: ${duration}`);
|
|
63
|
+
const value = parseInt(assertDefined(match[1], "duration digits group missing"), 10);
|
|
64
|
+
const unit = assertDefined(match[2], "duration unit group missing");
|
|
65
|
+
return value * unitToMs[unit];
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Schema for positive integer validation (from string input)
|
|
69
|
+
* Transforms the string to a number
|
|
70
|
+
*/
|
|
71
|
+
const positiveIntArg = z.coerce.number().int().positive();
|
|
72
|
+
/**
|
|
73
|
+
* Schema for non-negative integer validation (from string input).
|
|
74
|
+
* Accepts 0 (used for `--limit 0` to disable the limit).
|
|
75
|
+
*/
|
|
76
|
+
const nonNegativeIntArg = z.coerce.number().int().nonnegative();
|
|
77
|
+
/**
|
|
78
|
+
* Schema for sort order (`asc` or `desc`).
|
|
79
|
+
*/
|
|
80
|
+
const orderArg = z.enum(["asc", "desc"]);
|
|
81
|
+
/**
|
|
82
|
+
* Translate a CLI `--order` value into the proto `PageDirection` enum.
|
|
83
|
+
* Returns `undefined` when the user did not specify an order so that
|
|
84
|
+
* callers can omit the field and fall back to the server default.
|
|
85
|
+
* @param order - Order string from CLI args (`"asc"` | `"desc"` | undefined)
|
|
86
|
+
* @returns PageDirection, or undefined when `order` is undefined
|
|
87
|
+
*/
|
|
88
|
+
function toPageDirection(order) {
|
|
89
|
+
if (order === void 0) return void 0;
|
|
90
|
+
return order === "asc" ? PageDirection.ASC : PageDirection.DESC;
|
|
91
|
+
}
|
|
92
|
+
function hasMachineUserFlag(argv) {
|
|
93
|
+
return argv.slice(0, argv.indexOf("--") === -1 ? argv.length : argv.indexOf("--")).some((token) => token === "-m" || token.startsWith("-m=") || token === "--machine-user" || token.startsWith("--machine-user=") || token === "--machineUser" || token.startsWith("--machineUser=") || token === "--machineuser" || token.startsWith("--machineuser="));
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Resolve whether a parsed machine user value came from an explicit CLI option or env fallback.
|
|
97
|
+
* @param machineUser - Parsed machine user value
|
|
98
|
+
* @param argv - Raw CLI argv, excluding the executable and script path
|
|
99
|
+
* @param options - Source resolution options
|
|
100
|
+
* @returns Machine user input source, or undefined when no value was parsed
|
|
101
|
+
*/
|
|
102
|
+
function resolveMachineUserInputSource(machineUser, argv = process.argv.slice(2), options = {}) {
|
|
103
|
+
if (machineUser === void 0) return void 0;
|
|
104
|
+
if (options.valueIsExplicit) return "option";
|
|
105
|
+
if (hasMachineUserFlag(argv)) return "option";
|
|
106
|
+
return process.env.TAILOR_PLATFORM_MACHINE_USER_NAME === machineUser ? "env" : "option";
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Load env files from parsed arguments.
|
|
110
|
+
* Processes --env-file first, then --env-file-if-exists.
|
|
111
|
+
*
|
|
112
|
+
* Follows Node.js --env-file behavior:
|
|
113
|
+
* - Variables already set in the environment are NOT overwritten
|
|
114
|
+
* - Variables from later files override those from earlier files
|
|
115
|
+
* @param envFiles - Required env file path(s) that must exist
|
|
116
|
+
* @param envFilesIfExists - Optional env file path(s) that are loaded if they exist
|
|
117
|
+
*/
|
|
118
|
+
function loadEnvFiles(envFiles, envFilesIfExists) {
|
|
119
|
+
const originalEnvKeys = new Set(Object.keys(process.env));
|
|
120
|
+
const load = (files, required) => {
|
|
121
|
+
for (const file of [files ?? []].flat()) {
|
|
122
|
+
const envPath = path.resolve(process.cwd(), file);
|
|
123
|
+
if (!fs$1.existsSync(envPath)) {
|
|
124
|
+
if (required) throw new Error(`Environment file not found: ${envPath}`);
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
const parsed = parseEnv(fs$1.readFileSync(envPath, "utf-8"));
|
|
128
|
+
for (const [key, value] of Object.entries(parsed)) {
|
|
129
|
+
if (originalEnvKeys.has(key)) continue;
|
|
130
|
+
process.env[key] = value;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
load(envFiles, true);
|
|
135
|
+
load(envFilesIfExists, false);
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Common arguments for all CLI commands
|
|
139
|
+
*
|
|
140
|
+
* NOTE: --env-file and --env-file-if-exists collide with Node.js flags due to a bug
|
|
141
|
+
* (https://github.com/nodejs/node/issues/54232). Node.js parses these even after the
|
|
142
|
+
* script path, causing warnings (twice due to tsx loader).
|
|
143
|
+
*/
|
|
144
|
+
const commonArgs = {
|
|
145
|
+
"env-file": arg(z.string().optional(), {
|
|
146
|
+
alias: "e",
|
|
147
|
+
description: "Path to the environment file (error if not found)",
|
|
148
|
+
completion: {
|
|
149
|
+
type: "file",
|
|
150
|
+
matcher: [".env.*", ".env"]
|
|
151
|
+
}
|
|
152
|
+
}),
|
|
153
|
+
"env-file-if-exists": arg(z.string().optional(), {
|
|
154
|
+
description: "Path to the environment file (ignored if not found)",
|
|
155
|
+
completion: {
|
|
156
|
+
type: "file",
|
|
157
|
+
matcher: [".env.*", ".env"]
|
|
158
|
+
},
|
|
159
|
+
effect: (_value, { args }) => {
|
|
160
|
+
loadEnvFiles(args["env-file"], args["env-file-if-exists"]);
|
|
161
|
+
}
|
|
162
|
+
}),
|
|
163
|
+
verbose: arg(z.boolean().default(false), {
|
|
164
|
+
description: "Enable verbose logging",
|
|
165
|
+
effect: (value) => {
|
|
166
|
+
verboseMode = value;
|
|
167
|
+
}
|
|
168
|
+
}),
|
|
169
|
+
json: arg(z.boolean().default(false), {
|
|
170
|
+
alias: "j",
|
|
171
|
+
description: "Output as JSON",
|
|
172
|
+
effect: (value) => {
|
|
173
|
+
logger.jsonMode = value;
|
|
174
|
+
}
|
|
175
|
+
})
|
|
176
|
+
};
|
|
177
|
+
/**
|
|
178
|
+
* Arguments for commands that require workspace context
|
|
179
|
+
*/
|
|
180
|
+
const workspaceArgs = {
|
|
181
|
+
"workspace-id": arg(z.string().optional(), {
|
|
182
|
+
alias: "w",
|
|
183
|
+
description: "Workspace ID",
|
|
184
|
+
env: "TAILOR_PLATFORM_WORKSPACE_ID",
|
|
185
|
+
completion: { type: "none" }
|
|
186
|
+
}),
|
|
187
|
+
profile: arg(z.string().optional(), {
|
|
188
|
+
alias: "p",
|
|
189
|
+
description: "Workspace profile",
|
|
190
|
+
env: "TAILOR_PLATFORM_PROFILE",
|
|
191
|
+
completion: { type: "none" }
|
|
192
|
+
})
|
|
193
|
+
};
|
|
194
|
+
/**
|
|
195
|
+
* Shared config arg for commands that accept a config file path
|
|
196
|
+
*/
|
|
197
|
+
const configArg = { config: arg(z.string().default("tailor.config.ts"), {
|
|
198
|
+
alias: "c",
|
|
199
|
+
description: "Path to Tailor config file",
|
|
200
|
+
env: "TAILOR_CONFIG_PATH",
|
|
201
|
+
completion: {
|
|
202
|
+
type: "file",
|
|
203
|
+
extensions: ["ts"]
|
|
204
|
+
}
|
|
205
|
+
}) };
|
|
206
|
+
/**
|
|
207
|
+
* Shared config arg for commands that accept one or more comma-separated config file paths
|
|
208
|
+
*/
|
|
209
|
+
const multiConfigArg = { config: arg(z.string().default("tailor.config.ts"), {
|
|
210
|
+
alias: "c",
|
|
211
|
+
description: "Path to SDK config file. Use comma-separated paths to deploy multiple apps together.",
|
|
212
|
+
env: "TAILOR_PLATFORM_SDK_CONFIG_PATH",
|
|
213
|
+
completion: {
|
|
214
|
+
type: "file",
|
|
215
|
+
extensions: ["ts"]
|
|
216
|
+
}
|
|
217
|
+
}) };
|
|
218
|
+
/**
|
|
219
|
+
* Arguments for commands that interact with deployed resources (includes config)
|
|
220
|
+
*/
|
|
221
|
+
const deploymentArgs = {
|
|
222
|
+
...workspaceArgs,
|
|
223
|
+
...configArg
|
|
224
|
+
};
|
|
225
|
+
/**
|
|
226
|
+
* Arguments for commands that require confirmation
|
|
227
|
+
*/
|
|
228
|
+
const confirmationArgs = { yes: arg(z.boolean().default(false), {
|
|
229
|
+
alias: "y",
|
|
230
|
+
description: "Skip confirmation prompts"
|
|
231
|
+
}) };
|
|
232
|
+
/**
|
|
233
|
+
* Arguments for commands that require organization context
|
|
234
|
+
*/
|
|
235
|
+
const organizationArgs = { "organization-id": arg(z.string(), {
|
|
236
|
+
alias: "o",
|
|
237
|
+
description: "Organization ID",
|
|
238
|
+
env: "TAILOR_PLATFORM_ORGANIZATION_ID",
|
|
239
|
+
completion: { type: "none" }
|
|
240
|
+
}) };
|
|
241
|
+
/**
|
|
242
|
+
* Arguments for list commands that accept `--order` / `--limit`. Sort
|
|
243
|
+
* order defaults to `desc` (newest first) because most callers want the
|
|
244
|
+
* latest items; pass `--order asc` to opt in to ascending order. The
|
|
245
|
+
* limit is unbounded by default so existing invocations keep returning
|
|
246
|
+
* every item; pass `--limit N` to cap the result size.
|
|
247
|
+
* @param defaultOrder - Default value for `--order` (defaults to `"desc"`)
|
|
248
|
+
* @returns Argument shape suitable for spreading into a command schema
|
|
249
|
+
*/
|
|
250
|
+
const paginationArgs = (defaultOrder = "desc") => ({
|
|
251
|
+
order: arg(orderArg.default(defaultOrder), { description: "Sort order (asc or desc)" }),
|
|
252
|
+
limit: arg(nonNegativeIntArg.optional(), {
|
|
253
|
+
alias: "l",
|
|
254
|
+
description: "Maximum number of items to return (0 or omit: unlimited)"
|
|
255
|
+
})
|
|
256
|
+
});
|
|
257
|
+
/**
|
|
258
|
+
* Arguments for time-series log list commands. Defaults to newest-first
|
|
259
|
+
* (`desc`) and a 50-item cap so that listing stays responsive on busy
|
|
260
|
+
* workspaces. Pass `--limit 0` to disable the cap and fetch all entries.
|
|
261
|
+
*/
|
|
262
|
+
const pagedLogArgs = {
|
|
263
|
+
order: arg(orderArg.default("desc"), { description: "Sort order (asc or desc)" }),
|
|
264
|
+
limit: arg(nonNegativeIntArg.default(50), {
|
|
265
|
+
alias: "l",
|
|
266
|
+
description: "Maximum number of items to return (0: unlimited)"
|
|
267
|
+
})
|
|
268
|
+
};
|
|
269
|
+
/**
|
|
270
|
+
* Arguments for commands that require folder context
|
|
271
|
+
*/
|
|
272
|
+
const folderArgs = { "folder-id": arg(z.string(), {
|
|
273
|
+
alias: "f",
|
|
274
|
+
description: "Folder ID",
|
|
275
|
+
env: "TAILOR_PLATFORM_FOLDER_ID",
|
|
276
|
+
completion: { type: "none" }
|
|
277
|
+
}) };
|
|
278
|
+
let verboseMode = false;
|
|
279
|
+
/**
|
|
280
|
+
* Returns whether verbose mode is enabled.
|
|
281
|
+
* Used by the global cleanup handler which doesn't have access to parsed args.
|
|
282
|
+
* @returns Whether verbose mode is enabled
|
|
283
|
+
*/
|
|
284
|
+
function isVerbose() {
|
|
285
|
+
return verboseMode;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
//#endregion
|
|
36
289
|
//#region src/parser/app-config/log-level.ts
|
|
37
290
|
const LOG_LEVELS = [
|
|
38
291
|
"DEBUG",
|
|
@@ -245,7 +498,7 @@ function initOAuth2Client(config) {
|
|
|
245
498
|
*/
|
|
246
499
|
async function initOperatorClient(accessToken, config) {
|
|
247
500
|
const platformConfig = config ?? getPlatformConfigForToken(accessToken);
|
|
248
|
-
const [{ createTracingInterceptor }, { OperatorService }] = await Promise.all([import("./interceptor-e33JtsC-.mjs"), import("./service_pb-
|
|
501
|
+
const [{ createTracingInterceptor }, { OperatorService }] = await Promise.all([import("./interceptor-e33JtsC-.mjs"), import("./service_pb-B2FF59sP.mjs")]);
|
|
249
502
|
const interceptors = [
|
|
250
503
|
await userAgentInterceptor(),
|
|
251
504
|
await bearerTokenInterceptor(accessToken),
|
|
@@ -415,7 +668,8 @@ const RETRY_SAFE_CREATE_METHODS = /* @__PURE__ */ new Set([
|
|
|
415
668
|
"CreateTailorDBType",
|
|
416
669
|
"CreateTenantConfig",
|
|
417
670
|
"CreateUserProfileConfig",
|
|
418
|
-
"CreateWorkflow"
|
|
671
|
+
"CreateWorkflow",
|
|
672
|
+
"CreateWorkflowJobFunctionExecutionPolicy"
|
|
419
673
|
]);
|
|
420
674
|
/**
|
|
421
675
|
* Whether an error is an `AlreadyExists` from a retry-safe Create RPC.
|
|
@@ -1183,7 +1437,15 @@ async function loadMachineUserName(opts) {
|
|
|
1183
1437
|
message: "Machine user name cannot be empty.",
|
|
1184
1438
|
suggestion: "Pass a non-empty machine user name, or omit the option to use the environment variable or profile default."
|
|
1185
1439
|
});
|
|
1186
|
-
const
|
|
1440
|
+
const envMachineUser = process.env.TAILOR_PLATFORM_MACHINE_USER_NAME || void 0;
|
|
1441
|
+
const explicitMachineUser = opts?.machineUser ? {
|
|
1442
|
+
source: opts.machineUserSource ?? "option",
|
|
1443
|
+
value: opts.machineUser
|
|
1444
|
+
} : envMachineUser ? {
|
|
1445
|
+
source: "env",
|
|
1446
|
+
value: envMachineUser
|
|
1447
|
+
} : void 0;
|
|
1448
|
+
const explicit = explicitMachineUser?.value;
|
|
1187
1449
|
const profile = opts?.profile || process.env.TAILOR_PLATFORM_PROFILE;
|
|
1188
1450
|
if (!profile) return explicit;
|
|
1189
1451
|
const entry = (await readPlatformConfig()).profiles[profile];
|
|
@@ -1192,12 +1454,15 @@ async function loadMachineUserName(opts) {
|
|
|
1192
1454
|
throw new Error(`Profile "${profile}" not found`);
|
|
1193
1455
|
}
|
|
1194
1456
|
if (entry.machine_user && entry.machine_user_override === "deny") {
|
|
1195
|
-
if (explicit && explicit !== entry.machine_user)
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1457
|
+
if (explicit && explicit !== entry.machine_user) {
|
|
1458
|
+
const details = explicitMachineUser.source === "env" ? `The machine user is being set to "${explicit}" via the TAILOR_PLATFORM_MACHINE_USER_NAME environment variable, which conflicts with this profile's pinned machine user "${entry.machine_user}".` : `This profile fixes the machine user to "${entry.machine_user}" for application-data commands.`;
|
|
1459
|
+
throw createCLIError({
|
|
1460
|
+
code: "PROFILE_MACHINE_USER_OVERRIDE_DENIED",
|
|
1461
|
+
message: `Profile "${profile}" denies overriding the machine user.`,
|
|
1462
|
+
details,
|
|
1463
|
+
suggestion: `Omit the machine user option, unset TAILOR_PLATFORM_MACHINE_USER_NAME, or run 'tailor profile update ${profile} --machine-user-override allow'.`
|
|
1464
|
+
});
|
|
1465
|
+
}
|
|
1201
1466
|
return entry.machine_user;
|
|
1202
1467
|
}
|
|
1203
1468
|
return explicit || entry.machine_user;
|
|
@@ -2157,7 +2422,7 @@ function generateTypeFileContent(info) {
|
|
|
2157
2422
|
*/
|
|
2158
2423
|
import { db } from "@tailor-platform/sdk";
|
|
2159
2424
|
|
|
2160
|
-
export const ${variableName} = db.
|
|
2425
|
+
export const ${variableName} = db.table(${JSON.stringify(type.name)}, ${fieldsCode});
|
|
2161
2426
|
|
|
2162
2427
|
export type ${type.name} = typeof ${variableName};
|
|
2163
2428
|
`;
|
|
@@ -2666,7 +2931,8 @@ function detectTriggerCalls(program, sourceText) {
|
|
|
2666
2931
|
if (triggerCall) calls.push({
|
|
2667
2932
|
identifierName: triggerCall.identifierName,
|
|
2668
2933
|
callRange: triggerCall.callRange,
|
|
2669
|
-
argsText: triggerCall.argsText
|
|
2934
|
+
argsText: triggerCall.argsText,
|
|
2935
|
+
optionsText: triggerCall.optionsText
|
|
2670
2936
|
});
|
|
2671
2937
|
for (const key of Object.keys(node)) {
|
|
2672
2938
|
const child = node[key];
|
|
@@ -2931,7 +3197,8 @@ function detectExtendedTriggerCalls(program, sourceText, workflowNames, jobNames
|
|
|
2931
3197
|
kind: "job",
|
|
2932
3198
|
identifierName: triggerCall.identifierName,
|
|
2933
3199
|
callRange: triggerCall.callRange,
|
|
2934
|
-
argsText: triggerCall.argsText
|
|
3200
|
+
argsText: triggerCall.argsText,
|
|
3201
|
+
optionsText: triggerCall.optionsText
|
|
2935
3202
|
});
|
|
2936
3203
|
}
|
|
2937
3204
|
for (const key of Object.keys(node)) {
|
|
@@ -3007,7 +3274,8 @@ function transformFunctionTriggers(source, workflowNameMap, jobNameMap, workflow
|
|
|
3007
3274
|
} else {
|
|
3008
3275
|
const jobName = jobNameMap.get(call.identifierName);
|
|
3009
3276
|
if (jobName) {
|
|
3010
|
-
const
|
|
3277
|
+
const optionsPart = call.optionsText !== void 0 ? `, ${call.optionsText}` : "";
|
|
3278
|
+
const transformedCall = `tailor.workflow.triggerJobFunction("${jobName}", ${call.argsText || "undefined"}${optionsPart})`;
|
|
3011
3279
|
replacements.push({
|
|
3012
3280
|
start: call.callRange.start,
|
|
3013
3281
|
end: call.callRange.end,
|
|
@@ -3720,7 +3988,7 @@ function validatePluralFormUniqueness(types, namespace, typeSourceInfo) {
|
|
|
3720
3988
|
const singularQuery = inflection.camelize(parsedType.name, true);
|
|
3721
3989
|
if (singularQuery === inflection.camelize(parsedType.pluralForm, true)) {
|
|
3722
3990
|
const location = formatTypeSourceLocation(getTypeSourceInfo(typeSourceInfo, parsedType.name));
|
|
3723
|
-
errors.push(`Type "${parsedType.name}"${location} has identical singular and plural query names "${singularQuery}". Use db.
|
|
3991
|
+
errors.push(`Type "${parsedType.name}"${location} has identical singular and plural query names "${singularQuery}". Use db.table(["${parsedType.name}", "UniquePluralForm"], {...}) to set a unique pluralForm.`);
|
|
3724
3992
|
}
|
|
3725
3993
|
}
|
|
3726
3994
|
const queryNameToSource = /* @__PURE__ */ new Map();
|
|
@@ -5381,7 +5649,8 @@ function transformWorkflowSource(source, targetJobName, targetJobExportName, oth
|
|
|
5381
5649
|
if (isInsideRemovedRange(call.callRange.start)) continue;
|
|
5382
5650
|
const jobName = jobNameMap.get(call.identifierName);
|
|
5383
5651
|
if (jobName) {
|
|
5384
|
-
const
|
|
5652
|
+
const optionsPart = call.optionsText !== void 0 ? `, ${call.optionsText}` : "";
|
|
5653
|
+
const transformedCall = `tailor.workflow.triggerJobFunction("${jobName}", ${call.argsText || "undefined"}${optionsPart})`;
|
|
5385
5654
|
replacements.push({
|
|
5386
5655
|
start: call.callRange.start,
|
|
5387
5656
|
end: call.callRange.end,
|
|
@@ -5638,6 +5907,13 @@ const RetryPolicySchema = z.strictObject({
|
|
|
5638
5907
|
path: ["initialBackoff"]
|
|
5639
5908
|
});
|
|
5640
5909
|
const ConcurrencyPolicySchema = z.strictObject({ maxConcurrentExecutions: z.number().int().min(1).max(1e3).describe("Maximum number of concurrent executions (1-1000)") });
|
|
5910
|
+
const ExecutionPolicyNameSchema = z.string().regex(/^[a-z0-9][a-z0-9-]{1,61}[a-z0-9]$/, "Invalid execution policy name: must match [a-z0-9-] (3-63 chars; must start and end with [a-z0-9])").describe("Workspace-unique execution policy name embedded in the resource TRN");
|
|
5911
|
+
const ExecutionPolicyKeySchema = z.string().regex(/^[a-z0-9][a-z0-9_:.-]{0,62}[a-z0-9*]$/, "Invalid execution policy key: must match [a-z0-9_:.-] (2-64 chars; must start with [a-z0-9] and end with [a-z0-9] or a trailing '*')").describe("Execution policy key passed to triggerJobFunction's executionPolicyKey option");
|
|
5912
|
+
const WorkflowJobFunctionExecutionPolicySchema = z.strictObject({
|
|
5913
|
+
name: ExecutionPolicyNameSchema,
|
|
5914
|
+
key: ExecutionPolicyKeySchema,
|
|
5915
|
+
concurrencyPolicy: ConcurrencyPolicySchema.optional().describe("Optional per-key concurrency cap for job function dispatches matching this policy")
|
|
5916
|
+
});
|
|
5641
5917
|
const WorkflowSchema = z.strictObject({
|
|
5642
5918
|
name: z.string().describe("Workflow name"),
|
|
5643
5919
|
mainJob: WorkflowJobSchema.describe("Main job that starts the workflow"),
|
|
@@ -6389,5 +6665,5 @@ async function loadApplication(params) {
|
|
|
6389
6665
|
}
|
|
6390
6666
|
|
|
6391
6667
|
//#endregion
|
|
6392
|
-
export {
|
|
6393
|
-
//# sourceMappingURL=application-
|
|
6668
|
+
export { fetchUserInfo as $, hasAnyUserTokenEntry as A, readPlatformConfig as B, createBundleCache as C, positiveIntArg as Ct, loadConfig as D, hashFile as E, workspaceArgs as Et, loadMachineUserName as F, writePlatformConfig as G, resolveConfigUser as H, loadPlatformClientConfig as I, fetchAll as J, closeConnectionPool as K, loadStoredUserTokens as L, loadAccessToken as M, loadConfigPath as N, deleteUserTokens as O, loadConsoleBaseUrl as P, fetchPlatformMachineUserToken as Q, loadWorkspaceId as R, hasGenerationHooks as S, parseDuration as St, hashContent as T, toPageDirection as Tt, resolveUserTokenKey as U, removeLegacyUserAlias as V, saveUserTokens as W, fetchMachineUserToken as X, fetchAllTolerant as Y, fetchPaged as Z, platformBundleDefinePlugin as _, nonNegativeIntArg as _t, resolveInlineSourcemap as a, initOperatorClient as at, resolveBundleLogLevel as b, pagedLogArgs as bt, WorkflowJobSchema as c, byName as ct, INVOKER_EXPR as d, confirmationArgs as dt, getConsoleBaseUrl as et, buildExecutorArgsExpr as f, deploymentArgs as ft, stringifyFunction as g, multiConfigArg as gt, assertUniqueTailorDBTypeNamesWithExternal as h, isVerbose as ht, resolverBundleKey as i, initOAuth2Client as it, hasUserTokenEntry as j, fetchLatestToken as k, ResolverSchema as l, commonArgs as lt, assertUniqueLocalTailorDBTypeNames as m, folderArgs as mt, generatePluginFilesIfNeeded as n, getOrNull as nt, getApplicationAuthNamespace as o, isDefaultPlatform as ot, buildResolverOperationHookExpr as p, durationArg as pt, defaultPlatformBaseUrl as q, loadApplication as r, getPlatformBaseUrl as rt, WorkflowJobFunctionExecutionPolicySchema as s, resolveStaticWebsiteUrls as st, defineApplication as t, getOAuth2ClientId as tt, HTTP_METHODS as u, configArg as ut, composeFunctionTreeshakeOptions as v, orderArg as vt, getDistDir as w, resolveMachineUserInputSource as wt, getPluginGenerationDependencies as x, paginationArgs as xt, createLogLevelTreeshakeOptions as y, organizationArgs as yt, platformConfigFromProfile as z };
|
|
6669
|
+
//# sourceMappingURL=application-BX13RArL.mjs.map
|