@tailor-platform/sdk 1.74.0 → 1.74.1

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 (55) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/{application-DwmoI6ZQ.mjs → application-BsH6tkZC.mjs} +43 -5
  3. package/dist/application-BsH6tkZC.mjs.map +1 -0
  4. package/dist/application-CSUhZMb5.mjs +3 -0
  5. package/dist/cli/commands/tailordb/migrate/snapshot.d.mts +1 -16
  6. package/dist/cli/index.mjs +22 -33
  7. package/dist/cli/index.mjs.map +1 -1
  8. package/dist/cli/lib.d.mts +2 -2
  9. package/dist/cli/lib.mjs +3 -3
  10. package/dist/cli/lib.mjs.map +1 -1
  11. package/dist/completion/zsh-worker.zsh +1 -1
  12. package/dist/configure/index.mjs +2 -2
  13. package/dist/configure/services/tailordb/schema.d.mts +5 -19
  14. package/dist/configure/types/field-runtime.d.mts +17 -0
  15. package/dist/configure/types/type.d.mts +1 -18
  16. package/dist/field-runtime-9bfXBAOK.mjs +183 -0
  17. package/dist/field-runtime-9bfXBAOK.mjs.map +1 -0
  18. package/dist/plugin/builtin/seed/index.mjs +1 -1
  19. package/dist/{runtime-Zkg3SUwi.mjs → runtime-DV1EnfMs.mjs} +229 -394
  20. package/dist/runtime-DV1EnfMs.mjs.map +1 -0
  21. package/dist/{schema-DAdZSFOd.mjs → schema-Dl_y0m9e.mjs} +8 -167
  22. package/dist/schema-Dl_y0m9e.mjs.map +1 -0
  23. package/dist/secretmanager-Bd45j7an.mjs +98 -0
  24. package/dist/secretmanager-Bd45j7an.mjs.map +1 -0
  25. package/dist/{seed-DoMTMLcm.mjs → seed-fm0LeYP2.mjs} +14 -3
  26. package/dist/seed-fm0LeYP2.mjs.map +1 -0
  27. package/dist/types-BwzB2okW.mjs +199 -0
  28. package/dist/types-BwzB2okW.mjs.map +1 -0
  29. package/dist/types-KlawuVKa.mjs +4 -0
  30. package/dist/vitest/index.d.mts +8 -1
  31. package/dist/vitest/index.mjs +776 -1
  32. package/dist/vitest/index.mjs.map +1 -1
  33. package/dist/vitest/mock.d.mts +8 -363
  34. package/dist/vitest/mocks/aigateway.d.mts +30 -0
  35. package/dist/vitest/mocks/authconnection.d.mts +28 -0
  36. package/dist/vitest/mocks/file.d.mts +41 -0
  37. package/dist/vitest/mocks/iconv.d.mts +27 -0
  38. package/dist/vitest/mocks/idp.d.mts +44 -0
  39. package/dist/vitest/mocks/secretmanager.d.mts +33 -0
  40. package/dist/vitest/mocks/tailordb.d.mts +71 -0
  41. package/dist/vitest/mocks/workflow.d.mts +115 -0
  42. package/dist/vitest/setup.mjs +1 -1
  43. package/package.json +8 -8
  44. package/dist/application-BndtMTFY.mjs +0 -3
  45. package/dist/application-DwmoI6ZQ.mjs.map +0 -1
  46. package/dist/field-DOsJCPFa.mjs +0 -22
  47. package/dist/field-DOsJCPFa.mjs.map +0 -1
  48. package/dist/mock-Ce1GCi4-.mjs +0 -871
  49. package/dist/mock-Ce1GCi4-.mjs.map +0 -1
  50. package/dist/runtime-Zkg3SUwi.mjs.map +0 -1
  51. package/dist/schema-DAdZSFOd.mjs.map +0 -1
  52. package/dist/seed-DoMTMLcm.mjs.map +0 -1
  53. package/dist/types-qhFZ8y9B.mjs +0 -4
  54. package/dist/types-ywCGpzDZ.mjs +0 -360
  55. package/dist/types-ywCGpzDZ.mjs.map +0 -1
