@tailor-platform/sdk 1.25.4 → 1.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/{application-DegTCDd8.mjs → application-CxH6Yp54.mjs} +1 -1
  3. package/dist/{application-91Th6tm6.mjs → application-D9xahQRQ.mjs} +2066 -1968
  4. package/dist/application-D9xahQRQ.mjs.map +1 -0
  5. package/dist/cli/index.mjs +152 -3
  6. package/dist/cli/index.mjs.map +1 -1
  7. package/dist/cli/lib.d.mts +350 -8
  8. package/dist/cli/lib.mjs +2 -2
  9. package/dist/configure/index.d.mts +5 -5
  10. package/dist/configure/index.mjs.map +1 -1
  11. package/dist/{env-uBeVwE9B.d.mts → env-CSsVESbH.d.mts} +2 -2
  12. package/dist/{index-Bu12qy3m.d.mts → index-BJg0DTbR.d.mts} +4 -4
  13. package/dist/{index-CT53egux.d.mts → index-BKy-OC5C.d.mts} +2 -2
  14. package/dist/{index-cZilKprY.d.mts → index-BtYPY8ya.d.mts} +2 -2
  15. package/dist/{index-BD-K97-C.d.mts → index-DgRShBpu.d.mts} +2 -2
  16. package/dist/{index-D1J5SfyK.d.mts → index-DkJbItB-.d.mts} +2 -2
  17. package/dist/plugin/builtin/enum-constants/index.d.mts +1 -1
  18. package/dist/plugin/builtin/file-utils/index.d.mts +1 -1
  19. package/dist/plugin/builtin/kysely-type/index.d.mts +1 -1
  20. package/dist/plugin/builtin/seed/index.d.mts +1 -1
  21. package/dist/plugin/index.d.mts +2 -2
  22. package/dist/{plugin-zY5wvV82.d.mts → plugin-B1hNwcCC.d.mts} +15 -3
  23. package/dist/{query-kb_4EQp4.mjs → query-B8ml6ClT.mjs} +454 -358
  24. package/dist/query-B8ml6ClT.mjs.map +1 -0
  25. package/dist/utils/test/index.d.mts +2 -2
  26. package/dist/{workflow.generated-v1LXRuB6.d.mts → workflow.generated-Bm4b8hEk.d.mts} +2 -2
  27. package/docs/cli/setup.md +82 -0
  28. package/docs/cli-reference.md +8 -0
  29. package/docs/services/auth.md +33 -0
  30. package/package.json +4 -4
  31. package/dist/application-91Th6tm6.mjs.map +0 -1
  32. package/dist/query-kb_4EQp4.mjs.map +0 -1
@@ -2,8 +2,8 @@
2
2
  import "../chunk-Cz-A8uMR.mjs";
3
3
  import "../schema-BePzTFBV.mjs";
4
4
  import "../brand-GZnI4eYb.mjs";
