@platforma-sdk/model 1.75.2 → 1.75.8

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 (37) hide show
  1. package/dist/block_model.cjs +3 -3
  2. package/dist/block_model.cjs.map +1 -1
  3. package/dist/block_model.d.ts +4 -5
  4. package/dist/block_model.d.ts.map +1 -1
  5. package/dist/block_model.js +3 -3
  6. package/dist/block_model.js.map +1 -1
  7. package/dist/block_model_legacy.cjs +2 -1
  8. package/dist/block_model_legacy.cjs.map +1 -1
  9. package/dist/block_model_legacy.js +2 -1
  10. package/dist/block_model_legacy.js.map +1 -1
  11. package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV3.cjs +1 -1
  12. package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV3.cjs.map +1 -1
  13. package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV3.d.ts.map +1 -1
  14. package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV3.js +1 -1
  15. package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV3.js.map +1 -1
  16. package/dist/index.d.ts +3 -3
  17. package/dist/package.cjs +1 -1
  18. package/dist/package.js +1 -1
  19. package/dist/platforma.d.ts +8 -5
  20. package/dist/platforma.d.ts.map +1 -1
  21. package/dist/plugin_handle.cjs.map +1 -1
  22. package/dist/plugin_handle.d.ts +1 -1
  23. package/dist/plugin_handle.js.map +1 -1
  24. package/dist/plugin_model.cjs +34 -37
  25. package/dist/plugin_model.cjs.map +1 -1
  26. package/dist/plugin_model.d.ts +55 -53
  27. package/dist/plugin_model.d.ts.map +1 -1
  28. package/dist/plugin_model.js +34 -37
  29. package/dist/plugin_model.js.map +1 -1
  30. package/package.json +8 -8
  31. package/src/block_model.ts +16 -5
  32. package/src/block_model_legacy.ts +1 -0
  33. package/src/components/PlDataTable/createPlDataTable/createPlDataTableV3.ts +8 -6
  34. package/src/index.ts +2 -0
  35. package/src/platforma.ts +11 -5
  36. package/src/plugin_handle.ts +1 -1
  37. package/src/plugin_model.ts +189 -76
@@ -53,9 +53,22 @@ export const CREATE_PLUGIN_MODEL = Symbol("createPluginModel");
53
53
  /** Sentinel for PluginInstance without transferAt — no transfer possible. */
54
54
  const NO_TRANSFER_VERSION = "";
55
55
 
56
+ /**
57
+ * Runtime definition for a single public output field.
58
+ * Stored in PluginModel and passed through BlockModelInfo to the UI layer.
59
+ */
60
+ export type PublicOutputFieldDef = {
61
+ readonly getter: (data: unknown) => unknown;
62
+ };
63
+
64
+ export type PublicOutputDef<PublicOutputs extends PluginPublicOutputs> = {
65
+ [K in keyof PublicOutputs]: PublicOutputFieldDef;
66
+ };
67
+
56
68
  export type PluginData = Record<string, unknown>;
57
69
  export type PluginParams = undefined | Record<string, unknown>;
58
70
  export type PluginOutputs = Record<string, unknown>;
71
+ export type PluginPublicOutputs = Record<string, unknown>;
59
72
  export type PluginConfig = undefined | Record<string, unknown>;
60
73
 
61
74
  /**
@@ -306,6 +319,7 @@ export class PluginInstance<
306
319
  Data extends PluginData = PluginData,
307
320
  Params extends PluginParams = undefined,
308
321
  Outputs extends PluginOutputs = PluginOutputs,
322
+ PublicOutputs extends PluginPublicOutputs = PluginPublicOutputs,
309
323
  TransferData = never,
310
324
  ModelServices = unknown,
311
325
  UiServices = unknown,
@@ -319,19 +333,28 @@ export class PluginInstance<
319
333
  outputs: Outputs;
320
334
  modelServices: ModelServices;
321
335
  uiServices: UiServices;
336
+ publicOutputs: PublicOutputs;
322
337
  };
323
338
  /** Bound closure that creates the PluginModel. Config is captured at factory.create() time. */
