@simetrajs/designer 0.0.0-stage → 0.2.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/LICENSE +190 -0
- package/README.md +79 -2
- package/dist/command-BCAw6Fsb.js +794 -0
- package/dist/default-dir-DerxTbci.js +158 -0
- package/dist/errors-Brw6UjAD.js +35 -0
- package/dist/init-jr0Xsrpp.js +832 -0
- package/dist/main.js +29 -0
- package/dist/mcp-ChltmHBb.js +277 -0
- package/dist/mcp-args-D63akJ97.js +56 -0
- package/dist/package-Dg3MXPve.js +4 -0
- package/dist/report-DV4deFdu.js +2059 -0
- package/dist/schema-engine-DPPnife2.js +2809 -0
- package/dist/types-iWavtmdS.js +31 -0
- package/package.json +67 -3
- package/skills/simetra-adoption/SKILL.md +185 -0
- package/skills/simetra-metadata/SKILL.md +494 -0
- package/skills/simetra-metadata/references/agents-over-mcp.md +119 -0
- package/skills/simetra-metadata/references/object-modules.md +60 -0
- package/skills/simetra-metadata/references/people-and-rights.md +757 -0
- package/skills/simetra-metadata/references/project-setup.md +28 -0
- package/skills/simetra-metadata/references/sql-trust-boundary.md +194 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Object modules: TypeScript hooks of a command
|
|
2
|
+
|
|
3
|
+
How the server code of an application adds behaviour to the generated
|
|
4
|
+
commands of an object; the router is `SKILL.md`. The full contract is §6.9 of
|
|
5
|
+
the P4 runtime spec in the Simetra repository
|
|
6
|
+
(`docs/superpowers/specs/2026-10-26-p4-runtime-design.md`).
|
|
7
|
+
|
|
8
|
+
## Shape
|
|
9
|
+
|
|
10
|
+
An object module is a plain object typed by the generated entity type
|
|
11
|
+
(`entities.d.ts` from `compile --out`) and keyed by 1C write events:
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { defineObjectModule } from "simetra/model"
|
|
15
|
+
import type { Catalogs } from "./generated/entities" // the compile --out file
|
|
16
|
+
|
|
17
|
+
export const client = defineObjectModule<Catalogs.Client>({
|
|
18
|
+
beforeWrite({ ctx, draft }) {
|
|
19
|
+
return draft
|
|
20
|
+
},
|
|
21
|
+
onWrite({ ctx, row }) {},
|
|
22
|
+
})
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
- `beforeWrite` (1C `ПередЗаписью`) runs before the core function and returns
|
|
26
|
+
the draft `{ values?, tabularSections? }` the phase writes. It never adds
|
|
27
|
+
`id` or `mark`; the runtime checks the returned draft again.
|
|
28
|
+
- `onWrite` (1C `ПриЗаписи`) sees the written row in the same transaction.
|
|
29
|
+
- Both run on the operations `create`, `update` and `markDeletion`;
|
|
30
|
+
`delete` raises no module event. On `markDeletion` the draft is empty and
|
|
31
|
+
the mark is `ctx.mark`.
|
|
32
|
+
- The host passes modules to `createCommandRuntime` (`simetra/server`) as
|
|
33
|
+
`objectModules`, keyed `"<Kind>.<Name>"` (`"Catalog.Client"`). An unknown
|
|
34
|
+
object or hook key fails runtime creation, not the first command.
|
|
35
|
+
|
|
36
|
+
## The context
|
|
37
|
+
|
|
38
|
+
- `ctx.action` is the operation (`create`, `update`, `markDeletion`),
|
|
39
|
+
`ctx.isNew` is `create`; `ctx.user` is the current user.
|
|
40
|
+
- `ctx.additionalProperties` is shared by the hooks of one phase only.
|
|
41
|
+
- `ctx.run(operation)` runs a phase of another object in the same
|
|
42
|
+
transaction, with its own rights check and hooks; `ctx.read(query)` reads in
|
|
43
|
+
that transaction.
|
|
44
|
+
- `ctx.reject(code, path?)` fails the command with `command.rejected`.
|
|
45
|
+
- A `ctx` method works only while its hook runs. Never keep `ctx` for later:
|
|
46
|
+
a late call fails the command (`command.internal`).
|
|
47
|
+
- A failure the hook catches still fails the command; await every `ctx.run`.
|
|
48
|
+
|
|
49
|
+
## No external I/O in a hook
|
|
50
|
+
|
|
51
|
+
A serialization failure or a deadlock reruns the whole transaction, hooks
|
|
52
|
+
included. A hook never calls HTTP, mail or a queue outside the database. Put
|
|
53
|
+
such work into `ctx.afterCommit(fn)`: it runs after `COMMIT`, at most once,
|
|
54
|
+
and only for non-critical work (a crash after `COMMIT` loses it); its error
|
|
55
|
+
does not undo the command. On a serverless host, pass `defer` (`waitUntil`) to
|
|
56
|
+
`createCommandRuntime`, or `run` waits for this work before it returns.
|
|
57
|
+
|
|
58
|
+
A hook gets no database client and no SQL text. A row rule that must hold for
|
|
59
|
+
every writer belongs in the database (`EventSubscription`, row rules, rights),
|
|
60
|
+
not in a hook.
|