fauna-api 0.0.0-stage → 1.0.679

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 (171) hide show
  1. package/dist/brands.d.ts +2 -0
  2. package/dist/brands.js +2 -0
  3. package/dist/index.d.ts +64 -0
  4. package/dist/index.js +121 -0
  5. package/dist/src/ant/chat.d.ts +130 -0
  6. package/dist/src/ant/chat.js +467 -0
  7. package/dist/src/ant/format.d.ts +40 -0
  8. package/dist/src/ant/format.js +143 -0
  9. package/dist/src/ant/graph.d.ts +130 -0
  10. package/dist/src/ant/graph.js +449 -0
  11. package/dist/src/ant/index.d.ts +16 -0
  12. package/dist/src/ant/index.js +61 -0
  13. package/dist/src/ant/persona.d.ts +151 -0
  14. package/dist/src/ant/persona.js +136 -0
  15. package/dist/src/ant/timeline.d.ts +283 -0
  16. package/dist/src/ant/timeline.js +1025 -0
  17. package/dist/src/authentification.d.ts +45 -0
  18. package/dist/src/authentification.js +194 -0
  19. package/dist/src/billing.d.ts +135 -0
  20. package/dist/src/billing.js +128 -0
  21. package/dist/src/calendar.d.ts +83 -0
  22. package/dist/src/calendar.js +133 -0
  23. package/dist/src/chats.d.ts +113 -0
  24. package/dist/src/chats.js +100 -0
  25. package/dist/src/cicada/contacts.d.ts +31 -0
  26. package/dist/src/cicada/contacts.js +28 -0
  27. package/dist/src/cicada/conversations.d.ts +73 -0
  28. package/dist/src/cicada/conversations.js +236 -0
  29. package/dist/src/cicada/inboxes.d.ts +48 -0
  30. package/dist/src/cicada/inboxes.js +82 -0
  31. package/dist/src/cicada/index.d.ts +16 -0
  32. package/dist/src/cicada/index.js +61 -0
  33. package/dist/src/cicada/phone.d.ts +48 -0
  34. package/dist/src/cicada/phone.js +306 -0
  35. package/dist/src/drive.d.ts +80 -0
  36. package/dist/src/drive.js +472 -0
  37. package/dist/src/extensions/index.d.ts +4 -0
  38. package/dist/src/extensions/index.js +5 -0
  39. package/dist/src/extensions/web/index.d.ts +6 -0
  40. package/dist/src/extensions/web/index.js +7 -0
  41. package/dist/src/extensions/web/session.d.ts +108 -0
  42. package/dist/src/extensions/web/session.js +470 -0
  43. package/dist/src/extensions/web/tools.d.ts +13 -0
  44. package/dist/src/extensions/web/tools.js +72 -0
  45. package/dist/src/friends.d.ts +39 -0
  46. package/dist/src/friends.js +119 -0
  47. package/dist/src/groups.d.ts +82 -0
  48. package/dist/src/groups.js +269 -0
  49. package/dist/src/inbox.d.ts +11 -0
  50. package/dist/src/inbox.js +35 -0
  51. package/dist/src/integrations.d.ts +52 -0
  52. package/dist/src/integrations.js +205 -0
  53. package/dist/src/magpie/explorer.d.ts +14 -0
  54. package/dist/src/magpie/explorer.js +36 -0
  55. package/dist/src/magpie/index.d.ts +16 -0
  56. package/dist/src/magpie/index.js +61 -0
  57. package/dist/src/magpie/portfolio.d.ts +52 -0
  58. package/dist/src/magpie/portfolio.js +179 -0
  59. package/dist/src/magpie/quotes.d.ts +35 -0
  60. package/dist/src/magpie/quotes.js +47 -0
  61. package/dist/src/magpie/room.d.ts +61 -0
  62. package/dist/src/magpie/room.js +238 -0
  63. package/dist/src/maps.d.ts +159 -0
  64. package/dist/src/maps.js +171 -0
  65. package/dist/src/marmot/browser.d.ts +139 -0
  66. package/dist/src/marmot/browser.js +389 -0
  67. package/dist/src/marmot/index.d.ts +20 -0
  68. package/dist/src/marmot/index.js +65 -0
  69. package/dist/src/marmot/media.d.ts +56 -0
  70. package/dist/src/marmot/media.js +265 -0
  71. package/dist/src/marmot/research.d.ts +337 -0
  72. package/dist/src/marmot/research.js +1138 -0
  73. package/dist/src/marmot/scraper.d.ts +59 -0
  74. package/dist/src/marmot/scraper.js +94 -0
  75. package/dist/src/marmot/web.d.ts +402 -0
  76. package/dist/src/marmot/web.js +2586 -0
  77. package/dist/src/marmot/workspace.d.ts +81 -0
  78. package/dist/src/marmot/workspace.js +263 -0
  79. package/dist/src/parrot/agent.d.ts +53 -0
  80. package/dist/src/parrot/agent.js +93 -0
  81. package/dist/src/parrot/chat.d.ts +84 -0
  82. package/dist/src/parrot/chat.js +237 -0
  83. package/dist/src/parrot/format.d.ts +128 -0
  84. package/dist/src/parrot/format.js +639 -0
  85. package/dist/src/parrot/generative.d.ts +261 -0
  86. package/dist/src/parrot/generative.js +185 -0
  87. package/dist/src/parrot/index.d.ts +22 -0
  88. package/dist/src/parrot/index.js +67 -0
  89. package/dist/src/parrot/room.d.ts +225 -0
  90. package/dist/src/parrot/room.js +466 -0
  91. package/dist/src/parrot/routing.d.ts +90 -0
  92. package/dist/src/parrot/routing.js +78 -0
  93. package/dist/src/parrot/share.d.ts +126 -0
  94. package/dist/src/parrot/share.js +261 -0
  95. package/dist/src/parrot/socket.d.ts +41 -0
  96. package/dist/src/parrot/socket.js +478 -0
  97. package/dist/src/payments.d.ts +73 -0
  98. package/dist/src/payments.js +107 -0
  99. package/dist/src/private/cards.css +75 -0
  100. package/dist/src/rooms.d.ts +76 -0
  101. package/dist/src/rooms.js +168 -0
  102. package/dist/src/shared/schema.d.ts +24 -0
  103. package/dist/src/shared/schema.js +1 -0
  104. package/dist/src/shared/server.d.ts +65 -0
  105. package/dist/src/shared/server.js +302 -0
  106. package/dist/src/termite/environment.d.ts +110 -0
  107. package/dist/src/termite/environment.js +263 -0
  108. package/dist/src/termite/index.d.ts +14 -0
  109. package/dist/src/termite/index.js +59 -0
  110. package/dist/src/termite/os.d.ts +326 -0
  111. package/dist/src/termite/os.js +572 -0
  112. package/dist/src/termite/versioning.d.ts +94 -0
  113. package/dist/src/termite/versioning.js +217 -0
  114. package/dist/src/tickets.d.ts +43 -0
  115. package/dist/src/tickets.js +138 -0
  116. package/dist/src/travel.d.ts +85 -0
  117. package/dist/src/travel.js +44 -0
  118. package/dist/src/ui/authentification.d.ts +24 -0
  119. package/dist/src/ui/authentification.js +177 -0
  120. package/dist/src/ui/brands.css +11 -0
  121. package/dist/src/ui/brands.d.ts +7 -0
  122. package/dist/src/ui/brands.js +14 -0
  123. package/dist/src/ui/browser.d.ts +74 -0
  124. package/dist/src/ui/browser.js +470 -0
  125. package/dist/src/ui/chat.d.ts +183 -0
  126. package/dist/src/ui/chat.js +2379 -0
  127. package/dist/src/ui/chatPanel.d.ts +109 -0
  128. package/dist/src/ui/chatPanel.js +768 -0
  129. package/dist/src/ui/chatSequence.d.ts +36 -0
  130. package/dist/src/ui/chatSequence.js +42 -0
  131. package/dist/src/ui/crown.d.ts +19 -0
  132. package/dist/src/ui/crown.js +199 -0
  133. package/dist/src/ui/cursor.d.ts +73 -0
  134. package/dist/src/ui/cursor.js +175 -0
  135. package/dist/src/ui/device.d.ts +33 -0
  136. package/dist/src/ui/device.js +49 -0
  137. package/dist/src/ui/drive.d.ts +69 -0
  138. package/dist/src/ui/drive.js +1243 -0
  139. package/dist/src/ui/generative.d.ts +39 -0
  140. package/dist/src/ui/generative.js +313 -0
  141. package/dist/src/ui/hover.d.ts +6 -0
  142. package/dist/src/ui/hover.js +210 -0
  143. package/dist/src/ui/index.d.ts +42 -0
  144. package/dist/src/ui/index.js +87 -0
  145. package/dist/src/ui/integrations.d.ts +13 -0
  146. package/dist/src/ui/integrations.js +175 -0
  147. package/dist/src/ui/maps.d.ts +87 -0
  148. package/dist/src/ui/maps.js +547 -0
  149. package/dist/src/ui/roster.d.ts +32 -0
  150. package/dist/src/ui/roster.js +163 -0
  151. package/dist/src/ui/talk.d.ts +12 -0
  152. package/dist/src/ui/talk.js +560 -0
  153. package/dist/src/ui/tickets.d.ts +13 -0
  154. package/dist/src/ui/tickets.js +966 -0
  155. package/dist/src/ui/toast.d.ts +7 -0
  156. package/dist/src/ui/toast.js +258 -0
  157. package/dist/src/ui/tokenText.d.ts +18 -0
  158. package/dist/src/ui/tokenText.js +96 -0
  159. package/dist/src/ui/tokenized.d.ts +42 -0
  160. package/dist/src/ui/tokenized.js +622 -0
  161. package/dist/src/ui/ui.css +4763 -0
  162. package/dist/src/ui/view.d.ts +23 -0
  163. package/dist/src/ui/view.js +584 -0
  164. package/dist/src/view.d.ts +113 -0
  165. package/dist/src/view.js +386 -0
  166. package/dist/src/webhooks.d.ts +66 -0
  167. package/dist/src/webhooks.js +78 -0
  168. package/dist/ui.d.ts +1 -0
  169. package/dist/ui.js +1 -0
  170. package/package.json +87 -4
  171. package/README.md +0 -3
