@tailor-platform/sdk 1.56.0 → 1.57.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/README.md +0 -23
  3. package/dist/{application-YHZIkjdy.mjs → application-CdkoGX27.mjs} +37 -4
  4. package/dist/application-CdkoGX27.mjs.map +1 -0
  5. package/dist/application-x_mURdR0.mjs +4 -0
  6. package/dist/cli/erd-viewer-assets/app.js +1181 -0
  7. package/dist/cli/erd-viewer-assets/index.html +73 -0
  8. package/dist/cli/erd-viewer-assets/serve.json +13 -0
  9. package/dist/cli/erd-viewer-assets/styles.css +789 -0
  10. package/dist/cli/index.mjs +686 -345
  11. package/dist/cli/index.mjs.map +1 -1
  12. package/dist/cli/lib.d.mts +7 -2
  13. package/dist/cli/lib.mjs +2 -2
  14. package/dist/client-DLPEPJ_s.mjs.map +1 -1
  15. package/dist/configure/index.d.mts +2 -2
  16. package/dist/configure/index.mjs +1 -1
  17. package/dist/configure/index.mjs.map +1 -1
  18. package/dist/{index-BW3v5XYC.d.mts → index-B61gFI9a.d.mts} +7 -2
  19. package/dist/{runtime-B8F1nklz.mjs → runtime-1YuaoNr8.mjs} +57 -63
  20. package/dist/runtime-1YuaoNr8.mjs.map +1 -0
  21. package/dist/{types-BinLwXM9.mjs → types-BwGth3a1.mjs} +57 -28
  22. package/dist/types-BwGth3a1.mjs.map +1 -0
  23. package/dist/{types-UeXbHFXW.mjs → types-Ccwchyj5.mjs} +1 -1
  24. package/dist/utils/test/index.d.mts +2 -2
  25. package/dist/{workflow.generated-BHdBzgx6.d.mts → workflow.generated-Kz-nQrTf.d.mts} +10 -1
  26. package/docs/cli/tailordb.md +31 -26
  27. package/docs/cli-reference.md +2 -2
  28. package/package.json +1 -3
  29. package/dist/application-C9-t0qQb.mjs +0 -4
  30. package/dist/application-YHZIkjdy.mjs.map +0 -1
  31. package/dist/runtime-B8F1nklz.mjs.map +0 -1
  32. package/dist/types-BinLwXM9.mjs.map +0 -1
@@ -2,7 +2,7 @@
2
2
  import { t as db } from "./schema-DKsNhbav.mjs";
3
3
  import { $ as FilterSchema, A as FunctionExecution_Status, B as AuthOAuth2Client_GrantType, C as TailorDBType_Permission_Operator, D as IdPLang, E as PipelineResolver_OperationType, F as AuthConnection_Type, H as AuthSCIMAttribute_Type, I as AuthHookPoint, J as GetApplicationSchemaHealthResponse_ApplicationSchemaHealthStatus, K as TenantProviderConfig_TenantProviderType, L as AuthIDPConfig_AuthType, M as ExecutorJobStatus, N as ExecutorTargetType, O as IdPPermissionOperator, P as ExecutorTriggerType, Q as Condition_Operator, R as AuthInvokerSchema, S as TailorDBGQLPermission_Permit, T as TailorDBType_PermitAction, U as AuthSCIMAttribute_Uniqueness, V as AuthSCIMAttribute_Mutability, W as AuthSCIMConfig_AuthorizationType, X as Subgraph_ServiceType, Y as ApplicationSchemaUpdateAttemptStatus, Z as ConditionSchema, _ as WorkspacePlatformUserRole, a as fetchMachineUserToken, b as TailorDBGQLPermission_Action, d as initOperatorClient, et as PageDirection, g as OperatorService, h as userAgent, i as fetchAll, k as IdPPermissionPermit, m as resolveStaticWebsiteUrls, o as fetchPaged, p as platformBaseUrl, q as UserProfileProviderConfig_UserProfileProviderType, v as WorkflowExecution_Status, w as TailorDBType_Permission_Permit, x as TailorDBGQLPermission_Operator, y as WorkflowJobExecution_Status, z as AuthOAuth2Client_ClientType } from "./client-DLPEPJ_s.mjs";
