@yolk-sdk/emulators 0.1.0-canary.96
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/LICENSE +21 -0
- package/README.md +2135 -0
- package/dist/anthropic.d.mts +269 -0
- package/dist/anthropic.d.mts.map +1 -0
- package/dist/anthropic.mjs +177 -0
- package/dist/anthropic.mjs.map +1 -0
- package/dist/chat-completions.d.mts +288 -0
- package/dist/chat-completions.d.mts.map +1 -0
- package/dist/chat-completions.mjs +451 -0
- package/dist/chat-completions.mjs.map +1 -0
- package/dist/codex.d.mts +265 -0
- package/dist/codex.d.mts.map +1 -0
- package/dist/codex.mjs +199 -0
- package/dist/codex.mjs.map +1 -0
- package/dist/dropbox/api.d.mts +63 -0
- package/dist/dropbox/api.d.mts.map +1 -0
- package/dist/dropbox/api.mjs +565 -0
- package/dist/dropbox/api.mjs.map +1 -0
- package/dist/dropbox/state.d.mts +136 -0
- package/dist/dropbox/state.d.mts.map +1 -0
- package/dist/dropbox/state.mjs +209 -0
- package/dist/dropbox/state.mjs.map +1 -0
- package/dist/dropbox.d.mts +79 -0
- package/dist/dropbox.d.mts.map +1 -0
- package/dist/dropbox.mjs +124 -0
- package/dist/dropbox.mjs.map +1 -0
- package/dist/email-fixtures.d.mts +36 -0
- package/dist/email-fixtures.d.mts.map +1 -0
- package/dist/email-fixtures.mjs +1080 -0
- package/dist/email-fixtures.mjs.map +1 -0
- package/dist/email.d.mts +160 -0
- package/dist/email.d.mts.map +1 -0
- package/dist/email.mjs +608 -0
- package/dist/email.mjs.map +1 -0
- package/dist/emulator-compose.d.mts +40 -0
- package/dist/emulator-compose.d.mts.map +1 -0
- package/dist/emulator-compose.mjs +91 -0
- package/dist/emulator-compose.mjs.map +1 -0
- package/dist/emulator-http.d.mts +53 -0
- package/dist/emulator-http.d.mts.map +1 -0
- package/dist/emulator-http.mjs +117 -0
- package/dist/emulator-http.mjs.map +1 -0
- package/dist/emulator-kernel.d.mts +176 -0
- package/dist/emulator-kernel.d.mts.map +1 -0
- package/dist/emulator-kernel.mjs +413 -0
- package/dist/emulator-kernel.mjs.map +1 -0
- package/dist/fixture-route.d.mts +129 -0
- package/dist/fixture-route.d.mts.map +1 -0
- package/dist/fixture-route.mjs +257 -0
- package/dist/fixture-route.mjs.map +1 -0
- package/dist/fortnox/api.d.mts +92 -0
- package/dist/fortnox/api.d.mts.map +1 -0
- package/dist/fortnox/api.mjs +750 -0
- package/dist/fortnox/api.mjs.map +1 -0
- package/dist/fortnox/state.d.mts +533 -0
- package/dist/fortnox/state.d.mts.map +1 -0
- package/dist/fortnox/state.mjs +612 -0
- package/dist/fortnox/state.mjs.map +1 -0
- package/dist/fortnox.d.mts +128 -0
- package/dist/fortnox.d.mts.map +1 -0
- package/dist/fortnox.mjs +403 -0
- package/dist/fortnox.mjs.map +1 -0
- package/dist/gateway-evaluate-recordings.d.mts +12 -0
- package/dist/gateway-evaluate-recordings.d.mts.map +1 -0
- package/dist/gateway-evaluate-recordings.mjs +128 -0
- package/dist/gateway-evaluate-recordings.mjs.map +1 -0
- package/dist/gateway.d.mts +272 -0
- package/dist/gateway.d.mts.map +1 -0
- package/dist/gateway.mjs +400 -0
- package/dist/gateway.mjs.map +1 -0
- package/dist/github/api.d.mts +63 -0
- package/dist/github/api.d.mts.map +1 -0
- package/dist/github/api.mjs +527 -0
- package/dist/github/api.mjs.map +1 -0
- package/dist/github/state.d.mts +272 -0
- package/dist/github/state.d.mts.map +1 -0
- package/dist/github/state.mjs +303 -0
- package/dist/github/state.mjs.map +1 -0
- package/dist/github.d.mts +77 -0
- package/dist/github.d.mts.map +1 -0
- package/dist/github.mjs +180 -0
- package/dist/github.mjs.map +1 -0
- package/dist/google/calendar.d.mts +10 -0
- package/dist/google/calendar.d.mts.map +1 -0
- package/dist/google/calendar.mjs +252 -0
- package/dist/google/calendar.mjs.map +1 -0
- package/dist/google/drive.d.mts +8 -0
- package/dist/google/drive.d.mts.map +1 -0
- package/dist/google/drive.mjs +252 -0
- package/dist/google/drive.mjs.map +1 -0
- package/dist/google/gmail.d.mts +10 -0
- package/dist/google/gmail.d.mts.map +1 -0
- package/dist/google/gmail.mjs +591 -0
- package/dist/google/gmail.mjs.map +1 -0
- package/dist/google/shared.d.mts +107 -0
- package/dist/google/shared.d.mts.map +1 -0
- package/dist/google/shared.mjs +146 -0
- package/dist/google/shared.mjs.map +1 -0
- package/dist/google/state.d.mts +385 -0
- package/dist/google/state.d.mts.map +1 -0
- package/dist/google/state.mjs +496 -0
- package/dist/google/state.mjs.map +1 -0
- package/dist/google.d.mts +75 -0
- package/dist/google.d.mts.map +1 -0
- package/dist/google.mjs +210 -0
- package/dist/google.mjs.map +1 -0
- package/dist/linkedin-search/api.d.mts +45 -0
- package/dist/linkedin-search/api.d.mts.map +1 -0
- package/dist/linkedin-search/api.mjs +181 -0
- package/dist/linkedin-search/api.mjs.map +1 -0
- package/dist/linkedin-search/state.d.mts +123 -0
- package/dist/linkedin-search/state.d.mts.map +1 -0
- package/dist/linkedin-search/state.mjs +261 -0
- package/dist/linkedin-search/state.mjs.map +1 -0
- package/dist/linkedin-search.d.mts +69 -0
- package/dist/linkedin-search.d.mts.map +1 -0
- package/dist/linkedin-search.mjs +158 -0
- package/dist/linkedin-search.mjs.map +1 -0
- package/dist/mcp/api.d.mts +44 -0
- package/dist/mcp/api.d.mts.map +1 -0
- package/dist/mcp/api.mjs +557 -0
- package/dist/mcp/api.mjs.map +1 -0
- package/dist/mcp/recordings.d.mts +40 -0
- package/dist/mcp/recordings.d.mts.map +1 -0
- package/dist/mcp/recordings.mjs +2390 -0
- package/dist/mcp/recordings.mjs.map +1 -0
- package/dist/mcp/state.d.mts +71 -0
- package/dist/mcp/state.d.mts.map +1 -0
- package/dist/mcp/state.mjs +83 -0
- package/dist/mcp/state.mjs.map +1 -0
- package/dist/mcp.d.mts +84 -0
- package/dist/mcp.d.mts.map +1 -0
- package/dist/mcp.mjs +241 -0
- package/dist/mcp.mjs.map +1 -0
- package/dist/messages.d.mts +183 -0
- package/dist/messages.d.mts.map +1 -0
- package/dist/messages.mjs +532 -0
- package/dist/messages.mjs.map +1 -0
- package/dist/microsoft/api.d.mts +47 -0
- package/dist/microsoft/api.d.mts.map +1 -0
- package/dist/microsoft/api.mjs +178 -0
- package/dist/microsoft/api.mjs.map +1 -0
- package/dist/microsoft/calendar.d.mts +30 -0
- package/dist/microsoft/calendar.d.mts.map +1 -0
- package/dist/microsoft/calendar.mjs +271 -0
- package/dist/microsoft/calendar.mjs.map +1 -0
- package/dist/microsoft/drive.d.mts +36 -0
- package/dist/microsoft/drive.d.mts.map +1 -0
- package/dist/microsoft/drive.mjs +298 -0
- package/dist/microsoft/drive.mjs.map +1 -0
- package/dist/microsoft/graph.d.mts +198 -0
- package/dist/microsoft/graph.d.mts.map +1 -0
- package/dist/microsoft/graph.mjs +264 -0
- package/dist/microsoft/graph.mjs.map +1 -0
- package/dist/microsoft/mail.d.mts +48 -0
- package/dist/microsoft/mail.d.mts.map +1 -0
- package/dist/microsoft/mail.mjs +488 -0
- package/dist/microsoft/mail.mjs.map +1 -0
- package/dist/microsoft/state.d.mts +480 -0
- package/dist/microsoft/state.d.mts.map +1 -0
- package/dist/microsoft/state.mjs +625 -0
- package/dist/microsoft/state.mjs.map +1 -0
- package/dist/microsoft.d.mts +168 -0
- package/dist/microsoft.d.mts.map +1 -0
- package/dist/microsoft.mjs +483 -0
- package/dist/microsoft.mjs.map +1 -0
- package/dist/node.d.mts +47 -0
- package/dist/node.d.mts.map +1 -0
- package/dist/node.mjs +178 -0
- package/dist/node.mjs.map +1 -0
- package/dist/notion/api.d.mts +51 -0
- package/dist/notion/api.d.mts.map +1 -0
- package/dist/notion/api.mjs +507 -0
- package/dist/notion/api.mjs.map +1 -0
- package/dist/notion/state.d.mts +329 -0
- package/dist/notion/state.d.mts.map +1 -0
- package/dist/notion/state.mjs +432 -0
- package/dist/notion/state.mjs.map +1 -0
- package/dist/notion.d.mts +72 -0
- package/dist/notion.d.mts.map +1 -0
- package/dist/notion.mjs +127 -0
- package/dist/notion.mjs.map +1 -0
- package/dist/openai.d.mts +165 -0
- package/dist/openai.d.mts.map +1 -0
- package/dist/openai.mjs +141 -0
- package/dist/openai.mjs.map +1 -0
- package/dist/opencode-recordings.d.mts +7 -0
- package/dist/opencode-recordings.d.mts.map +1 -0
- package/dist/opencode-recordings.mjs +222 -0
- package/dist/opencode-recordings.mjs.map +1 -0
- package/dist/opencode.d.mts +70 -0
- package/dist/opencode.d.mts.map +1 -0
- package/dist/opencode.mjs +217 -0
- package/dist/opencode.mjs.map +1 -0
- package/dist/r2-fixtures.d.mts +36 -0
- package/dist/r2-fixtures.d.mts.map +1 -0
- package/dist/r2-fixtures.mjs +245 -0
- package/dist/r2-fixtures.mjs.map +1 -0
- package/dist/r2-guard.d.mts +43 -0
- package/dist/r2-guard.d.mts.map +1 -0
- package/dist/r2-guard.mjs +215 -0
- package/dist/r2-guard.mjs.map +1 -0
- package/dist/r2.d.mts +166 -0
- package/dist/r2.d.mts.map +1 -0
- package/dist/r2.mjs +517 -0
- package/dist/r2.mjs.map +1 -0
- package/dist/responses.d.mts +231 -0
- package/dist/responses.d.mts.map +1 -0
- package/dist/responses.mjs +556 -0
- package/dist/responses.mjs.map +1 -0
- package/dist/route-evidence.d.mts +45 -0
- package/dist/route-evidence.d.mts.map +1 -0
- package/dist/route-evidence.mjs +56 -0
- package/dist/route-evidence.mjs.map +1 -0
- package/dist/router.d.mts +93 -0
- package/dist/router.d.mts.map +1 -0
- package/dist/router.mjs +259 -0
- package/dist/router.mjs.map +1 -0
- package/dist/stateful-core.d.mts +17 -0
- package/dist/stateful-core.d.mts.map +1 -0
- package/dist/stateful-core.mjs +41 -0
- package/dist/stateful-core.mjs.map +1 -0
- package/dist/stateful-emulator.d.mts +565 -0
- package/dist/stateful-emulator.d.mts.map +1 -0
- package/dist/stateful-emulator.mjs +1228 -0
- package/dist/stateful-emulator.mjs.map +1 -0
- package/dist/stateful-secrets.d.mts +84 -0
- package/dist/stateful-secrets.d.mts.map +1 -0
- package/dist/stateful-secrets.mjs +216 -0
- package/dist/stateful-secrets.mjs.map +1 -0
- package/dist/subscription-usage-recordings.d.mts +9 -0
- package/dist/subscription-usage-recordings.d.mts.map +1 -0
- package/dist/subscription-usage-recordings.mjs +53 -0
- package/dist/subscription-usage-recordings.mjs.map +1 -0
- package/dist/subscription-usage.d.mts +53 -0
- package/dist/subscription-usage.d.mts.map +1 -0
- package/dist/subscription-usage.mjs +21 -0
- package/dist/subscription-usage.mjs.map +1 -0
- package/dist/telegram/api.d.mts +34 -0
- package/dist/telegram/api.d.mts.map +1 -0
- package/dist/telegram/api.mjs +257 -0
- package/dist/telegram/api.mjs.map +1 -0
- package/dist/telegram/state.d.mts +128 -0
- package/dist/telegram/state.d.mts.map +1 -0
- package/dist/telegram/state.mjs +154 -0
- package/dist/telegram/state.mjs.map +1 -0
- package/dist/telegram.d.mts +62 -0
- package/dist/telegram.d.mts.map +1 -0
- package/dist/telegram.mjs +127 -0
- package/dist/telegram.mjs.map +1 -0
- package/dist/todoist/api.d.mts +55 -0
- package/dist/todoist/api.d.mts.map +1 -0
- package/dist/todoist/api.mjs +415 -0
- package/dist/todoist/api.mjs.map +1 -0
- package/dist/todoist/state.d.mts +275 -0
- package/dist/todoist/state.d.mts.map +1 -0
- package/dist/todoist/state.mjs +345 -0
- package/dist/todoist/state.mjs.map +1 -0
- package/dist/todoist.d.mts +68 -0
- package/dist/todoist.d.mts.map +1 -0
- package/dist/todoist.mjs +181 -0
- package/dist/todoist.mjs.map +1 -0
- package/dist/xai.d.mts +267 -0
- package/dist/xai.d.mts.map +1 -0
- package/dist/xai.mjs +252 -0
- package/dist/xai.mjs.map +1 -0
- package/package.json +157 -0
- package/src/anthropic.ts +289 -0
- package/src/chat-completions.ts +924 -0
- package/src/codex.ts +296 -0
- package/src/dropbox/api.ts +1084 -0
- package/src/dropbox/state.ts +364 -0
- package/src/dropbox.ts +203 -0
- package/src/email-fixtures.ts +1297 -0
- package/src/email.ts +1108 -0
- package/src/emulator-compose.ts +147 -0
- package/src/emulator-http.ts +184 -0
- package/src/emulator-kernel.ts +844 -0
- package/src/fixture-route.ts +561 -0
- package/src/fortnox/api.ts +1352 -0
- package/src/fortnox/state.ts +798 -0
- package/src/fortnox.ts +801 -0
- package/src/gateway-evaluate-recordings.ts +153 -0
- package/src/gateway.ts +530 -0
- package/src/github/api.ts +986 -0
- package/src/github/state.ts +439 -0
- package/src/github.ts +271 -0
- package/src/google/calendar.ts +486 -0
- package/src/google/drive.ts +471 -0
- package/src/google/gmail.ts +1011 -0
- package/src/google/shared.ts +321 -0
- package/src/google/state.ts +686 -0
- package/src/google.ts +298 -0
- package/src/linkedin-search/api.ts +363 -0
- package/src/linkedin-search/state.ts +373 -0
- package/src/linkedin-search.ts +241 -0
- package/src/mcp/api.ts +995 -0
- package/src/mcp/recordings.ts +2665 -0
- package/src/mcp/state.ts +125 -0
- package/src/mcp.ts +319 -0
- package/src/messages.ts +844 -0
- package/src/microsoft/api.ts +426 -0
- package/src/microsoft/calendar.ts +491 -0
- package/src/microsoft/drive.ts +541 -0
- package/src/microsoft/graph.ts +550 -0
- package/src/microsoft/mail.ts +833 -0
- package/src/microsoft/state.ts +822 -0
- package/src/microsoft.ts +982 -0
- package/src/node.ts +293 -0
- package/src/notion/api.ts +976 -0
- package/src/notion/state.ts +512 -0
- package/src/notion.ts +210 -0
- package/src/openai.ts +198 -0
- package/src/opencode-recordings.ts +257 -0
- package/src/opencode.ts +271 -0
- package/src/r2-fixtures.ts +295 -0
- package/src/r2-guard.ts +323 -0
- package/src/r2.ts +890 -0
- package/src/responses.ts +901 -0
- package/src/route-evidence.ts +90 -0
- package/src/router.ts +490 -0
- package/src/stateful-core.ts +70 -0
- package/src/stateful-emulator.ts +2571 -0
- package/src/stateful-secrets.ts +299 -0
- package/src/subscription-usage-recordings.ts +77 -0
- package/src/subscription-usage.ts +68 -0
- package/src/telegram/api.ts +437 -0
- package/src/telegram/state.ts +229 -0
- package/src/telegram.ts +227 -0
- package/src/todoist/api.ts +736 -0
- package/src/todoist/state.ts +456 -0
- package/src/todoist.ts +316 -0
- package/src/xai.ts +341 -0
package/dist/dropbox.mjs
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { emulatorEvidenceHeader } from "./route-evidence.mjs";
|
|
2
|
+
import { StatefulFault, StatefulFaultMatch, checkBooleanDrills, makeStatefulEmulator, routeEvidence } from "./stateful-emulator.mjs";
|
|
3
|
+
import { DropboxEmulatorDeleted, DropboxEmulatorEntry, DropboxEmulatorEntrySeed, DropboxEmulatorFile, DropboxEmulatorProfile, DropboxEmulatorSeed, DropboxEmulatorStateSchema, buildSeedState, decodeState } from "./dropbox/state.mjs";
|
|
4
|
+
import { dropboxApiRoutes, dropboxEmulatorApiOrigin, dropboxEmulatorBasePath, dropboxEmulatorContentOrigin, dropboxEmulatorDrillKnobs, dropboxEmulatorErrorBodies } from "./dropbox/api.mjs";
|
|
5
|
+
import { statefulCoreRuntime } from "./stateful-core.mjs";
|
|
6
|
+
import { Data, Predicate } from "effect";
|
|
7
|
+
//#region src/dropbox.ts
|
|
8
|
+
/**
|
|
9
|
+
* Stateful Dropbox emulator (the `/2` RPC routes on `https://api.dropboxapi.com` and the upload
|
|
10
|
+
* route on `https://content.dropboxapi.com`), built on the upstream `@emulators/core` custom
|
|
11
|
+
* runtime, with a request ledger, status faults, and an `/_emulate/*` control plane.
|
|
12
|
+
*
|
|
13
|
+
* It never imports SDK code: its wire shapes, error envelopes, and default seed are copied as data
|
|
14
|
+
* from the synthetic Dropbox conformance fixtures, and every route names the conformance cases it
|
|
15
|
+
* follows in `dropboxEmulatorRoutes`. Only the routes those eight cases (with their cleanup) send
|
|
16
|
+
* are emulated, each on the origin its fixtures record. Response behaviour comes only from the
|
|
17
|
+
* fixtures: anything they do not show answers one ledgered 400 not-emulated, writes nothing, and
|
|
18
|
+
* uses up no fault. That includes a listing of an empty folder, so the read-only leftover lookup
|
|
19
|
+
* fails against the default seed's empty work folder (the live runner prints its lookup-failed
|
|
20
|
+
* WARN).
|
|
21
|
+
*
|
|
22
|
+
* Request-shape latitude (`/dropbox`, the only accepted deviations): any bearer value (never
|
|
23
|
+
* checked or stored); extra request headers; JSON key order; `content-type` media-type
|
|
24
|
+
* parameters; any path and search query (looked up in the state); any `list_folder` `limit` from
|
|
25
|
+
* 1 to 2000 and any `search_v2` `options.max_results` from 1 to 1000; and any upload body bytes.
|
|
26
|
+
* Everything else (other keys, booleans, modes, query parameters, another origin, ids or revs
|
|
27
|
+
* where the fixtures send paths, the root folder, and cursors not issued since the last reset or
|
|
28
|
+
* whose listing changed) is not emulated.
|
|
29
|
+
*
|
|
30
|
+
* Node-only: `@emulators/core` imports Node builtins, so the core is loaded lazily by
|
|
31
|
+
* `makeDropboxEmulator` (importing this module has no side effects).
|
|
32
|
+
*
|
|
33
|
+
* @experimental
|
|
34
|
+
*/
|
|
35
|
+
/**
|
|
36
|
+
* Route evidence manifest: every emulated route, whether it writes, and the conformance cases
|
|
37
|
+
* whose (currently synthetic, unverified) wire claims it follows. Kept in sync with the handlers
|
|
38
|
+
* by construction (both come from one route table).
|
|
39
|
+
*/
|
|
40
|
+
const dropboxEmulatorRoutes = dropboxApiRoutes.map(routeEvidence);
|
|
41
|
+
/**
|
|
42
|
+
* Optional fault filter; an omitted field matches every request. `method` is the HTTP method;
|
|
43
|
+
* `path` is the raw request path (ending in `*`, a prefix); `route` is a route template of the
|
|
44
|
+
* manifest (another value is rejected when the fault is added).
|
|
45
|
+
*/
|
|
46
|
+
const DropboxFaultMatch = StatefulFaultMatch;
|
|
47
|
+
/**
|
|
48
|
+
* A status fault (400-599): answer matching requests with this status, headers, and body instead
|
|
49
|
+
* of the route's write, so nothing is written. The body defaults to
|
|
50
|
+
* `{ error: { type: 'emulator_fault', message } }`; `count` limits how many requests it answers.
|
|
51
|
+
* Only a request the emulator would answer reaches a fault: a request that is not emulated, by
|
|
52
|
+
* its shape or by the state, never uses one up.
|
|
53
|
+
*/
|
|
54
|
+
const DropboxFault = StatefulFault;
|
|
55
|
+
/** Invalid emulator input from the JS API: a seed, a fault, or an option. A programmer error. */
|
|
56
|
+
var DropboxEmulatorInputInvalid = class extends Data.TaggedError("DropboxEmulatorInputInvalid") {
|
|
57
|
+
get message() {
|
|
58
|
+
return `Invalid Dropbox emulator ${this.input}: ${this.reason}`;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
const inputInvalid = (input, reason) => new DropboxEmulatorInputInvalid({
|
|
62
|
+
input,
|
|
63
|
+
reason
|
|
64
|
+
});
|
|
65
|
+
/**
|
|
66
|
+
* Create a stateful Dropbox emulator on the `@emulators/core` custom runtime. Each call has its
|
|
67
|
+
* own state, ledger, faults, and cursors. Rejects with `DropboxEmulatorInputInvalid` for an
|
|
68
|
+
* invalid seed or option. See `src/stateful-emulator.ts` for the request precedence.
|
|
69
|
+
*/
|
|
70
|
+
const makeDropboxEmulator = async (options = {}) => {
|
|
71
|
+
const initial = buildSeedState(options.seed ?? {});
|
|
72
|
+
if (Predicate.isString(initial)) throw inputInvalid("seed", initial);
|
|
73
|
+
checkBooleanDrills(options.drills, dropboxEmulatorDrillKnobs, inputInvalid);
|
|
74
|
+
const drills = options.drills ?? {};
|
|
75
|
+
const env = {
|
|
76
|
+
now: options.now ?? (() => Date.now()),
|
|
77
|
+
drills: {
|
|
78
|
+
listFolderSinglePage: drills.listFolderSinglePage === true,
|
|
79
|
+
getMetadataCaseSensitive: drills.getMetadataCaseSensitive === true,
|
|
80
|
+
searchRepeatsMatches: drills.searchRepeatsMatches === true,
|
|
81
|
+
notFoundAsPathLookup: drills.notFoundAsPathLookup === true,
|
|
82
|
+
folderConflictAsFile: drills.folderConflictAsFile === true,
|
|
83
|
+
deleteLeavesNoTombstone: drills.deleteLeavesNoTombstone === true,
|
|
84
|
+
moveMintsNewId: drills.moveMintsNewId === true,
|
|
85
|
+
uploadIgnoresRev: drills.uploadIgnoresRev === true
|
|
86
|
+
},
|
|
87
|
+
cursors: /* @__PURE__ */ new Map(),
|
|
88
|
+
cursorCounters: {
|
|
89
|
+
list: 1,
|
|
90
|
+
search: 1
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
const cursors = () => [...env.cursors].map(([cursor, state]) => ({
|
|
94
|
+
cursor,
|
|
95
|
+
kind: state.kind,
|
|
96
|
+
offset: state.offset
|
|
97
|
+
}));
|
|
98
|
+
return {
|
|
99
|
+
...await makeStatefulEmulator({
|
|
100
|
+
routes: dropboxApiRoutes,
|
|
101
|
+
env,
|
|
102
|
+
initial,
|
|
103
|
+
buildSeed: buildSeedState,
|
|
104
|
+
recordHeaders: [{
|
|
105
|
+
name: "dropbox-api-arg",
|
|
106
|
+
json: true
|
|
107
|
+
}],
|
|
108
|
+
clearRuntime: () => env.cursors.clear(),
|
|
109
|
+
runtimeState: () => ({ cursors: cursors() }),
|
|
110
|
+
seedSummary: (state) => ({ entries: state.entries.length }),
|
|
111
|
+
inputInvalid
|
|
112
|
+
}, statefulCoreRuntime({
|
|
113
|
+
name: "dropbox",
|
|
114
|
+
initial,
|
|
115
|
+
decodeState,
|
|
116
|
+
inputInvalid
|
|
117
|
+
})),
|
|
118
|
+
cursors
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
//#endregion
|
|
122
|
+
export { DropboxEmulatorDeleted, DropboxEmulatorEntry, DropboxEmulatorEntrySeed, DropboxEmulatorFile, DropboxEmulatorInputInvalid, DropboxEmulatorProfile, DropboxEmulatorSeed, DropboxEmulatorStateSchema, DropboxFault, DropboxFaultMatch, dropboxEmulatorApiOrigin, dropboxEmulatorBasePath, dropboxEmulatorContentOrigin, dropboxEmulatorErrorBodies, dropboxEmulatorRoutes, emulatorEvidenceHeader, makeDropboxEmulator };
|
|
123
|
+
|
|
124
|
+
//# sourceMappingURL=dropbox.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dropbox.mjs","names":[],"sources":["../src/dropbox.ts"],"sourcesContent":["/**\n * Stateful Dropbox emulator (the `/2` RPC routes on `https://api.dropboxapi.com` and the upload\n * route on `https://content.dropboxapi.com`), built on the upstream `@emulators/core` custom\n * runtime, with a request ledger, status faults, and an `/_emulate/*` control plane.\n *\n * It never imports SDK code: its wire shapes, error envelopes, and default seed are copied as data\n * from the synthetic Dropbox conformance fixtures, and every route names the conformance cases it\n * follows in `dropboxEmulatorRoutes`. Only the routes those eight cases (with their cleanup) send\n * are emulated, each on the origin its fixtures record. Response behaviour comes only from the\n * fixtures: anything they do not show answers one ledgered 400 not-emulated, writes nothing, and\n * uses up no fault. That includes a listing of an empty folder, so the read-only leftover lookup\n * fails against the default seed's empty work folder (the live runner prints its lookup-failed\n * WARN).\n *\n * Request-shape latitude (`/dropbox`, the only accepted deviations): any bearer value (never\n * checked or stored); extra request headers; JSON key order; `content-type` media-type\n * parameters; any path and search query (looked up in the state); any `list_folder` `limit` from\n * 1 to 2000 and any `search_v2` `options.max_results` from 1 to 1000; and any upload body bytes.\n * Everything else (other keys, booleans, modes, query parameters, another origin, ids or revs\n * where the fixtures send paths, the root folder, and cursors not issued since the last reset or\n * whose listing changed) is not emulated.\n *\n * Node-only: `@emulators/core` imports Node builtins, so the core is loaded lazily by\n * `makeDropboxEmulator` (importing this module has no side effects).\n *\n * @experimental\n */\nimport { Data, Predicate } from 'effect'\nimport {\n dropboxApiRoutes,\n dropboxEmulatorDrillKnobs,\n type DropboxApiEnv,\n type DropboxCursor,\n type DropboxEmulatorDrills\n} from './dropbox/api.ts'\nimport {\n buildSeedState,\n decodeState,\n type DropboxEmulatorSeed,\n type DropboxEmulatorState\n} from './dropbox/state.ts'\nimport type { EmulatorRouteEvidence } from './route-evidence.ts'\nimport {\n StatefulFault,\n StatefulFaultMatch,\n checkBooleanDrills,\n makeStatefulEmulator,\n routeEvidence,\n type StatefulCoverage,\n type StatefulEmulatorApi,\n type StatefulFaultState,\n type StatefulInputKind,\n type StatefulLedgerEntry\n} from './stateful-emulator.ts'\nimport { statefulCoreRuntime } from './stateful-core.ts'\n\nexport type { EmulatorEvidence, EmulatorRouteEvidence } from './route-evidence.ts'\n\nexport { emulatorEvidenceHeader } from './route-evidence.ts'\n\nexport {\n dropboxEmulatorApiOrigin,\n dropboxEmulatorBasePath,\n dropboxEmulatorContentOrigin,\n dropboxEmulatorErrorBodies,\n type DropboxEmulatorDrills\n} from './dropbox/api.ts'\n\nexport {\n DropboxEmulatorDeleted,\n DropboxEmulatorEntry,\n DropboxEmulatorEntrySeed,\n DropboxEmulatorFile,\n DropboxEmulatorProfile,\n DropboxEmulatorSeed,\n DropboxEmulatorStateSchema,\n type DropboxEmulatorState\n} from './dropbox/state.ts'\n\n/**\n * Route evidence manifest: every emulated route, whether it writes, and the conformance cases\n * whose (currently synthetic, unverified) wire claims it follows. Kept in sync with the handlers\n * by construction (both come from one route table).\n */\nexport const dropboxEmulatorRoutes: ReadonlyArray<EmulatorRouteEvidence> =\n dropboxApiRoutes.map(routeEvidence)\n\n/**\n * Optional fault filter; an omitted field matches every request. `method` is the HTTP method;\n * `path` is the raw request path (ending in `*`, a prefix); `route` is a route template of the\n * manifest (another value is rejected when the fault is added).\n */\nexport const DropboxFaultMatch = StatefulFaultMatch\n\nexport type DropboxFaultMatch = typeof StatefulFaultMatch.Type\n\n/**\n * A status fault (400-599): answer matching requests with this status, headers, and body instead\n * of the route's write, so nothing is written. The body defaults to\n * `{ error: { type: 'emulator_fault', message } }`; `count` limits how many requests it answers.\n * Only a request the emulator would answer reaches a fault: a request that is not emulated, by\n * its shape or by the state, never uses one up.\n */\nexport const DropboxFault = StatefulFault\n\nexport type DropboxFault = StatefulFault\n\nexport type DropboxFaultState = StatefulFaultState\n\nexport type DropboxLedgerEntry = StatefulLedgerEntry\n\nexport type DropboxCoverage = StatefulCoverage\n\n/** Invalid emulator input from the JS API: a seed, a fault, or an option. A programmer error. */\nexport class DropboxEmulatorInputInvalid extends Data.TaggedError('DropboxEmulatorInputInvalid')<{\n readonly input: StatefulInputKind\n readonly reason: string\n}> {\n override get message(): string {\n return `Invalid Dropbox emulator ${this.input}: ${this.reason}`\n }\n}\n\n/** A cursor as reported by `cursors()` and `/_emulate/state`. */\nexport type DropboxCursorState = {\n readonly cursor: string\n readonly kind: DropboxCursor['kind']\n /** Position of the next page in the listing or search. */\n readonly offset: number\n}\n\nexport type DropboxEmulatorOptions = {\n /** Typed seed; defaults to the fixture entries (`profile: 'default'`). */\n readonly seed?: DropboxEmulatorSeed\n /** Clock in epoch milliseconds (upload timestamps). Defaults to `Date.now`. */\n readonly now?: () => number\n /** Drill knobs (tests only): make the emulator disagree with one conformance claim. */\n readonly drills?: DropboxEmulatorDrills\n}\n\nexport type DropboxEmulator = StatefulEmulatorApi<DropboxEmulatorState, DropboxEmulatorSeed> & {\n /** The list and search cursors issued since the last reset or seed (runtime data). */\n readonly cursors: () => ReadonlyArray<DropboxCursorState>\n}\n\nconst inputInvalid = (input: StatefulInputKind, reason: string) =>\n new DropboxEmulatorInputInvalid({ input, reason })\n\n/**\n * Create a stateful Dropbox emulator on the `@emulators/core` custom runtime. Each call has its\n * own state, ledger, faults, and cursors. Rejects with `DropboxEmulatorInputInvalid` for an\n * invalid seed or option. See `src/stateful-emulator.ts` for the request precedence.\n */\nexport const makeDropboxEmulator = async (\n options: DropboxEmulatorOptions = {}\n): Promise<DropboxEmulator> => {\n const initial = buildSeedState(options.seed ?? {})\n\n if (Predicate.isString(initial)) {\n throw inputInvalid('seed', initial)\n }\n\n checkBooleanDrills(options.drills, dropboxEmulatorDrillKnobs, inputInvalid)\n\n const drills = options.drills ?? {}\n\n const env: DropboxApiEnv = {\n now: options.now ?? (() => Date.now()),\n drills: {\n listFolderSinglePage: drills.listFolderSinglePage === true,\n getMetadataCaseSensitive: drills.getMetadataCaseSensitive === true,\n searchRepeatsMatches: drills.searchRepeatsMatches === true,\n notFoundAsPathLookup: drills.notFoundAsPathLookup === true,\n folderConflictAsFile: drills.folderConflictAsFile === true,\n deleteLeavesNoTombstone: drills.deleteLeavesNoTombstone === true,\n moveMintsNewId: drills.moveMintsNewId === true,\n uploadIgnoresRev: drills.uploadIgnoresRev === true\n },\n cursors: new Map(),\n cursorCounters: { list: 1, search: 1 }\n }\n\n const cursors = (): ReadonlyArray<DropboxCursorState> =>\n [...env.cursors].map(([cursor, state]) => ({ cursor, kind: state.kind, offset: state.offset }))\n\n const api = await makeStatefulEmulator<DropboxEmulatorState, DropboxApiEnv, DropboxEmulatorSeed>(\n {\n routes: dropboxApiRoutes,\n env,\n initial,\n buildSeed: buildSeedState,\n recordHeaders: [{ name: 'dropbox-api-arg', json: true }],\n // Cursor numbers keep advancing, so a cursor issued before a reset is never issued again.\n clearRuntime: () => env.cursors.clear(),\n runtimeState: () => ({ cursors: cursors() }),\n seedSummary: state => ({ entries: state.entries.length }),\n inputInvalid\n },\n statefulCoreRuntime({ name: 'dropbox', initial, decodeState, inputInvalid })\n )\n\n return { ...api, cursors }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoFA,MAAa,wBACX,iBAAiB,IAAI,aAAa;;;;;;AAOpC,MAAa,oBAAoB;;;;;;;;AAWjC,MAAa,eAAe;;AAW5B,IAAa,8BAAb,cAAiD,KAAK,YAAY,6BAA6B,EAG5F;CACD,IAAa,UAAkB;EAC7B,OAAO,4BAA4B,KAAK,MAAM,IAAI,KAAK;CACzD;AACF;AAwBA,MAAM,gBAAgB,OAA0B,WAC9C,IAAI,4BAA4B;CAAE;CAAO;AAAO,CAAC;;;;;;AAOnD,MAAa,sBAAsB,OACjC,UAAkC,CAAC,MACN;CAC7B,MAAM,UAAU,eAAe,QAAQ,QAAQ,CAAC,CAAC;CAEjD,IAAI,UAAU,SAAS,OAAO,GAC5B,MAAM,aAAa,QAAQ,OAAO;CAGpC,mBAAmB,QAAQ,QAAQ,2BAA2B,YAAY;CAE1E,MAAM,SAAS,QAAQ,UAAU,CAAC;CAElC,MAAM,MAAqB;EACzB,KAAK,QAAQ,cAAc,KAAK,IAAI;EACpC,QAAQ;GACN,sBAAsB,OAAO,yBAAyB;GACtD,0BAA0B,OAAO,6BAA6B;GAC9D,sBAAsB,OAAO,yBAAyB;GACtD,sBAAsB,OAAO,yBAAyB;GACtD,sBAAsB,OAAO,yBAAyB;GACtD,yBAAyB,OAAO,4BAA4B;GAC5D,gBAAgB,OAAO,mBAAmB;GAC1C,kBAAkB,OAAO,qBAAqB;EAChD;EACA,yBAAS,IAAI,IAAI;EACjB,gBAAgB;GAAE,MAAM;GAAG,QAAQ;EAAE;CACvC;CAEA,MAAM,gBACJ,CAAC,GAAG,IAAI,OAAO,EAAE,KAAK,CAAC,QAAQ,YAAY;EAAE;EAAQ,MAAM,MAAM;EAAM,QAAQ,MAAM;CAAO,EAAE;CAkBhG,OAAO;EAAE,GAAG,MAhBM,qBAChB;GACE,QAAQ;GACR;GACA;GACA,WAAW;GACX,eAAe,CAAC;IAAE,MAAM;IAAmB,MAAM;GAAK,CAAC;GAEvD,oBAAoB,IAAI,QAAQ,MAAM;GACtC,qBAAqB,EAAE,SAAS,QAAQ,EAAE;GAC1C,cAAa,WAAU,EAAE,SAAS,MAAM,QAAQ,OAAO;GACvD;EACF,GACA,oBAAoB;GAAE,MAAM;GAAW;GAAS;GAAa;EAAa,CAAC,CAC7E;EAEiB;CAAQ;AAC3B"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import * as Schema from "effect/Schema";
|
|
2
|
+
|
|
3
|
+
//#region src/email-fixtures.d.ts
|
|
4
|
+
/** A port failure as a fixture records it (mirrors `PortFailure` in `@yolk-sdk/conformance`). */
|
|
5
|
+
type EmailEmulatorFailure = {
|
|
6
|
+
readonly kind: 'expected' | 'error';
|
|
7
|
+
readonly code: string;
|
|
8
|
+
readonly message: string;
|
|
9
|
+
readonly status?: number;
|
|
10
|
+
};
|
|
11
|
+
type EmailEmulatorFixtureFields = {
|
|
12
|
+
readonly id: string;
|
|
13
|
+
readonly port: string;
|
|
14
|
+
readonly method: string;
|
|
15
|
+
readonly request: Schema.Json;
|
|
16
|
+
readonly observed?: {
|
|
17
|
+
readonly account: string;
|
|
18
|
+
readonly date: string;
|
|
19
|
+
};
|
|
20
|
+
readonly note?: string;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* One recorded `EmailClient` call (the plain-JSON shape of a `PortFixture`): exactly one of
|
|
24
|
+
* `response` or `failure`.
|
|
25
|
+
*/
|
|
26
|
+
type EmailEmulatorFixture = (EmailEmulatorFixtureFields & {
|
|
27
|
+
readonly response: Schema.Json;
|
|
28
|
+
readonly failure?: never;
|
|
29
|
+
}) | (EmailEmulatorFixtureFields & {
|
|
30
|
+
readonly failure: EmailEmulatorFailure;
|
|
31
|
+
readonly response?: never;
|
|
32
|
+
});
|
|
33
|
+
declare const emailEmulatorFixtures: ReadonlyArray<EmailEmulatorFixture>;
|
|
34
|
+
//#endregion
|
|
35
|
+
export { EmailEmulatorFailure, EmailEmulatorFixture, emailEmulatorFixtures };
|
|
36
|
+
//# sourceMappingURL=email-fixtures.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"email-fixtures.d.mts","names":[],"sources":["../src/email-fixtures.ts"],"mappings":";;;;KAUY,oBAAA;EAAA,SACD,IAAA;EAAA,SACA,IAAA;EAAA,SACA,OAAA;EAAA,SACA,MAAA;AAAA;AAAA,KAGN,0BAAA;EAAA,SACM,EAAA;EAAA,SACA,IAAA;EAAA,SACA,MAAA;EAAA,SACA,OAAA,EAAS,MAAA,CAAO,IAAI;EAAA,SACpB,QAAA;IAAA,SAAsB,OAAA;IAAA,SAA0B,IAAA;EAAA;EAAA,SAChD,IAAA;AAAA;;;AAAI;AAOf;KAAY,oBAAA,IACP,0BAAA;EAAA,SAAwC,QAAA,EAAU,MAAA,CAAO,IAAA;EAAA,SAAe,OAAA;AAAA,MACxE,0BAAA;EAAA,SACU,OAAA,EAAS,oBAAA;EAAA,SACT,QAAA;AAAA;AAAA,cAGF,qBAAA,EAAuB,aAAa,CAAC,oBAAA"}
|