Skip to content

Commit

Permalink
Support CommonJS import of construct output types (#268)
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardfoyle authored Sep 22, 2023
1 parent 75d90a5 commit 5377925
Show file tree
Hide file tree
Showing 5 changed files with 197 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/good-readers-drum.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@aws-amplify/backend-output-schemas': patch
---

re-export construct output objects in root package namespace
146 changes: 146 additions & 0 deletions packages/backend-output-schemas/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,18 @@

import { z } from 'zod';

// @public (undocumented)
export type AuthOutput = z.infer<typeof versionedAuthOutputSchema>;

// @public
export const authOutputKey = "AWS::Amplify::Auth";

// @public (undocumented)
export type AwsAppsyncAuthenticationType = z.infer<typeof AwsAppsyncAuthenticationZodEnum>;

// @public (undocumented)
export const AwsAppsyncAuthenticationZodEnum: z.ZodEnum<["API_KEY", "AWS_LAMBDA", "AWS_IAM", "OPENID_CONNECT", "AMAZON_COGNITO_USER_POOLS"]>;

// @public
export type BackendOutputEntryStackMetadata = z.infer<typeof backendOutputEntryStackMetadataSchema>;

Expand Down Expand Up @@ -39,9 +48,15 @@ export const backendOutputStackMetadataSchema: z.ZodRecord<z.ZodString, z.ZodObj
stackOutputs: string[];
}>>;

// @public (undocumented)
export type GraphqlOutput = z.infer<typeof versionedGraphqlOutputSchema>;

// @public
export const graphqlOutputKey = "AWS::Amplify::GraphQL";

// @public (undocumented)
export type StorageOutput = z.infer<typeof versionedStorageOutputSchema>;

// @public
export const storageOutputKey = "AWS::Amplify::Storage";

Expand Down Expand Up @@ -241,6 +256,137 @@ export const unifiedBackendOutputSchema: z.ZodObject<{
} | undefined;
}>;

// @public (undocumented)
export const versionedAuthOutputSchema: z.ZodDiscriminatedUnion<"version", [z.ZodObject<{
version: z.ZodLiteral<"1">;
payload: z.ZodObject<{
userPoolId: z.ZodString;
webClientId: z.ZodString;
identityPoolId: z.ZodString;
amazonClientId: z.ZodOptional<z.ZodString>;
appleClientId: z.ZodOptional<z.ZodString>;
facebookClientId: z.ZodOptional<z.ZodString>;
googleClientId: z.ZodOptional<z.ZodString>;
authRegion: z.ZodString;
}, "strip", z.ZodTypeAny, {
userPoolId: string;
webClientId: string;
identityPoolId: string;
authRegion: string;
amazonClientId?: string | undefined;
appleClientId?: string | undefined;
facebookClientId?: string | undefined;
googleClientId?: string | undefined;
}, {
userPoolId: string;
webClientId: string;
identityPoolId: string;
authRegion: string;
amazonClientId?: string | undefined;
appleClientId?: string | undefined;
facebookClientId?: string | undefined;
googleClientId?: string | undefined;
}>;
}, "strip", z.ZodTypeAny, {
version: "1";
payload: {
userPoolId: string;
webClientId: string;
identityPoolId: string;
authRegion: string;
amazonClientId?: string | undefined;
appleClientId?: string | undefined;
facebookClientId?: string | undefined;
googleClientId?: string | undefined;
};
}, {
version: "1";
payload: {
userPoolId: string;
webClientId: string;
identityPoolId: string;
authRegion: string;
amazonClientId?: string | undefined;
appleClientId?: string | undefined;
facebookClientId?: string | undefined;
googleClientId?: string | undefined;
};
}>]>;