324
339
  private readonly createPluginModel: () => PluginModel<
325
340
  Data,
326
341
  Params,
327
342
  Outputs,
343
+ PublicOutputs,
328
344
  ModelServices,
329
345
  UiServices
330
346
  >;
331
347
 
332
348
  private constructor(
333
349
  id: Id,
334
- createPluginModel: () => PluginModel<Data, Params, Outputs, ModelServices, UiServices>,
350
+ createPluginModel: () => PluginModel<
351
+ Data,
352
+ Params,
353
+ Outputs,
354
+ PublicOutputs,
355
+ ModelServices,
356
+ UiServices
357
+ >,
335
358
  transferVersion: string,
336
359
  ) {
337
360
  this.id = id;
@@ -345,7 +368,8 @@ export class PluginInstance<
345
368
  Data extends PluginData,
346
369
  Params extends PluginParams,
347
370
  Outputs extends PluginOutputs,
348
- TransferData,
371
+ PublicOutputs extends PluginPublicOutputs = PluginPublicOutputs,
372
+ TransferData = never,
349
373
  Config extends PluginConfig = PluginConfig,
350
374
  ModelServices = unknown,
351
375
  UiServices = unknown,
@@ -355,6 +379,7 @@ export class PluginInstance<
355
379
  Data,
356
380
  Params,
357
381
  Outputs,
382
+ PublicOutputs,
358
383
  Config,
359
384
  Record<string, unknown>,
360
385
  ModelServices,
@@ -362,12 +387,28 @@ export class PluginInstance<
362
387
  >,
363
388
  transferVersion: string,
364
389
  config?: Config,
365
- ): PluginInstance<Id, Data, Params, Outputs, TransferData, ModelServices, UiServices> {
390
+ ): PluginInstance<
391
+ Id,
392
+ Data,
393
+ Params,
394
+ Outputs,
395
+ PublicOutputs,
396
+ TransferData,
397
+ ModelServices,
398
+ UiServices
399
+ > {
366
400
  return new PluginInstance(id, () => factory[CREATE_PLUGIN_MODEL](config), transferVersion);
367
401
  }
368
402
 
369
403
  /** @internal Create a PluginModel from this instance. Used by BlockModelV3.plugin(). */
370
- [CREATE_PLUGIN_MODEL](): PluginModel<Data, Params, Outputs, ModelServices, UiServices> {
404
+ [CREATE_PLUGIN_MODEL](): PluginModel<
405
+ Data,
406
+ Params,
407
+ Outputs,
408
+ PublicOutputs,
409
+ ModelServices,
410
+ UiServices
411
+ > {
371
412
  return this.createPluginModel();
372
413
  }
373
414
  }
@@ -380,6 +421,7 @@ export class PluginModel<
380
421
  Data extends PluginData = PluginData,
381
422
  Params extends PluginParams = undefined,
382
423
  Outputs extends PluginOutputs = PluginOutputs,
424
+ PublicOutputs extends PluginPublicOutputs = PluginPublicOutputs,
383
425
  ModelServices = {},
384
426
  UiServices = {},
