@nanobpm/urban 0.5.1 → 0.7.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/dist/runtime/core/host.d.ts +4 -0
- package/dist/runtime/core/manifest.d.ts +8 -0
- package/dist/runtime/core/modules/datasource.d.ts +9 -0
- package/dist/runtime/core/modules/datasource.js +12 -0
- package/dist/runtime/core/modules/gateway.d.ts +81 -0
- package/dist/runtime/core/modules/gateway.js +170 -0
- package/dist/runtime/core/modules/pages.d.ts +42 -0
- package/dist/runtime/core/modules/pages.js +670 -0
- package/dist/runtime/core/modules/surfaces.js +7 -0
- package/dist/runtime/engine/nanosdk.d.ts +6 -0
- package/dist/runtime/engine/nanosdk.js +3 -0
- package/dist/runtime/index.d.ts +4 -0
- package/dist/runtime/index.js +2 -0
- package/package.json +1 -1
- package/src/runtime/core/host.ts +2 -0
- package/src/runtime/core/manifest.ts +8 -0
- package/src/runtime/core/modules/datasource.ts +20 -0
- package/src/runtime/core/modules/gateway.test.ts +164 -0
- package/src/runtime/core/modules/gateway.ts +274 -0
- package/src/runtime/core/modules/pages.test.ts +224 -0
- package/src/runtime/core/modules/pages.ts +705 -0
- package/src/runtime/core/modules/surfaces.ts +8 -0
- package/src/runtime/core/runtime.test.ts +4 -0
- package/src/runtime/engine/nanosdk.test.ts +18 -0
- package/src/runtime/engine/nanosdk.ts +8 -0
- package/src/runtime/index.ts +11 -0
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import type { AppApi, RuntimeContext } from "../context.ts";
|
|
7
7
|
import { html, json, normalizeRoutePath, type Route } from "../router.ts";
|
|
8
|
+
import { mountPages } from "./pages.ts";
|
|
8
9
|
|
|
9
10
|
/** Escape HTML-significant characters before embedding a value in markup. */
|
|
10
11
|
function escapeHtml(s: string): string {
|
|
@@ -98,6 +99,13 @@ export function mountSurfaces(ctx: RuntimeContext, app: AppApi): SurfacesHandle
|
|
|
98
99
|
});
|
|
99
100
|
}
|
|
100
101
|
|
|
102
|
+
// The pages surface (the schema-driven page runtime) mounts its own routes.
|
|
103
|
+
const pages = mountPages(ctx, app);
|
|
104
|
+
if (pages.routes.length > 0) {
|
|
105
|
+
routes.push(...pages.routes);
|
|
106
|
+
enabled.push("pages@/");
|
|
107
|
+
}
|
|
108
|
+
|
|
101
109
|
ctx.host.log("info", "surfaces mounted", { enabled });
|
|
102
110
|
return { name: "surfaces", routes, describe: () => ({ enabled }) };
|
|
103
111
|
}
|
|
@@ -18,6 +18,7 @@ class FakeEngine implements EngineClient {
|
|
|
18
18
|
deployed = 0;
|
|
19
19
|
workers = new Map<string, JobHandler>();
|
|
20
20
|
messages: { name: string; correlationKey?: string; variables?: Record<string, unknown> }[] = [];
|
|
21
|
+
canceledInstances: string[] = [];
|
|
21
22
|
completedTasks: { key: string; variables?: Record<string, unknown> }[] = [];
|
|
22
23
|
userTasks = [{ userTaskKey: "ut-1", elementId: "approve", variables: {} }];
|
|
23
24
|
|
|
@@ -28,6 +29,9 @@ class FakeEngine implements EngineClient {
|
|
|
28
29
|
async createInstance() {
|
|
29
30
|
return { processInstanceKey: "pi-1" };
|
|
30
31
|
}
|
|
32
|
+
async cancelInstance(input: { processInstanceKey: string }) {
|
|
33
|
+
this.canceledInstances.push(input.processInstanceKey);
|
|
34
|
+
}
|
|
31
35
|
async publishMessage(input: { name: string; correlationKey?: string; variables?: Record<string, unknown> }) {
|
|
32
36
|
this.messages.push(input);
|
|
33
37
|
}
|
|
@@ -53,6 +53,10 @@ function fakeSdkClient(overrides: Partial<NanoSdkClient> = {}): NanoSdkClient &
|
|
|
53
53
|
calls.push("createProcessInstance");
|
|
54
54
|
return { processInstanceKey: 99, variables: input.variables };
|
|
55
55
|
},
|
|
56
|
+
async cancelProcessInstance(input) {
|
|
57
|
+
calls.push("cancelProcessInstance");
|
|
58
|
+
return { ...input };
|
|
59
|
+
},
|
|
56
60
|
async publishMessage(input) {
|
|
57
61
|
calls.push("publishMessage");
|
|
58
62
|
return { key: 1, ...input };
|
|
@@ -131,6 +135,20 @@ test("createInstance throws when the SDK response omits the instance key", async
|
|
|
131
135
|
);
|
|
132
136
|
});
|
|
133
137
|
|
|
138
|
+
test("cancelInstance routes through the SDK", async () => {
|
|
139
|
+
let seen: { processInstanceKey: string | number } | undefined;
|
|
140
|
+
const client = fakeSdkClient({
|
|
141
|
+
cancelProcessInstance: async (input) => {
|
|
142
|
+
seen = input;
|
|
143
|
+
return {};
|
|
144
|
+
},
|
|
145
|
+
});
|
|
146
|
+
const engine = new SdkEngineClient(client);
|
|
147
|
+
await engine.cancelInstance({ processInstanceKey: "pi-7" });
|
|
148
|
+
assert.deepEqual(seen, { processInstanceKey: "pi-7" });
|
|
149
|
+
assert.ok(client.calls.includes("cancelProcessInstance") || seen !== undefined);
|
|
150
|
+
});
|
|
151
|
+
|
|
134
152
|
test("publishMessage defaults correlationKey/variables", async () => {
|
|
135
153
|
let seen: Record<string, unknown> | undefined;
|
|
136
154
|
const client = fakeSdkClient({
|
|
@@ -79,6 +79,10 @@ export interface NanoSdkClient {
|
|
|
79
79
|
},
|
|
80
80
|
options?: unknown,
|
|
81
81
|
): Promise<Record<string, unknown>>;
|
|
82
|
+
cancelProcessInstance(
|
|
83
|
+
input: { processInstanceKey: string | number },
|
|
84
|
+
options?: unknown,
|
|
85
|
+
): Promise<unknown>;
|
|
82
86
|
publishMessage(
|
|
83
87
|
input: { name: string; correlationKey?: string; variables?: Record<string, unknown> },
|
|
84
88
|
options?: unknown,
|
|
@@ -150,6 +154,10 @@ export class SdkEngineClient implements EngineClient {
|
|
|
150
154
|
};
|
|
151
155
|
}
|
|
152
156
|
|
|
157
|
+
async cancelInstance(input: { processInstanceKey: string }): Promise<void> {
|
|
158
|
+
await this.client.cancelProcessInstance({ processInstanceKey: input.processInstanceKey });
|
|
159
|
+
}
|
|
160
|
+
|
|
153
161
|
async publishMessage(input: {
|
|
154
162
|
name: string;
|
|
155
163
|
correlationKey?: string;
|
package/src/runtime/index.ts
CHANGED
|
@@ -52,6 +52,17 @@ export type { AppApi, Mounted, RuntimeContext } from "./core/context.ts";
|
|
|
52
52
|
// Data layer
|
|
53
53
|
export { DataLayer, TypeRepo } from "./core/modules/datasource.ts";
|
|
54
54
|
export type { ProvisionedSource } from "./core/modules/datasource.ts";
|
|
55
|
+
export { makeGateway, Table } from "./core/modules/gateway.ts";
|
|
56
|
+
export type {
|
|
57
|
+
ColumnMeta,
|
|
58
|
+
DataSource as GatewayDataSource,
|
|
59
|
+
ExecResult,
|
|
60
|
+
ForeignKeyMeta,
|
|
61
|
+
Row,
|
|
62
|
+
TableMeta,
|
|
63
|
+
} from "./core/modules/gateway.ts";
|
|
64
|
+
export { createPagesRoutes, mountPages } from "./core/modules/pages.ts";
|
|
65
|
+
export type { PagesDataSource, PagesDeps, PagesHandle, PagesOptions } from "./core/modules/pages.ts";
|
|
55
66
|
export type { AppJobHandler } from "./core/modules/workers.ts";
|
|
56
67
|
export { resolveHandler } from "./core/modules/workers.ts";
|
|
57
68
|
export { evalCorrelation } from "./core/modules/triggers.ts";
|