Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Refactor code to TypeScript #74

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 0 additions & 43 deletions .eslintrc

This file was deleted.

50 changes: 50 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
module.exports = {
env: {
es6: true,
node: true,
mocha: true,
jest: true
},
extends: ['standard'],
globals: {
Atomics: 'readonly',
SharedArrayBuffer: 'readonly'
},

parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module'
},
plugins: ['@typescript-eslint', 'chai-friendly'],
rules: {
indent: ['error', 'tab'],
'no-tabs': 0,
'brace-style': ['error', 'stroustrup'],
'arrow-parens': ['error', 'always'],
'no-control-regex': 0,
'no-useless-escape': 0,
'array-bracket-spacing': ['error', 'never'],
'object-curly-spacing': ['error', 'always'],
'lines-between-class-members': ['error', 'always'],
'padding-line-between-statements': [
'error',
{ blankLine: 'always', prev: '*', next: 'multiline-block-like' },
{ blankLine: 'always', prev: 'multiline-block-like', next: '*' },
{ blankLine: 'always', prev: 'multiline-expression', next: '*' },
{ blankLine: 'always', prev: '*', next: 'multiline-expression' },
{ blankLine: 'always', prev: '*', next: 'return' }
],
'space-before-function-paren': [
'error',
{
anonymous: 'always',
named: 'always',
asyncArrow: 'always'
}
],
'standard/no-callback-literal': 1,
'no-unused-expressions': 0,
'chai-friendly/no-unused-expressions': 2
}
}
14 changes: 0 additions & 14 deletions .jshintrc

This file was deleted.

3 changes: 0 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,5 @@ node_js:
- 10
- 12

before_script:
- npm install -g grunt-cli

notifications:
email: false
71 changes: 0 additions & 71 deletions Gruntfile.js

This file was deleted.

1 change: 0 additions & 1 deletion index.js

This file was deleted.

4 changes: 4 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node'
}
1 change: 1 addition & 0 deletions lib/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './mock';
14 changes: 14 additions & 0 deletions lib/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions lib/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

55 changes: 55 additions & 0 deletions lib/mock.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/// <reference types="node" />
import fs from 'fs-extra';
import { CopyObjectOutput, CopyObjectRequest, CreateBucketOutput, CreateBucketRequest, DeleteBucketRequest, DeleteObjectOutput, DeleteObjectRequest, DeleteObjectsOutput, DeleteObjectsRequest, GetObjectOutput, GetObjectRequest, GetObjectTaggingOutput, GetObjectTaggingRequest, HeadObjectOutput, HeadObjectRequest, ListObjectsOutput, ListObjectsRequest, ListObjectsV2Output, ListObjectsV2Request, PutObjectOutput, PutObjectRequest, PutObjectTaggingOutput, PutObjectTaggingRequest } from 'aws-sdk/clients/s3';
import { AWSError } from 'aws-sdk/lib/core';
declare type Cb<T = any> = (err: AWSError | null, data: T) => void;
/** FakeStream class for mocking S3 streams */
declare class FakeStream {
private src;
constructor(search: {
Bucket: string;
Key: string;
});
createReadStream(): fs.ReadStream;
}
interface S3MockOptions {
params: any;
}
declare class S3Mock {
private objectMetadataDictionary;
private objectTaggingDictionary;
private defaultOptions;
private config;
constructor(options?: S3MockOptions);
listObjectsV2(searchV2: ListObjectsV2Request, callback: Cb<ListObjectsV2Output>): void;
listObjects(search: ListObjectsRequest, callback: Cb<ListObjectsOutput>): void;
getSignedUrl(operation: 'getObject' | 'putObject', params: {
Bucket: string;
Key: string;
}, callback: Cb): string | {
statusCode: number;
} | undefined;
deleteObjects(search: DeleteObjectsRequest, callback: Cb<DeleteObjectsOutput>): void;
deleteObject(search: DeleteObjectRequest, callback: Cb<DeleteObjectOutput>): void;
headObject(search: HeadObjectRequest, callback: Cb<HeadObjectOutput>): FakeStream | undefined;
copyObject(search: CopyObjectRequest, callback: Cb<CopyObjectOutput>): void;
getObject(search: GetObjectRequest, callback: Cb<GetObjectOutput>): FakeStream | undefined;
createBucket(params: CreateBucketRequest, callback: Cb<CreateBucketOutput>): void;
/**
* Deletes a bucket. Behaviour as createBucket
* @param params {Bucket: bucketName}. Name of bucket to delete
* @param callback
* @returns void
*/
deleteBucket(params: DeleteBucketRequest, callback: Cb<{}>): void;
putObject(search: PutObjectRequest, callback: Cb<PutObjectOutput>): {
send: (cb: any) => void;
};
getObjectTagging(search: GetObjectTaggingRequest, callback: Cb<GetObjectTaggingOutput>): void;
putObjectTagging(search: PutObjectTaggingRequest, callback: Cb<PutObjectTaggingOutput>): void;
upload(search: any, options: any, callback: Cb): void | {
send: (cb: any) => void;
};
}
export declare const S3: (options: S3MockOptions) => S3Mock;
export {};
Loading