s3db.js 9.2.0 → 9.2.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 +453 -102
- package/README.md +31 -2
- package/dist/s3db.cjs.js +1099 -507
- package/dist/s3db.cjs.js.map +1 -1
- package/dist/s3db.es.js +1099 -507
- package/dist/s3db.es.js.map +1 -1
- package/package.json +5 -5
- package/src/concerns/async-event-emitter.js +46 -0
- package/src/database.class.js +23 -0
- package/src/plugins/backup/base-backup-driver.class.js +119 -0
- package/src/plugins/backup/filesystem-backup-driver.class.js +254 -0
- package/src/plugins/backup/index.js +85 -0
- package/src/plugins/backup/multi-backup-driver.class.js +304 -0
- package/src/plugins/backup/s3-backup-driver.class.js +313 -0
- package/src/plugins/backup.plugin.js +375 -729
- package/src/plugins/backup.plugin.js.backup +1026 -0
- package/src/plugins/scheduler.plugin.js +0 -1
- package/src/resource.class.js +9 -6
package/src/resource.class.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { join } from "path";
|
|
2
|
-
import EventEmitter from "events";
|
|
3
2
|
import { createHash } from "crypto";
|
|
3
|
+
import AsyncEventEmitter from "./concerns/async-event-emitter.js";
|
|
4
4
|
import { customAlphabet, urlAlphabet } from 'nanoid';
|
|
5
5
|
import jsonStableStringify from "json-stable-stringify";
|
|
6
6
|
import { PromisePool } from "@supercharge/promise-pool";
|
|
@@ -16,7 +16,7 @@ import { calculateTotalSize, calculateEffectiveLimit } from "./concerns/calculat
|
|
|
16
16
|
import { mapAwsError, InvalidResourceItem, ResourceError, PartitionError } from "./errors.js";
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
export class Resource extends
|
|
19
|
+
export class Resource extends AsyncEventEmitter {
|
|
20
20
|
/**
|
|
21
21
|
* Create a new Resource instance
|
|
22
22
|
* @param {Object} config - Resource configuration
|
|
@@ -40,6 +40,7 @@ export class Resource extends EventEmitter {
|
|
|
40
40
|
* @param {number} [config.idSize=22] - Size for auto-generated IDs
|
|
41
41
|
* @param {boolean} [config.versioningEnabled=false] - Enable versioning for this resource
|
|
42
42
|
* @param {Object} [config.events={}] - Event listeners to automatically add
|
|
43
|
+
* @param {boolean} [config.asyncEvents=true] - Whether events should be emitted asynchronously
|
|
43
44
|
* @example
|
|
44
45
|
* const users = new Resource({
|
|
45
46
|
* name: 'users',
|
|
@@ -133,7 +134,8 @@ export class Resource extends EventEmitter {
|
|
|
133
134
|
idGenerator: customIdGenerator,
|
|
134
135
|
idSize = 22,
|
|
135
136
|
versioningEnabled = false,
|
|
136
|
-
events = {}
|
|
137
|
+
events = {},
|
|
138
|
+
asyncEvents = true
|
|
137
139
|
} = config;
|
|
138
140
|
|
|
139
141
|
// Set instance properties
|
|
@@ -145,6 +147,9 @@ export class Resource extends EventEmitter {
|
|
|
145
147
|
this.parallelism = parallelism;
|
|
146
148
|
this.passphrase = passphrase ?? 'secret';
|
|
147
149
|
this.versioningEnabled = versioningEnabled;
|
|
150
|
+
|
|
151
|
+
// Configure async events mode
|
|
152
|
+
this.setAsyncMode(asyncEvents);
|
|
148
153
|
|
|
149
154
|
// Configure ID generator
|
|
150
155
|
this.idGenerator = this.configureIdGenerator(customIdGenerator, idSize);
|
|
@@ -171,6 +176,7 @@ export class Resource extends EventEmitter {
|
|
|
171
176
|
partitions,
|
|
172
177
|
autoDecrypt,
|
|
173
178
|
allNestedObjectsOptional,
|
|
179
|
+
asyncEvents,
|
|
174
180
|
};
|
|
175
181
|
|
|
176
182
|
// Initialize hooks system
|
|
@@ -2452,9 +2458,6 @@ export class Resource extends EventEmitter {
|
|
|
2452
2458
|
return filtered;
|
|
2453
2459
|
}
|
|
2454
2460
|
|
|
2455
|
-
emit(event, ...args) {
|
|
2456
|
-
return super.emit(event, ...args);
|
|
2457
|
-
}
|
|
2458
2461
|
|
|
2459
2462
|
async replace(id, attributes) {
|
|
2460
2463
|
await this.delete(id);
|