1 | import { AWSAppSyncRealTimeProvider } from '@aws-amplify/pubsub';
|
2 | import { GraphQLOptions, GraphQLResult, GraphQLOperation, OperationTypeNode } from '@aws-amplify/api-graphql';
|
3 | import Observable from 'zen-observable-ts';
|
4 | import { GraphQLQuery, GraphQLSubscription } from './types';
|
5 | /**
|
6 | * @deprecated
|
7 | * Use RestApi or GraphQLAPI to reduce your application bundle size
|
8 | * Export Cloud Logic APIs
|
9 | */
|
10 | export declare class APIClass {
|
11 | /**
|
12 | * Initialize API with AWS configuration
|
13 | * @param {Object} options - Configuration object for API
|
14 | */
|
15 | private _options;
|
16 | private _restApi;
|
17 | private _graphqlApi;
|
18 | Auth: import("@aws-amplify/auth/lib-esm/Auth").AuthClass;
|
19 | Cache: import("@aws-amplify/cache/lib-esm/types").ICache;
|
20 | Credentials: import("@aws-amplify/core").CredentialsClass;
|
21 | /**
|
22 | * Initialize API with AWS configuration
|
23 | * @param {Object} options - Configuration object for API
|
24 | */
|
25 | constructor(options: any);
|
26 | getModuleName(): string;
|
27 | /**
|
28 | * Configure API part with aws configurations
|
29 | * @param {Object} config - Configuration of the API
|
30 | * Object} - The current configuration
{ |
31 | */
|
32 | configure(options: any): any;
|
33 | /**
|
34 | * Make a GET request
|
35 | * @param apiName - The api name of the request
|
36 | * @param path - The path of the request
|
37 | * @param [init] - Request extra params
|
38 | * @return A promise that resolves to an object with response status and JSON data, if successful.
|
39 | */
|
40 | get(apiName: string, path: string, init: {
|
41 | [key: string]: any;
|
42 | }): Promise<any>;
|
43 | /**
|
44 | * Make a POST request
|
45 | * @param apiName - The api name of the request
|
46 | * @param path - The path of the request
|
47 | * @param [init] - Request extra params
|
48 | * @return A promise that resolves to an object with response status and JSON data, if successful.
|
49 | */
|
50 | post(apiName: string, path: string, init: {
|
51 | [key: string]: any;
|
52 | }): Promise<any>;
|
53 | /**
|
54 | * Make a PUT request
|
55 | * @param apiName - The api name of the request
|
56 | * @param path - The path of the request
|
57 | * @param [init] - Request extra params
|
58 | * @return A promise that resolves to an object with response status and JSON data, if successful.
|
59 | */
|
60 | put(apiName: string, path: string, init: {
|
61 | [key: string]: any;
|
62 | }): Promise<any>;
|
63 | /**
|
64 | * Make a PATCH request
|
65 | * @param apiName - The api name of the request
|
66 | * @param path - The path of the request
|
67 | * @param [init] - Request extra params
|
68 | * @return A promise that resolves to an object with response status and JSON data, if successful.
|
69 | */
|
70 | patch(apiName: string, path: string, init: {
|
71 | [key: string]: any;
|
72 | }): Promise<any>;
|
73 | /**
|
74 | * Make a DEL request
|
75 | * @param apiName - The api name of the request
|
76 | * @param path - The path of the request
|
77 | * @param [init] - Request extra params
|
78 | * @return A promise that resolves to an object with response status and JSON data, if successful.
|
79 | */
|
80 | del(apiName: string, path: string, init: {
|
81 | [key: string]: any;
|
82 | }): Promise<any>;
|
83 | /**
|
84 | * Make a HEAD request
|
85 | * @param apiName - The api name of the request
|
86 | * @param path - The path of the request
|
87 | * @param [init] - Request extra params
|
88 | * @return A promise that resolves to an object with response status and JSON data, if successful.
|
89 | */
|
90 | head(apiName: string, path: string, init: {
|
91 | [key: string]: any;
|
92 | }): Promise<any>;
|
93 | /**
|
94 | * Checks to see if an error thrown is from an api request cancellation
|
95 | * @param error - Any error
|
96 | * @return If the error was from an api request cancellation
|
97 | */
|
98 | isCancel(error: any): boolean;
|
99 | /**
|
100 | * Cancels an inflight request for either a GraphQL request or a Rest API request.
|
101 | * @param request - request to cancel
|
102 | * @param [message] - custom error message
|
103 | * @return If the request was cancelled
|
104 | */
|
105 | cancel(request: Promise<any>, message?: string): boolean;
|
106 | /**
|
107 | * Getting endpoint for API
|
108 | * @param apiName - The name of the api
|
109 | * @return The endpoint of the api
|
110 | */
|
111 | endpoint(apiName: string): Promise<string>;
|
112 | /**
|
113 | * to get the operation type
|
114 | * @param operation
|
115 | */
|
116 | getGraphqlOperationType(operation: GraphQLOperation): OperationTypeNode;
|
117 | /**
|
118 | * Executes a GraphQL operation
|
119 | *
|
120 | * @param options - GraphQL Options
|
121 | * @param [additionalHeaders] - headers to merge in after any `graphql_headers` set in the config
|
122 | * @returns An Observable if queryType is 'subscription', else a promise of the graphql result from the query.
|
123 | */
|
124 | graphql<T>(options: GraphQLOptions, additionalHeaders?: {
|
125 | [key: string]: string;
|
126 | }): T extends GraphQLQuery<T> ? Promise<GraphQLResult<T>> : T extends GraphQLSubscription<T> ? Observable<{
|
127 | provider: AWSAppSyncRealTimeProvider;
|
128 | value: GraphQLResult<T>;
|
129 | }> : Promise<GraphQLResult<any>> | Observable<object>;
|
130 | }
|
131 | export declare const API: APIClass;
|