s3db.js 11.2.5 → 11.3.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 +138 -0
- package/dist/s3db.cjs.js +67 -2
- package/dist/s3db.cjs.js.map +1 -1
- package/dist/s3db.d.ts +3 -1
- package/dist/s3db.es.js +67 -2
- package/dist/s3db.es.js.map +1 -1
- package/mcp/.env.example +117 -0
- package/mcp/CLAUDE_CLI_SETUP.md +302 -0
- package/mcp/Dockerfile +45 -0
- package/mcp/Makefile +162 -0
- package/mcp/NPX_SETUP.md +327 -0
- package/mcp/PUBLISHING.md +281 -0
- package/mcp/README.md +125 -0
- package/mcp/docker-compose.yml +120 -0
- package/mcp/{server.js → entrypoint.js} +1941 -683
- package/mcp/examples/test-filesystem-cache.js +147 -0
- package/mcp/examples/test-mcp.js +433 -0
- package/mcp/package.json +66 -0
- package/mcp/tools/bulk.js +112 -0
- package/mcp/tools/connection.js +228 -0
- package/mcp/tools/crud.js +579 -0
- package/mcp/tools/debugging.js +299 -0
- package/mcp/tools/export-import.js +281 -0
- package/mcp/tools/index.js +67 -0
- package/mcp/tools/partitions.js +223 -0
- package/mcp/tools/query.js +150 -0
- package/mcp/tools/resources.js +96 -0
- package/mcp/tools/stats.js +281 -0
- package/package.json +17 -7
- package/src/database.class.js +1 -1
- package/src/resource.class.js +79 -0
- package/src/s3db.d.ts +3 -1
package/dist/s3db.d.ts
CHANGED
|
@@ -763,7 +763,9 @@ declare module 's3db.js' {
|
|
|
763
763
|
data: any;
|
|
764
764
|
}>;
|
|
765
765
|
validatePartitions(): void;
|
|
766
|
-
|
|
766
|
+
findOrphanedPartitions(): Record<string, { missingFields: string[]; definition: PartitionConfig; allFields: string[] }>;
|
|
767
|
+
removeOrphanedPartitions(options?: { dryRun?: boolean }): Record<string, { missingFields: string[]; definition: PartitionConfig; allFields: string[] }>;
|
|
768
|
+
|
|
767
769
|
// Partition operations
|
|
768
770
|
getPartitionKey(options: { partitionName: string; id: string; data: any }): string;
|
|
769
771
|
getFromPartition(options: { id: string; partitionName: string; partitionValues?: Record<string, any> }): Promise<any>;
|
package/dist/s3db.es.js
CHANGED
|
@@ -13121,6 +13121,71 @@ ${errorDetails}`,
|
|
|
13121
13121
|
}
|
|
13122
13122
|
return true;
|
|
13123
13123
|
}
|
|
13124
|
+
/**
|
|
13125
|
+
* Find orphaned partitions (partitions that reference non-existent fields)
|
|
13126
|
+
* @returns {Object} Object with orphaned partition names as keys and details as values
|
|
13127
|
+
* @example
|
|
13128
|
+
* const orphaned = resource.findOrphanedPartitions();
|
|
13129
|
+
* // Returns: { byRegion: { missingFields: ['region'], definition: {...} } }
|
|
13130
|
+
*/
|
|
13131
|
+
findOrphanedPartitions() {
|
|
13132
|
+
const orphaned = {};
|
|
13133
|
+
if (!this.config.partitions) {
|
|
13134
|
+
return orphaned;
|
|
13135
|
+
}
|
|
13136
|
+
for (const [partitionName, partitionDef] of Object.entries(this.config.partitions)) {
|
|
13137
|
+
if (!partitionDef.fields) {
|
|
13138
|
+
continue;
|
|
13139
|
+
}
|
|
13140
|
+
const missingFields = [];
|
|
13141
|
+
for (const fieldName of Object.keys(partitionDef.fields)) {
|
|
13142
|
+
if (!this.fieldExistsInAttributes(fieldName)) {
|
|
13143
|
+
missingFields.push(fieldName);
|
|
13144
|
+
}
|
|
13145
|
+
}
|
|
13146
|
+
if (missingFields.length > 0) {
|
|
13147
|
+
orphaned[partitionName] = {
|
|
13148
|
+
missingFields,
|
|
13149
|
+
definition: partitionDef,
|
|
13150
|
+
allFields: Object.keys(partitionDef.fields)
|
|
13151
|
+
};
|
|
13152
|
+
}
|
|
13153
|
+
}
|
|
13154
|
+
return orphaned;
|
|
13155
|
+
}
|
|
13156
|
+
/**
|
|
13157
|
+
* Remove orphaned partitions (partitions that reference non-existent fields)
|
|
13158
|
+
* WARNING: This will modify the resource configuration and should be followed by uploadMetadataFile()
|
|
13159
|
+
* @param {Object} options - Options
|
|
13160
|
+
* @param {boolean} options.dryRun - If true, only returns what would be removed without modifying (default: false)
|
|
13161
|
+
* @returns {Object} Object with removed partition names and details
|
|
13162
|
+
* @example
|
|
13163
|
+
* // Dry run to see what would be removed
|
|
13164
|
+
* const toRemove = resource.removeOrphanedPartitions({ dryRun: true });
|
|
13165
|
+
* console.log('Would remove:', toRemove);
|
|
13166
|
+
*
|
|
13167
|
+
* // Actually remove orphaned partitions
|
|
13168
|
+
* const removed = resource.removeOrphanedPartitions();
|
|
13169
|
+
* await database.uploadMetadataFile(); // Save changes to S3
|
|
13170
|
+
*/
|
|
13171
|
+
removeOrphanedPartitions({ dryRun = false } = {}) {
|
|
13172
|
+
const orphaned = this.findOrphanedPartitions();
|
|
13173
|
+
if (Object.keys(orphaned).length === 0) {
|
|
13174
|
+
return {};
|
|
13175
|
+
}
|
|
13176
|
+
if (dryRun) {
|
|
13177
|
+
return orphaned;
|
|
13178
|
+
}
|
|
13179
|
+
for (const partitionName of Object.keys(orphaned)) {
|
|
13180
|
+
delete this.config.partitions[partitionName];
|
|
13181
|
+
}
|
|
13182
|
+
this.emit("orphanedPartitionsRemoved", {
|
|
13183
|
+
resourceName: this.name,
|
|
13184
|
+
removed: Object.keys(orphaned),
|
|
13185
|
+
details: orphaned
|
|
13186
|
+
});
|
|
13187
|
+
return orphaned;
|
|
13188
|
+
}
|
|
13124
13189
|
/**
|
|
13125
13190
|
* Apply a single partition rule to a field value
|
|
13126
13191
|
* @param {*} value - The field value
|
|
@@ -15214,7 +15279,7 @@ class Database extends EventEmitter {
|
|
|
15214
15279
|
this.id = idGenerator(7);
|
|
15215
15280
|
this.version = "1";
|
|
15216
15281
|
this.s3dbVersion = (() => {
|
|
15217
|
-
const [ok, err, version] = tryFn(() => true ? "11.
|
|
15282
|
+
const [ok, err, version] = tryFn(() => true ? "11.3.1" : "latest");
|
|
15218
15283
|
return ok ? version : "latest";
|
|
15219
15284
|
})();
|
|
15220
15285
|
this.resources = {};
|
|
@@ -16018,7 +16083,7 @@ class Database extends EventEmitter {
|
|
|
16018
16083
|
autoDecrypt: config.autoDecrypt !== void 0 ? config.autoDecrypt : true,
|
|
16019
16084
|
hooks: hooks || {},
|
|
16020
16085
|
versioningEnabled: this.versioningEnabled,
|
|
16021
|
-
strictValidation: this.strictValidation,
|
|
16086
|
+
strictValidation: config.strictValidation !== void 0 ? config.strictValidation : this.strictValidation,
|
|
16022
16087
|
map: config.map,
|
|
16023
16088
|
idGenerator: config.idGenerator,
|
|
16024
16089
|
idSize: config.idSize,
|