@empyria/common 0.1.3 → 0.1.5
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/.github/dependabot.yml +11 -0
- package/lib/Ata.js +20 -3
- package/package.json +5 -4
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# To get started with Dependabot version updates, you'll need to specify which
|
|
2
|
+
# package ecosystems to update and where the package manifests are located.
|
|
3
|
+
# Please see the documentation for all configuration options:
|
|
4
|
+
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
|
|
5
|
+
|
|
6
|
+
version: 2
|
|
7
|
+
updates:
|
|
8
|
+
- package-ecosystem: "" # See documentation for possible values
|
|
9
|
+
directory: "/" # Location of package manifests
|
|
10
|
+
schedule:
|
|
11
|
+
interval: "daily"
|
package/lib/Ata.js
CHANGED
|
@@ -46,13 +46,30 @@ export function cloneBySchema(schema) {
|
|
|
46
46
|
* @param {Object} schemaDef - Map of property name to its JSON schema.
|
|
47
47
|
* @param {Object} [options={}]
|
|
48
48
|
* @param {boolean} [options.strict] - If true, disallows properties not listed in `schemaDef`.
|
|
49
|
-
* @
|
|
49
|
+
* @param {boolean} [options.optional] - If true, a property whose own schema carries
|
|
50
|
+
* `optional: true` is excluded from `required` (that marker is then stripped from the
|
|
51
|
+
* property itself — never leaked into the resulting schema, since it isn't a real JSON
|
|
52
|
+
* Schema keyword). Off by default: every declared property is required, exactly as before —
|
|
53
|
+
* a caller that never sets `optional: true` on any property sees no difference either way.
|
|
54
|
+
* @returns {Object} A JSON schema: `{ type: 'object', properties, required, additionalProperties }`.
|
|
50
55
|
*/
|
|
51
56
|
export function defineSchema(schemaDef, options = {}) {
|
|
57
|
+
const properties = {}
|
|
58
|
+
const required = []
|
|
59
|
+
|
|
60
|
+
for (const [key, propertySchema] of Object.entries(schemaDef)) {
|
|
61
|
+
if (options.optional && propertySchema?.optional) {
|
|
62
|
+
const { optional, ...rest } = propertySchema
|
|
63
|
+
properties[key] = rest
|
|
64
|
+
} else {
|
|
65
|
+
properties[key] = propertySchema
|
|
66
|
+
required.push(key)
|
|
67
|
+
}
|
|
68
|
+
}
|
|
52
69
|
const schema = {
|
|
53
70
|
type: 'object',
|
|
54
|
-
properties
|
|
55
|
-
required
|
|
71
|
+
properties,
|
|
72
|
+
required,
|
|
56
73
|
additionalProperties: !options.strict,
|
|
57
74
|
}
|
|
58
75
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@empyria/common",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "Shared backend goodies for Empyria",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Imre Fazekas <imre.fazekas@icloud.com>",
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
"test:watch": "bun test --watch"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@empyria/classification": "0.1.
|
|
23
|
-
"ata-validator": "1.
|
|
22
|
+
"@empyria/classification": "0.1.3",
|
|
23
|
+
"ata-validator": "1.9.0",
|
|
24
24
|
"clerobee": "1.0.8",
|
|
25
25
|
"ms": "2.1.3"
|
|
26
26
|
},
|
|
@@ -31,5 +31,6 @@
|
|
|
31
31
|
"engines": {
|
|
32
32
|
"bun": ">=1.4.0",
|
|
33
33
|
"node": ">=26"
|
|
34
|
-
}
|
|
34
|
+
},
|
|
35
|
+
"packageManager": "bun@1.4.0"
|
|
35
36
|
}
|