22// SPDX-License-Identifier: Apache-2.0
33
44import { AmplifyContext } from '@aws-amplify/core' ;
5+ import { resolveCtxArgs } from '@aws-amplify/core/internals/utils' ;
56
67import {
78 DeleteInput ,
@@ -67,7 +68,13 @@ import {
6768 * }
6869 * ```
6970 */
70- export const get = ( ctx : AmplifyContext , input : GetInput ) : GetOperation => commonGet ( ctx , input ) ;
71+ export function get ( input : GetInput ) : GetOperation ;
72+ export function get ( ctx : AmplifyContext , input : GetInput ) : GetOperation ;
73+ export function get ( ...args : any [ ] ) : GetOperation {
74+ const [ ctx , input ] = resolveCtxArgs < GetInput > ( args ) ;
75+
76+ return commonGet ( ctx , input ) ;
77+ }
7178
7279/**
7380 * POST HTTP request
@@ -108,8 +115,13 @@ export const get = (ctx: AmplifyContext, input: GetInput): GetOperation => commo
108115 * }
109116 * ```
110117 */
111- export const post = ( ctx : AmplifyContext , input : PostInput ) : PostOperation =>
112- commonPost ( ctx , input ) ;
118+ export function post ( input : PostInput ) : PostOperation ;
119+ export function post ( ctx : AmplifyContext , input : PostInput ) : PostOperation ;
120+ export function post ( ...args : any [ ] ) : PostOperation {
121+ const [ ctx , input ] = resolveCtxArgs < PostInput > ( args ) ;
122+
123+ return commonPost ( ctx , input ) ;
124+ }
113125
114126/**
115127 * PUT HTTP request
@@ -149,7 +161,13 @@ export const post = (ctx: AmplifyContext, input: PostInput): PostOperation =>
149161 * }
150162 * ```
151163 */
152- export const put = ( ctx : AmplifyContext , input : PutInput ) : PutOperation => commonPut ( ctx , input ) ;
164+ export function put ( input : PutInput ) : PutOperation ;
165+ export function put ( ctx : AmplifyContext , input : PutInput ) : PutOperation ;
166+ export function put ( ...args : any [ ] ) : PutOperation {
167+ const [ ctx , input ] = resolveCtxArgs < PutInput > ( args ) ;
168+
169+ return commonPut ( ctx , input ) ;
170+ }
153171
154172/**
155173 * DELETE HTTP request
@@ -171,8 +189,13 @@ export const put = (ctx: AmplifyContext, input: PutInput): PutOperation => commo
171189 * }).response;
172190 * ```
173191 */
174- export const del = ( ctx : AmplifyContext , input : DeleteInput ) : DeleteOperation =>
175- commonDel ( ctx , input ) ;
192+ export function del ( input : DeleteInput ) : DeleteOperation ;
193+ export function del ( ctx : AmplifyContext , input : DeleteInput ) : DeleteOperation ;
194+ export function del ( ...args : any [ ] ) : DeleteOperation {
195+ const [ ctx , input ] = resolveCtxArgs < DeleteInput > ( args ) ;
196+
197+ return commonDel ( ctx , input ) ;
198+ }
176199
177200/**
178201 * HEAD HTTP request
@@ -195,8 +218,13 @@ export const del = (ctx: AmplifyContext, input: DeleteInput): DeleteOperation =>
195218 * ```
196219 *
197220 */
198- export const head = ( ctx : AmplifyContext , input : HeadInput ) : HeadOperation =>
199- commonHead ( ctx , input ) ;
221+ export function head ( input : HeadInput ) : HeadOperation ;
222+ export function head ( ctx : AmplifyContext , input : HeadInput ) : HeadOperation ;
223+ export function head ( ...args : any [ ] ) : HeadOperation {
224+ const [ ctx , input ] = resolveCtxArgs < HeadInput > ( args ) ;
225+
226+ return commonHead ( ctx , input ) ;
227+ }
200228
201229/**
202230 * PATCH HTTP request
@@ -237,5 +265,10 @@ export const head = (ctx: AmplifyContext, input: HeadInput): HeadOperation =>
237265 * }
238266 * ```
239267 */
240- export const patch = ( ctx : AmplifyContext , input : PatchInput ) : PatchOperation =>
241- commonPatch ( ctx , input ) ;
268+ export function patch ( input : PatchInput ) : PatchOperation ;
269+ export function patch ( ctx : AmplifyContext , input : PatchInput ) : PatchOperation ;
270+ export function patch ( ...args : any [ ] ) : PatchOperation {
271+ const [ ctx , input ] = resolveCtxArgs < PatchInput > ( args ) ;
272+
273+ return commonPatch ( ctx , input ) ;
274+ }
0 commit comments