@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
package/build/_internal.d.ts
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
import { type DianaShell } from "./shellBridge";
|
|
1
|
+
import { type DianaShell, type ShellAiApi } from "./shellBridge";
|
|
2
2
|
export declare function requireShell(): DianaShell;
|
|
3
|
+
export declare function ensureOk(response: Response, action: string): Promise<void>;
|
|
4
|
+
export declare function stripContentType(headers: Record<string, string>): Record<string, string>;
|
|
5
|
+
export declare function resolveAi(shell: DianaShell, action: string): ShellAiApi;
|
package/build/_internal.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.requireShell = requireShell;
|
|
4
|
+
exports.ensureOk = ensureOk;
|
|
5
|
+
exports.stripContentType = stripContentType;
|
|
6
|
+
exports.resolveAi = resolveAi;
|
|
4
7
|
const errors_1 = require("./connectors/errors");
|
|
5
8
|
const shellBridge_1 = require("./shellBridge");
|
|
6
9
|
let versionMismatchWarned = false;
|
|
@@ -21,3 +24,67 @@ function requireShell() {
|
|
|
21
24
|
}
|
|
22
25
|
return shell;
|
|
23
26
|
}
|
|
27
|
+
// One entry of FastAPI's 422 `detail` array -> "body.name: too long".
|
|
28
|
+
function validationMessage(entry) {
|
|
29
|
+
if (typeof entry !== "object" || entry === null)
|
|
30
|
+
return undefined;
|
|
31
|
+
const { loc, msg } = entry;
|
|
32
|
+
if (typeof msg !== "string" || !msg)
|
|
33
|
+
return undefined;
|
|
34
|
+
return Array.isArray(loc) && loc.length ? `${loc.join(".")}: ${msg}` : msg;
|
|
35
|
+
}
|
|
36
|
+
// Maps a non-OK response to ConnectorError: 404 -> NOT_FOUND, everything else
|
|
37
|
+
// (409 expired, 410 gone, 413 too large, …) -> HTTP_ERROR, reading the
|
|
38
|
+
// FastAPI `detail` (or `message`) for the text.
|
|
39
|
+
async function ensureOk(response, action) {
|
|
40
|
+
if (response.ok)
|
|
41
|
+
return;
|
|
42
|
+
let message = `${action} failed with status ${response.status}`;
|
|
43
|
+
try {
|
|
44
|
+
const body = (await response.json());
|
|
45
|
+
const detail = body?.detail ?? body?.message;
|
|
46
|
+
if (typeof detail === "string" && detail)
|
|
47
|
+
message = detail;
|
|
48
|
+
else if (Array.isArray(detail)) {
|
|
49
|
+
// A 422 puts one entry per invalid field here instead of a string, so
|
|
50
|
+
// without this every validation failure reads as a bare status.
|
|
51
|
+
const parts = detail
|
|
52
|
+
.map(validationMessage)
|
|
53
|
+
.filter((part) => part !== undefined);
|
|
54
|
+
if (parts.length)
|
|
55
|
+
message = parts.join("; ");
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
// non-JSON error body — keep the generic message
|
|
60
|
+
}
|
|
61
|
+
throw new errors_1.ConnectorError(response.status === 404 ? "NOT_FOUND" : "HTTP_ERROR", message, {
|
|
62
|
+
status: response.status,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
// Case-insensitive Content-Type drop: a host-supplied value would otherwise
|
|
66
|
+
// collide with the one each caller sets for its own request (JSON needs the
|
|
67
|
+
// exact value, multipart needs the browser's own boundary). Header names are
|
|
68
|
+
// case-insensitive on the wire, so this matches loosely instead of deleting
|
|
69
|
+
// one spelling. Each caller layers its own extra headers on the result.
|
|
70
|
+
function stripContentType(headers) {
|
|
71
|
+
const result = {};
|
|
72
|
+
for (const [name, value] of Object.entries(headers)) {
|
|
73
|
+
if (name.toLowerCase() === "content-type")
|
|
74
|
+
continue;
|
|
75
|
+
result[name] = value;
|
|
76
|
+
}
|
|
77
|
+
return result;
|
|
78
|
+
}
|
|
79
|
+
// getAi() missing -> SHELL_TOO_OLD (bridge predates v3); null -> AI_UNAVAILABLE
|
|
80
|
+
// (no AI gateway configured for this deployment).
|
|
81
|
+
function resolveAi(shell, action) {
|
|
82
|
+
if (typeof shell.getAi !== "function") {
|
|
83
|
+
throw new errors_1.ConnectorError("SHELL_TOO_OLD", `${action} requires shell bridge v3 (getAi) — update the Rise-X shell`);
|
|
84
|
+
}
|
|
85
|
+
const ai = shell.getAi();
|
|
86
|
+
if (!ai) {
|
|
87
|
+
throw new errors_1.ConnectorError("AI_UNAVAILABLE", "no AI gateway is configured for this deployment");
|
|
88
|
+
}
|
|
89
|
+
return ai;
|
|
90
|
+
}
|
package/build/cli/index.d.ts
CHANGED
|
@@ -4,10 +4,16 @@ declare function parseCli(): {
|
|
|
4
4
|
pm: string | undefined;
|
|
5
5
|
port: string | undefined;
|
|
6
6
|
"skip-install": boolean | undefined;
|
|
7
|
+
env: string | undefined;
|
|
8
|
+
"no-scan": boolean | undefined;
|
|
9
|
+
strict: boolean | undefined;
|
|
10
|
+
"show-ignored": boolean | undefined;
|
|
7
11
|
json: boolean | undefined;
|
|
8
12
|
help: boolean | undefined;
|
|
9
13
|
};
|
|
10
14
|
positionals: string[];
|
|
11
15
|
};
|
|
12
|
-
export type CliFlags = ReturnType<typeof parseCli>["values"]
|
|
16
|
+
export type CliFlags = Partial<ReturnType<typeof parseCli>["values"]>;
|
|
17
|
+
export declare function main(): Promise<void>;
|
|
18
|
+
export declare function run(): Promise<void>;
|
|
13
19
|
export {};
|
package/build/cli/index.js
CHANGED
|
@@ -1,18 +1,41 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.main = main;
|
|
5
|
+
exports.run = run;
|
|
4
6
|
const node_util_1 = require("node:util");
|
|
5
7
|
const init_1 = require("./init");
|
|
8
|
+
const scan_1 = require("./scan");
|
|
9
|
+
const validate_1 = require("./validate");
|
|
6
10
|
function printUsage() {
|
|
7
|
-
console.error(`Usage: apps-sdk
|
|
11
|
+
console.error(`Usage: apps-sdk <command> [options]
|
|
8
12
|
|
|
9
|
-
|
|
13
|
+
Commands:
|
|
14
|
+
init <name> Create a new Rise-X federated app in the current directory
|
|
15
|
+
validate [dir] Check the app's rise-x-app.json against every environment
|
|
16
|
+
it declares, and warn about hardcoded ids (default dir: .)
|
|
17
|
+
scan [dir] Report Rise-X ids hardcoded in app source that
|
|
18
|
+
rise-x-app.json does not declare (default dir: .)
|
|
10
19
|
|
|
11
|
-
Options:
|
|
20
|
+
Options for init:
|
|
12
21
|
--pm=<npm|yarn|pnpm> Package manager (default: auto-detect from cwd lockfiles)
|
|
13
22
|
--port=<n> Standalone dev-server port (default: 5101)
|
|
14
23
|
--skip-install Skip <pm> install after scaffolding
|
|
15
24
|
--json Emit { path, slug, scope, pkgName, port, pm } on stdout
|
|
25
|
+
|
|
26
|
+
Options for validate:
|
|
27
|
+
--env=<name> Check only this environment (default: all declared)
|
|
28
|
+
--no-scan Skip the hardcoded-id scan
|
|
29
|
+
--show-ignored Also list the ids the scan set aside, and on what grounds
|
|
30
|
+
--json Emit { ok, manifest, environments, scan } on stdout
|
|
31
|
+
|
|
32
|
+
Options for scan:
|
|
33
|
+
--strict Exit non-zero when an undeclared id is found, the scan
|
|
34
|
+
was skipped, or a file could not be read
|
|
35
|
+
--show-ignored Also list the ids set aside, and on what grounds
|
|
36
|
+
--json Emit { ok, filesScanned, findings, ... } on stdout
|
|
37
|
+
|
|
38
|
+
Options:
|
|
16
39
|
--help, -h Show this help
|
|
17
40
|
`);
|
|
18
41
|
}
|
|
@@ -23,6 +46,10 @@ function parseCli() {
|
|
|
23
46
|
pm: { type: "string" },
|
|
24
47
|
port: { type: "string" },
|
|
25
48
|
"skip-install": { type: "boolean" },
|
|
49
|
+
env: { type: "string" },
|
|
50
|
+
"no-scan": { type: "boolean" },
|
|
51
|
+
strict: { type: "boolean" },
|
|
52
|
+
"show-ignored": { type: "boolean" },
|
|
26
53
|
json: { type: "boolean" },
|
|
27
54
|
help: { type: "boolean", short: "h" },
|
|
28
55
|
},
|
|
@@ -38,17 +65,44 @@ async function main() {
|
|
|
38
65
|
const [command, ...positional] = parsed.positionals;
|
|
39
66
|
if (!command) {
|
|
40
67
|
printUsage();
|
|
41
|
-
process.
|
|
68
|
+
process.exitCode = 1;
|
|
69
|
+
return;
|
|
42
70
|
}
|
|
43
|
-
if (command
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
71
|
+
if (command === "init") {
|
|
72
|
+
await (0, init_1.init)({ positional, flags: parsed.values });
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
if (command === "validate") {
|
|
76
|
+
// Non-zero on a manifest that does not resolve, so a release script can gate
|
|
77
|
+
// on it. The report is already printed; a throw would bury it. Scan findings
|
|
78
|
+
// are warnings and deliberately do not affect this.
|
|
79
|
+
const result = await (0, validate_1.validate)({ positional, flags: parsed.values });
|
|
80
|
+
if (!result.ok)
|
|
81
|
+
process.exitCode = 1;
|
|
82
|
+
return;
|
|
47
83
|
}
|
|
48
|
-
|
|
84
|
+
if (command === "scan") {
|
|
85
|
+
const result = await (0, scan_1.scan)({ positional, flags: parsed.values });
|
|
86
|
+
// Opt-in, because the classification is a heuristic: CI can gate on it, but
|
|
87
|
+
// a false positive must not break anyone who merely ran the command.
|
|
88
|
+
// `skipped` fails too: --strict asks for the check to have happened, and a
|
|
89
|
+
// gate that passes because it could not run is worse than no gate.
|
|
90
|
+
if (parsed.values.strict === true && (!result.ok || result.skipped)) {
|
|
91
|
+
process.exitCode = 1;
|
|
92
|
+
}
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
console.error(`Unknown command: ${command}`);
|
|
96
|
+
printUsage();
|
|
97
|
+
process.exitCode = 1;
|
|
98
|
+
}
|
|
99
|
+
function run() {
|
|
100
|
+
return main().catch((err) => {
|
|
101
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
102
|
+
console.error(`apps-sdk: ${message}`);
|
|
103
|
+
process.exitCode = 1;
|
|
104
|
+
});
|
|
49
105
|
}
|
|
50
|
-
main().
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
process.exit(1);
|
|
54
|
-
});
|
|
106
|
+
// Only when executed as the CLI, so a test can drive main() itself.
|
|
107
|
+
if (require.main === module)
|
|
108
|
+
void run();
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type * as TypeScript from "typescript";
|
|
2
|
+
import { type AppDependencyKind } from "../manifest";
|
|
3
|
+
import type { CliFlags } from "./index";
|
|
4
|
+
type TS = typeof TypeScript;
|
|
5
|
+
export interface ScanLocation {
|
|
6
|
+
file: string;
|
|
7
|
+
line: number;
|
|
8
|
+
context: string;
|
|
9
|
+
}
|
|
10
|
+
export interface ScanFinding {
|
|
11
|
+
id: string;
|
|
12
|
+
kind: AppDependencyKind | null;
|
|
13
|
+
suggestedAlias: string | null;
|
|
14
|
+
aliasCollision?: boolean;
|
|
15
|
+
collidedAlias?: string;
|
|
16
|
+
locations: ScanLocation[];
|
|
17
|
+
}
|
|
18
|
+
export interface ScanDismissal {
|
|
19
|
+
id: string;
|
|
20
|
+
by: "rule" | "marker";
|
|
21
|
+
locations: ScanLocation[];
|
|
22
|
+
}
|
|
23
|
+
export interface ScanResult {
|
|
24
|
+
ok: boolean;
|
|
25
|
+
filesScanned: number;
|
|
26
|
+
findings: ScanFinding[];
|
|
27
|
+
declared: number;
|
|
28
|
+
dismissed: ScanDismissal[];
|
|
29
|
+
silenced: ScanDismissal[];
|
|
30
|
+
unreadable: number;
|
|
31
|
+
skipped?: string;
|
|
32
|
+
}
|
|
33
|
+
/** What rise-x-app.json already carries: ids, so a declared one is not a
|
|
34
|
+
* finding, and aliases (lowercased), so a suggestion cannot duplicate a key. */
|
|
35
|
+
interface Declared {
|
|
36
|
+
ids: Set<string>;
|
|
37
|
+
aliases: Set<string>;
|
|
38
|
+
}
|
|
39
|
+
export interface ScanArgs {
|
|
40
|
+
positional: string[];
|
|
41
|
+
flags: CliFlags;
|
|
42
|
+
}
|
|
43
|
+
export declare function scanSource(ts: TS, files: string[], root: string, declared: Declared): {
|
|
44
|
+
findings: ScanFinding[];
|
|
45
|
+
declaredHits: number;
|
|
46
|
+
dismissed: ScanDismissal[];
|
|
47
|
+
silenced: ScanDismissal[];
|
|
48
|
+
unreadable: number;
|
|
49
|
+
};
|
|
50
|
+
export declare function runScan(dir: string): ScanResult;
|
|
51
|
+
/** The findings block, shared by `scan` and `validate`. Indented to sit under
|
|
52
|
+
* either report. `showDismissed` lists what was set aside and why. */
|
|
53
|
+
export declare function reportScan(result: ScanResult, showDismissed?: boolean): void;
|
|
54
|
+
/**
|
|
55
|
+
* Reports Rise-X ids hardcoded in app source. Exits non-zero only under
|
|
56
|
+
* `--strict`, because the classification is a heuristic and a false positive
|
|
57
|
+
* must never be able to block a deploy by default.
|
|
58
|
+
*/
|
|
59
|
+
export declare function scan(args: ScanArgs): Promise<ScanResult>;
|
|
60
|
+
export {};
|