@@ -0,0 +1,3 @@
1
+ import { n as generatePluginFilesIfNeeded, r as loadApplication, t as defineApplication } from "./application-BsH6tkZC.mjs";
2
+
3
+ export { defineApplication, generatePluginFilesIfNeeded };
@@ -21,21 +21,6 @@ declare const DB_TYPES_FILE_NAME = "db.ts";
21
21
  * Migration file type
22
22
  */
23
23
  type MigrationFileType = "schema" | "diff" | "migrate" | "db";
24
- /**
25
- * Information about a migration
26
- */
27
- interface MigrationInfo {
28
- /** Migration number (e.g., 1, 2, 3) */
29
- number: number;
30
- /** Migration number as 4-digit string (e.g., "0001", "0002") */
31
- numberStr: string;
32
- /** Migration file type */
33
- type: MigrationFileType;
34
- /** Path to migration file */
35
- path: string;
36
- /** Parsed content (schema snapshot or diff) */
37
- content: SchemaSnapshot | MigrationDiff;
38
- }
39
24
  /**
40
25
  * Get migration directory path for a given number
41
26
  * @param {string} migrationsDir - Base migrations directory path
@@ -110,4 +95,4 @@ declare function compareSnapshots(previous: SchemaSnapshot, current: SchemaSnaps
110
95
  */
111
96
  declare function compareLocalTypesWithSnapshot(snapshot: SchemaSnapshot, localTypes: Record<string, TailorDBSnapshotType>, namespace: string): MigrationDiff;
112
97
  //#endregion
113
- export { DB_TYPES_FILE_NAME, DIFF_FILE_NAME, INITIAL_SCHEMA_NUMBER, MIGRATE_FILE_NAME, MigrationFileType, MigrationInfo, type NormalizedSchemaSnapshot, SCHEMA_FILE_NAME, type SchemaSnapshot, type SnapshotFieldConfig, type TailorDBSnapshotType, compareLocalTypesWithSnapshot, compareSnapshots, createSnapshotFromLocalTypes, getLatestMigrationNumber, getMigrationDirPath, getMigrationFilePath, getMigrationFiles, getNextMigrationNumber, reconstructSnapshotFromMigrations };
98
+ export { DB_TYPES_FILE_NAME, DIFF_FILE_NAME, INITIAL_SCHEMA_NUMBER, MIGRATE_FILE_NAME, MigrationFileType, type NormalizedSchemaSnapshot, SCHEMA_FILE_NAME, type SchemaSnapshot, type SnapshotFieldConfig, type TailorDBSnapshotType, compareLocalTypesWithSnapshot, compareSnapshots, createSnapshotFromLocalTypes, getLatestMigrationNumber, getMigrationDirPath, getMigrationFilePath, getMigrationFiles, getNextMigrationNumber, reconstructSnapshotFromMigrations };
@@ -2,11 +2,11 @@
2
2
  import { C as CustomDomainStatus, R as FunctionExecution_Type, mt as AuthInvokerSchema, xt as PATScope } from "../service_pb-CIrhGwHk.mjs";
3
3
  import { t as assertDefined } from "../assert-DBxo8jPo.mjs";
4
4
  import { n as logger, r as styles } from "../logger-BEiZZ3qT.mjs";
