go-mokapi 0.9.16 → 0.9.17
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/dist/mokapi-darwin-arm64/mokapi +0 -0
- package/dist/mokapi-linux-amd64/mokapi +0 -0
- package/dist/mokapi-windows-amd64/mokapi.exe +0 -0
- package/package.json +1 -1
- package/types/faker.d.ts +23 -265
- package/types/http.d.ts +17 -117
- package/types/kafka.d.ts +29 -106
- package/types/ldap.d.ts +40 -104
- package/types/mustache.d.ts +2 -33
- package/types/yaml.d.ts +4 -38
- package/types/global.d.ts +0 -27
- package/types/index.d.ts +0 -275
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
package/types/faker.d.ts
CHANGED
|
@@ -1,269 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Creates a fake based on the given schema
|
|
5
|
-
* https://mokapi.io/docs/javascript-api/mokapi-faker/fake
|
|
6
|
-
* @param schema schema - OpenAPI Schema object contains definition of a type
|
|
7
|
-
* @example
|
|
8
|
-
* export default function() {
|
|
9
|
-
* console.log(fake({type: 'string'}))
|
|
10
|
-
* console.log(fake({type: 'number'}))
|
|
11
|
-
* console.log(fake({type: 'string', format: 'date-time'}))
|
|
12
|
-
* console.log(fake({type: 'string', pattern: '^\d{3}-\d{2}-\d{4}$'})) // 123-45-6789
|
|
13
|
-
* }
|
|
14
|
-
*/
|
|
15
|
-
export function fake(schema: Schema | FakeRequest): JSONValue;
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Gets the tree node with the given name
|
|
19
|
-
* @param name name - tree node's name
|
|
20
|
-
* @example
|
|
21
|
-
* export default function() {
|
|
22
|
-
* const root = findByName(RootName)
|
|
23
|
-
* root.insert(0, { name: 'foo', test: () => { return true }, fake: () => { return 'foobar' } })
|
|
24
|
-
* console.log(fake({type: 'string'}))
|
|
25
|
-
* }
|
|
26
|
-
*/
|
|
27
|
-
export function findByName(name: string): Tree
|
|
28
|
-
|
|
29
|
-
export const RootName = 'Faker'
|
|
30
|
-
|
|
31
|
-
export interface Tree {
|
|
32
|
-
name: string
|
|
33
|
-
readonly test: () => boolean
|
|
34
|
-
readonly fake: () => JSONValue
|
|
35
|
-
|
|
36
|
-
append: (node: Tree | CustomTree) => void
|
|
37
|
-
insert: (index: number, node: Tree | CustomTree) => void
|
|
38
|
-
removeAt: (index: number) => void
|
|
39
|
-
remove: (name: string) => void
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export interface CustomTree {
|
|
43
|
-
name: string
|
|
44
|
-
test: (r: Request) => boolean
|
|
45
|
-
fake: (r: Request) => JSONValue
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export interface FakeRequest {
|
|
49
|
-
names: string[]
|
|
50
|
-
schema: JSONSchema
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export interface Request {
|
|
54
|
-
Path: PathElement[]
|
|
55
|
-
|
|
56
|
-
last: () => PathElement
|
|
57
|
-
lastName: () => string
|
|
58
|
-
lastSchema: () => JSONSchema
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export interface PathElement {
|
|
62
|
-
name: string
|
|
63
|
-
schema: JSONSchema
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* JSON Schema defines a JSON-based format for describing the structure of JSON data
|
|
68
|
-
* @example
|
|
69
|
-
* {
|
|
70
|
-
* "type": "string",
|
|
71
|
-
* "format": "email"
|
|
72
|
-
* }
|
|
73
|
-
*/
|
|
74
|
-
export interface JSONSchema {
|
|
75
|
-
/**
|
|
76
|
-
* Specifies the data type for a schema.
|
|
77
|
-
*/
|
|
78
|
-
type: string | string[]
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* The enum keyword is used to restrict a value to a fixed set of values.
|
|
82
|
-
*/
|
|
83
|
-
enum: unknown[]
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* The const keyword is used to restrict a value to a single value.
|
|
87
|
-
*/
|
|
88
|
-
const: unknown
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Contains a list of valid examples.
|
|
92
|
-
*/
|
|
93
|
-
examples: unknown[]
|
|
94
|
-
|
|
95
|
-
// Numbers
|
|
96
|
-
/**
|
|
97
|
-
* Restricts the number to a multiple of the given number
|
|
98
|
-
*/
|
|
99
|
-
multipleOf: number | undefined
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Restricts the number to a maximum number
|
|
103
|
-
*/
|
|
104
|
-
maximum: number | undefined
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Restricts the number to a exclusive maximum number
|
|
108
|
-
*/
|
|
109
|
-
exclusiveMaximum: number | undefined
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Restricts the number to a minimum number
|
|
113
|
-
*/
|
|
114
|
-
minimum: number | undefined
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Restricts the number to a exclusive minimum number
|
|
118
|
-
*/
|
|
119
|
-
exclusiveMinimum: number | undefined
|
|
120
|
-
|
|
121
|
-
// Strings
|
|
122
|
-
/**
|
|
123
|
-
* Restricts the string to a maximum length
|
|
124
|
-
*/
|
|
125
|
-
maxLength: number | undefined
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* Restricts the string to a minimum length
|
|
129
|
-
*/
|
|
130
|
-
minLength: number | undefined
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* The pattern keyword is used to restrict a string to a particular regular expression.
|
|
134
|
-
*/
|
|
135
|
-
pattern: string
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* The format keyword allows for basic semantic identification of certain kinds of string values that are commonly used.
|
|
139
|
-
*/
|
|
140
|
-
format: string
|
|
141
|
-
|
|
142
|
-
// Arrays
|
|
143
|
-
/**
|
|
144
|
-
* Specifies the schema of the items in the array.
|
|
145
|
-
*/
|
|
146
|
-
items: JSONSchema | undefined
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* Restricts the array to have a maximum length
|
|
150
|
-
*/
|
|
151
|
-
maxItems: number | undefined
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* Restricts the array to have a minimum length
|
|
155
|
-
*/
|
|
156
|
-
minItems: number | undefined
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* Restricts the array to have unique items
|
|
160
|
-
*/
|
|
161
|
-
uniqueItems: boolean
|
|
162
|
-
|
|
163
|
-
// Objects
|
|
1
|
+
declare module 'mokapi/faker' {
|
|
164
2
|
/**
|
|
165
|
-
*
|
|
3
|
+
* Creates a fake based on the given schema
|
|
4
|
+
* @param schema
|
|
166
5
|
*/
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* Restricts the object to have a maximum of properties
|
|
171
|
-
*/
|
|
172
|
-
maxProperties: number | undefined
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* Restricts the object to have a minimum of properties
|
|
176
|
-
*/
|
|
177
|
-
minProperties: number | undefined
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* Specifies the required properties for an object
|
|
181
|
-
*/
|
|
182
|
-
required: string[] | undefined
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* The additionalProperties keyword is used to control the handling of extra stuff,
|
|
186
|
-
* that is, properties whose names are not listed in the properties keyword or match
|
|
187
|
-
* any of the regular expressions in the patternProperties keyword. By default, any
|
|
188
|
-
* additional properties are allowed.
|
|
189
|
-
*/
|
|
190
|
-
additionalProperties: boolean | JSONSchema | undefined
|
|
191
|
-
|
|
192
|
-
/**
|
|
193
|
-
* A value must be valid against all the schemas
|
|
194
|
-
*/
|
|
195
|
-
allOf: JSONSchema[] | undefined
|
|
196
|
-
|
|
197
|
-
/**
|
|
198
|
-
* A value must be valid against any the schemas
|
|
199
|
-
*/
|
|
200
|
-
anyOf: JSONSchema[] | undefined
|
|
201
|
-
|
|
202
|
-
/**
|
|
203
|
-
* A value must be valid against exactly one the schemas
|
|
204
|
-
*/
|
|
205
|
-
oneOf: JSONSchema[] | undefined
|
|
206
|
-
|
|
207
|
-
isAny: () => boolean
|
|
208
|
-
isString: () => boolean
|
|
209
|
-
isInteger: () => boolean
|
|
210
|
-
isNumber: () => boolean
|
|
211
|
-
isArray: () => boolean
|
|
212
|
-
isObject: () => boolean
|
|
213
|
-
isNullable: () => boolean
|
|
214
|
-
isDictionary: () => boolean
|
|
215
|
-
is: (typeName: string) => boolean
|
|
6
|
+
function fake(schema: Schema): any
|
|
216
7
|
}
|
|
217
8
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
/** Specifies the minimum range of possible values. */
|
|
238
|
-
minimum?: number;
|
|
239
|
-
|
|
240
|
-
/** Specifies the maximum range of possible values. */
|
|
241
|
-
maximum?: number;
|
|
242
|
-
|
|
243
|
-
/** Specifies whether minimum value is exluded. Default is false. */
|
|
244
|
-
exclusiveMinimum?: boolean;
|
|
245
|
-
|
|
246
|
-
/** ** Specifies whether maximum value is exluded. Default is false. */
|
|
247
|
-
exclusiveMaximum?: boolean;
|
|
248
|
-
|
|
249
|
-
/** Valid against one of the specified schemas. */
|
|
250
|
-
anyOf?: Schema[];
|
|
251
|
-
|
|
252
|
-
/** Valid against all of the specified schemas. */
|
|
253
|
-
allOf?: Schema[];
|
|
254
|
-
|
|
255
|
-
/** Valid against exactly one of the specified schemas. */
|
|
256
|
-
oneOf?: Schema[];
|
|
257
|
-
|
|
258
|
-
/** Specifies the minimum number of items an array must have. */
|
|
259
|
-
minItems?: number;
|
|
260
|
-
|
|
261
|
-
/** Specifies the maximum number of items an array must have. */
|
|
262
|
-
maxItems?: number;
|
|
263
|
-
|
|
264
|
-
/** Specifies whether items in array should have random order. The default is false */
|
|
265
|
-
shuffleItems?: boolean;
|
|
266
|
-
|
|
267
|
-
/** Specifies whether all items in an array must be unique. */
|
|
268
|
-
uniqueItems?: boolean;
|
|
269
|
-
}
|
|
9
|
+
declare interface Schema {
|
|
10
|
+
type: "object" | "array" | "number" | "integer" | "string" | "boolean"
|
|
11
|
+
format?: string
|
|
12
|
+
pattern?: string
|
|
13
|
+
items?: Schema
|
|
14
|
+
required?: string[]
|
|
15
|
+
enum?: any[]
|
|
16
|
+
minimum?: number
|
|
17
|
+
maximum?: number
|
|
18
|
+
exclusiveMinimum?: boolean
|
|
19
|
+
exclusiveMaximum?: boolean
|
|
20
|
+
anyOf?: Schema[]
|
|
21
|
+
allOf?: Schema[]
|
|
22
|
+
oneOf?: Schema[]
|
|
23
|
+
minItems?: number
|
|
24
|
+
maxItems?: number
|
|
25
|
+
shuffleItems?: boolean
|
|
26
|
+
uniqueItems?: boolean
|
|
27
|
+
}
|
package/types/http.d.ts
CHANGED
|
@@ -1,120 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
* @example
|
|
10
|
-
* get('https://mokapi.io')
|
|
11
|
-
*/
|
|
12
|
-
export function get(url: string, args?: Args): Response;
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Make POST request.
|
|
16
|
-
* https://mokapi.io/docs/javascript-api/mokapi-http/post
|
|
17
|
-
* @param url url - Request URL.
|
|
18
|
-
* @param body body - Request body.
|
|
19
|
-
* @param args args - Request arguments.
|
|
20
|
-
* @returns Resulting response.
|
|
21
|
-
* @example
|
|
22
|
-
* post("https://foo.bar/foo", { "foo":"bar" }, {
|
|
23
|
-
* headers: { 'Content-Type': "application/json" }
|
|
24
|
-
* })
|
|
25
|
-
*/
|
|
26
|
-
export function post(url: string, body?: JSONValue, args?: Args): Response;
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Make PUT request.
|
|
30
|
-
* https://mokapi.io/docs/javascript-api/mokapi-http/put
|
|
31
|
-
* @param url url - Request URL.
|
|
32
|
-
* @param body body - Request body.
|
|
33
|
-
* @param args args - Request arguments.
|
|
34
|
-
* @returns Resulting response.
|
|
35
|
-
* @example
|
|
36
|
-
* post("https://foo.bar/foo", { "foo":"bar" }, {
|
|
37
|
-
* headers: { 'Content-Type': "application/json" }
|
|
38
|
-
* })
|
|
39
|
-
*/
|
|
40
|
-
export function put(url: string, body?: JSONValue, args?: Args): Response;
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Make HEAD request.
|
|
44
|
-
* https://mokapi.io/docs/javascript-api/mokapi-http/head
|
|
45
|
-
* @param url url - Request URL.
|
|
46
|
-
* @param args args - Request arguments.
|
|
47
|
-
* @returns Resulting response.
|
|
48
|
-
* @example
|
|
49
|
-
* head("https://foo.bar/foo")
|
|
50
|
-
*/
|
|
51
|
-
export function head(url: string, args?: Args): Response;
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Make PATCH request.
|
|
55
|
-
* https://mokapi.io/docs/javascript-api/mokapi-http/patch
|
|
56
|
-
* @param url url - Request URL.
|
|
57
|
-
* @param body body - Request body.
|
|
58
|
-
* @param args args - Request arguments.
|
|
59
|
-
* @returns Resulting response.
|
|
60
|
-
* @example
|
|
61
|
-
* patch("https://foo.bar/foo")
|
|
62
|
-
*/
|
|
63
|
-
export function patch(url: string, body?: JSONValue, args?: Args): Response;
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Make PATCH request.
|
|
67
|
-
* https://mokapi.io/docs/javascript-api/mokapi-http/delete
|
|
68
|
-
* @param url url - Request URL.
|
|
69
|
-
* @param body body - Request body.
|
|
70
|
-
* @param args args - Request arguments.
|
|
71
|
-
* @returns Resulting response.
|
|
72
|
-
* @example
|
|
73
|
-
* del("https://foo.bar/foo")
|
|
74
|
-
*/
|
|
75
|
-
export function del(url: string, body?: JSONValue, args?: Args): Response;
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Make OPTIONS request.
|
|
79
|
-
* https://mokapi.io/docs/javascript-api/mokapi-http/options
|
|
80
|
-
* @param url url - Request URL.
|
|
81
|
-
* @param body body - Request body.
|
|
82
|
-
* @param args args - Request arguments.
|
|
83
|
-
* @returns Resulting response.
|
|
84
|
-
* @example
|
|
85
|
-
* options("https://foo.bar/foo")
|
|
86
|
-
*/
|
|
87
|
-
export function options(url: string, body?: JSONValue, args?: Args): Response;
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Request arguments.
|
|
91
|
-
* Used to add headers to a request.
|
|
92
|
-
*/
|
|
93
|
-
export interface Args {
|
|
94
|
-
/** Request headers. */
|
|
95
|
-
header?: { [name: string]: string };
|
|
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
|
|
96
9
|
}
|
|
97
10
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
* https://mokapi.io/docs/javascript-api/mokapi-http/httpresponse
|
|
101
|
-
*/
|
|
102
|
-
export interface Response {
|
|
103
|
-
/** Response body */
|
|
104
|
-
body: string;
|
|
105
|
-
|
|
106
|
-
/** HTTP status code */
|
|
107
|
-
statusCode: number;
|
|
108
|
-
|
|
109
|
-
/** Response headers */
|
|
110
|
-
headers: { [name: string]: string[] };
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Parse body as JSON
|
|
114
|
-
* @returns Returns a JS object, array or value
|
|
115
|
-
* @example
|
|
116
|
-
* const res = get(url)
|
|
117
|
-
* res.json()
|
|
118
|
-
*/
|
|
119
|
-
json(): JSONValue;
|
|
11
|
+
declare interface Args {
|
|
12
|
+
headers?: { [name: string]: any };
|
|
120
13
|
}
|
|
14
|
+
|
|
15
|
+
declare interface Response {
|
|
16
|
+
body: string
|
|
17
|
+
statusCode: number
|
|
18
|
+
headers: { [name: string]: string[] }
|
|
19
|
+
json(): any
|
|
20
|
+
}
|
package/types/kafka.d.ts
CHANGED
|
@@ -1,113 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Sends a single message to a Kafka topic.
|
|
5
|
-
* https://mokapi.io/docs/javascript-api/mokapi-kafka/produce
|
|
6
|
-
* @param args - ProduceArgs object contains Kafka produce arguments.
|
|
7
|
-
* @returns The produce result.
|
|
8
|
-
* @example
|
|
9
|
-
* export default function() {
|
|
10
|
-
* const res = produce({
|
|
11
|
-
* topic: 'foo',
|
|
12
|
-
* key: 'foo-1',
|
|
13
|
-
* value: { foo: "bar" }
|
|
14
|
-
* });
|
|
15
|
-
* console.log(`new kafka message written with offset: ${res.offset}`)
|
|
16
|
-
* }
|
|
17
|
-
*/
|
|
18
|
-
export function produce(args: ProduceArgs): ProduceResult;
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Contains produce-specific arguments.
|
|
22
|
-
* https://mokapi.io/docs/javascript-api/mokapi-kafka/produceargs
|
|
23
|
-
* @example
|
|
24
|
-
* export default function() {
|
|
25
|
-
* const res = produce({
|
|
26
|
-
* topic: 'foo',
|
|
27
|
-
* key: 'foo-1',
|
|
28
|
-
* value: { foo: "bar"}
|
|
29
|
-
* });
|
|
30
|
-
* }
|
|
31
|
-
*/
|
|
32
|
-
export interface ProduceArgs {
|
|
33
|
-
/** Kafka cluster name. Used when topic name is not unique. */
|
|
34
|
-
cluster?: string;
|
|
35
|
-
|
|
36
|
-
/** Kafka topic name. If not specified, message will be written to a random topic. */
|
|
37
|
-
topic?: string;
|
|
38
|
-
|
|
39
|
-
/** Kafka partition index. If not specified, the message will be written to any partition */
|
|
40
|
-
partition?: number;
|
|
41
|
-
|
|
42
|
-
/** Kafka message key. If not specified, a random key will be generated based on the topic configuration. */
|
|
43
|
-
key?: JSONValue;
|
|
44
|
-
|
|
45
|
-
/** Kafka message value. If not specified, a random value will be generated based on the topic configuration. */
|
|
46
|
-
value?: JSONValue;
|
|
47
|
-
|
|
48
|
-
/** Kafka message headers. */
|
|
49
|
-
headers?: { [name: string]: JSONValue };
|
|
1
|
+
declare module 'mokapi/kafka' {
|
|
2
|
+
function produce(args: ProduceArgs): ProduceResult
|
|
50
3
|
}
|
|
51
4
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
* }
|
|
60
|
-
*/
|
|
61
|
-
export interface ProduceResult {
|
|
62
|
-
/** Name of the Kafka cluster where the message was written. */
|
|
63
|
-
readonly cluster: string;
|
|
64
|
-
|
|
65
|
-
/** Kafka topic name where the message was written. */
|
|
66
|
-
readonly topic: string;
|
|
67
|
-
|
|
68
|
-
/** Kafka partition where the message was written. */
|
|
69
|
-
readonly partition: number;
|
|
70
|
-
|
|
71
|
-
/** The offset of the written message. */
|
|
72
|
-
readonly offset: number;
|
|
73
|
-
|
|
74
|
-
/** The key of the written message, */
|
|
75
|
-
readonly key: string;
|
|
76
|
-
|
|
77
|
-
/** The value of the written message. */
|
|
78
|
-
readonly value: string;
|
|
79
|
-
|
|
80
|
-
/** The headers of the written message */
|
|
81
|
-
readonly headers: { [name: string]: string };
|
|
5
|
+
declare interface ProduceArgs {
|
|
6
|
+
cluster?: string
|
|
7
|
+
topic?: string
|
|
8
|
+
partition?: number
|
|
9
|
+
key?: any
|
|
10
|
+
value?: any
|
|
11
|
+
headers?: {[key: string]: any; }
|
|
82
12
|
}
|
|
83
13
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
* })
|
|
93
|
-
* }
|
|
94
|
-
*/
|
|
95
|
-
export type KafkaEventHandler = (record: KafkaRecord) => boolean;
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* KafkaRecord is an object used by KafkaEventHandler that contains Kafka-specific message data.
|
|
99
|
-
* https://mokapi.io/docs/javascript-api/mokapi/eventhandler/KafkaRecord
|
|
100
|
-
*/
|
|
101
|
-
export interface KafkaRecord {
|
|
102
|
-
/** Kafka partition where the message was written to (read-only). */
|
|
103
|
-
readonly offset: number;
|
|
104
|
-
|
|
105
|
-
/** Kafka message key */
|
|
106
|
-
key: string;
|
|
14
|
+
declare interface ProduceResult {
|
|
15
|
+
cluster: string
|
|
16
|
+
topic: string
|
|
17
|
+
partition: number
|
|
18
|
+
offset: number
|
|
19
|
+
key: string
|
|
20
|
+
value: string
|
|
21
|
+
}
|
|
107
22
|
|
|
108
|
-
|
|
109
|
-
value: string;
|
|
23
|
+
type KafkaEventHandler = (record: KafkaRecord) => boolean
|
|
110
24
|
|
|
111
|
-
|
|
112
|
-
|
|
25
|
+
declare interface KafkaRecord {
|
|
26
|
+
offset: number
|
|
27
|
+
time: number
|
|
28
|
+
key: number[]
|
|
29
|
+
value: number[]
|
|
30
|
+
headers: { [name: string]: string }
|
|
113
31
|
}
|
|
32
|
+
|
|
33
|
+
declare interface KafkaHeader {
|
|
34
|
+
key: string
|
|
35
|
+
value: string
|
|
36
|
+
}
|
package/types/ldap.d.ts
CHANGED
|
@@ -1,118 +1,54 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
* })
|
|
18
|
-
* }
|
|
19
|
-
*/
|
|
20
|
-
export type LdapEventHandler = (request: LdapSearchRequest, response: LdapSearchResponse) => boolean;
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* LdapSearchRequest is an object used by LdapEventHandler that contains request-specific data.
|
|
24
|
-
*/
|
|
25
|
-
export interface LdapSearchRequest {
|
|
26
|
-
/** Search base DN. */
|
|
27
|
-
baseDN: string;
|
|
28
|
-
|
|
29
|
-
/** Search scope. */
|
|
30
|
-
scope: LdapSearchScope;
|
|
31
|
-
|
|
32
|
-
/** Alias dereference policy. */
|
|
33
|
-
dereferencePolicy: number;
|
|
34
|
-
|
|
35
|
-
/** Maximum number of entries to return from the search. */
|
|
36
|
-
sizeLimit: number;
|
|
37
|
-
|
|
38
|
-
/** Maximum length of time in seconds to allow for the search. */
|
|
39
|
-
timeLimit: number;
|
|
40
|
-
|
|
41
|
-
/** Only retrieve attribute names but not their values. */
|
|
42
|
-
typesOnly: number;
|
|
43
|
-
|
|
44
|
-
/** String representation of an LDAP search filter. */
|
|
45
|
-
filter: string;
|
|
46
|
-
|
|
47
|
-
/** Attribute list specifies the attributes to return in the entries found by the search. */
|
|
48
|
-
attributes: string[];
|
|
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
|
+
}
|
|
49
17
|
}
|
|
50
18
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
/** Search response message */
|
|
62
|
-
message: string;
|
|
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[]
|
|
63
28
|
}
|
|
64
29
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
dn: string;
|
|
30
|
+
declare interface LdapSearchResponse{
|
|
31
|
+
results: LdapSearchResult[]
|
|
32
|
+
status: LdapResultStatus
|
|
33
|
+
message: string
|
|
34
|
+
}
|
|
71
35
|
|
|
72
|
-
|
|
73
|
-
|
|
36
|
+
declare interface LdapSearchResult {
|
|
37
|
+
dn: string
|
|
38
|
+
attributes: { [name: string]: string[] }
|
|
74
39
|
}
|
|
75
40
|
|
|
76
|
-
|
|
77
|
-
* Specifies the portion of the target subtree that should be considered.
|
|
78
|
-
*/
|
|
79
|
-
export enum LdapSearchScope {
|
|
80
|
-
/**
|
|
81
|
-
* Indicates that only the entry specified as sthe search base should be considered.
|
|
82
|
-
* None of its subordinates will be considered.
|
|
83
|
-
*/
|
|
41
|
+
declare enum LdapSearchScope {
|
|
84
42
|
BaseObject,
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Indicates that only the immediate children of the entry specified should be considered.
|
|
88
|
-
*/
|
|
89
43
|
SingleLevel,
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Indicates that the entry specified as the search base, and all of its subordinates to any depth.
|
|
93
|
-
*/
|
|
94
|
-
WholeSubtree,
|
|
44
|
+
WholeSubtree
|
|
95
45
|
}
|
|
96
46
|
|
|
97
|
-
|
|
98
|
-
* Defines a number of result codes that are intended to be used in LdapSearchResponse.
|
|
99
|
-
*/
|
|
100
|
-
export enum LdapResultStatus {
|
|
101
|
-
/** The success result code is used to indicate that the associated operation completed successfully. */
|
|
47
|
+
declare enum LdapResultStatus {
|
|
102
48
|
Success = 0,
|
|
103
|
-
|
|
104
|
-
/** Indicates that the operation could not be processed because it wasn’t in the expected
|
|
105
|
-
* order relative to other operations on the same connection.
|
|
106
|
-
*/
|
|
107
49
|
OperationsError = 1,
|
|
108
|
-
|
|
109
|
-
/** Indicates that there was a problem with the client’s use of the LDAP protocol. */
|
|
110
50
|
ProtocolError = 2,
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
* the upper bound for that operation.
|
|
116
|
-
*/
|
|
117
|
-
SizeLimitExceeded = 4,
|
|
118
|
-
}
|
|
51
|
+
SizeLimitExceeded = 3,
|
|
52
|
+
AuthMethodNotSupported = 4,
|
|
53
|
+
CannotCancel = 121
|
|
54
|
+
}
|
package/types/mustache.d.ts
CHANGED
|
@@ -1,34 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Renders the given mustache template with the given data.
|
|
5
|
-
* https://mokapi.io/docs/javascript-api/mokapi-mustache/render
|
|
6
|
-
* @param template template - A mustache template.
|
|
7
|
-
* @param data data - A scope object that contains the data needed to render the template.
|
|
8
|
-
* @returns The rendered template
|
|
9
|
-
* @example
|
|
10
|
-
* export default function() {
|
|
11
|
-
* const scope = {
|
|
12
|
-
* firstname: fake({
|
|
13
|
-
* type: 'string',
|
|
14
|
-
* format: '{firstname}'
|
|
15
|
-
* }),
|
|
16
|
-
* calc: () => ( 3 + 4 )
|
|
17
|
-
* }
|
|
18
|
-
*
|
|
19
|
-
* const output = render("{{firstname}} has {{calc}} apples", scope)
|
|
20
|
-
* console.log(output)
|
|
21
|
-
* }
|
|
22
|
-
*/
|
|
23
|
-
export function render(template: string, data: Scope): string;
|
|
24
|
-
|
|
25
|
-
export type Scope = null | Scope[] | ScopeObject | JSONValue;
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Object representable with JSON.
|
|
29
|
-
*/
|
|
30
|
-
export interface ScopeObject {
|
|
31
|
-
[key: string]: Scope | ScopeFunction;
|
|
1
|
+
declare module 'mokapi/mustache' {
|
|
2
|
+
function render(template: string, data: any): string
|
|
32
3
|
}
|
|
33
|
-
|
|
34
|
-
export type ScopeFunction = () => Scope;
|
package/types/yaml.d.ts
CHANGED
|
@@ -1,38 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
* https://mokapi.io/docs/javascript-api/mokapi-yaml/parse
|
|
6
|
-
* @param text text - The string to parse as YAML.
|
|
7
|
-
* @returns The value corresponding to the given YAML text.
|
|
8
|
-
* @example
|
|
9
|
-
* export default function() {
|
|
10
|
-
* const orders = parse(open('orders.yaml'))
|
|
11
|
-
* console.log(outout[0].orderId)
|
|
12
|
-
* }
|
|
13
|
-
*/
|
|
14
|
-
export function parse(text: string): JSONValue;
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Converts a JavaScript value to a YAML string.
|
|
18
|
-
* @param value value - The value to convert to a YAML string.
|
|
19
|
-
* @returns A YAML string representing the given value
|
|
20
|
-
* @example
|
|
21
|
-
* export default function() {
|
|
22
|
-
* const orders = [
|
|
23
|
-
* {
|
|
24
|
-
* orderId: 345,
|
|
25
|
-
* customer: 'Bob'
|
|
26
|
-
* },
|
|
27
|
-
* {
|
|
28
|
-
* orderId: 874,
|
|
29
|
-
* customer: 'Alice'
|
|
30
|
-
* }
|
|
31
|
-
* ]
|
|
32
|
-
*
|
|
33
|
-
* on('http', function(request, response) {
|
|
34
|
-
* response.body = stringify(orders)
|
|
35
|
-
* })
|
|
36
|
-
* }
|
|
37
|
-
*/
|
|
38
|
-
export function stringify(value: JSONValue): string;
|
|
1
|
+
declare module 'mokapi/yaml' {
|
|
2
|
+
function parse(s: string): any
|
|
3
|
+
function stringify(value: any): string
|
|
4
|
+
}
|
package/types/global.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export {};
|
|
2
|
-
|
|
3
|
-
declare global {
|
|
4
|
-
/**
|
|
5
|
-
* Opens an existing file and reads its entire contents.
|
|
6
|
-
* https://mokapi.io/docs/javascript-api/globals/open
|
|
7
|
-
* @param filePath - Path to the file.
|
|
8
|
-
* @param args - Args object containing additional arguments
|
|
9
|
-
* @returns File content
|
|
10
|
-
* @example
|
|
11
|
-
* const data = JSON.parse(open("/path/to/file.json"));
|
|
12
|
-
* export default function() {
|
|
13
|
-
* mokapi.on("http", function(request, response) {
|
|
14
|
-
* response.data = data;
|
|
15
|
-
* return true;
|
|
16
|
-
* });
|
|
17
|
-
* }
|
|
18
|
-
*/
|
|
19
|
-
function open(filePath: string, args?: Args): string;
|
|
20
|
-
|
|
21
|
-
interface Args {
|
|
22
|
-
/**
|
|
23
|
-
* By default contents of the file are read as string, but with binary the file will be read as binary.
|
|
24
|
-
*/
|
|
25
|
-
as: "binary" | "string";
|
|
26
|
-
}
|
|
27
|
-
}
|
package/types/index.d.ts
DELETED
|
@@ -1,275 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Mokapi JavaScript API
|
|
3
|
-
* https://mokapi.io/docs/guides/get-started/welcome
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import "./faker";
|
|
7
|
-
import "./global";
|
|
8
|
-
import "./http";
|
|
9
|
-
import { KafkaEventHandler } from "./kafka";
|
|
10
|
-
import { LdapEventHandler } from "./ldap";
|
|
11
|
-
import "./mustache";
|
|
12
|
-
import "./yaml";
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Attaches an event handler for the given event.
|
|
16
|
-
* https://mokapi.io/docs/javascript-api/mokapi/on
|
|
17
|
-
* @param event Event type such as http
|
|
18
|
-
* @param handler An EventHandler to execute when the event is triggered
|
|
19
|
-
* @param args EventArgs object contains additional event arguments.
|
|
20
|
-
* @example
|
|
21
|
-
* export default function() {
|
|
22
|
-
* on('http', function(request, response) {
|
|
23
|
-
* if (request.url.path === '/echo') {
|
|
24
|
-
* response.data = {
|
|
25
|
-
* url: request.url.toString(),
|
|
26
|
-
* body: request.body,
|
|
27
|
-
* }
|
|
28
|
-
* }
|
|
29
|
-
* })
|
|
30
|
-
* }
|
|
31
|
-
*/
|
|
32
|
-
export function on<T extends keyof EventHandler>(event: T, handler: EventHandler[T], args?: EventArgs): void;
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Schedules a new periodic job with interval.
|
|
36
|
-
* @param interval interval - Scheduled interval.
|
|
37
|
-
* @param f f - Scheduled event handler
|
|
38
|
-
* @param args args - Additional arguments
|
|
39
|
-
* @example
|
|
40
|
-
* export default function() {
|
|
41
|
-
* every('1m', function() {
|
|
42
|
-
* console.log('foo')
|
|
43
|
-
* })
|
|
44
|
-
* }
|
|
45
|
-
*/
|
|
46
|
-
export function every(interval: Interval, f: ScheduledEventHandler, args?: ScheduledEventArgs): void;
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Schedules a new periodic job with a cron expression.
|
|
50
|
-
* @param expr expr - Cron expression
|
|
51
|
-
* @param f f - cheduled event handler
|
|
52
|
-
* @param args args - Additional arguments
|
|
53
|
-
* @example
|
|
54
|
-
* export default function() {
|
|
55
|
-
* cron('* * * * *', function() {
|
|
56
|
-
* console.log('foo')
|
|
57
|
-
* })
|
|
58
|
-
* }
|
|
59
|
-
*/
|
|
60
|
-
export function cron(expr: string, f: ScheduledEventHandler, args?: ScheduledEventArgs): void;
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Retrieves the value of the environment variable named by the key.
|
|
64
|
-
* @param name name - The name of the environment variable.
|
|
65
|
-
* @returns The value of the environment variable specified by variable, or an empty string
|
|
66
|
-
* if the environment variable is not found.
|
|
67
|
-
* @example
|
|
68
|
-
* export default function() {
|
|
69
|
-
* console.log(env('foo'))
|
|
70
|
-
* }
|
|
71
|
-
*/
|
|
72
|
-
export function env(name: string): string;
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Returns a textual representation of the date.
|
|
76
|
-
* https://mokapi.io/docs/javascript-api/mokapi/date
|
|
77
|
-
* @description Default layout is RFC3339. Default timestamp is current UTC
|
|
78
|
-
* @param args args - Adjusting textual representation
|
|
79
|
-
* @example
|
|
80
|
-
* export default function() {
|
|
81
|
-
* console.log(date())
|
|
82
|
-
* console.log(date({layout: 'UnixDate'}))
|
|
83
|
-
* console.log(date({timestamp: new Date().getTime()}))
|
|
84
|
-
* }
|
|
85
|
-
*/
|
|
86
|
-
export function date(args?: DateArgs): string;
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Suspends the execution for the specified duration.
|
|
90
|
-
* https://mokapi.io/docs/javascript-api/mokapi/sleep
|
|
91
|
-
* @param time Duration in milliseconds or duration as string with unit.
|
|
92
|
-
* Valid time units are `ns`, `us` (or `µs`), `ms`, `s`, `m`, `h`
|
|
93
|
-
*/
|
|
94
|
-
export function sleep(time: number | string): void;
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Specifies the interval of a periodic job.
|
|
98
|
-
* Interval string is a possibly signed sequence of decimal numbers, each with optional
|
|
99
|
-
* fraction and a unit suffix, such as "300ms", "-1.5h" or "2h45m".
|
|
100
|
-
* Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
|
|
101
|
-
*/
|
|
102
|
-
export type Interval = string;
|
|
103
|
-
|
|
104
|
-
export interface EventHandler {
|
|
105
|
-
http: HttpEventHandler;
|
|
106
|
-
kafka: KafkaEventHandler;
|
|
107
|
-
ldap: LdapEventHandler;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* HttpEventHandler is a function that is executed when an HTTP event is triggered.
|
|
112
|
-
* https://mokapi.io/docs/javascript-api/mokapi/eventhandler/httpeventhandler
|
|
113
|
-
* @example
|
|
114
|
-
* export default function() {
|
|
115
|
-
* on('http', function(request, response) {
|
|
116
|
-
* if (request.operationId === 'time') {
|
|
117
|
-
* response.body = date()
|
|
118
|
-
* return true
|
|
119
|
-
* }
|
|
120
|
-
* return false
|
|
121
|
-
* })
|
|
122
|
-
* }
|
|
123
|
-
*/
|
|
124
|
-
export type HttpEventHandler = (request: HttpRequest, response: HttpResponse) => boolean;
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* HttpRequest is an object used by HttpEventHandler that contains request-specific
|
|
128
|
-
* data such as HTTP headers.
|
|
129
|
-
* https://mokapi.io/docs/javascript-api/mokapi/eventhandler/httprequest
|
|
130
|
-
*/
|
|
131
|
-
export interface HttpRequest {
|
|
132
|
-
/** Request method. */
|
|
133
|
-
readonly method: string;
|
|
134
|
-
|
|
135
|
-
/** Represents a parsed URL. */
|
|
136
|
-
readonly url: Url;
|
|
137
|
-
|
|
138
|
-
/** Body contains request body specified by OpenAPI request body. */
|
|
139
|
-
readonly body: JSONValue;
|
|
140
|
-
|
|
141
|
-
/** Object contains path parameters specified by OpenAPI path parameters. */
|
|
142
|
-
readonly path: { [key: string]: JSONValue };
|
|
143
|
-
|
|
144
|
-
/** Object contains query parameters specified by OpenAPI query parameters. */
|
|
145
|
-
readonly query: { [key: string]: JSONValue };
|
|
146
|
-
|
|
147
|
-
/** Object contains header parameters specified by OpenAPI header parameters. */
|
|
148
|
-
readonly header: { [key: string]: JSONValue };
|
|
149
|
-
|
|
150
|
-
/** Object contains cookie parameters specified by OpenAPI cookie parameters. */
|
|
151
|
-
readonly cookie: { [key: string]: JSONValue };
|
|
152
|
-
|
|
153
|
-
/** Path value specified by the OpenAPI path */
|
|
154
|
-
readonly key: string;
|
|
155
|
-
|
|
156
|
-
/** OperationId defined in OpenAPI */
|
|
157
|
-
readonly operationId: string;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* HttpResponse is an object used by HttpEventHandler that contains response-specific data such as HTTP headers.
|
|
162
|
-
* https://mokapi.io/docs/javascript-api/mokapi/eventhandler/httpresponse
|
|
163
|
-
*/
|
|
164
|
-
export interface HttpResponse {
|
|
165
|
-
/** Object contains header parameters specified by OpenAPI header parameters. */
|
|
166
|
-
headers: { [key: string]: string };
|
|
167
|
-
|
|
168
|
-
/** Specifies the http status used to select the OpenAPI response definition. */
|
|
169
|
-
statusCode: number;
|
|
170
|
-
|
|
171
|
-
/** Response body. It has a higher precedence than data. */
|
|
172
|
-
body: string;
|
|
173
|
-
|
|
174
|
-
/** Data will be encoded with the OpenAPI response definition. */
|
|
175
|
-
data: JSONValue;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* Represents an URL
|
|
180
|
-
*/
|
|
181
|
-
export interface Url {
|
|
182
|
-
/** URL scheme. */
|
|
183
|
-
readonly scheme: string;
|
|
184
|
-
|
|
185
|
-
/** URL host. */
|
|
186
|
-
readonly host: string;
|
|
187
|
-
|
|
188
|
-
/** URL path. */
|
|
189
|
-
readonly path: string;
|
|
190
|
-
|
|
191
|
-
/** URL query string. */
|
|
192
|
-
readonly query: string;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* Contains optional arguments to format a datetime object
|
|
197
|
-
*/
|
|
198
|
-
export interface DateArgs {
|
|
199
|
-
/**
|
|
200
|
-
* The format of the textual representation, default is RFC3339
|
|
201
|
-
*/
|
|
202
|
-
layout?: DateLayout;
|
|
203
|
-
|
|
204
|
-
/**
|
|
205
|
-
* The timestamp of the date, default is current UTC time
|
|
206
|
-
*/
|
|
207
|
-
timestamp?: number;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
/**
|
|
211
|
-
* These are predefined layouts for use in date()
|
|
212
|
-
*/
|
|
213
|
-
export type DateLayout =
|
|
214
|
-
| "DateTime"
|
|
215
|
-
| "DateOnly"
|
|
216
|
-
| "TimeOnly"
|
|
217
|
-
| "UnixDate"
|
|
218
|
-
| "RFC882"
|
|
219
|
-
| "RFC822Z"
|
|
220
|
-
| "RFC850"
|
|
221
|
-
| "RFC1123"
|
|
222
|
-
| "RFC1123Z"
|
|
223
|
-
| "RFC3339"
|
|
224
|
-
| "RFC3339Nano";
|
|
225
|
-
|
|
226
|
-
/**
|
|
227
|
-
* Additional event arguments
|
|
228
|
-
*/
|
|
229
|
-
export interface EventArgs {
|
|
230
|
-
/**
|
|
231
|
-
* Adds or overrides existing tags used in dashboard
|
|
232
|
-
*/
|
|
233
|
-
tags?: { [key: string]: string };
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
/**
|
|
237
|
-
* cheduledEventArgs is an object used by every and cron function.
|
|
238
|
-
* https://mokapi.io/docs/javascript-api/mokapi/eventhandler/scheduledeventargs
|
|
239
|
-
* @example
|
|
240
|
-
* export default function() {
|
|
241
|
-
* every('1m', function() {
|
|
242
|
-
* console.log('foo')
|
|
243
|
-
* }, {times: 1, runFirstTimeImmediately: false})
|
|
244
|
-
* }
|
|
245
|
-
*/
|
|
246
|
-
export type ScheduledEventHandler = () => void;
|
|
247
|
-
|
|
248
|
-
export interface ScheduledEventArgs {
|
|
249
|
-
/**
|
|
250
|
-
* Adds or overrides existing tags used in dashboard
|
|
251
|
-
*/
|
|
252
|
-
tags?: { [key: string]: string };
|
|
253
|
-
|
|
254
|
-
/**
|
|
255
|
-
* Defines the number of times the scheduled function is executed.
|
|
256
|
-
*/
|
|
257
|
-
times?: number;
|
|
258
|
-
|
|
259
|
-
/**
|
|
260
|
-
* Toggles behavior of first execution. Default is true
|
|
261
|
-
*/
|
|
262
|
-
runFirstTimeImmediately?: boolean;
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
/**
|
|
266
|
-
* JavaScript value representable with JSON.
|
|
267
|
-
*/
|
|
268
|
-
export type JSONValue = null | boolean | number | string | JSONValue[] | JSONObject;
|
|
269
|
-
|
|
270
|
-
/**
|
|
271
|
-
* Object representable with JSON.
|
|
272
|
-
*/
|
|
273
|
-
export interface JSONObject {
|
|
274
|
-
[key: string]: JSONValue;
|
|
275
|
-
}
|