Skip to content

Commit

Permalink
Merge pull request #19 from hossam-magdy/add-ts-support
Browse files Browse the repository at this point in the history
Add typings for TypeScript support
  • Loading branch information
stefanodefaria authored Jul 17, 2020
2 parents bf1ee37 + b3b7ee2 commit 2d7eba0
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
43 changes: 43 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
declare class SwiftClient {
constructor(authenticator: SwiftClient.SwiftAuthenticator);

container(name: string): SwiftClient.SwiftContainer;
}

declare namespace SwiftClient {
export class SwiftAuthenticator {
constructor(url: string, username: string, password: string);
}

export class SwiftContainer {
list(
extra?: { [s: string]: string },
// @see: https://developer.openstack.org/api-ref/object-store/?expanded=show-container-details-and-list-objects-detail#show-account-details-and-list-containers
query?: string | { [s: string]: string }
): Promise<SwiftObject[]>;
get(name: string, stream: WritableStream): Promise<void>;
create(
name: string,
stream: ReadableStream,
meta?: { [s: string]: string },
extra?: { [s: string]: string }
): Promise<void>;
meta(name: string): Promise<SwiftObjectMeta>;
delete(name: string, when?: Date | number): Promise<void>;
}

interface SwiftObject {
bytes: number; // 3344
content_type: string; // "application/json"
hash: string; // "28c3c00641adc0da09400d1d9a1aec91"
name: string; // "0157f866cdd5cd92b14f261865000c92/Export-Xing.json"
last_modified: string; // "2016-09-09T12:30:09.181050"
}

interface SwiftObjectMeta {
author: string;
year: string;
}
}

export = SwiftClient;
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "2.1.1",
"description": "Connects to OpenStack Swift storage servers",
"main": "index.js",
"types": "index.d.ts",
"directories": {
"test": "test"
},
Expand Down

0 comments on commit 2d7eba0

Please sign in to comment.