@platforma-sdk/model 1.42.16 → 1.42.22

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.
Files changed (222) hide show
  1. package/dist/bconfig/index.d.ts +0 -1
  2. package/dist/bconfig/lambdas.d.ts +0 -1
  3. package/dist/bconfig/normalization.cjs +19 -0
  4. package/dist/bconfig/normalization.cjs.map +1 -0
  5. package/dist/bconfig/normalization.d.ts +0 -1
  6. package/dist/bconfig/normalization.js +16 -0
  7. package/dist/bconfig/normalization.js.map +1 -0
  8. package/dist/bconfig/types.cjs +8 -0
  9. package/dist/bconfig/types.cjs.map +1 -0
  10. package/dist/bconfig/types.d.ts +0 -1
  11. package/dist/bconfig/types.js +6 -0
  12. package/dist/bconfig/types.js.map +1 -0
  13. package/dist/bconfig/util.d.ts +0 -1
  14. package/dist/bconfig/v3.d.ts +0 -1
  15. package/dist/block_api_v1.d.ts +0 -1
  16. package/dist/block_api_v2.d.ts +0 -1
  17. package/dist/block_state_patch.d.ts +0 -1
  18. package/dist/block_state_util.cjs +28 -0
  19. package/dist/block_state_util.cjs.map +1 -0
  20. package/dist/block_state_util.d.ts +0 -1
  21. package/dist/block_state_util.js +24 -0
  22. package/dist/block_state_util.js.map +1 -0
  23. package/dist/branding.d.ts +0 -1
  24. package/dist/builder.cjs +166 -0
  25. package/dist/builder.cjs.map +1 -0
  26. package/dist/builder.d.ts +0 -1
  27. package/dist/builder.js +164 -0
  28. package/dist/builder.js.map +1 -0
  29. package/dist/components/PFrameForGraphs.cjs +261 -0
  30. package/dist/components/PFrameForGraphs.cjs.map +1 -0
  31. package/dist/components/PFrameForGraphs.d.ts +0 -1
  32. package/dist/components/PFrameForGraphs.js +254 -0
  33. package/dist/components/PFrameForGraphs.js.map +1 -0
  34. package/dist/components/PlAnnotations/filter.d.ts +0 -1
  35. package/dist/components/PlAnnotations/filters_ui.cjs +556 -0
  36. package/dist/components/PlAnnotations/filters_ui.cjs.map +1 -0
  37. package/dist/components/PlAnnotations/filters_ui.d.ts +0 -1
  38. package/dist/components/PlAnnotations/filters_ui.js +548 -0
  39. package/dist/components/PlAnnotations/filters_ui.js.map +1 -0
  40. package/dist/components/PlAnnotations/index.d.ts +0 -1
  41. package/dist/components/PlAnnotations/types.d.ts +0 -1
  42. package/dist/components/PlDataTable.cjs +337 -0
  43. package/dist/components/PlDataTable.cjs.map +1 -0
  44. package/dist/components/PlDataTable.d.ts +0 -1
  45. package/dist/components/PlDataTable.js +324 -0
  46. package/dist/components/PlDataTable.js.map +1 -0
  47. package/dist/components/PlMultiSequenceAlignment.cjs +33 -0
  48. package/dist/components/PlMultiSequenceAlignment.cjs.map +1 -0
  49. package/dist/components/PlMultiSequenceAlignment.d.ts +0 -1
  50. package/dist/components/PlMultiSequenceAlignment.js +31 -0
  51. package/dist/components/PlMultiSequenceAlignment.js.map +1 -0
  52. package/dist/components/PlSelectionModel.cjs +11 -0
  53. package/dist/components/PlSelectionModel.cjs.map +1 -0
  54. package/dist/components/PlSelectionModel.d.ts +0 -1
  55. package/dist/components/PlSelectionModel.js +9 -0
  56. package/dist/components/PlSelectionModel.js.map +1 -0
  57. package/dist/components/index.d.ts +0 -1
  58. package/dist/config/actions.cjs +266 -0
  59. package/dist/config/actions.cjs.map +1 -0
  60. package/dist/config/actions.d.ts +0 -1
  61. package/dist/config/actions.js +233 -0
  62. package/dist/config/actions.js.map +1 -0
  63. package/dist/config/actions_kinds.d.ts +0 -1
  64. package/dist/config/index.d.ts +0 -1
  65. package/dist/config/model.d.ts +0 -1
  66. package/dist/config/model_meta.d.ts +0 -1
  67. package/dist/config/type_engine.d.ts +0 -1
  68. package/dist/config/type_util.d.ts +0 -1
  69. package/dist/env_value.cjs +11 -0
  70. package/dist/env_value.cjs.map +1 -0
  71. package/dist/env_value.d.ts +0 -1
  72. package/dist/env_value.js +9 -0
  73. package/dist/env_value.js.map +1 -0
  74. package/dist/global.d.ts +14 -0
  75. package/dist/index.cjs +138 -0
  76. package/dist/index.cjs.map +1 -0
  77. package/dist/index.d.ts +0 -1
  78. package/dist/index.js +26 -1
  79. package/dist/index.js.map +1 -1
  80. package/dist/internal.cjs +56 -0
  81. package/dist/internal.cjs.map +1 -0
  82. package/dist/internal.d.ts +0 -1
  83. package/dist/internal.js +49 -0
  84. package/dist/internal.js.map +1 -0
  85. package/dist/package.json.cjs +6 -0
  86. package/dist/package.json.cjs.map +1 -0
  87. package/dist/package.json.js +4 -0
  88. package/dist/package.json.js.map +1 -0
  89. package/dist/pframe.cjs +34 -0
  90. package/dist/pframe.cjs.map +1 -0
  91. package/dist/pframe.d.ts +0 -1
  92. package/dist/pframe.js +32 -0
  93. package/dist/pframe.js.map +1 -0
  94. package/dist/platforma.d.ts +0 -1
  95. package/dist/raw_globals.cjs +28 -0
  96. package/dist/raw_globals.cjs.map +1 -0
  97. package/dist/raw_globals.d.ts +0 -1
  98. package/dist/raw_globals.js +25 -0
  99. package/dist/raw_globals.js.map +1 -0
  100. package/dist/ref_util.cjs +21 -0
  101. package/dist/ref_util.cjs.map +1 -0
  102. package/dist/ref_util.d.ts +11 -12
  103. package/dist/ref_util.js +18 -0
  104. package/dist/ref_util.js.map +1 -0
  105. package/dist/render/accessor.cjs +233 -0
  106. package/dist/render/accessor.cjs.map +1 -0
  107. package/dist/render/accessor.d.ts +0 -1
  108. package/dist/render/accessor.js +230 -0
  109. package/dist/render/accessor.js.map +1 -0
  110. package/dist/render/api.cjs +514 -0
  111. package/dist/render/api.cjs.map +1 -0
  112. package/dist/render/api.d.ts +0 -1
  113. package/dist/render/api.js +511 -0
  114. package/dist/render/api.js.map +1 -0
  115. package/dist/render/future.cjs +35 -0
  116. package/dist/render/future.cjs.map +1 -0
  117. package/dist/render/future.d.ts +0 -1
  118. package/dist/render/future.js +33 -0
  119. package/dist/render/future.js.map +1 -0
  120. package/dist/render/index.d.ts +0 -1
  121. package/dist/render/internal.cjs +43 -0
  122. package/dist/render/internal.cjs.map +1 -0
  123. package/dist/render/internal.d.ts +0 -1
  124. package/dist/render/internal.js +37 -0
  125. package/dist/render/internal.js.map +1 -0
  126. package/dist/render/traversal_ops.d.ts +0 -1
  127. package/dist/render/util/axis_filtering.cjs +87 -0
  128. package/dist/render/util/axis_filtering.cjs.map +1 -0
  129. package/dist/render/util/axis_filtering.d.ts +0 -1
  130. package/dist/render/util/axis_filtering.js +85 -0
  131. package/dist/render/util/axis_filtering.js.map +1 -0
  132. package/dist/render/util/column_collection.cjs +309 -0
  133. package/dist/render/util/column_collection.cjs.map +1 -0
  134. package/dist/render/util/column_collection.d.ts +0 -1
  135. package/dist/render/util/column_collection.js +307 -0
  136. package/dist/render/util/column_collection.js.map +1 -0
  137. package/dist/render/util/index.d.ts +0 -1
  138. package/dist/render/util/label.cjs +153 -0
  139. package/dist/render/util/label.cjs.map +1 -0
  140. package/dist/render/util/label.d.ts +0 -1
  141. package/dist/render/util/label.js +149 -0
  142. package/dist/render/util/label.js.map +1 -0
  143. package/dist/render/util/pcolumn_data.cjs +342 -0
  144. package/dist/render/util/pcolumn_data.cjs.map +1 -0
  145. package/dist/render/util/pcolumn_data.d.ts +0 -1
  146. package/dist/render/util/pcolumn_data.js +330 -0
  147. package/dist/render/util/pcolumn_data.js.map +1 -0
  148. package/dist/render/util/pframe_upgraders.cjs +47 -0
  149. package/dist/render/util/pframe_upgraders.cjs.map +1 -0
  150. package/dist/render/util/pframe_upgraders.d.ts +0 -1
  151. package/dist/render/util/pframe_upgraders.js +45 -0
  152. package/dist/render/util/pframe_upgraders.js.map +1 -0
  153. package/dist/render/util/split_selectors.d.ts +0 -1
  154. package/dist/sdk_info.cjs +10 -0
  155. package/dist/sdk_info.cjs.map +1 -0
  156. package/dist/sdk_info.d.ts +0 -1
  157. package/dist/sdk_info.js +8 -0
  158. package/dist/sdk_info.js.map +1 -0
  159. package/dist/unionize.d.ts +0 -1
  160. package/dist/version.cjs +8 -0
  161. package/dist/version.cjs.map +1 -0
  162. package/dist/version.d.ts +0 -1
  163. package/dist/version.js +6 -0
  164. package/dist/version.js.map +1 -0
  165. package/package.json +16 -18
  166. package/src/components/PFrameForGraphs.test.ts +2 -2
  167. package/src/components/PlAnnotations/filters_ui.test.ts +1 -1
  168. package/src/render/util/label.test.ts +2 -2
  169. package/src/typing.test.ts +2 -1
  170. package/dist/bconfig/index.d.ts.map +0 -1
  171. package/dist/bconfig/lambdas.d.ts.map +0 -1
  172. package/dist/bconfig/normalization.d.ts.map +0 -1
  173. package/dist/bconfig/types.d.ts.map +0 -1
  174. package/dist/bconfig/util.d.ts.map +0 -1
  175. package/dist/bconfig/v3.d.ts.map +0 -1
  176. package/dist/block_api_v1.d.ts.map +0 -1
  177. package/dist/block_api_v2.d.ts.map +0 -1
  178. package/dist/block_state_patch.d.ts.map +0 -1
  179. package/dist/block_state_util.d.ts.map +0 -1
  180. package/dist/branding.d.ts.map +0 -1
  181. package/dist/builder.d.ts.map +0 -1
  182. package/dist/components/PFrameForGraphs.d.ts.map +0 -1
  183. package/dist/components/PlAnnotations/filter.d.ts.map +0 -1
  184. package/dist/components/PlAnnotations/filters_ui.d.ts.map +0 -1
  185. package/dist/components/PlAnnotations/index.d.ts.map +0 -1
  186. package/dist/components/PlAnnotations/types.d.ts.map +0 -1
  187. package/dist/components/PlDataTable.d.ts.map +0 -1
  188. package/dist/components/PlMultiSequenceAlignment.d.ts.map +0 -1
  189. package/dist/components/PlSelectionModel.d.ts.map +0 -1
  190. package/dist/components/index.d.ts.map +0 -1
  191. package/dist/config/actions.d.ts.map +0 -1
  192. package/dist/config/actions_kinds.d.ts.map +0 -1
  193. package/dist/config/index.d.ts.map +0 -1
  194. package/dist/config/model.d.ts.map +0 -1
  195. package/dist/config/model_meta.d.ts.map +0 -1
  196. package/dist/config/type_engine.d.ts.map +0 -1
  197. package/dist/config/type_util.d.ts.map +0 -1
  198. package/dist/env_value.d.ts.map +0 -1
  199. package/dist/index.d.ts.map +0 -1
  200. package/dist/index.mjs +0 -2845
  201. package/dist/index.mjs.map +0 -1
  202. package/dist/internal.d.ts.map +0 -1
  203. package/dist/pframe.d.ts.map +0 -1
  204. package/dist/platforma.d.ts.map +0 -1
  205. package/dist/raw_globals.d.ts.map +0 -1
  206. package/dist/ref_util.d.ts.map +0 -1
  207. package/dist/render/accessor.d.ts.map +0 -1
  208. package/dist/render/api.d.ts.map +0 -1
  209. package/dist/render/future.d.ts.map +0 -1
  210. package/dist/render/index.d.ts.map +0 -1
  211. package/dist/render/internal.d.ts.map +0 -1
  212. package/dist/render/traversal_ops.d.ts.map +0 -1
  213. package/dist/render/util/axis_filtering.d.ts.map +0 -1
  214. package/dist/render/util/column_collection.d.ts.map +0 -1
  215. package/dist/render/util/index.d.ts.map +0 -1
  216. package/dist/render/util/label.d.ts.map +0 -1
  217. package/dist/render/util/pcolumn_data.d.ts.map +0 -1
  218. package/dist/render/util/pframe_upgraders.d.ts.map +0 -1
  219. package/dist/render/util/split_selectors.d.ts.map +0 -1
  220. package/dist/sdk_info.d.ts.map +0 -1
  221. package/dist/unionize.d.ts.map +0 -1
  222. package/dist/version.d.ts.map +0 -1
