@milaboratories/pl-model-common 1.22.0 → 1.24.0

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.
@@ -21,4 +21,13 @@ export type BlockState<Args = unknown, Outputs extends BlockOutputsBase = BlockO
21
21
  navigationState: NavigationState<Href>;
22
22
  readonly author: AuthorMarker | undefined;
23
23
  };
24
+ export type BlockStateV3<Outputs extends BlockOutputsBase = BlockOutputsBase, _Data = unknown, Href extends `/${string}` = `/${string}`> = {
25
+ /** Block storage persisted in the block state */
26
+ blockStorage: unknown;
27
+ /** Outputs rendered with block config */
28
+ outputs: Outputs;
29
+ /** Current navigation state */
30
+ navigationState: NavigationState<Href>;
31
+ readonly author: AuthorMarker | undefined;
32
+ };
24
33
  //# sourceMappingURL=block_state.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"block_state.d.ts","sourceRoot":"","sources":["../src/block_state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD;;;;;;;GAOG;AACH,MAAM,MAAM,UAAU,CACpB,IAAI,GAAG,OAAO,EACd,OAAO,SAAS,gBAAgB,GAAG,gBAAgB,EACnD,OAAO,GAAG,OAAO,EACjB,IAAI,SAAS,IAAI,MAAM,EAAE,GAAG,IAAI,MAAM,EAAE,IACtC;IACF,6CAA6C;IAC7C,IAAI,EAAE,IAAI,CAAC;IAEX;kBACc;IACd,EAAE,EAAE,OAAO,CAAC;IAEZ,yCAAyC;IACzC,OAAO,EAAE,OAAO,CAAC;IAEjB,+BAA+B;IAC/B,eAAe,EAAE,eAAe,CAAC,IAAI,CAAC,CAAC;IAEvC,QAAQ,CAAC,MAAM,EAAE,YAAY,GAAG,SAAS,CAAC;CAC3C,CAAC"}
