@scout9/app 1.0.0-alpha.0.1.86 → 1.0.0-alpha.0.1.88

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/index.cjs CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var exports$1 = require("./exports-291eb22e.cjs");
6
- var spirits = require("./spirits-643c422a.cjs");
5
+ var exports$1 = require("./exports-b2e88386.cjs");
6
+ var spirits = require("./spirits-1dc18cf4.cjs");
7
7
  require('node:readline');
8
8
  require('fs');
9
9
  require('events');
@@ -47,20 +47,22 @@ exports.InstructionSchema = exports$1.InstructionSchema;
47
47
  exports.IntentWorkflowEventSchema = exports$1.IntentWorkflowEventSchema;
48
48
  exports.MessageSchema = exports$1.MessageSchema;
49
49
  exports.Scout9ProjectBuildConfigSchema = exports$1.Scout9ProjectBuildConfigSchema;
50
+ exports.Scout9ProjectConfigSchema = exports$1.Scout9ProjectConfigSchema;
50
51
  exports.Scout9Test = exports$1.Scout9Test;
51
52
  exports.WorkflowConfigurationSchema = exports$1.WorkflowConfigurationSchema;
52
53
  exports.WorkflowEventSchema = exports$1.WorkflowEventSchema;
54
+ exports.WorkflowFunctionSchema = exports$1.WorkflowFunctionSchema;
53
55
  exports.WorkflowResponseMessage = exports$1.WorkflowResponseMessage;
54
56
  exports.WorkflowResponseMessageApiRequest = exports$1.WorkflowResponseMessageApiRequest;
55
57
  exports.WorkflowResponseMessageApiResponse = exports$1.WorkflowResponseMessageApiResponse;
56
58
  exports.WorkflowResponseSchema = exports$1.WorkflowResponseSchema;
57
59
  exports.WorkflowResponseSlotSchema = exports$1.WorkflowResponseSlotSchema;
58
60
  exports.WorkflowsConfigurationSchema = exports$1.WorkflowsConfigurationSchema;
59
- exports._entityApiConfigurationSchema = exports$1._entityApiConfigurationSchema;
60
61
  exports.agentBaseConfigurationSchema = exports$1.agentBaseConfigurationSchema;
61
62
  exports.agentConfigurationSchema = exports$1.agentConfigurationSchema;
62
63
  exports.agentsBaseConfigurationSchema = exports$1.agentsBaseConfigurationSchema;
63
64
  exports.agentsConfigurationSchema = exports$1.agentsConfigurationSchema;
65
+ exports.apiFunctionSchema = exports$1.apiFunctionSchema;
64
66
  exports.createMockAgent = exports$1.createMockAgent;
65
67
  exports.createMockConversation = exports$1.createMockConversation;
66
68
  exports.createMockCustomer = exports$1.createMockCustomer;
@@ -68,12 +70,19 @@ exports.createMockMessage = exports$1.createMockMessage;
68
70
  exports.createMockWorkflowEvent = exports$1.createMockWorkflowEvent;
69
71
  exports.customerSchema = exports$1.customerSchema;
70
72
  exports.customerValueSchema = exports$1.customerValueSchema;
73
+ exports.deleteApiFunctionSchema = exports$1.deleteApiFunctionSchema;
71
74
  exports.entitiesRootConfigurationSchema = exports$1.entitiesRootConfigurationSchema;
72
75
  exports.entitiesRootProjectConfigurationSchema = exports$1.entitiesRootProjectConfigurationSchema;
73
76
  exports.entityApiConfigurationSchema = exports$1.entityApiConfigurationSchema;
74
77
  exports.entityConfigurationSchema = exports$1.entityConfigurationSchema;
75
78
  exports.entityRootProjectConfigurationSchema = exports$1.entityRootProjectConfigurationSchema;
79
+ exports.eventResponseSchema = exports$1.eventResponseSchema;
80
+ exports.getApiFunctionSchema = exports$1.getApiFunctionSchema;
76
81
  exports.json = exports$1.json;
