@rise-x/apps-sdk 0.11.1 → 0.15.1
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 +915 -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/classes.json +2 -2
- package/build/ui/components/app-frame.d.ts +1 -1
- package/build/ui/components/data-table.d.ts +39 -4
- package/build/ui/components/statistic.d.ts +1 -1
- package/build/ui/demo.html +671 -543
- package/build/ui/shadcn.css +629 -0
- package/build/ui/standalone.js +45 -44
- 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
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Build-time reading of an app's `rise-x-app.json`, shared by both build paths:
|
|
3
|
+
// the webpack plugin (src/webpack) and the Rsbuild preset (src/rsbuild). Node
|
|
4
|
+
// only, and kept out of the root barrel so an app's runtime bundle never pulls
|
|
5
|
+
// in node:fs.
|
|
6
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
+
}
|
|
12
|
+
Object.defineProperty(o, k2, desc);
|
|
13
|
+
}) : (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
o[k2] = m[k];
|
|
16
|
+
}));
|
|
17
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
18
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
19
|
+
}) : function(o, v) {
|
|
20
|
+
o["default"] = v;
|
|
21
|
+
});
|
|
22
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
23
|
+
var ownKeys = function(o) {
|
|
24
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
25
|
+
var ar = [];
|
|
26
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
27
|
+
return ar;
|
|
28
|
+
};
|
|
29
|
+
return ownKeys(o);
|
|
30
|
+
};
|
|
31
|
+
return function (mod) {
|
|
32
|
+
if (mod && mod.__esModule) return mod;
|
|
33
|
+
var result = {};
|
|
34
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
35
|
+
__setModuleDefault(result, mod);
|
|
36
|
+
return result;
|
|
37
|
+
};
|
|
38
|
+
})();
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
exports.MANIFEST_GLOBAL_EXPRESSION = void 0;
|
|
41
|
+
exports.appManifestPath = appManifestPath;
|
|
42
|
+
exports.targetAppEnvironment = targetAppEnvironment;
|
|
43
|
+
exports.readAppManifestSource = readAppManifestSource;
|
|
44
|
+
exports.readResolvedAppManifest = readResolvedAppManifest;
|
|
45
|
+
exports.formatResolvedAppManifest = formatResolvedAppManifest;
|
|
46
|
+
const fs = __importStar(require("node:fs"));
|
|
47
|
+
const path = __importStar(require("node:path"));
|
|
48
|
+
const manifest_1 = require("./manifest");
|
|
49
|
+
// The expression the resolved manifest is substituted into, read at runtime by
|
|
50
|
+
// getAppDependencies(). Kept in sync with src/dependencyRegistry.ts by hand:
|
|
51
|
+
// that module reads the expression rather than publishing it as a string, so
|
|
52
|
+
// there is nothing to import.
|
|
53
|
+
exports.MANIFEST_GLOBAL_EXPRESSION = "globalThis.__RISE_APP_MANIFEST__";
|
|
54
|
+
function appManifestPath(context) {
|
|
55
|
+
return path.join(context, manifest_1.APP_MANIFEST_FILENAME);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* The environment to resolve for: an explicit value, else APP_ENV, else the
|
|
59
|
+
* default.
|
|
60
|
+
*/
|
|
61
|
+
function targetAppEnvironment(explicit) {
|
|
62
|
+
// `||`, not `??`: an APP_ENV exported as empty means "unset" here, and would
|
|
63
|
+
// otherwise fail the build with `unknown environment ""`.
|
|
64
|
+
return explicit || process.env.APP_ENV || manifest_1.DEFAULT_APP_ENVIRONMENT;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* The parsed, unvalidated `rise-x-app.json`, or null when the app declares none.
|
|
68
|
+
* Wrapped, because a file holding the literal `null` is a manifest that has to
|
|
69
|
+
* fail validation, not an absent one.
|
|
70
|
+
*
|
|
71
|
+
* Validating against more than one environment works from the source rather than
|
|
72
|
+
* a resolved copy, so this reads and parses the file once.
|
|
73
|
+
*/
|
|
74
|
+
function readAppManifestSource(sourcePath) {
|
|
75
|
+
if (!fs.existsSync(sourcePath))
|
|
76
|
+
return null;
|
|
77
|
+
const raw = fs.readFileSync(sourcePath, "utf8");
|
|
78
|
+
try {
|
|
79
|
+
return { source: JSON.parse(raw) };
|
|
80
|
+
}
|
|
81
|
+
catch (err) {
|
|
82
|
+
throw new Error(`${manifest_1.APP_MANIFEST_FILENAME} is not valid JSON: ${err.message}`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Null when the app declares no manifest; throws the resolver's error when it
|
|
87
|
+
* declares an invalid one.
|
|
88
|
+
*/
|
|
89
|
+
function readResolvedAppManifest(sourcePath, environment) {
|
|
90
|
+
const read = readAppManifestSource(sourcePath);
|
|
91
|
+
if (!read)
|
|
92
|
+
return null;
|
|
93
|
+
return (0, manifest_1.resolveAppManifest)(read.source, environment);
|
|
94
|
+
}
|
|
95
|
+
/** The bytes emitted as `dist/rise-x-app.json` — read by the backend, and by
|
|
96
|
+
* humans reading a deployed zip. */
|
|
97
|
+
function formatResolvedAppManifest(resolved) {
|
|
98
|
+
return `${JSON.stringify(resolved, null, 2)}\n`;
|
|
99
|
+
}
|
package/build/mockShell.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type ResolvedAppManifest } from "./manifest";
|
|
1
2
|
import type { DianaShell, ShellAiApi, ShellEnvironment, ShellUser } from "./shellBridge";
|
|
2
3
|
export interface MockShellFixtures {
|
|
3
4
|
workRows?: Record<string, unknown[]>;
|
|
@@ -16,6 +17,7 @@ export interface CreateMockShellOptions {
|
|
|
16
17
|
apiV4?: DianaShell["getApiV4"];
|
|
17
18
|
fixtures?: MockShellFixtures;
|
|
18
19
|
ai?: ShellAiApi | null;
|
|
20
|
+
dependencies?: ResolvedAppManifest["dependencies"];
|
|
19
21
|
}
|
|
20
22
|
export declare function createMockShell(overrides?: CreateMockShellOptions): DianaShell;
|
|
21
23
|
export declare function isMockShell(shell: DianaShell): boolean;
|
package/build/mockShell.js
CHANGED
|
@@ -4,6 +4,8 @@ exports.createMockShell = createMockShell;
|
|
|
4
4
|
exports.isMockShell = isMockShell;
|
|
5
5
|
const errors_1 = require("./connectors/errors");
|
|
6
6
|
const search_1 = require("./connectors/search");
|
|
7
|
+
const dependencyRegistry_1 = require("./dependencyRegistry");
|
|
8
|
+
const manifest_1 = require("./manifest");
|
|
7
9
|
const shellBridge_1 = require("./shellBridge");
|
|
8
10
|
// Both helpers return the error rather than throwing it, so every call site
|
|
9
11
|
// reads as an explicit `throw` instead of a function call that never returns.
|
|
@@ -146,6 +148,14 @@ function createFixtureClients(fixtures) {
|
|
|
146
148
|
// shell or supply their own instances. Navigate falls back to window.location.
|
|
147
149
|
function createMockShell(overrides = {}) {
|
|
148
150
|
const { user = { id: "standalone", name: "Standalone Dev" }, environment = { id: "dev", slug: "dev", name: "Standalone Dev Env" }, ai = null, } = overrides;
|
|
151
|
+
// Cleared when none are passed, so a mock shell built without dependencies
|
|
152
|
+
// never inherits the ones an earlier one registered.
|
|
153
|
+
(0, dependencyRegistry_1.registerAppDependencies)(overrides.dependencies
|
|
154
|
+
? {
|
|
155
|
+
environment: manifest_1.DEFAULT_APP_ENVIRONMENT,
|
|
156
|
+
dependencies: overrides.dependencies,
|
|
157
|
+
}
|
|
158
|
+
: null);
|
|
149
159
|
// Both getApi (no arg) and getApiV4 (V4ApiKey arg) need a thrower; we cast the
|
|
150
160
|
// returned function to whichever signature DianaShell expects at the callsite.
|
|
151
161
|
const notAvailable = (which) => () => {
|
|
@@ -198,6 +208,9 @@ function createMockShell(overrides = {}) {
|
|
|
198
208
|
fixtureApiV4 ??
|
|
199
209
|
notAvailable("getApiV4"),
|
|
200
210
|
getAi: () => ai,
|
|
211
|
+
// Standalone dev has no cache, outbox or sync engine — null is the honest answer for both.
|
|
212
|
+
getOffline: () => null,
|
|
213
|
+
getCache: () => null,
|
|
201
214
|
navigate,
|
|
202
215
|
};
|
|
203
216
|
// Untyped marker so SDK internals (e.g. the query layer's dev diagnostics)
|
package/build/query/client.js
CHANGED
|
@@ -46,7 +46,15 @@ function createAppQueryClient(overrides) {
|
|
|
46
46
|
staleTime: 30000,
|
|
47
47
|
gcTime: 5 * 60000,
|
|
48
48
|
refetchOnWindowFocus: false,
|
|
49
|
-
|
|
49
|
+
// Run the first attempt even while the browser is offline — the connectors' read ladder
|
|
50
|
+
// answers from the offline cache, and the 'online' default would pause before the queryFn
|
|
51
|
+
// ever ran. Not 'always': that would also stop reconnect refetches.
|
|
52
|
+
networkMode: "offlineFirst",
|
|
53
|
+
// 'offlineFirst' force-runs only the FIRST attempt; a retry while offline pauses instead,
|
|
54
|
+
// leaving a cache miss pending forever. Fail it now — refetchOnReconnect recovers.
|
|
55
|
+
retry: (failureCount, error) => react_query_1.onlineManager.isOnline() &&
|
|
56
|
+
failureCount < 2 &&
|
|
57
|
+
shouldRetryConnectorError(error),
|
|
50
58
|
...overrides?.queries,
|
|
51
59
|
},
|
|
52
60
|
mutations: {
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { QueryClient } from "@tanstack/react-query";
|
|
2
|
+
/**
|
|
3
|
+
* Prefetches what every dependency declared in `rise-x-app.json` needs: the flow
|
|
4
|
+
* config and layouts of a flow or asset type, the agent document of an agent (its
|
|
5
|
+
* run stream is SSE, so there is nothing cacheable to warm there). No-ops until
|
|
6
|
+
* the shell reports an environment — the query keys are environment-scoped, and
|
|
7
|
+
* prefetchQuery (unlike the hooks) does not honour `enabled`, so fetching early
|
|
8
|
+
* would fill a null-scoped key — and no-ops when the app declares no manifest,
|
|
9
|
+
* so a `void`-called effect never turns a missing manifest into an unhandled
|
|
10
|
+
* rejection.
|
|
11
|
+
*
|
|
12
|
+
* Pass the client the SDK hooks use, or the warm lands somewhere they never
|
|
13
|
+
* read from:
|
|
14
|
+
*
|
|
15
|
+
* ```tsx
|
|
16
|
+
* const client = useAppQueryClient();
|
|
17
|
+
* useEffect(() => {
|
|
18
|
+
* void prefetchAppDependencies(client);
|
|
19
|
+
* }, [client]);
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare function prefetchAppDependencies(client: QueryClient): Promise<void>;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.prefetchAppDependencies = prefetchAppDependencies;
|
|
4
|
+
const bound_1 = require("../dependencies/bound");
|
|
5
|
+
const agents_1 = require("./agents");
|
|
6
|
+
const flows_1 = require("./flows");
|
|
7
|
+
const shared_1 = require("./shared");
|
|
8
|
+
// null is a flow that does not exist (a 404 from getConfig), undefined is a
|
|
9
|
+
// config that was never cached; neither has layouts to warm.
|
|
10
|
+
function layoutIdsOf(config) {
|
|
11
|
+
const ids = new Set();
|
|
12
|
+
for (const step of config?.steps ?? []) {
|
|
13
|
+
for (const task of step.tasks) {
|
|
14
|
+
if (task.layoutId)
|
|
15
|
+
ids.add(task.layoutId);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return [...ids];
|
|
19
|
+
}
|
|
20
|
+
async function prefetchFlowDependency(client, flowOriginId) {
|
|
21
|
+
const config = flows_1.flowQueries.config(flowOriginId);
|
|
22
|
+
await client.prefetchQuery(config);
|
|
23
|
+
// Read back rather than returning from prefetchQuery (which resolves void):
|
|
24
|
+
// an already-cached config short-circuits the fetch and still gives us the
|
|
25
|
+
// layout ids.
|
|
26
|
+
const layouts = layoutIdsOf(client.getQueryData(config.queryKey));
|
|
27
|
+
await Promise.all(layouts.map((layoutId) => client.prefetchQuery(flows_1.flowQueries.layout(layoutId))));
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Prefetches what every dependency declared in `rise-x-app.json` needs: the flow
|
|
31
|
+
* config and layouts of a flow or asset type, the agent document of an agent (its
|
|
32
|
+
* run stream is SSE, so there is nothing cacheable to warm there). No-ops until
|
|
33
|
+
* the shell reports an environment — the query keys are environment-scoped, and
|
|
34
|
+
* prefetchQuery (unlike the hooks) does not honour `enabled`, so fetching early
|
|
35
|
+
* would fill a null-scoped key — and no-ops when the app declares no manifest,
|
|
36
|
+
* so a `void`-called effect never turns a missing manifest into an unhandled
|
|
37
|
+
* rejection.
|
|
38
|
+
*
|
|
39
|
+
* Pass the client the SDK hooks use, or the warm lands somewhere they never
|
|
40
|
+
* read from:
|
|
41
|
+
*
|
|
42
|
+
* ```tsx
|
|
43
|
+
* const client = useAppQueryClient();
|
|
44
|
+
* useEffect(() => {
|
|
45
|
+
* void prefetchAppDependencies(client);
|
|
46
|
+
* }, [client]);
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
async function prefetchAppDependencies(client) {
|
|
50
|
+
if ((0, shared_1.getLiveEnvId)() == null)
|
|
51
|
+
return;
|
|
52
|
+
const deps = (0, bound_1.tryGetAppDependencies)();
|
|
53
|
+
if (!deps)
|
|
54
|
+
return;
|
|
55
|
+
// Deduped: two aliases may point at the same flow or agent.
|
|
56
|
+
const flowOriginIds = new Set();
|
|
57
|
+
const agentIds = new Set();
|
|
58
|
+
for (const dep of Object.values(deps)) {
|
|
59
|
+
if (dep.kind === "agent")
|
|
60
|
+
agentIds.add(dep.agentId);
|
|
61
|
+
// Nothing to warm: unlike a flow/asset type there is no config document a
|
|
62
|
+
// federated app can read (the integration's own definition carries secret
|
|
63
|
+
// parameters), and invoke's result is per-call, not cacheable app config.
|
|
64
|
+
else if (dep.kind === "integration")
|
|
65
|
+
continue;
|
|
66
|
+
else
|
|
67
|
+
flowOriginIds.add(dep.flowOriginId);
|
|
68
|
+
}
|
|
69
|
+
await Promise.all([
|
|
70
|
+
...[...flowOriginIds].map((flowOriginId) => prefetchFlowDependency(client, flowOriginId)),
|
|
71
|
+
...[...agentIds].map((agentId) => client.prefetchQuery(agents_1.agentQueries.detail(agentId))),
|
|
72
|
+
]);
|
|
73
|
+
}
|
package/build/query/flows.d.ts
CHANGED
|
@@ -23,15 +23,15 @@ export declare function createFlowQueries(connector: FlowsConnector, getEnvId: (
|
|
|
23
23
|
} & {
|
|
24
24
|
queryKey: import("@tanstack/react-query").DataTag<readonly ["rise-apps-sdk", QueryEnvId, "flows", "detail", string], Flow>;
|
|
25
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;
|
|
26
|
+
config: (flowId: string) => import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<FlowConfig | null, Error, FlowConfig | null, readonly ["rise-apps-sdk", QueryEnvId, "flows", "config", string]>, "queryFn"> & {
|
|
27
|
+
queryFn?: import("@tanstack/react-query").QueryFunction<FlowConfig | null, readonly ["rise-apps-sdk", QueryEnvId, "flows", "config", string], never> | undefined;
|
|
28
28
|
} & {
|
|
29
|
-
queryKey: import("@tanstack/react-query").DataTag<readonly ["rise-apps-sdk", QueryEnvId, "flows", "config", string], FlowConfig>;
|
|
29
|
+
queryKey: import("@tanstack/react-query").DataTag<readonly ["rise-apps-sdk", QueryEnvId, "flows", "config", string], FlowConfig | null>;
|
|
30
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;
|
|
31
|
+
layout: (layoutId: string) => import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<Layout | null, Error, Layout | null, readonly ["rise-apps-sdk", QueryEnvId, "flows", "layout", string]>, "queryFn"> & {
|
|
32
|
+
queryFn?: import("@tanstack/react-query").QueryFunction<Layout | null, readonly ["rise-apps-sdk", QueryEnvId, "flows", "layout", string], never> | undefined;
|
|
33
33
|
} & {
|
|
34
|
-
queryKey: import("@tanstack/react-query").DataTag<readonly ["rise-apps-sdk", QueryEnvId, "flows", "layout", string], Layout>;
|
|
34
|
+
queryKey: import("@tanstack/react-query").DataTag<readonly ["rise-apps-sdk", QueryEnvId, "flows", "layout", string], Layout | null>;
|
|
35
35
|
};
|
|
36
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
37
|
[x: string]: unknown;
|
|
@@ -49,6 +49,6 @@ export type FlowQueries = ReturnType<typeof createFlowQueries>;
|
|
|
49
49
|
export declare const flowQueries: FlowQueries;
|
|
50
50
|
export declare function useFlows(args?: ListFlowsQueryArgs, options?: SdkQueryOptions): UseQueryResult<FlowSummary[], ConnectorError>;
|
|
51
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>;
|
|
52
|
+
export declare function useFlowConfig(flowId: string, options?: SdkQueryOptions): UseQueryResult<FlowConfig | null, ConnectorError>;
|
|
53
|
+
export declare function useFlowLayout(layoutId: string, options?: SdkQueryOptions): UseQueryResult<Layout | null, ConnectorError>;
|
|
54
54
|
export declare function useFlowTask(args: FindTaskQueryArgs, options?: SdkQueryOptions): UseQueryResult<FindTaskResult | null, ConnectorError>;
|
package/build/query/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export { createAppQueryClient, getFallbackAppClient, shouldRetryConnectorError,
|
|
|
4
4
|
export { AppQueryProvider, useAppQueryClient } from "./context";
|
|
5
5
|
export { getLiveEnvId, invalidateAppSdkQueries, type SdkMutationOptions, type SdkQueryOptions, } from "./shared";
|
|
6
6
|
export { createQueryLayer, type QueryLayer } from "./layer";
|
|
7
|
+
export { prefetchAppDependencies } from "./dependencies";
|
|
7
8
|
export { createFlowQueries, flowQueries, useFlow, useFlowConfig, useFlowLayout, useFlows, useFlowTask, type FindTaskQueryArgs, type FlowQueries, type ListFlowsQueryArgs, } from "./flows";
|
|
8
9
|
export { createWorkQueries, dedupeRows, useDeleteWork, usePatchWorkData, useRelatedWork, useStartWork, useSubmitWork, useWork, useWorkAudit, useWorkData, useWorkRows, useWorkSearch, workQueries, type DeleteWorkVariables, type ListRelatedWorkQueryArgs, type ListWorkRowsQueryArgs, type PatchWorkDataVariables, type SearchWorkQueryArgs, type StartWorkVariables, type SubmitWorkVariables, type WorkQueries, } from "./work";
|
|
9
10
|
export { assetQueries, createAssetQueries, useAsset, useAssetQuickSearch, useAssetRows, useAssetSearch, useAssetTypes, useCloneAsset, useCreateAsset, useDeleteAsset, useRelatedAssets, useStartEditAsset, type AssetQueries, type CloneAssetVariables, type CreateAssetVariables, type DeleteAssetVariables, type ListAssetRowsQueryArgs, type ListRelatedAssetsQueryArgs, type QuickSearchAssetsQueryArgs, type SearchAssetsQueryArgs, type StartEditAssetVariables, } from "./assets";
|
package/build/query/index.js
CHANGED
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
// Deliberately NOT re-exported from the package root: apps that don't import
|
|
22
22
|
// this subpath never load react-query.
|
|
23
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
-
exports.
|
|
25
|
-
exports.ConnectorError = exports.useUpdateAgent = exports.useRenameAgentChat = exports.useDeleteAgentChat = exports.useDeleteAgent = exports.useCreateAgent = exports.useAgents = void 0;
|
|
24
|
+
exports.useAgentChatMessages = exports.useAgentChat = exports.useAgent = exports.createAgentQueries = exports.agentQueries = exports.useStartEditAsset = exports.useRelatedAssets = exports.useDeleteAsset = exports.useCreateAsset = exports.useCloneAsset = exports.useAssetTypes = exports.useAssetSearch = exports.useAssetRows = exports.useAssetQuickSearch = exports.useAsset = exports.createAssetQueries = exports.assetQueries = exports.workQueries = exports.useWorkSearch = exports.useWorkRows = exports.useWorkData = exports.useWorkAudit = exports.useWork = exports.useSubmitWork = exports.useStartWork = exports.useRelatedWork = exports.usePatchWorkData = exports.useDeleteWork = exports.dedupeRows = exports.createWorkQueries = exports.useFlowTask = exports.useFlows = exports.useFlowLayout = exports.useFlowConfig = exports.useFlow = exports.flowQueries = exports.createFlowQueries = exports.prefetchAppDependencies = exports.createQueryLayer = exports.invalidateAppSdkQueries = exports.getLiveEnvId = exports.useAppQueryClient = exports.AppQueryProvider = exports.shouldRetryConnectorError = exports.getFallbackAppClient = exports.createAppQueryClient = exports.searchCacheShape = exports.QUERY_KEY_ROOT = exports.queryKeys = exports.normalizeArgs = void 0;
|
|
25
|
+
exports.ConnectorError = exports.useUpdateAgent = exports.useRenameAgentChat = exports.useDeleteAgentChat = exports.useDeleteAgent = exports.useCreateAgent = exports.useAgents = exports.useAgentChats = void 0;
|
|
26
26
|
var keys_1 = require("./keys");
|
|
27
27
|
Object.defineProperty(exports, "normalizeArgs", { enumerable: true, get: function () { return keys_1.normalizeArgs; } });
|
|
28
28
|
Object.defineProperty(exports, "queryKeys", { enumerable: true, get: function () { return keys_1.queryKeys; } });
|
|
@@ -44,6 +44,8 @@ Object.defineProperty(exports, "getLiveEnvId", { enumerable: true, get: function
|
|
|
44
44
|
Object.defineProperty(exports, "invalidateAppSdkQueries", { enumerable: true, get: function () { return shared_1.invalidateAppSdkQueries; } });
|
|
45
45
|
var layer_1 = require("./layer");
|
|
46
46
|
Object.defineProperty(exports, "createQueryLayer", { enumerable: true, get: function () { return layer_1.createQueryLayer; } });
|
|
47
|
+
var dependencies_1 = require("./dependencies");
|
|
48
|
+
Object.defineProperty(exports, "prefetchAppDependencies", { enumerable: true, get: function () { return dependencies_1.prefetchAppDependencies; } });
|
|
47
49
|
var flows_1 = require("./flows");
|
|
48
50
|
Object.defineProperty(exports, "createFlowQueries", { enumerable: true, get: function () { return flows_1.createFlowQueries; } });
|
|
49
51
|
Object.defineProperty(exports, "flowQueries", { enumerable: true, get: function () { return flows_1.flowQueries; } });
|
package/build/query/layer.d.ts
CHANGED
|
@@ -18,15 +18,15 @@ export declare function createQueryLayer(deps?: ConnectorDeps): {
|
|
|
18
18
|
} & {
|
|
19
19
|
queryKey: import("@tanstack/query-core").DataTag<readonly ["rise-apps-sdk", QueryEnvId, "flows", "detail", string], import("../connectors").Flow>;
|
|
20
20
|
};
|
|
21
|
-
config: (flowId: string) => import("@tanstack/query-core").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<import("../connectors").FlowConfig, Error, import("../connectors").FlowConfig, readonly ["rise-apps-sdk", QueryEnvId, "flows", "config", string]>, "queryFn"> & {
|
|
22
|
-
queryFn?: import("@tanstack/query-core").QueryFunction<import("../connectors").FlowConfig, readonly ["rise-apps-sdk", QueryEnvId, "flows", "config", string], never> | undefined;
|
|
21
|
+
config: (flowId: string) => import("@tanstack/query-core").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<import("../connectors").FlowConfig | null, Error, import("../connectors").FlowConfig | null, readonly ["rise-apps-sdk", QueryEnvId, "flows", "config", string]>, "queryFn"> & {
|
|
22
|
+
queryFn?: import("@tanstack/query-core").QueryFunction<import("../connectors").FlowConfig | null, readonly ["rise-apps-sdk", QueryEnvId, "flows", "config", string], never> | undefined;
|
|
23
23
|
} & {
|
|
24
|
-
queryKey: import("@tanstack/query-core").DataTag<readonly ["rise-apps-sdk", QueryEnvId, "flows", "config", string], import("../connectors").FlowConfig>;
|
|
24
|
+
queryKey: import("@tanstack/query-core").DataTag<readonly ["rise-apps-sdk", QueryEnvId, "flows", "config", string], import("../connectors").FlowConfig | null>;
|
|
25
25
|
};
|
|
26
|
-
layout: (layoutId: string) => import("@tanstack/query-core").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<import("../connectors").Layout, Error, import("../connectors").Layout, readonly ["rise-apps-sdk", QueryEnvId, "flows", "layout", string]>, "queryFn"> & {
|
|
27
|
-
queryFn?: import("@tanstack/query-core").QueryFunction<import("../connectors").Layout, readonly ["rise-apps-sdk", QueryEnvId, "flows", "layout", string], never> | undefined;
|
|
26
|
+
layout: (layoutId: string) => import("@tanstack/query-core").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<import("../connectors").Layout | null, Error, import("../connectors").Layout | null, readonly ["rise-apps-sdk", QueryEnvId, "flows", "layout", string]>, "queryFn"> & {
|
|
27
|
+
queryFn?: import("@tanstack/query-core").QueryFunction<import("../connectors").Layout | null, readonly ["rise-apps-sdk", QueryEnvId, "flows", "layout", string], never> | undefined;
|
|
28
28
|
} & {
|
|
29
|
-
queryKey: import("@tanstack/query-core").DataTag<readonly ["rise-apps-sdk", QueryEnvId, "flows", "layout", string], import("../connectors").Layout>;
|
|
29
|
+
queryKey: import("@tanstack/query-core").DataTag<readonly ["rise-apps-sdk", QueryEnvId, "flows", "layout", string], import("../connectors").Layout | null>;
|
|
30
30
|
};
|
|
31
31
|
task: (args: import("./flows").FindTaskQueryArgs) => import("@tanstack/query-core").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<import("../connectors/flows").FindTaskResult | null, Error, import("../connectors/flows").FindTaskResult | null, readonly ["rise-apps-sdk", QueryEnvId, "flows", "task", {
|
|
32
32
|
[x: string]: unknown;
|
|
@@ -41,10 +41,10 @@ export declare function createQueryLayer(deps?: ConnectorDeps): {
|
|
|
41
41
|
};
|
|
42
42
|
};
|
|
43
43
|
workQueries: {
|
|
44
|
-
detail: (workId: string) => import("@tanstack/query-core").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<import("../connectors").WorkDetail, Error, import("../connectors").WorkDetail, readonly ["rise-apps-sdk", QueryEnvId, "work", "detail", string]>, "queryFn"> & {
|
|
45
|
-
queryFn?: import("@tanstack/query-core").QueryFunction<import("../connectors").WorkDetail, readonly ["rise-apps-sdk", QueryEnvId, "work", "detail", string], never> | undefined;
|
|
44
|
+
detail: (workId: string) => import("@tanstack/query-core").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<import("../connectors").WorkDetail | null, Error, import("../connectors").WorkDetail | null, readonly ["rise-apps-sdk", QueryEnvId, "work", "detail", string]>, "queryFn"> & {
|
|
45
|
+
queryFn?: import("@tanstack/query-core").QueryFunction<import("../connectors").WorkDetail | null, readonly ["rise-apps-sdk", QueryEnvId, "work", "detail", string], never> | undefined;
|
|
46
46
|
} & {
|
|
47
|
-
queryKey: import("@tanstack/query-core").DataTag<readonly ["rise-apps-sdk", QueryEnvId, "work", "detail", string], import("../connectors").WorkDetail>;
|
|
47
|
+
queryKey: import("@tanstack/query-core").DataTag<readonly ["rise-apps-sdk", QueryEnvId, "work", "detail", string], import("../connectors").WorkDetail | null>;
|
|
48
48
|
};
|
|
49
49
|
data: (workId: string, opts?: {
|
|
50
50
|
path?: string;
|
package/build/query/shared.js
CHANGED
|
@@ -82,12 +82,19 @@ function useEnvSubscription() {
|
|
|
82
82
|
const [, setEnv] = (0, react_1.useState)(() => shell?.getEnvironment() ?? null);
|
|
83
83
|
(0, react_1.useEffect)(() => shell?.subscribeEnvironment(setEnv), [shell]);
|
|
84
84
|
}
|
|
85
|
+
// A per-call `retry` count (or `true`) would replace the client default and with it the offline
|
|
86
|
+
// guard, resurrecting the paused-forever pending on an offline cache miss (see client.ts).
|
|
87
|
+
// Compose instead: honour the cap, keep the guard. `false`/`0` already error immediately.
|
|
88
|
+
const guardRetry = (retry) => (failureCount) => react_query_1.onlineManager.isOnline() && (retry === true || failureCount < retry);
|
|
85
89
|
function useSdkQuery(built, options) {
|
|
86
90
|
useEnvSubscription();
|
|
87
91
|
const client = (0, context_1.useAppQueryClient)();
|
|
88
92
|
const merged = {
|
|
89
93
|
...built,
|
|
90
94
|
...options,
|
|
95
|
+
...(typeof options?.retry === "number" || options?.retry === true
|
|
96
|
+
? { retry: guardRetry(options.retry) }
|
|
97
|
+
: {}),
|
|
91
98
|
enabled: built.enabled === true && (options?.enabled ?? true),
|
|
92
99
|
};
|
|
93
100
|
return (0, react_query_1.useQuery)(merged, client);
|
|
@@ -98,6 +105,9 @@ function useSdkInfiniteQuery(built, options) {
|
|
|
98
105
|
const merged = {
|
|
99
106
|
...built,
|
|
100
107
|
...options,
|
|
108
|
+
...(typeof options?.retry === "number" || options?.retry === true
|
|
109
|
+
? { retry: guardRetry(options.retry) }
|
|
110
|
+
: {}),
|
|
101
111
|
enabled: built.enabled === true && (options?.enabled ?? true),
|
|
102
112
|
};
|
|
103
113
|
return (0, react_query_1.useInfiniteQuery)(merged, client);
|
package/build/query/work.d.ts
CHANGED
|
@@ -13,10 +13,10 @@ export declare function dedupeRows<T extends {
|
|
|
13
13
|
items: T[];
|
|
14
14
|
}> | undefined): T[];
|
|
15
15
|
export declare function createWorkQueries(connector: WorkConnector, getEnvId: () => QueryEnvId): {
|
|
16
|
-
detail: (workId: string) => import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<WorkDetail, Error, WorkDetail, readonly ["rise-apps-sdk", QueryEnvId, "work", "detail", string]>, "queryFn"> & {
|
|
17
|
-
queryFn?: import("@tanstack/react-query").QueryFunction<WorkDetail, readonly ["rise-apps-sdk", QueryEnvId, "work", "detail", string], never> | undefined;
|
|
16
|
+
detail: (workId: string) => import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<WorkDetail | null, Error, WorkDetail | null, readonly ["rise-apps-sdk", QueryEnvId, "work", "detail", string]>, "queryFn"> & {
|
|
17
|
+
queryFn?: import("@tanstack/react-query").QueryFunction<WorkDetail | null, readonly ["rise-apps-sdk", QueryEnvId, "work", "detail", string], never> | undefined;
|
|
18
18
|
} & {
|
|
19
|
-
queryKey: import("@tanstack/react-query").DataTag<readonly ["rise-apps-sdk", QueryEnvId, "work", "detail", string], WorkDetail>;
|
|
19
|
+
queryKey: import("@tanstack/react-query").DataTag<readonly ["rise-apps-sdk", QueryEnvId, "work", "detail", string], WorkDetail | null>;
|
|
20
20
|
};
|
|
21
21
|
data: (workId: string, opts?: {
|
|
22
22
|
path?: string;
|
|
@@ -66,7 +66,7 @@ export declare function createWorkQueries(connector: WorkConnector, getEnvId: ()
|
|
|
66
66
|
};
|
|
67
67
|
export type WorkQueries = ReturnType<typeof createWorkQueries>;
|
|
68
68
|
export declare const workQueries: WorkQueries;
|
|
69
|
-
export declare function useWork(workId: string, options?: SdkQueryOptions): UseQueryResult<WorkDetail, ConnectorError>;
|
|
69
|
+
export declare function useWork(workId: string, options?: SdkQueryOptions): UseQueryResult<WorkDetail | null, ConnectorError>;
|
|
70
70
|
export declare function useWorkData(workId: string, opts?: {
|
|
71
71
|
path?: string;
|
|
72
72
|
}, options?: SdkQueryOptions): UseQueryResult<unknown, ConnectorError>;
|
package/build/rsbuild/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { RsbuildConfig } from '@rsbuild/core';
|
|
2
|
+
export { pluginRiseAppManifest, type RiseAppManifestRsbuildPluginOptions, } from './riseAppManifestPlugin';
|
|
2
3
|
export interface AppPackageJson {
|
|
3
4
|
name: string;
|
|
4
5
|
version?: string;
|
|
@@ -24,7 +25,8 @@ export interface DefineAppConfigOptions {
|
|
|
24
25
|
exposes?: Record<string, string>;
|
|
25
26
|
/**
|
|
26
27
|
* Extra `source.define` entries. Values are raw code, so strings arrive
|
|
27
|
-
* quoted: `{ __MODE__: JSON.stringify('sample') }`. `__APP_VERSION__`
|
|
28
|
+
* quoted: `{ __MODE__: JSON.stringify('sample') }`. `__APP_VERSION__` and
|
|
29
|
+
* `__APP_SCOPE__` throw — both are derived here.
|
|
28
30
|
*/
|
|
29
31
|
define?: Record<string, string>;
|
|
30
32
|
}
|
package/build/rsbuild/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.pluginRiseAppManifest = void 0;
|
|
3
4
|
exports.deriveAppScope = deriveAppScope;
|
|
4
5
|
exports.defineAppConfig = defineAppConfig;
|
|
5
6
|
const node_module_1 = require("node:module");
|
|
@@ -7,6 +8,11 @@ const node_path_1 = require("node:path");
|
|
|
7
8
|
const plugin_react_1 = require("@rsbuild/plugin-react");
|
|
8
9
|
const plugin_type_check_1 = require("@rsbuild/plugin-type-check");
|
|
9
10
|
const lifecycle_1 = require("../lifecycle");
|
|
11
|
+
const riseAppManifestPlugin_1 = require("./riseAppManifestPlugin");
|
|
12
|
+
// Re-exported so an app with a hand-rolled Rsbuild config can wire the manifest
|
|
13
|
+
// itself, the way '@rise-x/apps-sdk/webpack' exposes its plugin.
|
|
14
|
+
var riseAppManifestPlugin_2 = require("./riseAppManifestPlugin");
|
|
15
|
+
Object.defineProperty(exports, "pluginRiseAppManifest", { enumerable: true, get: function () { return riseAppManifestPlugin_2.pluginRiseAppManifest; } });
|
|
10
16
|
// The shell validates an app's scope against this, and `uniqueName` (the
|
|
11
17
|
// chunk-loading global) is the same string — so an invalid scope fails at
|
|
12
18
|
// runtime in ways that are hard to trace. Fail at config time instead.
|
|
@@ -76,6 +82,11 @@ function defineAppConfig({ pkg, port, standalone = false, exposes, define, }) {
|
|
|
76
82
|
'from pkg.version so it always matches the deployed manifest. Change the version ' +
|
|
77
83
|
'in package.json instead.');
|
|
78
84
|
}
|
|
85
|
+
if (define && '__APP_SCOPE__' in define) {
|
|
86
|
+
throw new Error('defineAppConfig: __APP_SCOPE__ cannot be set through `define` — it is derived ' +
|
|
87
|
+
'from pkg.name (or APP_SCOPE) so it always matches the registered MF scope. Set ' +
|
|
88
|
+
'APP_SCOPE instead.');
|
|
89
|
+
}
|
|
79
90
|
const base = {
|
|
80
91
|
// pluginTypeCheck is NOT optional polish. The webpack configs this preset
|
|
81
92
|
// replaces used ts-loader, which type-checked on every build, and that pass
|
|
@@ -85,15 +96,35 @@ function defineAppConfig({ pkg, port, standalone = false, exposes, define, }) {
|
|
|
85
96
|
// packages/ui and ClientApp. Rsbuild transpiles with SWC, which strips
|
|
86
97
|
// types without checking them, so without this `pnpm build` would happily
|
|
87
98
|
// produce a deploy artifact from code that does not compile.
|
|
88
|
-
|
|
99
|
+
//
|
|
100
|
+
// pluginRiseAppManifest resolves the app's rise-x-app.json for ONE
|
|
101
|
+
// environment, emits it into the build output and injects it as a
|
|
102
|
+
// compile-time constant. In BOTH modes: standalone dev of an app that reads
|
|
103
|
+
// useAppDependencies() then works without re-declaring the ids by hand.
|
|
104
|
+
plugins: [(0, plugin_react_1.pluginReact)(), (0, plugin_type_check_1.pluginTypeCheck)(), (0, riseAppManifestPlugin_1.pluginRiseAppManifest)()],
|
|
89
105
|
source: {
|
|
90
106
|
entry: { index: './src/index.tsx' },
|
|
91
107
|
define: {
|
|
92
108
|
...define,
|
|
93
109
|
__APP_VERSION__: JSON.stringify(pkg.version ?? '0.0.0'),
|
|
110
|
+
// The app's own MF scope, for connectors that label requests with it
|
|
111
|
+
// (e.g. the vector-stores connector's X-Rise-App header). The same
|
|
112
|
+
// spelling is also the scaffolder's text-replacement token (cli/init.ts)
|
|
113
|
+
// — a template file that writes it gets substituted at `init` time and
|
|
114
|
+
// never reaches this define.
|
|
115
|
+
__APP_SCOPE__: JSON.stringify(scope),
|
|
94
116
|
},
|
|
95
117
|
},
|
|
96
118
|
html: { template: './public/index.html' },
|
|
119
|
+
output: {
|
|
120
|
+
// The app's CSS rides inside its JS: a host does no CSS chunk loading for remotes.
|
|
121
|
+
injectStyles: true,
|
|
122
|
+
},
|
|
123
|
+
tools: {
|
|
124
|
+
// Apps compile their own Tailwind utilities; the host ships only the design system's.
|
|
125
|
+
// `require`, not `import`: moduleResolution 'node' cannot follow @tailwindcss/postcss's `exports`.
|
|
126
|
+
postcss: (_, { addPlugins }) => addPlugins(require('@tailwindcss/postcss')()),
|
|
127
|
+
},
|
|
97
128
|
server: {
|
|
98
129
|
port,
|
|
99
130
|
historyApiFallback: true,
|
|
@@ -110,6 +141,7 @@ function defineAppConfig({ pkg, port, standalone = false, exposes, define, }) {
|
|
|
110
141
|
return {
|
|
111
142
|
...base,
|
|
112
143
|
output: {
|
|
144
|
+
...base.output,
|
|
113
145
|
distPath: { root: 'dist-local' },
|
|
114
146
|
assetPrefix: '/',
|
|
115
147
|
},
|
|
@@ -136,6 +168,7 @@ function defineAppConfig({ pkg, port, standalone = false, exposes, define, }) {
|
|
|
136
168
|
return {
|
|
137
169
|
...base,
|
|
138
170
|
output: {
|
|
171
|
+
...base.output,
|
|
139
172
|
// Flat dist: remoteEntry.js plus its sibling chunks at the archive root.
|
|
140
173
|
// tools/apps-dev-server probes `dist/remoteEntry.js`, and the deploy zips
|
|
141
174
|
// the CONTENTS of dist/ with remoteEntry.js at the top level.
|
|
@@ -172,6 +205,7 @@ function defineAppConfig({ pkg, port, standalone = false, exposes, define, }) {
|
|
|
172
205
|
headers: { 'Access-Control-Allow-Origin': '*' },
|
|
173
206
|
},
|
|
174
207
|
tools: {
|
|
208
|
+
...base.tools,
|
|
175
209
|
rspack: (config, { rspack, appendPlugins, isProd }) => {
|
|
176
210
|
// Rsbuild defaults production source maps OFF; the webpack configs this
|
|
177
211
|
// replaces shipped them, and without them a deployed app is unreadable
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { RsbuildPlugin } from "@rsbuild/core";
|
|
2
|
+
export declare const RISE_APP_MANIFEST_PLUGIN_NAME = "rise-x:app-manifest";
|
|
3
|
+
export interface RiseAppManifestRsbuildPluginOptions {
|
|
4
|
+
/** Directory holding rise-x-app.json. Defaults to the Rsbuild root. */
|
|
5
|
+
context?: string;
|
|
6
|
+
/** Target environment. Defaults to APP_ENV, then DEFAULT_APP_ENVIRONMENT. */
|
|
7
|
+
environment?: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* The Rsbuild half of the app-dependency manifest, and the counterpart of
|
|
11
|
+
* RiseAppManifestPlugin from '@rise-x/apps-sdk/webpack'. Resolves the app's
|
|
12
|
+
* `rise-x-app.json` for one environment, emits the result into the build output
|
|
13
|
+
* (so the backend can read the app's dependencies out of the deployed zip), and
|
|
14
|
+
* injects it as a compile-time constant (so `getAppDependencies()` can read it
|
|
15
|
+
* at runtime). No-ops when the app declares no manifest.
|
|
16
|
+
*
|
|
17
|
+
* `defineAppConfig` wires this in, so an app using the preset needs nothing.
|
|
18
|
+
*/
|
|
19
|
+
export declare function pluginRiseAppManifest(options?: RiseAppManifestRsbuildPluginOptions): RsbuildPlugin;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RISE_APP_MANIFEST_PLUGIN_NAME = void 0;
|
|
4
|
+
exports.pluginRiseAppManifest = pluginRiseAppManifest;
|
|
5
|
+
const manifest_1 = require("../manifest");
|
|
6
|
+
const manifestSource_1 = require("../manifestSource");
|
|
7
|
+
exports.RISE_APP_MANIFEST_PLUGIN_NAME = "rise-x:app-manifest";
|
|
8
|
+
// An invalid manifest is a mistake in the app's own rise-x-app.json, and Rsbuild
|
|
9
|
+
// prints the stack of anything thrown from a plugin's setup — frames through the
|
|
10
|
+
// SDK's internals that say nothing about the fix. Report the resolver's message
|
|
11
|
+
// as the whole error.
|
|
12
|
+
function readOrFail(sourcePath, environment) {
|
|
13
|
+
try {
|
|
14
|
+
return (0, manifestSource_1.readResolvedAppManifest)(sourcePath, environment);
|
|
15
|
+
}
|
|
16
|
+
catch (err) {
|
|
17
|
+
// An fs failure (EACCES, EISDIR) carries an errno `code` and is not a
|
|
18
|
+
// mistake in the manifest's contents — it needs its stack to be diagnosable,
|
|
19
|
+
// so let it through untouched.
|
|
20
|
+
if (err.code !== undefined)
|
|
21
|
+
throw err;
|
|
22
|
+
const failure = new Error(`[${exports.RISE_APP_MANIFEST_PLUGIN_NAME}] ${err.message}`);
|
|
23
|
+
failure.stack = failure.message;
|
|
24
|
+
throw failure;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The Rsbuild half of the app-dependency manifest, and the counterpart of
|
|
29
|
+
* RiseAppManifestPlugin from '@rise-x/apps-sdk/webpack'. Resolves the app's
|
|
30
|
+
* `rise-x-app.json` for one environment, emits the result into the build output
|
|
31
|
+
* (so the backend can read the app's dependencies out of the deployed zip), and
|
|
32
|
+
* injects it as a compile-time constant (so `getAppDependencies()` can read it
|
|
33
|
+
* at runtime). No-ops when the app declares no manifest.
|
|
34
|
+
*
|
|
35
|
+
* `defineAppConfig` wires this in, so an app using the preset needs nothing.
|
|
36
|
+
*/
|
|
37
|
+
function pluginRiseAppManifest(options = {}) {
|
|
38
|
+
return {
|
|
39
|
+
name: exports.RISE_APP_MANIFEST_PLUGIN_NAME,
|
|
40
|
+
setup(api) {
|
|
41
|
+
const sourcePath = (0, manifestSource_1.appManifestPath)(options.context || api.context.rootPath);
|
|
42
|
+
const environment = (0, manifestSource_1.targetAppEnvironment)(options.environment);
|
|
43
|
+
// Read ONCE per config load, and shared by both hooks below, so the
|
|
44
|
+
// emitted file and the injected constant can never disagree.
|
|
45
|
+
const resolved = readOrFail(sourcePath, environment);
|
|
46
|
+
api.modifyRsbuildConfig((config, { mergeRsbuildConfig }) => mergeRsbuildConfig(config, {
|
|
47
|
+
// Injected as a per-bundle compile-time constant rather than assigned
|
|
48
|
+
// to a real runtime global: several federated apps share one page, and
|
|
49
|
+
// a real global would let the last one loaded serve its ids to all of
|
|
50
|
+
// them.
|
|
51
|
+
// Defined even with no manifest, so the read is substituted rather
|
|
52
|
+
// than left live against the real globalThis another app can write.
|
|
53
|
+
source: {
|
|
54
|
+
define: {
|
|
55
|
+
[manifestSource_1.MANIFEST_GLOBAL_EXPRESSION]: resolved
|
|
56
|
+
? JSON.stringify(resolved)
|
|
57
|
+
: "undefined",
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
// Re-resolving takes a config re-evaluation: rspack's DefinePlugin has
|
|
61
|
+
// no `runtimeValue` (webpack's does — see the webpack plugin), so the
|
|
62
|
+
// constant is fixed once this config object is built. 'reload-server'
|
|
63
|
+
// restarts `rsbuild dev` and `rsbuild build --watch`, which re-runs
|
|
64
|
+
// this plugin against the edited file. Registered even with no
|
|
65
|
+
// manifest present, so adding one later also takes effect.
|
|
66
|
+
dev: { watchFiles: [{ paths: sourcePath, type: "reload-server" }] },
|
|
67
|
+
}));
|
|
68
|
+
if (!resolved)
|
|
69
|
+
return;
|
|
70
|
+
const contents = (0, manifestSource_1.formatResolvedAppManifest)(resolved);
|
|
71
|
+
// rspack's processAssets hook, through Rsbuild's wrapper. 'additional' is
|
|
72
|
+
// rspack's PROCESS_ASSETS_STAGE_ADDITIONAL — the stage for adding assets
|
|
73
|
+
// no other plugin's output depends on.
|
|
74
|
+
api.processAssets({ stage: "additional" }, ({ compilation, sources }) => {
|
|
75
|
+
compilation.emitAsset(manifest_1.APP_MANIFEST_FILENAME, new sources.RawSource(contents));
|
|
76
|
+
});
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
}
|