@aws-amplify/api 5.2.2-unstable.f47d472.1 → 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/lib-esm/API.d.ts CHANGED
@@ -1,119 +1,15 @@
1
1
  import { AWSAppSyncRealTimeProvider } from '@aws-amplify/pubsub';
2
- import { GraphQLOptions, GraphQLResult, GraphQLOperation, OperationTypeNode } from '@aws-amplify/api-graphql';
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-esm/API.js CHANGED
@@ -1,157 +1,25 @@
1
- import { __assign, __awaiter, __generator } from "tslib";
2
- // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
- // SPDX-License-Identifier: Apache-2.0
4
- import { Auth } from '@aws-amplify/auth';
5
- import { Cache } from '@aws-amplify/cache';
6
- import { RestAPIClass } from '@aws-amplify/api-rest';
7
- import { GraphQLAPIClass, } from '@aws-amplify/api-graphql';
8
- import { Amplify, ConsoleLogger as Logger, Credentials, } from '@aws-amplify/core';
1
+ import { __extends } from "tslib";
2
+ import { Amplify, ConsoleLogger as Logger } from '@aws-amplify/core';
3
+ import { InternalAPIClass } from './internals/InternalAPI';
9
4
  var logger = new Logger('API');
10
5
  /**
11
6
  * @deprecated
12
7
  * Use RestApi or GraphQLAPI to reduce your application bundle size
13
8
  * Export Cloud Logic APIs
14
9
  */
