@aws-amplify/api-graphql 4.0.19 → 4.0.20-api-graphql-eslint.dd94c10.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/dist/cjs/Providers/AWSAppSyncRealTimeProvider/index.js +40 -31
- package/dist/cjs/Providers/AWSAppSyncRealTimeProvider/index.js.map +1 -1
- package/dist/cjs/internals/APIClient.js +36 -20
- package/dist/cjs/internals/APIClient.js.map +1 -1
- package/dist/cjs/internals/InternalGraphQLAPI.js +10 -9
- package/dist/cjs/internals/InternalGraphQLAPI.js.map +1 -1
- package/dist/cjs/internals/generateClient.js +5 -5
- package/dist/cjs/internals/generateClient.js.map +1 -1
- package/dist/cjs/internals/operations/custom.js +4 -20
- package/dist/cjs/internals/operations/custom.js.map +1 -1
- package/dist/cjs/internals/operations/list.js +1 -1
- package/dist/cjs/internals/operations/list.js.map +1 -1
- package/dist/cjs/internals/server/generateClientWithAmplifyInstance.js +3 -3
- package/dist/cjs/internals/server/generateClientWithAmplifyInstance.js.map +1 -1
- package/dist/cjs/internals/server/generateModelsProperty.js +1 -1
- package/dist/cjs/internals/server/generateModelsProperty.js.map +1 -1
- package/dist/cjs/internals/utils/clientProperties/generateEnumsProperty.js.map +1 -0
- package/dist/cjs/internals/utils/{generateModelsProperty.js → clientProperties/generateModelsProperty.js} +7 -7
- package/dist/cjs/internals/utils/clientProperties/generateModelsProperty.js.map +1 -0
- package/dist/cjs/internals/utils/runtimeTypeGuards/isApiGraphQLProviderConfig.js.map +1 -0
- package/dist/cjs/internals/utils/runtimeTypeGuards/isConfigureEventWithResourceConfig.js.map +1 -0
- package/dist/cjs/internals/v6.js +0 -2
- package/dist/cjs/internals/v6.js.map +1 -1
- package/dist/cjs/utils/errors/repackageAuthError.js +1 -1
- package/dist/cjs/utils/errors/repackageAuthError.js.map +1 -1
- package/dist/esm/GraphQLAPI.d.ts +2 -2
- package/dist/esm/GraphQLAPI.mjs.map +1 -1
- package/dist/esm/Providers/AWSAppSyncRealTimeProvider/index.d.ts +8 -8
- package/dist/esm/Providers/AWSAppSyncRealTimeProvider/index.mjs +40 -31
- package/dist/esm/Providers/AWSAppSyncRealTimeProvider/index.mjs.map +1 -1
- package/dist/esm/internals/APIClient.d.ts +6 -5
- package/dist/esm/internals/APIClient.mjs +35 -20
- package/dist/esm/internals/APIClient.mjs.map +1 -1
- package/dist/esm/internals/InternalGraphQLAPI.d.ts +1 -1
- package/dist/esm/internals/InternalGraphQLAPI.mjs +10 -9
- package/dist/esm/internals/InternalGraphQLAPI.mjs.map +1 -1
- package/dist/esm/internals/generateClient.mjs +5 -5
- package/dist/esm/internals/generateClient.mjs.map +1 -1
- package/dist/esm/internals/generateCustomOperationsProperty.d.ts +2 -2
- package/dist/esm/internals/operations/custom.d.ts +1 -1
- package/dist/esm/internals/operations/custom.mjs +5 -21
- package/dist/esm/internals/operations/custom.mjs.map +1 -1
- package/dist/esm/internals/operations/get.d.ts +1 -1
- package/dist/esm/internals/operations/get.mjs.map +1 -1
- package/dist/esm/internals/operations/indexQuery.d.ts +3 -3
- package/dist/esm/internals/operations/indexQuery.mjs.map +1 -1
- package/dist/esm/internals/operations/list.d.ts +1 -1
- package/dist/esm/internals/operations/list.mjs +1 -1
- package/dist/esm/internals/operations/list.mjs.map +1 -1
- package/dist/esm/internals/operations/subscription.d.ts +1 -1
- package/dist/esm/internals/operations/subscription.mjs.map +1 -1
- package/dist/esm/internals/server/generateClientWithAmplifyInstance.d.ts +1 -1
- package/dist/esm/internals/server/generateClientWithAmplifyInstance.mjs +3 -3
- package/dist/esm/internals/server/generateClientWithAmplifyInstance.mjs.map +1 -1
- package/dist/esm/internals/server/generateModelsProperty.d.ts +1 -2
- package/dist/esm/internals/server/generateModelsProperty.mjs +1 -1
- package/dist/esm/internals/server/generateModelsProperty.mjs.map +1 -1
- package/dist/esm/internals/types.d.ts +2 -2
- package/dist/esm/internals/utils/clientProperties/generateEnumsProperty.mjs.map +1 -0
- package/dist/esm/internals/utils/{generateModelsProperty.d.ts → clientProperties/generateModelsProperty.d.ts} +1 -1
- package/dist/esm/internals/utils/{generateModelsProperty.mjs → clientProperties/generateModelsProperty.mjs} +7 -7
- package/dist/esm/internals/utils/clientProperties/generateModelsProperty.mjs.map +1 -0
- package/dist/esm/internals/utils/runtimeTypeGuards/isApiGraphQLProviderConfig.mjs.map +1 -0
- package/dist/esm/internals/utils/runtimeTypeGuards/isConfigureEventWithResourceConfig.mjs.map +1 -0
- package/dist/esm/internals/v6.d.ts +1 -1
- package/dist/esm/internals/v6.mjs +0 -2
- package/dist/esm/internals/v6.mjs.map +1 -1
- package/dist/esm/types/index.d.ts +33 -35
- package/dist/esm/utils/ConnectionStateMonitor.d.ts +2 -2
- package/dist/esm/utils/ConnectionStateMonitor.mjs.map +1 -1
- package/dist/esm/utils/ReachabilityMonitor/index.native.mjs.map +1 -1
- package/dist/esm/utils/errors/repackageAuthError.d.ts +2 -2
- package/dist/esm/utils/errors/repackageAuthError.mjs +1 -1
- package/dist/esm/utils/errors/repackageAuthError.mjs.map +1 -1
- package/dist/esm/utils/findIndexByFields.d.ts +1 -1
- package/package.json +8 -7
- package/src/GraphQLAPI.ts +4 -3
- package/src/Providers/AWSAppSyncRealTimeProvider/index.ts +84 -64
- package/src/internals/APIClient.ts +60 -28
- package/src/internals/InternalGraphQLAPI.ts +26 -30
- package/src/internals/clientUtils.ts +1 -1
- package/src/internals/generateClient.ts +13 -11
- package/src/internals/generateCustomOperationsProperty.ts +7 -6
- package/src/internals/operations/custom.ts +21 -35
- package/src/internals/operations/get.ts +9 -8
- package/src/internals/operations/indexQuery.ts +12 -11
- package/src/internals/operations/list.ts +11 -15
- package/src/internals/operations/observeQuery.ts +3 -1
- package/src/internals/operations/subscription.ts +12 -10
- package/src/internals/server/generateClientWithAmplifyInstance.ts +9 -9
- package/src/internals/server/generateModelsProperty.ts +7 -4
- package/src/internals/types.ts +2 -2
- package/src/internals/utils/{generateEnumsProperty.ts → clientProperties/generateEnumsProperty.ts} +7 -6
- package/src/internals/utils/{generateModelsProperty.ts → clientProperties/generateModelsProperty.ts} +10 -9
- package/src/internals/v6.ts +6 -4
- package/src/server/generateClient.ts +4 -1
- package/src/types/PubSub.ts +1 -0
- package/src/types/index.ts +51 -47
- package/src/utils/ConnectionStateMonitor.ts +8 -3
- package/src/utils/ReachabilityMonitor/index.native.ts +1 -1
- package/src/utils/ReachabilityMonitor/index.ts +1 -0
- package/src/utils/ReconnectionMonitor.ts +1 -0
- package/src/utils/errors/repackageAuthError.ts +6 -7
- package/src/utils/findIndexByFields.ts +1 -1
- package/src/utils/resolveConfig.ts +1 -0
- package/src/utils/resolveLibraryOptions.ts +1 -0
- package/src/utils/resolveOwnerFields.ts +7 -5
- package/src/utils/resolvePKFields.ts +1 -0
- package/dist/cjs/internals/utils/generateEnumsProperty.js.map +0 -1
- package/dist/cjs/internals/utils/generateModelsProperty.js.map +0 -1
- package/dist/cjs/internals/utils/isApiGraphQLProviderConfig.js.map +0 -1
- package/dist/cjs/internals/utils/isConfigureEventWithResourceConfig.js.map +0 -1
- package/dist/esm/internals/utils/generateEnumsProperty.mjs.map +0 -1
- package/dist/esm/internals/utils/generateModelsProperty.mjs.map +0 -1
- package/dist/esm/internals/utils/isApiGraphQLProviderConfig.mjs.map +0 -1
- package/dist/esm/internals/utils/isConfigureEventWithResourceConfig.mjs.map +0 -1
- /package/dist/cjs/internals/utils/{generateEnumsProperty.js → clientProperties/generateEnumsProperty.js} +0 -0
- /package/dist/cjs/internals/utils/{isApiGraphQLProviderConfig.js → runtimeTypeGuards/isApiGraphQLProviderConfig.js} +0 -0
- /package/dist/cjs/internals/utils/{isConfigureEventWithResourceConfig.js → runtimeTypeGuards/isConfigureEventWithResourceConfig.js} +0 -0
- /package/dist/esm/internals/utils/{generateEnumsProperty.d.ts → clientProperties/generateEnumsProperty.d.ts} +0 -0
- /package/dist/esm/internals/utils/{generateEnumsProperty.mjs → clientProperties/generateEnumsProperty.mjs} +0 -0
- /package/dist/esm/internals/utils/{isApiGraphQLProviderConfig.d.ts → runtimeTypeGuards/isApiGraphQLProviderConfig.d.ts} +0 -0
- /package/dist/esm/internals/utils/{isApiGraphQLProviderConfig.mjs → runtimeTypeGuards/isApiGraphQLProviderConfig.mjs} +0 -0
- /package/dist/esm/internals/utils/{isConfigureEventWithResourceConfig.d.ts → runtimeTypeGuards/isConfigureEventWithResourceConfig.d.ts} +0 -0
- /package/dist/esm/internals/utils/{isConfigureEventWithResourceConfig.mjs → runtimeTypeGuards/isConfigureEventWithResourceConfig.mjs} +0 -0
- /package/src/internals/utils/{isApiGraphQLProviderConfig.ts → runtimeTypeGuards/isApiGraphQLProviderConfig.ts} +0 -0
- /package/src/internals/utils/{isConfigureEventWithResourceConfig.ts → runtimeTypeGuards/isConfigureEventWithResourceConfig.ts} +0 -0
|
@@ -2,31 +2,32 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
import { AmplifyServer } from '@aws-amplify/core/internals/adapter-core';
|
|
4
4
|
import {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
ModelIntrospectionSchema,
|
|
6
|
+
SchemaModel,
|
|
7
|
+
} from '@aws-amplify/core/internals/utils';
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
authModeParams,
|
|
7
11
|
buildGraphQLVariables,
|
|
8
12
|
flattenItems,
|
|
9
|
-
|
|
13
|
+
generateGraphQLDocument,
|
|
10
14
|
getCustomHeaders,
|
|
15
|
+
initializeModel,
|
|
11
16
|
} from '../APIClient';
|
|
12
17
|
import {
|
|
13
18
|
AuthModeParams,
|
|
14
19
|
ClientWithModels,
|
|
15
|
-
ListArgs,
|
|
16
|
-
V6ClientSSRRequest,
|
|
17
20
|
GraphQLResult,
|
|
21
|
+
ListArgs,
|
|
18
22
|
QueryArgs,
|
|
23
|
+
V6ClientSSRRequest,
|
|
19
24
|
} from '../../types';
|
|
20
|
-
import {
|
|
21
|
-
ModelIntrospectionSchema,
|
|
22
|
-
SchemaModel,
|
|
23
|
-
} from '@aws-amplify/core/internals/utils';
|
|
24
25
|
|
|
25
|
-
export
|
|
26
|
+
export interface IndexMeta {
|
|
26
27
|
queryField: string;
|
|
27
28
|
pk: string;
|
|
28
29
|
sk?: string[];
|
|
29
|
-
}
|
|
30
|
+
}
|
|
30
31
|
|
|
31
32
|
export function indexQueryFactory(
|
|
32
33
|
client: ClientWithModels,
|
|
@@ -2,25 +2,26 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
import { AmplifyServer } from '@aws-amplify/core/internals/adapter-core';
|
|
4
4
|
import {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
ModelIntrospectionSchema,
|
|
6
|
+
SchemaModel,
|
|
7
|
+
} from '@aws-amplify/core/internals/utils';
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
authModeParams,
|
|
7
11
|
buildGraphQLVariables,
|
|
8
12
|
flattenItems,
|
|
9
|
-
|
|
13
|
+
generateGraphQLDocument,
|
|
10
14
|
getCustomHeaders,
|
|
15
|
+
initializeModel,
|
|
11
16
|
} from '../APIClient';
|
|
12
17
|
import {
|
|
13
18
|
AuthModeParams,
|
|
14
19
|
ClientWithModels,
|
|
20
|
+
GraphQLResult,
|
|
15
21
|
ListArgs,
|
|
16
22
|
V6Client,
|
|
17
23
|
V6ClientSSRRequest,
|
|
18
|
-
GraphQLResult,
|
|
19
24
|
} from '../../types';
|
|
20
|
-
import {
|
|
21
|
-
ModelIntrospectionSchema,
|
|
22
|
-
SchemaModel,
|
|
23
|
-
} from '@aws-amplify/core/internals/utils';
|
|
24
25
|
|
|
25
26
|
export function listFactory(
|
|
26
27
|
client: ClientWithModels,
|
|
@@ -51,12 +52,7 @@ async function _list(
|
|
|
51
52
|
) {
|
|
52
53
|
const { name } = model;
|
|
53
54
|
|
|
54
|
-
const query = generateGraphQLDocument(
|
|
55
|
-
modelIntrospection,
|
|
56
|
-
name,
|
|
57
|
-
'LIST',
|
|
58
|
-
args,
|
|
59
|
-
);
|
|
55
|
+
const query = generateGraphQLDocument(modelIntrospection, name, 'LIST', args);
|
|
60
56
|
const variables = buildGraphQLVariables(
|
|
61
57
|
model,
|
|
62
58
|
'LIST',
|
|
@@ -69,7 +65,7 @@ async function _list(
|
|
|
69
65
|
|
|
70
66
|
const headers = getCustomHeaders(client, args?.headers);
|
|
71
67
|
|
|
72
|
-
const { data, extensions } =
|
|
68
|
+
const { data, extensions } = contextSpec
|
|
73
69
|
? ((await (client as V6ClientSSRRequest<Record<string, any>>).graphql(
|
|
74
70
|
contextSpec,
|
|
75
71
|
{
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
import { Observable } from 'rxjs';
|
|
4
|
-
import { findIndexByFields, resolvePKFields } from '../../utils';
|
|
5
4
|
import { SchemaModel } from '@aws-amplify/core/internals/utils';
|
|
6
5
|
|
|
6
|
+
import { findIndexByFields, resolvePKFields } from '../../utils';
|
|
7
|
+
|
|
7
8
|
export function observeQueryFactory(models: any, model: SchemaModel) {
|
|
8
9
|
const { name } = model;
|
|
9
10
|
|
|
@@ -124,6 +125,7 @@ export function observeQueryFactory(models: any, model: SchemaModel) {
|
|
|
124
125
|
// switch the queue to write directly to the items collection
|
|
125
126
|
receiveMessages = (...messages: typeof messageQueue) => {
|
|
126
127
|
ingestMessages(messages);
|
|
128
|
+
|
|
127
129
|
return items.length;
|
|
128
130
|
};
|
|
129
131
|
})();
|
|
@@ -2,20 +2,21 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import { map } from 'rxjs';
|
|
5
|
-
import { V6Client, GraphqlSubscriptionResult } from '../../types';
|
|
6
|
-
import {
|
|
7
|
-
initializeModel,
|
|
8
|
-
generateGraphQLDocument,
|
|
9
|
-
buildGraphQLVariables,
|
|
10
|
-
authModeParams,
|
|
11
|
-
ModelOperation,
|
|
12
|
-
getCustomHeaders,
|
|
13
|
-
} from '../APIClient';
|
|
14
5
|
import {
|
|
15
6
|
ModelIntrospectionSchema,
|
|
16
7
|
SchemaModel,
|
|
17
8
|
} from '@aws-amplify/core/internals/utils';
|
|
18
9
|
|
|
10
|
+
import { GraphqlSubscriptionResult, V6Client } from '../../types';
|
|
11
|
+
import {
|
|
12
|
+
ModelOperation,
|
|
13
|
+
authModeParams,
|
|
14
|
+
buildGraphQLVariables,
|
|
15
|
+
generateGraphQLDocument,
|
|
16
|
+
getCustomHeaders,
|
|
17
|
+
initializeModel,
|
|
18
|
+
} from '../APIClient';
|
|
19
|
+
|
|
19
20
|
export function subscriptionFactory(
|
|
20
21
|
client: any,
|
|
21
22
|
modelIntrospection: ModelIntrospectionSchema,
|
|
@@ -29,7 +30,7 @@ export function subscriptionFactory(
|
|
|
29
30
|
modelIntrospection,
|
|
30
31
|
name,
|
|
31
32
|
operation,
|
|
32
|
-
args
|
|
33
|
+
args,
|
|
33
34
|
);
|
|
34
35
|
|
|
35
36
|
const variables = buildGraphQLVariables(
|
|
@@ -64,6 +65,7 @@ export function subscriptionFactory(
|
|
|
64
65
|
auth.authMode,
|
|
65
66
|
auth.authToken,
|
|
66
67
|
);
|
|
68
|
+
|
|
67
69
|
return initialized;
|
|
68
70
|
}),
|
|
69
71
|
);
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
import { generateModelsProperty } from './generateModelsProperty';
|
|
6
|
-
import { Hub } from '@aws-amplify/core';
|
|
4
|
+
import { cancel, graphql, isCancelError } from '..';
|
|
7
5
|
import {
|
|
6
|
+
CommonPublicClientOptions,
|
|
7
|
+
ServerClientGenerationParams,
|
|
8
|
+
V6ClientSSRCookies,
|
|
9
|
+
V6ClientSSRRequest,
|
|
8
10
|
__amplify,
|
|
9
11
|
__authMode,
|
|
10
12
|
__authToken,
|
|
11
13
|
__headers,
|
|
12
|
-
V6ClientSSRRequest,
|
|
13
|
-
V6ClientSSRCookies,
|
|
14
|
-
ServerClientGenerationParams,
|
|
15
|
-
CommonPublicClientOptions,
|
|
16
14
|
} from '../../types';
|
|
17
|
-
import { isApiGraphQLConfig } from '../utils/isApiGraphQLProviderConfig';
|
|
18
|
-
import { generateEnumsProperty } from '../utils/generateEnumsProperty';
|
|
15
|
+
import { isApiGraphQLConfig } from '../utils/runtimeTypeGuards/isApiGraphQLProviderConfig';
|
|
16
|
+
import { generateEnumsProperty } from '../utils/clientProperties/generateEnumsProperty';
|
|
19
17
|
import {
|
|
20
18
|
generateCustomMutationsProperty,
|
|
21
19
|
generateCustomQueriesProperty,
|
|
22
20
|
} from '../generateCustomOperationsProperty';
|
|
23
21
|
|
|
22
|
+
import { generateModelsProperty } from './generateModelsProperty';
|
|
23
|
+
|
|
24
24
|
/**
|
|
25
25
|
* @private
|
|
26
26
|
*
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
import { ModelTypes } from '@aws-amplify/data-schema-types';
|
|
4
|
-
import { graphQLOperationsInfo, ModelOperation } from '../APIClient';
|
|
5
|
-
import { ServerClientGenerationParams } from '../../types/';
|
|
6
|
-
import { V6ClientSSRRequest, V6ClientSSRCookies } from '../../types';
|
|
7
4
|
import { ModelIntrospectionSchema } from '@aws-amplify/core/internals/utils';
|
|
8
5
|
|
|
6
|
+
import { ModelOperation, graphQLOperationsInfo } from '../APIClient';
|
|
7
|
+
import {
|
|
8
|
+
ServerClientGenerationParams,
|
|
9
|
+
V6ClientSSRCookies,
|
|
10
|
+
V6ClientSSRRequest,
|
|
11
|
+
} from '../../types/';
|
|
9
12
|
import { listFactory } from '../operations/list';
|
|
10
13
|
import { indexQueryFactory } from '../operations/indexQuery';
|
|
11
14
|
import { getFactory } from '../operations/get';
|
|
@@ -20,7 +23,7 @@ export function generateModelsProperty<
|
|
|
20
23
|
>,
|
|
21
24
|
>(client: ClientType, params: ServerClientGenerationParams): ClientType {
|
|
22
25
|
const models = {} as any;
|
|
23
|
-
const config = params
|
|
26
|
+
const { config } = params;
|
|
24
27
|
const useContext = params.amplify === null;
|
|
25
28
|
|
|
26
29
|
if (!config) {
|
package/src/internals/types.ts
CHANGED
|
@@ -16,8 +16,8 @@ export type ClientGenerationParams = {
|
|
|
16
16
|
/**
|
|
17
17
|
* Common options that can be used on public `generateClient()` interfaces.
|
|
18
18
|
*/
|
|
19
|
-
export
|
|
19
|
+
export interface CommonPublicClientOptions {
|
|
20
20
|
authMode?: GraphQLAuthMode;
|
|
21
21
|
authToken?: string;
|
|
22
22
|
headers?: CustomHeaders;
|
|
23
|
-
}
|
|
23
|
+
}
|
package/src/internals/utils/{generateEnumsProperty.ts → clientProperties/generateEnumsProperty.ts}
RENAMED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
|
-
ModelIntrospectionSchema,
|
|
6
5
|
GraphQLProviderConfig,
|
|
6
|
+
ModelIntrospectionSchema,
|
|
7
7
|
} from '@aws-amplify/core/internals/utils';
|
|
8
8
|
import { EnumTypes } from '@aws-amplify/data-schema-types';
|
|
9
9
|
|
|
@@ -17,11 +17,12 @@ export const generateEnumsProperty = <T extends Record<any, any> = never>(
|
|
|
17
17
|
return {} as EnumTypes<never>;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
const enums:
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
const enums: Record<
|
|
21
|
+
string,
|
|
22
|
+
{
|
|
23
|
+
values(): string[];
|
|
24
|
+
}
|
|
25
|
+
> = {};
|
|
25
26
|
|
|
26
27
|
for (const [_, enumData] of Object.entries(modelIntrospection.enums)) {
|
|
27
28
|
enums[enumData.name] = {
|
package/src/internals/utils/{generateModelsProperty.ts → clientProperties/generateModelsProperty.ts}
RENAMED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
import { ModelTypes } from '@aws-amplify/data-schema-types';
|
|
4
|
-
import { graphQLOperationsInfo, ModelOperation } from '../APIClient';
|
|
5
|
-
import { V6Client, __authMode, __authToken } from '../../types';
|
|
6
|
-
import { listFactory } from '../operations/list';
|
|
7
|
-
import { indexQueryFactory } from '../operations/indexQuery';
|
|
8
|
-
import { getFactory } from '../operations/get';
|
|
9
|
-
import { subscriptionFactory } from '../operations/subscription';
|
|
10
|
-
import { observeQueryFactory } from '../operations/observeQuery';
|
|
11
4
|
import {
|
|
12
|
-
ModelIntrospectionSchema,
|
|
13
5
|
GraphQLProviderConfig,
|
|
6
|
+
ModelIntrospectionSchema,
|
|
14
7
|
} from '@aws-amplify/core/internals/utils';
|
|
15
|
-
|
|
8
|
+
|
|
9
|
+
import { ModelOperation, graphQLOperationsInfo } from '../../APIClient';
|
|
10
|
+
import { V6Client } from '../../../types';
|
|
11
|
+
import { listFactory } from '../../operations/list';
|
|
12
|
+
import { indexQueryFactory } from '../../operations/indexQuery';
|
|
13
|
+
import { getFactory } from '../../operations/get';
|
|
14
|
+
import { subscriptionFactory } from '../../operations/subscription';
|
|
15
|
+
import { observeQueryFactory } from '../../operations/observeQuery';
|
|
16
|
+
import { getSecondaryIndexesFromSchemaModel } from '../../clientUtils';
|
|
16
17
|
|
|
17
18
|
export function generateModelsProperty<T extends Record<any, any> = never>(
|
|
18
19
|
client: V6Client<Record<string, any>>,
|
package/src/internals/v6.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { CustomHeaders } from '@aws-amplify/data-schema-types';
|
|
4
|
+
|
|
3
5
|
import { GraphQLAPI } from '../GraphQLAPI';
|
|
4
6
|
import {
|
|
7
|
+
GraphQLOptionsV6,
|
|
8
|
+
GraphQLResponseV6,
|
|
9
|
+
V6Client,
|
|
5
10
|
__amplify,
|
|
6
11
|
__authMode,
|
|
7
12
|
__authToken,
|
|
8
|
-
V6Client,
|
|
9
|
-
GraphQLOptionsV6,
|
|
10
|
-
GraphQLResponseV6,
|
|
11
13
|
} from '../types';
|
|
12
|
-
import { CustomHeaders } from '@aws-amplify/data-schema-types';
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* Invokes graphql operations against a graphql service, providing correct input and
|
|
@@ -117,6 +118,7 @@ export function graphql<
|
|
|
117
118
|
options,
|
|
118
119
|
additionalHeaders,
|
|
119
120
|
);
|
|
121
|
+
|
|
120
122
|
return result as any;
|
|
121
123
|
}
|
|
122
124
|
|
|
@@ -5,6 +5,8 @@ import {
|
|
|
5
5
|
AmplifyServer,
|
|
6
6
|
getAmplifyServerContext,
|
|
7
7
|
} from '@aws-amplify/core/internals/adapter-core';
|
|
8
|
+
import { CustomHeaders } from '@aws-amplify/data-schema-types';
|
|
9
|
+
|
|
8
10
|
import { generateClientWithAmplifyInstance } from '../internals/server';
|
|
9
11
|
import {
|
|
10
12
|
GenerateServerClientParams,
|
|
@@ -14,7 +16,6 @@ import {
|
|
|
14
16
|
V6ClientSSRRequest,
|
|
15
17
|
__amplify,
|
|
16
18
|
} from '../types';
|
|
17
|
-
import { CustomHeaders } from '@aws-amplify/data-schema-types';
|
|
18
19
|
|
|
19
20
|
/**
|
|
20
21
|
* Generates an GraphQL API client that works with Amplify server context.
|
|
@@ -55,6 +56,7 @@ export function generateClient<T extends Record<any, any> = never>({
|
|
|
55
56
|
additionalHeaders?: CustomHeaders,
|
|
56
57
|
) => {
|
|
57
58
|
const amplifyInstance = getAmplifyServerContext(contextSpec).amplify;
|
|
59
|
+
|
|
58
60
|
return prevGraphql.call(
|
|
59
61
|
{ [__amplify]: amplifyInstance },
|
|
60
62
|
options,
|
|
@@ -63,5 +65,6 @@ export function generateClient<T extends Record<any, any> = never>({
|
|
|
63
65
|
};
|
|
64
66
|
|
|
65
67
|
client.graphql = wrappedGraphql as unknown as GraphQLMethodSSR;
|
|
68
|
+
|
|
66
69
|
return client;
|
|
67
70
|
}
|
package/src/types/PubSub.ts
CHANGED
package/src/types/index.ts
CHANGED
|
@@ -2,22 +2,22 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
import { AmplifyClassV6, ResourcesConfig } from '@aws-amplify/core';
|
|
4
4
|
import {
|
|
5
|
-
EnumTypes,
|
|
6
|
-
ModelTypes,
|
|
7
5
|
CustomHeaders,
|
|
8
|
-
CustomQueries,
|
|
9
6
|
CustomMutations,
|
|
7
|
+
CustomQueries,
|
|
8
|
+
EnumTypes,
|
|
9
|
+
ModelTypes,
|
|
10
10
|
} from '@aws-amplify/data-schema-types';
|
|
11
|
-
import {
|
|
12
|
-
export { OperationTypeNode } from 'graphql';
|
|
11
|
+
import { DocumentNode, GraphQLError, Source } from 'graphql';
|
|
13
12
|
import { Observable } from 'rxjs';
|
|
14
|
-
|
|
15
13
|
import {
|
|
16
|
-
GraphQLAuthMode,
|
|
17
14
|
DocumentType,
|
|
15
|
+
GraphQLAuthMode,
|
|
18
16
|
} from '@aws-amplify/core/internals/utils';
|
|
19
17
|
import { AmplifyServer } from '@aws-amplify/core/internals/adapter-core';
|
|
20
18
|
|
|
19
|
+
export { OperationTypeNode } from 'graphql';
|
|
20
|
+
|
|
21
21
|
export { CONTROL_MSG, ConnectionState } from './PubSub';
|
|
22
22
|
|
|
23
23
|
export { SelectionSet } from '@aws-amplify/data-schema-types';
|
|
@@ -41,9 +41,7 @@ export interface GraphQLOptions {
|
|
|
41
41
|
export interface GraphQLResult<T = object> {
|
|
42
42
|
data: T;
|
|
43
43
|
errors?: GraphQLError[];
|
|
44
|
-
extensions?:
|
|
45
|
-
[key: string]: any;
|
|
46
|
-
};
|
|
44
|
+
extensions?: Record<string, any>;
|
|
47
45
|
}
|
|
48
46
|
|
|
49
47
|
// Opaque type used for determining the graphql query type
|
|
@@ -75,21 +73,22 @@ export type GraphQLSubscription<T> = T & {
|
|
|
75
73
|
*
|
|
76
74
|
* This util simply makes related model properties optional recursively.
|
|
77
75
|
*/
|
|
78
|
-
export type GraphQLReturnType<T> =
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
76
|
+
export type GraphQLReturnType<T> =
|
|
77
|
+
T extends Record<string, unknown>
|
|
78
|
+
? {
|
|
79
|
+
[K in keyof T]?: GraphQLReturnType<T[K]>;
|
|
80
|
+
}
|
|
81
|
+
: T;
|
|
83
82
|
|
|
84
83
|
/**
|
|
85
84
|
* Describes a paged list result from AppSync, which can either
|
|
86
85
|
* live at the top query or property (e.g., related model) level.
|
|
87
86
|
*/
|
|
88
|
-
|
|
87
|
+
interface PagedList<T, TYPENAME> {
|
|
89
88
|
__typename: TYPENAME;
|
|
90
89
|
nextToken?: string | null | undefined;
|
|
91
|
-
items:
|
|
92
|
-
}
|
|
90
|
+
items: T[];
|
|
91
|
+
}
|
|
93
92
|
|
|
94
93
|
/**
|
|
95
94
|
* Recursively looks through a result type and removes nulls and
|
|
@@ -102,7 +101,7 @@ type PagedList<T, TYPENAME> = {
|
|
|
102
101
|
type WithListsFixed<T> =
|
|
103
102
|
T extends PagedList<infer IT, infer NAME>
|
|
104
103
|
? PagedList<Exclude<IT, null | undefined>, NAME>
|
|
105
|
-
: T extends
|
|
104
|
+
: T extends Record<string, unknown>
|
|
106
105
|
? {
|
|
107
106
|
[K in keyof T]: WithListsFixed<T[K]>;
|
|
108
107
|
}
|
|
@@ -169,9 +168,9 @@ export type GraphqlSubscriptionResult<T> = Observable<
|
|
|
169
168
|
* })
|
|
170
169
|
* ```
|
|
171
170
|
*/
|
|
172
|
-
export
|
|
171
|
+
export interface GraphqlSubscriptionMessage<T> {
|
|
173
172
|
data: T;
|
|
174
|
-
}
|
|
173
|
+
}
|
|
175
174
|
|
|
176
175
|
export interface AWSAppSyncRealTimeProviderOptions {
|
|
177
176
|
appSyncGraphqlEndpoint?: string;
|
|
@@ -180,15 +179,17 @@ export interface AWSAppSyncRealTimeProviderOptions {
|
|
|
180
179
|
variables?: Record<string, unknown>;
|
|
181
180
|
apiKey?: string;
|
|
182
181
|
region?: string;
|
|
183
|
-
libraryConfigHeaders
|
|
182
|
+
libraryConfigHeaders?():
|
|
183
|
+
| Record<string, unknown>
|
|
184
|
+
| (() => Promise<Record<string, unknown> | Headers>);
|
|
184
185
|
additionalHeaders?: CustomHeaders;
|
|
185
186
|
}
|
|
186
187
|
|
|
187
|
-
export
|
|
188
|
+
export interface AWSAppSyncRealTimeProvider {
|
|
188
189
|
subscribe(
|
|
189
190
|
options?: AWSAppSyncRealTimeProviderOptions,
|
|
190
191
|
): Observable<Record<string, unknown>>;
|
|
191
|
-
}
|
|
192
|
+
}
|
|
192
193
|
|
|
193
194
|
export enum GraphQLAuthError {
|
|
194
195
|
NO_API_KEY = 'No api-key configured',
|
|
@@ -259,18 +260,18 @@ export type GraphQLResponseV6<
|
|
|
259
260
|
FALLBACK_TYPE = unknown,
|
|
260
261
|
TYPED_GQL_STRING extends string = string,
|
|
261
262
|
> =
|
|
262
|
-
TYPED_GQL_STRING extends GeneratedQuery<infer
|
|
263
|
+
TYPED_GQL_STRING extends GeneratedQuery<infer _, infer QUERY_OUT>
|
|
263
264
|
? Promise<GraphQLResult<FixedQueryResult<QUERY_OUT>>>
|
|
264
|
-
: TYPED_GQL_STRING extends GeneratedMutation<infer
|
|
265
|
+
: TYPED_GQL_STRING extends GeneratedMutation<infer _, infer MUTATION_OUT>
|
|
265
266
|
? Promise<GraphQLResult<NeverEmpty<MUTATION_OUT>>>
|
|
266
|
-
: TYPED_GQL_STRING extends GeneratedSubscription<infer
|
|
267
|
+
: TYPED_GQL_STRING extends GeneratedSubscription<infer _, infer SUB_OUT>
|
|
267
268
|
? GraphqlSubscriptionResult<NeverEmpty<SUB_OUT>>
|
|
268
|
-
: FALLBACK_TYPE extends GraphQLQuery<infer
|
|
269
|
+
: FALLBACK_TYPE extends GraphQLQuery<infer _>
|
|
269
270
|
? Promise<GraphQLResult<FALLBACK_TYPE>>
|
|
270
|
-
: FALLBACK_TYPE extends GraphQLSubscription<infer
|
|
271
|
+
: FALLBACK_TYPE extends GraphQLSubscription<infer _>
|
|
271
272
|
? GraphqlSubscriptionResult<FALLBACK_TYPE>
|
|
272
273
|
: FALLBACK_TYPE extends GraphQLOperationType<
|
|
273
|
-
infer
|
|
274
|
+
infer _,
|
|
274
275
|
infer CUSTOM_OUT
|
|
275
276
|
>
|
|
276
277
|
? CUSTOM_OUT
|
|
@@ -294,10 +295,13 @@ export type GraphQLResponseV6<
|
|
|
294
295
|
* })
|
|
295
296
|
* ```
|
|
296
297
|
*/
|
|
297
|
-
export
|
|
298
|
+
export interface GraphQLOperationType<
|
|
299
|
+
IN extends Record<string, DocumentType>,
|
|
300
|
+
OUT extends Record<string, DocumentType>,
|
|
301
|
+
> {
|
|
298
302
|
variables: IN;
|
|
299
303
|
result: OUT;
|
|
300
|
-
}
|
|
304
|
+
}
|
|
301
305
|
|
|
302
306
|
/**
|
|
303
307
|
* Nominal type for branding generated graphql query operation strings with
|
|
@@ -386,8 +390,8 @@ export type V6Client<T extends Record<any, any> = never> = ExcludeNeverFields<{
|
|
|
386
390
|
[__authToken]?: string;
|
|
387
391
|
[__headers]?: CustomHeaders;
|
|
388
392
|
graphql: GraphQLMethod;
|
|
389
|
-
cancel
|
|
390
|
-
isCancelError
|
|
393
|
+
cancel(promise: Promise<any>, message?: string): boolean;
|
|
394
|
+
isCancelError(error: any): boolean;
|
|
391
395
|
models: ModelTypes<T>;
|
|
392
396
|
enums: EnumTypes<T>;
|
|
393
397
|
queries: CustomQueries<T>;
|
|
@@ -401,8 +405,8 @@ export type V6ClientSSRRequest<T extends Record<any, any> = never> =
|
|
|
401
405
|
[__authToken]?: string;
|
|
402
406
|
[__headers]?: CustomHeaders;
|
|
403
407
|
graphql: GraphQLMethodSSR;
|
|
404
|
-
cancel
|
|
405
|
-
isCancelError
|
|
408
|
+
cancel(promise: Promise<any>, message?: string): boolean;
|
|
409
|
+
isCancelError(error: any): boolean;
|
|
406
410
|
models: ModelTypes<T, 'REQUEST'>;
|
|
407
411
|
enums: EnumTypes<T>;
|
|
408
412
|
queries: CustomQueries<T, 'REQUEST'>;
|
|
@@ -416,8 +420,8 @@ export type V6ClientSSRCookies<T extends Record<any, any> = never> =
|
|
|
416
420
|
[__authToken]?: string;
|
|
417
421
|
[__headers]?: CustomHeaders;
|
|
418
422
|
graphql: GraphQLMethod;
|
|
419
|
-
cancel
|
|
420
|
-
isCancelError
|
|
423
|
+
cancel(promise: Promise<any>, message?: string): boolean;
|
|
424
|
+
isCancelError(error: any): boolean;
|
|
421
425
|
models: ModelTypes<T, 'COOKIES'>;
|
|
422
426
|
enums: EnumTypes<T>;
|
|
423
427
|
queries: CustomQueries<T, 'COOKIES'>;
|
|
@@ -446,30 +450,30 @@ export type GraphQLMethodSSR = <
|
|
|
446
450
|
*
|
|
447
451
|
* The knobs available for configuring `server/generateClient` internally.
|
|
448
452
|
*/
|
|
449
|
-
export
|
|
453
|
+
export interface ServerClientGenerationParams {
|
|
450
454
|
amplify:
|
|
451
455
|
| null // null expected when used with `generateServerClient`
|
|
452
456
|
// closure expected with `generateServerClientUsingCookies`
|
|
453
457
|
| ((fn: (amplify: AmplifyClassV6) => Promise<any>) => Promise<any>);
|
|
454
458
|
// global env-sourced config use for retrieving modelIntro
|
|
455
459
|
config: ResourcesConfig;
|
|
456
|
-
}
|
|
460
|
+
}
|
|
457
461
|
|
|
458
462
|
export type QueryArgs = Record<string, unknown>;
|
|
459
463
|
|
|
460
|
-
export
|
|
464
|
+
export interface ListArgs extends Record<string, unknown> {
|
|
461
465
|
selectionSet?: string[];
|
|
462
|
-
filter?:
|
|
466
|
+
filter?: Record<string, unknown>;
|
|
463
467
|
headers?: CustomHeaders;
|
|
464
|
-
}
|
|
468
|
+
}
|
|
465
469
|
|
|
466
|
-
export
|
|
470
|
+
export interface AuthModeParams extends Record<string, unknown> {
|
|
467
471
|
authMode?: GraphQLAuthMode;
|
|
468
472
|
authToken?: string;
|
|
469
|
-
}
|
|
473
|
+
}
|
|
470
474
|
|
|
471
|
-
export
|
|
475
|
+
export interface GenerateServerClientParams {
|
|
472
476
|
config: ResourcesConfig;
|
|
473
477
|
authMode?: GraphQLAuthMode;
|
|
474
478
|
authToken?: string;
|
|
475
|
-
}
|
|
479
|
+
}
|
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import { Observable, Observer, SubscriptionLike,
|
|
4
|
+
import { Observable, Observer, SubscriptionLike, filter, map } from 'rxjs';
|
|
5
|
+
|
|
5
6
|
import { ConnectionState } from '../types/PubSub';
|
|
7
|
+
|
|
6
8
|
import { ReachabilityMonitor } from './ReachabilityMonitor';
|
|
7
9
|
|
|
8
10
|
// Internal types for tracking different connection states
|
|
9
11
|
type LinkedConnectionState = 'connected' | 'disconnected';
|
|
10
12
|
type LinkedHealthState = 'healthy' | 'unhealthy';
|
|
11
|
-
|
|
13
|
+
interface LinkedConnectionStates {
|
|
12
14
|
networkState: LinkedConnectionState;
|
|
13
15
|
connectionState: LinkedConnectionState | 'connecting';
|
|
14
16
|
intendedConnectionState: LinkedConnectionState;
|
|
15
17
|
keepAliveState: LinkedHealthState;
|
|
16
|
-
}
|
|
18
|
+
}
|
|
17
19
|
|
|
18
20
|
export const CONNECTION_CHANGE: {
|
|
19
21
|
[key in
|
|
@@ -53,6 +55,7 @@ export class ConnectionStateMonitor {
|
|
|
53
55
|
private _linkedConnectionStateObserver:
|
|
54
56
|
| Observer<LinkedConnectionStates>
|
|
55
57
|
| undefined;
|
|
58
|
+
|
|
56
59
|
private _networkMonitoringSubscription?: SubscriptionLike;
|
|
57
60
|
private _initialNetworkStateSubscription?: SubscriptionLike;
|
|
58
61
|
|
|
@@ -132,6 +135,7 @@ export class ConnectionStateMonitor {
|
|
|
132
135
|
filter(current => {
|
|
133
136
|
const toInclude = current !== previous;
|
|
134
137
|
previous = current;
|
|
138
|
+
|
|
135
139
|
return toInclude;
|
|
136
140
|
}),
|
|
137
141
|
);
|
|
@@ -196,6 +200,7 @@ export class ConnectionStateMonitor {
|
|
|
196
200
|
// All remaining states directly correspond to the connection state
|
|
197
201
|
if (connectionState === 'connecting') return ConnectionState.Connecting;
|
|
198
202
|
if (connectionState === 'disconnected') return ConnectionState.Disconnected;
|
|
203
|
+
|
|
199
204
|
return ConnectionState.Connected;
|
|
200
205
|
}
|
|
201
206
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
import { Reachability } from '@aws-amplify/core/internals/utils';
|
|
4
|
-
import
|
|
4
|
+
import NetInfo from '@react-native-community/netinfo';
|
|
5
5
|
|
|
6
6
|
export const ReachabilityMonitor = () =>
|
|
7
7
|
new Reachability().networkMonitor(NetInfo);
|