@uniformdev/mesh-sdk 18.26.0 → 18.27.1-alpha.12

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.
package/dist/index.d.ts CHANGED
@@ -638,7 +638,7 @@ type DataSourceLocation = MeshLocationCore<DataSourceLocationValue, DataSourceLo
638
638
  type ParamTypeLocationMetadata<TParamConfiguration = unknown, TIntegrationConfiguration = unknown> = {
639
639
  rootNode: Omit<RootComponentInstance, 'slots' | '_data'>;
640
640
  parameterConfiguration: TParamConfiguration;
641
- component: Omit<ComponentInstance, 'slots' | '_parameters' | '_id'>;
641
+ component: Omit<ComponentInstance, 'slots'>;
642
642
  componentDefinitions: Record<string, ComponentDefinition | undefined>;
643
643
  parameterDefinition: ComponentDefinitionParameter;
644
644
  /** Settings defined at the integration level (arbitrary type used on settings location) */
@@ -749,19 +749,23 @@ type CloseDialogMessage = {
749
749
  };
750
750
  type GetDataResourceMessage = Pick<DataType, 'path' | 'headers' | 'parameters' | 'body' | 'method'>;
751
751
 
752
+ type MeshSDKEventInterface = Awaited<ReturnType<typeof connectToParent>>['parent'] & {
753
+ initialize: () => Promise<MeshContextData>;
754
+ };
752
755
  /**
753
756
  * Imports the iframe communications library and provides an interface for interacting with
754
757
  * the parent window via said communications library.
755
758
  */
756
- declare function connectToParent({ dialogResponseHandlers, }: {
759
+ declare function connectToParent({ dialogResponseHandlers, onMetadataUpdated, }: {
757
760
  dialogResponseHandlers: DialogResponseHandlers;
761
+ onMetadataUpdated: (metadata: unknown) => void;
758
762
  }): Promise<{
759
763
  initData: MeshContextData;
760
764
  parent: {
761
- resize: (height: CSSHeight) => Promise<void>;
762
- getValue: () => Promise<unknown>;
763
- setValue: (value: unknown, options?: SetValueOptions) => Promise<void>;
764
- getMetadata: () => Promise<unknown>;
765
+ resize: ({ height }: {
766
+ height: CSSHeight;
767
+ }) => Promise<void>;
768
+ setValue: (value: SetValueMessage) => Promise<void>;
765
769
  openDialog: (message: OpenDialogMessage) => Promise<Pick<DialogResponseData, "value" | "dialogId"> | undefined>;
766
770
  closeDialog: (message: CloseDialogMessage) => Promise<void>;
767
771
  getDataResource: <TExpectedResult>(message: GetDataResourceMessage) => Promise<TExpectedResult>;
@@ -877,6 +881,7 @@ type ParamTypeConfigLocationMetadata<TIntegrationConfiguration = unknown> = {
877
881
  settings: TIntegrationConfiguration;
878
882
  /** The Uniform project ID */
879
883
  projectId: string;
884
+ componentDefinition: ComponentDefinition;
880
885
  };
881
886
  type ParamTypeConfigLocation<TParamValue = unknown, TIntegrationConfiguration = unknown> = MeshLocationCore<TParamValue | undefined, ParamTypeConfigLocationMetadata<TIntegrationConfiguration>, TParamValue, 'paramTypeConfig'>;
882
887
 
@@ -936,6 +941,10 @@ type UniformMeshSDKEvents = {
936
941
  onValueChanged: {
937
942
  newValue: unknown;
938
943
  };
944
+ /** Fired when the location metadata value has been updated */
945
+ onMetadataChanged: {
946
+ newValue: unknown;
947
+ };
939
948
  };
940
949
  interface UniformMeshSDK {
941
950
  events: Emitter<UniformMeshSDKEvents>;
@@ -975,4 +984,4 @@ declare function initializeUniformMeshSDK({ autoResizingDisabled, }?: {
975
984
  autoResizingDisabled?: boolean;
976
985
  }): Promise<UniformMeshSDK | undefined>;
977
986
 
978
- export { CSSHeight, CloseDialogMessage, CloseLocationDialogOptions, DataConnectorInfo, DataResourceLocation, DataResourceLocationMetadata, DataSourceLocation, DataSourceLocationMetadata, DataSourceLocationValue, DataTypeInstanceLocation, DataTypeInstanceLocationMetadata, DataTypeLocation, DataTypeLocationMetadata, DataTypeLocationValue, DialogContext, DialogOptions, DialogParamValue, DialogParams, DialogResponseData, DialogResponseHandler, DialogResponseHandlers, DialogType, GetDataResourceLocation, GetDataResourceMessage, IntegrationDefinitionClient, IntegrationDefinitionDeleteParameters, IntegrationDefinitionGetParameters, IntegrationDefinitionGetResponse, IntegrationDefinitionPutParameters, IntegrationDefinitionPutResponse, IntegrationInstallationClient, IntegrationInstallationDeleteParameters, IntegrationInstallationGetParameters, IntegrationInstallationGetResponse, IntegrationInstallationPutParameters, LocationDialogResponse, MeshContextData, MeshLocation, MeshLocationCore, MeshLocationTypes, OpenConfirmationDialogOptions, OpenConfirmationDialogResult, OpenDialogMessage, OpenDialogResult, OpenLocationDialogOptions, ParamTypeConfigLocation, ParamTypeConfigLocationMetadata, ParamTypeLocation, ParamTypeLocationMetadata, SdkWindow, SetLocationFunction, SetValueMessage, SetValueOptions, SettingsLocation, UniformMeshSDK, UniformMeshSDKEvents, ValidationResult, initializeUniformMeshSDK };
987
+ export { CSSHeight, CloseDialogMessage, CloseLocationDialogOptions, DataConnectorInfo, DataResourceLocation, DataResourceLocationMetadata, DataSourceLocation, DataSourceLocationMetadata, DataSourceLocationValue, DataTypeInstanceLocation, DataTypeInstanceLocationMetadata, DataTypeLocation, DataTypeLocationMetadata, DataTypeLocationValue, DialogContext, DialogOptions, DialogParamValue, DialogParams, DialogResponseData, DialogResponseHandler, DialogResponseHandlers, DialogType, GetDataResourceLocation, GetDataResourceMessage, IntegrationDefinitionClient, IntegrationDefinitionDeleteParameters, IntegrationDefinitionGetParameters, IntegrationDefinitionGetResponse, IntegrationDefinitionPutParameters, IntegrationDefinitionPutResponse, IntegrationInstallationClient, IntegrationInstallationDeleteParameters, IntegrationInstallationGetParameters, IntegrationInstallationGetResponse, IntegrationInstallationPutParameters, LocationDialogResponse, MeshContextData, MeshLocation, MeshLocationCore, MeshLocationTypes, MeshSDKEventInterface, OpenConfirmationDialogOptions, OpenConfirmationDialogResult, OpenDialogMessage, OpenDialogResult, OpenLocationDialogOptions, ParamTypeConfigLocation, ParamTypeConfigLocationMetadata, ParamTypeLocation, ParamTypeLocationMetadata, SdkWindow, SetLocationFunction, SetValueMessage, SetValueOptions, SettingsLocation, UniformMeshSDK, UniformMeshSDKEvents, ValidationResult, initializeUniformMeshSDK };
package/dist/index.esm.js CHANGED
@@ -451,7 +451,8 @@ var ChildClient = class extends SharedClient {
451
451
 
452
452
  // src/sdkComms.ts
453
453
  async function connectToParent({
454
- dialogResponseHandlers
454
+ dialogResponseHandlers,
455
+ onMetadataUpdated
455
456
  }) {
456
457
  const client = new ChildClient({ debug: false });
457
458
  window.parent.postMessage("parents just don't understand", "*");
@@ -468,23 +469,15 @@ async function connectToParent({
468
469
  }
469
470
  delete dialogResponseHandlers[data.dialogId];
470
471
  });
472
+ client.onRequest("metadata-value", onMetadataUpdated);
471
473
  return {
472
474
  initData,
473
475
  parent: {
474
- resize: async (height) => {
475
- await client.request("resize", { height });
476
+ resize: async ({ height }) => {
477
+ await client.request("resize", height);
476
478
  },
477
- getValue: async () => {
478
- const res = await client.request("getValue");
479
- return res == null ? void 0 : res.data;
480
- },
481
- setValue: async (value, options) => {
482
- const message = { uniformMeshLocationValue: value, options };
483
- await client.request("setValue", message);
484
- },
485
- getMetadata: async () => {
486
- const res = await client.request("getMetadata");
487
- return res == null ? void 0 : res.data;
479
+ setValue: async (value) => {
480
+ await client.request("setValue", value);
488
481
  },
489
482
  openDialog: async (message) => {
490
483
  var _a;
@@ -594,12 +587,20 @@ async function initializeUniformMeshSDK({
594
587
  );
595
588
  }
596
589
  initializing = true;
590
+ let currentMetadata = void 0;
591
+ const events = mitt();
597
592
  const connectResult = await connectToParent({
598
- dialogResponseHandlers: sdkDialogResponseHandlers
593
+ dialogResponseHandlers: sdkDialogResponseHandlers,
594
+ onMetadataUpdated: (newMeta) => {
595
+ console.debug("Received metadata update", newMeta);
596
+ currentMetadata = newMeta;
597
+ events.emit("onMetadataChanged", { newValue: newMeta });
598
+ }
599
599
  });
600
600
  const { initData: contextData, parent } = connectResult;
601
+ currentMetadata = contextData.locationMetadata;
601
602
  const sdk = {
602
- events: mitt(),
603
+ events,
603
604
  getCurrentLocation: () => {
604
605
  const location = {
605
606
  getDataResource: parent.getDataResource,
@@ -617,21 +618,21 @@ async function initializeUniformMeshSDK({
617
618
  }
618
619
  contextData.locationValue = value;
619
620
  sdk.events.emit("onValueChanged", { newValue: value });
620
- await parent.setValue(value, options);
621
+ await parent.setValue({ uniformMeshLocationValue: value, options });
621
622
  },
622
623
  // DEPRECATED
623
- getMetadata: () => contextData.locationMetadata,
624
- metadata: contextData.locationMetadata,
624
+ getMetadata: () => currentMetadata,
625
+ metadata: currentMetadata,
625
626
  setValidationResult: async (value) => {
626
627
  await location.setValue(contextData.locationValue, value);
627
628
  },
628
629
  dialogContext: contextData.dialogContext ? {
629
630
  ...contextData.dialogContext,
630
- params: contextData.locationMetadata.dialogParams,
631
+ params: currentMetadata.dialogParams,
631
632
  returnDialogValue: async (value) => {
632
633
  contextData.locationValue = value;
633
634
  sdk.events.emit("onValueChanged", { newValue: value });
634
- await parent.setValue(value);
635
+ await parent.setValue({ uniformMeshLocationValue: value });
635
636
  }
636
637
  } : void 0
637
638
  };
@@ -639,7 +640,7 @@ async function initializeUniformMeshSDK({
639
640
  },
640
641
  currentWindow: createSdkWindow({
641
642
  onHeightChange: (height) => {
642
- parent.resize(height);
643
+ parent.resize({ height });
643
644
  },
644
645
  // If we're in a dialog context and the dialog was opened with a specified `contentHeight`,
645
646
  // then we disable autoResizing for the dialog location.
package/dist/index.js CHANGED
@@ -488,7 +488,8 @@ var ChildClient = class extends SharedClient {
488
488
 
489
489
  // src/sdkComms.ts
490
490
  async function connectToParent({
491
- dialogResponseHandlers
491
+ dialogResponseHandlers,
492
+ onMetadataUpdated
492
493
  }) {
493
494
  const client = new ChildClient({ debug: false });
494
495
  window.parent.postMessage("parents just don't understand", "*");
@@ -505,23 +506,15 @@ async function connectToParent({
505
506
  }
506
507
  delete dialogResponseHandlers[data.dialogId];
507
508
  });
509
+ client.onRequest("metadata-value", onMetadataUpdated);
508
510
  return {
509
511
  initData,
510
512
  parent: {
511
- resize: async (height) => {
512
- await client.request("resize", { height });
513
+ resize: async ({ height }) => {
514
+ await client.request("resize", height);
513
515
  },
514
- getValue: async () => {
515
- const res = await client.request("getValue");
516
- return res == null ? void 0 : res.data;
517
- },
518
- setValue: async (value, options) => {
519
- const message = { uniformMeshLocationValue: value, options };
520
- await client.request("setValue", message);
521
- },
522
- getMetadata: async () => {
523
- const res = await client.request("getMetadata");
524
- return res == null ? void 0 : res.data;
516
+ setValue: async (value) => {
517
+ await client.request("setValue", value);
525
518
  },
526
519
  openDialog: async (message) => {
527
520
  var _a;
@@ -631,12 +624,20 @@ async function initializeUniformMeshSDK({
631
624
  );
632
625
  }
633
626
  initializing = true;
627
+ let currentMetadata = void 0;
628
+ const events = (0, import_mitt.default)();
634
629
  const connectResult = await connectToParent({
635
- dialogResponseHandlers: sdkDialogResponseHandlers
630
+ dialogResponseHandlers: sdkDialogResponseHandlers,
631
+ onMetadataUpdated: (newMeta) => {
632
+ console.debug("Received metadata update", newMeta);
633
+ currentMetadata = newMeta;
634
+ events.emit("onMetadataChanged", { newValue: newMeta });
635
+ }
636
636
  });
637
637
  const { initData: contextData, parent } = connectResult;
638
+ currentMetadata = contextData.locationMetadata;
638
639
  const sdk = {
639
- events: (0, import_mitt.default)(),
640
+ events,
640
641
  getCurrentLocation: () => {
641
642
  const location = {
642
643
  getDataResource: parent.getDataResource,
@@ -654,21 +655,21 @@ async function initializeUniformMeshSDK({
654
655
  }
655
656
  contextData.locationValue = value;
656
657
  sdk.events.emit("onValueChanged", { newValue: value });
657
- await parent.setValue(value, options);
658
+ await parent.setValue({ uniformMeshLocationValue: value, options });
658
659
  },
659
660
  // DEPRECATED
660
- getMetadata: () => contextData.locationMetadata,
661
- metadata: contextData.locationMetadata,
661
+ getMetadata: () => currentMetadata,
662
+ metadata: currentMetadata,
662
663
  setValidationResult: async (value) => {
663
664
  await location.setValue(contextData.locationValue, value);
664
665
  },
665
666
  dialogContext: contextData.dialogContext ? {
666
667
  ...contextData.dialogContext,
667
- params: contextData.locationMetadata.dialogParams,
668
+ params: currentMetadata.dialogParams,
668
669
  returnDialogValue: async (value) => {
669
670
  contextData.locationValue = value;
670
671
  sdk.events.emit("onValueChanged", { newValue: value });
671
- await parent.setValue(value);
672
+ await parent.setValue({ uniformMeshLocationValue: value });
672
673
  }
673
674
  } : void 0
674
675
  };
@@ -676,7 +677,7 @@ async function initializeUniformMeshSDK({
676
677
  },
677
678
  currentWindow: createSdkWindow({
678
679
  onHeightChange: (height) => {
679
- parent.resize(height);
680
+ parent.resize({ height });
680
681
  },
681
682
  // If we're in a dialog context and the dialog was opened with a specified `contentHeight`,
682
683
  // then we disable autoResizing for the dialog location.
package/dist/index.mjs CHANGED
@@ -451,7 +451,8 @@ var ChildClient = class extends SharedClient {
451
451
 
452
452
  // src/sdkComms.ts
453
453
  async function connectToParent({
454
- dialogResponseHandlers
454
+ dialogResponseHandlers,
455
+ onMetadataUpdated
455
456
  }) {
456
457
  const client = new ChildClient({ debug: false });
457
458
  window.parent.postMessage("parents just don't understand", "*");
@@ -468,23 +469,15 @@ async function connectToParent({
468
469
  }
469
470
  delete dialogResponseHandlers[data.dialogId];
470
471
  });
472
+ client.onRequest("metadata-value", onMetadataUpdated);
471
473
  return {
472
474
  initData,
473
475
  parent: {
474
- resize: async (height) => {
475
- await client.request("resize", { height });
476
+ resize: async ({ height }) => {
477
+ await client.request("resize", height);
476
478
  },
477
- getValue: async () => {
478
- const res = await client.request("getValue");
479
- return res == null ? void 0 : res.data;
480
- },
481
- setValue: async (value, options) => {
482
- const message = { uniformMeshLocationValue: value, options };
483
- await client.request("setValue", message);
484
- },
485
- getMetadata: async () => {
486
- const res = await client.request("getMetadata");
487
- return res == null ? void 0 : res.data;
479
+ setValue: async (value) => {
480
+ await client.request("setValue", value);
488
481
  },
489
482
  openDialog: async (message) => {
490
483
  var _a;
@@ -594,12 +587,20 @@ async function initializeUniformMeshSDK({
594
587
  );
595
588
  }
596
589
  initializing = true;
590
+ let currentMetadata = void 0;
591
+ const events = mitt();
597
592
  const connectResult = await connectToParent({
598
- dialogResponseHandlers: sdkDialogResponseHandlers
593
+ dialogResponseHandlers: sdkDialogResponseHandlers,
594
+ onMetadataUpdated: (newMeta) => {
595
+ console.debug("Received metadata update", newMeta);
596
+ currentMetadata = newMeta;
597
+ events.emit("onMetadataChanged", { newValue: newMeta });
598
+ }
599
599
  });
600
600
  const { initData: contextData, parent } = connectResult;
601
+ currentMetadata = contextData.locationMetadata;
601
602
  const sdk = {
602
- events: mitt(),
603
+ events,
603
604
  getCurrentLocation: () => {
604
605
  const location = {
605
606
  getDataResource: parent.getDataResource,
@@ -617,21 +618,21 @@ async function initializeUniformMeshSDK({
617
618
  }
618
619
  contextData.locationValue = value;
619
620
  sdk.events.emit("onValueChanged", { newValue: value });
620
- await parent.setValue(value, options);
621
+ await parent.setValue({ uniformMeshLocationValue: value, options });
621
622
  },
622
623
  // DEPRECATED
623
- getMetadata: () => contextData.locationMetadata,
624
- metadata: contextData.locationMetadata,
624
+ getMetadata: () => currentMetadata,
625
+ metadata: currentMetadata,
625
626
  setValidationResult: async (value) => {
626
627
  await location.setValue(contextData.locationValue, value);
627
628
  },
628
629
  dialogContext: contextData.dialogContext ? {
629
630
  ...contextData.dialogContext,
630
- params: contextData.locationMetadata.dialogParams,
631
+ params: currentMetadata.dialogParams,
631
632
  returnDialogValue: async (value) => {
632
633
  contextData.locationValue = value;
633
634
  sdk.events.emit("onValueChanged", { newValue: value });
634
- await parent.setValue(value);
635
+ await parent.setValue({ uniformMeshLocationValue: value });
635
636
  }
636
637
  } : void 0
637
638
  };
@@ -639,7 +640,7 @@ async function initializeUniformMeshSDK({
639
640
  },
640
641
  currentWindow: createSdkWindow({
641
642
  onHeightChange: (height) => {
642
- parent.resize(height);
643
+ parent.resize({ height });
643
644
  },
644
645
  // If we're in a dialog context and the dialog was opened with a specified `contentHeight`,
645
646
  // then we disable autoResizing for the dialog location.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/mesh-sdk",
3
- "version": "18.26.0",
3
+ "version": "18.27.1-alpha.12+a2ae84d4d",
4
4
  "description": "Uniform Mesh Framework SDK",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "main": "./dist/index.js",
@@ -32,9 +32,9 @@
32
32
  "access": "public"
33
33
  },
34
34
  "dependencies": {
35
- "@uniformdev/canvas": "18.26.0",
36
- "@uniformdev/context": "18.26.0",
35
+ "@uniformdev/canvas": "18.27.1-alpha.12+a2ae84d4d",
36
+ "@uniformdev/context": "18.27.1-alpha.12+a2ae84d4d",
37
37
  "mitt": "^3.0.0"
38
38
  },
39
- "gitHead": "776654d5b12c24cf597acd66cde039d6b0111419"
39
+ "gitHead": "a2ae84d4d88dab29f6291a75d7628663dc2df8bd"
40
40
  }