@aws-amplify/api-graphql 4.0.1-console-preview.d745d43.0 → 4.0.1-mjs-test.6f5dab7.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 (155) hide show
  1. package/dist/cjs/GraphQLAPI.js +52 -0
  2. package/dist/cjs/GraphQLAPI.js.map +1 -0
  3. package/dist/cjs/Providers/AWSAppSyncRealTimeProvider/index.js +693 -0
  4. package/dist/cjs/Providers/AWSAppSyncRealTimeProvider/index.js.map +1 -0
  5. package/{lib → dist/cjs}/Providers/constants.js +8 -8
  6. package/dist/cjs/Providers/constants.js.map +1 -0
  7. package/dist/cjs/index.js +15 -0
  8. package/dist/cjs/index.js.map +1 -0
  9. package/dist/cjs/internals/InternalGraphQLAPI.js +274 -0
  10. package/dist/cjs/internals/InternalGraphQLAPI.js.map +1 -0
  11. package/dist/cjs/internals/index.js +14 -0
  12. package/dist/cjs/internals/index.js.map +1 -0
  13. package/{lib → dist/cjs}/internals/v6.js +7 -4
  14. package/dist/cjs/internals/v6.js.map +1 -0
  15. package/{lib → dist/cjs}/types/PubSub.js +6 -6
  16. package/dist/cjs/types/PubSub.js.map +1 -0
  17. package/{lib → dist/cjs}/types/index.js +7 -5
  18. package/dist/cjs/types/index.js.map +1 -0
  19. package/dist/cjs/utils/ConnectionStateMonitor.js +134 -0
  20. package/dist/cjs/utils/ConnectionStateMonitor.js.map +1 -0
  21. package/dist/cjs/utils/ReachabilityMonitor/index.js +10 -0
  22. package/dist/cjs/utils/ReachabilityMonitor/index.js.map +1 -0
  23. package/dist/cjs/utils/ReachabilityMonitor/index.native.js +12 -0
  24. package/dist/cjs/utils/ReachabilityMonitor/index.native.js.map +1 -0
  25. package/{lib → dist/cjs}/utils/ReconnectionMonitor.js +24 -25
  26. package/dist/cjs/utils/ReconnectionMonitor.js.map +1 -0
  27. package/dist/cjs/utils/errors/APIError.js +21 -0
  28. package/dist/cjs/utils/errors/APIError.js.map +1 -0
  29. package/dist/cjs/utils/errors/assertValidationError.js +19 -0
  30. package/dist/cjs/utils/errors/assertValidationError.js.map +1 -0
  31. package/dist/cjs/utils/errors/index.js +14 -0
  32. package/dist/cjs/utils/errors/index.js.map +1 -0
  33. package/{lib → dist/cjs}/utils/errors/validation.js +9 -7
  34. package/dist/cjs/utils/errors/validation.js.map +1 -0
  35. package/dist/cjs/utils/index.js +11 -0
  36. package/dist/cjs/utils/index.js.map +1 -0
  37. package/dist/cjs/utils/resolveConfig.js +26 -0
  38. package/dist/cjs/utils/resolveConfig.js.map +1 -0
  39. package/dist/cjs/utils/resolveLibraryOptions.js +16 -0
  40. package/dist/cjs/utils/resolveLibraryOptions.js.map +1 -0
  41. package/{lib-esm → dist/esm}/GraphQLAPI.d.ts +2 -2
  42. package/dist/esm/GraphQLAPI.mjs +50 -0
  43. package/dist/esm/GraphQLAPI.mjs.map +1 -0
  44. package/{lib → dist/esm}/Providers/AWSAppSyncRealTimeProvider/index.d.ts +1 -1
  45. package/dist/esm/Providers/AWSAppSyncRealTimeProvider/index.mjs +691 -0
  46. package/dist/esm/Providers/AWSAppSyncRealTimeProvider/index.mjs.map +1 -0
  47. package/{lib-esm/Providers/constants.js → dist/esm/Providers/constants.mjs} +18 -14
  48. package/dist/esm/Providers/constants.mjs.map +1 -0
  49. package/dist/esm/index.mjs +5 -0
  50. package/dist/esm/index.mjs.map +1 -0
  51. package/{lib → dist/esm}/internals/InternalGraphQLAPI.d.ts +2 -2
  52. package/dist/esm/internals/InternalGraphQLAPI.mjs +272 -0
  53. package/dist/esm/internals/InternalGraphQLAPI.mjs.map +1 -0
  54. package/dist/esm/internals/index.mjs +3 -0
  55. package/dist/esm/internals/index.mjs.map +1 -0
  56. package/{lib-esm/internals/v6.js → dist/esm/internals/v6.mjs} +10 -6
  57. package/dist/esm/internals/v6.mjs.map +1 -0
  58. package/{lib → dist/esm}/types/PubSub.d.ts +2 -2
  59. package/{lib-esm/types/PubSub.js → dist/esm/types/PubSub.mjs} +5 -2
  60. package/dist/esm/types/PubSub.mjs.map +1 -0
  61. package/{lib-esm → dist/esm}/types/index.d.ts +45 -25
  62. package/{lib-esm/types/index.js → dist/esm/types/index.mjs} +7 -3
  63. package/dist/esm/types/index.mjs.map +1 -0
  64. package/{lib-esm → dist/esm}/utils/ConnectionStateMonitor.d.ts +3 -3
  65. package/{lib-esm/utils/ConnectionStateMonitor.js → dist/esm/utils/ConnectionStateMonitor.mjs} +56 -66
  66. package/dist/esm/utils/ConnectionStateMonitor.mjs.map +1 -0
  67. package/dist/esm/utils/ReachabilityMonitor/index.d.ts +1 -0
  68. package/{lib-esm/utils/ReachabilityMonitor/index.js → dist/esm/utils/ReachabilityMonitor/index.mjs} +6 -2
  69. package/dist/esm/utils/ReachabilityMonitor/index.mjs.map +1 -0
  70. package/dist/esm/utils/ReachabilityMonitor/index.native.d.ts +1 -0
  71. package/dist/esm/utils/ReachabilityMonitor/index.native.mjs +9 -0
  72. package/dist/esm/utils/ReachabilityMonitor/index.native.mjs.map +1 -0
  73. package/{lib-esm/utils/ReconnectionMonitor.js → dist/esm/utils/ReconnectionMonitor.mjs} +25 -26
  74. package/dist/esm/utils/ReconnectionMonitor.mjs.map +1 -0
  75. package/dist/esm/utils/errors/APIError.mjs +19 -0
  76. package/dist/esm/utils/errors/APIError.mjs.map +1 -0
  77. package/dist/esm/utils/errors/assertValidationError.mjs +17 -0
  78. package/dist/esm/utils/errors/assertValidationError.mjs.map +1 -0
  79. package/dist/esm/utils/errors/index.mjs +4 -0
  80. package/dist/esm/utils/errors/index.mjs.map +1 -0
  81. package/{lib-esm/utils/errors/validation.js → dist/esm/utils/errors/validation.mjs} +9 -7
  82. package/dist/esm/utils/errors/validation.mjs.map +1 -0
  83. package/dist/esm/utils/index.mjs +3 -0
  84. package/dist/esm/utils/index.mjs.map +1 -0
  85. package/{lib → dist/esm}/utils/resolveConfig.d.ts +1 -1
  86. package/dist/esm/utils/resolveConfig.mjs +26 -0
  87. package/dist/esm/utils/resolveConfig.mjs.map +1 -0
  88. package/{lib-esm → dist/esm}/utils/resolveLibraryOptions.d.ts +2 -2
  89. package/dist/esm/utils/resolveLibraryOptions.mjs +13 -0
  90. package/dist/esm/utils/resolveLibraryOptions.mjs.map +1 -0
  91. package/internals/package.json +4 -4
  92. package/package.json +48 -26
  93. package/src/GraphQLAPI.ts +2 -2
  94. package/src/internals/InternalGraphQLAPI.ts +35 -10
  95. package/src/types/index.ts +51 -9
  96. package/lib/GraphQLAPI.d.ts +0 -38
  97. package/lib/GraphQLAPI.js +0 -57
  98. package/lib/Providers/AWSAppSyncRealTimeProvider/index.js +0 -805
  99. package/lib/Providers/constants.d.ts +0 -95
  100. package/lib/index.d.ts +0 -3
  101. package/lib/index.js +0 -12
  102. package/lib/internals/InternalGraphQLAPI.js +0 -316
  103. package/lib/internals/index.d.ts +0 -2
  104. package/lib/internals/index.js +0 -11
  105. package/lib/internals/v6.d.ts +0 -101
  106. package/lib/tsconfig.tsbuildinfo +0 -6638
  107. package/lib/types/index.d.ts +0 -289
  108. package/lib/utils/ConnectionStateMonitor.d.ts +0 -41
  109. package/lib/utils/ConnectionStateMonitor.js +0 -144
  110. package/lib/utils/ReachabilityMonitor/index.d.ts +0 -1
  111. package/lib/utils/ReachabilityMonitor/index.js +0 -6
  112. package/lib/utils/ReachabilityMonitor/index.native.d.ts +0 -1
  113. package/lib/utils/ReachabilityMonitor/index.native.js +0 -10
  114. package/lib/utils/ReconnectionMonitor.d.ts +0 -29
  115. package/lib/utils/errors/APIError.d.ts +0 -7
  116. package/lib/utils/errors/APIError.js +0 -22
  117. package/lib/utils/errors/assertValidationError.d.ts +0 -5
  118. package/lib/utils/errors/assertValidationError.js +0 -16
  119. package/lib/utils/errors/index.d.ts +0 -3
  120. package/lib/utils/errors/index.js +0 -11
  121. package/lib/utils/errors/validation.d.ts +0 -7
  122. package/lib/utils/index.d.ts +0 -2
  123. package/lib/utils/index.js +0 -8
  124. package/lib/utils/resolveConfig.js +0 -23
  125. package/lib/utils/resolveLibraryOptions.d.ts +0 -11
  126. package/lib/utils/resolveLibraryOptions.js +0 -13
  127. package/lib-esm/GraphQLAPI.js +0 -55
  128. package/lib-esm/Providers/AWSAppSyncRealTimeProvider/index.d.ts +0 -64
  129. package/lib-esm/Providers/AWSAppSyncRealTimeProvider/index.js +0 -803
  130. package/lib-esm/index.js +0 -5
  131. package/lib-esm/internals/InternalGraphQLAPI.d.ts +0 -58
  132. package/lib-esm/internals/InternalGraphQLAPI.js +0 -314
  133. package/lib-esm/internals/index.js +0 -4
  134. package/lib-esm/tsconfig.tsbuildinfo +0 -6638
  135. package/lib-esm/types/PubSub.d.ts +0 -27
  136. package/lib-esm/utils/ReachabilityMonitor/index.d.ts +0 -1
  137. package/lib-esm/utils/ReachabilityMonitor/index.native.d.ts +0 -1
  138. package/lib-esm/utils/ReachabilityMonitor/index.native.js +0 -7
  139. package/lib-esm/utils/errors/APIError.js +0 -20
  140. package/lib-esm/utils/errors/assertValidationError.js +0 -13
  141. package/lib-esm/utils/errors/index.js +0 -5
  142. package/lib-esm/utils/index.js +0 -4
  143. package/lib-esm/utils/resolveConfig.d.ts +0 -12
  144. package/lib-esm/utils/resolveConfig.js +0 -21
  145. package/lib-esm/utils/resolveLibraryOptions.js +0 -11
  146. /package/{lib-esm → dist/esm}/Providers/constants.d.ts +0 -0
  147. /package/{lib-esm → dist/esm}/index.d.ts +0 -0
  148. /package/{lib-esm → dist/esm}/internals/index.d.ts +0 -0
  149. /package/{lib-esm → dist/esm}/internals/v6.d.ts +0 -0
  150. /package/{lib-esm → dist/esm}/utils/ReconnectionMonitor.d.ts +0 -0
  151. /package/{lib-esm → dist/esm}/utils/errors/APIError.d.ts +0 -0
  152. /package/{lib-esm → dist/esm}/utils/errors/assertValidationError.d.ts +0 -0
  153. /package/{lib-esm → dist/esm}/utils/errors/index.d.ts +0 -0
  154. /package/{lib-esm → dist/esm}/utils/errors/validation.d.ts +0 -0
  155. /package/{lib-esm → dist/esm}/utils/index.d.ts +0 -0
