@bifrost-ai/ui-events 0.1.1-build.1784656950996

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.
@@ -0,0 +1,38 @@
1
+ //#region src/types.d.ts
2
+ type OpenWorkItemStatus = "draft" | "live" | "paused";
3
+ type OpenWorkItem = {
4
+ workItemId: string;
5
+ kind: string;
6
+ name: string;
7
+ status: OpenWorkItemStatus;
8
+ parentWorkItemId?: string;
9
+ };
10
+ type WorkItemsHydrated = {
11
+ type: "workItems/hydrated";
12
+ payload: {
13
+ items: OpenWorkItem[];
14
+ };
15
+ };
16
+ type WorkItemsUpserted = {
17
+ type: "workItems/upserted";
18
+ payload: OpenWorkItem;
19
+ };
20
+ type WorkItemsRemoved = {
21
+ type: "workItems/removed";
22
+ payload: {
23
+ workItemId: string;
24
+ };
25
+ };
26
+ type UiAction = WorkItemsHydrated | WorkItemsUpserted | WorkItemsRemoved;
27
+ declare const OPEN_WORK_ITEM_STATUSES: readonly ["draft", "live", "paused"];
28
+ declare function isOpenWorkItemStatus(status: string): status is OpenWorkItemStatus;
29
+ declare function isUiAction(value: unknown): value is UiAction;
30
+ declare function isOpenWorkItem(value: unknown): value is OpenWorkItem;
31
+ //#endregion
32
+ //#region src/actions.d.ts
33
+ declare function workItemsHydrated(items: OpenWorkItem[]): WorkItemsHydrated;
34
+ declare function workItemsUpserted(item: OpenWorkItem): WorkItemsUpserted;
35
+ declare function workItemsRemoved(workItemId: string): WorkItemsRemoved;
36
+ declare function parentWorkItemIdFrom(state: Record<string, unknown> | undefined, metadata: Record<string, unknown> | undefined): string | undefined;
37
+ //#endregion
38
+ export { OPEN_WORK_ITEM_STATUSES, type OpenWorkItem, type OpenWorkItemStatus, type UiAction, type WorkItemsHydrated, type WorkItemsRemoved, type WorkItemsUpserted, isOpenWorkItem, isOpenWorkItemStatus, isUiAction, parentWorkItemIdFrom, workItemsHydrated, workItemsRemoved, workItemsUpserted };
package/dist/index.mjs ADDED
@@ -0,0 +1,63 @@
1
+ //#region src/actions.ts
2
+ function workItemsHydrated(items) {
3
+ return {
4
+ type: "workItems/hydrated",
5
+ payload: { items }
6
+ };
7
+ }
8
+ function workItemsUpserted(item) {
9
+ return {
10
+ type: "workItems/upserted",
11
+ payload: item
12
+ };
13
+ }
14
+ function workItemsRemoved(workItemId) {
15
+ return {
16
+ type: "workItems/removed",
17
+ payload: { workItemId }
18
+ };
19
+ }
20
+ function parentWorkItemIdFrom(state, metadata) {
21
+ if (state !== void 0 && typeof state.workflowWorkItemId === "string") return state.workflowWorkItemId;
22
+ if (metadata !== void 0 && typeof metadata.parentId === "string") return metadata.parentId;
23
+ }
24
+ //#endregion
25
+ //#region src/types.ts
26
+ const OPEN_WORK_ITEM_STATUSES = [
27
+ "draft",
28
+ "live",
29
+ "paused"
30
+ ];
31
+ function isOpenWorkItemStatus(status) {
32
+ return OPEN_WORK_ITEM_STATUSES.includes(status);
33
+ }
34
+ function isUiAction(value) {
35
+ if (value === null || typeof value !== "object") return false;
36
+ const record = value;
37
+ if (typeof record.type !== "string") return false;
38
+ switch (record.type) {
39
+ case "workItems/hydrated": return isHydratedPayload(record.payload);
40
+ case "workItems/upserted": return isOpenWorkItem(record.payload);
41
+ case "workItems/removed": return isRemovedPayload(record.payload);
42
+ default: return false;
43
+ }
44
+ }
45
+ function isOpenWorkItem(value) {
46
+ if (value === null || typeof value !== "object") return false;
47
+ const record = value;
48
+ if (typeof record.workItemId !== "string" || record.workItemId.length === 0 || typeof record.kind !== "string" || record.kind.length === 0 || typeof record.name !== "string" || record.name.length === 0 || typeof record.status !== "string" || !isOpenWorkItemStatus(record.status)) return false;
49
+ if (record.parentWorkItemId !== void 0 && typeof record.parentWorkItemId !== "string") return false;
50
+ return true;
51
+ }
52
+ function isHydratedPayload(value) {
53
+ if (value === null || typeof value !== "object") return false;
54
+ const record = value;
55
+ return Array.isArray(record.items) && record.items.every((item) => isOpenWorkItem(item));
56
+ }
57
+ function isRemovedPayload(value) {
58
+ if (value === null || typeof value !== "object") return false;
59
+ const record = value;
60
+ return typeof record.workItemId === "string" && record.workItemId.length > 0;
61
+ }
62
+ //#endregion
63
+ export { OPEN_WORK_ITEM_STATUSES, isOpenWorkItem, isOpenWorkItemStatus, isUiAction, parentWorkItemIdFrom, workItemsHydrated, workItemsRemoved, workItemsUpserted };
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "@bifrost-ai/ui-events",
3
+ "version": "0.1.1-build.1784656950996",
4
+ "description": "Redux-shaped UI event actions for the orchestrator console",
5
+ "license": "MIT",
6
+ "files": [
7
+ "dist"
8
+ ],
9
+ "type": "module",
10
+ "exports": {
11
+ ".": "./dist/index.mjs",
12
+ "./package.json": "./package.json"
13
+ },
14
+ "publishConfig": {
15
+ "access": "public"
16
+ },
17
+ "devDependencies": {
18
+ "@types/node": "^25.6.2",
19
+ "@typescript/native-preview": "latest",
20
+ "bumpp": "^11.1.0",
21
+ "typescript": "^6.0.3",
22
+ "vite-plus": "^0.2.0",
23
+ "vitest-gwt": "^4.1.0"
24
+ },
25
+ "scripts": {
26
+ "build": "vp pack",
27
+ "dev": "vp pack --watch",
28
+ "test": "vp test --passWithNoTests",
29
+ "check": "vp check"
30
+ }
31
+ }