@@ -0,0 +1,87 @@
1
+ import * as DriveUI from "./drive.js";
2
+ import * as HoverUI from "./hover.js";
3
+ import * as ToastUI from "./toast.js";
4
+ import * as ChatUI from "./chat.js";
5
+ import * as GenerativeUI from "./generative.js";
6
+ import * as TalkUI from "./talk.js";
7
+ import * as TokenizedInputUI from "./tokenized.js";
8
+ import * as IntegrationsUI from "./integrations.js";
9
+ import * as AuthentificationUI from "./authentification.js";
10
+ import * as DeviceUI from "./device.js";
11
+ import * as CursorUI from "./cursor.js";
12
+ import * as TicketsUI from "./tickets.js";
13
+ import * as BrandsUI from "./brands.js";
14
+ import * as BrowserUI from "./browser.js";
15
+ import * as RosterUI from "./roster.js";
16
+ import * as MapsUI from "./maps.js";
17
+ import * as ViewUI from "./view.js";
18
+ export var UI;
19
+ (function (UI) {
20
+ var PREFIX = 'https://';
21
+ var IP = 'fauna.com';
22
+ var PORT = 443;
23
+ function setRoute(route) {
24
+ const parts_0 = route.split('//');
25
+ if (parts_0.length > 1) {
26
+ PREFIX = parts_0[0] + '//';
27
+ const parts_1 = parts_0[1].split(':');
28
+ if (parts_1.length > 1) {
29
+ IP = parts_1[0];
30
+ PORT = Number(parts_1[1]);
31
+ }
32
+ else {
33
+ IP = parts_1[0];
34
+ }
35
+ }
36
+ else {
37
+ const parts_1 = parts_0[0].split(':');
38
+ if (parts_1.length > 1) {
39
+ IP = parts_1[0];
40
+ PORT = Number(parts_1[1]);
41
+ }
42
+ else {
43
+ IP = parts_1[0];
44
+ }
45
+ }
46
+ }
47
+ UI.setRoute = setRoute;
48
+ function getIP() {
49
+ return IP;
50
+ }
51
+ UI.getIP = getIP;
52
+ function getPort() {
53
+ return PORT;
54
+ }
55
+ UI.getPort = getPort;
56
+ function getRoute() {
57
+ return IP + ':' + PORT;
58
+ }
59
+ UI.getRoute = getRoute;
60
+ function getURL() {
61
+ return PREFIX + IP + ':' + PORT;
62
+ }
63
+ UI.getURL = getURL;
64
+ async function ping() {
65
+ const start = Date.now();
66
+ await fetch(`${getURL()}/`);
67
+ return Date.now() - start;
68
+ }
69
+ UI.ping = ping;
70
+ UI.File = DriveUI;
71
+ UI.Hover = HoverUI;
72
+ UI.Toast = ToastUI;
73
+ UI.Chat = ChatUI;
74
+ UI.Generative = GenerativeUI;
75
+ UI.Talk = TalkUI;
76
+ UI.TokenizedInput = TokenizedInputUI;
77
+ UI.Integrations = IntegrationsUI;
78
+ UI.Authentification = AuthentificationUI;
79
+ UI.Device = DeviceUI;
80
+ UI.Cursor = CursorUI;
81
+ UI.Tickets = TicketsUI;
82
+ UI.Brands = BrandsUI;
83
+ UI.Browser = BrowserUI;
84
+ UI.Roster = RosterUI;
85
+ UI.Maps = MapsUI;
86
+ UI.View = ViewUI;
87
+ })(UI || (UI = {}));
@@ -0,0 +1,13 @@
1
+ import { Fauna } from "fauna-api";
2
+ import { Credentials } from "../authentification.js";
3
+ export type ConnectionsOptions = Partial<{
4
+ platforms: Fauna.Integrations.Platform[];
5
+ unlink: boolean;
6
+ onLinked: (platform: Fauna.Integrations.Platform) => void;
7
+ onUnlinked: (account: Fauna.Integrations.Account) => void;
8
+ onError: (error: Error) => void;
9
+ }>;
10
+ export declare function createConnections(credentials: Credentials, options?: ConnectionsOptions): {
11
+ getElement: () => HTMLElement;
12
+ refresh: () => Promise<void>;
13
+ };
@@ -0,0 +1,175 @@
1
+ import { Fauna } from "fauna-api";
2
+ import gsap from "gsap";
3
+ // Brand logos as inline SVG (currentColor-free, real brand marks) so the
4
+ // connections panel reads as a polished product surface rather than generic
5
+ // glyph buttons. Sized to a 24px box; the card controls final dimensions.
6
+ const PLATFORM_LOGOS = {
7
+ [Fauna.Integrations.Platform.GOOGLE]: `<svg viewBox="0 0 24 24" width="24" height="24" aria-hidden="true"><path fill="#4285F4" d="M23.49 12.27c0-.79-.07-1.54-.2-2.27H12v4.51h6.47a5.53 5.53 0 0 1-2.4 3.63v3h3.88c2.27-2.09 3.54-5.17 3.54-8.87z"/><path fill="#34A853" d="M12 24c3.24 0 5.95-1.08 7.93-2.91l-3.88-3c-1.08.72-2.45 1.16-4.05 1.16-3.12 0-5.76-2.11-6.71-4.94H1.29v3.09A12 12 0 0 0 12 24z"/><path fill="#FBBC05" d="M5.29 14.31a7.2 7.2 0 0 1 0-4.62V6.6H1.29a12 12 0 0 0 0 10.8l4-3.09z"/><path fill="#EA4335" d="M12 4.75c1.77 0 3.35.61 4.6 1.8l3.42-3.42A11.97 11.97 0 0 0 12 0 12 12 0 0 0 1.29 6.6l4 3.09C6.24 6.86 8.88 4.75 12 4.75z"/></svg>`,
8
+ [Fauna.Integrations.Platform.MICROSOFT]: `<svg viewBox="0 0 24 24" width="24" height="24" aria-hidden="true"><path fill="#0A2767" d="M24 12.34a.78.78 0 0 0-.38-.67l-.01-.01-8-4.73a1.07 1.07 0 0 0-1.16 0l-8 4.73-.01.01a.78.78 0 0 0 .03 1.35l8 4.73c.36.21.8.21 1.16 0l8-4.73a.78.78 0 0 0 .35-.62z"/><path fill="#0364B8" d="M6.92 8.9h4.96v4.55H6.92zM22.95 4H12.6v3.43l2.34 1.39.06.02 7.95-4.7V4.4a.4.4 0 0 0-.4-.4z"/><path fill="#0078D4" d="M12.6 7.43L14.94 8.82l-2.34 1.39z"/><path fill="#28A8EA" d="M12.6 7.43V4H6.92v4.9h4.96v1.31l.72-.4z"/><path fill="#0078D4" d="M.4 4h6.52a.4.4 0 0 1 .4.4v15.2a.4.4 0 0 1-.4.4H.4a.4.4 0 0 1-.4-.4V4.4A.4.4 0 0 1 .4 4z" transform="translate(0 0)"/><path fill="#fff" d="M3.66 8.3a2.93 2.93 0 0 0-2.6 1.5 4.7 4.7 0 0 0-.5 2.27 4.46 4.46 0 0 0 .49 2.16 2.83 2.83 0 0 0 2.51 1.46 2.87 2.87 0 0 0 2.55-1.48 4.6 4.6 0 0 0 .49-2.2 4.94 4.94 0 0 0-.46-2.21A2.78 2.78 0 0 0 3.66 8.3zm-.06 5.96c-1 0-1.45-.95-1.45-2.18 0-1.3.5-2.2 1.45-2.2.97 0 1.42.93 1.42 2.16 0 1.3-.45 2.22-1.42 2.22z"/></svg>`,
9
+ [Fauna.Integrations.Platform.SLACK]: `<svg viewBox="0 0 24 24" width="24" height="24" aria-hidden="true"><path fill="#E01E5A" d="M5.04 15.16a2.52 2.52 0 0 1-2.52 2.52A2.52 2.52 0 0 1 0 15.16a2.52 2.52 0 0 1 2.52-2.52h2.52v2.52zm1.27 0a2.52 2.52 0 0 1 2.52-2.52 2.52 2.52 0 0 1 2.52 2.52v6.32A2.52 2.52 0 0 1 8.83 24a2.52 2.52 0 0 1-2.52-2.52v-6.32z"/><path fill="#36C5F0" d="M8.83 5.04a2.52 2.52 0 0 1-2.52-2.52A2.52 2.52 0 0 1 8.83 0a2.52 2.52 0 0 1 2.52 2.52v2.52H8.83zm0 1.27a2.52 2.52 0 0 1 2.52 2.52 2.52 2.52 0 0 1-2.52 2.52H2.52A2.52 2.52 0 0 1 0 8.83a2.52 2.52 0 0 1 2.52-2.52h6.31z"/><path fill="#2EB67D" d="M18.96 8.83a2.52 2.52 0 0 1 2.52-2.52A2.52 2.52 0 0 1 24 8.83a2.52 2.52 0 0 1-2.52 2.52h-2.52V8.83zm-1.27 0a2.52 2.52 0 0 1-2.52 2.52 2.52 2.52 0 0 1-2.52-2.52V2.52A2.52 2.52 0 0 1 15.17 0a2.52 2.52 0 0 1 2.52 2.52v6.31z"/><path fill="#ECB22E" d="M15.17 18.96a2.52 2.52 0 0 1 2.52 2.52A2.52 2.52 0 0 1 15.17 24a2.52 2.52 0 0 1-2.52-2.52v-2.52h2.52zm0-1.27a2.52 2.52 0 0 1-2.52-2.52 2.52 2.52 0 0 1 2.52-2.52h6.31A2.52 2.52 0 0 1 24 15.17a2.52 2.52 0 0 1-2.52 2.52h-6.31z"/></svg>`,
10
+ [Fauna.Integrations.Platform.DISCORD]: `<svg viewBox="0 0 24 24" width="24" height="24" aria-hidden="true"><path fill="#5865F2" d="M20.32 4.37a19.8 19.8 0 0 0-4.88-1.51.07.07 0 0 0-.08.04c-.21.38-.44.87-.6 1.25a18.27 18.27 0 0 0-5.5 0 12.6 12.6 0 0 0-.61-1.25.08.08 0 0 0-.08-.04 19.74 19.74 0 0 0-4.88 1.51.07.07 0 0 0-.03.03C.53 9.05-.32 13.58.1 18.06a.08.08 0 0 0 .03.06 19.9 19.9 0 0 0 5.99 3.03.08.08 0 0 0 .08-.03c.46-.63.87-1.29 1.22-1.99a.08.08 0 0 0-.04-.11c-.65-.25-1.27-.55-1.87-.89a.08.08 0 0 1-.01-.13l.37-.29a.07.07 0 0 1 .08-.01 14.2 14.2 0 0 0 12.06 0 .07.07 0 0 1 .08 0l.37.3a.08.08 0 0 1-.01.13c-.6.35-1.22.64-1.87.89a.08.08 0 0 0-.04.11c.36.7.77 1.36 1.22 1.99a.08.08 0 0 0 .08.03 19.84 19.84 0 0 0 6-3.03.08.08 0 0 0 .03-.06c.5-5.18-.84-9.67-3.55-13.66a.06.06 0 0 0-.03-.03zM8.02 15.33c-1.18 0-2.16-1.08-2.16-2.42 0-1.33.96-2.42 2.16-2.42 1.21 0 2.18 1.1 2.16 2.42 0 1.34-.96 2.42-2.16 2.42zm7.97 0c-1.18 0-2.15-1.08-2.15-2.42 0-1.33.95-2.42 2.15-2.42 1.21 0 2.18 1.1 2.16 2.42 0 1.34-.95 2.42-2.16 2.42z"/></svg>`,
11
+ [Fauna.Integrations.Platform.TWILIO]: `<svg viewBox="0 0 24 24" width="24" height="24" aria-hidden="true"><path fill="#F22F46" d="M12 0a12 12 0 1 0 0 24 12 12 0 0 0 0-24zm0 20.4a8.4 8.4 0 1 1 0-16.8 8.4 8.4 0 0 1 0 16.8zm4.97-10.42a2.06 2.06 0 1 1-4.12 0 2.06 2.06 0 0 1 4.12 0zm0 4.08a2.06 2.06 0 1 1-4.12 0 2.06 2.06 0 0 1 4.12 0zm-4.08 0a2.06 2.06 0 1 1-4.12 0 2.06 2.06 0 0 1 4.12 0zm0-4.08a2.06 2.06 0 1 1-4.12 0 2.06 2.06 0 0 1 4.12 0z"/></svg>`,
12
+ [Fauna.Integrations.Platform.WHATSAPP]: `<svg viewBox="0 0 24 24" width="24" height="24" aria-hidden="true"><path fill="#25D366" d="M.06 24l1.68-6.16a11.87 11.87 0 0 1-1.59-5.95C.15 5.32 5.5 0 12.06 0a11.8 11.8 0 0 1 8.41 3.49 11.74 11.74 0 0 1 3.48 8.4c0 6.55-5.35 11.88-11.94 11.88a12 12 0 0 1-5.7-1.45L.06 24z"/><path fill="#fff" d="M9.03 6.95c-.22-.49-.45-.5-.66-.51l-.56-.01c-.2 0-.51.07-.78.37-.27.3-1.02 1-1.02 2.43s1.05 2.82 1.2 3.01c.15.2 2.03 3.25 5.02 4.43 2.48.98 2.99.79 3.53.74.54-.05 1.74-.71 1.98-1.4.25-.69.25-1.28.17-1.4-.07-.12-.27-.2-.56-.34-.3-.15-1.74-.86-2.01-.96-.27-.1-.47-.15-.66.15-.2.3-.76.95-.93 1.15-.17.2-.34.22-.63.07-.3-.15-1.25-.46-2.38-1.47-.88-.78-1.47-1.75-1.64-2.05-.17-.3-.02-.46.13-.6.13-.14.3-.36.45-.53.15-.18.2-.3.3-.5.1-.2.05-.38-.02-.53-.08-.15-.65-1.6-.92-2.18z"/></svg>`
13
+ };
14
+ // Per-platform presentation + the scope bundle to request on link. Apps can
15
+ // override the bundle/label/icon/color through options.
16
+ const PLATFORM_META = {
17
+ [Fauna.Integrations.Platform.GOOGLE]: { label: 'Google', icon: 'mail', color: '#ea4335' },
18
+ [Fauna.Integrations.Platform.SLACK]: { label: 'Slack', icon: 'tag', color: '#4a154b' },
19
+ [Fauna.Integrations.Platform.DISCORD]: { label: 'Discord', icon: 'forum', color: '#5865f2' },
20
+ [Fauna.Integrations.Platform.TWILIO]: { label: 'SMS', icon: 'sms', color: '#34d399' },
21
+ [Fauna.Integrations.Platform.MICROSOFT]: { label: 'Microsoft', icon: 'mail', color: '#0078d4' },
22
+ [Fauna.Integrations.Platform.WHATSAPP]: { label: 'WhatsApp', icon: 'chat', color: '#25d366' }
23
+ };
24
+ // The human label for a linked account — whatever the platform identifies it by.
25
+ function accountLabel(account) {
26
+ if (account instanceof Fauna.Integrations.Google)
27
+ return account.email;
28
+ if (account instanceof Fauna.Integrations.Slack)
29
+ return account.email;
30
+ if (account instanceof Fauna.Integrations.Discord)
31
+ return account.handle;
32
+ if (account instanceof Fauna.Integrations.Twilio)
33
+ return account.phone;
34
+ if (account instanceof Fauna.Integrations.Microsoft)
35
+ return account.email;
36
+ if (account instanceof Fauna.Integrations.WhatsApp)
37
+ return account.phone;
38
+ return account.platform;
39
+ }
40
+ // A drop-in connections panel: a responsive card grid, one card per platform,
41
+ // each showing the brand logo, the platform name, any linked accounts (with an
42
+ // unlink control), and a connect button. Handles the OAuth popup and refreshes
43
+ // itself once it closes. Neutral, product-grade styling that doesn't lean on a
44
+ // host app's accent color.
45
+ export function createConnections(credentials, options = {}) {
46
+ const platforms = options.platforms ?? Object.values(Fauna.Integrations.Platform);
47
+ const root = document.createElement('div');
48
+ root.className = 'connections-root';
49
+ const grid = document.createElement('div');
50
+ grid.className = 'connections-grid';
51
+ root.appendChild(grid);
52
+ function fail(err) {
53
+ options.onError?.(err instanceof Error ? err : new Error(String(err)));
54
+ }
55
+ async function connect(platform) {
56
+ try {
57
+ const popup = await Fauna.Integrations.linkPlatform(credentials, platform);
58
+ if (!popup)
59
+ return;
60
+ // Refresh once the consent popup closes.
61
+ const timer = setInterval(async () => {
62
+ if (popup.closed) {
63
+ clearInterval(timer);
64
+ await refresh();
65
+ options.onLinked?.(platform);
66
+ }
67
+ }, 1000);
68
+ }
69
+ catch (err) {
70
+ fail(err);
71
+ }
72
+ }
73
+ // One card per platform. `accounts` are the already-linked accounts for this
74
+ // platform (possibly several); each gets a labeled row with an unlink action.
75
+ function buildCard(platform, accounts) {
76
+ const meta = PLATFORM_META[platform];
77
+ const card = document.createElement('div');
78
+ card.className = 'connection-card' + (accounts.length ? ' connected' : '');
79
+ const head = document.createElement('div');
80
+ head.className = 'connection-card-head';
81
+ const logo = document.createElement('span');
82
+ logo.className = 'connection-card-logo';
83
+ logo.innerHTML = PLATFORM_LOGOS[platform] ?? '';
84
+ head.appendChild(logo);
85
+ const titles = document.createElement('div');
86
+ titles.className = 'connection-card-titles';
87
+ const name = document.createElement('span');
88
+ name.className = 'connection-card-name';
89
+ name.textContent = meta.label;
90
+ titles.appendChild(name);
91
+ const status = document.createElement('span');
92
+ status.className = 'connection-card-status';
93
+ status.textContent = accounts.length
94
+ ? `${accounts.length} connected`
95
+ : 'Not connected';
96
+ titles.appendChild(status);
97
+ head.appendChild(titles);
98
+ if (accounts.length) {
99
+ const badge = document.createElement('span');
100
+ badge.className = 'material-symbols-outlined connection-card-check';
101
+ badge.textContent = 'check_circle';
102
+ head.appendChild(badge);
103
+ }
104
+ card.appendChild(head);
105
+ // Linked account rows (label + unlink).
106
+ if (accounts.length) {
107
+ const accountsBox = document.createElement('div');
108
+ accountsBox.className = 'connection-card-accounts';
109
+ for (const account of accounts) {
110
+ const row = document.createElement('div');
111
+ row.className = 'connection-account';
112
+ const label = document.createElement('span');
113
+ label.className = 'connection-account-label';
114
+ label.textContent = accountLabel(account);
115
+ label.title = accountLabel(account);
116
+ row.appendChild(label);
117
+ if (options.unlink) {
118
+ const remove = document.createElement('button');
119
+ remove.type = 'button';
120
+ remove.className = 'connection-account-unlink';
121
+ remove.title = 'Disconnect';
122
+ remove.innerHTML = '<span class="material-symbols-outlined">close</span>';
123
+ remove.onclick = async () => {
124
+ try {
125
+ await account.unlink();
126
+ options.onUnlinked?.(account);
127
+ await refresh();
128
+ }
129
+ catch (err) {
130
+ fail(err);
131
+ }
132
+ };
133
+ row.appendChild(remove);
134
+ }
135
+ accountsBox.appendChild(row);
136
+ }
137
+ card.appendChild(accountsBox);
138
+ }
139
+ // Connect / add-another action.
140
+ const connectBtn = document.createElement('button');
141
+ connectBtn.type = 'button';
142
+ connectBtn.className = 'connection-card-connect';
143
+ connectBtn.innerHTML = `<span class="material-symbols-outlined">add</span><span>${accounts.length ? 'Add another' : 'Connect'}</span>`;
144
+ connectBtn.onclick = () => connect(platform);
145
+ card.appendChild(connectBtn);
146
+ return card;
147
+ }
148
+ async function refresh() {
149
+ try {
150
+ const accounts = await Fauna.Integrations.getAccounts(credentials);
151
+ const byPlatform = new Map();
152
+ for (const account of accounts) {
153
+ if (!platforms.includes(account.platform))
154
+ continue;
155
+ const list = byPlatform.get(account.platform) ?? [];
156
+ list.push(account);
157
+ byPlatform.set(account.platform, list);
158
+ }
159
+ grid.replaceChildren();
160
+ for (const platform of platforms) {
161
+ grid.appendChild(buildCard(platform, byPlatform.get(platform) ?? []));
162
+ }
163
+ // Subtle entrance so the grid doesn't pop in.
164
+ gsap.fromTo(grid.children, { opacity: 0, y: 8 }, { opacity: 1, y: 0, duration: 0.3, stagger: 0.04, ease: 'power2.out' });
165
+ }
166
+ catch (err) {
167
+ fail(err);
168
+ }
169
+ }
170
+ refresh();
171
+ return {
172
+ getElement: () => root,
173
+ refresh
174
+ };
175
+ }
@@ -0,0 +1,87 @@
1
+ import { type CSSProperties } from "react";
2
+ import maplibregl from "maplibre-gl";
3
+ import type { ApiKey, Credentials } from "../authentification.js";
4
+ import type { Group } from "../groups.js";
5
+ import type { Coordinates, MapTheme, Place, Route, TravelMode, Units } from "../maps.js";
6
+ import type { Flight, Offer } from "../travel.js";
7
+ /** Where maps calls go: straight to Fauna with `authorization` (billed to it, or to
8
+ * `group`), or to `proxy`, an app server that serves Fauna's /maps routes. */
9
+ export type MapsSource = {
10
+ authorization?: Credentials | ApiKey;
11
+ group?: Group;
12
+ proxy?: string;
13
+ /** Sent with every proxy call, e.g. the app's own sign in. */
14
+ headers?: Record<string, string>;
15
+ };
16
+ export type MapMarker = {
17
+ id: string;
18
+ coordinates: Coordinates;
19
+ label?: string;
20
+ tone?: "accent" | "muted";
21
+ };
22
+ export type MapOptions = MapsSource & {
23
+ theme?: MapTheme;
24
+ center?: Coordinates;
25
+ zoom?: number;
26
+ markers?: MapMarker[];
27
+ routes?: Route[];
28
+ /** Fit the view to the markers and routes whenever they change. Default true. */
29
+ fit?: boolean;
30
+ interactive?: boolean;
31
+ /** Tiles each pass buys. Default 150. */
32
+ tiles?: number;
33
+ /** Passes one map may buy as it is panned around. Default 4. */
34
+ maxPasses?: number;
35
+ onMarkerClick?: (marker: MapMarker) => void;
36
+ };
37
+ export type MapInstance = {
38
+ map: maplibregl.Map | undefined;
39
+ update(options: Partial<MapOptions>): void;
40
+ destroy(): void;
41
+ };
42
+ /**
43
+ * A map drawn from prepaid tile passes, with markers and route lines. A pass that
44
+ * runs out is replaced, up to `maxPasses`. The attribution the pass carries is
45
+ * always shown, as the tile provider's terms require.
46
+ */
47
+ export declare function createMap(container: HTMLElement, initial: MapOptions): MapInstance;
48
+ /** A map for React. The source and theme are fixed for its life; markers, routes and the view follow props. */
49
+ export declare function Map(props: MapOptions & {
50
+ className?: string;
51
+ style?: CSSProperties;
52
+ }): import("react").JSX.Element;
53
+ export declare function formatDuration(seconds: number): string;
54
+ export declare function formatDistance(meters: number, units?: Units): string;
55
+ export declare function formatMoney(amount: number, currency: string): string;
56
+ /** Open where to book: a link, or a form posted in a new tab when the offer carries one. */
57
+ export declare function openOffer(offer: Offer): void;
58
+ export type DirectionsProps = {
59
+ routes: Route[];
60
+ flights?: Flight[];
61
+ units?: Units;
62
+ /** The mode to open on. Defaults to `recommended`, else the first there is. */
63
+ mode?: TravelMode;
64
+ /** Marked as the best way there. */
65
+ recommended?: TravelMode;
66
+ onMode?: (mode: TravelMode) => void;
67
+ /** Where a flight can be booked; the Book button lists these. */
68
+ offers?: (flight: Flight) => Promise<Offer[]>;
69
+ className?: string;
70
+ };
71
+ /** Ways to get somewhere: a tab per mode, the time, distance and cost, and the steps or flights. */
72
+ export declare function Directions({ routes, flights, units, mode, recommended, onMode, offers, className }: DirectionsProps): import("react").JSX.Element;
73
+ export type PlaceSearchProps = MapsSource & {
74
+ onSelect: (place: Place) => void;
75
+ near?: Coordinates;
76
+ placeholder?: string;
77
+ defaultValue?: string;
78
+ autoFocus?: boolean;
79
+ className?: string;
80
+ };
81
+ /** A text box that suggests places as someone types and hands back the one they pick. */
82
+ export declare function PlaceSearch({ onSelect, near, placeholder, defaultValue, autoFocus, className, ...source }: PlaceSearchProps): import("react").JSX.Element;
83
+ /** Place search for apps without React. */
84
+ export declare function mountPlaceSearch(element: HTMLElement, props: PlaceSearchProps): {
85
+ update(props: PlaceSearchProps): void;
86
+ destroy(): void;
87
+ };