@webda/core 2.0.0-beta.3 → 2.1.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/lib/application.d.ts +5 -5
- package/lib/application.js +71 -84
- package/lib/application.js.map +1 -1
- package/lib/application.spec.js +121 -140
- package/lib/application.spec.js.map +1 -1
- package/lib/core.d.ts +21 -25
- package/lib/core.js +233 -320
- package/lib/core.js.map +1 -1
- package/lib/core.spec.js +334 -406
- package/lib/core.spec.js.map +1 -1
- package/lib/index.d.ts +49 -48
- package/lib/index.js +53 -70
- package/lib/index.js.map +1 -1
- package/lib/models/aclmodel.d.ts +2 -2
- package/lib/models/aclmodel.js +63 -90
- package/lib/models/aclmodel.js.map +1 -1
- package/lib/models/aclmodel.spec.js +128 -152
- package/lib/models/aclmodel.spec.js.map +1 -1
- package/lib/models/coremodel.d.ts +33 -14
- package/lib/models/coremodel.js +160 -117
- package/lib/models/coremodel.js.map +1 -1
- package/lib/models/coremodel.spec.js +143 -107
- package/lib/models/coremodel.spec.js.map +1 -1
- package/lib/models/deployment.js +1 -2
- package/lib/models/ident.d.ts +3 -3
- package/lib/models/ident.js +4 -9
- package/lib/models/ident.js.map +1 -1
- package/lib/models/ident.spec.js +9 -11
- package/lib/models/ident.spec.js.map +1 -1
- package/lib/models/ownermodel.d.ts +2 -2
- package/lib/models/ownermodel.js +39 -62
- package/lib/models/ownermodel.js.map +1 -1
- package/lib/models/ownermodel.spec.js +126 -168
- package/lib/models/ownermodel.spec.js.map +1 -1
- package/lib/models/rolemodel.d.ts +1 -1
- package/lib/models/rolemodel.js +24 -40
- package/lib/models/rolemodel.js.map +1 -1
- package/lib/models/rolemodel.spec.js +44 -63
- package/lib/models/rolemodel.spec.js.map +1 -1
- package/lib/models/user.d.ts +9 -9
- package/lib/models/user.js +3 -8
- package/lib/models/user.js.map +1 -1
- package/lib/models/user.spec.js +14 -16
- package/lib/models/user.spec.js.map +1 -1
- package/lib/queues/filequeue.d.ts +2 -2
- package/lib/queues/filequeue.js +72 -93
- package/lib/queues/filequeue.js.map +1 -1
- package/lib/queues/filequeue.spec.js +53 -70
- package/lib/queues/filequeue.spec.js.map +1 -1
- package/lib/queues/memoryqueue.d.ts +2 -2
- package/lib/queues/memoryqueue.js +37 -61
- package/lib/queues/memoryqueue.js.map +1 -1
- package/lib/queues/memoryqueue.spec.js +142 -165
- package/lib/queues/memoryqueue.spec.js.map +1 -1
- package/lib/queues/pubsubservice.d.ts +2 -2
- package/lib/queues/pubsubservice.js +3 -7
- package/lib/queues/pubsubservice.js.map +1 -1
- package/lib/queues/queue.spec.d.ts +1 -1
- package/lib/queues/queue.spec.js +42 -56
- package/lib/queues/queue.spec.js.map +1 -1
- package/lib/queues/queueservice.d.ts +3 -3
- package/lib/queues/queueservice.js +51 -67
- package/lib/queues/queueservice.js.map +1 -1
- package/lib/router.d.ts +3 -3
- package/lib/router.js +46 -47
- package/lib/router.js.map +1 -1
- package/lib/router.spec.js +64 -61
- package/lib/router.spec.js.map +1 -1
- package/lib/services/asyncevents.d.ts +2 -2
- package/lib/services/asyncevents.js +44 -64
- package/lib/services/asyncevents.js.map +1 -1
- package/lib/services/asyncevents.spec.js +81 -98
- package/lib/services/asyncevents.spec.js.map +1 -1
- package/lib/services/authentication.d.ts +23 -13
- package/lib/services/authentication.js +540 -566
- package/lib/services/authentication.js.map +1 -1
- package/lib/services/authentication.spec.js +411 -447
- package/lib/services/authentication.spec.js.map +1 -1
- package/lib/services/binary.d.ts +8 -6
- package/lib/services/binary.js +212 -245
- package/lib/services/binary.js.map +1 -1
- package/lib/services/binary.spec.d.ts +3 -3
- package/lib/services/binary.spec.js +390 -443
- package/lib/services/binary.spec.js.map +1 -1
- package/lib/services/cloudbinary.d.ts +3 -3
- package/lib/services/cloudbinary.js +45 -70
- package/lib/services/cloudbinary.js.map +1 -1
- package/lib/services/cloudbinary.spec.d.ts +3 -3
- package/lib/services/cloudbinary.spec.js +133 -162
- package/lib/services/cloudbinary.spec.js.map +1 -1
- package/lib/services/configuration.d.ts +1 -1
- package/lib/services/configuration.js +78 -105
- package/lib/services/configuration.js.map +1 -1
- package/lib/services/configuration.spec.js +63 -83
- package/lib/services/configuration.spec.js.map +1 -1
- package/lib/services/cron.d.ts +3 -2
- package/lib/services/cron.js +9 -13
- package/lib/services/cron.js.map +1 -1
- package/lib/services/cron.spec.js +18 -21
- package/lib/services/cron.spec.js.map +1 -1
- package/lib/services/cryptoservice.d.ts +9 -4
- package/lib/services/cryptoservice.js +187 -221
- package/lib/services/cryptoservice.js.map +1 -1
- package/lib/services/cryptoservice.spec.js +88 -115
- package/lib/services/cryptoservice.spec.js.map +1 -1
- package/lib/services/debugmailer.d.ts +1 -1
- package/lib/services/debugmailer.js +13 -34
- package/lib/services/debugmailer.js.map +1 -1
- package/lib/services/debugmailer.spec.js +16 -29
- package/lib/services/debugmailer.spec.js.map +1 -1
- package/lib/services/echo.d.ts +2 -2
- package/lib/services/echo.js +15 -31
- package/lib/services/echo.js.map +1 -1
- package/lib/services/echo.spec.js +27 -40
- package/lib/services/echo.spec.js.map +1 -1
- package/lib/services/filebinary.d.ts +5 -5
- package/lib/services/filebinary.js +165 -210
- package/lib/services/filebinary.js.map +1 -1
- package/lib/services/filebinary.spec.d.ts +2 -1
- package/lib/services/filebinary.spec.js +106 -116
- package/lib/services/filebinary.spec.js.map +1 -1
- package/lib/services/fileconfiguration.d.ts +1 -1
- package/lib/services/fileconfiguration.js +25 -44
- package/lib/services/fileconfiguration.js.map +1 -1
- package/lib/services/fileconfiguration.spec.js +79 -109
- package/lib/services/fileconfiguration.spec.js.map +1 -1
- package/lib/services/invitationservice.d.ts +8 -8
- package/lib/services/invitationservice.js +274 -314
- package/lib/services/invitationservice.js.map +1 -1
- package/lib/services/invitationservice.spec.js +443 -449
- package/lib/services/invitationservice.spec.js.map +1 -1
- package/lib/services/kubernetesconfiguration.d.ts +1 -1
- package/lib/services/kubernetesconfiguration.js +41 -60
- package/lib/services/kubernetesconfiguration.js.map +1 -1
- package/lib/services/kubernetesconfiguration.spec.js +80 -98
- package/lib/services/kubernetesconfiguration.spec.js.map +1 -1
- package/lib/services/mailer.d.ts +4 -4
- package/lib/services/mailer.js +62 -86
- package/lib/services/mailer.js.map +1 -1
- package/lib/services/mailer.spec.js +86 -127
- package/lib/services/mailer.spec.js.map +1 -1
- package/lib/services/notificationservice.d.ts +3 -3
- package/lib/services/notificationservice.js +21 -42
- package/lib/services/notificationservice.js.map +1 -1
- package/lib/services/notificationservice.spec.js +47 -73
- package/lib/services/notificationservice.spec.js.map +1 -1
- package/lib/services/oauth.d.ts +4 -4
- package/lib/services/oauth.js +68 -83
- package/lib/services/oauth.js.map +1 -1
- package/lib/services/oauth.spec.js +130 -156
- package/lib/services/oauth.spec.js.map +1 -1
- package/lib/services/proxy.d.ts +2 -6
- package/lib/services/proxy.js +45 -58
- package/lib/services/proxy.js.map +1 -1
- package/lib/services/proxy.spec.js +34 -53
- package/lib/services/proxy.spec.js.map +1 -1
- package/lib/services/resource.d.ts +2 -2
- package/lib/services/resource.js +12 -18
- package/lib/services/resource.js.map +1 -1
- package/lib/services/resource.spec.js +67 -99
- package/lib/services/resource.spec.js.map +1 -1
- package/lib/services/service.d.ts +26 -3
- package/lib/services/service.js +68 -40
- package/lib/services/service.js.map +1 -1
- package/lib/services/service.spec.js +62 -67
- package/lib/services/service.spec.js.map +1 -1
- package/lib/services/version.d.ts +1 -1
- package/lib/services/version.js +3 -8
- package/lib/services/version.js.map +1 -1
- package/lib/services/version.spec.js +11 -24
- package/lib/services/version.spec.js.map +1 -1
- package/lib/stores/aggregator.d.ts +2 -2
- package/lib/stores/aggregator.js +37 -58
- package/lib/stores/aggregator.js.map +1 -1
- package/lib/stores/file.d.ts +3 -3
- package/lib/stores/file.js +93 -131
- package/lib/stores/file.js.map +1 -1
- package/lib/stores/file.spec.d.ts +2 -2
- package/lib/stores/file.spec.js +262 -289
- package/lib/stores/file.spec.js.map +1 -1
- package/lib/stores/mapper.d.ts +3 -3
- package/lib/stores/mapper.js +110 -137
- package/lib/stores/mapper.js.map +1 -1
- package/lib/stores/mapper.spec.js +133 -150
- package/lib/stores/mapper.spec.js.map +1 -1
- package/lib/stores/memory.d.ts +3 -3
- package/lib/stores/memory.js +98 -144
- package/lib/stores/memory.js.map +1 -1
- package/lib/stores/memory.spec.d.ts +2 -2
- package/lib/stores/memory.spec.js +124 -145
- package/lib/stores/memory.spec.js.map +1 -1
- package/lib/stores/store.d.ts +27 -17
- package/lib/stores/store.js +833 -849
- package/lib/stores/store.js.map +1 -1
- package/lib/stores/store.spec.d.ts +5 -4
- package/lib/stores/store.spec.js +625 -669
- package/lib/stores/store.spec.js.map +1 -1
- package/lib/stores/webdaql/WebdaQLLexer.d.ts +4 -4
- package/lib/stores/webdaql/WebdaQLLexer.js +9 -13
- package/lib/stores/webdaql/WebdaQLLexer.js.map +1 -1
- package/lib/stores/webdaql/WebdaQLParserLexer.d.ts +4 -4
- package/lib/stores/webdaql/WebdaQLParserLexer.js +9 -13
- package/lib/stores/webdaql/WebdaQLParserLexer.js.map +1 -1
- package/lib/stores/webdaql/WebdaQLParserListener.d.ts +2 -2
- package/lib/stores/webdaql/WebdaQLParserListener.js +1 -2
- package/lib/stores/webdaql/WebdaQLParserListener.js.map +1 -1
- package/lib/stores/webdaql/WebdaQLParserParser.d.ts +10 -10
- package/lib/stores/webdaql/WebdaQLParserParser.js +62 -91
- package/lib/stores/webdaql/WebdaQLParserParser.js.map +1 -1
- package/lib/stores/webdaql/WebdaQLParserVisitor.d.ts +2 -2
- package/lib/stores/webdaql/WebdaQLParserVisitor.js +1 -2
- package/lib/stores/webdaql/WebdaQLParserVisitor.js.map +1 -1
- package/lib/stores/webdaql/query.d.ts +4 -5
- package/lib/stores/webdaql/query.js +16 -19
- package/lib/stores/webdaql/query.js.map +1 -1
- package/lib/stores/webdaql/query.spec.js +30 -32
- package/lib/stores/webdaql/query.spec.js.map +1 -1
- package/lib/test.d.ts +3 -3
- package/lib/test.js +73 -100
- package/lib/test.js.map +1 -1
- package/lib/unpackedapplication.d.ts +1 -1
- package/lib/unpackedapplication.js +49 -39
- package/lib/unpackedapplication.js.map +1 -1
- package/lib/utils/abstractdeployer.js +1 -5
- package/lib/utils/abstractdeployer.js.map +1 -1
- package/lib/utils/abstractdeployer.spec.js +6 -8
- package/lib/utils/abstractdeployer.spec.js.map +1 -1
- package/lib/utils/context.d.ts +7 -5
- package/lib/utils/context.js +95 -103
- package/lib/utils/context.js.map +1 -1
- package/lib/utils/context.spec.js +139 -163
- package/lib/utils/context.spec.js.map +1 -1
- package/lib/utils/cookie.d.ts +3 -3
- package/lib/utils/cookie.js +42 -61
- package/lib/utils/cookie.js.map +1 -1
- package/lib/utils/cookie.spec.js +42 -64
- package/lib/utils/cookie.spec.js.map +1 -1
- package/lib/utils/esm.d.ts +4 -0
- package/lib/utils/esm.js +10 -0
- package/lib/utils/esm.js.map +1 -0
- package/lib/utils/httpcontext.d.ts +3 -0
- package/lib/utils/httpcontext.js +48 -65
- package/lib/utils/httpcontext.js.map +1 -1
- package/lib/utils/httpcontext.spec.js +37 -56
- package/lib/utils/httpcontext.spec.js.map +1 -1
- package/lib/utils/logger.d.ts +2 -2
- package/lib/utils/logger.js +15 -28
- package/lib/utils/logger.js.map +1 -1
- package/lib/utils/logger.spec.js +9 -11
- package/lib/utils/logger.spec.js.map +1 -1
- package/lib/utils/serializers.js +17 -20
- package/lib/utils/serializers.js.map +1 -1
- package/lib/utils/serializers.spec.js +43 -44
- package/lib/utils/serializers.spec.js.map +1 -1
- package/lib/utils/session.d.ts +6 -6
- package/lib/utils/session.js +37 -59
- package/lib/utils/session.js.map +1 -1
- package/lib/utils/session.spec.js +38 -51
- package/lib/utils/session.spec.js.map +1 -1
- package/lib/utils/waiter.d.ts +1 -1
- package/lib/utils/waiter.js +32 -52
- package/lib/utils/waiter.js.map +1 -1
- package/lib/utils/waiter.spec.js +75 -92
- package/lib/utils/waiter.spec.js.map +1 -1
- package/package.json +18 -13
- package/test/config-invitation.json +1 -3
- package/test/config.json +1 -2
- package/test/config.old.json +1 -2
- package/test/moddas/annotatedservice.js +5 -5
- package/test/moddas/debugmailer.js +2 -3
- package/test/moddas/fakeservice.js +2 -3
- package/test/moddas/voidstore.js +6 -4
- package/test/models/ident.js +2 -6
- package/test/models/task.js +3 -7
- package/test/package.json +2 -1
- package/webda.module.json +895 -190
package/lib/stores/memory.js
CHANGED
|
@@ -1,29 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.Plop = exports.MemoryStore = void 0;
|
|
13
|
-
const crypto = require("crypto");
|
|
14
|
-
const fs_1 = require("fs");
|
|
15
|
-
const store_1 = require("./store");
|
|
1
|
+
import * as crypto from "crypto";
|
|
2
|
+
import { existsSync, readFileSync, writeFileSync } from "fs";
|
|
3
|
+
import { Store, StoreNotFoundError, StoreParameters, UpdateConditionFailError } from "./store.js";
|
|
16
4
|
/**
|
|
17
5
|
* Memory store
|
|
18
6
|
*/
|
|
19
|
-
class MemoryStoreParameters extends
|
|
7
|
+
class MemoryStoreParameters extends StoreParameters {
|
|
20
8
|
constructor(params, service) {
|
|
21
9
|
var _a, _b;
|
|
22
|
-
var _c, _d;
|
|
23
10
|
super(params, service);
|
|
24
11
|
if (this.persistence) {
|
|
25
|
-
(_a =
|
|
26
|
-
(_b =
|
|
12
|
+
(_a = this.persistence).delay ?? (_a.delay = 1000);
|
|
13
|
+
(_b = this.persistence).cipher ?? (_b.cipher = "aes-256-ctr");
|
|
27
14
|
}
|
|
28
15
|
}
|
|
29
16
|
}
|
|
@@ -33,7 +20,7 @@ class MemoryStoreParameters extends store_1.StoreParameters {
|
|
|
33
20
|
* @category CoreServices
|
|
34
21
|
* @WebdaModda
|
|
35
22
|
*/
|
|
36
|
-
class MemoryStore extends
|
|
23
|
+
class MemoryStore extends Store {
|
|
37
24
|
constructor() {
|
|
38
25
|
super(...arguments);
|
|
39
26
|
/**
|
|
@@ -47,7 +34,7 @@ class MemoryStore extends store_1.Store {
|
|
|
47
34
|
* Called every this.parameters.persistence.delay ms
|
|
48
35
|
*/
|
|
49
36
|
persist() {
|
|
50
|
-
|
|
37
|
+
writeFileSync(this.parameters.persistence.path, this.encrypt());
|
|
51
38
|
this.persistenceTimeout = null;
|
|
52
39
|
}
|
|
53
40
|
/**
|
|
@@ -87,113 +74,93 @@ class MemoryStore extends store_1.Store {
|
|
|
87
74
|
/**
|
|
88
75
|
* @override
|
|
89
76
|
*/
|
|
90
|
-
init() {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
if (this.parameters.persistence.
|
|
97
|
-
this.
|
|
98
|
-
}
|
|
99
|
-
try {
|
|
100
|
-
if ((0, fs_1.existsSync)(this.parameters.persistence.path)) {
|
|
101
|
-
this.storage = JSON.parse(this.decrypt((0, fs_1.readFileSync)(this.parameters.persistence.path).toString()));
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
catch (err) {
|
|
105
|
-
this.log("INFO", "Cannot loaded persisted memory data", err);
|
|
106
|
-
this.storage = {};
|
|
77
|
+
async init() {
|
|
78
|
+
if (this.parameters.persistence) {
|
|
79
|
+
if (this.parameters.persistence.key) {
|
|
80
|
+
this.key = crypto.createHash("sha256").update(this.parameters.persistence.key).digest();
|
|
81
|
+
}
|
|
82
|
+
try {
|
|
83
|
+
if (existsSync(this.parameters.persistence.path)) {
|
|
84
|
+
this.storage = JSON.parse(this.decrypt(readFileSync(this.parameters.persistence.path).toString()));
|
|
107
85
|
}
|
|
108
|
-
this.storage = new Proxy(this.storage, {
|
|
109
|
-
set: (target, p, value) => {
|
|
110
|
-
var _a;
|
|
111
|
-
target[p] = value;
|
|
112
|
-
(_a = this.persistenceTimeout) !== null && _a !== void 0 ? _a : (this.persistenceTimeout = setTimeout(() => this.persist(), this.parameters.persistence.delay));
|
|
113
|
-
return true;
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
86
|
}
|
|
117
|
-
|
|
118
|
-
|
|
87
|
+
catch (err) {
|
|
88
|
+
this.log("INFO", "Cannot loaded persisted memory data", err);
|
|
89
|
+
this.storage = {};
|
|
90
|
+
}
|
|
91
|
+
this.storage = new Proxy(this.storage, {
|
|
92
|
+
set: (target, p, value) => {
|
|
93
|
+
target[p] = value;
|
|
94
|
+
this.persistenceTimeout ?? (this.persistenceTimeout = setTimeout(() => this.persist(), this.parameters.persistence.delay));
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
return super.init();
|
|
119
100
|
}
|
|
120
101
|
/**
|
|
121
102
|
* @override
|
|
122
103
|
*/
|
|
123
|
-
exists(uid) {
|
|
124
|
-
return
|
|
125
|
-
return this.storage[uid] !== undefined;
|
|
126
|
-
});
|
|
104
|
+
async exists(uid) {
|
|
105
|
+
return this.storage[uid] !== undefined;
|
|
127
106
|
}
|
|
128
107
|
/**
|
|
129
108
|
* @override
|
|
130
109
|
*/
|
|
131
|
-
find(query) {
|
|
132
|
-
return
|
|
133
|
-
return this.simulateFind(query, Object.keys(this.storage));
|
|
134
|
-
});
|
|
110
|
+
async find(query) {
|
|
111
|
+
return this.simulateFind(query, Object.keys(this.storage));
|
|
135
112
|
}
|
|
136
113
|
/**
|
|
137
114
|
* @override
|
|
138
115
|
*/
|
|
139
|
-
_save(object) {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
return this._getSync(uid);
|
|
144
|
-
});
|
|
116
|
+
async _save(object) {
|
|
117
|
+
let uid = object[this._uuidField];
|
|
118
|
+
this.storage[uid] = object.toStoredJSON(true);
|
|
119
|
+
return this._getSync(uid);
|
|
145
120
|
}
|
|
146
121
|
/**
|
|
147
122
|
* @override
|
|
148
123
|
*/
|
|
149
|
-
_delete(uid) {
|
|
150
|
-
|
|
151
|
-
delete this.storage[uid];
|
|
152
|
-
});
|
|
124
|
+
async _delete(uid) {
|
|
125
|
+
delete this.storage[uid];
|
|
153
126
|
}
|
|
154
127
|
/**
|
|
155
128
|
* @override
|
|
156
129
|
*/
|
|
157
|
-
_patch(object, uuid, writeCondition, writeConditionField) {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
return this._getSync(uuid);
|
|
166
|
-
});
|
|
130
|
+
async _patch(object, uuid, writeCondition, writeConditionField) {
|
|
131
|
+
let obj = await this._get(uuid, true);
|
|
132
|
+
this.checkUpdateCondition(obj, writeConditionField, writeCondition);
|
|
133
|
+
for (let prop in object) {
|
|
134
|
+
obj[prop] = object[prop];
|
|
135
|
+
}
|
|
136
|
+
this.storage[uuid] = obj.toStoredJSON(true);
|
|
137
|
+
return this._getSync(uuid);
|
|
167
138
|
}
|
|
168
139
|
/**
|
|
169
140
|
* @override
|
|
170
141
|
*/
|
|
171
|
-
_update(object, uid, writeCondition, writeConditionField) {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
return this._getSync(uid);
|
|
177
|
-
});
|
|
142
|
+
async _update(object, uid, writeCondition, writeConditionField) {
|
|
143
|
+
let obj = await this._get(uid, true);
|
|
144
|
+
this.checkUpdateCondition(obj, writeConditionField, writeCondition);
|
|
145
|
+
await this._save(object);
|
|
146
|
+
return this._getSync(uid);
|
|
178
147
|
}
|
|
179
148
|
/**
|
|
180
149
|
* @override
|
|
181
150
|
*/
|
|
182
|
-
getAll(uids) {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
return
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
result.push(this._getSync(uids[i]));
|
|
193
|
-
}
|
|
151
|
+
async getAll(uids) {
|
|
152
|
+
if (!uids) {
|
|
153
|
+
return Object.keys(this.storage).map(key => {
|
|
154
|
+
return this._getSync(key);
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
let result = [];
|
|
158
|
+
for (let i in uids) {
|
|
159
|
+
if (this.storage[uids[i]]) {
|
|
160
|
+
result.push(this._getSync(uids[i]));
|
|
194
161
|
}
|
|
195
|
-
|
|
196
|
-
|
|
162
|
+
}
|
|
163
|
+
return result;
|
|
197
164
|
}
|
|
198
165
|
/**
|
|
199
166
|
* Retrieve the object as model
|
|
@@ -206,80 +173,67 @@ class MemoryStore extends store_1.Store {
|
|
|
206
173
|
return this.initModel(JSON.parse(this.storage[uid]));
|
|
207
174
|
}
|
|
208
175
|
else if (raiseIfNotFound) {
|
|
209
|
-
throw new
|
|
176
|
+
throw new StoreNotFoundError(uid, this.getName());
|
|
210
177
|
}
|
|
211
178
|
return null;
|
|
212
179
|
}
|
|
213
180
|
/**
|
|
214
181
|
* @override
|
|
215
182
|
*/
|
|
216
|
-
_removeAttribute(uuid, attribute, writeCondition, writeConditionField) {
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
this._save(res);
|
|
222
|
-
});
|
|
183
|
+
async _removeAttribute(uuid, attribute, writeCondition, writeConditionField) {
|
|
184
|
+
let res = await this._get(uuid, true);
|
|
185
|
+
this.checkUpdateCondition(res, writeConditionField, writeCondition);
|
|
186
|
+
delete res[attribute];
|
|
187
|
+
this._save(res);
|
|
223
188
|
}
|
|
224
189
|
/**
|
|
225
190
|
* @override
|
|
226
191
|
*/
|
|
227
|
-
_get(uid, raiseIfNotFound = false) {
|
|
228
|
-
|
|
229
|
-
if (
|
|
230
|
-
|
|
231
|
-
throw new store_1.StoreNotFoundError(uid, this.getName());
|
|
232
|
-
}
|
|
233
|
-
return;
|
|
192
|
+
async _get(uid, raiseIfNotFound = false) {
|
|
193
|
+
if (!this.storage[uid]) {
|
|
194
|
+
if (raiseIfNotFound) {
|
|
195
|
+
throw new StoreNotFoundError(uid, this.getName());
|
|
234
196
|
}
|
|
235
|
-
return
|
|
236
|
-
}
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
return this._getSync(uid);
|
|
237
200
|
}
|
|
238
201
|
/**
|
|
239
202
|
* @override
|
|
240
203
|
*/
|
|
241
|
-
__clean() {
|
|
242
|
-
|
|
243
|
-
this.storage = {};
|
|
244
|
-
});
|
|
204
|
+
async __clean() {
|
|
205
|
+
this.storage = {};
|
|
245
206
|
}
|
|
246
207
|
/**
|
|
247
208
|
* @override
|
|
248
209
|
*/
|
|
249
|
-
_incrementAttribute(uid, prop, value, updateDate) {
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
return this._save(res);
|
|
258
|
-
});
|
|
210
|
+
async _incrementAttribute(uid, prop, value, updateDate) {
|
|
211
|
+
const res = await this._get(uid, true);
|
|
212
|
+
if (!res[prop]) {
|
|
213
|
+
res[prop] = 0;
|
|
214
|
+
}
|
|
215
|
+
res[this._lastUpdateField] = updateDate;
|
|
216
|
+
res[prop] += value;
|
|
217
|
+
return this._save(res);
|
|
259
218
|
}
|
|
260
219
|
/**
|
|
261
220
|
* @inheritdoc
|
|
262
221
|
*/
|
|
263
|
-
_upsertItemToCollection(uid, prop, item, index, itemWriteCondition, itemWriteConditionField, updateDate) {
|
|
264
|
-
return
|
|
265
|
-
return this.simulateUpsertItemToCollection(this._getSync(uid, true), prop, item, updateDate, index, itemWriteCondition, itemWriteConditionField);
|
|
266
|
-
});
|
|
222
|
+
async _upsertItemToCollection(uid, prop, item, index, itemWriteCondition, itemWriteConditionField, updateDate) {
|
|
223
|
+
return this.simulateUpsertItemToCollection(this._getSync(uid, true), prop, item, updateDate, index, itemWriteCondition, itemWriteConditionField);
|
|
267
224
|
}
|
|
268
225
|
/**
|
|
269
226
|
* @override
|
|
270
227
|
*/
|
|
271
|
-
_deleteItemFromCollection(uid, prop, index, itemWriteCondition, itemWriteConditionField, updateDate) {
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
return this._save(res);
|
|
280
|
-
});
|
|
228
|
+
async _deleteItemFromCollection(uid, prop, index, itemWriteCondition, itemWriteConditionField, updateDate) {
|
|
229
|
+
let res = await this._get(uid, true);
|
|
230
|
+
if (itemWriteCondition && res[prop][index][itemWriteConditionField] != itemWriteCondition) {
|
|
231
|
+
throw new UpdateConditionFailError(uid, itemWriteConditionField, itemWriteCondition);
|
|
232
|
+
}
|
|
233
|
+
res[prop].splice(index, 1);
|
|
234
|
+
res[this._lastUpdateField] = updateDate;
|
|
235
|
+
return this._save(res);
|
|
281
236
|
}
|
|
282
237
|
}
|
|
283
|
-
|
|
284
|
-
exports.Plop = MemoryStore;
|
|
238
|
+
export { MemoryStore, MemoryStore as Plop };
|
|
285
239
|
//# sourceMappingURL=memory.js.map
|
package/lib/stores/memory.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory.js","sourceRoot":"","sources":["../../src/stores/memory.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"memory.js","sourceRoot":"","sources":["../../src/stores/memory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AAE7D,OAAO,EAAE,KAAK,EAAmB,kBAAkB,EAAE,eAAe,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAOhH;;GAEG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kBAAkB,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,uBAAuB,CAAC,IAAI,kBAAkB,EAAE;YACzF,MAAM,IAAI,wBAAwB,CAAC,GAAG,EAAE,uBAAuB,EAAE,kBAAkB,CAAC,CAAC;SACtF;QACD,GAAG,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QAC3B,GAAG,CAAC,IAAI,CAAC,gBAAgB,CAAC,GAAG,UAAU,CAAC;QACxC,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACzB,CAAC;CACF;AAED,OAAO,EAAE,WAAW,EAAc,WAAW,IAAI,IAAI,EAAE,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CoreModel, Store } from "../index";
|
|
2
|
-
import { StoreTest } from "./store.spec";
|
|
1
|
+
import { CoreModel, Store } from "../index.js";
|
|
2
|
+
import { StoreTest } from "./store.spec.js";
|
|
3
3
|
declare class MemoryStoreTest extends StoreTest {
|
|
4
4
|
getIdentStore(): Store<any>;
|
|
5
5
|
getUserStore(): Store<any>;
|