@@ -3,4 +3,3 @@ export * from './normalization';
3
3
  export * from './util';
4
4
  export * from './v3';
5
5
  export * from './types';
6
- //# sourceMappingURL=index.d.ts.map
@@ -30,4 +30,3 @@ export interface ConfigRenderLambda<_Return = unknown> extends ConfigRenderLambd
30
30
  handle: string;
31
31
  }
32
32
  export type ExtractFunctionHandleReturn<Func extends ConfigRenderLambda> = Func extends ConfigRenderLambda<infer Return> ? Return : never;
33
- //# sourceMappingURL=lambdas.d.ts.map
@@ -0,0 +1,19 @@
1
+ 'use strict';
2
+
3
+ var plModelCommon = require('@milaboratories/pl-model-common');
4
+ var types = require('./types.cjs');
5
+
6
+ function downgradeCfgOrLambda(data) {
7
+ if (data === undefined)
8
+ return undefined;
9
+ if (types.isConfigLambda(data))
10
+ return data.handle;
11
+ return data;
12
+ }
13
+ function extractConfig(cfg) {
14
+ return plModelCommon.extractConfigGeneric(cfg);
15
+ }
16
+
17
+ exports.downgradeCfgOrLambda = downgradeCfgOrLambda;
18
+ exports.extractConfig = extractConfig;
19
+ //# sourceMappingURL=normalization.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalization.cjs","sources":["../../src/bconfig/normalization.ts"],"sourcesContent":["import { extractConfigGeneric, type BlockConfigContainer } from '@milaboratories/pl-model-common';\nimport type { TypedConfigOrConfigLambda, TypedConfigOrString } from './types';\nimport { isConfigLambda } from './types';\nimport type { BlockConfig } from './v3';\n\nexport function downgradeCfgOrLambda(data: TypedConfigOrConfigLambda): TypedConfigOrString;\nexport function downgradeCfgOrLambda(\n data: TypedConfigOrConfigLambda | undefined\n): TypedConfigOrString | undefined;\nexport function downgradeCfgOrLambda(\n data: TypedConfigOrConfigLambda | undefined,\n): TypedConfigOrString | undefined {\n if (data === undefined) return undefined;\n if (isConfigLambda(data)) return data.handle;\n return data;\n}\n\nexport function extractConfig(cfg: BlockConfigContainer): BlockConfig {\n return extractConfigGeneric(cfg) as BlockConfig;\n}\n"],"names":["isConfigLambda","extractConfigGeneric"],"mappings":";;;;;AASM,SAAU,oBAAoB,CAClC,IAA2C,EAAA;IAE3C,IAAI,IAAI,KAAK,SAAS;AAAE,QAAA,OAAO,SAAS;IACxC,IAAIA,oBAAc,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC,MAAM;AAC5C,IAAA,OAAO,IAAI;AACb;AAEM,SAAU,aAAa,CAAC,GAAyB,EAAA;AACrD,IAAA,OAAOC,kCAAoB,CAAC,GAAG,CAAgB;AACjD;;;;;"}
@@ -4,4 +4,3 @@ import { BlockConfig } from './v3';
4
4
  export declare function downgradeCfgOrLambda(data: TypedConfigOrConfigLambda): TypedConfigOrString;
5
5
  export declare function downgradeCfgOrLambda(data: TypedConfigOrConfigLambda | undefined): TypedConfigOrString | undefined;
6
6
  export declare function extractConfig(cfg: BlockConfigContainer): BlockConfig;
