s3db.js 13.3.1 → 13.5.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/README.md +34 -10
- package/dist/s3db.cjs.js +12208 -11139
- package/dist/s3db.cjs.js.map +1 -1
- package/dist/s3db.es.js +12209 -11140
- package/dist/s3db.es.js.map +1 -1
- package/package.json +16 -3
- package/src/database.class.js +2 -2
- package/src/plugins/api/auth/basic-auth.js +17 -9
- package/src/plugins/api/index.js +23 -19
- package/src/plugins/api/routes/auth-routes.js +100 -79
- package/src/plugins/api/routes/resource-routes.js +3 -2
- package/src/plugins/api/server.js +176 -5
- package/src/plugins/api/utils/custom-routes.js +102 -0
- package/src/plugins/api/utils/openapi-generator.js +52 -6
- package/src/plugins/audit.plugin.js +427 -0
- package/src/plugins/concerns/plugin-dependencies.js +1 -1
- package/src/plugins/costs.plugin.js +524 -0
- package/src/plugins/eventual-consistency/consolidation.js +2 -2
- package/src/plugins/eventual-consistency/garbage-collection.js +2 -2
- package/src/plugins/eventual-consistency/install.js +2 -2
- package/src/plugins/fulltext.plugin.js +484 -0
- package/src/plugins/metrics.plugin.js +575 -0
- package/src/plugins/ml/base-model.class.js +33 -9
- package/src/plugins/ml.plugin.js +474 -13
- package/src/plugins/queue-consumer.plugin.js +607 -19
- package/src/plugins/state-machine.plugin.js +187 -26
package/README.md
CHANGED
|
@@ -137,6 +137,8 @@ console.log("🎉 Connected to S3 database!");
|
|
|
137
137
|
|
|
138
138
|
### 3. Create your first resource
|
|
139
139
|
|
|
140
|
+
Schema validation powered by **[fastest-validator](https://github.com/icebob/fastest-validator)** ⚡
|
|
141
|
+
|
|
140
142
|
```javascript
|
|
141
143
|
const users = await s3db.createResource({
|
|
142
144
|
name: "users",
|
|
@@ -718,7 +720,7 @@ await users.insert({ email: 'john@example.com', password: 'secret123', age: 25 }
|
|
|
718
720
|
|
|
719
721
|
### Schema & Field Types
|
|
720
722
|
|
|
721
|
-
Define your data structure with powerful validation:
|
|
723
|
+
Define your data structure with powerful validation using **[fastest-validator](https://github.com/icebob/fastest-validator)** - a blazing-fast validation library with comprehensive type support:
|
|
722
724
|
|
|
723
725
|
#### Basic Types
|
|
724
726
|
|
|
@@ -749,6 +751,9 @@ Define your data structure with powerful validation:
|
|
|
749
751
|
|
|
750
752
|
#### Schema Examples
|
|
751
753
|
|
|
754
|
+
> **📖 Validation powered by [fastest-validator](https://github.com/icebob/fastest-validator)**
|
|
755
|
+
> All schemas use fastest-validator's syntax with full support for shorthand notation.
|
|
756
|
+
|
|
752
757
|
```javascript
|
|
753
758
|
// Simple schema
|
|
754
759
|
{
|
|
@@ -757,21 +762,40 @@ Define your data structure with powerful validation:
|
|
|
757
762
|
age: 'number|integer|min:0|max:150'
|
|
758
763
|
}
|
|
759
764
|
|
|
760
|
-
// Nested objects
|
|
765
|
+
// Nested objects - MAGIC AUTO-DETECT! ✨ (recommended)
|
|
766
|
+
// Just write your object structure - s3db detects it automatically!
|
|
767
|
+
{
|
|
768
|
+
name: 'string|required',
|
|
769
|
+
profile: { // ← No $$type needed! Auto-detected as optional object
|
|
770
|
+
bio: 'string|max:500',
|
|
771
|
+
avatar: 'url|optional',
|
|
772
|
+
social: { // ← Deeply nested also works!
|
|
773
|
+
twitter: 'string|optional',
|
|
774
|
+
github: 'string|optional'
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
// Need validation control? Use $$type (when you need required/optional)
|
|
780
|
+
{
|
|
781
|
+
name: 'string|required',
|
|
782
|
+
profile: {
|
|
783
|
+
$$type: 'object|required', // ← Add required validation
|
|
784
|
+
bio: 'string|max:500',
|
|
785
|
+
avatar: 'url|optional'
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
// Advanced: Full control (rare cases - strict mode, etc)
|
|
761
790
|
{
|
|
762
791
|
name: 'string|required',
|
|
763
792
|
profile: {
|
|
764
793
|
type: 'object',
|
|
794
|
+
optional: false,
|
|
795
|
+
strict: true, // ← Enable strict validation
|
|
765
796
|
props: {
|
|
766
797
|
bio: 'string|max:500',
|
|
767
|
-
avatar: 'url|optional'
|
|
768
|
-
social: {
|
|
769
|
-
type: 'object',
|
|
770
|
-
props: {
|
|
771
|
-
twitter: 'string|optional',
|
|
772
|
-
github: 'string|optional'
|
|
773
|
-
}
|
|
774
|
-
}
|
|
798
|
+
avatar: 'url|optional'
|
|
775
799
|
}
|
|
776
800
|
}
|
|
777
801
|
}
|