@aws-amplify/api-graphql 4.4.1-events.619318.0 → 4.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/Providers/AWSAppSyncRealTimeProvider/index.js +732 -35
- package/dist/cjs/Providers/AWSAppSyncRealTimeProvider/index.js.map +1 -1
- package/dist/cjs/Providers/constants.js +2 -32
- package/dist/cjs/Providers/constants.js.map +1 -1
- package/dist/cjs/index.js +1 -4
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/internals/InternalGraphQLAPI.js +67 -8
- package/dist/cjs/internals/InternalGraphQLAPI.js.map +1 -1
- package/dist/cjs/utils/ReconnectionMonitor.js +1 -1
- package/dist/cjs/utils/ReconnectionMonitor.js.map +1 -1
- package/dist/cjs/utils/resolveConfig.js +0 -19
- package/dist/cjs/utils/resolveConfig.js.map +1 -1
- package/dist/esm/Providers/AWSAppSyncRealTimeProvider/index.d.ts +71 -24
- package/dist/esm/Providers/AWSAppSyncRealTimeProvider/index.mjs +732 -35
- package/dist/esm/Providers/AWSAppSyncRealTimeProvider/index.mjs.map +1 -1
- package/dist/esm/Providers/constants.d.ts +3 -33
- package/dist/esm/Providers/constants.mjs +2 -32
- package/dist/esm/Providers/constants.mjs.map +1 -1
- package/dist/esm/index.d.ts +0 -3
- package/dist/esm/index.mjs +0 -2
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/internals/InternalGraphQLAPI.d.ts +1 -0
- package/dist/esm/internals/InternalGraphQLAPI.mjs +68 -9
- package/dist/esm/internals/InternalGraphQLAPI.mjs.map +1 -1
- package/dist/esm/utils/ConnectionStateMonitor.d.ts +1 -29
- package/dist/esm/utils/ReconnectionMonitor.d.ts +1 -1
- package/dist/esm/utils/ReconnectionMonitor.mjs +1 -1
- package/dist/esm/utils/ReconnectionMonitor.mjs.map +1 -1
- package/dist/esm/utils/resolveConfig.mjs +0 -19
- package/dist/esm/utils/resolveConfig.mjs.map +1 -1
- package/package.json +4 -4
- package/src/Providers/AWSAppSyncRealTimeProvider/index.ts +1051 -58
- package/src/Providers/constants.ts +2 -32
- package/src/index.ts +0 -5
- package/src/internals/InternalGraphQLAPI.ts +102 -15
- package/src/utils/ConnectionStateMonitor.ts +13 -2
- package/src/utils/ReconnectionMonitor.ts +1 -1
- package/src/utils/resolveConfig.ts +0 -23
- package/dist/cjs/Providers/AWSAppSyncEventsProvider/index.js +0 -94
- package/dist/cjs/Providers/AWSAppSyncEventsProvider/index.js.map +0 -1
- package/dist/cjs/Providers/AWSWebSocketProvider/appsyncUrl.js +0 -112
- package/dist/cjs/Providers/AWSWebSocketProvider/appsyncUrl.js.map +0 -1
- package/dist/cjs/Providers/AWSWebSocketProvider/authHeaders.js +0 -99
- package/dist/cjs/Providers/AWSWebSocketProvider/authHeaders.js.map +0 -1
- package/dist/cjs/Providers/AWSWebSocketProvider/index.js +0 -623
- package/dist/cjs/Providers/AWSWebSocketProvider/index.js.map +0 -1
- package/dist/cjs/internals/events/appsyncRequest.js +0 -97
- package/dist/cjs/internals/events/appsyncRequest.js.map +0 -1
- package/dist/cjs/internals/events/index.js +0 -73
- package/dist/cjs/internals/events/index.js.map +0 -1
- package/dist/cjs/internals/events/types.js +0 -6
- package/dist/cjs/internals/events/types.js.map +0 -1
- package/dist/cjs/internals/events/utils.js +0 -57
- package/dist/cjs/internals/events/utils.js.map +0 -1
- package/dist/cjs/internals/graphqlAuth.js +0 -64
- package/dist/cjs/internals/graphqlAuth.js.map +0 -1
- package/dist/cjs/internals/graphqlRequest.js +0 -20
- package/dist/cjs/internals/graphqlRequest.js.map +0 -1
- package/dist/esm/Providers/AWSAppSyncEventsProvider/index.d.ts +0 -42
- package/dist/esm/Providers/AWSAppSyncEventsProvider/index.mjs +0 -93
- package/dist/esm/Providers/AWSAppSyncEventsProvider/index.mjs.map +0 -1
- package/dist/esm/Providers/AWSWebSocketProvider/appsyncUrl.d.ts +0 -21
- package/dist/esm/Providers/AWSWebSocketProvider/appsyncUrl.mjs +0 -106
- package/dist/esm/Providers/AWSWebSocketProvider/appsyncUrl.mjs.map +0 -1
- package/dist/esm/Providers/AWSWebSocketProvider/authHeaders.d.ts +0 -8
- package/dist/esm/Providers/AWSWebSocketProvider/authHeaders.mjs +0 -97
- package/dist/esm/Providers/AWSWebSocketProvider/authHeaders.mjs.map +0 -1
- package/dist/esm/Providers/AWSWebSocketProvider/index.d.ts +0 -83
- package/dist/esm/Providers/AWSWebSocketProvider/index.mjs +0 -621
- package/dist/esm/Providers/AWSWebSocketProvider/index.mjs.map +0 -1
- package/dist/esm/internals/events/appsyncRequest.d.ts +0 -14
- package/dist/esm/internals/events/appsyncRequest.mjs +0 -96
- package/dist/esm/internals/events/appsyncRequest.mjs.map +0 -1
- package/dist/esm/internals/events/index.d.ts +0 -17
- package/dist/esm/internals/events/index.mjs +0 -69
- package/dist/esm/internals/events/index.mjs.map +0 -1
- package/dist/esm/internals/events/types.d.ts +0 -23
- package/dist/esm/internals/events/types.mjs +0 -2
- package/dist/esm/internals/events/types.mjs.map +0 -1
- package/dist/esm/internals/events/utils.d.ts +0 -16
- package/dist/esm/internals/events/utils.mjs +0 -53
- package/dist/esm/internals/events/utils.mjs.map +0 -1
- package/dist/esm/internals/graphqlAuth.d.ts +0 -3
- package/dist/esm/internals/graphqlAuth.mjs +0 -64
- package/dist/esm/internals/graphqlAuth.mjs.map +0 -1
- package/dist/esm/internals/graphqlRequest.d.ts +0 -3
- package/dist/esm/internals/graphqlRequest.mjs +0 -18
- package/dist/esm/internals/graphqlRequest.mjs.map +0 -1
- package/src/Providers/AWSAppSyncEventsProvider/index.ts +0 -187
- package/src/Providers/AWSWebSocketProvider/appsyncUrl.ts +0 -151
- package/src/Providers/AWSWebSocketProvider/authHeaders.ts +0 -146
- package/src/Providers/AWSWebSocketProvider/index.ts +0 -925
- package/src/internals/events/appsyncRequest.ts +0 -169
- package/src/internals/events/index.ts +0 -138
- package/src/internals/events/types.ts +0 -35
- package/src/internals/events/utils.ts +0 -77
- package/src/internals/graphqlAuth.ts +0 -87
- package/src/internals/graphqlRequest.ts +0 -30
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../../../src/Providers/AWSWebSocketProvider/index.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Observable } from 'rxjs';\nimport { GraphQLError } from 'graphql';\nimport { ConsoleLogger, Hub } from '@aws-amplify/core';\nimport { NonRetryableError, amplifyUuid, base64Encoder, isNonRetryableError, jitteredExponentialRetry, } from '@aws-amplify/core/internals/utils';\nimport { CONTROL_MSG, ConnectionState, } from '../../types/PubSub';\nimport { AMPLIFY_SYMBOL, CONNECTION_INIT_TIMEOUT, CONNECTION_STATE_CHANGE, DEFAULT_KEEP_ALIVE_ALERT_TIMEOUT, DEFAULT_KEEP_ALIVE_TIMEOUT, MAX_DELAY_MS, MESSAGE_TYPES, NON_RETRYABLE_CODES, SOCKET_STATUS, START_ACK_TIMEOUT, SUBSCRIPTION_STATUS, } from '../constants';\nimport { CONNECTION_CHANGE, ConnectionStateMonitor, } from '../../utils/ConnectionStateMonitor';\nimport { ReconnectEvent, ReconnectionMonitor, } from '../../utils/ReconnectionMonitor';\nimport { additionalHeadersFromOptions, queryParamsFromCustomHeaders, realtimeUrlWithQueryString, } from './appsyncUrl';\nimport { awsRealTimeHeaderBasedAuth } from './authHeaders';\nconst dispatchApiEvent = (payload) => {\n Hub.dispatch('api', payload, 'PubSub', AMPLIFY_SYMBOL);\n};\nexport class AWSWebSocketProvider {\n constructor(providerName) {\n this.subscriptionObserverMap = new Map();\n this.socketStatus = SOCKET_STATUS.CLOSED;\n this.keepAliveTimeout = DEFAULT_KEEP_ALIVE_TIMEOUT;\n this.promiseArray = [];\n this.connectionStateMonitor = new ConnectionStateMonitor();\n this.reconnectionMonitor = new ReconnectionMonitor();\n /**\n * Open WebSocket connection & perform handshake\n * Ref: https://docs.aws.amazon.com/appsync/latest/devguide/real-time-websocket-client.html#appsynclong-real-time-websocket-client-implementation-guide-for-graphql-subscriptions\n *\n * @param subprotocol -\n */\n this._establishConnection = async (awsRealTimeUrl, subprotocol) => {\n this.logger.debug(`Establishing WebSocket connection to ${awsRealTimeUrl}`);\n try {\n await this._openConnection(awsRealTimeUrl, subprotocol);\n await this._initiateHandshake();\n }\n catch (err) {\n const { errorType, errorCode } = err;\n if (NON_RETRYABLE_CODES.includes(errorCode)) {\n throw new NonRetryableError(errorType);\n }\n else if (errorType) {\n throw new Error(errorType);\n }\n else {\n throw err;\n }\n }\n };\n this.logger = new ConsoleLogger(providerName);\n this.connectionStateMonitorSubscription =\n this._startConnectionStateMonitoring();\n }\n /**\n * Mark the socket closed and release all active listeners\n */\n close() {\n // Mark the socket closed both in status and the connection monitor\n this.socketStatus = SOCKET_STATUS.CLOSED;\n this.connectionStateMonitor.record(CONNECTION_CHANGE.CONNECTION_FAILED);\n // Turn off the subscription monitor Hub publishing\n this.connectionStateMonitorSubscription.unsubscribe();\n // Complete all reconnect observers\n this.reconnectionMonitor.close();\n }\n subscribe(options, customUserAgentDetails) {\n return new Observable(observer => {\n if (!options?.appSyncGraphqlEndpoint) {\n observer.error({\n errors: [\n {\n ...new GraphQLError(`Subscribe only available for AWS AppSync endpoint`),\n },\n ],\n });\n observer.complete();\n return;\n }\n let subscriptionStartInProgress = false;\n const subscriptionId = amplifyUuid();\n const startSubscription = () => {\n if (!subscriptionStartInProgress) {\n subscriptionStartInProgress = true;\n this._startSubscriptionWithAWSAppSyncRealTime({\n options,\n observer,\n subscriptionId,\n customUserAgentDetails,\n })\n .catch(err => {\n this.logger.debug(`${CONTROL_MSG.REALTIME_SUBSCRIPTION_INIT_ERROR}: ${err}`);\n this.connectionStateMonitor.record(CONNECTION_CHANGE.CLOSED);\n })\n .finally(() => {\n subscriptionStartInProgress = false;\n });\n }\n };\n // Add an observable to the reconnection list to manage reconnection for this subscription\n const reconnectSubscription = new Observable(reconnectSubscriptionObserver => {\n this.reconnectionMonitor.addObserver(reconnectSubscriptionObserver);\n }).subscribe(() => {\n startSubscription();\n });\n startSubscription();\n return async () => {\n await this._cleanupSubscription(subscriptionId, reconnectSubscription);\n };\n });\n }\n async connect(options) {\n if (this.socketStatus === SOCKET_STATUS.READY) {\n return;\n }\n await this._connectWebSocket(options);\n }\n async publish(options, customUserAgentDetails) {\n if (this.socketStatus !== SOCKET_STATUS.READY) {\n throw new Error('Subscription has not been initialized');\n }\n return this._publishMessage(options, customUserAgentDetails);\n }\n async _connectWebSocket(options) {\n const { apiKey, appSyncGraphqlEndpoint, authenticationType, region } = options;\n const { additionalCustomHeaders } = await additionalHeadersFromOptions(options);\n this.connectionStateMonitor.record(CONNECTION_CHANGE.OPENING_CONNECTION);\n await this._initializeWebSocketConnection({\n apiKey,\n appSyncGraphqlEndpoint,\n authenticationType,\n region,\n additionalCustomHeaders,\n });\n }\n async _publishMessage(options, customUserAgentDetails) {\n const subscriptionId = amplifyUuid();\n const { additionalCustomHeaders, libraryConfigHeaders } = await additionalHeadersFromOptions(options);\n const serializedSubscriptionMessage = await this._prepareSubscriptionPayload({\n options,\n subscriptionId,\n customUserAgentDetails,\n additionalCustomHeaders,\n libraryConfigHeaders,\n publish: true,\n });\n return new Promise((resolve, reject) => {\n if (this.awsRealTimeSocket) {\n const publishListener = (event) => {\n const data = JSON.parse(event.data);\n if (data.id === subscriptionId && data.type === 'publish_success') {\n this.awsRealTimeSocket &&\n this.awsRealTimeSocket.removeEventListener('message', publishListener);\n resolve();\n }\n if (data.erroredEvents && data.erroredEvents.length > 0) {\n // TODO: handle errors\n }\n };\n this.awsRealTimeSocket.addEventListener('message', publishListener);\n this.awsRealTimeSocket.addEventListener('close', () => {\n reject(new Error('WebSocket is closed'));\n });\n //\n // this.awsRealTimeSocket.addEventListener('error', publishListener);\n this.awsRealTimeSocket.send(serializedSubscriptionMessage);\n }\n });\n }\n async _cleanupSubscription(subscriptionId, reconnectSubscription) {\n // Cleanup reconnection subscription\n reconnectSubscription?.unsubscribe();\n // Cleanup after unsubscribing or observer.complete was called after _startSubscriptionWithAWSAppSyncRealTime\n try {\n // Waiting that subscription has been connected before trying to unsubscribe\n await this._waitForSubscriptionToBeConnected(subscriptionId);\n const { subscriptionState } = this.subscriptionObserverMap.get(subscriptionId) || {};\n if (!subscriptionState) {\n // subscription already unsubscribed\n return;\n }\n if (subscriptionState === SUBSCRIPTION_STATUS.CONNECTED) {\n this._sendUnsubscriptionMessage(subscriptionId);\n }\n else {\n throw new Error('Subscription never connected');\n }\n }\n catch (err) {\n this.logger.debug(`Error while unsubscribing ${err}`);\n }\n finally {\n this._removeSubscriptionObserver(subscriptionId);\n }\n }\n // Monitor the connection state and pass changes along to Hub\n _startConnectionStateMonitoring() {\n return this.connectionStateMonitor.connectionStateObservable.subscribe(connectionState => {\n dispatchApiEvent({\n event: CONNECTION_STATE_CHANGE,\n data: {\n provider: this,\n connectionState,\n },\n message: `Connection state is ${connectionState}`,\n });\n this.connectionState = connectionState;\n // Trigger START_RECONNECT when the connection is disrupted\n if (connectionState === ConnectionState.ConnectionDisrupted) {\n this.reconnectionMonitor.record(ReconnectEvent.START_RECONNECT);\n }\n // Trigger HALT_RECONNECT to halt reconnection attempts when the state is anything other than\n // ConnectionDisrupted or Connecting\n if ([\n ConnectionState.Connected,\n ConnectionState.ConnectedPendingDisconnect,\n ConnectionState.ConnectedPendingKeepAlive,\n ConnectionState.ConnectedPendingNetwork,\n ConnectionState.ConnectionDisruptedPendingNetwork,\n ConnectionState.Disconnected,\n ].includes(connectionState)) {\n this.reconnectionMonitor.record(ReconnectEvent.HALT_RECONNECT);\n }\n });\n }\n async _startSubscriptionWithAWSAppSyncRealTime({ options, observer, subscriptionId, customUserAgentDetails, }) {\n const { query, variables } = options;\n const { additionalCustomHeaders, libraryConfigHeaders } = await additionalHeadersFromOptions(options);\n this.subscriptionObserverMap.set(subscriptionId, {\n observer,\n query: query ?? '',\n variables: variables ?? {},\n subscriptionState: SUBSCRIPTION_STATUS.PENDING,\n startAckTimeoutId: undefined,\n });\n const serializedSubscriptionMessage = await this._prepareSubscriptionPayload({\n options,\n subscriptionId,\n customUserAgentDetails,\n additionalCustomHeaders,\n libraryConfigHeaders,\n });\n try {\n await this._connectWebSocket(options);\n }\n catch (err) {\n this._logStartSubscriptionError(subscriptionId, observer, err);\n return;\n }\n // Potential race condition can occur when unsubscribe is called during _initializeWebSocketConnection.\n // E.g.unsubscribe gets invoked prior to finishing WebSocket handshake or START_ACK.\n // Both subscriptionFailedCallback and subscriptionReadyCallback are used to synchronized this.\n const { subscriptionFailedCallback, subscriptionReadyCallback } = this.subscriptionObserverMap.get(subscriptionId) ?? {};\n // This must be done before sending the message in order to be listening immediately\n this.subscriptionObserverMap.set(subscriptionId, {\n observer,\n subscriptionState: SUBSCRIPTION_STATUS.PENDING,\n query: query ?? '',\n variables: variables ?? {},\n subscriptionReadyCallback,\n subscriptionFailedCallback,\n startAckTimeoutId: setTimeout(() => {\n this._timeoutStartSubscriptionAck(subscriptionId);\n }, START_ACK_TIMEOUT),\n });\n if (this.awsRealTimeSocket) {\n this.awsRealTimeSocket.send(serializedSubscriptionMessage);\n }\n }\n // Log logic for start subscription failures\n _logStartSubscriptionError(subscriptionId, observer, err) {\n this.logger.debug({ err });\n const message = String(err.message ?? '');\n // Resolving to give the state observer time to propogate the update\n this.connectionStateMonitor.record(CONNECTION_CHANGE.CLOSED);\n // Capture the error only when the network didn't cause disruption\n if (this.connectionState !== ConnectionState.ConnectionDisruptedPendingNetwork) {\n // When the error is non-retriable, error out the observable\n if (isNonRetryableError(err)) {\n observer.error({\n errors: [\n {\n ...new GraphQLError(`${CONTROL_MSG.CONNECTION_FAILED}: ${message}`),\n },\n ],\n });\n }\n else {\n this.logger.debug(`${CONTROL_MSG.CONNECTION_FAILED}: ${message}`);\n }\n const { subscriptionFailedCallback } = this.subscriptionObserverMap.get(subscriptionId) || {};\n // Notify concurrent unsubscription\n if (typeof subscriptionFailedCallback === 'function') {\n subscriptionFailedCallback();\n }\n }\n }\n // Waiting that subscription has been connected before trying to unsubscribe\n async _waitForSubscriptionToBeConnected(subscriptionId) {\n const subscriptionObserver = this.subscriptionObserverMap.get(subscriptionId);\n if (subscriptionObserver) {\n const { subscriptionState } = subscriptionObserver;\n // This in case unsubscribe is invoked before sending start subscription message\n if (subscriptionState === SUBSCRIPTION_STATUS.PENDING) {\n return new Promise((resolve, reject) => {\n const { observer, subscriptionState: observedSubscriptionState, variables, query, } = subscriptionObserver;\n this.subscriptionObserverMap.set(subscriptionId, {\n observer,\n subscriptionState: observedSubscriptionState,\n variables,\n query,\n subscriptionReadyCallback: resolve,\n subscriptionFailedCallback: reject,\n });\n });\n }\n }\n }\n _sendUnsubscriptionMessage(subscriptionId) {\n try {\n if (this.awsRealTimeSocket &&\n this.awsRealTimeSocket.readyState === WebSocket.OPEN &&\n this.socketStatus === SOCKET_STATUS.READY) {\n // Preparing unsubscribe message to stop receiving messages for that subscription\n const unsubscribeMessage = this._unsubscribeMessage(subscriptionId);\n const stringToAWSRealTime = JSON.stringify(unsubscribeMessage);\n this.awsRealTimeSocket.send(stringToAWSRealTime);\n }\n }\n catch (err) {\n // If GQL_STOP is not sent because of disconnection issue, then there is nothing the client can do\n this.logger.debug({ err });\n }\n }\n _removeSubscriptionObserver(subscriptionId) {\n this.subscriptionObserverMap.delete(subscriptionId);\n // Verifying 1000ms after removing subscription in case there are new subscription unmount/mount\n setTimeout(this._closeSocketIfRequired.bind(this), 1000);\n }\n _closeSocketIfRequired() {\n if (this.subscriptionObserverMap.size > 0) {\n // Active subscriptions on the WebSocket\n return;\n }\n if (!this.awsRealTimeSocket) {\n this.socketStatus = SOCKET_STATUS.CLOSED;\n return;\n }\n this.connectionStateMonitor.record(CONNECTION_CHANGE.CLOSING_CONNECTION);\n if (this.awsRealTimeSocket.bufferedAmount > 0) {\n // Still data on the WebSocket\n setTimeout(this._closeSocketIfRequired.bind(this), 1000);\n }\n else {\n this.logger.debug('closing WebSocket...');\n if (this.keepAliveTimeoutId) {\n clearTimeout(this.keepAliveTimeoutId);\n }\n if (this.keepAliveAlertTimeoutId) {\n clearTimeout(this.keepAliveAlertTimeoutId);\n }\n const tempSocket = this.awsRealTimeSocket;\n // Cleaning callbacks to avoid race condition, socket still exists\n tempSocket.onclose = null;\n tempSocket.onerror = null;\n tempSocket.close(1000);\n this.awsRealTimeSocket = undefined;\n this.socketStatus = SOCKET_STATUS.CLOSED;\n this.connectionStateMonitor.record(CONNECTION_CHANGE.CLOSED);\n }\n }\n _handleIncomingSubscriptionMessage(message) {\n if (typeof message.data !== 'string') {\n return;\n }\n const [isData, data] = this._handleSubscriptionData(message);\n if (isData)\n return;\n const { type, id, payload } = data;\n const { observer = null, query = '', variables = {}, startAckTimeoutId, subscriptionReadyCallback, subscriptionFailedCallback, } = this.subscriptionObserverMap.get(id) || {};\n if (type === MESSAGE_TYPES.GQL_START_ACK ||\n type === MESSAGE_TYPES.EVENT_SUBSCRIBE_ACK) {\n this.logger.debug(`subscription ready for ${JSON.stringify({ query, variables })}`);\n if (typeof subscriptionReadyCallback === 'function') {\n subscriptionReadyCallback();\n }\n if (startAckTimeoutId)\n clearTimeout(startAckTimeoutId);\n dispatchApiEvent({\n event: CONTROL_MSG.SUBSCRIPTION_ACK,\n data: { query, variables },\n message: 'Connection established for subscription',\n });\n const subscriptionState = SUBSCRIPTION_STATUS.CONNECTED;\n if (observer) {\n this.subscriptionObserverMap.set(id, {\n observer,\n query,\n variables,\n startAckTimeoutId: undefined,\n subscriptionState,\n subscriptionReadyCallback,\n subscriptionFailedCallback,\n });\n }\n this.connectionStateMonitor.record(CONNECTION_CHANGE.CONNECTION_ESTABLISHED);\n return;\n }\n if (type === MESSAGE_TYPES.GQL_CONNECTION_KEEP_ALIVE) {\n if (this.keepAliveTimeoutId)\n clearTimeout(this.keepAliveTimeoutId);\n if (this.keepAliveAlertTimeoutId)\n clearTimeout(this.keepAliveAlertTimeoutId);\n this.keepAliveTimeoutId = setTimeout(() => {\n this._errorDisconnect(CONTROL_MSG.TIMEOUT_DISCONNECT);\n }, this.keepAliveTimeout);\n this.keepAliveAlertTimeoutId = setTimeout(() => {\n this.connectionStateMonitor.record(CONNECTION_CHANGE.KEEP_ALIVE_MISSED);\n }, DEFAULT_KEEP_ALIVE_ALERT_TIMEOUT);\n this.connectionStateMonitor.record(CONNECTION_CHANGE.KEEP_ALIVE);\n return;\n }\n if (type === MESSAGE_TYPES.GQL_ERROR) {\n const subscriptionState = SUBSCRIPTION_STATUS.FAILED;\n if (observer) {\n this.subscriptionObserverMap.set(id, {\n observer,\n query,\n variables,\n startAckTimeoutId,\n subscriptionReadyCallback,\n subscriptionFailedCallback,\n subscriptionState,\n });\n this.logger.debug(`${CONTROL_MSG.CONNECTION_FAILED}: ${JSON.stringify(payload)}`);\n observer.error({\n errors: [\n {\n ...new GraphQLError(`${CONTROL_MSG.CONNECTION_FAILED}: ${JSON.stringify(payload)}`),\n },\n ],\n });\n if (startAckTimeoutId)\n clearTimeout(startAckTimeoutId);\n if (typeof subscriptionFailedCallback === 'function') {\n subscriptionFailedCallback();\n }\n }\n }\n }\n _errorDisconnect(msg) {\n this.logger.debug(`Disconnect error: ${msg}`);\n if (this.awsRealTimeSocket) {\n this.connectionStateMonitor.record(CONNECTION_CHANGE.CLOSED);\n this.awsRealTimeSocket.close();\n }\n this.socketStatus = SOCKET_STATUS.CLOSED;\n }\n _timeoutStartSubscriptionAck(subscriptionId) {\n const subscriptionObserver = this.subscriptionObserverMap.get(subscriptionId);\n if (subscriptionObserver) {\n const { observer, query, variables } = subscriptionObserver;\n if (!observer) {\n return;\n }\n this.subscriptionObserverMap.set(subscriptionId, {\n observer,\n query,\n variables,\n subscriptionState: SUBSCRIPTION_STATUS.FAILED,\n });\n this.connectionStateMonitor.record(CONNECTION_CHANGE.CLOSED);\n this.logger.debug('timeoutStartSubscription', JSON.stringify({ query, variables }));\n }\n }\n _initializeWebSocketConnection({ appSyncGraphqlEndpoint, authenticationType, apiKey, region, additionalCustomHeaders, }) {\n if (this.socketStatus === SOCKET_STATUS.READY) {\n return;\n }\n // TODO(Eslint): refactor to now use async function as the promise executor\n // eslint-disable-next-line no-async-promise-executor\n return new Promise(async (resolve, reject) => {\n this.promiseArray.push({ res: resolve, rej: reject });\n if (this.socketStatus === SOCKET_STATUS.CLOSED) {\n try {\n this.socketStatus = SOCKET_STATUS.CONNECTING;\n // Empty payload on connect\n const payloadString = '{}';\n const authHeader = await awsRealTimeHeaderBasedAuth({\n authenticationType,\n payload: payloadString,\n canonicalUri: '/connect',\n apiKey,\n appSyncGraphqlEndpoint,\n region,\n additionalCustomHeaders,\n });\n const headerString = authHeader ? JSON.stringify(authHeader) : '';\n // base64url-encoded string\n const encodedHeader = base64Encoder.convert(headerString, {\n urlSafe: true,\n skipPadding: true,\n });\n const authTokenSubprotocol = `header-${encodedHeader}`;\n const queryParams = queryParamsFromCustomHeaders(additionalCustomHeaders);\n const awsRealTimeUrl = realtimeUrlWithQueryString(appSyncGraphqlEndpoint, queryParams);\n await this._establishRetryableConnection(awsRealTimeUrl, authTokenSubprotocol);\n this.promiseArray.forEach(({ res }) => {\n this.logger.debug('Notifying connection successful');\n res();\n });\n this.socketStatus = SOCKET_STATUS.READY;\n this.promiseArray = [];\n }\n catch (err) {\n this.logger.debug('Connection exited with', err);\n this.promiseArray.forEach(({ rej }) => {\n rej(err);\n });\n this.promiseArray = [];\n if (this.awsRealTimeSocket &&\n this.awsRealTimeSocket.readyState === WebSocket.OPEN) {\n this.awsRealTimeSocket.close(3001);\n }\n this.awsRealTimeSocket = undefined;\n this.socketStatus = SOCKET_STATUS.CLOSED;\n }\n }\n });\n }\n async _establishRetryableConnection(awsRealTimeUrl, subprotocol) {\n this.logger.debug(`Establishing retryable connection`);\n await jitteredExponentialRetry(this._establishConnection.bind(this), [awsRealTimeUrl, subprotocol], MAX_DELAY_MS);\n }\n async _openConnection(awsRealTimeUrl, subprotocol) {\n return new Promise((resolve, reject) => {\n const newSocket = this._getNewWebSocket(awsRealTimeUrl, [\n 'graphql-ws',\n subprotocol,\n ]);\n newSocket.onerror = () => {\n this.logger.debug(`WebSocket connection error`);\n };\n newSocket.onclose = () => {\n reject(new Error('Connection handshake error'));\n };\n newSocket.onopen = () => {\n this.awsRealTimeSocket = newSocket;\n resolve();\n };\n });\n }\n _getNewWebSocket(url, protocol) {\n return new WebSocket(url, protocol);\n }\n async _initiateHandshake() {\n return new Promise((resolve, reject) => {\n if (!this.awsRealTimeSocket) {\n reject(new Error('awsRealTimeSocket undefined'));\n return;\n }\n let ackOk = false;\n this.awsRealTimeSocket.onerror = error => {\n this.logger.debug(`WebSocket error ${JSON.stringify(error)}`);\n };\n this.awsRealTimeSocket.onclose = event => {\n this.logger.debug(`WebSocket closed ${event.reason}`);\n reject(new Error(JSON.stringify(event)));\n };\n this.awsRealTimeSocket.onmessage = (message) => {\n if (typeof message.data !== 'string') {\n return;\n }\n this.logger.debug(`subscription message from AWS AppSyncRealTime: ${message.data} `);\n const data = JSON.parse(message.data);\n const { type, payload: { connectionTimeoutMs = DEFAULT_KEEP_ALIVE_TIMEOUT } = {}, } = data;\n if (type === MESSAGE_TYPES.GQL_CONNECTION_ACK) {\n ackOk = true;\n this._registerWebsocketHandlers(connectionTimeoutMs);\n resolve('Connected to AWS AppSyncRealTime');\n return;\n }\n if (type === MESSAGE_TYPES.GQL_CONNECTION_ERROR) {\n const { payload: { errors: [{ errorType = '', errorCode = 0 } = {}] = [], } = {}, } = data;\n // TODO(Eslint): refactor to reject an Error object instead of a plain object\n // eslint-disable-next-line prefer-promise-reject-errors\n reject({ errorType, errorCode });\n }\n };\n const gqlInit = {\n type: MESSAGE_TYPES.GQL_CONNECTION_INIT,\n };\n this.awsRealTimeSocket.send(JSON.stringify(gqlInit));\n const checkAckOk = (targetAckOk) => {\n if (!targetAckOk) {\n this.connectionStateMonitor.record(CONNECTION_CHANGE.CONNECTION_FAILED);\n reject(new Error(`Connection timeout: ack from AWSAppSyncRealTime was not received after ${CONNECTION_INIT_TIMEOUT} ms`));\n }\n };\n setTimeout(() => {\n checkAckOk(ackOk);\n }, CONNECTION_INIT_TIMEOUT);\n });\n }\n _registerWebsocketHandlers(connectionTimeoutMs) {\n if (!this.awsRealTimeSocket) {\n return;\n }\n this.keepAliveTimeout = connectionTimeoutMs;\n this.awsRealTimeSocket.onmessage =\n this._handleIncomingSubscriptionMessage.bind(this);\n this.awsRealTimeSocket.onerror = err => {\n this.logger.debug(err);\n this._errorDisconnect(CONTROL_MSG.CONNECTION_CLOSED);\n };\n this.awsRealTimeSocket.onclose = event => {\n this.logger.debug(`WebSocket closed ${event.reason}`);\n this._errorDisconnect(CONTROL_MSG.CONNECTION_CLOSED);\n };\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAAA;AACA;AAWA,MAAM,gBAAgB,GAAG,CAAC,OAAO,KAAK;AACtC,IAAI,GAAG,CAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAC;AAC3D,CAAC,CAAC;AACK,MAAM,oBAAoB,CAAC;AAClC,IAAI,WAAW,CAAC,YAAY,EAAE;AAC9B,QAAQ,IAAI,CAAC,uBAAuB,GAAG,IAAI,GAAG,EAAE,CAAC;AACjD,QAAQ,IAAI,CAAC,YAAY,GAAG,aAAa,CAAC,MAAM,CAAC;AACjD,QAAQ,IAAI,CAAC,gBAAgB,GAAG,0BAA0B,CAAC;AAC3D,QAAQ,IAAI,CAAC,YAAY,GAAG,EAAE,CAAC;AAC/B,QAAQ,IAAI,CAAC,sBAAsB,GAAG,IAAI,sBAAsB,EAAE,CAAC;AACnE,QAAQ,IAAI,CAAC,mBAAmB,GAAG,IAAI,mBAAmB,EAAE,CAAC;AAC7D;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ,IAAI,CAAC,oBAAoB,GAAG,OAAO,cAAc,EAAE,WAAW,KAAK;AAC3E,YAAY,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,qCAAqC,EAAE,cAAc,C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KAAK,CAAC,CAAC;AAClC,aAAa,EAAE,uBAAuB,CAAC,CAAC;AACxC,SAAS,CAAC,CAAC;AACX,KAAK;AACL,IAAI,0BAA0B,CAAC,mBAAmB,EAAE;AACpD,QAAQ,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE;AACrC,YAAY,OAAO;AACnB,SAAS;AACT,QAAQ,IAAI,CAAC,gBAAgB,GAAG,mBAAmB,CAAC;AACpD,QAAQ,IAAI,CAAC,iBAAiB,CAAC,SAAS;AACxC,YAAY,IAAI,CAAC,kCAAkC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC/D,QAAQ,IAAI,CAAC,iBAAiB,CAAC,OAAO,GAAG,GAAG,IAAI;AAChD,YAAY,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AACnC,YAAY,IAAI,CAAC,gBAAgB,CAAC,WAAW,CAAC,iBAAiB,CAAC,CAAC;AACjE,SAAS,CAAC;AACV,QAAQ,IAAI,CAAC,iBAAiB,CAAC,OAAO,GAAG,KAAK,IAAI;AAClD,YAAY,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,iBAAiB,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AAClE,YAAY,IAAI,CAAC,gBAAgB,CAAC,WAAW,CAAC,iBAAiB,CAAC,CAAC;AACjE,SAAS,CAAC;AACV,KAAK;AACL;;;;"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { AmplifyClassV6 } from '@aws-amplify/core';
|
|
2
|
-
import { CustomUserAgentDetails, GraphQLAuthMode } from '@aws-amplify/core/internals/utils';
|
|
3
|
-
import { CustomHeaders } from '@aws-amplify/data-schema/runtime';
|
|
4
|
-
interface GqlRequestOptions {
|
|
5
|
-
apiKey?: string;
|
|
6
|
-
region?: string;
|
|
7
|
-
appSyncGraphqlEndpoint: string;
|
|
8
|
-
authenticationType: GraphQLAuthMode;
|
|
9
|
-
query: string;
|
|
10
|
-
variables: string[];
|
|
11
|
-
authToken?: string;
|
|
12
|
-
}
|
|
13
|
-
export declare function appsyncRequest<T = any>(amplify: AmplifyClassV6, options: GqlRequestOptions, additionalHeaders: CustomHeaders | undefined, abortController: AbortController, customUserAgentDetails?: CustomUserAgentDetails): Promise<T>;
|
|
14
|
-
export {};
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { AmplifyUrl, getAmplifyUserAgent } from '@aws-amplify/core/internals/utils';
|
|
2
|
-
import { post } from '@aws-amplify/api-rest/internals';
|
|
3
|
-
import '../../utils/resolveConfig.mjs';
|
|
4
|
-
import { resolveLibraryOptions } from '../../utils/resolveLibraryOptions.mjs';
|
|
5
|
-
import { repackageUnauthorizedError } from '../../utils/errors/repackageAuthError.mjs';
|
|
6
|
-
import { headerBasedAuth } from '../graphqlAuth.mjs';
|
|
7
|
-
import { isGraphQLResponseWithErrors } from '../utils/runtimeTypeGuards/isGraphQLResponseWithErrors.mjs';
|
|
8
|
-
|
|
9
|
-
const USER_AGENT_HEADER = 'x-amz-user-agent';
|
|
10
|
-
// This is effectively a copy of InternalGraphQLAPI.ts._graphql(...)
|
|
11
|
-
// Our existing unit tests are tightly coupled to the implementation, so i was unable to refactor
|
|
12
|
-
// and extend _graphql() without having to change a bunch of tests as well... which in turn reduces confidence
|
|
13
|
-
// that this feature will _not affect_ GQL behavior.
|
|
14
|
-
async function appsyncRequest(amplify, options, additionalHeaders = {}, abortController, customUserAgentDetails) {
|
|
15
|
-
const { region, appSyncGraphqlEndpoint: endpoint, authenticationType: authMode, query, variables, } = options;
|
|
16
|
-
if (!endpoint) {
|
|
17
|
-
throw new Error('No endpoint');
|
|
18
|
-
}
|
|
19
|
-
const { withCredentials } = resolveLibraryOptions(amplify);
|
|
20
|
-
const headers = await requestHeaders(amplify, options, additionalHeaders, customUserAgentDetails);
|
|
21
|
-
const body = {
|
|
22
|
-
channel: query,
|
|
23
|
-
events: variables,
|
|
24
|
-
};
|
|
25
|
-
const signingServiceInfo = ['apiKey', 'none'].includes(authMode)
|
|
26
|
-
? undefined
|
|
27
|
-
: {
|
|
28
|
-
service: 'appsync',
|
|
29
|
-
region,
|
|
30
|
-
};
|
|
31
|
-
const { body: responseBody } = await post(amplify, {
|
|
32
|
-
url: new AmplifyUrl(endpoint),
|
|
33
|
-
options: {
|
|
34
|
-
headers,
|
|
35
|
-
body,
|
|
36
|
-
signingServiceInfo,
|
|
37
|
-
withCredentials,
|
|
38
|
-
},
|
|
39
|
-
abortController,
|
|
40
|
-
});
|
|
41
|
-
const response = await responseBody.json();
|
|
42
|
-
if (isGraphQLResponseWithErrors(response)) {
|
|
43
|
-
throw repackageUnauthorizedError(response);
|
|
44
|
-
}
|
|
45
|
-
return response;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Computes all the necessary HTTP headers for the request based on:
|
|
49
|
-
* 1. Operation-level header options
|
|
50
|
-
* 2. Amplify.configure custom headers
|
|
51
|
-
* 3. AuthZ headers for explicit auth mode specified for operation ?? default auth mode in config
|
|
52
|
-
*
|
|
53
|
-
* @returns HTTP request headers key/value
|
|
54
|
-
*/
|
|
55
|
-
async function requestHeaders(amplify, options, additionalHeaders, customUserAgentDetails) {
|
|
56
|
-
const { apiKey, appSyncGraphqlEndpoint: endpoint, authenticationType: authMode, query, variables, authToken, } = options;
|
|
57
|
-
const { headers: customHeadersFn } = resolveLibraryOptions(amplify);
|
|
58
|
-
let additionalCustomHeaders;
|
|
59
|
-
if (typeof additionalHeaders === 'function') {
|
|
60
|
-
const requestOptions = {
|
|
61
|
-
method: 'POST',
|
|
62
|
-
url: new AmplifyUrl(endpoint).toString(),
|
|
63
|
-
queryString: query,
|
|
64
|
-
};
|
|
65
|
-
additionalCustomHeaders = await additionalHeaders(requestOptions);
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
additionalCustomHeaders = additionalHeaders;
|
|
69
|
-
}
|
|
70
|
-
// if an authorization header is set, have the operation-level authToken take precedence
|
|
71
|
-
if (authToken) {
|
|
72
|
-
additionalCustomHeaders = {
|
|
73
|
-
...additionalCustomHeaders,
|
|
74
|
-
Authorization: authToken,
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
const authHeaders = await headerBasedAuth(amplify, authMode, apiKey, additionalCustomHeaders);
|
|
78
|
-
const customHeaders = customHeadersFn &&
|
|
79
|
-
(await customHeadersFn({
|
|
80
|
-
query,
|
|
81
|
-
variables: variables,
|
|
82
|
-
}));
|
|
83
|
-
const headers = {
|
|
84
|
-
...authHeaders,
|
|
85
|
-
// Custom headers included in Amplify configuration options:
|
|
86
|
-
...customHeaders,
|
|
87
|
-
// Custom headers from individual requests or API client configuration:
|
|
88
|
-
...additionalCustomHeaders,
|
|
89
|
-
// User agent headers:
|
|
90
|
-
[USER_AGENT_HEADER]: getAmplifyUserAgent(customUserAgentDetails),
|
|
91
|
-
};
|
|
92
|
-
return headers;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export { appsyncRequest };
|
|
96
|
-
//# sourceMappingURL=appsyncRequest.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"appsyncRequest.mjs","sources":["../../../../src/internals/events/appsyncRequest.ts"],"sourcesContent":["import { AmplifyUrl, getAmplifyUserAgent, } from '@aws-amplify/core/internals/utils';\nimport { post } from '@aws-amplify/api-rest/internals';\nimport { resolveLibraryOptions } from '../../utils';\nimport { repackageUnauthorizedError } from '../../utils/errors/repackageAuthError';\nimport { headerBasedAuth } from '../graphqlAuth';\nimport { isGraphQLResponseWithErrors } from '../utils/runtimeTypeGuards/isGraphQLResponseWithErrors';\nconst USER_AGENT_HEADER = 'x-amz-user-agent';\n// This is effectively a copy of InternalGraphQLAPI.ts._graphql(...)\n// Our existing unit tests are tightly coupled to the implementation, so i was unable to refactor\n// and extend _graphql() without having to change a bunch of tests as well... which in turn reduces confidence\n// that this feature will _not affect_ GQL behavior.\nexport async function appsyncRequest(amplify, options, additionalHeaders = {}, abortController, customUserAgentDetails) {\n const { region, appSyncGraphqlEndpoint: endpoint, authenticationType: authMode, query, variables, } = options;\n if (!endpoint) {\n throw new Error('No endpoint');\n }\n const { withCredentials } = resolveLibraryOptions(amplify);\n const headers = await requestHeaders(amplify, options, additionalHeaders, customUserAgentDetails);\n const body = {\n channel: query,\n events: variables,\n };\n const signingServiceInfo = ['apiKey', 'none'].includes(authMode)\n ? undefined\n : {\n service: 'appsync',\n region,\n };\n const { body: responseBody } = await post(amplify, {\n url: new AmplifyUrl(endpoint),\n options: {\n headers,\n body,\n signingServiceInfo,\n withCredentials,\n },\n abortController,\n });\n const response = await responseBody.json();\n if (isGraphQLResponseWithErrors(response)) {\n throw repackageUnauthorizedError(response);\n }\n return response;\n}\n/**\n * Computes all the necessary HTTP headers for the request based on:\n * 1. Operation-level header options\n * 2. Amplify.configure custom headers\n * 3. AuthZ headers for explicit auth mode specified for operation ?? default auth mode in config\n *\n * @returns HTTP request headers key/value\n */\nasync function requestHeaders(amplify, options, additionalHeaders, customUserAgentDetails) {\n const { apiKey, appSyncGraphqlEndpoint: endpoint, authenticationType: authMode, query, variables, authToken, } = options;\n const { headers: customHeadersFn } = resolveLibraryOptions(amplify);\n let additionalCustomHeaders;\n if (typeof additionalHeaders === 'function') {\n const requestOptions = {\n method: 'POST',\n url: new AmplifyUrl(endpoint).toString(),\n queryString: query,\n };\n additionalCustomHeaders = await additionalHeaders(requestOptions);\n }\n else {\n additionalCustomHeaders = additionalHeaders;\n }\n // if an authorization header is set, have the operation-level authToken take precedence\n if (authToken) {\n additionalCustomHeaders = {\n ...additionalCustomHeaders,\n Authorization: authToken,\n };\n }\n const authHeaders = await headerBasedAuth(amplify, authMode, apiKey, additionalCustomHeaders);\n const customHeaders = customHeadersFn &&\n (await customHeadersFn({\n query,\n variables: variables,\n }));\n const headers = {\n ...authHeaders,\n // Custom headers included in Amplify configuration options:\n ...customHeaders,\n // Custom headers from individual requests or API client configuration:\n ...additionalCustomHeaders,\n // User agent headers:\n [USER_AGENT_HEADER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EAAE,uBAAuB,CAAC,CAAC;AAClG,IAAI,MAAM,aAAa,GAAG,eAAe;AACzC,SAAS,MAAM,eAAe,CAAC;AAC/B,YAAY,KAAK;AACjB,YAAY,SAAS,EAAE,SAAS;AAChC,SAAS,CAAC,CAAC,CAAC;AACZ,IAAI,MAAM,OAAO,GAAG;AACpB,QAAQ,GAAG,WAAW;AACtB;AACA,QAAQ,GAAG,aAAa;AACxB;AACA,QAAQ,GAAG,uBAAuB;AAClC;AACA,QAAQ,CAAC,iBAAiB,GAAG,mBAAmB,CAAC,sBAAsB,CAAC;AACxE,KAAK,CAAC;AACN,IAAI,OAAO,OAAO,CAAC;AACnB;;;;"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { DocumentType } from '@aws-amplify/core/internals/utils';
|
|
2
|
-
import type { EventsChannel, EventsOptions, PublishedEvent } from './types';
|
|
3
|
-
/**
|
|
4
|
-
* Establish a WebSocket connection to an Events channel
|
|
5
|
-
*
|
|
6
|
-
*/
|
|
7
|
-
declare function connect(channelName: string, options?: EventsOptions): Promise<EventsChannel>;
|
|
8
|
-
/**
|
|
9
|
-
* Publish events to a channel via REST request
|
|
10
|
-
*
|
|
11
|
-
* @param channelName - publish destination
|
|
12
|
-
* @param event - JSON-serializable value or an array of values
|
|
13
|
-
* @param options
|
|
14
|
-
*/
|
|
15
|
-
declare function post(channelName: string, event: DocumentType | DocumentType[], options?: EventsOptions): Promise<void | PublishedEvent[]>;
|
|
16
|
-
declare function closeAll(): void;
|
|
17
|
-
export { connect, post, closeAll };
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { Amplify } from '@aws-amplify/core';
|
|
2
|
-
import { AppSyncEventProvider } from '../../Providers/AWSAppSyncEventsProvider/index.mjs';
|
|
3
|
-
import { appsyncRequest } from './appsyncRequest.mjs';
|
|
4
|
-
import { configure, normalizeAuth, serializeEvents } from './utils.mjs';
|
|
5
|
-
|
|
6
|
-
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
7
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
8
|
-
/**
|
|
9
|
-
* Establish a WebSocket connection to an Events channel
|
|
10
|
-
*
|
|
11
|
-
*/
|
|
12
|
-
async function connect(channelName, options) {
|
|
13
|
-
const providerOptions = configure();
|
|
14
|
-
providerOptions.authenticationType = normalizeAuth(options?.authMode, providerOptions.authenticationType);
|
|
15
|
-
await AppSyncEventProvider.connect(providerOptions);
|
|
16
|
-
let _subscription;
|
|
17
|
-
const sub = (observer, subOptions) => {
|
|
18
|
-
const subscribeOptions = { ...providerOptions, query: channelName };
|
|
19
|
-
subscribeOptions.authenticationType = normalizeAuth(subOptions?.authMode, subscribeOptions.authenticationType);
|
|
20
|
-
_subscription = AppSyncEventProvider
|
|
21
|
-
.subscribe(subscribeOptions)
|
|
22
|
-
.subscribe(observer);
|
|
23
|
-
return _subscription;
|
|
24
|
-
};
|
|
25
|
-
const close = () => {
|
|
26
|
-
_subscription && _subscription.unsubscribe();
|
|
27
|
-
};
|
|
28
|
-
return {
|
|
29
|
-
/**
|
|
30
|
-
* Subscribe to incoming events
|
|
31
|
-
*/
|
|
32
|
-
subscribe: sub,
|
|
33
|
-
/**
|
|
34
|
-
* Close channel and any active subscriptions
|
|
35
|
-
*/
|
|
36
|
-
close,
|
|
37
|
-
// publish: pub,
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Publish events to a channel via REST request
|
|
42
|
-
*
|
|
43
|
-
* @param channelName - publish destination
|
|
44
|
-
* @param event - JSON-serializable value or an array of values
|
|
45
|
-
* @param options
|
|
46
|
-
*/
|
|
47
|
-
async function post(channelName, event, options) {
|
|
48
|
-
const providerOptions = configure();
|
|
49
|
-
providerOptions.authenticationType = normalizeAuth(options?.authMode, providerOptions.authenticationType);
|
|
50
|
-
// trailing slash required in publish
|
|
51
|
-
const normalizedChannelName = channelName[0] === '/' ? channelName : `/${channelName}`;
|
|
52
|
-
const publishOptions = {
|
|
53
|
-
...providerOptions,
|
|
54
|
-
query: normalizedChannelName,
|
|
55
|
-
variables: serializeEvents(event),
|
|
56
|
-
authToken: options?.authToken,
|
|
57
|
-
};
|
|
58
|
-
const abortController = new AbortController();
|
|
59
|
-
const res = await appsyncRequest(Amplify, publishOptions, {}, abortController);
|
|
60
|
-
if (res.failed?.length > 0) {
|
|
61
|
-
return res.failed;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
function closeAll() {
|
|
65
|
-
AppSyncEventProvider.close();
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export { closeAll, connect, post };
|
|
69
|
-
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../../../src/internals/events/index.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Amplify } from '@aws-amplify/core';\nimport { AppSyncEventProvider as eventProvider } from '../../Providers/AWSAppSyncEventsProvider';\nimport { appsyncRequest } from './appsyncRequest';\nimport { configure, normalizeAuth, serializeEvents } from './utils';\n/**\n * Establish a WebSocket connection to an Events channel\n *\n */\nasync function connect(channelName, options) {\n const providerOptions = configure();\n providerOptions.authenticationType = normalizeAuth(options?.authMode, providerOptions.authenticationType);\n await eventProvider.connect(providerOptions);\n let _subscription;\n const sub = (observer, subOptions) => {\n const subscribeOptions = { ...providerOptions, query: channelName };\n subscribeOptions.authenticationType = normalizeAuth(subOptions?.authMode, subscribeOptions.authenticationType);\n _subscription = eventProvider\n .subscribe(subscribeOptions)\n .subscribe(observer);\n return _subscription;\n };\n // WS publish is not enabled in the service yet. It will be a follow up feature\n const _pub = async (event, pubOptions) => {\n const publishOptions = {\n ...providerOptions,\n query: channelName,\n variables: event,\n };\n publishOptions.authenticationType = normalizeAuth(pubOptions?.authMode, publishOptions.authenticationType);\n return eventProvider.publish(publishOptions);\n };\n const close = () => {\n _subscription && _subscription.unsubscribe();\n };\n return {\n /**\n * Subscribe to incoming events\n */\n subscribe: sub,\n /**\n * Close channel and any active subscriptions\n */\n close,\n // publish: pub,\n };\n}\n/**\n * Publish events to a channel via REST request\n *\n * @param channelName - publish destination\n * @param event - JSON-serializable value or an array of values\n * @param options\n */\nasync function post(channelName, event, options) {\n const providerOptions = configure();\n providerOptions.authenticationType = normalizeAuth(options?.authMode, providerOptions.authenticationType);\n // trailing slash required in publish\n const normalizedChannelName = channelName[0] === '/' ? channelName : `/${channelName}`;\n const publishOptions = {\n ...providerOptions,\n query: normalizedChannelName,\n variables: serializeEvents(event),\n authToken: options?.authToken,\n };\n const abortController = new AbortController();\n const res = await appsyncRequest(Amplify, publishOptions, {}, abortController);\n if (res.failed?.length > 0) {\n return res.failed;\n }\n}\nfunction closeAll() {\n eventProvider.close();\n}\nexport { connect, post, closeAll };\n"],"names":["eventProvider"],"mappings":";;;;;AAAA;AACA;AAKA;AACA;AACA;AACA;AACA,eAAe,OAAO,CAAC,WAAW,EAAE,OAAO,EAAE;AAC7C,IAAI,MAAM,eAAe,GAAG,SAAS,EAAE,CAAC;AACxC,IAAI,eAAe,CAAC,kBAAkB,GAAG,aAAa,CAAC,OAAO,EAAE,QAAQ,EAAE,eAAe,CAAC,kBAAkB,CAAC,CAAC;AAC9G,IAAI,MAAMA,oBAAa,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;AACjD,IAAI,IAAI,aAAa,CAAC;AACtB,IAAI,MAAM,GAAG,GAAG,CAAC,QAAQ,EAAE,UAAU,KAAK;AAC1C,QAAQ,MAAM,gBAAgB,GAAG,EAAE,GAAG,eAAe,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC;AAC5E,QAAQ,gBAAgB,CAAC,kBAAkB,GAAG,aAAa,CAAC,UAAU,EAAE,QAAQ,EAAE,gBAAgB,CAAC,kBAAkB,CAAC,CAAC;AACvH,QAAQ,aAAa,GAAGA,oBAAa;AACrC,aAAa,SAAS,CAAC,gBAAgB,CAAC;AACxC,aAAa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,oBAAa,CAAC,KAAK,EAAE,CAAC;AAC1B;;;;"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { Subscription } from 'rxjs';
|
|
2
|
-
import type { GraphQLAuthMode } from '@aws-amplify/core/internals/utils';
|
|
3
|
-
export interface SubscriptionObserver<T> {
|
|
4
|
-
next(value: T): void;
|
|
5
|
-
error(errorValue: any): void;
|
|
6
|
-
}
|
|
7
|
-
export interface EventsChannel {
|
|
8
|
-
subscribe(observer: SubscriptionObserver<any>, subOptions?: EventsOptions): Subscription;
|
|
9
|
-
close(): void;
|
|
10
|
-
}
|
|
11
|
-
export type ResolvedGraphQLAuthModes = Exclude<GraphQLAuthMode, 'identityPool'>;
|
|
12
|
-
export interface EventsOptions {
|
|
13
|
-
authMode?: GraphQLAuthMode;
|
|
14
|
-
authToken?: string;
|
|
15
|
-
}
|
|
16
|
-
export interface PublishedEvent {
|
|
17
|
-
identifier: string;
|
|
18
|
-
index: number;
|
|
19
|
-
}
|
|
20
|
-
export interface PublishResponse {
|
|
21
|
-
failed: PublishedEvent[];
|
|
22
|
-
successful: PublishedEvent[];
|
|
23
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { DocumentType, GraphQLAuthMode } from '@aws-amplify/core/internals/utils';
|
|
2
|
-
import type { ResolvedGraphQLAuthModes } from './types';
|
|
3
|
-
export declare const normalizeAuth: (explicitAuthMode: GraphQLAuthMode | undefined, defaultAuthMode: ResolvedGraphQLAuthModes) => ResolvedGraphQLAuthModes;
|
|
4
|
-
export declare const configure: () => {
|
|
5
|
-
appSyncGraphqlEndpoint: string;
|
|
6
|
-
region: string | undefined;
|
|
7
|
-
authenticationType: ResolvedGraphQLAuthModes;
|
|
8
|
-
apiKey: string | undefined;
|
|
9
|
-
};
|
|
10
|
-
/**
|
|
11
|
-
* Event API expects and array of JSON strings
|
|
12
|
-
*
|
|
13
|
-
* @param events - JSON-serializable value or an array of values
|
|
14
|
-
* @returns array of JSON strings
|
|
15
|
-
*/
|
|
16
|
-
export declare const serializeEvents: (events: DocumentType | DocumentType[]) => string[];
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { Amplify } from '@aws-amplify/core';
|
|
2
|
-
|
|
3
|
-
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
4
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
const normalizeAuth = (explicitAuthMode, defaultAuthMode) => {
|
|
6
|
-
if (!explicitAuthMode) {
|
|
7
|
-
return defaultAuthMode;
|
|
8
|
-
}
|
|
9
|
-
if (explicitAuthMode === 'identityPool') {
|
|
10
|
-
return 'iam';
|
|
11
|
-
}
|
|
12
|
-
return explicitAuthMode;
|
|
13
|
-
};
|
|
14
|
-
const configure = () => {
|
|
15
|
-
const config = Amplify.getConfig();
|
|
16
|
-
const eventsConfig = config.API?.Events;
|
|
17
|
-
if (!eventsConfig) {
|
|
18
|
-
throw new Error('Amplify configuration is missing. Have you called Amplify.configure()?');
|
|
19
|
-
}
|
|
20
|
-
const configAuthMode = normalizeAuth(eventsConfig.defaultAuthMode, 'apiKey');
|
|
21
|
-
const options = {
|
|
22
|
-
appSyncGraphqlEndpoint: eventsConfig.endpoint,
|
|
23
|
-
region: eventsConfig.region,
|
|
24
|
-
authenticationType: configAuthMode,
|
|
25
|
-
apiKey: eventsConfig.apiKey,
|
|
26
|
-
};
|
|
27
|
-
return options;
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* Event API expects and array of JSON strings
|
|
31
|
-
*
|
|
32
|
-
* @param events - JSON-serializable value or an array of values
|
|
33
|
-
* @returns array of JSON strings
|
|
34
|
-
*/
|
|
35
|
-
const serializeEvents = (events) => {
|
|
36
|
-
if (Array.isArray(events)) {
|
|
37
|
-
return events.map((ev, idx) => {
|
|
38
|
-
const eventJson = JSON.stringify(ev);
|
|
39
|
-
if (eventJson === undefined) {
|
|
40
|
-
throw new Error(`Event must be a valid JSON value. Received ${ev} at index ${idx}`);
|
|
41
|
-
}
|
|
42
|
-
return eventJson;
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
const eventJson = JSON.stringify(events);
|
|
46
|
-
if (eventJson === undefined) {
|
|
47
|
-
throw new Error(`Event must be a valid JSON value. Received ${events}`);
|
|
48
|
-
}
|
|
49
|
-
return [eventJson];
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
export { configure, normalizeAuth, serializeEvents };
|
|
53
|
-
//# sourceMappingURL=utils.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.mjs","sources":["../../../../src/internals/events/utils.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Amplify } from '@aws-amplify/core';\nexport const normalizeAuth = (explicitAuthMode, defaultAuthMode) => {\n if (!explicitAuthMode) {\n return defaultAuthMode;\n }\n if (explicitAuthMode === 'identityPool') {\n return 'iam';\n }\n return explicitAuthMode;\n};\nexport const configure = () => {\n const config = Amplify.getConfig();\n const eventsConfig = config.API?.Events;\n if (!eventsConfig) {\n throw new Error('Amplify configuration is missing. Have you called Amplify.configure()?');\n }\n const configAuthMode = normalizeAuth(eventsConfig.defaultAuthMode, 'apiKey');\n const options = {\n appSyncGraphqlEndpoint: eventsConfig.endpoint,\n region: eventsConfig.region,\n authenticationType: configAuthMode,\n apiKey: eventsConfig.apiKey,\n };\n return options;\n};\n/**\n * Event API expects and array of JSON strings\n *\n * @param events - JSON-serializable value or an array of values\n * @returns array of JSON strings\n */\nexport const serializeEvents = (events) => {\n if (Array.isArray(events)) {\n return events.map((ev, idx) => {\n const eventJson = JSON.stringify(ev);\n if (eventJson === undefined) {\n throw new Error(`Event must be a valid JSON value. Received ${ev} at index ${idx}`);\n }\n return eventJson;\n });\n }\n const eventJson = JSON.stringify(events);\n if (eventJson === undefined) {\n throw new Error(`Event must be a valid JSON value. Received ${events}`);\n }\n return [eventJson];\n};\n"],"names":[],"mappings":";;AAAA;AACA;AAEY,MAAC,aAAa,GAAG,CAAC,gBAAgB,EAAE,eAAe,KAAK;AACpE,IAAI,IAAI,CAAC,gBAAgB,EAAE;AAC3B,QAAQ,OAAO,eAAe,CAAC;AAC/B,KAAK;AACL,IAAI,IAAI,gBAAgB,KAAK,cAAc,EAAE;AAC7C,QAAQ,OAAO,KAAK,CAAC;AACrB,KAAK;AACL,IAAI,OAAO,gBAAgB,CAAC;AAC5B,EAAE;AACU,MAAC,SAAS,GAAG,MAAM;AAC/B,IAAI,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;AACvC,IAAI,MAAM,YAAY,GAAG,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC;AAC5C,IAAI,IAAI,CAAC,YAAY,EAAE;AACvB,QAAQ,MAAM,IAAI,KAAK,CAAC,wEAAwE,CAAC,CAAC;AAClG,KAAK;AACL,IAAI,MAAM,cAAc,GAAG,aAAa,CAAC,YAAY,CAAC,eAAe,EAAE,QAAQ,CAAC,CAAC;AACjF,IAAI,MAAM,OAAO,GAAG;AACpB,QAAQ,sBAAsB,EAAE,YAAY,CAAC,QAAQ;AACrD,QAAQ,MAAM,EAAE,YAAY,CAAC,MAAM;AACnC,QAAQ,kBAAkB,EAAE,cAAc;AAC1C,QAAQ,MAAM,EAAE,YAAY,CAAC,MAAM;AACnC,KAAK,CAAC;AACN,IAAI,OAAO,OAAO,CAAC;AACnB,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,eAAe,GAAG,CAAC,MAAM,KAAK;AAC3C,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;AAC/B,QAAQ,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,GAAG,KAAK;AACvC,YAAY,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;AACjD,YAAY,IAAI,SAAS,KAAK,SAAS,EAAE;AACzC,gBAAgB,MAAM,IAAI,KAAK,CAAC,CAAC,2CAA2C,EAAE,EAAE,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;AACpG,aAAa;AACb,YAAY,OAAO,SAAS,CAAC;AAC7B,SAAS,CAAC,CAAC;AACX,KAAK;AACL,IAAI,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;AAC7C,IAAI,IAAI,SAAS,KAAK,SAAS,EAAE;AACjC,QAAQ,MAAM,IAAI,KAAK,CAAC,CAAC,2CAA2C,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;AAChF,KAAK;AACL,IAAI,OAAO,CAAC,SAAS,CAAC,CAAC;AACvB;;;;"}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { GraphQLAuthMode } from '@aws-amplify/core/internals/utils';
|
|
2
|
-
import { AmplifyClassV6 } from '@aws-amplify/core';
|
|
3
|
-
export declare function headerBasedAuth(amplify: AmplifyClassV6, authMode: GraphQLAuthMode, apiKey: string | undefined, additionalHeaders?: Record<string, string>): Promise<{}>;
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { GraphQLApiError } from '../utils/errors/GraphQLApiError.mjs';
|
|
2
|
-
import '../utils/errors/validation.mjs';
|
|
3
|
-
import 'graphql';
|
|
4
|
-
import { NO_AUTH_TOKEN_HEADER, NO_SIGNED_IN_USER, NO_VALID_AUTH_TOKEN, NO_VALID_CREDENTIALS, NO_API_KEY } from '../utils/errors/constants.mjs';
|
|
5
|
-
|
|
6
|
-
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
7
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
8
|
-
async function headerBasedAuth(amplify, authMode, apiKey, additionalHeaders = {}) {
|
|
9
|
-
let headers = {};
|
|
10
|
-
switch (authMode) {
|
|
11
|
-
case 'apiKey':
|
|
12
|
-
if (!apiKey) {
|
|
13
|
-
throw new GraphQLApiError(NO_API_KEY);
|
|
14
|
-
}
|
|
15
|
-
headers = {
|
|
16
|
-
'X-Api-Key': apiKey,
|
|
17
|
-
};
|
|
18
|
-
break;
|
|
19
|
-
case 'iam': {
|
|
20
|
-
const session = await amplify.Auth.fetchAuthSession();
|
|
21
|
-
if (session.credentials === undefined) {
|
|
22
|
-
throw new GraphQLApiError(NO_VALID_CREDENTIALS);
|
|
23
|
-
}
|
|
24
|
-
break;
|
|
25
|
-
}
|
|
26
|
-
case 'oidc':
|
|
27
|
-
case 'userPool': {
|
|
28
|
-
let token;
|
|
29
|
-
try {
|
|
30
|
-
token = (await amplify.Auth.fetchAuthSession()).tokens?.accessToken.toString();
|
|
31
|
-
}
|
|
32
|
-
catch (e) {
|
|
33
|
-
// fetchAuthSession failed
|
|
34
|
-
throw new GraphQLApiError({
|
|
35
|
-
...NO_SIGNED_IN_USER,
|
|
36
|
-
underlyingError: e,
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
// `fetchAuthSession()` succeeded but didn't return `tokens`.
|
|
40
|
-
// This may happen when unauthenticated access is enabled and there is
|
|
41
|
-
// no user signed in.
|
|
42
|
-
if (!token) {
|
|
43
|
-
throw new GraphQLApiError(NO_VALID_AUTH_TOKEN);
|
|
44
|
-
}
|
|
45
|
-
headers = {
|
|
46
|
-
Authorization: token,
|
|
47
|
-
};
|
|
48
|
-
break;
|
|
49
|
-
}
|
|
50
|
-
case 'lambda':
|
|
51
|
-
if (typeof additionalHeaders === 'object' &&
|
|
52
|
-
!additionalHeaders.Authorization) {
|
|
53
|
-
throw new GraphQLApiError(NO_AUTH_TOKEN_HEADER);
|
|
54
|
-
}
|
|
55
|
-
headers = {
|
|
56
|
-
Authorization: additionalHeaders.Authorization,
|
|
57
|
-
};
|
|
58
|
-
break;
|
|
59
|
-
}
|
|
60
|
-
return headers;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export { headerBasedAuth };
|
|
64
|
-
//# sourceMappingURL=graphqlAuth.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"graphqlAuth.mjs","sources":["../../../src/internals/graphqlAuth.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { GraphQLApiError } from '../utils/errors';\nimport { NO_API_KEY, NO_AUTH_TOKEN_HEADER, NO_SIGNED_IN_USER, NO_VALID_AUTH_TOKEN, NO_VALID_CREDENTIALS, } from '../utils/errors/constants';\nexport async function headerBasedAuth(amplify, authMode, apiKey, additionalHeaders = {}) {\n let headers = {};\n switch (authMode) {\n case 'apiKey':\n if (!apiKey) {\n throw new GraphQLApiError(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 GraphQLApiError(NO_VALID_CREDENTIALS);\n }\n break;\n }\n case 'oidc':\n case 'userPool': {\n let token;\n try {\n token = (await amplify.Auth.fetchAuthSession()).tokens?.accessToken.toString();\n }\n catch (e) {\n // fetchAuthSession failed\n throw new GraphQLApiError({\n ...NO_SIGNED_IN_USER,\n underlyingError: e,\n });\n }\n // `fetchAuthSession()` succeeded but didn't return `tokens`.\n // This may happen when unauthenticated access is enabled and there is\n // no user signed in.\n if (!token) {\n throw new GraphQLApiError(NO_VALID_AUTH_TOKEN);\n }\n headers = {\n Authorization: token,\n };\n break;\n }\n case 'lambda':\n if (typeof additionalHeaders === 'object' &&\n !additionalHeaders.Authorization) {\n throw new GraphQLApiError(NO_AUTH_TOKEN_HEADER);\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"],"names":[],"mappings":";;;;;AAAA;AACA;AAGO,eAAe,eAAe,CAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,iBAAiB,GAA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K,QAAQ;AACrB,YAAY,IAAI,OAAO,iBAAiB,KAAK,QAAQ;AACrD,gBAAgB,CAAC,iBAAiB,CAAC,aAAa,EAAE;AAClD,gBAAgB,MAAM,IAAI,eAAe,CAAC,oBAAoB,CAAC,CAAC;AAChE,aAAa;AACb,YAAY,OAAO,GAAG;AACtB,gBAAgB,aAAa,EAAE,iBAAiB,CAAC,aAAa;AAC9D,aAAa,CAAC;AACd,YAAY,MAAM;AAKlB,KAAK;AACL,IAAI,OAAO,OAAO,CAAC;AACnB;;;;"}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { AmplifyClassV6 } from '@aws-amplify/core';
|
|
2
|
-
import { post } from '@aws-amplify/api-rest/internals';
|
|
3
|
-
export declare function graphqlRequest(amplify: AmplifyClassV6, url: string, options: any, abortController: AbortController, _post?: typeof post): Promise<import("@aws-amplify/core/internals/utils").DocumentType>;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { AmplifyUrl } from '@aws-amplify/core/internals/utils';
|
|
2
|
-
import { post } from '@aws-amplify/api-rest/internals';
|
|
3
|
-
|
|
4
|
-
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
5
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
6
|
-
async function graphqlRequest(amplify, url, options, abortController, _post) {
|
|
7
|
-
const p = _post ?? post;
|
|
8
|
-
const { body: responseBody } = await p(amplify, {
|
|
9
|
-
url: new AmplifyUrl(url),
|
|
10
|
-
options,
|
|
11
|
-
abortController,
|
|
12
|
-
});
|
|
13
|
-
const response = await responseBody.json();
|
|
14
|
-
return response;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export { graphqlRequest };
|
|
18
|
-
//# sourceMappingURL=graphqlRequest.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"graphqlRequest.mjs","sources":["../../../src/internals/graphqlRequest.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { AmplifyUrl } from '@aws-amplify/core/internals/utils';\nimport { \n// cancel as cancelREST,\npost,\n// updateRequestToBeCancellable,\n } from '@aws-amplify/api-rest/internals';\nexport async function graphqlRequest(amplify, url, options, abortController, _post) {\n const p = _post ?? post;\n const { body: responseBody } = await p(amplify, {\n url: new AmplifyUrl(url),\n options,\n abortController,\n });\n const response = await responseBody.json();\n return response;\n}\n"],"names":[],"mappings":";;;AAAA;AACA;AAOO,eAAe,cAAc,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE;AACpF,IAAI,MAAM,CAAC,GAAG,KAAK,IAAI,IAAI,CAAC;AAC5B,IAAI,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,GAAG,MAAM,CAAC,CAAC,OAAO,EAAE;AACpD,QAAQ,GAAG,EAAE,IAAI,UAAU,CAAC,GAAG,CAAC;AAChC,QAAQ,OAAO;AACf,QAAQ,eAAe;AACvB,KAAK,CAAC,CAAC;AACP,IAAI,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC,IAAI,EAAE,CAAC;AAC/C,IAAI,OAAO,QAAQ,CAAC;AACpB;;;;"}
|