@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,209 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BaseCommand
|
|
3
|
+
} from "../../chunk-MCRKUPJY.js";
|
|
4
|
+
import {
|
|
5
|
+
__toESM,
|
|
6
|
+
init_cjs_shims,
|
|
7
|
+
require_lib
|
|
8
|
+
} from "../../chunk-G6NE675D.js";
|
|
9
|
+
|
|
10
|
+
// src/commands/object/get.ts
|
|
11
|
+
init_cjs_shims();
|
|
12
|
+
var import_core = __toESM(require_lib(), 1);
|
|
13
|
+
import * as fs from "node:fs/promises";
|
|
14
|
+
import * as path from "path";
|
|
15
|
+
var ObjectGet = class extends BaseCommand {
|
|
16
|
+
static args = {
|
|
17
|
+
key: import_core.Args.string({
|
|
18
|
+
description: "key/path in the bucket",
|
|
19
|
+
required: true
|
|
20
|
+
}),
|
|
21
|
+
output: import_core.Args.file({
|
|
22
|
+
description: "output file (defaults to key basename)",
|
|
23
|
+
required: false
|
|
24
|
+
})
|
|
25
|
+
};
|
|
26
|
+
static description = "Download a file from the object storage";
|
|
27
|
+
static examples = [
|
|
28
|
+
`<%= config.bin %> object get my-key --bucket my-bucket
|
|
29
|
+
Download file with key 'my-key' from my-bucket
|
|
30
|
+
`,
|
|
31
|
+
`<%= config.bin %> object get my-key output.txt --application my-app --bucket my-bucket
|
|
32
|
+
Download file with key 'my-key' from my-bucket within my-app to output.txt
|
|
33
|
+
`
|
|
34
|
+
];
|
|
35
|
+
static flags = {
|
|
36
|
+
...BaseCommand.HIDDEN_FLAGS,
|
|
37
|
+
bucket: import_core.Flags.string({
|
|
38
|
+
char: "b",
|
|
39
|
+
description: "bucket name version can be specified with #, e.g. my-bucket#versionId",
|
|
40
|
+
required: false
|
|
41
|
+
}),
|
|
42
|
+
moduleId: import_core.Flags.string({
|
|
43
|
+
char: "m",
|
|
44
|
+
description: "moduleId",
|
|
45
|
+
required: false
|
|
46
|
+
}),
|
|
47
|
+
application: import_core.Flags.string({
|
|
48
|
+
char: "a",
|
|
49
|
+
description: "application name",
|
|
50
|
+
required: false
|
|
51
|
+
}),
|
|
52
|
+
format: import_core.Flags.string({
|
|
53
|
+
char: "f",
|
|
54
|
+
description: "output format",
|
|
55
|
+
default: "file",
|
|
56
|
+
options: ["file", "stdout", "json"]
|
|
57
|
+
}),
|
|
58
|
+
impersonate: import_core.Flags.string({
|
|
59
|
+
char: "i",
|
|
60
|
+
description: "impersonate organization",
|
|
61
|
+
required: false,
|
|
62
|
+
hidden: true
|
|
63
|
+
}),
|
|
64
|
+
manifest: import_core.Flags.string({
|
|
65
|
+
char: "M",
|
|
66
|
+
description: "project manifest",
|
|
67
|
+
required: false,
|
|
68
|
+
default: "raindrop.manifest",
|
|
69
|
+
hidden: true
|
|
70
|
+
})
|
|
71
|
+
};
|
|
72
|
+
async run() {
|
|
73
|
+
if (this.flags.bucket && this.flags.moduleId) {
|
|
74
|
+
this.error("Cannot specify both --bucket and --moduleId flags.");
|
|
75
|
+
}
|
|
76
|
+
if (this.flags.moduleId && this.flags.application) {
|
|
77
|
+
this.error("Cannot specify both --moduleId and --application flags.");
|
|
78
|
+
}
|
|
79
|
+
if (!this.flags.bucket && !this.flags.moduleId && !this.flags.application) {
|
|
80
|
+
this.error("Must specify one of: --bucket, --moduleId, or --application");
|
|
81
|
+
}
|
|
82
|
+
const { client: objectService, userId, organizationId } = await this.objectService();
|
|
83
|
+
let bucketLocation;
|
|
84
|
+
if (this.flags.moduleId) {
|
|
85
|
+
bucketLocation = {
|
|
86
|
+
bucketLocation: {
|
|
87
|
+
case: "moduleId",
|
|
88
|
+
value: this.flags.moduleId
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
} else if (this.flags.application && this.flags.bucket) {
|
|
92
|
+
const applicationName = this.flags.application;
|
|
93
|
+
const config = await this.loadConfig();
|
|
94
|
+
const applicationVersionId = config.versionId || void 0;
|
|
95
|
+
const { client: catalogService } = await this.catalogService();
|
|
96
|
+
const queryParams = {
|
|
97
|
+
userId,
|
|
98
|
+
applicationName,
|
|
99
|
+
organizationId,
|
|
100
|
+
moduleType: "smartbucket",
|
|
101
|
+
...applicationVersionId && { applicationVersionId }
|
|
102
|
+
};
|
|
103
|
+
const modulesResp = await catalogService.queryModules(queryParams);
|
|
104
|
+
if (!modulesResp.modules || modulesResp.modules.length === 0) {
|
|
105
|
+
this.error(`No bucket modules found for application '${applicationName}'`);
|
|
106
|
+
}
|
|
107
|
+
const bucketName = this.flags.bucket.split("#")[0];
|
|
108
|
+
const bucketModules = modulesResp.modules.filter((module) => module.name === bucketName);
|
|
109
|
+
if (bucketModules.length === 0) {
|
|
110
|
+
this.error(`Bucket '${bucketName}' not found in application '${applicationName}'`);
|
|
111
|
+
}
|
|
112
|
+
const bucketModule = applicationVersionId ? bucketModules.find((m) => m.applicationVersionId === applicationVersionId) || bucketModules.sort((a, b) => b.applicationVersionId.localeCompare(a.applicationVersionId))[0] : bucketModules.sort((a, b) => b.applicationVersionId.localeCompare(a.applicationVersionId))[0];
|
|
113
|
+
if (!bucketModule) {
|
|
114
|
+
this.error(`Bucket '${bucketName}' not found in application '${applicationName}'`);
|
|
115
|
+
}
|
|
116
|
+
bucketLocation = {
|
|
117
|
+
bucketLocation: {
|
|
118
|
+
case: "bucket",
|
|
119
|
+
value: {
|
|
120
|
+
name: bucketName,
|
|
121
|
+
version: bucketModule.applicationVersionId
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
} else if (this.flags.bucket) {
|
|
126
|
+
if (!this.flags.bucket.includes("#")) {
|
|
127
|
+
await this.loadConfig();
|
|
128
|
+
}
|
|
129
|
+
bucketLocation = {
|
|
130
|
+
bucketLocation: {
|
|
131
|
+
case: "bucket",
|
|
132
|
+
value: {
|
|
133
|
+
name: this.flags.bucket.split("#")[0],
|
|
134
|
+
version: this.flags.bucket.includes("#") ? this.flags.bucket.split("#")[1] : this.raindropConfig?.versionId
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
} else if (this.flags.application) {
|
|
139
|
+
const applicationName = this.flags.application;
|
|
140
|
+
const config = await this.loadConfig();
|
|
141
|
+
const applicationVersionId = config.versionId || void 0;
|
|
142
|
+
const { client: catalogService } = await this.catalogService();
|
|
143
|
+
const queryParams = {
|
|
144
|
+
userId,
|
|
145
|
+
applicationName,
|
|
146
|
+
organizationId,
|
|
147
|
+
moduleType: "smartbucket",
|
|
148
|
+
...applicationVersionId && { applicationVersionId }
|
|
149
|
+
};
|
|
150
|
+
const modulesResp = await catalogService.queryModules(queryParams);
|
|
151
|
+
if (!modulesResp.modules || modulesResp.modules.length === 0) {
|
|
152
|
+
this.error(`No bucket modules found for application '${applicationName}'`);
|
|
153
|
+
}
|
|
154
|
+
const bucketModule = modulesResp.modules[0];
|
|
155
|
+
if (!bucketModule) {
|
|
156
|
+
this.error(`No bucket modules found for application '${applicationName}'`);
|
|
157
|
+
}
|
|
158
|
+
bucketLocation = {
|
|
159
|
+
bucketLocation: {
|
|
160
|
+
case: "bucket",
|
|
161
|
+
value: {
|
|
162
|
+
name: bucketModule.name,
|
|
163
|
+
version: bucketModule.applicationVersionId
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
const response = await objectService.getObject({
|
|
169
|
+
userId,
|
|
170
|
+
organizationId,
|
|
171
|
+
key: this.args.key,
|
|
172
|
+
bucketLocation
|
|
173
|
+
});
|
|
174
|
+
if (!response.content) {
|
|
175
|
+
this.error("No content received from object storage");
|
|
176
|
+
}
|
|
177
|
+
switch (this.flags.format) {
|
|
178
|
+
case "json":
|
|
179
|
+
console.log(
|
|
180
|
+
JSON.stringify(
|
|
181
|
+
{
|
|
182
|
+
content: response.content.toString(),
|
|
183
|
+
contentType: response.contentType
|
|
184
|
+
},
|
|
185
|
+
null,
|
|
186
|
+
2
|
|
187
|
+
)
|
|
188
|
+
);
|
|
189
|
+
break;
|
|
190
|
+
case "stdout":
|
|
191
|
+
process.stdout.write(response.content);
|
|
192
|
+
break;
|
|
193
|
+
case "file":
|
|
194
|
+
case "text": {
|
|
195
|
+
const outputPath = this.args.output || path.basename(this.args.key);
|
|
196
|
+
await fs.writeFile(outputPath, response.content);
|
|
197
|
+
console.log("Successfully downloaded file:");
|
|
198
|
+
console.log(`Saved to: ${outputPath}`);
|
|
199
|
+
if (response.contentType) {
|
|
200
|
+
console.log(`Content-Type: ${response.contentType}`);
|
|
201
|
+
}
|
|
202
|
+
break;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
export {
|
|
208
|
+
ObjectGet as default
|
|
209
|
+
};
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BaseCommand
|
|
3
|
+
} from "../../chunk-MCRKUPJY.js";
|
|
4
|
+
import {
|
|
5
|
+
ListObjectsResponseSchema,
|
|
6
|
+
__toESM,
|
|
7
|
+
init_cjs_shims,
|
|
8
|
+
require_lib,
|
|
9
|
+
timestampDate,
|
|
10
|
+
toJsonString
|
|
11
|
+
} from "../../chunk-G6NE675D.js";
|
|
12
|
+
|
|
13
|
+
// src/commands/object/list.ts
|
|
14
|
+
init_cjs_shims();
|
|
15
|
+
var import_core = __toESM(require_lib(), 1);
|
|
16
|
+
var ObjectList = class extends BaseCommand {
|
|
17
|
+
static description = "List objects in a bucket";
|
|
18
|
+
static examples = [
|
|
19
|
+
`<%= config.bin %> object list --bucket my-bucket
|
|
20
|
+
List all objects in my-bucket
|
|
21
|
+
`,
|
|
22
|
+
`<%= config.bin %> object list --application my-app
|
|
23
|
+
List objects in the first bucket of my-app
|
|
24
|
+
`,
|
|
25
|
+
`<%= config.bin %> object list --application my-app --bucket my-bucket
|
|
26
|
+
List objects in my-bucket within my-app
|
|
27
|
+
`
|
|
28
|
+
];
|
|
29
|
+
static flags = {
|
|
30
|
+
...BaseCommand.HIDDEN_FLAGS,
|
|
31
|
+
bucket: import_core.Flags.string({
|
|
32
|
+
char: "b",
|
|
33
|
+
description: "bucket name version can be specified with #, e.g. my-bucket#versionId",
|
|
34
|
+
required: false
|
|
35
|
+
}),
|
|
36
|
+
moduleId: import_core.Flags.string({
|
|
37
|
+
char: "m",
|
|
38
|
+
description: "moduleId",
|
|
39
|
+
required: false
|
|
40
|
+
}),
|
|
41
|
+
application: import_core.Flags.string({
|
|
42
|
+
char: "a",
|
|
43
|
+
description: "application name",
|
|
44
|
+
required: false
|
|
45
|
+
}),
|
|
46
|
+
output: import_core.Flags.string({
|
|
47
|
+
char: "o",
|
|
48
|
+
description: "output format",
|
|
49
|
+
default: "text",
|
|
50
|
+
options: ["text", "json", "table"]
|
|
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
|
+
if (this.flags.bucket && this.flags.moduleId) {
|
|
68
|
+
this.error("Cannot specify both --bucket and --moduleId flags.");
|
|
69
|
+
}
|
|
70
|
+
if (this.flags.moduleId && this.flags.application) {
|
|
71
|
+
this.error("Cannot specify both --moduleId and --application flags.");
|
|
72
|
+
}
|
|
73
|
+
if (!this.flags.bucket && !this.flags.moduleId && !this.flags.application) {
|
|
74
|
+
this.error("Must specify one of: --bucket, --moduleId, or --application");
|
|
75
|
+
}
|
|
76
|
+
const { client: objectService, userId, organizationId } = await this.objectService();
|
|
77
|
+
let bucketLocation;
|
|
78
|
+
if (this.flags.moduleId) {
|
|
79
|
+
bucketLocation = {
|
|
80
|
+
bucketLocation: {
|
|
81
|
+
case: "moduleId",
|
|
82
|
+
value: this.flags.moduleId
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
} else if (this.flags.application && this.flags.bucket) {
|
|
86
|
+
const applicationName = this.flags.application;
|
|
87
|
+
const config = await this.loadConfig();
|
|
88
|
+
const applicationVersionId = config.versionId || void 0;
|
|
89
|
+
const { client: catalogService } = await this.catalogService();
|
|
90
|
+
const queryParams = {
|
|
91
|
+
userId,
|
|
92
|
+
applicationName,
|
|
93
|
+
organizationId,
|
|
94
|
+
moduleType: "smartbucket",
|
|
95
|
+
...applicationVersionId && { applicationVersionId }
|
|
96
|
+
};
|
|
97
|
+
const modulesResp = await catalogService.queryModules(queryParams);
|
|
98
|
+
if (!modulesResp.modules || modulesResp.modules.length === 0) {
|
|
99
|
+
this.error(`No bucket modules found for application '${applicationName}'`);
|
|
100
|
+
}
|
|
101
|
+
const bucketName = this.flags.bucket.split("#")[0];
|
|
102
|
+
const bucketModules = modulesResp.modules.filter((module) => module.name === bucketName);
|
|
103
|
+
if (bucketModules.length === 0) {
|
|
104
|
+
this.error(`Bucket '${bucketName}' not found in application '${applicationName}'`);
|
|
105
|
+
}
|
|
106
|
+
const bucketModule = applicationVersionId ? bucketModules.find((m) => m.applicationVersionId === applicationVersionId) || bucketModules.sort((a, b) => b.applicationVersionId.localeCompare(a.applicationVersionId))[0] : bucketModules.sort((a, b) => b.applicationVersionId.localeCompare(a.applicationVersionId))[0];
|
|
107
|
+
if (!bucketModule) {
|
|
108
|
+
this.error(`Bucket '${bucketName}' not found in application '${applicationName}'`);
|
|
109
|
+
}
|
|
110
|
+
bucketLocation = {
|
|
111
|
+
bucketLocation: {
|
|
112
|
+
case: "bucket",
|
|
113
|
+
value: {
|
|
114
|
+
name: bucketName,
|
|
115
|
+
version: bucketModule.applicationVersionId
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
} else if (this.flags.bucket) {
|
|
120
|
+
if (!this.flags.bucket.includes("#")) {
|
|
121
|
+
await this.loadConfig();
|
|
122
|
+
}
|
|
123
|
+
bucketLocation = {
|
|
124
|
+
bucketLocation: {
|
|
125
|
+
case: "bucket",
|
|
126
|
+
value: {
|
|
127
|
+
name: this.flags.bucket.split("#")[0],
|
|
128
|
+
version: this.flags.bucket.includes("#") ? this.flags.bucket.split("#")[1] : this.raindropConfig?.versionId
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
} else if (this.flags.application) {
|
|
133
|
+
const applicationName = this.flags.application;
|
|
134
|
+
const config = await this.loadConfig();
|
|
135
|
+
const applicationVersionId = config.versionId || void 0;
|
|
136
|
+
const { client: catalogService } = await this.catalogService();
|
|
137
|
+
const queryParams = {
|
|
138
|
+
userId,
|
|
139
|
+
applicationName,
|
|
140
|
+
organizationId,
|
|
141
|
+
moduleType: "smartbucket",
|
|
142
|
+
...applicationVersionId && { applicationVersionId }
|
|
143
|
+
};
|
|
144
|
+
const modulesResp = await catalogService.queryModules(queryParams);
|
|
145
|
+
if (!modulesResp.modules || modulesResp.modules.length === 0) {
|
|
146
|
+
this.error(`No bucket modules found for application '${applicationName}'`);
|
|
147
|
+
}
|
|
148
|
+
const bucketModule = modulesResp.modules[0];
|
|
149
|
+
if (!bucketModule) {
|
|
150
|
+
this.error(`No bucket modules found for application '${applicationName}'`);
|
|
151
|
+
}
|
|
152
|
+
bucketLocation = {
|
|
153
|
+
bucketLocation: {
|
|
154
|
+
case: "bucket",
|
|
155
|
+
value: {
|
|
156
|
+
name: bucketModule.name,
|
|
157
|
+
version: bucketModule.applicationVersionId
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
let response;
|
|
163
|
+
try {
|
|
164
|
+
response = await objectService.listObjects({
|
|
165
|
+
userId,
|
|
166
|
+
organizationId,
|
|
167
|
+
bucketLocation
|
|
168
|
+
});
|
|
169
|
+
} catch (error) {
|
|
170
|
+
const err = error;
|
|
171
|
+
const location = this.flags.bucket || this.flags.moduleId;
|
|
172
|
+
this.error(`Failed to list objects in ${this.flags.bucket ? "bucket" : "module"} ${location}: ${err.message}`);
|
|
173
|
+
}
|
|
174
|
+
if (!response.objects?.length) {
|
|
175
|
+
console.log("No objects found in bucket");
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
switch (this.flags.output) {
|
|
179
|
+
case "json":
|
|
180
|
+
console.log(toJsonString(ListObjectsResponseSchema, response, { prettySpaces: 2 }));
|
|
181
|
+
break;
|
|
182
|
+
case "table":
|
|
183
|
+
console.table(
|
|
184
|
+
response.objects.map((obj) => ({
|
|
185
|
+
key: obj.key,
|
|
186
|
+
size: obj.size,
|
|
187
|
+
contentType: obj.contentType,
|
|
188
|
+
lastModified: obj.lastModified ? timestampDate(obj.lastModified).toUTCString() : "N/A"
|
|
189
|
+
}))
|
|
190
|
+
);
|
|
191
|
+
break;
|
|
192
|
+
default:
|
|
193
|
+
for (const obj of response.objects) {
|
|
194
|
+
const lastModified = obj.lastModified ? timestampDate(obj.lastModified).toUTCString() : "N/A";
|
|
195
|
+
console.log(`Key: ${obj.key}`);
|
|
196
|
+
console.log(` Size: ${obj.size} bytes`);
|
|
197
|
+
console.log(` Content-Type: ${obj.contentType || "N/A"}`);
|
|
198
|
+
console.log(` Last Modified: ${lastModified}`);
|
|
199
|
+
console.log("---");
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
export {
|
|
205
|
+
ObjectList as default
|
|
206
|
+
};
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BaseCommand
|
|
3
|
+
} from "../../chunk-MCRKUPJY.js";
|
|
4
|
+
import {
|
|
5
|
+
PutObjectResponseSchema,
|
|
6
|
+
__toESM,
|
|
7
|
+
init_cjs_shims,
|
|
8
|
+
require_lib,
|
|
9
|
+
toJsonString
|
|
10
|
+
} from "../../chunk-G6NE675D.js";
|
|
11
|
+
|
|
12
|
+
// src/commands/object/put.ts
|
|
13
|
+
init_cjs_shims();
|
|
14
|
+
var import_core = __toESM(require_lib(), 1);
|
|
15
|
+
import * as fs from "node:fs/promises";
|
|
16
|
+
import * as path from "path";
|
|
17
|
+
var ObjectPut = class extends BaseCommand {
|
|
18
|
+
static args = {
|
|
19
|
+
file: import_core.Args.file({
|
|
20
|
+
description: "file to upload",
|
|
21
|
+
required: true,
|
|
22
|
+
exists: true
|
|
23
|
+
}),
|
|
24
|
+
key: import_core.Args.string({
|
|
25
|
+
description: "key/path in the bucket",
|
|
26
|
+
required: true
|
|
27
|
+
})
|
|
28
|
+
};
|
|
29
|
+
static description = "Upload a file to the object storage";
|
|
30
|
+
static examples = [
|
|
31
|
+
`<%= config.bin %> object put ./myfile.txt my-key --bucket my-bucket
|
|
32
|
+
Upload myfile.txt to my-bucket with key 'my-key'
|
|
33
|
+
`,
|
|
34
|
+
`<%= config.bin %> object put ./myfile.txt my-key --application my-app --bucket my-bucket
|
|
35
|
+
Upload myfile.txt to my-bucket within my-app with key 'my-key'
|
|
36
|
+
`
|
|
37
|
+
];
|
|
38
|
+
static flags = {
|
|
39
|
+
...BaseCommand.HIDDEN_FLAGS,
|
|
40
|
+
bucket: import_core.Flags.string({
|
|
41
|
+
char: "b",
|
|
42
|
+
description: "bucket name version can be specified with #, e.g. my-bucket#versionId",
|
|
43
|
+
required: false
|
|
44
|
+
}),
|
|
45
|
+
moduleId: import_core.Flags.string({
|
|
46
|
+
char: "m",
|
|
47
|
+
description: "moduleId",
|
|
48
|
+
required: false
|
|
49
|
+
}),
|
|
50
|
+
application: import_core.Flags.string({
|
|
51
|
+
char: "a",
|
|
52
|
+
description: "application name",
|
|
53
|
+
required: false
|
|
54
|
+
}),
|
|
55
|
+
contentType: import_core.Flags.string({
|
|
56
|
+
char: "t",
|
|
57
|
+
description: "content type of the file",
|
|
58
|
+
required: false
|
|
59
|
+
}),
|
|
60
|
+
output: import_core.Flags.string({
|
|
61
|
+
char: "o",
|
|
62
|
+
description: "output format",
|
|
63
|
+
default: "text",
|
|
64
|
+
options: ["text", "json"]
|
|
65
|
+
}),
|
|
66
|
+
impersonate: import_core.Flags.string({
|
|
67
|
+
char: "i",
|
|
68
|
+
description: "impersonate organization",
|
|
69
|
+
required: false,
|
|
70
|
+
hidden: true
|
|
71
|
+
}),
|
|
72
|
+
manifest: import_core.Flags.string({
|
|
73
|
+
char: "M",
|
|
74
|
+
description: "project manifest",
|
|
75
|
+
required: false,
|
|
76
|
+
default: "raindrop.manifest",
|
|
77
|
+
hidden: true
|
|
78
|
+
})
|
|
79
|
+
};
|
|
80
|
+
async run() {
|
|
81
|
+
if (this.flags.bucket && this.flags.moduleId) {
|
|
82
|
+
this.error("Cannot specify both --bucket and --moduleId flags.");
|
|
83
|
+
}
|
|
84
|
+
if (this.flags.moduleId && this.flags.application) {
|
|
85
|
+
this.error("Cannot specify both --moduleId and --application flags.");
|
|
86
|
+
}
|
|
87
|
+
if (!this.flags.bucket && !this.flags.moduleId && !this.flags.application) {
|
|
88
|
+
this.error("Must specify one of: --bucket, --moduleId, or --application");
|
|
89
|
+
}
|
|
90
|
+
const { client: objectService, userId, organizationId } = await this.objectService();
|
|
91
|
+
let bucketLocation;
|
|
92
|
+
if (this.flags.moduleId) {
|
|
93
|
+
bucketLocation = {
|
|
94
|
+
bucketLocation: {
|
|
95
|
+
case: "moduleId",
|
|
96
|
+
value: this.flags.moduleId
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
} else if (this.flags.application && this.flags.bucket) {
|
|
100
|
+
const applicationName = this.flags.application;
|
|
101
|
+
const config = await this.loadConfig();
|
|
102
|
+
const applicationVersionId = config.versionId || void 0;
|
|
103
|
+
const { client: catalogService } = await this.catalogService();
|
|
104
|
+
const queryParams = {
|
|
105
|
+
userId,
|
|
106
|
+
applicationName,
|
|
107
|
+
organizationId,
|
|
108
|
+
moduleType: "smartbucket",
|
|
109
|
+
...applicationVersionId && { applicationVersionId }
|
|
110
|
+
};
|
|
111
|
+
const modulesResp = await catalogService.queryModules(queryParams);
|
|
112
|
+
if (!modulesResp.modules || modulesResp.modules.length === 0) {
|
|
113
|
+
this.error(`No bucket modules found for application '${applicationName}'`);
|
|
114
|
+
}
|
|
115
|
+
const bucketName = this.flags.bucket.split("#")[0];
|
|
116
|
+
const bucketModules = modulesResp.modules.filter((module) => module.name === bucketName);
|
|
117
|
+
if (bucketModules.length === 0) {
|
|
118
|
+
this.error(`Bucket '${bucketName}' not found in application '${applicationName}'`);
|
|
119
|
+
}
|
|
120
|
+
const bucketModule = applicationVersionId ? bucketModules.find((m) => m.applicationVersionId === applicationVersionId) || bucketModules.sort((a, b) => b.applicationVersionId.localeCompare(a.applicationVersionId))[0] : bucketModules.sort((a, b) => b.applicationVersionId.localeCompare(a.applicationVersionId))[0];
|
|
121
|
+
if (!bucketModule) {
|
|
122
|
+
this.error(`Bucket '${bucketName}' not found in application '${applicationName}'`);
|
|
123
|
+
}
|
|
124
|
+
bucketLocation = {
|
|
125
|
+
bucketLocation: {
|
|
126
|
+
case: "bucket",
|
|
127
|
+
value: {
|
|
128
|
+
name: bucketName,
|
|
129
|
+
version: bucketModule.applicationVersionId
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
} else if (this.flags.bucket) {
|
|
134
|
+
if (!this.flags.bucket.includes("#")) {
|
|
135
|
+
await this.loadConfig();
|
|
136
|
+
}
|
|
137
|
+
bucketLocation = {
|
|
138
|
+
bucketLocation: {
|
|
139
|
+
case: "bucket",
|
|
140
|
+
value: {
|
|
141
|
+
name: this.flags.bucket.split("#")[0],
|
|
142
|
+
version: this.flags.bucket.includes("#") ? this.flags.bucket.split("#")[1] : this.raindropConfig?.versionId
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
} else if (this.flags.application) {
|
|
147
|
+
const applicationName = this.flags.application;
|
|
148
|
+
const config = await this.loadConfig();
|
|
149
|
+
const applicationVersionId = config.versionId || void 0;
|
|
150
|
+
const { client: catalogService } = await this.catalogService();
|
|
151
|
+
const queryParams = {
|
|
152
|
+
userId,
|
|
153
|
+
applicationName,
|
|
154
|
+
organizationId,
|
|
155
|
+
moduleType: "smartbucket",
|
|
156
|
+
...applicationVersionId && { applicationVersionId }
|
|
157
|
+
};
|
|
158
|
+
const modulesResp = await catalogService.queryModules(queryParams);
|
|
159
|
+
if (!modulesResp.modules || modulesResp.modules.length === 0) {
|
|
160
|
+
this.error(`No bucket modules found for application '${applicationName}'`);
|
|
161
|
+
}
|
|
162
|
+
const bucketModule = modulesResp.modules[0];
|
|
163
|
+
if (!bucketModule) {
|
|
164
|
+
this.error(`No bucket modules found for application '${applicationName}'`);
|
|
165
|
+
}
|
|
166
|
+
bucketLocation = {
|
|
167
|
+
bucketLocation: {
|
|
168
|
+
case: "bucket",
|
|
169
|
+
value: {
|
|
170
|
+
name: bucketModule.name,
|
|
171
|
+
version: bucketModule.applicationVersionId
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
const fileContent = await fs.readFile(this.args.file);
|
|
177
|
+
const contentType = this.flags.contentType || this.getContentType(this.args.file);
|
|
178
|
+
const response = await objectService.putObject({
|
|
179
|
+
userId,
|
|
180
|
+
organizationId,
|
|
181
|
+
bucketLocation,
|
|
182
|
+
key: this.args.key,
|
|
183
|
+
content: fileContent,
|
|
184
|
+
contentType
|
|
185
|
+
});
|
|
186
|
+
if (this.flags.output === "json") {
|
|
187
|
+
console.log(toJsonString(PutObjectResponseSchema, response, { prettySpaces: 2 }));
|
|
188
|
+
} else {
|
|
189
|
+
console.log("Successfully uploaded file:");
|
|
190
|
+
console.log(`Bucket: ${response.bucket?.bucketName}`);
|
|
191
|
+
console.log(`Key: ${response.key}`);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
getContentType(filePath) {
|
|
195
|
+
const extension = path.extname(filePath).toLowerCase();
|
|
196
|
+
const contentTypes = {
|
|
197
|
+
".txt": "text/plain",
|
|
198
|
+
".json": "application/json",
|
|
199
|
+
".png": "image/png",
|
|
200
|
+
".jpg": "image/jpeg",
|
|
201
|
+
".jpeg": "image/jpeg",
|
|
202
|
+
".pdf": "application/pdf",
|
|
203
|
+
".mp3": "audio/mpeg",
|
|
204
|
+
".wav": "audio/wav"
|
|
205
|
+
};
|
|
206
|
+
return contentTypes[extension] || "application/octet-stream";
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
export {
|
|
210
|
+
ObjectPut as default
|
|
211
|
+
};
|