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.
- package/README.md +102 -8
- package/dist/s3db.cjs.js +36664 -15480
- package/dist/s3db.cjs.js.map +1 -1
- package/dist/s3db.d.ts +57 -0
- package/dist/s3db.es.js +36661 -15531
- package/dist/s3db.es.js.map +1 -1
- package/mcp/entrypoint.js +58 -0
- package/mcp/tools/documentation.js +434 -0
- package/mcp/tools/index.js +4 -0
- package/package.json +27 -6
- package/src/behaviors/user-managed.js +13 -6
- package/src/client.class.js +41 -46
- package/src/concerns/base62.js +85 -0
- package/src/concerns/dictionary-encoding.js +294 -0
- package/src/concerns/geo-encoding.js +256 -0
- package/src/concerns/high-performance-inserter.js +34 -30
- package/src/concerns/ip.js +325 -0
- package/src/concerns/metadata-encoding.js +345 -66
- package/src/concerns/money.js +193 -0
- package/src/concerns/partition-queue.js +7 -4
- package/src/concerns/plugin-storage.js +39 -19
- package/src/database.class.js +76 -74
- package/src/errors.js +0 -4
- package/src/plugins/api/auth/api-key-auth.js +88 -0
- package/src/plugins/api/auth/basic-auth.js +154 -0
- package/src/plugins/api/auth/index.js +112 -0
- package/src/plugins/api/auth/jwt-auth.js +169 -0
- package/src/plugins/api/index.js +539 -0
- package/src/plugins/api/middlewares/index.js +15 -0
- package/src/plugins/api/middlewares/validator.js +185 -0
- package/src/plugins/api/routes/auth-routes.js +241 -0
- package/src/plugins/api/routes/resource-routes.js +304 -0
- package/src/plugins/api/server.js +350 -0
- package/src/plugins/api/utils/error-handler.js +147 -0
- package/src/plugins/api/utils/openapi-generator.js +1240 -0
- package/src/plugins/api/utils/response-formatter.js +218 -0
- package/src/plugins/backup/streaming-exporter.js +132 -0
- package/src/plugins/backup.plugin.js +103 -50
- package/src/plugins/cache/s3-cache.class.js +95 -47
- package/src/plugins/cache.plugin.js +107 -9
- package/src/plugins/concerns/plugin-dependencies.js +313 -0
- package/src/plugins/concerns/prometheus-formatter.js +255 -0
- package/src/plugins/consumers/rabbitmq-consumer.js +4 -0
- package/src/plugins/consumers/sqs-consumer.js +4 -0
- package/src/plugins/costs.plugin.js +255 -39
- package/src/plugins/eventual-consistency/helpers.js +15 -1
- package/src/plugins/geo.plugin.js +873 -0
- package/src/plugins/importer/index.js +1020 -0
- package/src/plugins/index.js +11 -0
- package/src/plugins/metrics.plugin.js +163 -4
- package/src/plugins/queue-consumer.plugin.js +6 -27
- package/src/plugins/relation.errors.js +139 -0
- package/src/plugins/relation.plugin.js +1242 -0
- package/src/plugins/replicators/bigquery-replicator.class.js +180 -8
- package/src/plugins/replicators/dynamodb-replicator.class.js +383 -0
- package/src/plugins/replicators/index.js +28 -3
- package/src/plugins/replicators/mongodb-replicator.class.js +391 -0
- package/src/plugins/replicators/mysql-replicator.class.js +558 -0
- package/src/plugins/replicators/planetscale-replicator.class.js +409 -0
- package/src/plugins/replicators/postgres-replicator.class.js +182 -7
- package/src/plugins/replicators/s3db-replicator.class.js +1 -12
- package/src/plugins/replicators/schema-sync.helper.js +601 -0
- package/src/plugins/replicators/sqs-replicator.class.js +11 -9
- package/src/plugins/replicators/turso-replicator.class.js +416 -0
- package/src/plugins/replicators/webhook-replicator.class.js +612 -0
- package/src/plugins/state-machine.plugin.js +122 -68
- package/src/plugins/tfstate/README.md +745 -0
- package/src/plugins/tfstate/base-driver.js +80 -0
- package/src/plugins/tfstate/errors.js +112 -0
- package/src/plugins/tfstate/filesystem-driver.js +129 -0
- package/src/plugins/tfstate/index.js +2660 -0
- package/src/plugins/tfstate/s3-driver.js +192 -0
- package/src/plugins/ttl.plugin.js +536 -0
- package/src/resource.class.js +14 -10
- package/src/s3db.d.ts +57 -0
- package/src/schema.class.js +366 -32
- package/SECURITY.md +0 -76
- package/src/partition-drivers/base-partition-driver.js +0 -106
- package/src/partition-drivers/index.js +0 -66
- package/src/partition-drivers/memory-partition-driver.js +0 -289
- package/src/partition-drivers/sqs-partition-driver.js +0 -337
- 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
|
|