385
427
  > {
@@ -389,27 +431,27 @@ export class PluginModel<
389
431
  readonly dataModel: DataModel<Data>;
390
432
  /** Output definitions - functions that compute outputs from plugin context */
391
433
  readonly outputs: PluginOutputFns<Data, Params, Outputs, ModelServices, UiServices>;
392
- /** Per-output flags (e.g. withStatus) */
393
- readonly outputFlags: Record<string, { withStatus: boolean }>;
394
434
  /** Feature flags declared by this plugin */
395
435
  readonly featureFlags?: BlockCodeKnownFeatureFlags;
396
436
  /** Create fresh default data. Config (if any) is captured at creation time. */
397
437
  readonly getDefaultData: () => DataVersioned<Data>;
438
+ /** Public output definitions — accessible without usePlugin() via app.plugins */
439
+ readonly publicOutputDef: PublicOutputDef<PublicOutputs>;
398
440
 
399
441
  private constructor(options: {
400
442
  name: PluginName;
401
443
  dataModel: DataModel<Data>;
402
444
  outputs: PluginOutputFns<Data, Params, Outputs, ModelServices, UiServices>;
403
- outputFlags: Record<string, { withStatus: boolean }>;
404
445
  featureFlags?: BlockCodeKnownFeatureFlags;
405
446
  getDefaultData: () => DataVersioned<Data>;
447
+ publicOutputDef: PublicOutputDef<PublicOutputs>;
406
448
  }) {
407
449
  this.name = options.name;
408
450
  this.dataModel = options.dataModel;
409
451
  this.outputs = options.outputs;
410
- this.outputFlags = options.outputFlags;
411
452
  this.featureFlags = options.featureFlags;
412
453
  this.getDefaultData = options.getDefaultData;
454
+ this.publicOutputDef = options.publicOutputDef;
413
455
  }
414
456
 
415
457
  /**
@@ -421,17 +463,20 @@ export class PluginModel<
421
463
  Data extends PluginData,
422
464
  Params extends PluginParams,
423
465
  Outputs extends PluginOutputs,
466
+ PublicOutputs extends PluginPublicOutputs = PluginPublicOutputs,
424
467
  ModelServices = {},
425
468
  UiServices = {},
426
469
  >(options: {
427
470
  name: PluginName;
428
471
  dataModel: DataModel<Data>;
429
472
  outputs: PluginOutputFns<Data, Params, Outputs, ModelServices, UiServices>;
430
- outputFlags: Record<string, { withStatus: boolean }>;
431
473
  featureFlags?: BlockCodeKnownFeatureFlags;
432
474
  getDefaultData: () => DataVersioned<Data>;
433
- }): PluginModel<Data, Params, Outputs, ModelServices, UiServices> {
434
- return new PluginModel<Data, Params, Outputs, ModelServices, UiServices>(options);
475
+ publicOutputDef: PublicOutputDef<PublicOutputs>;
476
+ }): PluginModel<Data, Params, Outputs, PublicOutputs, ModelServices, UiServices> {
477
+ return new PluginModel<Data, Params, Outputs, PublicOutputs, ModelServices, UiServices>(
478
+ options,
479
+ );
435
480
  }
436
481
 
437
482
  /**
@@ -521,6 +566,7 @@ export interface PluginFactory<
521
566
  Data extends PluginData = PluginData,
522
567
  Params extends PluginParams = undefined,
523
568
  Outputs extends PluginOutputs = PluginOutputs,
569
+ PublicOutputs extends PluginPublicOutputs = PluginPublicOutputs,
524
570
  Config extends PluginConfig = undefined,
525
571
  Versions extends Record<string, unknown> = {},
526
572
  ModelServices = {},
@@ -531,7 +577,19 @@ export interface PluginFactory<
531
577
  pluginId: Id;
532
578
  transferAt?: V;
533
579
  config?: Config;
534
- }): PluginInstance<Id, Data, Params, Outputs, Versions[V], ModelServices, UiServices>;
580
+ }): PluginInstance<
581
+ Id,
582
+ Data,
583
+ Params,
584
+ Outputs,
585
+ PublicOutputs,
586
+ Versions[V],
587
+ ModelServices,
588
+ UiServices
589
+ >;
590
+
591
+ /** Public output field definitions declared via .publicOutput(). */
592
+ readonly publicOutputDef: PublicOutputDef<PublicOutputs>;
535
593
 
536
594
  /**
537
595
  * @internal Phantom field for structural type extraction.
@@ -545,6 +603,7 @@ export interface PluginFactory<
545
603
  uiServices: UiServices;
546
604
  config: Config;
547
605
  versions: Versions;
606
+ publicOutputs: PublicOutputs;
548
607
  };
549
608
  }
550
609
 
@@ -552,32 +611,42 @@ class PluginModelFactory<
552
611
  Data extends PluginData = PluginData,
553
612
  Params extends PluginParams = undefined,
554
613
  Outputs extends PluginOutputs = PluginOutputs,
614
+ PublicOutputs extends PluginPublicOutputs = PluginPublicOutputs,
555
615
  Config extends PluginConfig = undefined,
556
616
  Versions extends Record<string, unknown> = {},
557
617
  ModelServices = {},
558
618
  UiServices = {},
559
- > implements PluginFactory<Data, Params, Outputs, Config, Versions, ModelServices, UiServices> {
619
+ > implements PluginFactory<
620
+ Data,
621
+ Params,
622
+ Outputs,
623
+ PublicOutputs,
624
+ Config,
625
+ Versions,
626
+ ModelServices,
627
+ UiServices
628
+ > {
560
629
  private readonly name: PluginName;
561
630
  private readonly dataFn: (config?: Config) => DataModel<Data>;
562
631
  private readonly getDefaultDataFn?: (config?: Config) => DataVersioned<Data>;
563
632
  readonly outputs: PluginOutputFns<Data, Params, Outputs, ModelServices, UiServices>;
564
- private readonly outputFlags: Record<string, { withStatus: boolean }>;
565
633
  private readonly featureFlags?: BlockCodeKnownFeatureFlags;
634
+ readonly publicOutputDef: PublicOutputDef<PublicOutputs>;
566
635
 
567
636
  private constructor(options: {
568
637
  name: PluginName;
569
638
  dataFn: (config?: Config) => DataModel<Data>;
570
639
  getDefaultDataFn?: (config?: Config) => DataVersioned<Data>;
571
640
  outputs: PluginOutputFns<Data, Params, Outputs, ModelServices, UiServices>;
572
- outputFlags: Record<string, { withStatus: boolean }>;
573
641
  featureFlags?: BlockCodeKnownFeatureFlags;
642
+ publicOutputDef: PublicOutputDef<PublicOutputs>;
574
643
  }) {
575
644
  this.name = options.name;
576
645
  this.dataFn = options.dataFn;
577
646
  this.getDefaultDataFn = options.getDefaultDataFn;
578
647
  this.outputs = options.outputs;
579
- this.outputFlags = options.outputFlags;
580
648
  this.featureFlags = options.featureFlags;
649
+ this.publicOutputDef = options.publicOutputDef;
581
650
  }
582
651
 
583
652
  /** @internal */
@@ -585,8 +654,9 @@ class PluginModelFactory<
585
654
  Data extends PluginData,
586
655
  Params extends PluginParams,
587
656
  Outputs extends PluginOutputs,
588
- Config extends PluginConfig,
589
- Versions extends Record<string, unknown>,
657
+ PublicOutputs extends PluginPublicOutputs = PluginPublicOutputs,
658
+ Config extends PluginConfig = undefined,
659
+ Versions extends Record<string, unknown> = {},
590
660
  ModelServices = {},
591
661
  UiServices = {},
592
662
  >(options: {
@@ -594,9 +664,18 @@ class PluginModelFactory<
594
664
  dataFn: (config?: Config) => DataModel<Data>;
595
665
  getDefaultDataFn?: (config?: Config) => DataVersioned<Data>;
596
666
  outputs: PluginOutputFns<Data, Params, Outputs, ModelServices, UiServices>;
597
- outputFlags: Record<string, { withStatus: boolean }>;
598
667
  featureFlags?: BlockCodeKnownFeatureFlags;
599
- }): PluginModelFactory<Data, Params, Outputs, Config, Versions, ModelServices, UiServices> {
668
+ publicOutputDef: PublicOutputDef<PublicOutputs>;
669
+ }): PluginModelFactory<
670
+ Data,
671
+ Params,
672
+ Outputs,
673
+ PublicOutputs,
674
+ Config,
675
+ Versions,
676
+ ModelServices,
677
+ UiServices
678
+ > {
600
679
  return new PluginModelFactory(options);
601
680
  }
