@push.rocks/smartjmap 1.0.0 → 2.1.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/.smartconfig.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "@git.zone/cli": {
3
+ "schemaVersion": 2,
3
4
  "projectType": "npm",
4
5
  "module": {
5
6
  "githost": "code.foss.global",
6
7
  "gitscope": "push.rocks",
7
8
  "gitrepo": "smartjmap",
8
- "shortDescription": "JMAP client for mail (RFC 8620/8621)",
9
- "description": "A TypeScript JMAP client for reading, sending, and watching mail via the JSON Meta Application Protocol (RFC 8620/8621), with a bundled test server for offline testing.",
9
+ "shortDescription": "JMAP client and server core for mail (RFC 8620/8621)",
10
+ "description": "A TypeScript JMAP toolkit (RFC 8620/8621): an event-driven mail client for reading, sending, and watching mail, plus an embeddable JMAP server core with pluggable storage.",
10
11
  "npmPackagename": "@push.rocks/smartjmap",
11
12
  "license": "MIT",
12
13
  "projectDomain": "push.rocks",
@@ -21,6 +22,8 @@
21
22
  "json",
22
23
  "http",
23
24
  "client",
25
+ "server",
26
+ "deno",
24
27
  "typescript",
25
28
  "event-driven",
26
29
  "push",
@@ -3,7 +3,7 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: '@push.rocks/smartjmap',
6
- version: '1.0.0',
7
- description: 'A TypeScript JMAP client for reading, sending, and watching mail via the JSON Meta Application Protocol (RFC 8620/8621), with a bundled test server for offline testing.'
6
+ version: '2.1.0',
7
+ description: 'A TypeScript JMAP toolkit (RFC 8620/8621): an event-driven mail client for reading, sending, and watching mail, plus an embeddable JMAP server core with pluggable storage.'
8
8
  };
9
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMDBfY29tbWl0aW5mb19kYXRhLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvMDBfY29tbWl0aW5mb19kYXRhLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOztHQUVHO0FBQ0gsTUFBTSxDQUFDLE1BQU0sVUFBVSxHQUFHO0lBQ3hCLElBQUksRUFBRSx1QkFBdUI7SUFDN0IsT0FBTyxFQUFFLE9BQU87SUFDaEIsV0FBVyxFQUFFLDBLQUEwSztDQUN4TCxDQUFBIn0=
9
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMDBfY29tbWl0aW5mb19kYXRhLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvMDBfY29tbWl0aW5mb19kYXRhLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOztHQUVHO0FBQ0gsTUFBTSxDQUFDLE1BQU0sVUFBVSxHQUFHO0lBQ3hCLElBQUksRUFBRSx1QkFBdUI7SUFDN0IsT0FBTyxFQUFFLE9BQU87SUFDaEIsV0FBVyxFQUFFLDZLQUE2SztDQUMzTCxDQUFBIn0=
@@ -125,6 +125,12 @@ export interface ISmartJmapMessage {
125
125
  /** The full raw JMAP Email object as returned by Email/get. */
126
126
  raw: IJmapEmail;
127
127
  }
128
+ /** An attachment reference for outgoing mail; upload the bytes first via `uploadBlob`. */
129
+ export interface IJmapOutgoingAttachment {
130
+ blobId: string;
131
+ type: string;
132
+ name?: string;
133
+ }
128
134
  export interface IJmapOutgoingEmail {
129
135
  /** Sender; defaults to the address of the account's first JMAP Identity. */
130
136
  from?: IJmapEmailAddress;
@@ -134,11 +140,20 @@ export interface IJmapOutgoingEmail {
134
140
  subject?: string;
135
141
  textBody?: string;
136
142
  htmlBody?: string;
143
+ /** Attachments referencing blobs previously uploaded with `uploadBlob`. */
144
+ attachments?: IJmapOutgoingAttachment[];
137
145
  }
138
146
  export interface IJmapSendResult {
139
147
  emailId: string;
140
148
  submissionId: string;
141
149
  }
150
+ /** The upload endpoint's response (RFC 8620 §6.1). */
151
+ export interface IJmapUploadResult {
152
+ accountId: string;
153
+ blobId: string;
154
+ type: string;
155
+ size: number;
156
+ }
142
157
  /** Error thrown for HTTP-level (RFC 7807 problem details) and JMAP method-level errors. */
143
158
  export declare class JmapError extends Error {
144
159
  httpStatus?: number;
@@ -151,18 +166,8 @@ export declare class JmapError extends Error {
151
166
  }
152
167
  export declare class JmapClient extends plugins.events.EventEmitter {
153
168
  private config;
154
- private session;
155
- private accountId;
156
- private apiUrl;
157
- private mailbox;
158
- private connected;
159
- private stopped;
160
- private lastEmailState;
161
- private seenEmailIds;
162
- private pollTimer;
163
- private sseAbortController;
164
- private fetchingDeltas;
165
- private deltaQueued;
169
+ private generationCounter;
170
+ private connectionGeneration;
166
171
  constructor(config: IJmapClientConfig);
167
172
  /**
168
173
  * Fetches and validates the JMAP session, resolves the target mailbox,
@@ -184,30 +189,56 @@ export declare class JmapClient extends plugins.events.EventEmitter {
184
189
  * JmapError with `httpStatus`/`problemType`/`jmapErrorType` fields.
185
190
  */
186
191
  request(methodCalls: TJmapMethodCall[]): Promise<TJmapMethodResponse[]>;
192
+ private requestWithGeneration;
187
193
  /** Returns all mailboxes of the account (Mailbox/get with ids: null). */
188
194
  getMailboxes(): Promise<IJmapMailbox[]>;
195
+ private getMailboxesWithGeneration;
189
196
  /**
190
197
  * Runs Email/query (default filter: the watched mailbox) followed by a full
191
198
  * Email/get and returns resolved messages, newest first.
192
199
  */
193
200
  queryEmails(filter?: Record<string, any>, limit?: number): Promise<ISmartJmapMessage[]>;
201
+ private queryEmailsWithGeneration;
194
202
  /** Fetches a single email with all body values resolved (RFC 8621 §4.2, fetchAllBodyValues). */
195
203
  getEmail(id: string): Promise<ISmartJmapMessage>;
196
204
  /** Replaces the full keywords object of an email via Email/set. */
197
205
  setKeywords(emailId: string, keywords: Record<string, boolean>): Promise<void>;
198
206
  /** Convenience: sets the $seen keyword via an Email/set keywords patch. */
199
207
  markSeen(emailId: string): Promise<void>;
208
+ /** Convenience: removes the $seen keyword via an Email/set keywords patch. */
209
+ markUnseen(emailId: string): Promise<void>;
210
+ /** Convenience: adds or removes the $flagged keyword. */
211
+ setFlagged(emailId: string, flagged: boolean): Promise<void>;
212
+ /**
213
+ * Replaces the email's mailbox membership. Pass one mailbox id for a
214
+ * provider-style move, or multiple ids when the remote JMAP account
215
+ * supports multi-mailbox membership.
216
+ */
217
+ setMailboxes(emailId: string, mailboxIds: string[]): Promise<void>;
218
+ /** Permanently destroys an email via Email/set. */
219
+ destroyEmail(emailId: string): Promise<void>;
200
220
  /**
201
221
  * Sends an email: Identity/get lookup, Email/set create (into the mailbox
202
222
  * with role 'sent', falling back to 'drafts', then the watched mailbox) and
203
223
  * EmailSubmission/set referencing the created email.
204
224
  */
205
225
  sendEmail(outgoing: IJmapOutgoingEmail): Promise<IJmapSendResult>;
226
+ /**
227
+ * Uploads raw bytes to the session's uploadUrl (RFC 8620 §6.1) and returns
228
+ * the stored blob's id, type, and size. Use the blobId in
229
+ * `sendEmail({ attachments: [...] })` or any other blob reference.
230
+ */
231
+ uploadBlob(data: Uint8Array, type?: string): Promise<IJmapUploadResult>;
206
232
  /**
207
233
  * Downloads a blob's raw bytes using the session downloadUrl template
208
234
  * (RFC 8620 §6.2: {accountId}, {blobId}, {type}, {name}).
209
235
  */
210
236
  downloadBlob(blobId: string, type?: string, name?: string): Promise<Uint8Array>;
237
+ private createConnectionGeneration;
238
+ private isCurrentGeneration;
239
+ private assertCurrentGeneration;
240
+ private requireConnectedGeneration;
241
+ private teardownGeneration;
211
242
  private getAuthHeader;
212
243
  private createHttpError;
213
244
  private resolveMailbox;
@@ -232,5 +263,4 @@ export declare class JmapClient extends plugins.events.EventEmitter {
232
263
  private fetchDeltasOnce;
233
264
  /** Full resync fallback when the server cannot calculate changes. */
234
265
  private resyncViaQuery;
235
- private teardownWatchers;
236
266
  }