@tailor-platform/sdk 0.12.0 → 0.12.2
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 +33 -0
- package/dist/cli/api.d.mts +39 -3
- package/dist/cli/api.mjs +3 -3
- package/dist/cli/api.mjs.map +1 -1
- package/dist/cli/index.d.mts +1 -1
- package/dist/cli/index.mjs +20 -3
- package/dist/cli/index.mjs.map +1 -1
- package/dist/configure/index.d.mts +4 -4
- package/dist/configure/index.mjs +1 -1
- package/dist/configure/index.mjs.map +1 -1
- package/dist/{index-CvaR3wBO.d.mts → index-IUg1mdFZ.d.mts} +6 -10
- package/dist/{job-CSwByDTq.mjs → job-B8jI-poE.mjs} +19 -18
- package/dist/job-B8jI-poE.mjs.map +1 -0
- package/dist/{token-C2dypdqc.mjs → list-DeXjmUU0.mjs} +185 -19
- package/dist/list-DeXjmUU0.mjs.map +1 -0
- package/dist/{types-CWvnDV8C.d.mts → types-CMTHSsxH.d.mts} +9 -13
- package/dist/{plugin-generated.d.ts → user-defined.d.ts} +4 -6
- package/dist/utils/test/index.d.mts +3 -3
- package/docs/cli-reference.md +65 -0
- package/package.json +2 -3
- package/postinstall.mjs +6 -8
- package/dist/job-CSwByDTq.mjs.map +0 -1
- package/dist/token-C2dypdqc.mjs.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WORKFLOW_JOB_BRAND, getDistDir, tailorUserMap } from "./job-
|
|
1
|
+
import { WORKFLOW_JOB_BRAND, getDistDir, tailorUserMap } from "./job-B8jI-poE.mjs";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import { defineCommand } from "citty";
|
|
4
4
|
import * as path from "node:path";
|
|
@@ -2214,32 +2214,30 @@ function extractAttributesFromConfig(config) {
|
|
|
2214
2214
|
return collectAttributesFromConfig(config);
|
|
2215
2215
|
}
|
|
2216
2216
|
function generateTypeDefinition(attributeMap, attributeList, env) {
|
|
2217
|
-
const mapFields = attributeMap ? Object.entries(attributeMap).map(([key, value]) => `
|
|
2217
|
+
const mapFields = attributeMap ? Object.entries(attributeMap).map(([key, value]) => ` ${key}: ${value};`).join("\n") : "";
|
|
2218
2218
|
const mapBody = !attributeMap || Object.keys(attributeMap).length === 0 ? "{}" : `{
|
|
2219
2219
|
${mapFields}
|
|
2220
|
-
|
|
2220
|
+
}`;
|
|
2221
2221
|
const listBody = `{
|
|
2222
|
-
|
|
2223
|
-
|
|
2222
|
+
__tuple?: ${attributeList ? `[${attributeList.map(() => "string").join(", ")}]` : "[]"};
|
|
2223
|
+
}`;
|
|
2224
2224
|
const envFields = env ? Object.entries(env).map(([key, value]) => {
|
|
2225
2225
|
const valueType = typeof value === "string" ? `"${value}"` : String(value);
|
|
2226
|
-
return `
|
|
2226
|
+
return ` ${key}: ${valueType};`;
|
|
2227
2227
|
}).join("\n") : "";
|
|
2228
2228
|
const envBody = !env || Object.keys(env).length === 0 ? "{}" : `{
|
|
2229
2229
|
${envFields}
|
|
2230
|
-
|
|
2230
|
+
}`;
|
|
2231
2231
|
return ml`
|
|
2232
2232
|
/* eslint-disable @typescript-eslint/no-empty-object-type */
|
|
2233
2233
|
// This file is auto-generated by @tailor-platform/sdk
|
|
2234
2234
|
// Do not edit this file manually
|
|
2235
2235
|
// Regenerated automatically when running 'tailor-sdk apply' or 'tailor-sdk generate'
|
|
2236
2236
|
|
|
2237
|
-
declare
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
interface Env ${envBody}
|
|
2242
|
-
}
|
|
2237
|
+
declare module "@tailor-platform/sdk" {
|
|
2238
|
+
interface AttributeMap ${mapBody}
|
|
2239
|
+
interface AttributeList ${listBody}
|
|
2240
|
+
interface Env ${envBody}
|
|
2243
2241
|
}
|
|
2244
2242
|
|
|
2245
2243
|
export {};
|
|
@@ -2279,8 +2277,8 @@ function resolveTypeDefinitionPath(configPath) {
|
|
|
2279
2277
|
if (typePath) return path.resolve(process.cwd(), typePath);
|
|
2280
2278
|
const configDir = path.dirname(path.resolve(configPath));
|
|
2281
2279
|
const packageDir = resolvePackageDirectory(configDir);
|
|
2282
|
-
if (!packageDir) return path.join(configDir, "node_modules", "@tailor-platform", "sdk", "dist", "
|
|
2283
|
-
return path.join(packageDir, "dist", "
|
|
2280
|
+
if (!packageDir) return path.join(configDir, "node_modules", "@tailor-platform", "sdk", "dist", "user-defined.d.ts");
|
|
2281
|
+
return path.join(packageDir, "dist", "user-defined.d.ts");
|
|
2284
2282
|
}
|
|
2285
2283
|
async function generateUserTypes(config, configPath) {
|
|
2286
2284
|
try {
|
|
@@ -6943,7 +6941,7 @@ async function workspaceList() {
|
|
|
6943
6941
|
return [workspaces, nextPageToken];
|
|
6944
6942
|
})).map(workspaceInfo);
|
|
6945
6943
|
}
|
|
6946
|
-
const listCommand$
|
|
6944
|
+
const listCommand$2 = defineCommand({
|
|
6947
6945
|
meta: {
|
|
6948
6946
|
name: "list",
|
|
6949
6947
|
description: "List all Tailor Platform workspaces"
|
|
@@ -7050,7 +7048,7 @@ async function machineUserList(options) {
|
|
|
7050
7048
|
return [machineUsers, nextPageToken];
|
|
7051
7049
|
})).map(machineUserInfo);
|
|
7052
7050
|
}
|
|
7053
|
-
const listCommand = defineCommand({
|
|
7051
|
+
const listCommand$1 = defineCommand({
|
|
7054
7052
|
meta: {
|
|
7055
7053
|
name: "list",
|
|
7056
7054
|
description: "List all machine users"
|
|
@@ -7168,5 +7166,173 @@ const tokenCommand = defineCommand({
|
|
|
7168
7166
|
});
|
|
7169
7167
|
|
|
7170
7168
|
//#endregion
|
|
7171
|
-
|
|
7172
|
-
|
|
7169
|
+
//#region src/cli/oauth2client/transform.ts
|
|
7170
|
+
const grantTypeToString = (grantType) => {
|
|
7171
|
+
switch (grantType) {
|
|
7172
|
+
case AuthOAuth2Client_GrantType.AUTHORIZATION_CODE: return "authorization_code";
|
|
7173
|
+
case AuthOAuth2Client_GrantType.REFRESH_TOKEN: return "refresh_token";
|
|
7174
|
+
default: return "unknown";
|
|
7175
|
+
}
|
|
7176
|
+
};
|
|
7177
|
+
function toOAuth2ClientInfo(client) {
|
|
7178
|
+
return {
|
|
7179
|
+
name: client.name,
|
|
7180
|
+
description: client.description,
|
|
7181
|
+
clientId: client.clientId,
|
|
7182
|
+
grantTypes: client.grantTypes.map(grantTypeToString),
|
|
7183
|
+
redirectUris: client.redirectUris,
|
|
7184
|
+
createdAt: client.createdAt ? timestampDate(client.createdAt).toISOString() : "N/A"
|
|
7185
|
+
};
|
|
7186
|
+
}
|
|
7187
|
+
function toOAuth2ClientCredentials(client) {
|
|
7188
|
+
return {
|
|
7189
|
+
name: client.name,
|
|
7190
|
+
description: client.description,
|
|
7191
|
+
clientId: client.clientId,
|
|
7192
|
+
clientSecret: client.clientSecret,
|
|
7193
|
+
grantTypes: client.grantTypes.map(grantTypeToString),
|
|
7194
|
+
redirectUris: client.redirectUris,
|
|
7195
|
+
createdAt: client.createdAt ? timestampDate(client.createdAt).toISOString() : "N/A"
|
|
7196
|
+
};
|
|
7197
|
+
}
|
|
7198
|
+
|
|
7199
|
+
//#endregion
|
|
7200
|
+
//#region src/cli/oauth2client/get.ts
|
|
7201
|
+
async function oauth2ClientGet(options) {
|
|
7202
|
+
const accessToken = await loadAccessToken({
|
|
7203
|
+
useProfile: true,
|
|
7204
|
+
profile: options.profile
|
|
7205
|
+
});
|
|
7206
|
+
const client = await initOperatorClient(accessToken);
|
|
7207
|
+
const workspaceId = loadWorkspaceId({
|
|
7208
|
+
workspaceId: options.workspaceId,
|
|
7209
|
+
profile: options.profile
|
|
7210
|
+
});
|
|
7211
|
+
const configPath = loadConfigPath(options.configPath);
|
|
7212
|
+
const { config } = await loadConfig(configPath);
|
|
7213
|
+
const { application } = await client.getApplication({
|
|
7214
|
+
workspaceId,
|
|
7215
|
+
applicationName: config.name
|
|
7216
|
+
});
|
|
7217
|
+
if (!application?.authNamespace) throw new Error(`Application ${config.name} does not have an auth configuration.`);
|
|
7218
|
+
try {
|
|
7219
|
+
const { oauth2Client } = await client.getAuthOAuth2Client({
|
|
7220
|
+
workspaceId,
|
|
7221
|
+
namespaceName: application.authNamespace,
|
|
7222
|
+
name: options.name
|
|
7223
|
+
});
|
|
7224
|
+
return toOAuth2ClientCredentials(oauth2Client);
|
|
7225
|
+
} catch (error) {
|
|
7226
|
+
if (error instanceof ConnectError && error.code === Code.NotFound) throw new Error(`OAuth2 client '${options.name}' not found.`);
|
|
7227
|
+
throw error;
|
|
7228
|
+
}
|
|
7229
|
+
}
|
|
7230
|
+
const getCommand = defineCommand({
|
|
7231
|
+
meta: {
|
|
7232
|
+
name: "get",
|
|
7233
|
+
description: "Get OAuth2 client credentials"
|
|
7234
|
+
},
|
|
7235
|
+
args: {
|
|
7236
|
+
...commonArgs,
|
|
7237
|
+
...formatArgs,
|
|
7238
|
+
name: {
|
|
7239
|
+
type: "positional",
|
|
7240
|
+
description: "OAuth2 client name",
|
|
7241
|
+
required: true
|
|
7242
|
+
},
|
|
7243
|
+
"workspace-id": {
|
|
7244
|
+
type: "string",
|
|
7245
|
+
description: "Workspace ID",
|
|
7246
|
+
alias: "w"
|
|
7247
|
+
},
|
|
7248
|
+
profile: {
|
|
7249
|
+
type: "string",
|
|
7250
|
+
description: "Workspace profile",
|
|
7251
|
+
alias: "p"
|
|
7252
|
+
},
|
|
7253
|
+
config: {
|
|
7254
|
+
type: "string",
|
|
7255
|
+
description: "Path to SDK config file",
|
|
7256
|
+
alias: "c",
|
|
7257
|
+
default: "tailor.config.ts"
|
|
7258
|
+
}
|
|
7259
|
+
},
|
|
7260
|
+
run: withCommonArgs(async (args) => {
|
|
7261
|
+
const format = parseFormat(args.format);
|
|
7262
|
+
const credentials = await oauth2ClientGet({
|
|
7263
|
+
name: args.name,
|
|
7264
|
+
workspaceId: args["workspace-id"],
|
|
7265
|
+
profile: args.profile,
|
|
7266
|
+
configPath: args.config
|
|
7267
|
+
});
|
|
7268
|
+
printWithFormat(credentials, format);
|
|
7269
|
+
})
|
|
7270
|
+
});
|
|
7271
|
+
|
|
7272
|
+
//#endregion
|
|
7273
|
+
//#region src/cli/oauth2client/list.ts
|
|
7274
|
+
async function oauth2ClientList(options) {
|
|
7275
|
+
const accessToken = await loadAccessToken({
|
|
7276
|
+
useProfile: true,
|
|
7277
|
+
profile: options?.profile
|
|
7278
|
+
});
|
|
7279
|
+
const client = await initOperatorClient(accessToken);
|
|
7280
|
+
const workspaceId = loadWorkspaceId({
|
|
7281
|
+
workspaceId: options?.workspaceId,
|
|
7282
|
+
profile: options?.profile
|
|
7283
|
+
});
|
|
7284
|
+
const configPath = loadConfigPath(options?.configPath);
|
|
7285
|
+
const { config } = await loadConfig(configPath);
|
|
7286
|
+
const { application } = await client.getApplication({
|
|
7287
|
+
workspaceId,
|
|
7288
|
+
applicationName: config.name
|
|
7289
|
+
});
|
|
7290
|
+
if (!application?.authNamespace) throw new Error(`Application ${config.name} does not have an auth configuration.`);
|
|
7291
|
+
return (await fetchAll(async (pageToken) => {
|
|
7292
|
+
const { oauth2Clients, nextPageToken } = await client.listAuthOAuth2Clients({
|
|
7293
|
+
workspaceId,
|
|
7294
|
+
pageToken,
|
|
7295
|
+
namespaceName: application.authNamespace
|
|
7296
|
+
});
|
|
7297
|
+
return [oauth2Clients, nextPageToken];
|
|
7298
|
+
})).map(toOAuth2ClientInfo);
|
|
7299
|
+
}
|
|
7300
|
+
const listCommand = defineCommand({
|
|
7301
|
+
meta: {
|
|
7302
|
+
name: "list",
|
|
7303
|
+
description: "List all OAuth2 clients"
|
|
7304
|
+
},
|
|
7305
|
+
args: {
|
|
7306
|
+
...commonArgs,
|
|
7307
|
+
...formatArgs,
|
|
7308
|
+
"workspace-id": {
|
|
7309
|
+
type: "string",
|
|
7310
|
+
description: "Workspace ID",
|
|
7311
|
+
alias: "w"
|
|
7312
|
+
},
|
|
7313
|
+
profile: {
|
|
7314
|
+
type: "string",
|
|
7315
|
+
description: "Workspace profile",
|
|
7316
|
+
alias: "p"
|
|
7317
|
+
},
|
|
7318
|
+
config: {
|
|
7319
|
+
type: "string",
|
|
7320
|
+
description: "Path to SDK config file",
|
|
7321
|
+
alias: "c",
|
|
7322
|
+
default: "tailor.config.ts"
|
|
7323
|
+
}
|
|
7324
|
+
},
|
|
7325
|
+
run: withCommonArgs(async (args) => {
|
|
7326
|
+
const format = parseFormat(args.format);
|
|
7327
|
+
const oauth2Clients = await oauth2ClientList({
|
|
7328
|
+
workspaceId: args["workspace-id"],
|
|
7329
|
+
profile: args.profile,
|
|
7330
|
+
configPath: args.config
|
|
7331
|
+
});
|
|
7332
|
+
printWithFormat(oauth2Clients, format);
|
|
7333
|
+
})
|
|
7334
|
+
});
|
|
7335
|
+
|
|
7336
|
+
//#endregion
|
|
7337
|
+
export { PATScope, apply, applyCommand, commonArgs, createCommand, deleteCommand, fetchAll, fetchLatestToken, fetchUserInfo, formatArgs, generate, generateCommand, generateUserTypes, getCommand, initOAuth2Client, initOperatorClient, listCommand, listCommand$1, listCommand$2, loadAccessToken, loadConfig, loadConfigPath, loadWorkspaceId, machineUserList, machineUserToken, oauth2ClientGet, oauth2ClientList, parseFormat, printWithFormat, readPackageJson, readPlatformConfig, remove, removeCommand, show, showCommand, tokenCommand, withCommonArgs, workspaceCreate, workspaceDelete, workspaceList, writePlatformConfig };
|
|
7338
|
+
//# sourceMappingURL=list-DeXjmUU0.mjs.map
|