plutin 1.0.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/dist/base-controller-cec5714c.d.ts +46 -0
- package/dist/core/decorators/controller-http-decorator.cjs +752 -0
- package/dist/core/decorators/controller-http-decorator.cjs.map +1 -0
- package/dist/core/decorators/controller-http-decorator.d.cts +13 -0
- package/dist/core/decorators/controller-http-decorator.d.ts +13 -0
- package/dist/core/decorators/controller-http-decorator.js +735 -0
- package/dist/core/decorators/controller-http-decorator.js.map +1 -0
- package/dist/core/decorators/dependency-container.cjs +92 -0
- package/dist/core/decorators/dependency-container.cjs.map +1 -0
- package/dist/core/decorators/dependency-container.d.cts +22 -0
- package/dist/core/decorators/dependency-container.d.ts +22 -0
- package/dist/core/decorators/dependency-container.js +69 -0
- package/dist/core/decorators/dependency-container.js.map +1 -0
- package/dist/core/entities/aggregate-root.cjs +99 -0
- package/dist/core/entities/aggregate-root.cjs.map +1 -0
- package/dist/core/entities/aggregate-root.d.cts +8 -0
- package/dist/core/entities/aggregate-root.d.ts +8 -0
- package/dist/core/entities/aggregate-root.js +74 -0
- package/dist/core/entities/aggregate-root.js.map +1 -0
- package/dist/core/entities/common-dto.cjs +19 -0
- package/dist/core/entities/common-dto.cjs.map +1 -0
- package/dist/core/entities/common-dto.d.cts +10 -0
- package/dist/core/entities/common-dto.d.ts +10 -0
- package/dist/core/entities/common-dto.js +1 -0
- package/dist/core/entities/common-dto.js.map +1 -0
- package/dist/core/entities/domain-event.cjs +19 -0
- package/dist/core/entities/domain-event.cjs.map +1 -0
- package/dist/core/entities/domain-event.d.cts +6 -0
- package/dist/core/entities/domain-event.d.ts +6 -0
- package/dist/core/entities/domain-event.js +1 -0
- package/dist/core/entities/domain-event.js.map +1 -0
- package/dist/core/entities/entity.cjs +92 -0
- package/dist/core/entities/entity.cjs.map +1 -0
- package/dist/core/entities/entity.d.cts +17 -0
- package/dist/core/entities/entity.d.ts +17 -0
- package/dist/core/entities/entity.js +67 -0
- package/dist/core/entities/entity.js.map +1 -0
- package/dist/core/entities/optional.cjs +19 -0
- package/dist/core/entities/optional.cjs.map +1 -0
- package/dist/core/entities/optional.d.cts +3 -0
- package/dist/core/entities/optional.d.ts +3 -0
- package/dist/core/entities/optional.js +1 -0
- package/dist/core/entities/optional.js.map +1 -0
- package/dist/core/entities/unique-entity-id.cjs +50 -0
- package/dist/core/entities/unique-entity-id.cjs.map +1 -0
- package/dist/core/entities/unique-entity-id.d.cts +9 -0
- package/dist/core/entities/unique-entity-id.d.ts +9 -0
- package/dist/core/entities/unique-entity-id.js +27 -0
- package/dist/core/entities/unique-entity-id.js.map +1 -0
- package/dist/core/entities/value-object.cjs +40 -0
- package/dist/core/entities/value-object.cjs.map +1 -0
- package/dist/core/entities/value-object.d.cts +6 -0
- package/dist/core/entities/value-object.d.ts +6 -0
- package/dist/core/entities/value-object.js +17 -0
- package/dist/core/entities/value-object.js.map +1 -0
- package/dist/core/entities/watched-list.cjs +121 -0
- package/dist/core/entities/watched-list.cjs.map +1 -0
- package/dist/core/entities/watched-list.d.cts +27 -0
- package/dist/core/entities/watched-list.d.ts +27 -0
- package/dist/core/entities/watched-list.js +98 -0
- package/dist/core/entities/watched-list.js.map +1 -0
- package/dist/core/entities/watched-list.test.cjs +186 -0
- package/dist/core/entities/watched-list.test.cjs.map +1 -0
- package/dist/core/entities/watched-list.test.d.cts +2 -0
- package/dist/core/entities/watched-list.test.d.ts +2 -0
- package/dist/core/entities/watched-list.test.js +185 -0
- package/dist/core/entities/watched-list.test.js.map +1 -0
- package/dist/core/errors/api-common-error.cjs +38 -0
- package/dist/core/errors/api-common-error.cjs.map +1 -0
- package/dist/core/errors/api-common-error.d.cts +28 -0
- package/dist/core/errors/api-common-error.d.ts +28 -0
- package/dist/core/errors/api-common-error.js +13 -0
- package/dist/core/errors/api-common-error.js.map +1 -0
- package/dist/core/errors/application-error.cjs +54 -0
- package/dist/core/errors/application-error.cjs.map +1 -0
- package/dist/core/errors/application-error.d.cts +8 -0
- package/dist/core/errors/application-error.d.ts +8 -0
- package/dist/core/errors/application-error.js +33 -0
- package/dist/core/errors/application-error.js.map +1 -0
- package/dist/core/errors/conflict-error.cjs +56 -0
- package/dist/core/errors/conflict-error.cjs.map +1 -0
- package/dist/core/errors/conflict-error.d.cts +13 -0
- package/dist/core/errors/conflict-error.d.ts +13 -0
- package/dist/core/errors/conflict-error.js +35 -0
- package/dist/core/errors/conflict-error.js.map +1 -0
- package/dist/core/errors/domain-error.cjs +54 -0
- package/dist/core/errors/domain-error.cjs.map +1 -0
- package/dist/core/errors/domain-error.d.cts +8 -0
- package/dist/core/errors/domain-error.d.ts +8 -0
- package/dist/core/errors/domain-error.js +33 -0
- package/dist/core/errors/domain-error.js.map +1 -0
- package/dist/core/errors/http-client-error.cjs +54 -0
- package/dist/core/errors/http-client-error.cjs.map +1 -0
- package/dist/core/errors/http-client-error.d.cts +8 -0
- package/dist/core/errors/http-client-error.d.ts +8 -0
- package/dist/core/errors/http-client-error.js +33 -0
- package/dist/core/errors/http-client-error.js.map +1 -0
- package/dist/core/errors/infra-error.cjs +54 -0
- package/dist/core/errors/infra-error.cjs.map +1 -0
- package/dist/core/errors/infra-error.d.cts +8 -0
- package/dist/core/errors/infra-error.d.ts +8 -0
- package/dist/core/errors/infra-error.js +33 -0
- package/dist/core/errors/infra-error.js.map +1 -0
- package/dist/core/errors/validation-error.cjs +55 -0
- package/dist/core/errors/validation-error.cjs.map +1 -0
- package/dist/core/errors/validation-error.d.cts +8 -0
- package/dist/core/errors/validation-error.d.ts +8 -0
- package/dist/core/errors/validation-error.js +34 -0
- package/dist/core/errors/validation-error.js.map +1 -0
- package/dist/core/http/base-controller.cjs +731 -0
- package/dist/core/http/base-controller.cjs.map +1 -0
- package/dist/core/http/base-controller.d.cts +1 -0
- package/dist/core/http/base-controller.d.ts +1 -0
- package/dist/core/http/base-controller.js +720 -0
- package/dist/core/http/base-controller.js.map +1 -0
- package/dist/core/http/dto-response.cjs +19 -0
- package/dist/core/http/dto-response.cjs.map +1 -0
- package/dist/core/http/dto-response.d.cts +10 -0
- package/dist/core/http/dto-response.d.ts +10 -0
- package/dist/core/http/dto-response.js +1 -0
- package/dist/core/http/dto-response.js.map +1 -0
- package/dist/core/http/error-notifier.cjs +19 -0
- package/dist/core/http/error-notifier.cjs.map +1 -0
- package/dist/core/http/error-notifier.d.cts +1 -0
- package/dist/core/http/error-notifier.d.ts +1 -0
- package/dist/core/http/error-notifier.js +1 -0
- package/dist/core/http/error-notifier.js.map +1 -0
- package/dist/core/http/get-take-and-skip.cjs +40 -0
- package/dist/core/http/get-take-and-skip.cjs.map +1 -0
- package/dist/core/http/get-take-and-skip.d.cts +6 -0
- package/dist/core/http/get-take-and-skip.d.ts +6 -0
- package/dist/core/http/get-take-and-skip.js +17 -0
- package/dist/core/http/get-take-and-skip.js.map +1 -0
- package/dist/core/http/health-connections.cjs +42 -0
- package/dist/core/http/health-connections.cjs.map +1 -0
- package/dist/core/http/health-connections.d.cts +16 -0
- package/dist/core/http/health-connections.d.ts +16 -0
- package/dist/core/http/health-connections.js +23 -0
- package/dist/core/http/health-connections.js.map +1 -0
- package/dist/core/http/http.cjs +19 -0
- package/dist/core/http/http.cjs.map +1 -0
- package/dist/core/http/http.d.cts +10 -0
- package/dist/core/http/http.d.ts +10 -0
- package/dist/core/http/http.js +1 -0
- package/dist/core/http/http.js.map +1 -0
- package/dist/core/http/pagination.cjs +19 -0
- package/dist/core/http/pagination.cjs.map +1 -0
- package/dist/core/http/pagination.d.cts +9 -0
- package/dist/core/http/pagination.d.ts +9 -0
- package/dist/core/http/pagination.js +1 -0
- package/dist/core/http/pagination.js.map +1 -0
- package/dist/core/http/validator.cjs +19 -0
- package/dist/core/http/validator.cjs.map +1 -0
- package/dist/core/http/validator.d.cts +11 -0
- package/dist/core/http/validator.d.ts +11 -0
- package/dist/core/http/validator.js +1 -0
- package/dist/core/http/validator.js.map +1 -0
- package/dist/core/index.cjs +957 -0
- package/dist/core/index.cjs.map +1 -0
- package/dist/core/index.d.cts +18 -0
- package/dist/core/index.d.ts +18 -0
- package/dist/core/index.js +933 -0
- package/dist/core/index.js.map +1 -0
- package/dist/infra/adapters/http/express-adapter.cjs +577 -0
- package/dist/infra/adapters/http/express-adapter.cjs.map +1 -0
- package/dist/infra/adapters/http/express-adapter.d.cts +15 -0
- package/dist/infra/adapters/http/express-adapter.d.ts +15 -0
- package/dist/infra/adapters/http/express-adapter.js +556 -0
- package/dist/infra/adapters/http/express-adapter.js.map +1 -0
- package/dist/infra/adapters/http/fastify-adapter.cjs +562 -0
- package/dist/infra/adapters/http/fastify-adapter.cjs.map +1 -0
- package/dist/infra/adapters/http/fastify-adapter.d.cts +14 -0
- package/dist/infra/adapters/http/fastify-adapter.d.ts +14 -0
- package/dist/infra/adapters/http/fastify-adapter.js +541 -0
- package/dist/infra/adapters/http/fastify-adapter.js.map +1 -0
- package/dist/infra/adapters/http/response-error-code.cjs +35 -0
- package/dist/infra/adapters/http/response-error-code.cjs.map +1 -0
- package/dist/infra/adapters/http/response-error-code.d.cts +6 -0
- package/dist/infra/adapters/http/response-error-code.d.ts +6 -0
- package/dist/infra/adapters/http/response-error-code.js +10 -0
- package/dist/infra/adapters/http/response-error-code.js.map +1 -0
- package/dist/infra/adapters/http/validate-controller-metadata.cjs +42 -0
- package/dist/infra/adapters/http/validate-controller-metadata.cjs.map +1 -0
- package/dist/infra/adapters/http/validate-controller-metadata.d.cts +11 -0
- package/dist/infra/adapters/http/validate-controller-metadata.d.ts +11 -0
- package/dist/infra/adapters/http/validate-controller-metadata.js +19 -0
- package/dist/infra/adapters/http/validate-controller-metadata.js.map +1 -0
- package/dist/infra/adapters/notifications/discord.cjs +86 -0
- package/dist/infra/adapters/notifications/discord.cjs.map +1 -0
- package/dist/infra/adapters/notifications/discord.d.cts +14 -0
- package/dist/infra/adapters/notifications/discord.d.ts +14 -0
- package/dist/infra/adapters/notifications/discord.js +65 -0
- package/dist/infra/adapters/notifications/discord.js.map +1 -0
- package/dist/infra/adapters/notifications/in-memory.cjs +40 -0
- package/dist/infra/adapters/notifications/in-memory.cjs.map +1 -0
- package/dist/infra/adapters/notifications/in-memory.d.cts +8 -0
- package/dist/infra/adapters/notifications/in-memory.d.ts +8 -0
- package/dist/infra/adapters/notifications/in-memory.js +21 -0
- package/dist/infra/adapters/notifications/in-memory.js.map +1 -0
- package/dist/infra/adapters/notifications/sentry.cjs +129 -0
- package/dist/infra/adapters/notifications/sentry.cjs.map +1 -0
- package/dist/infra/adapters/notifications/sentry.d.cts +13 -0
- package/dist/infra/adapters/notifications/sentry.d.ts +13 -0
- package/dist/infra/adapters/notifications/sentry.js +96 -0
- package/dist/infra/adapters/notifications/sentry.js.map +1 -0
- package/dist/infra/adapters/validators/zod/index.cjs +179 -0
- package/dist/infra/adapters/validators/zod/index.cjs.map +1 -0
- package/dist/infra/adapters/validators/zod/index.d.cts +19 -0
- package/dist/infra/adapters/validators/zod/index.d.ts +19 -0
- package/dist/infra/adapters/validators/zod/index.js +154 -0
- package/dist/infra/adapters/validators/zod/index.js.map +1 -0
- package/dist/infra/adapters/validators/zod/zod-map-error.cjs +79 -0
- package/dist/infra/adapters/validators/zod/zod-map-error.cjs.map +1 -0
- package/dist/infra/adapters/validators/zod/zod-map-error.d.cts +15 -0
- package/dist/infra/adapters/validators/zod/zod-map-error.d.ts +15 -0
- package/dist/infra/adapters/validators/zod/zod-map-error.js +60 -0
- package/dist/infra/adapters/validators/zod/zod-map-error.js.map +1 -0
- package/dist/infra/adapters/validators/zod/zod-validator.cjs +178 -0
- package/dist/infra/adapters/validators/zod/zod-validator.cjs.map +1 -0
- package/dist/infra/adapters/validators/zod/zod-validator.d.cts +13 -0
- package/dist/infra/adapters/validators/zod/zod-validator.d.ts +13 -0
- package/dist/infra/adapters/validators/zod/zod-validator.js +153 -0
- package/dist/infra/adapters/validators/zod/zod-validator.js.map +1 -0
- package/dist/infra/env/index.cjs +473 -0
- package/dist/infra/env/index.cjs.map +1 -0
- package/dist/infra/env/index.d.cts +10 -0
- package/dist/infra/env/index.d.ts +10 -0
- package/dist/infra/env/index.js +456 -0
- package/dist/infra/env/index.js.map +1 -0
- package/dist/infra/index.cjs +781 -0
- package/dist/infra/index.cjs.map +1 -0
- package/dist/infra/index.d.cts +5 -0
- package/dist/infra/index.d.ts +5 -0
- package/dist/infra/index.js +752 -0
- package/dist/infra/index.js.map +1 -0
- package/package.json +82 -0
- package/readme.md +56 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
|
|
4
|
+
// src/core/entities/watched-list.ts
|
|
5
|
+
var WatchedList = class {
|
|
6
|
+
static {
|
|
7
|
+
__name(this, "WatchedList");
|
|
8
|
+
}
|
|
9
|
+
currentItems;
|
|
10
|
+
initial;
|
|
11
|
+
new;
|
|
12
|
+
removed;
|
|
13
|
+
updated;
|
|
14
|
+
constructor(initialItems) {
|
|
15
|
+
this.currentItems = initialItems || [];
|
|
16
|
+
this.initial = initialItems || [];
|
|
17
|
+
this.new = [];
|
|
18
|
+
this.removed = [];
|
|
19
|
+
this.updated = [];
|
|
20
|
+
}
|
|
21
|
+
getItems() {
|
|
22
|
+
return this.currentItems;
|
|
23
|
+
}
|
|
24
|
+
getNewItems() {
|
|
25
|
+
return this.new;
|
|
26
|
+
}
|
|
27
|
+
getRemovedItems() {
|
|
28
|
+
return this.removed;
|
|
29
|
+
}
|
|
30
|
+
getUpdatedItems() {
|
|
31
|
+
return this.updated;
|
|
32
|
+
}
|
|
33
|
+
addUpdatedItem(item) {
|
|
34
|
+
return this.updated.push(item);
|
|
35
|
+
}
|
|
36
|
+
isCurrentItem(item) {
|
|
37
|
+
return this.currentItems.filter((v) => this.compareItems(item, v)).length !== 0;
|
|
38
|
+
}
|
|
39
|
+
isNewItem(item) {
|
|
40
|
+
return this.new.filter((v) => this.compareItems(item, v)).length !== 0;
|
|
41
|
+
}
|
|
42
|
+
isRemovedItem(item) {
|
|
43
|
+
return this.removed.filter((v) => this.compareItems(item, v)).length !== 0;
|
|
44
|
+
}
|
|
45
|
+
removeFromNew(item) {
|
|
46
|
+
this.new = this.new.filter((v) => !this.compareItems(v, item));
|
|
47
|
+
}
|
|
48
|
+
removeFromCurrent(item) {
|
|
49
|
+
this.currentItems = this.currentItems.filter((v) => !this.compareItems(item, v));
|
|
50
|
+
}
|
|
51
|
+
removeFromRemoved(item) {
|
|
52
|
+
this.removed = this.removed.filter((v) => !this.compareItems(item, v));
|
|
53
|
+
}
|
|
54
|
+
wasAddedInitially(item) {
|
|
55
|
+
return this.initial.filter((v) => this.compareItems(item, v)).length !== 0;
|
|
56
|
+
}
|
|
57
|
+
exists(item) {
|
|
58
|
+
return this.isCurrentItem(item);
|
|
59
|
+
}
|
|
60
|
+
add(item) {
|
|
61
|
+
if (this.isRemovedItem(item)) {
|
|
62
|
+
this.removeFromRemoved(item);
|
|
63
|
+
}
|
|
64
|
+
if (!this.isNewItem(item) && !this.wasAddedInitially(item)) {
|
|
65
|
+
this.new.push(item);
|
|
66
|
+
}
|
|
67
|
+
if (!this.isCurrentItem(item)) {
|
|
68
|
+
this.currentItems.push(item);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
remove(item) {
|
|
72
|
+
this.removeFromCurrent(item);
|
|
73
|
+
if (this.isNewItem(item)) {
|
|
74
|
+
this.removeFromNew(item);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if (!this.isRemovedItem(item)) {
|
|
78
|
+
this.removed.push(item);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
update(items) {
|
|
82
|
+
const newItems = items.filter((a) => {
|
|
83
|
+
return !this.getItems().some((b) => this.compareItems(a, b));
|
|
84
|
+
});
|
|
85
|
+
const removedItems = this.getItems().filter((a) => {
|
|
86
|
+
return !items.some((b) => this.compareItems(a, b));
|
|
87
|
+
});
|
|
88
|
+
const updatedItems = items.filter((item) => !newItems.some((a) => this.compareItems(item, a) && !removedItems.some((b) => this.compareItems(item, b))));
|
|
89
|
+
this.currentItems = items;
|
|
90
|
+
this.new = newItems;
|
|
91
|
+
this.removed = removedItems;
|
|
92
|
+
this.updated = updatedItems;
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
export {
|
|
96
|
+
WatchedList
|
|
97
|
+
};
|
|
98
|
+
//# sourceMappingURL=watched-list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/core/entities/watched-list.ts"],"sourcesContent":["export abstract class WatchedList<T> {\n public currentItems: T[]\n private initial: T[]\n private new: T[]\n private removed: T[]\n private updated: T[]\n\n constructor(initialItems?: T[]) {\n this.currentItems = initialItems || []\n this.initial = initialItems || []\n this.new = []\n this.removed = []\n this.updated = []\n }\n\n abstract compareItems(a: T, b: T): boolean\n\n public getItems(): T[] {\n return this.currentItems\n }\n\n public getNewItems(): T[] {\n return this.new\n }\n\n public getRemovedItems(): T[] {\n return this.removed\n }\n\n public getUpdatedItems(): T[] {\n return this.updated\n }\n\n public addUpdatedItem(item: T) {\n return this.updated.push(item)\n }\n\n private isCurrentItem(item: T): boolean {\n return (\n this.currentItems.filter((v: T) => this.compareItems(item, v)).length !==\n 0\n )\n }\n\n private isNewItem(item: T): boolean {\n return this.new.filter((v: T) => this.compareItems(item, v)).length !== 0\n }\n\n private isRemovedItem(item: T): boolean {\n return (\n this.removed.filter((v: T) => this.compareItems(item, v)).length !== 0\n )\n }\n\n private removeFromNew(item: T): void {\n this.new = this.new.filter((v) => !this.compareItems(v, item))\n }\n\n private removeFromCurrent(item: T): void {\n this.currentItems = this.currentItems.filter(\n (v) => !this.compareItems(item, v)\n )\n }\n\n private removeFromRemoved(item: T): void {\n this.removed = this.removed.filter((v) => !this.compareItems(item, v))\n }\n\n private wasAddedInitially(item: T): boolean {\n return (\n this.initial.filter((v: T) => this.compareItems(item, v)).length !== 0\n )\n }\n\n public exists(item: T): boolean {\n return this.isCurrentItem(item)\n }\n\n public add(item: T): void {\n if (this.isRemovedItem(item)) {\n this.removeFromRemoved(item)\n }\n\n if (!this.isNewItem(item) && !this.wasAddedInitially(item)) {\n this.new.push(item)\n }\n\n if (!this.isCurrentItem(item)) {\n this.currentItems.push(item)\n }\n }\n\n public remove(item: T): void {\n this.removeFromCurrent(item)\n\n if (this.isNewItem(item)) {\n this.removeFromNew(item)\n\n return\n }\n\n if (!this.isRemovedItem(item)) {\n this.removed.push(item)\n }\n }\n\n public update(items: T[]): void {\n const newItems = items.filter((a) => {\n return !this.getItems().some((b) => this.compareItems(a, b))\n })\n\n const removedItems = this.getItems().filter((a) => {\n return !items.some((b) => this.compareItems(a, b))\n })\n\n const updatedItems = items.filter(\n (item) =>\n !newItems.some(\n (a) =>\n this.compareItems(item, a) &&\n !removedItems.some((b) => this.compareItems(item, b))\n )\n )\n\n this.currentItems = items\n this.new = newItems\n this.removed = removedItems\n this.updated = updatedItems\n }\n}\n"],"mappings":";;;;AAAO,IAAeA,cAAf,MAAeA;EAAtB,OAAsBA;;;EACbC;EACCC;EACAC;EACAC;EACAC;EAERC,YAAYC,cAAoB;AAC9B,SAAKN,eAAeM,gBAAgB,CAAA;AACpC,SAAKL,UAAUK,gBAAgB,CAAA;AAC/B,SAAKJ,MAAM,CAAA;AACX,SAAKC,UAAU,CAAA;AACf,SAAKC,UAAU,CAAA;EACjB;EAIOG,WAAgB;AACrB,WAAO,KAAKP;EACd;EAEOQ,cAAmB;AACxB,WAAO,KAAKN;EACd;EAEOO,kBAAuB;AAC5B,WAAO,KAAKN;EACd;EAEOO,kBAAuB;AAC5B,WAAO,KAAKN;EACd;EAEOO,eAAeC,MAAS;AAC7B,WAAO,KAAKR,QAAQS,KAAKD,IAAAA;EAC3B;EAEQE,cAAcF,MAAkB;AACtC,WACE,KAAKZ,aAAae,OAAO,CAACC,MAAS,KAAKC,aAAaL,MAAMI,CAAAA,CAAAA,EAAIE,WAC/D;EAEJ;EAEQC,UAAUP,MAAk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F;AAEA,QAAI,CAAC,KAAKQ,cAAcR,IAAAA,GAAO;AAC7B,WAAKT,QAAQU,KAAKD,IAAAA;IACpB;EACF;EAEOgB,OAAOC,OAAkB;AAC9B,UAAMC,WAAWD,MAAMd,OAAO,CAACgB,MAAAA;AAC7B,aAAO,CAAC,KAAKxB,SAAQ,EAAGyB,KAAK,CAACC,MAAM,KAAKhB,aAAac,GAAGE,CAAAA,CAAAA;IAC3D,CAAA;AAEA,UAAMC,eAAe,KAAK3B,SAAQ,EAAGQ,OAAO,CAACgB,MAAAA;AAC3C,aAAO,CAACF,MAAMG,KAAK,CAACC,MAAM,KAAKhB,aAAac,GAAGE,CAAAA,CAAAA;IACjD,CAAA;AAEA,UAAME,eAAeN,MAAMd,OACzB,CAACH,SACC,CAACkB,SAASE,KACR,CAACD,MACC,KAAKd,aAAaL,MAAMmB,CAAAA,KACxB,CAACG,aAAaF,KAAK,CAACC,MAAM,KAAKhB,aAAaL,MAAMqB,CAAAA,CAAAA,CAAAA,CAAAA;AAI1D,SAAKjC,eAAe6B;AACpB,SAAK3B,MAAM4B;AACX,SAAK3B,UAAU+B;AACf,SAAK9B,UAAU+B;EACjB;AACF;","names":["WatchedList","currentItems","initial","new","removed","updated","constructor","initialItems","getItems","getNewItems","getRemovedItems","getUpdatedItems","addUpdatedItem","item","push","isCurrentItem","filter","v","compareItems","length","isNewItem","isRemovedItem","removeFromNew","removeFromCurrent","removeFromRemoved","wasAddedInitially","exists","add","remove","update","items","newItems","a","some","b","removedItems","updatedItems"]}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
4
|
+
|
|
5
|
+
// src/core/entities/watched-list.ts
|
|
6
|
+
var WatchedList = class {
|
|
7
|
+
static {
|
|
8
|
+
__name(this, "WatchedList");
|
|
9
|
+
}
|
|
10
|
+
currentItems;
|
|
11
|
+
initial;
|
|
12
|
+
new;
|
|
13
|
+
removed;
|
|
14
|
+
updated;
|
|
15
|
+
constructor(initialItems) {
|
|
16
|
+
this.currentItems = initialItems || [];
|
|
17
|
+
this.initial = initialItems || [];
|
|
18
|
+
this.new = [];
|
|
19
|
+
this.removed = [];
|
|
20
|
+
this.updated = [];
|
|
21
|
+
}
|
|
22
|
+
getItems() {
|
|
23
|
+
return this.currentItems;
|
|
24
|
+
}
|
|
25
|
+
getNewItems() {
|
|
26
|
+
return this.new;
|
|
27
|
+
}
|
|
28
|
+
getRemovedItems() {
|
|
29
|
+
return this.removed;
|
|
30
|
+
}
|
|
31
|
+
getUpdatedItems() {
|
|
32
|
+
return this.updated;
|
|
33
|
+
}
|
|
34
|
+
addUpdatedItem(item) {
|
|
35
|
+
return this.updated.push(item);
|
|
36
|
+
}
|
|
37
|
+
isCurrentItem(item) {
|
|
38
|
+
return this.currentItems.filter((v) => this.compareItems(item, v)).length !== 0;
|
|
39
|
+
}
|
|
40
|
+
isNewItem(item) {
|
|
41
|
+
return this.new.filter((v) => this.compareItems(item, v)).length !== 0;
|
|
42
|
+
}
|
|
43
|
+
isRemovedItem(item) {
|
|
44
|
+
return this.removed.filter((v) => this.compareItems(item, v)).length !== 0;
|
|
45
|
+
}
|
|
46
|
+
removeFromNew(item) {
|
|
47
|
+
this.new = this.new.filter((v) => !this.compareItems(v, item));
|
|
48
|
+
}
|
|
49
|
+
removeFromCurrent(item) {
|
|
50
|
+
this.currentItems = this.currentItems.filter((v) => !this.compareItems(item, v));
|
|
51
|
+
}
|
|
52
|
+
removeFromRemoved(item) {
|
|
53
|
+
this.removed = this.removed.filter((v) => !this.compareItems(item, v));
|
|
54
|
+
}
|
|
55
|
+
wasAddedInitially(item) {
|
|
56
|
+
return this.initial.filter((v) => this.compareItems(item, v)).length !== 0;
|
|
57
|
+
}
|
|
58
|
+
exists(item) {
|
|
59
|
+
return this.isCurrentItem(item);
|
|
60
|
+
}
|
|
61
|
+
add(item) {
|
|
62
|
+
if (this.isRemovedItem(item)) {
|
|
63
|
+
this.removeFromRemoved(item);
|
|
64
|
+
}
|
|
65
|
+
if (!this.isNewItem(item) && !this.wasAddedInitially(item)) {
|
|
66
|
+
this.new.push(item);
|
|
67
|
+
}
|
|
68
|
+
if (!this.isCurrentItem(item)) {
|
|
69
|
+
this.currentItems.push(item);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
remove(item) {
|
|
73
|
+
this.removeFromCurrent(item);
|
|
74
|
+
if (this.isNewItem(item)) {
|
|
75
|
+
this.removeFromNew(item);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
if (!this.isRemovedItem(item)) {
|
|
79
|
+
this.removed.push(item);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
update(items) {
|
|
83
|
+
const newItems = items.filter((a) => {
|
|
84
|
+
return !this.getItems().some((b) => this.compareItems(a, b));
|
|
85
|
+
});
|
|
86
|
+
const removedItems = this.getItems().filter((a) => {
|
|
87
|
+
return !items.some((b) => this.compareItems(a, b));
|
|
88
|
+
});
|
|
89
|
+
const updatedItems = items.filter((item) => !newItems.some((a) => this.compareItems(item, a) && !removedItems.some((b) => this.compareItems(item, b))));
|
|
90
|
+
this.currentItems = items;
|
|
91
|
+
this.new = newItems;
|
|
92
|
+
this.removed = removedItems;
|
|
93
|
+
this.updated = updatedItems;
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
// src/core/entities/watched-list.test.ts
|
|
98
|
+
var NumberWatchedList = class NumberWatchedList2 extends WatchedList {
|
|
99
|
+
static {
|
|
100
|
+
__name(this, "NumberWatchedList");
|
|
101
|
+
}
|
|
102
|
+
compareItems(a, b) {
|
|
103
|
+
return a === b;
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
describe("Watched List", () => {
|
|
107
|
+
it("should be able to create a watched list with initial items", () => {
|
|
108
|
+
const list = new NumberWatchedList([
|
|
109
|
+
1,
|
|
110
|
+
2,
|
|
111
|
+
3
|
|
112
|
+
]);
|
|
113
|
+
expect(list.currentItems).toHaveLength(3);
|
|
114
|
+
});
|
|
115
|
+
it("should be able to add new items to the list", () => {
|
|
116
|
+
const list = new NumberWatchedList([
|
|
117
|
+
1,
|
|
118
|
+
2,
|
|
119
|
+
3
|
|
120
|
+
]);
|
|
121
|
+
list.add(4);
|
|
122
|
+
expect(list.currentItems).toHaveLength(4);
|
|
123
|
+
expect(list.getNewItems()).toEqual([
|
|
124
|
+
4
|
|
125
|
+
]);
|
|
126
|
+
});
|
|
127
|
+
it("should be able to add remove items from the list", () => {
|
|
128
|
+
const list = new NumberWatchedList([
|
|
129
|
+
1,
|
|
130
|
+
2,
|
|
131
|
+
3
|
|
132
|
+
]);
|
|
133
|
+
list.remove(2);
|
|
134
|
+
expect(list.currentItems).toHaveLength(2);
|
|
135
|
+
expect(list.getRemovedItems()).toEqual([
|
|
136
|
+
2
|
|
137
|
+
]);
|
|
138
|
+
});
|
|
139
|
+
it("should be able to add an item even if it was removed before", () => {
|
|
140
|
+
const list = new NumberWatchedList([
|
|
141
|
+
1,
|
|
142
|
+
2,
|
|
143
|
+
3
|
|
144
|
+
]);
|
|
145
|
+
list.remove(2);
|
|
146
|
+
list.add(2);
|
|
147
|
+
expect(list.currentItems).toHaveLength(3);
|
|
148
|
+
expect(list.getRemovedItems()).toEqual([]);
|
|
149
|
+
expect(list.getNewItems()).toEqual([]);
|
|
150
|
+
});
|
|
151
|
+
it("should be able to remove an item even if it was added before", () => {
|
|
152
|
+
const list = new NumberWatchedList([
|
|
153
|
+
1,
|
|
154
|
+
2,
|
|
155
|
+
3
|
|
156
|
+
]);
|
|
157
|
+
list.add(4);
|
|
158
|
+
list.remove(4);
|
|
159
|
+
expect(list.currentItems).toHaveLength(3);
|
|
160
|
+
expect(list.getRemovedItems()).toEqual([]);
|
|
161
|
+
expect(list.getNewItems()).toEqual([]);
|
|
162
|
+
});
|
|
163
|
+
it("should be able to update watched list items", () => {
|
|
164
|
+
const list = new NumberWatchedList([
|
|
165
|
+
1,
|
|
166
|
+
2,
|
|
167
|
+
3
|
|
168
|
+
]);
|
|
169
|
+
list.update([
|
|
170
|
+
1,
|
|
171
|
+
3,
|
|
172
|
+
5
|
|
173
|
+
]);
|
|
174
|
+
expect(list.getRemovedItems()).toEqual([
|
|
175
|
+
2
|
|
176
|
+
]);
|
|
177
|
+
expect(list.getNewItems()).toEqual([
|
|
178
|
+
5
|
|
179
|
+
]);
|
|
180
|
+
expect(list.getUpdatedItems()).toEqual([
|
|
181
|
+
1,
|
|
182
|
+
3
|
|
183
|
+
]);
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
//# sourceMappingURL=watched-list.test.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/core/entities/watched-list.ts","../../../src/core/entities/watched-list.test.ts"],"sourcesContent":["export abstract class WatchedList<T> {\n public currentItems: T[]\n private initial: T[]\n private new: T[]\n private removed: T[]\n private updated: T[]\n\n constructor(initialItems?: T[]) {\n this.currentItems = initialItems || []\n this.initial = initialItems || []\n this.new = []\n this.removed = []\n this.updated = []\n }\n\n abstract compareItems(a: T, b: T): boolean\n\n public getItems(): T[] {\n return this.currentItems\n }\n\n public getNewItems(): T[] {\n return this.new\n }\n\n public getRemovedItems(): T[] {\n return this.removed\n }\n\n public getUpdatedItems(): T[] {\n return this.updated\n }\n\n public addUpdatedItem(item: T) {\n return this.updated.push(item)\n }\n\n private isCurrentItem(item: T): boolean {\n return (\n this.currentItems.filter((v: T) => this.compareItems(item, v)).length !==\n 0\n )\n }\n\n private isNewItem(item: T): boolean {\n return this.new.filter((v: T) => this.compareItems(item, v)).length !== 0\n }\n\n private isRemovedItem(item: T): boolean {\n return (\n this.removed.filter((v: T) => this.compareItems(item, v)).length !== 0\n )\n }\n\n private removeFromNew(item: T): void {\n this.new = this.new.filter((v) => !this.compareItems(v, item))\n }\n\n private removeFromCurrent(item: T): void {\n this.currentItems = this.currentItems.filter(\n (v) => !this.compareItems(item, v)\n )\n }\n\n private removeFromRemoved(item: T): void {\n this.removed = this.removed.filter((v) => !this.compareItems(item, v))\n }\n\n private wasAddedInitially(item: T): boolean {\n return (\n this.initial.filter((v: T) => this.compareItems(item, v)).length !== 0\n )\n }\n\n public exists(item: T): boolean {\n return this.isCurrentItem(item)\n }\n\n public add(item: T): void {\n if (this.isRemovedItem(item)) {\n this.removeFromRemoved(item)\n }\n\n if (!this.isNewItem(item) && !this.wasAddedInitially(item)) {\n this.new.push(item)\n }\n\n if (!this.isCurrentItem(item)) {\n this.currentItems.push(item)\n }\n }\n\n public remove(item: T): void {\n this.removeFromCurrent(item)\n\n if (this.isNewItem(item)) {\n this.removeFromNew(item)\n\n return\n }\n\n if (!this.isRemovedItem(item)) {\n this.removed.push(item)\n }\n }\n\n public update(items: T[]): void {\n const newItems = items.filter((a) => {\n return !this.getItems().some((b) => this.compareItems(a, b))\n })\n\n const removedItems = this.getItems().filter((a) => {\n return !items.some((b) => this.compareItems(a, b))\n })\n\n const updatedItems = items.filter(\n (item) =>\n !newItems.some(\n (a) =>\n this.compareItems(item, a) &&\n !removedItems.some((b) => this.compareItems(item, b))\n )\n )\n\n this.currentItems = items\n this.new = newItems\n this.removed = removedItems\n this.updated = updatedItems\n }\n}\n","import { WatchedList } from './watched-list'\n\nclass NumberWatchedList extends WatchedList<number> {\n compareItems(a: number, b: number): boolean {\n return a === b\n }\n}\n\ndescribe('Watched List', () => {\n it('should be able to create a watched list with initial items', () => {\n const list = new NumberWatchedList([1, 2, 3])\n\n expect(list.currentItems).toHaveLength(3)\n })\n\n it('should be able to add new items to the list', () => {\n const list = new NumberWatchedList([1, 2, 3])\n\n list.add(4)\n\n expect(list.currentItems).toHaveLength(4)\n expect(list.getNewItems()).toEqual([4])\n })\n\n it('should be able to add remove items from the list', () => {\n const list = new NumberWatchedList([1, 2, 3])\n\n list.remove(2)\n\n expect(list.currentItems).toHaveLength(2)\n expect(list.getRemovedItems()).toEqual([2])\n })\n\n it('should be able to add an item even if it was removed before', () => {\n const list = new NumberWatchedList([1, 2, 3])\n\n list.remove(2)\n list.add(2)\n\n expect(list.currentItems).toHaveLength(3)\n expect(list.getRemovedItems()).toEqual([])\n expect(list.getNewItems()).toEqual([])\n })\n\n it('should be able to remove an item even if it was added before', () => {\n const list = new NumberWatchedList([1, 2, 3])\n\n list.add(4)\n list.remove(4)\n\n expect(list.currentItems).toHaveLength(3)\n expect(list.getRemovedItems()).toEqual([])\n expect(list.getNewItems()).toEqual([])\n })\n\n it('should be able to update watched list items', () => {\n const list = new NumberWatchedList([1, 2, 3])\n\n list.update([1, 3, 5])\n\n expect(list.getRemovedItems()).toEqual([2])\n expect(list.getNewItems()).toEqual([5])\n expect(list.getUpdatedItems()).toEqual([1, 3])\n })\n})\n"],"mappings":";;;;;AAAO,IAAeA,cAAf,MAAeA;EAAtB,OAAsBA;;;EACbC;EACCC;EACAC;EACAC;EACAC;EAERC,YAAYC,cAAoB;AAC9B,SAAKN,eAAeM,gBAAgB,CAAA;AACpC,SAAKL,UAAUK,gBAAgB,CAAA;AAC/B,SAAKJ,MAAM,CAAA;AACX,SAAKC,UAAU,CAAA;AACf,SAAKC,UAAU,CAAA;EACjB;EAIOG,WAAgB;AACrB,WAAO,KAAKP;EACd;EAEOQ,cAAmB;AACxB,WAAO,KAAKN;EACd;EAEOO,kBAAuB;AAC5B,WAAO,KAAKN;EACd;EAEOO,kBAAuB;AAC5B,WAAO,KAAKN;EACd;EAEOO,eAAeC,MAAS;AAC7B,WAAO,KAAKR,QAAQS,KAAKD,IAAAA;EAC3B;EAEQE,cAAcF,MAAkB;AACtC,WACE,KAAKZ,aAAae,OAAO,CAACC,MAAS,KAAKC,aAAaL,MAAMI,CAAAA,CAAAA,EAAIE,WAC/D;EAEJ;EAEQC,UAAUP,MAAkB;AAClC,WAAO,KAAKV,IAAIa,OAAO,CAACC,MAAS,KAAKC,aAAaL,MAAMI,CAAAA,CAAAA,EAAIE,WAAW;EAC1E;EAEQE,cAAcR,M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E;AAE5CO,SAAKO,OAAO,CAAA;AAEZN,WAAOD,KAAKE,YAAY,EAAEC,aAAa,CAAA;AACvCF,WAAOD,KAAKQ,gBAAe,CAAA,EAAIF,QAAQ;MAAC;KAAE;EAC5C,CAAA;AAEAP,KAAG,+DAA+D,MAAA;AAChE,UAAMC,OAAO,IAAIP,kBAAkB;MAAC;MAAG;MAAG;KAAE;AAE5CO,SAAKO,OAAO,CAAA;AACZP,SAAKI,IAAI,CAAA;AAETH,WAAOD,KAAKE,YAAY,EAAEC,aAAa,CAAA;AACvCF,WAAOD,KAAKQ,gBAAe,CAAA,EAAIF,QAAQ,CAAA,CAAE;AACzCL,WAAOD,KAAKK,YAAW,CAAA,EAAIC,QAAQ,CAAA,CAAE;EACvC,CAAA;AAEAP,KAAG,gEAAgE,MAAA;AACjE,UAAMC,OAAO,IAAIP,kBAAkB;MAAC;MAAG;MAAG;KAAE;AAE5CO,SAAKI,IAAI,CAAA;AACTJ,SAAKO,OAAO,CAAA;AAEZN,WAAOD,KAAKE,YAAY,EAAEC,aAAa,CAAA;AACvCF,WAAOD,KAAKQ,gBAAe,CAAA,EAAIF,QAAQ,CAAA,CAAE;AACzCL,WAAOD,KAAKK,YAAW,CAAA,EAAIC,QAAQ,CAAA,CAAE;EACvC,CAAA;AAEAP,KAAG,+CAA+C,MAAA;AAChD,UAAMC,OAAO,IAAIP,kBAAkB;MAAC;MAAG;MAAG;KAAE;AAE5CO,SAAKS,OAAO;MAAC;MAAG;MAAG;KAAE;AAErBR,WAAOD,KAAKQ,gBAAe,CAAA,EAAIF,QAAQ;MAAC;KAAE;AAC1CL,WAAOD,KAAKK,YAAW,CAAA,EAAIC,QAAQ;MAAC;KAAE;AACtCL,WAAOD,KAAKU,gBAAe,CAAA,EAAIJ,QAAQ;MAAC;MAAG;KAAE;EAC/C,CAAA;AACF,CAAA;","names":["WatchedList","currentItems","initial","new","removed","updated","constructor","initialItems","getItems","getNewItems","getRemovedItems","getUpdatedItems","addUpdatedItem","item","push","isCurrentItem","filter","v","compareItems","length","isNewItem","isRemovedItem","removeFromNew","removeFromCurrent","removeFromRemoved","wasAddedInitially","exists","add","remove","update","items","newItems","a","some","b","removedItems","updatedItems","NumberWatchedList","WatchedList","compareItems","a","b","describe","it","list","expect","currentItems","toHaveLength","add","getNewItems","toEqual","remove","getRemovedItems","update","getUpdatedItems"]}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
|
|
4
|
+
// src/core/entities/watched-list.ts
|
|
5
|
+
var WatchedList = class {
|
|
6
|
+
static {
|
|
7
|
+
__name(this, "WatchedList");
|
|
8
|
+
}
|
|
9
|
+
currentItems;
|
|
10
|
+
initial;
|
|
11
|
+
new;
|
|
12
|
+
removed;
|
|
13
|
+
updated;
|
|
14
|
+
constructor(initialItems) {
|
|
15
|
+
this.currentItems = initialItems || [];
|
|
16
|
+
this.initial = initialItems || [];
|
|
17
|
+
this.new = [];
|
|
18
|
+
this.removed = [];
|
|
19
|
+
this.updated = [];
|
|
20
|
+
}
|
|
21
|
+
getItems() {
|
|
22
|
+
return this.currentItems;
|
|
23
|
+
}
|
|
24
|
+
getNewItems() {
|
|
25
|
+
return this.new;
|
|
26
|
+
}
|
|
27
|
+
getRemovedItems() {
|
|
28
|
+
return this.removed;
|
|
29
|
+
}
|
|
30
|
+
getUpdatedItems() {
|
|
31
|
+
return this.updated;
|
|
32
|
+
}
|
|
33
|
+
addUpdatedItem(item) {
|
|
34
|
+
return this.updated.push(item);
|
|
35
|
+
}
|
|
36
|
+
isCurrentItem(item) {
|
|
37
|
+
return this.currentItems.filter((v) => this.compareItems(item, v)).length !== 0;
|
|
38
|
+
}
|
|
39
|
+
isNewItem(item) {
|
|
40
|
+
return this.new.filter((v) => this.compareItems(item, v)).length !== 0;
|
|
41
|
+
}
|
|
42
|
+
isRemovedItem(item) {
|
|
43
|
+
return this.removed.filter((v) => this.compareItems(item, v)).length !== 0;
|
|
44
|
+
}
|
|
45
|
+
removeFromNew(item) {
|
|
46
|
+
this.new = this.new.filter((v) => !this.compareItems(v, item));
|
|
47
|
+
}
|
|
48
|
+
removeFromCurrent(item) {
|
|
49
|
+
this.currentItems = this.currentItems.filter((v) => !this.compareItems(item, v));
|
|
50
|
+
}
|
|
51
|
+
removeFromRemoved(item) {
|
|
52
|
+
this.removed = this.removed.filter((v) => !this.compareItems(item, v));
|
|
53
|
+
}
|
|
54
|
+
wasAddedInitially(item) {
|
|
55
|
+
return this.initial.filter((v) => this.compareItems(item, v)).length !== 0;
|
|
56
|
+
}
|
|
57
|
+
exists(item) {
|
|
58
|
+
return this.isCurrentItem(item);
|
|
59
|
+
}
|
|
60
|
+
add(item) {
|
|
61
|
+
if (this.isRemovedItem(item)) {
|
|
62
|
+
this.removeFromRemoved(item);
|
|
63
|
+
}
|
|
64
|
+
if (!this.isNewItem(item) && !this.wasAddedInitially(item)) {
|
|
65
|
+
this.new.push(item);
|
|
66
|
+
}
|
|
67
|
+
if (!this.isCurrentItem(item)) {
|
|
68
|
+
this.currentItems.push(item);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
remove(item) {
|
|
72
|
+
this.removeFromCurrent(item);
|
|
73
|
+
if (this.isNewItem(item)) {
|
|
74
|
+
this.removeFromNew(item);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if (!this.isRemovedItem(item)) {
|
|
78
|
+
this.removed.push(item);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
update(items) {
|
|
82
|
+
const newItems = items.filter((a) => {
|
|
83
|
+
return !this.getItems().some((b) => this.compareItems(a, b));
|
|
84
|
+
});
|
|
85
|
+
const removedItems = this.getItems().filter((a) => {
|
|
86
|
+
return !items.some((b) => this.compareItems(a, b));
|
|
87
|
+
});
|
|
88
|
+
const updatedItems = items.filter((item) => !newItems.some((a) => this.compareItems(item, a) && !removedItems.some((b) => this.compareItems(item, b))));
|
|
89
|
+
this.currentItems = items;
|
|
90
|
+
this.new = newItems;
|
|
91
|
+
this.removed = removedItems;
|
|
92
|
+
this.updated = updatedItems;
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
// src/core/entities/watched-list.test.ts
|
|
97
|
+
var NumberWatchedList = class NumberWatchedList2 extends WatchedList {
|
|
98
|
+
static {
|
|
99
|
+
__name(this, "NumberWatchedList");
|
|
100
|
+
}
|
|
101
|
+
compareItems(a, b) {
|
|
102
|
+
return a === b;
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
describe("Watched List", () => {
|
|
106
|
+
it("should be able to create a watched list with initial items", () => {
|
|
107
|
+
const list = new NumberWatchedList([
|
|
108
|
+
1,
|
|
109
|
+
2,
|
|
110
|
+
3
|
|
111
|
+
]);
|
|
112
|
+
expect(list.currentItems).toHaveLength(3);
|
|
113
|
+
});
|
|
114
|
+
it("should be able to add new items to the list", () => {
|
|
115
|
+
const list = new NumberWatchedList([
|
|
116
|
+
1,
|
|
117
|
+
2,
|
|
118
|
+
3
|
|
119
|
+
]);
|
|
120
|
+
list.add(4);
|
|
121
|
+
expect(list.currentItems).toHaveLength(4);
|
|
122
|
+
expect(list.getNewItems()).toEqual([
|
|
123
|
+
4
|
|
124
|
+
]);
|
|
125
|
+
});
|
|
126
|
+
it("should be able to add remove items from the list", () => {
|
|
127
|
+
const list = new NumberWatchedList([
|
|
128
|
+
1,
|
|
129
|
+
2,
|
|
130
|
+
3
|
|
131
|
+
]);
|
|
132
|
+
list.remove(2);
|
|
133
|
+
expect(list.currentItems).toHaveLength(2);
|
|
134
|
+
expect(list.getRemovedItems()).toEqual([
|
|
135
|
+
2
|
|
136
|
+
]);
|
|
137
|
+
});
|
|
138
|
+
it("should be able to add an item even if it was removed before", () => {
|
|
139
|
+
const list = new NumberWatchedList([
|
|
140
|
+
1,
|
|
141
|
+
2,
|
|
142
|
+
3
|
|
143
|
+
]);
|
|
144
|
+
list.remove(2);
|
|
145
|
+
list.add(2);
|
|
146
|
+
expect(list.currentItems).toHaveLength(3);
|
|
147
|
+
expect(list.getRemovedItems()).toEqual([]);
|
|
148
|
+
expect(list.getNewItems()).toEqual([]);
|
|
149
|
+
});
|
|
150
|
+
it("should be able to remove an item even if it was added before", () => {
|
|
151
|
+
const list = new NumberWatchedList([
|
|
152
|
+
1,
|
|
153
|
+
2,
|
|
154
|
+
3
|
|
155
|
+
]);
|
|
156
|
+
list.add(4);
|
|
157
|
+
list.remove(4);
|
|
158
|
+
expect(list.currentItems).toHaveLength(3);
|
|
159
|
+
expect(list.getRemovedItems()).toEqual([]);
|
|
160
|
+
expect(list.getNewItems()).toEqual([]);
|
|
161
|
+
});
|
|
162
|
+
it("should be able to update watched list items", () => {
|
|
163
|
+
const list = new NumberWatchedList([
|
|
164
|
+
1,
|
|
165
|
+
2,
|
|
166
|
+
3
|
|
167
|
+
]);
|
|
168
|
+
list.update([
|
|
169
|
+
1,
|
|
170
|
+
3,
|
|
171
|
+
5
|
|
172
|
+
]);
|
|
173
|
+
expect(list.getRemovedItems()).toEqual([
|
|
174
|
+
2
|
|
175
|
+
]);
|
|
176
|
+
expect(list.getNewItems()).toEqual([
|
|
177
|
+
5
|
|
178
|
+
]);
|
|
179
|
+
expect(list.getUpdatedItems()).toEqual([
|
|
180
|
+
1,
|
|
181
|
+
3
|
|
182
|
+
]);
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
//# sourceMappingURL=watched-list.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/core/entities/watched-list.ts","../../../src/core/entities/watched-list.test.ts"],"sourcesContent":["export abstract class WatchedList<T> {\n public currentItems: T[]\n private initial: T[]\n private new: T[]\n private removed: T[]\n private updated: T[]\n\n constructor(initialItems?: T[]) {\n this.currentItems = initialItems || []\n this.initial = initialItems || []\n this.new = []\n this.removed = []\n this.updated = []\n }\n\n abstract compareItems(a: T, b: T): boolean\n\n public getItems(): T[] {\n return this.currentItems\n }\n\n public getNewItems(): T[] {\n return this.new\n }\n\n public getRemovedItems(): T[] {\n return this.removed\n }\n\n public getUpdatedItems(): T[] {\n return this.updated\n }\n\n public addUpdatedItem(item: T) {\n return this.updated.push(item)\n }\n\n private isCurrentItem(item: T): boolean {\n return (\n this.currentItems.filter((v: T) => this.compareItems(item, v)).length !==\n 0\n )\n }\n\n private isNewItem(item: T): boolean {\n return this.new.filter((v: T) => this.compareItems(item, v)).length !== 0\n }\n\n private isRemovedItem(item: T): boolean {\n return (\n this.removed.filter((v: T) => this.compareItems(item, v)).length !== 0\n )\n }\n\n private removeFromNew(item: T): void {\n this.new = this.new.filter((v) => !this.compareItems(v, item))\n }\n\n private removeFromCurrent(item: T): void {\n this.currentItems = this.currentItems.filter(\n (v) => !this.compareItems(item, v)\n )\n }\n\n private removeFromRemoved(item: T): void {\n this.removed = this.removed.filter((v) => !this.compareItems(item, v))\n }\n\n private wasAddedInitially(item: T): boolean {\n return (\n this.initial.filter((v: T) => this.compareItems(item, v)).length !== 0\n )\n }\n\n public exists(item: T): boolean {\n return this.isCurrentItem(item)\n }\n\n public add(item: T): void {\n if (this.isRemovedItem(item)) {\n this.removeFromRemoved(item)\n }\n\n if (!this.isNewItem(item) && !this.wasAddedInitially(item)) {\n this.new.push(item)\n }\n\n if (!this.isCurrentItem(item)) {\n this.currentItems.push(item)\n }\n }\n\n public remove(item: T): void {\n this.removeFromCurrent(item)\n\n if (this.isNewItem(item)) {\n this.removeFromNew(item)\n\n return\n }\n\n if (!this.isRemovedItem(item)) {\n this.removed.push(item)\n }\n }\n\n public update(items: T[]): void {\n const newItems = items.filter((a) => {\n return !this.getItems().some((b) => this.compareItems(a, b))\n })\n\n const removedItems = this.getItems().filter((a) => {\n return !items.some((b) => this.compareItems(a, b))\n })\n\n const updatedItems = items.filter(\n (item) =>\n !newItems.some(\n (a) =>\n this.compareItems(item, a) &&\n !removedItems.some((b) => this.compareItems(item, b))\n )\n )\n\n this.currentItems = items\n this.new = newItems\n this.removed = removedItems\n this.updated = updatedItems\n }\n}\n","import { WatchedList } from './watched-list'\n\nclass NumberWatchedList extends WatchedList<number> {\n compareItems(a: number, b: number): boolean {\n return a === b\n }\n}\n\ndescribe('Watched List', () => {\n it('should be able to create a watched list with initial items', () => {\n const list = new NumberWatchedList([1, 2, 3])\n\n expect(list.currentItems).toHaveLength(3)\n })\n\n it('should be able to add new items to the list', () => {\n const list = new NumberWatchedList([1, 2, 3])\n\n list.add(4)\n\n expect(list.currentItems).toHaveLength(4)\n expect(list.getNewItems()).toEqual([4])\n })\n\n it('should be able to add remove items from the list', () => {\n const list = new NumberWatchedList([1, 2, 3])\n\n list.remove(2)\n\n expect(list.currentItems).toHaveLength(2)\n expect(list.getRemovedItems()).toEqual([2])\n })\n\n it('should be able to add an item even if it was removed before', () => {\n const list = new NumberWatchedList([1, 2, 3])\n\n list.remove(2)\n list.add(2)\n\n expect(list.currentItems).toHaveLength(3)\n expect(list.getRemovedItems()).toEqual([])\n expect(list.getNewItems()).toEqual([])\n })\n\n it('should be able to remove an item even if it was added before', () => {\n const list = new NumberWatchedList([1, 2, 3])\n\n list.add(4)\n list.remove(4)\n\n expect(list.currentItems).toHaveLength(3)\n expect(list.getRemovedItems()).toEqual([])\n expect(list.getNewItems()).toEqual([])\n })\n\n it('should be able to update watched list items', () => {\n const list = new NumberWatchedList([1, 2, 3])\n\n list.update([1, 3, 5])\n\n expect(list.getRemovedItems()).toEqual([2])\n expect(list.getNewItems()).toEqual([5])\n expect(list.getUpdatedItems()).toEqual([1, 3])\n })\n})\n"],"mappings":";;;;AAAO,IAAeA,cAAf,MAAeA;EAAtB,OAAsBA;;;EACbC;EACCC;EACAC;EACAC;EACAC;EAERC,YAAYC,cAAoB;AAC9B,SAAKN,eAAeM,gBAAgB,CAAA;AACpC,SAAKL,UAAUK,gBAAgB,CAAA;AAC/B,SAAKJ,MAAM,CAAA;AACX,SAAKC,UAAU,CAAA;AACf,SAAKC,UAAU,CAAA;EACjB;E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K,YAAW,CAAA,EAAIC,QAAQ,CAAA,CAAE;EACvC,CAAA;AAEAP,KAAG,+CAA+C,MAAA;AAChD,UAAMC,OAAO,IAAIP,kBAAkB;MAAC;MAAG;MAAG;KAAE;AAE5CO,SAAKS,OAAO;MAAC;MAAG;MAAG;KAAE;AAErBR,WAAOD,KAAKQ,gBAAe,CAAA,EAAIF,QAAQ;MAAC;KAAE;AAC1CL,WAAOD,KAAKK,YAAW,CAAA,EAAIC,QAAQ;MAAC;KAAE;AACtCL,WAAOD,KAAKU,gBAAe,CAAA,EAAIJ,QAAQ;MAAC;MAAG;KAAE;EAC/C,CAAA;AACF,CAAA;","names":["WatchedList","currentItems","initial","new","removed","updated","constructor","initialItems","getItems","getNewItems","getRemovedItems","getUpdatedItems","addUpdatedItem","item","push","isCurrentItem","filter","v","compareItems","length","isNewItem","isRemovedItem","removeFromNew","removeFromCurrent","removeFromRemoved","wasAddedInitially","exists","add","remove","update","items","newItems","a","some","b","removedItems","updatedItems","NumberWatchedList","WatchedList","compareItems","a","b","describe","it","list","expect","currentItems","toHaveLength","add","getNewItems","toEqual","remove","getRemovedItems","update","getUpdatedItems"]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/core/errors/api-common-error.ts
|
|
21
|
+
var api_common_error_exports = {};
|
|
22
|
+
__export(api_common_error_exports, {
|
|
23
|
+
ApiErrorEnum: () => ApiErrorEnum
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(api_common_error_exports);
|
|
26
|
+
var ApiErrorEnum = /* @__PURE__ */ function(ApiErrorEnum2) {
|
|
27
|
+
ApiErrorEnum2["DOMAIN"] = "ERR001";
|
|
28
|
+
ApiErrorEnum2["APPLICATION"] = "ERR002";
|
|
29
|
+
ApiErrorEnum2["INFRA"] = "ERR003";
|
|
30
|
+
ApiErrorEnum2["HTTP_CLIENT"] = "ERR004";
|
|
31
|
+
ApiErrorEnum2["VALIDATOR"] = "ERR005";
|
|
32
|
+
return ApiErrorEnum2;
|
|
33
|
+
}({});
|
|
34
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
35
|
+
0 && (module.exports = {
|
|
36
|
+
ApiErrorEnum
|
|
37
|
+
});
|
|
38
|
+
//# sourceMappingURL=api-common-error.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/core/errors/api-common-error.ts"],"sourcesContent":["export type PropertiesError = {\n receivedValue?: any\n type: string\n message: string\n property: string | number | undefined\n propertyType?: string\n path?: string\n}\n\nexport type CommonError = {\n location: string\n propertyErrors?: PropertiesError[]\n}\n\nexport type ApiCommonError = {\n code: number\n occurredAt: Date\n message: string\n errorCode: string\n errors?: CommonError[]\n}\n\nexport enum ApiErrorEnum {\n DOMAIN = 'ERR001',\n APPLICATION = 'ERR002',\n INFRA = 'ERR003',\n HTTP_CLIENT = 'ERR004',\n VALIDATOR = 'ERR005',\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAsBA;;;;;AAAO,IAAKA,eAAAA,yBAAAA,eAAAA;;;;;;SAAAA;;","names":["ApiErrorEnum"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
type PropertiesError = {
|
|
2
|
+
receivedValue?: any;
|
|
3
|
+
type: string;
|
|
4
|
+
message: string;
|
|
5
|
+
property: string | number | undefined;
|
|
6
|
+
propertyType?: string;
|
|
7
|
+
path?: string;
|
|
8
|
+
};
|
|
9
|
+
type CommonError = {
|
|
10
|
+
location: string;
|
|
11
|
+
propertyErrors?: PropertiesError[];
|
|
12
|
+
};
|
|
13
|
+
type ApiCommonError = {
|
|
14
|
+
code: number;
|
|
15
|
+
occurredAt: Date;
|
|
16
|
+
message: string;
|
|
17
|
+
errorCode: string;
|
|
18
|
+
errors?: CommonError[];
|
|
19
|
+
};
|
|
20
|
+
declare enum ApiErrorEnum {
|
|
21
|
+
DOMAIN = "ERR001",
|
|
22
|
+
APPLICATION = "ERR002",
|
|
23
|
+
INFRA = "ERR003",
|
|
24
|
+
HTTP_CLIENT = "ERR004",
|
|
25
|
+
VALIDATOR = "ERR005"
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export { ApiCommonError, ApiErrorEnum, CommonError, PropertiesError };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
type PropertiesError = {
|
|
2
|
+
receivedValue?: any;
|
|
3
|
+
type: string;
|
|
4
|
+
message: string;
|
|
5
|
+
property: string | number | undefined;
|
|
6
|
+
propertyType?: string;
|
|
7
|
+
path?: string;
|
|
8
|
+
};
|
|
9
|
+
type CommonError = {
|
|
10
|
+
location: string;
|
|
11
|
+
propertyErrors?: PropertiesError[];
|
|
12
|
+
};
|
|
13
|
+
type ApiCommonError = {
|
|
14
|
+
code: number;
|
|
15
|
+
occurredAt: Date;
|
|
16
|
+
message: string;
|
|
17
|
+
errorCode: string;
|
|
18
|
+
errors?: CommonError[];
|
|
19
|
+
};
|
|
20
|
+
declare enum ApiErrorEnum {
|
|
21
|
+
DOMAIN = "ERR001",
|
|
22
|
+
APPLICATION = "ERR002",
|
|
23
|
+
INFRA = "ERR003",
|
|
24
|
+
HTTP_CLIENT = "ERR004",
|
|
25
|
+
VALIDATOR = "ERR005"
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export { ApiCommonError, ApiErrorEnum, CommonError, PropertiesError };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// src/core/errors/api-common-error.ts
|
|
2
|
+
var ApiErrorEnum = /* @__PURE__ */ function(ApiErrorEnum2) {
|
|
3
|
+
ApiErrorEnum2["DOMAIN"] = "ERR001";
|
|
4
|
+
ApiErrorEnum2["APPLICATION"] = "ERR002";
|
|
5
|
+
ApiErrorEnum2["INFRA"] = "ERR003";
|
|
6
|
+
ApiErrorEnum2["HTTP_CLIENT"] = "ERR004";
|
|
7
|
+
ApiErrorEnum2["VALIDATOR"] = "ERR005";
|
|
8
|
+
return ApiErrorEnum2;
|
|
9
|
+
}({});
|
|
10
|
+
export {
|
|
11
|
+
ApiErrorEnum
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=api-common-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/core/errors/api-common-error.ts"],"sourcesContent":["export type PropertiesError = {\n receivedValue?: any\n type: string\n message: string\n property: string | number | undefined\n propertyType?: string\n path?: string\n}\n\nexport type CommonError = {\n location: string\n propertyErrors?: PropertiesError[]\n}\n\nexport type ApiCommonError = {\n code: number\n occurredAt: Date\n message: string\n errorCode: string\n errors?: CommonError[]\n}\n\nexport enum ApiErrorEnum {\n DOMAIN = 'ERR001',\n APPLICATION = 'ERR002',\n INFRA = 'ERR003',\n HTTP_CLIENT = 'ERR004',\n VALIDATOR = 'ERR005',\n}\n"],"mappings":";AAsBO,IAAKA,eAAAA,yBAAAA,eAAAA;;;;;;SAAAA;;","names":["ApiErrorEnum"]}
|