@uniformdev/mesh-sdk 20.49.2 → 20.49.3-alpha.47

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.mjs CHANGED
@@ -7,7 +7,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
7
7
 
8
8
  // src/clients/IntegrationDefinitionClient.ts
9
9
  import { ApiClient } from "@uniformdev/context/api";
10
- var _url;
10
+ var _url, _credentialsUrl;
11
11
  var _IntegrationDefinitionClient = class _IntegrationDefinitionClient extends ApiClient {
12
12
  constructor(options) {
13
13
  super(options);
@@ -18,7 +18,7 @@ var _IntegrationDefinitionClient = class _IntegrationDefinitionClient extends Ap
18
18
  const fetchUri = this.createUrl(__privateGet(_IntegrationDefinitionClient, _url), { ...options, teamId });
19
19
  return await this.apiClient(fetchUri);
20
20
  }
21
- /** Creates or updates a mesh app definition on a team */
21
+ /** Creates or updates a mesh app definition on a team. Identity-delegation credentials must be minted separately via {@link rotateCredential}. */
22
22
  async upsert(body) {
23
23
  const fetchUri = this.createUrl(__privateGet(_IntegrationDefinitionClient, _url));
24
24
  return await this.apiClient(fetchUri, {
@@ -35,9 +35,37 @@ var _IntegrationDefinitionClient = class _IntegrationDefinitionClient extends Ap
35
35
  expectNoContent: true
36
36
  });
37
37
  }
38
+ /**
39
+ * Mints or rotates an identity-delegation credential for an integration definition. The plaintext
40
+ * `appSecret` is returned exactly once and is not retrievable afterwards — Uniform stores only
41
+ * the hash. A successful response invalidates any previously-issued secret of the same kind.
42
+ * Caller must be a team admin.
43
+ */
44
+ async rotateCredential(body) {
45
+ const fetchUri = this.createUrl(__privateGet(_IntegrationDefinitionClient, _credentialsUrl));
46
+ return await this.apiClient(fetchUri, {
47
+ method: "POST",
48
+ body: JSON.stringify({ ...body, teamId: this.options.teamId })
49
+ });
50
+ }
51
+ /**
52
+ * Revokes an identity-delegation credential. Future delegation grants and refreshes will fail
53
+ * until a new credential is minted; in-flight delegation tokens remain valid until natural
54
+ * expiry (up to ~15 minutes). Caller must be a team admin.
55
+ */
56
+ async revokeCredential(body) {
57
+ const fetchUri = this.createUrl(__privateGet(_IntegrationDefinitionClient, _credentialsUrl));
58
+ await this.apiClient(fetchUri, {
59
+ method: "DELETE",
60
+ body: JSON.stringify({ ...body, teamId: this.options.teamId }),
61
+ expectNoContent: true
62
+ });
63
+ }
38
64
  };
39
65
  _url = new WeakMap();
66
+ _credentialsUrl = new WeakMap();
40
67
  __privateAdd(_IntegrationDefinitionClient, _url, "/api/v1/integration-definitions");
68
+ __privateAdd(_IntegrationDefinitionClient, _credentialsUrl, "/api/v1/integration-credentials");
41
69
  var IntegrationDefinitionClient = _IntegrationDefinitionClient;
42
70
 
43
71
  // src/clients/IntegrationInstallationClient.ts
@@ -86,6 +114,14 @@ _url2 = new WeakMap();
86
114
  __privateAdd(_IntegrationInstallationClient, _url2, "/api/v1/integration-installations");
87
115
  var IntegrationInstallationClient = _IntegrationInstallationClient;
88
116
 
117
+ // src/delegation/csrfConstants.ts
118
+ var CSRF_HEADER_NAME = "x-mesh-csrf";
119
+ var CSRF_HEADER_VALUE = "1";
120
+
121
+ // src/delegation/delegationExpired.ts
122
+ var DELEGATION_EXPIRED_CODE = "delegation_expired";
123
+ var DELEGATION_SESSION_EXPIRED_MESSAGE = "Delegation session expired.";
124
+
89
125
  // src/locations/aiAgents.ts
90
126
  var functionCallSystemParameters = ["pageHtml"];
