@milaboratories/pl-model-common 1.24.11 → 1.25.1

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,6 +1,7 @@
1
1
  import type { BlockOutputsBase } from "./common_types";
2
2
  import type { NavigationState } from "./navigation";
3
3
  import type { AuthorMarker } from "./author_marker";
4
+ import { StringifiedJson } from "./json";
4
5
  /**
5
6
  * @template Args sets type of block arguments passed to the workflow
6
7
  * @template Outputs type of the outputs returned by the workflow and rendered
@@ -21,9 +22,9 @@ export type BlockState<Args = unknown, Outputs extends BlockOutputsBase = BlockO
21
22
  navigationState: NavigationState<Href>;
22
23
  readonly author: AuthorMarker | undefined;
23
24
  };
24
- export type BlockStateV3<Outputs extends BlockOutputsBase = BlockOutputsBase, _Data = unknown, Href extends `/${string}` = `/${string}`> = {
25
+ export type BlockStateV3<_Data = unknown, Outputs extends BlockOutputsBase = BlockOutputsBase, Href extends `/${string}` = `/${string}`> = {
25
26
  /** Block storage persisted in the block state */
26
- blockStorage: unknown;
27
+ blockStorage: StringifiedJson;
27
28
  /** Outputs rendered with block config */
28
29
  outputs: Outputs;
29
30
  /** Current navigation state */
@@ -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;IA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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,KAAK,GAAG,OAAO,EACf,OAAO,SAAS,gBAAgB,GAAG,gBAAgB,EACnD,IAAI,SAAS,IAAI,MAAM,EAAE,GAAG,IAAI,MAAM,EAAE,IACtC;IACF,iDAAiD;IACjD,YAAY,EAAE,eAAe,CAAC;IAE9B,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 +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 * 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<\n string,\n BroadActiveHandleDescriptor\n >,\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<\n string,\n BroadActiveHandleDescriptor\n >,\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;AA8JM,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
+ {"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 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<\n string,\n BroadActiveHandleDescriptor\n >,\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 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 /** Config code bundle */\n readonly code?: Code;\n\n /** Feature flags for the block Model and UI code. */\n readonly featureFlags?: BlockCodeFeatureFlags;\n\n /** Facade callbacks supported by this block (for pre-execution validation) */\n readonly blockLifecycleCallbacks: Record<string, NarrowActiveHandleDescriptor>;\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<\n string,\n BroadActiveHandleDescriptor\n >,\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;AAmIM,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,15 +1,6 @@
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
4
  /**
14
5
  * BroadActiveHandleDescriptor = TypedConfigOrConfigLambda,
15
6
  * NarrowActiveHandleDescriptor = ConfigRenderLambda
@@ -22,16 +13,6 @@ export type BlockConfigV4Generic<_Args = unknown, _Data extends Record<string, u
22
13
  readonly sdkVersion: string;
23
14
  /** Main rendering mode for the block */
24
15
  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
16
  /** Lambda to derive list of sections for the left overview panel */
36
17
  readonly sections: NarrowActiveHandleDescriptor;
37
18
  /** Lambda to derive block title */
@@ -47,16 +28,12 @@ export type BlockConfigV4Generic<_Args = unknown, _Data extends Record<string, u
47
28
  readonly enrichmentTargets?: NarrowActiveHandleDescriptor;
48
29
  /** Configuration for the output cells */
49
30
  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
31
  /** Config code bundle */
57
32
  readonly code?: Code;
58
33
  /** Feature flags for the block Model and UI code. */
59
34
  readonly featureFlags?: BlockCodeFeatureFlags;
35
+ /** Facade callbacks supported by this block (for pre-execution validation) */
36
+ readonly blockLifecycleCallbacks: Record<string, NarrowActiveHandleDescriptor>;
60
37
  };
