@aws-amplify/api 5.4.5 → 6.0.1-console-preview.047a1dd.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/README.md +3 -0
- package/lib/API.d.ts +16 -3
- package/lib/API.js +10 -3
- package/lib/API.js.map +1 -1
- package/lib/index.d.ts +6 -2
- package/lib/index.js +2 -1
- package/lib/index.js.map +1 -1
- package/lib/internals/InternalAPI.d.ts +3 -81
- package/lib/internals/InternalAPI.js +6 -113
- package/lib/internals/InternalAPI.js.map +1 -1
- package/lib/types/index.d.ts +1 -8
- package/lib/types/index.js +0 -1
- package/lib/types/index.js.map +1 -1
- package/lib-esm/API.d.ts +16 -3
- package/lib-esm/API.js +10 -3
- package/lib-esm/API.js.map +1 -1
- package/lib-esm/index.d.ts +6 -2
- package/lib-esm/index.js +4 -2
- package/lib-esm/index.js.map +1 -1
- package/lib-esm/internals/InternalAPI.d.ts +3 -81
- package/lib-esm/internals/InternalAPI.js +6 -113
- package/lib-esm/internals/InternalAPI.js.map +1 -1
- package/lib-esm/types/index.d.ts +1 -8
- package/lib-esm/types/index.js +1 -1
- package/lib-esm/types/index.js.map +1 -1
- package/package.json +9 -8
- package/src/API.ts +31 -6
- package/src/index.ts +8 -2
- package/src/internals/InternalAPI.ts +9 -177
- package/src/types/index.ts +3 -9
package/README.md
ADDED
package/lib/API.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { AWSAppSyncRealTimeProvider } from '@aws-amplify/
|
|
2
|
-
import {
|
|
1
|
+
import { AWSAppSyncRealTimeProvider, GraphQLOptions, GraphQLResult, GraphQLQuery, GraphQLSubscription } from '@aws-amplify/api-graphql';
|
|
2
|
+
import { graphql as v6graphql } from '@aws-amplify/api-graphql/internals';
|
|
3
3
|
import Observable from 'zen-observable-ts';
|
|
4
|
-
import { GraphQLQuery, GraphQLSubscription } from './types';
|
|
5
4
|
import { InternalAPIClass } from './internals/InternalAPI';
|
|
6
5
|
/**
|
|
7
6
|
* @deprecated
|
|
@@ -23,5 +22,19 @@ export declare class APIClass extends InternalAPIClass {
|
|
|
23
22
|
provider: AWSAppSyncRealTimeProvider;
|
|
24
23
|
value: GraphQLResult<T>;
|
|
25
24
|
}> : Promise<GraphQLResult<any>> | Observable<object>;
|
|
25
|
+
/**
|
|
26
|
+
* Generates an API client that can work with models or raw GraphQL
|
|
27
|
+
*/
|
|
28
|
+
generateClient<T extends Record<any, any> = never>(): V6Client<T>;
|
|
26
29
|
}
|
|
30
|
+
declare type FilteredKeys<T> = {
|
|
31
|
+
[P in keyof T]: T[P] extends never ? never : P;
|
|
32
|
+
}[keyof T];
|
|
33
|
+
declare type ExcludeNeverFields<O> = {
|
|
34
|
+
[K in FilteredKeys<O>]: O[K];
|
|
35
|
+
};
|
|
36
|
+
declare type V6Client<T extends Record<any, any> = never> = ExcludeNeverFields<{
|
|
37
|
+
graphql: typeof v6graphql;
|
|
38
|
+
}>;
|
|
27
39
|
export declare const API: APIClass;
|
|
40
|
+
export {};
|
package/lib/API.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
var tslib_1 = require("tslib");
|
|
4
|
-
var
|
|
4
|
+
var internals_1 = require("@aws-amplify/api-graphql/internals");
|
|
5
5
|
var InternalAPI_1 = require("./internals/InternalAPI");
|
|
6
|
-
var logger = new core_1.ConsoleLogger('API');
|
|
7
6
|
/**
|
|
8
7
|
* @deprecated
|
|
9
8
|
* Use RestApi or GraphQLAPI to reduce your application bundle size
|
|
@@ -20,9 +19,17 @@ var APIClass = /** @class */ (function (_super) {
|
|
|
20
19
|
APIClass.prototype.graphql = function (options, additionalHeaders) {
|
|
21
20
|
return _super.prototype.graphql.call(this, options, additionalHeaders);
|
|
22
21
|
};
|
|
22
|
+
/**
|
|
23
|
+
* Generates an API client that can work with models or raw GraphQL
|
|
24
|
+
*/
|
|
25
|
+
APIClass.prototype.generateClient = function () {
|
|
26
|
+
var client = {
|
|
27
|
+
graphql: internals_1.graphql,
|
|
28
|
+
};
|
|
29
|
+
return client;
|
|
30
|
+
};
|
|
23
31
|
return APIClass;
|
|
24
32
|
}(InternalAPI_1.InternalAPIClass));
|
|
25
33
|
exports.APIClass = APIClass;
|
|
26
34
|
exports.API = new APIClass(null);
|
|
27
|
-
core_1.Amplify.register(exports.API);
|
|
28
35
|
//# sourceMappingURL=API.js.map
|
package/lib/API.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"API.js","sourceRoot":"","sources":["../src/API.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"API.js","sourceRoot":"","sources":["../src/API.ts"],"names":[],"mappings":";;;AASA,gEAA0E;AAE1E,uDAA2D;AAE3D;;;;GAIG;AACH;IAA8B,oCAAgB;IAA9C;;IAwCA,CAAC;IAvCO,gCAAa,GAApB;QACC,OAAO,KAAK,CAAC;IACd,CAAC;IAoBD,0BAAO,GAAP,UACC,OAAuB,EACvB,iBAA6C;QAE7C,OAAO,iBAAM,OAAO,YAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC;IAClD,CAAC;IAED;;OAEG;IACH,iCAAc,GAAd;QACC,IAAM,MAAM,GAAkB;YAC7B,OAAO,EAAE,mBAAS;SAClB,CAAC;QAEF,OAAO,MAAqB,CAAC;IAC9B,CAAC;IACF,eAAC;AAAD,CAAC,AAxCD,CAA8B,8BAAgB,GAwC7C;AAxCY,4BAAQ;AAsDR,QAAA,GAAG,GAAG,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
export { GraphQLQuery, GraphQLSubscription } from './types';
|
|
2
|
-
|
|
3
|
-
export { graphqlOperation, GraphQLAuthError,
|
|
2
|
+
import { API, APIClass } from './API';
|
|
3
|
+
export { graphqlOperation, GraphQLAuthError, GraphQLAuthMode, } from '@aws-amplify/api-graphql';
|
|
4
4
|
export type { GraphQLResult } from '@aws-amplify/api-graphql';
|
|
5
|
+
declare const generateClient: <T extends Record<any, any> = never>() => {
|
|
6
|
+
graphql: typeof import("@aws-amplify/api-graphql/lib-esm/internals").graphql;
|
|
7
|
+
};
|
|
8
|
+
export { API, APIClass, generateClient };
|
package/lib/index.js
CHANGED
|
@@ -8,5 +8,6 @@ exports.APIClass = API_1.APIClass;
|
|
|
8
8
|
var api_graphql_1 = require("@aws-amplify/api-graphql");
|
|
9
9
|
exports.graphqlOperation = api_graphql_1.graphqlOperation;
|
|
10
10
|
exports.GraphQLAuthError = api_graphql_1.GraphQLAuthError;
|
|
11
|
-
|
|
11
|
+
var generateClient = API_1.API.generateClient;
|
|
12
|
+
exports.generateClient = generateClient;
|
|
12
13
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;;AAKtC,6BAAsC;AAW7B,cAXA,SAAG,CAWA;AAAE,mBAXA,cAAQ,CAWA;AAVtB,wDAIkC;AAHjC,yCAAA,gBAAgB,CAAA;AAChB,yCAAA,gBAAgB,CAAA;AAMjB,IAAM,cAAc,GAAG,SAAG,CAAC,cAAc,CAAC;AAElB,wCAAc"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { GraphQLOperation, GraphQLOptions, GraphQLResult, OperationTypeNode } from '@aws-amplify/api-graphql';
|
|
2
|
-
import { CustomUserAgentDetails } from '@aws-amplify/core';
|
|
3
|
-
import { AWSAppSyncRealTimeProvider } from '@aws-amplify/pubsub';
|
|
1
|
+
import { AWSAppSyncRealTimeProvider, GraphQLOperation, GraphQLOptions, GraphQLResult, OperationTypeNode, GraphQLQuery, GraphQLSubscription } from '@aws-amplify/api-graphql';
|
|
2
|
+
import { CustomUserAgentDetails } from '@aws-amplify/core/internals/utils';
|
|
4
3
|
import Observable from 'zen-observable-ts';
|
|
5
|
-
import { GraphQLQuery, GraphQLSubscription } from '../types';
|
|
6
4
|
/**
|
|
7
5
|
* @deprecated
|
|
8
6
|
* Use RestApi or GraphQLAPI to reduce your application bundle size
|
|
@@ -14,83 +12,14 @@ export declare class InternalAPIClass {
|
|
|
14
12
|
* @param {Object} options - Configuration object for API
|
|
15
13
|
*/
|
|
16
14
|
private _options;
|
|
17
|
-
private _restApi;
|
|
18
15
|
private _graphqlApi;
|
|
19
|
-
|
|
20
|
-
Cache: import("@aws-amplify/cache/lib-esm/types").ICache;
|
|
21
|
-
Credentials: import("@aws-amplify/core").CredentialsClass;
|
|
16
|
+
Cache: import("@aws-amplify/core/lib-esm/Cache/types").ICache;
|
|
22
17
|
/**
|
|
23
18
|
* Initialize API with AWS configuration
|
|
24
19
|
* @param {Object} options - Configuration object for API
|
|
25
20
|
*/
|
|
26
21
|
constructor(options: any);
|
|
27
22
|
getModuleName(): string;
|
|
28
|
-
/**
|
|
29
|
-
* Configure API part with aws configurations
|
|
30
|
-
* @param {Object} config - Configuration of the API
|
|
31
|
-
* @return {Object} - The current configuration
|
|
32
|
-
*/
|
|
33
|
-
configure(options: any): any;
|
|
34
|
-
/**
|
|
35
|
-
* Make a GET request
|
|
36
|
-
* @param apiName - The api name of the request
|
|
37
|
-
* @param path - The path of the request
|
|
38
|
-
* @param [init] - Request extra params
|
|
39
|
-
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
40
|
-
*/
|
|
41
|
-
get(apiName: string, path: string, init: {
|
|
42
|
-
[key: string]: any;
|
|
43
|
-
}): Promise<any>;
|
|
44
|
-
/**
|
|
45
|
-
* Make a POST request
|
|
46
|
-
* @param apiName - The api name of the request
|
|
47
|
-
* @param path - The path of the request
|
|
48
|
-
* @param [init] - Request extra params
|
|
49
|
-
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
50
|
-
*/
|
|
51
|
-
post(apiName: string, path: string, init: {
|
|
52
|
-
[key: string]: any;
|
|
53
|
-
}): Promise<any>;
|
|
54
|
-
/**
|
|
55
|
-
* Make a PUT request
|
|
56
|
-
* @param apiName - The api name of the request
|
|
57
|
-
* @param path - The path of the request
|
|
58
|
-
* @param [init] - Request extra params
|
|
59
|
-
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
60
|
-
*/
|
|
61
|
-
put(apiName: string, path: string, init: {
|
|
62
|
-
[key: string]: any;
|
|
63
|
-
}): Promise<any>;
|
|
64
|
-
/**
|
|
65
|
-
* Make a PATCH request
|
|
66
|
-
* @param apiName - The api name of the request
|
|
67
|
-
* @param path - The path of the request
|
|
68
|
-
* @param [init] - Request extra params
|
|
69
|
-
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
70
|
-
*/
|
|
71
|
-
patch(apiName: string, path: string, init: {
|
|
72
|
-
[key: string]: any;
|
|
73
|
-
}): Promise<any>;
|
|
74
|
-
/**
|
|
75
|
-
* Make a DEL request
|
|
76
|
-
* @param apiName - The api name of the request
|
|
77
|
-
* @param path - The path of the request
|
|
78
|
-
* @param [init] - Request extra params
|
|
79
|
-
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
80
|
-
*/
|
|
81
|
-
del(apiName: string, path: string, init: {
|
|
82
|
-
[key: string]: any;
|
|
83
|
-
}): Promise<any>;
|
|
84
|
-
/**
|
|
85
|
-
* Make a HEAD request
|
|
86
|
-
* @param apiName - The api name of the request
|
|
87
|
-
* @param path - The path of the request
|
|
88
|
-
* @param [init] - Request extra params
|
|
89
|
-
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
90
|
-
*/
|
|
91
|
-
head(apiName: string, path: string, init: {
|
|
92
|
-
[key: string]: any;
|
|
93
|
-
}): Promise<any>;
|
|
94
23
|
/**
|
|
95
24
|
* Checks to see if an error thrown is from an api request cancellation
|
|
96
25
|
* @param error - Any error
|
|
@@ -104,13 +33,6 @@ export declare class InternalAPIClass {
|
|
|
104
33
|
* @return If the request was cancelled
|
|
105
34
|
*/
|
|
106
35
|
cancel(request: Promise<any>, message?: string): boolean;
|
|
107
|
-
private getInitWithCustomUserAgentDetails;
|
|
108
|
-
/**
|
|
109
|
-
* Getting endpoint for API
|
|
110
|
-
* @param apiName - The name of the api
|
|
111
|
-
* @return The endpoint of the api
|
|
112
|
-
*/
|
|
113
|
-
endpoint(apiName: string): Promise<string>;
|
|
114
36
|
/**
|
|
115
37
|
* to get the operation type
|
|
116
38
|
* @param operation
|
|
@@ -3,10 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
var tslib_1 = require("tslib");
|
|
4
4
|
var internals_1 = require("@aws-amplify/api-graphql/internals");
|
|
5
5
|
var api_rest_1 = require("@aws-amplify/api-rest");
|
|
6
|
-
var auth_1 = require("@aws-amplify/auth");
|
|
7
|
-
var cache_1 = require("@aws-amplify/cache");
|
|
8
6
|
var core_1 = require("@aws-amplify/core");
|
|
9
|
-
var
|
|
7
|
+
var utils_1 = require("@aws-amplify/core/internals/utils");
|
|
8
|
+
var logger = new utils_1.ConsoleLogger('API');
|
|
10
9
|
/**
|
|
11
10
|
* @deprecated
|
|
12
11
|
* Use RestApi or GraphQLAPI to reduce your application bundle size
|
|
@@ -18,100 +17,21 @@ var InternalAPIClass = /** @class */ (function () {
|
|
|
18
17
|
* @param {Object} options - Configuration object for API
|
|
19
18
|
*/
|
|
20
19
|
function InternalAPIClass(options) {
|
|
21
|
-
this.
|
|
22
|
-
this.Cache = cache_1.Cache;
|
|
23
|
-
this.Credentials = core_1.Credentials;
|
|
20
|
+
this.Cache = core_1.Cache;
|
|
24
21
|
this._options = options;
|
|
25
|
-
this._restApi = new api_rest_1.RestAPIClass(options);
|
|
26
22
|
this._graphqlApi = new internals_1.InternalGraphQLAPIClass(options);
|
|
27
23
|
logger.debug('API Options', this._options);
|
|
28
24
|
}
|
|
29
25
|
InternalAPIClass.prototype.getModuleName = function () {
|
|
30
26
|
return 'InternalAPI';
|
|
31
27
|
};
|
|
32
|
-
/**
|
|
33
|
-
* Configure API part with aws configurations
|
|
34
|
-
* @param {Object} config - Configuration of the API
|
|
35
|
-
* @return {Object} - The current configuration
|
|
36
|
-
*/
|
|
37
|
-
InternalAPIClass.prototype.configure = function (options) {
|
|
38
|
-
this._options = Object.assign({}, this._options, options);
|
|
39
|
-
// Share Amplify instance with client for SSR
|
|
40
|
-
this._restApi.Credentials = this.Credentials;
|
|
41
|
-
this._graphqlApi.Auth = this.Auth;
|
|
42
|
-
this._graphqlApi.Cache = this.Cache;
|
|
43
|
-
this._graphqlApi.Credentials = this.Credentials;
|
|
44
|
-
var restAPIConfig = this._restApi.configure(this._options);
|
|
45
|
-
var graphQLAPIConfig = this._graphqlApi.configure(this._options);
|
|
46
|
-
return tslib_1.__assign(tslib_1.__assign({}, restAPIConfig), graphQLAPIConfig);
|
|
47
|
-
};
|
|
48
|
-
/**
|
|
49
|
-
* Make a GET request
|
|
50
|
-
* @param apiName - The api name of the request
|
|
51
|
-
* @param path - The path of the request
|
|
52
|
-
* @param [init] - Request extra params
|
|
53
|
-
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
54
|
-
*/
|
|
55
|
-
InternalAPIClass.prototype.get = function (apiName, path, init) {
|
|
56
|
-
return this._restApi.get(apiName, path, this.getInitWithCustomUserAgentDetails(init, core_1.ApiAction.Get));
|
|
57
|
-
};
|
|
58
|
-
/**
|
|
59
|
-
* Make a POST request
|
|
60
|
-
* @param apiName - The api name of the request
|
|
61
|
-
* @param path - The path of the request
|
|
62
|
-
* @param [init] - Request extra params
|
|
63
|
-
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
64
|
-
*/
|
|
65
|
-
InternalAPIClass.prototype.post = function (apiName, path, init) {
|
|
66
|
-
return this._restApi.post(apiName, path, this.getInitWithCustomUserAgentDetails(init, core_1.ApiAction.Post));
|
|
67
|
-
};
|
|
68
|
-
/**
|
|
69
|
-
* Make a PUT request
|
|
70
|
-
* @param apiName - The api name of the request
|
|
71
|
-
* @param path - The path of the request
|
|
72
|
-
* @param [init] - Request extra params
|
|
73
|
-
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
74
|
-
*/
|
|
75
|
-
InternalAPIClass.prototype.put = function (apiName, path, init) {
|
|
76
|
-
return this._restApi.put(apiName, path, this.getInitWithCustomUserAgentDetails(init, core_1.ApiAction.Put));
|
|
77
|
-
};
|
|
78
|
-
/**
|
|
79
|
-
* Make a PATCH request
|
|
80
|
-
* @param apiName - The api name of the request
|
|
81
|
-
* @param path - The path of the request
|
|
82
|
-
* @param [init] - Request extra params
|
|
83
|
-
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
84
|
-
*/
|
|
85
|
-
InternalAPIClass.prototype.patch = function (apiName, path, init) {
|
|
86
|
-
return this._restApi.patch(apiName, path, this.getInitWithCustomUserAgentDetails(init, core_1.ApiAction.Patch));
|
|
87
|
-
};
|
|
88
|
-
/**
|
|
89
|
-
* Make a DEL request
|
|
90
|
-
* @param apiName - The api name of the request
|
|
91
|
-
* @param path - The path of the request
|
|
92
|
-
* @param [init] - Request extra params
|
|
93
|
-
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
94
|
-
*/
|
|
95
|
-
InternalAPIClass.prototype.del = function (apiName, path, init) {
|
|
96
|
-
return this._restApi.del(apiName, path, this.getInitWithCustomUserAgentDetails(init, core_1.ApiAction.Del));
|
|
97
|
-
};
|
|
98
|
-
/**
|
|
99
|
-
* Make a HEAD request
|
|
100
|
-
* @param apiName - The api name of the request
|
|
101
|
-
* @param path - The path of the request
|
|
102
|
-
* @param [init] - Request extra params
|
|
103
|
-
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
104
|
-
*/
|
|
105
|
-
InternalAPIClass.prototype.head = function (apiName, path, init) {
|
|
106
|
-
return this._restApi.head(apiName, path, this.getInitWithCustomUserAgentDetails(init, core_1.ApiAction.Head));
|
|
107
|
-
};
|
|
108
28
|
/**
|
|
109
29
|
* Checks to see if an error thrown is from an api request cancellation
|
|
110
30
|
* @param error - Any error
|
|
111
31
|
* @return If the error was from an api request cancellation
|
|
112
32
|
*/
|
|
113
33
|
InternalAPIClass.prototype.isCancel = function (error) {
|
|
114
|
-
return
|
|
34
|
+
return api_rest_1.isCancel(error);
|
|
115
35
|
};
|
|
116
36
|
/**
|
|
117
37
|
* Cancels an inflight request for either a GraphQL request or a Rest API request.
|
|
@@ -120,33 +40,7 @@ var InternalAPIClass = /** @class */ (function () {
|
|
|
120
40
|
* @return If the request was cancelled
|
|
121
41
|
*/
|
|
122
42
|
InternalAPIClass.prototype.cancel = function (request, message) {
|
|
123
|
-
|
|
124
|
-
return this._restApi.cancel(request, message);
|
|
125
|
-
}
|
|
126
|
-
else if (this._graphqlApi.hasCancelToken(request)) {
|
|
127
|
-
return this._graphqlApi.cancel(request, message);
|
|
128
|
-
}
|
|
129
|
-
return false;
|
|
130
|
-
};
|
|
131
|
-
InternalAPIClass.prototype.getInitWithCustomUserAgentDetails = function (init, action) {
|
|
132
|
-
var customUserAgentDetails = {
|
|
133
|
-
category: core_1.Category.API,
|
|
134
|
-
action: action,
|
|
135
|
-
};
|
|
136
|
-
var initParams = tslib_1.__assign(tslib_1.__assign({}, init), { customUserAgentDetails: customUserAgentDetails });
|
|
137
|
-
return initParams;
|
|
138
|
-
};
|
|
139
|
-
/**
|
|
140
|
-
* Getting endpoint for API
|
|
141
|
-
* @param apiName - The name of the api
|
|
142
|
-
* @return The endpoint of the api
|
|
143
|
-
*/
|
|
144
|
-
InternalAPIClass.prototype.endpoint = function (apiName) {
|
|
145
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
146
|
-
return tslib_1.__generator(this, function (_a) {
|
|
147
|
-
return [2 /*return*/, this._restApi.endpoint(apiName)];
|
|
148
|
-
});
|
|
149
|
-
});
|
|
43
|
+
return api_rest_1.cancel(request, message);
|
|
150
44
|
};
|
|
151
45
|
/**
|
|
152
46
|
* to get the operation type
|
|
@@ -156,12 +50,11 @@ var InternalAPIClass = /** @class */ (function () {
|
|
|
156
50
|
return this._graphqlApi.getGraphqlOperationType(operation);
|
|
157
51
|
};
|
|
158
52
|
InternalAPIClass.prototype.graphql = function (options, additionalHeaders, customUserAgentDetails) {
|
|
159
|
-
var apiUserAgentDetails = tslib_1.__assign({ category:
|
|
53
|
+
var apiUserAgentDetails = tslib_1.__assign({ category: utils_1.Category.API, action: utils_1.ApiAction.GraphQl }, customUserAgentDetails);
|
|
160
54
|
return this._graphqlApi.graphql(options, additionalHeaders, apiUserAgentDetails);
|
|
161
55
|
};
|
|
162
56
|
return InternalAPIClass;
|
|
163
57
|
}());
|
|
164
58
|
exports.InternalAPIClass = InternalAPIClass;
|
|
165
59
|
exports.InternalAPI = new InternalAPIClass(null);
|
|
166
|
-
core_1.Amplify.register(exports.InternalAPI);
|
|
167
60
|
//# sourceMappingURL=InternalAPI.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InternalAPI.js","sourceRoot":"","sources":["../../src/internals/InternalAPI.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"InternalAPI.js","sourceRoot":"","sources":["../../src/internals/InternalAPI.ts"],"names":[],"mappings":";;;AAWA,gEAA6E;AAC7E,kDAAyD;AACzD,0CAA0C;AAC1C,2DAK2C;AAG3C,IAAM,MAAM,GAAG,IAAI,qBAAM,CAAC,KAAK,CAAC,CAAC;AACjC;;;;GAIG;AACH;IAUC;;;OAGG;IACH,0BAAY,OAAO;QANnB,UAAK,GAAG,YAAK,CAAC;QAOb,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,WAAW,GAAG,IAAI,mCAAuB,CAAC,OAAO,CAAC,CAAC;QACxD,MAAM,CAAC,KAAK,CAAC,aAAa,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC5C,CAAC;IAEM,wCAAa,GAApB;QACC,OAAO,aAAa,CAAC;IACtB,CAAC;IAED;;;;OAIG;IACH,mCAAQ,GAAR,UAAS,KAAU;QAClB,OAAO,mBAAQ,CAAC,KAAK,CAAC,CAAC;IACxB,CAAC;IACD;;;;;OAKG;IACH,iCAAM,GAAN,UAAO,OAAqB,EAAE,OAAgB;QAC7C,OAAO,iBAAM,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACjC,CAAC;IAED;;;OAGG;IACH,kDAAuB,GAAvB,UAAwB,SAA2B;QAClD,OAAO,IAAI,CAAC,WAAW,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC;IAC5D,CAAC;IAqBD,kCAAO,GAAP,UACC,OAAuB,EACvB,iBAA6C,EAC7C,sBAA+C;QAE/C,IAAM,mBAAmB,sBACxB,QAAQ,EAAE,gBAAQ,CAAC,GAAG,EACtB,MAAM,EAAE,iBAAS,CAAC,OAAO,IACtB,sBAAsB,CACzB,CAAC;QAEF,OAAO,IAAI,CAAC,WAAW,CAAC,OAAO,CAC9B,OAAO,EACP,iBAAiB,EACjB,mBAAmB,CACnB,CAAC;IACH,CAAC;IACF,uBAAC;AAAD,CAAC,AAtFD,IAsFC;AAtFY,4CAAgB;AAwFhB,QAAA,WAAW,GAAG,IAAI,gBAAgB,CAAC,IAAI,CAAC,CAAC"}
|
package/lib/types/index.d.ts
CHANGED
|
@@ -3,11 +3,4 @@
|
|
|
3
3
|
* generates code that relies on this import path https://github.com/aws-amplify/amplify-cli/issues/3863
|
|
4
4
|
* This will be removed in future release when CLI and customers moves to recommeneded import styles.
|
|
5
5
|
*/
|
|
6
|
-
export { graphqlOperation, GraphQLAuthError, GraphQLResult,
|
|
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
|
-
};
|
|
6
|
+
export { graphqlOperation, GraphQLAuthError, GraphQLResult, GraphQLAuthMode, GraphQLQuery, GraphQLSubscription, } from '@aws-amplify/api-graphql';
|
package/lib/types/index.js
CHANGED
|
@@ -10,5 +10,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
10
10
|
var api_graphql_1 = require("@aws-amplify/api-graphql");
|
|
11
11
|
exports.graphqlOperation = api_graphql_1.graphqlOperation;
|
|
12
12
|
exports.GraphQLAuthError = api_graphql_1.GraphQLAuthError;
|
|
13
|
-
exports.GRAPHQL_AUTH_MODE = api_graphql_1.GRAPHQL_AUTH_MODE;
|
|
14
13
|
//# sourceMappingURL=index.js.map
|
package/lib/types/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;;AAEtC;;;;GAIG;AACH,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;;AAEtC;;;;GAIG;AACH,wDAOkC;AANjC,yCAAA,gBAAgB,CAAA;AAChB,yCAAA,gBAAgB,CAAA"}
|
package/lib-esm/API.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { AWSAppSyncRealTimeProvider } from '@aws-amplify/
|
|
2
|
-
import {
|
|
1
|
+
import { AWSAppSyncRealTimeProvider, GraphQLOptions, GraphQLResult, GraphQLQuery, GraphQLSubscription } from '@aws-amplify/api-graphql';
|
|
2
|
+
import { graphql as v6graphql } from '@aws-amplify/api-graphql/internals';
|
|
3
3
|
import Observable from 'zen-observable-ts';
|
|
4
|
-
import { GraphQLQuery, GraphQLSubscription } from './types';
|
|
5
4
|
import { InternalAPIClass } from './internals/InternalAPI';
|
|
6
5
|
/**
|
|
7
6
|
* @deprecated
|
|
@@ -23,5 +22,19 @@ export declare class APIClass extends InternalAPIClass {
|
|
|
23
22
|
provider: AWSAppSyncRealTimeProvider;
|
|
24
23
|
value: GraphQLResult<T>;
|
|
25
24
|
}> : Promise<GraphQLResult<any>> | Observable<object>;
|
|
25
|
+
/**
|
|
26
|
+
* Generates an API client that can work with models or raw GraphQL
|
|
27
|
+
*/
|
|
28
|
+
generateClient<T extends Record<any, any> = never>(): V6Client<T>;
|
|
26
29
|
}
|
|
30
|
+
declare type FilteredKeys<T> = {
|
|
31
|
+
[P in keyof T]: T[P] extends never ? never : P;
|
|
32
|
+
}[keyof T];
|
|
33
|
+
declare type ExcludeNeverFields<O> = {
|
|
34
|
+
[K in FilteredKeys<O>]: O[K];
|
|
35
|
+
};
|
|
36
|
+
declare type V6Client<T extends Record<any, any> = never> = ExcludeNeverFields<{
|
|
37
|
+
graphql: typeof v6graphql;
|
|
38
|
+
}>;
|
|
27
39
|
export declare const API: APIClass;
|
|
40
|
+
export {};
|
package/lib-esm/API.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { __extends } from "tslib";
|
|
2
|
-
import {
|
|
2
|
+
import { graphql as v6graphql } from '@aws-amplify/api-graphql/internals';
|
|
3
3
|
import { InternalAPIClass } from './internals/InternalAPI';
|
|
4
|
-
var logger = new Logger('API');
|
|
5
4
|
/**
|
|
6
5
|
* @deprecated
|
|
7
6
|
* Use RestApi or GraphQLAPI to reduce your application bundle size
|
|
@@ -18,9 +17,17 @@ var APIClass = /** @class */ (function (_super) {
|
|
|
18
17
|
APIClass.prototype.graphql = function (options, additionalHeaders) {
|
|
19
18
|
return _super.prototype.graphql.call(this, options, additionalHeaders);
|
|
20
19
|
};
|
|
20
|
+
/**
|
|
21
|
+
* Generates an API client that can work with models or raw GraphQL
|
|
22
|
+
*/
|
|
23
|
+
APIClass.prototype.generateClient = function () {
|
|
24
|
+
var client = {
|
|
25
|
+
graphql: v6graphql,
|
|
26
|
+
};
|
|
27
|
+
return client;
|
|
28
|
+
};
|
|
21
29
|
return APIClass;
|
|
22
30
|
}(InternalAPIClass));
|
|
23
31
|
export { APIClass };
|
|
24
32
|
export var API = new APIClass(null);
|
|
25
|
-
Amplify.register(API);
|
|
26
33
|
//# sourceMappingURL=API.js.map
|
package/lib-esm/API.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"API.js","sourceRoot":"","sources":["../src/API.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"API.js","sourceRoot":"","sources":["../src/API.ts"],"names":[],"mappings":";AASA,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAE1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D;;;;GAIG;AACH;IAA8B,4BAAgB;IAA9C;;IAwCA,CAAC;IAvCO,gCAAa,GAApB;QACC,OAAO,KAAK,CAAC;IACd,CAAC;IAoBD,0BAAO,GAAP,UACC,OAAuB,EACvB,iBAA6C;QAE7C,OAAO,iBAAM,OAAO,YAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC;IAClD,CAAC;IAED;;OAEG;IACH,iCAAc,GAAd;QACC,IAAM,MAAM,GAAkB;YAC7B,OAAO,EAAE,SAAS;SAClB,CAAC;QAEF,OAAO,MAAqB,CAAC;IAC9B,CAAC;IACF,eAAC;AAAD,CAAC,AAxCD,CAA8B,gBAAgB,GAwC7C;;AAcD,MAAM,CAAC,IAAM,GAAG,GAAG,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC"}
|
package/lib-esm/index.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
export { GraphQLQuery, GraphQLSubscription } from './types';
|
|
2
|
-
|
|
3
|
-
export { graphqlOperation, GraphQLAuthError,
|
|
2
|
+
import { API, APIClass } from './API';
|
|
3
|
+
export { graphqlOperation, GraphQLAuthError, GraphQLAuthMode, } from '@aws-amplify/api-graphql';
|
|
4
4
|
export type { GraphQLResult } from '@aws-amplify/api-graphql';
|
|
5
|
+
declare const generateClient: <T extends Record<any, any> = never>() => {
|
|
6
|
+
graphql: typeof import("@aws-amplify/api-graphql/lib-esm/internals").graphql;
|
|
7
|
+
};
|
|
8
|
+
export { API, APIClass, generateClient };
|
package/lib-esm/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
export { graphqlOperation, GraphQLAuthError,
|
|
3
|
+
import { API, APIClass } from './API';
|
|
4
|
+
export { graphqlOperation, GraphQLAuthError, } from '@aws-amplify/api-graphql';
|
|
5
|
+
var generateClient = API.generateClient;
|
|
6
|
+
export { API, APIClass, generateClient };
|
|
5
7
|
//# sourceMappingURL=index.js.map
|
package/lib-esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAKtC,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EACN,gBAAgB,EAChB,gBAAgB,GAEhB,MAAM,0BAA0B,CAAC;AAIlC,IAAM,cAAc,GAAG,GAAG,CAAC,cAAc,CAAC;AAE1C,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { GraphQLOperation, GraphQLOptions, GraphQLResult, OperationTypeNode } from '@aws-amplify/api-graphql';
|
|
2
|
-
import { CustomUserAgentDetails } from '@aws-amplify/core';
|
|
3
|
-
import { AWSAppSyncRealTimeProvider } from '@aws-amplify/pubsub';
|
|
1
|
+
import { AWSAppSyncRealTimeProvider, GraphQLOperation, GraphQLOptions, GraphQLResult, OperationTypeNode, GraphQLQuery, GraphQLSubscription } from '@aws-amplify/api-graphql';
|
|
2
|
+
import { CustomUserAgentDetails } from '@aws-amplify/core/internals/utils';
|
|
4
3
|
import Observable from 'zen-observable-ts';
|
|
5
|
-
import { GraphQLQuery, GraphQLSubscription } from '../types';
|
|
6
4
|
/**
|
|
7
5
|
* @deprecated
|
|
8
6
|
* Use RestApi or GraphQLAPI to reduce your application bundle size
|
|
@@ -14,83 +12,14 @@ export declare class InternalAPIClass {
|
|
|
14
12
|
* @param {Object} options - Configuration object for API
|
|
15
13
|
*/
|
|
16
14
|
private _options;
|
|
17
|
-
private _restApi;
|
|
18
15
|
private _graphqlApi;
|
|
19
|
-
|
|
20
|
-
Cache: import("@aws-amplify/cache/lib-esm/types").ICache;
|
|
21
|
-
Credentials: import("@aws-amplify/core").CredentialsClass;
|
|
16
|
+
Cache: import("@aws-amplify/core/lib-esm/Cache/types").ICache;
|
|
22
17
|
/**
|
|
23
18
|
* Initialize API with AWS configuration
|
|
24
19
|
* @param {Object} options - Configuration object for API
|
|
25
20
|
*/
|
|
26
21
|
constructor(options: any);
|
|
27
22
|
getModuleName(): string;
|
|
28
|
-
/**
|
|
29
|
-
* Configure API part with aws configurations
|
|
30
|
-
* @param {Object} config - Configuration of the API
|
|
31
|
-
* @return {Object} - The current configuration
|
|
32
|
-
*/
|
|
33
|
-
configure(options: any): any;
|
|
34
|
-
/**
|
|
35
|
-
* Make a GET request
|
|
36
|
-
* @param apiName - The api name of the request
|
|
37
|
-
* @param path - The path of the request
|
|
38
|
-
* @param [init] - Request extra params
|
|
39
|
-
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
40
|
-
*/
|
|
41
|
-
get(apiName: string, path: string, init: {
|
|
42
|
-
[key: string]: any;
|
|
43
|
-
}): Promise<any>;
|
|
44
|
-
/**
|
|
45
|
-
* Make a POST request
|
|
46
|
-
* @param apiName - The api name of the request
|
|
47
|
-
* @param path - The path of the request
|
|
48
|
-
* @param [init] - Request extra params
|
|
49
|
-
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
50
|
-
*/
|
|
51
|
-
post(apiName: string, path: string, init: {
|
|
52
|
-
[key: string]: any;
|
|
53
|
-
}): Promise<any>;
|
|
54
|
-
/**
|
|
55
|
-
* Make a PUT request
|
|
56
|
-
* @param apiName - The api name of the request
|
|
57
|
-
* @param path - The path of the request
|
|
58
|
-
* @param [init] - Request extra params
|
|
59
|
-
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
60
|
-
*/
|
|
61
|
-
put(apiName: string, path: string, init: {
|
|
62
|
-
[key: string]: any;
|
|
63
|
-
}): Promise<any>;
|
|
64
|
-
/**
|
|
65
|
-
* Make a PATCH request
|
|
66
|
-
* @param apiName - The api name of the request
|
|
67
|
-
* @param path - The path of the request
|
|
68
|
-
* @param [init] - Request extra params
|
|
69
|
-
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
70
|
-
*/
|
|
71
|
-
patch(apiName: string, path: string, init: {
|
|
72
|
-
[key: string]: any;
|
|
73
|
-
}): Promise<any>;
|
|
74
|
-
/**
|
|
75
|
-
* Make a DEL request
|
|
76
|
-
* @param apiName - The api name of the request
|
|
77
|
-
* @param path - The path of the request
|
|
78
|
-
* @param [init] - Request extra params
|
|
79
|
-
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
80
|
-
*/
|
|
81
|
-
del(apiName: string, path: string, init: {
|
|
82
|
-
[key: string]: any;
|
|
83
|
-
}): Promise<any>;
|
|
84
|
-
/**
|
|
85
|
-
* Make a HEAD request
|
|
86
|
-
* @param apiName - The api name of the request
|
|
87
|
-
* @param path - The path of the request
|
|
88
|
-
* @param [init] - Request extra params
|
|
89
|
-
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
90
|
-
*/
|
|
91
|
-
head(apiName: string, path: string, init: {
|
|
92
|
-
[key: string]: any;
|
|
93
|
-
}): Promise<any>;
|
|
94
23
|
/**
|
|
95
24
|
* Checks to see if an error thrown is from an api request cancellation
|
|
96
25
|
* @param error - Any error
|
|
@@ -104,13 +33,6 @@ export declare class InternalAPIClass {
|
|
|
104
33
|
* @return If the request was cancelled
|
|
105
34
|
*/
|
|
106
35
|
cancel(request: Promise<any>, message?: string): boolean;
|
|
107
|
-
private getInitWithCustomUserAgentDetails;
|
|
108
|
-
/**
|
|
109
|
-
* Getting endpoint for API
|
|
110
|
-
* @param apiName - The name of the api
|
|
111
|
-
* @return The endpoint of the api
|
|
112
|
-
*/
|
|
113
|
-
endpoint(apiName: string): Promise<string>;
|
|
114
36
|
/**
|
|
115
37
|
* to get the operation type
|
|
116
38
|
* @param operation
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { __assign
|
|
1
|
+
import { __assign } from "tslib";
|
|
2
2
|
import { InternalGraphQLAPIClass } from '@aws-amplify/api-graphql/internals';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { Amplify, ApiAction, Category, Credentials, ConsoleLogger as Logger, } from '@aws-amplify/core';
|
|
3
|
+
import { cancel, isCancel } from '@aws-amplify/api-rest';
|
|
4
|
+
import { Cache } from '@aws-amplify/core';
|
|
5
|
+
import { ApiAction, Category, ConsoleLogger as Logger, } from '@aws-amplify/core/internals/utils';
|
|
7
6
|
var logger = new Logger('API');
|
|
8
7
|
/**
|
|
9
8
|
* @deprecated
|
|
@@ -16,100 +15,21 @@ var InternalAPIClass = /** @class */ (function () {
|
|
|
16
15
|
* @param {Object} options - Configuration object for API
|
|
17
16
|
*/
|
|
18
17
|
function InternalAPIClass(options) {
|
|
19
|
-
this.Auth = Auth;
|
|
20
18
|
this.Cache = Cache;
|
|
21
|
-
this.Credentials = Credentials;
|
|
22
19
|
this._options = options;
|
|
23
|
-
this._restApi = new RestAPIClass(options);
|
|
24
20
|
this._graphqlApi = new InternalGraphQLAPIClass(options);
|
|
25
21
|
logger.debug('API Options', this._options);
|
|
26
22
|
}
|
|
27
23
|
InternalAPIClass.prototype.getModuleName = function () {
|
|
28
24
|
return 'InternalAPI';
|
|
29
25
|
};
|
|
30
|
-
/**
|
|
31
|
-
* Configure API part with aws configurations
|
|
32
|
-
* @param {Object} config - Configuration of the API
|
|
33
|
-
* @return {Object} - The current configuration
|
|
34
|
-
*/
|
|
35
|
-
InternalAPIClass.prototype.configure = function (options) {
|
|
36
|
-
this._options = Object.assign({}, this._options, options);
|
|
37
|
-
// Share Amplify instance with client for SSR
|
|
38
|
-
this._restApi.Credentials = this.Credentials;
|
|
39
|
-
this._graphqlApi.Auth = this.Auth;
|
|
40
|
-
this._graphqlApi.Cache = this.Cache;
|
|
41
|
-
this._graphqlApi.Credentials = this.Credentials;
|
|
42
|
-
var restAPIConfig = this._restApi.configure(this._options);
|
|
43
|
-
var graphQLAPIConfig = this._graphqlApi.configure(this._options);
|
|
44
|
-
return __assign(__assign({}, restAPIConfig), graphQLAPIConfig);
|
|
45
|
-
};
|
|
46
|
-
/**
|
|
47
|
-
* Make a GET request
|
|
48
|
-
* @param apiName - The api name of the request
|
|
49
|
-
* @param path - The path of the request
|
|
50
|
-
* @param [init] - Request extra params
|
|
51
|
-
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
52
|
-
*/
|
|
53
|
-
InternalAPIClass.prototype.get = function (apiName, path, init) {
|
|
54
|
-
return this._restApi.get(apiName, path, this.getInitWithCustomUserAgentDetails(init, ApiAction.Get));
|
|
55
|
-
};
|
|
56
|
-
/**
|
|
57
|
-
* Make a POST request
|
|
58
|
-
* @param apiName - The api name of the request
|
|
59
|
-
* @param path - The path of the request
|
|
60
|
-
* @param [init] - Request extra params
|
|
61
|
-
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
62
|
-
*/
|
|
63
|
-
InternalAPIClass.prototype.post = function (apiName, path, init) {
|
|
64
|
-
return this._restApi.post(apiName, path, this.getInitWithCustomUserAgentDetails(init, ApiAction.Post));
|
|
65
|
-
};
|
|
66
|
-
/**
|
|
67
|
-
* Make a PUT request
|
|
68
|
-
* @param apiName - The api name of the request
|
|
69
|
-
* @param path - The path of the request
|
|
70
|
-
* @param [init] - Request extra params
|
|
71
|
-
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
72
|
-
*/
|
|
73
|
-
InternalAPIClass.prototype.put = function (apiName, path, init) {
|
|
74
|
-
return this._restApi.put(apiName, path, this.getInitWithCustomUserAgentDetails(init, ApiAction.Put));
|
|
75
|
-
};
|
|
76
|
-
/**
|
|
77
|
-
* Make a PATCH request
|
|
78
|
-
* @param apiName - The api name of the request
|
|
79
|
-
* @param path - The path of the request
|
|
80
|
-
* @param [init] - Request extra params
|
|
81
|
-
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
82
|
-
*/
|
|
83
|
-
InternalAPIClass.prototype.patch = function (apiName, path, init) {
|
|
84
|
-
return this._restApi.patch(apiName, path, this.getInitWithCustomUserAgentDetails(init, ApiAction.Patch));
|
|
85
|
-
};
|
|
86
|
-
/**
|
|
87
|
-
* Make a DEL request
|
|
88
|
-
* @param apiName - The api name of the request
|
|
89
|
-
* @param path - The path of the request
|
|
90
|
-
* @param [init] - Request extra params
|
|
91
|
-
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
92
|
-
*/
|
|
93
|
-
InternalAPIClass.prototype.del = function (apiName, path, init) {
|
|
94
|
-
return this._restApi.del(apiName, path, this.getInitWithCustomUserAgentDetails(init, ApiAction.Del));
|
|
95
|
-
};
|
|
96
|
-
/**
|
|
97
|
-
* Make a HEAD request
|
|
98
|
-
* @param apiName - The api name of the request
|
|
99
|
-
* @param path - The path of the request
|
|
100
|
-
* @param [init] - Request extra params
|
|
101
|
-
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
102
|
-
*/
|
|
103
|
-
InternalAPIClass.prototype.head = function (apiName, path, init) {
|
|
104
|
-
return this._restApi.head(apiName, path, this.getInitWithCustomUserAgentDetails(init, ApiAction.Head));
|
|
105
|
-
};
|
|
106
26
|
/**
|
|
107
27
|
* Checks to see if an error thrown is from an api request cancellation
|
|
108
28
|
* @param error - Any error
|
|
109
29
|
* @return If the error was from an api request cancellation
|
|
110
30
|
*/
|
|
111
31
|
InternalAPIClass.prototype.isCancel = function (error) {
|
|
112
|
-
return
|
|
32
|
+
return isCancel(error);
|
|
113
33
|
};
|
|
114
34
|
/**
|
|
115
35
|
* Cancels an inflight request for either a GraphQL request or a Rest API request.
|
|
@@ -118,33 +38,7 @@ var InternalAPIClass = /** @class */ (function () {
|
|
|
118
38
|
* @return If the request was cancelled
|
|
119
39
|
*/
|
|
120
40
|
InternalAPIClass.prototype.cancel = function (request, message) {
|
|
121
|
-
|
|
122
|
-
return this._restApi.cancel(request, message);
|
|
123
|
-
}
|
|
124
|
-
else if (this._graphqlApi.hasCancelToken(request)) {
|
|
125
|
-
return this._graphqlApi.cancel(request, message);
|
|
126
|
-
}
|
|
127
|
-
return false;
|
|
128
|
-
};
|
|
129
|
-
InternalAPIClass.prototype.getInitWithCustomUserAgentDetails = function (init, action) {
|
|
130
|
-
var customUserAgentDetails = {
|
|
131
|
-
category: Category.API,
|
|
132
|
-
action: action,
|
|
133
|
-
};
|
|
134
|
-
var initParams = __assign(__assign({}, init), { customUserAgentDetails: customUserAgentDetails });
|
|
135
|
-
return initParams;
|
|
136
|
-
};
|
|
137
|
-
/**
|
|
138
|
-
* Getting endpoint for API
|
|
139
|
-
* @param apiName - The name of the api
|
|
140
|
-
* @return The endpoint of the api
|
|
141
|
-
*/
|
|
142
|
-
InternalAPIClass.prototype.endpoint = function (apiName) {
|
|
143
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
144
|
-
return __generator(this, function (_a) {
|
|
145
|
-
return [2 /*return*/, this._restApi.endpoint(apiName)];
|
|
146
|
-
});
|
|
147
|
-
});
|
|
41
|
+
return cancel(request, message);
|
|
148
42
|
};
|
|
149
43
|
/**
|
|
150
44
|
* to get the operation type
|
|
@@ -161,5 +55,4 @@ var InternalAPIClass = /** @class */ (function () {
|
|
|
161
55
|
}());
|
|
162
56
|
export { InternalAPIClass };
|
|
163
57
|
export var InternalAPI = new InternalAPIClass(null);
|
|
164
|
-
Amplify.register(InternalAPI);
|
|
165
58
|
//# sourceMappingURL=InternalAPI.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InternalAPI.js","sourceRoot":"","sources":["../../src/internals/InternalAPI.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"InternalAPI.js","sourceRoot":"","sources":["../../src/internals/InternalAPI.ts"],"names":[],"mappings":";AAWA,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EACN,SAAS,EACT,QAAQ,EACR,aAAa,IAAI,MAAM,GAEvB,MAAM,mCAAmC,CAAC;AAG3C,IAAM,MAAM,GAAG,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC;AACjC;;;;GAIG;AACH;IAUC;;;OAGG;IACH,0BAAY,OAAO;QANnB,UAAK,GAAG,KAAK,CAAC;QAOb,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,WAAW,GAAG,IAAI,uBAAuB,CAAC,OAAO,CAAC,CAAC;QACxD,MAAM,CAAC,KAAK,CAAC,aAAa,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC5C,CAAC;IAEM,wCAAa,GAApB;QACC,OAAO,aAAa,CAAC;IACtB,CAAC;IAED;;;;OAIG;IACH,mCAAQ,GAAR,UAAS,KAAU;QAClB,OAAO,QAAQ,CAAC,KAAK,CAAC,CAAC;IACxB,CAAC;IACD;;;;;OAKG;IACH,iCAAM,GAAN,UAAO,OAAqB,EAAE,OAAgB;QAC7C,OAAO,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACjC,CAAC;IAED;;;OAGG;IACH,kDAAuB,GAAvB,UAAwB,SAA2B;QAClD,OAAO,IAAI,CAAC,WAAW,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC;IAC5D,CAAC;IAqBD,kCAAO,GAAP,UACC,OAAuB,EACvB,iBAA6C,EAC7C,sBAA+C;QAE/C,IAAM,mBAAmB,cACxB,QAAQ,EAAE,QAAQ,CAAC,GAAG,EACtB,MAAM,EAAE,SAAS,CAAC,OAAO,IACtB,sBAAsB,CACzB,CAAC;QAEF,OAAO,IAAI,CAAC,WAAW,CAAC,OAAO,CAC9B,OAAO,EACP,iBAAiB,EACjB,mBAAmB,CACnB,CAAC;IACH,CAAC;IACF,uBAAC;AAAD,CAAC,AAtFD,IAsFC;;AAED,MAAM,CAAC,IAAM,WAAW,GAAG,IAAI,gBAAgB,CAAC,IAAI,CAAC,CAAC"}
|
package/lib-esm/types/index.d.ts
CHANGED
|
@@ -3,11 +3,4 @@
|
|
|
3
3
|
* generates code that relies on this import path https://github.com/aws-amplify/amplify-cli/issues/3863
|
|
4
4
|
* This will be removed in future release when CLI and customers moves to recommeneded import styles.
|
|
5
5
|
*/
|
|
6
|
-
export { graphqlOperation, GraphQLAuthError, GraphQLResult,
|
|
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
|
-
};
|
|
6
|
+
export { graphqlOperation, GraphQLAuthError, GraphQLResult, GraphQLAuthMode, GraphQLQuery, GraphQLSubscription, } from '@aws-amplify/api-graphql';
|
package/lib-esm/types/index.js
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* generates code that relies on this import path https://github.com/aws-amplify/amplify-cli/issues/3863
|
|
6
6
|
* This will be removed in future release when CLI and customers moves to recommeneded import styles.
|
|
7
7
|
*/
|
|
8
|
-
export { graphqlOperation, GraphQLAuthError,
|
|
8
|
+
export { graphqlOperation, GraphQLAuthError, } from '@aws-amplify/api-graphql';
|
|
9
9
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC;;;;GAIG;AACH,OAAO,EACN,gBAAgB,EAChB,gBAAgB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC;;;;GAIG;AACH,OAAO,EACN,gBAAgB,EAChB,gBAAgB,GAKhB,MAAM,0BAA0B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-amplify/api",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.1-console-preview.047a1dd.0+047a1dd",
|
|
4
4
|
"description": "Api category of aws-amplify",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"module": "./lib-esm/index.js",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"clean:size": "rimraf dual-publish-tmp tmp*",
|
|
36
36
|
"format": "echo \"Not implemented\"",
|
|
37
37
|
"lint": "tslint 'src/**/*.ts' && npm run ts-coverage",
|
|
38
|
-
"ts-coverage": "typescript-coverage-report -p ./tsconfig.build.json -t
|
|
38
|
+
"ts-coverage": "typescript-coverage-report -p ./tsconfig.build.json -t 88"
|
|
39
39
|
},
|
|
40
40
|
"repository": {
|
|
41
41
|
"type": "git",
|
|
@@ -48,7 +48,8 @@
|
|
|
48
48
|
},
|
|
49
49
|
"homepage": "https://aws-amplify.github.io/",
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@types/zen-observable": "^0.8.0"
|
|
51
|
+
"@types/zen-observable": "^0.8.0",
|
|
52
|
+
"typescript": "5.1.6"
|
|
52
53
|
},
|
|
53
54
|
"files": [
|
|
54
55
|
"lib",
|
|
@@ -58,16 +59,16 @@
|
|
|
58
59
|
"internals"
|
|
59
60
|
],
|
|
60
61
|
"dependencies": {
|
|
61
|
-
"@aws-amplify/api-graphql": "
|
|
62
|
-
"@aws-amplify/api-rest": "
|
|
63
|
-
"tslib": "^
|
|
62
|
+
"@aws-amplify/api-graphql": "4.0.1-console-preview.047a1dd.0+047a1dd",
|
|
63
|
+
"@aws-amplify/api-rest": "4.0.1-console-preview.047a1dd.0+047a1dd",
|
|
64
|
+
"tslib": "^2.6.1"
|
|
64
65
|
},
|
|
65
66
|
"size-limit": [
|
|
66
67
|
{
|
|
67
68
|
"name": "API (top-level class)",
|
|
68
69
|
"path": "./lib-esm/index.js",
|
|
69
70
|
"import": "{ Amplify, API }",
|
|
70
|
-
"limit": "
|
|
71
|
+
"limit": "93.82 kB"
|
|
71
72
|
}
|
|
72
73
|
],
|
|
73
74
|
"jest": {
|
|
@@ -114,5 +115,5 @@
|
|
|
114
115
|
"lib-esm"
|
|
115
116
|
]
|
|
116
117
|
},
|
|
117
|
-
"gitHead": "
|
|
118
|
+
"gitHead": "047a1dd83d54c8f3ee74e0766d96c6a3b9f97f90"
|
|
118
119
|
}
|
package/src/API.ts
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import {
|
|
4
|
+
AWSAppSyncRealTimeProvider,
|
|
5
|
+
GraphQLOptions,
|
|
6
|
+
GraphQLResult,
|
|
7
|
+
GraphQLQuery,
|
|
8
|
+
GraphQLSubscription,
|
|
9
|
+
} from '@aws-amplify/api-graphql';
|
|
10
|
+
import { graphql as v6graphql } from '@aws-amplify/api-graphql/internals';
|
|
6
11
|
import Observable from 'zen-observable-ts';
|
|
7
|
-
import { GraphQLQuery, GraphQLSubscription } from './types';
|
|
8
12
|
import { InternalAPIClass } from './internals/InternalAPI';
|
|
9
13
|
|
|
10
|
-
const logger = new Logger('API');
|
|
11
14
|
/**
|
|
12
15
|
* @deprecated
|
|
13
16
|
* Use RestApi or GraphQLAPI to reduce your application bundle size
|
|
@@ -42,7 +45,29 @@ export class APIClass extends InternalAPIClass {
|
|
|
42
45
|
): Promise<GraphQLResult<any>> | Observable<object> {
|
|
43
46
|
return super.graphql(options, additionalHeaders);
|
|
44
47
|
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Generates an API client that can work with models or raw GraphQL
|
|
51
|
+
*/
|
|
52
|
+
generateClient<T extends Record<any, any> = never>(): V6Client<T> {
|
|
53
|
+
const client: V6Client<any> = {
|
|
54
|
+
graphql: v6graphql,
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
return client as V6Client<T>;
|
|
58
|
+
}
|
|
45
59
|
}
|
|
46
60
|
|
|
61
|
+
type FilteredKeys<T> = {
|
|
62
|
+
[P in keyof T]: T[P] extends never ? never : P;
|
|
63
|
+
}[keyof T];
|
|
64
|
+
type ExcludeNeverFields<O> = {
|
|
65
|
+
[K in FilteredKeys<O>]: O[K];
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
// If no T is passed, ExcludeNeverFields removes "models" from the client
|
|
69
|
+
declare type V6Client<T extends Record<any, any> = never> = ExcludeNeverFields<{
|
|
70
|
+
graphql: typeof v6graphql;
|
|
71
|
+
}>;
|
|
72
|
+
|
|
47
73
|
export const API = new APIClass(null);
|
|
48
|
-
Amplify.register(API);
|
package/src/index.ts
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
+
// TODO(v6): revisit exports
|
|
5
|
+
|
|
4
6
|
export { GraphQLQuery, GraphQLSubscription } from './types';
|
|
5
|
-
|
|
7
|
+
import { API, APIClass } from './API';
|
|
6
8
|
export {
|
|
7
9
|
graphqlOperation,
|
|
8
10
|
GraphQLAuthError,
|
|
9
|
-
|
|
11
|
+
GraphQLAuthMode,
|
|
10
12
|
} from '@aws-amplify/api-graphql';
|
|
11
13
|
|
|
12
14
|
export type { GraphQLResult } from '@aws-amplify/api-graphql';
|
|
15
|
+
|
|
16
|
+
const generateClient = API.generateClient;
|
|
17
|
+
|
|
18
|
+
export { API, APIClass, generateClient };
|
|
@@ -1,26 +1,24 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
import {
|
|
4
|
+
AWSAppSyncRealTimeProvider,
|
|
4
5
|
GraphQLOperation,
|
|
5
6
|
GraphQLOptions,
|
|
6
7
|
GraphQLResult,
|
|
7
8
|
OperationTypeNode,
|
|
9
|
+
GraphQLQuery,
|
|
10
|
+
GraphQLSubscription,
|
|
8
11
|
} from '@aws-amplify/api-graphql';
|
|
9
12
|
import { InternalGraphQLAPIClass } from '@aws-amplify/api-graphql/internals';
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import { Cache } from '@aws-amplify/cache';
|
|
13
|
+
import { cancel, isCancel } from '@aws-amplify/api-rest';
|
|
14
|
+
import { Cache } from '@aws-amplify/core';
|
|
13
15
|
import {
|
|
14
|
-
Amplify,
|
|
15
16
|
ApiAction,
|
|
16
17
|
Category,
|
|
17
|
-
Credentials,
|
|
18
|
-
CustomUserAgentDetails,
|
|
19
18
|
ConsoleLogger as Logger,
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
CustomUserAgentDetails,
|
|
20
|
+
} from '@aws-amplify/core/internals/utils';
|
|
22
21
|
import Observable from 'zen-observable-ts';
|
|
23
|
-
import { GraphQLQuery, GraphQLSubscription } from '../types';
|
|
24
22
|
|
|
25
23
|
const logger = new Logger('API');
|
|
26
24
|
/**
|
|
@@ -34,12 +32,9 @@ export class InternalAPIClass {
|
|
|
34
32
|
* @param {Object} options - Configuration object for API
|
|
35
33
|
*/
|
|
36
34
|
private _options;
|
|
37
|
-
private _restApi: RestAPIClass;
|
|
38
35
|
private _graphqlApi: InternalGraphQLAPIClass;
|
|
39
36
|
|
|
40
|
-
Auth = Auth;
|
|
41
37
|
Cache = Cache;
|
|
42
|
-
Credentials = Credentials;
|
|
43
38
|
|
|
44
39
|
/**
|
|
45
40
|
* Initialize API with AWS configuration
|
|
@@ -47,7 +42,6 @@ export class InternalAPIClass {
|
|
|
47
42
|
*/
|
|
48
43
|
constructor(options) {
|
|
49
44
|
this._options = options;
|
|
50
|
-
this._restApi = new RestAPIClass(options);
|
|
51
45
|
this._graphqlApi = new InternalGraphQLAPIClass(options);
|
|
52
46
|
logger.debug('API Options', this._options);
|
|
53
47
|
}
|
|
@@ -56,148 +50,13 @@ export class InternalAPIClass {
|
|
|
56
50
|
return 'InternalAPI';
|
|
57
51
|
}
|
|
58
52
|
|
|
59
|
-
/**
|
|
60
|
-
* Configure API part with aws configurations
|
|
61
|
-
* @param {Object} config - Configuration of the API
|
|
62
|
-
* @return {Object} - The current configuration
|
|
63
|
-
*/
|
|
64
|
-
configure(options) {
|
|
65
|
-
this._options = Object.assign({}, this._options, options);
|
|
66
|
-
|
|
67
|
-
// Share Amplify instance with client for SSR
|
|
68
|
-
this._restApi.Credentials = this.Credentials;
|
|
69
|
-
|
|
70
|
-
this._graphqlApi.Auth = this.Auth;
|
|
71
|
-
this._graphqlApi.Cache = this.Cache;
|
|
72
|
-
this._graphqlApi.Credentials = this.Credentials;
|
|
73
|
-
|
|
74
|
-
const restAPIConfig = this._restApi.configure(this._options);
|
|
75
|
-
const graphQLAPIConfig = this._graphqlApi.configure(this._options);
|
|
76
|
-
|
|
77
|
-
return { ...restAPIConfig, ...graphQLAPIConfig };
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Make a GET request
|
|
82
|
-
* @param apiName - The api name of the request
|
|
83
|
-
* @param path - The path of the request
|
|
84
|
-
* @param [init] - Request extra params
|
|
85
|
-
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
86
|
-
*/
|
|
87
|
-
get(
|
|
88
|
-
apiName: string,
|
|
89
|
-
path: string,
|
|
90
|
-
init: { [key: string]: any }
|
|
91
|
-
): Promise<any> {
|
|
92
|
-
return this._restApi.get(
|
|
93
|
-
apiName,
|
|
94
|
-
path,
|
|
95
|
-
this.getInitWithCustomUserAgentDetails(init, ApiAction.Get)
|
|
96
|
-
);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Make a POST request
|
|
101
|
-
* @param apiName - The api name of the request
|
|
102
|
-
* @param path - The path of the request
|
|
103
|
-
* @param [init] - Request extra params
|
|
104
|
-
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
105
|
-
*/
|
|
106
|
-
post(
|
|
107
|
-
apiName: string,
|
|
108
|
-
path: string,
|
|
109
|
-
init: { [key: string]: any }
|
|
110
|
-
): Promise<any> {
|
|
111
|
-
return this._restApi.post(
|
|
112
|
-
apiName,
|
|
113
|
-
path,
|
|
114
|
-
this.getInitWithCustomUserAgentDetails(init, ApiAction.Post)
|
|
115
|
-
);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Make a PUT request
|
|
120
|
-
* @param apiName - The api name of the request
|
|
121
|
-
* @param path - The path of the request
|
|
122
|
-
* @param [init] - Request extra params
|
|
123
|
-
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
124
|
-
*/
|
|
125
|
-
put(
|
|
126
|
-
apiName: string,
|
|
127
|
-
path: string,
|
|
128
|
-
init: { [key: string]: any }
|
|
129
|
-
): Promise<any> {
|
|
130
|
-
return this._restApi.put(
|
|
131
|
-
apiName,
|
|
132
|
-
path,
|
|
133
|
-
this.getInitWithCustomUserAgentDetails(init, ApiAction.Put)
|
|
134
|
-
);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* Make a PATCH request
|
|
139
|
-
* @param apiName - The api name of the request
|
|
140
|
-
* @param path - The path of the request
|
|
141
|
-
* @param [init] - Request extra params
|
|
142
|
-
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
143
|
-
*/
|
|
144
|
-
patch(
|
|
145
|
-
apiName: string,
|
|
146
|
-
path: string,
|
|
147
|
-
init: { [key: string]: any }
|
|
148
|
-
): Promise<any> {
|
|
149
|
-
return this._restApi.patch(
|
|
150
|
-
apiName,
|
|
151
|
-
path,
|
|
152
|
-
this.getInitWithCustomUserAgentDetails(init, ApiAction.Patch)
|
|
153
|
-
);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* Make a DEL request
|
|
158
|
-
* @param apiName - The api name of the request
|
|
159
|
-
* @param path - The path of the request
|
|
160
|
-
* @param [init] - Request extra params
|
|
161
|
-
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
162
|
-
*/
|
|
163
|
-
del(
|
|
164
|
-
apiName: string,
|
|
165
|
-
path: string,
|
|
166
|
-
init: { [key: string]: any }
|
|
167
|
-
): Promise<any> {
|
|
168
|
-
return this._restApi.del(
|
|
169
|
-
apiName,
|
|
170
|
-
path,
|
|
171
|
-
this.getInitWithCustomUserAgentDetails(init, ApiAction.Del)
|
|
172
|
-
);
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
* Make a HEAD request
|
|
177
|
-
* @param apiName - The api name of the request
|
|
178
|
-
* @param path - The path of the request
|
|
179
|
-
* @param [init] - Request extra params
|
|
180
|
-
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
181
|
-
*/
|
|
182
|
-
head(
|
|
183
|
-
apiName: string,
|
|
184
|
-
path: string,
|
|
185
|
-
init: { [key: string]: any }
|
|
186
|
-
): Promise<any> {
|
|
187
|
-
return this._restApi.head(
|
|
188
|
-
apiName,
|
|
189
|
-
path,
|
|
190
|
-
this.getInitWithCustomUserAgentDetails(init, ApiAction.Head)
|
|
191
|
-
);
|
|
192
|
-
}
|
|
193
|
-
|
|
194
53
|
/**
|
|
195
54
|
* Checks to see if an error thrown is from an api request cancellation
|
|
196
55
|
* @param error - Any error
|
|
197
56
|
* @return If the error was from an api request cancellation
|
|
198
57
|
*/
|
|
199
58
|
isCancel(error: any): boolean {
|
|
200
|
-
return
|
|
59
|
+
return isCancel(error);
|
|
201
60
|
}
|
|
202
61
|
/**
|
|
203
62
|
* Cancels an inflight request for either a GraphQL request or a Rest API request.
|
|
@@ -206,33 +65,7 @@ export class InternalAPIClass {
|
|
|
206
65
|
* @return If the request was cancelled
|
|
207
66
|
*/
|
|
208
67
|
cancel(request: Promise<any>, message?: string): boolean {
|
|
209
|
-
|
|
210
|
-
return this._restApi.cancel(request, message);
|
|
211
|
-
} else if (this._graphqlApi.hasCancelToken(request)) {
|
|
212
|
-
return this._graphqlApi.cancel(request, message);
|
|
213
|
-
}
|
|
214
|
-
return false;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
private getInitWithCustomUserAgentDetails(
|
|
218
|
-
init: { [key: string]: any },
|
|
219
|
-
action: ApiAction
|
|
220
|
-
) {
|
|
221
|
-
const customUserAgentDetails: CustomUserAgentDetails = {
|
|
222
|
-
category: Category.API,
|
|
223
|
-
action,
|
|
224
|
-
};
|
|
225
|
-
const initParams = { ...init, customUserAgentDetails };
|
|
226
|
-
return initParams;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
/**
|
|
230
|
-
* Getting endpoint for API
|
|
231
|
-
* @param apiName - The name of the api
|
|
232
|
-
* @return The endpoint of the api
|
|
233
|
-
*/
|
|
234
|
-
async endpoint(apiName: string): Promise<string> {
|
|
235
|
-
return this._restApi.endpoint(apiName);
|
|
68
|
+
return cancel(request, message);
|
|
236
69
|
}
|
|
237
70
|
|
|
238
71
|
/**
|
|
@@ -282,4 +115,3 @@ export class InternalAPIClass {
|
|
|
282
115
|
}
|
|
283
116
|
|
|
284
117
|
export const InternalAPI = new InternalAPIClass(null);
|
|
285
|
-
Amplify.register(InternalAPI);
|
package/src/types/index.ts
CHANGED
|
@@ -10,13 +10,7 @@ export {
|
|
|
10
10
|
graphqlOperation,
|
|
11
11
|
GraphQLAuthError,
|
|
12
12
|
GraphQLResult,
|
|
13
|
-
|
|
13
|
+
GraphQLAuthMode,
|
|
14
|
+
GraphQLQuery,
|
|
15
|
+
GraphQLSubscription,
|
|
14
16
|
} from '@aws-amplify/api-graphql';
|
|
15
|
-
|
|
16
|
-
// Opaque type used for determining the graphql query type
|
|
17
|
-
declare const queryType: unique symbol;
|
|
18
|
-
|
|
19
|
-
export type GraphQLQuery<T> = T & { readonly [queryType]: 'query' };
|
|
20
|
-
export type GraphQLSubscription<T> = T & {
|
|
21
|
-
readonly [queryType]: 'subscription';
|
|
22
|
-
};
|