plutin 1.3.0 → 1.3.2
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/index.d.cts +286 -28
- package/dist/index.d.ts +286 -28
- package/dist/{index.js → index.mjs} +1 -1
- package/package.json +4 -3
- package/dist/base-controller-68008870.d.ts +0 -46
- package/dist/core/decorators/controller-http-decorator.cjs +0 -310
- package/dist/core/decorators/controller-http-decorator.cjs.map +0 -1
- package/dist/core/decorators/controller-http-decorator.d.cts +0 -13
- package/dist/core/decorators/controller-http-decorator.d.ts +0 -13
- package/dist/core/decorators/controller-http-decorator.js +0 -285
- package/dist/core/decorators/controller-http-decorator.js.map +0 -1
- package/dist/core/decorators/dependency-container.cjs +0 -95
- package/dist/core/decorators/dependency-container.cjs.map +0 -1
- package/dist/core/decorators/dependency-container.d.cts +0 -22
- package/dist/core/decorators/dependency-container.d.ts +0 -22
- package/dist/core/decorators/dependency-container.js +0 -71
- package/dist/core/decorators/dependency-container.js.map +0 -1
- package/dist/core/entities/aggregate-root.cjs +0 -99
- package/dist/core/entities/aggregate-root.cjs.map +0 -1
- package/dist/core/entities/aggregate-root.d.cts +0 -8
- package/dist/core/entities/aggregate-root.d.ts +0 -8
- package/dist/core/entities/aggregate-root.js +0 -74
- package/dist/core/entities/aggregate-root.js.map +0 -1
- package/dist/core/entities/common-dto.cjs +0 -19
- package/dist/core/entities/common-dto.cjs.map +0 -1
- package/dist/core/entities/common-dto.d.cts +0 -10
- package/dist/core/entities/common-dto.d.ts +0 -10
- package/dist/core/entities/common-dto.js +0 -1
- package/dist/core/entities/common-dto.js.map +0 -1
- package/dist/core/entities/domain-event.cjs +0 -19
- package/dist/core/entities/domain-event.cjs.map +0 -1
- package/dist/core/entities/domain-event.d.cts +0 -6
- package/dist/core/entities/domain-event.d.ts +0 -6
- package/dist/core/entities/domain-event.js +0 -1
- package/dist/core/entities/domain-event.js.map +0 -1
- package/dist/core/entities/entity.cjs +0 -92
- package/dist/core/entities/entity.cjs.map +0 -1
- package/dist/core/entities/entity.d.cts +0 -18
- package/dist/core/entities/entity.d.ts +0 -18
- package/dist/core/entities/entity.js +0 -67
- package/dist/core/entities/entity.js.map +0 -1
- package/dist/core/entities/optional.cjs +0 -19
- package/dist/core/entities/optional.cjs.map +0 -1
- package/dist/core/entities/optional.d.cts +0 -3
- package/dist/core/entities/optional.d.ts +0 -3
- package/dist/core/entities/optional.js +0 -1
- package/dist/core/entities/optional.js.map +0 -1
- package/dist/core/entities/replace.cjs +0 -19
- package/dist/core/entities/replace.cjs.map +0 -1
- package/dist/core/entities/replace.d.cts +0 -5
- package/dist/core/entities/replace.d.ts +0 -5
- package/dist/core/entities/replace.js +0 -1
- package/dist/core/entities/replace.js.map +0 -1
- package/dist/core/entities/unique-entity-id.cjs +0 -50
- package/dist/core/entities/unique-entity-id.cjs.map +0 -1
- package/dist/core/entities/unique-entity-id.d.cts +0 -9
- package/dist/core/entities/unique-entity-id.d.ts +0 -9
- package/dist/core/entities/unique-entity-id.js +0 -27
- package/dist/core/entities/unique-entity-id.js.map +0 -1
- package/dist/core/entities/value-object.cjs +0 -40
- package/dist/core/entities/value-object.cjs.map +0 -1
- package/dist/core/entities/value-object.d.cts +0 -6
- package/dist/core/entities/value-object.d.ts +0 -6
- package/dist/core/entities/value-object.js +0 -17
- package/dist/core/entities/value-object.js.map +0 -1
- package/dist/core/entities/watched-list.cjs +0 -121
- package/dist/core/entities/watched-list.cjs.map +0 -1
- package/dist/core/entities/watched-list.d.cts +0 -27
- package/dist/core/entities/watched-list.d.ts +0 -27
- package/dist/core/entities/watched-list.js +0 -98
- package/dist/core/entities/watched-list.js.map +0 -1
- package/dist/core/entities/watched-list.test.cjs +0 -186
- package/dist/core/entities/watched-list.test.cjs.map +0 -1
- package/dist/core/entities/watched-list.test.d.cts +0 -2
- package/dist/core/entities/watched-list.test.d.ts +0 -2
- package/dist/core/entities/watched-list.test.js +0 -185
- package/dist/core/entities/watched-list.test.js.map +0 -1
- package/dist/core/errors/api-common-error.cjs +0 -38
- package/dist/core/errors/api-common-error.cjs.map +0 -1
- package/dist/core/errors/api-common-error.d.cts +0 -28
- package/dist/core/errors/api-common-error.d.ts +0 -28
- package/dist/core/errors/api-common-error.js +0 -13
- package/dist/core/errors/api-common-error.js.map +0 -1
- package/dist/core/errors/application-error.cjs +0 -54
- package/dist/core/errors/application-error.cjs.map +0 -1
- package/dist/core/errors/application-error.d.cts +0 -8
- package/dist/core/errors/application-error.d.ts +0 -8
- package/dist/core/errors/application-error.js +0 -33
- package/dist/core/errors/application-error.js.map +0 -1
- package/dist/core/errors/conflict-error.cjs +0 -56
- package/dist/core/errors/conflict-error.cjs.map +0 -1
- package/dist/core/errors/conflict-error.d.cts +0 -13
- package/dist/core/errors/conflict-error.d.ts +0 -13
- package/dist/core/errors/conflict-error.js +0 -35
- package/dist/core/errors/conflict-error.js.map +0 -1
- package/dist/core/errors/domain-error.cjs +0 -54
- package/dist/core/errors/domain-error.cjs.map +0 -1
- package/dist/core/errors/domain-error.d.cts +0 -8
- package/dist/core/errors/domain-error.d.ts +0 -8
- package/dist/core/errors/domain-error.js +0 -33
- package/dist/core/errors/domain-error.js.map +0 -1
- package/dist/core/errors/http-client-error.cjs +0 -54
- package/dist/core/errors/http-client-error.cjs.map +0 -1
- package/dist/core/errors/http-client-error.d.cts +0 -8
- package/dist/core/errors/http-client-error.d.ts +0 -8
- package/dist/core/errors/http-client-error.js +0 -33
- package/dist/core/errors/http-client-error.js.map +0 -1
- package/dist/core/errors/infra-error.cjs +0 -54
- package/dist/core/errors/infra-error.cjs.map +0 -1
- package/dist/core/errors/infra-error.d.cts +0 -8
- package/dist/core/errors/infra-error.d.ts +0 -8
- package/dist/core/errors/infra-error.js +0 -33
- package/dist/core/errors/infra-error.js.map +0 -1
- package/dist/core/errors/validation-error.cjs +0 -55
- package/dist/core/errors/validation-error.cjs.map +0 -1
- package/dist/core/errors/validation-error.d.cts +0 -8
- package/dist/core/errors/validation-error.d.ts +0 -8
- package/dist/core/errors/validation-error.js +0 -34
- package/dist/core/errors/validation-error.js.map +0 -1
- package/dist/core/http/base-controller.cjs +0 -295
- package/dist/core/http/base-controller.cjs.map +0 -1
- package/dist/core/http/base-controller.d.cts +0 -1
- package/dist/core/http/base-controller.d.ts +0 -1
- package/dist/core/http/base-controller.js +0 -270
- package/dist/core/http/base-controller.js.map +0 -1
- package/dist/core/http/dto-response.cjs +0 -19
- package/dist/core/http/dto-response.cjs.map +0 -1
- package/dist/core/http/dto-response.d.cts +0 -10
- package/dist/core/http/dto-response.d.ts +0 -10
- package/dist/core/http/dto-response.js +0 -1
- package/dist/core/http/dto-response.js.map +0 -1
- package/dist/core/http/error-notifier.cjs +0 -19
- package/dist/core/http/error-notifier.cjs.map +0 -1
- package/dist/core/http/error-notifier.d.cts +0 -1
- package/dist/core/http/error-notifier.d.ts +0 -1
- package/dist/core/http/error-notifier.js +0 -1
- package/dist/core/http/error-notifier.js.map +0 -1
- package/dist/core/http/get-take-and-skip.cjs +0 -40
- package/dist/core/http/get-take-and-skip.cjs.map +0 -1
- package/dist/core/http/get-take-and-skip.d.cts +0 -6
- package/dist/core/http/get-take-and-skip.d.ts +0 -6
- package/dist/core/http/get-take-and-skip.js +0 -17
- package/dist/core/http/get-take-and-skip.js.map +0 -1
- package/dist/core/http/health-connections.cjs +0 -42
- package/dist/core/http/health-connections.cjs.map +0 -1
- package/dist/core/http/health-connections.d.cts +0 -16
- package/dist/core/http/health-connections.d.ts +0 -16
- package/dist/core/http/health-connections.js +0 -23
- package/dist/core/http/health-connections.js.map +0 -1
- package/dist/core/http/http.cjs +0 -19
- package/dist/core/http/http.cjs.map +0 -1
- package/dist/core/http/http.d.cts +0 -10
- package/dist/core/http/http.d.ts +0 -10
- package/dist/core/http/http.js +0 -1
- package/dist/core/http/http.js.map +0 -1
- package/dist/core/http/pagination.cjs +0 -19
- package/dist/core/http/pagination.cjs.map +0 -1
- package/dist/core/http/pagination.d.cts +0 -9
- package/dist/core/http/pagination.d.ts +0 -9
- package/dist/core/http/pagination.js +0 -1
- package/dist/core/http/pagination.js.map +0 -1
- package/dist/core/http/validator.cjs +0 -19
- package/dist/core/http/validator.cjs.map +0 -1
- package/dist/core/http/validator.d.cts +0 -11
- package/dist/core/http/validator.d.ts +0 -11
- package/dist/core/http/validator.js +0 -1
- package/dist/core/http/validator.js.map +0 -1
- package/dist/infra/adapters/http/express-adapter.cjs +0 -139
- package/dist/infra/adapters/http/express-adapter.cjs.map +0 -1
- package/dist/infra/adapters/http/express-adapter.d.cts +0 -15
- package/dist/infra/adapters/http/express-adapter.d.ts +0 -15
- package/dist/infra/adapters/http/express-adapter.js +0 -106
- package/dist/infra/adapters/http/express-adapter.js.map +0 -1
- package/dist/infra/adapters/http/fastify-adapter.cjs +0 -124
- package/dist/infra/adapters/http/fastify-adapter.cjs.map +0 -1
- package/dist/infra/adapters/http/fastify-adapter.d.cts +0 -14
- package/dist/infra/adapters/http/fastify-adapter.d.ts +0 -14
- package/dist/infra/adapters/http/fastify-adapter.js +0 -91
- package/dist/infra/adapters/http/fastify-adapter.js.map +0 -1
- package/dist/infra/adapters/http/response-error-code.cjs +0 -35
- package/dist/infra/adapters/http/response-error-code.cjs.map +0 -1
- package/dist/infra/adapters/http/response-error-code.d.cts +0 -6
- package/dist/infra/adapters/http/response-error-code.d.ts +0 -6
- package/dist/infra/adapters/http/response-error-code.js +0 -10
- package/dist/infra/adapters/http/response-error-code.js.map +0 -1
- package/dist/infra/adapters/http/validate-controller-metadata.cjs +0 -42
- package/dist/infra/adapters/http/validate-controller-metadata.cjs.map +0 -1
- package/dist/infra/adapters/http/validate-controller-metadata.d.cts +0 -11
- package/dist/infra/adapters/http/validate-controller-metadata.d.ts +0 -11
- package/dist/infra/adapters/http/validate-controller-metadata.js +0 -19
- package/dist/infra/adapters/http/validate-controller-metadata.js.map +0 -1
- package/dist/infra/adapters/notifications/discord.cjs +0 -90
- package/dist/infra/adapters/notifications/discord.cjs.map +0 -1
- package/dist/infra/adapters/notifications/discord.d.cts +0 -14
- package/dist/infra/adapters/notifications/discord.d.ts +0 -14
- package/dist/infra/adapters/notifications/discord.js +0 -65
- package/dist/infra/adapters/notifications/discord.js.map +0 -1
- package/dist/infra/adapters/notifications/in-memory.cjs +0 -44
- package/dist/infra/adapters/notifications/in-memory.cjs.map +0 -1
- package/dist/infra/adapters/notifications/in-memory.d.cts +0 -8
- package/dist/infra/adapters/notifications/in-memory.d.ts +0 -8
- package/dist/infra/adapters/notifications/in-memory.js +0 -21
- package/dist/infra/adapters/notifications/in-memory.js.map +0 -1
- package/dist/infra/adapters/notifications/notification-factory.cjs +0 -219
- package/dist/infra/adapters/notifications/notification-factory.cjs.map +0 -1
- package/dist/infra/adapters/notifications/notification-factory.d.cts +0 -18
- package/dist/infra/adapters/notifications/notification-factory.d.ts +0 -18
- package/dist/infra/adapters/notifications/notification-factory.js +0 -184
- package/dist/infra/adapters/notifications/notification-factory.js.map +0 -1
- package/dist/infra/adapters/notifications/sentry.cjs +0 -129
- package/dist/infra/adapters/notifications/sentry.cjs.map +0 -1
- package/dist/infra/adapters/notifications/sentry.d.cts +0 -13
- package/dist/infra/adapters/notifications/sentry.d.ts +0 -13
- package/dist/infra/adapters/notifications/sentry.js +0 -96
- package/dist/infra/adapters/notifications/sentry.js.map +0 -1
- package/dist/infra/adapters/validators/zod/index.cjs +0 -179
- package/dist/infra/adapters/validators/zod/index.cjs.map +0 -1
- package/dist/infra/adapters/validators/zod/index.d.cts +0 -19
- package/dist/infra/adapters/validators/zod/index.d.ts +0 -19
- package/dist/infra/adapters/validators/zod/index.js +0 -154
- package/dist/infra/adapters/validators/zod/index.js.map +0 -1
- package/dist/infra/adapters/validators/zod/zod-map-error.cjs +0 -79
- package/dist/infra/adapters/validators/zod/zod-map-error.cjs.map +0 -1
- package/dist/infra/adapters/validators/zod/zod-map-error.d.cts +0 -15
- package/dist/infra/adapters/validators/zod/zod-map-error.d.ts +0 -15
- package/dist/infra/adapters/validators/zod/zod-map-error.js +0 -60
- package/dist/infra/adapters/validators/zod/zod-map-error.js.map +0 -1
- package/dist/infra/adapters/validators/zod/zod-validator.cjs +0 -178
- package/dist/infra/adapters/validators/zod/zod-validator.cjs.map +0 -1
- package/dist/infra/adapters/validators/zod/zod-validator.d.cts +0 -13
- package/dist/infra/adapters/validators/zod/zod-validator.d.ts +0 -13
- package/dist/infra/adapters/validators/zod/zod-validator.js +0 -153
- package/dist/infra/adapters/validators/zod/zod-validator.js.map +0 -1
- package/dist/infra/env/index.cjs +0 -467
- package/dist/infra/env/index.cjs.map +0 -1
- package/dist/infra/env/index.d.cts +0 -26
- package/dist/infra/env/index.d.ts +0 -26
- package/dist/infra/env/index.js +0 -452
- package/dist/infra/env/index.js.map +0 -1
- /package/dist/{index.js.map → index.mjs.map} +0 -0
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
|
|
4
|
-
// src/core/entities/value-object.ts
|
|
5
|
-
var ValueObject = class {
|
|
6
|
-
static {
|
|
7
|
-
__name(this, "ValueObject");
|
|
8
|
-
}
|
|
9
|
-
props;
|
|
10
|
-
constructor(props) {
|
|
11
|
-
this.props = props;
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
export {
|
|
15
|
-
ValueObject
|
|
16
|
-
};
|
|
17
|
-
//# sourceMappingURL=value-object.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/core/entities/value-object.ts"],"sourcesContent":["export abstract class ValueObject<Props> {\n protected props: Props\n\n protected constructor(props: Props) {\n this.props = props\n }\n}\n"],"mappings":";;;;AAAO,IAAeA,cAAf,MAAeA;EAAtB,OAAsBA;;;EACVC;EAEV,YAAsBA,OAAc;AAClC,SAAKA,QAAQA;EACf;AACF;","names":["ValueObject","props"]}
|
|
@@ -1,121 +0,0 @@
|
|
|
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 __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
-
|
|
21
|
-
// src/core/entities/watched-list.ts
|
|
22
|
-
var watched_list_exports = {};
|
|
23
|
-
__export(watched_list_exports, {
|
|
24
|
-
WatchedList: () => WatchedList
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(watched_list_exports);
|
|
27
|
-
var WatchedList = class {
|
|
28
|
-
static {
|
|
29
|
-
__name(this, "WatchedList");
|
|
30
|
-
}
|
|
31
|
-
currentItems;
|
|
32
|
-
initial;
|
|
33
|
-
new;
|
|
34
|
-
removed;
|
|
35
|
-
updated;
|
|
36
|
-
constructor(initialItems) {
|
|
37
|
-
this.currentItems = initialItems || [];
|
|
38
|
-
this.initial = initialItems || [];
|
|
39
|
-
this.new = [];
|
|
40
|
-
this.removed = [];
|
|
41
|
-
this.updated = [];
|
|
42
|
-
}
|
|
43
|
-
getItems() {
|
|
44
|
-
return this.currentItems;
|
|
45
|
-
}
|
|
46
|
-
getNewItems() {
|
|
47
|
-
return this.new;
|
|
48
|
-
}
|
|
49
|
-
getRemovedItems() {
|
|
50
|
-
return this.removed;
|
|
51
|
-
}
|
|
52
|
-
getUpdatedItems() {
|
|
53
|
-
return this.updated;
|
|
54
|
-
}
|
|
55
|
-
addUpdatedItem(item) {
|
|
56
|
-
return this.updated.push(item);
|
|
57
|
-
}
|
|
58
|
-
isCurrentItem(item) {
|
|
59
|
-
return this.currentItems.filter((v) => this.compareItems(item, v)).length !== 0;
|
|
60
|
-
}
|
|
61
|
-
isNewItem(item) {
|
|
62
|
-
return this.new.filter((v) => this.compareItems(item, v)).length !== 0;
|
|
63
|
-
}
|
|
64
|
-
isRemovedItem(item) {
|
|
65
|
-
return this.removed.filter((v) => this.compareItems(item, v)).length !== 0;
|
|
66
|
-
}
|
|
67
|
-
removeFromNew(item) {
|
|
68
|
-
this.new = this.new.filter((v) => !this.compareItems(v, item));
|
|
69
|
-
}
|
|
70
|
-
removeFromCurrent(item) {
|
|
71
|
-
this.currentItems = this.currentItems.filter((v) => !this.compareItems(item, v));
|
|
72
|
-
}
|
|
73
|
-
removeFromRemoved(item) {
|
|
74
|
-
this.removed = this.removed.filter((v) => !this.compareItems(item, v));
|
|
75
|
-
}
|
|
76
|
-
wasAddedInitially(item) {
|
|
77
|
-
return this.initial.filter((v) => this.compareItems(item, v)).length !== 0;
|
|
78
|
-
}
|
|
79
|
-
exists(item) {
|
|
80
|
-
return this.isCurrentItem(item);
|
|
81
|
-
}
|
|
82
|
-
add(item) {
|
|
83
|
-
if (this.isRemovedItem(item)) {
|
|
84
|
-
this.removeFromRemoved(item);
|
|
85
|
-
}
|
|
86
|
-
if (!this.isNewItem(item) && !this.wasAddedInitially(item)) {
|
|
87
|
-
this.new.push(item);
|
|
88
|
-
}
|
|
89
|
-
if (!this.isCurrentItem(item)) {
|
|
90
|
-
this.currentItems.push(item);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
remove(item) {
|
|
94
|
-
this.removeFromCurrent(item);
|
|
95
|
-
if (this.isNewItem(item)) {
|
|
96
|
-
this.removeFromNew(item);
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
if (!this.isRemovedItem(item)) {
|
|
100
|
-
this.removed.push(item);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
update(items) {
|
|
104
|
-
const newItems = items.filter((a) => {
|
|
105
|
-
return !this.getItems().some((b) => this.compareItems(a, b));
|
|
106
|
-
});
|
|
107
|
-
const removedItems = this.getItems().filter((a) => {
|
|
108
|
-
return !items.some((b) => this.compareItems(a, b));
|
|
109
|
-
});
|
|
110
|
-
const updatedItems = items.filter((item) => !newItems.some((a) => this.compareItems(item, a) && !removedItems.some((b) => this.compareItems(item, b))));
|
|
111
|
-
this.currentItems = items;
|
|
112
|
-
this.new = newItems;
|
|
113
|
-
this.removed = removedItems;
|
|
114
|
-
this.updated = updatedItems;
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
118
|
-
0 && (module.exports = {
|
|
119
|
-
WatchedList
|
|
120
|
-
});
|
|
121
|
-
//# sourceMappingURL=watched-list.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
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":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;AAAO,IAAeA,cAAf,MAAeA;EAAtB,OAAsBA;;;EACbC;EACCC;EACAC;EACAC;EACAC;EAERC,YAAYC,cAAoB;AAC9B,SAAKN,eAAeM,gBAAgB,CAAA;AACpC,SAAKL,U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ated","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"]}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
declare abstract class WatchedList<T> {
|
|
2
|
-
currentItems: T[];
|
|
3
|
-
private initial;
|
|
4
|
-
private new;
|
|
5
|
-
private removed;
|
|
6
|
-
private updated;
|
|
7
|
-
constructor(initialItems?: T[]);
|
|
8
|
-
abstract compareItems(a: T, b: T): boolean;
|
|
9
|
-
getItems(): T[];
|
|
10
|
-
getNewItems(): T[];
|
|
11
|
-
getRemovedItems(): T[];
|
|
12
|
-
getUpdatedItems(): T[];
|
|
13
|
-
addUpdatedItem(item: T): number;
|
|
14
|
-
private isCurrentItem;
|
|
15
|
-
private isNewItem;
|
|
16
|
-
private isRemovedItem;
|
|
17
|
-
private removeFromNew;
|
|
18
|
-
private removeFromCurrent;
|
|
19
|
-
private removeFromRemoved;
|
|
20
|
-
private wasAddedInitially;
|
|
21
|
-
exists(item: T): boolean;
|
|
22
|
-
add(item: T): void;
|
|
23
|
-
remove(item: T): void;
|
|
24
|
-
update(items: T[]): void;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export { WatchedList };
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
declare abstract class WatchedList<T> {
|
|
2
|
-
currentItems: T[];
|
|
3
|
-
private initial;
|
|
4
|
-
private new;
|
|
5
|
-
private removed;
|
|
6
|
-
private updated;
|
|
7
|
-
constructor(initialItems?: T[]);
|
|
8
|
-
abstract compareItems(a: T, b: T): boolean;
|
|
9
|
-
getItems(): T[];
|
|
10
|
-
getNewItems(): T[];
|
|
11
|
-
getRemovedItems(): T[];
|
|
12
|
-
getUpdatedItems(): T[];
|
|
13
|
-
addUpdatedItem(item: T): number;
|
|
14
|
-
private isCurrentItem;
|
|
15
|
-
private isNewItem;
|
|
16
|
-
private isRemovedItem;
|
|
17
|
-
private removeFromNew;
|
|
18
|
-
private removeFromCurrent;
|
|
19
|
-
private removeFromRemoved;
|
|
20
|
-
private wasAddedInitially;
|
|
21
|
-
exists(item: T): boolean;
|
|
22
|
-
add(item: T): void;
|
|
23
|
-
remove(item: T): void;
|
|
24
|
-
update(items: T[]): void;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export { WatchedList };
|
|
@@ -1,98 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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;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T,IAAAA;AAEnB;IACF;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"]}
|
|
@@ -1,186 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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;EAC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atedItems","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"]}
|