@aws-amplify/api 5.4.6-unstable.7762f1a.0 → 6.0.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 ADDED
@@ -0,0 +1,3 @@
1
+ > INTERNAL USE ONLY
2
+
3
+ This package contains the AWS Amplify API category and is intended for internal use only. To integrate Amplify into your app, please use [aws-amplify](https://www.npmjs.com/package/aws-amplify).
package/lib/API.d.ts CHANGED
@@ -1,27 +1,5 @@
1
- import { AWSAppSyncRealTimeProvider } from '@aws-amplify/pubsub';
2
- import { GraphQLOptions, GraphQLResult } from '@aws-amplify/api-graphql';
3
- import Observable from 'zen-observable-ts';
4
- import { GraphQLQuery, GraphQLSubscription } from './types';
5
- import { InternalAPIClass } from './internals/InternalAPI';
1
+ import { V6Client } from '@aws-amplify/api-graphql';
6
2
  /**
7
- * @deprecated
8
- * Use RestApi or GraphQLAPI to reduce your application bundle size
9
- * Export Cloud Logic APIs
3
+ * Generates an API client that can work with models or raw GraphQL
10
4
  */
11
- export declare class APIClass extends InternalAPIClass {
12
- getModuleName(): string;
13
- /**
14
- * Executes a GraphQL operation
15
- *
16
- * @param options - GraphQL Options
17
- * @param [additionalHeaders] - headers to merge in after any `graphql_headers` set in the config
18
- * @returns An Observable if queryType is 'subscription', else a promise of the graphql result from the query.
19
- */
20
- graphql<T>(options: GraphQLOptions, additionalHeaders?: {
21
- [key: string]: string;
22
- }): T extends GraphQLQuery<T> ? Promise<GraphQLResult<T>> : T extends GraphQLSubscription<T> ? Observable<{
23
- provider: AWSAppSyncRealTimeProvider;
24
- value: GraphQLResult<T>;
25
- }> : Promise<GraphQLResult<any>> | Observable<object>;
26
- }
27
- export declare const API: APIClass;
5
+ export declare function generateClient<T extends Record<any, any> = never>(): V6Client<T>;
package/lib/API.js CHANGED
@@ -1,28 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var tslib_1 = require("tslib");
4
- var core_1 = require("@aws-amplify/core");
5
- var InternalAPI_1 = require("./internals/InternalAPI");
6
- var logger = new core_1.ConsoleLogger('API');
3
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ // SPDX-License-Identifier: Apache-2.0
5
+ const api_graphql_1 = require("@aws-amplify/api-graphql");
6
+ const internals_1 = require("@aws-amplify/api-graphql/internals");
7
+ const core_1 = require("@aws-amplify/core");
7
8
  /**
8
- * @deprecated
9
- * Use RestApi or GraphQLAPI to reduce your application bundle size
10
- * Export Cloud Logic APIs
9
+ * Generates an API client that can work with models or raw GraphQL
11
10
  */
12
- var APIClass = /** @class */ (function (_super) {
13
- tslib_1.__extends(APIClass, _super);
14
- function APIClass() {
15
- return _super !== null && _super.apply(this, arguments) || this;
16
- }
17
- APIClass.prototype.getModuleName = function () {
18
- return 'API';
11
+ function generateClient() {
12
+ return {
13
+ [api_graphql_1.__amplify]: core_1.Amplify,
14
+ graphql: internals_1.graphql,
15
+ cancel: internals_1.cancel,
16
+ isCancelError: internals_1.isCancelError,
19
17
  };
20
- APIClass.prototype.graphql = function (options, additionalHeaders) {
21
- return _super.prototype.graphql.call(this, options, additionalHeaders);
22
- };
23
- return APIClass;
24
- }(InternalAPI_1.InternalAPIClass));
25
- exports.APIClass = APIClass;
26
- exports.API = new APIClass(null);
27
- core_1.Amplify.register(exports.API);
18
+ }
19
+ exports.generateClient = generateClient;
28
20
  //# 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":";;;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"}
1
+ {"version":3,"file":"API.js","sourceRoot":"","sources":["../src/API.ts"],"names":[],"mappings":";;AAAA,qEAAqE;AACrE,sCAAsC;AACtC,0DAA+D;AAC/D,kEAI4C;AAC5C,4CAA4C;AAE5C;;GAEG;AACH,SAAgB,cAAc;IAG7B,OAAO;QACN,CAAC,uBAAS,CAAC,EAAE,cAAO;QACpB,OAAO,EAAE,mBAAS;QAClB,MAAM,EAAE,kBAAQ;QAChB,aAAa,EAAE,yBAAe;KAC9B,CAAC;AACH,CAAC;AATD,wCASC"}
package/lib/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export { GraphQLQuery, GraphQLSubscription } from './types';
2
- export { API, APIClass } from './API';
3
- export { graphqlOperation, GraphQLAuthError, GRAPHQL_AUTH_MODE, } from '@aws-amplify/api-graphql';
4
- export type { GraphQLResult } from '@aws-amplify/api-graphql';
2
+ export { generateClient } from './API';
3
+ export { GraphQLAuthError } from '@aws-amplify/api-graphql';
4
+ export type { GraphQLResult, GraphQLReturnType, } from '@aws-amplify/api-graphql';
5
+ export { get, put, post, del, head, patch, isCancelError, } from '@aws-amplify/api-rest';
package/lib/index.js CHANGED
@@ -3,10 +3,15 @@
3
3
  // SPDX-License-Identifier: Apache-2.0
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
5
  var API_1 = require("./API");
6
- exports.API = API_1.API;
7
- exports.APIClass = API_1.APIClass;
6
+ exports.generateClient = API_1.generateClient;
8
7
  var api_graphql_1 = require("@aws-amplify/api-graphql");
9
- exports.graphqlOperation = api_graphql_1.graphqlOperation;
10
8
  exports.GraphQLAuthError = api_graphql_1.GraphQLAuthError;
11
- exports.GRAPHQL_AUTH_MODE = api_graphql_1.GRAPHQL_AUTH_MODE;
9
+ var api_rest_1 = require("@aws-amplify/api-rest");
10
+ exports.get = api_rest_1.get;
11
+ exports.put = api_rest_1.put;
12
+ exports.post = api_rest_1.post;
13
+ exports.del = api_rest_1.del;
14
+ exports.head = api_rest_1.head;
15
+ exports.patch = api_rest_1.patch;
16
+ exports.isCancelError = api_rest_1.isCancelError;
12
17
  //# 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;;AAGtC,6BAAsC;AAA7B,oBAAA,GAAG,CAAA;AAAE,yBAAA,QAAQ,CAAA;AACtB,wDAIkC;AAHjC,yCAAA,gBAAgB,CAAA;AAChB,yCAAA,gBAAgB,CAAA;AAChB,0CAAA,iBAAiB,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;;AAKtC,6BAAuC;AAA9B,+BAAA,cAAc,CAAA;AAEvB,wDAA4D;AAAnD,yCAAA,gBAAgB,CAAA;AAOzB,kDAQ+B;AAP9B,yBAAA,GAAG,CAAA;AACH,yBAAA,GAAG,CAAA;AACH,0BAAA,IAAI,CAAA;AACJ,yBAAA,GAAG,CAAA;AACH,0BAAA,IAAI,CAAA;AACJ,2BAAA,KAAK,CAAA;AACL,mCAAA,aAAa,CAAA"}
@@ -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';
4
- import Observable from 'zen-observable-ts';
5
- import { GraphQLQuery, GraphQLSubscription } from '../types';
1
+ import { AWSAppSyncRealTimeProvider, GraphQLOperation, GraphQLOptions, GraphQLResult, OperationTypeNode, GraphQLQuery, GraphQLSubscription } from '@aws-amplify/api-graphql';
2
+ import { CustomUserAgentDetails } from '@aws-amplify/core/internals/utils';
3
+ import { Observable } from 'rxjs';
6
4
  /**
7
5
  * @deprecated
8
6
  * Use RestApi or GraphQLAPI to reduce your application bundle size
@@ -14,103 +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
- 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;
16
+ Cache: import("@aws-amplify/core/lib-esm/Cache/StorageCache").StorageCache;
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
- /**
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
23
  /**
115
24
  * to get the operation type
116
25
  * @param operation
@@ -1,167 +1,52 @@
1
1
  "use strict";
2
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');
3
+ const internals_1 = require("@aws-amplify/api-graphql/internals");
4
+ const core_1 = require("@aws-amplify/core");
5
+ const utils_1 = require("@aws-amplify/core/internals/utils");
6
+ /**
7
+ * NOTE!
8
+ *
9
+ * This is used only by DataStore.
10
+ *
11
+ * This can probably be pruned and/or removed. Just leaving it as much of the same
12
+ * state as possible for V6 to reduce number of potentially impactful changes to DataStore.
13
+ */
14
+ const logger = new core_1.ConsoleLogger('API');
10
15
  /**
11
16
  * @deprecated
12
17
  * Use RestApi or GraphQLAPI to reduce your application bundle size
13
18
  * Export Cloud Logic APIs
14
19
  */
15
- var InternalAPIClass = /** @class */ (function () {
20
+ class InternalAPIClass {
16
21
  /**
17
22
  * Initialize API with AWS configuration
18
23
  * @param {Object} options - Configuration object for API
19
24
  */
20
- function InternalAPIClass(options) {
21
- this.Auth = auth_1.Auth;
22
- this.Cache = cache_1.Cache;
23
- this.Credentials = core_1.Credentials;
25
+ constructor(options) {
26
+ this.Cache = core_1.Cache;
24
27
  this._options = options;
25
- this._restApi = new api_rest_1.RestAPIClass(options);
26
28
  this._graphqlApi = new internals_1.InternalGraphQLAPIClass(options);
27
29
  logger.debug('API Options', this._options);
28
30
  }
29
- InternalAPIClass.prototype.getModuleName = function () {
31
+ getModuleName() {
30
32
  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
- };
33
+ }
151
34
  /**
152
35
  * to get the operation type
153
36
  * @param operation
154
37
  */
155
- InternalAPIClass.prototype.getGraphqlOperationType = function (operation) {
38
+ getGraphqlOperationType(operation) {
156
39
  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
- }());
40
+ }
41
+ graphql(options, additionalHeaders, customUserAgentDetails) {
42
+ const apiUserAgentDetails = {
43
+ category: utils_1.Category.API,
44
+ action: utils_1.ApiAction.GraphQl,
45
+ ...customUserAgentDetails,
46
+ };
47
+ return this._graphqlApi.graphql(core_1.Amplify, options, additionalHeaders, apiUserAgentDetails);
48
+ }
49
+ }
164
50
  exports.InternalAPIClass = InternalAPIClass;
165
51
  exports.InternalAPI = new InternalAPIClass(null);
166
- core_1.Amplify.register(exports.InternalAPI);
167
52
  //# sourceMappingURL=InternalAPI.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"InternalAPI.js","sourceRoot":"","sources":["../../src/internals/InternalAPI.ts"],"names":[],"mappings":";;;AAQA,gEAA6E;AAC7E,kDAAqD;AACrD,0CAAyC;AACzC,4CAA2C;AAC3C,0CAO2B;AAK3B,IAAM,MAAM,GAAG,IAAI,oBAAM,CAAC,KAAK,CAAC,CAAC;AACjC;;;;GAIG;AACH;IAaC;;;OAGG;IACH,0BAAY,OAAO;QARnB,SAAI,GAAG,WAAI,CAAC;QACZ,UAAK,GAAG,aAAK,CAAC;QACd,gBAAW,GAAG,kBAAW,CAAC;QAOzB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,QAAQ,GAAG,IAAI,uBAAY,CAAC,OAAO,CAAC,CAAC;QAC1C,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,oCAAS,GAAT,UAAU,OAAO;QAChB,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAE1D,6CA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,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,aAAa;QACnB,OAAO,aAAa,CAAC;IACtB,CAAC;IAED;;;OAGG;IACH,uBAAuB,CAAC,SAA2B;QAClD,OAAO,IAAI,CAAC,WAAW,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC;IAC5D,CAAC;IAqBD,OAAO,CACN,OAAuB,EACvB,iBAA6C,EAC7C,sBAA+C;QAE/C,MAAM,mBAAmB,GAA2B;YACnD,QAAQ,EAAE,gBAAQ,CAAC,GAAG;YACtB,MAAM,EAAE,iBAAS,CAAC,OAAO;YACzB,GAAG,sBAAsB;SACzB,CAAC;QAEF,OAAO,IAAI,CAAC,WAAW,CAAC,OAAO,CAC9B,cAAO,EACP,OAAO,EACP,iBAAiB,EACjB,mBAAmB,CACnB,CAAC;IACH,CAAC;CACD;AArED,4CAqEC;AAEY,QAAA,WAAW,GAAG,IAAI,gBAAgB,CAAC,IAAI,CAAC,CAAC"}
@@ -0,0 +1,14 @@
1
+ export { GraphQLQuery, GraphQLSubscription } from './types';
2
+ import { V6Client, V6ClientSSR, ServerClientGenerationParams } from '@aws-amplify/api-graphql';
3
+ export type { GraphQLResult, GraphQLReturnType, } from '@aws-amplify/api-graphql';
4
+ /**
5
+ * @private
6
+ *
7
+ * Creates a client that can be used to make GraphQL requests, using a provided `AmplifyClassV6`
8
+ * compatible context object for config and auth fetching.
9
+ *
10
+ * @param params
11
+ * @returns
12
+ */
13
+ export declare function generateClient<T extends Record<any, any> = never, ClientType extends V6ClientSSR<T> | V6Client<T> = V6ClientSSR<T>>(params: ServerClientGenerationParams): ClientType;
14
+ export { get, put, post, del, head, patch, isCancelError, } from '@aws-amplify/api-rest/server';
package/lib/server.js ADDED
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ // SPDX-License-Identifier: Apache-2.0
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ const internals_1 = require("@aws-amplify/api-graphql/internals");
6
+ const api_graphql_1 = require("@aws-amplify/api-graphql");
7
+ /**
8
+ * @private
9
+ *
10
+ * Creates a client that can be used to make GraphQL requests, using a provided `AmplifyClassV6`
11
+ * compatible context object for config and auth fetching.
12
+ *
13
+ * @param params
14
+ * @returns
15
+ */
16
+ function generateClient(params) {
17
+ const client = {
18
+ [api_graphql_1.__amplify]: params.amplify,
19
+ graphql: internals_1.graphql,
20
+ cancel: internals_1.cancel,
21
+ isCancelError: internals_1.isCancelError,
22
+ models: {},
23
+ };
24
+ return client;
25
+ }
26
+ exports.generateClient = generateClient;
27
+ var server_1 = require("@aws-amplify/api-rest/server");
28
+ exports.get = server_1.get;
29
+ exports.put = server_1.put;
30
+ exports.post = server_1.post;
31
+ exports.del = server_1.del;
32
+ exports.head = server_1.head;
33
+ exports.patch = server_1.patch;
34
+ exports.isCancelError = server_1.isCancelError;
35
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;;AAGtC,kEAI4C;AAM5C,0DAKkC;AAOlC;;;;;;;;GAQG;AACH,SAAgB,cAAc,CAG5B,MAAoC;IACrC,MAAM,MAAM,GAAG;QACd,CAAC,uBAAS,CAAC,EAAE,MAAM,CAAC,OAAO;QAC3B,OAAO,EAAP,mBAAO;QACP,MAAM,EAAN,kBAAM;QACN,aAAa,EAAb,yBAAa;QACb,MAAM,EAAE,EAAE;KACH,CAAC;IAET,OAAO,MAAoB,CAAC;AAC7B,CAAC;AAbD,wCAaC;AAED,uDAQsC;AAPrC,uBAAA,GAAG,CAAA;AACH,uBAAA,GAAG,CAAA;AACH,wBAAA,IAAI,CAAA;AACJ,uBAAA,GAAG,CAAA;AACH,wBAAA,IAAI,CAAA;AACJ,yBAAA,KAAK,CAAA;AACL,iCAAA,aAAa,CAAA"}
@@ -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, GRAPHQL_AUTH_MODE, } from '@aws-amplify/api-graphql';
7
- declare const queryType: unique symbol;
8
- export declare type GraphQLQuery<T> = T & {
9
- readonly [queryType]: 'query';
10
- };
11
- export declare type GraphQLSubscription<T> = T & {
12
- readonly [queryType]: 'subscription';
13
- };
6
+ export { graphqlOperation, GraphQLAuthError, GraphQLResult, GraphQLQuery, GraphQLSubscription, } from '@aws-amplify/api-graphql';
@@ -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
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;;AAEtC;;;;GAIG;AACH,wDAKkC;AAJjC,yCAAA,gBAAgB,CAAA;AAChB,yCAAA,gBAAgB,CAAA;AAEhB,0CAAA,iBAAiB,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;;AAEtC;;;;GAIG;AACH,wDAMkC;AALjC,yCAAA,gBAAgB,CAAA;AAChB,yCAAA,gBAAgB,CAAA"}
package/lib-esm/API.d.ts CHANGED
@@ -1,27 +1,5 @@
1
- import { AWSAppSyncRealTimeProvider } from '@aws-amplify/pubsub';
2
- import { GraphQLOptions, GraphQLResult } from '@aws-amplify/api-graphql';
3
- import Observable from 'zen-observable-ts';
4
- import { GraphQLQuery, GraphQLSubscription } from './types';
5
- import { InternalAPIClass } from './internals/InternalAPI';
1
+ import { V6Client } from '@aws-amplify/api-graphql';
6
2
  /**
7
- * @deprecated
8
- * Use RestApi or GraphQLAPI to reduce your application bundle size
9
- * Export Cloud Logic APIs
3
+ * Generates an API client that can work with models or raw GraphQL
10
4
  */
11
- export declare class APIClass extends InternalAPIClass {
12
- getModuleName(): string;
13
- /**
14
- * Executes a GraphQL operation
15
- *
16
- * @param options - GraphQL Options
17
- * @param [additionalHeaders] - headers to merge in after any `graphql_headers` set in the config
18
- * @returns An Observable if queryType is 'subscription', else a promise of the graphql result from the query.
19
- */
20
- graphql<T>(options: GraphQLOptions, additionalHeaders?: {
21
- [key: string]: string;
22
- }): T extends GraphQLQuery<T> ? Promise<GraphQLResult<T>> : T extends GraphQLSubscription<T> ? Observable<{
23
- provider: AWSAppSyncRealTimeProvider;
24
- value: GraphQLResult<T>;
25
- }> : Promise<GraphQLResult<any>> | Observable<object>;
26
- }
27
- export declare const API: APIClass;
5
+ export declare function generateClient<T extends Record<any, any> = never>(): V6Client<T>;
package/lib-esm/API.js CHANGED
@@ -1,26 +1,17 @@
1
- import { __extends } from "tslib";
2
- import { Amplify, ConsoleLogger as Logger } from '@aws-amplify/core';
3
- import { InternalAPIClass } from './internals/InternalAPI';
4
- var logger = new Logger('API');
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import { __amplify } from '@aws-amplify/api-graphql';
4
+ import { graphql as v6graphql, cancel as v6cancel, isCancelError as v6isCancelError, } from '@aws-amplify/api-graphql/internals';
5
+ import { Amplify } from '@aws-amplify/core';
5
6
  /**
6
- * @deprecated
7
- * Use RestApi or GraphQLAPI to reduce your application bundle size
8
- * Export Cloud Logic APIs
7
+ * Generates an API client that can work with models or raw GraphQL
9
8
  */
10
- var APIClass = /** @class */ (function (_super) {
11
- __extends(APIClass, _super);
12
- function APIClass() {
13
- return _super !== null && _super.apply(this, arguments) || this;
14
- }
15
- APIClass.prototype.getModuleName = function () {
16
- return 'API';
9
+ export function generateClient() {
10
+ return {
11
+ [__amplify]: Amplify,
12
+ graphql: v6graphql,
13
+ cancel: v6cancel,
14
+ isCancelError: v6isCancelError,
17
15
  };
18
- APIClass.prototype.graphql = function (options, additionalHeaders) {
19
- return _super.prototype.graphql.call(this, options, additionalHeaders);
20
- };
21
- return APIClass;
22
- }(InternalAPIClass));
23
- export { APIClass };
24
- export var API = new APIClass(null);
25
- Amplify.register(API);
16
+ }
26
17
  //# sourceMappingURL=API.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"API.js","sourceRoot":"","sources":["../src/API.ts"],"names":[],"mappings":";AAIA,OAAO,EAAE,OAAO,EAAE,aAAa,IAAI,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAGrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,IAAM,MAAM,GAAG,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC;AACjC;;;;GAIG;AACH;IAA8B,4BAAgB;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,gBAAgB,GA6B7C;;AAED,MAAM,CAAC,IAAM,GAAG,GAAG,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC;AACtC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC"}
1
+ {"version":3,"file":"API.js","sourceRoot":"","sources":["../src/API.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,SAAS,EAAY,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EACN,OAAO,IAAI,SAAS,EACpB,MAAM,IAAI,QAAQ,EAClB,aAAa,IAAI,eAAe,GAChC,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C;;GAEG;AACH,MAAM,UAAU,cAAc;IAG7B,OAAO;QACN,CAAC,SAAS,CAAC,EAAE,OAAO;QACpB,OAAO,EAAE,SAAS;QAClB,MAAM,EAAE,QAAQ;QAChB,aAAa,EAAE,eAAe;KAC9B,CAAC;AACH,CAAC"}
@@ -1,4 +1,5 @@
1
1
  export { GraphQLQuery, GraphQLSubscription } from './types';
2
- export { API, APIClass } from './API';
3
- export { graphqlOperation, GraphQLAuthError, GRAPHQL_AUTH_MODE, } from '@aws-amplify/api-graphql';
4
- export type { GraphQLResult } from '@aws-amplify/api-graphql';
2
+ export { generateClient } from './API';
3
+ export { GraphQLAuthError } from '@aws-amplify/api-graphql';
4
+ export type { GraphQLResult, GraphQLReturnType, } from '@aws-amplify/api-graphql';
5
+ export { get, put, post, del, head, patch, isCancelError, } from '@aws-amplify/api-rest';
package/lib-esm/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
- export { API, APIClass } from './API';
4
- export { graphqlOperation, GraphQLAuthError, GRAPHQL_AUTH_MODE, } from '@aws-amplify/api-graphql';
3
+ export { generateClient } from './API';
4
+ export { GraphQLAuthError } from '@aws-amplify/api-graphql';
5
+ export { get, put, post, del, head, patch, isCancelError, } from '@aws-amplify/api-rest';
5
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAGtC,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EACN,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,GACjB,MAAM,0BAA0B,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAKtC,OAAO,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAO5D,OAAO,EACN,GAAG,EACH,GAAG,EACH,IAAI,EACJ,GAAG,EACH,IAAI,EACJ,KAAK,EACL,aAAa,GACb,MAAM,uBAAuB,CAAC"}