@botpress/cli 0.8.34 ā 0.8.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +9 -9
- package/dist/api/client.js +6 -0
- package/dist/api/client.js.map +2 -2
- package/dist/api/integration-body.js +1 -0
- package/dist/api/integration-body.js.map +2 -2
- package/dist/api/interface-body.js +76 -0
- package/dist/api/interface-body.js.map +7 -0
- package/dist/api/types.js.map +1 -1
- package/dist/code-generation/integration-implementation.js +16 -3
- package/dist/code-generation/integration-implementation.js.map +2 -2
- package/dist/code-generation/integration-instance.js +13 -3
- package/dist/code-generation/integration-instance.js.map +2 -2
- package/dist/code-generation/integration-schemas/actions-module.js +2 -1
- package/dist/code-generation/integration-schemas/actions-module.js.map +2 -2
- package/dist/code-generation/integration-schemas/entities-module.js +66 -0
- package/dist/code-generation/integration-schemas/entities-module.js.map +7 -0
- package/dist/code-generation/map-integration.js +4 -3
- package/dist/code-generation/map-integration.js.map +2 -2
- package/dist/code-generation/typings.js.map +1 -1
- package/dist/command-definitions.js +10 -2
- package/dist/command-definitions.js.map +2 -2
- package/dist/command-implementations/add-command.js +20 -13
- package/dist/command-implementations/add-command.js.map +2 -2
- package/dist/command-implementations/build-command.js +5 -1
- package/dist/command-implementations/build-command.js.map +2 -2
- package/dist/command-implementations/bundle-command.js +5 -1
- package/dist/command-implementations/bundle-command.js.map +2 -2
- package/dist/command-implementations/deploy-command.js +70 -4
- package/dist/command-implementations/deploy-command.js.map +2 -2
- package/dist/command-implementations/dev-command.js +12 -5
- package/dist/command-implementations/dev-command.js.map +2 -2
- package/dist/command-implementations/gen-command.js +4 -3
- package/dist/command-implementations/gen-command.js.map +2 -2
- package/dist/command-implementations/index.js +8 -0
- package/dist/command-implementations/index.js.map +2 -2
- package/dist/command-implementations/interface-commands.js +106 -0
- package/dist/command-implementations/interface-commands.js.map +7 -0
- package/dist/command-implementations/project-command.js +33 -4
- package/dist/command-implementations/project-command.js.map +2 -2
- package/dist/command-implementations/read-command.js +17 -5
- package/dist/command-implementations/read-command.js.map +2 -2
- package/dist/command-implementations/serve-command.js +7 -4
- package/dist/command-implementations/serve-command.js.map +2 -2
- package/dist/config.js +22 -1
- package/dist/config.js.map +2 -2
- package/dist/consts.js +2 -1
- package/dist/consts.js.map +2 -2
- package/dist/errors.js +10 -2
- package/dist/errors.js.map +2 -2
- package/package.json +2 -2
- package/templates/echo-bot/package.json +1 -1
- package/templates/empty-integration/.botpress/implementation/entities/index.ts +6 -0
- package/templates/empty-integration/.botpress/implementation/index.ts +7 -1
- package/templates/empty-integration/package.json +1 -1
- package/templates/hello-world/.botpress/implementation/entities/index.ts +6 -0
- package/templates/hello-world/.botpress/implementation/index.ts +7 -1
- package/templates/hello-world/package.json +1 -1
- package/templates/webhook-message/.botpress/implementation/entities/index.ts +6 -0
- package/templates/webhook-message/.botpress/implementation/index.ts +7 -1
- package/templates/webhook-message/package.json +1 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
|
|
2
|
-
> @botpress/cli@0.8.
|
|
2
|
+
> @botpress/cli@0.8.36 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.8.
|
|
6
|
+
> @botpress/cli@0.8.36 bundle /home/runner/work/botpress/botpress/packages/cli
|
|
7
7
|
> ts-node -T build.ts
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
> @botpress/cli@0.8.
|
|
10
|
+
> @botpress/cli@0.8.36 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.8.
|
|
14
|
-
š¤ Botpress CLI v0.8.
|
|
15
|
-
š¤ Botpress CLI v0.8.
|
|
16
|
-
š¤ Botpress CLI v0.8.
|
|
17
|
-
|
|
18
|
-
[2K[1G
|
|
13
|
+
š¤ Botpress CLI v0.8.36
|
|
14
|
+
š¤ Botpress CLI v0.8.36
|
|
15
|
+
š¤ Botpress CLI v0.8.36
|
|
16
|
+
š¤ Botpress CLI v0.8.36
|
|
17
|
+
[2K[1Gā Generating typings for integration webhook-message...[2K[1Gā Generating typings for integration hello-world...[2K[1Gā Generating typings for integration empty-integration...ā No typings to generate for bot projects
|
|
18
|
+
[2K[1Gā Typings available at .botpress
|
|
19
19
|
[2K[1Gā Typings available at .botpress
|
|
20
20
|
[2K[1Gā Typings available at .botpress
|
package/dist/api/client.js
CHANGED
|
@@ -94,6 +94,12 @@ class ApiClient {
|
|
|
94
94
|
}
|
|
95
95
|
return this.validateStatus(() => this.client.getPublicIntegration(ref).then((r) => r.integration), 404);
|
|
96
96
|
}
|
|
97
|
+
async findPublicInterface(ref) {
|
|
98
|
+
if (ref.type === "id") {
|
|
99
|
+
return this.validateStatus(() => this.client.getInterface(ref).then((r) => r.interface), 404);
|
|
100
|
+
}
|
|
101
|
+
return this.validateStatus(() => this.client.getInterfaceByName(ref).then((r) => r.interface), 404);
|
|
102
|
+
}
|
|
97
103
|
async testLogin() {
|
|
98
104
|
await this.client.listBots({});
|
|
99
105
|
}
|
package/dist/api/client.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/api/client.ts"],
|
|
4
|
-
"sourcesContent": ["import * as client from '@botpress/client'\nimport _ from 'lodash'\nimport { formatIntegrationRef, ApiIntegrationRef as IntegrationRef, NameIntegrationRef } from '../integration-ref'\nimport type { Logger } from '../logger'\nimport { findPreviousIntegrationVersion } from './find-previous-version'\nimport * as paging from './paging'\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,aAAwB;AACxB,oBAAc;AACd,6BAA8F;AAE9F,mCAA+C;AAC/C,aAAwB;
|
|
4
|
+
"sourcesContent": ["import * as client from '@botpress/client'\nimport _ from 'lodash'\nimport { formatIntegrationRef, ApiIntegrationRef as IntegrationRef, NameIntegrationRef } from '../integration-ref'\nimport type { Logger } from '../logger'\nimport { findPreviousIntegrationVersion } from './find-previous-version'\nimport * as paging from './paging'\nimport {\n ApiClientProps,\n PublicIntegration,\n PrivateIntegration,\n Integration,\n Requests,\n Responses,\n Interface,\n} from './types'\n\nexport * from './types'\n\n/**\n * This class is used to wrap the Botpress API and provide a more convenient way to interact with it.\n */\nexport class ApiClient {\n public readonly client: client.Client\n public readonly url: string\n public readonly token: string\n public readonly workspaceId: string\n\n public static newClient = (props: ApiClientProps, logger: Logger) => new ApiClient(props, logger)\n\n public constructor(props: ApiClientProps, private _logger: Logger) {\n const { apiUrl, token, workspaceId } = props\n this.client = new client.Client({ apiUrl, token, workspaceId })\n this.url = apiUrl\n this.token = token\n this.workspaceId = workspaceId\n }\n\n public get isBotpressWorkspace(): boolean {\n return [\n '6a76fa10-e150-4ff6-8f59-a300feec06c1',\n '95de33eb-1551-4af9-9088-e5dcb02efd09',\n '11111111-1111-1111-aaaa-111111111111',\n ].includes(this.workspaceId)\n }\n\n public async getWorkspace(): Promise<Responses['getWorkspace']> {\n return this.client.getWorkspace({ id: this.workspaceId })\n }\n\n public async updateWorkspace(props: Omit<Requests['updateWorkspace'], 'id'>): Promise<Responses['updateWorkspace']> {\n return this.client.updateWorkspace({ id: this.workspaceId, ...props })\n }\n\n public async findIntegration(ref: IntegrationRef): Promise<Integration | undefined> {\n const formatted = formatIntegrationRef(ref)\n\n const privateIntegration = await this.findPrivateIntegration(ref)\n if (privateIntegration) {\n this._logger.debug(`Found integration \"${formatted}\" in workspace`)\n return privateIntegration\n }\n\n const publicIntegration = await this.findPublicIntegration(ref)\n if (publicIntegration) {\n this._logger.debug(`Found integration \"${formatted}\" in hub`)\n return publicIntegration\n }\n\n return\n }\n\n public async findPrivateIntegration(ref: IntegrationRef): Promise<PrivateIntegration | undefined> {\n const { workspaceId } = this\n if (ref.type === 'id') {\n return this.validateStatus(\n () => this.client.getIntegration(ref).then((r) => ({ ...r.integration, workspaceId })),\n 404\n )\n }\n return this.validateStatus(\n () => this.client.getIntegrationByName(ref).then((r) => ({ ...r.integration, workspaceId })),\n 404\n )\n }\n\n public async findPublicIntegration(ref: IntegrationRef): Promise<PublicIntegration | undefined> {\n if (ref.type === 'id') {\n return this.validateStatus(() => this.client.getPublicIntegrationById(ref).then((r) => r.integration), 404)\n }\n return this.validateStatus(() => this.client.getPublicIntegration(ref).then((r) => r.integration), 404)\n }\n\n public async findPublicInterface(ref: IntegrationRef): Promise<Interface | undefined> {\n if (ref.type === 'id') {\n return this.validateStatus(() => this.client.getInterface(ref).then((r) => r.interface), 404)\n }\n return this.validateStatus(() => this.client.getInterfaceByName(ref).then((r) => r.interface), 404)\n }\n\n public async testLogin(): Promise<void> {\n await this.client.listBots({})\n }\n\n public listAllPages = paging.listAllPages\n\n public async validateStatus<V>(fn: () => Promise<V>, allowedStatuses: number | number[]): Promise<V | undefined> {\n try {\n const v = await fn()\n return v\n } catch (err) {\n const allowedStatusesArray = _.isArray(allowedStatuses) ? allowedStatuses : [allowedStatuses]\n const isAllowed = client.isApiError(err) && err.code && allowedStatusesArray.includes(err.code)\n if (isAllowed) {\n return\n }\n throw err\n }\n }\n\n public async findPreviousIntegrationVersion(ref: NameIntegrationRef): Promise<Integration | undefined> {\n const previous = await findPreviousIntegrationVersion(this.client, ref)\n if (!previous) {\n return\n }\n return this.findIntegration({ type: 'id', id: previous.id })\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,aAAwB;AACxB,oBAAc;AACd,6BAA8F;AAE9F,mCAA+C;AAC/C,aAAwB;AAWxB,2BAAc,oBAhBd;AAqBO,MAAM,UAAU;AAAA,EAQd,YAAY,OAA+B,SAAiB;AAAjB;AAChD,UAAM,EAAE,QA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6DAA+B,KAAK,QAAQ,GAAG;AACtE,QAAI,CAAC,UAAU;AACb;AAAA,IACF;AACA,WAAO,KAAK,gBAAgB,EAAE,MAAM,MAAM,IAAI,SAAS,GAAG,CAAC;AAAA,EAC7D;AACF;",
|
|
6
6
|
"names": ["_"]
|
|
7
7
|
}
|
|
@@ -39,6 +39,7 @@ const prepareCreateIntegrationBody = (integration) => ({
|
|
|
39
39
|
user: integration.user,
|
|
40
40
|
identifier: integration.identifier,
|
|
41
41
|
secrets: void 0,
|
|
42
|
+
interfaces: {},
|
|
42
43
|
configuration: integration.configuration ? {
|
|
43
44
|
...integration.configuration,
|
|
44
45
|
schema: utils.schema.mapZodToJsonSchema(integration.configuration)
|
|
@@ -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 configuration: integration.configuration\n ? {\n ...integration.configuration,\n schema: utils.schema.mapZodToJsonSchema(integration.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 return {\n ...localIntegration,\n actions,\n events,\n states,\n entities,\n user,\n channels,\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,eAAe,YAAY,gBACvB;AAAA,IACE,GAAG,YAAY;AAAA,IACf,QAAQ,MAAM,OAAO,mBAAmB,YAAY,aAAa;AAAA,EACnE,IACA;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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WAAW,qCAAqC,iBAAiB,YAAY,CAAC,GAAG,kBAAkB,QAAQ;AAEjH,SAAO;AAAA,IACL,GAAG;AAAA,IACH;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 * 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 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 return {\n ...localIntegration,\n actions,\n events,\n states,\n entities,\n user,\n channels,\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,EAC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Ac,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
|
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
var interface_body_exports = {};
|
|
26
|
+
__export(interface_body_exports, {
|
|
27
|
+
prepareCreateInterfaceBody: () => prepareCreateInterfaceBody,
|
|
28
|
+
prepareUpdateInterfaceBody: () => prepareUpdateInterfaceBody
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(interface_body_exports);
|
|
31
|
+
var import_sdk = require("@botpress/sdk");
|
|
32
|
+
var utils = __toESM(require("../utils"));
|
|
33
|
+
const prepareCreateInterfaceBody = (intrface) => ({
|
|
34
|
+
name: intrface.name,
|
|
35
|
+
version: intrface.version,
|
|
36
|
+
entities: intrface.entities ? utils.records.mapValues(intrface.entities, (entity) => ({
|
|
37
|
+
...entity,
|
|
38
|
+
schema: utils.schema.mapZodToJsonSchema(entity)
|
|
39
|
+
})) : {},
|
|
40
|
+
events: intrface.events ? utils.records.mapValues(intrface.events, (event) => ({
|
|
41
|
+
...event,
|
|
42
|
+
schema: utils.schema.mapZodToJsonSchema(_dereference(intrface, event))
|
|
43
|
+
})) : {},
|
|
44
|
+
actions: intrface.actions ? utils.records.mapValues(intrface.actions, (action) => ({
|
|
45
|
+
...action,
|
|
46
|
+
input: {
|
|
47
|
+
...action.input,
|
|
48
|
+
schema: utils.schema.mapZodToJsonSchema(_dereference(intrface, action.input))
|
|
49
|
+
},
|
|
50
|
+
output: {
|
|
51
|
+
...action.output,
|
|
52
|
+
schema: utils.schema.mapZodToJsonSchema(_dereference(intrface, action.output))
|
|
53
|
+
}
|
|
54
|
+
})) : {}
|
|
55
|
+
});
|
|
56
|
+
const prepareUpdateInterfaceBody = (localInterface, remoteInterface) => {
|
|
57
|
+
const actions = utils.records.setNullOnMissingValues(localInterface.actions, remoteInterface.actions);
|
|
58
|
+
const events = utils.records.setNullOnMissingValues(localInterface.events, remoteInterface.events);
|
|
59
|
+
const entities = utils.records.setNullOnMissingValues(localInterface.entities, remoteInterface.entities);
|
|
60
|
+
return {
|
|
61
|
+
...localInterface,
|
|
62
|
+
entities,
|
|
63
|
+
actions,
|
|
64
|
+
events
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
const _dereference = (intrface, { schema }) => {
|
|
68
|
+
const typeArguments = utils.records.mapValues(intrface.entities, (_, entityName) => import_sdk.z.ref(entityName));
|
|
69
|
+
return { schema: schema(typeArguments) };
|
|
70
|
+
};
|
|
71
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
72
|
+
0 && (module.exports = {
|
|
73
|
+
prepareCreateInterfaceBody,
|
|
74
|
+
prepareUpdateInterfaceBody
|
|
75
|
+
});
|
|
76
|
+
//# sourceMappingURL=interface-body.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 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;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/api/types.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/api/types.ts"],
|
|
4
|
-
"sourcesContent": ["import * as client from '@botpress/client'\nimport { Logger } from 'src/logger'\nimport { ApiClient } from './client'\n\nexport type ApiClientProps = {\n apiUrl: string\n token: string\n workspaceId: string\n}\n\nexport type ApiClientFactory = {\n newClient: (props: ApiClientProps, logger: Logger) => ApiClient\n}\n\nexport type PublicIntegration = client.Integration\nexport type PrivateIntegration = client.Integration & { workspaceId: string }\nexport type Integration = client.Integration & { workspaceId?: string }\nexport type IntegrationSummary = client.ClientOutputs['listIntegrations']['integrations'][number]\n\nexport type BaseOperation = (...args: any[]) => Promise<any>\nexport type Operations = {\n [K in keyof client.Client as client.Client[K] extends BaseOperation ? K : never]: client.Client[K]\n}\nexport type Requests = {\n [K in keyof Operations]: Parameters<Operations[K]>[0]\n}\nexport type Responses = {\n [K in keyof Operations]: ReturnType<Operations[K]>\n}\n"],
|
|
4
|
+
"sourcesContent": ["import * as client from '@botpress/client'\nimport { Logger } from 'src/logger'\nimport { ApiClient } from './client'\n\nexport type ApiClientProps = {\n apiUrl: string\n token: string\n workspaceId: string\n}\n\nexport type ApiClientFactory = {\n newClient: (props: ApiClientProps, logger: Logger) => ApiClient\n}\n\nexport type PublicIntegration = client.Integration\nexport type PrivateIntegration = client.Integration & { workspaceId: string }\nexport type Integration = client.Integration & { workspaceId?: string }\nexport type IntegrationSummary = client.ClientOutputs['listIntegrations']['integrations'][number]\n\nexport type Interface = client.Interface\n\nexport type BaseOperation = (...args: any[]) => Promise<any>\nexport type Operations = {\n [K in keyof client.Client as client.Client[K] extends BaseOperation ? K : never]: client.Client[K]\n}\nexport type Requests = {\n [K in keyof Operations]: Parameters<Operations[K]>[0]\n}\nexport type Responses = {\n [K in keyof Operations]: ReturnType<Operations[K]>\n}\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -26,11 +26,12 @@ var import_generators = require("./generators");
|
|
|
26
26
|
var import_actions_module = require("./integration-schemas/actions-module");
|
|
27
27
|
var import_channels_module = require("./integration-schemas/channels-module");
|
|
28
28
|
var import_configuration_module = require("./integration-schemas/configuration-module");
|
|
29
|
+
var import_entities_module = require("./integration-schemas/entities-module");
|
|
29
30
|
var import_events_module = require("./integration-schemas/events-module");
|
|
30
31
|
var import_states_module = require("./integration-schemas/states-module");
|
|
31
32
|
var import_module = require("./module");
|
|
32
33
|
class IntegrationImplementationIndexModule extends import_module.Module {
|
|
33
|
-
constructor(integration, configModule, actionsModule, channelsModule, eventsModule, statesModule, def) {
|
|
34
|
+
constructor(integration, configModule, actionsModule, channelsModule, eventsModule, statesModule, entitiesModule, def) {
|
|
34
35
|
super(def);
|
|
35
36
|
this.integration = integration;
|
|
36
37
|
this.configModule = configModule;
|
|
@@ -38,6 +39,7 @@ class IntegrationImplementationIndexModule extends import_module.Module {
|
|
|
38
39
|
this.channelsModule = channelsModule;
|
|
39
40
|
this.eventsModule = eventsModule;
|
|
40
41
|
this.statesModule = statesModule;
|
|
42
|
+
this.entitiesModule = entitiesModule;
|
|
41
43
|
}
|
|
42
44
|
static async create(integration) {
|
|
43
45
|
const configModule = await import_configuration_module.ConfigurationModule.create(integration.configuration ?? { schema: {} });
|
|
@@ -50,6 +52,8 @@ class IntegrationImplementationIndexModule extends import_module.Module {
|
|
|
50
52
|
eventsModule.unshift("events");
|
|
51
53
|
const statesModule = await import_states_module.StatesModule.create(integration.states ?? {});
|
|
52
54
|
statesModule.unshift("states");
|
|
55
|
+
const entitiesModule = await import_entities_module.EntitiesModule.create(integration.entities ?? {});
|
|
56
|
+
entitiesModule.unshift("entities");
|
|
53
57
|
const inst = new IntegrationImplementationIndexModule(
|
|
54
58
|
integration,
|
|
55
59
|
configModule,
|
|
@@ -57,6 +61,7 @@ class IntegrationImplementationIndexModule extends import_module.Module {
|
|
|
57
61
|
channelsModule,
|
|
58
62
|
eventsModule,
|
|
59
63
|
statesModule,
|
|
64
|
+
entitiesModule,
|
|
60
65
|
{
|
|
61
66
|
path: import_const.INDEX_FILE,
|
|
62
67
|
exportName: "Integration",
|
|
@@ -68,16 +73,18 @@ class IntegrationImplementationIndexModule extends import_module.Module {
|
|
|
68
73
|
inst.pushDep(channelsModule);
|
|
69
74
|
inst.pushDep(eventsModule);
|
|
70
75
|
inst.pushDep(statesModule);
|
|
76
|
+
inst.pushDep(entitiesModule);
|
|
71
77
|
return inst;
|
|
72
78
|
}
|
|
73
79
|
get content() {
|
|
74
80
|
let content = import_const.GENERATED_HEADER;
|
|
75
|
-
const { configModule, actionsModule, channelsModule, eventsModule, statesModule, integration } = this;
|
|
81
|
+
const { configModule, actionsModule, channelsModule, eventsModule, statesModule, entitiesModule, integration } = this;
|
|
76
82
|
const configImport = configModule.import(this);
|
|
77
83
|
const actionsImport = actionsModule.import(this);
|
|
78
84
|
const channelsImport = channelsModule.import(this);
|
|
79
85
|
const eventsImport = eventsModule.import(this);
|
|
80
86
|
const statesImport = statesModule.import(this);
|
|
87
|
+
const entitiesImport = entitiesModule.import(this);
|
|
81
88
|
content += [
|
|
82
89
|
import_const.GENERATED_HEADER,
|
|
83
90
|
'import * as sdk from "@botpress/sdk"',
|
|
@@ -87,15 +94,18 @@ class IntegrationImplementationIndexModule extends import_module.Module {
|
|
|
87
94
|
`import type * as ${channelsModule.name} from "./${channelsImport}"`,
|
|
88
95
|
`import type * as ${eventsModule.name} from "./${eventsImport}"`,
|
|
89
96
|
`import type * as ${statesModule.name} from "./${statesImport}"`,
|
|
97
|
+
`import type * as ${entitiesModule.name} from "./${entitiesImport}"`,
|
|
90
98
|
`export * as ${configModule.name} from "./${configImport}"`,
|
|
91
99
|
`export * as ${actionsModule.name} from "./${actionsImport}"`,
|
|
92
100
|
`export * as ${channelsModule.name} from "./${channelsImport}"`,
|
|
93
101
|
`export * as ${eventsModule.name} from "./${eventsImport}"`,
|
|
94
102
|
`export * as ${statesModule.name} from "./${statesImport}"`,
|
|
103
|
+
`export * as ${entitiesModule.name} from "./${entitiesImport}"`,
|
|
95
104
|
"",
|
|
96
105
|
"// type utils",
|
|
97
106
|
"type Cast<X, Y> = X extends Y ? X : Y",
|
|
98
107
|
"type ValueOf<T> = T[keyof T]",
|
|
108
|
+
"type AsyncFunction = (...args: any[]) => Promise<any>",
|
|
99
109
|
"type SimplifyObject<T extends object> = T extends infer O ? { [K in keyof O]: Simplify<O[K]> } : never",
|
|
100
110
|
"type Simplify<T> = T extends (...args: infer A) => infer R",
|
|
101
111
|
" ? (...args: Simplify<A>) => Simplify<R>",
|
|
@@ -116,6 +126,7 @@ class IntegrationImplementationIndexModule extends import_module.Module {
|
|
|
116
126
|
` events: ${eventsModule.name}.${eventsModule.exports}`,
|
|
117
127
|
` states: ${statesModule.name}.${statesModule.exports}`,
|
|
118
128
|
` user: ${(0, import_generators.stringifySingleLine)(integration.user)}`,
|
|
129
|
+
` entities: ${entitiesModule.name}.${entitiesModule.exports}`,
|
|
119
130
|
"}",
|
|
120
131
|
"",
|
|
121
132
|
"export type IntegrationProps = sdk.IntegrationProps<TIntegration>",
|
|
@@ -152,7 +163,9 @@ class IntegrationImplementationIndexModule extends import_module.Module {
|
|
|
152
163
|
"}",
|
|
153
164
|
"export type AnyAckFunction = ValueOf<ValueOf<AckFunctions>>",
|
|
154
165
|
"",
|
|
155
|
-
"export type ClientOperation = Simplify<
|
|
166
|
+
"export type ClientOperation = Simplify<ValueOf<{",
|
|
167
|
+
" [K in keyof Client as Client[K] extends AsyncFunction ? K : never]: K",
|
|
168
|
+
"}>>",
|
|
156
169
|
"export type ClientRequests = Simplify<{",
|
|
157
170
|
" [K in ClientOperation]: Parameters<Client[K]>[0]",
|
|
158
171
|
"}>",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/code-generation/integration-implementation.ts"],
|
|
4
|
-
"sourcesContent": ["import { GENERATED_HEADER, INDEX_FILE } from './const'\nimport { stringifySingleLine } from './generators'\nimport { ActionsModule } from './integration-schemas/actions-module'\nimport { ChannelsModule } from './integration-schemas/channels-module'\nimport { ConfigurationModule } from './integration-schemas/configuration-module'\nimport { EventsModule } from './integration-schemas/events-module'\nimport { StatesModule } from './integration-schemas/states-module'\nimport { Module, ModuleDef } from './module'\nimport * as types from './typings'\n\nexport class IntegrationImplementationIndexModule extends Module {\n public static async create(integration: types.IntegrationDefinition): Promise<IntegrationImplementationIndexModule> {\n const configModule = await ConfigurationModule.create(integration.configuration ?? { schema: {} })\n configModule.unshift('configuration')\n\n const actionsModule = await ActionsModule.create(integration.actions ?? {})\n actionsModule.unshift('actions')\n\n const channelsModule = await ChannelsModule.create(integration.channels ?? {})\n channelsModule.unshift('channels')\n\n const eventsModule = await EventsModule.create(integration.events ?? {})\n eventsModule.unshift('events')\n\n const statesModule = await StatesModule.create(integration.states ?? {})\n statesModule.unshift('states')\n\n const inst = new IntegrationImplementationIndexModule(\n integration,\n configModule,\n actionsModule,\n channelsModule,\n eventsModule,\n statesModule,\n {\n path: INDEX_FILE,\n exportName: 'Integration',\n content: '',\n }\n )\n\n inst.pushDep(configModule)\n inst.pushDep(actionsModule)\n inst.pushDep(channelsModule)\n inst.pushDep(eventsModule)\n inst.pushDep(statesModule)\n return inst\n }\n\n private constructor(\n private integration: types.IntegrationDefinition,\n private configModule: ConfigurationModule,\n private actionsModule: ActionsModule,\n private channelsModule: ChannelsModule,\n private eventsModule: EventsModule,\n private statesModule: StatesModule,\n def: ModuleDef\n ) {\n super(def)\n }\n\n public override get content(): string {\n let content = GENERATED_HEADER\n\n const { configModule, actionsModule, channelsModule, eventsModule, statesModule, integration }
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA6C;AAC7C,wBAAoC;AACpC,4BAA8B;AAC9B,6BAA+B;AAC/B,kCAAoC;AACpC,2BAA6B;AAC7B,2BAA6B;AAC7B,oBAAkC;AAG3B,MAAM,6CAA6C,qBAAO;AAAA,
|
|
4
|
+
"sourcesContent": ["import { GENERATED_HEADER, INDEX_FILE } from './const'\nimport { stringifySingleLine } from './generators'\nimport { ActionsModule } from './integration-schemas/actions-module'\nimport { ChannelsModule } from './integration-schemas/channels-module'\nimport { ConfigurationModule } from './integration-schemas/configuration-module'\nimport { EntitiesModule } from './integration-schemas/entities-module'\nimport { EventsModule } from './integration-schemas/events-module'\nimport { StatesModule } from './integration-schemas/states-module'\nimport { Module, ModuleDef } from './module'\nimport * as types from './typings'\n\nexport class IntegrationImplementationIndexModule extends Module {\n public static async create(integration: types.IntegrationDefinition): Promise<IntegrationImplementationIndexModule> {\n const configModule = await ConfigurationModule.create(integration.configuration ?? { schema: {} })\n configModule.unshift('configuration')\n\n const actionsModule = await ActionsModule.create(integration.actions ?? {})\n actionsModule.unshift('actions')\n\n const channelsModule = await ChannelsModule.create(integration.channels ?? {})\n channelsModule.unshift('channels')\n\n const eventsModule = await EventsModule.create(integration.events ?? {})\n eventsModule.unshift('events')\n\n const statesModule = await StatesModule.create(integration.states ?? {})\n statesModule.unshift('states')\n\n const entitiesModule = await EntitiesModule.create(integration.entities ?? {})\n entitiesModule.unshift('entities')\n\n const inst = new IntegrationImplementationIndexModule(\n integration,\n configModule,\n actionsModule,\n channelsModule,\n eventsModule,\n statesModule,\n entitiesModule,\n {\n path: INDEX_FILE,\n exportName: 'Integration',\n content: '',\n }\n )\n\n inst.pushDep(configModule)\n inst.pushDep(actionsModule)\n inst.pushDep(channelsModule)\n inst.pushDep(eventsModule)\n inst.pushDep(statesModule)\n inst.pushDep(entitiesModule)\n return inst\n }\n\n private constructor(\n private integration: types.IntegrationDefinition,\n private configModule: ConfigurationModule,\n private actionsModule: ActionsModule,\n private channelsModule: ChannelsModule,\n private eventsModule: EventsModule,\n private statesModule: StatesModule,\n private entitiesModule: EntitiesModule,\n def: ModuleDef\n ) {\n super(def)\n }\n\n public override get content(): string {\n let content = GENERATED_HEADER\n\n const { configModule, actionsModule, channelsModule, eventsModule, statesModule, entitiesModule, integration } =\n this\n\n const configImport = configModule.import(this)\n const actionsImport = actionsModule.import(this)\n const channelsImport = channelsModule.import(this)\n const eventsImport = eventsModule.import(this)\n const statesImport = statesModule.import(this)\n const entitiesImport = entitiesModule.import(this)\n\n content += [\n GENERATED_HEADER,\n 'import * as sdk from \"@botpress/sdk\"',\n '',\n `import type * as ${configModule.name} from \"./${configImport}\"`,\n `import type * as ${actionsModule.name} from \"./${actionsImport}\"`,\n `import type * as ${channelsModule.name} from \"./${channelsImport}\"`,\n `import type * as ${eventsModule.name} from \"./${eventsImport}\"`,\n `import type * as ${statesModule.name} from \"./${statesImport}\"`,\n `import type * as ${entitiesModule.name} from \"./${entitiesImport}\"`,\n `export * as ${configModule.name} from \"./${configImport}\"`,\n `export * as ${actionsModule.name} from \"./${actionsImport}\"`,\n `export * as ${channelsModule.name} from \"./${channelsImport}\"`,\n `export * as ${eventsModule.name} from \"./${eventsImport}\"`,\n `export * as ${statesModule.name} from \"./${statesImport}\"`,\n `export * as ${entitiesModule.name} from \"./${entitiesImport}\"`,\n '',\n '// type utils',\n 'type Cast<X, Y> = X extends Y ? X : Y',\n 'type ValueOf<T> = T[keyof T]',\n 'type AsyncFunction = (...args: any[]) => Promise<any>',\n 'type SimplifyObject<T extends object> = T extends infer O ? { [K in keyof O]: Simplify<O[K]> } : never',\n 'type Simplify<T> = T extends (...args: infer A) => infer R',\n ' ? (...args: Simplify<A>) => Simplify<R>',\n ' : T extends Buffer',\n ' ? Buffer',\n ' : T extends Promise<infer R>',\n ' ? Promise<Simplify<R>>',\n ' : T extends object',\n ' ? SimplifyObject<T>',\n ' : T',\n '',\n 'type TIntegration = {',\n ` name: \"${integration.name}\"`,\n ` version: \"${integration.version}\"`,\n ` configuration: ${configModule.name}.${configModule.exports}`,\n ` actions: ${actionsModule.name}.${actionsModule.exports}`,\n ` channels: ${channelsModule.name}.${channelsModule.exports}`,\n ` events: ${eventsModule.name}.${eventsModule.exports}`,\n ` states: ${statesModule.name}.${statesModule.exports}`,\n ` user: ${stringifySingleLine(integration.user)}`,\n ` entities: ${entitiesModule.name}.${entitiesModule.exports}`,\n '}',\n '',\n 'export type IntegrationProps = sdk.IntegrationProps<TIntegration>',\n '',\n 'export class Integration extends sdk.Integration<TIntegration> {}',\n '',\n 'export type Client = sdk.IntegrationSpecificClient<TIntegration>',\n '',\n '// extra types',\n '',\n \"export type HandlerProps = Simplify<Parameters<IntegrationProps['handler']>[0]>\",\n '',\n 'export type ActionProps = Simplify<{',\n \" [K in keyof IntegrationProps['actions']]: Parameters<IntegrationProps['actions'][K]>[0]\",\n '}>',\n 'export type AnyActionProps = ValueOf<ActionProps>',\n '',\n 'export type MessageProps = Simplify<{',\n \" [TChannel in keyof IntegrationProps['channels']]: {\",\n \" [TMessage in keyof IntegrationProps['channels'][TChannel]['messages']]: Parameters<\",\n \" IntegrationProps['channels'][TChannel]['messages'][TMessage]\",\n ' >[0]',\n ' }',\n '}>',\n 'export type AnyMessageProps = ValueOf<ValueOf<MessageProps>>',\n '',\n \"export type Context = HandlerProps['ctx']\",\n \"export type Logger = HandlerProps['logger']\",\n '',\n 'export type AckFunctions = {',\n ' [TChannel in keyof MessageProps]: {',\n \" [TMessage in keyof MessageProps[TChannel]]: Cast<MessageProps[TChannel][TMessage], AnyMessageProps>['ack']\",\n ' }',\n '}',\n 'export type AnyAckFunction = ValueOf<ValueOf<AckFunctions>>',\n '',\n 'export type ClientOperation = Simplify<ValueOf<{',\n ' [K in keyof Client as Client[K] extends AsyncFunction ? K : never]: K',\n '}>>',\n 'export type ClientRequests = Simplify<{',\n ' [K in ClientOperation]: Parameters<Client[K]>[0]',\n '}>',\n 'export type ClientResponses = Simplify<{',\n ' [K in ClientOperation]: Awaited<ReturnType<Client[K]>>',\n '}>',\n ].join('\\n')\n\n return content\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA6C;AAC7C,wBAAoC;AACpC,4BAA8B;AAC9B,6BAA+B;AAC/B,kCAAoC;AACpC,6BAA+B;AAC/B,2BAA6B;AAC7B,2BAA6B;AAC7B,oBAAkC;AAG3B,MAAM,6CAA6C,qBAAO;AAAA,EA4CvD,YACE,aACA,cACA,eACA,gBACA,cACA,cACA,gBACR,KACA;AACA,UAAM,GAAG;AATD;AACA;AACA;AACA;AACA;AACA;AACA;AAAA,EAIV;AAAA,EAtDA,aAAoB,OAAO,aAAyF;AAClH,UAAM,eAAe,MAAM,gDAAoB,OAAO,YAAY,iBAAiB,EAAE,QAAQ,CAAC,EAAE,CAAC;AACjG,iBAAa,QAAQ,eAAe;AAEpC,UAAM,gBAAgB,MAAM,oCAAc,OAAO,YAAY,WAAW,CAAC,CAAC;AAC1E,kBAAc,QAAQ,SAAS;AAE/B,UAAM,iBAAiB,MAAM,sCAAe,OAAO,YAAY,YAAY,CAAC,CAAC;AAC7E,mBAAe,QAAQ,UAAU;AAEjC,UAAM,eAAe,MAAM,kCAAa,OAAO,YAAY,UAAU,CAAC,CAAC;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 -27,11 +27,12 @@ var import_generators = require("./generators");
|
|
|
27
27
|
var import_actions_module = require("./integration-schemas/actions-module");
|
|
28
28
|
var import_channels_module = require("./integration-schemas/channels-module");
|
|
29
29
|
var import_configuration_module = require("./integration-schemas/configuration-module");
|
|
30
|
+
var import_entities_module = require("./integration-schemas/entities-module");
|
|
30
31
|
var import_events_module = require("./integration-schemas/events-module");
|
|
31
32
|
var import_states_module = require("./integration-schemas/states-module");
|
|
32
33
|
var import_module = require("./module");
|
|
33
34
|
class IntegrationInstanceIndexModule extends import_module.Module {
|
|
34
|
-
constructor(integration, configModule, actionsModule, channelsModule, eventsModule, statesModule, def) {
|
|
35
|
+
constructor(integration, configModule, actionsModule, channelsModule, eventsModule, statesModule, entitiesModule, def) {
|
|
35
36
|
super(def);
|
|
36
37
|
this.integration = integration;
|
|
37
38
|
this.configModule = configModule;
|
|
@@ -39,6 +40,7 @@ class IntegrationInstanceIndexModule extends import_module.Module {
|
|
|
39
40
|
this.channelsModule = channelsModule;
|
|
40
41
|
this.eventsModule = eventsModule;
|
|
41
42
|
this.statesModule = statesModule;
|
|
43
|
+
this.entitiesModule = entitiesModule;
|
|
42
44
|
}
|
|
43
45
|
static async create(integration) {
|
|
44
46
|
const { name } = integration;
|
|
@@ -52,6 +54,8 @@ class IntegrationInstanceIndexModule extends import_module.Module {
|
|
|
52
54
|
eventsModule.unshift("events");
|
|
53
55
|
const statesModule = await import_states_module.StatesModule.create(integration.states ?? {});
|
|
54
56
|
statesModule.unshift("states");
|
|
57
|
+
const entitiesModule = await import_entities_module.EntitiesModule.create(integration.entities ?? {});
|
|
58
|
+
entitiesModule.unshift("entities");
|
|
55
59
|
const exportName = import_utils.casing.to.pascalCase(name);
|
|
56
60
|
const inst = new IntegrationInstanceIndexModule(
|
|
57
61
|
integration,
|
|
@@ -60,6 +64,7 @@ class IntegrationInstanceIndexModule extends import_module.Module {
|
|
|
60
64
|
channelsModule,
|
|
61
65
|
eventsModule,
|
|
62
66
|
statesModule,
|
|
67
|
+
entitiesModule,
|
|
63
68
|
{
|
|
64
69
|
path: import_const.INDEX_FILE,
|
|
65
70
|
content: "",
|
|
@@ -71,15 +76,17 @@ class IntegrationInstanceIndexModule extends import_module.Module {
|
|
|
71
76
|
inst.pushDep(channelsModule);
|
|
72
77
|
inst.pushDep(eventsModule);
|
|
73
78
|
inst.pushDep(statesModule);
|
|
79
|
+
inst.pushDep(entitiesModule);
|
|
74
80
|
return inst;
|
|
75
81
|
}
|
|
76
82
|
get content() {
|
|
77
|
-
const { configModule, actionsModule, channelsModule, eventsModule, statesModule, integration } = this;
|
|
83
|
+
const { configModule, actionsModule, channelsModule, eventsModule, statesModule, entitiesModule, integration } = this;
|
|
78
84
|
const configImport = configModule.import(this);
|
|
79
85
|
const actionsImport = actionsModule.import(this);
|
|
80
86
|
const channelsImport = channelsModule.import(this);
|
|
81
87
|
const eventsImport = eventsModule.import(this);
|
|
82
88
|
const statesImport = statesModule.import(this);
|
|
89
|
+
const entitiesImport = entitiesModule.import(this);
|
|
83
90
|
const { name, version, id } = integration;
|
|
84
91
|
const className = import_utils.casing.to.pascalCase(name);
|
|
85
92
|
const propsName = `${className}Props`;
|
|
@@ -93,11 +100,13 @@ class IntegrationInstanceIndexModule extends import_module.Module {
|
|
|
93
100
|
`import type * as ${channelsModule.name} from "./${channelsImport}"`,
|
|
94
101
|
`import type * as ${eventsModule.name} from "./${eventsImport}"`,
|
|
95
102
|
`import type * as ${statesModule.name} from "./${statesImport}"`,
|
|
103
|
+
`import type * as ${entitiesModule.name} from "./${entitiesImport}"`,
|
|
96
104
|
`export * as ${configModule.name} from "./${configImport}"`,
|
|
97
105
|
`export * as ${actionsModule.name} from "./${actionsImport}"`,
|
|
98
106
|
`export * as ${channelsModule.name} from "./${channelsImport}"`,
|
|
99
107
|
`export * as ${eventsModule.name} from "./${eventsImport}"`,
|
|
100
108
|
`export * as ${statesModule.name} from "./${statesImport}"`,
|
|
109
|
+
`export * as ${entitiesModule.name} from "./${entitiesImport}"`,
|
|
101
110
|
"",
|
|
102
111
|
`export type ${propsName} = {`,
|
|
103
112
|
" enabled?: boolean",
|
|
@@ -113,9 +122,10 @@ class IntegrationInstanceIndexModule extends import_module.Module {
|
|
|
113
122
|
` events: ${eventsModule.name}.${eventsModule.exports}`,
|
|
114
123
|
` states: ${statesModule.name}.${statesModule.exports}`,
|
|
115
124
|
` user: ${(0, import_generators.stringifySingleLine)(this.integration.user)}`,
|
|
125
|
+
` entities: ${entitiesModule.name}.${entitiesModule.exports}`,
|
|
116
126
|
"}",
|
|
117
127
|
"",
|
|
118
|
-
`export class ${className} implements IntegrationInstance<
|
|
128
|
+
`export class ${className} implements IntegrationInstance<T${className}> {`,
|
|
119
129
|
"",
|
|
120
130
|
` public readonly name = '${name}'`,
|
|
121
131
|
` public readonly version = '${version}'`,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/code-generation/integration-instance.ts"],
|
|
4
|
-
"sourcesContent": ["import { casing } from '../utils'\nimport { GENERATED_HEADER, INDEX_FILE } from './const'\nimport { stringifySingleLine } from './generators'\nimport { ActionsModule } from './integration-schemas/actions-module'\nimport { ChannelsModule } from './integration-schemas/channels-module'\nimport { ConfigurationModule } from './integration-schemas/configuration-module'\nimport { EventsModule } from './integration-schemas/events-module'\nimport { StatesModule } from './integration-schemas/states-module'\nimport { Module, ModuleDef } from './module'\nimport * as types from './typings'\n\nexport class IntegrationInstanceIndexModule extends Module {\n public static async create(integration: types.IntegrationDefinition): Promise<IntegrationInstanceIndexModule> {\n const { name } = integration\n\n const configModule = await ConfigurationModule.create(integration.configuration ?? { schema: {} })\n configModule.unshift('configuration')\n\n const actionsModule = await ActionsModule.create(integration.actions ?? {})\n actionsModule.unshift('actions')\n\n const channelsModule = await ChannelsModule.create(integration.channels ?? {})\n channelsModule.unshift('channels')\n\n const eventsModule = await EventsModule.create(integration.events ?? {})\n eventsModule.unshift('events')\n\n const statesModule = await StatesModule.create(integration.states ?? {})\n statesModule.unshift('states')\n\n const exportName = casing.to.pascalCase(name)\n\n const inst = new IntegrationInstanceIndexModule(\n integration,\n configModule,\n actionsModule,\n channelsModule,\n eventsModule,\n statesModule,\n {\n path: INDEX_FILE,\n content: '',\n exportName,\n }\n )\n\n inst.pushDep(configModule)\n inst.pushDep(actionsModule)\n inst.pushDep(channelsModule)\n inst.pushDep(eventsModule)\n inst.pushDep(statesModule)\n\n return inst\n }\n\n private constructor(\n private integration: types.IntegrationDefinition,\n private configModule: ConfigurationModule,\n private actionsModule: ActionsModule,\n private channelsModule: ChannelsModule,\n private eventsModule: EventsModule,\n private statesModule: StatesModule,\n def: ModuleDef\n ) {\n super(def)\n }\n\n public override get content(): string {\n const { configModule, actionsModule, channelsModule, eventsModule, statesModule, integration }
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAuB;AACvB,mBAA6C;AAC7C,wBAAoC;AACpC,4BAA8B;AAC9B,6BAA+B;AAC/B,kCAAoC;AACpC,2BAA6B;AAC7B,2BAA6B;AAC7B,oBAAkC;AAG3B,MAAM,uCAAuC,qBAAO;AAAA,
|
|
4
|
+
"sourcesContent": ["import { casing } from '../utils'\nimport { GENERATED_HEADER, INDEX_FILE } from './const'\nimport { stringifySingleLine } from './generators'\nimport { ActionsModule } from './integration-schemas/actions-module'\nimport { ChannelsModule } from './integration-schemas/channels-module'\nimport { ConfigurationModule } from './integration-schemas/configuration-module'\nimport { EntitiesModule } from './integration-schemas/entities-module'\nimport { EventsModule } from './integration-schemas/events-module'\nimport { StatesModule } from './integration-schemas/states-module'\nimport { Module, ModuleDef } from './module'\nimport * as types from './typings'\n\nexport class IntegrationInstanceIndexModule extends Module {\n public static async create(integration: types.IntegrationDefinition): Promise<IntegrationInstanceIndexModule> {\n const { name } = integration\n\n const configModule = await ConfigurationModule.create(integration.configuration ?? { schema: {} })\n configModule.unshift('configuration')\n\n const actionsModule = await ActionsModule.create(integration.actions ?? {})\n actionsModule.unshift('actions')\n\n const channelsModule = await ChannelsModule.create(integration.channels ?? {})\n channelsModule.unshift('channels')\n\n const eventsModule = await EventsModule.create(integration.events ?? {})\n eventsModule.unshift('events')\n\n const statesModule = await StatesModule.create(integration.states ?? {})\n statesModule.unshift('states')\n\n const entitiesModule = await EntitiesModule.create(integration.entities ?? {})\n entitiesModule.unshift('entities')\n\n const exportName = casing.to.pascalCase(name)\n\n const inst = new IntegrationInstanceIndexModule(\n integration,\n configModule,\n actionsModule,\n channelsModule,\n eventsModule,\n statesModule,\n entitiesModule,\n {\n path: INDEX_FILE,\n content: '',\n exportName,\n }\n )\n\n inst.pushDep(configModule)\n inst.pushDep(actionsModule)\n inst.pushDep(channelsModule)\n inst.pushDep(eventsModule)\n inst.pushDep(statesModule)\n inst.pushDep(entitiesModule)\n\n return inst\n }\n\n private constructor(\n private integration: types.IntegrationDefinition,\n private configModule: ConfigurationModule,\n private actionsModule: ActionsModule,\n private channelsModule: ChannelsModule,\n private eventsModule: EventsModule,\n private statesModule: StatesModule,\n private entitiesModule: EntitiesModule,\n def: ModuleDef\n ) {\n super(def)\n }\n\n public override get content(): string {\n const { configModule, actionsModule, channelsModule, eventsModule, statesModule, entitiesModule, integration } =\n this\n\n const configImport = configModule.import(this)\n const actionsImport = actionsModule.import(this)\n const channelsImport = channelsModule.import(this)\n const eventsImport = eventsModule.import(this)\n const statesImport = statesModule.import(this)\n const entitiesImport = entitiesModule.import(this)\n\n const { name, version, id } = integration\n const className = casing.to.pascalCase(name)\n const propsName = `${className}Props`\n\n const integrationId = id === null ? 'null' : `'${id}'`\n\n const lines = [\n GENERATED_HEADER,\n \"import type { IntegrationInstance } from '@botpress/sdk'\",\n '',\n `import type * as ${configModule.name} from \"./${configImport}\"`,\n `import type * as ${actionsModule.name} from \"./${actionsImport}\"`,\n `import type * as ${channelsModule.name} from \"./${channelsImport}\"`,\n `import type * as ${eventsModule.name} from \"./${eventsImport}\"`,\n `import type * as ${statesModule.name} from \"./${statesImport}\"`,\n `import type * as ${entitiesModule.name} from \"./${entitiesImport}\"`,\n `export * as ${configModule.name} from \"./${configImport}\"`,\n `export * as ${actionsModule.name} from \"./${actionsImport}\"`,\n `export * as ${channelsModule.name} from \"./${channelsImport}\"`,\n `export * as ${eventsModule.name} from \"./${eventsImport}\"`,\n `export * as ${statesModule.name} from \"./${statesImport}\"`,\n `export * as ${entitiesModule.name} from \"./${entitiesImport}\"`,\n '',\n `export type ${propsName} = {`,\n ' enabled?: boolean',\n ` config?: ${configModule.name}.${configModule.exports}`,\n '}',\n '',\n `export type T${className} = {`,\n ` name: '${name}'`,\n ` version: '${version}'`,\n ` configuration: ${configModule.name}.${configModule.exports}`,\n ` actions: ${actionsModule.name}.${actionsModule.exports}`,\n ` channels: ${channelsModule.name}.${channelsModule.exports}`,\n ` events: ${eventsModule.name}.${eventsModule.exports}`,\n ` states: ${statesModule.name}.${statesModule.exports}`,\n ` user: ${stringifySingleLine(this.integration.user)}`,\n ` entities: ${entitiesModule.name}.${entitiesModule.exports}`,\n '}',\n '',\n `export class ${className} implements IntegrationInstance<T${className}> {`,\n '',\n ` public readonly name = '${name}'`,\n ` public readonly version = '${version}'`,\n ` public readonly id = ${integrationId}`,\n '',\n ' public readonly enabled?: boolean',\n ` public readonly configuration?: ${configModule.name}.${configModule.exports}`,\n '',\n ` constructor(props?: ${propsName}) {`,\n ' this.enabled = props?.enabled',\n ' this.configuration = props?.config',\n ' }',\n '}',\n ]\n\n return `${GENERATED_HEADER}\\n${lines.join('\\n')}`\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAuB;AACvB,mBAA6C;AAC7C,wBAAoC;AACpC,4BAA8B;AAC9B,6BAA+B;AAC/B,kCAAoC;AACpC,6BAA+B;AAC/B,2BAA6B;AAC7B,2BAA6B;AAC7B,oBAAkC;AAG3B,MAAM,uCAAuC,qBAAO;A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AAW,uCAAoB,KAAK,YAAY,IAAI;AAAA,MACpD,eAAe,eAAe,QAAQ,eAAe;AAAA,MACrD;AAAA,MACA;AAAA,MACA,gBAAgB,6CAA6C;AAAA,MAC7D;AAAA,MACA,6BAA6B;AAAA,MAC7B,gCAAgC;AAAA,MAChC,0BAA0B;AAAA,MAC1B;AAAA,MACA;AAAA,MACA,qCAAqC,aAAa,QAAQ,aAAa;AAAA,MACvE;AAAA,MACA,yBAAyB;AAAA,MACzB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAEA,WAAO,GAAG;AAAA,EAAqB,MAAM,KAAK,IAAI;AAAA,EAChD;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -64,8 +64,9 @@ class ActionModule extends import_module.ReExportTypeModule {
|
|
|
64
64
|
static async create(actionName, action) {
|
|
65
65
|
const inputModule = await ActionInputModule.create(action.input);
|
|
66
66
|
const outputModule = await ActionOutputModule.create(action.output);
|
|
67
|
+
const exportName = strings.typeName(actionName);
|
|
67
68
|
const inst = new ActionModule({
|
|
68
|
-
exportName
|
|
69
|
+
exportName
|
|
69
70
|
});
|
|
70
71
|
inst.pushDep(inputModule);
|
|
71
72
|
inst.pushDep(outputModule);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/code-generation/integration-schemas/actions-module.ts"],
|
|
4
|
-
"sourcesContent": ["import bluebird from 'bluebird'\nimport { jsonSchemaToTypeScriptType } from '../generators'\nimport { Module, ModuleDef, ReExportTypeModule } from '../module'\nimport * as strings from '../strings'\nimport type * as types from '../typings'\n\ntype ActionInput = types.ActionDefinition['input']\ntype ActionOutput = types.ActionDefinition['output']\n\nexport class ActionInputModule extends Module {\n public static async create(input: ActionInput): Promise<ActionInputModule> {\n const schema = input.schema\n const name = 'input'\n const exportName = strings.typeName(name)\n const def: ModuleDef = {\n path: `${name}.ts`,\n exportName,\n content: await jsonSchemaToTypeScriptType(schema, exportName),\n }\n return new ActionInputModule(def)\n }\n}\n\nexport class ActionOutputModule extends Module {\n public static async create(output: ActionOutput): Promise<ActionOutputModule> {\n const schema = output.schema\n const name = 'output'\n const exportName = strings.typeName(name)\n const def: ModuleDef = {\n path: `${name}.ts`,\n exportName,\n content: await jsonSchemaToTypeScriptType(schema, exportName),\n }\n return new ActionOutputModule(def)\n }\n}\n\nexport class ActionModule extends ReExportTypeModule {\n public static async create(actionName: string, action: types.ActionDefinition): Promise<ActionModule> {\n const inputModule = await ActionInputModule.create(action.input)\n const outputModule = await ActionOutputModule.create(action.output)\n\n const inst = new ActionModule({\n exportName
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAqB;AACrB,wBAA2C;AAC3C,oBAAsD;AACtD,cAAyB;AAMlB,MAAM,0BAA0B,qBAAO;AAAA,EAC5C,aAAoB,OAAO,OAAgD;AACzE,UAAM,SAAS,MAAM;AACrB,UAAM,OAAO;AACb,UAAM,aAAa,QAAQ,SAAS,IAAI;AACxC,UAAM,MAAiB;AAAA,MACrB,MAAM,GAAG;AAAA,MACT;AAAA,MACA,SAAS,UAAM,8CAA2B,QAAQ,UAAU;AAAA,IAC9D;AACA,WAAO,IAAI,kBAAkB,GAAG;AAAA,EAClC;AACF;AAEO,MAAM,2BAA2B,qBAAO;AAAA,EAC7C,aAAoB,OAAO,QAAmD;AAC5E,UAAM,SAAS,OAAO;AACtB,UAAM,OAAO;AACb,UAAM,aAAa,QAAQ,SAAS,IAAI;AACxC,UAAM,MAAiB;AAAA,MACrB,MAAM,GAAG;AAAA,MACT;AAAA,MACA,SAAS,UAAM,8CAA2B,QAAQ,UAAU;AAAA,IAC9D;AACA,WAAO,IAAI,mBAAmB,GAAG;AAAA,EACnC;AACF;AAEO,MAAM,qBAAqB,iCAAmB;AAAA,EACnD,aAAoB,OAAO,YAAoB,QAAuD;AACpG,UAAM,cAAc,MAAM,kBAAkB,OAAO,OAAO,KAAK;AAC/D,UAAM,eAAe,MAAM,mBAAmB,OAAO,OAAO,MAAM;AAElE,UAAM,OAAO,IAAI,aAAa;AAAA,MAC5B
|
|
4
|
+
"sourcesContent": ["import bluebird from 'bluebird'\nimport { jsonSchemaToTypeScriptType } from '../generators'\nimport { Module, ModuleDef, ReExportTypeModule } from '../module'\nimport * as strings from '../strings'\nimport type * as types from '../typings'\n\ntype ActionInput = types.ActionDefinition['input']\ntype ActionOutput = types.ActionDefinition['output']\n\nexport class ActionInputModule extends Module {\n public static async create(input: ActionInput): Promise<ActionInputModule> {\n const schema = input.schema\n const name = 'input'\n const exportName = strings.typeName(name)\n const def: ModuleDef = {\n path: `${name}.ts`,\n exportName,\n content: await jsonSchemaToTypeScriptType(schema, exportName),\n }\n return new ActionInputModule(def)\n }\n}\n\nexport class ActionOutputModule extends Module {\n public static async create(output: ActionOutput): Promise<ActionOutputModule> {\n const schema = output.schema\n const name = 'output'\n const exportName = strings.typeName(name)\n const def: ModuleDef = {\n path: `${name}.ts`,\n exportName,\n content: await jsonSchemaToTypeScriptType(schema, exportName),\n }\n return new ActionOutputModule(def)\n }\n}\n\nexport class ActionModule extends ReExportTypeModule {\n public static async create(actionName: string, action: types.ActionDefinition): Promise<ActionModule> {\n const inputModule = await ActionInputModule.create(action.input)\n const outputModule = await ActionOutputModule.create(action.output)\n\n const exportName = strings.typeName(actionName)\n const inst = new ActionModule({\n exportName,\n })\n\n inst.pushDep(inputModule)\n inst.pushDep(outputModule)\n\n return inst\n }\n}\n\nexport class ActionsModule extends ReExportTypeModule {\n public static async create(actions: Record<string, types.ActionDefinition>): Promise<ActionsModule> {\n const actionModules = await bluebird.map(Object.entries(actions), async ([actionName, action]) => {\n const mod = await ActionModule.create(actionName, action)\n return mod.unshift(actionName)\n })\n\n const inst = new ActionsModule({\n exportName: strings.typeName('actions'),\n })\n\n inst.pushDep(...actionModules)\n return inst\n }\n}\n"],
|
|
5
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