@botpress/cli 3.6.5 → 4.0.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.
@@ -1,32 +1,32 @@
1
1
 
2
- > @botpress/cli@3.6.5 build /home/runner/work/botpress/botpress/packages/cli
2
+ > @botpress/cli@4.0.1 build /home/runner/work/botpress/botpress/packages/cli
3
3
  > pnpm run bundle && pnpm run template:gen
4
4
 
5
5
 
6
- > @botpress/cli@3.6.5 bundle /home/runner/work/botpress/botpress/packages/cli
6
+ > @botpress/cli@4.0.1 bundle /home/runner/work/botpress/botpress/packages/cli
7
7
  > ts-node -T build.ts
8
8
 
9
9
 
10
- > @botpress/cli@3.6.5 template:gen /home/runner/work/botpress/botpress/packages/cli
10
+ > @botpress/cli@4.0.1 template:gen /home/runner/work/botpress/botpress/packages/cli
11
11
  > pnpm -r --stream -F @bp-templates/* exec bp gen
12
12
 
13
- 🤖 Botpress CLI v3.6.5
14
- 🤖 Botpress CLI v3.6.5
15
- 🤖 Botpress CLI v3.6.5
16
- 🤖 Botpress CLI v3.6.5
17
- ○ Generating typings for integration hello-world...
13
+ 🤖 Botpress CLI v4.0.1
14
+ 🤖 Botpress CLI v4.0.1
15
+ 🤖 Botpress CLI v4.0.1
16
+ 🤖 Botpress CLI v4.0.1
18
17
  ○ Generating typings for bot...
18
+ ○ Generating typings for integration hello-world...
19
19
  ✓ Typings available at .botpress
20
20
 
21
+ ○ Generating typings for plugin empty-plugin...
21
22
  ✓ Typings available at .botpress
22
23
 
23
- ○ Generating typings for plugin empty-plugin...
24
24
  ○ Generating typings for integration empty-integration...
25
25
  ✓ Typings available at .botpress
26
26
 
27
27
  ✓ Typings available at .botpress
28
28
 
29
- 🤖 Botpress CLI v3.6.5
29
+ 🤖 Botpress CLI v4.0.1
30
30
  ○ Generating typings for integration webhook-message...
31
31
  ✓ Typings available at .botpress
32
32
 
@@ -45,7 +45,7 @@ class BotIntegrationsModule extends import_module.ReExportTypeModule {
45
45
  exportName: "Integrations"
46
46
  });
47
47
  for (const [alias, integration] of Object.entries(bot.integrations ?? {})) {
48
- const integrationModule = new import_integration_typings.IntegrationTypingsModule(integration.definition);
48
+ const integrationModule = new import_integration_typings.IntegrationTypingsModule(integration.definition).setCustomTypeName(alias);
49
49
  integrationModule.unshift(alias);
50
50
  this.pushDep(integrationModule);
51
51
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/code-generation/bot-implementation/bot-typings/index.ts"],
4
- "sourcesContent": ["import * as sdk from '@botpress/sdk'\nimport * as consts from '../../consts'\nimport { IntegrationTypingsModule } from '../../integration-implementation/integration-typings'\nimport { Module, ReExportTypeModule } from '../../module'\nimport { ActionsModule } from './actions-module'\nimport { EventsModule } from './events-module'\nimport { StatesModule } from './states-module'\nimport { TablesModule } from './tables-module'\nimport { WorkflowsModule } from './workflows-module'\n\nclass BotIntegrationsModule extends ReExportTypeModule {\n public constructor(bot: sdk.BotDefinition) {\n super({\n exportName: 'Integrations',\n })\n\n for (const [alias, integration] of Object.entries(bot.integrations ?? {})) {\n const integrationModule = new IntegrationTypingsModule(integration.definition)\n integrationModule.unshift(alias)\n this.pushDep(integrationModule)\n }\n }\n}\n\ntype BotTypingsIndexDependencies = {\n integrationsModule: BotIntegrationsModule\n eventsModule: EventsModule\n statesModule: StatesModule\n actionsModule: ActionsModule\n tablesModule: TablesModule\n workflowsModule: WorkflowsModule\n}\n\nexport class BotTypingsModule extends Module {\n private _dependencies: BotTypingsIndexDependencies\n\n public constructor(bot: sdk.BotDefinition) {\n super({\n exportName: 'TBot',\n path: consts.INDEX_FILE,\n })\n\n const integrationsModule = new BotIntegrationsModule(bot)\n integrationsModule.unshift('integrations')\n this.pushDep(integrationsModule)\n\n const eventsModule = new EventsModule(bot.events ?? {})\n eventsModule.unshift('events')\n this.pushDep(eventsModule)\n\n const statesModule = new StatesModule(bot.states ?? {})\n statesModule.unshift('states')\n this.pushDep(statesModule)\n\n const tablesModule = new TablesModule(bot.tables ?? {})\n tablesModule.unshift('tables')\n this.pushDep(tablesModule)\n\n const actionsModule = new ActionsModule(bot.actions ?? {})\n actionsModule.unshift('actions')\n this.pushDep(actionsModule)\n\n const workflowsModule = new WorkflowsModule(bot.workflows ?? {})\n workflowsModule.unshift('workflows')\n this.pushDep(workflowsModule)\n\n this._dependencies = {\n integrationsModule,\n eventsModule,\n statesModule,\n actionsModule,\n tablesModule,\n workflowsModule,\n }\n }\n\n public async getContent() {\n const { integrationsModule, eventsModule, statesModule, actionsModule, tablesModule, workflowsModule } =\n this._dependencies\n\n const integrationsImport = integrationsModule.import(this)\n const eventsImport = eventsModule.import(this)\n const statesImport = statesModule.import(this)\n const actionsImport = actionsModule\n const tablesImport = tablesModule.import(this)\n const workflowsImport = workflowsModule\n\n return [\n consts.GENERATED_HEADER,\n `import * as ${integrationsModule.name} from './${integrationsImport}'`,\n `import * as ${eventsModule.name} from './${eventsModule.name}'`,\n `import * as ${statesModule.name} from './${statesModule.name}'`,\n `import * as ${actionsModule.name} from './${actionsImport.name}'`,\n `import * as ${tablesModule.name} from './${tablesImport}'`,\n `import * as ${workflowsModule.name} from './${workflowsImport.name}'`,\n '',\n `export * as ${integrationsModule.name} from './${integrationsImport}'`,\n `export * as ${eventsModule.name} from './${eventsImport}'`,\n `export * as ${statesModule.name} from './${statesImport}'`,\n `export * as ${actionsModule.name} from './${actionsImport.name}'`,\n `export * as ${tablesModule.name} from './${tablesImport}'`,\n `export * as ${workflowsModule.name} from './${workflowsImport.name}'`,\n '',\n 'export type TBot = {',\n ` integrations: ${integrationsModule.name}.${integrationsModule.exportName}`,\n ` events: ${eventsModule.name}.${eventsModule.exportName}`,\n ` states: ${statesModule.name}.${statesModule.exportName}`,\n ` actions: ${actionsModule.name}.${actionsModule.exportName}`,\n ` tables: ${tablesModule.name}.${tablesModule.exportName}`,\n ` workflows: ${workflowsModule.name}.${workflowsModule.exportName}`,\n '}',\n ].join('\\n')\n }\n}\n"],
5
- "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F,EAAE,KAAK,IAAI;AAAA,EACb;AACF;",
4
+ "sourcesContent": ["import * as sdk from '@botpress/sdk'\nimport * as consts from '../../consts'\nimport { IntegrationTypingsModule } from '../../integration-implementation/integration-typings'\nimport { Module, ReExportTypeModule } from '../../module'\nimport { ActionsModule } from './actions-module'\nimport { EventsModule } from './events-module'\nimport { StatesModule } from './states-module'\nimport { TablesModule } from './tables-module'\nimport { WorkflowsModule } from './workflows-module'\n\nclass BotIntegrationsModule extends ReExportTypeModule {\n public constructor(bot: sdk.BotDefinition) {\n super({\n exportName: 'Integrations',\n })\n\n for (const [alias, integration] of Object.entries(bot.integrations ?? {})) {\n const integrationModule = new IntegrationTypingsModule(integration.definition).setCustomTypeName(alias)\n integrationModule.unshift(alias)\n this.pushDep(integrationModule)\n }\n }\n}\n\ntype BotTypingsIndexDependencies = {\n integrationsModule: BotIntegrationsModule\n eventsModule: EventsModule\n statesModule: StatesModule\n actionsModule: ActionsModule\n tablesModule: TablesModule\n workflowsModule: WorkflowsModule\n}\n\nexport class BotTypingsModule extends Module {\n private _dependencies: BotTypingsIndexDependencies\n\n public constructor(bot: sdk.BotDefinition) {\n super({\n exportName: 'TBot',\n path: consts.INDEX_FILE,\n })\n\n const integrationsModule = new BotIntegrationsModule(bot)\n integrationsModule.unshift('integrations')\n this.pushDep(integrationsModule)\n\n const eventsModule = new EventsModule(bot.events ?? {})\n eventsModule.unshift('events')\n this.pushDep(eventsModule)\n\n const statesModule = new StatesModule(bot.states ?? {})\n statesModule.unshift('states')\n this.pushDep(statesModule)\n\n const tablesModule = new TablesModule(bot.tables ?? {})\n tablesModule.unshift('tables')\n this.pushDep(tablesModule)\n\n const actionsModule = new ActionsModule(bot.actions ?? {})\n actionsModule.unshift('actions')\n this.pushDep(actionsModule)\n\n const workflowsModule = new WorkflowsModule(bot.workflows ?? {})\n workflowsModule.unshift('workflows')\n this.pushDep(workflowsModule)\n\n this._dependencies = {\n integrationsModule,\n eventsModule,\n statesModule,\n actionsModule,\n tablesModule,\n workflowsModule,\n }\n }\n\n public async getContent() {\n const { integrationsModule, eventsModule, statesModule, actionsModule, tablesModule, workflowsModule } =\n this._dependencies\n\n const integrationsImport = integrationsModule.import(this)\n const eventsImport = eventsModule.import(this)\n const statesImport = statesModule.import(this)\n const actionsImport = actionsModule\n const tablesImport = tablesModule.import(this)\n const workflowsImport = workflowsModule\n\n return [\n consts.GENERATED_HEADER,\n `import * as ${integrationsModule.name} from './${integrationsImport}'`,\n `import * as ${eventsModule.name} from './${eventsModule.name}'`,\n `import * as ${statesModule.name} from './${statesModule.name}'`,\n `import * as ${actionsModule.name} from './${actionsImport.name}'`,\n `import * as ${tablesModule.name} from './${tablesImport}'`,\n `import * as ${workflowsModule.name} from './${workflowsImport.name}'`,\n '',\n `export * as ${integrationsModule.name} from './${integrationsImport}'`,\n `export * as ${eventsModule.name} from './${eventsImport}'`,\n `export * as ${statesModule.name} from './${statesImport}'`,\n `export * as ${actionsModule.name} from './${actionsImport.name}'`,\n `export * as ${tablesModule.name} from './${tablesImport}'`,\n `export * as ${workflowsModule.name} from './${workflowsImport.name}'`,\n '',\n 'export type TBot = {',\n ` integrations: ${integrationsModule.name}.${integrationsModule.exportName}`,\n ` events: ${eventsModule.name}.${eventsModule.exportName}`,\n ` states: ${statesModule.name}.${statesModule.exportName}`,\n ` actions: ${actionsModule.name}.${actionsModule.exportName}`,\n ` tables: ${tablesModule.name}.${tablesModule.exportName}`,\n ` workflows: ${workflowsModule.name}.${workflowsModule.exportName}`,\n '}',\n ].join('\\n')\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,aAAwB;AACxB,iCAAyC;AACzC,oBAA2C;AAC3C,4BAA8B;AAC9B,2BAA6B;AAC7B,2BAA6B;AAC7B,2BAA6B;AAC7B,8BAAgC;AAEhC,MAAM,8BAA8B,iCAAmB;AAAA,EAC9C,YAAY,KAAwB;AACzC,UAAM;AAAA,MACJ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AAgB,IACnG,KAAK;AAEP,UAAM,qBAAqB,mBAAmB,OAAO,IAAI;AACzD,UAAM,eAAe,aAAa,OAAO,IAAI;AAC7C,UAAM,eAAe,aAAa,OAAO,IAAI;AAC7C,UAAM,gBAAgB;AACtB,UAAM,eAAe,aAAa,OAAO,IAAI;AAC7C,UAAM,kBAAkB;AAExB,WAAO;AAAA,MACL,OAAO;AAAA,MACP,eAAe,mBAAmB,gBAAgB;AAAA,MAClD,eAAe,aAAa,gBAAgB,aAAa;AAAA,MACzD,eAAe,aAAa,gBAAgB,aAAa;AAAA,MACzD,eAAe,cAAc,gBAAgB,cAAc;AAAA,MAC3D,eAAe,aAAa,gBAAgB;AAAA,MAC5C,eAAe,gBAAgB,gBAAgB,gBAAgB;AAAA,MAC/D;AAAA,MACA,eAAe,mBAAmB,gBAAgB;AAAA,MAClD,eAAe,aAAa,gBAAgB;AAAA,MAC5C,eAAe,aAAa,gBAAgB;AAAA,MAC5C,eAAe,cAAc,gBAAgB,cAAc;AAAA,MAC3D,eAAe,aAAa,gBAAgB;AAAA,MAC5C,eAAe,gBAAgB,gBAAgB,gBAAgB;AAAA,MAC/D;AAAA,MACA;AAAA,MACA,mBAAmB,mBAAmB,QAAQ,mBAAmB;AAAA,MACjE,aAAa,aAAa,QAAQ,aAAa;AAAA,MAC/C,aAAa,aAAa,QAAQ,aAAa;AAAA,MAC/C,cAAc,cAAc,QAAQ,cAAc;AAAA,MAClD,aAAa,aAAa,QAAQ,aAAa;AAAA,MAC/C,gBAAgB,gBAAgB,QAAQ,gBAAgB;AAAA,MACxD;AAAA,IACF,EAAE,KAAK,IAAI;AAAA,EACb;AACF;",
6
6
  "names": []
7
7
  }
@@ -29,22 +29,50 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
29
29
  var states_module_exports = {};
30
30
  __export(states_module_exports, {
31
31
  StateModule: () => StateModule,
32
+ StatePayloadModule: () => StatePayloadModule,
32
33
  StatesModule: () => StatesModule
33
34
  });
34
35
  module.exports = __toCommonJS(states_module_exports);
35
- var import_generators = require("../../generators");
36
+ var consts = __toESM(require("../../consts"));
37
+ var gen = __toESM(require("../../generators"));
36
38
  var import_module = require("../../module");
37
39
  var strings = __toESM(require("../../strings"));
40
+ class StatePayloadModule extends import_module.Module {
41
+ constructor(_state) {
42
+ super({
43
+ path: "payload.ts",
44
+ exportName: strings.typeName("Payload")
45
+ });
46
+ this._state = _state;
47
+ }
48
+ async getContent() {
49
+ return gen.zuiSchemaToTypeScriptType(this._state.schema, "Payload");
50
+ }
51
+ }
38
52
  class StateModule extends import_module.Module {
39
- constructor(name, _state) {
53
+ constructor(_name, _state) {
40
54
  super({
41
- path: `${name}.ts`,
42
- exportName: strings.typeName(name)
55
+ path: consts.INDEX_FILE,
56
+ exportName: strings.typeName(_name)
43
57
  });
58
+ this._name = _name;
44
59
  this._state = _state;
60
+ this._payloadModule = new StatePayloadModule(_state);
61
+ this.pushDep(this._payloadModule);
45
62
  }
63
+ _payloadModule;
46
64
  async getContent() {
47
- return (0, import_generators.zuiSchemaToTypeScriptType)(this._state.schema, this.exportName);
65
+ const { _payloadModule } = this;
66
+ const payloadImport = _payloadModule.import(this);
67
+ const exportName = strings.typeName(this._name);
68
+ return [
69
+ consts.GENERATED_HEADER,
70
+ `import * as ${_payloadModule.name} from './${payloadImport}'`,
71
+ `export type ${exportName} = {`,
72
+ ` type: ${gen.primitiveToTypescriptValue(this._state.type)},`,
73
+ ` payload: ${_payloadModule.name}.${_payloadModule.exportName}`,
74
+ "}"
75
+ ].join("\n");
48
76
  }
49
77
  }
50
78
  class StatesModule extends import_module.ReExportTypeModule {
@@ -52,6 +80,7 @@ class StatesModule extends import_module.ReExportTypeModule {
52
80
  super({ exportName: strings.typeName("states") });
53
81
  for (const [stateName, state] of Object.entries(states)) {
54
82
  const module2 = new StateModule(stateName, state);
83
+ module2.unshift(stateName);
55
84
  this.pushDep(module2);
56
85
  }
57
86
  }
@@ -59,6 +88,7 @@ class StatesModule extends import_module.ReExportTypeModule {
59
88
  // Annotate the CommonJS export names for ESM import in node:
60
89
  0 && (module.exports = {
61
90
  StateModule,
91
+ StatePayloadModule,
62
92
  StatesModule
63
93
  });
64
94
  //# sourceMappingURL=states-module.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/code-generation/bot-implementation/bot-typings/states-module.ts"],
4
- "sourcesContent": ["import * as sdk from '@botpress/sdk'\nimport { zuiSchemaToTypeScriptType } from '../../generators'\nimport { Module, ReExportTypeModule } from '../../module'\nimport * as strings from '../../strings'\n\nexport class StateModule extends Module {\n public constructor(\n name: string,\n private _state: sdk.BotStateDefinition\n ) {\n super({\n path: `${name}.ts`,\n exportName: strings.typeName(name),\n })\n }\n\n public async getContent() {\n return zuiSchemaToTypeScriptType(this._state.schema, this.exportName)\n }\n}\n\nexport class StatesModule extends ReExportTypeModule {\n public constructor(states: Record<string, sdk.BotStateDefinition>) {\n super({ exportName: strings.typeName('states') })\n for (const [stateName, state] of Object.entries(states)) {\n const module = new StateModule(stateName, state)\n this.pushDep(module)\n }\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,wBAA0C;AAC1C,oBAA2C;AAC3C,cAAyB;AAElB,MAAM,oBAAoB,qBAAO;AAAA,EAC/B,YACL,MACQ,QACR;AACA,UAAM;AAAA,MACJ,MAAM,GAAG;AAAA,MACT,YAAY,QAAQ,SAAS,IAAI;AAAA,IACnC,CAAC;AALO;AAAA,EAMV;AAAA,EAEA,MAAa,aAAa;AACxB,eAAO,6CAA0B,KAAK,OAAO,QAAQ,KAAK,UAAU;AAAA,EACtE;AACF;AAEO,MAAM,qBAAqB,iCAAmB;AAAA,EAC5C,YAAY,QAAgD;AACjE,UAAM,EAAE,YAAY,QAAQ,SAAS,QAAQ,EAAE,CAAC;AAChD,eAAW,CAAC,WAAW,KAAK,KAAK,OAAO,QAAQ,MAAM,GAAG;AACvD,YAAMA,UAAS,IAAI,YAAY,WAAW,KAAK;AAC/C,WAAK,QAAQA,OAAM;AAAA,IACrB;AAAA,EACF;AACF;",
4
+ "sourcesContent": ["import * as sdk from '@botpress/sdk'\nimport * as consts from '../../consts'\nimport * as gen from '../../generators'\nimport { Module, ReExportTypeModule } from '../../module'\nimport * as strings from '../../strings'\n\nexport class StatePayloadModule extends Module {\n public constructor(private _state: sdk.BotStateDefinition) {\n super({\n path: 'payload.ts',\n exportName: strings.typeName('Payload'),\n })\n }\n\n public async getContent() {\n return gen.zuiSchemaToTypeScriptType(this._state.schema, 'Payload')\n }\n}\n\nexport class StateModule extends Module {\n private _payloadModule: StatePayloadModule\n\n public constructor(\n private _name: string,\n private _state: sdk.BotStateDefinition\n ) {\n super({\n path: consts.INDEX_FILE,\n exportName: strings.typeName(_name),\n })\n\n this._payloadModule = new StatePayloadModule(_state)\n this.pushDep(this._payloadModule)\n }\n\n public async getContent(): Promise<string> {\n const { _payloadModule } = this\n const payloadImport = _payloadModule.import(this)\n\n const exportName = strings.typeName(this._name)\n\n return [\n consts.GENERATED_HEADER,\n `import * as ${_payloadModule.name} from './${payloadImport}'`,\n `export type ${exportName} = {`,\n ` type: ${gen.primitiveToTypescriptValue(this._state.type)},`,\n ` payload: ${_payloadModule.name}.${_payloadModule.exportName}`,\n '}',\n ].join('\\n')\n }\n}\n\nexport class StatesModule extends ReExportTypeModule {\n public constructor(states: Record<string, sdk.BotStateDefinition>) {\n super({ exportName: strings.typeName('states') })\n for (const [stateName, state] of Object.entries(states)) {\n const module = new StateModule(stateName, state)\n module.unshift(stateName)\n this.pushDep(module)\n }\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,aAAwB;AACxB,UAAqB;AACrB,oBAA2C;AAC3C,cAAyB;AAElB,MAAM,2BAA2B,qBAAO;AAAA,EACtC,YAAoB,QAAgC;AACzD,UAAM;AAAA,MACJ,MAAM;AAAA,MACN,YAAY,QAAQ,SAAS,SAAS;AAAA,IACxC,CAAC;AAJwB;AAAA,EAK3B;AAAA,EAEA,MAAa,aAAa;AACxB,WAAO,IAAI,0BAA0B,KAAK,OAAO,QAAQ,SAAS;AAAA,EACpE;AACF;AAEO,MAAM,oBAAoB,qBAAO;AAAA,EAG/B,YACG,OACA,QACR;AACA,UAAM;AAAA,MACJ,MAAM,OAAO;AAAA,MACb,YAAY,QAAQ,SAAS,KAAK;AAAA,IACpC,CAAC;AANO;AACA;AAOR,SAAK,iBAAiB,IAAI,mBAAmB,MAAM;AACnD,SAAK,QAAQ,KAAK,cAAc;AAAA,EAClC;AAAA,EAbQ;AAAA,EAeR,MAAa,aAA8B;AACzC,UAAM,EAAE,eAAe,IAAI;AAC3B,UAAM,gBAAgB,eAAe,OAAO,IAAI;AAEhD,UAAM,aAAa,QAAQ,SAAS,KAAK,KAAK;AAE9C,WAAO;AAAA,MACL,OAAO;AAAA,MACP,eAAe,eAAe,gBAAgB;AAAA,MAC9C,eAAe;AAAA,MACf,WAAW,IAAI,2BAA2B,KAAK,OAAO,IAAI;AAAA,MAC1D,cAAc,eAAe,QAAQ,eAAe;AAAA,MACpD;AAAA,IACF,EAAE,KAAK,IAAI;AAAA,EACb;AACF;AAEO,MAAM,qBAAqB,iCAAmB;AAAA,EAC5C,YAAY,QAAgD;AACjE,UAAM,EAAE,YAAY,QAAQ,SAAS,QAAQ,EAAE,CAAC;AAChD,eAAW,CAAC,WAAW,KAAK,KAAK,OAAO,QAAQ,MAAM,GAAG;AACvD,YAAMA,UAAS,IAAI,YAAY,WAAW,KAAK;AAC/C,MAAAA,QAAO,QAAQ,SAAS;AACxB,WAAK,QAAQA,OAAM;AAAA,IACrB;AAAA,EACF;AACF;",
6
6
  "names": ["module"]
7
7
  }
@@ -29,22 +29,50 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
29
29
  var states_module_exports = {};
30
30
  __export(states_module_exports, {
31
31
  StateModule: () => StateModule,
32
+ StatePayloadModule: () => StatePayloadModule,
32
33
  StatesModule: () => StatesModule
33
34
  });
34
35
  module.exports = __toCommonJS(states_module_exports);
35
- var import_generators = require("../../generators");
36
+ var consts = __toESM(require("../../consts"));
37
+ var gen = __toESM(require("../../generators"));
36
38
  var import_module = require("../../module");
37
39
  var strings = __toESM(require("../../strings"));
40
+ class StatePayloadModule extends import_module.Module {
41
+ constructor(_state) {
42
+ super({
43
+ path: "payload.ts",
44
+ exportName: strings.typeName("Payload")
45
+ });
46
+ this._state = _state;
47
+ }
48
+ async getContent() {
49
+ return gen.zuiSchemaToTypeScriptType(this._state.schema, "Payload");
50
+ }
51
+ }
38
52
  class StateModule extends import_module.Module {
39
- constructor(name, _state) {
53
+ constructor(_name, _state) {
40
54
  super({
41
- path: `${name}.ts`,
42
- exportName: strings.typeName(name)
55
+ path: consts.INDEX_FILE,
56
+ exportName: strings.typeName(_name)
43
57
  });
58
+ this._name = _name;
44
59
  this._state = _state;
60
+ this._payloadModule = new StatePayloadModule(_state);
61
+ this.pushDep(this._payloadModule);
45
62
  }
63
+ _payloadModule;
46
64
  async getContent() {
47
- return (0, import_generators.zuiSchemaToTypeScriptType)(this._state.schema, this.exportName);
65
+ const { _payloadModule } = this;
66
+ const payloadImport = _payloadModule.import(this);
67
+ const exportName = strings.typeName(this._name);
68
+ return [
69
+ consts.GENERATED_HEADER,
70
+ `import * as ${_payloadModule.name} from './${payloadImport}'`,
71
+ `export type ${exportName} = {`,
72
+ ` type: ${gen.primitiveToTypescriptValue(this._state.type)},`,
73
+ ` payload: ${_payloadModule.name}.${_payloadModule.exportName}`,
74
+ "}"
75
+ ].join("\n");
48
76
  }
49
77
  }
50
78
  class StatesModule extends import_module.ReExportTypeModule {
@@ -52,6 +80,7 @@ class StatesModule extends import_module.ReExportTypeModule {
52
80
  super({ exportName: strings.typeName("states") });
53
81
  for (const [stateName, state] of Object.entries(states)) {
54
82
  const module2 = new StateModule(stateName, state);
83
+ module2.unshift(stateName);
55
84
  this.pushDep(module2);
56
85
  }
57
86
  }
@@ -59,6 +88,7 @@ class StatesModule extends import_module.ReExportTypeModule {
59
88
  // Annotate the CommonJS export names for ESM import in node:
60
89
  0 && (module.exports = {
61
90
  StateModule,
91
+ StatePayloadModule,
62
92
  StatesModule
63
93
  });
64
94
  //# sourceMappingURL=states-module.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/code-generation/integration-implementation/integration-typings/states-module.ts"],
4
- "sourcesContent": ["import * as sdk from '@botpress/sdk'\nimport { zuiSchemaToTypeScriptType } from '../../generators'\nimport { Module, ReExportTypeModule } from '../../module'\nimport * as strings from '../../strings'\n\nexport class StateModule extends Module {\n public constructor(\n name: string,\n private _state: sdk.StateDefinition\n ) {\n super({\n path: `${name}.ts`,\n exportName: strings.typeName(name),\n })\n }\n\n public async getContent() {\n return zuiSchemaToTypeScriptType(this._state.schema, this.exportName)\n }\n}\n\nexport class StatesModule extends ReExportTypeModule {\n public constructor(states: Record<string, sdk.StateDefinition>) {\n super({ exportName: strings.typeName('states') })\n for (const [stateName, state] of Object.entries(states)) {\n const module = new StateModule(stateName, state)\n this.pushDep(module)\n }\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,wBAA0C;AAC1C,oBAA2C;AAC3C,cAAyB;AAElB,MAAM,oBAAoB,qBAAO;AAAA,EAC/B,YACL,MACQ,QACR;AACA,UAAM;AAAA,MACJ,MAAM,GAAG;AAAA,MACT,YAAY,QAAQ,SAAS,IAAI;AAAA,IACnC,CAAC;AALO;AAAA,EAMV;AAAA,EAEA,MAAa,aAAa;AACxB,eAAO,6CAA0B,KAAK,OAAO,QAAQ,KAAK,UAAU;AAAA,EACtE;AACF;AAEO,MAAM,qBAAqB,iCAAmB;AAAA,EAC5C,YAAY,QAA6C;AAC9D,UAAM,EAAE,YAAY,QAAQ,SAAS,QAAQ,EAAE,CAAC;AAChD,eAAW,CAAC,WAAW,KAAK,KAAK,OAAO,QAAQ,MAAM,GAAG;AACvD,YAAMA,UAAS,IAAI,YAAY,WAAW,KAAK;AAC/C,WAAK,QAAQA,OAAM;AAAA,IACrB;AAAA,EACF;AACF;",
4
+ "sourcesContent": ["import * as sdk from '@botpress/sdk'\nimport * as consts from '../../consts'\nimport * as gen from '../../generators'\nimport { Module, ReExportTypeModule } from '../../module'\nimport * as strings from '../../strings'\n\nexport class StatePayloadModule extends Module {\n public constructor(private _state: sdk.StateDefinition) {\n super({\n path: 'payload.ts',\n exportName: strings.typeName('Payload'),\n })\n }\n\n public async getContent() {\n return gen.zuiSchemaToTypeScriptType(this._state.schema, 'Payload')\n }\n}\n\nexport class StateModule extends Module {\n private _payloadModule: StatePayloadModule\n\n public constructor(\n private _name: string,\n private _state: sdk.StateDefinition\n ) {\n super({\n path: consts.INDEX_FILE,\n exportName: strings.typeName(_name),\n })\n\n this._payloadModule = new StatePayloadModule(_state)\n this.pushDep(this._payloadModule)\n }\n\n public async getContent(): Promise<string> {\n const { _payloadModule } = this\n const payloadImport = _payloadModule.import(this)\n\n const exportName = strings.typeName(this._name)\n\n return [\n consts.GENERATED_HEADER,\n `import * as ${_payloadModule.name} from './${payloadImport}'`,\n `export type ${exportName} = {`,\n ` type: ${gen.primitiveToTypescriptValue(this._state.type)},`,\n ` payload: ${_payloadModule.name}.${_payloadModule.exportName}`,\n '}',\n ].join('\\n')\n }\n}\n\nexport class StatesModule extends ReExportTypeModule {\n public constructor(states: Record<string, sdk.StateDefinition>) {\n super({ exportName: strings.typeName('states') })\n for (const [stateName, state] of Object.entries(states)) {\n const module = new StateModule(stateName, state)\n module.unshift(stateName)\n this.pushDep(module)\n }\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,aAAwB;AACxB,UA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
@@ -43,6 +43,7 @@ class Module {
43
43
  this._def = _def;
44
44
  }
45
45
  _localDependencies = [];
46
+ _customTypeName;
46
47
  get path() {
47
48
  return this._def.path.split(import_path.posix.sep).map(strings.fileName).join(import_path.posix.sep);
48
49
  }
@@ -69,6 +70,16 @@ class Module {
69
70
  get deps() {
70
71
  return [...this._localDependencies];
71
72
  }
73
+ get typeName() {
74
+ return this._customTypeName ?? this.name;
75
+ }
76
+ get importAlias() {
77
+ return this.typeName.split(import_path.posix.sep).map(strings.importAlias).join("__");
78
+ }
79
+ setCustomTypeName(alias) {
80
+ this._customTypeName = alias;
81
+ return this;
82
+ }
72
83
  pushDep(...dependencies) {
73
84
  this._localDependencies.push(...dependencies);
74
85
  return this;
@@ -112,8 +123,7 @@ class ReExportTypeModule extends Module {
112
123
  async getContent() {
113
124
  let content = consts.GENERATED_HEADER;
114
125
  for (const m of this.deps) {
115
- const { name } = m;
116
- const importAlias = strings.importAlias(name);
126
+ const { importAlias } = m;
117
127
  const importFrom = m.import(this);
118
128
  content += `import * as ${importAlias} from "./${importFrom}";
119
129
  `;
@@ -123,9 +133,8 @@ class ReExportTypeModule extends Module {
123
133
  content += "\n";
124
134
  content += `export type ${this.exportName} = {
125
135
  `;
126
- for (const { name, exportName: exports } of this.deps) {
127
- const importAlias = strings.importAlias(name);
128
- content += ` "${name}": ${importAlias}.${exports};
136
+ for (const { importAlias, typeName, exportName: exports } of this.deps) {
137
+ content += ` "${typeName}": ${importAlias}.${exports};
129
138
  `;
130
139
  }
131
140
  content += "}";
@@ -145,8 +154,7 @@ class ReExportVariableModule extends Module {
145
154
  async getContent() {
146
155
  let content = consts.GENERATED_HEADER;
147
156
  for (const m of this.deps) {
148
- const { name } = m;
149
- const importAlias = strings.importAlias(name);
157
+ const { importAlias } = m;
150
158
  const importFrom = m.import(this);
151
159
  content += `import * as ${importAlias} from "./${importFrom}";
152
160
  `;
@@ -155,7 +163,7 @@ class ReExportVariableModule extends Module {
155
163
  }
156
164
  content += "\n";
157
165
  const depProps = Object.fromEntries(
158
- this.deps.map(({ name, exportName }) => [name, `${strings.importAlias(name)}.${exportName}`])
166
+ this.deps.map(({ name, exportName, importAlias }) => [name, `${importAlias}.${exportName}`])
159
167
  );
160
168
  const allProps = { ...depProps, ...this._extraProps };
161
169
  content += `export const ${this.exportName} = {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/code-generation/module.ts"],
4
- "sourcesContent": ["import { posix as pathlib } from 'path'\nimport * as utils from '../utils'\nimport * as consts from './consts'\nimport * as strings from './strings'\nimport { File } from './typings'\n\nexport type ModuleProps = {\n path: string\n exportName: string\n}\n\nexport abstract class Module {\n private _localDependencies: Module[] = []\n\n public get path(): string {\n return this._def.path.split(pathlib.sep).map(strings.fileName).join(pathlib.sep)\n }\n\n /**\n * @returns module name (equivalent to unescaped file name without extension)\n */\n public get name(): string {\n const path = this._def.path\n const basename = pathlib.basename(path)\n if (basename === consts.INDEX_FILE || basename === consts.INDEX_DECLARATION_FILE) {\n const dirPath = pathlib.dirname(path)\n const dirname = pathlib.basename(dirPath)\n return dirname\n }\n const withoutExtension = utils.path.rmExtension(basename)\n return withoutExtension\n }\n\n public get isDefaultExport(): boolean {\n return this._def.exportName === consts.DEFAULT_EXPORT_NAME\n }\n\n public get exportName(): string {\n return this._def.exportName\n }\n\n public get deps(): Module[] {\n return [...this._localDependencies]\n }\n\n protected constructor(private _def: ModuleProps) {}\n\n public abstract getContent(): Promise<string>\n\n public pushDep(...dependencies: Module[]): this {\n this._localDependencies.push(...dependencies)\n return this\n }\n\n public unshift(...basePath: string[]): this {\n this._def = {\n ...this._def,\n path: pathlib.join(...basePath, this._def.path),\n }\n this._localDependencies = this._localDependencies.map((d) => d.unshift(...basePath))\n return this\n }\n\n public async toFile(): Promise<File> {\n return {\n path: this.path,\n content: await this.getContent(),\n }\n }\n\n public async flatten(): Promise<File[]> {\n const self = await this.toFile()\n const allFiles: File[] = [self]\n for (const dep of this._localDependencies) {\n const depFiles = await dep.flatten()\n allFiles.push(...depFiles)\n }\n return allFiles\n }\n\n public import(base: Module): string {\n let relativePath = pathlib.relative(pathlib.dirname(base.path), this.path)\n relativePath = pathlib.join('.', relativePath)\n return utils.path.rmExtension(relativePath)\n }\n}\n\nexport class ReExportTypeModule extends Module {\n protected constructor(def: { exportName: string }) {\n super({\n ...def,\n path: consts.INDEX_FILE,\n })\n }\n\n public async getContent(): Promise<string> {\n let content = consts.GENERATED_HEADER\n\n for (const m of this.deps) {\n const { name } = m\n const importAlias = strings.importAlias(name)\n const importFrom = m.import(this)\n content += `import * as ${importAlias} from \"./${importFrom}\";\\n`\n content += `export * as ${importAlias} from \"./${importFrom}\";\\n`\n }\n\n content += '\\n'\n\n content += `export type ${this.exportName} = {\\n`\n for (const { name, exportName: exports } of this.deps) {\n const importAlias = strings.importAlias(name)\n content += ` \"${name}\": ${importAlias}.${exports};\\n`\n }\n content += '}'\n\n content += '\\n'\n\n return content\n }\n}\n\nexport class ReExportVariableModule extends Module {\n private _extraProps: Record<string, string> = {}\n\n protected constructor(def: { exportName: string; extraProps?: Record<string, string> }) {\n super({\n ...def,\n path: consts.INDEX_FILE,\n })\n this._extraProps = def.extraProps ?? {}\n }\n\n public async getContent(): Promise<string> {\n let content = consts.GENERATED_HEADER\n\n for (const m of this.deps) {\n const { name } = m\n const importAlias = strings.importAlias(name)\n const importFrom = m.import(this)\n content += `import * as ${importAlias} from \"./${importFrom}\";\\n`\n content += `export * as ${importAlias} from \"./${importFrom}\";\\n`\n }\n\n content += '\\n'\n\n const depProps: Record<string, string> = Object.fromEntries(\n this.deps.map(({ name, exportName }) => [name, `${strings.importAlias(name)}.${exportName}`])\n )\n\n const allProps = { ...depProps, ...this._extraProps }\n\n content += `export const ${this.exportName} = {\\n`\n for (const [key, value] of Object.entries(allProps)) {\n content += ` \"${key}\": ${value},\\n`\n }\n content += '}'\n\n content += '\\n'\n\n return content\n }\n}\n\nexport class SingleFileModule extends Module {\n private _content: string\n public constructor(def: ModuleProps & { content: string }) {\n super(def)\n this._content = def.content\n }\n\n public async getContent(): Promise<string> {\n return this._content\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiC;AACjC,YAAuB;AACvB,aAAwB;AACxB,cAAyB;AAQlB,MAAe,OAAO;AAAA,EAkCjB,YAAoB,MAAmB;AAAnB;AAAA,EAAoB;AAAA,EAjC1C,qBAA+B,CAAC;AAAA,EAExC,IAAW,OAAe;AACxB,WAAO,KAAK,KAAK,KAAK,MAAM,YAAAA,MAAQ,GAAG,EAAE,IAAI,QAAQ,QAAQ,EAAE,KAAK,YAAAA,MAAQ,GAAG;AAAA,EACjF;AAAA;AAAA;AAAA;AAAA,EAKA,IAAW,OAAe;AACxB,UAAM,OAAO,KAAK,KAAK;AACvB,UAAM,WAAW,YAAAA,MAAQ,SAAS,IAAI;AACtC,QAAI,aAAa,OAAO,cAAc,aAAa,OAAO,wBAAwB;AAChF,YAAM,UAAU,YAAAA,MAAQ,QAAQ,IAAI;AACpC,YAAM,UAAU,YAAAA,MAAQ,SAAS,OAAO;AACxC,aAAO;AAAA,IACT;AACA,UAAM,mBAAmB,MAAM,KAAK,YAAY,QAAQ;AACxD,WAAO;AAAA,EACT;AAAA,EAEA,IAAW,kBAA2B;AACpC,WAAO,KAAK,KAAK,eAAe,OAAO;AAAA,EACzC;AAAA,EAEA,IAAW,aAAqB;AAC9B,WAAO,KAAK,KAAK;AAAA,EACnB;AAAA,EAEA,IAAW,OAAiB;AAC1B,WAAO,CAAC,GAAG,KAAK,kBAAkB;AAAA,EACpC;AAAA,EAMO,WAAW,cAA8B;AAC9C,SAAK,mBAAmB,KAAK,GAAG,YAAY;AAC5C,WAAO;AAAA,EACT;AAAA,EAEO,WAAW,UAA0B;AAC1C,SAAK,OAAO;AAAA,MACV,GAAG,KAAK;AAAA,MACR,MAAM,YAAAA,MAAQ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from './consts'\nimport * as strings from './strings'\nimport { File } from './typings'\n\nexport type ModuleProps = {\n path: string\n exportName: string\n}\n\nexport abstract class Module {\n private _localDependencies: Module[] = []\n private _customTypeName: string | undefined\n\n public get path(): string {\n return this._def.path.split(pathlib.sep).map(strings.fileName).join(pathlib.sep)\n }\n\n /**\n * @returns module name (equivalent to unescaped file name without extension)\n */\n public get name(): string {\n const path = this._def.path\n const basename = pathlib.basename(path)\n if (basename === consts.INDEX_FILE || basename === consts.INDEX_DECLARATION_FILE) {\n const dirPath = pathlib.dirname(path)\n const dirname = pathlib.basename(dirPath)\n return dirname\n }\n const withoutExtension = utils.path.rmExtension(basename)\n return withoutExtension\n }\n\n public get isDefaultExport(): boolean {\n return this._def.exportName === consts.DEFAULT_EXPORT_NAME\n }\n\n public get exportName(): string {\n return this._def.exportName\n }\n\n public get deps(): Module[] {\n return [...this._localDependencies]\n }\n\n public get typeName(): string {\n return this._customTypeName ?? this.name\n }\n\n public get importAlias(): string {\n return this.typeName.split(pathlib.sep).map(strings.importAlias).join('__')\n }\n\n protected constructor(private _def: ModuleProps) {}\n\n public abstract getContent(): Promise<string>\n\n public setCustomTypeName(alias: string): this {\n this._customTypeName = alias\n return this\n }\n\n public pushDep(...dependencies: Module[]): this {\n this._localDependencies.push(...dependencies)\n return this\n }\n\n public unshift(...basePath: string[]): this {\n this._def = {\n ...this._def,\n path: pathlib.join(...basePath, this._def.path),\n }\n this._localDependencies = this._localDependencies.map((d) => d.unshift(...basePath))\n return this\n }\n\n public async toFile(): Promise<File> {\n return {\n path: this.path,\n content: await this.getContent(),\n }\n }\n\n public async flatten(): Promise<File[]> {\n const self = await this.toFile()\n const allFiles: File[] = [self]\n for (const dep of this._localDependencies) {\n const depFiles = await dep.flatten()\n allFiles.push(...depFiles)\n }\n return allFiles\n }\n\n public import(base: Module): string {\n let relativePath = pathlib.relative(pathlib.dirname(base.path), this.path)\n relativePath = pathlib.join('.', relativePath)\n return utils.path.rmExtension(relativePath)\n }\n}\n\nexport class ReExportTypeModule extends Module {\n protected constructor(def: { exportName: string }) {\n super({\n ...def,\n path: consts.INDEX_FILE,\n })\n }\n\n public async getContent(): Promise<string> {\n let content = consts.GENERATED_HEADER\n\n for (const m of this.deps) {\n const { importAlias } = m\n const importFrom = m.import(this)\n content += `import * as ${importAlias} from \"./${importFrom}\";\\n`\n content += `export * as ${importAlias} from \"./${importFrom}\";\\n`\n }\n\n content += '\\n'\n\n content += `export type ${this.exportName} = {\\n`\n for (const { importAlias, typeName, exportName: exports } of this.deps) {\n content += ` \"${typeName}\": ${importAlias}.${exports};\\n`\n }\n content += '}'\n\n content += '\\n'\n\n return content\n }\n}\n\nexport class ReExportVariableModule extends Module {\n private _extraProps: Record<string, string> = {}\n\n protected constructor(def: { exportName: string; extraProps?: Record<string, string> }) {\n super({\n ...def,\n path: consts.INDEX_FILE,\n })\n this._extraProps = def.extraProps ?? {}\n }\n\n public async getContent(): Promise<string> {\n let content = consts.GENERATED_HEADER\n\n for (const m of this.deps) {\n const { importAlias } = m\n const importFrom = m.import(this)\n content += `import * as ${importAlias} from \"./${importFrom}\";\\n`\n content += `export * as ${importAlias} from \"./${importFrom}\";\\n`\n }\n\n content += '\\n'\n\n const depProps: Record<string, string> = Object.fromEntries(\n this.deps.map(({ name, exportName, importAlias }) => [name, `${importAlias}.${exportName}`])\n )\n\n const allProps = { ...depProps, ...this._extraProps }\n\n content += `export const ${this.exportName} = {\\n`\n for (const [key, value] of Object.entries(allProps)) {\n content += ` \"${key}\": ${value},\\n`\n }\n content += '}'\n\n content += '\\n'\n\n return content\n }\n}\n\nexport class SingleFileModule extends Module {\n private _content: string\n public constructor(def: ModuleProps & { content: string }) {\n super(def)\n this._content = def.content\n }\n\n public async getContent(): Promise<string> {\n return this._content\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiC;AACjC,YAAuB;AACvB,aAAw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,KAAK,KAAK,MAAM;AACtE,iBAAW,MAAM,cAAc,eAAe;AAAA;AAAA,IAChD;AACA,eAAW;AAEX,eAAW;AAEX,WAAO;AAAA,EACT;AACF;AAEO,MAAM,+BAA+B,OAAO;AAAA,EACzC,cAAsC,CAAC;AAAA,EAErC,YAAY,KAAkE;AACtF,UAAM;AAAA,MACJ,GAAG;AAAA,MACH,MAAM,OAAO;AAAA,IACf,CAAC;AACD,SAAK,cAAc,IAAI,cAAc,CAAC;AAAA,EACxC;AAAA,EAEA,MAAa,aAA8B;AACzC,QAAI,UAAU,OAAO;AAErB,eAAW,KAAK,KAAK,MAAM;AACzB,YAAM,EAAE,YAAY,IAAI;AACxB,YAAM,aAAa,EAAE,OAAO,IAAI;AAChC,iBAAW,eAAe,uBAAuB;AAAA;AACjD,iBAAW,eAAe,uBAAuB;AAAA;AAAA,IACnD;AAEA,eAAW;AAEX,UAAM,WAAmC,OAAO;AAAA,MAC9C,KAAK,KAAK,IAAI,CAAC,EAAE,MAAM,YAAY,YAAY,MAAM,CAAC,MAAM,GAAG,eAAe,YAAY,CAAC;AAAA,IAC7F;AAEA,UAAM,WAAW,EAAE,GAAG,UAAU,GAAG,KAAK,YAAY;AAEpD,eAAW,gBAAgB,KAAK;AAAA;AAChC,eAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,QAAQ,GAAG;AACnD,iBAAW,MAAM,SAAS;AAAA;AAAA,IAC5B;AACA,eAAW;AAEX,eAAW;AAEX,WAAO;AAAA,EACT;AACF;AAEO,MAAM,yBAAyB,OAAO;AAAA,EACnC;AAAA,EACD,YAAY,KAAwC;AACzD,UAAM,GAAG;AACT,SAAK,WAAW,IAAI;AAAA,EACtB;AAAA,EAEA,MAAa,aAA8B;AACzC,WAAO,KAAK;AAAA,EACd;AACF;",
6
6
  "names": ["pathlib"]
7
7
  }
@@ -29,22 +29,50 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
29
29
  var states_module_exports = {};
30
30
  __export(states_module_exports, {
31
31
  StateModule: () => StateModule,
32
+ StatePayloadModule: () => StatePayloadModule,
32
33
  StatesModule: () => StatesModule
33
34
  });
34
35
  module.exports = __toCommonJS(states_module_exports);
35
- var import_generators = require("../../generators");
36
+ var consts = __toESM(require("../../consts"));
37
+ var gen = __toESM(require("../../generators"));
36
38
  var import_module = require("../../module");
37
39
  var strings = __toESM(require("../../strings"));
40
+ class StatePayloadModule extends import_module.Module {
41
+ constructor(_state) {
42
+ super({
43
+ path: "payload.ts",
44
+ exportName: strings.typeName("Payload")
45
+ });
46
+ this._state = _state;
47
+ }
48
+ async getContent() {
49
+ return gen.zuiSchemaToTypeScriptType(this._state.schema, "Payload");
50
+ }
51
+ }
38
52
  class StateModule extends import_module.Module {
39
- constructor(name, _state) {
53
+ constructor(_name, _state) {
40
54
  super({
41
- path: `${name}.ts`,
42
- exportName: strings.typeName(name)
55
+ path: consts.INDEX_FILE,
56
+ exportName: strings.typeName(_name)
43
57
  });
58
+ this._name = _name;
44
59
  this._state = _state;
60
+ this._payloadModule = new StatePayloadModule(_state);
61
+ this.pushDep(this._payloadModule);
45
62
  }
63
+ _payloadModule;
46
64
  async getContent() {
47
- return (0, import_generators.zuiSchemaToTypeScriptType)(this._state.schema, this.exportName);
65
+ const { _payloadModule } = this;
66
+ const payloadImport = _payloadModule.import(this);
67
+ const exportName = strings.typeName(this._name);
68
+ return [
69
+ consts.GENERATED_HEADER,
70
+ `import * as ${_payloadModule.name} from './${payloadImport}'`,
71
+ `export type ${exportName} = {`,
72
+ ` type: ${gen.primitiveToTypescriptValue(this._state.type)},`,
73
+ ` payload: ${_payloadModule.name}.${_payloadModule.exportName}`,
74
+ "}"
75
+ ].join("\n");
48
76
  }
49
77
  }
50
78
  class StatesModule extends import_module.ReExportTypeModule {
@@ -52,6 +80,7 @@ class StatesModule extends import_module.ReExportTypeModule {
52
80
  super({ exportName: strings.typeName("states") });
53
81
  for (const [stateName, state] of Object.entries(states)) {
54
82
  const module2 = new StateModule(stateName, state);
83
+ module2.unshift(stateName);
55
84
  this.pushDep(module2);
56
85
  }
57
86
  }
@@ -59,6 +88,7 @@ class StatesModule extends import_module.ReExportTypeModule {
59
88
  // Annotate the CommonJS export names for ESM import in node:
60
89
  0 && (module.exports = {
61
90
  StateModule,
91
+ StatePayloadModule,
62
92
  StatesModule
63
93
  });
64
94
  //# sourceMappingURL=states-module.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/code-generation/plugin-implementation/plugin-typings/states-module.ts"],
4
- "sourcesContent": ["import * as sdk from '@botpress/sdk'\nimport { zuiSchemaToTypeScriptType } from '../../generators'\nimport { Module, ReExportTypeModule } from '../../module'\nimport * as strings from '../../strings'\n\nexport class StateModule extends Module {\n public constructor(\n name: string,\n private _state: sdk.BotStateDefinition\n ) {\n super({\n path: `${name}.ts`,\n exportName: strings.typeName(name),\n })\n }\n\n public async getContent() {\n return zuiSchemaToTypeScriptType(this._state.schema, this.exportName)\n }\n}\n\nexport class StatesModule extends ReExportTypeModule {\n public constructor(states: Record<string, sdk.BotStateDefinition>) {\n super({ exportName: strings.typeName('states') })\n for (const [stateName, state] of Object.entries(states)) {\n const module = new StateModule(stateName, state)\n this.pushDep(module)\n }\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,wBAA0C;AAC1C,oBAA2C;AAC3C,cAAyB;AAElB,MAAM,oBAAoB,qBAAO;AAAA,EAC/B,YACL,MACQ,QACR;AACA,UAAM;AAAA,MACJ,MAAM,GAAG;AAAA,MACT,YAAY,QAAQ,SAAS,IAAI;AAAA,IACnC,CAAC;AALO;AAAA,EAMV;AAAA,EAEA,MAAa,aAAa;AACxB,eAAO,6CAA0B,KAAK,OAAO,QAAQ,KAAK,UAAU;AAAA,EACtE;AACF;AAEO,MAAM,qBAAqB,iCAAmB;AAAA,EAC5C,YAAY,QAAgD;AACjE,UAAM,EAAE,YAAY,QAAQ,SAAS,QAAQ,EAAE,CAAC;AAChD,eAAW,CAAC,WAAW,KAAK,KAAK,OAAO,QAAQ,MAAM,GAAG;AACvD,YAAMA,UAAS,IAAI,YAAY,WAAW,KAAK;AAC/C,WAAK,QAAQA,OAAM;AAAA,IACrB;AAAA,EACF;AACF;",
4
+ "sourcesContent": ["import * as sdk from '@botpress/sdk'\nimport * as consts from '../../consts'\nimport * as gen from '../../generators'\nimport { Module, ReExportTypeModule } from '../../module'\nimport * as strings from '../../strings'\n\nexport class StatePayloadModule extends Module {\n public constructor(private _state: sdk.BotStateDefinition) {\n super({\n path: 'payload.ts',\n exportName: strings.typeName('Payload'),\n })\n }\n\n public async getContent() {\n return gen.zuiSchemaToTypeScriptType(this._state.schema, 'Payload')\n }\n}\n\nexport class StateModule extends Module {\n private _payloadModule: StatePayloadModule\n\n public constructor(\n private _name: string,\n private _state: sdk.BotStateDefinition\n ) {\n super({\n path: consts.INDEX_FILE,\n exportName: strings.typeName(_name),\n })\n\n this._payloadModule = new StatePayloadModule(_state)\n this.pushDep(this._payloadModule)\n }\n\n public async getContent(): Promise<string> {\n const { _payloadModule } = this\n const payloadImport = _payloadModule.import(this)\n\n const exportName = strings.typeName(this._name)\n\n return [\n consts.GENERATED_HEADER,\n `import * as ${_payloadModule.name} from './${payloadImport}'`,\n `export type ${exportName} = {`,\n ` type: ${gen.primitiveToTypescriptValue(this._state.type)},`,\n ` payload: ${_payloadModule.name}.${_payloadModule.exportName}`,\n '}',\n ].join('\\n')\n }\n}\n\nexport class StatesModule extends ReExportTypeModule {\n public constructor(states: Record<string, sdk.BotStateDefinition>) {\n super({ exportName: strings.typeName('states') })\n for (const [stateName, state] of Object.entries(states)) {\n const module = new StateModule(stateName, state)\n module.unshift(stateName)\n this.pushDep(module)\n }\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,a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["module"]
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@botpress/cli",
3
- "version": "3.6.5",
3
+ "version": "4.0.1",
4
4
  "description": "Botpress CLI",
5
5
  "scripts": {
6
6
  "build": "pnpm run bundle && pnpm run template:gen",
@@ -22,7 +22,7 @@
22
22
  "@apidevtools/json-schema-ref-parser": "^11.7.0",
23
23
  "@botpress/chat": "0.5.1",
24
24
  "@botpress/client": "0.48.3",
25
- "@botpress/sdk": "3.6.3",
25
+ "@botpress/sdk": "4.0.0",
26
26
  "@bpinternal/const": "^0.1.0",
27
27
  "@bpinternal/tunnel": "^0.1.1",
28
28
  "@bpinternal/yargs-extra": "^0.0.3",
@@ -6,7 +6,7 @@
6
6
  "private": true,
7
7
  "dependencies": {
8
8
  "@botpress/client": "0.48.3",
9
- "@botpress/sdk": "3.6.3"
9
+ "@botpress/sdk": "4.0.0"
10
10
  },
11
11
  "devDependencies": {
12
12
  "@types/node": "^18.19.67",
@@ -7,7 +7,7 @@
7
7
  "private": true,
8
8
  "dependencies": {
9
9
  "@botpress/client": "0.48.3",
10
- "@botpress/sdk": "3.6.3"
10
+ "@botpress/sdk": "4.0.0"
11
11
  },
12
12
  "devDependencies": {
13
13
  "@types/node": "^18.19.67",
@@ -6,7 +6,7 @@
6
6
  },
7
7
  "private": true,
8
8
  "dependencies": {
9
- "@botpress/sdk": "3.6.3"
9
+ "@botpress/sdk": "4.0.0"
10
10
  },
11
11
  "devDependencies": {
12
12
  "@types/node": "^18.19.67",
@@ -7,7 +7,7 @@
7
7
  "private": true,
8
8
  "dependencies": {
9
9
  "@botpress/client": "0.48.3",
10
- "@botpress/sdk": "3.6.3"
10
+ "@botpress/sdk": "4.0.0"
11
11
  },
12
12
  "devDependencies": {
13
13
  "@types/node": "^18.19.67",
@@ -7,7 +7,7 @@
7
7
  "private": true,
8
8
  "dependencies": {
9
9
  "@botpress/client": "0.48.3",
10
- "@botpress/sdk": "3.6.3",
10
+ "@botpress/sdk": "4.0.0",
11
11
  "axios": "^1.6.8"
12
12
  },
13
13
  "devDependencies": {