@connectedxm/admin 7.5.1 → 7.8.0

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.js CHANGED
@@ -846,6 +846,93 @@ var isUUID = (id) => {
846
846
  return uuidRegex.test(id);
847
847
  };
848
848
 
849
+ // src/utilities/MapboxSearch.ts
850
+ import axios2 from "axios";
851
+ var SUGGEST_URL = "https://api.mapbox.com/search/searchbox/v1/suggest";
852
+ var RETRIEVE_URL = "https://api.mapbox.com/search/searchbox/v1/retrieve";
853
+ var REQUEST_TIMEOUT_MS = 1e4;
854
+ var createMapboxSessionToken = () => {
855
+ try {
856
+ if (typeof globalThis.crypto !== "undefined" && typeof globalThis.crypto.randomUUID === "function") {
857
+ return globalThis.crypto.randomUUID();
858
+ }
859
+ } catch {
860
+ }
861
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
862
+ const r = Math.random() * 16 | 0;
863
+ const v = c === "x" ? r : r & 3 | 8;
864
+ return v.toString(16);
865
+ });
866
+ };
867
+ var mapFeatureToAddress = (feature) => {
868
+ const p = feature?.properties ?? {};
869
+ const ctx = p.context ?? {};
870
+ const geo = feature?.geometry?.coordinates ?? [];
871
+ const coords = p.coordinates ?? { longitude: geo[0], latitude: geo[1] };
872
+ const isPoi = p.feature_type === "poi";
873
+ return {
874
+ venue: isPoi ? p.name || null : null,
875
+ address1: ctx.address?.name || (isPoi ? null : p.name) || null,
876
+ address2: null,
877
+ city: ctx.place?.name || null,
878
+ state: ctx.region?.region_code || ctx.region?.name || null,
879
+ country: ctx.country?.country_code || null,
880
+ zip: ctx.postcode?.name || null,
881
+ latitude: typeof coords.latitude === "number" ? coords.latitude : null,
882
+ longitude: typeof coords.longitude === "number" ? coords.longitude : null,
883
+ fullAddress: p.full_address ?? null
884
+ };
885
+ };
886
+ var mapboxSuggest = async (query, {
887
+ accessToken,
888
+ sessionToken,
889
+ country,
890
+ limit = 6,
891
+ language = "en"
892
+ }) => {
893
+ if (!accessToken || !query || query.trim().length < 2) return [];
894
+ try {
895
+ const { data } = await axios2.get(SUGGEST_URL, {
896
+ params: {
897
+ q: query,
898
+ access_token: accessToken,
899
+ session_token: sessionToken,
900
+ language,
901
+ limit,
902
+ ...country ? { country } : {}
903
+ },
904
+ timeout: REQUEST_TIMEOUT_MS
905
+ });
906
+ const suggestions = data?.suggestions ?? [];
907
+ return suggestions.map((s) => ({
908
+ mapboxId: s.mapbox_id,
909
+ name: s.name,
910
+ fullAddress: s.full_address ?? null,
911
+ placeFormatted: s.place_formatted ?? null,
912
+ featureType: s.feature_type ?? ""
913
+ }));
914
+ } catch {
915
+ return [];
916
+ }
917
+ };
918
+ var mapboxRetrieve = async (mapboxId, { accessToken, sessionToken }) => {
919
+ if (!accessToken || !mapboxId) return null;
920
+ try {
921
+ const { data } = await axios2.get(
922
+ `${RETRIEVE_URL}/${encodeURIComponent(mapboxId)}`,
923
+ {
924
+ params: { access_token: accessToken, session_token: sessionToken },
925
+ timeout: REQUEST_TIMEOUT_MS
926
+ }
927
+ );
928
+ const feature = data?.features?.[0];
929
+ if (!feature) return null;
930
+ return mapFeatureToAddress(feature);
931
+ } catch {
932
+ return null;
933
+ }
934
+ };
935
+
849
936
  // src/utilities/MergeInfinitePages.ts
