@aws-amplify/api-graphql 3.4.12-unstable.7762f1a.0 → 4.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/GraphQLAPI.d.ts +17 -4
- package/lib/GraphQLAPI.js +33 -27
- package/lib/Providers/AWSAppSyncRealTimeProvider/index.d.ts +64 -0
- package/lib/Providers/AWSAppSyncRealTimeProvider/index.js +690 -0
- package/lib/Providers/constants.d.ts +95 -0
- package/lib/Providers/constants.js +103 -0
- package/lib/index.d.ts +1 -3
- package/lib/index.js +6 -10
- package/lib/internals/InternalGraphQLAPI.d.ts +11 -34
- package/lib/internals/InternalGraphQLAPI.js +219 -345
- package/lib/internals/index.d.ts +1 -0
- package/lib/internals/index.js +4 -1
- package/lib/internals/v6.d.ts +101 -0
- package/lib/internals/v6.js +118 -0
- package/lib/tsconfig.tsbuildinfo +6813 -0
- package/lib/types/PubSub.d.ts +27 -0
- package/lib/types/PubSub.js +46 -0
- package/lib/types/index.d.ts +281 -5
- package/lib/types/index.js +4 -3
- package/lib/utils/ConnectionStateMonitor.d.ts +41 -0
- package/lib/utils/ConnectionStateMonitor.js +131 -0
- package/lib/utils/ReachabilityMonitor/index.d.ts +1 -0
- package/lib/utils/ReachabilityMonitor/index.js +6 -0
- package/lib/utils/ReachabilityMonitor/index.native.d.ts +1 -0
- package/lib/utils/ReachabilityMonitor/index.native.js +8 -0
- package/lib/utils/ReconnectionMonitor.d.ts +29 -0
- package/lib/utils/ReconnectionMonitor.js +68 -0
- package/lib/utils/errors/APIError.d.ts +7 -0
- package/lib/utils/errors/APIError.js +18 -0
- package/lib/utils/errors/assertValidationError.d.ts +5 -0
- package/lib/utils/errors/assertValidationError.js +16 -0
- package/lib/utils/errors/index.d.ts +3 -0
- package/lib/utils/errors/index.js +11 -0
- package/lib/utils/errors/validation.d.ts +7 -0
- package/lib/utils/errors/validation.js +25 -0
- package/lib/utils/index.d.ts +2 -0
- package/lib/utils/index.js +8 -0
- package/lib/utils/resolveConfig.d.ts +12 -0
- package/lib/utils/resolveConfig.js +22 -0
- package/lib/utils/resolveLibraryOptions.d.ts +11 -0
- package/lib/utils/resolveLibraryOptions.js +12 -0
- package/lib-esm/GraphQLAPI.d.ts +17 -4
- package/lib-esm/GraphQLAPI.js +33 -28
- package/lib-esm/Providers/AWSAppSyncRealTimeProvider/index.d.ts +64 -0
- package/lib-esm/Providers/AWSAppSyncRealTimeProvider/index.js +687 -0
- package/lib-esm/Providers/constants.d.ts +95 -0
- package/lib-esm/Providers/constants.js +100 -0
- package/lib-esm/index.d.ts +1 -3
- package/lib-esm/index.js +1 -4
- package/lib-esm/internals/InternalGraphQLAPI.d.ts +11 -34
- package/lib-esm/internals/InternalGraphQLAPI.js +218 -345
- package/lib-esm/internals/index.d.ts +1 -0
- package/lib-esm/internals/index.js +1 -1
- package/lib-esm/internals/v6.d.ts +101 -0
- package/lib-esm/internals/v6.js +113 -0
- package/lib-esm/tsconfig.tsbuildinfo +6813 -0
- package/lib-esm/types/PubSub.d.ts +27 -0
- package/lib-esm/types/PubSub.js +44 -0
- package/lib-esm/types/index.d.ts +281 -5
- package/lib-esm/types/index.js +2 -3
- package/lib-esm/utils/ConnectionStateMonitor.d.ts +41 -0
- package/lib-esm/utils/ConnectionStateMonitor.js +128 -0
- package/lib-esm/utils/ReachabilityMonitor/index.d.ts +1 -0
- package/lib-esm/utils/ReachabilityMonitor/index.js +4 -0
- package/lib-esm/utils/ReachabilityMonitor/index.native.d.ts +1 -0
- package/lib-esm/utils/ReachabilityMonitor/index.native.js +5 -0
- package/lib-esm/utils/ReconnectionMonitor.d.ts +29 -0
- package/lib-esm/utils/ReconnectionMonitor.js +65 -0
- package/lib-esm/utils/errors/APIError.d.ts +7 -0
- package/lib-esm/utils/errors/APIError.js +15 -0
- package/lib-esm/utils/errors/assertValidationError.d.ts +5 -0
- package/lib-esm/utils/errors/assertValidationError.js +13 -0
- package/lib-esm/utils/errors/index.d.ts +3 -0
- package/lib-esm/utils/errors/index.js +5 -0
- package/lib-esm/utils/errors/validation.d.ts +7 -0
- package/lib-esm/utils/errors/validation.js +23 -0
- package/lib-esm/utils/index.d.ts +2 -0
- package/lib-esm/utils/index.js +4 -0
- package/lib-esm/utils/resolveConfig.d.ts +12 -0
- package/lib-esm/utils/resolveConfig.js +20 -0
- package/lib-esm/utils/resolveLibraryOptions.d.ts +11 -0
- package/lib-esm/utils/resolveLibraryOptions.js +10 -0
- package/package.json +122 -114
- package/src/GraphQLAPI.ts +26 -4
- package/src/Providers/AWSAppSyncRealTimeProvider/index.ts +998 -0
- package/src/Providers/constants.ts +110 -0
- package/src/index.ts +2 -3
- package/src/internals/InternalGraphQLAPI.ts +181 -218
- package/src/internals/index.ts +2 -0
- package/src/internals/v6.ts +138 -0
- package/src/types/PubSub.ts +56 -0
- package/src/types/index.ts +378 -8
- package/src/utils/ConnectionStateMonitor.ts +199 -0
- package/src/utils/ReachabilityMonitor/index.native.ts +7 -0
- package/src/utils/ReachabilityMonitor/index.ts +4 -0
- package/src/utils/ReconnectionMonitor.ts +76 -0
- package/src/utils/errors/APIError.ts +21 -0
- package/src/utils/errors/assertValidationError.ts +19 -0
- package/src/utils/errors/index.ts +6 -0
- package/src/utils/errors/validation.ts +26 -0
- package/src/utils/index.ts +5 -0
- package/src/utils/resolveConfig.ts +35 -0
- package/src/utils/resolveLibraryOptions.ts +13 -0
- package/lib/.tsbuildinfo +0 -3
- package/lib/GraphQLAPI.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/internals/InternalGraphQLAPI.js.map +0 -1
- package/lib/internals/index.js.map +0 -1
- package/lib/types/index.js.map +0 -1
- package/lib-esm/.tsbuildinfo +0 -3
- package/lib-esm/GraphQLAPI.js.map +0 -1
- package/lib-esm/index.js.map +0 -1
- package/lib-esm/internals/InternalGraphQLAPI.js.map +0 -1
- package/lib-esm/internals/index.js.map +0 -1
- package/lib-esm/types/index.js.map +0 -1
package/README.md
ADDED
package/lib/GraphQLAPI.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { AmplifyClassV6 } from '@aws-amplify/core';
|
|
1
2
|
import { GraphQLOptions, GraphQLResult } from './types';
|
|
2
3
|
import { InternalGraphQLAPIClass } from './internals';
|
|
3
|
-
import Observable from '
|
|
4
|
-
export declare const graphqlOperation: (query: any, variables?: {}, authToken?: string) => {
|
|
4
|
+
import { Observable } from 'rxjs';
|
|
5
|
+
export declare const graphqlOperation: (query: any, variables?: {}, authToken?: string | undefined) => {
|
|
5
6
|
query: any;
|
|
6
7
|
variables: {};
|
|
7
|
-
authToken: string;
|
|
8
|
+
authToken: string | undefined;
|
|
8
9
|
};
|
|
9
10
|
/**
|
|
10
11
|
* Export Cloud Logic APIs
|
|
@@ -18,8 +19,20 @@ export declare class GraphQLAPIClass extends InternalGraphQLAPIClass {
|
|
|
18
19
|
* @param [additionalHeaders] - headers to merge in after any `graphql_headers` set in the config
|
|
19
20
|
* @returns An Observable if the query is a subscription query, else a promise of the graphql result.
|
|
20
21
|
*/
|
|
21
|
-
graphql<T = any>(options: GraphQLOptions, additionalHeaders?: {
|
|
22
|
+
graphql<T = any>(amplify: AmplifyClassV6 | (() => Promise<AmplifyClassV6>), options: GraphQLOptions, additionalHeaders?: {
|
|
22
23
|
[key: string]: string;
|
|
23
24
|
}): Observable<GraphQLResult<T>> | Promise<GraphQLResult<T>>;
|
|
25
|
+
/**
|
|
26
|
+
* Checks to see if an error thrown is from an api request cancellation
|
|
27
|
+
* @param error - Any error
|
|
28
|
+
* @returns A boolean indicating if the error was from an api request cancellation
|
|
29
|
+
*/
|
|
30
|
+
isCancelError(error: any): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Cancels an inflight request. Only applicable for graphql queries and mutations
|
|
33
|
+
* @param {any} request - request to cancel
|
|
34
|
+
* @returns A boolean indicating if the request was cancelled
|
|
35
|
+
*/
|
|
36
|
+
cancel(request: Promise<any>, message?: string): boolean;
|
|
24
37
|
}
|
|
25
38
|
export declare const GraphQLAPI: GraphQLAPIClass;
|
package/lib/GraphQLAPI.js
CHANGED
|
@@ -1,29 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return ({
|
|
11
|
-
query: query,
|
|
12
|
-
variables: variables,
|
|
13
|
-
authToken: authToken,
|
|
14
|
-
});
|
|
15
|
-
};
|
|
3
|
+
const utils_1 = require("@aws-amplify/core/internals/utils");
|
|
4
|
+
const internals_1 = require("./internals");
|
|
5
|
+
exports.graphqlOperation = (query, variables = {}, authToken) => ({
|
|
6
|
+
query,
|
|
7
|
+
variables,
|
|
8
|
+
authToken,
|
|
9
|
+
});
|
|
16
10
|
/**
|
|
17
11
|
* Export Cloud Logic APIs
|
|
18
12
|
*/
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
function GraphQLAPIClass() {
|
|
22
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
23
|
-
}
|
|
24
|
-
GraphQLAPIClass.prototype.getModuleName = function () {
|
|
13
|
+
class GraphQLAPIClass extends internals_1.InternalGraphQLAPIClass {
|
|
14
|
+
getModuleName() {
|
|
25
15
|
return 'GraphQLAPI';
|
|
26
|
-
}
|
|
16
|
+
}
|
|
27
17
|
/**
|
|
28
18
|
* Executes a GraphQL operation
|
|
29
19
|
*
|
|
@@ -31,12 +21,28 @@ var GraphQLAPIClass = /** @class */ (function (_super) {
|
|
|
31
21
|
* @param [additionalHeaders] - headers to merge in after any `graphql_headers` set in the config
|
|
32
22
|
* @returns An Observable if the query is a subscription query, else a promise of the graphql result.
|
|
33
23
|
*/
|
|
34
|
-
|
|
35
|
-
return
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
24
|
+
graphql(amplify, options, additionalHeaders) {
|
|
25
|
+
return super.graphql(amplify, options, additionalHeaders, {
|
|
26
|
+
category: utils_1.Category.API,
|
|
27
|
+
action: utils_1.ApiAction.GraphQl,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Checks to see if an error thrown is from an api request cancellation
|
|
32
|
+
* @param error - Any error
|
|
33
|
+
* @returns A boolean indicating if the error was from an api request cancellation
|
|
34
|
+
*/
|
|
35
|
+
isCancelError(error) {
|
|
36
|
+
return super.isCancelError(error);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Cancels an inflight request. Only applicable for graphql queries and mutations
|
|
40
|
+
* @param {any} request - request to cancel
|
|
41
|
+
* @returns A boolean indicating if the request was cancelled
|
|
42
|
+
*/
|
|
43
|
+
cancel(request, message) {
|
|
44
|
+
return super.cancel(request, message);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
39
47
|
exports.GraphQLAPIClass = GraphQLAPIClass;
|
|
40
48
|
exports.GraphQLAPI = new GraphQLAPIClass(null);
|
|
41
|
-
core_1.Amplify.register(exports.GraphQLAPI);
|
|
42
|
-
//# sourceMappingURL=GraphQLAPI.js.map
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
import { GraphQLAuthMode, CustomUserAgentDetails, DocumentType } from '@aws-amplify/core/internals/utils';
|
|
3
|
+
import { PubSubContentObserver } from '../../types/PubSub';
|
|
4
|
+
import { SUBSCRIPTION_STATUS } from '../constants';
|
|
5
|
+
export declare type ObserverQuery = {
|
|
6
|
+
observer: PubSubContentObserver;
|
|
7
|
+
query: string;
|
|
8
|
+
variables: Record<string, DocumentType>;
|
|
9
|
+
subscriptionState: SUBSCRIPTION_STATUS;
|
|
10
|
+
subscriptionReadyCallback?: Function;
|
|
11
|
+
subscriptionFailedCallback?: Function;
|
|
12
|
+
startAckTimeoutId?: ReturnType<typeof setTimeout>;
|
|
13
|
+
};
|
|
14
|
+
export interface AWSAppSyncRealTimeProviderOptions {
|
|
15
|
+
appSyncGraphqlEndpoint?: string;
|
|
16
|
+
authenticationType?: GraphQLAuthMode;
|
|
17
|
+
query?: string;
|
|
18
|
+
variables?: Record<string, DocumentType>;
|
|
19
|
+
apiKey?: string;
|
|
20
|
+
region?: string;
|
|
21
|
+
graphql_headers?: () => {} | (() => Promise<{}>);
|
|
22
|
+
additionalHeaders?: {
|
|
23
|
+
[key: string]: string;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export declare class AWSAppSyncRealTimeProvider {
|
|
27
|
+
private awsRealTimeSocket?;
|
|
28
|
+
private socketStatus;
|
|
29
|
+
private keepAliveTimeoutId?;
|
|
30
|
+
private keepAliveTimeout;
|
|
31
|
+
private keepAliveAlertTimeoutId?;
|
|
32
|
+
private subscriptionObserverMap;
|
|
33
|
+
private promiseArray;
|
|
34
|
+
private connectionState;
|
|
35
|
+
private readonly connectionStateMonitor;
|
|
36
|
+
private readonly reconnectionMonitor;
|
|
37
|
+
private connectionStateMonitorSubscription;
|
|
38
|
+
constructor(options?: AWSAppSyncRealTimeProviderOptions);
|
|
39
|
+
/**
|
|
40
|
+
* Mark the socket closed and release all active listeners
|
|
41
|
+
*/
|
|
42
|
+
close(): void;
|
|
43
|
+
getNewWebSocket(url: string, protocol: string): WebSocket;
|
|
44
|
+
getProviderName(): string;
|
|
45
|
+
private isCustomDomain;
|
|
46
|
+
subscribe(options?: AWSAppSyncRealTimeProviderOptions, customUserAgentDetails?: CustomUserAgentDetails): Observable<Record<string, unknown>>;
|
|
47
|
+
private _startSubscriptionWithAWSAppSyncRealTime;
|
|
48
|
+
private _logStartSubscriptionError;
|
|
49
|
+
private _waitForSubscriptionToBeConnected;
|
|
50
|
+
private _sendUnsubscriptionMessage;
|
|
51
|
+
private _removeSubscriptionObserver;
|
|
52
|
+
private _closeSocketIfRequired;
|
|
53
|
+
private _handleIncomingSubscriptionMessage;
|
|
54
|
+
private _errorDisconnect;
|
|
55
|
+
private _timeoutStartSubscriptionAck;
|
|
56
|
+
private _initializeWebSocketConnection;
|
|
57
|
+
private _initializeRetryableHandshake;
|
|
58
|
+
private _initializeHandshake;
|
|
59
|
+
private _awsRealTimeHeaderBasedAuth;
|
|
60
|
+
private _awsAuthTokenHeader;
|
|
61
|
+
private _awsRealTimeApiKeyHeader;
|
|
62
|
+
private _awsRealTimeIAMHeader;
|
|
63
|
+
private _customAuthHeader;
|
|
64
|
+
}
|