@tailor-platform/sdk 1.15.0 → 1.15.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 +14 -0
- package/dist/{application-DPunZ4lc.mjs → application-DLUgR1gv.mjs} +19 -4
- package/dist/application-DLUgR1gv.mjs.map +1 -0
- package/dist/application-DhvHS3pX.mjs +4 -0
- package/dist/cli/index.mjs +136 -2
- package/dist/cli/index.mjs.map +1 -1
- package/dist/cli/lib.d.mts +3 -2
- package/dist/cli/lib.mjs +2 -2
- package/dist/configure/index.d.mts +3 -3
- package/dist/{index-Bs9AsQb2.d.mts → index-Bg_UJxhL.d.mts} +11 -11
- package/dist/{index-DomkP6gz.d.mts → index-pQbghcVa.d.mts} +2 -2
- package/dist/plugin/index.d.mts +1 -1
- package/dist/{types-Db1oxr0U.d.mts → types-BZRw-Iys.d.mts} +43 -43
- package/dist/{update-C_ZTRB63.mjs → update-70uX2TDG.mjs} +34 -22
- package/dist/update-70uX2TDG.mjs.map +1 -0
- package/dist/utils/test/index.d.mts +3 -3
- package/docs/cli/function.md +64 -0
- package/docs/cli-reference.md +8 -0
- package/package.json +1 -1
- package/dist/application-DPunZ4lc.mjs.map +0 -1
- package/dist/application-JwJ_-_PQ.mjs +0 -4
- package/dist/update-C_ZTRB63.mjs.map +0 -1
package/dist/cli/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import "../chunk-GMkBE123.mjs";
|
|
3
3
|
import "../schema-DRYB-nzA.mjs";
|
|
4
|
-
import { $ as jobsCommand, $t as
|
|
5
|
-
import { f as logger, p as styles } from "../application-
|
|
4
|
+
import { $ as jobsCommand, $t as fetchUserInfo, A as generateCommand, Bt as getNamespacesWithMigrations, C as resumeCommand, F as removeCommand$1, Ft as loadDiff, G as generateCommand$1, H as listCommand$6, I as listCommand$7, J as triggerCommand, Jt as loadAccessToken, Kt as apiCommand, Mt as getMigrationFiles, N as showCommand, O as truncateCommand, Ot as formatMigrationNumber, Pt as isValidMigrationNumber, Qt as fetchAll, R as getCommand$2, S as healthCommand, T as listCommand$8, Ut as loadConfig, V as tokenCommand, Vt as trnPrefix, X as listCommand$5, Xt as readPlatformConfig, Yt as loadWorkspaceId, Zt as writePlatformConfig, _ as createCommand$3, a as listCommand$10, an as commonArgs, b as listCommand$9, cn as jsonArgs, d as listCommand$11, dt as getCommand$1, en as initOAuth2Client, h as deleteCommand$3, in as PATScope, it as getCommand$3, j as logBetaWarning, jt as getMigrationFilePath, l as restoreCommand, ln as withCommonArgs, lt as functionExecutionStatusToString, mt as applyCommand, nn as readPackageJson, nt as startCommand, on as confirmationArgs, ot as executionsCommand, p as getCommand$4, q as webhookCommand, qt as fetchLatestToken, r as removeCommand, rn as FunctionExecution_Type, s as inviteCommand, sn as deploymentArgs, t as updateCommand$2, tn as initOperatorClient, un as workspaceArgs, ut as formatKeyValueTable, vt as parseMigrationLabelNumber } from "../update-70uX2TDG.mjs";
|
|
5
|
+
import { f as logger, p as styles } from "../application-DLUgR1gv.mjs";
|
|
6
6
|
import { createRequire, register } from "node:module";
|
|
7
7
|
import { arg, defineCommand, runCommand, runMain } from "politty";
|
|
8
8
|
import { withCompletionCommand } from "politty/completion";
|
|
@@ -38,6 +38,139 @@ const executorCommand = defineCommand({
|
|
|
38
38
|
}
|
|
39
39
|
});
|
|
40
40
|
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region src/cli/function/logs.ts
|
|
43
|
+
/**
|
|
44
|
+
* Convert function execution type enum to string.
|
|
45
|
+
* @param type - Function execution type enum value
|
|
46
|
+
* @returns Type string representation
|
|
47
|
+
*/
|
|
48
|
+
function functionExecutionTypeToString(type) {
|
|
49
|
+
switch (type) {
|
|
50
|
+
case FunctionExecution_Type.STANDARD: return "STANDARD";
|
|
51
|
+
case FunctionExecution_Type.JOB: return "JOB";
|
|
52
|
+
default: return "UNSPECIFIED";
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Transform FunctionExecution to FunctionExecutionListInfo for list display.
|
|
57
|
+
* @param execution - FunctionExecution from proto
|
|
58
|
+
* @returns Function execution list info
|
|
59
|
+
*/
|
|
60
|
+
function toFunctionExecutionListInfo(execution) {
|
|
61
|
+
return {
|
|
62
|
+
id: execution.id,
|
|
63
|
+
scriptName: execution.scriptName,
|
|
64
|
+
status: functionExecutionStatusToString(execution.status),
|
|
65
|
+
type: functionExecutionTypeToString(execution.type),
|
|
66
|
+
startedAt: execution.startedAt ? timestampDate(execution.startedAt) : null,
|
|
67
|
+
finishedAt: execution.finishedAt ? timestampDate(execution.finishedAt) : null
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Transform FunctionExecution to FunctionExecutionDetailInfo for detail display.
|
|
72
|
+
* @param execution - FunctionExecution from proto
|
|
73
|
+
* @returns Function execution detail info
|
|
74
|
+
*/
|
|
75
|
+
function toFunctionExecutionDetailInfo(execution) {
|
|
76
|
+
return {
|
|
77
|
+
id: execution.id,
|
|
78
|
+
scriptName: execution.scriptName,
|
|
79
|
+
status: functionExecutionStatusToString(execution.status),
|
|
80
|
+
type: functionExecutionTypeToString(execution.type),
|
|
81
|
+
startedAt: execution.startedAt ? timestampDate(execution.startedAt) : null,
|
|
82
|
+
finishedAt: execution.finishedAt ? timestampDate(execution.finishedAt) : null,
|
|
83
|
+
logs: execution.logs,
|
|
84
|
+
result: execution.result
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Print function execution detail in a human-readable format.
|
|
89
|
+
* @param detail - Function execution detail info
|
|
90
|
+
*/
|
|
91
|
+
function printFunctionExecutionDetail(detail) {
|
|
92
|
+
const formatDate = (date) => date ? date.toISOString() : "N/A";
|
|
93
|
+
const summaryData = [
|
|
94
|
+
["id", detail.id],
|
|
95
|
+
["scriptName", detail.scriptName],
|
|
96
|
+
["status", detail.status],
|
|
97
|
+
["type", detail.type],
|
|
98
|
+
["startedAt", formatDate(detail.startedAt)],
|
|
99
|
+
["finishedAt", formatDate(detail.finishedAt)]
|
|
100
|
+
];
|
|
101
|
+
logger.out(formatKeyValueTable(summaryData));
|
|
102
|
+
if (detail.logs) {
|
|
103
|
+
logger.log(styles.bold("\nLogs:"));
|
|
104
|
+
for (const line of detail.logs.split("\n")) logger.log(` ${line}`);
|
|
105
|
+
}
|
|
106
|
+
if (detail.result) {
|
|
107
|
+
logger.log(styles.bold("\nResult:"));
|
|
108
|
+
try {
|
|
109
|
+
const parsed = JSON.parse(detail.result);
|
|
110
|
+
logger.log(` ${JSON.stringify(parsed, null, 2).split("\n").join("\n ")}`);
|
|
111
|
+
} catch {
|
|
112
|
+
logger.log(` ${detail.result}`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
const logsCommand = defineCommand({
|
|
117
|
+
name: "logs",
|
|
118
|
+
description: "List or get function execution logs.",
|
|
119
|
+
args: z.object({
|
|
120
|
+
...commonArgs,
|
|
121
|
+
...jsonArgs,
|
|
122
|
+
...workspaceArgs,
|
|
123
|
+
executionId: arg(z.string().optional(), {
|
|
124
|
+
positional: true,
|
|
125
|
+
description: "Execution ID (if provided, shows details with logs)"
|
|
126
|
+
})
|
|
127
|
+
}),
|
|
128
|
+
run: withCommonArgs(async (args) => {
|
|
129
|
+
const client = await initOperatorClient(await loadAccessToken({
|
|
130
|
+
useProfile: true,
|
|
131
|
+
profile: args.profile
|
|
132
|
+
}));
|
|
133
|
+
const workspaceId = loadWorkspaceId({
|
|
134
|
+
workspaceId: args["workspace-id"],
|
|
135
|
+
profile: args.profile
|
|
136
|
+
});
|
|
137
|
+
if (args.executionId) {
|
|
138
|
+
const { execution } = await client.getFunctionExecution({
|
|
139
|
+
workspaceId,
|
|
140
|
+
executionId: args.executionId
|
|
141
|
+
});
|
|
142
|
+
if (!execution) throw new Error(`Function execution '${args.executionId}' not found.`);
|
|
143
|
+
const detail = toFunctionExecutionDetailInfo(execution);
|
|
144
|
+
if (args.json) logger.out(detail);
|
|
145
|
+
else printFunctionExecutionDetail(detail);
|
|
146
|
+
} else {
|
|
147
|
+
const logs = (await fetchAll(async (pageToken) => {
|
|
148
|
+
const { executions, nextPageToken } = await client.listFunctionExecutions({
|
|
149
|
+
workspaceId,
|
|
150
|
+
pageToken
|
|
151
|
+
});
|
|
152
|
+
return [executions, nextPageToken];
|
|
153
|
+
})).map(toFunctionExecutionListInfo);
|
|
154
|
+
if (logs.length === 0 && !args.json) {
|
|
155
|
+
logger.info("No function execution logs found.");
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
logger.out(logs);
|
|
159
|
+
}
|
|
160
|
+
})
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
//#endregion
|
|
164
|
+
//#region src/cli/function/index.ts
|
|
165
|
+
const functionCommand = defineCommand({
|
|
166
|
+
name: "function",
|
|
167
|
+
description: "Manage functions",
|
|
168
|
+
subCommands: { logs: logsCommand },
|
|
169
|
+
async run() {
|
|
170
|
+
await runCommand(logsCommand, []);
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
|
|
41
174
|
//#endregion
|
|
42
175
|
//#region src/cli/init.ts
|
|
43
176
|
const detectPackageManager = () => {
|
|
@@ -2161,6 +2294,7 @@ const mainCommand = withCompletionCommand(defineCommand({
|
|
|
2161
2294
|
api: apiCommand,
|
|
2162
2295
|
apply: applyCommand,
|
|
2163
2296
|
executor: executorCommand,
|
|
2297
|
+
function: functionCommand,
|
|
2164
2298
|
generate: generateCommand$1,
|
|
2165
2299
|
init: initCommand,
|
|
2166
2300
|
login: loginCommand,
|