@nu-art/push-pub-sub-shared 0.400.7

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/api.d.ts ADDED
@@ -0,0 +1,14 @@
1
+ import { ApiDefResolver, BodyApi } from '@nu-art/thunderstorm-shared';
2
+ import { BaseSubscriptionData, PushMessage, Request_PushRegister } from './types.js';
3
+ export type Request_PushTest = {
4
+ message: PushMessage<any, any, any>;
5
+ };
6
+ export type ApiStruct_PushMessages = {
7
+ v1: {
8
+ test: BodyApi<void, Request_PushTest>;
9
+ unregister: BodyApi<void, Request_PushRegister, BaseSubscriptionData>;
10
+ register: BodyApi<void, Request_PushRegister, BaseSubscriptionData>;
11
+ registerAll: BodyApi<void, Request_PushRegister, BaseSubscriptionData[]>;
12
+ };
13
+ };
14
+ export declare const ApiDef_PushMessages: ApiDefResolver<ApiStruct_PushMessages>;
package/api.js ADDED
@@ -0,0 +1,26 @@
1
+ /*
2
+ * A generic push pub sub infra for webapps
3
+ *
4
+ * Copyright (C) 2020 Adam van der Kruk aka TacB0sS
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ import { HttpMethod } from '@nu-art/thunderstorm-shared';
19
+ export const ApiDef_PushMessages = {
20
+ v1: {
21
+ test: { method: HttpMethod.POST, path: 'v1/push-messages/test' },
22
+ unregister: { method: HttpMethod.POST, path: 'v1/push-messages/unregister' },
23
+ register: { method: HttpMethod.POST, path: 'v1/push-messages/register' },
24
+ registerAll: { method: HttpMethod.POST, path: 'v1/push-messages/register-all' }
25
+ }
26
+ };
package/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './api.js';
2
+ export * from './types.js';
package/index.js ADDED
@@ -0,0 +1,19 @@
1
+ /*
2
+ * A generic push pub sub infra for webapps
3
+ *
4
+ * Copyright (C) 2020 Adam van der Kruk aka TacB0sS
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ export * from './api.js';
19
+ export * from './types.js';
package/package.json ADDED
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "@nu-art/push-pub-sub-shared",
3
+ "version": "0.400.7",
4
+ "description": "push-pub-sub Shared",
5
+ "keywords": [
6
+ "TacB0sS",
7
+ "express",
8
+ "infra",
9
+ "nu-art",
10
+ "push-pub-sub",
11
+ "thunderstorm",
12
+ "typescript"
13
+ ],
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+ssh://git@github.com:nu-art-js/push-pub-sub.git"
17
+ },
18
+ "publishConfig": {
19
+ "directory": "dist",
20
+ "linkDirectory": true
21
+ },
22
+ "license": "Apache-2.0",
23
+ "author": "TacB0sS",
24
+ "scripts": {
25
+ "build": "tsc -b -f"
26
+ },
27
+ "dependencies": {
28
+ "@nu-art/thunderstorm-shared": "0.400.7",
29
+ "@nu-art/ts-styles": "0.400.7",
30
+ "@nu-art/permissions-shared": "0.400.7",
31
+ "@nu-art/ts-common": "0.400.7",
32
+ "@nu-art/firebase-shared": "0.400.7",
33
+ "@nu-art/user-account-shared": "0.400.7",
34
+ "firebase": "^11.9.0",
35
+ "firebase-admin": "13.4.0",
36
+ "moment": "^2.29.4",
37
+ "react": "^18.0.0"
38
+ },
39
+ "devDependencies": {
40
+ "@types/react": "^18.0.0"
41
+ },
42
+ "unitConfig": {
43
+ "type": "typescript-lib"
44
+ },
45
+ "type": "module",
46
+ "exports": {
47
+ ".": {
48
+ "types": "./index.d.ts",
49
+ "import": "./index.js"
50
+ },
51
+ "./*": {
52
+ "types": "./*.d.ts",
53
+ "import": "./*.js"
54
+ }
55
+ }
56
+ }
@@ -0,0 +1,5 @@
1
+ import { ApiDefResolver } from '@nu-art/thunderstorm-shared';
2
+ export type ApiStruct_PushMessagesHistory = {
3
+ _v1: {};
4
+ };
5
+ export declare const ApiDef_PushMessagesHistory: ApiDefResolver<ApiStruct_PushMessagesHistory>;
@@ -0,0 +1,3 @@
1
+ export const ApiDef_PushMessagesHistory = {
2
+ _v1: {}
3
+ };
@@ -0,0 +1,3 @@
1
+ import { DBDef_V3 } from '@nu-art/ts-common';
2
+ import { DBProto_PushMessagesHistory } from './types.js';
3
+ export declare const DBDef_PushMessagesHistory: DBDef_V3<DBProto_PushMessagesHistory>;
@@ -0,0 +1,24 @@
1
+ import { convertUpperCamelCase, tsValidateBoolean, tsValidateMustExist, tsValidateString, tsValidateUniqueId } from '@nu-art/ts-common';
2
+ import { PushPubSubDBGroup } from '../shared.js';
3
+ const Validator_ModifiableProps = {};
4
+ const Validator_GeneratedProps = {
5
+ pushSessionId: tsValidateString(),
6
+ token: tsValidateString(),
7
+ message: tsValidateMustExist,
8
+ read: tsValidateBoolean(),
9
+ originatingAccountId: tsValidateUniqueId,
10
+ };
11
+ export const DBDef_PushMessagesHistory = {
12
+ modifiablePropsValidator: Validator_ModifiableProps,
13
+ generatedPropsValidator: Validator_GeneratedProps,
14
+ versions: ['1.0.0'],
15
+ dbKey: 'push-messages-history',
16
+ entityName: convertUpperCamelCase('PushMessagesHistory', '-').toLowerCase(),
17
+ frontend: {
18
+ group: PushPubSubDBGroup,
19
+ name: 'message-history',
20
+ },
21
+ backend: {
22
+ name: 'push-messages-history'
23
+ }
24
+ };
@@ -0,0 +1,3 @@
1
+ export * from './types.js';
2
+ export * from './db-def.js';
3
+ export * from './api-def.js';
@@ -0,0 +1,4 @@
1
+ // Generated DB Item type: PushMessagesHistory
2
+ export * from './types.js';
3
+ export * from './db-def.js';
4
+ export * from './api-def.js';
@@ -0,0 +1,19 @@
1
+ import { DB_Object, DBProto, Proto_DB_Object, VersionsDeclaration } from '@nu-art/ts-common';
2
+ type VersionTypes_PushMessagesHistory = {
3
+ '1.0.0': DB_PushMessagesHistory;
4
+ };
5
+ type Versions = VersionsDeclaration<['1.0.0'], VersionTypes_PushMessagesHistory>;
6
+ type Dependencies = {};
7
+ type UniqueKeys = '_id';
8
+ type GeneratedKeys = 'pushSessionId' | 'token' | 'message' | 'read' | 'originatingAccountId';
9
+ type Proto = Proto_DB_Object<DB_PushMessagesHistory, 'push-messages-history', GeneratedKeys, Versions, UniqueKeys, Dependencies>;
10
+ export type DBProto_PushMessagesHistory = DBProto<Proto>;
11
+ export type UI_PushMessagesHistory = DBProto_PushMessagesHistory['uiType'];
12
+ export type DB_PushMessagesHistory = DB_Object & {
13
+ pushSessionId: string;
14
+ token: string;
15
+ message: any;
16
+ read: boolean;
17
+ originatingAccountId: string;
18
+ };
19
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ import { ApiDefResolver } from '@nu-art/thunderstorm-shared';
2
+ export type ApiStruct_PushSession = {
3
+ _v1: {};
4
+ };
5
+ export declare const ApiDef_PushSession: ApiDefResolver<ApiStruct_PushSession>;
@@ -0,0 +1,3 @@
1
+ export const ApiDef_PushSession = {
2
+ _v1: {}
3
+ };
@@ -0,0 +1,3 @@
1
+ import { DBDef_V3 } from '@nu-art/ts-common';
2
+ import { DBProto_PushSession } from './types.js';
3
+ export declare const DBDef_PushSession: DBDef_V3<DBProto_PushSession>;
@@ -0,0 +1,24 @@
1
+ import { convertUpperCamelCase, tsValidateString, tsValidateTimestamp, tsValidateUniqueId } from '@nu-art/ts-common';
2
+ import { PushPubSubDBGroup } from '../shared.js';
3
+ const Validator_ModifiableProps = {
4
+ accountId: tsValidateUniqueId,
5
+ pushSessionId: tsValidateString(),
6
+ firebaseToken: tsValidateString(),
7
+ timestamp: tsValidateTimestamp()
8
+ };
9
+ const Validator_GeneratedProps = {};
10
+ export const DBDef_PushSession = {
11
+ modifiablePropsValidator: Validator_ModifiableProps,
12
+ generatedPropsValidator: Validator_GeneratedProps,
13
+ versions: ['1.0.0'],
14
+ uniqueKeys: ['pushSessionId'],
15
+ dbKey: 'push-session',
16
+ entityName: convertUpperCamelCase('PushSession', '-').toLowerCase(),
17
+ frontend: {
18
+ group: PushPubSubDBGroup,
19
+ name: 'session',
20
+ },
21
+ backend: {
22
+ name: 'push-session'
23
+ }
24
+ };
@@ -0,0 +1,3 @@
1
+ export * from './types.js';
2
+ export * from './db-def.js';
3
+ export * from './api-def.js';
@@ -0,0 +1,4 @@
1
+ // Generated DB Item type: PushSession
2
+ export * from './types.js';
3
+ export * from './db-def.js';
4
+ export * from './api-def.js';
@@ -0,0 +1,16 @@
1
+ import { DB_Object, DBProto, Proto_DB_Object, VersionsDeclaration } from '@nu-art/ts-common';
2
+ import { FirebaseToken, PushSessionId } from '../types.js';
3
+ type VersionTypes_PushSession = {
4
+ '1.0.0': DB_PushSession;
5
+ };
6
+ type Versions = VersionsDeclaration<['1.0.0'], VersionTypes_PushSession>;
7
+ type Dependencies = {};
8
+ type UniqueKeys = 'pushSessionId';
9
+ type Proto = Proto_DB_Object<DB_PushSession, 'push-session', never, Versions, UniqueKeys, Dependencies>;
10
+ export type DBProto_PushSession = DBProto<Proto>;
11
+ export type UI_PushSession = DBProto_PushSession['uiType'];
12
+ export type DB_PushSession = DB_Object & FirebaseToken & PushSessionId & {
13
+ timestamp: number;
14
+ accountId: string;
15
+ };
16
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ import { ApiDefResolver } from '@nu-art/thunderstorm-shared';
2
+ export type ApiStruct_PushSubscription = {
3
+ _v1: {};
4
+ };
5
+ export declare const ApiDef_PushSubscription: ApiDefResolver<ApiStruct_PushSubscription>;
@@ -0,0 +1,3 @@
1
+ export const ApiDef_PushSubscription = {
2
+ _v1: {}
3
+ };
@@ -0,0 +1,3 @@
1
+ import { DBDef_V3 } from '@nu-art/ts-common';
2
+ import { DBProto_PushSubscription } from './types.js';
3
+ export declare const DBDef_PushSubscription: DBDef_V3<DBProto_PushSubscription>;
@@ -0,0 +1,33 @@
1
+ import { convertUpperCamelCase, exists, tsValidateDynamicObject, tsValidateMustExist, tsValidateNumber, tsValidateResult, tsValidateString } from '@nu-art/ts-common';
2
+ import { PushPubSubDBGroup } from '../shared.js';
3
+ const Validator_FilterKey = (value) => {
4
+ if (typeof value === 'string')
5
+ return tsValidateResult(value, tsValidateString());
6
+ if (typeof value === 'number')
7
+ return tsValidateResult(value, tsValidateNumber());
8
+ if (exists(value))
9
+ return `expected type number | string but received ${typeof value}`;
10
+ return tsValidateResult(value, tsValidateMustExist);
11
+ };
12
+ const Validator_ModifiableProps = {
13
+ pushSessionId: tsValidateString(),
14
+ filter: tsValidateDynamicObject(Validator_FilterKey, tsValidateString(), false),
15
+ topic: tsValidateString(200)
16
+ };
17
+ const Validator_GeneratedProps = {
18
+ //
19
+ };
20
+ export const DBDef_PushSubscription = {
21
+ modifiablePropsValidator: Validator_ModifiableProps,
22
+ generatedPropsValidator: Validator_GeneratedProps,
23
+ versions: ['1.0.0'],
24
+ dbKey: 'push-subscription',
25
+ entityName: convertUpperCamelCase('PushSubscription', '-').toLowerCase(),
26
+ frontend: {
27
+ group: PushPubSubDBGroup,
28
+ name: 'subscription',
29
+ },
30
+ backend: {
31
+ name: 'push-subscription'
32
+ }
33
+ };
@@ -0,0 +1,3 @@
1
+ export * from './types.js';
2
+ export * from './db-def.js';
3
+ export * from './api-def.js';
@@ -0,0 +1,4 @@
1
+ // Generated DB Item type: PushSubscription
2
+ export * from './types.js';
3
+ export * from './db-def.js';
4
+ export * from './api-def.js';
@@ -0,0 +1,13 @@
1
+ import { DB_Object, DBProto, Proto_DB_Object, VersionsDeclaration } from '@nu-art/ts-common';
2
+ import { BaseSubscriptionData, PushSessionId } from '../types.js';
3
+ type VersionTypes_PushSubscription = {
4
+ '1.0.0': DB_PushSubscription;
5
+ };
6
+ type Versions = VersionsDeclaration<['1.0.0'], VersionTypes_PushSubscription>;
7
+ type Dependencies = {};
8
+ type UniqueKeys = '_id';
9
+ type Proto = Proto_DB_Object<DB_PushSubscription, 'push-subscription', never, Versions, UniqueKeys, Dependencies>;
10
+ export type DBProto_PushSubscription = DBProto<Proto>;
11
+ export type UI_PushSubscription = DBProto_PushSubscription['uiType'];
12
+ export type DB_PushSubscription = DB_Object & PushSessionId & BaseSubscriptionData;
13
+ export {};
@@ -0,0 +1 @@
1
+ export {};
package/shared.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare const PushPubSubDBGroup = "push-pub-sub";
package/shared.js ADDED
@@ -0,0 +1 @@
1
+ export const PushPubSubDBGroup = 'push-pub-sub';
package/types.d.ts ADDED
@@ -0,0 +1,46 @@
1
+ import { DB_Object } from '@nu-art/ts-common';
2
+ export type FilterProps = {
3
+ [prop: string]: string | number;
4
+ };
5
+ export type BaseSubscriptionData = {
6
+ filter?: FilterProps;
7
+ topic: string;
8
+ };
9
+ export type Request_PushRegister = FirebaseToken & PushSessionId & {
10
+ subscriptions: BaseSubscriptionData[];
11
+ };
12
+ export type DB_PushSession = FirebaseToken & PushSessionId & {
13
+ timestamp: number;
14
+ userId: string;
15
+ };
16
+ export type DB_Notifications<MessageType> = DB_Object & {
17
+ message: MessageType;
18
+ userId?: string;
19
+ timestamp: number;
20
+ read: boolean;
21
+ persistent?: boolean;
22
+ };
23
+ export type DB_PushSubscription = PushSessionId & BaseSubscriptionData;
24
+ export type FirebaseToken = {
25
+ firebaseToken: string;
26
+ };
27
+ export type PushSessionId = {
28
+ pushSessionId: string;
29
+ };
30
+ export type PushMessage<Topic extends string, Filter extends FilterProps, Data = never> = {
31
+ topic: Topic;
32
+ filter: Filter;
33
+ data: Data;
34
+ };
35
+ export type PushMessage_PayloadWrapper = {
36
+ sessionId: string;
37
+ payload: string;
38
+ };
39
+ export type PushMessage_Payload<MessageType extends PushMessage<any, any, any> = PushMessage<any, any, any>> = BaseSubscriptionData & {
40
+ _id: string;
41
+ timestamp: number;
42
+ message: MessageType['data'];
43
+ };
44
+ export interface OnPushMessageReceived<MessageType extends PushMessage<any, any, any> = PushMessage<any, any, any>> {
45
+ __onMessageReceived(notification: PushMessage_Payload<MessageType>): void;
46
+ }
package/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};