@burdenoff/microfe-integrations 2026.1117.2 → 2026.1118.1

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 (131) hide show
  1. package/dist/generated/global-types.d.ts +398 -121
  2. package/dist/generated/wspace-operations.d.ts +727 -0
  3. package/dist/generated/wspace-operations.js +453 -174
  4. package/dist/generated/wspace-operations.js.map +1 -1
  5. package/dist/generated/wspace-types.d.ts +3838 -130
  6. package/dist/generated/wspace-types.js +28 -10
  7. package/dist/generated/wspace-types.js.map +1 -1
  8. package/dist/integrations/ConnectSourceDialog.js +30 -21
  9. package/dist/integrations/ConnectSourceDialog.js.map +1 -1
  10. package/dist/integrations/IntegrationsUserRoutes.js +32 -27
  11. package/dist/integrations/IntegrationsUserRoutes.js.map +1 -1
  12. package/dist/integrations/connected-apps/components/ActivitySections.d.ts +31 -0
  13. package/dist/integrations/connected-apps/components/ActivitySections.js +147 -0
  14. package/dist/integrations/connected-apps/components/ActivitySections.js.map +1 -0
  15. package/dist/integrations/connected-apps/components/AppItems.d.ts +26 -0
  16. package/dist/integrations/connected-apps/components/AppItems.js +171 -0
  17. package/dist/integrations/connected-apps/components/AppItems.js.map +1 -0
  18. package/dist/integrations/connected-apps/components/AppPanels.d.ts +48 -0
  19. package/dist/integrations/connected-apps/components/AppPanels.js +244 -0
  20. package/dist/integrations/connected-apps/components/AppPanels.js.map +1 -0
  21. package/dist/integrations/connected-apps/components/AppsSections.d.ts +30 -0
  22. package/dist/integrations/connected-apps/components/AppsSections.js +133 -0
  23. package/dist/integrations/connected-apps/components/AppsSections.js.map +1 -0
  24. package/dist/integrations/connected-apps/components/ConnectionActionDialogs.d.ts +30 -0
  25. package/dist/integrations/connected-apps/components/ConnectionActionDialogs.js +200 -0
  26. package/dist/integrations/connected-apps/components/ConnectionActionDialogs.js.map +1 -0
  27. package/dist/integrations/connected-apps/components/ConnectionActions.d.ts +38 -0
  28. package/dist/integrations/connected-apps/components/ConnectionActions.js +162 -0
  29. package/dist/integrations/connected-apps/components/ConnectionActions.js.map +1 -0
  30. package/dist/integrations/connected-apps/components/ConnectionHealth.d.ts +19 -0
  31. package/dist/integrations/connected-apps/components/ConnectionHealth.js +136 -0
  32. package/dist/integrations/connected-apps/components/ConnectionHealth.js.map +1 -0
  33. package/dist/integrations/connected-apps/components/ConnectionItems.d.ts +38 -0
  34. package/dist/integrations/connected-apps/components/ConnectionItems.js +358 -0
  35. package/dist/integrations/connected-apps/components/ConnectionItems.js.map +1 -0
  36. package/dist/integrations/connected-apps/components/ConnectionPanels.d.ts +37 -0
  37. package/dist/integrations/connected-apps/components/ConnectionPanels.js +248 -0
  38. package/dist/integrations/connected-apps/components/ConnectionPanels.js.map +1 -0
  39. package/dist/integrations/connected-apps/components/ConnectionsSections.d.ts +44 -0
  40. package/dist/integrations/connected-apps/components/ConnectionsSections.js +222 -0
  41. package/dist/integrations/connected-apps/components/ConnectionsSections.js.map +1 -0
  42. package/dist/integrations/connected-apps/components/Explainer.d.ts +3 -0
  43. package/dist/integrations/connected-apps/components/Explainer.js +56 -0
  44. package/dist/integrations/connected-apps/components/Explainer.js.map +1 -0
  45. package/dist/integrations/connected-apps/components/ListOrigin.d.ts +21 -0
  46. package/dist/integrations/connected-apps/components/ListOrigin.js +35 -0
  47. package/dist/integrations/connected-apps/components/ListOrigin.js.map +1 -0
  48. package/dist/integrations/connected-apps/components/Notices.d.ts +9 -0
  49. package/dist/integrations/connected-apps/components/Notices.js +71 -0
  50. package/dist/integrations/connected-apps/components/Notices.js.map +1 -0
  51. package/dist/integrations/connected-apps/components/PageFrame.d.ts +27 -0
  52. package/dist/integrations/connected-apps/components/PageFrame.js +55 -0
  53. package/dist/integrations/connected-apps/components/PageFrame.js.map +1 -0
  54. package/dist/integrations/connected-apps/components/Panels.d.ts +28 -0
  55. package/dist/integrations/connected-apps/components/Panels.js +50 -0
  56. package/dist/integrations/connected-apps/components/Panels.js.map +1 -0
  57. package/dist/integrations/connected-apps/components/Results.d.ts +50 -0
  58. package/dist/integrations/connected-apps/components/Results.js +129 -0
  59. package/dist/integrations/connected-apps/components/Results.js.map +1 -0
  60. package/dist/integrations/connected-apps/components/SearchPicker.d.ts +20 -0
  61. package/dist/integrations/connected-apps/components/SearchPicker.js +139 -0
  62. package/dist/integrations/connected-apps/components/SearchPicker.js.map +1 -0
  63. package/dist/integrations/connected-apps/components/StatusChip.d.ts +11 -0
  64. package/dist/integrations/connected-apps/components/StatusChip.js +40 -0
  65. package/dist/integrations/connected-apps/components/StatusChip.js.map +1 -0
  66. package/dist/integrations/connected-apps/components/Toolbar.d.ts +74 -0
  67. package/dist/integrations/connected-apps/components/Toolbar.js +216 -0
  68. package/dist/integrations/connected-apps/components/Toolbar.js.map +1 -0
  69. package/dist/integrations/connected-apps/components/styles.d.ts +12 -0
  70. package/dist/integrations/connected-apps/components/styles.js +15 -0
  71. package/dist/integrations/connected-apps/components/styles.js.map +1 -0
  72. package/dist/integrations/connected-apps/connect/AppPicker.d.ts +7 -0
  73. package/dist/integrations/connected-apps/connect/AppPicker.js +257 -0
  74. package/dist/integrations/connected-apps/connect/AppPicker.js.map +1 -0
  75. package/dist/integrations/connected-apps/connect/ConnectAppDialog.d.ts +18 -0
  76. package/dist/integrations/connected-apps/connect/ConnectAppDialog.js +224 -0
  77. package/dist/integrations/connected-apps/connect/ConnectAppDialog.js.map +1 -0
  78. package/dist/integrations/connected-apps/hooks/useCanCreateConnection.d.ts +1 -0
  79. package/dist/integrations/connected-apps/hooks/useCanCreateConnection.js +10 -0
  80. package/dist/integrations/connected-apps/hooks/useCanCreateConnection.js.map +1 -0
  81. package/dist/integrations/connected-apps/hooks/useConnectedAppsData.d.ts +372 -0
  82. package/dist/integrations/connected-apps/hooks/useConnectedAppsData.js +311 -0
  83. package/dist/integrations/connected-apps/hooks/useConnectedAppsData.js.map +1 -0
  84. package/dist/integrations/connected-apps/hooks/useListState.d.ts +21 -0
  85. package/dist/integrations/connected-apps/hooks/useListState.js +43 -0
  86. package/dist/integrations/connected-apps/hooks/useListState.js.map +1 -0
  87. package/dist/integrations/connected-apps/hooks/usePageChrome.d.ts +12 -0
  88. package/dist/integrations/connected-apps/hooks/usePageChrome.js +46 -0
  89. package/dist/integrations/connected-apps/hooks/usePageChrome.js.map +1 -0
  90. package/dist/integrations/connected-apps/model/activity.d.ts +26 -0
  91. package/dist/integrations/connected-apps/model/activity.js +79 -0
  92. package/dist/integrations/connected-apps/model/activity.js.map +1 -0
  93. package/dist/integrations/connected-apps/model/apps.d.ts +68 -0
  94. package/dist/integrations/connected-apps/model/apps.js +101 -0
  95. package/dist/integrations/connected-apps/model/apps.js.map +1 -0
  96. package/dist/integrations/connected-apps/model/connections.d.ts +58 -0
  97. package/dist/integrations/connected-apps/model/connections.js +55 -0
  98. package/dist/integrations/connected-apps/model/connections.js.map +1 -0
  99. package/dist/integrations/connected-apps/model/health.d.ts +30 -0
  100. package/dist/integrations/connected-apps/model/health.js +54 -0
  101. package/dist/integrations/connected-apps/model/health.js.map +1 -0
  102. package/dist/integrations/connected-apps/model/queries.d.ts +56 -0
  103. package/dist/integrations/connected-apps/model/queries.js +117 -0
  104. package/dist/integrations/connected-apps/model/queries.js.map +1 -0
  105. package/dist/integrations/connected-apps/model/status.d.ts +36 -0
  106. package/dist/integrations/connected-apps/model/status.js +73 -0
  107. package/dist/integrations/connected-apps/model/status.js.map +1 -0
  108. package/dist/integrations/connected-apps/model/translate.d.ts +2 -0
  109. package/dist/integrations/connected-apps/model/urlState.d.ts +52 -0
  110. package/dist/integrations/connected-apps/model/urlState.js +87 -0
  111. package/dist/integrations/connected-apps/model/urlState.js.map +1 -0
  112. package/dist/integrations/connected-apps/pages/ActivityPage.d.ts +1 -0
  113. package/dist/integrations/connected-apps/pages/ActivityPage.js +261 -0
  114. package/dist/integrations/connected-apps/pages/ActivityPage.js.map +1 -0
  115. package/dist/integrations/connected-apps/pages/AppDetailsPage.d.ts +1 -0
  116. package/dist/integrations/connected-apps/pages/AppDetailsPage.js +163 -0
  117. package/dist/integrations/connected-apps/pages/AppDetailsPage.js.map +1 -0
  118. package/dist/integrations/connected-apps/pages/AppsPage.d.ts +1 -0
  119. package/dist/integrations/connected-apps/pages/AppsPage.js +209 -0
  120. package/dist/integrations/connected-apps/pages/AppsPage.js.map +1 -0
  121. package/dist/integrations/connected-apps/pages/ConnectionDetailsPage.d.ts +1 -0
  122. package/dist/integrations/connected-apps/pages/ConnectionDetailsPage.js +240 -0
  123. package/dist/integrations/connected-apps/pages/ConnectionDetailsPage.js.map +1 -0
  124. package/dist/integrations/connected-apps/pages/ConnectionsPage.d.ts +1 -0
  125. package/dist/integrations/connected-apps/pages/ConnectionsPage.js +254 -0
  126. package/dist/integrations/connected-apps/pages/ConnectionsPage.js.map +1 -0
  127. package/dist/integrations/providers/IntegrationsProvider.js +22 -21
  128. package/dist/integrations/providers/IntegrationsProvider.js.map +1 -1
  129. package/dist/integrations/translations/en.d.ts +426 -0
  130. package/dist/integrations/types/index.d.ts +9 -0
  131. package/package.json +9 -9
