@nanobpm/urban 0.38.0 → 0.40.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 +37 -0
- package/dist/cli.js +6 -0
- package/dist/runtime/adapters/deno.js +18 -2
- package/dist/runtime/adapters/node.js +17 -5
- package/dist/runtime/core/context.d.ts +10 -1
- package/dist/runtime/core/host.d.ts +9 -2
- package/dist/runtime/core/logger.d.ts +69 -0
- package/dist/runtime/core/logger.js +134 -0
- package/dist/runtime/core/modules/api.js +7 -1
- package/dist/runtime/core/modules/pages.js +52 -4
- package/dist/runtime/core/modules/workers.js +16 -1
- package/dist/runtime/core/runtime.d.ts +5 -0
- package/dist/runtime/core/runtime.js +7 -1
- package/dist/runtime/engine/nanosdk.d.ts +1 -1
- package/dist/runtime/index.d.ts +1 -0
- package/dist/toolkit/artifact.d.ts +11 -0
- package/dist/toolkit/artifact.js +18 -0
- package/dist/toolkit/gen.d.ts +2 -0
- package/dist/toolkit/gen.js +24 -2
- package/dist/toolkit/scaffold/operations.js +3 -1
- package/dist/toolkit/scaffold/workers.js +2 -0
- package/dist/worker.d.ts +1 -0
- package/package.json +2 -2
- package/src/cli.ts +6 -0
- package/src/runtime/adapters/deno.ts +17 -4
- package/src/runtime/adapters/node.ts +17 -7
- package/src/runtime/core/context.ts +10 -1
- package/src/runtime/core/host.ts +9 -2
- package/src/runtime/core/logger.test.ts +221 -0
- package/src/runtime/core/logger.ts +177 -0
- package/src/runtime/core/modules/actions.test.ts +2 -1
- package/src/runtime/core/modules/api.test.ts +38 -2
- package/src/runtime/core/modules/api.ts +10 -1
- package/src/runtime/core/modules/cancel.test.ts +4 -1
- package/src/runtime/core/modules/connectors.test.ts +2 -1
- package/src/runtime/core/modules/instance-tracking.test.ts +4 -1
- package/src/runtime/core/modules/pages.test.ts +31 -0
- package/src/runtime/core/modules/pages.ts +52 -4
- package/src/runtime/core/modules/surfaces.test.ts +2 -1
- package/src/runtime/core/modules/triggers.test.ts +4 -1
- package/src/runtime/core/modules/workers.test.ts +59 -2
- package/src/runtime/core/modules/workers.ts +15 -1
- package/src/runtime/core/runtime.test.ts +22 -0
- package/src/runtime/core/runtime.ts +12 -1
- package/src/runtime/devserver.test.ts +2 -0
- package/src/runtime/engine/nanosdk.ts +1 -1
- package/src/runtime/index.ts +2 -0
- package/src/toolkit/artifact.ts +19 -0
- package/src/toolkit/gen.test.ts +53 -0
- package/src/toolkit/gen.ts +27 -2
- package/src/toolkit/scaffold/operations.ts +3 -1
- package/src/toolkit/scaffold/workers.ts +2 -0
- package/src/worker.ts +1 -0
package/src/toolkit/gen.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// pure; all IO is confined here behind a tiny FS port so the same code runs on Node and Deno.
|
|
5
5
|
|
|
6
6
|
import type { DerivedArtifact } from "./artifact.ts";
|
|
7
|
-
import { isAbsolutePath, sortArtifacts } from "./artifact.ts";
|
|
7
|
+
import { GENERATED_DIR, isAbsolutePath, RUNTIME_MATERIALIZED_ARTIFACTS, sortArtifacts } from "./artifact.ts";
|
|
8
8
|
import { deriveMigrations, type ToolkitManifest } from "./derivers/migrations.ts";
|
|
9
9
|
import { deriveDomain } from "./derivers/domain.ts";
|
|
10
10
|
import { deriveWorkerBindings, type ModelSource } from "./derivers/worker-io.ts";
|
|
@@ -51,6 +51,8 @@ export interface GenResult {
|
|
|
51
51
|
artifacts: DerivedArtifact[];
|
|
52
52
|
/** Paths that differ from disk (only populated by `check`). */
|
|
53
53
|
drift: string[];
|
|
54
|
+
/** App-relative paths of stale files removed from `nano-generated/` (only populated in write mode). */
|
|
55
|
+
swept: string[];
|
|
54
56
|
/** True if any code-first workflow failed to import/derive. */
|
|
55
57
|
incomplete: boolean;
|
|
56
58
|
/** Per-file model-derivation errors (empty on success). */
|
|
@@ -199,7 +201,30 @@ export async function runGen(opts: GenOptions & { check?: boolean }): Promise<Ge
|
|
|
199
201
|
}
|
|
200
202
|
}
|
|
201
203
|
|
|
202
|
-
|
|
204
|
+
// Stale-artifact sweep of `nano-generated/` (clean break, nano-bpm#: gen owns its output dir).
|
|
205
|
+
// The dir is gitignored and fully codegen-owned, so any file this run did not (re)write is stale
|
|
206
|
+
// from a prior gen — a renamed or removed artifact (e.g. an old `data_sdk.ts`) whose orphan the
|
|
207
|
+
// app might still import. Remove it. The one exception is the runtime-materialized set: the SDK
|
|
208
|
+
// shims + the `urban data`/console dataops wrappers gen does NOT emit but the app needs at runtime
|
|
209
|
+
// (RUNTIME_MATERIALIZED_ARTIFACTS). Protect those by name. Write mode only; skipped when io.remove
|
|
210
|
+
// is absent (the sweep is best-effort, mirroring the `.bpmn` sweep above). NOT on `modelsOnly`
|
|
211
|
+
// (`urban derive`): that path derives only models, so `artifacts` carries no `nano-generated/*` and
|
|
212
|
+
// sweeping would wrongly wipe the type-contract outputs a prior `urban gen` wrote.
|
|
213
|
+
const swept: string[] = [];
|
|
214
|
+
if (!opts.check && !opts.modelsOnly && !derived.incomplete && io.remove) {
|
|
215
|
+
const keep = new Set(
|
|
216
|
+
artifacts.map((a) => a.path).filter((p) => p.startsWith(`${GENERATED_DIR}/`)),
|
|
217
|
+
);
|
|
218
|
+
for (const name of RUNTIME_MATERIALIZED_ARTIFACTS) keep.add(`${GENERATED_DIR}/${name}`);
|
|
219
|
+
for (const name of await io.listDir(join(root, GENERATED_DIR))) {
|
|
220
|
+
const rel = `${GENERATED_DIR}/${name}`;
|
|
221
|
+
if (keep.has(rel)) continue;
|
|
222
|
+
await io.remove(join(root, rel));
|
|
223
|
+
swept.push(rel);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
return { artifacts, drift, swept: swept.sort(), incomplete: derived.incomplete, modelErrors: derived.errors };
|
|
203
228
|
}
|
|
204
229
|
|
|
205
230
|
export { dirOf, join as joinPath };
|
|
@@ -50,7 +50,9 @@ export function renderOperationStub(operationId: string, dir: string = DEFAULT_O
|
|
|
50
50
|
`\n` +
|
|
51
51
|
`export default defineOperation(${key}, async (input, app) => {\n` +
|
|
52
52
|
` // \`input\` is the validated request (params/query/body/req); reach app state + services\n` +
|
|
53
|
-
` // through the injected \`app\` API.
|
|
53
|
+
` // through the injected \`app\` API. Structured logs via \`app.log.info("…", { … })\` are\n` +
|
|
54
|
+
` // auto-tagged with this request's { method, path, operationId } (ADR 0061).\n` +
|
|
55
|
+
` // Return \`{ status?, headers?, body? }\` (or nothing → 204).\n` +
|
|
54
56
|
` throw new NotImplemented(${key});\n` +
|
|
55
57
|
`});\n`
|
|
56
58
|
);
|
|
@@ -101,6 +101,8 @@ export function renderWorkerStub(
|
|
|
101
101
|
varsNote +
|
|
102
102
|
`\n` +
|
|
103
103
|
` // Reach app state and services through the injected \`app\` API.\n` +
|
|
104
|
+
` // Structured logs: \`app.log.info("done", { … })\` — auto-tagged with this job's\n` +
|
|
105
|
+
` // { jobKey, jobType, processInstanceKey, elementId } (ADR 0061).\n` +
|
|
104
106
|
` throw new Error(${JSON.stringify(`worker not implemented: ${taskType}`)});\n` +
|
|
105
107
|
`};\n` +
|
|
106
108
|
`\n` +
|
package/src/worker.ts
CHANGED
|
@@ -19,3 +19,4 @@
|
|
|
19
19
|
export type { AppJobHandler } from "./runtime/core/modules/workers.ts";
|
|
20
20
|
export type { EngineJob, JobHandler } from "./runtime/core/host.ts";
|
|
21
21
|
export type { AppApi } from "./runtime/core/context.ts";
|
|
22
|
+
export type { Logger, LogLevel, LogFields } from "./runtime/core/logger.ts";
|