7
- //# sourceMappingURL=normalization.d.ts.map
@@ -0,0 +1,16 @@
1
+ import { extractConfigGeneric } from '@milaboratories/pl-model-common';
2
+ import { isConfigLambda } from './types.js';
3
+
4
+ function downgradeCfgOrLambda(data) {
5
+ if (data === undefined)
6
+ return undefined;
7
+ if (isConfigLambda(data))
8
+ return data.handle;
9
+ return data;
10
+ }
11
+ function extractConfig(cfg) {
12
+ return extractConfigGeneric(cfg);
13
+ }
14
+
15
+ export { downgradeCfgOrLambda, extractConfig };
16
+ //# sourceMappingURL=normalization.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalization.js","sources":["../../src/bconfig/normalization.ts"],"sourcesContent":["import { extractConfigGeneric, type BlockConfigContainer } from '@milaboratories/pl-model-common';\nimport type { TypedConfigOrConfigLambda, TypedConfigOrString } from './types';\nimport { isConfigLambda } from './types';\nimport type { BlockConfig } from './v3';\n\nexport function downgradeCfgOrLambda(data: TypedConfigOrConfigLambda): TypedConfigOrString;\nexport function downgradeCfgOrLambda(\n data: TypedConfigOrConfigLambda | undefined\n): TypedConfigOrString | undefined;\nexport function downgradeCfgOrLambda(\n data: TypedConfigOrConfigLambda | undefined,\n): TypedConfigOrString | undefined {\n if (data === undefined) return undefined;\n if (isConfigLambda(data)) return data.handle;\n return data;\n}\n\nexport function extractConfig(cfg: BlockConfigContainer): BlockConfig {\n return extractConfigGeneric(cfg) as BlockConfig;\n}\n"],"names":[],"mappings":";;;AASM,SAAU,oBAAoB,CAClC,IAA2C,EAAA;IAE3C,IAAI,IAAI,KAAK,SAAS;AAAE,QAAA,OAAO,SAAS;IACxC,IAAI,cAAc,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC,MAAM;AAC5C,IAAA,OAAO,IAAI;AACb;AAEM,SAAU,aAAa,CAAC,GAAyB,EAAA;AACrD,IAAA,OAAO,oBAAoB,CAAC,GAAG,CAAgB;AACjD;;;;"}
@@ -0,0 +1,8 @@
1
+ 'use strict';
2
+
3
+ function isConfigLambda(cfgOrFh) {
4
+ return cfgOrFh.__renderLambda === true;
5
+ }
6
+
7
+ exports.isConfigLambda = isConfigLambda;
8
+ //# sourceMappingURL=types.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.cjs","sources":["../../src/bconfig/types.ts"],"sourcesContent":["import type { TypedConfig } from '../config';\nimport type { ConfigRenderLambda } from './lambdas';\n\nexport function isConfigLambda(\n cfgOrFh: TypedConfigOrConfigLambda,\n): cfgOrFh is ConfigRenderLambda {\n return (cfgOrFh as any).__renderLambda === true;\n}\n\nexport type TypedConfigOrConfigLambda = TypedConfig | ConfigRenderLambda;\n\n/** @deprecated */\nexport type TypedConfigOrString = TypedConfig | string;\n"],"names":[],"mappings":";;AAGM,SAAU,cAAc,CAC5B,OAAkC,EAAA;AAElC,IAAA,OAAQ,OAAe,CAAC,cAAc,KAAK,IAAI;AACjD;;;;"}
@@ -4,4 +4,3 @@ export declare function isConfigLambda(cfgOrFh: TypedConfigOrConfigLambda): cfgO
4
4
  export type TypedConfigOrConfigLambda = TypedConfig | ConfigRenderLambda;
5
5
  /** @deprecated */
6
6
  export type TypedConfigOrString = TypedConfig | string;
7
- //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,6 @@
1
+ function isConfigLambda(cfgOrFh) {
2
+ return cfgOrFh.__renderLambda === true;
3
+ }
4
+
5
+ export { isConfigLambda };
6
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sources":["../../src/bconfig/types.ts"],"sourcesContent":["import type { TypedConfig } from '../config';\nimport type { ConfigRenderLambda } from './lambdas';\n\nexport function isConfigLambda(\n cfgOrFh: TypedConfigOrConfigLambda,\n): cfgOrFh is ConfigRenderLambda {\n return (cfgOrFh as any).__renderLambda === true;\n}\n\nexport type TypedConfigOrConfigLambda = TypedConfig | ConfigRenderLambda;\n\n/** @deprecated */\nexport type TypedConfigOrString = TypedConfig | string;\n"],"names":[],"mappings":"AAGM,SAAU,cAAc,CAC5B,OAAkC,EAAA;AAElC,IAAA,OAAQ,OAAe,CAAC,cAAc,KAAK,IAAI;AACjD;;;;"}
@@ -4,4 +4,3 @@ export type DeriveHref<S> = S extends readonly BlockSection[] ? OnlyString<Extra
4
4
  type: 'link';
5
5
  }>['href']> : never;
6
6
  export {};
7
- //# sourceMappingURL=util.d.ts.map
@@ -3,4 +3,3 @@ import { TypedConfigOrConfigLambda } from './types';
3
3
  import { ConfigRenderLambda } from './lambdas';
4
4
  export type BlockConfigV3<Args = unknown, UiState = unknown, Outputs extends Record<string, TypedConfigOrConfigLambda> = Record<string, TypedConfigOrConfigLambda>> = BlockConfigV3Generic<Args, UiState, TypedConfigOrConfigLambda, ConfigRenderLambda, Outputs>;
5
5
  export type BlockConfig = BlockConfigV3;
6
- //# sourceMappingURL=v3.d.ts.map
@@ -59,4 +59,3 @@ export interface BlockApiV1<Args = unknown, Outputs extends BlockOutputsBase = B
59
59
  * */
60
60
  setNavigationState(state: NavigationState<Href>): Promise<void>;
61
61
  }
62
- //# sourceMappingURL=block_api_v1.d.ts.map
@@ -47,4 +47,3 @@ export interface BlockApiV2<Args = unknown, Outputs extends BlockOutputsBase = B
47
47
  * */
48
48
  dispose(): Promise<ResultOrError<void>>;
49
49
  }
50
- //# sourceMappingURL=block_api_v2.d.ts.map
@@ -2,4 +2,3 @@ import { Unionize } from './unionize';
2
2
  import { BlockOutputsBase, BlockState } from '@milaboratories/pl-model-common';
3
3
  /** Patch for the BlockState, pushed by onStateUpdates method in SDK. */
4
4
  export type BlockStatePatch<Args = unknown, Outputs extends BlockOutputsBase = BlockOutputsBase, UiState = unknown, Href extends `/${string}` = `/${string}`> = Unionize<BlockState<Args, Outputs, UiState, Href>>;
5
- //# sourceMappingURL=block_state_patch.d.ts.map
@@ -0,0 +1,28 @@
1
+ 'use strict';
2
+
3
+ class OutputError extends Error {
4
+ errors;
5
+ moreErrors;
6
+ constructor(errors, moreErrors) {
7
+ super(`${errors.length}${moreErrors ? '+' : ''} errors, first error: ` + errors[0].message);
8
+ this.errors = errors;
9
+ this.moreErrors = moreErrors;
10
+ }
11
+ }
12
+ function readOutput(outputValue) {
13
+ if (!outputValue.ok)
14
+ throw new OutputError(outputValue.errors, outputValue.moreErrors);
15
+ return outputValue.value;
16
+ }
17
+ function wrapOutputs(outputs) {
18
+ return new Proxy(outputs, {
19
+ get(target, key) {
20
+ return readOutput(target[key]);
21
+ },
22
+ });
23
+ }
24
+
25
+ exports.OutputError = OutputError;
26
+ exports.readOutput = readOutput;
27
+ exports.wrapOutputs = wrapOutputs;
28
+ //# sourceMappingURL=block_state_util.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"block_state_util.cjs","sources":["../src/block_state_util.ts"],"sourcesContent":["import type { BlockOutputsBase, ValueOrErrors } from '@milaboratories/pl-model-common';\nimport type { ErrorLike } from '@milaboratories/pl-error-like';\n\nexport class OutputError extends Error {\n constructor(\n public readonly errors: ErrorLike[],\n public readonly moreErrors: boolean,\n ) {\n super(`${errors.length}${moreErrors ? '+' : ''} errors, first error: ` + errors[0].message);\n }\n}\n\nexport function readOutput<T>(outputValue: ValueOrErrors<T>): T {\n if (!outputValue.ok) throw new OutputError(outputValue.errors, outputValue.moreErrors);\n return outputValue.value;\n}\n\ntype ExtractValueType<V extends ValueOrErrors<unknown>> = Extract<V, { ok: true }>['value'];\ntype SimpleOutputs<Outputs extends BlockOutputsBase> = {\n [Key in keyof Outputs]: ExtractValueType<Outputs[Key]>;\n};\n\nexport function wrapOutputs<Outputs extends BlockOutputsBase>(\n outputs: Outputs,\n): SimpleOutputs<Outputs> {\n return new Proxy(outputs, {\n get(target, key: string) {\n return readOutput(target[key]);\n },\n }) as SimpleOutputs<Outputs>;\n}\n"],"names":[],"mappings":";;AAGM,MAAO,WAAY,SAAQ,KAAK,CAAA;AAElB,IAAA,MAAA;AACA,IAAA,UAAA;IAFlB,WAAA,CACkB,MAAmB,EACnB,UAAmB,EAAA;QAEnC,KAAK,CAAC,CAAA,EAAG,MAAM,CAAC,MAAM,GAAG,UAAU,GAAG,GAAG,GAAG,EAAE,CAAA,sBAAA,CAAwB,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;QAH3E,IAAA,CAAA,MAAM,GAAN,MAAM;QACN,IAAA,CAAA,UAAU,GAAV,UAAU;IAG5B;AACD;AAEK,SAAU,UAAU,CAAI,WAA6B,EAAA;IACzD,IAAI,CAAC,WAAW,CAAC,EAAE;QAAE,MAAM,IAAI,WAAW,CAAC,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,UAAU,CAAC;IACtF,OAAO,WAAW,CAAC,KAAK;AAC1B;AAOM,SAAU,WAAW,CACzB,OAAgB,EAAA;AAEhB,IAAA,OAAO,IAAI,KAAK,CAAC,OAAO,EAAE;QACxB,GAAG,CAAC,MAAM,EAAE,GAAW,EAAA;AACrB,YAAA,OAAO,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAChC,CAAC;AACF,KAAA,CAA2B;AAC9B;;;;;;"}
@@ -14,4 +14,3 @@ type SimpleOutputs<Outputs extends BlockOutputsBase> = {
14
14
  };
