@aws-amplify/api-graphql 4.0.1-api-v6-models.bc74e14.0 → 4.0.1-api-v6-models.13c9b49.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 (219) hide show
  1. package/{lib → dist/cjs}/GraphQLAPI.js +5 -3
  2. package/dist/cjs/GraphQLAPI.js.map +1 -0
  3. package/{lib → dist/cjs}/Providers/AWSAppSyncRealTimeProvider/index.js +3 -1
  4. package/dist/cjs/Providers/AWSAppSyncRealTimeProvider/index.js.map +1 -0
  5. package/{lib → dist/cjs}/Providers/constants.js +6 -7
  6. package/dist/cjs/Providers/constants.js.map +1 -0
  7. package/{lib → dist/cjs}/index.js +3 -1
  8. package/dist/cjs/index.js.map +1 -0
  9. package/{lib → dist/cjs}/internals/APIClient.js +3 -4
  10. package/dist/cjs/internals/APIClient.js.map +1 -0
  11. package/{lib → dist/cjs}/internals/InternalGraphQLAPI.js +4 -6
  12. package/dist/cjs/internals/InternalGraphQLAPI.js.map +1 -0
  13. package/{lib → dist/cjs}/internals/generateClient.js +3 -1
  14. package/dist/cjs/internals/generateClient.js.map +1 -0
  15. package/{lib → dist/cjs}/internals/generateModelsProperty.js +3 -1
  16. package/dist/cjs/internals/generateModelsProperty.js.map +1 -0
  17. package/{lib → dist/cjs}/internals/index.js +3 -1
  18. package/dist/cjs/internals/index.js.map +1 -0
  19. package/{lib → dist/cjs}/internals/operations/get.js +3 -1
  20. package/dist/cjs/internals/operations/get.js.map +1 -0
  21. package/{lib → dist/cjs}/internals/operations/list.js +3 -1
  22. package/dist/cjs/internals/operations/list.js.map +1 -0
  23. package/{lib → dist/cjs}/internals/operations/observeQuery.js +3 -1
  24. package/dist/cjs/internals/operations/observeQuery.js.map +1 -0
  25. package/{lib → dist/cjs}/internals/operations/subscription.js +3 -1
  26. package/dist/cjs/internals/operations/subscription.js.map +1 -0
  27. package/{lib → dist/cjs}/internals/server/generateClient.js +3 -1
  28. package/dist/cjs/internals/server/generateClient.js.map +1 -0
  29. package/{lib → dist/cjs}/internals/server/generateModelsProperty.js +3 -1
  30. package/dist/cjs/internals/server/generateModelsProperty.js.map +1 -0
  31. package/{lib → dist/cjs}/internals/server/index.js +3 -1
  32. package/dist/cjs/internals/server/index.js.map +1 -0
  33. package/{lib → dist/cjs}/internals/types.js +3 -1
  34. package/dist/cjs/internals/types.js.map +1 -0
  35. package/{lib → dist/cjs}/internals/v6.js +3 -1
  36. package/dist/cjs/internals/v6.js.map +1 -0
  37. package/{lib → dist/cjs}/types/PubSub.js +5 -6
  38. package/dist/cjs/types/PubSub.js.map +1 -0
  39. package/{lib → dist/cjs}/types/index.js +4 -3
  40. package/dist/cjs/types/index.js.map +1 -0
  41. package/{lib → dist/cjs}/utils/ConnectionStateMonitor.js +3 -1
  42. package/dist/cjs/utils/ConnectionStateMonitor.js.map +1 -0
  43. package/{lib → dist/cjs}/utils/ReachabilityMonitor/index.js +3 -1
  44. package/dist/cjs/utils/ReachabilityMonitor/index.js.map +1 -0
  45. package/{lib → dist/cjs}/utils/ReachabilityMonitor/index.native.js +3 -1
  46. package/dist/cjs/utils/ReachabilityMonitor/index.native.js.map +1 -0
  47. package/{lib → dist/cjs}/utils/ReconnectionMonitor.js +4 -2
  48. package/dist/cjs/utils/ReconnectionMonitor.js.map +1 -0
  49. package/{lib → dist/cjs}/utils/errors/APIError.js +3 -1
  50. package/dist/cjs/utils/errors/APIError.js.map +1 -0
  51. package/{lib → dist/cjs}/utils/errors/assertValidationError.js +3 -1
  52. package/dist/cjs/utils/errors/assertValidationError.js.map +1 -0
  53. package/{lib → dist/cjs}/utils/errors/index.js +3 -1
  54. package/dist/cjs/utils/errors/index.js.map +1 -0
  55. package/{lib → dist/cjs}/utils/errors/validation.js +4 -2
  56. package/dist/cjs/utils/errors/validation.js.map +1 -0
  57. package/{lib → dist/cjs}/utils/findIndexByFields.js +3 -1
  58. package/dist/cjs/utils/findIndexByFields.js.map +1 -0
  59. package/{lib → dist/cjs}/utils/index.js +3 -1
  60. package/dist/cjs/utils/index.js.map +1 -0
  61. package/{lib → dist/cjs}/utils/resolveConfig.js +3 -1
  62. package/dist/cjs/utils/resolveConfig.js.map +1 -0
  63. package/{lib → dist/cjs}/utils/resolveLibraryOptions.js +3 -1
  64. package/dist/cjs/utils/resolveLibraryOptions.js.map +1 -0
  65. package/{lib → dist/cjs}/utils/resolveOwnerFields.js +3 -1
  66. package/dist/cjs/utils/resolveOwnerFields.js.map +1 -0
  67. package/{lib → dist/cjs}/utils/resolvePKFields.js +3 -1
  68. package/dist/cjs/utils/resolvePKFields.js.map +1 -0
  69. package/{lib-esm → dist/esm}/GraphQLAPI.d.ts +1 -1
  70. package/{lib-esm/GraphQLAPI.js → dist/esm/GraphQLAPI.mjs} +8 -4
  71. package/dist/esm/GraphQLAPI.mjs.map +1 -0
  72. package/{lib-esm/Providers/AWSAppSyncRealTimeProvider/index.js → dist/esm/Providers/AWSAppSyncRealTimeProvider/index.mjs} +13 -9
  73. package/dist/esm/Providers/AWSAppSyncRealTimeProvider/index.mjs.map +1 -0
  74. package/{lib-esm/Providers/constants.js → dist/esm/Providers/constants.mjs} +18 -14
  75. package/dist/esm/Providers/constants.mjs.map +1 -0
  76. package/dist/esm/index.mjs +5 -0
  77. package/dist/esm/index.mjs.map +1 -0
  78. package/{lib-esm/internals/APIClient.js → dist/esm/internals/APIClient.mjs} +16 -15
  79. package/dist/esm/internals/APIClient.mjs.map +1 -0
  80. package/{lib-esm/internals/InternalGraphQLAPI.js → dist/esm/internals/InternalGraphQLAPI.mjs} +19 -18
  81. package/dist/esm/internals/InternalGraphQLAPI.mjs.map +1 -0
  82. package/{lib-esm/internals/generateClient.js → dist/esm/internals/generateClient.mjs} +8 -4
  83. package/dist/esm/internals/generateClient.mjs.map +1 -0
  84. package/{lib-esm/internals/generateModelsProperty.js → dist/esm/internals/generateModelsProperty.mjs} +10 -6
  85. package/dist/esm/internals/generateModelsProperty.mjs.map +1 -0
  86. package/dist/esm/internals/index.mjs +4 -0
  87. package/dist/esm/internals/index.mjs.map +1 -0
  88. package/{lib-esm/internals/operations/get.js → dist/esm/internals/operations/get.mjs} +6 -2
  89. package/dist/esm/internals/operations/get.mjs.map +1 -0
  90. package/{lib-esm/internals/operations/list.js → dist/esm/internals/operations/list.mjs} +6 -2
  91. package/dist/esm/internals/operations/list.mjs.map +1 -0
  92. package/{lib-esm/internals/operations/observeQuery.js → dist/esm/internals/operations/observeQuery.mjs} +10 -3
  93. package/dist/esm/internals/operations/observeQuery.mjs.map +1 -0
  94. package/{lib-esm/internals/operations/subscription.js → dist/esm/internals/operations/subscription.mjs} +7 -3
  95. package/dist/esm/internals/operations/subscription.mjs.map +1 -0
  96. package/{lib-esm/internals/server/generateClient.js → dist/esm/internals/server/generateClient.mjs} +12 -4
  97. package/dist/esm/internals/server/generateClient.mjs.map +1 -0
  98. package/{lib-esm/internals/server/generateModelsProperty.js → dist/esm/internals/server/generateModelsProperty.mjs} +8 -4
  99. package/dist/esm/internals/server/generateModelsProperty.mjs.map +1 -0
  100. package/dist/esm/internals/server/index.mjs +2 -0
  101. package/dist/esm/internals/server/index.mjs.map +1 -0
  102. package/dist/esm/internals/types.mjs +2 -0
  103. package/dist/esm/internals/types.mjs.map +1 -0
  104. package/{lib-esm/internals/v6.js → dist/esm/internals/v6.mjs} +9 -5
  105. package/dist/esm/internals/v6.mjs.map +1 -0
  106. package/{lib-esm/types/PubSub.js → dist/esm/types/PubSub.mjs} +5 -2
  107. package/dist/esm/types/PubSub.mjs.map +1 -0
  108. package/{lib-esm/types/index.js → dist/esm/types/index.mjs} +9 -5
  109. package/dist/esm/types/index.mjs.map +1 -0
  110. package/{lib-esm/utils/ConnectionStateMonitor.js → dist/esm/utils/ConnectionStateMonitor.mjs} +9 -5
  111. package/dist/esm/utils/ConnectionStateMonitor.mjs.map +1 -0
  112. package/dist/esm/utils/ReachabilityMonitor/index.d.ts +1 -0
  113. package/{lib-esm/utils/ReachabilityMonitor/index.js → dist/esm/utils/ReachabilityMonitor/index.mjs} +6 -2
  114. package/dist/esm/utils/ReachabilityMonitor/index.mjs.map +1 -0
  115. package/dist/esm/utils/ReachabilityMonitor/index.native.d.ts +1 -0
  116. package/dist/esm/utils/ReachabilityMonitor/index.native.mjs +9 -0
  117. package/dist/esm/utils/ReachabilityMonitor/index.native.mjs.map +1 -0
  118. package/{lib-esm/utils/ReconnectionMonitor.js → dist/esm/utils/ReconnectionMonitor.mjs} +7 -3
  119. package/dist/esm/utils/ReconnectionMonitor.mjs.map +1 -0
  120. package/{lib-esm/utils/errors/APIError.js → dist/esm/utils/errors/APIError.mjs} +6 -2
  121. package/dist/esm/utils/errors/APIError.mjs.map +1 -0
  122. package/{lib-esm/utils/errors/assertValidationError.js → dist/esm/utils/errors/assertValidationError.mjs} +7 -3
  123. package/dist/esm/utils/errors/assertValidationError.mjs.map +1 -0
  124. package/dist/esm/utils/errors/index.mjs +4 -0
  125. package/dist/esm/utils/errors/index.mjs.map +1 -0
  126. package/{lib-esm/utils/errors/validation.js → dist/esm/utils/errors/validation.mjs} +5 -2
  127. package/dist/esm/utils/errors/validation.mjs.map +1 -0
  128. package/{lib-esm/utils/findIndexByFields.js → dist/esm/utils/findIndexByFields.mjs} +4 -1
  129. package/dist/esm/utils/findIndexByFields.mjs.map +1 -0
  130. package/dist/esm/utils/index.mjs +5 -0
  131. package/dist/esm/utils/index.mjs.map +1 -0
  132. package/{lib-esm → dist/esm}/utils/resolveConfig.d.ts +1 -1
  133. package/{lib-esm/utils/resolveConfig.js → dist/esm/utils/resolveConfig.mjs} +8 -2
  134. package/dist/esm/utils/resolveConfig.mjs.map +1 -0
  135. package/{lib → dist/esm}/utils/resolveLibraryOptions.d.ts +2 -2
  136. package/{lib-esm/utils/resolveLibraryOptions.js → dist/esm/utils/resolveLibraryOptions.mjs} +4 -1
  137. package/dist/esm/utils/resolveLibraryOptions.mjs.map +1 -0
  138. package/{lib-esm/utils/resolveOwnerFields.js → dist/esm/utils/resolveOwnerFields.mjs} +4 -1
  139. package/dist/esm/utils/resolveOwnerFields.mjs.map +1 -0
  140. package/{lib-esm/utils/resolvePKFields.js → dist/esm/utils/resolvePKFields.mjs} +4 -1
  141. package/dist/esm/utils/resolvePKFields.mjs.map +1 -0
  142. package/internals/package.json +4 -4
  143. package/internals/server/package.json +4 -4
  144. package/package.json +51 -25
  145. package/src/GraphQLAPI.ts +1 -1
  146. package/lib/GraphQLAPI.d.ts +0 -38
  147. package/lib/Providers/AWSAppSyncRealTimeProvider/index.d.ts +0 -64
  148. package/lib/Providers/constants.d.ts +0 -95
  149. package/lib/index.d.ts +0 -3
  150. package/lib/internals/APIClient.d.ts +0 -121
  151. package/lib/internals/InternalGraphQLAPI.d.ts +0 -58
  152. package/lib/internals/generateClient.d.ts +0 -12
  153. package/lib/internals/generateModelsProperty.d.ts +0 -4
  154. package/lib/internals/index.d.ts +0 -3
  155. package/lib/internals/operations/get.d.ts +0 -2
  156. package/lib/internals/operations/list.d.ts +0 -2
  157. package/lib/internals/operations/observeQuery.d.ts +0 -2
  158. package/lib/internals/operations/subscription.d.ts +0 -1
  159. package/lib/internals/server/generateClient.d.ts +0 -11
  160. package/lib/internals/server/generateModelsProperty.d.ts +0 -3
  161. package/lib/internals/server/index.d.ts +0 -1
  162. package/lib/internals/types.d.ts +0 -17
  163. package/lib/internals/v6.d.ts +0 -101
  164. package/lib/tsconfig.tsbuildinfo +0 -1
  165. package/lib/types/PubSub.d.ts +0 -27
  166. package/lib/types/index.d.ts +0 -329
  167. package/lib/utils/ConnectionStateMonitor.d.ts +0 -41
  168. package/lib/utils/ReachabilityMonitor/index.d.ts +0 -1
  169. package/lib/utils/ReachabilityMonitor/index.native.d.ts +0 -1
  170. package/lib/utils/ReconnectionMonitor.d.ts +0 -29
  171. package/lib/utils/errors/APIError.d.ts +0 -7
  172. package/lib/utils/errors/assertValidationError.d.ts +0 -5
  173. package/lib/utils/errors/index.d.ts +0 -3
  174. package/lib/utils/errors/validation.d.ts +0 -7
  175. package/lib/utils/findIndexByFields.d.ts +0 -9
  176. package/lib/utils/index.d.ts +0 -4
  177. package/lib/utils/resolveConfig.d.ts +0 -12
  178. package/lib/utils/resolveOwnerFields.d.ts +0 -12
  179. package/lib/utils/resolvePKFields.d.ts +0 -13
  180. package/lib-esm/index.js +0 -5
  181. package/lib-esm/internals/index.js +0 -5
  182. package/lib-esm/internals/server/index.js +0 -3
  183. package/lib-esm/internals/types.js +0 -1
  184. package/lib-esm/tsconfig.tsbuildinfo +0 -1
  185. package/lib-esm/utils/ReachabilityMonitor/index.d.ts +0 -1
  186. package/lib-esm/utils/ReachabilityMonitor/index.native.d.ts +0 -1
  187. package/lib-esm/utils/ReachabilityMonitor/index.native.js +0 -5
  188. package/lib-esm/utils/errors/index.js +0 -5
  189. package/lib-esm/utils/index.js +0 -6
  190. package/lib-esm/utils/resolveLibraryOptions.d.ts +0 -11
  191. /package/{lib-esm → dist/esm}/Providers/AWSAppSyncRealTimeProvider/index.d.ts +0 -0
  192. /package/{lib-esm → dist/esm}/Providers/constants.d.ts +0 -0
  193. /package/{lib-esm → dist/esm}/index.d.ts +0 -0
  194. /package/{lib-esm → dist/esm}/internals/APIClient.d.ts +0 -0
  195. /package/{lib-esm → dist/esm}/internals/InternalGraphQLAPI.d.ts +0 -0
  196. /package/{lib-esm → dist/esm}/internals/generateClient.d.ts +0 -0
  197. /package/{lib-esm → dist/esm}/internals/generateModelsProperty.d.ts +0 -0
  198. /package/{lib-esm → dist/esm}/internals/index.d.ts +0 -0
  199. /package/{lib-esm → dist/esm}/internals/operations/get.d.ts +0 -0
  200. /package/{lib-esm → dist/esm}/internals/operations/list.d.ts +0 -0
  201. /package/{lib-esm → dist/esm}/internals/operations/observeQuery.d.ts +0 -0
  202. /package/{lib-esm → dist/esm}/internals/operations/subscription.d.ts +0 -0
  203. /package/{lib-esm → dist/esm}/internals/server/generateClient.d.ts +0 -0
  204. /package/{lib-esm → dist/esm}/internals/server/generateModelsProperty.d.ts +0 -0
  205. /package/{lib-esm → dist/esm}/internals/server/index.d.ts +0 -0
  206. /package/{lib-esm → dist/esm}/internals/types.d.ts +0 -0
  207. /package/{lib-esm → dist/esm}/internals/v6.d.ts +0 -0
  208. /package/{lib-esm → dist/esm}/types/PubSub.d.ts +0 -0
  209. /package/{lib-esm → dist/esm}/types/index.d.ts +0 -0
  210. /package/{lib-esm → dist/esm}/utils/ConnectionStateMonitor.d.ts +0 -0
  211. /package/{lib-esm → dist/esm}/utils/ReconnectionMonitor.d.ts +0 -0
  212. /package/{lib-esm → dist/esm}/utils/errors/APIError.d.ts +0 -0
  213. /package/{lib-esm → dist/esm}/utils/errors/assertValidationError.d.ts +0 -0
  214. /package/{lib-esm → dist/esm}/utils/errors/index.d.ts +0 -0
  215. /package/{lib-esm → dist/esm}/utils/errors/validation.d.ts +0 -0
  216. /package/{lib-esm → dist/esm}/utils/findIndexByFields.d.ts +0 -0
  217. /package/{lib-esm → dist/esm}/utils/index.d.ts +0 -0
  218. /package/{lib-esm → dist/esm}/utils/resolveOwnerFields.d.ts +0 -0
  219. /package/{lib-esm → dist/esm}/utils/resolvePKFields.d.ts +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InternalGraphQLAPI.mjs","sources":["../../../src/internals/InternalGraphQLAPI.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { print, parse, GraphQLError, } from 'graphql';\nimport { ConsoleLogger } from '@aws-amplify/core';\nimport { getAmplifyUserAgent, AmplifyUrl, } from '@aws-amplify/core/internals/utils';\nimport { GraphQLAuthError, } from '../types';\nimport { isCancelError as isCancelErrorREST } from '@aws-amplify/api-rest';\nimport { post, cancel as cancelREST, updateRequestToBeCancellable, } from '@aws-amplify/api-rest/internals';\nimport { AWSAppSyncRealTimeProvider } from '../Providers/AWSAppSyncRealTimeProvider';\nimport { resolveConfig, resolveLibraryOptions } from '../utils';\nconst USER_AGENT_HEADER = 'x-amz-user-agent';\nconst logger = new ConsoleLogger('GraphQLAPI');\nexport const graphqlOperation = (query, variables = {}, authToken) => ({\n query,\n variables,\n authToken,\n});\nconst isAmplifyInstance = (amplify) => {\n return typeof amplify !== 'function';\n};\n/**\n * Export Cloud Logic APIs\n */\nexport class InternalGraphQLAPIClass {\n /**\n * Initialize GraphQL API with AWS configuration\n * @param {Object} options - Configuration object for API\n */\n constructor(options) {\n this._api = {\n post,\n cancelREST,\n isCancelErrorREST,\n updateRequestToBeCancellable,\n };\n this._options = options;\n logger.debug('API Options', this._options);\n }\n getModuleName() {\n return 'InternalGraphQLAPI';\n }\n async _headerBasedAuth(amplify, authMode, additionalHeaders = {}) {\n const config = amplify.getConfig();\n const { region: region, endpoint: appSyncGraphqlEndpoint, apiKey, defaultAuthMode, } = resolveConfig(amplify);\n const authenticationType = authMode || defaultAuthMode || 'iam';\n let headers = {};\n switch (authenticationType) {\n case 'apiKey':\n if (!apiKey) {\n throw new Error(GraphQLAuthError.NO_API_KEY);\n }\n headers = {\n 'X-Api-Key': apiKey,\n };\n break;\n case 'iam':\n const session = await amplify.Auth.fetchAuthSession();\n if (session.credentials === undefined) {\n throw new Error(GraphQLAuthError.NO_CREDENTIALS);\n }\n break;\n case 'oidc':\n case 'userPool':\n try {\n let token;\n token = (await amplify.Auth.fetchAuthSession()).tokens?.accessToken.toString();\n if (!token) {\n throw new Error(GraphQLAuthError.NO_FEDERATED_JWT);\n }\n headers = {\n Authorization: token,\n };\n }\n catch (e) {\n throw new Error(GraphQLAuthError.NO_CURRENT_USER);\n }\n break;\n case 'lambda':\n if (!additionalHeaders.Authorization) {\n throw new Error(GraphQLAuthError.NO_AUTH_TOKEN);\n }\n headers = {\n Authorization: additionalHeaders.Authorization,\n };\n break;\n case 'none':\n break;\n default:\n break;\n }\n return headers;\n }\n /**\n * to get the operation type\n * @param operation\n */\n getGraphqlOperationType(operation) {\n const doc = parse(operation);\n const definitions = doc.definitions;\n const [{ operation: operationType }] = definitions;\n return operationType;\n }\n /**\n * Executes a GraphQL operation\n *\n * @param options - GraphQL Options\n * @param [additionalHeaders] - headers to merge in after any `graphql_headers` set in the config\n * @returns An Observable if the query is a subscription query, else a promise of the graphql result.\n */\n graphql(amplify, { query: paramQuery, variables = {}, authMode, authToken }, additionalHeaders, customUserAgentDetails) {\n const query = typeof paramQuery === 'string'\n ? parse(paramQuery)\n : parse(print(paramQuery));\n const [operationDef = {}] = query.definitions.filter(def => def.kind === 'OperationDefinition');\n const { operation: operationType } = operationDef;\n const headers = additionalHeaders || {};\n // if an authorization header is set, have the explicit authToken take precedence\n if (authToken) {\n headers.Authorization = authToken;\n }\n switch (operationType) {\n case 'query':\n case 'mutation':\n const abortController = new AbortController();\n let responsePromise;\n if (isAmplifyInstance(amplify)) {\n responsePromise = this._graphql(amplify, { query, variables, authMode }, headers, abortController, customUserAgentDetails);\n }\n else {\n const wrapper = amplifyInstance => this._graphql(amplifyInstance, { query, variables, authMode }, headers, abortController, customUserAgentDetails);\n responsePromise = amplify(wrapper);\n }\n this._api.updateRequestToBeCancellable(responsePromise, abortController);\n return responsePromise;\n case 'subscription':\n return this._graphqlSubscribe(amplify, { query, variables, authMode }, headers, customUserAgentDetails);\n default:\n throw new Error(`invalid operation type: ${operationType}`);\n }\n }\n async _graphql(amplify, { query, variables, authMode }, additionalHeaders = {}, abortController, customUserAgentDetails) {\n const { region: region, endpoint: appSyncGraphqlEndpoint, customEndpoint, customEndpointRegion, } = resolveConfig(amplify);\n // Retrieve library options from Amplify configuration\n const { headers: customHeaders, withCredentials } = resolveLibraryOptions(amplify);\n // TODO: Figure what we need to do to remove `!`'s.\n const headers = {\n ...(!customEndpoint &&\n (await this._headerBasedAuth(amplify, authMode, additionalHeaders))),\n /**\n * Custom endpoint headers.\n * If there is both a custom endpoint and custom region present, we get the headers.\n * If there is a custom endpoint but no region, we return an empty object.\n * If neither are present, we return an empty object.\n */\n ...((customEndpoint &&\n (customEndpointRegion\n ? await this._headerBasedAuth(amplify, authMode, additionalHeaders)\n : {})) ||\n {}),\n // Custom headers included in Amplify configuration options:\n ...(customHeaders &&\n (await customHeaders({\n query: print(query),\n variables,\n }))),\n // Headers from individual calls to `graphql`:\n ...additionalHeaders,\n // User agent headers:\n ...(!customEndpoint && {\n [USER_AGENT_HEADER]: getAmplifyUserAgent(customUserAgentDetails),\n }),\n };\n const body = {\n query: print(query),\n variables: variables || null,\n };\n let signingServiceInfo;\n /**\n * We do not send the signing service info to the REST API under the\n * following conditions (i.e. it will not sign the request):\n * - there is a custom endpoint but no region\n * - the auth mode is `none`, or `apiKey`\n * - the auth mode is a type other than the types listed below\n */\n if ((customEndpoint && !customEndpointRegion) ||\n (authMode !== 'oidc' &&\n authMode !== 'userPool' &&\n authMode !== 'iam' &&\n authMode !== 'lambda')) {\n signingServiceInfo = null;\n }\n else {\n signingServiceInfo = {\n service: !customEndpointRegion ? 'appsync' : 'execute-api',\n region: !customEndpointRegion ? region : customEndpointRegion,\n };\n }\n const endpoint = customEndpoint || appSyncGraphqlEndpoint;\n if (!endpoint) {\n const error = new GraphQLError('No graphql endpoint provided.');\n throw {\n data: {},\n errors: [error],\n };\n }\n let response;\n try {\n const { body: responseBody } = await this._api.post({\n url: new AmplifyUrl(endpoint),\n options: {\n headers,\n body,\n signingServiceInfo,\n withCredentials,\n },\n abortController,\n });\n const result = await responseBody.json();\n response = result;\n }\n catch (err) {\n // If the exception is because user intentionally\n // cancelled the request, do not modify the exception\n // so that clients can identify the exception correctly.\n if (this.isCancelError(err)) {\n throw err;\n }\n response = {\n data: {},\n errors: [new GraphQLError(err.message, null, null, null, null, err)],\n };\n }\n const { errors } = response;\n if (errors && errors.length) {\n throw response;\n }\n return response;\n }\n /**\n * Checks to see if an error thrown is from an api request cancellation\n * @param {any} error - Any error\n * @return {boolean} - A boolean indicating if the error was from an api request cancellation\n */\n isCancelError(error) {\n return this._api.isCancelErrorREST(error);\n }\n /**\n * Cancels an inflight request. Only applicable for graphql queries and mutations\n * @param {any} request - request to cancel\n * @returns - A boolean indicating if the request was cancelled\n */\n cancel(request, message) {\n return this._api.cancelREST(request, message);\n }\n _graphqlSubscribe(amplify, { query, variables, authMode }, additionalHeaders = {}, customUserAgentDetails) {\n const config = resolveConfig(amplify);\n if (!this.appSyncRealTime) {\n this.appSyncRealTime = new AWSAppSyncRealTimeProvider();\n }\n return this.appSyncRealTime.subscribe({\n query: print(query),\n variables,\n appSyncGraphqlEndpoint: config?.endpoint,\n region: config?.region,\n authenticationType: authMode || config?.defaultAuthMode,\n apiKey: config?.apiKey,\n additionalHeaders,\n }, customUserAgentDetails);\n }\n}\nexport const InternalGraphQLAPI = new InternalGraphQLAPIClass(null);\n"],"names":["cancelREST","isCancelErrorREST"],"mappings":";;;;;;;;;;AAAA;AACA;AASA,MAAM,iBAAiB,GAAG,kBAAkB,CAAC;AAC7C,MAAM,MAAM,GAAG,IAAI,aAAa,CAAC,YAAY,CAAC,CAAC;AACnC,MAAC,gBAAgB,GAAG,CAAC,KAAK,EAAE,SAAS,GAAG,EAAE,EAAE,SAAS,MAAM;AACvE,IAAI,KAAK;AACT,IAAI,SAAS;AACb,IAAI,SAAS;AACb,CAAC,EAAE;AACH,MAAM,iBAAiB,GAAG,CAAC,OAAO,KAAK;AACvC,IAAI,OAAO,OAAO,OAAO,KAAK,UAAU,CAAC;AACzC,CAAC,CAAC;AACF;AACA;AACA;AACO,MAAM,uBAAuB,CAAC;AACrC;AACA;AACA;AACA;AACA,IAAI,WAAW,CAAC,OAAO,EAAE;AACzB,QAAQ,IAAI,CAAC,IAAI,GAAG;AACpB,YAAY,IAAI;AAChB,wBAAYA,MAAU;AACtB,+BAAYC,aAAiB;AAC7B,YAAY,4BAA4B;AACxC,SAAS,CAAC;AACV,QAAQ,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;AAChC,QAAQ,MAAM,CAAC,KAAK,CAAC,aAAa,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;AACnD,KAAK;AACL,IAAI,aAAa,GAAG;AACpB,QAAQ,OAAO,oBAAoB,CAAC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;AACL,IAAI,iBAAiB,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,iBAAiB,GAAG,EAAE,EAAE,sBAAsB,EAAE;AAC/G,QAAQ,MAAM,MAAM,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;AAC9C,QAAQ,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE;AACnC,YAAY,IAAI,CAAC,eAAe,GAAG,IAAI,0BAA0B,EAAE,CAAC;AACpE,SAAS;AACT,QAAQ,OAAO,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC;AAC9C,YAAY,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC;AAC/B,YAAY,SAAS;AACrB,YAAY,sBAAsB,EAAE,MAAM,EAAE,QAAQ;AACpD,YAAY,MAAM,EAAE,MAAM,EAAE,MAAM;AAClC,YAAY,kBAAkB,EAAE,QAAQ,IAAI,MAAM,EAAE,eAAe;AACnE,YAAY,MAAM,EAAE,MAAM,EAAE,MAAM;AAClC,YAAY,iBAAiB;AAC7B,SAAS,EAAE,sBAAsB,CAAC,CAAC;AACnC,KAAK;AACL,CAAC;AACW,MAAC,kBAAkB,GAAG,IAAI,uBAAuB,CAAC,IAAI;;;;"}
@@ -1,8 +1,9 @@
1
+ import { graphql, cancel, isCancelError } from './v6.mjs';
2
+ import { generateModelsProperty } from './generateModelsProperty.mjs';
3
+ import { __amplify, __authMode, __authToken } from '../types/index.mjs';
4
+
1
5
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
6
  // SPDX-License-Identifier: Apache-2.0
3
- import { graphql, cancel, isCancelError } from './v6';
4
- import { generateModelsProperty } from './generateModelsProperty';
5
- import { __amplify, __authMode, __authToken } from '../types';
6
7
  /**
7
8
  * @private
8
9
  *
@@ -12,7 +13,7 @@ import { __amplify, __authMode, __authToken } from '../types';
12
13
  * @param params
13
14
  * @returns
14
15
  */
15
- export function generateClient(params) {
16
+ function generateClient(params) {
16
17
  const client = {
17
18
  [__amplify]: params.amplify,
18
19
  [__authMode]: params.authMode,
@@ -25,3 +26,6 @@ export function generateClient(params) {
25
26
  client.models = generateModelsProperty(client, params);
26
27
  return client;
27
28
  }
29
+
30
+ export { generateClient };
31
+ //# sourceMappingURL=generateClient.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generateClient.mjs","sources":["../../../src/internals/generateClient.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { graphql, cancel, isCancelError } from './v6';\nimport { generateModelsProperty } from './generateModelsProperty';\nimport { __amplify, __authMode, __authToken } from '../types';\n/**\n * @private\n *\n * Creates a client that can be used to make GraphQL requests, using a provided `AmplifyClassV6`\n * compatible context object for config and auth fetching.\n *\n * @param params\n * @returns\n */\nexport function generateClient(params) {\n const client = {\n [__amplify]: params.amplify,\n [__authMode]: params.authMode,\n [__authToken]: params.authToken,\n graphql,\n cancel,\n isCancelError,\n models: {},\n };\n client.models = generateModelsProperty(client, params);\n return client;\n}\n"],"names":[],"mappings":";;;;AAAA;AACA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,cAAc,CAAC,MAAM,EAAE;AACvC,IAAI,MAAM,MAAM,GAAG;AACnB,QAAQ,CAAC,SAAS,GAAG,MAAM,CAAC,OAAO;AACnC,QAAQ,CAAC,UAAU,GAAG,MAAM,CAAC,QAAQ;AACrC,QAAQ,CAAC,WAAW,GAAG,MAAM,CAAC,SAAS;AACvC,QAAQ,OAAO;AACf,QAAQ,MAAM;AACd,QAAQ,aAAa;AACrB,QAAQ,MAAM,EAAE,EAAE;AAClB,KAAK,CAAC;AACN,IAAI,MAAM,CAAC,MAAM,GAAG,sBAAsB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAC3D,IAAI,OAAO,MAAM,CAAC;AAClB;;;;"}
@@ -1,9 +1,10 @@
1
- import { graphQLOperationsInfo } from './APIClient';
2
- import { listFactory } from './operations/list';
3
- import { getFactory } from './operations/get';
4
- import { subscriptionFactory } from './operations/subscription';
5
- import { observeQueryFactory } from './operations/observeQuery';
6
- export function generateModelsProperty(client, params) {
1
+ import { graphQLOperationsInfo } from './APIClient.mjs';
2
+ import { listFactory } from './operations/list.mjs';
3
+ import { getFactory } from './operations/get.mjs';
4
+ import { subscriptionFactory } from './operations/subscription.mjs';
5
+ import { observeQueryFactory } from './operations/observeQuery.mjs';
6
+
7
+ function generateModelsProperty(client, params) {
7
8
  const models = {};
8
9
  const config = params.amplify.getConfig();
9
10
  if (!config.API?.GraphQL) {
@@ -35,3 +36,6 @@ export function generateModelsProperty(client, params) {
35
36
  }
36
37
  return models;
37
38
  }
39
+
40
+ export { generateModelsProperty };
41
+ //# sourceMappingURL=generateModelsProperty.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generateModelsProperty.mjs","sources":["../../../src/internals/generateModelsProperty.ts"],"sourcesContent":["import { graphQLOperationsInfo } from './APIClient';\nimport { listFactory } from './operations/list';\nimport { getFactory } from './operations/get';\nimport { subscriptionFactory } from './operations/subscription';\nimport { observeQueryFactory } from './operations/observeQuery';\nexport function generateModelsProperty(client, params) {\n const models = {};\n const config = params.amplify.getConfig();\n if (!config.API?.GraphQL) {\n throw new Error('The API configuration is missing. This is likely due to Amplify.configure() not being called prior to generateClient().');\n }\n const modelIntrospection = config.API?.GraphQL?.modelIntrospection;\n if (!modelIntrospection) {\n return {};\n }\n const SUBSCRIPTION_OPS = ['ONCREATE', 'ONUPDATE', 'ONDELETE'];\n for (const model of Object.values(modelIntrospection.models)) {\n const { name } = model;\n models[name] = {};\n Object.entries(graphQLOperationsInfo).forEach(([key, { operationPrefix }]) => {\n const operation = key;\n if (operation === 'LIST') {\n models[name][operationPrefix] = listFactory(client, modelIntrospection, model);\n }\n else if (SUBSCRIPTION_OPS.includes(operation)) {\n models[name][operationPrefix] = subscriptionFactory(client, modelIntrospection, model, operation);\n }\n else if (operation === 'OBSERVE_QUERY') {\n models[name][operationPrefix] = observeQueryFactory(models, model);\n }\n else {\n models[name][operationPrefix] = getFactory(client, modelIntrospection, model, operation);\n }\n });\n }\n return models;\n}\n"],"names":[],"mappings":";;;;;;AAKO,SAAS,sBAAsB,CAAC,MAAM,EAAE,MAAM,EAAE;AACvD,IAAI,MAAM,MAAM,GAAG,EAAE,CAAC;AACtB,IAAI,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC;AAC9C,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,OAAO,EAAE;AAC9B,QAAQ,MAAM,IAAI,KAAK,CAAC,yHAAyH,CAAC,CAAC;AACnJ,KAAK;AACL,IAAI,MAAM,kBAAkB,GAAG,MAAM,CAAC,GAAG,EAAE,OAAO,EAAE,kBAAkB,CAAC;AACvE,IAAI,IAAI,CAAC,kBAAkB,EAAE;AAC7B,QAAQ,OAAO,EAAE,CAAC;AAClB,KAAK;AACL,IAAI,MAAM,gBAAgB,GAAG,CAAC,UAAU,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;AAClE,IAAI,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,kBAAkB,CAAC,MAAM,CAAC,EAAE;AAClE,QAAQ,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC;AAC/B,QAAQ,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;AAC1B,QAAQ,MAAM,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,EAAE,eAAe,EAAE,CAAC,KAAK;AACtF,YAAY,MAAM,SAAS,GAAG,GAAG,CAAC;AAClC,YAAY,IAAI,SAAS,KAAK,MAAM,EAAE;AACtC,gBAAgB,MAAM,CAAC,IAAI,CAAC,CAAC,eAAe,CAAC,GAAG,WAAW,CAAC,MAAM,EAAE,kBAAkB,EAAE,KAAK,CAAC,CAAC;AAC/F,aAAa;AACb,iBAAiB,IAAI,gBAAgB,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE;AAC3D,gBAAgB,MAAM,CAAC,IAAI,CAAC,CAAC,eAAe,CAAC,GAAG,mBAAmB,CAAC,MAAM,EAAE,kBAAkB,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;AAClH,aAAa;AACb,iBAAiB,IAAI,SAAS,KAAK,eAAe,EAAE;AACpD,gBAAgB,MAAM,CAAC,IAAI,CAAC,CAAC,eAAe,CAAC,GAAG,mBAAmB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AACnF,aAAa;AACb,iBAAiB;AACjB,gBAAgB,MAAM,CAAC,IAAI,CAAC,CAAC,eAAe,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,kBAAkB,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;AACzG,aAAa;AACb,SAAS,CAAC,CAAC;AACX,KAAK;AACL,IAAI,OAAO,MAAM,CAAC;AAClB;;;;"}
@@ -0,0 +1,4 @@
1
+ export { InternalGraphQLAPI, InternalGraphQLAPIClass } from './InternalGraphQLAPI.mjs';
2
+ export { cancel, graphql, isCancelError } from './v6.mjs';
3
+ export { generateClient } from './generateClient.mjs';
4
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
@@ -1,5 +1,6 @@
1
- import { initializeModel, generateGraphQLDocument, buildGraphQLVariables, flattenItems, authModeParams, } from '../APIClient';
2
- export function getFactory(client, modelIntrospection, model, operation, context = false) {
1
+ import { generateGraphQLDocument, buildGraphQLVariables, authModeParams, flattenItems, initializeModel } from '../APIClient.mjs';
2
+
3
+ function getFactory(client, modelIntrospection, model, operation, context = false) {
3
4
  const getWithContext = async (contextSpec, arg, options) => {
4
5
  return _get(client, modelIntrospection, model, arg, options, operation, contextSpec);
5
6
  };
@@ -53,3 +54,6 @@ async function _get(client, modelIntrospection, model, arg, options, operation,
53
54
  }
54
55
  }
55
56
  }
57
+
58
+ export { getFactory };
59
+ //# sourceMappingURL=get.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get.mjs","sources":["../../../../src/internals/operations/get.ts"],"sourcesContent":["import { initializeModel, generateGraphQLDocument, buildGraphQLVariables, flattenItems, authModeParams, } from '../APIClient';\nexport function getFactory(client, modelIntrospection, model, operation, context = false) {\n const getWithContext = async (contextSpec, arg, options) => {\n return _get(client, modelIntrospection, model, arg, options, operation, contextSpec);\n };\n const get = async (arg, options) => {\n return _get(client, modelIntrospection, model, arg, options, operation, context);\n };\n return context ? getWithContext : get;\n}\nasync function _get(client, modelIntrospection, model, arg, options, operation, context) {\n const { name } = model;\n const query = generateGraphQLDocument(modelIntrospection.models, name, operation, options);\n const variables = buildGraphQLVariables(model, operation, arg, modelIntrospection);\n try {\n const auth = authModeParams(client, options);\n const { data, extensions } = context\n ? (await client.graphql(context, {\n ...auth,\n query,\n variables,\n }))\n : (await client.graphql({\n ...auth,\n query,\n variables,\n }));\n // flatten response\n if (data !== undefined) {\n const [key] = Object.keys(data);\n const flattenedResult = flattenItems(data)[key];\n if (options?.selectionSet) {\n return { data: flattenedResult, extensions };\n }\n else {\n // TODO: refactor to avoid destructuring here\n const [initialized] = initializeModel(client, name, [flattenedResult], modelIntrospection, auth.authMode, auth.authToken, context);\n return { data: initialized, extensions };\n }\n }\n else {\n return { data: null, extensions };\n }\n }\n catch (error) {\n if (error.errors) {\n // graphql errors pass through\n return error;\n }\n else {\n // non-graphql errors re re-thrown\n throw error;\n }\n }\n}\n"],"names":[],"mappings":";;AACO,SAAS,UAAU,CAAC,MAAM,EAAE,kBAAkB,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,GAAG,KAAK,EAAE;AAC1F,IAAI,MAAM,cAAc,GAAG,OAAO,WAAW,EAAE,GAAG,EAAE,OAAO,KAAK;AAChE,QAAQ,OAAO,IAAI,CAAC,MAAM,EAAE,kBAAkB,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO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CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC5C,YAAY,MAAM,eAAe,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;AAC5D,YAAY,IAAI,OAAO,EAAE,YAAY,EAAE;AACvC,gBAAgB,OAAO,EAAE,IAAI,EAAE,eAAe,EAAE,UAAU,EAAE,CAAC;AAC7D,aAAa;AACb,iBAAiB;AACjB;AACA,gBAAgB,MAAM,CAAC,WAAW,CAAC,GAAG,eAAe,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,eAAe,CAAC,EAAE,kBAAkB,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;AACnJ,gBAAgB,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC;AACzD,aAAa;AACb,SAAS;AACT,aAAa;AACb,YAAY,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;AAC9C,SAAS;AACT,KAAK;AACL,IAAI,OAAO,KAAK,EAAE;AAClB,QAAQ,IAAI,KAAK,CAAC,MAAM,EAAE;AAC1B;AACA,YAAY,OAAO,KAAK,CAAC;AACzB,SAAS;AACT,aAAa;AACb;AACA,YAAY,MAAM,KAAK,CAAC;AACxB,SAAS;AACT,KAAK;AACL;;;;"}
@@ -1,5 +1,6 @@
1
- import { initializeModel, generateGraphQLDocument, buildGraphQLVariables, flattenItems, authModeParams, } from '../APIClient';
2
- export function listFactory(client, modelIntrospection, model, context = false) {
1
+ import { generateGraphQLDocument, buildGraphQLVariables, authModeParams, flattenItems, initializeModel } from '../APIClient.mjs';
2
+
3
+ function listFactory(client, modelIntrospection, model, context = false) {
3
4
  const listWithContext = async (contextSpec, args) => {
4
5
  return _list(client, modelIntrospection, model, args, contextSpec);
5
6
  };
@@ -65,3 +66,6 @@ async function _list(client, modelIntrospection, model, args, context) {
65
66
  }
66
67
  }
67
68
  }
69
+
70
+ export { listFactory };
71
+ //# sourceMappingURL=list.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list.mjs","sources":["../../../../src/internals/operations/list.ts"],"sourcesContent":["import { initializeModel, generateGraphQLDocument, buildGraphQLVariables, flattenItems, authModeParams, } from '../APIClient';\nexport function listFactory(client, modelIntrospection, model, context = false) {\n const listWithContext = async (contextSpec, args) => {\n return _list(client, modelIntrospection, model, args, contextSpec);\n };\n const list = async (args) => {\n return _list(client, modelIntrospection, model, args, context);\n };\n return context ? listWithContext : list;\n}\nasync function _list(client, modelIntrospection, model, args, context) {\n const { name } = model;\n const query = generateGraphQLDocument(modelIntrospection.models, name, 'LIST', args);\n const variables = buildGraphQLVariables(model, 'LIST', args, modelIntrospection);\n try {\n const auth = authModeParams(client, args);\n const { data, extensions } = context\n ? (await client.graphql(context, {\n ...auth,\n query,\n variables,\n }))\n : (await client.graphql({\n ...auth,\n query,\n variables,\n }));\n // flatten response\n if (data !== undefined) {\n const [key] = Object.keys(data);\n if (data[key].items) {\n const flattenedResult = flattenItems(data)[key];\n // don't init if custom selection set\n if (args?.selectionSet) {\n return {\n data: flattenedResult,\n nextToken: data[key].nextToken,\n extensions,\n };\n }\n else {\n const initialized = initializeModel(client, name, flattenedResult, modelIntrospection, auth.authMode, auth.authToken, context);\n return {\n data: initialized,\n nextToken: data[key].nextToken,\n extensions,\n };\n }\n }\n return {\n data: data[key],\n nextToken: data[key].nextToken,\n extensions,\n };\n }\n }\n catch (error) {\n if (error.errors) {\n // graphql errors pass through\n return error;\n }\n else {\n // non-graphql errors re re-thrown\n throw error;\n }\n }\n}\n"],"names":[],"mappings":";;AACO,SAAS,WAAW,CAAC,MAAM,EAAE,kBAAkB,EAAE,KAAK,EAAE,OAAO,GAAG,KAAK,EAAE;AAChF,IAAI,MAAM,eAAe,GAAG,OAAO,WAAW,EAAE,IAAI,KAAK;AACzD,QAAQ,OAAO,KAAK,CAAC,MAAM,EAAE,kBAAkB,EAAE,KAAK,EAAE,IAAI,EAAE,WA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C,KAAK,EAAE;AACjC,gBAAgB,MAAM,eAAe,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;AAChE;AACA,gBAAgB,IAAI,IAAI,EAAE,YAAY,EAAE;AACxC,oBAAoB,OAAO;AAC3B,wBAAwB,IAAI,EAAE,eAAe;AAC7C,wBAAwB,SAAS,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,SAAS;AACtD,wBAAwB,UAAU;AAClC,qBAAqB,CAAC;AACtB,iBAAiB;AACjB,qBAAqB;AACrB,oBAAoB,MAAM,WAAW,GAAG,eAAe,CAAC,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE,kBAAkB,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;AACnJ,oBAAoB,OAAO;AAC3B,wBAAwB,IAAI,EAAE,WAAW;AACzC,wBAAwB,SAAS,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,SAAS;AACtD,wBAAwB,UAAU;AAClC,qBAAqB,CAAC;AACtB,iBAAiB;AACjB,aAAa;AACb,YAAY,OAAO;AACnB,gBAAgB,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC;AAC/B,gBAAgB,SAAS,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,SAAS;AAC9C,gBAAgB,UAAU;AAC1B,aAAa,CAAC;AACd,SAAS;AACT,KAAK;AACL,IAAI,OAAO,KAAK,EAAE;AAClB,QAAQ,IAAI,KAAK,CAAC,MAAM,EAAE;AAC1B;AACA,YAAY,OAAO,KAAK,CAAC;AACzB,SAAS;AACT,aAAa;AACb;AACA,YAAY,MAAM,KAAK,CAAC;AACxB,SAAS;AACT,KAAK;AACL;;;;"}
@@ -1,8 +1,12 @@
1
+ import { Observable } from 'rxjs';
2
+ import '@aws-amplify/core/internals/utils';
3
+ import '../../utils/errors/validation.mjs';
4
+ import { resolvePKFields } from '../../utils/resolvePKFields.mjs';
5
+ import { findIndexByFields } from '../../utils/findIndexByFields.mjs';
6
+
1
7
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
8
  // SPDX-License-Identifier: Apache-2.0
3
- import { Observable } from 'rxjs';
4
- import { findIndexByFields, resolvePKFields } from '../../utils';
5
- export function observeQueryFactory(models, model) {
9
+ function observeQueryFactory(models, model) {
6
10
  const { name } = model;
7
11
  const observeQuery = (arg) => new Observable(subscriber => {
8
12
  // what we'll be sending to our subscribers
@@ -113,3 +117,6 @@ export function observeQueryFactory(models, model) {
113
117
  });
114
118
  return observeQuery;
115
119
  }
120
+
121
+ export { observeQueryFactory };
122
+ //# sourceMappingURL=observeQuery.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"observeQuery.mjs","sources":["../../../../src/internals/operations/observeQuery.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Observable } from 'rxjs';\nimport { findIndexByFields, resolvePKFields } from '../../utils';\nexport function observeQueryFactory(models, model) {\n const { name } = model;\n const observeQuery = (arg) => new Observable(subscriber => {\n // what we'll be sending to our subscribers\n const items = [];\n // To enqueue subscription messages while we collect our initial\n // result set.\n const messageQueue = [];\n // operation to take when message(s) arrive.\n // this operation will be swapped out once initial \"sync\" is complete\n // to immediately ingest messsages.\n let receiveMessages = (...messages) => {\n return messageQueue.push(...messages);\n };\n // start subscriptions\n const onCreateSub = models[name].onCreate(arg).subscribe({\n next(item) {\n receiveMessages({ item, type: 'create' });\n },\n error(error) {\n subscriber.error({ type: 'onCreate', error });\n },\n });\n const onUpdateSub = models[name].onUpdate(arg).subscribe({\n next(item) {\n receiveMessages({ item, type: 'update' });\n },\n error(error) {\n subscriber.error({ type: 'onUpdate', error });\n },\n });\n const onDeleteSub = models[name].onDelete(arg).subscribe({\n next(item) {\n receiveMessages({ item, type: 'delete' });\n },\n error(error) {\n subscriber.error({ type: 'onDelete', error });\n },\n });\n // consumes a list of messages and sends a snapshot\n function ingestMessages(messages) {\n for (const message of messages) {\n const idx = findIndexByFields(message.item, items, pkFields);\n switch (message.type) {\n case 'create':\n if (idx < 0)\n items.push(message.item);\n break;\n case 'update':\n if (idx >= 0)\n items[idx] = message.item;\n break;\n case 'delete':\n if (idx >= 0)\n items.splice(idx, 1);\n break;\n default:\n console.error('Unrecognized message in observeQuery.', message);\n }\n }\n subscriber.next({\n items,\n isSynced: true,\n });\n }\n const pkFields = resolvePKFields(model);\n // initial results\n (async () => {\n let firstPage = true;\n let nextToken = null;\n while (!subscriber.closed && (firstPage || nextToken)) {\n firstPage = false;\n const { data: page, errors, nextToken: _nextToken, } = await models[name].list({ ...arg, nextToken });\n nextToken = _nextToken;\n items.push(...page);\n // if there are no more pages and no items we already know about\n // that need to be merged in from sub, we're \"synced\"\n const isSynced = messageQueue.length === 0 &&\n (nextToken === null || nextToken === undefined);\n subscriber.next({\n items,\n isSynced,\n });\n if (Array.isArray(errors)) {\n for (const error of errors) {\n subscriber.error(error);\n }\n }\n }\n // play through the queue\n if (messageQueue.length > 0) {\n ingestMessages(messageQueue);\n }\n // switch the queue to write directly to the items collection\n receiveMessages = (...messages) => {\n ingestMessages(messages);\n return items.length;\n };\n })();\n // when subscriber unsubscribes, tear down internal subs\n return () => {\n // 1. tear down internal subs\n onCreateSub.unsubscribe();\n onUpdateSub.unsubscribe();\n onDeleteSub.unsubscribe();\n // 2. there is no need to explicitly stop paging. instead, we\n // just check `subscriber.closed` above before fetching each page.\n };\n });\n return observeQuery;\n}\n"],"names":[],"mappings":";;;;;;AAAA;AACA;AAGO,SAAS,mBAAmB,CAAC,MAAM,EAAE,KAAK,EAAE;AACnD,IAAI,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC;AAC3B,IAAI,MAAM,YAAY,GAAG,CAAC,GAAG,KAAK,IAAI,UAAU,CAAC,UAAU,IAAI;AAC/D;AACA,QAAQ,MAAM,KAAK,GAAG,EAAE,CAAC;AACzB;AACA;AACA,QAAQ,MAAM,YAAY,GA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M;AACrB;AACA,YAAY,WAAW,CAAC,WAAW,EAAE,CAAC;AACtC,YAAY,WAAW,CAAC,WAAW,EAAE,CAAC;AACtC,YAAY,WAAW,CAAC,WAAW,EAAE,CAAC;AACtC;AACA;AACA,SAAS,CAAC;AACV,KAAK,CAAC,CAAC;AACP,IAAI,OAAO,YAAY,CAAC;AACxB;;;;"}
@@ -1,8 +1,9 @@
1
+ import { map } from 'rxjs';
2
+ import { generateGraphQLDocument, buildGraphQLVariables, authModeParams, initializeModel } from '../APIClient.mjs';
3
+
1
4
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
5
  // SPDX-License-Identifier: Apache-2.0
3
- import { map } from 'rxjs';
4
- import { initializeModel, generateGraphQLDocument, buildGraphQLVariables, authModeParams, } from '../APIClient';
5
- export function subscriptionFactory(client, modelIntrospection, model, operation) {
6
+ function subscriptionFactory(client, modelIntrospection, model, operation) {
6
7
  const { name } = model;
7
8
  const subscription = (args) => {
8
9
  const query = generateGraphQLDocument(modelIntrospection.models, name, operation);
@@ -21,3 +22,6 @@ export function subscriptionFactory(client, modelIntrospection, model, operation
21
22
  };
22
23
  return subscription;
23
24
  }
25
+
26
+ export { subscriptionFactory };
27
+ //# sourceMappingURL=subscription.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subscription.mjs","sources":["../../../../src/internals/operations/subscription.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { map } from 'rxjs';\nimport { initializeModel, generateGraphQLDocument, buildGraphQLVariables, authModeParams, } from '../APIClient';\nexport function subscriptionFactory(client, modelIntrospection, model, operation) {\n const { name } = model;\n const subscription = (args) => {\n const query = generateGraphQLDocument(modelIntrospection.models, name, operation);\n const variables = buildGraphQLVariables(model, operation, args, modelIntrospection);\n const auth = authModeParams(client, args);\n const observable = client.graphql({\n ...auth,\n query,\n variables,\n });\n return observable.pipe(map(value => {\n const [key] = Object.keys(value.data);\n const [initialized] = initializeModel(client, name, [value.data[key]], modelIntrospection, auth.authMode, auth.authToken);\n return initialized;\n }));\n };\n return subscription;\n}\n"],"names":[],"mappings":";;;AAAA;AACA;AAGO,SAAS,mBAAmB,CAAC,MAAM,EAAE,kBAAkB,EAAE,KAAK,EAAE,SAAS,EAAE;AAClF,IAAI,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC;AAC3B,IAAI,MAAM,YAAY,GAAG,CAAC,IAAI,KAAK;AACnC,QAAQ,MAAM,KAAK,GAAG,uBAAuB,CAAC,kBAAkB,CAAC,MAAM,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC;AAC1F,QAAQ,MAAM,SAAS,GAAG,qBAAqB,CAAC,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,kBAAkB,CAAC,CAAC;AAC5F,QAAQ,MAAM,IAAI,GAAG,cAAc,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AAClD,QAAQ,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC;AAC1C,YAAY,GAAG,IAAI;AACnB,YAAY,KAAK;AACjB,YAAY,SAAS;AACrB,SAAS,CAAC,CAAC;AACX,QAAQ,OAAO,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,IAAI;AAC5C,YAAY,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AAClD,YAAY,MAAM,CAAC,WAAW,CAAC,GAAG,eAAe,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,kBAAkB,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;AACtI,YAAY,OAAO,WAAW,CAAC;AAC/B,SAAS,CAAC,CAAC,CAAC;AACZ,KAAK,CAAC;AACN,IAAI,OAAO,YAAY,CAAC;AACxB;;;;"}
@@ -1,8 +1,13 @@
1
+ import '../InternalGraphQLAPI.mjs';
2
+ import { graphql, cancel, isCancelError } from '../v6.mjs';
3
+ import { __amplify, __authMode, __authToken } from '../../types/index.mjs';
4
+ import 'rxjs';
5
+ import '@aws-amplify/core/internals/utils';
6
+ import '../../utils/errors/validation.mjs';
7
+ import { generateModelsProperty } from './generateModelsProperty.mjs';
8
+
1
9
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
10
  // SPDX-License-Identifier: Apache-2.0
3
- import { graphql, cancel, isCancelError } from '../';
4
- import { generateModelsProperty } from './generateModelsProperty';
5
- import { __amplify, __authMode, __authToken, } from '../../types';
6
11
  /**
7
12
  * @private
8
13
  *
@@ -12,7 +17,7 @@ import { __amplify, __authMode, __authToken, } from '../../types';
12
17
  * @param params
13
18
  * @returns
14
19
  */
15
- export function generateClient(params) {
20
+ function generateClient(params) {
16
21
  const client = {
17
22
  [__amplify]: params.amplify,
18
23
  [__authMode]: params.authMode,
@@ -24,3 +29,6 @@ export function generateClient(params) {
24
29
  client.models = generateModelsProperty(client, params);
25
30
  return client;
26
31
  }
32
+
33
+ export { generateClient };
34
+ //# sourceMappingURL=generateClient.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generateClient.mjs","sources":["../../../../src/internals/server/generateClient.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { graphql, cancel, isCancelError } from '../';\nimport { generateModelsProperty } from './generateModelsProperty';\nimport { __amplify, __authMode, __authToken, } from '../../types';\n/**\n * @private\n *\n * Creates a client that can be used to make GraphQL requests, using a provided `AmplifyClassV6`\n * compatible context object for config and auth fetching.\n *\n * @param params\n * @returns\n */\nexport function generateClient(params) {\n const client = {\n [__amplify]: params.amplify,\n [__authMode]: params.authMode,\n [__authToken]: params.authToken,\n graphql,\n cancel,\n isCancelError,\n };\n client.models = generateModelsProperty(client, params);\n return client;\n}\n"],"names":[],"mappings":";;;;;;;;AAAA;AACA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,cAAc,CAAC,MAAM,EAAE;AACvC,IAAI,MAAM,MAAM,GAAG;AACnB,QAAQ,CAAC,SAAS,GAAG,MAAM,CAAC,OAAO;AACnC,QAAQ,CAAC,UAAU,GAAG,MAAM,CAAC,QAAQ;AACrC,QAAQ,CAAC,WAAW,GAAG,MAAM,CAAC,SAAS;AACvC,QAAQ,OAAO;AACf,QAAQ,MAAM;AACd,QAAQ,aAAa;AACrB,KAAK,CAAC;AACN,IAAI,MAAM,CAAC,MAAM,GAAG,sBAAsB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAC3D,IAAI,OAAO,MAAM,CAAC;AAClB;;;;"}
@@ -1,9 +1,10 @@
1
+ import { graphQLOperationsInfo } from '../APIClient.mjs';
2
+ import { listFactory } from '../operations/list.mjs';
3
+ import { getFactory } from '../operations/get.mjs';
4
+
1
5
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
6
  // SPDX-License-Identifier: Apache-2.0
3
- import { graphQLOperationsInfo } from '../APIClient';
4
- import { listFactory } from '../operations/list';
5
- import { getFactory } from '../operations/get';
6
- export function generateModelsProperty(client, params) {
7
+ function generateModelsProperty(client, params) {
7
8
  const models = {};
8
9
  const config = params.config;
9
10
  const useContext = client === null;
@@ -39,3 +40,6 @@ export function generateModelsProperty(client, params) {
39
40
  }
40
41
  return models;
41
42
  }
43
+
44
+ export { generateModelsProperty };
45
+ //# sourceMappingURL=generateModelsProperty.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generateModelsProperty.mjs","sources":["../../../../src/internals/server/generateModelsProperty.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { graphQLOperationsInfo } from '../APIClient';\nimport { listFactory } from '../operations/list';\nimport { getFactory } from '../operations/get';\nexport function generateModelsProperty(client, params) {\n const models = {};\n const config = params.config;\n const useContext = client === null;\n if (!config) {\n // TODO: improve\n throw new Error('generateModelsProperty cannot retrieve Amplify config');\n }\n const modelIntrospection = config.API?.GraphQL?.modelIntrospection;\n if (!modelIntrospection) {\n return {};\n }\n const SSR_UNSUPORTED_OPS = [\n 'ONCREATE',\n 'ONUPDATE',\n 'ONDELETE',\n 'OBSERVE_QUERY',\n ];\n for (const model of Object.values(modelIntrospection.models)) {\n const { name } = model;\n models[name] = {};\n Object.entries(graphQLOperationsInfo).forEach(([key, { operationPrefix }]) => {\n const operation = key;\n // subscriptions are not supported in SSR\n if (SSR_UNSUPORTED_OPS.includes(operation))\n return;\n if (operation === 'LIST') {\n models[name][operationPrefix] = listFactory(client, modelIntrospection, model, useContext);\n }\n else {\n models[name][operationPrefix] = getFactory(client, modelIntrospection, model, operation, useContext);\n }\n });\n }\n return models;\n}\n"],"names":[],"mappings":";;;;AAAA;AACA;AAIO,SAAS,sBAAsB,CAAC,MAAM,EAAE,MAAM,EAAE;AACvD,IAAI,MAAM,MAAM,GAAG,EAAE,CAAC;AACtB,IAAI,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;AACjC,IAAI,MAAM,UAAU,GAAG,MAAM,KAAK,IAAI,CAAC;AACvC,IAAI,IAAI,CAAC,MAAM,EAAE;AACjB;AACA,QAAQ,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;AACjF,KAAK;AACL,IAAI,MAAM,kBAAkB,GAAG,MAAM,CAAC,GAAG,EAAE,OAAO,EAAE,kBAAkB,CAAC;AACvE,IAAI,IAAI,CAAC,kBAAkB,EAAE;AAC7B,QAAQ,OAAO,EAAE,CAAC;AAClB,KAAK;AACL,IAAI,MAAM,kBAAkB,GAAG;AAC/B,QAAQ,UAAU;AAClB,QAAQ,UAAU;AAClB,QAAQ,UAAU;AAClB,QAAQ,eAAe;AACvB,KAAK,CAAC;AACN,IAAI,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,kBAAkB,CAAC,MAAM,CAAC,EAAE;AAClE,QAAQ,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC;AAC/B,QAAQ,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;AAC1B,QAAQ,MAAM,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,EAAE,eAAe,EAAE,CAAC,KAAK;AACtF,YAAY,MAAM,SAAS,GAAG,GAAG,CAAC;AAClC;AACA,YAAY,IAAI,kBAAkB,CAAC,QAAQ,CAAC,SAAS,CAAC;AACtD,gBAAgB,OAAO;AACvB,YAAY,IAAI,SAAS,KAAK,MAAM,EAAE;AACtC,gBAAgB,MAAM,CAAC,IAAI,CAAC,CAAC,eAAe,CAAC,GAAG,WAAW,CAAC,MAAM,EAAE,kBAAkB,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC;AAC3G,aAAa;AACb,iBAAiB;AACjB,gBAAgB,MAAM,CAAC,IAAI,CAAC,CAAC,eAAe,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,kBAAkB,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC;AACrH,aAAa;AACb,SAAS,CAAC,CAAC;AACX,KAAK;AACL,IAAI,OAAO,MAAM,CAAC;AAClB;;;;"}
@@ -0,0 +1,2 @@
1
+ export { generateClient } from './generateClient.mjs';
2
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=types.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,7 +1,8 @@
1
+ import { GraphQLAPI } from '../GraphQLAPI.mjs';
2
+ import { __amplify } from '../types/index.mjs';
3
+
1
4
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
5
  // SPDX-License-Identifier: Apache-2.0
3
- import { GraphQLAPI } from '../GraphQLAPI';
4
- import { __amplify, } from '../types';
5
6
  /**
6
7
  * Invokes graphql operations against a graphql service, providing correct input and
7
8
  * output types if Amplify-generated graphql from a recent version of the CLI/codegen
@@ -86,7 +87,7 @@ import { __amplify, } from '../types';
86
87
  * @param options
87
88
  * @param additionalHeaders
88
89
  */
89
- export function graphql(options, additionalHeaders) {
90
+ function graphql(options, additionalHeaders) {
90
91
  /**
91
92
  * The correctness of these typings depends on correct string branding or overrides.
92
93
  * Neither of these can actually be validated at runtime. Hence, we don't perform
@@ -100,7 +101,7 @@ export function graphql(options, additionalHeaders) {
100
101
  * @param {any} request - request to cancel
101
102
  * @returns - A boolean indicating if the request was cancelled
102
103
  */
103
- export function cancel(promise, message) {
104
+ function cancel(promise, message) {
104
105
  return GraphQLAPI.cancel(promise, message);
105
106
  }
106
107
  /**
@@ -108,6 +109,9 @@ export function cancel(promise, message) {
108
109
  * @param {any} error - Any error
109
110
  * @returns - A boolean indicating if the error was from an api request cancellation
110
111
  */
111
- export function isCancelError(error) {
112
+ function isCancelError(error) {
112
113
  return GraphQLAPI.isCancelError(error);
113
114
  }
115
+
116
+ export { cancel, graphql, isCancelError };
117
+ //# sourceMappingURL=v6.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"v6.mjs","sources":["../../../src/internals/v6.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { GraphQLAPI } from '../GraphQLAPI';\nimport { __amplify, } from '../types';\n/**\n * Invokes graphql operations against a graphql service, providing correct input and\n * output types if Amplify-generated graphql from a recent version of the CLI/codegen\n * are used *or* correct typing is provided via the type argument.\n *\n * Amplify-generated \"branded\" graphql queries will look similar to this:\n *\n * ```ts\n * //\n * // |-- branding\n * // v\n * export const getModel = `...` as GeneratedQuery<\n * \tGetModelQueryVariables,\n * \tGetModelQuery\n * >;\n * ```\n *\n * If this branding is not in your generated graphql, update to a newer version of\n * CLI/codegen and regenerate your graphql using `amplify codegen`.\n *\n * ## Using Amplify-generated graphql\n *\n * ```ts\n * import * as queries from './graphql/queries';\n *\n * //\n * // |-- correctly typed graphql response containing a Widget\n * // v\n * const queryResult = await graphql({\n * \tquery: queries.getWidget,\n * \tvariables: {\n * \t\tid: \"abc\", // <-- type hinted/enforced\n * \t},\n * });\n *\n * //\n * // |-- a correctly typed Widget\n * // v\n * const fetchedWidget = queryResult.data?.getWidget!;\n * ```\n *\n * ## Custom input + result types\n *\n * To provide input types (`variables`) and result types:\n *\n * ```ts\n * type GetById_NameOnly = {\n * \tvariables: {\n * \t\tid: string\n * \t},\n * \tresult: Promise<{\n * \t\tdata: { getWidget: { name: string } }\n * \t}>\n * }\n *\n * //\n * // |-- type is GetById_NameOnly[\"result\"]\n * // v\n * const result = graphql<GetById_NameOnly>({\n * \tquery: \"...\",\n * \tvariables: { id: \"abc\" } // <-- type of GetById_NameOnly[\"variables\"]\n * });\n * ```\n *\n * ## Custom result type only\n *\n * To specify result types only, use a type that is *not* in the `{variables, result}` shape:\n *\n * ```ts\n * type MyResultType = Promise<{\n * \tdata: {\n * \t\tgetWidget: { name: string }\n * \t}\n * }>\n *\n * //\n * // |-- type is MyResultType\n * // v\n * const result = graphql<MyResultType>({query: \"...\"});\n * ```\n *\n * @param options\n * @param additionalHeaders\n */\nexport function graphql(options, additionalHeaders) {\n /**\n * The correctness of these typings depends on correct string branding or overrides.\n * Neither of these can actually be validated at runtime. Hence, we don't perform\n * any validation or type-guarding here.\n */\n const result = GraphQLAPI.graphql(this[__amplify], options, additionalHeaders);\n return result;\n}\n/**\n * Cancels an inflight request. Only applicable for graphql queries and mutations\n * @param {any} request - request to cancel\n * @returns - A boolean indicating if the request was cancelled\n */\nexport function cancel(promise, message) {\n return GraphQLAPI.cancel(promise, message);\n}\n/**\n * Checks to see if an error thrown is from an api request cancellation\n * @param {any} error - Any error\n * @returns - A boolean indicating if the error was from an api request cancellation\n */\nexport function isCancelError(error) {\n return GraphQLAPI.isCancelError(error);\n}\n"],"names":[],"mappings":";;;AAAA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,OAAO,CAAC,OAAO,EAAE,iBAAiB,EAAE;AACpD;AACA;AACA;AACA;AACA;AACA,IAAI,MAAM,MAAM,GAAG,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,iBAAiB,CAAC,CAAC;AACnF,IAAI,OAAO,MAAM,CAAC;AAClB,CAAC;AACD;AACA;AACA;AACA;AACA;AACO,SAAS,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE;AACzC,IAAI,OAAO,UAAU,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AAC/C,CAAC;AACD;AACA;AACA;AACA;AACA;AACO,SAAS,aAAa,CAAC,KAAK,EAAE;AACrC,IAAI,OAAO,UAAU,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;AAC3C;;;;"}
@@ -1,4 +1,4 @@
1
- export var CONTROL_MSG;
1
+ var CONTROL_MSG;
2
2
  (function (CONTROL_MSG) {
3
3
  CONTROL_MSG["CONNECTION_CLOSED"] = "Connection closed";
4
4
  CONTROL_MSG["CONNECTION_FAILED"] = "Connection failed";
@@ -7,7 +7,7 @@ export var CONTROL_MSG;
7
7
  CONTROL_MSG["TIMEOUT_DISCONNECT"] = "Timeout disconnect";
8
8
  })(CONTROL_MSG || (CONTROL_MSG = {}));
9
9
  /** @enum {string} */
10
- export var ConnectionState;
10
+ var ConnectionState;
11
11
  (function (ConnectionState) {
12
12
  /*
13
13
  * The connection is alive and healthy
@@ -42,3 +42,6 @@ export var ConnectionState;
42
42
  */
43
43
  ConnectionState["ConnectedPendingKeepAlive"] = "ConnectedPendingKeepAlive";
44
44
  })(ConnectionState || (ConnectionState = {}));
45
+
46
+ export { CONTROL_MSG, ConnectionState };
47
+ //# sourceMappingURL=PubSub.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PubSub.mjs","sources":["../../../src/types/PubSub.ts"],"sourcesContent":["export var CONTROL_MSG;\n(function (CONTROL_MSG) {\n CONTROL_MSG[\"CONNECTION_CLOSED\"] = \"Connection closed\";\n CONTROL_MSG[\"CONNECTION_FAILED\"] = \"Connection failed\";\n CONTROL_MSG[\"REALTIME_SUBSCRIPTION_INIT_ERROR\"] = \"AppSync Realtime subscription init error\";\n CONTROL_MSG[\"SUBSCRIPTION_ACK\"] = \"Subscription ack\";\n CONTROL_MSG[\"TIMEOUT_DISCONNECT\"] = \"Timeout disconnect\";\n})(CONTROL_MSG || (CONTROL_MSG = {}));\n/** @enum {string} */\nexport var ConnectionState;\n(function (ConnectionState) {\n /*\n * The connection is alive and healthy\n */\n ConnectionState[\"Connected\"] = \"Connected\";\n /*\n * The connection is alive, but the connection is offline\n */\n ConnectionState[\"ConnectedPendingNetwork\"] = \"ConnectedPendingNetwork\";\n /*\n * The connection has been disconnected while in use\n */\n ConnectionState[\"ConnectionDisrupted\"] = \"ConnectionDisrupted\";\n /*\n * The connection has been disconnected and the network is offline\n */\n ConnectionState[\"ConnectionDisruptedPendingNetwork\"] = \"ConnectionDisruptedPendingNetwork\";\n /*\n * The connection is in the process of connecting\n */\n ConnectionState[\"Connecting\"] = \"Connecting\";\n /*\n * The connection is not in use and is being disconnected\n */\n ConnectionState[\"ConnectedPendingDisconnect\"] = \"ConnectedPendingDisconnect\";\n /*\n * The connection is not in use and has been disconnected\n */\n ConnectionState[\"Disconnected\"] = \"Disconnected\";\n /*\n * The connection is alive, but a keep alive message has been missed\n */\n ConnectionState[\"ConnectedPendingKeepAlive\"] = \"ConnectedPendingKeepAlive\";\n})(ConnectionState || (ConnectionState = {}));\n"],"names":[],"mappings":"AAAU,IAAC,YAAY;AACvB,CAAC,UAAU,WAAW,EAAE;AACxB,IAAI,WAAW,CAAC,mBAAmB,CAAC,GAAG,mBAAmB,CAAC;AAC3D,IAAI,WAAW,CAAC,mBAAmB,CAAC,GAAG,mBAAmB,CAAC;AAC3D,IAAI,WAAW,CAAC,kCAAkC,CAAC,GAAG,0CAA0C,CAAC;AACjG,IAAI,WAAW,CAAC,kBAAkB,CAAC,GAAG,kBAAkB,CAAC;AACzD,IAAI,WAAW,CAAC,oBAAoB,CAAC,GAAG,oBAAoB,CAAC;AAC7D,CAAC,EAAE,WAAW,KAAK,WAAW,GAAG,EAAE,CAAC,CAAC,CAAC;AACtC;AACU,IAAC,gBAAgB;AAC3B,CAAC,UAAU,eAAe,EAAE;AAC5B;AACA;AACA;AACA,IAAI,eAAe,CAAC,WAAW,CAAC,GAAG,WAAW,CAAC;AAC/C;AACA;AACA;AACA,IAAI,eAAe,CAAC,yBAAyB,CAAC,GAAG,yBAAyB,CAAC;AAC3E;AACA;AACA;AACA,IAAI,eAAe,CAAC,qBAAqB,CAAC,GAAG,qBAAqB,CAAC;AACnE;AACA;AACA;AACA,IAAI,eAAe,CAAC,mCAAmC,CAAC,GAAG,mCAAmC,CAAC;AAC/F;AACA;AACA;AACA,IAAI,eAAe,CAAC,YAAY,CAAC,GAAG,YAAY,CAAC;AACjD;AACA;AACA;AACA,IAAI,eAAe,CAAC,4BAA4B,CAAC,GAAG,4BAA4B,CAAC;AACjF;AACA;AACA;AACA,IAAI,eAAe,CAAC,cAAc,CAAC,GAAG,cAAc,CAAC;AACrD;AACA;AACA;AACA,IAAI,eAAe,CAAC,2BAA2B,CAAC,GAAG,2BAA2B,CAAC;AAC/E,CAAC,EAAE,eAAe,KAAK,eAAe,GAAG,EAAE,CAAC,CAAC;;;;"}
@@ -1,5 +1,6 @@
1
- export { CONTROL_MSG, ConnectionState } from './PubSub';
2
- export var GraphQLAuthError;
1
+ export { CONTROL_MSG, ConnectionState } from './PubSub.mjs';
2
+
3
+ var GraphQLAuthError;
3
4
  (function (GraphQLAuthError) {
4
5
  GraphQLAuthError["NO_API_KEY"] = "No api-key configured";
5
6
  GraphQLAuthError["NO_CURRENT_USER"] = "No current user";
@@ -7,6 +8,9 @@ export var GraphQLAuthError;
7
8
  GraphQLAuthError["NO_FEDERATED_JWT"] = "No federated jwt";
8
9
  GraphQLAuthError["NO_AUTH_TOKEN"] = "No auth token specified";
9
10
  })(GraphQLAuthError || (GraphQLAuthError = {}));
10
- export const __amplify = Symbol('amplify');
11
- export const __authMode = Symbol('authMode');
12
- export const __authToken = Symbol('authToken');
11
+ const __amplify = Symbol('amplify');
12
+ const __authMode = Symbol('authMode');
13
+ const __authToken = Symbol('authToken');
14
+
15
+ export { GraphQLAuthError, __amplify, __authMode, __authToken };
16
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sources":["../../../src/types/index.ts"],"sourcesContent":["export { CONTROL_MSG, ConnectionState } from './PubSub';\nexport var GraphQLAuthError;\n(function (GraphQLAuthError) {\n GraphQLAuthError[\"NO_API_KEY\"] = \"No api-key configured\";\n GraphQLAuthError[\"NO_CURRENT_USER\"] = \"No current user\";\n GraphQLAuthError[\"NO_CREDENTIALS\"] = \"No credentials\";\n GraphQLAuthError[\"NO_FEDERATED_JWT\"] = \"No federated jwt\";\n GraphQLAuthError[\"NO_AUTH_TOKEN\"] = \"No auth token specified\";\n})(GraphQLAuthError || (GraphQLAuthError = {}));\nexport const __amplify = Symbol('amplify');\nexport const __authMode = Symbol('authMode');\nexport const __authToken = Symbol('authToken');\n"],"names":[],"mappings":";;AACU,IAAC,iBAAiB;AAC5B,CAAC,UAAU,gBAAgB,EAAE;AAC7B,IAAI,gBAAgB,CAAC,YAAY,CAAC,GAAG,uBAAuB,CAAC;AAC7D,IAAI,gBAAgB,CAAC,iBAAiB,CAAC,GAAG,iBAAiB,CAAC;AAC5D,IAAI,gBAAgB,CAAC,gBAAgB,CAAC,GAAG,gBAAgB,CAAC;AAC1D,IAAI,gBAAgB,CAAC,kBAAkB,CAAC,GAAG,kBAAkB,CAAC;AAC9D,IAAI,gBAAgB,CAAC,eAAe,CAAC,GAAG,yBAAyB,CAAC;AAClE,CAAC,EAAE,gBAAgB,KAAK,gBAAgB,GAAG,EAAE,CAAC,CAAC,CAAC;AACpC,MAAC,SAAS,GAAG,MAAM,CAAC,SAAS,EAAE;AAC/B,MAAC,UAAU,GAAG,MAAM,CAAC,UAAU,EAAE;AACjC,MAAC,WAAW,GAAG,MAAM,CAAC,WAAW;;;;"}
@@ -1,9 +1,10 @@
1
+ import { Observable, map, filter } from 'rxjs';
2
+ import { ConnectionState } from '../types/PubSub.mjs';
3
+ import { ReachabilityMonitor } from './ReachabilityMonitor/index.mjs';
4
+
1
5
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
6
  // SPDX-License-Identifier: Apache-2.0
3
- import { Observable, map, filter } from 'rxjs';
4
- import { ConnectionState } from '../types/PubSub';
5
- import { ReachabilityMonitor } from './ReachabilityMonitor';
6
- export const CONNECTION_CHANGE = {
7
+ const CONNECTION_CHANGE = {
7
8
  KEEP_ALIVE_MISSED: { keepAliveState: 'unhealthy' },
8
9
  KEEP_ALIVE: { keepAliveState: 'healthy' },
9
10
  CONNECTION_ESTABLISHED: { connectionState: 'connected' },
@@ -20,7 +21,7 @@ export const CONNECTION_CHANGE = {
20
21
  ONLINE: { networkState: 'connected' },
21
22
  OFFLINE: { networkState: 'disconnected' },
22
23
  };
23
- export class ConnectionStateMonitor {
24
+ class ConnectionStateMonitor {
24
25
  constructor() {
25
26
  this._networkMonitoringSubscription = undefined;
26
27
  this._linkedConnectionState = {
@@ -126,3 +127,6 @@ export class ConnectionStateMonitor {
126
127
  return ConnectionState.Connected;
127
128
  }
128
129
  }
130
+
131
+ export { CONNECTION_CHANGE, ConnectionStateMonitor };
132
+ //# sourceMappingURL=ConnectionStateMonitor.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConnectionStateMonitor.mjs","sources":["../../../src/utils/ConnectionStateMonitor.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Observable, map, filter } from 'rxjs';\nimport { ConnectionState } from '../types/PubSub';\nimport { ReachabilityMonitor } from './ReachabilityMonitor';\nexport const CONNECTION_CHANGE = {\n KEEP_ALIVE_MISSED: { keepAliveState: 'unhealthy' },\n KEEP_ALIVE: { keepAliveState: 'healthy' },\n CONNECTION_ESTABLISHED: { connectionState: 'connected' },\n CONNECTION_FAILED: {\n intendedConnectionState: 'disconnected',\n connectionState: 'disconnected',\n },\n CLOSING_CONNECTION: { intendedConnectionState: 'disconnected' },\n OPENING_CONNECTION: {\n intendedConnectionState: 'connected',\n connectionState: 'connecting',\n },\n CLOSED: { connectionState: 'disconnected' },\n ONLINE: { networkState: 'connected' },\n OFFLINE: { networkState: 'disconnected' },\n};\nexport class ConnectionStateMonitor {\n constructor() {\n this._networkMonitoringSubscription = undefined;\n this._linkedConnectionState = {\n networkState: 'connected',\n connectionState: 'disconnected',\n intendedConnectionState: 'disconnected',\n keepAliveState: 'healthy',\n };\n // Attempt to update the state with the current actual network state\n this._initialNetworkStateSubscription = ReachabilityMonitor().subscribe(({ online }) => {\n this.record(online ? CONNECTION_CHANGE.ONLINE : CONNECTION_CHANGE.OFFLINE);\n this._initialNetworkStateSubscription?.unsubscribe();\n });\n this._linkedConnectionStateObservable =\n new Observable(connectionStateObserver => {\n connectionStateObserver.next(this._linkedConnectionState);\n this._linkedConnectionStateObserver = connectionStateObserver;\n });\n }\n /**\n * Turn network state monitoring on if it isn't on already\n */\n enableNetworkMonitoring() {\n // If no initial network state was discovered, stop trying\n this._initialNetworkStateSubscription?.unsubscribe();\n // Maintain the network state based on the reachability monitor\n if (this._networkMonitoringSubscription === undefined) {\n this._networkMonitoringSubscription = ReachabilityMonitor().subscribe(({ online }) => {\n this.record(online ? CONNECTION_CHANGE.ONLINE : CONNECTION_CHANGE.OFFLINE);\n });\n }\n }\n /**\n * Turn network state monitoring off if it isn't off already\n */\n disableNetworkMonitoring() {\n this._networkMonitoringSubscription?.unsubscribe();\n this._networkMonitoringSubscription = undefined;\n }\n /**\n * Get the observable that allows us to monitor the connection state\n *\n * @returns {Observable<ConnectionState>} - The observable that emits ConnectionState updates\n */\n get connectionStateObservable() {\n let previous;\n // The linked state aggregates state changes to any of the network, connection,\n // intendedConnection and keepAliveHealth. Some states will change these independent\n // states without changing the overall connection state.\n // After translating from linked states to ConnectionState, then remove any duplicates\n return this._linkedConnectionStateObservable\n .pipe(map(value => {\n return this.connectionStatesTranslator(value);\n }))\n .pipe(filter(current => {\n const toInclude = current !== previous;\n previous = current;\n return toInclude;\n }));\n }\n /*\n * Updates local connection state and emits the full state to the observer.\n */\n record(statusUpdates) {\n // Maintain the network monitor\n if (statusUpdates.intendedConnectionState === 'connected') {\n this.enableNetworkMonitoring();\n }\n else if (statusUpdates.intendedConnectionState === 'disconnected') {\n this.disableNetworkMonitoring();\n }\n // Maintain the socket state\n const newSocketStatus = {\n ...this._linkedConnectionState,\n ...statusUpdates,\n };\n this._linkedConnectionState = { ...newSocketStatus };\n this._linkedConnectionStateObserver?.next(this._linkedConnectionState);\n }\n /*\n * Translate the ConnectionState structure into a specific ConnectionState string literal union\n */\n connectionStatesTranslator({ connectionState, networkState, intendedConnectionState, keepAliveState, }) {\n if (connectionState === 'connected' && networkState === 'disconnected')\n return ConnectionState.ConnectedPendingNetwork;\n if (connectionState === 'connected' &&\n intendedConnectionState === 'disconnected')\n return ConnectionState.ConnectedPendingDisconnect;\n if (connectionState === 'disconnected' &&\n intendedConnectionState === 'connected' &&\n networkState === 'disconnected')\n return ConnectionState.ConnectionDisruptedPendingNetwork;\n if (connectionState === 'disconnected' &&\n intendedConnectionState === 'connected')\n return ConnectionState.ConnectionDisrupted;\n if (connectionState === 'connected' && keepAliveState === 'unhealthy')\n return ConnectionState.ConnectedPendingKeepAlive;\n // All remaining states directly correspond to the connection state\n if (connectionState === 'connecting')\n return ConnectionState.Connecting;\n if (connectionState === 'disconnected')\n return ConnectionState.Disconnected;\n return ConnectionState.Connected;\n }\n}\n"],"names":[],"mappings":";;;;AAAA;AACA;AAIY,MAAC,iBAAiB,GAAG;AACjC,IAAI,iBAAiB,EAAE,EAAE,cAAc,EAAE,WAAW,EAAE;AACtD,IAAI,UAAU,EAAE,EAAE,cAAc,EAAE,SAAS,EAAE;AAC7C,IAAI,sBAAsB,EAAE,EAAE,eAAe,EAAE,WAAW,EAAE;AAC5D,IAAI,iBAAiB,EAAE;AACvB,QAAQ,uBAAuB,EAAE,cAAc;AAC/C,QAAQ,eAAe,EAAE,cAAc;AACvC,KAAK;AACL,IAAI,kBAAkB,EAAE,EAAE,uBAAuB,EAAE,cAAc,EAAE;AACnE,IAAI,kBAAkB,EAAE;AACxB,QAAQ,uBAAuB,EAAE,WAAW;AAC5C,QAAQ,eAAe,EAAE,YAAY;AACrC,KAAK;AACL,IAAI,MAAM,EAAE,EAAE,eAAe,EAAE,cAAc,EAAE;AAC/C,IAAI,MAAM,EAAE,EAAE,YAAY,EAAE,WAAW,EAAE;AACzC,IAAI,OAAO,EAAE,EAAE,YAAY,EAAE,cAAc,EAAE;AAC7C,EAAE;AACK,MAAM,sBAAsB,CAAC;AACpC,IAAI,WAAW,GAAG;AAClB,QAAQ,IAAI,CAAC,8BAA8B,GAAG,SAAS,CAAC;AACxD,QAAQ,IAAI,CAAC,sBAAsB,GAAG;AACtC,YAAY,YAAY,EAAE,WAAW;AACrC,YAAY,eAAe,EAAE,cAAc;AAC3C,YAAY,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AuB,CAAC;AAC3D,QAAQ,IAAI,eAAe,KAAK,WAAW;AAC3C,YAAY,uBAAuB,KAAK,cAAc;AACtD,YAAY,OAAO,eAAe,CAAC,0BAA0B,CAAC;AAC9D,QAAQ,IAAI,eAAe,KAAK,cAAc;AAC9C,YAAY,uBAAuB,KAAK,WAAW;AACnD,YAAY,YAAY,KAAK,cAAc;AAC3C,YAAY,OAAO,eAAe,CAAC,iCAAiC,CAAC;AACrE,QAAQ,IAAI,eAAe,KAAK,cAAc;AAC9C,YAAY,uBAAuB,KAAK,WAAW;AACnD,YAAY,OAAO,eAAe,CAAC,mBAAmB,CAAC;AACvD,QAAQ,IAAI,eAAe,KAAK,WAAW,IAAI,cAAc,KAAK,WAAW;AAC7E,YAAY,OAAO,eAAe,CAAC,yBAAyB,CAAC;AAC7D;AACA,QAAQ,IAAI,eAAe,KAAK,YAAY;AAC5C,YAAY,OAAO,eAAe,CAAC,UAAU,CAAC;AAC9C,QAAQ,IAAI,eAAe,KAAK,cAAc;AAC9C,YAAY,OAAO,eAAe,CAAC,YAAY,CAAC;AAChD,QAAQ,OAAO,eAAe,CAAC,SAAS,CAAC;AACzC,KAAK;AACL;;;;"}
@@ -0,0 +1 @@
1
+ export declare const ReachabilityMonitor: () => import("rxjs").Observable<import("@aws-amplify/core/dist/esm/Reachability/types").NetworkStatus>;
@@ -1,4 +1,8 @@
1
+ import { Reachability } from '@aws-amplify/core/internals/utils';
2
+
1
3
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
4
  // SPDX-License-Identifier: Apache-2.0
3
- import { Reachability } from '@aws-amplify/core/internals/utils';
4
- export const ReachabilityMonitor = () => new Reachability().networkMonitor();
5
+ const ReachabilityMonitor = () => new Reachability().networkMonitor();
6
+
7
+ export { ReachabilityMonitor };
8
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sources":["../../../../src/utils/ReachabilityMonitor/index.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Reachability } from '@aws-amplify/core/internals/utils';\nexport const ReachabilityMonitor = () => new Reachability().networkMonitor();\n"],"names":[],"mappings":";;AAAA;AACA;AAEY,MAAC,mBAAmB,GAAG,MAAM,IAAI,YAAY,EAAE,CAAC,cAAc;;;;"}
@@ -0,0 +1 @@
1
+ export declare const ReachabilityMonitor: () => import("rxjs").Observable<import("@aws-amplify/core/dist/esm/Reachability/types").NetworkStatus>;
@@ -0,0 +1,9 @@
1
+ import { Reachability } from '@aws-amplify/core/internals/utils';
2
+ import NetInfo from '@react-native-community/netinfo';
3
+
4
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
5
+ // SPDX-License-Identifier: Apache-2.0
6
+ const ReachabilityMonitor = () => new Reachability().networkMonitor(NetInfo);
7
+
8
+ export { ReachabilityMonitor };
9
+ //# sourceMappingURL=index.native.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.native.mjs","sources":["../../../../src/utils/ReachabilityMonitor/index.native.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Reachability } from '@aws-amplify/core/internals/utils';\nimport { default as NetInfo } from '@react-native-community/netinfo';\nexport const ReachabilityMonitor = () => new Reachability().networkMonitor(NetInfo);\n"],"names":[],"mappings":";;;AAAA;AACA;AAGY,MAAC,mBAAmB,GAAG,MAAM,IAAI,YAAY,EAAE,CAAC,cAAc,CAAC,OAAO;;;;"}
@@ -1,5 +1,6 @@
1
- import { RECONNECT_DELAY, RECONNECT_INTERVAL } from '../Providers/constants';
2
- export var ReconnectEvent;
1
+ import { RECONNECT_INTERVAL, RECONNECT_DELAY } from '../Providers/constants.mjs';
2
+
3
+ var ReconnectEvent;
3
4
  (function (ReconnectEvent) {
4
5
  ReconnectEvent["START_RECONNECT"] = "START_RECONNECT";
5
6
  ReconnectEvent["HALT_RECONNECT"] = "HALT_RECONNECT";
@@ -10,7 +11,7 @@ export var ReconnectEvent;
10
11
  * Attempting to reconnect only once creates unrecoverable states when the network state isn't
11
12
  * supported by the browser, so this keeps retrying every minute until halted.
12
13
  */
13
- export class ReconnectionMonitor {
14
+ class ReconnectionMonitor {
14
15
  constructor() {
15
16
  this.reconnectObservers = [];
16
17
  }
@@ -63,3 +64,6 @@ export class ReconnectionMonitor {
63
64
  });
64
65
  }
65
66
  }
67
+
68
+ export { ReconnectEvent, ReconnectionMonitor };
69
+ //# sourceMappingURL=ReconnectionMonitor.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ReconnectionMonitor.mjs","sources":["../../../src/utils/ReconnectionMonitor.ts"],"sourcesContent":["import { RECONNECT_DELAY, RECONNECT_INTERVAL } from '../Providers/constants';\nexport var ReconnectEvent;\n(function (ReconnectEvent) {\n ReconnectEvent[\"START_RECONNECT\"] = \"START_RECONNECT\";\n ReconnectEvent[\"HALT_RECONNECT\"] = \"HALT_RECONNECT\";\n})(ReconnectEvent || (ReconnectEvent = {}));\n/**\n * Captures the reconnect event logic used to determine when to reconnect to PubSub providers.\n * Reconnnect attempts are delayed by 5 seconds to let the interface settle.\n * Attempting to reconnect only once creates unrecoverable states when the network state isn't\n * supported by the browser, so this keeps retrying every minute until halted.\n */\nexport class ReconnectionMonitor {\n constructor() {\n this.reconnectObservers = [];\n }\n /**\n * Add reconnect observer to the list of observers to alert on reconnect\n */\n addObserver(reconnectObserver) {\n this.reconnectObservers.push(reconnectObserver);\n }\n /**\n * Given a reconnect event, start the appropriate behavior\n */\n record(event) {\n if (event === ReconnectEvent.START_RECONNECT) {\n // If the reconnection hasn't been started\n if (this.reconnectSetTimeoutId === undefined &&\n this.reconnectIntervalId === undefined) {\n this.reconnectSetTimeoutId = setTimeout(() => {\n // Reconnect now\n this._triggerReconnect();\n // Retry reconnect every periodically until it works\n this.reconnectIntervalId = setInterval(() => {\n this._triggerReconnect();\n }, RECONNECT_INTERVAL);\n }, RECONNECT_DELAY);\n }\n }\n if (event === ReconnectEvent.HALT_RECONNECT) {\n if (this.reconnectIntervalId) {\n clearInterval(this.reconnectIntervalId);\n this.reconnectIntervalId = undefined;\n }\n if (this.reconnectSetTimeoutId) {\n clearTimeout(this.reconnectSetTimeoutId);\n this.reconnectSetTimeoutId = undefined;\n }\n }\n }\n /**\n * Complete all reconnect observers\n */\n close() {\n this.reconnectObservers.forEach(reconnectObserver => {\n reconnectObserver.complete?.();\n });\n }\n _triggerReconnect() {\n this.reconnectObservers.forEach(reconnectObserver => {\n reconnectObserver.next?.();\n });\n }\n}\n"],"names":[],"mappings":";;AACU,IAAC,eAAe;AAC1B,CAAC,UAAU,cAAc,EAAE;AAC3B,IAAI,cAAc,CAAC,iBAAiB,CAAC,GAAG,iBAAiB,CAAC;AAC1D,IAAI,cAAc,CAAC,gBAAgB,CAAC,GAAG,gBAAgB,CAAC;AACxD,CAAC,EAAE,cAAc,KAAK,cAAc,GAAG,EAAE,CAAC,CAAC,CAAC;AAC5C;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,mBAAmB,CAAC;AACjC,IAAI,WAAW,GAAG;AAClB,QAAQ,IAAI,CAAC,kBAAkB,GAAG,EAAE,CAAC;AACrC,KAAK;AACL;AACA;AACA;AACA,IAAI,WAAW,CAAC,iBAAiB,EAAE;AACnC,QAAQ,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;AACxD,KAAK;AACL;AACA;AACA;AACA,IAAI,MAAM,CAAC,KAAK,EAAE;AAClB,QAAQ,IAAI,KAAK,KAAK,cAAc,CAAC,eAAe,EAAE;AACtD;AACA,YAAY,IAAI,IAAI,CAAC,qBAAqB,KAAK,SAAS;AACxD,gBAAgB,IAAI,CAAC,mBAAmB,KAAK,SAAS,EAAE;AACxD,gBAAgB,IAAI,CAAC,qBAAqB,GAAG,UAAU,CAAC,MAAM;AAC9D;AACA,oBAAoB,IAAI,CAAC,iBAAiB,EAAE,CAAC;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