1
+ {"version":3,"file":"block_state.d.ts","sourceRoot":"","sources":["../src/block_state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD;;;;;;;GAOG;AACH,MAAM,MAAM,UAAU,CACpB,IAAI,GAAG,OAAO,EACd,OAAO,SAAS,gBAAgB,GAAG,gBAAgB,EACnD,OAAO,GAAG,OAAO,EACjB,IAAI,SAAS,IAAI,MAAM,EAAE,GAAG,IAAI,MAAM,EAAE,IACtC;IACF,6CAA6C;IAC7C,IAAI,EAAE,IAAI,CAAC;IAEX;kBACc;IACd,EAAE,EAAE,OAAO,CAAC;IAEZ,yCAAyC;IACzC,OAAO,EAAE,OAAO,CAAC;IAEjB,+BAA+B;IAC/B,eAAe,EAAE,eAAe,CAAC,IAAI,CAAC,CAAC;IAEvC,QAAQ,CAAC,MAAM,EAAE,YAAY,GAAG,SAAS,CAAC;CAC3C,CAAC;AAEF,MAAM,MAAM,YAAY,CACtB,OAAO,SAAS,gBAAgB,GAAG,gBAAgB,EACnD,KAAK,GAAG,OAAO,EACf,IAAI,SAAS,IAAI,MAAM,EAAE,GAAG,IAAI,MAAM,EAAE,IACtC;IACF,iDAAiD;IACjD,YAAY,EAAE,OAAO,CAAC;IAEtB,yCAAyC;IACzC,OAAO,EAAE,OAAO,CAAC;IAEjB,+BAA+B;IAC/B,eAAe,EAAE,eAAe,CAAC,IAAI,CAAC,CAAC;IAEvC,QAAQ,CAAC,MAAM,EAAE,YAAY,GAAG,SAAS,CAAC;CAC3C,CAAC"}
@@ -3,7 +3,7 @@
3
3
  // TODO BroadActiveHandleDescriptor must be removed
4
4
  function extractCodeWithInfo(cfg) {
5
5
  if (cfg.code === undefined)
6
- throw new Error('No code bundle');
6
+ throw new Error('extractCodeWithInfo: No code bundle');
7
7
  return {
8
8
  code: cfg.code,
9
9
  sdkVersion: cfg.sdkVersion,
@@ -1 +1 @@
1
- {"version":3,"file":"block_config.cjs","sources":["../../src/bmodel/block_config.ts"],"sourcesContent":["// TODO BroadActiveHandleDescriptor must be removed\n\nimport type { BlockCodeFeatureFlags } from '../flags';\nimport type { BlockCodeWithInfo, Code } from './code';\nimport type { BlockRenderingMode } from './types';\n\n/**\n * BroadActiveHandleDescriptor = TypedConfigOrConfigLambda,\n * NarrowActiveHandleDescriptor = ConfigRenderLambda\n */\nexport type BlockConfigV3Generic<\n Args = unknown,\n UiState = unknown,\n BroadActiveHandleDescriptor = unknown,\n NarrowActiveHandleDescriptor extends BroadActiveHandleDescriptor = BroadActiveHandleDescriptor,\n Outputs extends Record<string, BroadActiveHandleDescriptor> = Record<string, BroadActiveHandleDescriptor>,\n> = {\n /** SDK version used by the block */\n readonly sdkVersion: string;\n\n /** Main rendering mode for the block */\n readonly renderingMode: BlockRenderingMode;\n\n /** Initial value for the args when block is added to the project */\n readonly initialArgs: Args;\n\n /** Initial value for the args when block is added to the project */\n readonly initialUiState: UiState;\n\n /**\n * Config to determine whether the block can be executed with current\n * arguments.\n *\n * Optional to support earlier SDK version configs.\n */\n readonly inputsValid: BroadActiveHandleDescriptor;\n\n /** Configuration to derive list of section for the left overview panel */\n readonly sections: BroadActiveHandleDescriptor;\n\n /** Lambda to derive block title */\n readonly title?: NarrowActiveHandleDescriptor;\n\n /** Lambda to derive block subtitle, shown below the title */\n readonly subtitle?: NarrowActiveHandleDescriptor;\n\n /** Lambda returning array of tags for search functionality */\n readonly tags?: BroadActiveHandleDescriptor;\n\n /**\n * Lambda returning list of upstream blocks this block enriches with its exports,\n * influences dependency graph construction\n */\n readonly enrichmentTargets?: NarrowActiveHandleDescriptor;\n\n /** Configuration for the output cells */\n readonly outputs: Outputs;\n\n /** Config code bundle */\n readonly code?: Code;\n\n /** Feature flags for the block Model and UI code. */\n readonly featureFlags?: BlockCodeFeatureFlags;\n};\n\nexport type BlockConfigGeneric = BlockConfigV3Generic;\n\nexport function extractCodeWithInfo(cfg: BlockConfigV3Generic): BlockCodeWithInfo {\n if (cfg.code === undefined) throw new Error('No code bundle');\n return {\n code: cfg.code,\n sdkVersion: cfg.sdkVersion,\n featureFlags: cfg.featureFlags,\n };\n}\n"],"names":[],"mappings":";;AAAA;AAmEM,SAAU,mBAAmB,CAAC,GAAyB,EAAA;AAC3D,IAAA,IAAI,GAAG,CAAC,IAAI,KAAK,SAAS;AAAE,QAAA,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC;IAC7D,OAAO;QACL,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,UAAU,EAAE,GAAG,CAAC,UAAU;QAC1B,YAAY,EAAE,GAAG,CAAC,YAAY;KAC/B;AACH;;;;"}
1
+ {"version":3,"file":"block_config.cjs","sources":["../../src/bmodel/block_config.ts"],"sourcesContent":["// TODO BroadActiveHandleDescriptor must be removed\n\nimport type { BlockCodeFeatureFlags } from '../flags';\nimport type { BlockCodeWithInfo, Code } from './code';\nimport type { BlockRenderingMode } from './types';\n\n/**\n * Descriptor for a state migration function.\n * Unlike ConfigRenderLambda, migrations are not rendered reactively -\n * they are one-time synchronous transformations called during block pack updates.\n */\nexport type MigrationDescriptor = {\n /** Index of this migration in the migrations callback array */\n readonly index: number;\n};\n\n/**\n * BroadActiveHandleDescriptor = TypedConfigOrConfigLambda,\n * NarrowActiveHandleDescriptor = ConfigRenderLambda\n */\nexport type BlockConfigV4Generic<\n _Args = unknown,\n _Data extends Record<string, unknown> = Record<string, unknown>,\n BroadActiveHandleDescriptor = unknown,\n NarrowActiveHandleDescriptor extends BroadActiveHandleDescriptor = BroadActiveHandleDescriptor,\n Outputs extends Record<string, BroadActiveHandleDescriptor> = Record<string, BroadActiveHandleDescriptor>,\n> = {\n /** Discriminator to identify config version */\n readonly configVersion: 4;\n\n readonly modelAPIVersion: 2;\n\n /** SDK version used by the block */\n readonly sdkVersion: string;\n\n /** Main rendering mode for the block */\n readonly renderingMode: BlockRenderingMode;\n\n /** Lambda to derive block args from state */\n readonly args: NarrowActiveHandleDescriptor;\n\n /**\n * Lambda to derive prerun args from state (optional).\n * If not defined, defaults to using the args() result.\n * Used for staging/prerun phase.\n */\n readonly prerunArgs?: NarrowActiveHandleDescriptor;\n\n /** Lambda to get initial data when block is added to the project */\n readonly initialData: NarrowActiveHandleDescriptor;\n\n /** Lambda to derive list of sections for the left overview panel */\n readonly sections: NarrowActiveHandleDescriptor;\n\n /** Lambda to derive block title */\n readonly title?: NarrowActiveHandleDescriptor;\n\n /** Lambda to derive block subtitle, shown below the title */\n readonly subtitle?: NarrowActiveHandleDescriptor;\n\n /** Lambda returning array of tags for search functionality */\n readonly tags?: BroadActiveHandleDescriptor;\n\n /**\n * Lambda returning list of upstream blocks this block enriches with its exports,\n * influences dependency graph construction\n * */\n readonly enrichmentTargets?: NarrowActiveHandleDescriptor;\n\n /** Configuration for the output cells */\n readonly outputs: Outputs;\n\n /**\n * Array of migration descriptors for state version upgrades.\n * Each migration transforms state from version N to N+1.\n * Migrations are NOT rendered reactively - they run synchronously during block pack updates.\n */\n readonly migrations?: MigrationDescriptor[];\n\n /** Config code bundle */\n readonly code?: Code;\n\n /** Feature flags for the block Model and UI code. */\n readonly featureFlags?: BlockCodeFeatureFlags;\n};\n\n/**\n * BroadActiveHandleDescriptor = TypedConfigOrConfigLambda,\n * NarrowActiveHandleDescriptor = ConfigRenderLambda\n */\nexport type BlockConfigV3Generic<\n Args = unknown,\n UiState = unknown,\n BroadActiveHandleDescriptor = unknown,\n NarrowActiveHandleDescriptor extends BroadActiveHandleDescriptor = BroadActiveHandleDescriptor,\n Outputs extends Record<string, BroadActiveHandleDescriptor> = Record<string, BroadActiveHandleDescriptor>,\n> = {\n /** Discriminator to identify config version */\n readonly configVersion: 3;\n\n readonly modelAPIVersion: 1;\n\n /** SDK version used by the block */\n readonly sdkVersion: string;\n\n /** Main rendering mode for the block */\n readonly renderingMode: BlockRenderingMode;\n\n /** Initial value for the args when block is added to the project */\n readonly initialArgs: Args;\n\n /** Initial value for the args when block is added to the project */\n readonly initialUiState: UiState;\n\n /**\n * Config to determine whether the block can be executed with current\n * arguments.\n *\n * Optional to support earlier SDK version configs.\n */\n readonly inputsValid: BroadActiveHandleDescriptor;\n\n /** Configuration to derive list of section for the left overview panel */\n readonly sections: BroadActiveHandleDescriptor;\n\n /** Lambda to derive block title */\n readonly title?: NarrowActiveHandleDescriptor;\n\n /** Lambda to derive block subtitle, shown below the title */\n readonly subtitle?: NarrowActiveHandleDescriptor;\n\n /** Lambda returning array of tags for search functionality */\n readonly tags?: BroadActiveHandleDescriptor;\n\n /**\n * Lambda returning list of upstream blocks this block enriches with its exports,\n * influences dependency graph construction\n */\n readonly enrichmentTargets?: NarrowActiveHandleDescriptor;\n\n /** Configuration for the output cells */\n readonly outputs: Outputs;\n\n /** Config code bundle */\n readonly code?: Code;\n\n /** Feature flags for the block Model and UI code. */\n readonly featureFlags?: BlockCodeFeatureFlags;\n};\n\nexport type BlockConfigGeneric = BlockConfigV3Generic | BlockConfigV4Generic;\n\nexport function extractCodeWithInfo(cfg: BlockConfigGeneric): BlockCodeWithInfo {\n if (cfg.code === undefined) throw new Error('extractCodeWithInfo: No code bundle');\n return {\n code: cfg.code,\n sdkVersion: cfg.sdkVersion,\n featureFlags: cfg.featureFlags,\n };\n}\n"],"names":[],"mappings":";;AAAA;AAwJM,SAAU,mBAAmB,CAAC,GAAuB,EAAA;AACzD,IAAA,IAAI,GAAG,CAAC,IAAI,KAAK,SAAS;AAAE,QAAA,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC;IAClF,OAAO;QACL,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,UAAU,EAAE,GAAG,CAAC,UAAU;QAC1B,YAAY,EAAE,GAAG,CAAC,YAAY;KAC/B;AACH;;;;"}
@@ -1,11 +1,71 @@
1
1
  import type { BlockCodeFeatureFlags } from '../flags';
2
2
  import type { BlockCodeWithInfo, Code } from './code';
3
3
  import type { BlockRenderingMode } from './types';
4
+ /**
5
+ * Descriptor for a state migration function.
6
+ * Unlike ConfigRenderLambda, migrations are not rendered reactively -
7
+ * they are one-time synchronous transformations called during block pack updates.
8
+ */
9
+ export type MigrationDescriptor = {
10
+ /** Index of this migration in the migrations callback array */
11
+ readonly index: number;
12
+ };
13
+ /**
14
+ * BroadActiveHandleDescriptor = TypedConfigOrConfigLambda,
15
+ * NarrowActiveHandleDescriptor = ConfigRenderLambda
16
+ */
17
+ export type BlockConfigV4Generic<_Args = unknown, _Data extends Record<string, unknown> = Record<string, unknown>, BroadActiveHandleDescriptor = unknown, NarrowActiveHandleDescriptor extends BroadActiveHandleDescriptor = BroadActiveHandleDescriptor, Outputs extends Record<string, BroadActiveHandleDescriptor> = Record<string, BroadActiveHandleDescriptor>> = {
18
+ /** Discriminator to identify config version */
19
+ readonly configVersion: 4;
20
+ readonly modelAPIVersion: 2;
21
+ /** SDK version used by the block */
22
+ readonly sdkVersion: string;
23
+ /** Main rendering mode for the block */
24
+ readonly renderingMode: BlockRenderingMode;
25
+ /** Lambda to derive block args from state */
26
+ readonly args: NarrowActiveHandleDescriptor;
27
+ /**
28
+ * Lambda to derive prerun args from state (optional).
29
+ * If not defined, defaults to using the args() result.
30
+ * Used for staging/prerun phase.
31
+ */
32
+ readonly prerunArgs?: NarrowActiveHandleDescriptor;
33
+ /** Lambda to get initial data when block is added to the project */
34
+ readonly initialData: NarrowActiveHandleDescriptor;
35
+ /** Lambda to derive list of sections for the left overview panel */
36
+ readonly sections: NarrowActiveHandleDescriptor;
37
+ /** Lambda to derive block title */
38
+ readonly title?: NarrowActiveHandleDescriptor;
39
+ /** Lambda to derive block subtitle, shown below the title */
40
+ readonly subtitle?: NarrowActiveHandleDescriptor;
41
+ /** Lambda returning array of tags for search functionality */
42
+ readonly tags?: BroadActiveHandleDescriptor;
43
+ /**
44
+ * Lambda returning list of upstream blocks this block enriches with its exports,
45
+ * influences dependency graph construction
46
+ * */
47
+ readonly enrichmentTargets?: NarrowActiveHandleDescriptor;
48
+ /** Configuration for the output cells */
49
+ readonly outputs: Outputs;
50
+ /**
51
+ * Array of migration descriptors for state version upgrades.
52
+ * Each migration transforms state from version N to N+1.
53
+ * Migrations are NOT rendered reactively - they run synchronously during block pack updates.
54
+ */
55
+ readonly migrations?: MigrationDescriptor[];
56
+ /** Config code bundle */
57
+ readonly code?: Code;
58
+ /** Feature flags for the block Model and UI code. */
59
+ readonly featureFlags?: BlockCodeFeatureFlags;
60
+ };
4
61
  /**
5
62
  * BroadActiveHandleDescriptor = TypedConfigOrConfigLambda,
6
63
  * NarrowActiveHandleDescriptor = ConfigRenderLambda
7
64
  */
8
65
  export type BlockConfigV3Generic<Args = unknown, UiState = unknown, BroadActiveHandleDescriptor = unknown, NarrowActiveHandleDescriptor extends BroadActiveHandleDescriptor = BroadActiveHandleDescriptor, Outputs extends Record<string, BroadActiveHandleDescriptor> = Record<string, BroadActiveHandleDescriptor>> = {
66
+ /** Discriminator to identify config version */
67
+ readonly configVersion: 3;
68
+ readonly modelAPIVersion: 1;
9
69
  /** SDK version used by the block */
10
70
  readonly sdkVersion: string;
11
71
  /** Main rendering mode for the block */
@@ -41,6 +101,6 @@ export type BlockConfigV3Generic<Args = unknown, UiState = unknown, BroadActiveH
41
101
  /** Feature flags for the block Model and UI code. */
42
102
  readonly featureFlags?: BlockCodeFeatureFlags;
43
103
  };
44
- export type BlockConfigGeneric = BlockConfigV3Generic;
45
- export declare function extractCodeWithInfo(cfg: BlockConfigV3Generic): BlockCodeWithInfo;
104
+ export type BlockConfigGeneric = BlockConfigV3Generic | BlockConfigV4Generic;
105
+ export declare function extractCodeWithInfo(cfg: BlockConfigGeneric): BlockCodeWithInfo;
46
106
  //# sourceMappingURL=block_config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"block_config.d.ts","sourceRoot":"","sources":["../../src/bmodel/block_config.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM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c,EAAE,OAAO,CAAC;IAEjC;;;;;OAKG;IACH,QAAQ,CAAC,WAAW,EAAE,2BAA2B,CAAC;IAElD,0EAA0E;IAC1E,QAAQ,CAAC,QAAQ,EAAE,2BAA2B,CAAC;IAE/C,mCAAmC;IACnC,QAAQ,CAAC,KAAK,CAAC,EAAE,4BAA4B,CAAC;IAE9C,6DAA6D;IAC7D,QAAQ,CAAC,QAAQ,CAAC,EAAE,4BAA4B,CAAC;IAEjD,8DAA8D;IAC9D,QAAQ,CAAC,IAAI,CAAC,EAAE,2BAA2B,CAAC;IAE5C;;;OAGG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,4BAA4B,CAAC;IAE1D,yCAAyC;IACzC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAE1B,yBAAyB;IACzB,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC;IAErB,qDAAqD;IACrD,QAAQ,CAAC,YAAY,CAAC,EAAE,qBAAqB,CAAC;CAC/C,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,oBAAoB,GAAG,oBAAoB,CAAC;AAE7E,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,kBAAkB,GAAG,iBAAiB,CAO9E"}
@@ -1,7 +1,7 @@
1
1
  // TODO BroadActiveHandleDescriptor must be removed
2
2
  function extractCodeWithInfo(cfg) {
3
3
  if (cfg.code === undefined)
4
- throw new Error('No code bundle');
4
+ throw new Error('extractCodeWithInfo: No code bundle');
5
5
  return {
6
6
  code: cfg.code,
7
7
  sdkVersion: cfg.sdkVersion,
@@ -1 +1 @@
1
- {"version":3,"file":"block_config.js","sources":["../../src/bmodel/block_config.ts"],"sourcesContent":["// TODO BroadActiveHandleDescriptor must be removed\n\nimport type { BlockCodeFeatureFlags } from '../flags';\nimport type { BlockCodeWithInfo, Code } from './code';\nimport type { BlockRenderingMode } from './types';\n\n/**\n * BroadActiveHandleDescriptor = TypedConfigOrConfigLambda,\n * NarrowActiveHandleDescriptor = ConfigRenderLambda\n */\nexport type BlockConfigV3Generic<\n Args = unknown,\n UiState = unknown,\n BroadActiveHandleDescriptor = unknown,\n NarrowActiveHandleDescriptor extends BroadActiveHandleDescriptor = BroadActiveHandleDescriptor,\n Outputs extends Record<string, BroadActiveHandleDescriptor> = Record<string, BroadActiveHandleDescriptor>,\n> = {\n /** SDK version used by the block */\n readonly sdkVersion: string;\n\n /** Main rendering mode for the block */\n readonly renderingMode: BlockRenderingMode;\n\n /** Initial value for the args when block is added to the project */\n readonly initialArgs: Args;\n\n /** Initial value for the args when block is added to the project */\n readonly initialUiState: UiState;\n\n /**\n * Config to determine whether the block can be executed with current\n * arguments.\n *\n * Optional to support earlier SDK version configs.\n */\n readonly inputsValid: BroadActiveHandleDescriptor;\n\n /** Configuration to derive list of section for the left overview panel */\n readonly sections: BroadActiveHandleDescriptor;\n\n /** Lambda to derive block title */\n readonly title?: NarrowActiveHandleDescriptor;\n\n /** Lambda to derive block subtitle, shown below the title */\n readonly subtitle?: NarrowActiveHandleDescriptor;\n\n /** Lambda returning array of tags for search functionality */\n readonly tags?: BroadActiveHandleDescriptor;\n\n /**\n * Lambda returning list of upstream blocks this block enriches with its exports,\n * influences dependency graph construction\n */\n readonly enrichmentTargets?: NarrowActiveHandleDescriptor;\n\n /** Configuration for the output cells */\n readonly outputs: Outputs;\n\n /** Config code bundle */\n readonly code?: Code;\n\n /** Feature flags for the block Model and UI code. */\n readonly featureFlags?: BlockCodeFeatureFlags;\n};\n\nexport type BlockConfigGeneric = BlockConfigV3Generic;\n\nexport function extractCodeWithInfo(cfg: BlockConfigV3Generic): BlockCodeWithInfo {\n if (cfg.code === undefined) throw new Error('No code bundle');\n return {\n code: cfg.code,\n sdkVersion: cfg.sdkVersion,\n featureFlags: cfg.featureFlags,\n };\n}\n"],"names":[],"mappings":"AAAA;AAmEM,SAAU,mBAAmB,CAAC,GAAyB,EAAA;AAC3D,IAAA,IAAI,GAAG,CAAC,IAAI,KAAK,SAAS;AAAE,QAAA,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC;IAC7D,OAAO;QACL,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,UAAU,EAAE,GAAG,CAAC,UAAU;QAC1B,YAAY,EAAE,GAAG,CAAC,YAAY;KAC/B;AACH;;;;"}
1
+ {"version":3,"file":"block_config.js","sources":["../../src/bmodel/block_config.ts"],"sourcesContent":["// TODO BroadActiveHandleDescriptor must be removed\n\nimport type { BlockCodeFeatureFlags } from '../flags';\nimport type { BlockCodeWithInfo, Code } from './code';\nimport type { BlockRenderingMode } from './types';\n\n/**\n * Descriptor for a state migration function.\n * Unlike ConfigRenderLambda, migrations are not rendered reactively -\n * they are one-time synchronous transformations called during block pack updates.\n */\nexport type MigrationDescriptor = {\n /** Index of this migration in the migrations callback array */\n readonly index: number;\n};\n\n/**\n * BroadActiveHandleDescriptor = TypedConfigOrConfigLambda,\n * NarrowActiveHandleDescriptor = ConfigRenderLambda\n */\nexport type BlockConfigV4Generic<\n _Args = unknown,\n _Data extends Record<string, unknown> = Record<string, unknown>,\n BroadActiveHandleDescriptor = unknown,\n NarrowActiveHandleDescriptor extends BroadActiveHandleDescriptor = BroadActiveHandleDescriptor,\n Outputs extends Record<string, BroadActiveHandleDescriptor> = Record<string, BroadActiveHandleDescriptor>,\n> = {\n /** Discriminator to identify config version */\n readonly configVersion: 4;\n\n readonly modelAPIVersion: 2;\n\n /** SDK version used by the block */\n readonly sdkVersion: string;\n\n /** Main rendering mode for the block */\n readonly renderingMode: BlockRenderingMode;\n\n /** Lambda to derive block args from state */\n readonly args: NarrowActiveHandleDescriptor;\n\n /**\n * Lambda to derive prerun args from state (optional).\n * If not defined, defaults to using the args() result.\n * Used for staging/prerun phase.\n */\n readonly prerunArgs?: NarrowActiveHandleDescriptor;\n\n /** Lambda to get initial data when block is added to the project */\n readonly initialData: NarrowActiveHandleDescriptor;\n\n /** Lambda to derive list of sections for the left overview panel */\n readonly sections: NarrowActiveHandleDescriptor;\n\n /** Lambda to derive block title */\n readonly title?: NarrowActiveHandleDescriptor;\n\n /** Lambda to derive block subtitle, shown below the title */\n readonly subtitle?: NarrowActiveHandleDescriptor;\n\n /** Lambda returning array of tags for search functionality */\n readonly tags?: BroadActiveHandleDescriptor;\n\n /**\n * Lambda returning list of upstream blocks this block enriches with its exports,\n * influences dependency graph construction\n * */\n readonly enrichmentTargets?: NarrowActiveHandleDescriptor;\n\n /** Configuration for the output cells */\n readonly outputs: Outputs;\n\n /**\n * Array of migration descriptors for state version upgrades.\n * Each migration transforms state from version N to N+1.\n * Migrations are NOT rendered reactively - they run synchronously during block pack updates.\n */\n readonly migrations?: MigrationDescriptor[];\n\n /** Config code bundle */\n readonly code?: Code;\n\n /** Feature flags for the block Model and UI code. */\n readonly featureFlags?: BlockCodeFeatureFlags;\n};\n\n/**\n * BroadActiveHandleDescriptor = TypedConfigOrConfigLambda,\n * NarrowActiveHandleDescriptor = ConfigRenderLambda\n */\nexport type BlockConfigV3Generic<\n Args = unknown,\n UiState = unknown,\n BroadActiveHandleDescriptor = unknown,\n NarrowActiveHandleDescriptor extends BroadActiveHandleDescriptor = BroadActiveHandleDescriptor,\n Outputs extends Record<string, BroadActiveHandleDescriptor> = Record<string, BroadActiveHandleDescriptor>,\n> = {\n /** Discriminator to identify config version */\n readonly configVersion: 3;\n\n readonly modelAPIVersion: 1;\n\n /** SDK version used by the block */\n readonly sdkVersion: string;\n\n /** Main rendering mode for the block */\n readonly renderingMode: BlockRenderingMode;\n\n /** Initial value for the args when block is added to the project */\n readonly initialArgs: Args;\n\n /** Initial value for the args when block is added to the project */\n readonly initialUiState: UiState;\n\n /**\n * Config to determine whether the block can be executed with current\n * arguments.\n *\n * Optional to support earlier SDK version configs.\n */\n readonly inputsValid: BroadActiveHandleDescriptor;\n\n /** Configuration to derive list of section for the left overview panel */\n readonly sections: BroadActiveHandleDescriptor;\n\n /** Lambda to derive block title */\n readonly title?: NarrowActiveHandleDescriptor;\n\n /** Lambda to derive block subtitle, shown below the title */\n readonly subtitle?: NarrowActiveHandleDescriptor;\n\n /** Lambda returning array of tags for search functionality */\n readonly tags?: BroadActiveHandleDescriptor;\n\n /**\n * Lambda returning list of upstream blocks this block enriches with its exports,\n * influences dependency graph construction\n */\n readonly enrichmentTargets?: NarrowActiveHandleDescriptor;\n\n /** Configuration for the output cells */\n readonly outputs: Outputs;\n\n /** Config code bundle */\n readonly code?: Code;\n\n /** Feature flags for the block Model and UI code. */\n readonly featureFlags?: BlockCodeFeatureFlags;\n};\n\nexport type BlockConfigGeneric = BlockConfigV3Generic | BlockConfigV4Generic;\n\nexport function extractCodeWithInfo(cfg: BlockConfigGeneric): BlockCodeWithInfo {\n if (cfg.code === undefined) throw new Error('extractCodeWithInfo: No code bundle');\n return {\n code: cfg.code,\n sdkVersion: cfg.sdkVersion,\n featureFlags: cfg.featureFlags,\n };\n}\n"],"names":[],"mappings":"AAAA;AAwJM,SAAU,mBAAmB,CAAC,GAAuB,EAAA;AACzD,IAAA,IAAI,GAAG,CAAC,IAAI,KAAK,SAAS;AAAE,QAAA,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC;IAClF,OAAO;QACL,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,UAAU,EAAE,GAAG,CAAC,UAAU;QAC1B,YAAY,EAAE,GAAG,CAAC,YAAY;KAC/B;AACH;;;;"}
@@ -1,10 +1,11 @@
1
- import type { BlockConfigV3Generic } from './block_config';
1
+ import type { BlockConfigV3Generic, BlockConfigV4Generic } from './block_config';
2
2
  import type { Code } from './code';
3
3
  import type { BlockRenderingMode } from './types';
4
4
  /** Container simplifying maintenance of forward and backward compatibility */
5
5
  export type BlockConfigContainer = {
6
+ readonly v4?: Omit<BlockConfigV4Generic, 'code'>;
6
7
  /** Actual config */
7
- readonly v3: Omit<BlockConfigV3Generic, 'code'>;
8
+ readonly v3?: Omit<BlockConfigV3Generic, 'code'>;
8
9
  /** Config code bundle. Actually is required, but we keep it optional for backward compatibility */
9
10
  readonly code?: Code;
10
11
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../../src/bmodel/container.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAElD,8EAA8E;AAC9E,MAAM,MAAM,oBAAoB,GAAG;IACjC,oBAAoB;IACpB,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC,oBAAoB,EAAE,MAAM,CAAC,CAAC;IAEhD,mGAAmG;IACnG,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC;IAMrB;;;OAGG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAE7B;;;OAGG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,kBAAkB,CAAC;IAE5C;;;OAGG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC;IAE/B;;;OAGG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAE1B;;;OAGG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC;IAE/B;;;OAGG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAE5B;;;OAGG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC5C,CAAC"}
1
+ {"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../../src/bmodel/container.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACjF,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAElD,8EAA8E;AAC9E,MAAM,MAAM,oBAAoB,GAAG;IACjC,QAAQ,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,oBAAoB,EAAE,MAAM,CAAC,CAAC;IACjD,oBAAoB;IACpB,QAAQ,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,oBAAoB,EAAE,MAAM,CAAC,CAAC;IAEjD,mGAAmG;IACnG,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC;IAMrB;;;OAGG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAE7B;;;OAGG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,kBAAkB,CAAC;IAE5C;;;OAGG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC;IAE/B;;;OAGG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAE1B;;;OAGG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC;IAE/B;;;OAGG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAE5B;;;OAGG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC5C,CAAC"}
@@ -10,15 +10,38 @@ function upgradeCfgOrLambda(data) {
10
10
  /**
11
11
  * Takes universal config, and converts it into latest config structure.
12
12
  *
13
- * **Important**: This operation is not meant to be executed recusively.
13
+ * **Important**: This operation is not meant to be executed recursively.
14
14
  * In no circumstance result of this function should be persisted!
15
15
  * */
16
16
  function extractConfigGeneric(cfg) {
17
- if (cfg.v3 !== undefined) {
18
- // version 3
17
+ if (cfg.v4 !== undefined) {
18
+ // version 4 (BlockModelV3) - inputsValid is derived from args() success/failure
19
+ const { args, prerunArgs, initialData, outputs, renderingMode, sdkVersion, featureFlags, sections, title, enrichmentTargets, migrations } = cfg.v4;
20
+ const { code } = cfg;
21
+ return {
22
+ configVersion: 4,
23
+ modelAPIVersion: 2,
24
+ args,
25
+ prerunArgs,
26
+ initialData,
27
+ outputs,
28
+ renderingMode,
29
+ sdkVersion,
30
+ featureFlags,
31
+ sections,
32
+ title,
33
+ enrichmentTargets,
34
+ migrations,
35
+ code,
36
+ };
37
+ }
38
+ else if (cfg.v3 !== undefined) {
39
+ // version 3 (BlockModel v1)
19
40
  const { initialArgs, initialUiState, inputsValid, outputs, renderingMode, sdkVersion, featureFlags, sections, title, subtitle, tags, enrichmentTargets, } = cfg.v3;
20
41
  const { code } = cfg;
21
42
  return {
43
+ configVersion: 3,
44
+ modelAPIVersion: 1,
22
45
  initialArgs,
23
46
  initialUiState,
24
47
  inputsValid,
@@ -35,7 +58,7 @@ function extractConfigGeneric(cfg) {
35
58
  };
36
59
  }
37
60
  else if (cfg.inputsValid !== undefined) {
38
- // version 2
61
+ // version 2 (legacy) - normalize to v3 format
39
62
  const { sdkVersion, renderingMode, outputs, inputsValid, sections, initialArgs, code } = cfg;
40
63
  const fields = Object.keys(cfg);
41
64
  if (sdkVersion === undefined
@@ -46,6 +69,8 @@ function extractConfigGeneric(cfg) {
46
69
  || initialArgs === undefined)
47
70
  throw new Error(`Malformed config v2. SDK version ${sdkVersion}; Fields = ${fields.join(', ')}`);
48
71
  return {
72
+ configVersion: 3,
73
+ modelAPIVersion: 1,
49
74
  sdkVersion,
50
75
  renderingMode,
51
76
  initialArgs,
@@ -57,7 +82,7 @@ function extractConfigGeneric(cfg) {
57
82
  };
58
83
  }
59
84
  else if (cfg.renderingMode !== undefined) {
60
- // version 1
85
+ // version 1 (legacy) - normalize to v3 format
61
86
  const { sdkVersion, canRun, renderingMode, outputs, sections, initialArgs, code } = cfg;
62
87
  const fields = Object.keys(cfg);
63
88
  if (renderingMode === undefined
@@ -67,6 +92,8 @@ function extractConfigGeneric(cfg) {
67
92
  || initialArgs === undefined)
68
93
  throw new Error(`Malformed config v1. SDK version ${sdkVersion}; Fields = ${fields.join(', ')}`);
69
94
  return {
95
+ configVersion: 3,
96
+ modelAPIVersion: 1,
70
97
  sdkVersion: sdkVersion ?? 'unknown',
71
98
  renderingMode,
72
99
  initialArgs,
@@ -1 +1 @@
1
- {"version":3,"file":"normalization.cjs","sources":["../../src/bmodel/normalization.ts"],"sourcesContent":["import type { BlockConfigGeneric } from './block_config';\nimport type { BlockConfigContainer } from './container';\n\nfunction upgradeCfgOrLambda(data: unknown): unknown;\nfunction upgradeCfgOrLambda(\n data: unknown | undefined\n): unknown | undefined;\nfunction upgradeCfgOrLambda(\n data: unknown | undefined,\n): unknown | undefined {\n if (data === undefined) return undefined;\n if (typeof data === 'string') return { __renderLambda: true, handle: data, retentive: false };\n return data;\n}\n\n/**\n * Takes universal config, and converts it into latest config structure.\n *\n * **Important**: This operation is not meant to be executed recusively.\n * In no circumstance result of this function should be persisted!\n * */\nexport function extractConfigGeneric(cfg: BlockConfigContainer): BlockConfigGeneric {\n if (cfg.v3 !== undefined) {\n // version 3\n const {\n initialArgs,\n initialUiState,\n inputsValid,\n outputs,\n renderingMode,\n sdkVersion,\n featureFlags,\n sections,\n title,\n subtitle,\n tags,\n enrichmentTargets,\n } = cfg.v3;\n const { code } = cfg;\n return {\n initialArgs,\n initialUiState,\n inputsValid,\n outputs,\n renderingMode,\n sdkVersion,\n featureFlags,\n sections,\n title,\n subtitle,\n tags,\n code,\n enrichmentTargets,\n };\n } else if (cfg.inputsValid !== undefined) {\n // version 2\n const { sdkVersion, renderingMode, outputs, inputsValid, sections, initialArgs, code } = cfg;\n const fields = Object.keys(cfg);\n if (\n sdkVersion === undefined\n || renderingMode === undefined\n || outputs === undefined\n || inputsValid === undefined\n || sections === undefined\n || initialArgs === undefined\n )\n throw new Error(\n `Malformed config v2. SDK version ${sdkVersion}; Fields = ${fields.join(', ')}`,\n );\n return {\n sdkVersion,\n renderingMode,\n initialArgs,\n outputs: Object.fromEntries(\n Object.entries(outputs).map(([key, value]) => [key, upgradeCfgOrLambda(value)]),\n ),\n inputsValid: upgradeCfgOrLambda(inputsValid),\n sections: upgradeCfgOrLambda(sections),\n initialUiState: undefined,\n code,\n };\n } else if (cfg.renderingMode !== undefined) {\n // version 1\n const { sdkVersion, canRun, renderingMode, outputs, sections, initialArgs, code } = cfg;\n const fields = Object.keys(cfg);\n if (\n renderingMode === undefined\n || outputs === undefined\n || canRun === undefined\n || sections === undefined\n || initialArgs === undefined\n )\n throw new Error(\n `Malformed config v1. SDK version ${sdkVersion}; Fields = ${fields.join(', ')}`,\n );\n return {\n sdkVersion: sdkVersion ?? 'unknown',\n renderingMode,\n initialArgs,\n outputs: Object.fromEntries(\n Object.entries(outputs).map(([key, value]) => [key, upgradeCfgOrLambda(value)]),\n ),\n inputsValid: upgradeCfgOrLambda(canRun),\n sections: upgradeCfgOrLambda(sections),\n initialUiState: undefined,\n code,\n };\n } else {\n const { sdkVersion } = cfg;\n const fields = Object.keys(cfg);\n throw new Error(\n `Config format not supported: SDK = ${sdkVersion}; Fields = ${fields.join(', ')}`,\n );\n }\n}\n"],"names":[],"mappings":";;AAOA,SAAS,kBAAkB,CACzB,IAAyB,EAAA;IAEzB,IAAI,IAAI,KAAK,SAAS;AAAE,QAAA,OAAO,SAAS;IACxC,IAAI,OAAO,IAAI,KAAK,QAAQ;AAAE,QAAA,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE;AAC7F,IAAA,OAAO,IAAI;AACb;AAEA;;;;;AAKK;AACC,SAAU,oBAAoB,CAAC,GAAyB,EAAA;AAC5D,IAAA,IAAI,GAAG,CAAC,EAAE,KAAK,SAAS,EAAE;;AAExB,QAAA,MAAM,EACJ,WAAW,EACX,cAAc,EACd,WAAW,EACX,OAAO,EACP,aAAa,EACb,UAAU,EACV,YAAY,EACZ,QAAQ,EACR,KAAK,EACL,QAAQ,EACR,IAAI,EACJ,iBAAiB,GAClB,GAAG,GAAG,CAAC,EAAE;AACV,QAAA,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG;QACpB,OAAO;YACL,WAAW;YACX,cA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AE,GAAG,GAAG;QACvF,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;QAC/B,IACE,aAAa,KAAK;AACf,eAAA,OAAO,KAAK;AACZ,eAAA,MAAM,KAAK;AACX,eAAA,QAAQ,KAAK;AACb,eAAA,WAAW,KAAK,SAAS;AAE5B,YAAA,MAAM,IAAI,KAAK,CACb,CAAA,iCAAA,EAAoC,UAAU,CAAA,WAAA,EAAc,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA,CAAE,CAChF;QACH,OAAO;YACL,UAAU,EAAE,UAAU,IAAI,SAAS;YACnC,aAAa;YACb,WAAW;AACX,YAAA,OAAO,EAAE,MAAM,CAAC,WAAW,CACzB,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC,CAChF;AACD,YAAA,WAAW,EAAE,kBAAkB,CAAC,MAAM,CAAC;AACvC,YAAA,QAAQ,EAAE,kBAAkB,CAAC,QAAQ,CAAC;AACtC,YAAA,cAAc,EAAE,SAAS;YACzB,IAAI;SACL;IACH;SAAO;AACL,QAAA,MAAM,EAAE,UAAU,EAAE,GAAG,GAAG;QAC1B,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;AAC/B,QAAA,MAAM,IAAI,KAAK,CACb,CAAA,mCAAA,EAAsC,UAAU,CAAA,WAAA,EAAc,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA,CAAE,CAClF;IACH;AACF;;;;"}
1
+ {"version":3,"file":"normalization.cjs","sources":["../../src/bmodel/normalization.ts"],"sourcesContent":["import type { BlockConfigGeneric } from './block_config';\nimport type { BlockConfigContainer } from './container';\n\nfunction upgradeCfgOrLambda(data: unknown): unknown;\nfunction upgradeCfgOrLambda(\n data: unknown | undefined\n): unknown | undefined;\nfunction upgradeCfgOrLambda(\n data: unknown | undefined,\n): unknown | undefined {\n if (data === undefined) return undefined;\n if (typeof data === 'string') return { __renderLambda: true, handle: data, retentive: false };\n return data;\n}\n\n/**\n * Takes universal config, and converts it into latest config structure.\n *\n * **Important**: This operation is not meant to be executed recursively.\n * In no circumstance result of this function should be persisted!\n * */\nexport function extractConfigGeneric(cfg: BlockConfigContainer): BlockConfigGeneric {\n if (cfg.v4 !== undefined) {\n // version 4 (BlockModelV3) - inputsValid is derived from args() success/failure\n const { args, prerunArgs, initialData, outputs, renderingMode, sdkVersion, featureFlags, sections, title, enrichmentTargets, migrations } = cfg.v4;\n const { code } = cfg;\n return {\n configVersion: 4,\n modelAPIVersion: 2,\n args,\n prerunArgs,\n initialData,\n outputs,\n renderingMode,\n sdkVersion,\n featureFlags,\n sections,\n title,\n enrichmentTargets,\n migrations,\n code,\n };\n } else if (cfg.v3 !== undefined) {\n // version 3 (BlockModel v1)\n const {\n initialArgs,\n initialUiState,\n inputsValid,\n outputs,\n renderingMode,\n sdkVersion,\n featureFlags,\n sections,\n title,\n subtitle,\n tags,\n enrichmentTargets,\n } = cfg.v3;\n const { code } = cfg;\n return {\n configVersion: 3,\n modelAPIVersion: 1,\n initialArgs,\n initialUiState,\n inputsValid,\n outputs,\n renderingMode,\n sdkVersion,\n featureFlags,\n sections,\n title,\n subtitle,\n tags,\n code,\n enrichmentTargets,\n };\n } else if (cfg.inputsValid !== undefined) {\n // version 2 (legacy) - normalize to v3 format\n const { sdkVersion, renderingMode, outputs, inputsValid, sections, initialArgs, code } = cfg;\n const fields = Object.keys(cfg);\n if (\n sdkVersion === undefined\n || renderingMode === undefined\n || outputs === undefined\n || inputsValid === undefined\n || sections === undefined\n || initialArgs === undefined\n )\n throw new Error(\n `Malformed config v2. SDK version ${sdkVersion}; Fields = ${fields.join(', ')}`,\n );\n return {\n configVersion: 3,\n modelAPIVersion: 1,\n sdkVersion,\n renderingMode,\n initialArgs,\n outputs: Object.fromEntries(\n Object.entries(outputs).map(([key, value]) => [key, upgradeCfgOrLambda(value)]),\n ),\n inputsValid: upgradeCfgOrLambda(inputsValid),\n sections: upgradeCfgOrLambda(sections),\n initialUiState: undefined,\n code,\n };\n } else if (cfg.renderingMode !== undefined) {\n // version 1 (legacy) - normalize to v3 format\n const { sdkVersion, canRun, renderingMode, outputs, sections, initialArgs, code } = cfg;\n const fields = Object.keys(cfg);\n if (\n renderingMode === undefined\n || outputs === undefined\n || canRun === undefined\n || sections === undefined\n || initialArgs === undefined\n )\n throw new Error(\n `Malformed config v1. SDK version ${sdkVersion}; Fields = ${fields.join(', ')}`,\n );\n return {\n configVersion: 3,\n modelAPIVersion: 1,\n sdkVersion: sdkVersion ?? 'unknown',\n renderingMode,\n initialArgs,\n outputs: Object.fromEntries(\n Object.entries(outputs).map(([key, value]) => [key, upgradeCfgOrLambda(value)]),\n ),\n inputsValid: upgradeCfgOrLambda(canRun),\n sections: upgradeCfgOrLambda(sections),\n initialUiState: undefined,\n code,\n };\n } else {\n const { sdkVersion } = cfg;\n const fields = Object.keys(cfg);\n throw new Error(\n `Config format not supported: SDK = ${sdkVersion}; Fields = ${fields.join(', ')}`,\n );\n }\n}\n"],"names":[],"mappings":";;AAOA,SAAS,kBAAkB,CACzB,IAAyB,EAAA;IAEzB,IAAI,IAAI,KAAK,SAAS;AAAE,QAAA,OAAO,SAAS;IACxC,IAAI,OAAO,IAAI,KAAK,QAAQ;AAAE,QAAA,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE;AAC7F,IAAA,OAAO,IAAI;AACb;AAEA;;;;;AAKK;AACC,SAAU,oBAAoB,CAAC,GAAyB,EAAA;AAC5D,IAAA,IAAI,GAAG,CAAC,EAAE,KAAK,SAAS,EAAE;;QAExB,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,WAAW,EAAE,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,KA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AACX,YAAA,OAAO,EAAE,MAAM,CAAC,WAAW,CACzB,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC,CAChF;AACD,YAAA,WAAW,EAAE,kBAAkB,CAAC,MAAM,CAAC;AACvC,YAAA,QAAQ,EAAE,kBAAkB,CAAC,QAAQ,CAAC;AACtC,YAAA,cAAc,EAAE,SAAS;YACzB,IAAI;SACL;IACH;SAAO;AACL,QAAA,MAAM,EAAE,UAAU,EAAE,GAAG,GAAG;QAC1B,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;AAC/B,QAAA,MAAM,IAAI,KAAK,CACb,CAAA,mCAAA,EAAsC,UAAU,CAAA,WAAA,EAAc,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA,CAAE,CAClF;IACH;AACF;;;;"}
@@ -3,7 +3,7 @@ import type { BlockConfigContainer } from './container';
3
3
  /**
4
4
  * Takes universal config, and converts it into latest config structure.
5
5
  *
6
- * **Important**: This operation is not meant to be executed recusively.
6
+ * **Important**: This operation is not meant to be executed recursively.
7
7
  * In no circumstance result of this function should be persisted!
8
8
  * */
9
9
  export declare function extractConfigGeneric(cfg: BlockConfigContainer): BlockConfigGeneric;
@@ -1 +1 @@
1
- {"version":3,"file":"normalization.d.ts","sourceRoot":"","sources":["../../src/bmodel/normalization.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAcxD;;;;;KAKK;AACL,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,oBAAoB,GAAG,kBAAkB,CA6FlF"}
1
+ {"version":3,"file":"normalization.d.ts","sourceRoot":"","sources":["../../src/bmodel/normalization.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAcxD;;;;;KAKK;AACL,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,oBAAoB,GAAG,kBAAkB,CAuHlF"}
@@ -8,15 +8,38 @@ function upgradeCfgOrLambda(data) {
8
8
  /**
9
9
  * Takes universal config, and converts it into latest config structure.
10
10
  *
11
- * **Important**: This operation is not meant to be executed recusively.
11
+ * **Important**: This operation is not meant to be executed recursively.
12
12
  * In no circumstance result of this function should be persisted!
13
13
  * */
14
14
  function extractConfigGeneric(cfg) {
15
- if (cfg.v3 !== undefined) {
16
- // version 3
15
+ if (cfg.v4 !== undefined) {
16
+ // version 4 (BlockModelV3) - inputsValid is derived from args() success/failure
17
+ const { args, prerunArgs, initialData, outputs, renderingMode, sdkVersion, featureFlags, sections, title, enrichmentTargets, migrations } = cfg.v4;
18
+ const { code } = cfg;
19
+ return {
20
+ configVersion: 4,
21
+ modelAPIVersion: 2,
22
+ args,
23
+ prerunArgs,
24
+ initialData,
25
+ outputs,
26
+ renderingMode,
27
+ sdkVersion,
28
+ featureFlags,
29
+ sections,
30
+ title,
31
+ enrichmentTargets,
32
+ migrations,
33
+ code,
34
+ };
35
+ }
36
+ else if (cfg.v3 !== undefined) {
37
+ // version 3 (BlockModel v1)
17
38
  const { initialArgs, initialUiState, inputsValid, outputs, renderingMode, sdkVersion, featureFlags, sections, title, subtitle, tags, enrichmentTargets, } = cfg.v3;
18
39
  const { code } = cfg;
19
40
  return {
41
+ configVersion: 3,
42
+ modelAPIVersion: 1,
20
43
  initialArgs,
21
44
  initialUiState,
22
45
  inputsValid,
@@ -33,7 +56,7 @@ function extractConfigGeneric(cfg) {
33
56
  };
34
57
  }
35
58
  else if (cfg.inputsValid !== undefined) {
36
- // version 2
59
+ // version 2 (legacy) - normalize to v3 format
37
60
  const { sdkVersion, renderingMode, outputs, inputsValid, sections, initialArgs, code } = cfg;
38
61
  const fields = Object.keys(cfg);
39
62
  if (sdkVersion === undefined
@@ -44,6 +67,8 @@ function extractConfigGeneric(cfg) {
44
67
  || initialArgs === undefined)
45
68
  throw new Error(`Malformed config v2. SDK version ${sdkVersion}; Fields = ${fields.join(', ')}`);
46
69
  return {
70
+ configVersion: 3,
71
+ modelAPIVersion: 1,
47
72
  sdkVersion,
48
73
  renderingMode,
49
74
  initialArgs,
@@ -55,7 +80,7 @@ function extractConfigGeneric(cfg) {
55
80
  };
56
81
  }
57
82
  else if (cfg.renderingMode !== undefined) {
58
- // version 1
83
+ // version 1 (legacy) - normalize to v3 format
59
84
  const { sdkVersion, canRun, renderingMode, outputs, sections, initialArgs, code } = cfg;
60
85
  const fields = Object.keys(cfg);
61
86
  if (renderingMode === undefined
@@ -65,6 +90,8 @@ function extractConfigGeneric(cfg) {
65
90
  || initialArgs === undefined)
66
91
  throw new Error(`Malformed config v1. SDK version ${sdkVersion}; Fields = ${fields.join(', ')}`);
67
92
  return {
93
+ configVersion: 3,
94
+ modelAPIVersion: 1,
68
95
  sdkVersion: sdkVersion ?? 'unknown',
69
96
  renderingMode,
70
97
  initialArgs,
@@ -1 +1 @@
1
- {"version":3,"file":"normalization.js","sources":["../../src/bmodel/normalization.ts"],"sourcesContent":["import type { BlockConfigGeneric } from './block_config';\nimport type { BlockConfigContainer } from './container';\n\nfunction upgradeCfgOrLambda(data: unknown): unknown;\nfunction upgradeCfgOrLambda(\n data: unknown | undefined\n): unknown | undefined;\nfunction upgradeCfgOrLambda(\n data: unknown | undefined,\n): unknown | undefined {\n if (data === undefined) return undefined;\n if (typeof data === 'string') return { __renderLambda: true, handle: data, retentive: false };\n return data;\n}\n\n/**\n * Takes universal config, and converts it into latest config structure.\n *\n * **Important**: This operation is not meant to be executed recusively.\n * In no circumstance result of this function should be persisted!\n * */\nexport function extractConfigGeneric(cfg: BlockConfigContainer): BlockConfigGeneric {\n if (cfg.v3 !== undefined) {\n // version 3\n const {\n initialArgs,\n initialUiState,\n inputsValid,\n outputs,\n renderingMode,\n sdkVersion,\n featureFlags,\n sections,\n title,\n subtitle,\n tags,\n enrichmentTargets,\n } = cfg.v3;\n const { code } = cfg;\n return {\n initialArgs,\n initialUiState,\n inputsValid,\n outputs,\n renderingMode,\n sdkVersion,\n featureFlags,\n sections,\n title,\n subtitle,\n tags,\n code,\n enrichmentTargets,\n };\n } else if (cfg.inputsValid !== undefined) {\n // version 2\n const { sdkVersion, renderingMode, outputs, inputsValid, sections, initialArgs, code } = cfg;\n const fields = Object.keys(cfg);\n if (\n sdkVersion === undefined\n || renderingMode === undefined\n || outputs === undefined\n || inputsValid === undefined\n || sections === undefined\n || initialArgs === undefined\n )\n throw new Error(\n `Malformed config v2. SDK version ${sdkVersion}; Fields = ${fields.join(', ')}`,\n );\n return {\n sdkVersion,\n renderingMode,\n initialArgs,\n outputs: Object.fromEntries(\n Object.entries(outputs).map(([key, value]) => [key, upgradeCfgOrLambda(value)]),\n ),\n inputsValid: upgradeCfgOrLambda(inputsValid),\n sections: upgradeCfgOrLambda(sections),\n initialUiState: undefined,\n code,\n };\n } else if (cfg.renderingMode !== undefined) {\n // version 1\n const { sdkVersion, canRun, renderingMode, outputs, sections, initialArgs, code } = cfg;\n const fields = Object.keys(cfg);\n if (\n renderingMode === undefined\n || outputs === undefined\n || canRun === undefined\n || sections === undefined\n || initialArgs === undefined\n )\n throw new Error(\n `Malformed config v1. SDK version ${sdkVersion}; Fields = ${fields.join(', ')}`,\n );\n return {\n sdkVersion: sdkVersion ?? 'unknown',\n renderingMode,\n initialArgs,\n outputs: Object.fromEntries(\n Object.entries(outputs).map(([key, value]) => [key, upgradeCfgOrLambda(value)]),\n ),\n inputsValid: upgradeCfgOrLambda(canRun),\n sections: upgradeCfgOrLambda(sections),\n initialUiState: undefined,\n code,\n };\n } else {\n const { sdkVersion } = cfg;\n const fields = Object.keys(cfg);\n throw new Error(\n `Config format not supported: SDK = ${sdkVersion}; F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,GAAG,EAAE,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC,CAChF;AACD,YAAA,WAAW,EAAE,kBAAkB,CAAC,MAAM,CAAC;AACvC,YAAA,QAAQ,EAAE,kBAAkB,CAAC,QAAQ,CAAC;AACtC,YAAA,cAAc,EAAE,SAAS;YACzB,IAAI;SACL;IACH;SAAO;AACL,QAAA,MAAM,EAAE,UAAU,EAAE,GAAG,GAAG;QAC1B,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;AAC/B,QAAA,MAAM,IAAI,KAAK,CACb,CAAA,mCAAA,EAAsC,UAAU,CAAA,WAAA,EAAc,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA,CAAE,CAClF;IACH;AACF;;;;"}
1
+ {"version":3,"file":"normalization.js","sources":["../../src/bmodel/normalization.ts"],"sourcesContent":["import type { BlockConfigGeneric } from './block_config';\nimport type { BlockConfigContainer } from './container';\n\nfunction upgradeCfgOrLambda(data: unknown): unknown;\nfunction upgradeCfgOrLambda(\n data: unknown | undefined\n): unknown | undefined;\nfunction upgradeCfgOrLambda(\n data: unknown | undefined,\n): unknown | undefined {\n if (data === undefined) return undefined;\n if (typeof data === 'string') return { __renderLambda: true, handle: data, retentive: false };\n return data;\n}\n\n/**\n * Takes universal config, and converts it into latest config structure.\n *\n * **Important**: This operation is not meant to be executed recursively.\n * In no circumstance result of this function should be persisted!\n * */\nexport function extractConfigGeneric(cfg: BlockConfigContainer): BlockConfigGeneric {\n if (cfg.v4 !== undefined) {\n // version 4 (BlockModelV3) - inputsValid is derived from args() success/failure\n const { args, prerunArgs, initialData, outputs, renderingMode, sdkVersion, featureFlags, sections, title, enrichmentTargets, migrations } = cfg.v4;\n const { code } = cfg;\n return {\n configVersion: 4,\n modelAPIVersion: 2,\n args,\n prerunArgs,\n initialData,\n outputs,\n renderingMode,\n sdkVersion,\n featureFlags,\n sections,\n title,\n enrichmentTargets,\n migrations,\n code,\n };\n } else if (cfg.v3 !== undefined) {\n // version 3 (BlockModel v1)\n const {\n initialArgs,\n initialUiState,\n inputsValid,\n outputs,\n renderingMode,\n sdkVersion,\n featureFlags,\n sections,\n title,\n subtitle,\n tags,\n enrichmentTargets,\n } = cfg.v3;\n const { code } = cfg;\n return {\n configVersion: 3,\n modelAPIVersion: 1,\n initialArgs,\n initialUiState,\n inputsValid,\n outputs,\n renderingMode,\n sdkVersion,\n featureFlags,\n sections,\n title,\n subtitle,\n tags,\n code,\n enrichmentTargets,\n };\n } else if (cfg.inputsValid !== undefined) {\n // version 2 (legacy) - normalize to v3 format\n const { sdkVersion, renderingMode, outputs, inputsValid, sections, initialArgs, code } = cfg;\n const fields = Object.keys(cfg);\n if (\n sdkVersion === undefined\n || renderingMode === undefined\n || outputs === undefined\n || inputsValid === undefined\n || sections === undefined\n || initialArgs === undefined\n )\n throw new Error(\n `Malformed config v2. SDK version ${sdkVersion}; Fields = ${fields.join(', ')}`,\n );\n return {\n configVersion: 3,\n modelAPIVersion: 1,\n sdkVersion,\n renderingMode,\n initialArgs,\n outputs: Object.fromEntries(\n Object.entries(outputs).map(([key, value]) => [key, upgradeCfgOrLambda(value)]),\n ),\n inputsValid: upgradeCfgOrLambda(inputsValid),\n sections: upgradeCfgOrLambda(sections),\n initialUiState: undefined,\n code,\n };\n } else if (cfg.renderingMode !== undefined) {\n // version 1 (legacy) - normalize to v3 format\n const { sdkVersion, canRun, renderingMode, outputs, sections, initialArgs, code } = cfg;\n const fields = Object.keys(cfg);\n if (\n renderingMode === undefined\n || outputs === undefined\n || canRun === undefined\n || sections === undefined\n || initialArgs === undefined\n )\n throw new Error(\n `Malformed config v1. SDK version ${sdkVersion}; Fields = ${fields.join(', ')}`,\n );\n return {\n configVersion: 3,\n modelAPIVersion: 1,\n sdkVersion: sdkVersion ?? 'unknown',\n renderingMode,\n initialArgs,\n outputs: Object.fromEntries(\n Object.entries(outputs).map(([key, value]) => [key, upgradeCfgOrLambda(value)]),\n ),\n inputsValid: upgradeCfgOrLambda(canRun),\n sections: upgradeCfgOrLambda(sections),\n initialUiState: undefined,\n code,\n };\n } else {\n const { sdkVersion } = cfg;\n const fields = Object.keys(cfg);\n throw new Error(\n `Config format not supported: SDK = ${sdkVersion}; Fields = ${fields.join(', ')}`,\n );\n }\n}\n"],"names":[],"mappings":"AAOA,SAAS,kBAAkB,CACzB,IAAyB,EAAA;IAEzB,IAAI,IAAI,KAAK,SAAS;AAAE,QAAA,OAAO,SAAS;IACxC,IAAI,OAAO,IAAI,KAAK,QAAQ;AAAE,QAAA,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE;AAC7F,IAAA,OAAO,IAAI;AACb;AAEA;;;;;AAKK;AACC,SAAU,oBAAoB,CAAC,GAAyB,EAAA;AAC5D,IAAA,IAAI,GAAG,CAAC,EAAE,KAAK,SAAS,EAAE;;QAExB,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,WAAW,EAAE,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,KAAK,EAAE,iBAAiB,EAAE,UAAU,EAAE,GAAG,GAAG,CAAC,EAAE;AAClJ,QAAA,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG;QACpB,OAAO;AACL,YAAA,aAAa,EAAE,CAAC;AAChB,YAAA,eAAe,EAAE,CAAC;YAClB,IAAI;YACJ,UAAU;YACV,WAAW;YACX,OAAO;YACP,aAAa;YACb,UAAU;YACV,YAAY;YACZ,QAAQ;YACR,KAAK;YACL,iBAAiB;YACjB,UAAU;YACV,IAAI;SACL;IACH;AAAO,SAAA,IAAI,GAAG,CAAC,EAAE,KAAK,SAAS,EAAE;;AAE/B,QAAA,MAAM,EACJ,WAAW,EACX,cAAc,EACd,WAAW,EACX,OAAO,EACP,aAAa,EACb,UAAU,EACV,YAAY,EACZ,QAAQ,EACR,KAAK,EACL,QAAQ,EACR,IAAI,EACJ,iBAAiB,GAClB,GAAG,G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MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA,CAAE,CAClF;IACH;AACF;;;;"}
@@ -1,17 +1,17 @@
1
1
  import type { ErrorLike } from '@milaboratories/pl-error-like';
2
2
  /** Use this as constraint instead of `Function` */
3
3
  export type AnyFunction = (...args: any[]) => any;
4
- /** Value or errors */
5
- export type ValueOrErrors<T> = {
4
+ export type OutputWithStatus<T> = {
6
5
  ok: true;
7
6
  value: T;
7
+ stable: boolean;
8
8
  } | {
9
9
  ok: false;
10
10
  errors: ErrorLike[];
11
11
  moreErrors: boolean;
12
12
  };
13
13
  /** Base type for block outputs */
14
- export type BlockOutputsBase = Record<string, ValueOrErrors<unknown>>;
14
+ export type BlockOutputsBase = Record<string, OutputWithStatus<unknown>>;
15
15
  export type ListOptionBase<T = unknown> = {
16
16
  label: string;
17
17
  description?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"common_types.d.ts","sourceRoot":"","sources":["../src/common_types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAE/D,mDAAmD;AAEnD,MAAM,MAAM,WAAW,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC;AAElD,sBAAsB;AACtB,MAAM,MAAM,aAAa,CAAC,CAAC,IACvB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,CAAC,CAAA;CAAE,GACtB;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,SAAS,EAAE,CAAC;IAAC,UAAU,EAAE,OAAO,CAAA;CAAE,CAAC;AAE5D,kCAAkC;AAClC,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC;AAEtE,MAAM,MAAM,cAAc,CAAC,CAAC,GAAG,OAAO,IAAI;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,CAAC,CAAC;IACT,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC"}
1
+ {"version":3,"file":"common_types.d.ts","sourceRoot":"","sources":["../src/common_types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAE/D,mDAAmD;AAEnD,MAAM,MAAM,WAAW,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC;AAElD,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAC1B;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,CAAC,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,GACvC;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,SAAS,EAAE,CAAC;IAAC,UAAU,EAAE,OAAO,CAAA;CAAE,CAAC;AAE5D,kCAAkC;AAClC,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC;AAEzE,MAAM,MAAM,cAAc,CAAC,CAAC,GAAG,OAAO,IAAI;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,CAAC,CAAC;IACT,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@milaboratories/pl-model-common",
3
- "version": "1.22.0",
3
+ "version": "1.24.0",
4
4
  "description": "Platforma SDK Model",
5
5
  "type": "module",
6
6
  "types": "./dist/index.d.ts",
@@ -26,10 +26,10 @@
26
26
  "typescript": "~5.6.3",
27
27
  "vitest": "^4.0.16",
28
28
  "@vitest/coverage-istanbul": "^4.0.16",
29
- "@milaboratories/build-configs": "1.2.1",
30
- "@milaboratories/ts-configs": "1.2.0",
29
+ "@milaboratories/build-configs": "1.2.2",
31
30
  "@milaboratories/eslint-config": "1.0.5",
32
- "@milaboratories/ts-builder": "1.2.1"
31
+ "@milaboratories/ts-configs": "1.2.0",
32
+ "@milaboratories/ts-builder": "1.2.2"
33
33
  },
34
34
  "scripts": {
35
35
  "type-check": "ts-builder types --target node",
@@ -31,3 +31,20 @@ export type BlockState<
31
31
 
32
32
  readonly author: AuthorMarker | undefined;
33
33
  };
34
+
35
+ export type BlockStateV3<
36
+ Outputs extends BlockOutputsBase = BlockOutputsBase,
37
+ _Data = unknown,
38
+ Href extends `/${string}` = `/${string}`,
39
+ > = {
40
+ /** Block storage persisted in the block state */
41
+ blockStorage: unknown;
42
+
43
+ /** Outputs rendered with block config */
44
+ outputs: Outputs;
45
+
46
+ /** Current navigation state */
47
+ navigationState: NavigationState<Href>;
48
+
49
+ readonly author: AuthorMarker | undefined;
50
+ };
@@ -4,6 +4,86 @@ import type { BlockCodeFeatureFlags } from '../flags';
4
4
  import type { BlockCodeWithInfo, Code } from './code';
5
5
  import type { BlockRenderingMode } from './types';
6
6
 
7
+ /**
8
+ * Descriptor for a state migration function.
9
+ * Unlike ConfigRenderLambda, migrations are not rendered reactively -
10
+ * they are one-time synchronous transformations called during block pack updates.
11
+ */
12
+ export type MigrationDescriptor = {
13
+ /** Index of this migration in the migrations callback array */
14
+ readonly index: number;
15
+ };
16
+
17
+ /**
18
+ * BroadActiveHandleDescriptor = TypedConfigOrConfigLambda,
19
+ * NarrowActiveHandleDescriptor = ConfigRenderLambda
20
+ */
21
+ export type BlockConfigV4Generic<
22
+ _Args = unknown,
23
+ _Data extends Record<string, unknown> = Record<string, unknown>,
24
+ BroadActiveHandleDescriptor = unknown,
25
+ NarrowActiveHandleDescriptor extends BroadActiveHandleDescriptor = BroadActiveHandleDescriptor,
26
+ Outputs extends Record<string, BroadActiveHandleDescriptor> = Record<string, BroadActiveHandleDescriptor>,
27
+ > = {
28
+ /** Discriminator to identify config version */
29
+ readonly configVersion: 4;
30
+
31
+ readonly modelAPIVersion: 2;
32
+
33
+ /** SDK version used by the block */
34
+ readonly sdkVersion: string;
35
+
36
+ /** Main rendering mode for the block */
37
+ readonly renderingMode: BlockRenderingMode;
38
+
39
+ /** Lambda to derive block args from state */
40
+ readonly args: NarrowActiveHandleDescriptor;
41
+
42
+ /**
43
+ * Lambda to derive prerun args from state (optional).
44
+ * If not defined, defaults to using the args() result.
45
+ * Used for staging/prerun phase.
46
+ */
47
+ readonly prerunArgs?: NarrowActiveHandleDescriptor;
48
+
49
+ /** Lambda to get initial data when block is added to the project */
50
+ readonly initialData: NarrowActiveHandleDescriptor;
51
+
52
+ /** Lambda to derive list of sections for the left overview panel */
53
+ readonly sections: NarrowActiveHandleDescriptor;
54
+
55
+ /** Lambda to derive block title */
56
+ readonly title?: NarrowActiveHandleDescriptor;
57
+
58
+ /** Lambda to derive block subtitle, shown below the title */
59
+ readonly subtitle?: NarrowActiveHandleDescriptor;
60
+
61
+ /** Lambda returning array of tags for search functionality */
62
+ readonly tags?: BroadActiveHandleDescriptor;
63
+
64
+ /**
65
+ * Lambda returning list of upstream blocks this block enriches with its exports,
66
+ * influences dependency graph construction
67
+ * */
68
+ readonly enrichmentTargets?: NarrowActiveHandleDescriptor;
69
+
70
+ /** Configuration for the output cells */
71
+ readonly outputs: Outputs;
72
+
73
+ /**
74
+ * Array of migration descriptors for state version upgrades.
75
+ * Each migration transforms state from version N to N+1.
76
+ * Migrations are NOT rendered reactively - they run synchronously during block pack updates.
77
+ */
78
+ readonly migrations?: MigrationDescriptor[];
79
+
80
+ /** Config code bundle */
81
+ readonly code?: Code;
82
+
83
+ /** Feature flags for the block Model and UI code. */
84
+ readonly featureFlags?: BlockCodeFeatureFlags;
85
+ };
86
+
7
87
  /**
8
88
  * BroadActiveHandleDescriptor = TypedConfigOrConfigLambda,
9
89
  * NarrowActiveHandleDescriptor = ConfigRenderLambda
@@ -15,6 +95,11 @@ export type BlockConfigV3Generic<
15
95
  NarrowActiveHandleDescriptor extends BroadActiveHandleDescriptor = BroadActiveHandleDescriptor,
16
96
  Outputs extends Record<string, BroadActiveHandleDescriptor> = Record<string, BroadActiveHandleDescriptor>,
17
97
  > = {
98
+ /** Discriminator to identify config version */
99
+ readonly configVersion: 3;
100
+
101
+ readonly modelAPIVersion: 1;
102
+
18
103
  /** SDK version used by the block */
19
104
  readonly sdkVersion: string;
20
105
 
@@ -63,10 +148,10 @@ export type BlockConfigV3Generic<
63
148
  readonly featureFlags?: BlockCodeFeatureFlags;
64
149
  };
65
150
 
66
- export type BlockConfigGeneric = BlockConfigV3Generic;
151
+ export type BlockConfigGeneric = BlockConfigV3Generic | BlockConfigV4Generic;
67
152
 
68
- export function extractCodeWithInfo(cfg: BlockConfigV3Generic): BlockCodeWithInfo {
69
- if (cfg.code === undefined) throw new Error('No code bundle');
153
+ export function extractCodeWithInfo(cfg: BlockConfigGeneric): BlockCodeWithInfo {
154
+ if (cfg.code === undefined) throw new Error('extractCodeWithInfo: No code bundle');
70
155
  return {
71
156
  code: cfg.code,
72
157
  sdkVersion: cfg.sdkVersion,
@@ -1,11 +1,12 @@
1
- import type { BlockConfigV3Generic } from './block_config';
1
+ import type { BlockConfigV3Generic, BlockConfigV4Generic } from './block_config';
2
2
  import type { Code } from './code';
3
3
  import type { BlockRenderingMode } from './types';
4
4
 
5
5
  /** Container simplifying maintenance of forward and backward compatibility */
6
6
  export type BlockConfigContainer = {
7
+ readonly v4?: Omit<BlockConfigV4Generic, 'code'>;
7
8
  /** Actual config */
8
- readonly v3: Omit<BlockConfigV3Generic, 'code'>;
9
+ readonly v3?: Omit<BlockConfigV3Generic, 'code'>;
9
10
 
10
11
  /** Config code bundle. Actually is required, but we keep it optional for backward compatibility */
11
12
  readonly code?: Code;
@@ -16,12 +16,32 @@ function upgradeCfgOrLambda(
16
16
  /**
17
17
  * Takes universal config, and converts it into latest config structure.
18
18
  *
19
- * **Important**: This operation is not meant to be executed recusively.
19
+ * **Important**: This operation is not meant to be executed recursively.
20
20
  * In no circumstance result of this function should be persisted!
21
21
  * */
22
22
  export function extractConfigGeneric(cfg: BlockConfigContainer): BlockConfigGeneric {
23
- if (cfg.v3 !== undefined) {
24
- // version 3
23
+ if (cfg.v4 !== undefined) {
24
+ // version 4 (BlockModelV3) - inputsValid is derived from args() success/failure
25
+ const { args, prerunArgs, initialData, outputs, renderingMode, sdkVersion, featureFlags, sections, title, enrichmentTargets, migrations } = cfg.v4;
26
+ const { code } = cfg;
27
+ return {
28
+ configVersion: 4,
29
+ modelAPIVersion: 2,
30
+ args,
31
+ prerunArgs,
32
+ initialData,
33
+ outputs,
34
+ renderingMode,
35
+ sdkVersion,
36
+ featureFlags,
37
+ sections,
38
+ title,
39
+ enrichmentTargets,
40
+ migrations,
41
+ code,
42
+ };
43
+ } else if (cfg.v3 !== undefined) {
44
+ // version 3 (BlockModel v1)
25
45
  const {
26
46
  initialArgs,
27
47
  initialUiState,
@@ -38,6 +58,8 @@ export function extractConfigGeneric(cfg: BlockConfigContainer): BlockConfigGene
38
58
  } = cfg.v3;
39
59
  const { code } = cfg;
40
60
  return {
61
+ configVersion: 3,
62
+ modelAPIVersion: 1,
41
63
  initialArgs,
42
64
  initialUiState,
43
65
  inputsValid,
@@ -53,7 +75,7 @@ export function extractConfigGeneric(cfg: BlockConfigContainer): BlockConfigGene
53
75
  enrichmentTargets,
54
76
  };
55
77
  } else if (cfg.inputsValid !== undefined) {
56
- // version 2
78
+ // version 2 (legacy) - normalize to v3 format
57
79
  const { sdkVersion, renderingMode, outputs, inputsValid, sections, initialArgs, code } = cfg;
58
80
  const fields = Object.keys(cfg);
59
81
  if (
@@ -68,6 +90,8 @@ export function extractConfigGeneric(cfg: BlockConfigContainer): BlockConfigGene
68
90
  `Malformed config v2. SDK version ${sdkVersion}; Fields = ${fields.join(', ')}`,
69
91
  );
70
92
  return {
93
+ configVersion: 3,
94
+ modelAPIVersion: 1,
71
95
  sdkVersion,
72
96
  renderingMode,
73
97
  initialArgs,
@@ -80,7 +104,7 @@ export function extractConfigGeneric(cfg: BlockConfigContainer): BlockConfigGene
80
104
  code,
81
105
  };
82
106
  } else if (cfg.renderingMode !== undefined) {
83
- // version 1
107
+ // version 1 (legacy) - normalize to v3 format
84
108
  const { sdkVersion, canRun, renderingMode, outputs, sections, initialArgs, code } = cfg;
85
109
  const fields = Object.keys(cfg);
86
110
  if (
@@ -94,6 +118,8 @@ export function extractConfigGeneric(cfg: BlockConfigContainer): BlockConfigGene
94
118
  `Malformed config v1. SDK version ${sdkVersion}; Fields = ${fields.join(', ')}`,
95
119
  );
96
120
  return {
121
+ configVersion: 3,
122
+ modelAPIVersion: 1,
97
123
  sdkVersion: sdkVersion ?? 'unknown',
98
124
  renderingMode,
99
125
  initialArgs,
@@ -4,13 +4,12 @@ import type { ErrorLike } from '@milaboratories/pl-error-like';
4
4
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
5
5
  export type AnyFunction = (...args: any[]) => any;
6
6
 
7
- /** Value or errors */
8
- export type ValueOrErrors<T> =
9
- | { ok: true; value: T }
7
+ export type OutputWithStatus<T> =
8
+ | { ok: true; value: T; stable: boolean }
10
9
  | { ok: false; errors: ErrorLike[]; moreErrors: boolean };
11
10
 
12
11
  /** Base type for block outputs */
13
- export type BlockOutputsBase = Record<string, ValueOrErrors<unknown>>;
12
+ export type BlockOutputsBase = Record<string, OutputWithStatus<unknown>>;
14
13
 
15
14
  export type ListOptionBase<T = unknown> = {
16
15
  label: string;