How to use AWS method in pact-foundation-pact

Best JavaScript code snippet using pact-foundation-pact

AwsApiParser.ts

Source:AwsApiParser.ts Github

copy

Full Screen

1import { schemaComposer, ObjectTypeComposer } from 'graphql-compose';2import type { GraphQLObjectType, GraphQLFieldConfig } from 'graphql-compose/lib/graphql';3import { AwsService, ServiceConfig } from './AwsService';4import AwsConfigITC from './types/AwsConfigITC';5export type AwsSDK = any;6type AwsOpts = {7 name?: string;8 awsSDK?: AwsSDK;9};10export class AwsApiParser<TContext = any> {11 name: string;12 awsSDK: AwsSDK;13 tc?: ObjectTypeComposer<any, TContext>;14 _serviceMap: { [serviceIdentifier: string]: string };15 constructor(opts: AwsOpts) {16 this.name = opts.name || 'Aws';17 this.awsSDK = opts.awsSDK;18 this._serviceMap = {};19 this.getServicesNames();20 }21 getServicesNames(): string[] {22 const serviceNames = Object.keys(this.awsSDK).reduce((res, name) => {23 if (this.awsSDK[name].serviceIdentifier) {24 this._serviceMap[this.awsSDK[name].serviceIdentifier] = name;25 res.push(name);26 }27 return res;28 }, [] as string[]);29 serviceNames.sort();30 return serviceNames;31 }32 getServiceIdentifier(name: string): string {33 if (this._serviceMap[name]) return name;34 if (!this.awsSDK[name]) {35 throw new Error(`Service with name '${name}' does not exist. Run AwsApiParser.`);36 }37 return this.awsSDK[name].serviceIdentifier;38 }39 getServiceConfig(name: string): ServiceConfig {40 const cfg = this.awsSDK.apiLoader.services[this.getServiceIdentifier(name)];41 if (!cfg) {42 throw new Error(`Service with name '${name}' does not exist.`);43 }44 const versions = Object.keys(cfg);45 if (versions.length === 1) {46 return cfg[versions[0]];47 }48 versions.sort();49 return cfg[versions[versions.length - 1]];50 }51 getService(name: string): AwsService<TContext> {52 const config = this.getServiceConfig(name);53 // console.log(config);54 return new AwsService({55 serviceId: this._serviceMap[name] || name,56 prefix: this.name,57 config,58 awsSDK: this.awsSDK,59 });60 }61 getTypeComposer(): ObjectTypeComposer<any, TContext> {62 if (!this.tc) {63 const fields = this.getServicesNames().reduce((res, name) => {64 res[this.getServiceIdentifier(name)] = this.getService(name).getFieldConfig();65 return res;66 }, {} as any);67 this.tc = schemaComposer.createObjectTC({68 name: this.name,69 fields,70 description: `AWS SDK ${this.awsSDK.VERSION}`,71 });72 }73 return this.tc;74 }75 getType(): GraphQLObjectType {76 return this.getTypeComposer().getType();77 }78 getFieldConfig(): GraphQLFieldConfig<any, any> {79 return {80 type: this.getType(),81 args: {82 config: {83 type: AwsConfigITC.getType(),84 description: 'Will override default configs for aws-sdk.',85 },86 },87 resolve: (source, args) => ({88 awsConfig: { ...(source && source.awsConfig), ...(args && args.config) },89 }),90 description: this.getTypeComposer().getDescription(),91 };92 }...

Full Screen

Full Screen

files_0.js

Source:files_0.js Github

copy

Full Screen

1var searchData=2[3 ['aws_5fiot_5ferror_2eh',['aws_iot_error.h',['../aws__iot__error_8h.html',1,'']]],4 ['aws_5fiot_5flog_2eh',['aws_iot_log.h',['../aws__iot__log_8h.html',1,'']]],5 ['aws_5fiot_5fmqtt_5fclient_2ec',['aws_iot_mqtt_client.c',['../aws__iot__mqtt__client_8c.html',1,'']]],6 ['aws_5fiot_5fmqtt_5fclient_2eh',['aws_iot_mqtt_client.h',['../aws__iot__mqtt__client_8h.html',1,'']]],7 ['aws_5fiot_5fmqtt_5fclient_5fcommon_5finternal_2ec',['aws_iot_mqtt_client_common_internal.c',['../aws__iot__mqtt__client__common__internal_8c.html',1,'']]],8 ['aws_5fiot_5fmqtt_5fclient_5fcommon_5finternal_2eh',['aws_iot_mqtt_client_common_internal.h',['../aws__iot__mqtt__client__common__internal_8h.html',1,'']]],9 ['aws_5fiot_5fmqtt_5fclient_5fconnect_2ec',['aws_iot_mqtt_client_connect.c',['../aws__iot__mqtt__client__connect_8c.html',1,'']]],10 ['aws_5fiot_5fmqtt_5fclient_5fpublish_2ec',['aws_iot_mqtt_client_publish.c',['../aws__iot__mqtt__client__publish_8c.html',1,'']]],11 ['aws_5fiot_5fmqtt_5fclient_5fsubscribe_2ec',['aws_iot_mqtt_client_subscribe.c',['../aws__iot__mqtt__client__subscribe_8c.html',1,'']]],12 ['aws_5fiot_5fmqtt_5fclient_5funsubscribe_2ec',['aws_iot_mqtt_client_unsubscribe.c',['../aws__iot__mqtt__client__unsubscribe_8c.html',1,'']]],13 ['aws_5fiot_5fmqtt_5fclient_5fyield_2ec',['aws_iot_mqtt_client_yield.c',['../aws__iot__mqtt__client__yield_8c.html',1,'']]],14 ['aws_5fiot_5fshadow_2ec',['aws_iot_shadow.c',['../aws__iot__shadow_8c.html',1,'']]],15 ['aws_5fiot_5fshadow_5factions_2ec',['aws_iot_shadow_actions.c',['../aws__iot__shadow__actions_8c.html',1,'']]],16 ['aws_5fiot_5fshadow_5finterface_2eh',['aws_iot_shadow_interface.h',['../aws__iot__shadow__interface_8h.html',1,'']]],17 ['aws_5fiot_5fshadow_5fjson_2ec',['aws_iot_shadow_json.c',['../aws__iot__shadow__json_8c.html',1,'']]],18 ['aws_5fiot_5fshadow_5fjson_5fdata_2eh',['aws_iot_shadow_json_data.h',['../aws__iot__shadow__json__data_8h.html',1,'']]],19 ['aws_5fiot_5ftest_5fauto_5freconnect_2ec',['aws_iot_test_auto_reconnect.c',['../aws__iot__test__auto__reconnect_8c.html',1,'']]],20 ['aws_5fiot_5ftest_5fbasic_5fconnectivity_2ec',['aws_iot_test_basic_connectivity.c',['../aws__iot__test__basic__connectivity_8c.html',1,'']]],21 ['aws_5fiot_5ftest_5fintegration_5fcommon_2eh',['aws_iot_test_integration_common.h',['../aws__iot__test__integration__common_8h.html',1,'']]],22 ['aws_5fiot_5ftest_5fintegration_5frunner_2ec',['aws_iot_test_integration_runner.c',['../aws__iot__test__integration__runner_8c.html',1,'']]],23 ['aws_5fiot_5ftest_5fmultiple_5fclients_2ec',['aws_iot_test_multiple_clients.c',['../aws__iot__test__multiple__clients_8c.html',1,'']]],24 ['aws_5fiot_5fversion_2eh',['aws_iot_version.h',['../aws__iot__version_8h.html',1,'']]]...

Full Screen

Full Screen

AwsApiParser-test.ts

Source:AwsApiParser-test.ts Github

copy

Full Screen

1import awsSDK from 'aws-sdk';2import { AwsApiParser } from '../AwsApiParser';3import { AwsService } from '../AwsService';4import AwsConfigITC from '../types/AwsConfigITC';5describe('AwsApiParser', () => {6 const aws = new AwsApiParser({7 awsSDK,8 });9 it('getServicesNames()', () => {10 const names = aws.getServicesNames();11 expect(names).toContain('S3');12 expect(names).toContain('EC2');13 expect(names).toContain('Route53');14 expect(names).toContain('SQS');15 });16 it('getServiceIdentifier()', () => {17 expect(aws.getServiceIdentifier('S3')).toBe('s3');18 // also should work if provided serviceIdentifier19 expect(aws.getServiceIdentifier('s3')).toBe('s3');20 });21 it('getServiceConfig()', () => {22 const cfg = aws.getServiceConfig('S3');23 expect(Object.keys(cfg)).toEqual([24 'version',25 'metadata',26 'operations',27 'shapes',28 'paginators',29 'waiters',30 ]);31 // get config by serviceIdentifier32 const cfg2 = aws.getServiceConfig('s3');33 expect(Object.keys(cfg2)).toEqual([34 'version',35 'metadata',36 'operations',37 'shapes',38 'paginators',39 'waiters',40 ]);41 });42 it('getService()', () => {43 const service = aws.getService('S3');44 expect(service).toBeInstanceOf(AwsService);45 // get service by serviceIdentifier46 const service2 = aws.getService('s3');47 expect(service2).toBeInstanceOf(AwsService);48 });49 it('getType()', () => {50 const type = aws.getType();51 expect(type.name).toBe('Aws');52 });53 it('getFieldConfig()', () => {54 const fc: any = aws.getFieldConfig();55 expect(fc.type).toBe(aws.getType());56 expect(fc.args.config.type).toBe(AwsConfigITC.getType());57 expect(fc.resolve()).toEqual({ awsConfig: {} });58 });...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run pact-foundation-pact automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful