@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.
Files changed (185) hide show
  1. package/LICENSE +1 -0
  2. package/README.md +553 -0
  3. package/build/_internal.d.ts +2 -0
  4. package/build/_internal.js +23 -0
  5. package/build/accessors.d.ts +8 -0
  6. package/build/accessors.js +40 -0
  7. package/build/cli/index.d.ts +13 -0
  8. package/build/cli/index.js +54 -0
  9. package/build/cli/init.d.ts +6 -0
  10. package/build/cli/init.js +179 -0
  11. package/build/cli/templating.d.ts +2 -0
  12. package/build/cli/templating.js +84 -0
  13. package/build/connectors/agents.d.ts +85 -0
  14. package/build/connectors/agents.js +404 -0
  15. package/build/connectors/assets.d.ts +76 -0
  16. package/build/connectors/assets.js +204 -0
  17. package/build/connectors/deps.d.ts +4 -0
  18. package/build/connectors/deps.js +2 -0
  19. package/build/connectors/errors.d.ts +11 -0
  20. package/build/connectors/errors.js +67 -0
  21. package/build/connectors/flows.d.ts +37 -0
  22. package/build/connectors/flows.js +191 -0
  23. package/build/connectors/index.d.ts +8 -0
  24. package/build/connectors/index.js +50 -0
  25. package/build/connectors/sse.d.ts +12 -0
  26. package/build/connectors/sse.js +157 -0
  27. package/build/connectors/types.d.ts +285 -0
  28. package/build/connectors/types.js +419 -0
  29. package/build/connectors/work.d.ts +84 -0
  30. package/build/connectors/work.js +224 -0
  31. package/build/hooks.d.ts +4 -0
  32. package/build/hooks.js +28 -0
  33. package/build/index.d.ts +6 -0
  34. package/build/index.js +34 -0
  35. package/build/lifecycle.d.ts +23 -0
  36. package/build/lifecycle.js +6 -0
  37. package/build/mockShell.d.ts +10 -0
  38. package/build/mockShell.js +55 -0
  39. package/build/query/agents.d.ts +80 -0
  40. package/build/query/agents.js +143 -0
  41. package/build/query/assets.d.ts +73 -0
  42. package/build/query/assets.js +152 -0
  43. package/build/query/client.d.ts +5 -0
  44. package/build/query/client.js +68 -0
  45. package/build/query/context.d.ts +2 -0
  46. package/build/query/context.js +34 -0
  47. package/build/query/flows.d.ts +54 -0
  48. package/build/query/flows.js +81 -0
  49. package/build/query/index.d.ts +10 -0
  50. package/build/query/index.js +85 -0
  51. package/build/query/keys.d.ts +51 -0
  52. package/build/query/keys.js +79 -0
  53. package/build/query/layer.d.ts +175 -0
  54. package/build/query/layer.js +35 -0
  55. package/build/query/shared.d.ts +43 -0
  56. package/build/query/shared.js +116 -0
  57. package/build/query/work.d.ts +75 -0
  58. package/build/query/work.js +172 -0
  59. package/build/shell/index.d.ts +1 -0
  60. package/build/shell/index.js +6 -0
  61. package/build/shell/installShellBridge.d.ts +11 -0
  62. package/build/shell/installShellBridge.js +104 -0
  63. package/build/shellBridge.d.ts +36 -0
  64. package/build/shellBridge.js +10 -0
  65. package/build/topBar.d.ts +25 -0
  66. package/build/topBar.js +17 -0
  67. package/build/ui/components/ai.d.ts +49 -0
  68. package/build/ui/components/alert-dialog.d.ts +27 -0
  69. package/build/ui/components/alert.d.ts +14 -0
  70. package/build/ui/components/avatar.d.ts +17 -0
  71. package/build/ui/components/badge.d.ts +19 -0
  72. package/build/ui/components/button.d.ts +13 -0
  73. package/build/ui/components/calendar.d.ts +21 -0
  74. package/build/ui/components/card.d.ts +16 -0
  75. package/build/ui/components/chart.d.ts +124 -0
  76. package/build/ui/components/checkbox.d.ts +4 -0
  77. package/build/ui/components/data-table.d.ts +70 -0
  78. package/build/ui/components/dialog.d.ts +17 -0
  79. package/build/ui/components/dropdown-menu.d.ts +29 -0
  80. package/build/ui/components/empty-state.d.ts +7 -0
  81. package/build/ui/components/file-upload.d.ts +17 -0
  82. package/build/ui/components/input.d.ts +8 -0
  83. package/build/ui/components/label.d.ts +4 -0
  84. package/build/ui/components/list.d.ts +24 -0
  85. package/build/ui/components/map.d.ts +26 -0
  86. package/build/ui/components/message.d.ts +24 -0
  87. package/build/ui/components/nav.d.ts +12 -0
  88. package/build/ui/components/page-header.d.ts +27 -0
  89. package/build/ui/components/popover.d.ts +10 -0
  90. package/build/ui/components/progress.d.ts +4 -0
  91. package/build/ui/components/radio.d.ts +6 -0
  92. package/build/ui/components/resizable.d.ts +7 -0
  93. package/build/ui/components/scroll-area.d.ts +5 -0
  94. package/build/ui/components/segmented.d.ts +6 -0
  95. package/build/ui/components/select.d.ts +15 -0
  96. package/build/ui/components/separator.d.ts +4 -0
  97. package/build/ui/components/sheet.d.ts +14 -0
  98. package/build/ui/components/skeleton.d.ts +3 -0
  99. package/build/ui/components/slider.d.ts +15 -0
  100. package/build/ui/components/snackbar.d.ts +3 -0
  101. package/build/ui/components/sonner.d.ts +4 -0
  102. package/build/ui/components/spinner.d.ts +5 -0
  103. package/build/ui/components/statistic.d.ts +19 -0
  104. package/build/ui/components/stepper.d.ts +12 -0
  105. package/build/ui/components/switch.d.ts +6 -0
  106. package/build/ui/components/table.d.ts +24 -0
  107. package/build/ui/components/textarea.d.ts +3 -0
  108. package/build/ui/components/timeline.d.ts +15 -0
  109. package/build/ui/components/toggle-group.d.ts +10 -0
  110. package/build/ui/components/toggle.d.ts +9 -0
  111. package/build/ui/components/tooltip.d.ts +7 -0
  112. package/build/ui/index.d.ts +46 -0
  113. package/build/ui/index.js +8 -0
  114. package/build/ui/lib/utils.d.ts +2 -0
  115. package/build/ui/reference/README.md +11 -0
  116. package/build/ui/reference/components/ai.tsx +291 -0
  117. package/build/ui/reference/components/alert-dialog.tsx +208 -0
  118. package/build/ui/reference/components/alert.tsx +112 -0
  119. package/build/ui/reference/components/avatar.tsx +158 -0
  120. package/build/ui/reference/components/badge.tsx +160 -0
  121. package/build/ui/reference/components/button.tsx +100 -0
  122. package/build/ui/reference/components/calendar.tsx +119 -0
  123. package/build/ui/reference/components/card.tsx +144 -0
  124. package/build/ui/reference/components/chart.tsx +1394 -0
  125. package/build/ui/reference/components/checkbox.tsx +44 -0
  126. package/build/ui/reference/components/data-table.tsx +480 -0
  127. package/build/ui/reference/components/dialog.tsx +172 -0
  128. package/build/ui/reference/components/dropdown-menu.tsx +245 -0
  129. package/build/ui/reference/components/empty-state.tsx +63 -0
  130. package/build/ui/reference/components/file-upload.tsx +116 -0
  131. package/build/ui/reference/components/input.tsx +114 -0
  132. package/build/ui/reference/components/label.tsx +19 -0
  133. package/build/ui/reference/components/list.tsx +191 -0
  134. package/build/ui/reference/components/map.css +251 -0
  135. package/build/ui/reference/components/map.tsx +294 -0
  136. package/build/ui/reference/components/message.tsx +171 -0
  137. package/build/ui/reference/components/nav.tsx +113 -0
  138. package/build/ui/reference/components/page-header.tsx +213 -0
  139. package/build/ui/reference/components/popover.tsx +76 -0
  140. package/build/ui/reference/components/progress.tsx +31 -0
  141. package/build/ui/reference/components/radio.tsx +65 -0
  142. package/build/ui/reference/components/resizable.tsx +40 -0
  143. package/build/ui/reference/components/scroll-area.tsx +55 -0
  144. package/build/ui/reference/components/segmented.tsx +45 -0
  145. package/build/ui/reference/components/select.tsx +185 -0
  146. package/build/ui/reference/components/separator.tsx +26 -0
  147. package/build/ui/reference/components/sheet.tsx +173 -0
  148. package/build/ui/reference/components/skeleton.tsx +15 -0
  149. package/build/ui/reference/components/slider.tsx +161 -0
  150. package/build/ui/reference/components/snackbar.tsx +27 -0
  151. package/build/ui/reference/components/sonner.tsx +43 -0
  152. package/build/ui/reference/components/spinner.tsx +27 -0
  153. package/build/ui/reference/components/statistic.tsx +122 -0
  154. package/build/ui/reference/components/stepper.tsx +138 -0
  155. package/build/ui/reference/components/switch.tsx +47 -0
  156. package/build/ui/reference/components/table.tsx +233 -0
  157. package/build/ui/reference/components/textarea.tsx +28 -0
  158. package/build/ui/reference/components/timeline.tsx +94 -0
  159. package/build/ui/reference/components/toggle-group.tsx +86 -0
  160. package/build/ui/reference/components/toggle.tsx +46 -0
  161. package/build/ui/reference/components/tooltip.tsx +53 -0
  162. package/build/ui/reference/index.ts +49 -0
  163. package/build/ui/reference/lib/utils.ts +34 -0
  164. package/build/ui/standalone-stub.js +5 -0
  165. package/build/ui/standalone.js +135 -0
  166. package/build/ui/styles.css +3 -0
  167. package/connectors/package.json +8 -0
  168. package/package.json +114 -0
  169. package/query/package.json +8 -0
  170. package/shell/package.json +8 -0
  171. package/template/AGENTS.md +70 -0
  172. package/template/CLAUDE.md +4 -0
  173. package/template/README.md +102 -0
  174. package/template/_gitignore +6 -0
  175. package/template/commitlint.config.js +12 -0
  176. package/template/package.json +31 -0
  177. package/template/public/index.html +13 -0
  178. package/template/src/App.tsx +171 -0
  179. package/template/src/bootstrap.tsx +13 -0
  180. package/template/src/index.tsx +1 -0
  181. package/template/src/lifecycle.ts +20 -0
  182. package/template/tsconfig.json +31 -0
  183. package/template/webpack.config.js +112 -0
  184. package/template/webpack.local.config.js +68 -0
  185. package/ui/package.json +8 -0
