s3db.js 7.2.0 → 7.3.1
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/PLUGINS.md +200 -10
- package/dist/s3db.cjs.js +149 -1458
- package/dist/s3db.cjs.min.js +1 -1
- package/dist/s3db.d.ts +14 -15
- package/dist/s3db.es.js +150 -1459
- package/dist/s3db.es.min.js +1 -1
- package/dist/s3db.iife.js +149 -1458
- package/dist/s3db.iife.min.js +1 -1
- package/package.json +19 -8
- package/src/behaviors/body-only.js +2 -2
- package/src/behaviors/truncate-data.js +2 -2
- package/src/client.class.js +1 -1
- package/src/database.class.js +1 -1
- package/src/errors.js +1 -1
- package/src/plugins/audit.plugin.js +5 -5
- package/src/plugins/cache/filesystem-cache.class.js +661 -0
- package/src/plugins/cache/index.js +4 -0
- package/src/plugins/cache/partition-aware-filesystem-cache.class.js +480 -0
- package/src/plugins/cache.plugin.js +159 -9
- package/src/plugins/consumers/index.js +3 -3
- package/src/plugins/consumers/sqs-consumer.js +2 -2
- package/src/plugins/fulltext.plugin.js +5 -5
- package/src/plugins/metrics.plugin.js +2 -2
- package/src/plugins/queue-consumer.plugin.js +3 -3
- package/src/plugins/replicator.plugin.js +259 -362
- package/src/plugins/replicators/bigquery-replicator.class.js +102 -68
- package/src/plugins/replicators/postgres-replicator.class.js +19 -109
- package/src/plugins/replicators/s3db-replicator.class.js +56 -68
- package/src/plugins/replicators/sqs-replicator.class.js +34 -121
- package/src/resource.class.js +14 -14
- package/src/s3db.d.ts +14 -15
- package/src/schema.class.js +3 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "s3db.js",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.3.1",
|
|
4
4
|
"description": "Use AWS S3, the world's most reliable document storage, as a database with this ORM.",
|
|
5
5
|
"main": "dist/s3db.cjs.js",
|
|
6
6
|
"module": "dist/s3db.es.js",
|
|
@@ -25,6 +25,10 @@
|
|
|
25
25
|
],
|
|
26
26
|
"type": "module",
|
|
27
27
|
"sideEffects": false,
|
|
28
|
+
"imports": {
|
|
29
|
+
"#src/*": "./src/*",
|
|
30
|
+
"#tests/*": "./tests/*"
|
|
31
|
+
},
|
|
28
32
|
"exports": {
|
|
29
33
|
".": {
|
|
30
34
|
"import": "./dist/s3db.es.js",
|
|
@@ -40,7 +44,7 @@
|
|
|
40
44
|
"UNLICENSE"
|
|
41
45
|
],
|
|
42
46
|
"dependencies": {
|
|
43
|
-
"@aws-sdk/client-s3": "^3.
|
|
47
|
+
"@aws-sdk/client-s3": "^3.848.0",
|
|
44
48
|
"@supercharge/promise-pool": "^3.2.0",
|
|
45
49
|
"fastest-validator": "^1.19.1",
|
|
46
50
|
"flat": "^6.0.1",
|
|
@@ -77,12 +81,12 @@
|
|
|
77
81
|
"@rollup/plugin-commonjs": "^28.0.6",
|
|
78
82
|
"@rollup/plugin-json": "^6.1.0",
|
|
79
83
|
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
80
|
-
"@rollup/plugin-replace": "^6.0.
|
|
84
|
+
"@rollup/plugin-replace": "^6.0.2",
|
|
81
85
|
"@rollup/plugin-terser": "^0.4.4",
|
|
82
|
-
"@types/node": "24.0.
|
|
86
|
+
"@types/node": "24.0.15",
|
|
83
87
|
"dotenv": "^17.2.0",
|
|
84
|
-
"jest": "^
|
|
85
|
-
"rollup": "^4.
|
|
88
|
+
"jest": "^30.0.4",
|
|
89
|
+
"rollup": "^4.45.1",
|
|
86
90
|
"rollup-plugin-copy": "^3.5.0",
|
|
87
91
|
"rollup-plugin-esbuild": "^6.2.1",
|
|
88
92
|
"rollup-plugin-polyfill-node": "^0.13.0",
|
|
@@ -96,10 +100,17 @@
|
|
|
96
100
|
"build": "rollup -c",
|
|
97
101
|
"dev": "rollup -c -w",
|
|
98
102
|
"test": "npm run test:js && npm run test:ts",
|
|
99
|
-
"test:js": "node --no-warnings --experimental-vm-modules node_modules/jest/bin/jest.js",
|
|
103
|
+
"test:js": "node --no-warnings --experimental-vm-modules node_modules/jest/bin/jest.js --runInBand",
|
|
100
104
|
"test:ts": "tsc --noEmit --project tests/typescript/tsconfig.json",
|
|
101
|
-
"test:js-converage": "node --no-warnings --experimental-vm-modules node_modules/jest/bin/jest.js --detectOpenHandles --coverage",
|
|
105
|
+
"test:js-converage": "node --no-warnings --experimental-vm-modules node_modules/jest/bin/jest.js --detectOpenHandles --coverage --runInBand",
|
|
102
106
|
"test:js-ai": "node --no-warnings --experimental-vm-modules node_modules/jest/bin/jest.js --detectOpenHandles --runInBand",
|
|
107
|
+
"test:full": "npm run test:js && npm run test:ts",
|
|
108
|
+
"test:cache": "node --no-warnings --experimental-vm-modules node_modules/jest/bin/jest.js tests/plugins/plugin-cache*.test.js --runInBand",
|
|
109
|
+
"test:quick": "node --no-warnings --experimental-vm-modules node_modules/jest/bin/jest.js --runInBand --testTimeout=10000",
|
|
110
|
+
"test:batch": "./test-batch.sh",
|
|
111
|
+
"test:plugins": "node --no-warnings --experimental-vm-modules node_modules/jest/bin/jest.js tests/plugins/ --runInBand --testTimeout=60000",
|
|
112
|
+
"test:plugins:fast": "node --no-warnings --experimental-vm-modules node_modules/jest/bin/jest.js tests/plugins/ --runInBand --testTimeout=15000 --testPathIgnorePatterns='plugin-audit.test.js|plugin-replicator-s3db.test.js|plugin-fulltext.test.js'",
|
|
113
|
+
"test:slow": "node --no-warnings --experimental-vm-modules node_modules/jest/bin/jest.js tests/plugins/plugin-audit.test.js tests/plugins/plugin-replicator-s3db.test.js tests/plugins/plugin-fulltext.test.js --runInBand --testTimeout=120000",
|
|
103
114
|
"test:types": "tsc --noEmit --project tests/typescript/tsconfig.json",
|
|
104
115
|
"test:types:basic": "tsc --noEmit tests/typescript/basic-usage.test.ts",
|
|
105
116
|
"test:types:direct": "tsc --noEmit tests/typescript/direct-type-test.ts",
|
|
@@ -60,7 +60,7 @@ export async function handleInsert({ resource, data, mappedData }) {
|
|
|
60
60
|
};
|
|
61
61
|
metadataOnly._map = JSON.stringify(resource.schema.map);
|
|
62
62
|
|
|
63
|
-
// Use
|
|
63
|
+
// Use the original object for the body
|
|
64
64
|
const body = JSON.stringify(mappedData);
|
|
65
65
|
|
|
66
66
|
return { mappedData: metadataOnly, body };
|
|
@@ -77,7 +77,7 @@ export async function handleUpdate({ resource, id, data, mappedData }) {
|
|
|
77
77
|
};
|
|
78
78
|
metadataOnly._map = JSON.stringify(resource.schema.map);
|
|
79
79
|
|
|
80
|
-
// Use
|
|
80
|
+
// Use the original object for the body
|
|
81
81
|
const body = JSON.stringify(mappedData);
|
|
82
82
|
|
|
83
83
|
return { mappedData: metadataOnly, body };
|
|
@@ -168,11 +168,11 @@ function truncateValue(value, maxBytes) {
|
|
|
168
168
|
if (typeof value === 'string') {
|
|
169
169
|
return truncateString(value, maxBytes);
|
|
170
170
|
} else if (typeof value === 'object' && value !== null) {
|
|
171
|
-
|
|
171
|
+
// Truncate object as truncated JSON string
|
|
172
172
|
const jsonStr = JSON.stringify(value);
|
|
173
173
|
return truncateString(jsonStr, maxBytes);
|
|
174
174
|
} else {
|
|
175
|
-
//
|
|
175
|
+
// For numbers, booleans, etc., convert to string and truncate
|
|
176
176
|
const stringValue = String(value);
|
|
177
177
|
return truncateString(stringValue, maxBytes);
|
|
178
178
|
}
|
package/src/client.class.js
CHANGED
|
@@ -268,7 +268,7 @@ export class Client extends EventEmitter {
|
|
|
268
268
|
// console.error('[Client][ERROR] DeleteObjectsCommand errors:', response.Errors);
|
|
269
269
|
}
|
|
270
270
|
if (response && response.Deleted && response.Deleted.length !== keys.length) {
|
|
271
|
-
// console.error('[Client][ERROR]
|
|
271
|
+
// console.error('[Client][ERROR] Not all objects were deleted:', response.Deleted, 'expected:', keys);
|
|
272
272
|
}
|
|
273
273
|
return response;
|
|
274
274
|
});
|
package/src/database.class.js
CHANGED
|
@@ -114,7 +114,7 @@ export class Database extends EventEmitter {
|
|
|
114
114
|
this.resources[name] = new Resource({
|
|
115
115
|
name,
|
|
116
116
|
client: this.client,
|
|
117
|
-
database: this, //
|
|
117
|
+
database: this, // ensure reference
|
|
118
118
|
version: currentVersion,
|
|
119
119
|
attributes: versionData.attributes,
|
|
120
120
|
behavior: versionData.behavior || 'user-managed',
|
package/src/errors.js
CHANGED
|
@@ -197,7 +197,7 @@ export const ErrorMap = {
|
|
|
197
197
|
'InvalidResourceItem': InvalidResourceItem,
|
|
198
198
|
};
|
|
199
199
|
|
|
200
|
-
//
|
|
200
|
+
// Utility to map AWS error to custom error
|
|
201
201
|
export function mapAwsError(err, context = {}) {
|
|
202
202
|
const code = err.code || err.Code || err.name;
|
|
203
203
|
const metadata = err.$metadata ? { ...err.$metadata } : undefined;
|
|
@@ -110,7 +110,7 @@ export class AuditPlugin extends Plugin {
|
|
|
110
110
|
};
|
|
111
111
|
|
|
112
112
|
// Log audit asynchronously to avoid blocking
|
|
113
|
-
this.logAudit(auditRecord).catch(
|
|
113
|
+
this.logAudit(auditRecord).catch(() => {});
|
|
114
114
|
});
|
|
115
115
|
|
|
116
116
|
// Update event
|
|
@@ -143,7 +143,7 @@ export class AuditPlugin extends Plugin {
|
|
|
143
143
|
};
|
|
144
144
|
|
|
145
145
|
// Log audit asynchronously
|
|
146
|
-
this.logAudit(auditRecord).catch(
|
|
146
|
+
this.logAudit(auditRecord).catch(() => {});
|
|
147
147
|
});
|
|
148
148
|
|
|
149
149
|
// Delete event
|
|
@@ -176,14 +176,14 @@ export class AuditPlugin extends Plugin {
|
|
|
176
176
|
};
|
|
177
177
|
|
|
178
178
|
// Log audit asynchronously
|
|
179
|
-
this.logAudit(auditRecord).catch(
|
|
179
|
+
this.logAudit(auditRecord).catch(() => {});
|
|
180
180
|
});
|
|
181
181
|
|
|
182
182
|
// Remover monkey patch de deleteMany
|
|
183
183
|
// Adicionar middleware para deleteMany
|
|
184
184
|
resource.useMiddleware('deleteMany', async (ctx, next) => {
|
|
185
185
|
const ids = ctx.args[0];
|
|
186
|
-
//
|
|
186
|
+
// Capture data before deletion
|
|
187
187
|
const oldDataMap = {};
|
|
188
188
|
if (this.config.includeData) {
|
|
189
189
|
for (const id of ids) {
|
|
@@ -214,7 +214,7 @@ export class AuditPlugin extends Plugin {
|
|
|
214
214
|
batchOperation: true
|
|
215
215
|
})
|
|
216
216
|
};
|
|
217
|
-
this.logAudit(auditRecord).catch(
|
|
217
|
+
this.logAudit(auditRecord).catch(() => {});
|
|
218
218
|
}
|
|
219
219
|
}
|
|
220
220
|
return result;
|