602
681
 
@@ -604,13 +683,23 @@ class PluginModelFactory<
604
683
  pluginId: Id;
605
684
  transferAt?: V;
606
685
  config?: Config;
607
- }): PluginInstance<Id, Data, Params, Outputs, Versions[V], ModelServices, UiServices> {
686
+ }): PluginInstance<
687
+ Id,
688
+ Data,
689
+ Params,
690
+ Outputs,
691
+ PublicOutputs,
692
+ Versions[V],
693
+ ModelServices,
694
+ UiServices
695
+ > {
608
696
  const transferVersion = options.transferAt ?? NO_TRANSFER_VERSION;
609
697
  return PluginInstance[FROM_BUILDER]<
610
698
  Id,
611
699
  Data,
612
700
  Params,
613
701
  Outputs,
702
+ PublicOutputs,
614
703
  Versions[V],
615
704
  Config,
616
705
  ModelServices,
@@ -621,18 +710,25 @@ class PluginModelFactory<
621
710
  /** @internal Create a PluginModel from config. Config is captured in getDefaultData closure. */
622
711
  [CREATE_PLUGIN_MODEL](
623
712
  config?: Config,
624
- ): PluginModel<Data, Params, Outputs, ModelServices, UiServices> {
713
+ ): PluginModel<Data, Params, Outputs, PublicOutputs, ModelServices, UiServices> {
625
714
  const dataModel = this.dataFn(config);
626
715
  const getDefaultDataFn = this.getDefaultDataFn;
627
- return PluginModel[FROM_BUILDER]<Data, Params, Outputs, ModelServices, UiServices>({
716
+ return PluginModel[FROM_BUILDER]<
717
+ Data,
718
+ Params,
719
+ Outputs,
720
+ PublicOutputs,
721
+ ModelServices,
722
+ UiServices
723
+ >({
628
724
  name: this.name,
629
725
  dataModel,
630
726
  outputs: this.outputs,
631
- outputFlags: this.outputFlags,
632
727
  featureFlags: this.featureFlags,
633
728
  getDefaultData: getDefaultDataFn
634
729
  ? () => getDefaultDataFn(config)
635
730
  : () => dataModel.getDefaultData(),
731
+ publicOutputDef: this.publicOutputDef,
636
732
  });
637
733
  }
638
734
  }
@@ -660,6 +756,7 @@ class PluginModelBuilder<
660
756
  Data extends PluginData = PluginData,
661
757
  Params extends PluginParams = undefined,
662
758
  Outputs extends PluginOutputs = PluginOutputs,
759
+ PublicOutputs extends PluginPublicOutputs = PluginPublicOutputs,
663
760
  Config extends PluginConfig = undefined,
664
761
  Versions extends Record<string, unknown> = {},
665
762
  ModelServices = {},
@@ -669,24 +766,24 @@ class PluginModelBuilder<
669
766
  protected readonly dataFn: (config?: Config) => DataModel<Data>;
670
767
  protected readonly getDefaultDataFn?: (config?: Config) => DataVersioned<Data>;
671
768
  private readonly outputs: PluginOutputFns<Data, Params, Outputs, ModelServices, UiServices>;
672
- private readonly outputFlags: Record<string, { withStatus: boolean }>;
673
769
  protected readonly featureFlags?: BlockCodeKnownFeatureFlags;
770
+ private readonly publicOutputDef: PublicOutputDef<PublicOutputs>;
674
771
 
675
772
  protected constructor(options: {
676
773
  name: PluginName;
677
774
  dataFn: (config?: Config) => DataModel<Data>;
678
775
  getDefaultDataFn?: (config?: Config) => DataVersioned<Data>;
679
776
  outputs?: PluginOutputFns<Data, Params, Outputs, ModelServices, UiServices>;
680
- outputFlags?: Record<string, { withStatus: boolean }>;
681
777
  featureFlags?: BlockCodeKnownFeatureFlags;
778
+ publicOutputDef: PublicOutputDef<PublicOutputs>;
682
779
  }) {
683
780
  this.name = options.name;
684
781
  this.dataFn = options.dataFn;
685
782
  this.getDefaultDataFn = options.getDefaultDataFn;
686
783
  this.outputs =
687
784
  options.outputs ?? ({} as PluginOutputFns<Data, Params, Outputs, ModelServices, UiServices>);
688
- this.outputFlags = options.outputFlags ?? {};
689
785
  this.featureFlags = options.featureFlags;
786
+ this.publicOutputDef = options.publicOutputDef;
690
787
  }
691
788
 
692
789
  /** @internal */
@@ -694,7 +791,8 @@ class PluginModelBuilder<
694
791
  Data extends PluginData,
695
792
  Params extends PluginParams,
696
793
  Outputs extends PluginOutputs,
697
- Config extends PluginConfig,
794
+ PublicOutputs extends PluginPublicOutputs = PluginPublicOutputs,
795
+ Config extends PluginConfig = undefined,
698
796
  Versions extends Record<string, unknown> = {},
699
797
  ModelServices = {},
700
798
  UiServices = {},
@@ -703,22 +801,34 @@ class PluginModelBuilder<
703
801
  dataFn: (config?: Config) => DataModel<Data>;
704
802
  getDefaultDataFn?: (config?: Config) => DataVersioned<Data>;
705
803
  outputs?: PluginOutputFns<Data, Params, Outputs, ModelServices, UiServices>;
706
- outputFlags?: Record<string, { withStatus: boolean }>;
707
804
  featureFlags?: BlockCodeKnownFeatureFlags;
708
- }): PluginModelBuilder<Data, Params, Outputs, Config, Versions, ModelServices, UiServices> {
805
+ publicOutputDef: PublicOutputDef<PublicOutputs>;
806
+ }): PluginModelBuilder<
807
+ Data,
808
+ Params,
809
+ Outputs,
810
+ PublicOutputs,
811
+ Config,
812
+ Versions,
813
+ ModelServices,
814
+ UiServices
815
+ > {
709
816
  return new PluginModelBuilder(options);
710
817
  }
