@stacksjs/orm 0.75.585 → 0.75.590
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/model-registry.d.ts +1 -1
- package/dist/model-registry.js +1 -1
- package/package.json +23 -23
package/dist/model-registry.d.ts
CHANGED
|
@@ -57,7 +57,7 @@ export declare function resolveModelApiSelection(configured: unknown, envOverrid
|
|
|
57
57
|
export declare function selectApiModels(registry: LoadedModelRegistry, selection: ResolvedModelApiSelection): { models: Record<string, any>, unmatched: string[] };
|
|
58
58
|
export declare interface ModelRegistryOptions {
|
|
59
59
|
userRoot: string
|
|
60
|
-
defaultsRoot
|
|
60
|
+
defaultsRoot?: string
|
|
61
61
|
onImportError?: (file: string, error: unknown) => void
|
|
62
62
|
}
|
|
63
63
|
export declare interface LoadedModelRegistry {
|
package/dist/model-registry.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{readdirSync}from"node:fs";import{basename,extname,join}from"node:path";export function modelFiles(root){const files=[];const walk=(directory)=>{let entries;try{entries=readdirSync(directory,{withFileTypes:true})}catch{return}for(const entry of entries){const file=join(directory,entry.name);if(entry.isDirectory()){walk(file);continue}if(![".ts",".js"].includes(extname(entry.name)))continue;if(entry.name.startsWith(".")||entry.name.startsWith("index"))continue;files.push(file)}};walk(root);return files.sort()}async function loadRoot(root,origin,registry,onImportError){for(const file of modelFiles(root)){try{const extension=extname(file);const module=await import(`${file}?t=${Date.now()}`);const definition=module.default??module;const name=definition.name??basename(file,extension);registry.models[name]={...definition,name};registry.origins[name]=origin}catch(error){onImportError?.(file,error)}}}export async function loadModelRegistryWithOrigins(options){const registry={models:{},origins:{}};await loadRoot(options.defaultsRoot,"default",registry,options.onImportError);await loadRoot(options.userRoot,"app",registry,options.onImportError);return registry}export async function loadModelRegistry(options){return(await loadModelRegistryWithOrigins(options)).models}export function resolveModelApiSelection(configured,envOverride){let raw;let source="default";if(envOverride!==undefined&&envOverride!==null){raw=envOverride.split(",");source="env"}else if(typeof configured==="string"){raw=[configured];source="config"}else if(Array.isArray(configured)&&configured.every((entry)=>typeof entry==="string")){raw=configured;source="config"}if(raw===undefined)return{all:false,own:true,names:new Set,source};const names=raw.map((name)=>name.trim().toLowerCase()).filter(Boolean);if(names.length===0||names.includes("none"))return{all:false,own:false,names:new Set,source};if(names.includes("all"))return{all:true,own:false,names:new Set,source};return{all:false,own:names.includes("own"),names:new Set(names.filter((name)=>name!=="own")),source}}export function selectApiModels(registry,selection){const selected={};const matched=new Set;for(const[name,model]of Object.entries(registry.models)){if(!model?.traits?.useApi)continue;const key=name.toLowerCase();const named=selection.names.has(key);if(named)matched.add(key);if(selection.all||named||selection.own&®istry.origins[name]==="app")selected[name]=model}return{models:selected,unmatched:[...selection.names].filter((name)=>!matched.has(name)).sort()}}
|
|
1
|
+
import{readdirSync}from"node:fs";import{basename,extname,join}from"node:path";export function modelFiles(root){const files=[];const walk=(directory)=>{let entries;try{entries=readdirSync(directory,{withFileTypes:true})}catch{return}for(const entry of entries){const file=join(directory,entry.name);if(entry.isDirectory()){walk(file);continue}if(![".ts",".js"].includes(extname(entry.name)))continue;if(entry.name.startsWith(".")||entry.name.startsWith("index"))continue;files.push(file)}};walk(root);return files.sort()}async function loadRoot(root,origin,registry,onImportError){for(const file of modelFiles(root)){try{const extension=extname(file);const module=await import(`${file}?t=${Date.now()}`);const definition=module.default??module;const name=definition.name??basename(file,extension);registry.models[name]={...definition,name};registry.origins[name]=origin}catch(error){onImportError?.(file,error)}}}export async function loadModelRegistryWithOrigins(options){const registry={models:{},origins:{}};if(options.defaultsRoot)await loadRoot(options.defaultsRoot,"default",registry,options.onImportError);await loadRoot(options.userRoot,"app",registry,options.onImportError);return registry}export async function loadModelRegistry(options){return(await loadModelRegistryWithOrigins(options)).models}export function resolveModelApiSelection(configured,envOverride){let raw;let source="default";if(envOverride!==undefined&&envOverride!==null){raw=envOverride.split(",");source="env"}else if(typeof configured==="string"){raw=[configured];source="config"}else if(Array.isArray(configured)&&configured.every((entry)=>typeof entry==="string")){raw=configured;source="config"}if(raw===undefined)return{all:false,own:true,names:new Set,source};const names=raw.map((name)=>name.trim().toLowerCase()).filter(Boolean);if(names.length===0||names.includes("none"))return{all:false,own:false,names:new Set,source};if(names.includes("all"))return{all:true,own:false,names:new Set,source};return{all:false,own:names.includes("own"),names:new Set(names.filter((name)=>name!=="own")),source}}export function selectApiModels(registry,selection){const selected={};const matched=new Set;for(const[name,model]of Object.entries(registry.models)){if(!model?.traits?.useApi)continue;const key=name.toLowerCase();const named=selection.names.has(key);if(named)matched.add(key);if(selection.all||named||selection.own&®istry.origins[name]==="app")selected[name]=model}return{models:selected,unmatched:[...selection.names].filter((name)=>!matched.has(name)).sort()}}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@stacksjs/orm",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"sideEffects": false,
|
|
5
|
-
"version": "0.75.
|
|
5
|
+
"version": "0.75.590",
|
|
6
6
|
"description": "The Stacks ORM integration",
|
|
7
7
|
"author": "Chris Breuer",
|
|
8
8
|
"contributors": [
|
|
@@ -63,32 +63,32 @@
|
|
|
63
63
|
"prepublishOnly": "bun run build"
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
|
-
"@stacksjs/cache": "0.75.
|
|
67
|
-
"@stacksjs/cli": "0.75.
|
|
68
|
-
"@stacksjs/config": "0.75.
|
|
69
|
-
"@stacksjs/database": "0.75.
|
|
70
|
-
"@stacksjs/env": "0.75.
|
|
71
|
-
"@stacksjs/error-handling": "0.75.
|
|
72
|
-
"@stacksjs/events": "0.75.
|
|
73
|
-
"@stacksjs/logging": "0.75.
|
|
74
|
-
"@stacksjs/model-meta": "0.75.
|
|
75
|
-
"@stacksjs/pagination": "0.75.
|
|
76
|
-
"@stacksjs/path": "0.75.
|
|
77
|
-
"@stacksjs/query-builder": "0.75.
|
|
78
|
-
"@stacksjs/realtime": "0.75.
|
|
79
|
-
"@stacksjs/router": "0.75.
|
|
80
|
-
"@stacksjs/storage": "0.75.
|
|
81
|
-
"@stacksjs/strings": "0.75.
|
|
66
|
+
"@stacksjs/cache": "0.75.590",
|
|
67
|
+
"@stacksjs/cli": "0.75.590",
|
|
68
|
+
"@stacksjs/config": "0.75.590",
|
|
69
|
+
"@stacksjs/database": "0.75.590",
|
|
70
|
+
"@stacksjs/env": "0.75.590",
|
|
71
|
+
"@stacksjs/error-handling": "0.75.590",
|
|
72
|
+
"@stacksjs/events": "0.75.590",
|
|
73
|
+
"@stacksjs/logging": "0.75.590",
|
|
74
|
+
"@stacksjs/model-meta": "0.75.590",
|
|
75
|
+
"@stacksjs/pagination": "0.75.590",
|
|
76
|
+
"@stacksjs/path": "0.75.590",
|
|
77
|
+
"@stacksjs/query-builder": "0.75.590",
|
|
78
|
+
"@stacksjs/realtime": "0.75.590",
|
|
79
|
+
"@stacksjs/router": "0.75.590",
|
|
80
|
+
"@stacksjs/storage": "0.75.590",
|
|
81
|
+
"@stacksjs/strings": "0.75.590",
|
|
82
82
|
"@stacksjs/ts-validation": "^0.5.7",
|
|
83
|
-
"@stacksjs/validation": "0.75.
|
|
83
|
+
"@stacksjs/validation": "0.75.590",
|
|
84
84
|
"bun-query-builder": "^0.6.0",
|
|
85
85
|
"stripe": "23.0.0"
|
|
86
86
|
},
|
|
87
87
|
"peerDependencies": {
|
|
88
|
-
"@stacksjs/auth": "0.75.
|
|
89
|
-
"@stacksjs/payments": "0.75.
|
|
90
|
-
"@stacksjs/queue": "0.75.
|
|
91
|
-
"@stacksjs/search-engine": "0.75.
|
|
88
|
+
"@stacksjs/auth": "0.75.590",
|
|
89
|
+
"@stacksjs/payments": "0.75.590",
|
|
90
|
+
"@stacksjs/queue": "0.75.590",
|
|
91
|
+
"@stacksjs/search-engine": "0.75.590"
|
|
92
92
|
},
|
|
93
93
|
"peerDependenciesMeta": {
|
|
94
94
|
"@stacksjs/auth": {
|
|
@@ -102,7 +102,7 @@
|
|
|
102
102
|
}
|
|
103
103
|
},
|
|
104
104
|
"devDependencies": {
|
|
105
|
-
"@stacksjs/types": "0.75.
|
|
105
|
+
"@stacksjs/types": "0.75.590",
|
|
106
106
|
"better-dx": "^0.2.39"
|
|
107
107
|
}
|
|
108
108
|
}
|