@nu-art/ts-messaging-shared 0.401.8 → 0.500.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/index.d.ts +1 -0
- package/index.js +1 -0
- package/message/db-def.d.ts +3 -10
- package/message/db-def.js +11 -35
- package/message/types.d.ts +14 -31
- package/message/types.js +2 -5
- package/package.json +3 -3
- package/topic/db-def.d.ts +3 -3
- package/topic/db-def.js +5 -3
- package/topic/types.d.ts +9 -7
- package/topic/types.js +1 -1
package/index.d.ts
CHANGED
package/index.js
CHANGED
package/message/db-def.d.ts
CHANGED
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { DB_Message_Image, DB_Message_Text, DB_Message_Video,
|
|
3
|
-
/**
|
|
4
|
-
* Utility object containing type guard methods for different message types
|
|
5
|
-
*/
|
|
1
|
+
import { Database } from '@nu-art/db-api-shared';
|
|
2
|
+
import { DB_Message_Image, DB_Message_Text, DB_Message_Video, DatabaseDef_Message, UI_Message } from './types.js';
|
|
6
3
|
export declare const MessageTools: {
|
|
7
4
|
isText: (instance: UI_Message) => instance is DB_Message_Text;
|
|
8
5
|
isImage: (instance: UI_Message) => instance is DB_Message_Image;
|
|
9
6
|
isVideo: (instance: UI_Message) => instance is DB_Message_Video;
|
|
10
7
|
};
|
|
11
|
-
|
|
12
|
-
* Database definition for messages
|
|
13
|
-
* Includes validation rules, versioning, and database configuration
|
|
14
|
-
*/
|
|
15
|
-
export declare const DBDef_message: DBDef_V3<DBProto_Message>;
|
|
8
|
+
export declare const DBDef_message: Database<DatabaseDef_Message>;
|
package/message/db-def.js
CHANGED
|
@@ -1,29 +1,14 @@
|
|
|
1
1
|
import { deleteKeysObject, exists, removeDBObjectKeys, tsValidate, tsValidateString, tsValidateUniqueId, tsValidateValue } from '@nu-art/ts-common';
|
|
2
2
|
import { MessageType_Image, MessageType_Text, MessageType_Video } from './types.js';
|
|
3
3
|
import { MessagingDBGroup } from '../consts.js';
|
|
4
|
-
/**
|
|
5
|
-
* Utility object containing type guard methods for different message types
|
|
6
|
-
*/
|
|
7
4
|
export const MessageTools = {
|
|
8
|
-
isText: (instance) =>
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
isImage: (instance) => {
|
|
12
|
-
return instance.type === 'image';
|
|
13
|
-
},
|
|
14
|
-
isVideo: (instance) => {
|
|
15
|
-
return instance.type === 'video';
|
|
16
|
-
}
|
|
5
|
+
isText: (instance) => instance.type === 'text',
|
|
6
|
+
isImage: (instance) => instance.type === 'image',
|
|
7
|
+
isVideo: (instance) => instance.type === 'video',
|
|
17
8
|
};
|
|
18
|
-
|
|
19
|
-
* Validator for automatically generated message properties
|
|
20
|
-
*/
|
|
21
|
-
const Validator_GeneratedProps_Text = {
|
|
9
|
+
const Validator_GeneratedProps_Message = {
|
|
22
10
|
_auditorId: tsValidateUniqueId,
|
|
23
11
|
};
|
|
24
|
-
/**
|
|
25
|
-
* Base validator for common message properties
|
|
26
|
-
*/
|
|
27
12
|
const Validator_BaseMessage = {
|
|
28
13
|
topicId: tsValidateUniqueId,
|
|
29
14
|
};
|
|
@@ -41,12 +26,6 @@ const Validator_DB_Message_Text = {
|
|
|
41
26
|
type: tsValidateValue([MessageType_Text]),
|
|
42
27
|
text: tsValidateString(),
|
|
43
28
|
};
|
|
44
|
-
/**
|
|
45
|
-
* Validates modifiable properties of a message based on its type
|
|
46
|
-
*
|
|
47
|
-
* @param instance - The message instance to validate
|
|
48
|
-
* @returns Validation result or error message
|
|
49
|
-
*/
|
|
50
29
|
const Validator_ModifiableProps_Message = (instance) => {
|
|
51
30
|
if (!exists(instance))
|
|
52
31
|
return 'No object received';
|
|
@@ -59,25 +38,22 @@ const Validator_ModifiableProps_Message = (instance) => {
|
|
|
59
38
|
case MessageType_Video:
|
|
60
39
|
return tsValidate(__toValidate, Validator_DB_Message_Video);
|
|
61
40
|
default:
|
|
62
|
-
|
|
63
|
-
return `Could not find message type('${instance.type}') when attempting to validate a message!`;
|
|
41
|
+
return `Could not find message type('${instance?.type}') when attempting to validate a message!`;
|
|
64
42
|
}
|
|
65
43
|
};
|
|
66
|
-
/**
|
|
67
|
-
* Database definition for messages
|
|
68
|
-
* Includes validation rules, versioning, and database configuration
|
|
69
|
-
*/
|
|
70
44
|
export const DBDef_message = {
|
|
45
|
+
dbKey: 'messages',
|
|
46
|
+
entityName: 'Message',
|
|
71
47
|
modifiablePropsValidator: Validator_ModifiableProps_Message,
|
|
72
|
-
generatedPropsValidator:
|
|
48
|
+
generatedPropsValidator: Validator_GeneratedProps_Message,
|
|
49
|
+
generatedProps: ['_auditorId'],
|
|
73
50
|
versions: ['1.0.0'],
|
|
74
|
-
|
|
51
|
+
uniqueKeys: ['_id'],
|
|
75
52
|
frontend: {
|
|
76
53
|
group: MessagingDBGroup,
|
|
77
54
|
name: 'message',
|
|
78
55
|
},
|
|
79
56
|
backend: {
|
|
80
|
-
name: 'messages'
|
|
57
|
+
name: 'messages',
|
|
81
58
|
},
|
|
82
|
-
entityName: 'Message',
|
|
83
59
|
};
|
package/message/types.d.ts
CHANGED
|
@@ -1,31 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* This includes message types, database schemas, and UI representations.
|
|
4
|
-
*/
|
|
5
|
-
import { AuditableV2, DB_Object, DBProto, Proto_DB_Object, UniqueId, VersionsDeclaration } from '@nu-art/ts-common';
|
|
6
|
-
/**
|
|
7
|
-
* Version declaration for message types
|
|
8
|
-
* Currently supports version 1.0.0
|
|
2
|
+
* Types and interfaces for the messaging system: message types, DB schemas, UI representations.
|
|
9
3
|
*/
|
|
4
|
+
import { DB_Object, DB_ProtoSeed, DB_Prototype, VersionsDeclaration } from '@nu-art/db-api-shared';
|
|
5
|
+
export declare const Message_DbKey = "messages";
|
|
6
|
+
type DBKey = typeof Message_DbKey;
|
|
10
7
|
type VersionTypes_Message = {
|
|
11
8
|
'1.0.0': DB_Message;
|
|
12
9
|
};
|
|
13
10
|
type Versions = VersionsDeclaration<['1.0.0'], VersionTypes_Message>;
|
|
14
|
-
type Dependencies = {};
|
|
15
11
|
type UniqueKeys = '_id';
|
|
16
|
-
type
|
|
17
|
-
type
|
|
18
|
-
|
|
12
|
+
type GeneratedKeys = '_auditorId';
|
|
13
|
+
type Dependencies = {};
|
|
14
|
+
type Proto = DB_ProtoSeed<DB_Message, DBKey, GeneratedKeys, Versions, UniqueKeys, Dependencies>;
|
|
19
15
|
export declare const MessageType_Text: "text";
|
|
20
|
-
/** Constant representing an image message type */
|
|
21
16
|
export declare const MessageType_Image: "image";
|
|
22
|
-
/** Constant representing a video message type */
|
|
23
17
|
export declare const MessageType_Video: "video";
|
|
24
|
-
export type DBProto_Message = DBProto<Proto>;
|
|
25
|
-
export type UI_Message = DBProto_Message['uiType'];
|
|
26
|
-
/**
|
|
27
|
-
* Mapping of message types to their respective data structures
|
|
28
|
-
*/
|
|
29
18
|
export type MessageTypes_DataMap = {
|
|
30
19
|
text: {
|
|
31
20
|
text: string;
|
|
@@ -33,33 +22,27 @@ export type MessageTypes_DataMap = {
|
|
|
33
22
|
image: {
|
|
34
23
|
url: string;
|
|
35
24
|
};
|
|
36
|
-
video:
|
|
25
|
+
video: Record<string, never>;
|
|
37
26
|
};
|
|
38
|
-
/** Union type of all possible message types */
|
|
39
27
|
export type MessageType = keyof MessageTypes_DataMap;
|
|
40
|
-
/**
|
|
41
|
-
* Base interface for all message types
|
|
42
|
-
* @property topicId - Unique identifier for the topic this message belongs to
|
|
43
|
-
*/
|
|
44
28
|
export type BaseMessage = {
|
|
45
|
-
topicId:
|
|
29
|
+
topicId: string;
|
|
46
30
|
};
|
|
47
|
-
/** Database representation of a text message */
|
|
48
31
|
export type DB_Message_Text = BaseMessage & {
|
|
49
32
|
type: typeof MessageType_Text;
|
|
50
33
|
text: string;
|
|
51
34
|
};
|
|
52
|
-
/** Database representation of an image message */
|
|
53
35
|
export type DB_Message_Image = BaseMessage & {
|
|
54
36
|
type: typeof MessageType_Image;
|
|
55
37
|
url: string;
|
|
56
38
|
};
|
|
57
|
-
/** Database representation of a video message */
|
|
58
39
|
export type DB_Message_Video = BaseMessage & {
|
|
59
40
|
type: typeof MessageType_Video;
|
|
60
41
|
};
|
|
61
|
-
/** Union type of all possible message content types */
|
|
62
42
|
export type MessageContent = DB_Message_Text | DB_Message_Image | DB_Message_Video;
|
|
63
|
-
|
|
64
|
-
|
|
43
|
+
export type DB_Message = DB_Object<DBKey> & {
|
|
44
|
+
_auditorId?: string;
|
|
45
|
+
} & MessageContent;
|
|
46
|
+
export type DatabaseDef_Message = DB_Prototype<Proto>;
|
|
47
|
+
export type UI_Message = DatabaseDef_Message['uiType'];
|
|
65
48
|
export {};
|
package/message/types.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* This includes message types, database schemas, and UI representations.
|
|
2
|
+
* Types and interfaces for the messaging system: message types, DB schemas, UI representations.
|
|
4
3
|
*/
|
|
5
|
-
|
|
4
|
+
export const Message_DbKey = 'messages';
|
|
6
5
|
export const MessageType_Text = 'text';
|
|
7
|
-
/** Constant representing an image message type */
|
|
8
6
|
export const MessageType_Image = 'image';
|
|
9
|
-
/** Constant representing a video message type */
|
|
10
7
|
export const MessageType_Video = 'video';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nu-art/ts-messaging-shared",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.500.0",
|
|
4
4
|
"description": "A messaging module for Thunderstorm framework that provides topic-based messaging system with support for different message types (text, image, video) and discussion management features",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"TacB0sS",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"build": "tsc"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@nu-art/ts-common": "0.
|
|
35
|
-
"@nu-art/
|
|
34
|
+
"@nu-art/ts-common": "0.500.0",
|
|
35
|
+
"@nu-art/db-api-shared": "0.500.0",
|
|
36
36
|
"react": "^18.0.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
package/topic/db-def.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Database } from '@nu-art/db-api-shared';
|
|
2
|
+
import { DatabaseDef_Topic } from './types.js';
|
|
3
3
|
export declare const Validator_GeneratedProps_Topic: {
|
|
4
4
|
type: import("@nu-art/ts-common").Validator<string>;
|
|
5
5
|
refId: import("@nu-art/ts-common").Validator<string>;
|
|
6
6
|
};
|
|
7
|
-
export declare const DBDef_Topic:
|
|
7
|
+
export declare const DBDef_Topic: Database<DatabaseDef_Topic>;
|
package/topic/db-def.js
CHANGED
|
@@ -6,16 +6,18 @@ export const Validator_GeneratedProps_Topic = {
|
|
|
6
6
|
refId: tsValidateUniqueId,
|
|
7
7
|
};
|
|
8
8
|
export const DBDef_Topic = {
|
|
9
|
+
dbKey: 'topics',
|
|
10
|
+
entityName: 'Topic',
|
|
9
11
|
modifiablePropsValidator: Validator_ModifiableProps,
|
|
10
12
|
generatedPropsValidator: Validator_GeneratedProps_Topic,
|
|
13
|
+
generatedProps: ['refId', 'type'],
|
|
11
14
|
versions: ['1.0.0'],
|
|
12
|
-
|
|
13
|
-
entityName: 'Topic',
|
|
15
|
+
uniqueKeys: ['_id'],
|
|
14
16
|
frontend: {
|
|
15
17
|
group: MessagingDBGroup,
|
|
16
18
|
name: 'topic',
|
|
17
19
|
},
|
|
18
20
|
backend: {
|
|
19
21
|
name: 'topics',
|
|
20
|
-
}
|
|
22
|
+
},
|
|
21
23
|
};
|
package/topic/types.d.ts
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
import { DB_Object,
|
|
1
|
+
import { DB_Object, DB_ProtoSeed, DB_Prototype, VersionsDeclaration } from '@nu-art/db-api-shared';
|
|
2
|
+
export declare const Topic_DbKey = "topics";
|
|
3
|
+
type DBKey = typeof Topic_DbKey;
|
|
2
4
|
type VersionTypes_Topic = {
|
|
3
5
|
'1.0.0': DB_Topic;
|
|
4
6
|
};
|
|
5
7
|
type Versions = VersionsDeclaration<['1.0.0'], VersionTypes_Topic>;
|
|
6
|
-
type Dependencies = {};
|
|
7
8
|
type UniqueKeys = '_id';
|
|
8
|
-
type
|
|
9
|
-
type
|
|
10
|
-
|
|
11
|
-
export type
|
|
12
|
-
export type DB_Topic = DB_Object & {
|
|
9
|
+
type GeneratedKeys = 'type' | 'refId';
|
|
10
|
+
type Dependencies = {};
|
|
11
|
+
type Proto = DB_ProtoSeed<DB_Topic, DBKey, GeneratedKeys, Versions, UniqueKeys, Dependencies>;
|
|
12
|
+
export type DB_Topic = DB_Object<DBKey> & {
|
|
13
13
|
type: string;
|
|
14
14
|
refId: string;
|
|
15
15
|
};
|
|
16
|
+
export type DatabaseDef_Topic = DB_Prototype<Proto>;
|
|
17
|
+
export type UI_Topic = DatabaseDef_Topic['uiType'];
|
|
16
18
|
export {};
|
package/topic/types.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export const Topic_DbKey = 'topics';
|