@@ -0,0 +1,19 @@
1
+ import { AmplifyError } from '@aws-amplify/core/internals/utils';
2
+
3
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ // SPDX-License-Identifier: Apache-2.0
5
+ /**
6
+ * @internal
7
+ */
8
+ class APIError extends AmplifyError {
9
+ constructor(params) {
10
+ super(params);
11
+ // Hack for making the custom error class work when transpiled to es5
12
+ // TODO: Delete the following 2 lines after we change the build target to >= es2015
13
+ this.constructor = APIError;
14
+ Object.setPrototypeOf(this, APIError.prototype);
15
+ }
16
+ }
17
+
18
+ export { APIError };
19
+ //# sourceMappingURL=APIError.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"APIError.mjs","sources":["../../../../src/utils/errors/APIError.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { AmplifyError, } from '@aws-amplify/core/internals/utils';\n/**\n * @internal\n */\nexport class APIError extends AmplifyError {\n constructor(params) {\n super(params);\n // Hack for making the custom error class work when transpiled to es5\n // TODO: Delete the following 2 lines after we change the build target to >= es2015\n this.constructor = APIError;\n Object.setPrototypeOf(this, APIError.prototype);\n }\n}\n"],"names":[],"mappings":";;AAAA;AACA;AAEA;AACA;AACA;AACO,MAAM,QAAQ,SAAS,YAAY,CAAC;AAC3C,IAAI,WAAW,CAAC,MAAM,EAAE;AACxB,QAAQ,KAAK,CAAC,MAAM,CAAC,CAAC;AACtB;AACA;AACA,QAAQ,IAAI,CAAC,WAAW,GAAG,QAAQ,CAAC;AACpC,QAAQ,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAC;AACxD,KAAK;AACL;;;;"}
@@ -0,0 +1,17 @@
1
+ import { APIError } from './APIError.mjs';
2
+ import { validationErrorMap } from './validation.mjs';
3
+
4
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
5
+ // SPDX-License-Identifier: Apache-2.0
6
+ /**
7
+ * @internal
8
+ */
9
+ function assertValidationError(assertion, name) {
10
+ const { message, recoverySuggestion } = validationErrorMap[name];
11
+ if (!assertion) {
12
+ throw new APIError({ name, message, recoverySuggestion });
13
+ }
14
+ }
15
+
16
+ export { assertValidationError };
17
+ //# sourceMappingURL=assertValidationError.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assertValidationError.mjs","sources":["../../../../src/utils/errors/assertValidationError.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { APIError } from './APIError';\nimport { validationErrorMap } from './validation';\n/**\n * @internal\n */\nexport function assertValidationError(assertion, name) {\n const { message, recoverySuggestion } = validationErrorMap[name];\n if (!assertion) {\n throw new APIError({ name, message, recoverySuggestion });\n }\n}\n"],"names":[],"mappings":";;;AAAA;AACA;AAGA;AACA;AACA;AACO,SAAS,qBAAqB,CAAC,SAAS,EAAE,IAAI,EAAE;AACvD,IAAI,MAAM,EAAE,OAAO,EAAE,kBAAkB,EAAE,GAAG,kBAAkB,CAAC,IAAI,CAAC,CAAC;AACrE,IAAI,IAAI,CAAC,SAAS,EAAE;AACpB,QAAQ,MAAM,IAAI,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,kBAAkB,EAAE,CAAC,CAAC;AAClE,KAAK;AACL;;;;"}
@@ -0,0 +1,4 @@
1
+ export { APIError } from './APIError.mjs';
2
+ export { assertValidationError } from './assertValidationError.mjs';
3
+ export { APIValidationErrorCode, validationErrorMap } from './validation.mjs';
4
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
@@ -1,24 +1,26 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
- var _a;
4
- export var APIValidationErrorCode;
3
+ var APIValidationErrorCode;
5
4
  (function (APIValidationErrorCode) {
6
5
  APIValidationErrorCode["NoAuthSession"] = "NoAuthSession";
7
6
  APIValidationErrorCode["NoRegion"] = "NoRegion";
8
7
  APIValidationErrorCode["NoCustomEndpoint"] = "NoCustomEndpoint";
9
8
  })(APIValidationErrorCode || (APIValidationErrorCode = {}));