850
937
  function MergeInfinitePages(data) {
851
938
  return data.pages.reduce(
@@ -1042,11 +1129,11 @@ var useConnectedInfiniteQuery = (queryKeys, queryFn, params = {}, options = {
1042
1129
  };
1043
1130
 
1044
1131
  // src/AdminAPI.ts
1045
- import axios2 from "axios";
1132
+ import axios3 from "axios";
1046
1133
  var GetAdminAPI = async (params) => {
1047
1134
  const token = !!params.getToken && await params.getToken();
1048
1135
  const executeAs = params.getExecuteAs ? await params.getExecuteAs() : void 0;
1049
- return axios2.create({
1136
+ return axios3.create({
1050
1137
  baseURL: params.apiUrl,
1051
1138
  headers: {
1052
1139
  organization: params.organizationId,
@@ -34105,6 +34192,26 @@ var useDeleteEvent = (options = {}) => {
34105
34192
  return useConnectedMutation(DeleteEvent, options);
34106
34193
  };
34107
34194
 
34195
+ // src/mutations/events/useDeleteEventLocation.ts
34196
+ var DeleteEventLocation = async ({
34197
+ eventId,
34198
+ adminApiParams,
34199
+ queryClient
34200
+ }) => {
34201
+ const connectedXM = await GetAdminAPI(adminApiParams);
34202
+ const { data } = await connectedXM.delete(
34203
+ `/events/${eventId}/location`
34204
+ );
34205
+ if (queryClient && data.status === "ok") {
34206
+ queryClient.invalidateQueries({ queryKey: EVENTS_QUERY_KEY() });
34207
+ SET_EVENT_QUERY_DATA(queryClient, [data.data?.id], data);
34208
+ }
34209
+ return data;
34210
+ };
34211
+ var useDeleteEventLocation = (options = {}) => {
34212
+ return useConnectedMutation(DeleteEventLocation, options);
34213
+ };
34214
+
34108
34215
  // src/mutations/events/useDisableEventBuildMode.ts
34109
34216
  var DisableEventBuildMode = async ({
34110
34217
  eventId,
@@ -34139,6 +34246,28 @@ var useEnableEventBuildMode = (options = {}) => {
34139
34246
  return useConnectedMutation(EnableEventBuildMode, options);
34140
34247
  };
34141
34248
 
34249
+ // src/mutations/events/useSetEventLocation.ts
34250
+ var SetEventLocation = async ({
34251
+ eventId,
34252
+ location,
34253
+ adminApiParams,
34254
+ queryClient
34255
+ }) => {
34256
+ const connectedXM = await GetAdminAPI(adminApiParams);
34257
+ const { data } = await connectedXM.put(
34258
+ `/events/${eventId}/location`,
34259
+ location
34260
+ );
34261
+ if (queryClient && data.status === "ok") {
34262
+ queryClient.invalidateQueries({ queryKey: EVENTS_QUERY_KEY() });
34263
+ SET_EVENT_QUERY_DATA(queryClient, [data.data?.id], data);
34264
+ }
34265
+ return data;
34266
+ };
34267
+ var useSetEventLocation = (options = {}) => {
34268
+ return useConnectedMutation(SetEventLocation, options);
34269
+ };
34270
+
34142
34271
  // src/mutations/events/useUpdateEvent.ts
34143
34272
  var UpdateEvent = async ({
34144
34273
  eventId,
@@ -40526,6 +40655,7 @@ export {
40526
40655
  DeleteEventFaqSectionTranslation,
40527
40656
  DeleteEventFollowup,
40528
40657
  DeleteEventFollowupTranslation,
40658
+ DeleteEventLocation,
40529
40659
  DeleteEventMatch,
40530
40660
  DeleteEventMediaItem,
40531
40661
  DeleteEventMediaItemTranslation,
@@ -42248,6 +42378,7 @@ export {
42248
42378
  SendAnnouncementPreview,
42249
42379
  SendInvoice,
42250
42380
  SeriesQuestionType,
42381
+ SetEventLocation,
42251
42382
  SideEffectActionType,
42252
42383
  SideEffectTriggerType,
42253
42384
  StartEventRoundMatchmaking,
@@ -42500,9 +42631,13 @@ export {
42500
42631
  WidgetCategory,
42501
42632
  WidgetType,
42502
42633
  ZERO_DECIMAL_CURRENCIES,
42634
+ createMapboxSessionToken,
42503
42635
  getCurrencySymbol,
42504
42636
  isUUID,
42505
42637
  isZeroDecimalCurrency,
42638
+ mapFeatureToAddress,
42639
+ mapboxRetrieve,
42640
+ mapboxSuggest,
42506
42641
  setFirstPageData,
42507
42642
  useAcceptGroupRequest,
42508
42643
  useAddAccountFollower,
@@ -42759,6 +42894,7 @@ export {
42759
42894
  useDeleteEventFaqSectionTranslation,
42760
42895
  useDeleteEventFollowup,
42761
42896
  useDeleteEventFollowupTranslation,
42897
+ useDeleteEventLocation,
42762
42898
  useDeleteEventMatch,
42763
42899
  useDeleteEventMediaItem,
42764
42900
  useDeleteEventMediaItemTranslation,
@@ -43521,6 +43657,7 @@ export {
43521
43657
  useSelfLeaveOrganization,
43522
43658
  useSendAnnouncementPreview,
43523
43659
  useSendInvoice,
43660
+ useSetEventLocation,
43524
43661
  useStartEventRoundMatchmaking,
43525
43662
  useStartEventSessionRoundMatchmaking,
43526
43663
  useSwitchImage,
package/openapi.json CHANGED
@@ -29204,6 +29204,120 @@
29204
29204
  ]
29205
29205
  }
29206
29206
  },
29207
+ "/events/{eventId}/location": {
29208
+ "put": {
29209
+ "operationId": "SetEventLocation",
29210
+ "summary": "Set an event's location",
29211
+ "description": "Sets or updates the location details of an existing event, requiring the update events permission.",
29212
+ "parameters": [
29213
+ {
29214
+ "in": "path",
29215
+ "name": "eventId",
29216
+ "schema": {
29217
+ "type": "string"
29218
+ },
29219
+ "description": "The event identifier",
29220
+ "required": true
29221
+ }
29222
+ ],
29223
+ "requestBody": {
29224
+ "required": true,
29225
+ "content": {
29226
+ "application/json": {
29227
+ "schema": {
29228
+ "$ref": "#/components/schemas/EventLocationInputs"
29229
+ }
29230
+ }
29231
+ }
29232
+ },
29233
+ "responses": {
29234
+ "200": {
29235
+ "description": "Successful response",
29236
+ "content": {
29237
+ "application/json": {
29238
+ "schema": {
29239
+ "type": "object",
29240
+ "properties": {
29241
+ "status": {
29242
+ "type": "string",
29243
+ "enum": [
29244
+ "ok"
29245
+ ]
29246
+ },
29247
+ "message": {
29248
+ "type": "string",
29249
+ "example": "Success message."
29250
+ },
29251
+ "data": {
29252
+ "$ref": "#/components/schemas/Event"
29253
+ }
29254
+ },
29255
+ "required": [
29256
+ "status",
29257
+ "message",
29258
+ "data"
29259
+ ]
29260
+ }
29261
+ }
29262
+ }
29263
+ }
29264
+ },
29265
+ "tags": [
29266
+ "Events"
29267
+ ]
29268
+ },
29269
+ "delete": {
29270
+ "operationId": "DeleteEventLocation",
29271
+ "summary": "Delete an event's location",
29272
+ "description": "Clears the location details of an existing event, requiring the update events permission.",
29273
+ "parameters": [
29274
+ {
29275
+ "in": "path",
29276
+ "name": "eventId",
29277
+ "schema": {
29278
+ "type": "string"
29279
+ },
29280
+ "description": "The event identifier",
29281
+ "required": true
29282
+ }
29283
+ ],
29284
+ "responses": {
29285
+ "200": {
29286
+ "description": "Successful response",
29287
+ "content": {
29288
+ "application/json": {
29289
+ "schema": {
29290
+ "type": "object",
29291
+ "properties": {
29292
+ "status": {
29293
+ "type": "string",
29294
+ "enum": [
29295
+ "ok"
29296
+ ]
29297
+ },
29298
+ "message": {
29299
+ "type": "string",
29300
+ "example": "Success message."
29301
+ },
29302
+ "data": {
29303
+ "$ref": "#/components/schemas/Event"
29304
+ }
29305
+ },
29306
+ "required": [
29307
+ "status",
29308
+ "message",
29309
+ "data"
29310
+ ]
29311
+ }
29312
+ }
29313
+ }
29314
+ }
29315
+ },
29316
+ "tags": [
29317
+ "Events"
29318
+ ]
29319
+ }
29320
+ },
29207
29321
  "/events/{eventId}/media": {
29208
29322
  "get": {
29209
29323
  "operationId": "GetEventMediaItems",
@@ -97337,6 +97451,18 @@
97337
97451
  "type": "string",
97338
97452
  "nullable": true
97339
97453
  },
97454
+ "location": {
97455
+ "type": "string",
97456
+ "nullable": true
97457
+ },
97458
+ "latitude": {
97459
+ "type": "number",
97460
+ "nullable": true
97461
+ },
97462
+ "longitude": {
97463
+ "type": "number",
97464
+ "nullable": true
97465
+ },
97340
97466
  "imageId": {
97341
97467
  "type": "string",
97342
97468
  "nullable": true
@@ -97428,6 +97554,9 @@
97428
97554
  "state",
97429
97555
  "country",
97430
97556
  "zip",
97557
+ "location",
97558
+ "latitude",
97559
+ "longitude",
97431
97560
  "imageId",
97432
97561
  "image",
97433
97562
  "squareImageId",
@@ -97452,6 +97581,14 @@
97452
97581
  {
97453
97582
  "type": "object",
97454
97583
  "properties": {
97584
+ "mapImageLightUrl": {
97585
+ "type": "string",
97586
+ "nullable": true
97587
+ },
97588
+ "mapImageDarkUrl": {
97589
+ "type": "string",
97590
+ "nullable": true
97591
+ },
97455
97592
  "roundName": {
97456
97593
  "type": "string",
97457
97594
  "nullable": true
@@ -97644,6 +97781,8 @@
97644
97781
  }
97645
97782
  },
97646
97783
  "required": [
97784
+ "mapImageLightUrl",
97785
+ "mapImageDarkUrl",
97647
97786
  "roundName",
97648
97787
  "matchName",
97649
97788
  "passSupply",
@@ -103795,6 +103934,10 @@
103795
103934
  "type": "string",
103796
103935
  "nullable": true
103797
103936
  },
103937
+ "location": {
103938
+ "type": "string",
103939
+ "nullable": true
103940
+ },
103798
103941
  "image": {
103799
103942
  "allOf": [
103800
103943
  {
@@ -103813,6 +103956,7 @@
103813
103956
  "city",
103814
103957
  "state",
103815
103958
  "country",
103959
+ "location",
103816
103960
  "image"
103817
103961
  ]
103818
103962
  },
@@ -103824,6 +103968,14 @@
103824
103968
  {
103825
103969
  "type": "object",
103826
103970
  "properties": {
103971
+ "latitude": {
103972
+ "type": "number",
103973
+ "nullable": true
103974
+ },
103975
+ "longitude": {
103976
+ "type": "number",
103977
+ "nullable": true
103978
+ },
103827
103979
  "description": {
103828
103980
  "type": "string",
103829
103981
  "nullable": true
@@ -103836,6 +103988,8 @@
103836
103988
  }
103837
103989
  },
103838
103990
  "required": [
103991
+ "latitude",
103992
+ "longitude",
103839
103993
  "description",
103840
103994
  "createdAt",
103841
103995
  "updatedAt"
@@ -115269,6 +115423,51 @@
115269
115423
  }
115270
115424
  }
115271
115425
  },
115426
+ "EventLocationInputs": {
115427
+ "type": "object",
115428
+ "properties": {
115429
+ "venue": {
115430
+ "type": "string",
115431
+ "nullable": true
115432
+ },
115433
+ "location": {
115434
+ "type": "string",
115435
+ "nullable": true
115436
+ },
115437
+ "address1": {
115438
+ "type": "string",
115439
+ "nullable": true
115440
+ },
115441
+ "address2": {
115442
+ "type": "string",
115443
+ "nullable": true
115444
+ },
115445
+ "city": {
115446
+ "type": "string",
115447
+ "nullable": true
115448
+ },
115449
+ "state": {
115450
+ "type": "string",
115451
+ "nullable": true
115452
+ },
115453
+ "country": {
115454
+ "type": "string",
115455
+ "nullable": true
115456
+ },
115457
+ "zip": {
115458
+ "type": "string",
115459
+ "nullable": true
115460
+ },
115461
+ "latitude": {
115462
+ "type": "number",
115463
+ "nullable": true
115464
+ },
115465
+ "longitude": {
115466
+ "type": "number",
115467
+ "nullable": true
115468
+ }
115469
+ }
115470
+ },
115272
115471
  "EventCreateInputs": {
115273
115472
  "type": "object",
115274
115473
  "properties": {
@@ -115335,34 +115534,6 @@
115335
115534
  "type": "string",
115336
115535
  "nullable": true
115337
115536
  },
115338
- "venue": {
115339
- "type": "string",
115340
- "nullable": true
115341
- },
115342
- "address1": {
115343
- "type": "string",
115344
- "nullable": true
115345
- },
115346
- "address2": {
115347
- "type": "string",
115348
- "nullable": true
115349
- },
115350
- "city": {
115351
- "type": "string",
115352
- "nullable": true
115353
- },
115354
- "state": {
115355
- "type": "string",
115356
- "nullable": true
115357
- },
115358
- "country": {
115359
- "type": "string",
115360
- "nullable": true
115361
- },
115362
- "zip": {
115363
- "type": "string",
115364
- "nullable": true
115365
- },
115366
115537
  "creatorId": {
115367
115538
  "type": "string",
115368
115539
  "nullable": true
@@ -115621,34 +115792,6 @@
115621
115792
  "type": "string",
115622
115793
  "nullable": true
115623
115794
  },
115624
- "venue": {
115625
- "type": "string",
115626
- "nullable": true
115627
- },
115628
- "address1": {
115629
- "type": "string",
115630
- "nullable": true
115631
- },
115632
- "address2": {
115633
- "type": "string",
115634
- "nullable": true
115635
- },
115636
- "city": {
115637
- "type": "string",
115638
- "nullable": true
115639
- },
115640
- "state": {
115641
- "type": "string",
115642
- "nullable": true
115643
- },
115644
- "country": {
115645
- "type": "string",
115646
- "nullable": true
115647
- },
115648
- "zip": {
115649
- "type": "string",
115650
- "nullable": true
115651
- },
115652
115795
  "creatorId": {
115653
115796
  "type": "string",
115654
115797
  "nullable": true
@@ -116803,6 +116946,10 @@
116803
116946
  "EventSessionLocationCreateInputs": {
116804
116947
  "type": "object",
116805
116948
  "properties": {
116949
+ "location": {
116950
+ "type": "string",
116951
+ "nullable": true
116952
+ },
116806
116953
  "name": {
116807
116954
  "type": "string"
116808
116955
  },
@@ -116859,6 +117006,10 @@
116859
117006
  "EventSessionLocationUpdateInputs": {
116860
117007
  "type": "object",
116861
117008
  "properties": {
117009
+ "location": {
117010
+ "type": "string",
117011
+ "nullable": true
117012
+ },
116862
117013
  "name": {
116863
117014
  "type": "string"
116864
117015
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@connectedxm/admin",
3
- "version": "7.5.1",
3
+ "version": "7.8.0",
4
4
  "description": "Admin API javascript SDK",
5
5
  "author": "ConnectedXM Inc.",
6
6
  "type": "module",