@aws-amplify/api-graphql 4.0.1-server-generate-client.1e317a1.0 → 4.0.1-ssr-api.df60e41.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 (91) hide show
  1. package/lib/GraphQLAPI.d.ts +1 -1
  2. package/lib/GraphQLAPI.js +25 -30
  3. package/lib/Providers/AWSAppSyncRealTimeProvider/index.d.ts +1 -1
  4. package/lib/Providers/AWSAppSyncRealTimeProvider/index.js +468 -584
  5. package/lib/Providers/constants.js +4 -5
  6. package/lib/index.js +5 -6
  7. package/lib/internals/InternalGraphQLAPI.d.ts +1 -1
  8. package/lib/internals/InternalGraphQLAPI.js +203 -263
  9. package/lib/internals/index.d.ts +0 -1
  10. package/lib/internals/index.js +5 -8
  11. package/lib/internals/v6.js +3 -4
  12. package/lib/tsconfig.tsbuildinfo +6798 -1
  13. package/lib/types/PubSub.d.ts +2 -2
  14. package/lib/types/PubSub.js +2 -3
  15. package/lib/types/index.d.ts +39 -28
  16. package/lib/types/index.js +3 -4
  17. package/lib/utils/ConnectionStateMonitor.d.ts +3 -3
  18. package/lib/utils/ConnectionStateMonitor.js +51 -65
  19. package/lib/utils/ReachabilityMonitor/index.d.ts +1 -1
  20. package/lib/utils/ReachabilityMonitor/index.js +2 -4
  21. package/lib/utils/ReachabilityMonitor/index.native.d.ts +1 -1
  22. package/lib/utils/ReachabilityMonitor/index.native.js +4 -8
  23. package/lib/utils/ReconnectionMonitor.js +21 -26
  24. package/lib/utils/errors/APIError.js +7 -12
  25. package/lib/utils/errors/assertValidationError.js +4 -5
  26. package/lib/utils/errors/index.js +4 -5
  27. package/lib/utils/errors/validation.js +6 -8
  28. package/lib/utils/index.js +2 -3
  29. package/lib/utils/resolveConfig.d.ts +1 -1
  30. package/lib/utils/resolveConfig.js +10 -13
  31. package/lib/utils/resolveLibraryOptions.d.ts +1 -1
  32. package/lib/utils/resolveLibraryOptions.js +4 -7
  33. package/lib-esm/GraphQLAPI.d.ts +1 -1
  34. package/lib-esm/GraphQLAPI.js +25 -29
  35. package/lib-esm/Providers/AWSAppSyncRealTimeProvider/index.d.ts +1 -1
  36. package/lib-esm/Providers/AWSAppSyncRealTimeProvider/index.js +459 -575
  37. package/lib-esm/Providers/constants.js +10 -10
  38. package/lib-esm/internals/InternalGraphQLAPI.d.ts +1 -1
  39. package/lib-esm/internals/InternalGraphQLAPI.js +197 -256
  40. package/lib-esm/internals/index.d.ts +0 -1
  41. package/lib-esm/internals/index.js +0 -1
  42. package/lib-esm/internals/v6.js +1 -1
  43. package/lib-esm/tsconfig.tsbuildinfo +6798 -1
  44. package/lib-esm/types/PubSub.d.ts +2 -2
  45. package/lib-esm/types/index.d.ts +39 -28
  46. package/lib-esm/types/index.js +1 -1
  47. package/lib-esm/utils/ConnectionStateMonitor.d.ts +3 -3
  48. package/lib-esm/utils/ConnectionStateMonitor.js +49 -63
  49. package/lib-esm/utils/ReachabilityMonitor/index.d.ts +1 -1
  50. package/lib-esm/utils/ReachabilityMonitor/index.js +1 -1
  51. package/lib-esm/utils/ReachabilityMonitor/index.native.d.ts +1 -1
  52. package/lib-esm/utils/ReachabilityMonitor/index.native.js +1 -3
  53. package/lib-esm/utils/ReconnectionMonitor.js +19 -24
  54. package/lib-esm/utils/errors/APIError.js +6 -11
  55. package/lib-esm/utils/errors/assertValidationError.js +2 -2
  56. package/lib-esm/utils/errors/validation.js +5 -6
  57. package/lib-esm/utils/resolveConfig.d.ts +1 -1
  58. package/lib-esm/utils/resolveConfig.js +8 -9
  59. package/lib-esm/utils/resolveLibraryOptions.d.ts +1 -1
  60. package/lib-esm/utils/resolveLibraryOptions.js +4 -5
  61. package/package.json +6 -12
  62. package/src/GraphQLAPI.ts +6 -1
  63. package/src/Providers/AWSAppSyncRealTimeProvider/index.ts +6 -5
  64. package/src/internals/InternalGraphQLAPI.ts +7 -8
  65. package/src/internals/index.ts +0 -1
  66. package/src/types/index.ts +39 -15
  67. package/lib/internals/APIClient.d.ts +0 -101
  68. package/lib/internals/APIClient.js +0 -443
  69. package/lib/internals/generateClient.d.ts +0 -12
  70. package/lib/internals/generateClient.js +0 -30
  71. package/lib/internals/generateModelsProperty.d.ts +0 -4
  72. package/lib/internals/generateModelsProperty.js +0 -169
  73. package/lib/internals/types.d.ts +0 -10
  74. package/lib/internals/types.js +0 -2
  75. package/lib/utils/resolveOwnerFields.d.ts +0 -12
  76. package/lib/utils/resolveOwnerFields.js +0 -63
  77. package/lib-esm/internals/APIClient.d.ts +0 -101
  78. package/lib-esm/internals/APIClient.js +0 -432
  79. package/lib-esm/internals/generateClient.d.ts +0 -12
  80. package/lib-esm/internals/generateClient.js +0 -26
  81. package/lib-esm/internals/generateModelsProperty.d.ts +0 -4
  82. package/lib-esm/internals/generateModelsProperty.js +0 -165
  83. package/lib-esm/internals/types.d.ts +0 -10
  84. package/lib-esm/internals/types.js +0 -1
  85. package/lib-esm/utils/resolveOwnerFields.d.ts +0 -12
  86. package/lib-esm/utils/resolveOwnerFields.js +0 -59
  87. package/src/internals/APIClient.ts +0 -583
  88. package/src/internals/generateClient.ts +0 -30
  89. package/src/internals/generateModelsProperty.ts +0 -192
  90. package/src/internals/types.ts +0 -15
  91. package/src/utils/resolveOwnerFields.ts +0 -65
