@appweaver/skill 3.0.0 → 3.1.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/package.json +1 -1
- package/skill/SKILL.md +1 -0
- package/skill/references/audit.md +2 -0
- package/skill/references/cli.md +32 -1
- package/skill/references/client.md +123 -25
- package/skill/references/configuration.md +83 -18
- package/skill/references/database.md +4 -0
- package/skill/references/dependency-injection.md +1 -1
- package/skill/references/errors.md +183 -163
- package/skill/references/logging.md +1 -0
- package/skill/references/modules.md +46 -37
- package/skill/references/patterns.md +1 -0
- package/skill/references/payments.md +795 -0
- package/skill/references/resources.md +13 -3
- package/skill/references/telemetry.md +19 -14
- package/skill/references/workflow.md +1 -0
|
@@ -1104,9 +1104,19 @@ createModel({
|
|
|
1104
1104
|
Prisma cannot create a generated column, so `weaver generate` writes it into `database/sql/columns/generated.sql`,
|
|
1105
1105
|
applied by `weaver migrate`. Once the database has it, the next `weaver generate` reads its expression back as the
|
|
1106
1106
|
database renders it (`prisma db pull`) and declares it in the Prisma schema, so Prisma never drops it, with the index of
|
|
1107
|
-
the column by its name. The workflow of a new column is `weaver generate`, `weaver migrate`,
|
|
1108
|
-
again; `weaver migration check` then reports no migration. A changed `dbType` or expression
|
|
1109
|
-
again (its indexes applied again with it)
|
|
1107
|
+
the column by its name. The workflow of a new column, and of a changed one, is `weaver generate`, `weaver migrate`,
|
|
1108
|
+
then `weaver generate` again; `weaver migration check` then reports no migration. A changed `dbType` or expression
|
|
1109
|
+
drops the column and adds it again (its indexes applied again with it).
|
|
1110
|
+
|
|
1111
|
+
`prisma migrate dev` compares the database with what the Prisma migrations build, where a column of a SQL migration
|
|
1112
|
+
is a drift. So `weaver migration new` first records the declared generated columns and their indexes in a Prisma
|
|
1113
|
+
migration of their own, `<timestamp>_generated_columns`, and applies it: the statements of the SQL migration
|
|
1114
|
+
(`ADD COLUMN IF NOT EXISTS`), changing nothing in a migrated database. It is written again only once a column or an
|
|
1115
|
+
index of one changes; commit it with the migration created after it, and never edit it. A migration that cannot be
|
|
1116
|
+
applied, on a database without the tables of the models, is removed and marked as rolled back. The command fails when the
|
|
1117
|
+
schema declares a column otherwise than the database has it, i.e. before the `weaver migrate` and `weaver generate` of
|
|
1118
|
+
a changed expression. A column removed from a model is dropped by the next Prisma migration. Query a generated column
|
|
1119
|
+
with raw SQL:
|
|
1110
1120
|
|
|
1111
1121
|
```ts
|
|
1112
1122
|
const products = await injectService('Product').client.$queryRaw`
|
|
@@ -17,20 +17,21 @@ There is no telemetry contract and no provider per vendor: OTLP is the standard
|
|
|
17
17
|
|
|
18
18
|
## What is recorded
|
|
19
19
|
|
|
20
|
-
| Part (`telemetry.instrumentations.<key>`) | Spans | Metrics
|
|
21
|
-
| ----------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
22
|
-
| `http` (`@appweaver/web`) | A server span per request, `GET /api/posts/:id`, continuing the `traceparent` header, with the status and the `user.id` | `http.server.request.duration`, `http.server.active_requests`
|
|
23
|
-
| `database` (`@appweaver/data`) | A client span per Prisma operation, `findMany Post` or `$queryRaw`, without the query and its arguments | `db.client.operation.duration`
|
|
24
|
-
| `queue` (`memory`, `bullmq`) | A producer span `send <queue>` and a consumer span `process <queue>` per attempt, in the trace of the sender | `messaging.client.sent.messages`, `messaging.process.duration`
|
|
25
|
-
| `scheduler` (`@appweaver/cron`) | The root span of a new trace per run, `scheduler <name>` | `appweaver.scheduler.job.duration`
|
|
26
|
-
| `mailer`, `sms` | A client span per sent email (`mailer send`) and text message (`sms send`), inside the span of their queue job | —
|
|
27
|
-
| `cache` | — | `appweaver.cache.requests` (`appweaver.cache.result`: `hit`, `miss`)
|
|
28
|
-
| `task` (`weaver run`) | The root span of the task, `task <name>`, exported when the task ends | —
|
|
29
|
-
| `realtime` (`@appweaver/realtime`) | A server span per action call, `realtime action <name>`, over the WebSocket or HTTP, until the end of a streaming action; a producer span per stream opened, `realtime stream <name>` | `appweaver.realtime.connections`, `appweaver.realtime.events` (`appweaver.realtime.outcome`: `delivered`, `denied`, `dropped`), `appweaver.realtime.messages`, `appweaver.realtime.streams`, `appweaver.realtime.stream.chunks`, `appweaver.realtime.stream.bytes`, `appweaver.realtime.input.bytes`
|
|
30
|
-
| `ai` (`@appweaver/ai`) | A client span per model call, `chat <model>` or `embeddings <model>`, with the `gen_ai.*` attributes, and an `execute_tool <name>` span per tool call | `gen_ai.client.token.usage` (`gen_ai.token.type`: `input`, `output`), `gen_ai.client.operation.duration`
|
|
31
|
-
| `mcp` (`@appweaver/mcp`) | A server span per tool call, `tools/call <tool>`, with `mcp.method.name` and `gen_ai.tool.name` | `mcp.server.operation.duration`
|
|
32
|
-
| `audit` (`@appweaver/data`) | — | `appweaver.audit.written`, `appweaver.audit.dropped`
|
|
33
|
-
| `
|
|
20
|
+
| Part (`telemetry.instrumentations.<key>`) | Spans | Metrics |
|
|
21
|
+
| ----------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
22
|
+
| `http` (`@appweaver/web`) | A server span per request, `GET /api/posts/:id`, continuing the `traceparent` header, with the status and the `user.id` | `http.server.request.duration`, `http.server.active_requests` |
|
|
23
|
+
| `database` (`@appweaver/data`) | A client span per Prisma operation, `findMany Post` or `$queryRaw`, without the query and its arguments | `db.client.operation.duration` |
|
|
24
|
+
| `queue` (`memory`, `bullmq`) | A producer span `send <queue>` and a consumer span `process <queue>` per attempt, in the trace of the sender | `messaging.client.sent.messages`, `messaging.process.duration` |
|
|
25
|
+
| `scheduler` (`@appweaver/cron`) | The root span of a new trace per run, `scheduler <name>` | `appweaver.scheduler.job.duration` |
|
|
26
|
+
| `mailer`, `sms` | A client span per sent email (`mailer send`) and text message (`sms send`), inside the span of their queue job | — |
|
|
27
|
+
| `cache` | — | `appweaver.cache.requests` (`appweaver.cache.result`: `hit`, `miss`) |
|
|
28
|
+
| `task` (`weaver run`) | The root span of the task, `task <name>`, exported when the task ends | — |
|
|
29
|
+
| `realtime` (`@appweaver/realtime`) | A server span per action call, `realtime action <name>`, over the WebSocket or HTTP, until the end of a streaming action; a producer span per stream opened, `realtime stream <name>` | `appweaver.realtime.connections`, `appweaver.realtime.events` (`appweaver.realtime.outcome`: `delivered`, `denied`, `dropped`), `appweaver.realtime.messages`, `appweaver.realtime.streams`, `appweaver.realtime.stream.chunks`, `appweaver.realtime.stream.bytes`, `appweaver.realtime.input.bytes` |
|
|
30
|
+
| `ai` (`@appweaver/ai`) | A client span per model call, `chat <model>` or `embeddings <model>`, with the `gen_ai.*` attributes, and an `execute_tool <name>` span per tool call | `gen_ai.client.token.usage` (`gen_ai.token.type`: `input`, `output`), `gen_ai.client.operation.duration` |
|
|
31
|
+
| `mcp` (`@appweaver/mcp`) | A server span per tool call, `tools/call <tool>`, with `mcp.method.name` and `gen_ai.tool.name` | `mcp.server.operation.duration` |
|
|
32
|
+
| `audit` (`@appweaver/data`) | — | `appweaver.audit.written`, `appweaver.audit.dropped` |
|
|
33
|
+
| `payments` (`@appweaver/payments`) | A client span per call of a payment gateway, `payments createPayment`, with `appweaver.payments.gateway`, `appweaver.payments.driver` and `appweaver.payments.operation` | `appweaver.payments.gateway.duration`, `appweaver.payments.webhook.events` (`appweaver.payments.outcome`: `received`, `duplicate`, `ignored`, `invalid`, `processed`, `failed`), `appweaver.payments.events` (`appweaver.payments.event`, `appweaver.payments.outcome`: `delivered`, `retried`, `failed`) |
|
|
34
|
+
| `fetch` (`@appweaver/opentelemetry`) | A client span per outbound `fetch` request, which also sends the `traceparent` header. Node.js only | `http.client.request.duration` |
|
|
34
35
|
|
|
35
36
|
The names and the attributes follow the OpenTelemetry semantic conventions (`http.*`, `db.*`, `messaging.*`, `gen_ai.*`), the ones
|
|
36
37
|
of the framework are prefixed with `appweaver.`.
|
|
@@ -42,6 +43,10 @@ of the framework are prefixed with `appweaver.`.
|
|
|
42
43
|
- **Queue**: the trace context travels with the job, so the request that sent a job, the job and everything the worker
|
|
43
44
|
does are one trace, whichever process runs the worker. BullMQ stores it in the `telemetry.metadata` option of the
|
|
44
45
|
job, which `bullmq-otel` of another service reads too.
|
|
46
|
+
- **Payments**: the span of a gateway call is the parent of the `fetch` span of the request the Stripe SDK sends, and
|
|
47
|
+
the processing of a webhook event runs in the trace of its `payments` queue job. A failed call records its
|
|
48
|
+
`error.type` on the span and on the `appweaver.payments.gateway.duration` series. No amount, card detail or customer
|
|
49
|
+
is ever an attribute.
|
|
45
50
|
- **Scheduler**: name a job to name its spans and its metric series, `addJob({ name: 'reports:daily', ... })`.
|
|
46
51
|
- **Problem details**: an error response of a traced request carries the `traceId` next to the `requestId`, to find
|
|
47
52
|
its trace from a bug report.
|
|
@@ -118,6 +118,7 @@ of the version the project's `@appweaver/cli` is at:
|
|
|
118
118
|
weaver module list # the modules, whether enabled, their packages and requirements
|
|
119
119
|
weaver module add redis queue docker # add modules with the modules they require, and install them
|
|
120
120
|
weaver module add sms # the Twilio SMS sender, logging the messages in dev and test
|
|
121
|
+
weaver module add payments # the payments with the Stripe driver, the fake gateway until its keys are set
|
|
121
122
|
weaver module add web --database mysql # add the server and the database (data) it requires, on MySQL
|
|
122
123
|
weaver module add templates --dry-run # print the files and configuration it would change
|
|
123
124
|
weaver module add docker --force # overwrite the existing files instead of skipping them
|