Skip to content

Commit b019858

Browse files
committed
chore: restore curated server exports matching main branch
1 parent 422212d commit b019858

58 files changed

Lines changed: 431 additions & 547 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

packages/api-graphql/src/Providers/AWSAppSyncRealTimeProvider/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// SPDX-License-Identifier: Apache-2.0
33

44
import { AmplifyContext } from '@aws-amplify/core';
5-
65
import {
76
CustomUserAgentDetails,
87
DocumentType,

packages/api-graphql/src/Providers/AWSWebSocketProvider/authHeaders.ts

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ type AWSAppSyncRealTimeAuthInput =
1717
host?: string | undefined;
1818
};
1919

20-
const awsAuthTokenHeader = async (ctx: AmplifyContext, { host }: AWSAppSyncRealTimeAuthInput) => {
20+
const awsAuthTokenHeader = async (
21+
ctx: AmplifyContext,
22+
{ host }: AWSAppSyncRealTimeAuthInput,
23+
) => {
2124
const session = await ctx.fetchAuthSession();
2225

2326
return {
@@ -26,10 +29,10 @@ const awsAuthTokenHeader = async (ctx: AmplifyContext, { host }: AWSAppSyncRealT
2629
};
2730
};
2831

29-
const awsRealTimeApiKeyHeader = async (_ctx: AmplifyContext, {
30-
apiKey,
31-
host,
32-
}: AWSAppSyncRealTimeAuthInput) => {
32+
const awsRealTimeApiKeyHeader = async (
33+
_ctx: AmplifyContext,
34+
{ apiKey, host }: AWSAppSyncRealTimeAuthInput,
35+
) => {
3336
const dt = new Date();
3437
const dtStr = dt.toISOString().replace(/[:-]|\.\d{3}/g, '');
3538

@@ -40,12 +43,15 @@ const awsRealTimeApiKeyHeader = async (_ctx: AmplifyContext, {
4043
};
4144
};
4245

43-
const awsRealTimeIAMHeader = async (ctx: AmplifyContext, {
44-
payload,
45-
canonicalUri,
46-
appSyncGraphqlEndpoint,
47-
region,
48-
}: AWSAppSyncRealTimeAuthInput) => {
46+
const awsRealTimeIAMHeader = async (
47+
ctx: AmplifyContext,
48+
{
49+
payload,
50+
canonicalUri,
51+
appSyncGraphqlEndpoint,
52+
region,
53+
}: AWSAppSyncRealTimeAuthInput,
54+
) => {
4955
const endpointInfo = {
5056
region,
5157
service: 'appsync',
@@ -77,10 +83,10 @@ const awsRealTimeIAMHeader = async (ctx: AmplifyContext, {
7783
return signedParams.headers;
7884
};
7985

80-
const customAuthHeader = async (_ctx: AmplifyContext, {
81-
host,
82-
additionalCustomHeaders,
83-
}: AWSAppSyncRealTimeAuthInput) => {
86+
const customAuthHeader = async (
87+
_ctx: AmplifyContext,
88+
{ host, additionalCustomHeaders }: AWSAppSyncRealTimeAuthInput,
89+
) => {
8490
/**
8591
* If `additionalHeaders` was provided to the subscription as a function,
8692
* the headers that are returned by that function will already have been
@@ -96,17 +102,18 @@ const customAuthHeader = async (_ctx: AmplifyContext, {
96102
};
97103
};
98104

99-
export const awsRealTimeHeaderBasedAuth = async (ctx: AmplifyContext, {
100-
apiKey,
101-
authenticationType,
102-
canonicalUri,
103-
appSyncGraphqlEndpoint,
104-
region,
105-
additionalCustomHeaders,
106-
payload,
107-
}: AWSAppSyncRealTimeAuthInput): Promise<
108-
Record<string, string | undefined> | undefined
109-
> => {
105+
export const awsRealTimeHeaderBasedAuth = async (
106+
ctx: AmplifyContext,
107+
{
108+
apiKey,
109+
authenticationType,
110+
canonicalUri,
111+
appSyncGraphqlEndpoint,
112+
region,
113+
additionalCustomHeaders,
114+
payload,
115+
}: AWSAppSyncRealTimeAuthInput,
116+
): Promise<Record<string, string | undefined> | undefined> => {
110117
const headerHandler = {
111118
apiKey: awsRealTimeApiKeyHeader,
112119
iam: awsRealTimeIAMHeader,

packages/api-graphql/src/Providers/AWSWebSocketProvider/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22
// SPDX-License-Identifier: Apache-2.0
33
import { Observable, Subscription, SubscriptionLike } from 'rxjs';
44
import { GraphQLError } from 'graphql';
5-
import { AmplifyContext, ConsoleLogger, Hub, HubPayload } from '@aws-amplify/core';
5+
import {
6+
AmplifyContext,
7+
ConsoleLogger,
8+
Hub,
9+
HubPayload,
10+
} from '@aws-amplify/core';
611
import {
712
CustomUserAgentDetails,
813
DocumentType,

packages/api-graphql/src/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ import * as events from './internals/events';
55

66
export { events };
77

8-
export { createGraphQLAPI, GraphQLAPIClass, graphqlOperation } from './GraphQLAPI';
8+
export {
9+
createGraphQLAPI,
10+
GraphQLAPIClass,
11+
graphqlOperation,
12+
} from './GraphQLAPI';
913
export * from './types';
1014

1115
export { CONNECTION_STATE_CHANGE } from './Providers/constants';

packages/api-graphql/src/internals/InternalGraphQLAPI.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export class InternalGraphQLAPIClass {
5454
constructor(ctx: AmplifyContext) {
5555
this.ctx = ctx;
5656
}
57+
5758
/**
5859
* @private
5960
*/
@@ -397,7 +398,8 @@ export class InternalGraphQLAPIClass {
397398
// know why somethings depends on its absence!)
398399
const memoKey = appSyncGraphqlEndpoint ?? 'none';
399400
const realtimeProvider =
400-
this.appSyncRealTime.get(memoKey) ?? new AWSAppSyncRealTimeProvider(this.ctx);
401+
this.appSyncRealTime.get(memoKey) ??
402+
new AWSAppSyncRealTimeProvider(this.ctx);
401403
this.appSyncRealTime.set(memoKey, realtimeProvider);
402404

403405
return realtimeProvider
@@ -426,4 +428,5 @@ export class InternalGraphQLAPIClass {
426428
}
427429
}
428430

429-
export const createInternalGraphQLAPI = (ctx: AmplifyContext) => new InternalGraphQLAPIClass(ctx);
431+
export const createInternalGraphQLAPI = (ctx: AmplifyContext) =>
432+
new InternalGraphQLAPIClass(ctx);

packages/api-graphql/src/internals/events/index.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ const openChannels = new Set<string>();
4141
* @param options - request overrides: `authMode`, `authToken`
4242
*
4343
*/
44-
async function connect(ctx: AmplifyContext,
44+
async function connect(
45+
ctx: AmplifyContext,
4546
channel: string,
4647
options?: EventsOptions,
4748
): Promise<EventsChannel> {
@@ -146,12 +147,13 @@ async function connect(ctx: AmplifyContext,
146147
* @returns void on success
147148
* @throws on error
148149
*/
149-
async function post(ctx: AmplifyContext,
150+
async function post(
151+
ctx: AmplifyContext,
150152
channel: string,
151153
event: DocumentType | DocumentType[],
152154
options?: EventsOptions,
153155
): Promise<void | PublishedEvent[]> {
154-
const eventProvider = createAppSyncEventProvider(ctx);
156+
const _eventProvider = createAppSyncEventProvider(ctx);
155157
const providerOptions: ProviderOptions = configure(ctx);
156158
providerOptions.authenticationType = normalizeAuth(
157159
options?.authMode,

packages/api-graphql/src/internals/generateClient.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export function generateClient<
5656
subscriptions: emptyProperty as CustomSubscriptions<never>,
5757
} as any;
5858

59-
const apiGraphqlConfig = params.amplify.resourcesConfig.API?.GraphQL;
59+
const apiGraphqlConfig = params.amplify?.resourcesConfig?.API?.GraphQL;
6060

6161
if (client[__endpoint]) {
6262
if (!client[__authMode]) {

packages/api-graphql/src/internals/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
3+
import { generateClient as _generateClient } from './generateClient';
4+
35
export {
46
createInternalGraphQLAPI,
57
InternalGraphQLAPIClass,
@@ -9,11 +11,9 @@ export { graphql, cancel, isCancelError } from './v6';
911
export { generateClient } from './generateClient';
1012
export { CommonPublicClientOptions, DefaultCommonClientOptions } from './types';
1113

12-
import { generateClient as _generateClient } from './generateClient';
13-
1414
/** @deprecated Use generateClient instead. */
1515
export function generateClientWithAmplifyInstance<
16-
T extends Record<any, any> = never,
16+
_T extends Record<any, any> = never,
1717
ClientType = any,
1818
>(...args: any[]): ClientType {
1919
return (_generateClient as any)(...args);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
33

4-
export * from '..';
4+
export { generateClientWithAmplifyInstance } from '..';

packages/api-graphql/src/internals/v6.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
33
import { CustomHeaders } from '@aws-amplify/data-schema/runtime';
4-
5-
import { createGraphQLAPI } from '../GraphQLAPI';
64
import { isCancelError as isCancelErrorREST } from '@aws-amplify/api-rest';
75
import { cancel as cancelREST } from '@aws-amplify/api-rest/internals';
6+
7+
import { createGraphQLAPI } from '../GraphQLAPI';
88
import {
99
CommonPublicClientOptions,
1010
GraphQLOptions,

0 commit comments

Comments
 (0)