@platforma-sdk/model 1.58.3 → 1.58.9
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/_virtual/_rolldown/runtime.cjs +43 -0
- package/dist/_virtual/_rolldown/runtime.js +18 -0
- package/dist/annotations/converter.cjs +15 -20
- package/dist/annotations/converter.cjs.map +1 -1
- package/dist/annotations/converter.d.ts +6 -2
- package/dist/annotations/converter.js +14 -18
- package/dist/annotations/converter.js.map +1 -1
- package/dist/annotations/index.cjs +1 -0
- package/dist/annotations/index.d.ts +2 -3
- package/dist/annotations/index.js +1 -0
- package/dist/annotations/types.d.ts +21 -16
- package/dist/bconfig/index.cjs +2 -0
- package/dist/bconfig/index.d.ts +5 -6
- package/dist/bconfig/index.js +2 -0
- package/dist/bconfig/lambdas.d.ts +52 -52
- package/dist/bconfig/normalization.cjs +13 -18
- package/dist/bconfig/normalization.cjs.map +1 -1
- package/dist/bconfig/normalization.d.ts +10 -6
- package/dist/bconfig/normalization.js +12 -16
- package/dist/bconfig/normalization.js.map +1 -1
- package/dist/bconfig/types.cjs +4 -3
- package/dist/bconfig/types.cjs.map +1 -1
- package/dist/bconfig/types.d.ts +10 -5
- package/dist/bconfig/types.js +4 -2
- package/dist/bconfig/types.js.map +1 -1
- package/dist/bconfig/util.d.ts +7 -4
- package/dist/bconfig/v3.d.ts +10 -6
- package/dist/block_api_v1.d.ts +62 -58
- package/dist/block_api_v2.d.ts +51 -47
- package/dist/block_api_v3.d.ts +33 -29
- package/dist/block_migrations.cjs +481 -413
- package/dist/block_migrations.cjs.map +1 -1
- package/dist/block_migrations.d.ts +258 -204
- package/dist/block_migrations.js +482 -408
- package/dist/block_migrations.js.map +1 -1
- package/dist/block_model.cjs +312 -343
- package/dist/block_model.cjs.map +1 -1
- package/dist/block_model.d.ts +143 -147
- package/dist/block_model.js +312 -341
- package/dist/block_model.js.map +1 -1
- package/dist/block_model_legacy.cjs +231 -255
- package/dist/block_model_legacy.cjs.map +1 -1
- package/dist/block_model_legacy.d.ts +108 -106
- package/dist/block_model_legacy.js +231 -253
- package/dist/block_model_legacy.js.map +1 -1
- package/dist/block_state_patch.d.ts +10 -10
- package/dist/block_state_util.cjs +15 -19
- package/dist/block_state_util.cjs.map +1 -1
- package/dist/block_state_util.d.ts +14 -13
- package/dist/block_state_util.js +15 -18
- package/dist/block_state_util.js.map +1 -1
- package/dist/block_storage.cjs +233 -238
- package/dist/block_storage.cjs.map +1 -1
- package/dist/block_storage.d.ts +62 -78
- package/dist/block_storage.js +234 -237
- package/dist/block_storage.js.map +1 -1
- package/dist/block_storage_callbacks.cjs +156 -195
- package/dist/block_storage_callbacks.cjs.map +1 -1
- package/dist/block_storage_callbacks.js +156 -192
- package/dist/block_storage_callbacks.js.map +1 -1
- package/dist/block_storage_facade.cjs +29 -85
- package/dist/block_storage_facade.cjs.map +1 -1
- package/dist/block_storage_facade.d.ts +83 -126
- package/dist/block_storage_facade.js +29 -83
- package/dist/block_storage_facade.js.map +1 -1
- package/dist/components/PFrameForGraphs.cjs +26 -24
- package/dist/components/PFrameForGraphs.cjs.map +1 -1
- package/dist/components/PFrameForGraphs.d.ts +12 -7
- package/dist/components/PFrameForGraphs.js +25 -22
- package/dist/components/PFrameForGraphs.js.map +1 -1
- package/dist/components/PlAnnotations/filter.d.ts +62 -79
- package/dist/components/PlAnnotations/filters_ui.cjs +135 -171
- package/dist/components/PlAnnotations/filters_ui.cjs.map +1 -1
- package/dist/components/PlAnnotations/filters_ui.d.ts +48 -46
- package/dist/components/PlAnnotations/filters_ui.js +135 -170
- package/dist/components/PlAnnotations/filters_ui.js.map +1 -1
- package/dist/components/PlAnnotations/index.d.ts +2 -3
- package/dist/components/PlDataTable/index.cjs +2 -0
- package/dist/components/PlDataTable/index.d.ts +3 -5
- package/dist/components/PlDataTable/index.js +2 -0
- package/dist/components/PlDataTable/labels.cjs +59 -81
- package/dist/components/PlDataTable/labels.cjs.map +1 -1
- package/dist/components/PlDataTable/labels.js +58 -79
- package/dist/components/PlDataTable/labels.js.map +1 -1
- package/dist/components/PlDataTable/state-migration.cjs +186 -144
- package/dist/components/PlDataTable/state-migration.cjs.map +1 -1
- package/dist/components/PlDataTable/state-migration.d.ts +85 -82
- package/dist/components/PlDataTable/state-migration.js +185 -142
- package/dist/components/PlDataTable/state-migration.js.map +1 -1
- package/dist/components/PlDataTable/table.cjs +172 -194
- package/dist/components/PlDataTable/table.cjs.map +1 -1
- package/dist/components/PlDataTable/table.d.ts +16 -12
- package/dist/components/PlDataTable/table.js +171 -192
- package/dist/components/PlDataTable/table.js.map +1 -1
- package/dist/components/PlDataTable/v4.d.ts +84 -119
- package/dist/components/PlDataTable/v5.d.ts +80 -103
- package/dist/components/PlMultiSequenceAlignment.cjs +27 -29
- package/dist/components/PlMultiSequenceAlignment.cjs.map +1 -1
- package/dist/components/PlMultiSequenceAlignment.d.ts +36 -27
- package/dist/components/PlMultiSequenceAlignment.js +26 -27
- package/dist/components/PlMultiSequenceAlignment.js.map +1 -1
- package/dist/components/PlSelectionModel.cjs +7 -6
- package/dist/components/PlSelectionModel.cjs.map +1 -1
- package/dist/components/PlSelectionModel.d.ts +10 -8
- package/dist/components/PlSelectionModel.js +7 -5
- package/dist/components/PlSelectionModel.js.map +1 -1
- package/dist/components/index.cjs +8 -0
- package/dist/components/index.d.ts +11 -6
- package/dist/components/index.js +8 -0
- package/dist/config/actions.cjs +138 -171
- package/dist/config/actions.cjs.map +1 -1
- package/dist/config/actions.d.ts +47 -47
- package/dist/config/actions.js +146 -178
- package/dist/config/actions.js.map +1 -1
- package/dist/config/actions_kinds.d.ts +114 -121
- package/dist/config/index.cjs +1 -0
- package/dist/config/index.d.ts +6 -7
- package/dist/config/index.js +1 -0
- package/dist/config/model.d.ts +131 -127
- package/dist/config/model_meta.d.ts +4 -1
- package/dist/config/type_engine.d.ts +22 -21
- package/dist/config/type_util.d.ts +12 -10
- package/dist/env_value.cjs +5 -6
- package/dist/env_value.cjs.map +1 -1
- package/dist/env_value.d.ts +4 -1
- package/dist/env_value.js +5 -5
- package/dist/env_value.js.map +1 -1
- package/dist/filters/converters/filterToQuery.cjs +273 -239
- package/dist/filters/converters/filterToQuery.cjs.map +1 -1
- package/dist/filters/converters/filterToQuery.d.ts +6 -2
- package/dist/filters/converters/filterToQuery.js +272 -237
- package/dist/filters/converters/filterToQuery.js.map +1 -1
- package/dist/filters/converters/filterUiToExpressionImpl.cjs +56 -85
- package/dist/filters/converters/filterUiToExpressionImpl.cjs.map +1 -1
- package/dist/filters/converters/filterUiToExpressionImpl.d.ts +8 -4
- package/dist/filters/converters/filterUiToExpressionImpl.js +55 -83
- package/dist/filters/converters/filterUiToExpressionImpl.js.map +1 -1
- package/dist/filters/converters/index.cjs +2 -0
- package/dist/filters/converters/index.d.ts +2 -3
- package/dist/filters/converters/index.js +2 -0
- package/dist/filters/distill.cjs +59 -50
- package/dist/filters/distill.cjs.map +1 -1
- package/dist/filters/distill.d.ts +6 -3
- package/dist/filters/distill.js +58 -48
- package/dist/filters/distill.js.map +1 -1
- package/dist/filters/index.cjs +4 -0
- package/dist/filters/index.d.ts +5 -4
- package/dist/filters/index.js +4 -0
- package/dist/filters/traverse.cjs +31 -40
- package/dist/filters/traverse.cjs.map +1 -1
- package/dist/filters/traverse.js +31 -39
- package/dist/filters/traverse.js.map +1 -1
- package/dist/filters/types.d.ts +10 -7
- package/dist/index.cjs +193 -187
- package/dist/index.d.ts +61 -28
- package/dist/index.js +49 -41
- package/dist/internal.cjs +48 -62
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.js +49 -60
- package/dist/internal.js.map +1 -1
- package/dist/package.cjs +12 -0
- package/dist/package.cjs.map +1 -0
- package/dist/package.js +6 -0
- package/dist/package.js.map +1 -0
- package/dist/pframe.cjs +32 -37
- package/dist/pframe.cjs.map +1 -1
- package/dist/pframe.d.ts +14 -10
- package/dist/pframe.js +32 -35
- package/dist/pframe.js.map +1 -1
- package/dist/pframe_utils/axes.cjs +81 -114
- package/dist/pframe_utils/axes.cjs.map +1 -1
- package/dist/pframe_utils/axes.d.ts +10 -13
- package/dist/pframe_utils/axes.js +80 -112
- package/dist/pframe_utils/axes.js.map +1 -1
- package/dist/pframe_utils/columns.cjs +61 -81
- package/dist/pframe_utils/columns.cjs.map +1 -1
- package/dist/pframe_utils/columns.d.ts +15 -6
- package/dist/pframe_utils/columns.js +60 -79
- package/dist/pframe_utils/columns.js.map +1 -1
- package/dist/pframe_utils/index.cjs +232 -253
- package/dist/pframe_utils/index.cjs.map +1 -1
- package/dist/pframe_utils/index.d.ts +39 -35
- package/dist/pframe_utils/index.js +231 -251
- package/dist/pframe_utils/index.js.map +1 -1
- package/dist/platforma.d.ts +48 -46
- package/dist/plugin_handle.cjs +6 -14
- package/dist/plugin_handle.cjs.map +1 -1
- package/dist/plugin_handle.d.ts +20 -25
- package/dist/plugin_handle.js +6 -13
- package/dist/plugin_handle.js.map +1 -1
- package/dist/plugin_model.cjs +364 -163
- package/dist/plugin_model.cjs.map +1 -1
- package/dist/plugin_model.d.ts +280 -129
- package/dist/plugin_model.js +362 -163
- package/dist/plugin_model.js.map +1 -1
- package/dist/raw_globals.cjs +10 -22
- package/dist/raw_globals.cjs.map +1 -1
- package/dist/raw_globals.d.ts +8 -5
- package/dist/raw_globals.js +10 -20
- package/dist/raw_globals.js.map +1 -1
- package/dist/ref_util.cjs +14 -13
- package/dist/ref_util.cjs.map +1 -1
- package/dist/ref_util.d.ts +18 -12
- package/dist/ref_util.js +14 -11
- package/dist/ref_util.js.map +1 -1
- package/dist/render/accessor.cjs +213 -226
- package/dist/render/accessor.cjs.map +1 -1
- package/dist/render/accessor.d.ts +115 -120
- package/dist/render/accessor.js +212 -224
- package/dist/render/accessor.js.map +1 -1
- package/dist/render/api.cjs +478 -580
- package/dist/render/api.cjs.map +1 -1
- package/dist/render/api.d.ts +207 -209
- package/dist/render/api.js +476 -578
- package/dist/render/api.js.map +1 -1
- package/dist/render/future.cjs +28 -32
- package/dist/render/future.cjs.map +1 -1
- package/dist/render/future.d.ts +15 -11
- package/dist/render/future.js +28 -30
- package/dist/render/future.js.map +1 -1
- package/dist/render/index.cjs +8 -0
- package/dist/render/index.d.ts +10 -8
- package/dist/render/index.js +8 -0
- package/dist/render/internal.cjs +33 -29
- package/dist/render/internal.cjs.map +1 -1
- package/dist/render/internal.d.ts +78 -72
- package/dist/render/internal.js +29 -26
- package/dist/render/internal.js.map +1 -1
- package/dist/render/traversal_ops.d.ts +42 -43
- package/dist/render/util/axis_filtering.cjs +63 -86
- package/dist/render/util/axis_filtering.cjs.map +1 -1
- package/dist/render/util/axis_filtering.d.ts +10 -7
- package/dist/render/util/axis_filtering.js +63 -85
- package/dist/render/util/axis_filtering.js.map +1 -1
- package/dist/render/util/column_collection.cjs +266 -321
- package/dist/render/util/column_collection.cjs.map +1 -1
- package/dist/render/util/column_collection.d.ts +47 -47
- package/dist/render/util/column_collection.js +264 -319
- package/dist/render/util/column_collection.js.map +1 -1
- package/dist/render/util/index.cjs +4 -0
- package/dist/render/util/index.d.ts +4 -5
- package/dist/render/util/index.js +4 -0
- package/dist/render/util/label.cjs +129 -163
- package/dist/render/util/label.cjs.map +1 -1
- package/dist/render/util/label.d.ts +45 -46
- package/dist/render/util/label.js +128 -161
- package/dist/render/util/label.js.map +1 -1
- package/dist/render/util/pcolumn_data.cjs +315 -375
- package/dist/render/util/pcolumn_data.cjs.map +1 -1
- package/dist/render/util/pcolumn_data.d.ts +33 -32
- package/dist/render/util/pcolumn_data.js +314 -373
- package/dist/render/util/pcolumn_data.js.map +1 -1
- package/dist/render/util/pframe_upgraders.cjs +37 -42
- package/dist/render/util/pframe_upgraders.cjs.map +1 -1
- package/dist/render/util/pframe_upgraders.js +37 -41
- package/dist/render/util/pframe_upgraders.js.map +1 -1
- package/dist/render/util/split_selectors.d.ts +13 -9
- package/dist/version.cjs +6 -8
- package/dist/version.cjs.map +1 -1
- package/dist/version.d.ts +7 -4
- package/dist/version.js +5 -5
- package/dist/version.js.map +1 -1
- package/package.json +9 -3
- package/src/block_migrations.test.ts +184 -14
- package/src/block_migrations.ts +185 -30
- package/src/block_model.ts +111 -66
- package/src/block_storage.test.ts +147 -3
- package/src/block_storage.ts +43 -8
- package/src/block_storage_callbacks.ts +9 -4
- package/src/env_value.ts +0 -2
- package/src/filters/distill.ts +17 -6
- package/src/index.ts +12 -11
- package/src/internal.ts +0 -1
- package/src/platforma.ts +4 -4
- package/src/plugin_handle.ts +1 -1
- package/src/plugin_model.test.ts +217 -21
- package/src/plugin_model.ts +450 -55
- package/src/raw_globals.ts +0 -1
- package/dist/annotations/converter.d.ts.map +0 -1
- package/dist/annotations/index.d.ts.map +0 -1
- package/dist/annotations/types.d.ts.map +0 -1
- package/dist/bconfig/index.d.ts.map +0 -1
- package/dist/bconfig/lambdas.d.ts.map +0 -1
- package/dist/bconfig/normalization.d.ts.map +0 -1
- package/dist/bconfig/types.d.ts.map +0 -1
- package/dist/bconfig/util.d.ts.map +0 -1
- package/dist/bconfig/v3.d.ts.map +0 -1
- package/dist/block_api_v1.d.ts.map +0 -1
- package/dist/block_api_v2.d.ts.map +0 -1
- package/dist/block_api_v3.d.ts.map +0 -1
- package/dist/block_migrations.d.ts.map +0 -1
- package/dist/block_model.d.ts.map +0 -1
- package/dist/block_model_legacy.d.ts.map +0 -1
- package/dist/block_state_patch.d.ts.map +0 -1
- package/dist/block_state_util.d.ts.map +0 -1
- package/dist/block_storage.d.ts.map +0 -1
- package/dist/block_storage_callbacks.d.ts +0 -115
- package/dist/block_storage_callbacks.d.ts.map +0 -1
- package/dist/block_storage_facade.d.ts.map +0 -1
- package/dist/components/PFrameForGraphs.d.ts.map +0 -1
- package/dist/components/PlAnnotations/filter.d.ts.map +0 -1
- package/dist/components/PlAnnotations/filters_ui.d.ts.map +0 -1
- package/dist/components/PlAnnotations/index.d.ts.map +0 -1
- package/dist/components/PlAnnotations/types.d.ts +0 -3
- package/dist/components/PlAnnotations/types.d.ts.map +0 -1
- package/dist/components/PlDataTable/index.d.ts.map +0 -1
- package/dist/components/PlDataTable/labels.d.ts +0 -7
- package/dist/components/PlDataTable/labels.d.ts.map +0 -1
- package/dist/components/PlDataTable/state-migration.d.ts.map +0 -1
- package/dist/components/PlDataTable/table.d.ts.map +0 -1
- package/dist/components/PlDataTable/v4.d.ts.map +0 -1
- package/dist/components/PlDataTable/v5.d.ts.map +0 -1
- package/dist/components/PlMultiSequenceAlignment.d.ts.map +0 -1
- package/dist/components/PlSelectionModel.d.ts.map +0 -1
- package/dist/components/index.d.ts.map +0 -1
- package/dist/config/actions.d.ts.map +0 -1
- package/dist/config/actions_kinds.d.ts.map +0 -1
- package/dist/config/index.d.ts.map +0 -1
- package/dist/config/model.d.ts.map +0 -1
- package/dist/config/model_meta.d.ts.map +0 -1
- package/dist/config/type_engine.d.ts.map +0 -1
- package/dist/config/type_util.d.ts.map +0 -1
- package/dist/env_value.d.ts.map +0 -1
- package/dist/filters/converters/filterToQuery.d.ts.map +0 -1
- package/dist/filters/converters/filterUiToExpressionImpl.d.ts.map +0 -1
- package/dist/filters/converters/index.d.ts.map +0 -1
- package/dist/filters/distill.d.ts.map +0 -1
- package/dist/filters/index.d.ts.map +0 -1
- package/dist/filters/traverse.d.ts +0 -27
- package/dist/filters/traverse.d.ts.map +0 -1
- package/dist/filters/types.d.ts.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/internal.d.ts +0 -36
- package/dist/internal.d.ts.map +0 -1
- package/dist/package.json.cjs +0 -6
- package/dist/package.json.cjs.map +0 -1
- package/dist/package.json.js +0 -4
- package/dist/package.json.js.map +0 -1
- package/dist/pframe.d.ts.map +0 -1
- package/dist/pframe_utils/axes.d.ts.map +0 -1
- package/dist/pframe_utils/columns.d.ts.map +0 -1
- package/dist/pframe_utils/index.d.ts.map +0 -1
- package/dist/pframe_utils/querySpec.d.ts +0 -2
- package/dist/pframe_utils/querySpec.d.ts.map +0 -1
- package/dist/platforma.d.ts.map +0 -1
- package/dist/plugin_handle.d.ts.map +0 -1
- package/dist/plugin_model.d.ts.map +0 -1
- package/dist/raw_globals.d.ts.map +0 -1
- package/dist/ref_util.d.ts.map +0 -1
- package/dist/render/accessor.d.ts.map +0 -1
- package/dist/render/api.d.ts.map +0 -1
- package/dist/render/future.d.ts.map +0 -1
- package/dist/render/index.d.ts.map +0 -1
- package/dist/render/internal.d.ts.map +0 -1
- package/dist/render/traversal_ops.d.ts.map +0 -1
- package/dist/render/util/axis_filtering.d.ts.map +0 -1
- package/dist/render/util/column_collection.d.ts.map +0 -1
- package/dist/render/util/index.d.ts.map +0 -1
- package/dist/render/util/label.d.ts.map +0 -1
- package/dist/render/util/pcolumn_data.d.ts.map +0 -1
- package/dist/render/util/pframe_upgraders.d.ts +0 -3
- package/dist/render/util/pframe_upgraders.d.ts.map +0 -1
- package/dist/render/util/split_selectors.d.ts.map +0 -1
- package/dist/version.d.ts.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* BlockStorage Callback Implementations - wired to facade callbacks in BlockModelV3.
|
|
2
|
+
* BlockStorage Callback Implementations - wired to facade callbacks in BlockModelV3.done().
|
|
3
3
|
*
|
|
4
4
|
* Provides pure functions for storage operations (migration, initialization,
|
|
5
5
|
* args derivation, updates, debug views). Each function takes its dependencies
|
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
import type { PluginHandle } from "./plugin_handle";
|
|
28
28
|
|
|
29
29
|
import { stringifyJson, type StringifiedJson } from "@milaboratories/pl-model-common";
|
|
30
|
-
import type { DataVersioned } from "./block_migrations";
|
|
30
|
+
import type { DataVersioned, TransferRecord } from "./block_migrations";
|
|
31
31
|
|
|
32
32
|
// =============================================================================
|
|
33
33
|
// Hook interfaces for dependency injection
|
|
@@ -35,13 +35,18 @@ import type { DataVersioned } from "./block_migrations";
|
|
|
35
35
|
|
|
36
36
|
/** Dependencies for storage migration */
|
|
37
37
|
export interface MigrationHooks {
|
|
38
|
-
migrateBlockData: (versioned: DataVersioned<unknown>) => DataVersioned<unknown
|
|
38
|
+
migrateBlockData: (versioned: DataVersioned<unknown>) => DataVersioned<unknown> & {
|
|
39
|
+
transfers: TransferRecord;
|
|
40
|
+
};
|
|
39
41
|
getPluginRegistry: () => PluginRegistry;
|
|
40
42
|
migratePluginData: (
|
|
41
43
|
handle: PluginHandle,
|
|
42
44
|
versioned: DataVersioned<unknown>,
|
|
43
45
|
) => DataVersioned<unknown> | undefined;
|
|
44
|
-
createPluginData: (
|
|
46
|
+
createPluginData: (
|
|
47
|
+
handle: PluginHandle,
|
|
48
|
+
transfer?: DataVersioned<unknown>,
|
|
49
|
+
) => DataVersioned<unknown>;
|
|
45
50
|
}
|
|
46
51
|
|
|
47
52
|
/** Dependencies for initial storage creation */
|
package/src/env_value.ts
CHANGED
package/src/filters/distill.ts
CHANGED
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
} from "@milaboratories/pl-model-common";
|
|
7
7
|
import { traverseFilterSpec } from "./traverse";
|
|
8
8
|
import { InferFilterSpecLeaf } from "@milaboratories/pl-model-common";
|
|
9
|
+
import { isEmpty } from "es-toolkit/compat";
|
|
9
10
|
|
|
10
11
|
/** All possible field names that can appear in any FilterSpecLeaf variant. */
|
|
11
12
|
type FilterSpecLeafKey = DistributiveKeys<FilterSpecLeaf<string>>;
|
|
@@ -27,19 +28,29 @@ const KNOWN_LEAF_KEYS_TUPLE: UnionToTuples<FilterSpecLeafKey> = [
|
|
|
27
28
|
const KNOWN_LEAF_KEYS: Set<FilterSpecLeafKey> = new Set(KNOWN_LEAF_KEYS_TUPLE);
|
|
28
29
|
|
|
29
30
|
/** Returns true if the leaf is filled — type is defined and no required fields are undefined. */
|
|
30
|
-
function isFilledLeaf(node:
|
|
31
|
+
function isFilledLeaf<T>(node: FilterSpecLeaf<T>): boolean {
|
|
31
32
|
if (node.type == null) return false;
|
|
32
|
-
return !Object.values(node).some((
|
|
33
|
+
return !Object.values(node).some((value) => {
|
|
34
|
+
switch (typeof value) {
|
|
35
|
+
case "number":
|
|
36
|
+
case "boolean":
|
|
37
|
+
return false;
|
|
38
|
+
case "string":
|
|
39
|
+
return value.trim() === "";
|
|
40
|
+
default: // undefined, null, empty objects/arrays
|
|
41
|
+
return isEmpty(value);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
33
44
|
}
|
|
34
45
|
|
|
35
|
-
function distillLeaf(node:
|
|
46
|
+
function distillLeaf<T>(node: FilterSpecLeaf<T>): FilterSpecLeaf<T> {
|
|
36
47
|
const result: Record<string, unknown> = {};
|
|
37
48
|
for (const [key, value] of Object.entries(node)) {
|
|
38
49
|
if (KNOWN_LEAF_KEYS.has(key as FilterSpecLeafKey)) {
|
|
39
50
|
result[key] = value;
|
|
40
51
|
}
|
|
41
52
|
}
|
|
42
|
-
return result as FilterSpecLeaf<
|
|
53
|
+
return result as FilterSpecLeaf<T>;
|
|
43
54
|
}
|
|
44
55
|
|
|
45
56
|
/**
|
|
@@ -55,8 +66,8 @@ export function distillFilterSpec<
|
|
|
55
66
|
if (filter == null) return null;
|
|
56
67
|
return traverseFilterSpec<FS, null | R>(filter, {
|
|
57
68
|
leaf: (leaf) => {
|
|
58
|
-
|
|
59
|
-
return
|
|
69
|
+
const distilled = distillLeaf(leaf);
|
|
70
|
+
return isFilledLeaf(distilled) ? (distilled as R) : null;
|
|
60
71
|
},
|
|
61
72
|
and: (results) => {
|
|
62
73
|
const filtered = results.filter((f): f is NonNullable<typeof f> => f !== null);
|
package/src/index.ts
CHANGED
|
@@ -25,18 +25,19 @@ export {
|
|
|
25
25
|
export * from "./block_storage_facade";
|
|
26
26
|
export * from "./block_model_legacy";
|
|
27
27
|
export { BlockModelV3 } from "./block_model";
|
|
28
|
-
export type {
|
|
28
|
+
export type { PluginRecord, ParamsInput } from "./block_model";
|
|
29
|
+
export { DataModel, DataModelBuilder } from "./block_migrations";
|
|
29
30
|
export {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
31
|
+
type PluginData,
|
|
32
|
+
type PluginParams,
|
|
33
|
+
type PluginOutputs,
|
|
34
|
+
type PluginConfig,
|
|
35
|
+
PluginDataModel,
|
|
36
|
+
PluginDataModelBuilder,
|
|
37
|
+
PluginInstance,
|
|
38
|
+
PluginModel,
|
|
39
|
+
type PluginFactory,
|
|
40
|
+
} from "./plugin_model";
|
|
40
41
|
export * from "./bconfig";
|
|
41
42
|
export * from "./components";
|
|
42
43
|
export * from "./config";
|
package/src/internal.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { OutputWithStatus } from "@milaboratories/pl-model-common";
|
|
2
|
-
import {} from "./global";
|
|
3
2
|
import type { Platforma, PlatformaApiVersion } from "./platforma";
|
|
4
3
|
import type { FutureHandle, GlobalCfgRenderCtx } from "./render/internal";
|
|
5
4
|
import type { ConfigRenderLambda, ConfigRenderLambdaFlags } from "./bconfig";
|
package/src/platforma.ts
CHANGED
|
@@ -9,7 +9,7 @@ import type {
|
|
|
9
9
|
} from "@milaboratories/pl-model-common";
|
|
10
10
|
import type { SdkInfo } from "./version";
|
|
11
11
|
import type { BlockStatePatch } from "./block_state_patch";
|
|
12
|
-
import type {
|
|
12
|
+
import type { PluginRecord } from "./block_model";
|
|
13
13
|
import type { PluginHandle, PluginFactoryLike } from "./plugin_handle";
|
|
14
14
|
|
|
15
15
|
/** Defines all methods to interact with the platform environment from within a block UI. @deprecated */
|
|
@@ -134,7 +134,7 @@ export type InferPluginNames<Pl> =
|
|
|
134
134
|
export type InferPluginData<Pl, PluginId extends string> =
|
|
135
135
|
Pl extends PlatformaV3<unknown, unknown, BlockOutputsBase, `/${string}`, infer P>
|
|
136
136
|
? PluginId extends keyof P
|
|
137
|
-
? P[PluginId] extends
|
|
137
|
+
? P[PluginId] extends PluginRecord<infer D, any, any>
|
|
138
138
|
? D
|
|
139
139
|
: never
|
|
140
140
|
: never
|
|
@@ -143,10 +143,10 @@ export type InferPluginData<Pl, PluginId extends string> =
|
|
|
143
143
|
/**
|
|
144
144
|
* Map each plugin instance to a type-safe opaque handle branded with normalized phantom.
|
|
145
145
|
* Uses the same brand structure as InferPluginHandle — only data/params/outputs, no config —
|
|
146
|
-
* because
|
|
146
|
+
* because PluginRecord doesn't carry Config (lost after factory.create()).
|
|
147
147
|
*/
|
|
148
148
|
export type InferPluginHandles<T extends Record<string, unknown>> = {
|
|
149
|
-
readonly [K in keyof T]: T[K] extends
|
|
149
|
+
readonly [K in keyof T]: T[K] extends PluginRecord<infer Data, infer Params, infer Outputs>
|
|
150
150
|
? PluginHandle<PluginFactoryLike<Data, Params, Outputs>>
|
|
151
151
|
: never;
|
|
152
152
|
};
|
package/src/plugin_handle.ts
CHANGED
|
@@ -13,7 +13,7 @@ import type { Branded } from "@milaboratories/helpers";
|
|
|
13
13
|
/**
|
|
14
14
|
* Phantom-only base type for constraining PluginHandle's type parameter.
|
|
15
15
|
*
|
|
16
|
-
* PluginFactory has create() →
|
|
16
|
+
* PluginFactory has create() → PluginInstance with function properties, making it invariant
|
|
17
17
|
* under strictFunctionTypes. PluginFactoryLike exposes only the covariant `__types` phantom,
|
|
18
18
|
* avoiding the contravariance chain. Handles only need `__types` for type extraction.
|
|
19
19
|
*
|
package/src/plugin_model.test.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { describe, expect, it } from "vitest";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
PluginModel,
|
|
4
|
+
PluginDataModelBuilder,
|
|
5
|
+
PluginInstance,
|
|
6
|
+
CREATE_PLUGIN_MODEL,
|
|
7
|
+
} from "./plugin_model";
|
|
3
8
|
import type { PluginRenderCtx } from "./plugin_model";
|
|
4
9
|
import { DataModelBuilder } from "./block_migrations";
|
|
5
|
-
import { type PluginName } from "./block_storage";
|
|
10
|
+
import { type PluginName, DATA_MODEL_LEGACY_VERSION } from "./block_storage";
|
|
6
11
|
import type { ResultPool } from "./render";
|
|
7
12
|
|
|
8
|
-
// =============================================================================
|
|
9
|
-
// Test Fixtures
|
|
10
|
-
// =============================================================================
|
|
11
|
-
|
|
12
13
|
type Data = { count: number; label: string };
|
|
13
14
|
|
|
14
15
|
const dataModelChain = new DataModelBuilder().from<Data>("v1");
|
|
@@ -16,10 +17,6 @@ const dataModelChain = new DataModelBuilder().from<Data>("v1");
|
|
|
16
17
|
// Mock ResultPool for testing
|
|
17
18
|
const mockResultPool = {} as ResultPool;
|
|
18
19
|
|
|
19
|
-
// =============================================================================
|
|
20
|
-
// Tests
|
|
21
|
-
// =============================================================================
|
|
22
|
-
|
|
23
20
|
describe("PluginModel", () => {
|
|
24
21
|
it("creates PluginModel with required fields", () => {
|
|
25
22
|
const factory = PluginModel.define<Data>({
|
|
@@ -27,7 +24,8 @@ describe("PluginModel", () => {
|
|
|
27
24
|
data: () => dataModelChain.init(() => ({ count: 0, label: "" })),
|
|
28
25
|
}).build();
|
|
29
26
|
|
|
30
|
-
const
|
|
27
|
+
const instance = factory.create({ pluginId: "test" });
|
|
28
|
+
const plugin = instance[CREATE_PLUGIN_MODEL]();
|
|
31
29
|
expect(plugin.name).toBe("testPlugin");
|
|
32
30
|
expect(plugin.outputs).toEqual({});
|
|
33
31
|
});
|
|
@@ -40,7 +38,8 @@ describe("PluginModel", () => {
|
|
|
40
38
|
data: (cfg) => dataModelChain.init(() => ({ count: cfg.initialCount, label: "initialized" })),
|
|
41
39
|
}).build();
|
|
42
40
|
|
|
43
|
-
const
|
|
41
|
+
const instance = factory.create({ pluginId: "inst1", config: { initialCount: 100 } });
|
|
42
|
+
const plugin = instance[CREATE_PLUGIN_MODEL]();
|
|
44
43
|
expect(plugin.name).toBe("factoryPlugin");
|
|
45
44
|
expect(plugin.dataModel.initialData()).toEqual({ count: 100, label: "initialized" });
|
|
46
45
|
});
|
|
@@ -53,7 +52,8 @@ describe("PluginModel", () => {
|
|
|
53
52
|
.output("doubled", (ctx) => ctx.data.count * ctx.params.multiplier)
|
|
54
53
|
.build();
|
|
55
54
|
|
|
56
|
-
const
|
|
55
|
+
const instance = factory.create({ pluginId: "inst1" });
|
|
56
|
+
const plugin = instance[CREATE_PLUGIN_MODEL]();
|
|
57
57
|
expect(Object.keys(plugin.outputs)).toEqual(["doubled"]);
|
|
58
58
|
});
|
|
59
59
|
|
|
@@ -67,7 +67,8 @@ describe("PluginModel", () => {
|
|
|
67
67
|
.output("isReady", (ctx) => ctx.data.count > 0)
|
|
68
68
|
.build();
|
|
69
69
|
|
|
70
|
-
const
|
|
70
|
+
const instance = factory.create({ pluginId: "inst1" });
|
|
71
|
+
const plugin = instance[CREATE_PLUGIN_MODEL]();
|
|
71
72
|
expect(Object.keys(plugin.outputs).sort()).toEqual(["formattedCount", "isReady", "upperLabel"]);
|
|
72
73
|
});
|
|
73
74
|
|
|
@@ -79,7 +80,8 @@ describe("PluginModel", () => {
|
|
|
79
80
|
.output("computed", (ctx) => ctx.data.count * ctx.params.factor)
|
|
80
81
|
.build();
|
|
81
82
|
|
|
82
|
-
const
|
|
83
|
+
const instance = factory.create({ pluginId: "inst1" });
|
|
84
|
+
const plugin = instance[CREATE_PLUGIN_MODEL]();
|
|
83
85
|
|
|
84
86
|
const ctx: PluginRenderCtx<Data, { factor: number }> = {
|
|
85
87
|
data: { count: 5, label: "" },
|
|
@@ -99,7 +101,8 @@ describe("PluginModel", () => {
|
|
|
99
101
|
.output("hasResultPool", (ctx) => ctx.resultPool !== undefined)
|
|
100
102
|
.build();
|
|
101
103
|
|
|
102
|
-
const
|
|
104
|
+
const instance = factory.create({ pluginId: "inst1" });
|
|
105
|
+
const plugin = instance[CREATE_PLUGIN_MODEL]();
|
|
103
106
|
|
|
104
107
|
const ctx: PluginRenderCtx<Data> = {
|
|
105
108
|
data: { count: 0, label: "" },
|
|
@@ -119,7 +122,8 @@ describe("PluginModel", () => {
|
|
|
119
122
|
.output("hasSelection", (ctx) => ctx.data.count >= 0)
|
|
120
123
|
.build();
|
|
121
124
|
|
|
122
|
-
const
|
|
125
|
+
const instance = factory.create({ pluginId: "inst1", config: { option: true } });
|
|
126
|
+
const plugin = instance[CREATE_PLUGIN_MODEL]();
|
|
123
127
|
expect(plugin.name).toBe("completePlugin");
|
|
124
128
|
expect(Object.keys(plugin.outputs).sort()).toEqual(["currentItem", "hasSelection"]);
|
|
125
129
|
});
|
|
@@ -130,7 +134,8 @@ describe("PluginModel", () => {
|
|
|
130
134
|
data: () => dataModelChain.init(() => ({ count: 0, label: "" })),
|
|
131
135
|
}).build();
|
|
132
136
|
|
|
133
|
-
const
|
|
137
|
+
const instance = factory.create({ pluginId: "inst1" });
|
|
138
|
+
const plugin = instance[CREATE_PLUGIN_MODEL]();
|
|
134
139
|
expect(plugin.outputs).toEqual({});
|
|
135
140
|
});
|
|
136
141
|
|
|
@@ -143,7 +148,11 @@ describe("PluginModel", () => {
|
|
|
143
148
|
dataModelChain.init(() => ({ count: cfg.defaultCount, label: cfg.defaultLabel })),
|
|
144
149
|
}).build();
|
|
145
150
|
|
|
146
|
-
const
|
|
151
|
+
const instance = factory.create({
|
|
152
|
+
pluginId: "inst1",
|
|
153
|
+
config: { defaultCount: 10, defaultLabel: "default" },
|
|
154
|
+
});
|
|
155
|
+
const plugin = instance[CREATE_PLUGIN_MODEL]();
|
|
147
156
|
expect(plugin.dataModel.initialData()).toEqual({ count: 10, label: "default" });
|
|
148
157
|
});
|
|
149
158
|
|
|
@@ -159,10 +168,197 @@ describe("PluginModel", () => {
|
|
|
159
168
|
const factory1 = pluginWithOutput1.build();
|
|
160
169
|
const factory2 = pluginWithOutput2.build();
|
|
161
170
|
|
|
162
|
-
const plugin1 = factory1.create(
|
|
163
|
-
const plugin2 = factory2.create(
|
|
171
|
+
const plugin1 = factory1.create({ pluginId: "p1" })[CREATE_PLUGIN_MODEL]();
|
|
172
|
+
const plugin2 = factory2.create({ pluginId: "p2" })[CREATE_PLUGIN_MODEL]();
|
|
164
173
|
|
|
165
174
|
expect(Object.keys(plugin1.outputs)).toEqual(["first"]);
|
|
166
175
|
expect(Object.keys(plugin2.outputs)).toEqual(["second"]);
|
|
167
176
|
});
|
|
168
177
|
});
|
|
178
|
+
|
|
179
|
+
describe("PluginDataModel", () => {
|
|
180
|
+
it("creates default data via new PluginDataModelBuilder().from().init()", () => {
|
|
181
|
+
type PData = { items: string[] };
|
|
182
|
+
const pdm = new PluginDataModelBuilder().from<PData>("v1").init(() => ({ items: [] }));
|
|
183
|
+
|
|
184
|
+
const defaultData = pdm.getDefaultData();
|
|
185
|
+
expect(defaultData.version).toBe("v1");
|
|
186
|
+
expect(defaultData.data).toStrictEqual({ items: [] });
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
it("getDefaultData passes config to init function", () => {
|
|
190
|
+
type PData = { items: string[]; count: number };
|
|
191
|
+
type PConfig = { defaultCount: number };
|
|
192
|
+
|
|
193
|
+
const pdm = new PluginDataModelBuilder().from<PData>("v1").init<PConfig>((config?) => ({
|
|
194
|
+
items: [],
|
|
195
|
+
count: config?.defaultCount ?? 0,
|
|
196
|
+
}));
|
|
197
|
+
|
|
198
|
+
// Without config
|
|
199
|
+
const noConfig = pdm.getDefaultData();
|
|
200
|
+
expect(noConfig.data).toStrictEqual({ items: [], count: 0 });
|
|
201
|
+
|
|
202
|
+
// With config
|
|
203
|
+
const withConfig = pdm.getDefaultData({ defaultCount: 42 });
|
|
204
|
+
expect(withConfig.data).toStrictEqual({ items: [], count: 42 });
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
it("supports .recover() in the chain", () => {
|
|
208
|
+
type V1 = { value: number };
|
|
209
|
+
type V2 = { value: number; label: string };
|
|
210
|
+
|
|
211
|
+
const pdm = new PluginDataModelBuilder()
|
|
212
|
+
.from<V1>("v1")
|
|
213
|
+
.recover((version, data) => {
|
|
214
|
+
if (version === "legacy") return { value: (data as any).val || 0 };
|
|
215
|
+
throw new Error(`Unknown version: ${version}`);
|
|
216
|
+
})
|
|
217
|
+
.migrate<V2>("v2", (v1) => ({ ...v1, label: "recovered" }))
|
|
218
|
+
.init(() => ({ value: 0, label: "" }));
|
|
219
|
+
|
|
220
|
+
// Recovery path — test via inner dataModel
|
|
221
|
+
const result = pdm.dataModel.migrate({ version: "legacy", data: { val: 99 } });
|
|
222
|
+
expect(result.version).toBe("v2");
|
|
223
|
+
expect(result.data).toStrictEqual({ value: 99, label: "recovered" });
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
it("getDefaultData uses config from PluginDataModel path", () => {
|
|
227
|
+
type PData = { value: number };
|
|
228
|
+
type PConfig = { defaultValue: number };
|
|
229
|
+
|
|
230
|
+
const pdm = new PluginDataModelBuilder()
|
|
231
|
+
.from<PData>("v1")
|
|
232
|
+
.init<PConfig>((config?) => ({ value: config?.defaultValue ?? 0 }));
|
|
233
|
+
|
|
234
|
+
const factory = PluginModel.define({
|
|
235
|
+
name: "pdmTest" as PluginName,
|
|
236
|
+
data: pdm,
|
|
237
|
+
}).build();
|
|
238
|
+
|
|
239
|
+
const plugin = factory
|
|
240
|
+
.create({ pluginId: "inst1", config: { defaultValue: 42 } })
|
|
241
|
+
[CREATE_PLUGIN_MODEL]();
|
|
242
|
+
expect(plugin.getDefaultData().data).toStrictEqual({ value: 42 });
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
it("getDefaultData works for function-based data", () => {
|
|
246
|
+
const factory = PluginModel.define<Data>({
|
|
247
|
+
name: "fnTest" as PluginName,
|
|
248
|
+
data: () => dataModelChain.init(() => ({ count: 0, label: "" })),
|
|
249
|
+
}).build();
|
|
250
|
+
|
|
251
|
+
const plugin = factory.create({ pluginId: "inst1" })[CREATE_PLUGIN_MODEL]();
|
|
252
|
+
expect(plugin.getDefaultData().data).toStrictEqual({ count: 0, label: "" });
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
it("upgradeLegacy allows migrating from DATA_MODEL_LEGACY_VERSION", () => {
|
|
256
|
+
type V1 = { value: number };
|
|
257
|
+
type V2 = { value: number; extra: string };
|
|
258
|
+
|
|
259
|
+
const pdm = new PluginDataModelBuilder()
|
|
260
|
+
.from<V1>("v1")
|
|
261
|
+
.upgradeLegacy((data) => ({ value: (data as any).oldValue ?? 0 }))
|
|
262
|
+
.migrate<V2>("v2", (v1) => ({ ...v1, extra: "added" }))
|
|
263
|
+
.init(() => ({ value: 0, extra: "" }));
|
|
264
|
+
|
|
265
|
+
// Legacy path: data arrives with DATA_MODEL_LEGACY_VERSION
|
|
266
|
+
const result = pdm.dataModel.migrate({
|
|
267
|
+
version: DATA_MODEL_LEGACY_VERSION,
|
|
268
|
+
data: { oldValue: 42 },
|
|
269
|
+
});
|
|
270
|
+
expect(result.version).toBe("v2");
|
|
271
|
+
expect(result.data).toStrictEqual({ value: 42, extra: "added" });
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
it("upgradeLegacy is not needed for normal version migration", () => {
|
|
275
|
+
type V1 = { value: number };
|
|
276
|
+
type V2 = { value: number; extra: string };
|
|
277
|
+
|
|
278
|
+
const pdm = new PluginDataModelBuilder()
|
|
279
|
+
.from<V1>("v1")
|
|
280
|
+
.upgradeLegacy((data) => ({ value: (data as any).oldValue ?? 0 }))
|
|
281
|
+
.migrate<V2>("v2", (v1) => ({ ...v1, extra: "added" }))
|
|
282
|
+
.init(() => ({ value: 0, extra: "" }));
|
|
283
|
+
|
|
284
|
+
// Normal migration: v1 → v2
|
|
285
|
+
const result = pdm.dataModel.migrate({
|
|
286
|
+
version: "v1",
|
|
287
|
+
data: { value: 10 },
|
|
288
|
+
});
|
|
289
|
+
expect(result.version).toBe("v2");
|
|
290
|
+
expect(result.data).toStrictEqual({ value: 10, extra: "added" });
|
|
291
|
+
});
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
describe("PluginInstance", () => {
|
|
295
|
+
it("factory.create() returns a PluginInstance with correct id", () => {
|
|
296
|
+
const factory = PluginModel.define<Data>({
|
|
297
|
+
name: "instanceTest" as PluginName,
|
|
298
|
+
data: () => dataModelChain.init(() => ({ count: 0, label: "" })),
|
|
299
|
+
}).build();
|
|
300
|
+
|
|
301
|
+
const instance = factory.create({ pluginId: "myTable" });
|
|
302
|
+
expect(instance).toBeInstanceOf(PluginInstance);
|
|
303
|
+
expect(instance.id).toBe("myTable");
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
it("PluginInstance[CREATE_PLUGIN_MODEL]() delegates to factory", () => {
|
|
307
|
+
type Config = { initial: number };
|
|
308
|
+
const factory = PluginModel.define<Data, undefined, Config>({
|
|
309
|
+
name: "delegateTest" as PluginName,
|
|
310
|
+
data: (cfg) => dataModelChain.init(() => ({ count: cfg.initial, label: "" })),
|
|
311
|
+
}).build();
|
|
312
|
+
|
|
313
|
+
const instance = factory.create({ pluginId: "inst1", config: { initial: 42 } });
|
|
314
|
+
const plugin = instance[CREATE_PLUGIN_MODEL]();
|
|
315
|
+
expect(plugin.name).toBe("delegateTest");
|
|
316
|
+
expect(plugin.dataModel.initialData()).toStrictEqual({ count: 42, label: "" });
|
|
317
|
+
});
|
|
318
|
+
|
|
319
|
+
it("PluginInstance without transferAt has empty transferVersion", () => {
|
|
320
|
+
const factory = PluginModel.define<Data>({
|
|
321
|
+
name: "noTransfer" as PluginName,
|
|
322
|
+
data: () => dataModelChain.init(() => ({ count: 0, label: "" })),
|
|
323
|
+
}).build();
|
|
324
|
+
|
|
325
|
+
const instance = factory.create({ pluginId: "inst1" });
|
|
326
|
+
expect(instance.transferVersion).toBe("");
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
it("PluginInstance with transferAt has correct transferVersion", () => {
|
|
330
|
+
type V1 = { value: number };
|
|
331
|
+
type V2 = { value: number; label: string };
|
|
332
|
+
const pdm = new PluginDataModelBuilder()
|
|
333
|
+
.from<V1>("v1")
|
|
334
|
+
.migrate<V2>("v2", (v1) => ({ ...v1, label: "" }))
|
|
335
|
+
.init(() => ({ value: 0, label: "" }));
|
|
336
|
+
|
|
337
|
+
const factory = PluginModel.define({
|
|
338
|
+
name: "withTransfer" as PluginName,
|
|
339
|
+
data: pdm,
|
|
340
|
+
}).build();
|
|
341
|
+
|
|
342
|
+
const instance = factory.create({ pluginId: "inst1", transferAt: "v1" });
|
|
343
|
+
expect(instance.transferVersion).toBe("v1");
|
|
344
|
+
});
|
|
345
|
+
|
|
346
|
+
it("config is captured in getDefaultData closure", () => {
|
|
347
|
+
type PData = { items: string[]; count: number };
|
|
348
|
+
type PConfig = { defaultCount: number };
|
|
349
|
+
|
|
350
|
+
const pdm = new PluginDataModelBuilder().from<PData>("v1").init<PConfig>((config?) => ({
|
|
351
|
+
items: [],
|
|
352
|
+
count: config?.defaultCount ?? 0,
|
|
353
|
+
}));
|
|
354
|
+
|
|
355
|
+
const factory = PluginModel.define({
|
|
356
|
+
name: "configStore" as PluginName,
|
|
357
|
+
data: pdm,
|
|
358
|
+
}).build();
|
|
359
|
+
|
|
360
|
+
const instance = factory.create({ pluginId: "inst1", config: { defaultCount: 99 } });
|
|
361
|
+
const plugin = instance[CREATE_PLUGIN_MODEL]();
|
|
362
|
+
expect(plugin.getDefaultData().data).toStrictEqual({ items: [], count: 99 });
|
|
363
|
+
});
|
|
364
|
+
});
|