15
15
  export declare function wrapOutputs<Outputs extends BlockOutputsBase>(outputs: Outputs): SimpleOutputs<Outputs>;
16
16
  export {};
17
- //# sourceMappingURL=block_state_util.d.ts.map
@@ -0,0 +1,24 @@
1
+ class OutputError extends Error {
2
+ errors;
3
+ moreErrors;
4
+ constructor(errors, moreErrors) {
5
+ super(`${errors.length}${moreErrors ? '+' : ''} errors, first error: ` + errors[0].message);
6
+ this.errors = errors;
7
+ this.moreErrors = moreErrors;
8
+ }
9
+ }
10
+ function readOutput(outputValue) {
11
+ if (!outputValue.ok)
12
+ throw new OutputError(outputValue.errors, outputValue.moreErrors);
13
+ return outputValue.value;
14
+ }
15
+ function wrapOutputs(outputs) {
16
+ return new Proxy(outputs, {
17
+ get(target, key) {
18
+ return readOutput(target[key]);
19
+ },
20
+ });
21
+ }
22
+
23
+ export { OutputError, readOutput, wrapOutputs };
24
+ //# sourceMappingURL=block_state_util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"block_state_util.js","sources":["../src/block_state_util.ts"],"sourcesContent":["import type { BlockOutputsBase, ValueOrErrors } from '@milaboratories/pl-model-common';\nimport type { ErrorLike } from '@milaboratories/pl-error-like';\n\nexport class OutputError extends Error {\n constructor(\n public readonly errors: ErrorLike[],\n public readonly moreErrors: boolean,\n ) {\n super(`${errors.length}${moreErrors ? '+' : ''} errors, first error: ` + errors[0].message);\n }\n}\n\nexport function readOutput<T>(outputValue: ValueOrErrors<T>): T {\n if (!outputValue.ok) throw new OutputError(outputValue.errors, outputValue.moreErrors);\n return outputValue.value;\n}\n\ntype ExtractValueType<V extends ValueOrErrors<unknown>> = Extract<V, { ok: true }>['value'];\ntype SimpleOutputs<Outputs extends BlockOutputsBase> = {\n [Key in keyof Outputs]: ExtractValueType<Outputs[Key]>;\n};\n\nexport function wrapOutputs<Outputs extends BlockOutputsBase>(\n outputs: Outputs,\n): SimpleOutputs<Outputs> {\n return new Proxy(outputs, {\n get(target, key: string) {\n return readOutput(target[key]);\n },\n }) as SimpleOutputs<Outputs>;\n}\n"],"names":[],"mappings":"AAGM,MAAO,WAAY,SAAQ,KAAK,CAAA;AAElB,IAAA,MAAA;AACA,IAAA,UAAA;IAFlB,WAAA,CACkB,MAAmB,EACnB,UAAmB,EAAA;QAEnC,KAAK,CAAC,CAAA,EAAG,MAAM,CAAC,MAAM,GAAG,UAAU,GAAG,GAAG,GAAG,EAAE,CAAA,sBAAA,CAAwB,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;QAH3E,IAAA,CAAA,MAAM,GAAN,MAAM;QACN,IAAA,CAAA,UAAU,GAAV,UAAU;IAG5B;AACD;AAEK,SAAU,UAAU,CAAI,WAA6B,EAAA;IACzD,IAAI,CAAC,WAAW,CAAC,EAAE;QAAE,MAAM,IAAI,WAAW,CAAC,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,UAAU,CAAC;IACtF,OAAO,WAAW,CAAC,KAAK;AAC1B;AAOM,SAAU,WAAW,CACzB,OAAgB,EAAA;AAEhB,IAAA,OAAO,IAAI,KAAK,CAAC,OAAO,EAAE;QACxB,GAAG,CAAC,MAAM,EAAE,GAAW,EAAA;AACrB,YAAA,OAAO,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAChC,CAAC;AACF,KAAA,CAA2B;AAC9B;;;;"}
@@ -4,4 +4,3 @@ type Brand<B> = {
4
4
  };
5
5
  export type Branded<T, B> = T & Brand<B>;
6
6
  export {};
