@workos-inc/widgets 1.9.1 → 1.10.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.
Files changed (32) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/cjs/admin-portal-audit-log-streaming.client.cjs +167 -0
  3. package/dist/cjs/admin-portal-audit-log-streaming.client.cjs.map +1 -0
  4. package/dist/cjs/admin-portal-audit-log-streaming.client.d.cts +26 -0
  5. package/dist/cjs/api/api-provider.cjs.map +1 -1
  6. package/dist/cjs/api/api-provider.d.cts +1 -1
  7. package/dist/cjs/index.cjs +11 -0
  8. package/dist/cjs/index.cjs.map +1 -1
  9. package/dist/cjs/index.d.cts +2 -0
  10. package/dist/cjs/lib/admin-portal-audit-log-streaming.cjs +321 -0
  11. package/dist/cjs/lib/admin-portal-audit-log-streaming.cjs.map +1 -0
  12. package/dist/cjs/lib/admin-portal-audit-log-streaming.d.cts +54 -0
  13. package/dist/cjs/lib/audit-log-stream-icons.cjs +63 -0
  14. package/dist/cjs/lib/audit-log-stream-icons.cjs.map +1 -0
  15. package/dist/cjs/lib/audit-log-stream-icons.d.cts +5 -0
  16. package/dist/cjs/lib/identity-providers.d.cts +2 -2
  17. package/dist/esm/admin-portal-audit-log-streaming.client.d.ts +26 -0
  18. package/dist/esm/admin-portal-audit-log-streaming.client.js +153 -0
  19. package/dist/esm/admin-portal-audit-log-streaming.client.js.map +1 -0
  20. package/dist/esm/api/api-provider.d.ts +1 -1
  21. package/dist/esm/api/api-provider.js.map +1 -1
  22. package/dist/esm/index.d.ts +2 -0
  23. package/dist/esm/index.js +12 -0
  24. package/dist/esm/index.js.map +1 -1
  25. package/dist/esm/lib/admin-portal-audit-log-streaming.d.ts +54 -0
  26. package/dist/esm/lib/admin-portal-audit-log-streaming.js +290 -0
  27. package/dist/esm/lib/admin-portal-audit-log-streaming.js.map +1 -0
  28. package/dist/esm/lib/audit-log-stream-icons.d.ts +5 -0
  29. package/dist/esm/lib/audit-log-stream-icons.js +39 -0
  30. package/dist/esm/lib/audit-log-stream-icons.js.map +1 -0
  31. package/dist/esm/lib/identity-providers.d.ts +2 -2
  32. package/package.json +3 -3
package/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.10.0
4
+
5
+ - Add new `AdminPortalAuditLogStreaming` Widget for monitoring audit log stream status and configuration
6
+
3
7
  ## 1.9.1
4
8
 
5
9
  - Fix expired admin portal link error for the `AdminPortalSsoConnection` Widget
