agentic-notify 0.1.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -3
- package/dist/{chunk-6CKFBZOF.js → chunk-3N77SYRA.js} +8 -1
- package/dist/{chunk-FMU2ED2H.js → chunk-ARL7FN6Y.js} +52 -235
- package/dist/chunk-PHY45IVQ.js +101 -0
- package/dist/cli.js +3 -3
- package/dist/{d1-CUcNko0m.d.ts → dispatch-xe2IAqWe.d.ts} +5 -34
- package/dist/{gdpr-9I4eV86m.d.ts → gdpr-BAg1U1w6.d.ts} +1 -1
- package/dist/index.d.ts +10 -7
- package/dist/index.js +10 -10
- package/dist/mcp-bin.js +23 -15
- package/dist/mcp.d.ts +2 -2
- package/dist/mcp.js +82 -7
- package/dist/sdk.d.ts +8 -8
- package/dist/{email-UqtllxjF.d.ts → testing-46doJP5Y.d.ts} +3 -2
- package/dist/testing.d.ts +4 -12
- package/dist/testing.js +2 -147
- package/dist/types-BdX7UTFu.d.ts +20 -0
- package/dist/{types-GuAgyMOc.d.ts → types-anA8DMQH.d.ts} +31 -31
- package/dist/worker.d.ts +10 -6
- package/dist/worker.js +17 -7
- package/package.json +5 -2
- package/dist/chunk-DEPJ3SHO.js +0 -86
- package/dist/chunk-GJFAXI2K.js +0 -104
- package/dist/types-Dkst26cb.d.ts +0 -69
package/dist/index.js
CHANGED
|
@@ -1,45 +1,45 @@
|
|
|
1
1
|
import {
|
|
2
|
+
D1_SCHEMA,
|
|
2
3
|
DeliveryError,
|
|
3
4
|
PACKAGE_NAME,
|
|
4
5
|
SIGNATURE_HEADER,
|
|
6
|
+
createD1Store,
|
|
5
7
|
createDispatcher,
|
|
8
|
+
createMemoryStore,
|
|
6
9
|
createWebhookChannel,
|
|
7
10
|
signPayload,
|
|
8
11
|
verifySignature
|
|
9
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-3N77SYRA.js";
|
|
10
13
|
import {
|
|
11
14
|
createEmailChannel
|
|
12
15
|
} from "./chunk-KJKM56FT.js";
|
|
13
16
|
import {
|
|
14
17
|
CHANNELS,
|
|
15
|
-
D1Store,
|
|
16
18
|
DEFAULT_CHANNELS,
|
|
17
19
|
NotFoundError,
|
|
18
|
-
VERSION,
|
|
19
20
|
createNotifier,
|
|
20
21
|
defaultPreferences,
|
|
21
|
-
migrateD1,
|
|
22
22
|
recipientKey
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-ARL7FN6Y.js";
|
|
24
24
|
import {
|
|
25
|
-
|
|
26
|
-
} from "./chunk-
|
|
25
|
+
VERSION
|
|
26
|
+
} from "./chunk-PHY45IVQ.js";
|
|
27
27
|
export {
|
|
28
28
|
CHANNELS,
|
|
29
|
-
|
|
29
|
+
D1_SCHEMA,
|
|
30
30
|
DEFAULT_CHANNELS,
|
|
31
31
|
DeliveryError,
|
|
32
|
-
MemoryStore,
|
|
33
32
|
NotFoundError,
|
|
34
33
|
PACKAGE_NAME,
|
|
35
34
|
SIGNATURE_HEADER,
|
|
36
35
|
VERSION,
|
|
36
|
+
createD1Store,
|
|
37
37
|
createDispatcher,
|
|
38
38
|
createEmailChannel,
|
|
39
|
+
createMemoryStore,
|
|
39
40
|
createNotifier,
|
|
40
41
|
createWebhookChannel,
|
|
41
42
|
defaultPreferences,
|
|
42
|
-
migrateD1,
|
|
43
43
|
recipientKey,
|
|
44
44
|
signPayload,
|
|
45
45
|
verifySignature
|
package/dist/mcp-bin.js
CHANGED
|
@@ -1,19 +1,27 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-6CKFBZOF.js";
|
|
6
|
-
import {
|
|
7
|
-
createClient
|
|
8
|
-
} from "./chunk-FJPEUDTG.js";
|
|
9
|
-
import "./chunk-KJKM56FT.js";
|
|
10
|
-
import "./chunk-FMU2ED2H.js";
|
|
11
|
-
import "./chunk-GJFAXI2K.js";
|
|
3
|
+
VERSION
|
|
4
|
+
} from "./chunk-PHY45IVQ.js";
|
|
12
5
|
|
|
13
6
|
// src/mcp-bin.ts
|
|
14
|
-
var
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
7
|
+
var HELP = `agentic-notify-mcp ${VERSION}
|
|
8
|
+
Usage: agentic-notify-mcp [--help | --version]
|
|
9
|
+
|
|
10
|
+
Runs the MCP server on stdio. An MCP client starts it.
|
|
11
|
+
`;
|
|
12
|
+
var flag = process.argv[2];
|
|
13
|
+
if (flag === "--version" || flag === "-V") {
|
|
14
|
+
process.stdout.write(`${VERSION}
|
|
15
|
+
`);
|
|
16
|
+
} else if (flag === "--help" || flag === "-h") {
|
|
17
|
+
process.stdout.write(HELP);
|
|
18
|
+
} else {
|
|
19
|
+
Promise.all([import("./mcp.js"), import("./sdk.js")]).then(([{ startMcp }, { createClient }]) => {
|
|
20
|
+
const { NOTIFY_URL, NOTIFY_TOKEN } = process.env;
|
|
21
|
+
const client = NOTIFY_URL && NOTIFY_TOKEN ? createClient({ baseUrl: NOTIFY_URL, token: NOTIFY_TOKEN }) : void 0;
|
|
22
|
+
return startMcp(client);
|
|
23
|
+
}).catch((error) => {
|
|
24
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
25
|
+
process.exit(1);
|
|
26
|
+
});
|
|
27
|
+
}
|
package/dist/mcp.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
2
|
import { Client } from './sdk.js';
|
|
3
|
-
import './types-
|
|
3
|
+
import './types-anA8DMQH.js';
|
|
4
4
|
import 'zod';
|
|
5
|
-
import './gdpr-
|
|
5
|
+
import './gdpr-BAg1U1w6.js';
|
|
6
6
|
|
|
7
7
|
/** Without a client, only `ping` works and the other tools report that setup is missing. */
|
|
8
8
|
declare function createMcpServer(client?: Client): McpServer;
|
package/dist/mcp.js
CHANGED
|
@@ -1,12 +1,87 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
PACKAGE_NAME
|
|
3
|
+
} from "./chunk-3N77SYRA.js";
|
|
4
|
+
import {
|
|
5
|
+
ApiError
|
|
6
|
+
} from "./chunk-FJPEUDTG.js";
|
|
7
7
|
import "./chunk-KJKM56FT.js";
|
|
8
|
-
import
|
|
9
|
-
|
|
8
|
+
import {
|
|
9
|
+
preferencesSchema,
|
|
10
|
+
recipientSchema,
|
|
11
|
+
resourceRefSchema,
|
|
12
|
+
typeNameSchema
|
|
13
|
+
} from "./chunk-ARL7FN6Y.js";
|
|
14
|
+
import {
|
|
15
|
+
VERSION
|
|
16
|
+
} from "./chunk-PHY45IVQ.js";
|
|
17
|
+
|
|
18
|
+
// src/mcp.ts
|
|
19
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
20
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
21
|
+
import { z } from "zod";
|
|
22
|
+
async function wrap(fn) {
|
|
23
|
+
try {
|
|
24
|
+
return { content: [{ type: "text", text: JSON.stringify(await fn()) }] };
|
|
25
|
+
} catch (error) {
|
|
26
|
+
if (error instanceof ApiError) {
|
|
27
|
+
return { content: [{ type: "text", text: JSON.stringify({ error: error.code, status: error.status }) }], isError: true };
|
|
28
|
+
}
|
|
29
|
+
throw error;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function createMcpServer(client) {
|
|
33
|
+
const server = new McpServer({ name: PACKAGE_NAME, version: VERSION });
|
|
34
|
+
const need = (fn) => () => wrap(async () => {
|
|
35
|
+
if (!client) throw new ApiError(0, "not_configured");
|
|
36
|
+
return fn(client);
|
|
37
|
+
});
|
|
38
|
+
const read = { readOnlyHint: true };
|
|
39
|
+
const write = { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false };
|
|
40
|
+
server.registerTool(
|
|
41
|
+
"ping",
|
|
42
|
+
{ description: "Check that the server runs. Returns the package version.", inputSchema: {}, annotations: read },
|
|
43
|
+
async () => ({ content: [{ type: "text", text: JSON.stringify({ ok: true, version: VERSION }) }] })
|
|
44
|
+
);
|
|
45
|
+
server.registerTool("list_notifications", {
|
|
46
|
+
description: "List your notifications, newest first.",
|
|
47
|
+
inputSchema: { unreadOnly: z.boolean().optional(), limit: z.number().int().min(1).max(200).optional(), cursor: z.string().optional() },
|
|
48
|
+
annotations: read
|
|
49
|
+
}, (a) => need((c) => c.list(a))());
|
|
50
|
+
server.registerTool(
|
|
51
|
+
"read_notification",
|
|
52
|
+
{ description: "Get one notification by id.", inputSchema: { id: z.string() }, annotations: read },
|
|
53
|
+
({ id }) => need((c) => c.get(id))()
|
|
54
|
+
);
|
|
55
|
+
server.registerTool(
|
|
56
|
+
"mark_read",
|
|
57
|
+
{ description: "Mark one notification as read.", inputSchema: { id: z.string() }, annotations: write },
|
|
58
|
+
({ id }) => need((c) => c.markRead(id))()
|
|
59
|
+
);
|
|
60
|
+
server.registerTool(
|
|
61
|
+
"mark_all_read",
|
|
62
|
+
{ description: "Mark all your notifications as read.", inputSchema: {}, annotations: write },
|
|
63
|
+
need((c) => c.markAllRead())
|
|
64
|
+
);
|
|
65
|
+
server.registerTool(
|
|
66
|
+
"get_preferences",
|
|
67
|
+
{ description: "Read your notification preferences.", inputSchema: {}, annotations: read },
|
|
68
|
+
need((c) => c.getPreferences())
|
|
69
|
+
);
|
|
70
|
+
server.registerTool("set_preferences", {
|
|
71
|
+
description: "Replace your notification preferences: channels per type, mute, muted types.",
|
|
72
|
+
inputSchema: preferencesSchema.shape,
|
|
73
|
+
annotations: write
|
|
74
|
+
}, (a) => need((c) => c.setPreferences(a))());
|
|
75
|
+
server.registerTool("send_notification", {
|
|
76
|
+
description: "Send a notification. You must hold the send right. You are the actor.",
|
|
77
|
+
inputSchema: { recipient: recipientSchema, type: typeNameSchema, resource: resourceRefSchema, body: z.string().max(2e3) },
|
|
78
|
+
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false }
|
|
79
|
+
}, (a) => need((c) => c.send(a))());
|
|
80
|
+
return server;
|
|
81
|
+
}
|
|
82
|
+
async function startMcp(client) {
|
|
83
|
+
await createMcpServer(client).connect(new StdioServerTransport());
|
|
84
|
+
}
|
|
10
85
|
export {
|
|
11
86
|
createMcpServer,
|
|
12
87
|
startMcp
|
package/dist/sdk.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { N as Notification, D as Digest, P as Preferences, R as Recipient, a as ResourceRef } from './types-
|
|
2
|
-
import { R as RecipientExport } from './gdpr-
|
|
1
|
+
import { N as Notification, D as Digest, P as Preferences, R as Recipient, a as ResourceRef } from './types-anA8DMQH.js';
|
|
2
|
+
import { R as RecipientExport } from './gdpr-BAg1U1w6.js';
|
|
3
3
|
import 'zod';
|
|
4
4
|
|
|
5
5
|
declare class ApiError extends Error {
|
|
@@ -46,17 +46,17 @@ declare function createClient(options: ClientOptions): {
|
|
|
46
46
|
type: string;
|
|
47
47
|
id: string;
|
|
48
48
|
recipient: {
|
|
49
|
-
id: string;
|
|
50
49
|
kind: "human" | "agent";
|
|
50
|
+
id: string;
|
|
51
51
|
};
|
|
52
52
|
resource: {
|
|
53
|
-
id: string;
|
|
54
53
|
kind: string;
|
|
54
|
+
id: string;
|
|
55
55
|
url?: string | undefined;
|
|
56
56
|
};
|
|
57
57
|
actor: {
|
|
58
|
-
id: string;
|
|
59
58
|
kind: "human" | "agent";
|
|
59
|
+
id: string;
|
|
60
60
|
};
|
|
61
61
|
body: string;
|
|
62
62
|
createdAt: number;
|
|
@@ -66,17 +66,17 @@ declare function createClient(options: ClientOptions): {
|
|
|
66
66
|
type: string;
|
|
67
67
|
id: string;
|
|
68
68
|
recipient: {
|
|
69
|
-
id: string;
|
|
70
69
|
kind: "human" | "agent";
|
|
70
|
+
id: string;
|
|
71
71
|
};
|
|
72
72
|
resource: {
|
|
73
|
-
id: string;
|
|
74
73
|
kind: string;
|
|
74
|
+
id: string;
|
|
75
75
|
url?: string | undefined;
|
|
76
76
|
};
|
|
77
77
|
actor: {
|
|
78
|
-
id: string;
|
|
79
78
|
kind: "human" | "agent";
|
|
79
|
+
id: string;
|
|
80
80
|
};
|
|
81
81
|
body: string;
|
|
82
82
|
createdAt: number;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import 'agentic-identity/testing';
|
|
2
|
+
import { R as Recipient } from './types-anA8DMQH.js';
|
|
3
|
+
import { D as DeliveryChannel } from './types-BdX7UTFu.js';
|
|
3
4
|
|
|
4
5
|
interface EmailMessage {
|
|
5
6
|
to: string;
|
package/dist/testing.d.ts
CHANGED
|
@@ -1,13 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
export { T as TestEmailAdapter } from './
|
|
3
|
-
import './types-
|
|
1
|
+
export { runStoreContract } from 'agentic-identity/testing';
|
|
2
|
+
export { T as TestEmailAdapter } from './testing-46doJP5Y.js';
|
|
3
|
+
import './types-anA8DMQH.js';
|
|
4
4
|
import 'zod';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Contract suite for the Store port. Run it on every adapter.
|
|
8
|
-
* `make` must return a fresh store. When two calls share one backing
|
|
9
|
-
* database, the concurrency tests use both handles.
|
|
10
|
-
*/
|
|
11
|
-
declare function storeContract(name: string, make: () => Promise<Store>, makePeer?: (s: Store) => Promise<Store>): void;
|
|
12
|
-
|
|
13
|
-
export { storeContract };
|
|
5
|
+
import './types-BdX7UTFu.js';
|
package/dist/testing.js
CHANGED
|
@@ -1,155 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
TestEmailAdapter
|
|
3
3
|
} from "./chunk-KJKM56FT.js";
|
|
4
|
-
import {
|
|
5
|
-
encodeCursor
|
|
6
|
-
} from "./chunk-GJFAXI2K.js";
|
|
7
4
|
|
|
8
5
|
// src/testing.ts
|
|
9
|
-
import {
|
|
10
|
-
function storeContract(name, make, makePeer) {
|
|
11
|
-
describe(`Store contract: ${name}`, () => {
|
|
12
|
-
test("get returns null for a missing doc, put then get round-trips", async () => {
|
|
13
|
-
const s = await make();
|
|
14
|
-
expect(await s.get("c", "a")).toBeNull();
|
|
15
|
-
await s.put("c", "a", { n: 1, s: "x", t: true, z: null });
|
|
16
|
-
expect(await s.get("c", "a")).toEqual({ n: 1, s: "x", t: true, z: null });
|
|
17
|
-
});
|
|
18
|
-
test("collections are separate", async () => {
|
|
19
|
-
const s = await make();
|
|
20
|
-
await s.put("c1", "a", { v: 1 });
|
|
21
|
-
expect(await s.get("c2", "a")).toBeNull();
|
|
22
|
-
});
|
|
23
|
-
test("create refuses an existing id and keeps the old doc", async () => {
|
|
24
|
-
const s = await make();
|
|
25
|
-
expect(await s.create("c", "a", { v: 1 })).toBe(true);
|
|
26
|
-
expect(await s.create("c", "a", { v: 2 })).toBe(false);
|
|
27
|
-
expect(await s.get("c", "a")).toEqual({ v: 1 });
|
|
28
|
-
});
|
|
29
|
-
test("only one of two racing creates wins", async () => {
|
|
30
|
-
const s = await make();
|
|
31
|
-
const peer = makePeer ? await makePeer(s) : s;
|
|
32
|
-
const results = await Promise.all([s.create("c", "a", { v: 1 }), peer.create("c", "a", { v: 2 })]);
|
|
33
|
-
expect(results.filter(Boolean)).toHaveLength(1);
|
|
34
|
-
});
|
|
35
|
-
test("replaceIf swaps only when the doc is unchanged", async () => {
|
|
36
|
-
const s = await make();
|
|
37
|
-
await s.put("c", "a", { v: 1 });
|
|
38
|
-
expect(await s.replaceIf("c", "a", { v: 9 }, { v: 2 })).toBe(false);
|
|
39
|
-
expect(await s.replaceIf("c", "a", { v: 1 }, { v: 2 })).toBe(true);
|
|
40
|
-
expect(await s.get("c", "a")).toEqual({ v: 2 });
|
|
41
|
-
expect(await s.replaceIf("c", "missing", { v: 1 }, { v: 2 })).toBe(false);
|
|
42
|
-
});
|
|
43
|
-
test("replaceIf equality ignores key order", async () => {
|
|
44
|
-
const s = await make();
|
|
45
|
-
await s.put("c", "a", { a: 1, b: { x: 1, y: 2 } });
|
|
46
|
-
expect(await s.replaceIf("c", "a", { b: { y: 2, x: 1 }, a: 1 }, { a: 2 })).toBe(true);
|
|
47
|
-
});
|
|
48
|
-
test("only one of two racing replaceIf calls wins", async () => {
|
|
49
|
-
const s = await make();
|
|
50
|
-
const peer = makePeer ? await makePeer(s) : s;
|
|
51
|
-
await s.put("c", "a", { v: 0 });
|
|
52
|
-
const results = await Promise.all([
|
|
53
|
-
s.replaceIf("c", "a", { v: 0 }, { v: 1 }),
|
|
54
|
-
peer.replaceIf("c", "a", { v: 0 }, { v: 2 })
|
|
55
|
-
]);
|
|
56
|
-
expect(results.filter(Boolean)).toHaveLength(1);
|
|
57
|
-
});
|
|
58
|
-
test("delete removes a doc and ignores a missing one", async () => {
|
|
59
|
-
const s = await make();
|
|
60
|
-
await s.put("c", "a", { v: 1 });
|
|
61
|
-
await s.delete("c", "a");
|
|
62
|
-
await s.delete("c", "a");
|
|
63
|
-
expect(await s.get("c", "a")).toBeNull();
|
|
64
|
-
});
|
|
65
|
-
test("query filters on equality, including null", async () => {
|
|
66
|
-
const s = await make();
|
|
67
|
-
await s.put("c", "a", { k: "x", r: null });
|
|
68
|
-
await s.put("c", "b", { k: "x", r: 5 });
|
|
69
|
-
await s.put("c", "c", { k: "y", r: null });
|
|
70
|
-
const ids = async (where) => (await s.query("c", { where, orderBy: { field: "k", direction: "asc" } })).items.map((i) => i.id).sort();
|
|
71
|
-
expect(await ids({ k: "x" })).toEqual(["a", "b"]);
|
|
72
|
-
expect(await ids({ k: "x", r: null })).toEqual(["a"]);
|
|
73
|
-
expect(await ids({ r: 5 })).toEqual(["b"]);
|
|
74
|
-
expect(await ids({ k: "none" })).toEqual([]);
|
|
75
|
-
});
|
|
76
|
-
test("equality filters respect the value type", async () => {
|
|
77
|
-
const s = await make();
|
|
78
|
-
await s.put("c", "t", { f: true, o: { a: 1 } });
|
|
79
|
-
await s.put("c", "u", { f: 1, o: '{"a":1}' });
|
|
80
|
-
await s.put("c", "v", { f: "1", o: [1] });
|
|
81
|
-
const ids = async (where) => (await s.query("c", { where })).items.map((i) => i.id).sort();
|
|
82
|
-
expect(await ids({ f: true })).toEqual(["t"]);
|
|
83
|
-
expect(await ids({ f: 1 })).toEqual(["u"]);
|
|
84
|
-
expect(await ids({ f: "1" })).toEqual(["v"]);
|
|
85
|
-
expect(await ids({ o: '{"a":1}' })).toEqual(["u"]);
|
|
86
|
-
});
|
|
87
|
-
test("query orders by one field and breaks ties by id", async () => {
|
|
88
|
-
const s = await make();
|
|
89
|
-
for (const [id, n] of [["b", 2], ["a", 2], ["c", 1], ["d", 3]]) await s.put("c", id, { n });
|
|
90
|
-
const order = async (direction) => (await s.query("c", { orderBy: { field: "n", direction } })).items.map((i) => i.id);
|
|
91
|
-
expect(await order("asc")).toEqual(["c", "a", "b", "d"]);
|
|
92
|
-
expect(await order("desc")).toEqual(["d", "b", "a", "c"]);
|
|
93
|
-
});
|
|
94
|
-
test("cursor paging walks every doc once, in both directions", async () => {
|
|
95
|
-
const s = await make();
|
|
96
|
-
for (let i = 0; i < 7; i++) await s.put("c", `id${i}`, { n: i % 3 });
|
|
97
|
-
for (const direction of ["asc", "desc"]) {
|
|
98
|
-
const seen = [];
|
|
99
|
-
let cursor;
|
|
100
|
-
let pages = 0;
|
|
101
|
-
do {
|
|
102
|
-
const page = await s.query("c", { orderBy: { field: "n", direction }, limit: 3, cursor });
|
|
103
|
-
seen.push(...page.items.map((i) => i.id));
|
|
104
|
-
cursor = page.nextCursor ?? void 0;
|
|
105
|
-
pages++;
|
|
106
|
-
} while (cursor);
|
|
107
|
-
const whole = (await s.query("c", { orderBy: { field: "n", direction }, limit: 50 })).items.map((i) => i.id);
|
|
108
|
-
expect(pages).toBe(3);
|
|
109
|
-
expect(seen).toEqual(whole);
|
|
110
|
-
expect(new Set(seen).size).toBe(7);
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
test("cursor paging works with a filter and with no orderBy", async () => {
|
|
114
|
-
const s = await make();
|
|
115
|
-
for (let i = 0; i < 6; i++) await s.put("c", `id${i}`, { g: i % 2 === 0 ? "even" : "odd", n: i });
|
|
116
|
-
const walk = async (query) => {
|
|
117
|
-
const seen = [];
|
|
118
|
-
let cursor;
|
|
119
|
-
do {
|
|
120
|
-
const page = await s.query("c", { ...query, limit: 2, cursor });
|
|
121
|
-
seen.push(...page.items.map((i) => i.id));
|
|
122
|
-
cursor = page.nextCursor ?? void 0;
|
|
123
|
-
} while (cursor);
|
|
124
|
-
return seen;
|
|
125
|
-
};
|
|
126
|
-
expect(await walk({ where: { g: "even" }, orderBy: { field: "n", direction: "desc" } })).toEqual(["id4", "id2", "id0"]);
|
|
127
|
-
expect(await walk({})).toEqual(["id0", "id1", "id2", "id3", "id4", "id5"]);
|
|
128
|
-
});
|
|
129
|
-
test("a cursor of the wrong type for the sort field is rejected", async () => {
|
|
130
|
-
const s = await make();
|
|
131
|
-
await s.put("c", "a", { n: 1 });
|
|
132
|
-
await s.put("c", "b", { n: 2 });
|
|
133
|
-
await expect(s.query("c", { orderBy: { field: "n", direction: "asc" }, cursor: encodeCursor("abc", "a") })).rejects.toThrow();
|
|
134
|
-
});
|
|
135
|
-
test("bad limit and bad cursor are rejected", async () => {
|
|
136
|
-
const s = await make();
|
|
137
|
-
await expect(s.query("c", { limit: 0 })).rejects.toThrow();
|
|
138
|
-
await expect(s.query("c", { cursor: "%%%" })).rejects.toThrow();
|
|
139
|
-
});
|
|
140
|
-
test("stored docs are copies", async () => {
|
|
141
|
-
const s = await make();
|
|
142
|
-
const doc = { nested: { v: 1 } };
|
|
143
|
-
await s.put("c", "a", doc);
|
|
144
|
-
doc.nested.v = 2;
|
|
145
|
-
const got = await s.get("c", "a");
|
|
146
|
-
expect(got.nested.v).toBe(1);
|
|
147
|
-
got.nested.v = 3;
|
|
148
|
-
expect((await s.get("c", "a")).nested.v).toBe(1);
|
|
149
|
-
});
|
|
150
|
-
});
|
|
151
|
-
}
|
|
6
|
+
import { runStoreContract } from "agentic-identity/testing";
|
|
152
7
|
export {
|
|
153
8
|
TestEmailAdapter,
|
|
154
|
-
|
|
9
|
+
runStoreContract
|
|
155
10
|
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { N as Notification } from './types-anA8DMQH.js';
|
|
2
|
+
|
|
3
|
+
/** A delivery channel other than the inbox. */
|
|
4
|
+
interface DeliveryChannel {
|
|
5
|
+
/** Resolves "skipped" when the recipient has no target (no endpoint, no address). Throws on failure. */
|
|
6
|
+
deliver(notification: Notification): Promise<"sent" | "skipped">;
|
|
7
|
+
}
|
|
8
|
+
declare class DeliveryError extends Error {
|
|
9
|
+
readonly attempts: number;
|
|
10
|
+
readonly code = "DELIVERY_FAILED";
|
|
11
|
+
constructor(message: string, attempts: number, options?: {
|
|
12
|
+
cause?: unknown;
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
/** Logger that takes ids and counts only. Never pass content or addresses. */
|
|
16
|
+
interface Logger {
|
|
17
|
+
warn(message: string, fields?: Record<string, string | number>): void;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export { type DeliveryChannel as D, type Logger as L, DeliveryError as a };
|
|
@@ -6,11 +6,11 @@ declare const recipientSchema: z.ZodObject<{
|
|
|
6
6
|
kind: z.ZodEnum<["human", "agent"]>;
|
|
7
7
|
id: z.ZodString;
|
|
8
8
|
}, "strict", z.ZodTypeAny, {
|
|
9
|
-
id: string;
|
|
10
9
|
kind: "human" | "agent";
|
|
11
|
-
}, {
|
|
12
10
|
id: string;
|
|
11
|
+
}, {
|
|
13
12
|
kind: "human" | "agent";
|
|
13
|
+
id: string;
|
|
14
14
|
}>;
|
|
15
15
|
type Recipient = z.infer<typeof recipientSchema>;
|
|
16
16
|
declare const resourceRefSchema: z.ZodObject<{
|
|
@@ -18,12 +18,12 @@ declare const resourceRefSchema: z.ZodObject<{
|
|
|
18
18
|
id: z.ZodString;
|
|
19
19
|
url: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
20
20
|
}, "strict", z.ZodTypeAny, {
|
|
21
|
-
id: string;
|
|
22
21
|
kind: string;
|
|
22
|
+
id: string;
|
|
23
23
|
url?: string | undefined;
|
|
24
24
|
}, {
|
|
25
|
-
id: string;
|
|
26
25
|
kind: string;
|
|
26
|
+
id: string;
|
|
27
27
|
url?: string | undefined;
|
|
28
28
|
}>;
|
|
29
29
|
type ResourceRef = z.infer<typeof resourceRefSchema>;
|
|
@@ -31,11 +31,11 @@ declare const actorSchema: z.ZodObject<{
|
|
|
31
31
|
kind: z.ZodEnum<["human", "agent"]>;
|
|
32
32
|
id: z.ZodString;
|
|
33
33
|
}, "strict", z.ZodTypeAny, {
|
|
34
|
-
id: string;
|
|
35
34
|
kind: "human" | "agent";
|
|
36
|
-
}, {
|
|
37
35
|
id: string;
|
|
36
|
+
}, {
|
|
38
37
|
kind: "human" | "agent";
|
|
38
|
+
id: string;
|
|
39
39
|
}>;
|
|
40
40
|
type Actor = z.infer<typeof actorSchema>;
|
|
41
41
|
declare const notificationSchema: z.ZodObject<{
|
|
@@ -44,11 +44,11 @@ declare const notificationSchema: z.ZodObject<{
|
|
|
44
44
|
kind: z.ZodEnum<["human", "agent"]>;
|
|
45
45
|
id: z.ZodString;
|
|
46
46
|
}, "strict", z.ZodTypeAny, {
|
|
47
|
-
id: string;
|
|
48
47
|
kind: "human" | "agent";
|
|
49
|
-
}, {
|
|
50
48
|
id: string;
|
|
49
|
+
}, {
|
|
51
50
|
kind: "human" | "agent";
|
|
51
|
+
id: string;
|
|
52
52
|
}>;
|
|
53
53
|
type: z.ZodString;
|
|
54
54
|
resource: z.ZodObject<{
|
|
@@ -56,23 +56,23 @@ declare const notificationSchema: z.ZodObject<{
|
|
|
56
56
|
id: z.ZodString;
|
|
57
57
|
url: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
58
58
|
}, "strict", z.ZodTypeAny, {
|
|
59
|
-
id: string;
|
|
60
59
|
kind: string;
|
|
60
|
+
id: string;
|
|
61
61
|
url?: string | undefined;
|
|
62
62
|
}, {
|
|
63
|
-
id: string;
|
|
64
63
|
kind: string;
|
|
64
|
+
id: string;
|
|
65
65
|
url?: string | undefined;
|
|
66
66
|
}>;
|
|
67
67
|
actor: z.ZodObject<{
|
|
68
68
|
kind: z.ZodEnum<["human", "agent"]>;
|
|
69
69
|
id: z.ZodString;
|
|
70
70
|
}, "strict", z.ZodTypeAny, {
|
|
71
|
-
id: string;
|
|
72
71
|
kind: "human" | "agent";
|
|
73
|
-
}, {
|
|
74
72
|
id: string;
|
|
73
|
+
}, {
|
|
75
74
|
kind: "human" | "agent";
|
|
75
|
+
id: string;
|
|
76
76
|
}>;
|
|
77
77
|
body: z.ZodString;
|
|
78
78
|
createdAt: z.ZodNumber;
|
|
@@ -81,17 +81,17 @@ declare const notificationSchema: z.ZodObject<{
|
|
|
81
81
|
type: string;
|
|
82
82
|
id: string;
|
|
83
83
|
recipient: {
|
|
84
|
-
id: string;
|
|
85
84
|
kind: "human" | "agent";
|
|
85
|
+
id: string;
|
|
86
86
|
};
|
|
87
87
|
resource: {
|
|
88
|
-
id: string;
|
|
89
88
|
kind: string;
|
|
89
|
+
id: string;
|
|
90
90
|
url?: string | undefined;
|
|
91
91
|
};
|
|
92
92
|
actor: {
|
|
93
|
-
id: string;
|
|
94
93
|
kind: "human" | "agent";
|
|
94
|
+
id: string;
|
|
95
95
|
};
|
|
96
96
|
body: string;
|
|
97
97
|
createdAt: number;
|
|
@@ -100,17 +100,17 @@ declare const notificationSchema: z.ZodObject<{
|
|
|
100
100
|
type: string;
|
|
101
101
|
id: string;
|
|
102
102
|
recipient: {
|
|
103
|
-
id: string;
|
|
104
103
|
kind: "human" | "agent";
|
|
104
|
+
id: string;
|
|
105
105
|
};
|
|
106
106
|
resource: {
|
|
107
|
-
id: string;
|
|
108
107
|
kind: string;
|
|
108
|
+
id: string;
|
|
109
109
|
url?: string | undefined;
|
|
110
110
|
};
|
|
111
111
|
actor: {
|
|
112
|
-
id: string;
|
|
113
112
|
kind: "human" | "agent";
|
|
113
|
+
id: string;
|
|
114
114
|
};
|
|
115
115
|
body: string;
|
|
116
116
|
createdAt: number;
|
|
@@ -122,11 +122,11 @@ declare const sendInputSchema: z.ZodObject<{
|
|
|
122
122
|
kind: z.ZodEnum<["human", "agent"]>;
|
|
123
123
|
id: z.ZodString;
|
|
124
124
|
}, "strict", z.ZodTypeAny, {
|
|
125
|
-
id: string;
|
|
126
125
|
kind: "human" | "agent";
|
|
127
|
-
}, {
|
|
128
126
|
id: string;
|
|
127
|
+
}, {
|
|
129
128
|
kind: "human" | "agent";
|
|
129
|
+
id: string;
|
|
130
130
|
}>;
|
|
131
131
|
type: z.ZodString;
|
|
132
132
|
resource: z.ZodObject<{
|
|
@@ -134,55 +134,55 @@ declare const sendInputSchema: z.ZodObject<{
|
|
|
134
134
|
id: z.ZodString;
|
|
135
135
|
url: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
136
136
|
}, "strict", z.ZodTypeAny, {
|
|
137
|
-
id: string;
|
|
138
137
|
kind: string;
|
|
138
|
+
id: string;
|
|
139
139
|
url?: string | undefined;
|
|
140
140
|
}, {
|
|
141
|
-
id: string;
|
|
142
141
|
kind: string;
|
|
142
|
+
id: string;
|
|
143
143
|
url?: string | undefined;
|
|
144
144
|
}>;
|
|
145
145
|
actor: z.ZodObject<{
|
|
146
146
|
kind: z.ZodEnum<["human", "agent"]>;
|
|
147
147
|
id: z.ZodString;
|
|
148
148
|
}, "strict", z.ZodTypeAny, {
|
|
149
|
-
id: string;
|
|
150
149
|
kind: "human" | "agent";
|
|
151
|
-
}, {
|
|
152
150
|
id: string;
|
|
151
|
+
}, {
|
|
153
152
|
kind: "human" | "agent";
|
|
153
|
+
id: string;
|
|
154
154
|
}>;
|
|
155
155
|
body: z.ZodString;
|
|
156
156
|
}, "strict", z.ZodTypeAny, {
|
|
157
157
|
type: string;
|
|
158
158
|
recipient: {
|
|
159
|
-
id: string;
|
|
160
159
|
kind: "human" | "agent";
|
|
160
|
+
id: string;
|
|
161
161
|
};
|
|
162
162
|
resource: {
|
|
163
|
-
id: string;
|
|
164
163
|
kind: string;
|
|
164
|
+
id: string;
|
|
165
165
|
url?: string | undefined;
|
|
166
166
|
};
|
|
167
167
|
actor: {
|
|
168
|
-
id: string;
|
|
169
168
|
kind: "human" | "agent";
|
|
169
|
+
id: string;
|
|
170
170
|
};
|
|
171
171
|
body: string;
|
|
172
172
|
}, {
|
|
173
173
|
type: string;
|
|
174
174
|
recipient: {
|
|
175
|
-
id: string;
|
|
176
175
|
kind: "human" | "agent";
|
|
176
|
+
id: string;
|
|
177
177
|
};
|
|
178
178
|
resource: {
|
|
179
|
-
id: string;
|
|
180
179
|
kind: string;
|
|
180
|
+
id: string;
|
|
181
181
|
url?: string | undefined;
|
|
182
182
|
};
|
|
183
183
|
actor: {
|
|
184
|
-
id: string;
|
|
185
184
|
kind: "human" | "agent";
|
|
185
|
+
id: string;
|
|
186
186
|
};
|
|
187
187
|
body: string;
|
|
188
188
|
}>;
|
|
@@ -214,4 +214,4 @@ interface Digest {
|
|
|
214
214
|
groups: DigestGroup[];
|
|
215
215
|
}
|
|
216
216
|
|
|
217
|
-
export { type Actor as A,
|
|
217
|
+
export { type Actor as A, type Channel as C, type Digest as D, type Notification as N, type Preferences as P, type Recipient as R, type SendInput as S, type ResourceRef as a, CHANNELS as b, DEFAULT_CHANNELS as c, type DigestGroup as d, defaultPreferences as e, recipientKey as r };
|