@aws-amplify/api-rest 0.0.0-unstable-1ca644b-20260128091132
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/README.md +3 -0
- package/dist/cjs/apis/common/baseHandlers/authenticatedHandler.js +17 -0
- package/dist/cjs/apis/common/baseHandlers/authenticatedHandler.js.map +1 -0
- package/dist/cjs/apis/common/baseHandlers/unauthenticatedHandler.js +13 -0
- package/dist/cjs/apis/common/baseHandlers/unauthenticatedHandler.js.map +1 -0
- package/dist/cjs/apis/common/internalPost.js +98 -0
- package/dist/cjs/apis/common/internalPost.js.map +1 -0
- package/dist/cjs/apis/common/publicApis.js +57 -0
- package/dist/cjs/apis/common/publicApis.js.map +1 -0
- package/dist/cjs/apis/common/transferHandler.js +92 -0
- package/dist/cjs/apis/common/transferHandler.js.map +1 -0
- package/dist/cjs/apis/index.js +217 -0
- package/dist/cjs/apis/index.js.map +1 -0
- package/dist/cjs/apis/server.js +163 -0
- package/dist/cjs/apis/server.js.map +1 -0
- package/dist/cjs/errors/CanceledError.js +37 -0
- package/dist/cjs/errors/CanceledError.js.map +1 -0
- package/dist/cjs/errors/RestApiError.js +17 -0
- package/dist/cjs/errors/RestApiError.js.map +1 -0
- package/dist/cjs/errors/assertValidatonError.js +18 -0
- package/dist/cjs/errors/assertValidatonError.js.map +1 -0
- package/dist/cjs/errors/index.js +17 -0
- package/dist/cjs/errors/index.js.map +1 -0
- package/dist/cjs/errors/validation.js +17 -0
- package/dist/cjs/errors/validation.js.map +1 -0
- package/dist/cjs/index.js +16 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/internals/index.js +12 -0
- package/dist/cjs/internals/index.js.map +1 -0
- package/dist/cjs/internals/server.js +32 -0
- package/dist/cjs/internals/server.js.map +1 -0
- package/dist/cjs/server.js +16 -0
- package/dist/cjs/server.js.map +1 -0
- package/dist/cjs/types/index.js +4 -0
- package/dist/cjs/types/index.js.map +1 -0
- package/dist/cjs/utils/constants.js +15 -0
- package/dist/cjs/utils/constants.js.map +1 -0
- package/dist/cjs/utils/createCancellableOperation.js +76 -0
- package/dist/cjs/utils/createCancellableOperation.js.map +1 -0
- package/dist/cjs/utils/index.js +19 -0
- package/dist/cjs/utils/index.js.map +1 -0
- package/dist/cjs/utils/isIamAuthApplicable.js +39 -0
- package/dist/cjs/utils/isIamAuthApplicable.js.map +1 -0
- package/dist/cjs/utils/logger.js +9 -0
- package/dist/cjs/utils/logger.js.map +1 -0
- package/dist/cjs/utils/parseSigningInfo.js +43 -0
- package/dist/cjs/utils/parseSigningInfo.js.map +1 -0
- package/dist/cjs/utils/resolveApiUrl.js +48 -0
- package/dist/cjs/utils/resolveApiUrl.js.map +1 -0
- package/dist/cjs/utils/resolveHeaders.js +34 -0
- package/dist/cjs/utils/resolveHeaders.js.map +1 -0
- package/dist/cjs/utils/resolveLibraryOptions.js +16 -0
- package/dist/cjs/utils/resolveLibraryOptions.js.map +1 -0
- package/dist/cjs/utils/serviceError.js +98 -0
- package/dist/cjs/utils/serviceError.js.map +1 -0
- package/dist/esm/apis/common/baseHandlers/authenticatedHandler.d.ts +5 -0
- package/dist/esm/apis/common/baseHandlers/authenticatedHandler.mjs +16 -0
- package/dist/esm/apis/common/baseHandlers/authenticatedHandler.mjs.map +1 -0
- package/dist/esm/apis/common/baseHandlers/unauthenticatedHandler.d.ts +5 -0
- package/dist/esm/apis/common/baseHandlers/unauthenticatedHandler.mjs +12 -0
- package/dist/esm/apis/common/baseHandlers/unauthenticatedHandler.mjs.map +1 -0
- package/dist/esm/apis/common/internalPost.d.ts +43 -0
- package/dist/esm/apis/common/internalPost.mjs +98 -0
- package/dist/esm/apis/common/internalPost.mjs.map +1 -0
- package/dist/esm/apis/common/publicApis.d.ts +8 -0
- package/dist/esm/apis/common/publicApis.mjs +56 -0
- package/dist/esm/apis/common/publicApis.mjs.map +1 -0
- package/dist/esm/apis/common/transferHandler.d.ts +26 -0
- package/dist/esm/apis/common/transferHandler.mjs +95 -0
- package/dist/esm/apis/common/transferHandler.mjs.map +1 -0
- package/dist/esm/apis/index.d.ts +203 -0
- package/dist/esm/apis/index.mjs +210 -0
- package/dist/esm/apis/index.mjs.map +1 -0
- package/dist/esm/apis/server.d.ts +150 -0
- package/dist/esm/apis/server.mjs +156 -0
- package/dist/esm/apis/server.mjs.map +1 -0
- package/dist/esm/errors/CanceledError.d.ts +20 -0
- package/dist/esm/errors/CanceledError.mjs +34 -0
- package/dist/esm/errors/CanceledError.mjs.map +1 -0
- package/dist/esm/errors/RestApiError.d.ts +4 -0
- package/dist/esm/errors/RestApiError.mjs +15 -0
- package/dist/esm/errors/RestApiError.mjs.map +1 -0
- package/dist/esm/errors/assertValidatonError.d.ts +5 -0
- package/dist/esm/errors/assertValidatonError.mjs +17 -0
- package/dist/esm/errors/assertValidatonError.mjs.map +1 -0
- package/dist/esm/errors/index.d.ts +4 -0
- package/dist/esm/errors/index.mjs +5 -0
- package/dist/esm/errors/index.mjs.map +1 -0
- package/dist/esm/errors/validation.d.ts +5 -0
- package/dist/esm/errors/validation.mjs +15 -0
- package/dist/esm/errors/validation.mjs.map +1 -0
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.mjs +3 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/esm/internals/index.d.ts +2 -0
- package/dist/esm/internals/index.mjs +2 -0
- package/dist/esm/internals/index.mjs.map +1 -0
- package/dist/esm/internals/server.d.ts +20 -0
- package/dist/esm/internals/server.mjs +28 -0
- package/dist/esm/internals/server.mjs.map +1 -0
- package/dist/esm/server.d.ts +2 -0
- package/dist/esm/server.mjs +3 -0
- package/dist/esm/server.mjs.map +1 -0
- package/dist/esm/types/index.d.ts +122 -0
- package/dist/esm/types/index.mjs +2 -0
- package/dist/esm/types/index.mjs.map +1 -0
- package/dist/esm/utils/constants.d.ts +8 -0
- package/dist/esm/utils/constants.mjs +13 -0
- package/dist/esm/utils/constants.mjs.map +1 -0
- package/dist/esm/utils/createCancellableOperation.d.ts +12 -0
- package/dist/esm/utils/createCancellableOperation.mjs +77 -0
- package/dist/esm/utils/createCancellableOperation.mjs.map +1 -0
- package/dist/esm/utils/index.d.ts +6 -0
- package/dist/esm/utils/index.mjs +7 -0
- package/dist/esm/utils/index.mjs.map +1 -0
- package/dist/esm/utils/isIamAuthApplicable.d.ts +32 -0
- package/dist/esm/utils/isIamAuthApplicable.mjs +35 -0
- package/dist/esm/utils/isIamAuthApplicable.mjs.map +1 -0
- package/dist/esm/utils/logger.d.ts +2 -0
- package/dist/esm/utils/logger.mjs +8 -0
- package/dist/esm/utils/logger.mjs.map +1 -0
- package/dist/esm/utils/parseSigningInfo.d.ts +14 -0
- package/dist/esm/utils/parseSigningInfo.mjs +41 -0
- package/dist/esm/utils/parseSigningInfo.mjs.map +1 -0
- package/dist/esm/utils/resolveApiUrl.d.ts +12 -0
- package/dist/esm/utils/resolveApiUrl.mjs +48 -0
- package/dist/esm/utils/resolveApiUrl.mjs.map +1 -0
- package/dist/esm/utils/resolveHeaders.d.ts +1 -0
- package/dist/esm/utils/resolveHeaders.mjs +31 -0
- package/dist/esm/utils/resolveHeaders.mjs.map +1 -0
- package/dist/esm/utils/resolveLibraryOptions.d.ts +8 -0
- package/dist/esm/utils/resolveLibraryOptions.mjs +13 -0
- package/dist/esm/utils/resolveLibraryOptions.mjs.map +1 -0
- package/dist/esm/utils/serviceError.d.ts +13 -0
- package/dist/esm/utils/serviceError.mjs +97 -0
- package/dist/esm/utils/serviceError.mjs.map +1 -0
- package/internals/package.json +8 -0
- package/internals/server/package.json +7 -0
- package/package.json +94 -0
- package/server/package.json +7 -0
- package/src/apis/common/baseHandlers/authenticatedHandler.ts +28 -0
- package/src/apis/common/baseHandlers/unauthenticatedHandler.ts +22 -0
- package/src/apis/common/internalPost.ts +123 -0
- package/src/apis/common/publicApis.ts +118 -0
- package/src/apis/common/transferHandler.ts +154 -0
- package/src/apis/index.ts +241 -0
- package/src/apis/server.ts +210 -0
- package/src/errors/CanceledError.ts +37 -0
- package/src/errors/RestApiError.ts +14 -0
- package/src/errors/assertValidatonError.ts +19 -0
- package/src/errors/index.ts +7 -0
- package/src/errors/validation.ts +16 -0
- package/src/index.ts +5 -0
- package/src/internals/index.ts +8 -0
- package/src/internals/server.ts +37 -0
- package/src/server.ts +5 -0
- package/src/types/index.ts +138 -0
- package/src/utils/constants.ts +15 -0
- package/src/utils/createCancellableOperation.ts +108 -0
- package/src/utils/index.ts +9 -0
- package/src/utils/isIamAuthApplicable.ts +44 -0
- package/src/utils/logger.ts +6 -0
- package/src/utils/parseSigningInfo.ts +53 -0
- package/src/utils/resolveApiUrl.ts +59 -0
- package/src/utils/resolveHeaders.ts +36 -0
- package/src/utils/resolveLibraryOptions.ts +14 -0
- package/src/utils/serviceError.ts +109 -0
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { AmplifyServer } from '@aws-amplify/core/internals/adapter-core';
|
|
2
|
+
import { DeleteInput, DeleteOperation, GetInput, GetOperation, HeadInput, HeadOperation, PatchInput, PatchOperation, PostInput, PostOperation, PutInput, PutOperation } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* GET HTTP request (server-side)
|
|
5
|
+
* @param {AmplifyServer.ContextSpec} contextSpec - The context spec used to get the Amplify server context.
|
|
6
|
+
* @param {GetInput} input - Input for GET operation.
|
|
7
|
+
* @throws - {@link RestApiError}
|
|
8
|
+
* @example
|
|
9
|
+
* Send a GET request
|
|
10
|
+
* ```js
|
|
11
|
+
* import { get } from 'aws-amplify/api/server';
|
|
12
|
+
* //...
|
|
13
|
+
* const restApiResponse = await runWithAmplifyServerContext({
|
|
14
|
+
* nextServerContext: { request, response },
|
|
15
|
+
* operation: async (contextSpec) => {
|
|
16
|
+
* try {
|
|
17
|
+
* const { body } = await get(contextSpec, input).response;
|
|
18
|
+
* return await body.json();
|
|
19
|
+
* } catch (error) {
|
|
20
|
+
* console.log(error);
|
|
21
|
+
* return false;
|
|
22
|
+
* }
|
|
23
|
+
* },
|
|
24
|
+
* });
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare const get: (contextSpec: AmplifyServer.ContextSpec, input: GetInput) => GetOperation;
|
|
28
|
+
/**
|
|
29
|
+
* POST HTTP request (server-side)
|
|
30
|
+
* @param {AmplifyServer.ContextSpec} contextSpec - The context spec used to get the Amplify server context.
|
|
31
|
+
* @param {PostInput} input - Input for POST operation.
|
|
32
|
+
* @throws - {@link RestApiError}
|
|
33
|
+
* @example
|
|
34
|
+
* Send a POST request
|
|
35
|
+
* ```js
|
|
36
|
+
* import { post } from 'aws-amplify/api/server';
|
|
37
|
+
* //...
|
|
38
|
+
* const restApiResponse = await runWithAmplifyServerContext({
|
|
39
|
+
* nextServerContext: { request, response },
|
|
40
|
+
* operation: async (contextSpec) => {
|
|
41
|
+
* try {
|
|
42
|
+
* const { body } = await post(contextSpec, input).response;
|
|
43
|
+
* return await body.json();
|
|
44
|
+
* } catch (error) {
|
|
45
|
+
* console.log(error);
|
|
46
|
+
* return false;
|
|
47
|
+
* }
|
|
48
|
+
* },
|
|
49
|
+
* });
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export declare const post: (contextSpec: AmplifyServer.ContextSpec, input: PostInput) => PostOperation;
|
|
53
|
+
/**
|
|
54
|
+
* PUT HTTP request (server-side)
|
|
55
|
+
* @param {AmplifyServer.ContextSpec} contextSpec - The context spec used to get the Amplify server context.
|
|
56
|
+
* @param {PutInput} input - Input for PUT operation.
|
|
57
|
+
* @throws - {@link RestApiError}
|
|
58
|
+
* @example
|
|
59
|
+
* Send a PUT request
|
|
60
|
+
* ```js
|
|
61
|
+
* import { put } from 'aws-amplify/api/server';
|
|
62
|
+
* //...
|
|
63
|
+
* const restApiResponse = await runWithAmplifyServerContext({
|
|
64
|
+
* nextServerContext: { request, response },
|
|
65
|
+
* operation: async (contextSpec) => {
|
|
66
|
+
* try {
|
|
67
|
+
* const { body } = await put(contextSpec, input).response;
|
|
68
|
+
* return await body.json();
|
|
69
|
+
* } catch (error) {
|
|
70
|
+
* console.log(error);
|
|
71
|
+
* return false;
|
|
72
|
+
* }
|
|
73
|
+
* },
|
|
74
|
+
* });
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
export declare const put: (contextSpec: AmplifyServer.ContextSpec, input: PutInput) => PutOperation;
|
|
78
|
+
/**
|
|
79
|
+
* DELETE HTTP request (server-side)
|
|
80
|
+
* @param {AmplifyServer.ContextSpec} contextSpec - The context spec used to get the Amplify server context.
|
|
81
|
+
* @param {DeleteInput} input - Input for DELETE operation.
|
|
82
|
+
* @throws - {@link RestApiError}
|
|
83
|
+
* @example
|
|
84
|
+
* Send a DELETE request
|
|
85
|
+
* ```js
|
|
86
|
+
* import { del } from 'aws-amplify/api/server';
|
|
87
|
+
* //...
|
|
88
|
+
* const restApiResponse = await runWithAmplifyServerContext({
|
|
89
|
+
* nextServerContext: { request, response },
|
|
90
|
+
* operation: async (contextSpec) => {
|
|
91
|
+
* try {
|
|
92
|
+
* const { headers } = await del(contextSpec, input).response;
|
|
93
|
+
* } catch (error) {
|
|
94
|
+
* console.log(error);
|
|
95
|
+
* return false;
|
|
96
|
+
* }
|
|
97
|
+
* },
|
|
98
|
+
* });
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
export declare const del: (contextSpec: AmplifyServer.ContextSpec, input: DeleteInput) => DeleteOperation;
|
|
102
|
+
/**
|
|
103
|
+
* HEAD HTTP request (server-side)
|
|
104
|
+
* @param {AmplifyServer.ContextSpec} contextSpec - The context spec used to get the Amplify server context.
|
|
105
|
+
* @param {HeadInput} input - Input for HEAD operation.
|
|
106
|
+
* @throws - {@link RestApiError}
|
|
107
|
+
* @example
|
|
108
|
+
* Send a HEAD request
|
|
109
|
+
* ```js
|
|
110
|
+
* import { head } from 'aws-amplify/api/server';
|
|
111
|
+
* //...
|
|
112
|
+
* const restApiResponse = await runWithAmplifyServerContext({
|
|
113
|
+
* nextServerContext: { request, response },
|
|
114
|
+
* operation: async (contextSpec) => {
|
|
115
|
+
* try {
|
|
116
|
+
* const { headers } = await head(contextSpec, input).response;
|
|
117
|
+
* } catch (error) {
|
|
118
|
+
* console.log(error);
|
|
119
|
+
* return false;
|
|
120
|
+
* }
|
|
121
|
+
* },
|
|
122
|
+
* });
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
125
|
+
export declare const head: (contextSpec: AmplifyServer.ContextSpec, input: HeadInput) => HeadOperation;
|
|
126
|
+
/**
|
|
127
|
+
* PATCH HTTP request (server-side)
|
|
128
|
+
* @param {AmplifyServer.ContextSpec} contextSpec - The context spec used to get the Amplify server context.
|
|
129
|
+
* @param {PatchInput} input - Input for PATCH operation.
|
|
130
|
+
* @throws - {@link RestApiError}
|
|
131
|
+
* @example
|
|
132
|
+
* Send a PATCH request
|
|
133
|
+
* ```js
|
|
134
|
+
* import { patch } from 'aws-amplify/api/server';
|
|
135
|
+
* //...
|
|
136
|
+
* const restApiResponse = await runWithAmplifyServerContext({
|
|
137
|
+
* nextServerContext: { request, response },
|
|
138
|
+
* operation: async (contextSpec) => {
|
|
139
|
+
* try {
|
|
140
|
+
* const { body } = await patch(contextSpec, input).response;
|
|
141
|
+
* return await body.json();
|
|
142
|
+
* } catch (error) {
|
|
143
|
+
* console.log(error);
|
|
144
|
+
* return false;
|
|
145
|
+
* }
|
|
146
|
+
* },
|
|
147
|
+
* });
|
|
148
|
+
* ```
|
|
149
|
+
*/
|
|
150
|
+
export declare const patch: (contextSpec: AmplifyServer.ContextSpec, input: PatchInput) => PatchOperation;
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { getAmplifyServerContext } from '@aws-amplify/core/internals/adapter-core';
|
|
2
|
+
import { get as get$1, post as post$1, put as put$1, del as del$1, head as head$1, patch as patch$1 } from './common/publicApis.mjs';
|
|
3
|
+
|
|
4
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
5
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
6
|
+
/**
|
|
7
|
+
* GET HTTP request (server-side)
|
|
8
|
+
* @param {AmplifyServer.ContextSpec} contextSpec - The context spec used to get the Amplify server context.
|
|
9
|
+
* @param {GetInput} input - Input for GET operation.
|
|
10
|
+
* @throws - {@link RestApiError}
|
|
11
|
+
* @example
|
|
12
|
+
* Send a GET request
|
|
13
|
+
* ```js
|
|
14
|
+
* import { get } from 'aws-amplify/api/server';
|
|
15
|
+
* //...
|
|
16
|
+
* const restApiResponse = await runWithAmplifyServerContext({
|
|
17
|
+
* nextServerContext: { request, response },
|
|
18
|
+
* operation: async (contextSpec) => {
|
|
19
|
+
* try {
|
|
20
|
+
* const { body } = await get(contextSpec, input).response;
|
|
21
|
+
* return await body.json();
|
|
22
|
+
* } catch (error) {
|
|
23
|
+
* console.log(error);
|
|
24
|
+
* return false;
|
|
25
|
+
* }
|
|
26
|
+
* },
|
|
27
|
+
* });
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
const get = (contextSpec, input) => get$1(getAmplifyServerContext(contextSpec).amplify, input);
|
|
31
|
+
/**
|
|
32
|
+
* POST HTTP request (server-side)
|
|
33
|
+
* @param {AmplifyServer.ContextSpec} contextSpec - The context spec used to get the Amplify server context.
|
|
34
|
+
* @param {PostInput} input - Input for POST operation.
|
|
35
|
+
* @throws - {@link RestApiError}
|
|
36
|
+
* @example
|
|
37
|
+
* Send a POST request
|
|
38
|
+
* ```js
|
|
39
|
+
* import { post } from 'aws-amplify/api/server';
|
|
40
|
+
* //...
|
|
41
|
+
* const restApiResponse = await runWithAmplifyServerContext({
|
|
42
|
+
* nextServerContext: { request, response },
|
|
43
|
+
* operation: async (contextSpec) => {
|
|
44
|
+
* try {
|
|
45
|
+
* const { body } = await post(contextSpec, input).response;
|
|
46
|
+
* return await body.json();
|
|
47
|
+
* } catch (error) {
|
|
48
|
+
* console.log(error);
|
|
49
|
+
* return false;
|
|
50
|
+
* }
|
|
51
|
+
* },
|
|
52
|
+
* });
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
const post = (contextSpec, input) => post$1(getAmplifyServerContext(contextSpec).amplify, input);
|
|
56
|
+
/**
|
|
57
|
+
* PUT HTTP request (server-side)
|
|
58
|
+
* @param {AmplifyServer.ContextSpec} contextSpec - The context spec used to get the Amplify server context.
|
|
59
|
+
* @param {PutInput} input - Input for PUT operation.
|
|
60
|
+
* @throws - {@link RestApiError}
|
|
61
|
+
* @example
|
|
62
|
+
* Send a PUT request
|
|
63
|
+
* ```js
|
|
64
|
+
* import { put } from 'aws-amplify/api/server';
|
|
65
|
+
* //...
|
|
66
|
+
* const restApiResponse = await runWithAmplifyServerContext({
|
|
67
|
+
* nextServerContext: { request, response },
|
|
68
|
+
* operation: async (contextSpec) => {
|
|
69
|
+
* try {
|
|
70
|
+
* const { body } = await put(contextSpec, input).response;
|
|
71
|
+
* return await body.json();
|
|
72
|
+
* } catch (error) {
|
|
73
|
+
* console.log(error);
|
|
74
|
+
* return false;
|
|
75
|
+
* }
|
|
76
|
+
* },
|
|
77
|
+
* });
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
const put = (contextSpec, input) => put$1(getAmplifyServerContext(contextSpec).amplify, input);
|
|
81
|
+
/**
|
|
82
|
+
* DELETE HTTP request (server-side)
|
|
83
|
+
* @param {AmplifyServer.ContextSpec} contextSpec - The context spec used to get the Amplify server context.
|
|
84
|
+
* @param {DeleteInput} input - Input for DELETE operation.
|
|
85
|
+
* @throws - {@link RestApiError}
|
|
86
|
+
* @example
|
|
87
|
+
* Send a DELETE request
|
|
88
|
+
* ```js
|
|
89
|
+
* import { del } from 'aws-amplify/api/server';
|
|
90
|
+
* //...
|
|
91
|
+
* const restApiResponse = await runWithAmplifyServerContext({
|
|
92
|
+
* nextServerContext: { request, response },
|
|
93
|
+
* operation: async (contextSpec) => {
|
|
94
|
+
* try {
|
|
95
|
+
* const { headers } = await del(contextSpec, input).response;
|
|
96
|
+
* } catch (error) {
|
|
97
|
+
* console.log(error);
|
|
98
|
+
* return false;
|
|
99
|
+
* }
|
|
100
|
+
* },
|
|
101
|
+
* });
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
const del = (contextSpec, input) => del$1(getAmplifyServerContext(contextSpec).amplify, input);
|
|
105
|
+
/**
|
|
106
|
+
* HEAD HTTP request (server-side)
|
|
107
|
+
* @param {AmplifyServer.ContextSpec} contextSpec - The context spec used to get the Amplify server context.
|
|
108
|
+
* @param {HeadInput} input - Input for HEAD operation.
|
|
109
|
+
* @throws - {@link RestApiError}
|
|
110
|
+
* @example
|
|
111
|
+
* Send a HEAD request
|
|
112
|
+
* ```js
|
|
113
|
+
* import { head } from 'aws-amplify/api/server';
|
|
114
|
+
* //...
|
|
115
|
+
* const restApiResponse = await runWithAmplifyServerContext({
|
|
116
|
+
* nextServerContext: { request, response },
|
|
117
|
+
* operation: async (contextSpec) => {
|
|
118
|
+
* try {
|
|
119
|
+
* const { headers } = await head(contextSpec, input).response;
|
|
120
|
+
* } catch (error) {
|
|
121
|
+
* console.log(error);
|
|
122
|
+
* return false;
|
|
123
|
+
* }
|
|
124
|
+
* },
|
|
125
|
+
* });
|
|
126
|
+
* ```
|
|
127
|
+
*/
|
|
128
|
+
const head = (contextSpec, input) => head$1(getAmplifyServerContext(contextSpec).amplify, input);
|
|
129
|
+
/**
|
|
130
|
+
* PATCH HTTP request (server-side)
|
|
131
|
+
* @param {AmplifyServer.ContextSpec} contextSpec - The context spec used to get the Amplify server context.
|
|
132
|
+
* @param {PatchInput} input - Input for PATCH operation.
|
|
133
|
+
* @throws - {@link RestApiError}
|
|
134
|
+
* @example
|
|
135
|
+
* Send a PATCH request
|
|
136
|
+
* ```js
|
|
137
|
+
* import { patch } from 'aws-amplify/api/server';
|
|
138
|
+
* //...
|
|
139
|
+
* const restApiResponse = await runWithAmplifyServerContext({
|
|
140
|
+
* nextServerContext: { request, response },
|
|
141
|
+
* operation: async (contextSpec) => {
|
|
142
|
+
* try {
|
|
143
|
+
* const { body } = await patch(contextSpec, input).response;
|
|
144
|
+
* return await body.json();
|
|
145
|
+
* } catch (error) {
|
|
146
|
+
* console.log(error);
|
|
147
|
+
* return false;
|
|
148
|
+
* }
|
|
149
|
+
* },
|
|
150
|
+
* });
|
|
151
|
+
* ```
|
|
152
|
+
*/
|
|
153
|
+
const patch = (contextSpec, input) => patch$1(getAmplifyServerContext(contextSpec).amplify, input);
|
|
154
|
+
|
|
155
|
+
export { del, get, head, patch, post, put };
|
|
156
|
+
//# sourceMappingURL=server.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.mjs","sources":["../../../src/apis/server.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { getAmplifyServerContext, } from '@aws-amplify/core/internals/adapter-core';\nimport { del as commonDel, get as commonGet, head as commonHead, patch as commonPatch, post as commonPost, put as commonPut, } from './common/publicApis';\n/**\n * GET HTTP request (server-side)\n * @param {AmplifyServer.ContextSpec} contextSpec - The context spec used to get the Amplify server context.\n * @param {GetInput} input - Input for GET operation.\n * @throws - {@link RestApiError}\n * @example\n * Send a GET request\n * ```js\n * import { get } from 'aws-amplify/api/server';\n * //...\n * const restApiResponse = await runWithAmplifyServerContext({\n * nextServerContext: { request, response },\n * operation: async (contextSpec) => {\n * try {\n * const { body } = await get(contextSpec, input).response;\n * return await body.json();\n * } catch (error) {\n * console.log(error);\n * return false;\n * }\n * },\n * });\n * ```\n */\nexport const get = (contextSpec, input) => commonGet(getAmplifyServerContext(contextSpec).amplify, input);\n/**\n * POST HTTP request (server-side)\n * @param {AmplifyServer.ContextSpec} contextSpec - The context spec used to get the Amplify server context.\n * @param {PostInput} input - Input for POST operation.\n * @throws - {@link RestApiError}\n * @example\n * Send a POST request\n * ```js\n * import { post } from 'aws-amplify/api/server';\n * //...\n * const restApiResponse = await runWithAmplifyServerContext({\n * nextServerContext: { request, response },\n * operation: async (contextSpec) => {\n * try {\n * const { body } = await post(contextSpec, input).response;\n * return await body.json();\n * } catch (error) {\n * console.log(error);\n * return false;\n * }\n * },\n * });\n * ```\n */\nexport const post = (contextSpec, input) => commonPost(getAmplifyServerContext(contextSpec).amplify, input);\n/**\n * PUT HTTP request (server-side)\n * @param {AmplifyServer.ContextSpec} contextSpec - The context spec used to get the Amplify server context.\n * @param {PutInput} input - Input for PUT operation.\n * @throws - {@link RestApiError}\n * @example\n * Send a PUT request\n * ```js\n * import { put } from 'aws-amplify/api/server';\n * //...\n * const restApiResponse = await runWithAmplifyServerContext({\n * nextServerContext: { request, response },\n * operation: async (contextSpec) => {\n * try {\n * const { body } = await put(contextSpec, input).response;\n * return await body.json();\n * } catch (error) {\n * console.log(error);\n * return false;\n * }\n * },\n * });\n * ```\n */\nexport const put = (contextSpec, input) => commonPut(getAmplifyServerContext(contextSpec).amplify, input);\n/**\n * DELETE HTTP request (server-side)\n * @param {AmplifyServer.ContextSpec} contextSpec - The context spec used to get the Amplify server context.\n * @param {DeleteInput} input - Input for DELETE operation.\n * @throws - {@link RestApiError}\n * @example\n * Send a DELETE request\n * ```js\n * import { del } from 'aws-amplify/api/server';\n * //...\n * const restApiResponse = await runWithAmplifyServerContext({\n * nextServerContext: { request, response },\n * operation: async (contextSpec) => {\n * try {\n * const { headers } = await del(contextSpec, input).response;\n * } catch (error) {\n * console.log(error);\n * return false;\n * }\n * },\n * });\n * ```\n */\nexport const del = (contextSpec, input) => commonDel(getAmplifyServerContext(contextSpec).amplify, input);\n/**\n * HEAD HTTP request (server-side)\n * @param {AmplifyServer.ContextSpec} contextSpec - The context spec used to get the Amplify server context.\n * @param {HeadInput} input - Input for HEAD operation.\n * @throws - {@link RestApiError}\n * @example\n * Send a HEAD request\n * ```js\n * import { head } from 'aws-amplify/api/server';\n * //...\n * const restApiResponse = await runWithAmplifyServerContext({\n * nextServerContext: { request, response },\n * operation: async (contextSpec) => {\n * try {\n * const { headers } = await head(contextSpec, input).response;\n * } catch (error) {\n * console.log(error);\n * return false;\n * }\n * },\n * });\n * ```\n */\nexport const head = (contextSpec, input) => commonHead(getAmplifyServerContext(contextSpec).amplify, input);\n/**\n * PATCH HTTP request (server-side)\n * @param {AmplifyServer.ContextSpec} contextSpec - The context spec used to get the Amplify server context.\n * @param {PatchInput} input - Input for PATCH operation.\n * @throws - {@link RestApiError}\n * @example\n * Send a PATCH request\n * ```js\n * import { patch } from 'aws-amplify/api/server';\n * //...\n * const restApiResponse = await runWithAmplifyServerContext({\n * nextServerContext: { request, response },\n * operation: async (contextSpec) => {\n * try {\n * const { body } = await patch(contextSpec, input).response;\n * return await body.json();\n * } catch (error) {\n * console.log(error);\n * return false;\n * }\n * },\n * });\n * ```\n */\nexport const patch = (contextSpec, input) => commonPatch(getAmplifyServerContext(contextSpec).amplify, input);\n"],"names":["commonGet","commonPost","commonPut","commonDel","commonHead","commonPatch"],"mappings":";;;AAAA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,GAAG,GAAG,CAAC,WAAW,EAAE,KAAK,KAAKA,KAAS,CAAC,uBAAuB,CAAC,WAAW,CAAC,CAAC,OAAO,EAAE,KAAK;AACxG;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,IAAI,GAAG,CAAC,WAAW,EAAE,KAAK,KAAKC,MAAU,CAAC,uBAAuB,CAAC,WAAW,CAAC,CAAC,OAAO,EAAE,KAAK;AAC1G;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,GAAG,GAAG,CAAC,WAAW,EAAE,KAAK,KAAKC,KAAS,CAAC,uBAAuB,CAAC,WAAW,CAAC,CAAC,OAAO,EAAE,KAAK;AACxG;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,GAAG,GAAG,CAAC,WAAW,EAAE,KAAK,KAAKC,KAAS,CAAC,uBAAuB,CAAC,WAAW,CAAC,CAAC,OAAO,EAAE,KAAK;AACxG;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,IAAI,GAAG,CAAC,WAAW,EAAE,KAAK,KAAKC,MAAU,CAAC,uBAAuB,CAAC,WAAW,CAAC,CAAC,OAAO,EAAE,KAAK;AAC1G;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,KAAK,GAAG,CAAC,WAAW,EAAE,KAAK,KAAKC,OAAW,CAAC,uBAAuB,CAAC,WAAW,CAAC,CAAC,OAAO,EAAE,KAAK;;;;"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { AmplifyErrorParams } from '@aws-amplify/core/internals/utils';
|
|
2
|
+
import { RestApiError } from './RestApiError';
|
|
3
|
+
/**
|
|
4
|
+
* Internal-only class for CanceledError.
|
|
5
|
+
*
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
export declare class CanceledError extends RestApiError {
|
|
9
|
+
constructor(params?: Partial<AmplifyErrorParams>);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Check if an error is caused by user calling `cancel()` in REST API.
|
|
13
|
+
*
|
|
14
|
+
* @note This function works **ONLY** for errors thrown by REST API. For GraphQL APIs, use `client.isCancelError(error)`
|
|
15
|
+
* instead. `client` is generated from `generateClient()` API from `aws-amplify/api`.
|
|
16
|
+
*
|
|
17
|
+
* @param {unknown} error The unknown exception to be checked.
|
|
18
|
+
* @returns - A boolean indicating if the error was from an upload cancellation
|
|
19
|
+
*/
|
|
20
|
+
export declare const isCancelError: (error: unknown) => error is CanceledError;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { RestApiError } from './RestApiError.mjs';
|
|
2
|
+
|
|
3
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
4
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
/**
|
|
6
|
+
* Internal-only class for CanceledError.
|
|
7
|
+
*
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
class CanceledError extends RestApiError {
|
|
11
|
+
constructor(params = {}) {
|
|
12
|
+
super({
|
|
13
|
+
name: 'CanceledError',
|
|
14
|
+
message: 'Request is canceled by user',
|
|
15
|
+
...params,
|
|
16
|
+
});
|
|
17
|
+
// TODO: Delete the following 2 lines after we change the build target to >= es2015
|
|
18
|
+
this.constructor = CanceledError;
|
|
19
|
+
Object.setPrototypeOf(this, CanceledError.prototype);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Check if an error is caused by user calling `cancel()` in REST API.
|
|
24
|
+
*
|
|
25
|
+
* @note This function works **ONLY** for errors thrown by REST API. For GraphQL APIs, use `client.isCancelError(error)`
|
|
26
|
+
* instead. `client` is generated from `generateClient()` API from `aws-amplify/api`.
|
|
27
|
+
*
|
|
28
|
+
* @param {unknown} error The unknown exception to be checked.
|
|
29
|
+
* @returns - A boolean indicating if the error was from an upload cancellation
|
|
30
|
+
*/
|
|
31
|
+
const isCancelError = (error) => !!error && error instanceof CanceledError;
|
|
32
|
+
|
|
33
|
+
export { CanceledError, isCancelError };
|
|
34
|
+
//# sourceMappingURL=CanceledError.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CanceledError.mjs","sources":["../../../src/errors/CanceledError.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { RestApiError } from './RestApiError';\n/**\n * Internal-only class for CanceledError.\n *\n * @internal\n */\nexport class CanceledError extends RestApiError {\n constructor(params = {}) {\n super({\n name: 'CanceledError',\n message: 'Request is canceled by user',\n ...params,\n });\n // TODO: Delete the following 2 lines after we change the build target to >= es2015\n this.constructor = CanceledError;\n Object.setPrototypeOf(this, CanceledError.prototype);\n }\n}\n/**\n * Check if an error is caused by user calling `cancel()` in REST API.\n *\n * @note This function works **ONLY** for errors thrown by REST API. For GraphQL APIs, use `client.isCancelError(error)`\n * instead. `client` is generated from `generateClient()` API from `aws-amplify/api`.\n *\n * @param {unknown} error The unknown exception to be checked.\n * @returns - A boolean indicating if the error was from an upload cancellation\n */\nexport const isCancelError = (error) => !!error && error instanceof CanceledError;\n"],"names":[],"mappings":";;AAAA;AACA;AAEA;AACA;AACA;AACA;AACA;AACO,MAAM,aAAa,SAAS,YAAY,CAAC;AAChD,IAAI,WAAW,CAAC,MAAM,GAAG,EAAE,EAAE;AAC7B,QAAQ,KAAK,CAAC;AACd,YAAY,IAAI,EAAE,eAAe;AACjC,YAAY,OAAO,EAAE,6BAA6B;AAClD,YAAY,GAAG,MAAM;AACrB,SAAS,CAAC;AACV;AACA,QAAQ,IAAI,CAAC,WAAW,GAAG,aAAa;AACxC,QAAQ,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,aAAa,CAAC,SAAS,CAAC;AAC5D,IAAI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,aAAa,GAAG,CAAC,KAAK,KAAK,CAAC,CAAC,KAAK,IAAI,KAAK,YAAY;;;;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ApiError } from '@aws-amplify/core/internals/utils';
|
|
2
|
+
|
|
3
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
4
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
class RestApiError extends ApiError {
|
|
6
|
+
constructor(params) {
|
|
7
|
+
super(params);
|
|
8
|
+
// TODO: Delete the following 2 lines after we change the build target to >= es2015
|
|
9
|
+
this.constructor = RestApiError;
|
|
10
|
+
Object.setPrototypeOf(this, RestApiError.prototype);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { RestApiError };
|
|
15
|
+
//# sourceMappingURL=RestApiError.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RestApiError.mjs","sources":["../../../src/errors/RestApiError.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { ApiError } from '@aws-amplify/core/internals/utils';\nexport class RestApiError extends ApiError {\n constructor(params) {\n super(params);\n // TODO: Delete the following 2 lines after we change the build target to >= es2015\n this.constructor = RestApiError;\n Object.setPrototypeOf(this, RestApiError.prototype);\n }\n}\n"],"names":[],"mappings":";;AAAA;AACA;AAEO,MAAM,YAAY,SAAS,QAAQ,CAAC;AAC3C,IAAI,WAAW,CAAC,MAAM,EAAE;AACxB,QAAQ,KAAK,CAAC,MAAM,CAAC;AACrB;AACA,QAAQ,IAAI,CAAC,WAAW,GAAG,YAAY;AACvC,QAAQ,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,YAAY,CAAC,SAAS,CAAC;AAC3D,IAAI;AACJ;;;;"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { RestApiError } from './RestApiError.mjs';
|
|
2
|
+
import { validationErrorMap } from './validation.mjs';
|
|
3
|
+
|
|
4
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
5
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
6
|
+
/**
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
function assertValidationError(assertion, name) {
|
|
10
|
+
const { message, recoverySuggestion } = validationErrorMap[name];
|
|
11
|
+
if (!assertion) {
|
|
12
|
+
throw new RestApiError({ name, message, recoverySuggestion });
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { assertValidationError };
|
|
17
|
+
//# sourceMappingURL=assertValidatonError.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assertValidatonError.mjs","sources":["../../../src/errors/assertValidatonError.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { RestApiError } from './RestApiError';\nimport { validationErrorMap } from './validation';\n/**\n * @internal\n */\nexport function assertValidationError(assertion, name) {\n const { message, recoverySuggestion } = validationErrorMap[name];\n if (!assertion) {\n throw new RestApiError({ name, message, recoverySuggestion });\n }\n}\n"],"names":[],"mappings":";;;AAAA;AACA;AAGA;AACA;AACA;AACO,SAAS,qBAAqB,CAAC,SAAS,EAAE,IAAI,EAAE;AACvD,IAAI,MAAM,EAAE,OAAO,EAAE,kBAAkB,EAAE,GAAG,kBAAkB,CAAC,IAAI,CAAC;AACpE,IAAI,IAAI,CAAC,SAAS,EAAE;AACpB,QAAQ,MAAM,IAAI,YAAY,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,kBAAkB,EAAE,CAAC;AACrE,IAAI;AACJ;;;;"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { CanceledError, isCancelError } from './CanceledError.mjs';
|
|
2
|
+
export { RestApiError } from './RestApiError.mjs';
|
|
3
|
+
export { assertValidationError } from './assertValidatonError.mjs';
|
|
4
|
+
export { RestApiValidationErrorCode, validationErrorMap } from './validation.mjs';
|
|
5
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
var RestApiValidationErrorCode;
|
|
4
|
+
(function (RestApiValidationErrorCode) {
|
|
5
|
+
RestApiValidationErrorCode["InvalidApiName"] = "InvalidApiName";
|
|
6
|
+
})(RestApiValidationErrorCode || (RestApiValidationErrorCode = {}));
|
|
7
|
+
const validationErrorMap = {
|
|
8
|
+
[RestApiValidationErrorCode.InvalidApiName]: {
|
|
9
|
+
message: 'API name is invalid.',
|
|
10
|
+
recoverySuggestion: 'Check if the API name matches the one in your configuration or `aws-exports.js`',
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export { RestApiValidationErrorCode, validationErrorMap };
|
|
15
|
+
//# sourceMappingURL=validation.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.mjs","sources":["../../../src/errors/validation.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nexport var RestApiValidationErrorCode;\n(function (RestApiValidationErrorCode) {\n RestApiValidationErrorCode[\"InvalidApiName\"] = \"InvalidApiName\";\n})(RestApiValidationErrorCode || (RestApiValidationErrorCode = {}));\nexport const validationErrorMap = {\n [RestApiValidationErrorCode.InvalidApiName]: {\n message: 'API name is invalid.',\n recoverySuggestion: 'Check if the API name matches the one in your configuration or `aws-exports.js`',\n },\n};\n"],"names":[],"mappings":"AAAA;AACA;AACU,IAAC;AACX,CAAC,UAAU,0BAA0B,EAAE;AACvC,IAAI,0BAA0B,CAAC,gBAAgB,CAAC,GAAG,gBAAgB;AACnE,CAAC,EAAE,0BAA0B,KAAK,0BAA0B,GAAG,EAAE,CAAC,CAAC;AACvD,MAAC,kBAAkB,GAAG;AAClC,IAAI,CAAC,0BAA0B,CAAC,cAAc,GAAG;AACjD,QAAQ,OAAO,EAAE,sBAAsB;AACvC,QAAQ,kBAAkB,EAAE,iFAAiF;AAC7G,KAAK;AACL;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { AmplifyServer } from '@aws-amplify/core/internals/adapter-core';
|
|
2
|
+
import { InternalPostInput } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Internal-only REST POST handler to send GraphQL request to given endpoint. By default, it will use IAM to authorize
|
|
5
|
+
* the request. In some auth modes, the IAM auth has to be disabled. Here's how to set up the request auth correctly:
|
|
6
|
+
* * If auth mode is 'iam', you MUST NOT set 'authorization' header and 'x-api-key' header, since it would disable IAM
|
|
7
|
+
* auth. You MUST also set 'input.options.signingServiceInfo' option.
|
|
8
|
+
* * The including 'input.options.signingServiceInfo.service' and 'input.options.signingServiceInfo.region' are
|
|
9
|
+
* optional. If omitted, the signing service and region will be inferred from url.
|
|
10
|
+
* * If auth mode is 'none', you MUST NOT set 'options.signingServiceInfo' option.
|
|
11
|
+
* * If auth mode is 'apiKey', you MUST set 'x-api-key' custom header.
|
|
12
|
+
* * If auth mode is 'oidc' or 'lambda' or 'userPool', you MUST set 'authorization' header.
|
|
13
|
+
*
|
|
14
|
+
* To make the internal post cancellable, you must also call `updateRequestToBeCancellable()` with the promise from
|
|
15
|
+
* internal post call and the abort controller supplied to the internal post call.
|
|
16
|
+
*
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
export declare const post: (contextSpec: AmplifyServer.ContextSpec, input: InternalPostInput) => Promise<import("../types").RestApiResponse>;
|
|
20
|
+
export { cancel, updateRequestToBeCancellable, } from '../apis/common/internalPost';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { getAmplifyServerContext } from '@aws-amplify/core/internals/adapter-core';
|
|
2
|
+
import { post as post$1 } from '../apis/common/internalPost.mjs';
|
|
3
|
+
export { cancel, updateRequestToBeCancellable } from '../apis/common/internalPost.mjs';
|
|
4
|
+
|
|
5
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
6
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
7
|
+
/**
|
|
8
|
+
* Internal-only REST POST handler to send GraphQL request to given endpoint. By default, it will use IAM to authorize
|
|
9
|
+
* the request. In some auth modes, the IAM auth has to be disabled. Here's how to set up the request auth correctly:
|
|
10
|
+
* * If auth mode is 'iam', you MUST NOT set 'authorization' header and 'x-api-key' header, since it would disable IAM
|
|
11
|
+
* auth. You MUST also set 'input.options.signingServiceInfo' option.
|
|
12
|
+
* * The including 'input.options.signingServiceInfo.service' and 'input.options.signingServiceInfo.region' are
|
|
13
|
+
* optional. If omitted, the signing service and region will be inferred from url.
|
|
14
|
+
* * If auth mode is 'none', you MUST NOT set 'options.signingServiceInfo' option.
|
|
15
|
+
* * If auth mode is 'apiKey', you MUST set 'x-api-key' custom header.
|
|
16
|
+
* * If auth mode is 'oidc' or 'lambda' or 'userPool', you MUST set 'authorization' header.
|
|
17
|
+
*
|
|
18
|
+
* To make the internal post cancellable, you must also call `updateRequestToBeCancellable()` with the promise from
|
|
19
|
+
* internal post call and the abort controller supplied to the internal post call.
|
|
20
|
+
*
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
const post = (contextSpec, input) => {
|
|
24
|
+
return post$1(getAmplifyServerContext(contextSpec).amplify, input);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export { post };
|
|
28
|
+
//# sourceMappingURL=server.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.mjs","sources":["../../../src/internals/server.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { getAmplifyServerContext, } from '@aws-amplify/core/internals/adapter-core';\nimport { post as internalPost } from '../apis/common/internalPost';\n/**\n * Internal-only REST POST handler to send GraphQL request to given endpoint. By default, it will use IAM to authorize\n * the request. In some auth modes, the IAM auth has to be disabled. Here's how to set up the request auth correctly:\n * * If auth mode is 'iam', you MUST NOT set 'authorization' header and 'x-api-key' header, since it would disable IAM\n * auth. You MUST also set 'input.options.signingServiceInfo' option.\n * * The including 'input.options.signingServiceInfo.service' and 'input.options.signingServiceInfo.region' are\n * optional. If omitted, the signing service and region will be inferred from url.\n * * If auth mode is 'none', you MUST NOT set 'options.signingServiceInfo' option.\n * * If auth mode is 'apiKey', you MUST set 'x-api-key' custom header.\n * * If auth mode is 'oidc' or 'lambda' or 'userPool', you MUST set 'authorization' header.\n *\n * To make the internal post cancellable, you must also call `updateRequestToBeCancellable()` with the promise from\n * internal post call and the abort controller supplied to the internal post call.\n *\n * @internal\n */\nexport const post = (contextSpec, input) => {\n return internalPost(getAmplifyServerContext(contextSpec).amplify, input);\n};\nexport { cancel, updateRequestToBeCancellable, } from '../apis/common/internalPost';\n"],"names":["internalPost"],"mappings":";;;;AAAA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,IAAI,GAAG,CAAC,WAAW,EAAE,KAAK,KAAK;AAC5C,IAAI,OAAOA,MAAY,CAAC,uBAAuB,CAAC,WAAW,CAAC,CAAC,OAAO,EAAE,KAAK,CAAC;AAC5E;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|