@lix-js/sdk 0.6.0-preview.3 → 0.6.0-preview.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/README.md +1 -1
- package/SKILL.md +105 -65
- package/dist/engine-wasm/index.js +4 -4
- package/dist/engine-wasm/wasm/lix_engine.d.ts +30 -6
- package/dist/engine-wasm/wasm/lix_engine.js +187 -117
- package/dist/engine-wasm/wasm/lix_engine.wasm +0 -0
- package/dist/engine-wasm/wasm/lix_engine.wasm.d.ts +14 -8
- package/dist/generated/builtin-schemas.d.ts +69 -69
- package/dist/generated/builtin-schemas.js +94 -94
- package/dist/open-lix.d.ts +42 -28
- package/dist/open-lix.js +49 -10
- package/dist/sqlite/index.js +86 -30
- package/dist-engine-src/README.md +3 -3
- package/dist-engine-src/src/backend/capabilities.rs +67 -0
- package/dist-engine-src/src/backend/conformance/baseline.rs +1127 -0
- package/dist-engine-src/src/backend/conformance/factory.rs +93 -0
- package/dist-engine-src/src/backend/conformance/failure_tests.rs +608 -0
- package/dist-engine-src/src/backend/conformance/fixtures.rs +26 -0
- package/dist-engine-src/src/backend/conformance/mod.rs +75 -0
- package/dist-engine-src/src/backend/conformance/model.rs +28 -0
- package/dist-engine-src/src/backend/conformance/model_based.rs +257 -0
- package/dist-engine-src/src/backend/conformance/persistence.rs +204 -0
- package/dist-engine-src/src/backend/conformance/projection.rs +21 -0
- package/dist-engine-src/src/backend/conformance/pushdown.rs +24 -0
- package/dist-engine-src/src/backend/conformance/runner.rs +90 -0
- package/dist-engine-src/src/backend/conformance/scan.rs +24 -0
- package/dist-engine-src/src/backend/conformance/write.rs +16 -0
- package/dist-engine-src/src/backend/error.rs +94 -0
- package/dist-engine-src/src/backend/in_memory.rs +670 -0
- package/dist-engine-src/src/backend/mod.rs +36 -9
- package/dist-engine-src/src/backend/predicate.rs +80 -0
- package/dist-engine-src/src/backend/traits.rs +260 -0
- package/dist-engine-src/src/backend/types.rs +224 -81
- package/dist-engine-src/src/binary_cas/context.rs +8 -8
- package/dist-engine-src/src/binary_cas/kv.rs +234 -259
- package/dist-engine-src/src/{version → branch}/context.rs +12 -12
- package/dist-engine-src/src/branch/lifecycle.rs +221 -0
- package/dist-engine-src/src/branch/mod.rs +13 -0
- package/dist-engine-src/src/branch/refs.rs +321 -0
- package/dist-engine-src/src/branch/stage_rows.rs +67 -0
- package/dist-engine-src/src/branch/types.rs +21 -0
- package/dist-engine-src/src/catalog/context.rs +18 -18
- package/dist-engine-src/src/catalog/snapshot.rs +8 -8
- package/dist-engine-src/src/changelog/bench_support.rs +785 -0
- package/dist-engine-src/src/changelog/change.rs +1 -0
- package/dist-engine-src/src/changelog/codec.rs +497 -0
- package/dist-engine-src/src/changelog/commit.rs +1 -0
- package/dist-engine-src/src/changelog/context.rs +1614 -0
- package/dist-engine-src/src/changelog/mod.rs +29 -0
- package/dist-engine-src/src/changelog/store.rs +163 -0
- package/dist-engine-src/src/changelog/test_support.rs +54 -0
- package/dist-engine-src/src/changelog/types.rs +213 -0
- package/dist-engine-src/src/commit_graph/context.rs +317 -274
- package/dist-engine-src/src/commit_graph/mod.rs +2 -4
- package/dist-engine-src/src/commit_graph/types.rs +22 -42
- package/dist-engine-src/src/commit_graph/walker.rs +133 -103
- package/dist-engine-src/src/common/error.rs +52 -18
- package/dist-engine-src/src/common/identity.rs +2 -2
- package/dist-engine-src/src/common/mod.rs +1 -1
- package/dist-engine-src/src/domain.rs +42 -46
- package/dist-engine-src/src/engine.rs +74 -96
- package/dist-engine-src/src/{entity_identity.rs → entity_pk.rs} +89 -92
- package/dist-engine-src/src/functions/context.rs +56 -52
- package/dist-engine-src/src/functions/state.rs +51 -52
- package/dist-engine-src/src/init.rs +288 -154
- package/dist-engine-src/src/json_store/context.rs +15 -266
- package/dist-engine-src/src/json_store/mod.rs +26 -0
- package/dist-engine-src/src/json_store/store.rs +103 -718
- package/dist-engine-src/src/json_store/types.rs +4 -9
- package/dist-engine-src/src/lib.rs +49 -19
- package/dist-engine-src/src/live_state/context.rs +654 -790
- package/dist-engine-src/src/live_state/mod.rs +9 -3
- package/dist-engine-src/src/live_state/overlay.rs +4 -4
- package/dist-engine-src/src/live_state/types.rs +30 -21
- package/dist-engine-src/src/live_state/visibility.rs +514 -71
- package/dist-engine-src/src/plugin/install.rs +48 -48
- package/dist-engine-src/src/plugin/manifest.rs +7 -7
- package/dist-engine-src/src/plugin/materializer.rs +0 -275
- package/dist-engine-src/src/plugin/plugin_manifest.json +4 -3
- package/dist-engine-src/src/schema/builtin/lix_binary_blob_ref.json +2 -2
- package/dist-engine-src/src/schema/builtin/lix_branch_descriptor.json +34 -0
- package/dist-engine-src/src/schema/builtin/lix_branch_ref.json +48 -0
- package/dist-engine-src/src/schema/builtin/lix_change.json +3 -3
- package/dist-engine-src/src/schema/builtin/lix_commit.json +1 -1
- package/dist-engine-src/src/schema/builtin/lix_label_assignment.json +6 -6
- package/dist-engine-src/src/schema/builtin/mod.rs +18 -20
- package/dist-engine-src/src/schema/compatibility.rs +11 -11
- package/dist-engine-src/src/schema/definition.json +2 -2
- package/dist-engine-src/src/schema/definition.rs +5 -5
- package/dist-engine-src/src/schema/key.rs +3 -3
- package/dist-engine-src/src/schema/mod.rs +1 -1
- package/dist-engine-src/src/schema/tests.rs +18 -18
- package/dist-engine-src/src/session/context.rs +819 -124
- package/dist-engine-src/src/session/create_branch.rs +94 -0
- package/dist-engine-src/src/session/execute.rs +260 -57
- package/dist-engine-src/src/session/merge/analysis.rs +9 -3
- package/dist-engine-src/src/session/merge/{version.rs → branch.rs} +119 -129
- package/dist-engine-src/src/session/merge/conflicts.rs +2 -2
- package/dist-engine-src/src/session/merge/mod.rs +5 -6
- package/dist-engine-src/src/session/merge/stats.rs +7 -11
- package/dist-engine-src/src/session/mod.rs +19 -16
- package/dist-engine-src/src/session/switch_branch.rs +113 -0
- package/dist-engine-src/src/session/transaction.rs +557 -0
- package/dist-engine-src/src/sql2/bind/classify.rs +102 -0
- package/dist-engine-src/src/sql2/bind/error.rs +5 -0
- package/dist-engine-src/src/sql2/bind/expr.rs +29 -0
- package/dist-engine-src/src/sql2/bind/mod.rs +12 -0
- package/dist-engine-src/src/sql2/{udfs/public_call.rs → bind/public_udf.rs} +98 -3
- package/dist-engine-src/src/sql2/bind/read.rs +65 -0
- package/dist-engine-src/src/sql2/bind/statement.rs +2236 -0
- package/dist-engine-src/src/sql2/bind/table.rs +273 -0
- package/dist-engine-src/src/sql2/bind/write.rs +86 -0
- package/dist-engine-src/src/sql2/branch_scope.rs +436 -0
- package/dist-engine-src/src/sql2/catalog/capability.rs +20 -0
- package/dist-engine-src/src/sql2/catalog/entity_surface.rs +296 -0
- package/dist-engine-src/src/sql2/catalog/mod.rs +15 -0
- package/dist-engine-src/src/sql2/catalog/registry.rs +556 -0
- package/dist-engine-src/src/sql2/catalog/schema.rs +88 -0
- package/dist-engine-src/src/sql2/catalog/surface.rs +41 -0
- package/dist-engine-src/src/sql2/change_materialization.rs +122 -0
- package/dist-engine-src/src/sql2/context.rs +36 -30
- package/dist-engine-src/src/sql2/error.rs +4 -5
- package/dist-engine-src/src/sql2/exec/bound_public_write.rs +1593 -0
- package/dist-engine-src/src/sql2/exec/datafusion.rs +5266 -0
- package/dist-engine-src/src/sql2/exec/fast_write.rs +82 -0
- package/dist-engine-src/src/sql2/exec/mod.rs +24 -0
- package/dist-engine-src/src/sql2/exec/write.rs +661 -0
- package/dist-engine-src/src/sql2/filesystem_planner.rs +72 -77
- package/dist-engine-src/src/sql2/filesystem_visibility.rs +21 -21
- package/dist-engine-src/src/sql2/history_projection.rs +8 -8
- package/dist-engine-src/src/sql2/history_route.rs +35 -31
- package/dist-engine-src/src/sql2/mod.rs +30 -24
- package/dist-engine-src/src/sql2/optimize/datafusion.rs +1 -0
- package/dist-engine-src/src/sql2/optimize/mod.rs +2 -0
- package/dist-engine-src/src/sql2/optimize/simple_write.rs +116 -0
- package/dist-engine-src/src/sql2/parse/mod.rs +69 -0
- package/dist-engine-src/src/sql2/parse/normalize.rs +1 -0
- package/dist-engine-src/src/sql2/plan/branch_scope.rs +24 -0
- package/dist-engine-src/src/sql2/plan/mod.rs +5 -0
- package/dist-engine-src/src/sql2/plan/predicate.rs +22 -0
- package/dist-engine-src/src/sql2/plan/write.rs +147 -0
- package/dist-engine-src/src/sql2/predicate_typecheck.rs +258 -0
- package/dist-engine-src/src/sql2/{version_provider.rs → providers/branch.rs} +218 -214
- package/dist-engine-src/src/sql2/{change_provider.rs → providers/change.rs} +156 -42
- package/dist-engine-src/src/sql2/{directory_provider.rs → providers/directory.rs} +291 -322
- package/dist-engine-src/src/sql2/{directory_history_provider.rs → providers/directory_history.rs} +56 -42
- package/dist-engine-src/src/sql2/providers/entity.rs +1484 -0
- package/dist-engine-src/src/sql2/{entity_history_provider.rs → providers/entity_history.rs} +43 -31
- package/dist-engine-src/src/sql2/{file_provider.rs → providers/file.rs} +323 -316
- package/dist-engine-src/src/sql2/{file_history_provider.rs → providers/file_history.rs} +60 -46
- package/dist-engine-src/src/sql2/{history_provider.rs → providers/history.rs} +46 -32
- package/dist-engine-src/src/sql2/{lix_state_provider.rs → providers/lix_state.rs} +359 -329
- package/dist-engine-src/src/sql2/providers/mod.rs +508 -0
- package/dist-engine-src/src/sql2/read_only.rs +2 -2
- package/dist-engine-src/src/sql2/session.rs +47 -96
- package/dist-engine-src/src/sql2/storage/constraints.rs +1 -0
- package/dist-engine-src/src/sql2/storage/mod.rs +1 -0
- package/dist-engine-src/src/sql2/test_support/differential.rs +712 -0
- package/dist-engine-src/src/sql2/test_support/generators.rs +354 -0
- package/dist-engine-src/src/sql2/test_support/mod.rs +2 -0
- package/dist-engine-src/src/sql2/udfs/{lix_active_version_commit_id.rs → lix_active_branch_commit_id.rs} +7 -7
- package/dist-engine-src/src/sql2/udfs/mod.rs +3 -6
- package/dist-engine-src/src/sql2/write_normalization.rs +45 -22
- package/dist-engine-src/src/storage/conformance.rs +399 -0
- package/dist-engine-src/src/storage/context.rs +552 -288
- package/dist-engine-src/src/storage/mod.rs +48 -10
- package/dist-engine-src/src/storage/point.rs +440 -0
- package/dist-engine-src/src/storage/read_scope.rs +43 -64
- package/dist-engine-src/src/storage/reader.rs +867 -0
- package/dist-engine-src/src/storage/scan.rs +784 -0
- package/dist-engine-src/src/storage/spaces.rs +236 -0
- package/dist-engine-src/src/storage/stats.rs +80 -0
- package/dist-engine-src/src/storage/write_set.rs +962 -0
- package/dist-engine-src/src/storage_bench.rs +136 -4828
- package/dist-engine-src/src/test_support.rs +360 -138
- package/dist-engine-src/src/tracked_state/bench_support.rs +394 -0
- package/dist-engine-src/src/tracked_state/codec.rs +155 -1057
- package/dist-engine-src/src/tracked_state/commit_root_rebuild.rs +358 -0
- package/dist-engine-src/src/tracked_state/context.rs +1927 -993
- package/dist-engine-src/src/tracked_state/diff.rs +1715 -261
- package/dist-engine-src/src/tracked_state/merge.rs +74 -88
- package/dist-engine-src/src/tracked_state/mod.rs +19 -16
- package/dist-engine-src/src/tracked_state/{materialization.rs → row_materialization.rs} +50 -178
- package/dist-engine-src/src/tracked_state/storage.rs +243 -191
- package/dist-engine-src/src/tracked_state/tree.rs +247 -371
- package/dist-engine-src/src/tracked_state/types.rs +49 -42
- package/dist-engine-src/src/transaction/bench_support.rs +407 -0
- package/dist-engine-src/src/transaction/commit.rs +821 -713
- package/dist-engine-src/src/transaction/context.rs +705 -600
- package/dist-engine-src/src/transaction/mod.rs +13 -2
- package/dist-engine-src/src/transaction/normalization.rs +63 -76
- package/dist-engine-src/src/transaction/prep.rs +13 -13
- package/dist-engine-src/src/transaction/schema_resolver.rs +19 -5
- package/dist-engine-src/src/transaction/staging.rs +228 -434
- package/dist-engine-src/src/transaction/types.rs +41 -98
- package/dist-engine-src/src/transaction/validation.rs +382 -446
- package/dist-engine-src/src/untracked_state/codec.rs +337 -29
- package/dist-engine-src/src/untracked_state/context.rs +7 -7
- package/dist-engine-src/src/untracked_state/materialization.rs +2 -2
- package/dist-engine-src/src/untracked_state/mod.rs +1 -1
- package/dist-engine-src/src/untracked_state/storage.rs +659 -157
- package/dist-engine-src/src/untracked_state/types.rs +21 -21
- package/package.json +71 -68
- package/dist-engine-src/src/backend/kv.rs +0 -358
- package/dist-engine-src/src/backend/testing.rs +0 -658
- package/dist-engine-src/src/commit_store/codec.rs +0 -887
- package/dist-engine-src/src/commit_store/context.rs +0 -944
- package/dist-engine-src/src/commit_store/materialization.rs +0 -84
- package/dist-engine-src/src/commit_store/mod.rs +0 -16
- package/dist-engine-src/src/commit_store/storage.rs +0 -600
- package/dist-engine-src/src/commit_store/types.rs +0 -215
- package/dist-engine-src/src/schema/builtin/lix_version_descriptor.json +0 -34
- package/dist-engine-src/src/schema/builtin/lix_version_ref.json +0 -48
- package/dist-engine-src/src/session/create_version.rs +0 -88
- package/dist-engine-src/src/session/merge/apply.rs +0 -23
- package/dist-engine-src/src/session/optimization9_sql2_bench.rs +0 -100
- package/dist-engine-src/src/session/switch_version.rs +0 -109
- package/dist-engine-src/src/sql2/classify.rs +0 -182
- package/dist-engine-src/src/sql2/entity_provider.rs +0 -3211
- package/dist-engine-src/src/sql2/execute.rs +0 -3440
- package/dist-engine-src/src/sql2/public_bind/assignment.rs +0 -46
- package/dist-engine-src/src/sql2/public_bind/capability.rs +0 -41
- package/dist-engine-src/src/sql2/public_bind/dml.rs +0 -166
- package/dist-engine-src/src/sql2/public_bind/mod.rs +0 -25
- package/dist-engine-src/src/sql2/public_bind/table.rs +0 -168
- package/dist-engine-src/src/sql2/version_scope.rs +0 -394
- package/dist-engine-src/src/storage/types.rs +0 -501
- package/dist-engine-src/src/tracked_state/by_file_index.rs +0 -98
- package/dist-engine-src/src/tracked_state/materializer.rs +0 -488
- package/dist-engine-src/src/transaction/live_state_overlay.rs +0 -35
- package/dist-engine-src/src/version/lifecycle.rs +0 -221
- package/dist-engine-src/src/version/mod.rs +0 -13
- package/dist-engine-src/src/version/refs.rs +0 -330
- package/dist-engine-src/src/version/stage_rows.rs +0 -67
- package/dist-engine-src/src/version/types.rs +0 -21
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
use std::{collections::BTreeSet, fmt, ops::Deref, sync::Arc};
|
|
2
2
|
|
|
3
3
|
use crate::catalog::SchemaPlanId;
|
|
4
|
-
use crate::
|
|
4
|
+
use crate::entity_pk::EntityPk;
|
|
5
5
|
use crate::json_store::JsonRef;
|
|
6
6
|
use crate::live_state::MaterializedLiveStateRow;
|
|
7
|
-
use crate::tracked_state::MaterializedTrackedStateRow;
|
|
8
7
|
use crate::untracked_state::MaterializedUntrackedStateRow;
|
|
9
8
|
use crate::LixError;
|
|
10
9
|
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
|
@@ -112,7 +111,7 @@ impl<'de> Deserialize<'de> for TransactionJson {
|
|
|
112
111
|
/// `PreparedStateRow` without serializing already-normalized JSON again.
|
|
113
112
|
///
|
|
114
113
|
/// SQL providers stage semantic rows, not final storage rows. INSERT providers
|
|
115
|
-
/// may omit defaulted snapshot fields and leave `
|
|
114
|
+
/// may omit defaulted snapshot fields and leave `entity_pk` unset when the
|
|
116
115
|
/// target schema has an `x-lix-primary-key`; transaction normalization applies
|
|
117
116
|
/// schema defaults and derives the final identity. Typed UPDATE providers must
|
|
118
117
|
/// stage full rewritten snapshots after applying column assignments to the
|
|
@@ -120,7 +119,7 @@ impl<'de> Deserialize<'de> for TransactionJson {
|
|
|
120
119
|
/// implicit patches.
|
|
121
120
|
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
|
122
121
|
pub(crate) struct TransactionWriteRow {
|
|
123
|
-
pub(crate)
|
|
122
|
+
pub(crate) entity_pk: Option<EntityPk>,
|
|
124
123
|
pub(crate) schema_key: String,
|
|
125
124
|
pub(crate) file_id: Option<String>,
|
|
126
125
|
pub(crate) snapshot: Option<TransactionJson>,
|
|
@@ -132,15 +131,15 @@ pub(crate) struct TransactionWriteRow {
|
|
|
132
131
|
pub(crate) change_id: Option<String>,
|
|
133
132
|
pub(crate) commit_id: Option<String>,
|
|
134
133
|
pub(crate) untracked: bool,
|
|
135
|
-
pub(crate)
|
|
134
|
+
pub(crate) branch_id: String,
|
|
136
135
|
}
|
|
137
136
|
|
|
138
137
|
impl TransactionWriteRow {
|
|
139
|
-
pub(crate) fn
|
|
138
|
+
pub(crate) fn schema_scope_branch_id(&self) -> &str {
|
|
140
139
|
if self.global {
|
|
141
|
-
crate::
|
|
140
|
+
crate::GLOBAL_BRANCH_ID
|
|
142
141
|
} else {
|
|
143
|
-
self.
|
|
142
|
+
self.branch_id.as_str()
|
|
144
143
|
}
|
|
145
144
|
}
|
|
146
145
|
}
|
|
@@ -175,23 +174,11 @@ pub(crate) struct LogicalPrimaryKey {
|
|
|
175
174
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
176
175
|
pub(crate) struct TransactionFileData {
|
|
177
176
|
pub(crate) file_id: String,
|
|
178
|
-
pub(crate)
|
|
177
|
+
pub(crate) branch_id: String,
|
|
179
178
|
pub(crate) untracked: bool,
|
|
180
179
|
pub(crate) data: Vec<u8>,
|
|
181
180
|
}
|
|
182
181
|
|
|
183
|
-
/// Existing canonical change adopted into another version's tracked projection.
|
|
184
|
-
///
|
|
185
|
-
/// Merges use this path when the source side already owns the canonical
|
|
186
|
-
/// changelog fact. The target commit references that existing change id and
|
|
187
|
-
/// writes a target-version projection row without appending a copied change.
|
|
188
|
-
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
189
|
-
pub(crate) struct TransactionAdoptedChange {
|
|
190
|
-
pub(crate) version_id: String,
|
|
191
|
-
pub(crate) change_id: String,
|
|
192
|
-
pub(crate) projected_row: MaterializedTrackedStateRow,
|
|
193
|
-
}
|
|
194
|
-
|
|
195
182
|
/// One decoded write batch accepted by the transaction boundary.
|
|
196
183
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
197
184
|
pub(crate) enum TransactionWrite {
|
|
@@ -205,9 +192,6 @@ pub(crate) enum TransactionWrite {
|
|
|
205
192
|
file_data: Vec<TransactionFileData>,
|
|
206
193
|
count: u64,
|
|
207
194
|
},
|
|
208
|
-
AdoptedChanges {
|
|
209
|
-
changes: Vec<TransactionAdoptedChange>,
|
|
210
|
-
},
|
|
211
195
|
}
|
|
212
196
|
|
|
213
197
|
/// One decoded write batch after semantic normalization and JSON preparation.
|
|
@@ -223,9 +207,6 @@ pub(crate) enum PreparedTransactionWrite {
|
|
|
223
207
|
file_data: Vec<TransactionFileData>,
|
|
224
208
|
count: u64,
|
|
225
209
|
},
|
|
226
|
-
AdoptedChanges {
|
|
227
|
-
rows: Vec<PreparedAdoptedStateRow>,
|
|
228
|
-
},
|
|
229
210
|
}
|
|
230
211
|
|
|
231
212
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
@@ -284,7 +265,7 @@ pub(crate) struct PreparedRowFacts {
|
|
|
284
265
|
pub(crate) struct PreparedStateRow {
|
|
285
266
|
pub(crate) schema_plan_id: SchemaPlanId,
|
|
286
267
|
pub(crate) facts: PreparedRowFacts,
|
|
287
|
-
pub(crate)
|
|
268
|
+
pub(crate) entity_pk: EntityPk,
|
|
288
269
|
pub(crate) schema_key: String,
|
|
289
270
|
pub(crate) file_id: Option<String>,
|
|
290
271
|
pub(crate) snapshot: Option<StageJson>,
|
|
@@ -296,32 +277,14 @@ pub(crate) struct PreparedStateRow {
|
|
|
296
277
|
pub(crate) change_id: Option<String>,
|
|
297
278
|
pub(crate) commit_id: Option<String>,
|
|
298
279
|
pub(crate) untracked: bool,
|
|
299
|
-
pub(crate)
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
/// Transaction-hydrated projection for an adopted canonical change.
|
|
303
|
-
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
304
|
-
pub(crate) struct PreparedAdoptedStateRow {
|
|
305
|
-
pub(crate) schema_plan_id: SchemaPlanId,
|
|
306
|
-
pub(crate) facts: PreparedRowFacts,
|
|
307
|
-
pub(crate) entity_id: EntityIdentity,
|
|
308
|
-
pub(crate) schema_key: String,
|
|
309
|
-
pub(crate) file_id: Option<String>,
|
|
310
|
-
pub(crate) snapshot: Option<StageJson>,
|
|
311
|
-
pub(crate) metadata: Option<StageJson>,
|
|
312
|
-
pub(crate) created_at: String,
|
|
313
|
-
pub(crate) updated_at: String,
|
|
314
|
-
pub(crate) global: bool,
|
|
315
|
-
pub(crate) change_id: String,
|
|
316
|
-
pub(crate) commit_id: String,
|
|
317
|
-
pub(crate) version_id: String,
|
|
280
|
+
pub(crate) branch_id: String,
|
|
318
281
|
}
|
|
319
282
|
|
|
320
283
|
impl From<PreparedStateRow> for MaterializedLiveStateRow {
|
|
321
284
|
fn from(row: PreparedStateRow) -> Self {
|
|
322
285
|
let deleted = row.snapshot.is_none();
|
|
323
286
|
MaterializedLiveStateRow {
|
|
324
|
-
|
|
287
|
+
entity_pk: row.entity_pk,
|
|
325
288
|
schema_key: row.schema_key,
|
|
326
289
|
file_id: row.file_id,
|
|
327
290
|
snapshot_content: row.snapshot.map(|snapshot| snapshot.materialize()),
|
|
@@ -333,7 +296,7 @@ impl From<PreparedStateRow> for MaterializedLiveStateRow {
|
|
|
333
296
|
change_id: row.change_id,
|
|
334
297
|
commit_id: row.commit_id,
|
|
335
298
|
untracked: row.untracked,
|
|
336
|
-
|
|
299
|
+
branch_id: row.branch_id,
|
|
337
300
|
}
|
|
338
301
|
}
|
|
339
302
|
}
|
|
@@ -341,7 +304,7 @@ impl From<PreparedStateRow> for MaterializedLiveStateRow {
|
|
|
341
304
|
impl From<&PreparedStateRow> for MaterializedLiveStateRow {
|
|
342
305
|
fn from(row: &PreparedStateRow) -> Self {
|
|
343
306
|
MaterializedLiveStateRow {
|
|
344
|
-
|
|
307
|
+
entity_pk: row.entity_pk.clone(),
|
|
345
308
|
schema_key: row.schema_key.clone(),
|
|
346
309
|
file_id: row.file_id.clone(),
|
|
347
310
|
snapshot_content: row.snapshot.as_ref().map(StageJson::materialize),
|
|
@@ -353,48 +316,7 @@ impl From<&PreparedStateRow> for MaterializedLiveStateRow {
|
|
|
353
316
|
change_id: row.change_id.clone(),
|
|
354
317
|
commit_id: row.commit_id.clone(),
|
|
355
318
|
untracked: row.untracked,
|
|
356
|
-
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
impl From<PreparedAdoptedStateRow> for MaterializedLiveStateRow {
|
|
362
|
-
fn from(row: PreparedAdoptedStateRow) -> Self {
|
|
363
|
-
let deleted = row.snapshot.is_none();
|
|
364
|
-
MaterializedLiveStateRow {
|
|
365
|
-
entity_id: row.entity_id,
|
|
366
|
-
schema_key: row.schema_key,
|
|
367
|
-
file_id: row.file_id,
|
|
368
|
-
snapshot_content: row.snapshot.map(|snapshot| snapshot.materialize()),
|
|
369
|
-
metadata: row.metadata.map(|metadata| metadata.materialize()),
|
|
370
|
-
deleted,
|
|
371
|
-
created_at: row.created_at,
|
|
372
|
-
updated_at: row.updated_at,
|
|
373
|
-
global: row.global,
|
|
374
|
-
change_id: Some(row.change_id),
|
|
375
|
-
commit_id: Some(row.commit_id),
|
|
376
|
-
untracked: false,
|
|
377
|
-
version_id: row.version_id,
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
impl From<&PreparedAdoptedStateRow> for MaterializedLiveStateRow {
|
|
383
|
-
fn from(row: &PreparedAdoptedStateRow) -> Self {
|
|
384
|
-
MaterializedLiveStateRow {
|
|
385
|
-
entity_id: row.entity_id.clone(),
|
|
386
|
-
schema_key: row.schema_key.clone(),
|
|
387
|
-
file_id: row.file_id.clone(),
|
|
388
|
-
snapshot_content: row.snapshot.as_ref().map(StageJson::materialize),
|
|
389
|
-
metadata: row.metadata.as_ref().map(StageJson::materialize),
|
|
390
|
-
deleted: row.snapshot.is_none(),
|
|
391
|
-
created_at: row.created_at.clone(),
|
|
392
|
-
updated_at: row.updated_at.clone(),
|
|
393
|
-
global: row.global,
|
|
394
|
-
change_id: Some(row.change_id.clone()),
|
|
395
|
-
commit_id: Some(row.commit_id.clone()),
|
|
396
|
-
untracked: false,
|
|
397
|
-
version_id: row.version_id.clone(),
|
|
319
|
+
branch_id: row.branch_id.clone(),
|
|
398
320
|
}
|
|
399
321
|
}
|
|
400
322
|
}
|
|
@@ -403,7 +325,7 @@ impl From<PreparedStateRow> for MaterializedUntrackedStateRow {
|
|
|
403
325
|
fn from(row: PreparedStateRow) -> Self {
|
|
404
326
|
let deleted = row.snapshot.is_none();
|
|
405
327
|
MaterializedUntrackedStateRow {
|
|
406
|
-
|
|
328
|
+
entity_pk: row.entity_pk,
|
|
407
329
|
schema_key: row.schema_key,
|
|
408
330
|
file_id: row.file_id,
|
|
409
331
|
snapshot_content: row.snapshot.map(|snapshot| snapshot.materialize()),
|
|
@@ -412,32 +334,47 @@ impl From<PreparedStateRow> for MaterializedUntrackedStateRow {
|
|
|
412
334
|
created_at: row.created_at,
|
|
413
335
|
updated_at: row.updated_at,
|
|
414
336
|
global: row.global,
|
|
415
|
-
|
|
337
|
+
branch_id: row.branch_id,
|
|
416
338
|
}
|
|
417
339
|
}
|
|
418
340
|
}
|
|
419
341
|
|
|
420
|
-
/// Transaction-local
|
|
342
|
+
/// Transaction-local commit change refs accumulated while rows are staged.
|
|
421
343
|
///
|
|
422
344
|
/// Final commit row materialization owns commit ids, parent heads, and commit
|
|
423
345
|
/// row timestamps. Staging only tracks which hydrated tracked changes the
|
|
424
|
-
/// future commit introduces for a
|
|
346
|
+
/// future commit introduces for a branch.
|
|
425
347
|
#[derive(Debug, Clone, Default, PartialEq, Eq)]
|
|
426
|
-
pub(crate) struct
|
|
348
|
+
pub(crate) struct StagedCommitChangeRefs {
|
|
427
349
|
pub(crate) commit_id: String,
|
|
428
350
|
pub(crate) commit_change_id: String,
|
|
429
351
|
pub(crate) created_at: String,
|
|
430
352
|
pub(crate) change_ids: BTreeSet<String>,
|
|
353
|
+
pub(crate) selected_change_refs: Vec<StagedCommitChangeRef>,
|
|
431
354
|
pub(crate) allow_empty: bool,
|
|
432
355
|
}
|
|
433
356
|
|
|
434
|
-
|
|
357
|
+
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
358
|
+
pub(crate) struct StagedCommitChangeRef {
|
|
359
|
+
pub(crate) schema_key: String,
|
|
360
|
+
pub(crate) file_id: Option<String>,
|
|
361
|
+
pub(crate) entity_pk: EntityPk,
|
|
362
|
+
pub(crate) change_id: String,
|
|
363
|
+
pub(crate) snapshot_ref: Option<JsonRef>,
|
|
364
|
+
pub(crate) metadata_ref: Option<JsonRef>,
|
|
365
|
+
pub(crate) deleted: bool,
|
|
366
|
+
pub(crate) created_at: String,
|
|
367
|
+
pub(crate) updated_at: String,
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
impl StagedCommitChangeRefs {
|
|
435
371
|
pub(crate) fn new(commit_id: String, commit_change_id: String, created_at: String) -> Self {
|
|
436
372
|
Self {
|
|
437
373
|
commit_id,
|
|
438
374
|
commit_change_id,
|
|
439
375
|
created_at,
|
|
440
376
|
change_ids: BTreeSet::new(),
|
|
377
|
+
selected_change_refs: Vec::new(),
|
|
441
378
|
allow_empty: false,
|
|
442
379
|
}
|
|
443
380
|
}
|
|
@@ -446,6 +383,12 @@ impl StagedCommitMembers {
|
|
|
446
383
|
self.change_ids.insert(change_id);
|
|
447
384
|
}
|
|
448
385
|
|
|
386
|
+
pub(crate) fn add_selected_change_ref(&mut self, change_ref: StagedCommitChangeRef) {
|
|
387
|
+
if self.change_ids.insert(change_ref.change_id.clone()) {
|
|
388
|
+
self.selected_change_refs.push(change_ref);
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
|
|
449
392
|
pub(crate) fn remove_change_id(&mut self, change_id: &str) {
|
|
450
393
|
self.change_ids.remove(change_id);
|
|
451
394
|
}
|