@@ -1,27 +1,25 @@
1
1
  "use strict";
2
2
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
3
  // SPDX-License-Identifier: Apache-2.0
4
- var _a;
5
4
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.validationErrorMap = exports.APIValidationErrorCode = void 0;
7
5
  var APIValidationErrorCode;
8
6
  (function (APIValidationErrorCode) {
9
7
  APIValidationErrorCode["NoAuthSession"] = "NoAuthSession";
10
8
  APIValidationErrorCode["NoRegion"] = "NoRegion";
11
9
  APIValidationErrorCode["NoCustomEndpoint"] = "NoCustomEndpoint";
12
- })(APIValidationErrorCode || (exports.APIValidationErrorCode = APIValidationErrorCode = {}));
13
- exports.validationErrorMap = (_a = {},
14
- _a[APIValidationErrorCode.NoAuthSession] = {
10
+ })(APIValidationErrorCode = exports.APIValidationErrorCode || (exports.APIValidationErrorCode = {}));
11
+ exports.validationErrorMap = {
12
+ [APIValidationErrorCode.NoAuthSession]: {
15
13
  message: 'Auth session should not be empty.',
16
14
  },
17
15
  // TODO: re-enable when working in all test environments:
18
16
  // [APIValidationErrorCode.NoEndpoint]: {
19
17
  // message: 'Missing endpoint',
20
18
  // },
21
- _a[APIValidationErrorCode.NoRegion] = {
19
+ [APIValidationErrorCode.NoRegion]: {
22
20
  message: 'Missing region.',
23
21
  },
24
- _a[APIValidationErrorCode.NoCustomEndpoint] = {
22
+ [APIValidationErrorCode.NoCustomEndpoint]: {
25
23
  message: 'Custom endpoint region is present without custom endpoint.',
26
24
  },
27
- _a);
25
+ };
@@ -2,8 +2,7 @@
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.resolveLibraryOptions = exports.resolveConfig = void 0;
6
5
  var resolveConfig_1 = require("./resolveConfig");
7
- Object.defineProperty(exports, "resolveConfig", { enumerable: true, get: function () { return resolveConfig_1.resolveConfig; } });
6
+ exports.resolveConfig = resolveConfig_1.resolveConfig;
8
7
  var resolveLibraryOptions_1 = require("./resolveLibraryOptions");
9
- Object.defineProperty(exports, "resolveLibraryOptions", { enumerable: true, get: function () { return resolveLibraryOptions_1.resolveLibraryOptions; } });
8
+ exports.resolveLibraryOptions = resolveLibraryOptions_1.resolveLibraryOptions;
@@ -6,7 +6,7 @@ export declare const resolveConfig: (amplify: AmplifyClassV6) => {
6
6
  apiKey: string | undefined;
7
7
  customEndpoint: string | undefined;
8
8
  customEndpointRegion: string | undefined;
9
- defaultAuthMode: import("@aws-amplify/core/lib-esm/libraryUtils").GraphQLAuthMode | undefined;
9
+ defaultAuthMode: "apiKey" | "oidc" | "userPool" | "iam" | "lambda" | "none" | undefined;
10
10
  endpoint: string | undefined;
11
11
  region: string | undefined;
12
12
  };
@@ -2,24 +2,21 @@
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.resolveConfig = void 0;
6
- var errors_1 = require("./errors");
5
+ const errors_1 = require("./errors");
7
6
  /**
8
7
  * @internal
9
8
  */
10
- var resolveConfig = function (amplify) {
11
- var _a, _b;
12
- var _c = (_b = (_a = amplify.getConfig().API) === null || _a === void 0 ? void 0 : _a.GraphQL) !== null && _b !== void 0 ? _b : {}, apiKey = _c.apiKey, customEndpoint = _c.customEndpoint, customEndpointRegion = _c.customEndpointRegion, defaultAuthMode = _c.defaultAuthMode, endpoint = _c.endpoint, region = _c.region;
9
+ exports.resolveConfig = (amplify) => {
10
+ const { apiKey, customEndpoint, customEndpointRegion, defaultAuthMode, endpoint, region, } = amplify.getConfig().API?.GraphQL ?? {};
13
11
  // TODO: re-enable when working in all test environments:
14
12
  // assertValidationError(!!endpoint, APIValidationErrorCode.NoEndpoint);
15
- (0, errors_1.assertValidationError)(!(!customEndpoint && customEndpointRegion), errors_1.APIValidationErrorCode.NoCustomEndpoint);
13
+ errors_1.assertValidationError(!(!customEndpoint && customEndpointRegion), errors_1.APIValidationErrorCode.NoCustomEndpoint);
16
14
  return {
17
- apiKey: apiKey,
18
- customEndpoint: customEndpoint,
19
- customEndpointRegion: customEndpointRegion,
20
- defaultAuthMode: defaultAuthMode,
21
- endpoint: endpoint,
22
- region: region,
15
+ apiKey,
16
+ customEndpoint,
17
+ customEndpointRegion,
18
+ defaultAuthMode,
19
+ endpoint,
20
+ region,
23
21
  };
24
22
  };
25
- exports.resolveConfig = resolveConfig;
@@ -6,6 +6,6 @@ export declare const resolveLibraryOptions: (amplify: AmplifyClassV6) => {
6
6
  headers: ((options: {
7
7
  query: string;
8
8
  variables?: Record<string, import("@aws-amplify/core/lib-esm/libraryUtils").DocumentType> | undefined;
9
- }) => Promise<import("@aws-amplify/core/lib-esm/clients").Headers>) | undefined;
9
+ }) => Promise<Record<string, string>>) | undefined;
10
10
  withCredentials: boolean | undefined;
