@canmingir/link 1.2.4 → 1.2.6

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.
@@ -1,5 +1,3 @@
1
- import { useEffect, useRef } from "react";
2
-
3
1
  import Page from "../layouts/Page";
4
2
  import React from "react";
5
3
  import config from "../config/config";
@@ -10,6 +8,8 @@ import { useContext } from "../ContextProvider/ContextProvider";
10
8
  import { useLocation } from "react-router-dom";
11
9
  import { useNavigate } from "react-router-dom";
12
10
 
11
+ import { useEffect, useRef } from "react";
12
+
13
13
  function Callback() {
14
14
  const { project: appConfig, name, appId } = config();
15
15
  const projectBar = config().template?.projectBar;
@@ -28,12 +28,12 @@ function Callback() {
28
28
  const parsedQuery = qs.parse(location.search, { ignoreQueryPrefix: true });
29
29
  const { code, error, error_description, state } = parsedQuery;
30
30
 
31
- let provider;
31
+ let identityProvider;
32
32
  let stateData = {};
33
33
 
34
34
  if (state) {
35
35
  stateData = JSON.parse(decodeURIComponent(state));
36
- provider = stateData.provider;
36
+ identityProvider = stateData.identityProvider;
37
37
  }
38
38
 
39
39
  if (error) {
@@ -59,7 +59,7 @@ function Callback() {
59
59
  google,
60
60
  };
61
61
 
62
- const providerConfig = providerConfigs[provider];
62
+ const providerConfig = providerConfigs[identityProvider];
63
63
 
64
64
  if (!providerConfig) {
65
65
  console.error("Could not determine OAuth provider or redirect URI");
@@ -85,7 +85,7 @@ function Callback() {
85
85
  appId,
86
86
  code,
87
87
  redirectUri,
88
- provider: provider,
88
+ identityProvider: identityProvider,
89
89
  grant_type: "authorization_code",
90
90
  })
91
91
  .then(({ data }) => {
@@ -93,10 +93,10 @@ function Callback() {
93
93
  const refreshToken = data.refreshToken;
94
94
  const userInfo = data.user;
95
95
 
96
- storage.set(name, "accessToken", accessToken);
97
- storage.set(name, "refreshToken", refreshToken);
96
+ storage.set("link", "accessToken", accessToken);
97
+ storage.set("link", "refreshToken", refreshToken);
98
98
  // TODO - update provider info
99
- storage.set(name, "provider", provider);
99
+ storage.set("link", "identityProvider", identityProvider);
100
100
 
101
101
  dispatch({ type: "LOGIN", payload: { user: userInfo } });
102
102
 
@@ -11,7 +11,10 @@ function LoginPage() {
11
11
  const navigate = useNavigate();
12
12
 
13
13
  function token() {
14
- if (storage.get(name, "refreshToken") && storage.get(name, "accessToken")) {
14
+ if (
15
+ storage.get("link", "refreshToken") &&
16
+ storage.get("link", "accessToken")
17
+ ) {
15
18
  return true;
16
19
  } else {
17
20
  return false;
@@ -0,0 +1,333 @@
1
+ import { FlowChart } from "../lib/FlowChart";
2
+ import React from "react";
3
+
4
+ const treeToLinked = (tree) => {
5
+ if (!tree) return { nodes: {}, roots: [] };
6
+
7
+ const nodes = {};
8
+ const roots = [];
9
+
10
+ const walk = (node, parentId = null) => {
11
+ if (!node || !node.id) return;
12
+
13
+ const { children, ...rest } = node;
14
+ if (!nodes[node.id]) {
15
+ nodes[node.id] = { ...rest, id: node.id };
16
+ }
17
+
18
+ const kids = Array.isArray(children) ? children : [];
19
+ const nextIds = kids.map((c) => c.id).filter(Boolean);
20
+
21
+ if (nextIds.length === 1) {
22
+ nodes[node.id].next = nextIds[0];
23
+ } else if (nextIds.length > 1) {
24
+ nodes[node.id].next = nextIds;
25
+ }
26
+
27
+ if (parentId) {
28
+ nodes[node.id].previous = parentId;
29
+ } else if (!roots.includes(node.id)) {
30
+ roots.push(node.id);
31
+ }
32
+
33
+ kids.forEach((child) => walk(child, node.id));
34
+ };
35
+
36
+ walk(tree);
37
+ return { nodes, roots };
38
+ };
39
+
40
+ const arrayToLinked = (arr) => {
41
+ const a = Array.isArray(arr) ? [...arr] : [];
42
+ if (!a.length) return { nodes: {}, roots: [] };
43
+
44
+ a.sort((x, y) => {
45
+ const dx = x?.createdAt ? new Date(x.createdAt).getTime() : 0;
46
+ const dy = y?.createdAt ? new Date(y.createdAt).getTime() : 0;
47
+ return dx - dy;
48
+ });
49
+
50
+ const nodes = {};
51
+ const ids = [];
52
+
53
+ for (let i = 0; i < a.length; i++) {
54
+ const id = a[i]?.id ?? `auto-${i}`;
55
+ ids.push(id);
56
+ nodes[id] = { ...(a[i] || {}), id };
57
+ }
58
+
59
+ for (let i = 0; i < ids.length; i++) {
60
+ const cur = ids[i];
61
+ const prev = ids[i - 1];
62
+ const nxt = ids[i + 1];
63
+ if (prev) nodes[cur].previous = prev;
64
+ if (nxt) nodes[cur].next = nxt;
65
+ }
66
+
67
+ return { nodes, roots: [ids[0]] };
68
+ };
69
+
70
+ export default {
71
+ title: "Components/FlowChart",
72
+ component: FlowChart,
73
+ parameters: {
74
+ layout: "centered",
75
+ },
76
+ tags: ["autodocs"],
77
+ argTypes: {
78
+ data: {
79
+ control: "object",
80
+ description:
81
+ "Linked graph data: { nodes: { [id]: { id, next?, previous?, ... } }, roots?: string[] }",
82
+ },
83
+ style: {
84
+ control: "object",
85
+ description:
86
+ "Styling tokens or a style object; can also be a function (node) => tokens.",
87
+ },
88
+ type: {
89
+ control: "text",
90
+ description: 'Type of the flow chart, e.g. "default" or "task".',
91
+ },
92
+ variant: {
93
+ control: {
94
+ type: "select",
95
+ options: ["simple", "card", "pill", "decision"],
96
+ },
97
+ description: "Visual variant of the flow chart nodes.",
98
+ },
99
+ },
100
+ };
101
+
102
+ const simpleTree = {
103
+ id: "root",
104
+ label: "Start",
105
+ children: [
106
+ { id: "step1", label: "Step 1", children: [] },
107
+ { id: "step2", label: "Step 2", children: [] },
108
+ ],
109
+ };
110
+
111
+ export const SimpleTextNodes = {
112
+ args: {
113
+ type: "default",
114
+ data: treeToLinked(simpleTree),
115
+ variant: "simple",
116
+ },
117
+ };
118
+
119
+ const cardTree = {
120
+ id: "1",
121
+ title: "Project Alpha",
122
+ description: "Main project",
123
+ status: "active",
124
+ children: [
125
+ {
126
+ id: "2",
127
+ title: "Task 1",
128
+ description: "First task",
129
+ status: "completed",
130
+ children: [],
131
+ },
132
+ {
133
+ id: "3",
134
+ title: "Task 2",
135
+ description: "Second task",
136
+ status: "in-progress",
137
+ children: [],
138
+ },
139
+ ],
140
+ };
141
+
142
+ export const CardNodes = {
143
+ args: {
144
+ type: "default",
145
+ data: treeToLinked(cardTree),
146
+ variant: "card",
147
+ style: {
148
+ border: "light",
149
+ size: "small",
150
+ shadow: "heavy",
151
+ shape: "square",
152
+ },
153
+ },
154
+ };
155
+
156
+ export const OrganizationalChart = {
157
+ render: () => {
158
+ const orgTree = {
159
+ id: "add6dfa4-45ba-4da2-bc5c-5a529610b52f",
160
+ name: "Rebellion Coffee Shop Team",
161
+ icon: ":ph:coffee-bean-duotone:",
162
+ description: null,
163
+ type: null,
164
+ organizationId: "dfb990bb-81dd-4584-82ce-050eb8f6a12f",
165
+ coach: "Elijah",
166
+ colleagues: [
167
+ {
168
+ id: "00db1bd4-4829-40f2-8b99-d2e42342157e",
169
+ name: "Ava",
170
+ avatar: ":1:",
171
+ character: "Funny, friendly, and a coffee lover",
172
+ title: "Barista",
173
+ role: "Barista Expert",
174
+ teamId: "add6dfa4-45ba-4da2-bc5c-5a529610b52f",
175
+ aiEngineId: "289a3c9a-f23b-421a-ac6e-f14052a2d57c",
176
+ },
177
+ {
178
+ id: "ef906c5d-cafe-4518-9edc-b80c605df58e",
179
+ name: "Taylor",
180
+ title: "Customer Service Representative",
181
+ avatar: ":2:",
182
+ character: "Friendly, helpful, and a team player",
183
+ role: "Customer Service Representative",
184
+ teamId: "e6d4744d-a11b-4c75-acad-e24a02903729",
185
+ aiEngineId: "289a3c9a-f23b-421a-ac6e-f14052a2d57c",
186
+ },
187
+ ],
188
+ };
189
+
190
+ const data = treeToLinked(orgTree);
191
+
192
+ return <FlowChart type="teamChart" data={data} variant="simple" />;
193
+ },
194
+ };
195
+
196
+ export const DecisionTree = {
197
+ render: () => {
198
+ const decisionTree = {
199
+ id: "start",
200
+ label: "Start Process",
201
+ type: "start",
202
+ children: [
203
+ {
204
+ id: "check",
205
+ label: "Valid Input?",
206
+ type: "decision",
207
+ children: [
208
+ {
209
+ id: "process",
210
+ label: "Process Data",
211
+ type: "process",
212
+ children: [
213
+ { id: "success", label: "Success", type: "end", children: [] },
214
+ ],
215
+ },
216
+ {
217
+ id: "error",
218
+ label: "Show Error",
219
+ type: "process",
220
+ children: [
221
+ { id: "end", label: "End", type: "end", children: [] },
222
+ ],
223
+ },
224
+ ],
225
+ },
226
+ ],
227
+ };
228
+
229
+ const data = treeToLinked(decisionTree);
230
+
231
+ return (
232
+ <FlowChart
233
+ data={data}
234
+ variant="decision"
235
+ style={{ connectorType: "curved" }}
236
+ />
237
+ );
238
+ },
239
+ };
240
+
241
+ const deepTree = {
242
+ id: "root",
243
+ label: "Root",
244
+ children: [
245
+ {
246
+ id: "branch1",
247
+ label: "Branch 1",
248
+ children: [
249
+ {
250
+ id: "leaf1-1",
251
+ label: "Leaf 1.1",
252
+ children: [{ id: "leaf1-1-1", label: "Leaf 1.1.1", children: [] }],
253
+ },
254
+ ],
255
+ },
256
+ {
257
+ id: "branch2",
258
+ label: "Branch 2",
259
+ children: [
260
+ { id: "leaf2-1", label: "Leaf 2.1", children: [] },
261
+ { id: "leaf2-2", label: "Leaf 2.2", children: [] },
262
+ ],
263
+ },
264
+ ],
265
+ };
266
+
267
+ export const DeepHierarchy = {
268
+ args: {
269
+ type: "default",
270
+ data: treeToLinked(deepTree),
271
+ variant: "simple",
272
+ },
273
+ };
274
+
275
+ export const TaskFlow = {
276
+ render: () => {
277
+ const timeline = [
278
+ {
279
+ id: "773b051a-326a-4140-98c4-d63df8aba39f",
280
+ action: "PLATFORM:scrape_website",
281
+ parameters: {
282
+ url: "https://nucleoid.com/domain-ownership.html",
283
+ },
284
+ result:
285
+ '\n URL: https://nucleoid.com/domain-ownership.html\n Title: \n Content: This domain "nucleoid.com" is owned by Can Mingir for Nucleoid Ltd. Co. Contact: canmingir@nucleoid.com Phone: (914) 525-5929 Address: 2972 Webb Bridge Rd, Alpharetta, GA 30009, United States\n ',
286
+ comment: "Scrape the website to extract the list of emails",
287
+ status: "COMPLETED",
288
+ taskId: "6ce93ce9-d923-46ba-b8a9-1a4cea50ca07",
289
+ createdAt: "2025-11-10T13:09:53.188Z",
290
+ },
291
+ {
292
+ id: "e6b12140-f922-4fa5-9e9d-e3064909716c",
293
+ action: "PLATFORM:llm",
294
+ parameters: {
295
+ message:
296
+ 'Extract the email addresses from the scraped website content:\n\nThis domain "nucleoid.com" is owned by Can Mingir for Nucleoid Ltd. Co. Contact: canmingir@nucleoid.com Phone: (914) 525-5929 Address: 2972 Webb Bridge Rd, Alpharetta, GA 30009, United States',
297
+ },
298
+ result: '["canmingir@nucleoid.com"]',
299
+ comment: "Extract the email addresses from the scraped website content",
300
+ status: "COMPLETED",
301
+ taskId: "6ce93ce9-d923-46ba-b8a9-1a4cea50ca07",
302
+ createdAt: "2025-11-10T13:09:59.261Z",
303
+ },
304
+ {
305
+ id: "05fba361-4071-4db7-88e8-4f1b6fabddba",
306
+ action: "PLATFORM:complete",
307
+ parameters: {},
308
+ result: "Task completed successfully",
309
+ comment:
310
+ "Task completed after extracting email addresses from the website",
311
+ status: "COMPLETED",
312
+ taskId: "6ce93ce9-d923-46ba-b8a9-1a4cea50ca07",
313
+ createdAt: "2025-11-10T13:10:02.653Z",
314
+ },
315
+ ];
316
+
317
+ const data = arrayToLinked(timeline);
318
+
319
+ return (
320
+ <FlowChart
321
+ type="task"
322
+ data={data}
323
+ variant="pill"
324
+ style={{
325
+ visible: true,
326
+ delay: 0,
327
+ isLoading: false,
328
+ connectorType: "curved",
329
+ }}
330
+ />
331
+ );
332
+ },
333
+ };
@@ -19,7 +19,10 @@ export default function Auth0LoginView() {
19
19
  const navigate = useNavigate();
20
20
 
21
21
  function token() {
22
- if (storage.get(name, "refreshToken") && storage.get(name, "accessToken")) {
22
+ if (
23
+ storage.get("link", "refreshToken") &&
24
+ storage.get("link", "accessToken")
25
+ ) {
23
26
  return true;
24
27
  } else {
25
28
  return false;
@@ -1,17 +1,17 @@
1
- import { Box, Divider, Link as MuiLink, Typography } from "@mui/material";
2
- import React, { useState } from "react";
3
-
4
1
  import NucleoidLoginForm from "../../components/NucleoidLoginForm";
5
2
  import SocialLoginButtons from "../../components/SocialLoginButtons";
6
3
  import Stack from "@mui/material/Stack";
7
4
  import config from "../../config/config";
8
5
 
6
+ import { Box, Divider, Link as MuiLink, Typography } from "@mui/material";
7
+ import React, { useState } from "react";
8
+
9
9
  const handleOAuthLogin = (
10
10
  { redirectUri, authUrl, clientId, scope },
11
- provider
11
+ identityProvider
12
12
  ) => {
13
13
  const state = JSON.stringify({
14
- provider: provider,
14
+ identityProvider: identityProvider,
15
15
  });
16
16
  const encodedState = encodeURIComponent(state);
17
17
  window.location.href = `${authUrl}?client_id=${clientId}&scope=${scope}&response_type=code&redirect_uri=${redirectUri}&state=${encodedState}`;