@aws-amplify/core 6.0.5-unstable.b877493.0 → 6.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/Platform/version.js +1 -1
- package/dist/cjs/Platform/version.js.map +1 -1
- package/dist/cjs/adapterCore/serverContext/serverContext.js +25 -1
- package/dist/cjs/adapterCore/serverContext/serverContext.js.map +1 -1
- package/dist/esm/Platform/version.d.ts +1 -1
- package/dist/esm/Platform/version.mjs +1 -1
- package/dist/esm/Platform/version.mjs.map +1 -1
- package/dist/esm/adapterCore/serverContext/serverContext.mjs +25 -1
- package/dist/esm/adapterCore/serverContext/serverContext.mjs.map +1 -1
- package/package.json +3 -3
- package/src/Platform/version.ts +1 -1
- package/src/adapterCore/serverContext/serverContext.ts +33 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sources":["../../../src/Platform/version.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.version = void 0;\n// generated by genversion\nexports.version = '6.0.5
|
|
1
|
+
{"version":3,"file":"version.js","sources":["../../../src/Platform/version.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.version = void 0;\n// generated by genversion\nexports.version = '6.0.5';\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,OAAO,GAAG,KAAK,CAAC,CAAC;AACzB;AACA,OAAO,CAAC,OAAO,GAAG,OAAO;;"}
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.destroyAmplifyServerContext = exports.getAmplifyServerContext = exports.createAmplifyServerContext = void 0;
|
|
7
7
|
const serverContextRegistry_1 = require("./serverContextRegistry");
|
|
8
8
|
const singleton_1 = require("../../singleton");
|
|
9
|
+
const error_1 = require("../error");
|
|
9
10
|
/**
|
|
10
11
|
* Creates an Amplify server context.
|
|
11
12
|
* @param amplifyConfig The Amplify resource config.
|
|
@@ -26,11 +27,15 @@ exports.createAmplifyServerContext = createAmplifyServerContext;
|
|
|
26
27
|
* @returns The Amplify server context.
|
|
27
28
|
*/
|
|
28
29
|
const getAmplifyServerContext = (contextSpec) => {
|
|
30
|
+
assertContextSpec(contextSpec);
|
|
29
31
|
const context = serverContextRegistry_1.serverContextRegistry.get(contextSpec);
|
|
30
32
|
if (context) {
|
|
31
33
|
return context;
|
|
32
34
|
}
|
|
33
|
-
throw new
|
|
35
|
+
throw new error_1.AmplifyServerContextError({
|
|
36
|
+
message: 'Attempted to get the Amplify Server Context that may have been destroyed.',
|
|
37
|
+
recoverySuggestion: 'Ensure always call Amplify APIs within `runWithAmplifyServerContext` function, and do not attempt to reuse `contextSpec` object.',
|
|
38
|
+
});
|
|
34
39
|
};
|
|
35
40
|
exports.getAmplifyServerContext = getAmplifyServerContext;
|
|
36
41
|
/**
|
|
@@ -41,4 +46,23 @@ const destroyAmplifyServerContext = (contextSpec) => {
|
|
|
41
46
|
serverContextRegistry_1.serverContextRegistry.deregister(contextSpec);
|
|
42
47
|
};
|
|
43
48
|
exports.destroyAmplifyServerContext = destroyAmplifyServerContext;
|
|
49
|
+
const assertContextSpec = (contextSpec) => {
|
|
50
|
+
let invalid = false;
|
|
51
|
+
if (!Object.prototype.hasOwnProperty.call(contextSpec, 'token')) {
|
|
52
|
+
invalid = true;
|
|
53
|
+
}
|
|
54
|
+
else if (!Object.prototype.hasOwnProperty.call(contextSpec.token, 'value')) {
|
|
55
|
+
invalid = true;
|
|
56
|
+
}
|
|
57
|
+
else if (Object.prototype.toString.call(contextSpec.token.value) !==
|
|
58
|
+
'[object Symbol]') {
|
|
59
|
+
invalid = true;
|
|
60
|
+
}
|
|
61
|
+
if (invalid) {
|
|
62
|
+
throw new error_1.AmplifyServerContextError({
|
|
63
|
+
message: 'Invalid `contextSpec`.',
|
|
64
|
+
recoverySuggestion: 'Ensure to use the `contextSpec` object injected by `runWithAmplifyServerContext` function.',
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
};
|
|
44
68
|
//# sourceMappingURL=serverContext.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serverContext.js","sources":["../../../../src/adapterCore/serverContext/serverContext.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.destroyAmplifyServerContext = exports.getAmplifyServerContext = exports.createAmplifyServerContext = void 0;\nconst serverContextRegistry_1 = require(\"./serverContextRegistry\");\nconst singleton_1 = require(\"../../singleton\");\n/**\n * Creates an Amplify server context.\n * @param amplifyConfig The Amplify resource config.\n * @param libraryOptions The Amplify library options.\n * @returns The Amplify server context spec.\n */\nconst createAmplifyServerContext = (amplifyConfig, libraryOptions) => {\n const amplify = new singleton_1.AmplifyClass();\n amplify.configure(amplifyConfig, libraryOptions);\n return serverContextRegistry_1.serverContextRegistry.register({\n amplify,\n });\n};\nexports.createAmplifyServerContext = createAmplifyServerContext;\n/**\n * Returns an Amplify server context.\n * @param contextSpec The context spec used to get the Amplify server context.\n * @returns The Amplify server context.\n */\nconst getAmplifyServerContext = (contextSpec) => {\n const context = serverContextRegistry_1.serverContextRegistry.get(contextSpec);\n if (context) {\n return context;\n }\n throw new
|
|
1
|
+
{"version":3,"file":"serverContext.js","sources":["../../../../src/adapterCore/serverContext/serverContext.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.destroyAmplifyServerContext = exports.getAmplifyServerContext = exports.createAmplifyServerContext = void 0;\nconst serverContextRegistry_1 = require(\"./serverContextRegistry\");\nconst singleton_1 = require(\"../../singleton\");\nconst error_1 = require(\"../error\");\n/**\n * Creates an Amplify server context.\n * @param amplifyConfig The Amplify resource config.\n * @param libraryOptions The Amplify library options.\n * @returns The Amplify server context spec.\n */\nconst createAmplifyServerContext = (amplifyConfig, libraryOptions) => {\n const amplify = new singleton_1.AmplifyClass();\n amplify.configure(amplifyConfig, libraryOptions);\n return serverContextRegistry_1.serverContextRegistry.register({\n amplify,\n });\n};\nexports.createAmplifyServerContext = createAmplifyServerContext;\n/**\n * Returns an Amplify server context.\n * @param contextSpec The context spec used to get the Amplify server context.\n * @returns The Amplify server context.\n */\nconst getAmplifyServerContext = (contextSpec) => {\n assertContextSpec(contextSpec);\n const context = serverContextRegistry_1.serverContextRegistry.get(contextSpec);\n if (context) {\n return context;\n }\n throw new error_1.AmplifyServerContextError({\n message: 'Attempted to get the Amplify Server Context that may have been destroyed.',\n recoverySuggestion: 'Ensure always call Amplify APIs within `runWithAmplifyServerContext` function, and do not attempt to reuse `contextSpec` object.',\n });\n};\nexports.getAmplifyServerContext = getAmplifyServerContext;\n/**\n * Destroys an Amplify server context.\n * @param contextSpec The context spec used to destroy the Amplify server context.\n */\nconst destroyAmplifyServerContext = (contextSpec) => {\n serverContextRegistry_1.serverContextRegistry.deregister(contextSpec);\n};\nexports.destroyAmplifyServerContext = destroyAmplifyServerContext;\nconst assertContextSpec = (contextSpec) => {\n let invalid = false;\n if (!Object.prototype.hasOwnProperty.call(contextSpec, 'token')) {\n invalid = true;\n }\n else if (!Object.prototype.hasOwnProperty.call(contextSpec.token, 'value')) {\n invalid = true;\n }\n else if (Object.prototype.toString.call(contextSpec.token.value) !==\n '[object Symbol]') {\n invalid = true;\n }\n if (invalid) {\n throw new error_1.AmplifyServerContextError({\n message: 'Invalid `contextSpec`.',\n recoverySuggestion: 'Ensure to use the `contextSpec` object injected by `runWithAmplifyServerContext` function.',\n });\n }\n};\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,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AAG,CAAC,WAAW,KAAK;AACrD,IAAI,uBAAuB,CAAC,qBAAqB,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;AAC1E,CAAC,CAAC;AACF,OAAO,CAAC,2BAA2B,GAAG,2BAA2B,CAAC;AAClE,MAAM,iBAAiB,GAAG,CAAC,WAAW,KAAK;AAC3C,IAAI,IAAI,OAAO,GAAG,KAAK,CAAC;AACxB,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,WAAW,EAAE,OAAO,CAAC,EAAE;AACrE,QAAQ,OAAO,GAAG,IAAI,CAAC;AACvB,KAAK;AACL,SAAS,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,OAAO,CAAC,EAAE;AAChF,QAAQ,OAAO,GAAG,IAAI,CAAC;AACvB,KAAK;AACL,SAAS,IAAI,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC;AACpE,QAAQ,iBAAiB,EAAE;AAC3B,QAAQ,OAAO,GAAG,IAAI,CAAC;AACvB,KAAK;AACL,IAAI,IAAI,OAAO,EAAE;AACjB,QAAQ,MAAM,IAAI,OAAO,CAAC,yBAAyB,CAAC;AACpD,YAAY,OAAO,EAAE,wBAAwB;AAC7C,YAAY,kBAAkB,EAAE,4FAA4F;AAC5H,SAAS,CAAC,CAAC;AACX,KAAK;AACL,CAAC;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "6.0.5
|
|
1
|
+
export declare const version = "6.0.5";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.mjs","sources":["../../../src/Platform/version.ts"],"sourcesContent":["// generated by genversion\nexport const version = '6.0.5
|
|
1
|
+
{"version":3,"file":"version.mjs","sources":["../../../src/Platform/version.ts"],"sourcesContent":["// generated by genversion\nexport const version = '6.0.5';\n"],"names":[],"mappings":"AAAA;AACY,MAAC,OAAO,GAAG;;;;"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { serverContextRegistry } from './serverContextRegistry.mjs';
|
|
2
2
|
import { AmplifyClass } from '../../singleton/Amplify.mjs';
|
|
3
|
+
import { AmplifyServerContextError } from '../error/AmplifyServerContextError.mjs';
|
|
3
4
|
|
|
4
5
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
5
6
|
// SPDX-License-Identifier: Apache-2.0
|
|
@@ -22,11 +23,15 @@ const createAmplifyServerContext = (amplifyConfig, libraryOptions) => {
|
|
|
22
23
|
* @returns The Amplify server context.
|
|
23
24
|
*/
|
|
24
25
|
const getAmplifyServerContext = (contextSpec) => {
|
|
26
|
+
assertContextSpec(contextSpec);
|
|
25
27
|
const context = serverContextRegistry.get(contextSpec);
|
|
26
28
|
if (context) {
|
|
27
29
|
return context;
|
|
28
30
|
}
|
|
29
|
-
throw new
|
|
31
|
+
throw new AmplifyServerContextError({
|
|
32
|
+
message: 'Attempted to get the Amplify Server Context that may have been destroyed.',
|
|
33
|
+
recoverySuggestion: 'Ensure always call Amplify APIs within `runWithAmplifyServerContext` function, and do not attempt to reuse `contextSpec` object.',
|
|
34
|
+
});
|
|
30
35
|
};
|
|
31
36
|
/**
|
|
32
37
|
* Destroys an Amplify server context.
|
|
@@ -35,6 +40,25 @@ const getAmplifyServerContext = (contextSpec) => {
|
|
|
35
40
|
const destroyAmplifyServerContext = (contextSpec) => {
|
|
36
41
|
serverContextRegistry.deregister(contextSpec);
|
|
37
42
|
};
|
|
43
|
+
const assertContextSpec = (contextSpec) => {
|
|
44
|
+
let invalid = false;
|
|
45
|
+
if (!Object.prototype.hasOwnProperty.call(contextSpec, 'token')) {
|
|
46
|
+
invalid = true;
|
|
47
|
+
}
|
|
48
|
+
else if (!Object.prototype.hasOwnProperty.call(contextSpec.token, 'value')) {
|
|
49
|
+
invalid = true;
|
|
50
|
+
}
|
|
51
|
+
else if (Object.prototype.toString.call(contextSpec.token.value) !==
|
|
52
|
+
'[object Symbol]') {
|
|
53
|
+
invalid = true;
|
|
54
|
+
}
|
|
55
|
+
if (invalid) {
|
|
56
|
+
throw new AmplifyServerContextError({
|
|
57
|
+
message: 'Invalid `contextSpec`.',
|
|
58
|
+
recoverySuggestion: 'Ensure to use the `contextSpec` object injected by `runWithAmplifyServerContext` function.',
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
};
|
|
38
62
|
|
|
39
63
|
export { createAmplifyServerContext, destroyAmplifyServerContext, getAmplifyServerContext };
|
|
40
64
|
//# sourceMappingURL=serverContext.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serverContext.mjs","sources":["../../../../src/adapterCore/serverContext/serverContext.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { serverContextRegistry } from './serverContextRegistry';\nimport { AmplifyClass } from '../../singleton';\n/**\n * Creates an Amplify server context.\n * @param amplifyConfig The Amplify resource config.\n * @param libraryOptions The Amplify library options.\n * @returns The Amplify server context spec.\n */\nexport const createAmplifyServerContext = (amplifyConfig, libraryOptions) => {\n const amplify = new AmplifyClass();\n amplify.configure(amplifyConfig, libraryOptions);\n return serverContextRegistry.register({\n amplify,\n });\n};\n/**\n * Returns an Amplify server context.\n * @param contextSpec The context spec used to get the Amplify server context.\n * @returns The Amplify server context.\n */\nexport const getAmplifyServerContext = (contextSpec) => {\n const context = serverContextRegistry.get(contextSpec);\n if (context) {\n return context;\n }\n throw new
|
|
1
|
+
{"version":3,"file":"serverContext.mjs","sources":["../../../../src/adapterCore/serverContext/serverContext.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { serverContextRegistry } from './serverContextRegistry';\nimport { AmplifyClass } from '../../singleton';\nimport { AmplifyServerContextError } from '../error';\n/**\n * Creates an Amplify server context.\n * @param amplifyConfig The Amplify resource config.\n * @param libraryOptions The Amplify library options.\n * @returns The Amplify server context spec.\n */\nexport const createAmplifyServerContext = (amplifyConfig, libraryOptions) => {\n const amplify = new AmplifyClass();\n amplify.configure(amplifyConfig, libraryOptions);\n return serverContextRegistry.register({\n amplify,\n });\n};\n/**\n * Returns an Amplify server context.\n * @param contextSpec The context spec used to get the Amplify server context.\n * @returns The Amplify server context.\n */\nexport const getAmplifyServerContext = (contextSpec) => {\n assertContextSpec(contextSpec);\n const context = serverContextRegistry.get(contextSpec);\n if (context) {\n return context;\n }\n throw new AmplifyServerContextError({\n message: 'Attempted to get the Amplify Server Context that may have been destroyed.',\n recoverySuggestion: 'Ensure always call Amplify APIs within `runWithAmplifyServerContext` function, and do not attempt to reuse `contextSpec` object.',\n });\n};\n/**\n * Destroys an Amplify server context.\n * @param contextSpec The context spec used to destroy the Amplify server context.\n */\nexport const destroyAmplifyServerContext = (contextSpec) => {\n serverContextRegistry.deregister(contextSpec);\n};\nconst assertContextSpec = (contextSpec) => {\n let invalid = false;\n if (!Object.prototype.hasOwnProperty.call(contextSpec, 'token')) {\n invalid = true;\n }\n else if (!Object.prototype.hasOwnProperty.call(contextSpec.token, 'value')) {\n invalid = true;\n }\n else if (Object.prototype.toString.call(contextSpec.token.value) !==\n '[object Symbol]') {\n invalid = true;\n }\n if (invalid) {\n throw new AmplifyServerContextError({\n message: 'Invalid `contextSpec`.',\n recoverySuggestion: 'Ensure to use the `contextSpec` object injected by `runWithAmplifyServerContext` function.',\n });\n }\n};\n"],"names":[],"mappings":";;;;AAAA;AACA;AAIA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,0BAA0B,GAAG,CAAC,aAAa,EAAE,cAAc,KAAK;AAC7E,IAAI,MAAM,OAAO,GAAG,IAAI,YAAY,EAAE,CAAC;AACvC,IAAI,OAAO,CAAC,SAAS,CAAC,aAAa,EAAE,cAAc,CAAC,CAAC;AACrD,IAAI,OAAO,qBAAqB,CAAC,QAAQ,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,yBAAyB,CAAC;AAC5C,YAAY,OAAO,EAAE,wBAAwB;AAC7C,YAAY,kBAAkB,EAAE,4FAA4F;AAC5H,SAAS,CAAC,CAAC;AACX,KAAK;AACL,CAAC;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-amplify/core",
|
|
3
|
-
"version": "6.0.5
|
|
3
|
+
"version": "6.0.5",
|
|
4
4
|
"description": "Core category of aws-amplify",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"module": "./dist/esm/index.mjs",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"uuid": "^9.0.0"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
|
-
"@aws-amplify/react-native": "1.0.5
|
|
63
|
+
"@aws-amplify/react-native": "1.0.5",
|
|
64
64
|
"@rollup/plugin-typescript": "11.1.5",
|
|
65
65
|
"@types/js-cookie": "3.0.2",
|
|
66
66
|
"genversion": "^2.2.0",
|
|
@@ -234,5 +234,5 @@
|
|
|
234
234
|
"dist"
|
|
235
235
|
]
|
|
236
236
|
},
|
|
237
|
-
"gitHead": "
|
|
237
|
+
"gitHead": "1c545f4a0c111245a66d489aeb01a0c0f78cf7cb"
|
|
238
238
|
}
|
package/src/Platform/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// generated by genversion
|
|
2
|
-
export const version = '6.0.5
|
|
2
|
+
export const version = '6.0.5';
|
|
@@ -5,6 +5,7 @@ import { AmplifyServer } from './types';
|
|
|
5
5
|
import { serverContextRegistry } from './serverContextRegistry';
|
|
6
6
|
import { AmplifyClass } from '../../singleton';
|
|
7
7
|
import { LibraryOptions, ResourcesConfig } from '../../singleton/types';
|
|
8
|
+
import { AmplifyServerContextError } from '../error';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Creates an Amplify server context.
|
|
@@ -32,15 +33,19 @@ export const createAmplifyServerContext = (
|
|
|
32
33
|
export const getAmplifyServerContext = (
|
|
33
34
|
contextSpec: AmplifyServer.ContextSpec
|
|
34
35
|
): AmplifyServer.Context => {
|
|
36
|
+
assertContextSpec(contextSpec);
|
|
35
37
|
const context = serverContextRegistry.get(contextSpec);
|
|
36
38
|
|
|
37
39
|
if (context) {
|
|
38
40
|
return context;
|
|
39
41
|
}
|
|
40
42
|
|
|
41
|
-
throw new
|
|
42
|
-
|
|
43
|
-
|
|
43
|
+
throw new AmplifyServerContextError({
|
|
44
|
+
message:
|
|
45
|
+
'Attempted to get the Amplify Server Context that may have been destroyed.',
|
|
46
|
+
recoverySuggestion:
|
|
47
|
+
'Ensure always call Amplify APIs within `runWithAmplifyServerContext` function, and do not attempt to reuse `contextSpec` object.',
|
|
48
|
+
});
|
|
44
49
|
};
|
|
45
50
|
|
|
46
51
|
/**
|
|
@@ -52,3 +57,28 @@ export const destroyAmplifyServerContext = (
|
|
|
52
57
|
): void => {
|
|
53
58
|
serverContextRegistry.deregister(contextSpec);
|
|
54
59
|
};
|
|
60
|
+
|
|
61
|
+
const assertContextSpec = (contextSpec: AmplifyServer.ContextSpec) => {
|
|
62
|
+
let invalid = false;
|
|
63
|
+
|
|
64
|
+
if (!Object.prototype.hasOwnProperty.call(contextSpec, 'token')) {
|
|
65
|
+
invalid = true;
|
|
66
|
+
} else if (
|
|
67
|
+
!Object.prototype.hasOwnProperty.call(contextSpec.token, 'value')
|
|
68
|
+
) {
|
|
69
|
+
invalid = true;
|
|
70
|
+
} else if (
|
|
71
|
+
Object.prototype.toString.call(contextSpec.token.value) !==
|
|
72
|
+
'[object Symbol]'
|
|
73
|
+
) {
|
|
74
|
+
invalid = true;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (invalid) {
|
|
78
|
+
throw new AmplifyServerContextError({
|
|
79
|
+
message: 'Invalid `contextSpec`.',
|
|
80
|
+
recoverySuggestion:
|
|
81
|
+
'Ensure to use the `contextSpec` object injected by `runWithAmplifyServerContext` function.',
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
};
|