5
- import { C as fetchAll, D as initOperatorClient, E as initOAuth2Client, J as AuthInvokerSchema, S as writePlatformConfig, T as fetchUserInfo, U as FunctionExecution_Type, a as loadConfig, b as loadWorkspaceId, c as ExecutorSchema, ft as logger, g as getDistDir, i as resolveInlineSourcemap, o as WorkflowJobSchema, pt as styles, tt as PATScope, u as ResolverSchema, v as fetchLatestToken, x as readPlatformConfig, y as loadAccessToken } from "../application-91Th6tm6.mjs";
6
- import { C as listCommand$9, E as resumeCommand, Ft as isValidMigrationNumber, G as listCommand$6, Ht as prompt, I as showCommand, It as loadDiff, Jt as commonArgs, Kt as apiCommand, Mt as getMigrationFilePath, N as generateCommand$1, Nt as getMigrationFiles, O as listCommand$8, P as logBetaWarning, Q as listCommand$5, Qt as workspaceArgs, R as removeCommand$1, T as healthCommand, Ut as trnPrefix, V as getCommand$2, Vt as getNamespacesWithMigrations, W as tokenCommand, X as triggerCommand, Xt as deploymentArgs, Y as webhookCommand, Yt as confirmationArgs, Zt as isVerbose, b as createCommand$3, c as listCommand$10, ct as executionsCommand, dt as functionExecutionStatusToString, f as restoreCommand, ft as formatKeyValueTable, g as getCommand$4, gt as executeScript, ht as apply, i as updateCommand$2, it as startCommand, j as truncateCommand, kt as formatMigrationNumber, m as listCommand$11, n as queryCommand, o as removeCommand, ot as getCommand$3, pt as getCommand$1, q as generate, qt as defineAppCommand, r as isCLIError, tt as jobsCommand, u as inviteCommand, v as deleteCommand$3, yt as parseMigrationLabelNumber, z as listCommand$7 } from "../query-kb_4EQp4.mjs";
5
+ import { C as fetchAll, D as initOperatorClient, E as initOAuth2Client, S as writePlatformConfig, T as fetchUserInfo, U as FunctionExecution_Type, Y as AuthInvokerSchema, a as loadConfig, b as loadWorkspaceId, c as ExecutorSchema, g as getDistDir, i as resolveInlineSourcemap, mt as styles, nt as PATScope, o as WorkflowJobSchema, pt as logger, u as ResolverSchema, v as fetchLatestToken, x as readPlatformConfig, y as loadAccessToken } from "../application-D9xahQRQ.mjs";
6
+ import { C as listCommand$9, E as resumeCommand, F as showCommand, Ft as isValidMigrationNumber, G as listCommand$6, Ht as prompt, I as logBetaWarning, It as loadDiff, Jt as commonArgs, Kt as apiCommand, Mt as getMigrationFilePath, N as generateCommand$1, Nt as getMigrationFiles, O as listCommand$8, Q as listCommand$5, Qt as workspaceArgs, R as removeCommand$1, T as healthCommand, Ut as trnPrefix, V as getCommand$2, Vt as getNamespacesWithMigrations, W as tokenCommand, X as triggerCommand, Xt as deploymentArgs, Y as webhookCommand, Yt as confirmationArgs, Zt as isVerbose, b as createCommand$3, c as listCommand$10, ct as executionsCommand, dt as functionExecutionStatusToString, f as restoreCommand, ft as formatKeyValueTable, g as getCommand$4, gt as executeScript, ht as apply, i as updateCommand$2, it as startCommand, j as truncateCommand, kt as formatMigrationNumber, m as listCommand$11, n as queryCommand, o as removeCommand, ot as getCommand$3, pt as getCommand$1, q as generate, qt as defineAppCommand, r as isCLIError, tt as jobsCommand, u as inviteCommand, v as deleteCommand$3, yt as parseMigrationLabelNumber, z as listCommand$7 } from "../query-B8ml6ClT.mjs";
7
7
  import { t as readPackageJson } from "../package-json-CVUv8Y9T.mjs";
8
8
  import "../seed-CCVRLibh.mjs";
9
9
  import "../file-utils-2T9w20FP.mjs";
@@ -21,8 +21,8 @@ import { Code, ConnectError } from "@connectrpc/connect";
21
21
  import { resolveTSConfig } from "pkg-types";
22
22
  import ml from "multiline-ts";
23
23
  import * as crypto from "node:crypto";
24
- import { pathToFileURL } from "node:url";
25
24
  import * as rolldown from "rolldown";
25
+ import { pathToFileURL } from "node:url";
26
26
  import { create } from "@bufbuild/protobuf";
27
27
  import { spawn, spawnSync } from "node:child_process";
28
28
  import * as http from "node:http";
@@ -1424,6 +1424,154 @@ const secretCommand = defineCommand({
1424
1424
  }
1425
1425
  });
