@ahoo-wang/wow-generator 10.0.0-alpha.7 → 10.0.0-beta.2

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.
Files changed (71) hide show
  1. package/README.md +7 -4
  2. package/README.zh-CN.md +5 -3
  3. package/dist/analysis/clientNames.d.cts +0 -9
  4. package/dist/analysis/clientNames.d.ts +0 -9
  5. package/dist/cli.cjs +1 -1
  6. package/dist/cli.cjs.map +1 -1
  7. package/dist/cli.js +2 -2
  8. package/dist/{codeGenerator-Bouc_Ad8.js → codeGenerator-CXowDsB9.js} +1216 -842
  9. package/dist/codeGenerator-CXowDsB9.js.map +1 -0
  10. package/dist/codeGenerator-q59QJpfT.cjs +38 -0
  11. package/dist/codeGenerator-q59QJpfT.cjs.map +1 -0
  12. package/dist/emitters/manifest/aggregate.d.cts +4 -0
  13. package/dist/emitters/manifest/aggregate.d.ts +4 -0
  14. package/dist/emitters/manifest/commandClient.d.cts +4 -0
  15. package/dist/emitters/manifest/commandClient.d.ts +4 -0
  16. package/dist/emitters/manifest/contextClient.d.cts +8 -0
  17. package/dist/emitters/manifest/contextClient.d.ts +8 -0
  18. package/dist/emitters/manifest/contract.d.cts +17 -0
  19. package/dist/emitters/manifest/contract.d.ts +17 -0
  20. package/dist/emitters/manifest/generatedModule.d.cts +19 -0
  21. package/dist/emitters/manifest/generatedModule.d.ts +19 -0
  22. package/dist/emitters/manifest/queryClient.d.cts +4 -0
  23. package/dist/emitters/manifest/queryClient.d.ts +4 -0
  24. package/dist/emitters/manifest/routing.d.cts +9 -0
  25. package/dist/emitters/manifest/routing.d.ts +9 -0
  26. package/dist/emitters/manifest/serviceRoutes.d.cts +11 -0
  27. package/dist/emitters/manifest/serviceRoutes.d.ts +11 -0
  28. package/dist/emitters/manifest/textNumbers.d.cts +24 -0
  29. package/dist/emitters/manifest/textNumbers.d.ts +24 -0
  30. package/dist/emitters/manifest/typeDeclarations.d.cts +4 -0
  31. package/dist/emitters/manifest/typeDeclarations.d.ts +4 -0
  32. package/dist/emitters/manifestClients.d.cts +1 -5
  33. package/dist/emitters/manifestClients.d.ts +1 -5
  34. package/dist/emitters/models.d.cts +1 -1
  35. package/dist/emitters/models.d.ts +1 -1
  36. package/dist/emitters/target.d.cts +1 -1
  37. package/dist/emitters/target.d.ts +1 -1
  38. package/dist/index.cjs +1 -1
  39. package/dist/index.js +1 -1
  40. package/dist/manifest/aggregates.d.cts +6 -0
  41. package/dist/manifest/aggregates.d.ts +6 -0
  42. package/dist/manifest/analyze.d.cts +1 -176
  43. package/dist/manifest/analyze.d.ts +1 -176
  44. package/dist/manifest/document.d.cts +4 -0
  45. package/dist/manifest/document.d.ts +4 -0
  46. package/dist/manifest/model.d.cts +180 -0
  47. package/dist/manifest/model.d.ts +180 -0
  48. package/dist/manifest/names.d.cts +30 -0
  49. package/dist/manifest/names.d.ts +30 -0
  50. package/dist/manifest/schemaTypes.d.cts +46 -0
  51. package/dist/manifest/schemaTypes.d.ts +46 -0
  52. package/dist/manifest/serviceRoutes.d.cts +45 -0
  53. package/dist/manifest/serviceRoutes.d.ts +45 -0
  54. package/dist/manifest/textNumbers.d.cts +108 -0
  55. package/dist/manifest/textNumbers.d.ts +108 -0
  56. package/dist/manifest/typeText.d.cts +11 -0
  57. package/dist/manifest/typeText.d.ts +11 -0
  58. package/dist/naming/naming.d.cts +9 -0
  59. package/dist/naming/naming.d.ts +9 -0
  60. package/dist/types/indexSignature.d.cts +18 -0
  61. package/dist/types/indexSignature.d.ts +18 -0
  62. package/dist/types/literalTypes.d.cts +11 -0
  63. package/dist/types/literalTypes.d.ts +11 -0
  64. package/dist/types/typeContext.d.cts +66 -0
  65. package/dist/types/typeContext.d.ts +66 -0
  66. package/dist/types/typeResolver.d.cts +2 -101
  67. package/dist/types/typeResolver.d.ts +2 -101
  68. package/package.json +14 -6
  69. package/dist/codeGenerator-Bouc_Ad8.js.map +0 -1
  70. package/dist/codeGenerator-C0dKAKl6.cjs +0 -37
  71. package/dist/codeGenerator-C0dKAKl6.cjs.map +0 -1
