@tailor-platform/sdk 0.0.1 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +790 -0
- package/LICENSE +21 -0
- package/README.md +8 -41
- package/dist/auth-Di3vQUrT.mjs +743 -0
- package/dist/cli/api.d.mts +213 -0
- package/dist/cli/api.mjs +4 -0
- package/dist/cli/index.d.mts +3 -0
- package/dist/cli/index.mjs +996 -0
- package/dist/configure/index.d.mts +5 -0
- package/dist/configure/index.mjs +108 -0
- package/dist/index-BWN4RmSt.d.mts +232 -0
- package/dist/plugin-generated.d.ts +14 -0
- package/dist/token-B9YK0eTP.mjs +5498 -0
- package/dist/types-DWQxkbYl.d.mts +1389 -0
- package/dist/utils/test/index.d.mts +40 -0
- package/dist/utils/test/index.mjs +63 -0
- package/docs/cli-reference.md +484 -0
- package/docs/configuration.md +132 -0
- package/docs/core-concepts.md +504 -0
- package/docs/quickstart.md +96 -0
- package/docs/testing.md +298 -0
- package/package.json +87 -8
- package/postinstall.mjs +87 -0
|
@@ -0,0 +1,996 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { PATScope, applyCommand, commonArgs, createCommand, deleteCommand, fetchAll, fetchLatestToken, formatArgs, generateCommand, initOperatorClient, listCommand as listCommand$4, listCommand$1 as listCommand, loadAccessToken, loadConfig, loadConfigPath, loadWorkspaceId, parseFormat, printWithFormat, readPlatformConfig, showCommand, tokenCommand, userAgent, withCommonArgs, writePlatformConfig } from "../token-B9YK0eTP.mjs";
|
|
3
|
+
import "../auth-Di3vQUrT.mjs";
|
|
4
|
+
import { register } from "node:module";
|
|
5
|
+
import { defineCommand, runCommand, runMain } from "citty";
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
import { readPackageJSON } from "pkg-types";
|
|
8
|
+
import ml from "multiline-ts";
|
|
9
|
+
import { consola } from "consola";
|
|
10
|
+
import { spawnSync } from "node:child_process";
|
|
11
|
+
import * as crypto from "node:crypto";
|
|
12
|
+
import * as http from "node:http";
|
|
13
|
+
import open from "open";
|
|
14
|
+
import chalk from "chalk";
|
|
15
|
+
|
|
16
|
+
//#region src/cli/init.ts
|
|
17
|
+
const detectPackageManager = () => {
|
|
18
|
+
const availablePMs = [
|
|
19
|
+
"npm",
|
|
20
|
+
"yarn",
|
|
21
|
+
"pnpm"
|
|
22
|
+
];
|
|
23
|
+
const userAgent$1 = process.env.npm_config_user_agent;
|
|
24
|
+
if (!userAgent$1) return;
|
|
25
|
+
const [name] = userAgent$1.split("/");
|
|
26
|
+
if (!availablePMs.includes(name)) return;
|
|
27
|
+
return name;
|
|
28
|
+
};
|
|
29
|
+
const initCommand = defineCommand({
|
|
30
|
+
meta: {
|
|
31
|
+
name: "init",
|
|
32
|
+
description: "Initialize a new project using create-sdk"
|
|
33
|
+
},
|
|
34
|
+
args: {
|
|
35
|
+
...commonArgs,
|
|
36
|
+
name: {
|
|
37
|
+
type: "positional",
|
|
38
|
+
description: "Project name",
|
|
39
|
+
required: false
|
|
40
|
+
},
|
|
41
|
+
template: {
|
|
42
|
+
type: "string",
|
|
43
|
+
description: "Template name",
|
|
44
|
+
required: false,
|
|
45
|
+
alias: "t"
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
run: withCommonArgs(async (args) => {
|
|
49
|
+
const packageJson$1 = await readPackageJSON(import.meta.url);
|
|
50
|
+
const version = packageJson$1.version && packageJson$1.version !== "0.0.0" ? packageJson$1.version : "latest";
|
|
51
|
+
let packageManager = detectPackageManager();
|
|
52
|
+
if (!packageManager) {
|
|
53
|
+
consola.warn("⚠️ Could not detect package manager, defaulting to npm");
|
|
54
|
+
packageManager = "npm";
|
|
55
|
+
}
|
|
56
|
+
const initArgs = [
|
|
57
|
+
"create",
|
|
58
|
+
`@tailor-platform/sdk@${version}`,
|
|
59
|
+
...args.name ? [args.name] : [],
|
|
60
|
+
...packageManager === "npm" ? ["--"] : [],
|
|
61
|
+
...args.template ? ["--template", args.template] : []
|
|
62
|
+
];
|
|
63
|
+
consola.log(`Running: ${packageManager} ${initArgs.join(" ")}`);
|
|
64
|
+
spawnSync(packageManager, initArgs, { stdio: "inherit" });
|
|
65
|
+
})
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
//#endregion
|
|
69
|
+
//#region src/cli/login.ts
|
|
70
|
+
const CALLBACK_PORT = 8085;
|
|
71
|
+
const CALLBACK_URL = `http://tailorctl.tailor.tech:${CALLBACK_PORT}/callback`;
|
|
72
|
+
const PLATFORM_AUTH_URL = "https://api.tailor.tech/auth/platform";
|
|
73
|
+
const LOGIN_URL = PLATFORM_AUTH_URL + "/login";
|
|
74
|
+
const TOKEN_URL = PLATFORM_AUTH_URL + "/token";
|
|
75
|
+
const USER_INFO_URL = PLATFORM_AUTH_URL + "/userinfo";
|
|
76
|
+
const randomState = () => {
|
|
77
|
+
return crypto.randomBytes(32).toString("base64url");
|
|
78
|
+
};
|
|
79
|
+
const exchangeCode = async (code) => {
|
|
80
|
+
const body = new URLSearchParams();
|
|
81
|
+
body.append("code", code);
|
|
82
|
+
body.append("redirect_uri", CALLBACK_URL);
|
|
83
|
+
const resp = await fetch(TOKEN_URL, {
|
|
84
|
+
method: "POST",
|
|
85
|
+
headers: {
|
|
86
|
+
"User-Agent": await userAgent(),
|
|
87
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
88
|
+
},
|
|
89
|
+
body
|
|
90
|
+
});
|
|
91
|
+
if (!resp.ok) throw new Error(`Failed to exchange code: ${resp.statusText}`);
|
|
92
|
+
const rawData = await resp.json();
|
|
93
|
+
return z.object({
|
|
94
|
+
access_token: z.string(),
|
|
95
|
+
refresh_token: z.string(),
|
|
96
|
+
expires_in: z.number()
|
|
97
|
+
}).parse(rawData);
|
|
98
|
+
};
|
|
99
|
+
const fetchUserInfo = async (accessToken) => {
|
|
100
|
+
const resp = await fetch(USER_INFO_URL, { headers: {
|
|
101
|
+
Authorization: `Bearer ${accessToken}`,
|
|
102
|
+
"User-Agent": await userAgent()
|
|
103
|
+
} });
|
|
104
|
+
if (!resp.ok) throw new Error(`Failed to fetch user info: ${resp.statusText}`);
|
|
105
|
+
const rawData = await resp.json();
|
|
106
|
+
return z.object({ email: z.string() }).parse(rawData);
|
|
107
|
+
};
|
|
108
|
+
const startAuthServer = async () => {
|
|
109
|
+
return new Promise((resolve, reject) => {
|
|
110
|
+
const state = randomState();
|
|
111
|
+
const server = http.createServer(async (req, res) => {
|
|
112
|
+
try {
|
|
113
|
+
if (!req.url?.startsWith("/callback")) {
|
|
114
|
+
res.writeHead(404);
|
|
115
|
+
const msg = "Invalid callback URL";
|
|
116
|
+
res.end(msg);
|
|
117
|
+
reject(msg);
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
const url = new URL(req.url, `http://${req.headers.host}`);
|
|
121
|
+
const receivedState = url.searchParams.get("state");
|
|
122
|
+
const code = url.searchParams.get("code");
|
|
123
|
+
if (receivedState !== state) {
|
|
124
|
+
res.writeHead(400);
|
|
125
|
+
const msg = "Invalid state parameter";
|
|
126
|
+
res.end(msg);
|
|
127
|
+
reject(msg);
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
if (!code) {
|
|
131
|
+
res.writeHead(400);
|
|
132
|
+
const msg = "Missing authorization code";
|
|
133
|
+
res.end(msg);
|
|
134
|
+
reject(msg);
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
const tokens = await exchangeCode(code);
|
|
138
|
+
const userInfo = await fetchUserInfo(tokens.access_token);
|
|
139
|
+
const expiresAt = /* @__PURE__ */ new Date();
|
|
140
|
+
expiresAt.setSeconds(expiresAt.getSeconds() + tokens.expires_in);
|
|
141
|
+
const pfConfig = readPlatformConfig();
|
|
142
|
+
pfConfig.users = {
|
|
143
|
+
...pfConfig.users,
|
|
144
|
+
[userInfo.email]: {
|
|
145
|
+
access_token: tokens.access_token,
|
|
146
|
+
refresh_token: tokens.refresh_token,
|
|
147
|
+
token_expires_at: expiresAt.toISOString()
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
pfConfig.current_user = userInfo.email;
|
|
151
|
+
writePlatformConfig(pfConfig);
|
|
152
|
+
res.writeHead(200, { "Content-Type": "application/json" });
|
|
153
|
+
res.end(JSON.stringify({
|
|
154
|
+
status: "ok",
|
|
155
|
+
message: "Successfully authenticated. Please close this window."
|
|
156
|
+
}));
|
|
157
|
+
resolve();
|
|
158
|
+
} catch (error) {
|
|
159
|
+
res.writeHead(500);
|
|
160
|
+
res.end("Internal server error");
|
|
161
|
+
reject(error);
|
|
162
|
+
} finally {
|
|
163
|
+
server.close();
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
const timeout = setTimeout(() => {
|
|
167
|
+
server.close();
|
|
168
|
+
reject(/* @__PURE__ */ new Error("Login timeout exceeded"));
|
|
169
|
+
}, 300 * 1e3);
|
|
170
|
+
server.on("close", () => {
|
|
171
|
+
clearTimeout(timeout);
|
|
172
|
+
});
|
|
173
|
+
server.on("error", (error) => {
|
|
174
|
+
reject(error);
|
|
175
|
+
});
|
|
176
|
+
server.listen(CALLBACK_PORT, async () => {
|
|
177
|
+
const loginUrl = new URL(LOGIN_URL);
|
|
178
|
+
loginUrl.searchParams.set("redirect_uri", CALLBACK_URL);
|
|
179
|
+
loginUrl.searchParams.set("state", state);
|
|
180
|
+
consola.info(`Opening browser for login:\n\n${loginUrl.href}\n`);
|
|
181
|
+
try {
|
|
182
|
+
await open(loginUrl.href);
|
|
183
|
+
} catch {
|
|
184
|
+
consola.warn("Failed to open browser automatically. Please open the URL above manually.");
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
};
|
|
189
|
+
const loginCommand = defineCommand({
|
|
190
|
+
meta: {
|
|
191
|
+
name: "login",
|
|
192
|
+
description: "Login to Tailor Platform"
|
|
193
|
+
},
|
|
194
|
+
args: commonArgs,
|
|
195
|
+
run: withCommonArgs(async () => {
|
|
196
|
+
await startAuthServer();
|
|
197
|
+
consola.success("Successfully logged in to Tailor Platform.");
|
|
198
|
+
})
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
//#endregion
|
|
202
|
+
//#region src/cli/logout.ts
|
|
203
|
+
const LOGOUT_URL = PLATFORM_AUTH_URL + "/logout";
|
|
204
|
+
const logoutCommand = defineCommand({
|
|
205
|
+
meta: {
|
|
206
|
+
name: "logout",
|
|
207
|
+
description: "Logout from Tailor Platform"
|
|
208
|
+
},
|
|
209
|
+
args: commonArgs,
|
|
210
|
+
run: withCommonArgs(async () => {
|
|
211
|
+
const pfConfig = readPlatformConfig();
|
|
212
|
+
if (!pfConfig.current_user) {
|
|
213
|
+
consola.warn("You are not logged in.");
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
const token = pfConfig.users[pfConfig.current_user]?.access_token;
|
|
217
|
+
if (!token) {
|
|
218
|
+
consola.warn("You are not logged in.");
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
const resp = await fetch(LOGOUT_URL, { headers: {
|
|
222
|
+
Authorization: `Bearer ${token}`,
|
|
223
|
+
"User-Agent": await userAgent()
|
|
224
|
+
} });
|
|
225
|
+
if (!resp.ok) throw new Error(`Failed to logout: ${resp.statusText}`);
|
|
226
|
+
delete pfConfig.users[pfConfig.current_user];
|
|
227
|
+
pfConfig.current_user = null;
|
|
228
|
+
writePlatformConfig(pfConfig);
|
|
229
|
+
consola.success("Successfully logged out from Tailor Platform.");
|
|
230
|
+
})
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
//#endregion
|
|
234
|
+
//#region src/cli/machineuser/index.ts
|
|
235
|
+
const machineuserCommand = defineCommand({
|
|
236
|
+
meta: {
|
|
237
|
+
name: "machineuser",
|
|
238
|
+
description: "Manage machine users"
|
|
239
|
+
},
|
|
240
|
+
subCommands: {
|
|
241
|
+
list: listCommand$4,
|
|
242
|
+
token: tokenCommand
|
|
243
|
+
},
|
|
244
|
+
async run() {
|
|
245
|
+
await runCommand(listCommand$4, { rawArgs: [] });
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
//#endregion
|
|
250
|
+
//#region src/cli/profile/create.ts
|
|
251
|
+
const createCommand$2 = defineCommand({
|
|
252
|
+
meta: {
|
|
253
|
+
name: "create",
|
|
254
|
+
description: "Create new profile"
|
|
255
|
+
},
|
|
256
|
+
args: {
|
|
257
|
+
...commonArgs,
|
|
258
|
+
...formatArgs,
|
|
259
|
+
name: {
|
|
260
|
+
type: "positional",
|
|
261
|
+
description: "Profile name",
|
|
262
|
+
required: true
|
|
263
|
+
},
|
|
264
|
+
user: {
|
|
265
|
+
type: "string",
|
|
266
|
+
description: "User email",
|
|
267
|
+
required: true,
|
|
268
|
+
alias: "u"
|
|
269
|
+
},
|
|
270
|
+
"workspace-id": {
|
|
271
|
+
type: "string",
|
|
272
|
+
description: "Workspace ID",
|
|
273
|
+
required: true,
|
|
274
|
+
alias: "w"
|
|
275
|
+
}
|
|
276
|
+
},
|
|
277
|
+
run: withCommonArgs(async (args) => {
|
|
278
|
+
const format = parseFormat(args.format);
|
|
279
|
+
const config = readPlatformConfig();
|
|
280
|
+
if (config.profiles[args.name]) throw new Error(`Profile "${args.name}" already exists.`);
|
|
281
|
+
const token = await fetchLatestToken(config, args.user);
|
|
282
|
+
const client = await initOperatorClient(token);
|
|
283
|
+
if (!(await fetchAll(async (pageToken) => {
|
|
284
|
+
const { workspaces, nextPageToken } = await client.listWorkspaces({ pageToken });
|
|
285
|
+
return [workspaces, nextPageToken];
|
|
286
|
+
})).find((ws) => ws.id === args["workspace-id"])) throw new Error(`Workspace "${args["workspace-id"]}" not found.`);
|
|
287
|
+
config.profiles[args.name] = {
|
|
288
|
+
user: args.user,
|
|
289
|
+
workspace_id: args["workspace-id"]
|
|
290
|
+
};
|
|
291
|
+
writePlatformConfig(config);
|
|
292
|
+
if (format === "table") consola.success(`Profile "${args.name}" created successfully.`);
|
|
293
|
+
const profileInfo = {
|
|
294
|
+
name: args.name,
|
|
295
|
+
user: args.user,
|
|
296
|
+
workspaceId: args["workspace-id"]
|
|
297
|
+
};
|
|
298
|
+
printWithFormat(profileInfo, format);
|
|
299
|
+
})
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
//#endregion
|
|
303
|
+
//#region src/cli/profile/delete.ts
|
|
304
|
+
const deleteCommand$2 = defineCommand({
|
|
305
|
+
meta: {
|
|
306
|
+
name: "delete",
|
|
307
|
+
description: "Delete profile"
|
|
308
|
+
},
|
|
309
|
+
args: {
|
|
310
|
+
...commonArgs,
|
|
311
|
+
name: {
|
|
312
|
+
type: "positional",
|
|
313
|
+
description: "Profile name",
|
|
314
|
+
required: true
|
|
315
|
+
}
|
|
316
|
+
},
|
|
317
|
+
run: withCommonArgs(async (args) => {
|
|
318
|
+
const config = readPlatformConfig();
|
|
319
|
+
if (!config.profiles[args.name]) throw new Error(`Profile "${args.name}" not found.`);
|
|
320
|
+
delete config.profiles[args.name];
|
|
321
|
+
writePlatformConfig(config);
|
|
322
|
+
consola.success(`Profile "${args.name}" deleted successfully.`);
|
|
323
|
+
})
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
//#endregion
|
|
327
|
+
//#region src/cli/profile/list.ts
|
|
328
|
+
const listCommand$3 = defineCommand({
|
|
329
|
+
meta: {
|
|
330
|
+
name: "list",
|
|
331
|
+
description: "List all profiles"
|
|
332
|
+
},
|
|
333
|
+
args: {
|
|
334
|
+
...commonArgs,
|
|
335
|
+
...formatArgs
|
|
336
|
+
},
|
|
337
|
+
run: withCommonArgs(async (args) => {
|
|
338
|
+
const format = parseFormat(args.format);
|
|
339
|
+
const config = readPlatformConfig();
|
|
340
|
+
const profiles = Object.entries(config.profiles);
|
|
341
|
+
if (profiles.length === 0) {
|
|
342
|
+
consola.info(ml`
|
|
343
|
+
No profiles found.
|
|
344
|
+
Please create a profile first using 'tailor-sdk profile create' command.
|
|
345
|
+
`);
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
const profileInfos = profiles.map(([name, profile]) => ({
|
|
349
|
+
name,
|
|
350
|
+
user: profile.user,
|
|
351
|
+
workspaceId: profile.workspace_id
|
|
352
|
+
}));
|
|
353
|
+
printWithFormat(profileInfos, format);
|
|
354
|
+
})
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
//#endregion
|
|
358
|
+
//#region src/cli/profile/update.ts
|
|
359
|
+
const updateCommand$1 = defineCommand({
|
|
360
|
+
meta: {
|
|
361
|
+
name: "update",
|
|
362
|
+
description: "Update profile properties"
|
|
363
|
+
},
|
|
364
|
+
args: {
|
|
365
|
+
...commonArgs,
|
|
366
|
+
...formatArgs,
|
|
367
|
+
name: {
|
|
368
|
+
type: "positional",
|
|
369
|
+
description: "Profile name",
|
|
370
|
+
required: true
|
|
371
|
+
},
|
|
372
|
+
user: {
|
|
373
|
+
type: "string",
|
|
374
|
+
description: "New user email",
|
|
375
|
+
alias: "u"
|
|
376
|
+
},
|
|
377
|
+
"workspace-id": {
|
|
378
|
+
type: "string",
|
|
379
|
+
description: "New workspace ID",
|
|
380
|
+
alias: "w"
|
|
381
|
+
}
|
|
382
|
+
},
|
|
383
|
+
run: withCommonArgs(async (args) => {
|
|
384
|
+
const format = parseFormat(args.format);
|
|
385
|
+
const config = readPlatformConfig();
|
|
386
|
+
if (!config.profiles[args.name]) throw new Error(`Profile "${args.name}" not found.`);
|
|
387
|
+
if (!args.user && !args["workspace-id"]) throw new Error("Please provide at least one property to update.");
|
|
388
|
+
const profile = config.profiles[args.name];
|
|
389
|
+
const oldUser = profile.user;
|
|
390
|
+
const newUser = args.user || oldUser;
|
|
391
|
+
const oldWorkspaceId = profile.workspace_id;
|
|
392
|
+
const newWorkspaceId = args["workspace-id"] || oldWorkspaceId;
|
|
393
|
+
const token = await fetchLatestToken(config, newUser);
|
|
394
|
+
const client = await initOperatorClient(token);
|
|
395
|
+
if (!(await fetchAll(async (pageToken) => {
|
|
396
|
+
const { workspaces, nextPageToken } = await client.listWorkspaces({ pageToken });
|
|
397
|
+
return [workspaces, nextPageToken];
|
|
398
|
+
})).find((ws) => ws.id === newWorkspaceId)) throw new Error(`Workspace "${newWorkspaceId}" not found.`);
|
|
399
|
+
profile.user = newUser;
|
|
400
|
+
profile.workspace_id = newWorkspaceId;
|
|
401
|
+
writePlatformConfig(config);
|
|
402
|
+
if (format === "table") consola.success(`Profile "${args.name}" updated successfully`);
|
|
403
|
+
const profileInfo = {
|
|
404
|
+
name: args.name,
|
|
405
|
+
user: newUser,
|
|
406
|
+
workspaceId: newWorkspaceId
|
|
407
|
+
};
|
|
408
|
+
printWithFormat(profileInfo, format);
|
|
409
|
+
})
|
|
410
|
+
});
|
|
411
|
+
|
|
412
|
+
//#endregion
|
|
413
|
+
//#region src/cli/profile/index.ts
|
|
414
|
+
const profileCommand = defineCommand({
|
|
415
|
+
meta: {
|
|
416
|
+
name: "profile",
|
|
417
|
+
description: "Manage workspace profiles (user + workspace combinations)"
|
|
418
|
+
},
|
|
419
|
+
subCommands: {
|
|
420
|
+
create: createCommand$2,
|
|
421
|
+
delete: deleteCommand$2,
|
|
422
|
+
list: listCommand$3,
|
|
423
|
+
update: updateCommand$1
|
|
424
|
+
},
|
|
425
|
+
async run() {
|
|
426
|
+
await runCommand(listCommand$3, { rawArgs: [] });
|
|
427
|
+
}
|
|
428
|
+
});
|
|
429
|
+
|
|
430
|
+
//#endregion
|
|
431
|
+
//#region src/cli/tailordb/truncate.ts
|
|
432
|
+
async function truncateSingleType(options, client) {
|
|
433
|
+
await client.truncateTailorDBType({
|
|
434
|
+
workspaceId: options.workspaceId,
|
|
435
|
+
namespaceName: options.namespaceName,
|
|
436
|
+
tailordbTypeName: options.typeName
|
|
437
|
+
});
|
|
438
|
+
consola.success(`Truncated type "${options.typeName}" in namespace "${options.namespaceName}"`);
|
|
439
|
+
}
|
|
440
|
+
async function truncateNamespace(workspaceId, namespaceName, client) {
|
|
441
|
+
await client.truncateTailorDBTypes({
|
|
442
|
+
workspaceId,
|
|
443
|
+
namespaceName
|
|
444
|
+
});
|
|
445
|
+
consola.success(`Truncated all types in namespace "${namespaceName}"`);
|
|
446
|
+
}
|
|
447
|
+
async function getAllNamespaces(workspaceId, configPath) {
|
|
448
|
+
const { config } = await loadConfig(configPath);
|
|
449
|
+
const namespaces = /* @__PURE__ */ new Set();
|
|
450
|
+
if (config.db) for (const [namespaceName] of Object.entries(config.db)) namespaces.add(namespaceName);
|
|
451
|
+
return Array.from(namespaces);
|
|
452
|
+
}
|
|
453
|
+
async function getTypeNamespace(workspaceId, typeName, client, configPath) {
|
|
454
|
+
const namespaces = await getAllNamespaces(workspaceId, configPath);
|
|
455
|
+
for (const namespace of namespaces) try {
|
|
456
|
+
const { tailordbTypes } = await client.listTailorDBTypes({
|
|
457
|
+
workspaceId,
|
|
458
|
+
namespaceName: namespace
|
|
459
|
+
});
|
|
460
|
+
if (tailordbTypes.some((type) => type.name === typeName)) return namespace;
|
|
461
|
+
} catch {
|
|
462
|
+
continue;
|
|
463
|
+
}
|
|
464
|
+
return null;
|
|
465
|
+
}
|
|
466
|
+
async function truncate(options) {
|
|
467
|
+
const accessToken = await loadAccessToken({
|
|
468
|
+
useProfile: true,
|
|
469
|
+
profile: options?.profile
|
|
470
|
+
});
|
|
471
|
+
const client = await initOperatorClient(accessToken);
|
|
472
|
+
const workspaceId = loadWorkspaceId({
|
|
473
|
+
workspaceId: options?.workspaceId,
|
|
474
|
+
profile: options?.profile
|
|
475
|
+
});
|
|
476
|
+
const hasTypes = options?.types && options.types.length > 0;
|
|
477
|
+
const hasNamespace = !!options?.namespace;
|
|
478
|
+
const hasAll = !!options?.all;
|
|
479
|
+
if ([
|
|
480
|
+
hasTypes,
|
|
481
|
+
hasNamespace,
|
|
482
|
+
hasAll
|
|
483
|
+
].filter(Boolean).length > 1) throw new Error("Cannot specify multiple options: choose one of --all, --namespace, or type names");
|
|
484
|
+
if (!hasTypes && !hasNamespace && !hasAll) throw new Error("Please specify one of: --all, --namespace <name>, or type names");
|
|
485
|
+
const configPath = loadConfigPath(options?.configPath);
|
|
486
|
+
const namespaces = await getAllNamespaces(workspaceId, configPath);
|
|
487
|
+
if (hasAll) {
|
|
488
|
+
if (namespaces.length === 0) {
|
|
489
|
+
consola.warn("No namespaces found in config file.");
|
|
490
|
+
return;
|
|
491
|
+
}
|
|
492
|
+
if (!options?.yes) {
|
|
493
|
+
const namespaceList = namespaces.join(", ");
|
|
494
|
+
if (!await consola.prompt(`This will truncate ALL tables in the following namespaces: ${namespaceList}. Continue? (yes/no)`, {
|
|
495
|
+
type: "confirm",
|
|
496
|
+
initial: false
|
|
497
|
+
})) {
|
|
498
|
+
consola.info("Truncate cancelled.");
|
|
499
|
+
return;
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
for (const namespace of namespaces) await truncateNamespace(workspaceId, namespace, client);
|
|
503
|
+
consola.success("Truncated all tables in all namespaces");
|
|
504
|
+
return;
|
|
505
|
+
}
|
|
506
|
+
if (hasNamespace && options?.namespace) {
|
|
507
|
+
const namespace = options.namespace;
|
|
508
|
+
if (!namespaces.includes(namespace)) throw new Error(`Namespace "${namespace}" not found in config. Available namespaces: ${namespaces.join(", ")}`);
|
|
509
|
+
if (!options.yes) {
|
|
510
|
+
if (!await consola.prompt(`This will truncate ALL tables in namespace "${namespace}". Continue? (yes/no)`, {
|
|
511
|
+
type: "confirm",
|
|
512
|
+
initial: false
|
|
513
|
+
})) {
|
|
514
|
+
consola.info("Truncate cancelled.");
|
|
515
|
+
return;
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
await truncateNamespace(workspaceId, namespace, client);
|
|
519
|
+
return;
|
|
520
|
+
}
|
|
521
|
+
if (hasTypes && options?.types) {
|
|
522
|
+
const typeNames = options.types;
|
|
523
|
+
const typeNamespaceMap = /* @__PURE__ */ new Map();
|
|
524
|
+
const notFoundTypes = [];
|
|
525
|
+
for (const typeName of typeNames) {
|
|
526
|
+
const namespace = await getTypeNamespace(workspaceId, typeName, client, configPath);
|
|
527
|
+
if (namespace) typeNamespaceMap.set(typeName, namespace);
|
|
528
|
+
else notFoundTypes.push(typeName);
|
|
529
|
+
}
|
|
530
|
+
if (notFoundTypes.length > 0) throw new Error(`The following types were not found in any namespace: ${notFoundTypes.join(", ")}`);
|
|
531
|
+
if (!options.yes) {
|
|
532
|
+
const typeList = typeNames.join(", ");
|
|
533
|
+
if (!await consola.prompt(`This will truncate the following types: ${typeList}. Continue? (yes/no)`, {
|
|
534
|
+
type: "confirm",
|
|
535
|
+
initial: false
|
|
536
|
+
})) {
|
|
537
|
+
consola.info("Truncate cancelled.");
|
|
538
|
+
return;
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
for (const typeName of typeNames) {
|
|
542
|
+
const namespace = typeNamespaceMap.get(typeName);
|
|
543
|
+
if (!namespace) continue;
|
|
544
|
+
await truncateSingleType({
|
|
545
|
+
workspaceId,
|
|
546
|
+
namespaceName: namespace,
|
|
547
|
+
typeName
|
|
548
|
+
}, client);
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
const truncateCommand = defineCommand({
|
|
553
|
+
meta: {
|
|
554
|
+
name: "truncate",
|
|
555
|
+
description: "Truncate TailorDB tables"
|
|
556
|
+
},
|
|
557
|
+
args: {
|
|
558
|
+
...commonArgs,
|
|
559
|
+
types: {
|
|
560
|
+
type: "positional",
|
|
561
|
+
description: "Type names to truncate (space-separated)",
|
|
562
|
+
required: false
|
|
563
|
+
},
|
|
564
|
+
all: {
|
|
565
|
+
type: "boolean",
|
|
566
|
+
description: "Truncate all tables in all namespaces",
|
|
567
|
+
default: false,
|
|
568
|
+
alias: "a"
|
|
569
|
+
},
|
|
570
|
+
namespace: {
|
|
571
|
+
type: "string",
|
|
572
|
+
description: "Truncate all tables in specified namespace",
|
|
573
|
+
alias: "n"
|
|
574
|
+
},
|
|
575
|
+
yes: {
|
|
576
|
+
type: "boolean",
|
|
577
|
+
description: "Skip confirmation prompt",
|
|
578
|
+
alias: "y",
|
|
579
|
+
default: false
|
|
580
|
+
},
|
|
581
|
+
"workspace-id": {
|
|
582
|
+
type: "string",
|
|
583
|
+
description: "Workspace ID",
|
|
584
|
+
alias: "w"
|
|
585
|
+
},
|
|
586
|
+
profile: {
|
|
587
|
+
type: "string",
|
|
588
|
+
description: "Workspace profile",
|
|
589
|
+
alias: "p"
|
|
590
|
+
},
|
|
591
|
+
config: {
|
|
592
|
+
type: "string",
|
|
593
|
+
description: "Path to tailor config file",
|
|
594
|
+
default: "tailor.config.ts",
|
|
595
|
+
alias: "c"
|
|
596
|
+
}
|
|
597
|
+
},
|
|
598
|
+
run: withCommonArgs(async (args) => {
|
|
599
|
+
await truncate({
|
|
600
|
+
workspaceId: args["workspace-id"],
|
|
601
|
+
profile: args.profile,
|
|
602
|
+
configPath: args.config,
|
|
603
|
+
all: args.all,
|
|
604
|
+
namespace: args.namespace,
|
|
605
|
+
types: args.types ? args.types.split(/\s+/).filter(Boolean) : void 0,
|
|
606
|
+
yes: args.yes
|
|
607
|
+
});
|
|
608
|
+
})
|
|
609
|
+
});
|
|
610
|
+
|
|
611
|
+
//#endregion
|
|
612
|
+
//#region src/cli/tailordb/index.ts
|
|
613
|
+
const tailordbCommand = defineCommand({
|
|
614
|
+
meta: {
|
|
615
|
+
name: "tailordb",
|
|
616
|
+
description: "Manage TailorDB tables and data"
|
|
617
|
+
},
|
|
618
|
+
subCommands: { truncate: truncateCommand }
|
|
619
|
+
});
|
|
620
|
+
|
|
621
|
+
//#endregion
|
|
622
|
+
//#region src/cli/user/current.ts
|
|
623
|
+
const currentCommand = defineCommand({
|
|
624
|
+
meta: {
|
|
625
|
+
name: "current",
|
|
626
|
+
description: "Show current user"
|
|
627
|
+
},
|
|
628
|
+
args: commonArgs,
|
|
629
|
+
run: withCommonArgs(async () => {
|
|
630
|
+
const config = readPlatformConfig();
|
|
631
|
+
if (!config.current_user) {
|
|
632
|
+
consola.warn(ml`
|
|
633
|
+
Current user not set.
|
|
634
|
+
Please login first using 'tailor-sdk login' command to register a user.
|
|
635
|
+
`);
|
|
636
|
+
return;
|
|
637
|
+
}
|
|
638
|
+
if (!config.users[config.current_user]) throw new Error(ml`
|
|
639
|
+
Current user '${config.current_user}' not found in registered users.
|
|
640
|
+
Please login again using 'tailor-sdk login' command to register the user.
|
|
641
|
+
`);
|
|
642
|
+
console.log(config.current_user);
|
|
643
|
+
})
|
|
644
|
+
});
|
|
645
|
+
|
|
646
|
+
//#endregion
|
|
647
|
+
//#region src/cli/user/list.ts
|
|
648
|
+
const listCommand$1 = defineCommand({
|
|
649
|
+
meta: {
|
|
650
|
+
name: "list",
|
|
651
|
+
description: "List all users"
|
|
652
|
+
},
|
|
653
|
+
args: {
|
|
654
|
+
...commonArgs,
|
|
655
|
+
...formatArgs
|
|
656
|
+
},
|
|
657
|
+
run: withCommonArgs(async (args) => {
|
|
658
|
+
const format = parseFormat(args.format);
|
|
659
|
+
const config = readPlatformConfig();
|
|
660
|
+
const users = Object.keys(config.users);
|
|
661
|
+
if (users.length === 0) {
|
|
662
|
+
consola.info(ml`
|
|
663
|
+
No users found.
|
|
664
|
+
Please login first using 'tailor-sdk login' command to register a user.
|
|
665
|
+
`);
|
|
666
|
+
return;
|
|
667
|
+
}
|
|
668
|
+
switch (format) {
|
|
669
|
+
case "table":
|
|
670
|
+
users.forEach((user) => {
|
|
671
|
+
if (user === config.current_user) console.log(chalk.green.bold(`${user} (current)`));
|
|
672
|
+
else console.log(user);
|
|
673
|
+
});
|
|
674
|
+
break;
|
|
675
|
+
case "json":
|
|
676
|
+
console.log(JSON.stringify(users));
|
|
677
|
+
break;
|
|
678
|
+
default: throw new Error(`Format "${format}" is invalid.`);
|
|
679
|
+
}
|
|
680
|
+
})
|
|
681
|
+
});
|
|
682
|
+
|
|
683
|
+
//#endregion
|
|
684
|
+
//#region src/cli/user/pat/transform.ts
|
|
685
|
+
const patFormatSchema = z.enum(["text", "json"]);
|
|
686
|
+
const patFormatArgs = { format: {
|
|
687
|
+
type: "string",
|
|
688
|
+
description: `Output format (${patFormatSchema.options.join(", ")})`,
|
|
689
|
+
alias: "f",
|
|
690
|
+
default: "text"
|
|
691
|
+
} };
|
|
692
|
+
function parsePATFormat(format) {
|
|
693
|
+
const parsed = patFormatSchema.safeParse(format);
|
|
694
|
+
if (!parsed.success) throw new Error(`Format "${format}" is invalid. Must be one of: ${patFormatSchema.options.join(", ")}`);
|
|
695
|
+
return parsed.data;
|
|
696
|
+
}
|
|
697
|
+
function patScopeToString(scope) {
|
|
698
|
+
switch (scope) {
|
|
699
|
+
case PATScope.PAT_SCOPE_READ: return "read";
|
|
700
|
+
case PATScope.PAT_SCOPE_WRITE: return "write";
|
|
701
|
+
default: return "unknown";
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
function transformPersonalAccessToken(pat) {
|
|
705
|
+
return {
|
|
706
|
+
name: pat.name,
|
|
707
|
+
scopes: pat.scopes.map(patScopeToString)
|
|
708
|
+
};
|
|
709
|
+
}
|
|
710
|
+
function getScopesFromWriteFlag(write) {
|
|
711
|
+
return write ? [PATScope.PAT_SCOPE_READ, PATScope.PAT_SCOPE_WRITE] : [PATScope.PAT_SCOPE_READ];
|
|
712
|
+
}
|
|
713
|
+
function getScopeStringsFromWriteFlag(write) {
|
|
714
|
+
return write ? ["read", "write"] : ["read"];
|
|
715
|
+
}
|
|
716
|
+
function printCreatedToken(name, token, write, format, action) {
|
|
717
|
+
const scopes = getScopeStringsFromWriteFlag(write);
|
|
718
|
+
if (format === "text") console.log(ml`
|
|
719
|
+
Personal access token ${action} successfully.
|
|
720
|
+
|
|
721
|
+
name: ${name}
|
|
722
|
+
scopes: ${scopes.join("/")}
|
|
723
|
+
token: ${token}
|
|
724
|
+
|
|
725
|
+
Please save this token in a secure location. You won't be able to see it again.
|
|
726
|
+
`);
|
|
727
|
+
else console.log(JSON.stringify({
|
|
728
|
+
name,
|
|
729
|
+
scopes,
|
|
730
|
+
token
|
|
731
|
+
}));
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
//#endregion
|
|
735
|
+
//#region src/cli/user/pat/create.ts
|
|
736
|
+
const createCommand$1 = defineCommand({
|
|
737
|
+
meta: {
|
|
738
|
+
name: "create",
|
|
739
|
+
description: "Create new personal access token"
|
|
740
|
+
},
|
|
741
|
+
args: {
|
|
742
|
+
...commonArgs,
|
|
743
|
+
...patFormatArgs,
|
|
744
|
+
name: {
|
|
745
|
+
type: "positional",
|
|
746
|
+
description: "Token name",
|
|
747
|
+
required: true
|
|
748
|
+
},
|
|
749
|
+
write: {
|
|
750
|
+
type: "boolean",
|
|
751
|
+
description: "Grant write permission (default: read-only)",
|
|
752
|
+
default: false,
|
|
753
|
+
alias: "w"
|
|
754
|
+
}
|
|
755
|
+
},
|
|
756
|
+
run: withCommonArgs(async (args) => {
|
|
757
|
+
const format = parsePATFormat(args.format);
|
|
758
|
+
const config = readPlatformConfig();
|
|
759
|
+
if (!config.current_user) throw new Error(ml`
|
|
760
|
+
No user logged in.
|
|
761
|
+
Please login first using 'tailor-sdk login' command.
|
|
762
|
+
`);
|
|
763
|
+
const token = await fetchLatestToken(config, config.current_user);
|
|
764
|
+
const client = await initOperatorClient(token);
|
|
765
|
+
const scopes = getScopesFromWriteFlag(args.write);
|
|
766
|
+
const result = await client.createPersonalAccessToken({
|
|
767
|
+
name: args.name,
|
|
768
|
+
scopes
|
|
769
|
+
});
|
|
770
|
+
if (!result.accessToken) throw new Error("Failed to create personal access token");
|
|
771
|
+
printCreatedToken(args.name, result.accessToken, args.write, format, "created");
|
|
772
|
+
})
|
|
773
|
+
});
|
|
774
|
+
|
|
775
|
+
//#endregion
|
|
776
|
+
//#region src/cli/user/pat/delete.ts
|
|
777
|
+
const deleteCommand$1 = defineCommand({
|
|
778
|
+
meta: {
|
|
779
|
+
name: "delete",
|
|
780
|
+
description: "Delete personal access token"
|
|
781
|
+
},
|
|
782
|
+
args: {
|
|
783
|
+
...commonArgs,
|
|
784
|
+
name: {
|
|
785
|
+
type: "positional",
|
|
786
|
+
description: "Token name",
|
|
787
|
+
required: true
|
|
788
|
+
}
|
|
789
|
+
},
|
|
790
|
+
run: withCommonArgs(async (args) => {
|
|
791
|
+
const config = readPlatformConfig();
|
|
792
|
+
if (!config.current_user) throw new Error(ml`
|
|
793
|
+
No user logged in.
|
|
794
|
+
Please login first using 'tailor-sdk login' command.
|
|
795
|
+
`);
|
|
796
|
+
const token = await fetchLatestToken(config, config.current_user);
|
|
797
|
+
await (await initOperatorClient(token)).deletePersonalAccessToken({ name: args.name });
|
|
798
|
+
consola.success(`Personal access token "${args.name}" deleted successfully.`);
|
|
799
|
+
})
|
|
800
|
+
});
|
|
801
|
+
|
|
802
|
+
//#endregion
|
|
803
|
+
//#region src/cli/user/pat/list.ts
|
|
804
|
+
const listCommand$2 = defineCommand({
|
|
805
|
+
meta: {
|
|
806
|
+
name: "list",
|
|
807
|
+
description: "List all personal access tokens"
|
|
808
|
+
},
|
|
809
|
+
args: {
|
|
810
|
+
...commonArgs,
|
|
811
|
+
...patFormatArgs
|
|
812
|
+
},
|
|
813
|
+
run: withCommonArgs(async (args) => {
|
|
814
|
+
const format = parsePATFormat(args.format);
|
|
815
|
+
const config = readPlatformConfig();
|
|
816
|
+
if (!config.current_user) throw new Error(ml`
|
|
817
|
+
No user logged in.
|
|
818
|
+
Please login first using 'tailor-sdk login' command.
|
|
819
|
+
`);
|
|
820
|
+
const token = await fetchLatestToken(config, config.current_user);
|
|
821
|
+
const client = await initOperatorClient(token);
|
|
822
|
+
const pats = await fetchAll(async (pageToken) => {
|
|
823
|
+
const { personalAccessTokens, nextPageToken } = await client.listPersonalAccessTokens({ pageToken });
|
|
824
|
+
return [personalAccessTokens, nextPageToken];
|
|
825
|
+
});
|
|
826
|
+
if (pats.length === 0) {
|
|
827
|
+
consola.info(ml`
|
|
828
|
+
No personal access tokens found.
|
|
829
|
+
Please create a token using 'tailor-sdk user pat create' command.
|
|
830
|
+
`);
|
|
831
|
+
return;
|
|
832
|
+
}
|
|
833
|
+
if (format === "text") {
|
|
834
|
+
const maxNameLength = Math.max(...pats.map((pat) => pat.name.length));
|
|
835
|
+
pats.forEach((pat) => {
|
|
836
|
+
const info = transformPersonalAccessToken(pat);
|
|
837
|
+
const paddedName = info.name.padStart(maxNameLength);
|
|
838
|
+
console.log(`${paddedName}: ${info.scopes.join("/")}`);
|
|
839
|
+
});
|
|
840
|
+
} else {
|
|
841
|
+
const patInfos = pats.map(transformPersonalAccessToken);
|
|
842
|
+
console.log(JSON.stringify(patInfos));
|
|
843
|
+
}
|
|
844
|
+
})
|
|
845
|
+
});
|
|
846
|
+
|
|
847
|
+
//#endregion
|
|
848
|
+
//#region src/cli/user/pat/update.ts
|
|
849
|
+
const updateCommand = defineCommand({
|
|
850
|
+
meta: {
|
|
851
|
+
name: "update",
|
|
852
|
+
description: "Update personal access token (delete and recreate)"
|
|
853
|
+
},
|
|
854
|
+
args: {
|
|
855
|
+
...commonArgs,
|
|
856
|
+
...patFormatArgs,
|
|
857
|
+
name: {
|
|
858
|
+
type: "positional",
|
|
859
|
+
description: "Token name",
|
|
860
|
+
required: true
|
|
861
|
+
},
|
|
862
|
+
write: {
|
|
863
|
+
type: "boolean",
|
|
864
|
+
description: "Grant write permission (if not specified, keeps read-only)",
|
|
865
|
+
default: false,
|
|
866
|
+
alias: "w"
|
|
867
|
+
}
|
|
868
|
+
},
|
|
869
|
+
run: withCommonArgs(async (args) => {
|
|
870
|
+
const format = parsePATFormat(args.format);
|
|
871
|
+
const config = readPlatformConfig();
|
|
872
|
+
if (!config.current_user) throw new Error(ml`
|
|
873
|
+
No user logged in.
|
|
874
|
+
Please login first using 'tailor-sdk login' command.
|
|
875
|
+
`);
|
|
876
|
+
const token = await fetchLatestToken(config, config.current_user);
|
|
877
|
+
const client = await initOperatorClient(token);
|
|
878
|
+
await client.deletePersonalAccessToken({ name: args.name });
|
|
879
|
+
const scopes = getScopesFromWriteFlag(args.write);
|
|
880
|
+
const result = await client.createPersonalAccessToken({
|
|
881
|
+
name: args.name,
|
|
882
|
+
scopes
|
|
883
|
+
});
|
|
884
|
+
if (!result.accessToken) throw new Error("Failed to create personal access token");
|
|
885
|
+
printCreatedToken(args.name, result.accessToken, args.write, format, "updated");
|
|
886
|
+
})
|
|
887
|
+
});
|
|
888
|
+
|
|
889
|
+
//#endregion
|
|
890
|
+
//#region src/cli/user/pat/index.ts
|
|
891
|
+
const patCommand = defineCommand({
|
|
892
|
+
meta: {
|
|
893
|
+
name: "pat",
|
|
894
|
+
description: "Manage personal access tokens"
|
|
895
|
+
},
|
|
896
|
+
subCommands: {
|
|
897
|
+
create: createCommand$1,
|
|
898
|
+
delete: deleteCommand$1,
|
|
899
|
+
list: listCommand$2,
|
|
900
|
+
update: updateCommand
|
|
901
|
+
},
|
|
902
|
+
async run(context) {
|
|
903
|
+
await runCommand(listCommand$2, { rawArgs: context.rawArgs || [] });
|
|
904
|
+
}
|
|
905
|
+
});
|
|
906
|
+
|
|
907
|
+
//#endregion
|
|
908
|
+
//#region src/cli/user/use.ts
|
|
909
|
+
const useCommand = defineCommand({
|
|
910
|
+
meta: {
|
|
911
|
+
name: "use",
|
|
912
|
+
description: "Set current user"
|
|
913
|
+
},
|
|
914
|
+
args: {
|
|
915
|
+
...commonArgs,
|
|
916
|
+
user: {
|
|
917
|
+
type: "positional",
|
|
918
|
+
description: "User email",
|
|
919
|
+
required: true
|
|
920
|
+
}
|
|
921
|
+
},
|
|
922
|
+
run: withCommonArgs(async (args) => {
|
|
923
|
+
const config = readPlatformConfig();
|
|
924
|
+
if (!config.users[args.user]) throw new Error(ml`
|
|
925
|
+
User "${args.user}" not found.
|
|
926
|
+
Please login first using 'tailor-sdk login' command to register this user.
|
|
927
|
+
`);
|
|
928
|
+
config.current_user = args.user;
|
|
929
|
+
writePlatformConfig(config);
|
|
930
|
+
consola.success(`Current user set to "${args.user}" successfully.`);
|
|
931
|
+
})
|
|
932
|
+
});
|
|
933
|
+
|
|
934
|
+
//#endregion
|
|
935
|
+
//#region src/cli/user/index.ts
|
|
936
|
+
const userCommand = defineCommand({
|
|
937
|
+
meta: {
|
|
938
|
+
name: "user",
|
|
939
|
+
description: "Manage Tailor Platform users"
|
|
940
|
+
},
|
|
941
|
+
subCommands: {
|
|
942
|
+
current: currentCommand,
|
|
943
|
+
list: listCommand$1,
|
|
944
|
+
pat: patCommand,
|
|
945
|
+
use: useCommand
|
|
946
|
+
},
|
|
947
|
+
async run() {
|
|
948
|
+
await runCommand(listCommand$1, { rawArgs: [] });
|
|
949
|
+
}
|
|
950
|
+
});
|
|
951
|
+
|
|
952
|
+
//#endregion
|
|
953
|
+
//#region src/cli/workspace/index.ts
|
|
954
|
+
const workspaceCommand = defineCommand({
|
|
955
|
+
meta: {
|
|
956
|
+
name: "workspace",
|
|
957
|
+
description: "Manage Tailor Platform workspaces"
|
|
958
|
+
},
|
|
959
|
+
subCommands: {
|
|
960
|
+
create: createCommand,
|
|
961
|
+
delete: deleteCommand,
|
|
962
|
+
list: listCommand
|
|
963
|
+
},
|
|
964
|
+
async run() {
|
|
965
|
+
await runCommand(listCommand, { rawArgs: [] });
|
|
966
|
+
}
|
|
967
|
+
});
|
|
968
|
+
|
|
969
|
+
//#endregion
|
|
970
|
+
//#region src/cli/index.ts
|
|
971
|
+
register("tsx", import.meta.url, { data: {} });
|
|
972
|
+
const packageJson = await readPackageJSON(import.meta.url);
|
|
973
|
+
const mainCommand = defineCommand({
|
|
974
|
+
meta: {
|
|
975
|
+
name: packageJson.name,
|
|
976
|
+
version: packageJson.version,
|
|
977
|
+
description: packageJson.description || "Tailor CLI for managing Tailor Platform SDK applications"
|
|
978
|
+
},
|
|
979
|
+
subCommands: {
|
|
980
|
+
apply: applyCommand,
|
|
981
|
+
generate: generateCommand,
|
|
982
|
+
init: initCommand,
|
|
983
|
+
login: loginCommand,
|
|
984
|
+
logout: logoutCommand,
|
|
985
|
+
machineuser: machineuserCommand,
|
|
986
|
+
profile: profileCommand,
|
|
987
|
+
show: showCommand,
|
|
988
|
+
tailordb: tailordbCommand,
|
|
989
|
+
user: userCommand,
|
|
990
|
+
workspace: workspaceCommand
|
|
991
|
+
}
|
|
992
|
+
});
|
|
993
|
+
runMain(mainCommand);
|
|
994
|
+
|
|
995
|
+
//#endregion
|
|
996
|
+
export { };
|