Skip to content

Commit 1ebbde2

Browse files
committed
test(notifications): hold the push test doubles to the engine contracts, alias service-push and spec/system to source, and count service-push in spec's llms.txt
The engine doubles in push-channel.test.ts and notify-push-delivery.integration.test.ts route findOne/update/delete through the metadata-core dispatch predicates and hold the caller's find limit (pinned ledger rows written by check-engine-double-contract --write). Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JQwxbWDV359nY4JGrtUq4P
1 parent 391ab42 commit 1ebbde2

6 files changed

Lines changed: 80 additions & 9 deletions

File tree

‎packages/services/service-automation/src/builtin/notify-push-delivery.integration.test.ts‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ import http2 from 'node:http2';
2222
import { generateKeyPairSync } from 'node:crypto';
2323
import type { AddressInfo } from 'node:net';
2424
import { MessagingService, createInboxChannel, createPushChannel } from '@objectstack/service-messaging';
25+
import {
26+
assertEngineDeleteDispatch,
27+
assertEngineFindOnePredicate,
28+
assertEngineUpdateDispatch,
29+
type EngineFindOneQueryInput,
30+
} from '@objectstack/metadata-core';
2531
import { ApnsPushTransport, FcmPushTransport, PushService } from '@objectstack/service-push';
2632
import { AutomationEngine } from '../engine.js';
2733
import { registerNotifyNode } from './notify-node.js';
@@ -50,18 +56,22 @@ function memoryEngine() {
5056
(tables[object] ??= []).push(stored);
5157
return { ...stored };
5258
},
53-
async find(object: string, q: { where?: Record<string, unknown> } = {}) {
54-
return (tables[object] ?? []).filter((r) => matches(r, q.where)).map((r) => ({ ...r }));
59+
async find(object: string, q: { where?: Record<string, unknown>; limit?: number } = {}) {
60+
const rows = (tables[object] ?? []).filter((r) => matches(r, q.where));
61+
return (typeof q.limit === 'number' ? rows.slice(0, q.limit) : rows).map((r) => ({ ...r }));
5562
},
5663
async findOne(object: string, q: { where?: Record<string, unknown> } = {}) {
64+
assertEngineFindOnePredicate(object, q as EngineFindOneQueryInput);
5765
const hit = (tables[object] ?? []).find((r) => matches(r, q.where));
5866
return hit ? { ...hit } : null;
5967
},
6068
async update(object: string, values: Record<string, unknown>, opts: { where?: Record<string, unknown> }) {
69+
assertEngineUpdateDispatch(values as never, opts as never);
6170
for (const r of tables[object] ?? []) if (matches(r, opts.where)) Object.assign(r, values);
6271
return {};
6372
},
6473
async delete(object: string, opts: { where?: Record<string, unknown> }) {
74+
assertEngineDeleteDispatch(opts as never);
6575
tables[object] = (tables[object] ?? []).filter((r) => !matches(r, opts.where));
6676
return {};
6777
},

‎packages/services/service-automation/vitest.config.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,14 @@ export default defineConfig({
107107
find: /^@objectstack\/plugin-sharing$/,
108108
replacement: path.resolve(__dirname, '../../plugins/plugin-sharing/src/index.ts'),
109109
},
110+
{
111+
// [#29041] `notify-push-delivery.integration.test.ts` delivers a
112+
// `notify` node through the real APNs and FCM transports of
113+
// `@objectstack/service-push` against local mock endpoints. Read from
114+
// source for the reason the entries above give. Same anchored-regex rule.
115+
find: /^@objectstack\/service-push$/,
116+
replacement: path.resolve(__dirname, '../service-push/src/index.ts'),
117+
},
110118
{
111119
// The same suite reads the `sys_audit_log` rows the post-decision writes
112120
// leave (`AuditPlugin`'s writers), so the attribution it pins is the

‎packages/services/service-messaging/src/push-channel.test.ts‎

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ import { createPushChannel, deliveryData, truncateUtf8, type PushSenderSurface }
1414
import { MessagingServicePlugin } from './messaging-service-plugin.js';
1515
import type { MessagingService } from './messaging-service.js';
1616
import type { Delivery } from './channel.js';
17+
import {
18+
assertEngineDeleteDispatch,
19+
assertEngineFindOnePredicate,
20+
assertEngineUpdateDispatch,
21+
type EngineFindOneQueryInput,
22+
} from '@objectstack/metadata-core';
1723

1824
const ctx = { logger: { info() {}, warn() {}, error() {} } };
1925

@@ -215,12 +221,15 @@ describe('MessagingServicePlugin mounts the push channel while a push service is
215221
services.set('manifest', { register() {} });
216222
services.set('data', {
217223
async insert(_o: string, row: Record<string, unknown>) { return { id: 'evt_1', ...row }; },
218-
async find(object: string, q: { where?: Record<string, unknown> } = {}) {
219-
return object === 'sys_user_device' ? devices.filter((d) => d.user_id === q.where?.user_id) : [];
224+
async find(object: string, q: { where?: Record<string, unknown>; limit?: number } = {}) {
225+
if (object !== 'sys_user_device') return [];
226+
const rows = devices.filter((d) => Object.entries(q.where ?? {})
227+
.every(([k, v]) => (d as Record<string, unknown>)[k] === v));
228+
return typeof q.limit === 'number' ? rows.slice(0, q.limit) : rows;
220229
},
221-
async findOne() { return null; },
222-
async update() { return {}; },
223-
async delete() { return {}; },
230+
async findOne(object: string, q?: EngineFindOneQueryInput) { assertEngineFindOnePredicate(object, q); return null; },
231+
async update(_o: string, values: unknown, opts: unknown) { assertEngineUpdateDispatch(values as never, opts as never); return {}; },
232+
async delete(_o: string, opts: unknown) { assertEngineDeleteDispatch(opts as never); return {}; },
224233
});
225234
const logger: Record<string, unknown> = { info() {}, warn() {}, error() {}, debug() {} };
226235
logger.child = () => logger;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,24 @@
11
import { defineConfig } from 'vitest/config';
2+
import path from 'node:path';
23

4+
/**
5+
* The transports read their configuration types and the plugin parses its
6+
* `config` with `PushServiceConfigSchema`, both from `@objectstack/spec/system`.
7+
* Unaliased, the workspace link resolves that to the spec package's last
8+
* build, so a test about the source next to it would report on build state
9+
* instead (`pnpm check:test-source-alias` is the gate). Anchored regex, array
10+
* form: a bare string `find` matches by PREFIX.
11+
*/
312
export default defineConfig({
413
test: {
514
// A late console.* must not redden a green suite (#10374).
615
// Mechanism + measured costs: examples/app-showcase/vitest.config.ts.
716
// Enforced repo-wide by scripts/check-console-intercept-disarm.mjs.
817
disableConsoleIntercept: true,
918
},
19+
resolve: {
20+
alias: [
21+
{ find: /^@objectstack\/spec\/system$/, replacement: path.resolve(__dirname, '../../spec/src/system/index.ts') },
22+
],
23+
},
1024
});

‎packages/spec/llms.txt‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,9 @@ function registerObject(rawConfig: unknown) {
178178

179179
---
180180

181-
## 7. Package Ecosystem (73 packages)
181+
## 7. Package Ecosystem (74 packages)
182182

183-
The workspace publishes 73 packages under the `@objectstack` scope. The table
183+
The workspace publishes 74 packages under the `@objectstack` scope. The table
184184
below is a curated entry-point list, not the full set — drivers, connectors,
185185
triggers, plugins and kernel-managed services each form their own family.
186186

‎scripts/engine-double-contract.pinned.json‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5051,6 +5051,21 @@
50515051
"verb": "findOne",
50525052
"pinned": 1
50535053
},
5054+
{
5055+
"file": "packages/services/service-automation/src/builtin/notify-push-delivery.integration.test.ts",
5056+
"verb": "delete",
5057+
"pinned": 1
5058+
},
5059+
{
5060+
"file": "packages/services/service-automation/src/builtin/notify-push-delivery.integration.test.ts",
5061+
"verb": "findOne",
5062+
"pinned": 1
5063+
},
5064+
{
5065+
"file": "packages/services/service-automation/src/builtin/notify-push-delivery.integration.test.ts",
5066+
"verb": "update",
5067+
"pinned": 1
5068+
},
50545069
{
50555070
"file": "packages/services/service-automation/src/builtin/notify-written-address-channels.integration.test.ts",
50565071
"verb": "findOne",
@@ -5276,6 +5291,21 @@
52765291
"verb": "findOne",
52775292
"pinned": 1
52785293
},
5294+
{
5295+
"file": "packages/services/service-messaging/src/push-channel.test.ts",
5296+
"verb": "delete",
5297+
"pinned": 1
5298+
},
5299+
{
5300+
"file": "packages/services/service-messaging/src/push-channel.test.ts",
5301+
"verb": "findOne",
5302+
"pinned": 1
5303+
},
5304+
{
5305+
"file": "packages/services/service-messaging/src/push-channel.test.ts",
5306+
"verb": "update",
5307+
"pinned": 1
5308+
},
52795309
{
52805310
"file": "packages/services/service-messaging/src/read-receipt-organization.test.ts",
52815311
"verb": "findOne",

0 commit comments

Comments
 (0)