backend-test-tools 1.0.0 → 1.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/dist/factory/factory.js +0 -1
- package/dist/factory/factory.js.map +1 -1
- package/dist/factory/factory.types.d.ts +1 -8
- package/dist/factory/factory.types.js.map +1 -1
- package/dist/factory/workers/user.js +0 -8
- package/dist/factory/workers/user.js.map +1 -1
- package/dist/factory/workers/user.types.d.ts +0 -12
- package/dist/factory/workers/user.types.js.map +1 -1
- package/dist/stubs/server-engine/Localizator.js +1 -1
- package/dist/stubs/server-engine/Localizator.js.map +1 -1
- package/dist/stubs/server-engine/Localizator.types.d.ts +1 -1
- package/dist/stubs/server-engine/Localizator.types.js.map +1 -1
- package/dist/stubs/server-engine/PubSub.js +1 -1
- package/dist/stubs/server-engine/PubSub.js.map +1 -1
- package/dist/stubs/server-engine/PushNotification.js +1 -1
- package/dist/stubs/server-engine/PushNotification.js.map +1 -1
- package/dist/stubs/server-engine/sendPush.js +1 -1
- package/dist/stubs/server-engine/sendPush.js.map +1 -1
- package/package.json +2 -2
- package/src/factory/factory.ts +1 -2
- package/src/factory/factory.types.ts +0 -7
- package/src/factory/workers/user.ts +0 -8
- package/src/factory/workers/user.types.ts +0 -12
- package/src/stubs/server-engine/Localizator.ts +1 -1
- package/src/stubs/server-engine/Localizator.types.ts +1 -1
- package/src/stubs/server-engine/PubSub.ts +1 -1
- package/src/stubs/server-engine/PushNotification.ts +1 -1
- package/src/stubs/server-engine/sendPush.ts +1 -1
package/dist/factory/factory.js
CHANGED
|
@@ -8,7 +8,6 @@ var _crypto = require("crypto");
|
|
|
8
8
|
var _workers = require("./workers");
|
|
9
9
|
const modelsMap = {
|
|
10
10
|
connection: _workers.connectionFactoryWorker,
|
|
11
|
-
organization: _workers.organizationFactoryWorker,
|
|
12
11
|
user: _workers.userFactoryWorker
|
|
13
12
|
};
|
|
14
13
|
const factory = exports.factory = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.js","names":["_crypto","require","_workers","modelsMap","connection","connectionFactoryWorker","
|
|
1
|
+
{"version":3,"file":"factory.js","names":["_crypto","require","_workers","modelsMap","connection","connectionFactoryWorker","user","userFactoryWorker","factory","exports","build","name","attributes","buildOptions","Object","keys","includes","Error","worker","instance","id","randomUUID","buildMany","count","instances","i","push"],"sources":["../../src/factory/factory.ts"],"sourcesContent":["import {randomUUID} from 'crypto';\nimport {\n FactoryModel,\n FactoryBuildOptions,\n FactoryModelOverride,\n FactoryReturnType,\n ModelsMap,\n} from './factory.types';\nimport {connectionFactoryWorker, userFactoryWorker} from './workers';\n\nconst modelsMap: ModelsMap = {\n connection: connectionFactoryWorker,\n user: userFactoryWorker,\n};\n\nexport const factory = {\n /**\n * Build an object according to a defined model\n */\n build: function <T extends FactoryModel>(\n name: T,\n attributes: FactoryModelOverride<T> = {},\n buildOptions: FactoryBuildOptions<T> = {},\n ): FactoryReturnType<T> {\n if (!Object.keys(modelsMap).includes(name)) throw new Error(`Factory: unknown model \"${name}\"`);\n const worker = modelsMap[name];\n const instance = worker(buildOptions);\n return {\n id: randomUUID(),\n ...instance,\n ...attributes,\n };\n },\n\n /**\n * Build multiple objects according to a defined model\n */\n buildMany: function <T extends FactoryModel>(\n name: T,\n count: number,\n attributes: FactoryModelOverride<T> = {},\n buildOptions: FactoryBuildOptions<T> = {},\n ): Array<FactoryReturnType<T>> {\n const instances: Array<FactoryReturnType<T>> = [];\n for (let i = 0; i < count; i++) {\n instances.push(this.build(name, attributes, buildOptions));\n }\n return instances;\n },\n};\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAQA,IAAAC,QAAA,GAAAD,OAAA;AAEA,MAAME,SAAoB,GAAG;EAC3BC,UAAU,EAAEC,gCAAuB;EACnCC,IAAI,EAAEC;AACR,CAAC;AAEM,MAAMC,OAAO,GAAAC,OAAA,CAAAD,OAAA,GAAG;EACrB;AACF;AACA;EACEE,KAAK,EAAE,SAAAA,CACLC,IAAO,EACPC,UAAmC,GAAG,CAAC,CAAC,EACxCC,YAAoC,GAAG,CAAC,CAAC,EACnB;IACtB,IAAI,CAACC,MAAM,CAACC,IAAI,CAACZ,SAAS,CAAC,CAACa,QAAQ,CAACL,IAAI,CAAC,EAAE,MAAM,IAAIM,KAAK,CAAC,2BAA2BN,IAAI,GAAG,CAAC;IAC/F,MAAMO,MAAM,GAAGf,SAAS,CAACQ,IAAI,CAAC;IAC9B,MAAMQ,QAAQ,GAAGD,MAAM,CAACL,YAAY,CAAC;IACrC,OAAO;MACLO,EAAE,EAAE,IAAAC,kBAAU,EAAC,CAAC;MAChB,GAAGF,QAAQ;MACX,GAAGP;IACL,CAAC;EACH,CAAC;EAED;AACF;AACA;EACEU,SAAS,EAAE,SAAAA,CACTX,IAAO,EACPY,KAAa,EACbX,UAAmC,GAAG,CAAC,CAAC,EACxCC,YAAoC,GAAG,CAAC,CAAC,EACZ;IAC7B,MAAMW,SAAsC,GAAG,EAAE;IACjD,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGF,KAAK,EAAEE,CAAC,EAAE,EAAE;MAC9BD,SAAS,CAACE,IAAI,CAAC,IAAI,CAAChB,KAAK,CAACC,IAAI,EAAEC,UAAU,EAAEC,YAAY,CAAC,CAAC;IAC5D;IACA,OAAOW,SAAS;EAClB;AACF,CAAC","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ConnectionModel, ConnectionBuildOptions,
|
|
1
|
+
import { ConnectionModel, ConnectionBuildOptions, UserModel, UserBuildOptions } from './workers';
|
|
2
2
|
type FactoryTyping = {
|
|
3
3
|
/** Mapping for the connection model */
|
|
4
4
|
connection: {
|
|
@@ -7,13 +7,6 @@ type FactoryTyping = {
|
|
|
7
7
|
/** Return type for the connection model */
|
|
8
8
|
return: ConnectionModel;
|
|
9
9
|
};
|
|
10
|
-
/** Mapping for the organization model */
|
|
11
|
-
organization: {
|
|
12
|
-
/** Options for the organization model */
|
|
13
|
-
options: any;
|
|
14
|
-
/** Return type for the organization model */
|
|
15
|
-
return: OrganizationModel;
|
|
16
|
-
};
|
|
17
10
|
/** Mapping for the user model */
|
|
18
11
|
user: {
|
|
19
12
|
/** Options for the user model */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.types.js","names":[],"sources":["../../src/factory/factory.types.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport {\n ConnectionModel,\n ConnectionBuildOptions,\n OrganizationModel,\n UserModel,\n UserBuildOptions,\n} from './workers';\n\ntype FactoryTyping = {\n /** Mapping for the connection model */\n connection: {\n /** Options for the connection model */\n options: ConnectionBuildOptions;\n /** Return type for the connection model */\n return: ConnectionModel;\n };\n /** Mapping for the
|
|
1
|
+
{"version":3,"file":"factory.types.js","names":[],"sources":["../../src/factory/factory.types.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport {\n ConnectionModel,\n ConnectionBuildOptions,\n OrganizationModel,\n UserModel,\n UserBuildOptions,\n} from './workers';\n\ntype FactoryTyping = {\n /** Mapping for the connection model */\n connection: {\n /** Options for the connection model */\n options: ConnectionBuildOptions;\n /** Return type for the connection model */\n return: ConnectionModel;\n };\n /** Mapping for the user model */\n user: {\n /** Options for the user model */\n options: UserBuildOptions;\n /** Return type for the user model */\n return: UserModel;\n };\n};\n\nexport type FactoryModel = keyof FactoryTyping;\n\nexport type FactoryModelOverride<T extends FactoryModel> = Partial<FactoryTyping[T]['return']> & {\n /** Id of the model */\n id?: string;\n};\n\nexport type FactoryBuildOptions<T extends FactoryModel> = FactoryTyping[T]['options'];\n\nexport type FactoryReturnType<T extends FactoryModel> = FactoryTyping[T]['return'] & {\n /** Id of the model */\n id: string;\n};\n\nexport type ModelsMap = {\n [T in FactoryModel]: (buildOptions: FactoryTyping[T]['options']) => FactoryTyping[T]['return'];\n};\n"],"mappings":"","ignoreList":[]}
|
|
@@ -22,9 +22,6 @@ function userFactoryWorker(buildOptions = {}) {
|
|
|
22
22
|
lastName
|
|
23
23
|
});
|
|
24
24
|
const random = Math.random().toString(36).substring(7);
|
|
25
|
-
const organizationId = buildOptions.organizationId;
|
|
26
|
-
const organizationMember = buildOptions.member ?? false;
|
|
27
|
-
const organizationAdmin = buildOptions.admin ?? false;
|
|
28
25
|
return {
|
|
29
26
|
firstName,
|
|
30
27
|
lastName,
|
|
@@ -40,11 +37,6 @@ function userFactoryWorker(buildOptions = {}) {
|
|
|
40
37
|
regId: (0, _generators.generateRegId)(),
|
|
41
38
|
locale: (0, _generators.generateLocale)(),
|
|
42
39
|
pictureUrl: _faker.faker.image.avatar(),
|
|
43
|
-
organizationId,
|
|
44
|
-
joinedOrganizationAt: organizationId ? _faker.faker.date.recent() : null,
|
|
45
|
-
organizationAdmin: organizationAdmin,
|
|
46
|
-
requestedToJoinOrganization: organizationMember || organizationAdmin,
|
|
47
|
-
acceptedInOrganization: organizationMember || organizationAdmin,
|
|
48
40
|
linkId: (0, _crypto.randomUUID)(),
|
|
49
41
|
bbId: (0, _crypto.randomUUID)(),
|
|
50
42
|
bbEncrypted: (0, _generators.generateBbEncrypted)(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.js","names":["_crypto","require","_faker","_generators","userFactoryWorker","buildOptions","firstName","faker","person","lastName","email","internet","userName","random","Math","toString","substring","
|
|
1
|
+
{"version":3,"file":"user.js","names":["_crypto","require","_faker","_generators","userFactoryWorker","buildOptions","firstName","faker","person","lastName","email","internet","userName","random","Math","toString","substring","firstNameLastName","firstNameSpaceLastName","lastNameFirstName","lastNameSpaceFirstName","displayName","casualName","formalName","moreRandom","username","regId","generateRegId","locale","generateLocale","pictureUrl","image","avatar","linkId","randomUUID","bbId","bbEncrypted","generateBbEncrypted","signKeyEncrypted","generateSignKeyEncrypted","signKeyPub","generateSignKeyPub","autoConnect","searchable","enableUrlScan","enableMessageTranslation","emailVisibility"],"sources":["../../../src/factory/workers/user.ts"],"sourcesContent":["import { randomUUID } from 'crypto';\nimport { faker } from '@faker-js/faker';\nimport { UserModel, UserBuildOptions } from './user.types';\nimport {\n generateRegId,\n generateLocale,\n generateSignKeyPub,\n generateSignKeyEncrypted,\n generateBbEncrypted\n} from 'generators';\n\n/**\n * Create a random user\n */\nexport function userFactoryWorker(\n buildOptions: UserBuildOptions = {}\n): UserModel {\n const firstName = buildOptions.firstName ?? faker.person.firstName();\n const lastName = buildOptions.lastName ?? faker.person.lastName();\n const email = faker.internet.email({ firstName, lastName });\n const userName = faker.internet.userName({ firstName, lastName });\n const random = Math.random().toString(36).substring(7);\n return {\n firstName,\n lastName,\n firstNameLastName: `${firstName}${lastName}`,\n firstNameSpaceLastName: `${firstName} ${lastName}`,\n lastNameFirstName: `${lastName}${firstName}`,\n lastNameSpaceFirstName: `${lastName} ${firstName}`,\n displayName: `${firstName} ${lastName}`,\n casualName: `${firstName}`,\n formalName: `${firstName}`,\n email: buildOptions.moreRandom ? `${random}${email}` : email,\n username: buildOptions.moreRandom ? `${random}${userName}` : userName,\n regId: generateRegId(),\n locale: generateLocale(),\n pictureUrl: faker.image.avatar(),\n linkId: randomUUID(),\n bbId: randomUUID(),\n bbEncrypted: generateBbEncrypted(),\n signKeyEncrypted: generateSignKeyEncrypted(),\n signKeyPub: generateSignKeyPub(),\n autoConnect: true,\n searchable: true,\n enableUrlScan: true,\n enableMessageTranslation: true,\n emailVisibility: true\n };\n}\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAEA,IAAAE,WAAA,GAAAF,OAAA;AAQA;AACA;AACA;AACO,SAASG,iBAAiBA,CAC/BC,YAA8B,GAAG,CAAC,CAAC,EACxB;EACX,MAAMC,SAAS,GAAGD,YAAY,CAACC,SAAS,IAAIC,YAAK,CAACC,MAAM,CAACF,SAAS,CAAC,CAAC;EACpE,MAAMG,QAAQ,GAAGJ,YAAY,CAACI,QAAQ,IAAIF,YAAK,C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,EAAC,CAAC;IAClCC,gBAAgB,EAAE,IAAAC,oCAAwB,EAAC,CAAC;IAC5CC,UAAU,EAAE,IAAAC,8BAAkB,EAAC,CAAC;IAChCC,WAAW,EAAE,IAAI;IACjBC,UAAU,EAAE,IAAI;IAChBC,aAAa,EAAE,IAAI;IACnBC,wBAAwB,EAAE,IAAI;IAC9BC,eAAe,EAAE;EACnB,CAAC;AACH","ignoreList":[]}
|
|
@@ -28,16 +28,6 @@ export interface UserModel {
|
|
|
28
28
|
locale: string;
|
|
29
29
|
/** URL opf the user's avatar */
|
|
30
30
|
pictureUrl: string;
|
|
31
|
-
/** @deprecated ID of the user's organization */
|
|
32
|
-
organizationId?: string;
|
|
33
|
-
/** @deprecated Date at which the user joined the organization */
|
|
34
|
-
joinedOrganizationAt?: Date | null;
|
|
35
|
-
/** @deprecated Admin status of the user in the organization */
|
|
36
|
-
organizationAdmin: boolean;
|
|
37
|
-
/** @deprecated */
|
|
38
|
-
requestedToJoinOrganization: boolean;
|
|
39
|
-
/** @deprecated */
|
|
40
|
-
acceptedInOrganization: boolean;
|
|
41
31
|
/** User's ID for QR codes */
|
|
42
32
|
linkId: string;
|
|
43
33
|
/** User's BlackBerry ID */
|
|
@@ -65,8 +55,6 @@ export interface UserBuildOptions {
|
|
|
65
55
|
firstName?: string;
|
|
66
56
|
/** User's last name */
|
|
67
57
|
lastName?: string;
|
|
68
|
-
/** Id of the organization to which the user is affiliated */
|
|
69
|
-
organizationId?: string;
|
|
70
58
|
/** Admin status of the user in his organization */
|
|
71
59
|
admin?: boolean;
|
|
72
60
|
/** Membership status of the user in his organization */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.types.js","names":[],"sources":["../../../src/factory/workers/user.types.ts"],"sourcesContent":["/** User model template */\nexport interface UserModel {\n /** User's first name */\n firstName: string;\n /** User's last name */\n lastName: string;\n /** @deprecated */\n firstNameLastName: string;\n /** @deprecated */\n firstNameSpaceLastName: string;\n /** @deprecated */\n lastNameFirstName: string;\n /** @deprecated */\n lastNameSpaceFirstName: string;\n /** User's regular display name */\n displayName: string;\n /** User's casual display name */\n casualName: string;\n /** User's formal display name */\n formalName: string;\n /** User's email address */\n email: string;\n /** @deprecated User's username */\n username: string;\n /** User's RegId */\n regId: string;\n /** User's locale */\n locale: string;\n /** URL opf the user's avatar */\n pictureUrl: string;\n /**
|
|
1
|
+
{"version":3,"file":"user.types.js","names":[],"sources":["../../../src/factory/workers/user.types.ts"],"sourcesContent":["/** User model template */\nexport interface UserModel {\n /** User's first name */\n firstName: string;\n /** User's last name */\n lastName: string;\n /** @deprecated */\n firstNameLastName: string;\n /** @deprecated */\n firstNameSpaceLastName: string;\n /** @deprecated */\n lastNameFirstName: string;\n /** @deprecated */\n lastNameSpaceFirstName: string;\n /** User's regular display name */\n displayName: string;\n /** User's casual display name */\n casualName: string;\n /** User's formal display name */\n formalName: string;\n /** User's email address */\n email: string;\n /** @deprecated User's username */\n username: string;\n /** User's RegId */\n regId: string;\n /** User's locale */\n locale: string;\n /** URL opf the user's avatar */\n pictureUrl: string;\n /** User's ID for QR codes */\n linkId: string;\n /** User's BlackBerry ID */\n bbId: string;\n /** User's BlackBerry encrypted key */\n bbEncrypted: string;\n /** User's signature keys */\n signKeyEncrypted: string;\n /** User's public key */\n signKeyPub: string;\n /** Enables auto-acceptance of contact requests */\n autoConnect: boolean;\n /** Is the user searchable publicly */\n searchable: boolean;\n /** Is URL scanning enabled for the user */\n enableUrlScan: boolean;\n /** Is message translation enabled for the user */\n enableMessageTranslation: boolean;\n /** Is the user's email visible publicly */\n emailVisibility: boolean;\n}\n\n/** User template build options */\nexport interface UserBuildOptions {\n /** User's first name */\n firstName?: string;\n /** User's last name */\n lastName?: string;\n /** Admin status of the user in his organization */\n admin?: boolean;\n /** Membership status of the user in his organization */\n member?: boolean;\n /** Add randomness to avoid collisions when generating a large number of entities */\n moreRandom?: boolean;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.stubLocalizator = stubLocalizator;
|
|
7
|
-
var _Localizator = require("
|
|
7
|
+
var _Localizator = require("node-server-engine/dist/entities/Localizator/Localizator");
|
|
8
8
|
var _sinon = require("sinon");
|
|
9
9
|
const DEFAULT_LOCALE_DATA = {
|
|
10
10
|
enabled: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Localizator.js","names":["_Localizator","require","_sinon","DEFAULT_LOCALE_DATA","enabled","display","names","firstNameFirst","spacing","cloudTranslationKey","stubLocalizator","overrides","synchronize","stub","Localizator","resolves","init","shutdown","getLocaleData","returns","localeData","isValidLocale","isValid"],"sources":["../../../src/stubs/server-engine/Localizator.ts"],"sourcesContent":["import {Localizator} from '
|
|
1
|
+
{"version":3,"file":"Localizator.js","names":["_Localizator","require","_sinon","DEFAULT_LOCALE_DATA","enabled","display","names","firstNameFirst","spacing","cloudTranslationKey","stubLocalizator","overrides","synchronize","stub","Localizator","resolves","init","shutdown","getLocaleData","returns","localeData","isValidLocale","isValid"],"sources":["../../../src/stubs/server-engine/Localizator.ts"],"sourcesContent":["import {Localizator} from 'node-server-engine/dist/entities/Localizator/Localizator';\nimport {stub} from 'sinon';\nimport {LocalizatorStub, LocalizatorStubOptions} from './Localizator.types';\n\nconst DEFAULT_LOCALE_DATA = {\n enabled: true,\n display: 'English',\n names: {\n firstNameFirst: true,\n spacing: true,\n },\n cloudTranslationKey: 'en',\n};\n\n/** Stub the Localizator service */\nexport function stubLocalizator(overrides: LocalizatorStubOptions): LocalizatorStub {\n const synchronize = stub(Localizator, 'synchronize').resolves();\n const init = stub(Localizator, 'init').resolves();\n const shutdown = stub(Localizator, 'shutdown').resolves();\n const getLocaleData = stub(Localizator, 'getLocaleData').returns(\n overrides?.localeData ?? DEFAULT_LOCALE_DATA,\n );\n const isValidLocale = stub(Localizator, 'isValidLocale').returns(overrides?.isValid ?? true);\n return {synchronize, init, shutdown, getLocaleData, isValidLocale};\n}\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAGA,MAAME,mBAAmB,GAAG;EAC1BC,OAAO,EAAE,IAAI;EACbC,OAAO,EAAE,SAAS;EAClBC,KAAK,EAAE;IACLC,cAAc,EAAE,IAAI;IACpBC,OAAO,EAAE;EACX,CAAC;EACDC,mBAAmB,EAAE;AACvB,CAAC;;AAED;AACO,SAASC,eAAeA,CAACC,SAAiC,EAAmB;EAClF,MAAMC,WAAW,GAAG,IAAAC,WAAI,EAACC,wBAAW,EAAE,aAAa,CAAC,CAACC,QAAQ,CAAC,CAAC;EAC/D,MAAMC,IAAI,GAAG,IAAAH,WAAI,EAACC,wBAAW,EAAE,MAAM,CAAC,CAACC,QAAQ,CAAC,CAAC;EACjD,MAAME,QAAQ,GAAG,IAAAJ,WAAI,EAACC,wBAAW,EAAE,UAAU,CAAC,CAACC,QAAQ,CAAC,CAAC;EACzD,MAAMG,aAAa,GAAG,IAAAL,WAAI,EAACC,wBAAW,EAAE,eAAe,CAAC,CAACK,OAAO,CAC9DR,SAAS,EAAES,UAAU,IAAIjB,mBAC3B,CAAC;EACD,MAAMkB,aAAa,GAAG,IAAAR,WAAI,EAACC,wBAAW,EAAE,eAAe,CAAC,CAACK,OAAO,CAACR,SAAS,EAAEW,OAAO,IAAI,IAAI,CAAC;EAC5F,OAAO;IAACV,WAAW;IAAEI,IAAI;IAAEC,QAAQ;IAAEC,aAAa;IAAEG;EAAa,CAAC;AACpE","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LocalizatorLocalizationDataElement } from '
|
|
1
|
+
import { LocalizatorLocalizationDataElement } from 'node-server-engine';
|
|
2
2
|
import { SinonStub } from 'sinon';
|
|
3
3
|
/** Stubbing options for the Localizator */
|
|
4
4
|
export interface LocalizatorStubOptions {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Localizator.types.js","names":[],"sources":["../../../src/stubs/server-engine/Localizator.types.ts"],"sourcesContent":["import {LocalizatorLocalizationDataElement} from '
|
|
1
|
+
{"version":3,"file":"Localizator.types.js","names":[],"sources":["../../../src/stubs/server-engine/Localizator.types.ts"],"sourcesContent":["import {LocalizatorLocalizationDataElement} from 'node-server-engine';\nimport {SinonStub} from 'sinon';\n\n/** Stubbing options for the Localizator */\nexport interface LocalizatorStubOptions {\n /** Forces the return value of the isValidLocale functions */\n isValid?: boolean;\n /** Forces the return value of the getLocaleData functions */\n localeData?: LocalizatorLocalizationDataElement;\n}\n\n/** Stubbed properties of the Localizator entity */\nexport interface LocalizatorStub {\n /** Stub of the synchronize method */\n synchronize: SinonStub;\n /** Stub of the init method */\n init: SinonStub;\n /** Stub of the shutdown method */\n shutdown: SinonStub;\n /** Stub of the getLocaleData method */\n getLocaleData: SinonStub;\n /** Stub of the isValidLocale method */\n isValidLocale: SinonStub;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.stubPubSub = stubPubSub;
|
|
7
|
-
var _nodeServerEngine = require("
|
|
7
|
+
var _nodeServerEngine = require("node-server-engine");
|
|
8
8
|
var _sinon = require("sinon");
|
|
9
9
|
/** Stub the PubSub service */
|
|
10
10
|
function stubPubSub() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PubSub.js","names":["_nodeServerEngine","require","_sinon","stubPubSub","init","stub","PubSub","resolves","shutdown","addPublisher","returns","addSubscriber","publish"],"sources":["../../../src/stubs/server-engine/PubSub.ts"],"sourcesContent":["import {PubSub} from '
|
|
1
|
+
{"version":3,"file":"PubSub.js","names":["_nodeServerEngine","require","_sinon","stubPubSub","init","stub","PubSub","resolves","shutdown","addPublisher","returns","addSubscriber","publish"],"sources":["../../../src/stubs/server-engine/PubSub.ts"],"sourcesContent":["import {PubSub} from 'node-server-engine';\nimport {stub} from 'sinon';\nimport {PubSubStub} from './PubSub.types';\n\n/** Stub the PubSub service */\nexport function stubPubSub(): PubSubStub {\n const init = stub(PubSub, 'init').resolves();\n const shutdown = stub(PubSub, 'shutdown').resolves();\n const addPublisher = stub(PubSub, 'addPublisher').returns();\n const addSubscriber = stub(PubSub, 'addSubscriber').returns();\n const publish = stub(PubSub, 'publish').resolves();\n return {init, shutdown, addPublisher, addSubscriber, publish};\n}\n"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAGA;AACO,SAASE,UAAUA,CAAA,EAAe;EACvC,MAAMC,IAAI,GAAG,IAAAC,WAAI,EAACC,wBAAM,EAAE,MAAM,CAAC,CAACC,QAAQ,CAAC,CAAC;EAC5C,MAAMC,QAAQ,GAAG,IAAAH,WAAI,EAACC,wBAAM,EAAE,UAAU,CAAC,CAACC,QAAQ,CAAC,CAAC;EACpD,MAAME,YAAY,GAAG,IAAAJ,WAAI,EAACC,wBAAM,EAAE,cAAc,CAAC,CAACI,OAAO,CAAC,CAAC;EAC3D,MAAMC,aAAa,GAAG,IAAAN,WAAI,EAACC,wBAAM,EAAE,eAAe,CAAC,CAACI,OAAO,CAAC,CAAC;EAC7D,MAAME,OAAO,GAAG,IAAAP,WAAI,EAACC,wBAAM,EAAE,SAAS,CAAC,CAACC,QAAQ,CAAC,CAAC;EAClD,OAAO;IAACH,IAAI;IAAEI,QAAQ;IAAEC,YAAY;IAAEE,aAAa;IAAEC;EAAO,CAAC;AAC/D","ignoreList":[]}
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.stubPushNotification = stubPushNotification;
|
|
7
|
-
var _nodeServerEngine = require("
|
|
7
|
+
var _nodeServerEngine = require("node-server-engine");
|
|
8
8
|
var _sinon = require("sinon");
|
|
9
9
|
/** Stub the PushNotification service */
|
|
10
10
|
function stubPushNotification() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PushNotification.js","names":["_nodeServerEngine","require","_sinon","stubPushNotification","init","stub","PushNotification","resolves","sendPush"],"sources":["../../../src/stubs/server-engine/PushNotification.ts"],"sourcesContent":["import {PushNotification} from '
|
|
1
|
+
{"version":3,"file":"PushNotification.js","names":["_nodeServerEngine","require","_sinon","stubPushNotification","init","stub","PushNotification","resolves","sendPush"],"sources":["../../../src/stubs/server-engine/PushNotification.ts"],"sourcesContent":["import {PushNotification} from 'node-server-engine';\nimport {stub} from 'sinon';\nimport {PushNotificationStub} from './PushNotification.types';\n\n/** Stub the PushNotification service */\nexport function stubPushNotification(): PushNotificationStub {\n const init = stub(PushNotification, 'init').resolves();\n const sendPush = stub(PushNotification, 'sendPush').resolves();\n\n return {init, sendPush};\n}\n"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAGA;AACO,SAASE,oBAAoBA,CAAA,EAAyB;EAC3D,MAAMC,IAAI,GAAG,IAAAC,WAAI,EAACC,kCAAgB,EAAE,MAAM,CAAC,CAACC,QAAQ,CAAC,CAAC;EACtD,MAAMC,QAAQ,GAAG,IAAAH,WAAI,EAACC,kCAAgB,EAAE,UAAU,CAAC,CAACC,QAAQ,CAAC,CAAC;EAE9D,OAAO;IAACH,IAAI;IAAEI;EAAQ,CAAC;AACzB","ignoreList":[]}
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.stubSendPush = stubSendPush;
|
|
7
|
-
var sendPush = _interopRequireWildcard(require("
|
|
7
|
+
var sendPush = _interopRequireWildcard(require("node-server-engine/dist/utils/sendPush/sendPush"));
|
|
8
8
|
var _sinon = require("sinon");
|
|
9
9
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
10
10
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sendPush.js","names":["sendPush","_interopRequireWildcard","require","_sinon","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","stubSendPush","stub","resolves"],"sources":["../../../src/stubs/server-engine/sendPush.ts"],"sourcesContent":["import * as sendPush from '
|
|
1
|
+
{"version":3,"file":"sendPush.js","names":["sendPush","_interopRequireWildcard","require","_sinon","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","stubSendPush","stub","resolves"],"sources":["../../../src/stubs/server-engine/sendPush.ts"],"sourcesContent":["import * as sendPush from 'node-server-engine/dist/utils/sendPush/sendPush';\nimport {SinonStub, stub} from 'sinon';\n\n/** Stub the sendPush function */\nexport function stubSendPush(): SinonStub {\n return stub(sendPush, 'sendPush').resolves();\n}\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAAsC,SAAAE,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA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description": "Node test tools",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -78,6 +78,6 @@
|
|
|
78
78
|
"supertest": "^4.0.2"
|
|
79
79
|
},
|
|
80
80
|
"peerDependencies": {
|
|
81
|
-
"node-server-engine": "^1.0.
|
|
81
|
+
"node-server-engine": "^1.0.5"
|
|
82
82
|
}
|
|
83
83
|
}
|
package/src/factory/factory.ts
CHANGED
|
@@ -6,11 +6,10 @@ import {
|
|
|
6
6
|
FactoryReturnType,
|
|
7
7
|
ModelsMap,
|
|
8
8
|
} from './factory.types';
|
|
9
|
-
import {connectionFactoryWorker,
|
|
9
|
+
import {connectionFactoryWorker, userFactoryWorker} from './workers';
|
|
10
10
|
|
|
11
11
|
const modelsMap: ModelsMap = {
|
|
12
12
|
connection: connectionFactoryWorker,
|
|
13
|
-
organization: organizationFactoryWorker,
|
|
14
13
|
user: userFactoryWorker,
|
|
15
14
|
};
|
|
16
15
|
|
|
@@ -15,13 +15,6 @@ type FactoryTyping = {
|
|
|
15
15
|
/** Return type for the connection model */
|
|
16
16
|
return: ConnectionModel;
|
|
17
17
|
};
|
|
18
|
-
/** Mapping for the organization model */
|
|
19
|
-
organization: {
|
|
20
|
-
/** Options for the organization model */
|
|
21
|
-
options: any;
|
|
22
|
-
/** Return type for the organization model */
|
|
23
|
-
return: OrganizationModel;
|
|
24
|
-
};
|
|
25
18
|
/** Mapping for the user model */
|
|
26
19
|
user: {
|
|
27
20
|
/** Options for the user model */
|
|
@@ -20,9 +20,6 @@ export function userFactoryWorker(
|
|
|
20
20
|
const email = faker.internet.email({ firstName, lastName });
|
|
21
21
|
const userName = faker.internet.userName({ firstName, lastName });
|
|
22
22
|
const random = Math.random().toString(36).substring(7);
|
|
23
|
-
const organizationId = buildOptions.organizationId;
|
|
24
|
-
const organizationMember = buildOptions.member ?? false;
|
|
25
|
-
const organizationAdmin = buildOptions.admin ?? false;
|
|
26
23
|
return {
|
|
27
24
|
firstName,
|
|
28
25
|
lastName,
|
|
@@ -38,11 +35,6 @@ export function userFactoryWorker(
|
|
|
38
35
|
regId: generateRegId(),
|
|
39
36
|
locale: generateLocale(),
|
|
40
37
|
pictureUrl: faker.image.avatar(),
|
|
41
|
-
organizationId,
|
|
42
|
-
joinedOrganizationAt: organizationId ? faker.date.recent() : null,
|
|
43
|
-
organizationAdmin: organizationAdmin,
|
|
44
|
-
requestedToJoinOrganization: organizationMember || organizationAdmin,
|
|
45
|
-
acceptedInOrganization: organizationMember || organizationAdmin,
|
|
46
38
|
linkId: randomUUID(),
|
|
47
39
|
bbId: randomUUID(),
|
|
48
40
|
bbEncrypted: generateBbEncrypted(),
|
|
@@ -28,16 +28,6 @@ export interface UserModel {
|
|
|
28
28
|
locale: string;
|
|
29
29
|
/** URL opf the user's avatar */
|
|
30
30
|
pictureUrl: string;
|
|
31
|
-
/** @deprecated ID of the user's organization */
|
|
32
|
-
organizationId?: string;
|
|
33
|
-
/** @deprecated Date at which the user joined the organization */
|
|
34
|
-
joinedOrganizationAt?: Date | null;
|
|
35
|
-
/** @deprecated Admin status of the user in the organization */
|
|
36
|
-
organizationAdmin: boolean;
|
|
37
|
-
/** @deprecated */
|
|
38
|
-
requestedToJoinOrganization: boolean;
|
|
39
|
-
/** @deprecated */
|
|
40
|
-
acceptedInOrganization: boolean;
|
|
41
31
|
/** User's ID for QR codes */
|
|
42
32
|
linkId: string;
|
|
43
33
|
/** User's BlackBerry ID */
|
|
@@ -66,8 +56,6 @@ export interface UserBuildOptions {
|
|
|
66
56
|
firstName?: string;
|
|
67
57
|
/** User's last name */
|
|
68
58
|
lastName?: string;
|
|
69
|
-
/** Id of the organization to which the user is affiliated */
|
|
70
|
-
organizationId?: string;
|
|
71
59
|
/** Admin status of the user in his organization */
|
|
72
60
|
admin?: boolean;
|
|
73
61
|
/** Membership status of the user in his organization */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {Localizator} from '
|
|
1
|
+
import {Localizator} from 'node-server-engine/dist/entities/Localizator/Localizator';
|
|
2
2
|
import {stub} from 'sinon';
|
|
3
3
|
import {LocalizatorStub, LocalizatorStubOptions} from './Localizator.types';
|
|
4
4
|
|