@botpress/cli 0.11.1 → 0.11.2

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,19 +1,19 @@
1
1
 
2
- > @botpress/cli@0.11.1 build /home/runner/work/botpress/botpress/packages/cli
2
+ > @botpress/cli@0.11.2 build /home/runner/work/botpress/botpress/packages/cli
3
3
  > pnpm run bundle && pnpm run template:gen
4
4
 
5
5
 
6
- > @botpress/cli@0.11.1 bundle /home/runner/work/botpress/botpress/packages/cli
6
+ > @botpress/cli@0.11.2 bundle /home/runner/work/botpress/botpress/packages/cli
7
7
  > ts-node -T build.ts
8
8
 
9
9
 
10
- > @botpress/cli@0.11.1 template:gen /home/runner/work/botpress/botpress/packages/cli
10
+ > @botpress/cli@0.11.2 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 v0.11.1
14
- šŸ¤– Botpress CLI v0.11.1
15
- šŸ¤– Botpress CLI v0.11.1
16
- šŸ¤– Botpress CLI v0.11.1
13
+ šŸ¤– Botpress CLI v0.11.2
14
+ šŸ¤– Botpress CLI v0.11.2
15
+ šŸ¤– Botpress CLI v0.11.2
16
+ šŸ¤– Botpress CLI v0.11.2
17
17
  ⚠ No typings to generate for bot projects
18
18
  ā—‹ Generating typings for integration hello-world...ā—‹ Generating typings for integration webhook-message...ā—‹ Generating typings for integration empty-integration...āœ“ Typings available at .botpress
19
19
  āœ“ Typings available at .botpress
@@ -29,19 +29,19 @@ __export(bot_body_exports, {
29
29
  });
30
30
  module.exports = __toCommonJS(bot_body_exports);
31
31
  var utils = __toESM(require("../utils"));
