go-mokapi 0.7.0 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,7 +1,10 @@
1
1
  <p align="center">
2
- <img src="https://github.com/marle3003/mokapi/raw/v0.5.0/logo.svg" alt="Mokapi" title="Mokapi" width="400" />
2
+ <img src="https://github.com/marle3003/mokapi/raw/v0.5.0/logo.svg" alt="Mokapi" title="Mokapi" width="300" />
3
3
  </p>
4
4
 
5
+ <h3 align="center">Create and test API designs<br />before actually building them</h3>
6
+
7
+
5
8
  ## Overview
6
9
 
7
10
  Mokapi is a tool that allows developers to create and test API designs before actually building them. It works by emulating API responses based on the designs that have been created, which allows developers to test different configurations and edge cases without having to rely on a fully built API.
@@ -18,4 +21,14 @@ By using Mokapi, developers can reduce the time and effort required for developm
18
21
 
19
22
  ```shell
20
23
  npx mokapi --Providers.File.Directory=./mokapi
21
- ```
24
+ ```
25
+
26
+ ## Documentation
27
+
28
+ - [Get Started](https://mokapi.io/docs/guides/get-started/welcome)
29
+ - [HTTP](https://mokapi.io/docs/guides/http/overview)
30
+ - [Kafka](https://mokapi.io/docs/guides/kafka/overview)
31
+ - [LDAP](https://mokapi.io/docs/guides/ldap/overview)
32
+ - [SMTP](https://mokapi.io/docs/guides/smtp/overview)
33
+ - [Javascript API](https://mokapi.io/docs/javascript-api)
34
+ - [Examples](https://mokapi.io/docs/examples)
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "go-mokapi",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "description": "Create and test API designs before actually building them.",
5
5
  "homepage": "http://mokapi.io",
6
6
  "repository": {
package/types/faker.d.ts CHANGED
@@ -1,4 +1,8 @@
1
- declare module 'faker' {
1
+ declare module 'mokapi/faker' {
2
+ /**
3
+ * Creates a fake based on the given schema
4
+ * @param schema
5
+ */
2
6
  function fake(schema: Schema): any
3
7
  }
4
8
 
package/types/http.d.ts CHANGED
@@ -1,21 +1,20 @@
1
- declare module 'mustache' {
2
- function get(url: string, args: Args): Response
3
- function post(url: string, body: string, args: Args): Response
4
- function put(url: string, body: string, args: Args): Response
5
- function head(url: string, args: Args): Response
6
- function patch(url: string, args: Args): Response
7
- function del(url: string, body: string, args: Args): Response
8
- function options(url: string, body: string, args: Args): Response
1
+ declare module 'mokapi/http' {
2
+ function get(url: string, args?: Args): Response
3
+ function post(url: string, body?: any, args?: Args): Response
4
+ function put(url: string, body?: any, args?: Args): Response
5
+ function head(url: string, args?: Args): Response
6
+ function patch(url: string, args?: Args): Response
7
+ function del(url: string, body?: any, args?: Args): Response
8
+ function options(url: string, body?: any, args?: Args): Response
9
9
  }
10
10
 
11
- type Header = { [name: string]: string };
12
-
13
11
  declare interface Args {
14
- header?: Header;
12
+ header?: { [name: string]: any };
15
13
  }
16
14
 
17
15
  declare interface Response {
18
16
  body: string
19
17
  statusCode: number
20
- headers: Header
18
+ headers: { [name: string]: string[] }
19
+ json(): any
21
20
  }
package/types/kafka.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- declare module 'kafka' {
1
+ declare module 'mokapi/kafka' {
2
2
  function produce(args: ProduceArgs): ProduceResult
3
3
  }
4
4
 
@@ -12,7 +12,10 @@ declare interface ProduceArgs {
12
12
  }
13
13
 
14
14
  declare interface ProduceResult {
15
- key: any
16
- value: any
17
- error?: string
15
+ cluster: string
16
+ topic: string
17
+ partition: number
18
+ offset: number
19
+ key: string
20
+ value: string
18
21
  }
package/types/mokapi.d.ts CHANGED
@@ -1,15 +1,26 @@
1
1
  declare module 'mokapi' {
2
+
2
3
  /** Listener for http events. */
3
- function on(event: 'http', f: HttpEventHandler): void
4
+ function on(event: 'http', f: EventHandler, args: EventArgs): void
5
+
4
6
  /** Schedules a new periodic job with interval.
5
7
  * Interval string is a possibly signed sequence of
6
8
  * decimal numbers, each with optional fraction and a unit suffix,
7
9
  * such as "300ms", "-1.5h" or "2h45m".
8
10
  * Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
9
11
  */
10
- function every(interval: string, f: function(): void): void
12
+ function every(interval: string, f: ScheduledEventHandler, args: ScheduledEventArgs): void
13
+
14
+ /**
15
+ * Schedules a new periodic job with a cron expression.
16
+ * @param expr cron expression
17
+ * @param f function to execute
18
+ * @param args additional arguments
19
+ */
20
+ function cron(expr: string, f: ScheduledEventHandler, args: ScheduledEventArgs): void
21
+
11
22
  /** Returns the environment variable named by the key. */
12
- function env(key: string): string
23
+ function env(name: string): string
13
24
 
14
25
  /** Opens a file and reading all its content. */
15
26
  function open(path: string): string
@@ -19,8 +30,17 @@ declare module 'mokapi' {
19
30
  * Default layout is RFC3339.
20
31
  * Default timestamp is current UTC */
21
32
  function date(args?: DateArgs): string
33
+
34
+ /**
35
+ * Suspends the execution for the specified duration.
36
+ * Valid time units are `ns`, `us` (or `µs`), `ms`, `s`, `m`, `h`
37
+ * @param time Duration in milliseconds or duration as string with unit.
38
+ */
39
+ function sleep(time: number | string )
22
40
  }
23
41
 
42
+ type EventHandler = () => boolean | HttpEventHandler
43
+
24
44
  type HttpEventHandler = (request: HttpRequest, response: HttpResponse) => boolean
25
45
 
26
46
  declare interface HttpRequest {
@@ -40,7 +60,7 @@ declare interface HttpRequest {
40
60
  cookie: { [key: string]: any; }
41
61
  /** Path defined in OpenAPI. */
42
62
  key: string
43
- /** OperationId definied in OpenAPI. */
63
+ /** OperationId defined in OpenAPI. */
44
64
  operationId: string
45
65
  }
46
66
 
@@ -71,4 +91,30 @@ declare interface DateArgs {
71
91
  timestamp?: number
72
92
  }
73
93
 
74
- const RFC3339 = "RFC3339"
94
+ declare interface EventArgs {
95
+ /**
96
+ * Adds or overrides existing tags used in dashboard
97
+ */
98
+ tags: {[key: string]: string}
99
+ }
100
+
101
+ type ScheduledEventHandler = () => void
102
+
103
+ declare interface ScheduledEventArgs {
104
+ /**
105
+ * Adds or overrides existing tags used in dashboard
106
+ */
107
+ tags: {[key: string]: string}
108
+
109
+ /**
110
+ * Defines the number of times the scheduled function is executed.
111
+ */
112
+ times: number
113
+
114
+ /**
115
+ * Toggles behavior of first execution. Default is true
116
+ */
117
+ runFirstTimeImmediately: boolean
118
+ }
119
+
120
+ declare const RFC3339 = "RFC3339"
@@ -1,3 +1,3 @@
1
- declare module 'mustache' {
1
+ declare module 'mokapi/mustache' {
2
2
  function render(template: string, data: any): string
3
3
  }
package/types/yaml.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- declare module 'yaml' {
1
+ declare module 'mokapi/yaml' {
2
2
  function parse(s: string): any
3
3
  function stringify(value: any): string
4
4
  }