@aws-amplify/adapter-nextjs 0.0.2-preview-testing.64b45b1.0 → 0.0.2-preview-testing.034e780.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.
- package/lib/utils/getAmplifyConfig.js +4 -1
- package/lib/utils/getAmplifyConfig.js.map +1 -1
- package/lib/withAmplify.d.ts +2 -12
- package/lib/withAmplify.js +0 -11
- package/lib/withAmplify.js.map +1 -1
- package/lib-esm/utils/getAmplifyConfig.js +4 -1
- package/lib-esm/utils/getAmplifyConfig.js.map +1 -1
- package/lib-esm/withAmplify.d.ts +2 -12
- package/lib-esm/withAmplify.js +0 -11
- package/lib-esm/withAmplify.js.map +1 -1
- package/package.json +3 -3
- package/src/utils/getAmplifyConfig.ts +4 -1
- package/src/withAmplify.ts +3 -13
|
@@ -6,6 +6,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
6
6
|
};
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
8
|
exports.getAmplifyConfig = void 0;
|
|
9
|
+
var utils_1 = require("@aws-amplify/core/internals/utils");
|
|
9
10
|
var adapter_core_1 = require("@aws-amplify/core/internals/adapter-core");
|
|
10
11
|
var config_1 = __importDefault(require("next/config"));
|
|
11
12
|
var getAmplifyConfig = function () {
|
|
@@ -26,7 +27,9 @@ var getAmplifyConfig = function () {
|
|
|
26
27
|
}
|
|
27
28
|
var configObject = JSON.parse(configStr);
|
|
28
29
|
// TODO(HuiSF): adds ResourcesConfig validation when it has one.
|
|
29
|
-
return configObject;
|
|
30
|
+
return Object.keys(configObject).some(function (key) { return key.startsWith('aws_'); })
|
|
31
|
+
? (0, utils_1.parseAWSExports)(configObject)
|
|
32
|
+
: configObject;
|
|
30
33
|
};
|
|
31
34
|
exports.getAmplifyConfig = getAmplifyConfig;
|
|
32
35
|
//# sourceMappingURL=getAmplifyConfig.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getAmplifyConfig.js","sourceRoot":"","sources":["../../src/utils/getAmplifyConfig.ts"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;;;;;;AAGtC,yEAAqF;AACrF,uDAAoC;AAE7B,IAAM,gBAAgB,GAAG;IAC/B,IAAI,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC;IAE1C,qEAAqE;IACrE,yEAAyE;IACzE,4EAA4E;IAC5E,sDAAsD;IACtD,IAAI,CAAC,SAAS,EAAE;QACP,IAAA,mBAAmB,GAAK,IAAA,gBAAS,GAAE,oBAAhB,CAAiB;QAC5C,SAAS,GAAG,mBAAmB,aAAnB,mBAAmB,uBAAnB,mBAAmB,CAAE,aAAa,CAAC;KAC/C;IAED,IAAI,CAAC,SAAS,EAAE;QACf,MAAM,IAAI,wCAAyB,CAAC;YACnC,OAAO,EAAE,sDAAsD;YAC/D,kBAAkB,EACjB,gEAAgE;SACjE,CAAC,CAAC;KACH;IAED,IAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IAE3C,gEAAgE;IAChE,OAAO,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"getAmplifyConfig.js","sourceRoot":"","sources":["../../src/utils/getAmplifyConfig.ts"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;;;;;;AAGtC,2DAAoE;AACpE,yEAAqF;AACrF,uDAAoC;AAE7B,IAAM,gBAAgB,GAAG;IAC/B,IAAI,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC;IAE1C,qEAAqE;IACrE,yEAAyE;IACzE,4EAA4E;IAC5E,sDAAsD;IACtD,IAAI,CAAC,SAAS,EAAE;QACP,IAAA,mBAAmB,GAAK,IAAA,gBAAS,GAAE,oBAAhB,CAAiB;QAC5C,SAAS,GAAG,mBAAmB,aAAnB,mBAAmB,uBAAnB,mBAAmB,CAAE,aAAa,CAAC;KAC/C;IAED,IAAI,CAAC,SAAS,EAAE;QACf,MAAM,IAAI,wCAAyB,CAAC;YACnC,OAAO,EAAE,sDAAsD;YAC/D,kBAAkB,EACjB,gEAAgE;SACjE,CAAC,CAAC;KACH;IAED,IAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IAE3C,gEAAgE;IAChE,OAAO,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,UAAA,GAAG,IAAI,OAAA,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,EAAtB,CAAsB,CAAC;QACnE,CAAC,CAAC,IAAA,uBAAe,EAAC,YAAY,CAAC;QAC/B,CAAC,CAAC,YAAY,CAAC;AACjB,CAAC,CAAC;AA1BW,QAAA,gBAAgB,oBA0B3B"}
|
package/lib/withAmplify.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ResourcesConfig } from 'aws-amplify';
|
|
2
|
+
import { LegacyConfig } from 'aws-amplify/internals/adapter-core';
|
|
2
3
|
import { NextConfig } from 'next';
|
|
3
4
|
/**
|
|
4
5
|
* Merges the `amplifyConfig` into the `nextConfig.env`.
|
|
@@ -6,17 +7,6 @@ import { NextConfig } from 'next';
|
|
|
6
7
|
* @param nextConfig The next config for a Next.js app.
|
|
7
8
|
* @param amplifyConfig The Amplify configuration.
|
|
8
9
|
*
|
|
9
|
-
* **NOTE**: If you are using Amplify CLI to generate the `aws-exports.js`
|
|
10
|
-
* file, you need to use {@link parseAmplifyConfig} to reformat the configuration.
|
|
11
|
-
* E.g.
|
|
12
|
-
* ```javascript
|
|
13
|
-
* const { parseAmplifyConfig } = require('aws-amplify');
|
|
14
|
-
* const { withAmplify } = require('@aws-amplify/adapter-nextjs/with-amplify');
|
|
15
|
-
* const config = require('./src/aws-exports');
|
|
16
|
-
*
|
|
17
|
-
* const nextConfig = {};
|
|
18
|
-
* module.exports = withAmplify(nextConfig, parseAmplifyConfig(config));
|
|
19
|
-
* ```
|
|
20
10
|
* @returns The updated `nextConfig`.
|
|
21
11
|
*/
|
|
22
|
-
export declare const withAmplify: (nextConfig: NextConfig, amplifyConfig: ResourcesConfig) => NextConfig;
|
|
12
|
+
export declare const withAmplify: (nextConfig: NextConfig, amplifyConfig: ResourcesConfig | LegacyConfig) => NextConfig;
|
package/lib/withAmplify.js
CHANGED
|
@@ -23,17 +23,6 @@ exports.withAmplify = void 0;
|
|
|
23
23
|
* @param nextConfig The next config for a Next.js app.
|
|
24
24
|
* @param amplifyConfig The Amplify configuration.
|
|
25
25
|
*
|
|
26
|
-
* **NOTE**: If you are using Amplify CLI to generate the `aws-exports.js`
|
|
27
|
-
* file, you need to use {@link parseAmplifyConfig} to reformat the configuration.
|
|
28
|
-
* E.g.
|
|
29
|
-
* ```javascript
|
|
30
|
-
* const { parseAmplifyConfig } = require('aws-amplify');
|
|
31
|
-
* const { withAmplify } = require('@aws-amplify/adapter-nextjs/with-amplify');
|
|
32
|
-
* const config = require('./src/aws-exports');
|
|
33
|
-
*
|
|
34
|
-
* const nextConfig = {};
|
|
35
|
-
* module.exports = withAmplify(nextConfig, parseAmplifyConfig(config));
|
|
36
|
-
* ```
|
|
37
26
|
* @returns The updated `nextConfig`.
|
|
38
27
|
*/
|
|
39
28
|
var withAmplify = function (nextConfig, amplifyConfig) {
|
package/lib/withAmplify.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withAmplify.js","sourceRoot":"","sources":["../src/withAmplify.ts"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"withAmplify.js","sourceRoot":"","sources":["../src/withAmplify.ts"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;;;;;;;;;;;;;;AAMtC,oEAAoE;AACpE,2EAA2E;AAC3E,sCAAsC;AAEtC;;;;;;;GAOG;AACI,IAAM,WAAW,GAAG,UAC1B,UAAsB,EACtB,aAA6C;IAE7C,IAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;IAChD,UAAU,CAAC,GAAG,yBACV,UAAU,CAAC,GAAG,KACjB,aAAa,EAAE,SAAS,GACxB,CAAC;IAEF,UAAU,CAAC,mBAAmB,yBAC1B,UAAU,CAAC,mBAAmB,KACjC,aAAa,EAAE,SAAS,GACxB,CAAC;IAEF,OAAO,UAAU,CAAC;AACnB,CAAC,CAAC;AAhBW,QAAA,WAAW,eAgBtB"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { parseAWSExports } from '@aws-amplify/core/internals/utils';
|
|
3
4
|
import { AmplifyServerContextError } from '@aws-amplify/core/internals/adapter-core';
|
|
4
5
|
import getConfig from 'next/config';
|
|
5
6
|
export var getAmplifyConfig = function () {
|
|
@@ -20,6 +21,8 @@ export var getAmplifyConfig = function () {
|
|
|
20
21
|
}
|
|
21
22
|
var configObject = JSON.parse(configStr);
|
|
22
23
|
// TODO(HuiSF): adds ResourcesConfig validation when it has one.
|
|
23
|
-
return configObject;
|
|
24
|
+
return Object.keys(configObject).some(function (key) { return key.startsWith('aws_'); })
|
|
25
|
+
? parseAWSExports(configObject)
|
|
26
|
+
: configObject;
|
|
24
27
|
};
|
|
25
28
|
//# sourceMappingURL=getAmplifyConfig.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getAmplifyConfig.js","sourceRoot":"","sources":["../../src/utils/getAmplifyConfig.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAGtC,OAAO,EAAE,yBAAyB,EAAE,MAAM,0CAA0C,CAAC;AACrF,OAAO,SAAS,MAAM,aAAa,CAAC;AAEpC,MAAM,CAAC,IAAM,gBAAgB,GAAG;IAC/B,IAAI,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC;IAE1C,qEAAqE;IACrE,yEAA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CAAC,CAAC;IAE3C,gEAAgE;IAChE,OAAO,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,UAAA,GAAG,IAAI,OAAA,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,EAAtB,CAAsB,CAAC;QACnE,CAAC,CAAC,eAAe,CAAC,YAAY,CAAC;QAC/B,CAAC,CAAC,YAAY,CAAC;AACjB,CAAC,CAAC"}
|
package/lib-esm/withAmplify.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ResourcesConfig } from 'aws-amplify';
|
|
2
|
+
import { LegacyConfig } from 'aws-amplify/internals/adapter-core';
|
|
2
3
|
import { NextConfig } from 'next';
|
|
3
4
|
/**
|
|
4
5
|
* Merges the `amplifyConfig` into the `nextConfig.env`.
|
|
@@ -6,17 +7,6 @@ import { NextConfig } from 'next';
|
|
|
6
7
|
* @param nextConfig The next config for a Next.js app.
|
|
7
8
|
* @param amplifyConfig The Amplify configuration.
|
|
8
9
|
*
|
|
9
|
-
* **NOTE**: If you are using Amplify CLI to generate the `aws-exports.js`
|
|
10
|
-
* file, you need to use {@link parseAmplifyConfig} to reformat the configuration.
|
|
11
|
-
* E.g.
|
|
12
|
-
* ```javascript
|
|
13
|
-
* const { parseAmplifyConfig } = require('aws-amplify');
|
|
14
|
-
* const { withAmplify } = require('@aws-amplify/adapter-nextjs/with-amplify');
|
|
15
|
-
* const config = require('./src/aws-exports');
|
|
16
|
-
*
|
|
17
|
-
* const nextConfig = {};
|
|
18
|
-
* module.exports = withAmplify(nextConfig, parseAmplifyConfig(config));
|
|
19
|
-
* ```
|
|
20
10
|
* @returns The updated `nextConfig`.
|
|
21
11
|
*/
|
|
22
|
-
export declare const withAmplify: (nextConfig: NextConfig, amplifyConfig: ResourcesConfig) => NextConfig;
|
|
12
|
+
export declare const withAmplify: (nextConfig: NextConfig, amplifyConfig: ResourcesConfig | LegacyConfig) => NextConfig;
|
package/lib-esm/withAmplify.js
CHANGED
|
@@ -20,17 +20,6 @@ var __assign = (this && this.__assign) || function () {
|
|
|
20
20
|
* @param nextConfig The next config for a Next.js app.
|
|
21
21
|
* @param amplifyConfig The Amplify configuration.
|
|
22
22
|
*
|
|
23
|
-
* **NOTE**: If you are using Amplify CLI to generate the `aws-exports.js`
|
|
24
|
-
* file, you need to use {@link parseAmplifyConfig} to reformat the configuration.
|
|
25
|
-
* E.g.
|
|
26
|
-
* ```javascript
|
|
27
|
-
* const { parseAmplifyConfig } = require('aws-amplify');
|
|
28
|
-
* const { withAmplify } = require('@aws-amplify/adapter-nextjs/with-amplify');
|
|
29
|
-
* const config = require('./src/aws-exports');
|
|
30
|
-
*
|
|
31
|
-
* const nextConfig = {};
|
|
32
|
-
* module.exports = withAmplify(nextConfig, parseAmplifyConfig(config));
|
|
33
|
-
* ```
|
|
34
23
|
* @returns The updated `nextConfig`.
|
|
35
24
|
*/
|
|
36
25
|
export var withAmplify = function (nextConfig, amplifyConfig) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withAmplify.js","sourceRoot":"","sources":["../src/withAmplify.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"withAmplify.js","sourceRoot":"","sources":["../src/withAmplify.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;;;;;;;;;;;;AAMtC,oEAAoE;AACpE,2EAA2E;AAC3E,sCAAsC;AAEtC;;;;;;;GAOG;AACH,MAAM,CAAC,IAAM,WAAW,GAAG,UAC1B,UAAsB,EACtB,aAA6C;IAE7C,IAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;IAChD,UAAU,CAAC,GAAG,yBACV,UAAU,CAAC,GAAG,KACjB,aAAa,EAAE,SAAS,GACxB,CAAC;IAEF,UAAU,CAAC,mBAAmB,yBAC1B,UAAU,CAAC,mBAAmB,KACjC,aAAa,EAAE,SAAS,GACxB,CAAC;IAEF,OAAO,UAAU,CAAC;AACnB,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"@types/node": "^20.3.1",
|
|
16
16
|
"@types/react": "^18.2.13",
|
|
17
17
|
"@types/react-dom": "^18.2.6",
|
|
18
|
-
"aws-amplify": "6.0.1-preview-testing.
|
|
18
|
+
"aws-amplify": "6.0.1-preview-testing.034e780.0+034e780",
|
|
19
19
|
"jest-fetch-mock": "3.0.3",
|
|
20
20
|
"next": ">= 13.4.0 < 14.0.0",
|
|
21
21
|
"typescript": "5.1.6"
|
|
@@ -107,6 +107,6 @@
|
|
|
107
107
|
"ts-coverage": "typescript-coverage-report -p ./tsconfig.build.json -t 90.31"
|
|
108
108
|
},
|
|
109
109
|
"typings": "./lib-esm/index.d.ts",
|
|
110
|
-
"version": "0.0.2-preview-testing.
|
|
111
|
-
"gitHead": "
|
|
110
|
+
"version": "0.0.2-preview-testing.034e780.0+034e780",
|
|
111
|
+
"gitHead": "034e780c26d821aba19fa29a397a5f35ed8874de"
|
|
112
112
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import { ResourcesConfig } from 'aws-amplify';
|
|
5
|
+
import { parseAWSExports } from '@aws-amplify/core/internals/utils';
|
|
5
6
|
import { AmplifyServerContextError } from '@aws-amplify/core/internals/adapter-core';
|
|
6
7
|
import getConfig from 'next/config';
|
|
7
8
|
|
|
@@ -28,5 +29,7 @@ export const getAmplifyConfig = (): ResourcesConfig => {
|
|
|
28
29
|
const configObject = JSON.parse(configStr);
|
|
29
30
|
|
|
30
31
|
// TODO(HuiSF): adds ResourcesConfig validation when it has one.
|
|
31
|
-
return configObject
|
|
32
|
+
return Object.keys(configObject).some(key => key.startsWith('aws_'))
|
|
33
|
+
? parseAWSExports(configObject)
|
|
34
|
+
: configObject;
|
|
32
35
|
};
|
package/src/withAmplify.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import { ResourcesConfig
|
|
4
|
+
import { ResourcesConfig } from 'aws-amplify';
|
|
5
|
+
import { LegacyConfig } from 'aws-amplify/internals/adapter-core';
|
|
5
6
|
import { NextConfig } from 'next';
|
|
6
7
|
|
|
7
8
|
// NOTE: this function is exported from the subpath `/with-amplify`.
|
|
@@ -14,22 +15,11 @@ import { NextConfig } from 'next';
|
|
|
14
15
|
* @param nextConfig The next config for a Next.js app.
|
|
15
16
|
* @param amplifyConfig The Amplify configuration.
|
|
16
17
|
*
|
|
17
|
-
* **NOTE**: If you are using Amplify CLI to generate the `aws-exports.js`
|
|
18
|
-
* file, you need to use {@link parseAmplifyConfig} to reformat the configuration.
|
|
19
|
-
* E.g.
|
|
20
|
-
* ```javascript
|
|
21
|
-
* const { parseAmplifyConfig } = require('aws-amplify');
|
|
22
|
-
* const { withAmplify } = require('@aws-amplify/adapter-nextjs/with-amplify');
|
|
23
|
-
* const config = require('./src/aws-exports');
|
|
24
|
-
*
|
|
25
|
-
* const nextConfig = {};
|
|
26
|
-
* module.exports = withAmplify(nextConfig, parseAmplifyConfig(config));
|
|
27
|
-
* ```
|
|
28
18
|
* @returns The updated `nextConfig`.
|
|
29
19
|
*/
|
|
30
20
|
export const withAmplify = (
|
|
31
21
|
nextConfig: NextConfig,
|
|
32
|
-
amplifyConfig: ResourcesConfig
|
|
22
|
+
amplifyConfig: ResourcesConfig | LegacyConfig
|
|
33
23
|
) => {
|
|
34
24
|
const configStr = JSON.stringify(amplifyConfig);
|
|
35
25
|
nextConfig.env = {
|