@aws-amplify/adapter-nextjs 1.0.14-unstable.b814567.0 → 1.0.14

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.
@@ -1 +1 @@
1
- {"version":3,"file":"createServerRunnerForAPI.js","sources":["../../../src/api/createServerRunnerForAPI.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.createServerRunnerForAPI = void 0;\nconst utils_1 = require(\"../utils\");\nconst createServerRunnerForAPI = ({ config, }) => {\n const amplifyConfig = (0, utils_1.getAmplifyConfig)(config);\n return {\n runWithAmplifyServerContext: (0, utils_1.createRunWithAmplifyServerContext)({\n config: amplifyConfig,\n }),\n resourcesConfig: amplifyConfig,\n };\n};\nexports.createServerRunnerForAPI = createServerRunnerForAPI;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,wBAAwB,GAAG,KAAK,CAAC,CAAC;AAC1C,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AACpC,MAAM,wBAAwB,GAAG,CAAC,EAAE,MAAM,GAAG,KAAK;AAClD,IAAI,MAAM,aAAa,GAAG,IAAI,OAAO,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAAC;AAChE,IAAI,OAAO;AACX,QAAQ,2BAA2B,EAAE,IAAI,OAAO,CAAC,iCAAiC,EAAE;AACpF,YAAY,MAAM,EAAE,aAAa;AACjC,SAAS,CAAC;AACV,QAAQ,eAAe,EAAE,aAAa;AACtC,KAAK,CAAC;AACN,CAAC,CAAC;AACF,OAAO,CAAC,wBAAwB,GAAG,wBAAwB;;"}
1
+ {"version":3,"file":"createServerRunnerForAPI.js","sources":["../../../../src/api/createServerRunnerForAPI.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;AACA;;;AAGA,MAA+E,OAAA,GAAA,OAAA,CAAA,UAAA,CAAA,CAAA;AAGxE,MAAM,wBAAwB,GAAG,CAAC,EACxC,MAAM,GAC8B,KAEjC;AACH,IAAA,MAAM,aAAa,GAAG,IAAA,wBAAgB,EAAC,MAAM,CAAC,CAAC;IAE/C,OAAO;QACN,2BAA2B,EAAE,IAAA,OAAA,CAAA,iCAAiC,EAAC;AAC9D,YAAA,MAAM,EAAE,aAAa;SACrB,CAAC;AACF,QAAA,eAAe,EAAE,aAAa;KAC9B,CAAC;AACH,CAAC,CAAC;AAbW,OAAA,CAAA,wBAAwB,GAanC,wBAAA;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"generateServerClient.js","sources":["../../../src/api/generateServerClient.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.generateServerClientUsingReqRes = exports.generateServerClientUsingCookies = void 0;\nconst internals_1 = require(\"@aws-amplify/api/internals\");\nconst server_1 = require(\"aws-amplify/api/server\");\nconst adapter_core_1 = require(\"@aws-amplify/core/internals/adapter-core\");\nconst createServerRunnerForAPI_1 = require(\"./createServerRunnerForAPI\");\nconst utils_1 = require(\"../utils\");\n/**\n * Generates an API client that can be used inside a Next.js Server Component with Dynamic Rendering\n *\n * @example\n * import { cookies } from \"next/headers\"\n *\n * const client = generateServerClientUsingCookies({ cookies });\n * const result = await client.graphql({ query: listPosts });\n */\nfunction generateServerClientUsingCookies({ config, cookies, authMode, authToken, }) {\n if (typeof cookies !== 'function') {\n throw new adapter_core_1.AmplifyServerContextError({\n message: 'generateServerClientUsingCookies is only compatible with the `cookies` Dynamic Function available in Server Components.',\n // TODO: link to docs\n recoverySuggestion: 'use `generateServerClient` inside of `runWithAmplifyServerContext` with the `request` object.',\n });\n }\n const { runWithAmplifyServerContext, resourcesConfig } = (0, createServerRunnerForAPI_1.createServerRunnerForAPI)({ config });\n // This function reference gets passed down to InternalGraphQLAPI.ts.graphql\n // where this._graphql is passed in as the `fn` argument\n // causing it to always get invoked inside `runWithAmplifyServerContext`\n const getAmplify = (fn) => runWithAmplifyServerContext({\n nextServerContext: { cookies },\n operation: contextSpec => fn((0, adapter_core_1.getAmplifyServerContext)(contextSpec).amplify),\n });\n return (0, internals_1.generateClientWithAmplifyInstance)({\n amplify: getAmplify,\n config: resourcesConfig,\n authMode,\n authToken,\n });\n}\nexports.generateServerClientUsingCookies = generateServerClientUsingCookies;\n/**\n * Generates an API client that can be used with both Pages Router and App Router\n *\n * @example\n * import config from './amplifyconfiguration.json';\n * import { listPosts } from './graphql/queries';\n *\n * const client = generateServerClientUsingReqRes({ config });\n *\n * const result = await runWithAmplifyServerContext({\n * nextServerContext: { request, response },\n * operation: (contextSpec) => client.graphql(contextSpec, {\n * query: listPosts,\n * }),\n * });\n */\nfunction generateServerClientUsingReqRes({ config, authMode, authToken }) {\n const amplifyConfig = (0, utils_1.getAmplifyConfig)(config);\n return (0, server_1.generateClient)({\n config: amplifyConfig,\n authMode,\n authToken,\n });\n}\nexports.generateServerClientUsingReqRes = generateServerClientUsingReqRes;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,+BAA+B,GAAG,OAAO,CAAC,gCAAgC,GAAG,KAAK,CAAC,CAAC;AAC5F,MAAM,WAAW,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAAC;AAC1D,MAAM,QAAQ,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;AACnD,MAAM,cAAc,GAAG,OAAO,CAAC,0CAA0C,CAAC,CAAC;AAC3E,MAAM,0BAA0B,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAAC;AACzE,MA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,CAAC;AAChE,IAAI,OAAO,IAAI,QAAQ,CAAC,cAAc,EAAE;AACxC,QAAQ,MAAM,EAAE,aAAa;AAC7B,QAAQ,QAAQ;AAChB,QAAQ,SAAS;AACjB,KAAK,CAAC,CAAC;AACP,CAAC;AACD,OAAO,CAAC,+BAA+B,GAAG,+BAA+B;;"}
1
+ {"version":3,"file":"generateServerClient.js","sources":["../../../../src/api/generateServerClient.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;AACA;;;AAEA,MAA+E,WAAA,GAAA,OAAA,CAAA,4BAAA,CAAA,CAAA;AAC/E,MAAwD,QAAA,GAAA,OAAA,CAAA,wBAAA,CAAA,CAAA;AACxD,MAGkD,cAAA,GAAA,OAAA,CAAA,0CAAA,CAAA,CAAA;AAOlD,MAAsE,0BAAA,GAAA,OAAA,CAAA,4BAAA,CAAA,CAAA;AACtE,MAA4C,OAAA,GAAA,OAAA,CAAA,UAAA,CAAA,CAAA;AAgB5C;;;;;;;;AAQG;AACH,SAAgB,gCAAgC,CAE9C,EACD,MAAM,EACN,OAAO,EACP,QAAQ,EACR,SAAS,GACY,EAAA;AACrB,IAAA,IAAI,OAAO,OAAO,KAAK,UAAU,EAAE;QAClC,MAAM,IAAI,wCAAyB,CAAC;AACnC,YAAA,OAAO,EACN,yHAAyH;;AAE1H,YAAA,kBAAkB,EACjB,+FAA+F;AAChG,SAAA,CAAC,CAAC;AACH,KAAA;AAED,IAAA,MAAM,EAAE,2BAA2B,EAAE,eAAe,EAAE,GACrD,IAAA,0BAAA,CAAA,wBAAwB,EAAC,EAAE,MAAM,EAAE,CAAC,CAAC;;;;IAKtC,MAAM,UAAU,GAAG,CAAC,EAAkC,KACrD,2BAA2B,CAAC;QAC3B,iBAAiB,EAAE,EAAE,OAAO,EAAE;AAC9B,QAAA,SAAS,EAAE,WAAW,IACrB,EAAE,CAAC,IAAA,cAAA,CAAA,uBAAuB,EAAC,WAAW,CAAC,CAAC,OAAO,CAAC;AACjD,KAAA,CAAC,CAAC;IAEJ,OAAO,IAAA,6CAAiC,EAA2B;AAClE,QAAA,OAAO,EAAE,UAAU;AACnB,QAAA,MAAM,EAAE,eAAe;QACvB,QAAQ;QACR,SAAS;AACT,KAAA,CAAC,CAAC;AACJ,CAAC;AArCD,OAqCC,CAAA,gCAAA,GAAA,gCAAA,CAAA;AAED;;;;;;;;;;;;;;;AAeG;AACH,SAAgB,+BAA+B,CAE7C,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAmB,EAAA;AACjD,IAAA,MAAM,aAAa,GAAG,IAAA,wBAAgB,EAAC,MAAM,CAAC,CAAC;IAC/C,OAAO,IAAA,uBAAc,EAAI;AACxB,QAAA,MAAM,EAAE,aAAa;QACrB,QAAQ;QACR,SAAS;AACT,KAAA,CAAC,CAAC;AACJ,CAAC;AATD,OASC,CAAA,+BAAA,GAAA,+BAAA;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/api/index.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.generateServerClientUsingCookies = exports.generateServerClientUsingReqRes = void 0;\nvar generateServerClient_1 = require(\"./generateServerClient\");\nObject.defineProperty(exports, \"generateServerClientUsingReqRes\", { enumerable: true, get: function () { return generateServerClient_1.generateServerClientUsingReqRes; } });\nObject.defineProperty(exports, \"generateServerClientUsingCookies\", { enumerable: true, get: function () { return generateServerClient_1.generateServerClientUsingCookies; } });\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,gCAAgC,GAAG,OAAO,CAAC,+BAA+B,GAAG,KAAK,CAAC,CAAC;AAC5F,IAAI,sBAAsB,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;AAC/D,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,iCAAiC,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,sBAAsB,CAAC,+BAA+B,CAAC,EAAE,EAAE,CAAC,CAAC;AAC7K,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,kCAAkC,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,sBAAsB,CAAC,gCAAgC,CAAC,EAAE,EAAE,CAAC;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../src/api/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;AACA;;;AAEA,IAGgC,sBAAA,GAAA,OAAA,CAAA,wBAAA,CAAA,CAAA;AAF/B,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,iCAAA,EAAA,EAAA,UAAA,EAAA,IAAA,EAAA,GAAA,EAAA,YAAA,EAAA,OAAA,sBAAA,CAAA,+BAA+B,CAAA,EAAA,EAAA,CAAA,CAAA;AAC/B,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,kCAAA,EAAA,EAAA,UAAA,EAAA,IAAA,EAAA,GAAA,EAAA,YAAA,EAAA,OAAA,sBAAA,CAAA,gCAAgC,CAAA,EAAA,EAAA,CAAA;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"createServerRunner.js","sources":["../../src/createServerRunner.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.createServerRunner = void 0;\nconst utils_1 = require(\"./utils\");\n/**\n * Creates the `runWithAmplifyServerContext` function to run Amplify server side APIs in an isolated request context.\n *\n * @remarks\n * This function should be called only once; you can use the returned `runWithAmplifyServerContext` across\n * your codebase.\n *\n * @param input The input used to create the `runWithAmplifyServerContext` function.\n * @param input.config The {@link ResourcesConfig} imported from the `amplifyconfiguration.json` file or manually\n * created.\n * @returns An object that contains the `runWithAmplifyServerContext` function.\n *\n * @example\n * import { createServerRunner } from '@aws-amplify/adapter-nextjs';\n * import config from './amplifyconfiguration.json';\n *\n * export const { runWithAmplifyServerContext } = createServerRunner({ config })\n *\n */\nconst createServerRunner = ({ config, }) => {\n const amplifyConfig = (0, utils_1.getAmplifyConfig)(config);\n return {\n runWithAmplifyServerContext: (0, utils_1.createRunWithAmplifyServerContext)({\n config: amplifyConfig,\n }),\n };\n};\nexports.createServerRunner = createServerRunner;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,kBAAkB,GAAG,KAAK,CAAC,CAAC;AACpC,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;AACnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,kBAAkB,GAAG,CAAC,EAAE,MAAM,GAAG,KAAK;AAC5C,IAAI,MAAM,aAAa,GAAG,IAAI,OAAO,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAAC;AAChE,IAAI,OAAO;AACX,QAAQ,2BAA2B,EAAE,IAAI,OAAO,CAAC,iCAAiC,EAAE;AACpF,YAAY,MAAM,EAAE,aAAa;AACjC,SAAS,CAAC;AACV,KAAK,CAAC;AACN,CAAC,CAAC;AACF,OAAO,CAAC,kBAAkB,GAAG,kBAAkB;;"}
1
+ {"version":3,"file":"createServerRunner.js","sources":["../../../src/createServerRunner.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;AACA;;;AAIA,MAA8E,OAAA,GAAA,OAAA,CAAA,SAAA,CAAA,CAAA;AAG9E;;;;;;;;;;;;;;;;;;AAkBG;AACI,MAAM,kBAAkB,GAAkC,CAAC,EACjE,MAAM,GACN,KAAI;AACJ,IAAA,MAAM,aAAa,GAAG,IAAA,wBAAgB,EAAC,MAAM,CAAC,CAAC;IAE/C,OAAO;QACN,2BAA2B,EAAE,IAAA,OAAA,CAAA,iCAAiC,EAAC;AAC9D,YAAA,MAAM,EAAE,aAAa;SACrB,CAAC;KACF,CAAC;AACH,CAAC,CAAC;AAVW,OAAA,CAAA,kBAAkB,GAU7B,kBAAA;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/index.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.createServerRunner = void 0;\nvar createServerRunner_1 = require(\"./createServerRunner\");\nObject.defineProperty(exports, \"createServerRunner\", { enumerable: true, get: function () { return createServerRunner_1.createServerRunner; } });\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,kBAAkB,GAAG,KAAK,CAAC,CAAC;AACpC,IAAI,oBAAoB,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;AAC3D,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,oBAAoB,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,oBAAoB,CAAC,kBAAkB,CAAC,EAAE,EAAE,CAAC;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;AACA;;;AAEA,IAA0D,oBAAA,GAAA,OAAA,CAAA,sBAAA,CAAA,CAAA;AAAjD,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,oBAAA,EAAA,EAAA,UAAA,EAAA,IAAA,EAAA,GAAA,EAAA,YAAA,EAAA,OAAA,oBAAA,CAAA,kBAAkB,CAAA,EAAA,EAAA,CAAA;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"NextServer.js","sources":["../../../src/types/NextServer.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 });\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;;"}
1
+ {"version":3,"file":"NextServer.js","sources":["../../../../src/types/NextServer.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;AACA;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/types/index.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 });\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../src/types/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;AACA;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"createCookieStorageAdapterFromNextServerContext.js","sources":["../../../src/utils/createCookieStorageAdapterFromNextServerContext.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.createCookieStorageAdapterFromNextServerContext = exports.DATE_IN_THE_PAST = void 0;\nconst server_js_1 = require(\"next/server.js\");\nconst adapter_core_1 = require(\"@aws-amplify/core/internals/adapter-core\");\nexports.DATE_IN_THE_PAST = new Date(0);\nconst createCookieStorageAdapterFromNextServerContext = (context) => {\n const { request: req, response: res } = context;\n // When the server context is from `getServerSideProps`, the `req` is an instance\n // of IncomingMessage, and the `res` is an instance of ServerResponse.\n // We cannot import these two classes here from `http` as it breaks in Next\n // Edge Runtime. Hence, we check the methods that we need to use for creating\n // cookie adapter.\n if (req &&\n res &&\n Object.prototype.toString.call(req.cookies) === '[object Object]' &&\n typeof res.setHeader === 'function') {\n return createCookieStorageAdapterFromGetServerSidePropsContext(req, res);\n }\n const { request, response } = context;\n // When the server context is from `middleware`, the `request` is an instance\n // of `NextRequest`.\n // When the server context is from a route handler, the `request` is an `Proxy`\n // wrapped `Request`.\n // The `NextRequest` and the `Proxy` are sharing the same interface by Next\n // implementation. So we don't need to detect the difference.\n if (request && response) {\n if (response instanceof server_js_1.NextResponse) {\n return createCookieStorageAdapterFromNextRequestAndNextResponse(request, response);\n }\n else {\n return createCookieStorageAdapterFromNextRequestAndHttpResponse(request, response);\n }\n }\n const { cookies } = context;\n if (typeof cookies === 'function') {\n return createCookieStorageAdapterFromNextCookies(cookies);\n }\n // This should not happen normally.\n throw new adapter_core_1.AmplifyServerContextError({\n message: 'Attempted to create cookie storage adapter from an unsupported Next.js server context.',\n });\n};\nexports.createCookieStorageAdapterFromNextServerContext = createCookieStorageAdapterFromNextServerContext;\nconst createCookieStorageAdapterFromNextRequestAndNextResponse = (request, response) => {\n const readonlyCookieStore = request.cookies;\n const mutableCookieStore = response.cookies;\n return {\n get(name) {\n return readonlyCookieStore.get(ensureEncodedForJSCookie(name));\n },\n getAll: readonlyCookieStore.getAll.bind(readonlyCookieStore),\n set(name, value, options) {\n mutableCookieStore.set(ensureEncodedForJSCookie(name), value, options);\n },\n delete(name) {\n mutableCookieStore.delete(ensureEncodedForJSCookie(name));\n },\n };\n};\nconst createCookieStorageAdapterFromNextRequestAndHttpResponse = (request, response) => {\n const readonlyCookieStore = request.cookies;\n const mutableCookieStore = createMutableCookieStoreFromHeaders(response.headers);\n return {\n get(name) {\n return readonlyCookieStore.get(ensureEncodedForJSCookie(name));\n },\n getAll: readonlyCookieStore.getAll.bind(readonlyCookieStore),\n ...mutableCookieStore,\n };\n};\nconst createCookieStorageAdapterFromNextCookies = (cookies) => {\n const cookieStore = cookies();\n // When Next cookies() is called in a server component, it returns a readonly\n // cookie store. Hence calling set and delete throws an error. However,\n // cookies() returns a mutable cookie store when called in a server action.\n // We have no way to detect which one is returned, so we try to call set and delete\n // and safely ignore the error if it is thrown.\n const setFunc = (name, value, options) => {\n try {\n cookieStore.set(ensureEncodedForJSCookie(name), value, options);\n }\n catch {\n // no-op\n }\n };\n const deleteFunc = name => {\n try {\n cookieStore.delete(ensureEncodedForJSCookie(name));\n }\n catch {\n // no-op\n }\n };\n return {\n get(name) {\n return cookieStore.get(ensureEncodedForJSCookie(name));\n },\n getAll: cookieStore.getAll.bind(cookieStore),\n set: setFunc,\n delete: deleteFunc,\n };\n};\nconst createCookieStorageAdapterFromGetServerSidePropsContext = (request, response) => {\n const cookiesMap = { ...request.cookies };\n const allCookies = Object.entries(cookiesMap).map(([name, value]) => ({\n name,\n value,\n }));\n return {\n get(name) {\n const value = cookiesMap[ensureEncodedForJSCookie(name)];\n return value\n ? {\n name,\n value,\n }\n : undefined;\n },\n getAll() {\n return allCookies;\n },\n set(name, value, options) {\n response.setHeader('Set-Cookie', `${ensureEncodedForJSCookie(name)}=${value};${options ? serializeSetCookieOptions(options) : ''}`);\n },\n delete(name) {\n response.setHeader('Set-Cookie', `${ensureEncodedForJSCookie(name)}=;Expires=${exports.DATE_IN_THE_PAST.toUTCString()}`);\n },\n };\n};\nconst createMutableCookieStoreFromHeaders = (headers) => {\n const setFunc = (name, value, options) => {\n headers.append('Set-Cookie', `${ensureEncodedForJSCookie(name)}=${value};${options ? serializeSetCookieOptions(options) : ''}`);\n };\n const deleteFunc = name => {\n headers.append('Set-Cookie', `${ensureEncodedForJSCookie(name)}=;Expires=${exports.DATE_IN_THE_PAST.toUTCString()}`);\n };\n return {\n set: setFunc,\n delete: deleteFunc,\n };\n};\nconst serializeSetCookieOptions = (options) => {\n const { expires, domain, httpOnly, sameSite, secure } = options;\n const serializedOptions = [];\n if (domain) {\n serializedOptions.push(`Domain=${domain}`);\n }\n if (expires) {\n serializedOptions.push(`Expires=${expires.toUTCString()}`);\n }\n if (httpOnly) {\n serializedOptions.push(`HttpOnly`);\n }\n if (sameSite) {\n serializedOptions.push(`SameSite=${sameSite}`);\n }\n if (secure) {\n serializedOptions.push(`Secure`);\n }\n return serializedOptions.join(';');\n};\n// Ensures the cookie names are encoded in order to look up the cookie store\n// that is manipulated by js-cookie on the client side.\n// Details of the js-cookie encoding behavior see:\n// https://github.com/js-cookie/js-cookie#encoding\n// The implementation is borrowed from js-cookie without escaping `[()]` as\n// we are not using those chars in the auth keys.\nconst ensureEncodedForJSCookie = (name) => encodeURIComponent(name).replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent);\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,+CAA+C,GAAG,OAAO,CAAC,gBAAgB,GAAG,KAAK,CAAC,CAAC;AAC5F,MAAM,WAAW,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAC9C,MAAM,cAAc,GAAG,OAAO,CAAC,0CAA0C,CAAC,CAAC;AAC3E,OAAO,CAAC,gBAAgB,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC;AACvC,MAAM,+CAA+C,GAAG,CAAC,OAAO,KAAK;AACrE,IAAI,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;AACpD;AACA;AACA;AACA;AACA;AACA,IAAI,IAAI,GAAG;AACX,QAAQ,GAAG;AACX,QAAQ,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,iBAAiB;AACzE,QAAQ,OAAO,GAAG,CAAC,SA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,CAAC;AACpE,IAAI,MAAM,iBAAiB,GAAG,EAAE,CAAC;AACjC,IAAI,IAAI,MAAM,EAAE;AAChB,QAAQ,iBAAiB,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;AACnD,KAAK;AACL,IAAI,IAAI,OAAO,EAAE;AACjB,QAAQ,iBAAiB,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC;AACnE,KAAK;AACL,IAAI,IAAI,QAAQ,EAAE;AAClB,QAAQ,iBAAiB,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;AAC3C,KAAK;AACL,IAAI,IAAI,QAAQ,EAAE;AAClB,QAAQ,iBAAiB,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;AACvD,KAAK;AACL,IAAI,IAAI,MAAM,EAAE;AAChB,QAAQ,iBAAiB,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AACzC,KAAK;AACL,IAAI,OAAO,iBAAiB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACvC,CAAC,CAAC;AACF;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,wBAAwB,GAAG,CAAC,IAAI,KAAK,kBAAkB,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,sBAAsB,EAAE,kBAAkB,CAAC;;"}
1
+ {"version":3,"file":"createCookieStorageAdapterFromNextServerContext.js","sources":["../../../../src/utils/createCookieStorageAdapterFromNextServerContext.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;AACA;;;AAEA,MAA2D,WAAA,GAAA,OAAA,CAAA,gBAAA,CAAA,CAAA;AAC3D,MAGkD,cAAA,GAAA,OAAA,CAAA,0CAAA,CAAA,CAAA;AAIrC,OAAA,CAAA,gBAAgB,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC;AAEr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AAM,CAAA,CAAE,CAAC,CAAC;AAC3C,KAAA;AACD,IAAA,IAAI,OAAO,EAAE;QACZ,iBAAiB,CAAC,IAAI,CAAC,CAAW,QAAA,EAAA,OAAO,CAAC,WAAW,EAAE,CAAE,CAAA,CAAC,CAAC;AAC3D,KAAA;AACD,IAAA,IAAI,QAAQ,EAAE;AACb,QAAA,iBAAiB,CAAC,IAAI,CAAC,CAAA,QAAA,CAAU,CAAC,CAAC;AACnC,KAAA;AACD,IAAA,IAAI,QAAQ,EAAE;AACb,QAAA,iBAAiB,CAAC,IAAI,CAAC,YAAY,QAAQ,CAAA,CAAE,CAAC,CAAC;AAC/C,KAAA;AACD,IAAA,IAAI,MAAM,EAAE;AACX,QAAA,iBAAiB,CAAC,IAAI,CAAC,CAAA,MAAA,CAAQ,CAAC,CAAC;AACjC,KAAA;AAED,IAAA,OAAO,iBAAiB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACpC,CAAC,CAAC;AAEF;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,wBAAwB,GAAG,CAAC,IAAY,KAC7C,kBAAkB,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,sBAAsB,EAAE,kBAAkB,CAAC;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"createRunWithAmplifyServerContext.js","sources":["../../../src/utils/createRunWithAmplifyServerContext.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.createRunWithAmplifyServerContext = void 0;\nconst core_1 = require(\"@aws-amplify/core\");\nconst adapter_core_1 = require(\"aws-amplify/adapter-core\");\nconst createCookieStorageAdapterFromNextServerContext_1 = require(\"./createCookieStorageAdapterFromNextServerContext\");\nconst createRunWithAmplifyServerContext = ({ config: resourcesConfig, }) => {\n const runWithAmplifyServerContext = async ({ nextServerContext, operation }) => {\n // When the Auth config is presented, attempt to create a Amplify server\n // context with token and credentials provider.\n if (resourcesConfig.Auth) {\n const keyValueStorage = \n // When `null` is passed as the value of `nextServerContext`, opt-in\n // unauthenticated role (primarily for static rendering). It's\n // safe to use the singleton `MemoryKeyValueStorage` here, as the\n // static rendering uses the same unauthenticated role cross-sever.\n nextServerContext === null\n ? core_1.sharedInMemoryStorage\n : (0, adapter_core_1.createKeyValueStorageFromCookieStorageAdapter)((0, createCookieStorageAdapterFromNextServerContext_1.createCookieStorageAdapterFromNextServerContext)(nextServerContext));\n const credentialsProvider = (0, adapter_core_1.createAWSCredentialsAndIdentityIdProvider)(resourcesConfig.Auth, keyValueStorage);\n const tokenProvider = (0, adapter_core_1.createUserPoolsTokenProvider)(resourcesConfig.Auth, keyValueStorage);\n return (0, adapter_core_1.runWithAmplifyServerContext)(resourcesConfig, {\n Auth: { credentialsProvider, tokenProvider },\n }, operation);\n }\n // Otherwise it may be the case that auth is not used, e.g. API key.\n // Omitting the `Auth` in the second parameter.\n return (0, adapter_core_1.runWithAmplifyServerContext)(resourcesConfig, {}, operation);\n };\n return runWithAmplifyServerContext;\n};\nexports.createRunWithAmplifyServerContext = createRunWithAmplifyServerContext;\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,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAC5C,MAAM,cAAc,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAAC;AAC3D,MAAM,iDAAiD,GAAG,OAAO,CAAC,mDAAmD,CAAC,CAAC;AACvH,MAAM,iCAAiC,GAAG,CAAC,EAAE,MAAM,EAAE,eAAe,GAAG,KAAK;AAC5E,IAAI,MAAM,2BAA2B,GAAG,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,KAAK;AACpF;AACA;AACA,QAAQ,IAAI,eAAe,CAAC,IAAI,EAAE;AAClC,YAAY,MAAM,eAAe;AACjC;AACA;AACA;AACA;AACA,YAAY,iBAAiB,KAAK,IAAI;AACtC,kBAAkB,MAAM,CAAC,qBAAqB;AAC9C,kBAAkB,IAAI,cAAc,CAAC,6CAA6C,EAAE,IAAI,iDAAiD,CAAC,+CAA+C,EAAE,iBAAiB,CAAC,CAAC,CAAC;AAC/M,YAAY,MAAM,mBAAmB,GAAG,IAAI,cAAc,CAAC,yCAAyC,EAAE,eAAe,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC;AAC7I,YAAY,MAAM,aAAa,GAAG,IAAI,cAAc,CAAC,4BAA4B,EAAE,eAAe,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC;AAC1H,YAAY,OAAO,IAAI,cAAc,CAAC,2BAA2B,EAAE,eAAe,EAAE;AACpF,gBAAgB,IAAI,EAAE,EAAE,mBAAmB,EAAE,aAAa,EAAE;AAC5D,aAAa,EAAE,SAAS,CAAC,CAAC;AAC1B,SAAS;AACT;AACA;AACA,QAAQ,OAAO,IAAI,cAAc,CAAC,2BAA2B,EAAE,eAAe,EAAE,EAAE,EAAE,SAAS,CAAC,CAAC;AAC/F,KAAK,CAAC;AACN,IAAI,OAAO,2BAA2B,CAAC;AACvC,CAAC,CAAC;AACF,OAAO,CAAC,iCAAiC,GAAG,iCAAiC;;"}
1
+ {"version":3,"file":"createRunWithAmplifyServerContext.js","sources":["../../../../src/utils/createRunWithAmplifyServerContext.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;AACA;;;AAEA,MAA2E,MAAA,GAAA,OAAA,CAAA,mBAAA,CAAA,CAAA;AAC3E,MAKkC,cAAA,GAAA,OAAA,CAAA,0BAAA,CAAA,CAAA;AAIlC,MAAoH,iDAAA,GAAA,OAAA,CAAA,mDAAA,CAAA,CAAA;AAE7G,MAAM,iCAAiC,GAAG,CAAC,EACjD,MAAM,EAAE,eAAe,GAGvB,KAAI;IACJ,MAAM,2BAA2B,GAChC,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,KAAI;;;QAG1C,IAAI,eAAe,CAAC,IAAI,EAAE;AACzB,YAAA,MAAM,eAAe;;;;;AAKpB,YAAA,iBAAiB,KAAK,IAAI;AACzB,kBAAE,MAAqB,CAAA,qBAAA;kBACrB,IAAA,cAAA,CAAA,6CAA6C,EAC7C,IAAA,iGAA+C,EAC9C,iBAAiB,CACjB,CACA,CAAC;YACN,MAAM,mBAAmB,GAAG,IAAA,cAAyC,CAAA,yCAAA,EACpE,eAAe,CAAC,IAAI,EACpB,eAAe,CACf,CAAC;YACF,MAAM,aAAa,GAAG,IAAA,cAA4B,CAAA,4BAAA,EACjD,eAAe,CAAC,IAAI,EACpB,eAAe,CACf,CAAC;AAEF,YAAA,OAAO,IAAA,cAAA,CAAA,2BAA+B,EACrC,eAAe,EACf;AACC,gBAAA,IAAI,EAAE,EAAE,mBAAmB,EAAE,aAAa,EAAE;aAC5C,EACD,SAAS,CACT,CAAC;AACF,SAAA;;;QAID,OAAO,IAAA,0CAA+B,EAAC,eAAe,EAAE,EAAE,EAAE,SAAS,CAAC,CAAC;AACxE,KAAC,CAAC;AAEH,IAAA,OAAO,2BAA2B,CAAC;AACpC,CAAC,CAAC;AA9CW,OAAA,CAAA,iCAAiC,GA8C5C,iCAAA;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"getAmplifyConfig.js","sources":["../../../src/utils/getAmplifyConfig.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.getAmplifyConfig = void 0;\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst getAmplifyConfig = (config) => Object.keys(config).some(key => key.startsWith('aws_'))\n ? (0, utils_1.parseAWSExports)(config)\n : config;\nexports.getAmplifyConfig = getAmplifyConfig;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,gBAAgB,GAAG,KAAK,CAAC,CAAC;AAClC,MAAM,OAAO,GAAG,OAAO,CAAC,mCAAmC,CAAC,CAAC;AAC7D,MAAM,gBAAgB,GAAG,CAAC,MAAM,KAAK,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;AAC5F,MAAM,IAAI,OAAO,CAAC,eAAe,EAAE,MAAM,CAAC;AAC1C,MAAM,MAAM,CAAC;AACb,OAAO,CAAC,gBAAgB,GAAG,gBAAgB;;"}
1
+ {"version":3,"file":"getAmplifyConfig.js","sources":["../../../../src/utils/getAmplifyConfig.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;AACA;;;AAIA,MAAoE,OAAA,GAAA,OAAA,CAAA,mCAAA,CAAA,CAAA;AAE7D,MAAM,gBAAgB,GAAG,CAC/B,MAAsC,KAEtC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;AACtD,MAAE,IAAA,OAAe,CAAA,eAAA,EAAC,MAAM,CAAC;MACtB,MAA0B,CAAC;AALnB,OAAA,CAAA,gBAAgB,GAKG,gBAAA;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/utils/index.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.createRunWithAmplifyServerContext = exports.getAmplifyConfig = void 0;\nvar getAmplifyConfig_1 = require(\"./getAmplifyConfig\");\nObject.defineProperty(exports, \"getAmplifyConfig\", { enumerable: true, get: function () { return getAmplifyConfig_1.getAmplifyConfig; } });\nvar createRunWithAmplifyServerContext_1 = require(\"./createRunWithAmplifyServerContext\");\nObject.defineProperty(exports, \"createRunWithAmplifyServerContext\", { enumerable: true, get: function () { return createRunWithAmplifyServerContext_1.createRunWithAmplifyServerContext; } });\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,OAAO,CAAC,gBAAgB,GAAG,KAAK,CAAC,CAAC;AAC9E,IAAI,kBAAkB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;AACvD,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,kBAAkB,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,kBAAkB,CAAC,gBAAgB,CAAC,EAAE,EAAE,CAAC,CAAC;AAC3I,IAAI,mCAAmC,GAAG,OAAO,CAAC,qCAAqC,CAAC,CAAC;AACzF,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,mCAAmC,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,mCAAmC,CAAC,iCAAiC,CAAC,EAAE,EAAE,CAAC;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../src/utils/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;AACA;;;AAEA,IAAsD,kBAAA,GAAA,OAAA,CAAA,oBAAA,CAAA,CAAA;AAA7C,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,kBAAA,EAAA,EAAA,UAAA,EAAA,IAAA,EAAA,GAAA,EAAA,YAAA,EAAA,OAAA,kBAAA,CAAA,gBAAgB,CAAA,EAAA,EAAA,CAAA,CAAA;AACzB,IAAwF,mCAAA,GAAA,OAAA,CAAA,qCAAA,CAAA,CAAA;AAA/E,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,mCAAA,EAAA,EAAA,UAAA,EAAA,IAAA,EAAA,GAAA,EAAA,YAAA,EAAA,OAAA,mCAAA,CAAA,iCAAiC,CAAA,EAAA,EAAA,CAAA;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"createServerRunnerForAPI.mjs","sources":["../../../src/api/createServerRunnerForAPI.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { createRunWithAmplifyServerContext, getAmplifyConfig } from '../utils';\nexport const createServerRunnerForAPI = ({ config, }) => {\n const amplifyConfig = getAmplifyConfig(config);\n return {\n runWithAmplifyServerContext: createRunWithAmplifyServerContext({\n config: amplifyConfig,\n }),\n resourcesConfig: amplifyConfig,\n };\n};\n"],"names":[],"mappings":";;;AAAA;AACA;AAEY,MAAC,wBAAwB,GAAG,CAAC,EAAE,MAAM,GAAG,KAAK;AACzD,IAAI,MAAM,aAAa,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC;AACnD,IAAI,OAAO;AACX,QAAQ,2BAA2B,EAAE,iCAAiC,CAAC;AACvE,YAAY,MAAM,EAAE,aAAa;AACjC,SAAS,CAAC;AACV,QAAQ,eAAe,EAAE,aAAa;AACtC,KAAK,CAAC;AACN;;;;"}
1
+ {"version":3,"file":"createServerRunnerForAPI.mjs","sources":["../../../../src/api/createServerRunnerForAPI.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAAA;AACA;MAMa,wBAAwB,GAAG,CAAC,EACxC,MAAM,GAC8B,KAEjC;AACH,IAAA,MAAM,aAAa,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAE/C,OAAO;QACN,2BAA2B,EAAE,iCAAiC,CAAC;AAC9D,YAAA,MAAM,EAAE,aAAa;SACrB,CAAC;AACF,QAAA,eAAe,EAAE,aAAa;KAC9B,CAAC;AACH;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"generateServerClient.mjs","sources":["../../../src/api/generateServerClient.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { generateClientWithAmplifyInstance } from '@aws-amplify/api/internals';\nimport { generateClient } from 'aws-amplify/api/server';\nimport { getAmplifyServerContext, AmplifyServerContextError, } from '@aws-amplify/core/internals/adapter-core';\nimport { createServerRunnerForAPI } from './createServerRunnerForAPI';\nimport { getAmplifyConfig } from '../utils';\n/**\n * Generates an API client that can be used inside a Next.js Server Component with Dynamic Rendering\n *\n * @example\n * import { cookies } from \"next/headers\"\n *\n * const client = generateServerClientUsingCookies({ cookies });\n * const result = await client.graphql({ query: listPosts });\n */\nexport function generateServerClientUsingCookies({ config, cookies, authMode, authToken, }) {\n if (typeof cookies !== 'function') {\n throw new AmplifyServerContextError({\n message: 'generateServerClientUsingCookies is only compatible with the `cookies` Dynamic Function available in Server Components.',\n // TODO: link to docs\n recoverySuggestion: 'use `generateServerClient` inside of `runWithAmplifyServerContext` with the `request` object.',\n });\n }\n const { runWithAmplifyServerContext, resourcesConfig } = createServerRunnerForAPI({ config });\n // This function reference gets passed down to InternalGraphQLAPI.ts.graphql\n // where this._graphql is passed in as the `fn` argument\n // causing it to always get invoked inside `runWithAmplifyServerContext`\n const getAmplify = (fn) => runWithAmplifyServerContext({\n nextServerContext: { cookies },\n operation: contextSpec => fn(getAmplifyServerContext(contextSpec).amplify),\n });\n return generateClientWithAmplifyInstance({\n amplify: getAmplify,\n config: resourcesConfig,\n authMode,\n authToken,\n });\n}\n/**\n * Generates an API client that can be used with both Pages Router and App Router\n *\n * @example\n * import config from './amplifyconfiguration.json';\n * import { listPosts } from './graphql/queries';\n *\n * const client = generateServerClientUsingReqRes({ config });\n *\n * const result = await runWithAmplifyServerContext({\n * nextServerContext: { request, response },\n * operation: (contextSpec) => client.graphql(contextSpec, {\n * query: listPosts,\n * }),\n * });\n */\nexport function generateServerClientUsingReqRes({ config, authMode, authToken }) {\n const amplifyConfig = getAmplifyConfig(config);\n return generate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,SAAS;AACjB,KAAK,CAAC,CAAC;AACP;;;;"}
1
+ {"version":3,"file":"generateServerClient.mjs","sources":["../../../../src/api/generateServerClient.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;AAAA;AACA;AA+BA;;;;;;;;AAQG;AACG,SAAU,gCAAgC,CAE9C,EACD,MAAM,EACN,OAAO,EACP,QAAQ,EACR,SAAS,GACY,EAAA;AACrB,IAAA,IAAI,OAAO,OAAO,KAAK,UAAU,EAAE;QAClC,MAAM,IAAI,yBAAyB,CAAC;AACnC,YAAA,OAAO,EACN,yHAAyH;;AAE1H,YAAA,kBAAkB,EACjB,+FAA+F;AAChG,SAAA,CAAC,CAAC;AACH,KAAA;AAED,IAAA,MAAM,EAAE,2BAA2B,EAAE,eAAe,EAAE,GACrD,wBAAwB,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;;;;IAKtC,MAAM,UAAU,GAAG,CAAC,EAAkC,KACrD,2BAA2B,CAAC;QAC3B,iBAAiB,EAAE,EAAE,OAAO,EAAE;AAC9B,QAAA,SAAS,EAAE,WAAW,IACrB,EAAE,CAAC,uBAAuB,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC;AACjD,KAAA,CAAC,CAAC;AAEJ,IAAA,OAAO,iCAAiC,CAA2B;AAClE,QAAA,OAAO,EAAE,UAAU;AACnB,QAAA,MAAM,EAAE,eAAe;QACvB,QAAQ;QACR,SAAS;AACT,KAAA,CAAC,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;AAeG;AACG,SAAU,+BAA+B,CAE7C,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAmB,EAAA;AACjD,IAAA,MAAM,aAAa,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC;AAC/C,IAAA,OAAO,cAAc,CAAI;AACxB,QAAA,MAAM,EAAE,aAAa;QACrB,QAAQ;QACR,SAAS;AACT,KAAA,CAAC,CAAC;AACJ;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"createServerRunner.mjs","sources":["../../src/createServerRunner.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { createRunWithAmplifyServerContext, getAmplifyConfig } from './utils';\n/**\n * Creates the `runWithAmplifyServerContext` function to run Amplify server side APIs in an isolated request context.\n *\n * @remarks\n * This function should be called only once; you can use the returned `runWithAmplifyServerContext` across\n * your codebase.\n *\n * @param input The input used to create the `runWithAmplifyServerContext` function.\n * @param input.config The {@link ResourcesConfig} imported from the `amplifyconfiguration.json` file or manually\n * created.\n * @returns An object that contains the `runWithAmplifyServerContext` function.\n *\n * @example\n * import { createServerRunner } from '@aws-amplify/adapter-nextjs';\n * import config from './amplifyconfiguration.json';\n *\n * export const { runWithAmplifyServerContext } = createServerRunner({ config })\n *\n */\nexport const createServerRunner = ({ config, }) => {\n const amplifyConfig = getAmplifyConfig(config);\n return {\n runWithAmplifyServerContext: createRunWithAmplifyServerContext({\n config: amplifyConfig,\n }),\n };\n};\n"],"names":[],"mappings":";;;AAAA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,kBAAkB,GAAG,CAAC,EAAE,MAAM,GAAG,KAAK;AACnD,IAAI,MAAM,aAAa,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC;AACnD,IAAI,OAAO;AACX,QAAQ,2BAA2B,EAAE,iCAAiC,CAAC;AACvE,YAAY,MAAM,EAAE,aAAa;AACjC,SAAS,CAAC;AACV,KAAK,CAAC;AACN;;;;"}
1
+ {"version":3,"file":"createServerRunner.mjs","sources":["../../../src/createServerRunner.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAAA;AACA;AAOA;;;;;;;;;;;;;;;;;;AAkBG;MACU,kBAAkB,GAAkC,CAAC,EACjE,MAAM,GACN,KAAI;AACJ,IAAA,MAAM,aAAa,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAE/C,OAAO;QACN,2BAA2B,EAAE,iCAAiC,CAAC;AAC9D,YAAA,MAAM,EAAE,aAAa;SACrB,CAAC;KACF,CAAC;AACH;;;;"}
@@ -11,60 +11,53 @@ export declare namespace NextServer {
11
11
  * - Next App Router [route handler](https://nextjs.org/docs/app/building-your-application/routing/route-handlers)
12
12
  * when using `NextResponse` to create the response of the route handler
13
13
  */
14
- type NextRequestAndNextResponseContext = {
14
+ interface NextRequestAndNextResponseContext {
15
15
  request: NextRequest;
16
16
  response: NextResponse;
17
- };
17
+ }
18
18
  /**
19
19
  * This context is normally available in the following:
20
20
  * - Next App Router [route handler](https://nextjs.org/docs/app/building-your-application/routing/route-handlers)
21
21
  * when using the Web API [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response)
22
22
  * to create the response of the route handler
23
23
  */
24
- type NextRequestAndResponseContext = {
24
+ interface NextRequestAndResponseContext {
25
25
  request: NextRequest;
26
26
  response: Response;
27
- };
27
+ }
28
28
  /**
29
29
  * This context is normally available in the following:
30
30
  * - Next [Server Component](https://nextjs.org/docs/getting-started/react-essentials#server-components)
31
31
  * where the [`cookies`](https://nextjs.org/docs/app/api-reference/functions/cookies)
32
32
  * function can be imported and called
33
33
  */
34
- type ServerComponentContext = {
34
+ interface ServerComponentContext {
35
35
  cookies: typeof cookies;
36
- };
36
+ }
37
37
  type ServerActionContext = ServerComponentContext;
38
38
  /**
39
39
  * This context is normally available in the
40
40
  * [`getServerSideProps`](https://nextjs.org/docs/pages/building-your-application/data-fetching/get-server-side-props)
41
41
  * function of the Next Pages Router.
42
42
  */
43
- type GetServerSidePropsContext = {
43
+ interface GetServerSidePropsContext {
44
44
  request: NextGetServerSidePropsContext['req'];
45
45
  response: NextGetServerSidePropsContext['res'];
46
- };
46
+ }
47
47
  /**
48
48
  * The union of possible Next.js app server context types.
49
49
  */
50
50
  type Context = NextRequestAndNextResponseContext | NextRequestAndResponseContext | ServerComponentContext | GetServerSidePropsContext;
51
- /**
52
- * The interface of the input of {@link RunOperationWithContext}.
53
- */
54
51
  interface RunWithContextInput<OperationResult> {
55
52
  nextServerContext: Context | null;
56
- operation: (contextSpec: AmplifyServer.ContextSpec) => OperationResult | Promise<OperationResult>;
57
- }
58
- interface RunOperationWithContext {
59
- <OperationResult>(input: RunWithContextInput<OperationResult>): Promise<OperationResult>;
53
+ operation(contextSpec: AmplifyServer.ContextSpec): OperationResult | Promise<OperationResult>;
60
54
  }
55
+ type RunOperationWithContext = <OperationResult>(input: RunWithContextInput<OperationResult>) => Promise<OperationResult>;
61
56
  interface CreateServerRunnerInput {
62
57
  config: ResourcesConfig | LegacyConfig;
63
58
  }
64
59
  interface CreateServerRunnerOutput {
65
60
  runWithAmplifyServerContext: RunOperationWithContext;
66
61
  }
67
- interface CreateServerRunner {
68
- (input: CreateServerRunnerInput): CreateServerRunnerOutput;
69
- }
62
+ type CreateServerRunner = (input: CreateServerRunnerInput) => CreateServerRunnerOutput;
70
63
  }
@@ -1,4 +1,4 @@
1
- import { NextServer } from '../types';
2
1
  import { CookieStorage } from '@aws-amplify/core/internals/adapter-core';
2
+ import { NextServer } from '../types';
3
3
  export declare const DATE_IN_THE_PAST: Date;
4
4
  export declare const createCookieStorageAdapterFromNextServerContext: (context: NextServer.Context) => CookieStorage.Adapter;
@@ -1 +1 @@
1
- {"version":3,"file":"createCookieStorageAdapterFromNextServerContext.mjs","sources":["../../../src/utils/createCookieStorageAdapterFromNextServerContext.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { NextResponse } from 'next/server.js';\nimport { AmplifyServerContextError, } from '@aws-amplify/core/internals/adapter-core';\nexport const DATE_IN_THE_PAST = new Date(0);\nexport const createCookieStorageAdapterFromNextServerContext = (context) => {\n const { request: req, response: res } = context;\n // When the server context is from `getServerSideProps`, the `req` is an instance\n // of IncomingMessage, and the `res` is an instance of ServerResponse.\n // We cannot import these two classes here from `http` as it breaks in Next\n // Edge Runtime. Hence, we check the methods that we need to use for creating\n // cookie adapter.\n if (req &&\n res &&\n Object.prototype.toString.call(req.cookies) === '[object Object]' &&\n typeof res.setHeader === 'function') {\n return createCookieStorageAdapterFromGetServerSidePropsContext(req, res);\n }\n const { request, response } = context;\n // When the server context is from `middleware`, the `request` is an instance\n // of `NextRequest`.\n // When the server context is from a route handler, the `request` is an `Proxy`\n // wrapped `Request`.\n // The `NextRequest` and the `Proxy` are sharing the same interface by Next\n // implementation. So we don't need to detect the difference.\n if (request && response) {\n if (response instanceof NextResponse) {\n return createCookieStorageAdapterFromNextRequestAndNextResponse(request, response);\n }\n else {\n return createCookieStorageAdapterFromNextRequestAndHttpResponse(request, response);\n }\n }\n const { cookies } = context;\n if (typeof cookies === 'function') {\n return createCookieStorageAdapterFromNextCookies(cookies);\n }\n // This should not happen normally.\n throw new AmplifyServerContextError({\n message: 'Attempted to create cookie storage adapter from an unsupported Next.js server context.',\n });\n};\nconst createCookieStorageAdapterFromNextRequestAndNextResponse = (request, response) => {\n const readonlyCookieStore = request.cookies;\n const mutableCookieStore = response.cookies;\n return {\n get(name) {\n return readonlyCookieStore.get(ensureEncodedForJSCookie(name));\n },\n getAll: readonlyCookieStore.getAll.bind(readonlyCookieStore),\n set(name, value, options) {\n mutableCookieStore.set(ensureEncodedForJSCookie(name), value, options);\n },\n delete(name) {\n mutableCookieStore.delete(ensureEncodedForJSCookie(name));\n },\n };\n};\nconst createCookieStorageAdapterFromNextRequestAndHttpResponse = (request, response) => {\n const readonlyCookieStore = request.cookies;\n const mutableCookieStore = createMutableCookieStoreFromHeaders(response.headers);\n return {\n get(name) {\n return readonlyCookieStore.get(ensureEncodedForJSCookie(name));\n },\n getAll: readonlyCookieStore.getAll.bind(readonlyCookieStore),\n ...mutableCookieStore,\n };\n};\nconst createCookieStorageAdapterFromNextCookies = (cookies) => {\n const cookieStore = cookies();\n // When Next cookies() is called in a server component, it returns a readonly\n // cookie store. Hence calling set and delete throws an error. However,\n // cookies() returns a mutable cookie store when called in a server action.\n // We have no way to detect which one is returned, so we try to call set and delete\n // and safely ignore the error if it is thrown.\n const setFunc = (name, value, options) => {\n try {\n cookieStore.set(ensureEncodedForJSCookie(name), value, options);\n }\n catch {\n // no-op\n }\n };\n const deleteFunc = name => {\n try {\n cookieStore.delete(ensureEncodedForJSCookie(name));\n }\n catch {\n // no-op\n }\n };\n return {\n get(name) {\n return cookieStore.get(ensureEncodedForJSCookie(name));\n },\n getAll: cookieStore.getAll.bind(cookieStore),\n set: setFunc,\n delete: deleteFunc,\n };\n};\nconst createCookieStorageAdapterFromGetServerSidePropsContext = (request, response) => {\n const cookiesMap = { ...request.cookies };\n const allCookies = Object.entries(cookiesMap).map(([name, value]) => ({\n name,\n value,\n }));\n return {\n get(name) {\n const value = cookiesMap[ensureEncodedForJSCookie(name)];\n return value\n ? {\n name,\n value,\n }\n : undefined;\n },\n getAll() {\n return allCookies;\n },\n set(name, value, options) {\n response.setHeader('Set-Cookie', `${ensureEncodedForJSCookie(name)}=${value};${options ? serializeSetCookieOptions(options) : ''}`);\n },\n delete(name) {\n response.setHeader('Set-Cookie', `${ensureEncodedForJSCookie(name)}=;Expires=${DATE_IN_THE_PAST.toUTCString()}`);\n },\n };\n};\nconst createMutableCookieStoreFromHeaders = (headers) => {\n const setFunc = (name, value, options) => {\n headers.append('Set-Cookie', `${ensureEncodedForJSCookie(name)}=${value};${options ? serializeSetCookieOptions(options) : ''}`);\n };\n const deleteFunc = name => {\n headers.append('Set-Cookie', `${ensureEncodedForJSCookie(name)}=;Expires=${DATE_IN_THE_PAST.toUTCString()}`);\n };\n return {\n set: setFunc,\n delete: deleteFunc,\n };\n};\nconst serializeSetCookieOptions = (options) => {\n const { expires, domain, httpOnly, sameSite, secure } = options;\n const serializedOptions = [];\n if (domain) {\n serializedOptions.push(`Domain=${domain}`);\n }\n if (expires) {\n serializedOptions.push(`Expires=${expires.toUTCString()}`);\n }\n if (httpOnly) {\n serializedOptions.push(`HttpOnly`);\n }\n if (sameSite) {\n serializedOptions.push(`SameSite=${sameSite}`);\n }\n if (secure) {\n serializedOptions.push(`Secure`);\n }\n return serializedOptions.join(';');\n};\n// Ensures the cookie names are encoded in order to look up the cookie store\n// that is manipulated by js-cookie on the client side.\n// Details of the js-cookie encoding behavior see:\n// https://github.com/js-cookie/js-cookie#encoding\n// The implementation is borrowed from js-cookie without escaping `[()]` as\n// we are not using those chars in the auth keys.\nconst ensureEncodedForJSCookie = (name) => encodeURIComponent(name).replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent);\n"],"names":[],"mappings":";;;AAAA;AACA;AAGY,MAAC,gBAAgB,GAAG,IAAI,IAAI,CAAC,CAAC,EAAE;AAChC,MAAC,+CAA+C,GAAG,CAAC,OAAO,KAAK;AAC5E,IAAI,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;AACpD;AACA;AACA;AACA;AACA;AACA,IAAI,IAAI,GAAG;AACX,QAAQ,GAAG;AACX,QAAQ,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,iBAAiB;AACzE,QAAQ,OAAO,GAAG,CAAC,SAAS,KAAK,UAAU,EAAE;AAC7C,QAAQ,OAAO,uDAAuD,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AACjF,KAAK;AACL,IAAI,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,IAAI,OAAO,IAAI,QAAQ,EAAE;AAC7B,QAAQ,IAAI,QAAQ,YAAY,YAAY,EAAE;AAC9C,YAAY,OAAO,wDAAwD,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;AAC/F,SAAS;AACT,aAAa;AACb,YAAY,OAAO,wDAAwD,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;AAC/F,SAAS;AACT,KAAK;AACL,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D,KAAK;AACL,IAAI,IAAI,MAAM,EAAE;AAChB,QAAQ,iBAAiB,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AACzC,KAAK;AACL,IAAI,OAAO,iBAAiB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACvC,CAAC,CAAC;AACF;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,wBAAwB,GAAG,CAAC,IAAI,KAAK,kBAAkB,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,sBAAsB,EAAE,kBAAkB,CAAC;;;;"}
1
+ {"version":3,"file":"createCookieStorageAdapterFromNextServerContext.mjs","sources":["../../../../src/utils/createCookieStorageAdapterFromNextServerContext.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAAA;AACA;MAUa,gBAAgB,GAAG,IAAI,IAAI,CAAC,CAAC,EAAE;AAE/B,MAAA,+CAA+C,GAAG,CAC9D,OAA2B,KACD;IAC1B,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,GACpC,OAAwD,CAAC;;;;;;AAO1D,IAAA,IACC,GAAG;QACH,GAAG;AACH,QAAA,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,iBAAiB;AACjE,QAAA,OAAO,GAAG,CAAC,SAAS,KAAK,UAAU,EAClC;AACD,QAAA,OAAO,uDAAuD,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AACzE,KAAA;AAED,IAAA,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,OAG7B,CAAC;;;;;;;IAQF,IAAI,OAAO,IAAI,QAAQ,EAAE;QACxB,IAAI,QAAQ,YAAY,YAAY,EAAE;AACrC,YAAA,OAAO,wDAAwD,CAC9D,OAAO,EACP,QAAQ,CACR,CAAC;AACF,SAAA;AAAM,aAAA;AACN,YAAA,OAAO,wDAAwD,CAC9D,OAAO,EACP,QAAQ,CACR,CAAC;AAC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unWithAmplifyServerContext.mjs","sources":["../../../src/utils/createRunWithAmplifyServerContext.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { sharedInMemoryStorage } from '@aws-amplify/core';\nimport { createAWSCredentialsAndIdentityIdProvider, createKeyValueStorageFromCookieStorageAdapter, createUserPoolsTokenProvider, runWithAmplifyServerContext as runWithAmplifyServerContextCore, } from 'aws-amplify/adapter-core';\nimport { createCookieStorageAdapterFromNextServerContext } from './createCookieStorageAdapterFromNextServerContext';\nexport const createRunWithAmplifyServerContext = ({ config: resourcesConfig, }) => {\n const runWithAmplifyServerContext = async ({ nextServerContext, operation }) => {\n // When the Auth config is presented, attempt to create a Amplify server\n // context with token and credentials provider.\n if (resourcesConfig.Auth) {\n const keyValueStorage = \n // When `null` is passed as the value of `nextServerContext`, opt-in\n // unauthenticated role (primarily for static rendering). It's\n // safe to use the singleton `MemoryKeyValueStorage` here, as the\n // static rendering uses the same unauthenticated role cross-sever.\n nextServerContext === null\n ? sharedInMemoryStorage\n : createKeyValueStorageFromCookieStorageAdapter(createCookieStorageAdapterFromNextServerContext(nextServerContext));\n const credentialsProvider = createAWSCredentialsAndIdentityIdProvider(resourcesConfig.Auth, keyValueStorage);\n const tokenProvider = createUserPoolsTokenProvider(resourcesConfig.Auth, keyValueStorage);\n return runWithAmplifyServerContextCore(resourcesConfig, {\n Auth: { credentialsProvider, tokenProvider },\n }, operation);\n }\n // Otherwise it may be the case that auth is not used, e.g. API key.\n // Omitting the `Auth` in the second parameter.\n return runWithAmplifyServerContextCore(resourcesConfig, {}, operation);\n };\n return runWithAmplifyServerContext;\n};\n"],"names":["runWithAmplifyServerContext","runWithAmplifyServerContextCore"],"mappings":";;;;AAAA;AACA;AAIY,MAAC,iCAAiC,GAAG,CAAC,EAAE,MAAM,EAAE,eAAe,GAAG,KAAK;AACnF,IAAI,MAAMA,6BAA2B,GAAG,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,KAAK;AACpF;AACA;AACA,QAAQ,IAAI,eAAe,CAAC,IAAI,EAAE;AAClC,YAAY,MAAM,eAAe;AACjC;AACA;AACA;AACA;AACA,YAAY,iBAAiB,KAAK,IAAI;AACtC,kBAAkB,qBAAqB;AACvC,kBAAkB,6CAA6C,CAAC,+CAA+C,CAAC,iBAAiB,CAAC,CAAC,CAAC;AACpI,YAAY,MAAM,mBAAmB,GAAG,yCAAyC,CAAC,eAAe,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC;AACzH,YAAY,MAAM,aAAa,GAAG,4BAA4B,CAAC,eAAe,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC;AACtG,YAAY,OAAOC,2BAA+B,CAAC,eAAe,EAAE;AACpE,gBAAgB,IAAI,EAAE,EAAE,mBAAmB,EAAE,aAAa,EAAE;AAC5D,aAAa,EAAE,SAAS,CAAC,CAAC;AAC1B,SAAS;AACT;AACA;AACA,QAAQ,OAAOA,2BAA+B,CAAC,eAAe,EAAE,EAAE,EAAE,SAAS,CAAC,CAAC;AAC/E,KAAK,CAAC;AACN,IAAI,OAAOD,6BAA2B,CAAC;AACvC;;;;"}
1
+ {"version":3,"file":"createRunWithAmplifyServerContext.mjs","sources":["../../../../src/utils/createRunWithAmplifyServerContext.ts"],"sourcesContent":[null],"names":["runWithAmplifyServerContext","runWithAmplifyServerContextCore"],"mappings":";;;;AAAA;AACA;AAca,MAAA,iCAAiC,GAAG,CAAC,EACjD,MAAM,EAAE,eAAe,GAGvB,KAAI;IACJ,MAAMA,6BAA2B,GAChC,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,KAAI;;;QAG1C,IAAI,eAAe,CAAC,IAAI,EAAE;AACzB,YAAA,MAAM,eAAe;;;;;AAKpB,YAAA,iBAAiB,KAAK,IAAI;AACzB,kBAAE,qBAAqB;kBACrB,6CAA6C,CAC7C,+CAA+C,CAC9C,iBAAiB,CACjB,CACA,CAAC;YACN,MAAM,mBAAmB,GAAG,yCAAyC,CACpE,eAAe,CAAC,IAAI,EACpB,eAAe,CACf,CAAC;YACF,MAAM,aAAa,GAAG,4BAA4B,CACjD,eAAe,CAAC,IAAI,EACpB,eAAe,CACf,CAAC;YAEF,OAAOC,2BAA+B,CACrC,eAAe,EACf;AACC,gBAAA,IAAI,EAAE,EAAE,mBAAmB,EAAE,aAAa,EAAE;aAC5C,EACD,SAAS,CACT,CAAC;AACF,SAAA;;;QAID,OAAOA,2BAA+B,CAAC,eAAe,EAAE,EAAE,EAAE,SAAS,CAAC,CAAC;AACxE,KAAC,CAAC;AAEH,IAAA,OAAOD,6BAA2B,CAAC;AACpC;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"getAmplifyConfig.mjs","sources":["../../../src/utils/getAmplifyConfig.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { parseAWSExports } from '@aws-amplify/core/internals/utils';\nexport const getAmplifyConfig = (config) => Object.keys(config).some(key => key.startsWith('aws_'))\n ? parseAWSExports(config)\n : config;\n"],"names":[],"mappings":";;AAAA;AACA;AAEY,MAAC,gBAAgB,GAAG,CAAC,MAAM,KAAK,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;AACnG,MAAM,eAAe,CAAC,MAAM,CAAC;AAC7B,MAAM;;;;"}
1
+ {"version":3,"file":"getAmplifyConfig.mjs","sources":["../../../../src/utils/getAmplifyConfig.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;AACA;AAMO,MAAM,gBAAgB,GAAG,CAC/B,MAAsC,KAEtC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;AACtD,MAAE,eAAe,CAAC,MAAM,CAAC;MACtB;;;;"}
package/package.json CHANGED
@@ -1,76 +1,73 @@
1
1
  {
2
- "author": "Amazon Web Services",
3
- "name": "@aws-amplify/adapter-nextjs",
4
- "version": "1.0.14-unstable.b814567.0+b814567",
5
- "description": "The adapter for the supporting of using Amplify APIs in Next.js.",
6
- "peerDependencies": {
7
- "aws-amplify": "6.0.14-unstable.b814567.0+b814567",
8
- "next": ">=13.5.0 <15.0.0"
9
- },
10
- "dependencies": {
11
- "cookie": "0.5.0"
12
- },
13
- "devDependencies": {
14
- "@rollup/plugin-typescript": "11.1.5",
15
- "@types/cookie": "0.5.1",
16
- "@types/node": "^20.3.1",
17
- "@types/react": "^18.2.13",
18
- "@types/react-dom": "^18.2.6",
19
- "aws-amplify": "6.0.14-unstable.b814567.0+b814567",
20
- "jest-fetch-mock": "3.0.3",
21
- "next": ">= 13.5.0 < 15.0.0",
22
- "rollup": "3.29.4",
23
- "typescript": "5.0.2"
24
- },
25
- "publishConfig": {
26
- "access": "public"
27
- },
28
- "bugs": {
29
- "url": "https://github.com/aws/aws-amplify/issues"
30
- },
31
- "exports": {
32
- ".": {
33
- "types": "./dist/esm/index.d.ts",
34
- "import": "./dist/esm/index.mjs",
35
- "require": "./dist/cjs/index.js"
36
- },
37
- "./api": {
38
- "types": "./dist/esm/api/index.d.ts",
39
- "import": "./dist/esm/api/index.mjs",
40
- "require": "./dist/cjs/api/index.js"
41
- },
42
- "./data": {
43
- "types": "./dist/esm/api/index.d.ts",
44
- "import": "./dist/esm/api/index.mjs",
45
- "require": "./dist/cjs/api/index.js"
46
- },
47
- "./package.json": "./package.json"
48
- },
49
- "files": [
50
- "dist/cjs",
51
- "dist/esm",
52
- "src",
53
- "api",
54
- "data"
55
- ],
56
- "homepage": "https://aws-amplify.github.io/",
57
- "license": "Apache-2.0",
58
- "main": "./dist/cjs/index.js",
59
- "module": "./dist/esm/index.mjs",
60
- "typings": "./dist/esm/index.d.ts",
61
- "sideEffects": false,
62
- "scripts": {
63
- "build": "npm run clean && npm run build:esm-cjs",
64
- "build-with-test": "npm test && npm run build",
65
- "build:cjs:watch": "rimraf dist/cjs && tsc -m commonjs --outDir dist/cjs --watch",
66
- "build:esm-cjs": "rollup -c rollup.config.mjs",
67
- "build:esm:watch": "rimraf dist/esm && tsc -m esnext --outDir dist/esm --watch",
68
- "clean": "npm run clean:size && rimraf dist",
69
- "clean:size": "rimraf dual-publish-tmp tmp*",
70
- "format": "echo \"Not implemented\"",
71
- "lint": "tslint 'src/**/*.ts' && npm run ts-coverage",
72
- "test": "npm run lint && jest -w 1 --coverage --logHeapUsage",
73
- "ts-coverage": "typescript-coverage-report -p ./tsconfig.build.json -t 90.31"
74
- },
75
- "gitHead": "b814567adf4cc3cdaad38fe94580d90697ee521a"
2
+ "author": "Amazon Web Services",
3
+ "name": "@aws-amplify/adapter-nextjs",
4
+ "version": "1.0.14",
5
+ "description": "The adapter for the supporting of using Amplify APIs in Next.js.",
6
+ "peerDependencies": {
7
+ "aws-amplify": "^6.0.7",
8
+ "next": ">=13.5.0 <15.0.0"
9
+ },
10
+ "dependencies": {
11
+ "cookie": "0.5.0"
12
+ },
13
+ "devDependencies": {
14
+ "@types/cookie": "0.5.1",
15
+ "@types/node": "^20.3.1",
16
+ "@types/react": "^18.2.13",
17
+ "@types/react-dom": "^18.2.6",
18
+ "aws-amplify": "6.0.14",
19
+ "jest-fetch-mock": "3.0.3",
20
+ "next": ">= 13.5.0 < 15.0.0"
21
+ },
22
+ "publishConfig": {
23
+ "access": "public"
24
+ },
25
+ "bugs": {
26
+ "url": "https://github.com/aws/aws-amplify/issues"
27
+ },
28
+ "exports": {
29
+ ".": {
30
+ "types": "./dist/esm/index.d.ts",
31
+ "import": "./dist/esm/index.mjs",
32
+ "require": "./dist/cjs/index.js"
33
+ },
34
+ "./api": {
35
+ "types": "./dist/esm/api/index.d.ts",
36
+ "import": "./dist/esm/api/index.mjs",
37
+ "require": "./dist/cjs/api/index.js"
38
+ },
39
+ "./data": {
40
+ "types": "./dist/esm/api/index.d.ts",
41
+ "import": "./dist/esm/api/index.mjs",
42
+ "require": "./dist/cjs/api/index.js"
43
+ },
44
+ "./package.json": "./package.json"
45
+ },
46
+ "files": [
47
+ "dist/cjs",
48
+ "dist/esm",
49
+ "src",
50
+ "api",
51
+ "data"
52
+ ],
53
+ "homepage": "https://aws-amplify.github.io/",
54
+ "license": "Apache-2.0",
55
+ "main": "./dist/cjs/index.js",
56
+ "module": "./dist/esm/index.mjs",
57
+ "typings": "./dist/esm/index.d.ts",
58
+ "sideEffects": false,
59
+ "scripts": {
60
+ "build": "npm run clean && npm run build:esm-cjs",
61
+ "build-with-test": "npm test && npm run build",
62
+ "build:esm-cjs": "rollup -c rollup.config.mjs",
63
+ "build:watch": "npm run build:esm-cjs -- --watch",
64
+ "clean": "npm run clean:size && rimraf dist",
65
+ "clean:size": "rimraf dual-publish-tmp tmp*",
66
+ "format": "echo \"Not implemented\"",
67
+ "lint": "eslint '**/*.{ts,tsx}' && npm run ts-coverage",
68
+ "lint:fix": "eslint '**/*.{ts,tsx}' --fix",
69
+ "test": "npm run lint && jest -w 1 --coverage --logHeapUsage",
70
+ "ts-coverage": "typescript-coverage-report -p ./tsconfig.build.json -t 90.31"
71
+ },
72
+ "gitHead": "ac07014b8a5bbf12f6e9188a6eb2f3f29cc3880c"
76
73
  }
@@ -2,6 +2,7 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  import { ResourcesConfig } from 'aws-amplify';
5
+
5
6
  import { createRunWithAmplifyServerContext, getAmplifyConfig } from './utils';
6
7
  import { NextServer } from './types';
7
8
 
@@ -8,17 +8,17 @@ import { LegacyConfig } from 'aws-amplify/adapter-core';
8
8
  import { AmplifyServer } from '@aws-amplify/core/internals/adapter-core';
9
9
  import { ResourcesConfig } from '@aws-amplify/core';
10
10
 
11
- export namespace NextServer {
11
+ export declare namespace NextServer {
12
12
  /**
13
13
  * This context is normally available in the following:
14
14
  * - Next App Router [middleware](https://nextjs.org/docs/app/building-your-application/routing/middleware)
15
15
  * - Next App Router [route handler](https://nextjs.org/docs/app/building-your-application/routing/route-handlers)
16
16
  * when using `NextResponse` to create the response of the route handler
17
17
  */
18
- export type NextRequestAndNextResponseContext = {
18
+ export interface NextRequestAndNextResponseContext {
19
19
  request: NextRequest;
20
20
  response: NextResponse;
21
- };
21
+ }
22
22
 
23
23
  /**
24
24
  * This context is normally available in the following:
@@ -26,10 +26,10 @@ export namespace NextServer {
26
26
  * when using the Web API [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response)
27
27
  * to create the response of the route handler
28
28
  */
29
- export type NextRequestAndResponseContext = {
29
+ export interface NextRequestAndResponseContext {
30
30
  request: NextRequest;
31
31
  response: Response;
32
- };
32
+ }
33
33
 
34
34
  /**
35
35
  * This context is normally available in the following:
@@ -37,9 +37,9 @@ export namespace NextServer {
37
37
  * where the [`cookies`](https://nextjs.org/docs/app/api-reference/functions/cookies)
38
38
  * function can be imported and called
39
39
  */
40
- export type ServerComponentContext = {
40
+ export interface ServerComponentContext {
41
41
  cookies: typeof cookies;
42
- };
42
+ }
43
43
 
44
44
  export type ServerActionContext = ServerComponentContext;
45
45
 
@@ -48,10 +48,10 @@ export namespace NextServer {
48
48
  * [`getServerSideProps`](https://nextjs.org/docs/pages/building-your-application/data-fetching/get-server-side-props)
49
49
  * function of the Next Pages Router.
50
50
  */
51
- export type GetServerSidePropsContext = {
51
+ export interface GetServerSidePropsContext {
52
52
  request: NextGetServerSidePropsContext['req'];
53
53
  response: NextGetServerSidePropsContext['res'];
54
- };
54
+ }
55
55
 
56
56
  /**
57
57
  * The union of possible Next.js app server context types.
@@ -62,21 +62,16 @@ export namespace NextServer {
62
62
  | ServerComponentContext
63
63
  | GetServerSidePropsContext;
64
64
 
65
- /**
66
- * The interface of the input of {@link RunOperationWithContext}.
67
- */
68
65
  export interface RunWithContextInput<OperationResult> {
69
66
  nextServerContext: Context | null;
70
- operation: (
71
- contextSpec: AmplifyServer.ContextSpec
72
- ) => OperationResult | Promise<OperationResult>;
67
+ operation(
68
+ contextSpec: AmplifyServer.ContextSpec,
69
+ ): OperationResult | Promise<OperationResult>;
73
70
  }
74
71
 
75
- export interface RunOperationWithContext {
76
- <OperationResult>(
77
- input: RunWithContextInput<OperationResult>
78
- ): Promise<OperationResult>;
79
- }
72
+ export type RunOperationWithContext = <OperationResult>(
73
+ input: RunWithContextInput<OperationResult>,
74
+ ) => Promise<OperationResult>;
80
75
 
81
76
  export interface CreateServerRunnerInput {
82
77
  config: ResourcesConfig | LegacyConfig;
@@ -86,7 +81,7 @@ export namespace NextServer {
86
81
  runWithAmplifyServerContext: RunOperationWithContext;
87
82
  }
88
83
 
89
- export interface CreateServerRunner {
90
- (input: CreateServerRunnerInput): CreateServerRunnerOutput;
91
- }
84
+ export type CreateServerRunner = (
85
+ input: CreateServerRunnerInput,
86
+ ) => CreateServerRunnerOutput;
92
87
  }
@@ -2,16 +2,17 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  import { NextRequest, NextResponse } from 'next/server.js';
5
- import { NextServer } from '../types';
6
5
  import {
7
6
  AmplifyServerContextError,
8
7
  CookieStorage,
9
8
  } from '@aws-amplify/core/internals/adapter-core';
10
9
 
10
+ import { NextServer } from '../types';
11
+
11
12
  export const DATE_IN_THE_PAST = new Date(0);
12
13
 
13
14
  export const createCookieStorageAdapterFromNextServerContext = (
14
- context: NextServer.Context
15
+ context: NextServer.Context,
15
16
  ): CookieStorage.Adapter => {
16
17
  const { request: req, response: res } =
17
18
  context as Partial<NextServer.GetServerSidePropsContext>;
@@ -45,12 +46,12 @@ export const createCookieStorageAdapterFromNextServerContext = (
45
46
  if (response instanceof NextResponse) {
46
47
  return createCookieStorageAdapterFromNextRequestAndNextResponse(
47
48
  request,
48
- response
49
+ response,
49
50
  );
50
51
  } else {
51
52
  return createCookieStorageAdapterFromNextRequestAndHttpResponse(
52
53
  request,
53
- response
54
+ response,
54
55
  );
55
56
  }
56
57
  }
@@ -72,7 +73,7 @@ export const createCookieStorageAdapterFromNextServerContext = (
72
73
 
73
74
  const createCookieStorageAdapterFromNextRequestAndNextResponse = (
74
75
  request: NextRequest,
75
- response: NextResponse
76
+ response: NextResponse,
76
77
  ): CookieStorage.Adapter => {
77
78
  const readonlyCookieStore = request.cookies;
78
79
  const mutableCookieStore = response.cookies;
@@ -93,11 +94,11 @@ const createCookieStorageAdapterFromNextRequestAndNextResponse = (
93
94
 
94
95
  const createCookieStorageAdapterFromNextRequestAndHttpResponse = (
95
96
  request: NextRequest,
96
- response: Response
97
+ response: Response,
97
98
  ): CookieStorage.Adapter => {
98
99
  const readonlyCookieStore = request.cookies;
99
100
  const mutableCookieStore = createMutableCookieStoreFromHeaders(
100
- response.headers
101
+ response.headers,
101
102
  );
102
103
 
103
104
  return {
@@ -110,7 +111,7 @@ const createCookieStorageAdapterFromNextRequestAndHttpResponse = (
110
111
  };
111
112
 
112
113
  const createCookieStorageAdapterFromNextCookies = (
113
- cookies: NextServer.ServerComponentContext['cookies']
114
+ cookies: NextServer.ServerComponentContext['cookies'],
114
115
  ): CookieStorage.Adapter => {
115
116
  const cookieStore = cookies();
116
117
 
@@ -147,7 +148,7 @@ const createCookieStorageAdapterFromNextCookies = (
147
148
 
148
149
  const createCookieStorageAdapterFromGetServerSidePropsContext = (
149
150
  request: NextServer.GetServerSidePropsContext['request'],
150
- response: NextServer.GetServerSidePropsContext['response']
151
+ response: NextServer.GetServerSidePropsContext['response'],
151
152
  ): CookieStorage.Adapter => {
152
153
  const cookiesMap = { ...request.cookies };
153
154
  const allCookies = Object.entries(cookiesMap).map(([name, value]) => ({
@@ -158,6 +159,7 @@ const createCookieStorageAdapterFromGetServerSidePropsContext = (
158
159
  return {
159
160
  get(name) {
160
161
  const value = cookiesMap[ensureEncodedForJSCookie(name)];
162
+
161
163
  return value
162
164
  ? {
163
165
  name,
@@ -173,39 +175,40 @@ const createCookieStorageAdapterFromGetServerSidePropsContext = (
173
175
  'Set-Cookie',
174
176
  `${ensureEncodedForJSCookie(name)}=${value};${
175
177
  options ? serializeSetCookieOptions(options) : ''
176
- }`
178
+ }`,
177
179
  );
178
180
  },
179
181
  delete(name) {
180
182
  response.setHeader(
181
183
  'Set-Cookie',
182
184
  `${ensureEncodedForJSCookie(
183
- name
184
- )}=;Expires=${DATE_IN_THE_PAST.toUTCString()}`
185
+ name,
186
+ )}=;Expires=${DATE_IN_THE_PAST.toUTCString()}`,
185
187
  );
186
188
  },
187
189
  };
188
190
  };
189
191
 
190
192
  const createMutableCookieStoreFromHeaders = (
191
- headers: Headers
193
+ headers: Headers,
192
194
  ): Pick<CookieStorage.Adapter, 'set' | 'delete'> => {
193
195
  const setFunc: CookieStorage.Adapter['set'] = (name, value, options) => {
194
196
  headers.append(
195
197
  'Set-Cookie',
196
198
  `${ensureEncodedForJSCookie(name)}=${value};${
197
199
  options ? serializeSetCookieOptions(options) : ''
198
- }`
200
+ }`,
199
201
  );
200
202
  };
201
203
  const deleteFunc: CookieStorage.Adapter['delete'] = name => {
202
204
  headers.append(
203
205
  'Set-Cookie',
204
206
  `${ensureEncodedForJSCookie(
205
- name
206
- )}=;Expires=${DATE_IN_THE_PAST.toUTCString()}`
207
+ name,
208
+ )}=;Expires=${DATE_IN_THE_PAST.toUTCString()}`,
207
209
  );
208
210
  };
211
+
209
212
  return {
210
213
  set: setFunc,
211
214
  delete: deleteFunc,
@@ -213,7 +216,7 @@ const createMutableCookieStoreFromHeaders = (
213
216
  };
214
217
 
215
218
  const serializeSetCookieOptions = (
216
- options: CookieStorage.SetCookieOptions
219
+ options: CookieStorage.SetCookieOptions,
217
220
  ): string => {
218
221
  const { expires, domain, httpOnly, sameSite, secure } = options;
219
222
  const serializedOptions: string[] = [];
@@ -232,6 +235,7 @@ const serializeSetCookieOptions = (
232
235
  if (secure) {
233
236
  serializedOptions.push(`Secure`);
234
237
  }
238
+
235
239
  return serializedOptions.join(';');
236
240
  };
237
241
 
@@ -9,9 +9,10 @@ import {
9
9
  runWithAmplifyServerContext as runWithAmplifyServerContextCore,
10
10
  } from 'aws-amplify/adapter-core';
11
11
 
12
- import { createCookieStorageAdapterFromNextServerContext } from './createCookieStorageAdapterFromNextServerContext';
13
12
  import { NextServer } from '../types';
14
13
 
14
+ import { createCookieStorageAdapterFromNextServerContext } from './createCookieStorageAdapterFromNextServerContext';
15
+
15
16
  export const createRunWithAmplifyServerContext = ({
16
17
  config: resourcesConfig,
17
18
  }: {
@@ -31,16 +32,16 @@ export const createRunWithAmplifyServerContext = ({
31
32
  ? sharedInMemoryStorage
32
33
  : createKeyValueStorageFromCookieStorageAdapter(
33
34
  createCookieStorageAdapterFromNextServerContext(
34
- nextServerContext
35
- )
35
+ nextServerContext,
36
+ ),
36
37
  );
37
38
  const credentialsProvider = createAWSCredentialsAndIdentityIdProvider(
38
39
  resourcesConfig.Auth,
39
- keyValueStorage
40
+ keyValueStorage,
40
41
  );
41
42
  const tokenProvider = createUserPoolsTokenProvider(
42
43
  resourcesConfig.Auth,
43
- keyValueStorage
44
+ keyValueStorage,
44
45
  );
45
46
 
46
47
  return runWithAmplifyServerContextCore(
@@ -48,7 +49,7 @@ export const createRunWithAmplifyServerContext = ({
48
49
  {
49
50
  Auth: { credentialsProvider, tokenProvider },
50
51
  },
51
- operation
52
+ operation,
52
53
  );
53
54
  }
54
55
 
@@ -6,7 +6,7 @@ import { LegacyConfig } from 'aws-amplify/adapter-core';
6
6
  import { parseAWSExports } from '@aws-amplify/core/internals/utils';
7
7
 
8
8
  export const getAmplifyConfig = (
9
- config: ResourcesConfig | LegacyConfig
9
+ config: ResourcesConfig | LegacyConfig,
10
10
  ): ResourcesConfig =>
11
11
  Object.keys(config).some(key => key.startsWith('aws_'))
12
12
  ? parseAWSExports(config)