@liquidmetal-ai/raindrop 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +254 -207
- package/bundle/chunk-5AOMZVOJ.js +48 -0
- package/bundle/chunk-5AP5HNN3.js +133 -0
- package/bundle/chunk-6CDCK5IP.js +58 -0
- package/bundle/chunk-6GTBXHHK.js +502 -0
- package/bundle/chunk-A26NDSVL.js +12148 -0
- package/bundle/{chunk-6UE75KX2.js → chunk-AKNNZNIC.js} +1 -2
- package/bundle/{chunk-CW5ZHVPX.js → chunk-DOTQ3CSX.js} +2 -2
- package/bundle/chunk-FO7VH4GU.js +75 -0
- package/bundle/chunk-HEOY5F6W.js +147 -0
- package/bundle/chunk-HMD2JXLE.js +238722 -0
- package/bundle/chunk-KGZ7KWP4.js +44 -0
- package/bundle/chunk-MNUILM7W.js +380 -0
- package/bundle/chunk-OROAB5YF.js +805 -0
- package/bundle/chunk-OZWZILJX.js +4539 -0
- package/bundle/{chunk-6B4I2CKP.js → chunk-YDVG2SA2.js} +4 -4
- package/bundle/chunk-ZQQFKWNC.js +22452 -0
- package/bundle/commands/annotation/get.js +4 -4
- package/bundle/commands/annotation/list.js +4 -4
- package/bundle/commands/annotation/put.js +4 -4
- package/bundle/commands/auth/list.js +2 -2
- package/bundle/commands/auth/login.js +3 -3
- package/bundle/commands/auth/logout.js +2 -2
- package/bundle/commands/auth/select.js +3 -3
- package/bundle/commands/bucket/create-credential.js +3 -3
- package/bundle/commands/bucket/delete-credential.js +3 -3
- package/bundle/commands/bucket/get-credential.js +3 -3
- package/bundle/commands/bucket/list-credentials.js +3 -3
- package/bundle/commands/build/branch.js +26 -14
- package/bundle/commands/build/checkout.js +6 -6
- package/bundle/commands/build/clone.js +5 -5
- package/bundle/commands/build/delete.js +24 -14
- package/bundle/commands/build/deploy.js +25 -13
- package/bundle/commands/build/env/get.js +19 -6
- package/bundle/commands/build/env/set.js +19 -6
- package/bundle/commands/build/find.js +18 -10
- package/bundle/commands/build/generate.js +4 -4
- package/bundle/commands/build/init.js +3 -3
- package/bundle/commands/build/list-templates.js +63 -0
- package/bundle/commands/build/list.js +4 -4
- package/bundle/commands/build/package-template.js +238 -0
- package/bundle/commands/build/sandbox.js +16 -10
- package/bundle/commands/build/start.js +10 -6
- package/bundle/commands/build/status.js +16 -11
- package/bundle/commands/build/stop.js +10 -6
- package/bundle/commands/build/tools/check.js +2 -2
- package/bundle/commands/build/tools/fmt.js +2 -2
- package/bundle/commands/build/unsandbox.js +16 -10
- package/bundle/commands/build/upload.js +23 -9
- package/bundle/commands/build/validate.js +5 -5
- package/bundle/commands/build/workos/delete.js +4 -4
- package/bundle/commands/build/workos/env/attach.js +20 -8
- package/bundle/commands/build/workos/env/create.js +60 -11
- package/bundle/commands/build/workos/env/delete.js +3 -3
- package/bundle/commands/build/workos/env/detach.js +20 -8
- package/bundle/commands/build/workos/env/get.js +21 -3
- package/bundle/commands/build/workos/env/list.js +3 -3
- package/bundle/commands/build/workos/env/set.js +91 -25
- package/bundle/commands/build/workos/invite.js +3 -3
- package/bundle/commands/build/workos/setup.js +14 -5
- package/bundle/commands/build/workos/status.js +116 -25
- package/bundle/commands/dns/create.js +2 -2
- package/bundle/commands/dns/delete.js +4 -4
- package/bundle/commands/dns/get.js +4 -4
- package/bundle/commands/dns/list.js +3 -3
- package/bundle/commands/dns/records/create.js +2 -2
- package/bundle/commands/dns/records/delete.js +3 -3
- package/bundle/commands/dns/records/get.js +2 -2
- package/bundle/commands/dns/records/list.js +2 -2
- package/bundle/commands/dns/records/update.js +2 -2
- package/bundle/commands/logs/query.js +15 -10
- package/bundle/commands/logs/tail.js +16 -11
- package/bundle/commands/mcp/install-claude.js +2 -2
- package/bundle/commands/mcp/install-gemini.js +2 -2
- package/bundle/commands/mcp/install-goose.js +2 -2
- package/bundle/commands/mcp/status.js +2 -2
- package/bundle/commands/object/delete.js +27 -14
- package/bundle/commands/object/get.js +27 -14
- package/bundle/commands/object/list.js +28 -15
- package/bundle/commands/object/put.js +27 -14
- package/bundle/commands/query/chunk-search.js +24 -10
- package/bundle/commands/query/document.js +39 -16
- package/bundle/commands/query/events.js +13 -8
- package/bundle/commands/query/reindex.js +14 -6
- package/bundle/commands/query/search.js +40 -17
- package/bundle/commands/tail.js +2 -2
- package/bundle/index.js +1 -1
- package/dist/base-command.d.ts.map +1 -1
- package/dist/base-command.js +27 -0
- package/dist/commands/annotation/get.js +1 -1
- package/dist/commands/annotation/list.js +1 -1
- package/dist/commands/annotation/put.js +1 -1
- package/dist/commands/bucket/create-credential.js +1 -1
- package/dist/commands/bucket/delete-credential.js +1 -1
- package/dist/commands/bucket/get-credential.js +1 -1
- package/dist/commands/bucket/list-credentials.js +1 -1
- package/dist/commands/build/branch.d.ts +2 -0
- package/dist/commands/build/branch.d.ts.map +1 -1
- package/dist/commands/build/branch.js +18 -5
- package/dist/commands/build/checkout.js +1 -1
- package/dist/commands/build/delete.d.ts +1 -0
- package/dist/commands/build/delete.d.ts.map +1 -1
- package/dist/commands/build/delete.js +25 -12
- package/dist/commands/build/deploy.d.ts +2 -0
- package/dist/commands/build/deploy.d.ts.map +1 -1
- package/dist/commands/build/deploy.js +17 -4
- package/dist/commands/build/env/get.d.ts +2 -0
- package/dist/commands/build/env/get.d.ts.map +1 -1
- package/dist/commands/build/env/get.js +18 -4
- package/dist/commands/build/env/set.d.ts +2 -0
- package/dist/commands/build/env/set.d.ts.map +1 -1
- package/dist/commands/build/env/set.js +18 -4
- package/dist/commands/build/find.d.ts +1 -0
- package/dist/commands/build/find.d.ts.map +1 -1
- package/dist/commands/build/find.js +18 -7
- package/dist/commands/build/generate.js +1 -1
- package/dist/commands/build/list-templates.d.ts +11 -0
- package/dist/commands/build/list-templates.d.ts.map +1 -0
- package/dist/commands/build/list-templates.js +47 -0
- package/dist/commands/build/list.js +1 -1
- package/dist/commands/build/package-template.d.ts +28 -0
- package/dist/commands/build/package-template.d.ts.map +1 -0
- package/dist/commands/build/package-template.js +256 -0
- package/dist/commands/build/sandbox.d.ts +1 -0
- package/dist/commands/build/sandbox.d.ts.map +1 -1
- package/dist/commands/build/sandbox.js +10 -3
- package/dist/commands/build/start.d.ts +1 -0
- package/dist/commands/build/start.d.ts.map +1 -1
- package/dist/commands/build/start.js +9 -4
- package/dist/commands/build/status.d.ts +1 -0
- package/dist/commands/build/status.d.ts.map +1 -1
- package/dist/commands/build/status.js +13 -7
- package/dist/commands/build/stop.d.ts +1 -0
- package/dist/commands/build/stop.d.ts.map +1 -1
- package/dist/commands/build/stop.js +9 -4
- package/dist/commands/build/unsandbox.d.ts +1 -0
- package/dist/commands/build/unsandbox.d.ts.map +1 -1
- package/dist/commands/build/unsandbox.js +10 -3
- package/dist/commands/build/upload.d.ts +3 -1
- package/dist/commands/build/upload.d.ts.map +1 -1
- package/dist/commands/build/upload.js +19 -4
- package/dist/commands/build/validate.js +1 -1
- package/dist/commands/build/workos/env/attach.d.ts +2 -0
- package/dist/commands/build/workos/env/attach.d.ts.map +1 -1
- package/dist/commands/build/workos/env/attach.js +17 -5
- package/dist/commands/build/workos/env/create.d.ts +3 -0
- package/dist/commands/build/workos/env/create.d.ts.map +1 -1
- package/dist/commands/build/workos/env/create.js +61 -8
- package/dist/commands/build/workos/env/detach.d.ts +2 -0
- package/dist/commands/build/workos/env/detach.d.ts.map +1 -1
- package/dist/commands/build/workos/env/detach.js +17 -5
- package/dist/commands/build/workos/env/get.d.ts.map +1 -1
- package/dist/commands/build/workos/env/get.js +19 -0
- package/dist/commands/build/workos/env/set.d.ts +12 -6
- package/dist/commands/build/workos/env/set.d.ts.map +1 -1
- package/dist/commands/build/workos/env/set.js +83 -22
- package/dist/commands/build/workos/setup.d.ts +1 -0
- package/dist/commands/build/workos/setup.d.ts.map +1 -1
- package/dist/commands/build/workos/setup.js +12 -3
- package/dist/commands/build/workos/status.d.ts +5 -0
- package/dist/commands/build/workos/status.d.ts.map +1 -1
- package/dist/commands/build/workos/status.js +128 -21
- package/dist/commands/logs/query.d.ts +1 -0
- package/dist/commands/logs/query.d.ts.map +1 -1
- package/dist/commands/logs/query.js +13 -7
- package/dist/commands/logs/tail.d.ts +1 -0
- package/dist/commands/logs/tail.d.ts.map +1 -1
- package/dist/commands/logs/tail.js +14 -8
- package/dist/commands/object/delete.d.ts +1 -0
- package/dist/commands/object/delete.d.ts.map +1 -1
- package/dist/commands/object/delete.js +25 -11
- package/dist/commands/object/get.d.ts +1 -0
- package/dist/commands/object/get.d.ts.map +1 -1
- package/dist/commands/object/get.js +25 -11
- package/dist/commands/object/list.d.ts +1 -0
- package/dist/commands/object/list.d.ts.map +1 -1
- package/dist/commands/object/list.js +26 -12
- package/dist/commands/object/put.d.ts +1 -0
- package/dist/commands/object/put.d.ts.map +1 -1
- package/dist/commands/object/put.js +25 -11
- package/dist/commands/query/chunk-search.d.ts +1 -0
- package/dist/commands/query/chunk-search.d.ts.map +1 -1
- package/dist/commands/query/chunk-search.js +21 -6
- package/dist/commands/query/document.d.ts +3 -1
- package/dist/commands/query/document.d.ts.map +1 -1
- package/dist/commands/query/document.js +36 -13
- package/dist/commands/query/events.d.ts +1 -0
- package/dist/commands/query/events.d.ts.map +1 -1
- package/dist/commands/query/events.js +12 -6
- package/dist/commands/query/reindex.d.ts +1 -0
- package/dist/commands/query/reindex.d.ts.map +1 -1
- package/dist/commands/query/reindex.js +13 -4
- package/dist/commands/query/search.d.ts +2 -0
- package/dist/commands/query/search.d.ts.map +1 -1
- package/dist/commands/query/search.js +37 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/templates/registry.d.ts +38 -0
- package/dist/templates/registry.d.ts.map +1 -0
- package/dist/templates/registry.js +72 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/oclif.manifest.json +2823 -2047
- package/package.json +3 -3
- package/templates/db/node_modules/.bin/prisma +2 -2
- package/templates/db/node_modules/.bin/prisma-kysely +2 -2
- package/templates/db/node_modules/.bin/tsc +2 -2
- package/templates/db/node_modules/.bin/tsserver +2 -2
- package/templates/db/node_modules/.bin/zx +2 -2
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import {
|
|
2
|
+
init_cjs_shims
|
|
3
|
+
} from "./chunk-HMD2JXLE.js";
|
|
4
|
+
|
|
5
|
+
// ../drizzle/dist/mrn.js
|
|
6
|
+
init_cjs_shims();
|
|
7
|
+
function parseMRN(mrn) {
|
|
8
|
+
const parts = mrn.split(":");
|
|
9
|
+
if (parts.length !== 6) {
|
|
10
|
+
throw new Error(`Invalid MRN format: ${mrn}`);
|
|
11
|
+
}
|
|
12
|
+
const [type, applicationName, versionId, module, itemOrKey, revision] = parts;
|
|
13
|
+
if (!type || !applicationName || !versionId) {
|
|
14
|
+
throw new Error(`MRN must contain type, applicationName, and versionId: ${mrn}`);
|
|
15
|
+
}
|
|
16
|
+
if (!["annotation", "label"].includes(type)) {
|
|
17
|
+
throw new Error(`Invalid MRN type: ${type}`);
|
|
18
|
+
}
|
|
19
|
+
const mrnObject = {
|
|
20
|
+
type,
|
|
21
|
+
applicationName,
|
|
22
|
+
versionId
|
|
23
|
+
};
|
|
24
|
+
if (module) {
|
|
25
|
+
mrnObject.module = module;
|
|
26
|
+
}
|
|
27
|
+
if (itemOrKey) {
|
|
28
|
+
if (itemOrKey.includes("^")) {
|
|
29
|
+
const [item, keyValue] = itemOrKey.split("^");
|
|
30
|
+
mrnObject.item = item;
|
|
31
|
+
mrnObject.key = keyValue || "";
|
|
32
|
+
} else {
|
|
33
|
+
mrnObject.key = itemOrKey;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (revision) {
|
|
37
|
+
mrnObject.revision = revision;
|
|
38
|
+
}
|
|
39
|
+
return mrnObject;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export {
|
|
43
|
+
parseMRN
|
|
44
|
+
};
|
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
import {
|
|
2
|
+
source_default
|
|
3
|
+
} from "./chunk-6GTBXHHK.js";
|
|
4
|
+
import {
|
|
5
|
+
BaseCommand
|
|
6
|
+
} from "./chunk-OZWZILJX.js";
|
|
7
|
+
import {
|
|
8
|
+
ApplicationsResponseSchema,
|
|
9
|
+
EPOCH_TS,
|
|
10
|
+
UnitState,
|
|
11
|
+
__toESM,
|
|
12
|
+
init_cjs_shims,
|
|
13
|
+
require_lib,
|
|
14
|
+
timestampDate,
|
|
15
|
+
toJsonString
|
|
16
|
+
} from "./chunk-HMD2JXLE.js";
|
|
17
|
+
|
|
18
|
+
// src/commands/build/list.ts
|
|
19
|
+
init_cjs_shims();
|
|
20
|
+
var import_core = __toESM(require_lib(), 1);
|
|
21
|
+
var statusString = {
|
|
22
|
+
[UnitState.UNSPECIFIED]: "<unknown>",
|
|
23
|
+
[UnitState.PENDING]: "pending...",
|
|
24
|
+
[UnitState.STARTING]: "starting...",
|
|
25
|
+
[UnitState.RUNNING]: "running",
|
|
26
|
+
[UnitState.STOPPING]: "stopping...",
|
|
27
|
+
[UnitState.STOPPED]: "stopped",
|
|
28
|
+
[UnitState.DELETING]: "deleting...",
|
|
29
|
+
[UnitState.DELETED]: "deleted"
|
|
30
|
+
};
|
|
31
|
+
var List = class extends BaseCommand {
|
|
32
|
+
static args = {};
|
|
33
|
+
static description = "list Raindrop catalog resources";
|
|
34
|
+
static examples = [
|
|
35
|
+
`<%= config.bin %> <%= command.id %>
|
|
36
|
+
List applications in compact view (default).
|
|
37
|
+
|
|
38
|
+
<%= config.bin %> <%= command.id %> -o tree
|
|
39
|
+
Show applications in tree view with version hierarchy.
|
|
40
|
+
|
|
41
|
+
<%= config.bin %> <%= command.id %> -o log
|
|
42
|
+
Show git-log style view with branch visualization.
|
|
43
|
+
|
|
44
|
+
<%= config.bin %> <%= command.id %> --app demo-fts --limit 5
|
|
45
|
+
Show only demo-fts application, limited to 5 versions.
|
|
46
|
+
|
|
47
|
+
<%= config.bin %> <%= command.id %> --active
|
|
48
|
+
Show only running/active versions.
|
|
49
|
+
`
|
|
50
|
+
];
|
|
51
|
+
static flags = {
|
|
52
|
+
...BaseCommand.HIDDEN_FLAGS,
|
|
53
|
+
all: import_core.Flags.boolean({ char: "a", description: "show deleted resources", default: false }),
|
|
54
|
+
output: import_core.Flags.string({
|
|
55
|
+
char: "o",
|
|
56
|
+
description: "output format",
|
|
57
|
+
default: "compact",
|
|
58
|
+
options: ["text", "table", "json", "log", "compact", "tree"]
|
|
59
|
+
}),
|
|
60
|
+
app: import_core.Flags.string({
|
|
61
|
+
description: "filter by application name",
|
|
62
|
+
required: false
|
|
63
|
+
}),
|
|
64
|
+
limit: import_core.Flags.integer({
|
|
65
|
+
char: "n",
|
|
66
|
+
description: "limit number of versions shown per application",
|
|
67
|
+
required: false
|
|
68
|
+
}),
|
|
69
|
+
active: import_core.Flags.boolean({
|
|
70
|
+
description: "show only running/active versions",
|
|
71
|
+
default: false
|
|
72
|
+
}),
|
|
73
|
+
impersonate: import_core.Flags.string({
|
|
74
|
+
char: "i",
|
|
75
|
+
description: "impersonate organization",
|
|
76
|
+
required: false,
|
|
77
|
+
hidden: true
|
|
78
|
+
}),
|
|
79
|
+
manifest: import_core.Flags.string({
|
|
80
|
+
char: "m",
|
|
81
|
+
description: "project manifest",
|
|
82
|
+
required: false,
|
|
83
|
+
default: "raindrop.manifest",
|
|
84
|
+
hidden: true
|
|
85
|
+
})
|
|
86
|
+
};
|
|
87
|
+
// Build a version tree from applications
|
|
88
|
+
buildVersionTree(applications) {
|
|
89
|
+
const nodesMap = /* @__PURE__ */ new Map();
|
|
90
|
+
const rootNodes = [];
|
|
91
|
+
applications.forEach((app) => {
|
|
92
|
+
const node = {
|
|
93
|
+
versionId: app.versionId,
|
|
94
|
+
previousVersionId: app.previousVersionId || null,
|
|
95
|
+
application: app,
|
|
96
|
+
children: [],
|
|
97
|
+
branch: app.branch
|
|
98
|
+
};
|
|
99
|
+
nodesMap.set(app.versionId, node);
|
|
100
|
+
});
|
|
101
|
+
for (const node of nodesMap.values()) {
|
|
102
|
+
if (node.previousVersionId && nodesMap.has(node.previousVersionId)) {
|
|
103
|
+
nodesMap.get(node.previousVersionId).children.push(node);
|
|
104
|
+
} else {
|
|
105
|
+
rootNodes.push(node);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return { rootNodes, nodesMap };
|
|
109
|
+
}
|
|
110
|
+
// Render the version tree in git-log style with branch lines
|
|
111
|
+
renderGitLogStyle(applications) {
|
|
112
|
+
const groups = this.groupApplicationsByName(applications);
|
|
113
|
+
const result = [];
|
|
114
|
+
for (const [_appName, appVersions] of groups) {
|
|
115
|
+
result.push("");
|
|
116
|
+
const firstApp = appVersions[0];
|
|
117
|
+
if (!firstApp) continue;
|
|
118
|
+
const formattedAppName = this.formatAppName(firstApp);
|
|
119
|
+
result.push(source_default.bold.underline(`=== ${formattedAppName} ===`));
|
|
120
|
+
result.push("");
|
|
121
|
+
const { rootNodes } = this.buildVersionTree(appVersions);
|
|
122
|
+
const columnMap = /* @__PURE__ */ new Map();
|
|
123
|
+
let maxColumn = 0;
|
|
124
|
+
const assignColumns = (node, parentColumn) => {
|
|
125
|
+
if (columnMap.has(node.versionId)) return;
|
|
126
|
+
if (parentColumn !== void 0) {
|
|
127
|
+
columnMap.set(node.versionId, parentColumn);
|
|
128
|
+
} else {
|
|
129
|
+
columnMap.set(node.versionId, maxColumn++);
|
|
130
|
+
}
|
|
131
|
+
node.children.forEach((child) => {
|
|
132
|
+
assignColumns(child, columnMap.get(node.versionId));
|
|
133
|
+
});
|
|
134
|
+
};
|
|
135
|
+
rootNodes.forEach((root) => assignColumns(root));
|
|
136
|
+
const flattenedNodes = [];
|
|
137
|
+
const flatten = (node) => {
|
|
138
|
+
flattenedNodes.push(node);
|
|
139
|
+
node.children.forEach((child) => flatten(child));
|
|
140
|
+
};
|
|
141
|
+
rootNodes.forEach((root) => flatten(root));
|
|
142
|
+
flattenedNodes.sort((a, b) => {
|
|
143
|
+
const aTime = timestampDate(a.application.createdAt || EPOCH_TS).getTime() || 0;
|
|
144
|
+
const bTime = timestampDate(b.application.createdAt || EPOCH_TS).getTime() || 0;
|
|
145
|
+
return bTime - aTime;
|
|
146
|
+
});
|
|
147
|
+
const processed = /* @__PURE__ */ new Set();
|
|
148
|
+
const linesInUse = /* @__PURE__ */ new Set();
|
|
149
|
+
for (const node of flattenedNodes) {
|
|
150
|
+
if (processed.has(node.versionId)) continue;
|
|
151
|
+
processed.add(node.versionId);
|
|
152
|
+
const app = node.application;
|
|
153
|
+
const column = columnMap.get(node.versionId) || 0;
|
|
154
|
+
linesInUse.add(column);
|
|
155
|
+
const date = timestampDate(app.createdAt || EPOCH_TS);
|
|
156
|
+
const timestamp = date.toLocaleString("en-US", {
|
|
157
|
+
weekday: "short",
|
|
158
|
+
month: "short",
|
|
159
|
+
day: "numeric",
|
|
160
|
+
year: "numeric",
|
|
161
|
+
hour: "numeric",
|
|
162
|
+
minute: "numeric",
|
|
163
|
+
second: "numeric",
|
|
164
|
+
hour12: false,
|
|
165
|
+
timeZoneName: "short"
|
|
166
|
+
});
|
|
167
|
+
let graphLine = "";
|
|
168
|
+
for (let i = 0; i <= maxColumn; i++) {
|
|
169
|
+
if (i === column) {
|
|
170
|
+
graphLine += "*";
|
|
171
|
+
} else if (linesInUse.has(i)) {
|
|
172
|
+
graphLine += "|";
|
|
173
|
+
} else {
|
|
174
|
+
graphLine += " ";
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
let branchInfo = "";
|
|
178
|
+
if (app.branch) {
|
|
179
|
+
branchInfo = ` (${app.branch})`;
|
|
180
|
+
}
|
|
181
|
+
let parentInfo = "";
|
|
182
|
+
if (app.previousVersionId) {
|
|
183
|
+
parentInfo = ` [parent: ${app.previousVersionId}]`;
|
|
184
|
+
}
|
|
185
|
+
const versionLine = `${graphLine} ${source_default.yellow("version")} ${source_default.yellow(app.versionId)}${source_default.cyan(branchInfo)}${source_default.dim(parentInfo)}`;
|
|
186
|
+
result.push(versionLine);
|
|
187
|
+
graphLine = graphLine.replace("*", "|");
|
|
188
|
+
let statusColor;
|
|
189
|
+
if (app.state === UnitState.RUNNING) {
|
|
190
|
+
statusColor = source_default.green;
|
|
191
|
+
} else if (app.state === UnitState.DELETING) {
|
|
192
|
+
statusColor = source_default.yellow;
|
|
193
|
+
} else if (app.state === UnitState.DELETED) {
|
|
194
|
+
statusColor = source_default.red;
|
|
195
|
+
} else {
|
|
196
|
+
statusColor = source_default.gray;
|
|
197
|
+
}
|
|
198
|
+
result.push(`${graphLine} ${source_default.bold("Status:")} ${statusColor(statusString[app.state])}`);
|
|
199
|
+
result.push(`${graphLine} ${source_default.bold("Date:")} ${source_default.dim(timestamp)}`);
|
|
200
|
+
result.push(`${graphLine} `);
|
|
201
|
+
result.push(`${graphLine} ${source_default.bold(this.formatAppName(app))}`);
|
|
202
|
+
result.push(`${graphLine}`);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
return result.join("\n");
|
|
206
|
+
}
|
|
207
|
+
// Helper function to format app name with privileged indicator
|
|
208
|
+
formatAppName(app) {
|
|
209
|
+
const privilegedIcon = app.privileged ? source_default.magenta("\u{1F512} ") : "";
|
|
210
|
+
return `${privilegedIcon}${app.name}`;
|
|
211
|
+
}
|
|
212
|
+
// Group applications by name
|
|
213
|
+
groupApplicationsByName(applications) {
|
|
214
|
+
const groups = /* @__PURE__ */ new Map();
|
|
215
|
+
for (const app of applications) {
|
|
216
|
+
const name = app.name;
|
|
217
|
+
if (!groups.has(name)) {
|
|
218
|
+
groups.set(name, []);
|
|
219
|
+
}
|
|
220
|
+
groups.get(name).push(app);
|
|
221
|
+
}
|
|
222
|
+
for (const apps of groups.values()) {
|
|
223
|
+
apps.sort((a, b) => {
|
|
224
|
+
const aTime = timestampDate(a.createdAt || EPOCH_TS).getTime();
|
|
225
|
+
const bTime = timestampDate(b.createdAt || EPOCH_TS).getTime();
|
|
226
|
+
return bTime - aTime;
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
return groups;
|
|
230
|
+
}
|
|
231
|
+
// Render compact view
|
|
232
|
+
renderCompactView(applications) {
|
|
233
|
+
const groups = this.groupApplicationsByName(applications);
|
|
234
|
+
const result = [];
|
|
235
|
+
const sortedGroups = Array.from(groups.entries()).sort((a, b) => {
|
|
236
|
+
const aLatest = a[1][0];
|
|
237
|
+
const bLatest = b[1][0];
|
|
238
|
+
if (!aLatest || !bLatest) return 0;
|
|
239
|
+
const aTime = timestampDate(aLatest.createdAt || EPOCH_TS).getTime();
|
|
240
|
+
const bTime = timestampDate(bLatest.createdAt || EPOCH_TS).getTime();
|
|
241
|
+
return bTime - aTime;
|
|
242
|
+
});
|
|
243
|
+
for (const [_appName, versions] of sortedGroups) {
|
|
244
|
+
const activeVersions2 = versions.filter((v) => v.state === UnitState.RUNNING);
|
|
245
|
+
const deletedVersions = versions.filter((v) => v.state === UnitState.DELETED || v.state === UnitState.DELETING);
|
|
246
|
+
const firstVersion = versions[0];
|
|
247
|
+
if (!firstVersion) continue;
|
|
248
|
+
const formattedAppName = this.formatAppName(firstVersion);
|
|
249
|
+
result.push(`
|
|
250
|
+
${source_default.bold(formattedAppName)} ${source_default.dim(`(${versions.length} version${versions.length !== 1 ? "s" : ""})`)}`);
|
|
251
|
+
let shown = 0;
|
|
252
|
+
for (const version of activeVersions2) {
|
|
253
|
+
if (this.flags.limit && shown >= this.flags.limit) break;
|
|
254
|
+
const date = timestampDate(version.createdAt || EPOCH_TS).toLocaleDateString();
|
|
255
|
+
const branch = version.branch ? source_default.cyan(` (${version.branch})`) : "";
|
|
256
|
+
const status = source_default.green(statusString[version.state]);
|
|
257
|
+
result.push(` \u2514\u2500 ${source_default.yellow(version.versionId)}...${branch} - ${status} - ${source_default.dim(date)}`);
|
|
258
|
+
shown++;
|
|
259
|
+
}
|
|
260
|
+
if (!this.flags.active && deletedVersions.length > 0) {
|
|
261
|
+
const remaining = this.flags.limit ? Math.max(0, this.flags.limit - shown) : deletedVersions.length;
|
|
262
|
+
const toShow = Math.min(remaining, deletedVersions.length);
|
|
263
|
+
for (let i = 0; i < toShow && i < 3; i++) {
|
|
264
|
+
const version = deletedVersions[i];
|
|
265
|
+
if (!version) continue;
|
|
266
|
+
const date = timestampDate(version.createdAt || EPOCH_TS).toLocaleDateString();
|
|
267
|
+
const status = version.state === UnitState.DELETING ? source_default.yellow(statusString[version.state]) : source_default.red(statusString[version.state]);
|
|
268
|
+
result.push(` \u2514\u2500 ${source_default.gray(version.versionId)}... - ${status} - ${source_default.dim(date)}`);
|
|
269
|
+
}
|
|
270
|
+
if (deletedVersions.length > toShow) {
|
|
271
|
+
result.push(source_default.dim(` ... ${deletedVersions.length - toShow} more deleted versions`));
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
const totalApps = sortedGroups.length;
|
|
276
|
+
const totalVersions = applications.length;
|
|
277
|
+
const activeVersions = applications.filter((app) => app.state === UnitState.RUNNING).length;
|
|
278
|
+
result.push("");
|
|
279
|
+
result.push(source_default.dim("\u2500".repeat(50)));
|
|
280
|
+
result.push(source_default.dim(`Total: ${totalApps} applications, ${totalVersions} versions (${activeVersions} active)`));
|
|
281
|
+
return result.join("\n");
|
|
282
|
+
}
|
|
283
|
+
// Render tree view for a specific application
|
|
284
|
+
renderTreeView(applications) {
|
|
285
|
+
const groups = this.groupApplicationsByName(applications);
|
|
286
|
+
const result = [];
|
|
287
|
+
for (const [_appName, versions] of groups) {
|
|
288
|
+
const firstVersion = versions[0];
|
|
289
|
+
if (!firstVersion) continue;
|
|
290
|
+
const formattedAppName = this.formatAppName(firstVersion);
|
|
291
|
+
result.push(`
|
|
292
|
+
${source_default.bold.underline(`=== ${formattedAppName} ===`)}`);
|
|
293
|
+
const { rootNodes } = this.buildVersionTree(versions);
|
|
294
|
+
const renderNode = (node, prefix = "", isLast = true) => {
|
|
295
|
+
const app = node.application;
|
|
296
|
+
const date = timestampDate(app.createdAt || EPOCH_TS).toLocaleDateString();
|
|
297
|
+
const branch = app.branch ? source_default.cyan(` (${app.branch})`) : "";
|
|
298
|
+
let status;
|
|
299
|
+
if (app.state === UnitState.RUNNING) {
|
|
300
|
+
status = source_default.green(statusString[app.state]);
|
|
301
|
+
} else if (app.state === UnitState.DELETING) {
|
|
302
|
+
status = source_default.yellow(statusString[app.state]);
|
|
303
|
+
} else if (app.state === UnitState.DELETED) {
|
|
304
|
+
status = source_default.red(statusString[app.state]);
|
|
305
|
+
} else {
|
|
306
|
+
status = source_default.gray(statusString[app.state]);
|
|
307
|
+
}
|
|
308
|
+
const current = app.state === UnitState.RUNNING && app.branch === "main" ? source_default.bold.green(" \u2190 current") : "";
|
|
309
|
+
const connector = isLast ? "\u2514\u2500" : "\u251C\u2500";
|
|
310
|
+
const shortId = source_default.yellow(app.versionId);
|
|
311
|
+
result.push(`${prefix}${connector} ${shortId}...${branch} - ${status} - ${source_default.dim(date)}${current}`);
|
|
312
|
+
const childPrefix = prefix + (isLast ? " " : "\u2502 ");
|
|
313
|
+
node.children.forEach((child, index) => {
|
|
314
|
+
renderNode(child, childPrefix, index === node.children.length - 1);
|
|
315
|
+
});
|
|
316
|
+
};
|
|
317
|
+
rootNodes.forEach((root, index) => {
|
|
318
|
+
renderNode(root, "", index === rootNodes.length - 1);
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
return result.join("\n");
|
|
322
|
+
}
|
|
323
|
+
async listApplications() {
|
|
324
|
+
const { client: catalogService, organizationId: defaultOrganizationId, userId } = await this.catalogService();
|
|
325
|
+
const organizationId = this.flags.impersonate ?? defaultOrganizationId;
|
|
326
|
+
if (this.flags.output === "log" || this.flags.output === "table") {
|
|
327
|
+
this.log(source_default.dim(`Listing applications for organization ${organizationId}`));
|
|
328
|
+
}
|
|
329
|
+
const resp = await catalogService.applications({
|
|
330
|
+
userId,
|
|
331
|
+
organizationId,
|
|
332
|
+
showDeleted: this.flags.all
|
|
333
|
+
});
|
|
334
|
+
let applications = resp.applications;
|
|
335
|
+
if (this.flags.app) {
|
|
336
|
+
applications = applications.filter((app) => app.name === this.flags.app);
|
|
337
|
+
}
|
|
338
|
+
if (this.flags.active) {
|
|
339
|
+
applications = applications.filter((app) => app.state === UnitState.RUNNING);
|
|
340
|
+
}
|
|
341
|
+
if (this.flags.output === "log") {
|
|
342
|
+
this.log(this.renderGitLogStyle(applications));
|
|
343
|
+
} else if (this.flags.output === "compact") {
|
|
344
|
+
this.log(this.renderCompactView(applications));
|
|
345
|
+
} else if (this.flags.output === "tree") {
|
|
346
|
+
this.log(this.renderTreeView(applications));
|
|
347
|
+
} else if (this.flags.output === "table") {
|
|
348
|
+
console.table(
|
|
349
|
+
applications.reduce(
|
|
350
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
351
|
+
(acc, a) => {
|
|
352
|
+
const dateStr = a.createdAt ? timestampDate(a.createdAt).toISOString() : "";
|
|
353
|
+
acc[dateStr] = {
|
|
354
|
+
...a,
|
|
355
|
+
status: statusString[a.state],
|
|
356
|
+
locked: a.lock ? "locked" : "",
|
|
357
|
+
privileged: a.privileged ? "system" : "user"
|
|
358
|
+
};
|
|
359
|
+
return acc;
|
|
360
|
+
},
|
|
361
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
362
|
+
{}
|
|
363
|
+
),
|
|
364
|
+
["organizationId", "name", "versionId", "branch", "status", "locked", "privileged", ...this.flags.all ? ["deletedAt"] : []]
|
|
365
|
+
);
|
|
366
|
+
} else if (this.flags.output === "json") {
|
|
367
|
+
console.log(toJsonString(ApplicationsResponseSchema, resp, { prettySpaces: 2 }));
|
|
368
|
+
} else {
|
|
369
|
+
this.log(this.renderCompactView(applications));
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
async run() {
|
|
373
|
+
await this.listApplications();
|
|
374
|
+
}
|
|
375
|
+
};
|
|
376
|
+
|
|
377
|
+
export {
|
|
378
|
+
statusString,
|
|
379
|
+
List
|
|
380
|
+
};
|