@nanobpm/urban 0.6.0 → 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.
@@ -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;
@@ -61,6 +61,8 @@ export type {
61
61
  Row,
62
62
  TableMeta,
63
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";
64
66
  export type { AppJobHandler } from "./core/modules/workers.ts";
65
67
  export { resolveHandler } from "./core/modules/workers.ts";
66
68
  export { evalCorrelation } from "./core/modules/triggers.ts";