11
11
  };
@@ -2,14 +2,11 @@
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.resolveLibraryOptions = void 0;
6
5
  /**
7
6
  * @internal
8
7
  */
9
- var resolveLibraryOptions = function (amplify) {
10
- var _a, _b, _c, _d, _e, _f;
11
- var headers = (_c = (_b = (_a = amplify.libraryOptions) === null || _a === void 0 ? void 0 : _a.API) === null || _b === void 0 ? void 0 : _b.GraphQL) === null || _c === void 0 ? void 0 : _c.headers;
12
- var withCredentials = (_f = (_e = (_d = amplify.libraryOptions) === null || _d === void 0 ? void 0 : _d.API) === null || _e === void 0 ? void 0 : _e.GraphQL) === null || _f === void 0 ? void 0 : _f.withCredentials;
13
- return { headers: headers, withCredentials: withCredentials };
8
+ exports.resolveLibraryOptions = (amplify) => {
9
+ const headers = amplify.libraryOptions?.API?.GraphQL?.headers;
10
+ const withCredentials = amplify.libraryOptions?.API?.GraphQL?.withCredentials;
11
+ return { headers, withCredentials };
14
12
  };
15
- exports.resolveLibraryOptions = resolveLibraryOptions;
@@ -2,7 +2,7 @@ import { AmplifyClassV6 } from '@aws-amplify/core';
2
2
  import { GraphQLOptions, GraphQLResult } from './types';
3
3
  import { InternalGraphQLAPIClass } from './internals';
4
4
  import { Observable } from 'rxjs';
5
- export declare const graphqlOperation: (query: any, variables?: {}, authToken?: string) => {
5
+ export declare const graphqlOperation: (query: any, variables?: {}, authToken?: string | undefined) => {
6
6
  query: any;
7
7
  variables: {};
8
8
  authToken: string | undefined;
@@ -1,24 +1,17 @@
1
- import { __extends } from "tslib";
1
+ import { Category, ApiAction } from '@aws-amplify/core/internals/utils';
2
2
  import { InternalGraphQLAPIClass } from './internals';
3
- export var graphqlOperation = function (query, variables, authToken) {
4
- if (variables === void 0) { variables = {}; }
5
- return ({
6
- query: query,
7
- variables: variables,
8
- authToken: authToken,
9
- });
10
- };
3
+ export const graphqlOperation = (query, variables = {}, authToken) => ({
4
+ query,
5
+ variables,
6
+ authToken,
7
+ });
11
8
  /**
12
9
  * Export Cloud Logic APIs
13
10
  */
14
- var GraphQLAPIClass = /** @class */ (function (_super) {
15
- __extends(GraphQLAPIClass, _super);
16
- function GraphQLAPIClass() {
17
- return _super !== null && _super.apply(this, arguments) || this;
18
- }
19
- GraphQLAPIClass.prototype.getModuleName = function () {
11
+ export class GraphQLAPIClass extends InternalGraphQLAPIClass {
12
+ getModuleName() {
20
13
  return 'GraphQLAPI';
21
- };
14
+ }
22
15
  /**
23
16
  * Executes a GraphQL operation
24
17
  *
@@ -26,26 +19,29 @@ var GraphQLAPIClass = /** @class */ (function (_super) {
26
19
  * @param [additionalHeaders] - headers to merge in after any `graphql_headers` set in the config
27
20
  * @returns An Observable if the query is a subscription query, else a promise of the graphql result.
28
21
  */
29
- GraphQLAPIClass.prototype.graphql = function (amplify, options, additionalHeaders) {
30
- return _super.prototype.graphql.call(this, amplify, options, additionalHeaders);
31
- };
22
+ graphql(amplify,
23
+ // amplify: AmplifyClassV6 | (() => Promise<AmplifyClassV6>),
24
+ options, additionalHeaders) {
25
+ return super.graphql(amplify, options, additionalHeaders, {
26
+ category: Category.API,
27
+ action: ApiAction.GraphQl,
28
+ });
29
+ }
32
30
  /**
33
31
  * Checks to see if an error thrown is from an api request cancellation
34
32
  * @param error - Any error
35
33
  * @returns A boolean indicating if the error was from an api request cancellation
36
34
  */
37
- GraphQLAPIClass.prototype.isCancelError = function (error) {
38
- return _super.prototype.isCancelError.call(this, error);
39
- };
35
+ isCancelError(error) {
36
+ return super.isCancelError(error);
37
+ }
40
38
  /**
41
39
  * Cancels an inflight request. Only applicable for graphql queries and mutations
42
40
  * @param {any} request - request to cancel
43
41
  * @returns A boolean indicating if the request was cancelled
44
42
  */
45
- GraphQLAPIClass.prototype.cancel = function (request, message) {
46
- return _super.prototype.cancel.call(this, request, message);
47
- };
48
- return GraphQLAPIClass;
49
- }(InternalGraphQLAPIClass));
50
- export { GraphQLAPIClass };
51
- export var GraphQLAPI = new GraphQLAPIClass(null);
43
+ cancel(request, message) {
44
+ return super.cancel(request, message);
45
+ }
46
+ }
47
+ export const GraphQLAPI = new GraphQLAPIClass(null);
@@ -2,7 +2,7 @@ import { Observable } from 'rxjs';
2
2
  import { GraphQLAuthMode, CustomUserAgentDetails, DocumentType } from '@aws-amplify/core/internals/utils';
3
3
  import { PubSubContentObserver } from '../../types/PubSub';
4
4
  import { SUBSCRIPTION_STATUS } from '../constants';
5
- export type ObserverQuery = {
5
+ export declare type ObserverQuery = {
6
6
  observer: PubSubContentObserver;
7
7
  query: string;
8
8
  variables: Record<string, DocumentType>;