@hiliosai/sdk 0.1.27 → 0.1.29

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 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<TChannel>(ctx: TContext, integration: TChannel): Promise<boolean>;
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,24 @@ function defineIntegration(config) {
1088
1088
  channels: {
1089
1089
  [`${CHANNELS.INTEGRATION.REGISTERED}.${config.spec.id}`]: {
1090
1090
  context: true,
1091
- handler(ctx, payload) {
1092
- const integration = payload.json();
1093
- payload.ackAck().then(() => {
1094
- ctx.broker.logger.debug("Integration registered", {
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 });
1103
+ payload.ackAck().then(
1104
+ () => ctx.broker.logger.debug("Integration registered", {
1095
1105
  name: this.name,
1096
1106
  version: this.version
1097
- });
1098
- });
1099
- ctx.broker.call(`v${this.version}.${this.name}.i_createChannel`, {
1100
- integration
1101
- });
1107
+ })
1108
+ );
1102
1109
  }
1103
1110
  }
1104
1111
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hiliosai/sdk",
3
- "version": "0.1.27",
3
+ "version": "0.1.29",
4
4
  "type": "module",
5
5
  "license": "UNLICENSED",
6
6
  "main": "./dist/index.js",