4
4
  import { a as parseBoolean, i as symbols, n as logger, r as styles, t as CIPromptError } from "./logger-DpJyJvNz.mjs";
5
- import { D as loadWorkspaceId, E as loadConfigPath, O as readPlatformConfig, S as loadConfig, T as loadAccessToken, b as getDistDir, c as createExecutorService, d as buildExecutorArgsExpr, f as buildResolverOperationHookExpr, h as loadFilesWithIgnores, j as writePlatformConfig, m as stringifyFunction, n as generatePluginFilesIfNeeded, p as TailorDBTypeSchema, r as loadApplication, s as HTTP_METHODS, t as defineApplication, x as hashFile, y as createBundleCache } from "./application-YHZIkjdy.mjs";
5
+ import { C as loadConfig, D as loadConfigPath, E as loadAccessToken, M as writePlatformConfig, O as loadWorkspaceId, S as hashFile, b as getDistDir, c as createExecutorService, d as buildExecutorArgsExpr, f as buildResolverOperationHookExpr, h as loadFilesWithIgnores, k as readPlatformConfig, m as stringifyFunction, n as generatePluginFilesIfNeeded, p as TailorDBTypeSchema, r as loadApplication, s as HTTP_METHODS, t as defineApplication, y as createBundleCache } from "./application-CdkoGX27.mjs";
6
6
  import { t as multiline } from "./multiline-Cf9ODpr1.mjs";
7
7
  import { t as readPackageJson } from "./package-json-DcQApfPQ.mjs";
8
8
  import { n as isCLIError, t as createCLIError } from "./errors-EsY4XO6O.mjs";
