@aws-amplify/api-graphql 4.0.21 → 4.0.22-unstable.1a6d358.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 (98) hide show
  1. package/dist/cjs/Providers/AWSAppSyncRealTimeProvider/index.js +40 -31
  2. package/dist/cjs/Providers/AWSAppSyncRealTimeProvider/index.js.map +1 -1
  3. package/dist/cjs/internals/APIClient.js +34 -19
  4. package/dist/cjs/internals/APIClient.js.map +1 -1
  5. package/dist/cjs/internals/InternalGraphQLAPI.js +10 -9
  6. package/dist/cjs/internals/InternalGraphQLAPI.js.map +1 -1
  7. package/dist/cjs/internals/generateClient.js +1 -1
  8. package/dist/cjs/internals/generateClient.js.map +1 -1
  9. package/dist/cjs/internals/operations/custom.js +2 -2
  10. package/dist/cjs/internals/operations/custom.js.map +1 -1
  11. package/dist/cjs/internals/operations/list.js +1 -1
  12. package/dist/cjs/internals/operations/list.js.map +1 -1
  13. package/dist/cjs/internals/server/generateClientWithAmplifyInstance.js +1 -1
  14. package/dist/cjs/internals/server/generateClientWithAmplifyInstance.js.map +1 -1
  15. package/dist/cjs/internals/server/generateModelsProperty.js +1 -1
  16. package/dist/cjs/internals/server/generateModelsProperty.js.map +1 -1
  17. package/dist/cjs/internals/v6.js +0 -2
  18. package/dist/cjs/internals/v6.js.map +1 -1
  19. package/dist/cjs/utils/errors/repackageAuthError.js +1 -1
  20. package/dist/cjs/utils/errors/repackageAuthError.js.map +1 -1
  21. package/dist/esm/GraphQLAPI.d.ts +2 -2
  22. package/dist/esm/GraphQLAPI.mjs.map +1 -1
  23. package/dist/esm/Providers/AWSAppSyncRealTimeProvider/index.d.ts +8 -8
  24. package/dist/esm/Providers/AWSAppSyncRealTimeProvider/index.mjs +40 -31
  25. package/dist/esm/Providers/AWSAppSyncRealTimeProvider/index.mjs.map +1 -1
  26. package/dist/esm/internals/APIClient.d.ts +5 -6
  27. package/dist/esm/internals/APIClient.mjs +34 -19
  28. package/dist/esm/internals/APIClient.mjs.map +1 -1
  29. package/dist/esm/internals/InternalGraphQLAPI.d.ts +1 -1
  30. package/dist/esm/internals/InternalGraphQLAPI.mjs +10 -9
  31. package/dist/esm/internals/InternalGraphQLAPI.mjs.map +1 -1
  32. package/dist/esm/internals/generateClient.mjs +1 -1
  33. package/dist/esm/internals/generateClient.mjs.map +1 -1
  34. package/dist/esm/internals/generateCustomOperationsProperty.d.ts +2 -2
  35. package/dist/esm/internals/operations/custom.d.ts +1 -1
  36. package/dist/esm/internals/operations/custom.mjs +2 -2
  37. package/dist/esm/internals/operations/custom.mjs.map +1 -1
  38. package/dist/esm/internals/operations/get.d.ts +1 -1
  39. package/dist/esm/internals/operations/get.mjs.map +1 -1
  40. package/dist/esm/internals/operations/indexQuery.d.ts +3 -3
  41. package/dist/esm/internals/operations/indexQuery.mjs.map +1 -1
  42. package/dist/esm/internals/operations/list.d.ts +1 -1
  43. package/dist/esm/internals/operations/list.mjs +1 -1
  44. package/dist/esm/internals/operations/list.mjs.map +1 -1
  45. package/dist/esm/internals/operations/subscription.d.ts +1 -1
  46. package/dist/esm/internals/operations/subscription.mjs.map +1 -1
  47. package/dist/esm/internals/server/generateClientWithAmplifyInstance.d.ts +1 -1
  48. package/dist/esm/internals/server/generateClientWithAmplifyInstance.mjs +1 -1
  49. package/dist/esm/internals/server/generateClientWithAmplifyInstance.mjs.map +1 -1
  50. package/dist/esm/internals/server/generateModelsProperty.d.ts +1 -2
  51. package/dist/esm/internals/server/generateModelsProperty.mjs +1 -1
  52. package/dist/esm/internals/server/generateModelsProperty.mjs.map +1 -1
  53. package/dist/esm/internals/types.d.ts +2 -2
  54. package/dist/esm/internals/utils/clientProperties/generateModelsProperty.d.ts +1 -1
  55. package/dist/esm/internals/v6.d.ts +1 -1
  56. package/dist/esm/internals/v6.mjs +0 -2
  57. package/dist/esm/internals/v6.mjs.map +1 -1
  58. package/dist/esm/types/index.d.ts +33 -35
  59. package/dist/esm/utils/ConnectionStateMonitor.d.ts +2 -2
  60. package/dist/esm/utils/ConnectionStateMonitor.mjs.map +1 -1
  61. package/dist/esm/utils/ReachabilityMonitor/index.native.mjs.map +1 -1
  62. package/dist/esm/utils/errors/repackageAuthError.d.ts +2 -2
  63. package/dist/esm/utils/errors/repackageAuthError.mjs +1 -1
  64. package/dist/esm/utils/errors/repackageAuthError.mjs.map +1 -1
  65. package/dist/esm/utils/findIndexByFields.d.ts +1 -1
  66. package/package.json +6 -5
  67. package/src/GraphQLAPI.ts +4 -3
  68. package/src/Providers/AWSAppSyncRealTimeProvider/index.ts +84 -64
  69. package/src/internals/APIClient.ts +59 -27
  70. package/src/internals/InternalGraphQLAPI.ts +26 -30
  71. package/src/internals/clientUtils.ts +1 -1
  72. package/src/internals/generateClient.ts +12 -10
  73. package/src/internals/generateCustomOperationsProperty.ts +7 -6
  74. package/src/internals/operations/custom.ts +16 -13
  75. package/src/internals/operations/get.ts +9 -8
  76. package/src/internals/operations/indexQuery.ts +12 -11
  77. package/src/internals/operations/list.ts +11 -15
  78. package/src/internals/operations/observeQuery.ts +3 -1
  79. package/src/internals/operations/subscription.ts +12 -10
  80. package/src/internals/server/generateClientWithAmplifyInstance.ts +7 -7
  81. package/src/internals/server/generateModelsProperty.ts +7 -4
  82. package/src/internals/types.ts +2 -2
  83. package/src/internals/utils/clientProperties/generateEnumsProperty.ts +7 -6
  84. package/src/internals/utils/clientProperties/generateModelsProperty.ts +7 -6
  85. package/src/internals/v6.ts +6 -4
  86. package/src/server/generateClient.ts +4 -1
  87. package/src/types/PubSub.ts +1 -0
  88. package/src/types/index.ts +49 -47
  89. package/src/utils/ConnectionStateMonitor.ts +8 -3
  90. package/src/utils/ReachabilityMonitor/index.native.ts +1 -1
  91. package/src/utils/ReachabilityMonitor/index.ts +1 -0
  92. package/src/utils/ReconnectionMonitor.ts +1 -0
  93. package/src/utils/errors/repackageAuthError.ts +6 -7
  94. package/src/utils/findIndexByFields.ts +1 -1
  95. package/src/utils/resolveConfig.ts +1 -0
  96. package/src/utils/resolveLibraryOptions.ts +1 -0
  97. package/src/utils/resolveOwnerFields.ts +7 -5
  98. package/src/utils/resolvePKFields.ts +1 -0