711
818
 
712
819
  /**
713
820
  * Adds an output to the plugin.
821
+ * All plugin outputs are always wrapped with status — the UI receives
822
+ * {@link OutputWithStatus} for every output, allowing it to distinguish
823
+ * between pending, success, and error states.
714
824
  *
715
825
  * @param key - Output name
716
826
  * @param fn - Function that computes the output value from plugin context
717
- * @returns PluginModel with the new output added
827
+ * @returns Builder with the new output added
718
828
  *
719
829
  * @example
720
830
  * .output('model', (ctx) => createModel(ctx.params.columns, ctx.data.state))
721
- * .output('isReady', (ctx) => ctx.params.columns !== undefined)
831
+ * .output('pFrame', (ctx) => ctx.createPFrame([...]))
722
832
  */
723
833
  output<const Key extends string, T>(
724
834
  key: Key,
@@ -730,7 +840,8 @@ class PluginModelBuilder<
730
840
  ): PluginModelBuilder<
731
841
  Data,
732
842
  Params,
733
- Outputs & { [K in Key]: T },
843
+ Outputs & { [K in Key]: OutputWithStatus<T> },
844
+ PublicOutputs,
734
845
  Config,
735
846
  Versions,
736
847
  ModelServices,
@@ -739,7 +850,8 @@ class PluginModelBuilder<
739
850
  return new PluginModelBuilder<