1426
1426
 
1427
+ //#endregion
1428
+ //#region src/cli/commands/setup/github/fetch-tailor-token.action.yml
1429
+ var fetch_tailor_token_action_default = "name: Fetch Tailor Platform Token\ndescription: Fetch an OAuth2 access token via client credentials grant and export as TAILOR_PLATFORM_TOKEN\n\ninputs:\n client_id:\n description: OAuth2 client ID\n required: true\n client_secret:\n description: OAuth2 client secret\n required: true\n platform_oauth2_url:\n description: OAuth2 token endpoint URL\n required: false\n default: https://api.tailor.tech/oauth2/platform/token\n\nruns:\n using: composite\n steps:\n - name: Fetch access token\n shell: bash\n run: |\n RESPONSE=$(curl -s -X POST \"${{ inputs.platform_oauth2_url }}\" \\\n -H \"Content-Type: application/x-www-form-urlencoded\" \\\n -d \"grant_type=client_credentials\" \\\n --data-urlencode \"client_id=${{ inputs.client_id }}\" \\\n --data-urlencode \"client_secret=${{ inputs.client_secret }}\")\n\n TOKEN=$(echo \"$RESPONSE\" | jq -r '.access_token')\n\n if [ \"$TOKEN\" = \"null\" ] || [ -z \"$TOKEN\" ]; then\n echo \"::error::Failed to fetch access token\"\n echo \"$RESPONSE\" | jq .\n exit 1\n fi\n\n echo \"::add-mask::$TOKEN\"\n echo \"TAILOR_PLATFORM_TOKEN=$TOKEN\" >> \"$GITHUB_ENV\"\n";
1430
+
1431
+ //#endregion
1432
+ //#region src/cli/commands/setup/github/install-node.action.yml
1433
+ var install_node_action_default = "name: Install Node.js\ndescription: Install pnpm, Node.js, and project dependencies\n\nruns:\n using: composite\n steps:\n - name: Install pnpm\n uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0\n with:\n version: 10\n\n - name: Setup Node.js\n uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0\n with:\n node-version: 22\n cache: pnpm\n\n - name: Install dependencies\n run: pnpm install --frozen-lockfile\n shell: bash\n";
1434
+
1435
+ //#endregion
1436
+ //#region src/cli/commands/setup/github/deploy.workflow.yml
1437
+ var deploy_workflow_default = "name: Deploy\n\non:\n push:\n branches:\n - main\n workflow_dispatch:\n\nconcurrency:\n group: deploy-__WORKSPACE_NAME__\n cancel-in-progress: false\n\nenv:\n WORKSPACE_NAME: __WORKSPACE_NAME__\n WORKSPACE_REGION: __WORKSPACE_REGION__\n TAILOR_PLATFORM_ORGANIZATION_ID: __ORGANIZATION_ID__\n TAILOR_PLATFORM_FOLDER_ID: __FOLDER_ID__\n# __DEFAULTS_BLOCK__\njobs:\n deploy:\n runs-on: ubuntu-latest\n steps:\n - name: Checkout\n uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2\n with:\n persist-credentials: false\n\n - name: Install Node.js\n uses: ./.github/actions/install-node\n\n - name: Fetch Tailor Platform token\n uses: ./.github/actions/fetch-tailor-token\n with:\n client_id: ${{ secrets.PLATFORM_MACHINE_USER_CLIENT_ID }}\n client_secret: ${{ secrets.PLATFORM_MACHINE_USER_CLIENT_SECRET }}\n\n - name: Ensure workspace exists\n run: |\n WORKSPACE_ID=$(pnpm tailor-sdk workspace list -j | jq -r --arg name \"$WORKSPACE_NAME\" --arg region \"$WORKSPACE_REGION\" '.[] | select(.name == $name and .region == $region) | .id')\n\n if [ -z \"$WORKSPACE_ID\" ]; then\n echo \"Workspace '$WORKSPACE_NAME' not found, creating...\"\n WORKSPACE_ID=$(pnpm tailor-sdk workspace create -j --name \"$WORKSPACE_NAME\" --region \"$WORKSPACE_REGION\" --organization-id \"$TAILOR_PLATFORM_ORGANIZATION_ID\" --folder-id \"$TAILOR_PLATFORM_FOLDER_ID\" | jq -r '.id')\n echo \"Created workspace: $WORKSPACE_ID\"\n else\n echo \"Found existing workspace: $WORKSPACE_ID\"\n fi\n\n echo \"TAILOR_PLATFORM_WORKSPACE_ID=$WORKSPACE_ID\" >> \"$GITHUB_ENV\"\n\n - name: Generate types\n run: pnpm generate\n\n - name: Deploy\n # Runs the \"deploy\" script from package.json (tailor-sdk apply --yes)\n run: pnpm run deploy -- --yes\n\n - name: Show application info\n run: pnpm tailor-sdk show -j -w \"$TAILOR_PLATFORM_WORKSPACE_ID\"\n";
1438
+
1439
+ //#endregion
1440
+ //#region src/cli/commands/setup/github/template-deploy.ts
1441
+ /**
1442
+ * Render the deploy workflow YAML.
1443
+ *
1444
+ * Targets single-application scaffolds (those with `generate` and `deploy` scripts).
1445
+ * Multi-application projects (e.g. chained `deploy:*` scripts) need manual workflow customization.
1446
+ * @param params - Workspace and deployment configuration
1447
+ * @returns Workflow YAML content
1448
+ */
1449
+ function renderDeploy(params) {
1450
+ const { workspaceName, workspaceRegion, organizationId, folderId, workingDirectory } = params;
1451
+ const defaultsBlock = workingDirectory ? `\ndefaults:\n run:\n working-directory: ${workingDirectory}\n` : "";
1452
+ return deploy_workflow_default.replaceAll("__WORKSPACE_NAME__", () => workspaceName).replace("__WORKSPACE_REGION__", () => workspaceRegion).replace("__ORGANIZATION_ID__", () => organizationId).replace("__FOLDER_ID__", () => folderId).replace("# __DEFAULTS_BLOCK__\n", () => defaultsBlock);
1453
+ }
1454
+
1455
+ //#endregion
1456
+ //#region src/cli/commands/setup/github/github.ts
1457
+ /**
1458
+ * Build the list of GitHub Actions files to generate.
1459
+ * @param options - Setup options including workspace config and output directory
1460
+ * @returns Array of files with paths and rendered content
1461
+ */
1462
+ function buildFiles(options) {
1463
+ const githubDir = path.join(options.outputDir, ".github");
1464
+ return [
1465
+ {
1466
+ path: path.join(githubDir, "actions/fetch-tailor-token/action.yml"),
1467
+ content: fetch_tailor_token_action_default
1468
+ },
1469
+ {
1470
+ path: path.join(githubDir, "actions/install-node/action.yml"),
1471
+ content: install_node_action_default
1472
+ },
1473
+ {
1474
+ path: path.join(githubDir, `workflows/deploy-${options.workspaceName}.yml`),
1475
+ content: renderDeploy({
1476
+ workspaceName: options.workspaceName,
1477
+ workspaceRegion: options.workspaceRegion,
1478
+ organizationId: options.organizationId,
1479
+ folderId: options.folderId,
1480
+ workingDirectory: options.dir !== "." ? options.dir : void 0
1481
+ })
1482
+ }
1483
+ ];
1484
+ }
1485
+ /**
1486
+ * Write files to disk, skipping any that already exist.
1487
+ * @param files - Files to write
1488
+ * @returns Result with lists of written and skipped file paths
1489
+ */
1490
+ function writeFiles(files) {
1491
+ const written = [];
1492
+ const skipped = [];
1493
+ for (const file of files) {
1494
+ if (fs$1.existsSync(file.path)) {
1495
+ skipped.push(file.path);
1496
+ continue;
1497
+ }
1498
+ fs$1.mkdirSync(path.dirname(file.path), { recursive: true });
1499
+ fs$1.writeFileSync(file.path, file.content);
1500
+ written.push(file.path);
1501
+ }
1502
+ return {
1503
+ written,
1504
+ skipped
1505
+ };
1506
+ }
1507
+ /**
1508
+ * Generate GitHub Actions workflow files and print next steps.
1509
+ * @param options - Setup options including workspace config and output directory
1510
+ */
1511
+ function setupGitHub(options) {
1512
+ logBetaWarning("setup github");
1513
+ const result = writeFiles(buildFiles(options));
1514
+ for (const filePath of result.written) {
1515
+ const relativePath = path.relative(options.outputDir, filePath);
1516
+ logger.success(`Generated ${styles.path(relativePath)}`);
1517
+ }
1518
+ for (const filePath of result.skipped) {
1519
+ const relativePath = path.relative(options.outputDir, filePath);
1520
+ logger.warn(`Skipped ${styles.path(relativePath)} (already exists)`);
1521
+ }
1522
+ logger.newline();
1523
+ logger.info("Next steps - set GitHub secrets:");
1524
+ logger.log(` gh secret set PLATFORM_MACHINE_USER_CLIENT_ID`);
1525
+ logger.log(` gh secret set PLATFORM_MACHINE_USER_CLIENT_SECRET`);
1526
+ }
1527
+
1528
+ //#endregion
1529
+ //#region src/cli/commands/setup/github/index.ts
1530
+ const githubCommand = defineAppCommand({
1531
+ name: "github",
1532
+ description: "Generate GitHub Actions workflow for deployment. (beta)",
1533
+ args: z.object({
1534
+ "workspace-name": arg(z.string(), {
1535
+ alias: "n",
1536
+ description: "Workspace name"
1537
+ }),
1538
+ "workspace-region": arg(z.string(), {
1539
+ alias: "r",
1540
+ description: "Workspace region"
1541
+ }),
1542
+ "organization-id": arg(z.string(), {
1543
+ alias: "o",
1544
+ description: "Organization ID"
1545
+ }),
1546
+ "folder-id": arg(z.string(), {
1547
+ alias: "f",
1548
+ description: "Folder ID"
1549
+ }),
1550
+ dir: arg(z.string().default("."), {
1551
+ alias: "d",
1552
+ description: "App directory (for monorepo setups)"
1553
+ })
1554
+ }).strict(),
1555
+ run: (args) => {
1556
+ setupGitHub({
1557
+ workspaceName: args["workspace-name"],
1558
+ workspaceRegion: args["workspace-region"],
1559
+ organizationId: args["organization-id"],
1560
+ folderId: args["folder-id"],
1561
+ dir: args.dir,
1562
+ outputDir: process.cwd()
1563
+ });
1564
+ }
1565
+ });
1566
+
1567
+ //#endregion
1568
+ //#region src/cli/commands/setup/index.ts
1569
+ const setupCommand = defineCommand({
1570
+ name: "setup",
1571
+ description: "Set up project infrastructure.",
1572
+ subCommands: { github: githubCommand }
1573
+ });
1574
+
1427
1575
  //#endregion
1428
1576
  //#region src/cli/shared/progress.ts
1429
1577
  /**
@@ -2809,6 +2957,7 @@ const mainCommand = withCompletionCommand(defineCommand({
2809
2957
  query: queryCommand,
2810
2958
  remove: removeCommand$1,
2811
2959
  secret: secretCommand,
2960
+ setup: setupCommand,
2812
2961
  show: showCommand,
2813
2962
  staticwebsite: staticwebsiteCommand,
2814
2963
  tailordb: tailordbCommand,