@@ -0,0 +1,311 @@
1
+ import { ConnectedAppProviderFieldsFragmentDoc as e, GetActivityPageDocument as t, GetAppCatalogTotalDocument as n, GetAppCategoryCountsDocument as r, GetAppConnectionsDocument as i, GetAppDetailsDocument as a, GetAppsPageDocument as o, GetConnectedAppDetailsDocument as s, GetConnectedAppsPageDocument as c, GetConnectedAppsStatusCountsDocument as l, GetConnectionDocument as u, GetConnectionPeopleDocument as d, GetProviderDocument as ee } from "../../../generated/wspace-operations.js";
2
+ import { ConnectionSortDirection as f, ConnectionSortField as p, PluginStatus as m, ProviderCategory as h } from "../../../generated/wspace-types.js";
3
+ import { useIntegrations as g } from "../../providers/IntegrationsProvider.js";
4
+ import { mapConnection as _, mapProvider as v } from "../../utils/mappers.js";
5
+ import { activityPageVariables as y, appCategoryCountVariables as b, appsPageVariables as x, connectionsPageVariables as S, statusCountVariables as C } from "../model/queries.js";
6
+ import { useMemo as w } from "react";
7
+ import { CombinedGraphQLErrors as te, gql as T } from "@apollo/client";
8
+ import { useApolloClient as E, useQuery as D } from "@apollo/client/react";
9
+ import { POPULAR_PROVIDER_KEYS as O } from "@burdenoff/fe-libs/connections";
10
+ import { GALLERY_PAGE_SIZE as k } from "@burdenoff/fe-libs/ui";
11
+ // src/integrations/connected-apps/hooks/useConnectedAppsData.ts
12
+ function A(e) {
13
+ return e;
14
+ }
15
+ var j = A(c), M = A(l), N = A(s), P = A(d), F = A(o), I = A(n), L = A(r), R = A(a), z = A(i), B = A(t), V = A(u), H = A(ee), U = /* @__PURE__ */ new Set(["NOT_FOUND", "FORBIDDEN"]);
16
+ function W(e, t) {
17
+ return e === void 0 ? !1 : !t || te.is(t) && t.errors.length > 0 && t.errors.every((e) => U.has(String(e.extensions?.code ?? "")));
18
+ }
19
+ function G(e, t, n, r, i) {
20
+ let a = e ?? t ?? null;
21
+ return {
22
+ items: a ? [...a.items] : [],
23
+ total: a?.total ?? 0,
24
+ hasData: a !== null,
25
+ pageLoading: n && !e && !!t,
26
+ settled: !n && !!e,
27
+ loading: n,
28
+ error: e ? void 0 : r,
29
+ refetch: () => {
30
+ i();
31
+ }
32
+ };
33
+ }
34
+ function ne(e) {
35
+ let { workspaceId: t } = g(), n = w(() => S(e, k), [e]), { data: r, previousData: i, loading: a, error: o, refetch: s } = D(j, {
36
+ variables: n,
37
+ skip: !t,
38
+ errorPolicy: "all",
39
+ fetchPolicy: "cache-and-network"
40
+ });
41
+ return G(r?.getConnections, i?.getConnections, a, o, s);
42
+ }
43
+ function K(e) {
44
+ let { workspaceId: t } = g(), { q: n, app: r, owner: i } = e, a = w(() => C({
45
+ q: n,
46
+ app: r,
47
+ owner: i
48
+ }), [
49
+ n,
50
+ r,
51
+ i
52
+ ]), { data: o, loading: s, error: c, refetch: l } = D(M, {
53
+ variables: a,
54
+ skip: !t,
55
+ errorPolicy: "all",
56
+ fetchPolicy: "cache-and-network"
57
+ });
58
+ return {
59
+ counts: w(() => {
60
+ if (!o?.all) return null;
61
+ let e = (e) => e?.total ?? 0;
62
+ return {
63
+ all: e(o.all),
64
+ attention: e(o.error) + e(o.expired),
65
+ error: e(o.error),
66
+ expired: e(o.expired),
67
+ working: e(o.active),
68
+ unfinished: e(o.pendingAuth),
69
+ off: e(o.inactive),
70
+ disconnected: e(o.revoked)
71
+ };
72
+ }, [o]),
73
+ loading: s,
74
+ error: c,
75
+ refetch: l
76
+ };
77
+ }
78
+ function q(e) {
79
+ let { workspaceId: t } = g(), { data: n, previousData: r, loading: i, error: a, refetch: o } = D(N, {
80
+ variables: { id: e },
81
+ skip: !t || !e,
82
+ errorPolicy: "all",
83
+ fetchPolicy: "cache-and-network"
84
+ }), s = r?.getConnection, c = n?.getConnection ?? (a && s?.id === e ? s : n?.getConnection);
85
+ return {
86
+ connection: c ?? null,
87
+ answered: W(n, a) || c != null,
88
+ loading: i,
89
+ error: a,
90
+ refetch: o
91
+ };
92
+ }
93
+ function J(e) {
94
+ let { workspaceId: t } = g(), n = [...new Set(e.filter(Boolean))].sort().join("\n"), r = w(() => n ? n.split("\n") : [], [n]), { data: i } = D(P, {
95
+ variables: {
96
+ userIds: r,
97
+ workspaceId: t ?? null
98
+ },
99
+ skip: !t || r.length === 0,
100
+ errorPolicy: "all"
101
+ });
102
+ return w(() => {
103
+ let e = /* @__PURE__ */ new Map();
104
+ for (let t of i?.workspaceMemberIdentities ?? []) t?.userId && e.set(t.userId, t.displayName || t.email || "");
105
+ return e;
106
+ }, [i]);
107
+ }
108
+ function Y(e) {
109
+ let { workspaceId: t } = g(), n = [...new Set(e.filter(Boolean))].sort().join("\n"), r = w(() => n ? n.split("\n") : [], [n]), i = w(() => {
110
+ if (r.length === 0) return null;
111
+ let e = r.map((e, t) => `$c${t}: ID!`).join(", "), t = r.map((e, t) => `c${t}: getConnection(id: $c${t}) { id name provider { id key name category icon } }`).join("\n");
112
+ return T(`query ConnectedAppNames(${e}) {\n${t}\n}`);
113
+ }, [r]), a = w(() => Object.fromEntries(r.map((e, t) => [`c${t}`, e])), [r]), { data: o } = D(i ?? X, {
114
+ variables: a,
115
+ skip: !i || !t,
116
+ errorPolicy: "all"
117
+ });
118
+ return w(() => {
119
+ let e = /* @__PURE__ */ new Map();
120
+ for (let t of Object.values(o ?? {})) t?.id && e.set(t.id, t);
121
+ return e;
122
+ }, [o]);
123
+ }
124
+ var X = T`
125
+ query ConnectedAppNamesSkipped {
126
+ __typename
127
+ }
128
+ `;
129
+ function Z(e) {
130
+ let { workspaceId: t } = g(), n = w(() => x(e, k), [e]), { data: r, previousData: i, loading: a, error: o, refetch: s } = D(F, {
131
+ variables: n,
132
+ skip: !t,
133
+ errorPolicy: "all",
134
+ fetchPolicy: "cache-and-network"
135
+ });
136
+ return G(r?.getProviders, i?.getProviders, a, o, s);
137
+ }
138
+ var re = [
139
+ [h.Accounting, "accounting"],
140
+ [h.Analytics, "analytics"],
141
+ [h.Calendar, "calendar"],
142
+ [h.CloudStorage, "cloudStorage"],
143
+ [h.Communication, "communication"],
144
+ [h.Crm, "crm"],
145
+ [h.Custom, "custom"],
146
+ [h.Development, "development"],
147
+ [h.Email, "email"],
148
+ [h.Payment, "payment"],
149
+ [h.Productivity, "productivity"],
150
+ [h.Social, "social"]
151
+ ];
152
+ function Q(e) {
153
+ return e ? {
154
+ facets: re.map(([t, n]) => ({
155
+ value: t,
156
+ count: e[n]?.total ?? 0
157
+ })).filter((e) => e.count > 0).sort((e, t) => t.count - e.count || e.value.localeCompare(t.value)),
158
+ total: e.all?.total ?? 0
159
+ } : {
160
+ facets: [],
161
+ total: 0
162
+ };
163
+ }
164
+ function ie() {
165
+ let { workspaceId: e } = g(), { data: t } = D(I, {
166
+ skip: !e,
167
+ errorPolicy: "all",
168
+ fetchPolicy: "cache-first"
169
+ });
170
+ return t?.getProviders?.total ?? 0;
171
+ }
172
+ function ae(e) {
173
+ let { workspaceId: t } = g(), n = w(() => b(e), [e]), { data: r, previousData: i, loading: a } = D(L, {
174
+ variables: n,
175
+ skip: !t,
176
+ errorPolicy: "all",
177
+ fetchPolicy: "cache-and-network"
178
+ });
179
+ return {
180
+ ...Q(r ?? i),
181
+ loading: a
182
+ };
183
+ }
184
+ function oe(e) {
185
+ let { workspaceId: t } = g(), { data: n, loading: r } = D(se, {
186
+ skip: !t,
187
+ errorPolicy: "all",
188
+ fetchPolicy: "cache-first"
189
+ });
190
+ return {
191
+ apps: w(() => O.map((e, t) => n?.[`p${t}`] ?? null).filter((e) => e !== null && e.isEnabled && e.pluginStatus === m.Installed).slice(0, e), [n, e]),
192
+ loading: r
193
+ };
194
+ }
195
+ var se = T`
196
+ query ConnectedAppsPopular {
197
+ ${O.map((e, t) => `p${t}: getProviderByKey(key: ${JSON.stringify(e)}) { ...ConnectedAppProviderFields }`).join("\n")}
198
+ }
199
+ ${e}
200
+ `;
201
+ function ce(e, t, n, r = !0) {
202
+ let { workspaceId: i } = g(), a = w(() => x({
203
+ q: e,
204
+ category: n ?? "all",
205
+ method: "all",
206
+ install: m.Installed,
207
+ page: t
208
+ }, k), [
209
+ e,
210
+ t,
211
+ n
212
+ ]), { data: o, previousData: s, loading: c, error: l, refetch: u } = D(F, {
213
+ variables: a,
214
+ skip: !r || !i,
215
+ errorPolicy: "all",
216
+ fetchPolicy: "cache-and-network"
217
+ });
218
+ return G(o?.getProviders, s?.getProviders, c, l, u);
219
+ }
220
+ function le(e, t) {
221
+ let { workspaceId: n } = g(), r = w(() => ({
222
+ filter: e.trim() ? { search: e.trim() } : {},
223
+ pagination: {
224
+ limit: k,
225
+ offset: 0
226
+ },
227
+ sort: {
228
+ field: p.Name,
229
+ direction: f.Asc
230
+ }
231
+ }), [e]), { data: i, previousData: a, loading: o, error: s, refetch: c } = D(j, {
232
+ variables: r,
233
+ skip: !t || !n,
234
+ errorPolicy: "all",
235
+ fetchPolicy: "cache-and-network"
236
+ });
237
+ return G(i?.getConnections, a?.getConnections, o, s, c);
238
+ }
239
+ function $(e) {
240
+ let { workspaceId: t } = g(), { data: n, loading: r, error: i, refetch: a } = D(R, {
241
+ variables: { id: e },
242
+ skip: !t || !e,
243
+ errorPolicy: "all",
244
+ fetchPolicy: "cache-and-network"
245
+ });
246
+ return {
247
+ app: n?.getProvider ?? null,
248
+ answered: W(n, i),
249
+ loading: r,
250
+ error: i,
251
+ refetch: a
252
+ };
253
+ }
254
+ function ue(e, t) {
255
+ let { workspaceId: n } = g(), { data: r, loading: i, error: a, refetch: o } = D(z, {
256
+ variables: {
257
+ providerId: e,
258
+ pagination: {
259
+ limit: t,
260
+ offset: 0
261
+ }
262
+ },
263
+ skip: !n || !e,
264
+ errorPolicy: "all",
265
+ fetchPolicy: "cache-and-network"
266
+ });
267
+ return {
268
+ items: r?.getConnectionsByProvider?.items ?? [],
269
+ total: r?.getConnectionsByProvider?.total ?? 0,
270
+ hasData: !!r?.getConnectionsByProvider,
271
+ loading: i,
272
+ error: a,
273
+ refetch: o
274
+ };
275
+ }
276
+ function de(e, t, n) {
277
+ let { workspaceId: r } = g(), i = w(() => y(e, k, t), [e, t]), { data: a, previousData: o, loading: s, error: c, refetch: l } = D(B, {
278
+ variables: i,
279
+ skip: n || !r,
280
+ errorPolicy: "all",
281
+ fetchPolicy: "cache-and-network"
282
+ });
283
+ return G(a?.getIntegrationLogs, o?.getIntegrationLogs, s, c, l);
284
+ }
285
+ function fe() {
286
+ let e = E(), { onConnectionSelect: t } = g();
287
+ return w(() => t ? (n) => {
288
+ e.query({
289
+ query: V,
290
+ variables: { id: n },
291
+ fetchPolicy: "cache-first"
292
+ }).then(({ data: e }) => {
293
+ e?.getConnection && t(_(e.getConnection));
294
+ }).catch(() => void 0);
295
+ } : null, [e, t]);
296
+ }
297
+ function pe() {
298
+ let e = E(), { onProviderSelect: t } = g();
299
+ return w(() => t ? (n) => {
300
+ e.query({
301
+ query: H,
302
+ variables: { id: n },
303
+ fetchPolicy: "cache-first"
304
+ }).then(({ data: e }) => {
305
+ e?.getProvider && t(v(e.getProvider));
306
+ }).catch(() => void 0);
307
+ } : null, [e, t]);
308
+ }
309
+ export { Q as categoryFacets, de as useActivityPage, ie as useAppCatalogTotal, ae as useAppCategoryCounts, ue as useAppConnections, $ as useAppDetails, ce as useAppSearch, Z as useAppsPage, q as useConnectionDetails, Y as useConnectionNames, le as useConnectionSearch, K as useConnectionStatusCounts, ne as useConnectionsPage, J as usePeopleNames, oe as usePopularApps, pe as useSelectApp, fe as useSelectConnection };
310
+
311
+ //# sourceMappingURL=useConnectedAppsData.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useConnectedAppsData.js","names":["typed","document","CONNECTIONS_PAGE","GetConnectedAppsPageDocument","STATUS_COUNTS","GetConnectedAppsStatusCountsDocument","CONNECTION_DETAILS","GetConnectedAppDetailsDocument","PEOPLE","GetConnectionPeopleDocument","APPS_PAGE","GetAppsPageDocument","CATALOG_TOTAL","GetAppCatalogTotalDocument","CATEGORY_COUNTS","GetAppCategoryCountsDocument","APP_DETAILS","GetAppDetailsDocument","APP_CONNECTIONS","GetAppConnectionsDocument","ACTIVITY_PAGE","GetActivityPageDocument","CONNECTION_FULL","GetConnectionDocument","PROVIDER_FULL","GetProviderDocument","NO_RECORD_CODES","answeredAboutRecord","data","error","CombinedGraphQLErrors","entry","paged","shown","current","previous","loading","useConnectionsPage","useIntegrations","variables","useMemo","connectionsPageVariables","state","GALLERY_PAGE_SIZE","useQuery","workspaceId","previousData","refetch","useConnectionStatusCounts","scope","statusCountVariables","q","app","owner","total","useConnectionDetails","id","usePeopleNames","idsKey","userIds","ids","names","person","useConnectionNames","uniqueKey","unique","index","fields","gql","EMPTY_DOCUMENT","useAppsPage","appsPageVariables","CATEGORY_FIELDS","ProviderCategory","categoryFacets","category","field","facet","b","a","useAppCatalogTotal","useAppCategoryCounts","appCategoryCountVariables","usePopularApps","POPULAR_APPS_DOCUMENT","POPULAR_PROVIDER_KEYS","PluginStatus","limit","key","ConnectedAppProviderFieldsFragmentDoc","useAppSearch","search","page","enabled","useConnectionSearch","ConnectionSortField","ConnectionSortDirection","useAppDetails","useAppConnections","providerId","useActivityPage","activityPageVariables","now","skip","useSelectConnection","client","useApolloClient","onConnectionSelect","mapConnection","useSelectApp","onProviderSelect","mapProvider"],"sources":["../../../../src/integrations/connected-apps/hooks/useConnectedAppsData.ts"],"sourcesContent":["/**\n * The redesigned Connected apps' reads (BOFF-15373). Every list is one server\n * page of 20 with the server's total, and keeps the previous page on screen\n * while the next one loads (Apollo's `previousData`), as Templates does.\n *\n * ★ A query that has not answered is never an empty result. `hasData` stays\n * false until the server has replied (a skipped query — no workspace yet —\n * looks exactly like \"found nothing\" otherwise; see `useConnections`).\n */\nimport { useMemo } from 'react';\nimport {\n CombinedGraphQLErrors,\n gql,\n type DocumentNode,\n type ErrorLike,\n type OperationVariables,\n type TypedDocumentNode,\n} from '@apollo/client';\nimport { useApolloClient, useQuery } from '@apollo/client/react';\nimport { POPULAR_PROVIDER_KEYS } from '@burdenoff/fe-libs/connections';\nimport { GALLERY_PAGE_SIZE, type CategoryFacet } from '@burdenoff/fe-libs/ui';\n\nimport {\n ConnectedAppProviderFieldsFragmentDoc,\n GetActivityPageDocument,\n GetAppCatalogTotalDocument,\n GetAppCategoryCountsDocument,\n GetAppConnectionsDocument,\n GetAppDetailsDocument,\n GetAppsPageDocument,\n GetConnectedAppDetailsDocument,\n GetConnectedAppsPageDocument,\n GetConnectedAppsStatusCountsDocument,\n GetConnectionDocument,\n GetConnectionPeopleDocument,\n GetProviderDocument,\n type ConnectedAppProviderFieldsFragment,\n type GetActivityPageQuery,\n type GetActivityPageQueryVariables,\n type GetAppCatalogTotalQuery,\n type GetAppCatalogTotalQueryVariables,\n type GetAppCategoryCountsQuery,\n type GetAppCategoryCountsQueryVariables,\n type GetAppConnectionsQuery,\n type GetAppConnectionsQueryVariables,\n type GetAppDetailsQuery,\n type GetAppDetailsQueryVariables,\n type GetAppsPageQuery,\n type GetAppsPageQueryVariables,\n type GetConnectedAppDetailsQuery,\n type GetConnectedAppDetailsQueryVariables,\n type GetConnectedAppsPageQuery,\n type GetConnectedAppsPageQueryVariables,\n type GetConnectedAppsStatusCountsQuery,\n type GetConnectedAppsStatusCountsQueryVariables,\n type GetConnectionPeopleQuery,\n type GetConnectionPeopleQueryVariables,\n type GetConnectionQuery,\n type GetConnectionQueryVariables,\n type GetProviderQuery,\n type GetProviderQueryVariables,\n} from '../../../generated/wspace-operations';\nimport {\n ConnectionSortDirection,\n ConnectionSortField,\n PluginStatus,\n ProviderCategory,\n} from '../../../generated/wspace-types';\nimport { useIntegrations } from '../../providers/IntegrationsProvider';\nimport { mapConnection, mapProvider } from '../../utils/mappers';\nimport {\n activityPageVariables,\n appCategoryCountVariables,\n appsPageVariables,\n connectionsPageVariables,\n statusCountVariables,\n type ConnectionCountScope,\n} from '../model/queries';\nimport type { ActivityUrlState, AppsUrlState, ConnectionsUrlState } from '../model/urlState';\n\n/**\n * The generated documents, typed with the generated result types. Both come\n * from the same `.graphql` file, so the cast only restores what codegen's\n * untyped `DocumentNode` dropped; it lets `useQuery` infer complete results.\n */\nfunction typed<TData, TVariables extends OperationVariables>(\n document: DocumentNode\n): TypedDocumentNode<TData, TVariables> {\n return document as TypedDocumentNode<TData, TVariables>;\n}\n\nconst CONNECTIONS_PAGE = typed<GetConnectedAppsPageQuery, GetConnectedAppsPageQueryVariables>(\n GetConnectedAppsPageDocument\n);\nconst STATUS_COUNTS = typed<\n GetConnectedAppsStatusCountsQuery,\n GetConnectedAppsStatusCountsQueryVariables\n>(GetConnectedAppsStatusCountsDocument);\nconst CONNECTION_DETAILS = typed<GetConnectedAppDetailsQuery, GetConnectedAppDetailsQueryVariables>(\n GetConnectedAppDetailsDocument\n);\nconst PEOPLE = typed<GetConnectionPeopleQuery, GetConnectionPeopleQueryVariables>(\n GetConnectionPeopleDocument\n);\nconst APPS_PAGE = typed<GetAppsPageQuery, GetAppsPageQueryVariables>(GetAppsPageDocument);\nconst CATALOG_TOTAL = typed<GetAppCatalogTotalQuery, GetAppCatalogTotalQueryVariables>(\n GetAppCatalogTotalDocument\n);\nconst CATEGORY_COUNTS = typed<GetAppCategoryCountsQuery, GetAppCategoryCountsQueryVariables>(\n GetAppCategoryCountsDocument\n);\nconst APP_DETAILS = typed<GetAppDetailsQuery, GetAppDetailsQueryVariables>(GetAppDetailsDocument);\nconst APP_CONNECTIONS = typed<GetAppConnectionsQuery, GetAppConnectionsQueryVariables>(\n GetAppConnectionsDocument\n);\nconst ACTIVITY_PAGE = typed<GetActivityPageQuery, GetActivityPageQueryVariables>(\n GetActivityPageDocument\n);\n/** Today's full records, for a host's onConnectionSelect / onProviderSelect. */\nconst CONNECTION_FULL = typed<GetConnectionQuery, GetConnectionQueryVariables>(\n GetConnectionDocument\n);\nconst PROVIDER_FULL = typed<GetProviderQuery, GetProviderQueryVariables>(GetProviderDocument);\n\n/** The codes the service answers for a record this person may not see, or that is gone. */\nconst NO_RECORD_CODES: ReadonlySet<string> = new Set(['NOT_FOUND', 'FORBIDDEN']);\n\n/**\n * Whether a query has its answer about one record. A resolver failure can come\n * back as a null record plus an error (errorPolicy 'all'); that is a failed\n * load, to retry, not \"not available\". Only no error, or an error saying the\n * record is not found or not allowed, is an answer.\n */\nfunction answeredAboutRecord(data: unknown, error: ErrorLike | undefined): boolean {\n if (data === undefined) return false;\n if (!error) return true;\n return (\n CombinedGraphQLErrors.is(error) &&\n error.errors.length > 0 &&\n error.errors.every((entry) => NO_RECORD_CODES.has(String(entry.extensions?.code ?? '')))\n );\n}\n\n/** What every paged list hands its page. */\nexport interface PagedResult<T> {\n items: T[];\n total: number;\n /** The server has answered at least once (this page or the one before). */\n hasData: boolean;\n /** This page is loading and `items` still holds the previous one. */\n pageLoading: boolean;\n /** The current page's own answer is in (for clamping a page past the end). */\n settled: boolean;\n loading: boolean;\n error: ErrorLike | undefined;\n refetch: () => void;\n}\n\nfunction paged<T>(\n current: { items: readonly T[]; total: number } | null | undefined,\n previous: { items: readonly T[]; total: number } | null | undefined,\n loading: boolean,\n error: ErrorLike | undefined,\n refetch: () => unknown\n): PagedResult<T> {\n const shown = current ?? previous ?? null;\n return {\n items: shown ? [...shown.items] : [],\n total: shown?.total ?? 0,\n hasData: shown !== null,\n pageLoading: loading && !current && Boolean(previous),\n settled: !loading && Boolean(current),\n loading,\n error: current ? undefined : error,\n refetch: () => {\n void refetch();\n },\n };\n}\n\n// ─── Your connections ───────────────────────────────────────────────────────\n\nexport function useConnectionsPage(state: ConnectionsUrlState) {\n const { workspaceId } = useIntegrations();\n const variables = useMemo(() => connectionsPageVariables(state, GALLERY_PAGE_SIZE), [state]);\n const { data, previousData, loading, error, refetch } = useQuery(CONNECTIONS_PAGE, {\n variables,\n skip: !workspaceId,\n errorPolicy: 'all',\n fetchPolicy: 'cache-and-network',\n });\n return paged(data?.getConnections, previousData?.getConnections, loading, error, refetch);\n}\n\n/** Server totals per status group, for the chips and the attention banner. */\nexport interface StatusCounts {\n all: number;\n attention: number;\n error: number;\n expired: number;\n working: number;\n unfinished: number;\n off: number;\n disconnected: number;\n}\n\n/**\n * Status totals for `scope`: the list's search, app and owner filters for the\n * chips, `WORKSPACE_COUNT_SCOPE` for the workspace's own count line and banner.\n */\nexport function useConnectionStatusCounts(scope: ConnectionCountScope) {\n const { workspaceId } = useIntegrations();\n const { q, app, owner } = scope;\n const variables = useMemo(() => statusCountVariables({ q, app, owner }), [q, app, owner]);\n const { data, loading, error, refetch } = useQuery(STATUS_COUNTS, {\n variables,\n skip: !workspaceId,\n errorPolicy: 'all',\n fetchPolicy: 'cache-and-network',\n });\n const counts = useMemo<StatusCounts | null>(() => {\n // errorPolicy 'all' can answer with some totals missing; a missing one is unknown, not 0.\n if (!data?.all) return null;\n const total = (entry: { total: number } | null | undefined) => entry?.total ?? 0;\n return {\n all: total(data.all),\n attention: total(data.error) + total(data.expired),\n error: total(data.error),\n expired: total(data.expired),\n working: total(data.active),\n unfinished: total(data.pendingAuth),\n off: total(data.inactive),\n disconnected: total(data.revoked),\n };\n }, [data]);\n return { counts, loading, error, refetch };\n}\n\nexport function useConnectionDetails(id: string) {\n const { workspaceId } = useIntegrations();\n const { data, previousData, loading, error, refetch } = useQuery(CONNECTION_DETAILS, {\n variables: { id },\n skip: !workspaceId || !id,\n errorPolicy: 'all',\n fetchPolicy: 'cache-and-network',\n });\n // A failed background refetch keeps the connection already on screen (an open\n // Reconnect sign-in window must survive it); a different id never does.\n const previous = previousData?.getConnection;\n const current =\n data?.getConnection ?? (error && previous?.id === id ? previous : data?.getConnection);\n return {\n connection: current ?? null,\n /** The server has answered: a null connection then means it is not available. */\n answered: answeredAboutRecord(data, error) || (current !== undefined && current !== null),\n loading,\n error,\n refetch,\n };\n}\n\n/** Display names for workspace members (the connection's owner). */\nexport function usePeopleNames(userIds: string[]) {\n const { workspaceId } = useIntegrations();\n // Keyed on the ids' content: callers pass a fresh array each render.\n const idsKey = [...new Set(userIds.filter(Boolean))].sort().join('\\n');\n const ids = useMemo(() => (idsKey ? idsKey.split('\\n') : []), [idsKey]);\n const { data } = useQuery(PEOPLE, {\n variables: { userIds: ids, workspaceId: workspaceId ?? null },\n skip: !workspaceId || ids.length === 0,\n errorPolicy: 'all',\n });\n return useMemo(() => {\n const names = new Map<string, string>();\n for (const person of data?.workspaceMemberIdentities ?? []) {\n if (person?.userId) names.set(person.userId, person.displayName || person.email || '');\n }\n return names;\n }, [data]);\n}\n\n/**\n * Names of the connections a page of activity mentions: one request, one\n * `getConnection` per distinct id (a page has at most 20).\n */\nexport function useConnectionNames(ids: readonly string[]) {\n const { workspaceId } = useIntegrations();\n const uniqueKey = [...new Set(ids.filter(Boolean))].sort().join('\\n');\n const unique = useMemo(() => (uniqueKey ? uniqueKey.split('\\n') : []), [uniqueKey]);\n const document = useMemo<TypedDocumentNode<\n Record<string, ConnectionNameRecord | null>,\n Record<string, string>\n > | null>(() => {\n if (unique.length === 0) return null;\n const variables = unique.map((_, index) => `$c${index}: ID!`).join(', ');\n const fields = unique\n .map(\n (_, index) =>\n `c${index}: getConnection(id: $c${index}) { id name provider { id key name category icon } }`\n )\n .join('\\n');\n return gql(`query ConnectedAppNames(${variables}) {\\n${fields}\\n}`);\n }, [unique]);\n const variables = useMemo(\n () => Object.fromEntries(unique.map((id, index) => [`c${index}`, id])),\n [unique]\n );\n const { data } = useQuery(document ?? EMPTY_DOCUMENT, {\n variables,\n skip: !document || !workspaceId,\n errorPolicy: 'all',\n });\n return useMemo(() => {\n const names = new Map<string, ConnectionNameRecord>();\n for (const entry of Object.values(data ?? {})) {\n if (entry?.id) names.set(entry.id, entry);\n }\n return names;\n }, [data]);\n}\n\nexport interface ConnectionNameRecord {\n id: string;\n name: string;\n provider: { id: string; key: string; name: string; category: string; icon: string | null };\n}\n\n/** A document that is never sent: `useQuery` needs one even while skipped. */\nconst EMPTY_DOCUMENT: TypedDocumentNode<\n Record<string, ConnectionNameRecord | null>,\n Record<string, string>\n> = gql`\n query ConnectedAppNamesSkipped {\n __typename\n }\n`;\n\n// ─── All apps ───────────────────────────────────────────────────────────────\n\nexport function useAppsPage(state: AppsUrlState) {\n const { workspaceId } = useIntegrations();\n const variables = useMemo(() => appsPageVariables(state, GALLERY_PAGE_SIZE), [state]);\n const { data, previousData, loading, error, refetch } = useQuery(APPS_PAGE, {\n variables,\n skip: !workspaceId,\n errorPolicy: 'all',\n fetchPolicy: 'cache-and-network',\n });\n return paged(data?.getProviders, previousData?.getProviders, loading, error, refetch);\n}\n\nconst CATEGORY_FIELDS: ReadonlyArray<[ProviderCategory, keyof GetAppCategoryCountsQuery]> = [\n [ProviderCategory.Accounting, 'accounting'],\n [ProviderCategory.Analytics, 'analytics'],\n [ProviderCategory.Calendar, 'calendar'],\n [ProviderCategory.CloudStorage, 'cloudStorage'],\n [ProviderCategory.Communication, 'communication'],\n [ProviderCategory.Crm, 'crm'],\n [ProviderCategory.Custom, 'custom'],\n [ProviderCategory.Development, 'development'],\n [ProviderCategory.Email, 'email'],\n [ProviderCategory.Payment, 'payment'],\n [ProviderCategory.Productivity, 'productivity'],\n [ProviderCategory.Social, 'social'],\n];\n\n/** The categories in the data, largest first, with the total they add up to. */\nexport function categoryFacets(data: GetAppCategoryCountsQuery | undefined): {\n facets: CategoryFacet[];\n total: number;\n} {\n if (!data) return { facets: [], total: 0 };\n const facets = CATEGORY_FIELDS.map(([category, field]) => ({\n value: category as string,\n count: data[field]?.total ?? 0,\n }))\n .filter((facet) => facet.count > 0)\n .sort((a, b) => b.count - a.count || a.value.localeCompare(b.value));\n return { facets, total: data.all?.total ?? 0 };\n}\n\n/** How many apps the workspace can connect (0 until known). */\nexport function useAppCatalogTotal(): number {\n const { workspaceId } = useIntegrations();\n const { data } = useQuery(CATALOG_TOTAL, {\n skip: !workspaceId,\n errorPolicy: 'all',\n fetchPolicy: 'cache-first',\n });\n return data?.getProviders?.total ?? 0;\n}\n\nexport function useAppCategoryCounts(state: AppsUrlState) {\n const { workspaceId } = useIntegrations();\n const variables = useMemo(() => appCategoryCountVariables(state), [state]);\n const { data, previousData, loading } = useQuery(CATEGORY_COUNTS, {\n variables,\n skip: !workspaceId,\n errorPolicy: 'all',\n fetchPolicy: 'cache-and-network',\n });\n return { ...categoryFacets(data ?? previousData), loading };\n}\n\n/**\n * The popular apps this workspace offers, in fe-libs' popular order: one\n * request for the few keys, never the whole catalog.\n */\nexport function usePopularApps(limit: number) {\n const { workspaceId } = useIntegrations();\n const { data, loading } = useQuery(POPULAR_APPS_DOCUMENT, {\n skip: !workspaceId,\n errorPolicy: 'all',\n fetchPolicy: 'cache-first',\n });\n const apps = useMemo(\n () =>\n POPULAR_PROVIDER_KEYS.map((_, index) => data?.[`p${index}`] ?? null)\n .filter(\n (app): app is ConnectedAppProviderFieldsFragment =>\n app !== null && app.isEnabled && app.pluginStatus === PluginStatus.Installed\n )\n .slice(0, limit),\n [data, limit]\n );\n return { apps, loading };\n}\n\nconst POPULAR_APPS_DOCUMENT: TypedDocumentNode<\n Record<string, ConnectedAppProviderFieldsFragment | null>,\n Record<string, never>\n> = gql`\n query ConnectedAppsPopular {\n ${POPULAR_PROVIDER_KEYS.map(\n (key, index) =>\n `p${index}: getProviderByKey(key: ${JSON.stringify(key)}) { ...ConnectedAppProviderFields }`\n ).join('\\n')}\n }\n ${ConnectedAppProviderFieldsFragmentDoc}\n`;\n\n/** Apps whose name, key or description matches, for pickers: one page of 20. */\nexport function useAppSearch(\n search: string,\n page: number,\n category: ProviderCategory | null,\n enabled = true\n) {\n const { workspaceId } = useIntegrations();\n const variables = useMemo(\n () =>\n appsPageVariables(\n {\n q: search,\n category: category ?? 'all',\n method: 'all',\n install: PluginStatus.Installed,\n page,\n },\n GALLERY_PAGE_SIZE\n ),\n [search, page, category]\n );\n const { data, previousData, loading, error, refetch } = useQuery(APPS_PAGE, {\n variables,\n skip: !enabled || !workspaceId,\n errorPolicy: 'all',\n fetchPolicy: 'cache-and-network',\n });\n return paged(data?.getProviders, previousData?.getProviders, loading, error, refetch);\n}\n\n/** Connections whose name or description matches, for the activity filter. */\nexport function useConnectionSearch(search: string, enabled: boolean) {\n const { workspaceId } = useIntegrations();\n const variables = useMemo(\n () => ({\n filter: search.trim() ? { search: search.trim() } : {},\n pagination: { limit: GALLERY_PAGE_SIZE, offset: 0 },\n sort: { field: ConnectionSortField.Name, direction: ConnectionSortDirection.Asc },\n }),\n [search]\n );\n const { data, previousData, loading, error, refetch } = useQuery(CONNECTIONS_PAGE, {\n variables,\n skip: !enabled || !workspaceId,\n errorPolicy: 'all',\n fetchPolicy: 'cache-and-network',\n });\n return paged(data?.getConnections, previousData?.getConnections, loading, error, refetch);\n}\n\nexport function useAppDetails(id: string) {\n const { workspaceId } = useIntegrations();\n const { data, loading, error, refetch } = useQuery(APP_DETAILS, {\n variables: { id },\n skip: !workspaceId || !id,\n errorPolicy: 'all',\n fetchPolicy: 'cache-and-network',\n });\n return {\n app: data?.getProvider ?? null,\n /** The server has answered: a null app then means it is not in the catalog. */\n answered: answeredAboutRecord(data, error),\n loading,\n error,\n refetch,\n };\n}\n\n/** The first `limit` of the workspace's connections to one app, with the total. */\nexport function useAppConnections(providerId: string, limit: number) {\n const { workspaceId } = useIntegrations();\n const { data, loading, error, refetch } = useQuery(APP_CONNECTIONS, {\n variables: { providerId, pagination: { limit, offset: 0 } },\n skip: !workspaceId || !providerId,\n errorPolicy: 'all',\n fetchPolicy: 'cache-and-network',\n });\n return {\n items: data?.getConnectionsByProvider?.items ?? [],\n total: data?.getConnectionsByProvider?.total ?? 0,\n hasData: Boolean(data?.getConnectionsByProvider),\n loading,\n error,\n refetch,\n };\n}\n\n// ─── Activity logs ──────────────────────────────────────────────────────────\n\nexport function useActivityPage(state: ActivityUrlState, now: number, skip: boolean) {\n const { workspaceId } = useIntegrations();\n const variables = useMemo(\n () => activityPageVariables(state, GALLERY_PAGE_SIZE, now),\n [state, now]\n );\n const { data, previousData, loading, error, refetch } = useQuery(ACTIVITY_PAGE, {\n variables,\n skip: skip || !workspaceId,\n errorPolicy: 'all',\n fetchPolicy: 'cache-and-network',\n });\n return paged(data?.getIntegrationLogs, previousData?.getIntegrationLogs, loading, error, refetch);\n}\n\n// ─── The host's selection callbacks ─────────────────────────────────────────\n\n/**\n * A host's `onConnectionSelect`, handed the same full record today's list\n * hands it: the redesigned rows load only what they show, so the connection\n * is read in full (from the cache when the connection page already loaded it)\n * before the host hears of it. Null when the host passed no callback.\n */\nexport function useSelectConnection(): ((id: string) => void) | null {\n const client = useApolloClient();\n const { onConnectionSelect } = useIntegrations();\n return useMemo(() => {\n if (!onConnectionSelect) return null;\n return (id: string) => {\n client\n .query({ query: CONNECTION_FULL, variables: { id }, fetchPolicy: 'cache-first' })\n .then(({ data }) => {\n if (data?.getConnection) onConnectionSelect(mapConnection(data.getConnection));\n })\n // The click still opens the connection; only the host's notice is missed.\n .catch(() => undefined);\n };\n }, [client, onConnectionSelect]);\n}\n\n/** The same for a host's `onProviderSelect`, with today's full app record. */\nexport function useSelectApp(): ((id: string) => void) | null {\n const client = useApolloClient();\n const { onProviderSelect } = useIntegrations();\n return useMemo(() => {\n if (!onProviderSelect) return null;\n return (id: string) => {\n client\n .query({ query: PROVIDER_FULL, variables: { id }, fetchPolicy: 'cache-first' })\n .then(({ data }) => {\n if (data?.getProvider) onProviderSelect(mapProvider(data.getProvider));\n })\n .catch(() => undefined);\n };\n }, [client, onProviderSelect]);\n}\n"],"mappings":";;;;;;;;;;;AAqFA,SAASA,EACP,GACsC;CACtC,OAAOC;AACT;AAEA,IAAMC,IAAmBF,EACvBG,CACF,GACMC,IAAgBJ,EAGpBK,CAAoC,GAChCC,IAAqBN,EACzBO,CACF,GACMC,IAASR,EACbS,CACF,GACMC,IAAYV,EAAmDW,CAAmB,GAClFC,IAAgBZ,EACpBa,CACF,GACMC,IAAkBd,EACtBe,CACF,GACMC,IAAchB,EAAuDiB,CAAqB,GAC1FC,IAAkBlB,EACtBmB,CACF,GACMC,IAAgBpB,EACpBqB,CACF,GAEMC,IAAkBtB,EACtBuB,CACF,GACMC,IAAgBxB,EAAmDyB,EAAmB,GAGtFC,oBAAuC,IAAI,IAAI,CAAC,aAAa,WAAW,CAAC;AAQ/E,SAASC,EAAoB,GAAe,GAAuC;CAGjF,OAFIC,MAAS,KAAA,IAAkB,KAC/B,CAAKC,KAEHC,GAAsB,GAAGD,CAAK,KAC9BA,EAAM,OAAO,SAAS,KACtBA,EAAM,OAAO,OAAO,MAAUH,EAAgB,IAAI,OAAOK,EAAM,YAAY,QAAQ,EAAE,CAAC,CAAC;AAE3F;AAiBA,SAASC,EACP,GACA,GACA,GACA,GACA,GACgB;CAChB,IAAMC,IAAQC,KAAWC,KAAY;CACrC,OAAO;EACL,OAAOF,IAAQ,CAAC,GAAGA,EAAM,KAAK,IAAI,CAAC;EACnC,OAAOA,GAAO,SAAS;EACvB,SAASA,MAAU;EACnB,aAAaG,KAAW,CAACF,KAAW,EAAQC;EAC5C,SAAS,CAACC,KAAW,EAAQF;EAC7B;EACA,OAAOA,IAAU,KAAA,IAAYL;EAC7B,eAAe;GACb,EAAa;EACf;CACF;AACF;AAIA,SAAgBQ,GAAmB,GAA4B;CAC7D,IAAM,EAAE,mBAAgBC,EAAgB,GAClCC,IAAYC,QA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G;AAUA,SAAgByD,KAAqD;CACnE,IAAMC,IAASC,EAAgB,GACzB,EAAE,0BAAuBpE,EAAgB;CAC/C,OAAOE,QACAmE,KACG,MAAe;EACrB,EACG,MAAM;GAAE,OAAOrF;GAAiB,WAAW,EAAE,MAAG;GAAG,aAAa;EAAc,CAAC,CAAC,CAChF,MAAM,EAAE,cAAW;GAClB,AAAIM,GAAM,iBAAe+E,EAAmBC,EAAchF,EAAK,aAAa,CAAC;EAC/E,CAAC,CAAC,CAED,YAAY,KAAA,CAAS;CAC1B,IATgC,MAU/B,CAAC6E,GAAQE,CAAkB,CAAC;AACjC;AAGA,SAAgBE,KAA8C;CAC5D,IAAMJ,IAASC,EAAgB,GACzB,EAAE,wBAAqBpE,EAAgB;CAC7C,OAAOE,QACAsE,KACG,MAAe;EACrB,EACG,MAAM;GAAE,OAAOtF;GAAe,WAAW,EAAE,MAAG;GAAG,aAAa;EAAc,CAAC,CAAC,CAC9E,MAAM,EAAE,cAAW;GAClB,AAAII,GAAM,eAAakF,EAAiBC,EAAYnF,EAAK,WAAW,CAAC;EACvE,CAAC,CAAC,CACD,YAAY,KAAA,CAAS;CAC1B,IAR8B,MAS7B,CAAC6E,GAAQK,CAAgB,CAAC;AAC/B"}
@@ -0,0 +1,21 @@
1
+ export interface ListUpdateOptions {
2
+ /** Change the current history entry instead of adding one. */
3
+ replace?: boolean;
4
+ }
5
+ export declare function useListState<S>(read: (params: URLSearchParams) => S, write: (params: URLSearchParams, patch: Partial<S>) => URLSearchParams): readonly [S, (patch: Partial<S>, options?: ListUpdateOptions) => void];
6
+ /**
7
+ * A page past the end (an old link, a narrower search) becomes the last page,
8
+ * fixed in the address without a history entry, once the count is known.
9
+ */
10
+ export declare function useClampedPage(page: number, total: number, pageSize: number, settled: boolean, setPage: (page: number) => void): void;
11
+ /** A value that settles `delay` ms after it stops changing. */
12
+ export declare function useDebouncedValue<T>(value: T, delay?: number): T;
13
+ /**
14
+ * The search box's text. Typing is instant; the address (and so the server
15
+ * query) follows once the person pauses, without a history entry per letter.
16
+ * When the address changes on its own (Back, Clear filters, a link), the box
17
+ * follows it and a half-typed word still waiting to be sent is dropped: the
18
+ * navigation is the newer intent. The box's own search arriving in the
19
+ * address never resets what the person has typed since.
20
+ */
21
+ export declare function useSearchDraft(committed: string, commit: (value: string) => void, delay?: number): readonly [string, (value: string) => void];
@@ -0,0 +1,43 @@
1
+ import { useCallback as e, useEffect as t, useLayoutEffect as n, useMemo as r, useRef as i, useState as a } from "react";
2
+ import { useSearchParams as o } from "react-router";
3
+ import { clampPage as s, totalPagesFor as c } from "@burdenoff/fe-libs/ui";
4
+ // src/integrations/connected-apps/hooks/useListState.ts
5
+ function l(t, n) {
6
+ let [i, a] = o();
7
+ return [r(() => t(i), [i, t]), e((e, t) => a((t) => n(t, e), { replace: t?.replace }), [a, n])];
8
+ }
9
+ function u(e, n, r, i, a) {
10
+ let o = c(n, r);
11
+ t(() => {
12
+ if (!i) return;
13
+ let t = s(e, o);
14
+ t !== e && a(t);
15
+ }, [
16
+ i,
17
+ e,
18
+ o,
19
+ a
20
+ ]);
21
+ }
22
+ function d(e, n = 300) {
23
+ let [r, i] = a(e);
24
+ return t(() => {
25
+ let t = setTimeout(() => i(e), n);
26
+ return () => clearTimeout(t);
27
+ }, [e, n]), r;
28
+ }
29
+ function f(r, o, s = 300) {
30
+ let [c, l] = a(r), [u, d] = a(r), [f, p] = a(null), [m, h] = a(0), g = i(null);
31
+ return r !== u && (d(r), r === f ? p(null) : (l(r), h((e) => e + 1))), n(() => {
32
+ m !== 0 && g.current && (clearTimeout(g.current), g.current = null);
33
+ }, [m]), t(() => () => {
34
+ g.current && clearTimeout(g.current);
35
+ }, []), [c, e((e) => {
36
+ l(e), g.current && clearTimeout(g.current), g.current = setTimeout(() => {
37
+ g.current = null, p(e), o(e);
38
+ }, s);
39
+ }, [o, s])];
40
+ }
41
+ export { u as useClampedPage, d as useDebouncedValue, l as useListState, f as useSearchDraft };
42
+
43
+ //# sourceMappingURL=useListState.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useListState.js","names":["useListState","params","setParams","useSearchParams","useMemo","read","useCallback","write","previous","patch","options","useClampedPage","lastPage","totalPagesFor","total","pageSize","settled","clamped","clampPage","page","setPage","useDebouncedValue","setSettled","useState","value","useEffect","timer","delay","useSearchDraft","draft","setDraft","committed","seen","setSeen","sent","setSent","outsideChanges","setOutsideChanges","useRef","count","useLayoutEffect","commit"],"sources":["../../../../src/integrations/connected-apps/hooks/useListState.ts"],"sourcesContent":["/**\n * List state that lives in the address (BOFF-15373): read it with a page's\n * `read*Url`, change it with its `with*State`. Filter and page changes add a\n * history entry, so Back returns to the previous results; corrections (a page\n * past the end, a search being typed) replace the current entry.\n */\nimport { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';\nimport { useSearchParams } from 'react-router';\nimport { clampPage, totalPagesFor } from '@burdenoff/fe-libs/ui';\n\nexport interface ListUpdateOptions {\n /** Change the current history entry instead of adding one. */\n replace?: boolean;\n}\n\nexport function useListState<S>(\n read: (params: URLSearchParams) => S,\n write: (params: URLSearchParams, patch: Partial<S>) => URLSearchParams\n) {\n const [params, setParams] = useSearchParams();\n const state = useMemo(() => read(params), [params, read]);\n const update = useCallback(\n (patch: Partial<S>, options?: ListUpdateOptions) =>\n setParams((previous) => write(previous, patch), { replace: options?.replace }),\n [setParams, write]\n );\n return [state, update] as const;\n}\n\n/**\n * A page past the end (an old link, a narrower search) becomes the last page,\n * fixed in the address without a history entry, once the count is known.\n */\nexport function useClampedPage(\n page: number,\n total: number,\n pageSize: number,\n settled: boolean,\n setPage: (page: number) => void\n) {\n const lastPage = totalPagesFor(total, pageSize);\n useEffect(() => {\n if (!settled) return;\n const clamped = clampPage(page, lastPage);\n if (clamped !== page) setPage(clamped);\n }, [settled, page, lastPage, setPage]);\n}\n\n/** A value that settles `delay` ms after it stops changing. */\nexport function useDebouncedValue<T>(value: T, delay = 300): T {\n const [settled, setSettled] = useState(value);\n useEffect(() => {\n const timer = setTimeout(() => setSettled(value), delay);\n return () => clearTimeout(timer);\n }, [value, delay]);\n return settled;\n}\n\n/**\n * The search box's text. Typing is instant; the address (and so the server\n * query) follows once the person pauses, without a history entry per letter.\n * When the address changes on its own (Back, Clear filters, a link), the box\n * follows it and a half-typed word still waiting to be sent is dropped: the\n * navigation is the newer intent. The box's own search arriving in the\n * address never resets what the person has typed since.\n */\nexport function useSearchDraft(committed: string, commit: (value: string) => void, delay = 300) {\n const [draft, setDraft] = useState(committed);\n // The address value last seen, the value this box last sent, and how many\n // times the address changed on its own.\n const [seen, setSeen] = useState(committed);\n const [sent, setSent] = useState<string | null>(null);\n const [outsideChanges, setOutsideChanges] = useState(0);\n const timer = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n if (committed !== seen) {\n // Adjusting state while rendering, as React recommends for a changed prop.\n setSeen(committed);\n if (committed === sent) {\n setSent(null);\n } else {\n setDraft(committed);\n setOutsideChanges((count) => count + 1);\n }\n }\n\n // An outside change cancels the search still waiting to be sent. A layout\n // effect, so the timer cannot fire between this render and the cancel.\n useLayoutEffect(() => {\n if (outsideChanges === 0 || !timer.current) return;\n clearTimeout(timer.current);\n timer.current = null;\n }, [outsideChanges]);\n\n useEffect(\n () => () => {\n if (timer.current) clearTimeout(timer.current);\n },\n []\n );\n\n const change = useCallback(\n (value: string) => {\n setDraft(value);\n if (timer.current) clearTimeout(timer.current);\n timer.current = setTimeout(() => {\n timer.current = null;\n setSent(value);\n commit(value);\n }, delay);\n },\n [commit, delay]\n );\n\n return [draft, change] as const;\n}\n"],"mappings":";;;;AAeA,SAAgBA,EACd,GACA,GACA;CACA,IAAM,CAACC,GAAQC,KAAaC,EAAgB;CAO5C,OAAO,CANOC,QAAcC,EAAKJ,CAAM,GAAG,CAACA,GAAQI,CAAI,CAM/C,GALOC,GACZ,GAAmB,MAClBJ,GAAW,MAAaK,EAAMC,GAAUC,CAAK,GAAG,EAAE,SAASC,GAAS,QAAQ,CAAC,GAC/E,CAACR,GAA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BAAiB;GAG/B,AAFA,EAAM,UAAU,MAChBS,EAAQX,CAAK,GACbiB,EAAOjB,CAAK;EACd,GAAGG,CAAK;CACV,GACA,CAACc,GAAQd,CAAK,CAGD,CAAM;AACvB"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Call `onPicked()` when the person picks a page; once that page is on screen,
3
+ * the results heading takes focus and scrolls into view (instantly when the
4
+ * person prefers reduced motion).
5
+ */
6
+ export declare function useResultsFocus(pageLoading: boolean, hasData: boolean, page: number): {
7
+ headingRef: import('react').RefObject<HTMLHeadingElement | null>;
8
+ onPicked: () => void;
9
+ };
10
+ export type ListView = 'list' | 'grid';
11
+ /** Rows or cards, remembered per list in this browser; `fallback` until chosen. */
12
+ export declare function useListView(storageKey: string, fallback: ListView): readonly [ListView, (next: ListView) => void];
@@ -0,0 +1,46 @@
1
+ import { useCallback as e, useEffect as t, useRef as n, useState as r } from "react";
2
+ // src/integrations/connected-apps/hooks/usePageChrome.ts
3
+ function i(r, i, a) {
4
+ let o = n(null), s = n(!1);
5
+ return t(() => {
6
+ if (!s.current || r || !i) return;
7
+ s.current = !1;
8
+ let e = o.current;
9
+ if (!e) return;
10
+ e.focus({ preventScroll: !0 });
11
+ let t = typeof window < "u" && typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
12
+ e.scrollIntoView?.({
13
+ block: "start",
14
+ behavior: t ? "auto" : "smooth"
15
+ });
16
+ }, [
17
+ r,
18
+ i,
19
+ a
20
+ ]), {
21
+ headingRef: o,
22
+ onPicked: e(() => {
23
+ s.current = !0;
24
+ }, [])
25
+ };
26
+ }
27
+ function a(e) {
28
+ try {
29
+ let t = window.localStorage.getItem(e);
30
+ return t === "list" || t === "grid" ? t : null;
31
+ } catch {
32
+ return null;
33
+ }
34
+ }
35
+ function o(t, n) {
36
+ let i = `integrations.connectedApps.view.${t}`, [o, s] = r(() => a(i) ?? n);
37
+ return [o, e((e) => {
38
+ s(e);
39
+ try {
40
+ window.localStorage.setItem(i, e);
41
+ } catch {}
42
+ }, [i])];
43
+ }
44
+ export { o as useListView, i as useResultsFocus };
45
+
46
+ //# sourceMappingURL=usePageChrome.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePageChrome.js","names":["useResultsFocus","headingRef","useRef","pending","useEffect","pageLoading","hasData","heading","reduce","page","useCallback","readStoredView","value","key","useListView","storageKey","view","setViewState","useState","fallback","next"],"sources":["../../../../src/integrations/connected-apps/hooks/usePageChrome.ts"],"sourcesContent":["/**\n * Small page behaviours the redesigned lists share with FluidGrids' Templates\n * gallery (BOFF-15373): focus moves to the results heading once a page the\n * person picked has loaded, and each list remembers its view (rows or cards)\n * for this person.\n */\nimport { useCallback, useEffect, useRef, useState } from 'react';\n\n/**\n * Call `onPicked()` when the person picks a page; once that page is on screen,\n * the results heading takes focus and scrolls into view (instantly when the\n * person prefers reduced motion).\n */\nexport function useResultsFocus(pageLoading: boolean, hasData: boolean, page: number) {\n const headingRef = useRef<HTMLHeadingElement>(null);\n const pending = useRef(false);\n\n useEffect(() => {\n if (!pending.current || pageLoading || !hasData) return;\n pending.current = false;\n const heading = headingRef.current;\n if (!heading) return;\n heading.focus({ preventScroll: true });\n const reduce =\n typeof window !== 'undefined' &&\n typeof window.matchMedia === 'function' &&\n window.matchMedia('(prefers-reduced-motion: reduce)').matches;\n heading.scrollIntoView?.({ block: 'start', behavior: reduce ? 'auto' : 'smooth' });\n }, [pageLoading, hasData, page]);\n\n const onPicked = useCallback(() => {\n pending.current = true;\n }, []);\n\n return { headingRef, onPicked };\n}\n\nexport type ListView = 'list' | 'grid';\n\nfunction readStoredView(key: string): ListView | null {\n try {\n const value = window.localStorage.getItem(key);\n return value === 'list' || value === 'grid' ? value : null;\n } catch {\n // Storage can be unavailable (private mode, blocked site data): use the default.\n return null;\n }\n}\n\n/** Rows or cards, remembered per list in this browser; `fallback` until chosen. */\nexport function useListView(storageKey: string, fallback: ListView) {\n const key = `integrations.connectedApps.view.${storageKey}`;\n const [view, setViewState] = useState<ListView>(() => readStoredView(key) ?? fallback);\n const setView = useCallback(\n (next: ListView) => {\n setViewState(next);\n try {\n window.localStorage.setItem(key, next);\n } catch {\n // Not remembered when storage is unavailable; the choice still applies now.\n }\n },\n [key]\n );\n return [view, setView] as const;\n}\n"],"mappings":";;AAaA,SAAgBA,EAAgB,GAAsB,GAAkB,GAAc;CACpF,IAAMC,IAAaC,EAA2B,IAAI,GAC5CC,IAAUD,EAAO,EAAK;CAmB5B,OAjBAE,QAAgB;EACd,IAAI,CAACD,EAAQ,WAAWE,KAAe,CAACC,GAAS;EACjD,EAAQ,UAAU;EAClB,IAAMC,IAAUN,EAAW;EAC3B,IAAI,CAACM,GAAS;EACd,EAAQ,MAAM,EAAE,eAAe,GAAK,CAAC;EACrC,IAAMC,IACJ,OAAO,SAAW,OAClB,OAAO,OAAO,cAAe,cAC7B,OAAO,WAAW,kCAAkC,CAAC,CAAC;EACxD,EAAQ,iBAAiB;GAAE,OAAO;GAAS,UAAUA,IAAS,SAAS;EAAS,CAAC;CACnF,GAAG;EAACH;EAAaC;EAASG;CAAI,CAAC,GAMxB;EAAE;EAAY,UAJJC,QAAkB;GACjC,EAAQ,UAAU;EACpB,GAAG,CAAC,CAEiB;CAAS;AAChC;AAIA,SAASC,EAAe,GAA8B;CACpD,IAAI;EACF,IAAMC,IAAQ,OAAO,aAAa,QAAQC,CAAG;EAC7C,OAAOD,MAAU,UAAUA,MAAU,SAASA,IAAQ;CACxD,QAAQ;EAEN,OAAO;CACT;AACF;AAGA,SAAgBE,EAAY,GAAoB,GAAoB;CAClE,IAAMD,IAAM,mCAAmCE,KACzC,CAACC,GAAMC,KAAgBC,QAAyBP,EAAeE,CAAG,KAAKM,CAAQ;CAYrF,OAAO,CAACH,GAXQN,GACb,MAAmB;EAClB,EAAaU,CAAI;EACjB,IAAI;GACF,OAAO,aAAa,QAAQP,GAAKO,CAAI;EACvC,QAAQ,CAER;CACF,GACA,CAACP,CAAG,CAEQ,CAAO;AACvB"}
@@ -0,0 +1,26 @@
1
+ import { GetActivityPageQuery } from '../../../generated/wspace-operations';
2
+ import { LogAction, LogLevel } from '../../../generated/wspace-types';
3
+ import { StatusTone } from './status';
4
+ import { Translate } from './translate';
5
+ import { ActivityRange } from './urlState';
6
+ /** One event as Activity logs reads it. */
7
+ export type ActivityEvent = GetActivityPageQuery['getIntegrationLogs']['items'][number];
8
+ export declare function levelLabel(tr: Translate, level: LogLevel): string;
9
+ /** The level filter's option, and the results heading for it. */
10
+ export declare function levelFilterLabel(tr: Translate, level: LogLevel | 'all'): string;
11
+ /** Errors are red, warnings yellow, the rest quiet. */
12
+ export declare function levelTone(level: LogLevel): StatusTone;
13
+ export declare function actionLabel(tr: Translate, action: LogAction): string;
14
+ export declare function rangeLabel(tr: Translate, range: ActivityRange): string;
15
+ export interface CsvEvent {
16
+ createdAt: string;
17
+ level: LogLevel;
18
+ action: LogAction;
19
+ message: string;
20
+ requestMethod: string | null;
21
+ requestUrl: string | null;
22
+ responseStatus: number | null;
23
+ connectionName: string;
24
+ }
25
+ /** The events as CSV, with translated headings; values stay as the service wrote them. */
26
+ export declare function eventsToCsv(tr: Translate, events: readonly CsvEvent[]): string;
@@ -0,0 +1,79 @@
1
+ import { LogAction as e, LogLevel as t } from "../../../generated/wspace-types.js";
2
+ // src/integrations/connected-apps/model/activity.ts
3
+ function n(e, n) {
4
+ switch (n) {
5
+ case t.Error: return e("integrations.connectedApps.level.error", "Error");
6
+ case t.Warning: return e("integrations.connectedApps.level.warning", "Warning");
7
+ case t.Info: return e("integrations.connectedApps.level.info", "Info");
8
+ case t.Debug: return e("integrations.connectedApps.level.debug", "Debug");
9
+ }
10
+ }
11
+ function r(e, n) {
12
+ switch (n) {
13
+ case "all": return e("integrations.connectedApps.level.all", "Every level");
14
+ case t.Error: return e("integrations.connectedApps.level.errors", "Errors");
15
+ case t.Warning: return e("integrations.connectedApps.level.warnings", "Warnings");
16
+ case t.Info: return e("integrations.connectedApps.level.info", "Info");
17
+ case t.Debug: return e("integrations.connectedApps.level.debug", "Debug");
18
+ }
19
+ }
20
+ function i(e) {
21
+ switch (e) {
22
+ case t.Error: return "danger";
23
+ case t.Warning: return "warning";
24
+ case t.Info:
25
+ case t.Debug: return "neutral";
26
+ }
27
+ }
28
+ function a(t, n) {
29
+ switch (n) {
30
+ case e.ApiCall: return t("integrations.connectedApps.action.apiCall", "Request");
31
+ case e.AuthCompleted: return t("integrations.connectedApps.action.authCompleted", "Sign-in completed");
32
+ case e.AuthFailed: return t("integrations.connectedApps.action.authFailed", "Sign-in failed");
33
+ case e.AuthInitiated: return t("integrations.connectedApps.action.authInitiated", "Sign-in started");
34
+ case e.ConnectionCreated: return t("integrations.connectedApps.action.connectionCreated", "Connection created");
35
+ case e.ConnectionDeleted: return t("integrations.connectedApps.action.connectionDeleted", "Connection removed");
36
+ case e.ConnectionUpdated: return t("integrations.connectedApps.action.connectionUpdated", "Connection updated");
37
+ case e.CredentialUpdated: return t("integrations.connectedApps.action.credentialUpdated", "Key updated");
38
+ case e.PermissionChanged: return t("integrations.connectedApps.action.permissionChanged", "Sharing changed");
39
+ case e.TokenExpired: return t("integrations.connectedApps.action.tokenExpired", "Token expired");
40
+ case e.TokenRefreshed: return t("integrations.connectedApps.action.tokenRefreshed", "Token refreshed");
41
+ case e.TokenRevoked: return t("integrations.connectedApps.action.tokenRevoked", "Token revoked");
42
+ }
43
+ }
44
+ function o(e, t) {
45
+ switch (t) {
46
+ case "all": return e("integrations.connectedApps.range.all", "Any time");
47
+ case "24h": return e("integrations.connectedApps.range.day", "Last 24 hours");
48
+ case "7d": return e("integrations.connectedApps.range.week", "Last 7 days");
49
+ case "30d": return e("integrations.connectedApps.range.month", "Last 30 days");
50
+ }
51
+ }
52
+ function s(e) {
53
+ let t = String(e ?? "");
54
+ return `"${(/^[=+\-@\t\r]/.test(t) ? `'${t}` : t).replaceAll("\"", "\"\"")}"`;
55
+ }
56
+ function c(e, t) {
57
+ return [[
58
+ e("integrations.connectedApps.csv.createdAt", "Time"),
59
+ e("integrations.connectedApps.csv.level", "Level"),
60
+ e("integrations.connectedApps.csv.action", "Action"),
61
+ e("integrations.connectedApps.csv.connection", "Connection"),
62
+ e("integrations.connectedApps.csv.message", "Message"),
63
+ e("integrations.connectedApps.csv.requestMethod", "Request method"),
64
+ e("integrations.connectedApps.csv.requestUrl", "Request URL"),
65
+ e("integrations.connectedApps.csv.status", "Status")
66
+ ], ...t.map((e) => [
67
+ e.createdAt,
68
+ e.level,
69
+ e.action,
70
+ e.connectionName,
71
+ e.message,
72
+ e.requestMethod,
73
+ e.requestUrl,
74
+ e.responseStatus
75
+ ])].map((e) => e.map(s).join(",")).join("\n");
76
+ }
77
+ export { a as actionLabel, c as eventsToCsv, r as levelFilterLabel, n as levelLabel, i as levelTone, o as rangeLabel };
78
+
79
+ //# sourceMappingURL=activity.js.map