740
851
  Data,
741
852
  Params,
742
- Outputs & { [K in Key]: T },
853
+ Outputs & { [K in Key]: OutputWithStatus<T> },
854
+ PublicOutputs,
743
855
  Config,
744
856
  Versions,
745
857
  ModelServices,
@@ -752,45 +864,38 @@ class PluginModelBuilder<
752
864
  outputs: {
753
865
  ...this.outputs,
754
866
  [key]: fn,
755
- } as {
756
- [K in keyof (Outputs & { [P in Key]: T })]: (
757
- ctx: PluginRenderCtx<
758
- PluginFactoryLike<Data, Params, Record<string, unknown>, ModelServices, UiServices>
759
- >,
760
- ) => (Outputs & { [P in Key]: T })[K];
761
- },
762
- outputFlags: { ...this.outputFlags, [key]: { withStatus: false } },
867
+ } as unknown as PluginOutputFns<
868
+ Data,
869
+ Params,
870
+ Outputs & { [P in Key]: OutputWithStatus<T> },
871
+ ModelServices,
872
+ UiServices
873
+ >,
874
+ publicOutputDef: this.publicOutputDef,
763
875
  });
764
876
  }
765
877
 
766
878
  /**
767
- * Adds an output wrapped with status information to the plugin.
879
+ * Exposes a plugin data field as a public output — accessible without `usePlugin()`
880
+ * via `app.plugins.pluginName.publicOutputs.key`.
768
881
  *
769
- * The UI receives the full {@link OutputWithStatus} object instead of an unwrapped value,
770
- * allowing it to distinguish between pending, success, and error states.
882
+ * The getter runs against the plugin's reactive data object.
883
+ * Public outputs are read-only.
771
884
  *
772
- * @param key - Output name
773
- * @param fn - Function that computes the output value from plugin context
774
- * @returns PluginModel with the new status-wrapped output added
885
+ * @param key - Name of the public output field
886
+ * @param getter - Function deriving the value from plugin data
775
887
  *
776
888
  * @example
777
- * .outputWithStatus('table', (ctx) => {
778
- * const pCols = ctx.params.pFrame?.getPColumns();
779
- * if (pCols === undefined) return undefined;
780
- * return createPlDataTableV2(ctx, pCols, ctx.data.tableState);
781
- * })
889
+ * .publicOutput('selection', (d) => d.selection)
782
890
  */
