@aws-amplify/api-graphql 4.0.1-api-v6-models.9351bcf.0 → 4.0.1-api-v6-models.58f2536.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/internals/server/package.json +8 -0
- package/lib/GraphQLAPI.d.ts +1 -1
- package/lib/GraphQLAPI.js +23 -28
- package/lib/Providers/AWSAppSyncRealTimeProvider/index.js +467 -582
- package/lib/index.js +1 -1
- package/lib/internals/APIClient.d.ts +16 -1
- package/lib/internals/APIClient.js +232 -206
- package/lib/internals/InternalGraphQLAPI.d.ts +1 -1
- package/lib/internals/InternalGraphQLAPI.js +205 -247
- package/lib/internals/generateClient.js +14 -13
- package/lib/internals/generateModelsProperty.js +19 -312
- package/lib/internals/operations/get.d.ts +2 -0
- package/lib/internals/operations/get.js +59 -0
- package/lib/internals/operations/list.d.ts +2 -0
- package/lib/internals/operations/list.js +71 -0
- package/lib/internals/operations/observeQuery.d.ts +2 -0
- package/lib/internals/operations/observeQuery.js +119 -0
- package/lib/internals/operations/subscription.d.ts +1 -0
- package/lib/internals/operations/subscription.js +27 -0
- package/lib/internals/server/generateClient.d.ts +11 -0
- package/lib/internals/server/generateClient.js +30 -0
- package/lib/internals/server/generateModelsProperty.d.ts +3 -0
- package/lib/internals/server/generateModelsProperty.js +45 -0
- package/lib/internals/server/index.d.ts +1 -0
- package/lib/internals/server/index.js +7 -0
- package/lib/internals/v6.js +3 -3
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types/index.d.ts +36 -4
- package/lib/utils/ConnectionStateMonitor.js +51 -64
- package/lib/utils/ReachabilityMonitor/index.js +2 -2
- package/lib/utils/ReachabilityMonitor/index.native.js +4 -6
- package/lib/utils/ReconnectionMonitor.js +20 -24
- package/lib/utils/errors/APIError.js +7 -11
- package/lib/utils/errors/assertValidationError.js +4 -4
- package/lib/utils/errors/validation.js +5 -6
- package/lib/utils/findIndexByFields.js +4 -9
- package/lib/utils/resolveConfig.js +9 -10
- package/lib/utils/resolveLibraryOptions.js +4 -5
- package/lib/utils/resolveOwnerFields.js +10 -33
- package/lib/utils/resolvePKFields.js +2 -3
- package/lib-esm/GraphQLAPI.d.ts +1 -1
- package/lib-esm/GraphQLAPI.js +23 -29
- package/lib-esm/Providers/AWSAppSyncRealTimeProvider/index.js +459 -575
- package/lib-esm/Providers/constants.js +10 -10
- package/lib-esm/internals/APIClient.d.ts +16 -1
- package/lib-esm/internals/APIClient.js +230 -205
- package/lib-esm/internals/InternalGraphQLAPI.d.ts +1 -1
- package/lib-esm/internals/InternalGraphQLAPI.js +201 -244
- package/lib-esm/internals/generateClient.js +11 -10
- package/lib-esm/internals/generateModelsProperty.js +19 -312
- package/lib-esm/internals/operations/get.d.ts +2 -0
- package/lib-esm/internals/operations/get.js +55 -0
- package/lib-esm/internals/operations/list.d.ts +2 -0
- package/lib-esm/internals/operations/list.js +67 -0
- package/lib-esm/internals/operations/observeQuery.d.ts +2 -0
- package/lib-esm/internals/operations/observeQuery.js +115 -0
- package/lib-esm/internals/operations/subscription.d.ts +1 -0
- package/lib-esm/internals/operations/subscription.js +23 -0
- package/lib-esm/internals/server/generateClient.d.ts +11 -0
- package/lib-esm/internals/server/generateClient.js +26 -0
- package/lib-esm/internals/server/generateModelsProperty.d.ts +3 -0
- package/lib-esm/internals/server/generateModelsProperty.js +41 -0
- package/lib-esm/internals/server/index.d.ts +1 -0
- package/lib-esm/internals/server/index.js +3 -0
- package/lib-esm/internals/v6.js +1 -1
- package/lib-esm/tsconfig.tsbuildinfo +1 -1
- package/lib-esm/types/index.d.ts +36 -4
- package/lib-esm/types/index.js +3 -3
- package/lib-esm/utils/ConnectionStateMonitor.js +49 -63
- package/lib-esm/utils/ReachabilityMonitor/index.js +1 -1
- package/lib-esm/utils/ReachabilityMonitor/index.native.js +1 -3
- package/lib-esm/utils/ReconnectionMonitor.js +19 -24
- package/lib-esm/utils/errors/APIError.js +6 -11
- package/lib-esm/utils/errors/assertValidationError.js +2 -2
- package/lib-esm/utils/errors/validation.js +5 -6
- package/lib-esm/utils/findIndexByFields.js +4 -9
- package/lib-esm/utils/resolveConfig.js +8 -9
- package/lib-esm/utils/resolveLibraryOptions.js +4 -5
- package/lib-esm/utils/resolveOwnerFields.js +10 -33
- package/lib-esm/utils/resolvePKFields.js +2 -3
- package/package.json +8 -7
- package/src/GraphQLAPI.ts +6 -2
- package/src/Providers/AWSAppSyncRealTimeProvider/index.ts +6 -5
- package/src/internals/APIClient.ts +122 -35
- package/src/internals/InternalGraphQLAPI.ts +35 -10
- package/src/internals/generateClient.ts +0 -1
- package/src/internals/generateModelsProperty.ts +27 -340
- package/src/internals/operations/get.ts +121 -0
- package/src/internals/operations/list.ts +111 -0
- package/src/internals/operations/observeQuery.ts +140 -0
- package/src/internals/operations/subscription.ts +59 -0
- package/src/internals/server/generateClient.ts +45 -0
- package/src/internals/server/generateModelsProperty.ts +70 -0
- package/src/internals/server/index.ts +4 -0
- package/src/types/index.ts +65 -9
|
@@ -0,0 +1,30 @@
|
|
|
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
|
+
exports.generateClient = void 0;
|
|
6
|
+
const __1 = require("../");
|
|
7
|
+
const generateModelsProperty_1 = require("./generateModelsProperty");
|
|
8
|
+
const types_1 = require("../../types");
|
|
9
|
+
/**
|
|
10
|
+
* @private
|
|
11
|
+
*
|
|
12
|
+
* Creates a client that can be used to make GraphQL requests, using a provided `AmplifyClassV6`
|
|
13
|
+
* compatible context object for config and auth fetching.
|
|
14
|
+
*
|
|
15
|
+
* @param params
|
|
16
|
+
* @returns
|
|
17
|
+
*/
|
|
18
|
+
function generateClient(params) {
|
|
19
|
+
const client = {
|
|
20
|
+
[types_1.__amplify]: params.amplify,
|
|
21
|
+
[types_1.__authMode]: params.authMode,
|
|
22
|
+
[types_1.__authToken]: params.authToken,
|
|
23
|
+
graphql: __1.graphql,
|
|
24
|
+
cancel: __1.cancel,
|
|
25
|
+
isCancelError: __1.isCancelError,
|
|
26
|
+
};
|
|
27
|
+
client.models = (0, generateModelsProperty_1.generateModelsProperty)(client, params);
|
|
28
|
+
return client;
|
|
29
|
+
}
|
|
30
|
+
exports.generateClient = generateClient;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { ServerClientGenerationParams } from '../../types/';
|
|
2
|
+
import { V6ClientSSRRequest, V6ClientSSRCookies } from '../../types';
|
|
3
|
+
export declare function generateModelsProperty<T extends Record<any, any> = never, ClientType extends V6ClientSSRRequest<T> | V6ClientSSRCookies<T> = V6ClientSSRCookies<T>>(client: ClientType, params: ServerClientGenerationParams): ClientType;
|
|
@@ -0,0 +1,45 @@
|
|
|
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
|
+
exports.generateModelsProperty = void 0;
|
|
6
|
+
const APIClient_1 = require("../APIClient");
|
|
7
|
+
const list_1 = require("../operations/list");
|
|
8
|
+
const get_1 = require("../operations/get");
|
|
9
|
+
function generateModelsProperty(client, params) {
|
|
10
|
+
const models = {};
|
|
11
|
+
const config = params.config;
|
|
12
|
+
const useContext = client === null;
|
|
13
|
+
if (!config) {
|
|
14
|
+
// TODO: improve
|
|
15
|
+
throw new Error('generateModelsProperty cannot retrieve Amplify config');
|
|
16
|
+
}
|
|
17
|
+
const modelIntrospection = config.API?.GraphQL?.modelIntrospection;
|
|
18
|
+
if (!modelIntrospection) {
|
|
19
|
+
return {};
|
|
20
|
+
}
|
|
21
|
+
const SSR_UNSUPORTED_OPS = [
|
|
22
|
+
'ONCREATE',
|
|
23
|
+
'ONUPDATE',
|
|
24
|
+
'ONDELETE',
|
|
25
|
+
'OBSERVE_QUERY',
|
|
26
|
+
];
|
|
27
|
+
for (const model of Object.values(modelIntrospection.models)) {
|
|
28
|
+
const { name } = model;
|
|
29
|
+
models[name] = {};
|
|
30
|
+
Object.entries(APIClient_1.graphQLOperationsInfo).forEach(([key, { operationPrefix }]) => {
|
|
31
|
+
const operation = key;
|
|
32
|
+
// subscriptions are not supported in SSR
|
|
33
|
+
if (SSR_UNSUPORTED_OPS.includes(operation))
|
|
34
|
+
return;
|
|
35
|
+
if (operation === 'LIST') {
|
|
36
|
+
models[name][operationPrefix] = (0, list_1.listFactory)(client, modelIntrospection, model, useContext);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
models[name][operationPrefix] = (0, get_1.getFactory)(client, modelIntrospection, model, operation, useContext);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
return models;
|
|
44
|
+
}
|
|
45
|
+
exports.generateModelsProperty = generateModelsProperty;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { generateClient } from './generateClient';
|
|
@@ -0,0 +1,7 @@
|
|
|
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
|
+
exports.generateClient = void 0;
|
|
6
|
+
var generateClient_1 = require("./generateClient");
|
|
7
|
+
Object.defineProperty(exports, "generateClient", { enumerable: true, get: function () { return generateClient_1.generateClient; } });
|
package/lib/internals/v6.js
CHANGED
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.isCancelError = exports.cancel = exports.graphql = void 0;
|
|
4
4
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
5
5
|
// SPDX-License-Identifier: Apache-2.0
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
const GraphQLAPI_1 = require("../GraphQLAPI");
|
|
7
|
+
const types_1 = require("../types");
|
|
8
8
|
/**
|
|
9
9
|
* Invokes graphql operations against a graphql service, providing correct input and
|
|
10
10
|
* output types if Amplify-generated graphql from a recent version of the CLI/codegen
|
|
@@ -95,7 +95,7 @@ function graphql(options, additionalHeaders) {
|
|
|
95
95
|
* Neither of these can actually be validated at runtime. Hence, we don't perform
|
|
96
96
|
* any validation or type-guarding here.
|
|
97
97
|
*/
|
|
98
|
-
|
|
98
|
+
const result = GraphQLAPI_1.GraphQLAPI.graphql(this[types_1.__amplify], options, additionalHeaders);
|
|
99
99
|
return result;
|
|
100
100
|
}
|
|
101
101
|
exports.graphql = graphql;
|