32
- const prepareCreateBotBody = (bot) => ({
32
+ const prepareCreateBotBody = async (bot) => ({
33
33
  ...bot.props,
34
34
  configuration: bot.props.configuration ? {
35
35
  ...bot.props.configuration,
36
- schema: utils.schema.mapZodToJsonSchema(bot.props.configuration)
36
+ schema: await utils.schema.mapZodToJsonSchema(bot.props.configuration)
37
37
  } : void 0,
38
- events: bot.props.events ? utils.records.mapValues(bot.props.events, (event) => ({
38
+ events: bot.props.events ? await utils.records.mapValuesAsync(bot.props.events, async (event) => ({
39
39
  ...event,
40
- schema: utils.schema.mapZodToJsonSchema(event)
40
+ schema: await utils.schema.mapZodToJsonSchema(event)
41
41
  })) : void 0,
42
- states: bot.props.states ? utils.records.mapValues(bot.props.states, (state) => ({
42
+ states: bot.props.states ? await utils.records.mapValuesAsync(bot.props.states, async (state) => ({
43
43
  ...state,
44
- schema: utils.schema.mapZodToJsonSchema(state)
44
+ schema: await utils.schema.mapZodToJsonSchema(state)
45
45
  })) : void 0
46
46
  });
47
47
  const prepareUpdateBotBody = (localBot, remoteBot) => ({
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/api/bot-body.ts"],
4
- "sourcesContent": ["import type * as client from '@botpress/client'\nimport type * as sdk from '@botpress/sdk'\nimport * as utils from '../utils'\n\nexport type CreateBotBody = Parameters<client.Client['createBot']>[0]\nexport type UpdateBotBody = Parameters<client.Client['updateBot']>[0]\n\nexport const prepareCreateBotBody = (bot: sdk.Bot): CreateBotBody => ({\n ...bot.props,\n configuration: bot.props.configuration\n ? {\n ...bot.props.configuration,\n schema: utils.schema.mapZodToJsonSchema(bot.props.configuration),\n }\n : undefined,\n events: bot.props.events\n ? utils.records.mapValues(bot.props.events, (event) => ({\n ...event,\n schema: utils.schema.mapZodToJsonSchema(event),\n }))\n : undefined,\n states: bot.props.states\n ? utils.records.mapValues(bot.props.states, (state) => ({\n ...state,\n schema: utils.schema.mapZodToJsonSchema(state),\n }))\n : undefined,\n})\n\nexport const prepareUpdateBotBody = (localBot: UpdateBotBody, remoteBot: client.Bot): UpdateBotBody => ({\n ...localBot,\n states: utils.records.setNullOnMissingValues(localBot.states, remoteBot.states),\n recurringEvents: utils.records.setNullOnMissingValues(localBot.recurringEvents, remoteBot.recurringEvents),\n events: utils.records.setNullOnMissingValues(localBot.events, remoteBot.events),\n user: {\n ...localBot.user,\n tags: utils.records.setNullOnMissingValues(localBot.user?.tags, remoteBot.user?.tags),\n },\n conversation: {\n ...localBot.conversation,\n tags: utils.records.setNullOnMissingValues(localBot.conversation?.tags, remoteBot.conversation?.tags),\n },\n message: {\n ...localBot.message,\n tags: utils.records.setNullOnMissingValues(localBot.message?.tags, remoteBot.message?.tags),\n },\n integrations: utils.records.setNullOnMissingValues(localBot.integrations, remoteBot.integrations),\n})\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,YAAuB;AAKhB,MAAM,uBAAuB,CAAC,SAAiC;AAAA,EACpE,GAAG,IAAI;AAAA,EACP,eAAe,IAAI,MAAM,gBACrB;AAAA,IACE,GAAG,IAAI,MAAM;AAAA,IACb,QAAQ,MAAM,OAAO,mBAAmB,IAAI,MAAM,aAAa;AAAA,EACjE,IACA;AAAA,EACJ,QAAQ,IAAI,MAAM,SACd,MAAM,QAAQ,UAAU,IAAI,MAAM,QAAQ,CAAC,WAAW;AAAA,IACpD,GAAG;AAAA,IACH,QAAQ,MAAM,OAAO,mBAAmB,KAAK;AAAA,EAC/C,EAAE,IACF;AAAA,EACJ,QAAQ,IAAI,MAAM,SACd,MAAM,QAAQ,UAAU,IAAI,MAAM,QAAQ,CAAC,WAAW;AAAA,IACpD,GAAG;AAAA,IACH,QAAQ,MAAM,OAAO,mBAAmB,KAAK;AAAA,EAC/C,EAAE,IACF;AACN;AAEO,MAAM,uBAAuB,CAAC,UAAyB,eAA0C;AAAA,EACtG,GAAG;AAAA,EACH,QAAQ,MAAM,QAAQ,uBAAuB,SAAS,QAAQ,UAAU,MAAM;AAAA,EAC9E,iBAAiB,MAAM,QAAQ,uBAAuB,SAAS,iBAAiB,UAAU,eAAe;AAAA,EACzG,QAAQ,MAAM,QAAQ,uBAAuB,SAAS,QAAQ,UAAU,MAAM;AAAA,EAC9E,MAAM;AAAA,IACJ,GAAG,SAAS;AAAA,IACZ,MAAM,MAAM,QAAQ,uBAAuB,SAAS,MAAM,MAAM,UAAU,MAAM,IAAI;AAAA,EACtF;AAAA,EACA,cAAc;AAAA,IACZ,GAAG,SAAS;AAAA,IACZ,MAAM,MAAM,QAAQ,uBAAuB,SAAS,cAAc,MAAM,UAAU,cAAc,IAAI;AAAA,EACtG;AAAA,EACA,SAAS;AAAA,IACP,GAAG,SAAS;AAAA,IACZ,MAAM,MAAM,QAAQ,uBAAuB,SAAS,SAAS,MAAM,UAAU,SAAS,IAAI;AAAA,EAC5F;AAAA,EACA,cAAc,MAAM,QAAQ,uBAAuB,SAAS,cAAc,UAAU,YAAY;AAClG;",
4
+ "sourcesContent": ["import type * as client from '@botpress/client'\nimport type * as sdk from '@botpress/sdk'\nimport * as utils from '../utils'\n\nexport type CreateBotBody = Parameters<client.Client['createBot']>[0]\nexport type UpdateBotBody = Parameters<client.Client['updateBot']>[0]\n\nexport const prepareCreateBotBody = async (bot: sdk.Bot): Promise<CreateBotBody> => ({\n ...bot.props,\n configuration: bot.props.configuration\n ? {\n ...bot.props.configuration,\n schema: await utils.schema.mapZodToJsonSchema(bot.props.configuration),\n }\n : undefined,\n events: bot.props.events\n ? await utils.records.mapValuesAsync(bot.props.events, async (event) => ({\n ...event,\n schema: await utils.schema.mapZodToJsonSchema(event),\n }))\n : undefined,\n states: bot.props.states\n ? await utils.records.mapValuesAsync(bot.props.states, async (state) => ({\n ...state,\n schema: await utils.schema.mapZodToJsonSchema(state),\n }))\n : undefined,\n})\n\nexport const prepareUpdateBotBody = (localBot: UpdateBotBody, remoteBot: client.Bot): UpdateBotBody => ({\n ...localBot,\n states: utils.records.setNullOnMissingValues(localBot.states, remoteBot.states),\n recurringEvents: utils.records.setNullOnMissingValues(localBot.recurringEvents, remoteBot.recurringEvents),\n events: utils.records.setNullOnMissingValues(localBot.events, remoteBot.events),\n user: {\n ...localBot.user,\n tags: utils.records.setNullOnMissingValues(localBot.user?.tags, remoteBot.user?.tags),\n },\n conversation: {\n ...localBot.conversation,\n tags: utils.records.setNullOnMissingValues(localBot.conversation?.tags, remoteBot.conversation?.tags),\n },\n message: {\n ...localBot.message,\n tags: utils.records.setNullOnMissingValues(localBot.message?.tags, remoteBot.message?.tags),\n },\n integrations: utils.records.setNullOnMissingValues(localBot.integrations, remoteBot.integrations),\n})\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,YAAuB;AAKhB,MAAM,uBAAuB,OAAO,SAA0C;AAAA,EACnF,GAAG,IAAI;AAAA,EACP,eAAe,IAAI,MAAM,gBACrB;AAAA,IACE,GAAG,IAAI,MAAM;AAAA,IACb,QAAQ,MAAM,MAAM,OAAO,mBAAmB,IAAI,MAAM,aAAa;AAAA,EACvE,IACA;AAAA,EACJ,QAAQ,IAAI,MAAM,SACd,MAAM,MAAM,QAAQ,eAAe,IAAI,MAAM,QAAQ,OAAO,WAAW;AAAA,IACrE,GAAG;AAAA,IACH,QAAQ,MAAM,MAAM,OAAO,mBAAmB,KAAK;AAAA,EACrD,EAAE,IACF;AAAA,EACJ,QAAQ,IAAI,MAAM,SACd,MAAM,MAAM,QAAQ,eAAe,IAAI,MAAM,QAAQ,OAAO,WAAW;AAAA,IACrE,GAAG;AAAA,IACH,QAAQ,MAAM,MAAM,OAAO,mBAAmB,KAAK;AAAA,EACrD,EAAE,IACF;AACN;AAEO,MAAM,uBAAuB,CAAC,UAAyB,eAA0C;AAAA,EACtG,GAAG;AAAA,EACH,QAAQ,MAAM,QAAQ,uBAAuB,SAAS,QAAQ,UAAU,MAAM;AAAA,EAC9E,iBAAiB,MAAM,QAAQ,uBAAuB,SAAS,iBAAiB,UAAU,eAAe;AAAA,EACzG,QAAQ,MAAM,QAAQ,uBAAuB,SAAS,QAAQ,UAAU,MAAM;AAAA,EAC9E,MAAM;AAAA,IACJ,GAAG,SAAS;AAAA,IACZ,MAAM,MAAM,QAAQ,uBAAuB,SAAS,MAAM,MAAM,UAAU,MAAM,IAAI;AAAA,EACtF;AAAA,EACA,cAAc;AAAA,IACZ,GAAG,SAAS;AAAA,IACZ,MAAM,MAAM,QAAQ,uBAAuB,SAAS,cAAc,MAAM,UAAU,cAAc,IAAI;AAAA,EACtG;AAAA,EACA,SAAS;AAAA,IACP,GAAG,SAAS;AAAA,IACZ,MAAM,MAAM,QAAQ,uBAAuB,SAAS,SAAS,MAAM,UAAU,SAAS,IAAI;AAAA,EAC5F;AAAA,EACA,cAAc,MAAM,QAAQ,uBAAuB,SAAS,cAAc,UAAU,YAAY;AAClG;",
6
6
  "names": []
7
7
  }
@@ -29,7 +29,7 @@ __export(integration_body_exports, {
29
29
  });
30
30
  module.exports = __toCommonJS(integration_body_exports);
31
31
  var utils = __toESM(require("../utils"));
32
- const prepareCreateIntegrationBody = (integration) => ({
32
+ const prepareCreateIntegrationBody = async (integration, options = {}) => ({
33
33
  name: integration.name,
34
34
  version: integration.version,
35
35
  title: integration.title,
@@ -42,41 +42,41 @@ const prepareCreateIntegrationBody = (integration) => ({
42
42
  interfaces: {},
43
43
  configuration: integration.configuration ? {
44
44
  ...integration.configuration,
45
- schema: utils.schema.mapZodToJsonSchema(integration.configuration)
45
+ schema: await utils.schema.mapZodToJsonSchema(integration.configuration, options)
46
46
  } : void 0,
47
- configurations: integration.configurations ? utils.records.mapValues(integration.configurations, (configuration) => ({
47
+ configurations: integration.configurations ? await utils.records.mapValuesAsync(integration.configurations, async (configuration) => ({
48
48
  ...configuration,
49
- schema: utils.schema.mapZodToJsonSchema(configuration)
49
+ schema: await utils.schema.mapZodToJsonSchema(configuration, options)
50
50
  })) : void 0,
51
- events: integration.events ? utils.records.mapValues(integration.events, (event) => ({
51
+ events: integration.events ? await utils.records.mapValuesAsync(integration.events, async (event) => ({
52
52
  ...event,
53
- schema: utils.schema.mapZodToJsonSchema(event)
53
+ schema: await utils.schema.mapZodToJsonSchema(event, options)
54
54
  })) : void 0,
55
- actions: integration.actions ? utils.records.mapValues(integration.actions, (action) => ({
55
+ actions: integration.actions ? await utils.records.mapValuesAsync(integration.actions, async (action) => ({
56
56
  ...action,
57
57
  input: {
58
58
  ...action.input,
59
- schema: utils.schema.mapZodToJsonSchema(action.input)
59
+ schema: await utils.schema.mapZodToJsonSchema(action.input, options)
60
60
  },
61
61
  output: {
62
62
  ...action.output,
63
- schema: utils.schema.mapZodToJsonSchema(action.output)
63
+ schema: await utils.schema.mapZodToJsonSchema(action.output, options)
64
64
  }
65
65
  })) : void 0,
66
- channels: integration.channels ? utils.records.mapValues(integration.channels, (channel) => ({
66
+ channels: integration.channels ? await utils.records.mapValuesAsync(integration.channels, async (channel) => ({
67
67
  ...channel,
68
- messages: utils.records.mapValues(channel.messages, (message) => ({
68
+ messages: await utils.records.mapValuesAsync(channel.messages, async (message) => ({
69
69
  ...message,
70
- schema: utils.schema.mapZodToJsonSchema(message)
70
+ schema: await utils.schema.mapZodToJsonSchema(message, options)
71
71
  }))
72
72
  })) : void 0,
73
- states: integration.states ? utils.records.mapValues(integration.states, (state) => ({
73
+ states: integration.states ? await utils.records.mapValuesAsync(integration.states, async (state) => ({
74
74
  ...state,
75
- schema: utils.schema.mapZodToJsonSchema(state)
75
+ schema: await utils.schema.mapZodToJsonSchema(state, options)
76
76
  })) : void 0,
77
- entities: integration.entities ? utils.records.mapValues(integration.entities, (entity) => ({
77
+ entities: integration.entities ? await utils.records.mapValuesAsync(integration.entities, async (entity) => ({
78
78
  ...entity,
79
- schema: utils.schema.mapZodToJsonSchema(entity)
79
+ schema: await utils.schema.mapZodToJsonSchema(entity, options)
80
80
  })) : void 0
81
81
  });
82
82
  const prepareUpdateIntegrationBody = (localIntegration, remoteIntegration) => {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/api/integration-body.ts"],
4
- "sourcesContent": ["import type { Client, Integration } from '@botpress/client'\nimport type * as sdk from '@botpress/sdk'\nimport * as utils from '../utils'\n\nexport type CreateIntegrationBody = Parameters<Client['createIntegration']>[0]\nexport type UpdateIntegrationBody = Parameters<Client['updateIntegration']>[0]\n\ntype UpdateIntegrationChannelsBody = NonNullable<UpdateIntegrationBody['channels']>\ntype UpdateIntegrationChannelBody = UpdateIntegrationChannelsBody[string]\n\ntype Channels = Integration['channels']\ntype Channel = Integration['channels'][string]\n\nexport const prepareCreateIntegrationBody = (integration: sdk.IntegrationDefinition): CreateIntegrationBody => ({\n name: integration.name,\n version: integration.version,\n title: integration.title,\n description: integration.description,\n icon: integration.icon,\n readme: integration.readme,\n user: integration.user,\n identifier: integration.identifier,\n secrets: undefined,\n interfaces: {},\n configuration: integration.configuration\n ? {\n ...integration.configuration,\n schema: utils.schema.mapZodToJsonSchema(integration.configuration),\n }\n : undefined,\n configurations: integration.configurations\n ? utils.records.mapValues(integration.configurations, (configuration) => ({\n ...configuration,\n schema: utils.schema.mapZodToJsonSchema(configuration),\n }))\n : undefined,\n events: integration.events\n ? utils.records.mapValues(integration.events, (event) => ({\n ...event,\n schema: utils.schema.mapZodToJsonSchema(event),\n }))\n : undefined,\n actions: integration.actions\n ? utils.records.mapValues(integration.actions, (action) => ({\n ...action,\n input: {\n ...action.input,\n schema: utils.schema.mapZodToJsonSchema(action.input),\n },\n output: {\n ...action.output,\n schema: utils.schema.mapZodToJsonSchema(action.output),\n },\n }))\n : undefined,\n channels: integration.channels\n ? utils.records.mapValues(integration.channels, (channel) => ({\n ...channel,\n messages: utils.records.mapValues(channel.messages, (message) => ({\n ...message,\n schema: utils.schema.mapZodToJsonSchema(message),\n })),\n }))\n : undefined,\n states: integration.states\n ? utils.records.mapValues(integration.states, (state) => ({\n ...state,\n schema: utils.schema.mapZodToJsonSchema(state),\n }))\n : undefined,\n entities: integration.entities\n ? utils.records.mapValues(integration.entities, (entity) => ({\n ...entity,\n schema: utils.schema.mapZodToJsonSchema(entity),\n }))\n : undefined,\n})\n\nexport const prepareUpdateIntegrationBody = (\n localIntegration: UpdateIntegrationBody,\n remoteIntegration: Integration\n): UpdateIntegrationBody => {\n const actions = utils.records.setNullOnMissingValues(localIntegration.actions, remoteIntegration.actions)\n const events = utils.records.setNullOnMissingValues(localIntegration.events, remoteIntegration.events)\n const states = utils.records.setNullOnMissingValues(localIntegration.states, remoteIntegration.states)\n const entities = utils.records.setNullOnMissingValues(localIntegration.entities, remoteIntegration.entities)\n const user = {\n ...localIntegration.user,\n tags: utils.records.setNullOnMissingValues(localIntegration.user?.tags, remoteIntegration.user?.tags),\n }\n\n const channels = prepareUpdateIntegrationChannelsBody(localIntegration.channels ?? {}, remoteIntegration.channels)\n\n const interfaces = utils.records.setNullOnMissingValues(localIntegration.interfaces, remoteIntegration.interfaces)\n\n const configurations = utils.records.setNullOnMissingValues(\n localIntegration.configurations,\n remoteIntegration.configurations\n )\n\n return {\n ...localIntegration,\n actions,\n events,\n states,\n entities,\n user,\n channels,\n interfaces,\n configurations,\n }\n}\n\nconst prepareUpdateIntegrationChannelsBody = (\n localChannels: UpdateIntegrationChannelsBody,\n remoteChannels: Channels\n): UpdateIntegrationChannelsBody => {\n const channelBody: UpdateIntegrationChannelsBody = {}\n\n const zipped = utils.records.zipObjects(localChannels, remoteChannels)\n for (const [channelName, [localChannel, remoteChannel]] of Object.entries(zipped)) {\n if (localChannel && remoteChannel) {\n // channel has to be updated\n channelBody[channelName] = prepareUpdateIntegrationChannelBody(localChannel, remoteChannel)\n } else if (localChannel) {\n // channel has to be created\n channelBody[channelName] = localChannel\n continue\n } else if (remoteChannel) {\n // channel has to be deleted\n channelBody[channelName] = null\n continue\n }\n }\n\n return channelBody\n}\n\nconst prepareUpdateIntegrationChannelBody = (\n localChannel: UpdateIntegrationChannelBody,\n remoteChannel: Channel\n): UpdateIntegrationChannelBody => ({\n ...localChannel,\n messages: utils.records.setNullOnMissingValues(localChannel?.messages, remoteChannel.messages),\n message: {\n ...localChannel?.message,\n tags: utils.records.setNullOnMissingValues(localChannel?.message?.tags, remoteChannel.message.tags),\n },\n conversation: {\n ...localChannel?.conversation,\n tags: utils.records.setNullOnMissingValues(localChannel?.conversation?.tags, remoteChannel.conversation.tags),\n },\n})\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,YAAuB;AAWhB,MAAM,+BAA+B,CAAC,iBAAmE;AAAA,EAC9G,MAAM,YAAY;AAAA,EAClB,SAAS,YAAY;AAAA,EACrB,OAAO,YAAY;AAAA,EACnB,aAAa,YAAY;AAAA,EACzB,MAAM,YAAY;AAAA,EAClB,QAAQ,YAAY;AAAA,EACpB,MAAM,YAAY;AAAA,EAClB,YAAY,YAAY;AAAA,EACxB,SAAS;AAAA,EACT,YAAY,CAAC;AAAA,EACb,eAAe,YAAY,gBACvB;AAAA,IACE,GAAG,YAAY;AAAA,IACf,QAAQ,MAAM,OAAO,mBAAmB,YAAY,aAAa;AAAA,EACnE,IACA;AAAA,EACJ,gBAAgB,YAAY,iBACxB,MAAM,QAAQ,UAAU,YAAY,gBAAgB,CAAC,mBAAmB;AAAA,IACtE,GAAG;AAAA,IACH,QAAQ,MAAM,OAAO,mBAAmB,aAAa;AAAA,EACvD,EAAE,IACF;AAAA,EACJ,QAAQ,YAAY,SAChB,MAAM,QAAQ,UAAU,YAAY,QAAQ,CAAC,WAAW;AAAA,IACtD,GAAG;AAAA,IACH,QAAQ,MAAM,OAAO,mBAAmB,KAAK;AAAA,EAC/C,EAAE,IACF;AAAA,EACJ,SAAS,YAAY,UACjB,MAAM,QAAQ,UAAU,YAAY,SAAS,CAAC,YAAY;AAAA,IACxD,GAAG;AAAA,IACH,OAAO;AAAA,MACL,GAAG,OAAO;AAAA,MACV,QAAQ,MAAM,OAAO,mBAAmB,OAAO,KAAK;AAAA,IACtD;AAAA,IACA,QAAQ;AAAA,MACN,GAAG,OAAO;AAAA,MACV,QAAQ,MAAM,OAAO,mBAAmB,OAAO,MAAM;AAAA,IACvD;AAAA,EACF,EAAE,IACF;AAAA,EACJ,UAAU,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AAkB;AAAA,EACpB;AAEA,SAAO;AAAA,IACL,GAAG;AAAA,IACH;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAEA,MAAM,uCAAuC,CAC3C,eACA,mBACkC;AAClC,QAAM,cAA6C,CAAC;AAEpD,QAAM,SAAS,MAAM,QAAQ,WAAW,eAAe,cAAc;AACrE,aAAW,CAAC,aAAa,CAAC,cAAc,aAAa,CAAC,KAAK,OAAO,QAAQ,MAAM,GAAG;AACjF,QAAI,gBAAgB,eAAe;AAEjC,kBAAY,eAAe,oCAAoC,cAAc,aAAa;AAAA,IAC5F,WAAW,cAAc;AAEvB,kBAAY,eAAe;AAC3B;AAAA,IACF,WAAW,eAAe;AAExB,kBAAY,eAAe;AAC3B;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;AAEA,MAAM,sCAAsC,CAC1C,cACA,mBACkC;AAAA,EAClC,GAAG;AAAA,EACH,UAAU,MAAM,QAAQ,uBAAuB,cAAc,UAAU,cAAc,QAAQ;AAAA,EAC7F,SAAS;AAAA,IACP,GAAG,cAAc;AAAA,IACjB,MAAM,MAAM,QAAQ,uBAAuB,cAAc,SAAS,MAAM,cAAc,QAAQ,IAAI;AAAA,EACpG;AAAA,EACA,cAAc;AAAA,IACZ,GAAG,cAAc;AAAA,IACjB,MAAM,MAAM,QAAQ,uBAAuB,cAAc,cAAc,MAAM,cAAc,aAAa,IAAI;AAAA,EAC9G;AACF;",
4
+ "sourcesContent": ["import type { Client, Integration } from '@botpress/client'\nimport type * as sdk from '@botpress/sdk'\nimport { ZodToJsonOptions } from 'src/utils/schema-utils'\nimport * as utils from '../utils'\n\nexport type CreateIntegrationBody = Parameters<Client['createIntegration']>[0]\nexport type UpdateIntegrationBody = Parameters<Client['updateIntegration']>[0]\n\ntype UpdateIntegrationChannelsBody = NonNullable<UpdateIntegrationBody['channels']>\ntype UpdateIntegrationChannelBody = UpdateIntegrationChannelsBody[string]\n\ntype Channels = Integration['channels']\ntype Channel = Integration['channels'][string]\n\nexport const prepareCreateIntegrationBody = async (\n integration: sdk.IntegrationDefinition,\n options: ZodToJsonOptions = {}\n): Promise<CreateIntegrationBody> => ({\n name: integration.name,\n version: integration.version,\n title: integration.title,\n description: integration.description,\n icon: integration.icon,\n readme: integration.readme,\n user: integration.user,\n identifier: integration.identifier,\n secrets: undefined,\n interfaces: {},\n configuration: integration.configuration\n ? {\n ...integration.configuration,\n schema: await utils.schema.mapZodToJsonSchema(integration.configuration, options),\n }\n : undefined,\n configurations: integration.configurations\n ? await utils.records.mapValuesAsync(integration.configurations, async (configuration) => ({\n ...configuration,\n schema: await utils.schema.mapZodToJsonSchema(configuration, options),\n }))\n : undefined,\n events: integration.events\n ? await utils.records.mapValuesAsync(integration.events, async (event) => ({\n ...event,\n schema: await utils.schema.mapZodToJsonSchema(event, options),\n }))\n : undefined,\n actions: integration.actions\n ? await utils.records.mapValuesAsync(integration.actions, async (action) => ({\n ...action,\n input: {\n ...action.input,\n schema: await utils.schema.mapZodToJsonSchema(action.input, options),\n },\n output: {\n ...action.output,\n schema: await utils.schema.mapZodToJsonSchema(action.output, options),\n },\n }))\n : undefined,\n channels: integration.channels\n ? await utils.records.mapValuesAsync(integration.channels, async (channel) => ({\n ...channel,\n messages: await utils.records.mapValuesAsync(channel.messages, async (message) => ({\n ...message,\n schema: await utils.schema.mapZodToJsonSchema(message, options),\n })),\n }))\n : undefined,\n states: integration.states\n ? await utils.records.mapValuesAsync(integration.states, async (state) => ({\n ...state,\n schema: await utils.schema.mapZodToJsonSchema(state, options),\n }))\n : undefined,\n entities: integration.entities\n ? await utils.records.mapValuesAsync(integration.entities, async (entity) => ({\n ...entity,\n schema: await utils.schema.mapZodToJsonSchema(entity, options),\n }))\n : undefined,\n})\n\nexport const prepareUpdateIntegrationBody = (\n localIntegration: UpdateIntegrationBody,\n remoteIntegration: Integration\n): UpdateIntegrationBody => {\n const actions = utils.records.setNullOnMissingValues(localIntegration.actions, remoteIntegration.actions)\n const events = utils.records.setNullOnMissingValues(localIntegration.events, remoteIntegration.events)\n const states = utils.records.setNullOnMissingValues(localIntegration.states, remoteIntegration.states)\n const entities = utils.records.setNullOnMissingValues(localIntegration.entities, remoteIntegration.entities)\n const user = {\n ...localIntegration.user,\n tags: utils.records.setNullOnMissingValues(localIntegration.user?.tags, remoteIntegration.user?.tags),\n }\n\n const channels = prepareUpdateIntegrationChannelsBody(localIntegration.channels ?? {}, remoteIntegration.channels)\n\n const interfaces = utils.records.setNullOnMissingValues(localIntegration.interfaces, remoteIntegration.interfaces)\n\n const configurations = utils.records.setNullOnMissingValues(\n localIntegration.configurations,\n remoteIntegration.configurations\n )\n\n return {\n ...localIntegration,\n actions,\n events,\n states,\n entities,\n user,\n channels,\n interfaces,\n configurations,\n }\n}\n\nconst prepareUpdateIntegrationChannelsBody = (\n localChannels: UpdateIntegrationChannelsBody,\n remoteChannels: Channels\n): UpdateIntegrationChannelsBody => {\n const channelBody: UpdateIntegrationChannelsBody = {}\n\n const zipped = utils.records.zipObjects(localChannels, remoteChannels)\n for (const [channelName, [localChannel, remoteChannel]] of Object.entries(zipped)) {\n if (localChannel && remoteChannel) {\n // channel has to be updated\n channelBody[channelName] = prepareUpdateIntegrationChannelBody(localChannel, remoteChannel)\n } else if (localChannel) {\n // channel has to be created\n channelBody[channelName] = localChannel\n continue\n } else if (remoteChannel) {\n // channel has to be deleted\n channelBody[channelName] = null\n continue\n }\n }\n\n return channelBody\n}\n\nconst prepareUpdateIntegrationChannelBody = (\n localChannel: UpdateIntegrationChannelBody,\n remoteChannel: Channel\n): UpdateIntegrationChannelBody => ({\n ...localChannel,\n messages: utils.records.setNullOnMissingValues(localChannel?.messages, remoteChannel.messages),\n message: {\n ...localChannel?.message,\n tags: utils.records.setNullOnMissingValues(localChannel?.message?.tags, remoteChannel.message.tags),\n },\n conversation: {\n ...localChannel?.conversation,\n tags: utils.records.setNullOnMissingValues(localChannel?.conversation?.tags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BAAuB,iBAAiB,YAAY,kBAAkB,UAAU;AAEjH,QAAM,iBAAiB,MAAM,QAAQ;AAAA,IACnC,iBAAiB;AAAA,IACjB,kBAAkB;AAAA,EACpB;AAEA,SAAO;AAAA,IACL,GAAG;AAAA,IACH;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAEA,MAAM,uCAAuC,CAC3C,eACA,mBACkC;AAClC,QAAM,cAA6C,CAAC;AAEpD,QAAM,SAAS,MAAM,QAAQ,WAAW,eAAe,cAAc;AACrE,aAAW,CAAC,aAAa,CAAC,cAAc,aAAa,CAAC,KAAK,OAAO,QAAQ,MAAM,GAAG;AACjF,QAAI,gBAAgB,eAAe;AAEjC,kBAAY,eAAe,oCAAoC,cAAc,aAAa;AAAA,IAC5F,WAAW,cAAc;AAEvB,kBAAY,eAAe;AAC3B;AAAA,IACF,WAAW,eAAe;AAExB,kBAAY,eAAe;AAC3B;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;AAEA,MAAM,sCAAsC,CAC1C,cACA,mBACkC;AAAA,EAClC,GAAG;AAAA,EACH,UAAU,MAAM,QAAQ,uBAAuB,cAAc,UAAU,cAAc,QAAQ;AAAA,EAC7F,SAAS;AAAA,IACP,GAAG,cAAc;AAAA,IACjB,MAAM,MAAM,QAAQ,uBAAuB,cAAc,SAAS,MAAM,cAAc,QAAQ,IAAI;AAAA,EACpG;AAAA,EACA,cAAc;AAAA,IACZ,GAAG,cAAc;AAAA,IACjB,MAAM,MAAM,QAAQ,uBAAuB,cAAc,cAAc,MAAM,cAAc,aAAa,IAAI;AAAA,EAC9G;AACF;",
6
6
  "names": []
7
7
  }
@@ -30,26 +30,26 @@ __export(interface_body_exports, {
30
30
  module.exports = __toCommonJS(interface_body_exports);
31
31
  var import_sdk = require("@botpress/sdk");
32
32
  var utils = __toESM(require("../utils"));
33
- const prepareCreateInterfaceBody = (intrface) => ({
33
+ const prepareCreateInterfaceBody = async (intrface) => ({
34
34
  name: intrface.name,
35
35
  version: intrface.version,
36
- entities: intrface.entities ? utils.records.mapValues(intrface.entities, (entity) => ({
36
+ entities: intrface.entities ? await utils.records.mapValuesAsync(intrface.entities, async (entity) => ({
37
37
  ...entity,
38
- schema: utils.schema.mapZodToJsonSchema(entity)
38
+ schema: await utils.schema.mapZodToJsonSchema(entity)
39
39
  })) : {},
40
- events: intrface.events ? utils.records.mapValues(intrface.events, (event) => ({
40
+ events: intrface.events ? await utils.records.mapValuesAsync(intrface.events, async (event) => ({
41
41
  ...event,
42
- schema: utils.schema.mapZodToJsonSchema(_dereference(intrface, event))
42
+ schema: await utils.schema.mapZodToJsonSchema(_dereference(intrface, event))
43
43
  })) : {},
44
- actions: intrface.actions ? utils.records.mapValues(intrface.actions, (action) => ({
44
+ actions: intrface.actions ? await utils.records.mapValuesAsync(intrface.actions, async (action) => ({
45
45
  ...action,
46
46
  input: {
47
47
  ...action.input,
48
- schema: utils.schema.mapZodToJsonSchema(_dereference(intrface, action.input))
48
+ schema: await utils.schema.mapZodToJsonSchema(_dereference(intrface, action.input))
49
49
  },
50
50
  output: {
51
51
  ...action.output,
52
- schema: utils.schema.mapZodToJsonSchema(_dereference(intrface, action.output))
52
+ schema: await utils.schema.mapZodToJsonSchema(_dereference(intrface, action.output))
53
53
  }
54
54
  })) : {}
55
55
  });
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/api/interface-body.ts"],
4
- "sourcesContent": ["import type { Client, Interface } from '@botpress/client'\nimport type * as sdk from '@botpress/sdk'\nimport { AnyZodObject, GenericZuiSchema, z } from '@botpress/sdk'\nimport * as utils from '../utils'\n\nexport type CreateInterfaceBody = Parameters<Client['createInterface']>[0]\nexport type UpdateInterfaceBody = Parameters<Client['updateInterface']>[0]\n\nexport const prepareCreateInterfaceBody = (intrface: sdk.InterfaceDeclaration): CreateInterfaceBody => ({\n name: intrface.name,\n version: intrface.version,\n entities: intrface.entities\n ? utils.records.mapValues(intrface.entities, (entity) => ({\n ...entity,\n schema: utils.schema.mapZodToJsonSchema(entity),\n }))\n : {},\n events: intrface.events\n ? utils.records.mapValues(intrface.events, (event) => ({\n ...event,\n schema: utils.schema.mapZodToJsonSchema(_dereference(intrface, event)),\n }))\n : {},\n actions: intrface.actions\n ? utils.records.mapValues(intrface.actions, (action) => ({\n ...action,\n input: {\n ...action.input,\n schema: utils.schema.mapZodToJsonSchema(_dereference(intrface, action.input)),\n },\n output: {\n ...action.output,\n schema: utils.schema.mapZodToJsonSchema(_dereference(intrface, action.output)),\n },\n }))\n : {},\n})\n\nexport const prepareUpdateInterfaceBody = (\n localInterface: UpdateInterfaceBody,\n remoteInterface: Interface\n): UpdateInterfaceBody => {\n const actions = utils.records.setNullOnMissingValues(localInterface.actions, remoteInterface.actions)\n const events = utils.records.setNullOnMissingValues(localInterface.events, remoteInterface.events)\n const entities = utils.records.setNullOnMissingValues(localInterface.entities, remoteInterface.entities)\n return {\n ...localInterface,\n entities,\n actions,\n events,\n }\n}\n\nconst _dereference = (\n intrface: sdk.InterfaceDeclaration,\n { schema }: { schema: GenericZuiSchema<Record<string, z.ZodRef>, AnyZodObject> }\n): { schema: AnyZodObject } => {\n const typeArguments = utils.records.mapValues(intrface.entities, (_, entityName) => z.ref(entityName))\n return { schema: schema(typeArguments) }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,iBAAkD;AAClD,YAAuB;AAKhB,MAAM,6BAA6B,CAAC,cAA6D;AAAA,EACtG,MAAM,SAAS;AAAA,EACf,SAAS,SAAS;AAAA,EAClB,UAAU,SAAS,WACf,MAAM,QAAQ,UAAU,SAAS,UAAU,CAAC,YAAY;AAAA,IACtD,GAAG;AAAA,IACH,QAAQ,MAAM,OAAO,mBAAmB,MAAM;AAAA,EAChD,EAAE,IACF,CAAC;AAAA,EACL,QAAQ,SAAS,SACb,MAAM,QAAQ,UAAU,SAAS,QAAQ,CAAC,WAAW;AAAA,IACnD,GAAG;AAAA,IACH,QAAQ,MAAM,OAAO,mBAAmB,aAAa,UAAU,KAAK,CAAC;AAAA,EACvE,EAAE,IACF,CAAC;AAAA,EACL,SAAS,SAAS,UACd,MAAM,QAAQ,UAAU,SAAS,SAAS,CAAC,YAAY;AAAA,IACrD,GAAG;AAAA,IACH,OAAO;AAAA,MACL,GAAG,OAAO;AAAA,MACV,QAAQ,MAAM,OAAO,mBAAmB,aAAa,UAAU,OAAO,KAAK,CAAC;AAAA,IAC9E;AAAA,IACA,QAAQ;AAAA,MACN,GAAG,OAAO;AAAA,MACV,QAAQ,MAAM,OAAO,mBAAmB,aAAa,UAAU,OAAO,MAAM,CAAC;AAAA,IAC/E;AAAA,EACF,EAAE,IACF,CAAC;AACP;AAEO,MAAM,6BAA6B,CACxC,gBACA,oBACwB;AACxB,QAAM,UAAU,MAAM,QAAQ,uBAAuB,eAAe,SAAS,gBAAgB,OAAO;AACpG,QAAM,SAAS,MAAM,QAAQ,uBAAuB,eAAe,QAAQ,gBAAgB,MAAM;AACjG,QAAM,WAAW,MAAM,QAAQ,uBAAuB,eAAe,UAAU,gBAAgB,QAAQ;AACvG,SAAO;AAAA,IACL,GAAG;AAAA,IACH;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAEA,MAAM,eAAe,CACnB,UACA,EAAE,OAAO,MACoB;AAC7B,QAAM,gBAAgB,MAAM,QAAQ,UAAU,SAAS,UAAU,CAAC,GAAG,eAAe,aAAE,IAAI,UAAU,CAAC;AACrG,SAAO,EAAE,QAAQ,OAAO,aAAa,EAAE;AACzC;",
4
+ "sourcesContent": ["import type { Client, Interface } from '@botpress/client'\nimport type * as sdk from '@botpress/sdk'\nimport { AnyZodObject, GenericZuiSchema, z } from '@botpress/sdk'\nimport * as utils from '../utils'\n\nexport type CreateInterfaceBody = Parameters<Client['createInterface']>[0]\nexport type UpdateInterfaceBody = Parameters<Client['updateInterface']>[0]\n\nexport const prepareCreateInterfaceBody = async (intrface: sdk.InterfaceDeclaration): Promise<CreateInterfaceBody> => ({\n name: intrface.name,\n version: intrface.version,\n entities: intrface.entities\n ? await utils.records.mapValuesAsync(intrface.entities, async (entity) => ({\n ...entity,\n schema: await utils.schema.mapZodToJsonSchema(entity),\n }))\n : {},\n events: intrface.events\n ? await utils.records.mapValuesAsync(intrface.events, async (event) => ({\n ...event,\n schema: await utils.schema.mapZodToJsonSchema(_dereference(intrface, event)),\n }))\n : {},\n actions: intrface.actions\n ? await utils.records.mapValuesAsync(intrface.actions, async (action) => ({\n ...action,\n input: {\n ...action.input,\n schema: await utils.schema.mapZodToJsonSchema(_dereference(intrface, action.input)),\n },\n output: {\n ...action.output,\n schema: await utils.schema.mapZodToJsonSchema(_dereference(intrface, action.output)),\n },\n }))\n : {},\n})\n\nexport const prepareUpdateInterfaceBody = (\n localInterface: UpdateInterfaceBody,\n remoteInterface: Interface\n): UpdateInterfaceBody => {\n const actions = utils.records.setNullOnMissingValues(localInterface.actions, remoteInterface.actions)\n const events = utils.records.setNullOnMissingValues(localInterface.events, remoteInterface.events)\n const entities = utils.records.setNullOnMissingValues(localInterface.entities, remoteInterface.entities)\n return {\n ...localInterface,\n entities,\n actions,\n events,\n }\n}\n\nconst _dereference = (\n intrface: sdk.InterfaceDeclaration,\n { schema }: { schema: GenericZuiSchema<Record<string, z.ZodRef>, AnyZodObject> }\n): { schema: AnyZodObject } => {\n const typeArguments = utils.records.mapValues(intrface.entities, (_, entityName) => z.ref(entityName))\n return { schema: schema(typeArguments) }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,iBAAkD;AAClD,YAAuB;AAKhB,MAAM,6BAA6B,OAAO,cAAsE;AAAA,EACrH,MAAM,SAAS;AAAA,EACf,SAAS,SAAS;AAAA,EAClB,UAAU,SAAS,WACf,MAAM,MAAM,QAAQ,eAAe,SAAS,UAAU,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7 @@ var import_typings = require("./typings");
45
45
  var import_integration_secret2 = require("./integration-secret");
46
46
  const INTEGRATION_JSON = "integration.json";
47
47
  const generateIntegrationImplementationTypings = async (sdkIntegration, implementationTypingsPath) => {
48
- const integration = mapIntegration.from.sdk(sdkIntegration);
48
+ const integration = await mapIntegration.from.sdk(sdkIntegration);
49
49
  const indexModule = await import_integration_implementation.IntegrationImplementationIndexModule.create(integration);
50
50
  indexModule.unshift(implementationTypingsPath);
51
51
  return indexModule.flatten();
@@ -71,7 +71,7 @@ const generateIntegrationInstance = async (anyIntegration, installPath) => {
71
71
  if ("id" in anyIntegration) {
72
72
  integration = mapIntegration.from.client(anyIntegration);
73
73
  } else {
74
- integration = mapIntegration.from.sdk(anyIntegration);
74
+ integration = await mapIntegration.from.sdk(anyIntegration);
75
75
  }
76
76
  const indexModule = await import_integration_instance.IntegrationInstanceIndexModule.create(integration);
77
77
  const dirname = utils.casing.to.kebabCase(integration.name);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/code-generation/index.ts"],
4
- "sourcesContent": ["import type * as client from '@botpress/client'\nimport type * as sdk from '@botpress/sdk'\nimport pathlib from 'path'\nimport * as utils from '../utils'\nimport { GENERATED_HEADER, INDEX_FILE } from './const'\nimport { IntegrationImplementationIndexModule } from './integration-implementation'\nimport { IntegrationInstanceIndexModule } from './integration-instance'\nimport { IntegrationSecretIndexModule } from './integration-secret'\nimport * as mapIntegration from './map-integration'\nimport type * as types from './typings'\n\nexport { File } from './typings'\nexport { secretEnvVariableName } from './integration-secret'\nexport const INTEGRATION_JSON = 'integration.json'\n\nexport const generateIntegrationImplementationTypings = async (\n sdkIntegration: sdk.IntegrationDefinition,\n implementationTypingsPath: string\n): Promise<types.File[]> => {\n const integration = mapIntegration.from.sdk(sdkIntegration)\n const indexModule = await IntegrationImplementationIndexModule.create(integration)\n indexModule.unshift(implementationTypingsPath)\n return indexModule.flatten()\n}\n\nexport const generateIntegrationSecrets = async (\n sdkIntegration: sdk.IntegrationDefinition,\n secretsPath: string\n): Promise<types.File[]> => {\n const indexModule = await IntegrationSecretIndexModule.create(sdkIntegration)\n indexModule.unshift(secretsPath)\n return indexModule.flatten()\n}\n\nexport const generateIntegrationIndex = async (\n implementationTypingsPath: string,\n implementationSecretsPath: string\n): Promise<types.File> => {\n let content = ''\n content += `export * from './${implementationTypingsPath}'\\n`\n content += `export * from './${implementationSecretsPath}'\\n`\n return {\n path: INDEX_FILE,\n content,\n }\n}\n\nexport type IntegrationInstanceJson = {\n name: string\n version: string\n id: string | null\n}\n\nexport const generateIntegrationInstance = async (\n anyIntegration: client.Integration | sdk.IntegrationDefinition,\n installPath: string\n): Promise<types.File[]> => {\n let integration: types.IntegrationDefinition\n if ('id' in anyIntegration) {\n integration = mapIntegration.from.client(anyIntegration)\n } else {\n integration = mapIntegration.from.sdk(anyIntegration)\n }\n\n const indexModule = await IntegrationInstanceIndexModule.create(integration)\n const dirname = utils.casing.to.kebabCase(integration.name)\n indexModule.unshift(installPath, dirname)\n const files = indexModule.flatten()\n\n const { name, version, id } = integration\n const json: IntegrationInstanceJson = {\n name,\n version,\n id,\n }\n files.push({\n path: pathlib.join(installPath, dirname, INTEGRATION_JSON),\n content: JSON.stringify(json, null, 2),\n })\n\n return files\n}\n\nexport const generateBotIndex = async (\n installPath: string,\n instances: { name: string; dirname: string }[]\n): Promise<types.File> => {\n const lines: string[] = [\n GENERATED_HEADER,\n \"import * as sdk from '@botpress/sdk'\",\n ...instances.map((i) => `import * as ${utils.casing.to.camelCase(i.name)} from './${installPath}/${i.dirname}'`),\n ...instances.map((i) => `export * as ${utils.casing.to.camelCase(i.name)} from './${installPath}/${i.dirname}'`),\n '',\n 'type TIntegrations = {',\n ...instances.map(\n (i) => ` \"${i.name}\": ${utils.casing.to.camelCase(i.name)}.T${utils.casing.to.pascalCase(i.dirname)}`\n ),\n '}',\n '',\n 'type BaseStates = sdk.Bot extends sdk.Bot<any, infer TStates, any> ? TStates : never',\n 'type BaseEvents = sdk.Bot extends sdk.Bot<any, any, infer TEvents> ? TEvents : never',\n '',\n 'export class Bot<',\n ' TStates extends BaseStates,',\n ' TEvents extends BaseEvents',\n '> extends sdk.Bot<',\n ' TIntegrations,',\n ' TStates,',\n ' TEvents',\n '> {}',\n ]\n\n return {\n path: INDEX_FILE,\n content: lines.join('\\n'),\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,kBAAoB;AACpB,YAAuB;AACvB,mBAA6C;AAC7C,wCAAqD;AACrD,kCAA+C;AAC/C,gCAA6C;AAC7C,qBAAgC;AAGhC,qBAAqB;AACrB,IAAAA,6BAAsC;AAC/B,MAAM,mBAAmB;AAEzB,MAAM,2CAA2C,OACtD,gBACA,8BAC0B;AAC1B,QAAM,cAAc,eAAe,KAAK,IAAI,cAAc;AAC1D,QAAM,cAAc,MAAM,uEAAqC,OAAO,WAAW;AACjF,cAAY,QAAQ,yBAAyB;AAC7C,SAAO,YAAY,QAAQ;AAC7B;AAEO,MAAM,6BAA6B,OACxC,gBACA,gBAC0B;AAC1B,QAAM,cAAc,MAAM,uDAA6B,OAAO,cAAc;AAC5E,cAAY,QAAQ,WAAW;AAC/B,SAAO,YAAY,QAAQ;AAC7B;AAEO,MAAM,2BAA2B,OACtC,2BACA,8BACwB;AACxB,MAAI,UAAU;AACd,aAAW,oBAAoB;AAAA;AAC/B,aAAW,oBAAoB;AAAA;AAC/B,SAAO;AAAA,IACL,MAAM;AAAA,IACN;AAAA,EACF;AACF;AAQO,MAAM,8BAA8B,OACzC,gBACA,gBAC0B;AAC1B,MAAI;AACJ,MAAI,QAAQ,gBAAgB;AAC1B,kBAAc,eAAe,KAAK,OAAO,cAAc;AAAA,EACzD,OAAO;AACL,kBAAc,eAAe,KAAK,IAAI,cAAc;AAAA,EACtD;AAEA,QAAM,cAAc,MAAM,2DAA+B,OAAO,WAAW;AAC3E,QAAM,UAAU,MAAM,OAAO,GAAG,UAAU,YAAY,IAAI;AAC1D,cAAY,QAAQ,aAAa,OAAO;AACxC,QAAM,QAAQ,YAAY,QAAQ;AAElC,QAAM,EAAE,MAAM,SAAS,GAAG,IAAI;AAC9B,QAAM,OAAgC;AAAA,IACpC;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACA,QAAM,KAAK;AAAA,IACT,MAAM,YAAAC,QAAQ,KAAK,aAAa,SAAS,gBAAgB;AAAA,IACzD,SAAS,KAAK,UAAU,MAAM,MAAM,CAAC;AAAA,EACvC,CAAC;AAED,SAAO;AACT;AAEO,MAAM,mBAAmB,OAC9B,aACA,cACwB;AACxB,QAAM,QAAkB;AAAA,IACtB;AAAA,IACA;AAAA,IACA,GAAG,UAAU,IAAI,CAAC,MAAM,eAAe,MAAM,OAAO,GAAG,UAAU,EAAE,IAAI,aAAa,eAAe,EAAE,UAAU;AAAA,IAC/G,GAAG,UAAU,IAAI,CAAC,MAAM,eAAe,MAAM,OAAO,GAAG,UAAU,EAAE,IAAI,aAAa,eAAe,EAAE,UAAU;AAAA,IAC/G;AAAA,IACA;AAAA,IACA,GAAG,UAAU;AAAA,MACX,CAAC,MAAM,MAAM,EAAE,UAAU,MAAM,OAAO,GAAG,UAAU,EAAE,IAAI,MAAM,MAAM,OAAO,GAAG,WAAW,EAAE,OAAO;AAAA,IACrG;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,SAAO;AAAA,IACL,MAAM;AAAA,IACN,SAAS,MAAM,KAAK,IAAI;AAAA,EAC1B;AACF;",
4
+ "sourcesContent": ["import type * as client from '@botpress/client'\nimport type * as sdk from '@botpress/sdk'\nimport pathlib from 'path'\nimport * as utils from '../utils'\nimport { GENERATED_HEADER, INDEX_FILE } from './const'\nimport { IntegrationImplementationIndexModule } from './integration-implementation'\nimport { IntegrationInstanceIndexModule } from './integration-instance'\nimport { IntegrationSecretIndexModule } from './integration-secret'\nimport * as mapIntegration from './map-integration'\nimport type * as types from './typings'\n\nexport { File } from './typings'\nexport { secretEnvVariableName } from './integration-secret'\nexport const INTEGRATION_JSON = 'integration.json'\n\nexport const generateIntegrationImplementationTypings = async (\n sdkIntegration: sdk.IntegrationDefinition,\n implementationTypingsPath: string\n): Promise<types.File[]> => {\n const integration = await mapIntegration.from.sdk(sdkIntegration)\n const indexModule = await IntegrationImplementationIndexModule.create(integration)\n indexModule.unshift(implementationTypingsPath)\n return indexModule.flatten()\n}\n\nexport const generateIntegrationSecrets = async (\n sdkIntegration: sdk.IntegrationDefinition,\n secretsPath: string\n): Promise<types.File[]> => {\n const indexModule = await IntegrationSecretIndexModule.create(sdkIntegration)\n indexModule.unshift(secretsPath)\n return indexModule.flatten()\n}\n\nexport const generateIntegrationIndex = async (\n implementationTypingsPath: string,\n implementationSecretsPath: string\n): Promise<types.File> => {\n let content = ''\n content += `export * from './${implementationTypingsPath}'\\n`\n content += `export * from './${implementationSecretsPath}'\\n`\n return {\n path: INDEX_FILE,\n content,\n }\n}\n\nexport type IntegrationInstanceJson = {\n name: string\n version: string\n id: string | null\n}\n\nexport const generateIntegrationInstance = async (\n anyIntegration: client.Integration | sdk.IntegrationDefinition,\n installPath: string\n): Promise<types.File[]> => {\n let integration: types.IntegrationDefinition\n if ('id' in anyIntegration) {\n integration = mapIntegration.from.client(anyIntegration)\n } else {\n integration = await mapIntegration.from.sdk(anyIntegration)\n }\n\n const indexModule = await IntegrationInstanceIndexModule.create(integration)\n const dirname = utils.casing.to.kebabCase(integration.name)\n indexModule.unshift(installPath, dirname)\n const files = indexModule.flatten()\n\n const { name, version, id } = integration\n const json: IntegrationInstanceJson = {\n name,\n version,\n id,\n }\n files.push({\n path: pathlib.join(installPath, dirname, INTEGRATION_JSON),\n content: JSON.stringify(json, null, 2),\n })\n\n return files\n}\n\nexport const generateBotIndex = async (\n installPath: string,\n instances: { name: string; dirname: string }[]\n): Promise<types.File> => {\n const lines: string[] = [\n GENERATED_HEADER,\n \"import * as sdk from '@botpress/sdk'\",\n ...instances.map((i) => `import * as ${utils.casing.to.camelCase(i.name)} from './${installPath}/${i.dirname}'`),\n ...instances.map((i) => `export * as ${utils.casing.to.camelCase(i.name)} from './${installPath}/${i.dirname}'`),\n '',\n 'type TIntegrations = {',\n ...instances.map(\n (i) => ` \"${i.name}\": ${utils.casing.to.camelCase(i.name)}.T${utils.casing.to.pascalCase(i.dirname)}`\n ),\n '}',\n '',\n 'type BaseStates = sdk.Bot extends sdk.Bot<any, infer TStates, any> ? TStates : never',\n 'type BaseEvents = sdk.Bot extends sdk.Bot<any, any, infer TEvents> ? TEvents : never',\n '',\n 'export class Bot<',\n ' TStates extends BaseStates,',\n ' TEvents extends BaseEvents',\n '> extends sdk.Bot<',\n ' TIntegrations,',\n ' TStates,',\n ' TEvents',\n '> {}',\n ]\n\n return {\n path: INDEX_FILE,\n content: lines.join('\\n'),\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,kBAAoB;AACpB,YAAuB;AACvB,mBAA6C;AAC7C,wCAAqD;AACrD,kCAA+C;AAC/C,gCAA6C;AAC7C,qBAAgC;AAGhC,qBAAqB;AACrB,IAAAA,6BAAsC;AAC/B,MAAM,mBAAmB;AAEzB,MAAM,2CAA2C,OACtD,gBACA,8BAC0B;AAC1B,QAAM,cAAc,MAAM,eAAe,KAAK,IAAI,cAAc;AAChE,QAAM,cAAc,MAAM,uEAAqC,OAAO,WAAW;AACjF,cAAY,QAAQ,yBAAyB;AAC7C,SAAO,YAAY,QAAQ;AAC7B;AAEO,MAAM,6BAA6B,OACxC,gBACA,gBAC0B;AAC1B,QAAM,cAAc,MAAM,uDAA6B,OAAO,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E,UAAU,MAAM,OAAO,GAAG,UAAU,EAAE,IAAI,MAAM,MAAM,OAAO,GAAG,WAAW,EAAE,OAAO;AAAA,IACrG;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,SAAO;AAAA,IACL,MAAM;AAAA,IACN,SAAS,MAAM,KAAK,IAAI;AAAA,EAC1B;AACF;",
6
6
  "names": ["import_integration_secret", "pathlib"]
7
7
  }
@@ -30,7 +30,7 @@ module.exports = __toCommonJS(map_integration_exports);
30
30
  var utils = __toESM(require("../utils"));
31
31
  var from;
32
32
  ((from2) => {
33
- from2.sdk = (i) => {
33
+ from2.sdk = async (i) => {
34
34
  return {
35
35
  id: null,
36
36
  name: i.name,
@@ -39,15 +39,15 @@ var from;
39
39
  tags: i.user?.tags ?? {},
40
40
  creation: i.user?.creation ?? { enabled: false, requiredTags: [] }
41
41
  },
42
- configuration: i.configuration ? _mapSchema(i.configuration) : { schema: {} },
43
- configurations: i.configurations ? utils.records.mapValues(i.configurations, _mapSchema) : {},
44
- events: i.events ? utils.records.mapValues(i.events, _mapSchema) : {},
45
- states: i.states ? utils.records.mapValues(i.states, _mapSchema) : {},
46
- actions: i.actions ? utils.records.mapValues(i.actions, (a) => ({
47
- input: _mapSchema(a.input),
48
- output: _mapSchema(a.output)
42
+ configuration: i.configuration ? await _mapSchema(i.configuration) : { schema: {} },
43
+ configurations: i.configurations ? await utils.records.mapValuesAsync(i.configurations, _mapSchema) : {},
44
+ events: i.events ? await utils.records.mapValuesAsync(i.events, _mapSchema) : {},
45
+ states: i.states ? await utils.records.mapValuesAsync(i.states, _mapSchema) : {},
46
+ actions: i.actions ? await utils.records.mapValuesAsync(i.actions, async (a) => ({
47
+ input: await _mapSchema(a.input),
48
+ output: await _mapSchema(a.output)
49
49
  })) : {},
50
- channels: i.channels ? utils.records.mapValues(i.channels, (c) => ({
50
+ channels: i.channels ? await utils.records.mapValuesAsync(i.channels, async (c) => ({
51
51
  conversation: {
52
52
  tags: c.conversation?.tags ?? {},
53
53
  creation: c.conversation?.creation ?? { enabled: false, requiredTags: [] }
@@ -55,18 +55,18 @@ var from;
55
55
  message: {
56
56
  tags: c.message?.tags ?? {}
57
57
  },
58
- messages: utils.records.mapValues(c.messages, _mapSchema)
58
+ messages: await utils.records.mapValuesAsync(c.messages, _mapSchema)
59
59
  })) : {},
60
- entities: i.entities ? utils.records.mapValues(i.entities, _mapSchema) : {}
60
+ entities: i.entities ? await utils.records.mapValuesAsync(i.entities, _mapSchema) : {}
61
61
  };
62
62
  };
63
63
  from2.client = (i) => {
64
64
  const { id, name, version, configuration, configurations, channels, states, events, actions, user, entities } = i;
65
65
  return { id, name, version, configuration, configurations, channels, states, events, actions, user, entities };
66
66
  };
67
- const _mapSchema = (x) => ({
67
+ const _mapSchema = async (x) => ({
68
68
  ...x,
69
- schema: utils.schema.mapZodToJsonSchema(x)
69
+ schema: await utils.schema.mapZodToJsonSchema(x)
70
70
  });
71
71
  })(from || (from = {}));
72
72
  // Annotate the CommonJS export names for ESM import in node:
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/code-generation/map-integration.ts"],
4
- "sourcesContent": ["import type * as client from '@botpress/client'\nimport type * as sdk from '@botpress/sdk'\nimport { z } from '@botpress/sdk'\nimport * as utils from '../utils'\nimport * as types from './typings'\n\nexport namespace from {\n export const sdk = (i: sdk.IntegrationDefinition): types.IntegrationDefinition => {\n return {\n id: null,\n name: i.name,\n version: i.version,\n user: {\n tags: i.user?.tags ?? {},\n creation: i.user?.creation ?? { enabled: false, requiredTags: [] },\n },\n configuration: i.configuration ? _mapSchema(i.configuration) : { schema: {} },\n configurations: i.configurations ? utils.records.mapValues(i.configurations, _mapSchema) : {},\n events: i.events ? utils.records.mapValues(i.events, _mapSchema) : {},\n states: i.states ? utils.records.mapValues(i.states, _mapSchema) : {},\n actions: i.actions\n ? utils.records.mapValues(i.actions, (a) => ({\n input: _mapSchema(a.input),\n output: _mapSchema(a.output),\n }))\n : {},\n channels: i.channels\n ? utils.records.mapValues(i.channels, (c) => ({\n conversation: {\n tags: c.conversation?.tags ?? {},\n creation: c.conversation?.creation ?? { enabled: false, requiredTags: [] },\n },\n message: {\n tags: c.message?.tags ?? {},\n },\n messages: utils.records.mapValues(c.messages, _mapSchema),\n }))\n : {},\n entities: i.entities ? utils.records.mapValues(i.entities, _mapSchema) : {},\n }\n }\n\n export const client = (i: client.Integration): types.IntegrationDefinition => {\n const { id, name, version, configuration, configurations, channels, states, events, actions, user, entities } = i\n return { id, name, version, configuration, configurations, channels, states, events, actions, user, entities }\n }\n\n const _mapSchema = <T extends { schema: z.ZodObject<any> }>(\n x: T\n ): utils.types.Merge<T, { schema: ReturnType<typeof utils.schema.mapZodToJsonSchema> }> => ({\n ...x,\n schema: utils.schema.mapZodToJsonSchema(x),\n })\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,YAAuB;AAGhB,IAAU;AAAA,CAAV,CAAUA,UAAV;AACE,EAAMA,MAAA,MAAM,CAAC,MAA8D;AAChF,WAAO;AAAA,MACL,IAAI;AAAA,MACJ,MAAM,EAAE;AAAA,MACR,SAAS,EAAE;AAAA,MACX,MAAM;AAAA,QACJ,MAAM,EAAE,MAAM,QAAQ,CAAC;AAAA,QACvB,UAAU,EAAE,MAAM,YAAY,EAAE,SAAS,OAAO,cAAc,CAAC,EAAE;AAAA,MACnE;AAAA,MACA,eAAe,EAAE,gBAAgB,WAAW,EAAE,aAAa,IAAI,EAAE,QAAQ,CAAC,EAAE;AAAA,MAC5E,gBAAgB,EAAE,iBAAiB,MAAM,QAAQ,UAAU,EAAE,gBAAgB,UAAU,IAAI,CAAC;AAAA,MAC5F,QAAQ,EAAE,SAAS,MAAM,QAAQ,UAAU,EAAE,QAAQ,UAAU,IAAI,CAAC;AAAA,MACpE,QAAQ,EAAE,SAAS,MAAM,QAAQ,UAAU,EAAE,QAAQ,UAAU,IAAI,CAAC;AAAA,MACpE,SAAS,EAAE,UACP,MAAM,QAAQ,UAAU,EAAE,SAAS,CAAC,OAAO;AAAA,QACzC,OAAO,WAAW,EAAE,KAAK;AAAA,QACzB,QAAQ,WAAW,EAAE,MAAM;AAAA,MAC7B,EAAE,IACF,CAAC;AAAA,MACL,UAAU,EAAE,WACR,MAAM,QAAQ,UAAU,EAAE,UAAU,CAAC,OAAO;AAAA,QAC1C,cAAc;AAAA,UACZ,MAAM,EAAE,cAAc,QAAQ,CAAC;AAAA,UAC/B,UAAU,EAAE,cAAc,YAAY,EAAE,SAAS,OAAO,cAAc,CAAC,EAAE;AAAA,QAC3E;AAAA,QACA,SAAS;AAAA,UACP,MAAM,EAAE,SAAS,QAAQ,CAAC;AAAA,QAC5B;AAAA,QACA,UAAU,MAAM,QAAQ,UAAU,EAAE,UAAU,UAAU;AAAA,MAC1D,EAAE,IACF,CAAC;AAAA,MACL,UAAU,EAAE,WAAW,MAAM,QAAQ,UAAU,EAAE,UAAU,UAAU,IAAI,CAAC;AAAA,IAC5E;AAAA,EACF;AAEO,EAAMA,MAAA,SAAS,CAAC,MAAuD;AAC5E,UAAM,EAAE,IAAI,MAAM,SAAS,eAAe,gBAAgB,UAAU,QAAQ,QAAQ,SAAS,MAAM,SAAS,IAAI;AAChH,WAAO,EAAE,IAAI,MAAM,SAAS,eAAe,gBAAgB,UAAU,QAAQ,QAAQ,SAAS,MAAM,SAAS;AAAA,EAC/G;AAEA,QAAM,aAAa,CACjB,OAC0F;AAAA,IAC1F,GAAG;AAAA,IACH,QAAQ,MAAM,OAAO,mBAAmB,CAAC;AAAA,EAC3C;AAAA,GA9Ce;",
4
+ "sourcesContent": ["import type * as client from '@botpress/client'\nimport type * as sdk from '@botpress/sdk'\nimport { z } from '@botpress/sdk'\nimport * as utils from '../utils'\nimport * as types from './typings'\n\nexport namespace from {\n export const sdk = async (i: sdk.IntegrationDefinition): Promise<types.IntegrationDefinition> => {\n return {\n id: null,\n name: i.name,\n version: i.version,\n user: {\n tags: i.user?.tags ?? {},\n creation: i.user?.creation ?? { enabled: false, requiredTags: [] },\n },\n configuration: i.configuration ? await _mapSchema(i.configuration) : { schema: {} },\n configurations: i.configurations ? await utils.records.mapValuesAsync(i.configurations, _mapSchema) : {},\n events: i.events ? await utils.records.mapValuesAsync(i.events, _mapSchema) : {},\n states: i.states ? await utils.records.mapValuesAsync(i.states, _mapSchema) : {},\n actions: i.actions\n ? await utils.records.mapValuesAsync(i.actions, async (a) => ({\n input: await _mapSchema(a.input),\n output: await _mapSchema(a.output),\n }))\n : {},\n channels: i.channels\n ? await utils.records.mapValuesAsync(i.channels, async (c) => ({\n conversation: {\n tags: c.conversation?.tags ?? {},\n creation: c.conversation?.creation ?? { enabled: false, requiredTags: [] },\n },\n message: {\n tags: c.message?.tags ?? {},\n },\n messages: await utils.records.mapValuesAsync(c.messages, _mapSchema),\n }))\n : {},\n entities: i.entities ? await utils.records.mapValuesAsync(i.entities, _mapSchema) : {},\n }\n }\n\n export const client = (i: client.Integration): types.IntegrationDefinition => {\n const { id, name, version, configuration, configurations, channels, states, events, actions, user, entities } = i\n return { id, name, version, configuration, configurations, channels, states, events, actions, user, entities }\n }\n\n const _mapSchema = async <T extends { schema: z.ZodObject<any> }>(\n x: T\n ): Promise<utils.types.Merge<T, { schema: Awaited<ReturnType<typeof utils.schema.mapZodToJsonSchema>> }>> => ({\n ...x,\n schema: await utils.schema.mapZodToJsonSchema(x),\n })\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,YAAuB;AAGhB,IAAU;AAAA,CAAV,CAAUA,UAAV;AACE,EAAMA,MAAA,MAAM,OAAO,MAAuE;AAC/F,WAAO;AAAA,MACL,IAAI;AAAA,MACJ,MAAM,EAAE;AAAA,MACR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AC,MAAuD;AAC5E,UAAM,EAAE,IAAI,MAAM,SAAS,eAAe,gBAAgB,UAAU,QAAQ,QAAQ,SAAS,MAAM,SAAS,IAAI;AAChH,WAAO,EAAE,IAAI,MAAM,SAAS,eAAe,gBAAgB,UAAU,QAAQ,QAAQ,SAAS,MAAM,SAAS;AAAA,EAC/G;AAEA,QAAM,aAAa,OACjB,OAC4G;AAAA,IAC5G,GAAG;AAAA,IACH,QAAQ,MAAM,MAAM,OAAO,mBAAmB,CAAC;AAAA,EACjD;AAAA,GA9Ce;",
6
6
  "names": ["from"]
7
7
  }
@@ -90,7 +90,7 @@ class DeployCommand extends import_project_command.ProjectCommand {
90
90
  this.logger.log("Aborted");
91
91
  return;
92
92
  }
93
- let createBody = (0, import_integration_body.prepareCreateIntegrationBody)(integrationDef);
93
+ let createBody = await (0, import_integration_body.prepareCreateIntegrationBody)(integrationDef);
94
94
  createBody = {
95
95
  ...createBody,
96
96
  interfaces: await this._formatInterfacesImplStatements(api, integrationDef),
@@ -161,7 +161,7 @@ class DeployCommand extends import_project_command.ProjectCommand {
161
161
  this.logger.log("Aborted");
162
162
  return;
163
163
  }
164
- const createBody = (0, import_interface_body.prepareCreateInterfaceBody)(interfaceDeclaration);
164
+ const createBody = await (0, import_interface_body.prepareCreateInterfaceBody)(interfaceDeclaration);
165
165
  const startedMessage = `Deploying interface ${import_chalk.default.bold(name)} v${version}...`;
166
166
  const successMessage = "Interface deployed";
167
167
  if (intrface) {
@@ -259,7 +259,7 @@ class DeployCommand extends import_project_command.ProjectCommand {
259
259
  const integrationInstances = await this.fetchBotIntegrationInstances(botImpl, api);
260
260
  const updateBotBody = (0, import_bot_body.prepareUpdateBotBody)(
261
261
  {
262
- ...(0, import_bot_body.prepareCreateBotBody)(botImpl),
262
+ ...await (0, import_bot_body.prepareCreateBotBody)(botImpl),
263
263
  id: bot.id,
264
264
  code,
265
265
  integrations: integrationInstances
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/command-implementations/deploy-command.ts"],
4
- "sourcesContent": ["import type * as client from '@botpress/client'\nimport type * as sdk from '@botpress/sdk'\nimport chalk from 'chalk'\nimport * as fs from 'fs'\nimport semver from 'semver'\nimport { prepareCreateBotBody, prepareUpdateBotBody } from '../api/bot-body'\nimport type { ApiClient } from '../api/client'\nimport {\n CreateIntegrationBody,\n prepareUpdateIntegrationBody,\n prepareCreateIntegrationBody,\n} from '../api/integration-body'\nimport { CreateInterfaceBody, prepareCreateInterfaceBody, prepareUpdateInterfaceBody } from '../api/interface-body'\nimport type commandDefinitions from '../command-definitions'\nimport * as errors from '../errors'\nimport * as utils from '../utils'\nimport { BuildCommand } from './build-command'\nimport { ProjectCommand } from './project-command'\n\nexport type DeployCommandDefinition = typeof commandDefinitions.deploy\nexport class DeployCommand extends ProjectCommand<DeployCommandDefinition> {\n public async run(): Promise<void> {\n const api = await this.ensureLoginAndCreateClient(this.argv)\n\n if (!this.argv.noBuild) {\n await this._runBuild() // This ensures the bundle is always synced with source code\n }\n\n const projectDef = await this.readProjectDefinitionFromFS()\n\n if (projectDef.type === 'integration') {\n return this._deployIntegration(api, projectDef.definition)\n }\n if (projectDef.type === 'interface') {\n return this._deployInterface(api, projectDef.definition)\n }\n return this._deployBot(api, this.argv.botId, this.argv.createNewBot)\n }\n\n private async _runBuild() {\n return new BuildCommand(this.api, this.prompt, this.logger, this.argv).run()\n }\n\n private async _deployIntegration(api: ApiClient, integrationDef: sdk.IntegrationDefinition) {\n const outfile = this.projectPaths.abs.outFile\n const code = await fs.promises.readFile(outfile, 'utf-8')\n\n integrationDef = await this._manageWorkspaceHandle(api, integrationDef)\n\n const { name, version, icon: iconRelativeFilePath, readme: readmeRelativeFilePath, identifier } = integrationDef\n\n if (iconRelativeFilePath && !iconRelativeFilePath.toLowerCase().endsWith('.svg')) {\n throw new errors.BotpressCLIError('Icon must be an SVG file')\n }\n\n const iconFileContent = await this._readMediaFile('icon', iconRelativeFilePath)\n const readmeFileContent = await this._readMediaFile('readme', readmeRelativeFilePath)\n const identifierExtractScriptFileContent = await this.readProjectFile(identifier?.extractScript)\n const fallbackHandlerScriptFileContent = await this.readProjectFile(identifier?.fallbackHandlerScript)\n\n const integration = await api.findIntegration({ type: 'name', name, version })\n if (integration && integration.workspaceId !== api.workspaceId) {\n throw new errors.BotpressCLIError(\n `Public integration ${name} v${version} is already deployed in another workspace.`\n )\n }\n\n if (integration && integration.public && !api.isBotpressWorkspace) {\n throw new errors.BotpressCLIError(\n `Integration ${name} v${version} is already deployed publicly and cannot be updated. Please bump the version.`\n )\n }\n\n let message: string\n if (integration) {\n this.logger.warn('Integration already exists. If you decide to deploy, it will override the existing one.')\n message = `Are you sure you want to override integration ${name} v${version}?`\n } else {\n message = `Are you sure you want to deploy integration ${name} v${version}?`\n }\n\n const confirm = await this.prompt.confirm(message)\n if (!confirm) {\n this.logger.log('Aborted')\n return\n }\n\n let createBody: CreateIntegrationBody = prepareCreateIntegrationBody(integrationDef)\n createBody = {\n ...createBody,\n interfaces: await this._formatInterfacesImplStatements(api, integrationDef),\n code,\n icon: iconFileContent,\n readme: readmeFileContent,\n configuration: await this.readIntegrationConfigDefinition(createBody.configuration),\n configurations: await utils.promises.awaitRecord(\n utils.records.mapValues(createBody.configurations ?? {}, this.readIntegrationConfigDefinition)\n ),\n identifier: {\n extractScript: identifierExtractScriptFileContent,\n fallbackHandlerScript: fallbackHandlerScriptFileContent,\n },\n public: this.argv.public,\n }\n\n const startedMessage = `Deploying integration ${chalk.bold(name)} v${version}...`\n const successMessage = 'Integration deployed'\n if (integration) {\n const updateBody = prepareUpdateIntegrationBody(\n {\n id: integration.id,\n ...createBody,\n public: this.argv.public,\n },\n integration\n )\n\n const { secrets: knownSecrets } = integration\n updateBody.secrets = await this.promptSecrets(integrationDef, this.argv, { knownSecrets })\n this._detectDeprecatedFeatures(integrationDef, { allowDeprecated: true })\n\n const line = this.logger.line()\n line.started(startedMessage)\n await api.client.updateIntegration(updateBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not update integration \"${name}\"`)\n })\n line.success(successMessage)\n } else {\n const previousVersion = await api.findPreviousIntegrationVersion({ type: 'name', name, version })\n const knownSecrets = previousVersion?.secrets\n\n const createSecrets = await this.promptSecrets(integrationDef, this.argv, { knownSecrets })\n createBody.secrets = utils.records.filterValues(createSecrets, utils.guards.is.notNull)\n\n this._detectDeprecatedFeatures(integrationDef, {\n allowDeprecated: this._allowDeprecatedFeatures(integrationDef, previousVersion),\n })\n\n const line = this.logger.line()\n line.started(startedMessage)\n await api.client.createIntegration(createBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not create integration \"${name}\"`)\n })\n line.success(successMessage)\n }\n }\n\n private async _deployInterface(api: ApiClient, interfaceDeclaration: sdk.InterfaceDeclaration) {\n if (!api.isBotpressWorkspace) {\n throw new errors.BotpressCLIError('Your workspace is not allowed to deploy interfaces.')\n }\n\n const { name, version } = interfaceDeclaration\n const intrface = await api.findPublicInterface({ type: 'name', name, version })\n\n let message: string\n if (intrface) {\n this.logger.warn('Interface already exists. If you decide to deploy, it will override the existing one.')\n message = `Are you sure you want to override interface ${name} v${version}?`\n } else {\n message = `Are you sure you want to deploy interface ${name} v${version}?`\n }\n\n const confirm = await this.prompt.confirm(message)\n if (!confirm) {\n this.logger.log('Aborted')\n return\n }\n\n const createBody: CreateInterfaceBody = prepareCreateInterfaceBody(interfaceDeclaration)\n\n const startedMessage = `Deploying interface ${chalk.bold(name)} v${version}...`\n const successMessage = 'Interface deployed'\n if (intrface) {\n const updateBody = prepareUpdateInterfaceBody(\n {\n id: intrface.id,\n ...createBody,\n },\n intrface\n )\n\n const line = this.logger.line()\n line.started(startedMessage)\n await api.client.updateInterface(updateBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not update interface \"${name}\"`)\n })\n line.success(successMessage)\n } else {\n const line = this.logger.line()\n line.started(startedMessage)\n await api.client.createInterface(createBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not create interface \"${name}\"`)\n })\n line.success(successMessage)\n }\n }\n\n private _allowDeprecatedFeatures(\n integrationDef: sdk.IntegrationDefinition,\n previousVersion: client.Integration | undefined\n ): boolean {\n if (this.argv.allowDeprecated) {\n return true\n }\n\n if (!previousVersion) {\n return false\n }\n\n const versionDiff = semver.diff(integrationDef.version, previousVersion.version)\n if (!versionDiff) {\n return false\n }\n\n return utils.semver.releases.lt(versionDiff, 'major')\n }\n\n private _detectDeprecatedFeatures(\n integrationDef: sdk.IntegrationDefinition,\n opts: { allowDeprecated?: boolean } = {}\n ) {\n const deprecatedFields: string[] = []\n const { user, channels } = integrationDef\n if (user?.creation?.enabled) {\n deprecatedFields.push('user.creation')\n }\n\n for (const [channelName, channel] of Object.entries(channels ?? {})) {\n if (channel?.conversation?.creation?.enabled) {\n deprecatedFields.push(`channels.${channelName}.creation`)\n }\n }\n\n if (!deprecatedFields.length) {\n return\n }\n\n const errorMessage = `The following fields of the integration's definition are deprecated: ${deprecatedFields.join(\n ', '\n )}`\n\n if (opts.allowDeprecated) {\n this.logger.warn(errorMessage)\n } else {\n throw new errors.BotpressCLIError(errorMessage)\n }\n }\n\n private _readMediaFile = async (\n filePurpose: 'icon' | 'readme',\n filePath: string | undefined\n ): Promise<string | undefined> => {\n if (!filePath) {\n return undefined\n }\n\n const absoluteFilePath = utils.path.absoluteFrom(this.projectPaths.abs.workDir, filePath)\n return fs.promises.readFile(absoluteFilePath, 'base64').catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not read ${filePurpose} file \"${absoluteFilePath}\"`)\n })\n }\n\n private async _deployBot(api: ApiClient, argvBotId: string | undefined, argvCreateNew: boolean | undefined) {\n const outfile = this.projectPaths.abs.outFile\n const code = await fs.promises.readFile(outfile, 'utf-8')\n const { default: botImpl } = utils.require.requireJsFile<{ default: sdk.Bot }>(outfile)\n\n let bot: client.Bot\n if (argvBotId && argvCreateNew) {\n throw new errors.BotpressCLIError('Cannot specify both --botId and --createNew')\n } else if (argvCreateNew) {\n const confirm = await this.prompt.confirm('Are you sure you want to create a new bot ?')\n if (!confirm) {\n this.logger.log('Aborted')\n return\n }\n\n bot = await this._createNewBot(api)\n } else {\n bot = await this._getExistingBot(api, argvBotId)\n\n const confirm = await this.prompt.confirm(`Are you sure you want to deploy the bot \"${bot.name}\"?`)\n if (!confirm) {\n this.logger.log('Aborted')\n return\n }\n }\n\n const line = this.logger.line()\n line.started(`Deploying bot ${chalk.bold(bot.name)}...`)\n\n const integrationInstances = await this.fetchBotIntegrationInstances(botImpl, api)\n const updateBotBody = prepareUpdateBotBody(\n {\n ...prepareCreateBotBody(botImpl),\n id: bot.id,\n code,\n integrations: integrationInstances,\n },\n bot\n )\n\n const { bot: updatedBot } = await api.client.updateBot(updateBotBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not update bot \"${bot.name}\"`)\n })\n line.success('Bot deployed')\n this.displayWebhookUrls(updatedBot)\n }\n\n private async _createNewBot(api: ApiClient): Promise<client.Bot> {\n const line = this.logger.line()\n const { bot: createdBot } = await api.client.createBot({}).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not create bot')\n })\n line.success(`Bot created with ID \"${createdBot.id}\" and name \"${createdBot.name}\"`)\n await this.projectCache.set('botId', createdBot.id)\n return createdBot\n }\n\n private async _getExistingBot(api: ApiClient, botId: string | undefined): Promise<client.Bot> {\n const promptedBotId = await this.projectCache.sync('botId', botId, async (defaultId) => {\n const userBots = await api\n .listAllPages(api.client.listBots, (r) => r.bots)\n .catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not fetch existing bots')\n })\n\n if (!userBots.length) {\n throw new errors.NoBotsFoundError()\n }\n\n const initial = userBots.find((bot) => bot.id === defaultId)\n\n const prompted = await this.prompt.select('Which bot do you want to deploy?', {\n initial: initial && { title: initial.name, value: initial.id },\n choices: userBots.map((bot) => ({ title: bot.name, value: bot.id })),\n })\n\n if (!prompted) {\n throw new errors.ParamRequiredError('Bot Id')\n }\n\n return prompted\n })\n\n const { bot: fetchedBot } = await api.client.getBot({ id: promptedBotId }).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not get bot info')\n })\n\n return fetchedBot\n }\n\n private async _manageWorkspaceHandle(\n api: ApiClient,\n integration: sdk.IntegrationDefinition\n ): Promise<sdk.IntegrationDefinition> {\n const { name: localName, workspaceHandle: localHandle } = this._parseIntegrationName(integration.name)\n if (!localHandle && api.isBotpressWorkspace) {\n this.logger.debug('Botpress workspace detected; workspace handle omitted')\n return integration // botpress has the right to omit workspace handle\n }\n\n const { handle: remoteHandle, name: workspaceName } = await api.getWorkspace().catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not fetch workspace')\n })\n\n if (localHandle && remoteHandle) {\n if (localHandle !== remoteHandle) {\n throw new errors.BotpressCLIError(\n `Your current workspace handle is \"${remoteHandle}\" but the integration handle is \"${localHandle}\".`\n )\n }\n return integration\n }\n\n const workspaceHandleIsMandatoryMsg = 'Cannot deploy integration without workspace handle'\n\n if (!localHandle && remoteHandle) {\n const confirmAddHandle = await this.prompt.confirm(\n `Your current workspace handle is \"${remoteHandle}\". Do you want to use the name \"${remoteHandle}/${localName}\"?`\n )\n if (!confirmAddHandle) {\n throw new errors.BotpressCLIError(workspaceHandleIsMandatoryMsg)\n }\n const newName = `${remoteHandle}/${localName}`\n return integration.clone({ name: newName })\n }\n\n if (localHandle && !remoteHandle) {\n const { available } = await api.client.checkHandleAvailability({ handle: localHandle }).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not check handle availability')\n })\n\n if (!available) {\n throw new errors.BotpressCLIError(`Handle \"${localHandle}\" is not yours and is not available`)\n }\n\n const confirmClaimHandle = await this.prompt.confirm(\n `Handle \"${localHandle}\" is available. Do you want to claim it for your workspace ${workspaceName}?`\n )\n if (!confirmClaimHandle) {\n throw new errors.BotpressCLIError(workspaceHandleIsMandatoryMsg)\n }\n\n await api.updateWorkspace({ handle: localHandle }).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not claim handle \"${localHandle}\"`)\n })\n\n this.logger.success(`Handle \"${localHandle}\" is now yours!`)\n return integration\n }\n\n this.logger.warn(\"It seems you don't have a workspace handle yet.\")\n let claimedHandle: string | undefined = undefined\n do {\n const prompted = await this.prompt.text('Please enter a workspace handle')\n if (!prompted) {\n throw new errors.BotpressCLIError(workspaceHandleIsMandatoryMsg)\n }\n\n const { available, suggestions } = await api.client.checkHandleAvailability({ handle: prompted })\n if (!available) {\n this.logger.warn(`Handle \"${prompted}\" is not available. Suggestions: ${suggestions.join(', ')}`)\n continue\n }\n\n claimedHandle = prompted\n await api.updateWorkspace({ handle: claimedHandle }).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not claim handle \"${claimedHandle}\"`)\n })\n } while (!claimedHandle)\n\n this.logger.success(`Handle \"${claimedHandle}\" is yours!`)\n const newName = `${claimedHandle}/${localName}`\n return integration.clone({ name: newName })\n }\n\n private _parseIntegrationName = (integrationName: string): { name: string; workspaceHandle?: string } => {\n const parts = integrationName.split('/')\n if (parts.length > 2) {\n throw new errors.BotpressCLIError(\n `Invalid integration name \"${integrationName}\": a single forward slash is allowed`\n )\n }\n if (parts.length === 2) {\n const [workspaceHandle, name] = parts as [string, string]\n return { name, workspaceHandle }\n }\n const [name] = parts as [string]\n return { name }\n }\n\n private _formatInterfacesImplStatements = async (\n api: ApiClient,\n integration: sdk.IntegrationDefinition\n ): Promise<CreateIntegrationBody['interfaces']> => {\n const interfacesEntries = Object.entries(integration.interfaces)\n if (!interfacesEntries.length) {\n return undefined\n }\n\n const interfaces: NonNullable<CreateIntegrationBody['interfaces']> = {}\n for (const [key, i] of interfacesEntries) {\n const { name, version, entities, actions, events } = i\n const intrface = await api.findPublicInterface({ type: 'name', name, version })\n if (!intrface) {\n throw new errors.BotpressCLIError(`Could not find interface \"${name}@${version}\"`)\n }\n const { id } = intrface\n\n interfaces[key] = { id,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AiBC,KAAI,IAAI;AAChC,aAAO,EAAE,MAAAA,OAAM,gBAAgB;AAAA,IACjC;AACA,UAAM,CAAC,IAAI,IAAI;AACf,WAAO,EAAE,KAAK;AAAA,EAChB;AAAA,EAEQ,kCAAkC,OACxC,KACA,gBACiD;AACjD,UAAM,oBAAoB,OAAO,QAAQ,YAAY,UAAU;AAC/D,QAAI,CAAC,kBAAkB,QAAQ;AAC7B,aAAO;AAAA,IACT;AAEA,UAAM,aAA+D,CAAC;AACtE,eAAW,CAAC,KAAK,CAAC,KAAK,mBAAmB;AACxC,YAAM,EAAE,MAAM,SAAS,UAAU,SAAS,OAAO,IAAI;AACrD,YAAM,WAAW,MAAM,IAAI,oBAAoB,EAAE,MAAM,QAAQ,MAAM,QAAQ,CAAC;AAC9E,UAAI,CAAC,UAAU;AACb,cAAM,IAAI,OAAO,iBAAiB,6BAA6B,QAAQ,UAAU;AAAA,MACnF;AACA,YAAM,EAAE,GAAG,IAAI;AAEf,iBAAW,OAAO,EAAE,IAAI,UAAU,SAAS,OAAO;AAAA,IACpD;AAEA,WAAO;AAAA,EACT;AACF;",
4
+ "sourcesContent": ["import type * as client from '@botpress/client'\nimport type * as sdk from '@botpress/sdk'\nimport chalk from 'chalk'\nimport * as fs from 'fs'\nimport semver from 'semver'\nimport { prepareCreateBotBody, prepareUpdateBotBody } from '../api/bot-body'\nimport type { ApiClient } from '../api/client'\nimport {\n CreateIntegrationBody,\n prepareUpdateIntegrationBody,\n prepareCreateIntegrationBody,\n} from '../api/integration-body'\nimport { CreateInterfaceBody, prepareCreateInterfaceBody, prepareUpdateInterfaceBody } from '../api/interface-body'\nimport type commandDefinitions from '../command-definitions'\nimport * as errors from '../errors'\nimport * as utils from '../utils'\nimport { BuildCommand } from './build-command'\nimport { ProjectCommand } from './project-command'\n\nexport type DeployCommandDefinition = typeof commandDefinitions.deploy\nexport class DeployCommand extends ProjectCommand<DeployCommandDefinition> {\n public async run(): Promise<void> {\n const api = await this.ensureLoginAndCreateClient(this.argv)\n\n if (!this.argv.noBuild) {\n await this._runBuild() // This ensures the bundle is always synced with source code\n }\n\n const projectDef = await this.readProjectDefinitionFromFS()\n\n if (projectDef.type === 'integration') {\n return this._deployIntegration(api, projectDef.definition)\n }\n if (projectDef.type === 'interface') {\n return this._deployInterface(api, projectDef.definition)\n }\n return this._deployBot(api, this.argv.botId, this.argv.createNewBot)\n }\n\n private async _runBuild() {\n return new BuildCommand(this.api, this.prompt, this.logger, this.argv).run()\n }\n\n private async _deployIntegration(api: ApiClient, integrationDef: sdk.IntegrationDefinition) {\n const outfile = this.projectPaths.abs.outFile\n const code = await fs.promises.readFile(outfile, 'utf-8')\n\n integrationDef = await this._manageWorkspaceHandle(api, integrationDef)\n\n const { name, version, icon: iconRelativeFilePath, readme: readmeRelativeFilePath, identifier } = integrationDef\n\n if (iconRelativeFilePath && !iconRelativeFilePath.toLowerCase().endsWith('.svg')) {\n throw new errors.BotpressCLIError('Icon must be an SVG file')\n }\n\n const iconFileContent = await this._readMediaFile('icon', iconRelativeFilePath)\n const readmeFileContent = await this._readMediaFile('readme', readmeRelativeFilePath)\n const identifierExtractScriptFileContent = await this.readProjectFile(identifier?.extractScript)\n const fallbackHandlerScriptFileContent = await this.readProjectFile(identifier?.fallbackHandlerScript)\n\n const integration = await api.findIntegration({ type: 'name', name, version })\n if (integration && integration.workspaceId !== api.workspaceId) {\n throw new errors.BotpressCLIError(\n `Public integration ${name} v${version} is already deployed in another workspace.`\n )\n }\n\n if (integration && integration.public && !api.isBotpressWorkspace) {\n throw new errors.BotpressCLIError(\n `Integration ${name} v${version} is already deployed publicly and cannot be updated. Please bump the version.`\n )\n }\n\n let message: string\n if (integration) {\n this.logger.warn('Integration already exists. If you decide to deploy, it will override the existing one.')\n message = `Are you sure you want to override integration ${name} v${version}?`\n } else {\n message = `Are you sure you want to deploy integration ${name} v${version}?`\n }\n\n const confirm = await this.prompt.confirm(message)\n if (!confirm) {\n this.logger.log('Aborted')\n return\n }\n\n let createBody: CreateIntegrationBody = await prepareCreateIntegrationBody(integrationDef)\n createBody = {\n ...createBody,\n interfaces: await this._formatInterfacesImplStatements(api, integrationDef),\n code,\n icon: iconFileContent,\n readme: readmeFileContent,\n configuration: await this.readIntegrationConfigDefinition(createBody.configuration),\n configurations: await utils.promises.awaitRecord(\n utils.records.mapValues(createBody.configurations ?? {}, this.readIntegrationConfigDefinition)\n ),\n identifier: {\n extractScript: identifierExtractScriptFileContent,\n fallbackHandlerScript: fallbackHandlerScriptFileContent,\n },\n public: this.argv.public,\n }\n\n const startedMessage = `Deploying integration ${chalk.bold(name)} v${version}...`\n const successMessage = 'Integration deployed'\n if (integration) {\n const updateBody = prepareUpdateIntegrationBody(\n {\n id: integration.id,\n ...createBody,\n public: this.argv.public,\n },\n integration\n )\n\n const { secrets: knownSecrets } = integration\n updateBody.secrets = await this.promptSecrets(integrationDef, this.argv, { knownSecrets })\n this._detectDeprecatedFeatures(integrationDef, { allowDeprecated: true })\n\n const line = this.logger.line()\n line.started(startedMessage)\n await api.client.updateIntegration(updateBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not update integration \"${name}\"`)\n })\n line.success(successMessage)\n } else {\n const previousVersion = await api.findPreviousIntegrationVersion({ type: 'name', name, version })\n const knownSecrets = previousVersion?.secrets\n\n const createSecrets = await this.promptSecrets(integrationDef, this.argv, { knownSecrets })\n createBody.secrets = utils.records.filterValues(createSecrets, utils.guards.is.notNull)\n\n this._detectDeprecatedFeatures(integrationDef, {\n allowDeprecated: this._allowDeprecatedFeatures(integrationDef, previousVersion),\n })\n\n const line = this.logger.line()\n line.started(startedMessage)\n await api.client.createIntegration(createBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not create integration \"${name}\"`)\n })\n line.success(successMessage)\n }\n }\n\n private async _deployInterface(api: ApiClient, interfaceDeclaration: sdk.InterfaceDeclaration) {\n if (!api.isBotpressWorkspace) {\n throw new errors.BotpressCLIError('Your workspace is not allowed to deploy interfaces.')\n }\n\n const { name, version } = interfaceDeclaration\n const intrface = await api.findPublicInterface({ type: 'name', name, version })\n\n let message: string\n if (intrface) {\n this.logger.warn('Interface already exists. If you decide to deploy, it will override the existing one.')\n message = `Are you sure you want to override interface ${name} v${version}?`\n } else {\n message = `Are you sure you want to deploy interface ${name} v${version}?`\n }\n\n const confirm = await this.prompt.confirm(message)\n if (!confirm) {\n this.logger.log('Aborted')\n return\n }\n\n const createBody: CreateInterfaceBody = await prepareCreateInterfaceBody(interfaceDeclaration)\n\n const startedMessage = `Deploying interface ${chalk.bold(name)} v${version}...`\n const successMessage = 'Interface deployed'\n if (intrface) {\n const updateBody = prepareUpdateInterfaceBody(\n {\n id: intrface.id,\n ...createBody,\n },\n intrface\n )\n\n const line = this.logger.line()\n line.started(startedMessage)\n await api.client.updateInterface(updateBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not update interface \"${name}\"`)\n })\n line.success(successMessage)\n } else {\n const line = this.logger.line()\n line.started(startedMessage)\n await api.client.createInterface(createBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not create interface \"${name}\"`)\n })\n line.success(successMessage)\n }\n }\n\n private _allowDeprecatedFeatures(\n integrationDef: sdk.IntegrationDefinition,\n previousVersion: client.Integration | undefined\n ): boolean {\n if (this.argv.allowDeprecated) {\n return true\n }\n\n if (!previousVersion) {\n return false\n }\n\n const versionDiff = semver.diff(integrationDef.version, previousVersion.version)\n if (!versionDiff) {\n return false\n }\n\n return utils.semver.releases.lt(versionDiff, 'major')\n }\n\n private _detectDeprecatedFeatures(\n integrationDef: sdk.IntegrationDefinition,\n opts: { allowDeprecated?: boolean } = {}\n ) {\n const deprecatedFields: string[] = []\n const { user, channels } = integrationDef\n if (user?.creation?.enabled) {\n deprecatedFields.push('user.creation')\n }\n\n for (const [channelName, channel] of Object.entries(channels ?? {})) {\n if (channel?.conversation?.creation?.enabled) {\n deprecatedFields.push(`channels.${channelName}.creation`)\n }\n }\n\n if (!deprecatedFields.length) {\n return\n }\n\n const errorMessage = `The following fields of the integration's definition are deprecated: ${deprecatedFields.join(\n ', '\n )}`\n\n if (opts.allowDeprecated) {\n this.logger.warn(errorMessage)\n } else {\n throw new errors.BotpressCLIError(errorMessage)\n }\n }\n\n private _readMediaFile = async (\n filePurpose: 'icon' | 'readme',\n filePath: string | undefined\n ): Promise<string | undefined> => {\n if (!filePath) {\n return undefined\n }\n\n const absoluteFilePath = utils.path.absoluteFrom(this.projectPaths.abs.workDir, filePath)\n return fs.promises.readFile(absoluteFilePath, 'base64').catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not read ${filePurpose} file \"${absoluteFilePath}\"`)\n })\n }\n\n private async _deployBot(api: ApiClient, argvBotId: string | undefined, argvCreateNew: boolean | undefined) {\n const outfile = this.projectPaths.abs.outFile\n const code = await fs.promises.readFile(outfile, 'utf-8')\n const { default: botImpl } = utils.require.requireJsFile<{ default: sdk.Bot }>(outfile)\n\n let bot: client.Bot\n if (argvBotId && argvCreateNew) {\n throw new errors.BotpressCLIError('Cannot specify both --botId and --createNew')\n } else if (argvCreateNew) {\n const confirm = await this.prompt.confirm('Are you sure you want to create a new bot ?')\n if (!confirm) {\n this.logger.log('Aborted')\n return\n }\n\n bot = await this._createNewBot(api)\n } else {\n bot = await this._getExistingBot(api, argvBotId)\n\n const confirm = await this.prompt.confirm(`Are you sure you want to deploy the bot \"${bot.name}\"?`)\n if (!confirm) {\n this.logger.log('Aborted')\n return\n }\n }\n\n const line = this.logger.line()\n line.started(`Deploying bot ${chalk.bold(bot.name)}...`)\n\n const integrationInstances = await this.fetchBotIntegrationInstances(botImpl, api)\n const updateBotBody = prepareUpdateBotBody(\n {\n ...(await prepareCreateBotBody(botImpl)),\n id: bot.id,\n code,\n integrations: integrationInstances,\n },\n bot\n )\n\n const { bot: updatedBot } = await api.client.updateBot(updateBotBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not update bot \"${bot.name}\"`)\n })\n line.success('Bot deployed')\n this.displayWebhookUrls(updatedBot)\n }\n\n private async _createNewBot(api: ApiClient): Promise<client.Bot> {\n const line = this.logger.line()\n const { bot: createdBot } = await api.client.createBot({}).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not create bot')\n })\n line.success(`Bot created with ID \"${createdBot.id}\" and name \"${createdBot.name}\"`)\n await this.projectCache.set('botId', createdBot.id)\n return createdBot\n }\n\n private async _getExistingBot(api: ApiClient, botId: string | undefined): Promise<client.Bot> {\n const promptedBotId = await this.projectCache.sync('botId', botId, async (defaultId) => {\n const userBots = await api\n .listAllPages(api.client.listBots, (r) => r.bots)\n .catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not fetch existing bots')\n })\n\n if (!userBots.length) {\n throw new errors.NoBotsFoundError()\n }\n\n const initial = userBots.find((bot) => bot.id === defaultId)\n\n const prompted = await this.prompt.select('Which bot do you want to deploy?', {\n initial: initial && { title: initial.name, value: initial.id },\n choices: userBots.map((bot) => ({ title: bot.name, value: bot.id })),\n })\n\n if (!prompted) {\n throw new errors.ParamRequiredError('Bot Id')\n }\n\n return prompted\n })\n\n const { bot: fetchedBot } = await api.client.getBot({ id: promptedBotId }).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not get bot info')\n })\n\n return fetchedBot\n }\n\n private async _manageWorkspaceHandle(\n api: ApiClient,\n integration: sdk.IntegrationDefinition\n ): Promise<sdk.IntegrationDefinition> {\n const { name: localName, workspaceHandle: localHandle } = this._parseIntegrationName(integration.name)\n if (!localHandle && api.isBotpressWorkspace) {\n this.logger.debug('Botpress workspace detected; workspace handle omitted')\n return integration // botpress has the right to omit workspace handle\n }\n\n const { handle: remoteHandle, name: workspaceName } = await api.getWorkspace().catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not fetch workspace')\n })\n\n if (localHandle && remoteHandle) {\n if (localHandle !== remoteHandle) {\n throw new errors.BotpressCLIError(\n `Your current workspace handle is \"${remoteHandle}\" but the integration handle is \"${localHandle}\".`\n )\n }\n return integration\n }\n\n const workspaceHandleIsMandatoryMsg = 'Cannot deploy integration without workspace handle'\n\n if (!localHandle && remoteHandle) {\n const confirmAddHandle = await this.prompt.confirm(\n `Your current workspace handle is \"${remoteHandle}\". Do you want to use the name \"${remoteHandle}/${localName}\"?`\n )\n if (!confirmAddHandle) {\n throw new errors.BotpressCLIError(workspaceHandleIsMandatoryMsg)\n }\n const newName = `${remoteHandle}/${localName}`\n return integration.clone({ name: newName })\n }\n\n if (localHandle && !remoteHandle) {\n const { available } = await api.client.checkHandleAvailability({ handle: localHandle }).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not check handle availability')\n })\n\n if (!available) {\n throw new errors.BotpressCLIError(`Handle \"${localHandle}\" is not yours and is not available`)\n }\n\n const confirmClaimHandle = await this.prompt.confirm(\n `Handle \"${localHandle}\" is available. Do you want to claim it for your workspace ${workspaceName}?`\n )\n if (!confirmClaimHandle) {\n throw new errors.BotpressCLIError(workspaceHandleIsMandatoryMsg)\n }\n\n await api.updateWorkspace({ handle: localHandle }).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not claim handle \"${localHandle}\"`)\n })\n\n this.logger.success(`Handle \"${localHandle}\" is now yours!`)\n return integration\n }\n\n this.logger.warn(\"It seems you don't have a workspace handle yet.\")\n let claimedHandle: string | undefined = undefined\n do {\n const prompted = await this.prompt.text('Please enter a workspace handle')\n if (!prompted) {\n throw new errors.BotpressCLIError(workspaceHandleIsMandatoryMsg)\n }\n\n const { available, suggestions } = await api.client.checkHandleAvailability({ handle: prompted })\n if (!available) {\n this.logger.warn(`Handle \"${prompted}\" is not available. Suggestions: ${suggestions.join(', ')}`)\n continue\n }\n\n claimedHandle = prompted\n await api.updateWorkspace({ handle: claimedHandle }).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not claim handle \"${claimedHandle}\"`)\n })\n } while (!claimedHandle)\n\n this.logger.success(`Handle \"${claimedHandle}\" is yours!`)\n const newName = `${claimedHandle}/${localName}`\n return integration.clone({ name: newName })\n }\n\n private _parseIntegrationName = (integrationName: string): { name: string; workspaceHandle?: string } => {\n const parts = integrationName.split('/')\n if (parts.length > 2) {\n throw new errors.BotpressCLIError(\n `Invalid integration name \"${integrationName}\": a single forward slash is allowed`\n )\n }\n if (parts.length === 2) {\n const [workspaceHandle, name] = parts as [string, string]\n return { name, workspaceHandle }\n }\n const [name] = parts as [string]\n return { name }\n }\n\n private _formatInterfacesImplStatements = async (\n api: ApiClient,\n integration: sdk.IntegrationDefinition\n ): Promise<CreateIntegrationBody['interfaces']> => {\n const interfacesEntries = Object.entries(integration.interfaces)\n if (!interfacesEntries.length) {\n return undefined\n }\n\n const interfaces: NonNullable<CreateIntegrationBody['interfaces']> = {}\n for (const [key, i] of interfacesEntries) {\n const { name, version, entities, actions, events } = i\n const intrface = await api.findPublicInterface({ type: 'name', name, version })\n if (!intrface) {\n throw new errors.BotpressCLIError(`Could not find interface \"${name}@${version}\"`)\n }\n const { id } = intrface\n\n interfaces[key] = { id, entities, actions, events }\n }\n\n return interfaces\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAAkB;AAClB,SAAoB;AACpB,oBAAmB;AACnB,sBAA2D;AAE3D,8BAIO;AACP,4BAA4F;AAE5F,aAAwB;AACxB,YAAuB;AACvB,2BAA6B;AAC7B,6BAA+B;AAGxB,MAAM,sBAAsB,sCAAwC;AAAA,EACzE,MAAa,MAAqB;AAChC,UAAM,MAAM,MAAM,KAAK,2BAA2B,KAAK,IAAI;AAE3D,QAAI,CAAC,KAAK,KAAK,SAAS;AACtB,YAAM,KAAK,UAAU;AAAA,IACvB;AAEA,UAAM,aAAa,MAAM,KAAK,4BAA4B;AAE1D,QAAI,WAAW,SAAS,eAAe;AACrC,aAAO,KAAK,mBAAmB,KAAK,WAAW,UAAU;AAAA,IAC3D;AACA,QAA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,UAAU;AAAA,MACnF;AACA,YAAM,EAAE,GAAG,IAAI;AAEf,iBAAW,OAAO,EAAE,IAAI,UAAU,SAAS,OAAO;AAAA,IACpD;AAEA,WAAO;AAAA,EACT;AACF;",
6
6
  "names": ["chalk", "semver", "newName", "name"]
7
7
  }
@@ -215,7 +215,7 @@ class DevCommand extends import_project_command.ProjectCommand {
215
215
  }
216
216
  const line = this.logger.line();
217
217
  line.started(`Deploying dev integration ${import_chalk.default.bold(integrationDef.name)}...`);
218
- let createIntegrationBody = (0, import_integration_body.prepareCreateIntegrationBody)(integrationDef);
218
+ let createIntegrationBody = await (0, import_integration_body.prepareCreateIntegrationBody)(integrationDef);
219
219
  createIntegrationBody = {
220
220
  ...createIntegrationBody,
221
221
  url: externalUrl,
@@ -279,7 +279,7 @@ class DevCommand extends import_project_command.ProjectCommand {
279
279
  const integrationInstances = await this.fetchBotIntegrationInstances(botImpl, api);
280
280
  const updateBotBody = (0, import_bot_body.prepareUpdateBotBody)(
281
281
  {
282
- ...(0, import_bot_body.prepareCreateBotBody)(botImpl),
282
+ ...await (0, import_bot_body.prepareCreateBotBody)(botImpl),
283
283
  id: bot.id,
284
284
  url: externalUrl,
285
285
  integrations: integrationInstances
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/command-implementations/dev-command.ts"],
4
- "sourcesContent": ["import type * as client from '@botpress/client'\nimport type * as sdk from '@botpress/sdk'\nimport { TunnelRequest, TunnelResponse } from '@bpinternal/tunnel'\nimport axios, { AxiosRequestConfig, AxiosResponse } from 'axios'\nimport chalk from 'chalk'\nimport * as pathlib from 'path'\nimport * as uuid from 'uuid'\nimport { prepareCreateBotBody, prepareUpdateBotBody } from '../api/bot-body'\nimport type { ApiClient } from '../api/client'\nimport {\n prepareUpdateIntegrationBody,\n CreateIntegrationBody,\n prepareCreateIntegrationBody,\n} from '../api/integration-body'\nimport type commandDefinitions from '../command-definitions'\nimport * as errors from '../errors'\nimport * as utils from '../utils'\nimport { Worker } from '../worker'\nimport { BuildCommand } from './build-command'\nimport { ProjectCommand } from './project-command'\n\nconst DEFAULT_BOT_PORT = 8075\nconst DEFAULT_INTEGRATION_PORT = 8076\nconst TUNNEL_HELLO_INTERVAL = 5000\n\nexport type DevCommandDefinition = typeof commandDefinitions.dev\nexport class DevCommand extends ProjectCommand<DevCommandDefinition> {\n private _initialDef: sdk.IntegrationDefinition | undefined = undefined\n\n public async run(): Promise<void> {\n this.logger.warn('This command is experimental and subject to breaking changes without notice.')\n\n const api = await this.ensureLoginAndCreateClient(this.argv)\n\n const projectDef = await this.readProjectDefinitionFromFS()\n if (projectDef.type === 'interface') {\n throw new errors.BotpressCLIError('This feature is not available for interfaces.')\n }\n\n this._initialDef = projectDef.definition ?? undefined\n\n let env: Record<string, string> = {\n ...process.env,\n BP_API_URL: api.url,\n BP_TOKEN: api.token,\n }\n\n let defaultPort = DEFAULT_BOT_PORT\n if (this._initialDef) {\n defaultPort = DEFAULT_INTEGRATION_PORT\n // TODO: store secrets in local cache to avoid prompting every time\n const secretEnvVariables = await this.promptSecrets(this._initialDef, this.argv, { formatEnv: true })\n const nonNullSecretEnvVariables = utils.records.filterValues(secretEnvVariables, utils.guards.is.notNull)\n env = { ...env, ...nonNullSecretEnvVariables }\n }\n\n const port = this.argv.port ?? defaultPort\n\n const urlParseResult = utils.url.parse(this.argv.tunnelUrl)\n if (urlParseResult.status === 'error') {\n throw new errors.BotpressCLIError(`Invalid tunnel URL: ${urlParseResult.error}`)\n }\n\n const tunnelId = uuid.v4()\n\n const { url: parsedTunnelUrl } = urlParseResult\n const isSecured = parsedTunnelUrl.protocol === 'https' || parsedTunnelUrl.protocol === 'wss'\n\n const wsTunnelUrl: string = utils.url.format({ ...parsedTunnelUrl, protocol: isSecured ? 'wss' : 'ws' })\n const httpTunnelUrl: string = utils.url.format({\n ...parsedTunnelUrl,\n protocol: isSecured ? 'https' : 'http',\n path: `/${tunnelId}`,\n })\n\n let worker: Worker | undefined = undefined\n\n const supervisor = new utils.tunnel.TunnelSupervisor(wsTunnelUrl, tunnelId, this.logger)\n supervisor.events.on('connected', ({ tunnel }) => {\n // prevents the tunnel from closing due to inactivity\n const timer = setInterval(() => {\n if (tunnel.closed) {\n return handleClose()\n }\n tunnel.hello()\n }, TUNNEL_HELLO_INTERVAL)\n const handleClose = (): void => clearInterval(timer)\n tunnel.events.on('close', handleClose)\n\n tunnel.events.on('request', (req) => {\n if (!worker) {\n this.logger.debug('Worker not ready yet, ignoring request')\n tunnel.send({ requestId: req.id, status: 503, body: 'Worker not ready yet' })\n return\n }\n\n void this._forwardTunnelRequest(`http://localhost:${port}`, req)\n .then((res) => {\n tunnel.send(res)\n })\n .catch((thrown) => {\n const err = errors.BotpressCLIError.wrap(thrown, 'An error occurred while handling request')\n this.logger.error(err.message)\n tunnel.send({\n requestId: req.id,\n status: 500,\n body: err.message,\n })\n })\n })\n })\n\n supervisor.events.on('manuallyClosed', () => {\n this.logger.debug('Tunnel manually closed')\n })\n\n await supervisor.start()\n\n await this._runBuild()\n await this._deploy(api, httpTunnelUrl)\n worker = await this._spawnWorker(env, port)\n\n try {\n const watcher = await utils.filewatcher.FileWatcher.watch(\n this.argv.workDir,\n async (events) => {\n if (!worker) {\n this.logger.debug('Worker not ready yet, ignoring file change event')\n return\n }\n\n const typescriptEvents = events.filter((e) => pathlib.extname(e.path) === '.ts')\n if (typescriptEvents.length === 0) {\n return\n }\n\n this.logger.log('Changes detected, rebuilding')\n await this._restart(api, worker, httpTunnelUrl)\n },\n {\n ignore: [this.projectPaths.abs.outDir],\n }\n )\n\n await Promise.race([worker.wait(), watcher.wait(), supervisor.wait()])\n\n if (worker.running) {\n await worker.kill()\n }\n await watcher.close()\n supervisor.close()\n } catch (thrown) {\n throw errors.BotpressCLIError.wrap(thrown, 'An error occurred while running the dev server')\n } finally {\n if (worker.running) {\n await worker.kill()\n }\n }\n }\n\n private _restart = async (api: ApiClient, worker: Worker, tunnelUrl: string) => {\n try {\n await this._runBuild()\n } catch (thrown) {\n const error = errors.BotpressCLIError.wrap(thrown, 'Build failed')\n this.logger.error(error.message)\n return\n }\n\n await this._deploy(api, tunnelUrl)\n await worker.reload()\n }\n\n private _deploy = async (api: ApiClient, tunnelUrl: string) => {\n const projectDef = await this.readProjectDefinitionFromFS()\n if (projectDef.type === 'interface') {\n throw new errors.BotpressCLIError('This feature is not available for interfaces.')\n }\n\n if (projectDef.type === 'integration') {\n this._checkSecrets(projectDef.definition)\n await this._deployDevIntegration(api, tunnelUrl, projectDef.definition)\n } else {\n await this._deployDevBot(api, tunnelUrl)\n }\n }\n\n private _checkSecrets(integrationDef: sdk.IntegrationDefinition) {\n const initialSecrets = this._initialDef?.secrets ?? {}\n const currentSecrets = integrationDef.secrets ?? {}\n const newSecrets = Object.keys(currentSecrets).filter((s) => !initialSecrets[s])\n if (newSecrets.length > 0) {\n throw new errors.BotpressCLIError('Secrets were added while the server was running. A restart is required.')\n }\n }\n\n private _spawnWorker = async (env: Record<string, string>, port: number) => {\n const outfile = this.projectPaths.abs.outFile\n const importPath = utils.path.toUnix(outfile)\n const requireFrom = utils.path.rmExtension(importPath)\n const code = `require('${requireFrom}').default.start(${port})`\n const worker = await Worker.spawn(\n {\n type: 'code',\n code,\n env,\n },\n this.logger\n ).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not start dev worker')\n })\n\n return worker\n }\n\n private _runBuild() {\n return new BuildCommand(this.api, this.prompt, this.logger, this.argv).run()\n }\n\n private async _deployDevIntegration(\n api: ApiClient,\n externalUrl: string,\n integrationDef: sdk.IntegrationDefinition\n ): Promise<void> {\n const devId = await this.projectCache.get('devId')\n\n let integration: client.Integration | undefined = undefined\n\n if (devId) {\n const resp = await api.client.getIntegration({ id: devId }).catch(async (thrown) => {\n const err = errors.BotpressCLIError.wrap(thrown, `Could not find existing dev integration with id \"${devId}\"`)\n this.logger.warn(err.message)\n return { integration: undefined }\n })\n\n if (resp.integration?.dev) {\n integration = resp.integration\n } else {\n await this.projectCache.rm('devId')\n }\n }\n\n const line = this.logger.line()\n line.started(`Deploying dev integration ${chalk.bold(integrationDef.name)}...`)\n\n let createIntegrationBody: CreateIntegrationBody = prepareCreateIntegrationBody(integrationDef)\n createIntegrationBody = {\n ...createIntegrationBody,\n url: externalUrl,\n configuration: await this.readIntegrationConfigDefinition(createIntegrationBody.configuration),\n configurations: await utils.promises.awaitRecord(\n utils.records.mapValues(createIntegrationBody.configurations ?? {}, this.readIntegrationConfigDefinition)\n ),\n }\n\n if (integration) {\n const updateIntegrationBody = prepareUpdateIntegrationBody(\n { ...createIntegrationBody, id: integration.id },\n integration\n )\n\n const resp = await api.client.updateIntegration(updateIntegrationBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not update dev integration \"${integrationDef.name}\"`)\n })\n integration = resp.integration\n } else {\n const resp = await api.client.createIntegration({ ...createIntegrationBody, dev: true }).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not deploy dev integration \"${integrationDef.name}\"`)\n })\n integration = resp.integration\n }\n\n line.success(`Dev Integration deployed with id \"${integration.id}\"`)\n line.commit()\n\n await this.projectCache.set('devId', integration.id)\n }\n\n private async _deployDevBot(api: ApiClient, externalUrl: string): Promise<void> {\n const devId = await this.projectCache.get('devId')\n\n let bot: client.Bot | undefined = undefined\n\n if (devId) {\n const resp = await api.client.getBot({ id: devId }).catch(async (thrown) => {\n const err = errors.BotpressCLIError.wrap(thrown, `Could not find existing dev bot with id \"${devId}\"`)\n this.logger.warn(err.message)\n return { bot: undefined }\n })\n\n if (resp.bot?.dev) {\n bot = resp.bot\n } else {\n await this.projectCache.rm('devId')\n }\n }\n\n if (!bot) {\n const createLine = this.logger.line()\n createLine.started('Creating dev bot...')\n const resp = await api.client\n .createBot({\n dev: true,\n url: externalUrl,\n })\n .catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not deploy dev bot')\n })\n\n bot = resp.bot\n createLine.success(`Dev Bot created with id \"${bot.id}\"`)\n createLine.commit()\n await this.projectCache.set('devId', bot.id)\n }\n\n const outfile = this.projectPaths.abs.outFile\n const { default: botImpl } = utils.require.requireJsFile<{ default: sdk.Bot }>(outfile)\n\n const updateLine = this.logger.line()\n updateLine.started('Deploying dev bot...')\n\n const integrationInstances = await this.fetchBotIntegrationInstances(botImpl, api)\n const updateBotBody = prepareUpdateBotBody(\n {\n ...prepareCreateBotBody(botImpl),\n id: bot.id,\n url: externalUrl,\n integrations: integrationInstances,\n },\n bot\n )\n\n const { bot: updatedBot } = await api.client.updateBot(updateBotBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not deploy dev bot')\n })\n updateLine.success(`Dev Bot deployed with id \"${updatedBot.id}\"`)\n updateLine.commit()\n\n this.displayWebhookUrls(updatedBot)\n }\n\n private _forwardTunnelRequest = async (baseUrl: string, request: TunnelRequest): Promise<TunnelResponse> => {\n const axiosConfig = {\n method: request.method,\n url: this._formatLocalUrl(baseUrl, request),\n headers: request.headers,\n data: request.body,\n responseType: 'text',\n validateStatus: () => true,\n } satisfies AxiosRequestConfig\n\n this.logger.debug(`Forwarding request to ${axiosConfig.url}`)\n const response = await axios(axiosConfig)\n this.logger.debug('Sending back response up the tunnel')\n\n return {\n requestId: request.id,\n status: response.status,\n headers: this._getHeaders(response.headers),\n body: response.data,\n }\n }\n\n private _formatLocalUrl = (baseUrl: string, req: TunnelRequest): string => {\n if (req.query) {\n return `${baseUrl}${req.path}?${req.query}`\n }\n return `${baseUrl}${req.path}`\n }\n\n private _getHeaders = (res: AxiosResponse['headers']): TunnelResponse['headers'] => {\n const headers: TunnelResponse['headers'] = {}\n for (const key in res) {\n if (typeof res[key] === 'string' || typeof res[key] === 'number') {\n headers[key] = res[key]\n }\n }\n return headers\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,mBAAyD;AACzD,mBAAkB;AAClB,cAAyB;AACzB,WAAsB;AACtB,sBA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AAK;AACrB,UAAI,OAAO,IAAI,SAAS,YAAY,OAAO,IAAI,SAAS,UAAU;AAChE,gBAAQ,OAAO,IAAI;AAAA,MACrB;AAAA,IACF;AACA,WAAO;AAAA,EACT;AACF;",
4
+ "sourcesContent": ["import type * as client from '@botpress/client'\nimport type * as sdk from '@botpress/sdk'\nimport { TunnelRequest, TunnelResponse } from '@bpinternal/tunnel'\nimport axios, { AxiosRequestConfig, AxiosResponse } from 'axios'\nimport chalk from 'chalk'\nimport * as pathlib from 'path'\nimport * as uuid from 'uuid'\nimport { prepareCreateBotBody, prepareUpdateBotBody } from '../api/bot-body'\nimport type { ApiClient } from '../api/client'\nimport {\n prepareUpdateIntegrationBody,\n CreateIntegrationBody,\n prepareCreateIntegrationBody,\n} from '../api/integration-body'\nimport type commandDefinitions from '../command-definitions'\nimport * as errors from '../errors'\nimport * as utils from '../utils'\nimport { Worker } from '../worker'\nimport { BuildCommand } from './build-command'\nimport { ProjectCommand } from './project-command'\n\nconst DEFAULT_BOT_PORT = 8075\nconst DEFAULT_INTEGRATION_PORT = 8076\nconst TUNNEL_HELLO_INTERVAL = 5000\n\nexport type DevCommandDefinition = typeof commandDefinitions.dev\nexport class DevCommand extends ProjectCommand<DevCommandDefinition> {\n private _initialDef: sdk.IntegrationDefinition | undefined = undefined\n\n public async run(): Promise<void> {\n this.logger.warn('This command is experimental and subject to breaking changes without notice.')\n\n const api = await this.ensureLoginAndCreateClient(this.argv)\n\n const projectDef = await this.readProjectDefinitionFromFS()\n if (projectDef.type === 'interface') {\n throw new errors.BotpressCLIError('This feature is not available for interfaces.')\n }\n\n this._initialDef = projectDef.definition ?? undefined\n\n let env: Record<string, string> = {\n ...process.env,\n BP_API_URL: api.url,\n BP_TOKEN: api.token,\n }\n\n let defaultPort = DEFAULT_BOT_PORT\n if (this._initialDef) {\n defaultPort = DEFAULT_INTEGRATION_PORT\n // TODO: store secrets in local cache to avoid prompting every time\n const secretEnvVariables = await this.promptSecrets(this._initialDef, this.argv, { formatEnv: true })\n const nonNullSecretEnvVariables = utils.records.filterValues(secretEnvVariables, utils.guards.is.notNull)\n env = { ...env, ...nonNullSecretEnvVariables }\n }\n\n const port = this.argv.port ?? defaultPort\n\n const urlParseResult = utils.url.parse(this.argv.tunnelUrl)\n if (urlParseResult.status === 'error') {\n throw new errors.BotpressCLIError(`Invalid tunnel URL: ${urlParseResult.error}`)\n }\n\n const tunnelId = uuid.v4()\n\n const { url: parsedTunnelUrl } = urlParseResult\n const isSecured = parsedTunnelUrl.protocol === 'https' || parsedTunnelUrl.protocol === 'wss'\n\n const wsTunnelUrl: string = utils.url.format({ ...parsedTunnelUrl, protocol: isSecured ? 'wss' : 'ws' })\n const httpTunnelUrl: string = utils.url.format({\n ...parsedTunnelUrl,\n protocol: isSecured ? 'https' : 'http',\n path: `/${tunnelId}`,\n })\n\n let worker: Worker | undefined = undefined\n\n const supervisor = new utils.tunnel.TunnelSupervisor(wsTunnelUrl, tunnelId, this.logger)\n supervisor.events.on('connected', ({ tunnel }) => {\n // prevents the tunnel from closing due to inactivity\n const timer = setInterval(() => {\n if (tunnel.closed) {\n return handleClose()\n }\n tunnel.hello()\n }, TUNNEL_HELLO_INTERVAL)\n const handleClose = (): void => clearInterval(timer)\n tunnel.events.on('close', handleClose)\n\n tunnel.events.on('request', (req) => {\n if (!worker) {\n this.logger.debug('Worker not ready yet, ignoring request')\n tunnel.send({ requestId: req.id, status: 503, body: 'Worker not ready yet' })\n return\n }\n\n void this._forwardTunnelRequest(`http://localhost:${port}`, req)\n .then((res) => {\n tunnel.send(res)\n })\n .catch((thrown) => {\n const err = errors.BotpressCLIError.wrap(thrown, 'An error occurred while handling request')\n this.logger.error(err.message)\n tunnel.send({\n requestId: req.id,\n status: 500,\n body: err.message,\n })\n })\n })\n })\n\n supervisor.events.on('manuallyClosed', () => {\n this.logger.debug('Tunnel manually closed')\n })\n\n await supervisor.start()\n\n await this._runBuild()\n await this._deploy(api, httpTunnelUrl)\n worker = await this._spawnWorker(env, port)\n\n try {\n const watcher = await utils.filewatcher.FileWatcher.watch(\n this.argv.workDir,\n async (events) => {\n if (!worker) {\n this.logger.debug('Worker not ready yet, ignoring file change event')\n return\n }\n\n const typescriptEvents = events.filter((e) => pathlib.extname(e.path) === '.ts')\n if (typescriptEvents.length === 0) {\n return\n }\n\n this.logger.log('Changes detected, rebuilding')\n await this._restart(api, worker, httpTunnelUrl)\n },\n {\n ignore: [this.projectPaths.abs.outDir],\n }\n )\n\n await Promise.race([worker.wait(), watcher.wait(), supervisor.wait()])\n\n if (worker.running) {\n await worker.kill()\n }\n await watcher.close()\n supervisor.close()\n } catch (thrown) {\n throw errors.BotpressCLIError.wrap(thrown, 'An error occurred while running the dev server')\n } finally {\n if (worker.running) {\n await worker.kill()\n }\n }\n }\n\n private _restart = async (api: ApiClient, worker: Worker, tunnelUrl: string) => {\n try {\n await this._runBuild()\n } catch (thrown) {\n const error = errors.BotpressCLIError.wrap(thrown, 'Build failed')\n this.logger.error(error.message)\n return\n }\n\n await this._deploy(api, tunnelUrl)\n await worker.reload()\n }\n\n private _deploy = async (api: ApiClient, tunnelUrl: string) => {\n const projectDef = await this.readProjectDefinitionFromFS()\n if (projectDef.type === 'interface') {\n throw new errors.BotpressCLIError('This feature is not available for interfaces.')\n }\n\n if (projectDef.type === 'integration') {\n this._checkSecrets(projectDef.definition)\n await this._deployDevIntegration(api, tunnelUrl, projectDef.definition)\n } else {\n await this._deployDevBot(api, tunnelUrl)\n }\n }\n\n private _checkSecrets(integrationDef: sdk.IntegrationDefinition) {\n const initialSecrets = this._initialDef?.secrets ?? {}\n const currentSecrets = integrationDef.secrets ?? {}\n const newSecrets = Object.keys(currentSecrets).filter((s) => !initialSecrets[s])\n if (newSecrets.length > 0) {\n throw new errors.BotpressCLIError('Secrets were added while the server was running. A restart is required.')\n }\n }\n\n private _spawnWorker = async (env: Record<string, string>, port: number) => {\n const outfile = this.projectPaths.abs.outFile\n const importPath = utils.path.toUnix(outfile)\n const requireFrom = utils.path.rmExtension(importPath)\n const code = `require('${requireFrom}').default.start(${port})`\n const worker = await Worker.spawn(\n {\n type: 'code',\n code,\n env,\n },\n this.logger\n ).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not start dev worker')\n })\n\n return worker\n }\n\n private _runBuild() {\n return new BuildCommand(this.api, this.prompt, this.logger, this.argv).run()\n }\n\n private async _deployDevIntegration(\n api: ApiClient,\n externalUrl: string,\n integrationDef: sdk.IntegrationDefinition\n ): Promise<void> {\n const devId = await this.projectCache.get('devId')\n\n let integration: client.Integration | undefined = undefined\n\n if (devId) {\n const resp = await api.client.getIntegration({ id: devId }).catch(async (thrown) => {\n const err = errors.BotpressCLIError.wrap(thrown, `Could not find existing dev integration with id \"${devId}\"`)\n this.logger.warn(err.message)\n return { integration: undefined }\n })\n\n if (resp.integration?.dev) {\n integration = resp.integration\n } else {\n await this.projectCache.rm('devId')\n }\n }\n\n const line = this.logger.line()\n line.started(`Deploying dev integration ${chalk.bold(integrationDef.name)}...`)\n\n let createIntegrationBody: CreateIntegrationBody = await prepareCreateIntegrationBody(integrationDef)\n createIntegrationBody = {\n ...createIntegrationBody,\n url: externalUrl,\n configuration: await this.readIntegrationConfigDefinition(createIntegrationBody.configuration),\n configurations: await utils.promises.awaitRecord(\n utils.records.mapValues(createIntegrationBody.configurations ?? {}, this.readIntegrationConfigDefinition)\n ),\n }\n\n if (integration) {\n const updateIntegrationBody = prepareUpdateIntegrationBody(\n { ...createIntegrationBody, id: integration.id },\n integration\n )\n\n const resp = await api.client.updateIntegration(updateIntegrationBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not update dev integration \"${integrationDef.name}\"`)\n })\n integration = resp.integration\n } else {\n const resp = await api.client.createIntegration({ ...createIntegrationBody, dev: true }).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not deploy dev integration \"${integrationDef.name}\"`)\n })\n integration = resp.integration\n }\n\n line.success(`Dev Integration deployed with id \"${integration.id}\"`)\n line.commit()\n\n await this.projectCache.set('devId', integration.id)\n }\n\n private async _deployDevBot(api: ApiClient, externalUrl: string): Promise<void> {\n const devId = await this.projectCache.get('devId')\n\n let bot: client.Bot | undefined = undefined\n\n if (devId) {\n const resp = await api.client.getBot({ id: devId }).catch(async (thrown) => {\n const err = errors.BotpressCLIError.wrap(thrown, `Could not find existing dev bot with id \"${devId}\"`)\n this.logger.warn(err.message)\n return { bot: undefined }\n })\n\n if (resp.bot?.dev) {\n bot = resp.bot\n } else {\n await this.projectCache.rm('devId')\n }\n }\n\n if (!bot) {\n const createLine = this.logger.line()\n createLine.started('Creating dev bot...')\n const resp = await api.client\n .createBot({\n dev: true,\n url: externalUrl,\n })\n .catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not deploy dev bot')\n })\n\n bot = resp.bot\n createLine.success(`Dev Bot created with id \"${bot.id}\"`)\n createLine.commit()\n await this.projectCache.set('devId', bot.id)\n }\n\n const outfile = this.projectPaths.abs.outFile\n const { default: botImpl } = utils.require.requireJsFile<{ default: sdk.Bot }>(outfile)\n\n const updateLine = this.logger.line()\n updateLine.started('Deploying dev bot...')\n\n const integrationInstances = await this.fetchBotIntegrationInstances(botImpl, api)\n const updateBotBody = prepareUpdateBotBody(\n {\n ...(await prepareCreateBotBody(botImpl)),\n id: bot.id,\n url: externalUrl,\n integrations: integrationInstances,\n },\n bot\n )\n\n const { bot: updatedBot } = await api.client.updateBot(updateBotBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not deploy dev bot')\n })\n updateLine.success(`Dev Bot deployed with id \"${updatedBot.id}\"`)\n updateLine.commit()\n\n this.displayWebhookUrls(updatedBot)\n }\n\n private _forwardTunnelRequest = async (baseUrl: string, request: TunnelRequest): Promise<TunnelResponse> => {\n const axiosConfig = {\n method: request.method,\n url: this._formatLocalUrl(baseUrl, request),\n headers: request.headers,\n data: request.body,\n responseType: 'text',\n validateStatus: () => true,\n } satisfies AxiosRequestConfig\n\n this.logger.debug(`Forwarding request to ${axiosConfig.url}`)\n const response = await axios(axiosConfig)\n this.logger.debug('Sending back response up the tunnel')\n\n return {\n requestId: request.id,\n status: response.status,\n headers: this._getHeaders(response.headers),\n body: response.data,\n }\n }\n\n private _formatLocalUrl = (baseUrl: string, req: TunnelRequest): string => {\n if (req.query) {\n return `${baseUrl}${req.path}?${req.query}`\n }\n return `${baseUrl}${req.path}`\n }\n\n private _getHeaders = (res: AxiosResponse['headers']): TunnelResponse['headers'] => {\n const headers: TunnelResponse['headers'] = {}\n for (const key in res) {\n if (typeof res[key] === 'string' || typeof res[key] === 'number') {\n headers[key] = res[key]\n }\n }\n return headers\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,mBAAyD;AACzD,mBAAkB;AAClB,cAAyB;AACzB,WAAsB;AACtB,sBAA2D;AAE3D,8BAIO;AAEP,aAAwB;AACxB,YAAuB;AACvB,oBAAuB;AACvB,2BAA6B;AAC7B,6BAA+B;AAE/B,MAAM,mBAAmB;AACzB,MAAM,2BAA2B;AACjC,MAAM,wBAAwB;AAGvB,MAAM,mBAAmB,sCAAqC;AAAA,EAC3D,cAAqD;AAAA,EAE7D,MAAa,MAAqB;AAChC,SAAK,OAAO,KAAK,8EAA8E;AAE/F,UAAM,MAAM,MAAM,KAAK,2BAA2B,KAAK,IAAI;AAE3D,UAAM,aAAa,MAAM,KAAK,4BAA4B;AAC1D,QAAI,WAAW,SAAS,aAAa;AACnC,YAAM,IAAI,OAAO,iBAAiB,+CAA+C;AAAA,IACnF;AAEA,SAAK,cAAc,WAAW,cAAc;AAE5C,QAAI,MAA8B;AAAA,MAChC,GAAG,QAAQ;AAAA,MACX,YAAY,IAAI;AAAA,MAChB,UAAU,IAAI;AAAA,IAChB;AAEA,QAAI,cAAc;AAClB,QAAI,KAAK,aAAa;AACpB,oBAAc;AAEd,YAAM,qBAAqB,MAAM,KAAK,cAAc,KAAK,aAAa,KAAK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cAAc;AAAA,MACd,gBAAgB,MAAM;AAAA,IACxB;AAEA,SAAK,OAAO,MAAM,yBAAyB,YAAY,KAAK;AAC5D,UAAM,WAAW,UAAM,aAAAC,SAAM,WAAW;AACxC,SAAK,OAAO,MAAM,qCAAqC;AAEvD,WAAO;AAAA,MACL,WAAW,QAAQ;AAAA,MACnB,QAAQ,SAAS;AAAA,MACjB,SAAS,KAAK,YAAY,SAAS,OAAO;AAAA,MAC1C,MAAM,SAAS;AAAA,IACjB;AAAA,EACF;AAAA,EAEQ,kBAAkB,CAAC,SAAiB,QAA+B;AACzE,QAAI,IAAI,OAAO;AACb,aAAO,GAAG,UAAU,IAAI,QAAQ,IAAI;AAAA,IACtC;AACA,WAAO,GAAG,UAAU,IAAI;AAAA,EAC1B;AAAA,EAEQ,cAAc,CAAC,QAA6D;AAClF,UAAM,UAAqC,CAAC;AAC5C,eAAW,OAAO,KAAK;AACrB,UAAI,OAAO,IAAI,SAAS,YAAY,OAAO,IAAI,SAAS,UAAU;AAChE,gBAAQ,OAAO,IAAI;AAAA,MACrB;AAAA,IACF;AACA,WAAO;AAAA,EACT;AACF;",
6
6
  "names": ["chalk", "axios"]
7
7
  }
@@ -46,7 +46,7 @@ class LintCommand extends import_project_command.ProjectCommand {
46
46
  }
47
47
  }
48
48
  async _runLintForIntegration(definition) {
49
- const parsedIntegrationDefinition = (0, import_integration_body.prepareCreateIntegrationBody)(definition);
49
+ const parsedIntegrationDefinition = await (0, import_integration_body.prepareCreateIntegrationBody)(definition, { dereference: true });
50
50
  const linter = new import_integration_linter.IntegrationLinter(parsedIntegrationDefinition);
51
51
  await linter.lint();
52
52
  linter.logResults(this.logger);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/command-implementations/lint-command.ts"],
4
- "sourcesContent": ["import { IntegrationDefinition } from '@botpress/sdk'\nimport { prepareCreateIntegrationBody } from '../api/integration-body'\nimport type commandDefinitions from '../command-definitions'\nimport * as errors from '../errors'\nimport { IntegrationLinter } from '../linter/integration-linter'\nimport { ProjectCommand } from './project-command'\n\nexport type LintCommandDefinition = typeof commandDefinitions.lint\nexport class LintCommand extends ProjectCommand<LintCommandDefinition> {\n public async run(): Promise<void> {\n const projectDef = await this.readProjectDefinitionFromFS()\n\n switch (projectDef.type) {\n case 'integration':\n return this._runLintForIntegration(projectDef.definition)\n case 'bot':\n throw new errors.BotpressCLIError('Bot linting is not yet implemented')\n case 'interface':\n throw new errors.BotpressCLIError('Interface linting is not yet implemented')\n default:\n throw new errors.BotpressCLIError('Unsupported project type')\n }\n }\n\n private async _runLintForIntegration(definition: IntegrationDefinition): Promise<void> {\n const parsedIntegrationDefinition = prepareCreateIntegrationBody(definition)\n const linter = new IntegrationLinter(parsedIntegrationDefinition)\n\n await linter.lint()\n linter.logResults(this.logger)\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,8BAA6C;AAE7C,aAAwB;AACxB,gCAAkC;AAClC,6BAA+B;AAGxB,MAAM,oBAAoB,sCAAsC;AAAA,EACrE,MAAa,MAAqB;AAChC,UAAM,aAAa,MAAM,KAAK,4BAA4B;AAE1D,YAAQ,WAAW,MAAM;AAAA,MACvB,KAAK;AACH,eAAO,KAAK,uBAAuB,WAAW,UAAU;AAAA,MAC1D,KAAK;AACH,cAAM,IAAI,OAAO,iBAAiB,oCAAoC;AAAA,MACxE,KAAK;AACH,cAAM,IAAI,OAAO,iBAAiB,0CAA0C;AAAA,MAC9E;AACE,cAAM,IAAI,OAAO,iBAAiB,0BAA0B;AAAA,IAChE;AAAA,EACF;AAAA,EAEA,MAAc,uBAAuB,YAAkD;AACrF,UAAM,kCAA8B,sDAA6B,UAAU;AAC3E,UAAM,SAAS,IAAI,4CAAkB,2BAA2B;AAEhE,UAAM,OAAO,KAAK;AAClB,WAAO,WAAW,KAAK,MAAM;AAAA,EAC/B;AACF;",
4
+ "sourcesContent": ["import { IntegrationDefinition } from '@botpress/sdk'\nimport { prepareCreateIntegrationBody } from '../api/integration-body'\nimport type commandDefinitions from '../command-definitions'\nimport * as errors from '../errors'\nimport { IntegrationLinter } from '../linter/integration-linter'\nimport { ProjectCommand } from './project-command'\n\nexport type LintCommandDefinition = typeof commandDefinitions.lint\nexport class LintCommand extends ProjectCommand<LintCommandDefinition> {\n public async run(): Promise<void> {\n const projectDef = await this.readProjectDefinitionFromFS()\n\n switch (projectDef.type) {\n case 'integration':\n return this._runLintForIntegration(projectDef.definition)\n case 'bot':\n throw new errors.BotpressCLIError('Bot linting is not yet implemented')\n case 'interface':\n throw new errors.BotpressCLIError('Interface linting is not yet implemented')\n default:\n throw new errors.BotpressCLIError('Unsupported project type')\n }\n }\n\n private async _runLintForIntegration(definition: IntegrationDefinition): Promise<void> {\n const parsedIntegrationDefinition = await prepareCreateIntegrationBody(definition, { dereference: true })\n const linter = new IntegrationLinter(parsedIntegrationDefinition)\n\n await linter.lint()\n linter.logResults(this.logger)\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,8BAA6C;AAE7C,aAAwB;AACxB,gCAAkC;AAClC,6BAA+B;AAGxB,MAAM,oBAAoB,sCAAsC;AAAA,EACrE,MAAa,MAAqB;AAChC,UAAM,aAAa,MAAM,KAAK,4BAA4B;AAE1D,YAAQ,WAAW,MAAM;AAAA,MACvB,KAAK;AACH,eAAO,KAAK,uBAAuB,WAAW,UAAU;AAAA,MAC1D,KAAK;AACH,cAAM,IAAI,OAAO,iBAAiB,oCAAoC;AAAA,MACxE,KAAK;AACH,cAAM,IAAI,OAAO,iBAAiB,0CAA0C;AAAA,MAC9E;AACE,cAAM,IAAI,OAAO,iBAAiB,0BAA0B;AAAA,IAChE;AAAA,EACF;AAAA,EAEA,MAAc,uBAAuB,YAAkD;AACrF,UAAM,8BAA8B,UAAM,sDAA6B,YAAY,EAAE,aAAa,KAAK,CAAC;AACxG,UAAM,SAAS,IAAI,4CAAkB,2BAA2B;AAEhE,UAAM,OAAO,KAAK;AAClB,WAAO,WAAW,KAAK,MAAM;AAAA,EAC/B;AACF;",
6
6
  "names": []
7
7
  }
@@ -36,7 +36,7 @@ class ReadCommand extends import_project_command.ProjectCommand {
36
36
  async run() {
37
37
  const projectDef = await this.readProjectDefinitionFromFS();
38
38
  if (projectDef.type === "integration") {
39
- const parsed = (0, import_integration_body.prepareCreateIntegrationBody)(projectDef.definition);
39
+ const parsed = await (0, import_integration_body.prepareCreateIntegrationBody)(projectDef.definition);
40
40
  parsed.interfaces = utils.records.mapValues(projectDef.definition.interfaces, (iface) => ({
41
41
  id: "...",
42
42
  ...iface
@@ -45,7 +45,7 @@ class ReadCommand extends import_project_command.ProjectCommand {
45
45
  return;
46
46
  }
47
47
  if (projectDef.type === "interface") {
48
- const parsed = (0, import_interface_body.prepareCreateInterfaceBody)(projectDef.definition);
48
+ const parsed = await (0, import_interface_body.prepareCreateInterfaceBody)(projectDef.definition);
49
49
  this.logger.json(parsed);
50
50
  return;
51
51
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/command-implementations/read-command.ts"],
4
- "sourcesContent": ["import { prepareCreateIntegrationBody } from '../api/integration-body'\nimport { prepareCreateInterfaceBody } from '../api/interface-body'\nimport type commandDefinitions from '../command-definitions'\nimport * as errors from '../errors'\nimport * as utils from '../utils'\nimport { ProjectCommand } from './project-command'\n\nexport type ReadCommandDefinition = typeof commandDefinitions.read\nexport class ReadCommand extends ProjectCommand<ReadCommandDefinition> {\n public async run(): Promise<void> {\n const projectDef = await this.readProjectDefinitionFromFS()\n if (projectDef.type === 'integration') {\n const parsed = prepareCreateIntegrationBody(projectDef.definition)\n parsed.interfaces = utils.records.mapValues(projectDef.definition.interfaces, (iface) => ({\n id: '...', // need to be logged in to get this id\n ...iface,\n }))\n this.logger.json(parsed)\n return\n }\n if (projectDef.type === 'interface') {\n const parsed = prepareCreateInterfaceBody(projectDef.definition)\n this.logger.json(parsed)\n return\n }\n\n throw new errors.BotpressCLIError('A bot project has no definition to read')\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8BAA6C;AAC7C,4BAA2C;AAE3C,aAAwB;AACxB,YAAuB;AACvB,6BAA+B;AAGxB,MAAM,oBAAoB,sCAAsC;AAAA,EACrE,MAAa,MAAqB;AAChC,UAAM,aAAa,MAAM,KAAK,4BAA4B;AAC1D,QAAI,WAAW,SAAS,eAAe;AACrC,YAAM,aAAS,sDAA6B,WAAW,UAAU;AACjE,aAAO,aAAa,MAAM,QAAQ,UAAU,WAAW,WAAW,YAAY,CAAC,WAAW;AAAA,QACxF,IAAI;AAAA,QACJ,GAAG;AAAA,MACL,EAAE;AACF,WAAK,OAAO,KAAK,MAAM;AACvB;AAAA,IACF;AACA,QAAI,WAAW,SAAS,aAAa;AACnC,YAAM,aAAS,kDAA2B,WAAW,UAAU;AAC/D,WAAK,OAAO,KAAK,MAAM;AACvB;AAAA,IACF;AAEA,UAAM,IAAI,OAAO,iBAAiB,yCAAyC;AAAA,EAC7E;AACF;",
4
+ "sourcesContent": ["import { prepareCreateIntegrationBody } from '../api/integration-body'\nimport { prepareCreateInterfaceBody } from '../api/interface-body'\nimport type commandDefinitions from '../command-definitions'\nimport * as errors from '../errors'\nimport * as utils from '../utils'\nimport { ProjectCommand } from './project-command'\n\nexport type ReadCommandDefinition = typeof commandDefinitions.read\nexport class ReadCommand extends ProjectCommand<ReadCommandDefinition> {\n public async run(): Promise<void> {\n const projectDef = await this.readProjectDefinitionFromFS()\n if (projectDef.type === 'integration') {\n const parsed = await prepareCreateIntegrationBody(projectDef.definition)\n parsed.interfaces = utils.records.mapValues(projectDef.definition.interfaces, (iface) => ({\n id: '...', // need to be logged in to get this id\n ...iface,\n }))\n this.logger.json(parsed)\n return\n }\n if (projectDef.type === 'interface') {\n const parsed = await prepareCreateInterfaceBody(projectDef.definition)\n this.logger.json(parsed)\n return\n }\n\n throw new errors.BotpressCLIError('A bot project has no definition to read')\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8BAA6C;AAC7C,4BAA2C;AAE3C,aAAwB;AACxB,YAAuB;AACvB,6BAA+B;AAGxB,MAAM,oBAAoB,sCAAsC;AAAA,EACrE,MAAa,MAAqB;AAChC,UAAM,aAAa,MAAM,KAAK,4BAA4B;AAC1D,QAAI,WAAW,SAAS,eAAe;AACrC,YAAM,SAAS,UAAM,sDAA6B,WAAW,UAAU;AACvE,aAAO,aAAa,MAAM,QAAQ,UAAU,WAAW,WAAW,YAAY,CAAC,WAAW;AAAA,QACxF,IAAI;AAAA,QACJ,GAAG;AAAA,MACL,EAAE;AACF,WAAK,OAAO,KAAK,MAAM;AACvB;AAAA,IACF;AACA,QAAI,WAAW,SAAS,aAAa;AACnC,YAAM,SAAS,UAAM,kDAA2B,WAAW,UAAU;AACrE,WAAK,OAAO,KAAK,MAAM;AACvB;AAAA,IACF;AAEA,UAAM,IAAI,OAAO,iBAAiB,yCAAyC;AAAA,EAC7E;AACF;",
6
6
  "names": []
7
7
  }
@@ -113,7 +113,7 @@ const mockLogger = {
113
113
  };
114
114
  const lintDefinition = async (definition) => {
115
115
  const integrationDefinition = new import_sdk.IntegrationDefinition(definition);
116
- const linter = new import_integration_linter.IntegrationLinter((0, import_integration_body.prepareCreateIntegrationBody)(integrationDefinition));
116
+ const linter = new import_integration_linter.IntegrationLinter(await (0, import_integration_body.prepareCreateIntegrationBody)(integrationDefinition));
117
117
  await linter.lint();
118
118
  return linter;
119
119
  };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/linter/integration-linter.test.ts"],
4
- "sourcesContent": ["import { test, expect, describe, vi } from 'vitest'\nimport { prepareCreateIntegrationBody } from '../api/integration-body'\nimport { IntegrationLinter } from './integration-linter'\nimport { IntegrationDefinition, IntegrationDefinitionProps, z } from '@botpress/sdk'\nimport { Logger } from 'src/logger'\n\nconst EMPTY_STRING = ''\nconst TRUTHY_STRING = 'truthy'\nconst ACTION_NAME = 'actionName'\nconst EVENT_NAME = 'eventName'\nconst CONFIG_NAME = 'configName'\nconst PARAM_NAME = 'paramName'\nconst TAG_NAME = 'tagName'\nconst CHANNEL_NAME = 'channelName'\nconst STATE_NAME = 'stateName'\nconst MESSAGE_TYPE = 'text'\n\nconst VALID_INTEGRATION = {\n name: TRUTHY_STRING,\n title: TRUTHY_STRING,\n description: TRUTHY_STRING,\n version: TRUTHY_STRING,\n readme: TRUTHY_STRING,\n icon: TRUTHY_STRING,\n actions: {\n [ACTION_NAME]: {\n title: TRUTHY_STRING,\n description: TRUTHY_STRING,\n input: {\n schema: z\n .object({\n [PARAM_NAME]: z.string().title(TRUTHY_STRING).describe(TRUTHY_STRING),\n })\n .title(TRUTHY_STRING)\n .describe(TRUTHY_STRING),\n },\n output: {\n schema: z\n .object({\n [PARAM_NAME]: z.string().title(TRUTHY_STRING).describe(TRUTHY_STRING),\n })\n .title(TRUTHY_STRING)\n .describe(TRUTHY_STRING),\n },\n },\n },\n events: {\n [EVENT_NAME]: {\n title: TRUTHY_STRING,\n description: TRUTHY_STRING,\n schema: z\n .object({\n [PARAM_NAME]: z.string().title(TRUTHY_STRING).describe(TRUTHY_STRING),\n })\n .title(TRUTHY_STRING)\n .describe(TRUTHY_STRING),\n },\n },\n configuration: {\n schema: z\n .object({\n [PARAM_NAME]: z.string().title(TRUTHY_STRING).describe(TRUTHY_STRING),\n })\n .title(TRUTHY_STRING)\n .describe(TRUTHY_STRING),\n },\n configurations: {\n [CONFIG_NAME]: {\n title: TRUTHY_STRING,\n description: TRUTHY_STRING,\n schema: z\n .object({\n [PARAM_NAME]: z.string().title(TRUTHY_STRING).describe(TRUTHY_STRING),\n })\n .title(TRUTHY_STRING)\n .describe(TRUTHY_STRING),\n },\n },\n user: {\n tags: {\n [TAG_NAME]: {\n title: TRUTHY_STRING,\n description: TRUTHY_STRING,\n },\n },\n },\n channels: {\n [CHANNEL_NAME]: {\n title: TRUTHY_STRING,\n description: TRUTHY_STRING,\n messages: {\n [MESSAGE_TYPE]: {\n schema: z\n .object({\n [PARAM_NAME]: z.string().title(TRUTHY_STRING).describe(TRUTHY_STRING),\n })\n .title(TRUTHY_STRING)\n .describe(TRUTHY_STRING),\n },\n },\n message: {\n tags: {\n [TAG_NAME]: {\n title: TRUTHY_STRING,\n description: TRUTHY_STRING,\n },\n },\n },\n conversation: {\n tags: {\n [TAG_NAME]: {\n title: TRUTHY_STRING,\n description: TRUTHY_STRING,\n },\n },\n },\n },\n },\n states: {\n [STATE_NAME]: {\n type: 'integration',\n schema: z\n .object({\n [PARAM_NAME]: z.string().title(TRUTHY_STRING).describe(TRUTHY_STRING),\n })\n .title(TRUTHY_STRING)\n .describe(TRUTHY_STRING),\n },\n },\n} as const satisfies IntegrationDefinitionProps\n\nconst mockLogger = {\n log: vi.fn((message) => void message),\n warn: vi.fn((message) => void message),\n error: vi.fn((message) => void message),\n debug: vi.fn((message) => void message),\n}\n\nconst lintDefinition = async (definition: IntegrationDefinitionProps) => {\n const integrationDefinition = new IntegrationDefinition(definition)\n const linter = new IntegrationLinter(prepareCreateIntegrationBody(integrationDefinition))\n await linter.lint()\n return linter\n}\n\nconst lintDefinitionAndReturnResults = async (definition: IntegrationDefinitionProps) => {\n const linter = await lintDefinition(definition)\n return linter.getSortedResults()\n}\n\nconst lintDefinitionAndLogResults = async (definition: IntegrationDefinitionProps) => {\n const linter = await lintDefinition(definition)\n linter.logResults(mockLogger as any)\n}\n\ndescribe.concurrent('Integration Linter', () => {\n test('should lint a valid definition without giving errors', async () => {\n // arrange\n const definition = VALID_INTEGRATION\n\n // act\n const results = await lintDefinitionAndReturnResults(definition)\n\n expect(results).toEqual([])\n })\n\n test('should report an error when missing required fields', async () => {\n // arrange\n const definition = {\n ...VALID_INTEGRATION,\n title: EMPTY_STRING,\n } as const\n\n // act\n const results = await lintDefinitionAndReturnResults(definition)\n\n // assert\n expect(results[0]?.message).toContain('title')\n })\n\n test('should report an error when missing a title in an action input schema', async () => {\n // arrange\n const definition = {\n ...VALID_INTEGRATION,\n actions: {\n [ACTION_NAME]: {\n ...VALID_INTEGRATION.actions[ACTION_NAME],\n input: {\n schema: z.object({\n [PARAM_NAME]: z.string().describe(TRUTHY_STRING),\n }),\n },\n },\n },\n } as const\n\n // act\n const results = await lintDefinitionAndReturnResults(definition)\n\n // assert\n expect(results[0]?.message).toContain('title')\n })\n\n test('should log as an error when severity is 0', async () => {\n // arrange\n const definition = {\n ...VALID_INTEGRATION,\n title: EMPTY_STRING,\n } as const\n\n // act\n await lintDefinitionAndLogResults(definition)\n\n // assert\n expect(mockLogger.error).toHaveBeenCalled()\n })\n\n test('should log as a warning when severity is 1', async () => {\n // arrange\n const definition = {\n ...VALID_INTEGRATION,\n user: {\n tags: {\n [TAG_NAME]: {},\n },\n },\n } as const\n\n // act\n await lintDefinitionAndLogResults(definition)\n\n // assert\n expect(mockLogger.warn).toHaveBeenCalled()\n })\n})\n"],
5
- "mappings": ";AAAA,oBAA2C;AAC3C,8BAA6C;AAC7C,gCAAkC;AAClC,iBAAqE;AAGrE,MAAM,eAAe;AACrB,MAAM,gBAAgB;AACtB,MAAM,cAAc;AACpB,MAAM,aAAa;AACnB,MAAM,cAAc;AACpB,MAAM,aAAa;AACnB,MAAM,WAAW;AACjB,MAAM,eAAe;AACrB,MAAM,aAAa;AACnB,MAAM,eAAe;AAErB,MAAM,oBAAoB;AAAA,EACxB,MAAM;AAAA,EACN,OAAO;AAAA,EACP,aAAa;AAAA,EACb,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,SAAS;AAAA,IACP,CAAC,cAAc;AAAA,MACb,OAAO;AAAA,MACP,aAAa;AAAA,MACb,OAAO;AAAA,QACL,QAAQ,aACL,OAAO;AAAA,UACN,CAAC,aAAa,aAAE,OAAO,EAAE,M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AAI,EAAE,iBAAiB;AAAA,EAC3C,CAAC;AACH,CAAC;",
4
+ "sourcesContent": ["import { test, expect, describe, vi } from 'vitest'\nimport { prepareCreateIntegrationBody } from '../api/integration-body'\nimport { IntegrationLinter } from './integration-linter'\nimport { IntegrationDefinition, IntegrationDefinitionProps, z } from '@botpress/sdk'\nimport { Logger } from 'src/logger'\n\nconst EMPTY_STRING = ''\nconst TRUTHY_STRING = 'truthy'\nconst ACTION_NAME = 'actionName'\nconst EVENT_NAME = 'eventName'\nconst CONFIG_NAME = 'configName'\nconst PARAM_NAME = 'paramName'\nconst TAG_NAME = 'tagName'\nconst CHANNEL_NAME = 'channelName'\nconst STATE_NAME = 'stateName'\nconst MESSAGE_TYPE = 'text'\n\nconst VALID_INTEGRATION = {\n name: TRUTHY_STRING,\n title: TRUTHY_STRING,\n description: TRUTHY_STRING,\n version: TRUTHY_STRING,\n readme: TRUTHY_STRING,\n icon: TRUTHY_STRING,\n actions: {\n [ACTION_NAME]: {\n title: TRUTHY_STRING,\n description: TRUTHY_STRING,\n input: {\n schema: z\n .object({\n [PARAM_NAME]: z.string().title(TRUTHY_STRING).describe(TRUTHY_STRING),\n })\n .title(TRUTHY_STRING)\n .describe(TRUTHY_STRING),\n },\n output: {\n schema: z\n .object({\n [PARAM_NAME]: z.string().title(TRUTHY_STRING).describe(TRUTHY_STRING),\n })\n .title(TRUTHY_STRING)\n .describe(TRUTHY_STRING),\n },\n },\n },\n events: {\n [EVENT_NAME]: {\n title: TRUTHY_STRING,\n description: TRUTHY_STRING,\n schema: z\n .object({\n [PARAM_NAME]: z.string().title(TRUTHY_STRING).describe(TRUTHY_STRING),\n })\n .title(TRUTHY_STRING)\n .describe(TRUTHY_STRING),\n },\n },\n configuration: {\n schema: z\n .object({\n [PARAM_NAME]: z.string().title(TRUTHY_STRING).describe(TRUTHY_STRING),\n })\n .title(TRUTHY_STRING)\n .describe(TRUTHY_STRING),\n },\n configurations: {\n [CONFIG_NAME]: {\n title: TRUTHY_STRING,\n description: TRUTHY_STRING,\n schema: z\n .object({\n [PARAM_NAME]: z.string().title(TRUTHY_STRING).describe(TRUTHY_STRING),\n })\n .title(TRUTHY_STRING)\n .describe(TRUTHY_STRING),\n },\n },\n user: {\n tags: {\n [TAG_NAME]: {\n title: TRUTHY_STRING,\n description: TRUTHY_STRING,\n },\n },\n },\n channels: {\n [CHANNEL_NAME]: {\n title: TRUTHY_STRING,\n description: TRUTHY_STRING,\n messages: {\n [MESSAGE_TYPE]: {\n schema: z\n .object({\n [PARAM_NAME]: z.string().title(TRUTHY_STRING).describe(TRUTHY_STRING),\n })\n .title(TRUTHY_STRING)\n .describe(TRUTHY_STRING),\n },\n },\n message: {\n tags: {\n [TAG_NAME]: {\n title: TRUTHY_STRING,\n description: TRUTHY_STRING,\n },\n },\n },\n conversation: {\n tags: {\n [TAG_NAME]: {\n title: TRUTHY_STRING,\n description: TRUTHY_STRING,\n },\n },\n },\n },\n },\n states: {\n [STATE_NAME]: {\n type: 'integration',\n schema: z\n .object({\n [PARAM_NAME]: z.string().title(TRUTHY_STRING).describe(TRUTHY_STRING),\n })\n .title(TRUTHY_STRING)\n .describe(TRUTHY_STRING),\n },\n },\n} as const satisfies IntegrationDefinitionProps\n\nconst mockLogger = {\n log: vi.fn((message) => void message),\n warn: vi.fn((message) => void message),\n error: vi.fn((message) => void message),\n debug: vi.fn((message) => void message),\n}\n\nconst lintDefinition = async (definition: IntegrationDefinitionProps) => {\n const integrationDefinition = new IntegrationDefinition(definition)\n const linter = new IntegrationLinter(await prepareCreateIntegrationBody(integrationDefinition))\n await linter.lint()\n return linter\n}\n\nconst lintDefinitionAndReturnResults = async (definition: IntegrationDefinitionProps) => {\n const linter = await lintDefinition(definition)\n return linter.getSortedResults()\n}\n\nconst lintDefinitionAndLogResults = async (definition: IntegrationDefinitionProps) => {\n const linter = await lintDefinition(definition)\n linter.logResults(mockLogger as any)\n}\n\ndescribe.concurrent('Integration Linter', () => {\n test('should lint a valid definition without giving errors', async () => {\n // arrange\n const definition = VALID_INTEGRATION\n\n // act\n const results = await lintDefinitionAndReturnResults(definition)\n\n expect(results).toEqual([])\n })\n\n test('should report an error when missing required fields', async () => {\n // arrange\n const definition = {\n ...VALID_INTEGRATION,\n title: EMPTY_STRING,\n } as const\n\n // act\n const results = await lintDefinitionAndReturnResults(definition)\n\n // assert\n expect(results[0]?.message).toContain('title')\n })\n\n test('should report an error when missing a title in an action input schema', async () => {\n // arrange\n const definition = {\n ...VALID_INTEGRATION,\n actions: {\n [ACTION_NAME]: {\n ...VALID_INTEGRATION.actions[ACTION_NAME],\n input: {\n schema: z.object({\n [PARAM_NAME]: z.string().describe(TRUTHY_STRING),\n }),\n },\n },\n },\n } as const\n\n // act\n const results = await lintDefinitionAndReturnResults(definition)\n\n // assert\n expect(results[0]?.message).toContain('title')\n })\n\n test('should log as an error when severity is 0', async () => {\n // arrange\n const definition = {\n ...VALID_INTEGRATION,\n title: EMPTY_STRING,\n } as const\n\n // act\n await lintDefinitionAndLogResults(definition)\n\n // assert\n expect(mockLogger.error).toHaveBeenCalled()\n })\n\n test('should log as a warning when severity is 1', async () => {\n // arrange\n const definition = {\n ...VALID_INTEGRATION,\n user: {\n tags: {\n [TAG_NAME]: {},\n },\n },\n } as const\n\n // act\n await lintDefinitionAndLogResults(definition)\n\n // assert\n expect(mockLogger.warn).toHaveBeenCalled()\n })\n})\n"],
5
+ "mappings": ";AAAA,oBAA2C;AAC3C,8BAA6C;AAC7C,gCAAkC;AAClC,iBAAqE;AAGrE,MAAM,eAAe;AACrB,MAAM,gBAAgB;AACtB,MAAM,cAAc;AACpB,MAAM,aAAa;AACnB,MAAM,cAAc;AACpB,MAAM,aAAa;AACnB,MAAM,WAAW;AACjB,MAAM,eAAe;AACrB,MAAM,aAAa;AACnB,MAAM,eAAe;AAErB,MAAM,oBAAoB;AAAA,EACxB,MAAM;AAAA,EACN,OAAO;AAAA,EACP,aAAa;AAAA,EACb,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,MAA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,aAAa;AAAA,MACjB,GAAG;AAAA,MACH,MAAM;AAAA,QACJ,MAAM;AAAA,UACJ,CAAC,WAAW,CAAC;AAAA,QACf;AAAA,MACF;AAAA,IACF;AAGA,UAAM,4BAA4B,UAAU;AAG5C,8BAAO,WAAW,IAAI,EAAE,iBAAiB;AAAA,EAC3C,CAAC;AACH,CAAC;",
6
6
  "names": []
7
7
  }
@@ -21,6 +21,7 @@ __export(record_utils_exports, {
21
21
  filterValues: () => filterValues,
22
22
  mapKeys: () => mapKeys,
23
23
  mapValues: () => mapValues,
24
+ mapValuesAsync: () => mapValuesAsync,
24
25
  setNullOnMissingValues: () => setNullOnMissingValues,
25
26
  zipObjects: () => zipObjects
26
27
  });
@@ -52,6 +53,13 @@ const mapValues = (record, fn) => {
52
53
  }
53
54
  return newRecord;
54
55
  };
56
+ const mapValuesAsync = async (record, fn) => {
57
+ const newRecord = {};
58
+ for (const [key, value] of Object.entries(record)) {
59
+ newRecord[key] = await fn(value, key);
60
+ }
61
+ return newRecord;
62
+ };
55
63
  const mapKeys = (record, fn) => {
56
64
  const newRecord = {};
57
65
  for (const [key, value] of Object.entries(record)) {
@@ -74,6 +82,7 @@ function filterValues(record, fn) {
74
82
  filterValues,
75
83
  mapKeys,
76
84
  mapValues,
85
+ mapValuesAsync,
77
86
  setNullOnMissingValues,
78
87
  zipObjects
79
88
  });
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/utils/record-utils.ts"],
4
- "sourcesContent": ["export const setNullOnMissingValues = <A, B>(\n record: Record<string, A> = {},\n oldRecord: Record<string, B> = {}\n): Record<string, A | null> => {\n const newRecord: Record<string, A | null> = {}\n\n for (const [key, value] of Object.entries(record)) {\n newRecord[key] = value\n }\n\n for (const value of Object.keys(oldRecord)) {\n if (!record[value]) {\n newRecord[value] = null\n }\n }\n\n return newRecord\n}\n\nexport const zipObjects = <A, B>(\n recordA: Record<string, A>,\n recordB: Record<string, B>\n): Record<string, [A | null, B | null]> => {\n const allKeys = new Set([...Object.keys(recordA), ...Object.keys(recordB)])\n const newRecord: Record<string, [A | null, B | null]> = {}\n\n for (const key of allKeys) {\n newRecord[key] = [recordA[key] ?? null, recordB[key] ?? null]\n }\n\n return newRecord\n}\n\nexport const mapValues = <A, B>(record: Record<string, A>, fn: (value: A, key: string) => B): Record<string, B> => {\n const newRecord: Record<string, B> = {}\n\n for (const [key, value] of Object.entries(record)) {\n newRecord[key] = fn(value, key)\n }\n\n return newRecord\n}\n\nexport const mapKeys = <A>(record: Record<string, A>, fn: (value: A, key: string) => string): Record<string, A> => {\n const newRecord: Record<string, A> = {}\n\n for (const [key, value] of Object.entries(record)) {\n const newKey = fn(value, key) as string\n newRecord[newKey] = value\n }\n\n return newRecord\n}\n\nexport function filterValues<A, B extends A>(\n record: Record<string, A>,\n fn: (value: A, key: string) => value is B\n): Record<string, B>\nexport function filterValues<A, _B extends A>(\n record: Record<string, A>,\n fn: (value: A, key: string) => boolean\n): Record<string, A>\nexport function filterValues<A>(record: Record<string, A>, fn: (value: A, key: string) => boolean) {\n const newRecord: Record<string, A> = {}\n\n for (const [key, value] of Object.entries(record)) {\n if (fn(value, key)) {\n newRecord[key] = value\n }\n }\n\n return newRecord\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,yBAAyB,CACpC,SAA4B,CAAC,GAC7B,YAA+B,CAAC,MACH;AAC7B,QAAM,YAAsC,CAAC;AAE7C,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,MAAM,GAAG;AACjD,cAAU,OAAO;AAAA,EACnB;AAEA,aAAW,SAAS,OAAO,KAAK,SAAS,GAAG;AAC1C,QAAI,CAAC,OAAO,QAAQ;AAClB,gBAAU,SAAS;AAAA,IACrB;AAAA,EACF;AAEA,SAAO;AACT;AAEO,MAAM,aAAa,CACxB,SACA,YACyC;AACzC,QAAM,UAAU,oBAAI,IAAI,CAAC,GAAG,OAAO,KAAK,OAAO,GAAG,GAAG,OAAO,KAAK,OAAO,CAAC,CAAC;AAC1E,QAAM,YAAkD,CAAC;AAEzD,aAAW,OAAO,SAAS;AACzB,cAAU,OAAO,CAAC,QAAQ,QAAQ,MAAM,QAAQ,QAAQ,IAAI;AAAA,EAC9D;AAEA,SAAO;AACT;AAEO,MAAM,YAAY,CAAO,QAA2B,OAAwD;AACjH,QAAM,YAA+B,CAAC;AAEtC,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,MAAM,GAAG;AACjD,cAAU,OAAO,GAAG,OAAO,GAAG;AAAA,EAChC;AAEA,SAAO;AACT;AAEO,MAAM,UAAU,CAAI,QAA2B,OAA6D;AACjH,QAAM,YAA+B,CAAC;AAEtC,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,MAAM,GAAG;AACjD,UAAM,SAAS,GAAG,OAAO,GAAG;AAC5B,cAAU,UAAU;AAAA,EACtB;AAEA,SAAO;AACT;AAUO,SAAS,aAAgB,QAA2B,IAAwC;AACjG,QAAM,YAA+B,CAAC;AAEtC,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,MAAM,GAAG;AACjD,QAAI,GAAG,OAAO,GAAG,GAAG;AAClB,gBAAU,OAAO;AAAA,IACnB;AAAA,EACF;AAEA,SAAO;AACT;",
4
+ "sourcesContent": ["export const setNullOnMissingValues = <A, B>(\n record: Record<string, A> = {},\n oldRecord: Record<string, B> = {}\n): Record<string, A | null> => {\n const newRecord: Record<string, A | null> = {}\n\n for (const [key, value] of Object.entries(record)) {\n newRecord[key] = value\n }\n\n for (const value of Object.keys(oldRecord)) {\n if (!record[value]) {\n newRecord[value] = null\n }\n }\n\n return newRecord\n}\n\nexport const zipObjects = <A, B>(\n recordA: Record<string, A>,\n recordB: Record<string, B>\n): Record<string, [A | null, B | null]> => {\n const allKeys = new Set([...Object.keys(recordA), ...Object.keys(recordB)])\n const newRecord: Record<string, [A | null, B | null]> = {}\n\n for (const key of allKeys) {\n newRecord[key] = [recordA[key] ?? null, recordB[key] ?? null]\n }\n\n return newRecord\n}\n\nexport const mapValues = <A, B>(record: Record<string, A>, fn: (value: A, key: string) => B): Record<string, B> => {\n const newRecord: Record<string, B> = {}\n\n for (const [key, value] of Object.entries(record)) {\n newRecord[key] = fn(value, key)\n }\n\n return newRecord\n}\n\nexport const mapValuesAsync = async <A, B>(\n record: Record<string, A>,\n fn: (value: A, key: string) => Promise<B>\n): Promise<Record<string, B>> => {\n const newRecord: Record<string, B> = {}\n\n for (const [key, value] of Object.entries(record)) {\n newRecord[key] = await fn(value, key)\n }\n\n return newRecord\n}\n\nexport const mapKeys = <A>(record: Record<string, A>, fn: (value: A, key: string) => string): Record<string, A> => {\n const newRecord: Record<string, A> = {}\n\n for (const [key, value] of Object.entries(record)) {\n const newKey = fn(value, key) as string\n newRecord[newKey] = value\n }\n\n return newRecord\n}\n\nexport function filterValues<A, B extends A>(\n record: Record<string, A>,\n fn: (value: A, key: string) => value is B\n): Record<string, B>\nexport function filterValues<A, _B extends A>(\n record: Record<string, A>,\n fn: (value: A, key: string) => boolean\n): Record<string, A>\nexport function filterValues<A>(record: Record<string, A>, fn: (value: A, key: string) => boolean) {\n const newRecord: Record<string, A> = {}\n\n for (const [key, value] of Object.entries(record)) {\n if (fn(value, key)) {\n newRecord[key] = value\n }\n }\n\n return newRecord\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,yBAAyB,CACpC,SAA4B,CAAC,GAC7B,YAA+B,CAAC,MACH;AAC7B,QAAM,YAAsC,CAAC;AAE7C,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,MAAM,GAAG;AACjD,cAAU,OAAO;AAAA,EACnB;AAEA,aAAW,SAAS,OAAO,KAAK,SAAS,GAAG;AAC1C,QAAI,CAAC,OAAO,QAAQ;AAClB,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chema: () => mapZodToJsonSchema
22
22
  });
23
23
  module.exports = __toCommonJS(schema_utils_exports);
24
+ var import_json_schema_ref_parser = require("@apidevtools/json-schema-ref-parser");
24
25
  var import_sdk = require("@botpress/sdk");
25
26
  const isObjectSchema = (schema) => schema.type === "object";
26
- function mapZodToJsonSchema(definition) {
27
- const schema = import_sdk.transforms.zuiToJsonSchema(definition.schema, { target: "jsonSchema7" });
27
+ async function mapZodToJsonSchema(definition, options = {}) {
28
+ let schema = import_sdk.transforms.zuiToJsonSchema(definition.schema, { target: "jsonSchema7" });
29
+ if (options.dereference) {
30
+ schema = await (0, import_json_schema_ref_parser.dereference)(schema);
31
+ }
28
32
  if (!isObjectSchema(schema) || !definition.ui) {
29
33
  return schema;
30
34
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/utils/schema-utils.ts"],
4
- "sourcesContent": ["import { z, transforms } from '@botpress/sdk'\n\ntype ZuiToJsonSchema = typeof transforms.zuiToJsonSchema\ntype JsonSchema = ReturnType<ZuiToJsonSchema>\ntype ObjectJsonSchema = Extract<JsonSchema, { type: 'object' }>\n\ntype SchemaOptions = {\n title?: string\n examples?: any[]\n}\n\ntype SchemaDefinition = {\n schema: z.ZodObject<any>\n ui?: Record<string, SchemaOptions | undefined>\n}\n\nconst isObjectSchema = (schema: JsonSchema): schema is ObjectJsonSchema => schema.type === 'object'\n\nexport function mapZodToJsonSchema(definition: SchemaDefinition): ReturnType<typeof transforms.zuiToJsonSchema> {\n const schema = transforms.zuiToJsonSchema(definition.schema, { target: 'jsonSchema7' })\n if (!isObjectSchema(schema) || !definition.ui) {\n return schema\n }\n\n for (const [key, value] of Object.entries(definition.ui ?? {})) {\n const property = schema.properties?.[key]\n\n if (!property) {\n continue\n }\n\n if (!!value?.title) {\n ;(property as any).title = value.title\n }\n\n if (!!value?.examples) {\n ;(property as any).examples = value.examples\n }\n }\n\n return schema\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAA8B;AAgB9B,MAAM,iBAAiB,CAAC,WAAmD,OAAO,SAAS;AAEpF,SAAS,mBAAmB,YAA6E;AAC9G,QAAM,SAAS,sBAAW,gBAAgB,WAAW,QAAQ,EAAE,QAAQ,cAAc,CAAC;AACtF,MAAI,CAAC,eAAe,MAAM,KAAK,CAAC,WAAW,IAAI;AAC7C,WAAO;AAAA,EACT;AAEA,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,WAAW,MAAM,CAAC,CAAC,GAAG;AAC9D,UAAM,WAAW,OAAO,aAAa;AAErC,QAAI,CAAC,UAAU;AACb;AAAA,IACF;AAEA,QAAI,CAAC,CAAC,OAAO,OAAO;AAClB;AAAC,MAAC,SAAiB,QAAQ,MAAM;AAAA,IACnC;AAEA,QAAI,CAAC,CAAC,OAAO,UAAU;AACrB;AAAC,MAAC,SAAiB,WAAW,MAAM;AAAA,IACtC;AAAA,EACF;AAEA,SAAO;AACT;",
4
+ "sourcesContent": ["import { dereference } from '@apidevtools/json-schema-ref-parser'\nimport { z, transforms, JSONSchema } from '@botpress/sdk'\n\ntype ZuiToJsonSchema = typeof transforms.zuiToJsonSchema\ntype JsonSchema = ReturnType<ZuiToJsonSchema>\ntype ObjectJsonSchema = Extract<JsonSchema, { type: 'object' }>\n\ntype SchemaOptions = {\n title?: string\n examples?: any[]\n}\n\ntype SchemaDefinition = {\n schema: z.ZodObject<any>\n ui?: Record<string, SchemaOptions | undefined>\n}\n\nexport type ZodToJsonOptions = {\n dereference?: boolean\n}\n\nconst isObjectSchema = (schema: JsonSchema): schema is ObjectJsonSchema => schema.type === 'object'\n\nexport async function mapZodToJsonSchema(\n definition: SchemaDefinition,\n options: ZodToJsonOptions = {}\n): Promise<ReturnType<typeof transforms.zuiToJsonSchema>> {\n let schema = transforms.zuiToJsonSchema(definition.schema, { target: 'jsonSchema7' })\n\n if (options.dereference) {\n schema = (await dereference(schema)) as JSONSchema satisfies JSONSchema\n }\n\n if (!isObjectSchema(schema) || !definition.ui) {\n return schema\n }\n\n for (const [key, value] of Object.entries(definition.ui ?? {})) {\n const property = schema.properties?.[key]\n\n if (!property) {\n continue\n }\n\n if (!!value?.title) {\n ;(property as any).title = value.title\n }\n\n if (!!value?.examples) {\n ;(property as any).examples = value.examples\n }\n }\n\n return schema\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oCAA4B;AAC5B,iBAA0C;AAoB1C,MAAM,iBAAiB,CAAC,WAAmD,OAAO,SAAS;AAE3F,eAAsB,mBACpB,YACA,UAA4B,CAAC,GAC2B;AACxD,MAAI,SAAS,sBAAW,gBAAgB,WAAW,QAAQ,EAAE,QAAQ,cAAc,CAAC;AAEpF,MAAI,QAAQ,aAAa;AACvB,aAAU,UAAM,2CAAY,MAAM;AAAA,EACpC;AAEA,MAAI,CAAC,eAAe,MAAM,KAAK,CAAC,WAAW,IAAI;AAC7C,WAAO;AAAA,EACT;AAEA,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,WAAW,MAAM,CAAC,CAAC,GAAG;AAC9D,UAAM,WAAW,OAAO,aAAa;AAErC,QAAI,CAAC,UAAU;AACb;AAAA,IACF;AAEA,QAAI,CAAC,CAAC,OAAO,OAAO;AAClB;AAAC,MAAC,SAAiB,QAAQ,MAAM;AAAA,IACnC;AAEA,QAAI,CAAC,CAAC,OAAO,UAAU;AACrB;AAAC,MAAC,SAAiB,WAAW,MAAM;AAAA,IACtC;AAAA,EACF;AAEA,SAAO;AACT;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@botpress/cli",
3
- "version": "0.11.1",
3
+ "version": "0.11.2",
4
4
  "description": "Botpress CLI",
5
5
  "scripts": {
6
6
  "build": "pnpm run bundle && pnpm run template:gen",
@@ -20,6 +20,7 @@
20
20
  },
21
21
  "main": "dist/index.js",
22
22
  "dependencies": {
23
+ "@apidevtools/json-schema-ref-parser": "^11.7.0",
23
24
  "@botpress/client": "0.31.0",
24
25
  "@botpress/sdk": "0.11.6",
25
26
  "@bpinternal/const": "^0.0.20",