@jutsustack/api-codegen 0.1.0 → 0.2.0

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 (199) hide show
  1. package/README.md +574 -141
  2. package/dist/cache/manifest.d.ts +0 -1
  3. package/dist/cache/manifest.d.ts.map +1 -1
  4. package/dist/cache/manifest.js +1 -1
  5. package/dist/cache/manifest.js.map +1 -1
  6. package/dist/cjs/cache/manifest.d.ts +34 -0
  7. package/dist/cjs/cache/manifest.js +45 -0
  8. package/dist/cjs/cli.d.ts +8 -0
  9. package/dist/cjs/cli.js +245 -0
  10. package/dist/cjs/codegen/emit-api.d.ts +6 -0
  11. package/dist/cjs/codegen/emit-api.js +108 -0
  12. package/dist/cjs/codegen/emit-bindings.d.ts +8 -0
  13. package/dist/cjs/codegen/emit-bindings.js +115 -0
  14. package/dist/cjs/codegen/emit-types.d.ts +10 -0
  15. package/dist/cjs/codegen/emit-types.js +232 -0
  16. package/dist/cjs/codegen/emit.d.ts +28 -0
  17. package/dist/cjs/codegen/emit.js +180 -0
  18. package/dist/cjs/codegen/files.d.ts +14 -0
  19. package/dist/cjs/codegen/files.js +66 -0
  20. package/dist/cjs/codegen/plan.d.ts +32 -0
  21. package/dist/cjs/codegen/plan.js +84 -0
  22. package/dist/cjs/codegen/print.d.ts +10 -0
  23. package/dist/cjs/codegen/print.js +65 -0
  24. package/dist/cjs/codegen/templates/bindings.d.ts +13 -0
  25. package/dist/cjs/codegen/templates/bindings.js +707 -0
  26. package/dist/cjs/codegen/templates/runtime.d.ts +2 -0
  27. package/dist/cjs/codegen/templates/runtime.js +1401 -0
  28. package/dist/cjs/codegen/templates/transports.d.ts +1 -0
  29. package/dist/cjs/codegen/templates/transports.js +272 -0
  30. package/dist/cjs/codegen/tsType.d.ts +15 -0
  31. package/dist/cjs/codegen/tsType.js +114 -0
  32. package/dist/cjs/collect/collect.d.ts +16 -0
  33. package/dist/cjs/collect/collect.js +472 -0
  34. package/dist/cjs/collect/naming.d.ts +25 -0
  35. package/dist/cjs/collect/naming.js +149 -0
  36. package/dist/cjs/collect/path.d.ts +10 -0
  37. package/dist/cjs/collect/path.js +67 -0
  38. package/dist/cjs/config/init.d.ts +37 -0
  39. package/dist/cjs/config/init.js +143 -0
  40. package/dist/cjs/config/load.d.ts +11 -0
  41. package/dist/cjs/config/load.js +121 -0
  42. package/dist/cjs/config/types.d.ts +88 -0
  43. package/dist/cjs/config/types.js +2 -0
  44. package/dist/cjs/config/validate.d.ts +8 -0
  45. package/dist/cjs/config/validate.js +200 -0
  46. package/dist/cjs/generate.d.ts +55 -0
  47. package/dist/cjs/generate.js +263 -0
  48. package/dist/cjs/index.d.ts +23 -0
  49. package/dist/cjs/index.js +48 -0
  50. package/dist/cjs/model/collection.d.ts +83 -0
  51. package/dist/cjs/model/collection.js +16 -0
  52. package/dist/cjs/model/infer.d.ts +7 -0
  53. package/dist/cjs/model/infer.js +95 -0
  54. package/dist/cjs/model/merge.d.ts +3 -0
  55. package/dist/cjs/model/merge.js +131 -0
  56. package/dist/cjs/model/reserved.d.ts +2 -0
  57. package/dist/cjs/model/reserved.js +128 -0
  58. package/dist/cjs/model/schema.d.ts +54 -0
  59. package/dist/cjs/model/schema.js +2 -0
  60. package/dist/cjs/package.json +1 -0
  61. package/dist/cjs/parsers/openapi-schema.d.ts +30 -0
  62. package/dist/cjs/parsers/openapi-schema.js +241 -0
  63. package/dist/cjs/parsers/openapi.d.ts +8 -0
  64. package/dist/cjs/parsers/openapi.js +435 -0
  65. package/dist/cjs/parsers/postman.d.ts +20 -0
  66. package/dist/cjs/parsers/postman.js +493 -0
  67. package/dist/cjs/parsers/types.d.ts +52 -0
  68. package/dist/cjs/parsers/types.js +2 -0
  69. package/dist/cjs/sources/load.d.ts +25 -0
  70. package/dist/cjs/sources/load.js +296 -0
  71. package/dist/cjs/sources/parse.d.ts +4 -0
  72. package/dist/cjs/sources/parse.js +50 -0
  73. package/dist/cjs/util/errors.d.ts +9 -0
  74. package/dist/cjs/util/errors.js +23 -0
  75. package/dist/cjs/util/fs.d.ts +7 -0
  76. package/dist/cjs/util/fs.js +44 -0
  77. package/dist/cjs/util/hash.d.ts +3 -0
  78. package/dist/cjs/util/hash.js +26 -0
  79. package/dist/cjs/util/json.d.ts +10 -0
  80. package/dist/cjs/util/json.js +31 -0
  81. package/dist/cjs/util/log.d.ts +22 -0
  82. package/dist/cjs/util/log.js +45 -0
  83. package/dist/cjs/version.d.ts +2 -0
  84. package/dist/cjs/version.js +6 -0
  85. package/dist/cli.d.ts +3 -1
  86. package/dist/cli.d.ts.map +1 -1
  87. package/dist/cli.js +42 -12
  88. package/dist/cli.js.map +1 -1
  89. package/dist/codegen/emit-api.d.ts +3 -1
  90. package/dist/codegen/emit-api.d.ts.map +1 -1
  91. package/dist/codegen/emit-api.js +32 -7
  92. package/dist/codegen/emit-api.js.map +1 -1
  93. package/dist/codegen/emit-bindings.d.ts +9 -0
  94. package/dist/codegen/emit-bindings.d.ts.map +1 -0
  95. package/dist/codegen/emit-bindings.js +112 -0
  96. package/dist/codegen/emit-bindings.js.map +1 -0
  97. package/dist/codegen/emit-types.d.ts +8 -1
  98. package/dist/codegen/emit-types.d.ts.map +1 -1
  99. package/dist/codegen/emit-types.js +10 -8
  100. package/dist/codegen/emit-types.js.map +1 -1
  101. package/dist/codegen/emit.d.ts +10 -1
  102. package/dist/codegen/emit.d.ts.map +1 -1
  103. package/dist/codegen/emit.js +142 -37
  104. package/dist/codegen/emit.js.map +1 -1
  105. package/dist/codegen/files.d.ts +3 -12
  106. package/dist/codegen/files.d.ts.map +1 -1
  107. package/dist/codegen/files.js +3 -12
  108. package/dist/codegen/files.js.map +1 -1
  109. package/dist/codegen/print.d.ts +1 -4
  110. package/dist/codegen/print.d.ts.map +1 -1
  111. package/dist/codegen/print.js +1 -4
  112. package/dist/codegen/print.js.map +1 -1
  113. package/dist/codegen/templates/bindings.d.ts +14 -0
  114. package/dist/codegen/templates/bindings.d.ts.map +1 -0
  115. package/dist/codegen/templates/bindings.js +705 -0
  116. package/dist/codegen/templates/bindings.js.map +1 -0
  117. package/dist/codegen/templates/runtime.d.ts +2 -1
  118. package/dist/codegen/templates/runtime.d.ts.map +1 -1
  119. package/dist/codegen/templates/runtime.js +1192 -279
  120. package/dist/codegen/templates/runtime.js.map +1 -1
  121. package/dist/codegen/templates/transports.d.ts +2 -0
  122. package/dist/codegen/templates/transports.d.ts.map +1 -0
  123. package/dist/codegen/templates/transports.js +270 -0
  124. package/dist/codegen/templates/transports.js.map +1 -0
  125. package/dist/collect/collect.d.ts +1 -11
  126. package/dist/collect/collect.d.ts.map +1 -1
  127. package/dist/collect/collect.js +21 -28
  128. package/dist/collect/collect.js.map +1 -1
  129. package/dist/collect/naming.d.ts +1 -4
  130. package/dist/collect/naming.d.ts.map +1 -1
  131. package/dist/collect/naming.js +1 -4
  132. package/dist/collect/naming.js.map +1 -1
  133. package/dist/collect/path.d.ts +2 -9
  134. package/dist/collect/path.d.ts.map +1 -1
  135. package/dist/collect/path.js +2 -9
  136. package/dist/collect/path.js.map +1 -1
  137. package/dist/config/init.d.ts +11 -2
  138. package/dist/config/init.d.ts.map +1 -1
  139. package/dist/config/init.js +55 -7
  140. package/dist/config/init.js.map +1 -1
  141. package/dist/config/load.d.ts.map +1 -1
  142. package/dist/config/load.js +26 -1
  143. package/dist/config/load.js.map +1 -1
  144. package/dist/config/types.d.ts +13 -5
  145. package/dist/config/types.d.ts.map +1 -1
  146. package/dist/config/validate.d.ts +2 -6
  147. package/dist/config/validate.d.ts.map +1 -1
  148. package/dist/config/validate.js +18 -7
  149. package/dist/config/validate.js.map +1 -1
  150. package/dist/generate.d.ts +2 -8
  151. package/dist/generate.d.ts.map +1 -1
  152. package/dist/generate.js +13 -12
  153. package/dist/generate.js.map +1 -1
  154. package/dist/index.d.ts +4 -4
  155. package/dist/index.d.ts.map +1 -1
  156. package/dist/index.js +4 -4
  157. package/dist/index.js.map +1 -1
  158. package/dist/model/infer.d.ts +2 -9
  159. package/dist/model/infer.d.ts.map +1 -1
  160. package/dist/model/infer.js +2 -9
  161. package/dist/model/infer.js.map +1 -1
  162. package/dist/model/merge.d.ts +1 -5
  163. package/dist/model/merge.d.ts.map +1 -1
  164. package/dist/model/merge.js +1 -5
  165. package/dist/model/merge.js.map +1 -1
  166. package/dist/model/reserved.d.ts +1 -4
  167. package/dist/model/reserved.d.ts.map +1 -1
  168. package/dist/model/reserved.js +63 -4
  169. package/dist/model/reserved.js.map +1 -1
  170. package/dist/model/schema.d.ts +1 -4
  171. package/dist/model/schema.d.ts.map +1 -1
  172. package/dist/parsers/openapi-schema.d.ts +1 -5
  173. package/dist/parsers/openapi-schema.d.ts.map +1 -1
  174. package/dist/parsers/openapi-schema.js +2 -5
  175. package/dist/parsers/openapi-schema.js.map +1 -1
  176. package/dist/parsers/postman.d.ts +0 -3
  177. package/dist/parsers/postman.d.ts.map +1 -1
  178. package/dist/parsers/postman.js +2 -5
  179. package/dist/parsers/postman.js.map +1 -1
  180. package/dist/sources/load.d.ts +0 -6
  181. package/dist/sources/load.d.ts.map +1 -1
  182. package/dist/sources/load.js +4 -7
  183. package/dist/sources/load.js.map +1 -1
  184. package/dist/sources/parse.d.ts +0 -2
  185. package/dist/sources/parse.d.ts.map +1 -1
  186. package/dist/sources/parse.js +1 -1
  187. package/dist/sources/parse.js.map +1 -1
  188. package/dist/version.d.ts +1 -1
  189. package/dist/version.js +1 -1
  190. package/package.json +40 -12
  191. package/schema/config.schema.json +58 -12
  192. package/dist/codegen/emit-hooks.d.ts +0 -5
  193. package/dist/codegen/emit-hooks.d.ts.map +0 -1
  194. package/dist/codegen/emit-hooks.js +0 -67
  195. package/dist/codegen/emit-hooks.js.map +0 -1
  196. package/dist/codegen/templates/hooks.d.ts +0 -11
  197. package/dist/codegen/templates/hooks.d.ts.map +0 -1
  198. package/dist/codegen/templates/hooks.js +0 -272
  199. package/dist/codegen/templates/hooks.js.map +0 -1
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HTTP_METHODS = void 0;
4
+ exports.isHttpMethod = isHttpMethod;
5
+ exports.HTTP_METHODS = [
6
+ 'GET',
7
+ 'HEAD',
8
+ 'OPTIONS',
9
+ 'POST',
10
+ 'PUT',
11
+ 'PATCH',
12
+ 'DELETE',
13
+ ];
14
+ function isHttpMethod(value) {
15
+ return exports.HTTP_METHODS.includes(value);
16
+ }
@@ -0,0 +1,7 @@
1
+ import type { Schema } from './schema.js';
2
+ /** Stand-in for a Postman `{{variable}}` in a JSON body; infers as `unknown`. */
3
+ export declare const PLACEHOLDER = "\0jutsu:placeholder";
4
+ /** Infer a schema from one example value (a Postman body or saved response). */
5
+ export declare function inferSchema(value: unknown, depth?: number): Schema;
6
+ /** Parses a Postman JSON body with `{{var}}` placeholders; undefined if it is not JSON. */
7
+ export declare function parseLooseJson(text: string): unknown;
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PLACEHOLDER = void 0;
4
+ exports.inferSchema = inferSchema;
5
+ exports.parseLooseJson = parseLooseJson;
6
+ const merge_js_1 = require("./merge.js");
7
+ /** Stand-in for a Postman `{{variable}}` in a JSON body; infers as `unknown`. */
8
+ exports.PLACEHOLDER = '\u0000jutsu:placeholder';
9
+ const MAX_DEPTH = 32;
10
+ /** Infer a schema from one example value (a Postman body or saved response). */
11
+ function inferSchema(value, depth = 0) {
12
+ if (depth > MAX_DEPTH)
13
+ return { type: 'unknown' };
14
+ // one `null` example says "nullable", not "always null": the other examples give the type
15
+ if (value === null)
16
+ return { type: 'unknown', nullable: true };
17
+ switch (typeof value) {
18
+ case 'string':
19
+ return value === exports.PLACEHOLDER ? { type: 'unknown' } : { type: 'string' };
20
+ case 'number':
21
+ return { type: Number.isInteger(value) ? 'integer' : 'number' };
22
+ case 'boolean':
23
+ return { type: 'boolean' };
24
+ case 'object': {
25
+ if (Array.isArray(value)) {
26
+ let items = { type: 'unknown' };
27
+ for (const item of value)
28
+ items = (0, merge_js_1.mergeSchemas)(items, inferSchema(item, depth + 1));
29
+ return { type: 'array', items };
30
+ }
31
+ const properties = {};
32
+ for (const [key, v] of Object.entries(value)) {
33
+ properties[key] = inferSchema(v, depth + 1);
34
+ }
35
+ return { type: 'object', properties, required: Object.keys(properties) };
36
+ }
37
+ default:
38
+ return { type: 'unknown' };
39
+ }
40
+ }
41
+ /** Parses a Postman JSON body with `{{var}}` placeholders; undefined if it is not JSON. */
42
+ function parseLooseJson(text) {
43
+ const trimmed = stripJsonComments(text).trim();
44
+ if (!trimmed)
45
+ return undefined;
46
+ const quoted = JSON.stringify(exports.PLACEHOLDER);
47
+ const replaced = trimmed
48
+ .replace(/"\{\{[^{}"]+\}\}"/g, quoted)
49
+ .replace(/\{\{[^{}"]+\}\}/g, quoted);
50
+ try {
51
+ return JSON.parse(replaced);
52
+ }
53
+ catch {
54
+ return undefined;
55
+ }
56
+ }
57
+ /** Postman allows `//` and `/* *\/` comments in raw JSON bodies. Strings are left intact. */
58
+ function stripJsonComments(text) {
59
+ if (!text.includes('/'))
60
+ return text;
61
+ let out = '';
62
+ let inString = false;
63
+ for (let i = 0; i < text.length; i++) {
64
+ const ch = text[i];
65
+ const next = text[i + 1];
66
+ if (inString) {
67
+ out += ch;
68
+ if (ch === '\\') {
69
+ out += next ?? '';
70
+ i++;
71
+ }
72
+ else if (ch === '"') {
73
+ inString = false;
74
+ }
75
+ continue;
76
+ }
77
+ if (ch === '"') {
78
+ inString = true;
79
+ out += ch;
80
+ }
81
+ else if (ch === '/' && next === '/') {
82
+ while (i < text.length && text[i] !== '\n')
83
+ i++;
84
+ out += '\n';
85
+ }
86
+ else if (ch === '/' && next === '*') {
87
+ const end = text.indexOf('*/', i + 2);
88
+ i = end === -1 ? text.length : end + 1;
89
+ }
90
+ else {
91
+ out += ch;
92
+ }
93
+ }
94
+ return out;
95
+ }
@@ -0,0 +1,3 @@
1
+ import type { Schema } from './schema.js';
2
+ /** Merges two examples of one value: objects property-wise, null as nullable, else a union. */
3
+ export declare function mergeSchemas(a: Schema, b: Schema): Schema;
@@ -0,0 +1,131 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mergeSchemas = mergeSchemas;
4
+ const hash_js_1 = require("../util/hash.js");
5
+ /** Merges two examples of one value: objects property-wise, null as nullable, else a union. */
6
+ function mergeSchemas(a, b) {
7
+ if (a.type === 'unknown')
8
+ return withMeta(b, a);
9
+ if (b.type === 'unknown')
10
+ return withMeta(a, b);
11
+ if (a.type === 'null' && b.type === 'null')
12
+ return a;
13
+ if (a.type === 'null')
14
+ return withMeta({ ...b, nullable: true }, a);
15
+ if (b.type === 'null')
16
+ return withMeta({ ...a, nullable: true }, b);
17
+ const nullable = a.nullable === true || b.nullable === true;
18
+ const merged = mergeSameFamily(a, b);
19
+ if (merged)
20
+ return withMeta(nullable ? { ...merged, nullable } : merged, b);
21
+ const members = [];
22
+ for (const s of [...flatten(a), ...flatten(b)])
23
+ addToUnion(members, s);
24
+ if (members.length === 1)
25
+ return members[0];
26
+ const union = { type: 'union', anyOf: members };
27
+ if (nullable)
28
+ union.nullable = true;
29
+ return union;
30
+ }
31
+ function flatten(s) {
32
+ if (s.type !== 'union')
33
+ return [s];
34
+ if (!s.nullable)
35
+ return s.anyOf;
36
+ return s.anyOf.map((m) => ({ ...m, nullable: true }));
37
+ }
38
+ function addToUnion(members, s) {
39
+ for (let i = 0; i < members.length; i++) {
40
+ const merged = mergeSameFamily(members[i], s);
41
+ if (merged) {
42
+ members[i] = merged;
43
+ return;
44
+ }
45
+ }
46
+ const key = (0, hash_js_1.stableStringify)(s);
47
+ if (!members.some((m) => (0, hash_js_1.stableStringify)(m) === key))
48
+ members.push(s);
49
+ }
50
+ /** Merge when both sides are the same kind of value; undefined otherwise. */
51
+ function mergeSameFamily(a, b) {
52
+ switch (a.type) {
53
+ case 'string': {
54
+ if (b.type !== 'string')
55
+ return undefined;
56
+ const out = { ...a };
57
+ if (a.enum && b.enum)
58
+ out.enum = [...new Set([...a.enum, ...b.enum])];
59
+ else
60
+ delete out.enum;
61
+ if (a.format !== b.format)
62
+ delete out.format;
63
+ return out;
64
+ }
65
+ case 'integer':
66
+ case 'number': {
67
+ if (b.type !== 'integer' && b.type !== 'number')
68
+ return undefined;
69
+ const out = {
70
+ ...a,
71
+ type: a.type === 'integer' && b.type === 'integer' ? 'integer' : 'number',
72
+ };
73
+ if (a.enum && b.enum)
74
+ out.enum = [...new Set([...a.enum, ...b.enum])];
75
+ else
76
+ delete out.enum;
77
+ return out;
78
+ }
79
+ case 'boolean': {
80
+ if (b.type !== 'boolean')
81
+ return undefined;
82
+ const out = { ...a };
83
+ delete out.enum;
84
+ return out;
85
+ }
86
+ case 'array':
87
+ return b.type === 'array'
88
+ ? { ...a, items: mergeSchemas(a.items, b.items) }
89
+ : undefined;
90
+ case 'object': {
91
+ if (b.type !== 'object')
92
+ return undefined;
93
+ const properties = {};
94
+ for (const [key, s] of Object.entries(a.properties)) {
95
+ const other = b.properties[key];
96
+ properties[key] = other ? mergeSchemas(s, other) : s;
97
+ }
98
+ for (const [key, s] of Object.entries(b.properties)) {
99
+ if (!(key in properties))
100
+ properties[key] = s;
101
+ }
102
+ const inB = new Set(b.required);
103
+ const out = {
104
+ ...a,
105
+ properties,
106
+ required: a.required.filter((k) => inB.has(k)),
107
+ };
108
+ if (a.additionalProperties === undefined &&
109
+ b.additionalProperties !== undefined) {
110
+ out.additionalProperties = b.additionalProperties;
111
+ }
112
+ return out;
113
+ }
114
+ case 'ref':
115
+ return b.type === 'ref' && a.name === b.name ? a : undefined;
116
+ case 'file':
117
+ return b.type === 'file' ? a : undefined;
118
+ default:
119
+ return undefined;
120
+ }
121
+ }
122
+ /** Keep the first known description / deprecation flag. */
123
+ function withMeta(target, other) {
124
+ if (target.description === undefined && other.description !== undefined) {
125
+ target = { ...target, description: other.description };
126
+ }
127
+ if (other.nullable && !target.nullable && target.type !== 'unknown') {
128
+ target = { ...target, nullable: true };
129
+ }
130
+ return target;
131
+ }
@@ -0,0 +1,2 @@
1
+ /** Type names generated code must not redefine (kept complete by test/reserved.test.ts). */
2
+ export declare const RESERVED_TYPE_NAMES: readonly string[];
@@ -0,0 +1,128 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RESERVED_TYPE_NAMES = void 0;
4
+ /** Type names generated code must not redefine (kept complete by test/reserved.test.ts). */
5
+ exports.RESERVED_TYPE_NAMES = [
6
+ // globals
7
+ 'Array',
8
+ 'ArrayBuffer',
9
+ 'ArrayBufferView',
10
+ 'Blob',
11
+ 'Boolean',
12
+ 'Date',
13
+ 'Error',
14
+ 'File',
15
+ 'FormData',
16
+ 'Function',
17
+ 'Map',
18
+ 'Number',
19
+ 'Object',
20
+ 'Omit',
21
+ 'Partial',
22
+ 'Pick',
23
+ 'Promise',
24
+ 'Readonly',
25
+ 'Record',
26
+ 'Required',
27
+ 'Set',
28
+ 'String',
29
+ 'Symbol',
30
+ 'Uint8Array',
31
+ 'URLSearchParams',
32
+ // runtime.ts
33
+ 'Api',
34
+ 'ApiError',
35
+ 'ApiErrorKind',
36
+ 'ApiResponse',
37
+ 'ApiTransport',
38
+ 'BinaryBody',
39
+ 'BodyEncoding',
40
+ 'CallOptions',
41
+ 'Endpoint',
42
+ 'EndpointSpec',
43
+ 'ErrorOf',
44
+ 'FetchClientConfig',
45
+ 'FetchInit',
46
+ 'FileInput',
47
+ 'HttpMethod',
48
+ 'JutsuFileInput',
49
+ 'JutsuFormData',
50
+ 'MultipartBody',
51
+ 'Query',
52
+ 'QueryValue',
53
+ 'RequestOptions',
54
+ 'ResponseKind',
55
+ // hooks.ts
56
+ 'ApiMutation',
57
+ 'ApiProvider',
58
+ 'ApiProviderProps',
59
+ 'ApiQuery',
60
+ 'MutationHookOptions',
61
+ 'MutationState',
62
+ 'MutationStatus',
63
+ 'QueryHookOptions',
64
+ 'QueryState',
65
+ 'QueryStatus',
66
+ // v0.2: runtime.ts, api.ts and the framework bindings
67
+ 'API_CONTEXT',
68
+ 'AngularHttpClientLike',
69
+ 'ApiClient',
70
+ 'ApiContext',
71
+ 'ApiContextValue',
72
+ 'ApiLogger',
73
+ 'ApiOptions',
74
+ 'ApiRequester',
75
+ 'AxiosLike',
76
+ 'ClientConfig',
77
+ 'EndpointId',
78
+ 'EndpointOptions',
79
+ 'Endpoints',
80
+ 'ErrorMessage',
81
+ 'ErrorMessages',
82
+ 'FallbackReporter',
83
+ 'Middleware',
84
+ 'HttpLibrary',
85
+ 'MiddlewareNext',
86
+ 'RawResponse',
87
+ 'ResponseHeaders',
88
+ 'FetchTransportConfig',
89
+ 'HeaderValues',
90
+ 'Input',
91
+ 'LogLevel',
92
+ 'MutationAccessors',
93
+ 'MutationComposableOptions',
94
+ 'MutationController',
95
+ 'MutationOptions',
96
+ 'MutationPrimitiveOptions',
97
+ 'MutationRefs',
98
+ 'MutationResult',
99
+ 'MutationSignalOptions',
100
+ 'MutationSignals',
101
+ 'MutationStore',
102
+ 'MutationStoreOptions',
103
+ 'NativeFile',
104
+ 'QueryAccessors',
105
+ 'QueryComposableOptions',
106
+ 'QueryController',
107
+ 'QueryOptions',
108
+ 'QueryPrimitiveOptions',
109
+ 'QueryRefs',
110
+ 'QueryResult',
111
+ 'QuerySignalOptions',
112
+ 'QuerySignals',
113
+ 'QueryStore',
114
+ 'QueryStoreOptions',
115
+ 'ReactNativeFetchLike',
116
+ 'RequestAccessors',
117
+ 'RequestMetric',
118
+ 'RequestRefs',
119
+ 'RequestSignals',
120
+ 'RequestState',
121
+ 'RequestStatus',
122
+ 'RetryOption',
123
+ 'RetryPolicy',
124
+ 'StoreInput',
125
+ 'Transport',
126
+ 'TransportRequest',
127
+ 'TransportResponse',
128
+ ];
@@ -0,0 +1,54 @@
1
+ /** The JSON-Schema subset OpenAPI schemas and Postman examples both map onto. */
2
+ export type Schema = StringSchema | NumberSchema | BooleanSchema | NullSchema | ArraySchema | ObjectSchema | RefSchema | UnionSchema | IntersectionSchema | UnknownSchema | FileSchema;
3
+ export interface SchemaBase {
4
+ description?: string;
5
+ nullable?: boolean;
6
+ deprecated?: boolean;
7
+ }
8
+ export interface StringSchema extends SchemaBase {
9
+ type: 'string';
10
+ enum?: string[];
11
+ format?: string;
12
+ }
13
+ export interface NumberSchema extends SchemaBase {
14
+ type: 'number' | 'integer';
15
+ enum?: number[];
16
+ }
17
+ export interface BooleanSchema extends SchemaBase {
18
+ type: 'boolean';
19
+ enum?: boolean[];
20
+ }
21
+ export interface NullSchema extends SchemaBase {
22
+ type: 'null';
23
+ }
24
+ export interface ArraySchema extends SchemaBase {
25
+ type: 'array';
26
+ items: Schema;
27
+ }
28
+ export interface ObjectSchema extends SchemaBase {
29
+ type: 'object';
30
+ properties: Record<string, Schema>;
31
+ required: string[];
32
+ /** `true`/absent = open, `false` = closed, schema = typed map values */
33
+ additionalProperties?: Schema | boolean;
34
+ }
35
+ /** Reference to a named model in `ApiCollection.models`. */
36
+ export interface RefSchema extends SchemaBase {
37
+ type: 'ref';
38
+ name: string;
39
+ }
40
+ export interface UnionSchema extends SchemaBase {
41
+ type: 'union';
42
+ anyOf: Schema[];
43
+ }
44
+ export interface IntersectionSchema extends SchemaBase {
45
+ type: 'intersection';
46
+ allOf: Schema[];
47
+ }
48
+ export interface UnknownSchema extends SchemaBase {
49
+ type: 'unknown';
50
+ }
51
+ /** Binary payload (file upload / download). */
52
+ export interface FileSchema extends SchemaBase {
53
+ type: 'file';
54
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ { "type": "commonjs" }
@@ -0,0 +1,30 @@
1
+ import type { Schema } from '../model/schema.js';
2
+ import type { Json } from '../util/json.js';
3
+ /** OpenAPI / Swagger schemas → {@link Schema}; model refs stay refs, cycles end as `unknown`. */
4
+ export declare class SchemaReader {
5
+ private readonly doc;
6
+ private readonly sourceId;
7
+ /** `#/components/schemas/` or `#/definitions/` */
8
+ private readonly modelPrefix;
9
+ /** original model name → generated type name */
10
+ private readonly modelNames;
11
+ private readonly warn;
12
+ private readonly resolving;
13
+ constructor(doc: Json, sourceId: string,
14
+ /** `#/components/schemas/` or `#/definitions/` */
15
+ modelPrefix: string,
16
+ /** original model name → generated type name */
17
+ modelNames: Map<string, string>, warn: (message: string) => void);
18
+ /** Follow `$ref`s on non-schema objects (parameters, request bodies, responses). */
19
+ deref(node: unknown, hops?: number): unknown;
20
+ toSchema(node: unknown, depth?: number): Schema;
21
+ private refSchema;
22
+ /** A local JSON pointer (`#/components/…`); warns about anything it cannot resolve. */
23
+ private resolve;
24
+ private allOfSchema;
25
+ /** `oneOf` / `anyOf`: a union; a `null` member makes it nullable instead. */
26
+ private choiceSchema;
27
+ private typedSchema;
28
+ private schemaOfType;
29
+ private objectSchema;
30
+ }