@roadmanjs/push 0.0.1
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 +42 -0
- package/dist/config.d.ts +5 -0
- package/dist/config.js +17 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/push/Push.test.d.ts +2 -0
- package/dist/push/Push.test.js +28 -0
- package/dist/push/Push.test.js.map +1 -0
- package/dist/push/index.d.ts +1 -0
- package/dist/push/index.js +18 -0
- package/dist/push/index.js.map +1 -0
- package/dist/push/push.methods.d.ts +16 -0
- package/dist/push/push.methods.js +93 -0
- package/dist/push/push.methods.js.map +1 -0
- package/dist/roadman.d.ts +8 -0
- package/dist/roadman.js +18 -0
- package/dist/roadman.js.map +1 -0
- package/dist/user/UserDevice.model.d.ts +22 -0
- package/dist/user/UserDevice.model.js +76 -0
- package/dist/user/UserDevice.model.js.map +1 -0
- package/dist/user/index.d.ts +1 -0
- package/dist/user/index.js +18 -0
- package/dist/user/index.js.map +1 -0
- package/package.json +83 -0
- package/register/index.js +1 -0
- package/register/transpile-only.js +3 -0
- package/register/type-check.js +3 -0
package/README.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
|
|
2
|
+
<p align="center">
|
|
3
|
+
<h1 align="center"> Roadman - Couchbase UserType Model + Firebase Auth </h1>
|
|
4
|
+
</p>
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
## An auth roadman using a UserType model in Couchbase and firebase-auth
|
|
8
|
+
|
|
9
|
+
### How to use
|
|
10
|
+
```
|
|
11
|
+
yarn add @roadmanjs/auth
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
app.ts
|
|
15
|
+
```ts
|
|
16
|
+
import roadman from 'roadman';
|
|
17
|
+
import {AuthResolvers} from '@roadmanjs/auth';
|
|
18
|
+
|
|
19
|
+
await roadman({
|
|
20
|
+
resolvers: [...AuthResolvers, ...MyOtherResolvers]
|
|
21
|
+
});
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
also exports, middleswares like, isAuth, or FirebaseToken
|
|
25
|
+
|
|
26
|
+
#### Env required
|
|
27
|
+
```sh
|
|
28
|
+
DEBUG=roadman*
|
|
29
|
+
|
|
30
|
+
# Firebasebase service account json string
|
|
31
|
+
FIREBASE_SA={"firebase admmin service account": ""}
|
|
32
|
+
|
|
33
|
+
# Couchbase envs
|
|
34
|
+
COUCHBASE_URL=
|
|
35
|
+
COUCHBASE_BUCKET=
|
|
36
|
+
COUCHBASE_USERNAME=
|
|
37
|
+
COUCHBASE_PASSWORD=
|
|
38
|
+
|
|
39
|
+
# Access token generator secrets
|
|
40
|
+
ACCESS_TOKEN_SECRET=xxxxx
|
|
41
|
+
REFRESH_TOKEN_SECRET=xxxx
|
|
42
|
+
```
|
package/dist/config.d.ts
ADDED
package/dist/config.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.firebaseIos = exports.firebaseAndroid = exports.FIREBASE_SA_ANDROID = exports.FIREBASE_SA_IOS = void 0;
|
|
4
|
+
const utils_1 = require("couchset/dist/utils");
|
|
5
|
+
exports.FIREBASE_SA_IOS = process.env.FIREBASE_SA_IOS;
|
|
6
|
+
exports.FIREBASE_SA_ANDROID = process.env.FIREBASE_SA_ANDROID;
|
|
7
|
+
const serviceAccountIos = (0, utils_1.JSONDATA)(exports.FIREBASE_SA_IOS || {});
|
|
8
|
+
const serviceAccountAndroid = (0, utils_1.JSONDATA)(exports.FIREBASE_SA_ANDROID || {});
|
|
9
|
+
exports.firebaseAndroid = {
|
|
10
|
+
appOptions: serviceAccountAndroid,
|
|
11
|
+
name: serviceAccountAndroid.project_id,
|
|
12
|
+
};
|
|
13
|
+
exports.firebaseIos = {
|
|
14
|
+
appOptions: serviceAccountIos,
|
|
15
|
+
name: serviceAccountIos.project_id,
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;;AACA,+CAA6C;AAChC,QAAA,eAAe,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC;AAC9C,QAAA,mBAAmB,GAAG,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC;AAEnE,MAAM,iBAAiB,GAAQ,IAAA,gBAAQ,EAAC,uBAAe,IAAI,EAAE,CAAC,CAAC;AAC/D,MAAM,qBAAqB,GAAQ,IAAA,gBAAQ,EAAC,2BAAmB,IAAI,EAAE,CAAC,CAAC;AAC1D,QAAA,eAAe,GAAmB;IAC3C,UAAU,EAAE,qBAAqB;IACjC,IAAI,EAAE,qBAAqB,CAAC,UAAU;CACzC,CAAC;AACW,QAAA,WAAW,GAAmB;IACvC,UAAU,EAAE,iBAAiB;IAC7B,IAAI,EAAE,iBAAiB,CAAC,UAAU;CACrC,CAAC"}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./push"), exports);
|
|
18
|
+
__exportStar(require("./roadman"), exports);
|
|
19
|
+
__exportStar(require("./user"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yCAAuB;AACvB,4CAA0B;AAC1B,yCAAuB"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
require("reflect-metadata");
|
|
4
|
+
require("mocha");
|
|
5
|
+
const chai_1 = require("chai");
|
|
6
|
+
const couchset_1 = require("@roadmanjs/couchset");
|
|
7
|
+
const push_methods_1 = require("./push.methods");
|
|
8
|
+
before((done) => {
|
|
9
|
+
(0, couchset_1.startCouchbase)().then(() => done());
|
|
10
|
+
});
|
|
11
|
+
describe('Push', () => {
|
|
12
|
+
it('it should send a notification to user', async () => {
|
|
13
|
+
const userId = '99bc43ba-02ab-4394-b48b-49a39a95443c';
|
|
14
|
+
const sentMessage = await (0, push_methods_1.sendMessageToUser)(userId, {
|
|
15
|
+
data: {
|
|
16
|
+
type: 'tv',
|
|
17
|
+
},
|
|
18
|
+
notification: {
|
|
19
|
+
title: 'Basic Notification',
|
|
20
|
+
body: 'This is a basic notification sent from the server!',
|
|
21
|
+
imageUrl: 'https://my-cdn.com/app-logo.png',
|
|
22
|
+
sound: 'vuga_zing',
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
(0, chai_1.expect)(sentMessage).to.be.not.empty;
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
//# sourceMappingURL=Push.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Push.test.js","sourceRoot":"","sources":["../../src/push/Push.test.ts"],"names":[],"mappings":";;AAAA,4BAA0B;AAC1B,iBAAe;AAEf,+BAA4B;AAC5B,kDAAmD;AACnD,iDAAiD;AAEjD,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE;IACZ,IAAA,yBAAc,GAAE,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC;AACxC,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,MAAM,EAAE,GAAG,EAAE;IAClB,EAAE,CAAC,uCAAuC,EAAE,KAAK,IAAI,EAAE;QACnD,MAAM,MAAM,GAAG,sCAAsC,CAAC;QACtD,MAAM,WAAW,GAAG,MAAM,IAAA,gCAAiB,EAAC,MAAM,EAAE;YAChD,IAAI,EAAE;gBACF,IAAI,EAAE,IAAI;aACb;YACD,YAAY,EAAE;gBACV,KAAK,EAAE,oBAAoB;gBAC3B,IAAI,EAAE,oDAAoD;gBAC1D,QAAQ,EAAE,iCAAiC;gBAC3C,KAAK,EAAE,WAAW;aACrB;SACJ,CAAC,CAAC;QAEH,IAAA,aAAM,EAAC,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC;IACxC,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './push.methods';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./push.methods"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/push/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { MessagingPayload, MessagingOptions, MessagingDevicesResponse } from 'firebase-admin/messaging';
|
|
2
|
+
interface SendNotification {
|
|
3
|
+
options?: MessagingOptions;
|
|
4
|
+
payload: MessagingPayload;
|
|
5
|
+
iosTokens: string[];
|
|
6
|
+
androidTokens: string[];
|
|
7
|
+
}
|
|
8
|
+
export declare const sendNotification: (args: SendNotification) => Promise<MessagingDevicesResponse[] | null>;
|
|
9
|
+
/**
|
|
10
|
+
* How to use sendNotification
|
|
11
|
+
* @param owner
|
|
12
|
+
* @param payload
|
|
13
|
+
* @param options
|
|
14
|
+
*/
|
|
15
|
+
export declare const sendMessageToUser: (owner: string, payload: MessagingPayload, options?: MessagingOptions) => Promise<MessagingDevicesResponse[]>;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.sendMessageToUser = exports.sendNotification = void 0;
|
|
7
|
+
const user_1 = require("../user");
|
|
8
|
+
const auth_1 = require("@roadmanjs/auth");
|
|
9
|
+
const isEmpty_1 = __importDefault(require("lodash/isEmpty"));
|
|
10
|
+
const logs_1 = require("@roadmanjs/logs");
|
|
11
|
+
const utils_1 = require("couchset/dist/utils");
|
|
12
|
+
const firebase_admin_1 = require("@roadmanjs/firebase-admin");
|
|
13
|
+
const config_1 = require("../config");
|
|
14
|
+
const sendNotification = async (args) => {
|
|
15
|
+
const { payload, iosTokens = [], androidTokens = [] } = args;
|
|
16
|
+
const response = [];
|
|
17
|
+
const options = args.options || {
|
|
18
|
+
// Required for background/quit data-only messages on iOS
|
|
19
|
+
contentAvailable: true,
|
|
20
|
+
// Required for background/quit data-only messages on Android
|
|
21
|
+
priority: 'high',
|
|
22
|
+
};
|
|
23
|
+
try {
|
|
24
|
+
const iosClient = await (0, firebase_admin_1.configureFirebase)(config_1.firebaseIos);
|
|
25
|
+
const androidClient = await (0, firebase_admin_1.configureFirebase)(config_1.firebaseAndroid);
|
|
26
|
+
const sendMsg = async (client, tokens) => {
|
|
27
|
+
try {
|
|
28
|
+
const sentMessage = await client.messaging().sendToDevice(tokens, payload, options);
|
|
29
|
+
(0, logs_1.log)('messaging().sendToDevice', JSON.stringify(sentMessage));
|
|
30
|
+
return sentMessage;
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
(0, logs_1.log)('messaging().sendToDevice', error);
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
if (!(0, isEmpty_1.default)(iosTokens)) {
|
|
38
|
+
const iosSent = await sendMsg(iosClient, iosTokens);
|
|
39
|
+
response.push(iosSent);
|
|
40
|
+
}
|
|
41
|
+
if (!(0, isEmpty_1.default)(androidTokens)) {
|
|
42
|
+
const androidSent = await sendMsg(androidClient, androidTokens);
|
|
43
|
+
response.push(androidSent);
|
|
44
|
+
}
|
|
45
|
+
return response;
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
(0, logs_1.log)('error sending notification', error);
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
exports.sendNotification = sendNotification;
|
|
53
|
+
/**
|
|
54
|
+
* How to use sendNotification
|
|
55
|
+
* @param owner
|
|
56
|
+
* @param payload
|
|
57
|
+
* @param options
|
|
58
|
+
*/
|
|
59
|
+
const sendMessageToUser = async (owner, payload, options) => {
|
|
60
|
+
try {
|
|
61
|
+
const [errorUser, existingUser] = await (0, utils_1.awaitTo)(auth_1.UserModel.findById(owner));
|
|
62
|
+
if (errorUser) {
|
|
63
|
+
throw new Error('user not found');
|
|
64
|
+
}
|
|
65
|
+
if (existingUser) {
|
|
66
|
+
const userDevices = await user_1.UserDeviceModel.pagination({
|
|
67
|
+
where: {
|
|
68
|
+
owner,
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
if (!(0, isEmpty_1.default)(userDevices)) {
|
|
72
|
+
const androidTokens = userDevices
|
|
73
|
+
.filter((device) => device.clientType === 'android')
|
|
74
|
+
.map((userDevice) => userDevice.pushtoken);
|
|
75
|
+
const iosTokens = userDevices
|
|
76
|
+
.filter((device) => device.clientType === 'ios')
|
|
77
|
+
.map((userDevice) => userDevice.pushtoken);
|
|
78
|
+
return await (0, exports.sendNotification)({
|
|
79
|
+
androidTokens,
|
|
80
|
+
iosTokens,
|
|
81
|
+
options,
|
|
82
|
+
payload,
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
throw new Error('there are no user devices available');
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
(0, logs_1.log)('error sending message to device', error);
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
exports.sendMessageToUser = sendMessageToUser;
|
|
93
|
+
//# sourceMappingURL=push.methods.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"push.methods.js","sourceRoot":"","sources":["../../src/push/push.methods.ts"],"names":[],"mappings":";;;;;;AAKA,kCAAwD;AACxD,0CAA0C;AAC1C,6DAAqC;AAC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M,IAAA,wBAAgB,EAAC;oBAC1B,aAAa;oBACb,SAAS;oBACT,OAAO;oBACP,OAAO;iBACV,CAAC,CAAC;aACN;YAED,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;SAC1D;KACJ;IAAC,OAAO,KAAK,EAAE;QACZ,IAAA,UAAG,EAAC,iCAAiC,EAAE,KAAK,CAAC,CAAC;KACjD;AACL,CAAC,CAAC;AAxCW,QAAA,iBAAiB,qBAwC5B"}
|
package/dist/roadman.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.pushRoadman = void 0;
|
|
4
|
+
require("dotenv/config");
|
|
5
|
+
const config_1 = require("./config");
|
|
6
|
+
/**
|
|
7
|
+
* An auth roadman using a UserType model in Couchbase and firebase-auth
|
|
8
|
+
* @param RoadmanBuild
|
|
9
|
+
*/
|
|
10
|
+
const pushRoadman = async (args) => {
|
|
11
|
+
if (!config_1.FIREBASE_SA_ANDROID || !config_1.FIREBASE_SA_IOS) {
|
|
12
|
+
throw new Error('Please specify FIREBASE_SA_ANDROID and FIREBASE_SA_IOS');
|
|
13
|
+
}
|
|
14
|
+
return args;
|
|
15
|
+
};
|
|
16
|
+
exports.pushRoadman = pushRoadman;
|
|
17
|
+
exports.default = exports.pushRoadman;
|
|
18
|
+
//# sourceMappingURL=roadman.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"roadman.js","sourceRoot":"","sources":["../src/roadman.ts"],"names":[],"mappings":";;;AAAA,yBAAuB;AAGvB,qCAA8D;AAE9D;;;GAGG;AACI,MAAM,WAAW,GAAY,KAAK,EAAE,IAAkB,EAAyB,EAAE;IACpF,IAAI,CAAC,4BAAmB,IAAI,CAAC,wBAAe,EAAE;QAC1C,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;KAC7E;IACD,OAAO,IAAI,CAAC;AAChB,CAAC,CAAC;AALW,QAAA,WAAW,eAKtB;AAEF,kBAAe,mBAAW,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Model } from 'couchset';
|
|
2
|
+
export declare const userDeviceModelName = "UserDevice";
|
|
3
|
+
/**
|
|
4
|
+
* GraphQL Types start
|
|
5
|
+
*/
|
|
6
|
+
export declare class UserDeviceType {
|
|
7
|
+
id?: string;
|
|
8
|
+
unique?: string;
|
|
9
|
+
owner?: string;
|
|
10
|
+
countryCode?: string;
|
|
11
|
+
pushtoken?: string;
|
|
12
|
+
appversion: string;
|
|
13
|
+
imei: string;
|
|
14
|
+
osid: string;
|
|
15
|
+
osName?: string;
|
|
16
|
+
clientType?: string;
|
|
17
|
+
createdAt?: Date;
|
|
18
|
+
updatedAt?: Date;
|
|
19
|
+
}
|
|
20
|
+
export declare const allUserDeviceModelKeys: string[];
|
|
21
|
+
export declare const UserDeviceModel: Model;
|
|
22
|
+
export default UserDeviceModel;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.UserDeviceModel = exports.allUserDeviceModelKeys = exports.UserDeviceType = exports.userDeviceModelName = void 0;
|
|
10
|
+
const couchset_1 = require("couchset");
|
|
11
|
+
exports.userDeviceModelName = 'UserDevice';
|
|
12
|
+
/**
|
|
13
|
+
* GraphQL Types start
|
|
14
|
+
*/
|
|
15
|
+
let UserDeviceType = class UserDeviceType {
|
|
16
|
+
constructor() {
|
|
17
|
+
this.id = '';
|
|
18
|
+
this.unique = '';
|
|
19
|
+
// User who created this device
|
|
20
|
+
this.owner = '';
|
|
21
|
+
this.countryCode = '';
|
|
22
|
+
this.pushtoken = '';
|
|
23
|
+
this.appversion = '';
|
|
24
|
+
this.imei = '';
|
|
25
|
+
this.osid = '';
|
|
26
|
+
this.osName = '';
|
|
27
|
+
// android, ios, web
|
|
28
|
+
this.clientType = '';
|
|
29
|
+
this.createdAt = new Date();
|
|
30
|
+
this.updatedAt = new Date();
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
__decorate([
|
|
34
|
+
(0, couchset_1.Field)(() => String, { nullable: true })
|
|
35
|
+
], UserDeviceType.prototype, "id", void 0);
|
|
36
|
+
__decorate([
|
|
37
|
+
(0, couchset_1.Field)(() => String, { nullable: true })
|
|
38
|
+
], UserDeviceType.prototype, "unique", void 0);
|
|
39
|
+
__decorate([
|
|
40
|
+
(0, couchset_1.Field)(() => String, { nullable: true })
|
|
41
|
+
], UserDeviceType.prototype, "owner", void 0);
|
|
42
|
+
__decorate([
|
|
43
|
+
(0, couchset_1.Field)(() => String, { nullable: true })
|
|
44
|
+
], UserDeviceType.prototype, "countryCode", void 0);
|
|
45
|
+
__decorate([
|
|
46
|
+
(0, couchset_1.Field)(() => String, { nullable: true })
|
|
47
|
+
], UserDeviceType.prototype, "pushtoken", void 0);
|
|
48
|
+
__decorate([
|
|
49
|
+
(0, couchset_1.Field)(() => String, { nullable: true })
|
|
50
|
+
], UserDeviceType.prototype, "appversion", void 0);
|
|
51
|
+
__decorate([
|
|
52
|
+
(0, couchset_1.Field)(() => String, { nullable: true })
|
|
53
|
+
], UserDeviceType.prototype, "imei", void 0);
|
|
54
|
+
__decorate([
|
|
55
|
+
(0, couchset_1.Field)(() => String, { nullable: true })
|
|
56
|
+
], UserDeviceType.prototype, "osid", void 0);
|
|
57
|
+
__decorate([
|
|
58
|
+
(0, couchset_1.Field)(() => String, { nullable: true })
|
|
59
|
+
], UserDeviceType.prototype, "osName", void 0);
|
|
60
|
+
__decorate([
|
|
61
|
+
(0, couchset_1.Field)(() => String, { nullable: true })
|
|
62
|
+
], UserDeviceType.prototype, "clientType", void 0);
|
|
63
|
+
__decorate([
|
|
64
|
+
(0, couchset_1.Field)(() => Date, { nullable: true })
|
|
65
|
+
], UserDeviceType.prototype, "createdAt", void 0);
|
|
66
|
+
__decorate([
|
|
67
|
+
(0, couchset_1.Field)(() => Date, { nullable: true })
|
|
68
|
+
], UserDeviceType.prototype, "updatedAt", void 0);
|
|
69
|
+
UserDeviceType = __decorate([
|
|
70
|
+
(0, couchset_1.ObjectType)('UserDeviceType')
|
|
71
|
+
], UserDeviceType);
|
|
72
|
+
exports.UserDeviceType = UserDeviceType;
|
|
73
|
+
exports.allUserDeviceModelKeys = Object.getOwnPropertyNames(new UserDeviceType());
|
|
74
|
+
exports.UserDeviceModel = new couchset_1.Model(exports.userDeviceModelName);
|
|
75
|
+
exports.default = exports.UserDeviceModel;
|
|
76
|
+
//# sourceMappingURL=UserDevice.model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UserDevice.model.js","sourceRoot":"","sources":["../../src/user/UserDevice.model.ts"],"names":[],"mappings":";;;;;;;;;AAAA,uCAAkD;AAErC,QAAA,mBAAmB,GAAG,YAAY,CAAC;AAChD;;GAEG;AAGI,IAAM,cAAc,GAApB,MAAM,cAAc;IAApB;QAEH,OAAE,GAAY,EAAE,CAAC;QAGjB,WAAM,GAAY,EAAE,CAAC;QAErB,+BAA+B;QAE/B,UAAK,GAAY,EAAE,CAAC;QAGpB,gBAAW,GAAY,EAAE,CAAC;QAG1B,cAAS,GAAY,EAAE,CAAC;QAGxB,eAAU,GAAG,EAAE,CAAC;QAGhB,SAAI,GAAG,EAAE,CAAC;QAGV,SAAI,GAAG,EAAE,CAAC;QAGV,W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b;AAGzB;IADC,IAAA,gBAAK,EAAC,GAAG,EAAE,CAAC,IAAI,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC;iDACN;AAG9B;IADC,IAAA,gBAAK,EAAC,GAAG,EAAE,CAAC,IAAI,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC;iDACN;AArCrB,cAAc;IAD1B,IAAA,qBAAU,EAAC,gBAAgB,CAAC;GAChB,cAAc,CAsC1B;AAtCY,wCAAc;AAwCd,QAAA,sBAAsB,GAAa,MAAM,CAAC,mBAAmB,CAAC,IAAI,cAAc,EAAE,CAAC,CAAC;AAEpF,QAAA,eAAe,GAAU,IAAI,gBAAK,CAAC,2BAAmB,CAAC,CAAC;AAErE,kBAAe,uBAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './UserDevice.model';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./UserDevice.model"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/user/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAmC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@roadmanjs/push",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "An roadman for push notifications",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"docs/",
|
|
9
|
+
"dist/",
|
|
10
|
+
"register/",
|
|
11
|
+
"LICENSE"
|
|
12
|
+
],
|
|
13
|
+
"author": {
|
|
14
|
+
"name": "Ceddy Muhoza",
|
|
15
|
+
"email": "ceddymuhoza@gmail.com",
|
|
16
|
+
"url": "https://ceddy.org"
|
|
17
|
+
},
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"private": false,
|
|
20
|
+
"scripts": {
|
|
21
|
+
"lint": "tslint \"src/**/*.ts\" --project tsconfig.json",
|
|
22
|
+
"build": "rm -rf dist && ./node_modules/.bin/tsc --skipLibCheck",
|
|
23
|
+
"push": "mocha src/push/*test.ts --exit",
|
|
24
|
+
"users": "mocha src/user/*test.ts --exit",
|
|
25
|
+
"eslint": "eslint ./src --fix --ext=ts"
|
|
26
|
+
},
|
|
27
|
+
"lint-staged": {
|
|
28
|
+
"*.{ts,tsx}": [
|
|
29
|
+
"npm run eslint"
|
|
30
|
+
]
|
|
31
|
+
},
|
|
32
|
+
"husky": {
|
|
33
|
+
"hooks": {
|
|
34
|
+
"pre-commit": "lint-staged"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@faker-js/faker": "^7.5.0",
|
|
39
|
+
"@types/chai": "^4.2.14",
|
|
40
|
+
"@types/chalk": "^2.2.0",
|
|
41
|
+
"@types/debug": "^4.1.5",
|
|
42
|
+
"@types/dotenv": "^8.2.0",
|
|
43
|
+
"@types/jsonwebtoken": "^8.5.8",
|
|
44
|
+
"@types/lodash": "^4.14.168",
|
|
45
|
+
"@types/mocha": "^8.2.0",
|
|
46
|
+
"@types/node": "^10.0.3",
|
|
47
|
+
"@types/source-map-support": "^0.4.0",
|
|
48
|
+
"@typescript-eslint/eslint-plugin": "^3.4.0",
|
|
49
|
+
"@typescript-eslint/parser": "^3.4.0",
|
|
50
|
+
"chai": "^4.2.0",
|
|
51
|
+
"eslint": "7.32.0",
|
|
52
|
+
"eslint-config-prettier": "^6.11.0",
|
|
53
|
+
"eslint-loader": "^4.0.2",
|
|
54
|
+
"eslint-plugin-import": "^2.20.2",
|
|
55
|
+
"eslint-plugin-json": "^2.1.1",
|
|
56
|
+
"eslint-plugin-prettier": "^3.1.4",
|
|
57
|
+
"eslint-plugin-simple-import-sort": "^5.0.2",
|
|
58
|
+
"eslint-plugin-typescript": "^0.14.0",
|
|
59
|
+
"husky": "^4.2.5",
|
|
60
|
+
"lint-staged": "^10.1.7",
|
|
61
|
+
"mocha": "^9.2.0",
|
|
62
|
+
"prettier": "^2.0.5",
|
|
63
|
+
"rimraf": "^2.5.4",
|
|
64
|
+
"ts-node": "^9.1.1",
|
|
65
|
+
"tslint": "^5.11.0",
|
|
66
|
+
"tslint-config-standard": "^8.0.1",
|
|
67
|
+
"typescript": "^4.4.3"
|
|
68
|
+
},
|
|
69
|
+
"peerDependencies": {
|
|
70
|
+
"@roadmanjs/auth": ">=0.0.27",
|
|
71
|
+
"@roadmanjs/couchset": ">=0.0.3",
|
|
72
|
+
"@roadmanjs/firebase-admin": ">=0.0.17",
|
|
73
|
+
"@roadmanjs/logs": ">=0.0.1",
|
|
74
|
+
"typescript": ">=2.0"
|
|
75
|
+
},
|
|
76
|
+
"dependencies": {
|
|
77
|
+
"@roadmanjs/auth": "^0.0.27",
|
|
78
|
+
"@roadmanjs/couchset": "^0.0.3",
|
|
79
|
+
"@roadmanjs/firebase-admin": "^0.0.17",
|
|
80
|
+
"@roadmanjs/logs": "^0.0.1",
|
|
81
|
+
"@roadmanjs/utils": "^0.0.4"
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require('../').register()
|