@chatbotkit/cli 1.9.0 → 1.9.1
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/dist/cjs/command/solution/index.cjs +1 -0
- package/dist/cjs/solution/index.cjs +44 -7
- package/dist/cjs/solution/index.d.ts +25 -18
- package/dist/esm/command/solution/index.js +1 -0
- package/dist/esm/solution/index.d.ts +83 -76
- package/dist/esm/solution/index.js +42 -6
- package/dist/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +2 -2
|
@@ -40,6 +40,7 @@ exports.solutionSync = new commander_1.Command()
|
|
|
40
40
|
.action(async (name) => {
|
|
41
41
|
const solution = await index_js_1.Solution.load(name);
|
|
42
42
|
await solution.sync();
|
|
43
|
+
await index_js_1.Solution.save(name, solution);
|
|
43
44
|
});
|
|
44
45
|
exports.command = new commander_1.Command()
|
|
45
46
|
.name('solution')
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getArrayBackedObject = exports.ArrayBackedObject = exports.Solution = exports.SitemapIntegrationResource = exports.WidgetIntegrationResource = exports.SkillsetResource = exports.DatasetResource = exports.BotResource = exports.Resource = exports.SolutionConfigSchema = exports.ResourceConfigSchema = exports.SitemapIntegrationResourceConfigSchema = exports.WidgetIntegrationResourceConfigSchema = exports.SkillsetResourceConfigSchema = exports.DatasetResourceConfigSchema = exports.BotResourceConfigSchema = exports.BasicResourceConfigSchema = exports.getSolutionFileNameAndPath = exports.getSolutionFilePath = exports.getSolutionFileName = exports.getSolutionFolderPath = void 0;
|
|
3
|
+
exports.getArrayBackedObject = exports.ArrayBackedObject = exports.Solution = exports.SitemapIntegrationResource = exports.WidgetIntegrationResource = exports.SkillsetResource = exports.DatasetResource = exports.BotResource = exports.Resource = exports.SolutionConfigSchema = exports.ResourceConfigSchema = exports.SitemapIntegrationResourceConfigSchema = exports.WidgetIntegrationResourceConfigSchema = exports.SkillsetResourceConfigSchema = exports.DatasetResourceConfigSchema = exports.BotResourceConfigSchema = exports.BasicResourceConfigSchema = exports.replaceEnvVars = exports.getSolutionFileNameAndPath = exports.getSolutionFilePath = exports.getSolutionFileName = exports.getSolutionFolderPath = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const env_js_1 = require("../env.cjs");
|
|
6
6
|
const output_js_1 = require("../output.cjs");
|
|
@@ -30,10 +30,32 @@ function getSolutionFileNameAndPath(name) {
|
|
|
30
30
|
return { fileName, filePath };
|
|
31
31
|
}
|
|
32
32
|
exports.getSolutionFileNameAndPath = getSolutionFileNameAndPath;
|
|
33
|
+
function replaceEnvVars(value) {
|
|
34
|
+
if (!value) {
|
|
35
|
+
return value;
|
|
36
|
+
}
|
|
37
|
+
if (typeof value === 'string') {
|
|
38
|
+
return value.replace(/\${env\.([A-Z_]+)}/g, (_, name) => {
|
|
39
|
+
const envValue = process.env[name];
|
|
40
|
+
if (envValue === undefined) {
|
|
41
|
+
throw new output_js_1.CommandError(`Environment variable ${name} is not set`);
|
|
42
|
+
}
|
|
43
|
+
return envValue;
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
if (Array.isArray(value)) {
|
|
47
|
+
return value.map(replaceEnvVars);
|
|
48
|
+
}
|
|
49
|
+
if (typeof value === 'object') {
|
|
50
|
+
return Object.fromEntries(Object.entries(value).map(([key, value]) => [key, replaceEnvVars(value)]));
|
|
51
|
+
}
|
|
52
|
+
return value;
|
|
53
|
+
}
|
|
54
|
+
exports.replaceEnvVars = replaceEnvVars;
|
|
33
55
|
exports.BasicResourceConfigSchema = zod_1.z.object({
|
|
34
56
|
type: zod_1.z.string(),
|
|
35
57
|
slug: zod_1.z.string().optional(),
|
|
36
|
-
id: zod_1.z.string(),
|
|
58
|
+
id: zod_1.z.string().optional(),
|
|
37
59
|
name: zod_1.z.string(),
|
|
38
60
|
description: zod_1.z.string().optional(),
|
|
39
61
|
properties: zod_1.z.record(zod_1.z.unknown()),
|
|
@@ -110,11 +132,21 @@ class Resource {
|
|
|
110
132
|
throw new Error('Not implemented');
|
|
111
133
|
}
|
|
112
134
|
async sync() {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
135
|
+
if (this.config.id) {
|
|
136
|
+
await this.client.update(this.config.id, {
|
|
137
|
+
...this.config.properties,
|
|
138
|
+
name: this.config.name,
|
|
139
|
+
description: this.config.description,
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
const { id } = await this.client.create({
|
|
144
|
+
...this.config.properties,
|
|
145
|
+
name: this.config.name,
|
|
146
|
+
description: this.config.description,
|
|
147
|
+
});
|
|
148
|
+
this.config.id = id;
|
|
149
|
+
}
|
|
118
150
|
}
|
|
119
151
|
}
|
|
120
152
|
exports.Resource = Resource;
|
|
@@ -265,8 +297,13 @@ Solution.load = async function (config) {
|
|
|
265
297
|
if (!parsedConfig.success) {
|
|
266
298
|
throw new output_js_1.CommandError(`Invalid solution configuration`);
|
|
267
299
|
}
|
|
300
|
+
parsedConfig.data = replaceEnvVars(parsedConfig.data);
|
|
268
301
|
return new Solution(parsedConfig.data);
|
|
269
302
|
};
|
|
303
|
+
Solution.save = async function (name, solution) {
|
|
304
|
+
const filePath = getSolutionFilePath(name);
|
|
305
|
+
await promises_1.default.writeFile(filePath, JSON.stringify(solution.config, null, 2));
|
|
306
|
+
};
|
|
270
307
|
class ArrayBackedObject {
|
|
271
308
|
constructor(array) {
|
|
272
309
|
this.array = array;
|
|
@@ -5,13 +5,14 @@ export function getSolutionFileNameAndPath(name: string): {
|
|
|
5
5
|
fileName: string;
|
|
6
6
|
filePath: string;
|
|
7
7
|
};
|
|
8
|
+
export function replaceEnvVars(value: any): any;
|
|
8
9
|
export function getArrayBackedObject<T>(array: T[]): {
|
|
9
10
|
[key: string]: T;
|
|
10
11
|
};
|
|
11
12
|
export const BasicResourceConfigSchema: z.ZodObject<{
|
|
12
13
|
type: z.ZodString;
|
|
13
14
|
slug: z.ZodOptional<z.ZodString>;
|
|
14
|
-
id: z.ZodString
|
|
15
|
+
id: z.ZodOptional<z.ZodString>;
|
|
15
16
|
name: z.ZodString;
|
|
16
17
|
description: z.ZodOptional<z.ZodString>;
|
|
17
18
|
properties: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
@@ -32,7 +33,7 @@ export const BasicResourceConfigSchema: z.ZodObject<{
|
|
|
32
33
|
}>;
|
|
33
34
|
export const BotResourceConfigSchema: z.ZodObject<{
|
|
34
35
|
slug: z.ZodOptional<z.ZodString>;
|
|
35
|
-
id: z.ZodString
|
|
36
|
+
id: z.ZodOptional<z.ZodString>;
|
|
36
37
|
name: z.ZodString;
|
|
37
38
|
description: z.ZodOptional<z.ZodString>;
|
|
38
39
|
type: z.ZodLiteral<"bot">;
|
|
@@ -89,7 +90,7 @@ export const BotResourceConfigSchema: z.ZodObject<{
|
|
|
89
90
|
}>;
|
|
90
91
|
export const DatasetResourceConfigSchema: z.ZodObject<{
|
|
91
92
|
slug: z.ZodOptional<z.ZodString>;
|
|
92
|
-
id: z.ZodString
|
|
93
|
+
id: z.ZodOptional<z.ZodString>;
|
|
93
94
|
name: z.ZodString;
|
|
94
95
|
description: z.ZodOptional<z.ZodString>;
|
|
95
96
|
type: z.ZodLiteral<"dataset">;
|
|
@@ -111,7 +112,7 @@ export const DatasetResourceConfigSchema: z.ZodObject<{
|
|
|
111
112
|
}>;
|
|
112
113
|
export const SkillsetResourceConfigSchema: z.ZodObject<{
|
|
113
114
|
slug: z.ZodOptional<z.ZodString>;
|
|
114
|
-
id: z.ZodString
|
|
115
|
+
id: z.ZodOptional<z.ZodString>;
|
|
115
116
|
name: z.ZodString;
|
|
116
117
|
description: z.ZodOptional<z.ZodString>;
|
|
117
118
|
type: z.ZodLiteral<"skillset">;
|
|
@@ -133,7 +134,7 @@ export const SkillsetResourceConfigSchema: z.ZodObject<{
|
|
|
133
134
|
}>;
|
|
134
135
|
export const WidgetIntegrationResourceConfigSchema: z.ZodObject<{
|
|
135
136
|
slug: z.ZodOptional<z.ZodString>;
|
|
136
|
-
id: z.ZodString
|
|
137
|
+
id: z.ZodOptional<z.ZodString>;
|
|
137
138
|
name: z.ZodString;
|
|
138
139
|
description: z.ZodOptional<z.ZodString>;
|
|
139
140
|
type: z.ZodLiteral<"widgetIntegration">;
|
|
@@ -155,7 +156,7 @@ export const WidgetIntegrationResourceConfigSchema: z.ZodObject<{
|
|
|
155
156
|
}>;
|
|
156
157
|
export const SitemapIntegrationResourceConfigSchema: z.ZodObject<{
|
|
157
158
|
slug: z.ZodOptional<z.ZodString>;
|
|
158
|
-
id: z.ZodString
|
|
159
|
+
id: z.ZodOptional<z.ZodString>;
|
|
159
160
|
name: z.ZodString;
|
|
160
161
|
description: z.ZodOptional<z.ZodString>;
|
|
161
162
|
type: z.ZodLiteral<"sitemapIntegration">;
|
|
@@ -192,7 +193,7 @@ export const SitemapIntegrationResourceConfigSchema: z.ZodObject<{
|
|
|
192
193
|
}>;
|
|
193
194
|
export const ResourceConfigSchema: z.ZodUnion<[z.ZodObject<{
|
|
194
195
|
slug: z.ZodOptional<z.ZodString>;
|
|
195
|
-
id: z.ZodString
|
|
196
|
+
id: z.ZodOptional<z.ZodString>;
|
|
196
197
|
name: z.ZodString;
|
|
197
198
|
description: z.ZodOptional<z.ZodString>;
|
|
198
199
|
type: z.ZodLiteral<"bot">;
|
|
@@ -248,7 +249,7 @@ export const ResourceConfigSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
248
249
|
};
|
|
249
250
|
}>, z.ZodObject<{
|
|
250
251
|
slug: z.ZodOptional<z.ZodString>;
|
|
251
|
-
id: z.ZodString
|
|
252
|
+
id: z.ZodOptional<z.ZodString>;
|
|
252
253
|
name: z.ZodString;
|
|
253
254
|
description: z.ZodOptional<z.ZodString>;
|
|
254
255
|
type: z.ZodLiteral<"dataset">;
|
|
@@ -269,7 +270,7 @@ export const ResourceConfigSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
269
270
|
properties?: {};
|
|
270
271
|
}>, z.ZodObject<{
|
|
271
272
|
slug: z.ZodOptional<z.ZodString>;
|
|
272
|
-
id: z.ZodString
|
|
273
|
+
id: z.ZodOptional<z.ZodString>;
|
|
273
274
|
name: z.ZodString;
|
|
274
275
|
description: z.ZodOptional<z.ZodString>;
|
|
275
276
|
type: z.ZodLiteral<"skillset">;
|
|
@@ -290,7 +291,7 @@ export const ResourceConfigSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
290
291
|
properties?: {};
|
|
291
292
|
}>, z.ZodObject<{
|
|
292
293
|
slug: z.ZodOptional<z.ZodString>;
|
|
293
|
-
id: z.ZodString
|
|
294
|
+
id: z.ZodOptional<z.ZodString>;
|
|
294
295
|
name: z.ZodString;
|
|
295
296
|
description: z.ZodOptional<z.ZodString>;
|
|
296
297
|
type: z.ZodLiteral<"widgetIntegration">;
|
|
@@ -311,7 +312,7 @@ export const ResourceConfigSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
311
312
|
properties?: {};
|
|
312
313
|
}>, z.ZodObject<{
|
|
313
314
|
slug: z.ZodOptional<z.ZodString>;
|
|
314
|
-
id: z.ZodString
|
|
315
|
+
id: z.ZodOptional<z.ZodString>;
|
|
315
316
|
name: z.ZodString;
|
|
316
317
|
description: z.ZodOptional<z.ZodString>;
|
|
317
318
|
type: z.ZodLiteral<"sitemapIntegration">;
|
|
@@ -350,7 +351,7 @@ export const SolutionConfigSchema: z.ZodObject<{
|
|
|
350
351
|
version: z.ZodLiteral<1>;
|
|
351
352
|
resources: z.ZodArray<z.ZodUnion<[z.ZodObject<{
|
|
352
353
|
slug: z.ZodOptional<z.ZodString>;
|
|
353
|
-
id: z.ZodString
|
|
354
|
+
id: z.ZodOptional<z.ZodString>;
|
|
354
355
|
name: z.ZodString;
|
|
355
356
|
description: z.ZodOptional<z.ZodString>;
|
|
356
357
|
type: z.ZodLiteral<"bot">;
|
|
@@ -406,7 +407,7 @@ export const SolutionConfigSchema: z.ZodObject<{
|
|
|
406
407
|
};
|
|
407
408
|
}>, z.ZodObject<{
|
|
408
409
|
slug: z.ZodOptional<z.ZodString>;
|
|
409
|
-
id: z.ZodString
|
|
410
|
+
id: z.ZodOptional<z.ZodString>;
|
|
410
411
|
name: z.ZodString;
|
|
411
412
|
description: z.ZodOptional<z.ZodString>;
|
|
412
413
|
type: z.ZodLiteral<"dataset">;
|
|
@@ -427,7 +428,7 @@ export const SolutionConfigSchema: z.ZodObject<{
|
|
|
427
428
|
properties?: {};
|
|
428
429
|
}>, z.ZodObject<{
|
|
429
430
|
slug: z.ZodOptional<z.ZodString>;
|
|
430
|
-
id: z.ZodString
|
|
431
|
+
id: z.ZodOptional<z.ZodString>;
|
|
431
432
|
name: z.ZodString;
|
|
432
433
|
description: z.ZodOptional<z.ZodString>;
|
|
433
434
|
type: z.ZodLiteral<"skillset">;
|
|
@@ -448,7 +449,7 @@ export const SolutionConfigSchema: z.ZodObject<{
|
|
|
448
449
|
properties?: {};
|
|
449
450
|
}>, z.ZodObject<{
|
|
450
451
|
slug: z.ZodOptional<z.ZodString>;
|
|
451
|
-
id: z.ZodString
|
|
452
|
+
id: z.ZodOptional<z.ZodString>;
|
|
452
453
|
name: z.ZodString;
|
|
453
454
|
description: z.ZodOptional<z.ZodString>;
|
|
454
455
|
type: z.ZodLiteral<"widgetIntegration">;
|
|
@@ -469,7 +470,7 @@ export const SolutionConfigSchema: z.ZodObject<{
|
|
|
469
470
|
properties?: {};
|
|
470
471
|
}>, z.ZodObject<{
|
|
471
472
|
slug: z.ZodOptional<z.ZodString>;
|
|
472
|
-
id: z.ZodString
|
|
473
|
+
id: z.ZodOptional<z.ZodString>;
|
|
473
474
|
name: z.ZodString;
|
|
474
475
|
description: z.ZodOptional<z.ZodString>;
|
|
475
476
|
type: z.ZodLiteral<"sitemapIntegration">;
|
|
@@ -656,7 +657,12 @@ export class Resource {
|
|
|
656
657
|
get description(): string;
|
|
657
658
|
get baseClient(): ChatBotKit;
|
|
658
659
|
get client(): {
|
|
659
|
-
|
|
660
|
+
create: (properties: Record<string, any>) => Promise<{
|
|
661
|
+
id: string;
|
|
662
|
+
}>;
|
|
663
|
+
update: (id: string, properties: Record<string, any>) => Promise<{
|
|
664
|
+
id: string;
|
|
665
|
+
}>;
|
|
660
666
|
};
|
|
661
667
|
sync(): Promise<void>;
|
|
662
668
|
}
|
|
@@ -673,7 +679,7 @@ export class WidgetIntegrationResource extends Resource {
|
|
|
673
679
|
override get client(): any;
|
|
674
680
|
}
|
|
675
681
|
export class SitemapIntegrationResource extends Resource {
|
|
676
|
-
|
|
682
|
+
get client(): any;
|
|
677
683
|
}
|
|
678
684
|
export class Solution {
|
|
679
685
|
constructor(config: SolutionConfig);
|
|
@@ -804,6 +810,7 @@ export namespace Solution {
|
|
|
804
810
|
};
|
|
805
811
|
})[];
|
|
806
812
|
}): Promise<Solution>;
|
|
813
|
+
export function save(name: string, solution: Solution): Promise<void>;
|
|
807
814
|
}
|
|
808
815
|
export class ArrayBackedObject<T> {
|
|
809
816
|
constructor(array: T[]);
|