5
- import { $t as compareSnapshotWithRemote, A as listCommand$12, An as apiCommand, Bn as pagedLogArgs, C as listCommand$13, Cn as hasChanges, Dn as PluginManager, Dt as listCommand$6, E as waitCommand, En as sdkNameLabelKey, F as generateCommand$1, Fn as configArg, G as removeCommand$1, Gt as deploy, H as extractOwnedNamespaces, Hn as toPageDirection, Ht as formatKeyValueTable, I as generateMigrationScript, In as confirmationArgs, It as getCommand$6, K as updateCommand$3, Kt as ensureConfigId, L as writeDbTypesFile, Ln as deploymentArgs, Mn as assertWritable, N as truncateCommand, Nn as defineAppCommand, O as resumeCommand, On as generateUserTypes, Pn as commonArgs, Pt as startCommand, Q as getCommand$5, Qt as parseMigrationLabelNumber, R as getConfiguredEditorCommand, Rn as isVerbose, Rt as executionsCommand, Sn as formatMigrationDiff, T as healthCommand, Tn as resourceTrn, Tt as triggerCommand, U as logBetaWarning, Un as workspaceArgs, Ut as getCommand$1, V as showCommand, Vn as paginationArgs, Vt as functionExecutionStatusToString, X as listCommand$11, Xt as MIGRATION_LABEL_KEY, Y as treeCommand, Zt as handleOptionalToRequiredError, _n as loadDiff, b as createCommand$4, bn as parseMigrationNumberArg, c as listCommand$14, cn as compareLocalTypesWithSnapshot, ct as createCommand$3, dn as getLatestMigrationNumber, en as generateAllTypeManifestsFromSnapshot, et as updateCommand$2, f as restoreCommand, ft as getCommand$3, g as getCommand$7, gn as isValidMigrationNumber, gt as listCommand$8, ht as tokenCommand, i as updateCommand$4, in as INITIAL_SCHEMA_NUMBER, it as getCommand$4, jt as jobsCommand, kn as prompt, m as listCommand$15, mn as getMigrationFiles, nt as listCommand$10, o as removeCommand, ot as deleteCommand$4, pn as getMigrationFilePath, qt as executeScript, r as queryCommand, sn as assertValidMigrationFiles, t as isNativeTypeScriptRuntime, tn as protoGqlPermission, u as inviteCommand, un as createSnapshotFromLocalTypes, ut as listCommand$9, v as deleteCommand$5, vn as reconstructSnapshotFromMigrations, vt as generate, wn as getNamespacesWithMigrations, wt as webhookCommand, xt as getCommand$2, yn as formatMigrationNumber, yt as listCommand$7, z as openInConfiguredEditor, zn as multiConfigArg } from "../runtime-Zkg3SUwi.mjs";
6
- import { $ as initOAuth2Client, A as hasUserTokenEntry, B as resolveUserTokenKey, C as getDistDir, D as deleteUserTokens, E as loadConfig, G as fetchAll, H as writePlatformConfig, I as loadStoredUserTokens, J as fetchPlatformMachineUserToken, L as loadWorkspaceId, N as loadConsoleBaseUrl, O as fetchLatestToken, P as loadMachineUserName, R as platformConfigFromProfile, U as closeConnectionPool, V as saveUserTokens, W as defaultPlatformBaseUrl, Y as fetchUserInfo, _ as composeFunctionTreeshakeOptions, a as resolveInlineSourcemap, et as initOperatorClient, g as platformBundleDefinePlugin, j as loadAccessToken, k as hasAnyUserTokenEntry, l as INVOKER_EXPR, o as WorkflowJobSchema, q as fetchPaged, s as ResolverSchema, t as defineApplication, tt as isDefaultPlatform, v as createLogLevelTreeshakeOptions, w as hashContent$1, y as resolveBundleLogLevel, z as readPlatformConfig } from "../application-DwmoI6ZQ.mjs";
5
+ import { $t as compareSnapshotWithRemote, A as listCommand$12, An as apiCommand, Bn as pagedLogArgs, C as listCommand$13, Cn as hasChanges, Dn as PluginManager, Dt as listCommand$6, E as waitCommand, En as sdkNameLabelKey, F as generateCommand$1, Fn as configArg, G as removeCommand$1, Gt as deploy, H as extractOwnedNamespaces, Hn as toPageDirection, Ht as formatKeyValueTable, I as generateMigrationScript, In as confirmationArgs, It as getCommand$6, K as updateCommand$3, Kt as ensureConfigId, L as writeDbTypesFile, Ln as deploymentArgs, Mn as assertWritable, N as truncateCommand, Nn as defineAppCommand, O as resumeCommand, On as generateUserTypes, Pn as commonArgs, Pt as startCommand, Q as getCommand$5, Qt as parseMigrationLabelNumber, R as getConfiguredEditorCommand, Rn as isVerbose, Rt as executionsCommand, Sn as formatMigrationDiff, T as healthCommand, Tn as resourceTrn, Tt as triggerCommand, U as logBetaWarning, Un as workspaceArgs, Ut as getCommand$1, V as showCommand, Vn as paginationArgs, Vt as functionExecutionStatusToString, X as listCommand$11, Xt as MIGRATION_LABEL_KEY, Y as treeCommand, Zt as handleOptionalToRequiredError, _n as loadDiff, b as createCommand$4, bn as parseMigrationNumberArg, c as listCommand$14, cn as compareLocalTypesWithSnapshot, ct as createCommand$3, dn as getLatestMigrationNumber, en as generateAllTypeManifestsFromSnapshot, et as updateCommand$2, f as restoreCommand, ft as getCommand$3, g as getCommand$7, gn as isValidMigrationNumber, gt as listCommand$8, ht as tokenCommand, i as updateCommand$4, in as INITIAL_SCHEMA_NUMBER, it as getCommand$4, jt as jobsCommand, kn as prompt, m as listCommand$15, mn as getMigrationFiles, nt as listCommand$10, o as removeCommand, ot as deleteCommand$4, pn as getMigrationFilePath, qt as executeScript, r as queryCommand, sn as assertValidMigrationFiles, t as isNativeTypeScriptRuntime, tn as protoGqlPermission, u as inviteCommand, un as createSnapshotFromLocalTypes, ut as listCommand$9, v as deleteCommand$5, vn as reconstructSnapshotFromMigrations, vt as generate, wn as getNamespacesWithMigrations, wt as webhookCommand, xt as getCommand$2, yn as formatMigrationNumber, yt as listCommand$7, z as openInConfiguredEditor, zn as multiConfigArg } from "../runtime-DV1EnfMs.mjs";
6
+ import { $ as getOrNull, A as hasUserTokenEntry, B as resolveUserTokenKey, C as getDistDir, D as deleteUserTokens, E as loadConfig, G as fetchAll, H as writePlatformConfig, I as loadStoredUserTokens, J as fetchPaged, K as fetchAllTolerant, L as loadWorkspaceId, N as loadConsoleBaseUrl, O as fetchLatestToken, P as loadMachineUserName, R as platformConfigFromProfile, U as closeConnectionPool, V as saveUserTokens, W as defaultPlatformBaseUrl, X as fetchUserInfo, Y as fetchPlatformMachineUserToken, _ as composeFunctionTreeshakeOptions, a as resolveInlineSourcemap, g as platformBundleDefinePlugin, j as loadAccessToken, k as hasAnyUserTokenEntry, l as INVOKER_EXPR, nt as initOperatorClient, o as WorkflowJobSchema, rt as isDefaultPlatform, s as ResolverSchema, t as defineApplication, tt as initOAuth2Client, v as createLogLevelTreeshakeOptions, w as hashContent$1, y as resolveBundleLogLevel, z as readPlatformConfig } from "../application-BsH6tkZC.mjs";
7
7
  import { n as ExecutorSchema } from "../service-BCRJ-3NV.mjs";
