@crombolo/contracts 0.11.0 → 0.13.1
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/DeliveryApi.json +1365 -0
- package/generated/delivery-api.d.ts +415 -0
- package/package.json +5 -3
- package/src/spec.ts +11 -0
- package/src/types.ts +17 -0
|
@@ -0,0 +1,415 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was auto-generated by openapi-typescript.
|
|
3
|
+
* Do not make direct changes to the file.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
export interface paths {
|
|
8
|
+
"/umbraco/delivery/api/v2/content": {
|
|
9
|
+
get: operations["GetContent2.0"];
|
|
10
|
+
};
|
|
11
|
+
"/umbraco/delivery/api/v2/content/item/{id}": {
|
|
12
|
+
get: operations["GetContentItemById2.0"];
|
|
13
|
+
};
|
|
14
|
+
"/umbraco/delivery/api/v2/content/item/{path}": {
|
|
15
|
+
get: operations["GetContentItemByPath2.0"];
|
|
16
|
+
};
|
|
17
|
+
"/umbraco/delivery/api/v2/content/items": {
|
|
18
|
+
get: operations["GetContentItems2.0"];
|
|
19
|
+
};
|
|
20
|
+
"/umbraco/delivery/api/v2/media": {
|
|
21
|
+
get: operations["GetMedia2.0"];
|
|
22
|
+
};
|
|
23
|
+
"/umbraco/delivery/api/v2/media/item/{id}": {
|
|
24
|
+
get: operations["GetMediaItemById2.0"];
|
|
25
|
+
};
|
|
26
|
+
"/umbraco/delivery/api/v2/media/item/{path}": {
|
|
27
|
+
get: operations["GetMediaItemByPath2.0"];
|
|
28
|
+
};
|
|
29
|
+
"/umbraco/delivery/api/v2/media/items": {
|
|
30
|
+
get: operations["GetMediaItems2.0"];
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export type webhooks = Record<string, never>;
|
|
35
|
+
|
|
36
|
+
export interface components {
|
|
37
|
+
schemas: {
|
|
38
|
+
IApiContentResponseModel: {
|
|
39
|
+
contentType: null | string;
|
|
40
|
+
name?: null | string;
|
|
41
|
+
/** Format: date-time */
|
|
42
|
+
createDate: string;
|
|
43
|
+
/** Format: date-time */
|
|
44
|
+
updateDate: string;
|
|
45
|
+
route: components["schemas"]["IApiContentRouteModel"];
|
|
46
|
+
/** Format: uuid */
|
|
47
|
+
id: string;
|
|
48
|
+
properties: null | Record<string, never>;
|
|
49
|
+
cultures: null | {
|
|
50
|
+
[key: string]: components["schemas"]["IApiContentRouteModel"];
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
IApiContentRouteModel: {
|
|
54
|
+
path: null | string;
|
|
55
|
+
queryString?: null | string;
|
|
56
|
+
startItem: components["schemas"]["IApiContentStartItemModel"];
|
|
57
|
+
};
|
|
58
|
+
IApiContentStartItemModel: {
|
|
59
|
+
/** Format: uuid */
|
|
60
|
+
id: string;
|
|
61
|
+
path: null | string;
|
|
62
|
+
};
|
|
63
|
+
IApiMediaWithCropsResponseModel: {
|
|
64
|
+
path: null | string;
|
|
65
|
+
/** Format: date-time */
|
|
66
|
+
createDate: string;
|
|
67
|
+
/** Format: date-time */
|
|
68
|
+
updateDate: string;
|
|
69
|
+
focalPoint?: components["schemas"]["ImageFocalPointModel"];
|
|
70
|
+
crops?: null | components["schemas"]["ImageCropModel"][];
|
|
71
|
+
/** Format: uuid */
|
|
72
|
+
id: string;
|
|
73
|
+
name: null | string;
|
|
74
|
+
mediaType: null | string;
|
|
75
|
+
url: null | string;
|
|
76
|
+
extension?: null | string;
|
|
77
|
+
/** Format: int32 */
|
|
78
|
+
width?: null | number;
|
|
79
|
+
/** Format: int32 */
|
|
80
|
+
height?: null | number;
|
|
81
|
+
/** Format: int32 */
|
|
82
|
+
bytes?: null | number;
|
|
83
|
+
properties: null | Record<string, never>;
|
|
84
|
+
};
|
|
85
|
+
ImageCropCoordinatesModel: {
|
|
86
|
+
/** Format: double */
|
|
87
|
+
x1: number;
|
|
88
|
+
/** Format: double */
|
|
89
|
+
y1: number;
|
|
90
|
+
/** Format: double */
|
|
91
|
+
x2: number;
|
|
92
|
+
/** Format: double */
|
|
93
|
+
y2: number;
|
|
94
|
+
};
|
|
95
|
+
ImageCropModel: {
|
|
96
|
+
alias: null | string;
|
|
97
|
+
/** Format: int32 */
|
|
98
|
+
width: number;
|
|
99
|
+
/** Format: int32 */
|
|
100
|
+
height: number;
|
|
101
|
+
coordinates: components["schemas"]["ImageCropCoordinatesModel"];
|
|
102
|
+
};
|
|
103
|
+
ImageFocalPointModel: {
|
|
104
|
+
/** Format: double */
|
|
105
|
+
left: number;
|
|
106
|
+
/** Format: double */
|
|
107
|
+
top: number;
|
|
108
|
+
};
|
|
109
|
+
PagedIApiContentResponseModel: {
|
|
110
|
+
/** Format: int64 */
|
|
111
|
+
total: number;
|
|
112
|
+
items: components["schemas"]["IApiContentResponseModel"][];
|
|
113
|
+
};
|
|
114
|
+
PagedIApiMediaWithCropsResponseModel: {
|
|
115
|
+
/** Format: int64 */
|
|
116
|
+
total: number;
|
|
117
|
+
items: components["schemas"]["IApiMediaWithCropsResponseModel"][];
|
|
118
|
+
};
|
|
119
|
+
ProblemDetails: {
|
|
120
|
+
type?: null | string;
|
|
121
|
+
title?: null | string;
|
|
122
|
+
/** Format: int32 */
|
|
123
|
+
status?: null | number;
|
|
124
|
+
detail?: null | string;
|
|
125
|
+
instance?: null | string;
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
responses: never;
|
|
129
|
+
parameters: never;
|
|
130
|
+
requestBodies: never;
|
|
131
|
+
headers: never;
|
|
132
|
+
pathItems: never;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export type $defs = Record<string, never>;
|
|
136
|
+
|
|
137
|
+
export type external = Record<string, never>;
|
|
138
|
+
|
|
139
|
+
export interface operations {
|
|
140
|
+
|
|
141
|
+
"GetContent2.0": {
|
|
142
|
+
parameters: {
|
|
143
|
+
query?: {
|
|
144
|
+
/** @description Specifies the content items to fetch. Refer to [the documentation](https://docs.umbraco.com/umbraco-cms/reference/content-delivery-api#query-parameters) for more details on this. */
|
|
145
|
+
fetch?: string;
|
|
146
|
+
/** @description Defines how to filter the fetched content items. Refer to [the documentation](https://docs.umbraco.com/umbraco-cms/reference/content-delivery-api#query-parameters) for more details on this. */
|
|
147
|
+
filter?: string[];
|
|
148
|
+
/** @description Defines how to sort the found content items. Refer to [the documentation](https://docs.umbraco.com/umbraco-cms/reference/content-delivery-api#query-parameters) for more details on this. */
|
|
149
|
+
sort?: string[];
|
|
150
|
+
/** @description Specifies the number of found content items to skip. Use this to control pagination of the response. */
|
|
151
|
+
skip?: number;
|
|
152
|
+
/** @description Specifies the number of found content items to take. Use this to control pagination of the response. */
|
|
153
|
+
take?: number;
|
|
154
|
+
/** @description Defines the properties that should be expanded in the response. Refer to [the documentation](https://docs.umbraco.com/umbraco-cms/reference/content-delivery-api#query-parameters) for more details on this. */
|
|
155
|
+
expand?: string;
|
|
156
|
+
/** @description Explicitly defines which properties should be included in the response (by default all properties are included). Refer to [the documentation](https://docs.umbraco.com/umbraco-cms/reference/content-delivery-api#query-parameters) for more details on this. */
|
|
157
|
+
fields?: string;
|
|
158
|
+
};
|
|
159
|
+
header?: {
|
|
160
|
+
/** @description Defines the language to return. Use this when querying language variant content items. */
|
|
161
|
+
"Accept-Language"?: string;
|
|
162
|
+
/** @description Defines the segment to return. Use this when querying segment variant content items. */
|
|
163
|
+
"Accept-Segment"?: string;
|
|
164
|
+
/** @description Whether to request draft content. */
|
|
165
|
+
Preview?: boolean;
|
|
166
|
+
/** @description URL segment or GUID of a root content item. */
|
|
167
|
+
"Start-Item"?: string;
|
|
168
|
+
};
|
|
169
|
+
};
|
|
170
|
+
responses: {
|
|
171
|
+
/** @description OK */
|
|
172
|
+
200: {
|
|
173
|
+
content: {
|
|
174
|
+
"application/json": components["schemas"]["PagedIApiContentResponseModel"];
|
|
175
|
+
};
|
|
176
|
+
};
|
|
177
|
+
/** @description Bad Request */
|
|
178
|
+
400: {
|
|
179
|
+
content: {
|
|
180
|
+
"application/json": components["schemas"]["ProblemDetails"];
|
|
181
|
+
};
|
|
182
|
+
};
|
|
183
|
+
/** @description Not Found */
|
|
184
|
+
404: {
|
|
185
|
+
content: never;
|
|
186
|
+
};
|
|
187
|
+
};
|
|
188
|
+
};
|
|
189
|
+
"GetContentItemById2.0": {
|
|
190
|
+
parameters: {
|
|
191
|
+
query?: {
|
|
192
|
+
/** @description Defines the properties that should be expanded in the response. Refer to [the documentation](https://docs.umbraco.com/umbraco-cms/reference/content-delivery-api#query-parameters) for more details on this. */
|
|
193
|
+
expand?: string;
|
|
194
|
+
/** @description Explicitly defines which properties should be included in the response (by default all properties are included). Refer to [the documentation](https://docs.umbraco.com/umbraco-cms/reference/content-delivery-api#query-parameters) for more details on this. */
|
|
195
|
+
fields?: string;
|
|
196
|
+
};
|
|
197
|
+
header?: {
|
|
198
|
+
/** @description Defines the language to return. Use this when querying language variant content items. */
|
|
199
|
+
"Accept-Language"?: string;
|
|
200
|
+
/** @description Defines the segment to return. Use this when querying segment variant content items. */
|
|
201
|
+
"Accept-Segment"?: string;
|
|
202
|
+
/** @description Whether to request draft content. */
|
|
203
|
+
Preview?: boolean;
|
|
204
|
+
/** @description URL segment or GUID of a root content item. */
|
|
205
|
+
"Start-Item"?: string;
|
|
206
|
+
};
|
|
207
|
+
path: {
|
|
208
|
+
id: string;
|
|
209
|
+
};
|
|
210
|
+
};
|
|
211
|
+
responses: {
|
|
212
|
+
/** @description OK */
|
|
213
|
+
200: {
|
|
214
|
+
content: {
|
|
215
|
+
"application/json": components["schemas"]["IApiContentResponseModel"];
|
|
216
|
+
};
|
|
217
|
+
};
|
|
218
|
+
/** @description Unauthorized */
|
|
219
|
+
401: {
|
|
220
|
+
content: never;
|
|
221
|
+
};
|
|
222
|
+
/** @description Forbidden */
|
|
223
|
+
403: {
|
|
224
|
+
content: never;
|
|
225
|
+
};
|
|
226
|
+
/** @description Not Found */
|
|
227
|
+
404: {
|
|
228
|
+
content: never;
|
|
229
|
+
};
|
|
230
|
+
};
|
|
231
|
+
};
|
|
232
|
+
"GetContentItemByPath2.0": {
|
|
233
|
+
parameters: {
|
|
234
|
+
query?: {
|
|
235
|
+
/** @description Defines the properties that should be expanded in the response. Refer to [the documentation](https://docs.umbraco.com/umbraco-cms/reference/content-delivery-api#query-parameters) for more details on this. */
|
|
236
|
+
expand?: string;
|
|
237
|
+
/** @description Explicitly defines which properties should be included in the response (by default all properties are included). Refer to [the documentation](https://docs.umbraco.com/umbraco-cms/reference/content-delivery-api#query-parameters) for more details on this. */
|
|
238
|
+
fields?: string;
|
|
239
|
+
};
|
|
240
|
+
header?: {
|
|
241
|
+
/** @description Defines the language to return. Use this when querying language variant content items. */
|
|
242
|
+
"Accept-Language"?: string;
|
|
243
|
+
/** @description Defines the segment to return. Use this when querying segment variant content items. */
|
|
244
|
+
"Accept-Segment"?: string;
|
|
245
|
+
/** @description Whether to request draft content. */
|
|
246
|
+
Preview?: boolean;
|
|
247
|
+
/** @description URL segment or GUID of a root content item. */
|
|
248
|
+
"Start-Item"?: string;
|
|
249
|
+
};
|
|
250
|
+
path: {
|
|
251
|
+
path: string;
|
|
252
|
+
};
|
|
253
|
+
};
|
|
254
|
+
responses: {
|
|
255
|
+
/** @description OK */
|
|
256
|
+
200: {
|
|
257
|
+
content: {
|
|
258
|
+
"application/json": components["schemas"]["IApiContentResponseModel"];
|
|
259
|
+
};
|
|
260
|
+
};
|
|
261
|
+
/** @description Unauthorized */
|
|
262
|
+
401: {
|
|
263
|
+
content: never;
|
|
264
|
+
};
|
|
265
|
+
/** @description Forbidden */
|
|
266
|
+
403: {
|
|
267
|
+
content: never;
|
|
268
|
+
};
|
|
269
|
+
/** @description Not Found */
|
|
270
|
+
404: {
|
|
271
|
+
content: never;
|
|
272
|
+
};
|
|
273
|
+
};
|
|
274
|
+
};
|
|
275
|
+
"GetContentItems2.0": {
|
|
276
|
+
parameters: {
|
|
277
|
+
query?: {
|
|
278
|
+
id?: string[];
|
|
279
|
+
/** @description Defines the properties that should be expanded in the response. Refer to [the documentation](https://docs.umbraco.com/umbraco-cms/reference/content-delivery-api#query-parameters) for more details on this. */
|
|
280
|
+
expand?: string;
|
|
281
|
+
/** @description Explicitly defines which properties should be included in the response (by default all properties are included). Refer to [the documentation](https://docs.umbraco.com/umbraco-cms/reference/content-delivery-api#query-parameters) for more details on this. */
|
|
282
|
+
fields?: string;
|
|
283
|
+
};
|
|
284
|
+
header?: {
|
|
285
|
+
/** @description Defines the language to return. Use this when querying language variant content items. */
|
|
286
|
+
"Accept-Language"?: string;
|
|
287
|
+
/** @description Defines the segment to return. Use this when querying segment variant content items. */
|
|
288
|
+
"Accept-Segment"?: string;
|
|
289
|
+
/** @description Whether to request draft content. */
|
|
290
|
+
Preview?: boolean;
|
|
291
|
+
/** @description URL segment or GUID of a root content item. */
|
|
292
|
+
"Start-Item"?: string;
|
|
293
|
+
};
|
|
294
|
+
};
|
|
295
|
+
responses: {
|
|
296
|
+
/** @description OK */
|
|
297
|
+
200: {
|
|
298
|
+
content: {
|
|
299
|
+
"application/json": components["schemas"]["IApiContentResponseModel"][];
|
|
300
|
+
};
|
|
301
|
+
};
|
|
302
|
+
/** @description Unauthorized */
|
|
303
|
+
401: {
|
|
304
|
+
content: never;
|
|
305
|
+
};
|
|
306
|
+
/** @description Forbidden */
|
|
307
|
+
403: {
|
|
308
|
+
content: never;
|
|
309
|
+
};
|
|
310
|
+
};
|
|
311
|
+
};
|
|
312
|
+
"GetMedia2.0": {
|
|
313
|
+
parameters: {
|
|
314
|
+
query?: {
|
|
315
|
+
/** @description Specifies the media items to fetch. Refer to [the documentation](https://docs.umbraco.com/umbraco-cms/reference/content-delivery-api/media-delivery-api#query-parameters) for more details on this. */
|
|
316
|
+
fetch?: string;
|
|
317
|
+
/** @description Defines how to filter the fetched media items. Refer to [the documentation](https://docs.umbraco.com/umbraco-cms/reference/content-delivery-api/media-delivery-api#query-parameters) for more details on this. */
|
|
318
|
+
filter?: string[];
|
|
319
|
+
/** @description Defines how to sort the found media items. Refer to [the documentation](https://docs.umbraco.com/umbraco-cms/reference/content-delivery-api/media-delivery-api#query-parameters) for more details on this. */
|
|
320
|
+
sort?: string[];
|
|
321
|
+
/** @description Specifies the number of found media items to skip. Use this to control pagination of the response. */
|
|
322
|
+
skip?: number;
|
|
323
|
+
/** @description Specifies the number of found media items to take. Use this to control pagination of the response. */
|
|
324
|
+
take?: number;
|
|
325
|
+
/** @description Defines the properties that should be expanded in the response. Refer to [the documentation](https://docs.umbraco.com/umbraco-cms/reference/content-delivery-api/media-delivery-api#query-parameters) for more details on this. */
|
|
326
|
+
expand?: string;
|
|
327
|
+
/** @description Explicitly defines which properties should be included in the response (by default all properties are included). Refer to [the documentation](https://docs.umbraco.com/umbraco-cms/reference/content-delivery-api/media-delivery-api#query-parameters) for more details on this. */
|
|
328
|
+
fields?: string;
|
|
329
|
+
};
|
|
330
|
+
};
|
|
331
|
+
responses: {
|
|
332
|
+
/** @description OK */
|
|
333
|
+
200: {
|
|
334
|
+
content: {
|
|
335
|
+
"application/json": components["schemas"]["PagedIApiMediaWithCropsResponseModel"];
|
|
336
|
+
};
|
|
337
|
+
};
|
|
338
|
+
/** @description Bad Request */
|
|
339
|
+
400: {
|
|
340
|
+
content: {
|
|
341
|
+
"application/json": components["schemas"]["ProblemDetails"];
|
|
342
|
+
};
|
|
343
|
+
};
|
|
344
|
+
};
|
|
345
|
+
};
|
|
346
|
+
"GetMediaItemById2.0": {
|
|
347
|
+
parameters: {
|
|
348
|
+
query?: {
|
|
349
|
+
/** @description Defines the properties that should be expanded in the response. Refer to [the documentation](https://docs.umbraco.com/umbraco-cms/reference/content-delivery-api/media-delivery-api#query-parameters) for more details on this. */
|
|
350
|
+
expand?: string;
|
|
351
|
+
/** @description Explicitly defines which properties should be included in the response (by default all properties are included). Refer to [the documentation](https://docs.umbraco.com/umbraco-cms/reference/content-delivery-api/media-delivery-api#query-parameters) for more details on this. */
|
|
352
|
+
fields?: string;
|
|
353
|
+
};
|
|
354
|
+
path: {
|
|
355
|
+
id: string;
|
|
356
|
+
};
|
|
357
|
+
};
|
|
358
|
+
responses: {
|
|
359
|
+
/** @description OK */
|
|
360
|
+
200: {
|
|
361
|
+
content: {
|
|
362
|
+
"application/json": components["schemas"]["IApiMediaWithCropsResponseModel"];
|
|
363
|
+
};
|
|
364
|
+
};
|
|
365
|
+
/** @description Not Found */
|
|
366
|
+
404: {
|
|
367
|
+
content: never;
|
|
368
|
+
};
|
|
369
|
+
};
|
|
370
|
+
};
|
|
371
|
+
"GetMediaItemByPath2.0": {
|
|
372
|
+
parameters: {
|
|
373
|
+
query?: {
|
|
374
|
+
/** @description Defines the properties that should be expanded in the response. Refer to [the documentation](https://docs.umbraco.com/umbraco-cms/reference/content-delivery-api/media-delivery-api#query-parameters) for more details on this. */
|
|
375
|
+
expand?: string;
|
|
376
|
+
/** @description Explicitly defines which properties should be included in the response (by default all properties are included). Refer to [the documentation](https://docs.umbraco.com/umbraco-cms/reference/content-delivery-api/media-delivery-api#query-parameters) for more details on this. */
|
|
377
|
+
fields?: string;
|
|
378
|
+
};
|
|
379
|
+
path: {
|
|
380
|
+
path: string;
|
|
381
|
+
};
|
|
382
|
+
};
|
|
383
|
+
responses: {
|
|
384
|
+
/** @description OK */
|
|
385
|
+
200: {
|
|
386
|
+
content: {
|
|
387
|
+
"application/json": components["schemas"]["IApiMediaWithCropsResponseModel"];
|
|
388
|
+
};
|
|
389
|
+
};
|
|
390
|
+
/** @description Not Found */
|
|
391
|
+
404: {
|
|
392
|
+
content: never;
|
|
393
|
+
};
|
|
394
|
+
};
|
|
395
|
+
};
|
|
396
|
+
"GetMediaItems2.0": {
|
|
397
|
+
parameters: {
|
|
398
|
+
query?: {
|
|
399
|
+
id?: string[];
|
|
400
|
+
/** @description Defines the properties that should be expanded in the response. Refer to [the documentation](https://docs.umbraco.com/umbraco-cms/reference/content-delivery-api/media-delivery-api#query-parameters) for more details on this. */
|
|
401
|
+
expand?: string;
|
|
402
|
+
/** @description Explicitly defines which properties should be included in the response (by default all properties are included). Refer to [the documentation](https://docs.umbraco.com/umbraco-cms/reference/content-delivery-api/media-delivery-api#query-parameters) for more details on this. */
|
|
403
|
+
fields?: string;
|
|
404
|
+
};
|
|
405
|
+
};
|
|
406
|
+
responses: {
|
|
407
|
+
/** @description OK */
|
|
408
|
+
200: {
|
|
409
|
+
content: {
|
|
410
|
+
"application/json": components["schemas"]["IApiMediaWithCropsResponseModel"][];
|
|
411
|
+
};
|
|
412
|
+
};
|
|
413
|
+
};
|
|
414
|
+
};
|
|
415
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crombolo/contracts",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "The Umbraco Management API OpenAPI
|
|
3
|
+
"version": "0.13.1",
|
|
4
|
+
"description": "The Umbraco Management and Delivery API OpenAPI documents and the TypeScript types generated from them.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Crombolo",
|
|
7
7
|
"homepage": "https://github.com/kineco-au/crombolo-cms#readme",
|
|
@@ -19,11 +19,13 @@
|
|
|
19
19
|
"type": "module",
|
|
20
20
|
"exports": {
|
|
21
21
|
".": "./src/index.ts",
|
|
22
|
-
"./OpenApi.json": "./OpenApi.json"
|
|
22
|
+
"./OpenApi.json": "./OpenApi.json",
|
|
23
|
+
"./DeliveryApi.json": "./DeliveryApi.json"
|
|
23
24
|
},
|
|
24
25
|
"files": [
|
|
25
26
|
"src",
|
|
26
27
|
"OpenApi.json",
|
|
28
|
+
"DeliveryApi.json",
|
|
27
29
|
"generated",
|
|
28
30
|
"NOTICE"
|
|
29
31
|
],
|
package/src/spec.ts
CHANGED
|
@@ -4,6 +4,9 @@ import { join } from 'node:path'
|
|
|
4
4
|
|
|
5
5
|
export const SPEC_PATH = join(import.meta.dir, '../OpenApi.json')
|
|
6
6
|
|
|
7
|
+
/** Umbraco's Delivery API at release-18.2.0: its generic contract (story 050). */
|
|
8
|
+
export const DELIVERY_SPEC_PATH = join(import.meta.dir, '../DeliveryApi.json')
|
|
9
|
+
|
|
7
10
|
export const HTTP_METHODS = ['get', 'post', 'put', 'delete', 'patch'] as const
|
|
8
11
|
export type HttpMethod = (typeof HTTP_METHODS)[number]
|
|
9
12
|
|
|
@@ -43,6 +46,14 @@ export function loadSpec(): OpenApiSpec {
|
|
|
43
46
|
return cached
|
|
44
47
|
}
|
|
45
48
|
|
|
49
|
+
let deliveryCached: OpenApiSpec | undefined
|
|
50
|
+
|
|
51
|
+
export function loadDeliverySpec(): OpenApiSpec {
|
|
52
|
+
if (!deliveryCached)
|
|
53
|
+
deliveryCached = JSON.parse(readFileSync(DELIVERY_SPEC_PATH, 'utf8')) as OpenApiSpec
|
|
54
|
+
return deliveryCached
|
|
55
|
+
}
|
|
56
|
+
|
|
46
57
|
export async function loadSpecAsync(): Promise<OpenApiSpec> {
|
|
47
58
|
if (!cached) cached = (await Bun.file(SPEC_PATH).json()) as OpenApiSpec
|
|
48
59
|
return cached
|
package/src/types.ts
CHANGED
|
@@ -35,3 +35,20 @@ export type RequestOf<K extends OperationId> = operations[K] extends {
|
|
|
35
35
|
export type ParamsOf<K extends OperationId> = operations[K] extends { parameters: infer P }
|
|
36
36
|
? P
|
|
37
37
|
: never
|
|
38
|
+
|
|
39
|
+
import type {
|
|
40
|
+
components as DeliveryComponents,
|
|
41
|
+
operations as DeliveryOperationTable,
|
|
42
|
+
} from '../generated/delivery-api.d.ts'
|
|
43
|
+
|
|
44
|
+
/** The Delivery API's schemas: `DeliverySchemas['IApiContentResponseModel']`. */
|
|
45
|
+
export type DeliverySchemas = DeliveryComponents['schemas']
|
|
46
|
+
export type DeliveryOperations = DeliveryOperationTable
|
|
47
|
+
export type DeliveryOperationId = keyof DeliveryOperationTable
|
|
48
|
+
|
|
49
|
+
/** The 200 JSON body of a Delivery API operation. */
|
|
50
|
+
export type DeliveryResponseOf<K extends DeliveryOperationId> = DeliveryOperationTable[K] extends {
|
|
51
|
+
responses: { 200: infer Ok }
|
|
52
|
+
}
|
|
53
|
+
? JsonContent<Ok>
|
|
54
|
+
: never
|