@ir-kit/openapi-ts-typia 0.1.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.
- package/LICENSE.md +21 -0
- package/README.md +136 -0
- package/dist/api.d.ts +22 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +24 -0
- package/dist/api.js.map +1 -0
- package/dist/config.d.ts +9 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +55 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/orpc/index.d.ts +14 -0
- package/dist/orpc/index.d.ts.map +1 -0
- package/dist/orpc/index.js +63 -0
- package/dist/orpc/index.js.map +1 -0
- package/dist/plugin.d.ts +3 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +3 -0
- package/dist/plugin.js.map +1 -0
- package/dist/shared/emit.d.ts +59 -0
- package/dist/shared/emit.d.ts.map +1 -0
- package/dist/shared/emit.js +91 -0
- package/dist/shared/emit.js.map +1 -0
- package/dist/shared/operation.d.ts +11 -0
- package/dist/shared/operation.d.ts.map +1 -0
- package/dist/shared/operation.js +72 -0
- package/dist/shared/operation.js.map +1 -0
- package/dist/shared/type-transformer.d.ts +12 -0
- package/dist/shared/type-transformer.d.ts.map +1 -0
- package/dist/shared/type-transformer.js +169 -0
- package/dist/shared/type-transformer.js.map +1 -0
- package/dist/shared/typia-tags.generated.d.ts +99 -0
- package/dist/shared/typia-tags.generated.d.ts.map +1 -0
- package/dist/shared/typia-tags.generated.js +134 -0
- package/dist/shared/typia-tags.generated.js.map +1 -0
- package/dist/types.d.ts +123 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/v1/api.d.ts +10 -0
- package/dist/v1/api.d.ts.map +1 -0
- package/dist/v1/api.js +46 -0
- package/dist/v1/api.js.map +1 -0
- package/dist/v1/plugin.d.ts +3 -0
- package/dist/v1/plugin.d.ts.map +1 -0
- package/dist/v1/plugin.js +146 -0
- package/dist/v1/plugin.js.map +1 -0
- package/package.json +92 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { $, TsDsl } from "@hey-api/openapi-ts";
|
|
2
|
+
import ts from "typescript";
|
|
3
|
+
/**
|
|
4
|
+
* Emits `Data extends { [K]: infer V } ? [V] extends [undefined] ? unknown : V : unknown`.
|
|
5
|
+
* Widens absent keys and `?: never` sections so HTTP adapters can pass `{}` / header bags
|
|
6
|
+
* without tripping strict checks. Declared schemas fall through unchanged.
|
|
7
|
+
*/
|
|
8
|
+
class HttpSectionFallbackTsDsl extends TsDsl {
|
|
9
|
+
_data;
|
|
10
|
+
_key;
|
|
11
|
+
"~dsl" = "HttpSectionFallbackTsDsl";
|
|
12
|
+
constructor(_data, _key) {
|
|
13
|
+
super();
|
|
14
|
+
this._data = _data;
|
|
15
|
+
this._key = _key;
|
|
16
|
+
}
|
|
17
|
+
toAst() {
|
|
18
|
+
const dataNode = this._data instanceof TsDsl ? this._data.toAst() : this._data;
|
|
19
|
+
const inferVar = ts.factory.createTypeParameterDeclaration(undefined, "V");
|
|
20
|
+
const inferType = ts.factory.createInferTypeNode(inferVar);
|
|
21
|
+
const unknownNode = ts.factory.createKeywordTypeNode(ts.SyntaxKind.UnknownKeyword);
|
|
22
|
+
const undefinedTuple = ts.factory.createTupleTypeNode([
|
|
23
|
+
ts.factory.createKeywordTypeNode(ts.SyntaxKind.UndefinedKeyword),
|
|
24
|
+
]);
|
|
25
|
+
const presenceShape = ts.factory.createTypeLiteralNode([
|
|
26
|
+
ts.factory.createPropertySignature(undefined, ts.factory.createStringLiteral(this._key), undefined, inferType),
|
|
27
|
+
]);
|
|
28
|
+
const vRef = ts.factory.createTypeReferenceNode("V");
|
|
29
|
+
const innerConditional = ts.factory.createConditionalTypeNode(ts.factory.createTupleTypeNode([vRef]), undefinedTuple, unknownNode, vRef);
|
|
30
|
+
return ts.factory.createConditionalTypeNode(dataNode, presenceShape, innerConditional, unknownNode);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export function queryDataTypeSymbol(plugin, operation) {
|
|
34
|
+
return plugin.querySymbol({
|
|
35
|
+
category: "type",
|
|
36
|
+
resource: "operation",
|
|
37
|
+
resourceId: operation.id,
|
|
38
|
+
role: "data",
|
|
39
|
+
tool: "typescript",
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
export function queryResponseTypeSymbol(plugin, operation) {
|
|
43
|
+
return plugin.querySymbol({
|
|
44
|
+
category: "type",
|
|
45
|
+
resource: "operation",
|
|
46
|
+
resourceId: operation.id,
|
|
47
|
+
role: "response",
|
|
48
|
+
tool: "typescript",
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
export function queryErrorsTypeSymbol(plugin, operation) {
|
|
52
|
+
return plugin.querySymbol({
|
|
53
|
+
category: "type",
|
|
54
|
+
resource: "operation",
|
|
55
|
+
resourceId: operation.id,
|
|
56
|
+
role: "errors",
|
|
57
|
+
tool: "typescript",
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
export function buildRequestInputType(dataSymbol) {
|
|
61
|
+
const omitKeys = $.type.or($.type.literal("url"), $.type.literal("path"), $.type.literal("body"), $.type.literal("query"), $.type.literal("headers"));
|
|
62
|
+
const stripped = $.type("Omit").generic($.type(dataSymbol)).generic(omitKeys);
|
|
63
|
+
const sectionFallback = (key) => new HttpSectionFallbackTsDsl($.type(dataSymbol), key);
|
|
64
|
+
const overrides = $.type
|
|
65
|
+
.object()
|
|
66
|
+
.prop("params", (p) => p.type($.type(dataSymbol).idx($.type.literal("path"))))
|
|
67
|
+
.prop("body", (p) => p.type(sectionFallback("body")))
|
|
68
|
+
.prop("query", (p) => p.type(sectionFallback("query")))
|
|
69
|
+
.prop("headers", (p) => p.type(sectionFallback("headers")));
|
|
70
|
+
return $.type.and(stripped, overrides);
|
|
71
|
+
}
|
|
72
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AAe,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IAE9D,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;AACzC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { $ } from "@hey-api/openapi-ts";
|
|
2
|
+
import type { IR } from "@hey-api/shared";
|
|
3
|
+
import ts from "typescript";
|
|
4
|
+
/**
|
|
5
|
+
* Annotates a schema's generated TypeScript type with typia constraint
|
|
6
|
+
* tag intersections. Register on `@hey-api/transformers.typeTransformers`.
|
|
7
|
+
*/
|
|
8
|
+
export declare function typiaTypeTransformer(ctx: {
|
|
9
|
+
$: typeof $;
|
|
10
|
+
schema: IR.SchemaObject;
|
|
11
|
+
}): ts.TypeNode | undefined;
|
|
12
|
+
//# sourceMappingURL=type-transformer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-transformer.d.ts","sourceRoot":"","sources":["../../src/shared/type-transformer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,MAAM,YAAY,CAAC;AAyF5B;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE;IACxC,CAAC,EAAE,OAAO,CAAC,CAAC;IACZ,MAAM,EAAE,EAAE,CAAC,YAAY,CAAC;CACzB,GAAG,EAAE,CAAC,QAAQ,GAAG,SAAS,CA+B1B"}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
import { TYPIA_FORMAT_VALUES, TYPIA_INTEGER_FORMATS, TYPIA_TAG_META, } from "./typia-tags.generated";
|
|
3
|
+
/** Tags we emit from OpenAPI constraints. `(kind, targets)` comes from `TYPIA_TAG_META`. */
|
|
4
|
+
const HANDLED_TAGS = [
|
|
5
|
+
"ExclusiveMaximum",
|
|
6
|
+
"ExclusiveMinimum",
|
|
7
|
+
"Format",
|
|
8
|
+
"MaxItems",
|
|
9
|
+
"MaxLength",
|
|
10
|
+
"Maximum",
|
|
11
|
+
"MinItems",
|
|
12
|
+
"MinLength",
|
|
13
|
+
"Minimum",
|
|
14
|
+
"MultipleOf",
|
|
15
|
+
"Pattern",
|
|
16
|
+
"Type",
|
|
17
|
+
"UniqueItems",
|
|
18
|
+
];
|
|
19
|
+
const SKIPPED_TAGS = [
|
|
20
|
+
"Constant",
|
|
21
|
+
"ContentMediaType",
|
|
22
|
+
"Default",
|
|
23
|
+
"Example",
|
|
24
|
+
"Examples",
|
|
25
|
+
"JsonSchemaPlugin",
|
|
26
|
+
"Sequence",
|
|
27
|
+
"TagBase",
|
|
28
|
+
];
|
|
29
|
+
const _tagCoverage = true;
|
|
30
|
+
void _tagCoverage;
|
|
31
|
+
const TYPIA_TO_OPENAPI_TARGET = {
|
|
32
|
+
array: ["array"],
|
|
33
|
+
bigint: ["number"],
|
|
34
|
+
number: ["number"],
|
|
35
|
+
string: ["string"],
|
|
36
|
+
};
|
|
37
|
+
const INTEGER_FORMATS = new Set(TYPIA_INTEGER_FORMATS);
|
|
38
|
+
const TYPIA_FORMATS = new Set(TYPIA_FORMAT_VALUES);
|
|
39
|
+
/** Emission plan: for each OpenAPI target, the tags that apply + their schema fields. */
|
|
40
|
+
const TAG_PLAN = (() => {
|
|
41
|
+
const plan = {
|
|
42
|
+
array: [],
|
|
43
|
+
number: [],
|
|
44
|
+
string: [],
|
|
45
|
+
};
|
|
46
|
+
for (const name of HANDLED_TAGS) {
|
|
47
|
+
const meta = TYPIA_TAG_META[name];
|
|
48
|
+
if (!meta.kind)
|
|
49
|
+
continue;
|
|
50
|
+
const apiTargets = new Set();
|
|
51
|
+
for (const typiaTarget of meta.targets) {
|
|
52
|
+
for (const mapped of TYPIA_TO_OPENAPI_TARGET[typiaTarget] ?? []) {
|
|
53
|
+
apiTargets.add(mapped);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
for (const apiTarget of apiTargets) {
|
|
57
|
+
plan[apiTarget].push({ field: meta.kind, name });
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return plan;
|
|
61
|
+
})();
|
|
62
|
+
/**
|
|
63
|
+
* Annotates a schema's generated TypeScript type with typia constraint
|
|
64
|
+
* tag intersections. Register on `@hey-api/transformers.typeTransformers`.
|
|
65
|
+
*/
|
|
66
|
+
export function typiaTypeTransformer(ctx) {
|
|
67
|
+
const { schema } = ctx;
|
|
68
|
+
if (schema.type === "string") {
|
|
69
|
+
const tagNodes = collectTags(schema, "string");
|
|
70
|
+
return tagNodes.length
|
|
71
|
+
? ts.factory.createIntersectionTypeNode([stringKeyword(), ...tagNodes])
|
|
72
|
+
: undefined;
|
|
73
|
+
}
|
|
74
|
+
if (schema.type === "integer" || schema.type === "number") {
|
|
75
|
+
const tagNodes = collectTags(schema, "number");
|
|
76
|
+
return tagNodes.length
|
|
77
|
+
? ts.factory.createIntersectionTypeNode([numberKeyword(), ...tagNodes])
|
|
78
|
+
: undefined;
|
|
79
|
+
}
|
|
80
|
+
if (schema.type === "array") {
|
|
81
|
+
const tagNodes = collectTags(schema, "array");
|
|
82
|
+
if (!tagNodes.length)
|
|
83
|
+
return;
|
|
84
|
+
const itemTypeNode = buildArrayItemType(ctx);
|
|
85
|
+
if (!itemTypeNode)
|
|
86
|
+
return;
|
|
87
|
+
return ts.factory.createIntersectionTypeNode([
|
|
88
|
+
ts.factory.createTypeReferenceNode("Array", [itemTypeNode]),
|
|
89
|
+
...tagNodes,
|
|
90
|
+
]);
|
|
91
|
+
}
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
function collectTags(schema, target) {
|
|
95
|
+
const out = [];
|
|
96
|
+
for (const { field, name } of TAG_PLAN[target]) {
|
|
97
|
+
const value = schema[field];
|
|
98
|
+
if (value == null)
|
|
99
|
+
continue;
|
|
100
|
+
if (name === "Type") {
|
|
101
|
+
if (schema.type !== "integer" ||
|
|
102
|
+
typeof value !== "string" ||
|
|
103
|
+
!INTEGER_FORMATS.has(value)) {
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
else if (name === "Format") {
|
|
108
|
+
if (typeof value !== "string")
|
|
109
|
+
continue;
|
|
110
|
+
if (INTEGER_FORMATS.has(value))
|
|
111
|
+
continue;
|
|
112
|
+
if (!TYPIA_FORMATS.has(value))
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
else if (name === "UniqueItems") {
|
|
116
|
+
if (value !== true)
|
|
117
|
+
continue;
|
|
118
|
+
out.push(buildTagNode("UniqueItems", null));
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
out.push(buildTagNode(name, value));
|
|
122
|
+
}
|
|
123
|
+
return out;
|
|
124
|
+
}
|
|
125
|
+
function buildArrayItemType(ctx) {
|
|
126
|
+
const items = ctx.schema.items;
|
|
127
|
+
if (!items || items.length === 0) {
|
|
128
|
+
return ts.factory.createKeywordTypeNode(ts.SyntaxKind.UnknownKeyword);
|
|
129
|
+
}
|
|
130
|
+
if (items.length === 1) {
|
|
131
|
+
return (typiaTypeTransformer({ ...ctx, schema: items[0] }) ??
|
|
132
|
+
primitiveToTypeNode(items[0]));
|
|
133
|
+
}
|
|
134
|
+
const mapped = items.map((item) => typiaTypeTransformer({ ...ctx, schema: item }) ??
|
|
135
|
+
primitiveToTypeNode(item));
|
|
136
|
+
return mapped.every((n) => n !== null)
|
|
137
|
+
? ts.factory.createUnionTypeNode(mapped)
|
|
138
|
+
: null;
|
|
139
|
+
}
|
|
140
|
+
function buildTagNode(tagName, value) {
|
|
141
|
+
const typeArgs = value === null
|
|
142
|
+
? undefined
|
|
143
|
+
: [
|
|
144
|
+
ts.factory.createLiteralTypeNode(typeof value === "number"
|
|
145
|
+
? ts.factory.createNumericLiteral(value)
|
|
146
|
+
: ts.factory.createStringLiteral(value)),
|
|
147
|
+
];
|
|
148
|
+
return ts.factory.createImportTypeNode(ts.factory.createLiteralTypeNode(ts.factory.createStringLiteral("typia")), undefined, ts.factory.createQualifiedName(ts.factory.createIdentifier("tags"), ts.factory.createIdentifier(tagName)), typeArgs);
|
|
149
|
+
}
|
|
150
|
+
function primitiveToTypeNode(schema) {
|
|
151
|
+
switch (schema.type) {
|
|
152
|
+
case "boolean":
|
|
153
|
+
return ts.factory.createKeywordTypeNode(ts.SyntaxKind.BooleanKeyword);
|
|
154
|
+
case "integer":
|
|
155
|
+
case "number":
|
|
156
|
+
return numberKeyword();
|
|
157
|
+
case "string":
|
|
158
|
+
return stringKeyword();
|
|
159
|
+
default:
|
|
160
|
+
return null;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
function stringKeyword() {
|
|
164
|
+
return ts.factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword);
|
|
165
|
+
}
|
|
166
|
+
function numberKeyword() {
|
|
167
|
+
return ts.factory.createKeywordTypeNode(ts.SyntaxKind.NumberKeyword);
|
|
168
|
+
}
|
|
169
|
+
//# sourceMappingURL=type-transformer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-transformer.js","sourceRoot":"","sources":["../../src/shared/type-transformer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,cAAc,GAEf,MAAM,wBAAwB,CAAC;AAIhC,4FAA4F;AAC5F,MAAM,YAAY,GAAG;IACnB,kBAAkB;IAClB,kBAAkB;IAClB,QAAQ;IACR,UAAU;IACV,WAAW;IACX,SAAS;IACT,UAAU;IACV,WAAW;IACX,SAAS;IACT,YAAY;IACZ,SAAS;IACT,MAAM;IACN,aAAa;CACiC,CAAC;AAEjD,MAAM,YAAY,GAAG;IACnB,UAAU;IACV,kBAAkB;IAClB,SAAS;IACT,SAAS;IACT,UAAU;IACV,kBAAkB;IAClB,UAAU;IACV,SAAS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gBAAgB,CAAC,MAAM,CAAC,EACnC,EAAE,CAAC,OAAO,CAAC,gBAAgB,CAAC,OAAO,CAAC,CACrC,EACD,QAAQ,CACT,CAAC;AACJ,CAAC;AAED,SAAS,mBAAmB,CAAC,MAAuB;IAClD,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;QACpB,KAAK,SAAS;YACZ,OAAO,EAAE,CAAC,OAAO,CAAC,qBAAqB,CAAC,EAAE,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC;QACxE,KAAK,SAAS,CAAC;QACf,KAAK,QAAQ;YACX,OAAO,aAAa,EAAE,CAAC;QACzB,KAAK,QAAQ;YACX,OAAO,aAAa,EAAE,CAAC;QACzB;YACE,OAAO,IAAI,CAAC;IAChB,CAAC;AACH,CAAC;AAED,SAAS,aAAa;IACpB,OAAO,EAAE,CAAC,OAAO,CAAC,qBAAqB,CAAC,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;AACvE,CAAC;AAED,SAAS,aAAa;IACpB,OAAO,EAAE,CAAC,OAAO,CAAC,qBAAqB,CAAC,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;AACvE,CAAC"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AUTO-GENERATED — do not edit.
|
|
3
|
+
* Regenerate via `pnpm sync-tags` after bumping typia.
|
|
4
|
+
*
|
|
5
|
+
* Source: @typia/interface v12.0.2
|
|
6
|
+
*/
|
|
7
|
+
export declare const TYPIA_TAGS: readonly ["Constant", "ContentMediaType", "Default", "Example", "Examples", "ExclusiveMaximum", "ExclusiveMinimum", "Format", "JsonSchemaPlugin", "MaxItems", "MaxLength", "Maximum", "MinItems", "MinLength", "Minimum", "MultipleOf", "Pattern", "Sequence", "TagBase", "Type", "UniqueItems"];
|
|
8
|
+
export declare const TYPIA_TAG_META: {
|
|
9
|
+
readonly Constant: {
|
|
10
|
+
readonly kind: null;
|
|
11
|
+
readonly targets: readonly [];
|
|
12
|
+
};
|
|
13
|
+
readonly ContentMediaType: {
|
|
14
|
+
readonly kind: "contentMediaType";
|
|
15
|
+
readonly targets: readonly ["string"];
|
|
16
|
+
};
|
|
17
|
+
readonly Default: {
|
|
18
|
+
readonly kind: "default";
|
|
19
|
+
readonly targets: readonly ["boolean", "bigint", "number", "string"];
|
|
20
|
+
};
|
|
21
|
+
readonly Example: {
|
|
22
|
+
readonly kind: "example";
|
|
23
|
+
readonly targets: readonly ["boolean", "bigint", "number", "string", "array", "object"];
|
|
24
|
+
};
|
|
25
|
+
readonly Examples: {
|
|
26
|
+
readonly kind: "examples";
|
|
27
|
+
readonly targets: readonly ["boolean", "bigint", "number", "string", "array", "object"];
|
|
28
|
+
};
|
|
29
|
+
readonly ExclusiveMaximum: {
|
|
30
|
+
readonly kind: "exclusiveMaximum";
|
|
31
|
+
readonly targets: readonly ["bigint", "number"];
|
|
32
|
+
};
|
|
33
|
+
readonly ExclusiveMinimum: {
|
|
34
|
+
readonly kind: "exclusiveMinimum";
|
|
35
|
+
readonly targets: readonly ["bigint", "number"];
|
|
36
|
+
};
|
|
37
|
+
readonly Format: {
|
|
38
|
+
readonly kind: "format";
|
|
39
|
+
readonly targets: readonly ["string"];
|
|
40
|
+
};
|
|
41
|
+
readonly JsonSchemaPlugin: {
|
|
42
|
+
readonly kind: "jsonPlugin";
|
|
43
|
+
readonly targets: readonly ["string", "boolean", "bigint", "number", "array", "object"];
|
|
44
|
+
};
|
|
45
|
+
readonly MaxItems: {
|
|
46
|
+
readonly kind: "maxItems";
|
|
47
|
+
readonly targets: readonly ["array"];
|
|
48
|
+
};
|
|
49
|
+
readonly MaxLength: {
|
|
50
|
+
readonly kind: "maxLength";
|
|
51
|
+
readonly targets: readonly ["string"];
|
|
52
|
+
};
|
|
53
|
+
readonly Maximum: {
|
|
54
|
+
readonly kind: "maximum";
|
|
55
|
+
readonly targets: readonly ["bigint", "number"];
|
|
56
|
+
};
|
|
57
|
+
readonly MinItems: {
|
|
58
|
+
readonly kind: "minItems";
|
|
59
|
+
readonly targets: readonly ["array"];
|
|
60
|
+
};
|
|
61
|
+
readonly MinLength: {
|
|
62
|
+
readonly kind: "minLength";
|
|
63
|
+
readonly targets: readonly ["string"];
|
|
64
|
+
};
|
|
65
|
+
readonly Minimum: {
|
|
66
|
+
readonly kind: "minimum";
|
|
67
|
+
readonly targets: readonly ["bigint", "number"];
|
|
68
|
+
};
|
|
69
|
+
readonly MultipleOf: {
|
|
70
|
+
readonly kind: "multipleOf";
|
|
71
|
+
readonly targets: readonly ["bigint", "number"];
|
|
72
|
+
};
|
|
73
|
+
readonly Pattern: {
|
|
74
|
+
readonly kind: "pattern";
|
|
75
|
+
readonly targets: readonly ["string"];
|
|
76
|
+
};
|
|
77
|
+
readonly Sequence: {
|
|
78
|
+
readonly kind: "sequence";
|
|
79
|
+
readonly targets: readonly ["boolean", "bigint", "number", "string", "array", "object"];
|
|
80
|
+
};
|
|
81
|
+
readonly TagBase: {
|
|
82
|
+
readonly kind: null;
|
|
83
|
+
readonly targets: readonly [];
|
|
84
|
+
};
|
|
85
|
+
readonly Type: {
|
|
86
|
+
readonly kind: "type";
|
|
87
|
+
readonly targets: readonly ["bigint", "number"];
|
|
88
|
+
};
|
|
89
|
+
readonly UniqueItems: {
|
|
90
|
+
readonly kind: "uniqueItems";
|
|
91
|
+
readonly targets: readonly ["array"];
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
export declare const TYPIA_FORMAT_VALUES: readonly ["byte", "password", "regex", "uuid", "email", "hostname", "idn-email", "idn-hostname", "iri", "iri-reference", "ipv4", "ipv6", "uri", "uri-reference", "uri-template", "url", "date-time", "date", "time", "duration", "json-pointer", "relative-json-pointer"];
|
|
95
|
+
export declare const TYPIA_INTEGER_FORMATS: readonly ["int32", "uint32", "int64", "uint64", "float", "double"];
|
|
96
|
+
export type TypiaTagName = (typeof TYPIA_TAGS)[number];
|
|
97
|
+
export type TypiaFormatValue = (typeof TYPIA_FORMAT_VALUES)[number];
|
|
98
|
+
export type TypiaIntegerFormat = (typeof TYPIA_INTEGER_FORMATS)[number];
|
|
99
|
+
//# sourceMappingURL=typia-tags.generated.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typia-tags.generated.d.ts","sourceRoot":"","sources":["../../src/shared/typia-tags.generated.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,UAAU,kSAsBb,CAAC;AAEX,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuEjB,CAAC;AAEX,eAAO,MAAM,mBAAmB,2QAuBtB,CAAC;AAEX,eAAO,MAAM,qBAAqB,oEAOxB,CAAC;AAEX,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC;AACvD,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,CAAC,CAAC;AACpE,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,qBAAqB,CAAC,CAAC,MAAM,CAAC,CAAC"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AUTO-GENERATED — do not edit.
|
|
3
|
+
* Regenerate via `pnpm sync-tags` after bumping typia.
|
|
4
|
+
*
|
|
5
|
+
* Source: @typia/interface v12.0.2
|
|
6
|
+
*/
|
|
7
|
+
export const TYPIA_TAGS = [
|
|
8
|
+
"Constant",
|
|
9
|
+
"ContentMediaType",
|
|
10
|
+
"Default",
|
|
11
|
+
"Example",
|
|
12
|
+
"Examples",
|
|
13
|
+
"ExclusiveMaximum",
|
|
14
|
+
"ExclusiveMinimum",
|
|
15
|
+
"Format",
|
|
16
|
+
"JsonSchemaPlugin",
|
|
17
|
+
"MaxItems",
|
|
18
|
+
"MaxLength",
|
|
19
|
+
"Maximum",
|
|
20
|
+
"MinItems",
|
|
21
|
+
"MinLength",
|
|
22
|
+
"Minimum",
|
|
23
|
+
"MultipleOf",
|
|
24
|
+
"Pattern",
|
|
25
|
+
"Sequence",
|
|
26
|
+
"TagBase",
|
|
27
|
+
"Type",
|
|
28
|
+
"UniqueItems",
|
|
29
|
+
];
|
|
30
|
+
export const TYPIA_TAG_META = {
|
|
31
|
+
Constant: { kind: null, targets: [] },
|
|
32
|
+
ContentMediaType: { kind: "contentMediaType", targets: ["string"] },
|
|
33
|
+
Default: {
|
|
34
|
+
kind: "default",
|
|
35
|
+
targets: ["boolean", "bigint", "number", "string"],
|
|
36
|
+
},
|
|
37
|
+
Example: {
|
|
38
|
+
kind: "example",
|
|
39
|
+
targets: [
|
|
40
|
+
"boolean",
|
|
41
|
+
"bigint",
|
|
42
|
+
"number",
|
|
43
|
+
"string",
|
|
44
|
+
"array",
|
|
45
|
+
"object",
|
|
46
|
+
],
|
|
47
|
+
},
|
|
48
|
+
Examples: {
|
|
49
|
+
kind: "examples",
|
|
50
|
+
targets: [
|
|
51
|
+
"boolean",
|
|
52
|
+
"bigint",
|
|
53
|
+
"number",
|
|
54
|
+
"string",
|
|
55
|
+
"array",
|
|
56
|
+
"object",
|
|
57
|
+
],
|
|
58
|
+
},
|
|
59
|
+
ExclusiveMaximum: {
|
|
60
|
+
kind: "exclusiveMaximum",
|
|
61
|
+
targets: ["bigint", "number"],
|
|
62
|
+
},
|
|
63
|
+
ExclusiveMinimum: {
|
|
64
|
+
kind: "exclusiveMinimum",
|
|
65
|
+
targets: ["bigint", "number"],
|
|
66
|
+
},
|
|
67
|
+
Format: { kind: "format", targets: ["string"] },
|
|
68
|
+
JsonSchemaPlugin: {
|
|
69
|
+
kind: "jsonPlugin",
|
|
70
|
+
targets: [
|
|
71
|
+
"string",
|
|
72
|
+
"boolean",
|
|
73
|
+
"bigint",
|
|
74
|
+
"number",
|
|
75
|
+
"array",
|
|
76
|
+
"object",
|
|
77
|
+
],
|
|
78
|
+
},
|
|
79
|
+
MaxItems: { kind: "maxItems", targets: ["array"] },
|
|
80
|
+
MaxLength: { kind: "maxLength", targets: ["string"] },
|
|
81
|
+
Maximum: { kind: "maximum", targets: ["bigint", "number"] },
|
|
82
|
+
MinItems: { kind: "minItems", targets: ["array"] },
|
|
83
|
+
MinLength: { kind: "minLength", targets: ["string"] },
|
|
84
|
+
Minimum: { kind: "minimum", targets: ["bigint", "number"] },
|
|
85
|
+
MultipleOf: { kind: "multipleOf", targets: ["bigint", "number"] },
|
|
86
|
+
Pattern: { kind: "pattern", targets: ["string"] },
|
|
87
|
+
Sequence: {
|
|
88
|
+
kind: "sequence",
|
|
89
|
+
targets: [
|
|
90
|
+
"boolean",
|
|
91
|
+
"bigint",
|
|
92
|
+
"number",
|
|
93
|
+
"string",
|
|
94
|
+
"array",
|
|
95
|
+
"object",
|
|
96
|
+
],
|
|
97
|
+
},
|
|
98
|
+
TagBase: { kind: null, targets: [] },
|
|
99
|
+
Type: { kind: "type", targets: ["bigint", "number"] },
|
|
100
|
+
UniqueItems: { kind: "uniqueItems", targets: ["array"] },
|
|
101
|
+
};
|
|
102
|
+
export const TYPIA_FORMAT_VALUES = [
|
|
103
|
+
"byte",
|
|
104
|
+
"password",
|
|
105
|
+
"regex",
|
|
106
|
+
"uuid",
|
|
107
|
+
"email",
|
|
108
|
+
"hostname",
|
|
109
|
+
"idn-email",
|
|
110
|
+
"idn-hostname",
|
|
111
|
+
"iri",
|
|
112
|
+
"iri-reference",
|
|
113
|
+
"ipv4",
|
|
114
|
+
"ipv6",
|
|
115
|
+
"uri",
|
|
116
|
+
"uri-reference",
|
|
117
|
+
"uri-template",
|
|
118
|
+
"url",
|
|
119
|
+
"date-time",
|
|
120
|
+
"date",
|
|
121
|
+
"time",
|
|
122
|
+
"duration",
|
|
123
|
+
"json-pointer",
|
|
124
|
+
"relative-json-pointer",
|
|
125
|
+
];
|
|
126
|
+
export const TYPIA_INTEGER_FORMATS = [
|
|
127
|
+
"int32",
|
|
128
|
+
"uint32",
|
|
129
|
+
"int64",
|
|
130
|
+
"uint64",
|
|
131
|
+
"float",
|
|
132
|
+
"double",
|
|
133
|
+
];
|
|
134
|
+
//# sourceMappingURL=typia-tags.generated.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typia-tags.generated.js","sourceRoot":"","sources":["../../src/shared/typia-tags.generated.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,UAAU;IACV,kBAAkB;IAClB,SAAS;IACT,SAAS;IACT,UAAU;IACV,kBAAkB;IAClB,kBAAkB;IAClB,QAAQ;IACR,kBAAkB;IAClB,UAAU;IACV,WAAW;IACX,SAAS;IACT,UAAU;IACV,WAAW;IACX,SAAS;IACT,YAAY;IACZ,SAAS;IACT,UAAU;IACV,SAAS;IACT,MAAM;IACN,aAAa;CACL,CAAC;AAEX,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,QAAQ,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,EAAW,EAAE;IAC9C,gBAAgB,EAAE,EAAE,IAAI,EAAE,kBAAkB,EAAE,OAAO,EAAE,CAAC,QAAQ,CAAU,EAAE;IAC5E,OAAO,EAAE;QACP,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,CAAC,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAU;KAC5D;IACD,OAAO,EAAE;QACP,IAAI,EAAE,SAAS;QACf,OAAO,EAAE;YACP,SAAS;YACT,QAAQ;YACR,QAAQ;YACR,QAAQ;YACR,OAAO;YACP,QAAQ;SACA;KACX;IACD,QAAQ,EAAE;QACR,IAAI,EAAE,UAAU;QAChB,OAAO,EAAE;YACP,SAAS;YACT,QAAQ;YACR,QAAQ;YACR,QAAQ;YACR,OAAO;YACP,QAAQ;SACA;KACX;IACD,gBAAgB,EAAE;QAChB,IAAI,EAAE,kBAAkB;QACxB,OAAO,EAAE,CAAC,QAAQ,E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,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,EAAW,EAAE;IAC7C,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAU,EAAE;IAC9D,WAAW,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,CAAC,OAAO,CAAU,EAAE;CACzD,CAAC;AAEX,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,MAAM;IACN,UAAU;IACV,OAAO;IACP,MAAM;IACN,OAAO;IACP,UAAU;IACV,WAAW;IACX,cAAc;IACd,KAAK;IACL,eAAe;IACf,MAAM;IACN,MAAM;IACN,KAAK;IACL,eAAe;IACf,cAAc;IACd,KAAK;IACL,WAAW;IACX,MAAM;IACN,MAAM;IACN,UAAU;IACV,cAAc;IACd,uBAAuB;CACf,CAAC;AAEX,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,OAAO;IACP,QAAQ;IACR,OAAO;IACP,QAAQ;IACR,OAAO;IACP,QAAQ;CACA,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import type { Casing, DefinePlugin, NameTransformer, Plugin } from "@hey-api/shared";
|
|
2
|
+
import type { IApi } from "./api";
|
|
3
|
+
export type UserConfig = Plugin.Hooks & Plugin.UserExports & {
|
|
4
|
+
name: "@ir-kit/openapi-ts-typia";
|
|
5
|
+
/**
|
|
6
|
+
* Casing convention for generated names.
|
|
7
|
+
*
|
|
8
|
+
* @default 'camelCase'
|
|
9
|
+
*/
|
|
10
|
+
case?: Casing;
|
|
11
|
+
/**
|
|
12
|
+
* Generate JSDoc comments on emitted validators from OpenAPI
|
|
13
|
+
* summary/description.
|
|
14
|
+
*
|
|
15
|
+
* @default true
|
|
16
|
+
*/
|
|
17
|
+
comments?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Emit JSON Schema companions alongside the Standard Schema
|
|
20
|
+
* validators. One `typia.json.schemas<[T1, T2, ...]>()` call per
|
|
21
|
+
* output file shares the components pool across operations.
|
|
22
|
+
*
|
|
23
|
+
* Disable for pure-server setups that don't need OpenAPI spec
|
|
24
|
+
* generation.
|
|
25
|
+
*
|
|
26
|
+
* @default true
|
|
27
|
+
*/
|
|
28
|
+
jsonSchema?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Configuration for per-operation request validators.
|
|
31
|
+
*
|
|
32
|
+
* Can be:
|
|
33
|
+
* - `boolean`: Shorthand for `{ enabled: boolean }`
|
|
34
|
+
* - `string` or `function`: Shorthand for `{ name: string | function }`
|
|
35
|
+
* - `object`: Full configuration object
|
|
36
|
+
*
|
|
37
|
+
* @default true
|
|
38
|
+
*/
|
|
39
|
+
requests?: boolean | NameTransformer | {
|
|
40
|
+
/**
|
|
41
|
+
* Casing convention for generated names.
|
|
42
|
+
*
|
|
43
|
+
* @default 'camelCase'
|
|
44
|
+
*/
|
|
45
|
+
case?: Casing;
|
|
46
|
+
/**
|
|
47
|
+
* Whether this feature is enabled.
|
|
48
|
+
*
|
|
49
|
+
* @default true
|
|
50
|
+
*/
|
|
51
|
+
enabled?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Naming pattern for the JSON Schema companion symbol.
|
|
54
|
+
* Only used when `jsonSchema: true`.
|
|
55
|
+
*
|
|
56
|
+
* @default 't{{name}}DataJsonSchema'
|
|
57
|
+
*/
|
|
58
|
+
jsonName?: NameTransformer;
|
|
59
|
+
/**
|
|
60
|
+
* Naming pattern for the validator symbol.
|
|
61
|
+
*
|
|
62
|
+
* @default 't{{name}}Data'
|
|
63
|
+
*/
|
|
64
|
+
name?: NameTransformer;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Configuration for per-operation response validators.
|
|
68
|
+
*
|
|
69
|
+
* @default true
|
|
70
|
+
*/
|
|
71
|
+
responses?: boolean | NameTransformer | {
|
|
72
|
+
/**
|
|
73
|
+
* Casing convention for generated names.
|
|
74
|
+
*
|
|
75
|
+
* @default 'camelCase'
|
|
76
|
+
*/
|
|
77
|
+
case?: Casing;
|
|
78
|
+
/**
|
|
79
|
+
* Whether this feature is enabled.
|
|
80
|
+
*
|
|
81
|
+
* @default true
|
|
82
|
+
*/
|
|
83
|
+
enabled?: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Naming pattern for the JSON Schema companion symbol.
|
|
86
|
+
* Only used when `jsonSchema: true`.
|
|
87
|
+
*
|
|
88
|
+
* @default 't{{name}}ResponseJsonSchema'
|
|
89
|
+
*/
|
|
90
|
+
jsonName?: NameTransformer;
|
|
91
|
+
/**
|
|
92
|
+
* Naming pattern for the validator symbol.
|
|
93
|
+
*
|
|
94
|
+
* @default 't{{name}}Response'
|
|
95
|
+
*/
|
|
96
|
+
name?: NameTransformer;
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
export type Config = Plugin.Hooks & Plugin.Exports & {
|
|
100
|
+
name: "@ir-kit/openapi-ts-typia";
|
|
101
|
+
case: Casing;
|
|
102
|
+
comments: boolean;
|
|
103
|
+
jsonSchema: boolean;
|
|
104
|
+
requests: {
|
|
105
|
+
case: Casing;
|
|
106
|
+
enabled: boolean;
|
|
107
|
+
jsonName: NameTransformer;
|
|
108
|
+
name: NameTransformer;
|
|
109
|
+
};
|
|
110
|
+
responses: {
|
|
111
|
+
case: Casing;
|
|
112
|
+
enabled: boolean;
|
|
113
|
+
jsonName: NameTransformer;
|
|
114
|
+
name: NameTransformer;
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
export type TypiaPlugin = DefinePlugin<UserConfig, Config, IApi>;
|
|
118
|
+
declare module "@hey-api/openapi-ts" {
|
|
119
|
+
interface PluginConfigMap {
|
|
120
|
+
"@ir-kit/openapi-ts-typia": TypiaPlugin["Types"];
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRo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ACR,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,OAAO,CAAC;QACjB,QAAQ,EAAE,eAAe,CAAC;QAC1B,IAAI,EAAE,eAAe,CAAC;KACvB,CAAC;IACF,SAAS,EAAE;QACT,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,OAAO,CAAC;QACjB,QAAQ,EAAE,eAAe,CAAC;QAC1B,IAAI,EAAE,eAAe,CAAC;KACvB,CAAC;CACH,CAAC;AAEJ,MAAM,MAAM,WAAW,GAAG,YAAY,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;AAGjE,OAAO,QAAQ,qBAAqB,CAAC;IACnC,UAAiB,eAAe;QAC9B,0BAA0B,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;KAClD;CACF"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/dist/v1/api.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Symbol } from "@hey-api/codegen-core";
|
|
2
|
+
import { $ } from "@hey-api/openapi-ts";
|
|
3
|
+
import type { IR, RequestSchemaContext } from "@hey-api/shared";
|
|
4
|
+
import type { ValidatorArgs } from "../api";
|
|
5
|
+
import type { TypiaPlugin } from "../types";
|
|
6
|
+
export declare function createRequestSchemaV1(ctx: RequestSchemaContext<TypiaPlugin["Instance"]>): Symbol | undefined;
|
|
7
|
+
export declare function createRequestValidatorV1(ctx: RequestSchemaContext<TypiaPlugin["Instance"]>): ReturnType<typeof $.func> | undefined;
|
|
8
|
+
export declare function createResponseValidatorV1({ operation, plugin, }: ValidatorArgs): ReturnType<typeof $.func> | undefined;
|
|
9
|
+
export declare function getJsonSchemaSymbolV1(plugin: TypiaPlugin["Instance"], operation: IR.OperationObject, role: "data" | "response"): Symbol | undefined;
|
|
10
|
+
//# sourceMappingURL=api.d.ts.map
|