@rise-x/apps-sdk 0.11.1 → 0.15.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/README.md +903 -19
- package/build/_internal.d.ts +4 -1
- package/build/_internal.js +67 -0
- package/build/cli/index.d.ts +7 -1
- package/build/cli/index.js +68 -14
- package/build/cli/scan.d.ts +60 -0
- package/build/cli/scan.js +725 -0
- package/build/cli/validate.d.ts +33 -0
- package/build/cli/validate.js +169 -0
- package/build/connectors/agents.d.ts +10 -6
- package/build/connectors/agents.js +59 -44
- package/build/connectors/attachments.d.ts +51 -0
- package/build/connectors/attachments.js +76 -0
- package/build/connectors/errors.js +24 -0
- package/build/connectors/flows.d.ts +13 -2
- package/build/connectors/flows.js +64 -19
- package/build/connectors/index.d.ts +5 -1
- package/build/connectors/index.js +14 -2
- package/build/connectors/integrations.d.ts +29 -0
- package/build/connectors/integrations.js +32 -0
- package/build/connectors/offline.d.ts +34 -0
- package/build/connectors/offline.js +135 -0
- package/build/connectors/readPolicy.d.ts +29 -0
- package/build/connectors/readPolicy.js +105 -0
- package/build/connectors/types.d.ts +75 -0
- package/build/connectors/types.js +128 -0
- package/build/connectors/vectorStores.d.ts +45 -0
- package/build/connectors/vectorStores.js +199 -0
- package/build/connectors/work.d.ts +14 -2
- package/build/connectors/work.js +43 -19
- package/build/dependencies/bound.d.ts +87 -0
- package/build/dependencies/bound.js +207 -0
- package/build/dependencies/index.d.ts +2 -0
- package/build/dependencies/index.js +13 -0
- package/build/dependencyRegistry.d.ts +15 -0
- package/build/dependencyRegistry.js +28 -0
- package/build/index.d.ts +2 -1
- package/build/index.js +12 -1
- package/build/lifecycle.d.ts +10 -1
- package/build/manifest.d.ts +69 -0
- package/build/manifest.js +229 -0
- package/build/manifestSource.d.ts +27 -0
- package/build/manifestSource.js +99 -0
- package/build/mockShell.d.ts +2 -0
- package/build/mockShell.js +13 -0
- package/build/query/client.js +9 -1
- package/build/query/dependencies.d.ts +22 -0
- package/build/query/dependencies.js +73 -0
- package/build/query/flows.d.ts +8 -8
- package/build/query/index.d.ts +1 -0
- package/build/query/index.js +4 -2
- package/build/query/layer.d.ts +9 -9
- package/build/query/shared.js +10 -0
- package/build/query/work.d.ts +4 -4
- package/build/rsbuild/index.d.ts +3 -1
- package/build/rsbuild/index.js +35 -1
- package/build/rsbuild/riseAppManifestPlugin.d.ts +19 -0
- package/build/rsbuild/riseAppManifestPlugin.js +79 -0
- package/build/shell/installShellBridge.d.ts +2 -0
- package/build/shell/installShellBridge.js +3 -1
- package/build/shellBridge.d.ts +233 -1
- package/build/shellBridge.js +8 -7
- package/build/ui/components/app-frame.d.ts +1 -1
- package/build/ui/demo.html +365 -360
- package/build/ui/shadcn.css +629 -0
- package/build/ui/standalone.js +16 -15
- package/build/ui/styles.css +1 -1
- package/build/ui/tailwind.css +12 -0
- package/build/ui/theme.css +412 -0
- package/build/ui/tw-animate.css +1 -0
- package/build/webpack/index.d.ts +1 -0
- package/build/webpack/index.js +7 -0
- package/build/webpack/riseAppManifestPlugin.d.ts +61 -0
- package/build/webpack/riseAppManifestPlugin.js +103 -0
- package/dependencies/package.json +8 -0
- package/package.json +17 -4
- package/template/AGENTS.md +34 -4
- package/template/README.md +85 -2
- package/template/package.json +4 -0
- package/template/rise-x-app.json +4 -0
- package/template/src/App.tsx +7 -17
- package/template/src/styles.css +5 -0
- package/webpack/package.json +8 -0
|
@@ -6,6 +6,8 @@ export interface MutableShell extends DianaShell {
|
|
|
6
6
|
}
|
|
7
7
|
export type InstallShellBridgeOptions = Pick<DianaShell, "getApi" | "getApiV4"> & {
|
|
8
8
|
getAi?: DianaShell["getAi"];
|
|
9
|
+
getOffline?: DianaShell["getOffline"];
|
|
10
|
+
getCache?: DianaShell["getCache"];
|
|
9
11
|
};
|
|
10
12
|
export declare function installShellBridge(options: InstallShellBridgeOptions): void;
|
|
11
13
|
export declare function getMutableShell(): MutableShell | null;
|
|
@@ -56,7 +56,7 @@ function isEqualEnvironment(a, b) {
|
|
|
56
56
|
function installShellBridge(options) {
|
|
57
57
|
if (window.__DIANA_SHELL__)
|
|
58
58
|
return;
|
|
59
|
-
const { getApi, getApiV4, getAi = () => null } = options;
|
|
59
|
+
const { getApi, getApiV4, getAi = () => null, getOffline = () => null, getCache = () => null, } = options;
|
|
60
60
|
let currentUser = null;
|
|
61
61
|
let currentEnvironment = null;
|
|
62
62
|
let navigate = defaultNavigate;
|
|
@@ -80,6 +80,8 @@ function installShellBridge(options) {
|
|
|
80
80
|
getApi,
|
|
81
81
|
getApiV4,
|
|
82
82
|
getAi,
|
|
83
|
+
getOffline,
|
|
84
|
+
getCache,
|
|
83
85
|
navigate: navigateShim,
|
|
84
86
|
_setUser(user) {
|
|
85
87
|
if (isEqualUser(currentUser, user))
|
package/build/shellBridge.d.ts
CHANGED
|
@@ -17,6 +17,232 @@ export interface ShellAiApi {
|
|
|
17
17
|
baseUrl: string;
|
|
18
18
|
getHeaders(): Record<string, string>;
|
|
19
19
|
}
|
|
20
|
+
export interface WorkSyncStatus {
|
|
21
|
+
/**
|
|
22
|
+
* Whether a write for this work should be queued or sent right now. Stays `'queued'` while
|
|
23
|
+
* anything is still queued for the work even back online (replay preserves edit order), so read
|
|
24
|
+
* it immediately before the write, never once at mount.
|
|
25
|
+
*/
|
|
26
|
+
writeMode: "direct" | "queued";
|
|
27
|
+
/** Anything queued for this work that has not reached the server. */
|
|
28
|
+
hasPendingItems: boolean;
|
|
29
|
+
/** 0–100 across the queued items. */
|
|
30
|
+
syncProgress: number;
|
|
31
|
+
/** A queued item last failed to sync. It is retried, so this can clear on its own. */
|
|
32
|
+
hasError: boolean;
|
|
33
|
+
/** Everything that was queued has synced with no errors; `false` when nothing was ever queued. */
|
|
34
|
+
allSynced: boolean;
|
|
35
|
+
}
|
|
36
|
+
/** The outbox item kinds an app can see and filter on. Mirrors the shell's pending-item types. */
|
|
37
|
+
export type QueuedWorkOperationKind = "workCreation" | "dataUpdate" | "attachmentUpload" | "attachmentDeletion" | "actionExecution" | "attachmentTitleUpdate";
|
|
38
|
+
/** One queued operation, as an app sees it. */
|
|
39
|
+
export interface QueuedWorkOperation {
|
|
40
|
+
id: string;
|
|
41
|
+
kind: QueuedWorkOperationKind;
|
|
42
|
+
workId: string;
|
|
43
|
+
/**
|
|
44
|
+
* The operation's data as the app queued it; its shape varies by `kind`. A `dataUpdate`
|
|
45
|
+
* carries `{ id, originId, path, operation, sectionId, value }` — `id` the update's own id,
|
|
46
|
+
* `originId`/`sectionId` the flow origin and task node it replays against, and `operation` a
|
|
47
|
+
* {@link WorkPatchOperationName}, the same vocabulary `queueWorkDataUpdate` accepts.
|
|
48
|
+
*/
|
|
49
|
+
payload: unknown;
|
|
50
|
+
/** ISO timestamp of when it was queued — the order replay will follow. */
|
|
51
|
+
queuedAt: string;
|
|
52
|
+
isSynced: boolean;
|
|
53
|
+
}
|
|
54
|
+
export interface UpdateWorkDataArgs {
|
|
55
|
+
workId: string;
|
|
56
|
+
/** JSON path into the work data document, e.g. `$.parts[0].pickedQty`. */
|
|
57
|
+
dataPath: string;
|
|
58
|
+
/** Stored and read back exactly as passed — the shell does not coerce it. */
|
|
59
|
+
value: unknown;
|
|
60
|
+
/** The TASK node of the work's step tree, not `activeStepId` (its parent); omit to resolve the work's active task, which requires the work to be in the offline cache. */
|
|
61
|
+
sectionId?: string;
|
|
62
|
+
/** Defaults to the work's `flowOriginId` from the offline cache; when that cannot be resolved either, the update is refused rather than queued with an empty id. */
|
|
63
|
+
originId?: string;
|
|
64
|
+
/** Defaults to a plain set. */
|
|
65
|
+
operation?: WorkPatchOperationName;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* How `value` combines with whatever is already at `dataPath`. `push`/`pull`/`addToSet` operate on
|
|
69
|
+
* an array there (creating one if absent); `merge` deep-merges; `unset` removes the path.
|
|
70
|
+
*/
|
|
71
|
+
export type WorkPatchOperationName = "set" | "push" | "pull" | "unset" | "addToSet" | "merge";
|
|
72
|
+
/** One invitee. `email` identifies them; the rest is filled from the action's configuration. */
|
|
73
|
+
export interface WorkActionInvite {
|
|
74
|
+
email: string;
|
|
75
|
+
name?: string;
|
|
76
|
+
id?: string;
|
|
77
|
+
partyName?: string;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Replaces the invitees the flow config resolves for one of an action's destinations — for the
|
|
81
|
+
* case where the configured paths resolve to nobody (the work page shows a picker for it).
|
|
82
|
+
*/
|
|
83
|
+
export interface WorkActionRecipients {
|
|
84
|
+
/** Which destination to override; omit when the action has a single one. */
|
|
85
|
+
targetStep?: string;
|
|
86
|
+
to?: WorkActionInvite[];
|
|
87
|
+
cc?: WorkActionInvite[];
|
|
88
|
+
}
|
|
89
|
+
export interface ExecuteWorkActionArgs {
|
|
90
|
+
workId: string;
|
|
91
|
+
/** As `WorkDetail.actions[].id` — everything else the submission needs is read off the cached work. */
|
|
92
|
+
actionId: string;
|
|
93
|
+
/** Omit to invite whoever the flow config resolves against the work's current data. */
|
|
94
|
+
recipients?: WorkActionRecipients[];
|
|
95
|
+
/** Defaults to the task holding {@link actionId}; pass one only to target a different task. */
|
|
96
|
+
sectionId?: string;
|
|
97
|
+
}
|
|
98
|
+
export interface CreateWorkArgs {
|
|
99
|
+
/** The flow's version id (not `flowOriginId`) — the version whose steps/layouts to create work in. */
|
|
100
|
+
flowId: string;
|
|
101
|
+
/** Step name to open the new work at. */
|
|
102
|
+
targetTaskName: string;
|
|
103
|
+
/** Used verbatim instead of a provisional `OFFLINE-…` code; throws if it collides with any locally known code. */
|
|
104
|
+
workCode?: string;
|
|
105
|
+
}
|
|
106
|
+
export interface UploadWorkAttachmentArgs {
|
|
107
|
+
workId: string;
|
|
108
|
+
files: File[];
|
|
109
|
+
/**
|
|
110
|
+
* Grouping key for listing attachments back. Attachments upsert on resourceId+folder+filename,
|
|
111
|
+
* so re-uploading the same filename into the same folder replaces the earlier attachment.
|
|
112
|
+
*/
|
|
113
|
+
folder: string;
|
|
114
|
+
/** How this attachment renders when the work is printed; cosmetic only, no effect on the upload. */
|
|
115
|
+
reportSize?: "small" | "large" | "custom";
|
|
116
|
+
/** See {@link UpdateWorkDataArgs.sectionId}. */
|
|
117
|
+
sectionId?: string;
|
|
118
|
+
}
|
|
119
|
+
export interface ReadAttachmentBlobArgs {
|
|
120
|
+
id: string;
|
|
121
|
+
/**
|
|
122
|
+
* The id of the resource the attachment hangs off. A still-pending offline upload only resolves
|
|
123
|
+
* for work resources — the outbox queues work attachments only today.
|
|
124
|
+
*/
|
|
125
|
+
resourceId: string;
|
|
126
|
+
/** Read the thumbnail rather than the full attachment; a pending offline upload has none yet, so this returns full-resolution bytes instead. */
|
|
127
|
+
thumb?: boolean;
|
|
128
|
+
/** Feeds the cache key — pass the attachment's current version to avoid a stale cached blob after a same-id replace upload. */
|
|
129
|
+
version?: number;
|
|
130
|
+
}
|
|
131
|
+
export interface DeleteWorkAttachmentArgs {
|
|
132
|
+
workId: string;
|
|
133
|
+
/** Authoritative — this alone identifies the attachment to the server. */
|
|
134
|
+
id: string;
|
|
135
|
+
/** Only carried through to describe the pending deletion while queued offline; not matched on. */
|
|
136
|
+
fileName: string;
|
|
137
|
+
/** Only carried through to describe the pending deletion while queued offline; not matched on. */
|
|
138
|
+
folder: string;
|
|
139
|
+
/** Only carried through to describe the pending deletion while queued offline; not matched on. */
|
|
140
|
+
mimeType: string;
|
|
141
|
+
/** See {@link UpdateWorkDataArgs.sectionId}. */
|
|
142
|
+
sectionId?: string;
|
|
143
|
+
}
|
|
144
|
+
export type FlowDownloadStatus = "idle" | "preparing" | "downloading" | "done" | "error";
|
|
145
|
+
export interface FlowDownloadInfo {
|
|
146
|
+
status: FlowDownloadStatus;
|
|
147
|
+
/** Epoch ms the flow's works were last downloaded for offline use, or `null` if never. */
|
|
148
|
+
downloadedAt: number | null;
|
|
149
|
+
/**
|
|
150
|
+
* Works finished / expected for the run in flight (both `0` when idle) — what lets an
|
|
151
|
+
* `onOfflineDownload` hook mirror the shell's progress instead of reporting only at the end.
|
|
152
|
+
*/
|
|
153
|
+
processed: number;
|
|
154
|
+
total: number;
|
|
155
|
+
}
|
|
156
|
+
export interface DownloadFlowWorksArgs {
|
|
157
|
+
flowOriginId: string;
|
|
158
|
+
/** Omit it — the shell resolves the flow's current version. Pass one only to pin a specific version. */
|
|
159
|
+
flowId?: string;
|
|
160
|
+
}
|
|
161
|
+
export interface DownloadFlowWorksResult {
|
|
162
|
+
total: number;
|
|
163
|
+
failedWorkIds: string[];
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Raw local reads — exactly what a download put in the cache, with nothing merged in. Internal
|
|
167
|
+
* transport, not app API: apps reach this through the connectors, whose reads resolve a source
|
|
168
|
+
* themselves (see `resolveRead` in connectors/readPolicy.ts). Every method is total — `null`/`[]`
|
|
169
|
+
* means "not downloaded", and none consults the network — except `readWorkData`, which can throw.
|
|
170
|
+
*/
|
|
171
|
+
export interface CacheApi {
|
|
172
|
+
/** The raw v4 POCO the download stored — not the shell's transformed shape (it renames fields) and with no queued edits folded in — so the connector maps both sources through one mapper. */
|
|
173
|
+
readWork(workId: string): Record<string, unknown> | null;
|
|
174
|
+
/**
|
|
175
|
+
* The cached work-data document, or the subtree at `opts.path` (the same JSONPath the v4 data
|
|
176
|
+
* endpoint accepts as `?path=`). `null` when the work is not downloaded or the path resolves to
|
|
177
|
+
* nothing. Throws on a recursive-descent path (`..`), which would answer with a different shape
|
|
178
|
+
* locally than the endpoint does.
|
|
179
|
+
*/
|
|
180
|
+
readWorkData(workId: string, opts?: {
|
|
181
|
+
path?: string;
|
|
182
|
+
}): unknown;
|
|
183
|
+
/**
|
|
184
|
+
* The roles the signed-in user holds on this work. `null` means the work was not downloaded;
|
|
185
|
+
* `[]` means it was and the user holds none — the read policy relies on the distinction.
|
|
186
|
+
*/
|
|
187
|
+
readMyWorkAccess(workId: string): string[] | null;
|
|
188
|
+
readFlow(flowId: string): Record<string, unknown> | null;
|
|
189
|
+
/**
|
|
190
|
+
* The flat `parentId` list as stored, which is also what the network returns — both sources go
|
|
191
|
+
* through one mapper and neither is rearranged.
|
|
192
|
+
*/
|
|
193
|
+
readLayout(layoutId: string): Record<string, unknown> | null;
|
|
194
|
+
/** Async because the bytes may live in IndexedDB; still resolves `null` when nothing was downloaded. */
|
|
195
|
+
readAttachmentBlob(args: ReadAttachmentBlobArgs): Promise<Blob | null>;
|
|
196
|
+
}
|
|
197
|
+
/** Connectivity, queueing, and offline flow-download state. */
|
|
198
|
+
export interface OfflineApi {
|
|
199
|
+
isOnline(): boolean;
|
|
200
|
+
subscribeOnline(listener: (online: boolean) => void): ShellEventUnsubscribe;
|
|
201
|
+
/**
|
|
202
|
+
* The queue tools append to the outbox and fold the result into the live work page store — they
|
|
203
|
+
* never send or branch on connectivity; the caller routes on `getWorkSyncStatus().writeMode`.
|
|
204
|
+
*/
|
|
205
|
+
queueWorkDataUpdate(args: UpdateWorkDataArgs): void;
|
|
206
|
+
queueWorkAction(args: ExecuteWorkActionArgs): void;
|
|
207
|
+
/**
|
|
208
|
+
* Builds the work locally and queues its creation. The work is real under the returned id
|
|
209
|
+
* immediately and stays under it after sync, so an app can navigate to it straight away.
|
|
210
|
+
*/
|
|
211
|
+
queueWorkCreation(args: CreateWorkArgs): {
|
|
212
|
+
workId: string;
|
|
213
|
+
code: string;
|
|
214
|
+
};
|
|
215
|
+
/** Async because the bytes are written to the blob store before the item is queued. */
|
|
216
|
+
queueWorkAttachmentUpload(args: UploadWorkAttachmentArgs): Promise<void>;
|
|
217
|
+
queueWorkAttachmentDeletion(args: DeleteWorkAttachmentArgs): void;
|
|
218
|
+
/** Everything still queued, newest last — the order replay will follow. */
|
|
219
|
+
listQueuedWorkOperations(args?: {
|
|
220
|
+
workId?: string;
|
|
221
|
+
kind?: QueuedWorkOperationKind;
|
|
222
|
+
}): QueuedWorkOperation[];
|
|
223
|
+
/** Outbox state for one work, including the `writeMode` a caller routes on. */
|
|
224
|
+
getWorkSyncStatus(workId: string): WorkSyncStatus;
|
|
225
|
+
/**
|
|
226
|
+
* Ask the shell to drain the outbox. Resolves when the attempt finishes, not when it succeeds —
|
|
227
|
+
* check `getWorkSyncStatus` for the outcome. A no-op while offline.
|
|
228
|
+
*/
|
|
229
|
+
requestSync(args?: {
|
|
230
|
+
workId?: string;
|
|
231
|
+
}): Promise<void>;
|
|
232
|
+
/** Ids of the works a download put in the cache. The local counterpart to a server-side list. */
|
|
233
|
+
listDownloadedWorkIds(flowOriginId?: string): string[];
|
|
234
|
+
/** Ids of every flow whose config is held locally — version ids, which is what configs are keyed by. */
|
|
235
|
+
listDownloadedFlowIds(): string[];
|
|
236
|
+
/** Downloads a flow's works for offline use, tracked under the shared `flow:` download subject. */
|
|
237
|
+
downloadFlowWorks(args: DownloadFlowWorksArgs): Promise<DownloadFlowWorksResult>;
|
|
238
|
+
/** Current download state for a flow — derived, not persisted; recomputed from the cache each call. */
|
|
239
|
+
getFlowWorksDownloadInfo(flowOriginId: string): FlowDownloadInfo;
|
|
240
|
+
/**
|
|
241
|
+
* Fires whenever this flow's download state moves — `getFlowWorksDownloadInfo` reads a store
|
|
242
|
+
* outside React, so polling it alone would sit on `idle` for the whole download.
|
|
243
|
+
*/
|
|
244
|
+
subscribeFlowDownload(flowOriginId: string, listener: () => void): ShellEventUnsubscribe;
|
|
245
|
+
}
|
|
20
246
|
export interface DianaShell {
|
|
21
247
|
version: number;
|
|
22
248
|
getUser(): ShellUser | null;
|
|
@@ -26,6 +252,12 @@ export interface DianaShell {
|
|
|
26
252
|
getApi(): AxiosInstance;
|
|
27
253
|
getApiV4(name: V4ApiKey): AxiosInstance;
|
|
28
254
|
getAi(): ShellAiApi | null;
|
|
255
|
+
getOffline(): OfflineApi | null;
|
|
256
|
+
/**
|
|
257
|
+
* Raw cache reads. `null` on a host that has not wired it — the connectors' read policy treats
|
|
258
|
+
* that as "no local copy exists", so an app degrades to network-only rather than throwing.
|
|
259
|
+
*/
|
|
260
|
+
getCache(): CacheApi | null;
|
|
29
261
|
navigate: ShellNavigate;
|
|
30
262
|
}
|
|
31
263
|
declare global {
|
|
@@ -33,4 +265,4 @@ declare global {
|
|
|
33
265
|
__DIANA_SHELL__?: DianaShell;
|
|
34
266
|
}
|
|
35
267
|
}
|
|
36
|
-
export declare const SHELL_BRIDGE_VERSION =
|
|
268
|
+
export declare const SHELL_BRIDGE_VERSION = 4;
|
package/build/shellBridge.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SHELL_BRIDGE_VERSION = void 0;
|
|
4
|
-
// Bumped to
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
|
|
4
|
+
// Bumped to 4: adds the offline surface as a getCache()/getOffline() split — CacheApi owns the raw
|
|
5
|
+
// cache reads (readWork, readWorkData, readFlow, readLayout, readAttachmentBlob) and OfflineApi
|
|
6
|
+
// owns connectivity, the queue tools and flow downloads. Additive, so v3-built apps keep working on
|
|
7
|
+
// a v4 host. A v4 app on an older host finds no accessor at all, so detect the method you are about
|
|
8
|
+
// to call rather than comparing versions: `typeof offline.queueWorkDataUpdate === 'function'`.
|
|
9
|
+
// (v3 added getAi(); v2 added the V4ApiKey arg to getApiV4.)
|
|
10
|
+
// requireShell() compares the host's shell.version against this constant and warns once on mismatch.
|
|
11
|
+
exports.SHELL_BRIDGE_VERSION = 4;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
type MobileNav = 'strip' | 'tabs';
|
|
3
|
-
declare function AppFrame({ className, mobileNav, ...props }: React.ComponentProps<'div'> & {
|
|
3
|
+
declare function AppFrame({ className, mobileNav, children, ...props }: React.ComponentProps<'div'> & {
|
|
4
4
|
mobileNav?: MobileNav;
|
|
5
5
|
}): React.JSX.Element;
|
|
6
6
|
/** Fixed left rail from the frame's `2xl` container width up (180px, the Nav
|