s3db.js 6.1.0 → 7.0.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.
Files changed (60) hide show
  1. package/PLUGINS.md +2724 -0
  2. package/README.md +377 -492
  3. package/UNLICENSE +24 -0
  4. package/dist/s3db.cjs.js +30054 -18189
  5. package/dist/s3db.cjs.min.js +1 -1
  6. package/dist/s3db.d.ts +373 -72
  7. package/dist/s3db.es.js +30040 -18186
  8. package/dist/s3db.es.min.js +1 -1
  9. package/dist/s3db.iife.js +29727 -17863
  10. package/dist/s3db.iife.min.js +1 -1
  11. package/package.json +44 -69
  12. package/src/behaviors/body-only.js +110 -0
  13. package/src/behaviors/body-overflow.js +153 -0
  14. package/src/behaviors/enforce-limits.js +195 -0
  15. package/src/behaviors/index.js +39 -0
  16. package/src/behaviors/truncate-data.js +204 -0
  17. package/src/behaviors/user-managed.js +147 -0
  18. package/src/client.class.js +515 -0
  19. package/src/concerns/base62.js +61 -0
  20. package/src/concerns/calculator.js +204 -0
  21. package/src/concerns/crypto.js +142 -0
  22. package/src/concerns/id.js +8 -0
  23. package/src/concerns/index.js +5 -0
  24. package/src/concerns/try-fn.js +151 -0
  25. package/src/connection-string.class.js +75 -0
  26. package/src/database.class.js +599 -0
  27. package/src/errors.js +261 -0
  28. package/src/index.js +17 -0
  29. package/src/plugins/audit.plugin.js +442 -0
  30. package/src/plugins/cache/cache.class.js +53 -0
  31. package/src/plugins/cache/index.js +6 -0
  32. package/src/plugins/cache/memory-cache.class.js +164 -0
  33. package/src/plugins/cache/s3-cache.class.js +189 -0
  34. package/src/plugins/cache.plugin.js +275 -0
  35. package/src/plugins/consumers/index.js +24 -0
  36. package/src/plugins/consumers/rabbitmq-consumer.js +56 -0
  37. package/src/plugins/consumers/sqs-consumer.js +102 -0
  38. package/src/plugins/costs.plugin.js +81 -0
  39. package/src/plugins/fulltext.plugin.js +473 -0
  40. package/src/plugins/index.js +12 -0
  41. package/src/plugins/metrics.plugin.js +603 -0
  42. package/src/plugins/plugin.class.js +210 -0
  43. package/src/plugins/plugin.obj.js +13 -0
  44. package/src/plugins/queue-consumer.plugin.js +134 -0
  45. package/src/plugins/replicator.plugin.js +769 -0
  46. package/src/plugins/replicators/base-replicator.class.js +85 -0
  47. package/src/plugins/replicators/bigquery-replicator.class.js +328 -0
  48. package/src/plugins/replicators/index.js +44 -0
  49. package/src/plugins/replicators/postgres-replicator.class.js +427 -0
  50. package/src/plugins/replicators/s3db-replicator.class.js +352 -0
  51. package/src/plugins/replicators/sqs-replicator.class.js +427 -0
  52. package/src/resource.class.js +2626 -0
  53. package/src/s3db.d.ts +1263 -0
  54. package/src/schema.class.js +706 -0
  55. package/src/stream/index.js +16 -0
  56. package/src/stream/resource-ids-page-reader.class.js +10 -0
  57. package/src/stream/resource-ids-reader.class.js +63 -0
  58. package/src/stream/resource-reader.class.js +81 -0
  59. package/src/stream/resource-writer.class.js +92 -0
  60. package/src/validator.class.js +97 -0
