@sqldoc/ns-codegen 0.0.4 → 0.0.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@sqldoc/ns-codegen",
4
- "version": "0.0.4",
4
+ "version": "0.0.6",
5
5
  "description": "Code generation namespace for sqldoc -- runs configurable templates against compiled Atlas schema",
6
6
  "exports": {
7
7
  ".": {
@@ -22,12 +22,12 @@
22
22
  "typecheck": "tsgo -noEmit"
23
23
  },
24
24
  "peerDependencies": {
25
- "@sqldoc/core": "0.0.3",
26
- "@sqldoc/db": "0.0.3"
25
+ "@sqldoc/core": "0.0.5",
26
+ "@sqldoc/db": "0.0.5"
27
27
  },
28
28
  "devDependencies": {
29
- "@sqldoc/core": "0.0.3",
30
- "@sqldoc/db": "0.0.3",
29
+ "@sqldoc/core": "0.0.5",
30
+ "@sqldoc/db": "0.0.5",
31
31
  "@typescript/native-preview": "latest",
32
32
  "@sqldoc/test-utils": "0.0.1"
33
33
  }
package/src/index.ts CHANGED
@@ -87,6 +87,8 @@ const plugin: NamespacePlugin = {
87
87
  output: entry.output,
88
88
  templateName,
89
89
  externalObjectNames: ctx.externalObjectNames,
90
+ stripSchemaFromName: config.stripSchemaFromName,
91
+ defaultSchema: ctx.dialect === 'postgres' ? 'public' : ctx.dialect === 'sqlite' ? 'main' : undefined,
90
92
  }
91
93
 
92
94
  const result = template.generate(templateCtx)
package/src/types.ts CHANGED
@@ -4,6 +4,8 @@ import type { AtlasRealm } from '@sqldoc/db'
4
4
  /** Config for the codegen namespace in sqldoc.config.ts namespaces.codegen */
5
5
  export interface CodegenConfig {
6
6
  templates?: TemplateEntry[]
7
+ /** When true, strip schema prefixes from generated type names. Hard error on name clashes. */
8
+ stripSchemaFromName?: boolean
7
9
  }
8
10
 
9
11
  export interface CodegenNamespaceConfig {
@@ -43,6 +45,10 @@ export interface TemplateContext<C = Record<string, unknown>> {
43
45
  templateName: string
44
46
  /** Set of object names from @external files. Templates can use this to annotate external types. */
45
47
  externalObjectNames?: Set<string>
48
+ /** When true, strip schema prefixes from generated type names. Propagated from CodegenConfig. */
49
+ stripSchemaFromName?: boolean
50
+ /** Default schema for the dialect (e.g. 'public' for postgres). Tables in this schema don't get schema-prefixed names. */
51
+ defaultSchema?: string
46
52
  }
47
53
 
48
54
  /** Result returned from a template's generate function */