@voiceflow/base-types 2.119.0 → 2.121.0
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/build/cjs/node/utils/command.d.ts +28 -5
- package/build/cjs/node/utils/command.d.ts.map +1 -1
- package/build/cjs/node/utils/command.js +18 -1
- package/build/cjs/node/utils/event.d.ts +2 -0
- package/build/cjs/node/utils/event.d.ts.map +1 -1
- package/build/cjs/node/utils/event.js +6 -2
- package/build/esm/node/utils/command.d.ts +28 -5
- package/build/esm/node/utils/command.d.ts.map +1 -1
- package/build/esm/node/utils/command.js +9 -0
- package/build/esm/node/utils/event.d.ts +2 -0
- package/build/esm/node/utils/event.d.ts.map +1 -1
- package/build/esm/node/utils/event.js +3 -1
- package/package.json +5 -4
|
@@ -1,24 +1,47 @@
|
|
|
1
1
|
import type { Nullable } from '@voiceflow/common';
|
|
2
2
|
import type { BaseCommand } from './base';
|
|
3
|
-
import type
|
|
3
|
+
import { type BaseEvent } from './event';
|
|
4
4
|
export declare enum CommandType {
|
|
5
5
|
JUMP = "jump",
|
|
6
6
|
PUSH = "push"
|
|
7
7
|
}
|
|
8
|
-
export interface TypedBaseCommand
|
|
8
|
+
export interface TypedBaseCommand extends BaseCommand {
|
|
9
9
|
type: CommandType;
|
|
10
|
+
}
|
|
11
|
+
export interface WithEventMatching<Event extends BaseEvent = BaseEvent> {
|
|
10
12
|
event: Event;
|
|
11
13
|
}
|
|
12
|
-
export interface
|
|
14
|
+
export interface WithSiftOnMatching {
|
|
15
|
+
on: Record<string, unknown>;
|
|
16
|
+
}
|
|
17
|
+
export interface WithJump extends TypedBaseCommand {
|
|
13
18
|
type: CommandType.JUMP;
|
|
14
19
|
nextID: Nullable<string>;
|
|
15
20
|
diagramID?: Nullable<string>;
|
|
16
21
|
platform?: string;
|
|
17
22
|
}
|
|
18
|
-
export interface
|
|
23
|
+
export interface WithPush extends TypedBaseCommand {
|
|
19
24
|
type: CommandType.PUSH;
|
|
20
25
|
diagramID: Nullable<string>;
|
|
21
26
|
platform?: string;
|
|
22
27
|
}
|
|
23
|
-
export
|
|
28
|
+
export interface JumpEventMatchedCommand<Event extends BaseEvent = BaseEvent> extends WithJump, WithEventMatching<Event> {
|
|
29
|
+
}
|
|
30
|
+
export interface PushEventMatchedCommand<Event extends BaseEvent = BaseEvent> extends WithPush, WithEventMatching<Event> {
|
|
31
|
+
}
|
|
32
|
+
export interface JumpOnMatchedCommand extends WithJump, WithSiftOnMatching {
|
|
33
|
+
}
|
|
34
|
+
export interface PushOnMatchedCommand extends WithPush, WithSiftOnMatching {
|
|
35
|
+
}
|
|
36
|
+
export type EventMatchedCommand<Event extends BaseEvent = BaseEvent> = JumpEventMatchedCommand<Event> | PushEventMatchedCommand<Event>;
|
|
37
|
+
export type OnMatchedCommand = JumpOnMatchedCommand | PushOnMatchedCommand;
|
|
38
|
+
export type AnyCommand<Event extends BaseEvent = BaseEvent> = EventMatchedCommand<Event> | OnMatchedCommand;
|
|
39
|
+
export declare const isWithJump: (command: BaseCommand) => command is WithJump;
|
|
40
|
+
export declare const isWithPush: (command: BaseCommand) => command is WithPush;
|
|
41
|
+
export declare const isWithEventMatching: <TEvent extends BaseEvent = BaseEvent>(command: BaseCommand) => command is EventMatchedCommand<TEvent>;
|
|
42
|
+
export declare const isWithOnMatching: (command: BaseCommand) => command is OnMatchedCommand;
|
|
43
|
+
export declare const isJumpEventMatchedCommand: <Event extends BaseEvent = BaseEvent>(command: BaseCommand) => command is JumpEventMatchedCommand<Event>;
|
|
44
|
+
export declare const isPushEventMatchedCommand: <Event extends BaseEvent = BaseEvent>(command: BaseCommand) => command is JumpEventMatchedCommand<Event>;
|
|
45
|
+
export declare const isJumpOnMatchedCommand: <Event extends BaseEvent = BaseEvent>(command: BaseCommand) => command is JumpEventMatchedCommand<Event>;
|
|
46
|
+
export declare const isPushOnMatchedCommand: <Event extends BaseEvent = BaseEvent>(command: BaseCommand) => command is JumpEventMatchedCommand<Event>;
|
|
24
47
|
//# sourceMappingURL=command.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../../../src/node/utils/command.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAElD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAC1C,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../../../src/node/utils/command.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAElD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAC1C,OAAO,EAAE,KAAK,SAAS,EAAe,MAAM,SAAS,CAAC;AAGtD,oBAAY,WAAW;IACrB,IAAI,SAAS;IACb,IAAI,SAAS;CACd;AAED,MAAM,WAAW,gBAAiB,SAAQ,WAAW;IACnD,IAAI,EAAE,WAAW,CAAC;CACnB;AAED,MAAM,WAAW,iBAAiB,CAAC,KAAK,SAAS,SAAS,GAAG,SAAS;IACpE,KAAK,EAAE,KAAK,CAAC;CACd;AAED,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC7B;AAED,MAAM,WAAW,QAAS,SAAQ,gBAAgB;IAChD,IAAI,EAAE,WAAW,CAAC,IAAI,CAAC;IACvB,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IACzB,SAAS,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,QAAS,SAAQ,gBAAgB;IAChD,IAAI,EAAE,WAAW,CAAC,IAAI,CAAC;IACvB,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC5B,QAAQ,CAAC,EAAE,MAAM,CA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ommandType = void 0;
|
|
3
|
+
exports.isPushOnMatchedCommand = exports.isJumpOnMatchedCommand = exports.isPushEventMatchedCommand = exports.isJumpEventMatchedCommand = exports.isWithOnMatching = exports.isWithEventMatching = exports.isWithPush = exports.isWithJump = exports.CommandType = void 0;
|
|
4
|
+
const event_1 = require("./event");
|
|
4
5
|
// BUILT IN COMMANDS
|
|
5
6
|
var CommandType;
|
|
6
7
|
(function (CommandType) {
|
|
7
8
|
CommandType["JUMP"] = "jump";
|
|
8
9
|
CommandType["PUSH"] = "push";
|
|
9
10
|
})(CommandType || (exports.CommandType = CommandType = {}));
|
|
11
|
+
const isWithJump = (command) => command.type === CommandType.JUMP;
|
|
12
|
+
exports.isWithJump = isWithJump;
|
|
13
|
+
const isWithPush = (command) => command.type === CommandType.PUSH;
|
|
14
|
+
exports.isWithPush = isWithPush;
|
|
15
|
+
const isWithEventMatching = (command) => 'event' in command && (0, event_1.isBaseEvent)(command.event);
|
|
16
|
+
exports.isWithEventMatching = isWithEventMatching;
|
|
17
|
+
const isWithOnMatching = (command) => 'on' in command && typeof command.on === 'object' && command.on !== null;
|
|
18
|
+
exports.isWithOnMatching = isWithOnMatching;
|
|
19
|
+
const isJumpEventMatchedCommand = (command) => (0, exports.isWithJump)(command) && (0, exports.isWithEventMatching)(command);
|
|
20
|
+
exports.isJumpEventMatchedCommand = isJumpEventMatchedCommand;
|
|
21
|
+
const isPushEventMatchedCommand = (command) => (0, exports.isWithPush)(command) && (0, exports.isWithEventMatching)(command);
|
|
22
|
+
exports.isPushEventMatchedCommand = isPushEventMatchedCommand;
|
|
23
|
+
const isJumpOnMatchedCommand = (command) => (0, exports.isWithJump)(command) && (0, exports.isWithOnMatching)(command);
|
|
24
|
+
exports.isJumpOnMatchedCommand = isJumpOnMatchedCommand;
|
|
25
|
+
const isPushOnMatchedCommand = (command) => (0, exports.isWithPush)(command) && (0, exports.isWithOnMatching)(command);
|
|
26
|
+
exports.isPushOnMatchedCommand = isPushOnMatchedCommand;
|
|
@@ -35,6 +35,8 @@ export interface GeneralEvent extends BaseEvent {
|
|
|
35
35
|
name: string;
|
|
36
36
|
}
|
|
37
37
|
export type AnyEvent = IntentEvent | GeneralEvent | EventEvent;
|
|
38
|
+
export declare const isBaseEvent: (event: unknown) => event is BaseEvent;
|
|
38
39
|
export declare const isIntentEvent: (event: BaseEvent) => event is IntentEvent;
|
|
40
|
+
export declare const isEventEvent: (event: BaseEvent) => event is EventEvent;
|
|
39
41
|
export declare const isGeneralEvent: (event: GeneralEvent) => event is GeneralEvent;
|
|
40
42
|
//# sourceMappingURL=event.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../../../../src/node/utils/event.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAElD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAG/C,oBAAY,SAAS;IACnB,MAAM,WAAW;IACjB,KAAK,UAAU;IACf,KAAK,UAAU;CAChB;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,MAAM,MAAM,KAAK,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,EAAE,CAAC,GAAG,OAAO,IAAI;IAAE,IAAI,EAAE,CAAC,CAAA;CAAE,GAAG,CAAC,CAAC;AAE5E,MAAM,WAAW,WAAY,SAAQ,SAAS,EAAE,YAAY;IAC1D,IAAI,EAAE,SAAS,CAAC,MAAM,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,UAAW,SAAQ,SAAS;IAC3C,IAAI,EAAE,SAAS,CAAC,KAAK,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,UAAW,SAAQ,SAAS;IAC3C,IAAI,EAAE,SAAS,CAAC,KAAK,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IAC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EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC1D;AAED,MAAM,WAAW,YAAa,SAAQ,SAAS;IAC7C,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,MAAM,QAAQ,GAAG,WAAW,GAAG,YAAY,GAAG,UAAU,CAAC;AAI/D,eAAO,MAAM,WAAW,UAAW,OAAO,uBACwD,CAAC;AAEnG,eAAO,MAAM,aAAa,UAAW,SAAS,yBAA0D,CAAC;AAEzG,eAAO,MAAM,YAAY,UAAW,SAAS,wBAAwD,CAAC;AAEtG,eAAO,MAAM,cAAc,UAAW,YAAY,0BAAkE,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isGeneralEvent = exports.isIntentEvent = exports.EventType = void 0;
|
|
3
|
+
exports.isGeneralEvent = exports.isEventEvent = exports.isIntentEvent = exports.isBaseEvent = exports.EventType = void 0;
|
|
4
4
|
// BUILT IN EVENTS
|
|
5
5
|
var EventType;
|
|
6
6
|
(function (EventType) {
|
|
@@ -8,8 +8,12 @@ var EventType;
|
|
|
8
8
|
EventType["EVENT"] = "event";
|
|
9
9
|
EventType["ALEXA"] = "alexa";
|
|
10
10
|
})(EventType || (exports.EventType = EventType = {}));
|
|
11
|
+
const ALL_EVENTS_TYPES = Object.values(EventType);
|
|
12
|
+
const isBaseEvent = (event) => typeof event === 'object' && event !== null && 'type' in event && typeof event.type === 'string';
|
|
13
|
+
exports.isBaseEvent = isBaseEvent;
|
|
11
14
|
const isIntentEvent = (event) => event.type === EventType.INTENT;
|
|
12
15
|
exports.isIntentEvent = isIntentEvent;
|
|
13
|
-
const
|
|
16
|
+
const isEventEvent = (event) => event.type === EventType.EVENT;
|
|
17
|
+
exports.isEventEvent = isEventEvent;
|
|
14
18
|
const isGeneralEvent = (event) => !ALL_EVENTS_TYPES.includes(event.type);
|
|
15
19
|
exports.isGeneralEvent = isGeneralEvent;
|
|
@@ -1,24 +1,47 @@
|
|
|
1
1
|
import type { Nullable } from '@voiceflow/common';
|
|
2
2
|
import type { BaseCommand } from './base.js';
|
|
3
|
-
import type
|
|
3
|
+
import { type BaseEvent } from './event.js';
|
|
4
4
|
export declare enum CommandType {
|
|
5
5
|
JUMP = "jump",
|
|
6
6
|
PUSH = "push"
|
|
7
7
|
}
|
|
8
|
-
export interface TypedBaseCommand
|
|
8
|
+
export interface TypedBaseCommand extends BaseCommand {
|
|
9
9
|
type: CommandType;
|
|
10
|
+
}
|
|
11
|
+
export interface WithEventMatching<Event extends BaseEvent = BaseEvent> {
|
|
10
12
|
event: Event;
|
|
11
13
|
}
|
|
12
|
-
export interface
|
|
14
|
+
export interface WithSiftOnMatching {
|
|
15
|
+
on: Record<string, unknown>;
|
|
16
|
+
}
|
|
17
|
+
export interface WithJump extends TypedBaseCommand {
|
|
13
18
|
type: CommandType.JUMP;
|
|
14
19
|
nextID: Nullable<string>;
|
|
15
20
|
diagramID?: Nullable<string>;
|
|
16
21
|
platform?: string;
|
|
17
22
|
}
|
|
18
|
-
export interface
|
|
23
|
+
export interface WithPush extends TypedBaseCommand {
|
|
19
24
|
type: CommandType.PUSH;
|
|
20
25
|
diagramID: Nullable<string>;
|
|
21
26
|
platform?: string;
|
|
22
27
|
}
|
|
23
|
-
export
|
|
28
|
+
export interface JumpEventMatchedCommand<Event extends BaseEvent = BaseEvent> extends WithJump, WithEventMatching<Event> {
|
|
29
|
+
}
|
|
30
|
+
export interface PushEventMatchedCommand<Event extends BaseEvent = BaseEvent> extends WithPush, WithEventMatching<Event> {
|
|
31
|
+
}
|
|
32
|
+
export interface JumpOnMatchedCommand extends WithJump, WithSiftOnMatching {
|
|
33
|
+
}
|
|
34
|
+
export interface PushOnMatchedCommand extends WithPush, WithSiftOnMatching {
|
|
35
|
+
}
|
|
36
|
+
export type EventMatchedCommand<Event extends BaseEvent = BaseEvent> = JumpEventMatchedCommand<Event> | PushEventMatchedCommand<Event>;
|
|
37
|
+
export type OnMatchedCommand = JumpOnMatchedCommand | PushOnMatchedCommand;
|
|
38
|
+
export type AnyCommand<Event extends BaseEvent = BaseEvent> = EventMatchedCommand<Event> | OnMatchedCommand;
|
|
39
|
+
export declare const isWithJump: (command: BaseCommand) => command is WithJump;
|
|
40
|
+
export declare const isWithPush: (command: BaseCommand) => command is WithPush;
|
|
41
|
+
export declare const isWithEventMatching: <TEvent extends BaseEvent = BaseEvent>(command: BaseCommand) => command is EventMatchedCommand<TEvent>;
|
|
42
|
+
export declare const isWithOnMatching: (command: BaseCommand) => command is OnMatchedCommand;
|
|
43
|
+
export declare const isJumpEventMatchedCommand: <Event extends BaseEvent = BaseEvent>(command: BaseCommand) => command is JumpEventMatchedCommand<Event>;
|
|
44
|
+
export declare const isPushEventMatchedCommand: <Event extends BaseEvent = BaseEvent>(command: BaseCommand) => command is JumpEventMatchedCommand<Event>;
|
|
45
|
+
export declare const isJumpOnMatchedCommand: <Event extends BaseEvent = BaseEvent>(command: BaseCommand) => command is JumpEventMatchedCommand<Event>;
|
|
46
|
+
export declare const isPushOnMatchedCommand: <Event extends BaseEvent = BaseEvent>(command: BaseCommand) => command is JumpEventMatchedCommand<Event>;
|
|
24
47
|
//# sourceMappingURL=command.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../../../src/node/utils/command.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAElD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAC1C,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../../../src/node/utils/command.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAElD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,QAAQ,CA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B,CAAC,KAAK,CAAC,GAC9B,uBAAuB,CAAC,KAAK,CAAC,CAAC;AAEnC,MAAM,MAAM,gBAAgB,GAAG,oBAAoB,GAAG,oBAAoB,CAAC;AAE3E,MAAM,MAAM,UAAU,CAAC,KAAK,SAAS,SAAS,GAAG,SAAS,IAAI,mBAAmB,CAAC,KAAK,CAAC,GAAG,gBAAgB,CAAC;AAE5G,eAAO,MAAM,UAAU,YAAa,WAAW,wBAA2D,CAAC;AAE3G,eAAO,MAAM,UAAU,YAAa,WAAW,wBAA2D,CAAC;AAE3G,eAAO,MAAM,mBAAmB,kDACrB,WAAW,2CACuE,CAAC;AAE9F,eAAO,MAAM,gBAAgB,YAAa,WAAW,gCACqB,CAAC;AAE3E,eAAO,MAAM,yBAAyB,iDAC3B,WAAW,8CAC6E,CAAC;AAEpG,eAAO,MAAM,yBAAyB,iDAC3B,WAAW,8CAC6E,CAAC;AAEpG,eAAO,MAAM,sBAAsB,iDACxB,WAAW,8CAC0E,CAAC;AAEjG,eAAO,MAAM,sBAAsB,iDACxB,WAAW,8CAC0E,CAAC"}
|
|
@@ -1,6 +1,15 @@
|
|
|
1
|
+
import { isBaseEvent } from './event.js';
|
|
1
2
|
// BUILT IN COMMANDS
|
|
2
3
|
export var CommandType;
|
|
3
4
|
(function (CommandType) {
|
|
4
5
|
CommandType["JUMP"] = "jump";
|
|
5
6
|
CommandType["PUSH"] = "push";
|
|
6
7
|
})(CommandType || (CommandType = {}));
|
|
8
|
+
export const isWithJump = (command) => command.type === CommandType.JUMP;
|
|
9
|
+
export const isWithPush = (command) => command.type === CommandType.PUSH;
|
|
10
|
+
export const isWithEventMatching = (command) => 'event' in command && isBaseEvent(command.event);
|
|
11
|
+
export const isWithOnMatching = (command) => 'on' in command && typeof command.on === 'object' && command.on !== null;
|
|
12
|
+
export const isJumpEventMatchedCommand = (command) => isWithJump(command) && isWithEventMatching(command);
|
|
13
|
+
export const isPushEventMatchedCommand = (command) => isWithPush(command) && isWithEventMatching(command);
|
|
14
|
+
export const isJumpOnMatchedCommand = (command) => isWithJump(command) && isWithOnMatching(command);
|
|
15
|
+
export const isPushOnMatchedCommand = (command) => isWithPush(command) && isWithOnMatching(command);
|
|
@@ -35,6 +35,8 @@ export interface GeneralEvent extends BaseEvent {
|
|
|
35
35
|
name: string;
|
|
36
36
|
}
|
|
37
37
|
export type AnyEvent = IntentEvent | GeneralEvent | EventEvent;
|
|
38
|
+
export declare const isBaseEvent: (event: unknown) => event is BaseEvent;
|
|
38
39
|
export declare const isIntentEvent: (event: BaseEvent) => event is IntentEvent;
|
|
40
|
+
export declare const isEventEvent: (event: BaseEvent) => event is EventEvent;
|
|
39
41
|
export declare const isGeneralEvent: (event: GeneralEvent) => event is GeneralEvent;
|
|
40
42
|
//# sourceMappingURL=event.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../../../../src/node/utils/event.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAElD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAG/C,oBAAY,SAAS;IACnB,MAAM,WAAW;IACjB,KAAK,UAAU;IACf,KAAK,UAAU;CAChB;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,MAAM,MAAM,KAAK,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,EAAE,CAAC,GAAG,OAAO,IAAI;IAAE,IAAI,EAAE,CAAC,CAAA;CAAE,GAAG,CAAC,CAAC;AAE5E,MAAM,WAAW,WAAY,SAAQ,SAAS,EAAE,YAAY;IAC1D,IAAI,EAAE,SAAS,CAAC,MAAM,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,UAAW,SAAQ,SAAS;IAC3C,IAAI,EAAE,SAAS,CAAC,KAAK,CAAC;IACtB,KAAK,EAAE,MAA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AC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,KAAK,CAAC;QAAE,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC1D;AAED,MAAM,WAAW,YAAa,SAAQ,SAAS;IAC7C,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,MAAM,QAAQ,GAAG,WAAW,GAAG,YAAY,GAAG,UAAU,CAAC;AAI/D,eAAO,MAAM,WAAW,UAAW,OAAO,uBACwD,CAAC;AAEnG,eAAO,MAAM,aAAa,UAAW,SAAS,yBAA0D,CAAC;AAEzG,eAAO,MAAM,YAAY,UAAW,SAAS,wBAAwD,CAAC;AAEtG,eAAO,MAAM,cAAc,UAAW,YAAY,0BAAkE,CAAC"}
|
|
@@ -5,6 +5,8 @@ export var EventType;
|
|
|
5
5
|
EventType["EVENT"] = "event";
|
|
6
6
|
EventType["ALEXA"] = "alexa";
|
|
7
7
|
})(EventType || (EventType = {}));
|
|
8
|
-
export const isIntentEvent = (event) => event.type === EventType.INTENT;
|
|
9
8
|
const ALL_EVENTS_TYPES = Object.values(EventType);
|
|
9
|
+
export const isBaseEvent = (event) => typeof event === 'object' && event !== null && 'type' in event && typeof event.type === 'string';
|
|
10
|
+
export const isIntentEvent = (event) => event.type === EventType.INTENT;
|
|
11
|
+
export const isEventEvent = (event) => event.type === EventType.EVENT;
|
|
10
12
|
export const isGeneralEvent = (event) => !ALL_EVENTS_TYPES.includes(event.type);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voiceflow/base-types",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.121.0",
|
|
4
4
|
"description": "Voiceflow base project types",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"voiceflow",
|
|
@@ -32,10 +32,11 @@
|
|
|
32
32
|
"lint:eslint": "yarn g:eslint",
|
|
33
33
|
"lint:fix": "yarn g:run-p -c \"lint:eslint --fix\" \"lint:prettier --write\"",
|
|
34
34
|
"lint:prettier": "yarn g:prettier --check",
|
|
35
|
-
"
|
|
35
|
+
"tdd": "yarn g:vitest",
|
|
36
|
+
"test": "yarn g:run-p -c test:dependencies test:types test:unit",
|
|
36
37
|
"test:dependencies": "yarn g:depcruise",
|
|
37
38
|
"test:types": "yarn g:tsc --noEmit",
|
|
38
|
-
"test:unit": ""
|
|
39
|
+
"test:unit": "yarn g:vitest run --coverage"
|
|
39
40
|
},
|
|
40
41
|
"dependencies": {
|
|
41
42
|
"@voiceflow/common": "8.3.1",
|
|
@@ -47,5 +48,5 @@
|
|
|
47
48
|
"publishConfig": {
|
|
48
49
|
"access": "public"
|
|
49
50
|
},
|
|
50
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "d1b27e5fd4bfd0c94e47920fdee2d080da9061b6"
|
|
51
52
|
}
|