starta.microservice 0.1.2209
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/lib/Exception.d.ts +21 -0
- package/lib/Exception.js +56 -0
- package/lib/Exception.js.map +1 -0
- package/lib/adapters/aws/index.d.ts +5 -0
- package/lib/adapters/aws/index.js +15 -0
- package/lib/adapters/aws/index.js.map +1 -0
- package/lib/adapters/database/DBScripts/BaseMigration.d.ts +11 -0
- package/lib/adapters/database/DBScripts/BaseMigration.js +12 -0
- package/lib/adapters/database/DBScripts/BaseMigration.js.map +1 -0
- package/lib/adapters/database/DBScripts/DBInitialise.d.ts +4 -0
- package/lib/adapters/database/DBScripts/DBInitialise.js +22 -0
- package/lib/adapters/database/DBScripts/DBInitialise.js.map +1 -0
- package/lib/adapters/database/index.d.ts +25 -0
- package/lib/adapters/database/index.js +88 -0
- package/lib/adapters/database/index.js.map +1 -0
- package/lib/adapters/logger/index.d.ts +14 -0
- package/lib/adapters/logger/index.js +113 -0
- package/lib/adapters/logger/index.js.map +1 -0
- package/lib/adapters/rabbitmq/index.d.ts +17 -0
- package/lib/adapters/rabbitmq/index.js +145 -0
- package/lib/adapters/rabbitmq/index.js.map +1 -0
- package/lib/adapters/redisService/Listener.d.ts +10 -0
- package/lib/adapters/redisService/Listener.js +35 -0
- package/lib/adapters/redisService/Listener.js.map +1 -0
- package/lib/adapters/redisService/Publisher.d.ts +7 -0
- package/lib/adapters/redisService/Publisher.js +38 -0
- package/lib/adapters/redisService/Publisher.js.map +1 -0
- package/lib/adapters/redisService/RedisAdapter.d.ts +29 -0
- package/lib/adapters/redisService/RedisAdapter.js +161 -0
- package/lib/adapters/redisService/RedisAdapter.js.map +1 -0
- package/lib/adapters/redisService/index.d.ts +71 -0
- package/lib/adapters/redisService/index.js +337 -0
- package/lib/adapters/redisService/index.js.map +1 -0
- package/lib/adapters/redisService/types.d.ts +14 -0
- package/lib/adapters/redisService/types.js +3 -0
- package/lib/adapters/redisService/types.js.map +1 -0
- package/lib/config.d.ts +103 -0
- package/lib/config.js +126 -0
- package/lib/config.js.map +1 -0
- package/lib/entities/Account.d.ts +191 -0
- package/lib/entities/Account.js +62 -0
- package/lib/entities/Account.js.map +1 -0
- package/lib/entities/Base.d.ts +29 -0
- package/lib/entities/Base.js +62 -0
- package/lib/entities/Base.js.map +1 -0
- package/lib/entities/Version.d.ts +6 -0
- package/lib/entities/Version.js +10 -0
- package/lib/entities/Version.js.map +1 -0
- package/lib/entities/types/index.d.ts +108 -0
- package/lib/entities/types/index.js +3 -0
- package/lib/entities/types/index.js.map +1 -0
- package/lib/helpers/index.d.ts +24 -0
- package/lib/helpers/index.js +151 -0
- package/lib/helpers/index.js.map +1 -0
- package/lib/repositories/Repository.d.ts +39 -0
- package/lib/repositories/Repository.js +403 -0
- package/lib/repositories/Repository.js.map +1 -0
- package/lib/repositories/index.d.ts +6 -0
- package/lib/repositories/index.js +16 -0
- package/lib/repositories/index.js.map +1 -0
- package/lib/repositories/types/AggregateOptions.d.ts +4 -0
- package/lib/repositories/types/AggregateOptions.js +6 -0
- package/lib/repositories/types/AggregateOptions.js.map +1 -0
- package/lib/repositories/types/FindOptions.d.ts +16 -0
- package/lib/repositories/types/FindOptions.js +6 -0
- package/lib/repositories/types/FindOptions.js.map +1 -0
- package/lib/repositories/types/IQuery.d.ts +4 -0
- package/lib/repositories/types/IQuery.js +3 -0
- package/lib/repositories/types/IQuery.js.map +1 -0
- package/lib/repositories/types/JoinOptions.d.ts +8 -0
- package/lib/repositories/types/JoinOptions.js +6 -0
- package/lib/repositories/types/JoinOptions.js.map +1 -0
- package/lib/services/ServiceExecutor.d.ts +16 -0
- package/lib/services/ServiceExecutor.js +169 -0
- package/lib/services/ServiceExecutor.js.map +1 -0
- package/lib/services/ServiceExecutorHandler.d.ts +13 -0
- package/lib/services/ServiceExecutorHandler.js +323 -0
- package/lib/services/ServiceExecutorHandler.js.map +1 -0
- package/lib/services/ServiceFactoryBase.d.ts +15 -0
- package/lib/services/ServiceFactoryBase.js +11 -0
- package/lib/services/ServiceFactoryBase.js.map +1 -0
- package/lib/services/ServiceHandlerBase.d.ts +30 -0
- package/lib/services/ServiceHandlerBase.js +113 -0
- package/lib/services/ServiceHandlerBase.js.map +1 -0
- package/lib/services/dataSelectors.d.ts +38 -0
- package/lib/services/dataSelectors.js +60 -0
- package/lib/services/dataSelectors.js.map +1 -0
- package/lib/timeProvider.d.ts +14 -0
- package/lib/timeProvider.js +37 -0
- package/lib/timeProvider.js.map +1 -0
- package/lib/types/index.d.ts +72 -0
- package/lib/types/index.js +14 -0
- package/lib/types/index.js.map +1 -0
- package/package.json +51 -0
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import Base from './Base';
|
|
2
|
+
import { Service, OrganizationSchedule, BookingWidgetStyleType, Schedule } from './types';
|
|
3
|
+
declare class Account extends Base {
|
|
4
|
+
_passwordHash: string;
|
|
5
|
+
login: string;
|
|
6
|
+
firstName: string;
|
|
7
|
+
lastName: string;
|
|
8
|
+
externalId: string;
|
|
9
|
+
email: string;
|
|
10
|
+
emailConfirmed: boolean;
|
|
11
|
+
phone: string;
|
|
12
|
+
phoneConfirmed: boolean;
|
|
13
|
+
password: string;
|
|
14
|
+
owner: string;
|
|
15
|
+
referralId: string;
|
|
16
|
+
acceptedTermsAndConditions: boolean;
|
|
17
|
+
showTimeInProviderTz?: boolean;
|
|
18
|
+
demo: boolean;
|
|
19
|
+
socialNetworkIds?: {
|
|
20
|
+
googleId: string;
|
|
21
|
+
};
|
|
22
|
+
approvedToSearchAt?: Date;
|
|
23
|
+
devices: {
|
|
24
|
+
[key: string]: {
|
|
25
|
+
os: 'ios' | 'android';
|
|
26
|
+
expoPushToken: string;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
onboardingStep: 'info' | 'schedules' | 'members' | 'services' | 'integrations' | 'success';
|
|
30
|
+
bookingWidget: {
|
|
31
|
+
settings: {
|
|
32
|
+
enabled: boolean;
|
|
33
|
+
bookingInterval: number;
|
|
34
|
+
theme: string;
|
|
35
|
+
};
|
|
36
|
+
styles: BookingWidgetStyleType;
|
|
37
|
+
};
|
|
38
|
+
mfuDiscountSettings: {
|
|
39
|
+
enabled: boolean;
|
|
40
|
+
discount: number;
|
|
41
|
+
};
|
|
42
|
+
integrations?: {
|
|
43
|
+
liqpay?: {
|
|
44
|
+
enabled: boolean;
|
|
45
|
+
publicKey: string;
|
|
46
|
+
privateKey: string;
|
|
47
|
+
};
|
|
48
|
+
way4pay?: {
|
|
49
|
+
enabled: boolean;
|
|
50
|
+
merchantAccount: string;
|
|
51
|
+
merchantSecretKey: string;
|
|
52
|
+
};
|
|
53
|
+
website?: {
|
|
54
|
+
enabled: boolean;
|
|
55
|
+
openButtonEnabled: boolean;
|
|
56
|
+
};
|
|
57
|
+
turbosms?: {
|
|
58
|
+
enabled: boolean;
|
|
59
|
+
authToken: string;
|
|
60
|
+
verified: boolean;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
services: Array<Service>;
|
|
64
|
+
rooms: Array<{
|
|
65
|
+
id: string;
|
|
66
|
+
name: string;
|
|
67
|
+
[x: string]: any;
|
|
68
|
+
}>;
|
|
69
|
+
snSubscribers?: '<1000' | '1000-5000' | '5000-10000' | '10000-50000' | '50000-100000' | '100000+';
|
|
70
|
+
members: Array<{
|
|
71
|
+
login: string;
|
|
72
|
+
isActive: boolean;
|
|
73
|
+
schedule?: Schedule;
|
|
74
|
+
languages?: Array<string>;
|
|
75
|
+
[key: string]: any;
|
|
76
|
+
}>;
|
|
77
|
+
invites: Array<{
|
|
78
|
+
name: string;
|
|
79
|
+
roles: string[];
|
|
80
|
+
code: string;
|
|
81
|
+
}>;
|
|
82
|
+
answerForHowManyEmployees?: '1' | '2-10' | '10-100' | '100+';
|
|
83
|
+
countryIso2: string;
|
|
84
|
+
type: 'user' | 'organization';
|
|
85
|
+
timeZone: string;
|
|
86
|
+
name: string;
|
|
87
|
+
nameTranslations?: {
|
|
88
|
+
'en-us'?: string;
|
|
89
|
+
'uk-ua'?: string;
|
|
90
|
+
'ru-ru'?: string;
|
|
91
|
+
};
|
|
92
|
+
subtitle?: {
|
|
93
|
+
'default'?: string;
|
|
94
|
+
'en-us'?: string;
|
|
95
|
+
'uk-ua'?: string;
|
|
96
|
+
'ru-ru'?: string;
|
|
97
|
+
};
|
|
98
|
+
currency: string;
|
|
99
|
+
isPrivate: boolean;
|
|
100
|
+
orgType: 'individual' | 'corporate';
|
|
101
|
+
description: {};
|
|
102
|
+
memberRoles: {
|
|
103
|
+
[key: string]: string[];
|
|
104
|
+
};
|
|
105
|
+
balance: number;
|
|
106
|
+
miniAva: string;
|
|
107
|
+
avatar: any;
|
|
108
|
+
banner: any;
|
|
109
|
+
schedules: Array<OrganizationSchedule>;
|
|
110
|
+
roles: Array<{
|
|
111
|
+
id: string;
|
|
112
|
+
name: string;
|
|
113
|
+
isActive: boolean;
|
|
114
|
+
permissions: string[];
|
|
115
|
+
}>;
|
|
116
|
+
contactsSettings: {
|
|
117
|
+
contacts: Array<{
|
|
118
|
+
type: string;
|
|
119
|
+
contact: string;
|
|
120
|
+
}>;
|
|
121
|
+
};
|
|
122
|
+
gallerySettings: {
|
|
123
|
+
gallery: Array<{
|
|
124
|
+
imageId: any;
|
|
125
|
+
}>;
|
|
126
|
+
};
|
|
127
|
+
language: string;
|
|
128
|
+
license: {
|
|
129
|
+
commissionBreakdown?: Array<{
|
|
130
|
+
till: null | number;
|
|
131
|
+
percent: number;
|
|
132
|
+
}>;
|
|
133
|
+
cardLast4?: string;
|
|
134
|
+
cardBrand?: string;
|
|
135
|
+
paymentInfoSetUp?: boolean;
|
|
136
|
+
stripeSetupIntentId?: string;
|
|
137
|
+
stripeCustomerId?: string;
|
|
138
|
+
period?: 'monthly' | 'yearly';
|
|
139
|
+
freeLicenses: number;
|
|
140
|
+
paidLicenses: number;
|
|
141
|
+
price: number;
|
|
142
|
+
currency: 'USD';
|
|
143
|
+
subscriptionId?: string;
|
|
144
|
+
endOfCycleAt?: Date;
|
|
145
|
+
refundableTill?: Date;
|
|
146
|
+
};
|
|
147
|
+
serviceProviders: {
|
|
148
|
+
[login: string]: {
|
|
149
|
+
lastEventDate: Date;
|
|
150
|
+
totalOrders: number;
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
adminPermissions?: boolean;
|
|
154
|
+
topStatus?: {
|
|
155
|
+
isTop: boolean;
|
|
156
|
+
};
|
|
157
|
+
lastUtm?: {
|
|
158
|
+
utm_source?: string;
|
|
159
|
+
utm_medium?: string;
|
|
160
|
+
utm_campaign?: string;
|
|
161
|
+
utm_term?: string;
|
|
162
|
+
utm_content?: string;
|
|
163
|
+
};
|
|
164
|
+
remarketingUrls?: {
|
|
165
|
+
websiteUrl: string;
|
|
166
|
+
time: Date;
|
|
167
|
+
params: {
|
|
168
|
+
[login: string]: any;
|
|
169
|
+
};
|
|
170
|
+
}[];
|
|
171
|
+
wasCreatedInStarta1?: boolean;
|
|
172
|
+
toHash(): {
|
|
173
|
+
[propName: string]: any;
|
|
174
|
+
id?: string;
|
|
175
|
+
};
|
|
176
|
+
getLanguage(): string;
|
|
177
|
+
getUserFullName(): string;
|
|
178
|
+
toMainData(): {
|
|
179
|
+
login: string;
|
|
180
|
+
type: "user" | "organization";
|
|
181
|
+
firstName: string;
|
|
182
|
+
lastName: string;
|
|
183
|
+
name: string;
|
|
184
|
+
email: string;
|
|
185
|
+
avatar: any;
|
|
186
|
+
};
|
|
187
|
+
setPasswordHash(password: any): void;
|
|
188
|
+
checkPassword(password: any): boolean;
|
|
189
|
+
getKeyString(): string;
|
|
190
|
+
}
|
|
191
|
+
export default Account;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
const crypto_1 = require("crypto");
|
|
18
|
+
const Base_1 = __importDefault(require("./Base"));
|
|
19
|
+
class Account extends Base_1.default {
|
|
20
|
+
toHash() {
|
|
21
|
+
const _a = super.toHash(), { password, passwordConfirm, old_password } = _a, hash = __rest(_a, ["password", "passwordConfirm", "old_password"]);
|
|
22
|
+
return hash;
|
|
23
|
+
}
|
|
24
|
+
getLanguage() {
|
|
25
|
+
var _a;
|
|
26
|
+
return (_a = this.language) !== null && _a !== void 0 ? _a : 'en-us';
|
|
27
|
+
}
|
|
28
|
+
getUserFullName() {
|
|
29
|
+
return this.firstName || this.lastName
|
|
30
|
+
? `${this.firstName} ${this.lastName}`
|
|
31
|
+
: this.login;
|
|
32
|
+
}
|
|
33
|
+
toMainData() {
|
|
34
|
+
return {
|
|
35
|
+
login: this.login,
|
|
36
|
+
type: this.type,
|
|
37
|
+
firstName: this.firstName,
|
|
38
|
+
lastName: this.lastName,
|
|
39
|
+
name: this.name,
|
|
40
|
+
email: this.email,
|
|
41
|
+
avatar: this.avatar,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
setPasswordHash(password) {
|
|
45
|
+
if (password) {
|
|
46
|
+
this._passwordHash = (0, crypto_1.createHash)('md5').update(password).digest('hex');
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
checkPassword(password) {
|
|
50
|
+
if (!password || !this._passwordHash)
|
|
51
|
+
return false;
|
|
52
|
+
const passwordHash = (0, crypto_1.createHash)('md5').update(password).digest('hex');
|
|
53
|
+
return passwordHash === this._passwordHash;
|
|
54
|
+
}
|
|
55
|
+
getKeyString() {
|
|
56
|
+
if (!this.login)
|
|
57
|
+
return this._id.toString();
|
|
58
|
+
return this.login;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.default = Account;
|
|
62
|
+
//# sourceMappingURL=Account.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Account.js","sourceRoot":"","sources":["../../src/entities/Account.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mCAAoC;AACpC,kDAA2B;AAG3B,MAAM,OAAQ,SAAQ,cAAI;IA0KxB,MAAM;QACJ,MAAM,KAAuD,KAAK,CAAC,MAAM,EAAE,EAArE,EAAE,QAAQ,EAAE,eAAe,EAAE,YAAY,OAA4B,EAAvB,IAAI,cAAlD,+CAAoD,CAAiB,CAAC;QAE5E,OAAO,IAAI,CAAC;IACd,CAAC;IAED,WAAW;;QACT,OAAO,MAAA,IAAI,CAAC,QAAQ,mCAAI,OAAO,CAAC;IAClC,CAAC;IAED,eAAe;QACb,OAAO,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,QAAQ;YACpC,CAAC,CAAC,GAAG,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,QAAQ,EAAE;YACtC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAA;IAChB,CAAC;IAED,UAAU;QACR,OAAO;YACL,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,MAAM,EAAE,IAAI,CAAC,MAAM;SACpB,CAAA;IACH,CAAC;IAED,eAAe,CAAC,QAAQ;QACtB,IAAI,QAAQ,EAAE;YACZ,IAAI,CAAC,aAAa,GAAG,IAAA,mBAAU,EAAC,KAAK,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;SACvE;IACH,CAAC;IAED,aAAa,CAAC,QAAQ;QACpB,IAAI,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,aAAa;YAAE,OAAO,KAAK,CAAC;QACnD,MAAM,YAAY,GAAG,IAAA,mBAAU,EAAC,KAAK,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACtE,OAAO,YAAY,KAAK,IAAI,CAAC,aAAa,CAAC;IAC7C,CAAC;IAED,YAAY;QACV,IAAI,CAAC,IAAI,CAAC,KAAK;YAAE,OAAO,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;QAC5C,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;CACF;AAED,kBAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ObjectId } from 'mongodb';
|
|
2
|
+
interface Storable {
|
|
3
|
+
_id: ObjectId;
|
|
4
|
+
id: string;
|
|
5
|
+
}
|
|
6
|
+
interface EntityHash {
|
|
7
|
+
id?: string;
|
|
8
|
+
[propName: string]: any;
|
|
9
|
+
}
|
|
10
|
+
interface Entity extends Storable {
|
|
11
|
+
revisions: object[];
|
|
12
|
+
isActive: boolean;
|
|
13
|
+
}
|
|
14
|
+
declare abstract class Base implements Entity {
|
|
15
|
+
constructor(attrs: any);
|
|
16
|
+
_id: ObjectId;
|
|
17
|
+
id: string;
|
|
18
|
+
revisions: any[];
|
|
19
|
+
originalRevision: any;
|
|
20
|
+
isActive: boolean;
|
|
21
|
+
createdAt: Date;
|
|
22
|
+
createdBy: string;
|
|
23
|
+
toHash(): EntityHash;
|
|
24
|
+
toHashWithoutRevisions(): EntityHash;
|
|
25
|
+
setAttrs(attrs: any): void;
|
|
26
|
+
getKeyString(): string;
|
|
27
|
+
}
|
|
28
|
+
export { Storable, EntityHash, Entity };
|
|
29
|
+
export default Base;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const mongodb_1 = require("mongodb");
|
|
4
|
+
class Base {
|
|
5
|
+
constructor(attrs) {
|
|
6
|
+
this._id = new mongodb_1.ObjectId;
|
|
7
|
+
this.revisions = [];
|
|
8
|
+
this.isActive = true;
|
|
9
|
+
this.setAttrs(attrs);
|
|
10
|
+
if ((typeof attrs._id) === 'string') {
|
|
11
|
+
this._id = new mongodb_1.ObjectId(attrs._id);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
toHash() {
|
|
15
|
+
const hash = {};
|
|
16
|
+
if (!this.id && this._id) {
|
|
17
|
+
hash.id = this._id.toHexString();
|
|
18
|
+
}
|
|
19
|
+
Object.keys(this).forEach((key) => {
|
|
20
|
+
if (!this.hasOwnProperty(key))
|
|
21
|
+
return;
|
|
22
|
+
if (key[0] === '_')
|
|
23
|
+
return;
|
|
24
|
+
if (this[key] instanceof Array && key !== 'revisions') {
|
|
25
|
+
const arr = [];
|
|
26
|
+
this[key].forEach((item) => {
|
|
27
|
+
const res = item;
|
|
28
|
+
if (typeof (res) === 'object' && !res.id && res._id) {
|
|
29
|
+
res.id = res._id.toString();
|
|
30
|
+
}
|
|
31
|
+
arr.push((typeof (res) === 'object' && !(res.constructor.toString().startsWith('function ObjectId(inputId)'))) ? Base.prototype.toHash.apply(res) : res);
|
|
32
|
+
});
|
|
33
|
+
hash[key] = arr;
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
hash[key] = this[key];
|
|
37
|
+
}
|
|
38
|
+
return;
|
|
39
|
+
});
|
|
40
|
+
return hash;
|
|
41
|
+
}
|
|
42
|
+
toHashWithoutRevisions() {
|
|
43
|
+
const hash = this.toHash();
|
|
44
|
+
delete hash.revisions;
|
|
45
|
+
delete hash.originalRevision;
|
|
46
|
+
return hash;
|
|
47
|
+
}
|
|
48
|
+
setAttrs(attrs) {
|
|
49
|
+
if (!attrs)
|
|
50
|
+
throw new Error('Args required');
|
|
51
|
+
if (attrs._id)
|
|
52
|
+
this.id = attrs._id.toString();
|
|
53
|
+
Object.keys(attrs).forEach((key) => {
|
|
54
|
+
this[key] = attrs[key];
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
getKeyString() {
|
|
58
|
+
return `${this._id.toString()}`;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.default = Base;
|
|
62
|
+
//# sourceMappingURL=Base.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Base.js","sourceRoot":"","sources":["../../src/entities/Base.ts"],"names":[],"mappings":";;AAAA,qCAAmC;AAiBnC,MAAe,IAAI;IACjB,YAAY,KAAK;QAQjB,QAAG,GAAa,IAAI,kBAAQ,CAAC;QAE7B,cAAS,GAAU,EAAE,CAAC;QAEtB,aAAQ,GAAY,IAAI,CAAC;QAVvB,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACrB,IAAI,CAAC,OAAO,KAAK,CAAC,GAAG,CAAC,KAAK,QAAQ,EAAC;YAClC,IAAI,CAAC,GAAG,GAAG,IAAI,kBAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;SACnC;IACH,CAAC;IAUD,MAAM;QACJ,MAAM,IAAI,GAAgB,EAAI,CAAC;QAE/B,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,IAAI,CAAC,GAAG,EAAE;YACxB,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC;SAClC;QAED,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;YAChC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC;gBAAE,OAAO;YACtC,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG;gBAAE,OAAO;YAE3B,IAAI,IAAI,CAAC,GAAG,CAAC,YAAY,KAAK,IAAI,GAAG,KAAK,WAAW,EAAE;gBACrD,MAAM,GAAG,GAAU,EAAE,CAAC;gBACtB,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;oBACzB,MAAM,GAAG,GAAG,IAAI,CAAC;oBACjB,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,QAAQ,IAAI,CAAC,GAAG,CAAC,EAAE,IAAI,GAAG,CAAC,GAAG,EAAE;wBACnD,GAAG,CAAC,EAAE,GAAG,GAAG,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;qBAC7B;oBACD,GAAG,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC,UAAU,CAAC,4BAA4B,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;gBAC3J,CAAC,CAAC,CAAC;gBACH,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC;aACjB;iBAAM;gBACL,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;aACvB;YAED,OAAO;QACT,CAAC,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC;IACd,CAAC;IAED,sBAAsB;QACpB,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;QAE3B,OAAO,IAAI,CAAC,SAAS,CAAC;QACtB,OAAO,IAAI,CAAC,gBAAgB,CAAC;QAE7B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,QAAQ,CAAC,KAAK;QACZ,IAAI,CAAC,KAAK;YAAE,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC;QAE7C,IAAI,KAAK,CAAC,GAAG;YAAE,IAAI,CAAC,EAAE,GAAG,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;QAC9C,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;YACjC,IAAI,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;QACzB,CAAC,CAAC,CAAC;IACL,CAAC;IAED,YAAY;QACV,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,CAAC;IAClC,CAAC;CACF;AAGD,kBAAe,IAAI,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
const Base_1 = __importDefault(require("./Base"));
|
|
7
|
+
class Version extends Base_1.default {
|
|
8
|
+
}
|
|
9
|
+
exports.default = Version;
|
|
10
|
+
//# sourceMappingURL=Version.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Version.js","sourceRoot":"","sources":["../../src/entities/Version.ts"],"names":[],"mappings":";;;;;AAAA,kDAAgC;AAEhC,MAAM,OAAQ,SAAQ,cAAU;CAG/B;AAED,kBAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { ObjectId } from "mongodb";
|
|
2
|
+
export type Service = {
|
|
3
|
+
id: string;
|
|
4
|
+
isActive: boolean;
|
|
5
|
+
price: number;
|
|
6
|
+
image: string;
|
|
7
|
+
duration: number;
|
|
8
|
+
allowCancellationByCustomer?: boolean;
|
|
9
|
+
disableCancellationByCustomerPriorHours?: number;
|
|
10
|
+
disableBookingByCustomerPriorHours?: number;
|
|
11
|
+
disableBookingByCustomer?: boolean;
|
|
12
|
+
blockMoreThanThreshholdBookingsPerDay?: boolean;
|
|
13
|
+
bookingsPerDayThreshold?: number;
|
|
14
|
+
blockMoreThanThreshholdBookingsPerCustomerPerDay?: boolean;
|
|
15
|
+
bookingsPerCustomerPerDayThreshold?: number;
|
|
16
|
+
executors: Array<ServiceExecutor>;
|
|
17
|
+
starttime: Date;
|
|
18
|
+
endtime: Date;
|
|
19
|
+
schedules: Array<{
|
|
20
|
+
id: string;
|
|
21
|
+
enabled: boolean;
|
|
22
|
+
}>;
|
|
23
|
+
name: {
|
|
24
|
+
default: string;
|
|
25
|
+
'en-us': string;
|
|
26
|
+
'uk-ua': string;
|
|
27
|
+
'ru-ru': string;
|
|
28
|
+
};
|
|
29
|
+
description: {
|
|
30
|
+
default: string;
|
|
31
|
+
'en-us': string;
|
|
32
|
+
'uk-ua': string;
|
|
33
|
+
'ru-ru': string;
|
|
34
|
+
};
|
|
35
|
+
serviceCategoryId?: ObjectId;
|
|
36
|
+
};
|
|
37
|
+
export type ServiceExecutor = {
|
|
38
|
+
login: string;
|
|
39
|
+
price: number;
|
|
40
|
+
duration: number;
|
|
41
|
+
};
|
|
42
|
+
export type DailySchedule = {
|
|
43
|
+
intervals: Interval<string>[];
|
|
44
|
+
};
|
|
45
|
+
export type weekday = 'mon' | 'tue' | 'wed' | 'thu' | 'fri' | 'sat' | 'sun';
|
|
46
|
+
export type WeeklySchedule = {
|
|
47
|
+
[key in weekday]: DailySchedule;
|
|
48
|
+
};
|
|
49
|
+
export type Schedule = {
|
|
50
|
+
weekly: WeeklySchedule;
|
|
51
|
+
daily: {
|
|
52
|
+
workForDays: number;
|
|
53
|
+
restForDays: number;
|
|
54
|
+
startingFrom: string;
|
|
55
|
+
daySchedule: DailySchedule;
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
export type OrganizationSchedule = {
|
|
59
|
+
id: string;
|
|
60
|
+
name: any;
|
|
61
|
+
location: {
|
|
62
|
+
isOnline: boolean;
|
|
63
|
+
description?: {
|
|
64
|
+
default: any;
|
|
65
|
+
};
|
|
66
|
+
address?: {
|
|
67
|
+
id: any;
|
|
68
|
+
formattedAddress: any;
|
|
69
|
+
timezone: any;
|
|
70
|
+
name: any;
|
|
71
|
+
streetNumber: any;
|
|
72
|
+
streetName: any;
|
|
73
|
+
region: any;
|
|
74
|
+
city: any;
|
|
75
|
+
country: any;
|
|
76
|
+
zipCode: any;
|
|
77
|
+
appartment: any;
|
|
78
|
+
location: {
|
|
79
|
+
lat: number;
|
|
80
|
+
lng: number;
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
schedule: Schedule;
|
|
85
|
+
isActive: boolean;
|
|
86
|
+
};
|
|
87
|
+
export type BookingWidgetStyleType = {
|
|
88
|
+
widgetParent: string;
|
|
89
|
+
widgetHeader: string;
|
|
90
|
+
widgetCloseButton: string;
|
|
91
|
+
openWidgetButton: string;
|
|
92
|
+
};
|
|
93
|
+
export type ServiceType = "service" | "roomRent" | "seminar";
|
|
94
|
+
export type OrderStatus = 'new' | 'inprogress' | 'canceled' | 'completed';
|
|
95
|
+
export type Interval<T> = {
|
|
96
|
+
from: T;
|
|
97
|
+
to: T;
|
|
98
|
+
};
|
|
99
|
+
export type ComparsionOperator = '$eq' | '$gt' | '$gte' | '$in' | '$lt' | '$lte' | '$ne' | '$nin';
|
|
100
|
+
export type RangeOperator = '$in' | '$nin';
|
|
101
|
+
export type SearchCondition<T> = {
|
|
102
|
+
operator: ComparsionOperator;
|
|
103
|
+
value: T;
|
|
104
|
+
};
|
|
105
|
+
export type SearchRangeCondition<T> = {
|
|
106
|
+
operator: RangeOperator;
|
|
107
|
+
value: T;
|
|
108
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/entities/types/index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
clone: <T>(obj: T) => T;
|
|
3
|
+
diffPatcher: () => any;
|
|
4
|
+
createDiffPatcher: (filterOutProperies: any) => any;
|
|
5
|
+
getSessionId: (token: any) => string[];
|
|
6
|
+
extractSessionData: (token: any) => string[];
|
|
7
|
+
delay: (ms: any) => Promise<unknown>;
|
|
8
|
+
createObjectComparer: (propertyName: any, order: any) => (a: any, b: any) => number;
|
|
9
|
+
uniquify: (array: any[], getProp?: Function) => any[];
|
|
10
|
+
createIssueQueryFieldBuilder: (projectOwner: any, projectId: any, issueId: any) => (queryField: any) => {
|
|
11
|
+
[x: string]: any;
|
|
12
|
+
};
|
|
13
|
+
setMainDataFields: (entity: any, newEntity: any) => any;
|
|
14
|
+
getDataForScheduleStep: (schedule: any, notifyOffsetSeconds: any, isFirst: any) => {
|
|
15
|
+
timeout: any;
|
|
16
|
+
notifyTime: any;
|
|
17
|
+
};
|
|
18
|
+
getSprintTimeframe: (sprintRevisions: any, sprintDuration: any) => {
|
|
19
|
+
startDate: any;
|
|
20
|
+
endDate: any;
|
|
21
|
+
expectedEndDate: Date;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
export default _default;
|
|
@@ -0,0 +1,151 @@
|
|
|
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
|
+
const jsondiffpatch_1 = __importDefault(require("jsondiffpatch"));
|
|
7
|
+
const extend_1 = __importDefault(require("extend"));
|
|
8
|
+
const moment_1 = __importDefault(require("moment"));
|
|
9
|
+
const timeProvider_1 = __importDefault(require("../timeProvider"));
|
|
10
|
+
const createDiffPatcher = (filterOutProperies) => {
|
|
11
|
+
filterOutProperies = Object.assign({ 'revisions': true, 'originalRevision': true, '_originalVersion': true, '_id': true }, filterOutProperies);
|
|
12
|
+
return jsondiffpatch_1.default.create({
|
|
13
|
+
objectHash: obj => (obj.id || JSON.stringify(obj)),
|
|
14
|
+
propertyFilter: name => !filterOutProperies[name],
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
const defaultDiffPatcher = createDiffPatcher({});
|
|
18
|
+
const daysOfWeek = ['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun'];
|
|
19
|
+
exports.default = {
|
|
20
|
+
clone: function (obj) { return (0, extend_1.default)(true, {}, obj); },
|
|
21
|
+
diffPatcher: () => defaultDiffPatcher,
|
|
22
|
+
createDiffPatcher: (filterOutProperies) => createDiffPatcher(filterOutProperies),
|
|
23
|
+
getSessionId: token => new Buffer(token, 'base64').toString().split(':', 1),
|
|
24
|
+
extractSessionData: token => new Buffer(token, 'base64').toString().split(':', 2),
|
|
25
|
+
delay: ms => new Promise(resolve => setTimeout(resolve, ms)),
|
|
26
|
+
createObjectComparer: (propertyName, order) => {
|
|
27
|
+
if (order !== '+' && order !== '-') {
|
|
28
|
+
throw Error('order must be + or -');
|
|
29
|
+
}
|
|
30
|
+
return (a, b) => {
|
|
31
|
+
let unorderedResult = 0;
|
|
32
|
+
const aHasProperty = ({}).hasOwnProperty.call(a, propertyName);
|
|
33
|
+
const bHasProperty = ({}).hasOwnProperty.call(b, propertyName);
|
|
34
|
+
if (aHasProperty && !bHasProperty) {
|
|
35
|
+
unorderedResult = 1;
|
|
36
|
+
}
|
|
37
|
+
else if (bHasProperty && !aHasProperty) {
|
|
38
|
+
unorderedResult = -1;
|
|
39
|
+
}
|
|
40
|
+
else if (aHasProperty && bHasProperty) {
|
|
41
|
+
let aProperty = a[propertyName] || ' ';
|
|
42
|
+
let bProperty = b[propertyName] || ' ';
|
|
43
|
+
if (aProperty.toLowerCase && bProperty.toLowerCase) {
|
|
44
|
+
aProperty = aProperty.toLowerCase();
|
|
45
|
+
bProperty = bProperty.toLowerCase();
|
|
46
|
+
}
|
|
47
|
+
if (aProperty && !bProperty) {
|
|
48
|
+
unorderedResult = 1;
|
|
49
|
+
}
|
|
50
|
+
else if (bProperty && !aProperty) {
|
|
51
|
+
unorderedResult = -1;
|
|
52
|
+
}
|
|
53
|
+
else if (aHasProperty && bHasProperty) {
|
|
54
|
+
if (aProperty > bProperty) {
|
|
55
|
+
unorderedResult = 1;
|
|
56
|
+
}
|
|
57
|
+
else if (aProperty < bProperty) {
|
|
58
|
+
unorderedResult = -1;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return order === '-'
|
|
63
|
+
? -unorderedResult
|
|
64
|
+
: unorderedResult;
|
|
65
|
+
};
|
|
66
|
+
},
|
|
67
|
+
uniquify: (array, getProp) => {
|
|
68
|
+
const map = {};
|
|
69
|
+
array.forEach(item => (map[getProp ? getProp(item) : item] = item));
|
|
70
|
+
return Object.keys(map).map(prop => map[prop]);
|
|
71
|
+
},
|
|
72
|
+
createIssueQueryFieldBuilder: (projectOwner, projectId, issueId) => queryField => ({
|
|
73
|
+
[`${queryField}.project.owner`]: projectOwner,
|
|
74
|
+
[`${queryField}.project.id`]: projectId,
|
|
75
|
+
[`${queryField}.id`]: issueId,
|
|
76
|
+
}),
|
|
77
|
+
setMainDataFields: (entity, newEntity) => Object.assign(entity, newEntity),
|
|
78
|
+
getDataForScheduleStep: (schedule, notifyOffsetSeconds, isFirst) => {
|
|
79
|
+
const { type, atHours, atMinutes, everyHours, dayOfWeek, dayOfMonth, } = schedule;
|
|
80
|
+
const typeMap = {
|
|
81
|
+
hourly: {
|
|
82
|
+
getEventMoment: () => (0, moment_1.default)().hour(atHours).minute(atMinutes),
|
|
83
|
+
passToNextPeriod: momentOfEvent => momentOfEvent.add(1, 'days'),
|
|
84
|
+
getNextEventMoment: () => (0, moment_1.default)().add(everyHours, 'hours'),
|
|
85
|
+
},
|
|
86
|
+
daily: {
|
|
87
|
+
getEventMoment: () => (0, moment_1.default)().hour(atHours).minute(atMinutes),
|
|
88
|
+
passToNextPeriod: momentOfEvent => momentOfEvent.add(1, 'days'),
|
|
89
|
+
getNextEventMoment: () => (0, moment_1.default)().add(1, 'days'),
|
|
90
|
+
},
|
|
91
|
+
weekly: {
|
|
92
|
+
getEventMoment: () => (0, moment_1.default)().day(daysOfWeek.indexOf(dayOfWeek) + 1).hour(atHours).minute(atMinutes),
|
|
93
|
+
passToNextPeriod: momentOfEvent => momentOfEvent.add(1, 'weeks'),
|
|
94
|
+
getNextEventMoment: () => (0, moment_1.default)().add(1, 'weeks'),
|
|
95
|
+
},
|
|
96
|
+
monthly: {
|
|
97
|
+
getEventMoment: () => (0, moment_1.default)().date(dayOfMonth).hour(atHours).minute(atMinutes),
|
|
98
|
+
passToNextPeriod: momentOfEvent => momentOfEvent.add(1, 'months'),
|
|
99
|
+
getNextEventMoment: () => (0, moment_1.default)().add(1, 'months'),
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
const typeConfig = typeMap[type];
|
|
103
|
+
if (isFirst) {
|
|
104
|
+
const momentOfEvent = typeConfig.getEventMoment();
|
|
105
|
+
if ((0, moment_1.default)().isAfter(momentOfEvent)) {
|
|
106
|
+
typeConfig.passToNextPeriod(momentOfEvent);
|
|
107
|
+
}
|
|
108
|
+
const secondsToEvent = momentOfEvent.diff((0, moment_1.default)(), 'seconds');
|
|
109
|
+
if (secondsToEvent < notifyOffsetSeconds) {
|
|
110
|
+
return {
|
|
111
|
+
timeout: 1,
|
|
112
|
+
notifyTime: secondsToEvent,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
return {
|
|
116
|
+
timeout: secondsToEvent - notifyOffsetSeconds,
|
|
117
|
+
notifyTime: notifyOffsetSeconds,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
const momentOfNextMeeting = typeConfig.getNextEventMoment();
|
|
121
|
+
momentOfNextMeeting.subtract(((0, moment_1.default)().minutes() - (atMinutes - notifyOffsetSeconds / 60)) % 60, 'minutes'); // discard time error and subtract notifyOffsetSeconds
|
|
122
|
+
return {
|
|
123
|
+
timeout: momentOfNextMeeting.diff((0, moment_1.default)(), 'seconds'),
|
|
124
|
+
notifyTime: notifyOffsetSeconds,
|
|
125
|
+
};
|
|
126
|
+
},
|
|
127
|
+
getSprintTimeframe: (sprintRevisions, sprintDuration) => {
|
|
128
|
+
let flag = true;
|
|
129
|
+
let i = 0;
|
|
130
|
+
let startDate = null;
|
|
131
|
+
let endDate = null;
|
|
132
|
+
while (i < sprintRevisions.length && flag) {
|
|
133
|
+
const revision = sprintRevisions[i];
|
|
134
|
+
if (revision.status) {
|
|
135
|
+
const prevStatus = revision.status[0];
|
|
136
|
+
const afterUpdateStatus = revision.status[1];
|
|
137
|
+
if (prevStatus === 'new' && afterUpdateStatus === 'running') {
|
|
138
|
+
startDate = revision.createdAt[1];
|
|
139
|
+
}
|
|
140
|
+
if (prevStatus === 'running' && afterUpdateStatus === 'completed') {
|
|
141
|
+
endDate = revision.createdAt[1];
|
|
142
|
+
}
|
|
143
|
+
if (startDate && endDate)
|
|
144
|
+
flag = false;
|
|
145
|
+
}
|
|
146
|
+
i++;
|
|
147
|
+
}
|
|
148
|
+
return { startDate, endDate, expectedEndDate: !endDate ? new Date(timeProvider_1.default.add(timeProvider_1.default.moment(), sprintDuration - 1, 'days')) : null };
|
|
149
|
+
},
|
|
150
|
+
};
|
|
151
|
+
//# sourceMappingURL=index.js.map
|