go-mokapi 0.9.13 → 0.9.15

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.13",
3
+ "version": "0.9.15",
4
4
  "description": "Easy and flexible API mocking",
5
5
  "homepage": "https://mokapi.io",
6
6
  "repository": {
package/types/faker.d.ts CHANGED
@@ -14,6 +14,81 @@ import { JSONValue } from ".";
14
14
  */
15
15
  export function fake(schema: Schema): JSONValue;
16
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 = ''
30
+
31
+ export interface Tree {
32
+ name: string
33
+ test: () => boolean
34
+ fake: () => JSONValue
35
+
36
+ append?: (node: Tree) => void
37
+ insert?: (index: number, node: Tree) => void
38
+ }
39
+
40
+ export interface Request {
41
+ names: string[]
42
+ schema: JSONSchema
43
+ }
44
+
45
+ export interface JSONSchema {
46
+ type: string | string[]
47
+ enum: unknown[]
48
+ const: unknown
49
+ examples: unknown[]
50
+
51
+ // Numbers
52
+ multipleOf: number | undefined
53
+ maximum: number | undefined
54
+ exclusiveMaximum: number | undefined
55
+ minimum: number | undefined
56
+ exclusiveMinimum: number | undefined
57
+
58
+ // Strings
59
+ maxLength: number | undefined
60
+ minLength: number | undefined
61
+ pattern: string
62
+ format: string
63
+
64
+ // Arrays
65
+ items: JSONSchema | undefined
66
+ maxItems: number | undefined
67
+ minItems: number | undefined
68
+ uniqueItems: boolean
69
+
70
+ // Objects
71
+ properties: { [name: string]: JSONSchema }
72
+ maxProperties: number | undefined
73
+ minProperties: number | undefined
74
+ required: string[] | undefined
75
+ additionalProperties: boolean | JSONSchema | undefined
76
+
77
+ allOf: JSONSchema[] | undefined
78
+ anyOf: JSONSchema[] | undefined
79
+ oneOf: JSONSchema[] | undefined
80
+
81
+ isAny: () => boolean
82
+ isString: () => boolean
83
+ isInteger: () => boolean
84
+ isNumber: () => boolean
85
+ isArray: () => boolean
86
+ isObject: () => boolean
87
+ isNullable: () => boolean
88
+ isDictionary: () => boolean
89
+ is: (typeName: string) => boolean
90
+ }
91
+
17
92
  export interface Schema {
18
93
  /** Type of fake value */
19
94
  type?: "object" | "array" | "number" | "integer" | "string" | "boolean";