@sqldoc/ns-codegen 0.0.2 → 0.0.4
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/package.json +12 -11
- package/src/index.ts +11 -2
- package/src/types.ts +7 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@sqldoc/ns-codegen",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.4",
|
|
5
5
|
"description": "Code generation namespace for sqldoc -- runs configurable templates against compiled Atlas schema",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
@@ -17,17 +17,18 @@
|
|
|
17
17
|
"!src/__tests__",
|
|
18
18
|
"package.json"
|
|
19
19
|
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"test": "node --test 'src/__tests__/**/*.test.ts'",
|
|
22
|
+
"typecheck": "tsgo -noEmit"
|
|
23
|
+
},
|
|
20
24
|
"peerDependencies": {
|
|
21
|
-
"@sqldoc/core": "0.0.
|
|
22
|
-
"@sqldoc/
|
|
25
|
+
"@sqldoc/core": "0.0.3",
|
|
26
|
+
"@sqldoc/db": "0.0.3"
|
|
23
27
|
},
|
|
24
28
|
"devDependencies": {
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"@
|
|
28
|
-
"@sqldoc/
|
|
29
|
-
},
|
|
30
|
-
"scripts": {
|
|
31
|
-
"test": "vitest run"
|
|
29
|
+
"@sqldoc/core": "0.0.3",
|
|
30
|
+
"@sqldoc/db": "0.0.3",
|
|
31
|
+
"@typescript/native-preview": "latest",
|
|
32
|
+
"@sqldoc/test-utils": "0.0.1"
|
|
32
33
|
}
|
|
33
|
-
}
|
|
34
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as path from 'node:path'
|
|
2
|
-
import type { AtlasRealm } from '@sqldoc/atlas'
|
|
3
2
|
import type { NamespacePlugin, ProjectContext, ProjectOutput } from '@sqldoc/core'
|
|
4
3
|
import { findSqldocDir, tsImport, unwrapDefault } from '@sqldoc/core'
|
|
4
|
+
import type { AtlasRealm } from '@sqldoc/db'
|
|
5
5
|
import type { CodegenConfig, TemplateContext } from './types.ts'
|
|
6
6
|
|
|
7
7
|
/** Extract template name from import path: '@sqldoc/templates/typescript' -> 'typescript', './my.ts' -> 'my' */
|
|
@@ -86,6 +86,7 @@ const plugin: NamespacePlugin = {
|
|
|
86
86
|
config: entry.config ?? {},
|
|
87
87
|
output: entry.output,
|
|
88
88
|
templateName,
|
|
89
|
+
externalObjectNames: ctx.externalObjectNames,
|
|
89
90
|
}
|
|
90
91
|
|
|
91
92
|
const result = template.generate(templateCtx)
|
|
@@ -108,5 +109,13 @@ const plugin: NamespacePlugin = {
|
|
|
108
109
|
}
|
|
109
110
|
|
|
110
111
|
export default plugin
|
|
111
|
-
export type {
|
|
112
|
+
export type {
|
|
113
|
+
CodegenConfig,
|
|
114
|
+
CodegenNamespaceConfig,
|
|
115
|
+
Template,
|
|
116
|
+
TemplateContext,
|
|
117
|
+
TemplateDef,
|
|
118
|
+
TemplateEntry,
|
|
119
|
+
TemplateResult,
|
|
120
|
+
} from './types.ts'
|
|
112
121
|
export { defineTemplate } from './types.ts'
|
package/src/types.ts
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import type { AtlasRealm } from '@sqldoc/atlas'
|
|
2
1
|
import type { ArgType, DocsMeta, InferSchema } from '@sqldoc/core'
|
|
2
|
+
import type { AtlasRealm } from '@sqldoc/db'
|
|
3
3
|
|
|
4
4
|
/** Config for the codegen namespace in sqldoc.config.ts namespaces.codegen */
|
|
5
5
|
export interface CodegenConfig {
|
|
6
6
|
templates?: TemplateEntry[]
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
+
export interface CodegenNamespaceConfig {
|
|
10
|
+
codegen: CodegenConfig
|
|
11
|
+
}
|
|
12
|
+
|
|
9
13
|
/** A single template entry in the codegen config */
|
|
10
14
|
export interface TemplateEntry {
|
|
11
15
|
/** The template — either an import path string or a Template object */
|
|
@@ -37,6 +41,8 @@ export interface TemplateContext<C = Record<string, unknown>> {
|
|
|
37
41
|
output: string
|
|
38
42
|
/** Template name (derived from import path) */
|
|
39
43
|
templateName: string
|
|
44
|
+
/** Set of object names from @external files. Templates can use this to annotate external types. */
|
|
45
|
+
externalObjectNames?: Set<string>
|
|
40
46
|
}
|
|
41
47
|
|
|
42
48
|
/** Result returned from a template's generate function */
|