@hiliosai/sdk 0.1.28 → 0.1.30
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/dist/index.d.ts +2 -2
- package/dist/index.js +15 -9
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -687,13 +687,13 @@ type ServiceConfig<TSettings = unknown, TDatasourceConstructors extends Datasour
|
|
|
687
687
|
};
|
|
688
688
|
interface IntegrationServiceConfig<TSettings = unknown, TDatasourceConstructors extends DatasourceConstructorRegistry = DatasourceConstructorRegistry, TContext extends AppContext<DatasourceInstanceTypes<TDatasourceConstructors>> = AppContext<DatasourceInstanceTypes<TDatasourceConstructors>>> extends ServiceConfig<TSettings, TDatasourceConstructors> {
|
|
689
689
|
name: string;
|
|
690
|
-
version: string;
|
|
690
|
+
version: string | number;
|
|
691
691
|
spec: BaseSpec;
|
|
692
692
|
normalize<TPayload = any>(webhook: WebhookEvent<TPayload>): Promise<Message[]>;
|
|
693
693
|
getChannelConfig(ctx: TContext, channelId: string): Promise<IntegrationConfig | null>;
|
|
694
694
|
validateWebhook?<TPayload = any>(webhook: WebhookEvent<TPayload>): boolean;
|
|
695
695
|
sendMessage(ctx: TContext, message: Message, config: IntegrationConfig): Promise<SendResult>;
|
|
696
|
-
createChannel
|
|
696
|
+
createChannel(ctx: TContext, integration: IntegrationConfig): Promise<boolean>;
|
|
697
697
|
verifyWebhook?(params: {
|
|
698
698
|
mode: string;
|
|
699
699
|
token: string;
|
package/dist/index.js
CHANGED
|
@@ -1088,17 +1088,23 @@ function defineIntegration(config) {
|
|
|
1088
1088
|
channels: {
|
|
1089
1089
|
[`${CHANNELS.INTEGRATION.REGISTERED}.${config.spec.id}`]: {
|
|
1090
1090
|
context: true,
|
|
1091
|
-
handler(ctx, payload) {
|
|
1092
|
-
const
|
|
1093
|
-
|
|
1094
|
-
|
|
1091
|
+
async handler(ctx, payload) {
|
|
1092
|
+
const integrationRaw = payload.json();
|
|
1093
|
+
const integration = {
|
|
1094
|
+
id: integrationRaw.integrationId,
|
|
1095
|
+
tenantId: integrationRaw.tenantId,
|
|
1096
|
+
name: config.name,
|
|
1097
|
+
version: `${config.version}`,
|
|
1098
|
+
config: integrationRaw.config,
|
|
1099
|
+
credentials: integrationRaw.credentials
|
|
1100
|
+
};
|
|
1101
|
+
const createChannelAction = `v${this.version}.${this.name}.i_createChannel`;
|
|
1102
|
+
await ctx.broker.call(createChannelAction, { integration }).then(() => payload.ackAck()).then(
|
|
1103
|
+
() => ctx.broker.logger.debug("Integration registered", {
|
|
1095
1104
|
name: this.name,
|
|
1096
1105
|
version: this.version
|
|
1097
|
-
})
|
|
1098
|
-
|
|
1099
|
-
ctx.broker.call(`v${this.version}.${this.name}.i_createChannel`, {
|
|
1100
|
-
integration
|
|
1101
|
-
});
|
|
1106
|
+
})
|
|
1107
|
+
);
|
|
1102
1108
|
}
|
|
1103
1109
|
}
|
|
1104
1110
|
}
|