@@ -1,105 +1,6 @@
1
- import { Components, Reference, Schema } from '@ahoo-wang/fetcher-openapi';
2
- import { ModelInfo } from '../naming/modelInfo.cjs';
1
+ import { Reference, Schema } from '@ahoo-wang/fetcher-openapi';
3
2
  import { MapSchema } from '../openapi/schemas.cjs';
4
- /**
5
- * Schema → TypeScript type expression, as pure functions.
6
- *
7
- * Every entry point takes a schema and a {@link TypeScope} - where the type
8
- * is written - and returns a {@link ResolvedType}: the type's text, and the
9
- * imports the module needs for it. Nothing is written; the caller applies the
10
- * imports to its module (`ImportRegistry.apply`) before it resolves the next
11
- * type, so a later reference sees the names and aliases an earlier one took.
12
- */
13
- /** An import a resolved type needs: a name, and the alias it goes by. */
14
- export interface ImportRequest {
15
- readonly moduleSpecifier: string;
16
- readonly name: string;
17
- readonly alias?: string;
18
- }
19
- /** A type expression, and the imports it needs. */
20
- export interface ResolvedType {
21
- readonly text: string;
22
- readonly imports: readonly ImportRequest[];
23
- }
24
- /** The imports a module already holds, as the resolver reads them. */
25
- export interface ImportLookup {
26
- entries(): readonly ImportRequest[];
27
- }
28
- /**
29
- * What stays the same for every type of one document: its components, how a
30
- * component names its model, and the model names declared at each path.
31
- */
32
- export interface TypeContext {
33
- readonly components?: Components;
34
- /** The model a reference names. */
35
- modelOf(reference: Reference): ModelInfo;
36
- /** The models declared at a path, with their `EnumText` companions. */
37
- namesAt(path: string): readonly string[];
38
- }
39
- /**
40
- * How a document's component keys name models: `resolveModelInfo` and
41
- * `resolveReferenceModelInfo` of `analysis/modelInfo.ts`.
42
- */
43
- export interface ModelNaming {
44
- ofKey(key: string): ModelInfo;
45
- ofReference(reference: Reference, components?: Components): ModelInfo;
46
- }
47
- /**
48
- * Builds the context of a document. The model names of each path are read
49
- * once, on first use, rather than from every component for every reference.
50
- */
51
- export declare function createTypeContext(components: Components | undefined, naming: ModelNaming): TypeContext;
52
- /** Where a type is written. */
53
- export interface TypeScope {
54
- readonly context: TypeContext;
55
- /**
56
- * The declaration the type belongs to. An import never takes its name.
57
- * With a `path`, it is a model: the models of that path are declared beside
58
- * it, so a reference to one needs no import, and an import takes none of
59
- * their names. Without, every referenced model is imported.
60
- */
61
- readonly owner: {
62
- readonly name: string;
63
- readonly path?: string;
64
- };
65
- /** The specifier the module imports a model by. */
66
- specifierOf(model: ModelInfo): string;
67
- /** The imports the module holds. */
68
- readonly imports: ImportLookup;
69
- }
70
- /**
71
- * Global names generated code relies on. A model imported under one of these
72
- * names would shadow the global, so the import is aliased instead: a model
73
- * named `Response` must not turn `Promise<Response>` into a promise of the
74
- * model.
75
- */
76
- export declare const GLOBAL_TYPE_NAMES: readonly string[];
77
- /**
78
- * Chooses the intersection representation over an interface with an index
79
- * signature.
80
- *
81
- * An interface may only carry a named property whose type is assignable to
82
- * its index signature (TS2411). Every generated property is required, so
83
- * only a clash that can be PROVEN off the schemas moves one - see
84
- * {@link clashesWithIndexSignature}. Anything undecided keeps the interface,
85
- * which is the only form that can reference itself through an index
86
- * signature: an alias reaching itself through `Record` is circular (TS2456),
87
- * which is what a dictionary of its own type would generate.
88
- *
89
- * @param schema - The object schema to represent
90
- * @param components - The components a reference resolves against
91
- * @returns True when the schema needs the intersection form
92
- */
93
- export declare function requiresAdditionalPropertiesIntersection(schema: Schema, components?: Components): boolean;
94
- /**
95
- * Renders a JSON value as a TypeScript literal type: a string in single
96
- * quotes, escaped as ts-morph's printer escapes it, an array as a tuple, an
97
- * object as an object type that no array matches.
98
- *
99
- * @param value - The value from the document
100
- * @returns The literal type
101
- */
102
- export declare function resolveLiteral(value: unknown): string;
3
+ import { ResolvedType, TypeScope } from './typeContext.cjs';
103
4
  /**
104
5
  * The type a schema generates.
105
6
  *
@@ -1,105 +1,6 @@
1
- import { Components, Reference, Schema } from '@ahoo-wang/fetcher-openapi';
2
- import { ModelInfo } from '../naming/modelInfo.js';
1
+ import { Reference, Schema } from '@ahoo-wang/fetcher-openapi';
3
2
  import { MapSchema } from '../openapi/schemas.js';
4
- /**
5
- * Schema → TypeScript type expression, as pure functions.
6
- *
7
- * Every entry point takes a schema and a {@link TypeScope} - where the type
8
- * is written - and returns a {@link ResolvedType}: the type's text, and the
9
- * imports the module needs for it. Nothing is written; the caller applies the
10
- * imports to its module (`ImportRegistry.apply`) before it resolves the next
11
- * type, so a later reference sees the names and aliases an earlier one took.
12
- */
13
- /** An import a resolved type needs: a name, and the alias it goes by. */
14
- export interface ImportRequest {
15
- readonly moduleSpecifier: string;
16
- readonly name: string;
17
- readonly alias?: string;
18
- }
19
- /** A type expression, and the imports it needs. */
20
- export interface ResolvedType {
21
- readonly text: string;
22
- readonly imports: readonly ImportRequest[];
23
- }
24
- /** The imports a module already holds, as the resolver reads them. */
25
- export interface ImportLookup {
26
- entries(): readonly ImportRequest[];
27
- }
28
- /**
29
- * What stays the same for every type of one document: its components, how a
30
- * component names its model, and the model names declared at each path.
31
- */
32
- export interface TypeContext {
33
- readonly components?: Components;
34
- /** The model a reference names. */
35
- modelOf(reference: Reference): ModelInfo;
36
- /** The models declared at a path, with their `EnumText` companions. */
37
- namesAt(path: string): readonly string[];
38
- }
39
- /**
40
- * How a document's component keys name models: `resolveModelInfo` and
41
- * `resolveReferenceModelInfo` of `analysis/modelInfo.ts`.
42
- */
43
- export interface ModelNaming {
44
- ofKey(key: string): ModelInfo;
45
- ofReference(reference: Reference, components?: Components): ModelInfo;
46
- }
47
- /**
48
- * Builds the context of a document. The model names of each path are read
49
- * once, on first use, rather than from every component for every reference.
50
- */
51
- export declare function createTypeContext(components: Components | undefined, naming: ModelNaming): TypeContext;
52
- /** Where a type is written. */
53
- export interface TypeScope {
54
- readonly context: TypeContext;
55
- /**
56
- * The declaration the type belongs to. An import never takes its name.
57
- * With a `path`, it is a model: the models of that path are declared beside
58
- * it, so a reference to one needs no import, and an import takes none of
59
- * their names. Without, every referenced model is imported.
60
- */
61
- readonly owner: {
62
- readonly name: string;
63
- readonly path?: string;
64
- };
65
- /** The specifier the module imports a model by. */
66
- specifierOf(model: ModelInfo): string;
67
- /** The imports the module holds. */
68
- readonly imports: ImportLookup;
69
- }
70
- /**
71
- * Global names generated code relies on. A model imported under one of these
72
- * names would shadow the global, so the import is aliased instead: a model
73
- * named `Response` must not turn `Promise<Response>` into a promise of the
74
- * model.
75
- */
76
- export declare const GLOBAL_TYPE_NAMES: readonly string[];
77
- /**
78
- * Chooses the intersection representation over an interface with an index
79
- * signature.
80
- *
81
- * An interface may only carry a named property whose type is assignable to
82
- * its index signature (TS2411). Every generated property is required, so
83
- * only a clash that can be PROVEN off the schemas moves one - see
84
- * {@link clashesWithIndexSignature}. Anything undecided keeps the interface,
85
- * which is the only form that can reference itself through an index
86
- * signature: an alias reaching itself through `Record` is circular (TS2456),
87
- * which is what a dictionary of its own type would generate.
88
- *
89
- * @param schema - The object schema to represent
90
- * @param components - The components a reference resolves against
91
- * @returns True when the schema needs the intersection form
92
- */
93
- export declare function requiresAdditionalPropertiesIntersection(schema: Schema, components?: Components): boolean;
94
- /**
95
- * Renders a JSON value as a TypeScript literal type: a string in single
96
- * quotes, escaped as ts-morph's printer escapes it, an array as a tuple, an
97
- * object as an object type that no array matches.
98
- *
99
- * @param value - The value from the document
100
- * @returns The literal type
101
- */
102
- export declare function resolveLiteral(value: unknown): string;
3
+ import { ResolvedType, TypeScope } from './typeContext.js';
103
4
  /**
104
5
  * The type a schema generates.
105
6
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ahoo-wang/wow-generator",
3
- "version": "10.0.0-alpha.7",
3
+ "version": "10.0.0-beta.2",
4
4
  "description": "Generates the typed TypeScript clients of a Wow service from its Manifest, and TypeScript models and Fetcher decorator clients from any OpenAPI 3 document (https://github.com/Ahoo-Wang/Wow).",
5
5
  "keywords": [
6
6
  "wow",
@@ -64,7 +64,15 @@
64
64
  "@ahoo-wang/fetcher": "^5.1.5 || ^6.0.0",
65
65
  "@ahoo-wang/fetcher-decorator": "^5.1.5 || ^6.0.0",
66
66
  "@ahoo-wang/fetcher-eventstream": "^5.1.5 || ^6.0.0",
67
- "@ahoo-wang/wow-client": "~10.0.0-alpha.7"
67
+ "@ahoo-wang/wow-client": "~10.0.0-beta.2"
68
+ },
69
+ "peerDependenciesMeta": {
70
+ "@ahoo-wang/fetcher-decorator": {
71
+ "optional": true
72
+ },
73
+ "@ahoo-wang/fetcher-eventstream": {
74
+ "optional": true
75
+ }
68
76
  },
69
77
  "dependencies": {
70
78
  "ts-morph": "^28.0.0",
@@ -77,20 +85,20 @@
77
85
  "@ahoo-wang/fetcher-eventstream": "^6.0.1",
78
86
  "@ahoo-wang/fetcher-openapi": "^6.0.1",
79
87
  "@eslint/js": "^10.0.1",
80
- "@types/node": "^26.6.5",
88
+ "@types/node": "^26.6.6",
81
89
  "@vitest/coverage-v8": "4.1.12",
82
90
  "@vitest/ui": "^4.1.12",
83
- "eslint": "^10.13.0",
91
+ "eslint": "^10.14.0",
84
92
  "eslint-plugin-import-x": "^4.17.1",
85
93
  "globals": "^17.13.0",
86
94
  "prettier": "3.9.10",
87
95
  "typescript": "~6.0.3",
88
- "typescript-eslint": "^8.72.0",
96
+ "typescript-eslint": "^8.72.1",
89
97
  "unplugin-dts": "1.1.2",
90
98
  "vite": "8.3.5",
91
99
  "vite-bundle-analyzer": "^1.3.9",
92
100
  "vitest": "^4.1.12",
93
- "@ahoo-wang/wow-client": "~10.0.0-alpha.7"
101
+ "@ahoo-wang/wow-client": "~10.0.0-beta.2"
94
102
  },
95
103
  "scripts": {
96
104
  "build": "vite build && pnpm test:package",