@scout9/app 1.0.0-alpha.0.2.4 → 1.0.0-alpha.0.2.6
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/{dev-73ac7343.cjs → dev-170fa3f5.cjs} +18 -4683
- package/dist/{index-6fd2c8cd.cjs → index-44e73470.cjs} +16 -15
- package/dist/index.cjs +3 -52
- package/dist/macros-eff64992.cjs +4588 -0
- package/dist/{multipart-parser-a55dfbdc.cjs → multipart-parser-bd1fae8a.cjs} +3 -2
- package/dist/schemas.cjs +55 -0
- package/dist/testing-tools.cjs +2 -1
- package/package.json +6 -1
- package/src/core/templates/app.js +17 -6
- package/src/exports.js +0 -1
- package/src/public.d.ts +2 -2
- package/src/runtime/client/api.js +1 -1
- package/src/runtime/schemas/api.js +0 -8
- package/src/runtime/schemas/platform.js +2 -46
- package/src/runtime/schemas/users.js +0 -16
- package/src/schemas.js +1 -0
- package/types/index.d.ts +14708 -2
- package/types/index.d.ts.map +64 -3
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
require('node:fs');
|
|
4
4
|
require('node:path');
|
|
5
|
-
var index = require("./index-
|
|
5
|
+
var index = require("./index-44e73470.cjs");
|
|
6
6
|
require("./spirits-76855e30.cjs");
|
|
7
|
-
require("./dev-
|
|
7
|
+
require("./dev-170fa3f5.cjs");
|
|
8
8
|
require('util');
|
|
9
9
|
require('stream');
|
|
10
10
|
require('path');
|
|
@@ -25,6 +25,7 @@ require('node:stream');
|
|
|
25
25
|
require('node:string_decoder');
|
|
26
26
|
require('node:readline');
|
|
27
27
|
require('node:process');
|
|
28
|
+
require("./macros-eff64992.cjs");
|
|
28
29
|
require('node:os');
|
|
29
30
|
require('fs/promises');
|
|
30
31
|
require('constants');
|
package/dist/schemas.cjs
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var macros = require("./macros-eff64992.cjs");
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
exports.AgentConfigurationSchema = macros.AgentConfigurationSchema;
|
|
10
|
+
exports.AgentSchema = macros.AgentSchema;
|
|
11
|
+
exports.AgentsConfigurationSchema = macros.AgentsConfigurationSchema;
|
|
12
|
+
exports.AgentsSchema = macros.AgentsSchema;
|
|
13
|
+
exports.ContextExampleSchema = macros.ContextExampleSchema;
|
|
14
|
+
exports.ContextExampleWithTrainingDataSchema = macros.ContextExampleWithTrainingDataSchema;
|
|
15
|
+
exports.ConversationAnticipateSchema = macros.ConversationAnticipateSchema;
|
|
16
|
+
exports.ConversationContext = macros.ConversationContext;
|
|
17
|
+
exports.ConversationSchema = macros.ConversationSchema;
|
|
18
|
+
exports.CustomerSchema = macros.CustomerSchema;
|
|
19
|
+
exports.CustomerValueSchema = macros.CustomerValueSchema;
|
|
20
|
+
exports.EntitiesRootConfigurationSchema = macros.EntitiesRootConfigurationSchema;
|
|
21
|
+
exports.EntitiesRootProjectConfigurationSchema = macros.EntitiesRootProjectConfigurationSchema;
|
|
22
|
+
exports.EntityApiConfigurationSchema = macros.EntityApiConfigurationSchema;
|
|
23
|
+
exports.EntityConfigurationSchema = macros.EntityConfigurationSchema;
|
|
24
|
+
exports.EntityRootProjectConfigurationSchema = macros.EntityRootProjectConfigurationSchema;
|
|
25
|
+
exports.FollowupBaseSchema = macros.FollowupBaseSchema;
|
|
26
|
+
exports.FollowupSchema = macros.FollowupSchema;
|
|
27
|
+
exports.ForwardSchema = macros.ForwardSchema;
|
|
28
|
+
exports.InstructionObjectSchema = macros.InstructionObjectSchema;
|
|
29
|
+
exports.InstructionSchema = macros.InstructionSchema;
|
|
30
|
+
exports.IntentWorkflowEventSchema = macros.IntentWorkflowEventSchema;
|
|
31
|
+
exports.MessageSchema = macros.MessageSchema;
|
|
32
|
+
exports.PersonaConfigurationSchema = macros.PersonaConfigurationSchema;
|
|
33
|
+
exports.PersonaSchema = macros.PersonaSchema;
|
|
34
|
+
exports.PersonasConfigurationSchema = macros.PersonasConfigurationSchema;
|
|
35
|
+
exports.PersonasSchema = macros.PersonasSchema;
|
|
36
|
+
exports.Scout9ProjectBuildConfigSchema = macros.Scout9ProjectBuildConfigSchema;
|
|
37
|
+
exports.Scout9ProjectConfigSchema = macros.Scout9ProjectConfigSchema;
|
|
38
|
+
exports.WorkflowConfigurationSchema = macros.WorkflowConfigurationSchema;
|
|
39
|
+
exports.WorkflowEventSchema = macros.WorkflowEventSchema;
|
|
40
|
+
exports.WorkflowFunctionSchema = macros.WorkflowFunctionSchema;
|
|
41
|
+
exports.WorkflowResponseMessage = macros.WorkflowResponseMessage;
|
|
42
|
+
exports.WorkflowResponseMessageApiRequest = macros.WorkflowResponseMessageApiRequest;
|
|
43
|
+
exports.WorkflowResponseMessageApiResponse = macros.WorkflowResponseMessageApiResponse;
|
|
44
|
+
exports.WorkflowResponseSchema = macros.WorkflowResponseSchema;
|
|
45
|
+
exports.WorkflowResponseSlotBaseSchema = macros.WorkflowResponseSlotBaseSchema;
|
|
46
|
+
exports.WorkflowResponseSlotSchema = macros.WorkflowResponseSlotSchema;
|
|
47
|
+
exports.WorkflowsConfigurationSchema = macros.WorkflowsConfigurationSchema;
|
|
48
|
+
exports.apiFunctionSchema = macros.apiFunctionSchema;
|
|
49
|
+
exports.deleteApiFunctionSchema = macros.deleteApiFunctionSchema;
|
|
50
|
+
exports.eventResponseSchema = macros.eventResponseSchema;
|
|
51
|
+
exports.getApiFunctionSchema = macros.getApiFunctionSchema;
|
|
52
|
+
exports.patchApiFunctionSchema = macros.patchApiFunctionSchema;
|
|
53
|
+
exports.postApiFunctionSchema = macros.postApiFunctionSchema;
|
|
54
|
+
exports.putApiFunctionSchema = macros.putApiFunctionSchema;
|
|
55
|
+
exports.queryApiFunctionSchema = macros.queryApiFunctionSchema;
|
package/dist/testing-tools.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var dev = require("./dev-
|
|
5
|
+
var dev = require("./dev-170fa3f5.cjs");
|
|
6
6
|
require("./spirits-76855e30.cjs");
|
|
7
7
|
require('util');
|
|
8
8
|
require('stream');
|
|
@@ -26,6 +26,7 @@ require('node:stream');
|
|
|
26
26
|
require('node:string_decoder');
|
|
27
27
|
require('node:readline');
|
|
28
28
|
require('node:process');
|
|
29
|
+
require("./macros-eff64992.cjs");
|
|
29
30
|
require('node:os');
|
|
30
31
|
require('fs/promises');
|
|
31
32
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scout9/app",
|
|
3
|
-
"version": "1.0.0-alpha.0.2.
|
|
3
|
+
"version": "1.0.0-alpha.0.2.6",
|
|
4
4
|
"description": "Build and deploy your Scout9 app for SMS auto replies",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -56,6 +56,11 @@
|
|
|
56
56
|
"import": "./src/testing-tools/spirits.js",
|
|
57
57
|
"types": "./types/index.d.ts",
|
|
58
58
|
"require": "./dist/spirits.cjs"
|
|
59
|
+
},
|
|
60
|
+
"./schemas": {
|
|
61
|
+
"import": "./src/schemas.js",
|
|
62
|
+
"types": "./types/index.d.ts",
|
|
63
|
+
"require": "./dist/schemas.cjs"
|
|
59
64
|
}
|
|
60
65
|
},
|
|
61
66
|
"keywords": [],
|
|
@@ -5,7 +5,7 @@ import bodyParser from 'body-parser';
|
|
|
5
5
|
import colors from 'kleur';
|
|
6
6
|
import { config as dotenv } from 'dotenv';
|
|
7
7
|
import { Configuration, Scout9Api } from '@scout9/admin';
|
|
8
|
-
import { EventResponse, WorkflowEventSchema } from '@scout9/app';
|
|
8
|
+
import { EventResponse, WorkflowEventSchema, WorkflowResponseSchema } from '@scout9/app';
|
|
9
9
|
import path, { resolve } from 'node:path';
|
|
10
10
|
import fs from 'node:fs';
|
|
11
11
|
import https from 'node:https';
|
|
@@ -179,7 +179,7 @@ app.post(dev ? '/dev/workflow' : '/', async (req, res) => {
|
|
|
179
179
|
const formattedErrors = error.format();
|
|
180
180
|
res.writeHead(400, {'Content-Type': 'application/json'});
|
|
181
181
|
res.end(JSON.stringify({
|
|
182
|
-
status: '
|
|
182
|
+
status: 'Invalid WorkflowEvent',
|
|
183
183
|
errors: formattedErrors
|
|
184
184
|
}));
|
|
185
185
|
console.log(colors.red(`${colors.bold(`Bad Input Event:`)}: Received: ${JSON.stringify(req.body.event, null, 2)}\n\nErrors:\n\n${JSON.stringify(formattedErrors, null, 2)}`));
|
|
@@ -195,15 +195,26 @@ app.post(dev ? '/dev/workflow' : '/', async (req, res) => {
|
|
|
195
195
|
|
|
196
196
|
try {
|
|
197
197
|
const response = await projectApp(workflowEvent);
|
|
198
|
+
const formattedResponse = WorkflowEventSchema.parse(response);
|
|
198
199
|
if (dev) {
|
|
199
200
|
console.log(colors.green(`Workflow Sending Response:`));
|
|
200
|
-
console.log(colors.grey(JSON.stringify(
|
|
201
|
+
console.log(colors.grey(JSON.stringify(formattedResponse, null, 2)));
|
|
201
202
|
}
|
|
202
203
|
res.writeHead(200, {'Content-Type': 'application/json'});
|
|
203
|
-
res.end(JSON.stringify(
|
|
204
|
+
res.end(JSON.stringify(formattedResponse));
|
|
204
205
|
} catch (error) {
|
|
205
|
-
error
|
|
206
|
-
|
|
206
|
+
if (error instanceof ZodError) {
|
|
207
|
+
const formattedErrors = error.format();
|
|
208
|
+
res.writeHead(500, {'Content-Type': 'application/json'});
|
|
209
|
+
res.end(JSON.stringify({
|
|
210
|
+
status: 'Invalid WorkflowResponse',
|
|
211
|
+
errors: formattedErrors
|
|
212
|
+
}));
|
|
213
|
+
console.log(colors.red(`${colors.bold(`Input Workflow Response`)}: Fix needed\n\n${JSON.stringify(formattedErrors, null, 2)}`));
|
|
214
|
+
} else {
|
|
215
|
+
error.message = `Workflow Template Runtime Error: ` + error.message
|
|
216
|
+
handleError(error, res);
|
|
217
|
+
}
|
|
207
218
|
}
|
|
208
219
|
});
|
|
209
220
|
|
package/src/exports.js
CHANGED
package/src/public.d.ts
CHANGED
|
@@ -25,7 +25,7 @@ export function run(event: WorkflowEvent, options: {
|
|
|
25
25
|
* @param {ResponseInit | undefined} [init]
|
|
26
26
|
* @returns {EventResponse<T>}
|
|
27
27
|
*/
|
|
28
|
-
export function json<T>(data: T, init?: ResponseInit | undefined): EventResponse<T>;
|
|
28
|
+
export function json<T = any>(data: T, init?: ResponseInit | undefined): EventResponse<T>;
|
|
29
29
|
/**
|
|
30
30
|
* @param {WorkflowEvent} event - every workflow receives an event object
|
|
31
31
|
* @param {Object} options
|
|
@@ -47,7 +47,7 @@ export function sendEvent(event: WorkflowEvent, options: {
|
|
|
47
47
|
* Utility runtime class used to guide event output
|
|
48
48
|
* @template T
|
|
49
49
|
*/
|
|
50
|
-
export class EventResponse<T> {
|
|
50
|
+
export class EventResponse<T = any> {
|
|
51
51
|
/**
|
|
52
52
|
* Create a new EventResponse instance with a JSON body.
|
|
53
53
|
* @template T
|
|
@@ -9,7 +9,7 @@ export class EventResponse {
|
|
|
9
9
|
* @template T
|
|
10
10
|
* @param {T} body - The body of the response.
|
|
11
11
|
* @param {ResponseInit} [options] - Additional options for the response.
|
|
12
|
-
* @returns {EventResponse<T>} A new EventResponse instance.
|
|
12
|
+
* @returns {EventResponse<T = any>} A new EventResponse instance.
|
|
13
13
|
*/
|
|
14
14
|
static json(body, options) {
|
|
15
15
|
return new EventResponse(body, options);
|
|
@@ -7,14 +7,6 @@ const responseInitSchema = z.object({
|
|
|
7
7
|
headers: z.any().optional() // Headers can be complex; adjust as needed
|
|
8
8
|
});
|
|
9
9
|
|
|
10
|
-
/**
|
|
11
|
-
* @template T
|
|
12
|
-
* @typedef {object} IEventResponse
|
|
13
|
-
* @property {T} body - The body of the response.
|
|
14
|
-
* @property {ResponseInit} [init] - Additional options for the response.
|
|
15
|
-
* @property {Response} response - The response object.
|
|
16
|
-
* @property {T} data - The body of the response.
|
|
17
|
-
*/
|
|
18
10
|
export const eventResponseSchema = z.object({
|
|
19
11
|
body: z.any(), // Adjust as per your actual body structure
|
|
20
12
|
init: responseInitSchema.optional()
|
|
@@ -2,85 +2,41 @@ import { z } from 'zod';
|
|
|
2
2
|
import { eventResponseSchema } from './api.js';
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
/**
|
|
6
|
-
* @typedef {object} IApiFunctionParams
|
|
7
|
-
* @property {Object.<string, string|string[]>} searchParams
|
|
8
|
-
* @property {Record<string, string>} params
|
|
9
|
-
*/
|
|
10
5
|
const apiFunctionParamsSchema = z.object({
|
|
11
6
|
searchParams: z.record(z.string(), z.union([z.string(), z.array(z.string())])),
|
|
12
7
|
params: z.record(z.string(), z.string())
|
|
13
8
|
});
|
|
14
9
|
|
|
15
|
-
/**
|
|
16
|
-
* @typedef {IApiFunctionParams & { id: string }} IApiEntityFunctionParams
|
|
17
|
-
*/
|
|
18
10
|
const apiEntityFunctionParamsSchema = apiFunctionParamsSchema.extend({
|
|
19
11
|
id: z.string()
|
|
20
12
|
});
|
|
21
13
|
|
|
22
|
-
/**
|
|
23
|
-
* @template Params
|
|
24
|
-
* @template Response
|
|
25
|
-
* @typedef {function(IApiFunctionParams): Promise<EventResponse>} IApiFunction
|
|
26
|
-
*/
|
|
27
14
|
export const apiFunctionSchema = z.function()
|
|
28
15
|
.args(apiFunctionParamsSchema)
|
|
29
16
|
.returns(z.promise(eventResponseSchema));
|
|
30
17
|
|
|
31
|
-
/**
|
|
32
|
-
* @template Params
|
|
33
|
-
* @template Response
|
|
34
|
-
* @typedef {IApiFunction<Params, Response>} IQueryApiFunction
|
|
35
|
-
*/
|
|
36
18
|
export const queryApiFunctionSchema = apiFunctionSchema;
|
|
37
19
|
|
|
38
|
-
/**
|
|
39
|
-
* @template Params
|
|
40
|
-
* @template Response
|
|
41
|
-
* @typedef {IApiFunction<Params, Response>} GetApiFunction
|
|
42
|
-
*/
|
|
43
20
|
export const getApiFunctionSchema = apiFunctionSchema;
|
|
44
21
|
|
|
45
|
-
/**
|
|
46
|
-
* @template Params
|
|
47
|
-
* @template RequestBody
|
|
48
|
-
* @template Response
|
|
49
|
-
* @typedef {function(IApiFunctionParams & {body: Partial<RequestBody>}): Promise<EventResponse<Response>>} IPostApiFunction
|
|
50
|
-
*/
|
|
51
22
|
export const postApiFunctionSchema = (requestBodySchema) => z.function()
|
|
52
23
|
.args(apiFunctionParamsSchema.extend({
|
|
53
24
|
body: requestBodySchema.partial()
|
|
54
25
|
}))
|
|
55
26
|
.returns(z.promise(eventResponseSchema));
|
|
56
27
|
|
|
57
|
-
|
|
58
|
-
* @template Params
|
|
59
|
-
* @template RequestBody
|
|
60
|
-
* @template Response
|
|
61
|
-
* @typedef {function(IApiFunctionParams & {body: Partial<RequestBody>}): Promise<EventResponse<Response>>} IPutApiFunction
|
|
62
|
-
*/
|
|
28
|
+
|
|
63
29
|
export const putApiFunctionSchema = (requestBodySchema) => z.function()
|
|
64
30
|
.args(apiFunctionParamsSchema.extend({
|
|
65
31
|
body: requestBodySchema.partial()
|
|
66
32
|
}))
|
|
67
33
|
.returns(z.promise(eventResponseSchema));
|
|
68
34
|
|
|
69
|
-
|
|
70
|
-
* @template Params
|
|
71
|
-
* @template RequestBody
|
|
72
|
-
* @template Response
|
|
73
|
-
* @typedef {function(IApiFunctionParams & {body: Partial<RequestBody>}): Promise<EventResponse<Response>>} IPatchApiFunction
|
|
74
|
-
*/
|
|
35
|
+
|
|
75
36
|
export const patchApiFunctionSchema = (requestBodySchema) => z.function()
|
|
76
37
|
.args(apiFunctionParamsSchema.extend({
|
|
77
38
|
body: requestBodySchema.partial()
|
|
78
39
|
}))
|
|
79
40
|
.returns(z.promise(eventResponseSchema));
|
|
80
41
|
|
|
81
|
-
/**
|
|
82
|
-
* @template Params
|
|
83
|
-
* @template Response
|
|
84
|
-
* @typedef {IApiFunction<Params, Response>} IDeleteApiFunction
|
|
85
|
-
*/
|
|
86
42
|
export const deleteApiFunctionSchema = apiFunctionSchema;
|
|
@@ -65,19 +65,3 @@ export const PersonasConfigurationSchema = z.array(PersonaConfigurationSchema);
|
|
|
65
65
|
export const AgentsSchema = z.array(AgentSchema);
|
|
66
66
|
|
|
67
67
|
export const PersonasSchema = z.array(PersonaSchema);
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
export const Bus = z.object({
|
|
71
|
-
foo: z.string(),
|
|
72
|
-
bar: z.boolean().optional()
|
|
73
|
-
});
|
|
74
|
-
export const Baz = z.object({
|
|
75
|
-
boo: z.object({
|
|
76
|
-
one: z.number(),
|
|
77
|
-
two: z.number().optional()
|
|
78
|
-
})
|
|
79
|
-
})
|
|
80
|
-
export const TestSchema = z.object({
|
|
81
|
-
baz: Baz,
|
|
82
|
-
bus: Bus
|
|
83
|
-
});
|
package/src/schemas.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './runtime/schemas/index.js';
|