@hiliosai/sdk 0.1.10 → 0.1.11

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/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@hiliosai/sdk",
3
- "version": "0.1.10",
3
+ "version": "0.1.11",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./src/index.ts"
7
7
  },
8
8
  "scripts": {
9
9
  "build": "tsup",
10
- "format": "bunx prettier --write ./**/*.{ts,json,md,yaml}",
10
+ "format": "bunx prettier --write ./**/*.{ts,json}",
11
11
  "typecheck": "tsc --noEmit"
12
12
  },
13
13
  "dependencies": {
@@ -9,11 +9,7 @@ import {
9
9
  } from '../types/channels';
10
10
  import type {AppContext} from '../types/context';
11
11
  import type {IntegrationConfig} from '../types/integration';
12
- import type {
13
- NormalizedMessage,
14
- SendResult,
15
- WebhookEvent,
16
- } from '../types/message';
12
+ import type {Message, SendResult, WebhookEvent} from '../types/message';
17
13
  import type {DatasourceInstanceTypes} from '../types/datasource';
18
14
  import type {
19
15
  IntegrationServiceConfig,
@@ -204,7 +200,7 @@ export function defineIntegration<
204
200
  ctx: AppContext<
205
201
  TDatasources,
206
202
  {
207
- message: NormalizedMessage;
203
+ message: Message;
208
204
  channelId: string;
209
205
  }
210
206
  >
@@ -1,5 +1,5 @@
1
1
  import type {IntegrationPlatform} from './platform';
2
- import type {NormalizedMessage} from './message';
2
+ import type {Message} from './message';
3
3
 
4
4
  /**
5
5
  * Channel event payload types for reliable messaging via @moleculer/channels
@@ -10,7 +10,7 @@ export interface IntegrationMessageReceivedPayload {
10
10
  tenantId: string;
11
11
  channelId: string;
12
12
  platform: IntegrationPlatform;
13
- message: NormalizedMessage;
13
+ message: Message;
14
14
  timestamp: number;
15
15
  metadata?: Record<string, unknown>;
16
16
  }
@@ -29,7 +29,7 @@ export interface IntegrationMessageFailedPayload {
29
29
  channelId: string;
30
30
  platform: IntegrationPlatform;
31
31
  error: string; // Serialized error message
32
- message?: NormalizedMessage;
32
+ message?: Message;
33
33
  timestamp: number;
34
34
  retryCount?: number;
35
35
  metadata?: Record<string, unknown>;
@@ -59,22 +59,56 @@ export interface CarouselItem {
59
59
  buttons?: MessageButton[];
60
60
  }
61
61
 
62
- export interface NormalizedMessage {
62
+ export type MessageDirection = 'incoming' | 'outgoing' | 'internal';
63
+
64
+ export type MessageType =
65
+ | 'text'
66
+ | 'image'
67
+ | 'file'
68
+ | 'audio'
69
+ | 'video'
70
+ | 'location'
71
+ | 'contact'
72
+ | 'sticker'
73
+ | 'template';
74
+
75
+ export type MessageStatus =
76
+ | 'pending'
77
+ | 'sent'
78
+ | 'delivered'
79
+ | 'read'
80
+ | 'failed';
81
+
82
+ export interface Message {
63
83
  id: string;
64
84
  conversationId: string;
65
85
  from: MessageParticipant;
66
86
  to: MessageParticipant;
67
87
  content: MessageContent;
88
+ direction: MessageDirection;
89
+ type: MessageType;
90
+ status: MessageStatus;
68
91
  timestamp: number;
69
92
  platform: IntegrationPlatform;
70
93
  replyTo?: string;
71
94
  threadId?: string;
95
+ attachments?: MessageAttachment[];
96
+ metadata?: Record<string, any>;
97
+ }
98
+
99
+ export interface MessageAttachment {
100
+ id: string;
101
+ name: string;
102
+ type: string;
103
+ size: number;
104
+ url: string;
105
+ thumbnail?: string;
72
106
  metadata?: Record<string, any>;
73
107
  }
74
108
 
75
- export interface PlatformMessage {
109
+ export interface PlatformMessage<P = any> {
76
110
  platform: IntegrationPlatform;
77
- payload: any;
111
+ payload: P;
78
112
  }
79
113
 
80
114
  export interface WebhookEvent<TPayload = any> {
@@ -11,8 +11,7 @@ import type {DatasourceConstructorRegistry} from '../middlewares/datasource.midd
11
11
  import type {AppContext} from './context';
12
12
  import type {DatasourceInstanceTypes} from './datasource';
13
13
  import type {BaseSpec, IntegrationConfig} from './integration';
14
- import type {NormalizedMessage, SendResult, WebhookEvent} from './message';
15
-
14
+ import type {Message, SendResult, WebhookEvent} from './message';
16
15
 
17
16
  // Type to infer TypeScript types from Moleculer parameter schemas
18
17
  type InferParamsType<T> = T extends Record<string, any>
@@ -123,7 +122,7 @@ export type ServiceConfig<
123
122
  TSettings,
124
123
  DatasourceInstanceTypes<TDatasourceConstructors>
125
124
  > & {
126
- datasources?: TDatasourceConstructors;
125
+ datasources: TDatasourceConstructors;
127
126
  };
128
127
 
129
128
  // Integration-specific types
@@ -140,7 +139,7 @@ export interface IntegrationServiceConfig<
140
139
  // Core integration methods
141
140
  normalize<TPayload = any>(
142
141
  webhook: WebhookEvent<TPayload>
143
- ): Promise<NormalizedMessage[]>;
142
+ ): Promise<Message[]>;
144
143
  getChannelConfig(
145
144
  ctx: TContext,
146
145
  channelId: string
@@ -148,7 +147,7 @@ export interface IntegrationServiceConfig<
148
147
  validateWebhook?<TPayload = any>(webhook: WebhookEvent<TPayload>): boolean;
149
148
  sendMessage(
150
149
  ctx: TContext,
151
- message: NormalizedMessage,
150
+ message: Message,
152
151
  config: IntegrationConfig
153
152
  ): Promise<SendResult>;
154
153
 
@@ -181,7 +180,7 @@ export interface IntegrationServiceSchema<TSettings = unknown>
181
180
  spec: BaseSpec;
182
181
  normalize<TPayload = any>(
183
182
  webhook: WebhookEvent<TPayload>
184
- ): Promise<NormalizedMessage[]>;
183
+ ): Promise<Message[]>;
185
184
  getChannelConfig(
186
185
  ctx: AppContext,
187
186
  channelId: string
@@ -189,7 +188,7 @@ export interface IntegrationServiceSchema<TSettings = unknown>
189
188
  validateWebhook?<TPayload = any>(webhook: WebhookEvent<TPayload>): boolean;
190
189
  sendMessage(
191
190
  ctx: AppContext,
192
- message: NormalizedMessage,
191
+ message: Message,
193
192
  config: IntegrationConfig
194
193
  ): Promise<SendResult>;
195
194
  verifyWebhook?(params: {