@23blocks/block-conversations 0.1.0
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/README.md +62 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/conversations.block.js +24 -0
- package/dist/lib/conversations.block.js.map +1 -0
- package/dist/lib/mappers/draft-message.mapper.js +50 -0
- package/dist/lib/mappers/draft-message.mapper.js.map +1 -0
- package/dist/lib/mappers/group.mapper.js +29 -0
- package/dist/lib/mappers/group.mapper.js.map +1 -0
- package/dist/lib/mappers/index.js +7 -0
- package/dist/lib/mappers/index.js.map +1 -0
- package/dist/lib/mappers/message.mapper.js +53 -0
- package/dist/lib/mappers/message.mapper.js.map +1 -0
- package/dist/lib/mappers/notification.mapper.js +39 -0
- package/dist/lib/mappers/notification.mapper.js.map +1 -0
- package/dist/lib/mappers/utils.js +75 -0
- package/dist/lib/mappers/utils.js.map +1 -0
- package/dist/lib/services/conversations.service.js +38 -0
- package/dist/lib/services/conversations.service.js.map +1 -0
- package/dist/lib/services/draft-messages.service.js +94 -0
- package/dist/lib/services/draft-messages.service.js.map +1 -0
- package/dist/lib/services/groups.service.js +109 -0
- package/dist/lib/services/groups.service.js.map +1 -0
- package/dist/lib/services/index.js +7 -0
- package/dist/lib/services/index.js.map +1 -0
- package/dist/lib/services/messages.service.js +116 -0
- package/dist/lib/services/messages.service.js.map +1 -0
- package/dist/lib/services/notifications.service.js +100 -0
- package/dist/lib/services/notifications.service.js.map +1 -0
- package/dist/lib/types/conversation.js +4 -0
- package/dist/lib/types/conversation.js.map +1 -0
- package/dist/lib/types/draft-message.js +3 -0
- package/dist/lib/types/draft-message.js.map +1 -0
- package/dist/lib/types/group.js +3 -0
- package/dist/lib/types/group.js.map +1 -0
- package/dist/lib/types/index.js +7 -0
- package/dist/lib/types/index.js.map +1 -0
- package/dist/lib/types/message.js +3 -0
- package/dist/lib/types/message.js.map +1 -0
- package/dist/lib/types/notification.js +3 -0
- package/dist/lib/types/notification.js.map +1 -0
- package/package.json +64 -0
package/README.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# @23blocks/block-conversations
|
|
2
|
+
|
|
3
|
+
Conversations block for 23blocks SDK - messaging, groups, notifications, and conversations management.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @23blocks/block-conversations
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { createConversationsBlock } from '@23blocks/block-conversations';
|
|
15
|
+
|
|
16
|
+
const conversationsBlock = createConversationsBlock(transport, {
|
|
17
|
+
appId: 'your-app-id',
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
// Send a message
|
|
21
|
+
const message = await conversationsBlock.messages.create({
|
|
22
|
+
content: 'Hello, world!',
|
|
23
|
+
contextId: 'conversation-123',
|
|
24
|
+
sourceId: 'user-456',
|
|
25
|
+
targetId: 'user-789',
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// Get conversation
|
|
29
|
+
const conversation = await conversationsBlock.conversations.get({
|
|
30
|
+
context: 'conversation-123',
|
|
31
|
+
includeFiles: true,
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
// Create a group
|
|
35
|
+
const group = await conversationsBlock.groups.create({
|
|
36
|
+
name: 'My Group',
|
|
37
|
+
members: ['user-1', 'user-2', 'user-3'],
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
// Send notification
|
|
41
|
+
const notification = await conversationsBlock.notifications.create({
|
|
42
|
+
content: 'You have a new message',
|
|
43
|
+
targetId: 'user-123',
|
|
44
|
+
url: '/messages/456',
|
|
45
|
+
});
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Features
|
|
49
|
+
|
|
50
|
+
- **Messages**: Send, receive, and manage messages
|
|
51
|
+
- **Draft Messages**: Create and manage draft messages
|
|
52
|
+
- **Groups**: Create and manage conversation groups
|
|
53
|
+
- **Notifications**: Send and manage notifications
|
|
54
|
+
- **Conversations**: Get full conversation threads with messages and files
|
|
55
|
+
|
|
56
|
+
## API Reference
|
|
57
|
+
|
|
58
|
+
See the [full documentation](https://github.com/23blocks-OS/frontend-sdk/tree/main/packages/block-conversations) for detailed API reference.
|
|
59
|
+
|
|
60
|
+
## License
|
|
61
|
+
|
|
62
|
+
MIT
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Block factory and metadata
|
|
2
|
+
export { createConversationsBlock, conversationsBlockMetadata } from './lib/conversations.block';
|
|
3
|
+
export { createMessagesService, createDraftMessagesService, createGroupsService, createNotificationsService, createConversationsService } from './lib/services';
|
|
4
|
+
// Mappers (for advanced use cases)
|
|
5
|
+
export { messageMapper, draftMessageMapper, groupMapper, notificationMapper } from './lib/mappers';
|
|
6
|
+
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["// Block factory and metadata\nexport { createConversationsBlock, conversationsBlockMetadata } from './lib/conversations.block';\nexport type { ConversationsBlock, ConversationsBlockConfig } from './lib/conversations.block';\n\n// Types\nexport type {\n // Message types\n Message,\n CreateMessageRequest,\n UpdateMessageRequest,\n ListMessagesParams,\n // Draft Message types\n DraftMessage,\n CreateDraftMessageRequest,\n UpdateDraftMessageRequest,\n ListDraftMessagesParams,\n // Group types\n Group,\n CreateGroupRequest,\n UpdateGroupRequest,\n ListGroupsParams,\n // Notification types\n Notification,\n CreateNotificationRequest,\n UpdateNotificationRequest,\n ListNotificationsParams,\n // Conversation types\n Conversation,\n ConversationFile,\n ConversationMeta,\n GetConversationParams,\n} from './lib/types';\n\n// Services\nexport type {\n MessagesService,\n DraftMessagesService,\n GroupsService,\n NotificationsService,\n ConversationsService,\n} from './lib/services';\n\nexport {\n createMessagesService,\n createDraftMessagesService,\n createGroupsService,\n createNotificationsService,\n createConversationsService,\n} from './lib/services';\n\n// Mappers (for advanced use cases)\nexport {\n messageMapper,\n draftMessageMapper,\n groupMapper,\n notificationMapper,\n} from './lib/mappers';\n"],"names":["createConversationsBlock","conversationsBlockMetadata","createMessagesService","createDraftMessagesService","createGroupsService","createNotificationsService","createConversationsService","messageMapper","draftMessageMapper","groupMapper","notificationMapper"],"rangeMappings":";;;;","mappings":"AAAA,6BAA6B;AAC7B,SAASA,wBAAwB,EAAEC,0BAA0B,QAAQ,4BAA4B;AAyCjG,SACEC,qBAAqB,EACrBC,0BAA0B,EAC1BC,mBAAmB,EACnBC,0BAA0B,EAC1BC,0BAA0B,QACrB,iBAAiB;AAExB,mCAAmC;AACnC,SACEC,aAAa,EACbC,kBAAkB,EAClBC,WAAW,EACXC,kBAAkB,QACb,gBAAgB"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { createMessagesService, createDraftMessagesService, createGroupsService, createNotificationsService, createConversationsService } from './services';
|
|
2
|
+
export function createConversationsBlock(transport, config) {
|
|
3
|
+
return {
|
|
4
|
+
messages: createMessagesService(transport, config),
|
|
5
|
+
draftMessages: createDraftMessagesService(transport, config),
|
|
6
|
+
groups: createGroupsService(transport, config),
|
|
7
|
+
notifications: createNotificationsService(transport, config),
|
|
8
|
+
conversations: createConversationsService(transport, config)
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export const conversationsBlockMetadata = {
|
|
12
|
+
name: 'conversations',
|
|
13
|
+
version: '0.1.0',
|
|
14
|
+
description: 'Messaging, conversations, groups, and notifications management',
|
|
15
|
+
resourceTypes: [
|
|
16
|
+
'Message',
|
|
17
|
+
'DraftMessage',
|
|
18
|
+
'Group',
|
|
19
|
+
'Notification',
|
|
20
|
+
'Conversation'
|
|
21
|
+
]
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=conversations.block.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/lib/conversations.block.ts"],"sourcesContent":["import type { Transport, BlockConfig, BlockMetadata } from '@23blocks/contracts';\nimport {\n createMessagesService,\n createDraftMessagesService,\n createGroupsService,\n createNotificationsService,\n createConversationsService,\n type MessagesService,\n type DraftMessagesService,\n type GroupsService,\n type NotificationsService,\n type ConversationsService,\n} from './services';\n\nexport interface ConversationsBlockConfig extends BlockConfig {\n appId: string;\n tenantId?: string;\n}\n\nexport interface ConversationsBlock {\n messages: MessagesService;\n draftMessages: DraftMessagesService;\n groups: GroupsService;\n notifications: NotificationsService;\n conversations: ConversationsService;\n}\n\nexport function createConversationsBlock(\n transport: Transport,\n config: ConversationsBlockConfig\n): ConversationsBlock {\n return {\n messages: createMessagesService(transport, config),\n draftMessages: createDraftMessagesService(transport, config),\n groups: createGroupsService(transport, config),\n notifications: createNotificationsService(transport, config),\n conversations: createConversationsService(transport, config),\n };\n}\n\nexport const conversationsBlockMetadata: BlockMetadata = {\n name: 'conversations',\n version: '0.1.0',\n description: 'Messaging, conversations, groups, and notifications management',\n resourceTypes: [\n 'Message',\n 'DraftMessage',\n 'Group',\n 'Notification',\n 'Conversation',\n ],\n};\n"],"names":["createMessagesService","createDraftMessagesService","createGroupsService","createNotificationsService","createConversationsService","createConversationsBlock","transport","config","messages","draftMessages","groups","notifications","conversations","conversationsBlockMetadata","name","version","description","resourceTypes"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;","mappings":"AACA,SACEA,qBAAqB,EACrBC,0BAA0B,EAC1BC,mBAAmB,EACnBC,0BAA0B,EAC1BC,0BAA0B,QAMrB,aAAa;AAepB,OAAO,SAASC,yBACdC,SAAoB,EACpBC,MAAgC;IAEhC,OAAO;QACLC,UAAUR,sBAAsBM,WAAWC;QAC3CE,eAAeR,2BAA2BK,WAAWC;QACrDG,QAAQR,oBAAoBI,WAAWC;QACvCI,eAAeR,2BAA2BG,WAAWC;QACrDK,eAAeR,2BAA2BE,WAAWC;IACvD;AACF;AAEA,OAAO,MAAMM,6BAA4C;IACvDC,MAAM;IACNC,SAAS;IACTC,aAAa;IACbC,eAAe;QACb;QACA;QACA;QACA;QACA;KACD;AACH,EAAE"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { parseString, parseDate, parseBoolean, parseOptionalNumber, parseStatus, parseStringArray } from './utils';
|
|
2
|
+
export const draftMessageMapper = {
|
|
3
|
+
type: 'DraftMessage',
|
|
4
|
+
map: (resource)=>({
|
|
5
|
+
id: resource.id,
|
|
6
|
+
uniqueId: parseString(resource.attributes['unique_id']) || resource.id,
|
|
7
|
+
createdAt: parseDate(resource.attributes['created_at']) || new Date(),
|
|
8
|
+
updatedAt: parseDate(resource.attributes['updated_at']) || new Date(),
|
|
9
|
+
contextId: parseString(resource.attributes['context_id']),
|
|
10
|
+
parentId: parseString(resource.attributes['parent_id']),
|
|
11
|
+
content: parseString(resource.attributes['content']) || '',
|
|
12
|
+
// Source (sender)
|
|
13
|
+
source: parseString(resource.attributes['source']),
|
|
14
|
+
sourceId: parseString(resource.attributes['source_id']),
|
|
15
|
+
sourceAlias: parseString(resource.attributes['source_alias']),
|
|
16
|
+
sourceEmail: parseString(resource.attributes['source_email']),
|
|
17
|
+
sourcePhone: parseString(resource.attributes['source_phone']),
|
|
18
|
+
sourceType: parseString(resource.attributes['source_type']),
|
|
19
|
+
// Target (recipient)
|
|
20
|
+
target: parseString(resource.attributes['target']),
|
|
21
|
+
targetId: parseString(resource.attributes['target_id']),
|
|
22
|
+
targetAlias: parseString(resource.attributes['target_alias']),
|
|
23
|
+
targetEmail: parseString(resource.attributes['target_email']),
|
|
24
|
+
targetPhone: parseString(resource.attributes['target_phone']),
|
|
25
|
+
targetType: parseString(resource.attributes['target_type']),
|
|
26
|
+
targetDeviceId: parseString(resource.attributes['target_device_id']),
|
|
27
|
+
// Value and data source
|
|
28
|
+
value: parseOptionalNumber(resource.attributes['value']),
|
|
29
|
+
dataSource: parseString(resource.attributes['data_source']),
|
|
30
|
+
dataSourceId: parseString(resource.attributes['data_source_id']),
|
|
31
|
+
dataSourceType: parseString(resource.attributes['data_source_type']),
|
|
32
|
+
dataSourceAlias: parseString(resource.attributes['data_source_alias']),
|
|
33
|
+
// Status
|
|
34
|
+
status: parseStatus(resource.attributes['status']),
|
|
35
|
+
enabled: parseBoolean(resource.attributes['enabled']),
|
|
36
|
+
// Extra data
|
|
37
|
+
payload: resource.attributes['payload'],
|
|
38
|
+
// Notification
|
|
39
|
+
notificationContent: parseString(resource.attributes['notification_content']),
|
|
40
|
+
notificationUrl: parseString(resource.attributes['notification_url']),
|
|
41
|
+
// Expiration
|
|
42
|
+
expiresAt: parseDate(resource.attributes['expires_at']),
|
|
43
|
+
// RAG sources
|
|
44
|
+
ragSources: parseStringArray(resource.attributes['rag_sources']),
|
|
45
|
+
// Idempotency
|
|
46
|
+
idempotencyKey: parseString(resource.attributes['idempotency_key'])
|
|
47
|
+
})
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
//# sourceMappingURL=draft-message.mapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/mappers/draft-message.mapper.ts"],"sourcesContent":["import type { ResourceMapper } from '@23blocks/jsonapi-codec';\nimport type { DraftMessage } from '../types/draft-message';\nimport { parseString, parseDate, parseBoolean, parseOptionalNumber, parseStatus, parseStringArray } from './utils';\n\nexport const draftMessageMapper: ResourceMapper<DraftMessage> = {\n type: 'DraftMessage',\n map: (resource) => ({\n id: resource.id,\n uniqueId: parseString(resource.attributes['unique_id']) || resource.id,\n createdAt: parseDate(resource.attributes['created_at']) || new Date(),\n updatedAt: parseDate(resource.attributes['updated_at']) || new Date(),\n\n contextId: parseString(resource.attributes['context_id']),\n parentId: parseString(resource.attributes['parent_id']),\n content: parseString(resource.attributes['content']) || '',\n\n // Source (sender)\n source: parseString(resource.attributes['source']),\n sourceId: parseString(resource.attributes['source_id']),\n sourceAlias: parseString(resource.attributes['source_alias']),\n sourceEmail: parseString(resource.attributes['source_email']),\n sourcePhone: parseString(resource.attributes['source_phone']),\n sourceType: parseString(resource.attributes['source_type']),\n\n // Target (recipient)\n target: parseString(resource.attributes['target']),\n targetId: parseString(resource.attributes['target_id']),\n targetAlias: parseString(resource.attributes['target_alias']),\n targetEmail: parseString(resource.attributes['target_email']),\n targetPhone: parseString(resource.attributes['target_phone']),\n targetType: parseString(resource.attributes['target_type']),\n targetDeviceId: parseString(resource.attributes['target_device_id']),\n\n // Value and data source\n value: parseOptionalNumber(resource.attributes['value']),\n dataSource: parseString(resource.attributes['data_source']),\n dataSourceId: parseString(resource.attributes['data_source_id']),\n dataSourceType: parseString(resource.attributes['data_source_type']),\n dataSourceAlias: parseString(resource.attributes['data_source_alias']),\n\n // Status\n status: parseStatus(resource.attributes['status']),\n enabled: parseBoolean(resource.attributes['enabled']),\n\n // Extra data\n payload: resource.attributes['payload'] as Record<string, unknown> | undefined,\n\n // Notification\n notificationContent: parseString(resource.attributes['notification_content']),\n notificationUrl: parseString(resource.attributes['notification_url']),\n\n // Expiration\n expiresAt: parseDate(resource.attributes['expires_at']),\n\n // RAG sources\n ragSources: parseStringArray(resource.attributes['rag_sources']),\n\n // Idempotency\n idempotencyKey: parseString(resource.attributes['idempotency_key']),\n }),\n};\n"],"names":["parseString","parseDate","parseBoolean","parseOptionalNumber","parseStatus","parseStringArray","draftMessageMapper","type","map","resource","id","uniqueId","attributes","createdAt","Date","updatedAt","contextId","parentId","content","source","sourceId","sourceAlias","sourceEmail","sourcePhone","sourceType","target","targetId","targetAlias","targetEmail","targetPhone","targetType","targetDeviceId","value","dataSource","dataSourceId","dataSourceType","dataSourceAlias","status","enabled","payload","notificationContent","notificationUrl","expiresAt","ragSources","idempotencyKey"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,SAASA,WAAW,EAAEC,SAAS,EAAEC,YAAY,EAAEC,mBAAmB,EAAEC,WAAW,EAAEC,gBAAgB,QAAQ,UAAU;AAEnH,OAAO,MAAMC,qBAAmD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uB,gBAAgBnC,YAAYS,SAASG,UAAU,CAAC,mBAAmB;YACnEwB,iBAAiBpC,YAAYS,SAASG,UAAU,CAAC,oBAAoB;YAErE,SAAS;YACTyB,QAAQjC,YAAYK,SAASG,UAAU,CAAC,SAAS;YACjD0B,SAASpC,aAAaO,SAASG,UAAU,CAAC,UAAU;YAEpD,aAAa;YACb2B,SAAS9B,SAASG,UAAU,CAAC,UAAU;YAEvC,eAAe;YACf4B,qBAAqBxC,YAAYS,SAASG,UAAU,CAAC,uBAAuB;YAC5E6B,iBAAiBzC,YAAYS,SAASG,UAAU,CAAC,mBAAmB;YAEpE,aAAa;YACb8B,WAAWzC,UAAUQ,SAASG,UAAU,CAAC,aAAa;YAEtD,cAAc;YACd+B,YAAYtC,iBAAiBI,SAASG,UAAU,CAAC,cAAc;YAE/D,cAAc;YACdgC,gBAAgB5C,YAAYS,SAASG,UAAU,CAAC,kBAAkB;QACpE,CAAA;AACF,EAAE"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { parseString, parseDate, parseBoolean, parseStatus, parseStringArray } from './utils';
|
|
2
|
+
export const groupMapper = {
|
|
3
|
+
type: 'Group',
|
|
4
|
+
map: (resource)=>({
|
|
5
|
+
id: resource.id,
|
|
6
|
+
uniqueId: parseString(resource.attributes['unique_id']) || resource.id,
|
|
7
|
+
createdAt: parseDate(resource.attributes['created_at']) || new Date(),
|
|
8
|
+
updatedAt: parseDate(resource.attributes['updated_at']) || new Date(),
|
|
9
|
+
name: parseString(resource.attributes['name']) || '',
|
|
10
|
+
code: parseString(resource.attributes['code']),
|
|
11
|
+
uniqueCode: parseString(resource.attributes['unique_code']),
|
|
12
|
+
qcode: parseString(resource.attributes['qcode']),
|
|
13
|
+
groupType: parseString(resource.attributes['group_type']),
|
|
14
|
+
// Members
|
|
15
|
+
members: parseStringArray(resource.attributes['members']),
|
|
16
|
+
// Status
|
|
17
|
+
status: parseStatus(resource.attributes['status']),
|
|
18
|
+
enabled: parseBoolean(resource.attributes['enabled']),
|
|
19
|
+
// Source
|
|
20
|
+
source: parseString(resource.attributes['source']),
|
|
21
|
+
sourceAlias: parseString(resource.attributes['source_alias']),
|
|
22
|
+
sourceId: parseString(resource.attributes['source_id']),
|
|
23
|
+
sourceType: parseString(resource.attributes['source_type']),
|
|
24
|
+
// Extra data
|
|
25
|
+
payload: resource.attributes['payload']
|
|
26
|
+
})
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=group.mapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/mappers/group.mapper.ts"],"sourcesContent":["import type { ResourceMapper } from '@23blocks/jsonapi-codec';\nimport type { Group } from '../types/group';\nimport { parseString, parseDate, parseBoolean, parseStatus, parseStringArray } from './utils';\n\nexport const groupMapper: ResourceMapper<Group> = {\n type: 'Group',\n map: (resource) => ({\n id: resource.id,\n uniqueId: parseString(resource.attributes['unique_id']) || resource.id,\n createdAt: parseDate(resource.attributes['created_at']) || new Date(),\n updatedAt: parseDate(resource.attributes['updated_at']) || new Date(),\n\n name: parseString(resource.attributes['name']) || '',\n code: parseString(resource.attributes['code']),\n uniqueCode: parseString(resource.attributes['unique_code']),\n qcode: parseString(resource.attributes['qcode']),\n groupType: parseString(resource.attributes['group_type']),\n\n // Members\n members: parseStringArray(resource.attributes['members']),\n\n // Status\n status: parseStatus(resource.attributes['status']),\n enabled: parseBoolean(resource.attributes['enabled']),\n\n // Source\n source: parseString(resource.attributes['source']),\n sourceAlias: parseString(resource.attributes['source_alias']),\n sourceId: parseString(resource.attributes['source_id']),\n sourceType: parseString(resource.attributes['source_type']),\n\n // Extra data\n payload: resource.attributes['payload'] as Record<string, unknown> | undefined,\n }),\n};\n"],"names":["parseString","parseDate","parseBoolean","parseStatus","parseStringArray","groupMapper","type","map","resource","id","uniqueId","attributes","createdAt","Date","updatedAt","name","code","uniqueCode","qcode","groupType","members","status","enabled","source","sourceAlias","sourceId","sourceType","payload"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,SAASA,WAAW,EAAEC,SAAS,EAAEC,YAAY,EAAEC,WAAW,EAAEC,gBAAgB,QAAQ,UAAU;AAE9F,OAAO,MAAMC,cAAqC;IAChDC,MAAM;IACNC,KAAK,CAACC,WAAc,CAAA;YAClBC,IAAID,SAASC,EAAE;YACfC,UAAUV,YAAYQ,SAASG,UAAU,CAAC,YAAY,KAAKH,SAASC,EAAE;YACtEG,WAAWX,UAAUO,SAASG,UAAU,CAAC,aAAa,KAAK,IAAIE;YAC/DC,WAAWb,UAAUO,SAASG,UAAU,CAAC,aAAa,KAAK,IAAIE;YAE/DE,MAAMf,YAAYQ,SAASG,UAAU,CAAC,OAAO,KAAK;YAClDK,MAAMhB,YAAYQ,SAASG,UAAU,CAAC,OAAO;YAC7CM,YAAYjB,YAAYQ,SAASG,UAAU,CAAC,cAAc;YAC1DO,OAAOlB,YAAYQ,SAASG,UAAU,CAAC,QAAQ;YAC/CQ,WAAWnB,YAAYQ,SAASG,UAAU,CAAC,aAAa;YAExD,UAAU;YACVS,SAAShB,iBAAiBI,SAASG,UAAU,CAAC,UAAU;YAExD,SAAS;YACTU,QAAQlB,YAAYK,SAASG,UAAU,CAAC,SAAS;YACjDW,SAASpB,aAAaM,SAASG,UAAU,CAAC,UAAU;YAEpD,SAAS;YACTY,QAAQvB,YAAYQ,SAASG,UAAU,CAAC,SAAS;YACjDa,aAAaxB,YAAYQ,SAASG,UAAU,CAAC,eAAe;YAC5Dc,UAAUzB,YAAYQ,SAASG,UAAU,CAAC,YAAY;YACtDe,YAAY1B,YAAYQ,SAASG,UAAU,CAAC,cAAc;YAE1D,aAAa;YACbgB,SAASnB,SAASG,UAAU,CAAC,UAAU;QACzC,CAAA;AACF,EAAE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/mappers/index.ts"],"sourcesContent":["export * from './message.mapper';\nexport * from './draft-message.mapper';\nexport * from './group.mapper';\nexport * from './notification.mapper';\nexport * from './utils';\n"],"names":[],"rangeMappings":";;;;","mappings":"AAAA,cAAc,mBAAmB;AACjC,cAAc,yBAAyB;AACvC,cAAc,iBAAiB;AAC/B,cAAc,wBAAwB;AACtC,cAAc,UAAU"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { parseString, parseDate, parseBoolean, parseOptionalNumber, parseStatus, parseStringArray } from './utils';
|
|
2
|
+
export const messageMapper = {
|
|
3
|
+
type: 'Message',
|
|
4
|
+
map: (resource)=>({
|
|
5
|
+
id: resource.id,
|
|
6
|
+
uniqueId: parseString(resource.attributes['unique_id']) || resource.id,
|
|
7
|
+
createdAt: parseDate(resource.attributes['created_at']) || new Date(),
|
|
8
|
+
updatedAt: parseDate(resource.attributes['updated_at']) || new Date(),
|
|
9
|
+
contextId: parseString(resource.attributes['context_id']),
|
|
10
|
+
parentId: parseString(resource.attributes['parent_id']),
|
|
11
|
+
content: parseString(resource.attributes['content']) || '',
|
|
12
|
+
// Source (sender)
|
|
13
|
+
source: parseString(resource.attributes['source']),
|
|
14
|
+
sourceId: parseString(resource.attributes['source_id']),
|
|
15
|
+
sourceAlias: parseString(resource.attributes['source_alias']),
|
|
16
|
+
sourceEmail: parseString(resource.attributes['source_email']),
|
|
17
|
+
sourcePhone: parseString(resource.attributes['source_phone']),
|
|
18
|
+
sourceType: parseString(resource.attributes['source_type']),
|
|
19
|
+
// Target (recipient)
|
|
20
|
+
target: parseString(resource.attributes['target']),
|
|
21
|
+
targetId: parseString(resource.attributes['target_id']),
|
|
22
|
+
targetAlias: parseString(resource.attributes['target_alias']),
|
|
23
|
+
targetEmail: parseString(resource.attributes['target_email']),
|
|
24
|
+
targetPhone: parseString(resource.attributes['target_phone']),
|
|
25
|
+
targetType: parseString(resource.attributes['target_type']),
|
|
26
|
+
targetDeviceId: parseString(resource.attributes['target_device_id']),
|
|
27
|
+
// Value and data source
|
|
28
|
+
value: parseOptionalNumber(resource.attributes['value']),
|
|
29
|
+
dataSource: parseString(resource.attributes['data_source']),
|
|
30
|
+
dataSourceId: parseString(resource.attributes['data_source_id']),
|
|
31
|
+
dataSourceType: parseString(resource.attributes['data_source_type']),
|
|
32
|
+
dataSourceAlias: parseString(resource.attributes['data_source_alias']),
|
|
33
|
+
// Status
|
|
34
|
+
status: parseStatus(resource.attributes['status']),
|
|
35
|
+
enabled: parseBoolean(resource.attributes['enabled']),
|
|
36
|
+
// Extra data
|
|
37
|
+
payload: resource.attributes['payload'],
|
|
38
|
+
// Notification
|
|
39
|
+
notificationContent: parseString(resource.attributes['notification_content']),
|
|
40
|
+
notificationUrl: parseString(resource.attributes['notification_url']),
|
|
41
|
+
// Expiration
|
|
42
|
+
expiresAt: parseDate(resource.attributes['expires_at']),
|
|
43
|
+
// RAG sources
|
|
44
|
+
ragSources: parseStringArray(resource.attributes['rag_sources']),
|
|
45
|
+
// Idempotency
|
|
46
|
+
idempotencyKey: parseString(resource.attributes['idempotency_key']),
|
|
47
|
+
// Tracking
|
|
48
|
+
createdBy: parseString(resource.attributes['created_by']),
|
|
49
|
+
updatedBy: parseString(resource.attributes['updated_by'])
|
|
50
|
+
})
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
//# sourceMappingURL=message.mapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/mappers/message.mapper.ts"],"sourcesContent":["import type { ResourceMapper } from '@23blocks/jsonapi-codec';\nimport type { Message } from '../types/message';\nimport { parseString, parseDate, parseBoolean, parseOptionalNumber, parseStatus, parseStringArray } from './utils';\n\nexport const messageMapper: ResourceMapper<Message> = {\n type: 'Message',\n map: (resource) => ({\n id: resource.id,\n uniqueId: parseString(resource.attributes['unique_id']) || resource.id,\n createdAt: parseDate(resource.attributes['created_at']) || new Date(),\n updatedAt: parseDate(resource.attributes['updated_at']) || new Date(),\n\n contextId: parseString(resource.attributes['context_id']),\n parentId: parseString(resource.attributes['parent_id']),\n content: parseString(resource.attributes['content']) || '',\n\n // Source (sender)\n source: parseString(resource.attributes['source']),\n sourceId: parseString(resource.attributes['source_id']),\n sourceAlias: parseString(resource.attributes['source_alias']),\n sourceEmail: parseString(resource.attributes['source_email']),\n sourcePhone: parseString(resource.attributes['source_phone']),\n sourceType: parseString(resource.attributes['source_type']),\n\n // Target (recipient)\n target: parseString(resource.attributes['target']),\n targetId: parseString(resource.attributes['target_id']),\n targetAlias: parseString(resource.attributes['target_alias']),\n targetEmail: parseString(resource.attributes['target_email']),\n targetPhone: parseString(resource.attributes['target_phone']),\n targetType: parseString(resource.attributes['target_type']),\n targetDeviceId: parseString(resource.attributes['target_device_id']),\n\n // Value and data source\n value: parseOptionalNumber(resource.attributes['value']),\n dataSource: parseString(resource.attributes['data_source']),\n dataSourceId: parseString(resource.attributes['data_source_id']),\n dataSourceType: parseString(resource.attributes['data_source_type']),\n dataSourceAlias: parseString(resource.attributes['data_source_alias']),\n\n // Status\n status: parseStatus(resource.attributes['status']),\n enabled: parseBoolean(resource.attributes['enabled']),\n\n // Extra data\n payload: resource.attributes['payload'] as Record<string, unknown> | undefined,\n\n // Notification\n notificationContent: parseString(resource.attributes['notification_content']),\n notificationUrl: parseString(resource.attributes['notification_url']),\n\n // Expiration\n expiresAt: parseDate(resource.attributes['expires_at']),\n\n // RAG sources\n ragSources: parseStringArray(resource.attributes['rag_sources']),\n\n // Idempotency\n idempotencyKey: parseString(resource.attributes['idempotency_key']),\n\n // Tracking\n createdBy: parseString(resource.attributes['created_by']),\n updatedBy: parseString(resource.attributes['updated_by']),\n }),\n};\n"],"names":["parseString","parseDate","parseBoolean","parseOptionalNumber","parseStatus","parseStringArray","messageMapper","type","map","resource","id","uniqueId","attributes","createdAt","Date","updatedAt","contextId","parentId","content","source","sourceId","sourceAlias","sourceEmail","sourcePhone","sourceType","target","targetId","targetAlias","targetEmail","targetPhone","targetType","targetDeviceId","value","dataSource","dataSourceId","dataSourceType","dataSourceAlias","status","enabled","payload","notificationContent","notificationUrl","expiresAt","ragS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cAAc;YAC1DmB,gBAAgB/B,YAAYS,SAASG,UAAU,CAAC,mBAAmB;YAEnE,wBAAwB;YACxBoB,OAAO7B,oBAAoBM,SAASG,UAAU,CAAC,QAAQ;YACvDqB,YAAYjC,YAAYS,SAASG,UAAU,CAAC,cAAc;YAC1DsB,cAAclC,YAAYS,SAASG,UAAU,CAAC,iBAAiB;YAC/DuB,gBAAgBnC,YAAYS,SAASG,UAAU,CAAC,mBAAmB;YACnEwB,iBAAiBpC,YAAYS,SAASG,UAAU,CAAC,oBAAoB;YAErE,SAAS;YACTyB,QAAQjC,YAAYK,SAASG,UAAU,CAAC,SAAS;YACjD0B,SAASpC,aAAaO,SAASG,UAAU,CAAC,UAAU;YAEpD,aAAa;YACb2B,SAAS9B,SAASG,UAAU,CAAC,UAAU;YAEvC,eAAe;YACf4B,qBAAqBxC,YAAYS,SAASG,UAAU,CAAC,uBAAuB;YAC5E6B,iBAAiBzC,YAAYS,SAASG,UAAU,CAAC,mBAAmB;YAEpE,aAAa;YACb8B,WAAWzC,UAAUQ,SAASG,UAAU,CAAC,aAAa;YAEtD,cAAc;YACd+B,YAAYtC,iBAAiBI,SAASG,UAAU,CAAC,cAAc;YAE/D,cAAc;YACdgC,gBAAgB5C,YAAYS,SAASG,UAAU,CAAC,kBAAkB;YAElE,WAAW;YACXiC,WAAW7C,YAAYS,SAASG,UAAU,CAAC,aAAa;YACxDkC,WAAW9C,YAAYS,SAASG,UAAU,CAAC,aAAa;QAC1D,CAAA;AACF,EAAE"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { parseString, parseDate, parseBoolean, parseStatus } from './utils';
|
|
2
|
+
export const notificationMapper = {
|
|
3
|
+
type: 'Notification',
|
|
4
|
+
map: (resource)=>({
|
|
5
|
+
id: resource.id,
|
|
6
|
+
uniqueId: parseString(resource.attributes['unique_id']) || resource.id,
|
|
7
|
+
createdAt: parseDate(resource.attributes['created_at']) || new Date(),
|
|
8
|
+
updatedAt: parseDate(resource.attributes['updated_at']) || new Date(),
|
|
9
|
+
content: parseString(resource.attributes['content']) || '',
|
|
10
|
+
// Source
|
|
11
|
+
source: parseString(resource.attributes['source']),
|
|
12
|
+
sourceAlias: parseString(resource.attributes['source_alias']),
|
|
13
|
+
sourceId: parseString(resource.attributes['source_id']),
|
|
14
|
+
sourceType: parseString(resource.attributes['source_type']),
|
|
15
|
+
// URL
|
|
16
|
+
url: parseString(resource.attributes['url']),
|
|
17
|
+
// Status
|
|
18
|
+
status: parseStatus(resource.attributes['status']),
|
|
19
|
+
// Target
|
|
20
|
+
target: parseString(resource.attributes['target']),
|
|
21
|
+
targetId: parseString(resource.attributes['target_id']),
|
|
22
|
+
targetAlias: parseString(resource.attributes['target_alias']),
|
|
23
|
+
targetType: parseString(resource.attributes['target_type']),
|
|
24
|
+
targetEmail: parseString(resource.attributes['target_email']),
|
|
25
|
+
targetPhone: parseString(resource.attributes['target_phone']),
|
|
26
|
+
targetDeviceId: parseString(resource.attributes['target_device_id']),
|
|
27
|
+
// Multichannel
|
|
28
|
+
multichannel: parseBoolean(resource.attributes['multichannel']),
|
|
29
|
+
// Extra data
|
|
30
|
+
payload: resource.attributes['payload'],
|
|
31
|
+
// Expiration
|
|
32
|
+
expiresAt: parseDate(resource.attributes['expires_at']),
|
|
33
|
+
// Tracking
|
|
34
|
+
createdBy: parseString(resource.attributes['created_by']),
|
|
35
|
+
updatedBy: parseString(resource.attributes['updated_by'])
|
|
36
|
+
})
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
//# sourceMappingURL=notification.mapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/mappers/notification.mapper.ts"],"sourcesContent":["import type { ResourceMapper } from '@23blocks/jsonapi-codec';\nimport type { Notification } from '../types/notification';\nimport { parseString, parseDate, parseBoolean, parseStatus } from './utils';\n\nexport const notificationMapper: ResourceMapper<Notification> = {\n type: 'Notification',\n map: (resource) => ({\n id: resource.id,\n uniqueId: parseString(resource.attributes['unique_id']) || resource.id,\n createdAt: parseDate(resource.attributes['created_at']) || new Date(),\n updatedAt: parseDate(resource.attributes['updated_at']) || new Date(),\n\n content: parseString(resource.attributes['content']) || '',\n\n // Source\n source: parseString(resource.attributes['source']),\n sourceAlias: parseString(resource.attributes['source_alias']),\n sourceId: parseString(resource.attributes['source_id']),\n sourceType: parseString(resource.attributes['source_type']),\n\n // URL\n url: parseString(resource.attributes['url']),\n\n // Status\n status: parseStatus(resource.attributes['status']),\n\n // Target\n target: parseString(resource.attributes['target']),\n targetId: parseString(resource.attributes['target_id']),\n targetAlias: parseString(resource.attributes['target_alias']),\n targetType: parseString(resource.attributes['target_type']),\n targetEmail: parseString(resource.attributes['target_email']),\n targetPhone: parseString(resource.attributes['target_phone']),\n targetDeviceId: parseString(resource.attributes['target_device_id']),\n\n // Multichannel\n multichannel: parseBoolean(resource.attributes['multichannel']),\n\n // Extra data\n payload: resource.attributes['payload'] as Record<string, unknown> | undefined,\n\n // Expiration\n expiresAt: parseDate(resource.attributes['expires_at']),\n\n // Tracking\n createdBy: parseString(resource.attributes['created_by']),\n updatedBy: parseString(resource.attributes['updated_by']),\n }),\n};\n"],"names":["parseString","parseDate","parseBoolean","parseStatus","notificationMapper","type","map","resource","id","uniqueId","attributes","createdAt","Date","updatedAt","content","source","sourceAlias","sourceId","sourceType","url","status","target","targetId","targetAlias","targetType","targetEmail","targetPhone","targetDeviceId","multichannel","payload","expiresAt","createdBy","updatedBy"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,SAASA,WAAW,EAAEC,SAAS,EAAEC,YAAY,EAAEC,WAAW,QAAQ,UAAU;AAE5E,OAAO,MAAMC,qBAAmD;IAC9DC,MAAM;IACNC,KAAK,CAACC,WAAc,CAAA;YAClBC,IAAID,SAASC,EAAE;YACfC,UAAUT,YAAYO,SAASG,UAAU,CAAC,YAAY,KAAKH,SAASC,EAAE;YACtEG,WAAWV,UAAUM,SAASG,UAAU,CAAC,aAAa,KAAK,IAAIE;YAC/DC,WAAWZ,UAAUM,SAASG,UAAU,CAAC,aAAa,KAAK,IAAIE;YAE/DE,SAASd,YAAYO,SAASG,UAAU,CAAC,UAAU,KAAK;YAExD,SAAS;YACTK,QAAQf,YAAYO,SAASG,UAAU,CAAC,SAAS;YACjDM,aAAahB,YAAYO,SAASG,UAAU,CAAC,eAAe;YAC5DO,UAAUjB,YAAYO,SAASG,UAAU,CAAC,YAAY;YACtDQ,YAAYlB,YAAYO,SAASG,UAAU,CAAC,cAAc;YAE1D,MAAM;YACNS,KAAKnB,YAAYO,SAASG,UAAU,CAAC,MAAM;YAE3C,SAAS;YACTU,QAAQjB,YAAYI,SAASG,UAAU,CAAC,SAAS;YAEjD,SAAS;YACTW,QAAQrB,YAAYO,SAASG,UAAU,CAAC,SAAS;YACjDY,UAAUtB,YAAYO,SAASG,UAAU,CAAC,YAAY;YACtDa,aAAavB,YAAYO,SAASG,UAAU,CAAC,eAAe;YAC5Dc,YAAYxB,YAAYO,SAASG,UAAU,CAAC,cAAc;YAC1De,aAAazB,YAAYO,SAASG,UAAU,CAAC,eAAe;YAC5DgB,aAAa1B,YAAYO,SAASG,UAAU,CAAC,eAAe;YAC5DiB,gBAAgB3B,YAAYO,SAASG,UAAU,CAAC,mBAAmB;YAEnE,eAAe;YACfkB,cAAc1B,aAAaK,SAASG,UAAU,CAAC,eAAe;YAE9D,aAAa;YACbmB,SAAStB,SAASG,UAAU,CAAC,UAAU;YAEvC,aAAa;YACboB,WAAW7B,UAAUM,SAASG,UAAU,CAAC,aAAa;YAEtD,WAAW;YACXqB,WAAW/B,YAAYO,SAASG,UAAU,CAAC,aAAa;YACxDsB,WAAWhC,YAAYO,SAASG,UAAU,CAAC,aAAa;QAC1D,CAAA;AACF,EAAE"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse a string value, returning undefined for empty/undefined
|
|
3
|
+
*/ export function parseString(value) {
|
|
4
|
+
if (value === null || value === undefined) {
|
|
5
|
+
return undefined;
|
|
6
|
+
}
|
|
7
|
+
const str = String(value);
|
|
8
|
+
return str.length > 0 ? str : undefined;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Parse a date value
|
|
12
|
+
*/ export function parseDate(value) {
|
|
13
|
+
if (value === null || value === undefined) {
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
if (value instanceof Date) {
|
|
17
|
+
return value;
|
|
18
|
+
}
|
|
19
|
+
if (typeof value === 'string' || typeof value === 'number') {
|
|
20
|
+
const date = new Date(value);
|
|
21
|
+
return isNaN(date.getTime()) ? undefined : date;
|
|
22
|
+
}
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Parse a boolean value
|
|
27
|
+
*/ export function parseBoolean(value) {
|
|
28
|
+
if (typeof value === 'boolean') {
|
|
29
|
+
return value;
|
|
30
|
+
}
|
|
31
|
+
if (value === 'true' || value === '1' || value === 1) {
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Parse an array of strings
|
|
38
|
+
*/ export function parseStringArray(value) {
|
|
39
|
+
if (value === null || value === undefined) {
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
if (Array.isArray(value)) {
|
|
43
|
+
return value.map(String);
|
|
44
|
+
}
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Parse a number value
|
|
49
|
+
*/ export function parseNumber(value) {
|
|
50
|
+
if (value === null || value === undefined) {
|
|
51
|
+
return 0;
|
|
52
|
+
}
|
|
53
|
+
const num = Number(value);
|
|
54
|
+
return isNaN(num) ? 0 : num;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Parse an optional number value
|
|
58
|
+
*/ export function parseOptionalNumber(value) {
|
|
59
|
+
if (value === null || value === undefined) {
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
const num = Number(value);
|
|
63
|
+
return isNaN(num) ? undefined : num;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Parse entity status
|
|
67
|
+
*/ export function parseStatus(value) {
|
|
68
|
+
const status = parseString(value);
|
|
69
|
+
if (status === 'active' || status === 'inactive' || status === 'pending' || status === 'archived' || status === 'deleted') {
|
|
70
|
+
return status;
|
|
71
|
+
}
|
|
72
|
+
return 'active';
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/mappers/utils.ts"],"sourcesContent":["/**\n * Parse a string value, returning undefined for empty/undefined\n */\nexport function parseString(value: unknown): string | undefined {\n if (value === null || value === undefined) {\n return undefined;\n }\n const str = String(value);\n return str.length > 0 ? str : undefined;\n}\n\n/**\n * Parse a date value\n */\nexport function parseDate(value: unknown): Date | undefined {\n if (value === null || value === undefined) {\n return undefined;\n }\n\n if (value instanceof Date) {\n return value;\n }\n\n if (typeof value === 'string' || typeof value === 'number') {\n const date = new Date(value);\n return isNaN(date.getTime()) ? undefined : date;\n }\n\n return undefined;\n}\n\n/**\n * Parse a boolean value\n */\nexport function parseBoolean(value: unknown): boolean {\n if (typeof value === 'boolean') {\n return value;\n }\n if (value === 'true' || value === '1' || value === 1) {\n return true;\n }\n return false;\n}\n\n/**\n * Parse an array of strings\n */\nexport function parseStringArray(value: unknown): string[] | undefined {\n if (value === null || value === undefined) {\n return undefined;\n }\n if (Array.isArray(value)) {\n return value.map(String);\n }\n return undefined;\n}\n\n/**\n * Parse a number value\n */\nexport function parseNumber(value: unknown): number {\n if (value === null || value === undefined) {\n return 0;\n }\n const num = Number(value);\n return isNaN(num) ? 0 : num;\n}\n\n/**\n * Parse an optional number value\n */\nexport function parseOptionalNumber(value: unknown): number | undefined {\n if (value === null || value === undefined) {\n return undefined;\n }\n const num = Number(value);\n return isNaN(num) ? undefined : num;\n}\n\n/**\n * Parse entity status\n */\nexport function parseStatus(value: unknown): 'active' | 'inactive' | 'pending' | 'archived' | 'deleted' {\n const status = parseString(value);\n if (status === 'active' || status === 'inactive' || status === 'pending' || status === 'archived' || status === 'deleted') {\n return status;\n }\n return 'active';\n}\n"],"names":["parseString","value","undefined","str","String","length","parseDate","Date","date","isNaN","getTime","parseBoolean","parseStringArray","Array","isArray","map","parseNumber","num","Number","parseOptionalNumber","parseStatus","status"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;;CAEC,GACD,OAAO,SAASA,YAAYC,KAAc;IACxC,IAAIA,UAAU,QAAQA,UAAUC,WAAW;QACzC,OAAOA;IACT;IACA,MAAMC,MAAMC,OAAOH;IACnB,OAAOE,IAAIE,MAAM,GAAG,IAAIF,MAAMD;AAChC;AAEA;;CAEC,GACD,OAAO,SAASI,UAAUL,KAAc;IACtC,IAAIA,UAAU,QAAQA,UAAUC,WAAW;QACzC,OAAOA;IACT;IAEA,IAAID,iBAAiBM,MAAM;QACzB,OAAON;IACT;IAEA,IAAI,OAAOA,UAAU,YAAY,OAAOA,UAAU,UAAU;QAC1D,MAAMO,OAAO,IAAID,KAAKN;QACtB,OAAOQ,MAAMD,KAAKE,OAAO,MAAMR,YAAYM;IAC7C;IAEA,OAAON;AACT;AAEA;;CAEC,GACD,OAAO,SAASS,aAAaV,KAAc;IACzC,IAAI,OAAOA,UAAU,WAAW;QAC9B,OAAOA;IACT;IACA,IAAIA,UAAU,UAAUA,UAAU,OAAOA,UAAU,GAAG;QACpD,OAAO;IACT;IACA,OAAO;AACT;AAEA;;CAEC,GACD,OAAO,SAASW,iBAAiBX,KAAc;IAC7C,IAAIA,UAAU,QAAQA,UAAUC,WAAW;QACzC,OAAOA;IACT;IACA,IAAIW,MAAMC,OAAO,CAACb,QAAQ;QACxB,OAAOA,MAAMc,GAAG,CAACX;IACnB;IACA,OAAOF;AACT;AAEA;;CAEC,GACD,OAAO,SAASc,YAAYf,KAAc;IACxC,IAAIA,UAAU,QAAQA,UAAUC,WAAW;QACzC,OAAO;IACT;IACA,MAAMe,MAAMC,OAAOjB;IACnB,OAAOQ,MAAMQ,OAAO,IAAIA;AAC1B;AAEA;;CAEC,GACD,OAAO,SAASE,oBAAoBlB,KAAc;IAChD,IAAIA,UAAU,QAAQA,UAAUC,WAAW;QACzC,OAAOA;IACT;IACA,MAAMe,MAAMC,OAAOjB;IACnB,OAAOQ,MAAMQ,OAAOf,YAAYe;AAClC;AAEA;;CAEC,GACD,OAAO,SAASG,YAAYnB,KAAc;IACxC,MAAMoB,SAASrB,YAAYC;IAC3B,IAAIoB,WAAW,YAAYA,WAAW,cAAcA,WAAW,aAAaA,WAAW,cAAcA,WAAW,WAAW;QACzH,OAAOA;IACT;IACA,OAAO;AACT"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { decodeMany } from '@23blocks/jsonapi-codec';
|
|
2
|
+
import { messageMapper } from '../mappers/message.mapper';
|
|
3
|
+
export function createConversationsService(transport, _config) {
|
|
4
|
+
return {
|
|
5
|
+
async get (params) {
|
|
6
|
+
const queryParams = {};
|
|
7
|
+
if (params.page) queryParams['page'] = String(params.page);
|
|
8
|
+
if (params.perPage) queryParams['records'] = String(params.perPage);
|
|
9
|
+
if (params.includeFiles) queryParams['with'] = 'files';
|
|
10
|
+
const response = await transport.get(`/conversations/${params.context}`, {
|
|
11
|
+
params: queryParams
|
|
12
|
+
});
|
|
13
|
+
// Decode messages
|
|
14
|
+
const messages = decodeMany(response, messageMapper);
|
|
15
|
+
// Extract files and meta from response if available
|
|
16
|
+
const rawResponse = response;
|
|
17
|
+
const files = rawResponse.files || [];
|
|
18
|
+
const meta = rawResponse.meta || {};
|
|
19
|
+
return {
|
|
20
|
+
id: params.context,
|
|
21
|
+
context: params.context,
|
|
22
|
+
messages,
|
|
23
|
+
files,
|
|
24
|
+
meta
|
|
25
|
+
};
|
|
26
|
+
},
|
|
27
|
+
async listContexts () {
|
|
28
|
+
var _response_data;
|
|
29
|
+
const response = await transport.get('/conversations/contexts');
|
|
30
|
+
return ((_response_data = response.data) == null ? void 0 : _response_data.contexts) || [];
|
|
31
|
+
},
|
|
32
|
+
async deleteContext (context) {
|
|
33
|
+
await transport.delete(`/conversations/${context}`);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
//# sourceMappingURL=conversations.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/services/conversations.service.ts"],"sourcesContent":["import type { Transport } from '@23blocks/contracts';\nimport { decodeMany } from '@23blocks/jsonapi-codec';\nimport type {\n Conversation,\n GetConversationParams,\n} from '../types/conversation';\nimport { messageMapper } from '../mappers/message.mapper';\n\nexport interface ConversationsService {\n get(params: GetConversationParams): Promise<Conversation>;\n listContexts(): Promise<string[]>;\n deleteContext(context: string): Promise<void>;\n}\n\nexport function createConversationsService(transport: Transport, _config: { appId: string }): ConversationsService {\n return {\n async get(params: GetConversationParams): Promise<Conversation> {\n const queryParams: Record<string, string> = {};\n if (params.page) queryParams['page'] = String(params.page);\n if (params.perPage) queryParams['records'] = String(params.perPage);\n if (params.includeFiles) queryParams['with'] = 'files';\n\n const response = await transport.get<unknown>(`/conversations/${params.context}`, { params: queryParams });\n\n // Decode messages\n const messages = decodeMany(response, messageMapper);\n\n // Extract files and meta from response if available\n const rawResponse = response as any;\n const files = rawResponse.files || [];\n const meta = rawResponse.meta || {};\n\n return {\n id: params.context,\n context: params.context,\n messages,\n files,\n meta,\n };\n },\n\n async listContexts(): Promise<string[]> {\n const response = await transport.get<any>('/conversations/contexts');\n return response.data?.contexts || [];\n },\n\n async deleteContext(context: string): Promise<void> {\n await transport.delete(`/conversations/${context}`);\n },\n };\n}\n"],"names":["decodeMany","messageMapper","createConversationsService","transport","_config","get","params","queryParams","page","String","perPage","includeFiles","response","context","messages","rawResponse","files","meta","id","listContexts","data","contexts","deleteContext","delete"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AACA,SAASA,UAAU,QAAQ,0BAA0B;AAKrD,SAASC,aAAa,QAAQ,4BAA4B;AAQ1D,OAAO,SAASC,2BAA2BC,SAAoB,EAAEC,OAA0B;IACzF,OAAO;QACL,MAAMC,KAAIC,MAA6B;YACrC,MAAMC,cAAsC,CAAC;YAC7C,IAAID,OAAOE,IAAI,EAAED,WAAW,CAAC,OAAO,GAAGE,OAAOH,OAAOE,IAAI;YACzD,IAAIF,OAAOI,OAAO,EAAEH,WAAW,CAAC,UAAU,GAAGE,OAAOH,OAAOI,OAAO;YAClE,IAAIJ,OAAOK,YAAY,EAAEJ,WAAW,CAAC,OAAO,GAAG;YAE/C,MAAMK,WAAW,MAAMT,UAAUE,GAAG,CAAU,CAAC,eAAe,EAAEC,OAAOO,OAAO,CAAC,CAAC,EAAE;gBAAEP,QAAQC;YAAY;YAExG,kBAAkB;YAClB,MAAMO,WAAWd,WAAWY,UAAUX;YAEtC,oDAAoD;YACpD,MAAMc,cAAcH;YACpB,MAAMI,QAAQD,YAAYC,KAAK,IAAI,EAAE;YACrC,MAAMC,OAAOF,YAAYE,IAAI,IAAI,CAAC;YAElC,OAAO;gBACLC,IAAIZ,OAAOO,OAAO;gBAClBA,SAASP,OAAOO,OAAO;gBACvBC;gBACAE;gBACAC;YACF;QACF;QAEA,MAAME;gBAEGP;YADP,MAAMA,WAAW,MAAMT,UAAUE,GAAG,CAAM;YAC1C,OAAOO,EAAAA,iBAAAA,SAASQ,IAAI,qBAAbR,eAAeS,QAAQ,KAAI,EAAE;QACtC;QAEA,MAAMC,eAAcT,OAAe;YACjC,MAAMV,UAAUoB,MAAM,CAAC,CAAC,eAAe,EAAEV,QAAQ,CAAC;QACpD;IACF;AACF"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { decodeOne, decodePageResult } from '@23blocks/jsonapi-codec';
|
|
2
|
+
import { draftMessageMapper } from '../mappers/draft-message.mapper';
|
|
3
|
+
export function createDraftMessagesService(transport, _config) {
|
|
4
|
+
return {
|
|
5
|
+
async list (params) {
|
|
6
|
+
const queryParams = {};
|
|
7
|
+
if (params == null ? void 0 : params.page) queryParams['page'] = String(params.page);
|
|
8
|
+
if (params == null ? void 0 : params.perPage) queryParams['records'] = String(params.perPage);
|
|
9
|
+
if (params == null ? void 0 : params.status) queryParams['status'] = params.status;
|
|
10
|
+
if (params == null ? void 0 : params.contextId) queryParams['context_id'] = params.contextId;
|
|
11
|
+
if (params == null ? void 0 : params.sourceId) queryParams['source_id'] = params.sourceId;
|
|
12
|
+
if (params == null ? void 0 : params.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;
|
|
13
|
+
const response = await transport.get('/draft_messages', {
|
|
14
|
+
params: queryParams
|
|
15
|
+
});
|
|
16
|
+
return decodePageResult(response, draftMessageMapper);
|
|
17
|
+
},
|
|
18
|
+
async get (uniqueId) {
|
|
19
|
+
const response = await transport.get(`/draft_messages/${uniqueId}`);
|
|
20
|
+
return decodeOne(response, draftMessageMapper);
|
|
21
|
+
},
|
|
22
|
+
async create (data) {
|
|
23
|
+
const response = await transport.post('/draft_messages', {
|
|
24
|
+
data: {
|
|
25
|
+
type: 'DraftMessage',
|
|
26
|
+
attributes: {
|
|
27
|
+
context_id: data.contextId,
|
|
28
|
+
parent_id: data.parentId,
|
|
29
|
+
content: data.content,
|
|
30
|
+
source: data.source,
|
|
31
|
+
source_id: data.sourceId,
|
|
32
|
+
source_alias: data.sourceAlias,
|
|
33
|
+
source_email: data.sourceEmail,
|
|
34
|
+
source_phone: data.sourcePhone,
|
|
35
|
+
source_type: data.sourceType,
|
|
36
|
+
target: data.target,
|
|
37
|
+
target_id: data.targetId,
|
|
38
|
+
target_alias: data.targetAlias,
|
|
39
|
+
target_email: data.targetEmail,
|
|
40
|
+
target_phone: data.targetPhone,
|
|
41
|
+
target_type: data.targetType,
|
|
42
|
+
target_device_id: data.targetDeviceId,
|
|
43
|
+
value: data.value,
|
|
44
|
+
data_source: data.dataSource,
|
|
45
|
+
data_source_id: data.dataSourceId,
|
|
46
|
+
data_source_type: data.dataSourceType,
|
|
47
|
+
data_source_alias: data.dataSourceAlias,
|
|
48
|
+
notification_content: data.notificationContent,
|
|
49
|
+
notification_url: data.notificationUrl,
|
|
50
|
+
expires_at: data.expiresAt,
|
|
51
|
+
rag_sources: data.ragSources,
|
|
52
|
+
idempotency_key: data.idempotencyKey,
|
|
53
|
+
payload: data.payload
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
return decodeOne(response, draftMessageMapper);
|
|
58
|
+
},
|
|
59
|
+
async update (uniqueId, data) {
|
|
60
|
+
const response = await transport.put(`/draft_messages/${uniqueId}`, {
|
|
61
|
+
data: {
|
|
62
|
+
type: 'DraftMessage',
|
|
63
|
+
attributes: {
|
|
64
|
+
content: data.content,
|
|
65
|
+
status: data.status,
|
|
66
|
+
enabled: data.enabled,
|
|
67
|
+
payload: data.payload
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
return decodeOne(response, draftMessageMapper);
|
|
72
|
+
},
|
|
73
|
+
async delete (uniqueId) {
|
|
74
|
+
await transport.delete(`/draft_messages/${uniqueId}`);
|
|
75
|
+
},
|
|
76
|
+
async listByContext (contextId, params) {
|
|
77
|
+
const queryParams = {};
|
|
78
|
+
if (params == null ? void 0 : params.page) queryParams['page'] = String(params.page);
|
|
79
|
+
if (params == null ? void 0 : params.perPage) queryParams['records'] = String(params.perPage);
|
|
80
|
+
if (params == null ? void 0 : params.status) queryParams['status'] = params.status;
|
|
81
|
+
if (params == null ? void 0 : params.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;
|
|
82
|
+
const response = await transport.get(`/draft_messages/context/${contextId}`, {
|
|
83
|
+
params: queryParams
|
|
84
|
+
});
|
|
85
|
+
return decodePageResult(response, draftMessageMapper);
|
|
86
|
+
},
|
|
87
|
+
async publish (uniqueId) {
|
|
88
|
+
const response = await transport.put(`/draft_messages/${uniqueId}/publish`, {});
|
|
89
|
+
return decodeOne(response, draftMessageMapper);
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
//# sourceMappingURL=draft-messages.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/services/draft-messages.service.ts"],"sourcesContent":["import type { Transport, PageResult } from '@23blocks/contracts';\nimport { decodeOne, decodeMany, decodePageResult } from '@23blocks/jsonapi-codec';\nimport type {\n DraftMessage,\n CreateDraftMessageRequest,\n UpdateDraftMessageRequest,\n ListDraftMessagesParams,\n} from '../types/draft-message';\nimport { draftMessageMapper } from '../mappers/draft-message.mapper';\n\nexport interface DraftMessagesService {\n list(params?: ListDraftMessagesParams): Promise<PageResult<DraftMessage>>;\n get(uniqueId: string): Promise<DraftMessage>;\n create(data: CreateDraftMessageRequest): Promise<DraftMessage>;\n update(uniqueId: string, data: UpdateDraftMessageRequest): Promise<DraftMessage>;\n delete(uniqueId: string): Promise<void>;\n listByContext(contextId: string, params?: ListDraftMessagesParams): Promise<PageResult<DraftMessage>>;\n publish(uniqueId: string): Promise<DraftMessage>;\n}\n\nexport function createDraftMessagesService(transport: Transport, _config: { appId: string }): DraftMessagesService {\n return {\n async list(params?: ListDraftMessagesParams): Promise<PageResult<DraftMessage>> {\n const queryParams: Record<string, string> = {};\n if (params?.page) queryParams['page'] = String(params.page);\n if (params?.perPage) queryParams['records'] = String(params.perPage);\n if (params?.status) queryParams['status'] = params.status;\n if (params?.contextId) queryParams['context_id'] = params.contextId;\n if (params?.sourceId) queryParams['source_id'] = params.sourceId;\n if (params?.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;\n\n const response = await transport.get<unknown>('/draft_messages', { params: queryParams });\n return decodePageResult(response, draftMessageMapper);\n },\n\n async get(uniqueId: string): Promise<DraftMessage> {\n const response = await transport.get<unknown>(`/draft_messages/${uniqueId}`);\n return decodeOne(response, draftMessageMapper);\n },\n\n async create(data: CreateDraftMessageRequest): Promise<DraftMessage> {\n const response = await transport.post<unknown>('/draft_messages', {\n data: {\n type: 'DraftMessage',\n attributes: {\n context_id: data.contextId,\n parent_id: data.parentId,\n content: data.content,\n source: data.source,\n source_id: data.sourceId,\n source_alias: data.sourceAlias,\n source_email: data.sourceEmail,\n source_phone: data.sourcePhone,\n source_type: data.sourceType,\n target: data.target,\n target_id: data.targetId,\n target_alias: data.targetAlias,\n target_email: data.targetEmail,\n target_phone: data.targetPhone,\n target_type: data.targetType,\n target_device_id: data.targetDeviceId,\n value: data.value,\n data_source: data.dataSource,\n data_source_id: data.dataSourceId,\n data_source_type: data.dataSourceType,\n data_source_alias: data.dataSourceAlias,\n notification_content: data.notificationContent,\n notification_url: data.notificationUrl,\n expires_at: data.expiresAt,\n rag_sources: data.ragSources,\n idempotency_key: data.idempotencyKey,\n payload: data.payload,\n },\n },\n });\n return decodeOne(response, draftMessageMapper);\n },\n\n async update(uniqueId: string, data: UpdateDraftMessageRequest): Promise<DraftMessage> {\n const response = await transport.put<unknown>(`/draft_messages/${uniqueId}`, {\n data: {\n type: 'DraftMessage',\n attributes: {\n content: data.content,\n status: data.status,\n enabled: data.enabled,\n payload: data.payload,\n },\n },\n });\n return decodeOne(response, draftMessageMapper);\n },\n\n async delete(uniqueId: string): Promise<void> {\n await transport.delete(`/draft_messages/${uniqueId}`);\n },\n\n async listByContext(contextId: string, params?: ListDraftMessagesParams): Promise<PageResult<DraftMessage>> {\n const queryParams: Record<string, string> = {};\n if (params?.page) queryParams['page'] = String(params.page);\n if (params?.perPage) queryParams['records'] = String(params.perPage);\n if (params?.status) queryParams['status'] = params.status;\n if (params?.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;\n\n const response = await transport.get<unknown>(`/draft_messages/context/${contextId}`, { params: queryParams });\n return decodePageResult(response, draftMessageMapper);\n },\n\n async publish(uniqueId: string): Promise<DraftMessage> {\n const response = await transport.put<unknown>(`/draft_messages/${uniqueId}/publish`, {});\n return decodeOne(response, draftMessageMapper);\n },\n };\n}\n"],"names":["decodeOne","decodePageResult","draftMessageMapper","createDraftMessagesService","transport","_config","list","params","queryParams","page","String","perPage","status","contextId","sourceId","sortBy","sortOrder","response","get","uniqueId","create","data","post","type","attributes","context_id","parent_id","parentId","content","source","source_id","source_alias","sourceAlias","source_email","sourceEmail","source_phone","sourcePhone","source_type","sourceType","target","target_id","targetId","target_alias","targetAlias","target_email","targetEmail","target_phone","targetPhone","target_type","targetType","target_device_id","targetDeviceId","value","data_source","dataSource","data_source_id","dataSourceId","data_source_type","dataSourceType","data_source_alias","dataSourceAlias","notification_content","notificationContent","notification_url","notificationUrl","expires_at","expiresAt","rag_sources","ragSources","idempotency_key","idempotencyKey","payload","update","put","enabled","delete","listByContext","publish"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AACA,SAASA,SAAS,EAAcC,gBAAgB,QAAQ,0BAA0B;AAOlF,SAASC,kBAAkB,QAAQ,kCAAkC;AAYrE,OAAO,SAASC,2BAA2BC,SAAoB,EAAEC,OAA0B;IACzF,OAAO;QACL,MAAMC,MAAKC,MAAgC;YACzC,MAAMC,cAAsC,CAAC;YAC7C,IAAID,0BAAAA,OAAQE,IAAI,EAAED,WAAW,CAAC,OAAO,GAAGE,OAAOH,OAAOE,IAAI;YAC1D,IAAIF,0BAAAA,OAAQI,OAAO,EAAEH,WAAW,CAAC,UAAU,GAAGE,OAAOH,OAAOI,OAAO;YACnE,IAAIJ,0BAAAA,OAAQK,MAAM,EAAEJ,WAAW,CAAC,SAAS,GAAGD,OAAOK,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,CAAC,OAAO,GAAGD,OAAOS,SAAS,KAAK,SAAS,CAAC,CAAC,EAAET,OAAOQ,MAAM,CAAC,CAAC,GAAGR,OAAOQ,MAAM;YAE3G,MAAME,WAAW,MAAMb,UAAUc,GAAG,CAAU,CAAC,wBAAwB,EAAEL,UAAU,CAAC,EAAE;gBAAEN,QAAQC;YAAY;YAC5G,OAAOP,iBAAiBgB,UAAUf;QACpC;QAEA,MAAM2E,SAAQ1D,QAAgB;YAC5B,MAAMF,WAAW,MAAMb,UAAUqE,GAAG,CAAU,CAAC,gBAAgB,EAAEtD,SAAS,QAAQ,CAAC,EAAE,CAAC;YACtF,OAAOnB,UAAUiB,UAAUf;QAC7B;IACF;AACF"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { decodeOne, decodePageResult } from '@23blocks/jsonapi-codec';
|
|
2
|
+
import { groupMapper } from '../mappers/group.mapper';
|
|
3
|
+
export function createGroupsService(transport, _config) {
|
|
4
|
+
return {
|
|
5
|
+
async list (params) {
|
|
6
|
+
const queryParams = {};
|
|
7
|
+
if (params == null ? void 0 : params.page) queryParams['page'] = String(params.page);
|
|
8
|
+
if (params == null ? void 0 : params.perPage) queryParams['records'] = String(params.perPage);
|
|
9
|
+
if (params == null ? void 0 : params.status) queryParams['status'] = params.status;
|
|
10
|
+
if (params == null ? void 0 : params.groupType) queryParams['group_type'] = params.groupType;
|
|
11
|
+
if (params == null ? void 0 : params.search) queryParams['search'] = params.search;
|
|
12
|
+
if (params == null ? void 0 : params.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;
|
|
13
|
+
const response = await transport.get('/groups', {
|
|
14
|
+
params: queryParams
|
|
15
|
+
});
|
|
16
|
+
return decodePageResult(response, groupMapper);
|
|
17
|
+
},
|
|
18
|
+
async get (uniqueId) {
|
|
19
|
+
const response = await transport.get(`/groups/${uniqueId}`);
|
|
20
|
+
return decodeOne(response, groupMapper);
|
|
21
|
+
},
|
|
22
|
+
async create (data) {
|
|
23
|
+
const response = await transport.post('/groups', {
|
|
24
|
+
data: {
|
|
25
|
+
type: 'Group',
|
|
26
|
+
attributes: {
|
|
27
|
+
name: data.name,
|
|
28
|
+
code: data.code,
|
|
29
|
+
unique_code: data.uniqueCode,
|
|
30
|
+
qcode: data.qcode,
|
|
31
|
+
group_type: data.groupType,
|
|
32
|
+
members: data.members,
|
|
33
|
+
source: data.source,
|
|
34
|
+
source_alias: data.sourceAlias,
|
|
35
|
+
source_id: data.sourceId,
|
|
36
|
+
source_type: data.sourceType,
|
|
37
|
+
payload: data.payload
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
return decodeOne(response, groupMapper);
|
|
42
|
+
},
|
|
43
|
+
async update (uniqueId, data) {
|
|
44
|
+
const response = await transport.put(`/groups/${uniqueId}`, {
|
|
45
|
+
data: {
|
|
46
|
+
type: 'Group',
|
|
47
|
+
attributes: {
|
|
48
|
+
name: data.name,
|
|
49
|
+
code: data.code,
|
|
50
|
+
unique_code: data.uniqueCode,
|
|
51
|
+
qcode: data.qcode,
|
|
52
|
+
group_type: data.groupType,
|
|
53
|
+
members: data.members,
|
|
54
|
+
status: data.status,
|
|
55
|
+
enabled: data.enabled,
|
|
56
|
+
payload: data.payload
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
return decodeOne(response, groupMapper);
|
|
61
|
+
},
|
|
62
|
+
async delete (uniqueId) {
|
|
63
|
+
await transport.delete(`/groups/${uniqueId}`);
|
|
64
|
+
},
|
|
65
|
+
async recover (uniqueId) {
|
|
66
|
+
const response = await transport.put(`/groups/${uniqueId}/recover`, {});
|
|
67
|
+
return decodeOne(response, groupMapper);
|
|
68
|
+
},
|
|
69
|
+
async search (query, params) {
|
|
70
|
+
const queryParams = {
|
|
71
|
+
search: query
|
|
72
|
+
};
|
|
73
|
+
if (params == null ? void 0 : params.page) queryParams['page'] = String(params.page);
|
|
74
|
+
if (params == null ? void 0 : params.perPage) queryParams['records'] = String(params.perPage);
|
|
75
|
+
const response = await transport.post('/groups/search', {
|
|
76
|
+
search: query
|
|
77
|
+
}, {
|
|
78
|
+
params: queryParams
|
|
79
|
+
});
|
|
80
|
+
return decodePageResult(response, groupMapper);
|
|
81
|
+
},
|
|
82
|
+
async listDeleted (params) {
|
|
83
|
+
const queryParams = {};
|
|
84
|
+
if (params == null ? void 0 : params.page) queryParams['page'] = String(params.page);
|
|
85
|
+
if (params == null ? void 0 : params.perPage) queryParams['records'] = String(params.perPage);
|
|
86
|
+
const response = await transport.get('/groups/trash/show', {
|
|
87
|
+
params: queryParams
|
|
88
|
+
});
|
|
89
|
+
return decodePageResult(response, groupMapper);
|
|
90
|
+
},
|
|
91
|
+
async addMember (uniqueId, memberId) {
|
|
92
|
+
const response = await transport.post(`/groups/${uniqueId}/members`, {
|
|
93
|
+
data: {
|
|
94
|
+
type: 'GroupMember',
|
|
95
|
+
attributes: {
|
|
96
|
+
member_id: memberId
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
return decodeOne(response, groupMapper);
|
|
101
|
+
},
|
|
102
|
+
async removeMember (uniqueId, memberId) {
|
|
103
|
+
const response = await transport.delete(`/groups/${uniqueId}/members/${memberId}`);
|
|
104
|
+
return decodeOne(response, groupMapper);
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
//# sourceMappingURL=groups.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/services/groups.service.ts"],"sourcesContent":["import type { Transport, PageResult } from '@23blocks/contracts';\nimport { decodeOne, decodeMany, decodePageResult } from '@23blocks/jsonapi-codec';\nimport type {\n Group,\n CreateGroupRequest,\n UpdateGroupRequest,\n ListGroupsParams,\n} from '../types/group';\nimport { groupMapper } from '../mappers/group.mapper';\n\nexport interface GroupsService {\n list(params?: ListGroupsParams): Promise<PageResult<Group>>;\n get(uniqueId: string): Promise<Group>;\n create(data: CreateGroupRequest): Promise<Group>;\n update(uniqueId: string, data: UpdateGroupRequest): Promise<Group>;\n delete(uniqueId: string): Promise<void>;\n recover(uniqueId: string): Promise<Group>;\n search(query: string, params?: ListGroupsParams): Promise<PageResult<Group>>;\n listDeleted(params?: ListGroupsParams): Promise<PageResult<Group>>;\n addMember(uniqueId: string, memberId: string): Promise<Group>;\n removeMember(uniqueId: string, memberId: string): Promise<Group>;\n}\n\nexport function createGroupsService(transport: Transport, _config: { appId: string }): GroupsService {\n return {\n async list(params?: ListGroupsParams): Promise<PageResult<Group>> {\n const queryParams: Record<string, string> = {};\n if (params?.page) queryParams['page'] = String(params.page);\n if (params?.perPage) queryParams['records'] = String(params.perPage);\n if (params?.status) queryParams['status'] = params.status;\n if (params?.groupType) queryParams['group_type'] = params.groupType;\n if (params?.search) queryParams['search'] = params.search;\n if (params?.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;\n\n const response = await transport.get<unknown>('/groups', { params: queryParams });\n return decodePageResult(response, groupMapper);\n },\n\n async get(uniqueId: string): Promise<Group> {\n const response = await transport.get<unknown>(`/groups/${uniqueId}`);\n return decodeOne(response, groupMapper);\n },\n\n async create(data: CreateGroupRequest): Promise<Group> {\n const response = await transport.post<unknown>('/groups', {\n data: {\n type: 'Group',\n attributes: {\n name: data.name,\n code: data.code,\n unique_code: data.uniqueCode,\n qcode: data.qcode,\n group_type: data.groupType,\n members: data.members,\n source: data.source,\n source_alias: data.sourceAlias,\n source_id: data.sourceId,\n source_type: data.sourceType,\n payload: data.payload,\n },\n },\n });\n return decodeOne(response, groupMapper);\n },\n\n async update(uniqueId: string, data: UpdateGroupRequest): Promise<Group> {\n const response = await transport.put<unknown>(`/groups/${uniqueId}`, {\n data: {\n type: 'Group',\n attributes: {\n name: data.name,\n code: data.code,\n unique_code: data.uniqueCode,\n qcode: data.qcode,\n group_type: data.groupType,\n members: data.members,\n status: data.status,\n enabled: data.enabled,\n payload: data.payload,\n },\n },\n });\n return decodeOne(response, groupMapper);\n },\n\n async delete(uniqueId: string): Promise<void> {\n await transport.delete(`/groups/${uniqueId}`);\n },\n\n async recover(uniqueId: string): Promise<Group> {\n const response = await transport.put<unknown>(`/groups/${uniqueId}/recover`, {});\n return decodeOne(response, groupMapper);\n },\n\n async search(query: string, params?: ListGroupsParams): Promise<PageResult<Group>> {\n const queryParams: Record<string, string> = { search: query };\n if (params?.page) queryParams['page'] = String(params.page);\n if (params?.perPage) queryParams['records'] = String(params.perPage);\n\n const response = await transport.post<unknown>('/groups/search', { search: query }, { params: queryParams });\n return decodePageResult(response, groupMapper);\n },\n\n async listDeleted(params?: ListGroupsParams): Promise<PageResult<Group>> {\n const queryParams: Record<string, string> = {};\n if (params?.page) queryParams['page'] = String(params.page);\n if (params?.perPage) queryParams['records'] = String(params.perPage);\n\n const response = await transport.get<unknown>('/groups/trash/show', { params: queryParams });\n return decodePageResult(response, groupMapper);\n },\n\n async addMember(uniqueId: string, memberId: string): Promise<Group> {\n const response = await transport.post<unknown>(`/groups/${uniqueId}/members`, {\n data: {\n type: 'GroupMember',\n attributes: {\n member_id: memberId,\n },\n },\n });\n return decodeOne(response, groupMapper);\n },\n\n async removeMember(uniqueId: string, memberId: string): Promise<Group> {\n const response = await transport.delete<unknown>(`/groups/${uniqueId}/members/${memberId}`);\n return decodeOne(response, groupMapper);\n },\n };\n}\n"],"names":["decodeOne","decodePageResult","groupMapper","createGroupsService","transport","_config","list","params","queryParams","page","String","perPage","status","groupType","search","sortBy","sortOrder","response","get","uniqueId","create","data","post","type","attributes","name","code","unique_code","uniqueCode","qcode","group_type","members","source","source_alias","sourceAlias","source_id","sourceId","source_type","sourceType","payload","update","put","enabled","delete","recover","query","listDeleted","addMember","memberId","member_id","removeMember"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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O,GAAGE,OAAOH,OAAOE,IAAI;YAC1D,IAAIF,0BAAAA,OAAQI,OAAO,EAAEH,WAAW,CAAC,UAAU,GAAGE,OAAOH,OAAOI,OAAO;YAEnE,MAAMM,WAAW,MAAMb,UAAUkB,IAAI,CAAU,kBAAkB;gBAAER,QAAQ+B;YAAM,GAAG;gBAAEtC,QAAQC;YAAY;YAC1G,OAAOP,iBAAiBgB,UAAUf;QACpC;QAEA,MAAM4C,aAAYvC,MAAyB;YACzC,MAAMC,cAAsC,CAAC;YAC7C,IAAID,0BAAAA,OAAQE,IAAI,EAAED,WAAW,CAAC,OAAO,GAAGE,OAAOH,OAAOE,IAAI;YAC1D,IAAIF,0BAAAA,OAAQI,OAAO,EAAEH,WAAW,CAAC,UAAU,GAAGE,OAAOH,OAAOI,OAAO;YAEnE,MAAMM,WAAW,MAAMb,UAAUc,GAAG,CAAU,sBAAsB;gBAAEX,QAAQC;YAAY;YAC1F,OAAOP,iBAAiBgB,UAAUf;QACpC;QAEA,MAAM6C,WAAU5B,QAAgB,EAAE6B,QAAgB;YAChD,MAAM/B,WAAW,MAAMb,UAAUkB,IAAI,CAAU,CAAC,QAAQ,EAAEH,SAAS,QAAQ,CAAC,EAAE;gBAC5EE,MAAM;oBACJE,MAAM;oBACNC,YAAY;wBACVyB,WAAWD;oBACb;gBACF;YACF;YACA,OAAOhD,UAAUiB,UAAUf;QAC7B;QAEA,MAAMgD,cAAa/B,QAAgB,EAAE6B,QAAgB;YACnD,MAAM/B,WAAW,MAAMb,UAAUuC,MAAM,CAAU,CAAC,QAAQ,EAAExB,SAAS,SAAS,EAAE6B,SAAS,CAAC;YAC1F,OAAOhD,UAAUiB,UAAUf;QAC7B;IACF;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/services/index.ts"],"sourcesContent":["export * from './messages.service';\nexport * from './draft-messages.service';\nexport * from './groups.service';\nexport * from './notifications.service';\nexport * from './conversations.service';\n"],"names":[],"rangeMappings":";;;;","mappings":"AAAA,cAAc,qBAAqB;AACnC,cAAc,2BAA2B;AACzC,cAAc,mBAAmB;AACjC,cAAc,0BAA0B;AACxC,cAAc,0BAA0B"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { decodeOne, decodePageResult } from '@23blocks/jsonapi-codec';
|
|
2
|
+
import { messageMapper } from '../mappers/message.mapper';
|
|
3
|
+
export function createMessagesService(transport, _config) {
|
|
4
|
+
return {
|
|
5
|
+
async list (params) {
|
|
6
|
+
const queryParams = {};
|
|
7
|
+
if (params == null ? void 0 : params.page) queryParams['page'] = String(params.page);
|
|
8
|
+
if (params == null ? void 0 : params.perPage) queryParams['records'] = String(params.perPage);
|
|
9
|
+
if (params == null ? void 0 : params.status) queryParams['status'] = params.status;
|
|
10
|
+
if (params == null ? void 0 : params.contextId) queryParams['context_id'] = params.contextId;
|
|
11
|
+
if (params == null ? void 0 : params.parentId) queryParams['parent_id'] = params.parentId;
|
|
12
|
+
if (params == null ? void 0 : params.sourceId) queryParams['source_id'] = params.sourceId;
|
|
13
|
+
if (params == null ? void 0 : params.targetId) queryParams['target_id'] = params.targetId;
|
|
14
|
+
if (params == null ? void 0 : params.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;
|
|
15
|
+
const response = await transport.get('/messages', {
|
|
16
|
+
params: queryParams
|
|
17
|
+
});
|
|
18
|
+
return decodePageResult(response, messageMapper);
|
|
19
|
+
},
|
|
20
|
+
async get (uniqueId) {
|
|
21
|
+
const response = await transport.get(`/messages/${uniqueId}`);
|
|
22
|
+
return decodeOne(response, messageMapper);
|
|
23
|
+
},
|
|
24
|
+
async create (data) {
|
|
25
|
+
const response = await transport.post('/messages', {
|
|
26
|
+
data: {
|
|
27
|
+
type: 'Message',
|
|
28
|
+
attributes: {
|
|
29
|
+
context_id: data.contextId,
|
|
30
|
+
parent_id: data.parentId,
|
|
31
|
+
content: data.content,
|
|
32
|
+
source: data.source,
|
|
33
|
+
source_id: data.sourceId,
|
|
34
|
+
source_alias: data.sourceAlias,
|
|
35
|
+
source_email: data.sourceEmail,
|
|
36
|
+
source_phone: data.sourcePhone,
|
|
37
|
+
source_type: data.sourceType,
|
|
38
|
+
target: data.target,
|
|
39
|
+
target_id: data.targetId,
|
|
40
|
+
target_alias: data.targetAlias,
|
|
41
|
+
target_email: data.targetEmail,
|
|
42
|
+
target_phone: data.targetPhone,
|
|
43
|
+
target_type: data.targetType,
|
|
44
|
+
target_device_id: data.targetDeviceId,
|
|
45
|
+
value: data.value,
|
|
46
|
+
data_source: data.dataSource,
|
|
47
|
+
data_source_id: data.dataSourceId,
|
|
48
|
+
data_source_type: data.dataSourceType,
|
|
49
|
+
data_source_alias: data.dataSourceAlias,
|
|
50
|
+
notification_content: data.notificationContent,
|
|
51
|
+
notification_url: data.notificationUrl,
|
|
52
|
+
expires_at: data.expiresAt,
|
|
53
|
+
rag_sources: data.ragSources,
|
|
54
|
+
idempotency_key: data.idempotencyKey,
|
|
55
|
+
payload: data.payload
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
return decodeOne(response, messageMapper);
|
|
60
|
+
},
|
|
61
|
+
async update (uniqueId, data) {
|
|
62
|
+
const response = await transport.put(`/messages/${uniqueId}`, {
|
|
63
|
+
data: {
|
|
64
|
+
type: 'Message',
|
|
65
|
+
attributes: {
|
|
66
|
+
content: data.content,
|
|
67
|
+
status: data.status,
|
|
68
|
+
enabled: data.enabled,
|
|
69
|
+
payload: data.payload
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
return decodeOne(response, messageMapper);
|
|
74
|
+
},
|
|
75
|
+
async delete (uniqueId) {
|
|
76
|
+
await transport.delete(`/messages/${uniqueId}`);
|
|
77
|
+
},
|
|
78
|
+
async recover (uniqueId) {
|
|
79
|
+
const response = await transport.put(`/messages/${uniqueId}/recover`, {});
|
|
80
|
+
return decodeOne(response, messageMapper);
|
|
81
|
+
},
|
|
82
|
+
async listByContext (contextId, params) {
|
|
83
|
+
const queryParams = {};
|
|
84
|
+
if (params == null ? void 0 : params.page) queryParams['page'] = String(params.page);
|
|
85
|
+
if (params == null ? void 0 : params.perPage) queryParams['records'] = String(params.perPage);
|
|
86
|
+
if (params == null ? void 0 : params.status) queryParams['status'] = params.status;
|
|
87
|
+
if (params == null ? void 0 : params.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;
|
|
88
|
+
const response = await transport.get(`/messages/context/${contextId}`, {
|
|
89
|
+
params: queryParams
|
|
90
|
+
});
|
|
91
|
+
return decodePageResult(response, messageMapper);
|
|
92
|
+
},
|
|
93
|
+
async listByParent (parentId, params) {
|
|
94
|
+
const queryParams = {};
|
|
95
|
+
if (params == null ? void 0 : params.page) queryParams['page'] = String(params.page);
|
|
96
|
+
if (params == null ? void 0 : params.perPage) queryParams['records'] = String(params.perPage);
|
|
97
|
+
if (params == null ? void 0 : params.status) queryParams['status'] = params.status;
|
|
98
|
+
if (params == null ? void 0 : params.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;
|
|
99
|
+
const response = await transport.get(`/messages/parent/${parentId}`, {
|
|
100
|
+
params: queryParams
|
|
101
|
+
});
|
|
102
|
+
return decodePageResult(response, messageMapper);
|
|
103
|
+
},
|
|
104
|
+
async listDeleted (params) {
|
|
105
|
+
const queryParams = {};
|
|
106
|
+
if (params == null ? void 0 : params.page) queryParams['page'] = String(params.page);
|
|
107
|
+
if (params == null ? void 0 : params.perPage) queryParams['records'] = String(params.perPage);
|
|
108
|
+
const response = await transport.get('/messages/trash/show', {
|
|
109
|
+
params: queryParams
|
|
110
|
+
});
|
|
111
|
+
return decodePageResult(response, messageMapper);
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
//# sourceMappingURL=messages.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/services/messages.service.ts"],"sourcesContent":["import type { Transport, PageResult } from '@23blocks/contracts';\nimport { decodeOne, decodeMany, decodePageResult } from '@23blocks/jsonapi-codec';\nimport type {\n Message,\n CreateMessageRequest,\n UpdateMessageRequest,\n ListMessagesParams,\n} from '../types/message';\nimport { messageMapper } from '../mappers/message.mapper';\n\nexport interface MessagesService {\n list(params?: ListMessagesParams): Promise<PageResult<Message>>;\n get(uniqueId: string): Promise<Message>;\n create(data: CreateMessageRequest): Promise<Message>;\n update(uniqueId: string, data: UpdateMessageRequest): Promise<Message>;\n delete(uniqueId: string): Promise<void>;\n recover(uniqueId: string): Promise<Message>;\n listByContext(contextId: string, params?: ListMessagesParams): Promise<PageResult<Message>>;\n listByParent(parentId: string, params?: ListMessagesParams): Promise<PageResult<Message>>;\n listDeleted(params?: ListMessagesParams): Promise<PageResult<Message>>;\n}\n\nexport function createMessagesService(transport: Transport, _config: { appId: string }): MessagesService {\n return {\n async list(params?: ListMessagesParams): Promise<PageResult<Message>> {\n const queryParams: Record<string, string> = {};\n if (params?.page) queryParams['page'] = String(params.page);\n if (params?.perPage) queryParams['records'] = String(params.perPage);\n if (params?.status) queryParams['status'] = params.status;\n if (params?.contextId) queryParams['context_id'] = params.contextId;\n if (params?.parentId) queryParams['parent_id'] = params.parentId;\n if (params?.sourceId) queryParams['source_id'] = params.sourceId;\n if (params?.targetId) queryParams['target_id'] = params.targetId;\n if (params?.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;\n\n const response = await transport.get<unknown>('/messages', { params: queryParams });\n return decodePageResult(response, messageMapper);\n },\n\n async get(uniqueId: string): Promise<Message> {\n const response = await transport.get<unknown>(`/messages/${uniqueId}`);\n return decodeOne(response, messageMapper);\n },\n\n async create(data: CreateMessageRequest): Promise<Message> {\n const response = await transport.post<unknown>('/messages', {\n data: {\n type: 'Message',\n attributes: {\n context_id: data.contextId,\n parent_id: data.parentId,\n content: data.content,\n source: data.source,\n source_id: data.sourceId,\n source_alias: data.sourceAlias,\n source_email: data.sourceEmail,\n source_phone: data.sourcePhone,\n source_type: data.sourceType,\n target: data.target,\n target_id: data.targetId,\n target_alias: data.targetAlias,\n target_email: data.targetEmail,\n target_phone: data.targetPhone,\n target_type: data.targetType,\n target_device_id: data.targetDeviceId,\n value: data.value,\n data_source: data.dataSource,\n data_source_id: data.dataSourceId,\n data_source_type: data.dataSourceType,\n data_source_alias: data.dataSourceAlias,\n notification_content: data.notificationContent,\n notification_url: data.notificationUrl,\n expires_at: data.expiresAt,\n rag_sources: data.ragSources,\n idempotency_key: data.idempotencyKey,\n payload: data.payload,\n },\n },\n });\n return decodeOne(response, messageMapper);\n },\n\n async update(uniqueId: string, data: UpdateMessageRequest): Promise<Message> {\n const response = await transport.put<unknown>(`/messages/${uniqueId}`, {\n data: {\n type: 'Message',\n attributes: {\n content: data.content,\n status: data.status,\n enabled: data.enabled,\n payload: data.payload,\n },\n },\n });\n return decodeOne(response, messageMapper);\n },\n\n async delete(uniqueId: string): Promise<void> {\n await transport.delete(`/messages/${uniqueId}`);\n },\n\n async recover(uniqueId: string): Promise<Message> {\n const response = await transport.put<unknown>(`/messages/${uniqueId}/recover`, {});\n return decodeOne(response, messageMapper);\n },\n\n async listByContext(contextId: string, params?: ListMessagesParams): Promise<PageResult<Message>> {\n const queryParams: Record<string, string> = {};\n if (params?.page) queryParams['page'] = String(params.page);\n if (params?.perPage) queryParams['records'] = String(params.perPage);\n if (params?.status) queryParams['status'] = params.status;\n if (params?.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;\n\n const response = await transport.get<unknown>(`/messages/context/${contextId}`, { params: queryParams });\n return decodePageResult(response, messageMapper);\n },\n\n async listByParent(parentId: string, params?: ListMessagesParams): Promise<PageResult<Message>> {\n const queryParams: Record<string, string> = {};\n if (params?.page) queryParams['page'] = String(params.page);\n if (params?.perPage) queryParams['records'] = String(params.perPage);\n if (params?.status) queryParams['status'] = params.status;\n if (params?.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;\n\n const response = await transport.get<unknown>(`/messages/parent/${parentId}`, { params: queryParams });\n return decodePageResult(response, messageMapper);\n },\n\n async listDeleted(params?: ListMessagesParams): Promise<PageResult<Message>> {\n const queryParams: Record<string, string> = {};\n if (params?.page) queryParams['page'] = String(params.page);\n if (params?.perPage) queryParams['records'] = String(params.perPage);\n\n const response = await transport.get<unknown>('/messages/trash/show', { params: queryParams });\n return decodePageResult(response, messageMapper);\n },\n };\n}\n"],"names":["decodeOne","decodePageResult","messageMapper","createMessagesService","transport","_config","list","params","queryParams","page","String","perPage","status","contextId","parentId","sourceId","targetId","sortBy","sortOrder","response","get","uniqueId","create","data","post","type","attributes","context_id","parent_id","content","source","source_id","source_alias","sourceAlias","source_email","sourceEmail","source_phone","sourcePhone","source_type","sourceType","target","target_id","target_alias","targetAlias","target_email","targetEmail","target_phone","targetPhone","target_type","targetType","target_device_id","targetDeviceId","value","data_source","dataSource","data_source_id","dataSourceId","data_source_type","dataSourceType","data_source_alias","dataSourceAlias","notification_content","notificationContent","notification_url","notificationUrl","expires_at","expiresAt","rag_sources","ragSources","idempotency_key","idempotencyKey","payload","update","put","enabled","delete","recover","listByContext","listByParent","listDeleted"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AACA,SAASA,SAAS,EAAcC,gBAAgB,QAAQ,0BAA0B;AAOlF,SAASC,aAAa,QAAQ,4BAA4B;AAc1D,OAAO,SAASC,sBAAsBC,SAAoB,EAAEC,OAA0B;IACpF,OAAO;QACL,MAAMC,MAAKC,MAA2B;YACpC,MAAMC,cAAsC,CAAC;YAC7C,IAAID,0BAAAA,OAAQE,IAAI,EAAED,WAAW,CAAC,OAAO,GAAGE,OAAOH,OAAOE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MAAM;YAE3G,MAAME,WAAW,MAAMf,UAAUgB,GAAG,CAAU,CAAC,iBAAiB,EAAEN,SAAS,CAAC,EAAE;gBAAEP,QAAQC;YAAY;YACpG,OAAOP,iBAAiBkB,UAAUjB;QACpC;QAEA,MAAM6E,aAAYxE,MAA2B;YAC3C,MAAMC,cAAsC,CAAC;YAC7C,IAAID,0BAAAA,OAAQE,IAAI,EAAED,WAAW,CAAC,OAAO,GAAGE,OAAOH,OAAOE,IAAI;YAC1D,IAAIF,0BAAAA,OAAQI,OAAO,EAAEH,WAAW,CAAC,UAAU,GAAGE,OAAOH,OAAOI,OAAO;YAEnE,MAAMQ,WAAW,MAAMf,UAAUgB,GAAG,CAAU,wBAAwB;gBAAEb,QAAQC;YAAY;YAC5F,OAAOP,iBAAiBkB,UAAUjB;QACpC;IACF;AACF"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { decodeOne, decodePageResult } from '@23blocks/jsonapi-codec';
|
|
2
|
+
import { notificationMapper } from '../mappers/notification.mapper';
|
|
3
|
+
export function createNotificationsService(transport, _config) {
|
|
4
|
+
return {
|
|
5
|
+
async list (params) {
|
|
6
|
+
const queryParams = {};
|
|
7
|
+
if (params == null ? void 0 : params.page) queryParams['page'] = String(params.page);
|
|
8
|
+
if (params == null ? void 0 : params.perPage) queryParams['records'] = String(params.perPage);
|
|
9
|
+
if (params == null ? void 0 : params.status) queryParams['status'] = params.status;
|
|
10
|
+
if (params == null ? void 0 : params.targetId) queryParams['target_id'] = params.targetId;
|
|
11
|
+
if (params == null ? void 0 : params.sourceId) queryParams['source_id'] = params.sourceId;
|
|
12
|
+
if (params == null ? void 0 : params.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;
|
|
13
|
+
const response = await transport.get('/notifications', {
|
|
14
|
+
params: queryParams
|
|
15
|
+
});
|
|
16
|
+
return decodePageResult(response, notificationMapper);
|
|
17
|
+
},
|
|
18
|
+
async get (uniqueId) {
|
|
19
|
+
const response = await transport.get(`/notifications/${uniqueId}`);
|
|
20
|
+
return decodeOne(response, notificationMapper);
|
|
21
|
+
},
|
|
22
|
+
async create (data) {
|
|
23
|
+
const response = await transport.post('/notifications', {
|
|
24
|
+
data: {
|
|
25
|
+
type: 'Notification',
|
|
26
|
+
attributes: {
|
|
27
|
+
content: data.content,
|
|
28
|
+
source: data.source,
|
|
29
|
+
source_alias: data.sourceAlias,
|
|
30
|
+
source_id: data.sourceId,
|
|
31
|
+
source_type: data.sourceType,
|
|
32
|
+
url: data.url,
|
|
33
|
+
target: data.target,
|
|
34
|
+
target_id: data.targetId,
|
|
35
|
+
target_alias: data.targetAlias,
|
|
36
|
+
target_type: data.targetType,
|
|
37
|
+
target_email: data.targetEmail,
|
|
38
|
+
target_phone: data.targetPhone,
|
|
39
|
+
target_device_id: data.targetDeviceId,
|
|
40
|
+
multichannel: data.multichannel,
|
|
41
|
+
expires_at: data.expiresAt,
|
|
42
|
+
payload: data.payload
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
return decodeOne(response, notificationMapper);
|
|
47
|
+
},
|
|
48
|
+
async update (uniqueId, data) {
|
|
49
|
+
const response = await transport.put(`/notifications/${uniqueId}`, {
|
|
50
|
+
data: {
|
|
51
|
+
type: 'Notification',
|
|
52
|
+
attributes: {
|
|
53
|
+
content: data.content,
|
|
54
|
+
url: data.url,
|
|
55
|
+
status: data.status,
|
|
56
|
+
payload: data.payload
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
return decodeOne(response, notificationMapper);
|
|
61
|
+
},
|
|
62
|
+
async delete (uniqueId) {
|
|
63
|
+
await transport.delete(`/notifications/${uniqueId}`);
|
|
64
|
+
},
|
|
65
|
+
async markAsRead (uniqueId) {
|
|
66
|
+
const response = await transport.put(`/notifications/${uniqueId}/read`, {});
|
|
67
|
+
return decodeOne(response, notificationMapper);
|
|
68
|
+
},
|
|
69
|
+
async markAsUnread (uniqueId) {
|
|
70
|
+
const response = await transport.put(`/notifications/${uniqueId}/unread`, {});
|
|
71
|
+
return decodeOne(response, notificationMapper);
|
|
72
|
+
},
|
|
73
|
+
async listByTarget (targetId, params) {
|
|
74
|
+
const queryParams = {};
|
|
75
|
+
if (params == null ? void 0 : params.page) queryParams['page'] = String(params.page);
|
|
76
|
+
if (params == null ? void 0 : params.perPage) queryParams['records'] = String(params.perPage);
|
|
77
|
+
if (params == null ? void 0 : params.status) queryParams['status'] = params.status;
|
|
78
|
+
if (params == null ? void 0 : params.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;
|
|
79
|
+
const response = await transport.get(`/notifications/target/${targetId}`, {
|
|
80
|
+
params: queryParams
|
|
81
|
+
});
|
|
82
|
+
return decodePageResult(response, notificationMapper);
|
|
83
|
+
},
|
|
84
|
+
async listUnread (params) {
|
|
85
|
+
const queryParams = {
|
|
86
|
+
status: 'pending'
|
|
87
|
+
};
|
|
88
|
+
if (params == null ? void 0 : params.page) queryParams['page'] = String(params.page);
|
|
89
|
+
if (params == null ? void 0 : params.perPage) queryParams['records'] = String(params.perPage);
|
|
90
|
+
if (params == null ? void 0 : params.targetId) queryParams['target_id'] = params.targetId;
|
|
91
|
+
if (params == null ? void 0 : params.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;
|
|
92
|
+
const response = await transport.get('/notifications/unread', {
|
|
93
|
+
params: queryParams
|
|
94
|
+
});
|
|
95
|
+
return decodePageResult(response, notificationMapper);
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
//# sourceMappingURL=notifications.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/services/notifications.service.ts"],"sourcesContent":["import type { Transport, PageResult } from '@23blocks/contracts';\nimport { decodeOne, decodeMany, decodePageResult } from '@23blocks/jsonapi-codec';\nimport type {\n Notification,\n CreateNotificationRequest,\n UpdateNotificationRequest,\n ListNotificationsParams,\n} from '../types/notification';\nimport { notificationMapper } from '../mappers/notification.mapper';\n\nexport interface NotificationsService {\n list(params?: ListNotificationsParams): Promise<PageResult<Notification>>;\n get(uniqueId: string): Promise<Notification>;\n create(data: CreateNotificationRequest): Promise<Notification>;\n update(uniqueId: string, data: UpdateNotificationRequest): Promise<Notification>;\n delete(uniqueId: string): Promise<void>;\n markAsRead(uniqueId: string): Promise<Notification>;\n markAsUnread(uniqueId: string): Promise<Notification>;\n listByTarget(targetId: string, params?: ListNotificationsParams): Promise<PageResult<Notification>>;\n listUnread(params?: ListNotificationsParams): Promise<PageResult<Notification>>;\n}\n\nexport function createNotificationsService(transport: Transport, _config: { appId: string }): NotificationsService {\n return {\n async list(params?: ListNotificationsParams): Promise<PageResult<Notification>> {\n const queryParams: Record<string, string> = {};\n if (params?.page) queryParams['page'] = String(params.page);\n if (params?.perPage) queryParams['records'] = String(params.perPage);\n if (params?.status) queryParams['status'] = params.status;\n if (params?.targetId) queryParams['target_id'] = params.targetId;\n if (params?.sourceId) queryParams['source_id'] = params.sourceId;\n if (params?.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;\n\n const response = await transport.get<unknown>('/notifications', { params: queryParams });\n return decodePageResult(response, notificationMapper);\n },\n\n async get(uniqueId: string): Promise<Notification> {\n const response = await transport.get<unknown>(`/notifications/${uniqueId}`);\n return decodeOne(response, notificationMapper);\n },\n\n async create(data: CreateNotificationRequest): Promise<Notification> {\n const response = await transport.post<unknown>('/notifications', {\n data: {\n type: 'Notification',\n attributes: {\n content: data.content,\n source: data.source,\n source_alias: data.sourceAlias,\n source_id: data.sourceId,\n source_type: data.sourceType,\n url: data.url,\n target: data.target,\n target_id: data.targetId,\n target_alias: data.targetAlias,\n target_type: data.targetType,\n target_email: data.targetEmail,\n target_phone: data.targetPhone,\n target_device_id: data.targetDeviceId,\n multichannel: data.multichannel,\n expires_at: data.expiresAt,\n payload: data.payload,\n },\n },\n });\n return decodeOne(response, notificationMapper);\n },\n\n async update(uniqueId: string, data: UpdateNotificationRequest): Promise<Notification> {\n const response = await transport.put<unknown>(`/notifications/${uniqueId}`, {\n data: {\n type: 'Notification',\n attributes: {\n content: data.content,\n url: data.url,\n status: data.status,\n payload: data.payload,\n },\n },\n });\n return decodeOne(response, notificationMapper);\n },\n\n async delete(uniqueId: string): Promise<void> {\n await transport.delete(`/notifications/${uniqueId}`);\n },\n\n async markAsRead(uniqueId: string): Promise<Notification> {\n const response = await transport.put<unknown>(`/notifications/${uniqueId}/read`, {});\n return decodeOne(response, notificationMapper);\n },\n\n async markAsUnread(uniqueId: string): Promise<Notification> {\n const response = await transport.put<unknown>(`/notifications/${uniqueId}/unread`, {});\n return decodeOne(response, notificationMapper);\n },\n\n async listByTarget(targetId: string, params?: ListNotificationsParams): Promise<PageResult<Notification>> {\n const queryParams: Record<string, string> = {};\n if (params?.page) queryParams['page'] = String(params.page);\n if (params?.perPage) queryParams['records'] = String(params.perPage);\n if (params?.status) queryParams['status'] = params.status;\n if (params?.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;\n\n const response = await transport.get<unknown>(`/notifications/target/${targetId}`, { params: queryParams });\n return decodePageResult(response, notificationMapper);\n },\n\n async listUnread(params?: ListNotificationsParams): Promise<PageResult<Notification>> {\n const queryParams: Record<string, string> = { status: 'pending' };\n if (params?.page) queryParams['page'] = String(params.page);\n if (params?.perPage) queryParams['records'] = String(params.perPage);\n if (params?.targetId) queryParams['target_id'] = params.targetId;\n if (params?.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;\n\n const response = await transport.get<unknown>('/notifications/unread', { params: queryParams });\n return decodePageResult(response, notificationMapper);\n },\n };\n}\n"],"names":["decodeOne","decodePageResult","notificationMapper","createNotificationsService","transport","_config","list","params","queryParams","page","String","perPage","status","targetId","sourceId","sortBy","sortOrder","response","get","uniqueId","create","data","post","type","attributes","content","source","source_alias","sourceAlias","source_id","source_type","sourceType","url","target","target_id","target_alias","targetAlias","target_type","targetType","target_email","targetEmail","target_phone","targetPhone","target_device_id","targetDeviceId","multichannel","expires_at","expiresAt","payload","update","put","delete","markAsRead","markAsUnread","listByTarget","listUnread"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AACA,SAASA,SAAS,EAAcC,gBAAgB,QAAQ,0BAA0B;AAOlF,SAASC,kBAAkB,QAAQ,iCAAiC;AAcpE,OAAO,SAASC,2BAA2BC,SAAoB,EAAEC,OAA0B;IACzF,OAAO;QACL,MAAMC,MAAKC,MAAgC;YACzC,MAAMC,cAAsC,CAAC;YAC7C,IAAID,0BAAAA,OAAQE,IAAI,EAAED,WAAW,CAAC,OAAO,GAAGE,OAAOH,OAAOE,IAAI;YAC1D,IAAIF,0BAAAA,OAAQI,OAAO,EAAEH,WAAW,CAAC,UAAU,GAAGE,OAAOH,OAAOI,OAAO;YACnE,IAAIJ,0BAAAA,OAAQK,MAAM,EAAEJ,WAAW,CAAC,SAAS,GAAGD,OAAOK,MAAM;YACzD,IAAIL,0BAAAA,OAAQM,QAAQ,EAAEL,WAAW,CAAC,YAAY,GAAGD,OAAOM,QAAQ;YAChE,IAAIN,0BAAAA,OAAQO,QAAQ,EAAEN,WAAW,CAAC,YAAY,GAAGD,OAAOO,QAAQ;YAChE,IAAIP,0BAAAA,OAAQQ,MAAM,EAAEP,WAAW,CAAC,OAAO,GAAGD,OAAOS,SAAS,KAAK,SAAS,CAAC,CAAC,EAAET,OAAOQ,MAAM,CAAC,CAAC,GAAGR,OAAOQ,MAAM;YAE3G,MAAME,WAAW,MAAMb,UAAUc,GAAG,CAAU,kBAAkB;gBAAEX,QAAQC;YAAY;YACtF,OAAOP,iBAAiBgB,UAAUf;QACpC;QAEA,MAAMgB,KA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YACnE,IAAIJ,0BAAAA,OAAQM,QAAQ,EAAEL,WAAW,CAAC,YAAY,GAAGD,OAAOM,QAAQ;YAChE,IAAIN,0BAAAA,OAAQQ,MAAM,EAAEP,WAAW,CAAC,OAAO,GAAGD,OAAOS,SAAS,KAAK,SAAS,CAAC,CAAC,EAAET,OAAOQ,MAAM,CAAC,CAAC,GAAGR,OAAOQ,MAAM;YAE3G,MAAME,WAAW,MAAMb,UAAUc,GAAG,CAAU,yBAAyB;gBAAEX,QAAQC;YAAY;YAC7F,OAAOP,iBAAiBgB,UAAUf;QACpC;IACF;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/types/conversation.ts"],"sourcesContent":["import type { Message } from './message';\n\nexport interface ConversationFile {\n uniqueId: string;\n name: string;\n url: string;\n type?: string;\n size?: number;\n}\n\nexport interface ConversationMeta {\n totalMessages?: number;\n unreadCount?: number;\n lastMessageAt?: Date;\n participants?: string[];\n [key: string]: unknown;\n}\n\nexport interface Conversation {\n id: string;\n context: string;\n messages: Message[];\n files?: ConversationFile[];\n meta?: ConversationMeta;\n}\n\n// Request types\nexport interface GetConversationParams {\n context: string;\n page?: number;\n perPage?: number;\n includeFiles?: boolean;\n}\n"],"names":[],"rangeMappings":";","mappings":"AA0BA,gBAAgB;AAChB,WAKC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/types/draft-message.ts"],"sourcesContent":["import type { IdentityCore, EntityStatus } from '@23blocks/contracts';\n\nexport interface DraftMessage extends IdentityCore {\n contextId?: string;\n parentId?: string;\n content: string;\n\n // Source (sender)\n source?: string;\n sourceId?: string;\n sourceAlias?: string;\n sourceEmail?: string;\n sourcePhone?: string;\n sourceType?: string;\n\n // Target (recipient)\n target?: string;\n targetId?: string;\n targetAlias?: string;\n targetEmail?: string;\n targetPhone?: string;\n targetType?: string;\n targetDeviceId?: string;\n\n // Value and data source\n value?: number;\n dataSource?: string;\n dataSourceId?: string;\n dataSourceType?: string;\n dataSourceAlias?: string;\n\n // Status\n status: EntityStatus;\n enabled: boolean;\n\n // Extra data\n payload?: Record<string, unknown>;\n\n // Notification\n notificationContent?: string;\n notificationUrl?: string;\n\n // Expiration\n expiresAt?: Date;\n\n // RAG sources\n ragSources?: string[];\n\n // Idempotency\n idempotencyKey?: string;\n}\n\n// Request types\nexport interface CreateDraftMessageRequest {\n contextId?: string;\n parentId?: string;\n content: string;\n source?: string;\n sourceId?: string;\n sourceAlias?: string;\n sourceEmail?: string;\n sourcePhone?: string;\n sourceType?: string;\n target?: string;\n targetId?: string;\n targetAlias?: string;\n targetEmail?: string;\n targetPhone?: string;\n targetType?: string;\n targetDeviceId?: string;\n value?: number;\n dataSource?: string;\n dataSourceId?: string;\n dataSourceType?: string;\n dataSourceAlias?: string;\n notificationContent?: string;\n notificationUrl?: string;\n expiresAt?: Date;\n ragSources?: string[];\n idempotencyKey?: string;\n payload?: Record<string, unknown>;\n}\n\nexport interface UpdateDraftMessageRequest {\n content?: string;\n status?: EntityStatus;\n enabled?: boolean;\n payload?: Record<string, unknown>;\n}\n\nexport interface ListDraftMessagesParams {\n page?: number;\n perPage?: number;\n contextId?: string;\n status?: EntityStatus;\n sourceId?: string;\n sortBy?: string;\n sortOrder?: 'asc' | 'desc';\n}\n"],"names":[],"rangeMappings":"","mappings":"AA0FA,WAQC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/types/group.ts"],"sourcesContent":["import type { IdentityCore, EntityStatus } from '@23blocks/contracts';\n\nexport interface Group extends IdentityCore {\n name: string;\n code?: string;\n uniqueCode?: string;\n qcode?: string;\n groupType?: string;\n\n // Members\n members?: string[];\n\n // Status\n status: EntityStatus;\n enabled: boolean;\n\n // Source\n source?: string;\n sourceAlias?: string;\n sourceId?: string;\n sourceType?: string;\n\n // Extra data\n payload?: Record<string, unknown>;\n}\n\n// Request types\nexport interface CreateGroupRequest {\n name: string;\n code?: string;\n uniqueCode?: string;\n qcode?: string;\n groupType?: string;\n members?: string[];\n source?: string;\n sourceAlias?: string;\n sourceId?: string;\n sourceType?: string;\n payload?: Record<string, unknown>;\n}\n\nexport interface UpdateGroupRequest {\n name?: string;\n code?: string;\n uniqueCode?: string;\n qcode?: string;\n groupType?: string;\n members?: string[];\n status?: EntityStatus;\n enabled?: boolean;\n payload?: Record<string, unknown>;\n}\n\nexport interface ListGroupsParams {\n page?: number;\n perPage?: number;\n status?: EntityStatus;\n groupType?: string;\n search?: string;\n sortBy?: string;\n sortOrder?: 'asc' | 'desc';\n}\n"],"names":[],"rangeMappings":"","mappings":"AAqDA,WAQC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/types/index.ts"],"sourcesContent":["export * from './message';\nexport * from './draft-message';\nexport * from './group';\nexport * from './notification';\nexport * from './conversation';\n"],"names":[],"rangeMappings":";;;;","mappings":"AAAA,cAAc,YAAY;AAC1B,cAAc,kBAAkB;AAChC,cAAc,UAAU;AACxB,cAAc,iBAAiB;AAC/B,cAAc,iBAAiB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/types/message.ts"],"sourcesContent":["import type { IdentityCore, EntityStatus } from '@23blocks/contracts';\n\nexport interface Message extends IdentityCore {\n contextId?: string;\n parentId?: string;\n content: string;\n\n // Source (sender)\n source?: string;\n sourceId?: string;\n sourceAlias?: string;\n sourceEmail?: string;\n sourcePhone?: string;\n sourceType?: string;\n\n // Target (recipient)\n target?: string;\n targetId?: string;\n targetAlias?: string;\n targetEmail?: string;\n targetPhone?: string;\n targetType?: string;\n targetDeviceId?: string;\n\n // Value and data source\n value?: number;\n dataSource?: string;\n dataSourceId?: string;\n dataSourceType?: string;\n dataSourceAlias?: string;\n\n // Status\n status: EntityStatus;\n enabled: boolean;\n\n // Extra data\n payload?: Record<string, unknown>;\n\n // Notification\n notificationContent?: string;\n notificationUrl?: string;\n\n // Expiration\n expiresAt?: Date;\n\n // RAG sources\n ragSources?: string[];\n\n // Idempotency\n idempotencyKey?: string;\n\n // Tracking\n createdBy?: string;\n updatedBy?: string;\n}\n\n// Request types\nexport interface CreateMessageRequest {\n contextId?: string;\n parentId?: string;\n content: string;\n source?: string;\n sourceId?: string;\n sourceAlias?: string;\n sourceEmail?: string;\n sourcePhone?: string;\n sourceType?: string;\n target?: string;\n targetId?: string;\n targetAlias?: string;\n targetEmail?: string;\n targetPhone?: string;\n targetType?: string;\n targetDeviceId?: string;\n value?: number;\n dataSource?: string;\n dataSourceId?: string;\n dataSourceType?: string;\n dataSourceAlias?: string;\n notificationContent?: string;\n notificationUrl?: string;\n expiresAt?: Date;\n ragSources?: string[];\n idempotencyKey?: string;\n payload?: Record<string, unknown>;\n}\n\nexport interface UpdateMessageRequest {\n content?: string;\n status?: EntityStatus;\n enabled?: boolean;\n payload?: Record<string, unknown>;\n}\n\nexport interface ListMessagesParams {\n page?: number;\n perPage?: number;\n contextId?: string;\n parentId?: string;\n status?: EntityStatus;\n sourceId?: string;\n targetId?: string;\n sortBy?: string;\n sortOrder?: 'asc' | 'desc';\n}\n"],"names":[],"rangeMappings":"","mappings":"AA8FA,WAUC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/types/notification.ts"],"sourcesContent":["import type { IdentityCore, EntityStatus } from '@23blocks/contracts';\n\nexport interface Notification extends IdentityCore {\n content: string;\n\n // Source\n source?: string;\n sourceAlias?: string;\n sourceId?: string;\n sourceType?: string;\n\n // URL\n url?: string;\n\n // Status\n status: EntityStatus;\n\n // Target\n target?: string;\n targetId?: string;\n targetAlias?: string;\n targetType?: string;\n targetEmail?: string;\n targetPhone?: string;\n targetDeviceId?: string;\n\n // Multichannel\n multichannel?: boolean;\n\n // Extra data\n payload?: Record<string, unknown>;\n\n // Expiration\n expiresAt?: Date;\n\n // Tracking\n createdBy?: string;\n updatedBy?: string;\n}\n\n// Request types\nexport interface CreateNotificationRequest {\n content: string;\n source?: string;\n sourceAlias?: string;\n sourceId?: string;\n sourceType?: string;\n url?: string;\n target?: string;\n targetId?: string;\n targetAlias?: string;\n targetType?: string;\n targetEmail?: string;\n targetPhone?: string;\n targetDeviceId?: string;\n multichannel?: boolean;\n expiresAt?: Date;\n payload?: Record<string, unknown>;\n}\n\nexport interface UpdateNotificationRequest {\n content?: string;\n url?: string;\n status?: EntityStatus;\n payload?: Record<string, unknown>;\n}\n\nexport interface ListNotificationsParams {\n page?: number;\n perPage?: number;\n status?: EntityStatus;\n targetId?: string;\n sourceId?: string;\n sortBy?: string;\n sortOrder?: 'asc' | 'desc';\n}\n"],"names":[],"rangeMappings":"","mappings":"AAmEA,WAQC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@23blocks/block-conversations",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Conversations block for 23blocks SDK - messaging, groups, notifications, and conversations management",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "23blocks <hello@23blocks.com>",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/23blocks-OS/frontend-sdk.git",
|
|
10
|
+
"directory": "packages/block-conversations"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/23blocks-OS/frontend-sdk/tree/main/packages/block-conversations",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/23blocks-OS/frontend-sdk/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"23blocks",
|
|
18
|
+
"sdk",
|
|
19
|
+
"conversations",
|
|
20
|
+
"messaging",
|
|
21
|
+
"chat",
|
|
22
|
+
"notifications",
|
|
23
|
+
"groups"
|
|
24
|
+
],
|
|
25
|
+
"type": "module",
|
|
26
|
+
"main": "./dist/index.js",
|
|
27
|
+
"module": "./dist/index.js",
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"exports": {
|
|
30
|
+
"./package.json": "./package.json",
|
|
31
|
+
".": {
|
|
32
|
+
"types": "./dist/index.d.ts",
|
|
33
|
+
"import": "./dist/index.js",
|
|
34
|
+
"default": "./dist/index.js"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"files": [
|
|
38
|
+
"dist",
|
|
39
|
+
"!**/*.tsbuildinfo"
|
|
40
|
+
],
|
|
41
|
+
"nx": {
|
|
42
|
+
"sourceRoot": "packages/block-conversations/src",
|
|
43
|
+
"targets": {
|
|
44
|
+
"build": {
|
|
45
|
+
"executor": "@nx/js:swc",
|
|
46
|
+
"outputs": [
|
|
47
|
+
"{options.outputPath}"
|
|
48
|
+
],
|
|
49
|
+
"options": {
|
|
50
|
+
"outputPath": "packages/block-conversations/dist",
|
|
51
|
+
"main": "packages/block-conversations/src/index.ts",
|
|
52
|
+
"tsConfig": "packages/block-conversations/tsconfig.lib.json",
|
|
53
|
+
"skipTypeCheck": true,
|
|
54
|
+
"stripLeadingPaths": true
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"dependencies": {
|
|
60
|
+
"@23blocks/contracts": "*",
|
|
61
|
+
"@23blocks/jsonapi-codec": "*",
|
|
62
|
+
"@swc/helpers": "~0.5.11"
|
|
63
|
+
}
|
|
64
|
+
}
|