@aws-amplify/api 5.4.6-unstable.7762f1a.0 → 6.0.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/README.md +3 -0
- package/lib/API.d.ts +3 -25
- package/lib/API.js +14 -22
- package/lib/API.js.map +1 -1
- package/lib/index.d.ts +4 -3
- package/lib/index.js +9 -4
- package/lib/index.js.map +1 -1
- package/lib/internals/InternalAPI.d.ts +4 -95
- package/lib/internals/InternalAPI.js +28 -143
- package/lib/internals/InternalAPI.js.map +1 -1
- package/lib/server.d.ts +14 -0
- package/lib/server.js +35 -0
- package/lib/server.js.map +1 -0
- package/lib/types/index.d.ts +1 -8
- package/lib/types/index.js +0 -1
- package/lib/types/index.js.map +1 -1
- package/lib-esm/API.d.ts +3 -25
- package/lib-esm/API.js +13 -22
- package/lib-esm/API.js.map +1 -1
- package/lib-esm/index.d.ts +4 -3
- package/lib-esm/index.js +3 -2
- package/lib-esm/index.js.map +1 -1
- package/lib-esm/internals/InternalAPI.d.ts +4 -95
- package/lib-esm/internals/InternalAPI.js +27 -143
- package/lib-esm/internals/InternalAPI.js.map +1 -1
- package/lib-esm/server.d.ts +14 -0
- package/lib-esm/server.js +25 -0
- package/lib-esm/server.js.map +1 -0
- package/lib-esm/types/index.d.ts +1 -8
- package/lib-esm/types/index.js +1 -1
- package/lib-esm/types/index.js.map +1 -1
- package/package.json +9 -24
- package/server/package.json +8 -0
- package/src/API.ts +17 -42
- package/src/index.ts +18 -6
- package/src/internals/InternalAPI.ts +17 -195
- package/src/server.ts +59 -0
- package/src/types/index.ts +2 -9
- package/index.v37.d.ts +0 -12
package/README.md
ADDED
package/lib/API.d.ts
CHANGED
|
@@ -1,27 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { GraphQLOptions, GraphQLResult } from '@aws-amplify/api-graphql';
|
|
3
|
-
import Observable from 'zen-observable-ts';
|
|
4
|
-
import { GraphQLQuery, GraphQLSubscription } from './types';
|
|
5
|
-
import { InternalAPIClass } from './internals/InternalAPI';
|
|
1
|
+
import { V6Client } from '@aws-amplify/api-graphql';
|
|
6
2
|
/**
|
|
7
|
-
*
|
|
8
|
-
* Use RestApi or GraphQLAPI to reduce your application bundle size
|
|
9
|
-
* Export Cloud Logic APIs
|
|
3
|
+
* Generates an API client that can work with models or raw GraphQL
|
|
10
4
|
*/
|
|
11
|
-
export declare
|
|
12
|
-
getModuleName(): string;
|
|
13
|
-
/**
|
|
14
|
-
* Executes a GraphQL operation
|
|
15
|
-
*
|
|
16
|
-
* @param options - GraphQL Options
|
|
17
|
-
* @param [additionalHeaders] - headers to merge in after any `graphql_headers` set in the config
|
|
18
|
-
* @returns An Observable if queryType is 'subscription', else a promise of the graphql result from the query.
|
|
19
|
-
*/
|
|
20
|
-
graphql<T>(options: GraphQLOptions, additionalHeaders?: {
|
|
21
|
-
[key: string]: string;
|
|
22
|
-
}): T extends GraphQLQuery<T> ? Promise<GraphQLResult<T>> : T extends GraphQLSubscription<T> ? Observable<{
|
|
23
|
-
provider: AWSAppSyncRealTimeProvider;
|
|
24
|
-
value: GraphQLResult<T>;
|
|
25
|
-
}> : Promise<GraphQLResult<any>> | Observable<object>;
|
|
26
|
-
}
|
|
27
|
-
export declare const API: APIClass;
|
|
5
|
+
export declare function generateClient<T extends Record<any, any> = never>(): V6Client<T>;
|
package/lib/API.js
CHANGED
|
@@ -1,28 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
4
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
const api_graphql_1 = require("@aws-amplify/api-graphql");
|
|
6
|
+
const internals_1 = require("@aws-amplify/api-graphql/internals");
|
|
7
|
+
const core_1 = require("@aws-amplify/core");
|
|
7
8
|
/**
|
|
8
|
-
*
|
|
9
|
-
* Use RestApi or GraphQLAPI to reduce your application bundle size
|
|
10
|
-
* Export Cloud Logic APIs
|
|
9
|
+
* Generates an API client that can work with models or raw GraphQL
|
|
11
10
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return 'API';
|
|
11
|
+
function generateClient() {
|
|
12
|
+
return {
|
|
13
|
+
[api_graphql_1.__amplify]: core_1.Amplify,
|
|
14
|
+
graphql: internals_1.graphql,
|
|
15
|
+
cancel: internals_1.cancel,
|
|
16
|
+
isCancelError: internals_1.isCancelError,
|
|
19
17
|
};
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
};
|
|
23
|
-
return APIClass;
|
|
24
|
-
}(InternalAPI_1.InternalAPIClass));
|
|
25
|
-
exports.APIClass = APIClass;
|
|
26
|
-
exports.API = new APIClass(null);
|
|
27
|
-
core_1.Amplify.register(exports.API);
|
|
18
|
+
}
|
|
19
|
+
exports.generateClient = generateClient;
|
|
28
20
|
//# sourceMappingURL=API.js.map
|
package/lib/API.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"API.js","sourceRoot":"","sources":["../src/API.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"API.js","sourceRoot":"","sources":["../src/API.ts"],"names":[],"mappings":";;AAAA,qEAAqE;AACrE,sCAAsC;AACtC,0DAA+D;AAC/D,kEAI4C;AAC5C,4CAA4C;AAE5C;;GAEG;AACH,SAAgB,cAAc;IAG7B,OAAO;QACN,CAAC,uBAAS,CAAC,EAAE,cAAO;QACpB,OAAO,EAAE,mBAAS;QAClB,MAAM,EAAE,kBAAQ;QAChB,aAAa,EAAE,yBAAe;KAC9B,CAAC;AACH,CAAC;AATD,wCASC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { GraphQLQuery, GraphQLSubscription } from './types';
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export type { GraphQLResult } from '@aws-amplify/api-graphql';
|
|
2
|
+
export { generateClient } from './API';
|
|
3
|
+
export { GraphQLAuthError } from '@aws-amplify/api-graphql';
|
|
4
|
+
export type { GraphQLResult, GraphQLReturnType, } from '@aws-amplify/api-graphql';
|
|
5
|
+
export { get, put, post, del, head, patch, isCancelError, } from '@aws-amplify/api-rest';
|
package/lib/index.js
CHANGED
|
@@ -3,10 +3,15 @@
|
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
var API_1 = require("./API");
|
|
6
|
-
exports.
|
|
7
|
-
exports.APIClass = API_1.APIClass;
|
|
6
|
+
exports.generateClient = API_1.generateClient;
|
|
8
7
|
var api_graphql_1 = require("@aws-amplify/api-graphql");
|
|
9
|
-
exports.graphqlOperation = api_graphql_1.graphqlOperation;
|
|
10
8
|
exports.GraphQLAuthError = api_graphql_1.GraphQLAuthError;
|
|
11
|
-
|
|
9
|
+
var api_rest_1 = require("@aws-amplify/api-rest");
|
|
10
|
+
exports.get = api_rest_1.get;
|
|
11
|
+
exports.put = api_rest_1.put;
|
|
12
|
+
exports.post = api_rest_1.post;
|
|
13
|
+
exports.del = api_rest_1.del;
|
|
14
|
+
exports.head = api_rest_1.head;
|
|
15
|
+
exports.patch = api_rest_1.patch;
|
|
16
|
+
exports.isCancelError = api_rest_1.isCancelError;
|
|
12
17
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;;AAKtC,6BAAuC;AAA9B,+BAAA,cAAc,CAAA;AAEvB,wDAA4D;AAAnD,yCAAA,gBAAgB,CAAA;AAOzB,kDAQ+B;AAP9B,yBAAA,GAAG,CAAA;AACH,yBAAA,GAAG,CAAA;AACH,0BAAA,IAAI,CAAA;AACJ,yBAAA,GAAG,CAAA;AACH,0BAAA,IAAI,CAAA;AACJ,2BAAA,KAAK,CAAA;AACL,mCAAA,aAAa,CAAA"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { GraphQLOperation, GraphQLOptions, GraphQLResult, OperationTypeNode } from '@aws-amplify/api-graphql';
|
|
2
|
-
import { CustomUserAgentDetails } from '@aws-amplify/core';
|
|
3
|
-
import {
|
|
4
|
-
import Observable from 'zen-observable-ts';
|
|
5
|
-
import { GraphQLQuery, GraphQLSubscription } from '../types';
|
|
1
|
+
import { AWSAppSyncRealTimeProvider, GraphQLOperation, GraphQLOptions, GraphQLResult, OperationTypeNode, GraphQLQuery, GraphQLSubscription } from '@aws-amplify/api-graphql';
|
|
2
|
+
import { CustomUserAgentDetails } from '@aws-amplify/core/internals/utils';
|
|
3
|
+
import { Observable } from 'rxjs';
|
|
6
4
|
/**
|
|
7
5
|
* @deprecated
|
|
8
6
|
* Use RestApi or GraphQLAPI to reduce your application bundle size
|
|
@@ -14,103 +12,14 @@ export declare class InternalAPIClass {
|
|
|
14
12
|
* @param {Object} options - Configuration object for API
|
|
15
13
|
*/
|
|
16
14
|
private _options;
|
|
17
|
-
private _restApi;
|
|
18
15
|
private _graphqlApi;
|
|
19
|
-
|
|
20
|
-
Cache: import("@aws-amplify/cache/lib-esm/types").ICache;
|
|
21
|
-
Credentials: import("@aws-amplify/core").CredentialsClass;
|
|
16
|
+
Cache: import("@aws-amplify/core/lib-esm/Cache/StorageCache").StorageCache;
|
|
22
17
|
/**
|
|
23
18
|
* Initialize API with AWS configuration
|
|
24
19
|
* @param {Object} options - Configuration object for API
|
|
25
20
|
*/
|
|
26
21
|
constructor(options: any);
|
|
27
22
|
getModuleName(): string;
|
|
28
|
-
/**
|
|
29
|
-
* Configure API part with aws configurations
|
|
30
|
-
* @param {Object} config - Configuration of the API
|
|
31
|
-
* @return {Object} - The current configuration
|
|
32
|
-
*/
|
|
33
|
-
configure(options: any): any;
|
|
34
|
-
/**
|
|
35
|
-
* Make a GET request
|
|
36
|
-
* @param apiName - The api name of the request
|
|
37
|
-
* @param path - The path of the request
|
|
38
|
-
* @param [init] - Request extra params
|
|
39
|
-
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
40
|
-
*/
|
|
41
|
-
get(apiName: string, path: string, init: {
|
|
42
|
-
[key: string]: any;
|
|
43
|
-
}): Promise<any>;
|
|
44
|
-
/**
|
|
45
|
-
* Make a POST request
|
|
46
|
-
* @param apiName - The api name of the request
|
|
47
|
-
* @param path - The path of the request
|
|
48
|
-
* @param [init] - Request extra params
|
|
49
|
-
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
50
|
-
*/
|
|
51
|
-
post(apiName: string, path: string, init: {
|
|
52
|
-
[key: string]: any;
|
|
53
|
-
}): Promise<any>;
|
|
54
|
-
/**
|
|
55
|
-
* Make a PUT request
|
|
56
|
-
* @param apiName - The api name of the request
|
|
57
|
-
* @param path - The path of the request
|
|
58
|
-
* @param [init] - Request extra params
|
|
59
|
-
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
60
|
-
*/
|
|
61
|
-
put(apiName: string, path: string, init: {
|
|
62
|
-
[key: string]: any;
|
|
63
|
-
}): Promise<any>;
|
|
64
|
-
/**
|
|
65
|
-
* Make a PATCH request
|
|
66
|
-
* @param apiName - The api name of the request
|
|
67
|
-
* @param path - The path of the request
|
|
68
|
-
* @param [init] - Request extra params
|
|
69
|
-
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
70
|
-
*/
|
|
71
|
-
patch(apiName: string, path: string, init: {
|
|
72
|
-
[key: string]: any;
|
|
73
|
-
}): Promise<any>;
|
|
74
|
-
/**
|
|
75
|
-
* Make a DEL request
|
|
76
|
-
* @param apiName - The api name of the request
|
|
77
|
-
* @param path - The path of the request
|
|
78
|
-
* @param [init] - Request extra params
|
|
79
|
-
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
80
|
-
*/
|
|
81
|
-
del(apiName: string, path: string, init: {
|
|
82
|
-
[key: string]: any;
|
|
83
|
-
}): Promise<any>;
|
|
84
|
-
/**
|
|
85
|
-
* Make a HEAD request
|
|
86
|
-
* @param apiName - The api name of the request
|
|
87
|
-
* @param path - The path of the request
|
|
88
|
-
* @param [init] - Request extra params
|
|
89
|
-
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
90
|
-
*/
|
|
91
|
-
head(apiName: string, path: string, init: {
|
|
92
|
-
[key: string]: any;
|
|
93
|
-
}): Promise<any>;
|
|
94
|
-
/**
|
|
95
|
-
* Checks to see if an error thrown is from an api request cancellation
|
|
96
|
-
* @param error - Any error
|
|
97
|
-
* @return If the error was from an api request cancellation
|
|
98
|
-
*/
|
|
99
|
-
isCancel(error: any): boolean;
|
|
100
|
-
/**
|
|
101
|
-
* Cancels an inflight request for either a GraphQL request or a Rest API request.
|
|
102
|
-
* @param request - request to cancel
|
|
103
|
-
* @param [message] - custom error message
|
|
104
|
-
* @return If the request was cancelled
|
|
105
|
-
*/
|
|
106
|
-
cancel(request: Promise<any>, message?: string): boolean;
|
|
107
|
-
private getInitWithCustomUserAgentDetails;
|
|
108
|
-
/**
|
|
109
|
-
* Getting endpoint for API
|
|
110
|
-
* @param apiName - The name of the api
|
|
111
|
-
* @return The endpoint of the api
|
|
112
|
-
*/
|
|
113
|
-
endpoint(apiName: string): Promise<string>;
|
|
114
23
|
/**
|
|
115
24
|
* to get the operation type
|
|
116
25
|
* @param operation
|
|
@@ -1,167 +1,52 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
const internals_1 = require("@aws-amplify/api-graphql/internals");
|
|
4
|
+
const core_1 = require("@aws-amplify/core");
|
|
5
|
+
const utils_1 = require("@aws-amplify/core/internals/utils");
|
|
6
|
+
/**
|
|
7
|
+
* NOTE!
|
|
8
|
+
*
|
|
9
|
+
* This is used only by DataStore.
|
|
10
|
+
*
|
|
11
|
+
* This can probably be pruned and/or removed. Just leaving it as much of the same
|
|
12
|
+
* state as possible for V6 to reduce number of potentially impactful changes to DataStore.
|
|
13
|
+
*/
|
|
14
|
+
const logger = new core_1.ConsoleLogger('API');
|
|
10
15
|
/**
|
|
11
16
|
* @deprecated
|
|
12
17
|
* Use RestApi or GraphQLAPI to reduce your application bundle size
|
|
13
18
|
* Export Cloud Logic APIs
|
|
14
19
|
*/
|
|
15
|
-
|
|
20
|
+
class InternalAPIClass {
|
|
16
21
|
/**
|
|
17
22
|
* Initialize API with AWS configuration
|
|
18
23
|
* @param {Object} options - Configuration object for API
|
|
19
24
|
*/
|
|
20
|
-
|
|
21
|
-
this.
|
|
22
|
-
this.Cache = cache_1.Cache;
|
|
23
|
-
this.Credentials = core_1.Credentials;
|
|
25
|
+
constructor(options) {
|
|
26
|
+
this.Cache = core_1.Cache;
|
|
24
27
|
this._options = options;
|
|
25
|
-
this._restApi = new api_rest_1.RestAPIClass(options);
|
|
26
28
|
this._graphqlApi = new internals_1.InternalGraphQLAPIClass(options);
|
|
27
29
|
logger.debug('API Options', this._options);
|
|
28
30
|
}
|
|
29
|
-
|
|
31
|
+
getModuleName() {
|
|
30
32
|
return 'InternalAPI';
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Configure API part with aws configurations
|
|
34
|
-
* @param {Object} config - Configuration of the API
|
|
35
|
-
* @return {Object} - The current configuration
|
|
36
|
-
*/
|
|
37
|
-
InternalAPIClass.prototype.configure = function (options) {
|
|
38
|
-
this._options = Object.assign({}, this._options, options);
|
|
39
|
-
// Share Amplify instance with client for SSR
|
|
40
|
-
this._restApi.Credentials = this.Credentials;
|
|
41
|
-
this._graphqlApi.Auth = this.Auth;
|
|
42
|
-
this._graphqlApi.Cache = this.Cache;
|
|
43
|
-
this._graphqlApi.Credentials = this.Credentials;
|
|
44
|
-
var restAPIConfig = this._restApi.configure(this._options);
|
|
45
|
-
var graphQLAPIConfig = this._graphqlApi.configure(this._options);
|
|
46
|
-
return tslib_1.__assign(tslib_1.__assign({}, restAPIConfig), graphQLAPIConfig);
|
|
47
|
-
};
|
|
48
|
-
/**
|
|
49
|
-
* Make a GET request
|
|
50
|
-
* @param apiName - The api name of the request
|
|
51
|
-
* @param path - The path of the request
|
|
52
|
-
* @param [init] - Request extra params
|
|
53
|
-
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
54
|
-
*/
|
|
55
|
-
InternalAPIClass.prototype.get = function (apiName, path, init) {
|
|
56
|
-
return this._restApi.get(apiName, path, this.getInitWithCustomUserAgentDetails(init, core_1.ApiAction.Get));
|
|
57
|
-
};
|
|
58
|
-
/**
|
|
59
|
-
* Make a POST request
|
|
60
|
-
* @param apiName - The api name of the request
|
|
61
|
-
* @param path - The path of the request
|
|
62
|
-
* @param [init] - Request extra params
|
|
63
|
-
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
64
|
-
*/
|
|
65
|
-
InternalAPIClass.prototype.post = function (apiName, path, init) {
|
|
66
|
-
return this._restApi.post(apiName, path, this.getInitWithCustomUserAgentDetails(init, core_1.ApiAction.Post));
|
|
67
|
-
};
|
|
68
|
-
/**
|
|
69
|
-
* Make a PUT request
|
|
70
|
-
* @param apiName - The api name of the request
|
|
71
|
-
* @param path - The path of the request
|
|
72
|
-
* @param [init] - Request extra params
|
|
73
|
-
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
74
|
-
*/
|
|
75
|
-
InternalAPIClass.prototype.put = function (apiName, path, init) {
|
|
76
|
-
return this._restApi.put(apiName, path, this.getInitWithCustomUserAgentDetails(init, core_1.ApiAction.Put));
|
|
77
|
-
};
|
|
78
|
-
/**
|
|
79
|
-
* Make a PATCH request
|
|
80
|
-
* @param apiName - The api name of the request
|
|
81
|
-
* @param path - The path of the request
|
|
82
|
-
* @param [init] - Request extra params
|
|
83
|
-
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
84
|
-
*/
|
|
85
|
-
InternalAPIClass.prototype.patch = function (apiName, path, init) {
|
|
86
|
-
return this._restApi.patch(apiName, path, this.getInitWithCustomUserAgentDetails(init, core_1.ApiAction.Patch));
|
|
87
|
-
};
|
|
88
|
-
/**
|
|
89
|
-
* Make a DEL request
|
|
90
|
-
* @param apiName - The api name of the request
|
|
91
|
-
* @param path - The path of the request
|
|
92
|
-
* @param [init] - Request extra params
|
|
93
|
-
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
94
|
-
*/
|
|
95
|
-
InternalAPIClass.prototype.del = function (apiName, path, init) {
|
|
96
|
-
return this._restApi.del(apiName, path, this.getInitWithCustomUserAgentDetails(init, core_1.ApiAction.Del));
|
|
97
|
-
};
|
|
98
|
-
/**
|
|
99
|
-
* Make a HEAD request
|
|
100
|
-
* @param apiName - The api name of the request
|
|
101
|
-
* @param path - The path of the request
|
|
102
|
-
* @param [init] - Request extra params
|
|
103
|
-
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
104
|
-
*/
|
|
105
|
-
InternalAPIClass.prototype.head = function (apiName, path, init) {
|
|
106
|
-
return this._restApi.head(apiName, path, this.getInitWithCustomUserAgentDetails(init, core_1.ApiAction.Head));
|
|
107
|
-
};
|
|
108
|
-
/**
|
|
109
|
-
* Checks to see if an error thrown is from an api request cancellation
|
|
110
|
-
* @param error - Any error
|
|
111
|
-
* @return If the error was from an api request cancellation
|
|
112
|
-
*/
|
|
113
|
-
InternalAPIClass.prototype.isCancel = function (error) {
|
|
114
|
-
return this._restApi.isCancel(error);
|
|
115
|
-
};
|
|
116
|
-
/**
|
|
117
|
-
* Cancels an inflight request for either a GraphQL request or a Rest API request.
|
|
118
|
-
* @param request - request to cancel
|
|
119
|
-
* @param [message] - custom error message
|
|
120
|
-
* @return If the request was cancelled
|
|
121
|
-
*/
|
|
122
|
-
InternalAPIClass.prototype.cancel = function (request, message) {
|
|
123
|
-
if (this._restApi.hasCancelToken(request)) {
|
|
124
|
-
return this._restApi.cancel(request, message);
|
|
125
|
-
}
|
|
126
|
-
else if (this._graphqlApi.hasCancelToken(request)) {
|
|
127
|
-
return this._graphqlApi.cancel(request, message);
|
|
128
|
-
}
|
|
129
|
-
return false;
|
|
130
|
-
};
|
|
131
|
-
InternalAPIClass.prototype.getInitWithCustomUserAgentDetails = function (init, action) {
|
|
132
|
-
var customUserAgentDetails = {
|
|
133
|
-
category: core_1.Category.API,
|
|
134
|
-
action: action,
|
|
135
|
-
};
|
|
136
|
-
var initParams = tslib_1.__assign(tslib_1.__assign({}, init), { customUserAgentDetails: customUserAgentDetails });
|
|
137
|
-
return initParams;
|
|
138
|
-
};
|
|
139
|
-
/**
|
|
140
|
-
* Getting endpoint for API
|
|
141
|
-
* @param apiName - The name of the api
|
|
142
|
-
* @return The endpoint of the api
|
|
143
|
-
*/
|
|
144
|
-
InternalAPIClass.prototype.endpoint = function (apiName) {
|
|
145
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
146
|
-
return tslib_1.__generator(this, function (_a) {
|
|
147
|
-
return [2 /*return*/, this._restApi.endpoint(apiName)];
|
|
148
|
-
});
|
|
149
|
-
});
|
|
150
|
-
};
|
|
33
|
+
}
|
|
151
34
|
/**
|
|
152
35
|
* to get the operation type
|
|
153
36
|
* @param operation
|
|
154
37
|
*/
|
|
155
|
-
|
|
38
|
+
getGraphqlOperationType(operation) {
|
|
156
39
|
return this._graphqlApi.getGraphqlOperationType(operation);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
}
|
|
40
|
+
}
|
|
41
|
+
graphql(options, additionalHeaders, customUserAgentDetails) {
|
|
42
|
+
const apiUserAgentDetails = {
|
|
43
|
+
category: utils_1.Category.API,
|
|
44
|
+
action: utils_1.ApiAction.GraphQl,
|
|
45
|
+
...customUserAgentDetails,
|
|
46
|
+
};
|
|
47
|
+
return this._graphqlApi.graphql(core_1.Amplify, options, additionalHeaders, apiUserAgentDetails);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
164
50
|
exports.InternalAPIClass = InternalAPIClass;
|
|
165
51
|
exports.InternalAPI = new InternalAPIClass(null);
|
|
166
|
-
core_1.Amplify.register(exports.InternalAPI);
|
|
167
52
|
//# sourceMappingURL=InternalAPI.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InternalAPI.js","sourceRoot":"","sources":["../../src/internals/InternalAPI.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"InternalAPI.js","sourceRoot":"","sources":["../../src/internals/InternalAPI.ts"],"names":[],"mappings":";;AAWA,kEAA6E;AAC7E,4CAAkE;AAClE,6DAI2C;AAG3C;;;;;;;GAOG;AAEH,MAAM,MAAM,GAAG,IAAI,oBAAa,CAAC,KAAK,CAAC,CAAC;AACxC;;;;GAIG;AACH,MAAa,gBAAgB;IAU5B;;;OAGG;IACH,YAAY,OAAO;QANnB,UAAK,GAAG,YAAK,CAAC;QAOb,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,WAAW,GAAG,IAAI,mCAAuB,CAAC,OAAO,CAAC,CAAC;QACxD,MAAM,CAAC,KAAK,CAAC,aAAa,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC5C,CAAC;IAEM,aAAa;QACnB,OAAO,aAAa,CAAC;IACtB,CAAC;IAED;;;OAGG;IACH,uBAAuB,CAAC,SAA2B;QAClD,OAAO,IAAI,CAAC,WAAW,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC;IAC5D,CAAC;IAqBD,OAAO,CACN,OAAuB,EACvB,iBAA6C,EAC7C,sBAA+C;QAE/C,MAAM,mBAAmB,GAA2B;YACnD,QAAQ,EAAE,gBAAQ,CAAC,GAAG;YACtB,MAAM,EAAE,iBAAS,CAAC,OAAO;YACzB,GAAG,sBAAsB;SACzB,CAAC;QAEF,OAAO,IAAI,CAAC,WAAW,CAAC,OAAO,CAC9B,cAAO,EACP,OAAO,EACP,iBAAiB,EACjB,mBAAmB,CACnB,CAAC;IACH,CAAC;CACD;AArED,4CAqEC;AAEY,QAAA,WAAW,GAAG,IAAI,gBAAgB,CAAC,IAAI,CAAC,CAAC"}
|
package/lib/server.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { GraphQLQuery, GraphQLSubscription } from './types';
|
|
2
|
+
import { V6Client, V6ClientSSR, ServerClientGenerationParams } from '@aws-amplify/api-graphql';
|
|
3
|
+
export type { GraphQLResult, GraphQLReturnType, } from '@aws-amplify/api-graphql';
|
|
4
|
+
/**
|
|
5
|
+
* @private
|
|
6
|
+
*
|
|
7
|
+
* Creates a client that can be used to make GraphQL requests, using a provided `AmplifyClassV6`
|
|
8
|
+
* compatible context object for config and auth fetching.
|
|
9
|
+
*
|
|
10
|
+
* @param params
|
|
11
|
+
* @returns
|
|
12
|
+
*/
|
|
13
|
+
export declare function generateClient<T extends Record<any, any> = never, ClientType extends V6ClientSSR<T> | V6Client<T> = V6ClientSSR<T>>(params: ServerClientGenerationParams): ClientType;
|
|
14
|
+
export { get, put, post, del, head, patch, isCancelError, } from '@aws-amplify/api-rest/server';
|
package/lib/server.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
const internals_1 = require("@aws-amplify/api-graphql/internals");
|
|
6
|
+
const api_graphql_1 = require("@aws-amplify/api-graphql");
|
|
7
|
+
/**
|
|
8
|
+
* @private
|
|
9
|
+
*
|
|
10
|
+
* Creates a client that can be used to make GraphQL requests, using a provided `AmplifyClassV6`
|
|
11
|
+
* compatible context object for config and auth fetching.
|
|
12
|
+
*
|
|
13
|
+
* @param params
|
|
14
|
+
* @returns
|
|
15
|
+
*/
|
|
16
|
+
function generateClient(params) {
|
|
17
|
+
const client = {
|
|
18
|
+
[api_graphql_1.__amplify]: params.amplify,
|
|
19
|
+
graphql: internals_1.graphql,
|
|
20
|
+
cancel: internals_1.cancel,
|
|
21
|
+
isCancelError: internals_1.isCancelError,
|
|
22
|
+
models: {},
|
|
23
|
+
};
|
|
24
|
+
return client;
|
|
25
|
+
}
|
|
26
|
+
exports.generateClient = generateClient;
|
|
27
|
+
var server_1 = require("@aws-amplify/api-rest/server");
|
|
28
|
+
exports.get = server_1.get;
|
|
29
|
+
exports.put = server_1.put;
|
|
30
|
+
exports.post = server_1.post;
|
|
31
|
+
exports.del = server_1.del;
|
|
32
|
+
exports.head = server_1.head;
|
|
33
|
+
exports.patch = server_1.patch;
|
|
34
|
+
exports.isCancelError = server_1.isCancelError;
|
|
35
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;;AAGtC,kEAI4C;AAM5C,0DAKkC;AAOlC;;;;;;;;GAQG;AACH,SAAgB,cAAc,CAG5B,MAAoC;IACrC,MAAM,MAAM,GAAG;QACd,CAAC,uBAAS,CAAC,EAAE,MAAM,CAAC,OAAO;QAC3B,OAAO,EAAP,mBAAO;QACP,MAAM,EAAN,kBAAM;QACN,aAAa,EAAb,yBAAa;QACb,MAAM,EAAE,EAAE;KACH,CAAC;IAET,OAAO,MAAoB,CAAC;AAC7B,CAAC;AAbD,wCAaC;AAED,uDAQsC;AAPrC,uBAAA,GAAG,CAAA;AACH,uBAAA,GAAG,CAAA;AACH,wBAAA,IAAI,CAAA;AACJ,uBAAA,GAAG,CAAA;AACH,wBAAA,IAAI,CAAA;AACJ,yBAAA,KAAK,CAAA;AACL,iCAAA,aAAa,CAAA"}
|
package/lib/types/index.d.ts
CHANGED
|
@@ -3,11 +3,4 @@
|
|
|
3
3
|
* generates code that relies on this import path https://github.com/aws-amplify/amplify-cli/issues/3863
|
|
4
4
|
* This will be removed in future release when CLI and customers moves to recommeneded import styles.
|
|
5
5
|
*/
|
|
6
|
-
export { graphqlOperation, GraphQLAuthError, GraphQLResult,
|
|
7
|
-
declare const queryType: unique symbol;
|
|
8
|
-
export declare type GraphQLQuery<T> = T & {
|
|
9
|
-
readonly [queryType]: 'query';
|
|
10
|
-
};
|
|
11
|
-
export declare type GraphQLSubscription<T> = T & {
|
|
12
|
-
readonly [queryType]: 'subscription';
|
|
13
|
-
};
|
|
6
|
+
export { graphqlOperation, GraphQLAuthError, GraphQLResult, GraphQLQuery, GraphQLSubscription, } from '@aws-amplify/api-graphql';
|
package/lib/types/index.js
CHANGED
|
@@ -10,5 +10,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
10
10
|
var api_graphql_1 = require("@aws-amplify/api-graphql");
|
|
11
11
|
exports.graphqlOperation = api_graphql_1.graphqlOperation;
|
|
12
12
|
exports.GraphQLAuthError = api_graphql_1.GraphQLAuthError;
|
|
13
|
-
exports.GRAPHQL_AUTH_MODE = api_graphql_1.GRAPHQL_AUTH_MODE;
|
|
14
13
|
//# sourceMappingURL=index.js.map
|
package/lib/types/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;;AAEtC;;;;GAIG;AACH,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;;AAEtC;;;;GAIG;AACH,wDAMkC;AALjC,yCAAA,gBAAgB,CAAA;AAChB,yCAAA,gBAAgB,CAAA"}
|
package/lib-esm/API.d.ts
CHANGED
|
@@ -1,27 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { GraphQLOptions, GraphQLResult } from '@aws-amplify/api-graphql';
|
|
3
|
-
import Observable from 'zen-observable-ts';
|
|
4
|
-
import { GraphQLQuery, GraphQLSubscription } from './types';
|
|
5
|
-
import { InternalAPIClass } from './internals/InternalAPI';
|
|
1
|
+
import { V6Client } from '@aws-amplify/api-graphql';
|
|
6
2
|
/**
|
|
7
|
-
*
|
|
8
|
-
* Use RestApi or GraphQLAPI to reduce your application bundle size
|
|
9
|
-
* Export Cloud Logic APIs
|
|
3
|
+
* Generates an API client that can work with models or raw GraphQL
|
|
10
4
|
*/
|
|
11
|
-
export declare
|
|
12
|
-
getModuleName(): string;
|
|
13
|
-
/**
|
|
14
|
-
* Executes a GraphQL operation
|
|
15
|
-
*
|
|
16
|
-
* @param options - GraphQL Options
|
|
17
|
-
* @param [additionalHeaders] - headers to merge in after any `graphql_headers` set in the config
|
|
18
|
-
* @returns An Observable if queryType is 'subscription', else a promise of the graphql result from the query.
|
|
19
|
-
*/
|
|
20
|
-
graphql<T>(options: GraphQLOptions, additionalHeaders?: {
|
|
21
|
-
[key: string]: string;
|
|
22
|
-
}): T extends GraphQLQuery<T> ? Promise<GraphQLResult<T>> : T extends GraphQLSubscription<T> ? Observable<{
|
|
23
|
-
provider: AWSAppSyncRealTimeProvider;
|
|
24
|
-
value: GraphQLResult<T>;
|
|
25
|
-
}> : Promise<GraphQLResult<any>> | Observable<object>;
|
|
26
|
-
}
|
|
27
|
-
export declare const API: APIClass;
|
|
5
|
+
export declare function generateClient<T extends Record<any, any> = never>(): V6Client<T>;
|
package/lib-esm/API.js
CHANGED
|
@@ -1,26 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { __amplify } from '@aws-amplify/api-graphql';
|
|
4
|
+
import { graphql as v6graphql, cancel as v6cancel, isCancelError as v6isCancelError, } from '@aws-amplify/api-graphql/internals';
|
|
5
|
+
import { Amplify } from '@aws-amplify/core';
|
|
5
6
|
/**
|
|
6
|
-
*
|
|
7
|
-
* Use RestApi or GraphQLAPI to reduce your application bundle size
|
|
8
|
-
* Export Cloud Logic APIs
|
|
7
|
+
* Generates an API client that can work with models or raw GraphQL
|
|
9
8
|
*/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return 'API';
|
|
9
|
+
export function generateClient() {
|
|
10
|
+
return {
|
|
11
|
+
[__amplify]: Amplify,
|
|
12
|
+
graphql: v6graphql,
|
|
13
|
+
cancel: v6cancel,
|
|
14
|
+
isCancelError: v6isCancelError,
|
|
17
15
|
};
|
|
18
|
-
|
|
19
|
-
return _super.prototype.graphql.call(this, options, additionalHeaders);
|
|
20
|
-
};
|
|
21
|
-
return APIClass;
|
|
22
|
-
}(InternalAPIClass));
|
|
23
|
-
export { APIClass };
|
|
24
|
-
export var API = new APIClass(null);
|
|
25
|
-
Amplify.register(API);
|
|
16
|
+
}
|
|
26
17
|
//# sourceMappingURL=API.js.map
|
package/lib-esm/API.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"API.js","sourceRoot":"","sources":["../src/API.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"API.js","sourceRoot":"","sources":["../src/API.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,SAAS,EAAY,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EACN,OAAO,IAAI,SAAS,EACpB,MAAM,IAAI,QAAQ,EAClB,aAAa,IAAI,eAAe,GAChC,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C;;GAEG;AACH,MAAM,UAAU,cAAc;IAG7B,OAAO;QACN,CAAC,SAAS,CAAC,EAAE,OAAO;QACpB,OAAO,EAAE,SAAS;QAClB,MAAM,EAAE,QAAQ;QAChB,aAAa,EAAE,eAAe;KAC9B,CAAC;AACH,CAAC"}
|
package/lib-esm/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { GraphQLQuery, GraphQLSubscription } from './types';
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export type { GraphQLResult } from '@aws-amplify/api-graphql';
|
|
2
|
+
export { generateClient } from './API';
|
|
3
|
+
export { GraphQLAuthError } from '@aws-amplify/api-graphql';
|
|
4
|
+
export type { GraphQLResult, GraphQLReturnType, } from '@aws-amplify/api-graphql';
|
|
5
|
+
export { get, put, post, del, head, patch, isCancelError, } from '@aws-amplify/api-rest';
|
package/lib-esm/index.js
CHANGED
|
@@ -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
|
-
export {
|
|
4
|
-
export {
|
|
3
|
+
export { generateClient } from './API';
|
|
4
|
+
export { GraphQLAuthError } from '@aws-amplify/api-graphql';
|
|
5
|
+
export { get, put, post, del, head, patch, isCancelError, } from '@aws-amplify/api-rest';
|
|
5
6
|
//# sourceMappingURL=index.js.map
|
package/lib-esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAKtC,OAAO,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAO5D,OAAO,EACN,GAAG,EACH,GAAG,EACH,IAAI,EACJ,GAAG,EACH,IAAI,EACJ,KAAK,EACL,aAAa,GACb,MAAM,uBAAuB,CAAC"}
|