@liquidmetal-ai/raindrop 0.7.0 → 0.8.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 +408 -73
- package/bin/cjs-shims.js +7 -0
- package/bin/run.js +20 -2
- package/bundle/chunk-5GH4FS6C.js +12148 -0
- package/bundle/chunk-6B4I2CKP.js +231 -0
- package/bundle/chunk-6UE75KX2.js +4481 -0
- package/bundle/chunk-AU3EGGJP.js +44 -0
- package/bundle/chunk-CDQRD3JA.js +75 -0
- package/bundle/chunk-CMCEP64V.js +380 -0
- package/bundle/chunk-CW5ZHVPX.js +292 -0
- package/bundle/chunk-G6NE675D.js +238720 -0
- package/bundle/chunk-GLIYVKQA.js +48 -0
- package/bundle/chunk-KXEV6E63.js +133 -0
- package/bundle/chunk-MCRKUPJY.js +4515 -0
- package/bundle/chunk-MGM2L2T3.js +805 -0
- package/bundle/chunk-MVQYQJHI.js +502 -0
- package/bundle/chunk-NG7CZTTE.js +147 -0
- package/bundle/chunk-PU4RCSXF.js +22452 -0
- package/bundle/chunk-VXAZKB3J.js +292 -0
- package/bundle/chunk-W2L3MYN6.js +4480 -0
- package/bundle/chunk-XYJACVNA.js +231 -0
- package/bundle/commands/annotation/get.js +153 -0
- package/bundle/commands/annotation/list.js +226 -0
- package/bundle/commands/annotation/put.js +177 -0
- package/bundle/commands/auth/list.js +75 -0
- package/bundle/commands/auth/login.js +1654 -0
- package/bundle/commands/auth/logout.js +27 -0
- package/bundle/commands/auth/select.js +53 -0
- package/bundle/commands/bucket/create-credential.js +173 -0
- package/bundle/commands/bucket/delete-credential.js +140 -0
- package/bundle/commands/bucket/get-credential.js +151 -0
- package/bundle/commands/bucket/list-credentials.js +148 -0
- package/bundle/commands/build/branch.js +126 -0
- package/bundle/commands/build/checkout.js +198 -0
- package/bundle/commands/build/clone.js +153 -0
- package/bundle/commands/build/delete.js +227 -0
- package/bundle/commands/build/deploy.js +160 -0
- package/bundle/commands/build/env/get.js +105 -0
- package/bundle/commands/build/env/set.js +115 -0
- package/bundle/commands/build/find.js +333 -0
- package/bundle/commands/build/generate.js +75 -0
- package/bundle/commands/build/init.js +76 -0
- package/bundle/commands/build/list.js +11 -0
- package/bundle/commands/build/sandbox.js +65 -0
- package/bundle/commands/build/start.js +84 -0
- package/bundle/commands/build/status.js +1839 -0
- package/bundle/commands/build/stop.js +84 -0
- package/bundle/commands/build/tools/check.js +32 -0
- package/bundle/commands/build/tools/fmt.js +49 -0
- package/bundle/commands/build/unsandbox.js +65 -0
- package/bundle/commands/build/upload.js +83 -0
- package/bundle/commands/build/validate.js +71 -0
- package/bundle/commands/build/workos/delete.js +86 -0
- package/bundle/commands/build/workos/env/attach.js +134 -0
- package/bundle/commands/build/workos/env/create.js +176 -0
- package/bundle/commands/build/workos/env/delete.js +84 -0
- package/bundle/commands/build/workos/env/detach.js +115 -0
- package/bundle/commands/build/workos/env/get.js +117 -0
- package/bundle/commands/build/workos/env/list.js +139 -0
- package/bundle/commands/build/workos/env/set.js +138 -0
- package/bundle/commands/build/workos/invite.js +91 -0
- package/bundle/commands/build/workos/setup.js +124 -0
- package/bundle/commands/build/workos/status.js +93 -0
- package/bundle/commands/dns/create.js +128 -0
- package/bundle/commands/dns/delete.js +80 -0
- package/bundle/commands/dns/get.js +167 -0
- package/bundle/commands/dns/list.js +193 -0
- package/bundle/commands/dns/records/create.js +150 -0
- package/bundle/commands/dns/records/delete.js +76 -0
- package/bundle/commands/dns/records/get.js +118 -0
- package/bundle/commands/dns/records/list.js +153 -0
- package/bundle/commands/dns/records/update.js +146 -0
- package/bundle/commands/logs/query.js +237 -0
- package/bundle/commands/logs/tail.js +155 -0
- package/bundle/commands/mcp/install-claude.js +220 -0
- package/bundle/commands/mcp/install-gemini.js +220 -0
- package/bundle/commands/mcp/install-goose.js +232 -0
- package/bundle/commands/mcp/status.js +153 -0
- package/bundle/commands/object/delete.js +180 -0
- package/bundle/commands/object/get.js +209 -0
- package/bundle/commands/object/list.js +206 -0
- package/bundle/commands/object/put.js +211 -0
- package/bundle/commands/query/chunk-search.js +123 -0
- package/bundle/commands/query/document.js +126 -0
- package/bundle/commands/query/events.js +98 -0
- package/bundle/commands/query/reindex.js +147 -0
- package/bundle/commands/query/search.js +169 -0
- package/bundle/commands/tail.js +31 -0
- package/bundle/index.js +51 -0
- package/dist/base-command.d.ts +6 -0
- package/dist/base-command.d.ts.map +1 -1
- package/dist/base-command.js +14 -1
- package/dist/build.d.ts +2 -1
- package/dist/build.d.ts.map +1 -1
- package/dist/build.js +169 -51
- package/dist/codegen.d.ts +1 -1
- package/dist/codegen.d.ts.map +1 -1
- package/dist/codegen.js +17 -3
- package/dist/codegen.test.js +44 -0
- package/dist/commands/build/checkout.d.ts.map +1 -1
- package/dist/commands/build/checkout.js +4 -0
- package/dist/commands/build/delete.d.ts.map +1 -1
- package/dist/commands/build/delete.js +6 -3
- package/dist/commands/build/deploy.d.ts.map +1 -1
- package/dist/commands/build/deploy.js +10 -2
- 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 +33 -2
- package/dist/commands/build/validate.d.ts.map +1 -1
- package/dist/commands/build/validate.js +0 -1
- package/dist/commands/build/workos/delete.d.ts +18 -0
- package/dist/commands/build/workos/delete.d.ts.map +1 -0
- package/dist/commands/build/workos/delete.js +72 -0
- package/dist/commands/build/workos/env/attach.d.ts +24 -0
- package/dist/commands/build/workos/env/attach.d.ts.map +1 -0
- package/dist/commands/build/workos/env/attach.js +111 -0
- package/dist/commands/build/workos/env/create.d.ts +26 -0
- package/dist/commands/build/workos/env/create.d.ts.map +1 -0
- package/dist/commands/build/workos/env/create.js +156 -0
- package/dist/commands/build/workos/env/delete.d.ts +20 -0
- package/dist/commands/build/workos/env/delete.d.ts.map +1 -0
- package/dist/commands/build/workos/env/delete.js +61 -0
- package/dist/commands/build/workos/env/detach.d.ts +21 -0
- package/dist/commands/build/workos/env/detach.d.ts.map +1 -0
- package/dist/commands/build/workos/env/detach.js +94 -0
- package/dist/commands/build/workos/env/get.d.ts +20 -0
- package/dist/commands/build/workos/env/get.d.ts.map +1 -0
- package/dist/commands/build/workos/env/get.js +94 -0
- package/dist/commands/build/workos/env/list.d.ts +18 -0
- package/dist/commands/build/workos/env/list.d.ts.map +1 -0
- package/dist/commands/build/workos/env/list.js +114 -0
- package/dist/commands/build/workos/env/set.d.ts +27 -0
- package/dist/commands/build/workos/env/set.d.ts.map +1 -0
- package/dist/commands/build/workos/env/set.js +115 -0
- package/dist/commands/build/workos/invite.d.ts +21 -0
- package/dist/commands/build/workos/invite.d.ts.map +1 -0
- package/dist/commands/build/workos/invite.js +68 -0
- package/dist/commands/build/workos/setup.d.ts +20 -0
- package/dist/commands/build/workos/setup.d.ts.map +1 -0
- package/dist/commands/build/workos/setup.js +106 -0
- package/dist/commands/build/workos/status.d.ts +18 -0
- package/dist/commands/build/workos/status.d.ts.map +1 -0
- package/dist/commands/build/workos/status.js +70 -0
- package/dist/commands/mcp/install-claude.d.ts.map +1 -1
- package/dist/commands/mcp/install-claude.js +0 -2
- package/dist/commands/mcp/install-gemini.d.ts.map +1 -1
- package/dist/commands/mcp/install-gemini.js +0 -2
- package/dist/commands/mcp/install-goose.d.ts.map +1 -1
- package/dist/commands/mcp/install-goose.js +0 -2
- package/dist/deploy.d.ts.map +1 -1
- package/dist/deploy.js +2 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/oclif.manifest.json +4286 -2208
- package/package.json +8 -5
- package/templates/claude-code/debug-raindrop-app.md +89 -0
- package/templates/claude-code/new-raindrop-app.md +10 -6
- package/templates/claude-code/reattach-raindrop-session.md +50 -12
- package/templates/claude-code/update-raindrop-app.md +61 -9
- 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
- package/templates/gemini-code/debug-raindrop-app.toml +86 -0
- package/templates/gemini-code/new-raindrop-app.toml +9 -5
- package/templates/gemini-code/reattach-raindrop-session.toml +9 -11
- package/templates/gemini-code/update-raindrop-app.toml +55 -10
- package/templates/goose/debug-raindrop-app.yaml +91 -0
- package/templates/goose/new-raindrop-app.yaml +12 -7
- package/templates/goose/reattach-raindrop-session.yaml +11 -4
- package/templates/goose/update-raindrop-app.yaml +57 -5
- package/templates/init/src/_app/auth.ts +18 -0
- package/templates/init/src/_app/cors.ts +64 -0
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/templates/claude-code/raindrop-guidelines.md +0 -322
- package/templates/gemini-code/raindrop-guidelines.md +0 -322
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import {
|
|
2
|
+
FileSystemBundle,
|
|
3
|
+
archive
|
|
4
|
+
} from "./chunk-MGM2L2T3.js";
|
|
5
|
+
import {
|
|
6
|
+
buildHandlers
|
|
7
|
+
} from "./chunk-VXAZKB3J.js";
|
|
8
|
+
import {
|
|
9
|
+
tmpdir
|
|
10
|
+
} from "./chunk-PU4RCSXF.js";
|
|
11
|
+
import {
|
|
12
|
+
BundleArchiveType,
|
|
13
|
+
Code,
|
|
14
|
+
ConnectError,
|
|
15
|
+
ReleaseRequest_LockSchema,
|
|
16
|
+
create,
|
|
17
|
+
init_cjs_shims,
|
|
18
|
+
listEnvVars,
|
|
19
|
+
valueOf
|
|
20
|
+
} from "./chunk-G6NE675D.js";
|
|
21
|
+
|
|
22
|
+
// src/deploy.ts
|
|
23
|
+
init_cjs_shims();
|
|
24
|
+
import fs from "node:fs/promises";
|
|
25
|
+
import * as path from "node:path";
|
|
26
|
+
async function deploy(options) {
|
|
27
|
+
const { command, root, manifest, output } = options;
|
|
28
|
+
const manifestPath = path.isAbsolute(manifest) ? manifest : path.join(root, manifest);
|
|
29
|
+
const buildDir = path.isAbsolute(output) ? output : path.join(root, output);
|
|
30
|
+
const apps = await command.loadManifest();
|
|
31
|
+
if (apps[0] === void 0) {
|
|
32
|
+
command.error("There are no applications in the manifest");
|
|
33
|
+
return "";
|
|
34
|
+
}
|
|
35
|
+
const app = apps[0];
|
|
36
|
+
const manifestContents = await fs.readFile(manifestPath, "utf8");
|
|
37
|
+
await buildHandlers(command, apps, buildDir, root);
|
|
38
|
+
const runtimeVersion = await command.raindropFrameworkVersion();
|
|
39
|
+
const { client: catalogService, userId, organizationId: defaultOrganizationId } = await command.catalogService();
|
|
40
|
+
const organizationId = options.impersonate ?? defaultOrganizationId;
|
|
41
|
+
let deployResp;
|
|
42
|
+
try {
|
|
43
|
+
deployResp = await catalogService.deploy({
|
|
44
|
+
userId,
|
|
45
|
+
organizationId,
|
|
46
|
+
applications: [
|
|
47
|
+
{
|
|
48
|
+
application: valueOf(app.name),
|
|
49
|
+
previousVersionId: options.previousVersionId,
|
|
50
|
+
currentVersionId: options.currentVersionId,
|
|
51
|
+
branch: options.branch,
|
|
52
|
+
amend: options.amend,
|
|
53
|
+
metadata: {
|
|
54
|
+
runtimeVersion
|
|
55
|
+
},
|
|
56
|
+
manifest: manifestContents,
|
|
57
|
+
lock: options.lock,
|
|
58
|
+
suite: ""
|
|
59
|
+
}
|
|
60
|
+
]
|
|
61
|
+
});
|
|
62
|
+
} catch (err) {
|
|
63
|
+
if (err instanceof ConnectError && err.code === Code.FailedPrecondition) {
|
|
64
|
+
command.error(
|
|
65
|
+
`Failed to ${options.amend ? "amend" : "deploy"} ${valueOf(app.name)}@${options.previousVersionId}=>${options.currentVersionId}: ${err.message}`
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
throw err;
|
|
69
|
+
}
|
|
70
|
+
if (deployResp.applications[0] === void 0) {
|
|
71
|
+
command.error("Failed to deploy application");
|
|
72
|
+
}
|
|
73
|
+
const currentVersionId = deployResp.applications[0].currentVersionId;
|
|
74
|
+
if (!currentVersionId) {
|
|
75
|
+
command.error("Failed to retrieve current version ID from deployment response.");
|
|
76
|
+
}
|
|
77
|
+
const lock = deployResp.applications[0].lock;
|
|
78
|
+
const config = await command.loadConfig();
|
|
79
|
+
config.versionId = currentVersionId;
|
|
80
|
+
config.lock = lock;
|
|
81
|
+
await command.saveConfig(config);
|
|
82
|
+
await checkEnvironmentVariables(command, app, catalogService, userId, organizationId, currentVersionId);
|
|
83
|
+
await uploadBundles(command, app, buildDir, catalogService, userId, organizationId, currentVersionId);
|
|
84
|
+
await uploadDbBundle(command, root, catalogService, userId, organizationId, app, currentVersionId);
|
|
85
|
+
if (options.start) {
|
|
86
|
+
await catalogService.setActive({
|
|
87
|
+
userId,
|
|
88
|
+
organizationId,
|
|
89
|
+
applications: deployResp.applications.map((a) => ({
|
|
90
|
+
applicationName: a.applicationName,
|
|
91
|
+
currentVersionId: a.currentVersionId,
|
|
92
|
+
isActive: options.start
|
|
93
|
+
}))
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
await catalogService.release({
|
|
97
|
+
userId,
|
|
98
|
+
organizationId,
|
|
99
|
+
locks: deployResp.applications.map(
|
|
100
|
+
(a) => create(ReleaseRequest_LockSchema, {
|
|
101
|
+
applicationName: a.applicationName,
|
|
102
|
+
currentVersionId: a.currentVersionId,
|
|
103
|
+
lock: a.lock
|
|
104
|
+
})
|
|
105
|
+
)
|
|
106
|
+
});
|
|
107
|
+
config.lock = void 0;
|
|
108
|
+
await command.saveConfig(config);
|
|
109
|
+
return currentVersionId;
|
|
110
|
+
}
|
|
111
|
+
async function checkEnvironmentVariables(command, app, catalogService, userId, organizationId, currentVersionId) {
|
|
112
|
+
const envVars = listEnvVars(app);
|
|
113
|
+
if (Object.keys(envVars).length > 0) {
|
|
114
|
+
const getEnvsResp = await catalogService.getEnvs({
|
|
115
|
+
userId,
|
|
116
|
+
organizationId,
|
|
117
|
+
envs: Object.keys(envVars).map((key) => ({
|
|
118
|
+
applicationName: valueOf(app.name),
|
|
119
|
+
currentVersionId,
|
|
120
|
+
key
|
|
121
|
+
}))
|
|
122
|
+
});
|
|
123
|
+
let unset = false;
|
|
124
|
+
const remoteEnvVars = Object.fromEntries(getEnvsResp.envs.map((env) => [env.key, env.value]));
|
|
125
|
+
for (const key of Object.keys(envVars)) {
|
|
126
|
+
const manifestDefault = envVars[key]?.default;
|
|
127
|
+
const remoteValue = remoteEnvVars[key];
|
|
128
|
+
if (remoteValue === void 0 && manifestDefault === void 0) {
|
|
129
|
+
if (!unset) {
|
|
130
|
+
command.warn(`The following environment variables were not set and are required for deployment:`);
|
|
131
|
+
}
|
|
132
|
+
unset = true;
|
|
133
|
+
command.warn(key);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
if (unset) {
|
|
137
|
+
command.error(
|
|
138
|
+
"Please set environment variables before deploying. You can resume using `raindrop build deploy --amend`"
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
async function uploadBundles(command, app, buildDir, catalogService, userId, organizationId, currentVersionId) {
|
|
144
|
+
await Promise.all(
|
|
145
|
+
app.handlers().map(async (handler) => {
|
|
146
|
+
const bundle = new FileSystemBundle(path.join(buildDir, valueOf(handler.name)));
|
|
147
|
+
await catalogService.uploadBundle({
|
|
148
|
+
userId,
|
|
149
|
+
organizationId,
|
|
150
|
+
applicationName: valueOf(app.name),
|
|
151
|
+
applicationVersionId: currentVersionId,
|
|
152
|
+
archiveType: BundleArchiveType.ZIP,
|
|
153
|
+
bundleName: valueOf(handler.name),
|
|
154
|
+
archive: Buffer.from(await archive(bundle))
|
|
155
|
+
});
|
|
156
|
+
command.log(`Uploaded bundle "${valueOf(handler.name)}"`);
|
|
157
|
+
})
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
async function uploadDbBundle(command, root, catalogService, userId, organizationId, app, currentVersionId) {
|
|
161
|
+
const dbDir = path.join(root, "db");
|
|
162
|
+
let dbExists = false;
|
|
163
|
+
try {
|
|
164
|
+
const stat = await fs.lstat(dbDir);
|
|
165
|
+
dbExists = stat.isDirectory();
|
|
166
|
+
} catch (_e) {
|
|
167
|
+
}
|
|
168
|
+
if (dbExists) {
|
|
169
|
+
command.log(`Checking for SQL files in ${dbDir}`);
|
|
170
|
+
const files = await fs.readdir(dbDir, {
|
|
171
|
+
withFileTypes: true
|
|
172
|
+
});
|
|
173
|
+
const folders = files.filter((file) => file.isDirectory());
|
|
174
|
+
try {
|
|
175
|
+
const tempDir = tmpdir();
|
|
176
|
+
for (const folder of folders) {
|
|
177
|
+
const sqlFiles = (await fs.readdir(path.join(dbDir, folder.name))).filter((file) => file.endsWith(".sql"));
|
|
178
|
+
const tmpDbFolder = await fs.mkdir(path.join(tempDir, folder.name), { recursive: true });
|
|
179
|
+
for (const sqlFile of sqlFiles) {
|
|
180
|
+
await fs.copyFile(path.join(dbDir, folder.name, sqlFile), path.join(tmpDbFolder, sqlFile));
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
const dbBundle = new FileSystemBundle(tempDir);
|
|
184
|
+
await catalogService.uploadBundle({
|
|
185
|
+
userId,
|
|
186
|
+
organizationId,
|
|
187
|
+
applicationName: valueOf(app.name),
|
|
188
|
+
applicationVersionId: currentVersionId,
|
|
189
|
+
archiveType: BundleArchiveType.ZIP,
|
|
190
|
+
bundleName: "db",
|
|
191
|
+
archive: Buffer.from(await archive(dbBundle))
|
|
192
|
+
});
|
|
193
|
+
command.log(`Uploaded db bundle with SQL files`);
|
|
194
|
+
await fs.rm(tempDir, { recursive: true, force: true });
|
|
195
|
+
} catch (error) {
|
|
196
|
+
command.log(`Failed to upload db bundle: ${error}`);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
async function sandbox(options) {
|
|
201
|
+
const { command, versionId: versionIdRaw, impersonate, isSandboxed } = options;
|
|
202
|
+
const config = await command.loadConfig();
|
|
203
|
+
const { client: catalogService, userId, organizationId: defaultOrganizationId } = await command.catalogService();
|
|
204
|
+
const organizationId = impersonate ?? defaultOrganizationId;
|
|
205
|
+
const apps = await command.loadManifest();
|
|
206
|
+
const app = apps[0];
|
|
207
|
+
const versionId = versionIdRaw ?? config.versionId;
|
|
208
|
+
if (!app) {
|
|
209
|
+
throw new Error("No application found");
|
|
210
|
+
}
|
|
211
|
+
const applications = [
|
|
212
|
+
{
|
|
213
|
+
applicationName: valueOf(app.name),
|
|
214
|
+
currentVersionId: versionId,
|
|
215
|
+
isSandboxed
|
|
216
|
+
}
|
|
217
|
+
];
|
|
218
|
+
await catalogService.setSandbox({
|
|
219
|
+
userId,
|
|
220
|
+
organizationId,
|
|
221
|
+
applications
|
|
222
|
+
});
|
|
223
|
+
config.sandbox = isSandboxed;
|
|
224
|
+
await command.saveConfig(config);
|
|
225
|
+
return applications;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
export {
|
|
229
|
+
deploy,
|
|
230
|
+
sandbox
|
|
231
|
+
};
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import {
|
|
2
|
+
parseMRN
|
|
3
|
+
} from "../../chunk-AU3EGGJP.js";
|
|
4
|
+
import {
|
|
5
|
+
BaseCommand
|
|
6
|
+
} from "../../chunk-MCRKUPJY.js";
|
|
7
|
+
import {
|
|
8
|
+
AnnotationLocatorSchema,
|
|
9
|
+
GetAnnotationRequestSchema,
|
|
10
|
+
__toESM,
|
|
11
|
+
create,
|
|
12
|
+
init_cjs_shims,
|
|
13
|
+
require_lib,
|
|
14
|
+
valueOf
|
|
15
|
+
} from "../../chunk-G6NE675D.js";
|
|
16
|
+
|
|
17
|
+
// src/commands/annotation/get.ts
|
|
18
|
+
init_cjs_shims();
|
|
19
|
+
var import_core = __toESM(require_lib(), 1);
|
|
20
|
+
var AnnotationGet = class _AnnotationGet extends BaseCommand {
|
|
21
|
+
static args = {
|
|
22
|
+
mrn: import_core.Args.string({
|
|
23
|
+
description: "MRN (Machine Resource Name) of the annotation to retrieve. Can be partial (e.g., my-module:my-key:) or full (e.g., annotation:app:v1:my-module:my-key:)",
|
|
24
|
+
required: true
|
|
25
|
+
})
|
|
26
|
+
};
|
|
27
|
+
static description = "Get an annotation by MRN";
|
|
28
|
+
static examples = [
|
|
29
|
+
`<%= config.bin %> annotation get my-module:my-item^my-key:
|
|
30
|
+
Get annotation by partial MRN (prefilled with app/version from manifest and config)
|
|
31
|
+
`,
|
|
32
|
+
`<%= config.bin %> annotation get annotation:my-app:v1.0.0:my-module:my-item^my-key:
|
|
33
|
+
Get annotation with the full MRN
|
|
34
|
+
`,
|
|
35
|
+
`<%= config.bin %> annotation get my-module:my-key: --format json
|
|
36
|
+
Get annotation by partial MRN and output as JSON
|
|
37
|
+
`
|
|
38
|
+
];
|
|
39
|
+
static flags = {
|
|
40
|
+
...BaseCommand.HIDDEN_FLAGS,
|
|
41
|
+
format: import_core.Flags.string({
|
|
42
|
+
char: "f",
|
|
43
|
+
description: "output format",
|
|
44
|
+
default: "text",
|
|
45
|
+
options: ["text", "json"]
|
|
46
|
+
}),
|
|
47
|
+
impersonate: import_core.Flags.string({
|
|
48
|
+
char: "i",
|
|
49
|
+
description: "impersonate organization",
|
|
50
|
+
required: false,
|
|
51
|
+
hidden: true
|
|
52
|
+
}),
|
|
53
|
+
manifest: import_core.Flags.string({
|
|
54
|
+
char: "M",
|
|
55
|
+
description: "project manifest",
|
|
56
|
+
required: false,
|
|
57
|
+
default: "raindrop.manifest",
|
|
58
|
+
hidden: true
|
|
59
|
+
})
|
|
60
|
+
};
|
|
61
|
+
async run() {
|
|
62
|
+
const { args, flags } = await this.parse(_AnnotationGet);
|
|
63
|
+
let fullMrn = args.mrn;
|
|
64
|
+
let mrnParts;
|
|
65
|
+
if (!args.mrn.startsWith("annotation:") && !args.mrn.startsWith("label:")) {
|
|
66
|
+
const apps = await this.loadManifest();
|
|
67
|
+
const config = await this.loadConfig();
|
|
68
|
+
if (apps.length === 0) {
|
|
69
|
+
this.error("No applications found in manifest");
|
|
70
|
+
}
|
|
71
|
+
const app = apps[0];
|
|
72
|
+
const appName = valueOf(app.name);
|
|
73
|
+
const versionId = config.versionId;
|
|
74
|
+
console.log(`Using application: ${appName}, version: ${versionId}`);
|
|
75
|
+
if (!appName) {
|
|
76
|
+
this.error("Application name not found in manifest");
|
|
77
|
+
}
|
|
78
|
+
if (!versionId) {
|
|
79
|
+
this.error("Version ID not found in config. Run a build or deployment first to set the version.");
|
|
80
|
+
}
|
|
81
|
+
fullMrn = `annotation:${appName}:${versionId}:${args.mrn}`;
|
|
82
|
+
}
|
|
83
|
+
const parts = fullMrn.split(":");
|
|
84
|
+
if (parts.length < 6) {
|
|
85
|
+
const colonsToAdd = 6 - parts.length;
|
|
86
|
+
fullMrn += ":".repeat(colonsToAdd);
|
|
87
|
+
}
|
|
88
|
+
try {
|
|
89
|
+
mrnParts = parseMRN(fullMrn);
|
|
90
|
+
} catch (error) {
|
|
91
|
+
this.error(`Invalid MRN format: ${error}`);
|
|
92
|
+
}
|
|
93
|
+
const {
|
|
94
|
+
client: annotationServiceClient,
|
|
95
|
+
userId,
|
|
96
|
+
organizationId
|
|
97
|
+
} = await this.annotationService();
|
|
98
|
+
try {
|
|
99
|
+
const locator = create(AnnotationLocatorSchema, {
|
|
100
|
+
applicationName: mrnParts.applicationName,
|
|
101
|
+
applicationVersionId: mrnParts.versionId,
|
|
102
|
+
moduleName: mrnParts.module,
|
|
103
|
+
item: mrnParts.item,
|
|
104
|
+
key: mrnParts.key,
|
|
105
|
+
revision: mrnParts.revision
|
|
106
|
+
});
|
|
107
|
+
const request = create(GetAnnotationRequestSchema, {
|
|
108
|
+
userId,
|
|
109
|
+
organizationId,
|
|
110
|
+
locator
|
|
111
|
+
});
|
|
112
|
+
const response = await annotationServiceClient.getAnnotation(request);
|
|
113
|
+
switch (flags.format) {
|
|
114
|
+
case "json":
|
|
115
|
+
console.log(
|
|
116
|
+
JSON.stringify(
|
|
117
|
+
{
|
|
118
|
+
mrn: fullMrn,
|
|
119
|
+
inputMrn: args.mrn,
|
|
120
|
+
...mrnParts,
|
|
121
|
+
annotation: response.annotation?.annotation || "",
|
|
122
|
+
location: response.annotation?.location
|
|
123
|
+
},
|
|
124
|
+
null,
|
|
125
|
+
2
|
|
126
|
+
)
|
|
127
|
+
);
|
|
128
|
+
break;
|
|
129
|
+
case "text":
|
|
130
|
+
console.log(`MRN: ${fullMrn}`);
|
|
131
|
+
if (fullMrn !== args.mrn) {
|
|
132
|
+
console.log(`Input: ${args.mrn} (prefilled with app/version)`);
|
|
133
|
+
}
|
|
134
|
+
console.log(`Type: ${mrnParts.type}`);
|
|
135
|
+
console.log(`Application: ${mrnParts.applicationName}`);
|
|
136
|
+
console.log(`Version: ${mrnParts.versionId}`);
|
|
137
|
+
if (mrnParts.module) console.log(`Module: ${mrnParts.module}`);
|
|
138
|
+
if (mrnParts.item) console.log(`Item: ${mrnParts.item}`);
|
|
139
|
+
if (mrnParts.key) console.log(`Key: ${mrnParts.key}`);
|
|
140
|
+
if (mrnParts.revision) console.log(`Revision: ${mrnParts.revision}`);
|
|
141
|
+
console.log("");
|
|
142
|
+
console.log("Annotation:");
|
|
143
|
+
console.log(response.annotation?.annotation || "(no content)");
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
} catch (error) {
|
|
147
|
+
this.error(`Failed to get annotation: ${error}`);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
export {
|
|
152
|
+
AnnotationGet as default
|
|
153
|
+
};
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import {
|
|
2
|
+
parseMRN
|
|
3
|
+
} from "../../chunk-AU3EGGJP.js";
|
|
4
|
+
import {
|
|
5
|
+
BaseCommand
|
|
6
|
+
} from "../../chunk-MCRKUPJY.js";
|
|
7
|
+
import {
|
|
8
|
+
AnnotationLocatorSchema,
|
|
9
|
+
ListAnnotationsRequestSchema,
|
|
10
|
+
__toESM,
|
|
11
|
+
create,
|
|
12
|
+
init_cjs_shims,
|
|
13
|
+
require_lib,
|
|
14
|
+
valueOf
|
|
15
|
+
} from "../../chunk-G6NE675D.js";
|
|
16
|
+
|
|
17
|
+
// src/commands/annotation/list.ts
|
|
18
|
+
init_cjs_shims();
|
|
19
|
+
var import_core = __toESM(require_lib(), 1);
|
|
20
|
+
var AnnotationList = class _AnnotationList extends BaseCommand {
|
|
21
|
+
static args = {
|
|
22
|
+
mrnPrefix: import_core.Args.string({
|
|
23
|
+
description: "MRN prefix to filter annotations (e.g., my-module or annotation:app:v1:my-module). If not provided, uses app/version from manifest and config.",
|
|
24
|
+
required: false
|
|
25
|
+
})
|
|
26
|
+
};
|
|
27
|
+
static description = "List annotations by MRN prefix";
|
|
28
|
+
static examples = [
|
|
29
|
+
`<%= config.bin %> annotation list
|
|
30
|
+
List all annotations for the current app/version from manifest and config
|
|
31
|
+
`,
|
|
32
|
+
`<%= config.bin %> annotation list my-module
|
|
33
|
+
List annotations for 'my-module' (prefilled with app/version from manifest and config)
|
|
34
|
+
`,
|
|
35
|
+
`<%= config.bin %> annotation list annotation:my-app:v1.0.0:my-module --format json
|
|
36
|
+
List annotations for a specific module using full MRN prefix in JSON format
|
|
37
|
+
`
|
|
38
|
+
];
|
|
39
|
+
static flags = {
|
|
40
|
+
...BaseCommand.HIDDEN_FLAGS,
|
|
41
|
+
output: import_core.Flags.string({
|
|
42
|
+
char: "o",
|
|
43
|
+
description: "output format",
|
|
44
|
+
default: "table",
|
|
45
|
+
options: ["table", "text", "json"]
|
|
46
|
+
}),
|
|
47
|
+
limit: import_core.Flags.integer({
|
|
48
|
+
char: "l",
|
|
49
|
+
description: "maximum number of annotations to return",
|
|
50
|
+
default: 100
|
|
51
|
+
}),
|
|
52
|
+
impersonate: import_core.Flags.string({
|
|
53
|
+
char: "i",
|
|
54
|
+
description: "impersonate organization",
|
|
55
|
+
required: false,
|
|
56
|
+
hidden: true
|
|
57
|
+
}),
|
|
58
|
+
manifest: import_core.Flags.string({
|
|
59
|
+
char: "M",
|
|
60
|
+
description: "project manifest",
|
|
61
|
+
required: false,
|
|
62
|
+
default: "raindrop.manifest",
|
|
63
|
+
hidden: true
|
|
64
|
+
})
|
|
65
|
+
};
|
|
66
|
+
async run() {
|
|
67
|
+
const { args, flags } = await this.parse(_AnnotationList);
|
|
68
|
+
let mrnParts = {};
|
|
69
|
+
let fullMrnPrefix = args.mrnPrefix || "";
|
|
70
|
+
if (args.mrnPrefix) {
|
|
71
|
+
if (!args.mrnPrefix.startsWith("annotation:") && !args.mrnPrefix.startsWith("label:")) {
|
|
72
|
+
const apps = await this.loadManifest();
|
|
73
|
+
const config = await this.loadConfig();
|
|
74
|
+
if (apps.length === 0) {
|
|
75
|
+
this.error("No applications found in manifest");
|
|
76
|
+
}
|
|
77
|
+
const app = apps[0];
|
|
78
|
+
const manifestAppName = valueOf(app.name);
|
|
79
|
+
const configVersionId = config.versionId;
|
|
80
|
+
if (!manifestAppName) {
|
|
81
|
+
this.error("Application name not found in manifest");
|
|
82
|
+
}
|
|
83
|
+
if (!configVersionId) {
|
|
84
|
+
this.error("Version ID not found in config. Run a build or deployment first to set the version.");
|
|
85
|
+
}
|
|
86
|
+
fullMrnPrefix = `annotation:${manifestAppName}:${configVersionId}:${args.mrnPrefix}`;
|
|
87
|
+
}
|
|
88
|
+
try {
|
|
89
|
+
mrnParts = parseMRN(fullMrnPrefix);
|
|
90
|
+
} catch {
|
|
91
|
+
const parts = fullMrnPrefix.split(":");
|
|
92
|
+
if (parts.length >= 3 && parts[0] === "annotation") {
|
|
93
|
+
mrnParts = {
|
|
94
|
+
type: parts[0],
|
|
95
|
+
applicationName: parts[1],
|
|
96
|
+
versionId: parts[2],
|
|
97
|
+
module: parts[3] || void 0,
|
|
98
|
+
key: parts[4] || void 0,
|
|
99
|
+
revision: parts[5] || void 0
|
|
100
|
+
};
|
|
101
|
+
} else {
|
|
102
|
+
this.error("MRN prefix must at least contain annotation:applicationName:versionId");
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
} else {
|
|
106
|
+
const apps = await this.loadManifest();
|
|
107
|
+
const config = await this.loadConfig();
|
|
108
|
+
if (apps.length === 0) {
|
|
109
|
+
this.error("No applications found in manifest");
|
|
110
|
+
}
|
|
111
|
+
const app = apps[0];
|
|
112
|
+
const manifestAppName = valueOf(app.name);
|
|
113
|
+
const configVersionId = config.versionId;
|
|
114
|
+
if (!manifestAppName) {
|
|
115
|
+
this.error("Application name not found in manifest");
|
|
116
|
+
}
|
|
117
|
+
if (!configVersionId) {
|
|
118
|
+
this.error("Version ID not found in config. Run a build or deployment first to set the version.");
|
|
119
|
+
}
|
|
120
|
+
fullMrnPrefix = `annotation:${manifestAppName}:${configVersionId}`;
|
|
121
|
+
mrnParts = {
|
|
122
|
+
type: "annotation",
|
|
123
|
+
applicationName: manifestAppName,
|
|
124
|
+
versionId: configVersionId
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
const {
|
|
128
|
+
client: annotationServiceClient,
|
|
129
|
+
userId,
|
|
130
|
+
organizationId
|
|
131
|
+
} = await this.annotationService();
|
|
132
|
+
try {
|
|
133
|
+
const locator = create(AnnotationLocatorSchema, {
|
|
134
|
+
applicationName: mrnParts.applicationName,
|
|
135
|
+
applicationVersionId: mrnParts.versionId,
|
|
136
|
+
moduleName: mrnParts.module,
|
|
137
|
+
item: mrnParts.item,
|
|
138
|
+
key: mrnParts.key,
|
|
139
|
+
revision: mrnParts.revision
|
|
140
|
+
});
|
|
141
|
+
const request = create(ListAnnotationsRequestSchema, {
|
|
142
|
+
userId,
|
|
143
|
+
organizationId,
|
|
144
|
+
locator
|
|
145
|
+
});
|
|
146
|
+
const response = await annotationServiceClient.listAnnotations(request);
|
|
147
|
+
const annotations = response.annotation || [];
|
|
148
|
+
switch (flags.output) {
|
|
149
|
+
case "json":
|
|
150
|
+
console.log(
|
|
151
|
+
JSON.stringify(
|
|
152
|
+
{
|
|
153
|
+
annotations: annotations.map((loc) => ({
|
|
154
|
+
applicationName: loc.applicationName,
|
|
155
|
+
applicationVersionId: loc.applicationVersionId,
|
|
156
|
+
moduleName: loc.moduleName,
|
|
157
|
+
item: loc.item,
|
|
158
|
+
key: loc.key,
|
|
159
|
+
revision: loc.revision
|
|
160
|
+
})),
|
|
161
|
+
total: annotations.length,
|
|
162
|
+
prefix: fullMrnPrefix,
|
|
163
|
+
inputPrefix: args.mrnPrefix
|
|
164
|
+
},
|
|
165
|
+
null,
|
|
166
|
+
2
|
|
167
|
+
)
|
|
168
|
+
);
|
|
169
|
+
break;
|
|
170
|
+
case "text":
|
|
171
|
+
console.log(`Found ${annotations.length} annotations`);
|
|
172
|
+
console.log(`Prefix: ${fullMrnPrefix}`);
|
|
173
|
+
if (fullMrnPrefix !== (args.mrnPrefix || "")) {
|
|
174
|
+
console.log(`Input: ${args.mrnPrefix || "(none)"} (prefilled with app/version)`);
|
|
175
|
+
}
|
|
176
|
+
console.log("");
|
|
177
|
+
annotations.forEach((loc, index) => {
|
|
178
|
+
const mrn = `${loc.applicationName}:${loc.applicationVersionId}:${loc.moduleName || ""}:${loc.item || ""}^${loc.key || ""}:${loc.revision || ""}`;
|
|
179
|
+
console.log(`${index + 1}. ${mrn}`);
|
|
180
|
+
console.log(` Application: ${loc.applicationName}`);
|
|
181
|
+
console.log(` Version: ${loc.applicationVersionId}`);
|
|
182
|
+
if (loc.moduleName) console.log(` Module: ${loc.moduleName}`);
|
|
183
|
+
if (loc.item) console.log(` Item: ${loc.item}`);
|
|
184
|
+
if (loc.key) console.log(` Key: ${loc.key}`);
|
|
185
|
+
if (loc.revision) console.log(` Revision: ${loc.revision}`);
|
|
186
|
+
console.log("");
|
|
187
|
+
});
|
|
188
|
+
break;
|
|
189
|
+
case "table":
|
|
190
|
+
if (annotations.length === 0) {
|
|
191
|
+
console.log("No annotations found");
|
|
192
|
+
console.log(`Prefix: ${fullMrnPrefix}`);
|
|
193
|
+
if (fullMrnPrefix !== (args.mrnPrefix || "")) {
|
|
194
|
+
console.log(`Input: ${args.mrnPrefix || "(none)"} (prefilled with app/version)`);
|
|
195
|
+
}
|
|
196
|
+
} else {
|
|
197
|
+
console.log("Application Version Module Item Key Revision");
|
|
198
|
+
console.log(
|
|
199
|
+
"--------------- --------------- --------------- --------------- --------------- ---------------"
|
|
200
|
+
);
|
|
201
|
+
annotations.forEach((loc) => {
|
|
202
|
+
const app = (loc.applicationName || "").padEnd(15).substring(0, 15);
|
|
203
|
+
const version = (loc.applicationVersionId || "").padEnd(15).substring(0, 15);
|
|
204
|
+
const module = (loc.moduleName || "").padEnd(15).substring(0, 15);
|
|
205
|
+
const item = (loc.item || "").padEnd(15).substring(0, 15);
|
|
206
|
+
const key = (loc.key || "").padEnd(15).substring(0, 15);
|
|
207
|
+
const revision = (loc.revision || "").padEnd(15).substring(0, 15);
|
|
208
|
+
console.log(`${app} ${version} ${module} ${item} ${key} ${revision}`);
|
|
209
|
+
});
|
|
210
|
+
console.log(`
|
|
211
|
+
Total: ${annotations.length} annotations`);
|
|
212
|
+
console.log(`Prefix: ${fullMrnPrefix}`);
|
|
213
|
+
if (fullMrnPrefix !== (args.mrnPrefix || "")) {
|
|
214
|
+
console.log(`Input: ${args.mrnPrefix || "(none)"} (prefilled with app/version)`);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
break;
|
|
218
|
+
}
|
|
219
|
+
} catch (error) {
|
|
220
|
+
this.error(`Failed to list annotations: ${error}`);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
export {
|
|
225
|
+
AnnotationList as default
|
|
226
|
+
};
|