@milaboratories/milaboratories.ui-examples.model 1.4.3 → 1.4.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.
@@ -1,16 +1,16 @@
1
1
   WARN  Issue while reading "/home/runner/_work/platforma/platforma/.npmrc". Failed to replace env in config: ${NPMJS_TOKEN}
2
2
 
3
- > @milaboratories/milaboratories.ui-examples.model@1.4.3 build /home/runner/_work/platforma/platforma/etc/blocks/ui-examples/model
3
+ > @milaboratories/milaboratories.ui-examples.model@1.4.5 build /home/runner/_work/platforma/platforma/etc/blocks/ui-examples/model
4
4
  > ts-builder build --target block-model && block-tools build-model
5
5
 
6
6
  Building block-model project...
7
7
  ↳ rollup -c /configs/rollup.block-model.config.js
8
8
  
9
9
  ./src/index.ts → dist, dist...
10
- created dist, dist in 2.3s
10
+ created dist, dist in 2.7s
11
11
  
12
12
  ./src/index.ts → dist...
13
13
  (!) Circular dependency
14
14
  ../../../../sdk/model/dist/components/PFrameForGraphs.js -> ../../../../sdk/model/dist/pframe_utils/columns.js -> ../../../../sdk/model/dist/components/PFrameForGraphs.js
15
- created dist in 5s
15
+ created dist in 3.6s
16
16
  Build completed successfully
@@ -1,5 +1,5 @@
1
1
   WARN  Issue while reading "/home/runner/_work/platforma/platforma/.npmrc". Failed to replace env in config: ${NPMJS_TOKEN}
2
2
 
3
- > @milaboratories/milaboratories.ui-examples.model@1.4.3 lint /home/runner/_work/platforma/platforma/etc/blocks/ui-examples/model
3
+ > @milaboratories/milaboratories.ui-examples.model@1.4.5 lint /home/runner/_work/platforma/platforma/etc/blocks/ui-examples/model
4
4
  > eslint .
5
5
 
@@ -1,6 +1,6 @@
1
1
   WARN  Issue while reading "/home/runner/_work/platforma/platforma/.npmrc". Failed to replace env in config: ${NPMJS_TOKEN}
2
2
 
3
- > @milaboratories/milaboratories.ui-examples.model@1.4.3 type-check /home/runner/_work/platforma/platforma/etc/blocks/ui-examples/model
3
+ > @milaboratories/milaboratories.ui-examples.model@1.4.5 type-check /home/runner/_work/platforma/platforma/etc/blocks/ui-examples/model
4
4
  > ts-builder types --target block-model
5
5
 
6
6
  ↳ tsc --noEmit --project ./tsconfig.json --customConditions ,
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @milaboratories/milaboratories.ui-examples.model
2
2
 
3
+ ## 1.4.5
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [57799dd]
8
+ - @platforma-sdk/model@1.53.2
9
+
10
+ ## 1.4.4
11
+
12
+ ### Patch Changes
13
+
14
+ - Updated dependencies [a748b92]
15
+ - @platforma-sdk/model@1.53.1
16
+
3
17
  ## 1.4.3
4
18
 
5
19
  ### Patch Changes
package/dist/bundle.js CHANGED
@@ -27,6 +27,11 @@
27
27
  * Increment this when the storage structure itself changes (not block state migrations).
28
28
  */
29
29
  const BLOCK_STORAGE_SCHEMA_VERSION = 'v1';
30
+ /**
31
+ * Default data version for new blocks without migrations.
32
+ * Unique identifier ensures blocks are created via DataModel API.
33
+ */
34
+ const DATA_MODEL_DEFAULT_VERSION = '__pl_v1_d4e8f2a1__';
30
35
  /**
31
36
  * Type guard to check if a value is a valid BlockStorage object.
32
37
  * Checks for the discriminator key and valid schema version.
@@ -46,16 +51,38 @@
46
51
  * Creates a BlockStorage with the given initial data
47
52
  *
48
53
  * @param initialData - The initial data value (defaults to empty object)
49
- * @param version - The initial data version (defaults to 1)
54
+ * @param version - The initial data version key (defaults to DATA_MODEL_DEFAULT_VERSION)
50
55
  * @returns A new BlockStorage instance with discriminator key
51
56
  */