82
+ exports.patchApiFunctionSchema = exports$1.patchApiFunctionSchema;
83
+ exports.postApiFunctionSchema = exports$1.postApiFunctionSchema;
84
+ exports.putApiFunctionSchema = exports$1.putApiFunctionSchema;
85
+ exports.queryApiFunctionSchema = exports$1.queryApiFunctionSchema;
77
86
  exports.run = exports$1.run;
78
87
  exports.sendEvent = exports$1.sendEvent;
79
88
  exports.Spirits = spirits.Spirits;
@@ -2,8 +2,8 @@
2
2
 
3
3
  require('node:fs');
4
4
  require('node:path');
5
- var exports$1 = require("./exports-291eb22e.cjs");
6
- require("./spirits-643c422a.cjs");
5
+ var exports$1 = require("./exports-b2e88386.cjs");
6
+ require("./spirits-1dc18cf4.cjs");
7
7
  require('node:readline');
8
8
  require('fs');
9
9
  require('events');
@@ -566,35 +566,35 @@ function _createForOfIteratorHelper(o, allowArrayLike) {
566
566
 
567
567
  /**
568
568
  * @typedef {Object} ConversationData
569
- * @property {import('@scout9/app').Scout9ProjectBuildConfig} config - used to define generation and extract persona metadata
570
- * @property {import('@scout9/app').Conversation} conversation
571
- * @property {Array<import('@scout9/app').Message>} messages
572
- * @property {import('@scout9/app').Message} message - the message sent by the customer (should exist in messages)
573
- * @property {import('@scout9/app').Customer} customer
569
+ * @property {import('@scout9/app').IScout9ProjectBuildConfig} config - used to define generation and extract persona metadata
570
+ * @property {import('@scout9/app').IConversation} conversation
571
+ * @property {Array<import('@scout9/app').IMessage>} messages
572
+ * @property {import('@scout9/app').IMessage} message - the message sent by the customer (should exist in messages)
573
+ * @property {import('@scout9/app').ICustomer} customer
574
574
  * @property {any} context
575
575
  */
576
576
 
577
577
  /**
578
578
  * @typedef {Object} ParseOutput
579
- * @property {Array<import('@scout9/app').Message>} messages
580
- * @property {import('@scout9/app').Conversation} conversation
581
- * @property {import('@scout9/app').Message} message
579
+ * @property {Array<import('@scout9/app').IMessage>} messages
580
+ * @property {import('@scout9/app').IConversation} conversation
581
+ * @property {import('@scout9/app').IMessage} message
582
582
  * @property {any} context
583
583
  */
584
584
 
585
585
  /**
586
586
  * @typedef {Object} WorkflowOutput
587
- * @property {Array<import('@scout9/app').WorkflowResponseSlot>} slots
588
- * @property {Array<import('@scout9/app').Message>} messages
589
- * @property {import('@scout9/app').Conversation} conversation
587
+ * @property {Array<import('@scout9/app').IWorkflowResponseSlot>} slots
588
+ * @property {Array<import('@scout9/app').IMessage>} messages
589
+ * @property {import('@scout9/app').IConversation} conversation
590
590
  * @property {any} context
591
591
  */
592
592
 
593
593
  /**
594
594
  * @typedef {Object} GenerateOutput
595
595
  * @property {import('@scout9/admin').GenerateResponse | undefined} generate
596
- * @property {Array<import('@scout9/app').Message>} messages
597
- * @property {import('@scout9/app').Conversation} conversation
596
+ * @property {Array<import('@scout9/app').IMessage>} messages
597
+ * @property {import('@scout9/app').IConversation} conversation
598
598
  * @property {any} context
599
599
  */
600
600
 
@@ -607,8 +607,8 @@ function _createForOfIteratorHelper(o, allowArrayLike) {
607
607
 
608
608
  /**
609
609
  * @callback WorkflowFun
610
- * @param {import('@scout9/app').WorkflowEvent} event - conversation data
611
- * @returns {Promise<import('@scout9/app').WorkflowResponse>}
610
+ * @param {import('@scout9/app').IWorkflowEvent} event - conversation data
611
+ * @returns {Promise<import('@scout9/app').IWorkflowResponse>}
612
612
  */
613
613
 
614
614
  /**
@@ -619,7 +619,7 @@ function _createForOfIteratorHelper(o, allowArrayLike) {
619
619
 
620
620
  /**
621
621
  * @callback IdGeneratorFun
622
- * @param {import('@scout9/app').Message.role} prefix
622
+ * @param {import('@scout9/app').IMessage.role} prefix
623
623
  * @returns {string}
624
624
  */
625
625
  /**
@@ -642,10 +642,10 @@ function _createForOfIteratorHelper(o, allowArrayLike) {
642
642
 
643
643
  /**
644
644
  * @typedef {Object} ConversationEvent
645
- * @property {Change<import('@scout9/app').Conversation> & {forwardNote?: string; forward?: import('@scout9/app').WorkflowResponseSlot['forward']}} conversation
646
- * @property {Change<Array<import('@scout9/app').Message>>} messages
645
+ * @property {Change<import('@scout9/app').IConversation> & {forwardNote?: string; forward?: import('@scout9/app').WorkflowResponseSlot['forward']}} conversation
646
+ * @property {Change<Array<import('@scout9/app').IMessage>>} messages
647
647
  * @property {Change<Object>} context
648
- * @property {Change<import('@scout9/app').Message>} message
648
+ * @property {Change<import('@scout9/app').IMessage>} message
649
649
  */
650
650
  var Spirits = {
651
651
  /**
package/dist/spirits.cjs CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var spirits = require("./spirits-643c422a.cjs");
5
+ var spirits = require("./spirits-1dc18cf4.cjs");
6
6
 
7
7
 
8
8
 
@@ -2,8 +2,8 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var exports$1 = require("./exports-291eb22e.cjs");
6
- var spirits = require("./spirits-643c422a.cjs");
5
+ var exports$1 = require("./exports-b2e88386.cjs");
6
+ var spirits = require("./spirits-1dc18cf4.cjs");
7
7
  require('node:readline');
8
8
  require('fs');
9
9
  require('events');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scout9/app",
3
- "version": "1.0.0-alpha.0.1.86",
3
+ "version": "1.0.0-alpha.0.1.88",
4
4
  "description": "Build and deploy your Scout9 app for SMS auto replies",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -31,12 +31,12 @@ async function loadEntityApiConfig(cwd, filePath) {
31
31
  }
32
32
 
33
33
  /**
34
- * @returns {Promise<EntitiesBuildConfig>}
34
+ * @returns {Promise<import('@scout9/app').IEntitiesRootProjectConfiguration>}
35
35
  */
36
36
  export default async function loadEntitiesConfig(
37
37
  {cwd = process.cwd(), src = 'src', logger, cb = (message) => {}} = {}
38
38
  ) {
39
- /** @type EntitiesBuildConfig */
39
+ /** @type import('@scout9/app').IEntitiesRootProjectConfiguration */
40
40
  const config = [];
41
41
  // const paths = globSync(path.resolve(cwd, `${src}/entities/**/{index,config,api}.{ts,js}`), {cwd, absolute: true});
42
42
  const filePaths = globSync(`${src}/entities/**/{index,config,api}.{ts,js}`, {cwd, absolute: true});
@@ -7,8 +7,6 @@ import loadProjectConfig from './project.js';
7
7
  import loadWorkflowsConfig from './workflow.js';
8
8
  import { Scout9ProjectBuildConfigSchema } from '../../runtime/index.js';
9
9
  import { ProgressLogger } from '../../utils/index.js';
10
- import ProjectFiles from '../../utils/project.js';
11
- import { logUserValidationError } from '../../report.js';
12
10
 
13
11
 
14
12
  export function loadEnvConfig({
@@ -36,7 +34,7 @@ export function loadEnvConfig({
36
34
  /**
37
35
  * @deprecated use "new ProjectFiles(...).load()" instead
38
36
  * @param {{cwd: string; src: string; logger?: ProgressLogger; deploying?: boolean; cb?: (message: string) => void}} - build options
39
- * @returns {Promise<Scout9ProjectBuildConfig>}
37
+ * @returns {Promise<import('@scout9/app').IScout9ProjectBuildConfig>}
40
38
  */
41
39
  export async function loadConfig({
42
40
  cwd = process.cwd(), src = 'src', dest = '/tmp/project', deploying = false, logger = new ProgressLogger(), cb = (msg) => {
@@ -51,7 +49,7 @@ export async function loadConfig({
51
49
  const workflowsConfig = await loadWorkflowsConfig({cwd, src, logger, deploying, cb});
52
50
 
53
51
  /**
54
- * @type {Scout9ProjectBuildConfig}
52
+ * @type {import('@scout9/app').IScout9ProjectBuildConfig}
55
53
  */
56
54
  const projectConfig = {
57
55
  ...baseProjectConfig,
@@ -35,7 +35,8 @@ async function writeImageToServer({img, type = 'icon', source}) {
35
35
 
36
36
 
37
37
  /**
38
- * Loads the users local package.json, if they provide a package-s9-test.json, it will load that instead (used for scout9 internal testing)
38
+ * Loads the users local package.json, if they provide a package-s9-test.json,
39
+ * it will load that instead (used for scout9 internal testing)
39
40
  * @param {cwd?: string}
40
41
  * @returns {Promise<{isTest: boolean, pkg: {name: string; version: string; dependencies: Record<string, string>}}>}
41
42
  */
@@ -54,7 +55,7 @@ export async function loadUserPackageJson({cwd = process.cwd()}) {
54
55
  }
55
56
 
56
57
  /**
57
- * @returns {Promise<Scout9ProjectConfig>}
58
+ * @returns {Promise<import('@scout9/app').IScout9ProjectConfig>}
58
59
  */
59
60
  export default async function loadProjectConfig({cwd = process.cwd(), deploying = false, src = 'src', cb = (message) => {}} = {}) {
60
61
  // Grab the project tag name (from their package.json)
@@ -1,13 +1,9 @@
1
1
  import { globSync } from 'glob';
2
- import path from 'node:path';
3
- import {
4
- WorkflowConfigurationSchema,
5
- WorkflowsConfigurationSchema
6
- } from '../../runtime/index.js';
2
+ import { WorkflowConfigurationSchema, WorkflowsConfigurationSchema } from '../../runtime/index.js';
7
3
 
8
4
 
9
5
  /**
10
- * @returns {Promise<WorkflowsBuildConfig>}
6
+ * @returns {Promise<import('@scout9/app').IWorkflowsConfiguration>}
11
7
  */
12
8
  export default async function loadWorkflowsConfig(
13
9
  {
@@ -34,7 +30,7 @@ export default async function loadWorkflowsConfig(
34
30
  .map(({path, parents}) => {
35
31
 
36
32
  // Validate project configuration
37
- /** @type {WorkflowBuildConfig} */
33
+ /** @type {import('@scout9/app').IWorkflowConfiguration} */
38
34
  const workflowConfig = {
39
35
  entity: parents[0],
40
36
  entities: parents.reverse(),
package/src/core/index.js CHANGED
@@ -20,34 +20,6 @@ const __filename = fileURLToPath(import.meta.url);
20
20
  const __dirname = path.dirname(__filename);
21
21
 
22
22
 
23
- /**
24
- * @returns {Promise<string>} - the output directory
25
- */
26
- // async function runNpmRunBuild({cwd = process.cwd(), src = 'src'} = {}) {
27
- // const pkg = JSON.parse(fss.readFileSync(new URL(`${cwd}/package.json`, import.meta.url), 'utf-8'));
28
- // // Package.json must have a "build" script
29
- // const buildScript = pkg.scripts?.build;
30
- // if (!buildScript) {
31
- // // If no build script then just return src
32
- // return path.resolve(cwd, src);
33
- // }
34
- // // "build" script cannot contain "scout9 build" (otherwise we'll get stuck in a loop)
35
- // if (buildScript.includes('scout9 build')) {
36
- // throw new Error(`"build" script in ${cwd}/package.json cannot contain "scout9 build"`);
37
- // }
38
- //
39
- // return new Promise((resolve, reject) => {
40
- // exec('npm run build', {cwd}, (error, stdout, stderr) => {
41
- // if (error) {
42
- // return reject(error);
43
- // }
44
- // // @TODO don't assume build script created a "build" directory (use a config)
45
- // return resolve(path.resolve(cwd, 'build'));
46
- // });
47
- // });
48
- // }
49
-
50
-
51
23
  function zipDirectory(source, out) {
52
24
  const archive = archiver('tar', {
53
25
  gzip: true,
@@ -126,7 +98,7 @@ async function downloadAndUnpackZip(outputDir) {
126
98
  * @param {string} cwd
127
99
  * @param {string} src
128
100
  * @param {string} dest
129
- * @param {Scout9ProjectBuildConfig} config
101
+ * @param {import('@scout9/app').IScout9ProjectBuildConfig} config
130
102
  * @returns {Promise<void>}
131
103
  */
132
104
  async function buildApp(cwd, src, dest, config) {
@@ -245,6 +217,13 @@ async function downloadDevApp(destination, version) {
245
217
 
246
218
  }
247
219
 
220
+ /**
221
+ * @param {Object} [options]
222
+ * @param {string} [options.cwd]
223
+ * @param {string} [options.src]
224
+ * @param {boolean} [options.ignoreAppRequire]
225
+ * @returns {Promise<{app: *, fileName: string, exe: string, filePath: string}>}
226
+ */
248
227
  export async function getApp({cwd = process.cwd(), src = 'src', ignoreAppRequire = false} = {}) {
249
228
  const indexTsPath = path.resolve(cwd, src, 'index.ts');
250
229
  const indexJsPath = path.resolve(cwd, src, 'index.js');
@@ -313,10 +292,10 @@ export async function getAgentContacts() {
313
292
  * Runs a given project container from scout9 to given environment
314
293
  * Runs the project in a container
315
294
  *
316
- * @param {WorkflowEvent} event - every workflow receives an event object
295
+ * @param {import('../runtime/client/workflow.js').IWorkflowEvent} event - every workflow receives an event object
317
296
  * @param {Object} options
318
297
  * @param {string} options.eventSource - the source path of the event
319
- * @returns {Promise<WorkflowResponse<any>>}
298
+ * @returns {Promise<import('../runtime/client/workflow.js').IWorkflowResponse>}
320
299
  */
321
300
  export async function run(event, {eventSource} = {}) {
322
301
  const result = WorkflowEventSchema.safeParse(event);
@@ -359,7 +338,7 @@ export async function runConfig() {
359
338
  /**
360
339
  * Builds a local project
361
340
  * @param {{cwd: string; src: string; dest: string; logger: ProgressLogger; mode: string;}} - build options
362
- * @param {Scout9ProjectBuildConfig} config
341
+ * @param {import('../runtime/client/').IScout9ProjectBuildConfig} config
363
342
  * @returns {messages: string[]}
364
343
  */
365
344
  export async function build({
@@ -408,6 +387,7 @@ export async function build({
408
387
  * Deploys a local project to scout9
409
388
  * @param {{cwd: string; src: string, dest: string}} - build options
410
389
  * @param {Scout9ProjectBuildConfig} config
390
+ * @return {Promise<{deploy: Object, contacts: any}>}
411
391
  */
412
392
  export async function deploy(
413
393
  {cwd = process.cwd(), src = './src', dest = '/tmp/project', logger = new ProgressLogger()},
@@ -455,7 +435,7 @@ export async function deploy(
455
435
  /**
456
436
  * Tests a local project to scout9 by running a dummy parse command with the project's local entities
457
437
  * @param {{cwd: string; src: string, dest: string}} - build options
458
- * @param {Scout9ProjectBuildConfig} config
438
+ * @param {import('@scout9/app').IScout9ProjectBuildConfig} config
459
439
  */
460
440
  export async function test(
461
441
  {cwd = process.cwd(), src = './src', dest = '/tmp/project', logger = new ProgressLogger()},
@@ -487,8 +467,8 @@ export async function test(
487
467
  /**
488
468
  *
489
469
  * @param {{cwd: string; src: string; projectFiles: ProjectFiles; logger: ProgressLogger}} options
490
- * @param {Scout9ProjectBuildConfig} config
491
- * @returns {Promise<{success: boolean; config: Scout9ProjectBuildConfig}>}
470
+ * @param {import('@scout9/app').IScout9ProjectBuildConfig} config
471
+ * @returns {Promise<{success: boolean; config: import('@scout9/app').IScout9ProjectBuildConfig}>}
492
472
  */
493
473
  export async function sync({
494
474
  cwd = process.cwd(), src = 'src',
package/src/core/sync.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { platformApi } from './data.js';
2
2
 
3
3
  /**
4
- * @param {Scout9ProjectBuildConfig} config
5
- * @returns {Promise<Scout9ProjectBuildConfig>}
4
+ * @param {import('@scout9/app').IScout9ProjectBuildConfig} config
5
+ * @returns {Promise<import('@scout9/app').IScout9ProjectBuildConfig>}
6
6
  */
7
7
  export async function syncData(config) {
8
8
  if (!process.env.SCOUT9_API_KEY) {
@@ -1,9 +1,5 @@
1
1
  import fs from 'node:fs/promises';
2
2
  import { globSync } from 'glob';
3
- import path from 'node:path';
4
- import fss from 'node:fs';
5
- import { checkVariableType, requireProjectFile } from '../../utils/index.js';
6
-
7
3
 
8
4
 
9
5
  const resolveFilePath = () => {
@@ -19,7 +15,7 @@ const resolveFilePath = () => {
19
15
  export const entities = {
20
16
  /**
21
17
  * Generates ./src/entities/
22
- * @param {Scout9ProjectBuildConfig} config
18
+ * @param {import('@scout9/app').IScout9ProjectBuildConfig} config
23
19
  * @param {string} cwd
24
20
  * @param {string} src
25
21
  * @returns {Promise<void>}
package/src/exports.js CHANGED
@@ -2,30 +2,34 @@ import { Scout9Platform } from './platform.js';
2
2
  import { EventResponse } from './runtime/index.js';
3
3
 
4
4
  export { EventResponse } from './runtime/index.js';
5
- // export * from './types';
5
+
6
6
  export * from './testing-tools/index.js';
7
7
  export * from './runtime/client/index.js';
8
8
 
9
9
  /**
10
- * @param {WorkflowEvent} event - every workflow receives an event object
11
- * @param {{cwd: string; mode: 'development' | 'production'; src: string}} options - build options
12
- * @returns {Promise<WorkflowResponse<any>>}
10
+ * @param {import('./runtime/client/workflow.js').IWorkflowEvent} event - every workflow receives an event object
11
+ * @param {Object} options
12
+ * @param {string} [options.cwd=process.cwd()] - the working directory
13
+ * @param {string} [options.mode='production'] - the build mode
14
+ * @param {string} [options.src='./src'] - the source directory
15
+ * @param {string} options.eventSource - the source of the workflow event
16
+ * @returns {Promise<import('./runtime/client/workflow.js').IWorkflowResponse>}
13
17
  */
14
18
  export async function run(event, options) {
15
19
  return Scout9Platform.run(event, options)
16
20
  }
17
21
 
18
22
  /**
19
- * @param {WorkflowEvent} event - every workflow receives an event object
23
+ * @param {import('./runtime/client/workflow.js').IWorkflowEvent} event - every workflow receives an event object
20
24
  * @param {{cwd: string; mode: 'development' | 'production'; src: string}} options - build options
21
- * @returns {Promise<WorkflowResponse<any>>}
25
+ * @returns {Promise<import('./runtime/client/workflow.js').IWorkflowResponse>}
22
26
  */
23
27
  export const sendEvent = run;
24
28
 
25
29
  /**
26
30
  * @param data {T}
27
31
  * @param init {ResponseInit | undefined}
28
- * @returns {EventResponse<T>}
32
+ * @returns {import('./runtime/client/api.js').EventResponse<T>}
29
33
  */
30
34
  export function json(data, init) {
31
35
  if (data instanceof Promise) {