create-auto-app 0.8.4 → 0.8.5
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 +1 -1
- package/templates/shopping-app/package.json +3 -1
- package/templates/shopping-app/server/package.json +2 -1
- package/templates/shopping-app/server/src/integrations/index.ts +1 -1
- package/templates/shopping-app/server/src/integrations/product-catalogue/generated/product-catalog/client/client.gen.ts +199 -0
- package/templates/shopping-app/server/src/integrations/product-catalogue/generated/product-catalog/client/index.ts +25 -0
- package/templates/shopping-app/server/src/integrations/product-catalogue/generated/product-catalog/client/types.gen.ts +232 -0
- package/templates/shopping-app/server/src/integrations/product-catalogue/generated/product-catalog/client/utils.gen.ts +419 -0
- package/templates/shopping-app/server/src/integrations/product-catalogue/generated/product-catalog/client.gen.ts +18 -0
- package/templates/shopping-app/server/src/integrations/product-catalogue/generated/product-catalog/core/auth.gen.ts +42 -0
- package/templates/shopping-app/server/src/integrations/product-catalogue/generated/product-catalog/core/bodySerializer.gen.ts +92 -0
- package/templates/shopping-app/server/src/integrations/product-catalogue/generated/product-catalog/core/params.gen.ts +153 -0
- package/templates/shopping-app/server/src/integrations/product-catalogue/generated/product-catalog/core/pathSerializer.gen.ts +181 -0
- package/templates/shopping-app/server/src/integrations/product-catalogue/generated/product-catalog/core/types.gen.ts +120 -0
- package/templates/shopping-app/server/src/integrations/product-catalogue/generated/product-catalog/index.ts +2 -0
- package/templates/shopping-app/server/src/integrations/product-catalogue/generated/product-catalog/types.gen.ts +133 -0
- package/templates/shopping-app/server/src/integrations/product-catalogue/generated/product-catalog/zod.gen.ts +62 -0
- package/templates/shopping-app/server/src/integrations/product-catalogue/index.ts +1 -0
- package/templates/shopping-app/server/src/integrations/product-catalogue/product-catalogue-integration.ts +232 -0
- package/templates/shopping-app/server/src/integrations/product-catalogue-integration.ts +0 -363
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
+
|
|
3
|
+
type Slot = 'body' | 'headers' | 'path' | 'query';
|
|
4
|
+
|
|
5
|
+
export type Field =
|
|
6
|
+
| {
|
|
7
|
+
in: Exclude<Slot, 'body'>;
|
|
8
|
+
/**
|
|
9
|
+
* Field name. This is the name we want the user to see and use.
|
|
10
|
+
*/
|
|
11
|
+
key: string;
|
|
12
|
+
/**
|
|
13
|
+
* Field mapped name. This is the name we want to use in the request.
|
|
14
|
+
* If omitted, we use the same value as `key`.
|
|
15
|
+
*/
|
|
16
|
+
map?: string;
|
|
17
|
+
}
|
|
18
|
+
| {
|
|
19
|
+
in: Extract<Slot, 'body'>;
|
|
20
|
+
/**
|
|
21
|
+
* Key isn't required for bodies.
|
|
22
|
+
*/
|
|
23
|
+
key?: string;
|
|
24
|
+
map?: string;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export interface Fields {
|
|
28
|
+
allowExtra?: Partial<Record<Slot, boolean>>;
|
|
29
|
+
args?: ReadonlyArray<Field>;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export type FieldsConfig = ReadonlyArray<Field | Fields>;
|
|
33
|
+
|
|
34
|
+
const extraPrefixesMap: Record<string, Slot> = {
|
|
35
|
+
$body_: 'body',
|
|
36
|
+
$headers_: 'headers',
|
|
37
|
+
$path_: 'path',
|
|
38
|
+
$query_: 'query',
|
|
39
|
+
};
|
|
40
|
+
const extraPrefixes = Object.entries(extraPrefixesMap);
|
|
41
|
+
|
|
42
|
+
type KeyMap = Map<
|
|
43
|
+
string,
|
|
44
|
+
{
|
|
45
|
+
in: Slot;
|
|
46
|
+
map?: string;
|
|
47
|
+
}
|
|
48
|
+
>;
|
|
49
|
+
|
|
50
|
+
const buildKeyMap = (fields: FieldsConfig, map?: KeyMap): KeyMap => {
|
|
51
|
+
if (!map) {
|
|
52
|
+
map = new Map();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
for (const config of fields) {
|
|
56
|
+
if ('in' in config) {
|
|
57
|
+
if (config.key) {
|
|
58
|
+
map.set(config.key, {
|
|
59
|
+
in: config.in,
|
|
60
|
+
map: config.map,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
} else if (config.args) {
|
|
64
|
+
buildKeyMap(config.args, map);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return map;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
interface Params {
|
|
72
|
+
body: unknown;
|
|
73
|
+
headers: Record<string, unknown>;
|
|
74
|
+
path: Record<string, unknown>;
|
|
75
|
+
query: Record<string, unknown>;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const stripEmptySlots = (params: Params) => {
|
|
79
|
+
for (const [slot, value] of Object.entries(params)) {
|
|
80
|
+
if (value && typeof value === 'object' && !Object.keys(value).length) {
|
|
81
|
+
delete params[slot as Slot];
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export const buildClientParams = (
|
|
87
|
+
args: ReadonlyArray<unknown>,
|
|
88
|
+
fields: FieldsConfig,
|
|
89
|
+
) => {
|
|
90
|
+
const params: Params = {
|
|
91
|
+
body: {},
|
|
92
|
+
headers: {},
|
|
93
|
+
path: {},
|
|
94
|
+
query: {},
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
const map = buildKeyMap(fields);
|
|
98
|
+
|
|
99
|
+
let config: FieldsConfig[number] | undefined;
|
|
100
|
+
|
|
101
|
+
for (const [index, arg] of args.entries()) {
|
|
102
|
+
if (fields[index]) {
|
|
103
|
+
config = fields[index];
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (!config) {
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if ('in' in config) {
|
|
111
|
+
if (config.key) {
|
|
112
|
+
const field = map.get(config.key)!;
|
|
113
|
+
const name = field.map || config.key;
|
|
114
|
+
(params[field.in] as Record<string, unknown>)[name] = arg;
|
|
115
|
+
} else {
|
|
116
|
+
params.body = arg;
|
|
117
|
+
}
|
|
118
|
+
} else {
|
|
119
|
+
for (const [key, value] of Object.entries(arg ?? {})) {
|
|
120
|
+
const field = map.get(key);
|
|
121
|
+
|
|
122
|
+
if (field) {
|
|
123
|
+
const name = field.map || key;
|
|
124
|
+
(params[field.in] as Record<string, unknown>)[name] = value;
|
|
125
|
+
} else {
|
|
126
|
+
const extra = extraPrefixes.find(([prefix]) =>
|
|
127
|
+
key.startsWith(prefix),
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
if (extra) {
|
|
131
|
+
const [prefix, slot] = extra;
|
|
132
|
+
(params[slot] as Record<string, unknown>)[
|
|
133
|
+
key.slice(prefix.length)
|
|
134
|
+
] = value;
|
|
135
|
+
} else {
|
|
136
|
+
for (const [slot, allowed] of Object.entries(
|
|
137
|
+
config.allowExtra ?? {},
|
|
138
|
+
)) {
|
|
139
|
+
if (allowed) {
|
|
140
|
+
(params[slot as Slot] as Record<string, unknown>)[key] = value;
|
|
141
|
+
break;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
stripEmptySlots(params);
|
|
151
|
+
|
|
152
|
+
return params;
|
|
153
|
+
};
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
+
|
|
3
|
+
interface SerializeOptions<T>
|
|
4
|
+
extends SerializePrimitiveOptions,
|
|
5
|
+
SerializerOptions<T> {}
|
|
6
|
+
|
|
7
|
+
interface SerializePrimitiveOptions {
|
|
8
|
+
allowReserved?: boolean;
|
|
9
|
+
name: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface SerializerOptions<T> {
|
|
13
|
+
/**
|
|
14
|
+
* @default true
|
|
15
|
+
*/
|
|
16
|
+
explode: boolean;
|
|
17
|
+
style: T;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited';
|
|
21
|
+
export type ArraySeparatorStyle = ArrayStyle | MatrixStyle;
|
|
22
|
+
type MatrixStyle = 'label' | 'matrix' | 'simple';
|
|
23
|
+
export type ObjectStyle = 'form' | 'deepObject';
|
|
24
|
+
type ObjectSeparatorStyle = ObjectStyle | MatrixStyle;
|
|
25
|
+
|
|
26
|
+
interface SerializePrimitiveParam extends SerializePrimitiveOptions {
|
|
27
|
+
value: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const separatorArrayExplode = (style: ArraySeparatorStyle) => {
|
|
31
|
+
switch (style) {
|
|
32
|
+
case 'label':
|
|
33
|
+
return '.';
|
|
34
|
+
case 'matrix':
|
|
35
|
+
return ';';
|
|
36
|
+
case 'simple':
|
|
37
|
+
return ',';
|
|
38
|
+
default:
|
|
39
|
+
return '&';
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export const separatorArrayNoExplode = (style: ArraySeparatorStyle) => {
|
|
44
|
+
switch (style) {
|
|
45
|
+
case 'form':
|
|
46
|
+
return ',';
|
|
47
|
+
case 'pipeDelimited':
|
|
48
|
+
return '|';
|
|
49
|
+
case 'spaceDelimited':
|
|
50
|
+
return '%20';
|
|
51
|
+
default:
|
|
52
|
+
return ',';
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export const separatorObjectExplode = (style: ObjectSeparatorStyle) => {
|
|
57
|
+
switch (style) {
|
|
58
|
+
case 'label':
|
|
59
|
+
return '.';
|
|
60
|
+
case 'matrix':
|
|
61
|
+
return ';';
|
|
62
|
+
case 'simple':
|
|
63
|
+
return ',';
|
|
64
|
+
default:
|
|
65
|
+
return '&';
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export const serializeArrayParam = ({
|
|
70
|
+
allowReserved,
|
|
71
|
+
explode,
|
|
72
|
+
name,
|
|
73
|
+
style,
|
|
74
|
+
value,
|
|
75
|
+
}: SerializeOptions<ArraySeparatorStyle> & {
|
|
76
|
+
value: unknown[];
|
|
77
|
+
}) => {
|
|
78
|
+
if (!explode) {
|
|
79
|
+
const joinedValues = (
|
|
80
|
+
allowReserved ? value : value.map((v) => encodeURIComponent(v as string))
|
|
81
|
+
).join(separatorArrayNoExplode(style));
|
|
82
|
+
switch (style) {
|
|
83
|
+
case 'label':
|
|
84
|
+
return `.${joinedValues}`;
|
|
85
|
+
case 'matrix':
|
|
86
|
+
return `;${name}=${joinedValues}`;
|
|
87
|
+
case 'simple':
|
|
88
|
+
return joinedValues;
|
|
89
|
+
default:
|
|
90
|
+
return `${name}=${joinedValues}`;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const separator = separatorArrayExplode(style);
|
|
95
|
+
const joinedValues = value
|
|
96
|
+
.map((v) => {
|
|
97
|
+
if (style === 'label' || style === 'simple') {
|
|
98
|
+
return allowReserved ? v : encodeURIComponent(v as string);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return serializePrimitiveParam({
|
|
102
|
+
allowReserved,
|
|
103
|
+
name,
|
|
104
|
+
value: v as string,
|
|
105
|
+
});
|
|
106
|
+
})
|
|
107
|
+
.join(separator);
|
|
108
|
+
return style === 'label' || style === 'matrix'
|
|
109
|
+
? separator + joinedValues
|
|
110
|
+
: joinedValues;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
export const serializePrimitiveParam = ({
|
|
114
|
+
allowReserved,
|
|
115
|
+
name,
|
|
116
|
+
value,
|
|
117
|
+
}: SerializePrimitiveParam) => {
|
|
118
|
+
if (value === undefined || value === null) {
|
|
119
|
+
return '';
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (typeof value === 'object') {
|
|
123
|
+
throw new Error(
|
|
124
|
+
'Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.',
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
export const serializeObjectParam = ({
|
|
132
|
+
allowReserved,
|
|
133
|
+
explode,
|
|
134
|
+
name,
|
|
135
|
+
style,
|
|
136
|
+
value,
|
|
137
|
+
valueOnly,
|
|
138
|
+
}: SerializeOptions<ObjectSeparatorStyle> & {
|
|
139
|
+
value: Record<string, unknown> | Date;
|
|
140
|
+
valueOnly?: boolean;
|
|
141
|
+
}) => {
|
|
142
|
+
if (value instanceof Date) {
|
|
143
|
+
return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (style !== 'deepObject' && !explode) {
|
|
147
|
+
let values: string[] = [];
|
|
148
|
+
Object.entries(value).forEach(([key, v]) => {
|
|
149
|
+
values = [
|
|
150
|
+
...values,
|
|
151
|
+
key,
|
|
152
|
+
allowReserved ? (v as string) : encodeURIComponent(v as string),
|
|
153
|
+
];
|
|
154
|
+
});
|
|
155
|
+
const joinedValues = values.join(',');
|
|
156
|
+
switch (style) {
|
|
157
|
+
case 'form':
|
|
158
|
+
return `${name}=${joinedValues}`;
|
|
159
|
+
case 'label':
|
|
160
|
+
return `.${joinedValues}`;
|
|
161
|
+
case 'matrix':
|
|
162
|
+
return `;${name}=${joinedValues}`;
|
|
163
|
+
default:
|
|
164
|
+
return joinedValues;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const separator = separatorObjectExplode(style);
|
|
169
|
+
const joinedValues = Object.entries(value)
|
|
170
|
+
.map(([key, v]) =>
|
|
171
|
+
serializePrimitiveParam({
|
|
172
|
+
allowReserved,
|
|
173
|
+
name: style === 'deepObject' ? `${name}[${key}]` : key,
|
|
174
|
+
value: v as string,
|
|
175
|
+
}),
|
|
176
|
+
)
|
|
177
|
+
.join(separator);
|
|
178
|
+
return style === 'label' || style === 'matrix'
|
|
179
|
+
? separator + joinedValues
|
|
180
|
+
: joinedValues;
|
|
181
|
+
};
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
+
|
|
3
|
+
import type { Auth, AuthToken } from './auth.gen';
|
|
4
|
+
import type {
|
|
5
|
+
BodySerializer,
|
|
6
|
+
QuerySerializer,
|
|
7
|
+
QuerySerializerOptions,
|
|
8
|
+
} from './bodySerializer.gen';
|
|
9
|
+
|
|
10
|
+
export interface Client<
|
|
11
|
+
RequestFn = never,
|
|
12
|
+
Config = unknown,
|
|
13
|
+
MethodFn = never,
|
|
14
|
+
BuildUrlFn = never,
|
|
15
|
+
> {
|
|
16
|
+
/**
|
|
17
|
+
* Returns the final request URL.
|
|
18
|
+
*/
|
|
19
|
+
buildUrl: BuildUrlFn;
|
|
20
|
+
connect: MethodFn;
|
|
21
|
+
delete: MethodFn;
|
|
22
|
+
get: MethodFn;
|
|
23
|
+
getConfig: () => Config;
|
|
24
|
+
head: MethodFn;
|
|
25
|
+
options: MethodFn;
|
|
26
|
+
patch: MethodFn;
|
|
27
|
+
post: MethodFn;
|
|
28
|
+
put: MethodFn;
|
|
29
|
+
request: RequestFn;
|
|
30
|
+
setConfig: (config: Config) => Config;
|
|
31
|
+
trace: MethodFn;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface Config {
|
|
35
|
+
/**
|
|
36
|
+
* Auth token or a function returning auth token. The resolved value will be
|
|
37
|
+
* added to the request payload as defined by its `security` array.
|
|
38
|
+
*/
|
|
39
|
+
auth?: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken;
|
|
40
|
+
/**
|
|
41
|
+
* A function for serializing request body parameter. By default,
|
|
42
|
+
* {@link JSON.stringify()} will be used.
|
|
43
|
+
*/
|
|
44
|
+
bodySerializer?: BodySerializer | null;
|
|
45
|
+
/**
|
|
46
|
+
* An object containing any HTTP headers that you want to pre-populate your
|
|
47
|
+
* `Headers` object with.
|
|
48
|
+
*
|
|
49
|
+
* {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more}
|
|
50
|
+
*/
|
|
51
|
+
headers?:
|
|
52
|
+
| RequestInit['headers']
|
|
53
|
+
| Record<
|
|
54
|
+
string,
|
|
55
|
+
| string
|
|
56
|
+
| number
|
|
57
|
+
| boolean
|
|
58
|
+
| (string | number | boolean)[]
|
|
59
|
+
| null
|
|
60
|
+
| undefined
|
|
61
|
+
| unknown
|
|
62
|
+
>;
|
|
63
|
+
/**
|
|
64
|
+
* The request method.
|
|
65
|
+
*
|
|
66
|
+
* {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more}
|
|
67
|
+
*/
|
|
68
|
+
method?:
|
|
69
|
+
| 'CONNECT'
|
|
70
|
+
| 'DELETE'
|
|
71
|
+
| 'GET'
|
|
72
|
+
| 'HEAD'
|
|
73
|
+
| 'OPTIONS'
|
|
74
|
+
| 'PATCH'
|
|
75
|
+
| 'POST'
|
|
76
|
+
| 'PUT'
|
|
77
|
+
| 'TRACE';
|
|
78
|
+
/**
|
|
79
|
+
* A function for serializing request query parameters. By default, arrays
|
|
80
|
+
* will be exploded in form style, objects will be exploded in deepObject
|
|
81
|
+
* style, and reserved characters are percent-encoded.
|
|
82
|
+
*
|
|
83
|
+
* This method will have no effect if the native `paramsSerializer()` Axios
|
|
84
|
+
* API function is used.
|
|
85
|
+
*
|
|
86
|
+
* {@link https://swagger.io/docs/specification/serialization/#query View examples}
|
|
87
|
+
*/
|
|
88
|
+
querySerializer?: QuerySerializer | QuerySerializerOptions;
|
|
89
|
+
/**
|
|
90
|
+
* A function validating request data. This is useful if you want to ensure
|
|
91
|
+
* the request conforms to the desired shape, so it can be safely sent to
|
|
92
|
+
* the server.
|
|
93
|
+
*/
|
|
94
|
+
requestValidator?: (data: unknown) => Promise<unknown>;
|
|
95
|
+
/**
|
|
96
|
+
* A function transforming response data before it's returned. This is useful
|
|
97
|
+
* for post-processing data, e.g. converting ISO strings into Date objects.
|
|
98
|
+
*/
|
|
99
|
+
responseTransformer?: (data: unknown) => Promise<unknown>;
|
|
100
|
+
/**
|
|
101
|
+
* A function validating response data. This is useful if you want to ensure
|
|
102
|
+
* the response conforms to the desired shape, so it can be safely passed to
|
|
103
|
+
* the transformers and returned to the user.
|
|
104
|
+
*/
|
|
105
|
+
responseValidator?: (data: unknown) => Promise<unknown>;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
type IsExactlyNeverOrNeverUndefined<T> = [T] extends [never]
|
|
109
|
+
? true
|
|
110
|
+
: [T] extends [never | undefined]
|
|
111
|
+
? [undefined] extends [T]
|
|
112
|
+
? false
|
|
113
|
+
: true
|
|
114
|
+
: false;
|
|
115
|
+
|
|
116
|
+
export type OmitNever<T extends Record<string, unknown>> = {
|
|
117
|
+
[K in keyof T as IsExactlyNeverOrNeverUndefined<T[K]> extends true
|
|
118
|
+
? never
|
|
119
|
+
: K]: T[K];
|
|
120
|
+
};
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
+
|
|
3
|
+
export type ProductCatalogItem = {
|
|
4
|
+
/**
|
|
5
|
+
* Unique identifier for the product
|
|
6
|
+
*/
|
|
7
|
+
productId: string;
|
|
8
|
+
/**
|
|
9
|
+
* Product name
|
|
10
|
+
*/
|
|
11
|
+
name: string;
|
|
12
|
+
/**
|
|
13
|
+
* Product category
|
|
14
|
+
*/
|
|
15
|
+
category: string;
|
|
16
|
+
/**
|
|
17
|
+
* Product price in dollars
|
|
18
|
+
*/
|
|
19
|
+
price: number;
|
|
20
|
+
/**
|
|
21
|
+
* Array of tags associated with the product
|
|
22
|
+
*/
|
|
23
|
+
tags: Array<string>;
|
|
24
|
+
/**
|
|
25
|
+
* URL of the product image
|
|
26
|
+
*/
|
|
27
|
+
imageUrl: string;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export type GetApiProductsData = {
|
|
31
|
+
body?: never;
|
|
32
|
+
path?: never;
|
|
33
|
+
query?: never;
|
|
34
|
+
url: '/api/products';
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export type GetApiProductsResponses = {
|
|
38
|
+
/**
|
|
39
|
+
* List of all products
|
|
40
|
+
*/
|
|
41
|
+
200: Array<ProductCatalogItem>;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export type GetApiProductsResponse = GetApiProductsResponses[keyof GetApiProductsResponses];
|
|
45
|
+
|
|
46
|
+
export type GetApiProductsSearchData = {
|
|
47
|
+
body?: never;
|
|
48
|
+
path?: never;
|
|
49
|
+
query: {
|
|
50
|
+
/**
|
|
51
|
+
* Search query for product name or tags
|
|
52
|
+
*/
|
|
53
|
+
q: string;
|
|
54
|
+
};
|
|
55
|
+
url: '/api/products/search';
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export type GetApiProductsSearchErrors = {
|
|
59
|
+
/**
|
|
60
|
+
* Query parameter is missing
|
|
61
|
+
*/
|
|
62
|
+
400: {
|
|
63
|
+
error?: string;
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export type GetApiProductsSearchError = GetApiProductsSearchErrors[keyof GetApiProductsSearchErrors];
|
|
68
|
+
|
|
69
|
+
export type GetApiProductsSearchResponses = {
|
|
70
|
+
/**
|
|
71
|
+
* List of matching products
|
|
72
|
+
*/
|
|
73
|
+
200: Array<ProductCatalogItem>;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export type GetApiProductsSearchResponse = GetApiProductsSearchResponses[keyof GetApiProductsSearchResponses];
|
|
77
|
+
|
|
78
|
+
export type GetApiProductsCategoryByCategoryData = {
|
|
79
|
+
body?: never;
|
|
80
|
+
path: {
|
|
81
|
+
/**
|
|
82
|
+
* Category name to filter by
|
|
83
|
+
*/
|
|
84
|
+
category: string;
|
|
85
|
+
};
|
|
86
|
+
query?: never;
|
|
87
|
+
url: '/api/products/category/{category}';
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
export type GetApiProductsCategoryByCategoryResponses = {
|
|
91
|
+
/**
|
|
92
|
+
* List of products in the category
|
|
93
|
+
*/
|
|
94
|
+
200: Array<ProductCatalogItem>;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
export type GetApiProductsCategoryByCategoryResponse = GetApiProductsCategoryByCategoryResponses[keyof GetApiProductsCategoryByCategoryResponses];
|
|
98
|
+
|
|
99
|
+
export type GetApiProductsByIdData = {
|
|
100
|
+
body?: never;
|
|
101
|
+
path: {
|
|
102
|
+
/**
|
|
103
|
+
* Product ID
|
|
104
|
+
*/
|
|
105
|
+
id: string;
|
|
106
|
+
};
|
|
107
|
+
query?: never;
|
|
108
|
+
url: '/api/products/{id}';
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
export type GetApiProductsByIdErrors = {
|
|
112
|
+
/**
|
|
113
|
+
* Product not found
|
|
114
|
+
*/
|
|
115
|
+
404: {
|
|
116
|
+
error?: string;
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
export type GetApiProductsByIdError = GetApiProductsByIdErrors[keyof GetApiProductsByIdErrors];
|
|
121
|
+
|
|
122
|
+
export type GetApiProductsByIdResponses = {
|
|
123
|
+
/**
|
|
124
|
+
* Product details
|
|
125
|
+
*/
|
|
126
|
+
200: ProductCatalogItem;
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
export type GetApiProductsByIdResponse = GetApiProductsByIdResponses[keyof GetApiProductsByIdResponses];
|
|
130
|
+
|
|
131
|
+
export type ClientOptions = {
|
|
132
|
+
baseUrl: 'http://localhost:3001' | (string & {});
|
|
133
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
+
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
|
|
5
|
+
export const zProductCatalogItem = z.object({
|
|
6
|
+
productId: z.string(),
|
|
7
|
+
name: z.string(),
|
|
8
|
+
category: z.string(),
|
|
9
|
+
price: z.number(),
|
|
10
|
+
tags: z.array(z.string()),
|
|
11
|
+
imageUrl: z.string()
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
export const zGetApiProductsData = z.object({
|
|
15
|
+
body: z.optional(z.never()),
|
|
16
|
+
path: z.optional(z.never()),
|
|
17
|
+
query: z.optional(z.never())
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* List of all products
|
|
22
|
+
*/
|
|
23
|
+
export const zGetApiProductsResponse = z.array(zProductCatalogItem);
|
|
24
|
+
|
|
25
|
+
export const zGetApiProductsSearchData = z.object({
|
|
26
|
+
body: z.optional(z.never()),
|
|
27
|
+
path: z.optional(z.never()),
|
|
28
|
+
query: z.object({
|
|
29
|
+
q: z.string()
|
|
30
|
+
})
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* List of matching products
|
|
35
|
+
*/
|
|
36
|
+
export const zGetApiProductsSearchResponse = z.array(zProductCatalogItem);
|
|
37
|
+
|
|
38
|
+
export const zGetApiProductsCategoryByCategoryData = z.object({
|
|
39
|
+
body: z.optional(z.never()),
|
|
40
|
+
path: z.object({
|
|
41
|
+
category: z.string()
|
|
42
|
+
}),
|
|
43
|
+
query: z.optional(z.never())
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* List of products in the category
|
|
48
|
+
*/
|
|
49
|
+
export const zGetApiProductsCategoryByCategoryResponse = z.array(zProductCatalogItem);
|
|
50
|
+
|
|
51
|
+
export const zGetApiProductsByIdData = z.object({
|
|
52
|
+
body: z.optional(z.never()),
|
|
53
|
+
path: z.object({
|
|
54
|
+
id: z.string()
|
|
55
|
+
}),
|
|
56
|
+
query: z.optional(z.never())
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Product details
|
|
61
|
+
*/
|
|
62
|
+
export const zGetApiProductsByIdResponse = zProductCatalogItem;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './product-catalogue-integration';
|