@aws-amplify/api 5.4.6-api-v6-models.b3abc9b.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/.tsbuildinfo +3 -0
- package/lib/API.d.ts +3 -41
- package/lib/API.js +15 -131
- package/lib/API.js.map +1 -0
- package/lib/index.d.ts +4 -3
- package/lib/index.js +11 -6
- package/lib/index.js.map +1 -0
- package/lib/internals/InternalAPI.d.ts +4 -94
- package/lib/internals/InternalAPI.js +29 -144
- package/lib/internals/InternalAPI.js.map +1 -0
- package/lib/internals/index.js +3 -3
- package/lib/internals/index.js.map +1 -0
- 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 -2
- package/lib/types/index.js +3 -4
- package/lib/types/index.js.map +1 -0
- package/lib-esm/.tsbuildinfo +3 -0
- package/lib-esm/API.d.ts +3 -41
- package/lib-esm/API.js +14 -130
- package/lib-esm/API.js.map +1 -0
- package/lib-esm/index.d.ts +4 -3
- package/lib-esm/index.js +4 -2
- package/lib-esm/index.js.map +1 -0
- package/lib-esm/internals/InternalAPI.d.ts +4 -94
- package/lib-esm/internals/InternalAPI.js +28 -143
- package/lib-esm/internals/InternalAPI.js.map +1 -0
- package/lib-esm/internals/index.js +1 -0
- package/lib-esm/internals/index.js.map +1 -0
- 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 -2
- package/lib-esm/types/index.js +2 -1
- package/lib-esm/types/index.js.map +1 -0
- package/package.json +12 -32
- package/server/package.json +8 -0
- package/src/API.ts +16 -200
- package/src/index.ts +18 -6
- package/src/internals/InternalAPI.ts +15 -194
- package/src/server.ts +59 -0
- package/src/types/index.ts +0 -2
- package/index.v37.d.ts +0 -12
- package/lib/APIClient.d.ts +0 -55
- package/lib/APIClient.js +0 -404
- package/lib/tsconfig.build.tsbuildinfo +0 -1
- package/lib-esm/APIClient.d.ts +0 -55
- package/lib-esm/APIClient.js +0 -393
- package/lib-esm/tsconfig.build.tsbuildinfo +0 -1
- package/src/APIClient.ts +0 -534
package/lib/types/index.js
CHANGED
|
@@ -2,13 +2,12 @@
|
|
|
2
2
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.GRAPHQL_AUTH_MODE = exports.GraphQLAuthError = exports.graphqlOperation = void 0;
|
|
6
5
|
/**
|
|
7
6
|
* This exports from the types directory is a temporary workaround, since Amplify CLI currently
|
|
8
7
|
* generates code that relies on this import path https://github.com/aws-amplify/amplify-cli/issues/3863
|
|
9
8
|
* This will be removed in future release when CLI and customers moves to recommeneded import styles.
|
|
10
9
|
*/
|
|
11
10
|
var api_graphql_1 = require("@aws-amplify/api-graphql");
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
exports.graphqlOperation = api_graphql_1.graphqlOperation;
|
|
12
|
+
exports.GraphQLAuthError = api_graphql_1.GraphQLAuthError;
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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,43 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { GraphQLOptions, GraphQLResult, GraphQLQuery, GraphQLSubscription } from '@aws-amplify/api-graphql';
|
|
3
|
-
import { graphql as v6graphql } from '@aws-amplify/api-graphql/internals';
|
|
4
|
-
import Observable from 'zen-observable-ts';
|
|
5
|
-
import { InternalAPIClass } from './internals/InternalAPI';
|
|
6
|
-
import type { ModelTypes } from '@aws-amplify/amplify-api-next-types-alpha';
|
|
1
|
+
import { V6Client } from '@aws-amplify/api-graphql';
|
|
7
2
|
/**
|
|
8
|
-
*
|
|
9
|
-
* Use RestApi or GraphQLAPI to reduce your application bundle size
|
|
10
|
-
* Export Cloud Logic APIs
|
|
3
|
+
* Generates an API client that can work with models or raw GraphQL
|
|
11
4
|
*/
|
|
12
|
-
export declare
|
|
13
|
-
getModuleName(): string;
|
|
14
|
-
/**
|
|
15
|
-
* Executes a GraphQL operation
|
|
16
|
-
*
|
|
17
|
-
* @param options - GraphQL Options
|
|
18
|
-
* @param [additionalHeaders] - headers to merge in after any `graphql_headers` set in the config
|
|
19
|
-
* @returns An Observable if queryType is 'subscription', else a promise of the graphql result from the query.
|
|
20
|
-
*/
|
|
21
|
-
graphql<T>(options: GraphQLOptions, additionalHeaders?: {
|
|
22
|
-
[key: string]: string;
|
|
23
|
-
}): T extends GraphQLQuery<T> ? Promise<GraphQLResult<T>> : T extends GraphQLSubscription<T> ? Observable<{
|
|
24
|
-
provider: AWSAppSyncRealTimeProvider;
|
|
25
|
-
value: GraphQLResult<T>;
|
|
26
|
-
}> : Promise<GraphQLResult<any>> | Observable<object>;
|
|
27
|
-
/**
|
|
28
|
-
* Generates an API client that can work with models or raw GraphQL
|
|
29
|
-
*/
|
|
30
|
-
generateClient<T extends Record<any, any> = never>(): V6Client<T>;
|
|
31
|
-
}
|
|
32
|
-
type FilteredKeys<T> = {
|
|
33
|
-
[P in keyof T]: T[P] extends never ? never : P;
|
|
34
|
-
}[keyof T];
|
|
35
|
-
type ExcludeNeverFields<O> = {
|
|
36
|
-
[K in FilteredKeys<O>]: O[K];
|
|
37
|
-
};
|
|
38
|
-
declare type V6Client<T extends Record<any, any> = never> = ExcludeNeverFields<{
|
|
39
|
-
graphql: typeof v6graphql;
|
|
40
|
-
models: ModelTypes<T>;
|
|
41
|
-
}>;
|
|
42
|
-
export declare const API: APIClass;
|
|
43
|
-
export {};
|
|
5
|
+
export declare function generateClient<T extends Record<any, any> = never>(): V6Client<T>;
|
package/lib-esm/API.js
CHANGED
|
@@ -1,133 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
var logger = new Logger('API');
|
|
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';
|
|
7
6
|
/**
|
|
8
|
-
*
|
|
9
|
-
* Use RestApi or GraphQLAPI to reduce your application bundle size
|
|
10
|
-
* Export Cloud Logic APIs
|
|
7
|
+
* Generates an API client that can work with models or raw GraphQL
|
|
11
8
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return 'API';
|
|
9
|
+
export function generateClient() {
|
|
10
|
+
return {
|
|
11
|
+
[__amplify]: Amplify,
|
|
12
|
+
graphql: v6graphql,
|
|
13
|
+
cancel: v6cancel,
|
|
14
|
+
isCancelError: v6isCancelError,
|
|
19
15
|
};
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
};
|
|
23
|
-
/**
|
|
24
|
-
* Generates an API client that can work with models or raw GraphQL
|
|
25
|
-
*/
|
|
26
|
-
APIClass.prototype.generateClient = function () {
|
|
27
|
-
var e_1, _a;
|
|
28
|
-
var _this = this;
|
|
29
|
-
var config = _super.prototype.configure.call(this, {});
|
|
30
|
-
var modelIntrospection = config.modelIntrospection;
|
|
31
|
-
var client = {
|
|
32
|
-
graphql: v6graphql,
|
|
33
|
-
models: {},
|
|
34
|
-
};
|
|
35
|
-
var _loop_1 = function (model) {
|
|
36
|
-
var name_1 = model.name;
|
|
37
|
-
client.models[name_1] = {};
|
|
38
|
-
Object.entries(graphQLOperationsInfo).forEach(function (_a) {
|
|
39
|
-
var _b = __read(_a, 2), key = _b[0], operationPrefix = _b[1].operationPrefix;
|
|
40
|
-
var operation = key;
|
|
41
|
-
if (operation === 'LIST') {
|
|
42
|
-
client.models[name_1][operationPrefix] = function (args) { return __awaiter(_this, void 0, void 0, function () {
|
|
43
|
-
var query, variables, res, _a, key_1, flattenedResult, initialized;
|
|
44
|
-
return __generator(this, function (_b) {
|
|
45
|
-
switch (_b.label) {
|
|
46
|
-
case 0:
|
|
47
|
-
query = generateGraphQLDocument(modelIntrospection.models, name_1, 'LIST', args);
|
|
48
|
-
variables = buildGraphQLVariables(model, 'LIST', args, modelIntrospection);
|
|
49
|
-
console.log('API list', query, variables);
|
|
50
|
-
return [4 /*yield*/, this.graphql({
|
|
51
|
-
query: query,
|
|
52
|
-
variables: variables,
|
|
53
|
-
})];
|
|
54
|
-
case 1:
|
|
55
|
-
res = (_b.sent());
|
|
56
|
-
// flatten response
|
|
57
|
-
if (res.data !== undefined) {
|
|
58
|
-
_a = __read(Object.keys(res.data), 1), key_1 = _a[0];
|
|
59
|
-
if (res.data[key_1].items) {
|
|
60
|
-
flattenedResult = flattenItems(res.data)[key_1];
|
|
61
|
-
// don't init if custom selection set
|
|
62
|
-
if (args === null || args === void 0 ? void 0 : args.selectionSet) {
|
|
63
|
-
return [2 /*return*/, flattenedResult];
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
initialized = initializeModel(client, name_1, flattenedResult, modelIntrospection);
|
|
67
|
-
console.log('initialized', initialized);
|
|
68
|
-
return [2 /*return*/, initialized];
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
return [2 /*return*/, res.data[key_1]];
|
|
72
|
-
}
|
|
73
|
-
return [2 /*return*/, res];
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
}); };
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
client.models[name_1][operationPrefix] = function (arg, options) { return __awaiter(_this, void 0, void 0, function () {
|
|
80
|
-
var query, variables, res, _a, key_2, flattenedResult, _b, initialized;
|
|
81
|
-
return __generator(this, function (_c) {
|
|
82
|
-
switch (_c.label) {
|
|
83
|
-
case 0:
|
|
84
|
-
query = generateGraphQLDocument(modelIntrospection.models, name_1, operation, options);
|
|
85
|
-
variables = buildGraphQLVariables(model, operation, arg, modelIntrospection);
|
|
86
|
-
console.log("API ".concat(operationPrefix), query, variables);
|
|
87
|
-
return [4 /*yield*/, this.graphql({
|
|
88
|
-
query: query,
|
|
89
|
-
variables: variables,
|
|
90
|
-
})];
|
|
91
|
-
case 1:
|
|
92
|
-
res = (_c.sent());
|
|
93
|
-
// flatten response
|
|
94
|
-
if (res.data !== undefined) {
|
|
95
|
-
_a = __read(Object.keys(res.data), 1), key_2 = _a[0];
|
|
96
|
-
flattenedResult = flattenItems(res.data)[key_2];
|
|
97
|
-
if (options === null || options === void 0 ? void 0 : options.selectionSet) {
|
|
98
|
-
return [2 /*return*/, flattenedResult];
|
|
99
|
-
}
|
|
100
|
-
else {
|
|
101
|
-
_b = __read(initializeModel(client, name_1, [flattenedResult], modelIntrospection), 1), initialized = _b[0];
|
|
102
|
-
return [2 /*return*/, initialized];
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
return [2 /*return*/, res];
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
}); };
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
};
|
|
112
|
-
try {
|
|
113
|
-
// TODO: refactor this to use separate methods for each CRUDL.
|
|
114
|
-
// Doesn't make sense to gen the methods dynamically given the different args and return values
|
|
115
|
-
for (var _b = __values(Object.values(modelIntrospection.models)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
116
|
-
var model = _c.value;
|
|
117
|
-
_loop_1(model);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
121
|
-
finally {
|
|
122
|
-
try {
|
|
123
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
124
|
-
}
|
|
125
|
-
finally { if (e_1) throw e_1.error; }
|
|
126
|
-
}
|
|
127
|
-
return client;
|
|
128
|
-
};
|
|
129
|
-
return APIClass;
|
|
130
|
-
}(InternalAPIClass));
|
|
131
|
-
export { APIClass };
|
|
132
|
-
export var API = new APIClass(null);
|
|
133
|
-
Amplify.register(API);
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=API.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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,4 +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';
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { GraphQLOperation, GraphQLOptions, GraphQLResult, OperationTypeNode, GraphQLQuery, GraphQLSubscription } from '@aws-amplify/api-graphql';
|
|
2
|
-
import { CustomUserAgentDetails } from '@aws-amplify/core';
|
|
3
|
-
import {
|
|
4
|
-
import Observable from 'zen-observable-ts';
|
|
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';
|
|
5
4
|
/**
|
|
6
5
|
* @deprecated
|
|
7
6
|
* Use RestApi or GraphQLAPI to reduce your application bundle size
|
|
@@ -13,103 +12,14 @@ export declare class InternalAPIClass {
|
|
|
13
12
|
* @param {Object} options - Configuration object for API
|
|
14
13
|
*/
|
|
15
14
|
private _options;
|
|
16
|
-
private _restApi;
|
|
17
15
|
private _graphqlApi;
|
|
18
|
-
|
|
19
|
-
Cache: import("@aws-amplify/cache/lib-esm/types").ICache;
|
|
20
|
-
Credentials: import("@aws-amplify/core").CredentialsClass;
|
|
16
|
+
Cache: import("@aws-amplify/core/lib-esm/Cache/StorageCache").StorageCache;
|
|
21
17
|
/**
|
|
22
18
|
* Initialize API with AWS configuration
|
|
23
19
|
* @param {Object} options - Configuration object for API
|
|
24
20
|
*/
|
|
25
21
|
constructor(options: any);
|
|
26
22
|
getModuleName(): string;
|
|
27
|
-
/**
|
|
28
|
-
* Configure API part with aws configurations
|
|
29
|
-
* @param {Object} config - Configuration of the API
|
|
30
|
-
* @return {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
|
-
private getInitWithCustomUserAgentDetails;
|
|
107
|
-
/**
|
|
108
|
-
* Getting endpoint for API
|
|
109
|
-
* @param apiName - The name of the api
|
|
110
|
-
* @return The endpoint of the api
|
|
111
|
-
*/
|
|
112
|
-
endpoint(apiName: string): Promise<string>;
|
|
113
23
|
/**
|
|
114
24
|
* to get the operation type
|
|
115
25
|
* @param operation
|
|
@@ -1,164 +1,49 @@
|
|
|
1
|
-
import { __assign, __awaiter, __generator } from "tslib";
|
|
2
1
|
import { InternalGraphQLAPIClass } from '@aws-amplify/api-graphql/internals';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
import { Amplify, Cache, ConsoleLogger } from '@aws-amplify/core';
|
|
3
|
+
import { ApiAction, Category, } from '@aws-amplify/core/internals/utils';
|
|
4
|
+
/**
|
|
5
|
+
* NOTE!
|
|
6
|
+
*
|
|
7
|
+
* This is used only by DataStore.
|
|
8
|
+
*
|
|
9
|
+
* This can probably be pruned and/or removed. Just leaving it as much of the same
|
|
10
|
+
* state as possible for V6 to reduce number of potentially impactful changes to DataStore.
|
|
11
|
+
*/
|
|
12
|
+
const logger = new ConsoleLogger('API');
|
|
8
13
|
/**
|
|
9
14
|
* @deprecated
|
|
10
15
|
* Use RestApi or GraphQLAPI to reduce your application bundle size
|
|
11
16
|
* Export Cloud Logic APIs
|
|
12
17
|
*/
|
|
13
|
-
|
|
18
|
+
export class InternalAPIClass {
|
|
14
19
|
/**
|
|
15
20
|
* Initialize API with AWS configuration
|
|
16
21
|
* @param {Object} options - Configuration object for API
|
|
17
22
|
*/
|
|
18
|
-
|
|
19
|
-
this.Auth = Auth;
|
|
23
|
+
constructor(options) {
|
|
20
24
|
this.Cache = Cache;
|
|
21
|
-
this.Credentials = Credentials;
|
|
22
25
|
this._options = options;
|
|
23
|
-
this._restApi = new RestAPIClass(options);
|
|
24
26
|
this._graphqlApi = new InternalGraphQLAPIClass(options);
|
|
25
27
|
logger.debug('API Options', this._options);
|
|
26
28
|
}
|
|
27
|
-
|
|
29
|
+
getModuleName() {
|
|
28
30
|
return 'InternalAPI';
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Configure API part with aws configurations
|
|
32
|
-
* @param {Object} config - Configuration of the API
|
|
33
|
-
* @return {Object} - The current configuration
|
|
34
|
-
*/
|
|
35
|
-
InternalAPIClass.prototype.configure = function (options) {
|
|
36
|
-
this._options = Object.assign({}, this._options, options);
|
|
37
|
-
// Share Amplify instance with client for SSR
|
|
38
|
-
this._restApi.Credentials = this.Credentials;
|
|
39
|
-
this._graphqlApi.Auth = this.Auth;
|
|
40
|
-
this._graphqlApi.Cache = this.Cache;
|
|
41
|
-
this._graphqlApi.Credentials = this.Credentials;
|
|
42
|
-
var restAPIConfig = this._restApi.configure(this._options);
|
|
43
|
-
var graphQLAPIConfig = this._graphqlApi.configure(this._options);
|
|
44
|
-
return __assign(__assign({}, restAPIConfig), graphQLAPIConfig);
|
|
45
|
-
};
|
|
46
|
-
/**
|
|
47
|
-
* Make a GET request
|
|
48
|
-
* @param apiName - The api name of the request
|
|
49
|
-
* @param path - The path of the request
|
|
50
|
-
* @param [init] - Request extra params
|
|
51
|
-
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
52
|
-
*/
|
|
53
|
-
InternalAPIClass.prototype.get = function (apiName, path, init) {
|
|
54
|
-
return this._restApi.get(apiName, path, this.getInitWithCustomUserAgentDetails(init, ApiAction.Get));
|
|
55
|
-
};
|
|
56
|
-
/**
|
|
57
|
-
* Make a POST request
|
|
58
|
-
* @param apiName - The api name of the request
|
|
59
|
-
* @param path - The path of the request
|
|
60
|
-
* @param [init] - Request extra params
|
|
61
|
-
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
62
|
-
*/
|
|
63
|
-
InternalAPIClass.prototype.post = function (apiName, path, init) {
|
|
64
|
-
return this._restApi.post(apiName, path, this.getInitWithCustomUserAgentDetails(init, ApiAction.Post));
|
|
65
|
-
};
|
|
66
|
-
/**
|
|
67
|
-
* Make a PUT request
|
|
68
|
-
* @param apiName - The api name of the request
|
|
69
|
-
* @param path - The path of the request
|
|
70
|
-
* @param [init] - Request extra params
|
|
71
|
-
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
72
|
-
*/
|
|
73
|
-
InternalAPIClass.prototype.put = function (apiName, path, init) {
|
|
74
|
-
return this._restApi.put(apiName, path, this.getInitWithCustomUserAgentDetails(init, ApiAction.Put));
|
|
75
|
-
};
|
|
76
|
-
/**
|
|
77
|
-
* Make a PATCH request
|
|
78
|
-
* @param apiName - The api name of the request
|
|
79
|
-
* @param path - The path of the request
|
|
80
|
-
* @param [init] - Request extra params
|
|
81
|
-
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
82
|
-
*/
|
|
83
|
-
InternalAPIClass.prototype.patch = function (apiName, path, init) {
|
|
84
|
-
return this._restApi.patch(apiName, path, this.getInitWithCustomUserAgentDetails(init, ApiAction.Patch));
|
|
85
|
-
};
|
|
86
|
-
/**
|
|
87
|
-
* Make a DEL request
|
|
88
|
-
* @param apiName - The api name of the request
|
|
89
|
-
* @param path - The path of the request
|
|
90
|
-
* @param [init] - Request extra params
|
|
91
|
-
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
92
|
-
*/
|
|
93
|
-
InternalAPIClass.prototype.del = function (apiName, path, init) {
|
|
94
|
-
return this._restApi.del(apiName, path, this.getInitWithCustomUserAgentDetails(init, ApiAction.Del));
|
|
95
|
-
};
|
|
96
|
-
/**
|
|
97
|
-
* Make a HEAD request
|
|
98
|
-
* @param apiName - The api name of the request
|
|
99
|
-
* @param path - The path of the request
|
|
100
|
-
* @param [init] - Request extra params
|
|
101
|
-
* @return A promise that resolves to an object with response status and JSON data, if successful.
|
|
102
|
-
*/
|
|
103
|
-
InternalAPIClass.prototype.head = function (apiName, path, init) {
|
|
104
|
-
return this._restApi.head(apiName, path, this.getInitWithCustomUserAgentDetails(init, ApiAction.Head));
|
|
105
|
-
};
|
|
106
|
-
/**
|
|
107
|
-
* Checks to see if an error thrown is from an api request cancellation
|
|
108
|
-
* @param error - Any error
|
|
109
|
-
* @return If the error was from an api request cancellation
|
|
110
|
-
*/
|
|
111
|
-
InternalAPIClass.prototype.isCancel = function (error) {
|
|
112
|
-
return this._restApi.isCancel(error);
|
|
113
|
-
};
|
|
114
|
-
/**
|
|
115
|
-
* Cancels an inflight request for either a GraphQL request or a Rest API request.
|
|
116
|
-
* @param request - request to cancel
|
|
117
|
-
* @param [message] - custom error message
|
|
118
|
-
* @return If the request was cancelled
|
|
119
|
-
*/
|
|
120
|
-
InternalAPIClass.prototype.cancel = function (request, message) {
|
|
121
|
-
if (this._restApi.hasCancelToken(request)) {
|
|
122
|
-
return this._restApi.cancel(request, message);
|
|
123
|
-
}
|
|
124
|
-
else if (this._graphqlApi.hasCancelToken(request)) {
|
|
125
|
-
return this._graphqlApi.cancel(request, message);
|
|
126
|
-
}
|
|
127
|
-
return false;
|
|
128
|
-
};
|
|
129
|
-
InternalAPIClass.prototype.getInitWithCustomUserAgentDetails = function (init, action) {
|
|
130
|
-
var customUserAgentDetails = {
|
|
131
|
-
category: Category.API,
|
|
132
|
-
action: action,
|
|
133
|
-
};
|
|
134
|
-
var initParams = __assign(__assign({}, init), { customUserAgentDetails: customUserAgentDetails });
|
|
135
|
-
return initParams;
|
|
136
|
-
};
|
|
137
|
-
/**
|
|
138
|
-
* Getting endpoint for API
|
|
139
|
-
* @param apiName - The name of the api
|
|
140
|
-
* @return The endpoint of the api
|
|
141
|
-
*/
|
|
142
|
-
InternalAPIClass.prototype.endpoint = function (apiName) {
|
|
143
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
144
|
-
return __generator(this, function (_a) {
|
|
145
|
-
return [2 /*return*/, this._restApi.endpoint(apiName)];
|
|
146
|
-
});
|
|
147
|
-
});
|
|
148
|
-
};
|
|
31
|
+
}
|
|
149
32
|
/**
|
|
150
33
|
* to get the operation type
|
|
151
34
|
* @param operation
|
|
152
35
|
*/
|
|
153
|
-
|
|
36
|
+
getGraphqlOperationType(operation) {
|
|
154
37
|
return this._graphqlApi.getGraphqlOperationType(operation);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
38
|
+
}
|
|
39
|
+
graphql(options, additionalHeaders, customUserAgentDetails) {
|
|
40
|
+
const apiUserAgentDetails = {
|
|
41
|
+
category: Category.API,
|
|
42
|
+
action: ApiAction.GraphQl,
|
|
43
|
+
...customUserAgentDetails,
|
|
44
|
+
};
|
|
45
|
+
return this._graphqlApi.graphql(Amplify, options, additionalHeaders, apiUserAgentDetails);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
export const InternalAPI = new InternalAPIClass(null);
|
|
49
|
+
//# sourceMappingURL=InternalAPI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InternalAPI.js","sourceRoot":"","sources":["../../src/internals/InternalAPI.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EACN,SAAS,EACT,QAAQ,GAER,MAAM,mCAAmC,CAAC;AAG3C;;;;;;;GAOG;AAEH,MAAM,MAAM,GAAG,IAAI,aAAa,CAAC,KAAK,CAAC,CAAC;AACxC;;;;GAIG;AACH,MAAM,OAAO,gBAAgB;IAU5B;;;OAGG;IACH,YAAY,OAAO;QANnB,UAAK,GAAG,KAAK,CAAC;QAOb,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,WAAW,GAAG,IAAI,uBAAuB,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,QAAQ,CAAC,GAAG;YACtB,MAAM,EAAE,SAAS,CAAC,OAAO;YACzB,GAAG,sBAAsB;SACzB,CAAC;QAEF,OAAO,IAAI,CAAC,WAAW,CAAC,OAAO,CAC9B,OAAO,EACP,OAAO,EACP,iBAAiB,EACjB,mBAAmB,CACnB,CAAC;IACH,CAAC;CACD;AAED,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,gBAAgB,CAAC,IAAI,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/internals/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -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';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { graphql, cancel, isCancelError, } from '@aws-amplify/api-graphql/internals';
|
|
4
|
+
import { __amplify, } from '@aws-amplify/api-graphql';
|
|
5
|
+
/**
|
|
6
|
+
* @private
|
|
7
|
+
*
|
|
8
|
+
* Creates a client that can be used to make GraphQL requests, using a provided `AmplifyClassV6`
|
|
9
|
+
* compatible context object for config and auth fetching.
|
|
10
|
+
*
|
|
11
|
+
* @param params
|
|
12
|
+
* @returns
|
|
13
|
+
*/
|
|
14
|
+
export function generateClient(params) {
|
|
15
|
+
const client = {
|
|
16
|
+
[__amplify]: params.amplify,
|
|
17
|
+
graphql,
|
|
18
|
+
cancel,
|
|
19
|
+
isCancelError,
|
|
20
|
+
models: {},
|
|
21
|
+
};
|
|
22
|
+
return client;
|
|
23
|
+
}
|
|
24
|
+
export { get, put, post, del, head, patch, isCancelError, } from '@aws-amplify/api-rest/server';
|
|
25
|
+
//# 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,OAAO,EACN,OAAO,EACP,MAAM,EACN,aAAa,GACb,MAAM,oCAAoC,CAAC;AAM5C,OAAO,EACN,SAAS,GAIT,MAAM,0BAA0B,CAAC;AAOlC;;;;;;;;GAQG;AACH,MAAM,UAAU,cAAc,CAG5B,MAAoC;IACrC,MAAM,MAAM,GAAG;QACd,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC,OAAO;QAC3B,OAAO;QACP,MAAM;QACN,aAAa;QACb,MAAM,EAAE,EAAE;KACH,CAAC;IAET,OAAO,MAAoB,CAAC;AAC7B,CAAC;AAED,OAAO,EACN,GAAG,EACH,GAAG,EACH,IAAI,EACJ,GAAG,EACH,IAAI,EACJ,KAAK,EACL,aAAa,GACb,MAAM,8BAA8B,CAAC"}
|
package/lib-esm/types/index.d.ts
CHANGED
|
@@ -3,5 +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
|
-
export { SelectionSet } from '@aws-amplify/amplify-api-next-types-alpha';
|
|
6
|
+
export { graphqlOperation, GraphQLAuthError, GraphQLResult, GraphQLQuery, GraphQLSubscription, } from '@aws-amplify/api-graphql';
|
package/lib-esm/types/index.js
CHANGED
|
@@ -5,4 +5,5 @@
|
|
|
5
5
|
* generates code that relies on this import path https://github.com/aws-amplify/amplify-cli/issues/3863
|
|
6
6
|
* This will be removed in future release when CLI and customers moves to recommeneded import styles.
|
|
7
7
|
*/
|
|
8
|
-
export { graphqlOperation, GraphQLAuthError,
|
|
8
|
+
export { graphqlOperation, GraphQLAuthError, } from '@aws-amplify/api-graphql';
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC;;;;GAIG;AACH,OAAO,EACN,gBAAgB,EAChB,gBAAgB,GAIhB,MAAM,0BAA0B,CAAC"}
|