783
- outputWithStatus<const Key extends string, T>(
891
+ publicOutput<const Key extends string, T>(
784
892
  key: Key,
785
- fn: (
786
- ctx: PluginRenderCtx<
787
- PluginFactoryLike<Data, Params, Record<string, unknown>, ModelServices, UiServices>
788
- >,
789
- ) => T,
893
+ getter: (data: Data) => T,
790
894
  ): PluginModelBuilder<
791
895
  Data,
792
896
  Params,
793
- Outputs & { [K in Key]: OutputWithStatus<T> },
897
+ Outputs,
898
+ PublicOutputs & { [K in Key]: T },
794
899
  Config,
795
900
  Versions,
796
901
  ModelServices,
@@ -799,7 +904,8 @@ class PluginModelBuilder<
799
904
  return new PluginModelBuilder<
800
905
  Data,
801
906
  Params,
802
- Outputs & { [K in Key]: OutputWithStatus<T> },
907
+ Outputs,
908
+ PublicOutputs & { [K in Key]: T },
803
909
  Config,
804
910
  Versions,
805
911
  ModelServices,
@@ -809,17 +915,11 @@ class PluginModelBuilder<
809
915
  dataFn: this.dataFn,
810
916
  getDefaultDataFn: this.getDefaultDataFn,
811
917
  featureFlags: this.featureFlags,
812
- outputs: {
813
- ...this.outputs,
814
- [key]: fn,
815
- } as {
816
- [K in keyof (Outputs & { [P in Key]: OutputWithStatus<T> })]: (
817
- ctx: PluginRenderCtx<
818
- PluginFactoryLike<Data, Params, Record<string, unknown>, ModelServices, UiServices>
819
- >,
820
- ) => (Outputs & { [P in Key]: OutputWithStatus<T> })[K];
821
- },
822
- outputFlags: { ...this.outputFlags, [key]: { withStatus: true } },
918
+ outputs: this.outputs,
919
+ publicOutputDef: {
920
+ ...this.publicOutputDef,
921
+ [key]: { getter: getter as (data: unknown) => unknown },
922
+ } as PublicOutputDef<PublicOutputs & { [K in Key]: T }>,
823
923
  });
