@naturalcycles/js-lib 15.46.0 → 15.47.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.
- package/dist/http/fetcher.d.ts +1 -1
- package/dist/http/fetcher.js +1 -1
- package/dist/promise/pProps.js +1 -1
- package/dist/promise/pTimeout.js +1 -1
- package/dist/semver.js +1 -0
- package/dist/web.d.ts +1 -1
- package/dist/web.js +1 -1
- package/package.json +3 -4
- package/readme.md +0 -8
- package/src/http/fetcher.ts +1 -1
- package/src/promise/pProps.ts +1 -1
- package/src/promise/pTimeout.ts +1 -1
- package/src/semver.ts +1 -0
- package/src/types.ts +4 -4
- package/src/web.ts +1 -1
- package/src/zod/zod.shared.schemas.ts +1 -1
- package/dist/json-schema/from-data/generateJsonSchemaFromData.d.ts +0 -8
- package/dist/json-schema/from-data/generateJsonSchemaFromData.js +0 -87
- package/dist/json-schema/index.d.ts +0 -5
- package/dist/json-schema/index.js +0 -5
- package/dist/json-schema/jsonSchema.cnst.d.ts +0 -2
- package/dist/json-schema/jsonSchema.cnst.js +0 -38
- package/dist/json-schema/jsonSchema.model.d.ts +0 -121
- package/dist/json-schema/jsonSchema.model.js +0 -1
- package/dist/json-schema/jsonSchema.util.d.ts +0 -8
- package/dist/json-schema/jsonSchema.util.js +0 -27
- package/dist/json-schema/jsonSchemaBuilder.d.ts +0 -159
- package/dist/json-schema/jsonSchemaBuilder.js +0 -412
- package/dist/json-schema/jsonSchemas.d.ts +0 -2
- package/dist/json-schema/jsonSchemas.js +0 -6
- package/src/json-schema/from-data/generateJsonSchemaFromData.ts +0 -121
- package/src/json-schema/index.ts +0 -5
- package/src/json-schema/jsonSchema.cnst.ts +0 -52
- package/src/json-schema/jsonSchema.model.ts +0 -172
- package/src/json-schema/jsonSchema.util.ts +0 -36
- package/src/json-schema/jsonSchemaBuilder.ts +0 -590
- package/src/json-schema/jsonSchemas.ts +0 -8
package/src/json-schema/index.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
JsonSchema,
|
|
3
|
-
JsonSchemaAny,
|
|
4
|
-
JsonSchemaNumber,
|
|
5
|
-
JsonSchemaObject,
|
|
6
|
-
JsonSchemaString,
|
|
7
|
-
} from './jsonSchema.model.js'
|
|
8
|
-
|
|
9
|
-
export const JSON_SCHEMA_ORDER: (
|
|
10
|
-
| keyof JsonSchema
|
|
11
|
-
| keyof JsonSchemaAny
|
|
12
|
-
| keyof JsonSchemaObject
|
|
13
|
-
| keyof JsonSchemaString
|
|
14
|
-
| keyof JsonSchemaNumber
|
|
15
|
-
)[] = [
|
|
16
|
-
'$schema',
|
|
17
|
-
'$id',
|
|
18
|
-
'title',
|
|
19
|
-
'description',
|
|
20
|
-
'deprecated',
|
|
21
|
-
'readOnly',
|
|
22
|
-
'writeOnly',
|
|
23
|
-
'type',
|
|
24
|
-
'default',
|
|
25
|
-
// Object,
|
|
26
|
-
'properties',
|
|
27
|
-
'required',
|
|
28
|
-
'minProperties',
|
|
29
|
-
'maxProperties',
|
|
30
|
-
'patternProperties',
|
|
31
|
-
'propertyNames',
|
|
32
|
-
// Array
|
|
33
|
-
'properties',
|
|
34
|
-
'required',
|
|
35
|
-
'minProperties',
|
|
36
|
-
'maxProperties',
|
|
37
|
-
'patternProperties',
|
|
38
|
-
'propertyNames',
|
|
39
|
-
// String
|
|
40
|
-
'pattern',
|
|
41
|
-
'minLength',
|
|
42
|
-
'maxLength',
|
|
43
|
-
'format',
|
|
44
|
-
'transform',
|
|
45
|
-
// Number
|
|
46
|
-
'format',
|
|
47
|
-
'multipleOf',
|
|
48
|
-
'minimum',
|
|
49
|
-
'exclusiveMinimum',
|
|
50
|
-
'maximum',
|
|
51
|
-
'exclusiveMaximum',
|
|
52
|
-
]
|
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
import type { AnyObject, StringMap } from '../types.js'
|
|
2
|
-
|
|
3
|
-
export type JsonSchema<T = unknown> =
|
|
4
|
-
| JsonSchemaAny<T>
|
|
5
|
-
| JsonSchemaOneOf<T>
|
|
6
|
-
| JsonSchemaAllOf<T>
|
|
7
|
-
| JsonSchemaAnyOf<T>
|
|
8
|
-
| JsonSchemaNot<T>
|
|
9
|
-
| JsonSchemaRef<T>
|
|
10
|
-
| JsonSchemaConst<T>
|
|
11
|
-
| JsonSchemaEnum<T>
|
|
12
|
-
| JsonSchemaString
|
|
13
|
-
| JsonSchemaNumber
|
|
14
|
-
| JsonSchemaBoolean
|
|
15
|
-
| JsonSchemaNull
|
|
16
|
-
| JsonSchemaObject<T extends AnyObject ? T : AnyObject>
|
|
17
|
-
| JsonSchemaArray<T>
|
|
18
|
-
| JsonSchemaTuple<T>
|
|
19
|
-
|
|
20
|
-
export interface JsonSchemaAny<T = unknown> {
|
|
21
|
-
$schema?: string
|
|
22
|
-
$id?: string
|
|
23
|
-
title?: string
|
|
24
|
-
description?: string
|
|
25
|
-
// $comment?: string
|
|
26
|
-
// nullable?: boolean // not sure about that field
|
|
27
|
-
deprecated?: boolean
|
|
28
|
-
readOnly?: boolean
|
|
29
|
-
writeOnly?: boolean
|
|
30
|
-
|
|
31
|
-
type?: string | string[]
|
|
32
|
-
|
|
33
|
-
default?: T
|
|
34
|
-
|
|
35
|
-
// https://json-schema.org/understanding-json-schema/reference/conditionals.html#id6
|
|
36
|
-
if?: JsonSchema
|
|
37
|
-
then?: JsonSchema
|
|
38
|
-
else?: JsonSchema
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* https://ajv.js.org/packages/ajv-keywords.html#instanceof
|
|
42
|
-
*
|
|
43
|
-
* Useful for Node.js Buffer, you can use it like:
|
|
44
|
-
* `instanceof: 'Buffer'`
|
|
45
|
-
*/
|
|
46
|
-
instanceof?: string | string[]
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* This is a temporary "intermediate AST" field that is used inside the parser.
|
|
50
|
-
* In the final schema this field will NOT be present.
|
|
51
|
-
*/
|
|
52
|
-
optionalField?: true
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Union type
|
|
57
|
-
*/
|
|
58
|
-
export interface JsonSchemaOneOf<T = unknown> extends JsonSchemaAny<T> {
|
|
59
|
-
oneOf: JsonSchema[]
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Intersection type
|
|
64
|
-
*/
|
|
65
|
-
export interface JsonSchemaAllOf<T = unknown> extends JsonSchemaAny<T> {
|
|
66
|
-
allOf: JsonSchema[]
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export interface JsonSchemaAnyOf<T = unknown> extends JsonSchemaAny<T> {
|
|
70
|
-
anyOf: JsonSchema[]
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export interface JsonSchemaNot<T = unknown> extends JsonSchemaAny<T> {
|
|
74
|
-
not: JsonSchema
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// Trying to loosen the type restrictions, to make things simpler. To be monitored!
|
|
78
|
-
// export interface JsonSchemaConst<T extends string | number | boolean = any>
|
|
79
|
-
export interface JsonSchemaConst<T = unknown> extends JsonSchemaAny<T> {
|
|
80
|
-
const: T // literal type
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export interface JsonSchemaString<T extends string = string> extends JsonSchemaAny<T> {
|
|
84
|
-
type: 'string'
|
|
85
|
-
pattern?: string
|
|
86
|
-
minLength?: number
|
|
87
|
-
maxLength?: number
|
|
88
|
-
format?: string
|
|
89
|
-
|
|
90
|
-
contentMediaType?: string
|
|
91
|
-
contentEncoding?: string // e.g 'base64'
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* https://ajv.js.org/packages/ajv-keywords.html#transform
|
|
95
|
-
*/
|
|
96
|
-
transform?: ('trim' | 'toLowerCase' | 'toUpperCase')[]
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export interface JsonSchemaNumber<T extends number = number> extends JsonSchemaAny<T> {
|
|
100
|
-
type: 'number' | 'integer'
|
|
101
|
-
format?: string
|
|
102
|
-
multipleOf?: number
|
|
103
|
-
minimum?: number
|
|
104
|
-
exclusiveMinimum?: number
|
|
105
|
-
maximum?: number
|
|
106
|
-
exclusiveMaximum?: number
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
export interface JsonSchemaBoolean extends JsonSchemaAny<boolean> {
|
|
110
|
-
type: 'boolean'
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
export interface JsonSchemaNull extends JsonSchemaAny<null> {
|
|
114
|
-
type: 'null'
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
// export interface JsonSchemaEnum<T extends string | number = any> extends JsonSchemaAny<T> {
|
|
118
|
-
export interface JsonSchemaEnum<T = unknown> extends JsonSchemaAny<T> {
|
|
119
|
-
enum: T[]
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
export interface JsonSchemaRef<T = unknown> extends JsonSchemaAny<T> {
|
|
123
|
-
$ref: string
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
export interface JsonSchemaRootObject<T extends AnyObject = AnyObject> extends JsonSchemaObject<T> {
|
|
127
|
-
$id: string
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
export interface JsonSchemaObject<T extends AnyObject = AnyObject> extends JsonSchemaAny<T> {
|
|
131
|
-
type: 'object'
|
|
132
|
-
// let's be strict and require all these
|
|
133
|
-
properties: {
|
|
134
|
-
[k in keyof T]: JsonSchema
|
|
135
|
-
}
|
|
136
|
-
required: (keyof T)[]
|
|
137
|
-
additionalProperties: boolean
|
|
138
|
-
minProperties?: number
|
|
139
|
-
maxProperties?: number
|
|
140
|
-
|
|
141
|
-
// StringMap
|
|
142
|
-
patternProperties?: StringMap<JsonSchema>
|
|
143
|
-
propertyNames?: JsonSchema
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* @example
|
|
147
|
-
*
|
|
148
|
-
* dependentRequired: {
|
|
149
|
-
* credit_card: ['billing_address']
|
|
150
|
-
* }
|
|
151
|
-
*/
|
|
152
|
-
dependentRequired?: StringMap<string[]>
|
|
153
|
-
|
|
154
|
-
dependentSchemas?: StringMap<JsonSchema>
|
|
155
|
-
|
|
156
|
-
dependencies?: StringMap<string[]>
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
export interface JsonSchemaArray<ITEM = unknown> extends JsonSchemaAny<ITEM[]> {
|
|
160
|
-
type: 'array'
|
|
161
|
-
items: JsonSchema<ITEM>
|
|
162
|
-
minItems?: number
|
|
163
|
-
maxItems?: number
|
|
164
|
-
uniqueItems?: boolean
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
export interface JsonSchemaTuple<T = unknown> extends JsonSchemaAny<T> {
|
|
168
|
-
type: 'array'
|
|
169
|
-
items: JsonSchema[]
|
|
170
|
-
minItems: number
|
|
171
|
-
maxItems: number
|
|
172
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { _uniq } from '../array/array.util.js'
|
|
2
|
-
import { _filterNullishValues } from '../object/object.util.js'
|
|
3
|
-
import type { AnyObject } from '../types.js'
|
|
4
|
-
import type { JsonSchemaObject } from './jsonSchema.model.js'
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Merges s2 into s1 (mutates s1) and returns s1.
|
|
8
|
-
* Does not mutate s2.
|
|
9
|
-
* API similar to Object.assign(s1, s2)
|
|
10
|
-
*/
|
|
11
|
-
export function mergeJsonSchemaObjects<T1 extends AnyObject, T2 extends AnyObject>(
|
|
12
|
-
s1: JsonSchemaObject<T1>,
|
|
13
|
-
s2: JsonSchemaObject<T2>,
|
|
14
|
-
): JsonSchemaObject<T1 & T2> {
|
|
15
|
-
// Merge `properties`
|
|
16
|
-
Object.entries(s2.properties).forEach(([k, v]) => {
|
|
17
|
-
;(s1.properties as any)[k] = v
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
// Merge `patternProperties`
|
|
21
|
-
Object.entries(s2.patternProperties || {}).forEach(([k, v]) => {
|
|
22
|
-
;(s1.patternProperties as any)[k] = v
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
s1.propertyNames = s2.propertyNames || s1.propertyNames
|
|
26
|
-
s1.minProperties = s2.minProperties ?? s1.minProperties
|
|
27
|
-
s1.maxProperties = s2.maxProperties ?? s1.maxProperties
|
|
28
|
-
|
|
29
|
-
// Merge `required`
|
|
30
|
-
s1.required.push(...(s2.required as any))
|
|
31
|
-
s1.required = _uniq(s1.required).sort()
|
|
32
|
-
|
|
33
|
-
// `additionalProperties` remains the same
|
|
34
|
-
|
|
35
|
-
return _filterNullishValues(s1, { mutate: true }) as any
|
|
36
|
-
}
|