@digitraffic/common 2024.8.27-1 → 2024.8.30-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.
@@ -0,0 +1,134 @@
|
|
1
|
+
import { z } from "zod";
|
2
|
+
export const serverObject = z.object({
|
3
|
+
url: z.string(),
|
4
|
+
description: z.string().optional(),
|
5
|
+
variables: z.record(z.unknown()).optional(),
|
6
|
+
});
|
7
|
+
export const parameterObject = z.object({
|
8
|
+
name: z.string(),
|
9
|
+
in: z.enum(["query", "header", "path", "cookie"]),
|
10
|
+
description: z.string().optional(),
|
11
|
+
required: z.boolean().optional(),
|
12
|
+
deprecated: z.boolean().optional(),
|
13
|
+
allowEmptyValue: z.boolean().optional(),
|
14
|
+
style: z
|
15
|
+
.enum(["matrix", "label", "form", "simple", "spaceDelimited", "pipeDelimited", "deepObject"])
|
16
|
+
.optional(),
|
17
|
+
explode: z.string().optional(),
|
18
|
+
allowReserved: z.boolean().optional(),
|
19
|
+
schema: z.unknown().optional(),
|
20
|
+
example: z.unknown().optional(),
|
21
|
+
examples: z.record(z.unknown()).optional(),
|
22
|
+
content: z.record(z.unknown()).optional(),
|
23
|
+
});
|
24
|
+
export const referenceObject = z.object({
|
25
|
+
$ref: z.string(),
|
26
|
+
summary: z.string().optional(),
|
27
|
+
description: z.string().optional(),
|
28
|
+
});
|
29
|
+
export const openapiOperation = z
|
30
|
+
.object({
|
31
|
+
tags: z.array(z.string()),
|
32
|
+
summary: z.string(),
|
33
|
+
description: z.string(),
|
34
|
+
externalDocs: z.unknown(),
|
35
|
+
operationId: z.string(),
|
36
|
+
parameters: z.array(parameterObject.or(referenceObject)),
|
37
|
+
requestBody: z.unknown(),
|
38
|
+
responses: z.unknown(),
|
39
|
+
callbacks: z.unknown(),
|
40
|
+
deprecated: z.boolean(),
|
41
|
+
security: z.array(z.record(z.array(z.string()))),
|
42
|
+
servers: z.array(z.unknown()),
|
43
|
+
})
|
44
|
+
.partial();
|
45
|
+
// Path items have some fixed fields but also allow for extended fields starting with "x-".
|
46
|
+
//export const openapiPathItem = z.record(openapiOperation.or(serverObject).or(parameterObject));
|
47
|
+
export const openapiPathItem = z
|
48
|
+
.object({
|
49
|
+
summary: z.string(),
|
50
|
+
description: z.string(),
|
51
|
+
get: openapiOperation,
|
52
|
+
put: openapiOperation,
|
53
|
+
post: openapiOperation,
|
54
|
+
delete: openapiOperation,
|
55
|
+
options: openapiOperation,
|
56
|
+
head: openapiOperation,
|
57
|
+
patch: openapiOperation,
|
58
|
+
trace: openapiOperation,
|
59
|
+
servers: serverObject,
|
60
|
+
parameters: z.array(parameterObject),
|
61
|
+
})
|
62
|
+
.partial();
|
63
|
+
export const openapiSchema = z
|
64
|
+
.object({
|
65
|
+
openapi: z.string().regex(new RegExp("^3\\.0\\.\\d(-.+)?$")),
|
66
|
+
info: z
|
67
|
+
.object({
|
68
|
+
title: z.string(),
|
69
|
+
description: z.string().optional(),
|
70
|
+
termsOfService: z.string().optional(),
|
71
|
+
contact: z
|
72
|
+
.object({
|
73
|
+
name: z.string().optional(),
|
74
|
+
url: z.string().optional(),
|
75
|
+
email: z.string().email().optional(),
|
76
|
+
})
|
77
|
+
.strict()
|
78
|
+
.optional(),
|
79
|
+
license: z.object({ name: z.string(), url: z.string().optional() }).strict().optional(),
|
80
|
+
version: z.string(),
|
81
|
+
})
|
82
|
+
.strict(),
|
83
|
+
externalDocs: z.object({ description: z.string().optional(), url: z.string() }).strict().optional(),
|
84
|
+
servers: z
|
85
|
+
.array(z
|
86
|
+
.object({
|
87
|
+
url: z.string(),
|
88
|
+
description: z.string().optional(),
|
89
|
+
variables: z
|
90
|
+
.record(z
|
91
|
+
.object({
|
92
|
+
enum: z.array(z.string()).optional(),
|
93
|
+
default: z.string(),
|
94
|
+
description: z.string().optional(),
|
95
|
+
})
|
96
|
+
.strict())
|
97
|
+
.optional(),
|
98
|
+
})
|
99
|
+
.strict())
|
100
|
+
.optional(),
|
101
|
+
security: z.array(z.record(z.array(z.string()))).optional(),
|
102
|
+
tags: z
|
103
|
+
.array(z
|
104
|
+
.object({
|
105
|
+
name: z.string(),
|
106
|
+
description: z.string().optional(),
|
107
|
+
externalDocs: z
|
108
|
+
.object({
|
109
|
+
description: z.string().optional(),
|
110
|
+
url: z.string(),
|
111
|
+
})
|
112
|
+
.strict()
|
113
|
+
.optional(),
|
114
|
+
})
|
115
|
+
.strict())
|
116
|
+
.optional(),
|
117
|
+
paths: z.record(openapiPathItem),
|
118
|
+
components: z
|
119
|
+
.object({
|
120
|
+
schemas: z.record(z.any()).optional(),
|
121
|
+
responses: z.record(z.any()).optional(),
|
122
|
+
parameters: z.record(z.any()).optional(),
|
123
|
+
examples: z.record(z.any()).optional(),
|
124
|
+
requestBodies: z.record(z.any()).optional(),
|
125
|
+
headers: z.record(z.any()).optional(),
|
126
|
+
securitySchemes: z.record(z.any()).optional(),
|
127
|
+
links: z.record(z.any()).optional(),
|
128
|
+
callbacks: z.record(z.any()).optional(),
|
129
|
+
})
|
130
|
+
.strict()
|
131
|
+
.optional(),
|
132
|
+
})
|
133
|
+
.describe("The description of OpenAPI v3.0.x documents, as defined by https://spec.openapis.org/oas/v3.0.3");
|
134
|
+
//# sourceMappingURL=openapi-schema.js.map
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@digitraffic/common",
|
3
|
-
"version": "2024.8.
|
3
|
+
"version": "2024.8.30-1",
|
4
4
|
"description": "",
|
5
5
|
"type": "module",
|
6
6
|
"repository": {
|
@@ -33,6 +33,7 @@
|
|
33
33
|
"./dist/types/http-error": "./dist/types/http-error.js",
|
34
34
|
"./dist/types/language": "./dist/types/language.js",
|
35
35
|
"./dist/types/traffictype": "./dist/types/traffictype.js",
|
36
|
+
"./dist/types/openapi-schema": "./dist/types/openapi-schema.js",
|
36
37
|
"./dist/test/testutils": "./dist/__test__/testutils.js",
|
37
38
|
"./dist/test/db-testutils": "./dist/__test__/db-testutils.js",
|
38
39
|
"./dist/test/httpserver": "./dist/__test__/httpserver.js",
|
@@ -120,7 +121,8 @@
|
|
120
121
|
"lodash-es": "~4.17.21",
|
121
122
|
"node-ttl": "^0.2.0",
|
122
123
|
"pg-native": "^3.1.0",
|
123
|
-
"pg-promise": "^11.9.1"
|
124
|
+
"pg-promise": "^11.9.1",
|
125
|
+
"zod": "~3.23.8"
|
124
126
|
},
|
125
127
|
"devDependencies": {
|
126
128
|
"@aws-sdk/client-api-gateway": "^3.637.0",
|
@@ -146,8 +148,8 @@
|
|
146
148
|
"@types/node": "20.14.9",
|
147
149
|
"@typescript-eslint/eslint-plugin": "~7.14.1",
|
148
150
|
"@typescript-eslint/parser": "^7.18.0",
|
149
|
-
"aws-cdk-lib": "^2.
|
150
|
-
"aws-sdk": "^2.
|
151
|
+
"aws-cdk-lib": "^2.155.0",
|
152
|
+
"aws-sdk": "^2.1686.0",
|
151
153
|
"change-case": "^5.4.4",
|
152
154
|
"constructs": "~10.3.0",
|
153
155
|
"date-fns": "~3.6.0",
|
@@ -170,7 +172,8 @@
|
|
170
172
|
"rimraf": "^6.0.1",
|
171
173
|
"ts-jest": "^29.2.5",
|
172
174
|
"typescript": "~5.5.4",
|
173
|
-
"velocityjs": "^2.0.6"
|
175
|
+
"velocityjs": "^2.0.6",
|
176
|
+
"zod": "~3.23.8"
|
174
177
|
},
|
175
178
|
"scripts": {
|
176
179
|
"build": "heft build --clean",
|