jmap-kit 0.0.0 → 1.0.2
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 +138 -3
- package/dist/src/capabilities/blob/blob.d.ts +83 -0
- package/dist/src/capabilities/blob/blob.js +98 -0
- package/dist/src/capabilities/blob/blob.js.map +1 -0
- package/dist/src/capabilities/blob/types.d.ts +212 -0
- package/dist/src/capabilities/blob/types.js +16 -0
- package/dist/src/capabilities/blob/types.js.map +1 -0
- package/dist/src/capabilities/blob-capability.d.ts +195 -0
- package/dist/src/capabilities/blob-capability.js +277 -0
- package/dist/src/capabilities/blob-capability.js.map +1 -0
- package/dist/src/capabilities/core/core.d.ts +47 -0
- package/dist/src/capabilities/core/core.js +59 -0
- package/dist/src/capabilities/core/core.js.map +1 -0
- package/dist/src/capabilities/core/types.d.ts +13 -0
- package/dist/src/capabilities/core/types.js +2 -0
- package/dist/src/capabilities/core/types.js.map +1 -0
- package/dist/src/capabilities/core-capability.d.ts +307 -0
- package/dist/src/capabilities/core-capability.js +344 -0
- package/dist/src/capabilities/core-capability.js.map +1 -0
- package/dist/src/capabilities/email/email.d.ts +124 -0
- package/dist/src/capabilities/email/email.js +136 -0
- package/dist/src/capabilities/email/email.js.map +1 -0
- package/dist/src/capabilities/email/types.d.ts +776 -0
- package/dist/src/capabilities/email/types.js +2 -0
- package/dist/src/capabilities/email/types.js.map +1 -0
- package/dist/src/capabilities/email-capability.d.ts +266 -0
- package/dist/src/capabilities/email-capability.js +241 -0
- package/dist/src/capabilities/email-capability.js.map +1 -0
- package/dist/src/capabilities/emailsubmission/emailsubmission.d.ts +95 -0
- package/dist/src/capabilities/emailsubmission/emailsubmission.js +107 -0
- package/dist/src/capabilities/emailsubmission/emailsubmission.js.map +1 -0
- package/dist/src/capabilities/emailsubmission/types.d.ts +256 -0
- package/dist/src/capabilities/emailsubmission/types.js +2 -0
- package/dist/src/capabilities/emailsubmission/types.js.map +1 -0
- package/dist/src/capabilities/example/example.d.ts +80 -0
- package/dist/src/capabilities/example/example.js +91 -0
- package/dist/src/capabilities/example/example.js.map +1 -0
- package/dist/src/capabilities/example/types.d.ts +33 -0
- package/dist/src/capabilities/example/types.js +2 -0
- package/dist/src/capabilities/example/types.js.map +1 -0
- package/dist/src/capabilities/identity/identity.d.ts +71 -0
- package/dist/src/capabilities/identity/identity.js +83 -0
- package/dist/src/capabilities/identity/identity.js.map +1 -0
- package/dist/src/capabilities/identity/types.d.ts +110 -0
- package/dist/src/capabilities/identity/types.js +2 -0
- package/dist/src/capabilities/identity/types.js.map +1 -0
- package/dist/src/capabilities/mailbox/mailbox.d.ts +91 -0
- package/dist/src/capabilities/mailbox/mailbox.js +103 -0
- package/dist/src/capabilities/mailbox/mailbox.js.map +1 -0
- package/dist/src/capabilities/mailbox/types.d.ts +248 -0
- package/dist/src/capabilities/mailbox/types.js +2 -0
- package/dist/src/capabilities/mailbox/types.js.map +1 -0
- package/dist/src/capabilities/maskedemail/maskedemail.d.ts +60 -0
- package/dist/src/capabilities/maskedemail/maskedemail.js +72 -0
- package/dist/src/capabilities/maskedemail/maskedemail.js.map +1 -0
- package/dist/src/capabilities/maskedemail/types.d.ts +67 -0
- package/dist/src/capabilities/maskedemail/types.js +4 -0
- package/dist/src/capabilities/maskedemail/types.js.map +1 -0
- package/dist/src/capabilities/maskedemail-capability.d.ts +112 -0
- package/dist/src/capabilities/maskedemail-capability.js +166 -0
- package/dist/src/capabilities/maskedemail-capability.js.map +1 -0
- package/dist/src/capabilities/searchsnippet/searchsnippet.d.ts +51 -0
- package/dist/src/capabilities/searchsnippet/searchsnippet.js +63 -0
- package/dist/src/capabilities/searchsnippet/searchsnippet.js.map +1 -0
- package/dist/src/capabilities/searchsnippet/types.d.ts +88 -0
- package/dist/src/capabilities/searchsnippet/types.js +2 -0
- package/dist/src/capabilities/searchsnippet/types.js.map +1 -0
- package/dist/src/capabilities/submission-capability.d.ts +89 -0
- package/dist/src/capabilities/submission-capability.js +75 -0
- package/dist/src/capabilities/submission-capability.js.map +1 -0
- package/dist/src/capabilities/thread/thread.d.ts +58 -0
- package/dist/src/capabilities/thread/thread.js +70 -0
- package/dist/src/capabilities/thread/thread.js.map +1 -0
- package/dist/src/capabilities/thread/types.d.ts +43 -0
- package/dist/src/capabilities/thread/types.js +2 -0
- package/dist/src/capabilities/thread/types.js.map +1 -0
- package/dist/src/capabilities/utils/assert-invocation-datatype.d.ts +7 -0
- package/dist/src/capabilities/utils/assert-invocation-datatype.js +13 -0
- package/dist/src/capabilities/utils/assert-invocation-datatype.js.map +1 -0
- package/dist/src/capabilities/utils/assert-invocation-method.d.ts +7 -0
- package/dist/src/capabilities/utils/assert-invocation-method.js +13 -0
- package/dist/src/capabilities/utils/assert-invocation-method.js.map +1 -0
- package/dist/src/capabilities/utils/assert-invocation.d.ts +7 -0
- package/dist/src/capabilities/utils/assert-invocation.js +22 -0
- package/dist/src/capabilities/utils/assert-invocation.js.map +1 -0
- package/dist/src/capabilities/utils/assert-non-nullish.d.ts +1 -0
- package/dist/src/capabilities/utils/assert-non-nullish.js +6 -0
- package/dist/src/capabilities/utils/assert-non-nullish.js.map +1 -0
- package/dist/src/capabilities/utils/create-readonly-account-validator.d.ts +49 -0
- package/dist/src/capabilities/utils/create-readonly-account-validator.js +80 -0
- package/dist/src/capabilities/utils/create-readonly-account-validator.js.map +1 -0
- package/dist/src/capabilities/vacationresponse/types.d.ts +100 -0
- package/dist/src/capabilities/vacationresponse/types.js +2 -0
- package/dist/src/capabilities/vacationresponse/types.js.map +1 -0
- package/dist/src/capabilities/vacationresponse/vacationresponse.d.ts +61 -0
- package/dist/src/capabilities/vacationresponse/vacationresponse.js +73 -0
- package/dist/src/capabilities/vacationresponse/vacationresponse.js.map +1 -0
- package/dist/src/capabilities/vacationresponse-capability.d.ts +65 -0
- package/dist/src/capabilities/vacationresponse-capability.js +68 -0
- package/dist/src/capabilities/vacationresponse-capability.js.map +1 -0
- package/dist/src/capability-registry/capability-registry.d.ts +148 -0
- package/dist/src/capability-registry/capability-registry.js +360 -0
- package/dist/src/capability-registry/capability-registry.js.map +1 -0
- package/dist/src/capability-registry/types.d.ts +385 -0
- package/dist/src/capability-registry/types.js +2 -0
- package/dist/src/capability-registry/types.js.map +1 -0
- package/dist/src/capability-registry/utils.d.ts +71 -0
- package/dist/src/capability-registry/utils.js +163 -0
- package/dist/src/capability-registry/utils.js.map +1 -0
- package/dist/src/common/registry.d.ts +366 -0
- package/dist/src/common/registry.js +321 -0
- package/dist/src/common/registry.js.map +1 -0
- package/dist/src/common/types.d.ts +338 -0
- package/dist/src/common/types.js +21 -0
- package/dist/src/common/types.js.map +1 -0
- package/dist/src/common/utils.d.ts +20 -0
- package/dist/src/common/utils.js +26 -0
- package/dist/src/common/utils.js.map +1 -0
- package/dist/src/index.d.ts +40 -0
- package/dist/src/index.js +33 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/invocation/arguments-proxy.d.ts +14 -0
- package/dist/src/invocation/arguments-proxy.js +37 -0
- package/dist/src/invocation/arguments-proxy.js.map +1 -0
- package/dist/src/invocation/error-invocation.d.ts +27 -0
- package/dist/src/invocation/error-invocation.js +39 -0
- package/dist/src/invocation/error-invocation.js.map +1 -0
- package/dist/src/invocation/invocation.d.ts +111 -0
- package/dist/src/invocation/invocation.js +158 -0
- package/dist/src/invocation/invocation.js.map +1 -0
- package/dist/src/invocation/result-reference.d.ts +86 -0
- package/dist/src/invocation/result-reference.js +118 -0
- package/dist/src/invocation/result-reference.js.map +1 -0
- package/dist/src/invocation/types.d.ts +637 -0
- package/dist/src/invocation/types.js +2 -0
- package/dist/src/invocation/types.js.map +1 -0
- package/dist/src/invocation/utils.d.ts +21 -0
- package/dist/src/invocation/utils.js +30 -0
- package/dist/src/invocation/utils.js.map +1 -0
- package/dist/src/invocation-factory/invocation-factory-manager.d.ts +20 -0
- package/dist/src/invocation-factory/invocation-factory-manager.js +50 -0
- package/dist/src/invocation-factory/invocation-factory-manager.js.map +1 -0
- package/dist/src/invocation-factory/invocation-list.d.ts +32 -0
- package/dist/src/invocation-factory/invocation-list.js +77 -0
- package/dist/src/invocation-factory/invocation-list.js.map +1 -0
- package/dist/src/invocation-factory/types.d.ts +11 -0
- package/dist/src/invocation-factory/types.js +2 -0
- package/dist/src/invocation-factory/types.js.map +1 -0
- package/dist/src/jmap-client/jmap-client.d.ts +252 -0
- package/dist/src/jmap-client/jmap-client.js +777 -0
- package/dist/src/jmap-client/jmap-client.js.map +1 -0
- package/dist/src/jmap-client/types.d.ts +427 -0
- package/dist/src/jmap-client/types.js +21 -0
- package/dist/src/jmap-client/types.js.map +1 -0
- package/dist/src/jmap-client/utils/abort-controller.d.ts +8 -0
- package/dist/src/jmap-client/utils/abort-controller.js +24 -0
- package/dist/src/jmap-client/utils/abort-controller.js.map +1 -0
- package/dist/src/jmap-client/utils/assert-connected.d.ts +7 -0
- package/dist/src/jmap-client/utils/assert-connected.js +11 -0
- package/dist/src/jmap-client/utils/assert-connected.js.map +1 -0
- package/dist/src/jmap-client/utils/deep-freeze.d.ts +7 -0
- package/dist/src/jmap-client/utils/deep-freeze.js +17 -0
- package/dist/src/jmap-client/utils/deep-freeze.js.map +1 -0
- package/dist/src/jmap-client/utils/emitter.d.ts +9 -0
- package/dist/src/jmap-client/utils/emitter.js +18 -0
- package/dist/src/jmap-client/utils/emitter.js.map +1 -0
- package/dist/src/jmap-client/utils/filter-session-capabilities.d.ts +22 -0
- package/dist/src/jmap-client/utils/filter-session-capabilities.js +40 -0
- package/dist/src/jmap-client/utils/filter-session-capabilities.js.map +1 -0
- package/dist/src/jmap-client/utils/jmap-request-error.d.ts +28 -0
- package/dist/src/jmap-client/utils/jmap-request-error.js +48 -0
- package/dist/src/jmap-client/utils/jmap-request-error.js.map +1 -0
- package/dist/src/jmap-client/utils/logger.d.ts +6 -0
- package/dist/src/jmap-client/utils/logger.js +22 -0
- package/dist/src/jmap-client/utils/logger.js.map +1 -0
- package/dist/src/jmap-client/utils/merge-headers.d.ts +11 -0
- package/dist/src/jmap-client/utils/merge-headers.js +40 -0
- package/dist/src/jmap-client/utils/merge-headers.js.map +1 -0
- package/dist/src/jmap-client/utils/template-utils.d.ts +27 -0
- package/dist/src/jmap-client/utils/template-utils.js +61 -0
- package/dist/src/jmap-client/utils/template-utils.js.map +1 -0
- package/dist/src/jmap-client/utils/track-utils.d.ts +19 -0
- package/dist/src/jmap-client/utils/track-utils.js +35 -0
- package/dist/src/jmap-client/utils/track-utils.js.map +1 -0
- package/dist/src/jmap-client/utils/transport.d.ts +12 -0
- package/dist/src/jmap-client/utils/transport.js +38 -0
- package/dist/src/jmap-client/utils/transport.js.map +1 -0
- package/dist/src/jmap-client/utils/validate-session.d.ts +19 -0
- package/dist/src/jmap-client/utils/validate-session.js +29 -0
- package/dist/src/jmap-client/utils/validate-session.js.map +1 -0
- package/dist/src/request-builder/request-builder.d.ts +95 -0
- package/dist/src/request-builder/request-builder.js +343 -0
- package/dist/src/request-builder/request-builder.js.map +1 -0
- package/dist/src/request-builder/types.d.ts +32 -0
- package/dist/src/request-builder/types.js +2 -0
- package/dist/src/request-builder/types.js.map +1 -0
- package/package.json +69 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Lachlan Hunt
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,7 +1,142 @@
|
|
|
1
1
|
# jmap-kit
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://github.com/lachlanhunt/jmap-kit)
|
|
4
|
+
[](https://www.npmjs.com/package/jmap-kit)
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
A typed TypeScript library for building [JMAP](https://jmap.io/) clients. It handles session discovery, request building with type-safe invocation factories, response dispatching, file operations, and a plugin system for validation and transformation — so you can focus on your application instead of the protocol.
|
|
6
7
|
|
|
7
|
-
See the [
|
|
8
|
+
See the complete [jmap-kit Documentation](https://lachlanhunt.github.io/jmap-kit/).
|
|
9
|
+
|
|
10
|
+
## Using jmap-kit
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
- **Session management**: automatic discovery via `.well-known/jmap`, session state tracking, staleness detection
|
|
15
|
+
- **Type-safe invocations**: factory functions for every JMAP method, with compile-time enforcement of argument types and property names
|
|
16
|
+
- **Result references**: chain dependent method calls within a single request without extra round trips
|
|
17
|
+
- **Request building**: combine multiple method calls into one request with automatic capability URI inclusion and ID management
|
|
18
|
+
- **Response dispatching**: route responses to handlers by method name, data type, or invocation ID
|
|
19
|
+
- **File operations**: upload and download with server limit enforcement and automatic concurrency control
|
|
20
|
+
- **Plugin system**: validation and transformation hooks at each stage of request processing
|
|
21
|
+
- **Server limit enforcement**: built-in validators for `maxObjectsInGet`, `maxObjectsInSet`, `maxCallsInRequest`, `maxSizeRequest`, and read-only accounts
|
|
22
|
+
- **Extensible**: define custom capabilities with their own types, invocations, validators, and transformers
|
|
23
|
+
|
|
24
|
+
### Installation
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npm install jmap-kit
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
yarn add jmap-kit
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
pnpm add jmap-kit
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Quick Example
|
|
39
|
+
|
|
40
|
+
```typescript
|
|
41
|
+
import { JMAPClient, EmailCapability, Mailbox } from "jmap-kit";
|
|
42
|
+
|
|
43
|
+
const transport = /* your HTTP transport (see Developer Guide) */;
|
|
44
|
+
const client = new JMAPClient(transport, { hostname: "api.example.com" });
|
|
45
|
+
client.registerCapabilities(EmailCapability);
|
|
46
|
+
|
|
47
|
+
await client.connect();
|
|
48
|
+
|
|
49
|
+
const accountId = client.primaryAccounts["urn:ietf:params:jmap:mail"];
|
|
50
|
+
|
|
51
|
+
// Query for the Inbox, then fetch it — in a single request
|
|
52
|
+
const query = Mailbox.request.query({
|
|
53
|
+
accountId,
|
|
54
|
+
filter: { role: "inbox" },
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
const get = Mailbox.request.get({
|
|
58
|
+
accountId,
|
|
59
|
+
ids: query.createReference("/ids"),
|
|
60
|
+
properties: ["id", "name", "role", "totalEmails", "unreadEmails"],
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const request = client.createRequestBuilder().add(query).add(get);
|
|
64
|
+
const response = await request.send();
|
|
65
|
+
|
|
66
|
+
await response.methodResponses.dispatch({
|
|
67
|
+
"Mailbox/get": (invocation) => {
|
|
68
|
+
const mailboxes = invocation.getArgument("list");
|
|
69
|
+
console.log("Inbox:", mailboxes);
|
|
70
|
+
},
|
|
71
|
+
error: (invocation) => {
|
|
72
|
+
console.error("Error:", invocation.type);
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
await client.disconnect();
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Documentation
|
|
80
|
+
|
|
81
|
+
See the [Developer Guide](./guide/README.md) for comprehensive documentation covering session management, capabilities, invocations, request building, response handling, file operations, customisation, the plugin system, and creating custom capabilities.
|
|
82
|
+
|
|
83
|
+
## Development
|
|
84
|
+
|
|
85
|
+
### Setup
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
git clone <repository-url>
|
|
89
|
+
cd jmap-kit
|
|
90
|
+
yarn install
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Scripts
|
|
94
|
+
|
|
95
|
+
| Command | Description |
|
|
96
|
+
| ------------------- | ------------------------------------------------------------------- |
|
|
97
|
+
| `yarn test` | Run tests in interactive watch mode ([Vitest](https://vitest.dev/)) |
|
|
98
|
+
| `yarn test --run` | Run all tests once (CI) |
|
|
99
|
+
| `yarn format:check` | Check Prettier formatting |
|
|
100
|
+
| `yarn lint` | Run ESLint (`--fix` to auto-fix) |
|
|
101
|
+
| `yarn typecheck` | Type-check without emitting files |
|
|
102
|
+
| `yarn build` | Compile TypeScript |
|
|
103
|
+
| `yarn bundle` | Build bundles with Rollup (for analysis, not shipped) |
|
|
104
|
+
| `yarn size-check` | Bundle and print file sizes |
|
|
105
|
+
| `yarn docs` | Generate API docs with TypeDoc |
|
|
106
|
+
|
|
107
|
+
### Contributing
|
|
108
|
+
|
|
109
|
+
Contributions are welcome! See the [Contributing Guide](CONTRIBUTING.md) for development setup, conventions, and PR guidelines.
|
|
110
|
+
|
|
111
|
+
## Roadmap
|
|
112
|
+
|
|
113
|
+
jmap-kit currently implements the JMAP Core (RFC 8620), Mail (RFC 8621), and Blob Management (RFC 9404) specifications, plus the FastMail Masked Email extension. The following features are planned for future minor releases.
|
|
114
|
+
|
|
115
|
+
### Core specification features
|
|
116
|
+
|
|
117
|
+
- **PushSubscription** (RFC 8620 Section 7.2) — `PushSubscription/get` and `PushSubscription/set` methods for managing push notification subscriptions
|
|
118
|
+
- **EventSource** (RFC 8620 Section 7.3) — built-in client for server-sent events, including connection management and automatic reconnection (URL generation via `getEventSourceUrl()` is already available)
|
|
119
|
+
|
|
120
|
+
### Additional JMAP capabilities
|
|
121
|
+
|
|
122
|
+
Support for capabilities defined in other published and draft JMAP specifications is planned, including:
|
|
123
|
+
|
|
124
|
+
- **Quotas** — [RFC 9425](https://www.rfc-editor.org/rfc/rfc9425.html)
|
|
125
|
+
- **Contacts** — [RFC 9610](https://www.rfc-editor.org/rfc/rfc9610.html)
|
|
126
|
+
- **Sieve Scripts** — [RFC 9661](https://www.rfc-editor.org/rfc/rfc9661.html)
|
|
127
|
+
- **Principals and Sharing** — [RFC 9670](https://www.rfc-editor.org/rfc/rfc9670.html)
|
|
128
|
+
- **MDN (Message Disposition Notification)** — [RFC 9007](https://www.rfc-editor.org/rfc/rfc9007.html)
|
|
129
|
+
- **S/MIME Signature Verification** — [RFC 9219](https://www.rfc-editor.org/rfc/rfc9219.html)
|
|
130
|
+
- **WebPush VAPID** — [RFC 9749](https://www.rfc-editor.org/rfc/rfc9749.html)
|
|
131
|
+
- **Calendars** — [Draft IETF JMAP Calendars](https://datatracker.ietf.org/doc/html/draft-ietf-jmap-calendars)
|
|
132
|
+
- **Tasks** — [Draft IETF JMAP Tasks](https://datatracker.ietf.org/doc/html/draft-ietf-jmap-tasks)
|
|
133
|
+
|
|
134
|
+
Any of the above capabilities can be implemented as [custom capabilities](./guide/custom-capabilities.md) using the plugin system. Contributions are welcome!
|
|
135
|
+
|
|
136
|
+
### Other specifications
|
|
137
|
+
|
|
138
|
+
- **JMAP over WebSocket** — [RFC 8887](https://www.rfc-editor.org/rfc/rfc8887.html).
|
|
139
|
+
|
|
140
|
+
## License
|
|
141
|
+
|
|
142
|
+
[MIT License](LICENSE)
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { JMAPCapability, JMAPMethodName } from "../../common/types.js";
|
|
2
|
+
import { Invocation } from "../../invocation/invocation.js";
|
|
3
|
+
import type { InvocationArgs, InvocationFactory } from "../../invocation/types.js";
|
|
4
|
+
import type { BlobCopyRequestInvocationArgs, BlobCopyResponseInvocationArgs, BlobGetRequestInvocationArgs, BlobGetResponseInvocationArgs, BlobLookupRequestInvocationArgs, BlobLookupResponseInvocationArgs, BlobRequestInvocationArgs, BlobResponseInvocationArgs, BlobUploadRequestInvocationArgs, BlobUploadResponseInvocationArgs } from "./types.js";
|
|
5
|
+
/**
|
|
6
|
+
* BlobInvocation represents a JMAP Blob capability invocation.
|
|
7
|
+
*
|
|
8
|
+
* The Blob data type handles binary data management with methods for copying, uploading,
|
|
9
|
+
* retrieving, and looking up binary data across accounts. The Blob/copy method is part
|
|
10
|
+
* of the Core capability (RFC 8620), while upload/get/lookup are part of the Blob
|
|
11
|
+
* Management Extension (RFC 9404).
|
|
12
|
+
*
|
|
13
|
+
* @see {@link https://www.rfc-editor.org/rfc/rfc8620.html#section-6.3 | RFC 8620 Section 6.3: Blob/copy}
|
|
14
|
+
* @see {@link https://www.rfc-editor.org/rfc/rfc9404.html#section-4 | RFC 9404 Section 4: Blob Methods}
|
|
15
|
+
*/
|
|
16
|
+
export declare class BlobInvocation<TArgs extends BlobRequestInvocationArgs | BlobResponseInvocationArgs> extends Invocation<TArgs> {
|
|
17
|
+
get uri(): JMAPCapability;
|
|
18
|
+
/**
|
|
19
|
+
* Constructs a BlobInvocation
|
|
20
|
+
*
|
|
21
|
+
* @param method The name of the method being invoked (e.g., "copy", "upload", "get", "lookup")
|
|
22
|
+
* @param args The arguments for the method invocation
|
|
23
|
+
* @param methodCallId An optional unique symbol to identify this method call for result referencing
|
|
24
|
+
*/
|
|
25
|
+
constructor(method: JMAPMethodName, args: InvocationArgs<TArgs>, methodCallId?: symbol);
|
|
26
|
+
/**
|
|
27
|
+
* Create an invocation factory function
|
|
28
|
+
*
|
|
29
|
+
* @param method The name of the method to create
|
|
30
|
+
* @returns A new Blob invocation factory function for creating invocations of the specified type
|
|
31
|
+
*/
|
|
32
|
+
static createInvocationFactory<TArgs extends BlobRequestInvocationArgs | BlobResponseInvocationArgs>(method: JMAPMethodName): InvocationFactory<TArgs, BlobInvocation<TArgs>>;
|
|
33
|
+
}
|
|
34
|
+
export declare const Blob: {
|
|
35
|
+
request: {
|
|
36
|
+
/**
|
|
37
|
+
* Copies a Blob from one account to another.
|
|
38
|
+
*
|
|
39
|
+
* @param args The invocation arguments for Blob/copy
|
|
40
|
+
* @param methodCallId An optional unique symbol to identify this method call for result referencing
|
|
41
|
+
* @returns A BlobInvocation representing the Blob/copy request
|
|
42
|
+
*
|
|
43
|
+
* @see {@link https://www.rfc-editor.org/rfc/rfc8620.html#section-6.3 | RFC 8620 Section 6.3: Blob/copy}
|
|
44
|
+
*/
|
|
45
|
+
copy: InvocationFactory<BlobCopyRequestInvocationArgs, BlobInvocation<BlobCopyRequestInvocationArgs>>;
|
|
46
|
+
/**
|
|
47
|
+
* Retrieves binary data by blob ID with optional range and encoding support.
|
|
48
|
+
*
|
|
49
|
+
* @param args The invocation arguments for Blob/get
|
|
50
|
+
* @param methodCallId An optional unique symbol to identify this method call for result referencing
|
|
51
|
+
* @returns A BlobInvocation representing the Blob/get request
|
|
52
|
+
*
|
|
53
|
+
* @see {@link https://www.rfc-editor.org/rfc/rfc9404.html#section-4.2 | RFC 9404 Section 4.2: Blob/get}
|
|
54
|
+
*/
|
|
55
|
+
get: InvocationFactory<BlobGetRequestInvocationArgs, BlobInvocation<BlobGetRequestInvocationArgs>>;
|
|
56
|
+
/**
|
|
57
|
+
* Uploads binary data and returns the blob ID.
|
|
58
|
+
*
|
|
59
|
+
* @param args The invocation arguments for Blob/upload
|
|
60
|
+
* @param methodCallId An optional unique symbol to identify this method call for result referencing
|
|
61
|
+
* @returns A BlobInvocation representing the Blob/upload request
|
|
62
|
+
*
|
|
63
|
+
* @see {@link https://www.rfc-editor.org/rfc/rfc9404.html#section-4.1 | RFC 9404 Section 4.1: Blob/upload}
|
|
64
|
+
*/
|
|
65
|
+
upload: InvocationFactory<BlobUploadRequestInvocationArgs, BlobInvocation<BlobUploadRequestInvocationArgs>>;
|
|
66
|
+
/**
|
|
67
|
+
* Looks up blob IDs by their data type and account.
|
|
68
|
+
*
|
|
69
|
+
* @param args The invocation arguments for Blob/lookup
|
|
70
|
+
* @param methodCallId An optional unique symbol to identify this method call for result referencing
|
|
71
|
+
* @returns A BlobInvocation representing the Blob/lookup request
|
|
72
|
+
*
|
|
73
|
+
* @see {@link https://www.rfc-editor.org/rfc/rfc9404.html#section-4.3 | RFC 9404 Section 4.3: Blob/lookup}
|
|
74
|
+
*/
|
|
75
|
+
lookup: InvocationFactory<BlobLookupRequestInvocationArgs, BlobInvocation<BlobLookupRequestInvocationArgs>>;
|
|
76
|
+
};
|
|
77
|
+
response: {
|
|
78
|
+
copy: InvocationFactory<BlobCopyResponseInvocationArgs, BlobInvocation<BlobCopyResponseInvocationArgs>>;
|
|
79
|
+
get: InvocationFactory<BlobGetResponseInvocationArgs, BlobInvocation<BlobGetResponseInvocationArgs>>;
|
|
80
|
+
upload: InvocationFactory<BlobUploadResponseInvocationArgs, BlobInvocation<BlobUploadResponseInvocationArgs>>;
|
|
81
|
+
lookup: InvocationFactory<BlobLookupResponseInvocationArgs, BlobInvocation<BlobLookupResponseInvocationArgs>>;
|
|
82
|
+
};
|
|
83
|
+
};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { BLOB_CAPABILITY_URI, CORE_CAPABILITY_URI } from "../../common/registry.js";
|
|
2
|
+
import { Invocation } from "../../invocation/invocation.js";
|
|
3
|
+
/**
|
|
4
|
+
* BlobInvocation represents a JMAP Blob capability invocation.
|
|
5
|
+
*
|
|
6
|
+
* The Blob data type handles binary data management with methods for copying, uploading,
|
|
7
|
+
* retrieving, and looking up binary data across accounts. The Blob/copy method is part
|
|
8
|
+
* of the Core capability (RFC 8620), while upload/get/lookup are part of the Blob
|
|
9
|
+
* Management Extension (RFC 9404).
|
|
10
|
+
*
|
|
11
|
+
* @see {@link https://www.rfc-editor.org/rfc/rfc8620.html#section-6.3 | RFC 8620 Section 6.3: Blob/copy}
|
|
12
|
+
* @see {@link https://www.rfc-editor.org/rfc/rfc9404.html#section-4 | RFC 9404 Section 4: Blob Methods}
|
|
13
|
+
*/
|
|
14
|
+
export class BlobInvocation extends Invocation {
|
|
15
|
+
get uri() {
|
|
16
|
+
if (this.name === "Blob/copy") {
|
|
17
|
+
return CORE_CAPABILITY_URI;
|
|
18
|
+
}
|
|
19
|
+
return BLOB_CAPABILITY_URI;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Constructs a BlobInvocation
|
|
23
|
+
*
|
|
24
|
+
* @param method The name of the method being invoked (e.g., "copy", "upload", "get", "lookup")
|
|
25
|
+
* @param args The arguments for the method invocation
|
|
26
|
+
* @param methodCallId An optional unique symbol to identify this method call for result referencing
|
|
27
|
+
*/
|
|
28
|
+
constructor(method, args, methodCallId) {
|
|
29
|
+
super("Blob", method, args, methodCallId);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Create an invocation factory function
|
|
33
|
+
*
|
|
34
|
+
* @param method The name of the method to create
|
|
35
|
+
* @returns A new Blob invocation factory function for creating invocations of the specified type
|
|
36
|
+
*/
|
|
37
|
+
static createInvocationFactory(method) {
|
|
38
|
+
/**
|
|
39
|
+
* An invocation factory function to create a `Blob/*` invocation for the specified `method`
|
|
40
|
+
*
|
|
41
|
+
* @param args The invocation arguments for the specified `method`
|
|
42
|
+
* @param methodCallId An optional unique symbol to identify this method call for result referencing
|
|
43
|
+
* @returns An object representing the named arguments for the specified `method`
|
|
44
|
+
*/
|
|
45
|
+
return (args, methodCallId) => new BlobInvocation(method, args, methodCallId);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
export const Blob = {
|
|
49
|
+
request: {
|
|
50
|
+
/**
|
|
51
|
+
* Copies a Blob from one account to another.
|
|
52
|
+
*
|
|
53
|
+
* @param args The invocation arguments for Blob/copy
|
|
54
|
+
* @param methodCallId An optional unique symbol to identify this method call for result referencing
|
|
55
|
+
* @returns A BlobInvocation representing the Blob/copy request
|
|
56
|
+
*
|
|
57
|
+
* @see {@link https://www.rfc-editor.org/rfc/rfc8620.html#section-6.3 | RFC 8620 Section 6.3: Blob/copy}
|
|
58
|
+
*/
|
|
59
|
+
copy: BlobInvocation.createInvocationFactory("copy"),
|
|
60
|
+
/**
|
|
61
|
+
* Retrieves binary data by blob ID with optional range and encoding support.
|
|
62
|
+
*
|
|
63
|
+
* @param args The invocation arguments for Blob/get
|
|
64
|
+
* @param methodCallId An optional unique symbol to identify this method call for result referencing
|
|
65
|
+
* @returns A BlobInvocation representing the Blob/get request
|
|
66
|
+
*
|
|
67
|
+
* @see {@link https://www.rfc-editor.org/rfc/rfc9404.html#section-4.2 | RFC 9404 Section 4.2: Blob/get}
|
|
68
|
+
*/
|
|
69
|
+
get: BlobInvocation.createInvocationFactory("get"),
|
|
70
|
+
/**
|
|
71
|
+
* Uploads binary data and returns the blob ID.
|
|
72
|
+
*
|
|
73
|
+
* @param args The invocation arguments for Blob/upload
|
|
74
|
+
* @param methodCallId An optional unique symbol to identify this method call for result referencing
|
|
75
|
+
* @returns A BlobInvocation representing the Blob/upload request
|
|
76
|
+
*
|
|
77
|
+
* @see {@link https://www.rfc-editor.org/rfc/rfc9404.html#section-4.1 | RFC 9404 Section 4.1: Blob/upload}
|
|
78
|
+
*/
|
|
79
|
+
upload: BlobInvocation.createInvocationFactory("upload"),
|
|
80
|
+
/**
|
|
81
|
+
* Looks up blob IDs by their data type and account.
|
|
82
|
+
*
|
|
83
|
+
* @param args The invocation arguments for Blob/lookup
|
|
84
|
+
* @param methodCallId An optional unique symbol to identify this method call for result referencing
|
|
85
|
+
* @returns A BlobInvocation representing the Blob/lookup request
|
|
86
|
+
*
|
|
87
|
+
* @see {@link https://www.rfc-editor.org/rfc/rfc9404.html#section-4.3 | RFC 9404 Section 4.3: Blob/lookup}
|
|
88
|
+
*/
|
|
89
|
+
lookup: BlobInvocation.createInvocationFactory("lookup"),
|
|
90
|
+
},
|
|
91
|
+
response: {
|
|
92
|
+
copy: BlobInvocation.createInvocationFactory("copy"),
|
|
93
|
+
get: BlobInvocation.createInvocationFactory("get"),
|
|
94
|
+
upload: BlobInvocation.createInvocationFactory("upload"),
|
|
95
|
+
lookup: BlobInvocation.createInvocationFactory("lookup"),
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
//# sourceMappingURL=blob.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blob.js","sourceRoot":"","sources":["../../../../src/capabilities/blob/blob.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAEpF,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAe5D;;;;;;;;;;GAUG;AACH,MAAM,OAAO,cAEX,SAAQ,UAAiB;IACvB,IAAI,GAAG;QACH,IAAI,IAAI,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;YAC5B,OAAO,mBAAmB,CAAC;QAC/B,CAAC;QACD,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IAED;;;;;;OAMG;IACH,YAAY,MAAsB,EAAE,IAA2B,EAAE,YAAqB;QAClF,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,CAAC,CAAC;IAC9C,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,uBAAuB,CAC1B,MAAsB;QAEtB;;;;;;WAMG;QACH,OAAO,CAAC,IAAI,EAAE,YAAY,EAAE,EAAE,CAAC,IAAI,cAAc,CAAQ,MAAM,EAAE,IAAI,EAAE,YAAY,CAAC,CAAC;IACzF,CAAC;CACJ;AAED,MAAM,CAAC,MAAM,IAAI,GAAG;IAChB,OAAO,EAAE;QACL;;;;;;;;WAQG;QACH,IAAI,EAAE,cAAc,CAAC,uBAAuB,CAAgC,MAAM,CAAC;QACnF;;;;;;;;WAQG;QACH,GAAG,EAAE,cAAc,CAAC,uBAAuB,CAA+B,KAAK,CAAC;QAChF;;;;;;;;WAQG;QACH,MAAM,EAAE,cAAc,CAAC,uBAAuB,CAAkC,QAAQ,CAAC;QACzF;;;;;;;;WAQG;QACH,MAAM,EAAE,cAAc,CAAC,uBAAuB,CAAkC,QAAQ,CAAC;KAC5F;IACD,QAAQ,EAAE;QACN,IAAI,EAAE,cAAc,CAAC,uBAAuB,CAAiC,MAAM,CAAC;QACpF,GAAG,EAAE,cAAc,CAAC,uBAAuB,CAAgC,KAAK,CAAC;QACjF,MAAM,EAAE,cAAc,CAAC,uBAAuB,CAAmC,QAAQ,CAAC;QAC1F,MAAM,EAAE,cAAc,CAAC,uBAAuB,CAAmC,QAAQ,CAAC;KAC7F;CACkC,CAAC"}
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { z } from "zod/v4";
|
|
2
|
+
import type { Id, UnsignedInt } from "../../common/types.js";
|
|
3
|
+
import type { BaseGetRequestInvocationArgs, BaseGetResponseInvocationArgs, SetError } from "../../invocation/types.js";
|
|
4
|
+
/**
|
|
5
|
+
* Zod schema for validating HTTP Digest Algorithm values from the
|
|
6
|
+
* {@link https://www.iana.org/assignments/http-dig-alg/http-dig-alg.xhtml IANA HTTP Digest Algorithm Values registry}.
|
|
7
|
+
*/
|
|
8
|
+
export declare const HTTPDigestAlgorithmSchema: z.ZodEnum<{
|
|
9
|
+
adler32: "adler32";
|
|
10
|
+
crc32c: "crc32c";
|
|
11
|
+
md5: "md5";
|
|
12
|
+
sha: "sha";
|
|
13
|
+
"sha-256": "sha-256";
|
|
14
|
+
"sha-512": "sha-512";
|
|
15
|
+
unixsum: "unixsum";
|
|
16
|
+
unixcksum: "unixcksum";
|
|
17
|
+
}>;
|
|
18
|
+
/**
|
|
19
|
+
* The list of algorithms defined in the
|
|
20
|
+
* {@link https://www.iana.org/assignments/http-dig-alg/http-dig-alg.xhtml IANA HTTP Digest Algorithm Values registry}
|
|
21
|
+
* that the server supports for calculating blob digests.
|
|
22
|
+
*/
|
|
23
|
+
export type HTTPDigestAlgorithm = z.infer<typeof HTTPDigestAlgorithmSchema>;
|
|
24
|
+
/**
|
|
25
|
+
* Specifies the encoding format for blob data (text or base64)
|
|
26
|
+
*/
|
|
27
|
+
export type BlobDataFormat = "asText" | "asBase64";
|
|
28
|
+
/**
|
|
29
|
+
* Partial record of digest values for a blob, keyed by digest algorithm
|
|
30
|
+
*/
|
|
31
|
+
export type BlobObjectDigest = Partial<Record<`digest:${HTTPDigestAlgorithm}`, string>>;
|
|
32
|
+
/**
|
|
33
|
+
* Partial record of blob data in various formats (raw data, asText, or asBase64)
|
|
34
|
+
*/
|
|
35
|
+
export type BlobObjectData = Partial<Record<"data" | `data:${BlobDataFormat}`, string>>;
|
|
36
|
+
/**
|
|
37
|
+
* The size of a blob in octets
|
|
38
|
+
*/
|
|
39
|
+
export type BlobObjectSize = {
|
|
40
|
+
size?: UnsignedInt;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* A Blob object represents binary data managed by the server
|
|
44
|
+
*/
|
|
45
|
+
export type BlobObject = BlobObjectDigest & BlobObjectData & BlobObjectSize;
|
|
46
|
+
/**
|
|
47
|
+
* The arguments to copy Blob objects via a `Blob/copy` call
|
|
48
|
+
*/
|
|
49
|
+
export type BlobCopyRequestInvocationArgs = {
|
|
50
|
+
/** The accountId of the account to copy the blobs to */
|
|
51
|
+
accountId: Id;
|
|
52
|
+
/** The accountId of the account to copy the blobs from */
|
|
53
|
+
fromAccountId: Id;
|
|
54
|
+
/** The blobIds to copy */
|
|
55
|
+
blobIds: Id[];
|
|
56
|
+
};
|
|
57
|
+
export type BlobCopyResponseInvocationArgs = {
|
|
58
|
+
/** The id of the account blobs were copied from. */
|
|
59
|
+
fromAccountId: Id;
|
|
60
|
+
/** The id of the account blobs were copied to. */
|
|
61
|
+
accountId: Id;
|
|
62
|
+
/**
|
|
63
|
+
* A map of the blobId in the fromAccount to the id for the blob in the account it was copied
|
|
64
|
+
* to, or null if none were successfully copied.
|
|
65
|
+
*/
|
|
66
|
+
copied: Record<Id, Id> | null;
|
|
67
|
+
/**
|
|
68
|
+
* A map of blobId to a SetError object for each blob that failed to be copied, or null if none.
|
|
69
|
+
*/
|
|
70
|
+
notCopied: Record<Id, SetError<"create", "notFound">> | null;
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* The object representing the blob of data being uploaded
|
|
74
|
+
*/
|
|
75
|
+
export type UploadObject = {
|
|
76
|
+
/**
|
|
77
|
+
* An array of zero or more octet sources in order (zero to create an empty blob).
|
|
78
|
+
* The result of each of these sources is concatenated together in order to create the blob.
|
|
79
|
+
*/
|
|
80
|
+
data: DataSourceObject[];
|
|
81
|
+
/** (default: null) Hint for media type of the data */
|
|
82
|
+
type?: string | null;
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* A source of octets to use in creating a blob
|
|
86
|
+
*/
|
|
87
|
+
export type DataSourceObject = {
|
|
88
|
+
/** The raw octets, must be UTF-8 */
|
|
89
|
+
"data:asText": string | null;
|
|
90
|
+
} | {
|
|
91
|
+
/** The base64 representation of octets */
|
|
92
|
+
"data:asBase64": string | null;
|
|
93
|
+
} | {
|
|
94
|
+
/** The blobId to copy from */
|
|
95
|
+
blobId: Id;
|
|
96
|
+
/** (default: 0) The number of octets offset into the referenced blob */
|
|
97
|
+
offset?: UnsignedInt | null;
|
|
98
|
+
/** (default: remaining octets in the blog) The length of data to copy from the referenced blob */
|
|
99
|
+
length?: UnsignedInt | null;
|
|
100
|
+
};
|
|
101
|
+
export type DataCreatedObject = {
|
|
102
|
+
/** The blobId that was created. */
|
|
103
|
+
id: Id;
|
|
104
|
+
/**
|
|
105
|
+
* The media type as given in the creation (if any). If not provided, the server MAY perform
|
|
106
|
+
* content analysis and return one of the following: the calculated value, `application/octet-string`,
|
|
107
|
+
* or `null`. */
|
|
108
|
+
type: string | null;
|
|
109
|
+
/** The size of the created blob in octets. */
|
|
110
|
+
size: UnsignedInt;
|
|
111
|
+
};
|
|
112
|
+
/**
|
|
113
|
+
* The arguments for fetching Blob objects via a `Blob/get` call
|
|
114
|
+
*/
|
|
115
|
+
export type BlobGetRequestInvocationArgs = BaseGetRequestInvocationArgs<BlobObject> & {
|
|
116
|
+
/** (default: 0) Start this many octets into the blob data */
|
|
117
|
+
offset?: UnsignedInt | null;
|
|
118
|
+
/**
|
|
119
|
+
* (default: all remaining octets) Return at most this many octets of the blob data.
|
|
120
|
+
* If null or unspecified, then all remaining octets in the blob are returned. This can be
|
|
121
|
+
* considered equivalent to an infinitely large length value, except that the isTruncated
|
|
122
|
+
* warning is not given unless the start offset is past the end of the blob.
|
|
123
|
+
*/
|
|
124
|
+
length?: UnsignedInt | null;
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* The response to a `Blob/get` call
|
|
128
|
+
*/
|
|
129
|
+
export type BlobGetResponseInvocationArgs = Omit<BaseGetResponseInvocationArgs<Omit<BlobObject, "data">>, "state"> & {
|
|
130
|
+
/** (default: false) */
|
|
131
|
+
isEncodingProblem: boolean;
|
|
132
|
+
/** (default: false) */
|
|
133
|
+
isTruncated: boolean;
|
|
134
|
+
};
|
|
135
|
+
/**
|
|
136
|
+
* The arguments for uploading Blob objects via a `Blob/upload` call
|
|
137
|
+
*/
|
|
138
|
+
export type BlobUploadRequestInvocationArgs = {
|
|
139
|
+
/** The accountId of the account to upload the blob to */
|
|
140
|
+
accountId: Id;
|
|
141
|
+
/** The blobs to upload */
|
|
142
|
+
create: {
|
|
143
|
+
[id: string]: UploadObject;
|
|
144
|
+
};
|
|
145
|
+
};
|
|
146
|
+
/**
|
|
147
|
+
* The response to a `Blob/upload` call
|
|
148
|
+
*/
|
|
149
|
+
export type BlobUploadResponseInvocationArgs = {
|
|
150
|
+
/** The id of the account used for the call. */
|
|
151
|
+
accountId: Id;
|
|
152
|
+
/**
|
|
153
|
+
* The state string that would have been returned by Foo/get before making the requested
|
|
154
|
+
* changes, or null if the server doesn’t know what the previous state string was.
|
|
155
|
+
*/
|
|
156
|
+
oldState?: string | null;
|
|
157
|
+
/** The state string that will now be returned by Foo/get. */
|
|
158
|
+
newState: string;
|
|
159
|
+
/**
|
|
160
|
+
* A map of the creation id to an object containing any properties of the created Foo object
|
|
161
|
+
* that were not sent by the client. This includes all server-set properties (such as the id in
|
|
162
|
+
* most object types) and any properties that were omitted by the client and thus set to a
|
|
163
|
+
* default by the server.
|
|
164
|
+
*
|
|
165
|
+
* This argument is null if no Foo objects were successfully created.
|
|
166
|
+
*/
|
|
167
|
+
created?: Record<Id, DataCreatedObject> | null;
|
|
168
|
+
/**
|
|
169
|
+
* A map of the creation id to a SetError object for each record that failed to be created, or
|
|
170
|
+
* null if all successful.
|
|
171
|
+
*/
|
|
172
|
+
notCreated?: Record<Id, SetError<"create">> | null;
|
|
173
|
+
};
|
|
174
|
+
/**
|
|
175
|
+
* The arguments for looking up blobs via the Blob/lookup method
|
|
176
|
+
*/
|
|
177
|
+
export type BlobLookupRequestInvocationArgs = {
|
|
178
|
+
/** The accountId of the account to lookup the blobs in */
|
|
179
|
+
accountId: Id;
|
|
180
|
+
/** A list of names from the "JMAP Data Types" registry, or defined by private extensions which the client has requested. Only names for which "Can reference blobs" is true may be specified, and the capability which defines each type must also be used by the overall JMAP request in which this method is called.If a type name is not known by the server, or the associated capability has not been requested, then the server returns an "unknownDataType" error. */
|
|
181
|
+
typeNames: string[];
|
|
182
|
+
/** A list of blobId values to be looked for. */
|
|
183
|
+
ids: Id[];
|
|
184
|
+
/** A list of BlobInfo objects. */
|
|
185
|
+
list: BlobInfo[];
|
|
186
|
+
};
|
|
187
|
+
/**
|
|
188
|
+
* The response to a `Blob/lookup` call
|
|
189
|
+
*/
|
|
190
|
+
export type BlobLookupResponseInvocationArgs = {
|
|
191
|
+
/** A list of BlobInfo objects. */
|
|
192
|
+
list: BlobInfo[];
|
|
193
|
+
};
|
|
194
|
+
export type BlobInfo = {
|
|
195
|
+
/** The Blob Identifier. */
|
|
196
|
+
id: Id;
|
|
197
|
+
/**
|
|
198
|
+
* A map from type name to list of Ids of that data type (e.g. the name "Email" maps to a list of emailIds)
|
|
199
|
+
* If a blob is not visible to a user, or does not exist on the server at all, then the server MUST still
|
|
200
|
+
* return an empty array for each type as this doesn't leak any information about whether the blob is on the
|
|
201
|
+
* server but not visible to the requesting user.
|
|
202
|
+
*/
|
|
203
|
+
matchedIds: Record<string, Id[]>;
|
|
204
|
+
};
|
|
205
|
+
/**
|
|
206
|
+
* Union type of all Blob capability request invocation arguments
|
|
207
|
+
*/
|
|
208
|
+
export type BlobRequestInvocationArgs = BlobCopyRequestInvocationArgs | BlobGetRequestInvocationArgs | BlobUploadRequestInvocationArgs | BlobLookupRequestInvocationArgs;
|
|
209
|
+
/**
|
|
210
|
+
* Union type of all Blob capability response invocation arguments
|
|
211
|
+
*/
|
|
212
|
+
export type BlobResponseInvocationArgs = BlobCopyResponseInvocationArgs | BlobGetResponseInvocationArgs | BlobUploadResponseInvocationArgs | BlobLookupResponseInvocationArgs;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { z } from "zod/v4";
|
|
2
|
+
/**
|
|
3
|
+
* Zod schema for validating HTTP Digest Algorithm values from the
|
|
4
|
+
* {@link https://www.iana.org/assignments/http-dig-alg/http-dig-alg.xhtml IANA HTTP Digest Algorithm Values registry}.
|
|
5
|
+
*/
|
|
6
|
+
export const HTTPDigestAlgorithmSchema = z.enum([
|
|
7
|
+
"adler32",
|
|
8
|
+
"crc32c",
|
|
9
|
+
"md5",
|
|
10
|
+
"sha",
|
|
11
|
+
"sha-256",
|
|
12
|
+
"sha-512",
|
|
13
|
+
"unixsum",
|
|
14
|
+
"unixcksum",
|
|
15
|
+
]);
|
|
16
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/capabilities/blob/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAI3B;;;GAGG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC,IAAI,CAAC;IAC5C,SAAS;IACT,QAAQ;IACR,KAAK;IACL,KAAK;IACL,SAAS;IACT,SAAS;IACT,SAAS;IACT,WAAW;CACd,CAAC,CAAC"}
|