@tailor-platform/sdk 2.28.0 → 2.29.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.
- package/CHANGELOG.md +61 -0
- package/README.md +0 -8
- package/dist/{application-CvmKh5WT.mjs → application-dalGHdrI.mjs} +1 -1
- package/dist/{application-CgJLyJaF.mjs → application-rWYDAfNU.mjs} +29 -29
- package/dist/application-rWYDAfNU.mjs.map +1 -0
- package/dist/cli/cache/bundle-cache.d.mts +1 -0
- package/dist/cli/lib.mjs +1 -1
- package/dist/cli/lib.mjs.map +1 -1
- package/dist/cli/main.d.mts +5 -0
- package/dist/cli/main.mjs +46 -46
- package/dist/cli/main.mjs.map +1 -1
- package/dist/cli/ts-hook.mjs +15 -11
- package/dist/completion/zsh-worker.zsh +59 -2
- package/dist/configure/config/types.d.mts +57 -0
- package/dist/{register-ts-hook-yxshv0LV.mjs → register-ts-hook-CkfKqhJT.mjs} +78 -77
- package/dist/register-ts-hook-CkfKqhJT.mjs.map +1 -0
- package/dist/seed/index.d.mts +1 -1
- package/dist/seed/index.mjs +1 -1
- package/dist/seed/index.mjs.map +1 -1
- package/dist/seed-C3P_T_Eh.mjs.map +1 -1
- package/dist/vitest/mocks/file.d.mts +1 -1
- package/docs/cli/application.md +8 -3
- package/docs/cli/tailordb.md +34 -0
- package/docs/cli-reference.md +11 -0
- package/docs/configuration.md +53 -2
- package/docs/github-actions.md +90 -7
- package/docs/plugin/custom.md +1 -1
- package/docs/services/resolver.md +1 -58
- package/docs/services/tailordb-migration.md +12 -3
- package/docs/services/workflow.md +2 -2
- package/docs/testing.md +2 -2
- package/package.json +16 -16
- package/dist/application-CgJLyJaF.mjs.map +0 -1
- package/dist/register-ts-hook-yxshv0LV.mjs.map +0 -1
package/dist/cli/ts-hook.mjs
CHANGED
|
@@ -174,10 +174,10 @@ const IMPORT_NONCE_PARAM = "tailorImportNonce";
|
|
|
174
174
|
// nonce'd entry module gets a fresh evaluation of its whole project subgraph.
|
|
175
175
|
// Bare specifiers are left alone: node_modules packages (and workspace-linked
|
|
176
176
|
// ones resolving outside node_modules) must stay singletons.
|
|
177
|
-
function propagateImportNonce(resolved,
|
|
177
|
+
function propagateImportNonce(resolved, parentURL) {
|
|
178
178
|
if (!resolved?.url?.startsWith("file:")) return resolved;
|
|
179
|
-
if (!
|
|
180
|
-
const nonce = new URL(
|
|
179
|
+
if (!parentURL?.startsWith("file:")) return resolved;
|
|
180
|
+
const nonce = new URL(parentURL).searchParams.get(IMPORT_NONCE_PARAM);
|
|
181
181
|
if (!nonce) return resolved;
|
|
182
182
|
const url = new URL(resolved.url);
|
|
183
183
|
if (url.searchParams.has(IMPORT_NONCE_PARAM) || url.pathname.includes("/node_modules/")) {
|
|
@@ -199,11 +199,13 @@ function isProjectLocalSpecifier(specifier) {
|
|
|
199
199
|
// --- module hooks ---
|
|
200
200
|
|
|
201
201
|
export async function resolve(specifier, context, nextResolve) {
|
|
202
|
+
const { parentURL } = context;
|
|
202
203
|
const resolved = await resolveTs(specifier, context, nextResolve);
|
|
203
|
-
return isProjectLocalSpecifier(specifier) ? propagateImportNonce(resolved,
|
|
204
|
+
return isProjectLocalSpecifier(specifier) ? propagateImportNonce(resolved, parentURL) : resolved;
|
|
204
205
|
}
|
|
205
206
|
|
|
206
207
|
async function resolveTs(specifier, context, nextResolve) {
|
|
208
|
+
const { parentURL } = context;
|
|
207
209
|
try {
|
|
208
210
|
return await nextResolve(specifier, context);
|
|
209
211
|
} catch (err) {
|
|
@@ -225,8 +227,8 @@ async function resolveTs(specifier, context, nextResolve) {
|
|
|
225
227
|
|
|
226
228
|
if (!specifier.startsWith(".") && !specifier.startsWith("/")) {
|
|
227
229
|
// Non-relative: try tsconfig path aliases
|
|
228
|
-
if (
|
|
229
|
-
const parentParsed = new URL(
|
|
230
|
+
if (parentURL?.startsWith("file://")) {
|
|
231
|
+
const parentParsed = new URL(parentURL);
|
|
230
232
|
const parentNonce = parentParsed.searchParams.get(IMPORT_NONCE_PARAM) ?? "";
|
|
231
233
|
parentParsed.search = "";
|
|
232
234
|
parentParsed.hash = "";
|
|
@@ -236,7 +238,7 @@ async function resolveTs(specifier, context, nextResolve) {
|
|
|
236
238
|
if (candidates) {
|
|
237
239
|
for (const candidate of candidates) {
|
|
238
240
|
const result = await tryResolveWithExtensions(candidate, context, nextResolve);
|
|
239
|
-
if (result) return propagateImportNonce(result,
|
|
241
|
+
if (result) return propagateImportNonce(result, parentURL);
|
|
240
242
|
}
|
|
241
243
|
}
|
|
242
244
|
}
|
|
@@ -291,11 +293,13 @@ export async function load(url, context, nextLoad) {
|
|
|
291
293
|
// on require() of scheme-only builtins (node:sqlite, node:test, node:sea) once both
|
|
292
294
|
// resolve and load are registered — nodejs/node#58607, fixed by nodejs/node#58612.
|
|
293
295
|
export function resolveSync(specifier, context, nextResolve) {
|
|
296
|
+
const { parentURL } = context;
|
|
294
297
|
const resolved = resolveTsSync(specifier, context, nextResolve);
|
|
295
|
-
return isProjectLocalSpecifier(specifier) ? propagateImportNonce(resolved,
|
|
298
|
+
return isProjectLocalSpecifier(specifier) ? propagateImportNonce(resolved, parentURL) : resolved;
|
|
296
299
|
}
|
|
297
300
|
|
|
298
301
|
function resolveTsSync(specifier, context, nextResolve) {
|
|
302
|
+
const { parentURL } = context;
|
|
299
303
|
try {
|
|
300
304
|
return nextResolve(specifier, context);
|
|
301
305
|
} catch (err) {
|
|
@@ -317,8 +321,8 @@ function resolveTsSync(specifier, context, nextResolve) {
|
|
|
317
321
|
|
|
318
322
|
if (!specifier.startsWith(".") && !specifier.startsWith("/")) {
|
|
319
323
|
// Non-relative: try tsconfig path aliases
|
|
320
|
-
if (
|
|
321
|
-
const parentParsed = new URL(
|
|
324
|
+
if (parentURL?.startsWith("file://")) {
|
|
325
|
+
const parentParsed = new URL(parentURL);
|
|
322
326
|
const parentNonce = parentParsed.searchParams.get(IMPORT_NONCE_PARAM) ?? "";
|
|
323
327
|
parentParsed.search = "";
|
|
324
328
|
parentParsed.hash = "";
|
|
@@ -328,7 +332,7 @@ function resolveTsSync(specifier, context, nextResolve) {
|
|
|
328
332
|
if (candidates) {
|
|
329
333
|
for (const candidate of candidates) {
|
|
330
334
|
const result = tryResolveWithExtensionsSync(candidate, context, nextResolve);
|
|
331
|
-
if (result) return propagateImportNonce(result,
|
|
335
|
+
if (result) return propagateImportNonce(result, parentURL);
|
|
332
336
|
}
|
|
333
337
|
}
|
|
334
338
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# politty-completion-version: 1
|
|
2
|
-
# politty-bin-sig:
|
|
2
|
+
# politty-bin-sig: 1792375657
|
|
3
3
|
# politty-bin-path: /home/runner/work/sdk/sdk/node_modules/.bin/tailor
|
|
4
4
|
# program: tailor
|
|
5
5
|
# shell: zsh
|
|
@@ -761,6 +761,10 @@ __tailor_worker_opt_takes_value() {
|
|
|
761
761
|
tailordb:migration:rebaseline:--profile|tailordb:migration:rebaseline:-p|tailordb:migration:rebaseline:--p) return 0 ;;
|
|
762
762
|
tailordb:migration:rebaseline:--config|tailordb:migration:rebaseline:-c|tailordb:migration:rebaseline:--c) return 0 ;;
|
|
763
763
|
tailordb:migration:rebaseline:--namespace|tailordb:migration:rebaseline:-n|tailordb:migration:rebaseline:--n) return 0 ;;
|
|
764
|
+
tailordb:migration:resolve:--workspace-id|tailordb:migration:resolve:--workspaceId|tailordb:migration:resolve:-w|tailordb:migration:resolve:--w) return 0 ;;
|
|
765
|
+
tailordb:migration:resolve:--profile|tailordb:migration:resolve:-p|tailordb:migration:resolve:--p) return 0 ;;
|
|
766
|
+
tailordb:migration:resolve:--config|tailordb:migration:resolve:-c|tailordb:migration:resolve:--c) return 0 ;;
|
|
767
|
+
tailordb:migration:resolve:--namespace|tailordb:migration:resolve:-n|tailordb:migration:resolve:--n) return 0 ;;
|
|
764
768
|
tailordb:migration:script:--config|tailordb:migration:script:-c|tailordb:migration:script:--c) return 0 ;;
|
|
765
769
|
tailordb:migration:script:--namespace|tailordb:migration:script:-n|tailordb:migration:script:--n) return 0 ;;
|
|
766
770
|
tailordb:migration:script:--reason) return 0 ;;
|
|
@@ -1024,6 +1028,7 @@ __tailor_worker_is_subcmd() {
|
|
|
1024
1028
|
tailordb:truncate) return 0 ;;
|
|
1025
1029
|
tailordb:migration:generate) return 0 ;;
|
|
1026
1030
|
tailordb:migration:rebaseline) return 0 ;;
|
|
1031
|
+
tailordb:migration:resolve) return 0 ;;
|
|
1027
1032
|
tailordb:migration:script) return 0 ;;
|
|
1028
1033
|
tailordb:migration:set) return 0 ;;
|
|
1029
1034
|
tailordb:migration:status) return 0 ;;
|
|
@@ -3540,6 +3545,57 @@ __tailor_worker_complete_tailordb_migration_rebaseline() {
|
|
|
3540
3545
|
fi
|
|
3541
3546
|
}
|
|
3542
3547
|
|
|
3548
|
+
__tailor_worker_complete_tailordb_migration_resolve() {
|
|
3549
|
+
local -a _vals=()
|
|
3550
|
+
case "${words[CURRENT-1]}" in
|
|
3551
|
+
--config|-c|--c)
|
|
3552
|
+
setopt local_options null_glob
|
|
3553
|
+
local _cur="${words[CURRENT]:-}" _dir _prefix _f _out
|
|
3554
|
+
local -a _exts=("ts")
|
|
3555
|
+
if [[ -z "$_cur" || "$_cur" != */* ]]; then
|
|
3556
|
+
_dir="."
|
|
3557
|
+
_prefix="$_cur"
|
|
3558
|
+
elif [[ "$_cur" == */ ]]; then
|
|
3559
|
+
_dir="${_cur%/}"
|
|
3560
|
+
_prefix=""
|
|
3561
|
+
else
|
|
3562
|
+
_dir="${_cur%/*}"
|
|
3563
|
+
_prefix="${_cur##*/}"
|
|
3564
|
+
fi
|
|
3565
|
+
for _f in "$_dir"/"$_prefix"*(N/); do
|
|
3566
|
+
_out="${_f#./}"
|
|
3567
|
+
__tailor_worker_add_path_candidate "$_out"
|
|
3568
|
+
done
|
|
3569
|
+
local _ext
|
|
3570
|
+
for _f in "$_dir"/"$_prefix"*(N.); do
|
|
3571
|
+
_out="${_f#./}"
|
|
3572
|
+
for _ext in "${_exts[@]}"; do
|
|
3573
|
+
[[ -n "$_ext" && "$_out" == *."$_ext" ]] && { __tailor_worker_add_path_candidate "$_out"; break; }
|
|
3574
|
+
done
|
|
3575
|
+
done
|
|
3576
|
+
return 0 ;;
|
|
3577
|
+
esac
|
|
3578
|
+
if __tailor_worker_opt_takes_value "tailordb:migration:resolve" "${words[CURRENT-1]}"; then return 0; fi
|
|
3579
|
+
if (( _after_dd )); then return 0; fi
|
|
3580
|
+
if [[ "${words[CURRENT]}" == -* ]]; then
|
|
3581
|
+
local -a _opts=()
|
|
3582
|
+
__tailor_worker_not_used "--workspace-id" "--workspaceId" "-w" "--w" && _opts+=("--workspace-id:Workspace ID")
|
|
3583
|
+
__tailor_worker_not_used "--profile" "-p" "--p" && _opts+=("--profile:Workspace profile")
|
|
3584
|
+
__tailor_worker_not_used "--config" "-c" "--c" && _opts+=("--config:Path to Tailor config file")
|
|
3585
|
+
__tailor_worker_not_used "--yes" "-y" "--y" && _opts+=("--yes:Skip confirmation prompts")
|
|
3586
|
+
__tailor_worker_not_used "--rollback" && _opts+=("--rollback:Return the namespace to the schema before the in-progress migration")
|
|
3587
|
+
__tailor_worker_not_used "--complete" && _opts+=("--complete:Apply the schema of the in-progress migration and mark it as completed")
|
|
3588
|
+
__tailor_worker_not_used "--namespace" "-n" "--n" && _opts+=("--namespace:Target TailorDB namespace (required if multiple namespaces exist)")
|
|
3589
|
+
if (( ! _any_opt_used )); then
|
|
3590
|
+
_opts+=("--help:Show help")
|
|
3591
|
+
_opts+=("--help-all:Show help with all subcommand options")
|
|
3592
|
+
_opts+=("--help-json:Show help as JSON")
|
|
3593
|
+
fi
|
|
3594
|
+
__tailor_worker_cdescribe 'options' _opts
|
|
3595
|
+
return 0
|
|
3596
|
+
fi
|
|
3597
|
+
}
|
|
3598
|
+
|
|
3543
3599
|
__tailor_worker_complete_tailordb_migration_script() {
|
|
3544
3600
|
local -a _vals=()
|
|
3545
3601
|
case "${words[CURRENT-1]}" in
|
|
@@ -3914,7 +3970,7 @@ __tailor_worker_complete_tailordb_migration() {
|
|
|
3914
3970
|
__tailor_worker_cdescribe 'options' _opts
|
|
3915
3971
|
return 0
|
|
3916
3972
|
fi
|
|
3917
|
-
local -a _subs=("generate:Generate migration files by detecting schema differences between current local tables and the previous migration snapshot." "rebaseline:Collapse the full migration history into a new 0000 baseline." "script:Add a migration script (migrate.ts) template to an existing migration directory, or record with --no-script that a migration intentionally has none." "set:Set migration checkpoint to a specific number." "status:Show the current migration status for TailorDB namespaces, including applied and pending migrations." "sync:Sync remote TailorDB schema to a specific migration snapshot (recovery from --no-schema-check drift)." "test:Test pending migrations with seed fixtures or cloned data in a temporary workspace." "validate:Validate the full migration history, unreviewed generated migration scripts, and schema drift (local tables vs. migration snapshot, remote schema vs. migration checkpoint) without deploying. This includes the migration and schema-drift checks used by 'deploy' and exits with a non-zero code when issues are found.")
|
|
3973
|
+
local -a _subs=("generate:Generate migration files by detecting schema differences between current local tables and the previous migration snapshot." "rebaseline:Collapse the full migration history into a new 0000 baseline." "resolve:Settle a migration that a failed deploy left partially applied." "script:Add a migration script (migrate.ts) template to an existing migration directory, or record with --no-script that a migration intentionally has none." "set:Set migration checkpoint to a specific number." "status:Show the current migration status for TailorDB namespaces, including applied and pending migrations." "sync:Sync remote TailorDB schema to a specific migration snapshot (recovery from --no-schema-check drift)." "test:Test pending migrations with seed fixtures or cloned data in a temporary workspace." "validate:Validate the full migration history, unreviewed generated migration scripts, and schema drift (local tables vs. migration snapshot, remote schema vs. migration checkpoint) without deploying. This includes the migration and schema-drift checks used by 'deploy' and exits with a non-zero code when issues are found.")
|
|
3918
3974
|
__tailor_worker_cdescribe 'subcommands' _subs
|
|
3919
3975
|
}
|
|
3920
3976
|
|
|
@@ -5127,6 +5183,7 @@ _tailor_worker_completions() {
|
|
|
5127
5183
|
tailordb:truncate) __tailor_worker_complete_tailordb_truncate ;;
|
|
5128
5184
|
tailordb:migration:generate) __tailor_worker_complete_tailordb_migration_generate ;;
|
|
5129
5185
|
tailordb:migration:rebaseline) __tailor_worker_complete_tailordb_migration_rebaseline ;;
|
|
5186
|
+
tailordb:migration:resolve) __tailor_worker_complete_tailordb_migration_resolve ;;
|
|
5130
5187
|
tailordb:migration:script) __tailor_worker_complete_tailordb_migration_script ;;
|
|
5131
5188
|
tailordb:migration:set) __tailor_worker_complete_tailordb_migration_set ;;
|
|
5132
5189
|
tailordb:migration:status) __tailor_worker_complete_tailordb_migration_status ;;
|
|
@@ -17,6 +17,44 @@ export type LogLevelInput = LogLevel | (string & {});
|
|
|
17
17
|
* referencing in a later version.
|
|
18
18
|
*/
|
|
19
19
|
export type AllowedRuntimeGlobals = Record<string, true | string[]>;
|
|
20
|
+
/**
|
|
21
|
+
* Switches that control how unused code is removed from bundled functions.
|
|
22
|
+
*
|
|
23
|
+
* Most of them ask whether something has side effects, so `true` keeps it and `false` lets
|
|
24
|
+
* it be removed when its result is unused. `annotations` is the exception: it asks whether
|
|
25
|
+
* to honor annotations, so `true` removes more. Each switch overrides the value the SDK
|
|
26
|
+
* uses by default.
|
|
27
|
+
*/
|
|
28
|
+
export interface TreeshakeOptions {
|
|
29
|
+
/**
|
|
30
|
+
* `true` assumes that importing a module may have effects beyond its exports, so the
|
|
31
|
+
* module is kept even when all of its exports are unused; `false` leaves such a module
|
|
32
|
+
* out of the bundle.
|
|
33
|
+
* @default false
|
|
34
|
+
*/
|
|
35
|
+
moduleSideEffects?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* `true` honors `@__PURE__` and `@__NO_SIDE_EFFECTS__` comment annotations when deciding
|
|
38
|
+
* whether a call can be removed; `false` ignores them.
|
|
39
|
+
* @default true
|
|
40
|
+
*/
|
|
41
|
+
annotations?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* `true` treats reading a global the bundle does not define as having an effect, so the
|
|
44
|
+
* read is kept even when its result is unused; `false` lets it be removed.
|
|
45
|
+
* @default false
|
|
46
|
+
*/
|
|
47
|
+
unknownGlobalSideEffects?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* `true` treats reading a property (`config.db.company`) as having an effect, so the
|
|
50
|
+
* read is kept even when its result is unused. `false` removes unused calls whose
|
|
51
|
+
* arguments only read properties, which keeps modules a function never reaches out of
|
|
52
|
+
* the bundle. It also removes a read that exists only for its effect, such as a getter
|
|
53
|
+
* with a side effect or a read that throws when the object is `undefined`.
|
|
54
|
+
* @default true
|
|
55
|
+
*/
|
|
56
|
+
propertyReadSideEffects?: boolean;
|
|
57
|
+
}
|
|
20
58
|
/** Options for how `defineConfig()` bundles functions. */
|
|
21
59
|
export interface BuildOptions {
|
|
22
60
|
/**
|
|
@@ -24,6 +62,18 @@ export interface BuildOptions {
|
|
|
24
62
|
* @default true
|
|
25
63
|
*/
|
|
26
64
|
inlineSourcemap?: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Embed the source text of installed packages (everything under `node_modules`) in
|
|
67
|
+
* the inline sourcemap. By default only your own source text is embedded, which
|
|
68
|
+
* makes bundled functions much smaller. Set `true` to embed all installed packages,
|
|
69
|
+
* or list package names (such as `["kysely", "@scope/lib"]`) to embed only those.
|
|
70
|
+
* A listed package's own dependencies are not embedded unless they are listed too. Error positions still resolve to the
|
|
71
|
+
* original files and lines; `tailor function run` shows a code snippet for a frame
|
|
72
|
+
* inside an installed package only when that package's file exists locally.
|
|
73
|
+
* Only applies when `inlineSourcemap` is enabled.
|
|
74
|
+
* @default false
|
|
75
|
+
*/
|
|
76
|
+
inlineSourcemapDependencySources?: boolean | string[];
|
|
27
77
|
/**
|
|
28
78
|
* Controls which `console.*` and `logger.*` (from `@tailor-platform/sdk/runtime`)
|
|
29
79
|
* calls remain in bundled functions. `logger.setAttributes` has no severity and
|
|
@@ -46,6 +96,13 @@ export interface BuildOptions {
|
|
|
46
96
|
* }
|
|
47
97
|
*/
|
|
48
98
|
allowedRuntimeGlobals?: AllowedRuntimeGlobals;
|
|
99
|
+
/**
|
|
100
|
+
* Overrides how unused code is removed from bundled functions. Unset switches keep the
|
|
101
|
+
* SDK's defaults.
|
|
102
|
+
* @example
|
|
103
|
+
* treeshake: { propertyReadSideEffects: false }
|
|
104
|
+
*/
|
|
105
|
+
treeshake?: TreeshakeOptions;
|
|
49
106
|
}
|
|
50
107
|
/** Value an `env` entry resolves to at runtime. */
|
|
51
108
|
export type EnvValue = string | number | boolean;
|