@rise-x/apps-sdk 0.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.
- package/LICENSE +1 -0
- package/README.md +553 -0
- package/build/_internal.d.ts +2 -0
- package/build/_internal.js +23 -0
- package/build/accessors.d.ts +8 -0
- package/build/accessors.js +40 -0
- package/build/cli/index.d.ts +13 -0
- package/build/cli/index.js +54 -0
- package/build/cli/init.d.ts +6 -0
- package/build/cli/init.js +179 -0
- package/build/cli/templating.d.ts +2 -0
- package/build/cli/templating.js +84 -0
- package/build/connectors/agents.d.ts +85 -0
- package/build/connectors/agents.js +404 -0
- package/build/connectors/assets.d.ts +76 -0
- package/build/connectors/assets.js +204 -0
- package/build/connectors/deps.d.ts +4 -0
- package/build/connectors/deps.js +2 -0
- package/build/connectors/errors.d.ts +11 -0
- package/build/connectors/errors.js +67 -0
- package/build/connectors/flows.d.ts +37 -0
- package/build/connectors/flows.js +191 -0
- package/build/connectors/index.d.ts +8 -0
- package/build/connectors/index.js +50 -0
- package/build/connectors/sse.d.ts +12 -0
- package/build/connectors/sse.js +157 -0
- package/build/connectors/types.d.ts +285 -0
- package/build/connectors/types.js +419 -0
- package/build/connectors/work.d.ts +84 -0
- package/build/connectors/work.js +224 -0
- package/build/hooks.d.ts +4 -0
- package/build/hooks.js +28 -0
- package/build/index.d.ts +6 -0
- package/build/index.js +34 -0
- package/build/lifecycle.d.ts +23 -0
- package/build/lifecycle.js +6 -0
- package/build/mockShell.d.ts +10 -0
- package/build/mockShell.js +55 -0
- package/build/query/agents.d.ts +80 -0
- package/build/query/agents.js +143 -0
- package/build/query/assets.d.ts +73 -0
- package/build/query/assets.js +152 -0
- package/build/query/client.d.ts +5 -0
- package/build/query/client.js +68 -0
- package/build/query/context.d.ts +2 -0
- package/build/query/context.js +34 -0
- package/build/query/flows.d.ts +54 -0
- package/build/query/flows.js +81 -0
- package/build/query/index.d.ts +10 -0
- package/build/query/index.js +85 -0
- package/build/query/keys.d.ts +51 -0
- package/build/query/keys.js +79 -0
- package/build/query/layer.d.ts +175 -0
- package/build/query/layer.js +35 -0
- package/build/query/shared.d.ts +43 -0
- package/build/query/shared.js +116 -0
- package/build/query/work.d.ts +75 -0
- package/build/query/work.js +172 -0
- package/build/shell/index.d.ts +1 -0
- package/build/shell/index.js +6 -0
- package/build/shell/installShellBridge.d.ts +11 -0
- package/build/shell/installShellBridge.js +104 -0
- package/build/shellBridge.d.ts +36 -0
- package/build/shellBridge.js +10 -0
- package/build/topBar.d.ts +25 -0
- package/build/topBar.js +17 -0
- package/build/ui/components/ai.d.ts +49 -0
- package/build/ui/components/alert-dialog.d.ts +27 -0
- package/build/ui/components/alert.d.ts +14 -0
- package/build/ui/components/avatar.d.ts +17 -0
- package/build/ui/components/badge.d.ts +19 -0
- package/build/ui/components/button.d.ts +13 -0
- package/build/ui/components/calendar.d.ts +21 -0
- package/build/ui/components/card.d.ts +16 -0
- package/build/ui/components/chart.d.ts +124 -0
- package/build/ui/components/checkbox.d.ts +4 -0
- package/build/ui/components/data-table.d.ts +70 -0
- package/build/ui/components/dialog.d.ts +17 -0
- package/build/ui/components/dropdown-menu.d.ts +29 -0
- package/build/ui/components/empty-state.d.ts +7 -0
- package/build/ui/components/file-upload.d.ts +17 -0
- package/build/ui/components/input.d.ts +8 -0
- package/build/ui/components/label.d.ts +4 -0
- package/build/ui/components/list.d.ts +24 -0
- package/build/ui/components/map.d.ts +26 -0
- package/build/ui/components/message.d.ts +24 -0
- package/build/ui/components/nav.d.ts +12 -0
- package/build/ui/components/page-header.d.ts +27 -0
- package/build/ui/components/popover.d.ts +10 -0
- package/build/ui/components/progress.d.ts +4 -0
- package/build/ui/components/radio.d.ts +6 -0
- package/build/ui/components/resizable.d.ts +7 -0
- package/build/ui/components/scroll-area.d.ts +5 -0
- package/build/ui/components/segmented.d.ts +6 -0
- package/build/ui/components/select.d.ts +15 -0
- package/build/ui/components/separator.d.ts +4 -0
- package/build/ui/components/sheet.d.ts +14 -0
- package/build/ui/components/skeleton.d.ts +3 -0
- package/build/ui/components/slider.d.ts +15 -0
- package/build/ui/components/snackbar.d.ts +3 -0
- package/build/ui/components/sonner.d.ts +4 -0
- package/build/ui/components/spinner.d.ts +5 -0
- package/build/ui/components/statistic.d.ts +19 -0
- package/build/ui/components/stepper.d.ts +12 -0
- package/build/ui/components/switch.d.ts +6 -0
- package/build/ui/components/table.d.ts +24 -0
- package/build/ui/components/textarea.d.ts +3 -0
- package/build/ui/components/timeline.d.ts +15 -0
- package/build/ui/components/toggle-group.d.ts +10 -0
- package/build/ui/components/toggle.d.ts +9 -0
- package/build/ui/components/tooltip.d.ts +7 -0
- package/build/ui/index.d.ts +46 -0
- package/build/ui/index.js +8 -0
- package/build/ui/lib/utils.d.ts +2 -0
- package/build/ui/reference/README.md +11 -0
- package/build/ui/reference/components/ai.tsx +291 -0
- package/build/ui/reference/components/alert-dialog.tsx +208 -0
- package/build/ui/reference/components/alert.tsx +112 -0
- package/build/ui/reference/components/avatar.tsx +158 -0
- package/build/ui/reference/components/badge.tsx +160 -0
- package/build/ui/reference/components/button.tsx +100 -0
- package/build/ui/reference/components/calendar.tsx +119 -0
- package/build/ui/reference/components/card.tsx +144 -0
- package/build/ui/reference/components/chart.tsx +1394 -0
- package/build/ui/reference/components/checkbox.tsx +44 -0
- package/build/ui/reference/components/data-table.tsx +480 -0
- package/build/ui/reference/components/dialog.tsx +172 -0
- package/build/ui/reference/components/dropdown-menu.tsx +245 -0
- package/build/ui/reference/components/empty-state.tsx +63 -0
- package/build/ui/reference/components/file-upload.tsx +116 -0
- package/build/ui/reference/components/input.tsx +114 -0
- package/build/ui/reference/components/label.tsx +19 -0
- package/build/ui/reference/components/list.tsx +191 -0
- package/build/ui/reference/components/map.css +251 -0
- package/build/ui/reference/components/map.tsx +294 -0
- package/build/ui/reference/components/message.tsx +171 -0
- package/build/ui/reference/components/nav.tsx +113 -0
- package/build/ui/reference/components/page-header.tsx +213 -0
- package/build/ui/reference/components/popover.tsx +76 -0
- package/build/ui/reference/components/progress.tsx +31 -0
- package/build/ui/reference/components/radio.tsx +65 -0
- package/build/ui/reference/components/resizable.tsx +40 -0
- package/build/ui/reference/components/scroll-area.tsx +55 -0
- package/build/ui/reference/components/segmented.tsx +45 -0
- package/build/ui/reference/components/select.tsx +185 -0
- package/build/ui/reference/components/separator.tsx +26 -0
- package/build/ui/reference/components/sheet.tsx +173 -0
- package/build/ui/reference/components/skeleton.tsx +15 -0
- package/build/ui/reference/components/slider.tsx +161 -0
- package/build/ui/reference/components/snackbar.tsx +27 -0
- package/build/ui/reference/components/sonner.tsx +43 -0
- package/build/ui/reference/components/spinner.tsx +27 -0
- package/build/ui/reference/components/statistic.tsx +122 -0
- package/build/ui/reference/components/stepper.tsx +138 -0
- package/build/ui/reference/components/switch.tsx +47 -0
- package/build/ui/reference/components/table.tsx +233 -0
- package/build/ui/reference/components/textarea.tsx +28 -0
- package/build/ui/reference/components/timeline.tsx +94 -0
- package/build/ui/reference/components/toggle-group.tsx +86 -0
- package/build/ui/reference/components/toggle.tsx +46 -0
- package/build/ui/reference/components/tooltip.tsx +53 -0
- package/build/ui/reference/index.ts +49 -0
- package/build/ui/reference/lib/utils.ts +34 -0
- package/build/ui/standalone-stub.js +5 -0
- package/build/ui/standalone.js +135 -0
- package/build/ui/styles.css +3 -0
- package/connectors/package.json +8 -0
- package/package.json +114 -0
- package/query/package.json +8 -0
- package/shell/package.json +8 -0
- package/template/AGENTS.md +70 -0
- package/template/CLAUDE.md +4 -0
- package/template/README.md +102 -0
- package/template/_gitignore +6 -0
- package/template/commitlint.config.js +12 -0
- package/template/package.json +31 -0
- package/template/public/index.html +13 -0
- package/template/src/App.tsx +171 -0
- package/template/src/bootstrap.tsx +13 -0
- package/template/src/index.tsx +1 -0
- package/template/src/lifecycle.ts +20 -0
- package/template/tsconfig.json +31 -0
- package/template/webpack.config.js +112 -0
- package/template/webpack.local.config.js +68 -0
- package/ui/package.json +8 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.agentQueries = void 0;
|
|
4
|
+
exports.createAgentQueries = createAgentQueries;
|
|
5
|
+
exports.useAgents = useAgents;
|
|
6
|
+
exports.useAgent = useAgent;
|
|
7
|
+
exports.useAgentChats = useAgentChats;
|
|
8
|
+
exports.useAgentChat = useAgentChat;
|
|
9
|
+
exports.useAgentChatMessages = useAgentChatMessages;
|
|
10
|
+
exports.useCreateAgent = useCreateAgent;
|
|
11
|
+
exports.useUpdateAgent = useUpdateAgent;
|
|
12
|
+
exports.useDeleteAgent = useDeleteAgent;
|
|
13
|
+
exports.useRenameAgentChat = useRenameAgentChat;
|
|
14
|
+
exports.useDeleteAgentChat = useDeleteAgentChat;
|
|
15
|
+
// Agents domain: queryOptions factories, hooks, and the agent mutations with
|
|
16
|
+
// their cache-consistency rules. Built-in invalidation runs before the
|
|
17
|
+
// caller's onSuccess — composed, never replaced.
|
|
18
|
+
//
|
|
19
|
+
// The SSE surfaces (agents.run, chat sessions) are streams, not cacheable
|
|
20
|
+
// reads — they stay on the connector.
|
|
21
|
+
const react_query_1 = require("@tanstack/react-query");
|
|
22
|
+
const agents_1 = require("../connectors/agents");
|
|
23
|
+
const keys_1 = require("./keys");
|
|
24
|
+
const shared_1 = require("./shared");
|
|
25
|
+
function createAgentQueries(connector, getEnvId) {
|
|
26
|
+
return {
|
|
27
|
+
list: (args = {}) => {
|
|
28
|
+
const envId = getEnvId();
|
|
29
|
+
return (0, react_query_1.queryOptions)({
|
|
30
|
+
queryKey: keys_1.queryKeys.agents.list(envId, (0, keys_1.normalizeArgs)(args)),
|
|
31
|
+
queryFn: ({ signal }) => connector.list({ ...args, signal }),
|
|
32
|
+
enabled: envId != null,
|
|
33
|
+
});
|
|
34
|
+
},
|
|
35
|
+
detail: (id) => {
|
|
36
|
+
const envId = getEnvId();
|
|
37
|
+
return (0, react_query_1.queryOptions)({
|
|
38
|
+
queryKey: keys_1.queryKeys.agents.detail(envId, id),
|
|
39
|
+
queryFn: ({ signal }) => connector.get(id, { signal }),
|
|
40
|
+
enabled: envId != null && !!id,
|
|
41
|
+
});
|
|
42
|
+
},
|
|
43
|
+
chats: (args = {}) => {
|
|
44
|
+
const envId = getEnvId();
|
|
45
|
+
return (0, react_query_1.queryOptions)({
|
|
46
|
+
queryKey: keys_1.queryKeys.agents.chats(envId, (0, keys_1.normalizeArgs)(args)),
|
|
47
|
+
queryFn: ({ signal }) => connector.listChats({ ...args, signal }),
|
|
48
|
+
enabled: envId != null,
|
|
49
|
+
});
|
|
50
|
+
},
|
|
51
|
+
chat: (id) => {
|
|
52
|
+
const envId = getEnvId();
|
|
53
|
+
return (0, react_query_1.queryOptions)({
|
|
54
|
+
queryKey: keys_1.queryKeys.agents.chat(envId, id),
|
|
55
|
+
queryFn: ({ signal }) => connector.getChat(id, { signal }),
|
|
56
|
+
enabled: envId != null && !!id,
|
|
57
|
+
});
|
|
58
|
+
},
|
|
59
|
+
chatMessages: (id, args = {}) => {
|
|
60
|
+
const envId = getEnvId();
|
|
61
|
+
return (0, react_query_1.queryOptions)({
|
|
62
|
+
queryKey: keys_1.queryKeys.agents.chatMessages(envId, id, (0, keys_1.normalizeArgs)(args)),
|
|
63
|
+
queryFn: ({ signal }) => connector.getChatMessages(id, { ...args, signal }),
|
|
64
|
+
enabled: envId != null && !!id,
|
|
65
|
+
});
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
// Ready-made singleton bound to the live shell bridge — same construction
|
|
70
|
+
// createQueryLayer() uses, just against the live connector singleton.
|
|
71
|
+
exports.agentQueries = createAgentQueries(agents_1.agents, shared_1.getLiveEnvId);
|
|
72
|
+
// ---- hooks ----
|
|
73
|
+
function useAgents(args, options) {
|
|
74
|
+
return (0, shared_1.useSdkQuery)(exports.agentQueries.list(args), options);
|
|
75
|
+
}
|
|
76
|
+
function useAgent(id, options) {
|
|
77
|
+
return (0, shared_1.useSdkQuery)(exports.agentQueries.detail(id), options);
|
|
78
|
+
}
|
|
79
|
+
function useAgentChats(args, options) {
|
|
80
|
+
return (0, shared_1.useSdkQuery)(exports.agentQueries.chats(args), options);
|
|
81
|
+
}
|
|
82
|
+
function useAgentChat(id, options) {
|
|
83
|
+
return (0, shared_1.useSdkQuery)(exports.agentQueries.chat(id), options);
|
|
84
|
+
}
|
|
85
|
+
function useAgentChatMessages(id, args, options) {
|
|
86
|
+
return (0, shared_1.useSdkQuery)(exports.agentQueries.chatMessages(id, args), options);
|
|
87
|
+
}
|
|
88
|
+
// ---- mutations ----
|
|
89
|
+
function useCreateAgent(options) {
|
|
90
|
+
return (0, shared_1.useSdkMutation)((vars) => agents_1.agents.create(vars), (client) => {
|
|
91
|
+
const envId = (0, shared_1.getLiveEnvId)();
|
|
92
|
+
void client.invalidateQueries({
|
|
93
|
+
queryKey: keys_1.queryKeys.agents.lists(envId),
|
|
94
|
+
});
|
|
95
|
+
}, options);
|
|
96
|
+
}
|
|
97
|
+
function useUpdateAgent(options) {
|
|
98
|
+
return (0, shared_1.useSdkMutation)((vars) => agents_1.agents.update(vars.id, vars.patch), (client, data, vars) => {
|
|
99
|
+
const envId = (0, shared_1.getLiveEnvId)();
|
|
100
|
+
client.setQueryData(keys_1.queryKeys.agents.detail(envId, vars.id), data);
|
|
101
|
+
void client.invalidateQueries({
|
|
102
|
+
queryKey: keys_1.queryKeys.agents.lists(envId),
|
|
103
|
+
});
|
|
104
|
+
}, options);
|
|
105
|
+
}
|
|
106
|
+
function useDeleteAgent(options) {
|
|
107
|
+
return (0, shared_1.useSdkMutation)((vars) => agents_1.agents.delete(vars.id), (client, _data, vars) => {
|
|
108
|
+
const envId = (0, shared_1.getLiveEnvId)();
|
|
109
|
+
client.removeQueries({
|
|
110
|
+
queryKey: keys_1.queryKeys.agents.detail(envId, vars.id),
|
|
111
|
+
});
|
|
112
|
+
void client.invalidateQueries({
|
|
113
|
+
queryKey: keys_1.queryKeys.agents.lists(envId),
|
|
114
|
+
});
|
|
115
|
+
// Deleting an agent orphans its chats — refresh the chat listings too.
|
|
116
|
+
void client.invalidateQueries({
|
|
117
|
+
queryKey: keys_1.queryKeys.agents.chatsAll(envId),
|
|
118
|
+
});
|
|
119
|
+
}, options);
|
|
120
|
+
}
|
|
121
|
+
function useRenameAgentChat(options) {
|
|
122
|
+
return (0, shared_1.useSdkMutation)((vars) => agents_1.agents.renameChat(vars.id, vars.title), (client, data, vars) => {
|
|
123
|
+
const envId = (0, shared_1.getLiveEnvId)();
|
|
124
|
+
client.setQueryData(keys_1.queryKeys.agents.chat(envId, vars.id), data);
|
|
125
|
+
void client.invalidateQueries({
|
|
126
|
+
queryKey: keys_1.queryKeys.agents.chatsAll(envId),
|
|
127
|
+
});
|
|
128
|
+
}, options);
|
|
129
|
+
}
|
|
130
|
+
function useDeleteAgentChat(options) {
|
|
131
|
+
return (0, shared_1.useSdkMutation)((vars) => agents_1.agents.deleteChat(vars.id), (client, _data, vars) => {
|
|
132
|
+
const envId = (0, shared_1.getLiveEnvId)();
|
|
133
|
+
client.removeQueries({
|
|
134
|
+
queryKey: keys_1.queryKeys.agents.chat(envId, vars.id),
|
|
135
|
+
});
|
|
136
|
+
client.removeQueries({
|
|
137
|
+
queryKey: keys_1.queryKeys.agents.chatMessagesAll(envId, vars.id),
|
|
138
|
+
});
|
|
139
|
+
void client.invalidateQueries({
|
|
140
|
+
queryKey: keys_1.queryKeys.agents.chatsAll(envId),
|
|
141
|
+
});
|
|
142
|
+
}, options);
|
|
143
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { type InfiniteData, type UseInfiniteQueryResult, type UseQueryResult } from "@tanstack/react-query";
|
|
2
|
+
import { type AssetRowPage, type AssetsConnector, type CreateAssetArgs, type ListAssetRowsArgs, type ListRelatedAssetsArgs, type SearchAssetsArgs, type StartEditAssetArgs } from "../connectors/assets";
|
|
3
|
+
import type { ConnectorError } from "../connectors/errors";
|
|
4
|
+
import type { AssetDetail, AssetSummary, AssetType, WorkDetail } from "../connectors/types";
|
|
5
|
+
import { type QueryEnvId } from "./keys";
|
|
6
|
+
import { type SdkMutationOptions, type SdkQueryOptions } from "./shared";
|
|
7
|
+
export type SearchAssetsQueryArgs = Omit<SearchAssetsArgs, "signal">;
|
|
8
|
+
export type ListAssetRowsQueryArgs = Omit<ListAssetRowsArgs, "skip" | "signal">;
|
|
9
|
+
export type ListRelatedAssetsQueryArgs = Omit<ListRelatedAssetsArgs, "signal">;
|
|
10
|
+
export declare function createAssetQueries(connector: AssetsConnector, getEnvId: () => QueryEnvId): {
|
|
11
|
+
types: () => import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<AssetType[], Error, AssetType[], readonly ["rise-apps-sdk", QueryEnvId, "assets", "types"]>, "queryFn"> & {
|
|
12
|
+
queryFn?: import("@tanstack/react-query").QueryFunction<AssetType[], readonly ["rise-apps-sdk", QueryEnvId, "assets", "types"], never> | undefined;
|
|
13
|
+
} & {
|
|
14
|
+
queryKey: import("@tanstack/react-query").DataTag<readonly ["rise-apps-sdk", QueryEnvId, "assets", "types"], AssetType[]>;
|
|
15
|
+
};
|
|
16
|
+
detail: (assetId: string) => import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<AssetDetail, Error, AssetDetail, readonly ["rise-apps-sdk", QueryEnvId, "assets", "detail", string]>, "queryFn"> & {
|
|
17
|
+
queryFn?: import("@tanstack/react-query").QueryFunction<AssetDetail, readonly ["rise-apps-sdk", QueryEnvId, "assets", "detail", string], never> | undefined;
|
|
18
|
+
} & {
|
|
19
|
+
queryKey: import("@tanstack/react-query").DataTag<readonly ["rise-apps-sdk", QueryEnvId, "assets", "detail", string], AssetDetail>;
|
|
20
|
+
};
|
|
21
|
+
search: (args: SearchAssetsQueryArgs) => import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<AssetSummary[], Error, AssetSummary[], readonly ["rise-apps-sdk", QueryEnvId, "assets", "search", {
|
|
22
|
+
[x: string]: unknown;
|
|
23
|
+
}]>, "queryFn"> & {
|
|
24
|
+
queryFn?: import("@tanstack/react-query").QueryFunction<AssetSummary[], readonly ["rise-apps-sdk", QueryEnvId, "assets", "search", {
|
|
25
|
+
[x: string]: unknown;
|
|
26
|
+
}], never> | undefined;
|
|
27
|
+
} & {
|
|
28
|
+
queryKey: import("@tanstack/react-query").DataTag<readonly ["rise-apps-sdk", QueryEnvId, "assets", "search", {
|
|
29
|
+
[x: string]: unknown;
|
|
30
|
+
}], AssetSummary[]>;
|
|
31
|
+
};
|
|
32
|
+
rows: (args: ListAssetRowsQueryArgs) => import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseInfiniteQueryOptions<AssetRowPage, Error, InfiniteData<AssetRowPage, unknown>, AssetRowPage, readonly ["rise-apps-sdk", QueryEnvId, "assets", "rows", {
|
|
33
|
+
[x: string]: unknown;
|
|
34
|
+
}], number>, "queryFn"> & {
|
|
35
|
+
queryFn?: import("@tanstack/react-query").QueryFunction<AssetRowPage, readonly ["rise-apps-sdk", QueryEnvId, "assets", "rows", {
|
|
36
|
+
[x: string]: unknown;
|
|
37
|
+
}], number> | undefined;
|
|
38
|
+
} & {
|
|
39
|
+
queryKey: import("@tanstack/react-query").DataTag<readonly ["rise-apps-sdk", QueryEnvId, "assets", "rows", {
|
|
40
|
+
[x: string]: unknown;
|
|
41
|
+
}], InfiniteData<AssetRowPage, unknown>>;
|
|
42
|
+
};
|
|
43
|
+
related: (args: ListRelatedAssetsQueryArgs) => import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<AssetSummary[], Error, AssetSummary[], readonly ["rise-apps-sdk", QueryEnvId, "assets", "related", {
|
|
44
|
+
[x: string]: unknown;
|
|
45
|
+
}]>, "queryFn"> & {
|
|
46
|
+
queryFn?: import("@tanstack/react-query").QueryFunction<AssetSummary[], readonly ["rise-apps-sdk", QueryEnvId, "assets", "related", {
|
|
47
|
+
[x: string]: unknown;
|
|
48
|
+
}], never> | undefined;
|
|
49
|
+
} & {
|
|
50
|
+
queryKey: import("@tanstack/react-query").DataTag<readonly ["rise-apps-sdk", QueryEnvId, "assets", "related", {
|
|
51
|
+
[x: string]: unknown;
|
|
52
|
+
}], AssetSummary[]>;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
export type AssetQueries = ReturnType<typeof createAssetQueries>;
|
|
56
|
+
export declare const assetQueries: AssetQueries;
|
|
57
|
+
export declare function useAssetTypes(options?: SdkQueryOptions): UseQueryResult<AssetType[], ConnectorError>;
|
|
58
|
+
export declare function useAsset(assetId: string, options?: SdkQueryOptions): UseQueryResult<AssetDetail, ConnectorError>;
|
|
59
|
+
export declare function useAssetSearch(args: SearchAssetsQueryArgs, options?: SdkQueryOptions): UseQueryResult<AssetSummary[], ConnectorError>;
|
|
60
|
+
export declare function useAssetRows(args: ListAssetRowsQueryArgs, options?: SdkQueryOptions): UseInfiniteQueryResult<InfiniteData<AssetRowPage>, ConnectorError>;
|
|
61
|
+
export declare function useRelatedAssets(args: ListRelatedAssetsQueryArgs, options?: SdkQueryOptions): UseQueryResult<AssetSummary[], ConnectorError>;
|
|
62
|
+
export type CreateAssetVariables = Omit<CreateAssetArgs, "signal">;
|
|
63
|
+
export declare function useCreateAsset(options?: SdkMutationOptions<WorkDetail, CreateAssetVariables>): import("@tanstack/react-query").UseMutationResult<WorkDetail, ConnectorError, CreateAssetVariables, unknown>;
|
|
64
|
+
export type StartEditAssetVariables = Omit<StartEditAssetArgs, "signal">;
|
|
65
|
+
export declare function useStartEditAsset(options?: SdkMutationOptions<WorkDetail, StartEditAssetVariables>): import("@tanstack/react-query").UseMutationResult<WorkDetail, ConnectorError, StartEditAssetVariables, unknown>;
|
|
66
|
+
export interface CloneAssetVariables {
|
|
67
|
+
assetId: string;
|
|
68
|
+
}
|
|
69
|
+
export declare function useCloneAsset(options?: SdkMutationOptions<AssetDetail, CloneAssetVariables>): import("@tanstack/react-query").UseMutationResult<AssetDetail, ConnectorError, CloneAssetVariables, unknown>;
|
|
70
|
+
export interface DeleteAssetVariables {
|
|
71
|
+
assetId: string;
|
|
72
|
+
}
|
|
73
|
+
export declare function useDeleteAsset(options?: SdkMutationOptions<void, DeleteAssetVariables>): import("@tanstack/react-query").UseMutationResult<void, ConnectorError, DeleteAssetVariables, unknown>;
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.assetQueries = void 0;
|
|
4
|
+
exports.createAssetQueries = createAssetQueries;
|
|
5
|
+
exports.useAssetTypes = useAssetTypes;
|
|
6
|
+
exports.useAsset = useAsset;
|
|
7
|
+
exports.useAssetSearch = useAssetSearch;
|
|
8
|
+
exports.useAssetRows = useAssetRows;
|
|
9
|
+
exports.useRelatedAssets = useRelatedAssets;
|
|
10
|
+
exports.useCreateAsset = useCreateAsset;
|
|
11
|
+
exports.useStartEditAsset = useStartEditAsset;
|
|
12
|
+
exports.useCloneAsset = useCloneAsset;
|
|
13
|
+
exports.useDeleteAsset = useDeleteAsset;
|
|
14
|
+
// Assets domain: queryOptions factories, hooks, and the asset mutations with
|
|
15
|
+
// their cache-consistency rules. Built-in invalidation runs before the
|
|
16
|
+
// caller's onSuccess — composed, never replaced.
|
|
17
|
+
//
|
|
18
|
+
// Note the platform's edit model: create/startEdit return a DRAFT WORK ITEM —
|
|
19
|
+
// the asset only materializes when that draft is saved via work.submit
|
|
20
|
+
// (useSubmitWork), which is why those mutations invalidate the WORK listings
|
|
21
|
+
// here and useSubmitWork (query/work.ts) invalidates the assets scope.
|
|
22
|
+
const react_query_1 = require("@tanstack/react-query");
|
|
23
|
+
const assets_1 = require("../connectors/assets");
|
|
24
|
+
const keys_1 = require("./keys");
|
|
25
|
+
const shared_1 = require("./shared");
|
|
26
|
+
// Key-side view of an AssetTypeRef. Never throws (unlike the connector's
|
|
27
|
+
// resolver) — a flow-less type still needs a stable key so the query can fail
|
|
28
|
+
// through queryFn with a proper ConnectorError instead of crashing the render.
|
|
29
|
+
const assetTypeKey = (type) => typeof type === "string"
|
|
30
|
+
? type
|
|
31
|
+
: type
|
|
32
|
+
? type.flow?.flowOriginId ||
|
|
33
|
+
type.flow?.id ||
|
|
34
|
+
`entityType:${type.entityType}`
|
|
35
|
+
: "";
|
|
36
|
+
function createAssetQueries(connector, getEnvId) {
|
|
37
|
+
return {
|
|
38
|
+
types: () => {
|
|
39
|
+
const envId = getEnvId();
|
|
40
|
+
return (0, react_query_1.queryOptions)({
|
|
41
|
+
queryKey: keys_1.queryKeys.assets.types(envId),
|
|
42
|
+
queryFn: ({ signal }) => connector.types({ signal }),
|
|
43
|
+
enabled: envId != null,
|
|
44
|
+
});
|
|
45
|
+
},
|
|
46
|
+
detail: (assetId) => {
|
|
47
|
+
const envId = getEnvId();
|
|
48
|
+
return (0, react_query_1.queryOptions)({
|
|
49
|
+
queryKey: keys_1.queryKeys.assets.detail(envId, assetId),
|
|
50
|
+
queryFn: ({ signal }) => connector.get(assetId, { signal }),
|
|
51
|
+
enabled: envId != null && !!assetId,
|
|
52
|
+
});
|
|
53
|
+
},
|
|
54
|
+
search: (args) => {
|
|
55
|
+
const envId = getEnvId();
|
|
56
|
+
return (0, react_query_1.queryOptions)({
|
|
57
|
+
queryKey: keys_1.queryKeys.assets.search(envId, (0, keys_1.normalizeArgs)(args)),
|
|
58
|
+
queryFn: ({ signal }) => connector.search({ ...args, signal }),
|
|
59
|
+
enabled: envId != null && (args.type != null || args.typeOriginId != null),
|
|
60
|
+
});
|
|
61
|
+
},
|
|
62
|
+
// Infinite skip-paged listing — see shared.ts's getNextRowsPageParam for
|
|
63
|
+
// the shift-safe advance rule. Render with dedupeRows(data).
|
|
64
|
+
rows: (args) => {
|
|
65
|
+
const envId = getEnvId();
|
|
66
|
+
return (0, react_query_1.infiniteQueryOptions)({
|
|
67
|
+
queryKey: keys_1.queryKeys.assets.rows(envId, (0, keys_1.normalizeArgs)({ ...args, type: assetTypeKey(args.type) })),
|
|
68
|
+
queryFn: ({ pageParam, signal }) => connector.list({ ...args, skip: pageParam, signal }),
|
|
69
|
+
initialPageParam: 0,
|
|
70
|
+
getNextPageParam: shared_1.getNextRowsPageParam,
|
|
71
|
+
enabled: envId != null && args.type != null,
|
|
72
|
+
});
|
|
73
|
+
},
|
|
74
|
+
related: (args) => {
|
|
75
|
+
const envId = getEnvId();
|
|
76
|
+
return (0, react_query_1.queryOptions)({
|
|
77
|
+
queryKey: keys_1.queryKeys.assets.related(envId, (0, keys_1.normalizeArgs)(args)),
|
|
78
|
+
queryFn: ({ signal }) => connector.listRelated({ ...args, signal }),
|
|
79
|
+
enabled: envId != null && !!args.assetId,
|
|
80
|
+
});
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
// Ready-made singleton bound to the live shell bridge — same construction
|
|
85
|
+
// createQueryLayer() uses, just against the live connector singleton.
|
|
86
|
+
exports.assetQueries = createAssetQueries(assets_1.assets, shared_1.getLiveEnvId);
|
|
87
|
+
// ---- hooks ----
|
|
88
|
+
function useAssetTypes(options) {
|
|
89
|
+
return (0, shared_1.useSdkQuery)(exports.assetQueries.types(), options);
|
|
90
|
+
}
|
|
91
|
+
function useAsset(assetId, options) {
|
|
92
|
+
return (0, shared_1.useSdkQuery)(exports.assetQueries.detail(assetId), options);
|
|
93
|
+
}
|
|
94
|
+
function useAssetSearch(args, options) {
|
|
95
|
+
return (0, shared_1.useSdkQuery)(exports.assetQueries.search(args), options);
|
|
96
|
+
}
|
|
97
|
+
// Infinite skip-paged listing; flatten pages with dedupeRows(data).
|
|
98
|
+
function useAssetRows(args, options) {
|
|
99
|
+
return (0, shared_1.useSdkInfiniteQuery)(exports.assetQueries.rows(args), options);
|
|
100
|
+
}
|
|
101
|
+
function useRelatedAssets(args, options) {
|
|
102
|
+
return (0, shared_1.useSdkQuery)(exports.assetQueries.related(args), options);
|
|
103
|
+
}
|
|
104
|
+
// Returns the draft work item — fill it with usePatchWorkData and save it
|
|
105
|
+
// with useSubmitWork (which also refreshes the asset listings).
|
|
106
|
+
function useCreateAsset(options) {
|
|
107
|
+
return (0, shared_1.useSdkMutation)((vars) => assets_1.assets.create(vars), (client) => {
|
|
108
|
+
const envId = (0, shared_1.getLiveEnvId)();
|
|
109
|
+
// CROSS-DOMAIN: the draft shows up as a WORK item; the asset itself
|
|
110
|
+
// only exists after submit.
|
|
111
|
+
void client.invalidateQueries({
|
|
112
|
+
queryKey: keys_1.queryKeys.work.allRows(envId),
|
|
113
|
+
});
|
|
114
|
+
}, options);
|
|
115
|
+
}
|
|
116
|
+
function useStartEditAsset(options) {
|
|
117
|
+
return (0, shared_1.useSdkMutation)((vars) => assets_1.assets.startEdit(vars), (client) => {
|
|
118
|
+
const envId = (0, shared_1.getLiveEnvId)();
|
|
119
|
+
// CROSS-DOMAIN: same draft-as-work-item model as useCreateAsset.
|
|
120
|
+
void client.invalidateQueries({
|
|
121
|
+
queryKey: keys_1.queryKeys.work.allRows(envId),
|
|
122
|
+
});
|
|
123
|
+
}, options);
|
|
124
|
+
}
|
|
125
|
+
function useCloneAsset(options) {
|
|
126
|
+
return (0, shared_1.useSdkMutation)((vars) => assets_1.assets.clone(vars.assetId), (client) => {
|
|
127
|
+
const envId = (0, shared_1.getLiveEnvId)();
|
|
128
|
+
void client.invalidateQueries({
|
|
129
|
+
queryKey: keys_1.queryKeys.assets.allRows(envId),
|
|
130
|
+
});
|
|
131
|
+
void client.invalidateQueries({
|
|
132
|
+
queryKey: keys_1.queryKeys.assets.searchAll(envId),
|
|
133
|
+
});
|
|
134
|
+
}, options);
|
|
135
|
+
}
|
|
136
|
+
function useDeleteAsset(options) {
|
|
137
|
+
return (0, shared_1.useSdkMutation)((vars) => assets_1.assets.delete(vars.assetId), (client, _data, vars) => {
|
|
138
|
+
const envId = (0, shared_1.getLiveEnvId)();
|
|
139
|
+
client.removeQueries({
|
|
140
|
+
queryKey: keys_1.queryKeys.assets.detail(envId, vars.assetId),
|
|
141
|
+
});
|
|
142
|
+
void client.invalidateQueries({
|
|
143
|
+
queryKey: keys_1.queryKeys.assets.allRows(envId),
|
|
144
|
+
});
|
|
145
|
+
void client.invalidateQueries({
|
|
146
|
+
queryKey: keys_1.queryKeys.assets.searchAll(envId),
|
|
147
|
+
});
|
|
148
|
+
void client.invalidateQueries({
|
|
149
|
+
queryKey: keys_1.queryKeys.assets.relatedAll(envId),
|
|
150
|
+
});
|
|
151
|
+
}, options);
|
|
152
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { QueryClient } from "@tanstack/react-query";
|
|
2
|
+
export declare function shouldRetryConnectorError(error: unknown): boolean;
|
|
3
|
+
export type AppQueryClientDefaults = NonNullable<ConstructorParameters<typeof QueryClient>[0]>["defaultOptions"];
|
|
4
|
+
export declare function createAppQueryClient(overrides?: AppQueryClientDefaults): QueryClient;
|
|
5
|
+
export declare function getFallbackAppClient(): QueryClient;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.shouldRetryConnectorError = shouldRetryConnectorError;
|
|
4
|
+
exports.createAppQueryClient = createAppQueryClient;
|
|
5
|
+
exports.getFallbackAppClient = getFallbackAppClient;
|
|
6
|
+
// QueryClient construction + the SDK's fallback client.
|
|
7
|
+
//
|
|
8
|
+
// NOTE on module resolution: react-query v5 still ships top-level `main`/
|
|
9
|
+
// `types` fields pointing at its legacy CJS build, which is what this
|
|
10
|
+
// package's tsc build (moduleResolution "node") resolves. If a future 5.x
|
|
11
|
+
// drops those fields, switch tsconfig.package.json to moduleResolution
|
|
12
|
+
// "node16" — nothing else in this layer depends on the resolution mode.
|
|
13
|
+
const react_query_1 = require("@tanstack/react-query");
|
|
14
|
+
const errors_1 = require("../connectors/errors");
|
|
15
|
+
// Codes that a retry can never fix: the request was refused, not lost.
|
|
16
|
+
const NON_RETRYABLE_CODES = new Set([
|
|
17
|
+
"ABORTED",
|
|
18
|
+
"NOT_FOUND",
|
|
19
|
+
"INVALID_ARG",
|
|
20
|
+
"SHELL_UNAVAILABLE",
|
|
21
|
+
"SHELL_TOO_OLD",
|
|
22
|
+
"AI_UNAVAILABLE",
|
|
23
|
+
]);
|
|
24
|
+
// Whether a failed request is worth retrying. Connector errors with terminal
|
|
25
|
+
// codes (and HTTP 4xx) are not; network errors and 5xx are. Unknown error
|
|
26
|
+
// shapes default to retryable — they are most likely transport-level.
|
|
27
|
+
function shouldRetryConnectorError(error) {
|
|
28
|
+
if (!(error instanceof errors_1.ConnectorError))
|
|
29
|
+
return true;
|
|
30
|
+
if (NON_RETRYABLE_CODES.has(error.code))
|
|
31
|
+
return false;
|
|
32
|
+
if (error.code === "HTTP_ERROR" &&
|
|
33
|
+
error.status !== undefined &&
|
|
34
|
+
error.status < 500) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
// A QueryClient tuned for federated apps: short staleTime (apps mostly show
|
|
40
|
+
// live operational data), bounded memory via gcTime, and a retry policy that
|
|
41
|
+
// understands ConnectorError. Pass overrides to adjust per app.
|
|
42
|
+
function createAppQueryClient(overrides) {
|
|
43
|
+
return new react_query_1.QueryClient({
|
|
44
|
+
defaultOptions: {
|
|
45
|
+
queries: {
|
|
46
|
+
staleTime: 30000,
|
|
47
|
+
gcTime: 5 * 60000,
|
|
48
|
+
refetchOnWindowFocus: false,
|
|
49
|
+
retry: (failureCount, error) => failureCount < 2 && shouldRetryConnectorError(error),
|
|
50
|
+
...overrides?.queries,
|
|
51
|
+
},
|
|
52
|
+
mutations: {
|
|
53
|
+
...overrides?.mutations,
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
// Per-bundle fallback client — used by the SDK hooks when no QueryClient is
|
|
59
|
+
// found in React context (standalone dev, an older shell that doesn't wrap
|
|
60
|
+
// apps, or an app whose webpack doesn't share @tanstack/react-query so the
|
|
61
|
+
// shell's context can't reach it). One client per app bundle keeps caches
|
|
62
|
+
// isolated between apps by construction.
|
|
63
|
+
let fallbackClient = null;
|
|
64
|
+
function getFallbackAppClient() {
|
|
65
|
+
if (!fallbackClient)
|
|
66
|
+
fallbackClient = createAppQueryClient();
|
|
67
|
+
return fallbackClient;
|
|
68
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useAppQueryClient = useAppQueryClient;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const react_query_1 = require("@tanstack/react-query");
|
|
6
|
+
const accessors_1 = require("../accessors");
|
|
7
|
+
const mockShell_1 = require("../mockShell");
|
|
8
|
+
const client_1 = require("./client");
|
|
9
|
+
let fallbackWarned = false;
|
|
10
|
+
// The QueryClient every SDK hook runs against: the nearest provider in React
|
|
11
|
+
// context when one exists (federated apps get a per-app client mounted by the
|
|
12
|
+
// shell's RemoteAppLoader), otherwise the SDK's per-bundle fallback client.
|
|
13
|
+
// Context requires the app to MF-share @tanstack/react-query (singleton) —
|
|
14
|
+
// without that the shell's provider can't reach the app's copy of the module
|
|
15
|
+
// and the fallback kicks in, which still works, just unmanaged by the shell.
|
|
16
|
+
function useAppQueryClient() {
|
|
17
|
+
const fromContext = (0, react_1.useContext)(react_query_1.QueryClientContext);
|
|
18
|
+
if (fromContext)
|
|
19
|
+
return fromContext;
|
|
20
|
+
if (process.env.NODE_ENV !== "production" && !fallbackWarned) {
|
|
21
|
+
const shell = (0, accessors_1.getShell)();
|
|
22
|
+
// Standalone dev runs on the mock shell where the fallback is the
|
|
23
|
+
// expected path — only warn when a real host failed to reach us.
|
|
24
|
+
if (shell && !(0, mockShell_1.isMockShell)(shell)) {
|
|
25
|
+
fallbackWarned = true;
|
|
26
|
+
console.warn("[@rise-x/apps-sdk/query] no QueryClient found in React context — " +
|
|
27
|
+
"using the SDK's per-bundle fallback client. If this app runs " +
|
|
28
|
+
"federated inside the Rise-X shell, add '@tanstack/react-query' " +
|
|
29
|
+
"to your webpack `shared` config (singleton) so the shell-managed " +
|
|
30
|
+
"per-app client can reach it.");
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return (0, client_1.getFallbackAppClient)();
|
|
34
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { type UseQueryResult } from "@tanstack/react-query";
|
|
2
|
+
import { type FindTaskArgs, type FindTaskResult, type FlowsConnector, type ListFlowsArgs } from "../connectors/flows";
|
|
3
|
+
import type { ConnectorError } from "../connectors/errors";
|
|
4
|
+
import type { Flow, FlowConfig, FlowSummary, Layout } from "../connectors/types";
|
|
5
|
+
import { type QueryEnvId } from "./keys";
|
|
6
|
+
import { type SdkQueryOptions } from "./shared";
|
|
7
|
+
export type ListFlowsQueryArgs = Omit<ListFlowsArgs, "signal">;
|
|
8
|
+
export type FindTaskQueryArgs = Omit<FindTaskArgs, "signal">;
|
|
9
|
+
export declare function createFlowQueries(connector: FlowsConnector, getEnvId: () => QueryEnvId): {
|
|
10
|
+
list: (args?: ListFlowsQueryArgs) => import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<FlowSummary[], Error, FlowSummary[], readonly ["rise-apps-sdk", QueryEnvId, "flows", "list", {
|
|
11
|
+
[x: string]: unknown;
|
|
12
|
+
}]>, "queryFn"> & {
|
|
13
|
+
queryFn?: import("@tanstack/react-query").QueryFunction<FlowSummary[], readonly ["rise-apps-sdk", QueryEnvId, "flows", "list", {
|
|
14
|
+
[x: string]: unknown;
|
|
15
|
+
}], never> | undefined;
|
|
16
|
+
} & {
|
|
17
|
+
queryKey: import("@tanstack/react-query").DataTag<readonly ["rise-apps-sdk", QueryEnvId, "flows", "list", {
|
|
18
|
+
[x: string]: unknown;
|
|
19
|
+
}], FlowSummary[]>;
|
|
20
|
+
};
|
|
21
|
+
detail: (flowId: string) => import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<Flow, Error, Flow, readonly ["rise-apps-sdk", QueryEnvId, "flows", "detail", string]>, "queryFn"> & {
|
|
22
|
+
queryFn?: import("@tanstack/react-query").QueryFunction<Flow, readonly ["rise-apps-sdk", QueryEnvId, "flows", "detail", string], never> | undefined;
|
|
23
|
+
} & {
|
|
24
|
+
queryKey: import("@tanstack/react-query").DataTag<readonly ["rise-apps-sdk", QueryEnvId, "flows", "detail", string], Flow>;
|
|
25
|
+
};
|
|
26
|
+
config: (flowId: string) => import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<FlowConfig, Error, FlowConfig, readonly ["rise-apps-sdk", QueryEnvId, "flows", "config", string]>, "queryFn"> & {
|
|
27
|
+
queryFn?: import("@tanstack/react-query").QueryFunction<FlowConfig, readonly ["rise-apps-sdk", QueryEnvId, "flows", "config", string], never> | undefined;
|
|
28
|
+
} & {
|
|
29
|
+
queryKey: import("@tanstack/react-query").DataTag<readonly ["rise-apps-sdk", QueryEnvId, "flows", "config", string], FlowConfig>;
|
|
30
|
+
};
|
|
31
|
+
layout: (layoutId: string) => import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<Layout, Error, Layout, readonly ["rise-apps-sdk", QueryEnvId, "flows", "layout", string]>, "queryFn"> & {
|
|
32
|
+
queryFn?: import("@tanstack/react-query").QueryFunction<Layout, readonly ["rise-apps-sdk", QueryEnvId, "flows", "layout", string], never> | undefined;
|
|
33
|
+
} & {
|
|
34
|
+
queryKey: import("@tanstack/react-query").DataTag<readonly ["rise-apps-sdk", QueryEnvId, "flows", "layout", string], Layout>;
|
|
35
|
+
};
|
|
36
|
+
task: (args: FindTaskQueryArgs) => import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<FindTaskResult | null, Error, FindTaskResult | null, readonly ["rise-apps-sdk", QueryEnvId, "flows", "task", {
|
|
37
|
+
[x: string]: unknown;
|
|
38
|
+
}]>, "queryFn"> & {
|
|
39
|
+
queryFn?: import("@tanstack/react-query").QueryFunction<FindTaskResult | null, readonly ["rise-apps-sdk", QueryEnvId, "flows", "task", {
|
|
40
|
+
[x: string]: unknown;
|
|
41
|
+
}], never> | undefined;
|
|
42
|
+
} & {
|
|
43
|
+
queryKey: import("@tanstack/react-query").DataTag<readonly ["rise-apps-sdk", QueryEnvId, "flows", "task", {
|
|
44
|
+
[x: string]: unknown;
|
|
45
|
+
}], FindTaskResult | null>;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
export type FlowQueries = ReturnType<typeof createFlowQueries>;
|
|
49
|
+
export declare const flowQueries: FlowQueries;
|
|
50
|
+
export declare function useFlows(args?: ListFlowsQueryArgs, options?: SdkQueryOptions): UseQueryResult<FlowSummary[], ConnectorError>;
|
|
51
|
+
export declare function useFlow(flowId: string, options?: SdkQueryOptions): UseQueryResult<Flow, ConnectorError>;
|
|
52
|
+
export declare function useFlowConfig(flowId: string, options?: SdkQueryOptions): UseQueryResult<FlowConfig, ConnectorError>;
|
|
53
|
+
export declare function useFlowLayout(layoutId: string, options?: SdkQueryOptions): UseQueryResult<Layout, ConnectorError>;
|
|
54
|
+
export declare function useFlowTask(args: FindTaskQueryArgs, options?: SdkQueryOptions): UseQueryResult<FindTaskResult | null, ConnectorError>;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.flowQueries = void 0;
|
|
4
|
+
exports.createFlowQueries = createFlowQueries;
|
|
5
|
+
exports.useFlows = useFlows;
|
|
6
|
+
exports.useFlow = useFlow;
|
|
7
|
+
exports.useFlowConfig = useFlowConfig;
|
|
8
|
+
exports.useFlowLayout = useFlowLayout;
|
|
9
|
+
exports.useFlowTask = useFlowTask;
|
|
10
|
+
// Flows domain: queryOptions factories + hooks. Flows are read-only — no
|
|
11
|
+
// mutations here.
|
|
12
|
+
const react_query_1 = require("@tanstack/react-query");
|
|
13
|
+
const flows_1 = require("../connectors/flows");
|
|
14
|
+
const keys_1 = require("./keys");
|
|
15
|
+
const shared_1 = require("./shared");
|
|
16
|
+
// queryOptions factories over the flows connector. Every factory reads the
|
|
17
|
+
// environment id at call time (the hooks re-render on env switch, so keys
|
|
18
|
+
// recompute) and disables itself until the shell reports an environment.
|
|
19
|
+
function createFlowQueries(connector, getEnvId) {
|
|
20
|
+
return {
|
|
21
|
+
list: (args = {}) => {
|
|
22
|
+
const envId = getEnvId();
|
|
23
|
+
return (0, react_query_1.queryOptions)({
|
|
24
|
+
queryKey: keys_1.queryKeys.flows.list(envId, (0, keys_1.normalizeArgs)(args)),
|
|
25
|
+
queryFn: ({ signal }) => connector.list({ ...args, signal }),
|
|
26
|
+
enabled: envId != null,
|
|
27
|
+
});
|
|
28
|
+
},
|
|
29
|
+
detail: (flowId) => {
|
|
30
|
+
const envId = getEnvId();
|
|
31
|
+
return (0, react_query_1.queryOptions)({
|
|
32
|
+
queryKey: keys_1.queryKeys.flows.detail(envId, flowId),
|
|
33
|
+
queryFn: ({ signal }) => connector.get(flowId, { signal }),
|
|
34
|
+
enabled: envId != null && !!flowId,
|
|
35
|
+
});
|
|
36
|
+
},
|
|
37
|
+
config: (flowId) => {
|
|
38
|
+
const envId = getEnvId();
|
|
39
|
+
return (0, react_query_1.queryOptions)({
|
|
40
|
+
queryKey: keys_1.queryKeys.flows.config(envId, flowId),
|
|
41
|
+
queryFn: ({ signal }) => connector.getConfig(flowId, { signal }),
|
|
42
|
+
enabled: envId != null && !!flowId,
|
|
43
|
+
});
|
|
44
|
+
},
|
|
45
|
+
layout: (layoutId) => {
|
|
46
|
+
const envId = getEnvId();
|
|
47
|
+
return (0, react_query_1.queryOptions)({
|
|
48
|
+
queryKey: keys_1.queryKeys.flows.layout(envId, layoutId),
|
|
49
|
+
queryFn: ({ signal }) => connector.getLayout(layoutId, { signal }),
|
|
50
|
+
enabled: envId != null && !!layoutId,
|
|
51
|
+
});
|
|
52
|
+
},
|
|
53
|
+
task: (args) => {
|
|
54
|
+
const envId = getEnvId();
|
|
55
|
+
return (0, react_query_1.queryOptions)({
|
|
56
|
+
queryKey: keys_1.queryKeys.flows.task(envId, (0, keys_1.normalizeArgs)(args)),
|
|
57
|
+
queryFn: ({ signal }) => connector.findTask({ ...args, signal }),
|
|
58
|
+
enabled: envId != null && !!args.flow && !!args.task,
|
|
59
|
+
});
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
// Ready-made singleton bound to the live shell bridge — same construction
|
|
64
|
+
// createQueryLayer() uses, just against the live connector singleton.
|
|
65
|
+
exports.flowQueries = createFlowQueries(flows_1.flows, shared_1.getLiveEnvId);
|
|
66
|
+
// ---- hooks ----
|
|
67
|
+
function useFlows(args, options) {
|
|
68
|
+
return (0, shared_1.useSdkQuery)(exports.flowQueries.list(args), options);
|
|
69
|
+
}
|
|
70
|
+
function useFlow(flowId, options) {
|
|
71
|
+
return (0, shared_1.useSdkQuery)(exports.flowQueries.detail(flowId), options);
|
|
72
|
+
}
|
|
73
|
+
function useFlowConfig(flowId, options) {
|
|
74
|
+
return (0, shared_1.useSdkQuery)(exports.flowQueries.config(flowId), options);
|
|
75
|
+
}
|
|
76
|
+
function useFlowLayout(layoutId, options) {
|
|
77
|
+
return (0, shared_1.useSdkQuery)(exports.flowQueries.layout(layoutId), options);
|
|
78
|
+
}
|
|
79
|
+
function useFlowTask(args, options) {
|
|
80
|
+
return (0, shared_1.useSdkQuery)(exports.flowQueries.task(args), options);
|
|
81
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { normalizeArgs, queryKeys, QUERY_KEY_ROOT, type QueryEnvId, } from "./keys";
|
|
2
|
+
export { createAppQueryClient, getFallbackAppClient, shouldRetryConnectorError, type AppQueryClientDefaults, } from "./client";
|
|
3
|
+
export { useAppQueryClient } from "./context";
|
|
4
|
+
export { getLiveEnvId, invalidateAppSdkQueries, type SdkMutationOptions, type SdkQueryOptions, } from "./shared";
|
|
5
|
+
export { createQueryLayer, type QueryLayer } from "./layer";
|
|
6
|
+
export { createFlowQueries, flowQueries, useFlow, useFlowConfig, useFlowLayout, useFlows, useFlowTask, type FindTaskQueryArgs, type FlowQueries, type ListFlowsQueryArgs, } from "./flows";
|
|
7
|
+
export { createWorkQueries, dedupeRows, useDeleteWork, usePatchWorkData, useRelatedWork, useStartWork, useSubmitWork, useWork, useWorkAudit, useWorkData, useWorkRows, workQueries, type DeleteWorkVariables, type ListRelatedWorkQueryArgs, type ListWorkRowsQueryArgs, type PatchWorkDataVariables, type StartWorkVariables, type SubmitWorkVariables, type WorkQueries, } from "./work";
|
|
8
|
+
export { assetQueries, createAssetQueries, useAsset, useAssetRows, useAssetSearch, useAssetTypes, useCloneAsset, useCreateAsset, useDeleteAsset, useRelatedAssets, useStartEditAsset, type AssetQueries, type CloneAssetVariables, type CreateAssetVariables, type DeleteAssetVariables, type ListAssetRowsQueryArgs, type ListRelatedAssetsQueryArgs, type SearchAssetsQueryArgs, type StartEditAssetVariables, } from "./assets";
|
|
9
|
+
export { agentQueries, createAgentQueries, useAgent, useAgentChat, useAgentChatMessages, useAgentChats, useAgents, useCreateAgent, useDeleteAgent, useDeleteAgentChat, useRenameAgentChat, useUpdateAgent, type AgentQueries, type DeleteAgentChatVariables, type DeleteAgentVariables, type GetChatMessagesQueryArgs, type ListAgentsQueryArgs, type ListChatsQueryArgs, type RenameAgentChatVariables, type UpdateAgentVariables, } from "./agents";
|
|
10
|
+
export { ConnectorError, type ConnectorErrorCode } from "../connectors/errors";
|