@lix-js/sdk 0.6.0-preview.0 → 0.6.0-preview.2
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/README.md +9 -0
- package/SKILL.md +468 -0
- package/dist/engine-wasm/index.d.ts +15 -11
- package/dist/engine-wasm/index.js +105 -38
- package/dist/engine-wasm/wasm/lix_engine.d.ts +14 -2
- package/dist/engine-wasm/wasm/lix_engine.js +18 -17
- package/dist/engine-wasm/wasm/lix_engine.wasm +0 -0
- package/dist/engine-wasm/wasm/lix_engine.wasm.d.ts +2 -1
- package/dist/generated/builtin-schemas.d.ts +31 -41
- package/dist/generated/builtin-schemas.js +52 -56
- package/dist/open-lix.d.ts +141 -24
- package/dist/open-lix.js +199 -35
- package/dist/sqlite/index.js +99 -22
- package/dist-engine-src/README.md +18 -0
- package/dist-engine-src/src/backend/kv.rs +358 -0
- package/dist-engine-src/src/backend/mod.rs +12 -0
- package/dist-engine-src/src/backend/testing.rs +658 -0
- package/dist-engine-src/src/backend/types.rs +96 -0
- package/dist-engine-src/src/binary_cas/chunking.rs +31 -0
- package/dist-engine-src/src/binary_cas/codec.rs +346 -0
- package/dist-engine-src/src/binary_cas/context.rs +139 -0
- package/dist-engine-src/src/binary_cas/kv.rs +1063 -0
- package/dist-engine-src/src/binary_cas/mod.rs +11 -0
- package/dist-engine-src/src/binary_cas/types.rs +127 -0
- package/dist-engine-src/src/cel/context.rs +86 -0
- package/dist-engine-src/src/cel/error.rs +19 -0
- package/dist-engine-src/src/cel/mod.rs +8 -0
- package/dist-engine-src/src/cel/provider.rs +9 -0
- package/dist-engine-src/src/cel/runtime.rs +167 -0
- package/dist-engine-src/src/cel/value.rs +50 -0
- package/dist-engine-src/src/changelog/codec.rs +321 -0
- package/dist-engine-src/src/changelog/context.rs +92 -0
- package/dist-engine-src/src/changelog/materialization.rs +121 -0
- package/dist-engine-src/src/changelog/mod.rs +13 -0
- package/dist-engine-src/src/changelog/reader.rs +20 -0
- package/dist-engine-src/src/changelog/storage.rs +220 -0
- package/dist-engine-src/src/changelog/types.rs +38 -0
- package/dist-engine-src/src/commit_graph/context.rs +1588 -0
- package/dist-engine-src/src/commit_graph/mod.rs +12 -0
- package/dist-engine-src/src/commit_graph/types.rs +145 -0
- package/dist-engine-src/src/commit_graph/walker.rs +780 -0
- package/dist-engine-src/src/common/error.rs +313 -0
- package/dist-engine-src/src/common/fingerprint.rs +3 -0
- package/dist-engine-src/src/common/fs_path.rs +1336 -0
- package/dist-engine-src/src/common/identity.rs +135 -0
- package/dist-engine-src/src/common/metadata.rs +35 -0
- package/dist-engine-src/src/common/mod.rs +23 -0
- package/dist-engine-src/src/common/types.rs +105 -0
- package/dist-engine-src/src/common/wire.rs +222 -0
- package/dist-engine-src/src/engine.rs +239 -0
- package/dist-engine-src/src/entity_identity.rs +285 -0
- package/dist-engine-src/src/functions/context.rs +327 -0
- package/dist-engine-src/src/functions/deterministic.rs +113 -0
- package/dist-engine-src/src/functions/mod.rs +18 -0
- package/dist-engine-src/src/functions/provider.rs +130 -0
- package/dist-engine-src/src/functions/state.rs +363 -0
- package/dist-engine-src/src/functions/types.rs +37 -0
- package/dist-engine-src/src/init.rs +505 -0
- package/dist-engine-src/src/json_store/compression.rs +77 -0
- package/dist-engine-src/src/json_store/context.rs +129 -0
- package/dist-engine-src/src/json_store/encoded.rs +15 -0
- package/dist-engine-src/src/json_store/mod.rs +9 -0
- package/dist-engine-src/src/json_store/store.rs +236 -0
- package/dist-engine-src/src/json_store/types.rs +52 -0
- package/dist-engine-src/src/lib.rs +61 -0
- package/dist-engine-src/src/live_state/context.rs +2241 -0
- package/dist-engine-src/src/live_state/mod.rs +15 -0
- package/dist-engine-src/src/live_state/overlay.rs +75 -0
- package/dist-engine-src/src/live_state/reader.rs +23 -0
- package/dist-engine-src/src/live_state/types.rs +239 -0
- package/dist-engine-src/src/live_state/visibility.rs +218 -0
- package/dist-engine-src/src/plugin/archive.rs +441 -0
- package/dist-engine-src/src/plugin/component.rs +183 -0
- package/dist-engine-src/src/plugin/install.rs +637 -0
- package/dist-engine-src/src/plugin/manifest.rs +516 -0
- package/dist-engine-src/src/plugin/materializer.rs +477 -0
- package/dist-engine-src/src/plugin/mod.rs +33 -0
- package/dist-engine-src/src/plugin/plugin_manifest.json +119 -0
- package/dist-engine-src/src/plugin/storage.rs +74 -0
- package/dist-engine-src/src/schema/annotations/defaults.rs +280 -0
- package/dist-engine-src/src/schema/annotations/mod.rs +1 -0
- package/dist-engine-src/src/schema/builtin/lix_account.json +22 -0
- package/dist-engine-src/src/schema/builtin/lix_active_account.json +30 -0
- package/dist-engine-src/src/schema/builtin/lix_binary_blob_ref.json +30 -0
- package/dist-engine-src/src/schema/builtin/lix_change.json +62 -0
- package/dist-engine-src/src/schema/builtin/lix_change_author.json +46 -0
- package/dist-engine-src/src/schema/builtin/lix_change_set.json +18 -0
- package/dist-engine-src/src/schema/builtin/lix_change_set_element.json +75 -0
- package/dist-engine-src/src/schema/builtin/lix_commit.json +62 -0
- package/dist-engine-src/src/schema/builtin/lix_commit_edge.json +46 -0
- package/dist-engine-src/src/schema/builtin/lix_directory_descriptor.json +53 -0
- package/dist-engine-src/src/schema/builtin/lix_entity_label.json +63 -0
- package/dist-engine-src/src/schema/builtin/lix_file_descriptor.json +53 -0
- package/dist-engine-src/src/schema/builtin/lix_key_value.json +41 -0
- package/dist-engine-src/src/schema/builtin/lix_label.json +22 -0
- package/dist-engine-src/src/schema/builtin/lix_registered_schema.json +31 -0
- package/dist-engine-src/src/schema/builtin/lix_version_descriptor.json +35 -0
- package/dist-engine-src/src/schema/builtin/lix_version_ref.json +49 -0
- package/dist-engine-src/src/schema/builtin/mod.rs +271 -0
- package/dist-engine-src/src/schema/definition.json +157 -0
- package/dist-engine-src/src/schema/definition.rs +636 -0
- package/dist-engine-src/src/schema/key.rs +206 -0
- package/dist-engine-src/src/schema/mod.rs +20 -0
- package/dist-engine-src/src/schema/seed.rs +14 -0
- package/dist-engine-src/src/schema/tests.rs +739 -0
- package/dist-engine-src/src/schema_registry.rs +294 -0
- package/dist-engine-src/src/session/context.rs +366 -0
- package/dist-engine-src/src/session/create_version.rs +80 -0
- package/dist-engine-src/src/session/execute.rs +447 -0
- package/dist-engine-src/src/session/merge/analysis.rs +102 -0
- package/dist-engine-src/src/session/merge/apply.rs +23 -0
- package/dist-engine-src/src/session/merge/conflicts.rs +62 -0
- package/dist-engine-src/src/session/merge/mod.rs +11 -0
- package/dist-engine-src/src/session/merge/stats.rs +65 -0
- package/dist-engine-src/src/session/merge/version.rs +437 -0
- package/dist-engine-src/src/session/mod.rs +25 -0
- package/dist-engine-src/src/session/switch_version.rs +121 -0
- package/dist-engine-src/src/sql2/change_provider.rs +337 -0
- package/dist-engine-src/src/sql2/classify.rs +147 -0
- package/dist-engine-src/src/sql2/commit_derived_provider.rs +591 -0
- package/dist-engine-src/src/sql2/context.rs +307 -0
- package/dist-engine-src/src/sql2/directory_history_provider.rs +623 -0
- package/dist-engine-src/src/sql2/directory_provider.rs +2405 -0
- package/dist-engine-src/src/sql2/dml.rs +148 -0
- package/dist-engine-src/src/sql2/entity_history_provider.rs +444 -0
- package/dist-engine-src/src/sql2/entity_provider.rs +2700 -0
- package/dist-engine-src/src/sql2/error.rs +196 -0
- package/dist-engine-src/src/sql2/execute.rs +3379 -0
- package/dist-engine-src/src/sql2/file_history_provider.rs +902 -0
- package/dist-engine-src/src/sql2/file_provider.rs +3254 -0
- package/dist-engine-src/src/sql2/filesystem_planner.rs +1526 -0
- package/dist-engine-src/src/sql2/filesystem_predicates.rs +159 -0
- package/dist-engine-src/src/sql2/filesystem_visibility.rs +369 -0
- package/dist-engine-src/src/sql2/history_projection.rs +80 -0
- package/dist-engine-src/src/sql2/history_provider.rs +418 -0
- package/dist-engine-src/src/sql2/history_route.rs +643 -0
- package/dist-engine-src/src/sql2/lix_state_provider.rs +2430 -0
- package/dist-engine-src/src/sql2/mod.rs +43 -0
- package/dist-engine-src/src/sql2/read_only.rs +65 -0
- package/dist-engine-src/src/sql2/record_batch.rs +17 -0
- package/dist-engine-src/src/sql2/result_metadata.rs +29 -0
- package/dist-engine-src/src/sql2/runtime.rs +60 -0
- package/dist-engine-src/src/sql2/session.rs +135 -0
- package/dist-engine-src/src/sql2/udfs/common.rs +295 -0
- package/dist-engine-src/src/sql2/udfs/lix_active_version_commit_id.rs +53 -0
- package/dist-engine-src/src/sql2/udfs/lix_empty_blob.rs +47 -0
- package/dist-engine-src/src/sql2/udfs/lix_json.rs +100 -0
- package/dist-engine-src/src/sql2/udfs/lix_json_get.rs +99 -0
- package/dist-engine-src/src/sql2/udfs/lix_json_get_text.rs +99 -0
- package/dist-engine-src/src/sql2/udfs/lix_text_decode.rs +82 -0
- package/dist-engine-src/src/sql2/udfs/lix_text_encode.rs +85 -0
- package/dist-engine-src/src/sql2/udfs/lix_uuid_v7.rs +76 -0
- package/dist-engine-src/src/sql2/udfs/mod.rs +82 -0
- package/dist-engine-src/src/sql2/version_provider.rs +1187 -0
- package/dist-engine-src/src/sql2/version_scope.rs +394 -0
- package/dist-engine-src/src/sql2/write_normalization.rs +345 -0
- package/dist-engine-src/src/storage/context.rs +356 -0
- package/dist-engine-src/src/storage/mod.rs +14 -0
- package/dist-engine-src/src/storage/read_scope.rs +88 -0
- package/dist-engine-src/src/storage/types.rs +501 -0
- package/dist-engine-src/src/storage_bench.rs +3406 -0
- package/dist-engine-src/src/test_support.rs +81 -0
- package/dist-engine-src/src/tracked_state/by_file_index.rs +102 -0
- package/dist-engine-src/src/tracked_state/codec.rs +747 -0
- package/dist-engine-src/src/tracked_state/context.rs +983 -0
- package/dist-engine-src/src/tracked_state/diff.rs +494 -0
- package/dist-engine-src/src/tracked_state/materialization.rs +141 -0
- package/dist-engine-src/src/tracked_state/merge.rs +474 -0
- package/dist-engine-src/src/tracked_state/mod.rs +31 -0
- package/dist-engine-src/src/tracked_state/rebuild.rs +771 -0
- package/dist-engine-src/src/tracked_state/storage.rs +243 -0
- package/dist-engine-src/src/tracked_state/tree.rs +2744 -0
- package/dist-engine-src/src/tracked_state/tree_types.rs +176 -0
- package/dist-engine-src/src/tracked_state/types.rs +61 -0
- package/dist-engine-src/src/transaction/commit.rs +1224 -0
- package/dist-engine-src/src/transaction/context.rs +1307 -0
- package/dist-engine-src/src/transaction/live_state_overlay.rs +34 -0
- package/dist-engine-src/src/transaction/mod.rs +11 -0
- package/dist-engine-src/src/transaction/normalization.rs +1026 -0
- package/dist-engine-src/src/transaction/schema_resolver.rs +127 -0
- package/dist-engine-src/src/transaction/staging.rs +1436 -0
- package/dist-engine-src/src/transaction/types.rs +351 -0
- package/dist-engine-src/src/transaction/validation.rs +4811 -0
- package/dist-engine-src/src/untracked_state/codec.rs +363 -0
- package/dist-engine-src/src/untracked_state/context.rs +82 -0
- package/dist-engine-src/src/untracked_state/materialization.rs +157 -0
- package/dist-engine-src/src/untracked_state/mod.rs +17 -0
- package/dist-engine-src/src/untracked_state/storage.rs +348 -0
- package/dist-engine-src/src/untracked_state/types.rs +96 -0
- package/dist-engine-src/src/version/context.rs +52 -0
- package/dist-engine-src/src/version/mod.rs +12 -0
- package/dist-engine-src/src/version/refs.rs +421 -0
- package/dist-engine-src/src/version/stage_rows.rs +71 -0
- package/dist-engine-src/src/version/types.rs +21 -0
- package/dist-engine-src/src/wasm/mod.rs +60 -0
- package/package.json +68 -63
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"x-lix-key": "lix_directory_descriptor",
|
|
3
|
+
"x-lix-version": "1",
|
|
4
|
+
"x-lix-primary-key": [
|
|
5
|
+
"/id"
|
|
6
|
+
],
|
|
7
|
+
"x-lix-unique": [
|
|
8
|
+
[
|
|
9
|
+
"/parent_id",
|
|
10
|
+
"/name"
|
|
11
|
+
]
|
|
12
|
+
],
|
|
13
|
+
"x-lix-foreign-keys": [
|
|
14
|
+
{
|
|
15
|
+
"properties": [
|
|
16
|
+
"/parent_id"
|
|
17
|
+
],
|
|
18
|
+
"references": {
|
|
19
|
+
"schemaKey": "lix_directory_descriptor",
|
|
20
|
+
"properties": [
|
|
21
|
+
"/id"
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
],
|
|
26
|
+
"type": "object",
|
|
27
|
+
"properties": {
|
|
28
|
+
"id": {
|
|
29
|
+
"type": "string",
|
|
30
|
+
"x-lix-default": "lix_uuid_v7()"
|
|
31
|
+
},
|
|
32
|
+
"parent_id": {
|
|
33
|
+
"type": [
|
|
34
|
+
"string",
|
|
35
|
+
"null"
|
|
36
|
+
]
|
|
37
|
+
},
|
|
38
|
+
"name": {
|
|
39
|
+
"type": "string",
|
|
40
|
+
"pattern": "^(?!\\.{1,2}$)[^/\\\\]+$"
|
|
41
|
+
},
|
|
42
|
+
"hidden": {
|
|
43
|
+
"type": "boolean",
|
|
44
|
+
"x-lix-default": "false"
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"required": [
|
|
48
|
+
"id",
|
|
49
|
+
"parent_id",
|
|
50
|
+
"name"
|
|
51
|
+
],
|
|
52
|
+
"additionalProperties": false
|
|
53
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"x-lix-key": "lix_entity_label",
|
|
3
|
+
"x-lix-version": "1",
|
|
4
|
+
"x-lix-primary-key": [
|
|
5
|
+
"/entity_id",
|
|
6
|
+
"/schema_key",
|
|
7
|
+
"/file_id",
|
|
8
|
+
"/label_id"
|
|
9
|
+
],
|
|
10
|
+
"x-lix-foreign-keys": [
|
|
11
|
+
{
|
|
12
|
+
"properties": [
|
|
13
|
+
"/entity_id",
|
|
14
|
+
"/schema_key",
|
|
15
|
+
"/file_id"
|
|
16
|
+
],
|
|
17
|
+
"references": {
|
|
18
|
+
"schemaKey": "lix_state",
|
|
19
|
+
"properties": [
|
|
20
|
+
"/entity_id",
|
|
21
|
+
"/schema_key",
|
|
22
|
+
"/file_id"
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"properties": [
|
|
28
|
+
"/label_id"
|
|
29
|
+
],
|
|
30
|
+
"references": {
|
|
31
|
+
"schemaKey": "lix_label",
|
|
32
|
+
"properties": [
|
|
33
|
+
"/id"
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
],
|
|
38
|
+
"type": "object",
|
|
39
|
+
"properties": {
|
|
40
|
+
"entity_id": {
|
|
41
|
+
"type": "string"
|
|
42
|
+
},
|
|
43
|
+
"schema_key": {
|
|
44
|
+
"type": "string"
|
|
45
|
+
},
|
|
46
|
+
"file_id": {
|
|
47
|
+
"type": [
|
|
48
|
+
"string",
|
|
49
|
+
"null"
|
|
50
|
+
]
|
|
51
|
+
},
|
|
52
|
+
"label_id": {
|
|
53
|
+
"type": "string"
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
"required": [
|
|
57
|
+
"entity_id",
|
|
58
|
+
"schema_key",
|
|
59
|
+
"file_id",
|
|
60
|
+
"label_id"
|
|
61
|
+
],
|
|
62
|
+
"additionalProperties": false
|
|
63
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"x-lix-key": "lix_file_descriptor",
|
|
3
|
+
"x-lix-version": "1",
|
|
4
|
+
"x-lix-primary-key": [
|
|
5
|
+
"/id"
|
|
6
|
+
],
|
|
7
|
+
"x-lix-unique": [
|
|
8
|
+
[
|
|
9
|
+
"/directory_id",
|
|
10
|
+
"/name"
|
|
11
|
+
]
|
|
12
|
+
],
|
|
13
|
+
"x-lix-foreign-keys": [
|
|
14
|
+
{
|
|
15
|
+
"properties": [
|
|
16
|
+
"/directory_id"
|
|
17
|
+
],
|
|
18
|
+
"references": {
|
|
19
|
+
"schemaKey": "lix_directory_descriptor",
|
|
20
|
+
"properties": [
|
|
21
|
+
"/id"
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
],
|
|
26
|
+
"type": "object",
|
|
27
|
+
"properties": {
|
|
28
|
+
"id": {
|
|
29
|
+
"type": "string",
|
|
30
|
+
"x-lix-default": "lix_uuid_v7()"
|
|
31
|
+
},
|
|
32
|
+
"directory_id": {
|
|
33
|
+
"type": [
|
|
34
|
+
"string",
|
|
35
|
+
"null"
|
|
36
|
+
]
|
|
37
|
+
},
|
|
38
|
+
"name": {
|
|
39
|
+
"type": "string",
|
|
40
|
+
"pattern": "^(?!\\.{1,2}$)[^/\\\\]+$"
|
|
41
|
+
},
|
|
42
|
+
"hidden": {
|
|
43
|
+
"type": "boolean",
|
|
44
|
+
"x-lix-default": "false"
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"required": [
|
|
48
|
+
"id",
|
|
49
|
+
"directory_id",
|
|
50
|
+
"name"
|
|
51
|
+
],
|
|
52
|
+
"additionalProperties": false
|
|
53
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"x-lix-key": "lix_key_value",
|
|
3
|
+
"x-lix-version": "1",
|
|
4
|
+
"x-lix-primary-key": [
|
|
5
|
+
"/key"
|
|
6
|
+
],
|
|
7
|
+
"type": "object",
|
|
8
|
+
"properties": {
|
|
9
|
+
"key": {
|
|
10
|
+
"type": "string"
|
|
11
|
+
},
|
|
12
|
+
"value": {
|
|
13
|
+
"description": "Arbitrary JSON value. This field stays in the JSON domain even when different rows hold different JSON kinds.",
|
|
14
|
+
"anyOf": [
|
|
15
|
+
{
|
|
16
|
+
"type": "object"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"type": "array"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"type": "string"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"type": "number"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"type": "boolean"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"type": "null"
|
|
32
|
+
}
|
|
33
|
+
]
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"required": [
|
|
37
|
+
"key",
|
|
38
|
+
"value"
|
|
39
|
+
],
|
|
40
|
+
"additionalProperties": false
|
|
41
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"x-lix-key": "lix_label",
|
|
3
|
+
"x-lix-version": "1",
|
|
4
|
+
"x-lix-primary-key": [
|
|
5
|
+
"/id"
|
|
6
|
+
],
|
|
7
|
+
"type": "object",
|
|
8
|
+
"properties": {
|
|
9
|
+
"id": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"x-lix-default": "lix_uuid_v7()"
|
|
12
|
+
},
|
|
13
|
+
"name": {
|
|
14
|
+
"type": "string"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"required": [
|
|
18
|
+
"id",
|
|
19
|
+
"name"
|
|
20
|
+
],
|
|
21
|
+
"additionalProperties": false
|
|
22
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"x-lix-key": "lix_registered_schema",
|
|
3
|
+
"x-lix-version": "1",
|
|
4
|
+
"x-lix-primary-key": [
|
|
5
|
+
"/value/x-lix-key",
|
|
6
|
+
"/value/x-lix-version"
|
|
7
|
+
],
|
|
8
|
+
"type": "object",
|
|
9
|
+
"properties": {
|
|
10
|
+
"value": {
|
|
11
|
+
"type": "object",
|
|
12
|
+
"properties": {
|
|
13
|
+
"x-lix-key": {
|
|
14
|
+
"type": "string"
|
|
15
|
+
},
|
|
16
|
+
"x-lix-version": {
|
|
17
|
+
"type": "string"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"required": [
|
|
21
|
+
"x-lix-key",
|
|
22
|
+
"x-lix-version"
|
|
23
|
+
],
|
|
24
|
+
"additionalProperties": true
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"required": [
|
|
28
|
+
"value"
|
|
29
|
+
],
|
|
30
|
+
"additionalProperties": false
|
|
31
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"x-lix-key": "lix_version_descriptor",
|
|
3
|
+
"x-lix-version": "1",
|
|
4
|
+
"description": "User-facing version metadata (name and visibility) for a branch-like version. The stable identity of a version; the matching `lix_version_ref` carries the moving head pointer. The catalog's `lix_version` surface joins this descriptor with its ref to present a single user-visible version row.",
|
|
5
|
+
"x-lix-primary-key": [
|
|
6
|
+
"/id"
|
|
7
|
+
],
|
|
8
|
+
"x-lix-unique": [
|
|
9
|
+
[
|
|
10
|
+
"/name"
|
|
11
|
+
]
|
|
12
|
+
],
|
|
13
|
+
"type": "object",
|
|
14
|
+
"properties": {
|
|
15
|
+
"id": {
|
|
16
|
+
"type": "string",
|
|
17
|
+
"x-lix-default": "lix_uuid_v7()",
|
|
18
|
+
"description": "Stable version identifier (UUIDv7). Referenced by `lix_version_ref.id`."
|
|
19
|
+
},
|
|
20
|
+
"name": {
|
|
21
|
+
"type": "string",
|
|
22
|
+
"description": "Human-readable version name (e.g. `main`, `feature-x`) shown in version listings and CLI output."
|
|
23
|
+
},
|
|
24
|
+
"hidden": {
|
|
25
|
+
"type": "boolean",
|
|
26
|
+
"default": false,
|
|
27
|
+
"description": "When true, the version is filtered from default listings (CLI, catalog views); operations by explicit id still succeed."
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"required": [
|
|
31
|
+
"id",
|
|
32
|
+
"name"
|
|
33
|
+
],
|
|
34
|
+
"additionalProperties": false
|
|
35
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"x-lix-key": "lix_version_ref",
|
|
3
|
+
"x-lix-version": "1",
|
|
4
|
+
"description": "Version head pointer. Records which commit a version should currently resolve to in the local runtime. Intentionally not part of canonical commit membership: refs may be reset client-side after sync without introducing content conflicts. Each `lix_version_descriptor.id` has exactly one `lix_version_ref` row.",
|
|
5
|
+
"x-lix-primary-key": [
|
|
6
|
+
"/id"
|
|
7
|
+
],
|
|
8
|
+
"x-lix-foreign-keys": [
|
|
9
|
+
{
|
|
10
|
+
"properties": [
|
|
11
|
+
"/id"
|
|
12
|
+
],
|
|
13
|
+
"references": {
|
|
14
|
+
"schemaKey": "lix_version_descriptor",
|
|
15
|
+
"properties": [
|
|
16
|
+
"/id"
|
|
17
|
+
]
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"properties": [
|
|
22
|
+
"/commit_id"
|
|
23
|
+
],
|
|
24
|
+
"references": {
|
|
25
|
+
"schemaKey": "lix_commit",
|
|
26
|
+
"properties": [
|
|
27
|
+
"/id"
|
|
28
|
+
]
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
],
|
|
32
|
+
"type": "object",
|
|
33
|
+
"properties": {
|
|
34
|
+
"id": {
|
|
35
|
+
"type": "string",
|
|
36
|
+
"x-lix-default": "lix_uuid_v7()",
|
|
37
|
+
"description": "Version identifier whose head pointer is being stored; matches `lix_version_descriptor.id`."
|
|
38
|
+
},
|
|
39
|
+
"commit_id": {
|
|
40
|
+
"type": "string",
|
|
41
|
+
"description": "Commit the version should currently resolve to in the local runtime (references `lix_commit.id`)."
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"required": [
|
|
45
|
+
"id",
|
|
46
|
+
"commit_id"
|
|
47
|
+
],
|
|
48
|
+
"additionalProperties": false
|
|
49
|
+
}
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
use serde_json::Value as JsonValue;
|
|
2
|
+
use std::sync::OnceLock;
|
|
3
|
+
|
|
4
|
+
use crate::schema::lix_schema_definition;
|
|
5
|
+
|
|
6
|
+
const LIX_REGISTERED_SCHEMA_KEY: &str = "lix_registered_schema";
|
|
7
|
+
const LIX_KEY_VALUE_SCHEMA_KEY: &str = "lix_key_value";
|
|
8
|
+
const LIX_ACCOUNT_SCHEMA_KEY: &str = "lix_account";
|
|
9
|
+
const LIX_ACTIVE_ACCOUNT_SCHEMA_KEY: &str = "lix_active_account";
|
|
10
|
+
const LIX_LABEL_SCHEMA_KEY: &str = "lix_label";
|
|
11
|
+
const LIX_ENTITY_LABEL_SCHEMA_KEY: &str = "lix_entity_label";
|
|
12
|
+
const LIX_CHANGE_SCHEMA_KEY: &str = "lix_change";
|
|
13
|
+
const LIX_CHANGE_AUTHOR_SCHEMA_KEY: &str = "lix_change_author";
|
|
14
|
+
const LIX_CHANGE_SET_SCHEMA_KEY: &str = "lix_change_set";
|
|
15
|
+
const LIX_COMMIT_SCHEMA_KEY: &str = "lix_commit";
|
|
16
|
+
const LIX_VERSION_DESCRIPTOR_SCHEMA_KEY: &str = "lix_version_descriptor";
|
|
17
|
+
const LIX_VERSION_REF_SCHEMA_KEY: &str = "lix_version_ref";
|
|
18
|
+
const LIX_CHANGE_SET_ELEMENT_SCHEMA_KEY: &str = "lix_change_set_element";
|
|
19
|
+
const LIX_COMMIT_EDGE_SCHEMA_KEY: &str = "lix_commit_edge";
|
|
20
|
+
const LIX_FILE_DESCRIPTOR_SCHEMA_KEY: &str = "lix_file_descriptor";
|
|
21
|
+
const LIX_DIRECTORY_DESCRIPTOR_SCHEMA_KEY: &str = "lix_directory_descriptor";
|
|
22
|
+
const LIX_BINARY_BLOB_REF_SCHEMA_KEY: &str = "lix_binary_blob_ref";
|
|
23
|
+
const LIX_STATE_SURFACE_SCHEMA_KEY: &str = "lix_state";
|
|
24
|
+
|
|
25
|
+
const LIX_REGISTERED_SCHEMA_JSON: &str = include_str!("lix_registered_schema.json");
|
|
26
|
+
const LIX_KEY_VALUE_SCHEMA_JSON: &str = include_str!("lix_key_value.json");
|
|
27
|
+
const LIX_ACCOUNT_SCHEMA_JSON: &str = include_str!("lix_account.json");
|
|
28
|
+
const LIX_ACTIVE_ACCOUNT_SCHEMA_JSON: &str = include_str!("lix_active_account.json");
|
|
29
|
+
const LIX_LABEL_SCHEMA_JSON: &str = include_str!("lix_label.json");
|
|
30
|
+
const LIX_ENTITY_LABEL_SCHEMA_JSON: &str = include_str!("lix_entity_label.json");
|
|
31
|
+
const LIX_CHANGE_SCHEMA_JSON: &str = include_str!("lix_change.json");
|
|
32
|
+
const LIX_CHANGE_AUTHOR_SCHEMA_JSON: &str = include_str!("lix_change_author.json");
|
|
33
|
+
const LIX_CHANGE_SET_SCHEMA_JSON: &str = include_str!("lix_change_set.json");
|
|
34
|
+
const LIX_COMMIT_SCHEMA_JSON: &str = include_str!("lix_commit.json");
|
|
35
|
+
const LIX_VERSION_DESCRIPTOR_SCHEMA_JSON: &str = include_str!("lix_version_descriptor.json");
|
|
36
|
+
const LIX_VERSION_REF_SCHEMA_JSON: &str = include_str!("lix_version_ref.json");
|
|
37
|
+
const LIX_CHANGE_SET_ELEMENT_SCHEMA_JSON: &str = include_str!("lix_change_set_element.json");
|
|
38
|
+
const LIX_COMMIT_EDGE_SCHEMA_JSON: &str = include_str!("lix_commit_edge.json");
|
|
39
|
+
const LIX_FILE_DESCRIPTOR_SCHEMA_JSON: &str = include_str!("lix_file_descriptor.json");
|
|
40
|
+
const LIX_DIRECTORY_DESCRIPTOR_SCHEMA_JSON: &str = include_str!("lix_directory_descriptor.json");
|
|
41
|
+
const LIX_BINARY_BLOB_REF_SCHEMA_JSON: &str = include_str!("lix_binary_blob_ref.json");
|
|
42
|
+
|
|
43
|
+
static LIX_REGISTERED_SCHEMA: OnceLock<JsonValue> = OnceLock::new();
|
|
44
|
+
static LIX_KEY_VALUE_SCHEMA: OnceLock<JsonValue> = OnceLock::new();
|
|
45
|
+
static LIX_ACCOUNT_SCHEMA: OnceLock<JsonValue> = OnceLock::new();
|
|
46
|
+
static LIX_ACTIVE_ACCOUNT_SCHEMA: OnceLock<JsonValue> = OnceLock::new();
|
|
47
|
+
static LIX_LABEL_SCHEMA: OnceLock<JsonValue> = OnceLock::new();
|
|
48
|
+
static LIX_ENTITY_LABEL_SCHEMA: OnceLock<JsonValue> = OnceLock::new();
|
|
49
|
+
static LIX_CHANGE_SCHEMA: OnceLock<JsonValue> = OnceLock::new();
|
|
50
|
+
static LIX_CHANGE_AUTHOR_SCHEMA: OnceLock<JsonValue> = OnceLock::new();
|
|
51
|
+
static LIX_CHANGE_SET_SCHEMA: OnceLock<JsonValue> = OnceLock::new();
|
|
52
|
+
static LIX_COMMIT_SCHEMA: OnceLock<JsonValue> = OnceLock::new();
|
|
53
|
+
static LIX_VERSION_DESCRIPTOR_SCHEMA: OnceLock<JsonValue> = OnceLock::new();
|
|
54
|
+
static LIX_VERSION_REF_SCHEMA: OnceLock<JsonValue> = OnceLock::new();
|
|
55
|
+
static LIX_CHANGE_SET_ELEMENT_SCHEMA: OnceLock<JsonValue> = OnceLock::new();
|
|
56
|
+
static LIX_COMMIT_EDGE_SCHEMA: OnceLock<JsonValue> = OnceLock::new();
|
|
57
|
+
static LIX_FILE_DESCRIPTOR_SCHEMA: OnceLock<JsonValue> = OnceLock::new();
|
|
58
|
+
static LIX_DIRECTORY_DESCRIPTOR_SCHEMA: OnceLock<JsonValue> = OnceLock::new();
|
|
59
|
+
static LIX_BINARY_BLOB_REF_SCHEMA: OnceLock<JsonValue> = OnceLock::new();
|
|
60
|
+
static LIX_STATE_SURFACE_SCHEMA: OnceLock<JsonValue> = OnceLock::new();
|
|
61
|
+
|
|
62
|
+
const BUILTIN_SCHEMA_KEYS: &[&str] = &[
|
|
63
|
+
LIX_REGISTERED_SCHEMA_KEY,
|
|
64
|
+
LIX_KEY_VALUE_SCHEMA_KEY,
|
|
65
|
+
LIX_ACCOUNT_SCHEMA_KEY,
|
|
66
|
+
LIX_ACTIVE_ACCOUNT_SCHEMA_KEY,
|
|
67
|
+
LIX_LABEL_SCHEMA_KEY,
|
|
68
|
+
LIX_ENTITY_LABEL_SCHEMA_KEY,
|
|
69
|
+
LIX_CHANGE_SCHEMA_KEY,
|
|
70
|
+
LIX_CHANGE_AUTHOR_SCHEMA_KEY,
|
|
71
|
+
LIX_CHANGE_SET_SCHEMA_KEY,
|
|
72
|
+
LIX_COMMIT_SCHEMA_KEY,
|
|
73
|
+
LIX_VERSION_DESCRIPTOR_SCHEMA_KEY,
|
|
74
|
+
LIX_VERSION_REF_SCHEMA_KEY,
|
|
75
|
+
LIX_CHANGE_SET_ELEMENT_SCHEMA_KEY,
|
|
76
|
+
LIX_COMMIT_EDGE_SCHEMA_KEY,
|
|
77
|
+
LIX_FILE_DESCRIPTOR_SCHEMA_KEY,
|
|
78
|
+
LIX_DIRECTORY_DESCRIPTOR_SCHEMA_KEY,
|
|
79
|
+
LIX_BINARY_BLOB_REF_SCHEMA_KEY,
|
|
80
|
+
];
|
|
81
|
+
|
|
82
|
+
pub(super) fn is_seed_schema_key(schema_key: &str) -> bool {
|
|
83
|
+
BUILTIN_SCHEMA_KEYS.contains(&schema_key)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
pub(super) fn seed_schema_definitions() -> Vec<&'static JsonValue> {
|
|
87
|
+
BUILTIN_SCHEMA_KEYS
|
|
88
|
+
.iter()
|
|
89
|
+
.map(|schema_key| {
|
|
90
|
+
seed_schema_definition(schema_key)
|
|
91
|
+
.unwrap_or_else(|| panic!("missing seed schema definition for '{schema_key}'"))
|
|
92
|
+
})
|
|
93
|
+
.collect()
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// `lix_state` is a public SQL surface, not a stored builtin schema row, but
|
|
97
|
+
// multiple owners still need a schema-shaped contract for validation and SQL
|
|
98
|
+
// preparation. Keep that shared shape here so those callers do not drift.
|
|
99
|
+
pub(crate) fn lix_state_surface_schema_definition() -> &'static JsonValue {
|
|
100
|
+
LIX_STATE_SURFACE_SCHEMA.get_or_init(|| {
|
|
101
|
+
serde_json::json!({
|
|
102
|
+
"x-lix-key": LIX_STATE_SURFACE_SCHEMA_KEY,
|
|
103
|
+
"x-lix-version": "1",
|
|
104
|
+
"x-lix-primary-key": [
|
|
105
|
+
"/entity_id",
|
|
106
|
+
"/schema_key",
|
|
107
|
+
"/file_id"
|
|
108
|
+
],
|
|
109
|
+
"type": "object",
|
|
110
|
+
"properties": {
|
|
111
|
+
"entity_id": { "type": "string" },
|
|
112
|
+
"schema_key": { "type": "string" },
|
|
113
|
+
"file_id": { "type": "string" }
|
|
114
|
+
},
|
|
115
|
+
"required": [
|
|
116
|
+
"entity_id",
|
|
117
|
+
"schema_key",
|
|
118
|
+
"file_id"
|
|
119
|
+
],
|
|
120
|
+
"additionalProperties": true
|
|
121
|
+
})
|
|
122
|
+
})
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
pub(super) fn seed_schema_definition(schema_key: &str) -> Option<&'static JsonValue> {
|
|
126
|
+
match schema_key {
|
|
127
|
+
LIX_REGISTERED_SCHEMA_KEY => Some(
|
|
128
|
+
LIX_REGISTERED_SCHEMA.get_or_init(|| parse_registered_schema_with_inlined_definition()),
|
|
129
|
+
),
|
|
130
|
+
LIX_KEY_VALUE_SCHEMA_KEY => {
|
|
131
|
+
Some(LIX_KEY_VALUE_SCHEMA.get_or_init(|| {
|
|
132
|
+
parse_builtin_schema("lix_key_value.json", LIX_KEY_VALUE_SCHEMA_JSON)
|
|
133
|
+
}))
|
|
134
|
+
}
|
|
135
|
+
LIX_ACCOUNT_SCHEMA_KEY => Some(
|
|
136
|
+
LIX_ACCOUNT_SCHEMA
|
|
137
|
+
.get_or_init(|| parse_builtin_schema("lix_account.json", LIX_ACCOUNT_SCHEMA_JSON)),
|
|
138
|
+
),
|
|
139
|
+
LIX_ACTIVE_ACCOUNT_SCHEMA_KEY => Some(LIX_ACTIVE_ACCOUNT_SCHEMA.get_or_init(|| {
|
|
140
|
+
parse_builtin_schema("lix_active_account.json", LIX_ACTIVE_ACCOUNT_SCHEMA_JSON)
|
|
141
|
+
})),
|
|
142
|
+
LIX_LABEL_SCHEMA_KEY => Some(
|
|
143
|
+
LIX_LABEL_SCHEMA
|
|
144
|
+
.get_or_init(|| parse_builtin_schema("lix_label.json", LIX_LABEL_SCHEMA_JSON)),
|
|
145
|
+
),
|
|
146
|
+
LIX_ENTITY_LABEL_SCHEMA_KEY => Some(LIX_ENTITY_LABEL_SCHEMA.get_or_init(|| {
|
|
147
|
+
parse_builtin_schema("lix_entity_label.json", LIX_ENTITY_LABEL_SCHEMA_JSON)
|
|
148
|
+
})),
|
|
149
|
+
LIX_CHANGE_SCHEMA_KEY => Some(
|
|
150
|
+
LIX_CHANGE_SCHEMA
|
|
151
|
+
.get_or_init(|| parse_builtin_schema("lix_change.json", LIX_CHANGE_SCHEMA_JSON)),
|
|
152
|
+
),
|
|
153
|
+
LIX_CHANGE_AUTHOR_SCHEMA_KEY => Some(LIX_CHANGE_AUTHOR_SCHEMA.get_or_init(|| {
|
|
154
|
+
parse_builtin_schema("lix_change_author.json", LIX_CHANGE_AUTHOR_SCHEMA_JSON)
|
|
155
|
+
})),
|
|
156
|
+
LIX_CHANGE_SET_SCHEMA_KEY => Some(LIX_CHANGE_SET_SCHEMA.get_or_init(|| {
|
|
157
|
+
parse_builtin_schema("lix_change_set.json", LIX_CHANGE_SET_SCHEMA_JSON)
|
|
158
|
+
})),
|
|
159
|
+
LIX_COMMIT_SCHEMA_KEY => Some(
|
|
160
|
+
LIX_COMMIT_SCHEMA
|
|
161
|
+
.get_or_init(|| parse_builtin_schema("lix_commit.json", LIX_COMMIT_SCHEMA_JSON)),
|
|
162
|
+
),
|
|
163
|
+
LIX_VERSION_DESCRIPTOR_SCHEMA_KEY => {
|
|
164
|
+
Some(LIX_VERSION_DESCRIPTOR_SCHEMA.get_or_init(|| {
|
|
165
|
+
parse_builtin_schema(
|
|
166
|
+
"lix_version_descriptor.json",
|
|
167
|
+
LIX_VERSION_DESCRIPTOR_SCHEMA_JSON,
|
|
168
|
+
)
|
|
169
|
+
}))
|
|
170
|
+
}
|
|
171
|
+
LIX_VERSION_REF_SCHEMA_KEY => Some(LIX_VERSION_REF_SCHEMA.get_or_init(|| {
|
|
172
|
+
parse_builtin_schema("lix_version_ref.json", LIX_VERSION_REF_SCHEMA_JSON)
|
|
173
|
+
})),
|
|
174
|
+
LIX_CHANGE_SET_ELEMENT_SCHEMA_KEY => {
|
|
175
|
+
Some(LIX_CHANGE_SET_ELEMENT_SCHEMA.get_or_init(|| {
|
|
176
|
+
parse_builtin_schema(
|
|
177
|
+
"lix_change_set_element.json",
|
|
178
|
+
LIX_CHANGE_SET_ELEMENT_SCHEMA_JSON,
|
|
179
|
+
)
|
|
180
|
+
}))
|
|
181
|
+
}
|
|
182
|
+
LIX_COMMIT_EDGE_SCHEMA_KEY => Some(LIX_COMMIT_EDGE_SCHEMA.get_or_init(|| {
|
|
183
|
+
parse_builtin_schema("lix_commit_edge.json", LIX_COMMIT_EDGE_SCHEMA_JSON)
|
|
184
|
+
})),
|
|
185
|
+
LIX_FILE_DESCRIPTOR_SCHEMA_KEY => Some(LIX_FILE_DESCRIPTOR_SCHEMA.get_or_init(|| {
|
|
186
|
+
parse_builtin_schema("lix_file_descriptor.json", LIX_FILE_DESCRIPTOR_SCHEMA_JSON)
|
|
187
|
+
})),
|
|
188
|
+
LIX_DIRECTORY_DESCRIPTOR_SCHEMA_KEY => {
|
|
189
|
+
Some(LIX_DIRECTORY_DESCRIPTOR_SCHEMA.get_or_init(|| {
|
|
190
|
+
parse_builtin_schema(
|
|
191
|
+
"lix_directory_descriptor.json",
|
|
192
|
+
LIX_DIRECTORY_DESCRIPTOR_SCHEMA_JSON,
|
|
193
|
+
)
|
|
194
|
+
}))
|
|
195
|
+
}
|
|
196
|
+
LIX_BINARY_BLOB_REF_SCHEMA_KEY => Some(LIX_BINARY_BLOB_REF_SCHEMA.get_or_init(|| {
|
|
197
|
+
parse_builtin_schema("lix_binary_blob_ref.json", LIX_BINARY_BLOB_REF_SCHEMA_JSON)
|
|
198
|
+
})),
|
|
199
|
+
_ => None,
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
#[allow(dead_code)]
|
|
204
|
+
pub(crate) fn builtin_schema_json(schema_key: &str) -> Option<&'static str> {
|
|
205
|
+
match schema_key {
|
|
206
|
+
LIX_REGISTERED_SCHEMA_KEY => Some(LIX_REGISTERED_SCHEMA_JSON),
|
|
207
|
+
LIX_KEY_VALUE_SCHEMA_KEY => Some(LIX_KEY_VALUE_SCHEMA_JSON),
|
|
208
|
+
LIX_ACCOUNT_SCHEMA_KEY => Some(LIX_ACCOUNT_SCHEMA_JSON),
|
|
209
|
+
LIX_ACTIVE_ACCOUNT_SCHEMA_KEY => Some(LIX_ACTIVE_ACCOUNT_SCHEMA_JSON),
|
|
210
|
+
LIX_LABEL_SCHEMA_KEY => Some(LIX_LABEL_SCHEMA_JSON),
|
|
211
|
+
LIX_ENTITY_LABEL_SCHEMA_KEY => Some(LIX_ENTITY_LABEL_SCHEMA_JSON),
|
|
212
|
+
LIX_CHANGE_SCHEMA_KEY => Some(LIX_CHANGE_SCHEMA_JSON),
|
|
213
|
+
LIX_CHANGE_AUTHOR_SCHEMA_KEY => Some(LIX_CHANGE_AUTHOR_SCHEMA_JSON),
|
|
214
|
+
LIX_CHANGE_SET_SCHEMA_KEY => Some(LIX_CHANGE_SET_SCHEMA_JSON),
|
|
215
|
+
LIX_COMMIT_SCHEMA_KEY => Some(LIX_COMMIT_SCHEMA_JSON),
|
|
216
|
+
LIX_VERSION_DESCRIPTOR_SCHEMA_KEY => Some(LIX_VERSION_DESCRIPTOR_SCHEMA_JSON),
|
|
217
|
+
LIX_VERSION_REF_SCHEMA_KEY => Some(LIX_VERSION_REF_SCHEMA_JSON),
|
|
218
|
+
LIX_CHANGE_SET_ELEMENT_SCHEMA_KEY => Some(LIX_CHANGE_SET_ELEMENT_SCHEMA_JSON),
|
|
219
|
+
LIX_COMMIT_EDGE_SCHEMA_KEY => Some(LIX_COMMIT_EDGE_SCHEMA_JSON),
|
|
220
|
+
LIX_FILE_DESCRIPTOR_SCHEMA_KEY => Some(LIX_FILE_DESCRIPTOR_SCHEMA_JSON),
|
|
221
|
+
LIX_DIRECTORY_DESCRIPTOR_SCHEMA_KEY => Some(LIX_DIRECTORY_DESCRIPTOR_SCHEMA_JSON),
|
|
222
|
+
LIX_BINARY_BLOB_REF_SCHEMA_KEY => Some(LIX_BINARY_BLOB_REF_SCHEMA_JSON),
|
|
223
|
+
_ => None,
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
fn parse_builtin_schema(file_name: &str, raw_json: &str) -> JsonValue {
|
|
228
|
+
serde_json::from_str(raw_json).unwrap_or_else(|error| {
|
|
229
|
+
panic!("builtin schema file '{file_name}' must contain valid JSON: {error}")
|
|
230
|
+
})
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
fn parse_registered_schema_with_inlined_definition() -> JsonValue {
|
|
234
|
+
let mut schema = parse_builtin_schema("lix_registered_schema.json", LIX_REGISTERED_SCHEMA_JSON);
|
|
235
|
+
let value_schema = schema
|
|
236
|
+
.pointer_mut("/properties/value")
|
|
237
|
+
.expect("lix_registered_schema.json must define /properties/value");
|
|
238
|
+
let value_schema_object = value_schema
|
|
239
|
+
.as_object_mut()
|
|
240
|
+
.expect("lix_registered_schema.json /properties/value must be an object");
|
|
241
|
+
|
|
242
|
+
value_schema_object.insert(
|
|
243
|
+
"allOf".to_string(),
|
|
244
|
+
JsonValue::Array(vec![lix_schema_definition().clone()]),
|
|
245
|
+
);
|
|
246
|
+
|
|
247
|
+
schema
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
#[cfg(test)]
|
|
251
|
+
mod tests {
|
|
252
|
+
use super::{seed_schema_definition, BUILTIN_SCHEMA_KEYS};
|
|
253
|
+
|
|
254
|
+
#[test]
|
|
255
|
+
fn builtin_schemas_load_without_extra_override_metadata() {
|
|
256
|
+
for schema_key in BUILTIN_SCHEMA_KEYS {
|
|
257
|
+
seed_schema_definition(schema_key).expect("schema should exist");
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
#[test]
|
|
262
|
+
fn registered_schema_value_inlines_lix_schema_definition() {
|
|
263
|
+
let schema = seed_schema_definition("lix_registered_schema").expect("schema should exist");
|
|
264
|
+
let all_of = schema
|
|
265
|
+
.pointer("/properties/value/allOf")
|
|
266
|
+
.and_then(|value| value.as_array())
|
|
267
|
+
.expect("registered schema value must define allOf array");
|
|
268
|
+
assert_eq!(all_of.len(), 1);
|
|
269
|
+
assert_eq!(all_of[0], *crate::schema::lix_schema_definition());
|
|
270
|
+
}
|
|
271
|
+
}
|