@tailor-platform/sdk 1.49.0 → 1.50.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 +28 -0
- package/README.md +1 -1
- package/dist/cli/index.mjs +92 -4
- package/dist/cli/index.mjs.map +1 -1
- package/dist/cli/lib.d.mts +1409 -1373
- package/dist/cli/lib.mjs +1 -1
- package/dist/cli/lib.mjs.map +1 -1
- package/dist/{runtime-oZgK353r.mjs → runtime-B2K6JW7V.mjs} +454 -156
- package/dist/runtime-B2K6JW7V.mjs.map +1 -0
- package/docs/cli/tailordb.md +50 -0
- package/docs/cli-reference.md +1 -0
- package/docs/services/tailordb-migration.md +49 -31
- package/package.json +3 -3
- package/dist/runtime-oZgK353r.mjs.map +0 -1
- /package/{skills → agent-skills}/tailor-sdk/SKILL.md +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# @tailor-platform/sdk
|
|
2
2
|
|
|
3
|
+
## 1.50.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#1223](https://github.com/tailor-platform/sdk/pull/1223) [`c2f078d`](https://github.com/tailor-platform/sdk/commit/c2f078d6fb82d42bcc8c040e020b34072a2d2eb6) Thanks [@toiroakr](https://github.com/toiroakr)! - Improve `tailordb migration` handling of data-loss-possible changes:
|
|
8
|
+
|
|
9
|
+
- Removed fields (`field_removed`) and removed types (`type_removed`) are now reported as **warnings** during `tailordb migration generate`, not silent changes. They are no longer dropped before `migrate.ts` runs: the field/type stays available during the Pre-migration phase so that scripts can read it (e.g. `innerJoin` through a foreign key that is being dropped in the same migration), then the physical drop happens in the Post-migration phase.
|
|
10
|
+
- Add `tailordb migration script <number>` subcommand to add a `migrate.ts` (and `db.ts`) template to an existing migration directory. Useful for warning-tier changes where you want a custom data migration even though one was not generated automatically.
|
|
11
|
+
- `migrate.ts` is now executed whenever the file exists on disk for a pending migration, regardless of whether the diff originally required a script. Breaking changes still hard-require a script as before.
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [#1194](https://github.com/tailor-platform/sdk/pull/1194) [`4c227cc`](https://github.com/tailor-platform/sdk/commit/4c227cc404e51331c0514b0aaa07d96d8940c347) Thanks [@toiroakr](https://github.com/toiroakr)! - Colocate `src/vitest/` tests next to their sources (drop the
|
|
16
|
+
`src/vitest/__tests__/` directory). Vitest discovers the test files
|
|
17
|
+
via the existing `**/?(*.)+(spec|test).ts` include pattern, so the
|
|
18
|
+
`**/__tests__/**/*.ts` entry has been removed from `vitest.config.ts`.
|
|
19
|
+
The nested integration runner moves from
|
|
20
|
+
`src/vitest/__tests__/integration/` to `src/vitest/integration/`. Pure
|
|
21
|
+
refactor: no public API or behavior changes.
|
|
22
|
+
|
|
23
|
+
- [#1207](https://github.com/tailor-platform/sdk/pull/1207) [`c0b392d`](https://github.com/tailor-platform/sdk/commit/c0b392d95f81bcb2a4bfd9e856183222da87ef06) Thanks [@toiroakr](https://github.com/toiroakr)! - Fix `tailor deploy` so an intermediate migration's data script can still read fields that a later migration removes. Each migration's pre/post phase now submits the schema state reconstructed up to that migration (initial baseline + diffs through N), instead of the FINAL post-all-migrations schema. Previously, removals declared in later migrations leaked into earlier migrations' pre-phase and caused `field 'X' not found` failures at script execution time.
|
|
24
|
+
|
|
25
|
+
- [#1208](https://github.com/tailor-platform/sdk/pull/1208) [`59d7e0e`](https://github.com/tailor-platform/sdk/commit/59d7e0e7c1b42dcd1571365780114d596e44350c) Thanks [@toiroakr](https://github.com/toiroakr)! - fix(skills): rename bundled skill directory to `agent-skills/` so `gh skill install tailor-platform/sdk` resolves a single skill. `gh skill` uses a recursive `**/skills/*/SKILL.md` match and was picking up both `skills/tailor-sdk/` (the public mirror) and `packages/sdk/skills/tailor-sdk/` (the npm bundle), erroring with conflicting names. The bundled copy is now under `packages/sdk/agent-skills/` (excluded from gh's match), while the repo-root `skills/` mirror remains the single discovery target for `gh skill install` and `npx skills add <repo>`. `npx tailor-sdk skills install` continues to work via the bundled `agent-skills/` path inside the published package.
|
|
26
|
+
|
|
27
|
+
- [#1217](https://github.com/tailor-platform/sdk/pull/1217) [`b827cf9`](https://github.com/tailor-platform/sdk/commit/b827cf95c0c048959c269f7ed9a31fdc81a5eb13) Thanks [@renovate](https://github.com/apps/renovate)! - fix(deps): update dependency @toiroakr/read-multiline to v0.4.1
|
|
28
|
+
|
|
29
|
+
- [#1184](https://github.com/tailor-platform/sdk/pull/1184) [`dee2ad7`](https://github.com/tailor-platform/sdk/commit/dee2ad7199b2da238b7e9edea2d9bb9605033456) Thanks [@toiroakr](https://github.com/toiroakr)! - Fix `tailor deploy` so decimal fields without an explicit `scale` no longer show spurious drift against the platform (which materializes the default `6`). Deploy now plans and applies through the same snapshot pipeline as `tailordb migrate`.
|
|
30
|
+
|
|
3
31
|
## 1.49.0
|
|
4
32
|
|
|
5
33
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -60,7 +60,7 @@ npx tailor-sdk skills install -a codex -y
|
|
|
60
60
|
```
|
|
61
61
|
|
|
62
62
|
This uses the `skills` CLI under the hood, sourcing the skill from
|
|
63
|
-
`node_modules/@tailor-platform/sdk/skills` so the skill version always matches
|
|
63
|
+
`node_modules/@tailor-platform/sdk/agent-skills` so the skill version always matches
|
|
64
64
|
the installed SDK version. Files are copied (not symlinked) so they survive
|
|
65
65
|
`pnpm install` wiping `node_modules`.
|
|
66
66
|
|
package/dist/cli/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { G as PATScope, R as AuthInvokerSchema, c as fetchUserInfo, d as initOperatorClient, h as userAgent, i as fetchAll, j as FunctionExecution_Type, n as closeConnectionPool, o as fetchPaged, s as fetchPlatformMachineUserToken, u as initOAuth2Client } from "../client-_kHh0Pip.mjs";
|
|
4
4
|
import { n as logger, r as styles } from "../logger-DTNAMYGy.mjs";
|
|
5
|
-
import { $ as
|
|
5
|
+
import { $ as listCommand$10, An as workspaceArgs, At as startCommand, B as logBetaWarning, C as listCommand$13, Cn as configArg, Dn as pagedLogArgs, Dt as jobsCommand, E as resumeCommand, En as isVerbose, F as writeDbTypesFile, Gt as parseMigrationLabelNumber, H as removeCommand$1, Ht as executeScript, I as getConfiguredEditorCommand, K as treeCommand, L as openInConfiguredEditor, Lt as functionExecutionStatusToString, Mt as getCommand$6, N as generateCommand$1, O as listCommand$12, On as paginationArgs, P as generateMigrationScript, Pt as executionsCommand, Rt as formatKeyValueTable, Sn as commonArgs, St as triggerCommand, T as healthCommand, Tn as deploymentArgs, U as updateCommand$3, Vt as deploy, Y as getCommand$5, Yt as INITIAL_SCHEMA_NUMBER, Z as updateCommand$2, _n as prompt, an as getMigrationFiles, at as createCommand$3, b as createCommand$4, bn as assertWritable, c as listCommand$14, cn as loadDiff, f as restoreCommand, ft as tokenCommand, g as getCommand$7, gt as listCommand$7, hn as trnPrefix, ht as generate, i as updateCommand$4, in as getMigrationFilePath, j as truncateCommand, kn as toPageDirection, ln as reconstructSnapshotFromMigrations, lt as getCommand$3, m as listCommand$15, mn as sdkNameLabelKey, o as removeCommand, pn as getNamespacesWithMigrations, pt as listCommand$8, q as listCommand$11, r as queryCommand, rt as deleteCommand$3, sn as isValidMigrationNumber, st as listCommand$9, t as isNativeTypeScriptRuntime, tn as formatMigrationNumber, tt as getCommand$4, u as inviteCommand, v as deleteCommand$4, vn as apiCommand, vt as getCommand$2, wn as confirmationArgs, wt as listCommand$6, xn as defineAppCommand, xt as webhookCommand, z as showCommand, zt as getCommand$1 } from "../runtime-B2K6JW7V.mjs";
|
|
6
6
|
import { D as saveUserTokens, E as resolveTokens, O as writePlatformConfig, S as loadAccessToken, T as readPlatformConfig, _ as getDistDir, a as WorkflowJobSchema, b as deleteUserTokens, c as ExecutorSchema, i as resolveInlineSourcemap, l as INVOKER_EXPR, o as ResolverSchema, w as loadWorkspaceId, x as fetchLatestToken, y as loadConfig } from "../application-CZMzt9jL.mjs";
|
|
7
7
|
import { t as multiline } from "../multiline-e3IpANmS.mjs";
|
|
8
8
|
import { t as readPackageJson } from "../package-json-6Px8bDpG.mjs";
|
|
@@ -25,6 +25,7 @@ import * as crypto from "node:crypto";
|
|
|
25
25
|
import * as http from "node:http";
|
|
26
26
|
import open from "open";
|
|
27
27
|
import * as rolldown from "rolldown";
|
|
28
|
+
import * as fsPromises from "node:fs/promises";
|
|
28
29
|
import { TraceMap, generatedPositionFor, originalPositionFor } from "@jridgewell/trace-mapping";
|
|
29
30
|
import { spawn, spawnSync } from "node:child_process";
|
|
30
31
|
import * as fs from "fs";
|
|
@@ -2716,7 +2717,7 @@ async function runSkillsInstaller(options) {
|
|
|
2716
2717
|
//#endregion
|
|
2717
2718
|
//#region src/cli/commands/skills/install.ts
|
|
2718
2719
|
async function resolveBundledSkillsDir() {
|
|
2719
|
-
return resolve(dirname(await resolvePackageJSON(import.meta.url)), "skills");
|
|
2720
|
+
return resolve(dirname(await resolvePackageJSON(import.meta.url)), "agent-skills");
|
|
2720
2721
|
}
|
|
2721
2722
|
const DEFAULT_AGENT = "claude-code";
|
|
2722
2723
|
const installCommand = defineAppCommand({
|
|
@@ -3571,6 +3572,91 @@ const erdCommand = defineCommand({
|
|
|
3571
3572
|
}
|
|
3572
3573
|
});
|
|
3573
3574
|
|
|
3575
|
+
//#endregion
|
|
3576
|
+
//#region src/cli/commands/tailordb/migrate/script.ts
|
|
3577
|
+
/**
|
|
3578
|
+
* Script command for TailorDB migrations
|
|
3579
|
+
*
|
|
3580
|
+
* Adds a `migrate.ts` (and supporting `db.ts`) template to an existing
|
|
3581
|
+
* migration directory. Useful for warning-tier changes where users may
|
|
3582
|
+
* want to write a custom data migration even though the change does not
|
|
3583
|
+
* automatically require one.
|
|
3584
|
+
*/
|
|
3585
|
+
/**
|
|
3586
|
+
* Add a migrate.ts template to an existing migration directory.
|
|
3587
|
+
* @param {ScriptOptions} options - Command options
|
|
3588
|
+
*/
|
|
3589
|
+
async function script(options) {
|
|
3590
|
+
logBetaWarning("tailordb migration");
|
|
3591
|
+
let migrationNumber;
|
|
3592
|
+
if (isValidMigrationNumber(options.number)) migrationNumber = parseInt(options.number, 10);
|
|
3593
|
+
else if (/^[1-9]\d*$/.test(options.number)) {
|
|
3594
|
+
migrationNumber = parseInt(options.number, 10);
|
|
3595
|
+
if (migrationNumber > 9999) throw new Error(`Migration number ${options.number} is out of range. Expected 1-9999.`);
|
|
3596
|
+
} else throw new Error(`Invalid migration number format: ${options.number}. Expected 4-digit format (e.g., 0001) or integer 1-9999 (e.g., 1).`);
|
|
3597
|
+
if (migrationNumber === 0) throw new Error(`Migration ${options.number} is the initial schema snapshot and cannot have a migration script.`);
|
|
3598
|
+
const { config } = await loadConfig(options.configPath);
|
|
3599
|
+
const namespacesWithMigrations = getNamespacesWithMigrations(config, path.dirname(config.path));
|
|
3600
|
+
if (namespacesWithMigrations.length === 0) throw new Error("No TailorDB services with migrations configuration found");
|
|
3601
|
+
const targetNamespace = resolveTargetNamespace(namespacesWithMigrations, options.namespace);
|
|
3602
|
+
const { migrationsDir } = namespacesWithMigrations.find((ns) => ns.namespace === targetNamespace);
|
|
3603
|
+
const diffPath = getMigrationFilePath(migrationsDir, migrationNumber, "diff");
|
|
3604
|
+
if (!fs$1.existsSync(diffPath)) throw new Error(`Migration ${options.number} not found in ${migrationsDir}. Expected ${diffPath}.`);
|
|
3605
|
+
const migratePath = getMigrationFilePath(migrationsDir, migrationNumber, "migrate");
|
|
3606
|
+
if (fs$1.existsSync(migratePath)) throw new Error(`Migration script already exists at ${migratePath}.`);
|
|
3607
|
+
const diff = loadDiff(diffPath);
|
|
3608
|
+
const previousSnapshot = reconstructSnapshotFromMigrations(migrationsDir, migrationNumber - 1);
|
|
3609
|
+
if (!previousSnapshot) throw new Error(`Could not reconstruct previous schema for migration ${options.number}. Make sure migration ${0} exists.`);
|
|
3610
|
+
const scriptContent = generateMigrationScript(diff);
|
|
3611
|
+
await fsPromises.writeFile(migratePath, scriptContent);
|
|
3612
|
+
await writeDbTypesFile(previousSnapshot, migrationsDir, migrationNumber, diff);
|
|
3613
|
+
logger.success(`Added migration script for migration ${styles.bold(options.number)} in namespace ${styles.bold(targetNamespace)}`);
|
|
3614
|
+
logger.info(` Migration script: ${migratePath}`);
|
|
3615
|
+
logger.info(` DB types: ${getMigrationFilePath(migrationsDir, migrationNumber, "db")}`);
|
|
3616
|
+
logger.newline();
|
|
3617
|
+
logger.log("Edit the script to implement your data migration logic.");
|
|
3618
|
+
logger.log("It will be executed by 'tailor-sdk deploy' between Pre and Post phases.");
|
|
3619
|
+
const editor = getConfiguredEditorCommand();
|
|
3620
|
+
if (!editor) return;
|
|
3621
|
+
logger.newline();
|
|
3622
|
+
logger.info(`Opening ${path.basename(migratePath)} in ${editor}...`);
|
|
3623
|
+
try {
|
|
3624
|
+
await openInConfiguredEditor(migratePath);
|
|
3625
|
+
} catch {
|
|
3626
|
+
return;
|
|
3627
|
+
}
|
|
3628
|
+
}
|
|
3629
|
+
function resolveTargetNamespace(namespacesWithMigrations, requested) {
|
|
3630
|
+
if (requested) {
|
|
3631
|
+
if (!namespacesWithMigrations.some((ns) => ns.namespace === requested)) throw new Error(`Namespace "${requested}" not found or does not have migrations configured`);
|
|
3632
|
+
return requested;
|
|
3633
|
+
}
|
|
3634
|
+
if (namespacesWithMigrations.length === 1) return namespacesWithMigrations[0].namespace;
|
|
3635
|
+
throw new Error(`Multiple TailorDB services found. Please specify namespace with --namespace flag: ${namespacesWithMigrations.map((ns) => ns.namespace).join(", ")}`);
|
|
3636
|
+
}
|
|
3637
|
+
const scriptCommand = defineAppCommand({
|
|
3638
|
+
name: "script",
|
|
3639
|
+
description: "Add a migration script (migrate.ts) template to an existing migration directory.",
|
|
3640
|
+
args: z.object({
|
|
3641
|
+
...configArg,
|
|
3642
|
+
number: arg(z.string(), {
|
|
3643
|
+
positional: true,
|
|
3644
|
+
description: "Migration number to add a script to (e.g., 0001 or 1)"
|
|
3645
|
+
}),
|
|
3646
|
+
namespace: arg(z.string().optional(), {
|
|
3647
|
+
alias: "n",
|
|
3648
|
+
description: "Target TailorDB namespace (required if multiple namespaces exist)"
|
|
3649
|
+
})
|
|
3650
|
+
}).strict(),
|
|
3651
|
+
run: async (args) => {
|
|
3652
|
+
await script({
|
|
3653
|
+
configPath: args.config,
|
|
3654
|
+
number: args.number,
|
|
3655
|
+
namespace: args.namespace
|
|
3656
|
+
});
|
|
3657
|
+
}
|
|
3658
|
+
});
|
|
3659
|
+
|
|
3574
3660
|
//#endregion
|
|
3575
3661
|
//#region src/cli/commands/tailordb/migrate/set.ts
|
|
3576
3662
|
/**
|
|
@@ -3750,14 +3836,16 @@ const statusCommand = defineAppCommand({
|
|
|
3750
3836
|
*
|
|
3751
3837
|
* Subcommands:
|
|
3752
3838
|
* - generate: Generate migration files from schema differences
|
|
3753
|
-
* -
|
|
3754
|
-
* -
|
|
3839
|
+
* - script: Add a migrate.ts template to an existing migration
|
|
3840
|
+
* - set: Set migration checkpoint to a specific number
|
|
3841
|
+
* - status: Show migration status for TailorDB namespaces
|
|
3755
3842
|
*/
|
|
3756
3843
|
const migrationCommand = defineCommand({
|
|
3757
3844
|
name: "migration",
|
|
3758
3845
|
description: "Manage TailorDB schema migrations.",
|
|
3759
3846
|
subCommands: {
|
|
3760
3847
|
generate: generateCommand$1,
|
|
3848
|
+
script: scriptCommand,
|
|
3761
3849
|
set: setCommand,
|
|
3762
3850
|
status: statusCommand
|
|
3763
3851
|
}
|