7
- //# sourceMappingURL=branding.d.ts.map
@@ -0,0 +1,166 @@
1
+ 'use strict';
2
+
3
+ var actions = require('./config/actions.cjs');
4
+ var internal = require('./internal.cjs');
5
+ var api = require('./render/api.cjs');
6
+ require('@milaboratories/pl-model-common');
7
+ require('./render/util/label.cjs');
8
+ require('canonicalize');
9
+ var version = require('./version.cjs');
10
+ var normalization = require('./bconfig/normalization.cjs');
11
+
12
+ /** Main entry point that each block should use in it's "config" module. Don't forget
13
+ * to call {@link done()} at the end of configuration. Value returned by this builder must be
14
+ * exported as constant with name "platforma" from the "config" module. */
15
+ class BlockModel {
16
+ _renderingMode;
17
+ _initialArgs;
18
+ _initialUiState;
19
+ _outputs;
20
+ _inputsValid;
21
+ _sections;
22
+ _title;
23
+ _enrichmentTargets;
24
+ _featureFlags;
25
+ constructor(_renderingMode, _initialArgs, _initialUiState, _outputs, _inputsValid, _sections, _title, _enrichmentTargets, _featureFlags) {
26
+ this._renderingMode = _renderingMode;
27
+ this._initialArgs = _initialArgs;
28
+ this._initialUiState = _initialUiState;
29
+ this._outputs = _outputs;
30
+ this._inputsValid = _inputsValid;
31
+ this._sections = _sections;
32
+ this._title = _title;
33
+ this._enrichmentTargets = _enrichmentTargets;
34
+ this._featureFlags = _featureFlags;
35
+ }
36
+ static INITIAL_BLOCK_FEATURE_FLAGS = {
37
+ supportsLazyState: true,
38
+ requiresUIAPIVersion: 1,
39
+ requiresModelAPIVersion: 1,
40
+ };
41
+ static create(renderingMode = 'Heavy') {
42
+ return new BlockModel(renderingMode, undefined, {}, {}, actions.getImmediate(true), actions.getImmediate([]), undefined, undefined, { ...BlockModel.INITIAL_BLOCK_FEATURE_FLAGS });
43
+ }
44
+ output(key, cfgOrRf, flags = {}) {
45
+ if (typeof cfgOrRf === 'function') {
46
+ const handle = `output#${key}`;
47
+ internal.tryRegisterCallback(handle, () => cfgOrRf(new api.RenderCtx()));
48
+ return new BlockModel(this._renderingMode, this._initialArgs, this._initialUiState, {
49
+ ...this._outputs,
50
+ [key]: {
51
+ __renderLambda: true,
52
+ handle,
53
+ ...flags,
54
+ },
55
+ }, this._inputsValid, this._sections, this._title, this._enrichmentTargets, this._featureFlags);
56
+ }
57
+ else
58
+ return new BlockModel(this._renderingMode, this._initialArgs, this._initialUiState, {
59
+ ...this._outputs,
60
+ [key]: cfgOrRf,
61
+ }, this._inputsValid, this._sections, this._title, this._enrichmentTargets, this._featureFlags);
62
+ }
63
+ /** Shortcut for {@link output} with retentive flag set to true. */
64
+ retentiveOutput(key, rf) {
65
+ return this.output(key, rf, { retentive: true });
66
+ }
67
+ argsValid(cfgOrRf) {
68
+ if (typeof cfgOrRf === 'function') {
69
+ internal.tryRegisterCallback('inputsValid', () => cfgOrRf(new api.RenderCtx()));
70
+ return new BlockModel(this._renderingMode, this._initialArgs, this._initialUiState, this._outputs, {
71
+ __renderLambda: true,
72
+ handle: 'inputsValid',
73
+ }, this._sections, this._title, this._enrichmentTargets, this._featureFlags);
74
+ }
75
+ else
76
+ return new BlockModel(this._renderingMode, this._initialArgs, this._initialUiState, this._outputs, cfgOrRf, this._sections, this._title, this._enrichmentTargets, this._featureFlags);
77
+ }
78
+ sections(arrOrCfgOrRf) {
79
+ if (Array.isArray(arrOrCfgOrRf)) {
80
+ return this.sections(actions.getImmediate(arrOrCfgOrRf));
81
+ }
82
+ else if (typeof arrOrCfgOrRf === 'function') {
83
+ internal.tryRegisterCallback('sections', () => arrOrCfgOrRf(new api.RenderCtx()));
84
+ return new BlockModel(this._renderingMode, this._initialArgs, this._initialUiState, this._outputs, this._inputsValid, { __renderLambda: true, handle: 'sections' }, this._title, this._enrichmentTargets, this._featureFlags);
85
+ }
86
+ else
87
+ return new BlockModel(this._renderingMode, this._initialArgs, this._initialUiState, this._outputs, this._inputsValid, arrOrCfgOrRf, this._title, this._enrichmentTargets, this._featureFlags);
88
+ }
89
+ /** Sets a rendering function to derive block title, shown for the block in the left blocks-overview panel. */
90
+ title(rf) {
91
+ internal.tryRegisterCallback('title', () => rf(new api.RenderCtx()));
92
+ return new BlockModel(this._renderingMode, this._initialArgs, this._initialUiState, this._outputs, this._inputsValid, this._sections, { __renderLambda: true, handle: 'title' }, this._enrichmentTargets, this._featureFlags);
93
+ }
94
+ /**
95
+ * Sets initial args for the block, this value must be specified.
96
+ * @deprecated use {@link withArgs}
97
+ * */
98
+ initialArgs(value) {
99
+ return new BlockModel(this._renderingMode, value, this._initialUiState, this._outputs, this._inputsValid, this._sections, this._title, this._enrichmentTargets, this._featureFlags);
100
+ }
101
+ /** Sets initial args for the block, this value must be specified. */
102
+ withArgs(initialValue) {
103
+ return new BlockModel(this._renderingMode, initialValue, this._initialUiState, this._outputs, this._inputsValid, this._sections, this._title, this._enrichmentTargets, this._featureFlags);
104
+ }
105
+ /** Defines type and sets initial value for block UiState. */
106
+ withUiState(initialValue) {
107
+ return new BlockModel(this._renderingMode, this._initialArgs, initialValue, this._outputs, this._inputsValid, this._sections, this._title, this._enrichmentTargets, this._featureFlags);
108
+ }
109
+ /** Sets or overrides feature flags for the block. */
110
+ withFeatureFlags(flags) {
111
+ return new BlockModel(this._renderingMode, this._initialArgs, this._initialUiState, this._outputs, this._inputsValid, this._sections, this._title, this._enrichmentTargets, { ...this._featureFlags, ...flags });
112
+ }
113
+ /**
114
+ * Defines how to derive list of upstream references this block is meant to enrich with its exports from block args.
115
+ * Influences dependency graph construction.
116
+ */
117
+ enriches(lambda) {
118
+ internal.tryRegisterCallback('enrichmentTargets', lambda);
119
+ return new BlockModel(this._renderingMode, this._initialArgs, this._initialUiState, this._outputs, this._inputsValid, this._sections, this._title, { __renderLambda: true, handle: 'enrichmentTargets' }, this._featureFlags);
120
+ }
121
+ /** Renders all provided block settings into a pre-configured platforma API
122
+ * instance, that can be used in frontend to interact with block state, and
123
+ * other features provided by the platforma to the block. */
124
+ done(apiVersion) {
125
+ const requiresUIAPIVersion = apiVersion ?? 1;
126
+ return this.withFeatureFlags({
127
+ ...this._featureFlags,
128
+ requiresUIAPIVersion,
129
+ })._done(requiresUIAPIVersion);
130
+ }
131
+ _done(apiVersion) {
132
+ if (this._initialArgs === undefined)
133
+ throw new Error('Initial arguments not set.');
134
+ const config = {
135
+ v3: {
136
+ sdkVersion: version.PlatformaSDKVersion,
137
+ renderingMode: this._renderingMode,
138
+ initialArgs: this._initialArgs,
139
+ initialUiState: this._initialUiState,
140
+ inputsValid: this._inputsValid,
141
+ sections: this._sections,
142
+ title: this._title,
143
+ outputs: this._outputs,
144
+ enrichmentTargets: this._enrichmentTargets,
145
+ featureFlags: this._featureFlags,
146
+ },
147
+ // fields below are added to allow previous desktop versions read generated configs
148
+ sdkVersion: version.PlatformaSDKVersion,
149
+ renderingMode: this._renderingMode,
150
+ initialArgs: this._initialArgs,
151
+ inputsValid: normalization.downgradeCfgOrLambda(this._inputsValid),
152
+ sections: normalization.downgradeCfgOrLambda(this._sections),
153
+ outputs: Object.fromEntries(Object.entries(this._outputs).map(([key, value]) => [key, normalization.downgradeCfgOrLambda(value)])),
154
+ };
155
+ globalThis.platformaApiVersion = apiVersion;
156
+ if (!internal.isInUI())
157
+ // we are in the configuration rendering routine, not in actual UI
158
+ return { config };
159
+ // normal operation inside the UI
160
+ else
161
+ return internal.getPlatformaInstance({ sdkVersion: version.PlatformaSDKVersion, apiVersion: platformaApiVersion });
162
+ }
163
+ }
164
+
165
+ exports.BlockModel = BlockModel;
166
+ //# sourceMappingURL=builder.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"builder.cjs","sources":["../src/builder.ts"],"sourcesContent":["import type { BlockRenderingMode, BlockSection, ValueOrErrors, AnyFunction, PlRef, BlockCodeKnownFeatureFlags, BlockConfigContainer } from '@milaboratories/pl-model-common';\nimport type { Checked, ConfigResult, TypedConfig } from './config';\nimport { getImmediate } from './config';\nimport { getPlatformaInstance, isInUI, tryRegisterCallback } from './internal';\nimport type { Platforma, PlatformaApiVersion, PlatformaV1, PlatformaV2 } from './platforma';\nimport type { InferRenderFunctionReturn, RenderFunction } from './render';\nimport { RenderCtx } from './render';\nimport { PlatformaSDKVersion } from './version';\nimport type {\n TypedConfigOrConfigLambda,\n ConfigRenderLambda,\n StdCtxArgsOnly,\n DeriveHref,\n ResolveCfgType,\n ExtractFunctionHandleReturn,\n ConfigRenderLambdaFlags,\n} from './bconfig';\nimport {\n downgradeCfgOrLambda,\n} from './bconfig';\n\ntype SectionsExpectedType = readonly BlockSection[];\n\ntype SectionsCfgChecked<Cfg extends TypedConfig, Args, UiState> = Checked<\n Cfg,\n ConfigResult<Cfg, StdCtxArgsOnly<Args, UiState>> extends SectionsExpectedType ? true : false\n>;\n\n// TODO (Unused type in code)\n// type SectionsRFChecked<RF extends Function> = Checked<\n// RF,\n// InferRenderFunctionReturn<RF> extends SectionsExpectedType ? true : false\n// >;\n\ntype InputsValidExpectedType = boolean;\n\ntype InputsValidCfgChecked<Cfg extends TypedConfig, Args, UiState> = Checked<\n Cfg,\n ConfigResult<Cfg, StdCtxArgsOnly<Args, UiState>> extends InputsValidExpectedType ? true : false\n>;\n\n// TODO (Unused type in code)\n// type InputsValidRFChecked<RF extends Function> = Checked<\n// RF,\n// InferRenderFunctionReturn<RF> extends InputsValidExpectedType ? true : false\n// >;\n\ntype NoOb = Record<string, never>;\n\n/** Main entry point that each block should use in it's \"config\" module. Don't forget\n * to call {@link done()} at the end of configuration. Value returned by this builder must be\n * exported as constant with name \"platforma\" from the \"config\" module. */\nexport class BlockModel<\n Args,\n OutputsCfg extends Record<string, TypedConfigOrConfigLambda>,\n UiState,\n Href extends `/${string}` = '/',\n> {\n private constructor(\n private readonly _renderingMode: BlockRenderingMode,\n private readonly _initialArgs: Args | undefined,\n private readonly _initialUiState: UiState,\n private readonly _outputs: OutputsCfg,\n private readonly _inputsValid: TypedConfigOrConfigLambda,\n private readonly _sections: TypedConfigOrConfigLambda,\n private readonly _title: ConfigRenderLambda | undefined,\n private readonly _enrichmentTargets: ConfigRenderLambda | undefined,\n private readonly _featureFlags: BlockCodeKnownFeatureFlags,\n ) {}\n\n public static readonly INITIAL_BLOCK_FEATURE_FLAGS: BlockCodeKnownFeatureFlags = {\n supportsLazyState: true,\n requiresUIAPIVersion: 1,\n requiresModelAPIVersion: 1,\n };\n\n /** Initiates configuration builder */\n public static create(renderingMode: BlockRenderingMode): BlockModel<NoOb, {}, NoOb>;\n /** Initiates configuration builder */\n public static create(): BlockModel<NoOb, {}, NoOb>;\n /**\n * Initiates configuration builder\n * @deprecated use create method without generic parameter\n */\n public static create<Args>(renderingMode: BlockRenderingMode): BlockModel<Args, {}, NoOb>;\n /**\n * Initiates configuration builder\n * @deprecated use create method without generic parameter\n */\n public static create<Args>(): BlockModel<Args, {}, NoOb>;\n public static create(renderingMode: BlockRenderingMode = 'Heavy'): BlockModel<NoOb, {}, NoOb> {\n return new BlockModel<NoOb, {}, NoOb>(\n renderingMode,\n undefined,\n {},\n {},\n getImmediate(true),\n getImmediate([]),\n undefined,\n undefined,\n { ...BlockModel.INITIAL_BLOCK_FEATURE_FLAGS },\n );\n }\n\n /**\n * Add output cell to the configuration\n *\n * @param key output cell name, that can be later used to retrieve the rendered value\n * @param cfg configuration describing how to render cell value from the blocks\n * workflow outputs\n * @deprecated use lambda-based API\n * */\n public output<const Key extends string, const Cfg extends TypedConfig>(\n key: Key,\n cfg: Cfg\n ): BlockModel<Args, OutputsCfg & { [K in Key]: Cfg }, UiState, Href>;\n /**\n * Add output cell to the configuration\n *\n * @param key output cell name, that can be later used to retrieve the rendered value\n * @param rf callback calculating output value using context, that allows to access\n * workflows outputs and interact with platforma drivers\n * @param flags additional flags that may alter lambda rendering procedure\n * */\n public output<const Key extends string, const RF extends RenderFunction<Args, UiState>>(\n key: Key,\n rf: RF,\n flags?: ConfigRenderLambdaFlags\n ): BlockModel<\n Args,\n OutputsCfg & { [K in Key]: ConfigRenderLambda<InferRenderFunctionReturn<RF>> },\n UiState,\n Href\n >;\n public output(\n key: string,\n cfgOrRf: TypedConfig | AnyFunction,\n flags: ConfigRenderLambdaFlags = {},\n ): BlockModel<Args, OutputsCfg, UiState, Href> {\n if (typeof cfgOrRf === 'function') {\n const handle = `output#${key}`;\n tryRegisterCallback(handle, () => cfgOrRf(new RenderCtx()));\n return new BlockModel(\n this._renderingMode,\n this._initialArgs,\n this._initialUiState,\n {\n ...this._outputs,\n [key]: {\n __renderLambda: true,\n handle,\n ...flags,\n } satisfies ConfigRenderLambda,\n },\n this._inputsValid,\n this._sections,\n this._title,\n this._enrichmentTargets,\n this._featureFlags,\n );\n } else\n return new BlockModel(\n this._renderingMode,\n this._initialArgs,\n this._initialUiState,\n {\n ...this._outputs,\n [key]: cfgOrRf,\n },\n this._inputsValid,\n this._sections,\n this._title,\n this._enrichmentTargets,\n this._featureFlags,\n );\n }\n\n /** Shortcut for {@link output} with retentive flag set to true. */\n public retentiveOutput<const Key extends string, const RF extends RenderFunction<Args, UiState>>(\n key: Key,\n rf: RF,\n ): BlockModel<\n Args,\n OutputsCfg & { [K in Key]: ConfigRenderLambda<InferRenderFunctionReturn<RF>> },\n UiState,\n Href\n > {\n return this.output(key, rf, { retentive: true });\n }\n\n /** Sets custom configuration predicate on the block args at which block can be executed\n * @deprecated use lambda-based API */\n public argsValid<Cfg extends TypedConfig>(\n cfg: Cfg & InputsValidCfgChecked<Cfg, Args, UiState>\n ): BlockModel<Args, OutputsCfg, UiState, Href>;\n /** Sets custom configuration predicate on the block args at which block can be executed */\n public argsValid<RF extends RenderFunction<Args, UiState, boolean>>(\n rf: RF\n ): BlockModel<Args, OutputsCfg, UiState, Href>;\n public argsValid(\n cfgOrRf: TypedConfig | AnyFunction,\n ): BlockModel<Args, OutputsCfg, UiState, `/${string}`> {\n if (typeof cfgOrRf === 'function') {\n tryRegisterCallback('inputsValid', () => cfgOrRf(new RenderCtx()));\n return new BlockModel<Args, OutputsCfg, UiState>(\n this._renderingMode,\n this._initialArgs,\n this._initialUiState,\n this._outputs,\n {\n __renderLambda: true,\n handle: 'inputsValid',\n } satisfies ConfigRenderLambda,\n this._sections,\n this._title,\n this._enrichmentTargets,\n this._featureFlags,\n );\n } else\n return new BlockModel<Args, OutputsCfg, UiState>(\n this._renderingMode,\n this._initialArgs,\n this._initialUiState,\n this._outputs,\n cfgOrRf,\n this._sections,\n this._title,\n this._enrichmentTargets,\n this._featureFlags,\n );\n }\n\n /** Sets the config to generate list of section in the left block overviews panel\n * @deprecated use lambda-based API */\n public sections<const S extends SectionsExpectedType>(\n rf: S\n ): BlockModel<Args, OutputsCfg, UiState, DeriveHref<S>>;\n /** Sets the config to generate list of section in the left block overviews panel */\n public sections<\n const Ret extends SectionsExpectedType,\n const RF extends RenderFunction<Args, UiState, Ret>,\n >(rf: RF): BlockModel<Args, OutputsCfg, UiState, DeriveHref<ReturnType<RF>>>;\n public sections<const Cfg extends TypedConfig>(\n cfg: Cfg & SectionsCfgChecked<Cfg, Args, UiState>\n ): BlockModel<\n Args,\n OutputsCfg,\n UiState,\n DeriveHref<ConfigResult<Cfg, StdCtxArgsOnly<Args, UiState>>>\n >;\n public sections(\n arrOrCfgOrRf: SectionsExpectedType | TypedConfig | AnyFunction,\n ): BlockModel<Args, OutputsCfg, UiState, `/${string}`> {\n if (Array.isArray(arrOrCfgOrRf)) {\n return this.sections(getImmediate(arrOrCfgOrRf));\n } else if (typeof arrOrCfgOrRf === 'function') {\n tryRegisterCallback('sections', () => arrOrCfgOrRf(new RenderCtx()));\n return new BlockModel<Args, OutputsCfg, UiState>(\n this._renderingMode,\n this._initialArgs,\n this._initialUiState,\n this._outputs,\n this._inputsValid,\n { __renderLambda: true, handle: 'sections' } as ConfigRenderLambda,\n this._title,\n this._enrichmentTargets,\n this._featureFlags,\n );\n } else\n return new BlockModel<Args, OutputsCfg, UiState>(\n this._renderingMode,\n this._initialArgs,\n this._initialUiState,\n this._outputs,\n this._inputsValid,\n arrOrCfgOrRf as TypedConfig,\n this._title,\n this._enrichmentTargets,\n this._featureFlags,\n );\n }\n\n /** Sets a rendering function to derive block title, shown for the block in the left blocks-overview panel. */\n public title(\n rf: RenderFunction<Args, UiState, string>,\n ): BlockModel<Args, OutputsCfg, UiState, Href> {\n tryRegisterCallback('title', () => rf(new RenderCtx()));\n return new BlockModel<Args, OutputsCfg, UiState, Href>(\n this._renderingMode,\n this._initialArgs,\n this._initialUiState,\n this._outputs,\n this._inputsValid,\n this._sections,\n { __renderLambda: true, handle: 'title' } as ConfigRenderLambda,\n this._enrichmentTargets,\n this._featureFlags,\n );\n }\n\n /**\n * Sets initial args for the block, this value must be specified.\n * @deprecated use {@link withArgs}\n * */\n public initialArgs(value: Args): BlockModel<Args, OutputsCfg, UiState, Href> {\n return new BlockModel<Args, OutputsCfg, UiState, Href>(\n this._renderingMode,\n value,\n this._initialUiState,\n this._outputs,\n this._inputsValid,\n this._sections,\n this._title,\n this._enrichmentTargets,\n this._featureFlags,\n );\n }\n\n /** Sets initial args for the block, this value must be specified. */\n public withArgs<Args>(initialValue: Args): BlockModel<Args, OutputsCfg, UiState, Href> {\n return new BlockModel<Args, OutputsCfg, UiState, Href>(\n this._renderingMode,\n initialValue,\n this._initialUiState,\n this._outputs,\n this._inputsValid,\n this._sections,\n this._title,\n this._enrichmentTargets,\n this._featureFlags,\n );\n }\n\n /** Defines type and sets initial value for block UiState. */\n public withUiState<UiState>(initialValue: UiState): BlockModel<Args, OutputsCfg, UiState, Href> {\n return new BlockModel<Args, OutputsCfg, UiState, Href>(\n this._renderingMode,\n this._initialArgs,\n initialValue,\n this._outputs,\n this._inputsValid,\n this._sections,\n this._title,\n this._enrichmentTargets,\n this._featureFlags,\n );\n }\n\n /** Sets or overrides feature flags for the block. */\n public withFeatureFlags(flags: Partial<BlockCodeKnownFeatureFlags>): BlockModel<Args, OutputsCfg, UiState, Href> {\n return new BlockModel<Args, OutputsCfg, UiState, Href>(\n this._renderingMode,\n this._initialArgs,\n this._initialUiState,\n this._outputs,\n this._inputsValid,\n this._sections,\n this._title,\n this._enrichmentTargets,\n { ...this._featureFlags, ...flags },\n );\n }\n\n /**\n * Defines how to derive list of upstream references this block is meant to enrich with its exports from block args.\n * Influences dependency graph construction.\n */\n public enriches(\n lambda: (args: Args) => PlRef[],\n ): BlockModel<Args, OutputsCfg, UiState, Href> {\n tryRegisterCallback('enrichmentTargets', lambda);\n return new BlockModel<Args, OutputsCfg, UiState, Href>(\n this._renderingMode,\n this._initialArgs,\n this._initialUiState,\n this._outputs,\n this._inputsValid,\n this._sections,\n this._title,\n { __renderLambda: true, handle: 'enrichmentTargets' } as ConfigRenderLambda,\n this._featureFlags,\n );\n }\n\n public done(apiVersion?: 1): PlatformaV1<\n Args,\n InferOutputsFromConfigs<Args, OutputsCfg, UiState>,\n UiState,\n Href\n >;\n\n public done(apiVersion: 2): PlatformaV2<\n Args,\n InferOutputsFromConfigs<Args, OutputsCfg, UiState>,\n UiState,\n Href\n >;\n\n /** Renders all provided block settings into a pre-configured platforma API\n * instance, that can be used in frontend to interact with block state, and\n * other features provided by the platforma to the block. */\n public done(apiVersion?: PlatformaApiVersion): Platforma<\n Args,\n InferOutputsFromConfigs<Args, OutputsCfg, UiState>,\n UiState,\n Href\n > {\n const requiresUIAPIVersion = apiVersion ?? 1;\n return this.withFeatureFlags({\n ...this._featureFlags,\n requiresUIAPIVersion,\n })._done(requiresUIAPIVersion);\n }\n\n public _done(apiVersion: PlatformaApiVersion): Platforma<\n Args,\n InferOutputsFromConfigs<Args, OutputsCfg, UiState>,\n UiState,\n Href\n > {\n if (this._initialArgs === undefined) throw new Error('Initial arguments not set.');\n\n const config: BlockConfigContainer = {\n v3: {\n sdkVersion: PlatformaSDKVersion,\n renderingMode: this._renderingMode,\n initialArgs: this._initialArgs,\n initialUiState: this._initialUiState,\n inputsValid: this._inputsValid,\n sections: this._sections,\n title: this._title,\n outputs: this._outputs,\n enrichmentTargets: this._enrichmentTargets,\n featureFlags: this._featureFlags,\n },\n\n // fields below are added to allow previous desktop versions read generated configs\n sdkVersion: PlatformaSDKVersion,\n renderingMode: this._renderingMode,\n initialArgs: this._initialArgs,\n inputsValid: downgradeCfgOrLambda(this._inputsValid),\n sections: downgradeCfgOrLambda(this._sections),\n outputs: Object.fromEntries(\n Object.entries(this._outputs).map(([key, value]) => [key, downgradeCfgOrLambda(value)]),\n ),\n };\n\n globalThis.platformaApiVersion = apiVersion;\n\n if (!isInUI())\n // we are in the configuration rendering routine, not in actual UI\n return { config } as any;\n // normal operation inside the UI\n else return getPlatformaInstance({ sdkVersion: PlatformaSDKVersion, apiVersion: platformaApiVersion }) as any;\n }\n}\n\nexport type InferOutputType<CfgOrFH, Args, UiState> = CfgOrFH extends TypedConfig\n ? ResolveCfgType<CfgOrFH, Args, UiState>\n : CfgOrFH extends ConfigRenderLambda\n ? ExtractFunctionHandleReturn<CfgOrFH>\n : never;\n\ntype InferOutputsFromConfigs<\n Args,\n OutputsCfg extends Record<string, TypedConfigOrConfigLambda>,\n UiState,\n> = {\n [Key in keyof OutputsCfg]: ValueOrErrors<InferOutputType<OutputsCfg[Key], Args, UiState>>;\n};\n"],"names":["getImmediate","tryRegisterCallback","RenderCtx","PlatformaSDKVersion","downgradeCfgOrLambda","isInUI","getPlatformaInstance"],"mappings":";;;;;;;;;;;AAiDA;;AAE0E;MAC7D,UAAU,CAAA;AAOF,IAAA,cAAA;AACA,IAAA,YAAA;AACA,IAAA,eAAA;AACA,IAAA,QAAA;AACA,IAAA,YAAA;AACA,IAAA,SAAA;AACA,IAAA,MAAA;AACA,IAAA,kBAAA;AACA,IAAA,aAAA;AATnB,IAAA,WAAA,CACmB,cAAkC,EAClC,YAA8B,EAC9B,eAAwB,EACxB,QAAoB,EACpB,YAAuC,EACvC,SAAoC,EACp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AAK,EAAE,IAAI,CAAC,MAAM;gBAClB,OAAO,EAAE,IAAI,CAAC,QAAQ;gBACtB,iBAAiB,EAAE,IAAI,CAAC,kBAAkB;gBAC1C,YAAY,EAAE,IAAI,CAAC,aAAa;AACjC,aAAA;;AAGD,YAAA,UAAU,EAAEA,2BAAmB;YAC/B,aAAa,EAAE,IAAI,CAAC,cAAc;YAClC,WAAW,EAAE,IAAI,CAAC,YAAY;AAC9B,YAAA,WAAW,EAAEC,kCAAoB,CAAC,IAAI,CAAC,YAAY,CAAC;AACpD,YAAA,QAAQ,EAAEA,kCAAoB,CAAC,IAAI,CAAC,SAAS,CAAC;AAC9C,YAAA,OAAO,EAAE,MAAM,CAAC,WAAW,CACzB,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,EAAEA,kCAAoB,CAAC,KAAK,CAAC,CAAC,CAAC,CACxF;SACF;AAED,QAAA,UAAU,CAAC,mBAAmB,GAAG,UAAU;QAE3C,IAAI,CAACC,eAAM,EAAE;;YAEX,OAAO,EAAE,MAAM,EAAS;;;AAErB,YAAA,OAAOC,6BAAoB,CAAC,EAAE,UAAU,EAAEH,2BAAmB,EAAE,UAAU,EAAE,mBAAmB,EAAE,CAAQ;IAC/G;;;;;"}
package/dist/builder.d.ts CHANGED
@@ -101,4 +101,3 @@ type InferOutputsFromConfigs<Args, OutputsCfg extends Record<string, TypedConfig
101
101
  [Key in keyof OutputsCfg]: ValueOrErrors<InferOutputType<OutputsCfg[Key], Args, UiState>>;
