@aptana/multichannel-common 2.9.12
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/core/domain/Command.d.ts +3 -0
- package/core/domain/Command.js +2 -0
- package/core/domain/Entity.d.ts +6 -0
- package/core/domain/Entity.js +13 -0
- package/core/domain/Identifier.d.ts +5 -0
- package/core/domain/Identifier.js +13 -0
- package/core/domain/UniqueId.d.ts +4 -0
- package/core/domain/UniqueId.js +11 -0
- package/core/domain/UseCase.d.ts +3 -0
- package/core/domain/UseCase.js +2 -0
- package/core/domain/ValueObject.d.ts +4 -0
- package/core/domain/ValueObject.js +10 -0
- package/core/domain/auth/Auth.d.ts +17 -0
- package/core/domain/auth/Auth.js +41 -0
- package/core/domain/auth/Authenticable.d.ts +4 -0
- package/core/domain/auth/Authenticable.js +2 -0
- package/core/domain/auth/Guard.d.ts +20 -0
- package/core/domain/auth/Guard.js +2 -0
- package/core/domain/auth/TokenGuard.d.ts +33 -0
- package/core/domain/auth/TokenGuard.js +94 -0
- package/core/domain/auth/UserProvider.d.ts +17 -0
- package/core/domain/auth/UserProvider.js +2 -0
- package/core/domain/cache/Cache.d.ts +8 -0
- package/core/domain/cache/Cache.js +2 -0
- package/core/domain/cache/Repo.d.ts +51 -0
- package/core/domain/cache/Repo.js +2 -0
- package/core/domain/cache/Store.d.ts +26 -0
- package/core/domain/cache/Store.js +2 -0
- package/core/domain/events/Event.d.ts +8 -0
- package/core/domain/events/Event.js +2 -0
- package/core/domain/events/Listener.d.ts +4 -0
- package/core/domain/events/Listener.js +2 -0
- package/core/domain/events/Worker.d.ts +3 -0
- package/core/domain/events/Worker.js +2 -0
- package/core/domain/loaders/Loader.d.ts +4 -0
- package/core/domain/loaders/Loader.js +2 -0
- package/core/domain/loaders/Manager.d.ts +3 -0
- package/core/domain/loaders/Manager.js +2 -0
- package/core/errors/AppError.d.ts +10 -0
- package/core/errors/AppError.js +16 -0
- package/core/errors/AuthenticationTokenMissingError.d.ts +5 -0
- package/core/errors/AuthenticationTokenMissingError.js +11 -0
- package/core/errors/BadRequestError.d.ts +5 -0
- package/core/errors/BadRequestError.js +11 -0
- package/core/errors/NotAuthorizedError.d.ts +5 -0
- package/core/errors/NotAuthorizedError.js +11 -0
- package/core/errors/NotFoundError.d.ts +5 -0
- package/core/errors/NotFoundError.js +11 -0
- package/core/errors/RequestValidationError.d.ts +10 -0
- package/core/errors/RequestValidationError.js +47 -0
- package/core/errors/ValidationError.d.ts +8 -0
- package/core/errors/ValidationError.js +19 -0
- package/core/errors/WrongAuthenticationTokenError.d.ts +5 -0
- package/core/errors/WrongAuthenticationTokenError.js +11 -0
- package/core/errors/WrongCredentialsError.d.ts +5 -0
- package/core/errors/WrongCredentialsError.js +11 -0
- package/core/index.d.ts +48 -0
- package/core/index.js +69 -0
- package/core/infrastructure/Container.d.ts +1 -0
- package/core/infrastructure/Container.js +8 -0
- package/core/infrastructure/Controller.d.ts +9 -0
- package/core/infrastructure/Controller.js +30 -0
- package/core/infrastructure/DatabaseRepository.d.ts +35 -0
- package/core/infrastructure/DatabaseRepository.js +2 -0
- package/core/infrastructure/Mapper.d.ts +2 -0
- package/core/infrastructure/Mapper.js +6 -0
- package/core/infrastructure/Repo.d.ts +2 -0
- package/core/infrastructure/Repo.js +6 -0
- package/core/infrastructure/cache/Cache.d.ts +47 -0
- package/core/infrastructure/cache/Cache.js +101 -0
- package/core/infrastructure/cache/InMemoryCache.d.ts +20 -0
- package/core/infrastructure/cache/InMemoryCache.js +62 -0
- package/core/infrastructure/cache/RedisCache.d.ts +15 -0
- package/core/infrastructure/cache/RedisCache.js +51 -0
- package/core/infrastructure/cache/Repo.d.ts +25 -0
- package/core/infrastructure/cache/Repo.js +103 -0
- package/core/infrastructure/cache/stores/ArrayStore.d.ts +17 -0
- package/core/infrastructure/cache/stores/ArrayStore.js +65 -0
- package/core/infrastructure/cache/stores/FileStore.d.ts +14 -0
- package/core/infrastructure/cache/stores/FileStore.js +171 -0
- package/core/infrastructure/cache/stores/NullStore.d.ts +9 -0
- package/core/infrastructure/cache/stores/NullStore.js +24 -0
- package/core/infrastructure/cache/stores/RedisStore.d.ts +13 -0
- package/core/infrastructure/cache/stores/RedisStore.js +44 -0
- package/core/infrastructure/events/ChannelEvent.d.ts +9 -0
- package/core/infrastructure/events/ChannelEvent.js +37 -0
- package/core/infrastructure/events/Connection.d.ts +8 -0
- package/core/infrastructure/events/Connection.js +30 -0
- package/core/infrastructure/events/Event.d.ts +16 -0
- package/core/infrastructure/events/Event.js +42 -0
- package/core/infrastructure/events/Listener.d.ts +23 -0
- package/core/infrastructure/events/Listener.js +77 -0
- package/core/infrastructure/events/Worker.d.ts +9 -0
- package/core/infrastructure/events/Worker.js +34 -0
- package/core/infrastructure/events/grpc/Connection.d.ts +9 -0
- package/core/infrastructure/events/grpc/Connection.js +34 -0
- package/core/infrastructure/events/grpc/Event.d.ts +12 -0
- package/core/infrastructure/events/grpc/Event.js +80 -0
- package/core/infrastructure/events/grpc/Listener.d.ts +16 -0
- package/core/infrastructure/events/grpc/Listener.js +74 -0
- package/core/infrastructure/events/rpc/Event.d.ts +13 -0
- package/core/infrastructure/events/rpc/Event.js +98 -0
- package/core/infrastructure/events/rpc/Listener.d.ts +6 -0
- package/core/infrastructure/events/rpc/Listener.js +30 -0
- package/core/infrastructure/http/App.d.ts +15 -0
- package/core/infrastructure/http/App.js +73 -0
- package/core/infrastructure/http/middleware/alwaysAcceptJsonMiddleware.d.ts +2 -0
- package/core/infrastructure/http/middleware/alwaysAcceptJsonMiddleware.js +8 -0
- package/core/infrastructure/http/middleware/errorMiddleware.d.ts +2 -0
- package/core/infrastructure/http/middleware/errorMiddleware.js +18 -0
- package/core/infrastructure/http/middleware/loggerMiddleware.d.ts +2 -0
- package/core/infrastructure/http/middleware/loggerMiddleware.js +17 -0
- package/core/infrastructure/http/middleware/routeNotFoundMiddleware.d.ts +2 -0
- package/core/infrastructure/http/middleware/routeNotFoundMiddleware.js +11 -0
- package/core/infrastructure/http/middleware/validationMiddleware.d.ts +4 -0
- package/core/infrastructure/http/middleware/validationMiddleware.js +35 -0
- package/core/infrastructure/loaders/Loader.d.ts +8 -0
- package/core/infrastructure/loaders/Loader.js +14 -0
- package/core/infrastructure/loaders/Manager.d.ts +7 -0
- package/core/infrastructure/loaders/Manager.js +24 -0
- package/core/modules/health/errors/ConnectionNotFoundError.d.ts +4 -0
- package/core/modules/health/errors/ConnectionNotFoundError.js +10 -0
- package/core/modules/health/errors/HealthCheckError.d.ts +3 -0
- package/core/modules/health/errors/HealthCheckError.js +10 -0
- package/core/modules/health/errors/TimeoutError.d.ts +4 -0
- package/core/modules/health/errors/TimeoutError.js +10 -0
- package/core/modules/health/useCases/health/HealthController.d.ts +20 -0
- package/core/modules/health/useCases/health/HealthController.js +75 -0
- package/core/modules/health/useCases/healthCheck/HealthCheck.d.ts +8 -0
- package/core/modules/health/useCases/healthCheck/HealthCheck.js +37 -0
- package/core/modules/health/useCases/healthCheck/HealthCheckExecutor.d.ts +8 -0
- package/core/modules/health/useCases/healthCheck/HealthCheckExecutor.js +48 -0
- package/core/modules/health/useCases/healthCheck/HealthCheckResult.d.ts +6 -0
- package/core/modules/health/useCases/healthCheck/HealthCheckResult.js +2 -0
- package/core/modules/health/useCases/healthIndicator/HealthIndicator.d.ts +7 -0
- package/core/modules/health/useCases/healthIndicator/HealthIndicator.js +14 -0
- package/core/modules/health/useCases/healthIndicator/HealthIndicatorResult.d.ts +7 -0
- package/core/modules/health/useCases/healthIndicator/HealthIndicatorResult.js +2 -0
- package/core/modules/health/useCases/healthIndicator/database/mongooseHealthIndicator.d.ts +21 -0
- package/core/modules/health/useCases/healthIndicator/database/mongooseHealthIndicator.js +69 -0
- package/core/modules/health/useCases/healthIndicator/database/sequelizeHealthIndicator.d.ts +27 -0
- package/core/modules/health/useCases/healthIndicator/database/sequelizeHealthIndicator.js +73 -0
- package/core/modules/health/useCases/healthIndicator/message-broker/rabbitmqHealthIndicator.d.ts +21 -0
- package/core/modules/health/useCases/healthIndicator/message-broker/rabbitmqHealthIndicator.js +66 -0
- package/core/modules/health/utils/promise.d.ts +1 -0
- package/core/modules/health/utils/promise.js +12 -0
- package/core/modules/service/useCases/detail/DetailController.d.ts +6 -0
- package/core/modules/service/useCases/detail/DetailController.js +25 -0
- package/core/utils/Crypto.d.ts +24 -0
- package/core/utils/Crypto.js +93 -0
- package/core/utils/Hash.d.ts +6 -0
- package/core/utils/Hash.js +23 -0
- package/core/utils/cache.d.ts +1 -0
- package/core/utils/cache.js +16 -0
- package/core/utils/commands.d.ts +2 -0
- package/core/utils/commands.js +7 -0
- package/core/utils/events.d.ts +3 -0
- package/core/utils/events.js +11 -0
- package/core/utils/logger.d.ts +2 -0
- package/core/utils/logger.js +15 -0
- package/core/utils/response.d.ts +4 -0
- package/core/utils/response.js +11 -0
- package/core/utils/validator.d.ts +4 -0
- package/core/utils/validator.js +48 -0
- package/domain/BalanceMutation.d.ts +18 -0
- package/domain/BalanceMutation.js +8 -0
- package/domain/ChannelWhatsapp.d.ts +18 -0
- package/domain/ChannelWhatsapp.js +2 -0
- package/domain/MessageTemplate.d.ts +26 -0
- package/domain/MessageTemplate.js +12 -0
- package/domain/MessageTemplateCategoryUpdate.d.ts +8 -0
- package/domain/MessageTemplateCategoryUpdate.js +2 -0
- package/domain/MessageTemplateStatusUpdate.d.ts +8 -0
- package/domain/MessageTemplateStatusUpdate.js +2 -0
- package/domain/Payment.d.ts +14 -0
- package/domain/Payment.js +8 -0
- package/domain/Report.d.ts +33 -0
- package/domain/Report.js +15 -0
- package/domain/TransactionMessaging.d.ts +33 -0
- package/domain/TransactionMessaging.js +11 -0
- package/domain/TransactionMessagingStatusUpdate.d.ts +6 -0
- package/domain/TransactionMessagingStatusUpdate.js +2 -0
- package/domain/User.d.ts +25 -0
- package/domain/User.js +19 -0
- package/domain/index.d.ts +10 -0
- package/domain/index.js +26 -0
- package/index.d.ts +3 -0
- package/index.js +19 -0
- package/package.json +57 -0
- package/readme.md +4 -0
- package/shared/index.d.ts +5 -0
- package/shared/index.js +21 -0
- package/shared/plugins/axios-logger-mongo.d.ts +5 -0
- package/shared/plugins/axios-logger-mongo.js +113 -0
- package/shared/plugins/axios.d.ts +1 -0
- package/shared/plugins/axios.js +31 -0
- package/shared/plugins/cursor.d.ts +29 -0
- package/shared/plugins/cursor.js +231 -0
- package/shared/plugins/mongoose.d.ts +31 -0
- package/shared/plugins/mongoose.js +125 -0
- package/shared/resources/JsonResource.d.ts +16 -0
- package/shared/resources/JsonResource.js +59 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Schema, Model } from 'mongoose';
|
|
2
|
+
interface PaginationMeta {
|
|
3
|
+
limit: number | undefined;
|
|
4
|
+
offset: number | undefined;
|
|
5
|
+
total: number | undefined;
|
|
6
|
+
}
|
|
7
|
+
export declare class PaginationModel<T> {
|
|
8
|
+
meta: PaginationMeta;
|
|
9
|
+
docs: T[];
|
|
10
|
+
}
|
|
11
|
+
export interface PaginationOptions {
|
|
12
|
+
query?: any | undefined;
|
|
13
|
+
aggregate?: any | undefined;
|
|
14
|
+
populate?: any | undefined;
|
|
15
|
+
select?: any | undefined;
|
|
16
|
+
search?: {
|
|
17
|
+
value: string | undefined;
|
|
18
|
+
fields: string[] | undefined;
|
|
19
|
+
};
|
|
20
|
+
sort?: any | undefined;
|
|
21
|
+
projection?: any | undefined;
|
|
22
|
+
page?: {
|
|
23
|
+
limit?: any | undefined;
|
|
24
|
+
offset?: any | undefined;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export interface Pagination<T> extends Model<T> {
|
|
28
|
+
paginate(options?: PaginationOptions | undefined, onError?: Function | undefined): Promise<PaginationModel<T> | undefined>;
|
|
29
|
+
}
|
|
30
|
+
export declare function mongoosePaginate<T>(schema: Schema<T>): void;
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mongoosePaginate = exports.PaginationModel = void 0;
|
|
4
|
+
class PaginationModel {
|
|
5
|
+
meta = {
|
|
6
|
+
limit: 0,
|
|
7
|
+
offset: 0,
|
|
8
|
+
total: undefined,
|
|
9
|
+
};
|
|
10
|
+
docs = [];
|
|
11
|
+
}
|
|
12
|
+
exports.PaginationModel = PaginationModel;
|
|
13
|
+
function mongoosePaginate(schema) {
|
|
14
|
+
schema.statics.paginate = async function paginate(options, onError) {
|
|
15
|
+
// INIT
|
|
16
|
+
let query = options?.query ?? {};
|
|
17
|
+
let aggregate = options?.aggregate ?? undefined;
|
|
18
|
+
let populate = options?.populate ?? undefined;
|
|
19
|
+
let select = options?.select ?? undefined;
|
|
20
|
+
let search = options?.search ?? undefined;
|
|
21
|
+
let sort = options?.sort ?? '-_id';
|
|
22
|
+
let projection = options?.projection ?? {};
|
|
23
|
+
// PAGING
|
|
24
|
+
const limit = parseInt(options?.page?.limit) > 0 ? parseInt(options?.page?.limit) : 0;
|
|
25
|
+
const skip = parseInt(options?.page?.offset) > 0 ? parseInt(options?.page?.offset) : 0;
|
|
26
|
+
// SEARCHING
|
|
27
|
+
if (search
|
|
28
|
+
&& search.value
|
|
29
|
+
&& search.fields
|
|
30
|
+
&& search.fields.length) {
|
|
31
|
+
let searchQuery = {
|
|
32
|
+
'$regex': search.value,
|
|
33
|
+
'$options': 'i',
|
|
34
|
+
};
|
|
35
|
+
if (search.fields?.length == 1) {
|
|
36
|
+
query[search.fields[0]] = searchQuery;
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
if (!query.$or) {
|
|
40
|
+
query.$or = [];
|
|
41
|
+
}
|
|
42
|
+
search.fields.forEach(function (el) {
|
|
43
|
+
let obj = {};
|
|
44
|
+
obj[el] = searchQuery;
|
|
45
|
+
query.$or.push(obj);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
// QUERY
|
|
50
|
+
let docsPromise;
|
|
51
|
+
if (aggregate != undefined) {
|
|
52
|
+
var mQuery = this.aggregate(aggregate);
|
|
53
|
+
if (select != undefined) {
|
|
54
|
+
mQuery = mQuery.project(select);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
var mQuery = this.find(query, projection);
|
|
59
|
+
if (select != undefined) {
|
|
60
|
+
mQuery = mQuery.select(select);
|
|
61
|
+
}
|
|
62
|
+
if (populate != undefined) {
|
|
63
|
+
mQuery = mQuery.populate(populate);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (sort != undefined) {
|
|
67
|
+
mQuery = mQuery.sort(sort);
|
|
68
|
+
}
|
|
69
|
+
if (limit > 0) {
|
|
70
|
+
mQuery = mQuery.skip(skip);
|
|
71
|
+
mQuery = mQuery.limit(limit);
|
|
72
|
+
}
|
|
73
|
+
docsPromise = mQuery.exec();
|
|
74
|
+
// COUNTING
|
|
75
|
+
let countPromise;
|
|
76
|
+
if (aggregate != undefined) {
|
|
77
|
+
countPromise = this.aggregate(aggregate).count('count');
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
countPromise = this.countDocuments(query).exec();
|
|
81
|
+
}
|
|
82
|
+
// PERFORM
|
|
83
|
+
try {
|
|
84
|
+
const [counts, docs] = await Promise.all([countPromise, docsPromise]);
|
|
85
|
+
let count = 0;
|
|
86
|
+
if (aggregate != undefined) {
|
|
87
|
+
if (counts != undefined
|
|
88
|
+
&& counts[0] != undefined
|
|
89
|
+
&& counts[0]['count'] != undefined) {
|
|
90
|
+
count = counts[0]['count'];
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
count = counts;
|
|
95
|
+
}
|
|
96
|
+
const myModel = new PaginationModel();
|
|
97
|
+
myModel.meta.total = count;
|
|
98
|
+
myModel.meta.offset = skip;
|
|
99
|
+
if (limit > 0) {
|
|
100
|
+
myModel.meta.limit = limit;
|
|
101
|
+
}
|
|
102
|
+
if (limit == 0) {
|
|
103
|
+
myModel.meta.limit = 0;
|
|
104
|
+
}
|
|
105
|
+
myModel.docs = docs;
|
|
106
|
+
return myModel;
|
|
107
|
+
}
|
|
108
|
+
catch (error) {
|
|
109
|
+
if (onError != undefined) {
|
|
110
|
+
onError(error);
|
|
111
|
+
}
|
|
112
|
+
return undefined;
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
const options = {
|
|
116
|
+
virtuals: true,
|
|
117
|
+
transform: function (doc, ret) {
|
|
118
|
+
ret.id = ret._id;
|
|
119
|
+
delete ret.__v;
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
schema.set('toJSON', options);
|
|
123
|
+
schema.set('toObject', options);
|
|
124
|
+
}
|
|
125
|
+
exports.mongoosePaginate = mongoosePaginate;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare class JsonResource {
|
|
2
|
+
[property: string]: any;
|
|
3
|
+
protected hidden: string[];
|
|
4
|
+
protected fillable: string[];
|
|
5
|
+
protected attributes: any;
|
|
6
|
+
constructor(attributes: object);
|
|
7
|
+
protected fill(attributes: any): void;
|
|
8
|
+
protected isAttribute(key: string): boolean;
|
|
9
|
+
protected getAttribute(key: string): any;
|
|
10
|
+
protected setAttribute(key: string, value: any): void;
|
|
11
|
+
protected getHidden(): string[];
|
|
12
|
+
protected setHidden(keys: string[]): void;
|
|
13
|
+
protected getFillable(): string[];
|
|
14
|
+
protected setFillable(keys: string[]): void;
|
|
15
|
+
toJSON(): any;
|
|
16
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.JsonResource = void 0;
|
|
4
|
+
class JsonResource {
|
|
5
|
+
hidden = [];
|
|
6
|
+
fillable = [];
|
|
7
|
+
attributes = {};
|
|
8
|
+
constructor(attributes) {
|
|
9
|
+
this.fill(attributes);
|
|
10
|
+
return new Proxy(this, {
|
|
11
|
+
get: (target, property) => {
|
|
12
|
+
if (target.isAttribute(property)) {
|
|
13
|
+
return target.getAttribute(property);
|
|
14
|
+
}
|
|
15
|
+
return target[property];
|
|
16
|
+
},
|
|
17
|
+
set: (target, property, value) => {
|
|
18
|
+
target.setAttribute(property, value);
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
fill(attributes) {
|
|
24
|
+
for (const key in attributes) {
|
|
25
|
+
this.setAttribute(key, attributes[key]);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
isAttribute(key) {
|
|
29
|
+
return this.attributes.hasOwnProperty(key);
|
|
30
|
+
}
|
|
31
|
+
getAttribute(key) {
|
|
32
|
+
return this.attributes[key];
|
|
33
|
+
}
|
|
34
|
+
setAttribute(key, value) {
|
|
35
|
+
this.attributes[key] = value;
|
|
36
|
+
}
|
|
37
|
+
getHidden() {
|
|
38
|
+
return this.hidden;
|
|
39
|
+
}
|
|
40
|
+
setHidden(keys) {
|
|
41
|
+
this.hidden = keys;
|
|
42
|
+
}
|
|
43
|
+
getFillable() {
|
|
44
|
+
return this.fillable;
|
|
45
|
+
}
|
|
46
|
+
setFillable(keys) {
|
|
47
|
+
this.fillable = keys;
|
|
48
|
+
}
|
|
49
|
+
toJSON() {
|
|
50
|
+
return Object.keys(this.attributes)
|
|
51
|
+
.filter(key => this.getFillable().includes(key))
|
|
52
|
+
.filter(key => !this.getHidden().includes(key))
|
|
53
|
+
.reduce((target, key) => {
|
|
54
|
+
target[key] = this.attributes[key];
|
|
55
|
+
return target;
|
|
56
|
+
}, {});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.JsonResource = JsonResource;
|