10
- export var validationErrorMap = (_a = {},
11
- _a[APIValidationErrorCode.NoAuthSession] = {
9
+ const validationErrorMap = {
10
+ [APIValidationErrorCode.NoAuthSession]: {
12
11
  message: 'Auth session should not be empty.',
13
12
  },
14
13
  // TODO: re-enable when working in all test environments:
15
14
  // [APIValidationErrorCode.NoEndpoint]: {
16
15
  // message: 'Missing endpoint',
17
16
  // },
18
- _a[APIValidationErrorCode.NoRegion] = {
17
+ [APIValidationErrorCode.NoRegion]: {
19
18
  message: 'Missing region.',
20
19
  },
21
- _a[APIValidationErrorCode.NoCustomEndpoint] = {
20
+ [APIValidationErrorCode.NoCustomEndpoint]: {
22
21
  message: 'Custom endpoint region is present without custom endpoint.',
23
22
  },
24
- _a);
23
+ };
24
+
25
+ export { APIValidationErrorCode, validationErrorMap };
26
+ //# sourceMappingURL=validation.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.mjs","sources":["../../../../src/utils/errors/validation.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nexport var APIValidationErrorCode;\n(function (APIValidationErrorCode) {\n APIValidationErrorCode[\"NoAuthSession\"] = \"NoAuthSession\";\n APIValidationErrorCode[\"NoRegion\"] = \"NoRegion\";\n APIValidationErrorCode[\"NoCustomEndpoint\"] = \"NoCustomEndpoint\";\n})(APIValidationErrorCode || (APIValidationErrorCode = {}));\nexport const validationErrorMap = {\n [APIValidationErrorCode.NoAuthSession]: {\n message: 'Auth session should not be empty.',\n },\n // TODO: re-enable when working in all test environments:\n // [APIValidationErrorCode.NoEndpoint]: {\n // \tmessage: 'Missing endpoint',\n // },\n [APIValidationErrorCode.NoRegion]: {\n message: 'Missing region.',\n },\n [APIValidationErrorCode.NoCustomEndpoint]: {\n message: 'Custom endpoint region is present without custom endpoint.',\n },\n};\n"],"names":[],"mappings":"AAAA;AACA;AACU,IAAC,uBAAuB;AAClC,CAAC,UAAU,sBAAsB,EAAE;AACnC,IAAI,sBAAsB,CAAC,eAAe,CAAC,GAAG,eAAe,CAAC;AAC9D,IAAI,sBAAsB,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC;AACpD,IAAI,sBAAsB,CAAC,kBAAkB,CAAC,GAAG,kBAAkB,CAAC;AACpE,CAAC,EAAE,sBAAsB,KAAK,sBAAsB,GAAG,EAAE,CAAC,CAAC,CAAC;AAChD,MAAC,kBAAkB,GAAG;AAClC,IAAI,CAAC,sBAAsB,CAAC,aAAa,GAAG;AAC5C,QAAQ,OAAO,EAAE,mCAAmC;AACpD,KAAK;AACL;AACA;AACA;AACA;AACA,IAAI,CAAC,sBAAsB,CAAC,QAAQ,GAAG;AACvC,QAAQ,OAAO,EAAE,iBAAiB;AAClC,KAAK;AACL,IAAI,CAAC,sBAAsB,CAAC,gBAAgB,GAAG;AAC/C,QAAQ,OAAO,EAAE,4DAA4D;AAC7E,KAAK;AACL;;;;"}
@@ -0,0 +1,3 @@
1
+ export { resolveConfig } from './resolveConfig.mjs';
2
+ export { resolveLibraryOptions } from './resolveLibraryOptions.mjs';
3
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -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: "apiKey" | "oidc" | "userPool" | "iam" | "lambda" | "none" | undefined;
9
+ defaultAuthMode: import("@aws-amplify/core/internals/utils").GraphQLAuthMode | undefined;
10
10
  endpoint: string | undefined;
11
11
  region: string | undefined;
12
12
  };
@@ -0,0 +1,26 @@
1
+ import '@aws-amplify/core/internals/utils';
2
+ import { assertValidationError } from './errors/assertValidationError.mjs';
3
+ import { APIValidationErrorCode } from './errors/validation.mjs';
4
+
5
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
6
+ // SPDX-License-Identifier: Apache-2.0
7
+ /**
8
+ * @internal
9
+ */
10
+ const resolveConfig = (amplify) => {
11
+ const { apiKey, customEndpoint, customEndpointRegion, defaultAuthMode, endpoint, region, } = amplify.getConfig().API?.GraphQL ?? {};
12
+ // TODO: re-enable when working in all test environments:
13
+ // assertValidationError(!!endpoint, APIValidationErrorCode.NoEndpoint);
14
+ assertValidationError(!(!customEndpoint && customEndpointRegion), APIValidationErrorCode.NoCustomEndpoint);
15
+ return {
16
+ apiKey,
17
+ customEndpoint,
18
+ customEndpointRegion,
19
+ defaultAuthMode,
20
+ endpoint,
21
+ region,
22
+ };
23
+ };
24
+
25
+ export { resolveConfig };
26
+ //# sourceMappingURL=resolveConfig.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolveConfig.mjs","sources":["../../../src/utils/resolveConfig.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { APIValidationErrorCode, assertValidationError } from './errors';\n/**\n * @internal\n */\nexport const resolveConfig = (amplify) => {\n const { apiKey, customEndpoint, customEndpointRegion, defaultAuthMode, endpoint, region, } = amplify.getConfig().API?.GraphQL ?? {};\n // TODO: re-enable when working in all test environments:\n // assertValidationError(!!endpoint, APIValidationErrorCode.NoEndpoint);\n assertValidationError(!(!customEndpoint && customEndpointRegion), APIValidationErrorCode.NoCustomEndpoint);\n return {\n apiKey,\n customEndpoint,\n customEndpointRegion,\n defaultAuthMode,\n endpoint,\n region,\n };\n};\n"],"names":[],"mappings":";;;;AAAA;AACA;AAEA;AACA;AACA;AACY,MAAC,aAAa,GAAG,CAAC,OAAO,KAAK;AAC1C,IAAI,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,oBAAoB,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,GAAG,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,GAAG,EAAE,OAAO,IAAI,EAAE,CAAC;AACxI;AACA;AACA,IAAI,qBAAqB,CAAC,EAAE,CAAC,cAAc,IAAI,oBAAoB,CAAC,EAAE,sBAAsB,CAAC,gBAAgB,CAAC,CAAC;AAC/G,IAAI,OAAO;AACX,QAAQ,MAAM;AACd,QAAQ,cAAc;AACtB,QAAQ,oBAAoB;AAC5B,QAAQ,eAAe;AACvB,QAAQ,QAAQ;AAChB,QAAQ,MAAM;AACd,KAAK,CAAC;AACN;;;;"}
@@ -5,7 +5,7 @@ import { AmplifyClassV6 } from '@aws-amplify/core';
5
5
  export declare const resolveLibraryOptions: (amplify: AmplifyClassV6) => {
6
6
  headers: ((options: {
7
7
  query: string;
8
- variables?: Record<string, import("@aws-amplify/core/lib-esm/libraryUtils").DocumentType> | undefined;
9
- }) => Promise<Record<string, string>>) | undefined;
8
+ variables?: Record<string, import("@aws-amplify/core/internals/utils").DocumentType> | undefined;
9
+ }) => Promise<import("@aws-amplify/core/internals/aws-client-utils").Headers>) | undefined;
10
10
  withCredentials: boolean | undefined;
