@workos-inc/widgets 1.5.0 → 1.6.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 (224) hide show
  1. package/CHANGELOG.md +30 -8
  2. package/dist/cjs/admin-portal-domain-verification.client.cjs +34 -20
  3. package/dist/cjs/admin-portal-domain-verification.client.cjs.map +1 -1
  4. package/dist/cjs/admin-portal-domain-verification.client.d.cts +3 -2
  5. package/dist/cjs/{admin-portal-sso-connection-client.cjs → admin-portal-sso-connection.client.cjs} +61 -35
  6. package/dist/cjs/admin-portal-sso-connection.client.cjs.map +1 -0
  7. package/dist/cjs/admin-portal-sso-connection.client.d.cts +16 -0
  8. package/dist/cjs/api/api-provider.cjs +27 -19
  9. package/dist/cjs/api/api-provider.cjs.map +1 -1
  10. package/dist/cjs/api/api-provider.d.cts +5 -4
  11. package/dist/cjs/api/endpoint.cjs +62 -2
  12. package/dist/cjs/api/endpoint.cjs.map +1 -1
  13. package/dist/cjs/api/endpoint.d.cts +62 -1
  14. package/dist/cjs/api/utils.cjs +10 -0
  15. package/dist/cjs/api/utils.cjs.map +1 -1
  16. package/dist/cjs/api/utils.d.cts +7 -2
  17. package/dist/cjs/api/widgets-api-client.cjs +11 -5
  18. package/dist/cjs/api/widgets-api-client.cjs.map +1 -1
  19. package/dist/cjs/{api-keys-client.cjs → api-keys.client.cjs} +45 -33
  20. package/dist/cjs/api-keys.client.cjs.map +1 -0
  21. package/dist/cjs/api-keys.client.d.cts +15 -0
  22. package/dist/cjs/index.cjs +9 -2
  23. package/dist/cjs/index.cjs.map +1 -1
  24. package/dist/cjs/index.d.cts +6 -2
  25. package/dist/cjs/lib/add-mfa-dialog.cjs +1 -1
  26. package/dist/cjs/lib/add-mfa-dialog.cjs.map +1 -1
  27. package/dist/cjs/lib/admin-portal-domain-verification.cjs +18 -12
  28. package/dist/cjs/lib/admin-portal-domain-verification.cjs.map +1 -1
  29. package/dist/cjs/lib/admin-portal-domain-verification.d.cts +10 -6
  30. package/dist/cjs/lib/admin-portal-sso-connection.cjs +84 -106
  31. package/dist/cjs/lib/admin-portal-sso-connection.cjs.map +1 -1
  32. package/dist/cjs/lib/admin-portal-sso-connection.d.cts +13 -6
  33. package/dist/cjs/lib/api-keys/api-keys.cjs +70 -66
  34. package/dist/cjs/lib/api-keys/api-keys.cjs.map +1 -1
  35. package/dist/cjs/lib/api-keys/api-keys.d.cts +16 -8
  36. package/dist/cjs/lib/card-list.cjs.map +1 -0
  37. package/dist/cjs/lib/constants.cjs +5 -2
  38. package/dist/cjs/lib/constants.cjs.map +1 -1
  39. package/dist/cjs/lib/constants.d.cts +2 -1
  40. package/dist/cjs/lib/elevated-access.cjs.map +1 -1
  41. package/dist/cjs/lib/empty-state.cjs +24 -8
  42. package/dist/cjs/lib/empty-state.cjs.map +1 -1
  43. package/dist/cjs/lib/empty-state.d.cts +6 -2
  44. package/dist/cjs/lib/errors.cjs +1 -1
  45. package/dist/cjs/lib/errors.cjs.map +1 -1
  46. package/dist/cjs/lib/generic-error.cjs +56 -58
  47. package/dist/cjs/lib/generic-error.cjs.map +1 -1
  48. package/dist/cjs/lib/generic-error.d.cts +10 -3
  49. package/dist/cjs/lib/identity-providers.cjs +2 -1
  50. package/dist/cjs/lib/identity-providers.cjs.map +1 -1
  51. package/dist/cjs/lib/identity-providers.d.cts +2 -2
  52. package/dist/cjs/lib/oauth-icons.cjs +12 -7
  53. package/dist/cjs/lib/oauth-icons.cjs.map +1 -1
  54. package/dist/cjs/lib/oauth-icons.d.cts +7 -3
  55. package/dist/cjs/lib/organization-switcher.cjs +62 -9
  56. package/dist/cjs/lib/organization-switcher.cjs.map +1 -1
  57. package/dist/cjs/lib/organization-switcher.d.cts +12 -9
  58. package/dist/cjs/lib/otp-input.cjs +1 -1
  59. package/dist/cjs/lib/otp-input.cjs.map +1 -1
  60. package/dist/cjs/lib/pipes.cjs +343 -0
  61. package/dist/cjs/lib/pipes.cjs.map +1 -0
  62. package/dist/cjs/lib/pipes.d.cts +19 -0
  63. package/dist/cjs/lib/provider-icon.cjs +0 -6
  64. package/dist/cjs/lib/provider-icon.cjs.map +1 -1
  65. package/dist/cjs/lib/provider-icon.d.cts +4 -1
  66. package/dist/cjs/lib/save-button.cjs.map +1 -1
  67. package/dist/cjs/lib/use-permissions.cjs +7 -14
  68. package/dist/cjs/lib/use-permissions.cjs.map +1 -1
  69. package/dist/cjs/lib/use-permissions.d.cts +1 -1
  70. package/dist/cjs/lib/user-profile.cjs +77 -83
  71. package/dist/cjs/lib/user-profile.cjs.map +1 -1
  72. package/dist/cjs/lib/user-profile.d.cts +11 -7
  73. package/dist/cjs/lib/user-security.cjs +31 -25
  74. package/dist/cjs/lib/user-security.cjs.map +1 -1
  75. package/dist/cjs/lib/user-security.d.cts +10 -7
  76. package/dist/cjs/lib/user-sessions.cjs +20 -10
  77. package/dist/cjs/lib/user-sessions.cjs.map +1 -1
  78. package/dist/cjs/lib/user-sessions.d.cts +10 -6
  79. package/dist/cjs/lib/users-management.cjs +224 -216
  80. package/dist/cjs/lib/users-management.cjs.map +1 -1
  81. package/dist/cjs/lib/users-management.d.cts +10 -7
  82. package/dist/cjs/lib/utils.cjs +43 -0
  83. package/dist/cjs/lib/utils.cjs.map +1 -1
  84. package/dist/cjs/lib/utils.d.cts +29 -2
  85. package/dist/cjs/organization-switcher.client.cjs +47 -20
  86. package/dist/cjs/organization-switcher.client.cjs.map +1 -1
  87. package/dist/cjs/organization-switcher.client.d.cts +2 -1
  88. package/dist/cjs/pipes.client.cjs +64 -0
  89. package/dist/cjs/pipes.client.cjs.map +1 -0
  90. package/dist/cjs/pipes.client.d.cts +15 -0
  91. package/dist/cjs/user-profile.client.cjs +29 -16
  92. package/dist/cjs/user-profile.client.cjs.map +1 -1
  93. package/dist/cjs/user-profile.client.d.cts +4 -3
  94. package/dist/cjs/user-security.client.cjs +32 -14
  95. package/dist/cjs/user-security.client.cjs.map +1 -1
  96. package/dist/cjs/user-security.client.d.cts +3 -2
  97. package/dist/cjs/user-sessions.client.cjs +42 -28
  98. package/dist/cjs/user-sessions.client.cjs.map +1 -1
  99. package/dist/cjs/user-sessions.client.d.cts +4 -2
  100. package/dist/cjs/users-management.client.cjs +38 -27
  101. package/dist/cjs/users-management.client.cjs.map +1 -1
  102. package/dist/cjs/users-management.client.d.cts +3 -2
  103. package/dist/cjs/workos-widgets.client.cjs +7 -12
  104. package/dist/cjs/workos-widgets.client.cjs.map +1 -1
  105. package/dist/css/lib/provider-icon.css +16 -11
  106. package/dist/esm/admin-portal-domain-verification.client.d.ts +3 -2
  107. package/dist/esm/admin-portal-domain-verification.client.js +34 -21
  108. package/dist/esm/admin-portal-domain-verification.client.js.map +1 -1
  109. package/dist/esm/admin-portal-sso-connection.client.d.ts +16 -0
  110. package/dist/esm/{admin-portal-sso-connection-client.js → admin-portal-sso-connection.client.js} +61 -36
  111. package/dist/esm/admin-portal-sso-connection.client.js.map +1 -0
  112. package/dist/esm/api/api-provider.d.ts +5 -4
  113. package/dist/esm/api/api-provider.js +26 -19
  114. package/dist/esm/api/api-provider.js.map +1 -1
  115. package/dist/esm/api/endpoint.d.ts +62 -1
  116. package/dist/esm/api/endpoint.js +56 -2
  117. package/dist/esm/api/endpoint.js.map +1 -1
  118. package/dist/esm/api/utils.d.ts +7 -2
  119. package/dist/esm/api/utils.js +9 -0
  120. package/dist/esm/api/utils.js.map +1 -1
  121. package/dist/esm/api/widgets-api-client.js +11 -5
  122. package/dist/esm/api/widgets-api-client.js.map +1 -1
  123. package/dist/esm/api-keys.client.d.ts +15 -0
  124. package/dist/esm/api-keys.client.js +75 -0
  125. package/dist/esm/api-keys.client.js.map +1 -0
  126. package/dist/esm/index.d.ts +6 -2
  127. package/dist/esm/index.js +9 -2
  128. package/dist/esm/index.js.map +1 -1
  129. package/dist/esm/lib/add-mfa-dialog.js +1 -1
  130. package/dist/esm/lib/add-mfa-dialog.js.map +1 -1
  131. package/dist/esm/lib/admin-portal-domain-verification.d.ts +10 -6
  132. package/dist/esm/lib/admin-portal-domain-verification.js +18 -12
  133. package/dist/esm/lib/admin-portal-domain-verification.js.map +1 -1
  134. package/dist/esm/lib/admin-portal-sso-connection.d.ts +13 -6
  135. package/dist/esm/lib/admin-portal-sso-connection.js +88 -107
  136. package/dist/esm/lib/admin-portal-sso-connection.js.map +1 -1
  137. package/dist/esm/lib/api-keys/api-keys.d.ts +16 -8
  138. package/dist/esm/lib/api-keys/api-keys.js +69 -54
  139. package/dist/esm/lib/api-keys/api-keys.js.map +1 -1
  140. package/dist/esm/lib/card-list.js.map +1 -0
  141. package/dist/esm/lib/constants.d.ts +2 -1
  142. package/dist/esm/lib/constants.js +3 -1
  143. package/dist/esm/lib/constants.js.map +1 -1
  144. package/dist/esm/lib/elevated-access.js.map +1 -1
  145. package/dist/esm/lib/empty-state.d.ts +6 -2
  146. package/dist/esm/lib/empty-state.js +24 -8
  147. package/dist/esm/lib/empty-state.js.map +1 -1
  148. package/dist/esm/lib/errors.js +1 -1
  149. package/dist/esm/lib/errors.js.map +1 -1
  150. package/dist/esm/lib/generic-error.d.ts +10 -3
  151. package/dist/esm/lib/generic-error.js +56 -60
  152. package/dist/esm/lib/generic-error.js.map +1 -1
  153. package/dist/esm/lib/identity-providers.d.ts +2 -2
  154. package/dist/esm/lib/identity-providers.js +2 -1
  155. package/dist/esm/lib/identity-providers.js.map +1 -1
  156. package/dist/esm/lib/oauth-icons.d.ts +7 -3
  157. package/dist/esm/lib/oauth-icons.js +11 -6
  158. package/dist/esm/lib/oauth-icons.js.map +1 -1
  159. package/dist/esm/lib/organization-switcher.d.ts +12 -9
  160. package/dist/esm/lib/organization-switcher.js +54 -9
  161. package/dist/esm/lib/organization-switcher.js.map +1 -1
  162. package/dist/esm/lib/otp-input.js +1 -1
  163. package/dist/esm/lib/otp-input.js.map +1 -1
  164. package/dist/esm/lib/pipes.d.ts +19 -0
  165. package/dist/esm/lib/pipes.js +334 -0
  166. package/dist/esm/lib/pipes.js.map +1 -0
  167. package/dist/esm/lib/provider-icon.d.ts +4 -1
  168. package/dist/esm/lib/provider-icon.js +0 -8
  169. package/dist/esm/lib/provider-icon.js.map +1 -1
  170. package/dist/esm/lib/save-button.js.map +1 -1
  171. package/dist/esm/lib/use-permissions.d.ts +1 -1
  172. package/dist/esm/lib/use-permissions.js +8 -15
  173. package/dist/esm/lib/use-permissions.js.map +1 -1
  174. package/dist/esm/lib/user-profile.d.ts +11 -7
  175. package/dist/esm/lib/user-profile.js +82 -75
  176. package/dist/esm/lib/user-profile.js.map +1 -1
  177. package/dist/esm/lib/user-security.d.ts +10 -7
  178. package/dist/esm/lib/user-security.js +35 -26
  179. package/dist/esm/lib/user-security.js.map +1 -1
  180. package/dist/esm/lib/user-sessions.d.ts +10 -6
  181. package/dist/esm/lib/user-sessions.js +21 -10
  182. package/dist/esm/lib/user-sessions.js.map +1 -1
  183. package/dist/esm/lib/users-management.d.ts +10 -7
  184. package/dist/esm/lib/users-management.js +230 -217
  185. package/dist/esm/lib/users-management.js.map +1 -1
  186. package/dist/esm/lib/utils.d.ts +29 -2
  187. package/dist/esm/lib/utils.js +46 -1
  188. package/dist/esm/lib/utils.js.map +1 -1
  189. package/dist/esm/organization-switcher.client.d.ts +2 -1
  190. package/dist/esm/organization-switcher.client.js +47 -21
  191. package/dist/esm/organization-switcher.client.js.map +1 -1
  192. package/dist/esm/pipes.client.d.ts +15 -0
  193. package/dist/esm/pipes.client.js +42 -0
  194. package/dist/esm/pipes.client.js.map +1 -0
  195. package/dist/esm/user-profile.client.d.ts +4 -3
  196. package/dist/esm/user-profile.client.js +29 -17
  197. package/dist/esm/user-profile.client.js.map +1 -1
  198. package/dist/esm/user-security.client.d.ts +3 -2
  199. package/dist/esm/user-security.client.js +32 -15
  200. package/dist/esm/user-security.client.js.map +1 -1
  201. package/dist/esm/user-sessions.client.d.ts +4 -2
  202. package/dist/esm/user-sessions.client.js +43 -30
  203. package/dist/esm/user-sessions.client.js.map +1 -1
  204. package/dist/esm/users-management.client.d.ts +3 -2
  205. package/dist/esm/users-management.client.js +38 -28
  206. package/dist/esm/users-management.client.js.map +1 -1
  207. package/dist/esm/workos-widgets.client.js +7 -12
  208. package/dist/esm/workos-widgets.client.js.map +1 -1
  209. package/package.json +20 -10
  210. package/dist/cjs/admin-portal-sso-connection-client.cjs.map +0 -1
  211. package/dist/cjs/admin-portal-sso-connection-client.d.cts +0 -12
  212. package/dist/cjs/api-keys-client.cjs.map +0 -1
  213. package/dist/cjs/api-keys-client.d.cts +0 -10
  214. package/dist/cjs/card-list.cjs.map +0 -1
  215. package/dist/esm/admin-portal-sso-connection-client.d.ts +0 -12
  216. package/dist/esm/admin-portal-sso-connection-client.js.map +0 -1
  217. package/dist/esm/api-keys-client.d.ts +0 -10
  218. package/dist/esm/api-keys-client.js +0 -65
  219. package/dist/esm/api-keys-client.js.map +0 -1
  220. package/dist/esm/card-list.js.map +0 -1
  221. /package/dist/cjs/{card-list.cjs → lib/card-list.cjs} +0 -0
  222. /package/dist/cjs/{card-list.d.cts → lib/card-list.d.cts} +0 -0
  223. /package/dist/esm/{card-list.d.ts → lib/card-list.d.ts} +0 -0
  224. /package/dist/esm/{card-list.js → lib/card-list.js} +0 -0