61
38
  /**
62
39
  * BroadActiveHandleDescriptor = TypedConfigOrConfigLambda,
@@ -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,UAAU,CAAC;AACtD,OAAO,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AACtD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAElD;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,+DAA+D;IAC/D,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,oBAAoB,CAC9B,KAAK,GAAG,OAAO,EACf,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/D,2BAA2B,GAAG,OAAO,EACrC,4BAA4B,SAAS,2BAA2B,GAAG,2BAA2B,EAC9F,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,2BAA2B,CAAC,GAAG,MAAM,CAClE,MAAM,EACN,2BAA2B,CAC5B,IACC;IACF,+CAA+C;IAC/C,QAAQ,CAAC,aAAa,EAAE,CAAC,CAAC;IAE1B,QAAQ,CAAC,eAAe,EAAE,CAAC,CAAC;IAE5B,oCAAoC;IACpC,QAAQ,CAAC,U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oBAAoB,GAAG,oBAAoB,CAAC;AAE7E,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,kBAAkB,GAAG,iBAAiB,CAO9E"}
@@ -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 * 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<\n string,\n BroadActiveHandleDescriptor\n >,\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<\n string,\n BroadActiveHandleDescriptor\n >,\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;AA8JM,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
+ {"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 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<\n string,\n BroadActiveHandleDescriptor\n >,\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 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 /** Config code bundle */\n readonly code?: Code;\n\n /** Feature flags for the block Model and UI code. */\n readonly featureFlags?: BlockCodeFeatureFlags;\n\n /** Facade callbacks supported by this block (for pre-execution validation) */\n readonly blockLifecycleCallbacks: Record<string, NarrowActiveHandleDescriptor>;\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<\n string,\n BroadActiveHandleDescriptor\n >,\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;AAmIM,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;;;;"}
@@ -16,22 +16,21 @@ function upgradeCfgOrLambda(data) {
16
16
  function extractConfigGeneric(cfg) {
17
17
  if (cfg.v4 !== undefined) {
18
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;
19
+ const { outputs, renderingMode, sdkVersion, featureFlags, sections, title, subtitle, tags, enrichmentTargets, blockLifecycleCallbacks = {}, } = cfg.v4;
20
20
  const { code } = cfg;
21
21
  return {
22
22
  configVersion: 4,
23
23
  modelAPIVersion: 2,
24
- args,
25
- prerunArgs,
26
- initialData,
27
24
  outputs,
28
25
  renderingMode,
29
26
  sdkVersion,
30
27
  featureFlags,
31
28
  sections,
32
29
  title,
30
+ subtitle,
31
+ tags,
33
32
  enrichmentTargets,
34
- migrations,
33
+ blockLifecycleCallbacks,
35
34
  code,
36
35
  };
37
36
  }
@@ -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(data: unknown | undefined): unknown | undefined;\nfunction upgradeCfgOrLambda(data: unknown | undefined): 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 {\n args,\n prerunArgs,\n initialData,\n outputs,\n renderingMode,\n sdkVersion,\n featureFlags,\n sections,\n title,\n enrichmentTargets,\n migrations,\n } = 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":";;AAKA,SAAS,kBAAkB,CAAC,IAAyB,EAAA;IACnD,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,EACJ,IAAI,EACJ,UAAU,EACV,WAAW,EACX,OAAO,EACP,aAAa,EACb,UAAU,EACV,YAAY,EACZ,QAAQ,EACR,KAAK,EACL,iBAAiB,EACjB,UAAU,GACX,GAAG,GAAG,CAAC,EAAE;AACV,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,GAAG,CAAC,EAAE;A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AAA,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(data: unknown | undefined): unknown | undefined;\nfunction upgradeCfgOrLambda(data: unknown | undefined): 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 {\n outputs,\n renderingMode,\n sdkVersion,\n featureFlags,\n sections,\n title,\n subtitle,\n tags,\n enrichmentTargets,\n blockLifecycleCallbacks = {},\n } = cfg.v4;\n const { code } = cfg;\n return {\n configVersion: 4,\n modelAPIVersion: 2,\n outputs,\n renderingMode,\n sdkVersion,\n featureFlags,\n sections,\n title,\n subtitle,\n tags,\n enrichmentTargets,\n blockLifecycleCallbacks,\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":";;AAKA,SAAS,kBAAkB,CAAC,IAAyB,EAAA;IACnD,IAAI,IAAI,KAAK,SAAS;AAAE,QAAA,OAAO,SAAS;IACxC,IAAI,OAAO,IAAI,KA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AAM,aAAa,CAAC;AAUxD;;;;;KAKK;AACL,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,oBAAoB,GAAG,kBAAkB,CAmIlF"}
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;AAUxD;;;;;KAKK;AACL,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,oBAAoB,GAAG,kBAAkB,CAiIlF"}
@@ -14,22 +14,21 @@ function upgradeCfgOrLambda(data) {
14
14
  function extractConfigGeneric(cfg) {
15
15
  if (cfg.v4 !== undefined) {
16
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;
17
+ const { outputs, renderingMode, sdkVersion, featureFlags, sections, title, subtitle, tags, enrichmentTargets, blockLifecycleCallbacks = {}, } = cfg.v4;
18
18
  const { code } = cfg;
19
19
  return {
20
20
  configVersion: 4,
21
21
  modelAPIVersion: 2,
22
- args,
23
- prerunArgs,
24
- initialData,
25
22
  outputs,
26
23
  renderingMode,
27
24
  sdkVersion,
28
25
  featureFlags,
29
26
  sections,
30
27
  title,
28
+ subtitle,
29
+ tags,
31
30
  enrichmentTargets,
32
- migrations,
31
+ blockLifecycleCallbacks,
33
32
  code,
34
33
  };
35
34
  }
@@ -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(data: unknown | undefined): unknown | undefined;\nfunction upgradeCfgOrLambda(data: unknown | undefined): 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 {\n args,\n prerunArgs,\n initialData,\n outputs,\n renderingMode,\n sdkVersion,\n featureFlags,\n sections,\n title,\n enrichmentTargets,\n migrations,\n } = 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":"AAKA,SAAS,kBAAkB,CAAC,IAAyB,EAAA;IACnD,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,EACJ,IAAI,EACJ,UAAU,EACV,WAAW,EACX,OAAO,EACP,aAAa,EACb,UAAU,EACV,YAAY,EACZ,QAAQ,EACR,KAAK,EACL,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,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.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(data: unknown | undefined): unknown | undefined;\nfunction upgradeCfgOrLambda(data: unknown | undefined): 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 {\n outputs,\n renderingMode,\n sdkVersion,\n featureFlags,\n sections,\n title,\n subtitle,\n tags,\n enrichmentTargets,\n blockLifecycleCallbacks = {},\n } = cfg.v4;\n const { code } = cfg;\n return {\n configVersion: 4,\n modelAPIVersion: 2,\n outputs,\n renderingMode,\n sdkVersion,\n featureFlags,\n sections,\n title,\n subtitle,\n tags,\n enrichmentTargets,\n blockLifecycleCallbacks,\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":"AAKA,SAAS,kBAAkB,CAAC,IAAyB,EAAA;IACnD,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,EACJ,OAAO,EACP,aAAa,EACb,UAAU,EACV,YAAY,EACZ,QAAQ,EACR,KAAK,EACL,QAAQ,EACR,IAAI,EACJ,iBAAiB,EACjB,uBAAuB,GAAG,EAAE,GAC7B,GAAG,GAAG,CAAC,EAAE;AACV,QAAA,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG;QACpB,OAAO;AACL,YAAA,aAAa,EAAE,CAAC;AAChB,YAAA,eAAe,EAAE,CAAC;YAClB,OAAO;YACP,aAAa;YACb,UAAU;YACV,YAAY;YACZ,QAAQ;YACR,KAAK;YACL,QAAQ;YACR,IAAI;YACJ,iBAAiB;YACjB,uBAAuB;YACvB,IAAI;S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C,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 @@
3
3
  const AllSupportsFeatureFlags = ["supportsLazyState"];
4
4
  const AllRequiresFeatureFlags = [
5
5
  "requiresUIAPIVersion",
6
- "requiresCreatePTableV2",
6
+ "requiresCreatePTable",
7
7
  "requiresModelAPIVersion",
8
8
  ];
9
9
 
@@ -1 +1 @@
1
- {"version":3,"file":"block_flags.cjs","sources":["../../src/flags/block_flags.ts"],"sourcesContent":["import type { ArrayTypeUnion, Assert, Is, IsSubtypeOf } from \"./type_utils\";\n\n/**\n * Block-specific feature flags. Define flags that are interpreted by the desktop app to select\n * appropriate API to expose into Model and UI runtimes.\n *\n * Flags are split into two categories:\n * - supports... - those flags tells the desktop app that the block supports certain APIs, but can without them as well\n * - requires... - those flags tells the desktop app that the block requires certain APIs, and if desktop app doesn't support it, it can't be used in the block\n */\nexport type BlockCodeFeatureFlags = Record<`supports${string}`, boolean | number | undefined> &\n Record<`requires${string}`, boolean | number | undefined>;\n\n/**\n * Known block flags. Flags are set during model compilation, see `BlockModel.create` for more details and for initial values.\n */\nexport type BlockCodeKnownFeatureFlags = {\n readonly supportsLazyState?: boolean;\n readonly requiresModelAPIVersion?: number;\n readonly requiresUIAPIVersion?: number;\n readonly requiresCreatePTableV2?: boolean;\n};\n\nexport const AllSupportsFeatureFlags = [\"supportsLazyState\"] as const;\n\nexport const AllRequiresFeatureFlags = [\n \"requiresUIAPIVersion\",\n \"requiresCreatePTableV2\",\n \"requiresModelAPIVersion\",\n] as const;\n\n//\n// Assertions\n//\n\n// This assertion ensures that BlockConfigV3KnownFeatureFlags is a subtype of BlockConfigV3FeatureFlags.\n// It will produce a compile-time error if there's a mismatch.\ntype _KnownFlagsAreValidFlags = Assert<\n IsSubtypeOf<BlockCodeKnownFeatureFlags, BlockCodeFeatureFlags>\n>;\n\n// This check ensures that all keys in BlockConfigV3FeatureFlags are covered in the arrays above.\n// It will produce a compile-time error if there's a mismatch.\ntype _AllFlagsAreCovered = Assert<\n Is<\n keyof BlockCodeKnownFeatureFlags,\n ArrayTypeUnion<typeof AllRequiresFeatureFlags, typeof AllSupportsFeatureFlags>\n >\n>;\n"],"names":[],"mappings":";;AAuBO,MAAM,uBAAuB,GAAG,CAAC,mBAAmB;AAEpD,MAAM,uBAAuB,GAAG;IACrC,sBAAsB;IACtB,wBAAwB;IACxB,yBAAyB;;;;;;"}
1
+ {"version":3,"file":"block_flags.cjs","sources":["../../src/flags/block_flags.ts"],"sourcesContent":["import type { ArrayTypeUnion, Assert, Is, IsSubtypeOf } from \"./type_utils\";\n\n/**\n * Block-specific feature flags. Define flags that are interpreted by the desktop app to select\n * appropriate API to expose into Model and UI runtimes.\n *\n * Flags are split into two categories:\n * - supports... - those flags tells the desktop app that the block supports certain APIs, but can without them as well\n * - requires... - those flags tells the desktop app that the block requires certain APIs, and if desktop app doesn't support it, it can't be used in the block\n */\nexport type BlockCodeFeatureFlags = Record<`supports${string}`, boolean | number | undefined> &\n Record<`requires${string}`, boolean | number | undefined>;\n\n/**\n * Known block flags. Flags are set during model compilation, see `BlockModel.create` for more details and for initial values.\n */\nexport type BlockCodeKnownFeatureFlags = {\n readonly supportsLazyState?: boolean;\n readonly requiresModelAPIVersion?: number;\n readonly requiresUIAPIVersion?: number;\n readonly requiresCreatePTable?: number;\n};\n\nexport const AllSupportsFeatureFlags = [\"supportsLazyState\"] as const;\n\nexport const AllRequiresFeatureFlags = [\n \"requiresUIAPIVersion\",\n \"requiresCreatePTable\",\n \"requiresModelAPIVersion\",\n] as const;\n\n//\n// Assertions\n//\n\n// This assertion ensures that BlockConfigV3KnownFeatureFlags is a subtype of BlockConfigV3FeatureFlags.\n// It will produce a compile-time error if there's a mismatch.\ntype _KnownFlagsAreValidFlags = Assert<\n IsSubtypeOf<BlockCodeKnownFeatureFlags, BlockCodeFeatureFlags>\n>;\n\n// This check ensures that all keys in BlockConfigV3FeatureFlags are covered in the arrays above.\n// It will produce a compile-time error if there's a mismatch.\ntype _AllFlagsAreCovered = Assert<\n Is<\n keyof BlockCodeKnownFeatureFlags,\n ArrayTypeUnion<typeof AllRequiresFeatureFlags, typeof AllSupportsFeatureFlags>\n >\n>;\n"],"names":[],"mappings":";;AAuBO,MAAM,uBAAuB,GAAG,CAAC,mBAAmB;AAEpD,MAAM,uBAAuB,GAAG;IACrC,sBAAsB;IACtB,sBAAsB;IACtB,yBAAyB;;;;;;"}
@@ -14,8 +14,8 @@ export type BlockCodeKnownFeatureFlags = {
14
14
  readonly supportsLazyState?: boolean;
15
15
  readonly requiresModelAPIVersion?: number;
16
16
  readonly requiresUIAPIVersion?: number;
17
- readonly requiresCreatePTableV2?: boolean;
17
+ readonly requiresCreatePTable?: number;
18
18
  };
19
19
  export declare const AllSupportsFeatureFlags: readonly ["supportsLazyState"];
20
- export declare const AllRequiresFeatureFlags: readonly ["requiresUIAPIVersion", "requiresCreatePTableV2", "requiresModelAPIVersion"];
20
+ export declare const AllRequiresFeatureFlags: readonly ["requiresUIAPIVersion", "requiresCreatePTable", "requiresModelAPIVersion"];
21
21
  //# sourceMappingURL=block_flags.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"block_flags.d.ts","sourceRoot":"","sources":["../../src/flags/block_flags.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,MAAM,MAAM,qBAAqB,GAAG,MAAM,CAAC,WAAW,MAAM,EAAE,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC,GAC3F,MAAM,CAAC,WAAW,MAAM,EAAE,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC,CAAC;AAE5D;;GAEG;AACH,MAAM,MAAM,0BAA0B,GAAG;IACvC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,OAAO,CAAC;IACrC,QAAQ,CAAC,uBAAuB,CAAC,EAAE,MAAM,CAAC;IAC1C,QAAQ,CAAC,oBAAoB,CAAC,EAAE,MAAM,CAAC;IACvC,QAAQ,CAAC,sBAAsB,CAAC,EAAE,OAAO,CAAC;CAC3C,CAAC;AAEF,eAAO,MAAM,uBAAuB,gCAAiC,CAAC;AAEtE,eAAO,MAAM,uBAAuB,wFAI1B,CAAC"}
1
+ {"version":3,"file":"block_flags.d.ts","sourceRoot":"","sources":["../../src/flags/block_flags.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,MAAM,MAAM,qBAAqB,GAAG,MAAM,CAAC,WAAW,MAAM,EAAE,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC,GAC3F,MAAM,CAAC,WAAW,MAAM,EAAE,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC,CAAC;AAE5D;;GAEG;AACH,MAAM,MAAM,0BAA0B,GAAG;IACvC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,OAAO,CAAC;IACrC,QAAQ,CAAC,uBAAuB,CAAC,EAAE,MAAM,CAAC;IAC1C,QAAQ,CAAC,oBAAoB,CAAC,EAAE,MAAM,CAAC;IACvC,QAAQ,CAAC,oBAAoB,CAAC,EAAE,MAAM,CAAC;CACxC,CAAC;AAEF,eAAO,MAAM,uBAAuB,gCAAiC,CAAC;AAEtE,eAAO,MAAM,uBAAuB,sFAI1B,CAAC"}
@@ -1,7 +1,7 @@
1
1
  const AllSupportsFeatureFlags = ["supportsLazyState"];
2
2
  const AllRequiresFeatureFlags = [
3
3
  "requiresUIAPIVersion",
4
- "requiresCreatePTableV2",
4
+ "requiresCreatePTable",
5
5
  "requiresModelAPIVersion",
6
6
  ];
7
7
 
@@ -1 +1 @@
1
- {"version":3,"file":"block_flags.js","sources":["../../src/flags/block_flags.ts"],"sourcesContent":["import type { ArrayTypeUnion, Assert, Is, IsSubtypeOf } from \"./type_utils\";\n\n/**\n * Block-specific feature flags. Define flags that are interpreted by the desktop app to select\n * appropriate API to expose into Model and UI runtimes.\n *\n * Flags are split into two categories:\n * - supports... - those flags tells the desktop app that the block supports certain APIs, but can without them as well\n * - requires... - those flags tells the desktop app that the block requires certain APIs, and if desktop app doesn't support it, it can't be used in the block\n */\nexport type BlockCodeFeatureFlags = Record<`supports${string}`, boolean | number | undefined> &\n Record<`requires${string}`, boolean | number | undefined>;\n\n/**\n * Known block flags. Flags are set during model compilation, see `BlockModel.create` for more details and for initial values.\n */\nexport type BlockCodeKnownFeatureFlags = {\n readonly supportsLazyState?: boolean;\n readonly requiresModelAPIVersion?: number;\n readonly requiresUIAPIVersion?: number;\n readonly requiresCreatePTableV2?: boolean;\n};\n\nexport const AllSupportsFeatureFlags = [\"supportsLazyState\"] as const;\n\nexport const AllRequiresFeatureFlags = [\n \"requiresUIAPIVersion\",\n \"requiresCreatePTableV2\",\n \"requiresModelAPIVersion\",\n] as const;\n\n//\n// Assertions\n//\n\n// This assertion ensures that BlockConfigV3KnownFeatureFlags is a subtype of BlockConfigV3FeatureFlags.\n// It will produce a compile-time error if there's a mismatch.\ntype _KnownFlagsAreValidFlags = Assert<\n IsSubtypeOf<BlockCodeKnownFeatureFlags, BlockCodeFeatureFlags>\n>;\n\n// This check ensures that all keys in BlockConfigV3FeatureFlags are covered in the arrays above.\n// It will produce a compile-time error if there's a mismatch.\ntype _AllFlagsAreCovered = Assert<\n Is<\n keyof BlockCodeKnownFeatureFlags,\n ArrayTypeUnion<typeof AllRequiresFeatureFlags, typeof AllSupportsFeatureFlags>\n >\n>;\n"],"names":[],"mappings":"AAuBO,MAAM,uBAAuB,GAAG,CAAC,mBAAmB;AAEpD,MAAM,uBAAuB,GAAG;IACrC,sBAAsB;IACtB,wBAAwB;IACxB,yBAAyB;;;;;"}
1
+ {"version":3,"file":"block_flags.js","sources":["../../src/flags/block_flags.ts"],"sourcesContent":["import type { ArrayTypeUnion, Assert, Is, IsSubtypeOf } from \"./type_utils\";\n\n/**\n * Block-specific feature flags. Define flags that are interpreted by the desktop app to select\n * appropriate API to expose into Model and UI runtimes.\n *\n * Flags are split into two categories:\n * - supports... - those flags tells the desktop app that the block supports certain APIs, but can without them as well\n * - requires... - those flags tells the desktop app that the block requires certain APIs, and if desktop app doesn't support it, it can't be used in the block\n */\nexport type BlockCodeFeatureFlags = Record<`supports${string}`, boolean | number | undefined> &\n Record<`requires${string}`, boolean | number | undefined>;\n\n/**\n * Known block flags. Flags are set during model compilation, see `BlockModel.create` for more details and for initial values.\n */\nexport type BlockCodeKnownFeatureFlags = {\n readonly supportsLazyState?: boolean;\n readonly requiresModelAPIVersion?: number;\n readonly requiresUIAPIVersion?: number;\n readonly requiresCreatePTable?: number;\n};\n\nexport const AllSupportsFeatureFlags = [\"supportsLazyState\"] as const;\n\nexport const AllRequiresFeatureFlags = [\n \"requiresUIAPIVersion\",\n \"requiresCreatePTable\",\n \"requiresModelAPIVersion\",\n] as const;\n\n//\n// Assertions\n//\n\n// This assertion ensures that BlockConfigV3KnownFeatureFlags is a subtype of BlockConfigV3FeatureFlags.\n// It will produce a compile-time error if there's a mismatch.\ntype _KnownFlagsAreValidFlags = Assert<\n IsSubtypeOf<BlockCodeKnownFeatureFlags, BlockCodeFeatureFlags>\n>;\n\n// This check ensures that all keys in BlockConfigV3FeatureFlags are covered in the arrays above.\n// It will produce a compile-time error if there's a mismatch.\ntype _AllFlagsAreCovered = Assert<\n Is<\n keyof BlockCodeKnownFeatureFlags,\n ArrayTypeUnion<typeof AllRequiresFeatureFlags, typeof AllSupportsFeatureFlags>\n >\n>;\n"],"names":[],"mappings":"AAuBO,MAAM,uBAAuB,GAAG,CAAC,mBAAmB;AAEpD,MAAM,uBAAuB,GAAG;IACrC,sBAAsB;IACtB,sBAAsB;IACtB,yBAAyB;;;;;"}
@@ -29,6 +29,26 @@ function extractAllSupports(flags) {
29
29
  .filter(([key, value]) => key.startsWith("supports") && value === true)
30
30
  .map(([key]) => key));
31
31
  }
32
+ /**
33
+ * Merges two feature flag objects with type-aware logic:
34
+ * - `supports*` (boolean): OR — `true` if either side is `true`
35
+ * - `requires*` (numeric): MAX — take the higher version requirement
36
+ */
37
+ function mergeFeatureFlags(base, override) {
38
+ const result = { ...base };
39
+ for (const [key, value] of Object.entries(override)) {
40
+ if (value === undefined)
41
+ continue;
42
+ const existing = result[key];
43
+ if (typeof value === "boolean") {
44
+ result[key] = existing || value;
45
+ }
46
+ else if (typeof value === "number") {
47
+ result[key] = Math.max(existing ?? 0, value);
48
+ }
49
+ }
50
+ return result;
51
+ }
32
52
  class IncompatibleFlagsError extends Error {
33
53
  incompatibleFlags;
34
54
  name = "IncompatibleFlagsError";
@@ -99,4 +119,5 @@ exports.RuntimeCapabilities = RuntimeCapabilities;
99
119
  exports.checkBlockFlag = checkBlockFlag;
100
120
  exports.extractAllRequirements = extractAllRequirements;
101
121
  exports.extractAllSupports = extractAllSupports;
122
+ exports.mergeFeatureFlags = mergeFeatureFlags;
102
123
  //# sourceMappingURL=flag_utils.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"flag_utils.cjs","sources":["../../src/flags/flag_utils.ts"],"sourcesContent":["import type { BlockCodeFeatureFlags, BlockCodeKnownFeatureFlags } from \"./block_flags\";\nimport type { FilterKeysByPrefix } from \"./type_utils\";\n\nexport function checkBlockFlag(\n flags: BlockCodeFeatureFlags | undefined,\n flag: keyof BlockCodeKnownFeatureFlags,\n flagValue: boolean | number = true,\n): boolean {\n if (flags === undefined) return false;\n return flags[flag] === flagValue;\n}\n\n/**\n * Extracts all requirements from the feature flags.\n * @param flags - The feature flags.\n * @returns A set of requirements.\n */\nexport function extractAllRequirements(\n flags: BlockCodeFeatureFlags | undefined,\n): Set<`requires${string}`> {\n if (flags === undefined) return new Set();\n return new Set(\n Object.entries(flags)\n .filter(([key, value]) => key.startsWith(\"requires\") && value === true)\n .map(([key]) => key as `requires${string}`),\n );\n}\n\n/**\n * Extracts all supports from the feature flags.\n * @param flags - The feature flags.\n * @returns A set of supports.\n */\nexport function extractAllSupports(\n flags: BlockCodeFeatureFlags | undefined,\n): Set<`supports${string}`> {\n if (flags === undefined) return new Set();\n return new Set(\n Object.entries(flags)\n .filter(([key, value]) => key.startsWith(\"supports\") && value === true)\n .map(([key]) => key as `supports${string}`),\n );\n}\n\nexport class IncompatibleFlagsError extends Error {\n name = \"IncompatibleFlagsError\";\n constructor(public readonly incompatibleFlags: Map<`requires${string}`, number | boolean>) {\n super(\n `Some of the block requirements are not supported by the runtime: ${Array.from(\n incompatibleFlags.entries(),\n )\n .map(([key, value]) => `${key}: ${value}`)\n .join(\", \")}`,\n );\n }\n}\n\n/**\n * A type that represents a supported requirement.\n * @remarks\n * This type is used to represent a supported requirement.\n * It is a subtype of `BlockCodeKnownFeatureFlags` and is used to represent a supported requirement.\n * It is used to represent a supported requirement.\n */\nexport type SupportedRequirement = FilterKeysByPrefix<BlockCodeKnownFeatureFlags, \"requires\">;\n\nexport class RuntimeCapabilities {\n private readonly supportedRequirements: Map<`requires${string}`, Set<number | boolean>> =\n new Map();\n\n /**\n * Adds a supported requirement to the runtime capabilities.\n * @param requirement - The requirement.\n * @param value - The value of the requirement. If not provided, defaults to true.\n */\n public addSupportedRequirement(\n requirement: SupportedRequirement,\n value: number | boolean = true,\n ): this {\n if (!this.supportedRequirements.has(requirement)) {\n this.supportedRequirements.set(requirement, new Set());\n }\n this.supportedRequirements.get(requirement)!.add(value);\n return this;\n }\n\n /**\n * Returns a map of incompatible flags. If the block flags are compatible, returns undefined.\n * @param blockFlags - The block flags.\n * @returns A map of incompatible flags, or undefined if the block flags are compatible.\n */\n public getIncompatibleFlags(\n blockFlags: BlockCodeFeatureFlags | undefined,\n ): Map<`requires${string}`, number | boolean> | undefined {\n if (blockFlags === undefined) return undefined;\n const incompatibleFlags = new Map<`requires${string}`, number | boolean>();\n for (const [key, value] of Object.entries(blockFlags)) {\n if (key.startsWith(\"requires\")) {\n if (value === undefined) continue;\n const supportedValues = this.supportedRequirements.get(key as `requires${string}`);\n if (supportedValues === undefined || !supportedValues.has(value as number | boolean)) {\n incompatibleFlags.set(key as `requires${string}`, value as number | boolean);\n }\n }\n }\n return incompatibleFlags.size === 0 ? undefined : incompatibleFlags;\n }\n\n /**\n * Checks if the block flags are compatible with the runtime capabilities.\n * @param blockFlags - The block flags.\n * @returns True if the block flags are compatible, false otherwise.\n */\n public checkCompatibility(blockFlags: BlockCodeFeatureFlags | undefined): boolean {\n return this.getIncompatibleFlags(blockFlags) === undefined;\n }\n\n /**\n * Throws an error if the block flags are incompatible with the runtime capabilities.\n * @param blockFlags - The block flags.\n * @throws IncompatibleFlagsError if the block flags are incompatible with the runtime capabilities.\n */\n public throwIfIncompatible(blockFlags: BlockCodeFeatureFlags | undefined) {\n const incompatibleFlags = this.getIncompatibleFlags(blockFlags);\n if (incompatibleFlags !== undefined) throw new IncompatibleFlagsError(incompatibleFlags);\n }\n}\n"],"names":[],"mappings":";;AAGM,SAAU,cAAc,CAC5B,KAAwC,EACxC,IAAsC,EACtC,YAA8B,IAAI,EAAA;IAElC,IAAI,KAAK,KAAK,SAAS;AAAE,QAAA,OAAO,KAAK;AACrC,IAAA,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,SAAS;AAClC;AAEA;;;;AAIG;AACG,SAAU,sBAAsB,CACpC,KAAwC,EAAA;IAExC,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,IAAI,GAAG,EAAE;IACzC,OAAO,IAAI,GAAG,CACZ,MAAM,CAAC,OAAO,CAAC,KAAK;SACjB,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,KAAK,GAAG,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,KAAK,KAAK,IAAI;SACrE,GAAG,CAAC,CAAC,CAA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GAAG,CAAC,KAAK,CAAC;AACvD,QAAA,OAAO,IAAI;IACb;AAEA;;;;AAIG;AACI,IAAA,oBAAoB,CACzB,UAA6C,EAAA;QAE7C,IAAI,UAAU,KAAK,SAAS;AAAE,YAAA,OAAO,SAAS;AAC9C,QAAA,MAAM,iBAAiB,GAAG,IAAI,GAAG,EAAyC;AAC1E,QAAA,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;AACrD,YAAA,IAAI,GAAG,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE;gBAC9B,IAAI,KAAK,KAAK,SAAS;oBAAE;gBACzB,MAAM,eAAe,GAAG,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,GAA0B,CAAC;AAClF,gBAAA,IAAI,eAAe,KAAK,SAAS,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,KAAyB,CAAC,EAAE;AACpF,oBAAA,iBAAiB,CAAC,GAAG,CAAC,GAA0B,EAAE,KAAyB,CAAC;gBAC9E;YACF;QACF;AACA,QAAA,OAAO,iBAAiB,CAAC,IAAI,KAAK,CAAC,GAAG,SAAS,GAAG,iBAAiB;IACrE;AAEA;;;;AAIG;AACI,IAAA,kBAAkB,CAAC,UAA6C,EAAA;QACrE,OAAO,IAAI,CAAC,oBAAoB,CAAC,UAAU,CAAC,KAAK,SAAS;IAC5D;AAEA;;;;AAIG;AACI,IAAA,mBAAmB,CAAC,UAA6C,EAAA;QACtE,MAAM,iBAAiB,GAAG,IAAI,CAAC,oBAAoB,CAAC,UAAU,CAAC;QAC/D,IAAI,iBAAiB,KAAK,SAAS;AAAE,YAAA,MAAM,IAAI,sBAAsB,CAAC,iBAAiB,CAAC;IAC1F;AACD;;;;;;;;"}
1
+ {"version":3,"file":"flag_utils.cjs","sources":["../../src/flags/flag_utils.ts"],"sourcesContent":["import type { BlockCodeFeatureFlags, BlockCodeKnownFeatureFlags } from \"./block_flags\";\nimport type { FilterKeysByPrefix } from \"./type_utils\";\n\nexport function checkBlockFlag(\n flags: BlockCodeFeatureFlags | undefined,\n flag: keyof BlockCodeKnownFeatureFlags,\n flagValue: boolean | number = true,\n): boolean {\n if (flags === undefined) return false;\n return flags[flag] === flagValue;\n}\n\n/**\n * Extracts all requirements from the feature flags.\n * @param flags - The feature flags.\n * @returns A set of requirements.\n */\nexport function extractAllRequirements(\n flags: BlockCodeFeatureFlags | undefined,\n): Set<`requires${string}`> {\n if (flags === undefined) return new Set();\n return new Set(\n Object.entries(flags)\n .filter(([key, value]) => key.startsWith(\"requires\") && value === true)\n .map(([key]) => key as `requires${string}`),\n );\n}\n\n/**\n * Extracts all supports from the feature flags.\n * @param flags - The feature flags.\n * @returns A set of supports.\n */\nexport function extractAllSupports(\n flags: BlockCodeFeatureFlags | undefined,\n): Set<`supports${string}`> {\n if (flags === undefined) return new Set();\n return new Set(\n Object.entries(flags)\n .filter(([key, value]) => key.startsWith(\"supports\") && value === true)\n .map(([key]) => key as `supports${string}`),\n );\n}\n\n/**\n * Merges two feature flag objects with type-aware logic:\n * - `supports*` (boolean): OR — `true` if either side is `true`\n * - `requires*` (numeric): MAX — take the higher version requirement\n */\nexport function mergeFeatureFlags(\n base: BlockCodeKnownFeatureFlags,\n override: BlockCodeKnownFeatureFlags,\n): BlockCodeKnownFeatureFlags {\n const result: Record<string, boolean | number | undefined> = { ...base };\n for (const [key, value] of Object.entries(override)) {\n if (value === undefined) continue;\n const existing = result[key];\n if (typeof value === \"boolean\") {\n result[key] = (existing as boolean | undefined) || value;\n } else if (typeof value === \"number\") {\n result[key] = Math.max((existing as number) ?? 0, value);\n }\n }\n return result as BlockCodeKnownFeatureFlags;\n}\n\nexport class IncompatibleFlagsError extends Error {\n name = \"IncompatibleFlagsError\";\n constructor(public readonly incompatibleFlags: Map<`requires${string}`, number | boolean>) {\n super(\n `Some of the block requirements are not supported by the runtime: ${Array.from(\n incompatibleFlags.entries(),\n )\n .map(([key, value]) => `${key}: ${value}`)\n .join(\", \")}`,\n );\n }\n}\n\n/**\n * A type that represents a supported requirement.\n * @remarks\n * This type is used to represent a supported requirement.\n * It is a subtype of `BlockCodeKnownFeatureFlags` and is used to represent a supported requirement.\n * It is used to represent a supported requirement.\n */\nexport type SupportedRequirement = FilterKeysByPrefix<BlockCodeKnownFeatureFlags, \"requires\">;\n\nexport class RuntimeCapabilities {\n private readonly supportedRequirements: Map<`requires${string}`, Set<number | boolean>> =\n new Map();\n\n /**\n * Adds a supported requirement to the runtime capabilities.\n * @param requirement - The requirement.\n * @param value - The value of the requirement. If not provided, defaults to true.\n */\n public addSupportedRequirement(\n requirement: SupportedRequirement,\n value: number | boolean = true,\n ): this {\n if (!this.supportedRequirements.has(requirement)) {\n this.supportedRequirements.set(requirement, new Set());\n }\n this.supportedRequirements.get(requirement)!.add(value);\n return this;\n }\n\n /**\n * Returns a map of incompatible flags. If the block flags are compatible, returns undefined.\n * @param blockFlags - The block flags.\n * @returns A map of incompatible flags, or undefined if the block flags are compatible.\n */\n public getIncompatibleFlags(\n blockFlags: BlockCodeFeatureFlags | undefined,\n ): Map<`requires${string}`, number | boolean> | undefined {\n if (blockFlags === undefined) return undefined;\n const incompatibleFlags = new Map<`requires${string}`, number | boolean>();\n for (const [key, value] of Object.entries(blockFlags)) {\n if (key.startsWith(\"requires\")) {\n if (value === undefined) continue;\n const supportedValues = this.supportedRequirements.get(key as `requires${string}`);\n if (supportedValues === undefined || !supportedValues.has(value as number | boolean)) {\n incompatibleFlags.set(key as `requires${string}`, value as number | boolean);\n }\n }\n }\n return incompatibleFlags.size === 0 ? undefined : incompatibleFlags;\n }\n\n /**\n * Checks if the block flags are compatible with the runtime capabilities.\n * @param blockFlags - The block flags.\n * @returns True if the block flags are compatible, false otherwise.\n */\n public checkCompatibility(blockFlags: BlockCodeFeatureFlags | undefined): boolean {\n return this.getIncompatibleFlags(blockFlags) === undefined;\n }\n\n /**\n * Throws an error if the block flags are incompatible with the runtime capabilities.\n * @param blockFlags - The block flags.\n * @throws IncompatibleFlagsError if the block flags are incompatible with the runtime capabilities.\n */\n public throwIfIncompatible(blockFlags: BlockCodeFeatureFlags | undefined) {\n const incompatibleFlags = this.getIncompatibleFlags(blockFlags);\n if (incompatibleFlags !== undefined) throw new IncompatibleFlagsError(incompatibleFlags);\n }\n}\n"],"names":[],"mappings":";;AAGM,SAAU,cAAc,CAC5B,KAAwC,EACxC,IAAsC,EACtC,YAA8B,IAAI,EAAA;IAElC,IAAI,KAAK,KAAK,SAAS;AAAE,QAAA,OAAO,KAAK;AACrC,IAAA,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,SAAS;AAClC;AAEA;;;;AAIG;AACG,SAAU,sBAAsB,CACpC,KAAwC,EAAA;IAExC,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,IAAI,GAAG,EAAE;IACzC,OAAO,IAAI,GAAG,CACZ,MAAM,CAAC,OAAO,CAAC,KAAK;SACjB,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,KAAK,GAAG,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,KAAK,KAAK,IAAI;SACrE,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,GAA0B,CAAC,CAC9C;AACH;AAEA;;;;AAIG;AACG,SAAU,kBAAkB,CAChC,KAAwC,EAAA;IAExC,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,IAAI,GAAG,EAAE;IACzC,OAAO,IAAI,GAAG,CACZ,MAAM,CAAC,OAAO,CAAC,KAAK;SACjB,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,KAAK,GAAG,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,KAAK,KAAK,IAAI;SACrE,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,GAA0B,CAAC,CAC9C;AACH;AAEA;;;;AAIG;AACG,SAAU,iBAAiB,CAC/B,IAAgC,EAChC,QAAoC,EAAA;AAEpC,IAAA,MAAM,MAAM,GAA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
@@ -13,6 +13,12 @@ export declare function extractAllRequirements(flags: BlockCodeFeatureFlags | un
13
13
  * @returns A set of supports.
14
14
  */
15
15
  export declare function extractAllSupports(flags: BlockCodeFeatureFlags | undefined): Set<`supports${string}`>;
16
+ /**
17
+ * Merges two feature flag objects with type-aware logic:
18
+ * - `supports*` (boolean): OR — `true` if either side is `true`
19
+ * - `requires*` (numeric): MAX — take the higher version requirement
20
+ */
21
+ export declare function mergeFeatureFlags(base: BlockCodeKnownFeatureFlags, override: BlockCodeKnownFeatureFlags): BlockCodeKnownFeatureFlags;
16
22
  export declare class IncompatibleFlagsError extends Error {
17
23
  readonly incompatibleFlags: Map<`requires${string}`, number | boolean>;
18
24
  name: string;
@@ -1 +1 @@
1
- {"version":3,"file":"flag_utils.d.ts","sourceRoot":"","sources":["../../src/flags/flag_utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,0BAA0B,EAAE,MAAM,eAAe,CAAC;AACvF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAEvD,wBAAgB,cAAc,CAC5B,KAAK,EAAE,qBAAqB,GAAG,SAAS,EACxC,IAAI,EAAE,MAAM,0BAA0B,EACtC,SAAS,GAAE,OAAO,GAAG,MAAa,GACjC,OAAO,CAGT;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,qBAAqB,GAAG,SAAS,GACvC,GAAG,CAAC,WAAW,MAAM,EAAE,CAAC,CAO1B;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,qBAAqB,GAAG,SAAS,GACvC,GAAG,CAAC,WAAW,MAAM,EAAE,CAAC,CAO1B;AAED,qBAAa,sBAAuB,SAAQ,KAAK;aAEnB,iBAAiB,EAAE,GAAG,CAAC,WAAW,MAAM,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC;IADzF,IAAI,SAA4B;gBACJ,iBAAiB,EAAE,GAAG,CAAC,WAAW,M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;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,0BAA0B,EAChC,QAAQ,EAAE,0BAA0B,GACnC,0BAA0B,CAY5B;AAED,qBAAa,sBAAuB,SAAQ,KAAK;aAEnB,iBAAiB,EAAE,GAAG,CAAC,WAAW,MAAM,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC;IADzF,IAAI,SAA4B;gBACJ,iBAAiB,EAAE,GAAG,CAAC,WAAW,MAAM,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC;CAS1F;AAED;;;;;;GAMG;AACH,MAAM,MAAM,oBAAoB,GAAG,kBAAkB,CAAC,0BAA0B,EAAE,UAAU,CAAC,CAAC;AAE9F,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAC1B;IAEZ;;;;OAIG;IACI,uBAAuB,CAC5B,WAAW,EAAE,oBAAoB,EACjC,KAAK,GAAE,MAAM,GAAG,OAAc,GAC7B,IAAI;IAQP;;;;OAIG;IACI,oBAAoB,CACzB,UAAU,EAAE,qBAAqB,GAAG,SAAS,GAC5C,GAAG,CAAC,WAAW,MAAM,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,SAAS;IAezD;;;;OAIG;IACI,kBAAkB,CAAC,UAAU,EAAE,qBAAqB,GAAG,SAAS,GAAG,OAAO;IAIjF;;;;OAIG;IACI,mBAAmB,CAAC,UAAU,EAAE,qBAAqB,GAAG,SAAS;CAIzE"}
@@ -27,6 +27,26 @@ function extractAllSupports(flags) {
27
27
  .filter(([key, value]) => key.startsWith("supports") && value === true)
28
28
  .map(([key]) => key));
29
29
  }
30
+ /**
31
+ * Merges two feature flag objects with type-aware logic:
32
+ * - `supports*` (boolean): OR — `true` if either side is `true`
33
+ * - `requires*` (numeric): MAX — take the higher version requirement
34
+ */
35
+ function mergeFeatureFlags(base, override) {
36
+ const result = { ...base };
37
+ for (const [key, value] of Object.entries(override)) {
38
+ if (value === undefined)
39
+ continue;
40
+ const existing = result[key];
41
+ if (typeof value === "boolean") {
42
+ result[key] = existing || value;
43
+ }
44
+ else if (typeof value === "number") {
45
+ result[key] = Math.max(existing ?? 0, value);
46
+ }
47
+ }
48
+ return result;
49
+ }
30
50
  class IncompatibleFlagsError extends Error {
31
51
  incompatibleFlags;
32
52
  name = "IncompatibleFlagsError";
@@ -92,5 +112,5 @@ class RuntimeCapabilities {
92
112
  }
93
113
  }
94
114
 
95
- export { IncompatibleFlagsError, RuntimeCapabilities, checkBlockFlag, extractAllRequirements, extractAllSupports };
115
+ export { IncompatibleFlagsError, RuntimeCapabilities, checkBlockFlag, extractAllRequirements, extractAllSupports, mergeFeatureFlags };
96
116
  //# sourceMappingURL=flag_utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"flag_utils.js","sources":["../../src/flags/flag_utils.ts"],"sourcesContent":["import type { BlockCodeFeatureFlags, BlockCodeKnownFeatureFlags } from \"./block_flags\";\nimport type { FilterKeysByPrefix } from \"./type_utils\";\n\nexport function checkBlockFlag(\n flags: BlockCodeFeatureFlags | undefined,\n flag: keyof BlockCodeKnownFeatureFlags,\n flagValue: boolean | number = true,\n): boolean {\n if (flags === undefined) return false;\n return flags[flag] === flagValue;\n}\n\n/**\n * Extracts all requirements from the feature flags.\n * @param flags - The feature flags.\n * @returns A set of requirements.\n */\nexport function extractAllRequirements(\n flags: BlockCodeFeatureFlags | undefined,\n): Set<`requires${string}`> {\n if (flags === undefined) return new Set();\n return new Set(\n Object.entries(flags)\n .filter(([key, value]) => key.startsWith(\"requires\") && value === true)\n .map(([key]) => key as `requires${string}`),\n );\n}\n\n/**\n * Extracts all supports from the feature flags.\n * @param flags - The feature flags.\n * @returns A set of supports.\n */\nexport function extractAllSupports(\n flags: BlockCodeFeatureFlags | undefined,\n): Set<`supports${string}`> {\n if (flags === undefined) return new Set();\n return new Set(\n Object.entries(flags)\n .filter(([key, value]) => key.startsWith(\"supports\") && value === true)\n .map(([key]) => key as `supports${string}`),\n );\n}\n\nexport class IncompatibleFlagsError extends Error {\n name = \"IncompatibleFlagsError\";\n constructor(public readonly incompatibleFlags: Map<`requires${string}`, number | boolean>) {\n super(\n `Some of the block requirements are not supported by the runtime: ${Array.from(\n incompatibleFlags.entries(),\n )\n .map(([key, value]) => `${key}: ${value}`)\n .join(\", \")}`,\n );\n }\n}\n\n/**\n * A type that represents a supported requirement.\n * @remarks\n * This type is used to represent a supported requirement.\n * It is a subtype of `BlockCodeKnownFeatureFlags` and is used to represent a supported requirement.\n * It is used to represent a supported requirement.\n */\nexport type SupportedRequirement = FilterKeysByPrefix<BlockCodeKnownFeatureFlags, \"requires\">;\n\nexport class RuntimeCapabilities {\n private readonly supportedRequirements: Map<`requires${string}`, Set<number | boolean>> =\n new Map();\n\n /**\n * Adds a supported requirement to the runtime capabilities.\n * @param requirement - The requirement.\n * @param value - The value of the requirement. If not provided, defaults to true.\n */\n public addSupportedRequirement(\n requirement: SupportedRequirement,\n value: number | boolean = true,\n ): this {\n if (!this.supportedRequirements.has(requirement)) {\n this.supportedRequirements.set(requirement, new Set());\n }\n this.supportedRequirements.get(requirement)!.add(value);\n return this;\n }\n\n /**\n * Returns a map of incompatible flags. If the block flags are compatible, returns undefined.\n * @param blockFlags - The block flags.\n * @returns A map of incompatible flags, or undefined if the block flags are compatible.\n */\n public getIncompatibleFlags(\n blockFlags: BlockCodeFeatureFlags | undefined,\n ): Map<`requires${string}`, number | boolean> | undefined {\n if (blockFlags === undefined) return undefined;\n const incompatibleFlags = new Map<`requires${string}`, number | boolean>();\n for (const [key, value] of Object.entries(blockFlags)) {\n if (key.startsWith(\"requires\")) {\n if (value === undefined) continue;\n const supportedValues = this.supportedRequirements.get(key as `requires${string}`);\n if (supportedValues === undefined || !supportedValues.has(value as number | boolean)) {\n incompatibleFlags.set(key as `requires${string}`, value as number | boolean);\n }\n }\n }\n return incompatibleFlags.size === 0 ? undefined : incompatibleFlags;\n }\n\n /**\n * Checks if the block flags are compatible with the runtime capabilities.\n * @param blockFlags - The block flags.\n * @returns True if the block flags are compatible, false otherwise.\n */\n public checkCompatibility(blockFlags: BlockCodeFeatureFlags | undefined): boolean {\n return this.getIncompatibleFlags(blockFlags) === undefined;\n }\n\n /**\n * Throws an error if the block flags are incompatible with the runtime capabilities.\n * @param blockFlags - The block flags.\n * @throws IncompatibleFlagsError if the block flags are incompatible with the runtime capabilities.\n */\n public throwIfIncompatible(blockFlags: BlockCodeFeatureFlags | undefined) {\n const incompatibleFlags = this.getIncompatibleFlags(blockFlags);\n if (incompatibleFlags !== undefined) throw new IncompatibleFlagsError(incompatibleFlags);\n }\n}\n"],"names":[],"mappings":"AAGM,SAAU,cAAc,CAC5B,KAAwC,EACxC,IAAsC,EACtC,YAA8B,IAAI,EAAA;IAElC,IAAI,KAAK,KAAK,SAAS;AAAE,QAAA,OAAO,KAAK;AACrC,IAAA,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,SAAS;AAClC;AAEA;;;;AAIG;AACG,SAAU,sBAAsB,CACpC,KAAwC,EAAA;IAExC,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,IAAI,GAAG,EAAE;IACzC,OAAO,IAAI,GAAG,CACZ,MAAM,CAAC,OAAO,CAAC,KAAK;SACjB,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,KAAK,GAAG,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,KAAK,KAAK,IAAI;SACrE,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,GAA0B,CAAC,CAC9C;AACH;AAEA;;;;AAIG;AACG,SAAU,kBAAkB,CAChC,KAAwC,EAAA;IAExC,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,IAAI,GAAG,EAAE;IACzC,OAAO,IAAI,GAAG,CACZ,MAAM,CAAC,OAAO,CAAC,KAAK;SACjB,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,KAAK,GAAG,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,KAAK,KAAK,IAAI;SACrE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AC,UAAU,CAAC,UAAU,CAAC,EAAE;gBAC9B,IAAI,KAAK,KAAK,SAAS;oBAAE;gBACzB,MAAM,eAAe,GAAG,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,GAA0B,CAAC;AAClF,gBAAA,IAAI,eAAe,KAAK,SAAS,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,KAAyB,CAAC,EAAE;AACpF,oBAAA,iBAAiB,CAAC,GAAG,CAAC,GAA0B,EAAE,KAAyB,CAAC;gBAC9E;YACF;QACF;AACA,QAAA,OAAO,iBAAiB,CAAC,IAAI,KAAK,CAAC,GAAG,SAAS,GAAG,iBAAiB;IACrE;AAEA;;;;AAIG;AACI,IAAA,kBAAkB,CAAC,UAA6C,EAAA;QACrE,OAAO,IAAI,CAAC,oBAAoB,CAAC,UAAU,CAAC,KAAK,SAAS;IAC5D;AAEA;;;;AAIG;AACI,IAAA,mBAAmB,CAAC,UAA6C,EAAA;QACtE,MAAM,iBAAiB,GAAG,IAAI,CAAC,oBAAoB,CAAC,UAAU,CAAC;QAC/D,IAAI,iBAAiB,KAAK,SAAS;AAAE,YAAA,MAAM,IAAI,sBAAsB,CAAC,iBAAiB,CAAC;IAC1F;AACD;;;;"}
1
+ {"version":3,"file":"flag_utils.js","sources":["../../src/flags/flag_utils.ts"],"sourcesContent":["import type { BlockCodeFeatureFlags, BlockCodeKnownFeatureFlags } from \"./block_flags\";\nimport type { FilterKeysByPrefix } from \"./type_utils\";\n\nexport function checkBlockFlag(\n flags: BlockCodeFeatureFlags | undefined,\n flag: keyof BlockCodeKnownFeatureFlags,\n flagValue: boolean | number = true,\n): boolean {\n if (flags === undefined) return false;\n return flags[flag] === flagValue;\n}\n\n/**\n * Extracts all requirements from the feature flags.\n * @param flags - The feature flags.\n * @returns A set of requirements.\n */\nexport function extractAllRequirements(\n flags: BlockCodeFeatureFlags | undefined,\n): Set<`requires${string}`> {\n if (flags === undefined) return new Set();\n return new Set(\n Object.entries(flags)\n .filter(([key, value]) => key.startsWith(\"requires\") && value === true)\n .map(([key]) => key as `requires${string}`),\n );\n}\n\n/**\n * Extracts all supports from the feature flags.\n * @param flags - The feature flags.\n * @returns A set of supports.\n */\nexport function extractAllSupports(\n flags: BlockCodeFeatureFlags | undefined,\n): Set<`supports${string}`> {\n if (flags === undefined) return new Set();\n return new Set(\n Object.entries(flags)\n .filter(([key, value]) => key.startsWith(\"supports\") && value === true)\n .map(([key]) => key as `supports${string}`),\n );\n}\n\n/**\n * Merges two feature flag objects with type-aware logic:\n * - `supports*` (boolean): OR — `true` if either side is `true`\n * - `requires*` (numeric): MAX — take the higher version requirement\n */\nexport function mergeFeatureFlags(\n base: BlockCodeKnownFeatureFlags,\n override: BlockCodeKnownFeatureFlags,\n): BlockCodeKnownFeatureFlags {\n const result: Record<string, boolean | number | undefined> = { ...base };\n for (const [key, value] of Object.entries(override)) {\n if (value === undefined) continue;\n const existing = result[key];\n if (typeof value === \"boolean\") {\n result[key] = (existing as boolean | undefined) || value;\n } else if (typeof value === \"number\") {\n result[key] = Math.max((existing as number) ?? 0, value);\n }\n }\n return result as BlockCodeKnownFeatureFlags;\n}\n\nexport class IncompatibleFlagsError extends Error {\n name = \"IncompatibleFlagsError\";\n constructor(public readonly incompatibleFlags: Map<`requires${string}`, number | boolean>) {\n super(\n `Some of the block requirements are not supported by the runtime: ${Array.from(\n incompatibleFlags.entries(),\n )\n .map(([key, value]) => `${key}: ${value}`)\n .join(\", \")}`,\n );\n }\n}\n\n/**\n * A type that represents a supported requirement.\n * @remarks\n * This type is used to represent a supported requirement.\n * It is a subtype of `BlockCodeKnownFeatureFlags` and is used to represent a supported requirement.\n * It is used to represent a supported requirement.\n */\nexport type SupportedRequirement = FilterKeysByPrefix<BlockCodeKnownFeatureFlags, \"requires\">;\n\nexport class RuntimeCapabilities {\n private readonly supportedRequirements: Map<`requires${string}`, Set<number | boolean>> =\n new Map();\n\n /**\n * Adds a supported requirement to the runtime capabilities.\n * @param requirement - The requirement.\n * @param value - The value of the requirement. If not provided, defaults to true.\n */\n public addSupportedRequirement(\n requirement: SupportedRequirement,\n value: number | boolean = true,\n ): this {\n if (!this.supportedRequirements.has(requirement)) {\n this.supportedRequirements.set(requirement, new Set());\n }\n this.supportedRequirements.get(requirement)!.add(value);\n return this;\n }\n\n /**\n * Returns a map of incompatible flags. If the block flags are compatible, returns undefined.\n * @param blockFlags - The block flags.\n * @returns A map of incompatible flags, or undefined if the block flags are compatible.\n */\n public getIncompatibleFlags(\n blockFlags: BlockCodeFeatureFlags | undefined,\n ): Map<`requires${string}`, number | boolean> | undefined {\n if (blockFlags === undefined) return undefined;\n const incompatibleFlags = new Map<`requires${string}`, number | boolean>();\n for (const [key, value] of Object.entries(blockFlags)) {\n if (key.startsWith(\"requires\")) {\n if (value === undefined) continue;\n const supportedValues = this.supportedRequirements.get(key as `requires${string}`);\n if (supportedValues === undefined || !supportedValues.has(value as number | boolean)) {\n incompatibleFlags.set(key as `requires${string}`, value as number | boolean);\n }\n }\n }\n return incompatibleFlags.size === 0 ? undefined : incompatibleFlags;\n }\n\n /**\n * Checks if the block flags are compatible with the runtime capabilities.\n * @param blockFlags - The block flags.\n * @returns True if the block flags are compatible, false otherwise.\n */\n public checkCompatibility(blockFlags: BlockCodeFeatureFlags | undefined): boolean {\n return this.getIncompatibleFlags(blockFlags) === undefined;\n }\n\n /**\n * Throws an error if the block flags are incompatible with the runtime capabilities.\n * @param blockFlags - The block flags.\n * @throws IncompatibleFlagsError if the block flags are incompatible with the runtime capabilities.\n */\n public throwIfIncompatible(blockFlags: BlockCodeFeatureFlags | undefined) {\n const incompatibleFlags = this.getIncompatibleFlags(blockFlags);\n if (incompatibleFlags !== undefined) throw new IncompatibleFlagsError(incompatibleFlags);\n }\n}\n"],"names":[],"mappings":"AAGM,SAAU,cAAc,CAC5B,KAAwC,EACxC,IAAsC,EACtC,YAA8B,IAAI,EAAA;IAElC,IAAI,KAAK,KAAK,SAAS;AAAE,QAAA,OAAO,KAAK;AACrC,IAAA,OAA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AAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;AACrD,YAAA,IAAI,GAAG,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE;gBAC9B,IAAI,KAAK,KAAK,SAAS;oBAAE;gBACzB,MAAM,eAAe,GAAG,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,GAA0B,CAAC;AAClF,gBAAA,IAAI,eAAe,KAAK,SAAS,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,KAAyB,CAAC,EAAE;AACpF,oBAAA,iBAAiB,CAAC,GAAG,CAAC,GAA0B,EAAE,KAAyB,CAAC;gBAC9E;YACF;QACF;AACA,QAAA,OAAO,iBAAiB,CAAC,IAAI,KAAK,CAAC,GAAG,SAAS,GAAG,iBAAiB;IACrE;AAEA;;;;AAIG;AACI,IAAA,kBAAkB,CAAC,UAA6C,EAAA;QACrE,OAAO,IAAI,CAAC,oBAAoB,CAAC,UAAU,CAAC,KAAK,SAAS;IAC5D;AAEA;;;;AAIG;AACI,IAAA,mBAAmB,CAAC,UAA6C,EAAA;QACtE,MAAM,iBAAiB,GAAG,IAAI,CAAC,oBAAoB,CAAC,UAAU,CAAC;QAC/D,IAAI,iBAAiB,KAAK,SAAS;AAAE,YAAA,MAAM,IAAI,sBAAsB,CAAC,iBAAiB,CAAC;IAC1F;AACD;;;;"}
package/dist/index.cjs CHANGED
@@ -145,6 +145,7 @@ exports.RuntimeCapabilities = flag_utils.RuntimeCapabilities;
145
145
  exports.checkBlockFlag = flag_utils.checkBlockFlag;
146
146
  exports.extractAllRequirements = flag_utils.extractAllRequirements;
147
147
  exports.extractAllSupports = flag_utils.extractAllSupports;
148
+ exports.mergeFeatureFlags = flag_utils.mergeFeatureFlags;
148
149
  exports.bigintReplacer = json.bigintReplacer;
149
150
  exports.canonicalizeJson = json.canonicalizeJson;
150
151
  exports.parseJson = json.parseJson;
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/dist/index.js CHANGED
@@ -20,7 +20,7 @@ export { LinkerMap } from './drivers/pframe/linker_columns.js';
20
20
  export { ChunkedStreamReader } from './drivers/ChunkedStreamReader.js';
21
21
  export { AbortError, PFrameDriverError, PFrameError, UiError, deserializeError, deserializeResult, ensureError, hasAbortError, isAbortError, isAggregateError, isPFrameDriverError, isPFrameError, serializeError, serializeResult, unwrapResult, wrapAndSerialize, wrapAndSerializeAsync, wrapAsyncCallback, wrapCallback } from './errors.js';
22
22
  export { AllRequiresFeatureFlags, AllSupportsFeatureFlags } from './flags/block_flags.js';
23
- export { IncompatibleFlagsError, RuntimeCapabilities, checkBlockFlag, extractAllRequirements, extractAllSupports } from './flags/flag_utils.js';
23
+ export { IncompatibleFlagsError, RuntimeCapabilities, checkBlockFlag, extractAllRequirements, extractAllSupports, mergeFeatureFlags } from './flags/flag_utils.js';
24
24
  export { bigintReplacer, canonicalizeJson, parseJson, stringifyJson } from './json.js';
25
25
  export { DefaultNavigationState } from './navigation.js';
26
26
  export { PlId, PlIdBytes, PlIdLength, digestPlId, plId, uniquePlId } from './plid.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@milaboratories/pl-model-common",
3
- "version": "1.24.11",
3
+ "version": "1.25.1",
4
4
  "description": "Platforma SDK Model",
5
5
  "files": [
6
6
  "./dist/**/*",
@@ -22,12 +22,12 @@
22
22
  "@milaboratories/pl-error-like": "1.12.8"
23
23
  },
24
24
  "devDependencies": {
25
- "@vitest/coverage-istanbul": "^4.0.16",
25
+ "@vitest/coverage-istanbul": "^4.0.18",
26
26
  "typescript": "~5.6.3",
27
- "vitest": "^4.0.16",
28
- "@milaboratories/build-configs": "1.4.4",
29
- "@milaboratories/ts-builder": "1.2.10",
30
- "@milaboratories/ts-configs": "1.2.1"
27
+ "vitest": "^4.0.18",
28
+ "@milaboratories/ts-builder": "1.2.11",
29
+ "@milaboratories/ts-configs": "1.2.1",
30
+ "@milaboratories/build-configs": "1.5.0"
31
31
  },
32
32
  "scripts": {
33
33
  "build": "ts-builder build --target node",
@@ -1,6 +1,7 @@
1
1
  import type { BlockOutputsBase } from "./common_types";
2
2
  import type { NavigationState } from "./navigation";
3
3
  import type { AuthorMarker } from "./author_marker";
4
+ import { StringifiedJson } from "./json";
4
5
 
5
6
  /**
6
7
  * @template Args sets type of block arguments passed to the workflow
@@ -33,12 +34,12 @@ export type BlockState<
33
34
  };
34
35
 
35
36
  export type BlockStateV3<
36
- Outputs extends BlockOutputsBase = BlockOutputsBase,
37
37
  _Data = unknown,
38
+ Outputs extends BlockOutputsBase = BlockOutputsBase,
38
39
  Href extends `/${string}` = `/${string}`,
39
40
  > = {
40
41
  /** Block storage persisted in the block state */
41
- blockStorage: unknown;
42
+ blockStorage: StringifiedJson;
42
43
 
43
44
  /** Outputs rendered with block config */
44
45
  outputs: Outputs;
@@ -4,16 +4,6 @@ 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
7
  /**
18
8
  * BroadActiveHandleDescriptor = TypedConfigOrConfigLambda,
19
9
  * NarrowActiveHandleDescriptor = ConfigRenderLambda
@@ -39,19 +29,6 @@ export type BlockConfigV4Generic<
39
29
  /** Main rendering mode for the block */
40
30
  readonly renderingMode: BlockRenderingMode;
41
31
 
42
- /** Lambda to derive block args from state */
43
- readonly args: NarrowActiveHandleDescriptor;
44
-
45
- /**
46
- * Lambda to derive prerun args from state (optional).
47
- * If not defined, defaults to using the args() result.
48
- * Used for staging/prerun phase.
49
- */
50
- readonly prerunArgs?: NarrowActiveHandleDescriptor;
51
-
52
- /** Lambda to get initial data when block is added to the project */
53
- readonly initialData: NarrowActiveHandleDescriptor;
54
-
55
32
  /** Lambda to derive list of sections for the left overview panel */
56
33
  readonly sections: NarrowActiveHandleDescriptor;
57
34
 
@@ -73,18 +50,14 @@ export type BlockConfigV4Generic<
73
50
  /** Configuration for the output cells */
74
51
  readonly outputs: Outputs;
75
52
 
76
- /**
77
- * Array of migration descriptors for state version upgrades.
78
- * Each migration transforms state from version N to N+1.
79
- * Migrations are NOT rendered reactively - they run synchronously during block pack updates.
80
- */
81
- readonly migrations?: MigrationDescriptor[];
82
-
83
53
  /** Config code bundle */
84
54
  readonly code?: Code;
85
55
 
86
56
  /** Feature flags for the block Model and UI code. */
87
57
  readonly featureFlags?: BlockCodeFeatureFlags;
58
+
59
+ /** Facade callbacks supported by this block (for pre-execution validation) */
60
+ readonly blockLifecycleCallbacks: Record<string, NarrowActiveHandleDescriptor>;
88
61
  };
89
62
 
90
63
  /**
@@ -19,33 +19,31 @@ export function extractConfigGeneric(cfg: BlockConfigContainer): BlockConfigGene
19
19
  if (cfg.v4 !== undefined) {
20
20
  // version 4 (BlockModelV3) - inputsValid is derived from args() success/failure
21
21
  const {
22
- args,
23
- prerunArgs,
24
- initialData,
25
22
  outputs,
26
23
  renderingMode,
27
24
  sdkVersion,
28
25
  featureFlags,
29
26
  sections,
30
27
  title,
28
+ subtitle,
29
+ tags,
31
30
  enrichmentTargets,
32
- migrations,
31
+ blockLifecycleCallbacks = {},
33
32
  } = cfg.v4;
34
33
  const { code } = cfg;
35
34
  return {
36
35
  configVersion: 4,
37
36
  modelAPIVersion: 2,
38
- args,
39
- prerunArgs,
40
- initialData,
41
37
  outputs,
42
38
  renderingMode,
43
39
  sdkVersion,
44
40
  featureFlags,
45
41
  sections,
46
42
  title,
43
+ subtitle,
44
+ tags,
47
45
  enrichmentTargets,
48
- migrations,
46
+ blockLifecycleCallbacks,
49
47
  code,
50
48
  };
51
49
  } else if (cfg.v3 !== undefined) {
@@ -18,14 +18,14 @@ export type BlockCodeKnownFeatureFlags = {
18
18
  readonly supportsLazyState?: boolean;
19
19
  readonly requiresModelAPIVersion?: number;
20
20
  readonly requiresUIAPIVersion?: number;
21
- readonly requiresCreatePTableV2?: boolean;
21
+ readonly requiresCreatePTable?: number;
22
22
  };
23
23
 
24
24
  export const AllSupportsFeatureFlags = ["supportsLazyState"] as const;
25
25
 
26
26
  export const AllRequiresFeatureFlags = [
27
27
  "requiresUIAPIVersion",
28
- "requiresCreatePTableV2",
28
+ "requiresCreatePTable",
29
29
  "requiresModelAPIVersion",
30
30
  ] as const;
31
31
 
@@ -42,6 +42,28 @@ export function extractAllSupports(
42
42
  );
43
43
  }
44
44
 
45
+ /**
46
+ * Merges two feature flag objects with type-aware logic:
47
+ * - `supports*` (boolean): OR — `true` if either side is `true`
48
+ * - `requires*` (numeric): MAX — take the higher version requirement
49
+ */
50
+ export function mergeFeatureFlags(
51
+ base: BlockCodeKnownFeatureFlags,
52
+ override: BlockCodeKnownFeatureFlags,
53
+ ): BlockCodeKnownFeatureFlags {
54
+ const result: Record<string, boolean | number | undefined> = { ...base };
55
+ for (const [key, value] of Object.entries(override)) {
56
+ if (value === undefined) continue;
57
+ const existing = result[key];
58
+ if (typeof value === "boolean") {
59
+ result[key] = (existing as boolean | undefined) || value;
60
+ } else if (typeof value === "number") {
61
+ result[key] = Math.max((existing as number) ?? 0, value);
62
+ }
63
+ }
64
+ return result as BlockCodeKnownFeatureFlags;
65
+ }
66
+
45
67
  export class IncompatibleFlagsError extends Error {
46
68
  name = "IncompatibleFlagsError";
47
69
  constructor(public readonly incompatibleFlags: Map<`requires${string}`, number | boolean>) {