@scout9/app 1.0.0-alpha.0.4.3 → 1.0.0-alpha.0.4.4

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.
@@ -35049,7 +35049,7 @@ function _loadUserPackageJson() {
35049
35049
  targetPkgUrl = isTest ? packageTestJsonUrl : packageJsonUrl;
35050
35050
  _context2.t0 = JSON;
35051
35051
  _context2.next = 10;
35052
- return fs__default["default"].readFile(new URL(targetPkgUrl, (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('dev-195686a8.js', document.baseURI).href))), 'utf-8');
35052
+ return fs__default["default"].readFile(new URL(targetPkgUrl, (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('dev-bee5e8fd.js', document.baseURI).href))), 'utf-8');
35053
35053
  case 10:
35054
35054
  _context2.t1 = _context2.sent;
35055
35055
  pkg = _context2.t0.parse.call(_context2.t0, _context2.t1);
@@ -35787,14 +35787,25 @@ var MacroGlobals = /*#__PURE__*/function () {
35787
35787
  }
35788
35788
  spirits._createClass(MacroGlobals, null, [{
35789
35789
  key: "$convo",
35790
- value: function $convo() {
35790
+ value:
35791
+ /**
35792
+ * @returns {string}
35793
+ */
35794
+ function $convo() {
35791
35795
  var _globalThis$SCOUT;
35792
35796
  var $convo = globalThis === null || globalThis === void 0 || (_globalThis$SCOUT = globalThis.SCOUT9) === null || _globalThis$SCOUT === void 0 ? void 0 : _globalThis$SCOUT.$convo;
35793
35797
  if (!$convo) {
35794
35798
  throw new Error("$convo not found in runtime context, ".concat(spirits._classStaticPrivateFieldSpecGet(MacroGlobals, MacroGlobals, _hint)));
35795
35799
  }
35800
+ if (typeof $convo !== 'string') {
35801
+ throw new Error("$convo not a type string, $convo=".concat(JSON.stringify($convo)));
35802
+ }
35796
35803
  return $convo;
35797
35804
  }
35805
+
35806
+ /**
35807
+ * @returns {WorkflowEvent}
35808
+ */
35798
35809
  }, {
35799
35810
  key: "event",
35800
35811
  value: function event() {
@@ -35872,6 +35883,23 @@ var _excluded$1 = ["success"];
35872
35883
  * @property {WorkflowResponseSlotBaseWithKeywords[]} withoutCondition.instruction - Array of slots with keywords.
35873
35884
  */
35874
35885
 
35886
+ // export type WorkflowResponseSlotBase = {
35887
+ // /** Forward input information of a conversation */
35888
+ // forward?: Forward | undefined;
35889
+ // /** Note to provide to the agent, recommend using forward object api instead */
35890
+ // forwardNote?: string | undefined;
35891
+ // instructions?: Instruction[] | undefined;
35892
+ // removeInstructions?: string[] | undefined;
35893
+ // message?: string | undefined;
35894
+ // secondsDelay?: number | undefined;
35895
+ // scheduled?: number | undefined;
35896
+ // contextUpsert?: {
35897
+ // [x: string]: any;
35898
+ // } | undefined;
35899
+ // resetIntent?: boolean | undefined;
35900
+ // followup?: Followup | undefined;
35901
+ // };
35902
+
35875
35903
  /**
35876
35904
  * Event macros to be used inside your scout9 auto reply workflows
35877
35905
  * @typedef {Object} EventMacros
@@ -35884,6 +35912,9 @@ var _excluded$1 = ["success"];
35884
35912
  * @property {function(boolean?): Array<WorkflowResponseSlot>} toJSON
35885
35913
  */
35886
35914
  function EventMacrosFactory() {
35915
+ /**
35916
+ * @type {Array<WorkflowResponseSlot>}
35917
+ */
35887
35918
  var slots = [];
35888
35919
  return {
35889
35920
  /**
@@ -36025,6 +36056,53 @@ function EventMacrosFactory() {
36025
36056
  }
36026
36057
  return this;
36027
36058
  },
36059
+ resetIntent: function resetIntent() {
36060
+ /** @type {WorkflowResponseSlot} */
36061
+ var slot = {
36062
+ resetIntent: true
36063
+ };
36064
+ try {
36065
+ slots.push(macros.WorkflowResponseSlotSchema.parse(slot));
36066
+ } catch (e) {
36067
+ throw simplifyError(e, 'Invalid instruct() input');
36068
+ }
36069
+ return this;
36070
+ },
36071
+ /**
36072
+ * Removes an instruction from the system
36073
+ * @param {string | string[]} idOrIds - the instruction ids to remove
36074
+ * @param {boolean} [strict] - if true, throw error if no id exists
36075
+ */
36076
+ instructRemove: function instructRemove(idOrIds) {
36077
+ var strict = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
36078
+ /** @type {WorkflowResponseSlot} */
36079
+ var slot = {};
36080
+ var ids = Array.isArray(idOrIds) ? idOrIds : typeof idOrIds === 'string' ? [idOrIds] : [];
36081
+ if (!ids.length) {
36082
+ throw new Error("Given an empty or invalid value for instructRemove, given: ".concat(JSON.stringify(idOrIds), ", expect a type string or type Array<string>"));
36083
+ }
36084
+ var event = MacroGlobals.event(); // Check the event to eval ids to remove
36085
+ ids.forEach(function (id) {
36086
+ var message = event.messages.find(function (m) {
36087
+ return m.id === id;
36088
+ });
36089
+ if (!message) {
36090
+ var msg = "Cannot remove \"".concat(id, "\", no instruction found");
36091
+ if (strict) {
36092
+ throw new Error(msg);
36093
+ } else {
36094
+ console.warn(msg);
36095
+ }
36096
+ }
36097
+ });
36098
+ slot.removeInstructions = ids;
36099
+ try {
36100
+ slots.push(macros.WorkflowResponseSlotSchema.parse(slot));
36101
+ } catch (e) {
36102
+ throw simplifyError(e, 'Invalid instruct() input');
36103
+ }
36104
+ return this;
36105
+ },
36028
36106
  /**
36029
36107
  * If conversation is not stagnant, return instructions to guide next auto reply response, otherwise it will forward the conversation
36030
36108
  * @param {string} instruction
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var spirits = require("./spirits-5c9243a1.cjs");
4
- var dev = require("./dev-195686a8.cjs");
4
+ var dev = require("./dev-bee5e8fd.cjs");
5
5
  var macros = require("./macros-e4105c56.cjs");
6
6
  var require$$0 = require('fs');
7
7
  var require$$2$1 = require('events');
@@ -29483,7 +29483,7 @@ class Body {
29483
29483
  }
29484
29484
  const {
29485
29485
  toFormData
29486
- } = await Promise.resolve().then(function () { return require("./multipart-parser-a2f207ea.cjs"); });
29486
+ } = await Promise.resolve().then(function () { return require("./multipart-parser-f2044b7e.cjs"); });
29487
29487
  return toFormData(this.body, ct);
29488
29488
  }
29489
29489
 
@@ -41884,7 +41884,7 @@ function _loadUserPackageJson() {
41884
41884
  targetPkgUrl = isTest ? packageTestJsonUrl : packageJsonUrl;
41885
41885
  _context.t0 = JSON;
41886
41886
  _context.next = 10;
41887
- return fs__default["default"].readFile(new URL(targetPkgUrl, (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('index-ec0cd08d.js', document.baseURI).href))), 'utf-8');
41887
+ return fs__default["default"].readFile(new URL(targetPkgUrl, (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('index-d96ba879.js', document.baseURI).href))), 'utf-8');
41888
41888
  case 10:
41889
41889
  _context.t1 = _context.sent;
41890
41890
  pkg = _context.t0.parse.call(_context.t0, _context.t1);
@@ -43157,7 +43157,7 @@ var ProjectFiles = /*#__PURE__*/function () {
43157
43157
  return ProjectFiles;
43158
43158
  }();
43159
43159
 
43160
- var __filename$1 = node_url.fileURLToPath((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('index-ec0cd08d.js', document.baseURI).href)));
43160
+ var __filename$1 = node_url.fileURLToPath((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('index-d96ba879.js', document.baseURI).href)));
43161
43161
  var __dirname$1 = path__default["default"].dirname(__filename$1);
43162
43162
  function zipDirectory(source, out) {
43163
43163
  var archive = archiver$1('tar', {
@@ -43372,7 +43372,7 @@ function _buildApp() {
43372
43372
  case 11:
43373
43373
  _context4.t0 = JSON;
43374
43374
  _context4.next = 14;
43375
- return fs__default["default"].readFile(new URL(templatePackagePath, (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('index-ec0cd08d.js', document.baseURI).href))), 'utf-8');
43375
+ return fs__default["default"].readFile(new URL(templatePackagePath, (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('index-d96ba879.js', document.baseURI).href))), 'utf-8');
43376
43376
  case 14:
43377
43377
  _context4.t1 = _context4.sent;
43378
43378
  packageTemplate = _context4.t0.parse.call(_context4.t0, _context4.t1);
package/dist/index.cjs CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require("./index-ec0cd08d.cjs");
6
- var dev = require("./dev-195686a8.cjs");
5
+ var index = require("./index-d96ba879.cjs");
6
+ var dev = require("./dev-bee5e8fd.cjs");
7
7
  require("./spirits-5c9243a1.cjs");
8
8
  require("./macros-e4105c56.cjs");
9
9
  require('fs');
@@ -2,9 +2,9 @@
2
2
 
3
3
  require('node:fs');
4
4
  require('node:path');
5
- var index = require("./index-ec0cd08d.cjs");
5
+ var index = require("./index-d96ba879.cjs");
6
6
  require("./spirits-5c9243a1.cjs");
7
- require("./dev-195686a8.cjs");
7
+ require("./dev-bee5e8fd.cjs");
8
8
  require('util');
9
9
  require('stream');
10
10
  require('path');
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var dev = require("./dev-195686a8.cjs");
5
+ var dev = require("./dev-bee5e8fd.cjs");
6
6
  require("./spirits-5c9243a1.cjs");
7
7
  require('util');
8
8
  require('stream');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scout9/app",
3
- "version": "1.0.0-alpha.0.4.3",
3
+ "version": "1.0.0-alpha.0.4.4",
4
4
  "description": "Build and deploy your Scout9 app for SMS auto replies",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -62,6 +62,25 @@ import MacroGlobals from './globals.js';
62
62
  * @property {WorkflowResponseSlotBaseWithKeywords[]} withoutCondition.instruction - Array of slots with keywords.
63
63
  */
64
64
 
65
+ // export type WorkflowResponseSlotBase = {
66
+ // /** Forward input information of a conversation */
67
+ // forward?: Forward | undefined;
68
+ // /** Note to provide to the agent, recommend using forward object api instead */
69
+ // forwardNote?: string | undefined;
70
+ // instructions?: Instruction[] | undefined;
71
+ // removeInstructions?: string[] | undefined;
72
+ // message?: string | undefined;
73
+ // secondsDelay?: number | undefined;
74
+ // scheduled?: number | undefined;
75
+ // contextUpsert?: {
76
+ // [x: string]: any;
77
+ // } | undefined;
78
+ // resetIntent?: boolean | undefined;
79
+ // followup?: Followup | undefined;
80
+ // };
81
+
82
+
83
+
65
84
  /**
66
85
  * Event macros to be used inside your scout9 auto reply workflows
67
86
  * @typedef {Object} EventMacros
@@ -75,6 +94,9 @@ import MacroGlobals from './globals.js';
75
94
  */
76
95
  function EventMacrosFactory() {
77
96
 
97
+ /**
98
+ * @type {Array<WorkflowResponseSlot>}
99
+ */
78
100
  let slots = [];
79
101
 
80
102
  return {
@@ -215,6 +237,50 @@ function EventMacrosFactory() {
215
237
  return this;
216
238
  },
217
239
 
240
+ resetIntent() {
241
+ /** @type {WorkflowResponseSlot} */
242
+ const slot = {resetIntent: true};
243
+ try {
244
+ slots.push(WorkflowResponseSlotSchema.parse(slot));
245
+ } catch (e) {
246
+ throw simplifyError(e, 'Invalid instruct() input');
247
+ }
248
+ return this;
249
+ },
250
+
251
+ /**
252
+ * Removes an instruction from the system
253
+ * @param {string | string[]} idOrIds - the instruction ids to remove
254
+ * @param {boolean} [strict] - if true, throw error if no id exists
255
+ */
256
+ instructRemove(idOrIds, strict = false) {
257
+ /** @type {WorkflowResponseSlot} */
258
+ const slot = {};
259
+ const ids = Array.isArray(idOrIds) ? idOrIds : typeof idOrIds === 'string' ? [idOrIds] : [];
260
+ if (!ids.length) {
261
+ throw new Error(`Given an empty or invalid value for instructRemove, given: ${JSON.stringify(idOrIds)}, expect a type string or type Array<string>`);
262
+ }
263
+ const event = MacroGlobals.event(); // Check the event to eval ids to remove
264
+ ids.forEach((id) => {
265
+ const message = event.messages.find(m => m.id === id);
266
+ if (!message) {
267
+ const msg = `Cannot remove "${id}", no instruction found`
268
+ if (strict) {
269
+ throw new Error(msg);
270
+ } else {
271
+ console.warn(msg);
272
+ }
273
+ }
274
+ });
275
+ slot.removeInstructions = ids;
276
+ try {
277
+ slots.push(WorkflowResponseSlotSchema.parse(slot));
278
+ } catch (e) {
279
+ throw simplifyError(e, 'Invalid instruct() input');
280
+ }
281
+ return this;
282
+ },
283
+
218
284
  /**
219
285
  * If conversation is not stagnant, return instructions to guide next auto reply response, otherwise it will forward the conversation
220
286
  * @param {string} instruction
@@ -231,6 +297,8 @@ function EventMacrosFactory() {
231
297
  }
232
298
  },
233
299
 
300
+
301
+
234
302
  /**
235
303
  * Return instructions to guide next auto reply response
236
304
  * @param {string} instruction
@@ -2,14 +2,23 @@
2
2
 
3
3
  export default class MacroGlobals {
4
4
 
5
+ /**
6
+ * @returns {string}
7
+ */
5
8
  static $convo() {
6
9
  const $convo = globalThis?.SCOUT9?.$convo;
7
10
  if (!$convo) {
8
11
  throw new Error(`$convo not found in runtime context, ${MacroGlobals.#hint}`);
9
12
  }
13
+ if (typeof $convo !== 'string') {
14
+ throw new Error(`$convo not a type string, $convo=${JSON.stringify($convo)}`);
15
+ }
10
16
  return $convo;
11
17
  }
12
18
 
19
+ /**
20
+ * @returns {WorkflowEvent}
21
+ */
13
22
  static event() {
14
23
  const event = globalThis?.SCOUT9;
15
24
  if (!event) {