102
102
  };
103
103
  export {};
104
- //# sourceMappingURL=builder.d.ts.map
@@ -0,0 +1,164 @@
1
+ import { getImmediate } from './config/actions.js';
2
+ import { tryRegisterCallback, isInUI, getPlatformaInstance } from './internal.js';
3
+ import { RenderCtx } from './render/api.js';
4
+ import '@milaboratories/pl-model-common';
5
+ import './render/util/label.js';
6
+ import 'canonicalize';
7
+ import { PlatformaSDKVersion } from './version.js';
8
+ import { downgradeCfgOrLambda } from './bconfig/normalization.js';
9
+
10
+ /** Main entry point that each block should use in it's "config" module. Don't forget
11
+ * to call {@link done()} at the end of configuration. Value returned by this builder must be
12
+ * exported as constant with name "platforma" from the "config" module. */
13
+ class BlockModel {
14
+ _renderingMode;
15
+ _initialArgs;
16
+ _initialUiState;
17
+ _outputs;
18
+ _inputsValid;
19
+ _sections;
20
+ _title;
21
+ _enrichmentTargets;
22
+ _featureFlags;
23
+ constructor(_renderingMode, _initialArgs, _initialUiState, _outputs, _inputsValid, _sections, _title, _enrichmentTargets, _featureFlags) {
24
+ this._renderingMode = _renderingMode;
25
+ this._initialArgs = _initialArgs;
26
+ this._initialUiState = _initialUiState;
27
+ this._outputs = _outputs;
28
+ this._inputsValid = _inputsValid;
29
+ this._sections = _sections;
30
+ this._title = _title;
31
+ this._enrichmentTargets = _enrichmentTargets;
32
+ this._featureFlags = _featureFlags;
33
+ }
34
+ static INITIAL_BLOCK_FEATURE_FLAGS = {
35
+ supportsLazyState: true,
36
+ requiresUIAPIVersion: 1,
37
+ requiresModelAPIVersion: 1,
38
+ };
39
+ static create(renderingMode = 'Heavy') {
40
+ return new BlockModel(renderingMode, undefined, {}, {}, getImmediate(true), getImmediate([]), undefined, undefined, { ...BlockModel.INITIAL_BLOCK_FEATURE_FLAGS });
41
+ }
42
+ output(key, cfgOrRf, flags = {}) {
43
+ if (typeof cfgOrRf === 'function') {
44
+ const handle = `output#${key}`;
45
+ tryRegisterCallback(handle, () => cfgOrRf(new RenderCtx()));
46
+ return new BlockModel(this._renderingMode, this._initialArgs, this._initialUiState, {
47
+ ...this._outputs,
48
+ [key]: {
49
+ __renderLambda: true,
50
+ handle,
51
+ ...flags,
52
+ },
53
+ }, this._inputsValid, this._sections, this._title, this._enrichmentTargets, this._featureFlags);
54
+ }
55
+ else
56
+ return new BlockModel(this._renderingMode, this._initialArgs, this._initialUiState, {
57
+ ...this._outputs,
58
+ [key]: cfgOrRf,
59
+ }, this._inputsValid, this._sections, this._title, this._enrichmentTargets, this._featureFlags);
60
+ }
61
+ /** Shortcut for {@link output} with retentive flag set to true. */
62
+ retentiveOutput(key, rf) {
63
+ return this.output(key, rf, { retentive: true });
64
+ }
65
+ argsValid(cfgOrRf) {
66
+ if (typeof cfgOrRf === 'function') {
67
+ tryRegisterCallback('inputsValid', () => cfgOrRf(new RenderCtx()));
68
+ return new BlockModel(this._renderingMode, this._initialArgs, this._initialUiState, this._outputs, {
69
+ __renderLambda: true,
70
+ handle: 'inputsValid',
71
+ }, this._sections, this._title, this._enrichmentTargets, this._featureFlags);
72
+ }
73
+ else
74
+ return new BlockModel(this._renderingMode, this._initialArgs, this._initialUiState, this._outputs, cfgOrRf, this._sections, this._title, this._enrichmentTargets, this._featureFlags);
75
+ }
76
+ sections(arrOrCfgOrRf) {
77
+ if (Array.isArray(arrOrCfgOrRf)) {
78
+ return this.sections(getImmediate(arrOrCfgOrRf));
79
+ }
80
+ else if (typeof arrOrCfgOrRf === 'function') {
81
+ tryRegisterCallback('sections', () => arrOrCfgOrRf(new RenderCtx()));
82
+ return new BlockModel(this._renderingMode, this._initialArgs, this._initialUiState, this._outputs, this._inputsValid, { __renderLambda: true, handle: 'sections' }, this._title, this._enrichmentTargets, this._featureFlags);
83
+ }
84
+ else
85
+ return new BlockModel(this._renderingMode, this._initialArgs, this._initialUiState, this._outputs, this._inputsValid, arrOrCfgOrRf, this._title, this._enrichmentTargets, this._featureFlags);
86
+ }
87
+ /** Sets a rendering function to derive block title, shown for the block in the left blocks-overview panel. */
88
+ title(rf) {
89
+ tryRegisterCallback('title', () => rf(new RenderCtx()));
90
+ return new BlockModel(this._renderingMode, this._initialArgs, this._initialUiState, this._outputs, this._inputsValid, this._sections, { __renderLambda: true, handle: 'title' }, this._enrichmentTargets, this._featureFlags);
91
+ }
92
+ /**
93
+ * Sets initial args for the block, this value must be specified.
94
+ * @deprecated use {@link withArgs}
95
+ * */
96
+ initialArgs(value) {
97
+ return new BlockModel(this._renderingMode, value, this._initialUiState, this._outputs, this._inputsValid, this._sections, this._title, this._enrichmentTargets, this._featureFlags);
98
+ }
99
+ /** Sets initial args for the block, this value must be specified. */
100
+ withArgs(initialValue) {
101
+ return new BlockModel(this._renderingMode, initialValue, this._initialUiState, this._outputs, this._inputsValid, this._sections, this._title, this._enrichmentTargets, this._featureFlags);
102
+ }
103
+ /** Defines type and sets initial value for block UiState. */
104
+ withUiState(initialValue) {
105
+ return new BlockModel(this._renderingMode, this._initialArgs, initialValue, this._outputs, this._inputsValid, this._sections, this._title, this._enrichmentTargets, this._featureFlags);
106
+ }
107
+ /** Sets or overrides feature flags for the block. */
108
+ withFeatureFlags(flags) {
109
+ return new BlockModel(this._renderingMode, this._initialArgs, this._initialUiState, this._outputs, this._inputsValid, this._sections, this._title, this._enrichmentTargets, { ...this._featureFlags, ...flags });
110
+ }
111
+ /**
112
+ * Defines how to derive list of upstream references this block is meant to enrich with its exports from block args.
113
+ * Influences dependency graph construction.
114
+ */
115
+ enriches(lambda) {
116
+ tryRegisterCallback('enrichmentTargets', lambda);
117
+ return new BlockModel(this._renderingMode, this._initialArgs, this._initialUiState, this._outputs, this._inputsValid, this._sections, this._title, { __renderLambda: true, handle: 'enrichmentTargets' }, this._featureFlags);
118
+ }
119
+ /** Renders all provided block settings into a pre-configured platforma API
120
+ * instance, that can be used in frontend to interact with block state, and
121
+ * other features provided by the platforma to the block. */
122
+ done(apiVersion) {
123
+ const requiresUIAPIVersion = apiVersion ?? 1;
124
+ return this.withFeatureFlags({
125
+ ...this._featureFlags,
126
+ requiresUIAPIVersion,
127
+ })._done(requiresUIAPIVersion);
128
+ }
129
+ _done(apiVersion) {
130
+ if (this._initialArgs === undefined)
131
+ throw new Error('Initial arguments not set.');
132
+ const config = {
133
+ v3: {
134
+ sdkVersion: PlatformaSDKVersion,
135
+ renderingMode: this._renderingMode,
136
+ initialArgs: this._initialArgs,
137
+ initialUiState: this._initialUiState,
138
+ inputsValid: this._inputsValid,
139
+ sections: this._sections,
140
+ title: this._title,
141
+ outputs: this._outputs,
142
+ enrichmentTargets: this._enrichmentTargets,
143
+ featureFlags: this._featureFlags,
144
+ },
145
+ // fields below are added to allow previous desktop versions read generated configs
146
+ sdkVersion: PlatformaSDKVersion,
147
+ renderingMode: this._renderingMode,
148
+ initialArgs: this._initialArgs,
149
+ inputsValid: downgradeCfgOrLambda(this._inputsValid),
150
+ sections: downgradeCfgOrLambda(this._sections),
151
+ outputs: Object.fromEntries(Object.entries(this._outputs).map(([key, value]) => [key, downgradeCfgOrLambda(value)])),
152
+ };
153
+ globalThis.platformaApiVersion = apiVersion;
154
+ if (!isInUI())
155
+ // we are in the configuration rendering routine, not in actual UI
156
+ return { config };
157
+ // normal operation inside the UI
158
+ else
159
+ return getPlatformaInstance({ sdkVersion: PlatformaSDKVersion, apiVersion: platformaApiVersion });
160
+ }
161
+ }
162
+
163
+ export { BlockModel };
164
+ //# sourceMappingURL=builder.js.map