@@ -0,0 +1,167 @@
1
+ "use strict";
2
+ "use client";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+ var admin_portal_audit_log_streaming_client_exports = {};
21
+ __export(admin_portal_audit_log_streaming_client_exports, {
22
+ AdminPortalAuditLogStreaming: () => AdminPortalAuditLogStreaming,
23
+ AdminPortalAuditLogStreamingButton: () => import_admin_portal_audit_log_streaming3.AdminPortalAuditLogStreamingButton,
24
+ AdminPortalAuditLogStreamingError: () => import_admin_portal_audit_log_streaming2.AdminPortalAuditLogStreamingError,
25
+ AdminPortalAuditLogStreamingLoading: () => import_admin_portal_audit_log_streaming2.AdminPortalAuditLogStreamingLoading,
26
+ AdminPortalAuditLogStreamingPresentational: () => import_admin_portal_audit_log_streaming3.AdminPortalAuditLogStreaming
27
+ });
28
+ module.exports = __toCommonJS(admin_portal_audit_log_streaming_client_exports);
29
+ var import_jsx_runtime = require("react/jsx-runtime");
30
+ var import_admin_portal_audit_log_streaming = require("./lib/admin-portal-audit-log-streaming.js");
31
+ var import_api_provider = require("./api/api-provider.js");
32
+ var import_endpoint = require("./api/endpoint.js");
33
+ var import_widgets_context = require("./lib/widgets-context.js");
34
+ var import_error_boundary = require("./lib/error-boundary.js");
35
+ var import_admin_portal_audit_log_streaming2 = require("./lib/admin-portal-audit-log-streaming.js");
36
+ var import_admin_portal_audit_log_streaming3 = require("./lib/admin-portal-audit-log-streaming.js");
37
+ const AdminPortalAuditLogStreaming = ({ authToken, ...domProps }) => {
38
+ const baseUrl = (0, import_widgets_context.useWorkOsApiUrl)();
39
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
40
+ import_error_boundary.ErrorBoundary,
41
+ {
42
+ fallbackRender: ({ error }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_admin_portal_audit_log_streaming.AdminPortalAuditLogStreamingError, { error, ...domProps }),
43
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
44
+ import_api_provider.ApiProvider,
45
+ {
46
+ widgetType: "admin-portal-audit-log-streaming",
47
+ authToken,
48
+ baseUrl,
49
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AdminPortalAuditLogStreamingImpl, { ...domProps })
50
+ }
51
+ )
52
+ }
53
+ );
54
+ };
55
+ const AdminPortalAuditLogStreamingImpl = (props) => {
56
+ const isApiReady = (0, import_api_provider.useApiReady)();
57
+ const { mutate: generateAdminPortalLink, ...mutation } = (0, import_endpoint.useGenerateAdminPortalLink)({
58
+ mutation: {
59
+ onSuccess: (data) => {
60
+ window.open(data.link, "_blank", "noopener,noreferrer");
61
+ }
62
+ }
63
+ });
64
+ const adminPortalLink = mutation.data?.link ?? null;
65
+ const query = (0, import_endpoint.useGetAuditLogStream)({
66
+ query: {
67
+ enabled: isApiReady
68
+ }
69
+ });
70
+ const initConfig = () => {
71
+ generateAdminPortalLink({
72
+ params: {
73
+ intent: "log_streams"
74
+ }
75
+ });
76
+ };
77
+ if (query.isLoading) {
78
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_admin_portal_audit_log_streaming.AdminPortalAuditLogStreamingLoading, { ...props });
79
+ }
80
+ if (query.isError) {
81
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_admin_portal_audit_log_streaming.AdminPortalAuditLogStreamingError, { error: query.error, ...props });
82
+ }
83
+ if (query.data) {
84
+ const stream = query.data;
85
+ if (!Object.hasOwn(stream, "id")) {
86
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
87
+ import_admin_portal_audit_log_streaming.AdminPortalAuditLogStreaming,
88
+ {
89
+ ...props,
90
+ connectionStatus: "NotConfigured",
91
+ adminPortalOpenButton: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
92
+ import_admin_portal_audit_log_streaming.AdminPortalAuditLogStreamingButton,
93
+ {
94
+ isPending: mutation.isPending,
95
+ href: adminPortalLink,
96
+ initConfig
97
+ }
98
+ )
99
+ }
100
+ );
101
+ }
102
+ const configuredStream = stream;
103
+ const statusProps = (() => {
104
+ switch (configuredStream.state) {
105
+ case "Inactive":
106
+ return {
107
+ connectionStatus: "Inactive",
108
+ destinationType: configuredStream.type
109
+ };
110
+ case "Active":
111
+ return {
112
+ connectionStatus: "Active",
113
+ destinationType: configuredStream.type,
114
+ lastSyncedEventId: configuredStream.lastSyncedEventId
115
+ };
116
+ case "Error":
117
+ return {
118
+ connectionStatus: "Error",
119
+ destinationType: configuredStream.type,
120
+ lastSyncedEventId: configuredStream.lastSyncedEventId
121
+ };
122
+ case "Invalid":
123
+ return {
124
+ connectionStatus: "Error",
125
+ destinationType: configuredStream.type,
126
+ lastSyncedEventId: configuredStream.lastSyncedEventId
127
+ };
128
+ default:
129
+ return {
130
+ connectionStatus: "Inactive",
131
+ destinationType: configuredStream.type
132
+ };
133
+ }
134
+ })();
135
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
136
+ import_error_boundary.ErrorBoundary,
137
+ {
138
+ fallbackRender: ({ error }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_admin_portal_audit_log_streaming.AdminPortalAuditLogStreamingError, { error, ...props }),
139
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
140
+ import_admin_portal_audit_log_streaming.AdminPortalAuditLogStreaming,
141
+ {
142
+ ...props,
143
+ ...statusProps,
144
+ adminPortalOpenButton: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
145
+ import_admin_portal_audit_log_streaming.AdminPortalAuditLogStreamingButton,
146
+ {
147
+ isPending: mutation.isPending,
148
+ href: adminPortalLink,
149
+ initConfig
150
+ }
151
+ )
152
+ }
153
+ )
154
+ }
155
+ );
156
+ }
157
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_admin_portal_audit_log_streaming.AdminPortalAuditLogStreamingLoading, { ...props });
158
+ };
159
+ // Annotate the CommonJS export names for ESM import in node:
160
+ 0 && (module.exports = {
161
+ AdminPortalAuditLogStreaming,
162
+ AdminPortalAuditLogStreamingButton,
163
+ AdminPortalAuditLogStreamingError,
164
+ AdminPortalAuditLogStreamingLoading,
165
+ AdminPortalAuditLogStreamingPresentational
166
+ });
167
+ //# sourceMappingURL=admin-portal-audit-log-streaming.client.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/admin-portal-audit-log-streaming.client.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport {\n AdminPortalAuditLogStreamingError,\n AdminPortalAuditLogStreamingLoading,\n AdminPortalAuditLogStreaming as AdminPortalAuditLogStreamingPresentational,\n AdminPortalAuditLogStreamingButton,\n} from \"./lib/admin-portal-audit-log-streaming.js\";\nimport type { AdminPortalAuditLogStreamingStatusProps } from \"./lib/admin-portal-audit-log-streaming.js\";\nimport { ApiProvider, AuthToken, useApiReady } from \"./api/api-provider.js\";\nimport {\n useGenerateAdminPortalLink,\n useGetAuditLogStream,\n type AuditLogStreamJSON,\n} from \"./api/endpoint.js\";\nimport { useWorkOsApiUrl } from \"./lib/widgets-context.js\";\nimport { ErrorBoundary } from \"./lib/error-boundary.js\";\nimport { WidgetRootDomProps } from \"./lib/utils.js\";\n\ninterface AdminPortalAuditLogStreamingProps extends WidgetRootDomProps {\n authToken: AuthToken;\n}\n\nconst AdminPortalAuditLogStreaming: React.FC<\n AdminPortalAuditLogStreamingProps\n> = ({ authToken, ...domProps }) => {\n const baseUrl = useWorkOsApiUrl();\n return (\n <ErrorBoundary\n fallbackRender={({ error }) => (\n <AdminPortalAuditLogStreamingError error={error} {...domProps} />\n )}\n >\n <ApiProvider\n widgetType=\"admin-portal-audit-log-streaming\"\n authToken={authToken}\n baseUrl={baseUrl}\n >\n <AdminPortalAuditLogStreamingImpl {...domProps} />\n </ApiProvider>\n </ErrorBoundary>\n );\n};\n\nconst AdminPortalAuditLogStreamingImpl = (props: WidgetRootDomProps) => {\n const isApiReady = useApiReady();\n\n const { mutate: generateAdminPortalLink, ...mutation } =\n useGenerateAdminPortalLink({\n mutation: {\n onSuccess: (data) => {\n window.open(data.link, \"_blank\", \"noopener,noreferrer\");\n },\n },\n });\n\n const adminPortalLink = mutation.data?.link ?? null;\n\n const query = useGetAuditLogStream({\n query: {\n enabled: isApiReady,\n },\n });\n\n const initConfig = () => {\n generateAdminPortalLink({\n params: {\n intent: \"log_streams\",\n },\n });\n };\n\n if (query.isLoading) {\n return <AdminPortalAuditLogStreamingLoading {...props} />;\n }\n\n if (query.isError) {\n return <AdminPortalAuditLogStreamingError error={query.error} {...props} />;\n }\n\n if (query.data) {\n const stream = query.data;\n\n // Check if stream is configured (has id property)\n // API returns empty object {} when no stream is configured\n if (!Object.hasOwn(stream, \"id\")) {\n return (\n <AdminPortalAuditLogStreamingPresentational\n {...props}\n connectionStatus=\"NotConfigured\"\n adminPortalOpenButton={\n <AdminPortalAuditLogStreamingButton\n isPending={mutation.isPending}\n href={adminPortalLink}\n initConfig={initConfig}\n />\n }\n />\n );\n }\n\n // Type assertion: we've confirmed stream has id, so it's AuditLogStreamJSON\n const configuredStream = stream as AuditLogStreamJSON;\n\n // Map API state to widget status\n const statusProps: AdminPortalAuditLogStreamingStatusProps = (() => {\n switch (configuredStream.state) {\n case \"Inactive\":\n return {\n connectionStatus: \"Inactive\",\n destinationType: configuredStream.type,\n };\n case \"Active\":\n return {\n connectionStatus: \"Active\",\n destinationType: configuredStream.type,\n lastSyncedEventId: configuredStream.lastSyncedEventId,\n };\n case \"Error\":\n return {\n connectionStatus: \"Error\",\n destinationType: configuredStream.type,\n lastSyncedEventId: configuredStream.lastSyncedEventId,\n };\n case \"Invalid\":\n return {\n connectionStatus: \"Error\",\n destinationType: configuredStream.type,\n lastSyncedEventId: configuredStream.lastSyncedEventId,\n };\n default:\n // Fallback\n return {\n connectionStatus: \"Inactive\",\n destinationType: configuredStream.type,\n };\n }\n })();\n\n return (\n <ErrorBoundary\n fallbackRender={({ error }) => (\n <AdminPortalAuditLogStreamingError error={error} {...props} />\n )}\n >\n <AdminPortalAuditLogStreamingPresentational\n {...props}\n {...statusProps}\n adminPortalOpenButton={\n <AdminPortalAuditLogStreamingButton\n isPending={mutation.isPending}\n href={adminPortalLink}\n initConfig={initConfig}\n />\n }\n />\n </ErrorBoundary>\n );\n }\n\n return <AdminPortalAuditLogStreamingLoading {...props} />;\n};\n\nexport { AdminPortalAuditLogStreaming };\nexport type { AdminPortalAuditLogStreamingProps };\nexport {\n AdminPortalAuditLogStreamingLoading,\n AdminPortalAuditLogStreamingError,\n} from \"./lib/admin-portal-audit-log-streaming.js\";\nexport {\n AdminPortalAuditLogStreaming as AdminPortalAuditLogStreamingPresentational,\n AdminPortalAuditLogStreamingButton,\n type AdminPortalAuditLogStreamingStatusProps,\n} from \"./lib/admin-portal-audit-log-streaming.js\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AA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EA,SAAO,4CAAC,+EAAqC,GAAG,OAAO;AACzD;","names":["import_admin_portal_audit_log_streaming","AdminPortalAuditLogStreamingPresentational"]}
@@ -0,0 +1,26 @@
1
+ import * as React from 'react';
2
+ import { AuthToken } from './api/api-provider.cjs';
3
+ import { WidgetRootDomProps } from './lib/utils.cjs';
4
+ export { AdminPortalAuditLogStreamingButton, AdminPortalAuditLogStreamingError, AdminPortalAuditLogStreamingLoading, AdminPortalAuditLogStreaming as AdminPortalAuditLogStreamingPresentational, AdminPortalAuditLogStreamingStatusProps } from './lib/admin-portal-audit-log-streaming.cjs';
5
+ import 'react/jsx-runtime';
6
+ import './api/endpoint.cjs';
7
+ import '@tanstack/react-query';
8
+ import './api/widgets-api-client.cjs';
9
+ import './lib/elements.cjs';
10
+ import '@radix-ui/themes';
11
+ import '@radix-ui/themes/props';
12
+ import './dialog-C15qCLN3.cjs';
13
+ import '@radix-ui/themes/components/dialog';
14
+ import './alert-dialog-BlG3_awx.cjs';
15
+ import '@radix-ui/themes/components/alert-dialog';
16
+ import './dropdown-menu-BQ5LtvdR.cjs';
17
+ import '@radix-ui/themes/components/dropdown-menu';
18
+ import './select-KR89Qnvm.cjs';
19
+ import '@radix-ui/themes/components/select';
20
+
21
+ interface AdminPortalAuditLogStreamingProps extends WidgetRootDomProps {
22
+ authToken: AuthToken;
23
+ }
24
+ declare const AdminPortalAuditLogStreaming: React.FC<AdminPortalAuditLogStreamingProps>;
25
+
26
+ export { AdminPortalAuditLogStreaming, type AdminPortalAuditLogStreamingProps };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/api/api-provider.tsx"],"sourcesContent":["import { useQuery } from \"@tanstack/react-query\";\nimport * as React from \"react\";\nimport { useIsHydrated } from \"../lib/use-is-hydrated.js\";\nimport { getClaims } from \"./utils.js\";\n\nexport type WidgetType =\n | \"admin-portal-domain-verification\"\n | \"user-management\"\n | \"organization-switcher\"\n | \"user-sessions\"\n | \"user-security\"\n | \"user-profile\"\n | \"admin-portal-sso-connection\"\n | \"api-keys\"\n | \"pipes\"\n | \"directory-sync\";\n\nexport type AuthToken = string | (() => Promise<string>);\n\ninterface ElevatedAccess {\n token: string;\n expiresAt: string;\n}\n\ninterface ApiConfig {\n authToken: string | undefined;\n permissions: string[] | undefined;\n baseUrl: string;\n widgetType: WidgetType;\n elevatedAccess?: ElevatedAccess;\n setElevatedAccess: (elevatedAccess?: ElevatedAccess) => void;\n}\n\nconst ApiContext = React.createContext<ApiConfig | undefined>(undefined);\n\ninterface ApiProviderProps {\n authToken: AuthToken;\n baseUrl: string;\n children: React.ReactNode;\n widgetType: WidgetType;\n}\n\nexport const ApiProvider = ({\n authToken,\n baseUrl,\n children,\n widgetType,\n}: ApiProviderProps) => {\n const authTokenQuery = useQuery({\n initialData:\n typeof authToken === \"string\"\n ? {\n authToken,\n permissions: getClaims(authToken).permissions,\n }\n : undefined,\n queryFn: async () => {\n const resolvedToken =\n typeof authToken === \"string\" ? authToken : await authToken();\n\n return {\n authToken: resolvedToken,\n permissions: getClaims(resolvedToken).permissions,\n };\n },\n queryKey: [\"authToken\", widgetType],\n });\n\n const [elevatedAccess, setElevatedAccess] = React.useState<ElevatedAccess>();\n const elevatedAccessTimeout = React.useRef<number | undefined>(undefined);\n\n // This effect manages the expiration of elevated access tokens\n // When an elevated access token is present, it checks every 30 seconds if the token has expired\n // If the token has expired (current time > expiration time), it clears the elevated access\n React.useEffect(() => {\n if (elevatedAccessTimeout.current) {\n window.clearInterval(elevatedAccessTimeout.current);\n }\n\n if (elevatedAccess) {\n elevatedAccessTimeout.current = window.setInterval(() => {\n const now = new Date();\n const expiresAtDate = new Date(elevatedAccess.expiresAt);\n\n // Reset the elevated access if it has expired\n if (now > expiresAtDate) {\n setElevatedAccess(undefined);\n }\n }, 30_000); // every 30 seconds\n }\n\n return () => {\n if (elevatedAccessTimeout.current) {\n window.clearInterval(elevatedAccessTimeout.current);\n }\n };\n }, [elevatedAccess]);\n\n const value = React.useMemo(\n () => ({\n authToken: authTokenQuery.data?.authToken,\n permissions: authTokenQuery.data?.permissions,\n baseUrl,\n elevatedAccess,\n setElevatedAccess,\n widgetType,\n }),\n [\n authTokenQuery.data,\n baseUrl,\n elevatedAccess,\n setElevatedAccess,\n widgetType,\n ],\n );\n\n return <ApiContext.Provider value={value}>{children}</ApiContext.Provider>;\n};\n\nexport const useApi = () => {\n const context = React.useContext(ApiContext);\n\n if (context === undefined) {\n throw new Error(\"useApi must be used within an ApiProvider\");\n }\n\n return context;\n};\n\nexport const useElevatedAccessToken = () => {\n const { elevatedAccess, setElevatedAccess } = useApi();\n\n return { elevatedAccess, setElevatedAccess };\n};\n\nexport const useApiReady = () => {\n const { authToken } = useApi();\n const isHydrated = useIsHydrated();\n\n return isHydrated && authToken !== undefined;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAoHS;AApHT,yBAAyB;AACzB,YAAuB;AACvB,6BAA8B;AAC9B,mBAA0B;AA8B1B,MAAM,aAAa,MAAM,cAAqC,MAAS;AAShE,MAAM,cAAc,CAAC;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAwB;AACtB,QAAM,qBAAiB,6BAAS;AAAA,IAC9B,aACE,OAAO,cAAc,WACjB;AAAA,MACE;AAAA,MACA,iBAAa,wBAAU,SAAS,EAAE;AAAA,IACpC,IACA;AAAA,IACN,SAAS,YAAY;AACnB,YAAM,gBACJ,OAAO,cAAc,WAAW,YAAY,MAAM,UAAU;AAE9D,aAAO;AAAA,QACL,WAAW;AAAA,QACX,iBAAa,wBAAU,aAAa,EAAE;AAAA,MACxC;AAAA,IACF;AAAA,IACA,UAAU,CAAC,aAAa,UAAU;AAAA,EACpC,CAAC;AAED,QAAM,CAAC,gBAAgB,iBAAiB,IAAI,MAAM,SAAyB;AAC3E,QAAM,wBAAwB,MAAM,OAA2B,MAAS;AAKxE,QAAM,UAAU,MAAM;AACpB,QAAI,sBAAsB,SAAS;AACjC,aAAO,cAAc,sBAAsB,OAAO;AAAA,IACpD;AAEA,QAAI,gBAAgB;AAClB,4BAAsB,UAAU,OAAO,YAAY,MAAM;AACvD,cAAM,MAAM,oBAAI,KAAK;AACrB,cAAM,gBAAgB,IAAI,KAAK,eAAe,SAAS;AAGvD,YAAI,MAAM,eAAe;AACvB,4BAAkB,MAAS;AAAA,QAC7B;AAAA,MACF,GAAG,GAAM;AAAA,IACX;AAEA,WAAO,MAAM;AACX,UAAI,sBAAsB,SAAS;AACjC,eAAO,cAAc,sBAAsB,OAAO;AAAA,MACpD;AAAA,IACF;AAAA,EACF,GAAG,CAAC,cAAc,CAAC;AAEnB,QAAM,QAAQ,MAAM;AAAA,IAClB,OAAO;AAAA,MACL,WAAW,eAAe,MAAM;AAAA,MAChC,aAAa,eAAe,MAAM;AAAA,MAClC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,IACA;AAAA,MACE,eAAe;AAAA,MACf;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,SAAO,4CAAC,WAAW,UAAX,EAAoB,OAAe,UAAS;AACtD;AAEO,MAAM,SAAS,MAAM;AAC1B,QAAM,UAAU,MAAM,WAAW,UAAU;AAE3C,MAAI,YAAY,QAAW;AACzB,UAAM,IAAI,MAAM,2CAA2C;AAAA,EAC7D;AAEA,SAAO;AACT;AAEO,MAAM,yBAAyB,MAAM;AAC1C,QAAM,EAAE,gBAAgB,kBAAkB,IAAI,OAAO;AAErD,SAAO,EAAE,gBAAgB,kBAAkB;AAC7C;AAEO,MAAM,cAAc,MAAM;AAC/B,QAAM,EAAE,UAAU,IAAI,OAAO;AAC7B,QAAM,iBAAa,sCAAc;AAEjC,SAAO,cAAc,cAAc;AACrC;","names":[]}
1
+ {"version":3,"sources":["../../../src/api/api-provider.tsx"],"sourcesContent":["import { useQuery } from \"@tanstack/react-query\";\nimport * as React from \"react\";\nimport { useIsHydrated } from \"../lib/use-is-hydrated.js\";\nimport { getClaims } from \"./utils.js\";\n\nexport type WidgetType =\n | \"admin-portal-audit-log-streaming\"\n | \"admin-portal-domain-verification\"\n | \"user-management\"\n | \"organization-switcher\"\n | \"user-sessions\"\n | \"user-security\"\n | \"user-profile\"\n | \"admin-portal-sso-connection\"\n | \"api-keys\"\n | \"pipes\"\n | \"directory-sync\";\n\nexport type AuthToken = string | (() => Promise<string>);\n\ninterface ElevatedAccess {\n token: string;\n expiresAt: string;\n}\n\ninterface ApiConfig {\n authToken: string | undefined;\n permissions: string[] | undefined;\n baseUrl: string;\n widgetType: WidgetType;\n elevatedAccess?: ElevatedAccess;\n setElevatedAccess: (elevatedAccess?: ElevatedAccess) => void;\n}\n\nconst ApiContext = React.createContext<ApiConfig | undefined>(undefined);\n\ninterface ApiProviderProps {\n authToken: AuthToken;\n baseUrl: string;\n children: React.ReactNode;\n widgetType: WidgetType;\n}\n\nexport const ApiProvider = ({\n authToken,\n baseUrl,\n children,\n widgetType,\n}: ApiProviderProps) => {\n const authTokenQuery = useQuery({\n initialData:\n typeof authToken === \"string\"\n ? {\n authToken,\n permissions: getClaims(authToken).permissions,\n }\n : undefined,\n queryFn: async () => {\n const resolvedToken =\n typeof authToken === \"string\" ? authToken : await authToken();\n\n return {\n authToken: resolvedToken,\n permissions: getClaims(resolvedToken).permissions,\n };\n },\n queryKey: [\"authToken\", widgetType],\n });\n\n const [elevatedAccess, setElevatedAccess] = React.useState<ElevatedAccess>();\n const elevatedAccessTimeout = React.useRef<number | undefined>(undefined);\n\n // This effect manages the expiration of elevated access tokens\n // When an elevated access token is present, it checks every 30 seconds if the token has expired\n // If the token has expired (current time > expiration time), it clears the elevated access\n React.useEffect(() => {\n if (elevatedAccessTimeout.current) {\n window.clearInterval(elevatedAccessTimeout.current);\n }\n\n if (elevatedAccess) {\n elevatedAccessTimeout.current = window.setInterval(() => {\n const now = new Date();\n const expiresAtDate = new Date(elevatedAccess.expiresAt);\n\n // Reset the elevated access if it has expired\n if (now > expiresAtDate) {\n setElevatedAccess(undefined);\n }\n }, 30_000); // every 30 seconds\n }\n\n return () => {\n if (elevatedAccessTimeout.current) {\n window.clearInterval(elevatedAccessTimeout.current);\n }\n };\n }, [elevatedAccess]);\n\n const value = React.useMemo(\n () => ({\n authToken: authTokenQuery.data?.authToken,\n permissions: authTokenQuery.data?.permissions,\n baseUrl,\n elevatedAccess,\n setElevatedAccess,\n widgetType,\n }),\n [\n authTokenQuery.data,\n baseUrl,\n elevatedAccess,\n setElevatedAccess,\n widgetType,\n ],\n );\n\n return <ApiContext.Provider value={value}>{children}</ApiContext.Provider>;\n};\n\nexport const useApi = () => {\n const context = React.useContext(ApiContext);\n\n if (context === undefined) {\n throw new Error(\"useApi must be used within an ApiProvider\");\n }\n\n return context;\n};\n\nexport const useElevatedAccessToken = () => {\n const { elevatedAccess, setElevatedAccess } = useApi();\n\n return { elevatedAccess, setElevatedAccess };\n};\n\nexport const useApiReady = () => {\n const { authToken } = useApi();\n const isHydrated = useIsHydrated();\n\n return isHydrated && authToken !== undefined;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAqHS;AArHT,yBAAyB;AACzB,YAAuB;AACvB,6BAA8B;AAC9B,mBAA0B;AA+B1B,MAAM,aAAa,MAAM,cAAqC,MAAS;AAShE,MAAM,cAAc,CAAC;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAwB;AACtB,QAAM,qBAAiB,6BAAS;AAAA,IAC9B,aACE,OAAO,cAAc,WACjB;AAAA,MACE;AAAA,MACA,iBAAa,wBAAU,SAAS,EAAE;AAAA,IACpC,IACA;AAAA,IACN,SAAS,YAAY;AACnB,YAAM,gBACJ,OAAO,cAAc,WAAW,YAAY,MAAM,UAAU;AAE9D,aAAO;AAAA,QACL,WAAW;AAAA,QACX,iBAAa,wBAAU,aAAa,EAAE;AAAA,MACxC;AAAA,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IAAI,OAAO;AAC7B,QAAM,iBAAa,sCAAc;AAEjC,SAAO,cAAc,cAAc;AACrC;","names":[]}
@@ -1,7 +1,7 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import * as React from 'react';
3
3
 
4
- type WidgetType = "admin-portal-domain-verification" | "user-management" | "organization-switcher" | "user-sessions" | "user-security" | "user-profile" | "admin-portal-sso-connection" | "api-keys" | "pipes" | "directory-sync";
4
+ type WidgetType = "admin-portal-audit-log-streaming" | "admin-portal-domain-verification" | "user-management" | "organization-switcher" | "user-sessions" | "user-security" | "user-profile" | "admin-portal-sso-connection" | "api-keys" | "pipes" | "directory-sync";
5
5
  type AuthToken = string | (() => Promise<string>);
6
6
  interface ElevatedAccess {
7
7
  token: string;
@@ -18,6 +18,11 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var index_exports = {};
20
20
  __export(index_exports, {
21
+ AdminPortalAuditLogStreaming: () => import_admin_portal_audit_log_streaming_client.AdminPortalAuditLogStreaming,
22
+ AdminPortalAuditLogStreamingError: () => import_admin_portal_audit_log_streaming_client.AdminPortalAuditLogStreamingError,
23
+ AdminPortalAuditLogStreamingLoading: () => import_admin_portal_audit_log_streaming_client.AdminPortalAuditLogStreamingLoading,
24
+ AdminPortalAuditLogStreamingOpenButton: () => import_admin_portal_audit_log_streaming_client.AdminPortalAuditLogStreamingButton,
25
+ AdminPortalAuditLogStreamingPresentational: () => import_admin_portal_audit_log_streaming_client.AdminPortalAuditLogStreamingPresentational,
21
26
  AdminPortalDomainVerification: () => import_admin_portal_domain_verification_client.AdminPortalDomainVerification,
22
27
  AdminPortalDomainVerificationLoading: () => import_admin_portal_domain_verification_client.AdminPortalDomainVerificationLoading,
23
28
  AdminPortalSsoConnection: () => import_admin_portal_sso_connection_client.AdminPortalSsoConnection,
@@ -50,12 +55,18 @@ var import_user_security_client = require("./user-security.client.js");
50
55
  var import_user_sessions_client = require("./user-sessions.client.js");
51
56
  var import_users_management_client = require("./users-management.client.js");
52
57
  var import_admin_portal_domain_verification_client = require("./admin-portal-domain-verification.client.js");
58
+ var import_admin_portal_audit_log_streaming_client = require("./admin-portal-audit-log-streaming.client.js");
53
59
  var import_api_keys_client = require("./api-keys.client.js");
54
60
  var import_pipes_client = require("./pipes.client.js");
55
61
  var import_directory_sync_client = require("./directory-sync.client.js");
56
62
  var import_intl_context = require("./lib/i18n/intl-context.js");
57
63
  // Annotate the CommonJS export names for ESM import in node:
58
64
  0 && (module.exports = {
65
+ AdminPortalAuditLogStreaming,
66
+ AdminPortalAuditLogStreamingError,
67
+ AdminPortalAuditLogStreamingLoading,
68
+ AdminPortalAuditLogStreamingOpenButton,
69
+ AdminPortalAuditLogStreamingPresentational,
59
70
  AdminPortalDomainVerification,
60
71
  AdminPortalDomainVerificationLoading,
61
72
  AdminPortalSsoConnection,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export {\n WorkOsWidgets,\n type WorkOsWidgetsProps,\n} from \"./workos-widgets.client.js\";\nexport {\n OrganizationSwitcher,\n OrganizationSwitcherLoading,\n type OrganizationSwitcherProps,\n} from \"./organization-switcher.client.js\";\nexport {\n AdminPortalSsoConnection,\n AdminPortalSsoConnectionLoading,\n type AdminPortalSsoConnectionProps,\n} from \"./admin-portal-sso-connection.client.js\";\nexport {\n UserProfile,\n UserProfileLoading,\n type UserProfileProps,\n} from \"./user-profile.client.js\";\nexport {\n UserSecurity,\n UserSecurityLoading,\n type UserSecurityProps,\n} from \"./user-security.client.js\";\nexport {\n UserSessions,\n UserSessionsLoading,\n type UserSessionsProps,\n} from \"./user-sessions.client.js\";\nexport {\n UsersManagement,\n UsersManagementLoading,\n type UsersManagementProps,\n} from \"./users-management.client.js\";\nexport {\n AdminPortalDomainVerification,\n AdminPortalDomainVerificationLoading,\n type AdminPortalDomainVerificationProps,\n} from \"./admin-portal-domain-verification.client.js\";\nexport {\n ApiKeys,\n ApiKeysLoading,\n type ApiKeysProps,\n} from \"./api-keys.client.js\";\nexport { Pipes, PipesLoading, type PipesProps } from \"./pipes.client.js\";\nexport {\n DirectorySync,\n DirectorySyncLoading,\n type DirectorySyncProps,\n} from \"./directory-sync.client.js\";\nexport { IntlContext as internal_IntlContext } from \"./lib/i18n/intl-context.js\";\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mCAGO;AACP,0CAIO;AACP,gDAIO;AACP,iCAIO;AACP,kCAIO;AACP,kCAIO;AACP,qCAIO;AACP,qDAIO;AACP,6BAIO;AACP,0BAAqD;AACrD,mCAIO;AACP,0BAAoD;","names":[]}
1
+ {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export {\n WorkOsWidgets,\n type WorkOsWidgetsProps,\n} from \"./workos-widgets.client.js\";\nexport {\n OrganizationSwitcher,\n OrganizationSwitcherLoading,\n type OrganizationSwitcherProps,\n} from \"./organization-switcher.client.js\";\nexport {\n AdminPortalSsoConnection,\n AdminPortalSsoConnectionLoading,\n type AdminPortalSsoConnectionProps,\n} from \"./admin-portal-sso-connection.client.js\";\nexport {\n UserProfile,\n UserProfileLoading,\n type UserProfileProps,\n} from \"./user-profile.client.js\";\nexport {\n UserSecurity,\n UserSecurityLoading,\n type UserSecurityProps,\n} from \"./user-security.client.js\";\nexport {\n UserSessions,\n UserSessionsLoading,\n type UserSessionsProps,\n} from \"./user-sessions.client.js\";\nexport {\n UsersManagement,\n UsersManagementLoading,\n type UsersManagementProps,\n} from \"./users-management.client.js\";\nexport {\n AdminPortalDomainVerification,\n AdminPortalDomainVerificationLoading,\n type AdminPortalDomainVerificationProps,\n} from \"./admin-portal-domain-verification.client.js\";\nexport {\n AdminPortalAuditLogStreaming,\n AdminPortalAuditLogStreamingLoading,\n AdminPortalAuditLogStreamingError,\n type AdminPortalAuditLogStreamingProps,\n AdminPortalAuditLogStreamingPresentational,\n AdminPortalAuditLogStreamingButton as AdminPortalAuditLogStreamingOpenButton,\n type AdminPortalAuditLogStreamingStatusProps,\n} from \"./admin-portal-audit-log-streaming.client.js\";\nexport {\n ApiKeys,\n ApiKeysLoading,\n type ApiKeysProps,\n} from \"./api-keys.client.js\";\nexport { Pipes, PipesLoading, type PipesProps } from \"./pipes.client.js\";\nexport {\n DirectorySync,\n DirectorySyncLoading,\n type DirectorySyncProps,\n} from \"./directory-sync.client.js\";\nexport { IntlContext as internal_IntlContext } from \"./lib/i18n/intl-context.js\";\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mCAGO;AACP,0CAIO;AACP,gDAIO;AACP,iCAIO;AACP,kCAIO;AACP,kCAIO;AACP,qCAIO;AACP,qDAIO;AACP,qDAQO;AACP,6BAIO;AACP,0BAAqD;AACrD,mCAIO;AACP,0BAAoD;","names":[]}
@@ -6,6 +6,7 @@ export { UserSecurity, UserSecurityProps } from './user-security.client.cjs';
6
6
  export { UserSessions, UserSessionsProps } from './user-sessions.client.cjs';
7
7
  export { UsersManagement, UsersManagementProps } from './users-management.client.cjs';
8
8
  export { AdminPortalDomainVerification, AdminPortalDomainVerificationProps } from './admin-portal-domain-verification.client.cjs';
9
+ export { AdminPortalAuditLogStreaming, AdminPortalAuditLogStreamingProps } from './admin-portal-audit-log-streaming.client.cjs';
9
10
  export { ApiKeys, ApiKeysProps } from './api-keys.client.cjs';
10
11
  export { Pipes, PipesProps } from './pipes.client.cjs';
11
12
  export { DirectorySync, DirectorySyncProps } from './directory-sync.client.cjs';
@@ -17,6 +18,7 @@ export { UserSecurityLoading } from './lib/user-security.cjs';
17
18
  export { UserSessionsLoading } from './lib/user-sessions.cjs';
18
19
  export { UsersManagementLoading } from './lib/users-management.cjs';
19
20
  export { AdminPortalDomainVerificationLoading } from './lib/admin-portal-domain-verification.cjs';
21
+ export { AdminPortalAuditLogStreamingError, AdminPortalAuditLogStreamingLoading, AdminPortalAuditLogStreamingButton as AdminPortalAuditLogStreamingOpenButton, AdminPortalAuditLogStreaming as AdminPortalAuditLogStreamingPresentational, AdminPortalAuditLogStreamingStatusProps } from './lib/admin-portal-audit-log-streaming.cjs';
20
22
  export { ApiKeysLoading } from './lib/api-keys/api-keys.cjs';
21
23
  export { PipesLoading } from './lib/pipes.cjs';
22
24
  export { DirectorySyncLoading } from './lib/directory-sync.cjs';
@@ -0,0 +1,321 @@
1
+ "use strict";
2
+ "use client";
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __export = (target, all) => {
10
+ for (var name in all)
11
+ __defProp(target, name, { get: all[name], enumerable: true });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(to, key) && key !== except)
17
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
+ }
19
+ return to;
20
+ };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
+ var admin_portal_audit_log_streaming_exports = {};
31
+ __export(admin_portal_audit_log_streaming_exports, {
32
+ AdminPortalAuditLogStreaming: () => AdminPortalAuditLogStreaming,
33
+ AdminPortalAuditLogStreamingButton: () => AdminPortalAuditLogStreamingButton,
34
+ AdminPortalAuditLogStreamingError: () => AdminPortalAuditLogStreamingError,
35
+ AdminPortalAuditLogStreamingLoading: () => AdminPortalAuditLogStreamingLoading
36
+ });
37
+ module.exports = __toCommonJS(admin_portal_audit_log_streaming_exports);
38
+ var import_jsx_runtime = require("react/jsx-runtime");
39
+ var React = __toESM(require("react"), 1);
40
+ var import_themes = require("@radix-ui/themes");
41
+ var CardList = __toESM(require("./card-list.js"), 1);
42
+ var import_elements = require("./elements.js");
43
+ var import_react_icons = require("@radix-ui/react-icons");
44
+ var import_provider_icon = require("./provider-icon.js");
45
+ var import_icon_panel = require("./icon-panel.js");
46
+ var import_audit_log_stream_icons = require("./audit-log-stream-icons.js");
47
+ var import_status = require("./status.js");
48
+ var import_utils = require("./utils.js");
49
+ var import_translation = require("./i18n/translation.js");
50
+ var import_use_translation = require("./i18n/use-translation.js");
51
+ var import_generic_error = require("./generic-error.js");
52
+ const AdminPortalAuditLogStreamingContext = React.createContext(null);
53
+ function useAdminPortalAuditLogStreamingContext() {
54
+ const context = React.useContext(AdminPortalAuditLogStreamingContext);
55
+ if (!context) {
56
+ throw new Error(
57
+ "useAdminPortalAuditLogStreamingContext must be used within a AdminPortalAuditLogStreamingContext provider"
58
+ );
59
+ }
60
+ return context;
61
+ }
62
+ function getDestinationName(type) {
63
+ switch (type) {
64
+ case "Datadog":
65
+ return "Datadog";
66
+ case "Splunk":
67
+ return "Splunk";
68
+ case "S3":
69
+ return "AWS S3";
70
+ case "GoogleCloudStorage":
71
+ return "Google Cloud Storage";
72
+ case "AzureSentinel":
73
+ return "Azure Sentinel";
74
+ case "GenericHttps":
75
+ return "Generic HTTPS";
76
+ default:
77
+ return type;
78
+ }
79
+ }
80
+ function getDestinationIcon(type) {
81
+ switch (type) {
82
+ case "Datadog":
83
+ return "datadog";
84
+ case "Splunk":
85
+ return "splunk";
86
+ case "S3":
87
+ return "aws";
88
+ case "GoogleCloudStorage":
89
+ return "google-cloud";
90
+ case "AzureSentinel":
91
+ return "azure";
92
+ default:
93
+ return void 0;
94
+ }
95
+ }
96
+ function getWidgetRootDomProps(state, domProps) {
97
+ return (0, import_utils.getDomProps)({
98
+ ...domProps,
99
+ isWidgetRoot: true,
100
+ widgetId: "admin-portal-audit-log-streaming",
101
+ widgetState: state
102
+ });
103
+ }
104
+ const CROCKFORD_BASE32 = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
105
+ function decodeUlidTimestamp(ulid) {
106
+ if (!ulid || ulid.length < 10) return null;
107
+ let timestamp = 0;
108
+ for (let i = 0; i < 10; i++) {
109
+ const charIndex = CROCKFORD_BASE32.indexOf(ulid.charAt(i).toUpperCase());
110
+ if (charIndex === -1) return null;
111
+ timestamp = timestamp * 32 + charIndex;
112
+ }
113
+ return new Date(timestamp);
114
+ }
115
+ function getRelativeTimeString(currentDate, pastDate) {
116
+ const rtf = new Intl.RelativeTimeFormat("en", { numeric: "auto" });
117
+ const diff = pastDate.getTime() - currentDate.getTime();
118
+ const diffSeconds = Math.round(diff / 1e3);
119
+ const diffMinutes = Math.round(diffSeconds / 60);
120
+ const diffHours = Math.round(diffMinutes / 60);
121
+ const diffDays = Math.round(diffHours / 24);
122
+ const diffMonths = Math.round(diffDays / 30);
123
+ const diffYears = Math.round(diffMonths / 12);
124
+ if (Math.abs(diffSeconds) < 60) return "now";
125
+ if (Math.abs(diffMinutes) < 60) return rtf.format(diffMinutes, "minute");
126
+ if (Math.abs(diffHours) < 24) return rtf.format(diffHours, "hour");
127
+ if (Math.abs(diffDays) < 30) return rtf.format(diffDays, "day");
128
+ if (Math.abs(diffMonths) < 12) return rtf.format(diffMonths, "month");
129
+ return rtf.format(diffYears, "year");
130
+ }
131
+ function AdminPortalAuditLogStreamingButton({
132
+ isPending,
133
+ href,
134
+ initConfig
135
+ }) {
136
+ const { connectionStatus } = useAdminPortalAuditLogStreamingContext();
137
+ const label = (() => {
138
+ switch (connectionStatus) {
139
+ case "NotConfigured":
140
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
141
+ import_translation.Translation,
142
+ {
143
+ defaultMessage: "Set up Log Streams",
144
+ id: "s3Wu7U",
145
+ description: "Button label to start log stream setup"
146
+ }
147
+ );
148
+ case "Inactive":
149
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
150
+ import_translation.Translation,
151
+ {
152
+ defaultMessage: "Continue setup",
153
+ id: "/oM/HY",
154
+ description: "Button label to continue incomplete log stream setup"
155
+ }
156
+ );
157
+ case "Active":
158
+ case "Error":
159
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
160
+ import_translation.Translation,
161
+ {
162
+ defaultMessage: "Manage",
163
+ id: "+k5uUi",
164
+ description: "Button label to manage log stream settings"
165
+ }
166
+ );
167
+ }
168
+ })();
169
+ if (href) {
170
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_elements.Button, { variant: "secondary", asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("a", { href, target: "_blank", rel: "noopener noreferrer", children: [
171
+ label,
172
+ " ",
173
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_icons.ExternalLinkIcon, { "aria-hidden": true })
174
+ ] }) });
175
+ }
176
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
177
+ import_elements.Button,
178
+ {
179
+ variant: "secondary",
180
+ loading: isPending,
181
+ disabled: isPending,
182
+ onClick: initConfig,
183
+ children: [
184
+ label,
185
+ " ",
186
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_icons.ExternalLinkIcon, { "aria-hidden": true })
187
+ ]
188
+ }
189
+ );
190
+ }
191
+ const AdminPortalAuditLogStreaming = (props) => {
192
+ const { connectionStatus, adminPortalOpenButton, className } = props;
193
+ const destinationType = connectionStatus !== "NotConfigured" ? props.destinationType : null;
194
+ const lastSyncedEventId = connectionStatus === "Active" || connectionStatus === "Error" ? props.lastSyncedEventId : void 0;
195
+ const lastSyncedAt = lastSyncedEventId ? decodeUlidTimestamp(lastSyncedEventId) : null;
196
+ const icon = destinationType ? getDestinationIcon(destinationType) : null;
197
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AdminPortalAuditLogStreamingContext.Provider, { value: { connectionStatus }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(CardList.Root, { ...getWidgetRootDomProps("resolved", { className }), children: [
198
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CardList.Item, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_themes.Flex, { direction: "row", justify: "between", align: "center", gap: "2", children: [
199
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_themes.Flex, { gap: "4", align: "center", children: connectionStatus === "NotConfigured" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_themes.Text, { size: "2", color: "gray", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
200
+ import_translation.Translation,
201
+ {
202
+ defaultMessage: "You haven't set up Log Streams yet.",
203
+ id: "n4mruE",
204
+ description: "Empty state message when log streaming is not configured"
205
+ }
206
+ ) }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
207
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icon_panel.IconPanel, { color: "panel", children: icon ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_provider_icon.ProviderIcon, { provider: icon, size: "2" }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_audit_log_stream_icons.GenericHttpsIcon, {}) }),
208
+ lastSyncedAt ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_themes.Flex, { direction: "column", children: [
209
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_themes.Text, { size: "2", weight: "bold", children: getDestinationName(destinationType) }),
210
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_themes.Text, { size: "2", color: "gray", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
211
+ import_translation.Translation,
212
+ {
213
+ defaultMessage: "Last sync {relativeTime}",
214
+ id: "fT9f0p",
215
+ description: "Label showing when the last log stream sync occurred",
216
+ values: {
217
+ relativeTime: getRelativeTimeString(
218
+ /* @__PURE__ */ new Date(),
219
+ lastSyncedAt
220
+ )
221
+ }
222
+ }
223
+ ) })
224
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_themes.Text, { size: "2", weight: "bold", children: getDestinationName(destinationType) })
225
+ ] }) }),
226
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_themes.Flex, { gap: "5", align: "center", children: connectionStatus === "NotConfigured" ? adminPortalOpenButton : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
227
+ connectionStatus === "Inactive" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_status.Status, { state: "waiting", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
228
+ import_translation.Translation,
229
+ {
230
+ defaultMessage: "Setup in progress",
231
+ id: "M6iKLG",
232
+ description: "Status when log stream setup is incomplete"
233
+ }
234
+ ) }),
235
+ connectionStatus === "Active" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_status.Status, { state: "success", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
236
+ import_translation.Translation,
237
+ {
238
+ defaultMessage: "Streaming",
239
+ id: "25L0J+",
240
+ description: "Status when log stream is active"
241
+ }
242
+ ) }),
243
+ connectionStatus === "Error" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_status.Status, { state: "error", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
244
+ import_translation.Translation,
245
+ {
246
+ defaultMessage: "Not streaming",
247
+ id: "7fAKZo",
248
+ description: "Status when log stream has an error"
249
+ }
250
+ ) }),
251
+ adminPortalOpenButton
252
+ ] }) })
253
+ ] }) }),
254
+ connectionStatus === "Error" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CardList.Item, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_themes.Flex, { align: "start", gap: "2", children: [
255
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_themes.Box, { asChild: true, mt: "2px", flexShrink: "0", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_icons.InfoCircledIcon, { color: "gray" }) }),
256
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_themes.Text, { size: "2", color: "gray", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
257
+ import_translation.Translation,
258
+ {
259
+ defaultMessage: "The credentials provided are incorrect or missing. Please review and update your log stream configuration.",
260
+ id: "23tmgn",
261
+ description: "Error message shown when audit log stream has a configuration or delivery error"
262
+ }
263
+ ) })
264
+ ] }) })
265
+ ] }) });
266
+ };
267
+ const AdminPortalAuditLogStreamingLoading = (props) => {
268
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_themes.Card, { size: "2", ...getWidgetRootDomProps("loading", props), children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_themes.Flex, { direction: "row", justify: "between", align: "center", gap: "2", children: [
269
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_themes.Flex, { gap: "4", align: "center", children: [
270
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_elements.Skeleton, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icon_panel.IconPanel, { color: "panel", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_provider_icon.ProviderIcon, { provider: "datadog", size: "2" }) }) }),
271
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_themes.Flex, { direction: "column", gap: "1", my: "-4px", children: [
272
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_elements.Skeleton, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_themes.Text, { size: "1", children: "Datadog" }) }),
273
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_elements.Skeleton, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_themes.Text, { size: "1", children: "Last sync 10 minutes ago" }) })
274
+ ] })
275
+ ] }),
276
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_themes.Flex, { gap: "5", align: "center", children: [
277
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_elements.Skeleton, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_status.Status, { state: "success", children: "Streaming" }) }),
278
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_elements.Skeleton, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_elements.Button, { variant: "secondary", children: [
279
+ "Manage ",
280
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_icons.ExternalLinkIcon, { "aria-hidden": true })
281
+ ] }) })
282
+ ] })
283
+ ] }) });
284
+ };
285
+ const AdminPortalAuditLogStreamingError = ({ error, ...domProps }) => {
286
+ React.useEffect(() => {
287
+ console.error(error);
288
+ }, [error]);
289
+ const translate = (0, import_use_translation.useTranslation)();
290
+ const { heading, message } = (0, import_generic_error.getErrorMessage)(error, translate);
291
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_themes.Card, { size: "2", ...getWidgetRootDomProps("error", domProps), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_themes.Flex, { direction: "row", justify: "between", align: "center", gap: "2", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_themes.Flex, { gap: "4", align: "center", children: [
292
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
293
+ import_themes.Flex,
294
+ {
295
+ align: "center",
296
+ justify: "center",
297
+ width: "24px",
298
+ height: "24px",
299
+ style: {
300
+ borderRadius: "9999px",
301
+ backgroundColor: "var(--red-a4)",
302
+ color: "var(--red-a11)",
303
+ flexShrink: 0
304
+ },
305
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_icons.Cross2Icon, { width: "18px", height: "18px" })
306
+ }
307
+ ),
308
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_themes.Flex, { direction: "column", children: [
309
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_themes.Text, { size: "2", weight: "bold", children: heading }),
310
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_themes.Text, { size: "2", color: "gray", children: message })
311
+ ] })
312
+ ] }) }) });
313
+ };
314
+ // Annotate the CommonJS export names for ESM import in node:
315
+ 0 && (module.exports = {
316
+ AdminPortalAuditLogStreaming,
317
+ AdminPortalAuditLogStreamingButton,
318
+ AdminPortalAuditLogStreamingError,
319
+ AdminPortalAuditLogStreamingLoading
320
+ });
321
+ //# sourceMappingURL=admin-portal-audit-log-streaming.cjs.map