@topolo/sdk 0.2.8 → 0.2.9

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.cjs CHANGED
@@ -26,6 +26,7 @@ __export(index_exports, {
26
26
  CrmModule: () => CrmModule,
27
27
  DEFAULT_SERVICE_URLS: () => DEFAULT_SERVICE_URLS,
28
28
  IdentityModule: () => IdentityModule,
29
+ P2PModule: () => P2PModule,
29
30
  PLATFORM_SERVICE_IDS: () => PLATFORM_SERVICE_IDS,
30
31
  TOPOLO_WIDGET_ENDPOINT: () => TOPOLO_WIDGET_ENDPOINT,
31
32
  TOPOLO_WIDGET_REFRESH_INTERVAL_MS: () => TOPOLO_WIDGET_REFRESH_INTERVAL_MS,
@@ -112,39 +113,41 @@ var TopoloHttpError = class extends TopoloSdkError {
112
113
 
113
114
  // src/services.generated.ts
114
115
  var SERVICES = {
115
- agent: "https://topolo-agent-worker.topolo.workers.dev",
116
+ agent: "https://agent-api.topolo.app",
116
117
  auth: "https://auth.topolo.app",
117
118
  books: "https://books.topolo.app",
118
119
  bugfix: "https://bugfix.topolo.app",
119
- bytes: "https://r2-media-manager-worker.topolo.workers.dev",
120
+ bytes: "https://bytes-api.topolo.app",
120
121
  calendar: "https://calendar.topolo.app",
121
- capacity: "https://topolo-capacity.topolo.workers.dev",
122
+ capacity: "https://capacity.topolo.app",
122
123
  chat: "https://chat.topolo.app",
123
- commerce: "https://topolo-commerce-api.topolo.workers.dev",
124
+ commerce: "https://commerce-api.topolo.app",
124
125
  compose: "https://compose.topolo.app",
125
126
  crm: "https://crm-api.topolo.app",
126
127
  customer_success: "https://customer-success.topolo.app",
127
- feed: "https://topolo-feed-api.topolo.app",
128
+ feed: "https://feed-api.topolo.app",
128
129
  flow: "https://flow.topolo.app",
129
- forecast: "https://forecast-worker-production.topolo.workers.dev",
130
+ forecast: "https://forecast-api.topolo.app",
130
131
  forms: "https://forms.topolo.app",
131
132
  insights: "https://insights.topolo.app",
132
133
  inventory: "https://inventory.topolo.app",
133
- learn: "https://topololearn-api.topolo.workers.dev",
134
+ learn: "https://learn-api.topolo.app",
134
135
  mail: "https://mail.topolo.app",
135
- mdm: "https://topolo-mdm-api.topolo.app",
136
+ mdm: "https://mdm-api.topolo.app",
136
137
  messaging: "https://messages.topolo.app",
137
- nexus: "https://topolo-nexus-gateway.topolo.workers.dev",
138
+ nexus: "https://nexus-api.topolo.app",
138
139
  notify: "https://notify.topolo.app",
139
140
  one: "https://one.topolo.app",
140
- pay: "https://topolo-pay.topolo.workers.dev",
141
+ "one.ai": "https://ai.one.topolo.app",
142
+ p2p: "https://p2p.topolo.app",
143
+ pay: "https://pay.topolo.app",
141
144
  people: "https://people.topolo.app",
142
145
  "quro.api": "https://api.ol0.me",
143
146
  "quro.redirect": "https://ol0.me",
144
147
  roadmapper: "https://roadmapper-api.topolo.app",
145
148
  sign: "https://sign.topolo.app",
146
- social_studio: "https://topolo-social-studio-api.topolo.workers.dev",
147
- socialize: "https://socialize-prod-api.topolo.workers.dev",
149
+ social_studio: "https://studio-api.topolo.app",
150
+ socialize: "https://socialize-api.topolo.app",
148
151
  support: "https://support.topolo.app",
149
152
  survey: "https://survey.topolo.app",
150
153
  voice: "https://voice.topolo.app",
@@ -160,6 +163,7 @@ var PLATFORM_SERVICE_IDS = {
160
163
  insights: "srv_topolo_insights",
161
164
  inventory: "srv_topolo_inventory",
162
165
  notify: "svc_topolo_notify",
166
+ p2p: "srv_topolo_p2p",
163
167
  people: "srv_topolo_people",
164
168
  sign: "srv_topolo_sign",
165
169
  survey: "srv_topolo_survey",
@@ -180,7 +184,9 @@ var APPLICATIONS = {
180
184
  "name": "topoloadmin",
181
185
  "kind": "pages",
182
186
  "apiUrl": null,
183
- "domains": [],
187
+ "domains": [
188
+ "admin.topolo.app"
189
+ ],
184
190
  "routes": [],
185
191
  "serviceId": null
186
192
  }
@@ -200,15 +206,19 @@ var APPLICATIONS = {
200
206
  "name": "topolo-agent",
201
207
  "kind": "pages",
202
208
  "apiUrl": null,
203
- "domains": [],
209
+ "domains": [
210
+ "agent.topolo.app"
211
+ ],
204
212
  "routes": [],
205
213
  "serviceId": null
206
214
  },
207
215
  {
208
216
  "name": "topolo-agent-worker",
209
217
  "kind": "worker",
210
- "apiUrl": "https://topolo-agent-worker.topolo.workers.dev",
211
- "domains": [],
218
+ "apiUrl": "https://agent-api.topolo.app",
219
+ "domains": [
220
+ "agent-api.topolo.app"
221
+ ],
212
222
  "routes": [],
213
223
  "serviceId": "agent"
214
224
  }
@@ -300,15 +310,19 @@ var APPLICATIONS = {
300
310
  "name": "bytes",
301
311
  "kind": "pages",
302
312
  "apiUrl": null,
303
- "domains": [],
313
+ "domains": [
314
+ "bytes.topolo.app"
315
+ ],
304
316
  "routes": [],
305
317
  "serviceId": null
306
318
  },
307
319
  {
308
320
  "name": "r2-media-manager-worker",
309
321
  "kind": "worker",
310
- "apiUrl": "https://r2-media-manager-worker.topolo.workers.dev",
311
- "domains": [],
322
+ "apiUrl": "https://bytes-api.topolo.app",
323
+ "domains": [
324
+ "bytes-api.topolo.app"
325
+ ],
312
326
  "routes": [],
313
327
  "serviceId": "bytes"
314
328
  }
@@ -351,10 +365,9 @@ var APPLICATIONS = {
351
365
  {
352
366
  "name": "topolo-capacity",
353
367
  "kind": "worker",
354
- "apiUrl": "https://topolo-capacity.topolo.workers.dev",
368
+ "apiUrl": "https://capacity.topolo.app",
355
369
  "domains": [
356
- "capacity.topolo.app",
357
- "topolo-capacity.topolo.workers.dev"
370
+ "capacity.topolo.app"
358
371
  ],
359
372
  "routes": [],
360
373
  "serviceId": "capacity"
@@ -416,9 +429,9 @@ var APPLICATIONS = {
416
429
  {
417
430
  "name": "topolo-commerce-api",
418
431
  "kind": "worker",
419
- "apiUrl": "https://topolo-commerce-api.topolo.workers.dev",
432
+ "apiUrl": "https://commerce-api.topolo.app",
420
433
  "domains": [
421
- "topolo-commerce-api.topolo.workers.dev"
434
+ "commerce-api.topolo.app"
422
435
  ],
423
436
  "routes": [],
424
437
  "serviceId": "commerce"
@@ -428,8 +441,7 @@ var APPLICATIONS = {
428
441
  "kind": "pages",
429
442
  "apiUrl": null,
430
443
  "domains": [
431
- "guest.topolo.app",
432
- "topolo-commerce-guest-web.pages.dev"
444
+ "guest.topolo.app"
433
445
  ],
434
446
  "routes": [],
435
447
  "serviceId": null
@@ -439,8 +451,7 @@ var APPLICATIONS = {
439
451
  "kind": "pages",
440
452
  "apiUrl": null,
441
453
  "domains": [
442
- "commerce.topolo.app",
443
- "topolo-commerce-ops-web.pages.dev"
454
+ "commerce.topolo.app"
444
455
  ],
445
456
  "routes": [],
446
457
  "serviceId": null
@@ -450,8 +461,7 @@ var APPLICATIONS = {
450
461
  "kind": "pages",
451
462
  "apiUrl": null,
452
463
  "domains": [
453
- "station-commerce.topolo.app",
454
- "topolo-commerce-station-web.pages.dev"
464
+ "station-commerce.topolo.app"
455
465
  ],
456
466
  "routes": [],
457
467
  "serviceId": null
@@ -496,7 +506,9 @@ var APPLICATIONS = {
496
506
  "name": "topolo-crm-frontend",
497
507
  "kind": "pages",
498
508
  "apiUrl": null,
499
- "domains": [],
509
+ "domains": [
510
+ "crm.topolo.app"
511
+ ],
500
512
  "routes": [],
501
513
  "serviceId": null
502
514
  },
@@ -504,7 +516,9 @@ var APPLICATIONS = {
504
516
  "name": "topolo-crm-worker",
505
517
  "kind": "worker",
506
518
  "apiUrl": "https://crm-api.topolo.app",
507
- "domains": [],
519
+ "domains": [
520
+ "crm-api.topolo.app"
521
+ ],
508
522
  "routes": [],
509
523
  "serviceId": "crm"
510
524
  }
@@ -578,8 +592,8 @@ var APPLICATIONS = {
578
592
  "id": "feed",
579
593
  "appDir": "TopoloFeed",
580
594
  "name": "TopoloFeed",
581
- "packageName": null,
582
- "productionUrl": "https://topolo-feed-api.topolo.app",
595
+ "packageName": "topolo-feed",
596
+ "productionUrl": "https://feed-api.topolo.app",
583
597
  "services": [
584
598
  "feed"
585
599
  ],
@@ -587,24 +601,24 @@ var APPLICATIONS = {
587
601
  {
588
602
  "name": "topolo-feed-analytics-api",
589
603
  "kind": "worker",
590
- "apiUrl": "https://topolo-feed-analytics-api.topolo.app",
604
+ "apiUrl": "https://feed-analytics-api.topolo.app",
591
605
  "domains": [
592
- "topolo-feed-analytics-api.topolo.app"
606
+ "feed-analytics-api.topolo.app"
593
607
  ],
594
608
  "routes": [
595
- "topolo-feed-analytics-api.topolo.app"
609
+ "feed-analytics-api.topolo.app"
596
610
  ],
597
611
  "serviceId": null
598
612
  },
599
613
  {
600
614
  "name": "topolo-feed-api",
601
615
  "kind": "worker",
602
- "apiUrl": "https://topolo-feed-api.topolo.app",
616
+ "apiUrl": "https://feed-api.topolo.app",
603
617
  "domains": [
604
- "topolo-feed-api.topolo.app"
618
+ "feed-api.topolo.app"
605
619
  ],
606
620
  "routes": [
607
- "topolo-feed-api.topolo.app"
621
+ "feed-api.topolo.app"
608
622
  ],
609
623
  "serviceId": "feed"
610
624
  }
@@ -648,15 +662,19 @@ var APPLICATIONS = {
648
662
  "name": "forecast",
649
663
  "kind": "pages",
650
664
  "apiUrl": null,
651
- "domains": [],
665
+ "domains": [
666
+ "forecast.topolo.app"
667
+ ],
652
668
  "routes": [],
653
669
  "serviceId": null
654
670
  },
655
671
  {
656
672
  "name": "forecast-worker-production",
657
673
  "kind": "worker",
658
- "apiUrl": "https://forecast-worker-production.topolo.workers.dev",
659
- "domains": [],
674
+ "apiUrl": "https://forecast-api.topolo.app",
675
+ "domains": [
676
+ "forecast-api.topolo.app"
677
+ ],
660
678
  "routes": [],
661
679
  "serviceId": "forecast"
662
680
  }
@@ -757,9 +775,9 @@ var APPLICATIONS = {
757
775
  {
758
776
  "name": "topololearn-api",
759
777
  "kind": "worker",
760
- "apiUrl": "https://topololearn-api.topolo.workers.dev",
778
+ "apiUrl": "https://learn-api.topolo.app",
761
779
  "domains": [
762
- "topololearn-api.topolo.workers.dev"
780
+ "learn-api.topolo.app"
763
781
  ],
764
782
  "routes": [],
765
783
  "serviceId": "learn"
@@ -812,12 +830,12 @@ var APPLICATIONS = {
812
830
  {
813
831
  "name": "topolo-mdm-api",
814
832
  "kind": "worker",
815
- "apiUrl": "https://topolo-mdm-api.topolo.app",
833
+ "apiUrl": "https://mdm-api.topolo.app",
816
834
  "domains": [
817
- "topolo-mdm-api.topolo.app"
835
+ "mdm-api.topolo.app"
818
836
  ],
819
837
  "routes": [
820
- "topolo-mdm-api.topolo.app"
838
+ "mdm-api.topolo.app"
821
839
  ],
822
840
  "serviceId": "mdm"
823
841
  },
@@ -826,8 +844,7 @@ var APPLICATIONS = {
826
844
  "kind": "pages",
827
845
  "apiUrl": null,
828
846
  "domains": [
829
- "mdm.topolo.app",
830
- "topolo-mdm-console.pages.dev"
847
+ "mdm.topolo.app"
831
848
  ],
832
849
  "routes": [
833
850
  "mdm.topolo.app"
@@ -881,8 +898,7 @@ var APPLICATIONS = {
881
898
  "kind": "pages",
882
899
  "apiUrl": null,
883
900
  "domains": [
884
- "nexus.topolo.app",
885
- "topolo-nexus-dashboard.pages.dev"
901
+ "nexus.topolo.app"
886
902
  ],
887
903
  "routes": [],
888
904
  "serviceId": null
@@ -890,9 +906,9 @@ var APPLICATIONS = {
890
906
  {
891
907
  "name": "topolo-nexus-gateway",
892
908
  "kind": "worker",
893
- "apiUrl": "https://topolo-nexus-gateway.topolo.workers.dev",
909
+ "apiUrl": "https://nexus-api.topolo.app",
894
910
  "domains": [
895
- "topolo-nexus-gateway.topolo.workers.dev"
911
+ "nexus-api.topolo.app"
896
912
  ],
897
913
  "routes": [],
898
914
  "serviceId": "nexus"
@@ -930,25 +946,26 @@ var APPLICATIONS = {
930
946
  "packageName": "topolo-oneclick-sso",
931
947
  "productionUrl": "https://one.topolo.app",
932
948
  "services": [
933
- "one"
949
+ "one",
950
+ "one.ai"
934
951
  ],
935
952
  "deployTargets": [
936
953
  {
937
954
  "name": "ai-chat-rag",
938
955
  "kind": "worker",
939
- "apiUrl": null,
956
+ "apiUrl": "https://ai.one.topolo.app",
940
957
  "domains": [
941
- "ai-chat-rag.topolo.workers.dev"
958
+ "ai.one.topolo.app"
942
959
  ],
943
960
  "routes": [],
944
- "serviceId": null
961
+ "serviceId": "one.ai"
945
962
  },
946
963
  {
947
964
  "name": "topoloone",
948
965
  "kind": "pages",
949
966
  "apiUrl": null,
950
967
  "domains": [
951
- "oneclick-dashboard.pages.dev"
968
+ "one.topolo.app"
952
969
  ],
953
970
  "routes": [],
954
971
  "serviceId": null
@@ -969,7 +986,9 @@ var APPLICATIONS = {
969
986
  "name": "topoloone-worker",
970
987
  "kind": "worker",
971
988
  "apiUrl": "https://one.topolo.app",
972
- "domains": [],
989
+ "domains": [
990
+ "one.topolo.app"
991
+ ],
973
992
  "routes": [
974
993
  "one.topolo.app/*"
975
994
  ],
@@ -977,6 +996,30 @@ var APPLICATIONS = {
977
996
  }
978
997
  ]
979
998
  },
999
+ "p2p": {
1000
+ "id": "p2p",
1001
+ "appDir": "TopoloP2P",
1002
+ "name": "topolo-p2p",
1003
+ "packageName": "topolo-p2p",
1004
+ "productionUrl": "https://p2p.topolo.app",
1005
+ "services": [
1006
+ "p2p"
1007
+ ],
1008
+ "deployTargets": [
1009
+ {
1010
+ "name": "topolo-p2p",
1011
+ "kind": "worker",
1012
+ "apiUrl": "https://p2p.topolo.app",
1013
+ "domains": [
1014
+ "p2p.topolo.app"
1015
+ ],
1016
+ "routes": [
1017
+ "p2p.topolo.app"
1018
+ ],
1019
+ "serviceId": "p2p"
1020
+ }
1021
+ ]
1022
+ },
980
1023
  "pay": {
981
1024
  "id": "pay",
982
1025
  "appDir": "TopoloPay",
@@ -990,8 +1033,10 @@ var APPLICATIONS = {
990
1033
  {
991
1034
  "name": "topolo-pay",
992
1035
  "kind": "worker",
993
- "apiUrl": "https://topolo-pay.topolo.workers.dev",
994
- "domains": [],
1036
+ "apiUrl": "https://pay.topolo.app",
1037
+ "domains": [
1038
+ "pay.topolo.app"
1039
+ ],
995
1040
  "routes": [],
996
1041
  "serviceId": "pay"
997
1042
  }
@@ -1036,7 +1081,9 @@ var APPLICATIONS = {
1036
1081
  "name": "quro-api",
1037
1082
  "kind": "worker",
1038
1083
  "apiUrl": "https://api.ol0.me",
1039
- "domains": [],
1084
+ "domains": [
1085
+ "api.ol0.me"
1086
+ ],
1040
1087
  "routes": [],
1041
1088
  "serviceId": "quro.api"
1042
1089
  },
@@ -1044,7 +1091,9 @@ var APPLICATIONS = {
1044
1091
  "name": "quro-redirect-system",
1045
1092
  "kind": "worker",
1046
1093
  "apiUrl": "https://ol0.me",
1047
- "domains": [],
1094
+ "domains": [
1095
+ "ol0.me"
1096
+ ],
1048
1097
  "routes": [
1049
1098
  "ol0.me/*"
1050
1099
  ],
@@ -1054,7 +1103,9 @@ var APPLICATIONS = {
1054
1103
  "name": "quro-ui",
1055
1104
  "kind": "pages",
1056
1105
  "apiUrl": null,
1057
- "domains": [],
1106
+ "domains": [
1107
+ "quro.topolo.app"
1108
+ ],
1058
1109
  "routes": [],
1059
1110
  "serviceId": null
1060
1111
  }
@@ -1130,15 +1181,19 @@ var APPLICATIONS = {
1130
1181
  "name": "topolo-social-studio",
1131
1182
  "kind": "pages",
1132
1183
  "apiUrl": null,
1133
- "domains": [],
1184
+ "domains": [
1185
+ "studio.topolo.app"
1186
+ ],
1134
1187
  "routes": [],
1135
1188
  "serviceId": null
1136
1189
  },
1137
1190
  {
1138
1191
  "name": "topolo-social-studio-api",
1139
1192
  "kind": "worker",
1140
- "apiUrl": "https://topolo-social-studio-api.topolo.workers.dev",
1141
- "domains": [],
1193
+ "apiUrl": "https://studio-api.topolo.app",
1194
+ "domains": [
1195
+ "studio-api.topolo.app"
1196
+ ],
1142
1197
  "routes": [],
1143
1198
  "serviceId": "social_studio"
1144
1199
  },
@@ -1166,15 +1221,19 @@ var APPLICATIONS = {
1166
1221
  "name": "socialize",
1167
1222
  "kind": "pages",
1168
1223
  "apiUrl": null,
1169
- "domains": [],
1224
+ "domains": [
1225
+ "socialize.topolo.app"
1226
+ ],
1170
1227
  "routes": [],
1171
1228
  "serviceId": null
1172
1229
  },
1173
1230
  {
1174
1231
  "name": "socialize-prod-api",
1175
1232
  "kind": "worker",
1176
- "apiUrl": "https://socialize-prod-api.topolo.workers.dev",
1177
- "domains": [],
1233
+ "apiUrl": "https://socialize-api.topolo.app",
1234
+ "domains": [
1235
+ "socialize-api.topolo.app"
1236
+ ],
1178
1237
  "routes": [],
1179
1238
  "serviceId": "socialize"
1180
1239
  },
@@ -1949,6 +2008,222 @@ var IdentityModule = class {
1949
2008
  }
1950
2009
  };
1951
2010
 
2011
+ // src/modules/p2p.ts
2012
+ var P2PModule = class {
2013
+ constructor(client) {
2014
+ this.client = client;
2015
+ }
2016
+ client;
2017
+ // Directory ----------------------------------------------------------------
2018
+ async listDirectory(options = {}) {
2019
+ const res = await this.client.request({
2020
+ service: "p2p",
2021
+ path: "/api/directory/capabilities",
2022
+ query: { limit: options.limit }
2023
+ });
2024
+ return res.data.capabilities;
2025
+ }
2026
+ async getCapability(capabilityId) {
2027
+ if (!capabilityId) throw new Error("capabilityId is required");
2028
+ try {
2029
+ const res = await this.client.request({
2030
+ service: "p2p",
2031
+ path: `/api/directory/capabilities/${encodeURIComponent(capabilityId)}`
2032
+ });
2033
+ return res.data.capability;
2034
+ } catch (err) {
2035
+ if (isNotFound(err)) return null;
2036
+ throw err;
2037
+ }
2038
+ }
2039
+ async publishCapability(input) {
2040
+ const res = await this.client.request({
2041
+ service: "p2p",
2042
+ method: "POST",
2043
+ path: "/api/p2p/internal/capabilities/sync",
2044
+ body: {
2045
+ capability_id: input.capability_id,
2046
+ publisher_org_id: input.publisher_org_id,
2047
+ app_id: input.app_id,
2048
+ service_id: input.service_id,
2049
+ name: input.name,
2050
+ description: input.description,
2051
+ category: input.category,
2052
+ pricing_model: input.pricing_model,
2053
+ pricing_amount_minor: input.pricing_amount_minor ?? null,
2054
+ currency: input.currency ?? null,
2055
+ requires_human_approval: input.requires_human_approval ?? false,
2056
+ supported_contexts: input.supported_contexts,
2057
+ trust_level: input.trust_level ?? "standard",
2058
+ public_directory_visible: input.public_directory_visible,
2059
+ source_revision: input.source_revision,
2060
+ input_schema: input.input_schema ?? {},
2061
+ output_schema: input.output_schema ?? {},
2062
+ acting_for_org_id: input.acting_for_org_id ?? input.publisher_org_id
2063
+ },
2064
+ confirm: true
2065
+ });
2066
+ return res.data.capability;
2067
+ }
2068
+ // Actions ------------------------------------------------------------------
2069
+ async listActions(options = {}) {
2070
+ const res = await this.client.request({
2071
+ service: "p2p",
2072
+ path: "/api/actions",
2073
+ query: { state: options.state, limit: options.limit }
2074
+ });
2075
+ return res.data.actions;
2076
+ }
2077
+ async getAction(requestId) {
2078
+ if (!requestId) throw new Error("requestId is required");
2079
+ try {
2080
+ const res = await this.client.request({
2081
+ service: "p2p",
2082
+ path: `/api/actions/${encodeURIComponent(requestId)}`
2083
+ });
2084
+ return res.data;
2085
+ } catch (err) {
2086
+ if (isNotFound(err)) return null;
2087
+ throw err;
2088
+ }
2089
+ }
2090
+ async requestAction(input) {
2091
+ if (!input.capability_id) throw new Error("capability_id is required");
2092
+ if (!input.idempotency_key) throw new Error("idempotency_key is required");
2093
+ const res = await this.client.request({
2094
+ service: "p2p",
2095
+ method: "POST",
2096
+ path: "/api/actions/request",
2097
+ body: {
2098
+ capability_id: input.capability_id,
2099
+ idempotency_key: input.idempotency_key,
2100
+ inputs: input.inputs ?? {}
2101
+ },
2102
+ confirm: true
2103
+ });
2104
+ return res.data;
2105
+ }
2106
+ async respondAction(requestId, response, extras = {}) {
2107
+ if (!requestId) throw new Error("requestId is required");
2108
+ const res = await this.client.request({
2109
+ service: "p2p",
2110
+ method: "POST",
2111
+ path: `/api/actions/${encodeURIComponent(requestId)}/respond`,
2112
+ body: { response, ...extras },
2113
+ confirm: true
2114
+ });
2115
+ return res.data.request;
2116
+ }
2117
+ async completeAction(requestId, result = {}) {
2118
+ if (!requestId) throw new Error("requestId is required");
2119
+ const res = await this.client.request({
2120
+ service: "p2p",
2121
+ method: "POST",
2122
+ path: `/api/actions/${encodeURIComponent(requestId)}/complete`,
2123
+ body: { result },
2124
+ confirm: true
2125
+ });
2126
+ return res.data.request;
2127
+ }
2128
+ async disputeAction(requestId, reason) {
2129
+ if (!requestId) throw new Error("requestId is required");
2130
+ const res = await this.client.request({
2131
+ service: "p2p",
2132
+ method: "POST",
2133
+ path: `/api/actions/${encodeURIComponent(requestId)}/dispute`,
2134
+ body: { reason },
2135
+ confirm: true
2136
+ });
2137
+ return res.data.request;
2138
+ }
2139
+ // Policy + connections + ledger + settlement -----------------------------
2140
+ async getPolicy() {
2141
+ const res = await this.client.request({
2142
+ service: "p2p",
2143
+ path: "/api/policies"
2144
+ });
2145
+ return res.data.policy;
2146
+ }
2147
+ async updatePolicy(policy) {
2148
+ const res = await this.client.request({
2149
+ service: "p2p",
2150
+ method: "PUT",
2151
+ path: "/api/policies",
2152
+ body: policy,
2153
+ confirm: true
2154
+ });
2155
+ return res.data.policy;
2156
+ }
2157
+ async listConnections() {
2158
+ const res = await this.client.request({
2159
+ service: "p2p",
2160
+ path: "/api/connections"
2161
+ });
2162
+ return res.data.connections;
2163
+ }
2164
+ async createConnection(counterpartyOrgId, options = {}) {
2165
+ if (!counterpartyOrgId) throw new Error("counterpartyOrgId is required");
2166
+ const res = await this.client.request({
2167
+ service: "p2p",
2168
+ method: "POST",
2169
+ path: "/api/connections",
2170
+ body: { counterparty_org_id: counterpartyOrgId, status: options.status ?? "active" },
2171
+ confirm: true
2172
+ });
2173
+ return res.data.connection;
2174
+ }
2175
+ async revokeConnection(connectionId) {
2176
+ if (!connectionId) throw new Error("connectionId is required");
2177
+ await this.client.request({
2178
+ service: "p2p",
2179
+ method: "DELETE",
2180
+ path: `/api/connections/${encodeURIComponent(connectionId)}`,
2181
+ confirm: true
2182
+ });
2183
+ }
2184
+ async listLedger() {
2185
+ const res = await this.client.request({
2186
+ service: "p2p",
2187
+ path: "/api/ledger"
2188
+ });
2189
+ return res.data.ledger_entries;
2190
+ }
2191
+ async previewSettlements(filters = {}) {
2192
+ const res = await this.client.request({
2193
+ service: "p2p",
2194
+ method: "POST",
2195
+ path: "/api/settlements/preview",
2196
+ body: filters,
2197
+ confirm: true
2198
+ });
2199
+ return res.data.groups;
2200
+ }
2201
+ async createSettlement(filters = {}) {
2202
+ const res = await this.client.request({
2203
+ service: "p2p",
2204
+ method: "POST",
2205
+ path: "/api/settlements/create",
2206
+ body: { trigger: "manual", ...filters },
2207
+ confirm: true
2208
+ });
2209
+ return res.data;
2210
+ }
2211
+ async releaseHold(holdId, resolution, options = {}) {
2212
+ if (!holdId) throw new Error("holdId is required");
2213
+ const res = await this.client.request({
2214
+ service: "p2p",
2215
+ method: "POST",
2216
+ path: `/api/holds/${encodeURIComponent(holdId)}/release`,
2217
+ body: { resolution, reason: options.reason ?? null },
2218
+ confirm: true
2219
+ });
2220
+ return res.data;
2221
+ }
2222
+ };
2223
+ function isNotFound(err) {
2224
+ return Boolean(err && typeof err === "object" && "status" in err && err.status === 404);
2225
+ }
2226
+
1952
2227
  // src/oauth.ts
1953
2228
  var DEVICE_GRANT = "urn:ietf:params:oauth:grant-type:device_code";
1954
2229
  var TopoloOAuth = class {
@@ -2201,6 +2476,7 @@ function createTopolo(options) {
2201
2476
  CrmModule,
2202
2477
  DEFAULT_SERVICE_URLS,
2203
2478
  IdentityModule,
2479
+ P2PModule,
2204
2480
  PLATFORM_SERVICE_IDS,
2205
2481
  TOPOLO_WIDGET_ENDPOINT,
2206
2482
  TOPOLO_WIDGET_REFRESH_INTERVAL_MS,