go-mokapi 0.9.26 → 0.10.0

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.
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "go-mokapi",
3
- "version": "0.9.26",
3
+ "version": "0.10.0",
4
4
  "description": "Easy and flexible API mocking",
5
5
  "homepage": "https://mokapi.io",
6
6
  "repository": {
package/types/faker.d.ts CHANGED
@@ -12,7 +12,7 @@ import { JSONValue } from ".";
12
12
  * console.log(fake({type: 'string', pattern: '^\d{3}-\d{2}-\d{4}$'})) // 123-45-6789
13
13
  * }
14
14
  */
15
- export function fake(schema: Schema | FakeRequest): JSONValue;
15
+ export function fake(schema: Schema | JSONSchema): JSONValue;
16
16
 
17
17
  /**
18
18
  * Gets the tree node with the given name
@@ -40,44 +40,6 @@ export interface Tree {
40
40
  */
41
41
  name: string
42
42
 
43
- /**
44
- * Tests whether the tree node supports the request.
45
- * @param request request - Request for a new fake value
46
- * @example
47
- * export default function() {
48
- * const frequencyItems = ['never', 'daily', 'weekly', 'monthly', 'yearly']
49
- * const node = findByName('Strings')
50
- * node.append({
51
- * name: 'Frequency',
52
- * test: (r) => { return r.lastName() === 'frequency' },
53
- * fake: (r) => {
54
- * return frequencyItems[Math.floor(Math.random()*frequencyItems.length)]
55
- * }
56
- * })
57
- * return fake({ type: 'string' })
58
- * }
59
- */
60
- readonly test: (request: FakeRequest) => boolean
61
-
62
- /**
63
- * Gets a new fake value
64
- * @param request request - Request for a new fake value
65
- * @example
66
- * export default function() {
67
- * const frequencyItems = ['never', 'daily', 'weekly', 'monthly', 'yearly']
68
- * const node = findByName('Strings')
69
- * node.append({
70
- * name: 'Frequency',
71
- * test: (r) => { return r.lastName() === 'frequency' },
72
- * fake: (r) => {
73
- * return frequencyItems[Math.floor(Math.random()*frequencyItems.length)]
74
- * }
75
- * })
76
- * return fake({ type: 'string' })
77
- * }
78
- */
79
- readonly fake: (request: FakeRequest) => JSONValue
80
-
81
43
  /**
82
44
  * Inserts a Tree objects after the last child of this tree.
83
45
  * @param node node - A Tree node to insert after the last child.
@@ -152,23 +114,8 @@ export interface CustomTree {
152
114
  fake: (r: Request) => JSONValue
153
115
  }
154
116
 
155
- /**
156
- * Represents a request for a fake value
157
- */
158
- export interface FakeRequest {
159
- /**
160
- * Contains a list of attribute names representing the object graph for which a new value is to be faked
161
- */
162
- names: string[]
163
-
164
- /**
165
- * Describing the structure of JSON data to be faked
166
- */
167
- schema: JSONSchema
168
- }
169
-
170
117
  export interface Request {
171
- Path: PathElement[]
118
+ path: PathElement[]
172
119
 
173
120
  last: () => PathElement
174
121
  lastName: () => string
@@ -192,7 +139,7 @@ export interface JSONSchema {
192
139
  /**
193
140
  * Specifies the data type for a schema.
194
141
  */
195
- type: string | string[]
142
+ type: SchemaType | SchemaType[];
196
143
 
197
144
  /**
198
145
  * The enum keyword is used to restrict a value to a fixed set of values.
@@ -209,6 +156,11 @@ export interface JSONSchema {
209
156
  */
210
157
  examples: unknown[]
211
158
 
159
+ /**
160
+ * Specifies a default value.
161
+ */
162
+ default: unknown
163
+
212
164
  // Numbers
213
165
  /**
214
166
  * Restricts the number to a multiple of the given number
@@ -332,9 +284,11 @@ export interface JSONSchema {
332
284
  is: (typeName: string) => boolean
333
285
  }
334
286
 
287
+ export type SchemaType = "object" | "array" | "number" | "integer" | "string" | "boolean" | "null";
288
+
335
289
  export interface Schema {
336
290
  /** Type of fake value */
337
- type?: "object" | "array" | "number" | "integer" | "string" | "boolean";
291
+ type?: SchemaType | SchemaType[];
338
292
 
339
293
  /** Serves as a hint at the contents and format of the string. */
340
294
  format?: string;
@@ -358,10 +312,10 @@ export interface Schema {
358
312
  maximum?: number;
359
313
 
360
314
  /** Specifies whether minimum value is exluded. Default is false. */
361
- exclusiveMinimum?: boolean;
315
+ exclusiveMinimum?: number | boolean;
362
316
 
363
317
  /** ** Specifies whether maximum value is exluded. Default is false. */
364
- exclusiveMaximum?: boolean;
318
+ exclusiveMaximum?: number | boolean;
365
319
 
366
320
  /** Valid against one of the specified schemas. */
367
321
  anyOf?: Schema[];
package/types/index.d.ts CHANGED
@@ -445,7 +445,7 @@ export interface ScheduledEventArgs {
445
445
  /**
446
446
  * JavaScript value representable with JSON.
447
447
  */
448
- export type JSONValue = null | boolean | number | string | JSONValue[] | JSONObject;
448
+ export type JSONValue = null | undefined | boolean | number | string | JSONValue[] | JSONObject;
449
449
 
450
450
  /**
451
451
  * Object representable with JSON.