91
127
  function parseFunctionCall(request) {
@@ -131,7 +167,7 @@ var getLogger = (prefix, debug) => {
131
167
  };
132
168
 
133
169
  // src/temp/version.ts
134
- var UNIFORM_MESH_SDK_VERSION = "20.49.2";
170
+ var UNIFORM_MESH_SDK_VERSION = "20.74.3";
135
171
 
136
172
  // src/framepost/constants.ts
137
173
  var DEFAULT_REQUEST_TIMEOUT = 5e3;
@@ -488,54 +524,167 @@ async function connectToParent({
488
524
  });
489
525
  client.onRequest("metadata-value", onMetadataUpdated);
490
526
  client.onRequest("external-value-update", onValueExternallyUpdated);
527
+ const parent = {
528
+ resize: async ({ height }) => {
529
+ await client.request("resize", { height });
530
+ },
531
+ setValue: async (value) => {
532
+ await client.request("setValue", value);
533
+ },
534
+ openDialog: async (message) => {
535
+ const res = await client.request(
536
+ "openDialog",
537
+ message
538
+ );
539
+ const dialogId = res == null ? void 0 : res.dialogId;
540
+ if (!dialogId) {
541
+ return;
542
+ }
543
+ return new Promise((resolve, reject) => {
544
+ dialogResponseHandlers[dialogId] = { resolve, reject };
545
+ });
546
+ },
547
+ closeDialog: async (message) => {
548
+ await client.request("closeDialog", message);
549
+ },
550
+ getDataResource: async (message) => {
551
+ return await client.request("getDataResource", message, {
552
+ timeout: 3e4
553
+ });
554
+ },
555
+ navigate: async (message) => {
556
+ await client.request("navigate", message);
557
+ },
558
+ reloadLocation: async () => {
559
+ await client.request("reload");
560
+ },
561
+ editConnectedData: async (message) => {
562
+ return await client.request(
563
+ "editConnectedData",
564
+ message,
565
+ {
566
+ timeout: (
567
+ // 24 hours in ms
568
+ 864e5
569
+ )
570
+ }
571
+ );
572
+ },
573
+ getSessionToken: async () => {
574
+ return await client.request("getSessionToken", void 0, {
575
+ // Delegation may wait on consent UI + token API; default framepost timeout (5s) is too short.
576
+ timeout: 12e4
577
+ });
578
+ },
579
+ editorState: createEditorStateApi(client)
580
+ };
491
581
  return {
492
582
  initData,
493
- parent: {
494
- resize: async ({ height }) => {
495
- await client.request("resize", { height });
496
- },
497
- setValue: async (value) => {
498
- await client.request("setValue", value);
499
- },
500
- openDialog: async (message) => {
501
- const res = await client.request(
502
- "openDialog",
503
- message
504
- );
505
- const dialogId = res == null ? void 0 : res.dialogId;
506
- if (!dialogId) {
507
- return;
508
- }
509
- return new Promise((resolve, reject) => {
510
- dialogResponseHandlers[dialogId] = { resolve, reject };
511
- });
512
- },
513
- closeDialog: async (message) => {
514
- await client.request("closeDialog", message);
515
- },
516
- getDataResource: async (message) => {
517
- return await client.request("getDataResource", message, {
518
- timeout: 3e4
519
- });
520
- },
521
- navigate: async (message) => {
522
- await client.request("navigate", message);
523
- },
524
- reloadLocation: async () => {
525
- await client.request("reload");
526
- },
527
- editConnectedData: async (message) => {
528
- return await client.request(
529
- "editConnectedData",
530
- message,
531
- {
532
- timeout: (
533
- // 24 hours in ms
534
- 864e5
535
- )
536
- }
537
- );
583
+ parent
584
+ };
585
+ }
586
+ function createEditorStateApi(client) {
587
+ let cachedRootNodeId;
588
+ return {
589
+ async getRootNodeId() {
590
+ if (cachedRootNodeId) {
591
+ return cachedRootNodeId;
538
592
  }
593
+ const result = await client.request("editorState.getRootNodeId");
594
+ cachedRootNodeId = result;
595
+ return result;
596
+ },
597
+ // Read operations
598
+ async exportTree(params) {
599
+ const result = await client.request("editorState.exportTree", params);
600
+ cachedRootNodeId != null ? cachedRootNodeId : cachedRootNodeId = result == null ? void 0 : result._id;
601
+ return result;
602
+ },
603
+ async exportSubtree(params) {
604
+ return await client.request("editorState.exportSubtree", params);
605
+ },
606
+ async exportMetadata() {
607
+ return await client.request("editorState.exportMetadata");
608
+ },
609
+ async exportRootNodeMetadata() {
610
+ return await client.request("editorState.exportRootNodeMetadata");
611
+ },
612
+ async getNodeById(params) {
613
+ return await client.request("editorState.getNodeById", params);
614
+ },
615
+ async getNodeChildren(params) {
616
+ return await client.request("editorState.getNodeChildren", params);
617
+ },
618
+ async getNodeProperty(params) {
619
+ return await client.request("editorState.getNodeProperty", params);
620
+ },
621
+ async getNodeProperties(params) {
622
+ return await client.request("editorState.getNodeProperties", params);
623
+ },
624
+ async getParentInfo(params) {
625
+ return await client.request("editorState.getParentInfo", params);
626
+ },
627
+ // Selection
628
+ async getSelectedNodeId() {
629
+ return await client.request("editorState.getSelectedNodeId");
630
+ },
631
+ async setSelectedNodeId(params) {
632
+ await client.request("editorState.setSelectedNodeId", params);
633
+ },
634
+ async getSelectedParameterId() {
635
+ return await client.request("editorState.getSelectedParameterId");
636
+ },
637
+ async setSelectedParameterId(params) {
638
+ await client.request("editorState.setSelectedParameterId", params);
639
+ },
640
+ async getPristine() {
641
+ return await client.request("editorState.getPristine");
642
+ },
643
+ // Write operations
644
+ async insertNode(params) {
645
+ return await client.request("editorState.insertNode", params);
646
+ },
647
+ async deleteNode(params) {
648
+ await client.request("editorState.deleteNode", params);
649
+ },
650
+ async moveNode(params) {
651
+ await client.request("editorState.moveNode", params);
652
+ },
653
+ async updateNodeProperty(params) {
654
+ await client.request("editorState.updateNodeProperty", params);
655
+ },
656
+ async updateRootMetadata(params) {
657
+ await client.request("editorState.updateRootMetadata", params);
658
+ },
659
+ async updateRootNode(params) {
660
+ await client.request("editorState.updateRootNode", params);
661
+ },
662
+ // Pattern operations
663
+ async insertPattern(params) {
664
+ return await client.request("editorState.insertPattern", params);
665
+ },
666
+ async isPatternPropertyOverridden(params) {
667
+ return await client.request("editorState.isPatternPropertyOverridden", params);
668
+ },
669
+ async resetPatternPropertyOverride(params) {
670
+ await client.request("editorState.resetPatternPropertyOverride", params);
671
+ },
672
+ async setPropertyLocalizability(params) {
673
+ await client.request("editorState.setPropertyLocalizability", params);
674
+ },
675
+ // Locale operations
676
+ async enableLocale(params) {
677
+ await client.request("editorState.enableLocale", params);
678
+ },
679
+ async disableLocale(params) {
680
+ await client.request("editorState.disableLocale", params);
681
+ },
682
+ async setCurrentLocale(params) {
683
+ await client.request("editorState.setCurrentLocale", params);
684
+ },
685
+ // Dynamic input operations
686
+ async setDynamicInputPreviewValue(params) {
687
+ await client.request("editorState.setDynamicInputPreviewValue", params);
539
688
  }
540
689
  };
541
690
  }
@@ -733,7 +882,8 @@ async function initializeUniformMeshSDK({
733
882
  sdk.events.emit("onValueChanged", { newValue: value });
734
883
  await parent.setValue({ uniformMeshLocationValue: value, closeDialog: true });
735
884
  }
736
- } : void 0
885
+ } : void 0,
886
+ editorState: parent.editorState
737
887
  };
738
888
  return location;
739
889
  },
@@ -816,7 +966,8 @@ async function initializeUniformMeshSDK({
816
966
  },
817
967
  closeCurrentLocationDialog: async () => {
818
968
  await parent.closeDialog({ dialogId: void 0, dialogType: "currentLocation" });
819
- }
969
+ },
970
+ getSessionToken: () => parent.getSessionToken()
820
971
  };
821
972
  window.UniformMeshSDK = sdk;
822
973
  initializing = false;
@@ -838,6 +989,10 @@ var hasRole = (role, user) => {
838
989
  return user.roles.some((userRole) => userRole.name === role || userRole.id === role);
839
990
  };
840
991
  export {
992
+ CSRF_HEADER_NAME,
993
+ CSRF_HEADER_VALUE,
994
+ DELEGATION_EXPIRED_CODE,
995
+ DELEGATION_SESSION_EXPIRED_MESSAGE,
841
996
  IntegrationDefinitionClient,
842
997
  IntegrationInstallationClient,
843
998
  functionCallSystemParameters,