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/README.md
CHANGED
|
@@ -246,6 +246,25 @@ const s3db = new S3db({
|
|
|
246
246
|
});
|
|
247
247
|
```
|
|
248
248
|
|
|
249
|
+
### ๐งช Development & Testing
|
|
250
|
+
|
|
251
|
+
For local development, all plugin dependencies are already included as **devDependencies** - just run:
|
|
252
|
+
|
|
253
|
+
```bash
|
|
254
|
+
pnpm install # Installs everything including plugin dependencies
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
This automatically installs all plugin dependencies so you can:
|
|
258
|
+
- โ
Run the full test suite (`pnpm test`)
|
|
259
|
+
- โ
Test all plugins without errors
|
|
260
|
+
- โ
Verify compatibility with all integrations
|
|
261
|
+
|
|
262
|
+
**For end users:** They only install what they need via `peerDependencies`. The package manager automatically checks version compatibility.
|
|
263
|
+
|
|
264
|
+
**For CI/CD:** Just `pnpm install` - no extra steps needed!
|
|
265
|
+
|
|
266
|
+
---
|
|
267
|
+
|
|
249
268
|
### โก HTTP Client Configuration
|
|
250
269
|
|
|
251
270
|
s3db.js includes optimized HTTP client settings by default for excellent S3 performance. You can customize these settings based on your specific needs:
|
|
@@ -750,14 +769,32 @@ s3db.js automatically compresses numeric data using **Base62 encoding** to maxim
|
|
|
750
769
|
|
|
751
770
|
Extend s3db.js with powerful plugins for caching, monitoring, replication, search, and more:
|
|
752
771
|
|
|
772
|
+
> **๐ฆ Important:** Some plugins require additional dependencies. The s3db.js core package is lightweight (~500KB) and **does not include** plugin-specific dependencies. Install only what you need:
|
|
773
|
+
>
|
|
774
|
+
> ```bash
|
|
775
|
+
> # For PostgreSQL replication
|
|
776
|
+
> pnpm add pg
|
|
777
|
+
>
|
|
778
|
+
> # For BigQuery replication
|
|
779
|
+
> pnpm add @google-cloud/bigquery
|
|
780
|
+
>
|
|
781
|
+
> # For SQS replication/consumption
|
|
782
|
+
> pnpm add @aws-sdk/client-sqs
|
|
783
|
+
>
|
|
784
|
+
> # For RabbitMQ consumption
|
|
785
|
+
> pnpm add amqplib
|
|
786
|
+
> ```
|
|
787
|
+
>
|
|
788
|
+
> s3db.js will automatically validate dependencies at runtime and provide clear error messages with install commands if something is missing. See [Plugin Dependencies](#plugin-dependencies) for details.
|
|
789
|
+
|
|
753
790
|
```javascript
|
|
754
|
-
import {
|
|
755
|
-
CachePlugin,
|
|
756
|
-
CostsPlugin,
|
|
757
|
-
FullTextPlugin,
|
|
758
|
-
MetricsPlugin,
|
|
759
|
-
ReplicatorPlugin,
|
|
760
|
-
AuditPlugin
|
|
791
|
+
import {
|
|
792
|
+
CachePlugin,
|
|
793
|
+
CostsPlugin,
|
|
794
|
+
FullTextPlugin,
|
|
795
|
+
MetricsPlugin,
|
|
796
|
+
ReplicatorPlugin,
|
|
797
|
+
AuditPlugin
|
|
761
798
|
} from 's3db.js';
|
|
762
799
|
|
|
763
800
|
const s3db = new S3db({
|
|
@@ -803,6 +840,58 @@ await users.insert({ name: "John", email: "john@example.com" });
|
|
|
803
840
|
**๐ For complete plugin documentation and overview:**
|
|
804
841
|
**[๐ Plugin Documentation Index](./docs/plugins/README.md)**
|
|
805
842
|
|
|
843
|
+
---
|
|
844
|
+
|
|
845
|
+
#### Plugin Dependencies
|
|
846
|
+
|
|
847
|
+
s3db.js uses a **lightweight core** approach - plugin-specific dependencies are **not bundled** with the main package. This keeps the core package small (~500KB) and lets you install only what you need.
|
|
848
|
+
|
|
849
|
+
**How it works:**
|
|
850
|
+
|
|
851
|
+
1. **Automatic Validation** - When you use a plugin, s3db.js validates its dependencies at runtime
|
|
852
|
+
2. **Clear Error Messages** - If a dependency is missing, you get a helpful error with install commands
|
|
853
|
+
3. **Version Checking** - Ensures installed packages meet minimum version requirements
|
|
854
|
+
4. **Optional Dependencies** - All plugin dependencies are marked as `peerDependencies` (optional)
|
|
855
|
+
|
|
856
|
+
**Dependency Matrix:**
|
|
857
|
+
|
|
858
|
+
| Plugin | Required Package | Version | Install Command |
|
|
859
|
+
|--------|-----------------|---------|-----------------|
|
|
860
|
+
| PostgreSQL Replicator | `pg` | `^8.0.0` | `pnpm add pg` |
|
|
861
|
+
| BigQuery Replicator | `@google-cloud/bigquery` | `^7.0.0` | `pnpm add @google-cloud/bigquery` |
|
|
862
|
+
| SQS Replicator | `@aws-sdk/client-sqs` | `^3.0.0` | `pnpm add @aws-sdk/client-sqs` |
|
|
863
|
+
| SQS Consumer | `@aws-sdk/client-sqs` | `^3.0.0` | `pnpm add @aws-sdk/client-sqs` |
|
|
864
|
+
| RabbitMQ Consumer | `amqplib` | `^0.10.0` | `pnpm add amqplib` |
|
|
865
|
+
| Terraform State Plugin | `node-cron` | `^4.0.0` | `pnpm add node-cron` |
|
|
866
|
+
|
|
867
|
+
**Example Error:**
|
|
868
|
+
|
|
869
|
+
```bash
|
|
870
|
+
Error: PostgreSQL Replicator - Missing dependencies detected!
|
|
871
|
+
|
|
872
|
+
โ Missing dependency: pg
|
|
873
|
+
Description: PostgreSQL client for Node.js
|
|
874
|
+
Required: ^8.0.0
|
|
875
|
+
Install: pnpm add pg
|
|
876
|
+
|
|
877
|
+
Quick fix - Run all install commands:
|
|
878
|
+
pnpm add pg
|
|
879
|
+
```
|
|
880
|
+
|
|
881
|
+
**Checking Dependencies Programmatically:**
|
|
882
|
+
|
|
883
|
+
```javascript
|
|
884
|
+
import { getPluginDependencyReport } from 's3db.js/plugins/concerns/plugin-dependencies';
|
|
885
|
+
|
|
886
|
+
// Get a full report of all plugin dependencies
|
|
887
|
+
const report = await getPluginDependencyReport();
|
|
888
|
+
console.log(report);
|
|
889
|
+
```
|
|
890
|
+
|
|
891
|
+
**Example:** See `docs/examples/e46-plugin-dependency-validation.js` for complete examples of dependency validation.
|
|
892
|
+
|
|
893
|
+
---
|
|
894
|
+
|
|
806
895
|
### ๐๏ธ Resource Behaviors
|
|
807
896
|
|
|
808
897
|
Choose the right behavior strategy for your use case:
|
|
@@ -2141,7 +2230,12 @@ s3db.js includes comprehensive benchmarks demonstrating real-world performance o
|
|
|
2141
2230
|
**[Smart Encoding](./docs/benchmarks/smart-encoding.md)** - Intelligent encoding selection
|
|
2142
2231
|
- **Automatic type detection** and optimal encoding selection
|
|
2143
2232
|
- **2-3x faster** UTF-8 byte calculations with caching
|
|
2144
|
-
|
|
2233
|
+
|
|
2234
|
+
**[IP Address Encoding](./docs/benchmarks/ip-encoding.md)** - IPv4/IPv6 binary compression
|
|
2235
|
+
- **13.5% average savings** for IPv4 addresses (up to 47% for longer IPs)
|
|
2236
|
+
- **38.5% savings** for full-length IPv6 addresses
|
|
2237
|
+
- **2.7M+ ops/s** for IPv4 encoding, **595K+ ops/s** for IPv6
|
|
2238
|
+
- **Ideal for metadata-constrained storage** (S3 2KB limit)
|
|
2145
2239
|
|
|
2146
2240
|
### ๐ Plugin Performance
|
|
2147
2241
|
|