openwhisk-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rab...@apache.org
Subject [incubator-openwhisk-client-js] branch master updated: Adding type definitions for typescript (#72)
Date Mon, 02 Oct 2017 14:13:20 GMT
This is an automated email from the ASF dual-hosted git repository.

rabbah pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk-client-js.git


The following commit(s) were added to refs/heads/master by this push:
     new 401fdc5  Adding type definitions for typescript (#72)
401fdc5 is described below

commit 401fdc50a76e42e9253ca763aca3ab418539e408
Author: Guillaume Baudart <guillaume.baudart@gmail.com>
AuthorDate: Mon Oct 2 10:13:18 2017 -0400

    Adding type definitions for typescript (#72)
    
    * Adding type definitions for typescript
    * Requested changes
    * Adding type support for sequences
---
 lib/main.d.ts | 294 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 package.json  |   7 +-
 2 files changed, 299 insertions(+), 2 deletions(-)

diff --git a/lib/main.d.ts b/lib/main.d.ts
new file mode 100644
index 0000000..f2815e6
--- /dev/null
+++ b/lib/main.d.ts
@@ -0,0 +1,294 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more contributor
+// license agreements; and to You under the Apache License, Version 2.0.
+
+import * as Swagger from 'swagger-schema-official'
+
+export = openwhisk;
+
+declare function openwhisk(options?: openwhisk.Options): openwhisk.Client;
+
+declare namespace openwhisk {
+    interface Options {
+        api?: string;
+        api_key?: string;
+        apihost?: string;
+        namespace?: string;
+        ignore_certs?: boolean;
+        apigw_token?: string;
+        apigw_space_guid?: string;
+    }
+
+    // Client
+
+    interface Client {
+        actions: Actions;
+        activations: Activations;
+        namespaces: Namespaces;
+        packages: Packages;
+        rules: Rules;
+        triggers: Triggers;
+        feeds: Feeds;
+        routes: Routes;
+    }
+
+    // Ressources
+
+    interface Actions {
+        list(options?: { namespace?: string; skip?: number; limit?: number; }): Promise<ActionDesc[]>;
+        get(options: string): Promise<Action>
+        get(options: { name: string; namespace?: string }): Promise<Action>;
+        get(options: (string | { name: string; namespace?: string })[]): Promise<Action[]>;
+        invoke(options: string): Promise<{ activationId: string }>
+        invoke(options: { name: string; namespace?: string; blocking: true; params?: Dict;
result: true; }): Promise<Dict>;
+        invoke(options: { name: string; namespace?: string; blocking: true; params?: Dict;
result?: false; }): Promise<Activation<Dict>>;
+        invoke(options: { name: string; namespace?: string; blocking?: false; params?: Dict;
result?: boolean; }): Promise<{ activationId: string }>;
+        invoke(options: (string | { name: string; namespace?: string; blocking?: boolean;
params?: Dict; result?: boolean; })[]): Promise<{ activationId: string }[]>;
+        invoke<In extends Dict, Out extends Dict>(options: { name: string; namespace?:
string; blocking: true; params?: In; result: true; }): Promise<Out>;
+        invoke<In extends Dict, Out extends Dict>(options: { name: string; namespace?:
string; blocking: true; params?: In; result?: false; }): Promise<Activation<Out>>;
+        invoke<In extends Dict, Out extends Dict>(options: { name: string; namespace?:
string; blocking?: false; params?: In; result?: boolean; }): Promise<{ activationId: string
}>;
+        create(options: { name: string; namespace?: string; action: (string | Buffer | Action);
kind?: Kind; overwrite?: boolean; params?: Dict; version?: string; }): Promise<Action>;
+        //create(options: { name: string; namespace?: string; action: (string | Buffer |
Action); kind?: Kind; overwrite?: boolean; params?: Dict; version?: string; }[]): Promise<Action[]>;
+        update(options: { name: string; namespace?: string; action: (string | Buffer | Action);
kind?: Kind; params?: Dict; version?: string; }): Promise<Action>;
+        //update(options: ({ name: string; namespace?: string; action: (string | Buffer |
Action); kind?: Kind; params?: Dict; version?: string; })[]): Promise<Action[]>;
+        delete(options: string): Promise<Action>;
+        delete(options: { name: string; namespace?: string; }): Promise<Action>;
+        delete(options: (string | { name: string; namespace?: string; })[]): Promise<Action[]>;
+    }
+
+    interface Activations {
+        list(options?: { namespace?: string; name?: string; skip?: number; limit?: number;
upto?: number; docs?: boolean; since?: number }): Promise<ActivationDesc[]>;
+        get<T extends Dict>(options: string): Promise<Activation<T>>;
+        get<T extends Dict>(options: { name: string; namespace?: string }): Promise<Activation<T>>;
+        get(options: string): Promise<Activation<Dict>>;
+        get(options: { name: string; namespace?: string }): Promise<Activation<Dict>>;
+        //get(options: (string | { name: string; namespace?: string })[]): Promise<Activation<Dict>[]>;
+        logs(options: { name: string; namespace?: string }): Promise<{ logs: String[]
}>;
+        result<T extends Dict>(options: { name: string; namespace?: string }): Promise<Response<T>>;
+        result(options: { name: string; namespace?: string }): Promise<Response<Dict>>;
+    }
+
+    interface Namespaces {
+        list(): Promise<string[]>;
+        get(options: string): Promise<Namespace>
+        get(options: { namespace: string }): Promise<Namespace>
+        //get(options: (string | { namespace: string })[]): Promise<Namespace[]>
+    }
+
+    interface Packages {
+        list(options?: { namespace?: string; skip?: number; limit?: number; public?: boolean;
}): Promise<PackageDesc[]>;
+        get(options: string): Promise<Package>
+        get(options: { name: string; namespace?: string }): Promise<Package>;
+        get(options: (string | { name: string; namespace?: string })[]): Promise<Package[]>;
+        create(options: { name: string; namespace?: string; package?: Package; overwrite?:
boolean }): Promise<Package>;
+        update(options: { name: string; namespace?: string; package?: Package }): Promise<Package>;
+        delete(options: string): Promise<Package>
+        delete(options: { name: string; namespace?: string; }): Promise<Package>;
+        delete(options: (string | { name: string; namespace?: string; })[]): Promise<Package[]>;
+    }
+
+    interface Rules {
+        list(options?: { namespace?: string; skip?: number; limit?: number; }): Promise<RuleDesc[]>;
+        get(options: string): Promise<Rule>;
+        get(options: { name: string; namespace?: string; }): Promise<Rule>;
+        get(options: (string | { name: string; namespace?: string; })[]): Promise<Rule[]>;
+        create(options: { name: string; namespace?: string; action: string; trigger: string;
status?: Status; overwrite?: boolean }): Promise<Rule>;
+        update(options: { name: string; namespace?: string; action: string; trigger: string;
status?: Status }): Promise<Rule>;
+        delete(options: string): Promise<Rule>
+        delete(options: { name: string; namespace?: string; }): Promise<Rule>;
+        delete(options: (string | { name: string; namespace?: string; })[]): Promise<Rule[]>;
+        enable(options: { name: string; namespace?: string; }): Promise<String>;
+        disable(options: { name: string; namespace?: string; }): Promise<String>;
+    }
+
+    interface Triggers {
+        list(options?: { namespace?: string; skip?: number; limit?: number; }): Promise<TriggerDesc[]>;
+        get(options: string): Promise<Trigger>
+        get(options: { name: string; namespace?: string; }): Promise<Trigger>;
+        get(options: (string | { name: string; namespace?: string; })[]): Promise<Trigger[]>;
+        invoke(options: string): Promise<{ activationId: string }>
+        invoke(options: { name: string; namespace?: string; params?: Dict }): Promise<{
activationId: string }>
+        invoke(options: (string | { name: string; namespace?: string; params?: Dict })[]):
Promise<{ activationId: string }[]>
+        invoke<T extends Dict>(options: { name: string; namespace?: string; params?:
T }): Promise<{ activationId: string }>
+        create(options: { name: string; namespace?: string; trigger?: Trigger; overwrite?:
boolean; }): Promise<Trigger>;
+        update(options: { name: string; namespace?: string; trigger?: Trigger }): Promise<Trigger>;
+        delete(options: string): Promise<Trigger>
+        delete(options: { name: string; namespace?: string; }): Promise<Trigger>;
+        delete(options: (string | { name: string; namespace?: string; })[]): Promise<Trigger[]>;
+    }
+
+    interface Feeds {
+        create(options: { name: string; trigger: string; namespace?: string; params?: Dict
}): Promise<Activation<FeedActionDesc>>;
+        delete(options: { name: string; trigger: string; namespace?: string; }): Promise<Activation<FeedActionDesc>>;
+        feed(event: Event, options: { name: string; trigger: string; namespace?: string;
}): Promise<Activation<FeedActionDesc>>;
+    }
+
+    interface Routes {
+        list(options?: { relpath?: string, basepath?: string, operation?: string, limit?:
number, skip?: number }): Promise<{ apis: Route[] }>;
+        delete(options: { basepath: string; relpath?: string, operation?: Operation }): Promise<{}>;
+        create(options: { basepath?: string; relpath: string, operation: Operation, action:
string }): Promise<Api>;
+    }
+
+    // Descriptions
+
+    interface ShortDesc {
+        name: string;
+        annotations?: KeyVal[];
+        version?: string;
+    }
+
+    interface Desc extends ShortDesc {
+        publish?: boolean;
+        namespace?: string;
+    }
+
+    type ActionDesc = Desc
+
+    interface ActivationDesc extends Desc {
+        activationId: string;
+    }
+
+    interface PackageDesc extends Desc {
+        binding?: boolean;
+    }
+
+    type RuleDesc = Desc
+
+    type TriggerDesc = Desc
+
+    interface FeedActionDesc {
+        lifecycleEvent: Event;
+        authKey: string;
+        triggerName: string;
+    }
+
+    // Entities
+
+    interface Action extends ActionDesc {
+        parameters?: KeyVal[];
+        limits?: Limits;
+        exec: Exec | Sequence;
+    }
+
+    interface Activation<T extends Dict> extends ActivationDesc {
+        subject: string;
+        start: number;
+        end: number;
+        duration: number;
+        response?: Response<T>;
+        logs: string[];
+    }
+
+    interface Namespace {
+        actions?: ActionDesc[];
+        packages?: PackageDesc[];
+        rules?: RuleDesc[];
+        triggers?: TriggerDesc[];
+    }
+
+    interface Package extends Desc {
+        actions?: ShortDesc[];
+        feeds?: ShortDesc[];
+        parameters?: KeyVal[];
+        binding?: {} | Package;
+    }
+
+    interface Rule extends RuleDesc {
+        trigger: PathName;
+        status: Status;
+        action: PathName;
+    }
+
+    interface Trigger extends TriggerDesc {
+        parameters?: KeyVal[];
+        limits?: any;
+    }
+
+    interface Route {
+        id: string;
+        key: string;
+        value: Api;
+    }
+
+    // Other
+
+    interface Dict {
+        [key: string]: any
+    }
+
+    interface Exec {
+        kind: Kind;
+        code: string;
+        binary?: boolean
+    }
+
+    interface Sequence {
+        kind: "sequence";
+        components: string[];
+    }
+
+    type Kind =
+        "" |
+        "nodejs:default" |
+        "nodejs:6" |
+        "python:default" |
+        "python:3" |
+        "python:2" |
+        "swift:default" |
+        "swift:3.1.1" |
+        "php:default" |
+        "php:7.1";
+
+    interface Limits {
+        timeout: number;
+        memory: number;
+        logs: number;
+    }
+
+    interface Response<T extends Dict> {
+        status: "success" | "failure";
+        statusCode?: number;
+        success: boolean;
+        result: T
+    }
+
+    interface KeyVal {
+        key: string;
+        value: any;
+    }
+
+    interface PathName {
+        path: string;
+        name: string;
+    }
+
+    type Status =
+        "" |
+        "active" |
+        "inactive" |
+        "activating" |
+        "deactivating";
+
+    type Event =
+        "" |
+        "CREATE" |
+        "DELETE" |
+        "PAUSE" |
+        "UNPAUSE"
+
+    type Operation =
+        "" |
+        "GET" |
+        "POST" |
+        "PUT" |
+        "PATCH" |
+        "DELETE"
+
+    interface Api {
+        namespace: string;
+        gwApiActivated: boolean;
+        tenantId: boolean;
+        gwApiUrl: string;
+        apidoc: Swagger.Spec;
+    }
+
+}
\ No newline at end of file
diff --git a/package.json b/package.json
index e3cdec8..8a7f3e1 100644
--- a/package.json
+++ b/package.json
@@ -3,6 +3,7 @@
   "version": "3.6.0",
   "description": "JavaScript client library for the OpenWhisk platform",
   "main": "lib/main.js",
+  "typings": "lib/main.d.ts",
   "engines": {
     "node": ">=4.0.0"
   },
@@ -41,7 +42,9 @@
     "proxyquire": "1.7.4"
   },
   "dependencies": {
-    "request-promise": "^2.0.1"
+    "request-promise": "^2.0.1",
+    "@types/node": "^8.0.26",
+    "@types/swagger-schema-official": "^2.0.6"
   },
   "babel": {
     "presets": [
@@ -62,4 +65,4 @@
       "babel-core/register"
     ]
   }
-}
+}
\ No newline at end of file

-- 
To stop receiving notification emails like this one, please contact
['"commits@openwhisk.apache.org" <commits@openwhisk.apache.org>'].

Mime
View raw message