@aws-amplify/api 4.0.29 → 4.0.30-custom-pk.79
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/CHANGELOG.md +142 -0
- package/dist/aws-amplify-api.js +696 -516
- package/dist/aws-amplify-api.js.map +1 -1
- package/dist/aws-amplify-api.min.js +3 -3
- package/dist/aws-amplify-api.min.js.map +1 -1
- package/lib/API.d.ts +63 -45
- package/lib/API.js +39 -39
- package/lib/API.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js.map +1 -1
- package/lib/types/index.d.ts +7 -0
- package/lib-esm/API.d.ts +63 -45
- package/lib-esm/API.js +39 -39
- package/lib-esm/API.js.map +1 -1
- package/lib-esm/index.d.ts +1 -0
- package/lib-esm/index.js.map +1 -1
- package/lib-esm/types/index.d.ts +7 -0
- package/package.json +4 -4
- package/src/API.ts +93 -48
- package/src/index.ts +2 -0
- package/src/types/index.ts +8 -0
package/lib/API.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AWSAppSyncRealTimeProvider } from '@aws-amplify/pubsub';
|
|
2
|
+
import { GraphQLOptions, GraphQLResult, GraphQLOperation, OperationTypeNode } from '@aws-amplify/api-graphql';
|
|
2
3
|
import Observable from 'zen-observable-ts';
|
|
4
|
+
import { GraphQLQuery, GraphQLSubscription } from './types';
|
|
3
5
|
/**
|
|
4
6
|
* @deprecated
|
|
5
7
|
* Use RestApi or GraphQLAPI to reduce your application bundle size
|
|
@@ -30,84 +32,100 @@ export declare class APIClass {
|
|
|
30
32
|
configure(options: any): any;
|
|
31
33
|
/**
|
|
32
34
|
* Make a GET request
|
|
33
|
-
* @param
|
|
34
|
-
* @param
|
|
35
|
-
* @param
|
|
36
|
-
* @return
|
|
35
|
+
* @param apiName - The api name of the request
|
|
36
|
+
* @param path - The path of the request
|
|
37
|
+
* @param [init] - Request extra params
|
|
38
|
+
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
37
39
|
*/
|
|
38
|
-
get(apiName:
|
|
40
|
+
get(apiName: string, path: string, init: {
|
|
41
|
+
[key: string]: any;
|
|
42
|
+
}): Promise<any>;
|
|
39
43
|
/**
|
|
40
44
|
* Make a POST request
|
|
41
|
-
* @param
|
|
42
|
-
* @param
|
|
43
|
-
* @param
|
|
44
|
-
* @return
|
|
45
|
+
* @param apiName - The api name of the request
|
|
46
|
+
* @param path - The path of the request
|
|
47
|
+
* @param [init] - Request extra params
|
|
48
|
+
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
45
49
|
*/
|
|
46
|
-
post(apiName:
|
|
50
|
+
post(apiName: string, path: string, init: {
|
|
51
|
+
[key: string]: any;
|
|
52
|
+
}): Promise<any>;
|
|
47
53
|
/**
|
|
48
54
|
* Make a PUT request
|
|
49
|
-
* @param
|
|
50
|
-
* @param
|
|
51
|
-
* @param
|
|
52
|
-
* @return
|
|
55
|
+
* @param apiName - The api name of the request
|
|
56
|
+
* @param path - The path of the request
|
|
57
|
+
* @param [init] - Request extra params
|
|
58
|
+
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
53
59
|
*/
|
|
54
|
-
put(apiName:
|
|
60
|
+
put(apiName: string, path: string, init: {
|
|
61
|
+
[key: string]: any;
|
|
62
|
+
}): Promise<any>;
|
|
55
63
|
/**
|
|
56
64
|
* Make a PATCH request
|
|
57
|
-
* @param
|
|
58
|
-
* @param
|
|
59
|
-
* @param
|
|
60
|
-
* @return
|
|
65
|
+
* @param apiName - The api name of the request
|
|
66
|
+
* @param path - The path of the request
|
|
67
|
+
* @param [init] - Request extra params
|
|
68
|
+
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
61
69
|
*/
|
|
62
|
-
patch(apiName:
|
|
70
|
+
patch(apiName: string, path: string, init: {
|
|
71
|
+
[key: string]: any;
|
|
72
|
+
}): Promise<any>;
|
|
63
73
|
/**
|
|
64
74
|
* Make a DEL request
|
|
65
|
-
* @param
|
|
66
|
-
* @param
|
|
67
|
-
* @param
|
|
68
|
-
* @return
|
|
75
|
+
* @param apiName - The api name of the request
|
|
76
|
+
* @param path - The path of the request
|
|
77
|
+
* @param [init] - Request extra params
|
|
78
|
+
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
69
79
|
*/
|
|
70
|
-
del(apiName:
|
|
80
|
+
del(apiName: string, path: string, init: {
|
|
81
|
+
[key: string]: any;
|
|
82
|
+
}): Promise<any>;
|
|
71
83
|
/**
|
|
72
84
|
* Make a HEAD request
|
|
73
|
-
* @param
|
|
74
|
-
* @param
|
|
75
|
-
* @param
|
|
76
|
-
* @return
|
|
85
|
+
* @param apiName - The api name of the request
|
|
86
|
+
* @param path - The path of the request
|
|
87
|
+
* @param [init] - Request extra params
|
|
88
|
+
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
77
89
|
*/
|
|
78
|
-
head(apiName:
|
|
90
|
+
head(apiName: string, path: string, init: {
|
|
91
|
+
[key: string]: any;
|
|
92
|
+
}): Promise<any>;
|
|
79
93
|
/**
|
|
80
94
|
* Checks to see if an error thrown is from an api request cancellation
|
|
81
|
-
* @param
|
|
82
|
-
* @return
|
|
95
|
+
* @param error - Any error
|
|
96
|
+
* @return If the error was from an api request cancellation
|
|
83
97
|
*/
|
|
84
98
|
isCancel(error: any): boolean;
|
|
85
99
|
/**
|
|
86
|
-
* Cancels an inflight request
|
|
87
|
-
* @param
|
|
88
|
-
* @
|
|
100
|
+
* Cancels an inflight request for either a GraphQL request or a Rest API request.
|
|
101
|
+
* @param request - request to cancel
|
|
102
|
+
* @param [message] - custom error message
|
|
103
|
+
* @return If the request was cancelled
|
|
89
104
|
*/
|
|
90
105
|
cancel(request: Promise<any>, message?: string): boolean;
|
|
91
106
|
/**
|
|
92
107
|
* Getting endpoint for API
|
|
93
|
-
* @param
|
|
94
|
-
* @return
|
|
108
|
+
* @param apiName - The name of the api
|
|
109
|
+
* @return The endpoint of the api
|
|
95
110
|
*/
|
|
96
|
-
endpoint(apiName:
|
|
111
|
+
endpoint(apiName: string): Promise<string>;
|
|
97
112
|
/**
|
|
98
113
|
* to get the operation type
|
|
99
114
|
* @param operation
|
|
100
115
|
*/
|
|
101
|
-
getGraphqlOperationType(operation:
|
|
116
|
+
getGraphqlOperationType(operation: GraphQLOperation): OperationTypeNode;
|
|
102
117
|
/**
|
|
103
118
|
* Executes a GraphQL operation
|
|
104
119
|
*
|
|
105
|
-
* @param
|
|
106
|
-
* @param
|
|
107
|
-
* @returns
|
|
120
|
+
* @param options - GraphQL Options
|
|
121
|
+
* @param [additionalHeaders] - headers to merge in after any `graphql_headers` set in the config
|
|
122
|
+
* @returns An Observable if queryType is 'subscription', else a promise of the graphql result from the query.
|
|
108
123
|
*/
|
|
109
|
-
graphql(options: GraphQLOptions, additionalHeaders?: {
|
|
124
|
+
graphql<T>(options: GraphQLOptions, additionalHeaders?: {
|
|
110
125
|
[key: string]: string;
|
|
111
|
-
}): Promise<GraphQLResult>
|
|
126
|
+
}): T extends GraphQLQuery<T> ? Promise<GraphQLResult<T>> : T extends GraphQLSubscription<T> ? Observable<{
|
|
127
|
+
provider: AWSAppSyncRealTimeProvider;
|
|
128
|
+
value: GraphQLResult<T>;
|
|
129
|
+
}> : Promise<GraphQLResult<any>> | Observable<object>;
|
|
112
130
|
}
|
|
113
131
|
export declare const API: APIClass;
|
package/lib/API.js
CHANGED
|
@@ -108,84 +108,91 @@ var APIClass = /** @class */ (function () {
|
|
|
108
108
|
};
|
|
109
109
|
/**
|
|
110
110
|
* Make a GET request
|
|
111
|
-
* @param
|
|
112
|
-
* @param
|
|
113
|
-
* @param
|
|
114
|
-
* @return
|
|
111
|
+
* @param apiName - The api name of the request
|
|
112
|
+
* @param path - The path of the request
|
|
113
|
+
* @param [init] - Request extra params
|
|
114
|
+
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
115
115
|
*/
|
|
116
116
|
APIClass.prototype.get = function (apiName, path, init) {
|
|
117
117
|
return this._restApi.get(apiName, path, init);
|
|
118
118
|
};
|
|
119
119
|
/**
|
|
120
120
|
* Make a POST request
|
|
121
|
-
* @param
|
|
122
|
-
* @param
|
|
123
|
-
* @param
|
|
124
|
-
* @return
|
|
121
|
+
* @param apiName - The api name of the request
|
|
122
|
+
* @param path - The path of the request
|
|
123
|
+
* @param [init] - Request extra params
|
|
124
|
+
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
125
125
|
*/
|
|
126
126
|
APIClass.prototype.post = function (apiName, path, init) {
|
|
127
127
|
return this._restApi.post(apiName, path, init);
|
|
128
128
|
};
|
|
129
129
|
/**
|
|
130
130
|
* Make a PUT request
|
|
131
|
-
* @param
|
|
132
|
-
* @param
|
|
133
|
-
* @param
|
|
134
|
-
* @return
|
|
131
|
+
* @param apiName - The api name of the request
|
|
132
|
+
* @param path - The path of the request
|
|
133
|
+
* @param [init] - Request extra params
|
|
134
|
+
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
135
135
|
*/
|
|
136
136
|
APIClass.prototype.put = function (apiName, path, init) {
|
|
137
137
|
return this._restApi.put(apiName, path, init);
|
|
138
138
|
};
|
|
139
139
|
/**
|
|
140
140
|
* Make a PATCH request
|
|
141
|
-
* @param
|
|
142
|
-
* @param
|
|
143
|
-
* @param
|
|
144
|
-
* @return
|
|
141
|
+
* @param apiName - The api name of the request
|
|
142
|
+
* @param path - The path of the request
|
|
143
|
+
* @param [init] - Request extra params
|
|
144
|
+
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
145
145
|
*/
|
|
146
146
|
APIClass.prototype.patch = function (apiName, path, init) {
|
|
147
147
|
return this._restApi.patch(apiName, path, init);
|
|
148
148
|
};
|
|
149
149
|
/**
|
|
150
150
|
* Make a DEL request
|
|
151
|
-
* @param
|
|
152
|
-
* @param
|
|
153
|
-
* @param
|
|
154
|
-
* @return
|
|
151
|
+
* @param apiName - The api name of the request
|
|
152
|
+
* @param path - The path of the request
|
|
153
|
+
* @param [init] - Request extra params
|
|
154
|
+
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
155
155
|
*/
|
|
156
156
|
APIClass.prototype.del = function (apiName, path, init) {
|
|
157
157
|
return this._restApi.del(apiName, path, init);
|
|
158
158
|
};
|
|
159
159
|
/**
|
|
160
160
|
* Make a HEAD request
|
|
161
|
-
* @param
|
|
162
|
-
* @param
|
|
163
|
-
* @param
|
|
164
|
-
* @return
|
|
161
|
+
* @param apiName - The api name of the request
|
|
162
|
+
* @param path - The path of the request
|
|
163
|
+
* @param [init] - Request extra params
|
|
164
|
+
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
165
165
|
*/
|
|
166
166
|
APIClass.prototype.head = function (apiName, path, init) {
|
|
167
167
|
return this._restApi.head(apiName, path, init);
|
|
168
168
|
};
|
|
169
169
|
/**
|
|
170
170
|
* Checks to see if an error thrown is from an api request cancellation
|
|
171
|
-
* @param
|
|
172
|
-
* @return
|
|
171
|
+
* @param error - Any error
|
|
172
|
+
* @return If the error was from an api request cancellation
|
|
173
173
|
*/
|
|
174
174
|
APIClass.prototype.isCancel = function (error) {
|
|
175
175
|
return this._restApi.isCancel(error);
|
|
176
176
|
};
|
|
177
177
|
/**
|
|
178
|
-
* Cancels an inflight request
|
|
179
|
-
* @param
|
|
180
|
-
* @
|
|
178
|
+
* Cancels an inflight request for either a GraphQL request or a Rest API request.
|
|
179
|
+
* @param request - request to cancel
|
|
180
|
+
* @param [message] - custom error message
|
|
181
|
+
* @return If the request was cancelled
|
|
181
182
|
*/
|
|
182
183
|
APIClass.prototype.cancel = function (request, message) {
|
|
183
|
-
|
|
184
|
+
if (this._restApi.hasCancelToken(request)) {
|
|
185
|
+
return this._restApi.cancel(request, message);
|
|
186
|
+
}
|
|
187
|
+
else if (this._graphqlApi.hasCancelToken(request)) {
|
|
188
|
+
return this._graphqlApi.cancel(request, message);
|
|
189
|
+
}
|
|
190
|
+
return false;
|
|
184
191
|
};
|
|
185
192
|
/**
|
|
186
193
|
* Getting endpoint for API
|
|
187
|
-
* @param
|
|
188
|
-
* @return
|
|
194
|
+
* @param apiName - The name of the api
|
|
195
|
+
* @return The endpoint of the api
|
|
189
196
|
*/
|
|
190
197
|
APIClass.prototype.endpoint = function (apiName) {
|
|
191
198
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -201,13 +208,6 @@ var APIClass = /** @class */ (function () {
|
|
|
201
208
|
APIClass.prototype.getGraphqlOperationType = function (operation) {
|
|
202
209
|
return this._graphqlApi.getGraphqlOperationType(operation);
|
|
203
210
|
};
|
|
204
|
-
/**
|
|
205
|
-
* Executes a GraphQL operation
|
|
206
|
-
*
|
|
207
|
-
* @param {GraphQLOptions} GraphQL Options
|
|
208
|
-
* @param {object} additionalHeaders headers to merge in after any `graphql_headers` set in the config
|
|
209
|
-
* @returns {Promise<GraphQLResult> | Observable<object>}
|
|
210
|
-
*/
|
|
211
211
|
APIClass.prototype.graphql = function (options, additionalHeaders) {
|
|
212
212
|
return this._graphqlApi.graphql(options, additionalHeaders);
|
|
213
213
|
};
|
package/lib/API.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"API.js","sourceRoot":"","sources":["../src/API.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;GAWG;AACH,0CAAyC;AACzC,6DAAuC;
|
|
1
|
+
{"version":3,"file":"API.js","sourceRoot":"","sources":["../src/API.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;GAWG;AACH,0CAAyC;AACzC,6DAAuC;AAEvC,kDAAqD;AACrD,wDAMkC;AAClC,0CAI2B;AAI3B,IAAM,MAAM,GAAG,IAAI,oBAAM,CAAC,KAAK,CAAC,CAAC;AACjC;;;;GAIG;AACH;IAaC;;;OAGG;IACH,kBAAY,OAAO;QARnB,SAAI,GAAG,WAAI,CAAC;QACZ,UAAK,GAAG,eAA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AW,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE;YACpD,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;SACjD;QACD,OAAO,KAAK,CAAC;IACd,CAAC;IAED;;;;OAIG;IACG,2BAAQ,GAAd,UAAe,OAAe;;;gBAC7B,sBAAO,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAC;;;KACvC;IAED;;;OAGG;IACH,0CAAuB,GAAvB,UAAwB,SAA2B;QAClD,OAAO,IAAI,CAAC,WAAW,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC;IAC5D,CAAC;IAoBD,0BAAO,GAAP,UACC,OAAuB,EACvB,iBAA6C;QAE7C,OAAO,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC;IAC7D,CAAC;IACF,eAAC;AAAD,CAAC,AA3MD,IA2MC;AA3MY,4BAAQ;AA6MR,QAAA,GAAG,GAAG,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC;AACtC,cAAO,CAAC,QAAQ,CAAC,WAAG,CAAC,CAAC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { API } from './API';
|
|
2
|
+
export { GraphQLQuery, GraphQLSubscription } from './types';
|
|
2
3
|
export { API, APIClass } from './API';
|
|
3
4
|
export { graphqlOperation, GraphQLAuthError, GRAPHQL_AUTH_MODE, } from '@aws-amplify/api-graphql';
|
|
4
5
|
export type { GraphQLResult } from '@aws-amplify/api-graphql';
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;AAEH,6BAA4B;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;AAEH,6BAA4B;AAG5B,6BAAsC;AAA7B,oBAAA,GAAG,CAAA;AAAE,yBAAA,QAAQ,CAAA;AACtB,wDAIkC;AAHjC,yCAAA,gBAAgB,CAAA;AAChB,yCAAA,gBAAgB,CAAA;AAChB,0CAAA,iBAAiB,CAAA;AAKlB;;GAEG;AACH,kBAAe,SAAG,CAAC"}
|
package/lib/types/index.d.ts
CHANGED
|
@@ -4,3 +4,10 @@
|
|
|
4
4
|
* This will be removed in future release when CLI and customers moves to recommeneded import styles.
|
|
5
5
|
*/
|
|
6
6
|
export { graphqlOperation, GraphQLAuthError, GraphQLResult, GRAPHQL_AUTH_MODE, } from '@aws-amplify/api-graphql';
|
|
7
|
+
declare const queryType: unique symbol;
|
|
8
|
+
export declare type GraphQLQuery<T> = T & {
|
|
9
|
+
readonly [queryType]: 'query';
|
|
10
|
+
};
|
|
11
|
+
export declare type GraphQLSubscription<T> = T & {
|
|
12
|
+
readonly [queryType]: 'subscription';
|
|
13
|
+
};
|
package/lib-esm/API.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AWSAppSyncRealTimeProvider } from '@aws-amplify/pubsub';
|
|
2
|
+
import { GraphQLOptions, GraphQLResult, GraphQLOperation, OperationTypeNode } from '@aws-amplify/api-graphql';
|
|
2
3
|
import Observable from 'zen-observable-ts';
|
|
4
|
+
import { GraphQLQuery, GraphQLSubscription } from './types';
|
|
3
5
|
/**
|
|
4
6
|
* @deprecated
|
|
5
7
|
* Use RestApi or GraphQLAPI to reduce your application bundle size
|
|
@@ -30,84 +32,100 @@ export declare class APIClass {
|
|
|
30
32
|
configure(options: any): any;
|
|
31
33
|
/**
|
|
32
34
|
* Make a GET request
|
|
33
|
-
* @param
|
|
34
|
-
* @param
|
|
35
|
-
* @param
|
|
36
|
-
* @return
|
|
35
|
+
* @param apiName - The api name of the request
|
|
36
|
+
* @param path - The path of the request
|
|
37
|
+
* @param [init] - Request extra params
|
|
38
|
+
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
37
39
|
*/
|
|
38
|
-
get(apiName:
|
|
40
|
+
get(apiName: string, path: string, init: {
|
|
41
|
+
[key: string]: any;
|
|
42
|
+
}): Promise<any>;
|
|
39
43
|
/**
|
|
40
44
|
* Make a POST request
|
|
41
|
-
* @param
|
|
42
|
-
* @param
|
|
43
|
-
* @param
|
|
44
|
-
* @return
|
|
45
|
+
* @param apiName - The api name of the request
|
|
46
|
+
* @param path - The path of the request
|
|
47
|
+
* @param [init] - Request extra params
|
|
48
|
+
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
45
49
|
*/
|
|
46
|
-
post(apiName:
|
|
50
|
+
post(apiName: string, path: string, init: {
|
|
51
|
+
[key: string]: any;
|
|
52
|
+
}): Promise<any>;
|
|
47
53
|
/**
|
|
48
54
|
* Make a PUT request
|
|
49
|
-
* @param
|
|
50
|
-
* @param
|
|
51
|
-
* @param
|
|
52
|
-
* @return
|
|
55
|
+
* @param apiName - The api name of the request
|
|
56
|
+
* @param path - The path of the request
|
|
57
|
+
* @param [init] - Request extra params
|
|
58
|
+
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
53
59
|
*/
|
|
54
|
-
put(apiName:
|
|
60
|
+
put(apiName: string, path: string, init: {
|
|
61
|
+
[key: string]: any;
|
|
62
|
+
}): Promise<any>;
|
|
55
63
|
/**
|
|
56
64
|
* Make a PATCH request
|
|
57
|
-
* @param
|
|
58
|
-
* @param
|
|
59
|
-
* @param
|
|
60
|
-
* @return
|
|
65
|
+
* @param apiName - The api name of the request
|
|
66
|
+
* @param path - The path of the request
|
|
67
|
+
* @param [init] - Request extra params
|
|
68
|
+
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
61
69
|
*/
|
|
62
|
-
patch(apiName:
|
|
70
|
+
patch(apiName: string, path: string, init: {
|
|
71
|
+
[key: string]: any;
|
|
72
|
+
}): Promise<any>;
|
|
63
73
|
/**
|
|
64
74
|
* Make a DEL request
|
|
65
|
-
* @param
|
|
66
|
-
* @param
|
|
67
|
-
* @param
|
|
68
|
-
* @return
|
|
75
|
+
* @param apiName - The api name of the request
|
|
76
|
+
* @param path - The path of the request
|
|
77
|
+
* @param [init] - Request extra params
|
|
78
|
+
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
69
79
|
*/
|
|
70
|
-
del(apiName:
|
|
80
|
+
del(apiName: string, path: string, init: {
|
|
81
|
+
[key: string]: any;
|
|
82
|
+
}): Promise<any>;
|
|
71
83
|
/**
|
|
72
84
|
* Make a HEAD request
|
|
73
|
-
* @param
|
|
74
|
-
* @param
|
|
75
|
-
* @param
|
|
76
|
-
* @return
|
|
85
|
+
* @param apiName - The api name of the request
|
|
86
|
+
* @param path - The path of the request
|
|
87
|
+
* @param [init] - Request extra params
|
|
88
|
+
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
77
89
|
*/
|
|
78
|
-
head(apiName:
|
|
90
|
+
head(apiName: string, path: string, init: {
|
|
91
|
+
[key: string]: any;
|
|
92
|
+
}): Promise<any>;
|
|
79
93
|
/**
|
|
80
94
|
* Checks to see if an error thrown is from an api request cancellation
|
|
81
|
-
* @param
|
|
82
|
-
* @return
|
|
95
|
+
* @param error - Any error
|
|
96
|
+
* @return If the error was from an api request cancellation
|
|
83
97
|
*/
|
|
84
98
|
isCancel(error: any): boolean;
|
|
85
99
|
/**
|
|
86
|
-
* Cancels an inflight request
|
|
87
|
-
* @param
|
|
88
|
-
* @
|
|
100
|
+
* Cancels an inflight request for either a GraphQL request or a Rest API request.
|
|
101
|
+
* @param request - request to cancel
|
|
102
|
+
* @param [message] - custom error message
|
|
103
|
+
* @return If the request was cancelled
|
|
89
104
|
*/
|
|
90
105
|
cancel(request: Promise<any>, message?: string): boolean;
|
|
91
106
|
/**
|
|
92
107
|
* Getting endpoint for API
|
|
93
|
-
* @param
|
|
94
|
-
* @return
|
|
108
|
+
* @param apiName - The name of the api
|
|
109
|
+
* @return The endpoint of the api
|
|
95
110
|
*/
|
|
96
|
-
endpoint(apiName:
|
|
111
|
+
endpoint(apiName: string): Promise<string>;
|
|
97
112
|
/**
|
|
98
113
|
* to get the operation type
|
|
99
114
|
* @param operation
|
|
100
115
|
*/
|
|
101
|
-
getGraphqlOperationType(operation:
|
|
116
|
+
getGraphqlOperationType(operation: GraphQLOperation): OperationTypeNode;
|
|
102
117
|
/**
|
|
103
118
|
* Executes a GraphQL operation
|
|
104
119
|
*
|
|
105
|
-
* @param
|
|
106
|
-
* @param
|
|
107
|
-
* @returns
|
|
120
|
+
* @param options - GraphQL Options
|
|
121
|
+
* @param [additionalHeaders] - headers to merge in after any `graphql_headers` set in the config
|
|
122
|
+
* @returns An Observable if queryType is 'subscription', else a promise of the graphql result from the query.
|
|
108
123
|
*/
|
|
109
|
-
graphql(options: GraphQLOptions, additionalHeaders?: {
|
|
124
|
+
graphql<T>(options: GraphQLOptions, additionalHeaders?: {
|
|
110
125
|
[key: string]: string;
|
|
111
|
-
}): Promise<GraphQLResult>
|
|
126
|
+
}): T extends GraphQLQuery<T> ? Promise<GraphQLResult<T>> : T extends GraphQLSubscription<T> ? Observable<{
|
|
127
|
+
provider: AWSAppSyncRealTimeProvider;
|
|
128
|
+
value: GraphQLResult<T>;
|
|
129
|
+
}> : Promise<GraphQLResult<any>> | Observable<object>;
|
|
112
130
|
}
|
|
113
131
|
export declare const API: APIClass;
|
package/lib-esm/API.js
CHANGED
|
@@ -103,84 +103,91 @@ var APIClass = /** @class */ (function () {
|
|
|
103
103
|
};
|
|
104
104
|
/**
|
|
105
105
|
* Make a GET request
|
|
106
|
-
* @param
|
|
107
|
-
* @param
|
|
108
|
-
* @param
|
|
109
|
-
* @return
|
|
106
|
+
* @param apiName - The api name of the request
|
|
107
|
+
* @param path - The path of the request
|
|
108
|
+
* @param [init] - Request extra params
|
|
109
|
+
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
110
110
|
*/
|
|
111
111
|
APIClass.prototype.get = function (apiName, path, init) {
|
|
112
112
|
return this._restApi.get(apiName, path, init);
|
|
113
113
|
};
|
|
114
114
|
/**
|
|
115
115
|
* Make a POST request
|
|
116
|
-
* @param
|
|
117
|
-
* @param
|
|
118
|
-
* @param
|
|
119
|
-
* @return
|
|
116
|
+
* @param apiName - The api name of the request
|
|
117
|
+
* @param path - The path of the request
|
|
118
|
+
* @param [init] - Request extra params
|
|
119
|
+
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
120
120
|
*/
|
|
121
121
|
APIClass.prototype.post = function (apiName, path, init) {
|
|
122
122
|
return this._restApi.post(apiName, path, init);
|
|
123
123
|
};
|
|
124
124
|
/**
|
|
125
125
|
* Make a PUT request
|
|
126
|
-
* @param
|
|
127
|
-
* @param
|
|
128
|
-
* @param
|
|
129
|
-
* @return
|
|
126
|
+
* @param apiName - The api name of the request
|
|
127
|
+
* @param path - The path of the request
|
|
128
|
+
* @param [init] - Request extra params
|
|
129
|
+
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
130
130
|
*/
|
|
131
131
|
APIClass.prototype.put = function (apiName, path, init) {
|
|
132
132
|
return this._restApi.put(apiName, path, init);
|
|
133
133
|
};
|
|
134
134
|
/**
|
|
135
135
|
* Make a PATCH request
|
|
136
|
-
* @param
|
|
137
|
-
* @param
|
|
138
|
-
* @param
|
|
139
|
-
* @return
|
|
136
|
+
* @param apiName - The api name of the request
|
|
137
|
+
* @param path - The path of the request
|
|
138
|
+
* @param [init] - Request extra params
|
|
139
|
+
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
140
140
|
*/
|
|
141
141
|
APIClass.prototype.patch = function (apiName, path, init) {
|
|
142
142
|
return this._restApi.patch(apiName, path, init);
|
|
143
143
|
};
|
|
144
144
|
/**
|
|
145
145
|
* Make a DEL request
|
|
146
|
-
* @param
|
|
147
|
-
* @param
|
|
148
|
-
* @param
|
|
149
|
-
* @return
|
|
146
|
+
* @param apiName - The api name of the request
|
|
147
|
+
* @param path - The path of the request
|
|
148
|
+
* @param [init] - Request extra params
|
|
149
|
+
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
150
150
|
*/
|
|
151
151
|
APIClass.prototype.del = function (apiName, path, init) {
|
|
152
152
|
return this._restApi.del(apiName, path, init);
|
|
153
153
|
};
|
|
154
154
|
/**
|
|
155
155
|
* Make a HEAD request
|
|
156
|
-
* @param
|
|
157
|
-
* @param
|
|
158
|
-
* @param
|
|
159
|
-
* @return
|
|
156
|
+
* @param apiName - The api name of the request
|
|
157
|
+
* @param path - The path of the request
|
|
158
|
+
* @param [init] - Request extra params
|
|
159
|
+
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
160
160
|
*/
|
|
161
161
|
APIClass.prototype.head = function (apiName, path, init) {
|
|
162
162
|
return this._restApi.head(apiName, path, init);
|
|
163
163
|
};
|
|
164
164
|
/**
|
|
165
165
|
* Checks to see if an error thrown is from an api request cancellation
|
|
166
|
-
* @param
|
|
167
|
-
* @return
|
|
166
|
+
* @param error - Any error
|
|
167
|
+
* @return If the error was from an api request cancellation
|
|
168
168
|
*/
|
|
169
169
|
APIClass.prototype.isCancel = function (error) {
|
|
170
170
|
return this._restApi.isCancel(error);
|
|
171
171
|
};
|
|
172
172
|
/**
|
|
173
|
-
* Cancels an inflight request
|
|
174
|
-
* @param
|
|
175
|
-
* @
|
|
173
|
+
* Cancels an inflight request for either a GraphQL request or a Rest API request.
|
|
174
|
+
* @param request - request to cancel
|
|
175
|
+
* @param [message] - custom error message
|
|
176
|
+
* @return If the request was cancelled
|
|
176
177
|
*/
|
|
177
178
|
APIClass.prototype.cancel = function (request, message) {
|
|
178
|
-
|
|
179
|
+
if (this._restApi.hasCancelToken(request)) {
|
|
180
|
+
return this._restApi.cancel(request, message);
|
|
181
|
+
}
|
|
182
|
+
else if (this._graphqlApi.hasCancelToken(request)) {
|
|
183
|
+
return this._graphqlApi.cancel(request, message);
|
|
184
|
+
}
|
|
185
|
+
return false;
|
|
179
186
|
};
|
|
180
187
|
/**
|
|
181
188
|
* Getting endpoint for API
|
|
182
|
-
* @param
|
|
183
|
-
* @return
|
|
189
|
+
* @param apiName - The name of the api
|
|
190
|
+
* @return The endpoint of the api
|
|
184
191
|
*/
|
|
185
192
|
APIClass.prototype.endpoint = function (apiName) {
|
|
186
193
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -196,13 +203,6 @@ var APIClass = /** @class */ (function () {
|
|
|
196
203
|
APIClass.prototype.getGraphqlOperationType = function (operation) {
|
|
197
204
|
return this._graphqlApi.getGraphqlOperationType(operation);
|
|
198
205
|
};
|
|
199
|
-
/**
|
|
200
|
-
* Executes a GraphQL operation
|
|
201
|
-
*
|
|
202
|
-
* @param {GraphQLOptions} GraphQL Options
|
|
203
|
-
* @param {object} additionalHeaders headers to merge in after any `graphql_headers` set in the config
|
|
204
|
-
* @returns {Promise<GraphQLResult> | Observable<object>}
|
|
205
|
-
*/
|
|
206
206
|
APIClass.prototype.graphql = function (options, additionalHeaders) {
|
|
207
207
|
return this._graphqlApi.graphql(options, additionalHeaders);
|
|
208
208
|
};
|