@aws-amplify/amplify-appsync-simulator
Version:
An AppSync Simulator to test AppSync API.
374 lines (328 loc) • 11.2 kB
Markdown
not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
```ts
import { GraphQLResolveInfo } from 'graphql';
import { GraphQLSchema } from 'graphql';
import { PubSub } from 'graphql-subscriptions';
import { Request as Request_2 } from 'express';
// Warning: (ae-forgotten-export) The symbol "AmplifyAppSyncSimulatorDataLoader" needs to be exported by the entry point index.d.ts
//
// @public (undocumented)
export function addDataLoader(sourceType: AppSyncSimulatorDataSourceType, loader: new (config?: AppSyncSimulatorDataSourceConfig) => AmplifyAppSyncSimulatorDataLoader): void;
// @public (undocumented)
export type AmplifyAppSyncAPIConfig = {
name: string;
defaultAuthenticationType: AmplifyAppSyncAuthenticationProviderConfig;
authRoleName?: string;
unAuthRoleName?: string;
authAccessKeyId?: string;
accountId?: string;
apiKey?: string;
additionalAuthenticationProviders: AmplifyAppSyncAuthenticationProviderConfig[];
};
// @public (undocumented)
export type AmplifyAppSyncAuthenticationProviderAPIConfig = {
authenticationType: AmplifyAppSyncSimulatorAuthenticationType.API_KEY;
};
// @public (undocumented)
export type AmplifyAppSyncAuthenticationProviderCognitoConfig = {
authenticationType: AmplifyAppSyncSimulatorAuthenticationType.AMAZON_COGNITO_USER_POOLS;
cognitoUserPoolConfig: {
AppIdClientRegex?: string;
};
};
// @public (undocumented)
export type AmplifyAppSyncAuthenticationProviderConfig = AmplifyAppSyncAuthenticationProviderAPIConfig | AmplifyAppSyncAuthenticationProviderIAMConfig | AmplifyAppSyncAuthenticationProviderCognitoConfig | AmplifyAppSyncAuthenticationProviderOIDCConfig | AmplifyAppSyncAuthenticationProviderLambdaConfig;
// @public (undocumented)
export type AmplifyAppSyncAuthenticationProviderIAMConfig = {
authenticationType: AmplifyAppSyncSimulatorAuthenticationType.AWS_IAM;
};
// @public (undocumented)
export type AmplifyAppSyncAuthenticationProviderLambdaConfig = {
authenticationType: AmplifyAppSyncSimulatorAuthenticationType.AWS_LAMBDA;
lambdaAuthorizerConfig: {
AuthorizerUri: string;
AuthorizerResultTtlInSeconds?: number;
};
};
// @public (undocumented)
export type AmplifyAppSyncAuthenticationProviderOIDCConfig = {
authenticationType: AmplifyAppSyncSimulatorAuthenticationType.OPENID_CONNECT;
openIDConnectConfig: {
Issuer?: string;
ClientId?: string;
};
};
// @public (undocumented)
export class AmplifyAppSyncSimulator {
constructor(serverConfig?: AppSyncSimulatorServerConfig);
// (undocumented)
get appSyncConfig(): AmplifyAppSyncAPIConfig;
// (undocumented)
asyncIterator(trigger: string): AsyncIterator<any>;
// (undocumented)
clearData(): Promise<object>;
// (undocumented)
get config(): AmplifyAppSyncSimulatorConfig;
// (undocumented)
getDataLoader(sourceName: string): AmplifyAppSyncSimulatorDataLoader;
// Warning: (ae-forgotten-export) The symbol "AmplifySimulatorFunction" needs to be exported by the entry point index.d.ts
//
// (undocumented)
getFunction(functionName: string): AmplifySimulatorFunction;
// (undocumented)
getMappingTemplate(path: string): VelocityTemplate;
// (undocumented)
getResolver(typeName: any, fieldName: any): any;
// (undocumented)
init(config: AmplifyAppSyncSimulatorConfig): void;
// (undocumented)
get isHttps(): boolean;
// (undocumented)
get localhostUrl(): string;
// (undocumented)
get pubsub(): PubSub;
// (undocumented)
reload(config: AmplifyAppSyncSimulatorConfig): void;
// (undocumented)
get schema(): GraphQLSchema;
// (undocumented)
start(): Promise<void>;
// (undocumented)
stop(): Promise<void>;
// (undocumented)
get url(): string;
}
// @public (undocumented)
export enum AmplifyAppSyncSimulatorAuthenticationType {
// (undocumented)
AMAZON_COGNITO_USER_POOLS = "AMAZON_COGNITO_USER_POOLS",
// (undocumented)
API_KEY = "API_KEY",
// (undocumented)
AWS_IAM = "AWS_IAM",
// (undocumented)
AWS_LAMBDA = "AWS_LAMBDA",
// (undocumented)
OPENID_CONNECT = "OPENID_CONNECT"
}
// @public (undocumented)
export type AmplifyAppSyncSimulatorConfig = {
schema: AppSyncSimulatorSchemaConfig;
resolvers?: (AppSyncSimulatorUnitResolverConfig | AppSyncSimulatorPipelineResolverConfig)[];
functions?: AppSyncSimulatorFunctionsConfig[];
dataSources?: AppSyncSimulatorDataSourceConfig[];
mappingTemplates?: AppSyncSimulatorMappingTemplate[];
tables?: AppSyncSimulatorTable[];
appSync: AmplifyAppSyncAPIConfig;
};
// @public (undocumented)
export type AmplifyAppSyncSimulatorRequestContext = {
jwt?: object;
requestAuthorizationMode: AmplifyAppSyncSimulatorAuthenticationType;
request: Request_2;
appsyncErrors: any[];
};
// @public (undocumented)
export type AppSyncGraphQLExecutionContext = {
readonly sourceIp?: string;
readonly jwt?: JWTToken;
readonly iamToken?: IAMToken;
headers: Record<string, string | string[]>;
appsyncErrors?: Error[];
requestAuthorizationMode: AmplifyAppSyncSimulatorAuthenticationType;
};
// @public (undocumented)
export type AppSyncMockFile = {
path?: string;
content: string;
};
// @public (undocumented)
export interface AppSyncSimulatorBaseResolverConfig {
// (undocumented)
requestMappingTemplate?: string;
// (undocumented)
requestMappingTemplateLocation?: string;
// (undocumented)
responseMappingTemplate?: string;
// (undocumented)
responseMappingTemplateLocation?: string;
}
// @public (undocumented)
export interface AppSyncSimulatorDataSourceBaseConfig {
// (undocumented)
name: string;
// (undocumented)
type: AppSyncSimulatorDataSourceType | `${AppSyncSimulatorDataSourceType}`;
}
// @public (undocumented)
export type AppSyncSimulatorDataSourceConfig = AppSyncSimulatorDataSourceDDBConfig | AppSyncSimulatorDataSourceNoneConfig | AppSyncSimulatorDataSourceLambdaConfig;
// @public (undocumented)
export interface AppSyncSimulatorDataSourceDDBConfig extends AppSyncSimulatorDataSourceBaseConfig {
// (undocumented)
config: {
endpoint: string;
region?: string;
accessKeyId?: string;
secretAccessKey?: string;
tableName: string;
};
// (undocumented)
type: AppSyncSimulatorDataSourceType.DynamoDB | `${AppSyncSimulatorDataSourceType.DynamoDB}`;
}
// @public (undocumented)
export interface AppSyncSimulatorDataSourceLambdaConfig extends AppSyncSimulatorDataSourceBaseConfig {
// (undocumented)
invoke: Function;
// (undocumented)
type: AppSyncSimulatorDataSourceType.Lambda | `${AppSyncSimulatorDataSourceType.Lambda}`;
}
// @public (undocumented)
export interface AppSyncSimulatorDataSourceNoneConfig extends AppSyncSimulatorDataSourceBaseConfig {
// (undocumented)
type: AppSyncSimulatorDataSourceType.None | `${AppSyncSimulatorDataSourceType.None}`;
}
// @public (undocumented)
export const enum AppSyncSimulatorDataSourceType {
// (undocumented)
DynamoDB = "AMAZON_DYNAMODB",
// (undocumented)
Lambda = "AWS_LAMBDA",
// (undocumented)
None = "NONE",
// (undocumented)
OpenSearch = "AMAZON_ELASTICSEARCH"
}
// @public (undocumented)
export interface AppSyncSimulatorFunctionResolverConfig extends AppSyncSimulatorBaseResolverConfig {
// (undocumented)
dataSourceName: string;
}
// @public (undocumented)
export type AppSyncSimulatorFunctionsConfig = {
name: string;
dataSourceName: string;
requestMappingTemplateLocation: string;
responseMappingTemplateLocation: string;
};
// @public (undocumented)
export type AppSyncSimulatorMappingTemplate = AppSyncMockFile;
// @public (undocumented)
export interface AppSyncSimulatorPipelineResolver extends AppSyncSimulatorUnitResolverConfig {
// (undocumented)
functions: string[];
}
// @public (undocumented)
export interface AppSyncSimulatorPipelineResolverConfig extends AppSyncSimulatorBaseResolverConfig {
// (undocumented)
fieldName: string;
// (undocumented)
functions: string[];
// (undocumented)
kind: RESOLVER_KIND.PIPELINE;
// (undocumented)
typeName: string;
}
// @public (undocumented)
export type AppSyncSimulatorRequestContext = {
jwt?: {
iss?: string;
sub?: string;
'cognito:username'?: string;
};
request?: object;
};
// @public (undocumented)
export type AppSyncSimulatorSchemaConfig = AppSyncMockFile;
// @public (undocumented)
export type AppSyncSimulatorServerConfig = {
port?: number;
wsPort?: number;
httpsConfig?: {
sslKeyPath: string;
sslCertPath: string;
};
};
// @public (undocumented)
export type AppSyncSimulatorTable = string;
// @public (undocumented)
export interface AppSyncSimulatorUnitResolver extends AppSyncSimulatorUnitResolverConfig {
// (undocumented)
datSourceName: string;
}
// @public (undocumented)
export interface AppSyncSimulatorUnitResolverConfig extends AppSyncSimulatorBaseResolverConfig {
// (undocumented)
dataSourceName: string;
// (undocumented)
fieldName: string;
// (undocumented)
kind: RESOLVER_KIND.UNIT;
// (undocumented)
typeName: string;
}
// @public (undocumented)
export type AppSyncVTLRenderContext = {
arguments: object;
source: object;
stash?: object;
result?: any;
prevResult?: any;
error?: any;
};
// @public (undocumented)
export type AppSyncVTLTemplate = AppSyncMockFile;
// @public (undocumented)
export type IAMToken = {
accountId: string;
userArn: string;
username: string;
cognitoIdentityPoolId?: string;
cognitoIdentityId?: string;
cognitoIdentityAuthType?: 'authenticated' | 'unauthenticated';
cognitoIdentityAuthProvider?: string;
};
// @public (undocumented)
export type JWTToken = {
iss: string;
sub: string;
aud: string;
exp: number;
iat: number;
event_id?: string;
token_use?: string;
auth_time?: number;
nbf?: number;
username?: string;
email?: string;
groups?: string[];
'cognito:username'?: string;
'cognito:groups'?: string[];
};
// @public (undocumented)
export function removeDataLoader(sourceType: AppSyncSimulatorDataSourceType): boolean;
// @public (undocumented)
export enum RESOLVER_KIND {
// (undocumented)
PIPELINE = "PIPELINE",
// (undocumented)
UNIT = "UNIT"
}
// @public (undocumented)
export class VelocityTemplate {
constructor(template: AppSyncVTLTemplate, simulatorContext: AmplifyAppSyncSimulator);
// (undocumented)
render(ctxValues: AppSyncVTLRenderContext, requestContext: AppSyncGraphQLExecutionContext, info?: GraphQLResolveInfo): {
result: any;
stash: any;
args: any;
errors: any;
isReturn: boolean;
hadException: boolean;
};
}
// @public (undocumented)
export class VelocityTemplateParseError extends Error {
}
// (No @packageDocumentation comment for this package)
```
> Do