15
- var APIClass = /** @class */ (function () {
16
- /**
17
- * Initialize API with AWS configuration
18
- * @param {Object} options - Configuration object for API
19
- */
20
- function APIClass(options) {
21
- this.Auth = Auth;
22
- this.Cache = Cache;
23
- this.Credentials = Credentials;
24
- this._options = options;
25
- this._restApi = new RestAPIClass(options);
26
- this._graphqlApi = new GraphQLAPIClass(options);
27
- logger.debug('API Options', this._options);
10
+ var APIClass = /** @class */ (function (_super) {
11
+ __extends(APIClass, _super);
12
+ function APIClass() {
13
+ return _super !== null && _super.apply(this, arguments) || this;
28
14
  }
29
15
  APIClass.prototype.getModuleName = function () {
30
16
  return 'API';
31
17
  };
32
- /**
33
- * Configure API part with aws configurations
34
- * @param {Object} config - Configuration of the API
35
- * @return {Object} - The current configuration
36
- */
37
- APIClass.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 __assign(__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
- APIClass.prototype.get = function (apiName, path, init) {
56
- return this._restApi.get(apiName, path, init);
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
- APIClass.prototype.post = function (apiName, path, init) {
66
- return this._restApi.post(apiName, path, init);
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
- APIClass.prototype.put = function (apiName, path, init) {
76
- return this._restApi.put(apiName, path, init);
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
- APIClass.prototype.patch = function (apiName, path, init) {
86
- return this._restApi.patch(apiName, path, init);
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
- APIClass.prototype.del = function (apiName, path, init) {
96
- return this._restApi.del(apiName, path, init);
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
- APIClass.prototype.head = function (apiName, path, init) {
106
- return this._restApi.head(apiName, path, init);
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
- APIClass.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
- APIClass.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
- /**
132
- * Getting endpoint for API
133
- * @param apiName - The name of the api
134
- * @return The endpoint of the api
135
- */
136
- APIClass.prototype.endpoint = function (apiName) {
137
- return __awaiter(this, void 0, void 0, function () {
138
- return __generator(this, function (_a) {
139
- return [2 /*return*/, this._restApi.endpoint(apiName)];
140
- });
141
- });
142
- };
143
- /**
144
- * to get the operation type
145
- * @param operation
146
- */
147
- APIClass.prototype.getGraphqlOperationType = function (operation) {
148
- return this._graphqlApi.getGraphqlOperationType(operation);
149
- };
150
18
  APIClass.prototype.graphql = function (options, additionalHeaders) {
151
- return this._graphqlApi.graphql(options, additionalHeaders);
19
+ return _super.prototype.graphql.call(this, options, additionalHeaders);
152
20
  };
153
21
  return APIClass;
154
- }());
22
+ }(InternalAPIClass));
155
23
  export { APIClass };
156
24
  export var API = new APIClass(null);
157
25
  Amplify.register(API);
@@ -1 +1 @@
1
- {"version":3,"file":"API.js","sourceRoot":"","sources":["../src/API.ts"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EACN,eAAe,GAKf,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACN,OAAO,EACP,aAAa,IAAI,MAAM,EAC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O,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,gBAAgB,GA6B7C;;AAED,MAAM,CAAC,IAAM,GAAG,GAAG,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC;AACtC,OAAO,CAAC,QAAQ,CAAC,GAAG,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,165 @@
1
+ import { __assign, __awaiter, __generator } from "tslib";
2
+ import { InternalGraphQLAPIClass } from '@aws-amplify/api-graphql/internals';
3
+ import { RestAPIClass } from '@aws-amplify/api-rest';
4
+ import { Auth } from '@aws-amplify/auth';
5
+ import { Cache } from '@aws-amplify/cache';
6
+ import { Amplify, ApiAction, Category, Credentials, ConsoleLogger as Logger, } from '@aws-amplify/core';
7
+ var logger = new Logger('API');
8
+ /**
9
+ * @deprecated
10
+ * Use RestApi or GraphQLAPI to reduce your application bundle size
11
+ * Export Cloud Logic APIs
12
+ */
13
+ var InternalAPIClass = /** @class */ (function () {
14
+ /**
15
+ * Initialize API with AWS configuration
16
+ * @param {Object} options - Configuration object for API
17
+ */
18
+ function InternalAPIClass(options) {
19
+ this.Auth = Auth;
20
+ this.Cache = Cache;
21
+ this.Credentials = Credentials;
22
+ this._options = options;
23
+ this._restApi = new RestAPIClass(options);
24
+ this._graphqlApi = new InternalGraphQLAPIClass(options);
25
+ logger.debug('API Options', this._options);
26
+ }
27
+ InternalAPIClass.prototype.getModuleName = function () {
28
+ return 'InternalAPI';
29
+ };
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
+ /**
107
+ * Checks to see if an error thrown is from an api request cancellation
108
+ * @param error - Any error
109
+ * @return If the error was from an api request cancellation
110
+ */
111
+ InternalAPIClass.prototype.isCancel = function (error) {
112
+ return this._restApi.isCancel(error);
113
+ };
114
+ /**
115
+ * Cancels an inflight request for either a GraphQL request or a Rest API request.
116
+ * @param request - request to cancel
117
+ * @param [message] - custom error message
118
+ * @return If the request was cancelled
119
+ */
120
+ InternalAPIClass.prototype.cancel = function (request, message) {
121
+ if (this._restApi.hasCancelToken(request)) {
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
+ });
148
+ };
149
+ /**
150
+ * to get the operation type
151
+ * @param operation
152
+ */
153
+ InternalAPIClass.prototype.getGraphqlOperationType = function (operation) {
154
+ return this._graphqlApi.getGraphqlOperationType(operation);
155
+ };
156
+ InternalAPIClass.prototype.graphql = function (options, additionalHeaders, customUserAgentDetails) {
157
+ var apiUserAgentDetails = __assign({ category: Category.API, action: ApiAction.GraphQl }, customUserAgentDetails);
158
+ return this._graphqlApi.graphql(options, additionalHeaders, apiUserAgentDetails);
159
+ };
160
+ return InternalAPIClass;
161
+ }());
162
+ export { InternalAPIClass };
163
+ export var InternalAPI = new InternalAPIClass(null);
164
+ Amplify.register(InternalAPI);
165
+ //# sourceMappingURL=InternalAPI.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InternalAPI.js","sourceRoot":"","sources":["../../src/internals/InternalAPI.ts"],"names":[],"mappings":";AAQA,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EACN,OAAO,EACP,SAAS,EACT,QAAQ,EACR,WAAW,EAEX,aAAa,IAAI,MAAM,GACvB,MAAM,mBAAmB,CAAC;AAK3B,IAAM,MAAM,GAAG,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC;AACjC;;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S,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;;AAED,MAAM,CAAC,IAAM,WAAW,GAAG,IAAI,gBAAgB,CAAC,IAAI,CAAC,CAAC;AACtD,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export { InternalAPI, InternalAPIClass } from './InternalAPI';
@@ -0,0 +1,4 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ export { InternalAPI, InternalAPIClass } from './InternalAPI';
4
+ //# 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,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-amplify/api",
3
- "version": "5.2.2-unstable.f47d472.1+f47d472ea",
3
+ "version": "5.3.0",
4
4
  "description": "Api category of aws-amplify",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib-esm/index.js",
@@ -54,11 +54,12 @@
54
54
  "lib",
55
55
  "lib-esm",
56
56
  "src",
57
- "index.*.d.ts"
57
+ "index.*.d.ts",
58
+ "internals"
58
59
  ],
59
60
  "dependencies": {
60
- "@aws-amplify/api-graphql": "3.3.2-unstable.f47d472.1+f47d472ea",
61
- "@aws-amplify/api-rest": "3.2.2-unstable.f47d472.1+f47d472ea",
61
+ "@aws-amplify/api-graphql": "3.4.0",
62
+ "@aws-amplify/api-rest": "3.3.0",
62
63
  "tslib": "^1.8.0"
63
64
  },
64
65
  "size-limit": [
@@ -66,7 +67,7 @@
66
67
  "name": "API (top-level class)",
67
68
  "path": "./lib-esm/index.js",
68
69
  "import": "{ Amplify, API }",
69
- "limit": "88.35 kB"
70
+ "limit": "89 kB"
70
71
  }
71
72
  ],
72
73
  "jest": {
@@ -113,5 +114,5 @@
113
114
  "lib-esm"
114
115
  ]
115
116
  },
116
- "gitHead": "f47d472ea021dadb1a04d03295c3c6065155f0c0"
117
+ "gitHead": "95ab2ccdd0fd62afd90c02e3e8273d4acc400ddc"
117
118
  }