8
8
  import { t as multiline } from "../multiline-sfHpTZZK.mjs";
9
- import { r as isPluginGeneratedType } from "../seed-DoMTMLcm.mjs";
9
+ import { r as isPluginGeneratedType } from "../seed-fm0LeYP2.mjs";
10
10
  import { t as readPackageJson } from "../package-json-8b0O9TlX.mjs";
11
11
  import { i as userAgent } from "../secret-file-VSVGy1V0.mjs";
12
12
  import { n as isCLIError } from "../errors-Dtf2WPaW.mjs";
@@ -1288,7 +1288,7 @@ async function detectFunctionType(options) {
1288
1288
  const rawInput = module.default.input;
1289
1289
  let inputSchema;
1290
1290
  if (rawInput) {
1291
- const { t } = await import("../types-qhFZ8y9B.mjs");
1291
+ const { t } = await import("../types-KlawuVKa.mjs");
1292
1292
  inputSchema = t.object(rawInput);
1293
1293
  }
1294
1294
  return {
@@ -4852,7 +4852,7 @@ function buildViewerHtml(options) {
4852
4852
  const currentSchemaScript = options.currentSchema === void 0 ? "" : `\n <script type="application/json" id="erd-current-schema">${JSON.stringify(options.currentSchema).replaceAll("<", "\\u003c")}<\/script>`;
4853
4853
  const diffScript = options.diff === void 0 ? "" : `\n <script type="application/json" id="erd-diff">${JSON.stringify(options.diff).replaceAll("<", "\\u003c")}<\/script>`;
4854
4854
  const inlineScript = `<script type="module">\n${appJs.replace(/<\/script/gi, "<\\/script")}\n<\/script>`;
4855
- return html.replace("<title>TailorDB ERD</title>", `<title>${escapeHtml(options.title ?? "TailorDB ERD")}</title>`).replace(STYLES_LINK, `<style>\n${css}\n</style>`).replace(APP_SCRIPT, `${embedScript}${currentSchemaScript}${diffScript}\n ${inlineScript}`);
4855
+ return html.replace("<title>TailorDB ERD</title>", () => `<title>${escapeHtml(options.title ?? "TailorDB ERD")}</title>`).replace(STYLES_LINK, () => `<style>\n${css}\n</style>`).replace(APP_SCRIPT, () => `${embedScript}${currentSchemaScript}${diffScript}\n ${inlineScript}`);
4856
4856
  }
4857
4857
  /**
4858
4858
  * Write the self-contained TailorDB ERD viewer to `<distDir>/index.html`.
@@ -6023,19 +6023,14 @@ const statusCommand = defineAppCommand({
6023
6023
  //#endregion
6024
6024
  //#region src/cli/commands/tailordb/migrate/sync.ts
6025
6025
  async function fetchRemoteGqlPermissions(client, workspaceId, namespace) {
6026
- return fetchAll(async (pageToken, maxPageSize) => {
6027
- try {
6028
- const { permissions, nextPageToken } = await client.listTailorDBGQLPermissions({
6029
- workspaceId,
6030
- namespaceName: namespace,
6031
- pageToken,
6032
- pageSize: maxPageSize
6033
- });
6034
- return [permissions, nextPageToken];
6035
- } catch (error) {
6036
- if (error instanceof ConnectError && error.code === Code.NotFound) return [[], ""];
6037
- throw error;
6038
- }
6026
+ return fetchAllTolerant(async (pageToken, maxPageSize) => {
6027
+ const { permissions, nextPageToken } = await client.listTailorDBGQLPermissions({
6028
+ workspaceId,
6029
+ namespaceName: namespace,
6030
+ pageToken,
6031
+ pageSize: maxPageSize
6032
+ });
6033
+ return [permissions, nextPageToken];
6039
6034
  });
6040
6035
  }
6041
6036
  async function fetchRemoteTypes(client, workspaceId, namespace) {
@@ -6075,7 +6070,7 @@ async function fetchRemoteTypes(client, workspaceId, namespace) {
6075
6070
  async function assertMigrationsReproduceLocalTypes(loaded, target) {
6076
6071
  const { config, plugins } = loaded;
6077
6072
  const pluginManager = plugins.length > 0 ? new PluginManager(plugins) : void 0;
6078
- const { defineApplication, generatePluginFilesIfNeeded } = await import("../application-BndtMTFY.mjs");
6073
+ const { defineApplication, generatePluginFilesIfNeeded } = await import("../application-CSUhZMb5.mjs");
6079
6074
  const application = defineApplication({
6080
6075
  config,
6081
6076
  pluginManager
@@ -6122,21 +6117,15 @@ async function assertMigrationsReproduceLocalTypes(loaded, target) {
6122
6117
  * @returns Existing labels and the parsed current migration number
6123
6118
  */
6124
6119
  async function fetchRemoteMigrationState(client, trn) {
6125
- try {
6120
+ const labels = (await getOrNull(async () => {
6126
6121
  const { metadata } = await client.getMetadata({ trn });
6127
- const labels = metadata?.labels ?? {};
6128
- const label = labels[MIGRATION_LABEL_KEY];
6129
- return {
6130
- labels,
6131
- current: label ? parseMigrationLabelNumber(label) : null
6132
- };
6133
- } catch (error) {
6134
- if (error instanceof ConnectError && error.code === Code.NotFound) return {
6135
- labels: {},
6136
- current: null
6137
- };
6138
- throw error;
6139
- }
6122
+ return metadata;
6123
+ }))?.labels ?? {};
6124
+ const label = labels[MIGRATION_LABEL_KEY];
6125
+ return {
6126
+ labels,
6127
+ current: label ? parseMigrationLabelNumber(label) : null
6128
+ };
6140
6129
  }
6141
6130
  function selectTargetNamespace(namespacesWithMigrations, requested) {
6142
6131
  if (namespacesWithMigrations.length === 0) throw new Error("No TailorDB services with migrations configuration found");