@@ -0,0 +1,84 @@
1
+ import type { ConnectorDeps } from "./deps";
2
+ import { type WorkAuditEvent, type WorkDetail, type WorkRow } from "./types";
3
+ export interface StartWorkArgs {
4
+ flowId: string;
5
+ stepName?: string;
6
+ data?: Record<string, unknown>;
7
+ signal?: AbortSignal;
8
+ }
9
+ export interface SubmitWorkArgs {
10
+ workId: string;
11
+ actionName: string;
12
+ stepName?: string;
13
+ signal?: AbortSignal;
14
+ }
15
+ export type WorkPatchOperation = "Set" | "Push" | "Pull" | "Unset" | "AddToSet" | "Merge";
16
+ export interface WorkDataPatch {
17
+ originId: string;
18
+ path: string;
19
+ value?: unknown;
20
+ operation?: WorkPatchOperation;
21
+ position?: number;
22
+ sectionId?: string;
23
+ signal?: AbortSignal;
24
+ }
25
+ export type FlowRef = string | {
26
+ id: string;
27
+ flowOriginId?: string;
28
+ };
29
+ export interface ListWorkRowsArgs {
30
+ flow: FlowRef;
31
+ stepIds?: string[];
32
+ properties?: Record<string, string>;
33
+ showCompleted?: boolean;
34
+ sort?: {
35
+ field: string;
36
+ direction: "asc" | "desc";
37
+ };
38
+ pageSize?: number;
39
+ skip?: number;
40
+ signal?: AbortSignal;
41
+ }
42
+ export interface WorkRowPage {
43
+ items: WorkRow[];
44
+ skip: number;
45
+ pageSize: number;
46
+ hasMore: boolean;
47
+ }
48
+ export interface IterateWorkRowsArgs extends Omit<ListWorkRowsArgs, "skip"> {
49
+ maxItems?: number;
50
+ }
51
+ export interface ListRelatedWorkArgs {
52
+ workId: string;
53
+ relationships: string[];
54
+ properties?: Record<string, string>;
55
+ targetDataType?: number;
56
+ skip?: number;
57
+ limit?: number;
58
+ signal?: AbortSignal;
59
+ }
60
+ export interface WorkConnector {
61
+ start(args: StartWorkArgs): Promise<WorkDetail>;
62
+ get(workId: string, opts?: {
63
+ signal?: AbortSignal;
64
+ }): Promise<WorkDetail>;
65
+ getData(workId: string, opts?: {
66
+ path?: string;
67
+ signal?: AbortSignal;
68
+ }): Promise<unknown>;
69
+ patchData(workId: string, patch: WorkDataPatch): Promise<unknown>;
70
+ submit(args: SubmitWorkArgs): Promise<WorkDetail>;
71
+ delete(workId: string, opts?: {
72
+ signal?: AbortSignal;
73
+ }): Promise<void>;
74
+ list(args: ListWorkRowsArgs): Promise<WorkRowPage>;
75
+ iterate(args: IterateWorkRowsArgs): AsyncIterable<WorkRow>;
76
+ listRelated(args: ListRelatedWorkArgs): Promise<WorkRow[]>;
77
+ getAudit(workId: string, opts?: {
78
+ signal?: AbortSignal;
79
+ }): Promise<WorkAuditEvent[]>;
80
+ }
81
+ export declare const resolveFlowRef: (flow: FlowRef | null | undefined) => string;
82
+ export declare function buildAdditionalProperties(properties?: Record<string, string>): unknown[];
83
+ export declare function createWorkConnector(deps?: ConnectorDeps): WorkConnector;
84
+ export declare const work: WorkConnector;
@@ -0,0 +1,224 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.work = exports.resolveFlowRef = void 0;
4
+ exports.buildAdditionalProperties = buildAdditionalProperties;
5
+ exports.createWorkConnector = createWorkConnector;
6
+ const _internal_1 = require("../_internal");
7
+ const errors_1 = require("./errors");
8
+ const types_1 = require("./types");
9
+ // Wire codes of the platform's PatchOperation enum.
10
+ const PATCH_OPERATION_CODES = {
11
+ Push: 0,
12
+ Set: 1,
13
+ Pull: 3,
14
+ Unset: 4,
15
+ AddToSet: 5,
16
+ Merge: 7,
17
+ };
18
+ // Wire code of the platform's ResourceType enum for work items.
19
+ const RESOURCE_TYPE_WORK = 2;
20
+ const DEFAULT_PAGE_SIZE = 50;
21
+ // Exported so the query layer's cache keys can resolve a FlowRef the same
22
+ // way the request body does (see query/work.ts) — an object ref and its bare
23
+ // origin-id string must key identically.
24
+ const resolveFlowRef = (flow) => typeof flow === "string" ? flow : flow ? flow.flowOriginId || flow.id : "";
25
+ exports.resolveFlowRef = resolveFlowRef;
26
+ // Expand a `key → JSON path` map into the data-grid `additionalProperties`
27
+ // entries the server expects (the boilerplate every app hand-rolled so far).
28
+ // Shared with the assets connector — the asset-rows grid speaks the same dialect.
29
+ function buildAdditionalProperties(properties) {
30
+ return Object.entries(properties ?? {}).map(([key, path]) => ({
31
+ key,
32
+ displayName: key,
33
+ displayNamePath: null,
34
+ valuePath: path,
35
+ valuePaths: [path],
36
+ dataPath: path,
37
+ isExpandedProperty: false,
38
+ }));
39
+ }
40
+ function createWorkConnector(deps = { shell: _internal_1.requireShell }) {
41
+ const workApi = () => deps.shell().getApiV4("work");
42
+ // start/submit go through the v3 flow engine — the same endpoints the shell
43
+ // uses. The v4 `work/submit/*` routes only ever existed on the unreleased
44
+ // flow-engine branch and 404 on deployed APIs.
45
+ const start = async (args) => {
46
+ try {
47
+ const { data } = await deps
48
+ .shell()
49
+ .getApi()
50
+ .post(`/api/v3/flow/${args.flowId}/startAt`, args.data ?? {}, { params: { stepName: args.stepName }, signal: args.signal });
51
+ return (0, types_1.mapWorkDetail)(data ?? {});
52
+ }
53
+ catch (e) {
54
+ throw (0, errors_1.toConnectorError)(e);
55
+ }
56
+ };
57
+ const get = async (workId, opts = {}) => {
58
+ try {
59
+ const { data } = await workApi().get(`/api/v4/work/${workId}`, {
60
+ signal: opts.signal,
61
+ });
62
+ return (0, types_1.mapWorkDetail)(data ?? {});
63
+ }
64
+ catch (e) {
65
+ throw (0, errors_1.toConnectorError)(e);
66
+ }
67
+ };
68
+ const getData = async (workId, opts = {}) => {
69
+ try {
70
+ const { data } = await workApi().get(`/api/v4/work/${workId}/data`, {
71
+ params: { path: opts.path },
72
+ signal: opts.signal,
73
+ });
74
+ return data;
75
+ }
76
+ catch (e) {
77
+ throw (0, errors_1.toConnectorError)(e);
78
+ }
79
+ };
80
+ const patchData = async (workId, patch) => {
81
+ try {
82
+ const { data } = await workApi().patch(`/api/v4/work/${workId}/data`, {
83
+ resourceId: workId,
84
+ resourceType: RESOURCE_TYPE_WORK,
85
+ originId: patch.originId,
86
+ path: patch.path,
87
+ value: patch.value,
88
+ operation: PATCH_OPERATION_CODES[patch.operation ?? "Set"],
89
+ position: patch.position,
90
+ sectionId: patch.sectionId,
91
+ }, { signal: patch.signal });
92
+ return data;
93
+ }
94
+ catch (e) {
95
+ throw (0, errors_1.toConnectorError)(e);
96
+ }
97
+ };
98
+ const submit = async (args) => {
99
+ try {
100
+ const { data } = await deps
101
+ .shell()
102
+ .getApi()
103
+ .post(`/api/v3/flow/submit/${args.workId}`, { stepName: args.stepName }, { params: { eventName: args.actionName }, signal: args.signal });
104
+ return (0, types_1.mapWorkDetail)(data ?? {});
105
+ }
106
+ catch (e) {
107
+ throw (0, errors_1.toConnectorError)(e);
108
+ }
109
+ };
110
+ const del = async (workId, opts = {}) => {
111
+ try {
112
+ await workApi().delete(`/api/v4/work/${workId}`, { signal: opts.signal });
113
+ }
114
+ catch (e) {
115
+ throw (0, errors_1.toConnectorError)(e);
116
+ }
117
+ };
118
+ const list = async (args) => {
119
+ try {
120
+ const skip = args.skip ?? 0;
121
+ const pageSize = args.pageSize ?? DEFAULT_PAGE_SIZE;
122
+ const { data } = await deps
123
+ .shell()
124
+ .getApi()
125
+ .post("/api/v3/data-grid/work-rows", {
126
+ filterProperties: [],
127
+ flowOriginIds: [(0, exports.resolveFlowRef)(args.flow)],
128
+ workIds: [],
129
+ additionalProperties: buildAdditionalProperties(args.properties),
130
+ customViewQueries: [],
131
+ isExpandedFeatureEnabled: false,
132
+ showCompleted: args.showCompleted ?? true,
133
+ showInProgress: true,
134
+ skip,
135
+ limit: pageSize,
136
+ sortField: args.sort?.field ?? "createdDate",
137
+ sortDirection: args.sort?.direction ?? "desc",
138
+ activeStepIds: args.stepIds ?? [],
139
+ }, { signal: args.signal });
140
+ const items = (Array.isArray(data) ? data : []).map(types_1.mapWorkRow);
141
+ return { items, skip, pageSize, hasMore: items.length === pageSize };
142
+ }
143
+ catch (e) {
144
+ throw (0, errors_1.toConnectorError)(e);
145
+ }
146
+ };
147
+ const iterate = async function* (args) {
148
+ const pageSize = args.pageSize ?? DEFAULT_PAGE_SIZE;
149
+ const seen = new Set();
150
+ let skip = 0;
151
+ let yielded = 0;
152
+ for (;;) {
153
+ if (args.signal?.aborted) {
154
+ throw new errors_1.ConnectorError("ABORTED", "work iteration aborted");
155
+ }
156
+ const page = await list({ ...args, skip, pageSize });
157
+ let newInPage = 0;
158
+ for (const row of page.items) {
159
+ // Sort-shifted pages can repeat rows; ids are stable, dedupe on them.
160
+ if (seen.has(row.id))
161
+ continue;
162
+ seen.add(row.id);
163
+ newInPage += 1;
164
+ yield row;
165
+ yielded += 1;
166
+ if (args.maxItems !== undefined && yielded >= args.maxItems)
167
+ return;
168
+ }
169
+ // A full page of nothing-but-duplicates means we're not making progress
170
+ // (server repeating rows) — bail rather than loop forever.
171
+ if (!page.hasMore || newInPage === 0)
172
+ return;
173
+ // Advance by net-new rows, not pageSize: when rows shift up between
174
+ // pages (delete / sort-field change) a full-page skip overshoots and
175
+ // silently drops the row that moved into the gap.
176
+ skip += newInPage;
177
+ }
178
+ };
179
+ const listRelated = async (args) => {
180
+ try {
181
+ const { data } = await deps
182
+ .shell()
183
+ .getApi()
184
+ .post("/api/v3/data-grid/related-works", {
185
+ sourceId: args.workId,
186
+ targetDataType: args.targetDataType ?? 2,
187
+ relationshipNames: args.relationships,
188
+ filterProperties: [],
189
+ additionalProperties: buildAdditionalProperties(args.properties),
190
+ skip: args.skip ?? 0,
191
+ limit: args.limit ?? DEFAULT_PAGE_SIZE,
192
+ }, { signal: args.signal });
193
+ return (Array.isArray(data) ? data : []).map(types_1.mapWorkRow);
194
+ }
195
+ catch (e) {
196
+ throw (0, errors_1.toConnectorError)(e);
197
+ }
198
+ };
199
+ const getAudit = async (workId, opts = {}) => {
200
+ try {
201
+ const { data } = await workApi().get(`/api/v4/work/${workId}/audit`, {
202
+ signal: opts.signal,
203
+ });
204
+ return (Array.isArray(data) ? data : []).map(types_1.mapWorkAuditEvent);
205
+ }
206
+ catch (e) {
207
+ throw (0, errors_1.toConnectorError)(e);
208
+ }
209
+ };
210
+ return {
211
+ start,
212
+ get,
213
+ getData,
214
+ patchData,
215
+ submit,
216
+ delete: del,
217
+ list,
218
+ iterate,
219
+ listRelated,
220
+ getAudit,
221
+ };
222
+ }
223
+ // Ready-made singleton bound to the live shell bridge.
224
+ exports.work = createWorkConnector();
@@ -0,0 +1,4 @@
1
+ import type { ShellEnvironment, ShellNavigate, ShellUser } from './shellBridge';
2
+ export declare function useShellUser(): ShellUser | null;
3
+ export declare function useShellEnvironment(): ShellEnvironment | null;
4
+ export declare function useShellNavigate(): ShellNavigate;
package/build/hooks.js ADDED
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useShellUser = useShellUser;
4
+ exports.useShellEnvironment = useShellEnvironment;
5
+ exports.useShellNavigate = useShellNavigate;
6
+ const react_1 = require("react");
7
+ const _internal_1 = require("./_internal");
8
+ function useShellUser() {
9
+ const shell = (0, _internal_1.requireShell)();
10
+ const [user, setUser] = (0, react_1.useState)(() => shell.getUser());
11
+ (0, react_1.useEffect)(() => {
12
+ const unsubscribe = shell.subscribeUser(setUser);
13
+ return unsubscribe;
14
+ }, [shell]);
15
+ return user;
16
+ }
17
+ function useShellEnvironment() {
18
+ const shell = (0, _internal_1.requireShell)();
19
+ const [env, setEnv] = (0, react_1.useState)(() => shell.getEnvironment());
20
+ (0, react_1.useEffect)(() => {
21
+ const unsubscribe = shell.subscribeEnvironment(setEnv);
22
+ return unsubscribe;
23
+ }, [shell]);
24
+ return env;
25
+ }
26
+ function useShellNavigate() {
27
+ return (0, _internal_1.requireShell)().navigate;
28
+ }
@@ -0,0 +1,6 @@
1
+ export * from "./shellBridge";
2
+ export * from "./lifecycle";
3
+ export { useShellUser, useShellEnvironment, useShellNavigate } from "./hooks";
4
+ export { getShell, getShellAi, getShellApi, getShellApiV4, getShellEnvironment, getShellUser, } from "./accessors";
5
+ export { createMockShell, type CreateMockShellOptions } from "./mockShell";
6
+ export { registerTopBarActions, type TopBarAction } from "./topBar";
package/build/index.js ADDED
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.registerTopBarActions = exports.createMockShell = exports.getShellUser = exports.getShellEnvironment = exports.getShellApiV4 = exports.getShellApi = exports.getShellAi = exports.getShell = exports.useShellNavigate = exports.useShellEnvironment = exports.useShellUser = void 0;
18
+ __exportStar(require("./shellBridge"), exports);
19
+ __exportStar(require("./lifecycle"), exports);
20
+ var hooks_1 = require("./hooks");
21
+ Object.defineProperty(exports, "useShellUser", { enumerable: true, get: function () { return hooks_1.useShellUser; } });
22
+ Object.defineProperty(exports, "useShellEnvironment", { enumerable: true, get: function () { return hooks_1.useShellEnvironment; } });
23
+ Object.defineProperty(exports, "useShellNavigate", { enumerable: true, get: function () { return hooks_1.useShellNavigate; } });
24
+ var accessors_1 = require("./accessors");
25
+ Object.defineProperty(exports, "getShell", { enumerable: true, get: function () { return accessors_1.getShell; } });
26
+ Object.defineProperty(exports, "getShellAi", { enumerable: true, get: function () { return accessors_1.getShellAi; } });
27
+ Object.defineProperty(exports, "getShellApi", { enumerable: true, get: function () { return accessors_1.getShellApi; } });
28
+ Object.defineProperty(exports, "getShellApiV4", { enumerable: true, get: function () { return accessors_1.getShellApiV4; } });
29
+ Object.defineProperty(exports, "getShellEnvironment", { enumerable: true, get: function () { return accessors_1.getShellEnvironment; } });
30
+ Object.defineProperty(exports, "getShellUser", { enumerable: true, get: function () { return accessors_1.getShellUser; } });
31
+ var mockShell_1 = require("./mockShell");
32
+ Object.defineProperty(exports, "createMockShell", { enumerable: true, get: function () { return mockShell_1.createMockShell; } });
33
+ var topBar_1 = require("./topBar");
34
+ Object.defineProperty(exports, "registerTopBarActions", { enumerable: true, get: function () { return topBar_1.registerTopBarActions; } });
@@ -0,0 +1,23 @@
1
+ import type { ShellEnvironment, ShellUser } from './shellBridge';
2
+ export declare const LIFECYCLE_MODULE_NAME = "./lifecycle";
3
+ export interface AppManifestSnapshot {
4
+ id: string;
5
+ version: string;
6
+ name: string;
7
+ }
8
+ export interface LifecycleContext {
9
+ manifest: AppManifestSnapshot;
10
+ user: ShellUser | null;
11
+ environment: ShellEnvironment | null;
12
+ }
13
+ export type InstallHook = (ctx: LifecycleContext) => void | Promise<void>;
14
+ export type UninstallHook = (ctx: LifecycleContext) => void | Promise<void>;
15
+ export type UpdateHook = (ctx: LifecycleContext, change: {
16
+ from: string;
17
+ to: string;
18
+ }) => void | Promise<void>;
19
+ export interface LifecycleModule {
20
+ onInstall?: InstallHook;
21
+ onUninstall?: UninstallHook;
22
+ onUpdate?: UpdateHook;
23
+ }
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LIFECYCLE_MODULE_NAME = void 0;
4
+ // The Module Federation path an app exposes to ship lifecycle hooks.
5
+ // Shell and apps must agree on this string — the SDK owns it.
6
+ exports.LIFECYCLE_MODULE_NAME = './lifecycle';
@@ -0,0 +1,10 @@
1
+ import type { DianaShell, ShellAiApi, ShellEnvironment, ShellUser } from "./shellBridge";
2
+ export interface CreateMockShellOptions {
3
+ user?: ShellUser | null;
4
+ environment?: ShellEnvironment | null;
5
+ api?: DianaShell["getApi"];
6
+ apiV4?: DianaShell["getApiV4"];
7
+ ai?: ShellAiApi | null;
8
+ }
9
+ export declare function createMockShell(overrides?: CreateMockShellOptions): DianaShell;
10
+ export declare function isMockShell(shell: DianaShell): boolean;
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createMockShell = createMockShell;
4
+ exports.isMockShell = isMockShell;
5
+ const errors_1 = require("./connectors/errors");
6
+ const shellBridge_1 = require("./shellBridge");
7
+ // Mock shell for standalone dev bundles. getApi/getApiV4 throw unless handlers
8
+ // are passed via options — apps that need a backend either run inside the real
9
+ // shell or supply their own instances. Navigate falls back to window.location.
10
+ function createMockShell(overrides = {}) {
11
+ const { user = { id: "standalone", name: "Standalone Dev" }, environment = { id: "dev", slug: "dev", name: "Standalone Dev Env" }, ai = null, } = overrides;
12
+ // Both getApi (no arg) and getApiV4 (V4ApiKey arg) need a thrower; we cast the
13
+ // returned function to whichever signature DianaShell expects at the callsite.
14
+ const notAvailable = (which) => () => {
15
+ // ConnectorError so connectors surface this as SHELL_UNAVAILABLE
16
+ // (not NETWORK_ERROR) when the mock has no backend handler.
17
+ throw new errors_1.ConnectorError("SHELL_UNAVAILABLE", `[@rise-x/apps-sdk] ${which} is not available in standalone mode — ` +
18
+ `pass \`${which === "getApi" ? "api" : "apiV4"}\` to createMockShell to use a backend standalone`);
19
+ };
20
+ // Hand-rolled instead of react-router's `createPath` so the main barrel stays
21
+ // router-free — apps using the mock for standalone dev may not have
22
+ // react-router-dom installed, and we don't want to force it on them.
23
+ const navigate = ((to) => {
24
+ if (typeof to === "number") {
25
+ window.history.go(to);
26
+ return;
27
+ }
28
+ if (typeof to === "string") {
29
+ window.location.assign(to);
30
+ return;
31
+ }
32
+ const t = to;
33
+ window.location.assign(`${t?.pathname ?? ""}${t?.search ?? ""}${t?.hash ?? ""}`);
34
+ });
35
+ const shell = {
36
+ version: shellBridge_1.SHELL_BRIDGE_VERSION,
37
+ getUser: () => user,
38
+ getEnvironment: () => environment,
39
+ subscribeUser: () => () => { },
40
+ subscribeEnvironment: () => () => { },
41
+ getApi: overrides.api ?? notAvailable("getApi"),
42
+ getApiV4: overrides.apiV4 ?? notAvailable("getApiV4"),
43
+ getAi: () => ai,
44
+ navigate,
45
+ };
46
+ // Untyped marker so SDK internals (e.g. the query layer's dev diagnostics)
47
+ // can tell standalone-mock hosting from a real shell without widening the
48
+ // DianaShell contract.
49
+ Object.defineProperty(shell, MOCK_SHELL_MARKER, { value: true });
50
+ return shell;
51
+ }
52
+ const MOCK_SHELL_MARKER = "__riseMockShell";
53
+ function isMockShell(shell) {
54
+ return (shell[MOCK_SHELL_MARKER] === true);
55
+ }
@@ -0,0 +1,80 @@
1
+ import { type UseQueryResult } from "@tanstack/react-query";
2
+ import { type AgentsConnector, type GetChatMessagesArgs, type ListAgentsArgs, type ListChatsArgs } from "../connectors/agents";
3
+ import type { ConnectorError } from "../connectors/errors";
4
+ import type { AgentChat, AgentChatMessagePage, AgentChatPage, AgentCreateInput, AgentPage, AgentPatch, RiseAgent } from "../connectors/types";
5
+ import { type QueryEnvId } from "./keys";
6
+ import { type SdkMutationOptions, type SdkQueryOptions } from "./shared";
7
+ export type ListAgentsQueryArgs = Omit<ListAgentsArgs, "signal">;
8
+ export type ListChatsQueryArgs = Omit<ListChatsArgs, "signal">;
9
+ export type GetChatMessagesQueryArgs = Omit<GetChatMessagesArgs, "signal">;
10
+ export declare function createAgentQueries(connector: AgentsConnector, getEnvId: () => QueryEnvId): {
11
+ list: (args?: ListAgentsQueryArgs) => import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<AgentPage, Error, AgentPage, readonly ["rise-apps-sdk", QueryEnvId, "agents", "list", {
12
+ [x: string]: unknown;
13
+ }]>, "queryFn"> & {
14
+ queryFn?: import("@tanstack/react-query").QueryFunction<AgentPage, readonly ["rise-apps-sdk", QueryEnvId, "agents", "list", {
15
+ [x: string]: unknown;
16
+ }], never> | undefined;
17
+ } & {
18
+ queryKey: import("@tanstack/react-query").DataTag<readonly ["rise-apps-sdk", QueryEnvId, "agents", "list", {
19
+ [x: string]: unknown;
20
+ }], AgentPage>;
21
+ };
22
+ detail: (id: string) => import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<RiseAgent, Error, RiseAgent, readonly ["rise-apps-sdk", QueryEnvId, "agents", "detail", string]>, "queryFn"> & {
23
+ queryFn?: import("@tanstack/react-query").QueryFunction<RiseAgent, readonly ["rise-apps-sdk", QueryEnvId, "agents", "detail", string], never> | undefined;
24
+ } & {
25
+ queryKey: import("@tanstack/react-query").DataTag<readonly ["rise-apps-sdk", QueryEnvId, "agents", "detail", string], RiseAgent>;
26
+ };
27
+ chats: (args?: ListChatsQueryArgs) => import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<AgentChatPage, Error, AgentChatPage, readonly ["rise-apps-sdk", QueryEnvId, "agents", "chats", {
28
+ [x: string]: unknown;
29
+ }]>, "queryFn"> & {
30
+ queryFn?: import("@tanstack/react-query").QueryFunction<AgentChatPage, readonly ["rise-apps-sdk", QueryEnvId, "agents", "chats", {
31
+ [x: string]: unknown;
32
+ }], never> | undefined;
33
+ } & {
34
+ queryKey: import("@tanstack/react-query").DataTag<readonly ["rise-apps-sdk", QueryEnvId, "agents", "chats", {
35
+ [x: string]: unknown;
36
+ }], AgentChatPage>;
37
+ };
38
+ chat: (id: string) => import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<AgentChat, Error, AgentChat, readonly ["rise-apps-sdk", QueryEnvId, "agents", "chat", string]>, "queryFn"> & {
39
+ queryFn?: import("@tanstack/react-query").QueryFunction<AgentChat, readonly ["rise-apps-sdk", QueryEnvId, "agents", "chat", string], never> | undefined;
40
+ } & {
41
+ queryKey: import("@tanstack/react-query").DataTag<readonly ["rise-apps-sdk", QueryEnvId, "agents", "chat", string], AgentChat>;
42
+ };
43
+ chatMessages: (id: string, args?: GetChatMessagesQueryArgs) => import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<AgentChatMessagePage, Error, AgentChatMessagePage, readonly ["rise-apps-sdk", QueryEnvId, "agents", "chatMessages", string, {
44
+ [x: string]: unknown;
45
+ }]>, "queryFn"> & {
46
+ queryFn?: import("@tanstack/react-query").QueryFunction<AgentChatMessagePage, readonly ["rise-apps-sdk", QueryEnvId, "agents", "chatMessages", string, {
47
+ [x: string]: unknown;
48
+ }], never> | undefined;
49
+ } & {
50
+ queryKey: import("@tanstack/react-query").DataTag<readonly ["rise-apps-sdk", QueryEnvId, "agents", "chatMessages", string, {
51
+ [x: string]: unknown;
52
+ }], AgentChatMessagePage>;
53
+ };
54
+ };
55
+ export type AgentQueries = ReturnType<typeof createAgentQueries>;
56
+ export declare const agentQueries: AgentQueries;
57
+ export declare function useAgents(args?: ListAgentsQueryArgs, options?: SdkQueryOptions): UseQueryResult<AgentPage, ConnectorError>;
58
+ export declare function useAgent(id: string, options?: SdkQueryOptions): UseQueryResult<RiseAgent, ConnectorError>;
59
+ export declare function useAgentChats(args?: ListChatsQueryArgs, options?: SdkQueryOptions): UseQueryResult<AgentChatPage, ConnectorError>;
60
+ export declare function useAgentChat(id: string, options?: SdkQueryOptions): UseQueryResult<AgentChat, ConnectorError>;
61
+ export declare function useAgentChatMessages(id: string, args?: GetChatMessagesQueryArgs, options?: SdkQueryOptions): UseQueryResult<AgentChatMessagePage, ConnectorError>;
62
+ export declare function useCreateAgent(options?: SdkMutationOptions<RiseAgent, AgentCreateInput>): import("@tanstack/react-query").UseMutationResult<RiseAgent, ConnectorError, AgentCreateInput, unknown>;
63
+ export interface UpdateAgentVariables {
64
+ id: string;
65
+ patch: AgentPatch;
66
+ }
67
+ export declare function useUpdateAgent(options?: SdkMutationOptions<RiseAgent, UpdateAgentVariables>): import("@tanstack/react-query").UseMutationResult<RiseAgent, ConnectorError, UpdateAgentVariables, unknown>;
68
+ export interface DeleteAgentVariables {
69
+ id: string;
70
+ }
71
+ export declare function useDeleteAgent(options?: SdkMutationOptions<void, DeleteAgentVariables>): import("@tanstack/react-query").UseMutationResult<void, ConnectorError, DeleteAgentVariables, unknown>;
72
+ export interface RenameAgentChatVariables {
73
+ id: string;
74
+ title: string;
75
+ }
76
+ export declare function useRenameAgentChat(options?: SdkMutationOptions<AgentChat, RenameAgentChatVariables>): import("@tanstack/react-query").UseMutationResult<AgentChat, ConnectorError, RenameAgentChatVariables, unknown>;
77
+ export interface DeleteAgentChatVariables {
78
+ id: string;
79
+ }
80
+ export declare function useDeleteAgentChat(options?: SdkMutationOptions<void, DeleteAgentChatVariables>): import("@tanstack/react-query").UseMutationResult<void, ConnectorError, DeleteAgentChatVariables, unknown>;