@hiliosai/sdk 0.1.2 → 0.1.3

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.
@@ -139,9 +139,9 @@ Integration-specific logic is implemented as service methods:
139
139
 
140
140
  ```typescript
141
141
  import {defineIntegration} from '@pkg/sdk';
142
- import type {BaseIntegration, NormalizedMessage, WebhookEvent} from '@pkg/sdk';
142
+ import type {BaseSpec, NormalizedMessage, WebhookEvent} from '@pkg/sdk';
143
143
 
144
- const whatsappIntegration: BaseIntegration = {
144
+ const whatsappIntegration: BaseSpec = {
145
145
  id: 'whatsapp-business',
146
146
  name: 'WhatsApp Business',
147
147
  platform: 'whatsapp',
@@ -152,7 +152,7 @@ const whatsappIntegration: BaseIntegration = {
152
152
 
153
153
  export default defineIntegration({
154
154
  name: 'whatsapp',
155
- integration: whatsappIntegration,
155
+ spec: whatsappIntegration,
156
156
 
157
157
  // Required: Convert WhatsApp webhook to normalized message
158
158
  async normalize(webhook: WebhookEvent): Promise<NormalizedMessage[]> {
@@ -296,7 +296,7 @@ import {WhatsAppDatasource} from './datasources';
296
296
 
297
297
  export default defineIntegration({
298
298
  name: 'whatsapp',
299
- integration: whatsappIntegration,
299
+ spec: whatsappIntegration,
300
300
 
301
301
  // Configure per-service datasources
302
302
  datasources: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hiliosai/sdk",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./src/index.ts"
@@ -91,7 +91,7 @@ export function defineIntegration<
91
91
  i_receiveWebhook: {
92
92
  rest: {
93
93
  method: 'POST' as const,
94
- path: '/webhook',
94
+ path: '/:tenantId',
95
95
  },
96
96
  params: {
97
97
  tenantId: 'string',
@@ -181,20 +181,20 @@ export function defineIntegration<
181
181
  () => config.sendMessage(ctx, message, integrationConfig),
182
182
  3,
183
183
  1000,
184
- `Send message via ${config.integration.platform}`
184
+ `Send message via ${config.spec.platform}`
185
185
  );
186
186
 
187
187
  // Emit event based on result
188
188
  if (result.success) {
189
189
  ctx.emit('integration.message.sent', {
190
190
  messageId: result.messageId,
191
- platform: config.integration.platform,
191
+ platform: config.spec.platform,
192
192
  metadata: result.metadata,
193
193
  });
194
194
  } else {
195
195
  ctx.emit('integration.message.failed', {
196
196
  error: result.error,
197
- platform: config.integration.platform,
197
+ platform: config.spec.platform,
198
198
  message,
199
199
  });
200
200
  }
@@ -224,12 +224,12 @@ export function defineIntegration<
224
224
 
225
225
  return {
226
226
  status: 'healthy',
227
- message: `${config.integration.name} integration is running`,
227
+ message: `${config.spec.name} integration is running`,
228
228
  details: {
229
- integration: config.integration.id,
230
- version: config.integration.version,
229
+ id: config.spec.id,
230
+ version: config.spec.version,
231
231
  timestamp: new Date().toISOString(),
232
- capabilities: config.integration.capabilities,
232
+ capabilities: config.spec.capabilities,
233
233
  },
234
234
  };
235
235
  } catch (error: unknown) {
@@ -238,7 +238,7 @@ export function defineIntegration<
238
238
  status: 'unhealthy',
239
239
  message: err.message,
240
240
  details: {
241
- integration: config.integration.id,
241
+ id: config.spec.id,
242
242
  timestamp: new Date().toISOString(),
243
243
  },
244
244
  };
@@ -249,9 +249,10 @@ export function defineIntegration<
249
249
  i_verifyWebhook: {
250
250
  rest: {
251
251
  method: 'GET' as const,
252
- path: '/webhook',
252
+ path: '/:tenantId',
253
253
  },
254
254
  params: {
255
+ tenantId: 'string',
255
256
  mode: 'string',
256
257
  token: 'string',
257
258
  challenge: 'string',
@@ -259,7 +260,7 @@ export function defineIntegration<
259
260
  handler(
260
261
  ctx: AppContext<
261
262
  TDatasources,
262
- {mode: string; token: string; challenge: string}
263
+ {tenantId: string; mode: string; token: string; challenge: string}
263
264
  >
264
265
  ): string {
265
266
  if (config.verifyWebhook) {
@@ -277,12 +278,12 @@ export function defineIntegration<
277
278
  },
278
279
  handler(): object {
279
280
  return {
280
- id: config.integration.id,
281
- name: config.integration.name,
282
- platform: config.integration.platform,
283
- version: config.integration.version,
284
- status: config.integration.status,
285
- capabilities: config.integration.capabilities,
281
+ id: config.spec.id,
282
+ name: config.spec.name,
283
+ platform: config.spec.platform,
284
+ version: config.spec.version,
285
+ status: config.spec.status,
286
+ capabilities: config.spec.capabilities,
286
287
  };
287
288
  },
288
289
  },
@@ -316,7 +317,7 @@ export function defineIntegration<
316
317
  datasources: config.datasources,
317
318
  metadata: {
318
319
  ...config.metadata,
319
- integration: config.integration,
320
+ spec: config.spec,
320
321
  },
321
322
  actions,
322
323
  events: config.events ?? {},
@@ -347,7 +348,7 @@ export function defineIntegration<
347
348
  // Return the service schema - integration methods are available via service methods
348
349
  return {
349
350
  ...baseService,
350
- // Only add the integration metadata
351
- integration: config.integration,
351
+ // Only add the integration spec
352
+ spec: config.spec,
352
353
  } as IntegrationServiceSchema<TPlatformMessage, TSettings>;
353
354
  }
@@ -5,7 +5,7 @@ import type {
5
5
  IntegrationStatus,
6
6
  } from './platform';
7
7
 
8
- export interface BaseIntegration {
8
+ export interface BaseSpec {
9
9
  id: string;
10
10
  name: string;
11
11
  platform: IntegrationPlatform;
@@ -9,7 +9,7 @@ import type {
9
9
 
10
10
  import type {DatasourceConstructorRegistry} from '../middlewares/datasource.middleware';
11
11
  import type {AppContext} from './context';
12
- import type {BaseIntegration, IntegrationConfig} from './integration';
12
+ import type {BaseSpec, IntegrationConfig} from './integration';
13
13
  import type {
14
14
  NormalizedMessage,
15
15
  PlatformMessage,
@@ -134,7 +134,7 @@ export interface IntegrationServiceConfig<
134
134
  TDatasources = unknown
135
135
  > extends ServiceConfig<TSettings, TDatasources> {
136
136
  name: string;
137
- integration: BaseIntegration;
137
+ spec: BaseSpec;
138
138
 
139
139
  // Core integration methods
140
140
  normalize(webhook: WebhookEvent): Promise<NormalizedMessage[]>;
@@ -177,7 +177,7 @@ export interface IntegrationServiceSchema<
177
177
  TPlatformMessage extends PlatformMessage = PlatformMessage,
178
178
  TSettings = unknown
179
179
  > extends MoleculerServiceSchema<TSettings> {
180
- integration: BaseIntegration;
180
+ spec: BaseSpec;
181
181
  normalize(webhook: WebhookEvent): Promise<NormalizedMessage[]>;
182
182
  transform?(
183
183
  message: NormalizedMessage,