// @public (undocumented)
export const versionedGraphqlOutputSchema: z.ZodDiscriminatedUnion<"version", [z.ZodObject<{
version: z.ZodLiteral<"1">;
payload: z.ZodObject<{
awsAppsyncRegion: z.ZodString;
awsAppsyncApiEndpoint: z.ZodString;
awsAppsyncAuthenticationType: z.ZodEnum<["API_KEY", "AWS_LAMBDA", "AWS_IAM", "OPENID_CONNECT", "AMAZON_COGNITO_USER_POOLS"]>;
awsAppsyncApiKey: z.ZodOptional<z.ZodString>;
awsAppsyncApiId: z.ZodString;
amplifyApiModelSchemaS3Uri: z.ZodString;
}, "strip", z.ZodTypeAny, {
awsAppsyncRegion: string;
awsAppsyncApiEndpoint: string;
awsAppsyncAuthenticationType: "API_KEY" | "AWS_LAMBDA" | "AWS_IAM" | "OPENID_CONNECT" | "AMAZON_COGNITO_USER_POOLS";
awsAppsyncApiId: string;
amplifyApiModelSchemaS3Uri: string;
awsAppsyncApiKey?: string | undefined;
}, {
awsAppsyncRegion: string;
awsAppsyncApiEndpoint: string;
awsAppsyncAuthenticationType: "API_KEY" | "AWS_LAMBDA" | "AWS_IAM" | "OPENID_CONNECT" | "AMAZON_COGNITO_USER_POOLS";
awsAppsyncApiId: string;
amplifyApiModelSchemaS3Uri: string;
awsAppsyncApiKey?: string | undefined;
}>;
}, "strip", z.ZodTypeAny, {
version: "1";
payload: {
awsAppsyncRegion: string;
awsAppsyncApiEndpoint: string;
awsAppsyncAuthenticationType: "API_KEY" | "AWS_LAMBDA" | "AWS_IAM" | "OPENID_CONNECT" | "AMAZON_COGNITO_USER_POOLS";
awsAppsyncApiId: string;
amplifyApiModelSchemaS3Uri: string;
awsAppsyncApiKey?: string | undefined;
};
}, {
version: "1";
payload: {
awsAppsyncRegion: string;
awsAppsyncApiEndpoint: string;
awsAppsyncAuthenticationType: "API_KEY" | "AWS_LAMBDA" | "AWS_IAM" | "OPENID_CONNECT" | "AMAZON_COGNITO_USER_POOLS";
awsAppsyncApiId: string;
amplifyApiModelSchemaS3Uri: string;
awsAppsyncApiKey?: string | undefined;
};
}>]>;

// @public (undocumented)
export const versionedStorageOutputSchema: z.ZodDiscriminatedUnion<"version", [z.ZodObject<{
version: z.ZodLiteral<"1">;
payload: z.ZodObject<{
bucketName: z.ZodString;
storageRegion: z.ZodString;
}, "strip", z.ZodTypeAny, {
bucketName: string;
storageRegion: string;
}, {
bucketName: string;
storageRegion: string;
}>;
}, "strip", z.ZodTypeAny, {
version: "1";
payload: {
bucketName: string;
storageRegion: string;
};
}, {
version: "1";
payload: {
bucketName: string;
storageRegion: string;
};
}>]>;

// (No @packageDocumentation comment for this package)

```
6 changes: 5 additions & 1 deletion packages/backend-output-schemas/src/graphql/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { z } from 'zod';
import { graphqlOutputSchema as graphqlOutputSchemaV1 } from './v1.js';
export type { AwsAppsyncAuthenticationType } from './v1.js';

export {
AwsAppsyncAuthenticationType,
AwsAppsyncAuthenticationZodEnum,
} from './v1.js';

export const versionedGraphqlOutputSchema = z.discriminatedUnion('version', [
graphqlOutputSchemaV1,
Expand Down
2 changes: 1 addition & 1 deletion packages/backend-output-schemas/src/graphql/v1.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { z } from 'zod';

const AwsAppsyncAuthenticationZodEnum = z.enum([
export const AwsAppsyncAuthenticationZodEnum = z.enum([
'API_KEY',
'AWS_LAMBDA',
'AWS_IAM',
Expand Down
40 changes: 40 additions & 0 deletions packages/backend-output-schemas/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,58 @@ import { versionedAuthOutputSchema } from './auth/index.js';
import { versionedGraphqlOutputSchema } from './graphql/index.js';
import { versionedStorageOutputSchema } from './storage/index.js';

/**
* The auth, graphql and storage exports here are duplicated from the submodule exports in the package.json file
* This is because these types need to be consumed in CDK Constructs that may be JSII classes. JSII only supports
* CommonJS modules which can't interpret submodule exports
*/

/**
* ---------- Auth exports ----------
*/

/**
* re-export the auth output schema
*/
export * from './auth/index.js';

/**
* Expected key that auth output is stored under
*/
export const authOutputKey = 'AWS::Amplify::Auth';

/**
* ---------- GraphQL exports ----------
*/

/**
* re-export the graphql output schema
*/
export * from './graphql/index.js';

/**
* Expected key that graphql output is stored under
*/
export const graphqlOutputKey = 'AWS::Amplify::GraphQL';

/**
* ---------- Storage exports ----------
*/

/**
* re-export the storage output schema
*/
export * from './storage/index.js';

/**
* Expected key that storage output is stored under
*/
export const storageOutputKey = 'AWS::Amplify::Storage';

/**
* ---------- Unified exports ----------
*/

/**
* Defines the unified expected shape of Amplify backend output.
* As new constructs are added that need to contribute backend output, entries should be added here so that client config generation is aware of these outputs
Expand Down

0 comments on commit 5377925

Please sign in to comment.