11
11
  };
@@ -0,0 +1,13 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ /**
4
+ * @internal
5
+ */
6
+ const resolveLibraryOptions = (amplify) => {
7
+ const headers = amplify.libraryOptions?.API?.GraphQL?.headers;
8
+ const withCredentials = amplify.libraryOptions?.API?.GraphQL?.withCredentials;
9
+ return { headers, withCredentials };
10
+ };
11
+
12
+ export { resolveLibraryOptions };
13
+ //# sourceMappingURL=resolveLibraryOptions.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolveLibraryOptions.mjs","sources":["../../../src/utils/resolveLibraryOptions.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n/**\n * @internal\n */\nexport const resolveLibraryOptions = (amplify) => {\n const headers = amplify.libraryOptions?.API?.GraphQL?.headers;\n const withCredentials = amplify.libraryOptions?.API?.GraphQL?.withCredentials;\n return { headers, withCredentials };\n};\n"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACY,MAAC,qBAAqB,GAAG,CAAC,OAAO,KAAK;AAClD,IAAI,MAAM,OAAO,GAAG,OAAO,CAAC,cAAc,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC;AAClE,IAAI,MAAM,eAAe,GAAG,OAAO,CAAC,cAAc,EAAE,GAAG,EAAE,OAAO,EAAE,eAAe,CAAC;AAClF,IAAI,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,CAAC;AACxC;;;;"}
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@aws-amplify/api-graphql/internals",
3
- "types": "../lib-esm/internals/index.d.ts",
4
- "main": "../lib/internals/index.js",
5
- "module": "../lib-esm/internals/index.js",
6
- "react-native": "../lib-esm/internals/index.js",
3
+ "types": "../dist/esm/internals/index.d.ts",
4
+ "main": "../dist/cjs/internals/index.js",
5
+ "module": "../dist/esm/internals/index.mjs",
6
+ "react-native": "../src/internals/index.ts",
7
7
  "sideEffects": false
