@rise-x/apps-sdk 0.11.0 → 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.
Files changed (83) hide show
  1. package/README.md +904 -20
  2. package/build/_internal.d.ts +4 -1
  3. package/build/_internal.js +67 -0
  4. package/build/cli/index.d.ts +7 -1
  5. package/build/cli/index.js +68 -14
  6. package/build/cli/scan.d.ts +60 -0
  7. package/build/cli/scan.js +725 -0
  8. package/build/cli/validate.d.ts +33 -0
  9. package/build/cli/validate.js +169 -0
  10. package/build/connectors/agents.d.ts +10 -6
  11. package/build/connectors/agents.js +59 -44
  12. package/build/connectors/attachments.d.ts +51 -0
  13. package/build/connectors/attachments.js +76 -0
  14. package/build/connectors/errors.js +24 -0
  15. package/build/connectors/flows.d.ts +13 -2
  16. package/build/connectors/flows.js +64 -19
  17. package/build/connectors/index.d.ts +5 -1
  18. package/build/connectors/index.js +14 -2
  19. package/build/connectors/integrations.d.ts +29 -0
  20. package/build/connectors/integrations.js +32 -0
  21. package/build/connectors/offline.d.ts +34 -0
  22. package/build/connectors/offline.js +135 -0
  23. package/build/connectors/readPolicy.d.ts +29 -0
  24. package/build/connectors/readPolicy.js +105 -0
  25. package/build/connectors/types.d.ts +75 -0
  26. package/build/connectors/types.js +128 -0
  27. package/build/connectors/vectorStores.d.ts +45 -0
  28. package/build/connectors/vectorStores.js +199 -0
  29. package/build/connectors/work.d.ts +14 -2
  30. package/build/connectors/work.js +43 -19
  31. package/build/dependencies/bound.d.ts +87 -0
  32. package/build/dependencies/bound.js +207 -0
  33. package/build/dependencies/index.d.ts +2 -0
  34. package/build/dependencies/index.js +13 -0
  35. package/build/dependencyRegistry.d.ts +15 -0
  36. package/build/dependencyRegistry.js +28 -0
  37. package/build/index.d.ts +2 -1
  38. package/build/index.js +12 -1
  39. package/build/lifecycle.d.ts +10 -1
  40. package/build/manifest.d.ts +69 -0
  41. package/build/manifest.js +229 -0
  42. package/build/manifestSource.d.ts +27 -0
  43. package/build/manifestSource.js +99 -0
  44. package/build/mockShell.d.ts +2 -0
  45. package/build/mockShell.js +13 -0
  46. package/build/query/client.js +9 -1
  47. package/build/query/dependencies.d.ts +22 -0
  48. package/build/query/dependencies.js +73 -0
  49. package/build/query/flows.d.ts +8 -8
  50. package/build/query/index.d.ts +1 -0
  51. package/build/query/index.js +4 -2
  52. package/build/query/layer.d.ts +9 -9
  53. package/build/query/shared.js +10 -0
  54. package/build/query/work.d.ts +4 -4
  55. package/build/rsbuild/index.d.ts +3 -1
  56. package/build/rsbuild/index.js +36 -2
  57. package/build/rsbuild/riseAppManifestPlugin.d.ts +19 -0
  58. package/build/rsbuild/riseAppManifestPlugin.js +79 -0
  59. package/build/shell/installShellBridge.d.ts +2 -0
  60. package/build/shell/installShellBridge.js +3 -1
  61. package/build/shellBridge.d.ts +233 -1
  62. package/build/shellBridge.js +8 -7
  63. package/build/ui/components/app-frame.d.ts +1 -1
  64. package/build/ui/demo.html +365 -360
  65. package/build/ui/shadcn.css +629 -0
  66. package/build/ui/standalone.js +17 -15
  67. package/build/ui/styles.css +1 -1
  68. package/build/ui/tailwind.css +12 -0
  69. package/build/ui/theme.css +412 -0
  70. package/build/ui/tw-animate.css +1 -0
  71. package/build/webpack/index.d.ts +1 -0
  72. package/build/webpack/index.js +7 -0
  73. package/build/webpack/riseAppManifestPlugin.d.ts +61 -0
  74. package/build/webpack/riseAppManifestPlugin.js +103 -0
  75. package/dependencies/package.json +8 -0
  76. package/package.json +17 -4
  77. package/template/AGENTS.md +34 -4
  78. package/template/README.md +85 -2
  79. package/template/package.json +4 -0
  80. package/template/rise-x-app.json +4 -0
  81. package/template/src/App.tsx +7 -17
  82. package/template/src/styles.css +5 -0
  83. package/webpack/package.json +8 -0
@@ -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;
@@ -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
+ }
@@ -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 {};
@@ -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 init <name> [options]
11
+ console.error(`Usage: apps-sdk <command> [options]
8
12
 
9
- Creates a new Rise-X federated app in the current directory.
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.exit(1);
68
+ process.exitCode = 1;
69
+ return;
42
70
  }
43
- if (command !== "init") {
44
- console.error(`Unknown command: ${command}`);
45
- printUsage();
46
- process.exit(1);
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
- await (0, init_1.init)({ positional, flags: parsed.values });
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().catch((err) => {
51
- const message = err instanceof Error ? err.message : String(err);
52
- console.error(`apps-sdk: ${message}`);
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 {};