@aws-amplify/api 5.4.6-api-v6-models.b3abc9b.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.
Files changed (52) hide show
  1. package/README.md +3 -0
  2. package/lib/.tsbuildinfo +3 -0
  3. package/lib/API.d.ts +3 -41
  4. package/lib/API.js +15 -131
  5. package/lib/API.js.map +1 -0
  6. package/lib/index.d.ts +4 -3
  7. package/lib/index.js +11 -6
  8. package/lib/index.js.map +1 -0
  9. package/lib/internals/InternalAPI.d.ts +4 -94
  10. package/lib/internals/InternalAPI.js +29 -144
  11. package/lib/internals/InternalAPI.js.map +1 -0
  12. package/lib/internals/index.js +3 -3
  13. package/lib/internals/index.js.map +1 -0
  14. package/lib/server.d.ts +14 -0
  15. package/lib/server.js +35 -0
  16. package/lib/server.js.map +1 -0
  17. package/lib/types/index.d.ts +1 -2
  18. package/lib/types/index.js +3 -4
  19. package/lib/types/index.js.map +1 -0
  20. package/lib-esm/.tsbuildinfo +3 -0
  21. package/lib-esm/API.d.ts +3 -41
  22. package/lib-esm/API.js +14 -130
  23. package/lib-esm/API.js.map +1 -0
  24. package/lib-esm/index.d.ts +4 -3
  25. package/lib-esm/index.js +4 -2
  26. package/lib-esm/index.js.map +1 -0
  27. package/lib-esm/internals/InternalAPI.d.ts +4 -94
  28. package/lib-esm/internals/InternalAPI.js +28 -143
  29. package/lib-esm/internals/InternalAPI.js.map +1 -0
  30. package/lib-esm/internals/index.js +1 -0
  31. package/lib-esm/internals/index.js.map +1 -0
  32. package/lib-esm/server.d.ts +14 -0
  33. package/lib-esm/server.js +25 -0
  34. package/lib-esm/server.js.map +1 -0
  35. package/lib-esm/types/index.d.ts +1 -2
  36. package/lib-esm/types/index.js +2 -1
  37. package/lib-esm/types/index.js.map +1 -0
  38. package/package.json +12 -32
  39. package/server/package.json +8 -0
  40. package/src/API.ts +16 -200
  41. package/src/index.ts +18 -6
  42. package/src/internals/InternalAPI.ts +15 -194
  43. package/src/server.ts +59 -0
  44. package/src/types/index.ts +0 -2
  45. package/index.v37.d.ts +0 -12
  46. package/lib/APIClient.d.ts +0 -55
  47. package/lib/APIClient.js +0 -404
  48. package/lib/tsconfig.build.tsbuildinfo +0 -1
  49. package/lib-esm/APIClient.d.ts +0 -55
  50. package/lib-esm/APIClient.js +0 -393
  51. package/lib-esm/tsconfig.build.tsbuildinfo +0 -1
  52. package/src/APIClient.ts +0 -534
@@ -2,13 +2,12 @@
2
2
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
3
  // SPDX-License-Identifier: Apache-2.0
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.GRAPHQL_AUTH_MODE = exports.GraphQLAuthError = exports.graphqlOperation = void 0;
6
5
  /**
7
6
  * This exports from the types directory is a temporary workaround, since Amplify CLI currently
8
7
  * generates code that relies on this import path https://github.com/aws-amplify/amplify-cli/issues/3863
9
8
  * This will be removed in future release when CLI and customers moves to recommeneded import styles.
10
9
  */
11
10
  var api_graphql_1 = require("@aws-amplify/api-graphql");