package/src/s3db.d.ts ADDED
@@ -0,0 +1,1263 @@
1
+ declare module 's3db.js' {
2
+ import { EventEmitter } from 'events';
3
+ import { Readable, Writable } from 'stream';
4
+
5
+ // ============================================================================
6
+ // CORE TYPES
7
+ // ============================================================================
8
+
9
+ /** Main Database configuration */
10
+ export interface DatabaseConfig {
11
+ connectionString?: string;
12
+ region?: string;
13
+ accessKeyId?: string;
14
+ secretAccessKey?: string;
15
+ sessionToken?: string;
16
+ bucket?: string;
17
+ endpoint?: string;
18
+ forcePathStyle?: boolean;
19
+ verbose?: boolean;
20
+ parallelism?: number | string;
21
+ passphrase?: string;
22
+ versioningEnabled?: boolean;
23
+ cache?: CacheConfig | boolean;
24
+ plugins?: (PluginInterface | PluginFunction)[];
25
+ client?: Client;
26
+ }
27
+
28
+ /** Resource configuration */
29
+ export interface ResourceConfig {
30
+ name: string;
31
+ client: Client;
32
+ database?: Database;
33
+ version?: string;
34
+ attributes: Record<string, any>;
35
+ behavior?: BehaviorName;
36
+ passphrase?: string;
37
+ parallelism?: number;
38
+ observers?: any[];
39
+ cache?: boolean | CacheConfig;
40
+ autoDecrypt?: boolean;
41
+ timestamps?: boolean;
42
+ partitions?: Record<string, PartitionConfig>;
43
+ paranoid?: boolean;
44
+ allNestedObjectsOptional?: boolean;
45
+ hooks?: HookConfig;
46
+ idGenerator?: Function | number;
47
+ idSize?: number;
48
+ versioningEnabled?: boolean;
49
+ map?: any;
50
+ }
51
+
52
+ /** Partition configuration */
53
+ export interface PartitionConfig {
54
+ fields: Record<string, string>;
55
+ description?: string;
56
+ }
57
+
58
+ /** Hook configuration */
59
+ export interface HookConfig {
60
+ beforeInsert?: Function[];
61
+ afterInsert?: Function[];
62
+ beforeUpdate?: Function[];
63
+ afterUpdate?: Function[];
64
+ beforeDelete?: Function[];
65
+ afterDelete?: Function[];
66
+ }
67
+
68
+ /** Query options */
69
+ export interface QueryOptions {
70
+ limit?: number;
71
+ offset?: number;
72
+ partition?: string;
73
+ partitionValues?: Record<string, any>;
74
+ }
75
+
76
+ /** Insert options */
77
+ export interface InsertOptions {
78
+ id?: string;
79
+ }
80
+
81
+ /** Update options */
82
+ export interface UpdateOptions {
83
+ id: string;
84
+ }
85
+
86
+ /** Delete options */
87
+ export interface DeleteOptions {
88
+ id: string;
89
+ }
90
+
91
+ /** Page options */
92
+ export interface PageOptions {
93
+ offset?: number;
94
+ size?: number;
95
+ partition?: string;
96
+ partitionValues?: Record<string, any>;
97
+ skipCount?: boolean;
98
+ }
99
+
100
+ /** List options */
101
+ export interface ListOptions {
102
+ partition?: string;
103
+ partitionValues?: Record<string, any>;
104
+ limit?: number;
105
+ offset?: number;
106
+ }
107
+
108
+ /** Count options */
109
+ export interface CountOptions {
110
+ partition?: string;
111
+ partitionValues?: Record<string, any>;
112
+ }
113
+
114
+ // ============================================================================
115
+ // BEHAVIOR TYPES
116
+ // ============================================================================
117
+
118
+ /** Names of all built-in behaviors */
119
+ export type BehaviorName =
120
+ | 'user-managed'
121
+ | 'enforce-limits'
122
+ | 'truncate-data'
123
+ | 'body-overflow'
124
+ | 'body-only';
125
+
126
+ /** User Managed Behavior config (default) */
127
+ export interface UserManagedBehaviorConfig {
128
+ enabled?: boolean;
129
+ }
130
+
131
+ /** Enforce Limits Behavior config */
132
+ export interface EnforceLimitsBehaviorConfig {
133
+ enabled?: boolean;
134
+ maxBodySize?: number;
135
+ maxMetadataSize?: number;
136
+ maxKeySize?: number;
137
+ maxValueSize?: number;
138
+ maxFields?: number;
139
+ maxNestingDepth?: number;
140
+ maxArrayLength?: number;
141
+ maxStringLength?: number;
142
+ maxNumberValue?: number;
143
+ minNumberValue?: number;
144
+ enforcementMode?: 'strict' | 'warn' | 'soft';
145
+ logViolations?: boolean;
146
+ throwOnViolation?: boolean;
147
+ customValidator?: (data: any, limits: any, context: any) => boolean;
148
+ fieldLimits?: Record<string, number>;
149
+ excludeFields?: string[];
150
+ includeFields?: string[];
151
+ applyToInsert?: boolean;
152
+ applyToUpdate?: boolean;
153
+ applyToUpsert?: boolean;
154
+ applyToRead?: boolean;
155
+ warningThreshold?: number;
156
+ context?: Record<string, any>;
157
+ validateMetadata?: boolean;
158
+ validateBody?: boolean;
159
+ validateKeys?: boolean;
160
+ validateValues?: boolean;
161
+ }
162
+
163
+ /** Data Truncate Behavior config */
164
+ export interface DataTruncateBehaviorConfig {
165
+ enabled?: boolean;
166
+ truncateIndicator?: string;
167
+ priorityFields?: string[];
168
+ preserveStructure?: boolean;
169
+ fieldLimits?: Record<string, number>;
170
+ defaultLimit?: number;
171
+ truncateMode?: 'end' | 'start' | 'middle';
172
+ preserveWords?: boolean;
173
+ preserveSentences?: boolean;
174
+ excludeFields?: string[];
175
+ includeFields?: string[];
176
+ applyToInsert?: boolean;
177
+ applyToUpdate?: boolean;
178
+ applyToUpsert?: boolean;
179
+ logTruncations?: boolean;
180
+ warnOnTruncation?: boolean;
181
+ customTruncator?: (value: string, fieldName: string, limit: number, config: any) => string;
182
+ fieldTruncators?: Record<string, (value: string, fieldName: string, limit: number, config: any) => string>;
183
+ validateOnRead?: boolean;
184
+ warningThreshold?: number;
185
+ context?: Record<string, any>;
186
+ preserveHTML?: boolean;
187
+ preserveMarkdown?: boolean;
188
+ preserveTags?: string[];
189
+ }
190
+
191
+ /** Body Overflow Behavior config */
192
+ export interface BodyOverflowBehaviorConfig {
193
+ enabled?: boolean;
194
+ metadataReserve?: number;
195
+ priorityFields?: string[];
196
+ preserveOrder?: boolean;
197
+ maxBodySize?: number;
198
+ overflowStrategy?: 'truncate' | 'split' | 'reject';
199
+ truncateMode?: 'end' | 'start' | 'middle';
200
+ truncateIndicator?: string;
201
+ preserveStructure?: boolean;
202
+ overflowFields?: string[];
203
+ overflowStorage?: {
204
+ type?: 's3' | 'local' | 'memory';
205
+ bucket?: string;
206
+ prefix?: string;
207
+ path?: string;
208
+ maxSize?: number;
209
+ compress?: boolean;
210
+ };
211
+ logOverflow?: boolean;
212
+ customTruncator?: (data: any, maxSize: number, config: any) => any;
213
+ customOverflowHandler?: (overflowData: any, originalData: any, config: any) => string;
214
+ validateOnRead?: boolean;
215
+ validateOnWrite?: boolean;
216
+ warningThreshold?: number;
217
+ context?: Record<string, any>;
218
+ }
219
+
220
+ /** Body Only Behavior config */
221
+ export interface BodyOnlyBehaviorConfig {
222
+ enabled?: boolean;
223
+ excludeFields?: string[];
224
+ includeFields?: string[];
225
+ applyToRead?: boolean;
226
+ applyToList?: boolean;
227
+ applyToFind?: boolean;
228
+ applyToStream?: boolean;
229
+ preserveArrays?: boolean;
230
+ deepFilter?: boolean;
231
+ customFilter?: (data: any, context: any) => any;
232
+ logFilteredFields?: boolean;
233
+ context?: Record<string, any>;
234
+ }
235
+
236
+ // ============================================================================
237
+ // PLUGIN TYPES
238
+ // ============================================================================
239
+
240
+ /** Plugin function type */
241
+ export type PluginFunction = (database: Database) => PluginInterface;
242
+
243
+ /** Plugin base interface */
244
+ export interface PluginInterface {
245
+ name?: string;
246
+ setup?: (database: Database) => Promise<void> | void;
247
+ start?: () => Promise<void> | void;
248
+ stop?: () => Promise<void> | void;
249
+ beforeSetup?: () => Promise<void> | void;
250
+ afterSetup?: () => Promise<void> | void;
251
+ beforeStart?: () => Promise<void> | void;
252
+ afterStart?: () => Promise<void> | void;
253
+ beforeStop?: () => Promise<void> | void;
254
+ afterStop?: () => Promise<void> | void;
255
+ }
256
+
257
+ /** Plugin configuration base */
258
+ export interface PluginConfig {
259
+ enabled?: boolean;
260
+ }
261
+
262
+ /** Audit Plugin config */
263
+ export interface AuditPluginConfig extends PluginConfig {
264
+ trackOperations?: string[];
265
+ includeData?: boolean;
266
+ retentionDays?: number;
267
+ logToConsole?: boolean;
268
+ customLogger?: (logEntry: any) => void;
269
+ }
270
+
271
+ /** Cache Plugin config */
272
+ export interface CachePluginConfig extends PluginConfig {
273
+ type?: 'memory' | 's3';
274
+ ttl?: number;
275
+ maxSize?: number;
276
+ enableCompression?: boolean;
277
+ storageClass?: string;
278
+ enableEncryption?: boolean;
279
+ }
280
+
281
+ /** Costs Plugin config */
282
+ export interface CostsPluginConfig extends PluginConfig {
283
+ trackOperations?: boolean;
284
+ trackStorage?: boolean;
285
+ trackRequests?: boolean;
286
+ costThreshold?: number;
287
+ alertOnThreshold?: boolean;
288
+ customPricing?: Record<string, number>;
289
+ }
290
+
291
+ /** Fulltext Plugin config */
292
+ export interface FulltextPluginConfig extends PluginConfig {
293
+ searchableFields?: string[];
294
+ indexOnInsert?: boolean;
295
+ indexOnUpdate?: boolean;
296
+ searchAlgorithm?: 'exact' | 'fuzzy' | 'prefix';
297
+ maxResults?: number;
298
+ }
299
+
300
+ /** Metrics Plugin config */
301
+ export interface MetricsPluginConfig extends PluginConfig {
302
+ trackLatency?: boolean;
303
+ trackThroughput?: boolean;
304
+ trackErrors?: boolean;
305
+ customMetrics?: string[];
306
+ exportToCloudWatch?: boolean;
307
+ }
308
+
309
+ /** Queue Consumer Plugin config */
310
+ export interface QueueConsumerPluginConfig extends PluginConfig {
311
+ consumers?: QueueConsumerConfig[];
312
+ }
313
+
314
+ /** Replicator Plugin config */
315
+ export interface ReplicatorPluginConfig extends PluginConfig {
316
+ replicators?: ReplicatorConfig[];
317
+ }
318
+
319
+ // ============================================================================
320
+ // QUEUE CONSUMER TYPES
321
+ // ============================================================================
322
+
323
+ /** Queue Consumer configuration */
324
+ export interface QueueConsumerConfig {
325
+ driver: 'sqs' | 'rabbitmq';
326
+ config: SQSConsumerConfig | RabbitMQConsumerConfig;
327
+ resources?: string[];
328
+ }
329
+
330
+ /** SQS Consumer config */
331
+ export interface SQSConsumerConfig {
332
+ region: string;
333
+ accessKeyId?: string;
334
+ secretAccessKey?: string;
335
+ sessionToken?: string;
336
+ queueUrl: string;
337
+ maxNumberOfMessages?: number;
338
+ waitTimeSeconds?: number;
339
+ visibilityTimeout?: number;
340
+ messageRetentionPeriod?: number;
341
+ maxReceiveCount?: number;
342
+ deadLetterQueueUrl?: string;
343
+ logMessages?: boolean;
344
+ autoDeleteMessages?: boolean;
345
+ sqsClientOptions?: Record<string, any>;
346
+ }
347
+
348
+ /** RabbitMQ Consumer config */
349
+ export interface RabbitMQConsumerConfig {
350
+ connectionUrl: string;
351
+ queueName: string;
352
+ exchangeName?: string;
353
+ routingKey?: string;
354
+ durable?: boolean;
355
+ autoDelete?: boolean;
356
+ exclusive?: boolean;
357
+ arguments?: Record<string, any>;
358
+ prefetch?: number;
359
+ autoAck?: boolean;
360
+ logMessages?: boolean;
361
+ connectionOptions?: Record<string, any>;
362
+ }
363
+
364
+ // ============================================================================
365
+ // REPLICATOR TYPES
366
+ // ============================================================================
367
+
368
+ /** Replicator configuration */
369
+ export interface ReplicatorConfig {
370
+ driver: 's3db' | 'sqs' | 'bigquery' | 'postgres';
371
+ config: S3dbReplicatorConfig | SQSReplicatorConfig | BigQueryReplicatorConfig | PostgresReplicatorConfig;
372
+ resources?: string[];
373
+ }
374
+
375
+ /** S3DB Replicator config */
376
+ export interface S3dbReplicatorConfig {
377
+ connectionString: string;
378
+ region?: string;
379
+ accessKeyId?: string;
380
+ secretAccessKey?: string;
381
+ sessionToken?: string;
382
+ createResources?: boolean;
383
+ overwriteExisting?: boolean;
384
+ preservePartitions?: boolean;
385
+ syncMetadata?: boolean;
386
+ batchSize?: number;
387
+ maxConcurrency?: number;
388
+ logProgress?: boolean;
389
+ targetPrefix?: string;
390
+ resourceMapping?: Record<string, string>;
391
+ validateData?: boolean;
392
+ retryAttempts?: number;
393
+ retryDelay?: number;
394
+ }
395
+
396
+ /** SQS Replicator config */
397
+ export interface SQSReplicatorConfig {
398
+ region: string;
399
+ accessKeyId?: string;
400
+ secretAccessKey?: string;
401
+ sessionToken?: string;
402
+ defaultQueueUrl?: string;
403
+ resourceQueues?: Record<string, string>;
404
+ maxRetries?: number;
405
+ retryDelay?: number;
406
+ logMessages?: boolean;
407
+ messageDelaySeconds?: number;
408
+ messageAttributes?: Record<string, any>;
409
+ messageGroupId?: string;
410
+ useFIFO?: boolean;
411
+ batchSize?: number;
412
+ compressMessages?: boolean;
413
+ messageFormat?: 'json' | 'stringified';
414
+ sqsClientOptions?: Record<string, any>;
415
+ }
416
+
417
+ /** BigQuery Replicator config */
418
+ export interface BigQueryReplicatorConfig {
419
+ projectId: string;
420
+ datasetId: string;
421
+ keyFilename?: string;
422
+ credentials?: Record<string, any>;
423
+ tableMapping?: Record<string, string>;
424
+ logOperations?: boolean;
425
+ batchSize?: number;
426
+ maxRetries?: number;
427
+ retryDelay?: number;
428
+ writeDisposition?: 'WRITE_TRUNCATE' | 'WRITE_APPEND' | 'WRITE_EMPTY';
429
+ createDisposition?: 'CREATE_IF_NEEDED' | 'CREATE_NEVER';
430
+ schema?: Record<string, any>[];
431
+ location?: string;
432
+ clustering?: string[];
433
+ partitioning?: {
434
+ type: 'DAY' | 'HOUR' | 'MONTH' | 'YEAR';
435
+ field?: string;
436
+ };
437
+ labels?: Record<string, string>;
438
+ }
439
+
440
+ /** Postgres Replicator config */
441
+ export interface PostgresReplicatorConfig {
442
+ database: string;
443
+ resourceArn: string;
444
+ secretArn: string;
445
+ region?: string;
446
+ tableMapping?: Record<string, string>;
447
+ logOperations?: boolean;
448
+ schema?: string;
449
+ maxRetries?: number;
450
+ retryDelay?: number;
451
+ useUpsert?: boolean;
452
+ conflictColumn?: string;
453
+ }
454
+
455
+ // ============================================================================
456
+ // CACHE TYPES
457
+ // ============================================================================
458
+
459
+ /** Cache configuration */
460
+ export interface CacheConfig {
461
+ type?: 'memory' | 's3';
462
+ ttl?: number;
463
+ maxSize?: number;
464
+ enableCompression?: boolean;
465
+ storageClass?: string;
466
+ enableEncryption?: boolean;
467
+ }
468
+
469
+ /** Memory Cache config */
470
+ export interface MemoryCacheConfig {
471
+ maxSize?: number;
472
+ ttl?: number;
473
+ enableStats?: boolean;
474
+ evictionPolicy?: 'lru' | 'fifo';
475
+ logEvictions?: boolean;
476
+ cleanupInterval?: number;
477
+ caseSensitive?: boolean;
478
+ serializer?: (value: any) => string;
479
+ deserializer?: (str: string) => any;
480
+ enableCompression?: boolean;
481
+ compressionThreshold?: number;
482
+ tags?: Record<string, any>;
483
+ persistent?: boolean;
484
+ persistencePath?: string;
485
+ persistenceInterval?: number;
486
+ }
487
+
488
+ /** S3 Cache config */
489
+ export interface S3CacheConfig {
490
+ bucket: string;
491
+ region?: string;
492
+ accessKeyId?: string;
493
+ secretAccessKey?: string;
494
+ sessionToken?: string;
495
+ prefix?: string;
496
+ ttl?: number;
497
+ enableCompression?: boolean;
498
+ compressionThreshold?: number;
499
+ storageClass?: string;
500
+ enableEncryption?: boolean;
501
+ encryptionAlgorithm?: string;
502
+ kmsKeyId?: string;
503
+ maxConcurrency?: number;
504
+ retryAttempts?: number;
505
+ retryDelay?: number;
506
+ logOperations?: boolean;
507
+ metadata?: Record<string, any>;
508
+ contentType?: string;
509
+ enableVersioning?: boolean;
510
+ maxKeys?: number;
511
+ enableCacheControl?: boolean;
512
+ cacheControl?: string;
513
+ s3ClientOptions?: Record<string, any>;
514
+ enableLocalCache?: boolean;
515
+ localCacheSize?: number;
516
+ localCacheTtl?: number;
517
+ }
518
+
519
+ // ============================================================================
520
+ // EVENT TYPES
521
+ // ============================================================================
522
+
523
+ /** Event payload for S3 metadata limit warnings */
524
+ export interface ExceedsLimitEvent {
525
+ operation: 'insert' | 'update' | 'upsert';
526
+ id?: string;
527
+ totalSize: number;
528
+ limit: number;
529
+ excess: number;
530
+ data: any;
531
+ }
532
+
533
+ /** Event payload for data truncation */
534
+ export interface TruncateEvent {
535
+ operation: 'insert' | 'update' | 'upsert';
536
+ id?: string;
537
+ fieldName: string;
538
+ originalLength: number;
539
+ truncatedLength: number;
540
+ data: any;
541
+ }
542
+
543
+ /** Event payload for overflow handling */
544
+ export interface OverflowEvent {
545
+ operation: 'insert' | 'update' | 'upsert';
546
+ id?: string;
547
+ strategy: 'truncate' | 'split' | 'reject';
548
+ originalSize: number;
549
+ maxSize: number;
550
+ data: any;
551
+ }
552
+
553
+ /** Definition change event */
554
+ export interface DefinitionChangeEvent {
555
+ type: 'new' | 'changed' | 'deleted';
556
+ resourceName: string;
557
+ currentHash?: string;
558
+ savedHash?: string;
559
+ fromVersion?: string;
560
+ toVersion?: string;
561
+ deletedVersion?: string;
562
+ }
563
+
564
+ // ============================================================================
565
+ // MAIN CLASSES
566
+ // ============================================================================
567
+
568
+ /** Main Database class */
569
+ export class Database extends EventEmitter {
570
+ constructor(options?: DatabaseConfig);
571
+
572
+ // Properties
573
+ version: string;
574
+ s3dbVersion: string;
575
+ resources: Record<string, Resource>;
576
+ savedMetadata: any;
577
+ options: DatabaseConfig;
578
+ verbose: boolean;
579
+ parallelism: number;
580
+ plugins: Record<string, PluginInterface>;
581
+ pluginList: PluginInterface[];
582
+ cache: CacheConfig | boolean;
583
+ passphrase: string;
584
+ versioningEnabled: boolean;
585
+ client: Client;
586
+ bucket: string;
587
+ keyPrefix: string;
588
+
589
+ // Connection methods
590
+ connect(): Promise<void>;
591
+ disconnect(): Promise<void>;
592
+ isConnected(): boolean;
593
+
594
+ // Resource methods
595
+ createResource(config: ResourceConfig): Promise<Resource>;
596
+ resource(name: string): Resource;
597
+ getResource(name: string): Promise<Resource>;
598
+ listResources(): Promise<Array<{ name: string }>>;
599
+ resourceExists(name: string): boolean;
600
+ resourceExistsWithSameHash(config: {
601
+ name: string;
602
+ attributes: any;
603
+ behavior?: string;
604
+ partitions?: Record<string, PartitionConfig>;
605
+ options?: any;
606
+ }): { exists: boolean; sameHash: boolean; hash: string | null; existingHash?: string };
607
+
608
+ // Plugin methods
609
+ startPlugins(): Promise<void>;
610
+ usePlugin(plugin: PluginInterface | PluginFunction, name?: string): Promise<PluginInterface>;
611
+
612
+ // Utility methods
613
+ generateDefinitionHash(definition: any, behavior?: string): string;
614
+ getNextVersion(versions?: Record<string, any>): string;
615
+ detectDefinitionChanges(savedMetadata: any): DefinitionChangeEvent[];
616
+ uploadMetadataFile(): Promise<void>;
617
+ blankMetadataStructure(): any;
618
+
619
+ // Configuration
620
+ get config(): {
621
+ version: string;
622
+ s3dbVersion: string;
623
+ bucket: string;
624
+ keyPrefix: string;
625
+ parallelism: number;
626
+ verbose: boolean;
627
+ };
628
+
629
+ // Events
630
+ on(event: 'connected', handler: (date: Date) => void): this;
631
+ on(event: 'disconnected', handler: (date: Date) => void): this;
632
+ on(event: 'metadataUploaded', handler: (metadata: any) => void): this;
633
+ on(event: 'resourceDefinitionsChanged', handler: (data: { changes: DefinitionChangeEvent[]; metadata: any }) => void): this;
634
+ on(event: 's3db.resourceCreated', handler: (name: string) => void): this;
635
+ on(event: 's3db.resourceUpdated', handler: (name: string) => void): this;
636
+ on(event: string, handler: (...args: any[]) => void): this;
637
+ }
638
+
639
+ /** Main S3db class (alias for Database) */
640
+ export class S3db extends Database {}
641
+
642
+ /** Resource class */
643
+ export class Resource extends EventEmitter {
644
+ constructor(config: ResourceConfig);
645
+
646
+ // Properties
647
+ name: string;
648
+ client: Client;
649
+ database?: Database;
650
+ version: string;
651
+ behavior: BehaviorName;
652
+ observers: any[];
653
+ parallelism: number;
654
+ passphrase: string;
655
+ versioningEnabled: boolean;
656
+ idGenerator: Function;
657
+ config: {
658
+ cache: boolean | CacheConfig;
659
+ hooks: HookConfig;
660
+ paranoid: boolean;
661
+ timestamps: boolean;
662
+ partitions: Record<string, PartitionConfig>;
663
+ autoDecrypt: boolean;
664
+ allNestedObjectsOptional: boolean;
665
+ };
666
+ hooks: {
667
+ beforeInsert: Function[];
668
+ afterInsert: Function[];
669
+ beforeUpdate: Function[];
670
+ afterUpdate: Function[];
671
+ beforeDelete: Function[];
672
+ afterDelete: Function[];
673
+ };
674
+ attributes: Record<string, any>;
675
+ schema: Schema;
676
+ map: any;
677
+
678
+ // CRUD operations
679
+ insert(data: any): Promise<any>;
680
+ insertMany(objects: any[]): Promise<any[]>;
681
+ get(id: string): Promise<any>;
682
+ exists(id: string): Promise<boolean>;
683
+ update(id: string, attributes: any): Promise<any>;
684
+ upsert(data: any): Promise<any>;
685
+ delete(id: string): Promise<void>;
686
+ deleteMany(ids: string[]): Promise<void>;
687
+ deleteAll(): Promise<void>;
688
+ deleteAllData(): Promise<void>;
689
+
690
+ // List and count operations
691
+ listIds(options?: ListOptions): Promise<string[]>;
692
+ list(options?: ListOptions): Promise<any[]>;
693
+ listMain(options?: { limit?: number; offset?: number }): Promise<any[]>;
694
+ listPartition(options: { partition: string; partitionValues: Record<string, any>; limit?: number; offset?: number }): Promise<any[]>;
695
+ count(options?: CountOptions): Promise<number>;
696
+
697
+ // Batch operations
698
+ getMany(ids: string[]): Promise<any[]>;
699
+ getAll(): Promise<any[]>;
700
+
701
+ // Pagination
702
+ page(options?: PageOptions): Promise<{
703
+ items: any[];
704
+ totalItems?: number;
705
+ page: number;
706
+ pageSize: number;
707
+ totalPages?: number;
708
+ hasMore: boolean;
709
+ _debug: {
710
+ requestedSize: number;
711
+ requestedOffset: number;
712
+ actualItemsReturned: number;
713
+ skipCount: boolean;
714
+ hasTotalItems: boolean;
715
+ error?: string;
716
+ };
717
+ }>;
718
+
719
+ // Stream operations
720
+ readable(): Promise<Readable>;
721
+ writable(): Promise<Writable>;
722
+
723
+ // Content operations
724
+ setContent(options: { id: string; buffer: Buffer; contentType?: string }): Promise<void>;
725
+ content(id: string): Promise<Buffer>;
726
+ hasContent(id: string): Promise<boolean>;
727
+ deleteContent(id: string): Promise<void>;
728
+
729
+ // Schema and validation
730
+ updateAttributes(newAttributes: Record<string, any>): { oldAttributes: Record<string, any>; newAttributes: Record<string, any> };
731
+ validate(data: any): Promise<{
732
+ original: any;
733
+ isValid: boolean;
734
+ errors: any[];
735
+ data: any;
736
+ }>;
737
+ validatePartitions(): void;
738
+
739
+ // Partition operations
740
+ getPartitionKey(options: { partitionName: string; id: string; data: any }): string;
741
+ getFromPartition(options: { id: string; partitionName: string; partitionValues?: Record<string, any> }): Promise<any>;
742
+
743
+ // Query operations
744
+ query(filter?: any, options?: QueryOptions): Promise<any[]>;
745
+
746
+ // Versioning operations
747
+ createHistoricalVersion(id: string, data: any): Promise<void>;
748
+ applyVersionMapping(data: any, fromVersion: string, toVersion: string): any;
749
+ getSchemaForVersion(version: string): Promise<Schema>;
750
+
751
+ // Hook operations
752
+ addHook(event: string, fn: Function): void;
753
+ executeHooks(event: string, data: any): Promise<any>;
754
+
755
+ // Utility methods
756
+ getResourceKey(id: string): string;
757
+ getDefinitionHash(): string;
758
+ export(): any;
759
+ get options(): any;
760
+ applyDefaults(data: any): any;
761
+
762
+ // Events
763
+ on(event: 'exceedsLimit', handler: (event: ExceedsLimitEvent) => void): this;
764
+ on(event: 'truncate', handler: (event: TruncateEvent) => void): this;
765
+ on(event: 'overflow', handler: (event: OverflowEvent) => void): this;
766
+ on(event: 'versionUpdated', handler: (event: { oldVersion: string; newVersion: string }) => void): this;
767
+ on(event: 'get', handler: (data: any) => void): this;
768
+ on(event: 'page', handler: (result: any) => void): this;
769
+ on(event: string, handler: (...args: any[]) => void): this;
770
+ }
771
+
772
+ /** Client class */
773
+ export class Client extends EventEmitter {
774
+ constructor(config: {
775
+ verbose?: boolean;
776
+ id?: string;
777
+ AwsS3Client?: any;
778
+ connectionString: string;
779
+ parallelism?: number;
780
+ });
781
+
782
+ // Properties
783
+ verbose: boolean;
784
+ id: string;
785
+ parallelism: number;
786
+ config: ConnectionString;
787
+ client: any;
788
+
789
+ // S3 operations
790
+ putObject(options: {
791
+ key: string;
792
+ metadata?: Record<string, any>;
793
+ contentType?: string;
794
+ body?: Buffer;
795
+ contentEncoding?: string;
796
+ contentLength?: number;
797
+ }): Promise<any>;
798
+ getObject(key: string): Promise<any>;
799
+ headObject(key: string): Promise<any>;
800
+ copyObject(options: { from: string; to: string }): Promise<any>;
801
+ exists(key: string): Promise<boolean>;
802
+ deleteObject(key: string): Promise<any>;
803
+ deleteObjects(keys: string[]): Promise<{ deleted: any[]; notFound: any[] }>;
804
+ deleteAll(options?: { prefix?: string }): Promise<number>;
805
+ moveObject(options: { from: string; to: string }): Promise<boolean>;
806
+ moveAllObjects(options: { prefixFrom: string; prefixTo: string }): Promise<string[]>;
807
+
808
+ // List operations
809
+ listObjects(options?: {
810
+ prefix?: string;
811
+ maxKeys?: number;
812
+ continuationToken?: string;
813
+ }): Promise<any>;
814
+ count(options?: { prefix?: string }): Promise<number>;
815
+ getAllKeys(options?: { prefix?: string }): Promise<string[]>;
816
+ getContinuationTokenAfterOffset(params?: {
817
+ prefix?: string;
818
+ offset?: number;
819
+ maxKeys?: number;
820
+ continuationToken?: string;
821
+ }): Promise<string | null>;
822
+ getKeysPage(params?: {
823
+ prefix?: string;
824
+ offset?: number;
825
+ amount?: number;
826
+ }): Promise<string[]>;
827
+
828
+ // Utility methods
829
+ createClient(): any;
830
+ sendCommand(command: any): Promise<any>;
831
+
832
+ // Events
833
+ on(event: 'command.request', handler: (commandName: string, input: any) => void): this;
834
+ on(event: 'command.response', handler: (commandName: string, response: any, input: any) => void): this;
835
+ on(event: 'putObject', handler: (response: any, options: any) => void): this;
836
+ on(event: 'getObject', handler: (response: any, options: any) => void): this;
837
+ on(event: 'headObject', handler: (response: any, options: any) => void): this;
838
+ on(event: 'copyObject', handler: (response: any, options: any) => void): this;
839
+ on(event: 'deleteObjects', handler: (report: any, keys: string[]) => void): this;
840
+ on(event: 'deleteAll', handler: (data: { prefix?: string; batch: number; total: number }) => void): this;
841
+ on(event: 'deleteAllComplete', handler: (data: { prefix?: string; totalDeleted: number }) => void): this;
842
+ on(event: 'listObjects', handler: (response: any, options: any) => void): this;
843
+ on(event: 'count', handler: (count: number, options: any) => void): this;
844
+ on(event: 'getAllKeys', handler: (keys: string[], options: any) => void): this;
845
+ on(event: 'getContinuationTokenAfterOffset', handler: (token: string | null, params: any) => void): this;
846
+ on(event: 'getKeysPage', handler: (keys: string[], params: any) => void): this;
847
+ on(event: 'moveAllObjects', handler: (result: { results: string[]; errors: any[] }, options: any) => void): this;
848
+ on(event: string, handler: (...args: any[]) => void): this;
849
+ }
850
+
851
+ /** Connection String class */
852
+ export class ConnectionString {
853
+ constructor(connectionString: string);
854
+ parse(): DatabaseConfig;
855
+ toString(): string;
856
+ bucket: string;
857
+ region: string;
858
+ accessKeyId?: string;
859
+ secretAccessKey?: string;
860
+ sessionToken?: string;
861
+ endpoint?: string;
862
+ forcePathStyle?: boolean;
863
+ keyPrefix?: string;
864
+ }
865
+
866
+ /** Schema class */
867
+ export class Schema {
868
+ constructor(config: {
869
+ name?: string;
870
+ attributes?: Record<string, any>;
871
+ passphrase?: string;
872
+ version?: string;
873
+ options?: any;
874
+ map?: any;
875
+ });
876
+
877
+ validate(data: any, options?: any): Promise<boolean | any[]>;
878
+ migrate(data: any, fromVersion: string, toVersion: string): any;
879
+ export(): any;
880
+ import(data: any): void;
881
+ applyHooksActions(data: any, action: string): any;
882
+ preprocessAttributesForValidation(attributes: any, options?: any): any;
883
+ toArray(value: any): string;
884
+ fromArray(value: string): any;
885
+ toJSON(value: any): string;
886
+ fromJSON(value: string): any;
887
+ toNumber(value: any): number;
888
+ toBool(value: any): boolean;
889
+ fromBool(value: any): boolean;
890
+ extractObjectKeys(obj: any): string[];
891
+ unmapper(metadata: any): Promise<any>;
892
+ map: any;
893
+ }
894
+
895
+ /** Validator class */
896
+ export class Validator {
897
+ constructor(schema?: any);
898
+ validate(data: any): boolean;
899
+ getErrors(): string[];
900
+ }
901
+
902
+ // ============================================================================
903
+ // CACHE CLASSES
904
+ // ============================================================================
905
+
906
+ /** Cache base class */
907
+ export class Cache {
908
+ constructor(config?: any);
909
+ get(key: string): Promise<any>;
910
+ set(key: string, value: any, ttl?: number): Promise<void>;
911
+ delete(key: string): Promise<void>;
912
+ clear(): Promise<void>;
913
+ getStats(): any;
914
+ }
915
+
916
+ /** Memory Cache class */
917
+ export class MemoryCache extends Cache {
918
+ constructor(config?: MemoryCacheConfig);
919
+ }
920
+
921
+ /** S3 Cache class */
922
+ export class S3Cache extends Cache {
923
+ constructor(config: S3CacheConfig);
924
+ }
925
+
926
+ // ============================================================================
927
+ // PLUGIN CLASSES
928
+ // ============================================================================
929
+
930
+ /** Plugin base class */
931
+ export class Plugin extends EventEmitter implements PluginInterface {
932
+ constructor(options?: any);
933
+ name: string;
934
+ options: any;
935
+ database?: Database;
936
+
937
+ setup(database: Database): Promise<void>;
938
+ start(): Promise<void>;
939
+ stop(): Promise<void>;
940
+ beforeSetup(): Promise<void>;
941
+ afterSetup(): Promise<void>;
942
+ beforeStart(): Promise<void>;
943
+ afterStart(): Promise<void>;
944
+ beforeStop(): Promise<void>;
945
+ afterStop(): Promise<void>;
946
+
947
+ addHook(resourceName: string, event: string, fn: Function): void;
948
+ removeHook(resourceName: string, event: string, fn: Function): void;
949
+ wrapResourceMethod(resourceName: string, methodName: string, wrapper: Function): void;
950
+
951
+ extractPartitionValues(data: any, resource: Resource): Record<string, any>;
952
+ getNestedFieldValue(data: any, fieldPath: string): any;
953
+ }
954
+
955
+ /** Audit Plugin */
956
+ export class AuditPlugin extends Plugin {
957
+ constructor(config?: AuditPluginConfig);
958
+ logAudit(operation: string, resourceName: string, recordId: string, data?: any, oldData?: any): Promise<void>;
959
+ getAuditLogs(filters?: any): Promise<any[]>;
960
+ getAuditStats(filters?: any): Promise<any>;
961
+ }
962
+
963
+ /** Cache Plugin */
964
+ export class CachePlugin extends Plugin {
965
+ constructor(config?: CachePluginConfig);
966
+ cacheKeyFor(action: string, params?: any): string;
967
+ getCacheStats(): any;
968
+ clearCache(): Promise<void>;
969
+ warmCache(resourceName: string): Promise<void>;
970
+ }
971
+
972
+ /** Costs Plugin */
973
+ export class CostsPlugin extends Plugin {
974
+ constructor(config?: CostsPluginConfig);
975
+ trackOperation(operation: string, size: number, metadata?: any): void;
976
+ getCosts(): any;
977
+ resetCosts(): void;
978
+ }
979
+
980
+ /** Fulltext Plugin */
981
+ export class FullTextPlugin extends Plugin {
982
+ constructor(config?: FulltextPluginConfig);
983
+ search(query: string, options?: any): Promise<any[]>;
984
+ indexResource(resourceName: string): Promise<void>;
985
+ clearIndex(resourceName?: string): Promise<void>;
986
+ getIndexStats(): any;
987
+ }
988
+
989
+ /** Metrics Plugin */
990
+ export class MetricsPlugin extends Plugin {
991
+ constructor(config?: MetricsPluginConfig);
992
+ trackOperation(operation: string, duration: number, success: boolean): void;
993
+ getMetrics(): any;
994
+ getErrorLogs(): any[];
995
+ getPerformanceLogs(): any[];
996
+ getStats(): any;
997
+ }
998
+
999
+ /** Queue Consumer Plugin */
1000
+ export class QueueConsumerPlugin {
1001
+ constructor(config?: QueueConsumerPluginConfig);
1002
+ setup(database: Database): Promise<void>;
1003
+ start(): Promise<void>;
1004
+ stop(): Promise<void>;
1005
+ getConsumerStats(): any;
1006
+ getConsumerLogs(filters?: any): Promise<any[]>;
1007
+ }
1008
+
1009
+ /** Replicator Plugin */
1010
+ export class ReplicatorPlugin extends Plugin {
1011
+ constructor(config?: ReplicatorPluginConfig);
1012
+ replicate(operation: string, resourceName: string, data: any, oldData?: any): Promise<void>;
1013
+ getReplicatorStats(): any;
1014
+ getReplicatorLogs(filters?: any): Promise<any[]>;
1015
+ retryFailedReplications(): Promise<void>;
1016
+ syncAllData(targetName: string): Promise<void>;
1017
+ }
1018
+
1019
+ // ============================================================================
1020
+ // REPLICATOR CLASSES
1021
+ // ============================================================================
1022
+
1023
+ /** Base Replicator class */
1024
+ export class BaseReplicator {
1025
+ constructor(config: any);
1026
+ replicate(operation: string, resourceName: string, data: any, oldData?: any): Promise<void>;
1027
+ syncData(resourceName: string, data: any[]): Promise<void>;
1028
+ getStats(): any;
1029
+ getLogs(filters?: any): Promise<any[]>;
1030
+ }
1031
+
1032
+ /** S3DB Replicator class */
1033
+ export class S3dbReplicator extends BaseReplicator {
1034
+ constructor(config: S3dbReplicatorConfig);
1035
+ }
1036
+
1037
+ /** SQS Replicator class */
1038
+ export class SqsReplicator extends BaseReplicator {
1039
+ constructor(config: SQSReplicatorConfig);
1040
+ }
1041
+
1042
+ /** BigQuery Replicator class */
1043
+ export class BigqueryReplicator extends BaseReplicator {
1044
+ constructor(config: BigQueryReplicatorConfig);
1045
+ }
1046
+
1047
+ /** Postgres Replicator class */
1048
+ export class PostgresReplicator extends BaseReplicator {
1049
+ constructor(config: PostgresReplicatorConfig);
1050
+ }
1051
+
1052
+ // ============================================================================
1053
+ // STREAM CLASSES
1054
+ // ============================================================================
1055
+
1056
+ /** Resource Reader Stream */
1057
+ export class ResourceReader extends Readable {
1058
+ constructor(config: { resource: Resource; options?: any });
1059
+ build(): Promise<Readable>;
1060
+ }
1061
+
1062
+ /** Resource Writer Stream */
1063
+ export class ResourceWriter extends Writable {
1064
+ constructor(config: { resource: Resource; options?: any });
1065
+ build(): Promise<Writable>;
1066
+ }
1067
+
1068
+ /** Resource IDs Reader Stream */
1069
+ export class ResourceIdsReader extends Readable {
1070
+ constructor(config: { resource: Resource; options?: any });
1071
+ build(): Promise<Readable>;
1072
+ }
1073
+
1074
+ /** Resource IDs Page Reader Stream */
1075
+ export class ResourceIdsPageReader extends Readable {
1076
+ constructor(config: { resource: Resource; options?: any });
1077
+ build(): Promise<Readable>;
1078
+ }
1079
+
1080
+ // ============================================================================
1081
+ // ERROR CLASSES
1082
+ // ============================================================================
1083
+
1084
+ /** Base S3db error */
1085
+ export class BaseError extends Error {
1086
+ constructor(config: {
1087
+ verbose?: boolean;
1088
+ bucket?: string;
1089
+ key?: string;
1090
+ message: string;
1091
+ code?: string;
1092
+ statusCode?: number;
1093
+ requestId?: string;
1094
+ awsMessage?: string;
1095
+ original?: Error;
1096
+ commandName?: string;
1097
+ commandInput?: any;
1098
+ metadata?: any;
1099
+ suggestion?: string;
1100
+ [key: string]: any;
1101
+ });
1102
+
1103
+ bucket?: string;
1104
+ key?: string;
1105
+ thrownAt: Date;
1106
+ code?: string;
1107
+ statusCode?: number;
1108
+ requestId?: string;
1109
+ awsMessage?: string;
1110
+ original?: Error;
1111
+ commandName?: string;
1112
+ commandInput?: any;
1113
+ metadata?: any;
1114
+ suggestion?: string;
1115
+ data: any;
1116
+
1117
+ toJson(): any;
1118
+ }
1119
+
1120
+ /** Not Found error */
1121
+ export class NotFound extends BaseError {
1122
+ constructor(config: any);
1123
+ }
1124
+
1125
+ /** No Such Key error */
1126
+ export class NoSuchKey extends BaseError {
1127
+ constructor(config: any);
1128
+ }
1129
+
1130
+ /** No Such Bucket error */
1131
+ export class NoSuchBucket extends BaseError {
1132
+ constructor(config: any);
1133
+ }
1134
+
1135
+ /** Unknown Error */
1136
+ export class UnknownError extends BaseError {
1137
+ constructor(message: string, config?: any);
1138
+ }
1139
+
1140
+ /** Missing Metadata error */
1141
+ export class MissingMetadata extends BaseError {
1142
+ constructor(config: any);
1143
+ }
1144
+
1145
+ /** Invalid Resource Item error */
1146
+ export class InvalidResourceItem extends BaseError {
1147
+ constructor(config: any);
1148
+ }
1149
+
1150
+ /** Resource Error */
1151
+ export class ResourceError extends BaseError {
1152
+ constructor(message: string, config?: any);
1153
+ }
1154
+
1155
+ /** Resource Not Found error */
1156
+ export class ResourceNotFound extends BaseError {
1157
+ constructor(config: any);
1158
+ }
1159
+
1160
+ /** Partition Error */
1161
+ export class PartitionError extends BaseError {
1162
+ constructor(config: any);
1163
+ }
1164
+
1165
+ /** Crypto Error */
1166
+ export class CryptoError extends BaseError {
1167
+ constructor(message: string, config?: any);
1168
+ }
1169
+
1170
+ // ============================================================================
1171
+ // UTILITY FUNCTIONS
1172
+ // ============================================================================
1173
+
1174
+ /** Convert stream to string */
1175
+ export function streamToString(stream: Readable): Promise<string>;
1176
+
1177
+ /** Encrypt data */
1178
+ export function encrypt(data: any, passphrase: string): Promise<string>;
1179
+
1180
+ /** Decrypt data */
1181
+ export function decrypt(encryptedData: string, passphrase: string): Promise<any>;
1182
+
1183
+ /** SHA256 hash function */
1184
+ export function sha256(message: string): Promise<ArrayBuffer>;
1185
+
1186
+ /** Generate ID */
1187
+ export function idGenerator(): string;
1188
+
1189
+ /** Generate password */
1190
+ export function passwordGenerator(length?: number): string;
1191
+
1192
+ /** Try function wrapper */
1193
+ export function tryFn<T>(fn: () => Promise<T>): Promise<[boolean, Error | null, T | null]>;
1194
+ export function tryFnSync<T>(fn: () => T): [boolean, Error | null, T | null];
1195
+
1196
+ /** Calculate total size in bytes */
1197
+ export function calculateTotalSize(data: any): number;
1198
+
1199
+ /** Calculate effective limit */
1200
+ export function calculateEffectiveLimit(config: {
1201
+ s3Limit: number;
1202
+ systemConfig: {
1203
+ version?: string;
1204
+ timestamps?: boolean;
1205
+ id?: string;
1206
+ };
1207
+ }): number;
1208
+
1209
+ /** Calculate attribute sizes */
1210
+ export function calculateAttributeSizes(data: any): Record<string, number>;
1211
+
1212
+ /** Calculate UTF-8 bytes */
1213
+ export function calculateUTF8Bytes(str: string): number;
1214
+
1215
+ /** Map AWS error to s3db error */
1216
+ export function mapAwsError(error: Error, context: any): Error;
1217
+
1218
+ /** Base62 encoding */
1219
+ export function base62Encode(num: number): string;
1220
+ export function base62Decode(str: string): number;
1221
+
1222
+ // ============================================================================
1223
+ // BEHAVIOR FUNCTIONS
1224
+ // ============================================================================
1225
+
1226
+ /** Available behavior names */
1227
+ export const AVAILABLE_BEHAVIORS: BehaviorName[];
1228
+
1229
+ /** Default behavior name */
1230
+ export const DEFAULT_BEHAVIOR: BehaviorName;
1231
+
1232
+ /** Get behavior implementation */
1233
+ export function getBehavior(behaviorName: BehaviorName): {
1234
+ handleInsert: (params: { resource: Resource; data: any; mappedData: any; originalData?: any }) => Promise<{ mappedData: any; body: string }>;
1235
+ handleUpdate: (params: { resource: Resource; id: string; data: any; mappedData: any; originalData?: any }) => Promise<{ mappedData: any; body: string }>;
1236
+ handleUpsert: (params: { resource: Resource; id: string; data: any; mappedData: any; originalData?: any }) => Promise<{ mappedData: any; body: string }>;
1237
+ handleGet: (params: { resource: Resource; metadata: any; body: string }) => Promise<{ metadata: any; body: string }>;
1238
+ };
1239
+
1240
+ /** Available behaviors object */
1241
+ export const behaviors: Record<BehaviorName, any>;
1242
+
1243
+ // ============================================================================
1244
+ // REPLICATOR CONSTANTS
1245
+ // ============================================================================
1246
+
1247
+ /** Available replicator drivers */
1248
+ export const REPLICATOR_DRIVERS: {
1249
+ s3db: typeof S3dbReplicator;
1250
+ sqs: typeof SqsReplicator;
1251
+ bigquery: typeof BigqueryReplicator;
1252
+ postgres: typeof PostgresReplicator;
1253
+ };
1254
+
1255
+ /** Create replicator instance */
1256
+ export function createReplicator(driver: string, config: any): BaseReplicator;
1257
+
1258
+ // ============================================================================
1259
+ // DEFAULT EXPORT
1260
+ // ============================================================================
1261
+
1262
+ export default S3db;
1263
+ }