@starci/eslint-canon-be 3.24.0 → 3.27.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/CHANGELOG.md +25 -0
- package/README.md +3 -2
- package/dist/boundary-schema.js +1 -1
- package/dist/connections.js +1 -1
- package/dist/event-bus.js +10 -2
- package/dist/feature-thin.js +2 -2
- package/dist/health-ready.js +25 -9
- package/dist/jobs.d.ts +9 -3
- package/dist/jobs.js +315 -24
- package/dist/lib/config.d.ts +7 -6
- package/dist/lib/config.js +13 -11
- package/dist/lib/hfs-view.d.ts +30 -0
- package/dist/lib/persistence.d.ts +1 -1
- package/dist/lib/persistence.js +2 -2
- package/dist/lib/webhook-handoff-inbox.js +124 -7
- package/dist/lib/webhook-handoff-intake.js +15 -1
- package/dist/lib/webhook-verifiers.js +1 -1
- package/dist/module-shape.js +1 -1
- package/dist/projections.js +1 -1
- package/dist/realtime.js +68 -8
- package/dist/testing.js +1 -1
- package/dist/type-safety.js +2 -3
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 3.27.0 - 2026-11-14
|
|
4
|
+
|
|
5
|
+
- Changed: cut with `@starci/hfs` 6.13.0 (peer line); requires `@starci/hfs` `~6.13.0`. No rule changes.
|
|
6
|
+
|
|
7
|
+
## 3.26.0 - 2026-11-14
|
|
8
|
+
|
|
9
|
+
- Changed (R159, breaking): `job-run-key` is `job-effect-piece` (`BE_JOB_EFFECT_PIECE`). In a job step, and in a function that takes a `ClaimedJob` (a closure of it included), every call on an integration port is the `act` or the `confirm` read of an `Effects.once` call of `platform/effects`; a call made as the key argument, or outside the call object, is a finding. A function handed to a helper that `platform/effects` itself declares together with the `Effects` port (one that answers what its act answered) is an act too, and so is a `const` function whose every use hands it to the piece (`const act = ...` then `{ act }`); a use that only calls it adds no finding of its own. A member its port declares an outside READ (the port's interface extends `OutsideReads<"member" | ...>` of `platform/effects`, a client class merges an interface of its own name that extends it, or a class implements a contract that does; judged by that interface's origin, never by a name) needs no intent; an undeclared member is an act, and a read that decides an act does not excuse the act. Fixtures `integrations/mailer/mail-box.port.ts`, `own-reads.port.ts`. The `RunKey` of `platform/jobs` is no longer read. Spec `src/jobs.spec.ts`.
|
|
10
|
+
- Added (R403, `job-next-declared`): in a `defineJob` declaration `next` is an array literal of statically readable job names, each the name of a job a `defineJob` of the program declares (a computed or spread entry, a name no declaration carries, are findings). Spec `src/jobs.spec.ts`.
|
|
11
|
+
- Added (R404, `job-progress-shape`): a `defineJob` `progress.topic` is a function whose declared return type is `JobProgressTopic` of `platform/jobs`, and a function of `modules/domain` that takes a `ClaimedJob` never calls the `RealtimeHub` (it reports through `JobProgress`). Spec `src/jobs.spec.ts`.
|
|
12
|
+
- Changed (R152, `outbox-write-tx`): a direct `QueueOutbox.write` outside a typed producer is judged like a producer call: only a domain service writes it, with the manager of its own transaction. Spec `src/event-bus.spec.ts`.
|
|
13
|
+
- Changed (R185, R186, `realtime-read-only`, `realtime-topic-scope`): an SSE door may inject ONE stream read service (a class of the platform or domain tier whose public methods all answer an rxjs `Observable`) besides, or instead of, the `RealtimeHub`, and its call must pass the handler's principal (`serviceScope`); a second such service (`second`), a service that also writes, and a stream service in a gateway or a subscription door stay findings. `feature-thin` accepts the one-call door. Specs `src/realtime.spec.ts`, `src/feature-thin.spec.ts`.
|
|
14
|
+
- Fixed (R83, `no-repository-class`): `effects` is a persistence capability, so a platform effects piece may hold the `EntityManager` (`settleIn(tx)`). Spec `src/service-deps.spec.ts`.
|
|
15
|
+
- Changed: cut with `@starci/hfs` 6.12.0; requires `@starci/hfs` `~6.12.0`. Carries the 3.25.2 fix below.
|
|
16
|
+
|
|
17
|
+
## 3.25.2 - 2026-11-13
|
|
18
|
+
|
|
19
|
+
- Fixed (R262, `health-signals`, `ready-real`): `RangeError: Maximum call stack size exceeded` at the first file of an app that holds a constant used many times. `expandedNodes` re-expanded a local constant at every identifier that named it (a cost per reference, and a doubling per nested constant) and appended each expansion with `push(...expansion)`, which overflows the call stack once the list is large. Each constant is now expanded once per call under a visited set shared by the whole walk, nodes are appended one by one, and a self-referencing constant or a ring of constants ends at its second visit. Verdicts are unchanged. Spec `src/health-ready.spec.ts` (a tripling chain of constants, a ring, a self reference). 3.25.1 is taken by the open branch `pkg/claude-lint-split-s2`, so this patch is 3.25.2.
|
|
20
|
+
|
|
21
|
+
## 3.25.0 - 2026-11-13
|
|
22
|
+
|
|
23
|
+
- Changed (PROJECT-LINT-3, breaking for an app that relied on the fixed layout): `starciBePackagesConfig` knows no folder of a root package. It judges every script file of `packages/<pkg>/src/**` but the slots the project declares `lint: "fe"` in `ext/manifest.json` `packages` (the package view's `packageLint`); a back-end slot declared before a front-end slot it lies in stays back end. The fixed `src/workbench/**` and `src/public/**` ignores and the `src/workbench/contract/**` block are gone, so an undeclared package is back end whole. Spec `src/packages-config.spec.ts`.
|
|
24
|
+
- Changed: spec fixtures, typed fixtures, rule comments and the README name neutral providers and domains; no rule id, message id or behaviour changes.
|
|
25
|
+
- Changed (R263, `webhook-inbox-key`): the claim of a delivery intake may be the method of a receipt port the app declares in hfs.json `sides.be.receiptPorts` (`{ class, method, repeat, reason }`), besides `claim` and `claimRow` of the platform Inbox. A declared call is held to the same contract: the first await inside the receipt transaction, the transaction's own manager as its first argument, an argument that comes from the delivery (never a literal, never the raw payload), no call inside its arguments (a `const` before it binds what they need), and the declared repeat answer (`false` or `undefined`) returned on in the next statement. The handoff half accepts exactly the declared method inside the receipt transaction; any other method of that class, a lookalike class and an undeclared port stay `handoff` and `key` findings. Spec `src/webhook-handoff-inbox.spec.ts`.
|
|
26
|
+
- Changed (R263, `webhook-inbox-key`): a receipt port declared with `many: true` (`{ class, method, many, reason }`, hfs 6.10.0) is the claim of a delivery that carries several events: the same contract up to the call, its answer (the list of the new events, empty on a repeat) bound to one `const`, and every later statement of the receipt transaction a `for (const event of <that const>)` whose body reads nothing of the intake but its own bindings and the transaction's manager (no raw delivery, no binding made before the claim, no answer list, no `arguments`); `for await`, another iterable, a statement outside the loops, and the single form's repeat test on a many port are `key` findings. Spec `src/webhook-handoff-inbox.spec.ts`.
|
|
27
|
+
|
|
3
28
|
## 3.24.0 - 2026-11-13
|
|
4
29
|
|
|
5
30
|
- Changed (PROJECT-LINT-3, R381): `starciBeConfig` and `starciBePackagesConfig` load the lint rules of the project's extension (`ext/manifest.json`, `ext/lint/`) through `extEslintConfigs` of `@starci/hfs` 6.9.0: one block per rule, over the files its `appliesTo` names inside the config (the be side's own folder, `packages/` for the root packages), under the plugin `project-ext`. A refused extension throws `HFS_EXT_INVALID`. Rule packs (hfs.json `rulePacks`) are gone. Requires `@starci/hfs` `~6.9.0`. Spec `src/project-ext.spec.ts`.
|
package/README.md
CHANGED
|
@@ -63,7 +63,8 @@ A sample, not the list:
|
|
|
63
63
|
| **Entity base** | An `@Entity` class does not repeat the columns every table shares: a database-set `created_at` or `updated_at` (`@CreateDateColumn`, `@UpdateDateColumn`, or a `@Column` on those names with `insert: false`, `update: false` or a `default`) and, beside both, the generated uuid `id` are inherited from `UuidAbstractEntity` or `AbstractEntity` of `@modules/platform/database`; the finding names the base. A table whose timestamps the application sets, or that lacks one of them, extends nothing, and the base file `platform/database/abstract.entity.ts` is exempt (`entity-extends-base`, R342, BE-PERSISTENCE-3) |
|
|
64
64
|
| **Connections** | One database is one connection and one `Inject<Conn>EntityManager()` injector: `InjectEntityManager(`, `InjectDataSource(` and `getEntityManagerToken(` are called only in `platform/database/<conn>.decorators.ts`, the cli and the test world; an exported EntityManager injector is exactly the declared connection's; `TypeOrmModule.forRoot*` and `new DataSource(` live in the platform database capability and the cli; the connection name is written once, in its `<conn>.connection.ts`; a `<conn>.config.ts` reads only keys of its `envPrefix` (`one-connection-per-database`) |
|
|
65
65
|
| **Operations** | A versioned operation is declared once in the app's typed operation table (`query({ input, output, refusal })` / `mutation(...)` registered by `defineOperations`, declared by the platform capability `operations`): bounded input and output schemas come from an owner's `*.schema.ts` file, their inferred types are closed, and refusal codes form a closed union of string literals. A route takes `OperationRequest<Table>`, validates it with the canon `OperationValidationPolicy` constructed from that same table, and answers `Promise<OperationReply<Table>>` (`operation-contract-decidable`, `operation-table-schemas`, `operation-route-driven-by-table`) |
|
|
66
|
-
| **Webhooks and realtime** | A provider webhook door injects only the `WebhookSignatureService` and domain services, verifies first (awaited when async), and hands the POST delivery to exactly one domain intake that records the inbox receipt and outbox event; a domain method may combine proof and intake. The POST returns nothing or the own-feature exported literal `PROVIDER_ACK`. One optional GET challenge handler returns only its declared domain verifier's result. The door and HTTP module import or inject no `CommandBus`, `QueryBus` or feature command handler, and its resolved domain intake dispatches no command/query bus or feature handler; a reactor or job dispatches after commit (`webhook-shape`, `webhook-verify-first`, `feature-thin`). A realtime door is one gateway or
|
|
66
|
+
| **Webhooks and realtime** | A provider webhook door injects only the `WebhookSignatureService` and domain services, verifies first (awaited when async), and hands the POST delivery to exactly one domain intake that records the inbox receipt and outbox event; a domain method may combine proof and intake. The POST returns nothing or the own-feature exported literal `PROVIDER_ACK`. One optional GET challenge handler returns only its declared domain verifier's result. The door and HTTP module import or inject no `CommandBus`, `QueryBus` or feature command handler, and its resolved domain intake dispatches no command/query bus or feature handler; a reactor or job dispatches after commit (`webhook-shape`, `webhook-verify-first`, `feature-thin`). A realtime door is one gateway, subscription or SSE controller that injects the `RealtimeHub` (an SSE door may instead inject ONE stream read service whose public methods only answer an `Observable`, called with the principal) and subscribes to a topic built from its `@CurrentPrincipal()` (`realtime-shape`, `realtime-read-only`, `realtime-topic-scope`) |
|
|
67
|
+
| **Jobs** (R157-R160, R403, R404) | The job row is written only by `platform/jobs` through guarded writes that require the fencing token (`job-write-owner`, `job-fence-required`); a processor extends `FencedProcessor` and a step implements `JobStep` in their job folder (`job-shape`); in a step, and in any function that takes a `ClaimedJob`, every call on an integration port its port does not declare an outside read (`OutsideReads` of `platform/effects`) is the `act` or `confirm` of an `Effects.once` call (`job-effect-piece`); a `defineJob` `next` lists only declared jobs, as readable names (`job-next-declared`); a `progress.topic` returns the platform's principal-first `JobProgressTopic`, and a function that takes a `ClaimedJob` never calls the `RealtimeHub` (`job-progress-shape`); a job enqueues its next job through an outbox write of its own transaction (`outbox-write-tx`) |
|
|
67
68
|
| **Transport** | A door injects only `CommandBus` / `QueryBus` (and `RequestLocale` in REST) and dispatches exactly one message per handler, holding no branch, loop, EntityManager or call other than the bus, and pure `*.mapper.ts` functions and `unwrapOutcome` of `platform/primitives` (`transport-is-thin`); no response envelope, no `GraphQLJSON`, no `unknown` body, no `switch (input.operation)`; a REST door lives in `transport/http` and shows a public reason, a byte stream or a redirect; a capability never imports a feature (`transport-is-thin`, `no-response-envelope`, `no-graphql-json`, `door-lives-in-features`, `rest-door-needs-a-reason`, `no-capability-imports-features`) |
|
|
68
69
|
| **Feature thin** (R203 BE_FEATURE_THIN) | A feature-tier file of a thin role (`<name>.handler.ts`, `.resolver.ts`, `.controller.ts`, `.consumer.ts`, `.processor.ts`, `.step.ts`, `.saga.ts`, `.saga-step.ts`, `.compensation.ts`, `.webhook.ts`, `.gateway.ts`, `.subscription.ts`, `.cli.ts`, `.mapper.ts`, `.service.ts`) maps its parameters and makes exactly one delegating call into the modules - an injected member, a bus `execute` or a modules function in statement position - with no branch, loop, `try`, `throw` or computation; free calls are pure `*.mapper.ts` functions, the `Logger` port and a webhook's first verification call when followed by one separate intake (a combined domain verification and intake call counts as the delegation). A webhook POST may return its declared literal `PROVIDER_ACK`; its optional GET challenge has one domain verifier call and echoes only that result. Webhook doors and their HTTP modules reach no command/query bus or feature command handler; orchestration (step order, compensation, claim, fencing, retry) belongs to the platform (`feature-thin`) |
|
|
69
70
|
| **Infrastructure owners** | Each raw library (HTTP, cache, queue, scheduler, logger, date, config, events) is imported or reached as a global only inside the capability the manifest names for it (`ruleParams.be.infraOwners`); `@nestjs/config`, `dotenv` and `@nestjs/event-emitter` nowhere; the `HttpClient` port of `platform/http` (found by the receiver's type) is called only in an `integrations` owner, `platform/http` and the test world (`infra-import-owner`, `http-client-only-in-integrations`) |
|
|
@@ -91,7 +92,7 @@ For an existing service with another name, declare the exact verification method
|
|
|
91
92
|
`<provider>-http.module.ts`:
|
|
92
93
|
|
|
93
94
|
```ts
|
|
94
|
-
export const webhookVerifiers = [BillingService.prototype.
|
|
95
|
+
export const webhookVerifiers = [BillingService.prototype.receiveGammaPayWebhook] as const
|
|
95
96
|
```
|
|
96
97
|
|
|
97
98
|
The declaration names TypeScript method symbols, never strings. Its first unconditional call must finish proof before
|
package/dist/boundary-schema.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* - `schema-place` (R304) holds the territory. `zod` is imported only from a `<name>.schema.ts` file (or its spec) that sits
|
|
10
10
|
* in a `domain`, `platform` or `integrations` owner, or from any file of a root workspace package (tier `package`, slots
|
|
11
|
-
* `app.packages`
|
|
11
|
+
* `app.packages`), whose node, block and vocabulary contracts are zod schemas; never in a feature
|
|
12
12
|
* (a transport door answers to `class-validator`), never in a `dto/` folder, and a schema file does not also carry
|
|
13
13
|
* `class-validator` or a GraphQL type.
|
|
14
14
|
* - `schema-bounded` (R305) holds the cost. Every string, array, set, map and record a schema builds has an upper bound
|
package/dist/connections.js
CHANGED
|
@@ -80,7 +80,7 @@ const isEntityManagerInjector = (context, hfs, node) => {
|
|
|
80
80
|
};
|
|
81
81
|
/** Whether a call reaches a value declared by `pkg` under one of `names`, however it was imported. */
|
|
82
82
|
const callsPackage = (context, node, names, pkg) => typeOrigins(context, node).some((origin) => origin.module === pkg && names.has(origin.name));
|
|
83
|
-
/** The constant a declared connection name is exported as: `
|
|
83
|
+
/** The constant a declared connection name is exported as: `reporting` gives `REPORTING_CONNECTION`. */
|
|
84
84
|
const constantOf = (name) => `${name.toUpperCase().replace(/-/g, "_")}_CONNECTION`;
|
|
85
85
|
/** The string an env key argument spells, or null when it is not a plain string. */
|
|
86
86
|
const keyText = (node) => {
|
package/dist/event-bus.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The rules that hold the event-bus and queue patterns (catalog R152 `BE_OUTBOX_WRITE_TX`, R153 `BE_EVENT_CONSUMER_SHAPE`,
|
|
3
|
-
* R154 `BE_QUEUE_PRODUCER_SHAPE`).
|
|
3
|
+
* R154 `BE_QUEUE_PRODUCER_SHAPE`). A job starts, and enqueues its next job, only from an outbox row written in the transaction of the
|
|
4
|
+
* change that calls for it: every outbox write, a producer call and a direct `QueueOutbox.write` alike, is judged by `outbox-write-tx`.
|
|
4
5
|
*
|
|
5
6
|
* The one durable path of an event is: a domain service writes the outbox row in ITS transaction (`eventBus.publish(event, tx)`), the
|
|
6
7
|
* relay hands the row to Kafka, a consumer in `transport/message` receives it and dispatches one command. A queue job takes the same
|
|
@@ -68,12 +69,19 @@ const isTransactionManager = (context, argument) => {
|
|
|
68
69
|
return false;
|
|
69
70
|
return infraTypeOf(context, definition.name) === "EntityManager";
|
|
70
71
|
};
|
|
71
|
-
/**
|
|
72
|
+
/**
|
|
73
|
+
* The outbox-writing call a node is: `{ kind: "publish", argument }` or `{ kind: "producer", argument }`, or null. A `write` on the
|
|
74
|
+
* `QueueOutbox` port is an outbox write wherever it is called: a typed producer's own (tier `queues`) is judged by `queue-producer-shape`,
|
|
75
|
+
* any other, a job enqueuing its next job included, is judged here like a producer call.
|
|
76
|
+
*/
|
|
72
77
|
const outboxWriteOf = (context, hfs, node) => {
|
|
73
78
|
const callee = node.callee;
|
|
74
79
|
if (callee.type === "MemberExpression" && !callee.computed && callee.property.type === "Identifier" && callee.property.name === "publish" && isEventBusType(context, callee.object)) {
|
|
75
80
|
return { kind: "publish", argument: node.arguments[1], expected: 1 };
|
|
76
81
|
}
|
|
82
|
+
if (callee.type === "MemberExpression" && !callee.computed && callee.property.type === "Identifier" && callee.property.name === "write" && isQueueOutboxType(context, callee.object)) {
|
|
83
|
+
return hfs.tierOf(context.filename) === "queues" ? null : { kind: "producer", argument: node.arguments[0], expected: 0 };
|
|
84
|
+
}
|
|
77
85
|
const { checker, toTs } = typed(context);
|
|
78
86
|
const tsNode = toTs(node);
|
|
79
87
|
const declaration = tsNode ? checker.getResolvedSignature(tsNode)?.declaration : undefined;
|
package/dist/feature-thin.js
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* the file-name suffix the closed role vocabulary defines - never a path regex. What a receiver is comes
|
|
16
16
|
* from its TYPE (`Logger` of `platform/logging`, `WebhookSignatureService` of `platform/http-security`) and
|
|
17
17
|
* from whether the member is injected (`injectedMembers`); what a free function is comes from the file its
|
|
18
|
-
* import resolves to. A job `step` records its fence through `JobClaims` (`advance
|
|
18
|
+
* import resolves to. A job `step` records its fence through `JobClaims` (`advance`), and a webhook proves its signature through the shared `verify`
|
|
19
19
|
* or a declared domain verifier as its first call: a separate gate call is free beside the one intake delegation.
|
|
20
20
|
* A combined domain proof and intake counts as the delegation. `.spec.ts` and `.d.ts` are never judged, and neither is a file whose tier is not
|
|
21
21
|
* `feature` or whose role is not a thin role. A clean thin file is never flagged: that is the bar.
|
|
@@ -57,7 +57,7 @@ const roleOf = (filename) => /\.([a-z][a-z0-9-]*)\.ts$/.exec(baseName(filename))
|
|
|
57
57
|
const isSignatureReceiver = (context, node) => isOwnedType(context, node, { name: "WebhookSignatureService", capability: "http-security", tier: "platform" });
|
|
58
58
|
/** The shape conversions a mapper may make on a value it received: a collection mapped item by item and a date written as text. They decide nothing and compute nothing. */
|
|
59
59
|
const MAPPER_SHAPE_METHODS = new Set(["map", "toISOString"]);
|
|
60
|
-
/** The `JobClaims` port of `platform/jobs` - the fence a job step records itself through (`advance
|
|
60
|
+
/** The `JobClaims` port of `platform/jobs` - the fence a job step records itself through (`advance`): bookkeeping the fenced-job pattern requires, free beside the step's one delegating call. */
|
|
61
61
|
const isClaimsReceiver = (context, node) => isOwnedType(context, node, { name: "JobClaims", capability: "jobs", tier: "platform" });
|
|
62
62
|
/** The `Logger` port of `platform/logging` - the one call that is always free. */
|
|
63
63
|
const isLoggerReceiver = isLoggerType;
|
package/dist/health-ready.js
CHANGED
|
@@ -62,16 +62,32 @@ const bindingsOf = (program) => {
|
|
|
62
62
|
bindings.set(node.id.name, node.init); });
|
|
63
63
|
return bindings;
|
|
64
64
|
};
|
|
65
|
-
/**
|
|
66
|
-
|
|
65
|
+
/**
|
|
66
|
+
* Expand local constants when proving a race: a timeout promise or duration may be held in a const.
|
|
67
|
+
* Each constant is expanded once per call (a visited set shared by the whole walk), so a constant referenced many times, constants that
|
|
68
|
+
* reference each other in a chain or a ring, and a constant that refers to itself cost one visit each, never one per reference.
|
|
69
|
+
* The nodes are appended one by one: a spread of a large expansion into `push` overflows the call stack.
|
|
70
|
+
*/
|
|
71
|
+
function expandedNodes(node, bindings) {
|
|
67
72
|
const nodes = [];
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
const seen = new Set();
|
|
74
|
+
const expanded = new Set();
|
|
75
|
+
const visit = (start) => {
|
|
76
|
+
walk(start, (child) => {
|
|
77
|
+
if (seen.has(child))
|
|
78
|
+
return;
|
|
79
|
+
seen.add(child);
|
|
80
|
+
nodes.push(child);
|
|
81
|
+
if (child.type !== "Identifier" || expanded.has(child.name))
|
|
82
|
+
return;
|
|
83
|
+
const init = bindings.get(child.name);
|
|
84
|
+
if (!init)
|
|
85
|
+
return;
|
|
86
|
+
expanded.add(child.name);
|
|
87
|
+
visit(init);
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
visit(node);
|
|
75
91
|
return nodes;
|
|
76
92
|
}
|
|
77
93
|
function sourcePath(source, filename, root) {
|
package/dist/jobs.d.ts
CHANGED
|
@@ -3,15 +3,21 @@ import type { Recommended, RuleModule } from "./lib/rule.js";
|
|
|
3
3
|
export declare const jobWriteOwner: RuleModule;
|
|
4
4
|
/** Calls on the `JobClaims` port, and what a guarded write is: required token, no cast to get around it, and `JobFencedOut` is not swallowed. */
|
|
5
5
|
export declare const jobFenceRequired: RuleModule;
|
|
6
|
-
/**
|
|
7
|
-
export declare const
|
|
6
|
+
/** An outside call of a job is made by the effects piece: its intent row before the act, its result after. */
|
|
7
|
+
export declare const jobEffectPiece: RuleModule;
|
|
8
|
+
/** A job's `next` names only jobs a `defineJob` declares. */
|
|
9
|
+
export declare const jobNextDeclared: RuleModule;
|
|
10
|
+
/** A job's progress is a view the frame publishes: its topic is built principal-first, and no domain method publishes it itself. */
|
|
11
|
+
export declare const jobProgressShape: RuleModule;
|
|
8
12
|
/** A processor extends the fenced base and is named after its job; a step implements `JobStep` in `steps/`. */
|
|
9
13
|
export declare const jobShape: RuleModule;
|
|
10
14
|
export declare const rules: {
|
|
11
15
|
"job-write-owner": RuleModule;
|
|
12
16
|
"job-fence-required": RuleModule;
|
|
13
|
-
"job-
|
|
17
|
+
"job-effect-piece": RuleModule;
|
|
14
18
|
"job-shape": RuleModule;
|
|
19
|
+
"job-next-declared": RuleModule;
|
|
20
|
+
"job-progress-shape": RuleModule;
|
|
15
21
|
};
|
|
16
22
|
/** The level these laws ask for: `error`, switched off nowhere. */
|
|
17
23
|
export declare const recommended: Recommended;
|
package/dist/jobs.js
CHANGED
|
@@ -1,25 +1,39 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The rules that hold the fenced-job pattern (catalog R157 `BE_JOB_WRITE_OUTSIDE_OWNER`, R158 `BE_JOB_FENCE_REQUIRED`,
|
|
3
|
-
* R159 `
|
|
3
|
+
* R159 `BE_JOB_EFFECT_PIECE`, R160 `BE_JOB_SHAPE`, R403 `BE_JOB_NEXT_DECLARED`, R404 `BE_JOB_PROGRESS_SHAPE`).
|
|
4
4
|
*
|
|
5
|
-
* A
|
|
6
|
-
* write to the row is guarded by `expectedFencingToken
|
|
7
|
-
* `platform/jobs` is the ONE owner of the row: it declares the entity, the claim
|
|
5
|
+
* A job is a step of a chain: a row whose `fencingToken` the claim bumps, declared once with `defineJob`. A worker that lost its claim (a
|
|
6
|
+
* zombie) holds a stale token, so every write to the row is guarded by `expectedFencingToken`, and every outside act goes through the
|
|
7
|
+
* effects piece, which commits an intent row before the act. `platform/jobs` is the ONE owner of the row: it declares the entity, the claim
|
|
8
|
+
* and the guarded writes, and nothing else writes it.
|
|
8
9
|
*
|
|
9
|
-
* Everything is found by TYPE ORIGIN (the `JobClaims`, `JobStep`, `
|
|
10
|
-
*
|
|
11
|
-
*
|
|
10
|
+
* Everything is found by TYPE ORIGIN (the `JobClaims`, `JobStep`, `ClaimedJob`, `JobProgressTopic`, `defineJob` and `FencedProcessor`
|
|
11
|
+
* declared by `platform/jobs`, the `Effects` port of `platform/effects`, the `RealtimeHub` of `platform/realtime`, the entity class
|
|
12
|
+
* declared by that owner, typeorm receivers and query builders) and by the slot view (`be.feature.jobs.steps`, `be.feature.jobs`,
|
|
13
|
+
* `be.queues`); the only names read are the contract's own members `once` (with its `act` and `confirm`), `next`, `progress`, `topic`,
|
|
14
|
+
* `jobId` and `expectedFencingToken`.
|
|
12
15
|
*/
|
|
13
16
|
import ts from "typescript";
|
|
14
|
-
import { walk } from "./lib/ast.js";
|
|
17
|
+
import { keyName, walk } from "./lib/ast.js";
|
|
15
18
|
import { writtenEntityOrigins } from "./lib/entity-writes.js";
|
|
16
19
|
import { hfsOf, inTestWorld } from "./lib/hfs.js";
|
|
17
20
|
import { baseName, isOwnedType, ownerNameOf } from "./lib/ports.js";
|
|
18
|
-
import { typeOrigins, typed } from "./lib/types.js";
|
|
21
|
+
import { originsOfType, resolvedSymbol, typeOrigins, typed } from "./lib/types.js";
|
|
19
22
|
const isJobClaimsType = (context, node) => isOwnedType(context, node, { name: "JobClaims", capability: "jobs", tier: "platform" });
|
|
20
23
|
const isJobStepType = (context, node) => isOwnedType(context, node, { name: "JobStep", capability: "jobs", tier: "platform" });
|
|
21
24
|
const isFencedProcessorType = (context, node) => isOwnedType(context, node, { name: "FencedProcessor", capability: "jobs", tier: "platform" });
|
|
22
|
-
const
|
|
25
|
+
const isClaimedJobType = (context, node) => isOwnedType(context, node, { name: "ClaimedJob", capability: "jobs", tier: "platform" });
|
|
26
|
+
const isEffectsType = (context, node) => isOwnedType(context, node, { name: "Effects", capability: "effects", tier: "platform" });
|
|
27
|
+
const isRealtimeHubType = (context, node) => isOwnedType(context, node, { name: "RealtimeHub", capability: "realtime", tier: "platform" });
|
|
28
|
+
/** The contract's own members and types the rules below read. */
|
|
29
|
+
const ONCE = "once";
|
|
30
|
+
const ACT = "act";
|
|
31
|
+
const CONFIRM = "confirm";
|
|
32
|
+
const NEXT = "next";
|
|
33
|
+
const PROGRESS = "progress";
|
|
34
|
+
const TOPIC = "topic";
|
|
35
|
+
const DEFINE_JOB = "defineJob";
|
|
36
|
+
const PROGRESS_TOPIC = "JobProgressTopic";
|
|
23
37
|
/** True for a file of the owner itself, and for the test composition. */
|
|
24
38
|
const isOwnerOrTest = (hfs, file) => {
|
|
25
39
|
const tier = hfs.tierOf(file);
|
|
@@ -129,38 +143,311 @@ export const jobFenceRequired = {
|
|
|
129
143
|
};
|
|
130
144
|
},
|
|
131
145
|
};
|
|
132
|
-
/**
|
|
133
|
-
|
|
146
|
+
/** True for a function node that takes a `ClaimedJob`: the domain method a job's step calls. */
|
|
147
|
+
const takesClaimedJob = (context, fn) => fn.params.some((param) => {
|
|
148
|
+
const target = param.type === "TSParameterProperty" ? param.parameter : param;
|
|
149
|
+
const bound = target.type === "AssignmentPattern" ? target.left : target;
|
|
150
|
+
return isClaimedJobType(context, bound);
|
|
151
|
+
});
|
|
152
|
+
/** True when the node sits inside a function (or a closure of one) that takes a `ClaimedJob`. */
|
|
153
|
+
const insideJobFunction = (context, node) => {
|
|
154
|
+
for (let current = node.parent; current; current = current.parent) {
|
|
155
|
+
if ((current.type === "FunctionDeclaration" || current.type === "FunctionExpression" || current.type === "ArrowFunctionExpression") && takesClaimedJob(context, current))
|
|
156
|
+
return true;
|
|
157
|
+
}
|
|
158
|
+
return false;
|
|
159
|
+
};
|
|
160
|
+
/** True for `Effects.once(...)`: a call of `once` on the `Effects` port of `platform/effects`. */
|
|
161
|
+
const isEffectsOnce = (context, call) => call.callee.type === "MemberExpression"
|
|
162
|
+
&& !call.callee.computed
|
|
163
|
+
&& call.callee.property.type === "Identifier"
|
|
164
|
+
&& call.callee.property.name === ONCE
|
|
165
|
+
&& isEffectsType(context, call.callee.object);
|
|
166
|
+
/**
|
|
167
|
+
* True for a call of a function that `platform/effects` itself declares and that is handed the `Effects` port (a helper of the piece,
|
|
168
|
+
* such as one that answers what the act answered): the piece runs the functions passed to it inside its own `Effects.once`.
|
|
169
|
+
*/
|
|
170
|
+
const isEffectsHelperCall = (context, call) => {
|
|
171
|
+
if (!call.arguments.some((argument) => argument.type !== "SpreadElement" && isEffectsType(context, argument)))
|
|
172
|
+
return false;
|
|
173
|
+
const hfs = hfsOf(context);
|
|
174
|
+
const { checker, toTs } = typed(context);
|
|
175
|
+
const target = toTs(call.callee.type === "MemberExpression" ? call.callee.property : call.callee);
|
|
176
|
+
const symbol = resolvedSymbol(checker, target ? checker.getSymbolAtLocation(target) : undefined);
|
|
177
|
+
return (symbol?.declarations ?? []).some((declaration) => {
|
|
178
|
+
const file = String(declaration.getSourceFile().fileName).replace(/\\/g, "/");
|
|
179
|
+
return hfs.tierOf(file) === "platform" && ownerNameOf(hfs, file) === "effects";
|
|
180
|
+
});
|
|
181
|
+
};
|
|
182
|
+
/**
|
|
183
|
+
* True when the expression is handed to the effects piece as an act or a confirm read: the value of `act` or `confirm` in the call
|
|
184
|
+
* object of `Effects.once`, or a function argument of a helper of the piece.
|
|
185
|
+
*/
|
|
186
|
+
const isHandedToEffects = (context, expression) => {
|
|
187
|
+
const parent = expression.parent;
|
|
188
|
+
if (parent?.type === "CallExpression" && parent.arguments.includes(expression))
|
|
189
|
+
return isEffectsHelperCall(context, parent);
|
|
190
|
+
if (parent?.type !== "Property" || parent.value !== expression)
|
|
191
|
+
return false;
|
|
192
|
+
const key = keyName(parent.key);
|
|
193
|
+
if (key !== ACT && key !== CONFIRM)
|
|
194
|
+
return false;
|
|
195
|
+
const object = parent.parent;
|
|
196
|
+
const call = object?.parent;
|
|
197
|
+
return object?.type === "ObjectExpression" && call?.type === "CallExpression" && call.arguments.includes(object) && isEffectsOnce(context, call);
|
|
198
|
+
};
|
|
199
|
+
/**
|
|
200
|
+
* True when the function is an act or a confirm read the effects piece runs: handed to it directly, or bound to a `const` whose every
|
|
201
|
+
* use hands it to the piece (`const act = () => ...` then `{ act }`).
|
|
202
|
+
*/
|
|
203
|
+
const isEffectsAct = (context, fn) => {
|
|
204
|
+
if (isHandedToEffects(context, fn))
|
|
205
|
+
return true;
|
|
206
|
+
const declarator = fn.parent;
|
|
207
|
+
if (declarator?.type !== "VariableDeclarator" || declarator.init !== fn || declarator.id.type !== "Identifier")
|
|
208
|
+
return false;
|
|
209
|
+
if (declarator.parent.type !== "VariableDeclaration" || declarator.parent.kind !== "const")
|
|
210
|
+
return false;
|
|
211
|
+
const uses = context.sourceCode.getDeclaredVariables(declarator).flatMap((variable) => variable.references.filter((reference) => !reference.init));
|
|
212
|
+
// A use that only calls it (`return act()`, a path with no job) makes no outside call of a job by itself; the rule judges the uses that hand it on.
|
|
213
|
+
const handed = uses.filter((reference) => !(reference.identifier.parent.type === "CallExpression" && reference.identifier.parent.callee === reference.identifier));
|
|
214
|
+
return handed.length > 0 && handed.every((reference) => isHandedToEffects(context, reference.identifier));
|
|
215
|
+
};
|
|
216
|
+
/** True when the call is an act or a confirm read the effects piece runs: inside a function handed to `Effects.once` or to a helper of the piece. */
|
|
217
|
+
const insideEffectCall = (context, node) => {
|
|
218
|
+
for (let current = node.parent; current; current = current.parent) {
|
|
219
|
+
if ((current.type === "FunctionExpression" || current.type === "ArrowFunctionExpression") && isEffectsAct(context, current))
|
|
220
|
+
return true;
|
|
221
|
+
}
|
|
222
|
+
return false;
|
|
223
|
+
};
|
|
224
|
+
/** The marker a port declares its outside reads with: `OutsideReads<"member" | ...>` of `platform/effects`. */
|
|
225
|
+
const OUTSIDE_READS = "OutsideReads";
|
|
226
|
+
/** True for the phantom property of `OutsideReads`, judged by where it is declared: the interface `platform/effects` declares. */
|
|
227
|
+
const isOutsideReadsMarker = (hfs, property) => (property.declarations ?? []).some((declaration) => {
|
|
228
|
+
const holder = declaration.parent;
|
|
229
|
+
if (!ts.isInterfaceDeclaration(holder) || holder.name.text !== OUTSIDE_READS)
|
|
230
|
+
return false;
|
|
231
|
+
const file = String(declaration.getSourceFile().fileName).replace(/\\/g, "/");
|
|
232
|
+
return hfs.tierOf(file) === "platform" && ownerNameOf(hfs, file) === "effects";
|
|
233
|
+
});
|
|
234
|
+
/**
|
|
235
|
+
* The members a port declares as outside READS: the string literals of the `OutsideReads` its type extends (the port's interface, or an
|
|
236
|
+
* interface merged with a client class) or that the contract a class implements extends. A member the port does not declare is an act, so a forgotten declaration only makes the rule stricter.
|
|
237
|
+
*/
|
|
238
|
+
const declaredReads = (hfs, checker, type) => {
|
|
239
|
+
const reads = new Set();
|
|
240
|
+
const collect = (holder) => {
|
|
241
|
+
for (const property of checker.getPropertiesOfType(holder)) {
|
|
242
|
+
if (!isOutsideReadsMarker(hfs, property))
|
|
243
|
+
continue;
|
|
244
|
+
const members = checker.getTypeOfSymbol(property);
|
|
245
|
+
for (const part of members.isUnion() ? members.types : [members])
|
|
246
|
+
if (part.isStringLiteral())
|
|
247
|
+
reads.add(part.value);
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
collect(type);
|
|
251
|
+
for (const declaration of type.getSymbol()?.declarations ?? []) {
|
|
252
|
+
if (!ts.isClassDeclaration(declaration))
|
|
253
|
+
continue;
|
|
254
|
+
for (const clause of declaration.heritageClauses ?? [])
|
|
255
|
+
for (const implemented of clause.types)
|
|
256
|
+
collect(checker.getTypeAtLocation(implemented));
|
|
257
|
+
}
|
|
258
|
+
return reads;
|
|
259
|
+
};
|
|
260
|
+
/** True when the call is a member its port declares as an outside read (`OutsideReads`): a read has no intent to protect. */
|
|
261
|
+
const isDeclaredRead = (context, callee) => {
|
|
262
|
+
if (callee.property.type !== "Identifier")
|
|
263
|
+
return false;
|
|
264
|
+
const { checker, toTs } = typed(context);
|
|
265
|
+
const receiver = toTs(callee.object);
|
|
266
|
+
if (!receiver)
|
|
267
|
+
return false;
|
|
268
|
+
return declaredReads(hfsOf(context), checker, checker.getTypeAtLocation(receiver)).has(callee.property.name);
|
|
269
|
+
};
|
|
270
|
+
/** An outside call of a job is made by the effects piece: its intent row before the act, its result after. */
|
|
271
|
+
export const jobEffectPiece = {
|
|
134
272
|
meta: {
|
|
135
273
|
type: "problem",
|
|
136
|
-
docs: { description: "In a job step every call on an integration port
|
|
274
|
+
docs: { description: "In a job step, and in a function that takes a `ClaimedJob`, every call on an integration port that its port does not declare an outside read (`OutsideReads` of `platform/effects`) is the `act` or the `confirm` read of an `Effects.once` call of `platform/effects`." },
|
|
137
275
|
schema: [],
|
|
138
276
|
messages: {
|
|
139
|
-
|
|
140
|
-
forged: "This `RunKey` is built with a cast. Only `JobClaims.runKey(job, step)` makes one, so the key always carries the fencing token of the claim.",
|
|
277
|
+
outside: "`{{call}}` is an outside call of a job made without the effects piece. An act outside the database (a provider call, a mail, a paid model call, a write to an index) goes through `Effects.once(key, effect, { act, confirm?, ... })` of `platform/effects`: its intent row is committed before the act and its result after, so a crash between them is settled as the effect declares (`repeatable`, `confirm` or `person`) and never acted twice blind. A member that only reads the outside world has no intent to protect: its port declares it in `OutsideReads<\"member\">` of `platform/effects` (the port's interface extends it; a client class with no contract merges an interface of its own name that extends it); an undeclared member is an act.",
|
|
141
278
|
},
|
|
142
279
|
},
|
|
143
280
|
create(context) {
|
|
144
281
|
const hfs = hfsOf(context);
|
|
145
|
-
|
|
282
|
+
const file = context.filename;
|
|
283
|
+
const inStep = hfs.slotOf(file) === "be.feature.jobs.steps";
|
|
284
|
+
const inDomain = hfs.tierOf(file) === "domain";
|
|
285
|
+
if (!inStep && !inDomain)
|
|
146
286
|
return {};
|
|
147
287
|
return {
|
|
148
288
|
CallExpression(node) {
|
|
149
289
|
const callee = node.callee;
|
|
150
290
|
if (callee.type !== "MemberExpression" || callee.computed)
|
|
151
291
|
return;
|
|
292
|
+
if (!inStep && !insideJobFunction(context, node))
|
|
293
|
+
return;
|
|
152
294
|
const origins = typeOrigins(context, callee.object);
|
|
153
295
|
if (!origins.some((origin) => origin.module === null && hfs.tierOf(origin.file) === "integrations"))
|
|
154
296
|
return;
|
|
155
|
-
|
|
156
|
-
if (keyArguments.length === 0) {
|
|
157
|
-
context.report({ node, messageId: "missing", data: { call: context.sourceCode.getText(callee) } });
|
|
297
|
+
if (isDeclaredRead(context, callee) || insideEffectCall(context, node))
|
|
158
298
|
return;
|
|
299
|
+
context.report({ node, messageId: "outside", data: { call: context.sourceCode.getText(callee) } });
|
|
300
|
+
},
|
|
301
|
+
};
|
|
302
|
+
},
|
|
303
|
+
};
|
|
304
|
+
/** The names of the jobs the `defineJob` calls of the program declare, read once per program. */
|
|
305
|
+
const declaredJobNames = (context, hfs) => {
|
|
306
|
+
const { program, checker } = typed(context);
|
|
307
|
+
const known = declaredNames.get(program);
|
|
308
|
+
if (known)
|
|
309
|
+
return known;
|
|
310
|
+
const names = new Set();
|
|
311
|
+
const visit = (node) => {
|
|
312
|
+
if (ts.isCallExpression(node) && isDefineJobCall(hfs, checker, node)) {
|
|
313
|
+
const name = propertyValue(node.arguments[0], "name");
|
|
314
|
+
const type = name ? checker.getTypeAtLocation(name) : undefined;
|
|
315
|
+
if (type?.isStringLiteral())
|
|
316
|
+
names.add(type.value);
|
|
317
|
+
}
|
|
318
|
+
ts.forEachChild(node, visit);
|
|
319
|
+
};
|
|
320
|
+
for (const sourceFile of program.getSourceFiles()) {
|
|
321
|
+
if (!sourceFile.isDeclarationFile && hfs.slotOf(sourceFile.fileName) === "be.queues")
|
|
322
|
+
visit(sourceFile);
|
|
323
|
+
}
|
|
324
|
+
declaredNames.set(program, names);
|
|
325
|
+
return names;
|
|
326
|
+
};
|
|
327
|
+
/** The declared names per program: one scan serves every file linted in it. */
|
|
328
|
+
const declaredNames = new WeakMap();
|
|
329
|
+
/** The initializer of the property `name` in an object literal argument, or undefined. */
|
|
330
|
+
const propertyValue = (argument, name) => {
|
|
331
|
+
if (!argument || !ts.isObjectLiteralExpression(argument))
|
|
332
|
+
return undefined;
|
|
333
|
+
for (const property of argument.properties) {
|
|
334
|
+
if (ts.isPropertyAssignment(property) && ts.isIdentifier(property.name) && property.name.text === name)
|
|
335
|
+
return property.initializer;
|
|
336
|
+
}
|
|
337
|
+
return undefined;
|
|
338
|
+
};
|
|
339
|
+
/** True when a TypeScript call is `defineJob` of `platform/jobs`, judged by the declaration the callee resolves to. */
|
|
340
|
+
const isDefineJobCall = (hfs, checker, call) => {
|
|
341
|
+
const target = ts.isPropertyAccessExpression(call.expression) ? call.expression.name : call.expression;
|
|
342
|
+
let symbol = checker.getSymbolAtLocation(target);
|
|
343
|
+
if (symbol && (symbol.flags & ts.SymbolFlags.Alias) !== 0)
|
|
344
|
+
symbol = checker.getAliasedSymbol(symbol);
|
|
345
|
+
return symbol?.getName() === DEFINE_JOB && (symbol.declarations ?? []).some((declaration) => {
|
|
346
|
+
const owner = declaration.getSourceFile().fileName;
|
|
347
|
+
return hfs.tierOf(owner) === "platform" && ownerNameOf(hfs, owner) === "jobs";
|
|
348
|
+
});
|
|
349
|
+
};
|
|
350
|
+
/** The `defineJob` calls of an ESTree program, with the object literal they declare. */
|
|
351
|
+
const isDefineJobNode = (context, hfs, node) => {
|
|
352
|
+
const { checker, toTs } = typed(context);
|
|
353
|
+
const tsNode = toTs(node);
|
|
354
|
+
return Boolean(tsNode) && ts.isCallExpression(tsNode) && isDefineJobCall(hfs, checker, tsNode);
|
|
355
|
+
};
|
|
356
|
+
/** The value node of a property of an object literal, by key. */
|
|
357
|
+
const memberOf = (object, name) => object.properties.find((property) => property.type === "Property" && !property.computed && keyName(property.key) === name);
|
|
358
|
+
/** A job's `next` names only jobs a `defineJob` declares. */
|
|
359
|
+
export const jobNextDeclared = {
|
|
360
|
+
meta: {
|
|
361
|
+
type: "problem",
|
|
362
|
+
docs: { description: "In a `defineJob` declaration `next` is an array literal of statically readable job names, each the name of a job a `defineJob` of the program declares." },
|
|
363
|
+
schema: [],
|
|
364
|
+
messages: {
|
|
365
|
+
shape: "`next` of a job declaration is an array literal of job names. A computed, spread or variable list hides which jobs the job may enqueue, and the queue platform refuses an enqueue its `next` does not list; write the names out.",
|
|
366
|
+
literal: "This `next` entry is not a statically readable job name (a string literal or an enum member). Name the job the way its own `defineJob` does, so the chain can be read from the declarations.",
|
|
367
|
+
unknown: "`next` lists the job `{{name}}`, but no `defineJob` of the program declares a job of that name. A chain is the jobs the declarations name: declare the next job, or delete the entry.",
|
|
368
|
+
},
|
|
369
|
+
},
|
|
370
|
+
create(context) {
|
|
371
|
+
const hfs = hfsOf(context);
|
|
372
|
+
if (hfs.slotOf(context.filename) !== "be.queues")
|
|
373
|
+
return {};
|
|
374
|
+
const { checker, toTs } = typed(context);
|
|
375
|
+
return {
|
|
376
|
+
CallExpression(node) {
|
|
377
|
+
if (!isDefineJobNode(context, hfs, node))
|
|
378
|
+
return;
|
|
379
|
+
const [declaration] = node.arguments;
|
|
380
|
+
if (declaration?.type !== "ObjectExpression")
|
|
381
|
+
return;
|
|
382
|
+
const next = memberOf(declaration, NEXT);
|
|
383
|
+
if (!next)
|
|
384
|
+
return;
|
|
385
|
+
if (next.value.type !== "ArrayExpression") {
|
|
386
|
+
context.report({ node: next.value, messageId: "shape" });
|
|
387
|
+
return;
|
|
388
|
+
}
|
|
389
|
+
const declared = declaredJobNames(context, hfs);
|
|
390
|
+
for (const entry of next.value.elements) {
|
|
391
|
+
if (!entry || entry.type === "SpreadElement") {
|
|
392
|
+
context.report({ node: entry ?? next.value, messageId: "shape" });
|
|
393
|
+
continue;
|
|
394
|
+
}
|
|
395
|
+
const tsEntry = toTs(entry);
|
|
396
|
+
const type = tsEntry ? checker.getTypeAtLocation(tsEntry) : undefined;
|
|
397
|
+
if (!type?.isStringLiteral())
|
|
398
|
+
context.report({ node: entry, messageId: "literal" });
|
|
399
|
+
else if (!declared.has(type.value))
|
|
400
|
+
context.report({ node: entry, messageId: "unknown", data: { name: type.value } });
|
|
159
401
|
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
402
|
+
},
|
|
403
|
+
};
|
|
404
|
+
},
|
|
405
|
+
};
|
|
406
|
+
/** True when a type is a function type whose every return is `JobProgressTopic` of `platform/jobs`. */
|
|
407
|
+
const returnsProgressTopic = (checker, hfs, type) => {
|
|
408
|
+
const signatures = type.getCallSignatures();
|
|
409
|
+
return signatures.length > 0 && signatures.every((signature) => originsOfType(checker, checker.getReturnTypeOfSignature(signature)).some((origin) => origin.module === null && origin.name === PROGRESS_TOPIC && hfs.tierOf(origin.file) === "platform" && ownerNameOf(hfs, origin.file) === "jobs"));
|
|
410
|
+
};
|
|
411
|
+
/** A job's progress is a view the frame publishes: its topic is built principal-first, and no domain method publishes it itself. */
|
|
412
|
+
export const jobProgressShape = {
|
|
413
|
+
meta: {
|
|
414
|
+
type: "problem",
|
|
415
|
+
docs: { description: "A `defineJob` `progress.topic` is a function whose declared return type is `JobProgressTopic` of `platform/jobs` (principal first), and a function that takes a `ClaimedJob` never calls the `RealtimeHub`: it reports through `JobProgress`." },
|
|
416
|
+
schema: [],
|
|
417
|
+
messages: {
|
|
418
|
+
topic: "The `progress.topic` of this job does not return a `JobProgressTopic` of `platform/jobs`. A progress topic is principal first, then the chain root, so a client can only read what its principal owns: build it with a function whose declared return type is `JobProgressTopic`, never an object literal or a string.",
|
|
419
|
+
hub: "`{{call}}` publishes to the realtime hub from a function that takes a `ClaimedJob`. The progress of a job is a view the jobs frame publishes after commit: report step progress through `JobProgress.report(job, done, total, labelKey)`, which stores it on the job row first.",
|
|
420
|
+
},
|
|
421
|
+
},
|
|
422
|
+
create(context) {
|
|
423
|
+
const hfs = hfsOf(context);
|
|
424
|
+
const file = context.filename;
|
|
425
|
+
const inQueues = hfs.slotOf(file) === "be.queues";
|
|
426
|
+
const inDomain = hfs.tierOf(file) === "domain";
|
|
427
|
+
if (!inQueues && !inDomain)
|
|
428
|
+
return {};
|
|
429
|
+
const { checker, toTs } = typed(context);
|
|
430
|
+
return {
|
|
431
|
+
CallExpression(node) {
|
|
432
|
+
if (inQueues && isDefineJobNode(context, hfs, node)) {
|
|
433
|
+
const [declaration] = node.arguments;
|
|
434
|
+
if (declaration?.type !== "ObjectExpression")
|
|
435
|
+
return;
|
|
436
|
+
const progress = memberOf(declaration, PROGRESS);
|
|
437
|
+
if (progress?.value.type !== "ObjectExpression")
|
|
438
|
+
return;
|
|
439
|
+
const topic = memberOf(progress.value, TOPIC);
|
|
440
|
+
const tsTopic = topic ? toTs(topic.value) : undefined;
|
|
441
|
+
if (!topic || !tsTopic || !returnsProgressTopic(checker, hfs, checker.getTypeAtLocation(tsTopic)))
|
|
442
|
+
context.report({ node: topic ?? progress.value, messageId: "topic" });
|
|
443
|
+
return;
|
|
163
444
|
}
|
|
445
|
+
const callee = node.callee;
|
|
446
|
+
if (!inDomain || callee.type !== "MemberExpression" || callee.computed)
|
|
447
|
+
return;
|
|
448
|
+
if (!isRealtimeHubType(context, callee.object) || !insideJobFunction(context, node))
|
|
449
|
+
return;
|
|
450
|
+
context.report({ node, messageId: "hub", data: { call: context.sourceCode.getText(callee) } });
|
|
164
451
|
},
|
|
165
452
|
};
|
|
166
453
|
},
|
|
@@ -219,13 +506,17 @@ export const jobShape = {
|
|
|
219
506
|
export const rules = {
|
|
220
507
|
"job-write-owner": jobWriteOwner,
|
|
221
508
|
"job-fence-required": jobFenceRequired,
|
|
222
|
-
"job-
|
|
509
|
+
"job-effect-piece": jobEffectPiece,
|
|
223
510
|
"job-shape": jobShape,
|
|
511
|
+
"job-next-declared": jobNextDeclared,
|
|
512
|
+
"job-progress-shape": jobProgressShape,
|
|
224
513
|
};
|
|
225
514
|
/** The level these laws ask for: `error`, switched off nowhere. */
|
|
226
515
|
export const recommended = {
|
|
227
516
|
"starci-be/job-write-owner": "error",
|
|
228
517
|
"starci-be/job-fence-required": "error",
|
|
229
|
-
"starci-be/job-
|
|
518
|
+
"starci-be/job-effect-piece": "error",
|
|
230
519
|
"starci-be/job-shape": "error",
|
|
520
|
+
"starci-be/job-next-declared": "error",
|
|
521
|
+
"starci-be/job-progress-shape": "error",
|
|
231
522
|
};
|
package/dist/lib/config.d.ts
CHANGED
|
@@ -38,17 +38,18 @@ export declare const buildBeConfig: ({ hfs, plugin, recommended }: {
|
|
|
38
38
|
plugin: CanonPlugin | null | undefined;
|
|
39
39
|
recommended?: Recommended | undefined;
|
|
40
40
|
}) => Promise<TSESLint.FlatConfig.ConfigArray>;
|
|
41
|
-
/** The back-end
|
|
41
|
+
/** The back-end files of a root workspace package: every script file under `src/` no slot of the project hands to the front-end canon (`lint: fe`, ext/manifest.json packages). */
|
|
42
42
|
export declare const PACKAGE_SOURCE_FILES: readonly string[];
|
|
43
43
|
/** What a package folder never lints: build output, coverage output and installed packages. */
|
|
44
44
|
export declare const PACKAGE_IGNORED: readonly string[];
|
|
45
45
|
/**
|
|
46
|
-
* The flat config of the back-end
|
|
47
|
-
* `packages/<pkg>/src
|
|
48
|
-
*
|
|
49
|
-
*
|
|
46
|
+
* The flat config of the back-end files of the root workspace packages of an app: the config of a back end, with the files narrowed to
|
|
47
|
+
* `packages/<pkg>/src/**`. Which files are the front end's is the project's declaration, never a folder name this canon knows: a slot of
|
|
48
|
+
* `ext/manifest.json` `packages` with `lint: "fe"` is left to the front-end canon, and the first slot that holds a file decides
|
|
49
|
+
* (`hfs.packageLint`, PROJECT-LINT-3), so a back-end slot declared before a front-end slot it lies in stays back end. A package the project
|
|
50
|
+
* does not declare is back end whole. It is the very rule set of the be side, over the package view of the app root (`loadPackagesHfs`).
|
|
50
51
|
*
|
|
51
52
|
* @param {object} input - The attachment options of `buildBeConfig`.
|
|
52
|
-
* @returns {Promise<Array<object>>} The flat config: one ignore block and the rule and Sonar way blocks over the package
|
|
53
|
+
* @returns {Promise<Array<object>>} The flat config: one ignore block and the rule and Sonar way blocks over the package files.
|
|
53
54
|
*/
|
|
54
55
|
export declare const buildBePackagesConfig: (input: Parameters<typeof buildBeConfig>[0]) => Promise<TSESLint.FlatConfig.ConfigArray>;
|
package/dist/lib/config.js
CHANGED
|
@@ -101,32 +101,34 @@ export const buildBeConfig = async ({ hfs, plugin, recommended }) => {
|
|
|
101
101
|
{ name: TEST_SCOPE_BLOCK, files: [...SPEC_FILES], plugins: { sonarjs }, rules: sonarWayTestRules(sonarjs) },
|
|
102
102
|
];
|
|
103
103
|
};
|
|
104
|
-
/** The back-end
|
|
104
|
+
/** The back-end files of a root workspace package: every script file under `src/` no slot of the project hands to the front-end canon (`lint: fe`, ext/manifest.json packages). */
|
|
105
105
|
export const PACKAGE_SOURCE_FILES = Object.freeze(["packages/*/src/**/*.{ts,mts,cts,js,mjs,cjs}"]);
|
|
106
106
|
const PACKAGE_SPEC_FILES = Object.freeze(["packages/*/src/**/*.{spec,e2e-spec}.{ts,mts,cts,js,mjs,cjs}"]);
|
|
107
|
-
const
|
|
108
|
-
const
|
|
109
|
-
const PACKAGE_CONTRACT_FILES = Object.freeze(["packages/*/src/workbench/contract/**/*.{ts,mts,cts,js,mjs,cjs}"]);
|
|
107
|
+
const SCRIPT = "**/*.{ts,mts,cts,js,mjs,cjs}";
|
|
108
|
+
const SCRIPT_SPEC = "**/*.{spec,e2e-spec}.{ts,mts,cts,js,mjs,cjs}";
|
|
110
109
|
/** What a package folder never lints: build output, coverage output and installed packages. */
|
|
111
110
|
export const PACKAGE_IGNORED = Object.freeze(["**/dist/**", "**/coverage/**", "**/node_modules/**"]);
|
|
112
111
|
/**
|
|
113
|
-
* The flat config of the back-end
|
|
114
|
-
* `packages/<pkg>/src
|
|
115
|
-
*
|
|
116
|
-
*
|
|
112
|
+
* The flat config of the back-end files of the root workspace packages of an app: the config of a back end, with the files narrowed to
|
|
113
|
+
* `packages/<pkg>/src/**`. Which files are the front end's is the project's declaration, never a folder name this canon knows: a slot of
|
|
114
|
+
* `ext/manifest.json` `packages` with `lint: "fe"` is left to the front-end canon, and the first slot that holds a file decides
|
|
115
|
+
* (`hfs.packageLint`, PROJECT-LINT-3), so a back-end slot declared before a front-end slot it lies in stays back end. A package the project
|
|
116
|
+
* does not declare is back end whole. It is the very rule set of the be side, over the package view of the app root (`loadPackagesHfs`).
|
|
117
117
|
*
|
|
118
118
|
* @param {object} input - The attachment options of `buildBeConfig`.
|
|
119
|
-
* @returns {Promise<Array<object>>} The flat config: one ignore block and the rule and Sonar way blocks over the package
|
|
119
|
+
* @returns {Promise<Array<object>>} The flat config: one ignore block and the rule and Sonar way blocks over the package files.
|
|
120
120
|
*/
|
|
121
121
|
export const buildBePackagesConfig = async (input) => {
|
|
122
122
|
const [, ...blocks] = await buildBeConfig(input);
|
|
123
|
+
const lint = input.hfs?.packageLint ?? { frontEnd: [], fe: [], be: [] };
|
|
123
124
|
return [
|
|
124
125
|
{ ignores: [...PACKAGE_IGNORED] },
|
|
125
126
|
...blocks.flatMap((block) => {
|
|
126
127
|
const tests = block.name === TEST_SCOPE_BLOCK;
|
|
127
128
|
return [
|
|
128
|
-
{ ...block, files: [...(tests ? PACKAGE_SPEC_FILES : PACKAGE_SOURCE_FILES)], ignores: [...(block.ignores ?? []), ...
|
|
129
|
-
|
|
129
|
+
{ ...block, files: [...(tests ? PACKAGE_SPEC_FILES : PACKAGE_SOURCE_FILES)], ignores: [...(block.ignores ?? []), ...lint.frontEnd] },
|
|
130
|
+
// A back-end slot declared before a front-end slot that reaches it: its files, less the front-end slots declared before it.
|
|
131
|
+
...lint.be.map((scope) => ({ ...block, files: [[scope.files, tests ? SCRIPT_SPEC : SCRIPT]], ignores: [...(block.ignores ?? []), ...scope.ignores] })),
|
|
130
132
|
];
|
|
131
133
|
}),
|
|
132
134
|
];
|
package/dist/lib/hfs-view.d.ts
CHANGED
|
@@ -90,6 +90,18 @@ export interface HfsSpecDouble {
|
|
|
90
90
|
readonly double: string;
|
|
91
91
|
readonly forms: readonly string[];
|
|
92
92
|
}
|
|
93
|
+
/** A declared receipt port (`ruleParams.receiptPorts`): the single form answers a repeat `false` or `undefined`; the many form answers the new events. */
|
|
94
|
+
export type HfsReceiptPort = {
|
|
95
|
+
readonly class: string;
|
|
96
|
+
readonly method: string;
|
|
97
|
+
readonly reason: string;
|
|
98
|
+
} & ({
|
|
99
|
+
readonly repeat: "false" | "undefined";
|
|
100
|
+
readonly many?: undefined;
|
|
101
|
+
} | {
|
|
102
|
+
readonly many: true;
|
|
103
|
+
readonly repeat?: undefined;
|
|
104
|
+
});
|
|
93
105
|
/** The rule parameters of the be profile (`ruleParams.common` merged with `ruleParams.be`), by the keys the rules read. */
|
|
94
106
|
export interface HfsRuleParams {
|
|
95
107
|
readonly functionLines?: number;
|
|
@@ -126,6 +138,11 @@ export interface HfsRuleParams {
|
|
|
126
138
|
readonly path: string;
|
|
127
139
|
readonly reason: string;
|
|
128
140
|
}[];
|
|
141
|
+
/**
|
|
142
|
+
* The receipt ports the app declares (hfs.json `sides.be.receiptPorts`): a class of the app, its method that records a delivery once, and the
|
|
143
|
+
* answer it gives a repeat; or `many: true` for a delivery of several events, whose method answers the list of the new ones (R263).
|
|
144
|
+
*/
|
|
145
|
+
readonly receiptPorts?: readonly HfsReceiptPort[];
|
|
129
146
|
}
|
|
130
147
|
/** The frozen view of one side of an app. */
|
|
131
148
|
export interface HfsView {
|
|
@@ -154,6 +171,19 @@ export interface HfsView {
|
|
|
154
171
|
slot(id: string): HfsSlot | undefined;
|
|
155
172
|
/** The vocabulary the root package of a file declares in the `starci` key of its manifest (the view of the root packages only), or null outside a package. */
|
|
156
173
|
readonly packageContract?: (file: string) => HfsPackageContract | null;
|
|
174
|
+
/** What each canon lints of the root packages the project declares slots for (the view of the root packages only). */
|
|
175
|
+
readonly packageLint?: HfsPackageLint;
|
|
176
|
+
}
|
|
177
|
+
/** One lint scope of a declared package: the files of one slot (an app-relative glob), less the globs an earlier slot of the other canon holds. */
|
|
178
|
+
export interface HfsPackageLintScope {
|
|
179
|
+
readonly files: string;
|
|
180
|
+
readonly ignores: readonly string[];
|
|
181
|
+
}
|
|
182
|
+
/** The first-slot-wins partition of the declared packages: every `lint: fe` slot, the front-end scopes, and the back-end slots a later front-end slot reaches. */
|
|
183
|
+
export interface HfsPackageLint {
|
|
184
|
+
readonly frontEnd: readonly string[];
|
|
185
|
+
readonly fe: readonly HfsPackageLintScope[];
|
|
186
|
+
readonly be: readonly HfsPackageLintScope[];
|
|
157
187
|
}
|
|
158
188
|
/** A type a root package declares: its name and the app-root relative file that declares it. */
|
|
159
189
|
export interface HfsPackageDeclaredType {
|
|
@@ -9,7 +9,7 @@ export interface InjectionSite {
|
|
|
9
9
|
readonly annotation: TSESTree.TypeNode | null;
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
|
-
* PascalCase of a connection name: `
|
|
12
|
+
* PascalCase of a connection name: `reporting` gives `Reporting`.
|
|
13
13
|
*
|
|
14
14
|
* @param {string} name - A kebab-case connection name from `hfs.json`.
|
|
15
15
|
* @returns {string} The PascalCase form.
|
package/dist/lib/persistence.js
CHANGED
|
@@ -11,7 +11,7 @@ import { typeOrigins } from "./types.js";
|
|
|
11
11
|
/** The `typeorm` types a class must never receive except through the platform database capability. */
|
|
12
12
|
const INFRA_TYPES = new Set(["EntityManager", "DataSource", "QueryRunner"]);
|
|
13
13
|
/**
|
|
14
|
-
* PascalCase of a connection name: `
|
|
14
|
+
* PascalCase of a connection name: `reporting` gives `Reporting`.
|
|
15
15
|
*
|
|
16
16
|
* @param {string} name - A kebab-case connection name from `hfs.json`.
|
|
17
17
|
* @returns {string} The PascalCase form.
|
|
@@ -95,7 +95,7 @@ export const connectionFileOf = (hfs, file, role) => {
|
|
|
95
95
|
return connectionsOf(hfs).find((connection) => connection.name === name) ?? null;
|
|
96
96
|
};
|
|
97
97
|
/** The platform capabilities that own a `persistence/` and so may hold an `EntityManager` (a pattern capability is named by its folder). */
|
|
98
|
-
const PERSISTENCE_CAPABILITIES = ["database", "inbox", "event-bus", "queue", "jobs", "saga", "outbox", "realtime", "http-security"];
|
|
98
|
+
const PERSISTENCE_CAPABILITIES = ["database", "inbox", "event-bus", "queue", "jobs", "effects", "saga", "outbox", "realtime", "http-security"];
|
|
99
99
|
/**
|
|
100
100
|
* Whether a class in this file may receive an `EntityManager`: an application handler, a domain service, a projection, a typed queue producer (it takes the transaction of its caller), a platform persistence capability.
|
|
101
101
|
*
|
|
@@ -1,8 +1,18 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* R263 extends inbox dedupe to scalar delivery ids and signed raw-body intakes. The claim is the platform Inbox's `claim` or `claimRow`, or the
|
|
3
|
+
* method of a receipt port the app declares in hfs.json `sides.be.receiptPorts` (`{ class, method, repeat, reason }`): a class of the app whose
|
|
4
|
+
* method takes the transaction's manager first and answers a repeat exactly as the Inbox does (`false`, or `undefined`). A declared call is held
|
|
5
|
+
* to the same contract: inside the receipt transaction, on that transaction's manager, with an argument that comes from the delivery, before any
|
|
6
|
+
* other work, and followed at once by the return on a repeat. A port declared `many: true` (`{ class, method, many, reason }`) records a delivery
|
|
7
|
+
* of several events and answers the list of the new ones (a repeat answers the empty list): its answer is bound to one `const`, and every later
|
|
8
|
+
* statement of the receipt transaction is a `for (const <name> of <that const>)` whose body reads nothing of the intake but the transaction's
|
|
9
|
+
* manager and the loop's own bindings.
|
|
10
|
+
*/
|
|
2
11
|
import ts from "typescript";
|
|
3
12
|
import { memberKeyValue, nameOrValue, walk } from "./ast.js";
|
|
4
13
|
import { hfsOf } from "./hfs.js";
|
|
5
14
|
import { baseName, inboxClaimOf, ownerNameOf, refusesRepeat } from "./ports.js";
|
|
15
|
+
import { typeOrigins } from "./types.js";
|
|
6
16
|
import { resolveVariable } from "./transactions.js";
|
|
7
17
|
import { isPackageType, typed } from "./types.js";
|
|
8
18
|
import { webhookIntakeProcessesDelivery } from "./webhook-handoff-intake.js";
|
|
@@ -129,6 +139,102 @@ const usesKey = (context, argument, key) => {
|
|
|
129
139
|
&& sameBinding(context, argument.object, key.parameter)
|
|
130
140
|
&& key.properties.some((name) => name === memberKeyValue(argument));
|
|
131
141
|
};
|
|
142
|
+
/**
|
|
143
|
+
* The repeat answer of a declared receipt port's call (`claim` for `false`, `claimRow` for `undefined`, `many` for the list of new events), or null:
|
|
144
|
+
* a plain member call, without a spread, of a declared method on a receiver whose type is the declared class, declared in the app's own source (a
|
|
145
|
+
* slot owns its file; a class of a package, or a lookalike under another name, is none).
|
|
146
|
+
*/
|
|
147
|
+
const receiptPortClaimOf = (context, hfs, call) => {
|
|
148
|
+
const ports = hfs.ruleParams.receiptPorts ?? [];
|
|
149
|
+
if (ports.length === 0 || call?.type !== "CallExpression" || call.optional)
|
|
150
|
+
return null;
|
|
151
|
+
const callee = call.callee;
|
|
152
|
+
if (callee.type !== "MemberExpression" || callee.computed || callee.optional || callee.property.type !== "Identifier")
|
|
153
|
+
return null;
|
|
154
|
+
if (call.arguments.length < 2 || call.arguments.some((argument) => argument.type === "SpreadElement"))
|
|
155
|
+
return null;
|
|
156
|
+
const method = callee.property.name;
|
|
157
|
+
const origins = typeOrigins(context, callee.object).filter((origin) => origin.module === null && hfs.slotOf(origin.file) !== null && hfs.slotOf(origin.file) !== undefined);
|
|
158
|
+
const port = ports.find((entry) => entry.method === method && origins.some((origin) => origin.name === entry.class));
|
|
159
|
+
if (port === undefined)
|
|
160
|
+
return null;
|
|
161
|
+
if (port.many === true)
|
|
162
|
+
return "many";
|
|
163
|
+
return port.repeat === "false" ? "claim" : "claimRow";
|
|
164
|
+
};
|
|
165
|
+
/** A node lies inside another: its range is within the other's. */
|
|
166
|
+
const within = (inner, outer) => inner.range[0] >= outer.range[0] && inner.range[1] <= outer.range[1];
|
|
167
|
+
/**
|
|
168
|
+
* A loop body reads nothing of the intake but the receipt transaction's manager: every identifier it reads (in nested functions too, `arguments`
|
|
169
|
+
* included) binds outside the intake method, inside the loop itself, or to the manager. A non-computed property name reads nothing.
|
|
170
|
+
*/
|
|
171
|
+
const readsOnlyLoop = (context, method, loop, manager) => {
|
|
172
|
+
const own = resolveVariable(context.sourceCode, manager);
|
|
173
|
+
let only = true;
|
|
174
|
+
walk(loop.body, (node) => {
|
|
175
|
+
if (node.type !== "Identifier")
|
|
176
|
+
return;
|
|
177
|
+
const parent = node.parent;
|
|
178
|
+
if (parent?.type === "MemberExpression" && parent.property === node && !parent.computed)
|
|
179
|
+
return;
|
|
180
|
+
if (parent?.type === "Property" && parent.key === node && !parent.computed && !parent.shorthand)
|
|
181
|
+
return;
|
|
182
|
+
const variable = resolveVariable(context.sourceCode, node);
|
|
183
|
+
if (variable && variable !== own && within(variable.scope.block, method.value) && !within(variable.scope.block, loop))
|
|
184
|
+
only = false;
|
|
185
|
+
});
|
|
186
|
+
return only;
|
|
187
|
+
};
|
|
188
|
+
/**
|
|
189
|
+
* The effects after a declared `many` call only iterate the new events it answers: the answer is bound by a `const` of one name, and every
|
|
190
|
+
* later statement of the receipt transaction is a plain `for (const <name> of <that const>)` (no `for await`, no other iterable, nothing between
|
|
191
|
+
* or after) whose body reads nothing of the intake but the manager and its own bindings; the raw delivery, the bindings made before the claim and
|
|
192
|
+
* the answer list itself stay out of reach.
|
|
193
|
+
*/
|
|
194
|
+
const iteratesOnlyNew = (context, method, awaited, body, manager) => {
|
|
195
|
+
const parent = awaited.parent;
|
|
196
|
+
if (parent.type !== "VariableDeclarator" || parent.id.type !== "Identifier" || parent.init !== awaited)
|
|
197
|
+
return false;
|
|
198
|
+
const declaration = parent.parent;
|
|
199
|
+
const index = body.body.indexOf(declaration);
|
|
200
|
+
if (index === -1 || declaration.kind !== "const" || declaration.declarations.length !== 1)
|
|
201
|
+
return false;
|
|
202
|
+
const answer = parent.id;
|
|
203
|
+
return body.body.slice(index + 1).every((entry) => entry.type === "ForOfStatement" && !entry.await
|
|
204
|
+
&& entry.left.type === "VariableDeclaration" && entry.left.kind === "const" && entry.left.declarations.length === 1
|
|
205
|
+
&& entry.left.declarations[0]?.id.type === "Identifier"
|
|
206
|
+
&& entry.right.type === "Identifier" && sameBinding(context, entry.right, answer)
|
|
207
|
+
&& readsOnlyLoop(context, method, entry, manager));
|
|
208
|
+
};
|
|
209
|
+
/** An argument of a declared receipt call comes from the delivery: it reads a parameter of the intake, directly or through `const` bindings; a literal reads nothing. */
|
|
210
|
+
const fromDelivery = (context, method, expression, seen = new Set()) => {
|
|
211
|
+
if (!expression || seen.has(expression))
|
|
212
|
+
return false;
|
|
213
|
+
seen.add(expression);
|
|
214
|
+
let sourced = false;
|
|
215
|
+
walk(expression, (node) => {
|
|
216
|
+
if (node.type !== "Identifier")
|
|
217
|
+
return;
|
|
218
|
+
const variable = resolveVariable(context.sourceCode, node);
|
|
219
|
+
for (const definition of variable?.defs ?? []) {
|
|
220
|
+
if (definition.type === "Parameter" && definition.node === method.value)
|
|
221
|
+
sourced = true;
|
|
222
|
+
if (definition.type === "Variable" && definition.parent.kind === "const" && fromDelivery(context, method, definition.node.init, seen))
|
|
223
|
+
sourced = true;
|
|
224
|
+
}
|
|
225
|
+
}, { intoFunctions: false });
|
|
226
|
+
return sourced;
|
|
227
|
+
};
|
|
228
|
+
/** The arguments of a declared receipt call hold no call, construction or assignment: what they need is bound by a `const` before the claim. */
|
|
229
|
+
const plainArguments = (call) => {
|
|
230
|
+
let plain = true;
|
|
231
|
+
for (const argument of call.arguments)
|
|
232
|
+
walk(argument, (node) => {
|
|
233
|
+
if (["CallExpression", "NewExpression", "AssignmentExpression", "UpdateExpression", "AwaitExpression"].includes(node.type))
|
|
234
|
+
plain = false;
|
|
235
|
+
}, { intoFunctions: false });
|
|
236
|
+
return plain;
|
|
237
|
+
};
|
|
132
238
|
/** Find the first completed await, without treating a nested helper as work performed here. */
|
|
133
239
|
const firstAwait = (body) => {
|
|
134
240
|
let result = null;
|
|
@@ -147,12 +253,12 @@ const preservesKey = (context, key, call) => {
|
|
|
147
253
|
return variable !== null && !variable.references.some((reference) => reference.isWrite() && !reference.init
|
|
148
254
|
&& reference.identifier.range[0] < call.range[1]);
|
|
149
255
|
};
|
|
150
|
-
/** Scalar/DTO claims are the first statement; a raw intake may first bind its decoded key. */
|
|
151
|
-
const claimsBeforeWork = (context, body, statement, key, call) => {
|
|
256
|
+
/** Scalar/DTO claims are the first statement; a raw intake may first bind its decoded key, and a declared receipt call the `const` bindings its arguments read. */
|
|
257
|
+
const claimsBeforeWork = (context, body, statement, key, call, declared = false) => {
|
|
152
258
|
const index = body.body.findIndex((entry) => entry === statement);
|
|
153
259
|
if (index === 0)
|
|
154
260
|
return true;
|
|
155
|
-
if (index < 0 || !key.raw)
|
|
261
|
+
if (index < 0 || (!key.raw && !declared))
|
|
156
262
|
return false;
|
|
157
263
|
const dependencies = new Set();
|
|
158
264
|
const read = (expression) => {
|
|
@@ -170,7 +276,8 @@ const claimsBeforeWork = (context, body, statement, key, call) => {
|
|
|
170
276
|
read(definition.node.init);
|
|
171
277
|
}, { intoFunctions: false });
|
|
172
278
|
};
|
|
173
|
-
|
|
279
|
+
for (const argument of declared ? call.arguments.slice(1) : [call.arguments[1]])
|
|
280
|
+
read(argument);
|
|
174
281
|
return body.body.slice(0, index).every((entry) => entry.type === "VariableDeclaration" && entry.kind === "const"
|
|
175
282
|
&& entry.declarations.every((declaration) => declaration.id.type === "Identifier" && dependencies.has(resolveVariable(context.sourceCode, declaration.id))));
|
|
176
283
|
};
|
|
@@ -237,7 +344,7 @@ export const webhookInboxKey = {
|
|
|
237
344
|
docs: { description: "Delivery methods with first *Id parameters or DTO properties, or raw-body signature contracts, claim the real Inbox (claim, or claimRow on its EntityInbox) with a stable delivery key before work and return on duplicates. Receipt transactions publish events and leave processing to a reactor/job." },
|
|
238
345
|
schema: [],
|
|
239
346
|
messages: {
|
|
240
|
-
key: "[BE_WEBHOOK_INBOX_KEY] This delivery intake must first await the real platform/inbox claim(source, deliveryId), or claimRow(source, deliveryId, tx, receipt) on its EntityInbox, using its first *Id parameter or DTO property, or a decoded id for a signed raw-body intake, and return immediately on a repeat (claim answers false, claimRow undefined). A transaction claim uses that callback's own manager; raw payloads and fixed literals are not delivery keys.",
|
|
347
|
+
key: "[BE_WEBHOOK_INBOX_KEY] This delivery intake must first await the real platform/inbox claim(source, deliveryId), or claimRow(source, deliveryId, tx, receipt) on its EntityInbox, using its first *Id parameter or DTO property, or a decoded id for a signed raw-body intake, and return immediately on a repeat (claim answers false, claimRow undefined). A transaction claim uses that callback's own manager; raw payloads and fixed literals are not delivery keys. A receipt port the app declares in hfs.json sides.be.receiptPorts is held to the same contract: awaited first inside the receipt transaction, on that transaction's manager as its first argument, with an argument that comes from the delivery and no call inside its arguments, and its declared repeat answer (false or undefined) returned on at once; a port declared many: true answers the list of the new events, bound to one const, and every later statement of the transaction is a for (const event of <that const>) whose body reads nothing of the delivery.",
|
|
241
348
|
handoff: "[BE_WEBHOOK_INBOX_KEY] A receipt transaction records the inbox delivery and publishes the typed event. Remove the process callback and domain/command processing from this transaction; a reactor or job processes the delivery after commit.",
|
|
242
349
|
},
|
|
243
350
|
},
|
|
@@ -275,7 +382,17 @@ export const webhookInboxKey = {
|
|
|
275
382
|
&& claimsBeforeWork(context, body, statement, key, call)
|
|
276
383
|
&& !priorWork(statement, call)
|
|
277
384
|
&& rejectsDuplicate(context, awaited, body, claimMethod);
|
|
278
|
-
|
|
385
|
+
// A declared receipt port: the same contract, on the transaction's own manager (its first argument), keyed by the delivery.
|
|
386
|
+
const portMethod = claimMethod === null ? receiptPortClaimOf(context, hfs, call) : null;
|
|
387
|
+
const receives = awaited !== null && call?.type === "CallExpression" && portMethod !== null
|
|
388
|
+
&& manager !== null && sameBinding(context, call.arguments[0], manager)
|
|
389
|
+
&& plainArguments(call)
|
|
390
|
+
&& call.arguments.slice(1).some((argument) => argument.type !== "Literal" && fromDelivery(context, method, argument))
|
|
391
|
+
&& !(key.raw && call.arguments.slice(1).some((argument) => sameBinding(context, argument, key.parameter)))
|
|
392
|
+
&& claimsBeforeWork(context, body, statement, key, call, true)
|
|
393
|
+
&& !priorWork(statement, call)
|
|
394
|
+
&& (portMethod === "many" ? iteratesOnlyNew(context, method, awaited, body, manager) : rejectsDuplicate(context, awaited, body, portMethod));
|
|
395
|
+
if (!claims && !receives)
|
|
279
396
|
context.report({ node: method.key, messageId: "key" });
|
|
280
397
|
},
|
|
281
398
|
};
|
|
@@ -68,6 +68,20 @@ const isReceiptPort = (checker, hfs, type) => {
|
|
|
68
68
|
const isInbox = (origin) => origin.module === null && ["Inbox", "EntityInbox"].includes(origin.name) && hfs.tierOf(origin.file) === "platform" && ownerNameOf(hfs, origin.file) === "inbox";
|
|
69
69
|
return dependencies.every((origins) => origins.length > 0 && origins.every(isPort)) && dependencies.some((origins) => origins.some(isInbox));
|
|
70
70
|
};
|
|
71
|
+
/**
|
|
72
|
+
* A call of a receipt port the app declares (hfs.json `sides.be.receiptPorts`): the declared method on a receiver whose type is the declared class
|
|
73
|
+
* of the app's own source. Inside the receipt transaction it is the delivery's record itself, as a call on the platform Inbox is; any other
|
|
74
|
+
* method of that class is judged like any other domain call.
|
|
75
|
+
*/
|
|
76
|
+
const isDeclaredReceiptCall = (checker, hfs, call) => {
|
|
77
|
+
const ports = hfs.ruleParams.receiptPorts ?? [];
|
|
78
|
+
const callee = call.expression;
|
|
79
|
+
if (ports.length === 0 || !ts.isPropertyAccessExpression(callee))
|
|
80
|
+
return false;
|
|
81
|
+
const method = callee.name.text;
|
|
82
|
+
return hasOrigin(checker, callee.expression, (origin) => origin.module === null && hfs.slotOf(origin.file) !== null && hfs.slotOf(origin.file) !== undefined
|
|
83
|
+
&& ports.some((port) => port.class === origin.name && port.method === method));
|
|
84
|
+
};
|
|
71
85
|
/** The transaction port's package establishes when the callback runs before commit. */
|
|
72
86
|
const isTransactionCall = (checker, call, receiver) => memberName(call.expression) === "transaction"
|
|
73
87
|
&& hasOrigin(checker, receiver, (origin) => origin.module === "typeorm" && ["EntityManager", "DataSource"].includes(origin.name));
|
|
@@ -129,7 +143,7 @@ const processesDelivery = (checker, hfs, body) => {
|
|
|
129
143
|
if (isProcessCallback(checker, node))
|
|
130
144
|
found = true;
|
|
131
145
|
if (ts.isCallExpression(node)) {
|
|
132
|
-
if (inTransaction && isBusinessCall(checker, hfs, node.expression))
|
|
146
|
+
if (inTransaction && isBusinessCall(checker, hfs, node.expression) && !isDeclaredReceiptCall(checker, hfs, node))
|
|
133
147
|
found = true;
|
|
134
148
|
const callee = node.expression;
|
|
135
149
|
if ((ts.isPropertyAccessExpression(callee) || ts.isElementAccessExpression(callee)) && isTransactionCall(checker, node, callee.expression)) {
|
|
@@ -34,7 +34,7 @@ const isDomainVerifierType = (context, hfs, receiver) => {
|
|
|
34
34
|
};
|
|
35
35
|
/**
|
|
36
36
|
* A provider's adjacent HTTP module may export webhookVerifiers as an array of
|
|
37
|
-
* domain methods, e.g. [BillingService.prototype.
|
|
37
|
+
* domain methods, e.g. [BillingService.prototype.receiveGammaPayWebhook] as const.
|
|
38
38
|
* Compare symbols, so spelling an arbitrary receiver or alias as a verifier grants nothing.
|
|
39
39
|
*/
|
|
40
40
|
const declaresMethod = (checker, statement, method) => {
|
package/dist/module-shape.js
CHANGED
|
@@ -499,7 +499,7 @@ const isModuleDeclaration = (declaration) => {
|
|
|
499
499
|
};
|
|
500
500
|
/** The array of an `imports` property (the `@Module({ imports })` metadata or a dynamic module literal), else null. */
|
|
501
501
|
const importsArrayOf = (property) => (!property.computed && keyName(property.key) === "imports" && property.value.type === "ArrayExpression" ? property.value : null);
|
|
502
|
-
/** The PascalCase options type name a module file name implies: `
|
|
502
|
+
/** The PascalCase options type name a module file name implies: `acme-pay-feed-http` gives `AcmePayFeedHttpOptions`. */
|
|
503
503
|
const optionsTypeOf = (name) => `${name.replace(/(?:^|-)(\w)/g, (_, letter) => letter.toUpperCase())}Options`;
|
|
504
504
|
/**
|
|
505
505
|
* Every Nest module has a module definition and is registered through it: its
|
package/dist/projections.js
CHANGED
|
@@ -21,7 +21,7 @@ const isTestComposition = (hfs, file) => {
|
|
|
21
21
|
const tier = hfs.tierOf(file);
|
|
22
22
|
return tier === "e2e" || tier === "fixtures" || inTestWorld(hfs, file);
|
|
23
23
|
};
|
|
24
|
-
/** The word a method name starts with (`
|
|
24
|
+
/** The word a method name starts with (`recomputeUserScore` gives `recompute`), or null when the name has no camelCase boundary. */
|
|
25
25
|
const verbOf = (name) => {
|
|
26
26
|
const match = /^[a-z]+/.exec(name);
|
|
27
27
|
return match && (match[0].length === name.length || /[A-Z]/.test(name.charAt(match[0].length))) ? match[0] : null;
|
package/dist/realtime.js
CHANGED
|
@@ -10,11 +10,14 @@
|
|
|
10
10
|
* `.subscription.ts` holds one `@Resolver` class whose operations are `@Subscription`, and an SSE `.controller.ts` holds one
|
|
11
11
|
* `@Controller` class whose one route is `@Sse`. Each is the door its file role names, and none carries a query, a mutation or a
|
|
12
12
|
* plain REST route.
|
|
13
|
-
* - `realtime-read-only` (R185): the only value injected into a realtime door is the `RealtimeHub` of `platform/realtime
|
|
14
|
-
*
|
|
13
|
+
* - `realtime-read-only` (R185): the only value injected into a realtime door is the `RealtimeHub` of `platform/realtime`, or, in an SSE
|
|
14
|
+
* door, ONE stream read service: a class of the platform or domain tier whose public methods all answer an rxjs `Observable`, so the
|
|
15
|
+
* read of "current state, then live" happens in that service and the door stays one call. No `EntityManager`, bus, queue, event bus
|
|
16
|
+
* or other domain service reaches it.
|
|
15
17
|
* - `realtime-topic-scope` (R186): the topic passed to `hub.subscribe` (or `hub.stream`, the SSE form) is built from the principal parameter of the handler
|
|
16
18
|
* (`@CurrentPrincipal()` of `domain/identity`, or `Principal` of `platform/cqrs` for a push-only stream), so a client
|
|
17
|
-
* can only listen to what the principal owns
|
|
19
|
+
* can only listen to what the principal owns; a call to a stream read service passes that principal, which builds the topic the same
|
|
20
|
+
* way. A `Last-Event-ID` header only picks where the replay resumes inside that topic.
|
|
18
21
|
*
|
|
19
22
|
* What a receiver is comes from its TYPE, what a decorator is from the import that binds it, and where a parameter comes
|
|
20
23
|
* from from the declaration its name resolves to. No rule here tests a path pattern or a variable name.
|
|
@@ -24,10 +27,39 @@ import { aliasTarget, callsOf, hasClassDecorator, injectedMembers, methodsDecora
|
|
|
24
27
|
import { hfsOf } from "./lib/hfs.js";
|
|
25
28
|
import { decoratorCallee } from "./lib/import-source.js";
|
|
26
29
|
import { baseName, isOwnedType, ownerNameOf } from "./lib/ports.js";
|
|
30
|
+
import { originsOfType, typed } from "./lib/types.js";
|
|
31
|
+
import ts from "typescript";
|
|
27
32
|
/** The slot of realtime doors. */
|
|
28
33
|
const DOOR_SLOTS = new Set(["be.feature.realtime.graphql", "be.feature.realtime.websocket", "be.feature.realtime.sse"]);
|
|
29
34
|
/** The `RealtimeHub` port of `platform/realtime`. */
|
|
30
35
|
const isHubType = (context, node) => isOwnedType(context, node, { name: "RealtimeHub", capability: "realtime", tier: "platform" });
|
|
36
|
+
/** The slot of server-sent-event doors, the only door kind that may call a stream read service. */
|
|
37
|
+
const SSE_SLOT = "be.feature.realtime.sse";
|
|
38
|
+
/** The tiers a stream read service lives in: the platform capability that owns the stream, or the domain capability that does. */
|
|
39
|
+
const STREAM_SERVICE_TIERS = new Set(["platform", "domain"]);
|
|
40
|
+
/** The package and class of the stream a read service answers. */
|
|
41
|
+
const OBSERVABLE_PACKAGE = "rxjs";
|
|
42
|
+
const OBSERVABLE = "Observable";
|
|
43
|
+
/** True when a TypeScript member is declared private or protected: not part of a class's public surface. */
|
|
44
|
+
const isHidden = (symbol) => (symbol.declarations ?? []).some((declaration) => (ts.getCombinedModifierFlags(declaration) & (ts.ModifierFlags.Private | ts.ModifierFlags.Protected)) !== 0);
|
|
45
|
+
/**
|
|
46
|
+
* True when the node's type is a stream read service: declared in the repository by a platform or domain capability, with at least one
|
|
47
|
+
* public method and every public method answering an rxjs `Observable`. What the class IS comes from its type, never its name.
|
|
48
|
+
*/
|
|
49
|
+
const isStreamReadService = (context, hfs, node) => {
|
|
50
|
+
const { checker, toTs } = typed(context);
|
|
51
|
+
const tsNode = toTs(node);
|
|
52
|
+
if (!tsNode)
|
|
53
|
+
return false;
|
|
54
|
+
const type = ts.isTypeNode(tsNode) ? checker.getTypeFromTypeNode(tsNode) : checker.getTypeAtLocation(tsNode);
|
|
55
|
+
if (!originsOfType(checker, type).some((origin) => origin.module === null && STREAM_SERVICE_TIERS.has(hfs.tierOf(origin.file) ?? "")))
|
|
56
|
+
return false;
|
|
57
|
+
const methods = type.getProperties().filter((symbol) => (symbol.flags & ts.SymbolFlags.Method) !== 0 && !isHidden(symbol));
|
|
58
|
+
return methods.length > 0 && methods.every((method) => {
|
|
59
|
+
const signatures = checker.getTypeOfSymbolAtLocation(method, tsNode).getCallSignatures();
|
|
60
|
+
return signatures.length > 0 && signatures.every((signature) => originsOfType(checker, checker.getReturnTypeOfSignature(signature)).some((origin) => origin.module === OBSERVABLE_PACKAGE && origin.name === OBSERVABLE));
|
|
61
|
+
});
|
|
62
|
+
};
|
|
31
63
|
/** The plain HTTP route decorators of `@nestjs/common`: an SSE controller carries none of them, its one route is `@Sse`. */
|
|
32
64
|
const HTTP_ROUTES = ["Get", "Post", "Put", "Patch", "Delete", "All", "Options", "Head"];
|
|
33
65
|
/** The decorators that make a class a door of one kind of realtime file, by file role. */
|
|
@@ -121,21 +153,32 @@ const hasDecorator = (context, decorator, source, name) => hasClassDecorator(con
|
|
|
121
153
|
export const realtimeReadOnly = {
|
|
122
154
|
meta: {
|
|
123
155
|
type: "problem",
|
|
124
|
-
docs: { description: "
|
|
156
|
+
docs: { description: "A realtime door injects the `RealtimeHub` of `platform/realtime` and, in an SSE door, at most one stream read service (public methods that only answer an `Observable`): no `EntityManager`, bus, queue, event bus or other domain service." },
|
|
125
157
|
schema: [],
|
|
126
158
|
messages: {
|
|
127
|
-
injects: "`{{what}}` is injected into a realtime door. A realtime door reads and pushes only: it injects the `RealtimeHub` of `platform/realtime` and nothing that can write (an `EntityManager`, a `CommandBus`, an event bus, a queue,
|
|
159
|
+
injects: "`{{what}}` is injected into a realtime door. A realtime door reads and pushes only: it injects the `RealtimeHub` of `platform/realtime`, or in an SSE door one stream read service whose public methods only answer an `Observable`, and nothing that can write (an `EntityManager`, a `CommandBus`, an event bus, a queue, another domain service). The push is fed by a reactor that calls the hub; a write belongs in an api feature.",
|
|
160
|
+
second: "`{{what}}` is a second stream read service in this realtime door. A door makes ONE call: the read of the current state, the membership check and the topic live in one service, which this door asks.",
|
|
128
161
|
},
|
|
129
162
|
},
|
|
130
163
|
create(context) {
|
|
131
164
|
const hfs = hfsOf(context);
|
|
132
|
-
|
|
165
|
+
const slot = hfs.slotOf(context.filename) ?? "";
|
|
166
|
+
if (!DOOR_SLOTS.has(slot) || roleOf(context.filename) === null)
|
|
133
167
|
return {};
|
|
134
168
|
return {
|
|
135
169
|
ClassDeclaration(node) {
|
|
170
|
+
let services = 0;
|
|
136
171
|
for (const { node: member, annotation } of injectedMembers(context, node)) {
|
|
137
|
-
|
|
138
|
-
|
|
172
|
+
const what = context.sourceCode.getText(member);
|
|
173
|
+
if (annotation && isHubType(context, annotation))
|
|
174
|
+
continue;
|
|
175
|
+
if (slot === SSE_SLOT && annotation && isStreamReadService(context, hfs, annotation)) {
|
|
176
|
+
services += 1;
|
|
177
|
+
if (services > 1)
|
|
178
|
+
context.report({ node: member, messageId: "second", data: { what } });
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
context.report({ node: member, messageId: "injects", data: { what } });
|
|
139
182
|
}
|
|
140
183
|
},
|
|
141
184
|
};
|
|
@@ -183,6 +226,22 @@ const checkMethodTopics = (context, hfs, method, push) => {
|
|
|
183
226
|
if (!scoped)
|
|
184
227
|
context.report({ node: call, messageId: "scope" });
|
|
185
228
|
}
|
|
229
|
+
if (hfs.slotOf(context.filename) !== SSE_SLOT)
|
|
230
|
+
return;
|
|
231
|
+
for (const { call, receiver } of callsOf(method)) {
|
|
232
|
+
if (receiver === null || isHubType(context, receiver) || !isStreamReadService(context, hfs, receiver))
|
|
233
|
+
continue;
|
|
234
|
+
const passed = call.arguments.some((argument) => {
|
|
235
|
+
let scoped = false;
|
|
236
|
+
walk(argument, (child) => {
|
|
237
|
+
if (child.type === "Identifier" && resolvesTo(context, child, principals))
|
|
238
|
+
scoped = true;
|
|
239
|
+
});
|
|
240
|
+
return scoped;
|
|
241
|
+
});
|
|
242
|
+
if (!passed)
|
|
243
|
+
context.report({ node: call, messageId: "serviceScope" });
|
|
244
|
+
}
|
|
186
245
|
};
|
|
187
246
|
/** The topic a client subscribes to is built from the principal the handler receives. */
|
|
188
247
|
export const realtimeTopicScope = {
|
|
@@ -191,6 +250,7 @@ export const realtimeTopicScope = {
|
|
|
191
250
|
docs: { description: "The topic passed to `RealtimeHub.subscribe` is built from the handler's `@CurrentPrincipal()` parameter or the push-only stream's platform `Principal` parameter." },
|
|
192
251
|
schema: [],
|
|
193
252
|
messages: {
|
|
253
|
+
serviceScope: "The call to the stream read service does not pass the principal. A realtime handler takes `@CurrentPrincipal() principal` and hands it to the service (`this.stream.open(principal, ...)`), which builds the principal-first topic and checks membership before it reads anything; a call that takes only a client selector is a leak.",
|
|
194
254
|
scope: "The topic of this `subscribe` is not built from the principal. A realtime handler takes `@CurrentPrincipal() principal`, or a push-only stream takes the platform `Principal`, and subscribes to a topic made from `principal.id` (plus any verified id), so one client cannot listen to another's channel. A topic taken only from client input is a leak.",
|
|
195
255
|
},
|
|
196
256
|
},
|
package/dist/testing.js
CHANGED
|
@@ -274,7 +274,7 @@ export const noApiShapedE2eFilename = {
|
|
|
274
274
|
},
|
|
275
275
|
schema: [],
|
|
276
276
|
messages: {
|
|
277
|
-
apiShaped: "`{{segment}}` names an API shape - a resolver group, an endpoint, a module - not a business promise. TESTING-1 / E2E-1: one e2e file is one business flow and the filename IS that flow; `rewards-queries.e2e-spec.ts` is exactly the shape this refuses. Name the file for the sentence it proves (`
|
|
277
|
+
apiShaped: "`{{segment}}` names an API shape - a resolver group, an endpoint, a module - not a business promise. TESTING-1 / E2E-1: one e2e file is one business flow and the filename IS that flow; `rewards-queries.e2e-spec.ts` is exactly the shape this refuses. Name the file for the sentence it proves (`project-purchase.e2e-spec.ts`), not the API surface it happens to hit.",
|
|
278
278
|
},
|
|
279
279
|
},
|
|
280
280
|
create(context) {
|
package/dist/type-safety.js
CHANGED
|
@@ -265,9 +265,8 @@ export const explicitHandlerReturnType = {
|
|
|
265
265
|
// A rule was written here: two-or-more `is`/`has`-prefixed booleans sharing a type literal with a
|
|
266
266
|
// field that is optional and not itself boolean. It was measured against the reference backend
|
|
267
267
|
// before shipping, per this canon's own standard -- and both of its two real firings were wrong.
|
|
268
|
-
//
|
|
269
|
-
//
|
|
270
|
-
// `ctaText`) are both genuinely independent facts about one entity, not a product of states -- the
|
|
268
|
+
// They were a search-result item and a seed item, each with independent `is*` flags beside an
|
|
269
|
+
// unrelated optional field: both genuinely independent facts about one entity, not a product of states -- the
|
|
271
270
|
// exact "transport type" and "independent booleans" exceptions `type-safety.md` already names. A
|
|
272
271
|
// rule reporting a defect on 2 of its 2 real firings is not a rule with debt to burn down; it is
|
|
273
272
|
// wrong, and shipping it at any level would teach a reader to distrust the machine rather than the
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@starci/eslint-canon-be",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.27.0",
|
|
4
4
|
"description": "The StarCi back-end lint canon: every rule its laws publish, gathered as one flat-config plugin.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"node": ">=22.13.0"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"@starci/hfs": "~6.
|
|
43
|
+
"@starci/hfs": "~6.13.0",
|
|
44
44
|
"eslint": ">=9",
|
|
45
45
|
"typescript": ">=5.9"
|
|
46
46
|
},
|
|
@@ -74,6 +74,6 @@
|
|
|
74
74
|
"typescript": "^6.0.3"
|
|
75
75
|
},
|
|
76
76
|
"types": "./dist/index.d.ts",
|
|
77
|
-
"gitHead": "
|
|
78
|
-
"starciSource": "
|
|
77
|
+
"gitHead": "246530f8c270cac4e607131c04f62b8e063e0ef5",
|
|
78
|
+
"starciSource": "970234c5f6bf8627c9625dccb06829e114c41680893707accbac9751358ae320"
|
|
79
79
|
}
|