12
- Object.defineProperty(exports, "graphqlOperation", { enumerable: true, get: function () { return api_graphql_1.graphqlOperation; } });
13
- Object.defineProperty(exports, "GraphQLAuthError", { enumerable: true, get: function () { return api_graphql_1.GraphQLAuthError; } });
14
- Object.defineProperty(exports, "GRAPHQL_AUTH_MODE", { enumerable: true, get: function () { return api_graphql_1.GRAPHQL_AUTH_MODE; } });
11
+ exports.graphqlOperation = api_graphql_1.graphqlOperation;
12
+ exports.GraphQLAuthError = api_graphql_1.GraphQLAuthError;
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,3 @@
1
+ {
2
+ "version": "3.8.3"
3
+ }
package/lib-esm/API.d.ts CHANGED
@@ -1,43 +1,5 @@
1
- import { AWSAppSyncRealTimeProvider } from '@aws-amplify/pubsub';
2
- import { GraphQLOptions, GraphQLResult, GraphQLQuery, GraphQLSubscription } from '@aws-amplify/api-graphql';
3
- import { graphql as v6graphql } from '@aws-amplify/api-graphql/internals';
4
- import Observable from 'zen-observable-ts';
5
- import { InternalAPIClass } from './internals/InternalAPI';
6
- import type { ModelTypes } from '@aws-amplify/amplify-api-next-types-alpha';
1
+ import { V6Client } from '@aws-amplify/api-graphql';
7
2
  /**
8
- * @deprecated
9
- * Use RestApi or GraphQLAPI to reduce your application bundle size
10
- * Export Cloud Logic APIs
3
+ * Generates an API client that can work with models or raw GraphQL
11
4
  */
12
- export declare class APIClass extends InternalAPIClass {
13
- getModuleName(): string;
14
- /**
15
- * Executes a GraphQL operation
16
- *
17
- * @param options - GraphQL Options
18
- * @param [additionalHeaders] - headers to merge in after any `graphql_headers` set in the config
19
- * @returns An Observable if queryType is 'subscription', else a promise of the graphql result from the query.
20
- */
21
- graphql<T>(options: GraphQLOptions, additionalHeaders?: {
22
- [key: string]: string;
23
- }): T extends GraphQLQuery<T> ? Promise<GraphQLResult<T>> : T extends GraphQLSubscription<T> ? Observable<{
24
- provider: AWSAppSyncRealTimeProvider;
25
- value: GraphQLResult<T>;
26
- }> : Promise<GraphQLResult<any>> | Observable<object>;
27
- /**
28
- * Generates an API client that can work with models or raw GraphQL
29
- */
30
- generateClient<T extends Record<any, any> = never>(): V6Client<T>;
31
- }
32
- type FilteredKeys<T> = {
33
- [P in keyof T]: T[P] extends never ? never : P;
34
- }[keyof T];
35
- type ExcludeNeverFields<O> = {
36
- [K in FilteredKeys<O>]: O[K];
37
- };
38
- declare type V6Client<T extends Record<any, any> = never> = ExcludeNeverFields<{
39
- graphql: typeof v6graphql;
40
- models: ModelTypes<T>;
41
- }>;
42
- export declare const API: APIClass;
43
- export {};
5
+ export declare function generateClient<T extends Record<any, any> = never>(): V6Client<T>;
package/lib-esm/API.js CHANGED
@@ -1,133 +1,17 @@
1
- import { __awaiter, __extends, __generator, __read, __values } from "tslib";
2
- import { graphql as v6graphql } from '@aws-amplify/api-graphql/internals';
3
- import { Amplify, ConsoleLogger as Logger } from '@aws-amplify/core';
4
- import { InternalAPIClass } from './internals/InternalAPI';
5
- import { initializeModel, generateGraphQLDocument, buildGraphQLVariables, graphQLOperationsInfo, flattenItems, } from './APIClient';
6
- 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';
7
6
  /**
8
- * @deprecated
9
- * Use RestApi or GraphQLAPI to reduce your application bundle size
10
- * Export Cloud Logic APIs
7
+ * Generates an API client that can work with models or raw GraphQL
11
8
  */