@@ -1 +1 @@
1
- {"version":3,"file":"InternalGraphQLAPI.js","sources":["../../../src/internals/InternalGraphQLAPI.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.InternalGraphQLAPI = exports.InternalGraphQLAPIClass = void 0;\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nconst graphql_1 = require(\"graphql\");\nconst rxjs_1 = require(\"rxjs\");\nconst core_1 = require(\"@aws-amplify/core\");\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst types_1 = require(\"../types\");\nconst api_rest_1 = require(\"@aws-amplify/api-rest\");\nconst internals_1 = require(\"@aws-amplify/api-rest/internals\");\nconst AWSAppSyncRealTimeProvider_1 = require(\"../Providers/AWSAppSyncRealTimeProvider\");\nconst utils_2 = require(\"../utils\");\nconst repackageAuthError_1 = require(\"../utils/errors/repackageAuthError\");\nconst USER_AGENT_HEADER = 'x-amz-user-agent';\nconst logger = new core_1.ConsoleLogger('GraphQLAPI');\nconst isAmplifyInstance = (amplify) => {\n return typeof amplify !== 'function';\n};\n/**\n * Export Cloud Logic APIs\n */\nclass InternalGraphQLAPIClass {\n constructor() {\n /**\n * @private\n */\n this.appSyncRealTime = new AWSAppSyncRealTimeProvider_1.AWSAppSyncRealTimeProvider();\n this._api = {\n post: internals_1.post,\n cancelREST: internals_1.cancel,\n isCancelErrorREST: api_rest_1.isCancelError,\n updateRequestToBeCancellable: internals_1.updateRequestToBeCancellable,\n };\n }\n getModuleName() {\n return 'InternalGraphQLAPI';\n }\n async _headerBasedAuth(amplify, authMode, additionalHeaders = {}) {\n const { region: region, endpoint: appSyncGraphqlEndpoint, apiKey, } = (0, utils_2.resolveConfig)(amplify);\n let headers = {};\n switch (authMode) {\n case 'apiKey':\n if (!apiKey) {\n throw new Error(types_1.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(types_1.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(types_1.GraphQLAuthError.NO_FEDERATED_JWT);\n }\n headers = {\n Authorization: token,\n };\n }\n catch (e) {\n throw new Error(types_1.GraphQLAuthError.NO_CURRENT_USER);\n }\n break;\n case 'lambda':\n if (typeof additionalHeaders === 'object' &&\n !additionalHeaders.Authorization) {\n throw new Error(types_1.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 = (0, graphql_1.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 `libraryConfigHeaders` 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 ? (0, graphql_1.parse)(paramQuery)\n : (0, graphql_1.parse)((0, graphql_1.print)(paramQuery));\n const [operationDef = {}] = query.definitions.filter(def => def.kind === 'OperationDefinition');\n const { operation: operationType } = operationDef;\n const headers = additionalHeaders || {};\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, authToken);\n }\n else {\n // NOTE: this wrapper function must be await-able so the Amplify server context manager can\n // destroy the context only after it completes\n const wrapper = async (amplifyInstance) => {\n const result = await this._graphql(amplifyInstance, { query, variables, authMode }, headers, abortController, customUserAgentDetails, authToken);\n return result;\n };\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, authToken);\n default:\n throw new Error(`invalid operation type: ${operationType}`);\n }\n }\n async _graphql(amplify, { query, variables, authMode: explicitAuthMode }, additionalHeaders = {}, abortController, customUserAgentDetails, authToken) {\n const { region: region, endpoint: appSyncGraphqlEndpoint, customEndpoint, customEndpointRegion, defaultAuthMode, } = (0, utils_2.resolveConfig)(amplify);\n const authMode = explicitAuthMode || defaultAuthMode || 'iam';\n /**\n * Retrieve library options from Amplify configuration.\n * `customHeaders` here are from the Amplify configuration options,\n * and are for non-AppSync endpoints only. These are *not* the same as\n * `additionalHeaders`, which are custom headers that are either 1)\n * included when configuring the API client or 2) passed along with\n * individual requests.\n */\n const { headers: customHeaders, withCredentials } = (0, utils_2.resolveLibraryOptions)(amplify);\n /**\n * Client or request-specific custom headers that may or may not be\n * returned by a function:\n */\n let additionalCustomHeaders;\n if (typeof additionalHeaders === 'function') {\n const requestOptions = {\n method: 'POST',\n url: new utils_1.AmplifyUrl(customEndpoint || appSyncGraphqlEndpoint || '').toString(),\n queryString: (0, graphql_1.print)(query),\n };\n additionalCustomHeaders = await additionalHeaders(requestOptions);\n }\n else {\n additionalCustomHeaders = additionalHeaders;\n }\n // if an authorization header is set, have the explicit authToken take precedence\n if (authToken) {\n additionalCustomHeaders = {\n ...additionalCustomHeaders,\n Authorization: authToken,\n };\n }\n // TODO: Figure what we need to do to remove `!`'s.\n const headers = {\n ...(!customEndpoint &&\n (await this._headerBasedAuth(amplify, authMode, additionalCustomHeaders))),\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, additionalCustomHeaders)\n : {})) ||\n {}),\n // Custom headers included in Amplify configuration options:\n ...(customHeaders &&\n (await customHeaders({\n query: (0, graphql_1.print)(query),\n variables,\n }))),\n // Custom headers from individual requests or API client configuration:\n ...additionalCustomHeaders,\n // User agent headers:\n ...(!customEndpoint && {\n [USER_AGENT_HEADER]: (0, utils_1.getAmplifyUserAgent)(customUserAgentDetails),\n }),\n };\n const body = {\n query: (0, graphql_1.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 = undefined;\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 graphql_1.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(amplify, {\n url: new utils_1.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: [\n new graphql_1.GraphQLError(err.message, null, null, null, null, err),\n ],\n };\n }\n const { errors } = response;\n if (errors && errors.length) {\n throw (0, repackageAuthError_1.repackageUnauthError)(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, authToken) {\n const config = (0, utils_2.resolveConfig)(amplify);\n /**\n * Retrieve library options from Amplify configuration.\n * `libraryConfigHeaders` are from the Amplify configuration options,\n * and will not be overwritten by other custom headers. These are *not*\n * the same as `additionalHeaders`, which are custom headers that are\n * either 1)included when configuring the API client or 2) passed along\n * with individual requests.\n */\n const { headers: libraryConfigHeaders } = (0, utils_2.resolveLibraryOptions)(amplify);\n return this.appSyncRealTime\n .subscribe({\n query: (0, graphql_1.print)(query),\n variables,\n appSyncGraphqlEndpoint: config?.endpoint,\n region: config?.region,\n authenticationType: authMode || config?.defaultAuthMode,\n apiKey: config?.apiKey,\n additionalHeaders,\n authToken,\n libraryConfigHeaders,\n }, customUserAgentDetails)\n .pipe((0, rxjs_1.catchError)(e => {\n if (e.errors) {\n throw (0, repackageAuthError_1.repackageUnauthError)(e);\n }\n throw e;\n }));\n }\n}\nexports.InternalGraphQLAPIClass = InternalGraphQLAPIClass;\nexports.InternalGraphQLAPI = new InternalGraphQLAPIClass();\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,kBAAkB,GAAG,OAAO,CAAC,uBAAuB,GAAG,KAAK,CAAC,CAAC;AACtE;AACA;AACA,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;AACrC,MAAM,MAA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C,CAAC;AAC3D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ,MAAM,EAAE,OAAO,EAAE,oBAAoB,EAAE,GAAG,IAAI,OAAO,CAAC,qBAAqB,EAAE,OAAO,CAAC,CAAC;AAC9F,QAAQ,OAAO,IAAI,CAAC,eAAe;AACnC,aAAa,SAAS,CAAC;AACvB,YAAY,KAAK,EAAE,IAAI,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC;AAC9C,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,YAAY,SAAS;AACrB,YAAY,oBAAoB;AAChC,SAAS,EAAE,sBAAsB,CAAC;AAClC,aAAa,IAAI,CAAC,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC,IAAI;AAC9C,YAAY,IAAI,CAAC,CAAC,MAAM,EAAE;AAC1B,gBAAgB,MAAM,IAAI,oBAAoB,CAAC,oBAAoB,EAAE,CAAC,CAAC,CAAC;AACxE,aAAa;AACb,YAAY,MAAM,CAAC,CAAC;AACpB,SAAS,CAAC,CAAC,CAAC;AACZ,KAAK;AACL,CAAC;AACD,OAAO,CAAC,uBAAuB,GAAG,uBAAuB,CAAC;AAC1D,OAAO,CAAC,kBAAkB,GAAG,IAAI,uBAAuB,EAAE;;"}
1
+ {"version":3,"file":"InternalGraphQLAPI.js","sources":["../../../src/internals/InternalGraphQLAPI.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.InternalGraphQLAPI = exports.InternalGraphQLAPIClass = void 0;\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nconst graphql_1 = require(\"graphql\");\nconst rxjs_1 = require(\"rxjs\");\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst api_rest_1 = require(\"@aws-amplify/api-rest\");\nconst internals_1 = require(\"@aws-amplify/api-rest/internals\");\nconst AWSAppSyncRealTimeProvider_1 = require(\"../Providers/AWSAppSyncRealTimeProvider\");\nconst types_1 = require(\"../types\");\nconst utils_2 = require(\"../utils\");\nconst repackageAuthError_1 = require(\"../utils/errors/repackageAuthError\");\nconst USER_AGENT_HEADER = 'x-amz-user-agent';\nconst isAmplifyInstance = (amplify) => {\n return typeof amplify !== 'function';\n};\n/**\n * Export Cloud Logic APIs\n */\nclass InternalGraphQLAPIClass {\n constructor() {\n /**\n * @private\n */\n this.appSyncRealTime = new AWSAppSyncRealTimeProvider_1.AWSAppSyncRealTimeProvider();\n this._api = {\n post: internals_1.post,\n cancelREST: internals_1.cancel,\n isCancelErrorREST: api_rest_1.isCancelError,\n updateRequestToBeCancellable: internals_1.updateRequestToBeCancellable,\n };\n }\n getModuleName() {\n return 'InternalGraphQLAPI';\n }\n async _headerBasedAuth(amplify, authMode, additionalHeaders = {}) {\n const { apiKey } = (0, utils_2.resolveConfig)(amplify);\n let headers = {};\n switch (authMode) {\n case 'apiKey':\n if (!apiKey) {\n throw new Error(types_1.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(types_1.GraphQLAuthError.NO_CREDENTIALS);\n }\n break;\n }\n case 'oidc':\n case 'userPool':\n try {\n const token = (await amplify.Auth.fetchAuthSession()).tokens?.accessToken.toString();\n if (!token) {\n throw new Error(types_1.GraphQLAuthError.NO_FEDERATED_JWT);\n }\n headers = {\n Authorization: token,\n };\n }\n catch (e) {\n throw new Error(types_1.GraphQLAuthError.NO_CURRENT_USER);\n }\n break;\n case 'lambda':\n if (typeof additionalHeaders === 'object' &&\n !additionalHeaders.Authorization) {\n throw new Error(types_1.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 = (0, graphql_1.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 `libraryConfigHeaders` 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 ? (0, graphql_1.parse)(paramQuery)\n : (0, graphql_1.parse)((0, graphql_1.print)(paramQuery));\n const [operationDef = {}] = query.definitions.filter(def => def.kind === 'OperationDefinition');\n const { operation: operationType } = operationDef;\n const headers = additionalHeaders || {};\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, authToken);\n }\n else {\n // NOTE: this wrapper function must be await-able so the Amplify server context manager can\n // destroy the context only after it completes\n const wrapper = async (amplifyInstance) => {\n const result = await this._graphql(amplifyInstance, { query, variables, authMode }, headers, abortController, customUserAgentDetails, authToken);\n return result;\n };\n responsePromise = amplify(wrapper);\n }\n this._api.updateRequestToBeCancellable(responsePromise, abortController);\n return responsePromise;\n }\n case 'subscription':\n return this._graphqlSubscribe(amplify, { query, variables, authMode }, headers, customUserAgentDetails, authToken);\n default:\n throw new Error(`invalid operation type: ${operationType}`);\n }\n }\n async _graphql(amplify, { query, variables, authMode: explicitAuthMode }, additionalHeaders = {}, abortController, customUserAgentDetails, authToken) {\n const { region, endpoint: appSyncGraphqlEndpoint, customEndpoint, customEndpointRegion, defaultAuthMode, } = (0, utils_2.resolveConfig)(amplify);\n const authMode = explicitAuthMode || defaultAuthMode || 'iam';\n /**\n * Retrieve library options from Amplify configuration.\n * `customHeaders` here are from the Amplify configuration options,\n * and are for non-AppSync endpoints only. These are *not* the same as\n * `additionalHeaders`, which are custom headers that are either 1)\n * included when configuring the API client or 2) passed along with\n * individual requests.\n */\n const { headers: customHeaders, withCredentials } = (0, utils_2.resolveLibraryOptions)(amplify);\n /**\n * Client or request-specific custom headers that may or may not be\n * returned by a function:\n */\n let additionalCustomHeaders;\n if (typeof additionalHeaders === 'function') {\n const requestOptions = {\n method: 'POST',\n url: new utils_1.AmplifyUrl(customEndpoint || appSyncGraphqlEndpoint || '').toString(),\n queryString: (0, graphql_1.print)(query),\n };\n additionalCustomHeaders = await additionalHeaders(requestOptions);\n }\n else {\n additionalCustomHeaders = additionalHeaders;\n }\n // if an authorization header is set, have the explicit authToken take precedence\n if (authToken) {\n additionalCustomHeaders = {\n ...additionalCustomHeaders,\n Authorization: authToken,\n };\n }\n // TODO: Figure what we need to do to remove `!`'s.\n const headers = {\n ...(!customEndpoint &&\n (await this._headerBasedAuth(amplify, authMode, additionalCustomHeaders))),\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, additionalCustomHeaders)\n : {})) ||\n {}),\n // Custom headers included in Amplify configuration options:\n ...(customHeaders &&\n (await customHeaders({\n query: (0, graphql_1.print)(query),\n variables,\n }))),\n // Custom headers from individual requests or API client configuration:\n ...additionalCustomHeaders,\n // User agent headers:\n ...(!customEndpoint && {\n [USER_AGENT_HEADER]: (0, utils_1.getAmplifyUserAgent)(customUserAgentDetails),\n }),\n };\n const body = {\n query: (0, graphql_1.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 = undefined;\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 graphql_1.GraphQLError('No graphql endpoint provided.');\n // TODO(Eslint): refactor this to throw an Error instead of a plain object\n // eslint-disable-next-line no-throw-literal\n throw {\n data: {},\n errors: [error],\n };\n }\n let response;\n try {\n const { body: responseBody } = await this._api.post(amplify, {\n url: new utils_1.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: [\n new graphql_1.GraphQLError(err.message, null, null, null, null, err),\n ],\n };\n }\n const { errors } = response;\n if (errors && errors.length) {\n throw (0, repackageAuthError_1.repackageUnauthError)(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, authToken) {\n const config = (0, utils_2.resolveConfig)(amplify);\n /**\n * Retrieve library options from Amplify configuration.\n * `libraryConfigHeaders` are from the Amplify configuration options,\n * and will not be overwritten by other custom headers. These are *not*\n * the same as `additionalHeaders`, which are custom headers that are\n * either 1)included when configuring the API client or 2) passed along\n * with individual requests.\n */\n const { headers: libraryConfigHeaders } = (0, utils_2.resolveLibraryOptions)(amplify);\n return this.appSyncRealTime\n .subscribe({\n query: (0, graphql_1.print)(query),\n variables,\n appSyncGraphqlEndpoint: config?.endpoint,\n region: config?.region,\n authenticationType: authMode || config?.defaultAuthMode,\n apiKey: config?.apiKey,\n additionalHeaders,\n authToken,\n libraryConfigHeaders,\n }, customUserAgentDetails)\n .pipe((0, rxjs_1.catchError)(e => {\n if (e.errors) {\n throw (0, repackageAuthError_1.repackageUnauthError)(e);\n }\n throw e;\n }));\n }\n}\nexports.InternalGraphQLAPIClass = InternalGraphQLAPIClass;\nexports.InternalGraphQLAPI = new InternalGraphQLAPIClass();\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,kBAAkB,GAAG,OAAO,CAAC,uBAAuB,GAAG,KAAK,CAAC,CAAC;AACtE;AACA;AACA,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;AACrC,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AAC/B,MAAM,OAAO,GAAG,OAAO,CAAC,mCAAmC,CAAC,CAAC;AAC7D,MAAM,UAAU,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;AACpD,MAAM,WAAW,GAAG,OAAO,CAAC,iCAAiC,CAAC,CAAC;AAC/D,MAAM,4BAA4B,GAAG,OAAO,CAAC,yCAAyC,CAAC,CAAC;AACxF,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AACpC,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AACpC,MAAM,oBAAoB,GAAG,OAAO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S,EAAE,sBAAsB,CAAC;AAClC,aAAa,IAAI,CAAC,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC,IAAI;AAC9C,YAAY,IAAI,CAAC,CAAC,MAAM,EAAE;AAC1B,gBAAgB,MAAM,IAAI,oBAAoB,CAAC,oBAAoB,EAAE,CAAC,CAAC,CAAC;AACxE,aAAa;AACb,YAAY,MAAM,CAAC,CAAC;AACpB,SAAS,CAAC,CAAC,CAAC;AACZ,KAAK;AACL,CAAC;AACD,OAAO,CAAC,uBAAuB,GAAG,uBAAuB,CAAC;AAC1D,OAAO,CAAC,kBAAkB,GAAG,IAAI,uBAAuB,EAAE;;"}
@@ -5,12 +5,12 @@ exports.generateClient = void 0;
5
5
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
6
6
  // SPDX-License-Identifier: Apache-2.0
7
7
  const core_1 = require("@aws-amplify/core");
8
+ const types_1 = require("../types");
8
9
  const v6_1 = require("./v6");
9
10
  const generateEnumsProperty_1 = require("./utils/clientProperties/generateEnumsProperty");
10
11
  const generateModelsProperty_1 = require("./utils/clientProperties/generateModelsProperty");
11
12
  const isApiGraphQLProviderConfig_1 = require("./utils/runtimeTypeGuards/isApiGraphQLProviderConfig");
12
13
  const generateCustomOperationsProperty_1 = require("./generateCustomOperationsProperty");
13
- const types_1 = require("../types");
14
14
  const isConfigureEventWithResourceConfig_1 = require("./utils/runtimeTypeGuards/isConfigureEventWithResourceConfig");
15
15
  /**
16
16
  * @private
@@ -1 +1 @@
1
- {"version":3,"file":"generateClient.js","sources":["../../../src/internals/generateClient.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.generateClient = void 0;\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nconst core_1 = require(\"@aws-amplify/core\");\nconst v6_1 = require(\"./v6\");\nconst generateEnumsProperty_1 = require(\"./utils/clientProperties/generateEnumsProperty\");\nconst generateModelsProperty_1 = require(\"./utils/clientProperties/generateModelsProperty\");\nconst isApiGraphQLProviderConfig_1 = require(\"./utils/runtimeTypeGuards/isApiGraphQLProviderConfig\");\nconst generateCustomOperationsProperty_1 = require(\"./generateCustomOperationsProperty\");\nconst types_1 = require(\"../types\");\nconst isConfigureEventWithResourceConfig_1 = require(\"./utils/runtimeTypeGuards/isConfigureEventWithResourceConfig\");\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 */\nfunction generateClient(params) {\n const client = {\n [types_1.__amplify]: params.amplify,\n [types_1.__authMode]: params.authMode,\n [types_1.__authToken]: params.authToken,\n [types_1.__headers]: params.headers,\n graphql: v6_1.graphql,\n cancel: v6_1.cancel,\n isCancelError: v6_1.isCancelError,\n models: emptyProperty,\n enums: emptyProperty,\n queries: emptyProperty,\n mutations: emptyProperty,\n };\n const apiGraphqlConfig = params.amplify.getConfig().API?.GraphQL;\n if ((0, isApiGraphQLProviderConfig_1.isApiGraphQLConfig)(apiGraphqlConfig)) {\n client.models = (0, generateModelsProperty_1.generateModelsProperty)(client, apiGraphqlConfig);\n client.enums = (0, generateEnumsProperty_1.generateEnumsProperty)(apiGraphqlConfig);\n client.queries = (0, generateCustomOperationsProperty_1.generateCustomQueriesProperty)(client, apiGraphqlConfig);\n client.mutations = (0, generateCustomOperationsProperty_1.generateCustomMutationsProperty)(client, apiGraphqlConfig);\n }\n else {\n // This happens when the `Amplify.configure()` call gets evaluated after the `generateClient()` call.\n //\n // Cause: when the `generateClient()` and the `Amplify.configure()` calls are located in\n // different source files, script bundlers may randomly arrange their orders in the production\n // bundle.\n //\n // With the current implementation, the `client.models` instance created by `generateClient()`\n // will be rebuilt on every `Amplify.configure()` call that's provided with a valid GraphQL\n // provider configuration.\n //\n // TODO: revisit, and reverify this approach when enabling multiple clients for multi-endpoints\n // configuration.\n generateModelsPropertyOnAmplifyConfigure(client);\n }\n return client;\n}\nexports.generateClient = generateClient;\nconst generateModelsPropertyOnAmplifyConfigure = (clientRef) => {\n core_1.Hub.listen('core', coreEvent => {\n if (!(0, isConfigureEventWithResourceConfig_1.isConfigureEventWithResourceConfig)(coreEvent.payload)) {\n return;\n }\n const apiGraphQLConfig = coreEvent.payload.data.API?.GraphQL;\n if ((0, isApiGraphQLProviderConfig_1.isApiGraphQLConfig)(apiGraphQLConfig)) {\n clientRef.models = (0, generateModelsProperty_1.generateModelsProperty)(clientRef, apiGraphQLConfig);\n clientRef.enums = (0, generateEnumsProperty_1.generateEnumsProperty)(apiGraphQLConfig);\n clientRef.queries = (0, generateCustomOperationsProperty_1.generateCustomQueriesProperty)(clientRef, apiGraphQLConfig);\n clientRef.mutations = (0, generateCustomOperationsProperty_1.generateCustomMutationsProperty)(clientRef, apiGraphQLConfig);\n }\n });\n};\nconst emptyProperty = new Proxy({}, {\n get() {\n throw new Error('Client could not be generated. This is likely due to `Amplify.configure()` not being called prior to `generateClient()` or because the configuration passed to `Amplify.configure()` is missing GraphQL provider configuration.');\n },\n});\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,cAAc,GAAG,KAAK,CAAC,CAAC;AAChC;AACA;AACA,MAAM,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAC5C,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AAC7B,MAAM,uBAAuB,GAAG,OAAO,CAAC,gDAAgD,CAAC,CAAC;AAC1F,MAAM,wBAAwB,GAAG,OAAO,CAAC,iDAAiD,CAAC,CAAC;AAC5F,MAAM,4BAA4B,GAAG,OAAO,CAAC,sDAAsD,CAAC,CAAC;AACrG,MAAM,kCAAkC,GAAG,OAAO,CAAC,oCAAoC,CAAC,CAAC;AACzF,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AACp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AC,iOAAiO,CAAC,CAAC;AAC3P,KAAK;AACL,CAAC,CAAC;;"}
1
+ {"version":3,"file":"generateClient.js","sources":["../../../src/internals/generateClient.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.generateClient = void 0;\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nconst core_1 = require(\"@aws-amplify/core\");\nconst types_1 = require(\"../types\");\nconst v6_1 = require(\"./v6\");\nconst generateEnumsProperty_1 = require(\"./utils/clientProperties/generateEnumsProperty\");\nconst generateModelsProperty_1 = require(\"./utils/clientProperties/generateModelsProperty\");\nconst isApiGraphQLProviderConfig_1 = require(\"./utils/runtimeTypeGuards/isApiGraphQLProviderConfig\");\nconst generateCustomOperationsProperty_1 = require(\"./generateCustomOperationsProperty\");\nconst isConfigureEventWithResourceConfig_1 = require(\"./utils/runtimeTypeGuards/isConfigureEventWithResourceConfig\");\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 */\nfunction generateClient(params) {\n const client = {\n [types_1.__amplify]: params.amplify,\n [types_1.__authMode]: params.authMode,\n [types_1.__authToken]: params.authToken,\n [types_1.__headers]: params.headers,\n graphql: v6_1.graphql,\n cancel: v6_1.cancel,\n isCancelError: v6_1.isCancelError,\n models: emptyProperty,\n enums: emptyProperty,\n queries: emptyProperty,\n mutations: emptyProperty,\n };\n const apiGraphqlConfig = params.amplify.getConfig().API?.GraphQL;\n if ((0, isApiGraphQLProviderConfig_1.isApiGraphQLConfig)(apiGraphqlConfig)) {\n client.models = (0, generateModelsProperty_1.generateModelsProperty)(client, apiGraphqlConfig);\n client.enums = (0, generateEnumsProperty_1.generateEnumsProperty)(apiGraphqlConfig);\n client.queries = (0, generateCustomOperationsProperty_1.generateCustomQueriesProperty)(client, apiGraphqlConfig);\n client.mutations = (0, generateCustomOperationsProperty_1.generateCustomMutationsProperty)(client, apiGraphqlConfig);\n }\n else {\n // This happens when the `Amplify.configure()` call gets evaluated after the `generateClient()` call.\n //\n // Cause: when the `generateClient()` and the `Amplify.configure()` calls are located in\n // different source files, script bundlers may randomly arrange their orders in the production\n // bundle.\n //\n // With the current implementation, the `client.models` instance created by `generateClient()`\n // will be rebuilt on every `Amplify.configure()` call that's provided with a valid GraphQL\n // provider configuration.\n //\n // TODO: revisit, and reverify this approach when enabling multiple clients for multi-endpoints\n // configuration.\n generateModelsPropertyOnAmplifyConfigure(client);\n }\n return client;\n}\nexports.generateClient = generateClient;\nconst generateModelsPropertyOnAmplifyConfigure = (clientRef) => {\n core_1.Hub.listen('core', coreEvent => {\n if (!(0, isConfigureEventWithResourceConfig_1.isConfigureEventWithResourceConfig)(coreEvent.payload)) {\n return;\n }\n const apiGraphQLConfig = coreEvent.payload.data.API?.GraphQL;\n if ((0, isApiGraphQLProviderConfig_1.isApiGraphQLConfig)(apiGraphQLConfig)) {\n clientRef.models = (0, generateModelsProperty_1.generateModelsProperty)(clientRef, apiGraphQLConfig);\n clientRef.enums = (0, generateEnumsProperty_1.generateEnumsProperty)(apiGraphQLConfig);\n clientRef.queries = (0, generateCustomOperationsProperty_1.generateCustomQueriesProperty)(clientRef, apiGraphQLConfig);\n clientRef.mutations = (0, generateCustomOperationsProperty_1.generateCustomMutationsProperty)(clientRef, apiGraphQLConfig);\n }\n });\n};\nconst emptyProperty = new Proxy({}, {\n get() {\n throw new Error('Client could not be generated. This is likely due to `Amplify.configure()` not being called prior to `generateClient()` or because the configuration passed to `Amplify.configure()` is missing GraphQL provider configuration.');\n },\n});\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,cAAc,GAAG,KAAK,CAAC,CAAC;AAChC;AACA;AACA,MAAM,MAAM,GAAG,OAAO,CAAC,mBAAmB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nG,YAAY,SAAS,CAAC,OAAO,GAAG,IAAI,kCAAkC,CAAC,6BAA6B,EAAE,SAAS,EAAE,gBAAgB,CAAC,CAAC;AACnI,YAAY,SAAS,CAAC,SAAS,GAAG,IAAI,kCAAkC,CAAC,+BAA+B,EAAE,SAAS,EAAE,gBAAgB,CAAC,CAAC;AACvI,SAAS;AACT,KAAK,CAAC,CAAC;AACP,CAAC,CAAC;AACF,MAAM,aAAa,GAAG,IAAI,KAAK,CAAC,EAAE,EAAE;AACpC,IAAI,GAAG,GAAG;AACV,QAAQ,MAAM,IAAI,KAAK,CAAC,iOAAiO,CAAC,CAAC;AAC3P,KAAK;AACL,CAAC,CAAC;;"}
@@ -137,8 +137,8 @@ function outerArguments(operation) {
137
137
  * @returns "outer" arguments string
138
138
  */
139
139
  function innerArguments(operation) {
140
- const args = Object.entries(operation.arguments)
141
- .map(([k, v]) => `${k}: $${k}`)
140
+ const args = Object.keys(operation.arguments)
141
+ .map(k => `${k}: $${k}`)
142
142
  .join(', ');
143
143
  return args.length > 0 ? `(${args})` : '';
144
144
  }
@@ -1 +1 @@
1
- {"version":3,"file":"custom.js","sources":["../../../../src/internals/operations/custom.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.customOpFactory = void 0;\nconst APIClient_1 = require(\"../APIClient\");\n/**\n * Builds an operation function, embedded with all client and context data, that\n * can be attached to a client as a custom query or mutation.\n *\n * If we have this source schema:\n *\n * ```typescript\n * a.schema({\n * echo: a.query()\n * .arguments({input: a.string().required()})\n * .returns(a.string())\n * })\n * ```\n *\n * Our model intro schema will contain an entry like this:\n *\n * ```ts\n * {\n * queries: {\n * echo: {\n * name: \"echo\",\n * isArray: false,\n * type: 'String',\n * isRequired: false,\n * arguments: {\n * input: {\n * name: 'input',\n * isArray: false,\n * type: String,\n * isRequired: true\n * }\n * }\n * }\n * }\n * }\n * ```\n *\n * The `echo` object is used to build the `echo' method that goes here:\n *\n * ```typescript\n * const client = generateClent()\n * const { data } = await client.queries.echo({input: 'a string'});\n * // ^\n * // |\n * // +-- This one right here.\n * //\n * ```\n *\n *\n * @param client The client to run graphql queries through.\n * @param modelIntrospection The model introspection schema the op comes from.\n * @param operationType The broad category of graphql operation.\n * @param operation The operation definition from the introspection schema.\n * @param useContext Whether the function needs to accept an SSR context.\n * @returns The operation function to attach to query, mutations, etc.\n */\nfunction customOpFactory(client, modelIntrospection, operationType, operation, useContext) {\n const opWithContext = async (contextSpec, arg, options) => {\n return _op(client, modelIntrospection, operationType, operation, arg, options, contextSpec);\n };\n const op = async (arg, options) => {\n return _op(client, modelIntrospection, operationType, operation, arg, options);\n };\n return useContext ? opWithContext : op;\n}\nexports.customOpFactory = customOpFactory;\n/**\n * Runtime test and type guard to check whether `o[field]` is a `String`.\n *\n * ```typescript\n * if (hasStringField(o, 'prop')) {\n * const s = o.prop;\n * // ^? const s: string\n * }\n * ```\n *\n * @param o Object to inspect\n * @param field Field to look for\n * @returns Boolean: `true` if the `o[field]` is a `string`\n */\nfunction hasStringField(o, field) {\n return typeof o[field] === 'string';\n}\n/**\n * Generates \"outer\" arguments string for a custom operation. For example,\n * in this operation:\n *\n * ```graphql\n * query MyQuery(InputString: String!) {\n * echoString(InputString: $InputString)\n * }\n * ```\n *\n * This function returns the top/outer level arguments as a string:\n *\n * ```json\n * \"InputString: String!\"\n * ```\n *\n * @param operation Operation object from model introspection schema.\n * @returns \"outer\" arguments string\n */\nfunction outerArguments(operation) {\n const args = Object.entries(operation.arguments)\n .map(([k, v]) => {\n const baseType = v.type + (v.isRequired ? '!' : '');\n const finalType = v.isArray\n ? `[${baseType}]${v.isArrayNullable ? '' : '!'}`\n : baseType;\n return `$${k}: ${finalType}`;\n })\n .join(', ');\n return args.length > 0 ? `(${args})` : '';\n}\n/**\n * Generates \"inner\" arguments string for a custom operation. For example,\n * in this operation:\n *\n * ```graphql\n * query MyQuery(InputString: String!) {\n * echoString(InputString: $InputString)\n * }\n * ```\n *\n * This function returns the inner arguments as a string:\n *\n * ```json\n * \"InputString: $InputString\"\n * ```\n *\n * @param operation Operation object from model introspection schema.\n * @returns \"outer\" arguments string\n */\nfunction innerArguments(operation) {\n const args = Object.entries(operation.arguments)\n .map(([k, v]) => `${k}: $${k}`)\n .join(', ');\n return args.length > 0 ? `(${args})` : '';\n}\n/**\n * Generates the selection set string for a custom operation. This is slightly\n * different than the selection set generation for models. If the custom op returns\n * a primitive or enum types, it doen't require a selection set at all.\n *\n * E.g., the graphql might look like this:\n *\n * ```graphql\n * query MyQuery {\n * echoString(inputString: \"whatever\")\n * }\n * # ^\n * # |\n * # +-- no selection set\n * ```\n *\n * Non-primitive return type selection set generation will be similar to other\n * model operations.\n *\n * @param modelIntrospection The full code-generated introspection schema.\n * @param operation The operation object from the schema.\n * @returns The selection set as a string.\n */\nfunction operationSelectionSet(modelIntrospection, operation) {\n if (hasStringField(operation, 'type') ||\n hasStringField(operation.type, 'enum')) {\n return '';\n }\n else if (hasStringField(operation.type, 'nonModel')) {\n const nonModel = modelIntrospection.nonModels[operation.type.nonModel];\n return `{${(0, APIClient_1.selectionSetIRToString)((0, APIClient_1.defaultSelectionSetForNonModelWithIR)(nonModel, modelIntrospection))}}`;\n }\n else if (hasStringField(operation.type, 'model')) {\n return `{${(0, APIClient_1.generateSelectionSet)(modelIntrospection, operation.type.model)}}`;\n }\n else {\n return '';\n }\n}\n/**\n * Maps an arguments objec to graphql variables, removing superfluous args and\n * screaming loudly when required args are missing.\n *\n * @param operation The operation to construct graphql request variables for.\n * @param args The arguments to map variables from.\n * @returns The graphql variables object.\n */\nfunction operationVariables(operation, args = {}) {\n const variables = {};\n for (const argDef of Object.values(operation.arguments)) {\n if (typeof args[argDef.name] !== 'undefined') {\n variables[argDef.name] = args[argDef.name];\n }\n else if (argDef.isRequired) {\n // At this point, the variable is both required and missing: We don't need\n // to continue. The operation is expected to fail.\n throw new Error(`${operation.name} requires arguments '${argDef.name}'`);\n }\n }\n return variables;\n}\n/**\n * Executes an operation from the given model intro schema against a client, returning\n * a fully instantiated model when relevant.\n *\n * @param client The client to operate `graphql()` calls through.\n * @param modelIntrospection The model intro schema to construct requests from.\n * @param operationType The high level graphql operation type.\n * @param operation The specific operation name, args, return type details.\n * @param args The arguments to provide to the operation as variables.\n * @param options Request options like headers, etc.\n * @param context SSR context if relevant.\n * @returns Result from the graphql request, model-instantiated when relevant.\n */\nasync function _op(client, modelIntrospection, operationType, operation, args, options, context) {\n const { name: operationName } = operation;\n const auth = (0, APIClient_1.authModeParams)(client, options);\n const headers = (0, APIClient_1.getCustomHeaders)(client, options?.headers);\n const outerArgsString = outerArguments(operation);\n const innerArgsString = innerArguments(operation);\n const selectionSet = operationSelectionSet(modelIntrospection, operation);\n const returnTypeModelName = hasStringField(operation.type, 'model')\n ? operation.type.model\n : undefined;\n const query = `\n\t\t${operationType.toLocaleLowerCase()}${outerArgsString} {\n\t\t\t${operationName}${innerArgsString} ${selectionSet}\n\t\t}\n\t`;\n const variables = operationVariables(operation, args);\n try {\n const { data, extensions } = context\n ? (await client.graphql(context, {\n ...auth,\n query,\n variables,\n }, headers))\n : (await client.graphql({\n ...auth,\n query,\n variables,\n }, headers));\n // flatten response\n if (data) {\n const [key] = Object.keys(data);\n const flattenedResult = (0, APIClient_1.flattenItems)(data)[key];\n // TODO: custom selection set. current selection set is default selection set only\n // custom selection set requires data-schema-type + runtime updates above.\n const [initialized] = returnTypeModelName\n ? (0, APIClient_1.initializeModel)(client, returnTypeModelName, [flattenedResult], modelIntrospection, auth.authMode, auth.authToken, !!context)\n : [flattenedResult];\n return { data: initialized, extensions };\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":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,eAAe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ACrD,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
+ {"version":3,"file":"custom.js","sources":["../../../../src/internals/operations/custom.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.customOpFactory = void 0;\nconst APIClient_1 = require(\"../APIClient\");\n/**\n * Builds an operation function, embedded with all client and context data, that\n * can be attached to a client as a custom query or mutation.\n *\n * If we have this source schema:\n *\n * ```typescript\n * a.schema({\n * echo: a.query()\n * .arguments({input: a.string().required()})\n * .returns(a.string())\n * })\n * ```\n *\n * Our model intro schema will contain an entry like this:\n *\n * ```ts\n * {\n * queries: {\n * echo: {\n * name: \"echo\",\n * isArray: false,\n * type: 'String',\n * isRequired: false,\n * arguments: {\n * input: {\n * name: 'input',\n * isArray: false,\n * type: String,\n * isRequired: true\n * }\n * }\n * }\n * }\n * }\n * ```\n *\n * The `echo` object is used to build the `echo' method that goes here:\n *\n * ```typescript\n * const client = generateClent()\n * const { data } = await client.queries.echo({input: 'a string'});\n * // ^\n * // |\n * // +-- This one right here.\n * //\n * ```\n *\n *\n * @param client The client to run graphql queries through.\n * @param modelIntrospection The model introspection schema the op comes from.\n * @param operationType The broad category of graphql operation.\n * @param operation The operation definition from the introspection schema.\n * @param useContext Whether the function needs to accept an SSR context.\n * @returns The operation function to attach to query, mutations, etc.\n */\nfunction customOpFactory(client, modelIntrospection, operationType, operation, useContext) {\n const opWithContext = async (contextSpec, arg, options) => {\n return _op(client, modelIntrospection, operationType, operation, arg, options, contextSpec);\n };\n const op = async (arg, options) => {\n return _op(client, modelIntrospection, operationType, operation, arg, options);\n };\n return useContext ? opWithContext : op;\n}\nexports.customOpFactory = customOpFactory;\n/**\n * Runtime test and type guard to check whether `o[field]` is a `String`.\n *\n * ```typescript\n * if (hasStringField(o, 'prop')) {\n * const s = o.prop;\n * // ^? const s: string\n * }\n * ```\n *\n * @param o Object to inspect\n * @param field Field to look for\n * @returns Boolean: `true` if the `o[field]` is a `string`\n */\nfunction hasStringField(o, field) {\n return typeof o[field] === 'string';\n}\n/**\n * Generates \"outer\" arguments string for a custom operation. For example,\n * in this operation:\n *\n * ```graphql\n * query MyQuery(InputString: String!) {\n * echoString(InputString: $InputString)\n * }\n * ```\n *\n * This function returns the top/outer level arguments as a string:\n *\n * ```json\n * \"InputString: String!\"\n * ```\n *\n * @param operation Operation object from model introspection schema.\n * @returns \"outer\" arguments string\n */\nfunction outerArguments(operation) {\n const args = Object.entries(operation.arguments)\n .map(([k, v]) => {\n const baseType = v.type + (v.isRequired ? '!' : '');\n const finalType = v.isArray\n ? `[${baseType}]${v.isArrayNullable ? '' : '!'}`\n : baseType;\n return `$${k}: ${finalType}`;\n })\n .join(', ');\n return args.length > 0 ? `(${args})` : '';\n}\n/**\n * Generates \"inner\" arguments string for a custom operation. For example,\n * in this operation:\n *\n * ```graphql\n * query MyQuery(InputString: String!) {\n * echoString(InputString: $InputString)\n * }\n * ```\n *\n * This function returns the inner arguments as a string:\n *\n * ```json\n * \"InputString: $InputString\"\n * ```\n *\n * @param operation Operation object from model introspection schema.\n * @returns \"outer\" arguments string\n */\nfunction innerArguments(operation) {\n const args = Object.keys(operation.arguments)\n .map(k => `${k}: $${k}`)\n .join(', ');\n return args.length > 0 ? `(${args})` : '';\n}\n/**\n * Generates the selection set string for a custom operation. This is slightly\n * different than the selection set generation for models. If the custom op returns\n * a primitive or enum types, it doen't require a selection set at all.\n *\n * E.g., the graphql might look like this:\n *\n * ```graphql\n * query MyQuery {\n * echoString(inputString: \"whatever\")\n * }\n * # ^\n * # |\n * # +-- no selection set\n * ```\n *\n * Non-primitive return type selection set generation will be similar to other\n * model operations.\n *\n * @param modelIntrospection The full code-generated introspection schema.\n * @param operation The operation object from the schema.\n * @returns The selection set as a string.\n */\nfunction operationSelectionSet(modelIntrospection, operation) {\n if (hasStringField(operation, 'type') ||\n hasStringField(operation.type, 'enum')) {\n return '';\n }\n else if (hasStringField(operation.type, 'nonModel')) {\n const nonModel = modelIntrospection.nonModels[operation.type.nonModel];\n return `{${(0, APIClient_1.selectionSetIRToString)((0, APIClient_1.defaultSelectionSetForNonModelWithIR)(nonModel, modelIntrospection))}}`;\n }\n else if (hasStringField(operation.type, 'model')) {\n return `{${(0, APIClient_1.generateSelectionSet)(modelIntrospection, operation.type.model)}}`;\n }\n else {\n return '';\n }\n}\n/**\n * Maps an arguments objec to graphql variables, removing superfluous args and\n * screaming loudly when required args are missing.\n *\n * @param operation The operation to construct graphql request variables for.\n * @param args The arguments to map variables from.\n * @returns The graphql variables object.\n */\nfunction operationVariables(operation, args = {}) {\n const variables = {};\n for (const argDef of Object.values(operation.arguments)) {\n if (typeof args[argDef.name] !== 'undefined') {\n variables[argDef.name] = args[argDef.name];\n }\n else if (argDef.isRequired) {\n // At this point, the variable is both required and missing: We don't need\n // to continue. The operation is expected to fail.\n throw new Error(`${operation.name} requires arguments '${argDef.name}'`);\n }\n }\n return variables;\n}\n/**\n * Executes an operation from the given model intro schema against a client, returning\n * a fully instantiated model when relevant.\n *\n * @param client The client to operate `graphql()` calls through.\n * @param modelIntrospection The model intro schema to construct requests from.\n * @param operationType The high level graphql operation type.\n * @param operation The specific operation name, args, return type details.\n * @param args The arguments to provide to the operation as variables.\n * @param options Request options like headers, etc.\n * @param context SSR context if relevant.\n * @returns Result from the graphql request, model-instantiated when relevant.\n */\nasync function _op(client, modelIntrospection, operationType, operation, args, options, context) {\n const { name: operationName } = operation;\n const auth = (0, APIClient_1.authModeParams)(client, options);\n const headers = (0, APIClient_1.getCustomHeaders)(client, options?.headers);\n const outerArgsString = outerArguments(operation);\n const innerArgsString = innerArguments(operation);\n const selectionSet = operationSelectionSet(modelIntrospection, operation);\n const returnTypeModelName = hasStringField(operation.type, 'model')\n ? operation.type.model\n : undefined;\n const query = `\n\t\t${operationType.toLocaleLowerCase()}${outerArgsString} {\n\t\t\t${operationName}${innerArgsString} ${selectionSet}\n\t\t}\n\t`;\n const variables = operationVariables(operation, args);\n try {\n const { data, extensions } = context\n ? (await client.graphql(context, {\n ...auth,\n query,\n variables,\n }, headers))\n : (await client.graphql({\n ...auth,\n query,\n variables,\n }, headers));\n // flatten response\n if (data) {\n const [key] = Object.keys(data);\n const flattenedResult = (0, APIClient_1.flattenItems)(data)[key];\n // TODO: custom selection set. current selection set is default selection set only\n // custom selection set requires data-schema-type + runtime updates above.\n const [initialized] = returnTypeModelName\n ? (0, APIClient_1.initializeModel)(client, returnTypeModelName, [flattenedResult], modelIntrospection, auth.authMode, auth.authToken, !!context)\n : [flattenedResult];\n return { data: initialized, extensions };\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":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,eAAe,GAAG,KAAK,CAAC,CAAC;AACjC,MAAM,WAAW,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;AAC5C;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,SAAS,eAAe,CAAC,MAA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AG,IAAI;AACvB,gBAAgB,KAAK;AACrB,gBAAgB,SAAS;AACzB,aAAa,EAAE,OAAO,CAAC;AACvB,eAAe,MAAM,MAAM,CAAC,OAAO,CAAC;AACpC,gBAAgB,GAAG,IAAI;AACvB,gBAAgB,KAAK;AACrB,gBAAgB,SAAS;AACzB,aAAa,EAAE,OAAO,CAAC,CAAC,CAAC;AACzB;AACA,QAAQ,IAAI,IAAI,EAAE;AAClB,YAAY,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC5C,YAAY,MAAM,eAAe,GAAG,CAAC,CAAC,EAAE,WAAW,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;AAC7E;AACA;AACA,YAAY,MAAM,CAAC,WAAW,CAAC,GAAG,mBAAmB;AACrD,kBAAkB,CAAC,CAAC,EAAE,WAAW,CAAC,eAAe,EAAE,MAAM,EAAE,mBAAmB,EAAE,CAAC,eAAe,CAAC,EAAE,kBAAkB,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,OAAO,CAAC;AAChK,kBAAkB,CAAC,eAAe,CAAC,CAAC;AACpC,YAAY,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC;AACrD,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;;"}
@@ -20,7 +20,7 @@ async function _list(client, modelIntrospection, model, args, contextSpec) {
20
20
  try {
21
21
  const auth = (0, APIClient_1.authModeParams)(client, args);
22
22
  const headers = (0, APIClient_1.getCustomHeaders)(client, args?.headers);
23
- const { data, extensions } = !!contextSpec
23
+ const { data, extensions } = contextSpec
24
24
  ? (await client.graphql(contextSpec, {
25
25
  ...auth,
26
26
  query,
@@ -1 +1 @@
1
- {"version":3,"file":"list.js","sources":["../../../../src/internals/operations/list.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.listFactory = void 0;\nconst APIClient_1 = require(\"../APIClient\");\nfunction 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);\n };\n return context ? listWithContext : list;\n}\nexports.listFactory = listFactory;\nasync function _list(client, modelIntrospection, model, args, contextSpec) {\n const { name } = model;\n const query = (0, APIClient_1.generateGraphQLDocument)(modelIntrospection, name, 'LIST', args);\n const variables = (0, APIClient_1.buildGraphQLVariables)(model, 'LIST', args, modelIntrospection);\n try {\n const auth = (0, APIClient_1.authModeParams)(client, args);\n const headers = (0, APIClient_1.getCustomHeaders)(client, args?.headers);\n const { data, extensions } = !!contextSpec\n ? (await client.graphql(contextSpec, {\n ...auth,\n query,\n variables,\n }, headers))\n : (await client.graphql({\n ...auth,\n query,\n variables,\n }, headers));\n // flatten response\n if (data !== undefined) {\n const [key] = Object.keys(data);\n if (data[key].items) {\n const flattenedResult = (0, APIClient_1.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 = (0, APIClient_1.initializeModel)(client, name, flattenedResult, modelIntrospection, auth.authMode, auth.authToken, !!contextSpec);\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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EAAE,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC;AAC1K,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
+ {"version":3,"file":"list.js","sources":["../../../../src/internals/operations/list.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.listFactory = void 0;\nconst APIClient_1 = require(\"../APIClient\");\nfunction 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);\n };\n return context ? listWithContext : list;\n}\nexports.listFactory = listFactory;\nasync function _list(client, modelIntrospection, model, args, contextSpec) {\n const { name } = model;\n const query = (0, APIClient_1.generateGraphQLDocument)(modelIntrospection, name, 'LIST', args);\n const variables = (0, APIClient_1.buildGraphQLVariables)(model, 'LIST', args, modelIntrospection);\n try {\n const auth = (0, APIClient_1.authModeParams)(client, args);\n const headers = (0, APIClient_1.getCustomHeaders)(client, args?.headers);\n const { data, extensions } = contextSpec\n ? (await client.graphql(contextSpec, {\n ...auth,\n query,\n variables,\n }, headers))\n : (await client.graphql({\n ...auth,\n query,\n variables,\n }, headers));\n // flatten response\n if (data !== undefined) {\n const [key] = Object.keys(data);\n if (data[key].items) {\n const flattenedResult = (0, APIClient_1.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 = (0, APIClient_1.initializeModel)(client, name, flattenedResult, modelIntrospection, auth.authMode, auth.authToken, !!contextSpec);\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":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,WAAW,GAAG,KAAK,CAAC,CAAC;AAC7B,MAAM,WAAW,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;AAC5C,SAAS,WAAW,CAAC,MAAM,EAAE,kBAAkB,EAAE,KAAK,EAAE,OAAO,GAAG,KAAK,EAAE;AACzE,IAAI,MAAM,eAAe,GAAG,OAAO,WAAW,EAAE,IAAI,KAAK;AACzD,QAAQ,OAAO,KAAK,CAAC,MAAM,EAAE,kBAAkB,EAAE,KAAK,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC;AAC3E,KAAK,CAAC;AACN,IAAI,MAAM,IAAI,GAAG,OAAO,IAAI,KAAK;AACjC,QAAQ,OAAO,KAAK,CAAC,MAAM,EAAE,kBAAkB,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;AAC9D,KAAK,CAAC;AACN,IAAI,OAAO,OAAO,GAAG,eAAe,GAAG,IAAI,CAAC;AAC5C,CAAC;AACD,OAAO,C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,GAAG,CAAC,CAAC,EAAE,WAAW,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;AACjF;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,CAAC,CAAC,EAAE,WAAW,CAAC,eAAe,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE,kBAAkB,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC;AAC1K,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;;"}
@@ -5,11 +5,11 @@
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.generateClientWithAmplifyInstance = void 0;
7
7
  const __1 = require("..");
8
- const generateModelsProperty_1 = require("./generateModelsProperty");
9
8
  const types_1 = require("../../types");
10
9
  const isApiGraphQLProviderConfig_1 = require("../utils/runtimeTypeGuards/isApiGraphQLProviderConfig");
11
10
  const generateEnumsProperty_1 = require("../utils/clientProperties/generateEnumsProperty");
12
11
  const generateCustomOperationsProperty_1 = require("../generateCustomOperationsProperty");
12
+ const generateModelsProperty_1 = require("./generateModelsProperty");
13
13
  /**
14
14
  * @private
15
15
  *
@@ -1 +1 @@
1
- {"version":3,"file":"generateClientWithAmplifyInstance.js","sources":["../../../../src/internals/server/generateClientWithAmplifyInstance.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.generateClientWithAmplifyInstance = void 0;\nconst __1 = require(\"..\");\nconst generateModelsProperty_1 = require(\"./generateModelsProperty\");\nconst types_1 = require(\"../../types\");\nconst isApiGraphQLProviderConfig_1 = require(\"../utils/runtimeTypeGuards/isApiGraphQLProviderConfig\");\nconst generateEnumsProperty_1 = require(\"../utils/clientProperties/generateEnumsProperty\");\nconst generateCustomOperationsProperty_1 = require(\"../generateCustomOperationsProperty\");\n/**\n * @private\n *\n * Used internally by `adapter-nextjs` package.\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 */\nfunction generateClientWithAmplifyInstance(params) {\n const client = {\n [types_1.__amplify]: params.amplify,\n [types_1.__authMode]: params.authMode,\n [types_1.__authToken]: params.authToken,\n [types_1.__headers]: params.headers,\n graphql: __1.graphql,\n cancel: __1.cancel,\n isCancelError: __1.isCancelError,\n };\n const apiGraphqlConfig = params.config?.API?.GraphQL;\n if ((0, isApiGraphQLProviderConfig_1.isApiGraphQLConfig)(apiGraphqlConfig)) {\n client.models = (0, generateModelsProperty_1.generateModelsProperty)(client, params);\n client.enums = (0, generateEnumsProperty_1.generateEnumsProperty)(apiGraphqlConfig);\n client.queries = (0, generateCustomOperationsProperty_1.generateCustomQueriesProperty)(client, apiGraphqlConfig);\n client.mutations = (0, generateCustomOperationsProperty_1.generateCustomMutationsProperty)(client, apiGraphqlConfig);\n }\n return client;\n}\nexports.generateClientWithAmplifyInstance = generateClientWithAmplifyInstance;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,iCAAiC,GAAG,KAAK,CAAC,CAAC;AACnD,MAAM,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAC1B,MAAM,wBAAwB,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAAC;AACrE,MAAM,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AACvC,MAAM,4BAA4B,GAAG,OAAO,CAAC,uDAAuD,CAAC,CAAC;AACtG,MAAM,uBAAuB,GAAG,OAAO,CAAC,iDAAiD,CAAC,CAAC;AAC3F,MAAM,kCAAkC,GAAG,OAAO,CAAC,qCAAqC,CAAC,CAAC;AAC1F;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,iCAAiC,CAAC,MAAM,EAAE;AACnD,IAAI,MAAM,MAAM,GAAG;AACnB,QAAQ,CAAC,OAAO,CAAC,SAAS,GAAG,MAAM,CAAC,OAAO;AAC3C,QAAQ,CAAC,OAAO,CAAC,UAAU,GAAG,MAAM,CAAC,QAAQ;AAC7C,QAAQ,CAAC,OAAO,CAAC,WAAW,GAAG,MAAM,CAAC,SAAS;AAC/C,QAAQ,CAAC,OAAO,CAAC,SAAS,GAAG,MAAM,CAAC,OAAO;AAC3C,QAAQ,OAAO,EAAE,GAAG,CAAC,OAAO;AAC5B,QAAQ,MAAM,EAAE,GAAG,CAAC,MAAM;AAC1B,QAAQ,aAAa,EAAE,GAAG,CAAC,aAAa;AACxC,KAAK,CAAC;AACN,IAAI,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,CAAC;AACzD,IAAI,IAAI,IAAI,4BAA4B,CAAC,kBAAkB,EAAE,gBAAgB,CAAC,EAAE;AAChF,QAAQ,MAAM,CAAC,MAAM,GAAG,IAAI,wBAAwB,CAAC,sBAAsB,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAC7F,QAAQ,MAAM,CAAC,KAAK,GAAG,IAAI,uBAAuB,CAAC,qBAAqB,EAAE,gBAAgB,CAAC,CAAC;AAC5F,QAAQ,MAAM,CAAC,OAAO,GAAG,IAAI,kCAAkC,CAAC,6BAA6B,EAAE,MAAM,EAAE,gBAAgB,CAAC,CAAC;AACzH,QAAQ,MAAM,CAAC,SAAS,GAAG,IAAI,kCAAkC,CAAC,+BAA+B,EAAE,MAAM,EAAE,gBAAgB,CAAC,CAAC;AAC7H,KAAK;AACL,IAAI,OAAO,MAAM,CAAC;AAClB,CAAC;AACD,OAAO,CAAC,iCAAiC,GAAG,iCAAiC;;"}
1
+ {"version":3,"file":"generateClientWithAmplifyInstance.js","sources":["../../../../src/internals/server/generateClientWithAmplifyInstance.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.generateClientWithAmplifyInstance = void 0;\nconst __1 = require(\"..\");\nconst types_1 = require(\"../../types\");\nconst isApiGraphQLProviderConfig_1 = require(\"../utils/runtimeTypeGuards/isApiGraphQLProviderConfig\");\nconst generateEnumsProperty_1 = require(\"../utils/clientProperties/generateEnumsProperty\");\nconst generateCustomOperationsProperty_1 = require(\"../generateCustomOperationsProperty\");\nconst generateModelsProperty_1 = require(\"./generateModelsProperty\");\n/**\n * @private\n *\n * Used internally by `adapter-nextjs` package.\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 */\nfunction generateClientWithAmplifyInstance(params) {\n const client = {\n [types_1.__amplify]: params.amplify,\n [types_1.__authMode]: params.authMode,\n [types_1.__authToken]: params.authToken,\n [types_1.__headers]: params.headers,\n graphql: __1.graphql,\n cancel: __1.cancel,\n isCancelError: __1.isCancelError,\n };\n const apiGraphqlConfig = params.config?.API?.GraphQL;\n if ((0, isApiGraphQLProviderConfig_1.isApiGraphQLConfig)(apiGraphqlConfig)) {\n client.models = (0, generateModelsProperty_1.generateModelsProperty)(client, params);\n client.enums = (0, generateEnumsProperty_1.generateEnumsProperty)(apiGraphqlConfig);\n client.queries = (0, generateCustomOperationsProperty_1.generateCustomQueriesProperty)(client, apiGraphqlConfig);\n client.mutations = (0, generateCustomOperationsProperty_1.generateCustomMutationsProperty)(client, apiGraphqlConfig);\n }\n return client;\n}\nexports.generateClientWithAmplifyInstance = generateClientWithAmplifyInstance;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,iCAAiC,GAAG,KAAK,CAAC,CAAC;AACnD,MAAM,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAC1B,MAAM,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AACvC,MAAM,4BAA4B,GAAG,OAAO,CAAC,uDAAuD,CAAC,CAAC;AACtG,MAAM,uBAAuB,GAAG,OAAO,CAAC,iDAAiD,CAAC,CAAC;AAC3F,MAAM,kCAAkC,GAAG,OAAO,CAAC,qCAAqC,CAAC,CAAC;AAC1F,MAAM,wBAAwB,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAAC;AACrE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,iCAAiC,CAAC,MAAM,EAAE;AACnD,IAAI,MAAM,MAAM,GAAG;AACnB,QAAQ,CAAC,OAAO,CAAC,SAAS,GAAG,MAAM,CAAC,OAAO;AAC3C,QAAQ,CAAC,OAAO,CAAC,UAAU,GAAG,MAAM,CAAC,QAAQ;AAC7C,QAAQ,CAAC,OAAO,CAAC,WAAW,GAAG,MAAM,CAAC,SAAS;AAC/C,QAAQ,CAAC,OAAO,CAAC,SAAS,GAAG,MAAM,CAAC,OAAO;AAC3C,QAAQ,OAAO,EAAE,GAAG,CAAC,OAAO;AAC5B,QAAQ,MAAM,EAAE,GAAG,CAAC,MAAM;AAC1B,QAAQ,aAAa,EAAE,GAAG,CAAC,aAAa;AACxC,KAAK,CAAC;AACN,IAAI,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,CAAC;AACzD,IAAI,IAAI,IAAI,4BAA4B,CAAC,kBAAkB,EAAE,gBAAgB,CAAC,EAAE;AAChF,QAAQ,MAAM,CAAC,MAAM,GAAG,IAAI,wBAAwB,CAAC,sBAAsB,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAC7F,QAAQ,MAAM,CAAC,KAAK,GAAG,IAAI,uBAAuB,CAAC,qBAAqB,EAAE,gBAAgB,CAAC,CAAC;AAC5F,QAAQ,MAAM,CAAC,OAAO,GAAG,IAAI,kCAAkC,CAAC,6BAA6B,EAAE,MAAM,EAAE,gBAAgB,CAAC,CAAC;AACzH,QAAQ,MAAM,CAAC,SAAS,GAAG,IAAI,kCAAkC,CAAC,+BAA+B,EAAE,MAAM,EAAE,gBAAgB,CAAC,CAAC;AAC7H,KAAK;AACL,IAAI,OAAO,MAAM,CAAC;AAClB,CAAC;AACD,OAAO,CAAC,iCAAiC,GAAG,iCAAiC;;"}
@@ -9,7 +9,7 @@ const get_1 = require("../operations/get");
9
9
  const clientUtils_1 = require("../clientUtils");
10
10
  function generateModelsProperty(client, params) {
11
11
  const models = {};
12
- const config = params.config;
12
+ const { config } = params;
13
13
  const useContext = params.amplify === null;
14
14
  if (!config) {
15
15
  throw new Error('generateModelsProperty cannot retrieve Amplify config');
@@ -1 +1 @@
1
- {"version":3,"file":"generateModelsProperty.js","sources":["../../../../src/internals/server/generateModelsProperty.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.generateModelsProperty = void 0;\nconst APIClient_1 = require(\"../APIClient\");\nconst list_1 = require(\"../operations/list\");\nconst indexQuery_1 = require(\"../operations/indexQuery\");\nconst get_1 = require(\"../operations/get\");\nconst clientUtils_1 = require(\"../clientUtils\");\nfunction generateModelsProperty(client, params) {\n const models = {};\n const config = params.config;\n const useContext = params.amplify === null;\n if (!config) {\n throw new Error('generateModelsProperty cannot retrieve Amplify config');\n }\n if (!config.API?.GraphQL) {\n return {};\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(APIClient_1.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] = (0, list_1.listFactory)(client, modelIntrospection, model, useContext);\n }\n else {\n models[name][operationPrefix] = (0, get_1.getFactory)(client, modelIntrospection, model, operation, useContext);\n }\n });\n const secondaryIdxs = (0, clientUtils_1.getSecondaryIndexesFromSchemaModel)(model);\n for (const idx of secondaryIdxs) {\n models[name][idx.queryField] = (0, indexQuery_1.indexQueryFactory)(client, modelIntrospection, model, idx);\n }\n }\n return models;\n}\nexports.generateModelsProperty = generateModelsProperty;\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,C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E,CAAC;AAC1B,QAAQ,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,qBAAqB,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,EAAE,eAAe,EAAE,CAAC,KAAK;AAClG,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,IAAI,MAAM,CAAC,WAAW,EAAE,MAAM,EAAE,kBAAkB,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC;AACvH,aAAa;AACb,iBAAiB;AACjB,gBAAgB,MAAM,CAAC,IAAI,CAAC,CAAC,eAAe,CAAC,GAAG,IAAI,KAAK,CAAC,UAAU,EAAE,MAAM,EAAE,kBAAkB,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC;AAChI,aAAa;AACb,SAAS,CAAC,CAAC;AACX,QAAQ,MAAM,aAAa,GAAG,IAAI,aAAa,CAAC,kCAAkC,EAAE,KAAK,CAAC,CAAC;AAC3F,QAAQ,KAAK,MAAM,GAAG,IAAI,aAAa,EAAE;AACzC,YAAY,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,IAAI,YAAY,CAAC,iBAAiB,EAAE,MAAM,EAAE,kBAAkB,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;AACvH,SAAS;AACT,KAAK;AACL,IAAI,OAAO,MAAM,CAAC;AAClB,CAAC;AACD,OAAO,CAAC,sBAAsB,GAAG,sBAAsB;;"}
1
+ {"version":3,"file":"generateModelsProperty.js","sources":["../../../../src/internals/server/generateModelsProperty.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.generateModelsProperty = void 0;\nconst APIClient_1 = require(\"../APIClient\");\nconst list_1 = require(\"../operations/list\");\nconst indexQuery_1 = require(\"../operations/indexQuery\");\nconst get_1 = require(\"../operations/get\");\nconst clientUtils_1 = require(\"../clientUtils\");\nfunction generateModelsProperty(client, params) {\n const models = {};\n const { config } = params;\n const useContext = params.amplify === null;\n if (!config) {\n throw new Error('generateModelsProperty cannot retrieve Amplify config');\n }\n if (!config.API?.GraphQL) {\n return {};\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(APIClient_1.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] = (0, list_1.listFactory)(client, modelIntrospection, model, useContext);\n }\n else {\n models[name][operationPrefix] = (0, get_1.getFactory)(client, modelIntrospection, model, operation, useContext);\n }\n });\n const secondaryIdxs = (0, clientUtils_1.getSecondaryIndexesFromSchemaModel)(model);\n for (const idx of secondaryIdxs) {\n models[name][idx.queryField] = (0, indexQuery_1.indexQueryFactory)(client, modelIntrospection, model, idx);\n }\n }\n return models;\n}\nexports.generateModelsProperty = generateModelsProperty;\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,sBAAsB,GAAG,KAAK,CAAC,CAAC;AACxC,MAAM,WAAW,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;AAC5C,MAAM,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;AAC7C,MAAM,YAAY,GAAG,OAAO,CAAC,0BAA0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C;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,IAAI,MAAM,CAAC,WAAW,EAAE,MAAM,EAAE,kBAAkB,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC;AACvH,aAAa;AACb,iBAAiB;AACjB,gBAAgB,MAAM,CAAC,IAAI,CAAC,CAAC,eAAe,CAAC,GAAG,IAAI,KAAK,CAAC,UAAU,EAAE,MAAM,EAAE,kBAAkB,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC;AAChI,aAAa;AACb,SAAS,CAAC,CAAC;AACX,QAAQ,MAAM,aAAa,GAAG,IAAI,aAAa,CAAC,kCAAkC,EAAE,KAAK,CAAC,CAAC;AAC3F,QAAQ,KAAK,MAAM,GAAG,IAAI,aAAa,EAAE;AACzC,YAAY,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,IAAI,YAAY,CAAC,iBAAiB,EAAE,MAAM,EAAE,kBAAkB,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;AACvH,SAAS;AACT,KAAK;AACL,IAAI,OAAO,MAAM,CAAC;AAClB,CAAC;AACD,OAAO,CAAC,sBAAsB,GAAG,sBAAsB;;"}
@@ -2,8 +2,6 @@
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.isCancelError = exports.cancel = exports.graphql = void 0;
5
- // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
6
- // SPDX-License-Identifier: Apache-2.0
7
5
  const GraphQLAPI_1 = require("../GraphQLAPI");
8
6
  const types_1 = require("../types");
9
7
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"v6.js","sources":["../../../src/internals/v6.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.isCancelError = exports.cancel = exports.graphql = void 0;\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nconst GraphQLAPI_1 = require(\"../GraphQLAPI\");\nconst types_1 = require(\"../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 */\nfunction graphql(options, additionalHeaders) {\n // inject client-level auth\n options.authMode = options.authMode || this[types_1.__authMode];\n options.authToken = options.authToken || this[types_1.__authToken];\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_1.GraphQLAPI.graphql(this[types_1.__amplify], options, additionalHeaders);\n return result;\n}\nexports.graphql = graphql;\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 */\nfunction cancel(promise, message) {\n return GraphQLAPI_1.GraphQLAPI.cancel(promise, message);\n}\nexports.cancel = cancel;\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 */\nfunction isCancelError(error) {\n return GraphQLAPI_1.GraphQLAPI.isCancelError(error);\n}\nexports.isCancelError = isCancelError;\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,aAAa,GAAG,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,KAAK,CAAC,CAAC;AAClE;AACA;AACA,MAAM,YAAY,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;AAC9C,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AACpC;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;AACA,SAAS,OAAO,CAAC,OAAO,EAAE,iBAAiB,EAAE;AAC7C;AACA,IAAI,OAAO,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;AACpE,IAAI,OAAO,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;AACvE;AACA;AACA;AACA;AACA;AACA,IAAI,MAAM,MAAM,GAAG,YAAY,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,iBAAiB,CAAC,CAAC;AACxG,IAAI,OAAO,MAAM,CAAC;AAClB,CAAC;AACD,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC;AAC1B;AACA;AACA;AACA;AACA;AACA,SAAS,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE;AAClC,IAAI,OAAO,YAAY,CAAC,UAAU,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AAC5D,CAAC;AACD,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC;AACxB;AACA;AACA;AACA;AACA;AACA,SAAS,aAAa,CAAC,KAAK,EAAE;AAC9B,IAAI,OAAO,YAAY,CAAC,UAAU,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;AACxD,CAAC;AACD,OAAO,CAAC,aAAa,GAAG,aAAa;;"}
1
+ {"version":3,"file":"v6.js","sources":["../../../src/internals/v6.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.isCancelError = exports.cancel = exports.graphql = void 0;\nconst GraphQLAPI_1 = require(\"../GraphQLAPI\");\nconst types_1 = require(\"../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 */\nfunction graphql(options, additionalHeaders) {\n // inject client-level auth\n options.authMode = options.authMode || this[types_1.__authMode];\n options.authToken = options.authToken || this[types_1.__authToken];\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_1.GraphQLAPI.graphql(this[types_1.__amplify], options, additionalHeaders);\n return result;\n}\nexports.graphql = graphql;\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 */\nfunction cancel(promise, message) {\n return GraphQLAPI_1.GraphQLAPI.cancel(promise, message);\n}\nexports.cancel = cancel;\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 */\nfunction isCancelError(error) {\n return GraphQLAPI_1.GraphQLAPI.isCancelError(error);\n}\nexports.isCancelError = isCancelError;\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,aAAa,GAAG,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,KAAK,CAAC,CAAC;AAClE,MAAM,YAAY,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;AAC9C,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AACpC;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;AACA,SAAS,OAAO,CAAC,OAAO,EAAE,iBAAiB,EAAE;AAC7C;AACA,IAAI,OAAO,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;AACpE,IAAI,OAAO,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;AACvE;AACA;AACA;AACA;AACA;AACA,IAAI,MAAM,MAAM,GAAG,YAAY,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,iBAAiB,CAAC,CAAC;AACxG,IAAI,OAAO,MAAM,CAAC;AAClB,CAAC;AACD,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC;AAC1B;AACA;AACA;AACA;AACA;AACA,SAAS,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE;AAClC,IAAI,OAAO,YAAY,CAAC,UAAU,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AAC5D,CAAC;AACD,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC;AACxB;AACA;AACA;AACA;AACA;AACA,SAAS,aAAa,CAAC,KAAK,EAAE;AAC9B,IAAI,OAAO,YAAY,CAAC,UAAU,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;AACxD,CAAC;AACD,OAAO,CAAC,aAAa,GAAG,aAAa;;"}
@@ -26,7 +26,7 @@ function repackageUnauthError(content) {
26
26
  exports.repackageUnauthError = repackageUnauthError;
27
27
  function isUnauthError(error) {
28
28
  // Error pattern corresponding to appsync calls
29
- if (error?.['originalError']?.['name']?.startsWith('UnauthorizedException')) {
29
+ if (error?.originalError?.name?.startsWith('UnauthorizedException')) {
30
30
  return true;
31
31
  }
32
32
  // Error pattern corresponding to appsync subscriptions
@@ -1 +1 @@
1
- {"version":3,"file":"repackageAuthError.js","sources":["../../../../src/utils/errors/repackageAuthError.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.repackageUnauthError = void 0;\n/**\n * Checks to see if the given response or subscription message contains an\n * unauth error. If it does, it changes the error message to include instructions\n * for the app developer.\n */\nfunction repackageUnauthError(content) {\n if (content.errors && Array.isArray(content.errors)) {\n content.errors.forEach(e => {\n if (isUnauthError(e)) {\n e.message = 'Unauthorized';\n e.recoverySuggestion =\n `If you're calling an Amplify-generated API, make sure ` +\n `to set the \"authMode\" in generateClient({ authMode: '...' }) to the backend authorization ` +\n `rule's auth provider ('apiKey', 'userPool', 'iam', 'oidc', 'lambda')`;\n }\n });\n }\n return content;\n}\nexports.repackageUnauthError = repackageUnauthError;\nfunction isUnauthError(error) {\n // Error pattern corresponding to appsync calls\n if (error?.['originalError']?.['name']?.startsWith('UnauthorizedException')) {\n return true;\n }\n // Error pattern corresponding to appsync subscriptions\n if (error.message?.startsWith('Connection failed:') &&\n error.message?.includes('Permission denied')) {\n return true;\n }\n return false;\n}\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,oBAAoB,GAAG,KAAK,CAAC,CAAC;AACtC;AACA;AACA;AACA;AACA;AACA,SAAS,oBAAoB,CAAC,OAAO,EAAE;AACvC,IAAI,IAAI,OAAO,CAAC,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;AACzD,QAAQ,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI;AACpC,YAAY,IAAI,aAAa,CAAC,CAAC,CAAC,EAAE;AAClC,gBAAgB,CAAC,CAAC,OAAO,GAAG,cAAc,CAAC;AAC3C,gBAAgB,CAAC,CAAC,kBAAkB;AACpC,oBAAoB,CAAC,sDAAsD,CAAC;AAC5E,wBAAwB,CAAC,0FAA0F,CAAC;AACpH,wBAAwB,CAAC,oEAAoE,CAAC,CAAC;AAC/F,aAAa;AACb,SAAS,CAAC,CAAC;AACX,KAAK;AACL,IAAI,OAAO,OAAO,CAAC;AACnB,CAAC;AACD,OAAO,CAAC,oBAAoB,GAAG,oBAAoB,CAAC;AACpD,SAAS,aAAa,CAAC,KAAK,EAAE;AAC9B;AACA,IAAI,IAAI,KAAK,GAAG,eAAe,CAAC,GAAG,MAAM,CAAC,EAAE,UAAU,CAAC,uBAAuB,CAAC,EAAE;AACjF,QAAQ,OAAO,IAAI,CAAC;AACpB,KAAK;AACL;AACA,IAAI,IAAI,KAAK,CAAC,OAAO,EAAE,UAAU,CAAC,oBAAoB,CAAC;AACvD,QAAQ,KAAK,CAAC,OAAO,EAAE,QAAQ,CAAC,mBAAmB,CAAC,EAAE;AACtD,QAAQ,OAAO,IAAI,CAAC;AACpB,KAAK;AACL,IAAI,OAAO,KAAK,CAAC;AACjB;;"}
1
+ {"version":3,"file":"repackageAuthError.js","sources":["../../../../src/utils/errors/repackageAuthError.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.repackageUnauthError = void 0;\n/**\n * Checks to see if the given response or subscription message contains an\n * unauth error. If it does, it changes the error message to include instructions\n * for the app developer.\n */\nfunction repackageUnauthError(content) {\n if (content.errors && Array.isArray(content.errors)) {\n content.errors.forEach(e => {\n if (isUnauthError(e)) {\n e.message = 'Unauthorized';\n e.recoverySuggestion =\n `If you're calling an Amplify-generated API, make sure ` +\n `to set the \"authMode\" in generateClient({ authMode: '...' }) to the backend authorization ` +\n `rule's auth provider ('apiKey', 'userPool', 'iam', 'oidc', 'lambda')`;\n }\n });\n }\n return content;\n}\nexports.repackageUnauthError = repackageUnauthError;\nfunction isUnauthError(error) {\n // Error pattern corresponding to appsync calls\n if (error?.originalError?.name?.startsWith('UnauthorizedException')) {\n return true;\n }\n // Error pattern corresponding to appsync subscriptions\n if (error.message?.startsWith('Connection failed:') &&\n error.message?.includes('Permission denied')) {\n return true;\n }\n return false;\n}\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,oBAAoB,GAAG,KAAK,CAAC,CAAC;AACtC;AACA;AACA;AACA;AACA;AACA,SAAS,oBAAoB,CAAC,OAAO,EAAE;AACvC,IAAI,IAAI,OAAO,CAAC,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;AACzD,QAAQ,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI;AACpC,YAAY,IAAI,aAAa,CAAC,CAAC,CAAC,EAAE;AAClC,gBAAgB,CAAC,CAAC,OAAO,GAAG,cAAc,CAAC;AAC3C,gBAAgB,CAAC,CAAC,kBAAkB;AACpC,oBAAoB,CAAC,sDAAsD,CAAC;AAC5E,wBAAwB,CAAC,0FAA0F,CAAC;AACpH,wBAAwB,CAAC,oEAAoE,CAAC,CAAC;AAC/F,aAAa;AACb,SAAS,CAAC,CAAC;AACX,KAAK;AACL,IAAI,OAAO,OAAO,CAAC;AACnB,CAAC;AACD,OAAO,CAAC,oBAAoB,GAAG,oBAAoB,CAAC;AACpD,SAAS,aAAa,CAAC,KAAK,EAAE;AAC9B;AACA,IAAI,IAAI,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,UAAU,CAAC,uBAAuB,CAAC,EAAE;AACzE,QAAQ,OAAO,IAAI,CAAC;AACpB,KAAK;AACL;AACA,IAAI,IAAI,KAAK,CAAC,OAAO,EAAE,UAAU,CAAC,oBAAoB,CAAC;AACvD,QAAQ,KAAK,CAAC,OAAO,EAAE,QAAQ,CAAC,mBAAmB,CAAC,EAAE;AACtD,QAAQ,OAAO,IAAI,CAAC;AACpB,KAAK;AACL,IAAI,OAAO,KAAK,CAAC;AACjB;;"}
@@ -1,8 +1,8 @@
1
1
  import { AmplifyClassV6 } from '@aws-amplify/core';
2
- import { GraphQLOptions, GraphQLResult } from './types';
3
- import { InternalGraphQLAPIClass } from './internals/InternalGraphQLAPI';
4
2
  import { CustomHeaders } from '@aws-amplify/data-schema-types';
5
3
  import { Observable } from 'rxjs';
4
+ import { GraphQLOptions, GraphQLResult } from './types';
5
+ import { InternalGraphQLAPIClass } from './internals/InternalGraphQLAPI';
6
6
  export declare const graphqlOperation: (query: any, variables?: {}, authToken?: string) => {
7
7
  query: any;
8
8
  variables: {};
@@ -1 +1 @@
1
- {"version":3,"file":"GraphQLAPI.mjs","sources":["../../src/GraphQLAPI.ts"],"sourcesContent":["import { Category, ApiAction } from '@aws-amplify/core/internals/utils';\nimport { InternalGraphQLAPIClass } from './internals/InternalGraphQLAPI';\nexport const graphqlOperation = (query, variables = {}, authToken) => ({\n query,\n variables,\n authToken,\n});\n/**\n * Export Cloud Logic APIs\n */\nexport class GraphQLAPIClass extends InternalGraphQLAPIClass {\n getModuleName() {\n return 'GraphQLAPI';\n }\n /**\n * Executes a GraphQL operation\n *\n * @param options - GraphQL Options\n * @param [additionalHeaders] - headers to merge in after any `libraryConfigHeaders` 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, options, additionalHeaders) {\n return super.graphql(amplify, options, additionalHeaders, {\n category: Category.API,\n action: ApiAction.GraphQl,\n });\n }\n /**\n * Checks to see if an error thrown is from an api request cancellation\n * @param error - Any error\n * @returns A boolean indicating if the error was from an api request cancellation\n */\n isCancelError(error) {\n return super.isCancelError(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 super.cancel(request, message);\n }\n}\nexport const GraphQLAPI = new GraphQLAPIClass();\n"],"names":[],"mappings":";;;AAEY,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;AACA;AACA;AACO,MAAM,eAAe,SAAS,uBAAuB,CAAC;AAC7D,IAAI,aAAa,GAAG;AACpB,QAAQ,OAAO,YAAY,CAAC;AAC5B,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE;AACjD,QAAQ,OAAO,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE;AAClE,YAAY,QAAQ,EAAE,QAAQ,CAAC,GAAG;AAClC,YAAY,MAAM,EAAE,SAAS,CAAC,OAAO;AACrC,SAAS,CAAC,CAAC;AACX,KAAK;AACL;AACA;AACA;AACA;AACA;AACA,IAAI,aAAa,CAAC,KAAK,EAAE;AACzB,QAAQ,OAAO,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;AAC1C,KAAK;AACL;AACA;AACA;AACA;AACA;AACA,IAAI,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE;AAC7B,QAAQ,OAAO,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AAC9C,KAAK;AACL,CAAC;AACW,MAAC,UAAU,GAAG,IAAI,eAAe;;;;"}
1
+ {"version":3,"file":"GraphQLAPI.mjs","sources":["../../src/GraphQLAPI.ts"],"sourcesContent":["import { ApiAction, Category } from '@aws-amplify/core/internals/utils';\nimport { InternalGraphQLAPIClass } from './internals/InternalGraphQLAPI';\nexport const graphqlOperation = (query, variables = {}, authToken) => ({\n query,\n variables,\n authToken,\n});\n/**\n * Export Cloud Logic APIs\n */\nexport class GraphQLAPIClass extends InternalGraphQLAPIClass {\n getModuleName() {\n return 'GraphQLAPI';\n }\n /**\n * Executes a GraphQL operation\n *\n * @param options - GraphQL Options\n * @param [additionalHeaders] - headers to merge in after any `libraryConfigHeaders` 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, options, additionalHeaders) {\n return super.graphql(amplify, options, additionalHeaders, {\n category: Category.API,\n action: ApiAction.GraphQl,\n });\n }\n /**\n * Checks to see if an error thrown is from an api request cancellation\n * @param error - Any error\n * @returns A boolean indicating if the error was from an api request cancellation\n */\n isCancelError(error) {\n return super.isCancelError(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 super.cancel(request, message);\n }\n}\nexport const GraphQLAPI = new GraphQLAPIClass();\n"],"names":[],"mappings":";;;AAEY,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;AACA;AACA;AACO,MAAM,eAAe,SAAS,uBAAuB,CAAC;AAC7D,IAAI,aAAa,GAAG;AACpB,QAAQ,OAAO,YAAY,CAAC;AAC5B,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE;AACjD,QAAQ,OAAO,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE;AAClE,YAAY,QAAQ,EAAE,QAAQ,CAAC,GAAG;AAClC,YAAY,MAAM,EAAE,SAAS,CAAC,OAAO;AACrC,SAAS,CAAC,CAAC;AACX,KAAK;AACL;AACA;AACA;AACA;AACA;AACA,IAAI,aAAa,CAAC,KAAK,EAAE;AACzB,QAAQ,OAAO,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;AAC1C,KAAK;AACL;AACA;AACA;AACA;AACA;AACA,IAAI,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE;AAC7B,QAAQ,OAAO,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AAC9C,KAAK;AACL,CAAC;AACW,MAAC,UAAU,GAAG,IAAI,eAAe;;;;"}
@@ -1,17 +1,17 @@
1
1
  import { Observable } from 'rxjs';
2
- import { GraphQLAuthMode, CustomUserAgentDetails, DocumentType } from '@aws-amplify/core/internals/utils';
2
+ import { CustomUserAgentDetails, DocumentType, GraphQLAuthMode } from '@aws-amplify/core/internals/utils';
3
+ import { CustomHeaders } from '@aws-amplify/data-schema-types';
3
4
  import { PubSubContentObserver } from '../../types/PubSub';
4
5
  import { SUBSCRIPTION_STATUS } from '../constants';
5
- import { CustomHeaders } from '@aws-amplify/data-schema-types';
6
- export type ObserverQuery = {
6
+ export interface ObserverQuery {
7
7
  observer: PubSubContentObserver;
8
8
  query: string;
9
9
  variables: Record<string, DocumentType>;
10
10
  subscriptionState: SUBSCRIPTION_STATUS;
11
- subscriptionReadyCallback?: Function;
12
- subscriptionFailedCallback?: Function;
11
+ subscriptionReadyCallback?(): void;
12
+ subscriptionFailedCallback?(reason?: any): void;
13
13
  startAckTimeoutId?: ReturnType<typeof setTimeout>;
14
- };
14
+ }
15
15
  export interface AWSAppSyncRealTimeProviderOptions {
16
16
  appSyncGraphqlEndpoint?: string;
17
17
  authenticationType?: GraphQLAuthMode;
@@ -19,7 +19,7 @@ export interface AWSAppSyncRealTimeProviderOptions {
19
19
  variables?: Record<string, DocumentType>;
20
20
  apiKey?: string;
21
21
  region?: string;
22
- libraryConfigHeaders?: () => {} | (() => Promise<{}>);
22
+ libraryConfigHeaders?(): Promise<Record<string, unknown> | Headers>;
23
23
  additionalHeaders?: CustomHeaders;
24
24
  additionalCustomHeaders?: Record<string, string>;
25
25
  authToken?: string;
@@ -36,7 +36,7 @@ export declare class AWSAppSyncRealTimeProvider {
36
36
  private readonly connectionStateMonitor;
37
37
  private readonly reconnectionMonitor;
38
38
  private connectionStateMonitorSubscription;
39
- constructor(options?: AWSAppSyncRealTimeProviderOptions);
39
+ constructor();
40
40
  /**
41
41
  * Mark the socket closed and release all active listeners
42
42
  */