s3db.js 11.3.2 → 12.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 (82) hide show
  1. package/README.md +102 -8
  2. package/dist/s3db.cjs.js +36664 -15480
  3. package/dist/s3db.cjs.js.map +1 -1
  4. package/dist/s3db.d.ts +57 -0
  5. package/dist/s3db.es.js +36661 -15531
  6. package/dist/s3db.es.js.map +1 -1
  7. package/mcp/entrypoint.js +58 -0
  8. package/mcp/tools/documentation.js +434 -0
  9. package/mcp/tools/index.js +4 -0
  10. package/package.json +27 -6
  11. package/src/behaviors/user-managed.js +13 -6
  12. package/src/client.class.js +41 -46
  13. package/src/concerns/base62.js +85 -0
  14. package/src/concerns/dictionary-encoding.js +294 -0
  15. package/src/concerns/geo-encoding.js +256 -0
  16. package/src/concerns/high-performance-inserter.js +34 -30
  17. package/src/concerns/ip.js +325 -0
  18. package/src/concerns/metadata-encoding.js +345 -66
  19. package/src/concerns/money.js +193 -0
  20. package/src/concerns/partition-queue.js +7 -4
  21. package/src/concerns/plugin-storage.js +39 -19
  22. package/src/database.class.js +76 -74
  23. package/src/errors.js +0 -4
  24. package/src/plugins/api/auth/api-key-auth.js +88 -0
  25. package/src/plugins/api/auth/basic-auth.js +154 -0
  26. package/src/plugins/api/auth/index.js +112 -0
  27. package/src/plugins/api/auth/jwt-auth.js +169 -0
  28. package/src/plugins/api/index.js +539 -0
  29. package/src/plugins/api/middlewares/index.js +15 -0
  30. package/src/plugins/api/middlewares/validator.js +185 -0
  31. package/src/plugins/api/routes/auth-routes.js +241 -0
  32. package/src/plugins/api/routes/resource-routes.js +304 -0
  33. package/src/plugins/api/server.js +350 -0
  34. package/src/plugins/api/utils/error-handler.js +147 -0
  35. package/src/plugins/api/utils/openapi-generator.js +1240 -0
  36. package/src/plugins/api/utils/response-formatter.js +218 -0
  37. package/src/plugins/backup/streaming-exporter.js +132 -0
  38. package/src/plugins/backup.plugin.js +103 -50
  39. package/src/plugins/cache/s3-cache.class.js +95 -47
  40. package/src/plugins/cache.plugin.js +107 -9
  41. package/src/plugins/concerns/plugin-dependencies.js +313 -0
  42. package/src/plugins/concerns/prometheus-formatter.js +255 -0
  43. package/src/plugins/consumers/rabbitmq-consumer.js +4 -0
  44. package/src/plugins/consumers/sqs-consumer.js +4 -0
  45. package/src/plugins/costs.plugin.js +255 -39
  46. package/src/plugins/eventual-consistency/helpers.js +15 -1
  47. package/src/plugins/geo.plugin.js +873 -0
  48. package/src/plugins/importer/index.js +1020 -0
  49. package/src/plugins/index.js +11 -0
  50. package/src/plugins/metrics.plugin.js +163 -4
  51. package/src/plugins/queue-consumer.plugin.js +6 -27
  52. package/src/plugins/relation.errors.js +139 -0
  53. package/src/plugins/relation.plugin.js +1242 -0
  54. package/src/plugins/replicators/bigquery-replicator.class.js +180 -8
  55. package/src/plugins/replicators/dynamodb-replicator.class.js +383 -0
  56. package/src/plugins/replicators/index.js +28 -3
  57. package/src/plugins/replicators/mongodb-replicator.class.js +391 -0
  58. package/src/plugins/replicators/mysql-replicator.class.js +558 -0
  59. package/src/plugins/replicators/planetscale-replicator.class.js +409 -0
  60. package/src/plugins/replicators/postgres-replicator.class.js +182 -7
  61. package/src/plugins/replicators/s3db-replicator.class.js +1 -12
  62. package/src/plugins/replicators/schema-sync.helper.js +601 -0
  63. package/src/plugins/replicators/sqs-replicator.class.js +11 -9
  64. package/src/plugins/replicators/turso-replicator.class.js +416 -0
  65. package/src/plugins/replicators/webhook-replicator.class.js +612 -0
  66. package/src/plugins/state-machine.plugin.js +122 -68
  67. package/src/plugins/tfstate/README.md +745 -0
  68. package/src/plugins/tfstate/base-driver.js +80 -0
  69. package/src/plugins/tfstate/errors.js +112 -0
  70. package/src/plugins/tfstate/filesystem-driver.js +129 -0
  71. package/src/plugins/tfstate/index.js +2660 -0
  72. package/src/plugins/tfstate/s3-driver.js +192 -0
  73. package/src/plugins/ttl.plugin.js +536 -0
  74. package/src/resource.class.js +14 -10
  75. package/src/s3db.d.ts +57 -0
  76. package/src/schema.class.js +366 -32
  77. package/SECURITY.md +0 -76
  78. package/src/partition-drivers/base-partition-driver.js +0 -106
  79. package/src/partition-drivers/index.js +0 -66
  80. package/src/partition-drivers/memory-partition-driver.js +0 -289
  81. package/src/partition-drivers/sqs-partition-driver.js +0 -337
  82. package/src/partition-drivers/sync-partition-driver.js +0 -38
