@appweaver/core 1.1.5 → 1.1.6
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/memory/in-memory.js
CHANGED
|
@@ -53,7 +53,11 @@ class InMemory extends common_1.Memory {
|
|
|
53
53
|
// is below the configured value
|
|
54
54
|
if (this._maxSizeBytes) {
|
|
55
55
|
while (this._approximatedSize > this._maxSizeBytes) {
|
|
56
|
-
|
|
56
|
+
const oldestKey = this._storage.keys().next().value;
|
|
57
|
+
if (oldestKey === undefined) {
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
await this.removeValue(oldestKey);
|
|
57
61
|
}
|
|
58
62
|
}
|
|
59
63
|
return true;
|
|
@@ -62,12 +66,12 @@ class InMemory extends common_1.Memory {
|
|
|
62
66
|
return this._storage.has(key);
|
|
63
67
|
}
|
|
64
68
|
async removeValue(key) {
|
|
65
|
-
const
|
|
66
|
-
if (!
|
|
69
|
+
const entry = this._storage.get(key);
|
|
70
|
+
if (!entry) {
|
|
67
71
|
return false;
|
|
68
72
|
}
|
|
69
73
|
const deleted = this._storage.delete(key);
|
|
70
|
-
this._approximatedSize -= Buffer.byteLength(
|
|
74
|
+
this._approximatedSize -= Buffer.byteLength(entry.value, 'utf8');
|
|
71
75
|
if (this._approximatedSize < 0) {
|
|
72
76
|
this._approximatedSize = 0;
|
|
73
77
|
}
|
|
@@ -146,14 +150,14 @@ class InMemory extends common_1.Memory {
|
|
|
146
150
|
async cleanupExpired() {
|
|
147
151
|
const now = Date.now();
|
|
148
152
|
// Clean up expired storage entries
|
|
149
|
-
for (const key
|
|
153
|
+
for (const key of Array.from(this._storage.keys())) {
|
|
150
154
|
const entry = this._storage.get(key);
|
|
151
155
|
if (entry && entry.expiresAt && entry.expiresAt < now) {
|
|
152
156
|
await this.removeValue(key);
|
|
153
157
|
}
|
|
154
158
|
}
|
|
155
159
|
// Clean up expired locks
|
|
156
|
-
for (const key
|
|
160
|
+
for (const key of Array.from(this._locks.keys())) {
|
|
157
161
|
const lock = this._locks.get(key);
|
|
158
162
|
if (lock && lock.expiresAt < now) {
|
|
159
163
|
this._locks.delete(key);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appweaver/core",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.6",
|
|
4
4
|
"description": "Appweaver - the backend framework for AI-first development (@core)",
|
|
5
5
|
"author": "Luka Matosevic",
|
|
6
6
|
"license": "MIT",
|
|
@@ -38,9 +38,9 @@
|
|
|
38
38
|
"@fastify/oauth2": "8.2.0",
|
|
39
39
|
"@fastify/rate-limit": "11.0.0",
|
|
40
40
|
"@fastify/request-context": "7.0.0",
|
|
41
|
-
"@fastify/static": "
|
|
41
|
+
"@fastify/static": "10.1.2",
|
|
42
42
|
"@fastify/swagger": "9.7.0",
|
|
43
|
-
"@fastify/swagger-ui": "6.
|
|
43
|
+
"@fastify/swagger-ui": "6.1.1",
|
|
44
44
|
"@fastify/type-provider-typebox": "6.1.0",
|
|
45
45
|
"@sinclair/typebox": "0.34.49",
|
|
46
46
|
"bcrypt": "6.0.0",
|
|
@@ -507,8 +507,10 @@ class ResourceService {
|
|
|
507
507
|
relationSchema?.type === 'array' ||
|
|
508
508
|
fileSchema?.type === 'array';
|
|
509
509
|
const isArrayValue = (0, common_1.isArray)(value);
|
|
510
|
-
// Recursively map nested objects and handle arrays of objects
|
|
511
|
-
|
|
510
|
+
// Recursively map nested objects and handle arrays of objects. Arrays of
|
|
511
|
+
// plain values are mapped below as inclusion, range or relation filters.
|
|
512
|
+
if (((0, common_1.isObject)(value) && !isArrayValue) ||
|
|
513
|
+
(isArrayValue && (0, common_1.isObject)(value[0]))) {
|
|
512
514
|
const resourceName = (0, common_1.extractResourceName)(relationSchema ?? fileSchema);
|
|
513
515
|
if (resourceName) {
|
|
514
516
|
queryFilter[key] = isArrayValue
|
|
@@ -685,8 +687,8 @@ class ResourceService {
|
|
|
685
687
|
}
|
|
686
688
|
// Map relation disconnects if unique keys are no longer present or the
|
|
687
689
|
// new value is null. Delete relations if orphanRemoval is set to true.
|
|
688
|
-
//
|
|
689
|
-
//
|
|
690
|
+
// Relations that are not set on the current resource are left untouched,
|
|
691
|
+
// so no relation action is applied for them.
|
|
690
692
|
if (action === 'update') {
|
|
691
693
|
const currentValue = currentData[key];
|
|
692
694
|
const removalMethod = config?.orphanRemoval ? 'delete' : 'disconnect';
|
package/server/create-server.js
CHANGED
|
@@ -88,10 +88,10 @@ function createServer() {
|
|
|
88
88
|
constraints: common_1.config.SERVER_STATIC_ALLOWED_HOST
|
|
89
89
|
? { host: common_1.config.SERVER_STATIC_ALLOWED_HOST }
|
|
90
90
|
: {},
|
|
91
|
-
setHeaders: (
|
|
91
|
+
setHeaders: (reply) => {
|
|
92
92
|
for (const header of common_1.config.SERVER_STATIC_RESPONSE_HEADERS) {
|
|
93
93
|
const [name, ...valueParts] = header.split(':');
|
|
94
|
-
|
|
94
|
+
reply.header(name.trim(), valueParts.join(':').trim());
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
});
|