@acorex/connectivity 18.2.0
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 +7 -0
- package/esm2022/acorex-connectivity.mjs +5 -0
- package/esm2022/index.mjs +2 -0
- package/esm2022/lib/connectivity.component.mjs +12 -0
- package/esm2022/mock/acorex-connectivity-mock.mjs +5 -0
- package/esm2022/mock/index.mjs +2 -0
- package/esm2022/mock/lib/application-management/application-management-mock-data.mjs +109 -0
- package/esm2022/mock/lib/application-management/application.seeder.mjs +26 -0
- package/esm2022/mock/lib/application-management/index.mjs +3 -0
- package/esm2022/mock/lib/comments/comment.mock.data.mjs +73 -0
- package/esm2022/mock/lib/comments/comment.mock.service.mjs +77 -0
- package/esm2022/mock/lib/comments/comment.seeder.mjs +18 -0
- package/esm2022/mock/lib/comments/index.mjs +4 -0
- package/esm2022/mock/lib/form-management/designer-connector.mock.service.mjs +56 -0
- package/esm2022/mock/lib/mock.module.mjs +113 -0
- package/esm2022/mock/lib/notification-management/notification/notification.mock.service.mjs +75 -0
- package/esm2022/mock/lib/platform-management/global-variables/global-variable.seeder.mjs +18 -0
- package/esm2022/mock/lib/platform-management/global-variables/global-variables.mock.data.mjs +18 -0
- package/esm2022/mock/lib/platform-management/global-variables/index.mjs +3 -0
- package/esm2022/mock/lib/platform-management/index.mjs +3 -0
- package/esm2022/mock/lib/platform-management/languages/index.mjs +3 -0
- package/esm2022/mock/lib/platform-management/languages/language.seeder.mjs +18 -0
- package/esm2022/mock/lib/platform-management/languages/lanuage.mock.data.mjs +14 -0
- package/esm2022/mock/lib/text-template-management/category.seeder.mjs +19 -0
- package/esm2022/mock/lib/text-template-management/index.mjs +4 -0
- package/esm2022/mock/lib/text-template-management/template.seeder.mjs +19 -0
- package/esm2022/mock/lib/text-template-management/text-template-management.mock.data.mjs +118 -0
- package/fesm2022/acorex-connectivity-mock.mjs +736 -0
- package/fesm2022/acorex-connectivity-mock.mjs.map +1 -0
- package/fesm2022/acorex-connectivity.mjs +19 -0
- package/fesm2022/acorex-connectivity.mjs.map +1 -0
- package/index.d.ts +1 -0
- package/lib/connectivity.component.d.ts +5 -0
- package/mock/README.md +3 -0
- package/mock/index.d.ts +1 -0
- package/mock/lib/application-management/application-management-mock-data.d.ts +67 -0
- package/mock/lib/application-management/application.seeder.d.ts +8 -0
- package/mock/lib/application-management/index.d.ts +2 -0
- package/mock/lib/comments/comment.mock.data.d.ts +9 -0
- package/mock/lib/comments/comment.mock.service.d.ts +7 -0
- package/mock/lib/comments/comment.seeder.d.ts +8 -0
- package/mock/lib/comments/index.d.ts +3 -0
- package/mock/lib/form-management/designer-connector.mock.service.d.ts +8 -0
- package/mock/lib/mock.module.d.ts +6 -0
- package/mock/lib/notification-management/notification/notification.mock.service.d.ts +12 -0
- package/mock/lib/platform-management/global-variables/global-variable.seeder.d.ts +8 -0
- package/mock/lib/platform-management/global-variables/global-variables.mock.data.d.ts +7 -0
- package/mock/lib/platform-management/global-variables/index.d.ts +2 -0
- package/mock/lib/platform-management/index.d.ts +2 -0
- package/mock/lib/platform-management/languages/index.d.ts +2 -0
- package/mock/lib/platform-management/languages/language.seeder.d.ts +8 -0
- package/mock/lib/platform-management/languages/lanuage.mock.data.d.ts +5 -0
- package/mock/lib/text-template-management/category.seeder.d.ts +8 -0
- package/mock/lib/text-template-management/index.d.ts +3 -0
- package/mock/lib/text-template-management/template.seeder.d.ts +8 -0
- package/mock/lib/text-template-management/text-template-management.mock.data.d.ts +7 -0
- package/package.json +31 -0
@@ -0,0 +1,736 @@
|
|
1
|
+
import { AXMCommentService } from '@acorex/modules/conversation';
|
2
|
+
import { AXMNotificationService } from '@acorex/modules/notification-management';
|
3
|
+
import { AXPDataGenerator, AXPDexieEntityStorageService, AXPEntityStorageService, AXP_DATA_SEEDER_TOKEN } from '@acorex/platform/common';
|
4
|
+
import { AXPDesignerConnectorAbstract } from '@acorex/platform/layout/designer';
|
5
|
+
import * as i0 from '@angular/core';
|
6
|
+
import { inject, Injectable, NgModule } from '@angular/core';
|
7
|
+
import { APPLICATION_SOURCE_NAME, MODULE_SOURCE_NAME, ENTITY_SOURCE_NAME, FEATURE_SOURCE_NAME, PERMISSION_SOURCE_NAME, PROPERTY_SOURCE_NAME } from '@acorex/modules/application-management';
|
8
|
+
import { AXPCommentServiceImpl } from '@acorex/modules/platform-management';
|
9
|
+
import { AXPSessionService } from '@acorex/platform/auth';
|
10
|
+
import { convertArrayToDataSource } from '@acorex/components/common';
|
11
|
+
import { CATEGORY_SOURCE_NAME, TEMPLATE_SOURCE_NAME } from '@acorex/modules/template-management';
|
12
|
+
|
13
|
+
const APPLICATIONS = Array.from({ length: 5 }).map((_, i) => {
|
14
|
+
const source = ['appOne', 'appTwo', 'appThree', 'myCoolApp', 'awesomeApp', 'superApp'];
|
15
|
+
const name = AXPDataGenerator.pick(source);
|
16
|
+
return {
|
17
|
+
id: AXPDataGenerator.uuid(),
|
18
|
+
name: name,
|
19
|
+
title: name,
|
20
|
+
isArchived: AXPDataGenerator.boolean(),
|
21
|
+
};
|
22
|
+
});
|
23
|
+
const MODULES = Array.from({ length: 5 }).map((_, i) => {
|
24
|
+
const source = [
|
25
|
+
'UserManagement',
|
26
|
+
'Analytics',
|
27
|
+
'Reporting',
|
28
|
+
'PaymentGateway',
|
29
|
+
'NotificationService',
|
30
|
+
'InventoryManagement',
|
31
|
+
];
|
32
|
+
const name = AXPDataGenerator.pick(source);
|
33
|
+
return {
|
34
|
+
id: AXPDataGenerator.uuid(),
|
35
|
+
name: name,
|
36
|
+
title: name,
|
37
|
+
isArchived: AXPDataGenerator.boolean(),
|
38
|
+
};
|
39
|
+
});
|
40
|
+
const APPLICATIONS_MODULES = Array.from({ length: 5 }).map((_, i) => {
|
41
|
+
return {
|
42
|
+
id: AXPDataGenerator.uuid(),
|
43
|
+
application: AXPDataGenerator.pick(APPLICATIONS),
|
44
|
+
module: AXPDataGenerator.pick(MODULES),
|
45
|
+
};
|
46
|
+
});
|
47
|
+
const EDITIONS = Array.from({ length: 5 }).map((_, i) => {
|
48
|
+
const source = ['Standard', 'Premium', 'Gold', 'Silver', 'Bronze', 'Platinum', 'Enterprise'];
|
49
|
+
const name = AXPDataGenerator.pick(source);
|
50
|
+
return {
|
51
|
+
id: AXPDataGenerator.uuid(),
|
52
|
+
application: AXPDataGenerator.pick(APPLICATIONS),
|
53
|
+
name: name,
|
54
|
+
title: name,
|
55
|
+
isArchived: AXPDataGenerator.boolean(),
|
56
|
+
};
|
57
|
+
});
|
58
|
+
const FEATURES = Array.from({ length: 5 }).map((_, i) => {
|
59
|
+
const source = [
|
60
|
+
'User Authentication',
|
61
|
+
'Data Encryption',
|
62
|
+
'Real-time Notifications',
|
63
|
+
'Customizable Dashboards',
|
64
|
+
'API Access',
|
65
|
+
'Multi-language Support',
|
66
|
+
'Analytics and Reporting',
|
67
|
+
'Offline Mode',
|
68
|
+
];
|
69
|
+
const name = AXPDataGenerator.pick(source);
|
70
|
+
return {
|
71
|
+
id: AXPDataGenerator.uuid(),
|
72
|
+
moduleId: AXPDataGenerator.pick(MODULES).id,
|
73
|
+
name: name,
|
74
|
+
title: name,
|
75
|
+
isArchived: AXPDataGenerator.boolean(),
|
76
|
+
};
|
77
|
+
});
|
78
|
+
const ENTITIES = Array.from({ length: 5 }).map((_, i) => {
|
79
|
+
const source = ['User', 'Product', 'Order', 'Customer', 'Transaction', 'Category', 'Review', 'InventoryItem'];
|
80
|
+
const name = AXPDataGenerator.pick(source);
|
81
|
+
return {
|
82
|
+
id: AXPDataGenerator.uuid(),
|
83
|
+
moduleId: AXPDataGenerator.pick(MODULES).id,
|
84
|
+
name: name,
|
85
|
+
title: name,
|
86
|
+
isArchived: AXPDataGenerator.boolean(),
|
87
|
+
};
|
88
|
+
});
|
89
|
+
const PERMISSIONS = Array.from({ length: 5 }).map((_, i) => {
|
90
|
+
const source = ['Read', 'Write', 'Update', 'Delete', 'ManageUsers', 'ViewReports', 'AccessSettings', 'CreateContent'];
|
91
|
+
const name = AXPDataGenerator.pick(source);
|
92
|
+
return {
|
93
|
+
id: AXPDataGenerator.uuid(),
|
94
|
+
moduleId: AXPDataGenerator.pick(MODULES).id,
|
95
|
+
name: name,
|
96
|
+
title: name,
|
97
|
+
isArchived: AXPDataGenerator.boolean(),
|
98
|
+
};
|
99
|
+
});
|
100
|
+
const PROPERTIES = Array.from({ length: 10 }).map((_, i) => {
|
101
|
+
const source = [
|
102
|
+
'property1',
|
103
|
+
'property2',
|
104
|
+
'property3',
|
105
|
+
'property4',
|
106
|
+
'property5',
|
107
|
+
'property6',
|
108
|
+
'property7',
|
109
|
+
'property8',
|
110
|
+
];
|
111
|
+
const name = AXPDataGenerator.pick(source);
|
112
|
+
return {
|
113
|
+
id: AXPDataGenerator.uuid(),
|
114
|
+
entityId: AXPDataGenerator.pick(ENTITIES).id,
|
115
|
+
name: name,
|
116
|
+
title: name,
|
117
|
+
path: name,
|
118
|
+
};
|
119
|
+
});
|
120
|
+
|
121
|
+
class AXPApplicationTemplateDataSeeder {
|
122
|
+
constructor() {
|
123
|
+
this.storageService = inject(AXPDexieEntityStorageService);
|
124
|
+
}
|
125
|
+
async seed() {
|
126
|
+
const applications = this.storageService.initial(APPLICATION_SOURCE_NAME, APPLICATIONS);
|
127
|
+
const modules = this.storageService.initial(MODULE_SOURCE_NAME, MODULES);
|
128
|
+
const entities = this.storageService.initial(ENTITY_SOURCE_NAME, ENTITIES);
|
129
|
+
const features = this.storageService.initial(FEATURE_SOURCE_NAME, FEATURES);
|
130
|
+
const permissions = this.storageService.initial(PERMISSION_SOURCE_NAME, PERMISSIONS);
|
131
|
+
const editions = this.storageService.initial(PERMISSION_SOURCE_NAME, EDITIONS);
|
132
|
+
const properties = this.storageService.initial(PROPERTY_SOURCE_NAME, PROPERTIES);
|
133
|
+
await Promise.all([applications, modules, entities, features, permissions, editions, properties]);
|
134
|
+
}
|
135
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXPApplicationTemplateDataSeeder, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
136
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXPApplicationTemplateDataSeeder }); }
|
137
|
+
}
|
138
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXPApplicationTemplateDataSeeder, decorators: [{
|
139
|
+
type: Injectable
|
140
|
+
}] });
|
141
|
+
|
142
|
+
// import { AXPDataGenerator, AXPEntityStorageService } from '@acorex/platform/common';
|
143
|
+
// import {
|
144
|
+
// AXPComment,
|
145
|
+
// AXPCommentCreateRequest,
|
146
|
+
// AXPCommentDeleteRequest,
|
147
|
+
// AXPCommentGetRequest,
|
148
|
+
// AXPCommentLikeRequest,
|
149
|
+
// AXPCommentResponse,
|
150
|
+
// AXPCommentUpdateRequest,
|
151
|
+
// } from '@acorex/platform/themes/shared';
|
152
|
+
// import { inject, Injectable } from '@angular/core';
|
153
|
+
const generateUser = () => ({
|
154
|
+
userName: AXPDataGenerator.firstName().toLowerCase(),
|
155
|
+
firstName: AXPDataGenerator.firstName(),
|
156
|
+
lastName: AXPDataGenerator.lastName(),
|
157
|
+
picture: null,
|
158
|
+
id: AXPDataGenerator.uuid(),
|
159
|
+
});
|
160
|
+
const COMMENTS = Array.from({ length: 10 }).map(() => {
|
161
|
+
const contentSource = [
|
162
|
+
'This is a comment.',
|
163
|
+
'I really like this!',
|
164
|
+
'Could you clarify your point?',
|
165
|
+
'Great job on this!',
|
166
|
+
'I have some suggestions.',
|
167
|
+
'This is quite insightful.',
|
168
|
+
'Thanks for sharing!',
|
169
|
+
'I disagree with this perspective.',
|
170
|
+
'Interesting take!',
|
171
|
+
'What do you think about this?',
|
172
|
+
];
|
173
|
+
const repliesCount = AXPDataGenerator.number(0, 3);
|
174
|
+
return {
|
175
|
+
id: AXPDataGenerator.uuid(),
|
176
|
+
content: `<p>${AXPDataGenerator.pick(contentSource)}</p>`,
|
177
|
+
contentType: AXPDataGenerator.pick(['text', 'image', 'video']),
|
178
|
+
memberId: AXPDataGenerator.uuid(),
|
179
|
+
memberType: AXPDataGenerator.pick(['user', 'admin']),
|
180
|
+
roomId: AXPDataGenerator.uuid(),
|
181
|
+
isPrivate: AXPDataGenerator.boolean(),
|
182
|
+
replyId: null,
|
183
|
+
messageVisibles: [], // Ensure AXPCommentVisibleMessage[] type is defined
|
184
|
+
messageStatuses: [], // Ensure AXPCommentStatusMessage[] type is defined
|
185
|
+
messageHistories: [], // Ensure AXPCommentHistoryMessage[] type is defined
|
186
|
+
replies: Array.from({ length: repliesCount }).map(() => ({
|
187
|
+
id: AXPDataGenerator.uuid(),
|
188
|
+
content: `<p>${AXPDataGenerator.pick(contentSource)}</p>`,
|
189
|
+
contentType: 'text',
|
190
|
+
memberId: AXPDataGenerator.uuid(),
|
191
|
+
memberType: AXPDataGenerator.pick(['user', 'admin']),
|
192
|
+
roomId: AXPDataGenerator.uuid(),
|
193
|
+
isPrivate: AXPDataGenerator.boolean(),
|
194
|
+
replyId: AXPDataGenerator.uuid(),
|
195
|
+
messageVisibles: [],
|
196
|
+
messageStatuses: [],
|
197
|
+
messageHistories: [],
|
198
|
+
isArchived: AXPDataGenerator.boolean(),
|
199
|
+
isLiked: AXPDataGenerator.boolean(),
|
200
|
+
reactionsCount: AXPDataGenerator.number(0, 10),
|
201
|
+
repliesCount: 0,
|
202
|
+
user: generateUser(), // Ensure AXPCommentUserDetails type is defined
|
203
|
+
replies: [], // Add an empty replies array here to match the AXPComment type
|
204
|
+
})),
|
205
|
+
isArchived: AXPDataGenerator.boolean(),
|
206
|
+
isLiked: AXPDataGenerator.boolean(),
|
207
|
+
reactionsCount: AXPDataGenerator.number(0, 100),
|
208
|
+
repliesCount,
|
209
|
+
user: generateUser(), // Ensure AXPCommentUserDetails type is defined
|
210
|
+
createdAt: AXPDataGenerator.date(new Date(2021), new Date()),
|
211
|
+
};
|
212
|
+
});
|
213
|
+
|
214
|
+
class AXPCommentDataSeeder {
|
215
|
+
constructor() {
|
216
|
+
this.storageService = inject(AXPDexieEntityStorageService);
|
217
|
+
}
|
218
|
+
async seed() {
|
219
|
+
await this.storageService.initial('comments', COMMENTS);
|
220
|
+
}
|
221
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXPCommentDataSeeder, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
222
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXPCommentDataSeeder }); }
|
223
|
+
}
|
224
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXPCommentDataSeeder, decorators: [{
|
225
|
+
type: Injectable
|
226
|
+
}] });
|
227
|
+
|
228
|
+
class AXMCommentMockService extends AXPCommentServiceImpl {
|
229
|
+
constructor() {
|
230
|
+
super(...arguments);
|
231
|
+
this.sessionService = inject(AXPSessionService);
|
232
|
+
}
|
233
|
+
async insertOne(request) {
|
234
|
+
const fullPayload = {
|
235
|
+
...request,
|
236
|
+
memberId: AXPDataGenerator.uuid(),
|
237
|
+
memberType: AXPDataGenerator.pick(['user', 'admin']),
|
238
|
+
roomId: AXPDataGenerator.uuid(),
|
239
|
+
messageVisibles: [],
|
240
|
+
messageStatuses: [],
|
241
|
+
messageHistories: [],
|
242
|
+
replies: [],
|
243
|
+
isArchived: false,
|
244
|
+
isLiked: false,
|
245
|
+
reactionsCount: 0,
|
246
|
+
repliesCount: 0,
|
247
|
+
user: {
|
248
|
+
userName: this.sessionService.user?.name ?? AXPDataGenerator.firstName().toLowerCase(),
|
249
|
+
firstName: this.sessionService.user?.name ?? AXPDataGenerator.firstName(),
|
250
|
+
lastName: this.sessionService.user?.name ?? AXPDataGenerator.lastName(),
|
251
|
+
picture: this.sessionService.user?.avatar ?? null,
|
252
|
+
id: this.sessionService.user?.id ?? AXPDataGenerator.uuid(),
|
253
|
+
},
|
254
|
+
createdAt: new Date(),
|
255
|
+
id: AXPDataGenerator.uuid(),
|
256
|
+
};
|
257
|
+
if (request.replyId) {
|
258
|
+
const message = await super.getOne(request.replyId);
|
259
|
+
await super.updateOne(request.replyId, {
|
260
|
+
...message,
|
261
|
+
replies: [...message.replies, fullPayload],
|
262
|
+
});
|
263
|
+
}
|
264
|
+
else {
|
265
|
+
await super.insertOne(fullPayload);
|
266
|
+
//await super.storageService.insertOne('comments', fullPayload);
|
267
|
+
}
|
268
|
+
return 'done';
|
269
|
+
}
|
270
|
+
async like(payload) {
|
271
|
+
const comment = await super.getOne(payload.messageId);
|
272
|
+
if (comment) {
|
273
|
+
const isLiked = !comment.isLiked;
|
274
|
+
const reactionsCount = isLiked ? comment.reactionsCount + 1 : comment.reactionsCount - 1;
|
275
|
+
await super.updateOne(payload.messageId, { ...comment, isLiked, reactionsCount });
|
276
|
+
}
|
277
|
+
else {
|
278
|
+
const allComments = await super.query({
|
279
|
+
skip: 0,
|
280
|
+
take: 9999,
|
281
|
+
});
|
282
|
+
const commentWithReply = allComments.items.find((comment) => comment?.replies?.some((reply) => reply.id === payload.messageId));
|
283
|
+
if (commentWithReply) {
|
284
|
+
commentWithReply.replies = commentWithReply.replies.map((reply) => reply.id === payload.messageId
|
285
|
+
? {
|
286
|
+
...reply,
|
287
|
+
isLiked: !reply.isLiked,
|
288
|
+
reactionsCount: reply.isLiked ? reply.reactionsCount - 1 : reply.reactionsCount + 1,
|
289
|
+
}
|
290
|
+
: reply);
|
291
|
+
await super.updateOne(commentWithReply.id, commentWithReply);
|
292
|
+
}
|
293
|
+
else {
|
294
|
+
throw new Error('No comment with this ID found.');
|
295
|
+
}
|
296
|
+
}
|
297
|
+
return 'done';
|
298
|
+
}
|
299
|
+
}
|
300
|
+
|
301
|
+
class AXPMockDesignerConnector extends AXPDesignerConnectorAbstract {
|
302
|
+
//#region DataSources Management
|
303
|
+
async getDataSourcesNames() {
|
304
|
+
return [
|
305
|
+
{
|
306
|
+
id: "countries",
|
307
|
+
title: "Countries"
|
308
|
+
},
|
309
|
+
{
|
310
|
+
id: "users",
|
311
|
+
title: "Users"
|
312
|
+
}
|
313
|
+
];
|
314
|
+
}
|
315
|
+
async getDataSource(name) {
|
316
|
+
switch (name) {
|
317
|
+
case 'countries':
|
318
|
+
return {
|
319
|
+
columns: [
|
320
|
+
{
|
321
|
+
name: 'id',
|
322
|
+
title: 'Id',
|
323
|
+
},
|
324
|
+
{
|
325
|
+
name: 'title',
|
326
|
+
title: 'Title',
|
327
|
+
}
|
328
|
+
],
|
329
|
+
name: "countries",
|
330
|
+
source: convertArrayToDataSource([
|
331
|
+
{
|
332
|
+
id: "1",
|
333
|
+
title: "Iran"
|
334
|
+
},
|
335
|
+
{
|
336
|
+
id: "2",
|
337
|
+
title: "Usa"
|
338
|
+
},
|
339
|
+
])
|
340
|
+
};
|
341
|
+
default:
|
342
|
+
return undefined;
|
343
|
+
}
|
344
|
+
}
|
345
|
+
//#endregion
|
346
|
+
//#region Save and load Widgets
|
347
|
+
save() {
|
348
|
+
throw new Error("Method not implemented.");
|
349
|
+
}
|
350
|
+
load(id) {
|
351
|
+
throw new Error("Method not implemented.");
|
352
|
+
}
|
353
|
+
}
|
354
|
+
|
355
|
+
class AXMMockNotificationService {
|
356
|
+
constructor() {
|
357
|
+
this.storageService = inject(AXPEntityStorageService);
|
358
|
+
this.name = 'notifications';
|
359
|
+
}
|
360
|
+
async getList() {
|
361
|
+
await this.storageService.initial(this.name, NOTIFICATIONS);
|
362
|
+
const items = (await this.storageService.getAll(this.name));
|
363
|
+
return { total: items.length, items };
|
364
|
+
}
|
365
|
+
async markAsRead(payload) {
|
366
|
+
const notifications = (await this.storageService.getAll(this.name));
|
367
|
+
if (!payload) {
|
368
|
+
notifications
|
369
|
+
.filter((item) => !item.readAt)
|
370
|
+
.forEach((item) => this.storageService.updateOne(this.name, item.id, { ...item, readAt: new Date() }));
|
371
|
+
}
|
372
|
+
else {
|
373
|
+
for (const id of payload.id) {
|
374
|
+
const item = await this.storageService.getOne(this.name, id);
|
375
|
+
const readAt = item.readAt ? null : new Date();
|
376
|
+
this.storageService.updateOne(this.name, item.id, { ...item, readAt });
|
377
|
+
}
|
378
|
+
}
|
379
|
+
}
|
380
|
+
async create(payload) {
|
381
|
+
const notification = payload || generateNotification();
|
382
|
+
await this.storageService.insertOne(this.name, notification);
|
383
|
+
}
|
384
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXMMockNotificationService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
385
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXMMockNotificationService, providedIn: 'root' }); }
|
386
|
+
}
|
387
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXMMockNotificationService, decorators: [{
|
388
|
+
type: Injectable,
|
389
|
+
args: [{
|
390
|
+
providedIn: 'root',
|
391
|
+
}]
|
392
|
+
}] });
|
393
|
+
const CHANNELS = ['InApp', 'Email', 'SMS'];
|
394
|
+
const TITLES = ['Buy Me!', 'Black Friday', 'New Message'];
|
395
|
+
const BODIES = ['Buy New Glass From Shop', 'New Offers For Black Friday!', 'Saeed Send New File Message'];
|
396
|
+
const CATEGORIES = ['Inbox', 'Archive'];
|
397
|
+
const TYPES = ['File', 'Person', 'Notification'];
|
398
|
+
const PRIORITIES = ['Warning', 'Danger', 'Notice'];
|
399
|
+
const NOTIFICATIONS = Array.from({ length: 5 }).map(generateNotification);
|
400
|
+
function generateNotification() {
|
401
|
+
return {
|
402
|
+
id: AXPDataGenerator.uuid(),
|
403
|
+
title: AXPDataGenerator.pick(TITLES),
|
404
|
+
body: AXPDataGenerator.pick(BODIES),
|
405
|
+
channel: AXPDataGenerator.pick(CHANNELS),
|
406
|
+
content: {
|
407
|
+
type: AXPDataGenerator.pick(TYPES),
|
408
|
+
data: {},
|
409
|
+
},
|
410
|
+
user: {
|
411
|
+
id: AXPDataGenerator.uuid(),
|
412
|
+
name: `${AXPDataGenerator.firstName()} ${AXPDataGenerator.lastName()}`,
|
413
|
+
image: 'https://i.pravatar.cc/300',
|
414
|
+
},
|
415
|
+
template: {
|
416
|
+
category: AXPDataGenerator.pick(CATEGORIES),
|
417
|
+
prority: AXPDataGenerator.pick(PRIORITIES),
|
418
|
+
icon: 'fa-image',
|
419
|
+
isPinned: AXPDataGenerator.boolean(),
|
420
|
+
},
|
421
|
+
readAt: AXPDataGenerator.pick([new Date(), null]),
|
422
|
+
createAt: AXPDataGenerator.date(new Date(2021), new Date()),
|
423
|
+
entityName: 'notifications',
|
424
|
+
};
|
425
|
+
}
|
426
|
+
|
427
|
+
const names = ['key', 'counter', 'logo', 'tenant'];
|
428
|
+
const data = [
|
429
|
+
['key1', 'string'],
|
430
|
+
['sequence', 'integer'],
|
431
|
+
['appLogo', 'function'],
|
432
|
+
['CompanyName', 'function'],
|
433
|
+
];
|
434
|
+
const GLOBAL_VARIABLES = Array.from({ length: 4 }).map((element, i) => {
|
435
|
+
return {
|
436
|
+
id: AXPDataGenerator.uuid(),
|
437
|
+
name: names[i],
|
438
|
+
title: names[i],
|
439
|
+
dataType: data[i][1],
|
440
|
+
dataValue: data[i][0],
|
441
|
+
};
|
442
|
+
});
|
443
|
+
|
444
|
+
class AXPGlobalVariablesDataSeeder {
|
445
|
+
constructor() {
|
446
|
+
this.storageService = inject(AXPDexieEntityStorageService);
|
447
|
+
}
|
448
|
+
async seed() {
|
449
|
+
await this.storageService.initial('globalVariable', GLOBAL_VARIABLES);
|
450
|
+
}
|
451
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXPGlobalVariablesDataSeeder, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
452
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXPGlobalVariablesDataSeeder }); }
|
453
|
+
}
|
454
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXPGlobalVariablesDataSeeder, decorators: [{
|
455
|
+
type: Injectable
|
456
|
+
}] });
|
457
|
+
|
458
|
+
const LANGUAGES = [
|
459
|
+
{
|
460
|
+
id: AXPDataGenerator.uuid(),
|
461
|
+
title: 'English',
|
462
|
+
code: 'en'
|
463
|
+
},
|
464
|
+
{
|
465
|
+
id: AXPDataGenerator.uuid(),
|
466
|
+
title: 'Persian',
|
467
|
+
code: 'fa'
|
468
|
+
}
|
469
|
+
];
|
470
|
+
|
471
|
+
class AXPLanguageDataSeeder {
|
472
|
+
constructor() {
|
473
|
+
this.storageService = inject(AXPDexieEntityStorageService);
|
474
|
+
}
|
475
|
+
async seed() {
|
476
|
+
await this.storageService.initial('language', LANGUAGES);
|
477
|
+
}
|
478
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXPLanguageDataSeeder, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
479
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXPLanguageDataSeeder }); }
|
480
|
+
}
|
481
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXPLanguageDataSeeder, decorators: [{
|
482
|
+
type: Injectable
|
483
|
+
}] });
|
484
|
+
|
485
|
+
const TEXT_TEMPLATE_CATEGORY = [
|
486
|
+
{
|
487
|
+
id: AXPDataGenerator.uuid(),
|
488
|
+
name: 'security',
|
489
|
+
title: 'Security'
|
490
|
+
},
|
491
|
+
{
|
492
|
+
id: AXPDataGenerator.uuid(),
|
493
|
+
name: 'marketing',
|
494
|
+
title: 'Marketing'
|
495
|
+
}
|
496
|
+
];
|
497
|
+
const TEXT_TEMPLATES = [
|
498
|
+
{
|
499
|
+
id: AXPDataGenerator.uuid(),
|
500
|
+
name: 'RestPassword',
|
501
|
+
title: 'Rest Password',
|
502
|
+
content: `
|
503
|
+
<tr>
|
504
|
+
<td>
|
505
|
+
<p>Hi {{user_name}},</p>
|
506
|
+
<p>We received a request to reset your password for your account. If you didn’t make this request, you can ignore this email. Otherwise, you can reset your password using the link below:</p>
|
507
|
+
<p style="text-align: center; margin: 20px 0;">
|
508
|
+
<a href="{{Reset Password Link}}" style="background-color: #007bff; color: #ffffff; padding: 10px 20px; text-decoration: none; border-radius: 5px;">Reset Password</a>
|
509
|
+
</p>
|
510
|
+
<p style="font-size: 12px; color: #666666;">*This link will expire in {{Expiration Time}}*</p>
|
511
|
+
<p>If the link above doesn’t work, copy and paste the following URL into your browser:</p>
|
512
|
+
<p style="color: #007bff;">{{Reset Password URL}}</p>
|
513
|
+
<p>For your security, please make sure to keep your new password safe and avoid using it for other sites.</p>
|
514
|
+
<p>If you have any questions, feel free to reach out to our support team at <a href="mailto:{{Support Email}}">{{Support Email}}</a>.</p>
|
515
|
+
<p>Best regards,<br>{{Company Name}} Support Team</p>
|
516
|
+
</td>
|
517
|
+
</tr>
|
518
|
+
`,
|
519
|
+
category: TEXT_TEMPLATE_CATEGORY[0],
|
520
|
+
type: 'template',
|
521
|
+
templateVariables: [
|
522
|
+
{
|
523
|
+
name: 'user_name',
|
524
|
+
title: 'User Name',
|
525
|
+
type: 'string',
|
526
|
+
required: true,
|
527
|
+
},
|
528
|
+
],
|
529
|
+
},
|
530
|
+
{
|
531
|
+
id: AXPDataGenerator.uuid(),
|
532
|
+
name: 'NewDevice',
|
533
|
+
title: 'New Device Login',
|
534
|
+
content: `
|
535
|
+
<tr>
|
536
|
+
<td>
|
537
|
+
<p>Hi {{User's Name}},</p>
|
538
|
+
<p>We detected a login to your account from a new device. If this was you, there’s nothing you need to do. If you didn’t sign in from a new device, please review your account for any unauthorized activity.</p>
|
539
|
+
<p style="font-weight: bold;">Device Information:</p>
|
540
|
+
<ul>
|
541
|
+
<li><strong>Device:</strong> {{Device Type}}</li>
|
542
|
+
<li><strong>Location:</strong> {{Location, e.g., City, Country}}</li>
|
543
|
+
<li><strong>Date & Time:</strong> {{Date and Time}}</li>
|
544
|
+
<li><strong>IP Address:</strong> {{IP Address}}</li>
|
545
|
+
</ul>
|
546
|
+
<p>If you have any concerns, please secure your account by resetting your password and enabling two-factor authentication.</p>
|
547
|
+
<p style="text-align: center; margin: 20px 0;">
|
548
|
+
<a href="https://example.com/security-settings" style="background-color: #007bff; color: #ffffff; padding: 10px 20px; text-decoration: none; border-radius: 5px;">Review Account Security</a>
|
549
|
+
</p>
|
550
|
+
<p>Thank you for helping us keep your account safe.</p>
|
551
|
+
<p>Best regards,<br>{{Your Company Name}} Security Team</p>
|
552
|
+
</td>
|
553
|
+
</tr>
|
554
|
+
`,
|
555
|
+
category: TEXT_TEMPLATE_CATEGORY[0],
|
556
|
+
type: 'template',
|
557
|
+
templateVariables: [
|
558
|
+
{
|
559
|
+
name: 'user_name',
|
560
|
+
title: 'User Name',
|
561
|
+
type: 'string',
|
562
|
+
required: true,
|
563
|
+
},
|
564
|
+
],
|
565
|
+
},
|
566
|
+
{
|
567
|
+
id: AXPDataGenerator.uuid(),
|
568
|
+
name: 'offer',
|
569
|
+
title: 'Offer',
|
570
|
+
content: `
|
571
|
+
<tr>
|
572
|
+
<td>
|
573
|
+
<p>Hi {{user_name}},</p>
|
574
|
+
<p>We're excited to bring you an exclusive offer! For a limited time, you can enjoy {{Discount Percentage}}% off on {{Product or Service Name}}. Don’t miss out on this amazing deal!</p>
|
575
|
+
<p style="font-weight: bold;">Offer Details:</p>
|
576
|
+
<ul>
|
577
|
+
<li><strong>Discount:</strong> {{Discount Percentage}}%</li>
|
578
|
+
<li><strong>Valid Until:</strong> {{Expiration Date}}</li>
|
579
|
+
<li><strong>Promo Code:</strong> <span style="color: #007bff;">{{Promo Code}}</span></li>
|
580
|
+
</ul>
|
581
|
+
<p style="text-align: center; margin: 20px 0;">
|
582
|
+
<a href="{{Offer Link}}" style="background-color: #ff9800; color: #ffffff; padding: 10px 20px; text-decoration: none; border-radius: 5px;">Redeem Offer</a>
|
583
|
+
</p>
|
584
|
+
<p>Thank you for being a valued customer. We hope you enjoy this special offer!</p>
|
585
|
+
<p>Best regards,<br>{{Company Name}} Team</p>
|
586
|
+
</td>
|
587
|
+
</tr>
|
588
|
+
`,
|
589
|
+
category: TEXT_TEMPLATE_CATEGORY[1],
|
590
|
+
type: 'template',
|
591
|
+
templateVariables: [
|
592
|
+
{
|
593
|
+
name: 'user_name',
|
594
|
+
title: 'User Name',
|
595
|
+
type: 'string',
|
596
|
+
required: true,
|
597
|
+
},
|
598
|
+
],
|
599
|
+
},
|
600
|
+
];
|
601
|
+
|
602
|
+
class AXPTextTemplateCategoryDataSeeder {
|
603
|
+
constructor() {
|
604
|
+
this.storageService = inject(AXPDexieEntityStorageService);
|
605
|
+
}
|
606
|
+
async seed() {
|
607
|
+
await this.storageService.initial(CATEGORY_SOURCE_NAME, TEXT_TEMPLATE_CATEGORY);
|
608
|
+
}
|
609
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXPTextTemplateCategoryDataSeeder, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
610
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXPTextTemplateCategoryDataSeeder }); }
|
611
|
+
}
|
612
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXPTextTemplateCategoryDataSeeder, decorators: [{
|
613
|
+
type: Injectable
|
614
|
+
}] });
|
615
|
+
|
616
|
+
class AXPTextTemplateDataSeeder {
|
617
|
+
constructor() {
|
618
|
+
this.storageService = inject(AXPDexieEntityStorageService);
|
619
|
+
}
|
620
|
+
async seed() {
|
621
|
+
await this.storageService.initial(TEMPLATE_SOURCE_NAME, TEXT_TEMPLATES);
|
622
|
+
}
|
623
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXPTextTemplateDataSeeder, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
624
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXPTextTemplateDataSeeder }); }
|
625
|
+
}
|
626
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXPTextTemplateDataSeeder, decorators: [{
|
627
|
+
type: Injectable
|
628
|
+
}] });
|
629
|
+
|
630
|
+
class AXCMockModule {
|
631
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXCMockModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
632
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.2.0", ngImport: i0, type: AXCMockModule }); }
|
633
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXCMockModule, providers: [
|
634
|
+
AXPDexieEntityStorageService,
|
635
|
+
{
|
636
|
+
provide: AXMNotificationService,
|
637
|
+
useClass: AXMMockNotificationService,
|
638
|
+
},
|
639
|
+
{
|
640
|
+
provide: AXPDesignerConnectorAbstract,
|
641
|
+
useClass: AXPMockDesignerConnector,
|
642
|
+
},
|
643
|
+
{
|
644
|
+
provide: AXPEntityStorageService,
|
645
|
+
useClass: AXPDexieEntityStorageService,
|
646
|
+
},
|
647
|
+
{
|
648
|
+
provide: AXP_DATA_SEEDER_TOKEN,
|
649
|
+
useClass: AXPGlobalVariablesDataSeeder,
|
650
|
+
multi: true,
|
651
|
+
},
|
652
|
+
{
|
653
|
+
provide: AXP_DATA_SEEDER_TOKEN,
|
654
|
+
useClass: AXPLanguageDataSeeder,
|
655
|
+
multi: true,
|
656
|
+
},
|
657
|
+
{
|
658
|
+
provide: AXP_DATA_SEEDER_TOKEN,
|
659
|
+
useClass: AXPTextTemplateCategoryDataSeeder,
|
660
|
+
multi: true,
|
661
|
+
},
|
662
|
+
{
|
663
|
+
provide: AXP_DATA_SEEDER_TOKEN,
|
664
|
+
useClass: AXPTextTemplateDataSeeder,
|
665
|
+
multi: true,
|
666
|
+
},
|
667
|
+
{
|
668
|
+
provide: AXP_DATA_SEEDER_TOKEN,
|
669
|
+
useClass: AXPApplicationTemplateDataSeeder,
|
670
|
+
multi: true,
|
671
|
+
},
|
672
|
+
{
|
673
|
+
provide: AXMCommentService,
|
674
|
+
useClass: AXMCommentMockService,
|
675
|
+
},
|
676
|
+
] }); }
|
677
|
+
}
|
678
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXCMockModule, decorators: [{
|
679
|
+
type: NgModule,
|
680
|
+
args: [{
|
681
|
+
imports: [],
|
682
|
+
exports: [],
|
683
|
+
declarations: [],
|
684
|
+
providers: [
|
685
|
+
AXPDexieEntityStorageService,
|
686
|
+
{
|
687
|
+
provide: AXMNotificationService,
|
688
|
+
useClass: AXMMockNotificationService,
|
689
|
+
},
|
690
|
+
{
|
691
|
+
provide: AXPDesignerConnectorAbstract,
|
692
|
+
useClass: AXPMockDesignerConnector,
|
693
|
+
},
|
694
|
+
{
|
695
|
+
provide: AXPEntityStorageService,
|
696
|
+
useClass: AXPDexieEntityStorageService,
|
697
|
+
},
|
698
|
+
{
|
699
|
+
provide: AXP_DATA_SEEDER_TOKEN,
|
700
|
+
useClass: AXPGlobalVariablesDataSeeder,
|
701
|
+
multi: true,
|
702
|
+
},
|
703
|
+
{
|
704
|
+
provide: AXP_DATA_SEEDER_TOKEN,
|
705
|
+
useClass: AXPLanguageDataSeeder,
|
706
|
+
multi: true,
|
707
|
+
},
|
708
|
+
{
|
709
|
+
provide: AXP_DATA_SEEDER_TOKEN,
|
710
|
+
useClass: AXPTextTemplateCategoryDataSeeder,
|
711
|
+
multi: true,
|
712
|
+
},
|
713
|
+
{
|
714
|
+
provide: AXP_DATA_SEEDER_TOKEN,
|
715
|
+
useClass: AXPTextTemplateDataSeeder,
|
716
|
+
multi: true,
|
717
|
+
},
|
718
|
+
{
|
719
|
+
provide: AXP_DATA_SEEDER_TOKEN,
|
720
|
+
useClass: AXPApplicationTemplateDataSeeder,
|
721
|
+
multi: true,
|
722
|
+
},
|
723
|
+
{
|
724
|
+
provide: AXMCommentService,
|
725
|
+
useClass: AXMCommentMockService,
|
726
|
+
},
|
727
|
+
],
|
728
|
+
}]
|
729
|
+
}] });
|
730
|
+
|
731
|
+
/**
|
732
|
+
* Generated bundle index. Do not edit.
|
733
|
+
*/
|
734
|
+
|
735
|
+
export { AXCMockModule };
|
736
|
+
//# sourceMappingURL=acorex-connectivity-mock.mjs.map
|