package/dist/s3db.d.ts CHANGED
@@ -319,6 +319,20 @@ declare module 's3db.js' {
319
319
  maxResults?: number;
320
320
  }
321
321
 
322
+ /** Geo Plugin resource config */
323
+ export interface GeoResourceConfig {
324
+ latField: string;
325
+ lonField: string;
326
+ precision?: number;
327
+ addGeohash?: boolean;
328
+ }
329
+
330
+ /** Geo Plugin config */
331
+ export interface GeoPluginConfig extends PluginConfig {
332
+ resources?: Record<string, GeoResourceConfig>;
333
+ verbose?: boolean;
334
+ }
335
+
322
336
  /** Metrics Plugin config */
323
337
  export interface MetricsPluginConfig extends PluginConfig {
324
338
  trackLatency?: boolean;
@@ -1016,6 +1030,16 @@ declare module 's3db.js' {
1016
1030
  getIndexStats(): any;
1017
1031
  }
1018
1032
 
1033
+ /** Geo Plugin */
1034
+ export class GeoPlugin extends Plugin {
1035
+ constructor(config?: GeoPluginConfig);
1036
+ encodeGeohash(latitude: number, longitude: number, precision?: number): string;
1037
+ decodeGeohash(geohash: string): { latitude: number; longitude: number; error: { latitude: number; longitude: number } };
1038
+ calculateDistance(lat1: number, lon1: number, lat2: number, lon2: number): number;
1039
+ getNeighbors(geohash: string): string[];
1040
+ getStats(): any;
1041
+ }
1042
+
1019
1043
  /** Metrics Plugin */
1020
1044
  export class MetricsPlugin extends Plugin {
1021
1045
  constructor(config?: MetricsPluginConfig);
@@ -1254,6 +1278,33 @@ declare module 's3db.js' {
1254
1278
  }
1255
1279
 
1256
1280
  /** Resource extensions added by EventualConsistencyPlugin */
1281
+ export interface GeoResourceExtensions {
1282
+ /** Find locations within radius of a point */
1283
+ findNearby(options: {
1284
+ lat: number;
1285
+ lon: number;
1286
+ radius?: number;
1287
+ limit?: number;
1288
+ }): Promise<Array<any & { _distance: number }>>;
1289
+
1290
+ /** Find locations within bounding box */
1291
+ findInBounds(options: {
1292
+ north: number;
1293
+ south: number;
1294
+ east: number;
1295
+ west: number;
1296
+ limit?: number;
1297
+ }): Promise<any[]>;
1298
+
1299
+ /** Get distance between two records */
1300
+ getDistance(id1: string, id2: string): Promise<{
1301
+ distance: number;
1302
+ unit: string;
1303
+ from: string;
1304
+ to: string;
1305
+ }>;
1306
+ }
1307
+
1257
1308
  export interface EventualConsistencyResourceExtensions {
1258
1309
  /** Set field value (replaces current value) */
1259
1310
  set(id: string, field: string, value: number): Promise<number>;
@@ -1264,6 +1315,12 @@ declare module 's3db.js' {
1264
1315
  /** Decrement field value */
1265
1316
  sub(id: string, field: string, amount: number): Promise<number>;
1266
1317
 
1318
+ /** Increment field value by 1 (shorthand for add(id, field, 1)) */
1319
+ increment(id: string, field: string): Promise<number>;
1320
+
1321
+ /** Decrement field value by 1 (shorthand for sub(id, field, 1)) */
1322
+ decrement(id: string, field: string): Promise<number>;
1323
+
1267
1324
  /** Manually trigger consolidation */
1268
1325
  consolidate(id: string, field: string): Promise<number>;
1269
1326