@stacksjs/orm 0.72.23 → 0.72.24
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/generate-database-schema.d.ts +18 -1
- package/dist/index.js +16 -15
- package/package.json +4 -4
|
@@ -8,12 +8,13 @@ export declare function buildDatabaseSchema(options?: GenerateSchemaOptions): Pr
|
|
|
8
8
|
* Pure renderer — for tests that don't want to round-trip through the
|
|
9
9
|
* model loader.
|
|
10
10
|
*/
|
|
11
|
-
export declare function renderDatabaseTypeFile(tables: Array<{ table: string, columns: Record<string, string> }
|
|
11
|
+
export declare function renderDatabaseTypeFile(tables: Array<{ table: string, columns: Record<string, string> }>, target?: SchemaTarget): string;
|
|
12
12
|
export declare interface GenerateSchemaOptions {
|
|
13
13
|
modelsDir?: string
|
|
14
14
|
defaultsDir?: string
|
|
15
15
|
outFile?: string
|
|
16
16
|
dryRun?: boolean
|
|
17
|
+
target?: SchemaTarget
|
|
17
18
|
}
|
|
18
19
|
export declare interface GenerateSchemaResult {
|
|
19
20
|
outFile: string
|
|
@@ -21,3 +22,19 @@ export declare interface GenerateSchemaResult {
|
|
|
21
22
|
errors: Array<{ file: string, error: string }>
|
|
22
23
|
content: string
|
|
23
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* The two shapes this generator can write.
|
|
27
|
+
*
|
|
28
|
+
* `app` augments `DatabaseSchema` from userland, which is what
|
|
29
|
+
* `buddy generate:db-types` produces. `framework` declares `FrameworkSchema`
|
|
30
|
+
* *inside* the database package, so the framework's own default models are typed
|
|
31
|
+
* for the framework's own code - which is the difference between
|
|
32
|
+
* `db.selectFrom('reviews')` answering a review and answering an unknown-valued
|
|
33
|
+
* record that every call site then has to assert.
|
|
34
|
+
*
|
|
35
|
+
* They are separate interfaces rather than one merged declaration on purpose:
|
|
36
|
+
* an app that overrides a default model must win, and declaration merging has no
|
|
37
|
+
* notion of precedence - two declarations of the same table would be a
|
|
38
|
+
* conflict rather than an override.
|
|
39
|
+
*/
|
|
40
|
+
export type SchemaTarget = 'app' | 'framework';
|