s3db.js 12.2.4 → 12.4.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 +117 -0
- package/dist/s3db.cjs.js +1596 -167
- package/dist/s3db.cjs.js.map +1 -1
- package/dist/s3db.es.js +1499 -73
- package/dist/s3db.es.js.map +1 -1
- package/package.json +2 -2
- package/src/behaviors/body-only.js +15 -5
- package/src/behaviors/body-overflow.js +9 -0
- package/src/behaviors/user-managed.js +8 -1
- package/src/clients/index.js +14 -0
- package/src/clients/memory-client.class.js +883 -0
- package/src/clients/memory-client.md +917 -0
- package/src/clients/memory-storage.class.js +504 -0
- package/src/{client.class.js → clients/s3-client.class.js} +11 -10
- package/src/concerns/typescript-generator.js +12 -2
- package/src/database.class.js +2 -2
- package/src/index.js +2 -1
- package/src/plugins/api/utils/openapi-generator.js +21 -2
- package/src/plugins/replicators/bigquery-replicator.class.js +109 -21
- package/src/plugins/replicators/mysql-replicator.class.js +9 -1
- package/src/plugins/replicators/planetscale-replicator.class.js +9 -1
- package/src/plugins/replicators/postgres-replicator.class.js +9 -1
- package/src/plugins/replicators/schema-sync.helper.js +53 -2
- package/src/plugins/replicators/turso-replicator.class.js +9 -1
- package/src/plugins/tfstate/s3-driver.js +3 -3
- package/src/plugins/vector.plugin.js +3 -3
- package/src/resource.class.js +203 -4
- package/src/schema.class.js +223 -33
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "s3db.js",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.4.0",
|
|
4
4
|
"description": "Use AWS S3, the world's most reliable document storage, as a database with this ORM.",
|
|
5
5
|
"main": "dist/s3db.cjs.js",
|
|
6
6
|
"module": "dist/s3db.es.js",
|
|
@@ -131,6 +131,7 @@
|
|
|
131
131
|
"@rollup/plugin-terser": "^0.4.4",
|
|
132
132
|
"@types/node": "24.7.0",
|
|
133
133
|
"@xenova/transformers": "^2.17.2",
|
|
134
|
+
"@yao-pkg/pkg": "^6.9.0",
|
|
134
135
|
"amqplib": "^0.10.9",
|
|
135
136
|
"babel-loader": "^10.0.0",
|
|
136
137
|
"chalk": "^5.6.2",
|
|
@@ -143,7 +144,6 @@
|
|
|
143
144
|
"node-loader": "^2.1.0",
|
|
144
145
|
"ora": "^9.0.0",
|
|
145
146
|
"pg": "^8.16.3",
|
|
146
|
-
"pkg": "^5.8.1",
|
|
147
147
|
"rollup": "^4.52.5",
|
|
148
148
|
"rollup-plugin-copy": "^3.5.0",
|
|
149
149
|
"rollup-plugin-esbuild": "^6.2.1",
|
|
@@ -59,10 +59,15 @@ export async function handleInsert({ resource, data, mappedData }) {
|
|
|
59
59
|
'_v': mappedData._v || String(resource.version)
|
|
60
60
|
};
|
|
61
61
|
metadataOnly._map = JSON.stringify(resource.schema.map);
|
|
62
|
-
|
|
62
|
+
|
|
63
|
+
// Store pluginMap for backwards compatibility when plugins are added/removed
|
|
64
|
+
if (resource.schema.pluginMap && Object.keys(resource.schema.pluginMap).length > 0) {
|
|
65
|
+
metadataOnly._pluginMap = JSON.stringify(resource.schema.pluginMap);
|
|
66
|
+
}
|
|
67
|
+
|
|
63
68
|
// Use the original object for the body
|
|
64
69
|
const body = JSON.stringify(mappedData);
|
|
65
|
-
|
|
70
|
+
|
|
66
71
|
return { mappedData: metadataOnly, body };
|
|
67
72
|
}
|
|
68
73
|
|
|
@@ -70,16 +75,21 @@ export async function handleUpdate({ resource, id, data, mappedData }) {
|
|
|
70
75
|
// For updates, we need to merge with existing data
|
|
71
76
|
// Since we can't easily read the existing body during update,
|
|
72
77
|
// we'll put the update data in the body and let the resource handle merging
|
|
73
|
-
|
|
78
|
+
|
|
74
79
|
// Keep only the version field in metadata
|
|
75
80
|
const metadataOnly = {
|
|
76
81
|
'_v': mappedData._v || String(resource.version)
|
|
77
82
|
};
|
|
78
83
|
metadataOnly._map = JSON.stringify(resource.schema.map);
|
|
79
|
-
|
|
84
|
+
|
|
85
|
+
// Store pluginMap for backwards compatibility when plugins are added/removed
|
|
86
|
+
if (resource.schema.pluginMap && Object.keys(resource.schema.pluginMap).length > 0) {
|
|
87
|
+
metadataOnly._pluginMap = JSON.stringify(resource.schema.pluginMap);
|
|
88
|
+
}
|
|
89
|
+
|
|
80
90
|
// Use the original object for the body
|
|
81
91
|
const body = JSON.stringify(mappedData);
|
|
82
|
-
|
|
92
|
+
|
|
83
93
|
return { mappedData: metadataOnly, body };
|
|
84
94
|
}
|
|
85
95
|
|
|
@@ -90,6 +90,15 @@ export async function handleInsert({ resource, data, mappedData, originalData })
|
|
|
90
90
|
currentSize += attributeSizes._v;
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
+
// Always include plugin map for backwards compatibility when plugins are added/removed
|
|
94
|
+
// Note: _pluginMap is not in mappedData, it's added separately by behaviors
|
|
95
|
+
if (resource.schema?.pluginMap && Object.keys(resource.schema.pluginMap).length > 0) {
|
|
96
|
+
const pluginMapStr = JSON.stringify(resource.schema.pluginMap);
|
|
97
|
+
const pluginMapSize = calculateUTF8Bytes('_pluginMap') + calculateUTF8Bytes(pluginMapStr);
|
|
98
|
+
metadataFields._pluginMap = pluginMapStr;
|
|
99
|
+
currentSize += pluginMapSize;
|
|
100
|
+
}
|
|
101
|
+
|
|
93
102
|
// Reserve space for $overflow if overflow is possible
|
|
94
103
|
let reservedLimit = effectiveLimit;
|
|
95
104
|
for (const [fieldName, size] of sortedFields) {
|
|
@@ -88,7 +88,14 @@ export async function handleInsert({ resource, data, mappedData, originalData })
|
|
|
88
88
|
data: originalData || data
|
|
89
89
|
});
|
|
90
90
|
// If data exceeds limit, store in body
|
|
91
|
-
|
|
91
|
+
const metadataOnly = { _v: mappedData._v };
|
|
92
|
+
|
|
93
|
+
// Store pluginMap for backwards compatibility when plugins are added/removed
|
|
94
|
+
if (resource.schema?.pluginMap && Object.keys(resource.schema.pluginMap).length > 0) {
|
|
95
|
+
metadataOnly._pluginMap = JSON.stringify(resource.schema.pluginMap);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return { mappedData: metadataOnly, body: JSON.stringify(mappedData) };
|
|
92
99
|
}
|
|
93
100
|
|
|
94
101
|
// If data fits in metadata, store only in metadata
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* S3DB Clients
|
|
3
|
+
*
|
|
4
|
+
* Provides different client implementations for S3DB:
|
|
5
|
+
* - S3Client: Production client for AWS S3, MinIO, LocalStack
|
|
6
|
+
* - MemoryClient: Ultra-fast in-memory client for testing
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export { S3Client } from './s3-client.class.js';
|
|
10
|
+
export { MemoryClient } from './memory-client.class.js';
|
|
11
|
+
export { MemoryStorage } from './memory-storage.class.js';
|
|
12
|
+
|
|
13
|
+
// Default export is S3Client for backward compatibility
|
|
14
|
+
export { S3Client as default } from './s3-client.class.js';
|