@zuplo/cli 1.28.0 → 1.29.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zuplo/cli",
3
- "version": "1.28.0",
3
+ "version": "1.29.0",
4
4
  "type": "module",
5
5
  "repository": "https://github.com/zuplo/cli",
6
6
  "author": "Zuplo, Inc.",
@@ -1,303 +0,0 @@
1
- import { expect } from "chai";
2
- import { convertRoutes } from "../engine.js";
3
- describe("Routes.json Conversion Engine", () => {
4
- it("should handle simple route conversion (no version)", () => {
5
- const routesConfig = {
6
- versions: [
7
- {
8
- name: "v1",
9
- pathPrefix: "/v1",
10
- },
11
- {
12
- name: "none",
13
- pathPrefix: "",
14
- },
15
- ],
16
- routes: [
17
- {
18
- methods: ["GET"],
19
- path: "/test",
20
- summary: "Test route",
21
- version: "none",
22
- corsPolicy: "anything-goes",
23
- description: "This is a test route",
24
- operationId: "random",
25
- handler: {
26
- export: "urlRewriteHandler",
27
- module: "$import(@zuplo/runtime)",
28
- options: {
29
- rewritePattern: "https://jsonplaceholder.typicode.com/todos",
30
- forwardSearch: true,
31
- },
32
- },
33
- },
34
- ],
35
- };
36
- const expected = {
37
- openapi: "3.1.0",
38
- info: {
39
- title: "Converted from config/routes.json",
40
- version: "1.0.0",
41
- },
42
- paths: {
43
- "/test": {
44
- get: {
45
- summary: "Test route",
46
- description: "This is a test route",
47
- operationId: "random",
48
- "x-zuplo-route": {
49
- corsPolicy: "anything-goes",
50
- handler: {
51
- export: "urlRewriteHandler",
52
- module: "$import(@zuplo/runtime)",
53
- options: {
54
- rewritePattern: "https://jsonplaceholder.typicode.com/todos",
55
- forwardSearch: true,
56
- },
57
- },
58
- version: "none",
59
- },
60
- },
61
- "x-zuplo-path": {
62
- pathMode: "path-to-regexp",
63
- },
64
- },
65
- },
66
- };
67
- const actual = convertRoutes(routesConfig);
68
- expect(actual).to.deep.equal(expected);
69
- });
70
- it("should handle simple route conversion (with version)", () => {
71
- const routesConfig = {
72
- versions: [
73
- {
74
- name: "v1",
75
- pathPrefix: "/v1",
76
- },
77
- {
78
- name: "none",
79
- pathPrefix: "",
80
- },
81
- ],
82
- routes: [
83
- {
84
- methods: ["GET"],
85
- path: "/test",
86
- summary: "Test route",
87
- version: "v1",
88
- corsPolicy: "anything-goes",
89
- description: "This is a test route",
90
- operationId: "random",
91
- handler: {
92
- export: "urlRewriteHandler",
93
- module: "$import(@zuplo/runtime)",
94
- options: {
95
- rewritePattern: "https://jsonplaceholder.typicode.com/todos",
96
- forwardSearch: true,
97
- },
98
- },
99
- },
100
- ],
101
- };
102
- const expected = {
103
- openapi: "3.1.0",
104
- info: {
105
- title: "Converted from config/routes.json",
106
- version: "1.0.0",
107
- },
108
- paths: {
109
- "/v1/test": {
110
- get: {
111
- summary: "Test route",
112
- description: "This is a test route",
113
- operationId: "random",
114
- "x-zuplo-route": {
115
- corsPolicy: "anything-goes",
116
- handler: {
117
- export: "urlRewriteHandler",
118
- module: "$import(@zuplo/runtime)",
119
- options: {
120
- rewritePattern: "https://jsonplaceholder.typicode.com/todos",
121
- forwardSearch: true,
122
- },
123
- },
124
- version: "none",
125
- },
126
- },
127
- "x-zuplo-path": {
128
- pathMode: "path-to-regexp",
129
- },
130
- },
131
- },
132
- };
133
- const actual = convertRoutes(routesConfig);
134
- expect(actual).to.deep.equal(expected);
135
- });
136
- it("should handle single route with multiple methods", () => {
137
- const routesConfig = {
138
- versions: [
139
- {
140
- name: "v1",
141
- pathPrefix: "/v1",
142
- },
143
- {
144
- name: "none",
145
- pathPrefix: "",
146
- },
147
- ],
148
- routes: [
149
- {
150
- methods: ["GET", "POST", "HEAD"],
151
- path: "/test",
152
- summary: "Test route",
153
- version: "v1",
154
- corsPolicy: "anything-goes",
155
- description: "This is a test route",
156
- operationId: "random",
157
- handler: {
158
- export: "urlRewriteHandler",
159
- module: "$import(@zuplo/runtime)",
160
- options: {
161
- rewritePattern: "https://jsonplaceholder.typicode.com/todos",
162
- forwardSearch: true,
163
- },
164
- },
165
- },
166
- ],
167
- };
168
- const expected = {
169
- openapi: "3.1.0",
170
- info: {
171
- title: "Converted from config/routes.json",
172
- version: "1.0.0",
173
- },
174
- paths: {
175
- "/v1/test": {
176
- "get,post,head": {
177
- summary: "Test route",
178
- description: "This is a test route",
179
- operationId: "random",
180
- "x-zuplo-route": {
181
- corsPolicy: "anything-goes",
182
- handler: {
183
- export: "urlRewriteHandler",
184
- module: "$import(@zuplo/runtime)",
185
- options: {
186
- rewritePattern: "https://jsonplaceholder.typicode.com/todos",
187
- forwardSearch: true,
188
- },
189
- },
190
- version: "none",
191
- },
192
- },
193
- "x-zuplo-path": {
194
- pathMode: "path-to-regexp",
195
- },
196
- },
197
- },
198
- };
199
- const actual = convertRoutes(routesConfig);
200
- expect(actual).to.deep.equal(expected);
201
- });
202
- it("should handle single route with different methods", () => {
203
- const routesConfig = {
204
- versions: [
205
- {
206
- name: "v1",
207
- pathPrefix: "/v1",
208
- },
209
- {
210
- name: "none",
211
- pathPrefix: "",
212
- },
213
- ],
214
- routes: [
215
- {
216
- methods: ["GET"],
217
- path: "/test",
218
- summary: "Test route",
219
- description: "This is a test route",
220
- version: "v1",
221
- corsPolicy: "anything-goes",
222
- handler: {
223
- export: "urlRewriteHandler",
224
- module: "$import(@zuplo/runtime)",
225
- options: {
226
- rewritePattern: "https://welcome.zuplo.io/",
227
- forwardSearch: true,
228
- },
229
- },
230
- operationId: "random1",
231
- },
232
- {
233
- methods: ["POST"],
234
- path: "/test",
235
- summary: "Test route",
236
- description: "This is a test route",
237
- version: "v1",
238
- corsPolicy: "anything-goes",
239
- handler: {
240
- export: "urlRewriteHandler",
241
- module: "$import(@zuplo/runtime)",
242
- options: {
243
- rewritePattern: "https://welcome.zuplo.io/",
244
- forwardSearch: true,
245
- },
246
- },
247
- operationId: "random2",
248
- },
249
- ],
250
- };
251
- const expected = {
252
- openapi: "3.1.0",
253
- info: {
254
- title: "Converted from config/routes.json",
255
- version: "1.0.0",
256
- },
257
- paths: {
258
- "/v1/test": {
259
- get: {
260
- summary: "Test route",
261
- description: "This is a test route",
262
- operationId: "random1",
263
- "x-zuplo-route": {
264
- corsPolicy: "anything-goes",
265
- handler: {
266
- export: "urlRewriteHandler",
267
- module: "$import(@zuplo/runtime)",
268
- options: {
269
- rewritePattern: "https://welcome.zuplo.io/",
270
- forwardSearch: true,
271
- },
272
- },
273
- version: "none",
274
- },
275
- },
276
- post: {
277
- summary: "Test route",
278
- description: "This is a test route",
279
- operationId: "random2",
280
- "x-zuplo-route": {
281
- corsPolicy: "anything-goes",
282
- handler: {
283
- export: "urlRewriteHandler",
284
- module: "$import(@zuplo/runtime)",
285
- options: {
286
- rewritePattern: "https://welcome.zuplo.io/",
287
- forwardSearch: true,
288
- },
289
- },
290
- version: "none",
291
- },
292
- },
293
- "x-zuplo-path": {
294
- pathMode: "path-to-regexp",
295
- },
296
- },
297
- },
298
- };
299
- const actual = convertRoutes(routesConfig);
300
- expect(actual).to.deep.equal(expected);
301
- });
302
- });
303
- //# sourceMappingURL=engine.spec.js.map