@stacksjs/database 0.75.518 → 0.75.520
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/dist/schema-drift.d.ts +9 -0
- package/dist/schema-drift.js +1 -1
- package/package.json +16 -16
package/dist/schema-drift.d.ts
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
import type { Model } from '@stacksjs/types';
|
|
2
|
+
/**
|
|
3
|
+
* Load every model under a directory.
|
|
4
|
+
*
|
|
5
|
+
* Recursive, and tolerant per file: the built-in models are grouped into
|
|
6
|
+
* subdirectories, and one unreadable model must not cost every other model its
|
|
7
|
+
* audit. Mirrors the loader in relation-columns.ts.
|
|
8
|
+
*/
|
|
9
|
+
export declare function loadSchemaAuditModels(dir: string, include?: readonly string[]): Promise<Model[]>;
|
|
1
10
|
/**
|
|
2
11
|
* Compare the live schema against the application's models.
|
|
3
12
|
*
|
package/dist/schema-drift.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import fs from"node:fs";import{path}from"@stacksjs/path";async function
|
|
1
|
+
import fs from"node:fs";import{config,overridesReady}from"@stacksjs/config";import{path}from"@stacksjs/path";export async function loadSchemaAuditModels(dir,include){const out=[];const selected=include===undefined?undefined:new Set(include.map((name)=>name.trim().toLowerCase()));if(!fs.existsSync(dir))return out;for(const entry of fs.readdirSync(dir,{withFileTypes:true})){const fullPath=path.join(dir,entry.name);if(entry.isDirectory()){out.push(...await loadSchemaAuditModels(fullPath,include));continue}if(!entry.name.endsWith(".ts")||entry.name.startsWith("_")||entry.name.startsWith("index"))continue;if(selected&&!selected.has(entry.name.slice(0,-3).toLowerCase()))continue;try{const imported=(await import(fullPath)).default;if(imported?.name||imported?.table)out.push(imported)}catch{}}return out}export async function auditSchemaDrift(){const empty={missingTables:[],missingColumns:[],typeMismatches:[],clean:true,skipped:true};try{await overridesReady;const models=await loadSchemaAuditModels(path.appPath("Models"),config.database?.models?.include);if(models.length===0)return empty;const qb=await import("bun-query-builder");if(typeof qb.auditSchemaDrift!=="function"||typeof qb.buildMigrationPlan!=="function")return empty;const defined=qb.defineModels(Object.fromEntries(models.map((model)=>[model.name??model.table,model])));const plan=qb.buildMigrationPlan(defined,{});const drift=await qb.auditSchemaDrift(plan,{});return{...drift,skipped:false}}catch{return empty}}export async function formatSchemaDrift(report){if(report.skipped||report.clean)return"";const{formatSchemaDrift:format}=await import("bun-query-builder");return typeof format==="function"?format(report):""}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@stacksjs/database",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"sideEffects": false,
|
|
5
|
-
"version": "0.75.
|
|
5
|
+
"version": "0.75.520",
|
|
6
6
|
"description": "The Stacks database integration.",
|
|
7
7
|
"author": "Chris Breuer",
|
|
8
8
|
"contributors": [
|
|
@@ -66,26 +66,26 @@
|
|
|
66
66
|
"prepublishOnly": "bun run build"
|
|
67
67
|
},
|
|
68
68
|
"dependencies": {
|
|
69
|
-
"@stacksjs/config": "0.75.
|
|
70
|
-
"@stacksjs/env": "0.75.
|
|
71
|
-
"@stacksjs/error-handling": "0.75.
|
|
72
|
-
"@stacksjs/faker": "0.75.
|
|
73
|
-
"@stacksjs/features": "0.75.
|
|
74
|
-
"@stacksjs/logging": "0.75.
|
|
75
|
-
"@stacksjs/model-meta": "0.75.
|
|
76
|
-
"@stacksjs/path": "0.75.
|
|
77
|
-
"@stacksjs/query-builder": "0.75.
|
|
78
|
-
"@stacksjs/security": "0.75.
|
|
79
|
-
"@stacksjs/storage": "0.75.
|
|
80
|
-
"@stacksjs/strings": "0.75.
|
|
69
|
+
"@stacksjs/config": "0.75.520",
|
|
70
|
+
"@stacksjs/env": "0.75.520",
|
|
71
|
+
"@stacksjs/error-handling": "0.75.520",
|
|
72
|
+
"@stacksjs/faker": "0.75.520",
|
|
73
|
+
"@stacksjs/features": "0.75.520",
|
|
74
|
+
"@stacksjs/logging": "0.75.520",
|
|
75
|
+
"@stacksjs/model-meta": "0.75.520",
|
|
76
|
+
"@stacksjs/path": "0.75.520",
|
|
77
|
+
"@stacksjs/query-builder": "0.75.520",
|
|
78
|
+
"@stacksjs/security": "0.75.520",
|
|
79
|
+
"@stacksjs/storage": "0.75.520",
|
|
80
|
+
"@stacksjs/strings": "0.75.520",
|
|
81
81
|
"@stacksjs/ts-validation": "^0.5.7",
|
|
82
82
|
"bun-query-builder": "^0.3.38",
|
|
83
83
|
"dynamodb-tooling": "^0.3.6"
|
|
84
84
|
},
|
|
85
85
|
"devDependencies": {
|
|
86
|
-
"@stacksjs/cli": "0.75.
|
|
87
|
-
"@stacksjs/router": "0.75.
|
|
88
|
-
"@stacksjs/utils": "0.75.
|
|
86
|
+
"@stacksjs/cli": "0.75.520",
|
|
87
|
+
"@stacksjs/router": "0.75.520",
|
|
88
|
+
"@stacksjs/utils": "0.75.520",
|
|
89
89
|
"better-dx": "^0.2.24"
|
|
90
90
|
}
|
|
91
91
|
}
|