52
- function createBlockStorage(initialData = {}, version = 1) {
57
+ function createBlockStorage(initialData = {}, version = DATA_MODEL_DEFAULT_VERSION) {
53
58
  return {
54
59
  [BLOCK_STORAGE_KEY]: BLOCK_STORAGE_SCHEMA_VERSION,
55
60
  __dataVersion: version,
56
61
  __data: initialData,
57
62
  };
58
63
  }
64
+ /**
65
+ * Normalizes raw storage data to BlockStorage format.
66
+ * If the input is already a BlockStorage, returns it as-is.
67
+ * If the input is legacy format (raw state), wraps it in BlockStorage structure.
68
+ *
69
+ * @param raw - Raw storage data (may be legacy format or BlockStorage)
70
+ * @returns Normalized BlockStorage
71
+ */
72
+ function normalizeBlockStorage(raw) {
73
+ if (isBlockStorage(raw)) {
74
+ const storage = raw;
75
+ return {
76
+ ...storage,
77
+ // Fix for early released version where __dataVersion was a number
78
+ __dataVersion: typeof storage.__dataVersion === 'number'
79
+ ? DATA_MODEL_DEFAULT_VERSION
80
+ : storage.__dataVersion,
81
+ };
82
+ }
83
+ // Legacy format: raw is the state directly
84
+ return createBlockStorage(raw);
85
+ }
59
86
  // =============================================================================
60
87
  // Data Access & Update Functions
61
88
  // =============================================================================
@@ -7502,7 +7529,7 @@
7502
7529
  }
7503
7530
  }
7504
7531
 
7505
- var version = "1.53.0";
7532
+ var version = "1.53.2";
7506
7533
 
7507
7534
  const PlatformaSDKVersion = version;
7508
7535
 
@@ -7768,7 +7795,7 @@
7768
7795
  *
7769
7796
  * Callbacks registered by DataModel.registerCallbacks():
7770
7797
  * - `__pl_data_initial`: () => initial data
7771
- * - `__pl_data_upgrade`: (versioned) => UpgradeResult
7798
+ * - `__pl_data_upgrade`: (versioned) => DataMigrationResult
7772
7799
  * - `__pl_storage_initial`: () => initial BlockStorage as JSON string
7773
7800
  *
7774
7801
  * @module block_storage_vm
@@ -7804,7 +7831,8 @@
7804
7831
  }
7805
7832
  // Check for BlockStorage format (has discriminator)
7806
7833
  if (isBlockStorage(parsed)) {
7807
- return { storage: parsed, data: getStorageData(parsed) };
7834
+ const storage = normalizeBlockStorage(parsed);
7835
+ return { storage, data: getStorageData(storage) };
7808
7836
  }
7809
7837
  // Check for legacy V1/V2 format: { args, uiState }
7810
7838
  if (isLegacyModelV1ApiFormat(parsed)) {
@@ -7869,7 +7897,7 @@
7869
7897
  return getStorageDebugView(rawStorage);
7870
7898
  });
7871
7899
  /**
7872
- * Runs storage migration using the DataModel's upgrade callback.
7900
+ * Runs storage migration using the DataModel's migrate callback.
7873
7901
  * This is the main entry point for the middle layer to trigger migrations.
7874
7902
  *
7875
7903
  * Uses the '__pl_data_upgrade' callback registered by DataModel.registerCallbacks() which:
@@ -7896,26 +7924,26 @@
7896
7924
  __data: data,
7897
7925
  });
7898
7926
  };
7899
- // Get the upgrade callback (registered by DataModel.registerCallbacks())
7900
- const upgradeCallback = ctx.callbackRegistry['__pl_data_upgrade'];
7901
- if (typeof upgradeCallback !== 'function') {
7927
+ // Get the migrate callback (registered by DataModel.registerCallbacks())
7928
+ const migrateCallback = ctx.callbackRegistry['__pl_data_upgrade'];
7929
+ if (typeof migrateCallback !== 'function') {
7902
7930
  return { error: '__pl_data_upgrade callback not found (DataModel not registered)' };
7903
7931
  }
7904
- // Call the migrator's upgrade function
7932
+ // Call the migrator's migrate function
7905
7933
  let result;
7906
7934
  try {
7907
- result = upgradeCallback({ version: currentVersion, data: currentData });
7935
+ result = migrateCallback({ version: currentVersion, data: currentData });
7908
7936
  }
7909
7937
  catch (e) {
7910
7938
  const errorMsg = e instanceof Error ? e.message : String(e);
7911
- return { error: `upgrade() threw: ${errorMsg}` };
7939
+ return { error: `migrate() threw: ${errorMsg}` };
7912
7940
  }
7913
7941
  // Build info message
7914
7942
  const info = result.version === currentVersion
7915
- ? `No migration needed (v${currentVersion})`
7943
+ ? `No migration needed (${currentVersion})`
7916
7944
  : result.warning
7917
- ? `Reset to initial data (v${result.version})`
7918
- : `Migrated v${currentVersion}→v${result.version}`;
7945
+ ? `Reset to initial data (${result.version})`
7946
+ : `Migrated ${currentVersion}→${result.version}`;
7919
7947
  return {
7920
7948
  newStorageJson: createStorageJson(result.data, result.version),
7921
7949
  info,