@@ -0,0 +1,343 @@
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 pipes_exports = {};
31
+ __export(pipes_exports, {
32
+ Pipes: () => Pipes,
33
+ PipesError: () => PipesError,
34
+ PipesLoading: () => PipesLoading
35
+ });
36
+ module.exports = __toCommonJS(pipes_exports);
37
+ var import_jsx_runtime = require("react/jsx-runtime");
38
+ var import_themes = require("@radix-ui/themes");
39
+ var import_react = require("react");
40
+ var CardList = __toESM(require("./card-list.js"), 1);
41
+ var import_provider_icon = require("./provider-icon.js");
42
+ var import_react_icons = require("@radix-ui/react-icons");
43
+ var import_elements = require("./elements.js");
44
+ var import_icon_panel = require("./icon-panel.js");
45
+ var import_status = require("./status.js");
46
+ var import_endpoint = require("../api/endpoint.js");
47
+ var import_react_query = require("@tanstack/react-query");
48
+ var import_generic_error = require("./generic-error.js");
49
+ var import_utils = require("./utils.js");
50
+ const useOpenDataIntegrationAuthorizeUrl = (integration) => {
51
+ const getDataIntegrationAuthorizeUrl = (0, import_endpoint.useGetDataIntegrationAuthorizeUrlHook)();
52
+ const settings = (0, import_endpoint.useSettings)();
53
+ const baseUrl = settings.data?.authkitOrigin ?? "";
54
+ return (0, import_react.useCallback)(async () => {
55
+ const win = window.open(`${baseUrl}/pipes/redirecting`, "_blank");
56
+ const { url } = await getDataIntegrationAuthorizeUrl(integration.slug);
57
+ if (win) {
58
+ win.location = url;
59
+ }
60
+ }, [getDataIntegrationAuthorizeUrl, integration.slug, baseUrl]);
61
+ };
62
+ function ConnectIntegrationButton({
63
+ integration
64
+ }) {
65
+ const eventHandler = useOpenDataIntegrationAuthorizeUrl(integration);
66
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
67
+ import_themes.Button,
68
+ {
69
+ onClick: async () => {
70
+ try {
71
+ await eventHandler();
72
+ } catch {
73
+ }
74
+ },
75
+ variant: "outline",
76
+ size: "2",
77
+ color: "gray",
78
+ children: "Connect"
79
+ }
80
+ );
81
+ }
82
+ function SharedCredentialsConnectIntegrationButton({
83
+ integration
84
+ }) {
85
+ const settings = (0, import_endpoint.useSettings)();
86
+ const [open, setOpen] = (0, import_react.useState)(false);
87
+ const eventHandler = useOpenDataIntegrationAuthorizeUrl(integration);
88
+ const logo = settings.data?.logoDarkPath ?? settings.data?.logoLightPath;
89
+ const appName = settings.data?.teamName ?? "This application";
90
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
91
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_themes.Dialog.Root, { open, onOpenChange: setOpen, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_themes.Dialog.Content, { maxWidth: "430px", children: [
92
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_themes.Flex, { justify: "center", align: "center", gap: "2", mt: "2", children: [
93
+ logo && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
94
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
95
+ import_icon_panel.IconPanel,
96
+ {
97
+ color: "panel",
98
+ style: { width: "48px", height: "48px" },
99
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
100
+ import_provider_icon.ProviderIcon,
101
+ {
102
+ size: "2",
103
+ provider: "workos",
104
+ style: { backgroundImage: `url(${logo})` }
105
+ }
106
+ )
107
+ }
108
+ ),
109
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_icons.DotsHorizontalIcon, {})
110
+ ] }),
111
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
112
+ import_icon_panel.IconPanel,
113
+ {
114
+ color: "panel",
115
+ style: {
116
+ ...logo ? { borderWidth: 0 } : void 0,
117
+ width: "48px",
118
+ height: "48px"
119
+ },
120
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_provider_icon.ProviderIcon, { size: "2", provider: "workos" })
121
+ }
122
+ ),
123
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_icons.DotsHorizontalIcon, {}),
124
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icon_panel.IconPanel, { color: "panel", style: { width: "48px", height: "48px" }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_provider_icon.ProviderIcon, { size: "2", provider: integration.integrationType }) })
125
+ ] }),
126
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_themes.Dialog.Title, { size: "2", mt: "5", mb: "5", weight: "bold", align: "center", children: [
127
+ appName,
128
+ " uses WorkOS to connect to ",
129
+ integration.name,
130
+ "."
131
+ ] }),
132
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_themes.Card, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_themes.Flex, { direction: "column", gap: "4", children: [
133
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_themes.Flex, { gap: "2", align: "center", children: [
134
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
135
+ import_icon_panel.IconPanel,
136
+ {
137
+ color: "gray",
138
+ style: { width: "32px", height: "32px" },
139
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_icons.GlobeIcon, {})
140
+ }
141
+ ),
142
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_themes.Flex, { direction: "column", children: [
143
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_themes.Text, { size: "1", weight: "bold", children: [
144
+ "You'll be redirected to sign in with ",
145
+ integration.name,
146
+ "."
147
+ ] }),
148
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_themes.Text, { size: "1", children: "Authorize access to connect your account." })
149
+ ] })
150
+ ] }),
151
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_themes.Flex, { gap: "2", align: "center", children: [
152
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
153
+ import_icon_panel.IconPanel,
154
+ {
155
+ color: "gray",
156
+ style: { width: "32px", height: "32px" },
157
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_icons.LockClosedIcon, {})
158
+ }
159
+ ),
160
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_themes.Flex, { direction: "column", children: [
161
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_themes.Text, { size: "1", weight: "bold", children: "Your credentials remain secure." }),
162
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_themes.Text, { size: "1", children: "WorkOS never sees your credentials." })
163
+ ] })
164
+ ] })
165
+ ] }) }),
166
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_themes.Flex, { justify: "end", gap: "3", mt: "5", children: [
167
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_themes.Dialog.Close, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_elements.SecondaryButton, { children: "Cancel" }) }),
168
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
169
+ import_elements.PrimaryButton,
170
+ {
171
+ onClick: async () => {
172
+ try {
173
+ await eventHandler();
174
+ setOpen(false);
175
+ } catch {
176
+ }
177
+ },
178
+ children: [
179
+ "Connect ",
180
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_icons.ExternalLinkIcon, {})
181
+ ]
182
+ }
183
+ )
184
+ ] })
185
+ ] }) }),
186
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
187
+ import_themes.Button,
188
+ {
189
+ onClick: () => setOpen(true),
190
+ variant: "outline",
191
+ size: "2",
192
+ color: "gray",
193
+ children: "Connect"
194
+ }
195
+ )
196
+ ] });
197
+ }
198
+ function ProviderStatus({ integration }) {
199
+ const [disconnectOpen, setDisconnectOpen] = (0, import_react.useState)(false);
200
+ const authorizeEventHandler = useOpenDataIntegrationAuthorizeUrl(integration);
201
+ if (integration.installation) {
202
+ const text = integration.installation.state === import_endpoint.DataInstallationState.connected ? "Connected" : "Requires reauthorization";
203
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
204
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
205
+ DisconnectAccountDialog,
206
+ {
207
+ integration,
208
+ installation: integration.installation,
209
+ open: disconnectOpen,
210
+ onOpenChange: setDisconnectOpen
211
+ }
212
+ ),
213
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
214
+ import_status.Status,
215
+ {
216
+ state: integration.installation.state === import_endpoint.DataInstallationState.connected ? "success" : "error",
217
+ children: text
218
+ }
219
+ ),
220
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_themes.DropdownMenu.Root, { children: [
221
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_themes.DropdownMenu.Trigger, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
222
+ import_themes.IconButton,
223
+ {
224
+ radius: "full",
225
+ variant: "ghost",
226
+ color: "gray",
227
+ title: "Pipe actions",
228
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_icons.DotsHorizontalIcon, {})
229
+ }
230
+ ) }),
231
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_themes.DropdownMenu.Content, { align: "end", children: [
232
+ integration.installation.state === import_endpoint.DataInstallationState.needs_reauthorization && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
233
+ import_themes.DropdownMenu.Item,
234
+ {
235
+ onClick: async () => {
236
+ try {
237
+ await authorizeEventHandler();
238
+ } catch {
239
+ }
240
+ },
241
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_themes.Flex, { gap: "4", width: "100%", justify: "between", align: "center", children: [
242
+ "Reauthorize",
243
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_icons.ExternalLinkIcon, {})
244
+ ] })
245
+ }
246
+ ),
247
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_elements.DestructiveMenuItem, { onClick: () => setDisconnectOpen(true), children: "Disconnect account" })
248
+ ] })
249
+ ] })
250
+ ] });
251
+ }
252
+ if (integration.credentialsType === "shared") {
253
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SharedCredentialsConnectIntegrationButton, { integration });
254
+ }
255
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ConnectIntegrationButton, { integration });
256
+ }
257
+ function DisconnectAccountDialog({
258
+ integration,
259
+ installation,
260
+ open,
261
+ onOpenChange
262
+ }) {
263
+ const queryClient = (0, import_react_query.useQueryClient)();
264
+ const {
265
+ mutate: deleteDataInstallation,
266
+ error,
267
+ reset,
268
+ isPending
269
+ } = (0, import_endpoint.useDeleteDataInstallation)({
270
+ mutation: {
271
+ onSuccess: () => {
272
+ onOpenChange(false);
273
+ queryClient.invalidateQueries({
274
+ queryKey: (0, import_endpoint.getMyDataIntegrationsQueryKey)()
275
+ });
276
+ }
277
+ }
278
+ });
279
+ (0, import_react.useEffect)(() => {
280
+ if (open) {
281
+ reset();
282
+ }
283
+ }, [open, reset]);
284
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_themes.AlertDialog.Root, { open, onOpenChange, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_themes.AlertDialog.Content, { style: { width: "80vw", maxWidth: "520px" }, children: [
285
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_themes.AlertDialog.Title, { children: "Disconnect account" }),
286
+ error && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_themes.Callout.Root, { my: "5", color: "red", role: "alert", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_themes.Callout.Text, { children: "An error occurred while disconnecting your account. Please refresh the page and try again." }) }),
287
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_themes.AlertDialog.Description, { children: [
288
+ "Are you sure you want to disconnect your",
289
+ " ",
290
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_themes.Text, { as: "span", weight: "bold", children: integration.name }),
291
+ " ",
292
+ "account?"
293
+ ] }),
294
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_themes.Flex, { gap: "3", justify: "end", mt: "5", children: [
295
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_themes.AlertDialog.Cancel, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_elements.SecondaryButton, { children: "Cancel" }) }),
296
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
297
+ import_elements.DestructiveButton,
298
+ {
299
+ disabled: isPending,
300
+ loading: isPending,
301
+ onClick: () => deleteDataInstallation({ installationId: installation.id }),
302
+ children: "Disconnect"
303
+ }
304
+ )
305
+ ] })
306
+ ] }) });
307
+ }
308
+ const PipesLoading = ({ count, ...domProps }) => {
309
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CardList.Root, { ...getWidgetRootDomProps("loading", domProps), children: Array.from({ length: count }).map((_, index) => /* @__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: [
310
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_themes.Flex, { gap: "4", align: "center", children: [
311
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_themes.Skeleton, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icon_panel.IconPanel, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_provider_icon.ProviderIcon, { provider: "google" }) }) }),
312
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_themes.Skeleton, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_themes.Text, { size: "2", weight: "bold", children: "Google Drive" }) })
313
+ ] }),
314
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_themes.Skeleton, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_themes.Button, { disabled: true, children: "Connect" }) })
315
+ ] }) }, index)) });
316
+ };
317
+ const Pipes = ({ integrations, ...domProps }) => {
318
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CardList.Root, { ...getWidgetRootDomProps("resolved", domProps), children: integrations.map((integration) => /* @__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: [
319
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_themes.Flex, { gap: "4", align: "center", children: [
320
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icon_panel.IconPanel, { color: "panel", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_provider_icon.ProviderIcon, { provider: integration.integrationType }) }),
321
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_themes.Text, { size: "2", weight: "bold", children: integration.name })
322
+ ] }),
323
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ProviderStatus, { integration })
324
+ ] }) }, integration.id)) });
325
+ };
326
+ const PipesError = ({ error, ...domProps }) => {
327
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_themes.Card, { size: "2", ...getWidgetRootDomProps("error", domProps), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_generic_error.GenericError, { error }) });
328
+ };
329
+ function getWidgetRootDomProps(state, domProps) {
330
+ return (0, import_utils.getDomProps)({
331
+ ...domProps,
332
+ isWidgetRoot: true,
333
+ widgetId: "pipes",
334
+ widgetState: state
335
+ });
336
+ }
337
+ // Annotate the CommonJS export names for ESM import in node:
338
+ 0 && (module.exports = {
339
+ Pipes,
340
+ PipesError,
341
+ PipesLoading
342
+ });
343
+ //# sourceMappingURL=pipes.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/lib/pipes.tsx"],"sourcesContent":["\"use client\";\nimport {\n AlertDialog,\n Button,\n Callout,\n Card,\n Dialog,\n DropdownMenu,\n Flex,\n IconButton,\n Skeleton,\n Text,\n} from \"@radix-ui/themes\";\nimport { useCallback, useEffect, useState } from \"react\";\nimport * as CardList from \"./card-list.js\";\nimport { ProviderIcon } from \"./provider-icon.js\";\nimport {\n DotsHorizontalIcon,\n ExternalLinkIcon,\n GlobeIcon,\n LockClosedIcon,\n} from \"@radix-ui/react-icons\";\nimport {\n DestructiveButton,\n DestructiveMenuItem,\n PrimaryButton,\n SecondaryButton,\n} from \"./elements.js\";\nimport { IconPanel } from \"./icon-panel.js\";\nimport { Status } from \"./status.js\";\nimport {\n DataIntegration,\n DataInstallation,\n useDeleteDataInstallation,\n useGetDataIntegrationAuthorizeUrlHook,\n getMyDataIntegrationsQueryKey,\n DataInstallationState,\n useSettings,\n} from \"../api/endpoint.js\";\nimport { useQueryClient } from \"@tanstack/react-query\";\nimport { GenericError } from \"./generic-error.js\";\nimport { getDomProps, WidgetRootDomProps, WidgetRootState } from \"./utils.js\";\n\ninterface PipesProps extends WidgetRootDomProps {\n integrations: DataIntegration[];\n}\n\nconst useOpenDataIntegrationAuthorizeUrl = (integration: DataIntegration) => {\n const getDataIntegrationAuthorizeUrl =\n useGetDataIntegrationAuthorizeUrlHook();\n const settings = useSettings();\n const baseUrl = settings.data?.authkitOrigin ?? \"\";\n\n return useCallback(async () => {\n // need to do this synchronously in the event handler to avoid popup blocker notifications\n const win = window.open(`${baseUrl}/pipes/redirecting`, \"_blank\");\n // caller will catch\n const { url } = await getDataIntegrationAuthorizeUrl(integration.slug);\n if (win) {\n win.location = url;\n }\n }, [getDataIntegrationAuthorizeUrl, integration.slug, baseUrl]);\n};\n\nfunction ConnectIntegrationButton({\n integration,\n}: {\n integration: DataIntegration;\n}) {\n const eventHandler = useOpenDataIntegrationAuthorizeUrl(integration);\n\n return (\n <Button\n onClick={async () => {\n try {\n await eventHandler();\n } catch {\n // pass - error displayed in new tab\n }\n }}\n variant=\"outline\"\n size=\"2\"\n color=\"gray\"\n >\n Connect\n </Button>\n );\n}\n\nfunction SharedCredentialsConnectIntegrationButton({\n integration,\n}: {\n integration: DataIntegration;\n}) {\n const settings = useSettings();\n const [open, setOpen] = useState(false);\n const eventHandler = useOpenDataIntegrationAuthorizeUrl(integration);\n\n const logo = settings.data?.logoDarkPath ?? settings.data?.logoLightPath;\n const appName = settings.data?.teamName ?? \"This application\";\n\n return (\n <>\n <Dialog.Root open={open} onOpenChange={setOpen}>\n <Dialog.Content maxWidth=\"430px\">\n <Flex justify=\"center\" align=\"center\" gap=\"2\" mt=\"2\">\n {logo && (\n <>\n <IconPanel\n color=\"panel\"\n style={{ width: \"48px\", height: \"48px\" }}\n >\n <ProviderIcon\n size=\"2\"\n provider=\"workos\"\n style={{ backgroundImage: `url(${logo})` }}\n />\n </IconPanel>\n <DotsHorizontalIcon />\n </>\n )}\n <IconPanel\n color=\"panel\"\n style={{\n ...(logo ? { borderWidth: 0 } : undefined),\n width: \"48px\",\n height: \"48px\",\n }}\n >\n <ProviderIcon size=\"2\" provider=\"workos\" />\n </IconPanel>\n <DotsHorizontalIcon />\n <IconPanel color=\"panel\" style={{ width: \"48px\", height: \"48px\" }}>\n <ProviderIcon size=\"2\" provider={integration.integrationType} />\n </IconPanel>\n </Flex>\n <Dialog.Title size=\"2\" mt=\"5\" mb=\"5\" weight={\"bold\"} align=\"center\">\n {appName} uses WorkOS to connect to {integration.name}.\n </Dialog.Title>\n <Card>\n <Flex direction=\"column\" gap=\"4\">\n <Flex gap=\"2\" align=\"center\">\n <IconPanel\n color=\"gray\"\n style={{ width: \"32px\", height: \"32px\" }}\n >\n <GlobeIcon />\n </IconPanel>\n <Flex direction=\"column\">\n <Text size=\"1\" weight=\"bold\">\n You&apos;ll be redirected to sign in with {integration.name}\n .\n </Text>\n <Text size=\"1\">\n Authorize access to connect your account.\n </Text>\n </Flex>\n </Flex>\n <Flex gap=\"2\" align=\"center\">\n <IconPanel\n color=\"gray\"\n style={{ width: \"32px\", height: \"32px\" }}\n >\n <LockClosedIcon />\n </IconPanel>\n <Flex direction=\"column\">\n <Text size=\"1\" weight=\"bold\">\n Your credentials remain secure.\n </Text>\n <Text size=\"1\">WorkOS never sees your credentials.</Text>\n </Flex>\n </Flex>\n </Flex>\n </Card>\n <Flex justify=\"end\" gap=\"3\" mt=\"5\">\n <Dialog.Close>\n <SecondaryButton>Cancel</SecondaryButton>\n </Dialog.Close>\n <PrimaryButton\n onClick={async () => {\n try {\n await eventHandler();\n setOpen(false);\n } catch {\n // pass - error displayed in new tab\n }\n }}\n >\n Connect <ExternalLinkIcon />\n </PrimaryButton>\n </Flex>\n </Dialog.Content>\n </Dialog.Root>\n <Button\n onClick={() => setOpen(true)}\n variant=\"outline\"\n size=\"2\"\n color=\"gray\"\n >\n Connect\n </Button>\n </>\n );\n}\n\nfunction ProviderStatus({ integration }: { integration: DataIntegration }) {\n const [disconnectOpen, setDisconnectOpen] = useState(false);\n const authorizeEventHandler = useOpenDataIntegrationAuthorizeUrl(integration);\n\n if (integration.installation) {\n const text =\n integration.installation.state === DataInstallationState.connected\n ? \"Connected\"\n : \"Requires reauthorization\";\n\n return (\n <>\n <DisconnectAccountDialog\n integration={integration}\n installation={integration.installation}\n open={disconnectOpen}\n onOpenChange={setDisconnectOpen}\n />\n <Status\n state={\n integration.installation.state === DataInstallationState.connected\n ? \"success\"\n : \"error\"\n }\n >\n {text}\n </Status>\n <DropdownMenu.Root>\n <DropdownMenu.Trigger>\n <IconButton\n radius=\"full\"\n variant=\"ghost\"\n color=\"gray\"\n title=\"Pipe actions\"\n >\n <DotsHorizontalIcon />\n </IconButton>\n </DropdownMenu.Trigger>\n <DropdownMenu.Content align=\"end\">\n {integration.installation.state ===\n DataInstallationState.needs_reauthorization && (\n <DropdownMenu.Item\n onClick={async () => {\n try {\n await authorizeEventHandler();\n } catch {\n // pass - error displayed in new tab\n }\n }}\n >\n <Flex gap=\"4\" width=\"100%\" justify=\"between\" align=\"center\">\n Reauthorize\n <ExternalLinkIcon />\n </Flex>\n </DropdownMenu.Item>\n )}\n <DestructiveMenuItem onClick={() => setDisconnectOpen(true)}>\n Disconnect account\n </DestructiveMenuItem>\n </DropdownMenu.Content>\n </DropdownMenu.Root>\n </>\n );\n }\n\n if (integration.credentialsType === \"shared\") {\n return (\n <SharedCredentialsConnectIntegrationButton integration={integration} />\n );\n }\n\n return <ConnectIntegrationButton integration={integration} />;\n}\n\nfunction DisconnectAccountDialog({\n integration,\n installation,\n open,\n onOpenChange,\n}: {\n integration: DataIntegration;\n installation: DataInstallation;\n open: boolean;\n onOpenChange: (open: boolean) => void;\n}) {\n const queryClient = useQueryClient();\n const {\n mutate: deleteDataInstallation,\n error,\n reset,\n isPending,\n } = useDeleteDataInstallation({\n mutation: {\n onSuccess: () => {\n onOpenChange(false);\n queryClient.invalidateQueries({\n queryKey: getMyDataIntegrationsQueryKey(),\n });\n },\n },\n });\n\n useEffect(() => {\n if (open) {\n reset();\n }\n }, [open, reset]);\n\n return (\n <AlertDialog.Root open={open} onOpenChange={onOpenChange}>\n <AlertDialog.Content style={{ width: \"80vw\", maxWidth: \"520px\" }}>\n <AlertDialog.Title>Disconnect account</AlertDialog.Title>\n {error && (\n <Callout.Root my=\"5\" color=\"red\" role=\"alert\">\n <Callout.Text>\n An error occurred while disconnecting your account. Please refresh\n the page and try again.\n </Callout.Text>\n </Callout.Root>\n )}\n <AlertDialog.Description>\n Are you sure you want to disconnect your{\" \"}\n <Text as=\"span\" weight=\"bold\">\n {integration.name}\n </Text>{\" \"}\n account?\n </AlertDialog.Description>\n <Flex gap=\"3\" justify=\"end\" mt=\"5\">\n <AlertDialog.Cancel>\n <SecondaryButton>Cancel</SecondaryButton>\n </AlertDialog.Cancel>\n <DestructiveButton\n disabled={isPending}\n loading={isPending}\n onClick={() =>\n deleteDataInstallation({ installationId: installation.id })\n }\n >\n Disconnect\n </DestructiveButton>\n </Flex>\n </AlertDialog.Content>\n </AlertDialog.Root>\n );\n}\n\ninterface PipesLoadingProps extends WidgetRootDomProps {\n count: number;\n}\n\nconst PipesLoading: React.FC<PipesLoadingProps> = ({ count, ...domProps }) => {\n return (\n <CardList.Root {...getWidgetRootDomProps(\"loading\", domProps)}>\n {Array.from({ length: count }).map((_, index) => (\n <CardList.Item key={index}>\n <Flex direction=\"row\" justify=\"between\" align=\"center\" gap=\"2\">\n <Flex gap=\"4\" align=\"center\">\n <Skeleton>\n <IconPanel>\n <ProviderIcon provider=\"google\" />\n </IconPanel>\n </Skeleton>\n <Skeleton>\n <Text size=\"2\" weight=\"bold\">\n Google Drive\n </Text>\n </Skeleton>\n </Flex>\n <Skeleton>\n <Button disabled>Connect</Button>\n </Skeleton>\n </Flex>\n </CardList.Item>\n ))}\n </CardList.Root>\n );\n};\n\nconst Pipes: React.FC<PipesProps> = ({ integrations, ...domProps }) => {\n return (\n <CardList.Root {...getWidgetRootDomProps(\"resolved\", domProps)}>\n {integrations.map((integration) => (\n <CardList.Item key={integration.id}>\n <Flex direction=\"row\" justify=\"between\" align=\"center\" gap=\"2\">\n <Flex gap=\"4\" align=\"center\">\n <IconPanel color=\"panel\">\n <ProviderIcon provider={integration.integrationType} />\n </IconPanel>\n <Text size=\"2\" weight=\"bold\">\n {integration.name}\n </Text>\n </Flex>\n <ProviderStatus integration={integration} />\n </Flex>\n </CardList.Item>\n ))}\n </CardList.Root>\n );\n};\n\ninterface PipesErrorProps extends WidgetRootDomProps {\n error: unknown;\n}\n\nconst PipesError: React.FC<PipesErrorProps> = ({ error, ...domProps }) => {\n return (\n <Card size=\"2\" {...getWidgetRootDomProps(\"error\", domProps)}>\n <GenericError error={error} />\n </Card>\n );\n};\n\nfunction getWidgetRootDomProps(\n state: WidgetRootState,\n domProps: WidgetRootDomProps,\n) {\n return getDomProps({\n ...domProps,\n isWidgetRoot: true,\n widgetId: \"pipes\",\n widgetState: state,\n });\n}\n\nexport type { PipesProps, PipesLoadingProps, PipesErrorProps };\nexport { Pipes, PipesLoading, PipesError };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAwEI;AAvEJ,oBAWO;AACP,mBAAiD;AACjD,eAA0B;AAC1B,2BAA6B;AAC7B,yBAKO;AACP,sBAKO;AACP,wBAA0B;AAC1B,oBAAuB;AACvB,sBAQO;AACP,yBAA+B;AAC/B,2BAA6B;AAC7B,mBAAiE;AAMjE,MAAM,qCAAqC,CAAC,gBAAiC;AAC3E,QAAM,qCACJ,uDAAsC;AACxC,QAAM,eAAW,6BAAY;AAC7B,QAAM,UAAU,SAAS,MAAM,iBAAiB;AAEhD,aAAO,0BAAY,YAAY;AAE7B,UAAM,MAAM,OAAO,KAAK,GAAG,OAAO,sBAAsB,QAAQ;AAEhE,UAAM,EAAE,IAAI,IAAI,MAAM,+BAA+B,YAAY,IAAI;AACrE,QAAI,KAAK;AACP,UAAI,WAAW;AAAA,IACjB;AAAA,EACF,GAAG,CAAC,gCAAgC,YAAY,MAAM,OAAO,CAAC;AAChE;AAEA,SAAS,yBAAyB;AAAA,EAChC;AACF,GAEG;AACD,QAAM,eAAe,mCAAmC,WAAW;AAEnE,SACE;AAAA,IAAC;AAAA;AAAA,MACC,SAAS,YAAY;AACnB,YAAI;AACF,gBAAM,aAAa;AAAA,QACrB,QAAQ;AAAA,QAER;AAAA,MACF;AAAA,MACA,SAAQ;AAAA,MACR,MAAK;AAAA,MACL,OAAM;AAAA,MACP;AAAA;AAAA,EAED;AAEJ;AAEA,SAAS,0CAA0C;AAAA,EACjD;AACF,GAEG;AACD,QAAM,eAAW,6BAAY;AAC7B,QAAM,CAAC,MAAM,OAAO,QAAI,uBAAS,KAAK;AACtC,QAAM,eAAe,mCAAmC,WAAW;AAEnE,QAAM,OAAO,SAAS,MAA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,GAC9B;AAEJ;AAEA,SAAS,sBACP,OACA,UACA;AACA,aAAO,0BAAY;AAAA,IACjB,GAAG;AAAA,IACH,cAAc;AAAA,IACd,UAAU;AAAA,IACV,aAAa;AAAA,EACf,CAAC;AACH;","names":[]}
@@ -0,0 +1,19 @@
1
+ import { DataIntegration } from '../api/endpoint.cjs';
2
+ import { WidgetRootDomProps } from './utils.cjs';
3
+ import '@tanstack/react-query';
4
+ import '../api/widgets-api-client.cjs';
5
+
6
+ interface PipesProps extends WidgetRootDomProps {
7
+ integrations: DataIntegration[];
8
+ }
9
+ interface PipesLoadingProps extends WidgetRootDomProps {
10
+ count: number;
11
+ }
12
+ declare const PipesLoading: React.FC<PipesLoadingProps>;
13
+ declare const Pipes: React.FC<PipesProps>;
14
+ interface PipesErrorProps extends WidgetRootDomProps {
15
+ error: unknown;
16
+ }
17
+ declare const PipesError: React.FC<PipesErrorProps>;
18
+
19
+ export { Pipes, PipesError, type PipesErrorProps, PipesLoading, type PipesLoadingProps, type PipesProps };
@@ -36,7 +36,6 @@ var import_helpers = require("@radix-ui/themes/helpers");
36
36
  var import_props = require("@radix-ui/themes/props");
37
37
  var import_clsx = __toESM(require("clsx"), 1);
38
38
  var React = __toESM(require("react"), 1);
39
- var import_identity_providers = require("./identity-providers.js");
40
39
  const ProviderIcon = React.forwardRef(
41
40
  (props, forwardedRef) => {
42
41
  const {
@@ -45,11 +44,6 @@ const ProviderIcon = React.forwardRef(
45
44
  className,
46
45
  ...providerIconProps
47
46
  } = (0, import_helpers.extractProps)(props, import_props.marginPropDefs);
48
- if (!(0, import_identity_providers.isIdentityProvider)(provider)) {
49
- throw new TypeError(
50
- `ProviderIcon: "${provider}" is not a valid provider.`
51
- );
52
- }
53
47
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
54
48
  "div",
55
49
  {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/lib/provider-icon.tsx"],"sourcesContent":["import { extractProps } from \"@radix-ui/themes/helpers\";\nimport { marginPropDefs, MarginProps } from \"@radix-ui/themes/props\";\nimport clsx from \"clsx\";\nimport * as React from \"react\";\nimport {\n isIdentityProvider,\n type IdentityProvider,\n} from \"./identity-providers.js\";\n\ninterface ProviderIconProps\n extends React.ComponentPropsWithRef<\"div\">,\n MarginProps {\n provider: IdentityProvider;\n size?: \"1\" | \"2\" | \"3\" | \"4\";\n}\n\nconst ProviderIcon = React.forwardRef<HTMLDivElement, ProviderIconProps>(\n (props, forwardedRef) => {\n const {\n provider,\n size = \"4\",\n className,\n ...providerIconProps\n } = extractProps(props, marginPropDefs);\n\n if (!isIdentityProvider(provider)) {\n throw new TypeError(\n `ProviderIcon: \"${provider}\" is not a valid provider.`,\n );\n }\n\n return (\n <div\n {...providerIconProps}\n ref={forwardedRef}\n className={clsx(\"woswidgets-provider-icon\", `size-${size}`, className)}\n data-provider={provider}\n />\n );\n },\n);\n\nProviderIcon.displayName = \"ProviderIcon\";\n\nexport { ProviderIcon };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAgCM;AAhCN,qBAA6B;AAC7B,mBAA4C;AAC5C,kBAAiB;AACjB,YAAuB;AACvB,gCAGO;AASP,MAAM,eAAe,MAAM;AAAA,EACzB,CAAC,OAAO,iBAAiB;AACvB,UAAM;AAAA,MACJ;AAAA,MACA,OAAO;AAAA,MACP;AAAA,MACA,GAAG;AAAA,IACL,QAAI,6BAAa,OAAO,2BAAc;AAEtC,QAAI,KAAC,8CAAmB,QAAQ,GAAG;AACjC,YAAM,IAAI;AAAA,QACR,kBAAkB,QAAQ;AAAA,MAC5B;AAAA,IACF;AAEA,WACE;AAAA,MAAC;AAAA;AAAA,QACE,GAAG;AAAA,QACJ,KAAK;AAAA,QACL,eAAW,YAAAA,SAAK,4BAA4B,QAAQ,IAAI,IAAI,SAAS;AAAA,QACrE,iBAAe;AAAA;AAAA,IACjB;AAAA,EAEJ;AACF;AAEA,aAAa,cAAc;","names":["clsx"]}
1
+ {"version":3,"sources":["../../../src/lib/provider-icon.tsx"],"sourcesContent":["import { extractProps } from \"@radix-ui/themes/helpers\";\nimport { marginPropDefs, type MarginProps } from \"@radix-ui/themes/props\";\nimport clsx from \"clsx\";\nimport * as React from \"react\";\nimport type { IdentityProvider } from \"./identity-providers.js\";\nimport type { DataIntegrationIntegrationType } from \"../api/endpoint.js\";\n\ninterface ProviderIconProps\n extends React.ComponentPropsWithRef<\"div\">,\n MarginProps {\n provider: IdentityProvider | keyof typeof DataIntegrationIntegrationType;\n size?: \"1\" | \"2\" | \"3\" | \"4\";\n}\n\nconst ProviderIcon = React.forwardRef<HTMLDivElement, ProviderIconProps>(\n (props, forwardedRef) => {\n const {\n provider,\n size = \"4\",\n className,\n ...providerIconProps\n } = extractProps(props, marginPropDefs);\n\n return (\n <div\n {...providerIconProps}\n ref={forwardedRef}\n className={clsx(\"woswidgets-provider-icon\", `size-${size}`, className)}\n data-provider={provider}\n />\n );\n },\n);\n\nProviderIcon.displayName = \"ProviderIcon\";\n\nexport { ProviderIcon };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAwBM;AAxBN,qBAA6B;AAC7B,mBAAiD;AACjD,kBAAiB;AACjB,YAAuB;AAWvB,MAAM,eAAe,MAAM;AAAA,EACzB,CAAC,OAAO,iBAAiB;AACvB,UAAM;AAAA,MACJ;AAAA,MACA,OAAO;AAAA,MACP;AAAA,MACA,GAAG;AAAA,IACL,QAAI,6BAAa,OAAO,2BAAc;AAEtC,WACE;AAAA,MAAC;AAAA;AAAA,QACE,GAAG;AAAA,QACJ,KAAK;AAAA,QACL,eAAW,YAAAA,SAAK,4BAA4B,QAAQ,IAAI,IAAI,SAAS;AAAA,QACrE,iBAAe;AAAA;AAAA,IACjB;AAAA,EAEJ;AACF;AAEA,aAAa,cAAc;","names":["clsx"]}
@@ -1,9 +1,12 @@
1
1
  import { MarginProps } from '@radix-ui/themes/props';
2
2
  import * as React from 'react';
3
3
  import { IdentityProvider } from './identity-providers.cjs';
4
+ import { DataIntegrationIntegrationType } from '../api/endpoint.cjs';
5
+ import '@tanstack/react-query';
6
+ import '../api/widgets-api-client.cjs';
4
7
 
5
8
  interface ProviderIconProps extends React.ComponentPropsWithRef<"div">, MarginProps {
6
- provider: IdentityProvider;
9
+ provider: IdentityProvider | keyof typeof DataIntegrationIntegrationType;
7
10
  size?: "1" | "2" | "3" | "4";
8
11
  }
9
12
  declare const ProviderIcon: React.ForwardRefExoticComponent<Omit<ProviderIconProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/lib/save-button.tsx"],"sourcesContent":["import {\n ButtonProps,\n Flex,\n Slot,\n Slottable,\n Spinner,\n Text,\n} from \"@radix-ui/themes\";\nimport { CheckIcon } from \"@radix-ui/react-icons\";\nimport { useEffect, useRef, useState } from \"react\";\nimport { namespaceClassNames } from \"./utils.js\";\n\nconst DONE_TIMEOUT_MS = 1500;\nconst SAVING_TIMEOUT_MS = 600;\n\ninterface SaveButtonProps extends ButtonProps {\n asChild?: boolean;\n children: React.ReactNode;\n loading?: boolean;\n done?: boolean;\n onDone?: () => void;\n}\n\nexport function SaveButton({\n asChild = false,\n children,\n loading,\n done,\n onDone,\n ...props\n}: SaveButtonProps) {\n const [state, setState] = useState<\"idle\" | \"loading\" | \"done\">(\n loading ? \"loading\" : done ? \"done\" : \"idle\",\n );\n const loadingStartTime = useRef<number | null>(null);\n const Button = asChild ? Slot : \"button\";\n\n useEffect(() => {\n if (loading) {\n setState(\"loading\");\n loadingStartTime.current = Date.now();\n } else if (done) {\n const currentTime = Date.now();\n const loadingDuration = loadingStartTime.current\n ? currentTime - loadingStartTime.current\n : 0;\n\n // If loading lasted less than 500 ms, wait for the remaining time\n const remainingDelay = Math.max(0, SAVING_TIMEOUT_MS - loadingDuration);\n\n let doneTimer: number | null = null;\n const savedTimer = window.setTimeout(() => {\n setState(\"done\");\n\n doneTimer = window.setTimeout(() => {\n onDone?.();\n }, DONE_TIMEOUT_MS);\n }, remainingDelay);\n\n return () => {\n window.clearTimeout(savedTimer);\n if (doneTimer !== null) {\n window.clearTimeout(doneTimer);\n }\n };\n } else if (!loading && !done) {\n setState(\"idle\");\n }\n }, [loading, done, onDone]);\n\n return (\n <Button\n {...props}\n className={namespaceClassNames(\"save-button\")}\n data-save-state={state}\n >\n <Slottable>{children}</Slottable>\n\n {state === \"loading\" && (\n <Flex\n as=\"span\"\n align=\"center\"\n justify=\"center\"\n position=\"absolute\"\n inset=\"0\"\n >\n <Spinner size=\"1\" />\n </Flex>\n )}\n\n {state === \"done\" && (\n <Flex\n as=\"span\"\n align=\"center\"\n justify=\"center\"\n position=\"absolute\"\n inset=\"0\"\n gap=\"1\"\n >\n <CheckIcon\n width=\"18px\"\n height=\"18px\"\n style={{ marginLeft: \"-4px\" }}\n className={namespaceClassNames(\"save-button__done-icon\")}\n />\n <Text className={namespaceClassNames(\"save-button__done-text\")}>\n Done\n </Text>\n </Flex>\n )}\n </Button>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA4EM;AA5EN,oBAOO;AACP,yBAA0B;AAC1B,mBAA4C;AAC5C,mBAAoC;AAEpC,MAAM,kBAAkB;AACxB,MAAM,oBAAoB;AAUnB,SAAS,WAAW;AAAA,EACzB,UAAU;AAAA,EACV;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAoB;AAClB,QAAM,CAAC,OAAO,QAAQ,QAAI;AAAA,IACxB,UAAU,YAAY,OAAO,SAAS;AAAA,EACxC;AACA,QAAM,uBAAmB,qBAAsB,IAAI;AACnD,QAAM,SAAS,UAAU,qBAAO;AAEhC,8BAAU,MAAM;AACd,QAAI,SAAS;AACX,eAAS,SAAS;AAClB,uBAAiB,UAAU,KAAK,IAAI;AAAA,IACtC,WAAW,MAAM;AACf,YAAM,cAAc,KAAK,IAAI;AA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F;AAAA;AAAA;AAAA,EAEJ;AAEJ;","names":[]}
1
+ {"version":3,"sources":["../../../src/lib/save-button.tsx"],"sourcesContent":["import {\n ButtonProps,\n Flex,\n Slot,\n Slottable,\n Spinner,\n Text,\n} from \"@radix-ui/themes\";\nimport { CheckIcon } from \"@radix-ui/react-icons\";\nimport { useEffect, useRef, useState } from \"react\";\nimport { namespaceClassNames } from \"./utils.js\";\n\nconst DONE_TIMEOUT_MS = 1500;\nconst SAVING_TIMEOUT_MS = 600;\n\ninterface SaveButtonProps extends ButtonProps {\n asChild?: boolean;\n children: React.ReactNode;\n loading?: boolean;\n done?: boolean;\n onDone?: () => void;\n}\n\nexport function SaveButton({\n asChild = false,\n children,\n loading,\n done,\n onDone,\n ...props\n}: SaveButtonProps) {\n const [state, setState] = useState<\"idle\" | \"loading\" | \"done\">(\n loading ? \"loading\" : done ? \"done\" : \"idle\",\n );\n const loadingStartTime = useRef<number | null>(null);\n const Button = asChild ? Slot : \"button\";\n\n useEffect(() => {\n if (loading) {\n // FIXME: This should be refactored\n // eslint-disable-next-line react-hooks/set-state-in-effect\n setState(\"loading\");\n loadingStartTime.current = Date.now();\n } else if (done) {\n const currentTime = Date.now();\n const loadingDuration = loadingStartTime.current\n ? currentTime - loadingStartTime.current\n : 0;\n\n // If loading lasted less than 500 ms, wait for the remaining time\n const remainingDelay = Math.max(0, SAVING_TIMEOUT_MS - loadingDuration);\n\n let doneTimer: number | null = null;\n const savedTimer = window.setTimeout(() => {\n setState(\"done\");\n\n doneTimer = window.setTimeout(() => {\n onDone?.();\n }, DONE_TIMEOUT_MS);\n }, remainingDelay);\n\n return () => {\n window.clearTimeout(savedTimer);\n if (doneTimer !== null) {\n window.clearTimeout(doneTimer);\n }\n };\n } else if (!loading && !done) {\n setState(\"idle\");\n }\n }, [loading, done, onDone]);\n\n return (\n <Button\n {...props}\n className={namespaceClassNames(\"save-button\")}\n data-save-state={state}\n >\n <Slottable>{children}</Slottable>\n\n {state === \"loading\" && (\n <Flex\n as=\"span\"\n align=\"center\"\n justify=\"center\"\n position=\"absolute\"\n inset=\"0\"\n >\n <Spinner size=\"1\" />\n </Flex>\n )}\n\n {state === \"done\" && (\n <Flex\n as=\"span\"\n align=\"center\"\n justify=\"center\"\n position=\"absolute\"\n inset=\"0\"\n gap=\"1\"\n >\n <CheckIcon\n width=\"18px\"\n height=\"18px\"\n style={{ marginLeft: \"-4px\" }}\n className={namespaceClassNames(\"save-button__done-icon\")}\n />\n <Text className={namespaceClassNames(\"save-button__done-text\")}>\n Done\n </Text>\n </Flex>\n )}\n </Button>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA8EM;AA9EN,oBAOO;AACP,yBAA0B;AAC1B,mBAA4C;AAC5C,mBAAoC;AAEpC,MAAM,kBAAkB;AACxB,MAAM,oBAAoB;AAUnB,SAAS,WAAW;AAAA,EACzB,UAAU;AAAA,EACV;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAoB;AAClB,QAAM,CAAC,OAAO,QAAQ,QAAI;AAAA,IACxB,UAAU,YAAY,OAAO,SAAS;AAAA,EACxC;AACA,QAAM,uBAAmB,qBAAsB,IAAI;AACnD,QAAM,SAAS,UAAU,qBAAO;AAEhC,8BAAU,MAAM;AACd,QAAI,SAAS;AAGX,eAAS,SAAS;AAClB,uBAAiB,UAAU,KAAK,IAAI;AAAA,IACtC,WAAW,MAAM;AACf,YAAM,cAAc,KAAK,IAAI;AAC7B,YAAM,kBAAkB,iBAAiB,UACrC,cAAc,iBAAiB,UAC/B;AAGJ,YAAM,iBAAiB,KAAK,IAAI,GAAG,oBAAoB,eAAe;AAEtE,UAAI,YAA2B;AAC/B,YAAM,aAAa,OAAO,WAAW,MAAM;AACzC,iBAAS,MAAM;AAEf,oBAAY,OAAO,WAAW,MAAM;AAClC,mBAAS;AAAA,QACX,GAAG,eAAe;AAAA,MACpB,GAAG,cAAc;AAEjB,aAAO,MAAM;AACX,eAAO,aAAa,UAAU;AAC9B,YAAI,cAAc,MAAM;AACtB,iBAAO,aAAa,SAAS;AAAA,QAC/B;AAAA,MACF;AAAA,IACF,WAAW,CAAC,WAAW,CAAC,MAAM;AAC5B,eAAS,MAAM;AAAA,IACjB;AAAA,EACF,GAAG,CAAC,SAAS,MAAM,MAAM,CAAC;AAE1B,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,eAAW,kCAAoB,aAAa;AAAA,MAC5C,mBAAiB;AAAA,MAEjB;AAAA,oDAAC,2BAAW,UAAS;AAAA,QAEpB,UAAU,aACT;AAAA,UAAC;AAAA;AAAA,YACC,IAAG;AAAA,YACH,OAAM;AAAA,YACN,SAAQ;AAAA,YACR,UAAS;AAAA,YACT,OAAM;AAAA,YAEN,sDAAC,yBAAQ,MAAK,KAAI;AAAA;AAAA,QACpB;AAAA,QAGD,UAAU,UACT;AAAA,UAAC;AAAA;AAAA,YACC,IAAG;AAAA,YACH,OAAM;AAAA,YACN,SAAQ;AAAA,YACR,UAAS;AAAA,YACT,OAAM;AAAA,YACN,KAAI;AAAA,YAEJ;AAAA;AAAA,gBAAC;AAAA;AAAA,kBACC,OAAM;AAAA,kBACN,QAAO;AAAA,kBACP,OAAO,EAAE,YAAY,OAAO;AAAA,kBAC5B,eAAW,kCAAoB,wBAAwB;AAAA;AAAA,cACzD;AAAA,cACA,4CAAC,sBAAK,eAAW,kCAAoB,wBAAwB,GAAG,kBAEhE;AAAA;AAAA;AAAA,QACF;AAAA;AAAA;AAAA,EAEJ;AAEJ;","names":[]}
@@ -22,15 +22,15 @@ __export(use_permissions_exports, {
22
22
  });
23
23
  module.exports = __toCommonJS(use_permissions_exports);
24
24
  var import_react_query = require("@tanstack/react-query");
25
+ var import_utils = require("../api/utils.js");
25
26
  var import_errors = require("./errors.js");
26
- function usePermissions(scope, authToken) {
27
+ var import_api_provider = require("../api/api-provider.js");
28
+ function usePermissions(scope) {
29
+ const { authToken } = (0, import_api_provider.useApi)();
27
30
  return (0, import_react_query.useQuery)({
28
31
  queryKey: ["permission", scope, authToken],
29
- queryFn: async () => {
30
- if (!authToken) {
31
- throw new import_errors.NoAuthTokenError();
32
- }
33
- const { permissions } = parseJwt(await authToken);
32
+ queryFn: authToken ? async () => {
33
+ const { permissions } = (0, import_utils.getClaims)(authToken);
34
34
  if (!permissions || !Array.isArray(permissions)) {
35
35
  throw new import_errors.NoAuthTokenError();
36
36
  }
@@ -38,16 +38,9 @@ function usePermissions(scope, authToken) {
38
38
  throw new import_errors.IncorrectPermissionsError();
39
39
  }
40
40
  return true;
41
- }
41
+ } : import_react_query.skipToken
42
42
  });
43
43
  }
44
- function parseJwt(token) {
45
- try {
46
- return JSON.parse(atob(token.split(".")[1]));
47
- } catch {
48
- return {};
49
- }
50
- }
51
44
  // Annotate the CommonJS export names for ESM import in node:
52
45
  0 && (module.exports = {
53
46
  usePermissions
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/lib/use-permissions.ts"],"sourcesContent":["import { useQuery } from \"@tanstack/react-query\";\nimport { IncorrectPermissionsError, NoAuthTokenError } from \"./errors.js\";\n\n// TODO find a way to reuse the same type in the @workos-inc/node package\ntype WidgetScope = \"widgets:users-table:manage\" | \"widgets:api-keys:manage\";\n\nexport function usePermissions(\n scope: WidgetScope,\n authToken: null | string | Promise<string>,\n) {\n return useQuery({\n queryKey: [\"permission\", scope, authToken],\n queryFn: async () => {\n if (!authToken) {\n throw new NoAuthTokenError();\n }\n\n const { permissions } = parseJwt(await authToken);\n\n // When the permissions is not present in the token\n if (!permissions || !Array.isArray(permissions)) {\n throw new NoAuthTokenError();\n }\n\n // When the scope is not present in the permissions\n if (!permissions.includes(scope)) {\n throw new IncorrectPermissionsError();\n }\n\n return true;\n },\n });\n}\n\nfunction parseJwt(token: string) {\n try {\n return JSON.parse(atob(token.split(\".\")[1]));\n } catch {\n return {};\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAAyB;AACzB,oBAA4D;AAKrD,SAAS,eACd,OACA,WACA;AACA,aAAO,6BAAS;AAAA,IACd,UAAU,CAAC,cAAc,OAAO,SAAS;AAAA,IACzC,SAAS,YAAY;AACnB,UAAI,CAAC,WAAW;AACd,cAAM,IAAI,+BAAiB;AAAA,MAC7B;AAEA,YAAM,EAAE,YAAY,IAAI,SAAS,MAAM,SAAS;AAGhD,UAAI,CAAC,eAAe,CAAC,MAAM,QAAQ,WAAW,GAAG;AAC/C,cAAM,IAAI,+BAAiB;AAAA,MAC7B;AAGA,UAAI,CAAC,YAAY,SAAS,KAAK,GAAG;AAChC,cAAM,IAAI,wCAA0B;AAAA,MACtC;AAEA,aAAO;AAAA,IACT;AAAA,EACF,CAAC;AACH;AAEA,SAAS,SAAS,OAAe;AAC/B,MAAI;AACF,WAAO,KAAK,MAAM,KAAK,MAAM,MAAM,GAAG,EAAE,CAAC,CAAC,CAAC;AAAA,EAC7C,QAAQ;AACN,WAAO,CAAC;AAAA,EACV;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../src/lib/use-permissions.ts"],"sourcesContent":["import { skipToken, useQuery } from \"@tanstack/react-query\";\nimport { getClaims } from \"../api/utils.js\";\nimport { IncorrectPermissionsError, NoAuthTokenError } from \"./errors.js\";\nimport { useApi } from \"../api/api-provider.js\";\n\n// TODO find a way to reuse the same type in the @workos-inc/node package\ntype WidgetScope = \"widgets:users-table:manage\" | \"widgets:api-keys:manage\";\n\nexport function usePermissions(scope: WidgetScope) {\n const { authToken } = useApi();\n\n return useQuery({\n queryKey: [\"permission\", scope, authToken],\n queryFn: authToken\n ? async () => {\n const { permissions } = getClaims(authToken);\n\n // When the permissions is not present in the token\n if (!permissions || !Array.isArray(permissions)) {\n throw new NoAuthTokenError();\n }\n\n // When the scope is not present in the permissions\n if (!permissions.includes(scope)) {\n throw new IncorrectPermissionsError();\n }\n\n return true;\n }\n : skipToken,\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAAoC;AACpC,mBAA0B;AAC1B,oBAA4D;AAC5D,0BAAuB;AAKhB,SAAS,eAAe,OAAoB;AACjD,QAAM,EAAE,UAAU,QAAI,4BAAO;AAE7B,aAAO,6BAAS;AAAA,IACd,UAAU,CAAC,cAAc,OAAO,SAAS;AAAA,IACzC,SAAS,YACL,YAAY;AACV,YAAM,EAAE,YAAY,QAAI,wBAAU,SAAS;AAG3C,UAAI,CAAC,eAAe,CAAC,MAAM,QAAQ,WAAW,GAAG;AAC/C,cAAM,IAAI,+BAAiB;AAAA,MAC7B;AAGA,UAAI,CAAC,YAAY,SAAS,KAAK,GAAG;AAChC,cAAM,IAAI,wCAA0B;AAAA,MACtC;AAEA,aAAO;AAAA,IACT,IACA;AAAA,EACN,CAAC;AACH;","names":[]}
@@ -1,6 +1,6 @@
1
1
  import * as _tanstack_react_query from '@tanstack/react-query';
2
2
 
3
3
  type WidgetScope = "widgets:users-table:manage" | "widgets:api-keys:manage";
4
- declare function usePermissions(scope: WidgetScope, authToken: null | string | Promise<string>): _tanstack_react_query.UseQueryResult<boolean, Error>;
4
+ declare function usePermissions(scope: WidgetScope): _tanstack_react_query.UseQueryResult<boolean, Error>;
5
5
 
6
6
  export { usePermissions };