824
924
  }
825
925
 
@@ -836,11 +936,21 @@ class PluginModelBuilder<
836
936
  * // Create a named instance:
837
937
  * const table = myPlugin.create({ pluginId: 'mainTable', config: { ... } });
838
938
  */
839
- build(): PluginFactory<Data, Params, Outputs, Config, Versions, ModelServices, UiServices> {
939
+ build(): PluginFactory<
940
+ Data,
941
+ Params,
942
+ Outputs,
943
+ PublicOutputs,
944
+ Config,
945
+ Versions,
946
+ ModelServices,
947
+ UiServices
948
+ > {
840
949
  return PluginModelFactory[FROM_BUILDER]<
841
950
  Data,
842
951
  Params,
843
952
  Outputs,
953
+ PublicOutputs,
844
954
  Config,
845
955
  Versions,
846
956
  ModelServices,
@@ -850,7 +960,7 @@ class PluginModelBuilder<
850
960
  dataFn: this.dataFn,
851
961
  getDefaultDataFn: this.getDefaultDataFn,
852
962
  outputs: this.outputs,
853
- outputFlags: this.outputFlags,
963
+ publicOutputDef: this.publicOutputDef,
854
964
  featureFlags: this.featureFlags,
855
965
  });
856
966
  }
@@ -867,7 +977,7 @@ class PluginModelInitialBuilder<
867
977
  Versions extends Record<string, unknown> = {},
868
978
  ModelServices = {},
869
979
  UiServices = {},
870
- > extends PluginModelBuilder<Data, Params, {}, Config, Versions, ModelServices, UiServices> {
980
+ > extends PluginModelBuilder<Data, Params, {}, {}, Config, Versions, ModelServices, UiServices> {
871
981
  /** @internal */
872
982
  static create<
873
983
  Data extends PluginData,
@@ -881,7 +991,7 @@ class PluginModelInitialBuilder<
881
991
  getDefaultDataFn?: (config?: Config) => DataVersioned<Data>;
882
992
  featureFlags?: BlockCodeKnownFeatureFlags;
883
993
  }): PluginModelInitialBuilder<Data, undefined, Config, Versions, ModelServices, UiServices> {
884
- return new PluginModelInitialBuilder(options);
994
+ return new PluginModelInitialBuilder({ ...options, publicOutputDef: {} });
885
995
  }
886
996
 
887
997
  /**
@@ -897,6 +1007,7 @@ class PluginModelInitialBuilder<
897
1007
  Data,
898
1008
  P,
899
1009
  {},
1010
+ {},
900
1011
  Config,
901
1012
  Versions,
902
1013
  ModelServices,
@@ -906,6 +1017,7 @@ class PluginModelInitialBuilder<
906
1017
  Data,
907
1018
  P,
908
1019
  {},
1020
+ {},
909
1021
  Config,
910
1022
  Versions,
911
1023
  ModelServices,
@@ -915,6 +1027,7 @@ class PluginModelInitialBuilder<
915
1027
  dataFn: this.dataFn,
916
1028
  getDefaultDataFn: this.getDefaultDataFn,
917
1029
  featureFlags: this.featureFlags,
1030
+ publicOutputDef: {},
918
1031
  });
919
1032
  }
920
1033
  }