@nu-art/ts-messaging-shared 0.400.2

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 ADDED
@@ -0,0 +1,3 @@
1
+ export * from './message/index.js';
2
+ export * from './topic/index.js';
3
+ export declare const MessagingDBGroup = "messaging";
package/index.js ADDED
@@ -0,0 +1,4 @@
1
+ export * from './message/index.js';
2
+ export * from './topic/index.js';
3
+ export const MessagingDBGroup = 'messaging';
4
+ //# sourceMappingURL=index.js.map
package/index.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"/Users/tacb0ss/dev/nu-art/beamz/_thunderstorm/ts-messaging/shared/src/main/","sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AAEjC,MAAM,CAAC,MAAM,gBAAgB,GAAG,WAAW,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { DBDef_V3 } from '@nu-art/ts-common';
2
+ import { DB_Message_Image, DB_Message_Text, DB_Message_Video, DBProto_Message, UI_Message } from './types.js';
3
+ /**
4
+ * Utility object containing type guard methods for different message types
5
+ */
6
+ export declare const MessageTools: {
7
+ isText: (instance: UI_Message) => instance is DB_Message_Text;
8
+ isImage: (instance: UI_Message) => instance is DB_Message_Image;
9
+ isVideo: (instance: UI_Message) => instance is DB_Message_Video;
10
+ };
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>;
@@ -0,0 +1,84 @@
1
+ import { deleteKeysObject, exists, removeDBObjectKeys, tsValidate, tsValidateString, tsValidateUniqueId, tsValidateValue } from '@nu-art/ts-common';
2
+ import { MessageType_Image, MessageType_Text, MessageType_Video } from './types.js';
3
+ import { MessagingDBGroup } from '../index.js';
4
+ /**
5
+ * Utility object containing type guard methods for different message types
6
+ */
7
+ export const MessageTools = {
8
+ isText: (instance) => {
9
+ return instance.type === 'text';
10
+ },
11
+ isImage: (instance) => {
12
+ return instance.type === 'image';
13
+ },
14
+ isVideo: (instance) => {
15
+ return instance.type === 'video';
16
+ }
17
+ };
18
+ /**
19
+ * Validator for automatically generated message properties
20
+ */
21
+ const Validator_GeneratedProps_Text = {
22
+ _auditorId: tsValidateUniqueId,
23
+ };
24
+ /**
25
+ * Base validator for common message properties
26
+ */
27
+ const Validator_BaseMessage = {
28
+ topicId: tsValidateUniqueId,
29
+ };
30
+ const Validator_DB_Message_Image = {
31
+ ...Validator_BaseMessage,
32
+ type: tsValidateValue([MessageType_Image]),
33
+ url: tsValidateString(),
34
+ };
35
+ const Validator_DB_Message_Video = {
36
+ ...Validator_BaseMessage,
37
+ type: tsValidateValue([MessageType_Video]),
38
+ };
39
+ const Validator_DB_Message_Text = {
40
+ ...Validator_BaseMessage,
41
+ type: tsValidateValue([MessageType_Text]),
42
+ text: tsValidateString(),
43
+ };
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
+ const Validator_ModifiableProps_Message = (instance) => {
51
+ if (!exists(instance))
52
+ return 'No object received';
53
+ const __toValidate = deleteKeysObject(removeDBObjectKeys(instance), ['_auditorId']);
54
+ switch (instance?.type) {
55
+ case MessageType_Text:
56
+ return tsValidate(__toValidate, Validator_DB_Message_Text);
57
+ case MessageType_Image:
58
+ return tsValidate(__toValidate, Validator_DB_Message_Image);
59
+ case MessageType_Video:
60
+ return tsValidate(__toValidate, Validator_DB_Message_Video);
61
+ default:
62
+ // @ts-ignore
63
+ return `Could not find message type('${instance.type}') when attempting to validate a message!`;
64
+ }
65
+ };
66
+ /**
67
+ * Database definition for messages
68
+ * Includes validation rules, versioning, and database configuration
69
+ */
70
+ export const DBDef_message = {
71
+ modifiablePropsValidator: Validator_ModifiableProps_Message,
72
+ generatedPropsValidator: Validator_GeneratedProps_Text,
73
+ versions: ['1.0.0'],
74
+ dbKey: 'messages',
75
+ frontend: {
76
+ group: MessagingDBGroup,
77
+ name: 'message',
78
+ },
79
+ backend: {
80
+ name: 'messages'
81
+ },
82
+ entityName: 'Message',
83
+ };
84
+ //# sourceMappingURL=db-def.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"db-def.js","sourceRoot":"/Users/tacb0ss/dev/nu-art/beamz/_thunderstorm/ts-messaging/shared/src/main/","sources":["message/db-def.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,gBAAgB,EAChB,MAAM,EAEN,kBAAkB,EAClB,UAAU,EACV,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,EAEf,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAON,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EAEjB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAC,gBAAgB,EAAC,MAAM,aAAa,CAAC;AAE7C;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC3B,MAAM,EAAE,CAAC,QAAoB,EAA+B,EAAE;QAC7D,OAAO,QAAQ,CAAC,IAAI,KAAK,MAAM,CAAC;IACjC,CAAC;IACD,OAAO,EAAE,CAAC,QAAoB,EAAgC,EAAE;QAC/D,OAAO,QAAQ,CAAC,IAAI,KAAK,OAAO,CAAC;IAClC,CAAC;IACD,OAAO,EAAE,CAAC,QAAoB,EAAgC,EAAE;QAC/D,OAAO,QAAQ,CAAC,IAAI,KAAK,OAAO,CAAC;IAClC,CAAC;CACD,CAAC;AAEF;;GAEG;AACH,MAAM,6BAA6B,GAA+C;IACjF,UAAU,EAAE,kBAAkB;CAC9B,CAAC;AAEF;;GAEG;AACH,MAAM,qBAAqB,GAAuC;IACjE,OAAO,EAAE,kBAAkB;CAC3B,CAAC;AAEF,MAAM,0BAA0B,GAA4C;IAC3E,GAAG,qBAAqB;IACxB,IAAI,EAAE,eAAe,CAAC,CAAC,iBAAiB,CAAC,CAAC;IAC1C,GAAG,EAAE,gBAAgB,EAAE;C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-0,0 +1,2 @@
1
+ export * from './types.js';
2
+ export * from './db-def.js';
@@ -0,0 +1,4 @@
1
+ // Generated DB Item type: message
2
+ export * from './types.js';
3
+ export * from './db-def.js';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"/Users/tacb0ss/dev/nu-art/beamz/_thunderstorm/ts-messaging/shared/src/main/","sources":["message/index.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC"}
@@ -0,0 +1,65 @@
1
+ /**
2
+ * @fileoverview Defines the types and interfaces for the messaging system.
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
9
+ */
10
+ type VersionTypes_Message = {
11
+ '1.0.0': DB_Message;
12
+ };
13
+ type Versions = VersionsDeclaration<['1.0.0'], VersionTypes_Message>;
14
+ type Dependencies = {};
15
+ type UniqueKeys = '_id';
16
+ type GeneratedProps = '_auditorId';
17
+ type Proto = Proto_DB_Object<DB_Message, 'messages', GeneratedProps, Versions, UniqueKeys, Dependencies>;
18
+ /** Constant representing a text message type */
19
+ export declare const MessageType_Text: "text";
20
+ /** Constant representing an image message type */
21
+ export declare const MessageType_Image: "image";
22
+ /** Constant representing a video message type */
23
+ 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
+ export type MessageTypes_DataMap = {
30
+ text: {
31
+ text: string;
32
+ };
33
+ image: {
34
+ url: string;
35
+ };
36
+ video: {};
37
+ };
38
+ /** Union type of all possible message types */
39
+ 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
+ export type BaseMessage = {
45
+ topicId: UniqueId;
46
+ };
47
+ /** Database representation of a text message */
48
+ export type DB_Message_Text = BaseMessage & {
49
+ type: typeof MessageType_Text;
50
+ text: string;
51
+ };
52
+ /** Database representation of an image message */
53
+ export type DB_Message_Image = BaseMessage & {
54
+ type: typeof MessageType_Image;
55
+ url: string;
56
+ };
57
+ /** Database representation of a video message */
58
+ export type DB_Message_Video = BaseMessage & {
59
+ type: typeof MessageType_Video;
60
+ };
61
+ /** Union type of all possible message content types */
62
+ export type MessageContent = DB_Message_Text | DB_Message_Image | DB_Message_Video;
63
+ /** Complete database message type including base DB object properties and audit information */
64
+ export type DB_Message = DB_Object & AuditableV2 & MessageContent;
65
+ export {};
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @fileoverview Defines the types and interfaces for the messaging system.
3
+ * This includes message types, database schemas, and UI representations.
4
+ */
5
+ /** Constant representing a text message type */
6
+ export const MessageType_Text = 'text';
7
+ /** Constant representing an image message type */
8
+ export const MessageType_Image = 'image';
9
+ /** Constant representing a video message type */
10
+ export const MessageType_Video = 'video';
11
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"/Users/tacb0ss/dev/nu-art/beamz/_thunderstorm/ts-messaging/shared/src/main/","sources":["message/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAmBH,gDAAgD;AAChD,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAe,CAAC;AAChD,kDAAkD;AAClD,MAAM,CAAC,MAAM,iBAAiB,GAAG,OAAgB,CAAC;AAClD,iDAAiD;AACjD,MAAM,CAAC,MAAM,iBAAiB,GAAG,OAAgB,CAAC"}
package/package.json ADDED
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "@nu-art/ts-messaging-shared",
3
+ "version": "0.400.2",
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
+ "keywords": [
6
+ "TacB0sS",
7
+ "infra",
8
+ "nu-art",
9
+ "thunderstorm",
10
+ "typescript",
11
+ "ts-messaging"
12
+ ],
13
+ "homepage": "https://github.com/nu-art-js/thunderstorm",
14
+ "bugs": {
15
+ "url": "https://github.com/nu-art-js/thunderstorm/issues"
16
+ },
17
+ "publishConfig": {
18
+ "directory": "dist",
19
+ "linkDirectory": true
20
+ },
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "git+ssh://git@github.com:nu-art-js/thunderstorm.git"
24
+ },
25
+ "license": "Apache-2.0",
26
+ "author": "TacB0sS",
27
+ "files": [
28
+ "**/*"
29
+ ],
30
+ "scripts": {
31
+ "build": "tsc"
32
+ },
33
+ "dependencies": {
34
+ "@nu-art/ts-common": "0.400.2",
35
+ "@nu-art/thunderstorm": "0.400.2",
36
+ "react": "^18.0.0"
37
+ },
38
+ "devDependencies": {
39
+ "@types/react": "^18.0.0",
40
+ "@types/chai": "^4.3.4",
41
+ "@types/mocha": "^10.0.1"
42
+ },
43
+ "unitConfig": {
44
+ "type": "typescript-lib"
45
+ },
46
+ "type": "module",
47
+ "exports": {
48
+ ".": {
49
+ "types": "./index.d.ts",
50
+ "import": "./index.js"
51
+ },
52
+ "./*": {
53
+ "types": "./*.d.ts",
54
+ "import": "./*.js"
55
+ }
56
+ }
57
+ }
@@ -0,0 +1,7 @@
1
+ import { DBDef_V3 } from '@nu-art/ts-common';
2
+ import { DBProto_Topic } from './types.js';
3
+ export declare const Validator_GeneratedProps_Topic: {
4
+ type: import("@nu-art/ts-common").Validator<string>;
5
+ refId: import("@nu-art/ts-common").Validator<string>;
6
+ };
7
+ export declare const DBDef_Topic: DBDef_V3<DBProto_Topic>;
@@ -0,0 +1,22 @@
1
+ import { tsValidateString, tsValidateUniqueId } from '@nu-art/ts-common';
2
+ import { MessagingDBGroup } from '../index.js';
3
+ const Validator_ModifiableProps = {};
4
+ export const Validator_GeneratedProps_Topic = {
5
+ type: tsValidateString(),
6
+ refId: tsValidateUniqueId,
7
+ };
8
+ export const DBDef_Topic = {
9
+ modifiablePropsValidator: Validator_ModifiableProps,
10
+ generatedPropsValidator: Validator_GeneratedProps_Topic,
11
+ versions: ['1.0.0'],
12
+ dbKey: 'topics',
13
+ entityName: 'Topic',
14
+ frontend: {
15
+ group: MessagingDBGroup,
16
+ name: 'topic',
17
+ },
18
+ backend: {
19
+ name: 'topics',
20
+ }
21
+ };
22
+ //# sourceMappingURL=db-def.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"db-def.js","sourceRoot":"/Users/tacb0ss/dev/nu-art/beamz/_thunderstorm/ts-messaging/shared/src/main/","sources":["topic/db-def.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,gBAAgB,EAAE,kBAAkB,EAAC,MAAM,mBAAmB,CAAC;AAEjF,OAAO,EAAC,gBAAgB,EAAC,MAAM,aAAa,CAAC;AAE7C,MAAM,yBAAyB,GAA8C,EAAE,CAAC;AAEhF,MAAM,CAAC,MAAM,8BAA8B,GAAG;IAC7C,IAAI,EAAE,gBAAgB,EAAE;IACxB,KAAK,EAAE,kBAAkB;CACzB,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAA4B;IACnD,wBAAwB,EAAE,yBAAyB;IACnD,uBAAuB,EAAE,8BAA8B;IACvD,QAAQ,EAAE,CAAC,OAAO,CAAC;IACnB,KAAK,EAAE,QAAQ;IACf,UAAU,EAAE,OAAO;IACnB,QAAQ,EAAE;QACT,KAAK,EAAE,gBAAgB;QACvB,IAAI,EAAE,OAAO;KACb;IACD,OAAO,EAAE;QACR,IAAI,EAAE,QAAQ;KACd;CACD,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './types.js';
2
+ export * from './db-def.js';
package/topic/index.js ADDED
@@ -0,0 +1,4 @@
1
+ // Generated DB Item type: topic
2
+ export * from './types.js';
3
+ export * from './db-def.js';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"/Users/tacb0ss/dev/nu-art/beamz/_thunderstorm/ts-messaging/shared/src/main/","sources":["topic/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { DB_Object, DBProto, Proto_DB_Object, VersionsDeclaration } from '@nu-art/ts-common';
2
+ type VersionTypes_Topic = {
3
+ '1.0.0': DB_Topic;
4
+ };
5
+ type Versions = VersionsDeclaration<['1.0.0'], VersionTypes_Topic>;
6
+ type Dependencies = {};
7
+ type UniqueKeys = '_id';
8
+ type GeneratedProps = 'type' | 'refId';
9
+ type Proto = Proto_DB_Object<DB_Topic, 'topics', GeneratedProps, Versions, UniqueKeys, Dependencies>;
10
+ export type DBProto_Topic = DBProto<Proto>;
11
+ export type UI_Topic = DBProto_Topic['uiType'];
12
+ export type DB_Topic = DB_Object & {
13
+ type: string;
14
+ refId: string;
15
+ };
16
+ export {};
package/topic/types.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"/Users/tacb0ss/dev/nu-art/beamz/_thunderstorm/ts-messaging/shared/src/main/","sources":["topic/types.ts"],"names":[],"mappings":""}