@@ -2134,7 +2134,7 @@ function hashValue(value) {
2134
2134
  //#endregion
2135
2135
  //#region src/cli/commands/deploy/auth-connection.ts
2136
2136
  function connectionTrn(workspaceId, name) {
2137
- return `${trnPrefix(workspaceId)}:auth-connection:${name}`;
2137
+ return `${trnPrefix(workspaceId)}:auth_connection:${name}`;
2138
2138
  }
2139
2139
  function buildConnectionRequest(workspaceId, name, config) {
2140
2140
  return {
@@ -2156,11 +2156,6 @@ function buildConnectionRequest(workspaceId, name, config) {
2156
2156
  }
2157
2157
  };
2158
2158
  }
2159
- /**
2160
- * Compute a hash of the full connection config for change detection.
2161
- * @param config - Auth connection config
2162
- * @returns SHA-256 hex digest
2163
- */
2164
2159
  function hashConnectionConfig(config) {
2165
2160
  return hashValue(JSON.stringify({
2166
2161
  type: config.type,
@@ -2172,12 +2167,6 @@ function hashConnectionConfig(config) {
2172
2167
  tokenUrl: config.tokenUrl ?? ""
2173
2168
  }));
2174
2169
  }
2175
- /**
2176
- * Check whether the non-secret fields of an existing connection differ from the desired config.
2177
- * @param existing - Existing connection from the server
2178
- * @param desired - Desired connection config
2179
- * @returns true if any non-secret field has changed
2180
- */
2181
2170
  function hasNonSecretFieldChanged(existing, desired) {
2182
2171
  if (existing.config.case !== "oauth2") return true;
2183
2172
  const oauth2 = existing.config.value;
@@ -2213,45 +2202,32 @@ async function planAuthConnections(client, workspaceId, appName, appId, auths) {
2213
2202
  }
2214
2203
  });
2215
2204
  const existingConnections = {};
2216
- let metadataSupported = true;
2217
2205
  await Promise.all(existingList.map(async (resource) => {
2218
- try {
2219
- const { metadata } = await client.getMetadata({ trn: connectionTrn(workspaceId, resource.name) });
2220
- existingConnections[resource.name] = {
2221
- resource,
2222
- label: metadata?.labels[sdkNameLabelKey],
2223
- allLabels: metadata?.labels
2224
- };
2225
- } catch (error) {
2226
- if (error instanceof ConnectError && error.code === Code.InvalidArgument) {
2227
- metadataSupported = false;
2228
- existingConnections[resource.name] = {
2229
- resource,
2230
- label: void 0
2231
- };
2232
- } else throw error;
2233
- }
2206
+ const { metadata } = await client.getMetadata({ trn: connectionTrn(workspaceId, resource.name) });
2207
+ existingConnections[resource.name] = {
2208
+ resource,
2209
+ label: metadata?.labels[sdkNameLabelKey],
2210
+ allLabels: metadata?.labels
2211
+ };
2234
2212
  }));
2235
2213
  const state = loadSecretsState();
2236
2214
  for (const [name, config] of Object.entries(desiredConnections)) {
2237
2215
  const existing = existingConnections[name];
2238
- const metaRequest = metadataSupported ? await buildMetaRequest({
2216
+ const metaRequest = await buildMetaRequest({
2239
2217
  trn: connectionTrn(workspaceId, name),
2240
2218
  appName,
2241
2219
  appId
2242
- }) : void 0;
2220
+ });
2243
2221
  if (existing) {
2244
- if (!isOwnedByApp(existing.allLabels, appName, appId)) {
2245
- if (metadataSupported && !existing.label) unmanaged.push({
2246
- resourceType: "Auth connection",
2247
- resourceName: name
2248
- });
2249
- else if (existing.label) conflicts.push({
2250
- resourceType: "Auth connection",
2251
- resourceName: name,
2252
- currentOwner: existing.label
2253
- });
2254
- }
2222
+ if (!isOwnedByApp(existing.allLabels, appName, appId)) if (existing.label) conflicts.push({
2223
+ resourceType: "Auth connection",
2224
+ resourceName: name,
2225
+ currentOwner: existing.label
2226
+ });
2227
+ else unmanaged.push({
2228
+ resourceType: "Auth connection",
2229
+ resourceName: name
2230
+ });
2255
2231
  const currentHash = hashConnectionConfig(config);
2256
2232
  const storedHash = state.connections?.[name];
2257
2233
  if (hasNonSecretFieldChanged(existing.resource, config) || currentHash !== storedHash) changeSet.replaces.push({
@@ -2263,6 +2239,10 @@ async function planAuthConnections(client, workspaceId, appName, appId, auths) {
2263
2239
  createRequest: buildConnectionRequest(workspaceId, name, config),
2264
2240
  metaRequest
2265
2241
  });
2242
+ else if (!existing.label) changeSet.updates.push({
2243
+ name,
2244
+ metaRequest
2245
+ });
2266
2246
  else changeSet.unchanged.push({ name });
2267
2247
  delete existingConnections[name];
2268
2248
  } else changeSet.creates.push({
@@ -2278,7 +2258,7 @@ async function planAuthConnections(client, workspaceId, appName, appId, auths) {
2278
2258
  resourceOwners.add(entry.label);
2279
2259
  continue;
2280
2260
  }
2281
- if (owned || !metadataSupported) changeSet.deletes.push({
2261
+ if (owned) changeSet.deletes.push({
2282
2262
  name,
2283
2263
  request: {
2284
2264
  workspaceId,
@@ -2293,20 +2273,6 @@ async function planAuthConnections(client, workspaceId, appName, appId, auths) {
2293
2273
  resourceOwners
2294
2274
  };
2295
2275
  }
2296
- /**
2297
- * Attempt to set metadata, silently ignoring InvalidArgument errors
2298
- * when the platform does not yet support auth-connection TRNs.
2299
- * @param client - Operator client instance
2300
- * @param metaRequest - Metadata request to send
2301
- */
2302
- async function trySetMetadata(client, metaRequest) {
2303
- try {
2304
- await client.setMetadata(metaRequest);
2305
- } catch (error) {
2306
- if (error instanceof ConnectError && error.code === Code.InvalidArgument) return;
2307
- throw error;
2308
- }
2309
- }
2310
2276
  function extractOAuth2Config(connection) {
2311
2277
  if (!connection) return void 0;
2312
2278
  const config = connection.config;
@@ -2333,13 +2299,16 @@ async function applyAuthConnections(client, result, phase) {
2333
2299
  if (phase === "create-update") {
2334
2300
  await Promise.all(changeSet.creates.map(async (create) => {
2335
2301
  await client.createAuthConnection(create.request);
2336
- if (create.metaRequest) await trySetMetadata(client, create.metaRequest);
2302
+ await client.setMetadata(create.metaRequest);
2337
2303
  }));
2338
2304
  for (const replace of changeSet.replaces) {
2339
2305
  await client.revokeAuthConnection(replace.revokeRequest);
2340
2306
  await client.createAuthConnection(replace.createRequest);
2341
- if (replace.metaRequest) await trySetMetadata(client, replace.metaRequest);
2307
+ await client.setMetadata(replace.metaRequest);
2342
2308
  }
2309
+ await Promise.all(changeSet.updates.map(async (update) => {
2310
+ await client.setMetadata(update.metaRequest);
2311
+ }));
2343
2312
  const state = loadSecretsState();
2344
2313
  if (!state.connections) state.connections = {};
2345
2314
  for (const create of changeSet.creates) {
@@ -3012,6 +2981,25 @@ function parseIdPPermission(rawPermission) {
3012
2981
  if (!rawPermission) return;
3013
2982
  return normalizeIdPPermission(rawPermission);
3014
2983
  }
2984
+ /**
2985
+ * Find object-format IdP permission rules that omit `permit`.
2986
+ *
2987
+ * Object-format rules default to `deny` when `permit` is omitted, whereas the
2988
+ * array shorthand defaults to `allow`. Omitting `permit` on an object rule is
2989
+ * therefore an easy way to accidentally deny access you meant to grant, so the
2990
+ * CLI warns about these locations to nudge authors toward setting `permit`
2991
+ * explicitly.
2992
+ * @param permission - Raw IdP permission from user config
2993
+ * @returns Locations of offending rules, e.g. `read[0]`
2994
+ */
2995
+ function findOmittedPermitRules(permission) {
2996
+ if (!permission) return [];
2997
+ const locations = [];
2998
+ for (const action of Object.keys(permission)) permission[action]?.forEach((rule, index) => {
2999
+ if (isObjectFormat(rule) && rule.permit === void 0) locations.push(`${String(action)}[${index}]`);
3000
+ });
3001
+ return locations;
3002
+ }
3015
3003
 
3016
3004
  //#endregion
3017
3005
  //#region src/cli/commands/deploy/idp.ts
@@ -3250,6 +3238,8 @@ async function planServices$3(client, workspaceId, appName, appId, idps, idpUser
3250
3238
  const publishUserEvents = idp.publishUserEvents ?? isIdpUserTriggerTarget;
3251
3239
  const emailConfig = idp.emailConfig;
3252
3240
  if (!idp.permission) logger.warn(`IdP service "${namespaceName}" has no permission configured.`);
3241
+ const omittedPermitLocations = findOmittedPermitRules(idp.permission);
3242
+ if (omittedPermitLocations.length > 0) logger.warn(`IdP service "${namespaceName}" has permission rule(s) ${omittedPermitLocations.join(", ")} in object form without an explicit "permit"; they default to "deny". Set permit: true (allow) or permit: false (deny) to silence this warning.`);
3253
3243
  const parsedPermission = parseIdPPermission(idp.permission);
3254
3244
  const protoPermission = parsedPermission ? protoIdPPermission(parsedPermission) : void 0;
3255
3245
  const desired = normalizeComparableIdPService({
@@ -10100,6 +10090,10 @@ async function deploy(options) {
10100
10090
  resourceType: "OAuth2 client (client type change)",
10101
10091
  resourceName: replace.name
10102
10092
  });
10093
+ for (const del of auth.changeSet.connection.deletes) importantDeletions.push({
10094
+ resourceType: "Auth connection",
10095
+ resourceName: del.name
10096
+ });
10103
10097
  for (const del of secretManager.vaultChangeSet.deletes) importantDeletions.push({
10104
10098
  resourceType: "Secret Manager vault",
10105
10099
  resourceName: del.name
@@ -14494,7 +14488,7 @@ async function generate(options) {
14494
14488
  if (options.init) await handleInitOption(namespacesWithMigrations, options.yes);
14495
14489
  let pluginManager;
14496
14490
  if (plugins.length > 0) pluginManager = new PluginManager(plugins);
14497
- const { defineApplication } = await import("./application-C9-t0qQb.mjs");
14491
+ const { defineApplication } = await import("./application-x_mURdR0.mjs");
14498
14492
  const application = defineApplication({
14499
14493
  config,
14500
14494
  pluginManager
@@ -16686,5 +16680,5 @@ function isDeno() {
16686
16680
  }
16687
16681
 
16688
16682
  //#endregion
16689
- export { listCommand$5 as $, compareSnapshots as $t, truncate as A, workspaceArgs as An, startCommand as At, logBetaWarning as B, getExecutor as Bt, listCommand$2 as C, configArg as Cn, triggerExecutor as Ct, resumeWorkflow as D, pagedLogArgs as Dn, jobsCommand as Dt, resumeCommand as E, isVerbose as En, getExecutorJob as Et, writeDbTypesFile as F, getWorkflowExecution as Ft, organizationTree as G, parseMigrationLabelNumber as Gt, removeCommand$1 as H, executeScript as Ht, getConfiguredEditorCommand as I, listWorkflowExecutions as It, listOrganizations as J, DIFF_FILE_NAME as Jt, treeCommand as K, bundleMigrationScript as Kt, openInConfiguredEditor as L, functionExecutionStatusToString as Lt, generate as M, getCommand$5 as Mt, generateCommand as N, getWorkflow as Nt, listCommand$3 as O, paginationArgs as On, listExecutorJobs as Ot, generateMigrationScript as P, executionsCommand as Pt, updateFolder as Q, compareLocalTypesWithSnapshot as Qt, show as R, formatKeyValueTable as Rt, listApps as S, commonArgs as Sn, triggerCommand as St, healthCommand as T, deploymentArgs as Tn, listExecutors as Tt, updateCommand$1 as U, waitForExecution$1 as Ut, remove as V, deploy as Vt, updateOrganization as W, MIGRATION_LABEL_KEY as Wt, getOrganization as X, MIGRATE_FILE_NAME as Xt, getCommand$1 as Y, INITIAL_SCHEMA_NUMBER as Yt, updateCommand$2 as Z, SCHEMA_FILE_NAME as Zt, getWorkspace as _, prompt as _n, listFunctionRegistries as _t, updateUser as a, getNextMigrationNumber as an, createCommand$1 as at, createCommand as b, assertWritable as bn, listWebhookExecutors as bt, listCommand as c, reconstructSnapshotFromMigrations as cn, listOAuth2Clients as ct, inviteUser as d, formatMigrationDiff as dn, getMachineUserToken as dt, createSnapshotFromLocalTypes as en, listFolders as et, restoreCommand as f, hasChanges as fn, tokenCommand as ft, getCommand as g, generateUserTypes as gn, listCommand$8 as gt, listWorkspaces as h, trnPrefix as hn, generate$1 as ht, updateCommand as i, getMigrationFiles as in, deleteFolder as it, truncateCommand as j, startWorkflow as jt, listWorkflows as k, toPageDirection as kn, watchExecutorJob as kt, listUsers as l, formatMigrationNumber as ln, getCommand$3 as lt, listCommand$1 as m, sdkNameLabelKey as mn, listMachineUsers as mt, query as n, getMigrationDirPath as nn, getFolder as nt, removeCommand as o, isValidMigrationNumber as on, createFolder as ot, restoreWorkspace as p, getNamespacesWithMigrations as pn, listCommand$7 as pt, listCommand$4 as q, DB_TYPES_FILE_NAME as qt, queryCommand as r, getMigrationFilePath as rn, deleteCommand$1 as rt, removeUser as s, loadDiff as sn, listCommand$6 as st, isNativeTypeScriptRuntime as t, getLatestMigrationNumber as tn, getCommand$2 as tt, inviteCommand as u, formatDiffSummary as un, getOAuth2Client as ut, deleteCommand as v, apiCommand as vn, getCommand$4 as vt, getAppHealth as w, confirmationArgs as wn, listCommand$9 as wt, createWorkspace as x, defineAppCommand as xn, webhookCommand as xt, deleteWorkspace as y, apiCall as yn, getFunctionRegistry as yt, showCommand as z, getCommand$6 as zt };
16690
- //# sourceMappingURL=runtime-B8F1nklz.mjs.map
16683
+ export { listCommand$5 as $, compareSnapshots as $t, truncate as A, toPageDirection as An, startCommand as At, logBetaWarning as B, getExecutor as Bt, listCommand$2 as C, commonArgs as Cn, triggerExecutor as Ct, resumeWorkflow as D, isVerbose as Dn, jobsCommand as Dt, resumeCommand as E, deploymentArgs as En, getExecutorJob as Et, writeDbTypesFile as F, getWorkflowExecution as Ft, organizationTree as G, parseMigrationLabelNumber as Gt, removeCommand$1 as H, executeScript as Ht, getConfiguredEditorCommand as I, listWorkflowExecutions as It, listOrganizations as J, DIFF_FILE_NAME as Jt, treeCommand as K, bundleMigrationScript as Kt, openInConfiguredEditor as L, functionExecutionStatusToString as Lt, generate as M, getCommand$5 as Mt, generateCommand as N, getWorkflow as Nt, listCommand$3 as O, pagedLogArgs as On, listExecutorJobs as Ot, generateMigrationScript as P, executionsCommand as Pt, updateFolder as Q, compareLocalTypesWithSnapshot as Qt, show as R, formatKeyValueTable as Rt, listApps as S, defineAppCommand as Sn, triggerCommand as St, healthCommand as T, confirmationArgs as Tn, listExecutors as Tt, updateCommand$1 as U, waitForExecution$1 as Ut, remove as V, deploy as Vt, updateOrganization as W, MIGRATION_LABEL_KEY as Wt, getOrganization as X, MIGRATE_FILE_NAME as Xt, getCommand$1 as Y, INITIAL_SCHEMA_NUMBER as Yt, updateCommand$2 as Z, SCHEMA_FILE_NAME as Zt, getWorkspace as _, generateUserTypes as _n, listFunctionRegistries as _t, updateUser as a, getNextMigrationNumber as an, createCommand$1 as at, createCommand as b, apiCall as bn, listWebhookExecutors as bt, listCommand as c, reconstructSnapshotFromMigrations as cn, listOAuth2Clients as ct, inviteUser as d, formatMigrationDiff as dn, getMachineUserToken as dt, createSnapshotFromLocalTypes as en, listFolders as et, restoreCommand as f, hasChanges as fn, tokenCommand as ft, getCommand as g, PluginManager as gn, listCommand$8 as gt, listWorkspaces as h, trnPrefix as hn, generate$1 as ht, updateCommand as i, getMigrationFiles as in, deleteFolder as it, truncateCommand as j, workspaceArgs as jn, startWorkflow as jt, listWorkflows as k, paginationArgs as kn, watchExecutorJob as kt, listUsers as l, formatMigrationNumber as ln, getCommand$3 as lt, listCommand$1 as m, sdkNameLabelKey as mn, listMachineUsers as mt, query as n, getMigrationDirPath as nn, getFolder as nt, removeCommand as o, isValidMigrationNumber as on, createFolder as ot, restoreWorkspace as p, getNamespacesWithMigrations as pn, listCommand$7 as pt, listCommand$4 as q, DB_TYPES_FILE_NAME as qt, queryCommand as r, getMigrationFilePath as rn, deleteCommand$1 as rt, removeUser as s, loadDiff as sn, listCommand$6 as st, isNativeTypeScriptRuntime as t, getLatestMigrationNumber as tn, getCommand$2 as tt, inviteCommand as u, formatDiffSummary as un, getOAuth2Client as ut, deleteCommand as v, prompt as vn, getCommand$4 as vt, getAppHealth as w, configArg as wn, listCommand$9 as wt, createWorkspace as x, assertWritable as xn, webhookCommand as xt, deleteWorkspace as y, apiCommand as yn, getFunctionRegistry as yt, showCommand as z, getCommand$6 as zt };
16684
+ //# sourceMappingURL=runtime-1YuaoNr8.mjs.map