12
- var APIClass = /** @class */ (function (_super) {
13
- __extends(APIClass, _super);
14
- function APIClass() {
15
- return _super !== null && _super.apply(this, arguments) || this;
16
- }
17
- APIClass.prototype.getModuleName = function () {
18
- return 'API';
9
+ export function generateClient() {
10
+ return {
11
+ [__amplify]: Amplify,
12
+ graphql: v6graphql,
13
+ cancel: v6cancel,
14
+ isCancelError: v6isCancelError,
19
15
  };
20
- APIClass.prototype.graphql = function (options, additionalHeaders) {
21
- return _super.prototype.graphql.call(this, options, additionalHeaders);
22
- };
23
- /**
24
- * Generates an API client that can work with models or raw GraphQL
25
- */
26
- APIClass.prototype.generateClient = function () {
27
- var e_1, _a;
28
- var _this = this;
29
- var config = _super.prototype.configure.call(this, {});
30
- var modelIntrospection = config.modelIntrospection;
31
- var client = {
32
- graphql: v6graphql,
33
- models: {},
34
- };
35
- var _loop_1 = function (model) {
36
- var name_1 = model.name;
37
- client.models[name_1] = {};
38
- Object.entries(graphQLOperationsInfo).forEach(function (_a) {
39
- var _b = __read(_a, 2), key = _b[0], operationPrefix = _b[1].operationPrefix;
40
- var operation = key;
41
- if (operation === 'LIST') {
42
- client.models[name_1][operationPrefix] = function (args) { return __awaiter(_this, void 0, void 0, function () {
43
- var query, variables, res, _a, key_1, flattenedResult, initialized;
44
- return __generator(this, function (_b) {
45
- switch (_b.label) {
46
- case 0:
47
- query = generateGraphQLDocument(modelIntrospection.models, name_1, 'LIST', args);
48
- variables = buildGraphQLVariables(model, 'LIST', args, modelIntrospection);
49
- console.log('API list', query, variables);
50
- return [4 /*yield*/, this.graphql({
51
- query: query,
52
- variables: variables,
53
- })];
54
- case 1:
55
- res = (_b.sent());
56
- // flatten response
57
- if (res.data !== undefined) {
58
- _a = __read(Object.keys(res.data), 1), key_1 = _a[0];
59
- if (res.data[key_1].items) {
60
- flattenedResult = flattenItems(res.data)[key_1];
61
- // don't init if custom selection set
62
- if (args === null || args === void 0 ? void 0 : args.selectionSet) {
63
- return [2 /*return*/, flattenedResult];
64
- }
65
- else {
66
- initialized = initializeModel(client, name_1, flattenedResult, modelIntrospection);
67
- console.log('initialized', initialized);
68
- return [2 /*return*/, initialized];
69
- }
70
- }
71
- return [2 /*return*/, res.data[key_1]];
72
- }
73
- return [2 /*return*/, res];
74
- }
75
- });
76
- }); };
77
- }
78
- else {
79
- client.models[name_1][operationPrefix] = function (arg, options) { return __awaiter(_this, void 0, void 0, function () {
80
- var query, variables, res, _a, key_2, flattenedResult, _b, initialized;
81
- return __generator(this, function (_c) {
82
- switch (_c.label) {
83
- case 0:
84
- query = generateGraphQLDocument(modelIntrospection.models, name_1, operation, options);
85
- variables = buildGraphQLVariables(model, operation, arg, modelIntrospection);
86
- console.log("API ".concat(operationPrefix), query, variables);
87
- return [4 /*yield*/, this.graphql({
88
- query: query,
89
- variables: variables,
90
- })];
91
- case 1:
92
- res = (_c.sent());
93
- // flatten response
94
- if (res.data !== undefined) {
95
- _a = __read(Object.keys(res.data), 1), key_2 = _a[0];
96
- flattenedResult = flattenItems(res.data)[key_2];
97
- if (options === null || options === void 0 ? void 0 : options.selectionSet) {
98
- return [2 /*return*/, flattenedResult];
99
- }
100
- else {
101
- _b = __read(initializeModel(client, name_1, [flattenedResult], modelIntrospection), 1), initialized = _b[0];
102
- return [2 /*return*/, initialized];
103
- }
104
- }
105
- return [2 /*return*/, res];
106
- }
107
- });
108
- }); };
109
- }
110
- });
111
- };
112
- try {
113
- // TODO: refactor this to use separate methods for each CRUDL.
114
- // Doesn't make sense to gen the methods dynamically given the different args and return values
115
- for (var _b = __values(Object.values(modelIntrospection.models)), _c = _b.next(); !_c.done; _c = _b.next()) {
116
- var model = _c.value;
117
- _loop_1(model);
118
- }
119
- }
120
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
121
- finally {
122
- try {
123
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
124
- }
125
- finally { if (e_1) throw e_1.error; }
126
- }
127
- return client;
128
- };
129
- return APIClass;
130
- }(InternalAPIClass));
131
- export { APIClass };
132
- export var API = new APIClass(null);
133
- Amplify.register(API);
16
+ }
17
+ //# sourceMappingURL=API.js.map
@@ -0,0 +1 @@
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,4 +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';
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
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"}
@@ -1,7 +1,6 @@
1
- import { GraphQLOperation, GraphQLOptions, GraphQLResult, OperationTypeNode, GraphQLQuery, GraphQLSubscription } 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';
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';
5
4
  /**
6
5
  * @deprecated
7
6
  * Use RestApi or GraphQLAPI to reduce your application bundle size
@@ -13,103 +12,14 @@ export declare class InternalAPIClass {
13
12
  * @param {Object} options - Configuration object for API
14
13
  */
15
14
  private _options;
16
- private _restApi;
17
15
  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;
16
+ Cache: import("@aws-amplify/core/lib-esm/Cache/StorageCache").StorageCache;
21
17
  /**
22
18
  * Initialize API with AWS configuration
23
19
  * @param {Object} options - Configuration object for API
24
20
  */
25
21
  constructor(options: any);
26
22
  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
- private getInitWithCustomUserAgentDetails;
107
- /**
108
- * Getting endpoint for API
109
- * @param apiName - The name of the api
110
- * @return The endpoint of the api
111
- */
112
- endpoint(apiName: string): Promise<string>;
113
23
  /**
114
24
  * to get the operation type
115
25
  * @param operation
@@ -1,164 +1,49 @@
1
- import { __assign, __awaiter, __generator } from "tslib";
2
1
  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');
2
+ import { Amplify, Cache, ConsoleLogger } from '@aws-amplify/core';
3
+ import { ApiAction, Category, } from '@aws-amplify/core/internals/utils';
4
+ /**
5
+ * NOTE!
6
+ *
7
+ * This is used only by DataStore.
8
+ *
9
+ * This can probably be pruned and/or removed. Just leaving it as much of the same
10
+ * state as possible for V6 to reduce number of potentially impactful changes to DataStore.
11
+ */
12
+ const logger = new ConsoleLogger('API');
8
13
  /**
9
14
  * @deprecated
10
15
  * Use RestApi or GraphQLAPI to reduce your application bundle size
11
16
  * Export Cloud Logic APIs
12
17
  */
13
- var InternalAPIClass = /** @class */ (function () {
18
+ export class InternalAPIClass {
14
19
  /**
15
20
  * Initialize API with AWS configuration
16
21
  * @param {Object} options - Configuration object for API
17
22
  */
18
- function InternalAPIClass(options) {
19
- this.Auth = Auth;
23
+ constructor(options) {
20
24
  this.Cache = Cache;
21
- this.Credentials = Credentials;
22
25
  this._options = options;
23
- this._restApi = new RestAPIClass(options);
24
26
  this._graphqlApi = new InternalGraphQLAPIClass(options);
25
27
  logger.debug('API Options', this._options);
26
28
  }
27
- InternalAPIClass.prototype.getModuleName = function () {
29
+ getModuleName() {
28
30
  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
- };
31
+ }
149
32
  /**
150
33
  * to get the operation type
151
34
  * @param operation
152
35
  */
153
- InternalAPIClass.prototype.getGraphqlOperationType = function (operation) {
36
+ getGraphqlOperationType(operation) {
154
37
  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);
38
+ }
39
+ graphql(options, additionalHeaders, customUserAgentDetails) {
40
+ const apiUserAgentDetails = {
41
+ category: Category.API,
42
+ action: ApiAction.GraphQl,
43
+ ...customUserAgentDetails,
44
+ };
45
+ return this._graphqlApi.graphql(Amplify, options, additionalHeaders, apiUserAgentDetails);
46
+ }
47
+ }
48
+ export const InternalAPI = new InternalAPIClass(null);
49
+ //# sourceMappingURL=InternalAPI.js.map
@@ -0,0 +1 @@
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,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EACN,SAAS,EACT,QAAQ,GAER,MAAM,mCAAmC,CAAC;AAG3C;;;;;;;GAOG;AAEH,MAAM,MAAM,GAAG,IAAI,aAAa,CAAC,KAAK,CAAC,CAAC;AACxC;;;;GAIG;AACH,MAAM,OAAO,gBAAgB;IAU5B;;;OAGG;IACH,YAAY,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,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,QAAQ,CAAC,GAAG;YACtB,MAAM,EAAE,SAAS,CAAC,OAAO;YACzB,GAAG,sBAAsB;SACzB,CAAC;QAEF,OAAO,IAAI,CAAC,WAAW,CAAC,OAAO,CAC9B,OAAO,EACP,OAAO,EACP,iBAAiB,EACjB,mBAAmB,CACnB,CAAC;IACH,CAAC;CACD;AAED,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,gBAAgB,CAAC,IAAI,CAAC,CAAC"}
@@ -1,3 +1,4 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
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"}
@@ -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';
@@ -0,0 +1,25 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import { graphql, cancel, isCancelError, } from '@aws-amplify/api-graphql/internals';
4
+ import { __amplify, } from '@aws-amplify/api-graphql';
5
+ /**
6
+ * @private
7
+ *
8
+ * Creates a client that can be used to make GraphQL requests, using a provided `AmplifyClassV6`
9
+ * compatible context object for config and auth fetching.
10
+ *
11
+ * @param params
12
+ * @returns
13
+ */
14
+ export function generateClient(params) {
15
+ const client = {
16
+ [__amplify]: params.amplify,
17
+ graphql,
18
+ cancel,
19
+ isCancelError,
20
+ models: {},
21
+ };
22
+ return client;
23
+ }
24
+ export { get, put, post, del, head, patch, isCancelError, } from '@aws-amplify/api-rest/server';
25
+ //# 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,OAAO,EACN,OAAO,EACP,MAAM,EACN,aAAa,GACb,MAAM,oCAAoC,CAAC;AAM5C,OAAO,EACN,SAAS,GAIT,MAAM,0BAA0B,CAAC;AAOlC;;;;;;;;GAQG;AACH,MAAM,UAAU,cAAc,CAG5B,MAAoC;IACrC,MAAM,MAAM,GAAG;QACd,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC,OAAO;QAC3B,OAAO;QACP,MAAM;QACN,aAAa;QACb,MAAM,EAAE,EAAE;KACH,CAAC;IAET,OAAO,MAAoB,CAAC;AAC7B,CAAC;AAED,OAAO,EACN,GAAG,EACH,GAAG,EACH,IAAI,EACJ,GAAG,EACH,IAAI,EACJ,KAAK,EACL,aAAa,GACb,MAAM,8BAA8B,CAAC"}
@@ -3,5 +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, GraphQLQuery, GraphQLSubscription, } from '@aws-amplify/api-graphql';
7
- export { SelectionSet } from '@aws-amplify/amplify-api-next-types-alpha';
6
+ export { graphqlOperation, GraphQLAuthError, GraphQLResult, GraphQLQuery, GraphQLSubscription, } from '@aws-amplify/api-graphql';
@@ -5,4 +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, GRAPHQL_AUTH_MODE, } from '@aws-amplify/api-graphql';
8
+ export { graphqlOperation, GraphQLAuthError, } from '@aws-amplify/api-graphql';
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +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,GAIhB,MAAM,0BAA0B,CAAC"}