@compassdigital/sdk.typescript 3.0.0-beta.10 → 3.0.0-beta.12
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/README.md +108 -8
- package/gen.ts +11 -4
- package/lib/base.d.ts +108 -6
- package/lib/base.d.ts.map +1 -1
- package/lib/base.js +152 -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 +148 -15
- package/src/index.ts +273 -238
- package/src/order.ts +6 -6
- package/template.ejs +2 -2
- package/test/client.test.ts +25 -3
- package/test/gen.test.ts +22 -0
package/README.md
CHANGED
|
@@ -8,31 +8,131 @@ Compass Digital Labs TypeScript SDK
|
|
|
8
8
|
$ npm install --save @compassdigital/sdk.typescript@latest
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
+
## Example Server Usage
|
|
12
|
+
|
|
13
|
+
``` typescript
|
|
14
|
+
import Provider from "@compassdigital/provider";
|
|
15
|
+
import { GetTaskRequest, GetTaskResponse } from "@compassdigital/sdk.typescript/task";
|
|
16
|
+
|
|
17
|
+
const provider = new Provider({ type: "payment" });
|
|
18
|
+
|
|
19
|
+
provider.on<GetTaskRequest, GetTaskResponse>("get_task", function (req, next): void {
|
|
20
|
+
// ...
|
|
21
|
+
})
|
|
22
|
+
```
|
|
23
|
+
|
|
11
24
|
## Example Client Usage
|
|
12
25
|
|
|
26
|
+
**Instanciate Client:**
|
|
27
|
+
|
|
13
28
|
``` typescript
|
|
14
29
|
import { ServiceClient } from "@compassdigital/sdk.typescript";
|
|
15
30
|
|
|
16
31
|
const api = new ServiceClient({ stage: "dev" });
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
**Basic Request:**
|
|
35
|
+
|
|
36
|
+
``` typescript
|
|
37
|
+
const task = await api.get_task(id);
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
**Request Options:**
|
|
41
|
+
|
|
42
|
+
* These options may be passed to any request.
|
|
17
43
|
|
|
18
|
-
|
|
19
|
-
|
|
44
|
+
``` typescript
|
|
45
|
+
interface RequestOptions {
|
|
46
|
+
// environment to make requests to
|
|
47
|
+
stage?: string;
|
|
48
|
+
// authentication token
|
|
49
|
+
token?: string;
|
|
50
|
+
// additional headers
|
|
51
|
+
headers?: Record<string, string>;
|
|
52
|
+
// log all requests and responses
|
|
53
|
+
debug?: boolean;
|
|
54
|
+
// the number of times to retry a request
|
|
55
|
+
retry?: number;
|
|
56
|
+
// make requests against this base url
|
|
57
|
+
// note: the stage property is ignored if base_url is set
|
|
58
|
+
base_url?: string;
|
|
59
|
+
// intercept outgoing http requests
|
|
60
|
+
intercept?: InterceptFn;
|
|
20
61
|
}
|
|
21
62
|
```
|
|
22
63
|
|
|
23
|
-
|
|
64
|
+
* The `RequestOptions` can be provided to the `ServiceClient` constructor or at the request call site.
|
|
65
|
+
* The options provided at the call site will overide options passed to the constructor.
|
|
24
66
|
|
|
25
67
|
``` typescript
|
|
26
|
-
import Provider from "@compassdigital/provider";
|
|
27
|
-
import { GetTaskRequest, GetTaskResponse } from "@compassdigital/sdk.typescript/task";
|
|
28
68
|
|
|
29
|
-
const
|
|
69
|
+
const api = new ServiceClient({
|
|
70
|
+
token: "<token>",
|
|
71
|
+
retry: 2,
|
|
72
|
+
})
|
|
30
73
|
|
|
31
|
-
|
|
32
|
-
|
|
74
|
+
const location = await api.get_location(id, {
|
|
75
|
+
token: "<token>",
|
|
76
|
+
retry: 2,
|
|
33
77
|
})
|
|
34
78
|
```
|
|
35
79
|
|
|
80
|
+
**Error Handling:**
|
|
81
|
+
|
|
82
|
+
* non-200 responses are rejected with a `ServiceError`.
|
|
83
|
+
|
|
84
|
+
``` typescript
|
|
85
|
+
try {
|
|
86
|
+
const shoppingcart = await api.get_shoppingcart(id);
|
|
87
|
+
} catch (err) {
|
|
88
|
+
// Since the error type is `unknown` we must type assert before
|
|
89
|
+
// accessing the properties.
|
|
90
|
+
if (err instanceof ServiceError) {
|
|
91
|
+
console.log(err.status, err.code, err.message);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// There are helpers for accessing the status and code
|
|
95
|
+
if (ServiceError.code(err) === 400.31) {
|
|
96
|
+
console.log("Failed to get menu");
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
* There is a `ignore` convinience method for ignoring specific status & error codes.
|
|
102
|
+
|
|
103
|
+
``` typescript
|
|
104
|
+
const issue: OrderIssue = { items: [] };
|
|
105
|
+
await api.post_order_issue(id, issue).ignore(400.18, 400.21);
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
* There is a `combine` convinience method for returning an object which contains the response or error.
|
|
109
|
+
|
|
110
|
+
``` typescript
|
|
111
|
+
const res = await api.get_task(id).combine();
|
|
112
|
+
|
|
113
|
+
if (res.ok) {
|
|
114
|
+
console.log("task", res.body);
|
|
115
|
+
} else {
|
|
116
|
+
console.log("error", res.err);
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
**Testing:**
|
|
121
|
+
|
|
122
|
+
* You can register an `intercept` function which will recieve all request.
|
|
123
|
+
|
|
124
|
+
``` typescript
|
|
125
|
+
|
|
126
|
+
import { ServiceClient, RequestData, ResponseData, FetchFn } from "@compassdigital/sdk.typescript";
|
|
127
|
+
|
|
128
|
+
async function intercept(req: RequestData, fetch: FetchFn): Promise<ResponseData> {
|
|
129
|
+
expect(req.name).toBe("get_shoppingcart");
|
|
130
|
+
return { ok: true, status: 200, body: JSON.stringify({}) }
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const api = new ServiceClient({ intercept });
|
|
134
|
+
```
|
|
135
|
+
|
|
36
136
|
## Code Gen
|
|
37
137
|
|
|
38
138
|
1. Add new services to `manifest.json`.
|
package/gen.ts
CHANGED
|
@@ -60,10 +60,11 @@ const operationIDs : Record<string, string> = {
|
|
|
60
60
|
"get /promo": "get_promos",
|
|
61
61
|
"get /schedule": "get_schedules",
|
|
62
62
|
"get /brand": "get_brands",
|
|
63
|
-
"get /announcement/resource": "get_resources"
|
|
63
|
+
"get /announcement/resource": "get_resources",
|
|
64
|
+
"get /order/location/brand/{id}": "get_order_location_brand",
|
|
64
65
|
};
|
|
65
66
|
|
|
66
|
-
class CodeGenerator {
|
|
67
|
+
export class CodeGenerator {
|
|
67
68
|
|
|
68
69
|
private imports: ClientImport[] = [];
|
|
69
70
|
private methods: ClientMethod[] = [];
|
|
@@ -249,7 +250,7 @@ class CodeGenerator {
|
|
|
249
250
|
* Infer the operation name from the method and parameter.
|
|
250
251
|
* These are a bunch of dirty hacks to make the generated names consistent.
|
|
251
252
|
*/
|
|
252
|
-
|
|
253
|
+
inferName(op: OperationDetails, service: ManifestService): OperationName {
|
|
253
254
|
let { method, path } = op;
|
|
254
255
|
let path_segments: string[] = [];
|
|
255
256
|
// use the operationId from our collection if we have one.
|
|
@@ -350,4 +351,10 @@ async function main() {
|
|
|
350
351
|
await gen.generate(manifest);
|
|
351
352
|
}
|
|
352
353
|
|
|
353
|
-
|
|
354
|
+
/**
|
|
355
|
+
* Only generate if --run flag was passed
|
|
356
|
+
*/
|
|
357
|
+
const args = process.argv.splice(2);
|
|
358
|
+
if (args[0] === "--run") {
|
|
359
|
+
main();
|
|
360
|
+
}
|
package/lib/base.d.ts
CHANGED
|
@@ -7,6 +7,10 @@ export interface RequestOptions {
|
|
|
7
7
|
base_url?: string;
|
|
8
8
|
intercept?: InterceptFn;
|
|
9
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* The request data provided to intercept
|
|
12
|
+
* functions.
|
|
13
|
+
*/
|
|
10
14
|
export interface RequestData {
|
|
11
15
|
name: string;
|
|
12
16
|
service: string;
|
|
@@ -15,41 +19,139 @@ export interface RequestData {
|
|
|
15
19
|
headers: Record<string, string>;
|
|
16
20
|
body?: string;
|
|
17
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* The response data expected from
|
|
24
|
+
* intercept functions.
|
|
25
|
+
*/
|
|
18
26
|
export interface ResponseData {
|
|
19
27
|
ok: boolean;
|
|
20
28
|
status: number;
|
|
21
29
|
body: string;
|
|
22
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* A function that performs an https request.
|
|
33
|
+
*/
|
|
23
34
|
export declare type FetchFn = (req: RequestData) => Promise<ResponseData>;
|
|
35
|
+
/**
|
|
36
|
+
* A function that intercepts an http request and returns a response.
|
|
37
|
+
*/
|
|
24
38
|
export declare type InterceptFn = (req: RequestData, fetch: FetchFn) => Promise<ResponseData>;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
39
|
+
/**
|
|
40
|
+
* We have to re-implement the promise methods instead of just existing
|
|
41
|
+
* the existing Promise class due to: https://github.com/microsoft/TypeScript/issues/15202
|
|
42
|
+
*/
|
|
43
|
+
export declare class ResponsePromise<T> implements Promise<T> {
|
|
44
|
+
private promise;
|
|
45
|
+
/**
|
|
46
|
+
* Implements Promise interface.
|
|
47
|
+
*/
|
|
48
|
+
[Symbol.toStringTag]: string;
|
|
49
|
+
constructor(promise: Promise<T>);
|
|
50
|
+
/**
|
|
51
|
+
* Implements Promise interface.
|
|
52
|
+
*/
|
|
53
|
+
then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): ResponsePromise<TResult1 | TResult2>;
|
|
54
|
+
/**
|
|
55
|
+
* Implements Promise interface.
|
|
56
|
+
*/
|
|
57
|
+
catch<TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null): ResponsePromise<T | TResult>;
|
|
58
|
+
/**
|
|
59
|
+
* Implements Promise interface.
|
|
60
|
+
*/
|
|
61
|
+
finally(onfinally?: (() => void) | null): ResponsePromise<T>;
|
|
62
|
+
/**
|
|
63
|
+
* Returns a promise that resolves to null if http status code
|
|
64
|
+
* or service error code matches one of the provided codes.
|
|
65
|
+
* If no codes are specified, all codes are ignored.
|
|
66
|
+
*/
|
|
67
|
+
ignore(...codes: number[]): ResponsePromise<T | null>;
|
|
68
|
+
/**
|
|
69
|
+
* Returns a promise that resolves to either the response body
|
|
70
|
+
* or a ServiceError.
|
|
71
|
+
*/
|
|
72
|
+
combine(): Promise<EitherResponse<T>>;
|
|
29
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* Either a response body or a service error.
|
|
76
|
+
*/
|
|
77
|
+
declare type EitherResponse<T> = {
|
|
78
|
+
ok: true;
|
|
79
|
+
body: T;
|
|
80
|
+
err?: ServiceError;
|
|
81
|
+
} | {
|
|
82
|
+
ok: false;
|
|
83
|
+
body?: T;
|
|
84
|
+
err: ServiceError;
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* An error returned from an api service.
|
|
88
|
+
*/
|
|
30
89
|
export declare class ServiceError extends Error {
|
|
31
90
|
status: number;
|
|
32
91
|
code: number;
|
|
33
92
|
constructor(status: number, // http status
|
|
34
93
|
code: number, // service error code
|
|
35
94
|
message: string);
|
|
95
|
+
/**
|
|
96
|
+
* Returns the http status code from err.
|
|
97
|
+
* If err isn't an instance of ServiceError, -1 is returned.
|
|
98
|
+
*/
|
|
36
99
|
static status(err: any): number;
|
|
100
|
+
/**
|
|
101
|
+
* Returns the service error code from err.
|
|
102
|
+
* If err isn't an instance of ServiceError, -1 is returned.
|
|
103
|
+
*/
|
|
37
104
|
static code(err: any): number;
|
|
105
|
+
/**
|
|
106
|
+
* Returns a promise that resolves to null if http status code
|
|
107
|
+
* or service error code matches one of the provided codes.
|
|
108
|
+
* If no codes are specified, all codes are ignored.
|
|
109
|
+
*/
|
|
38
110
|
static ignore<T>(codes: number[], response: Promise<T>): Promise<T | null>;
|
|
111
|
+
/**
|
|
112
|
+
* Returns a promise that resolves to either T or a ServiceError.
|
|
113
|
+
*/
|
|
114
|
+
static combine<T>(response: Promise<T>): Promise<EitherResponse<T>>;
|
|
115
|
+
/**
|
|
116
|
+
* Constructs a ServiceError from the provided response data.
|
|
117
|
+
*/
|
|
39
118
|
static from_res(res: ResponseData): ServiceError;
|
|
40
119
|
}
|
|
120
|
+
/**
|
|
121
|
+
* BaseServiceClient contains the logic for executing http requests.
|
|
122
|
+
* This class is meant to be extended by the generated code.
|
|
123
|
+
*/
|
|
41
124
|
export declare abstract class BaseServiceClient {
|
|
42
125
|
private options;
|
|
43
|
-
constructor(options?:
|
|
126
|
+
constructor(options?: RequestOptions);
|
|
44
127
|
/**
|
|
45
128
|
* Combine the route and query parameters into a full url.
|
|
46
129
|
*/
|
|
47
130
|
private build_url;
|
|
131
|
+
/**
|
|
132
|
+
* Perform the http request or pass it to the intercept function
|
|
133
|
+
* if one was configured.
|
|
134
|
+
*/
|
|
48
135
|
private fetch;
|
|
136
|
+
/**
|
|
137
|
+
* Returns true if the response status was a 4xx error.
|
|
138
|
+
*/
|
|
49
139
|
private is_4xx;
|
|
140
|
+
/**
|
|
141
|
+
* Returns the merged options.
|
|
142
|
+
*/
|
|
50
143
|
private get_options;
|
|
144
|
+
/**
|
|
145
|
+
* A delegate to _request that wraps the response in a ResponsePromise.
|
|
146
|
+
*/
|
|
51
147
|
protected request(service: string, name: string, method: string, route: string, body: any, options?: {
|
|
52
148
|
query?: any;
|
|
53
|
-
} & RequestOptions):
|
|
149
|
+
} & RequestOptions): ResponsePromise<any>;
|
|
150
|
+
/**
|
|
151
|
+
* The main logic for fulfilling a request as perscribed by
|
|
152
|
+
* the request options.
|
|
153
|
+
*/
|
|
154
|
+
private _request;
|
|
54
155
|
}
|
|
156
|
+
export {};
|
|
55
157
|
//# sourceMappingURL=base.d.ts.map
|
package/lib/base.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../src/base.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,cAAc;IA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G;WACU,OAAO,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;IAYzE;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,YAAY,GAAG,YAAY;CAYjD;AAED;;;GAGG;AACH,8BAAsB,iBAAiB;IACrC,OAAO,CAAC,OAAO,CAAiB;gBAEpB,OAAO,CAAC,EAAE,cAAc;IAIpC;;OAEG;IACH,OAAO,CAAC,SAAS;IAoBjB;;;OAGG;YACW,KAAK;IAgBnB;;OAEG;IACH,OAAO,CAAC,MAAM;IAId;;OAEG;IACH,OAAO,CAAC,WAAW;IAWnB;;OAEG;IACH,SAAS,CAAC,OAAO,CACf,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,GAAG,EACT,OAAO,GAAE;QAAE,KAAK,CAAC,EAAE,GAAG,CAAA;KAAE,GAAG,cAAmB,GAC7C,eAAe,CAAC,GAAG,CAAC;IAKvB;;;OAGG;YACW,QAAQ;CAyCvB"}
|
package/lib/base.js
CHANGED
|
@@ -64,9 +64,66 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
64
64
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
65
65
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
66
66
|
};
|
|
67
|
+
var _a;
|
|
67
68
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
68
|
-
exports.BaseServiceClient = exports.ServiceError = void 0;
|
|
69
|
+
exports.BaseServiceClient = exports.ServiceError = exports.ResponsePromise = void 0;
|
|
69
70
|
var cross_fetch_1 = __importDefault(require("cross-fetch"));
|
|
71
|
+
/**
|
|
72
|
+
* We have to re-implement the promise methods instead of just existing
|
|
73
|
+
* the existing Promise class due to: https://github.com/microsoft/TypeScript/issues/15202
|
|
74
|
+
*/
|
|
75
|
+
var ResponsePromise = /** @class */ (function () {
|
|
76
|
+
function ResponsePromise(promise) {
|
|
77
|
+
this.promise = promise;
|
|
78
|
+
/**
|
|
79
|
+
* Implements Promise interface.
|
|
80
|
+
*/
|
|
81
|
+
this[_a] = "[object ResponsePromise]";
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Implements Promise interface.
|
|
85
|
+
*/
|
|
86
|
+
ResponsePromise.prototype.then = function (onfulfilled, onrejected) {
|
|
87
|
+
return new ResponsePromise(this.promise.then(onfulfilled, onrejected));
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Implements Promise interface.
|
|
91
|
+
*/
|
|
92
|
+
ResponsePromise.prototype.catch = function (onrejected) {
|
|
93
|
+
return new ResponsePromise(this.promise.catch(onrejected));
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Implements Promise interface.
|
|
97
|
+
*/
|
|
98
|
+
ResponsePromise.prototype.finally = function (onfinally) {
|
|
99
|
+
return new ResponsePromise(this.promise.finally(onfinally));
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* Returns a promise that resolves to null if http status code
|
|
103
|
+
* or service error code matches one of the provided codes.
|
|
104
|
+
* If no codes are specified, all codes are ignored.
|
|
105
|
+
*/
|
|
106
|
+
ResponsePromise.prototype.ignore = function () {
|
|
107
|
+
var codes = [];
|
|
108
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
109
|
+
codes[_i] = arguments[_i];
|
|
110
|
+
}
|
|
111
|
+
return new ResponsePromise(ServiceError.ignore(codes, this.promise));
|
|
112
|
+
};
|
|
113
|
+
/**
|
|
114
|
+
* Returns a promise that resolves to either the response body
|
|
115
|
+
* or a ServiceError.
|
|
116
|
+
*/
|
|
117
|
+
ResponsePromise.prototype.combine = function () {
|
|
118
|
+
return new ResponsePromise(ServiceError.combine(this.promise));
|
|
119
|
+
};
|
|
120
|
+
return ResponsePromise;
|
|
121
|
+
}());
|
|
122
|
+
exports.ResponsePromise = ResponsePromise;
|
|
123
|
+
_a = Symbol.toStringTag;
|
|
124
|
+
/**
|
|
125
|
+
* An error returned from an api service.
|
|
126
|
+
*/
|
|
70
127
|
var ServiceError = /** @class */ (function (_super) {
|
|
71
128
|
__extends(ServiceError, _super);
|
|
72
129
|
function ServiceError(status, // http status
|
|
@@ -81,30 +138,46 @@ var ServiceError = /** @class */ (function (_super) {
|
|
|
81
138
|
Object.setPrototypeOf(_this, ServiceError.prototype);
|
|
82
139
|
return _this;
|
|
83
140
|
}
|
|
141
|
+
/**
|
|
142
|
+
* Returns the http status code from err.
|
|
143
|
+
* If err isn't an instance of ServiceError, -1 is returned.
|
|
144
|
+
*/
|
|
84
145
|
ServiceError.status = function (err) {
|
|
85
146
|
if (err instanceof ServiceError) {
|
|
86
147
|
return err.status;
|
|
87
148
|
}
|
|
88
149
|
return -1;
|
|
89
150
|
};
|
|
151
|
+
/**
|
|
152
|
+
* Returns the service error code from err.
|
|
153
|
+
* If err isn't an instance of ServiceError, -1 is returned.
|
|
154
|
+
*/
|
|
90
155
|
ServiceError.code = function (err) {
|
|
91
156
|
if (err instanceof ServiceError) {
|
|
92
157
|
return err.code;
|
|
93
158
|
}
|
|
94
159
|
return -1;
|
|
95
160
|
};
|
|
161
|
+
/**
|
|
162
|
+
* Returns a promise that resolves to null if http status code
|
|
163
|
+
* or service error code matches one of the provided codes.
|
|
164
|
+
* If no codes are specified, all codes are ignored.
|
|
165
|
+
*/
|
|
96
166
|
ServiceError.ignore = function (codes, response) {
|
|
97
167
|
return __awaiter(this, void 0, void 0, function () {
|
|
98
168
|
var err_1, _i, codes_1, code;
|
|
99
|
-
return __generator(this, function (
|
|
100
|
-
switch (
|
|
169
|
+
return __generator(this, function (_b) {
|
|
170
|
+
switch (_b.label) {
|
|
101
171
|
case 0:
|
|
102
|
-
|
|
172
|
+
_b.trys.push([0, 2, , 3]);
|
|
103
173
|
return [4 /*yield*/, response];
|
|
104
|
-
case 1: return [2 /*return*/,
|
|
174
|
+
case 1: return [2 /*return*/, _b.sent()];
|
|
105
175
|
case 2:
|
|
106
|
-
err_1 =
|
|
176
|
+
err_1 = _b.sent();
|
|
107
177
|
if (err_1 instanceof ServiceError) {
|
|
178
|
+
if (codes.length === 0) {
|
|
179
|
+
return [2 /*return*/, null];
|
|
180
|
+
}
|
|
108
181
|
for (_i = 0, codes_1 = codes; _i < codes_1.length; _i++) {
|
|
109
182
|
code = codes_1[_i];
|
|
110
183
|
if (err_1.status === code || err_1.code === code) {
|
|
@@ -118,6 +191,34 @@ var ServiceError = /** @class */ (function (_super) {
|
|
|
118
191
|
});
|
|
119
192
|
});
|
|
120
193
|
};
|
|
194
|
+
/**
|
|
195
|
+
* Returns a promise that resolves to either T or a ServiceError.
|
|
196
|
+
*/
|
|
197
|
+
ServiceError.combine = function (response) {
|
|
198
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
199
|
+
var body, err_2;
|
|
200
|
+
return __generator(this, function (_b) {
|
|
201
|
+
switch (_b.label) {
|
|
202
|
+
case 0:
|
|
203
|
+
_b.trys.push([0, 2, , 3]);
|
|
204
|
+
return [4 /*yield*/, response];
|
|
205
|
+
case 1:
|
|
206
|
+
body = _b.sent();
|
|
207
|
+
return [2 /*return*/, { ok: true, body: body }];
|
|
208
|
+
case 2:
|
|
209
|
+
err_2 = _b.sent();
|
|
210
|
+
if (err_2 instanceof ServiceError) {
|
|
211
|
+
return [2 /*return*/, { ok: false, err: err_2 }];
|
|
212
|
+
}
|
|
213
|
+
throw err_2;
|
|
214
|
+
case 3: return [2 /*return*/];
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
});
|
|
218
|
+
};
|
|
219
|
+
/**
|
|
220
|
+
* Constructs a ServiceError from the provided response data.
|
|
221
|
+
*/
|
|
121
222
|
ServiceError.from_res = function (res) {
|
|
122
223
|
var message = res.body;
|
|
123
224
|
var code = res.status;
|
|
@@ -134,6 +235,10 @@ var ServiceError = /** @class */ (function (_super) {
|
|
|
134
235
|
return ServiceError;
|
|
135
236
|
}(Error));
|
|
136
237
|
exports.ServiceError = ServiceError;
|
|
238
|
+
/**
|
|
239
|
+
* BaseServiceClient contains the logic for executing http requests.
|
|
240
|
+
* This class is meant to be extended by the generated code.
|
|
241
|
+
*/
|
|
137
242
|
var BaseServiceClient = /** @class */ (function () {
|
|
138
243
|
function BaseServiceClient(options) {
|
|
139
244
|
this.options = options !== null && options !== void 0 ? options : {};
|
|
@@ -141,8 +246,8 @@ var BaseServiceClient = /** @class */ (function () {
|
|
|
141
246
|
/**
|
|
142
247
|
* Combine the route and query parameters into a full url.
|
|
143
248
|
*/
|
|
144
|
-
BaseServiceClient.prototype.build_url = function (route,
|
|
145
|
-
var base_url =
|
|
249
|
+
BaseServiceClient.prototype.build_url = function (route, _b, params) {
|
|
250
|
+
var base_url = _b.base_url, _c = _b.stage, stage = _c === void 0 ? "dev" : _c;
|
|
146
251
|
var url = "https://api.compassdigital.org/" + stage + route;
|
|
147
252
|
// use the base url if one was provided.
|
|
148
253
|
if (base_url) {
|
|
@@ -153,8 +258,8 @@ var BaseServiceClient = /** @class */ (function () {
|
|
|
153
258
|
}
|
|
154
259
|
// add query parameters.
|
|
155
260
|
var query = [];
|
|
156
|
-
for (var _i = 0,
|
|
157
|
-
var
|
|
261
|
+
for (var _i = 0, _d = Object.entries(params); _i < _d.length; _i++) {
|
|
262
|
+
var _e = _d[_i], name_1 = _e[0], value = _e[1];
|
|
158
263
|
query.push(encodeURIComponent(name_1) + "=" + encodeURIComponent(value));
|
|
159
264
|
}
|
|
160
265
|
if (query.length > 0) {
|
|
@@ -162,12 +267,16 @@ var BaseServiceClient = /** @class */ (function () {
|
|
|
162
267
|
}
|
|
163
268
|
return url;
|
|
164
269
|
};
|
|
270
|
+
/**
|
|
271
|
+
* Perform the http request or pass it to the intercept function
|
|
272
|
+
* if one was configured.
|
|
273
|
+
*/
|
|
165
274
|
BaseServiceClient.prototype.fetch = function (req, options) {
|
|
166
275
|
return __awaiter(this, void 0, void 0, function () {
|
|
167
276
|
var res;
|
|
168
|
-
var
|
|
169
|
-
return __generator(this, function (
|
|
170
|
-
switch (
|
|
277
|
+
var _b;
|
|
278
|
+
return __generator(this, function (_c) {
|
|
279
|
+
switch (_c.label) {
|
|
171
280
|
case 0:
|
|
172
281
|
if (options === null || options === void 0 ? void 0 : options.intercept) {
|
|
173
282
|
return [2 /*return*/, options.intercept(req, this.fetch.bind(this))];
|
|
@@ -178,37 +287,52 @@ var BaseServiceClient = /** @class */ (function () {
|
|
|
178
287
|
headers: req.headers,
|
|
179
288
|
})];
|
|
180
289
|
case 1:
|
|
181
|
-
res =
|
|
182
|
-
|
|
290
|
+
res = _c.sent();
|
|
291
|
+
_b = {
|
|
183
292
|
ok: res.ok,
|
|
184
293
|
status: res.status
|
|
185
294
|
};
|
|
186
295
|
return [4 /*yield*/, res.text()];
|
|
187
|
-
case 2: return [2 /*return*/, (
|
|
188
|
-
|
|
296
|
+
case 2: return [2 /*return*/, (_b.body = _c.sent(),
|
|
297
|
+
_b)];
|
|
189
298
|
}
|
|
190
299
|
});
|
|
191
300
|
});
|
|
192
301
|
};
|
|
302
|
+
/**
|
|
303
|
+
* Returns true if the response status was a 4xx error.
|
|
304
|
+
*/
|
|
193
305
|
BaseServiceClient.prototype.is_4xx = function (res) {
|
|
194
306
|
return 400 <= res.status && res.status < 500;
|
|
195
307
|
};
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
return __assign(__assign(__assign(
|
|
308
|
+
/**
|
|
309
|
+
* Returns the merged options.
|
|
310
|
+
*/
|
|
311
|
+
BaseServiceClient.prototype.get_options = function (options) {
|
|
312
|
+
return __assign(__assign(__assign({}, this.options), options), { headers: __assign(__assign({}, this.options.headers), options.headers) });
|
|
201
313
|
};
|
|
314
|
+
/**
|
|
315
|
+
* A delegate to _request that wraps the response in a ResponsePromise.
|
|
316
|
+
*/
|
|
202
317
|
BaseServiceClient.prototype.request = function (service, name, method, route, body, options) {
|
|
203
|
-
|
|
318
|
+
if (options === void 0) { options = {}; }
|
|
319
|
+
var promise = this._request(service, name, method, route, body, options);
|
|
320
|
+
return new ResponsePromise(promise);
|
|
321
|
+
};
|
|
322
|
+
/**
|
|
323
|
+
* The main logic for fulfilling a request as perscribed by
|
|
324
|
+
* the request options.
|
|
325
|
+
*/
|
|
326
|
+
BaseServiceClient.prototype._request = function (service, name, method, route, body, options) {
|
|
327
|
+
var _b;
|
|
204
328
|
if (options === void 0) { options = {}; }
|
|
205
329
|
return __awaiter(this, void 0, void 0, function () {
|
|
206
330
|
var url, headers, req, res, err, data;
|
|
207
|
-
return __generator(this, function (
|
|
208
|
-
switch (
|
|
331
|
+
return __generator(this, function (_c) {
|
|
332
|
+
switch (_c.label) {
|
|
209
333
|
case 0:
|
|
210
|
-
options = this.get_options(
|
|
211
|
-
url = this.build_url(route, options, (
|
|
334
|
+
options = this.get_options(options);
|
|
335
|
+
url = this.build_url(route, options, (_b = options.query) !== null && _b !== void 0 ? _b : {});
|
|
212
336
|
headers = Object.assign({
|
|
213
337
|
"User-Agent": "CDL/ServiceClient"
|
|
214
338
|
}, options.headers);
|
|
@@ -224,7 +348,7 @@ var BaseServiceClient = /** @class */ (function () {
|
|
|
224
348
|
}
|
|
225
349
|
return [4 /*yield*/, this.fetch(req, options)];
|
|
226
350
|
case 1:
|
|
227
|
-
res =
|
|
351
|
+
res = _c.sent();
|
|
228
352
|
if (!res.ok) {
|
|
229
353
|
err = ServiceError.from_res(res);
|
|
230
354
|
if (options.debug) {
|
package/lib/base.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.js","sourceRoot":"","sources":["../src/base.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"base.js","sourceRoot":"","sources":["../src/base.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,4DAAgC;AAqDhC;;;GA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