@aws-amplify/api-graphql 4.0.1-console-preview.be08038.0 → 4.0.1-server-generate-client.1e317a1.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/lib/GraphQLAPI.d.ts +2 -2
- package/lib/GraphQLAPI.js +4 -6
- package/lib/Providers/AWSAppSyncRealTimeProvider/index.d.ts +1 -1
- package/lib/Providers/AWSAppSyncRealTimeProvider/index.js +36 -36
- package/lib/Providers/constants.js +5 -4
- package/lib/index.js +5 -4
- package/lib/internals/APIClient.d.ts +101 -0
- package/lib/internals/APIClient.js +443 -0
- package/lib/internals/InternalGraphQLAPI.d.ts +2 -2
- package/lib/internals/InternalGraphQLAPI.js +35 -17
- package/lib/internals/generateClient.d.ts +12 -0
- package/lib/internals/generateClient.js +30 -0
- package/lib/internals/generateModelsProperty.d.ts +4 -0
- package/lib/internals/generateModelsProperty.js +169 -0
- package/lib/internals/index.d.ts +1 -0
- package/lib/internals/index.js +8 -5
- package/lib/internals/types.d.ts +10 -0
- package/lib/internals/types.js +2 -0
- package/lib/internals/v6.js +1 -0
- package/lib/tsconfig.tsbuildinfo +1 -6619
- package/lib/types/PubSub.d.ts +2 -2
- package/lib/types/PubSub.js +3 -2
- package/lib/types/index.d.ts +25 -22
- package/lib/types/index.js +4 -3
- package/lib/utils/ConnectionStateMonitor.d.ts +3 -3
- package/lib/utils/ConnectionStateMonitor.js +7 -6
- package/lib/utils/ReachabilityMonitor/index.d.ts +1 -1
- package/lib/utils/ReachabilityMonitor/index.js +3 -1
- package/lib/utils/ReachabilityMonitor/index.native.d.ts +1 -1
- package/lib/utils/ReachabilityMonitor/index.native.js +3 -1
- package/lib/utils/ReconnectionMonitor.js +2 -1
- package/lib/utils/errors/APIError.js +1 -0
- package/lib/utils/errors/assertValidationError.js +1 -0
- package/lib/utils/errors/index.js +5 -4
- package/lib/utils/errors/validation.js +2 -1
- package/lib/utils/index.js +3 -2
- package/lib/utils/resolveConfig.d.ts +1 -1
- package/lib/utils/resolveConfig.js +4 -2
- package/lib/utils/resolveLibraryOptions.d.ts +1 -1
- package/lib/utils/resolveLibraryOptions.js +3 -1
- package/lib/utils/resolveOwnerFields.d.ts +12 -0
- package/lib/utils/resolveOwnerFields.js +63 -0
- package/lib-esm/GraphQLAPI.d.ts +2 -2
- package/lib-esm/GraphQLAPI.js +1 -5
- package/lib-esm/Providers/AWSAppSyncRealTimeProvider/index.d.ts +1 -1
- package/lib-esm/Providers/AWSAppSyncRealTimeProvider/index.js +28 -29
- package/lib-esm/internals/APIClient.d.ts +101 -0
- package/lib-esm/internals/APIClient.js +432 -0
- package/lib-esm/internals/InternalGraphQLAPI.d.ts +2 -2
- package/lib-esm/internals/InternalGraphQLAPI.js +21 -5
- package/lib-esm/internals/generateClient.d.ts +12 -0
- package/lib-esm/internals/generateClient.js +26 -0
- package/lib-esm/internals/generateModelsProperty.d.ts +4 -0
- package/lib-esm/internals/generateModelsProperty.js +165 -0
- package/lib-esm/internals/index.d.ts +1 -0
- package/lib-esm/internals/index.js +1 -0
- package/lib-esm/internals/types.d.ts +10 -0
- package/lib-esm/internals/types.js +1 -0
- package/lib-esm/tsconfig.tsbuildinfo +1 -6619
- package/lib-esm/types/PubSub.d.ts +2 -2
- package/lib-esm/types/index.d.ts +25 -22
- package/lib-esm/utils/ConnectionStateMonitor.d.ts +3 -3
- package/lib-esm/utils/ConnectionStateMonitor.js +2 -2
- package/lib-esm/utils/ReachabilityMonitor/index.d.ts +1 -1
- package/lib-esm/utils/ReachabilityMonitor/index.native.d.ts +1 -1
- package/lib-esm/utils/resolveConfig.d.ts +1 -1
- package/lib-esm/utils/resolveLibraryOptions.d.ts +1 -1
- package/lib-esm/utils/resolveOwnerFields.d.ts +12 -0
- package/lib-esm/utils/resolveOwnerFields.js +59 -0
- package/package.json +12 -6
- package/src/GraphQLAPI.ts +2 -6
- package/src/Providers/AWSAppSyncRealTimeProvider/index.ts +2 -3
- package/src/internals/APIClient.ts +583 -0
- package/src/internals/InternalGraphQLAPI.ts +35 -9
- package/src/internals/generateClient.ts +30 -0
- package/src/internals/generateModelsProperty.ts +192 -0
- package/src/internals/index.ts +1 -0
- package/src/internals/types.ts +15 -0
- package/src/types/index.ts +7 -1
- package/src/utils/resolveOwnerFields.ts +65 -0
package/lib/types/PubSub.d.ts
CHANGED
|
@@ -23,5 +23,5 @@ export declare enum ConnectionState {
|
|
|
23
23
|
Disconnected = "Disconnected",
|
|
24
24
|
ConnectedPendingKeepAlive = "ConnectedPendingKeepAlive"
|
|
25
25
|
}
|
|
26
|
-
export
|
|
27
|
-
export
|
|
26
|
+
export type PubSubContent = Record<string, unknown>;
|
|
27
|
+
export type PubSubContentObserver = Observer<PubSubContent>;
|
package/lib/types/PubSub.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConnectionState = exports.CONTROL_MSG = void 0;
|
|
3
4
|
var CONTROL_MSG;
|
|
4
5
|
(function (CONTROL_MSG) {
|
|
5
6
|
CONTROL_MSG["CONNECTION_CLOSED"] = "Connection closed";
|
|
@@ -7,7 +8,7 @@ var CONTROL_MSG;
|
|
|
7
8
|
CONTROL_MSG["REALTIME_SUBSCRIPTION_INIT_ERROR"] = "AppSync Realtime subscription init error";
|
|
8
9
|
CONTROL_MSG["SUBSCRIPTION_ACK"] = "Subscription ack";
|
|
9
10
|
CONTROL_MSG["TIMEOUT_DISCONNECT"] = "Timeout disconnect";
|
|
10
|
-
})(CONTROL_MSG
|
|
11
|
+
})(CONTROL_MSG || (exports.CONTROL_MSG = CONTROL_MSG = {}));
|
|
11
12
|
/** @enum {string} */
|
|
12
13
|
var ConnectionState;
|
|
13
14
|
(function (ConnectionState) {
|
|
@@ -43,4 +44,4 @@ var ConnectionState;
|
|
|
43
44
|
* The connection is alive, but a keep alive message has been missed
|
|
44
45
|
*/
|
|
45
46
|
ConnectionState["ConnectedPendingKeepAlive"] = "ConnectedPendingKeepAlive";
|
|
46
|
-
})(ConnectionState
|
|
47
|
+
})(ConnectionState || (exports.ConnectionState = ConnectionState = {}));
|
package/lib/types/index.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { AmplifyClassV6 } from '@aws-amplify/core';
|
|
2
|
+
import { ModelTypes } from '@aws-amplify/amplify-api-next-types-alpha';
|
|
2
3
|
import { Source, DocumentNode, GraphQLError } from 'graphql';
|
|
3
4
|
export { OperationTypeNode } from 'graphql';
|
|
4
5
|
import { Observable } from 'rxjs';
|
|
5
6
|
import { GraphQLAuthMode, DocumentType } from '@aws-amplify/core/internals/utils';
|
|
6
7
|
export { CONTROL_MSG, ConnectionState } from './PubSub';
|
|
8
|
+
export { SelectionSet } from '@aws-amplify/amplify-api-next-types-alpha';
|
|
7
9
|
/**
|
|
8
10
|
* Loose/Unknown options for raw GraphQLAPICategory `graphql()`.
|
|
9
11
|
*/
|
|
@@ -25,10 +27,10 @@ export interface GraphQLResult<T = object> {
|
|
|
25
27
|
};
|
|
26
28
|
}
|
|
27
29
|
declare const queryType: unique symbol;
|
|
28
|
-
export
|
|
30
|
+
export type GraphQLQuery<T> = T & {
|
|
29
31
|
readonly [queryType]: 'query';
|
|
30
32
|
};
|
|
31
|
-
export
|
|
33
|
+
export type GraphQLSubscription<T> = T & {
|
|
32
34
|
readonly [queryType]: 'subscription';
|
|
33
35
|
};
|
|
34
36
|
/**
|
|
@@ -52,14 +54,14 @@ export declare type GraphQLSubscription<T> = T & {
|
|
|
52
54
|
*
|
|
53
55
|
* This util simply makes related model properties optional recursively.
|
|
54
56
|
*/
|
|
55
|
-
export
|
|
57
|
+
export type GraphQLReturnType<T> = T extends {} ? {
|
|
56
58
|
[K in keyof T]?: GraphQLReturnType<T[K]>;
|
|
57
59
|
} : T;
|
|
58
60
|
/**
|
|
59
61
|
* Describes a paged list result from AppSync, which can either
|
|
60
62
|
* live at the top query or property (e.g., related model) level.
|
|
61
63
|
*/
|
|
62
|
-
|
|
64
|
+
type PagedList<T, TYPENAME> = {
|
|
63
65
|
__typename: TYPENAME;
|
|
64
66
|
nextToken?: string | null | undefined;
|
|
65
67
|
items: Array<T>;
|
|
@@ -72,13 +74,13 @@ declare type PagedList<T, TYPENAME> = {
|
|
|
72
74
|
* array, this will only be the case when we also have errors,
|
|
73
75
|
* which will then be *thrown*.
|
|
74
76
|
*/
|
|
75
|
-
|
|
77
|
+
type WithListsFixed<T> = T extends PagedList<infer IT, infer NAME> ? PagedList<Exclude<IT, null | undefined>, NAME> : T extends {} ? {
|
|
76
78
|
[K in keyof T]: WithListsFixed<T[K]>;
|
|
77
79
|
} : T;
|
|
78
80
|
/**
|
|
79
81
|
* Returns an updated response type to always return a value.
|
|
80
82
|
*/
|
|
81
|
-
|
|
83
|
+
type NeverEmpty<T> = {
|
|
82
84
|
[K in keyof T]-?: Exclude<WithListsFixed<T[K]>, undefined | null>;
|
|
83
85
|
};
|
|
84
86
|
/**
|
|
@@ -88,7 +90,7 @@ declare type NeverEmpty<T> = {
|
|
|
88
90
|
* If empty members are present, there will also be errors present,
|
|
89
91
|
* and the response will instead be *thrown*.
|
|
90
92
|
*/
|
|
91
|
-
|
|
93
|
+
type FixedQueryResult<T> = Exclude<T[keyof T], null | undefined> extends PagedList<any, any> ? {
|
|
92
94
|
[K in keyof T]-?: WithListsFixed<Exclude<T[K], null | undefined>>;
|
|
93
95
|
} : T;
|
|
94
96
|
/**
|
|
@@ -111,7 +113,7 @@ declare type FixedQueryResult<T> = Exclude<T[keyof T], null | undefined> extends
|
|
|
111
113
|
* })
|
|
112
114
|
* ```
|
|
113
115
|
*/
|
|
114
|
-
export
|
|
116
|
+
export type GraphqlSubscriptionResult<T> = Observable<GraphqlSubscriptionMessage<T>>;
|
|
115
117
|
/**
|
|
116
118
|
* The shape of messages passed to `next()` from a graphql subscription. E.g.,
|
|
117
119
|
*
|
|
@@ -128,7 +130,7 @@ export declare type GraphqlSubscriptionResult<T> = Observable<GraphqlSubscriptio
|
|
|
128
130
|
* })
|
|
129
131
|
* ```
|
|
130
132
|
*/
|
|
131
|
-
export
|
|
133
|
+
export type GraphqlSubscriptionMessage<T> = {
|
|
132
134
|
data: T;
|
|
133
135
|
};
|
|
134
136
|
export interface AWSAppSyncRealTimeProviderOptions {
|
|
@@ -143,7 +145,7 @@ export interface AWSAppSyncRealTimeProviderOptions {
|
|
|
143
145
|
[key: string]: string;
|
|
144
146
|
};
|
|
145
147
|
}
|
|
146
|
-
export
|
|
148
|
+
export type AWSAppSyncRealTimeProvider = {
|
|
147
149
|
subscribe(options?: AWSAppSyncRealTimeProviderOptions): Observable<Record<string, unknown>>;
|
|
148
150
|
};
|
|
149
151
|
export declare enum GraphQLAuthError {
|
|
@@ -157,7 +159,7 @@ export declare enum GraphQLAuthError {
|
|
|
157
159
|
* GraphQLSource or string, the type of the parameter for calling graphql.parse
|
|
158
160
|
* @see: https://graphql.org/graphql-js/language/#parse
|
|
159
161
|
*/
|
|
160
|
-
export
|
|
162
|
+
export type GraphQLOperation = Source | string;
|
|
161
163
|
/**
|
|
162
164
|
* API V6 `graphql({options})` type that can leverage branded graphql `query`
|
|
163
165
|
* objects and fallback types.
|
|
@@ -179,17 +181,17 @@ export interface GraphQLOptionsV6<FALLBACK_TYPES = unknown, TYPED_GQL_STRING ext
|
|
|
179
181
|
* Invoking code should either cast the result or use `?` and `!` operators to
|
|
180
182
|
* navigate the result objects.
|
|
181
183
|
*/
|
|
182
|
-
export
|
|
184
|
+
export type UnknownGraphQLResponse = Promise<GraphQLResult<any>> | GraphqlSubscriptionResult<any>;
|
|
183
185
|
/**
|
|
184
186
|
* The expected type for `variables` in a V6 `graphql()` operation with
|
|
185
187
|
* respect to the given `FALLBACK_TYPES` and `TYPED_GQL_STRING`.
|
|
186
188
|
*/
|
|
187
|
-
export
|
|
189
|
+
export type GraphQLVariablesV6<FALLBACK_TYPES = unknown, TYPED_GQL_STRING extends string = string> = TYPED_GQL_STRING extends GeneratedQuery<infer IN, any> ? IN : TYPED_GQL_STRING extends GeneratedMutation<infer IN, any> ? IN : TYPED_GQL_STRING extends GeneratedSubscription<infer IN, any> ? IN : FALLBACK_TYPES extends GraphQLOperationType<infer IN, any> ? IN : any;
|
|
188
190
|
/**
|
|
189
191
|
* The expected return type with respect to the given `FALLBACK_TYPE`
|
|
190
192
|
* and `TYPED_GQL_STRING`.
|
|
191
193
|
*/
|
|
192
|
-
export
|
|
194
|
+
export type GraphQLResponseV6<FALLBACK_TYPE = unknown, TYPED_GQL_STRING extends string = string> = TYPED_GQL_STRING extends GeneratedQuery<infer IN, infer QUERY_OUT> ? Promise<GraphQLResult<FixedQueryResult<QUERY_OUT>>> : TYPED_GQL_STRING extends GeneratedMutation<infer IN, infer MUTATION_OUT> ? Promise<GraphQLResult<NeverEmpty<MUTATION_OUT>>> : TYPED_GQL_STRING extends GeneratedSubscription<infer IN, infer SUB_OUT> ? GraphqlSubscriptionResult<NeverEmpty<SUB_OUT>> : FALLBACK_TYPE extends GraphQLQuery<infer T> ? Promise<GraphQLResult<FALLBACK_TYPE>> : FALLBACK_TYPE extends GraphQLSubscription<infer T> ? GraphqlSubscriptionResult<FALLBACK_TYPE> : FALLBACK_TYPE extends GraphQLOperationType<infer IN, infer CUSTOM_OUT> ? CUSTOM_OUT : UnknownGraphQLResponse;
|
|
193
195
|
/**
|
|
194
196
|
* The shape customers can use to provide `T` to `graphql<T>()` to specify both
|
|
195
197
|
* `IN` and `OUT` types (the type of `variables` and the return type, respectively).
|
|
@@ -208,7 +210,7 @@ export declare type GraphQLResponseV6<FALLBACK_TYPE = unknown, TYPED_GQL_STRING
|
|
|
208
210
|
* })
|
|
209
211
|
* ```
|
|
210
212
|
*/
|
|
211
|
-
export
|
|
213
|
+
export type GraphQLOperationType<IN extends {}, OUT extends {}> = {
|
|
212
214
|
variables: IN;
|
|
213
215
|
result: OUT;
|
|
214
216
|
};
|
|
@@ -228,7 +230,7 @@ export declare type GraphQLOperationType<IN extends {}, OUT extends {}> = {
|
|
|
228
230
|
* This allows `graphql()` to extract `InputType` and `OutputType` to correctly
|
|
229
231
|
* assign types to the `variables` and result objects.
|
|
230
232
|
*/
|
|
231
|
-
export
|
|
233
|
+
export type GeneratedQuery<InputType, OutputType> = string & {
|
|
232
234
|
__generatedQueryInput: InputType;
|
|
233
235
|
__generatedQueryOutput: OutputType;
|
|
234
236
|
};
|
|
@@ -248,7 +250,7 @@ export declare type GeneratedQuery<InputType, OutputType> = string & {
|
|
|
248
250
|
* This allows `graphql()` to extract `InputType` and `OutputType` to correctly
|
|
249
251
|
* assign types to the `variables` and result objects.
|
|
250
252
|
*/
|
|
251
|
-
export
|
|
253
|
+
export type GeneratedMutation<InputType, OutputType> = string & {
|
|
252
254
|
__generatedMutationInput: InputType;
|
|
253
255
|
__generatedMutationOutput: OutputType;
|
|
254
256
|
};
|
|
@@ -268,22 +270,23 @@ export declare type GeneratedMutation<InputType, OutputType> = string & {
|
|
|
268
270
|
* This allows `graphql()` to extract `InputType` and `OutputType` to correctly
|
|
269
271
|
* assign types to the `variables` and result objects.
|
|
270
272
|
*/
|
|
271
|
-
export
|
|
273
|
+
export type GeneratedSubscription<InputType, OutputType> = string & {
|
|
272
274
|
__generatedSubscriptionInput: InputType;
|
|
273
275
|
__generatedSubscriptionOutput: OutputType;
|
|
274
276
|
};
|
|
275
|
-
|
|
277
|
+
type FilteredKeys<T> = {
|
|
276
278
|
[P in keyof T]: T[P] extends never ? never : P;
|
|
277
279
|
}[keyof T];
|
|
278
|
-
|
|
280
|
+
type ExcludeNeverFields<O> = {
|
|
279
281
|
[K in FilteredKeys<O>]: O[K];
|
|
280
282
|
};
|
|
281
283
|
export declare const __amplify: unique symbol;
|
|
282
|
-
export
|
|
283
|
-
[__amplify]: AmplifyClassV6;
|
|
284
|
+
export type V6Client<T extends Record<any, any> = never> = ExcludeNeverFields<{
|
|
285
|
+
[__amplify]: AmplifyClassV6 | (() => Promise<AmplifyClassV6>);
|
|
284
286
|
graphql: <FALLBACK_TYPES = unknown, TYPED_GQL_STRING extends string = string>(options: GraphQLOptionsV6<FALLBACK_TYPES, TYPED_GQL_STRING>, additionalHeaders?: {
|
|
285
287
|
[key: string]: string;
|
|
286
288
|
} | undefined) => GraphQLResponseV6<FALLBACK_TYPES, TYPED_GQL_STRING>;
|
|
287
289
|
cancel: (promise: Promise<any>, message?: string) => boolean;
|
|
288
290
|
isCancelError: (error: any) => boolean;
|
|
291
|
+
models: ModelTypes<T>;
|
|
289
292
|
}>;
|
package/lib/types/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.__amplify = exports.GraphQLAuthError = exports.ConnectionState = exports.CONTROL_MSG = void 0;
|
|
3
4
|
var PubSub_1 = require("./PubSub");
|
|
4
|
-
exports
|
|
5
|
-
exports
|
|
5
|
+
Object.defineProperty(exports, "CONTROL_MSG", { enumerable: true, get: function () { return PubSub_1.CONTROL_MSG; } });
|
|
6
|
+
Object.defineProperty(exports, "ConnectionState", { enumerable: true, get: function () { return PubSub_1.ConnectionState; } });
|
|
6
7
|
var GraphQLAuthError;
|
|
7
8
|
(function (GraphQLAuthError) {
|
|
8
9
|
GraphQLAuthError["NO_API_KEY"] = "No api-key configured";
|
|
@@ -10,5 +11,5 @@ var GraphQLAuthError;
|
|
|
10
11
|
GraphQLAuthError["NO_CREDENTIALS"] = "No credentials";
|
|
11
12
|
GraphQLAuthError["NO_FEDERATED_JWT"] = "No federated jwt";
|
|
12
13
|
GraphQLAuthError["NO_AUTH_TOKEN"] = "No auth token specified";
|
|
13
|
-
})(GraphQLAuthError
|
|
14
|
+
})(GraphQLAuthError || (exports.GraphQLAuthError = GraphQLAuthError = {}));
|
|
14
15
|
exports.__amplify = Symbol('amplify');
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Observable } from 'rxjs';
|
|
2
2
|
import { ConnectionState } from '../types/PubSub';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
type LinkedConnectionState = 'connected' | 'disconnected';
|
|
4
|
+
type LinkedHealthState = 'healthy' | 'unhealthy';
|
|
5
|
+
type LinkedConnectionStates = {
|
|
6
6
|
networkState: LinkedConnectionState;
|
|
7
7
|
connectionState: LinkedConnectionState | 'connecting';
|
|
8
8
|
intendedConnectionState: LinkedConnectionState;
|
|
@@ -2,6 +2,7 @@
|
|
|
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.ConnectionStateMonitor = exports.CONNECTION_CHANGE = void 0;
|
|
5
6
|
var tslib_1 = require("tslib");
|
|
6
7
|
var rxjs_1 = require("rxjs");
|
|
7
8
|
var PubSub_1 = require("../types/PubSub");
|
|
@@ -34,9 +35,9 @@ var ConnectionStateMonitor = /** @class */ (function () {
|
|
|
34
35
|
keepAliveState: 'healthy',
|
|
35
36
|
};
|
|
36
37
|
// Attempt to update the state with the current actual network state
|
|
37
|
-
this._initialNetworkStateSubscription = ReachabilityMonitor_1.ReachabilityMonitor().subscribe(function (_a) {
|
|
38
|
-
var online = _a.online;
|
|
38
|
+
this._initialNetworkStateSubscription = (0, ReachabilityMonitor_1.ReachabilityMonitor)().subscribe(function (_a) {
|
|
39
39
|
var _b;
|
|
40
|
+
var online = _a.online;
|
|
40
41
|
_this.record(online ? exports.CONNECTION_CHANGE.ONLINE : exports.CONNECTION_CHANGE.OFFLINE);
|
|
41
42
|
(_b = _this._initialNetworkStateSubscription) === null || _b === void 0 ? void 0 : _b.unsubscribe();
|
|
42
43
|
});
|
|
@@ -56,7 +57,7 @@ var ConnectionStateMonitor = /** @class */ (function () {
|
|
|
56
57
|
(_a = this._initialNetworkStateSubscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
|
|
57
58
|
// Maintain the network state based on the reachability monitor
|
|
58
59
|
if (this._networkMonitoringSubscription === undefined) {
|
|
59
|
-
this._networkMonitoringSubscription = ReachabilityMonitor_1.ReachabilityMonitor().subscribe(function (_a) {
|
|
60
|
+
this._networkMonitoringSubscription = (0, ReachabilityMonitor_1.ReachabilityMonitor)().subscribe(function (_a) {
|
|
60
61
|
var online = _a.online;
|
|
61
62
|
_this.record(online ? exports.CONNECTION_CHANGE.ONLINE : exports.CONNECTION_CHANGE.OFFLINE);
|
|
62
63
|
});
|
|
@@ -84,16 +85,16 @@ var ConnectionStateMonitor = /** @class */ (function () {
|
|
|
84
85
|
// states without changing the overall connection state.
|
|
85
86
|
// After translating from linked states to ConnectionState, then remove any duplicates
|
|
86
87
|
return this._linkedConnectionStateObservable
|
|
87
|
-
.pipe(rxjs_1.map(function (value) {
|
|
88
|
+
.pipe((0, rxjs_1.map)(function (value) {
|
|
88
89
|
return _this.connectionStatesTranslator(value);
|
|
89
90
|
}))
|
|
90
|
-
.pipe(rxjs_1.filter(function (current) {
|
|
91
|
+
.pipe((0, rxjs_1.filter)(function (current) {
|
|
91
92
|
var toInclude = current !== previous;
|
|
92
93
|
previous = current;
|
|
93
94
|
return toInclude;
|
|
94
95
|
}));
|
|
95
96
|
},
|
|
96
|
-
enumerable:
|
|
97
|
+
enumerable: false,
|
|
97
98
|
configurable: true
|
|
98
99
|
});
|
|
99
100
|
/*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const ReachabilityMonitor: () =>
|
|
1
|
+
export declare const ReachabilityMonitor: () => import("rxjs").Observable<import("@aws-amplify/core/lib-esm/Reachability/types").NetworkStatus>;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ReachabilityMonitor = void 0;
|
|
3
4
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
4
5
|
// SPDX-License-Identifier: Apache-2.0
|
|
5
6
|
var utils_1 = require("@aws-amplify/core/internals/utils");
|
|
6
|
-
|
|
7
|
+
var ReachabilityMonitor = function () { return new utils_1.Reachability().networkMonitor(); };
|
|
8
|
+
exports.ReachabilityMonitor = ReachabilityMonitor;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const ReachabilityMonitor: () =>
|
|
1
|
+
export declare const ReachabilityMonitor: () => import("rxjs").Observable<import("@aws-amplify/core/lib-esm/Reachability/types").NetworkStatus>;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ReachabilityMonitor = void 0;
|
|
3
4
|
var tslib_1 = require("tslib");
|
|
4
5
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
5
6
|
// SPDX-License-Identifier: Apache-2.0
|
|
6
7
|
var utils_1 = require("@aws-amplify/core/internals/utils");
|
|
7
8
|
var netinfo_1 = tslib_1.__importDefault(require("@react-native-community/netinfo"));
|
|
8
|
-
|
|
9
|
+
var ReachabilityMonitor = function () {
|
|
9
10
|
return new utils_1.Reachability().networkMonitor(netinfo_1.default);
|
|
10
11
|
};
|
|
12
|
+
exports.ReachabilityMonitor = ReachabilityMonitor;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ReconnectionMonitor = exports.ReconnectEvent = void 0;
|
|
3
4
|
var constants_1 = require("../Providers/constants");
|
|
4
5
|
var ReconnectEvent;
|
|
5
6
|
(function (ReconnectEvent) {
|
|
6
7
|
ReconnectEvent["START_RECONNECT"] = "START_RECONNECT";
|
|
7
8
|
ReconnectEvent["HALT_RECONNECT"] = "HALT_RECONNECT";
|
|
8
|
-
})(ReconnectEvent
|
|
9
|
+
})(ReconnectEvent || (exports.ReconnectEvent = ReconnectEvent = {}));
|
|
9
10
|
/**
|
|
10
11
|
* Captures the reconnect event logic used to determine when to reconnect to PubSub providers.
|
|
11
12
|
* Reconnnect attempts are delayed by 5 seconds to let the interface settle.
|
|
@@ -2,6 +2,7 @@
|
|
|
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.APIError = void 0;
|
|
5
6
|
var tslib_1 = require("tslib");
|
|
6
7
|
var utils_1 = require("@aws-amplify/core/internals/utils");
|
|
7
8
|
/**
|
|
@@ -2,6 +2,7 @@
|
|
|
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.assertValidationError = void 0;
|
|
5
6
|
var APIError_1 = require("./APIError");
|
|
6
7
|
var validation_1 = require("./validation");
|
|
7
8
|
/**
|
|
@@ -2,10 +2,11 @@
|
|
|
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.validationErrorMap = exports.APIValidationErrorCode = exports.assertValidationError = exports.APIError = void 0;
|
|
5
6
|
var APIError_1 = require("./APIError");
|
|
6
|
-
exports
|
|
7
|
+
Object.defineProperty(exports, "APIError", { enumerable: true, get: function () { return APIError_1.APIError; } });
|
|
7
8
|
var assertValidationError_1 = require("./assertValidationError");
|
|
8
|
-
exports
|
|
9
|
+
Object.defineProperty(exports, "assertValidationError", { enumerable: true, get: function () { return assertValidationError_1.assertValidationError; } });
|
|
9
10
|
var validation_1 = require("./validation");
|
|
10
|
-
exports
|
|
11
|
-
exports
|
|
11
|
+
Object.defineProperty(exports, "APIValidationErrorCode", { enumerable: true, get: function () { return validation_1.APIValidationErrorCode; } });
|
|
12
|
+
Object.defineProperty(exports, "validationErrorMap", { enumerable: true, get: function () { return validation_1.validationErrorMap; } });
|
|
@@ -3,12 +3,13 @@
|
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
var _a;
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.validationErrorMap = exports.APIValidationErrorCode = void 0;
|
|
6
7
|
var APIValidationErrorCode;
|
|
7
8
|
(function (APIValidationErrorCode) {
|
|
8
9
|
APIValidationErrorCode["NoAuthSession"] = "NoAuthSession";
|
|
9
10
|
APIValidationErrorCode["NoRegion"] = "NoRegion";
|
|
10
11
|
APIValidationErrorCode["NoCustomEndpoint"] = "NoCustomEndpoint";
|
|
11
|
-
})(APIValidationErrorCode
|
|
12
|
+
})(APIValidationErrorCode || (exports.APIValidationErrorCode = APIValidationErrorCode = {}));
|
|
12
13
|
exports.validationErrorMap = (_a = {},
|
|
13
14
|
_a[APIValidationErrorCode.NoAuthSession] = {
|
|
14
15
|
message: 'Auth session should not be empty.',
|
package/lib/utils/index.js
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
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.resolveLibraryOptions = exports.resolveConfig = void 0;
|
|
5
6
|
var resolveConfig_1 = require("./resolveConfig");
|
|
6
|
-
exports
|
|
7
|
+
Object.defineProperty(exports, "resolveConfig", { enumerable: true, get: function () { return resolveConfig_1.resolveConfig; } });
|
|
7
8
|
var resolveLibraryOptions_1 = require("./resolveLibraryOptions");
|
|
8
|
-
exports
|
|
9
|
+
Object.defineProperty(exports, "resolveLibraryOptions", { enumerable: true, get: function () { return resolveLibraryOptions_1.resolveLibraryOptions; } });
|
|
@@ -6,7 +6,7 @@ export declare const resolveConfig: (amplify: AmplifyClassV6) => {
|
|
|
6
6
|
apiKey: string | undefined;
|
|
7
7
|
customEndpoint: string | undefined;
|
|
8
8
|
customEndpointRegion: string | undefined;
|
|
9
|
-
defaultAuthMode: "
|
|
9
|
+
defaultAuthMode: import("@aws-amplify/core/lib-esm/libraryUtils").GraphQLAuthMode | undefined;
|
|
10
10
|
endpoint: string | undefined;
|
|
11
11
|
region: string | undefined;
|
|
12
12
|
};
|
|
@@ -2,16 +2,17 @@
|
|
|
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.resolveConfig = void 0;
|
|
5
6
|
var errors_1 = require("./errors");
|
|
6
7
|
/**
|
|
7
8
|
* @internal
|
|
8
9
|
*/
|
|
9
|
-
|
|
10
|
+
var resolveConfig = function (amplify) {
|
|
10
11
|
var _a, _b;
|
|
11
12
|
var _c = (_b = (_a = amplify.getConfig().API) === null || _a === void 0 ? void 0 : _a.GraphQL) !== null && _b !== void 0 ? _b : {}, apiKey = _c.apiKey, customEndpoint = _c.customEndpoint, customEndpointRegion = _c.customEndpointRegion, defaultAuthMode = _c.defaultAuthMode, endpoint = _c.endpoint, region = _c.region;
|
|
12
13
|
// TODO: re-enable when working in all test environments:
|
|
13
14
|
// assertValidationError(!!endpoint, APIValidationErrorCode.NoEndpoint);
|
|
14
|
-
errors_1.assertValidationError(!(!customEndpoint && customEndpointRegion), errors_1.APIValidationErrorCode.NoCustomEndpoint);
|
|
15
|
+
(0, errors_1.assertValidationError)(!(!customEndpoint && customEndpointRegion), errors_1.APIValidationErrorCode.NoCustomEndpoint);
|
|
15
16
|
return {
|
|
16
17
|
apiKey: apiKey,
|
|
17
18
|
customEndpoint: customEndpoint,
|
|
@@ -21,3 +22,4 @@ exports.resolveConfig = function (amplify) {
|
|
|
21
22
|
region: region,
|
|
22
23
|
};
|
|
23
24
|
};
|
|
25
|
+
exports.resolveConfig = resolveConfig;
|
|
@@ -6,6 +6,6 @@ export declare const resolveLibraryOptions: (amplify: AmplifyClassV6) => {
|
|
|
6
6
|
headers: ((options: {
|
|
7
7
|
query: string;
|
|
8
8
|
variables?: Record<string, import("@aws-amplify/core/lib-esm/libraryUtils").DocumentType> | undefined;
|
|
9
|
-
}) => Promise<
|
|
9
|
+
}) => Promise<import("@aws-amplify/core/lib-esm/clients").Headers>) | undefined;
|
|
10
10
|
withCredentials: boolean | undefined;
|
|
11
11
|
};
|
|
@@ -2,12 +2,14 @@
|
|
|
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.resolveLibraryOptions = void 0;
|
|
5
6
|
/**
|
|
6
7
|
* @internal
|
|
7
8
|
*/
|
|
8
|
-
|
|
9
|
+
var resolveLibraryOptions = function (amplify) {
|
|
9
10
|
var _a, _b, _c, _d, _e, _f;
|
|
10
11
|
var headers = (_c = (_b = (_a = amplify.libraryOptions) === null || _a === void 0 ? void 0 : _a.API) === null || _b === void 0 ? void 0 : _b.GraphQL) === null || _c === void 0 ? void 0 : _c.headers;
|
|
11
12
|
var withCredentials = (_f = (_e = (_d = amplify.libraryOptions) === null || _d === void 0 ? void 0 : _d.API) === null || _e === void 0 ? void 0 : _e.GraphQL) === null || _f === void 0 ? void 0 : _f.withCredentials;
|
|
12
13
|
return { headers: headers, withCredentials: withCredentials };
|
|
13
14
|
};
|
|
15
|
+
exports.resolveLibraryOptions = resolveLibraryOptions;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ResourcesConfig } from '@aws-amplify/core';
|
|
2
|
+
type GraphQLConfig = Exclude<ResourcesConfig['API'], undefined>['GraphQL'];
|
|
3
|
+
type ModelIntrospectionSchema = Exclude<Exclude<GraphQLConfig, undefined>['modelIntrospection'], undefined>;
|
|
4
|
+
type Model = ModelIntrospectionSchema['models'][string];
|
|
5
|
+
/**
|
|
6
|
+
* Given an introspection schema model, returns all owner fields.
|
|
7
|
+
*
|
|
8
|
+
* @param model Model from an introspection schema
|
|
9
|
+
* @returns List of owner field names
|
|
10
|
+
*/
|
|
11
|
+
export declare function resolveOwnerFields(model: Model): string[];
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveOwnerFields = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
/**
|
|
6
|
+
* Given an introspection schema model, returns all owner fields.
|
|
7
|
+
*
|
|
8
|
+
* @param model Model from an introspection schema
|
|
9
|
+
* @returns List of owner field names
|
|
10
|
+
*/
|
|
11
|
+
function resolveOwnerFields(model) {
|
|
12
|
+
var e_1, _a, e_2, _b;
|
|
13
|
+
var ownerFields = new Set();
|
|
14
|
+
try {
|
|
15
|
+
for (var _c = tslib_1.__values(model.attributes || []), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
16
|
+
var attr = _d.value;
|
|
17
|
+
if (isAuthAttribute(attr)) {
|
|
18
|
+
try {
|
|
19
|
+
for (var _e = (e_2 = void 0, tslib_1.__values(attr.properties.rules)), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
20
|
+
var rule = _f.value;
|
|
21
|
+
if (rule.allow === 'owner') {
|
|
22
|
+
ownerFields.add(rule.ownerField || 'owner');
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
27
|
+
finally {
|
|
28
|
+
try {
|
|
29
|
+
if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
|
30
|
+
}
|
|
31
|
+
finally { if (e_2) throw e_2.error; }
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
37
|
+
finally {
|
|
38
|
+
try {
|
|
39
|
+
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
40
|
+
}
|
|
41
|
+
finally { if (e_1) throw e_1.error; }
|
|
42
|
+
}
|
|
43
|
+
return Array.from(ownerFields);
|
|
44
|
+
}
|
|
45
|
+
exports.resolveOwnerFields = resolveOwnerFields;
|
|
46
|
+
/**
|
|
47
|
+
* Type guard that identifies an auth attribute with an attached rules list that
|
|
48
|
+
* specifies an `allow` attribute at a minimum.
|
|
49
|
+
*
|
|
50
|
+
* @param attribute Any object. Ideally a model introspection schema model attribute
|
|
51
|
+
* @returns True if given object is an auth attribute
|
|
52
|
+
*/
|
|
53
|
+
function isAuthAttribute(attribute) {
|
|
54
|
+
var _a, _b;
|
|
55
|
+
if ((attribute === null || attribute === void 0 ? void 0 : attribute.type) === 'auth') {
|
|
56
|
+
if (typeof (attribute === null || attribute === void 0 ? void 0 : attribute.properties) === 'object') {
|
|
57
|
+
if (Array.isArray((_a = attribute === null || attribute === void 0 ? void 0 : attribute.properties) === null || _a === void 0 ? void 0 : _a.rules)) {
|
|
58
|
+
return ((_b = attribute === null || attribute === void 0 ? void 0 : attribute.properties) === null || _b === void 0 ? void 0 : _b.rules).every(function (rule) { return !!rule.allow; });
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return false;
|
|
63
|
+
}
|
package/lib-esm/GraphQLAPI.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { AmplifyClassV6 } from '@aws-amplify/core';
|
|
|
2
2
|
import { GraphQLOptions, GraphQLResult } from './types';
|
|
3
3
|
import { InternalGraphQLAPIClass } from './internals';
|
|
4
4
|
import { Observable } from 'rxjs';
|
|
5
|
-
export declare const graphqlOperation: (query: any, variables?: {}, authToken?: string
|
|
5
|
+
export declare const graphqlOperation: (query: any, variables?: {}, authToken?: string) => {
|
|
6
6
|
query: any;
|
|
7
7
|
variables: {};
|
|
8
8
|
authToken: string | undefined;
|
|
@@ -19,7 +19,7 @@ export declare class GraphQLAPIClass extends InternalGraphQLAPIClass {
|
|
|
19
19
|
* @param [additionalHeaders] - headers to merge in after any `graphql_headers` set in the config
|
|
20
20
|
* @returns An Observable if the query is a subscription query, else a promise of the graphql result.
|
|
21
21
|
*/
|
|
22
|
-
graphql<T = any>(amplify: AmplifyClassV6, options: GraphQLOptions, additionalHeaders?: {
|
|
22
|
+
graphql<T = any>(amplify: AmplifyClassV6 | (() => Promise<AmplifyClassV6>), options: GraphQLOptions, additionalHeaders?: {
|
|
23
23
|
[key: string]: string;
|
|
24
24
|
}): Observable<GraphQLResult<T>> | Promise<GraphQLResult<T>>;
|
|
25
25
|
/**
|
package/lib-esm/GraphQLAPI.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { __extends } from "tslib";
|
|
2
|
-
import { Category, ApiAction } from '@aws-amplify/core/internals/utils';
|
|
3
2
|
import { InternalGraphQLAPIClass } from './internals';
|
|
4
3
|
export var graphqlOperation = function (query, variables, authToken) {
|
|
5
4
|
if (variables === void 0) { variables = {}; }
|
|
@@ -28,10 +27,7 @@ var GraphQLAPIClass = /** @class */ (function (_super) {
|
|
|
28
27
|
* @returns An Observable if the query is a subscription query, else a promise of the graphql result.
|
|
29
28
|
*/
|
|
30
29
|
GraphQLAPIClass.prototype.graphql = function (amplify, options, additionalHeaders) {
|
|
31
|
-
return _super.prototype.graphql.call(this, amplify, options, additionalHeaders
|
|
32
|
-
category: Category.API,
|
|
33
|
-
action: ApiAction.GraphQl
|
|
34
|
-
});
|
|
30
|
+
return _super.prototype.graphql.call(this, amplify, options, additionalHeaders);
|
|
35
31
|
};
|
|
36
32
|
/**
|
|
37
33
|
* Checks to see if an error thrown is from an api request cancellation
|
|
@@ -2,7 +2,7 @@ import { Observable } from 'rxjs';
|
|
|
2
2
|
import { GraphQLAuthMode, CustomUserAgentDetails, DocumentType } from '@aws-amplify/core/internals/utils';
|
|
3
3
|
import { PubSubContentObserver } from '../../types/PubSub';
|
|
4
4
|
import { SUBSCRIPTION_STATUS } from '../constants';
|
|
5
|
-
export
|
|
5
|
+
export type ObserverQuery = {
|
|
6
6
|
observer: PubSubContentObserver;
|
|
7
7
|
query: string;
|
|
8
8
|
variables: Record<string, DocumentType>;
|