go-mokapi 0.7.1 → 0.7.3

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
@@ -2,7 +2,7 @@
2
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>
5
+ <h3 align="center">Easy and flexible API mocking</h3>
6
6
 
7
7
 
8
8
  ## Overview
package/bin/mokapi.js CHANGED
@@ -5,7 +5,7 @@ let path = require('path');
5
5
  const ARCH_MAPPING = {
6
6
  "ia32": "386",
7
7
  "x64": "amd64",
8
- "arm": "arm"
8
+ "arm64": "arm64"
9
9
  };
10
10
 
11
11
  // Mapping between Node's `process.platform` to Golang's
Binary file
Binary file
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "go-mokapi",
3
- "version": "0.7.1",
4
- "description": "Create and test API designs before actually building them.",
5
- "homepage": "http://mokapi.io",
3
+ "version": "0.7.3",
4
+ "description": "Easy and flexible API mocking",
5
+ "homepage": "https://mokapi.io",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "https://github.com/marle3003/mokapi.git"
package/types/kafka.d.ts CHANGED
@@ -18,4 +18,19 @@ declare interface ProduceResult {
18
18
  offset: number
19
19
  key: string
20
20
  value: string
21
+ }
22
+
23
+ type KafkaEventHandler = (record: KafkaRecord) => boolean
24
+
25
+ declare interface KafkaRecord {
26
+ offset: number
27
+ time: number
28
+ key: number[]
29
+ value: number[]
30
+ headers: KafkaHeader[]
31
+ }
32
+
33
+ declare interface KafkaHeader {
34
+ key: string
35
+ value: string
21
36
  }
@@ -0,0 +1,54 @@
1
+ type LdapEventHandler = (request: LdapSearchRequest, response: LdapSearchResponse) => boolean
2
+
3
+ declare module 'mokapi/ldap' {
4
+ enum SearchScope {
5
+ BaseObject,
6
+ SingleLevel,
7
+ WholeSubtree
8
+ }
9
+ enum ResultCode {
10
+ Success = 0,
11
+ OperationsError = 1,
12
+ ProtocolError = 2,
13
+ SizeLimitExceeded = 3,
14
+ AuthMethodNotSupported = 4,
15
+ CannotCancel = 121
16
+ }
17
+ }
18
+
19
+ declare interface LdapSearchRequest {
20
+ baseDN: string
21
+ scope: LdapSearchScope,
22
+ dereferencePolicy: number,
23
+ sizeLimit: number,
24
+ timeLimit: number,
25
+ typesOnly: number,
26
+ filter: string
27
+ attributes: string[]
28
+ }
29
+
30
+ declare interface LdapSearchResponse{
31
+ results: LdapSearchResult[]
32
+ status: LdapResultStatus
33
+ message: string
34
+ }
35
+
36
+ declare interface LdapSearchResult {
37
+ dn: string
38
+ attributes: { [name: string]: string[] }
39
+ }
40
+
41
+ declare enum LdapSearchScope {
42
+ BaseObject,
43
+ SingleLevel,
44
+ WholeSubtree
45
+ }
46
+
47
+ declare enum LdapResultStatus {
48
+ Success = 0,
49
+ OperationsError = 1,
50
+ ProtocolError = 2,
51
+ SizeLimitExceeded = 3,
52
+ AuthMethodNotSupported = 4,
53
+ CannotCancel = 121
54
+ }
package/types/mokapi.d.ts CHANGED
@@ -1,7 +1,15 @@
1
- declare module 'mokapi' {
1
+ /// <reference path="ldap.d.ts" />
2
+ /// <reference path="kafka.d.ts" />
3
+ /// <reference path="smtp.d.ts" />
2
4
 
3
- /** Listener for http events. */
4
- function on(event: 'http', f: EventHandler, args: EventArgs): void
5
+ declare module 'mokapi' {
6
+ /**
7
+ * Attaches an event handler for the given event.
8
+ * @param event Event type such as http
9
+ * @param handler An EventHandler to execute when the event is triggered
10
+ * @param args EventArgs object contains additional event arguments.
11
+ */
12
+ function on<T extends keyof EventHandler>(event: T, handler: EventHandler[T], args?: EventArgs): void
5
13
 
6
14
  /** Schedules a new periodic job with interval.
7
15
  * Interval string is a possibly signed sequence of
@@ -9,7 +17,7 @@ declare module 'mokapi' {
9
17
  * such as "300ms", "-1.5h" or "2h45m".
10
18
  * Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
11
19
  */
12
- function every(interval: string, f: ScheduledEventHandler, args: ScheduledEventArgs): void
20
+ function every(interval: string, f: ScheduledEventHandler, args?: ScheduledEventArgs): void
13
21
 
14
22
  /**
15
23
  * Schedules a new periodic job with a cron expression.
@@ -17,7 +25,7 @@ declare module 'mokapi' {
17
25
  * @param f function to execute
18
26
  * @param args additional arguments
19
27
  */
20
- function cron(expr: string, f: ScheduledEventHandler, args: ScheduledEventArgs): void
28
+ function cron(expr: string, f: ScheduledEventHandler, args?: ScheduledEventArgs): void
21
29
 
22
30
  /** Returns the environment variable named by the key. */
23
31
  function env(name: string): string
@@ -39,7 +47,12 @@ declare module 'mokapi' {
39
47
  function sleep(time: number | string )
40
48
  }
41
49
 
42
- type EventHandler = () => boolean | HttpEventHandler
50
+ type EventHandler = {
51
+ http: HttpEventHandler
52
+ ldap: LdapEventHandler
53
+ kafka: KafkaEventHandler
54
+ smtp: SmtpEventHandler
55
+ }
43
56
 
44
57
  type HttpEventHandler = (request: HttpRequest, response: HttpResponse) => boolean
45
58
 
@@ -104,17 +117,17 @@ declare interface ScheduledEventArgs {
104
117
  /**
105
118
  * Adds or overrides existing tags used in dashboard
106
119
  */
107
- tags: {[key: string]: string}
120
+ tags?: {[key: string]: string}
108
121
 
109
122
  /**
110
123
  * Defines the number of times the scheduled function is executed.
111
124
  */
112
- times: number
125
+ times?: number
113
126
 
114
127
  /**
115
128
  * Toggles behavior of first execution. Default is true
116
129
  */
117
- runFirstTimeImmediately: boolean
130
+ runFirstTimeImmediately?: boolean
118
131
  }
119
132
 
120
133
  declare const RFC3339 = "RFC3339"
@@ -0,0 +1,39 @@
1
+ declare module 'mokapi/mail' {
2
+ /**
3
+ * Sends an email message to an SMTP server for delivery.
4
+ * @param server Host to which the message is to be sent.
5
+ * @param message a Message that contains the message to send.
6
+ */
7
+ function send(server: string, message: Message)
8
+ }
9
+
10
+ type SmtpEventHandler = (record: Message) => boolean
11
+
12
+ declare interface Message {
13
+ server: string
14
+ sender?: Address
15
+ from: Address[]
16
+ to: Address[]
17
+ replyTo?: Address[]
18
+ cc?: Address[]
19
+ bcc?: Address[]
20
+ messageId: string
21
+ inReplyTo?: string
22
+ time?: Date
23
+ subject: string
24
+ contentType: string
25
+ encoding: string
26
+ body: string
27
+ attachments: Attachment[]
28
+ }
29
+
30
+ declare interface Address {
31
+ name?: string
32
+ address: string
33
+ }
34
+
35
+ declare interface Attachment {
36
+ name: string
37
+ contentType: string
38
+ data: Uint8Array
39
+ }