@aws-amplify/api 5.2.2-unstable.c1fa9c7.5 → 5.3.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/internals/package.json +8 -0
- package/lib/API.d.ts +3 -107
- package/lib/API.js +7 -139
- package/lib/API.js.map +1 -1
- package/lib/internals/InternalAPI.d.ts +133 -0
- package/lib/internals/InternalAPI.js +167 -0
- package/lib/internals/InternalAPI.js.map +1 -0
- package/lib/internals/index.d.ts +1 -0
- package/lib/internals/index.js +8 -0
- package/lib/internals/index.js.map +1 -0
- package/lib-esm/API.d.ts +3 -107
- package/lib-esm/API.js +9 -141
- package/lib-esm/API.js.map +1 -1
- package/lib-esm/internals/InternalAPI.d.ts +133 -0
- package/lib-esm/internals/InternalAPI.js +165 -0
- package/lib-esm/internals/InternalAPI.js.map +1 -0
- package/lib-esm/internals/index.d.ts +1 -0
- package/lib-esm/internals/index.js +4 -0
- package/lib-esm/internals/index.js.map +1 -0
- package/package.json +7 -6
- package/src/API.ts +5 -191
- package/src/internals/InternalAPI.ts +285 -0
- package/src/internals/index.ts +3 -0
package/lib/API.d.ts
CHANGED
|
@@ -1,119 +1,15 @@
|
|
|
1
1
|
import { AWSAppSyncRealTimeProvider } from '@aws-amplify/pubsub';
|
|
2
|
-
import { GraphQLOptions, GraphQLResult
|
|
2
|
+
import { GraphQLOptions, GraphQLResult } from '@aws-amplify/api-graphql';
|
|
3
3
|
import Observable from 'zen-observable-ts';
|
|
4
4
|
import { GraphQLQuery, GraphQLSubscription } from './types';
|
|
5
|
+
import { InternalAPIClass } from './internals/InternalAPI';
|
|
5
6
|
/**
|
|
6
7
|
* @deprecated
|
|
7
8
|
* Use RestApi or GraphQLAPI to reduce your application bundle size
|
|
8
9
|
* Export Cloud Logic APIs
|
|
9
10
|
*/
|
|
10
|
-
export declare class APIClass {
|
|
11
|
-
/**
|
|
12
|
-
* Initialize API with AWS configuration
|
|
13
|
-
* @param {Object} options - Configuration object for API
|
|
14
|
-
*/
|
|
15
|
-
private _options;
|
|
16
|
-
private _restApi;
|
|
17
|
-
private _graphqlApi;
|
|
18
|
-
Auth: import("@aws-amplify/auth/lib-esm/Auth").AuthClass;
|
|
19
|
-
Cache: import("@aws-amplify/cache/lib-esm/types").ICache;
|
|
20
|
-
Credentials: import("@aws-amplify/core").CredentialsClass;
|
|
21
|
-
/**
|
|
22
|
-
* Initialize API with AWS configuration
|
|
23
|
-
* @param {Object} options - Configuration object for API
|
|
24
|
-
*/
|
|
25
|
-
constructor(options: any);
|
|
11
|
+
export declare class APIClass extends InternalAPIClass {
|
|
26
12
|
getModuleName(): string;
|
|
27
|
-
/**
|
|
28
|
-
* Configure API part with aws configurations
|
|
29
|
-
* @param {Object} config - Configuration of the API
|
|
30
|
-
* @return {Object} - The current configuration
|
|
31
|
-
*/
|
|
32
|
-
configure(options: any): any;
|
|
33
|
-
/**
|
|
34
|
-
* Make a GET request
|
|
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.
|
|
39
|
-
*/
|
|
40
|
-
get(apiName: string, path: string, init: {
|
|
41
|
-
[key: string]: any;
|
|
42
|
-
}): Promise<any>;
|
|
43
|
-
/**
|
|
44
|
-
* Make a POST request
|
|
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.
|
|
49
|
-
*/
|
|
50
|
-
post(apiName: string, path: string, init: {
|
|
51
|
-
[key: string]: any;
|
|
52
|
-
}): Promise<any>;
|
|
53
|
-
/**
|
|
54
|
-
* Make a PUT request
|
|
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.
|
|
59
|
-
*/
|
|
60
|
-
put(apiName: string, path: string, init: {
|
|
61
|
-
[key: string]: any;
|
|
62
|
-
}): Promise<any>;
|
|
63
|
-
/**
|
|
64
|
-
* Make a PATCH request
|
|
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.
|
|
69
|
-
*/
|
|
70
|
-
patch(apiName: string, path: string, init: {
|
|
71
|
-
[key: string]: any;
|
|
72
|
-
}): Promise<any>;
|
|
73
|
-
/**
|
|
74
|
-
* Make a DEL request
|
|
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.
|
|
79
|
-
*/
|
|
80
|
-
del(apiName: string, path: string, init: {
|
|
81
|
-
[key: string]: any;
|
|
82
|
-
}): Promise<any>;
|
|
83
|
-
/**
|
|
84
|
-
* Make a HEAD request
|
|
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.
|
|
89
|
-
*/
|
|
90
|
-
head(apiName: string, path: string, init: {
|
|
91
|
-
[key: string]: any;
|
|
92
|
-
}): Promise<any>;
|
|
93
|
-
/**
|
|
94
|
-
* Checks to see if an error thrown is from an api request cancellation
|
|
95
|
-
* @param error - Any error
|
|
96
|
-
* @return If the error was from an api request cancellation
|
|
97
|
-
*/
|
|
98
|
-
isCancel(error: any): boolean;
|
|
99
|
-
/**
|
|
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
|
|
104
|
-
*/
|
|
105
|
-
cancel(request: Promise<any>, message?: string): boolean;
|
|
106
|
-
/**
|
|
107
|
-
* Getting endpoint for API
|
|
108
|
-
* @param apiName - The name of the api
|
|
109
|
-
* @return The endpoint of the api
|
|
110
|
-
*/
|
|
111
|
-
endpoint(apiName: string): Promise<string>;
|
|
112
|
-
/**
|
|
113
|
-
* to get the operation type
|
|
114
|
-
* @param operation
|
|
115
|
-
*/
|
|
116
|
-
getGraphqlOperationType(operation: GraphQLOperation): OperationTypeNode;
|
|
117
13
|
/**
|
|
118
14
|
* Executes a GraphQL operation
|
|
119
15
|
*
|
package/lib/API.js
CHANGED
|
@@ -1,159 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
var tslib_1 = require("tslib");
|
|
4
|
-
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
5
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
6
|
-
var auth_1 = require("@aws-amplify/auth");
|
|
7
|
-
var cache_1 = require("@aws-amplify/cache");
|
|
8
|
-
var api_rest_1 = require("@aws-amplify/api-rest");
|
|
9
|
-
var api_graphql_1 = require("@aws-amplify/api-graphql");
|
|
10
4
|
var core_1 = require("@aws-amplify/core");
|
|
5
|
+
var InternalAPI_1 = require("./internals/InternalAPI");
|
|
11
6
|
var logger = new core_1.ConsoleLogger('API');
|
|
12
7
|
/**
|
|
13
8
|
* @deprecated
|
|
14
9
|
* Use RestApi or GraphQLAPI to reduce your application bundle size
|
|
15
10
|
* Export Cloud Logic APIs
|
|
16
11
|
*/
|
|
17
|
-
var APIClass = /** @class */ (function () {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
*/
|
|
22
|
-
function APIClass(options) {
|
|
23
|
-
this.Auth = auth_1.Auth;
|
|
24
|
-
this.Cache = cache_1.Cache;
|
|
25
|
-
this.Credentials = core_1.Credentials;
|
|
26
|
-
this._options = options;
|
|
27
|
-
this._restApi = new api_rest_1.RestAPIClass(options);
|
|
28
|
-
this._graphqlApi = new api_graphql_1.GraphQLAPIClass(options);
|
|
29
|
-
logger.debug('API Options', this._options);
|
|
12
|
+
var APIClass = /** @class */ (function (_super) {
|
|
13
|
+
tslib_1.__extends(APIClass, _super);
|
|
14
|
+
function APIClass() {
|
|
15
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
30
16
|
}
|
|
31
17
|
APIClass.prototype.getModuleName = function () {
|
|
32
18
|
return 'API';
|
|
33
19
|
};
|
|
34
|
-
/**
|
|
35
|
-
* Configure API part with aws configurations
|
|
36
|
-
* @param {Object} config - Configuration of the API
|
|
37
|
-
* @return {Object} - The current configuration
|
|
38
|
-
*/
|
|
39
|
-
APIClass.prototype.configure = function (options) {
|
|
40
|
-
this._options = Object.assign({}, this._options, options);
|
|
41
|
-
// Share Amplify instance with client for SSR
|
|
42
|
-
this._restApi.Credentials = this.Credentials;
|
|
43
|
-
this._graphqlApi.Auth = this.Auth;
|
|
44
|
-
this._graphqlApi.Cache = this.Cache;
|
|
45
|
-
this._graphqlApi.Credentials = this.Credentials;
|
|
46
|
-
var restAPIConfig = this._restApi.configure(this._options);
|
|
47
|
-
var graphQLAPIConfig = this._graphqlApi.configure(this._options);
|
|
48
|
-
return tslib_1.__assign(tslib_1.__assign({}, restAPIConfig), graphQLAPIConfig);
|
|
49
|
-
};
|
|
50
|
-
/**
|
|
51
|
-
* Make a GET request
|
|
52
|
-
* @param apiName - The api name of the request
|
|
53
|
-
* @param path - The path of the request
|
|
54
|
-
* @param [init] - Request extra params
|
|
55
|
-
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
56
|
-
*/
|
|
57
|
-
APIClass.prototype.get = function (apiName, path, init) {
|
|
58
|
-
return this._restApi.get(apiName, path, init);
|
|
59
|
-
};
|
|
60
|
-
/**
|
|
61
|
-
* Make a POST request
|
|
62
|
-
* @param apiName - The api name of the request
|
|
63
|
-
* @param path - The path of the request
|
|
64
|
-
* @param [init] - Request extra params
|
|
65
|
-
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
66
|
-
*/
|
|
67
|
-
APIClass.prototype.post = function (apiName, path, init) {
|
|
68
|
-
return this._restApi.post(apiName, path, init);
|
|
69
|
-
};
|
|
70
|
-
/**
|
|
71
|
-
* Make a PUT request
|
|
72
|
-
* @param apiName - The api name of the request
|
|
73
|
-
* @param path - The path of the request
|
|
74
|
-
* @param [init] - Request extra params
|
|
75
|
-
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
76
|
-
*/
|
|
77
|
-
APIClass.prototype.put = function (apiName, path, init) {
|
|
78
|
-
return this._restApi.put(apiName, path, init);
|
|
79
|
-
};
|
|
80
|
-
/**
|
|
81
|
-
* Make a PATCH 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
|
-
APIClass.prototype.patch = function (apiName, path, init) {
|
|
88
|
-
return this._restApi.patch(apiName, path, init);
|
|
89
|
-
};
|
|
90
|
-
/**
|
|
91
|
-
* Make a DEL request
|
|
92
|
-
* @param apiName - The api name of the request
|
|
93
|
-
* @param path - The path of the request
|
|
94
|
-
* @param [init] - Request extra params
|
|
95
|
-
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
96
|
-
*/
|
|
97
|
-
APIClass.prototype.del = function (apiName, path, init) {
|
|
98
|
-
return this._restApi.del(apiName, path, init);
|
|
99
|
-
};
|
|
100
|
-
/**
|
|
101
|
-
* Make a HEAD request
|
|
102
|
-
* @param apiName - The api name of the request
|
|
103
|
-
* @param path - The path of the request
|
|
104
|
-
* @param [init] - Request extra params
|
|
105
|
-
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
106
|
-
*/
|
|
107
|
-
APIClass.prototype.head = function (apiName, path, init) {
|
|
108
|
-
return this._restApi.head(apiName, path, init);
|
|
109
|
-
};
|
|
110
|
-
/**
|
|
111
|
-
* Checks to see if an error thrown is from an api request cancellation
|
|
112
|
-
* @param error - Any error
|
|
113
|
-
* @return If the error was from an api request cancellation
|
|
114
|
-
*/
|
|
115
|
-
APIClass.prototype.isCancel = function (error) {
|
|
116
|
-
return this._restApi.isCancel(error);
|
|
117
|
-
};
|
|
118
|
-
/**
|
|
119
|
-
* Cancels an inflight request for either a GraphQL request or a Rest API request.
|
|
120
|
-
* @param request - request to cancel
|
|
121
|
-
* @param [message] - custom error message
|
|
122
|
-
* @return If the request was cancelled
|
|
123
|
-
*/
|
|
124
|
-
APIClass.prototype.cancel = function (request, message) {
|
|
125
|
-
if (this._restApi.hasCancelToken(request)) {
|
|
126
|
-
return this._restApi.cancel(request, message);
|
|
127
|
-
}
|
|
128
|
-
else if (this._graphqlApi.hasCancelToken(request)) {
|
|
129
|
-
return this._graphqlApi.cancel(request, message);
|
|
130
|
-
}
|
|
131
|
-
return false;
|
|
132
|
-
};
|
|
133
|
-
/**
|
|
134
|
-
* Getting endpoint for API
|
|
135
|
-
* @param apiName - The name of the api
|
|
136
|
-
* @return The endpoint of the api
|
|
137
|
-
*/
|
|
138
|
-
APIClass.prototype.endpoint = function (apiName) {
|
|
139
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
140
|
-
return tslib_1.__generator(this, function (_a) {
|
|
141
|
-
return [2 /*return*/, this._restApi.endpoint(apiName)];
|
|
142
|
-
});
|
|
143
|
-
});
|
|
144
|
-
};
|
|
145
|
-
/**
|
|
146
|
-
* to get the operation type
|
|
147
|
-
* @param operation
|
|
148
|
-
*/
|
|
149
|
-
APIClass.prototype.getGraphqlOperationType = function (operation) {
|
|
150
|
-
return this._graphqlApi.getGraphqlOperationType(operation);
|
|
151
|
-
};
|
|
152
20
|
APIClass.prototype.graphql = function (options, additionalHeaders) {
|
|
153
|
-
return
|
|
21
|
+
return _super.prototype.graphql.call(this, options, additionalHeaders);
|
|
154
22
|
};
|
|
155
23
|
return APIClass;
|
|
156
|
-
}());
|
|
24
|
+
}(InternalAPI_1.InternalAPIClass));
|
|
157
25
|
exports.APIClass = APIClass;
|
|
158
26
|
exports.API = new APIClass(null);
|
|
159
27
|
core_1.Amplify.register(exports.API);
|
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":";;;AAIA,0CAAqE;AAGrE,uDAA2D;AAE3D,IAAM,MAAM,GAAG,IAAI,oBAAM,CAAC,KAAK,CAAC,CAAC;AACjC;;;;GAIG;AACH;IAA8B,oCAAgB;IAA9C;;IA6BA,CAAC;IA5BO,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;IACF,eAAC;AAAD,CAAC,AA7BD,CAA8B,8BAAgB,GA6B7C;AA7BY,4BAAQ;AA+BR,QAAA,GAAG,GAAG,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC;AACtC,cAAO,CAAC,QAAQ,CAAC,WAAG,CAAC,CAAC"}
|
|
@@ -0,0 +1,133 @@
|
|
|
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';
|
|
4
|
+
import Observable from 'zen-observable-ts';
|
|
5
|
+
import { GraphQLQuery, GraphQLSubscription } from '../types';
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated
|
|
8
|
+
* Use RestApi or GraphQLAPI to reduce your application bundle size
|
|
9
|
+
* Export Cloud Logic APIs
|
|
10
|
+
*/
|
|
11
|
+
export declare class InternalAPIClass {
|
|
12
|
+
/**
|
|
13
|
+
* Initialize API with AWS configuration
|
|
14
|
+
* @param {Object} options - Configuration object for API
|
|
15
|
+
*/
|
|
16
|
+
private _options;
|
|
17
|
+
private _restApi;
|
|
18
|
+
private _graphqlApi;
|
|
19
|
+
Auth: import("@aws-amplify/auth/lib-esm/Auth").AuthClass;
|
|
20
|
+
Cache: import("@aws-amplify/cache/lib-esm/types").ICache;
|
|
21
|
+
Credentials: import("@aws-amplify/core").CredentialsClass;
|
|
22
|
+
/**
|
|
23
|
+
* Initialize API with AWS configuration
|
|
24
|
+
* @param {Object} options - Configuration object for API
|
|
25
|
+
*/
|
|
26
|
+
constructor(options: any);
|
|
27
|
+
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
|
+
/**
|
|
95
|
+
* Checks to see if an error thrown is from an api request cancellation
|
|
96
|
+
* @param error - Any error
|
|
97
|
+
* @return If the error was from an api request cancellation
|
|
98
|
+
*/
|
|
99
|
+
isCancel(error: any): boolean;
|
|
100
|
+
/**
|
|
101
|
+
* Cancels an inflight request for either a GraphQL request or a Rest API request.
|
|
102
|
+
* @param request - request to cancel
|
|
103
|
+
* @param [message] - custom error message
|
|
104
|
+
* @return If the request was cancelled
|
|
105
|
+
*/
|
|
106
|
+
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
|
+
/**
|
|
115
|
+
* to get the operation type
|
|
116
|
+
* @param operation
|
|
117
|
+
*/
|
|
118
|
+
getGraphqlOperationType(operation: GraphQLOperation): OperationTypeNode;
|
|
119
|
+
/**
|
|
120
|
+
* Executes a GraphQL operation
|
|
121
|
+
*
|
|
122
|
+
* @param options - GraphQL Options
|
|
123
|
+
* @param [additionalHeaders] - headers to merge in after any `graphql_headers` set in the config
|
|
124
|
+
* @returns An Observable if queryType is 'subscription', else a promise of the graphql result from the query.
|
|
125
|
+
*/
|
|
126
|
+
graphql<T>(options: GraphQLOptions, additionalHeaders?: {
|
|
127
|
+
[key: string]: string;
|
|
128
|
+
}, customUserAgentDetails?: CustomUserAgentDetails): T extends GraphQLQuery<T> ? Promise<GraphQLResult<T>> : T extends GraphQLSubscription<T> ? Observable<{
|
|
129
|
+
provider: AWSAppSyncRealTimeProvider;
|
|
130
|
+
value: GraphQLResult<T>;
|
|
131
|
+
}> : Promise<GraphQLResult<any>> | Observable<object>;
|
|
132
|
+
}
|
|
133
|
+
export declare const InternalAPI: InternalAPIClass;
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var tslib_1 = require("tslib");
|
|
4
|
+
var internals_1 = require("@aws-amplify/api-graphql/internals");
|
|
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
|
+
var core_1 = require("@aws-amplify/core");
|
|
9
|
+
var logger = new core_1.ConsoleLogger('API');
|
|
10
|
+
/**
|
|
11
|
+
* @deprecated
|
|
12
|
+
* Use RestApi or GraphQLAPI to reduce your application bundle size
|
|
13
|
+
* Export Cloud Logic APIs
|
|
14
|
+
*/
|
|
15
|
+
var InternalAPIClass = /** @class */ (function () {
|
|
16
|
+
/**
|
|
17
|
+
* Initialize API with AWS configuration
|
|
18
|
+
* @param {Object} options - Configuration object for API
|
|
19
|
+
*/
|
|
20
|
+
function InternalAPIClass(options) {
|
|
21
|
+
this.Auth = auth_1.Auth;
|
|
22
|
+
this.Cache = cache_1.Cache;
|
|
23
|
+
this.Credentials = core_1.Credentials;
|
|
24
|
+
this._options = options;
|
|
25
|
+
this._restApi = new api_rest_1.RestAPIClass(options);
|
|
26
|
+
this._graphqlApi = new internals_1.InternalGraphQLAPIClass(options);
|
|
27
|
+
logger.debug('API Options', this._options);
|
|
28
|
+
}
|
|
29
|
+
InternalAPIClass.prototype.getModuleName = function () {
|
|
30
|
+
return 'InternalAPI';
|
|
31
|
+
};
|
|
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
|
+
/**
|
|
109
|
+
* Checks to see if an error thrown is from an api request cancellation
|
|
110
|
+
* @param error - Any error
|
|
111
|
+
* @return If the error was from an api request cancellation
|
|
112
|
+
*/
|
|
113
|
+
InternalAPIClass.prototype.isCancel = function (error) {
|
|
114
|
+
return this._restApi.isCancel(error);
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* Cancels an inflight request for either a GraphQL request or a Rest API request.
|
|
118
|
+
* @param request - request to cancel
|
|
119
|
+
* @param [message] - custom error message
|
|
120
|
+
* @return If the request was cancelled
|
|
121
|
+
*/
|
|
122
|
+
InternalAPIClass.prototype.cancel = function (request, message) {
|
|
123
|
+
if (this._restApi.hasCancelToken(request)) {
|
|
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
|
+
});
|
|
150
|
+
};
|
|
151
|
+
/**
|
|
152
|
+
* to get the operation type
|
|
153
|
+
* @param operation
|
|
154
|
+
*/
|
|
155
|
+
InternalAPIClass.prototype.getGraphqlOperationType = function (operation) {
|
|
156
|
+
return this._graphqlApi.getGraphqlOperationType(operation);
|
|
157
|
+
};
|
|
158
|
+
InternalAPIClass.prototype.graphql = function (options, additionalHeaders, customUserAgentDetails) {
|
|
159
|
+
var apiUserAgentDetails = tslib_1.__assign({ category: core_1.Category.API, action: core_1.ApiAction.GraphQl }, customUserAgentDetails);
|
|
160
|
+
return this._graphqlApi.graphql(options, additionalHeaders, apiUserAgentDetails);
|
|
161
|
+
};
|
|
162
|
+
return InternalAPIClass;
|
|
163
|
+
}());
|
|
164
|
+
exports.InternalAPIClass = InternalAPIClass;
|
|
165
|
+
exports.InternalAPI = new InternalAPIClass(null);
|
|
166
|
+
core_1.Amplify.register(exports.InternalAPI);
|
|
167
|
+
//# sourceMappingURL=InternalAPI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InternalAPI.js","sourceRoot":"","sources":["../../src/internals/InternalAPI.ts"],"names":[],"mappings":";;;AAQA,gEAA6E;AAC7E,kDAAqD;AACrD,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AAuB,EACvB,iBAA6C,EAC7C,sBAA+C;QAE/C,IAAM,mBAAmB,sBACxB,QAAQ,EAAE,eAAQ,CAAC,GAAG,EACtB,MAAM,EAAE,gBAAS,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,AA3PD,IA2PC;AA3PY,4CAAgB;AA6PhB,QAAA,WAAW,GAAG,IAAI,gBAAgB,CAAC,IAAI,CAAC,CAAC;AACtD,cAAO,CAAC,QAAQ,CAAC,mBAAW,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { InternalAPI, InternalAPIClass } from './InternalAPI';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
4
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
var InternalAPI_1 = require("./InternalAPI");
|
|
6
|
+
exports.InternalAPI = InternalAPI_1.InternalAPI;
|
|
7
|
+
exports.InternalAPIClass = InternalAPI_1.InternalAPIClass;
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/internals/index.ts"],"names":[],"mappings":";;AAAA,qEAAqE;AACrE,sCAAsC;AACtC,6CAA8D;AAArD,oCAAA,WAAW,CAAA;AAAE,yCAAA,gBAAgB,CAAA"}
|