@liquidmetal-ai/raindrop 0.2.11 → 0.2.12
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 +70 -84
- package/dist/base-command.d.ts.map +1 -1
- package/dist/base-command.js +4 -2
- package/dist/build.d.ts.map +1 -1
- package/dist/build.js +12 -0
- package/dist/commands/build/find.d.ts +8 -0
- package/dist/commands/build/find.d.ts.map +1 -1
- package/dist/commands/build/find.js +51 -4
- package/dist/commands/build/sandbox.d.ts +2 -3
- package/dist/commands/build/sandbox.d.ts.map +1 -1
- package/dist/commands/build/sandbox.js +8 -5
- package/dist/commands/build/start.js +1 -1
- package/dist/commands/build/unsandbox.d.ts +2 -3
- package/dist/commands/build/unsandbox.d.ts.map +1 -1
- package/dist/commands/build/unsandbox.js +8 -5
- package/dist/commands/object/delete.js +1 -1
- package/dist/commands/object/get.js +1 -1
- package/dist/commands/object/list.d.ts.map +1 -1
- package/dist/commands/object/list.js +12 -5
- package/dist/commands/object/put.d.ts.map +1 -1
- package/dist/commands/object/put.js +2 -3
- package/dist/deploy.d.ts.map +1 -1
- package/dist/deploy.js +36 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -11
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/oclif.manifest.json +42 -183
- package/package.json +2 -2
- package/templates/init/package.json.hbs +1 -1
- package/dist/commands/query/register-retriever.d.ts +0 -21
- package/dist/commands/query/register-retriever.d.ts.map +0 -1
- package/dist/commands/query/register-retriever.js +0 -47
|
@@ -4,7 +4,7 @@ import { Flags } from '@oclif/core';
|
|
|
4
4
|
import { BaseCommand } from '../../base-command.js';
|
|
5
5
|
import { EPOCH_TS } from '../../index.js';
|
|
6
6
|
import { toJsonString } from '@bufbuild/protobuf';
|
|
7
|
-
import { QueryResourcesResponseSchema } from '@liquidmetal-ai/drizzle/liquidmetal/v1alpha1/catalog_pb';
|
|
7
|
+
import { QueryModulesResponseSchema, QueryResourcesResponseSchema, } from '@liquidmetal-ai/drizzle/liquidmetal/v1alpha1/catalog_pb';
|
|
8
8
|
export default class Find extends BaseCommand {
|
|
9
9
|
static args = {};
|
|
10
10
|
static description = 'find resources in Raindrop';
|
|
@@ -31,6 +31,10 @@ export default class Find extends BaseCommand {
|
|
|
31
31
|
description: 'application version',
|
|
32
32
|
required: false,
|
|
33
33
|
}),
|
|
34
|
+
moduleType: Flags.string({
|
|
35
|
+
description: 'filter by module type (e.g. smartbucket)',
|
|
36
|
+
required: false,
|
|
37
|
+
}),
|
|
34
38
|
output: Flags.string({
|
|
35
39
|
char: 'o',
|
|
36
40
|
description: 'output format',
|
|
@@ -51,6 +55,50 @@ export default class Find extends BaseCommand {
|
|
|
51
55
|
hidden: true,
|
|
52
56
|
}),
|
|
53
57
|
};
|
|
58
|
+
async queryModules(flags) {
|
|
59
|
+
if (!flags.version) {
|
|
60
|
+
const config = await this.loadConfig();
|
|
61
|
+
flags.version = config.versionId;
|
|
62
|
+
}
|
|
63
|
+
if (!flags.application) {
|
|
64
|
+
const apps = await this.loadManifest();
|
|
65
|
+
const app = apps[0];
|
|
66
|
+
if (app === undefined) {
|
|
67
|
+
this.error('No application provided or found in manifest', { exit: 1 });
|
|
68
|
+
}
|
|
69
|
+
flags.application = valueOf(app.name);
|
|
70
|
+
}
|
|
71
|
+
const { client: catalogService, userId, organizationId: defaultOrganizationId } = await this.catalogService();
|
|
72
|
+
const organizationId = this.flags.impersonate ?? defaultOrganizationId;
|
|
73
|
+
const resp = await catalogService.queryModules({
|
|
74
|
+
userId,
|
|
75
|
+
applicationName: flags.application,
|
|
76
|
+
applicationVersionId: flags.version,
|
|
77
|
+
organizationId,
|
|
78
|
+
moduleType: flags.moduleType,
|
|
79
|
+
});
|
|
80
|
+
if (flags.output === 'table') {
|
|
81
|
+
console.table(resp.modules.reduce((acc, v) => {
|
|
82
|
+
acc[v.name] = {
|
|
83
|
+
...v,
|
|
84
|
+
attributes: JSON.stringify(v.attributes),
|
|
85
|
+
createdAt: timestampDate(v.createdAt || EPOCH_TS).toISOString(),
|
|
86
|
+
updatedAt: timestampDate(v.updatedAt || EPOCH_TS).toISOString(),
|
|
87
|
+
};
|
|
88
|
+
return acc;
|
|
89
|
+
},
|
|
90
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
91
|
+
{}), ['moduleId', 'name', 'type', 'attributes', 'createdAt', 'updatedAt']);
|
|
92
|
+
}
|
|
93
|
+
else if (flags.output === 'json') {
|
|
94
|
+
console.log(toJsonString(QueryModulesResponseSchema, resp, { prettySpaces: 2 }));
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
for (const m of resp.modules) {
|
|
98
|
+
console.log(`${m.moduleId} ${m.name} ${m.type} ${timestampDate(m.createdAt || EPOCH_TS).toISOString()} ${timestampDate(m.updatedAt || EPOCH_TS).toISOString()} ${JSON.stringify(m.attributes)}`);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
54
102
|
async queryResources(flags) {
|
|
55
103
|
if (!flags.version) {
|
|
56
104
|
const config = await this.loadConfig();
|
|
@@ -76,12 +124,11 @@ export default class Find extends BaseCommand {
|
|
|
76
124
|
console.table(resp.resources.reduce((acc, v) => {
|
|
77
125
|
acc[v.name] = {
|
|
78
126
|
...v,
|
|
79
|
-
attributes: JSON.stringify(v.attributes, null, 2),
|
|
80
127
|
};
|
|
81
128
|
return acc;
|
|
82
129
|
},
|
|
83
130
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
84
|
-
{}), ['name', 'resourceId', 'applicationName', 'applicationVersionId', 'type'
|
|
131
|
+
{}), ['name', 'resourceId', 'applicationName', 'applicationVersionId', 'type']);
|
|
85
132
|
}
|
|
86
133
|
else if (flags.output === 'json') {
|
|
87
134
|
console.log(toJsonString(QueryResourcesResponseSchema, resp, { prettySpaces: 2 }));
|
|
@@ -97,7 +144,7 @@ export default class Find extends BaseCommand {
|
|
|
97
144
|
await this.queryResources(this.flags);
|
|
98
145
|
}
|
|
99
146
|
else {
|
|
100
|
-
this.
|
|
147
|
+
await this.queryModules(this.flags);
|
|
101
148
|
}
|
|
102
149
|
}
|
|
103
150
|
}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { BaseCommand } from '../../base-command.js';
|
|
2
2
|
export default class Sandbox extends BaseCommand<typeof Sandbox> {
|
|
3
|
-
static args: {
|
|
4
|
-
versionId: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
|
|
5
|
-
};
|
|
3
|
+
static args: {};
|
|
6
4
|
static description: string;
|
|
7
5
|
static examples: string[];
|
|
8
6
|
static flags: {
|
|
9
7
|
impersonate: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
8
|
manifest: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
version: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
10
|
config: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
11
|
rainbowAuthService: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
12
|
raindropCatalogService: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sandbox.d.ts","sourceRoot":"","sources":["../../../src/commands/build/sandbox.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,MAAM,CAAC,OAAO,OAAO,OAAQ,SAAQ,WAAW,CAAC,OAAO,OAAO,CAAC;IAC9D,MAAM,CAAC,IAAI
|
|
1
|
+
{"version":3,"file":"sandbox.d.ts","sourceRoot":"","sources":["../../../src/commands/build/sandbox.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,MAAM,CAAC,OAAO,OAAO,OAAQ,SAAQ,WAAW,CAAC,OAAO,OAAO,CAAC;IAC9D,MAAM,CAAC,IAAI,KAAM;IACjB,MAAM,CAAC,WAAW,SAAyD;IAE3E,MAAM,CAAC,QAAQ,WAGb;IAEF,MAAM,CAAC,KAAK;;;;;;;;;;MAcV;IAEI,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CA6B3B"}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { valueOf } from '@liquidmetal-ai/drizzle/appify/build';
|
|
2
|
-
import {
|
|
2
|
+
import { Flags } from '@oclif/core';
|
|
3
3
|
import { BaseCommand } from '../../base-command.js';
|
|
4
4
|
export default class Sandbox extends BaseCommand {
|
|
5
|
-
static args = {
|
|
6
|
-
versionId: Args.string({ char: 'v', description: 'version to sandbox', required: false }),
|
|
7
|
-
};
|
|
5
|
+
static args = {};
|
|
8
6
|
static description = 'mark a version as sandboxed in the Raindrop catalog';
|
|
9
7
|
static examples = [
|
|
10
8
|
`<%= config.bin %> <%= command.id %>
|
|
@@ -19,6 +17,11 @@ export default class Sandbox extends BaseCommand {
|
|
|
19
17
|
hidden: true,
|
|
20
18
|
}),
|
|
21
19
|
manifest: Flags.string({ default: 'raindrop.manifest', description: 'project manifest' }),
|
|
20
|
+
version: Flags.string({
|
|
21
|
+
char: 'v',
|
|
22
|
+
description: 'application version to sandbox',
|
|
23
|
+
required: false,
|
|
24
|
+
}),
|
|
22
25
|
};
|
|
23
26
|
async run() {
|
|
24
27
|
const config = await this.loadConfig();
|
|
@@ -29,7 +32,7 @@ export default class Sandbox extends BaseCommand {
|
|
|
29
32
|
const organizationId = this.flags.impersonate ?? defaultOrganizationId;
|
|
30
33
|
const apps = await this.loadManifest();
|
|
31
34
|
const app = apps[0];
|
|
32
|
-
const versionId = this.
|
|
35
|
+
const versionId = this.flags.version ?? config.versionId;
|
|
33
36
|
if (!app) {
|
|
34
37
|
this.error('No application found');
|
|
35
38
|
}
|
|
@@ -51,7 +51,7 @@ Start a Raindrop application.
|
|
|
51
51
|
}
|
|
52
52
|
applicationName = valueOf(app.name);
|
|
53
53
|
}
|
|
54
|
-
const currentVersionId = this.
|
|
54
|
+
const currentVersionId = this.flags.version ?? config.versionId;
|
|
55
55
|
await catalogService.setActive({
|
|
56
56
|
userId,
|
|
57
57
|
organizationId,
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { BaseCommand } from '../../base-command.js';
|
|
2
2
|
export default class Unsandbox extends BaseCommand<typeof Unsandbox> {
|
|
3
|
-
static args: {
|
|
4
|
-
versionId: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
|
|
5
|
-
};
|
|
3
|
+
static args: {};
|
|
6
4
|
static description: string;
|
|
7
5
|
static examples: string[];
|
|
8
6
|
static flags: {
|
|
9
7
|
impersonate: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
8
|
manifest: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
version: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
10
|
config: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
11
|
rainbowAuthService: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
12
|
raindropCatalogService: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unsandbox.d.ts","sourceRoot":"","sources":["../../../src/commands/build/unsandbox.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,MAAM,CAAC,OAAO,OAAO,SAAU,SAAQ,WAAW,CAAC,OAAO,SAAS,CAAC;IAClE,MAAM,CAAC,IAAI
|
|
1
|
+
{"version":3,"file":"unsandbox.d.ts","sourceRoot":"","sources":["../../../src/commands/build/unsandbox.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,MAAM,CAAC,OAAO,OAAO,SAAU,SAAQ,WAAW,CAAC,OAAO,SAAS,CAAC;IAClE,MAAM,CAAC,IAAI,KAAM;IAEjB,MAAM,CAAC,WAAW,SAA2D;IAE7E,MAAM,CAAC,QAAQ,WAGb;IAEF,MAAM,CAAC,KAAK;;;;;;;;;;MAcV;IAEI,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CA6B3B"}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { valueOf } from '@liquidmetal-ai/drizzle/appify/build';
|
|
2
|
-
import {
|
|
2
|
+
import { Flags } from '@oclif/core';
|
|
3
3
|
import { BaseCommand } from '../../base-command.js';
|
|
4
4
|
export default class Unsandbox extends BaseCommand {
|
|
5
|
-
static args = {
|
|
6
|
-
versionId: Args.string({ char: 'v', description: 'version to sandbox', required: false }),
|
|
7
|
-
};
|
|
5
|
+
static args = {};
|
|
8
6
|
static description = 'mark a version as unsandboxed in the Raindrop catalog';
|
|
9
7
|
static examples = [
|
|
10
8
|
`<%= config.bin %> <%= command.id %>
|
|
@@ -19,6 +17,11 @@ export default class Unsandbox extends BaseCommand {
|
|
|
19
17
|
hidden: true,
|
|
20
18
|
}),
|
|
21
19
|
manifest: Flags.string({ default: 'raindrop.manifest', description: 'project manifest' }),
|
|
20
|
+
version: Flags.string({
|
|
21
|
+
char: 'v',
|
|
22
|
+
description: 'application version to unsandbox',
|
|
23
|
+
required: false,
|
|
24
|
+
}),
|
|
22
25
|
};
|
|
23
26
|
async run() {
|
|
24
27
|
const config = await this.loadConfig();
|
|
@@ -29,7 +32,7 @@ export default class Unsandbox extends BaseCommand {
|
|
|
29
32
|
const organizationId = this.flags.impersonate ?? defaultOrganizationId;
|
|
30
33
|
const apps = await this.loadManifest();
|
|
31
34
|
const app = apps[0];
|
|
32
|
-
const versionId = this.
|
|
35
|
+
const versionId = this.flags.version ?? config.versionId;
|
|
33
36
|
if (!app) {
|
|
34
37
|
this.error('No application found');
|
|
35
38
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/commands/object/list.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAIpD,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,WAAW,CAAC,OAAO,UAAU,CAAC;IACpE,MAAM,CAAC,WAAW,SAA8B;IAEhD,MAAM,CAAC,QAAQ,WAIb;IAEF,MAAM,CAAC,KAAK;;;;;;;;;;;MA0BV;IAEI,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/commands/object/list.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAIpD,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,WAAW,CAAC,OAAO,UAAU,CAAC;IACpE,MAAM,CAAC,WAAW,SAA8B;IAEhD,MAAM,CAAC,QAAQ,WAIb;IAEF,MAAM,CAAC,KAAK;;;;;;;;;;;MA0BV;IAEI,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAiD3B"}
|
|
@@ -39,11 +39,18 @@ List all objects in my-bucket
|
|
|
39
39
|
async run() {
|
|
40
40
|
const { flags } = await this.parse(ObjectList);
|
|
41
41
|
const { client: objectService, userId, organizationId } = await this.objectService();
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
let response;
|
|
43
|
+
try {
|
|
44
|
+
response = await objectService.listObjects({
|
|
45
|
+
userId,
|
|
46
|
+
organizationId,
|
|
47
|
+
bucketId: flags.bucket,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
const err = error;
|
|
52
|
+
this.error(`Failed to list objects in bucket ${flags.bucket}: ${err.message}`);
|
|
53
|
+
}
|
|
47
54
|
if (!response.objects?.length) {
|
|
48
55
|
console.log('No objects found in bucket');
|
|
49
56
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"put.d.ts","sourceRoot":"","sources":["../../../src/commands/object/put.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAMpD,MAAM,CAAC,OAAO,OAAO,SAAU,SAAQ,WAAW,CAAC,OAAO,SAAS,CAAC;IAClE,MAAM,CAAC,IAAI;;;;;MAUT;IAEF,MAAM,CAAC,WAAW,SAAyC;IAE3D,MAAM,CAAC,QAAQ,WAIb;IAEF,MAAM,CAAC,KAAK;;;;;;;;;;;;MA+BV;IAEI,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"put.d.ts","sourceRoot":"","sources":["../../../src/commands/object/put.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAMpD,MAAM,CAAC,OAAO,OAAO,SAAU,SAAQ,WAAW,CAAC,OAAO,SAAS,CAAC;IAClE,MAAM,CAAC,IAAI;;;;;MAUT;IAEF,MAAM,CAAC,WAAW,SAAyC;IAE3D,MAAM,CAAC,QAAQ,WAIb;IAEF,MAAM,CAAC,KAAK;;;;;;;;;;;;MA+BV;IAEI,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;IA6B1B,OAAO,CAAC,cAAc;CAavB"}
|
|
@@ -64,7 +64,7 @@ Upload myfile.txt to my-bucket with key 'my-key'
|
|
|
64
64
|
const response = await objectService.putObject({
|
|
65
65
|
userId,
|
|
66
66
|
organizationId,
|
|
67
|
-
|
|
67
|
+
bucketId: flags.bucket,
|
|
68
68
|
key: args.key,
|
|
69
69
|
content: fileContent,
|
|
70
70
|
contentType,
|
|
@@ -74,9 +74,8 @@ Upload myfile.txt to my-bucket with key 'my-key'
|
|
|
74
74
|
}
|
|
75
75
|
else {
|
|
76
76
|
console.log('Successfully uploaded file:');
|
|
77
|
-
console.log(`Bucket: ${response.
|
|
77
|
+
console.log(`Bucket: ${response.bucketId}`);
|
|
78
78
|
console.log(`Key: ${response.key}`);
|
|
79
|
-
console.log(`Success: ${response.success}`);
|
|
80
79
|
}
|
|
81
80
|
}
|
|
82
81
|
getContentType(filePath) {
|
package/dist/deploy.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../src/deploy.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../src/deploy.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGhD,MAAM,WAAW,aAAa,CAAC,CAAC,SAAS,OAAO,WAAW;IAEzD,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;IAGxB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IAGf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,OAAO,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IAGd,KAAK,EAAE,OAAO,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,wBAAsB,MAAM,CAAC,CAAC,SAAS,OAAO,WAAW,EAAE,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAkHrG"}
|
package/dist/deploy.js
CHANGED
|
@@ -7,6 +7,7 @@ import { BundleArchiveType, ReleaseRequest_LockSchema, } from '@liquidmetal-ai/d
|
|
|
7
7
|
import { FileSystemBundle } from '@liquidmetal-ai/drizzle/unsafe/codestore';
|
|
8
8
|
import fs from 'node:fs/promises';
|
|
9
9
|
import * as path from 'node:path';
|
|
10
|
+
import { tmpdir } from 'zx';
|
|
10
11
|
import { buildHandlers } from './build.js';
|
|
11
12
|
export async function deploy(options) {
|
|
12
13
|
const { command, root, manifest, output } = options;
|
|
@@ -160,15 +161,41 @@ async function uploadDbBundle(command, root, catalogService, userId, organizatio
|
|
|
160
161
|
// Nothing to do
|
|
161
162
|
}
|
|
162
163
|
if (dbExists) {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
applicationVersionId: currentVersionId,
|
|
169
|
-
archiveType: BundleArchiveType.ZIP,
|
|
170
|
-
bundleName: 'db',
|
|
171
|
-
archive: Buffer.from(await archive(dbBundle)),
|
|
164
|
+
// Check if there are any SQL files in the directory
|
|
165
|
+
command.log(`Checking for SQL files in ${dbDir}`);
|
|
166
|
+
//check for subfolders under dbDir
|
|
167
|
+
const files = await fs.readdir(dbDir, {
|
|
168
|
+
withFileTypes: true,
|
|
172
169
|
});
|
|
170
|
+
const folders = files.filter((file) => file.isDirectory());
|
|
171
|
+
try {
|
|
172
|
+
// Generate a temporary directory path using zx's tmpfile
|
|
173
|
+
const tempDir = tmpdir();
|
|
174
|
+
// Copy only SQL files to the temporary directory
|
|
175
|
+
for (const folder of folders) {
|
|
176
|
+
//read all the files in the folder and filter for sql files
|
|
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
|
+
// Create bundle from the filtered directory
|
|
184
|
+
const dbBundle = new FileSystemBundle(tempDir);
|
|
185
|
+
await catalogService.uploadBundle({
|
|
186
|
+
userId,
|
|
187
|
+
organizationId,
|
|
188
|
+
applicationName: valueOf(app.name),
|
|
189
|
+
applicationVersionId: currentVersionId,
|
|
190
|
+
archiveType: BundleArchiveType.ZIP,
|
|
191
|
+
bundleName: 'db',
|
|
192
|
+
archive: Buffer.from(await archive(dbBundle)),
|
|
193
|
+
});
|
|
194
|
+
command.log(`Uploaded db bundle with SQL files`);
|
|
195
|
+
await fs.rm(tempDir, { recursive: true, force: true });
|
|
196
|
+
}
|
|
197
|
+
catch (error) {
|
|
198
|
+
command.log(`Failed to upload db bundle: ${error}`);
|
|
199
|
+
}
|
|
173
200
|
}
|
|
174
201
|
}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwC,KAAK,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAE5F,OAAO,EAAE,KAAK,MAAM,EAAgB,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAE7E,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AAEnE,OAAO,EAAE,cAAc,EAAE,MAAM,yDAAyD,CAAC;AACzF,OAAO,EACL,kBAAkB,EAEnB,MAAM,8DAA8D,CAAC;AAEtE,OAAO,EAAE,KAAK,aAAa,EAAuB,MAAM,0DAA0D,CAAC;AACnH,OAAO,EAAE,aAAa,EAAE,MAAM,wDAAwD,CAAC;AACvF,OAAO,EAAE,kBAAkB,EAAE,MAAM,8DAA8D,CAAC;AAMlG,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAElC,eAAO,MAAM,QAAQ,4CAAiC,CAAC;AAEvD,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,C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vD,OAAO,EAAE,CAAC,EACV,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,iBAAiB,EAAE,EAAE,oBAAoB,GAC5E,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAe3B"}
|
package/dist/index.js
CHANGED
|
@@ -12,7 +12,7 @@ import { Mutex } from 'async-mutex';
|
|
|
12
12
|
import { subSeconds, isAfter } from 'date-fns';
|
|
13
13
|
import * as fs from 'node:fs/promises';
|
|
14
14
|
import * as path from 'node:path';
|
|
15
|
-
import {
|
|
15
|
+
import { traceStore } from './trace.js';
|
|
16
16
|
export { run } from '@oclif/core';
|
|
17
17
|
export const EPOCH_TS = timestampFromDate(new Date(0));
|
|
18
18
|
export async function configFromAppFile(appFile) {
|
|
@@ -52,12 +52,19 @@ async function bearerTokenAndRefresh(configDir, rainbowAuth) {
|
|
|
52
52
|
// expired is true if the current time is after the earlier expiration date
|
|
53
53
|
const expired = isAfter(now, earlierExpirationDate);
|
|
54
54
|
if (expired) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
let next;
|
|
56
|
+
try {
|
|
57
|
+
next = await rainbowAuth.refreshAccessToken(create(RefreshAccessTokenRequestSchema, {
|
|
58
|
+
refreshToken: token.refreshToken,
|
|
59
|
+
organizationId: token.organizationId,
|
|
60
|
+
}));
|
|
61
|
+
}
|
|
62
|
+
catch (e) {
|
|
63
|
+
const err = e;
|
|
64
|
+
throw new Error(`unable to refresh access token: ${err.message}`);
|
|
65
|
+
}
|
|
59
66
|
if (!next.bearerToken) {
|
|
60
|
-
throw new Error('unable to refresh
|
|
67
|
+
throw new Error('unable to refresh access token: no bearer token returned');
|
|
61
68
|
}
|
|
62
69
|
state.organizationIdToBearerToken[state.currentOrganizationId] = next.bearerToken;
|
|
63
70
|
await replaceState(configDir, state);
|
|
@@ -100,11 +107,12 @@ export function createTraceInterceptor() {
|
|
|
100
107
|
return (next) => async (req) => {
|
|
101
108
|
const traceparent = traceStore.getOrCreateTraceparent(req.header.get('traceparent') ?? undefined);
|
|
102
109
|
req.header.set('traceparent', traceparent);
|
|
103
|
-
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}
|
|
110
|
+
// TODO [bosgood] re-enable once we can get a logger instance in here - messes up -o json | jq
|
|
111
|
+
// const rpcName = `${req.service.name}/${req.method.name}`;
|
|
112
|
+
// const traceUrl = generateTraceUrl(traceparent);
|
|
113
|
+
// if (traceUrl) {
|
|
114
|
+
// console.debug(`[DEBUG] ${rpcName} ${traceUrl}`);
|
|
115
|
+
// }
|
|
108
116
|
return traceStore.run(traceparent, async () => {
|
|
109
117
|
return await next(req);
|
|
110
118
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["../src/base-command.ts","../src/build.test.ts","../src/build.ts","../src/codegen.test.ts","../src/codegen.ts","../src/config.test.ts","../src/config.ts","../src/deploy.ts","../src/index.test.ts","../src/index.ts","../src/trace.ts","../src/commands/tail.ts","../src/commands/auth/list.ts","../src/commands/auth/login.ts","../src/commands/auth/logout.ts","../src/commands/auth/select.ts","../src/commands/build/branch.ts","../src/commands/build/checkout.ts","../src/commands/build/delete.ts","../src/commands/build/deploy.ts","../src/commands/build/find.ts","../src/commands/build/generate.ts","../src/commands/build/init.ts","../src/commands/build/list.ts","../src/commands/build/sandbox.ts","../src/commands/build/start.ts","../src/commands/build/status.ts","../src/commands/build/stop.ts","../src/commands/build/unsandbox.ts","../src/commands/build/upload.ts","../src/commands/build/validate.ts","../src/commands/build/env/get.ts","../src/commands/build/env/set.ts","../src/commands/build/tools/check.ts","../src/commands/build/tools/fmt.ts","../src/commands/object/delete.ts","../src/commands/object/get.ts","../src/commands/object/list.ts","../src/commands/object/put.ts","../src/commands/query/chunk-search.ts","../src/commands/query/
|
|
1
|
+
{"root":["../src/base-command.ts","../src/build.test.ts","../src/build.ts","../src/codegen.test.ts","../src/codegen.ts","../src/config.test.ts","../src/config.ts","../src/deploy.ts","../src/index.test.ts","../src/index.ts","../src/trace.ts","../src/commands/tail.ts","../src/commands/auth/list.ts","../src/commands/auth/login.ts","../src/commands/auth/logout.ts","../src/commands/auth/select.ts","../src/commands/build/branch.ts","../src/commands/build/checkout.ts","../src/commands/build/delete.ts","../src/commands/build/deploy.ts","../src/commands/build/find.ts","../src/commands/build/generate.ts","../src/commands/build/init.ts","../src/commands/build/list.ts","../src/commands/build/sandbox.ts","../src/commands/build/start.ts","../src/commands/build/status.ts","../src/commands/build/stop.ts","../src/commands/build/unsandbox.ts","../src/commands/build/upload.ts","../src/commands/build/validate.ts","../src/commands/build/env/get.ts","../src/commands/build/env/set.ts","../src/commands/build/tools/check.ts","../src/commands/build/tools/fmt.ts","../src/commands/object/delete.ts","../src/commands/object/get.ts","../src/commands/object/list.ts","../src/commands/object/put.ts","../src/commands/query/chunk-search.ts","../src/commands/query/search.ts"],"version":"5.8.2"}
|