@fabriktor/fx 0.0.178 → 0.0.179

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.
@@ -36,6 +36,7 @@ export * from "./marketplace/marketplace.js";
36
36
  export * from "./marketplace/validation.js";
37
37
  export * from "./memos/memos.js";
38
38
  export * from "./notifications/notifications.js";
39
+ export * from "./notifications/route.js";
39
40
  export * from "./payments/payments.js";
40
41
  export * from "./payrolls/payrolls.js";
41
42
  export * from "./payrolls/workspace.js";
package/dist/src/index.js CHANGED
@@ -36,6 +36,7 @@ export * from "./marketplace/marketplace.js";
36
36
  export * from "./marketplace/validation.js";
37
37
  export * from "./memos/memos.js";
38
38
  export * from "./notifications/notifications.js";
39
+ export * from "./notifications/route.js";
39
40
  export * from "./payments/payments.js";
40
41
  export * from "./payrolls/payrolls.js";
41
42
  export * from "./payrolls/workspace.js";
@@ -0,0 +1,2 @@
1
+ export type NotificationRoute = Record<string, string>;
2
+ export declare function notificationRoute(link: string): NotificationRoute | null;
@@ -0,0 +1,50 @@
1
+ import { ColChatChatRooms, DeepLinkScheme, DeepLinkViewKey, DeepLinkRecordKey, DeepLinkToolChat, DeepLinkViewChatAll, DeepLinkToolPreferences, DeepLinkViewPreferencesProfile, IDKey, } from "@fabriktor/schema";
2
+ import { resolvedID } from "../core/id.js";
3
+ export function notificationRoute(link) {
4
+ try {
5
+ const url = new URL(link);
6
+ if (url.protocol !== `${DeepLinkScheme}:` ||
7
+ !url.hostname ||
8
+ url.username ||
9
+ url.password ||
10
+ url.port ||
11
+ url.hash)
12
+ return null;
13
+ const parts = url.pathname
14
+ .split("/")
15
+ .filter(Boolean)
16
+ .map(decodeURIComponent);
17
+ const tool = url.hostname;
18
+ if (parts.length > 0 && (tool !== DeepLinkToolChat || parts.length !== 1))
19
+ return null;
20
+ const id = resolvedID(parts[0] ?? url.searchParams.get(IDKey));
21
+ const record = url.searchParams.get(DeepLinkRecordKey);
22
+ const view = url.searchParams.get(DeepLinkViewKey);
23
+ if (tool === DeepLinkToolChat &&
24
+ (parts.length === 1 || record === ColChatChatRooms))
25
+ return id
26
+ ? {
27
+ tool,
28
+ view: DeepLinkViewChatAll,
29
+ scope_type: ColChatChatRooms,
30
+ scope_id: id,
31
+ }
32
+ : null;
33
+ const out = { tool };
34
+ if (view)
35
+ out.view = view;
36
+ if (tool === DeepLinkToolPreferences &&
37
+ view === DeepLinkViewPreferencesProfile)
38
+ return out;
39
+ if (record) {
40
+ if (!id)
41
+ return null;
42
+ out.record = record;
43
+ out.id = id;
44
+ }
45
+ return out;
46
+ }
47
+ catch {
48
+ return null;
49
+ }
50
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fabriktor/fx",
3
- "version": "0.0.178",
3
+ "version": "0.0.179",
4
4
  "description": "![Fabriktor Logo](./img/fabriktor-character.gif)",
5
5
  "type": "module",
6
6
  "exports": {
@@ -17,9 +17,9 @@
17
17
  "typescript": "^6.0.3"
18
18
  },
19
19
  "dependencies": {
20
- "@fabriktor/client": "0.0.109",
20
+ "@fabriktor/client": "0.0.111",
21
21
  "@fabriktor/fx": "0.0.94",
22
- "@fabriktor/schema": "0.0.81",
22
+ "@fabriktor/schema": "0.0.83",
23
23
  "convert": "8.0.2"
24
24
  }
25
25
  }