8
8
  }
package/package.json CHANGED
@@ -1,16 +1,14 @@
1
1
  {
2
2
  "name": "@aws-amplify/api-graphql",
3
- "version": "4.0.1-console-preview.d745d43.0+d745d43",
3
+ "version": "4.0.1-mjs-test.6f5dab7.0+6f5dab7",
4
4
  "description": "Api-graphql category of aws-amplify",
5
- "main": "./lib/index.js",
6
- "module": "./lib-esm/index.js",
7
- "typings": "./lib-esm/index.d.ts",
8
- "react-native": {
9
- "./lib/index": "./lib-esm/index.js"
10
- },
5
+ "main": "./dist/cjs/index.js",
6
+ "module": "./dist/esm/index.mjs",
7
+ "typings": "./dist/esm/index.d.ts",
8
+ "react-native": "./src/index.ts",
11
9
  "sideEffects": [
12
- "./lib/GraphQLAPI.js",
13
- "./lib-esm/GraphQLAPI.js"
10
+ "./dist/cjs/GraphQLAPI.js",
11
+ "./dist/esm/GraphQLAPI.mjs"
14
12
  ],
15
13
  "publishConfig": {
16
14
  "access": "public"
@@ -18,18 +16,40 @@
18
16
  "scripts": {
19
17
  "test": "npm run lint && jest -w 1 --coverage",
20
18
  "test:watch": "tslint 'src/**/*.ts' && jest -w 1 --watch",
21
- "build-with-test": "npm run clean && npm test && tsc && webpack",
22
- "build:cjs": "rimraf lib && tsc -m commonjs --outDir lib && webpack && webpack --config ./webpack.config.dev.js",
23
- "build:esm": "rimraf lib-esm && tsc -m esnext --outDir lib-esm",
24
- "build:cjs:watch": "rimraf lib && tsc -m commonjs --outDir lib --watch",
25
- "build:esm:watch": "rimraf lib-esm && tsc -m esnext --outDir lib-esm --watch",
26
- "build": "npm run clean && npm run build:esm && npm run build:cjs",
27
- "clean": "npm run clean:size && rimraf lib-esm lib dist",
19
+ "build-with-test": "npm test && npm build",
20
+ "build:umd": "webpack && webpack --config ./webpack.config.dev.js",
21
+ "build:esm-cjs": "rollup -c rollup.config.mjs",
22
+ "build:cjs:watch": "rimraf dist/cjs && tsc -m commonjs --outDir dist/cjs --watch",
23
+ "build:esm:watch": "rimraf dist/esm && tsc -m esnext --outDir dist/esm --watch",
24
+ "build": "npm run clean && npm run build:esm-cjs && npm run build:umd",
25
+ "clean": "npm run clean:size && rimraf dist lib lib-esm",
28
26
  "clean:size": "rimraf dual-publish-tmp tmp*",
29
27
  "format": "echo \"Not implemented\"",
30
28
  "lint": "tslint 'src/**/*.ts' && npm run ts-coverage",
31
29
  "ts-coverage": "typescript-coverage-report -p ./tsconfig.json -t 70.0"
32
30
  },
31
+ "exports": {
32
+ ".": {
33
+ "types": "./dist/esm/index.d.ts",
34
+ "import": "./dist/esm/index.mjs",
35
+ "require": "./dist/cjs/index.js",
36
+ "react-native": "./src/index.ts"
37
+ },
38
+ "./internals": {
39
+ "types": "./dist/esm/internals/index.d.ts",
40
+ "import": "./dist/esm/internals/index.mjs",
41
+ "require": "./dist/cjs/internals/index.js",
42
+ "react-native": "./src/internals/index.ts"
43
+ },
44
+ "./package.json": "./package.json"
45
+ },
46
+ "typesVersions": {
47
+ ">=4.2": {
48
+ "internals": [
49
+ "./dist/esm/internals/index.d.ts"
50
+ ]
51
+ }
52
+ },
33
53
  "repository": {
34
54
  "type": "git",
35
55
  "url": "https://github.com/aws-amplify/amplify-js.git"
@@ -40,25 +60,29 @@
40
60
  "url": "https://github.com/aws/aws-amplify/issues"
41
61
  },
42
62
  "homepage": "https://aws-amplify.github.io/",
63
+ "devDependencies": {
64
+ "@rollup/plugin-typescript": "11.1.5",
65
+ "rollup": "3.29.4"
66
+ },
43
67
  "files": [
44
- "lib",
45
- "lib-esm",
68
+ "dist/cjs",
69
+ "dist/esm",
46
70
  "src",
47
71
  "internals"
48
72
  ],
49
73
  "dependencies": {
50
- "@aws-amplify/api-rest": "4.0.1-console-preview.d745d43.0+d745d43",
51
- "@aws-amplify/auth": "6.0.1-console-preview.d745d43.0+d745d43",
52
- "@aws-amplify/core": "6.0.1-console-preview.d745d43.0+d745d43",
74
+ "@aws-amplify/api-rest": "4.0.1-mjs-test.6f5dab7.0+6f5dab7",
75
+ "@aws-amplify/auth": "6.0.1-mjs-test.6f5dab7.0+6f5dab7",
76
+ "@aws-amplify/core": "6.0.1-mjs-test.6f5dab7.0+6f5dab7",
53
77
  "@aws-sdk/types": "3.387.0",
54
78
  "graphql": "15.8.0",
55
79
  "rxjs": "^7.8.1",
56
- "tslib": "^1.8.0"
80
+ "tslib": "^2.5.0"
57
81
  },
58
82
  "size-limit": [
59
83
  {
60
84
  "name": "API (GraphQL client)",
61
- "path": "./lib-esm/index.js",
85
+ "path": "./dist/esm/index.mjs",
62
86
  "import": "{ Amplify, GraphQLAPI }",
63
87
  "limit": "91.7 kB"
64
88
  }
@@ -115,10 +139,8 @@
115
139
  "coveragePathIgnorePatterns": [
116
140
  "<rootDir>/node_modules/",
117
141
  "<rootDir>/dist",
118
- "<rootDir>/lib",
119
- "<rootDir>/lib-esm",
120
142
  "<rootDir>/__tests__"
121
143
  ]
122
144
  },
123
- "gitHead": "d745d43595a690928a86070deff39f3eed526437"
145
+ "gitHead": "6f5dab7f07d1781d39217d1e5a253c6a5165c8b2"
124
146
  }
package/src/GraphQLAPI.ts CHANGED
@@ -32,13 +32,13 @@ export class GraphQLAPIClass extends InternalGraphQLAPIClass {
32
32
  * @returns An Observable if the query is a subscription query, else a promise of the graphql result.
33
33
  */
34
34
  graphql<T = any>(
35
- amplify: AmplifyClassV6,
35
+ amplify: AmplifyClassV6 | (() => Promise<AmplifyClassV6>),
36
36
  options: GraphQLOptions,
37
37
  additionalHeaders?: { [key: string]: string }
38
38
  ): Observable<GraphQLResult<T>> | Promise<GraphQLResult<T>> {
39
39
  return super.graphql(amplify, options, additionalHeaders, {
40
40
  category: Category.API,
41
- action: ApiAction.GraphQl
41
+ action: ApiAction.GraphQl,
42
42
  });
43
43
  }
44
44
 
@@ -45,6 +45,10 @@ export const graphqlOperation = (
45
45
  authToken,
46
46
  });
47
47
 
48
+ const isAmplifyInstance = (amplify): amplify is AmplifyClassV6 => {
49
+ return typeof amplify !== 'function';
50
+ };
51
+
48
52
  /**
49
53
  * Export Cloud Logic APIs
50
54
  */
@@ -163,7 +167,9 @@ export class InternalGraphQLAPIClass {
163
167
  * @returns An Observable if the query is a subscription query, else a promise of the graphql result.
164
168
  */
165
169
  graphql<T = any>(
166
- amplify: AmplifyClassV6,
170
+ amplify:
171
+ | AmplifyClassV6
172
+ | ((fn: (amplify: any) => Promise<any>) => Promise<AmplifyClassV6>),
167
173
  { query: paramQuery, variables = {}, authMode, authToken }: GraphQLOptions,
168
174
  additionalHeaders?: { [key: string]: string },
169
175
  customUserAgentDetails?: CustomUserAgentDetails
@@ -190,13 +196,32 @@ export class InternalGraphQLAPIClass {
190
196
  case 'query':
191
197
  case 'mutation':
192
198
  const abortController = new AbortController();
193
- const responsePromise = this._graphql<T>(
194
- amplify,
195
- { query, variables, authMode },
196
- headers,
197
- abortController,
198
- customUserAgentDetails
199
- );
199
+
200
+ let responsePromise: Promise<GraphQLResult<T>>;
201
+
202
+ if (isAmplifyInstance(amplify)) {
203
+ responsePromise = this._graphql<T>(
204
+ amplify,
205
+ { query, variables, authMode },
206
+ headers,
207
+ abortController,
208
+ customUserAgentDetails
209
+ );
210
+ } else {
211
+ const wrapper = amplifyInstance =>
212
+ this._graphql<T>(
213
+ amplifyInstance,
214
+ { query, variables, authMode },
215
+ headers,
216
+ abortController,
217
+ customUserAgentDetails
218
+ );
219
+
220
+ responsePromise = amplify(wrapper) as unknown as Promise<
221
+ GraphQLResult<T>
222
+ >;
223
+ }
224
+
200
225
  this._api.updateRequestToBeCancellable(
201
226
  responsePromise,
202
227
  abortController
@@ -204,7 +229,7 @@ export class InternalGraphQLAPIClass {
204
229
  return responsePromise;
205
230
  case 'subscription':
206
231
  return this._graphqlSubscribe(
207
- amplify,
232
+ amplify as AmplifyClassV6,
208
233
  { query, variables, authMode },
209
234
  headers,
210
235
  customUserAgentDetails
@@ -375,7 +400,7 @@ export class InternalGraphQLAPIClass {
375
400
  variables,
376
401
  appSyncGraphqlEndpoint: config?.endpoint,
377
402
  region: config?.region,
378
- authenticationType: config?.defaultAuthMode,
403
+ authenticationType: authMode ?? config?.defaultAuthMode,
379
404
  apiKey: config?.apiKey,
380
405
  additionalHeaders,
381
406
  },
@@ -1,6 +1,6 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
- import { AmplifyClassV6 } from '@aws-amplify/core';
3
+ import { AmplifyClassV6, ResourcesConfig } from '@aws-amplify/core';
4
4
  import { Source, DocumentNode, GraphQLError } from 'graphql';
5
5
  export { OperationTypeNode } from 'graphql';
6
6
  import { Observable } from 'rxjs';
@@ -9,6 +9,8 @@ import {
9
9
  GraphQLAuthMode,
10
10
  DocumentType,
11
11
  } from '@aws-amplify/core/internals/utils';
12
+ import { AmplifyServer } from '@aws-amplify/core/internals/adapter-core';
13
+
12
14
  export { CONTROL_MSG, ConnectionState } from './PubSub';
13
15
  /**
14
16
  * Loose/Unknown options for raw GraphQLAPICategory `graphql()`.
@@ -355,14 +357,54 @@ export const __amplify = Symbol('amplify');
355
357
 
356
358
  export type V6Client<T extends Record<any, any> = never> = ExcludeNeverFields<{
357
359
  [__amplify]: AmplifyClassV6;
358
- graphql: <FALLBACK_TYPES = unknown, TYPED_GQL_STRING extends string = string>(
359
- options: GraphQLOptionsV6<FALLBACK_TYPES, TYPED_GQL_STRING>,
360
- additionalHeaders?:
361
- | {
362
- [key: string]: string;
363
- }
364
- | undefined
365
- ) => GraphQLResponseV6<FALLBACK_TYPES, TYPED_GQL_STRING>;
360
+ graphql: GraphQLMethod;
366
361
  cancel: (promise: Promise<any>, message?: string) => boolean;
367
362
  isCancelError: (error: any) => boolean;
368
363
  }>;
364
+
365
+ export type V6ClientSSR<T extends Record<any, any> = never> =
366
+ ExcludeNeverFields<{
367
+ [__amplify]: AmplifyClassV6;
368
+ graphql: GraphQLMethodSSR;
369
+ cancel: (promise: Promise<any>, message?: string) => boolean;
370
+ isCancelError: (error: any) => boolean;
371
+ }>;
372
+
373
+ export type GraphQLMethod = <
374
+ FALLBACK_TYPES = unknown,
375
+ TYPED_GQL_STRING extends string = string
376
+ >(
377
+ options: GraphQLOptionsV6<FALLBACK_TYPES, TYPED_GQL_STRING>,
378
+ additionalHeaders?:
379
+ | {
380
+ [key: string]: string;
381
+ }
382
+ | undefined
383
+ ) => GraphQLResponseV6<FALLBACK_TYPES, TYPED_GQL_STRING>;
384
+
385
+ export type GraphQLMethodSSR = <
386
+ FALLBACK_TYPES = unknown,
387
+ TYPED_GQL_STRING extends string = string
388
+ >(
389
+ contextSpec: AmplifyServer.ContextSpec,
390
+ options: GraphQLOptionsV6<FALLBACK_TYPES, TYPED_GQL_STRING>,
391
+ additionalHeaders?:
392
+ | {
393
+ [key: string]: string;
394
+ }
395
+ | undefined
396
+ ) => GraphQLResponseV6<FALLBACK_TYPES, TYPED_GQL_STRING>;
397
+
398
+ /**
399
+ * @private
400
+ *
401
+ * The knobs available for configuring `server/generateClient` internally.
402
+ */
403
+ export type ServerClientGenerationParams = {
404
+ amplify:
405
+ | null // null expected when used with `generateServerClient`
406
+ // closure expected with `generateServerClientUsingCookies`
407
+ | ((fn: (amplify: any) => Promise<any>) => Promise<AmplifyClassV6>);
408
+ // global env-sourced config use for retrieving modelIntro
409
+ config: ResourcesConfig;
410
+ };
@@ -1,38 +0,0 @@
1
- import { AmplifyClassV6 } from '@aws-amplify/core';
2
- import { GraphQLOptions, GraphQLResult } from './types';
3
- import { InternalGraphQLAPIClass } from './internals';
4
- import { Observable } from 'rxjs';
5
- export declare const graphqlOperation: (query: any, variables?: {}, authToken?: string | undefined) => {
6
- query: any;
7
- variables: {};
8
- authToken: string | undefined;
9
- };
10
- /**
11
- * Export Cloud Logic APIs
12
- */
13
- export declare class GraphQLAPIClass extends InternalGraphQLAPIClass {
14
- getModuleName(): string;
15
- /**
16
- * Executes a GraphQL operation
17
- *
18
- * @param options - GraphQL Options
19
- * @param [additionalHeaders] - headers to merge in after any `graphql_headers` set in the config
20
- * @returns An Observable if the query is a subscription query, else a promise of the graphql result.
21
- */
22
- graphql<T = any>(amplify: AmplifyClassV6, options: GraphQLOptions, additionalHeaders?: {
23
- [key: string]: string;
24
- }): Observable<GraphQLResult<T>> | Promise<GraphQLResult<T>>;
25
- /**
26
- * Checks to see if an error thrown is from an api request cancellation
27
- * @param error - Any error
28
- * @returns A boolean indicating if the error was from an api request cancellation
29
- */
30
- isCancelError(error: any): boolean;
31
- /**
32
- * Cancels an inflight request. Only applicable for graphql queries and mutations
33
- * @param {any} request - request to cancel
34
- * @returns A boolean indicating if the request was cancelled
35
- */
36
- cancel(request: Promise<any>, message?: string): boolean;
37
- }
38
- export declare const GraphQLAPI: GraphQLAPIClass;
package/lib/GraphQLAPI.js DELETED
@@ -1,57 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var tslib_1 = require("tslib");
4
- var utils_1 = require("@aws-amplify/core/internals/utils");
5
- var internals_1 = require("./internals");
6
- exports.graphqlOperation = function (query, variables, authToken) {
7
- if (variables === void 0) { variables = {}; }
8
- return ({
9
- query: query,
10
- variables: variables,
11
- authToken: authToken,
12
- });
13
- };
14
- /**
15
- * Export Cloud Logic APIs
16
- */
17
- var GraphQLAPIClass = /** @class */ (function (_super) {
18
- tslib_1.__extends(GraphQLAPIClass, _super);
19
- function GraphQLAPIClass() {
20
- return _super !== null && _super.apply(this, arguments) || this;
21
- }
22
- GraphQLAPIClass.prototype.getModuleName = function () {
23
- return 'GraphQLAPI';
24
- };
25
- /**
26
- * Executes a GraphQL operation
27
- *
28
- * @param options - GraphQL Options
29
- * @param [additionalHeaders] - headers to merge in after any `graphql_headers` set in the config
30
- * @returns An Observable if the query is a subscription query, else a promise of the graphql result.
31
- */
32
- GraphQLAPIClass.prototype.graphql = function (amplify, options, additionalHeaders) {
33
- return _super.prototype.graphql.call(this, amplify, options, additionalHeaders, {
34
- category: utils_1.Category.API,
35
- action: utils_1.ApiAction.GraphQl
36
- });
37
- };
38
- /**
39
- * Checks to see if an error thrown is from an api request cancellation
40
- * @param error - Any error
41
- * @returns A boolean indicating if the error was from an api request cancellation
42
- */
43
- GraphQLAPIClass.prototype.isCancelError = function (error) {
44
- return _super.prototype.isCancelError.call(this, error);
45
- };
46
- /**
47
- * Cancels an inflight request. Only applicable for graphql queries and mutations
48
- * @param {any} request - request to cancel
49
- * @returns A boolean indicating if the request was cancelled
50
- */
51
- GraphQLAPIClass.prototype.cancel = function (request, message) {
52
- return _super.prototype.cancel.call(this, request, message);
53
- };
54
- return GraphQLAPIClass;
55
- }(internals_1.InternalGraphQLAPIClass));
56
- exports.GraphQLAPIClass = GraphQLAPIClass;
57
- exports.GraphQLAPI = new GraphQLAPIClass(null);