@tailor-platform/sdk 1.2.2 → 1.2.3
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 +8 -0
- package/dist/cli/index.mjs +54 -2
- package/dist/cli/index.mjs.map +1 -1
- package/dist/cli/lib.d.mts +110 -1
- package/dist/cli/lib.mjs +2 -2
- package/dist/{config-CnvbSTIP.mjs → config-CJPKA-ui.mjs} +47 -48
- package/dist/config-CJPKA-ui.mjs.map +1 -0
- package/dist/configure/index.d.mts +2 -2
- package/dist/configure/index.mjs +69 -1
- package/dist/configure/index.mjs.map +1 -1
- package/dist/{index-aNF917Ib.d.mts → index-DXZMT4aO.d.mts} +63 -3
- package/dist/{list-CinLZzZW.mjs → list-nW4EfF7C.mjs} +587 -28
- package/dist/list-nW4EfF7C.mjs.map +1 -0
- package/dist/{types-C0n7Syhv.d.mts → types-Dg_zk_OZ.d.mts} +68 -18
- package/dist/utils/test/index.d.mts +2 -2
- package/package.json +1 -1
- package/dist/config-CnvbSTIP.mjs.map +0 -1
- package/dist/list-CinLZzZW.mjs.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as __toCommonJS, i as __require, n as __esmMin, o as __toESM, r as __exportAll, t as __commonJSMin } from "./chunk-CIV_ash9.mjs";
|
|
2
|
-
import { i as WORKFLOW_JOB_BRAND, r as getDistDir } from "./config-
|
|
2
|
+
import { i as WORKFLOW_JOB_BRAND, r as getDistDir } from "./config-CJPKA-ui.mjs";
|
|
3
3
|
import Module, { createRequire } from "node:module";
|
|
4
4
|
import { defineCommand } from "citty";
|
|
5
5
|
import * as path$20 from "node:path";
|
|
@@ -1093,6 +1093,10 @@ const OperatorService = /* @__PURE__ */ serviceDesc(file_tailor_v1_service, 0);
|
|
|
1093
1093
|
//#endregion
|
|
1094
1094
|
//#region src/cli/utils/package-json.ts
|
|
1095
1095
|
let packageJson = null;
|
|
1096
|
+
/**
|
|
1097
|
+
* Read and cache the package.json of the SDK package.
|
|
1098
|
+
* @returns {Promise<PackageJson>} Parsed package.json contents
|
|
1099
|
+
*/
|
|
1096
1100
|
async function readPackageJson() {
|
|
1097
1101
|
if (packageJson) return packageJson;
|
|
1098
1102
|
packageJson = await readPackageJSON(import.meta.url);
|
|
@@ -1104,6 +1108,10 @@ async function readPackageJson() {
|
|
|
1104
1108
|
const platformBaseUrl = process.env.PLATFORM_URL ?? "https://api.tailor.tech";
|
|
1105
1109
|
const oauth2ClientId = "cpoc_0Iudir72fqSpqC6GQ58ri1cLAqcq5vJl";
|
|
1106
1110
|
const oauth2DiscoveryEndpoint = "/.well-known/oauth-authorization-server/oauth2/platform";
|
|
1111
|
+
/**
|
|
1112
|
+
* Initialize an OAuth2 client for Tailor Platform.
|
|
1113
|
+
* @returns {OAuth2Client} Configured OAuth2 client
|
|
1114
|
+
*/
|
|
1107
1115
|
function initOAuth2Client() {
|
|
1108
1116
|
return new OAuth2Client({
|
|
1109
1117
|
clientId: oauth2ClientId,
|
|
@@ -1111,6 +1119,11 @@ function initOAuth2Client() {
|
|
|
1111
1119
|
discoveryEndpoint: oauth2DiscoveryEndpoint
|
|
1112
1120
|
});
|
|
1113
1121
|
}
|
|
1122
|
+
/**
|
|
1123
|
+
* Initialize an Operator client with the given access token.
|
|
1124
|
+
* @param {string} accessToken - Access token for authentication
|
|
1125
|
+
* @returns {Promise<OperatorClient>} Configured Operator client
|
|
1126
|
+
*/
|
|
1114
1127
|
async function initOperatorClient(accessToken) {
|
|
1115
1128
|
return createClient(OperatorService, createConnectTransport({
|
|
1116
1129
|
httpVersion: "2",
|
|
@@ -1123,6 +1136,10 @@ async function initOperatorClient(accessToken) {
|
|
|
1123
1136
|
]
|
|
1124
1137
|
}));
|
|
1125
1138
|
}
|
|
1139
|
+
/**
|
|
1140
|
+
* Create an interceptor that sets a User-Agent header.
|
|
1141
|
+
* @returns {Promise<Interceptor>} User-Agent interceptor
|
|
1142
|
+
*/
|
|
1126
1143
|
async function userAgentInterceptor() {
|
|
1127
1144
|
const ua = await userAgent();
|
|
1128
1145
|
return (next) => async (req) => {
|
|
@@ -1130,15 +1147,28 @@ async function userAgentInterceptor() {
|
|
|
1130
1147
|
return await next(req);
|
|
1131
1148
|
};
|
|
1132
1149
|
}
|
|
1150
|
+
/**
|
|
1151
|
+
* Build the User-Agent string for CLI requests.
|
|
1152
|
+
* @returns {Promise<string>} User-Agent header value
|
|
1153
|
+
*/
|
|
1133
1154
|
async function userAgent() {
|
|
1134
1155
|
return `tailor-sdk/${(await readPackageJson()).version ?? "unknown"}`;
|
|
1135
1156
|
}
|
|
1157
|
+
/**
|
|
1158
|
+
* Create an interceptor that sets the Authorization bearer token.
|
|
1159
|
+
* @param {string} accessToken - Access token to use
|
|
1160
|
+
* @returns {Promise<Interceptor>} Bearer token interceptor
|
|
1161
|
+
*/
|
|
1136
1162
|
async function bearerTokenInterceptor(accessToken) {
|
|
1137
1163
|
return (next) => async (req) => {
|
|
1138
1164
|
req.header.set("Authorization", `Bearer ${accessToken}`);
|
|
1139
1165
|
return await next(req);
|
|
1140
1166
|
};
|
|
1141
1167
|
}
|
|
1168
|
+
/**
|
|
1169
|
+
* Create an interceptor that retries idempotent requests with backoff.
|
|
1170
|
+
* @returns {Interceptor} Retry interceptor
|
|
1171
|
+
*/
|
|
1142
1172
|
function retryInterceptor() {
|
|
1143
1173
|
return (next) => async (req) => {
|
|
1144
1174
|
if (req.stream) return await next(req);
|
|
@@ -1158,10 +1188,21 @@ function retryInterceptor() {
|
|
|
1158
1188
|
throw lastError;
|
|
1159
1189
|
};
|
|
1160
1190
|
}
|
|
1191
|
+
/**
|
|
1192
|
+
* Wait for an exponential backoff delay with jitter.
|
|
1193
|
+
* @param {number} attempt - Current retry attempt number (1-based)
|
|
1194
|
+
* @returns {Promise<void>} Promise that resolves after the delay
|
|
1195
|
+
*/
|
|
1161
1196
|
function waitRetryBackoff(attempt) {
|
|
1162
1197
|
const backoff = 50 * 2 ** (attempt - 1) * (1 + .1 * (Math.random() * 2 - 1));
|
|
1163
1198
|
return new Promise((resolve$3) => setTimeout(resolve$3, backoff));
|
|
1164
1199
|
}
|
|
1200
|
+
/**
|
|
1201
|
+
* Determine whether the given error is retriable for the method idempotency.
|
|
1202
|
+
* @param {unknown} error - Error thrown by the request
|
|
1203
|
+
* @param {MethodOptions_IdempotencyLevel} idempotency - Method idempotency level
|
|
1204
|
+
* @returns {boolean} True if the error should be retried
|
|
1205
|
+
*/
|
|
1165
1206
|
function isRetirable(error, idempotency) {
|
|
1166
1207
|
if (!(error instanceof ConnectError)) return false;
|
|
1167
1208
|
switch (error.code) {
|
|
@@ -1170,6 +1211,10 @@ function isRetirable(error, idempotency) {
|
|
|
1170
1211
|
default: return false;
|
|
1171
1212
|
}
|
|
1172
1213
|
}
|
|
1214
|
+
/**
|
|
1215
|
+
* Create an interceptor that enhances error messages from the Operator API.
|
|
1216
|
+
* @returns {Interceptor} Error handling interceptor
|
|
1217
|
+
*/
|
|
1173
1218
|
function errorHandlingInterceptor() {
|
|
1174
1219
|
return (next) => async (req) => {
|
|
1175
1220
|
try {
|
|
@@ -1210,6 +1255,12 @@ function formatRequestParams(message) {
|
|
|
1210
1255
|
return "(unable to serialize request)";
|
|
1211
1256
|
}
|
|
1212
1257
|
}
|
|
1258
|
+
/**
|
|
1259
|
+
* Fetch all paginated resources by repeatedly calling the given function.
|
|
1260
|
+
* @template T
|
|
1261
|
+
* @param {(pageToken: string) => Promise<[T[], string]>} fn - Page fetcher returning items and next page token
|
|
1262
|
+
* @returns {Promise<T[]>} All fetched items
|
|
1263
|
+
*/
|
|
1213
1264
|
async function fetchAll(fn) {
|
|
1214
1265
|
const items = [];
|
|
1215
1266
|
let pageToken = "";
|
|
@@ -1221,6 +1272,11 @@ async function fetchAll(fn) {
|
|
|
1221
1272
|
}
|
|
1222
1273
|
return items;
|
|
1223
1274
|
}
|
|
1275
|
+
/**
|
|
1276
|
+
* Fetch user info from the Tailor Platform userinfo endpoint.
|
|
1277
|
+
* @param {string} accessToken - Access token for the current user
|
|
1278
|
+
* @returns {Promise<{ email: string }>} Parsed user info
|
|
1279
|
+
*/
|
|
1224
1280
|
async function fetchUserInfo(accessToken) {
|
|
1225
1281
|
const userInfoUrl = new URL("/auth/platform/userinfo", platformBaseUrl).href;
|
|
1226
1282
|
const resp = await fetch(userInfoUrl, { headers: {
|
|
@@ -1231,6 +1287,14 @@ async function fetchUserInfo(accessToken) {
|
|
|
1231
1287
|
const rawJson = await resp.json();
|
|
1232
1288
|
return z.object({ email: z.string() }).parse(rawJson);
|
|
1233
1289
|
}
|
|
1290
|
+
/**
|
|
1291
|
+
* Resolve "name:url" patterns to actual Static Website URLs.
|
|
1292
|
+
* @param {OperatorClient} client - Operator client instance
|
|
1293
|
+
* @param {string} workspaceId - Workspace ID
|
|
1294
|
+
* @param {string[] | undefined} urls - URLs or name:url patterns
|
|
1295
|
+
* @param {string} context - Logging context (e.g., "CORS", "OAuth2 redirect URIs")
|
|
1296
|
+
* @returns {Promise<string[]>} Resolved URLs
|
|
1297
|
+
*/
|
|
1234
1298
|
async function resolveStaticWebsiteUrls(client, workspaceId, urls, context) {
|
|
1235
1299
|
if (!urls) return [];
|
|
1236
1300
|
return (await Promise.all(urls.map(async (url) => {
|
|
@@ -1256,6 +1320,13 @@ async function resolveStaticWebsiteUrls(client, workspaceId, urls, context) {
|
|
|
1256
1320
|
return [url];
|
|
1257
1321
|
}))).flat();
|
|
1258
1322
|
}
|
|
1323
|
+
/**
|
|
1324
|
+
* Fetch an OAuth2 access token for a machine user.
|
|
1325
|
+
* @param {string} url - OAuth2 server base URL
|
|
1326
|
+
* @param {string} clientId - Client ID for the machine user
|
|
1327
|
+
* @param {string} clientSecret - Client secret for the machine user
|
|
1328
|
+
* @returns {Promise<string>} Access token
|
|
1329
|
+
*/
|
|
1259
1330
|
async function fetchMachineUserToken(url, clientId, clientSecret) {
|
|
1260
1331
|
const tokenEndpoint = new URL("/oauth2/token", url).href;
|
|
1261
1332
|
const formData = new URLSearchParams();
|
|
@@ -1298,6 +1369,10 @@ function platformConfigPath() {
|
|
|
1298
1369
|
if (!xdgConfig) throw new Error("User home directory not found");
|
|
1299
1370
|
return path$20.join(xdgConfig, "tailor-platform", "config.yaml");
|
|
1300
1371
|
}
|
|
1372
|
+
/**
|
|
1373
|
+
* Read Tailor Platform CLI configuration, migrating from tailorctl if necessary.
|
|
1374
|
+
* @returns {PfConfig} Parsed platform configuration
|
|
1375
|
+
*/
|
|
1301
1376
|
function readPlatformConfig() {
|
|
1302
1377
|
const configPath = platformConfigPath();
|
|
1303
1378
|
if (!fs$15.existsSync(configPath)) {
|
|
@@ -1315,6 +1390,11 @@ function readPlatformConfig() {
|
|
|
1315
1390
|
const rawConfig = parseYAML(fs$15.readFileSync(configPath, "utf-8"));
|
|
1316
1391
|
return pfConfigSchema.parse(rawConfig);
|
|
1317
1392
|
}
|
|
1393
|
+
/**
|
|
1394
|
+
* Write Tailor Platform CLI configuration to disk.
|
|
1395
|
+
* @param {PfConfig} config - Platform configuration to write
|
|
1396
|
+
* @returns {void}
|
|
1397
|
+
*/
|
|
1318
1398
|
function writePlatformConfig(config) {
|
|
1319
1399
|
const configPath = platformConfigPath();
|
|
1320
1400
|
fs$15.mkdirSync(path$20.dirname(configPath), { recursive: true });
|
|
@@ -1367,6 +1447,12 @@ function validateUUID(value, source) {
|
|
|
1367
1447
|
if (!result.success) throw new Error(`Invalid value from ${source}: must be a valid UUID`);
|
|
1368
1448
|
return result.data;
|
|
1369
1449
|
}
|
|
1450
|
+
/**
|
|
1451
|
+
* Load workspace ID from command options, environment variables, or platform config.
|
|
1452
|
+
* Priority: opts/workspaceId > env/workspaceId > opts/profile > env/profile > error
|
|
1453
|
+
* @param {{ workspaceId?: string; profile?: string }} [opts] - Workspace and profile options
|
|
1454
|
+
* @returns {string} Resolved workspace ID
|
|
1455
|
+
*/
|
|
1370
1456
|
function loadWorkspaceId(opts) {
|
|
1371
1457
|
if (opts?.workspaceId) return validateUUID(opts.workspaceId, "--workspace-id option");
|
|
1372
1458
|
if (process.env.TAILOR_PLATFORM_WORKSPACE_ID) return validateUUID(process.env.TAILOR_PLATFORM_WORKSPACE_ID, "TAILOR_PLATFORM_WORKSPACE_ID environment variable");
|
|
@@ -1381,6 +1467,12 @@ function loadWorkspaceId(opts) {
|
|
|
1381
1467
|
Please specify workspace ID via --workspace-id option or TAILOR_PLATFORM_WORKSPACE_ID environment variable.
|
|
1382
1468
|
`);
|
|
1383
1469
|
}
|
|
1470
|
+
/**
|
|
1471
|
+
* Load access token from command options, environment variables, or platform config.
|
|
1472
|
+
* Priority: env/TAILOR_PLATFORM_TOKEN > env/TAILOR_TOKEN (deprecated) > opts/profile > env/profile > config/currentUser > error
|
|
1473
|
+
* @param {{ useProfile?: boolean; profile?: string }} [opts] - Profile options
|
|
1474
|
+
* @returns {Promise<string>} Resolved access token
|
|
1475
|
+
*/
|
|
1384
1476
|
async function loadAccessToken(opts) {
|
|
1385
1477
|
if (process.env.TAILOR_PLATFORM_TOKEN) return process.env.TAILOR_PLATFORM_TOKEN;
|
|
1386
1478
|
if (process.env.TAILOR_TOKEN) {
|
|
@@ -1404,6 +1496,12 @@ async function loadAccessToken(opts) {
|
|
|
1404
1496
|
}
|
|
1405
1497
|
return await fetchLatestToken(pfConfig, user);
|
|
1406
1498
|
}
|
|
1499
|
+
/**
|
|
1500
|
+
* Fetch the latest access token, refreshing if necessary.
|
|
1501
|
+
* @param {PfConfig} config - Platform config
|
|
1502
|
+
* @param {string} user - User name
|
|
1503
|
+
* @returns {Promise<string>} Latest access token
|
|
1504
|
+
*/
|
|
1407
1505
|
async function fetchLatestToken(config, user) {
|
|
1408
1506
|
const tokens = config.users[user];
|
|
1409
1507
|
if (!tokens) throw new Error(ml`
|
|
@@ -1425,15 +1523,33 @@ async function fetchLatestToken(config, user) {
|
|
|
1425
1523
|
return resp.accessToken;
|
|
1426
1524
|
}
|
|
1427
1525
|
const DEFAULT_CONFIG_FILENAME = "tailor.config.ts";
|
|
1526
|
+
/**
|
|
1527
|
+
* Load config path from command options or environment variables.
|
|
1528
|
+
* Priority: opts/config > env/config > search parent directories
|
|
1529
|
+
* @param {string} [configPath] - Optional explicit config path
|
|
1530
|
+
* @returns {string | undefined} Resolved config path or undefined
|
|
1531
|
+
*/
|
|
1428
1532
|
function loadConfigPath(configPath) {
|
|
1429
1533
|
if (configPath) return configPath;
|
|
1430
1534
|
if (process.env.TAILOR_PLATFORM_SDK_CONFIG_PATH) return process.env.TAILOR_PLATFORM_SDK_CONFIG_PATH;
|
|
1431
1535
|
return findUpSync(DEFAULT_CONFIG_FILENAME);
|
|
1432
1536
|
}
|
|
1537
|
+
/**
|
|
1538
|
+
* Load organization ID from command options or environment variables.
|
|
1539
|
+
* Priority: opts/organizationId > env/organizationId > undefined (optional)
|
|
1540
|
+
* @param {string} [organizationId] - Organization ID override
|
|
1541
|
+
* @returns {string | undefined} Resolved organization ID or undefined
|
|
1542
|
+
*/
|
|
1433
1543
|
function loadOrganizationId(organizationId) {
|
|
1434
1544
|
if (organizationId) return validateUUID(organizationId, "--organization-id option");
|
|
1435
1545
|
if (process.env.TAILOR_PLATFORM_ORGANIZATION_ID) return validateUUID(process.env.TAILOR_PLATFORM_ORGANIZATION_ID, "TAILOR_PLATFORM_ORGANIZATION_ID environment variable");
|
|
1436
1546
|
}
|
|
1547
|
+
/**
|
|
1548
|
+
* Load folder ID from command options or environment variables.
|
|
1549
|
+
* Priority: opts/folderId > env/folderId > undefined (optional)
|
|
1550
|
+
* @param {string} [folderId] - Folder ID override
|
|
1551
|
+
* @returns {string | undefined} Resolved folder ID or undefined
|
|
1552
|
+
*/
|
|
1437
1553
|
function loadFolderId(folderId) {
|
|
1438
1554
|
if (folderId) return validateUUID(folderId, "--folder-id option");
|
|
1439
1555
|
if (process.env.TAILOR_PLATFORM_FOLDER_ID) return validateUUID(process.env.TAILOR_PLATFORM_FOLDER_ID, "TAILOR_PLATFORM_FOLDER_ID environment variable");
|
|
@@ -1988,14 +2104,18 @@ const convertHookToExpr = (fn) => {
|
|
|
1988
2104
|
/**
|
|
1989
2105
|
* Parse TailorDBField into OperatorFieldConfig.
|
|
1990
2106
|
* This transforms user-defined functions into script expressions.
|
|
2107
|
+
* @param {TailorAnyDBField} field - TailorDB field definition
|
|
2108
|
+
* @returns {OperatorFieldConfig} Parsed operator field configuration
|
|
1991
2109
|
*/
|
|
1992
2110
|
function parseFieldConfig(field) {
|
|
1993
2111
|
const metadata = field.metadata;
|
|
1994
2112
|
const fieldType = field.type;
|
|
2113
|
+
const rawRelation = field.rawRelation;
|
|
1995
2114
|
const nestedFields = field.fields;
|
|
1996
2115
|
return {
|
|
1997
2116
|
type: fieldType,
|
|
1998
2117
|
...metadata,
|
|
2118
|
+
rawRelation,
|
|
1999
2119
|
...fieldType === "nested" && nestedFields && Object.keys(nestedFields).length > 0 ? { fields: Object.entries(nestedFields).reduce((acc, [key, nestedField]) => {
|
|
2000
2120
|
acc[key] = parseFieldConfig(nestedField);
|
|
2001
2121
|
return acc;
|
|
@@ -98745,6 +98865,12 @@ const eslintConfig = {
|
|
|
98745
98865
|
},
|
|
98746
98866
|
rules: { "no-undef": "error" }
|
|
98747
98867
|
};
|
|
98868
|
+
/**
|
|
98869
|
+
* Ensure that a TailorDB script expression does not reference external variables.
|
|
98870
|
+
* @param {string} expr - JavaScript expression to validate
|
|
98871
|
+
* @param {ScriptContext} ctx - Script context (type, field, kind)
|
|
98872
|
+
* @returns {void}
|
|
98873
|
+
*/
|
|
98748
98874
|
function ensureNoExternalVariablesInScript(expr, ctx) {
|
|
98749
98875
|
if (!expr.trim()) return;
|
|
98750
98876
|
let messages;
|
|
@@ -98763,6 +98889,13 @@ function ensureNoExternalVariablesInScript(expr, ctx) {
|
|
|
98763
98889
|
const namesList = [...externalNames].sort().join(", ");
|
|
98764
98890
|
throw new Error(`TailorDB ${ctx.kind} for ${ctx.typeName}.${ctx.fieldName} captures external variables (${namesList}). Hooks and validators must not reference variables outside their own parameters and local declarations.`);
|
|
98765
98891
|
}
|
|
98892
|
+
/**
|
|
98893
|
+
* Ensure that TailorDB field scripts do not capture external variables.
|
|
98894
|
+
* @param {string} typeName - TailorDB type name
|
|
98895
|
+
* @param {string} fieldName - Field name
|
|
98896
|
+
* @param {TailorDBFieldConfig} fieldConfig - Parsed field configuration
|
|
98897
|
+
* @returns {void}
|
|
98898
|
+
*/
|
|
98766
98899
|
function ensureNoExternalVariablesInFieldScripts(typeName, fieldName, fieldConfig) {
|
|
98767
98900
|
for (const validateConfig of fieldConfig.validate ?? []) {
|
|
98768
98901
|
const expr = validateConfig.script?.expr;
|
|
@@ -98812,12 +98945,24 @@ function isObjectFormat(p$1) {
|
|
|
98812
98945
|
function isSingleArrayConditionFormat(cond) {
|
|
98813
98946
|
return cond.length >= 2 && typeof cond[1] === "string";
|
|
98814
98947
|
}
|
|
98948
|
+
/**
|
|
98949
|
+
* Normalize record-level permissions into a standard structure.
|
|
98950
|
+
* @template User
|
|
98951
|
+
* @template Type
|
|
98952
|
+
* @param {TailorTypePermission<User, Type>} permission - Tailor type permission
|
|
98953
|
+
* @returns {StandardTailorTypePermission} Normalized record permissions
|
|
98954
|
+
*/
|
|
98815
98955
|
function normalizePermission(permission) {
|
|
98816
98956
|
return Object.keys(permission).reduce((acc, action) => {
|
|
98817
98957
|
acc[action] = permission[action].map((p$1) => normalizeActionPermission(p$1));
|
|
98818
98958
|
return acc;
|
|
98819
98959
|
}, {});
|
|
98820
98960
|
}
|
|
98961
|
+
/**
|
|
98962
|
+
* Normalize GraphQL permissions into a standard structure.
|
|
98963
|
+
* @param {TailorTypeGqlPermission<unknown, unknown>} permission - Tailor GQL permission
|
|
98964
|
+
* @returns {StandardTailorTypeGqlPermission} Normalized GQL permissions
|
|
98965
|
+
*/
|
|
98821
98966
|
function normalizeGqlPermission(permission) {
|
|
98822
98967
|
return permission.map((policy) => normalizeGqlPolicy(policy));
|
|
98823
98968
|
}
|
|
@@ -98832,6 +98977,8 @@ function normalizeGqlPolicy(policy) {
|
|
|
98832
98977
|
/**
|
|
98833
98978
|
* Parse raw permissions into normalized permissions.
|
|
98834
98979
|
* This is the main entry point for permission parsing in the parser layer.
|
|
98980
|
+
* @param {RawPermissions} rawPermissions - Raw permissions definition
|
|
98981
|
+
* @returns {Permissions} Normalized permissions
|
|
98835
98982
|
*/
|
|
98836
98983
|
function parsePermissions(rawPermissions) {
|
|
98837
98984
|
return {
|
|
@@ -98839,6 +98986,11 @@ function parsePermissions(rawPermissions) {
|
|
|
98839
98986
|
...rawPermissions.gql && { gql: normalizeGqlPermission(rawPermissions.gql) }
|
|
98840
98987
|
};
|
|
98841
98988
|
}
|
|
98989
|
+
/**
|
|
98990
|
+
* Normalize a single action permission into the standard format.
|
|
98991
|
+
* @param {unknown} permission - Raw permission definition
|
|
98992
|
+
* @returns {StandardActionPermission} Normalized action permission
|
|
98993
|
+
*/
|
|
98842
98994
|
function normalizeActionPermission(permission) {
|
|
98843
98995
|
if (isObjectFormat(permission)) {
|
|
98844
98996
|
const conditions$1 = permission.conditions;
|
|
@@ -98876,6 +99028,79 @@ function normalizeActionPermission(permission) {
|
|
|
98876
99028
|
};
|
|
98877
99029
|
}
|
|
98878
99030
|
|
|
99031
|
+
//#endregion
|
|
99032
|
+
//#region src/parser/service/tailordb/relation.ts
|
|
99033
|
+
const relationTypes = {
|
|
99034
|
+
"1-1": "1-1",
|
|
99035
|
+
oneToOne: "1-1",
|
|
99036
|
+
"n-1": "n-1",
|
|
99037
|
+
manyToOne: "n-1",
|
|
99038
|
+
"N-1": "n-1",
|
|
99039
|
+
keyOnly: "keyOnly"
|
|
99040
|
+
};
|
|
99041
|
+
function fieldRef(context) {
|
|
99042
|
+
return `Field "${context.fieldName}" on type "${context.typeName}"`;
|
|
99043
|
+
}
|
|
99044
|
+
/**
|
|
99045
|
+
* Validate relation configuration
|
|
99046
|
+
*/
|
|
99047
|
+
function validateRelationConfig(rawRelation, context) {
|
|
99048
|
+
if (!rawRelation.type) throw new Error(`${fieldRef(context)} has a relation but is missing the required 'type' property. Valid values: ${Object.keys(relationTypes).join(", ")}.`);
|
|
99049
|
+
if (!(rawRelation.type in relationTypes)) throw new Error(`${fieldRef(context)} has invalid relation type '${rawRelation.type}'. Valid values: ${Object.keys(relationTypes).join(", ")}.`);
|
|
99050
|
+
if (rawRelation.toward.type !== "self" && !context.allTypeNames.has(rawRelation.toward.type)) throw new Error(`${fieldRef(context)} references unknown type "${rawRelation.toward.type}".`);
|
|
99051
|
+
}
|
|
99052
|
+
/**
|
|
99053
|
+
* Process raw relation config and compute derived metadata values
|
|
99054
|
+
*/
|
|
99055
|
+
function processRelationMetadata(rawRelation, context, isArrayField = false) {
|
|
99056
|
+
const isUnique = relationTypes[rawRelation.type] === "1-1";
|
|
99057
|
+
const key = rawRelation.toward.key ?? "id";
|
|
99058
|
+
const targetTypeName = rawRelation.toward.type === "self" ? context.typeName : rawRelation.toward.type;
|
|
99059
|
+
const shouldSetIndex = !isArrayField;
|
|
99060
|
+
const shouldSetUnique = !isArrayField && isUnique;
|
|
99061
|
+
return {
|
|
99062
|
+
index: shouldSetIndex,
|
|
99063
|
+
foreignKey: true,
|
|
99064
|
+
relationType: rawRelation.type,
|
|
99065
|
+
unique: shouldSetUnique,
|
|
99066
|
+
foreignKeyType: targetTypeName,
|
|
99067
|
+
foreignKeyField: key
|
|
99068
|
+
};
|
|
99069
|
+
}
|
|
99070
|
+
/**
|
|
99071
|
+
* Build relation info for creating forward/backward relationships
|
|
99072
|
+
* Returns undefined for keyOnly relations
|
|
99073
|
+
*/
|
|
99074
|
+
function buildRelationInfo(rawRelation, context) {
|
|
99075
|
+
if (rawRelation.type === "keyOnly") return;
|
|
99076
|
+
const isUnique = relationTypes[rawRelation.type] === "1-1";
|
|
99077
|
+
const key = rawRelation.toward.key ?? "id";
|
|
99078
|
+
const targetTypeName = rawRelation.toward.type === "self" ? context.typeName : rawRelation.toward.type;
|
|
99079
|
+
let forwardName = rawRelation.toward.as;
|
|
99080
|
+
if (!forwardName) if (rawRelation.toward.type === "self") forwardName = context.fieldName.replace(/(ID|Id|id)$/u, "");
|
|
99081
|
+
else forwardName = inflection.camelize(targetTypeName, true);
|
|
99082
|
+
return {
|
|
99083
|
+
targetType: targetTypeName,
|
|
99084
|
+
forwardName,
|
|
99085
|
+
backwardName: rawRelation.backward ?? "",
|
|
99086
|
+
key,
|
|
99087
|
+
unique: isUnique
|
|
99088
|
+
};
|
|
99089
|
+
}
|
|
99090
|
+
/**
|
|
99091
|
+
* Apply processed relation metadata to field config
|
|
99092
|
+
*/
|
|
99093
|
+
function applyRelationMetadataToFieldConfig(fieldConfig, metadata) {
|
|
99094
|
+
return {
|
|
99095
|
+
...fieldConfig,
|
|
99096
|
+
index: metadata.index,
|
|
99097
|
+
foreignKey: metadata.foreignKey,
|
|
99098
|
+
unique: metadata.unique,
|
|
99099
|
+
foreignKeyType: metadata.foreignKeyType,
|
|
99100
|
+
foreignKeyField: metadata.foreignKeyField
|
|
99101
|
+
};
|
|
99102
|
+
}
|
|
99103
|
+
|
|
98879
99104
|
//#endregion
|
|
98880
99105
|
//#region src/parser/service/tailordb/type-parser.ts
|
|
98881
99106
|
/**
|
|
@@ -98884,7 +99109,8 @@ function normalizeActionPermission(permission) {
|
|
|
98884
99109
|
*/
|
|
98885
99110
|
function parseTypes(rawTypes, namespace, typeSourceInfo) {
|
|
98886
99111
|
const types$2 = {};
|
|
98887
|
-
|
|
99112
|
+
const allTypeNames = new Set(Object.keys(rawTypes));
|
|
99113
|
+
for (const [typeName, type] of Object.entries(rawTypes)) types$2[typeName] = parseTailorDBType(type, allTypeNames, rawTypes);
|
|
98888
99114
|
buildBackwardRelationships(types$2, namespace, typeSourceInfo);
|
|
98889
99115
|
validatePluralFormUniqueness(types$2, namespace, typeSourceInfo);
|
|
98890
99116
|
return types$2;
|
|
@@ -98892,13 +99118,24 @@ function parseTypes(rawTypes, namespace, typeSourceInfo) {
|
|
|
98892
99118
|
/**
|
|
98893
99119
|
* Parse a TailorDBType into a ParsedTailorDBType.
|
|
98894
99120
|
*/
|
|
98895
|
-
function parseTailorDBType(type) {
|
|
99121
|
+
function parseTailorDBType(type, allTypeNames, rawTypes) {
|
|
98896
99122
|
const metadata = type.metadata;
|
|
98897
99123
|
const pluralForm = metadata.settings?.pluralForm || inflection.pluralize(type.name);
|
|
98898
99124
|
const fields = {};
|
|
98899
99125
|
const forwardRelationships = {};
|
|
98900
99126
|
for (const [fieldName, fieldDef] of Object.entries(type.fields)) {
|
|
98901
|
-
|
|
99127
|
+
let fieldConfig = parseFieldConfig(fieldDef);
|
|
99128
|
+
const rawRelation = fieldConfig.rawRelation;
|
|
99129
|
+
const context = {
|
|
99130
|
+
typeName: type.name,
|
|
99131
|
+
fieldName,
|
|
99132
|
+
allTypeNames
|
|
99133
|
+
};
|
|
99134
|
+
if (rawRelation) {
|
|
99135
|
+
validateRelationConfig(rawRelation, context);
|
|
99136
|
+
const relationMetadata = processRelationMetadata(rawRelation, context, fieldConfig.array);
|
|
99137
|
+
fieldConfig = applyRelationMetadataToFieldConfig(fieldConfig, relationMetadata);
|
|
99138
|
+
}
|
|
98902
99139
|
if (fieldConfig.array && fieldConfig.index) throw new Error(`Field "${fieldName}" on type "${type.name}": index cannot be set on array fields`);
|
|
98903
99140
|
if (fieldConfig.array && fieldConfig.unique) throw new Error(`Field "${fieldName}" on type "${type.name}": unique cannot be set on array fields`);
|
|
98904
99141
|
ensureNoExternalVariablesInFieldScripts(type.name, fieldName, fieldConfig);
|
|
@@ -98906,29 +99143,18 @@ function parseTailorDBType(type) {
|
|
|
98906
99143
|
name: fieldName,
|
|
98907
99144
|
config: fieldConfig
|
|
98908
99145
|
};
|
|
98909
|
-
const
|
|
98910
|
-
if (
|
|
98911
|
-
|
|
98912
|
-
|
|
98913
|
-
|
|
98914
|
-
|
|
98915
|
-
|
|
98916
|
-
|
|
98917
|
-
|
|
98918
|
-
|
|
98919
|
-
|
|
98920
|
-
|
|
98921
|
-
unique: fieldDef.metadata?.unique ?? false
|
|
98922
|
-
};
|
|
98923
|
-
forwardRelationships[forwardName] = {
|
|
98924
|
-
name: forwardName,
|
|
98925
|
-
targetType,
|
|
98926
|
-
targetField: fieldName,
|
|
98927
|
-
sourceField: key,
|
|
98928
|
-
isArray: false,
|
|
98929
|
-
description: ref$1.type?.metadata?.description || ""
|
|
98930
|
-
};
|
|
98931
|
-
}
|
|
99146
|
+
const relationInfo = rawRelation ? buildRelationInfo(rawRelation, context) : void 0;
|
|
99147
|
+
if (relationInfo) {
|
|
99148
|
+
parsedField.relation = { ...relationInfo };
|
|
99149
|
+
const targetType = rawTypes[relationInfo.targetType];
|
|
99150
|
+
forwardRelationships[relationInfo.forwardName] = {
|
|
99151
|
+
name: relationInfo.forwardName,
|
|
99152
|
+
targetType: relationInfo.targetType,
|
|
99153
|
+
targetField: fieldName,
|
|
99154
|
+
sourceField: relationInfo.key,
|
|
99155
|
+
isArray: false,
|
|
99156
|
+
description: targetType?.metadata?.description || ""
|
|
99157
|
+
};
|
|
98932
99158
|
}
|
|
98933
99159
|
fields[fieldName] = parsedField;
|
|
98934
99160
|
}
|
|
@@ -99262,6 +99488,11 @@ var Application = class {
|
|
|
99262
99488
|
});
|
|
99263
99489
|
}
|
|
99264
99490
|
};
|
|
99491
|
+
/**
|
|
99492
|
+
* Define a Tailor application from the given configuration.
|
|
99493
|
+
* @param {AppConfig} config - Application configuration object
|
|
99494
|
+
* @returns {Application} Configured application instance
|
|
99495
|
+
*/
|
|
99265
99496
|
function defineApplication(config) {
|
|
99266
99497
|
const app = new Application(config.name, config);
|
|
99267
99498
|
app.defineTailorDB(config.db);
|
|
@@ -99968,6 +100199,11 @@ function createTriggerTransformPlugin(triggerContext) {
|
|
|
99968
100199
|
|
|
99969
100200
|
//#endregion
|
|
99970
100201
|
//#region src/cli/bundler/executor/loader.ts
|
|
100202
|
+
/**
|
|
100203
|
+
* Load and validate an executor definition from a file.
|
|
100204
|
+
* @param {string} executorFilePath - Path to the executor file
|
|
100205
|
+
* @returns {Promise<Executor | null>} Parsed executor or null if invalid
|
|
100206
|
+
*/
|
|
99971
100207
|
async function loadExecutor(executorFilePath) {
|
|
99972
100208
|
const executor = (await import(pathToFileURL(executorFilePath).href)).default;
|
|
99973
100209
|
const parseResult = ExecutorSchema.safeParse(executor);
|
|
@@ -100058,6 +100294,11 @@ async function bundleSingleExecutor(executor, outputDir, tsconfig, triggerContex
|
|
|
100058
100294
|
|
|
100059
100295
|
//#endregion
|
|
100060
100296
|
//#region src/cli/bundler/resolver/loader.ts
|
|
100297
|
+
/**
|
|
100298
|
+
* Load and validate a resolver definition from a file.
|
|
100299
|
+
* @param {string} resolverFilePath - Path to the resolver file
|
|
100300
|
+
* @returns {Promise<Resolver | null>} Parsed resolver or null if invalid
|
|
100301
|
+
*/
|
|
100061
100302
|
async function loadResolver(resolverFilePath) {
|
|
100062
100303
|
const resolver = (await import(pathToFileURL(resolverFilePath).href)).default;
|
|
100063
100304
|
const parseResult = ResolverSchema.safeParse(resolver);
|
|
@@ -101343,6 +101584,11 @@ const builtinGenerators = new Map([
|
|
|
101343
101584
|
[FileUtilsGeneratorID, (options) => new FileUtilsGenerator(options)]
|
|
101344
101585
|
]);
|
|
101345
101586
|
const GeneratorConfigSchema = createGeneratorConfigSchema(builtinGenerators);
|
|
101587
|
+
/**
|
|
101588
|
+
* Load Tailor configuration file and associated generators.
|
|
101589
|
+
* @param {string} [configPath] - Optional explicit config path
|
|
101590
|
+
* @returns {Promise<{ config: AppConfig; generators: Generator[]; configPath: string }>} Loaded config and generators
|
|
101591
|
+
*/
|
|
101346
101592
|
async function loadConfig(configPath) {
|
|
101347
101593
|
const foundPath = loadConfigPath(configPath);
|
|
101348
101594
|
if (!foundPath) throw new Error("Configuration file not found: tailor.config.ts not found in current or parent directories");
|
|
@@ -101376,6 +101622,13 @@ async function loadConfig(configPath) {
|
|
|
101376
101622
|
function extractAttributesFromConfig(config) {
|
|
101377
101623
|
return collectAttributesFromConfig(config);
|
|
101378
101624
|
}
|
|
101625
|
+
/**
|
|
101626
|
+
* Generate the contents of the user-defined type definition file.
|
|
101627
|
+
* @param {AttributeMapConfig | undefined} attributeMap - Attribute map configuration
|
|
101628
|
+
* @param {AttributeListConfig | undefined} attributeList - Attribute list configuration
|
|
101629
|
+
* @param {Record<string, string | number | boolean>} [env] - Environment configuration
|
|
101630
|
+
* @returns {string} Generated type definition source
|
|
101631
|
+
*/
|
|
101379
101632
|
function generateTypeDefinition(attributeMap, attributeList, env) {
|
|
101380
101633
|
const mapFields = attributeMap ? Object.entries(attributeMap).map(([key, value]) => ` ${key}: ${value};`).join("\n") : "";
|
|
101381
101634
|
const mapBody = !attributeMap || Object.keys(attributeMap).length === 0 ? "{}" : `{
|
|
@@ -101433,6 +101686,11 @@ function collectAttributesFromConfig(config) {
|
|
|
101433
101686
|
}
|
|
101434
101687
|
return {};
|
|
101435
101688
|
}
|
|
101689
|
+
/**
|
|
101690
|
+
* Resolve the output path for the generated type definition file.
|
|
101691
|
+
* @param {string} configPath - Path to Tailor config file
|
|
101692
|
+
* @returns {string} Absolute path to the type definition file
|
|
101693
|
+
*/
|
|
101436
101694
|
function resolveTypeDefinitionPath(configPath) {
|
|
101437
101695
|
const typePath = process.env.TAILOR_PLATFORM_SDK_TYPE_PATH;
|
|
101438
101696
|
if (typePath) return path$20.resolve(process.cwd(), typePath);
|
|
@@ -101441,6 +101699,12 @@ function resolveTypeDefinitionPath(configPath) {
|
|
|
101441
101699
|
if (!packageDir) return path$20.join(configDir, "node_modules", "@tailor-platform", "sdk", "dist", "user-defined.d.ts");
|
|
101442
101700
|
return path$20.join(packageDir, "dist", "user-defined.d.ts");
|
|
101443
101701
|
}
|
|
101702
|
+
/**
|
|
101703
|
+
* Generate user type definitions from the app config and write them to disk.
|
|
101704
|
+
* @param {AppConfig} config - Application config
|
|
101705
|
+
* @param {string} configPath - Path to Tailor config file
|
|
101706
|
+
* @returns {Promise<void>} Promise that resolves when types are generated
|
|
101707
|
+
*/
|
|
101444
101708
|
async function generateUserTypes(config, configPath) {
|
|
101445
101709
|
try {
|
|
101446
101710
|
const { attributeMap, attributeList } = extractAttributesFromConfig(config);
|
|
@@ -101481,10 +101745,21 @@ function resolvePackageDirectory(startDir) {
|
|
|
101481
101745
|
|
|
101482
101746
|
//#endregion
|
|
101483
101747
|
//#region src/cli/apply/services/label.ts
|
|
101748
|
+
/**
|
|
101749
|
+
* Build TRN prefix for a workspace.
|
|
101750
|
+
* @param {string} workspaceId - Workspace ID
|
|
101751
|
+
* @returns {string} TRN prefix string
|
|
101752
|
+
*/
|
|
101484
101753
|
function trnPrefix(workspaceId) {
|
|
101485
101754
|
return `trn:v1:workspace:${workspaceId}`;
|
|
101486
101755
|
}
|
|
101487
101756
|
const sdkNameLabelKey = "sdk-name";
|
|
101757
|
+
/**
|
|
101758
|
+
* Build metadata request with SDK labels.
|
|
101759
|
+
* @param {string} trn - Target TRN
|
|
101760
|
+
* @param {string} appName - Application name label
|
|
101761
|
+
* @returns {Promise<MessageInitShape<typeof SetMetadataRequestSchema>>} Metadata request
|
|
101762
|
+
*/
|
|
101488
101763
|
async function buildMetaRequest(trn$7, appName) {
|
|
101489
101764
|
const packageJson$1 = await readPackageJson();
|
|
101490
101765
|
const sdkVersion = packageJson$1.version ? `v${packageJson$1.version.replace(/\./g, "-")}` : "unknown";
|
|
@@ -101526,6 +101801,13 @@ var ChangeSet = class {
|
|
|
101526
101801
|
|
|
101527
101802
|
//#endregion
|
|
101528
101803
|
//#region src/cli/apply/services/application.ts
|
|
101804
|
+
/**
|
|
101805
|
+
* Apply application changes for the given phase.
|
|
101806
|
+
* @param {OperatorClient} client - Operator client instance
|
|
101807
|
+
* @param {ReturnType<typeof planApplication>} changeSet - Planned application changes
|
|
101808
|
+
* @param {"create-update" | "delete"} [phase="create-update"] - Apply phase
|
|
101809
|
+
* @returns {Promise<void>} Promise that resolves when applications are applied
|
|
101810
|
+
*/
|
|
101529
101811
|
async function applyApplication(client, changeSet, phase = "create-update") {
|
|
101530
101812
|
if (phase === "create-update") await Promise.all([...changeSet.creates.map(async (create$1) => {
|
|
101531
101813
|
create$1.request.cors = await resolveStaticWebsiteUrls(client, create$1.request.workspaceId, create$1.request.cors, "CORS");
|
|
@@ -101543,6 +101825,11 @@ async function applyApplication(client, changeSet, phase = "create-update") {
|
|
|
101543
101825
|
function trn$6(workspaceId, name$1) {
|
|
101544
101826
|
return `trn:v1:workspace:${workspaceId}:application:${name$1}`;
|
|
101545
101827
|
}
|
|
101828
|
+
/**
|
|
101829
|
+
* Plan application changes based on current and desired state.
|
|
101830
|
+
* @param {PlanContext} context - Planning context
|
|
101831
|
+
* @returns {Promise<ChangeSet<CreateApplication, UpdateApplication, DeleteApplication>>} Planned changes
|
|
101832
|
+
*/
|
|
101546
101833
|
async function planApplication({ client, workspaceId, application, forRemoval }) {
|
|
101547
101834
|
const changeSet = new ChangeSet("Applications");
|
|
101548
101835
|
const existingApplications = await fetchAll(async (pageToken) => {
|
|
@@ -101648,12 +101935,31 @@ function protoSubgraph(subgraph) {
|
|
|
101648
101935
|
|
|
101649
101936
|
//#endregion
|
|
101650
101937
|
//#region src/cli/apply/services/idp.ts
|
|
101938
|
+
/**
|
|
101939
|
+
* Build the vault name for an IdP client.
|
|
101940
|
+
* @param {string} namespaceName - IdP namespace name
|
|
101941
|
+
* @param {string} clientName - IdP client name
|
|
101942
|
+
* @returns {string} Vault name
|
|
101943
|
+
*/
|
|
101651
101944
|
function idpClientVaultName(namespaceName, clientName) {
|
|
101652
101945
|
return `idp-${namespaceName}-${clientName}`;
|
|
101653
101946
|
}
|
|
101947
|
+
/**
|
|
101948
|
+
* Build the secret name for an IdP client.
|
|
101949
|
+
* @param {string} namespaceName - IdP namespace name
|
|
101950
|
+
* @param {string} clientName - IdP client name
|
|
101951
|
+
* @returns {string} Secret name
|
|
101952
|
+
*/
|
|
101654
101953
|
function idpClientSecretName(namespaceName, clientName) {
|
|
101655
101954
|
return `client-secret-${namespaceName}-${clientName}`;
|
|
101656
101955
|
}
|
|
101956
|
+
/**
|
|
101957
|
+
* Apply IdP-related changes for the given phase.
|
|
101958
|
+
* @param {OperatorClient} client - Operator client instance
|
|
101959
|
+
* @param {Awaited<ReturnType<typeof planIdP>>} result - Planned IdP changes
|
|
101960
|
+
* @param {Exclude<ApplyPhase, "delete">} [phase="create-update"] - Apply phase
|
|
101961
|
+
* @returns {Promise<void>} Promise that resolves when IdP changes are applied
|
|
101962
|
+
*/
|
|
101657
101963
|
async function applyIdP(client, result, phase = "create-update") {
|
|
101658
101964
|
const { changeSet } = result;
|
|
101659
101965
|
if (phase === "create-update") {
|
|
@@ -101711,6 +102017,11 @@ async function applyIdP(client, result, phase = "create-update") {
|
|
|
101711
102017
|
}));
|
|
101712
102018
|
else if (phase === "delete-services") await Promise.all(changeSet.service.deletes.map((del) => client.deleteIdPService(del.request)));
|
|
101713
102019
|
}
|
|
102020
|
+
/**
|
|
102021
|
+
* Plan IdP-related changes based on current and desired state.
|
|
102022
|
+
* @param {PlanContext} context - Planning context
|
|
102023
|
+
* @returns {Promise<unknown>} Planned changes and metadata
|
|
102024
|
+
*/
|
|
101714
102025
|
async function planIdP({ client, workspaceId, application, forRemoval }) {
|
|
101715
102026
|
const idps = forRemoval ? [] : application.idpServices;
|
|
101716
102027
|
const { changeSet: serviceChangeSet, conflicts, unmanaged, resourceOwners } = await planServices$3(client, workspaceId, application.name, idps);
|
|
@@ -101899,6 +102210,13 @@ function convertLang(lang) {
|
|
|
101899
102210
|
|
|
101900
102211
|
//#endregion
|
|
101901
102212
|
//#region src/cli/apply/services/auth.ts
|
|
102213
|
+
/**
|
|
102214
|
+
* Apply auth-related changes for the given phase.
|
|
102215
|
+
* @param {OperatorClient} client - Operator client instance
|
|
102216
|
+
* @param {Awaited<ReturnType<typeof planAuth>>} result - Planned auth changes
|
|
102217
|
+
* @param {Exclude<ApplyPhase, "delete">} [phase="create-update"] - Apply phase
|
|
102218
|
+
* @returns {Promise<void>} Promise that resolves when auth changes are applied
|
|
102219
|
+
*/
|
|
101902
102220
|
async function applyAuth(client, result, phase = "create-update") {
|
|
101903
102221
|
const { changeSet } = result;
|
|
101904
102222
|
if (phase === "create-update") {
|
|
@@ -101935,6 +102253,11 @@ async function applyAuth(client, result, phase = "create-update") {
|
|
|
101935
102253
|
await Promise.all(changeSet.idpConfig.deletes.map((del) => client.deleteAuthIDPConfig(del.request)));
|
|
101936
102254
|
} else if (phase === "delete-services") await Promise.all(changeSet.service.deletes.map((del) => client.deleteAuthService(del.request)));
|
|
101937
102255
|
}
|
|
102256
|
+
/**
|
|
102257
|
+
* Plan auth-related changes based on current and desired state.
|
|
102258
|
+
* @param {PlanContext} context - Planning context
|
|
102259
|
+
* @returns {Promise<unknown>} Planned auth changes and metadata
|
|
102260
|
+
*/
|
|
101938
102261
|
async function planAuth({ client, workspaceId, application, forRemoval }) {
|
|
101939
102262
|
const auths = [];
|
|
101940
102263
|
if (!forRemoval && application.authService) {
|
|
@@ -102740,6 +103063,13 @@ function protoSCIMAttribute(attr) {
|
|
|
102740
103063
|
|
|
102741
103064
|
//#endregion
|
|
102742
103065
|
//#region src/cli/apply/services/confirm.ts
|
|
103066
|
+
/**
|
|
103067
|
+
* Confirm reassignment of resources when owner conflicts are detected.
|
|
103068
|
+
* @param {OwnerConflict[]} conflicts - Detected owner conflicts
|
|
103069
|
+
* @param {string} appName - Target application name
|
|
103070
|
+
* @param {boolean} yes - Whether to auto-confirm without prompting
|
|
103071
|
+
* @returns {Promise<void>} Promise that resolves when confirmation completes
|
|
103072
|
+
*/
|
|
102743
103073
|
async function confirmOwnerConflict(conflicts, appName, yes) {
|
|
102744
103074
|
if (conflicts.length === 0) return;
|
|
102745
103075
|
const currentOwners = [...new Set(conflicts.map((c$1) => c$1.currentOwner))];
|
|
@@ -102762,6 +103092,13 @@ async function confirmOwnerConflict(conflicts, appName, yes) {
|
|
|
102762
103092
|
To override, run again and confirm, or use --yes flag.
|
|
102763
103093
|
`);
|
|
102764
103094
|
}
|
|
103095
|
+
/**
|
|
103096
|
+
* Confirm allowing tailor-sdk to manage previously unmanaged resources.
|
|
103097
|
+
* @param {UnmanagedResource[]} resources - Unmanaged resources
|
|
103098
|
+
* @param {string} appName - Target application name
|
|
103099
|
+
* @param {boolean} yes - Whether to auto-confirm without prompting
|
|
103100
|
+
* @returns {Promise<void>} Promise that resolves when confirmation completes
|
|
103101
|
+
*/
|
|
102765
103102
|
async function confirmUnmanagedResources(resources, appName, yes) {
|
|
102766
103103
|
if (resources.length === 0) return;
|
|
102767
103104
|
logger.warn("Existing resources not tracked by tailor-sdk were found:");
|
|
@@ -102783,6 +103120,12 @@ async function confirmUnmanagedResources(resources, appName, yes) {
|
|
|
102783
103120
|
To override, run again and confirm, or use --yes flag.
|
|
102784
103121
|
`);
|
|
102785
103122
|
}
|
|
103123
|
+
/**
|
|
103124
|
+
* Confirm deletion of important resources.
|
|
103125
|
+
* @param {ImportantResourceDeletion[]} resources - Resources scheduled for deletion
|
|
103126
|
+
* @param {boolean} yes - Whether to auto-confirm without prompting
|
|
103127
|
+
* @returns {Promise<void>} Promise that resolves when confirmation completes
|
|
103128
|
+
*/
|
|
102786
103129
|
async function confirmImportantResourceDeletion(resources, yes) {
|
|
102787
103130
|
if (resources.length === 0) return;
|
|
102788
103131
|
logger.warn("The following resources will be deleted:");
|
|
@@ -102805,6 +103148,13 @@ async function confirmImportantResourceDeletion(resources, yes) {
|
|
|
102805
103148
|
|
|
102806
103149
|
//#endregion
|
|
102807
103150
|
//#region src/cli/apply/services/executor.ts
|
|
103151
|
+
/**
|
|
103152
|
+
* Apply executor-related changes for the given phase.
|
|
103153
|
+
* @param {OperatorClient} client - Operator client instance
|
|
103154
|
+
* @param {Awaited<ReturnType<typeof planExecutor>>} result - Planned executor changes
|
|
103155
|
+
* @param {Extract<ApplyPhase, "create-update" | "delete">} [phase="create-update"] - Apply phase
|
|
103156
|
+
* @returns {Promise<void>} Promise that resolves when executors are applied
|
|
103157
|
+
*/
|
|
102808
103158
|
async function applyExecutor(client, result, phase = "create-update") {
|
|
102809
103159
|
const { changeSet } = result;
|
|
102810
103160
|
if (phase === "create-update") await Promise.all([...changeSet.creates.map(async (create$1) => {
|
|
@@ -102819,6 +103169,11 @@ async function applyExecutor(client, result, phase = "create-update") {
|
|
|
102819
103169
|
function trn$3(workspaceId, name$1) {
|
|
102820
103170
|
return `trn:v1:workspace:${workspaceId}:executor:${name$1}`;
|
|
102821
103171
|
}
|
|
103172
|
+
/**
|
|
103173
|
+
* Plan executor-related changes based on current and desired state.
|
|
103174
|
+
* @param {PlanContext} context - Planning context
|
|
103175
|
+
* @returns {Promise<ChangeSet<CreateExecutor, UpdateExecutor, DeleteExecutor>>} Planned changes
|
|
103176
|
+
*/
|
|
102822
103177
|
async function planExecutor({ client, workspaceId, application, forRemoval }) {
|
|
102823
103178
|
const changeSet = new ChangeSet("Executors");
|
|
102824
103179
|
const conflicts = [];
|
|
@@ -103079,6 +103434,13 @@ const SCALAR_TYPE_MAP = {
|
|
|
103079
103434
|
name: "Time"
|
|
103080
103435
|
}
|
|
103081
103436
|
};
|
|
103437
|
+
/**
|
|
103438
|
+
* Apply resolver pipeline changes for the given phase.
|
|
103439
|
+
* @param {OperatorClient} client - Operator client instance
|
|
103440
|
+
* @param {Awaited<ReturnType<typeof planPipeline>>} result - Planned pipeline changes
|
|
103441
|
+
* @param {Exclude<ApplyPhase, "delete">} [phase="create-update"] - Apply phase
|
|
103442
|
+
* @returns {Promise<void>} Promise that resolves when pipeline changes are applied
|
|
103443
|
+
*/
|
|
103082
103444
|
async function applyPipeline(client, result, phase = "create-update") {
|
|
103083
103445
|
const { changeSet } = result;
|
|
103084
103446
|
if (phase === "create-update") {
|
|
@@ -103093,6 +103455,11 @@ async function applyPipeline(client, result, phase = "create-update") {
|
|
|
103093
103455
|
} else if (phase === "delete-resources") await Promise.all(changeSet.resolver.deletes.map((del) => client.deletePipelineResolver(del.request)));
|
|
103094
103456
|
else if (phase === "delete-services") await Promise.all(changeSet.service.deletes.map((del) => client.deletePipelineService(del.request)));
|
|
103095
103457
|
}
|
|
103458
|
+
/**
|
|
103459
|
+
* Plan resolver pipeline changes based on current and desired state.
|
|
103460
|
+
* @param {PlanContext} context - Planning context
|
|
103461
|
+
* @returns {Promise<unknown>} Planned changes
|
|
103462
|
+
*/
|
|
103096
103463
|
async function planPipeline({ client, workspaceId, application, forRemoval }) {
|
|
103097
103464
|
const pipelines = [];
|
|
103098
103465
|
if (!forRemoval) for (const pipeline of application.resolverServices) {
|
|
@@ -103327,6 +103694,13 @@ function protoFields(fields, baseName, isInput) {
|
|
|
103327
103694
|
|
|
103328
103695
|
//#endregion
|
|
103329
103696
|
//#region src/cli/apply/services/staticwebsite.ts
|
|
103697
|
+
/**
|
|
103698
|
+
* Apply static website changes for the given phase.
|
|
103699
|
+
* @param {OperatorClient} client - Operator client instance
|
|
103700
|
+
* @param {Awaited<ReturnType<typeof planStaticWebsite>>} result - Planned static website changes
|
|
103701
|
+
* @param {Extract<ApplyPhase, "create-update" | "delete">} [phase="create-update"] - Apply phase
|
|
103702
|
+
* @returns {Promise<void>} Promise that resolves when static websites are applied
|
|
103703
|
+
*/
|
|
103330
103704
|
async function applyStaticWebsite(client, result, phase = "create-update") {
|
|
103331
103705
|
const { changeSet } = result;
|
|
103332
103706
|
if (phase === "create-update") await Promise.all([...changeSet.creates.map(async (create$1) => {
|
|
@@ -103341,6 +103715,11 @@ async function applyStaticWebsite(client, result, phase = "create-update") {
|
|
|
103341
103715
|
function trn$1(workspaceId, name$1) {
|
|
103342
103716
|
return `trn:v1:workspace:${workspaceId}:staticwebsite:${name$1}`;
|
|
103343
103717
|
}
|
|
103718
|
+
/**
|
|
103719
|
+
* Plan static website changes based on current and desired state.
|
|
103720
|
+
* @param {PlanContext} context - Planning context
|
|
103721
|
+
* @returns {Promise<unknown>} Planned changes
|
|
103722
|
+
*/
|
|
103344
103723
|
async function planStaticWebsite({ client, workspaceId, application, forRemoval }) {
|
|
103345
103724
|
const changeSet = new ChangeSet("StaticWebsites");
|
|
103346
103725
|
const conflicts = [];
|
|
@@ -103430,6 +103809,13 @@ async function planStaticWebsite({ client, workspaceId, application, forRemoval
|
|
|
103430
103809
|
|
|
103431
103810
|
//#endregion
|
|
103432
103811
|
//#region src/cli/apply/services/tailordb.ts
|
|
103812
|
+
/**
|
|
103813
|
+
* Apply TailorDB-related changes for the given phase.
|
|
103814
|
+
* @param {OperatorClient} client - Operator client instance
|
|
103815
|
+
* @param {Awaited<ReturnType<typeof planTailorDB>>} result - Planned TailorDB changes
|
|
103816
|
+
* @param {Exclude<ApplyPhase, "delete">} [phase="create-update"] - Apply phase
|
|
103817
|
+
* @returns {Promise<void>} Promise that resolves when TailorDB changes are applied
|
|
103818
|
+
*/
|
|
103433
103819
|
async function applyTailorDB(client, result, phase = "create-update") {
|
|
103434
103820
|
const { changeSet } = result;
|
|
103435
103821
|
if (phase === "create-update") {
|
|
@@ -103444,6 +103830,11 @@ async function applyTailorDB(client, result, phase = "create-update") {
|
|
|
103444
103830
|
await Promise.all(changeSet.type.deletes.map((del) => client.deleteTailorDBType(del.request)));
|
|
103445
103831
|
} else if (phase === "delete-services") await Promise.all(changeSet.service.deletes.map((del) => client.deleteTailorDBService(del.request)));
|
|
103446
103832
|
}
|
|
103833
|
+
/**
|
|
103834
|
+
* Plan TailorDB-related changes based on current and desired state.
|
|
103835
|
+
* @param {PlanContext} context - Planning context
|
|
103836
|
+
* @returns {Promise<unknown>} Planned changes
|
|
103837
|
+
*/
|
|
103447
103838
|
async function planTailorDB({ client, workspaceId, application, forRemoval }) {
|
|
103448
103839
|
const tailordbs = [];
|
|
103449
103840
|
if (!forRemoval) for (const tailordb of application.tailorDBServices) {
|
|
@@ -103972,6 +104363,13 @@ function protoGqlOperand(operand) {
|
|
|
103972
104363
|
|
|
103973
104364
|
//#endregion
|
|
103974
104365
|
//#region src/cli/apply/services/workflow.ts
|
|
104366
|
+
/**
|
|
104367
|
+
* Apply workflow changes for the given phase.
|
|
104368
|
+
* @param {OperatorClient} client - Operator client instance
|
|
104369
|
+
* @param {Awaited<ReturnType<typeof planWorkflow>>} result - Planned workflow changes
|
|
104370
|
+
* @param {Extract<ApplyPhase, "create-update" | "delete">} [phase="create-update"] - Apply phase
|
|
104371
|
+
* @returns {Promise<void>} Promise that resolves when workflows are applied
|
|
104372
|
+
*/
|
|
103975
104373
|
async function applyWorkflow(client, result, phase = "create-update") {
|
|
103976
104374
|
const { changeSet, appName } = result;
|
|
103977
104375
|
if (phase === "create-update") {
|
|
@@ -104064,6 +104462,15 @@ function workflowTrn(workspaceId, name$1) {
|
|
|
104064
104462
|
function jobFunctionTrn(workspaceId, name$1) {
|
|
104065
104463
|
return `trn:v1:workspace:${workspaceId}:workflow_job_function:${name$1}`;
|
|
104066
104464
|
}
|
|
104465
|
+
/**
|
|
104466
|
+
* Plan workflow changes and job functions based on current and desired state.
|
|
104467
|
+
* @param {OperatorClient} client - Operator client instance
|
|
104468
|
+
* @param {string} workspaceId - Workspace ID
|
|
104469
|
+
* @param {string} appName - Application name
|
|
104470
|
+
* @param {Record<string, Workflow>} workflows - Parsed workflows
|
|
104471
|
+
* @param {Record<string, string[]>} mainJobDeps - Main job dependencies by workflow
|
|
104472
|
+
* @returns {Promise<unknown>} Planned workflow changes
|
|
104473
|
+
*/
|
|
104067
104474
|
async function planWorkflow(client, workspaceId, appName, workflows, mainJobDeps) {
|
|
104068
104475
|
const changeSet = new ChangeSet("Workflows");
|
|
104069
104476
|
const conflicts = [];
|
|
@@ -104155,6 +104562,11 @@ async function loadWorkflowScripts() {
|
|
|
104155
104562
|
|
|
104156
104563
|
//#endregion
|
|
104157
104564
|
//#region src/cli/apply/index.ts
|
|
104565
|
+
/**
|
|
104566
|
+
* Apply the configured application to the Tailor platform.
|
|
104567
|
+
* @param {ApplyOptions} [options] - Options for apply execution
|
|
104568
|
+
* @returns {Promise<void>} Promise that resolves when apply completes
|
|
104569
|
+
*/
|
|
104158
104570
|
async function apply(options) {
|
|
104159
104571
|
const { config, configPath } = await loadConfig(options?.configPath);
|
|
104160
104572
|
const dryRun = options?.dryRun ?? false;
|
|
@@ -105044,6 +105456,11 @@ var GenerationManager = class {
|
|
|
105044
105456
|
});
|
|
105045
105457
|
}
|
|
105046
105458
|
};
|
|
105459
|
+
/**
|
|
105460
|
+
* Run code generation using the Tailor configuration and generators.
|
|
105461
|
+
* @param {GenerateOptions} [options] - Generation options
|
|
105462
|
+
* @returns {Promise<void>} Promise that resolves when generation (and watch, if enabled) completes
|
|
105463
|
+
*/
|
|
105047
105464
|
async function generate(options) {
|
|
105048
105465
|
const { config, generators, configPath } = await loadConfig(options?.configPath);
|
|
105049
105466
|
const watch = options?.watch ?? false;
|
|
@@ -105082,6 +105499,11 @@ const generateCommand = defineCommand({
|
|
|
105082
105499
|
|
|
105083
105500
|
//#endregion
|
|
105084
105501
|
//#region src/cli/machineuser/list.ts
|
|
105502
|
+
/**
|
|
105503
|
+
* Map a MachineUser protobuf message to CLI-friendly info.
|
|
105504
|
+
* @param {MachineUser} user - Machine user resource
|
|
105505
|
+
* @returns {MachineUserInfo} Flattened machine user info
|
|
105506
|
+
*/
|
|
105085
105507
|
function machineUserInfo(user) {
|
|
105086
105508
|
return {
|
|
105087
105509
|
name: user.name,
|
|
@@ -105091,6 +105513,11 @@ function machineUserInfo(user) {
|
|
|
105091
105513
|
updatedAt: user.updatedAt ? timestampDate(user.updatedAt).toISOString() : "N/A"
|
|
105092
105514
|
};
|
|
105093
105515
|
}
|
|
105516
|
+
/**
|
|
105517
|
+
* List machine users for the current application.
|
|
105518
|
+
* @param {ListMachineUsersOptions} [options] - Machine user listing options
|
|
105519
|
+
* @returns {Promise<MachineUserInfo[]>} List of machine users
|
|
105520
|
+
*/
|
|
105094
105521
|
async function listMachineUsers(options) {
|
|
105095
105522
|
const client = await initOperatorClient(await loadAccessToken({
|
|
105096
105523
|
useProfile: true,
|
|
@@ -105137,6 +105564,11 @@ const listCommand$3 = defineCommand({
|
|
|
105137
105564
|
|
|
105138
105565
|
//#endregion
|
|
105139
105566
|
//#region src/cli/machineuser/token.ts
|
|
105567
|
+
/**
|
|
105568
|
+
* Get a machine user access token for the current application.
|
|
105569
|
+
* @param {GetMachineUserTokenOptions} options - Token retrieval options
|
|
105570
|
+
* @returns {Promise<MachineUserTokenInfo>} Machine user token info
|
|
105571
|
+
*/
|
|
105140
105572
|
async function getMachineUserToken(options) {
|
|
105141
105573
|
const client = await initOperatorClient(await loadAccessToken({
|
|
105142
105574
|
useProfile: true,
|
|
@@ -105207,6 +105639,11 @@ const grantTypeToString = (grantType) => {
|
|
|
105207
105639
|
default: return "unknown";
|
|
105208
105640
|
}
|
|
105209
105641
|
};
|
|
105642
|
+
/**
|
|
105643
|
+
* Transform an AuthOAuth2Client into CLI-friendly OAuth2 client info.
|
|
105644
|
+
* @param {AuthOAuth2Client} client - OAuth2 client resource
|
|
105645
|
+
* @returns {OAuth2ClientInfo} Flattened OAuth2 client info
|
|
105646
|
+
*/
|
|
105210
105647
|
function toOAuth2ClientInfo(client) {
|
|
105211
105648
|
return {
|
|
105212
105649
|
name: client.name,
|
|
@@ -105217,6 +105654,11 @@ function toOAuth2ClientInfo(client) {
|
|
|
105217
105654
|
createdAt: client.createdAt ? timestampDate(client.createdAt).toISOString() : "N/A"
|
|
105218
105655
|
};
|
|
105219
105656
|
}
|
|
105657
|
+
/**
|
|
105658
|
+
* Transform an AuthOAuth2Client into OAuth2 client credentials info.
|
|
105659
|
+
* @param {AuthOAuth2Client} client - OAuth2 client resource
|
|
105660
|
+
* @returns {OAuth2ClientCredentials} OAuth2 client credentials
|
|
105661
|
+
*/
|
|
105220
105662
|
function toOAuth2ClientCredentials(client) {
|
|
105221
105663
|
return {
|
|
105222
105664
|
name: client.name,
|
|
@@ -105231,6 +105673,11 @@ function toOAuth2ClientCredentials(client) {
|
|
|
105231
105673
|
|
|
105232
105674
|
//#endregion
|
|
105233
105675
|
//#region src/cli/oauth2client/get.ts
|
|
105676
|
+
/**
|
|
105677
|
+
* Get OAuth2 client credentials for the current application.
|
|
105678
|
+
* @param {GetOAuth2ClientOptions} options - OAuth2 client lookup options
|
|
105679
|
+
* @returns {Promise<OAuth2ClientCredentials>} OAuth2 client credentials
|
|
105680
|
+
*/
|
|
105234
105681
|
async function getOAuth2Client(options) {
|
|
105235
105682
|
const client = await initOperatorClient(await loadAccessToken({
|
|
105236
105683
|
useProfile: true,
|
|
@@ -105286,6 +105733,11 @@ const getCommand$1 = defineCommand({
|
|
|
105286
105733
|
|
|
105287
105734
|
//#endregion
|
|
105288
105735
|
//#region src/cli/oauth2client/list.ts
|
|
105736
|
+
/**
|
|
105737
|
+
* List OAuth2 clients for the current application.
|
|
105738
|
+
* @param {ListOAuth2ClientsOptions} [options] - OAuth2 client listing options
|
|
105739
|
+
* @returns {Promise<OAuth2ClientInfo[]>} List of OAuth2 clients
|
|
105740
|
+
*/
|
|
105289
105741
|
async function listOAuth2Clients(options) {
|
|
105290
105742
|
const client = await initOperatorClient(await loadAccessToken({
|
|
105291
105743
|
useProfile: true,
|
|
@@ -105378,6 +105830,11 @@ async function execRemove(client, workspaceId, application, confirm) {
|
|
|
105378
105830
|
await applyTailorDB(client, tailorDB, "delete-resources");
|
|
105379
105831
|
await applyTailorDB(client, tailorDB, "delete-services");
|
|
105380
105832
|
}
|
|
105833
|
+
/**
|
|
105834
|
+
* Remove all resources managed by the current application.
|
|
105835
|
+
* @param {RemoveOptions} [options] - Remove options
|
|
105836
|
+
* @returns {Promise<void>} Promise that resolves when removal completes
|
|
105837
|
+
*/
|
|
105381
105838
|
async function remove(options) {
|
|
105382
105839
|
const { client, workspaceId, application } = await loadOptions$1(options);
|
|
105383
105840
|
await execRemove(client, workspaceId, application);
|
|
@@ -105450,6 +105907,11 @@ function applicationInfo(app) {
|
|
|
105450
105907
|
updatedAt: app.updateTime ? timestampDate(app.updateTime).toISOString() : "N/A"
|
|
105451
105908
|
};
|
|
105452
105909
|
}
|
|
105910
|
+
/**
|
|
105911
|
+
* Show applied application information for the current workspace.
|
|
105912
|
+
* @param {ShowOptions} [options] - Show options
|
|
105913
|
+
* @returns {Promise<ApplicationInfo>} Application information
|
|
105914
|
+
*/
|
|
105453
105915
|
async function show(options) {
|
|
105454
105916
|
const client = await initOperatorClient(await loadAccessToken({
|
|
105455
105917
|
useProfile: true,
|
|
@@ -105527,6 +105989,11 @@ function formatTableWithHeaders(headers, rows) {
|
|
|
105527
105989
|
return lineIndex === 0 || lineIndex === 1 || lineIndex === rowCount;
|
|
105528
105990
|
} });
|
|
105529
105991
|
}
|
|
105992
|
+
/**
|
|
105993
|
+
* Format an ISO timestamp string as a human-readable relative time.
|
|
105994
|
+
* @param {string} isoString - ISO date string
|
|
105995
|
+
* @returns {string} Relative time (e.g., "5 minutes ago")
|
|
105996
|
+
*/
|
|
105530
105997
|
function humanizeRelativeTime(isoString) {
|
|
105531
105998
|
const date = new Date(isoString);
|
|
105532
105999
|
if (Number.isNaN(date.getTime())) return isoString;
|
|
@@ -105563,6 +106030,11 @@ const waitArgs = {
|
|
|
105563
106030
|
|
|
105564
106031
|
//#endregion
|
|
105565
106032
|
//#region src/cli/workflow/transform.ts
|
|
106033
|
+
/**
|
|
106034
|
+
* Convert a workflow execution status enum to a string.
|
|
106035
|
+
* @param {WorkflowExecution_Status} status - Workflow execution status
|
|
106036
|
+
* @returns {string} String representation of the status
|
|
106037
|
+
*/
|
|
105566
106038
|
function workflowExecutionStatusToString(status) {
|
|
105567
106039
|
switch (status) {
|
|
105568
106040
|
case WorkflowExecution_Status.PENDING: return "PENDING";
|
|
@@ -105573,6 +106045,11 @@ function workflowExecutionStatusToString(status) {
|
|
|
105573
106045
|
default: return "UNSPECIFIED";
|
|
105574
106046
|
}
|
|
105575
106047
|
}
|
|
106048
|
+
/**
|
|
106049
|
+
* Convert a workflow job execution status enum to a string.
|
|
106050
|
+
* @param {WorkflowJobExecution_Status} status - Workflow job execution status
|
|
106051
|
+
* @returns {string} String representation of the status
|
|
106052
|
+
*/
|
|
105576
106053
|
function workflowJobExecutionStatusToString(status) {
|
|
105577
106054
|
switch (status) {
|
|
105578
106055
|
case WorkflowJobExecution_Status.RUNNING: return "RUNNING";
|
|
@@ -105582,6 +106059,11 @@ function workflowJobExecutionStatusToString(status) {
|
|
|
105582
106059
|
default: return "UNSPECIFIED";
|
|
105583
106060
|
}
|
|
105584
106061
|
}
|
|
106062
|
+
/**
|
|
106063
|
+
* Convert a Workflow proto to CLI-friendly list info.
|
|
106064
|
+
* @param {Workflow} workflow - Workflow resource
|
|
106065
|
+
* @returns {WorkflowListInfo} Flattened workflow list info
|
|
106066
|
+
*/
|
|
105585
106067
|
function toWorkflowListInfo(workflow) {
|
|
105586
106068
|
return {
|
|
105587
106069
|
name: workflow.name,
|
|
@@ -105590,6 +106072,11 @@ function toWorkflowListInfo(workflow) {
|
|
|
105590
106072
|
updatedAt: workflow.updatedAt ? timestampDate(workflow.updatedAt).toISOString() : "N/A"
|
|
105591
106073
|
};
|
|
105592
106074
|
}
|
|
106075
|
+
/**
|
|
106076
|
+
* Convert a Workflow proto to detailed workflow info for CLI output.
|
|
106077
|
+
* @param {Workflow} workflow - Workflow resource
|
|
106078
|
+
* @returns {WorkflowInfo} Detailed workflow info
|
|
106079
|
+
*/
|
|
105593
106080
|
function toWorkflowInfo(workflow) {
|
|
105594
106081
|
const jobFunctions = {};
|
|
105595
106082
|
for (const [name$1, version$4] of Object.entries(workflow.jobFunctions)) jobFunctions[name$1] = version$4.toString();
|
|
@@ -105602,6 +106089,11 @@ function toWorkflowInfo(workflow) {
|
|
|
105602
106089
|
updatedAt: workflow.updatedAt ? timestampDate(workflow.updatedAt).toISOString() : "N/A"
|
|
105603
106090
|
};
|
|
105604
106091
|
}
|
|
106092
|
+
/**
|
|
106093
|
+
* Convert a WorkflowJobExecution proto to CLI-friendly job execution info.
|
|
106094
|
+
* @param {WorkflowJobExecution} jobExecution - Workflow job execution resource
|
|
106095
|
+
* @returns {WorkflowJobExecutionInfo} Flattened job execution info
|
|
106096
|
+
*/
|
|
105605
106097
|
function toWorkflowJobExecutionInfo(jobExecution) {
|
|
105606
106098
|
return {
|
|
105607
106099
|
id: jobExecution.id,
|
|
@@ -105612,6 +106104,11 @@ function toWorkflowJobExecutionInfo(jobExecution) {
|
|
|
105612
106104
|
finishedAt: jobExecution.finishedAt ? timestampDate(jobExecution.finishedAt).toISOString() : "N/A"
|
|
105613
106105
|
};
|
|
105614
106106
|
}
|
|
106107
|
+
/**
|
|
106108
|
+
* Convert a WorkflowExecution proto to CLI-friendly execution info.
|
|
106109
|
+
* @param {WorkflowExecution} execution - Workflow execution resource
|
|
106110
|
+
* @returns {WorkflowExecutionInfo} Flattened execution info
|
|
106111
|
+
*/
|
|
105615
106112
|
function toWorkflowExecutionInfo(execution) {
|
|
105616
106113
|
return {
|
|
105617
106114
|
id: execution.id,
|
|
@@ -105652,6 +106149,11 @@ function parseStatus(status) {
|
|
|
105652
106149
|
default: throw new Error(`Invalid status: ${status}. Valid values: PENDING, PENDING_RESUME, RUNNING, SUCCESS, FAILED`);
|
|
105653
106150
|
}
|
|
105654
106151
|
}
|
|
106152
|
+
/**
|
|
106153
|
+
* List workflow executions with optional filters.
|
|
106154
|
+
* @param {ListWorkflowExecutionsOptions} [options] - Workflow execution listing options
|
|
106155
|
+
* @returns {Promise<WorkflowExecutionInfo[]>} List of workflow executions
|
|
106156
|
+
*/
|
|
105655
106157
|
async function listWorkflowExecutions(options) {
|
|
105656
106158
|
const client = await initOperatorClient(await loadAccessToken({
|
|
105657
106159
|
useProfile: true,
|
|
@@ -105692,6 +106194,11 @@ async function listWorkflowExecutions(options) {
|
|
|
105692
106194
|
return [executions, nextPageToken];
|
|
105693
106195
|
})).map(toWorkflowExecutionInfo);
|
|
105694
106196
|
}
|
|
106197
|
+
/**
|
|
106198
|
+
* Get a single workflow execution with optional logs.
|
|
106199
|
+
* @param {GetWorkflowExecutionOptions} options - Workflow execution lookup options
|
|
106200
|
+
* @returns {Promise<GetWorkflowExecutionResult>} Workflow execution with optional logs
|
|
106201
|
+
*/
|
|
105695
106202
|
async function getWorkflowExecution(options) {
|
|
105696
106203
|
const client = await initOperatorClient(await loadAccessToken({
|
|
105697
106204
|
useProfile: true,
|
|
@@ -105774,6 +106281,11 @@ async function waitWithSpinner(waitFn, interval, json) {
|
|
|
105774
106281
|
spinner?.stop();
|
|
105775
106282
|
}
|
|
105776
106283
|
}
|
|
106284
|
+
/**
|
|
106285
|
+
* Print a workflow execution and its logs in a human-readable format.
|
|
106286
|
+
* @param {WorkflowExecutionDetailInfo} execution - Workflow execution detail info
|
|
106287
|
+
* @returns {void}
|
|
106288
|
+
*/
|
|
105777
106289
|
function printExecutionWithLogs(execution) {
|
|
105778
106290
|
const summaryData = [
|
|
105779
106291
|
["id", execution.id],
|
|
@@ -105867,6 +106379,13 @@ const executionsCommand = defineCommand({
|
|
|
105867
106379
|
|
|
105868
106380
|
//#endregion
|
|
105869
106381
|
//#region src/cli/workflow/get.ts
|
|
106382
|
+
/**
|
|
106383
|
+
* Resolve a workflow definition by name.
|
|
106384
|
+
* @param {Awaited<ReturnType<typeof initOperatorClient>>} client - Operator client
|
|
106385
|
+
* @param {string} workspaceId - Workspace ID
|
|
106386
|
+
* @param {string} name - Workflow name
|
|
106387
|
+
* @returns {Promise<unknown>} Resolved workflow
|
|
106388
|
+
*/
|
|
105870
106389
|
async function resolveWorkflow(client, workspaceId, name$1) {
|
|
105871
106390
|
const { workflow } = await client.getWorkflowByName({
|
|
105872
106391
|
workspaceId,
|
|
@@ -105875,6 +106394,11 @@ async function resolveWorkflow(client, workspaceId, name$1) {
|
|
|
105875
106394
|
if (!workflow) throw new Error(`Workflow '${name$1}' not found.`);
|
|
105876
106395
|
return workflow;
|
|
105877
106396
|
}
|
|
106397
|
+
/**
|
|
106398
|
+
* Get a workflow by name and return CLI-friendly info.
|
|
106399
|
+
* @param {GetWorkflowOptions} options - Workflow lookup options
|
|
106400
|
+
* @returns {Promise<WorkflowInfo>} Workflow information
|
|
106401
|
+
*/
|
|
105878
106402
|
async function getWorkflow(options) {
|
|
105879
106403
|
const client = await initOperatorClient(await loadAccessToken({
|
|
105880
106404
|
useProfile: true,
|
|
@@ -105914,6 +106438,11 @@ const getCommand = defineCommand({
|
|
|
105914
106438
|
|
|
105915
106439
|
//#endregion
|
|
105916
106440
|
//#region src/cli/workflow/list.ts
|
|
106441
|
+
/**
|
|
106442
|
+
* List workflows in the workspace and return CLI-friendly info.
|
|
106443
|
+
* @param {ListWorkflowsOptions} [options] - Workflow listing options
|
|
106444
|
+
* @returns {Promise<WorkflowListInfo[]>} List of workflows
|
|
106445
|
+
*/
|
|
105917
106446
|
async function listWorkflows(options) {
|
|
105918
106447
|
const client = await initOperatorClient(await loadAccessToken({
|
|
105919
106448
|
useProfile: true,
|
|
@@ -105988,6 +106517,11 @@ function colorizeStatus(status) {
|
|
|
105988
106517
|
default: return statusText;
|
|
105989
106518
|
}
|
|
105990
106519
|
}
|
|
106520
|
+
/**
|
|
106521
|
+
* Wait for a workflow execution to reach a terminal state, optionally showing progress.
|
|
106522
|
+
* @param {WaitForExecutionOptions} options - Wait options
|
|
106523
|
+
* @returns {Promise<WorkflowExecutionInfo>} Final workflow execution info
|
|
106524
|
+
*/
|
|
105991
106525
|
async function waitForExecution(options) {
|
|
105992
106526
|
const { client, workspaceId, executionId, interval, showProgress, trackJobs } = options;
|
|
105993
106527
|
let lastStatus;
|
|
@@ -106044,6 +106578,11 @@ function getRunningJobs(execution) {
|
|
|
106044
106578
|
function isTerminalStatus(status) {
|
|
106045
106579
|
return status === WorkflowExecution_Status.SUCCESS || status === WorkflowExecution_Status.FAILED || status === WorkflowExecution_Status.PENDING_RESUME;
|
|
106046
106580
|
}
|
|
106581
|
+
/**
|
|
106582
|
+
* Start a workflow and return a handle to wait for completion.
|
|
106583
|
+
* @param {StartWorkflowOptions} options - Start options
|
|
106584
|
+
* @returns {Promise<StartWorkflowResultWithWait>} Start result with wait helper
|
|
106585
|
+
*/
|
|
106047
106586
|
async function startWorkflow(options) {
|
|
106048
106587
|
const client = await initOperatorClient(await loadAccessToken({
|
|
106049
106588
|
useProfile: true,
|
|
@@ -106140,6 +106679,11 @@ const startCommand = defineCommand({
|
|
|
106140
106679
|
|
|
106141
106680
|
//#endregion
|
|
106142
106681
|
//#region src/cli/workflow/resume.ts
|
|
106682
|
+
/**
|
|
106683
|
+
* Resume a suspended workflow execution and return a handle to wait for completion.
|
|
106684
|
+
* @param {ResumeWorkflowOptions} options - Resume options
|
|
106685
|
+
* @returns {Promise<ResumeWorkflowResultWithWait>} Resume result with wait helper
|
|
106686
|
+
*/
|
|
106143
106687
|
async function resumeWorkflow(options) {
|
|
106144
106688
|
const client = await initOperatorClient(await loadAccessToken({
|
|
106145
106689
|
useProfile: true,
|
|
@@ -106242,6 +106786,11 @@ const validateRegion = async (region, client) => {
|
|
|
106242
106786
|
const availableRegions = await client.listAvailableWorkspaceRegions({});
|
|
106243
106787
|
if (!availableRegions.regions.includes(region)) throw new Error(`Region must be one of: ${availableRegions.regions.join(", ")}.`);
|
|
106244
106788
|
};
|
|
106789
|
+
/**
|
|
106790
|
+
* Create a new workspace with the given options.
|
|
106791
|
+
* @param {CreateWorkspaceOptions} options - Workspace creation options
|
|
106792
|
+
* @returns {Promise<WorkspaceInfo>} Created workspace info
|
|
106793
|
+
*/
|
|
106245
106794
|
async function createWorkspace(options) {
|
|
106246
106795
|
const result = createWorkspaceOptionsSchema.safeParse(options);
|
|
106247
106796
|
if (!result.success) throw new Error(result.error.issues[0].message);
|
|
@@ -106319,6 +106868,11 @@ async function loadOptions(options) {
|
|
|
106319
106868
|
workspaceId: result.data.workspaceId
|
|
106320
106869
|
};
|
|
106321
106870
|
}
|
|
106871
|
+
/**
|
|
106872
|
+
* Delete a workspace by ID.
|
|
106873
|
+
* @param {DeleteWorkspaceOptions} options - Workspace deletion options
|
|
106874
|
+
* @returns {Promise<void>} Promise that resolves when deletion completes
|
|
106875
|
+
*/
|
|
106322
106876
|
async function deleteWorkspace(options) {
|
|
106323
106877
|
const { client, workspaceId } = await loadOptions(options);
|
|
106324
106878
|
await client.deleteWorkspace({ workspaceId });
|
|
@@ -106365,6 +106919,11 @@ const deleteCommand = defineCommand({
|
|
|
106365
106919
|
//#endregion
|
|
106366
106920
|
//#region src/cli/workspace/list.ts
|
|
106367
106921
|
const limitSchema = z.coerce.number().int().positive().optional();
|
|
106922
|
+
/**
|
|
106923
|
+
* List workspaces with an optional limit.
|
|
106924
|
+
* @param {ListWorkspacesOptions} [options] - Workspace listing options
|
|
106925
|
+
* @returns {Promise<WorkspaceInfo[]>} List of workspaces
|
|
106926
|
+
*/
|
|
106368
106927
|
async function listWorkspaces(options) {
|
|
106369
106928
|
const limit = options?.limit;
|
|
106370
106929
|
const hasLimit = limit !== void 0;
|
|
@@ -106419,4 +106978,4 @@ const listCommand = defineCommand({
|
|
|
106419
106978
|
|
|
106420
106979
|
//#endregion
|
|
106421
106980
|
export { withCommonArgs as $, generate as A, loadWorkspaceId as B, listOAuth2Clients as C, tokenCommand as D, getMachineUserToken as E, loadConfig as F, initOAuth2Client as G, writePlatformConfig as H, apiCall as I, PATScope as J, initOperatorClient as K, apiCommand as L, apply as M, applyCommand as N, listCommand$3 as O, generateUserTypes as P, jsonArgs as Q, fetchLatestToken as R, listCommand$2 as S, getOAuth2Client as T, fetchAll as U, readPlatformConfig as V, fetchUserInfo as W, confirmationArgs as X, commonArgs as Y, deploymentArgs as Z, listWorkflowExecutions as _, createCommand as a, remove as b, resumeWorkflow as c, listCommand$1 as d, workspaceArgs as et, listWorkflows as f, getWorkflowExecution as g, executionsCommand as h, deleteWorkspace as i, generateCommand as j, listMachineUsers as k, startCommand as l, getWorkflow as m, listWorkspaces as n, createWorkspace as o, getCommand as p, readPackageJson as q, deleteCommand as r, resumeCommand as s, listCommand as t, logger as tt, startWorkflow as u, show as v, getCommand$1 as w, removeCommand as x, showCommand as y, loadAccessToken as z };
|
|
106422
|
-
//# sourceMappingURL=list-
|
|
106981
|
+
//# sourceMappingURL=list-nW4EfF7C.mjs.map
|