@compassdigital/sdk.typescript 3.0.0-beta.10 → 3.0.0-beta.11
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/gen.ts +11 -4
- package/lib/base.d.ts +86 -6
- package/lib/base.d.ts.map +1 -1
- package/lib/base.js +120 -28
- package/lib/base.js.map +1 -1
- package/lib/index.d.ts +236 -236
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -2
- package/lib/index.js.map +1 -1
- package/lib/order.d.ts +4 -4
- package/lib/order.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/base.ts +120 -15
- package/src/index.ts +273 -238
- package/src/order.ts +6 -6
- package/template.ejs +2 -2
- package/test/client.test.ts +3 -3
- package/test/gen.test.ts +22 -0
package/src/order.ts
CHANGED
|
@@ -376,12 +376,12 @@ export interface GetOrderCustomerOrdersBrandRequest extends GetOrderCustomerOrde
|
|
|
376
376
|
|
|
377
377
|
// GET /order/location/brand/{id} - Get all orders for a location Brand
|
|
378
378
|
|
|
379
|
-
export interface
|
|
379
|
+
export interface GetOrderLocationBrandPath {
|
|
380
380
|
// The location brand ID
|
|
381
381
|
id: string;
|
|
382
382
|
}
|
|
383
383
|
|
|
384
|
-
export interface
|
|
384
|
+
export interface GetOrderLocationBrandQuery {
|
|
385
385
|
// Filter orders by their pickup date. Only return orders that have a date greater than or equal to the date in milliseconds.
|
|
386
386
|
pickup_start?: number;
|
|
387
387
|
// Filter orders by their pickup date. Only return orders that have a date less than or equal to the date in milliseconds.
|
|
@@ -398,11 +398,11 @@ export interface GetOrderBrandOrdersQuery {
|
|
|
398
398
|
limit?: number;
|
|
399
399
|
}
|
|
400
400
|
|
|
401
|
-
export type
|
|
401
|
+
export type GetOrderLocationBrandResponse = Orders;
|
|
402
402
|
|
|
403
|
-
export interface
|
|
404
|
-
extends
|
|
405
|
-
|
|
403
|
+
export interface GetOrderLocationBrandRequest
|
|
404
|
+
extends GetOrderLocationBrandQuery,
|
|
405
|
+
GetOrderLocationBrandPath {}
|
|
406
406
|
|
|
407
407
|
// GET /order/location/{id} - Get all orders for a location
|
|
408
408
|
|
package/template.ejs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { BaseServiceClient, RequestOptions } from "./base";
|
|
2
|
+
import { BaseServiceClient, RequestOptions, ResponsePromise } from "./base";
|
|
3
3
|
export * from "./base";
|
|
4
4
|
|
|
5
5
|
export class ServiceClient extends BaseServiceClient {
|
|
@@ -14,7 +14,7 @@ export class ServiceClient extends BaseServiceClient {
|
|
|
14
14
|
* @param <%- param.name %><%- param.description ? " - " + param.description : "" %>
|
|
15
15
|
<% } -%>
|
|
16
16
|
*/
|
|
17
|
-
<%- name %>(<% for (let i = 0; i < params.length; i++) { %><%- i > 0 ? ", " : "" %><%- params[i].name %><%= params[i].required ? "" : "?" %>: <%- params[i].type %><% } %>):
|
|
17
|
+
<%- name %>(<% for (let i = 0; i < params.length; i++) { %><%- i > 0 ? ", " : "" %><%- params[i].name %><%= params[i].required ? "" : "?" %>: <%- params[i].type %><% } %>): ResponsePromise<<%= response %>> {
|
|
18
18
|
return this.request(<% for (let i = 0; i < args.length; i++) { %><%- i > 0 ? ", " : "" %><%- args[i] %><% } %>);
|
|
19
19
|
}
|
|
20
20
|
<% } %>
|
package/test/client.test.ts
CHANGED
|
@@ -79,7 +79,7 @@ describe("ServiceClient", () => {
|
|
|
79
79
|
intercept: async (req) => {
|
|
80
80
|
attempts++;
|
|
81
81
|
return { ok: false, status: 500, body: "something went wrong"};
|
|
82
|
-
}
|
|
82
|
+
},
|
|
83
83
|
});
|
|
84
84
|
try {
|
|
85
85
|
const task = await api.get_task("", { retry: 5 });
|
|
@@ -103,7 +103,7 @@ describe("ServiceClient", () => {
|
|
|
103
103
|
return { ok: false, status: 501, body: "" };
|
|
104
104
|
}
|
|
105
105
|
});
|
|
106
|
-
const task = await
|
|
106
|
+
const task = await api.get_task("").ignore(501);
|
|
107
107
|
expect(task).toBeNull();
|
|
108
108
|
});
|
|
109
109
|
|
|
@@ -113,7 +113,7 @@ describe("ServiceClient", () => {
|
|
|
113
113
|
return { ok: false, status: 500, body: JSON.stringify({ code: 500.4, message: "uh oh" }) };
|
|
114
114
|
}
|
|
115
115
|
});
|
|
116
|
-
const task = await
|
|
116
|
+
const task = await api.get_task("").ignore(500.4);
|
|
117
117
|
expect(task).toBeNull();
|
|
118
118
|
});
|
|
119
119
|
|
package/test/gen.test.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
|
|
2
|
+
import { OperationObject, OperationParams, Schema } from "@icholy/openapi-ts";
|
|
3
|
+
import { CodeGenerator } from "../gen";
|
|
4
|
+
|
|
5
|
+
describe("CodeGenerator", () => {
|
|
6
|
+
describe("inferName", () => {
|
|
7
|
+
const gen = new CodeGenerator();
|
|
8
|
+
test("/order/location/brand/{id}", () => {
|
|
9
|
+
const op: OperationObject = {
|
|
10
|
+
operationId: "get_brand_orders",
|
|
11
|
+
}
|
|
12
|
+
const name = gen.inferName({
|
|
13
|
+
method: "get",
|
|
14
|
+
params: new OperationParams(op),
|
|
15
|
+
path: "/order/location/brand/{id}",
|
|
16
|
+
obj: op,
|
|
17
|
+
}, { name: "order", swagger: "" });
|
|
18
|
+
expect(name.pascal).toBe("GetOrderLocationBrand");
|
|
19
|
+
expect(name.snake).toBe("get_order_location_brand");
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
});
|