stitchkit 0.70.6 → 0.72.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/README.md +1 -1
- package/dist/agent-runtime/coding-tool-contract.d.ts +11 -1
- package/dist/agent-runtime/coding-tool-contract.d.ts.map +1 -1
- package/dist/agent-runtime/coding-tool-files.d.ts.map +1 -1
- package/dist/agent-runtime/coding-tool-listing.d.ts +15 -0
- package/dist/agent-runtime/coding-tool-listing.d.ts.map +1 -0
- package/dist/agent-runtime/coding-tool-paths.d.ts.map +1 -1
- package/dist/agent-runtime/coding-tool-refusals.d.ts +59 -0
- package/dist/agent-runtime/coding-tool-refusals.d.ts.map +1 -0
- package/dist/agent-runtime/coding-tool-search-patch.d.ts.map +1 -1
- package/dist/agent-runtime/coding-tools.d.ts +3 -1
- package/dist/agent-runtime/coding-tools.d.ts.map +1 -1
- package/dist/agent-runtime/compaction.d.ts +35 -0
- package/dist/agent-runtime/compaction.d.ts.map +1 -1
- package/dist/agent-runtime/contained-files.d.ts +21 -2
- package/dist/agent-runtime/contained-files.d.ts.map +1 -1
- package/dist/agent-runtime/provider-failure.d.ts +66 -0
- package/dist/agent-runtime/provider-failure.d.ts.map +1 -0
- package/dist/agent-runtime/run-execution.d.ts.map +1 -1
- package/dist/agent-runtime/runtime.d.ts +31 -1
- package/dist/agent-runtime/runtime.d.ts.map +1 -1
- package/dist/agent-runtime/schemas.d.ts +1 -0
- package/dist/agent-runtime/schemas.d.ts.map +1 -1
- package/dist/agent-runtime-coding-tools.js +438 -124
- package/dist/agent-runtime-harness.js +4 -4
- package/dist/agent-runtime-openrouter.d.ts +19 -0
- package/dist/agent-runtime-openrouter.d.ts.map +1 -1
- package/dist/agent-runtime-openrouter.js +2 -1
- package/dist/agent-runtime.d.ts +3 -2
- package/dist/agent-runtime.d.ts.map +1 -1
- package/dist/agent-runtime.js +118 -14
- package/dist/application/admission.d.ts +22 -2
- package/dist/application/admission.d.ts.map +1 -1
- package/dist/application/channel.d.ts +28 -0
- package/dist/application/channel.d.ts.map +1 -1
- package/dist/application/diagnostic-journal-contract.d.ts +20 -0
- package/dist/application/diagnostic-journal-contract.d.ts.map +1 -1
- package/dist/application/diagnostic-journal-lock.d.ts +17 -0
- package/dist/application/diagnostic-journal-lock.d.ts.map +1 -0
- package/dist/application/diagnostic-journal-manager.d.ts +2 -1
- package/dist/application/diagnostic-journal-manager.d.ts.map +1 -1
- package/dist/application/diagnostic-journal-storage.d.ts +4 -1
- package/dist/application/diagnostic-journal-storage.d.ts.map +1 -1
- package/dist/application/diagnostic-journal.d.ts +4 -2
- package/dist/application/diagnostic-journal.d.ts.map +1 -1
- package/dist/application-opentelemetry.js +1 -1
- package/dist/application.d.ts +3 -3
- package/dist/application.d.ts.map +1 -1
- package/dist/application.js +134 -21
- package/dist/browser/resumable.d.ts +56 -0
- package/dist/browser/resumable.d.ts.map +1 -0
- package/dist/cli.js +5 -5
- package/dist/{index-cx84zg25.js → index-118v0z41.js} +1 -1
- package/dist/{index-zpyj7hsv.js → index-3cwck0rm.js} +98 -33
- package/dist/{index-ejv31h14.js → index-7qy2ex0m.js} +1 -1
- package/dist/{index-trrf7nch.js → index-ezmn6ac6.js} +3 -3
- package/dist/{index-ekkt4gy9.js → index-jqtsc9mj.js} +2 -2
- package/dist/{index-hxtm2xr2.js → index-k2zczx1g.js} +1 -1
- package/dist/{index-by57nwhc.js → index-m668wzyc.js} +10 -2
- package/dist/{index-w9m1wznn.js → index-nemjkxjp.js} +118 -1
- package/dist/{index-tnazr5tc.js → index-pz7ytdga.js} +3 -3
- package/dist/{index-1z5xxfst.js → index-rqpdar1e.js} +102 -5
- package/dist/{index-qm87g51s.js → index-s4c8wy8m.js} +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +103 -14
- package/dist/node.js +2 -2
- package/dist/observability/index.js +1 -1
- package/dist/primitives/audit.d.ts +52 -0
- package/dist/primitives/audit.d.ts.map +1 -0
- package/dist/primitives/deadline.d.ts +39 -0
- package/dist/primitives/deadline.d.ts.map +1 -0
- package/dist/primitives/decimal.d.ts +10 -0
- package/dist/primitives/decimal.d.ts.map +1 -0
- package/dist/primitives/delivery.d.ts +96 -0
- package/dist/primitives/delivery.d.ts.map +1 -0
- package/dist/primitives/event.d.ts +42 -0
- package/dist/primitives/event.d.ts.map +1 -0
- package/dist/primitives/export-operation.d.ts +89 -0
- package/dist/primitives/export-operation.d.ts.map +1 -0
- package/dist/primitives/index.d.ts +12 -0
- package/dist/primitives/index.d.ts.map +1 -0
- package/dist/primitives/lifecycle.d.ts +90 -0
- package/dist/primitives/lifecycle.d.ts.map +1 -0
- package/dist/primitives/migration-checks.d.ts +15 -0
- package/dist/primitives/migration-checks.d.ts.map +1 -0
- package/dist/primitives/money.d.ts +43 -0
- package/dist/primitives/money.d.ts.map +1 -0
- package/dist/primitives/owner-scope.d.ts +30 -0
- package/dist/primitives/owner-scope.d.ts.map +1 -0
- package/dist/primitives/permission.d.ts +28 -0
- package/dist/primitives/permission.d.ts.map +1 -0
- package/dist/primitives/quantity.d.ts +57 -0
- package/dist/primitives/quantity.d.ts.map +1 -0
- package/dist/primitives.d.ts +3 -0
- package/dist/primitives.d.ts.map +1 -0
- package/dist/primitives.js +750 -0
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +4 -2
- package/dist/server/request.d.ts +19 -0
- package/dist/server/request.d.ts.map +1 -1
- package/dist/telegram/init-data.d.ts +134 -0
- package/dist/telegram/init-data.d.ts.map +1 -0
- package/dist/telegram/send-failure.d.ts +73 -0
- package/dist/telegram/send-failure.d.ts.map +1 -0
- package/dist/telegram.d.ts +3 -0
- package/dist/telegram.d.ts.map +1 -0
- package/dist/telegram.js +224 -0
- package/dist/tool-invoker.js +4 -4
- package/dist/tools.js +7 -7
- package/llms-full.txt +510 -10
- package/llms.txt +1 -0
- package/native/darwin-arm64.node +0 -0
- package/native/darwin-x64.node +0 -0
- package/package.json +11 -3
|
@@ -59,6 +59,123 @@ function parseQueryParams(url) {
|
|
|
59
59
|
}
|
|
60
60
|
return query;
|
|
61
61
|
}
|
|
62
|
+
var IPV4_RESERVED = [
|
|
63
|
+
["0.0.0.0", 8],
|
|
64
|
+
["10.0.0.0", 8],
|
|
65
|
+
["100.64.0.0", 10],
|
|
66
|
+
["127.0.0.0", 8],
|
|
67
|
+
["169.254.0.0", 16],
|
|
68
|
+
["172.16.0.0", 12],
|
|
69
|
+
["192.0.0.0", 24],
|
|
70
|
+
["192.0.2.0", 24],
|
|
71
|
+
["192.88.99.0", 24],
|
|
72
|
+
["192.168.0.0", 16],
|
|
73
|
+
["198.18.0.0", 15],
|
|
74
|
+
["198.51.100.0", 24],
|
|
75
|
+
["203.0.113.0", 24],
|
|
76
|
+
["224.0.0.0", 4],
|
|
77
|
+
["240.0.0.0", 4]
|
|
78
|
+
];
|
|
79
|
+
function parseIpv4(value) {
|
|
80
|
+
const parts = value.split(".");
|
|
81
|
+
if (parts.length !== 4)
|
|
82
|
+
return;
|
|
83
|
+
let result = 0;
|
|
84
|
+
for (const part of parts) {
|
|
85
|
+
if (!/^(0|[1-9]\d{0,2})$/.test(part))
|
|
86
|
+
return;
|
|
87
|
+
const octet = Number(part);
|
|
88
|
+
if (octet > 255)
|
|
89
|
+
return;
|
|
90
|
+
result = result * 256 + octet;
|
|
91
|
+
}
|
|
92
|
+
return result;
|
|
93
|
+
}
|
|
94
|
+
function parseIpv6(value) {
|
|
95
|
+
const address = value.split("%")[0] ?? "";
|
|
96
|
+
if (!address.includes(":"))
|
|
97
|
+
return;
|
|
98
|
+
const halves = address.split("::");
|
|
99
|
+
if (halves.length > 2)
|
|
100
|
+
return;
|
|
101
|
+
const groups = [];
|
|
102
|
+
const tail = [];
|
|
103
|
+
const push = (into, text) => {
|
|
104
|
+
if (text === "")
|
|
105
|
+
return true;
|
|
106
|
+
for (const piece of text.split(":")) {
|
|
107
|
+
if (piece.includes(".")) {
|
|
108
|
+
const v4 = parseIpv4(piece);
|
|
109
|
+
if (v4 === undefined)
|
|
110
|
+
return false;
|
|
111
|
+
into.push(v4 >>> 16 & 65535, v4 & 65535);
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
if (!/^[0-9a-fA-F]{1,4}$/.test(piece))
|
|
115
|
+
return false;
|
|
116
|
+
into.push(Number.parseInt(piece, 16));
|
|
117
|
+
}
|
|
118
|
+
return true;
|
|
119
|
+
};
|
|
120
|
+
if (!push(groups, halves[0] ?? ""))
|
|
121
|
+
return;
|
|
122
|
+
if (halves.length === 2 && !push(tail, halves[1] ?? ""))
|
|
123
|
+
return;
|
|
124
|
+
const missing = 8 - groups.length - tail.length;
|
|
125
|
+
if (halves.length === 2 ? missing < 0 : missing !== 0)
|
|
126
|
+
return;
|
|
127
|
+
const words = [
|
|
128
|
+
...groups,
|
|
129
|
+
...Array(halves.length === 2 ? missing : 0).fill(0),
|
|
130
|
+
...tail
|
|
131
|
+
];
|
|
132
|
+
if (words.length !== 8)
|
|
133
|
+
return;
|
|
134
|
+
const bytes = new Uint8Array(16);
|
|
135
|
+
words.forEach((word, index) => {
|
|
136
|
+
bytes[index * 2] = word >>> 8 & 255;
|
|
137
|
+
bytes[index * 2 + 1] = word & 255;
|
|
138
|
+
});
|
|
139
|
+
return bytes;
|
|
140
|
+
}
|
|
141
|
+
function hasPrefix(bytes, prefix, bits) {
|
|
142
|
+
for (let index = 0;index < bits; index += 1) {
|
|
143
|
+
const byte = bytes[index >> 3] ?? 0;
|
|
144
|
+
const against = prefix[index >> 3] ?? 0;
|
|
145
|
+
const mask = 128 >> index % 8;
|
|
146
|
+
if ((byte & mask) !== (against & mask))
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
149
|
+
return true;
|
|
150
|
+
}
|
|
151
|
+
function isPublicIp(value) {
|
|
152
|
+
const address = value.trim();
|
|
153
|
+
if (!address)
|
|
154
|
+
return false;
|
|
155
|
+
const v4 = parseIpv4(address);
|
|
156
|
+
if (v4 !== undefined) {
|
|
157
|
+
return !IPV4_RESERVED.some(([network, bits]) => {
|
|
158
|
+
const base = parseIpv4(network);
|
|
159
|
+
if (base === undefined)
|
|
160
|
+
return false;
|
|
161
|
+
const mask = bits === 0 ? 0 : 4294967295 << 32 - bits >>> 0;
|
|
162
|
+
return (v4 & mask) >>> 0 === (base & mask) >>> 0;
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
const bytes = parseIpv6(address);
|
|
166
|
+
if (!bytes)
|
|
167
|
+
return false;
|
|
168
|
+
if (hasPrefix(bytes, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255], 96)) {
|
|
169
|
+
return isPublicIp(Array.from(bytes.slice(12)).join("."));
|
|
170
|
+
}
|
|
171
|
+
if (!hasPrefix(bytes, [32], 3))
|
|
172
|
+
return false;
|
|
173
|
+
if (hasPrefix(bytes, [32, 1, 0, 0], 23))
|
|
174
|
+
return false;
|
|
175
|
+
if (hasPrefix(bytes, [32, 1, 13, 184], 32))
|
|
176
|
+
return false;
|
|
177
|
+
return true;
|
|
178
|
+
}
|
|
62
179
|
|
|
63
180
|
// src/observability/context.ts
|
|
64
181
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
@@ -114,4 +231,4 @@ function wrapInRequestContext(handler, options = {}) {
|
|
|
114
231
|
};
|
|
115
232
|
}
|
|
116
233
|
|
|
117
|
-
export { generateTraceId, resolveTraceId, resolveSocketIp, extractIp, getClientInfo, parseQueryParams, runWithRequestContext, getRequestContext, getTraceId, getUserId, setRequestUser, setRequestEndpoint, setRequestDimensions, setRequestError, wrapInRequestContext };
|
|
234
|
+
export { generateTraceId, resolveTraceId, resolveSocketIp, extractIp, getClientInfo, parseQueryParams, isPublicIp, runWithRequestContext, getRequestContext, getTraceId, getUserId, setRequestUser, setRequestEndpoint, setRequestDimensions, setRequestError, wrapInRequestContext };
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
collectToolSurface
|
|
3
|
-
} from "./index-
|
|
3
|
+
} from "./index-k2zczx1g.js";
|
|
4
4
|
import {
|
|
5
5
|
createToolRunner,
|
|
6
6
|
formatToolError
|
|
7
|
-
} from "./index-
|
|
7
|
+
} from "./index-7qy2ex0m.js";
|
|
8
8
|
import {
|
|
9
9
|
coerceJsonArgs,
|
|
10
10
|
toolResultFromError
|
|
11
|
-
} from "./index-
|
|
11
|
+
} from "./index-s4c8wy8m.js";
|
|
12
12
|
import {
|
|
13
13
|
isWithinDir
|
|
14
14
|
} from "./index-sbdmyz75.js";
|
|
@@ -8,7 +8,16 @@ import {
|
|
|
8
8
|
read as readDescriptor,
|
|
9
9
|
write as writeDescriptor
|
|
10
10
|
} from "node:fs";
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
lstat,
|
|
13
|
+
mkdir,
|
|
14
|
+
open,
|
|
15
|
+
readdir,
|
|
16
|
+
realpath,
|
|
17
|
+
rename,
|
|
18
|
+
unlink,
|
|
19
|
+
writeFile
|
|
20
|
+
} from "node:fs/promises";
|
|
12
21
|
import { createRequire } from "node:module";
|
|
13
22
|
import path from "node:path";
|
|
14
23
|
import { fileURLToPath } from "node:url";
|
|
@@ -41,6 +50,7 @@ function loadDarwinBinding() {
|
|
|
41
50
|
"openDirectoryAt",
|
|
42
51
|
"openFileAt",
|
|
43
52
|
"createFileAt",
|
|
53
|
+
"createDirectoryAt",
|
|
44
54
|
"statAt",
|
|
45
55
|
"listAt",
|
|
46
56
|
"renameAt",
|
|
@@ -120,9 +130,10 @@ async function openFileAt(directory, name) {
|
|
|
120
130
|
}
|
|
121
131
|
return open(path.join(descriptorPath(directory), name), constants.O_RDONLY | constants.O_NOFOLLOW);
|
|
122
132
|
}
|
|
123
|
-
function entryMetadata(mode) {
|
|
133
|
+
function entryMetadata(mode, size) {
|
|
124
134
|
return {
|
|
125
135
|
mode,
|
|
136
|
+
...size !== undefined && { size },
|
|
126
137
|
isDirectory: () => modeIs(mode, FILE_TYPE_DIRECTORY),
|
|
127
138
|
isFile: () => modeIs(mode, FILE_TYPE_REGULAR),
|
|
128
139
|
isSymbolicLink: () => modeIs(mode, FILE_TYPE_SYMLINK)
|
|
@@ -131,7 +142,7 @@ function entryMetadata(mode) {
|
|
|
131
142
|
async function statAt(directory, name) {
|
|
132
143
|
if (process.platform === "darwin") {
|
|
133
144
|
const metadata = loadDarwinBinding().statAt(directory.fd, name);
|
|
134
|
-
return metadata ? entryMetadata(metadata.mode) : null;
|
|
145
|
+
return metadata ? entryMetadata(metadata.mode, metadata.size) : null;
|
|
135
146
|
}
|
|
136
147
|
return lstat(path.join(descriptorPath(directory), name)).catch((error) => {
|
|
137
148
|
if (error.code === "ENOENT")
|
|
@@ -145,7 +156,91 @@ async function listAt(directory) {
|
|
|
145
156
|
}
|
|
146
157
|
return readdir(descriptorPath(directory), { withFileTypes: true });
|
|
147
158
|
}
|
|
148
|
-
async function
|
|
159
|
+
async function listContainedDirectory(root, relative, maxEntries) {
|
|
160
|
+
let current = await openPinnedDirectory(root);
|
|
161
|
+
try {
|
|
162
|
+
if (relative !== ".") {
|
|
163
|
+
for (const segment of safeSegments(relative)) {
|
|
164
|
+
const next = await openDirectoryAt(current, segment);
|
|
165
|
+
const metadata = await next.stat();
|
|
166
|
+
if (!metadata.isDirectory()) {
|
|
167
|
+
await next.close();
|
|
168
|
+
throw new Error("Contained ancestor is not a directory");
|
|
169
|
+
}
|
|
170
|
+
await current.close();
|
|
171
|
+
current = next;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
const raw = [...await listAt(current)];
|
|
175
|
+
raw.sort((left, right) => left.name.localeCompare(right.name));
|
|
176
|
+
const entries = [];
|
|
177
|
+
for (const entry of raw.slice(0, maxEntries)) {
|
|
178
|
+
const kind = entry.isDirectory() ? "directory" : entry.isSymbolicLink() ? "symlink" : entry.isFile() ? "file" : "other";
|
|
179
|
+
if (kind !== "file") {
|
|
180
|
+
entries.push({ name: entry.name, kind });
|
|
181
|
+
continue;
|
|
182
|
+
}
|
|
183
|
+
const metadata = await statAt(current, entry.name);
|
|
184
|
+
entries.push({
|
|
185
|
+
name: entry.name,
|
|
186
|
+
kind,
|
|
187
|
+
...metadata && { bytes: metadata.size }
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
entries.sort((left, right) => {
|
|
191
|
+
if (left.kind === right.kind)
|
|
192
|
+
return left.name.localeCompare(right.name);
|
|
193
|
+
return left.kind === "directory" ? -1 : right.kind === "directory" ? 1 : 0;
|
|
194
|
+
});
|
|
195
|
+
return { entries, truncated: raw.length > maxEntries };
|
|
196
|
+
} finally {
|
|
197
|
+
await current.close();
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
async function createDirectoryAt(directory, name) {
|
|
201
|
+
if (process.platform === "darwin") {
|
|
202
|
+
return loadDarwinBinding().createDirectoryAt(directory.fd, name, 511);
|
|
203
|
+
}
|
|
204
|
+
try {
|
|
205
|
+
await mkdir(path.join(descriptorPath(directory), name));
|
|
206
|
+
return true;
|
|
207
|
+
} catch (error) {
|
|
208
|
+
if (error.code === "EEXIST")
|
|
209
|
+
return false;
|
|
210
|
+
throw error;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
async function missingContainedDirectories(root, relative) {
|
|
214
|
+
const segments = safeSegments(relative);
|
|
215
|
+
segments.pop();
|
|
216
|
+
const missing = [];
|
|
217
|
+
let current = await openPinnedDirectory(root);
|
|
218
|
+
try {
|
|
219
|
+
let walked = [];
|
|
220
|
+
for (const segment of segments) {
|
|
221
|
+
walked = [...walked, segment];
|
|
222
|
+
if (missing.length > 0) {
|
|
223
|
+
missing.push(walked.join(path.sep));
|
|
224
|
+
continue;
|
|
225
|
+
}
|
|
226
|
+
const next = await openDirectoryAt(current, segment).catch((error) => {
|
|
227
|
+
if (error.code === "ENOENT")
|
|
228
|
+
return null;
|
|
229
|
+
throw error;
|
|
230
|
+
});
|
|
231
|
+
if (!next) {
|
|
232
|
+
missing.push(walked.join(path.sep));
|
|
233
|
+
continue;
|
|
234
|
+
}
|
|
235
|
+
await current.close();
|
|
236
|
+
current = next;
|
|
237
|
+
}
|
|
238
|
+
return missing;
|
|
239
|
+
} finally {
|
|
240
|
+
await current.close();
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
async function openContainedParent(root, relative, options = {}) {
|
|
149
244
|
const segments = safeSegments(relative);
|
|
150
245
|
const basename = segments.pop();
|
|
151
246
|
if (!basename)
|
|
@@ -153,6 +248,8 @@ async function openContainedParent(root, relative) {
|
|
|
153
248
|
let current = await openPinnedDirectory(root);
|
|
154
249
|
try {
|
|
155
250
|
for (const segment of segments) {
|
|
251
|
+
if (options.create)
|
|
252
|
+
await createDirectoryAt(current, segment);
|
|
156
253
|
const next = await openDirectoryAt(current, segment);
|
|
157
254
|
const metadata = await next.stat();
|
|
158
255
|
if (!metadata.isDirectory()) {
|
|
@@ -394,4 +491,4 @@ async function scanContainedFiles(input) {
|
|
|
394
491
|
return { files, truncated, skippedDirectories, skippedSymlinks };
|
|
395
492
|
}
|
|
396
493
|
|
|
397
|
-
export { openContainedParent, openContainedFile, assertContainedFileCurrent, assertContainedParentCurrent, writeContainedFile, containedEntryMetadata, openContainedParentFile, readContainedUtf8Handle, walkContainedFiles, scanContainedFiles };
|
|
494
|
+
export { listContainedDirectory, missingContainedDirectories, openContainedParent, openContainedFile, assertContainedFileCurrent, assertContainedParentCurrent, writeContainedFile, containedEntryMetadata, openContainedParentFile, readContainedUtf8Handle, walkContainedFiles, scanContainedFiles };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { type ClientConfig, type ClientContract, type ClientFetch, type ClientRegistryValue, type ContractClientConfig, contractEndpointMatchers, createClient, createClients, createScopedClients, createScopedUrlBuilders, createUrlBuilder, createUrlBuilders, type PathPrefixArgs, type RegistryScope, type ScopeClientConfigs, type ScopedClientRegistry, type ScopedUrlBuilderRegistry, type UrlBuilderConfig, } from './browser/client.js';
|
|
2
2
|
export { ApiError, type ApiEvent, type ApiEventListener, type ConfiguredHttpClient, createHttpClient, type HeaderProvider, type HttpClient, type HttpClientConfig, type RequestOptions, type UnauthorizedMatcher, } from './browser/http.js';
|
|
3
3
|
export { createLiveStateController, type LiveStateController, type LiveStateControllerConfig, type LiveStateControllerError, type LiveStateControllerSnapshot, type LiveStateControllerStatus, LiveStateControllerStatusSchema, type LiveStateEventDecision, type LiveStatePhase, LiveStatePhaseSchema, type LiveStateSource, type LiveStateSourceOpenInput, type LiveStateSourceOpenResult, type LiveStateStopReason, LiveStateStopReasonSchema, type LiveStateSubscriberError, } from './browser/live-state.js';
|
|
4
|
+
export { type Backoff, type BackoffPolicy, BackoffPolicySchema, createBackoff, type ResumableAttempt, type ResumableIteratorConfig, resumableIterator, } from './browser/resumable.js';
|
|
4
5
|
export type { BindRealtimeClientOptions, BoundRealtimeClient, RealtimeClient, RealtimeClientOptions, RealtimeClientTransport, SocketEventMap, SocketIOClient, SocketIOClientConfig, SocketIOClientPeerLoaders, } from './browser/socket-io.js';
|
|
5
6
|
export { bindRealtimeClient, createRealtimeClient, createSocketIOClient, } from './browser/socket-io.js';
|
|
6
7
|
export { type ParseNDJSONOptions, type ParseSSEOptions, parseNDJSON, parseSSE, } from './browser/stream.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,wBAAwB,EACxB,YAAY,EACZ,aAAa,EACb,mBAAmB,EACnB,uBAAuB,EACvB,gBAAgB,EAChB,iBAAiB,EACjB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,wBAAwB,EAC7B,KAAK,gBAAgB,GACtB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,QAAQ,EACR,KAAK,QAAQ,EACb,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,gBAAgB,EAChB,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,mBAAmB,GACzB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,yBAAyB,EACzB,KAAK,mBAAmB,EACxB,KAAK,yBAAyB,EAC9B,KAAK,wBAAwB,EAC7B,KAAK,2BAA2B,EAChC,KAAK,yBAAyB,EAC9B,+BAA+B,EAC/B,KAAK,sBAAsB,EAC3B,KAAK,cAAc,EACnB,oBAAoB,EACpB,KAAK,eAAe,EACpB,KAAK,wBAAwB,EAC7B,KAAK,yBAAyB,EAC9B,KAAK,mBAAmB,EACxB,yBAAyB,EACzB,KAAK,wBAAwB,GAC9B,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EACV,yBAAyB,EACzB,mBAAmB,EACnB,cAAc,EACd,qBAAqB,EACrB,uBAAuB,EACvB,cAAc,EACd,cAAc,EACd,oBAAoB,EACpB,yBAAyB,GAC1B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,WAAW,EACX,QAAQ,GACT,MAAM,kBAAkB,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,YAAY,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAG7C,OAAO,EACL,SAAS,EACT,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,KAAK,YAAY,GAClB,MAAM,uBAAuB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,oBAAoB,EAAE,KAAK,cAAc,EAAE,MAAM,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,wBAAwB,EACxB,YAAY,EACZ,aAAa,EACb,mBAAmB,EACnB,uBAAuB,EACvB,gBAAgB,EAChB,iBAAiB,EACjB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,wBAAwB,EAC7B,KAAK,gBAAgB,GACtB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,QAAQ,EACR,KAAK,QAAQ,EACb,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,gBAAgB,EAChB,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,mBAAmB,GACzB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,yBAAyB,EACzB,KAAK,mBAAmB,EACxB,KAAK,yBAAyB,EAC9B,KAAK,wBAAwB,EAC7B,KAAK,2BAA2B,EAChC,KAAK,yBAAyB,EAC9B,+BAA+B,EAC/B,KAAK,sBAAsB,EAC3B,KAAK,cAAc,EACnB,oBAAoB,EACpB,KAAK,eAAe,EACpB,KAAK,wBAAwB,EAC7B,KAAK,yBAAyB,EAC9B,KAAK,mBAAmB,EACxB,yBAAyB,EACzB,KAAK,wBAAwB,GAC9B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,aAAa,EAClB,mBAAmB,EACnB,aAAa,EACb,KAAK,gBAAgB,EACrB,KAAK,uBAAuB,EAC5B,iBAAiB,GAClB,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EACV,yBAAyB,EACzB,mBAAmB,EACnB,cAAc,EACd,qBAAqB,EACrB,uBAAuB,EACvB,cAAc,EACd,cAAc,EACd,oBAAoB,EACpB,yBAAyB,GAC1B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,WAAW,EACX,QAAQ,GACT,MAAM,kBAAkB,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,YAAY,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAG7C,OAAO,EACL,SAAS,EACT,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,KAAK,YAAY,GAClB,MAAM,uBAAuB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,oBAAoB,EAAE,KAAK,cAAc,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1292,7 +1292,8 @@ var CreditWindowSnapshotSchema = z2.object({
|
|
|
1292
1292
|
leasedBytes: z2.number().int().nonnegative(),
|
|
1293
1293
|
acquired: z2.number().int().nonnegative(),
|
|
1294
1294
|
refused: z2.number().int().nonnegative(),
|
|
1295
|
-
replenishedBytes: z2.number().int().nonnegative()
|
|
1295
|
+
replenishedBytes: z2.number().int().nonnegative(),
|
|
1296
|
+
waiting: z2.number().int().nonnegative()
|
|
1296
1297
|
}).strict().readonly();
|
|
1297
1298
|
|
|
1298
1299
|
// src/browser/live-state.ts
|
|
@@ -1682,6 +1683,91 @@ function createLiveStateController(config) {
|
|
|
1682
1683
|
close
|
|
1683
1684
|
};
|
|
1684
1685
|
}
|
|
1686
|
+
// src/browser/resumable.ts
|
|
1687
|
+
import { z as z4 } from "zod";
|
|
1688
|
+
var PositiveSafeIntegerSchema3 = z4.number().int().positive().safe();
|
|
1689
|
+
var BackoffPolicySchema = z4.object({
|
|
1690
|
+
minDelayMs: PositiveSafeIntegerSchema3,
|
|
1691
|
+
maxDelayMs: PositiveSafeIntegerSchema3,
|
|
1692
|
+
jitter: z4.number().min(0).max(1)
|
|
1693
|
+
}).strict().readonly().refine((policy) => policy.maxDelayMs >= policy.minDelayMs, {
|
|
1694
|
+
message: "maxDelayMs must be at least minDelayMs"
|
|
1695
|
+
});
|
|
1696
|
+
function createBackoff(policy, random = Math.random) {
|
|
1697
|
+
const { minDelayMs, maxDelayMs, jitter } = BackoffPolicySchema.parse(policy);
|
|
1698
|
+
let attempt = 0;
|
|
1699
|
+
return {
|
|
1700
|
+
next() {
|
|
1701
|
+
const exponential = Math.min(maxDelayMs, minDelayMs * 2 ** attempt);
|
|
1702
|
+
attempt += 1;
|
|
1703
|
+
const spread = exponential * jitter * random();
|
|
1704
|
+
return Math.max(1, Math.round(exponential - spread));
|
|
1705
|
+
},
|
|
1706
|
+
reset() {
|
|
1707
|
+
attempt = 0;
|
|
1708
|
+
}
|
|
1709
|
+
};
|
|
1710
|
+
}
|
|
1711
|
+
var DEFAULT_RETRY = { minDelayMs: 100, maxDelayMs: 30000, jitter: 0.5 };
|
|
1712
|
+
|
|
1713
|
+
class ResumableAbortError extends Error {
|
|
1714
|
+
constructor() {
|
|
1715
|
+
super("Resumable iterator was aborted");
|
|
1716
|
+
this.name = "ResumableAbortError";
|
|
1717
|
+
}
|
|
1718
|
+
}
|
|
1719
|
+
function sleep(ms, signal) {
|
|
1720
|
+
return new Promise((resolve, reject) => {
|
|
1721
|
+
const timer = setTimeout(() => {
|
|
1722
|
+
signal?.removeEventListener("abort", onAbort);
|
|
1723
|
+
resolve();
|
|
1724
|
+
}, ms);
|
|
1725
|
+
function onAbort() {
|
|
1726
|
+
clearTimeout(timer);
|
|
1727
|
+
reject(new ResumableAbortError);
|
|
1728
|
+
}
|
|
1729
|
+
if (signal?.aborted) {
|
|
1730
|
+
clearTimeout(timer);
|
|
1731
|
+
reject(new ResumableAbortError);
|
|
1732
|
+
return;
|
|
1733
|
+
}
|
|
1734
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
1735
|
+
});
|
|
1736
|
+
}
|
|
1737
|
+
async function* resumableIterator(config) {
|
|
1738
|
+
const backoff = createBackoff(config.retry ?? DEFAULT_RETRY, config.random);
|
|
1739
|
+
let cursor;
|
|
1740
|
+
let attempt = 0;
|
|
1741
|
+
for (;; ) {
|
|
1742
|
+
if (config.signal?.aborted)
|
|
1743
|
+
return;
|
|
1744
|
+
try {
|
|
1745
|
+
const source = await config.open(cursor);
|
|
1746
|
+
for await (const item of source) {
|
|
1747
|
+
if (config.signal?.aborted)
|
|
1748
|
+
return;
|
|
1749
|
+
attempt = 0;
|
|
1750
|
+
backoff.reset();
|
|
1751
|
+
cursor = config.advance(item, cursor);
|
|
1752
|
+
yield item;
|
|
1753
|
+
if (config.isTerminal?.(item))
|
|
1754
|
+
return;
|
|
1755
|
+
}
|
|
1756
|
+
throw new Error("Resumable source ended without a terminal item");
|
|
1757
|
+
} catch (error) {
|
|
1758
|
+
if (config.signal?.aborted || error instanceof ResumableAbortError)
|
|
1759
|
+
return;
|
|
1760
|
+
attempt += 1;
|
|
1761
|
+
const delayMs = backoff.next();
|
|
1762
|
+
config.onAttempt?.({ number: attempt, delayMs, error });
|
|
1763
|
+
try {
|
|
1764
|
+
await sleep(delayMs, config.signal);
|
|
1765
|
+
} catch {
|
|
1766
|
+
return;
|
|
1767
|
+
}
|
|
1768
|
+
}
|
|
1769
|
+
}
|
|
1770
|
+
}
|
|
1685
1771
|
// src/internal/optional-peer.ts
|
|
1686
1772
|
function isModuleNotFound(error) {
|
|
1687
1773
|
if (typeof error !== "object" || error === null)
|
|
@@ -1692,19 +1778,19 @@ function isModuleNotFound(error) {
|
|
|
1692
1778
|
}
|
|
1693
1779
|
|
|
1694
1780
|
// src/realtime/request.ts
|
|
1695
|
-
import { z as
|
|
1696
|
-
var RealtimeRequestPhaseSchema =
|
|
1781
|
+
import { z as z5 } from "zod";
|
|
1782
|
+
var RealtimeRequestPhaseSchema = z5.enum([
|
|
1697
1783
|
"engine-handoff",
|
|
1698
1784
|
"engine-ack-received",
|
|
1699
1785
|
"settled",
|
|
1700
1786
|
"timeout",
|
|
1701
1787
|
"disconnected"
|
|
1702
1788
|
]);
|
|
1703
|
-
var RealtimeRequestPhaseEventSchema =
|
|
1704
|
-
requestId:
|
|
1705
|
-
event:
|
|
1789
|
+
var RealtimeRequestPhaseEventSchema = z5.object({
|
|
1790
|
+
requestId: z5.string().min(1),
|
|
1791
|
+
event: z5.string().min(1),
|
|
1706
1792
|
phase: RealtimeRequestPhaseSchema,
|
|
1707
|
-
elapsedMs:
|
|
1793
|
+
elapsedMs: z5.number().finite().nonnegative()
|
|
1708
1794
|
}).strict();
|
|
1709
1795
|
|
|
1710
1796
|
class RealtimeRequestTimeoutError extends Error {
|
|
@@ -1794,9 +1880,9 @@ function parseIssues(value) {
|
|
|
1794
1880
|
}
|
|
1795
1881
|
|
|
1796
1882
|
// src/realtime/rejection.ts
|
|
1797
|
-
import { z as
|
|
1883
|
+
import { z as z6 } from "zod";
|
|
1798
1884
|
function realtimeContractViolation(options) {
|
|
1799
|
-
const issues = options.cause instanceof
|
|
1885
|
+
const issues = options.cause instanceof z6.ZodError ? zodIssues(options.cause) : undefined;
|
|
1800
1886
|
const reason = options.reason.replaceAll("-", " ");
|
|
1801
1887
|
const error = new AppError("REALTIME_CONTRACT_VIOLATION", `Realtime event "${options.event}" (${options.direction}, ${options.phase}): ${reason}`, 500, {
|
|
1802
1888
|
event: options.event,
|
|
@@ -2532,27 +2618,28 @@ function createSocketIOClientInternal(config, onRequestPhase) {
|
|
|
2532
2618
|
};
|
|
2533
2619
|
}
|
|
2534
2620
|
// src/realtime/contract.ts
|
|
2535
|
-
import { z as
|
|
2621
|
+
import { z as z7 } from "zod";
|
|
2536
2622
|
function defineRealtimeContract(contract) {
|
|
2537
2623
|
return contract;
|
|
2538
2624
|
}
|
|
2539
|
-
var RealtimeRejectDirectionSchema =
|
|
2625
|
+
var RealtimeRejectDirectionSchema = z7.enum([
|
|
2540
2626
|
"client-inbound",
|
|
2541
2627
|
"client-outbound",
|
|
2542
2628
|
"server-inbound",
|
|
2543
2629
|
"server-outbound"
|
|
2544
2630
|
]);
|
|
2545
|
-
var RealtimeRejectPhaseSchema =
|
|
2546
|
-
var RealtimeRejectReasonSchema =
|
|
2631
|
+
var RealtimeRejectPhaseSchema = z7.enum(["arguments", "acknowledgement"]);
|
|
2632
|
+
var RealtimeRejectReasonSchema = z7.enum([
|
|
2547
2633
|
"unknown-event",
|
|
2548
2634
|
"invalid-arguments",
|
|
2549
2635
|
"invalid-acknowledgement-value",
|
|
2550
2636
|
"missing-acknowledgement",
|
|
2551
2637
|
"rejected-by-peer"
|
|
2552
2638
|
]);
|
|
2553
|
-
var RealtimeRejectFaultSchema =
|
|
2639
|
+
var RealtimeRejectFaultSchema = z7.enum(["peer", "local"]);
|
|
2554
2640
|
export {
|
|
2555
2641
|
unauthorized,
|
|
2642
|
+
resumableIterator,
|
|
2556
2643
|
rateLimited,
|
|
2557
2644
|
parseTraceparent,
|
|
2558
2645
|
parseSSE,
|
|
@@ -2580,6 +2667,7 @@ export {
|
|
|
2580
2667
|
createContractFactory,
|
|
2581
2668
|
createClients,
|
|
2582
2669
|
createClient,
|
|
2670
|
+
createBackoff,
|
|
2583
2671
|
contractEndpointMatchers,
|
|
2584
2672
|
conflict,
|
|
2585
2673
|
childSpan,
|
|
@@ -2602,6 +2690,7 @@ export {
|
|
|
2602
2690
|
LiveStateControllerStatusSchema,
|
|
2603
2691
|
DEFAULT_CONTRACT_STREAM_FRAME_BYTES,
|
|
2604
2692
|
ContractStreamFrameSchema,
|
|
2693
|
+
BackoffPolicySchema,
|
|
2605
2694
|
AppError,
|
|
2606
2695
|
ApiError,
|
|
2607
2696
|
ALL_TRANSPORTS
|
package/dist/node.js
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
createHandler,
|
|
6
6
|
createSocketIOServer,
|
|
7
7
|
createUnixClientTransport
|
|
8
|
-
} from "./index-
|
|
8
|
+
} from "./index-118v0z41.js";
|
|
9
9
|
import {
|
|
10
10
|
createImplement,
|
|
11
11
|
createImplementRegistry,
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
implement,
|
|
16
16
|
implementRegistry
|
|
17
17
|
} from "./index-vbf2p6me.js";
|
|
18
|
-
import"./index-
|
|
18
|
+
import"./index-nemjkxjp.js";
|
|
19
19
|
import"./index-7b188kmz.js";
|
|
20
20
|
import {
|
|
21
21
|
ShutdownOptionsSchema,
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { type ZodType, z } from 'zod';
|
|
2
|
+
import type { ContractDef } from '../contract/index.js';
|
|
3
|
+
import { type DomainEventActor, type DomainEventSubject } from './event.js';
|
|
4
|
+
export interface AuditRecordPolicy<TChange extends ZodType = ZodType> {
|
|
5
|
+
readonly mode: 'record';
|
|
6
|
+
readonly change: TChange;
|
|
7
|
+
}
|
|
8
|
+
export interface AuditOmitPolicy {
|
|
9
|
+
readonly mode: 'omit';
|
|
10
|
+
readonly reason: string;
|
|
11
|
+
}
|
|
12
|
+
export type AuditPolicy = AuditRecordPolicy | AuditOmitPolicy;
|
|
13
|
+
export declare const AuditChangeSchema: z.ZodObject<{
|
|
14
|
+
operation: z.ZodString;
|
|
15
|
+
change: z.ZodUnknown;
|
|
16
|
+
}, z.core.$strip>;
|
|
17
|
+
export declare const AuditRecordSchema: z.ZodObject<{
|
|
18
|
+
id: z.ZodString;
|
|
19
|
+
type: z.ZodString;
|
|
20
|
+
occurredAt: z.ZodISODateTime;
|
|
21
|
+
actor: z.ZodOptional<z.ZodObject<{
|
|
22
|
+
id: z.ZodString;
|
|
23
|
+
role: z.ZodString;
|
|
24
|
+
}, z.core.$strip>>;
|
|
25
|
+
subject: z.ZodObject<{
|
|
26
|
+
type: z.ZodString;
|
|
27
|
+
id: z.ZodString;
|
|
28
|
+
}, z.core.$strip>;
|
|
29
|
+
payload: z.ZodObject<{
|
|
30
|
+
operation: z.ZodString;
|
|
31
|
+
change: z.ZodUnknown;
|
|
32
|
+
}, z.core.$strip>;
|
|
33
|
+
}, z.core.$strip>;
|
|
34
|
+
export type AuditRecord = z.infer<typeof AuditRecordSchema>;
|
|
35
|
+
export declare const audit: Readonly<{
|
|
36
|
+
record<TChange extends ZodType>(change: TChange): AuditRecordPolicy<TChange>;
|
|
37
|
+
omit(reason: string): AuditOmitPolicy;
|
|
38
|
+
}>;
|
|
39
|
+
/** Refuse a contract whose operation author did not make an explicit audit decision. */
|
|
40
|
+
export declare function assertAuditDeclared(contract: ContractDef): void;
|
|
41
|
+
export interface CreateAuditRecordInput<TChange> {
|
|
42
|
+
readonly id: string;
|
|
43
|
+
readonly occurredAt: string;
|
|
44
|
+
readonly operation: string;
|
|
45
|
+
readonly actor: DomainEventActor;
|
|
46
|
+
readonly subject: DomainEventSubject;
|
|
47
|
+
readonly policy: AuditRecordPolicy<ZodType<TChange>>;
|
|
48
|
+
readonly change: TChange;
|
|
49
|
+
}
|
|
50
|
+
/** Validate the declared change and return the same event value journals and delivery consume. */
|
|
51
|
+
export declare function createAuditRecord<TChange>(input: CreateAuditRecordInput<TChange>): AuditRecord;
|
|
52
|
+
//# sourceMappingURL=audit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit.d.ts","sourceRoot":"","sources":["../../src/primitives/audit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACtC,OAAO,KAAK,EAAE,WAAW,EAAe,MAAM,aAAa,CAAC;AAC5D,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACxB,MAAM,SAAS,CAAC;AAEjB,MAAM,WAAW,iBAAiB,CAAC,OAAO,SAAS,OAAO,GAAG,OAAO;IAClE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,MAAM,WAAW,GAAG,iBAAiB,GAAG,eAAe,CAAC;AAE9D,eAAO,MAAM,iBAAiB;;;iBAG5B,CAAC;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;iBAA6C,CAAC;AAC5E,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE5D,eAAO,MAAM,KAAK;WACT,OAAO,SAAS,OAAO,UAAU,OAAO,GAAG,iBAAiB,CAAC,OAAO,CAAC;iBAG/D,MAAM,GAAG,eAAe;EAIrC,CAAC;AAuBH,wFAAwF;AACxF,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,WAAW,GAAG,IAAI,CAQ/D;AAED,MAAM,WAAW,sBAAsB,CAAC,OAAO;IAC7C,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,gBAAgB,CAAC;IACjC,QAAQ,CAAC,OAAO,EAAE,kBAAkB,CAAC;IACrC,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;IACrD,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;CAC1B;AAED,kGAAkG;AAClG,wBAAgB,iBAAiB,CAAC,OAAO,EACvC,KAAK,EAAE,sBAAsB,CAAC,OAAO,CAAC,GACrC,WAAW,CAUb"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const DeadlineResultSchema: z.ZodObject<{
|
|
3
|
+
dueAt: z.ZodISODateTime;
|
|
4
|
+
remainingDays: z.ZodNumber;
|
|
5
|
+
overdueDays: z.ZodNumber;
|
|
6
|
+
category: z.ZodString;
|
|
7
|
+
}, z.core.$strip>;
|
|
8
|
+
export type DeadlineResult = z.infer<typeof DeadlineResultSchema>;
|
|
9
|
+
export declare function defineDeadlinePolicy<const TOnTrack extends string, const TWarning extends string, const TOverdue extends string>(config: {
|
|
10
|
+
readonly boundary: 'elapsed-day' | 'calendar-day';
|
|
11
|
+
readonly timeZone: string;
|
|
12
|
+
readonly warningDays: number;
|
|
13
|
+
readonly categories: {
|
|
14
|
+
readonly onTrack: TOnTrack;
|
|
15
|
+
readonly warning: TWarning;
|
|
16
|
+
readonly overdue: TOverdue;
|
|
17
|
+
};
|
|
18
|
+
}): Readonly<{
|
|
19
|
+
definition: {
|
|
20
|
+
readonly boundary: 'elapsed-day' | 'calendar-day';
|
|
21
|
+
readonly timeZone: string;
|
|
22
|
+
readonly warningDays: number;
|
|
23
|
+
readonly categories: {
|
|
24
|
+
readonly onTrack: TOnTrack;
|
|
25
|
+
readonly warning: TWarning;
|
|
26
|
+
readonly overdue: TOverdue;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
evaluate(input: {
|
|
30
|
+
readonly anchorAt: Date;
|
|
31
|
+
readonly durationDays: number;
|
|
32
|
+
readonly now: Date;
|
|
33
|
+
}): DeadlineResult;
|
|
34
|
+
queryBoundary(now: Date): Readonly<{
|
|
35
|
+
overdueBefore: string;
|
|
36
|
+
warningBefore: string;
|
|
37
|
+
}>;
|
|
38
|
+
}>;
|
|
39
|
+
//# sourceMappingURL=deadline.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deadline.d.ts","sourceRoot":"","sources":["../../src/primitives/deadline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,oBAAoB;;;;;iBAK/B,CAAC;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AA8ElE,wBAAgB,oBAAoB,CAClC,KAAK,CAAC,QAAQ,SAAS,MAAM,EAC7B,KAAK,CAAC,QAAQ,SAAS,MAAM,EAC7B,KAAK,CAAC,QAAQ,SAAS,MAAM,EAC7B,MAAM,EAAE;IACR,QAAQ,CAAC,QAAQ,EAAE,aAAa,GAAG,cAAc,CAAC;IAClD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE;QACnB,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC;QAC3B,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC;QAC3B,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC;KAC5B,CAAC;CACH;;2BARoB,aAAa,GAAG,cAAc;2BAC9B,MAAM;8BACH,MAAM;6BACP;YACnB,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC;YAC3B,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC;YAC3B,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC;SAC5B;;oBAYiB;QACd,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC;QACxB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;QAC9B,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC;KACpB,GAAG,cAAc;uBAsBC,IAAI;;;;GAO1B"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface DecimalParts {
|
|
2
|
+
readonly coefficient: bigint;
|
|
3
|
+
readonly scale: number;
|
|
4
|
+
}
|
|
5
|
+
export declare function parseDecimal(value: string): DecimalParts;
|
|
6
|
+
export declare function normalizeDecimal(parts: DecimalParts): DecimalParts;
|
|
7
|
+
export declare function formatDecimal(parts: DecimalParts): string;
|
|
8
|
+
export declare function addDecimal(left: DecimalParts, right: DecimalParts): DecimalParts;
|
|
9
|
+
export declare function multiplyDecimalRatio(value: DecimalParts, numerator: bigint, denominator: bigint): DecimalParts;
|
|
10
|
+
//# sourceMappingURL=decimal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decimal.d.ts","sourceRoot":"","sources":["../../src/primitives/decimal.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,CAOxD;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,YAAY,GAAG,YAAY,CAQlE;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,YAAY,GAAG,MAAM,CAQzD;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,YAAY,GAAG,YAAY,CAKhF;AAED,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,YAAY,EACnB,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,GAClB,YAAY,CAYd"}
|