runline 0.36.0 → 0.38.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/dist/credentials/aws-plugin.d.ts +3 -0
- package/dist/credentials/aws-plugin.js +7 -2
- package/dist/credentials/aws.d.ts +11 -0
- package/dist/credentials/aws.js +110 -11
- package/dist/credentials/broker.js +8 -7
- package/dist/credentials/http.d.ts +17 -3
- package/dist/credentials/http.js +31 -9
- package/dist/credentials/transport.js +5 -1
- package/dist/credentials/types.d.ts +7 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/plugins/_shared/attachments.js +97 -0
- package/dist/plugins/_shared/microsoftAuth.js +33 -4
- package/dist/plugins/_shared/schemas.js +8 -0
- package/dist/plugins/agentMail/src/drafts.js +2 -1
- package/dist/plugins/agentMail/src/inboxes.js +2 -1
- package/dist/plugins/agentMail/src/messages.js +2 -1
- package/dist/plugins/agentMail/src/schemas.js +4 -41
- package/dist/plugins/agentMail/src/shared.js +28 -50
- package/dist/plugins/agentMail/src/threads.js +2 -1
- package/dist/plugins/gmail/src/index.js +10 -22
- package/dist/plugins/microsoftCalendar/src/index.js +513 -17
- package/dist/plugins/microsoftFiles/src/index.js +3 -3
- package/dist/plugins/microsoftMail/src/index.js +305 -54
- package/dist/plugins/todoist/src/credentials.js +4 -11
- package/dist/plugins/todoist/src/index.js +390 -281
- package/dist/plugins/zohoMail/src/credentials.js +92 -0
- package/dist/plugins/zohoMail/src/index.js +241 -0
- package/package.json +1 -1
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { basename } from "node:path";
|
|
2
1
|
import { AuthError, credentialRequest, jsonAnswer, pathSegment, responseFailed, } from "runline";
|
|
3
2
|
import * as t from "typebox";
|
|
4
3
|
import { Check } from "typebox/value";
|
|
5
|
-
import {
|
|
6
|
-
import { readLocalFile } from "../../_shared/localFile.js";
|
|
4
|
+
import { attachmentFile } from "../../_shared/attachments.js";
|
|
7
5
|
import { obj } from "../../_shared/provider.js";
|
|
8
6
|
import { agentMailCredential } from "./credentials.js";
|
|
9
7
|
import { id, MAX_REQUEST_BYTES } from "./schemas.js";
|
|
@@ -32,59 +30,39 @@ function wireFields(fields) {
|
|
|
32
30
|
}
|
|
33
31
|
/** The bytes a request body can still hold once base64 inflates them by 4/3. */
|
|
34
32
|
const MAX_FILE_BYTES = Math.floor((MAX_REQUEST_BYTES * 3) / 4);
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
33
|
+
/**
|
|
34
|
+
* One attachment as AgentMail's SendAttachment: its bytes as base64, or
|
|
35
|
+
* its URL for AgentMail to fetch.
|
|
36
|
+
*/
|
|
37
|
+
async function wireAttachment(input, index) {
|
|
38
|
+
let source;
|
|
39
|
+
let file;
|
|
40
|
+
if ("url" in input) {
|
|
41
|
+
try {
|
|
42
|
+
const url = new URL(input.url);
|
|
43
|
+
if (url.protocol !== "https:" || url.username || url.password)
|
|
44
|
+
throw new Error();
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
throw new Error(`agentMail: attachment ${index} url requires HTTPS without embedded credentials`);
|
|
48
|
+
}
|
|
49
|
+
source = { url: input.url };
|
|
50
|
+
file = { name: input.name, mimeType: input.mimeType };
|
|
48
51
|
}
|
|
49
|
-
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
+
else {
|
|
53
|
+
const resolved = await attachmentFile(input, index, {
|
|
54
|
+
plugin: "agentMail",
|
|
52
55
|
maxBytes: MAX_FILE_BYTES,
|
|
53
56
|
oversize: `agentMail: attachment ${index} exceeds the 6 MB request limit once encoded; use url`,
|
|
54
57
|
});
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
try {
|
|
60
|
-
const url = new URL(input.url);
|
|
61
|
-
if (url.protocol !== "https:" || url.username || url.password)
|
|
62
|
-
throw new Error();
|
|
58
|
+
if (!resolved.bytes.length)
|
|
59
|
+
throw new Error(`agentMail: attachment ${index} is empty`);
|
|
60
|
+
source = { content: resolved.bytes.toString("base64") };
|
|
61
|
+
file = resolved;
|
|
63
62
|
}
|
|
64
|
-
catch {
|
|
65
|
-
throw new Error(`agentMail: attachment ${index} url requires HTTPS without embedded credentials`);
|
|
66
|
-
}
|
|
67
|
-
return { url: input.url };
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* One attachment as AgentMail's SendAttachment. A download result passed
|
|
71
|
-
* as contentBase64 supplies the name and type the input leaves out; a
|
|
72
|
-
* local file is named for its path; text defaults to text/plain.
|
|
73
|
-
*/
|
|
74
|
-
async function wireAttachment(input, index) {
|
|
75
|
-
const source = await attachmentSource(input, index);
|
|
76
|
-
if ("content" in source && !source.content)
|
|
77
|
-
throw new Error(`agentMail: attachment ${index} is empty`);
|
|
78
|
-
const result = "contentBase64" in input && typeof input.contentBase64 !== "string"
|
|
79
|
-
? input.contentBase64
|
|
80
|
-
: undefined;
|
|
81
63
|
return Object.fromEntries(Object.entries({
|
|
82
|
-
filename:
|
|
83
|
-
|
|
84
|
-
("contentPath" in input ? basename(input.contentPath) : undefined),
|
|
85
|
-
content_type: input.mimeType ??
|
|
86
|
-
(result?.mimeType || undefined) ??
|
|
87
|
-
("content" in input ? "text/plain" : undefined),
|
|
64
|
+
filename: file.name,
|
|
65
|
+
content_type: file.mimeType,
|
|
88
66
|
content_disposition: input.inline === undefined
|
|
89
67
|
? undefined
|
|
90
68
|
: input.inline
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as t from "typebox";
|
|
2
|
-
import { atLeastOne
|
|
2
|
+
import { atLeastOne } from "../../_shared/schemas.js";
|
|
3
|
+
import { id, inboxFields, labelFields, mailListFields, pageFields, STRICT, searchFields, strings, threadFields, } from "./schemas.js";
|
|
3
4
|
import { attachmentPath, inboxPath, request, threadPath } from "./shared.js";
|
|
4
5
|
const list = t.Object({
|
|
5
6
|
...inboxFields,
|
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
*/
|
|
20
20
|
import { pathSegment, } from "runline";
|
|
21
21
|
import * as t from "typebox";
|
|
22
|
-
import {
|
|
22
|
+
import { base64File } from "../../_shared/attachments.js";
|
|
23
|
+
import { DownloadedFile } from "../../_shared/base64.js";
|
|
23
24
|
import { renderEmailJsx } from "../../_shared/emailJsx.js";
|
|
24
25
|
import { googleCredential, googleJsonRequest, googleOAuth, } from "../../_shared/googleAuth.js";
|
|
25
26
|
import { GoogleTimestamp, Id, NonEmptyString, stringEnum, } from "../../_shared/googleSchemas.js";
|
|
@@ -111,30 +112,17 @@ function normalizeAttachment(input, index) {
|
|
|
111
112
|
throw new Error(`gmail: attachment ${index} must be an object`);
|
|
112
113
|
}
|
|
113
114
|
const content = input.contentBase64;
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
typeof content
|
|
118
|
-
typeof content.contentBase64 === "string"
|
|
119
|
-
? content.contentBase64
|
|
120
|
-
: undefined;
|
|
121
|
-
if (typeof contentBase64 !== "string") {
|
|
115
|
+
if (typeof content !== "string" &&
|
|
116
|
+
(typeof content !== "object" ||
|
|
117
|
+
!content ||
|
|
118
|
+
typeof content.contentBase64 !== "string")) {
|
|
122
119
|
throw new Error(`gmail: attachment ${index} contentBase64 must be a base64 string`);
|
|
123
120
|
}
|
|
124
|
-
const
|
|
125
|
-
if (normalized === undefined) {
|
|
126
|
-
throw new Error(`gmail: attachment ${index} contentBase64 is not valid base64`);
|
|
127
|
-
}
|
|
128
|
-
// A download result passed as contentBase64 names its own file and type.
|
|
129
|
-
const result = typeof content === "object" && content ? content : {};
|
|
130
|
-
const named = (value) => typeof value === "string" && value ? value : undefined;
|
|
121
|
+
const file = base64File(content, `gmail: attachment ${index}`);
|
|
131
122
|
return {
|
|
132
|
-
name: input.name ??
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
`attachment-${index + 1}`,
|
|
136
|
-
mimeType: input.mimeType ?? named(result.mimeType) ?? "application/octet-stream",
|
|
137
|
-
contentBase64: normalized,
|
|
123
|
+
name: input.name ?? input.filename ?? file.name ?? `attachment-${index + 1}`,
|
|
124
|
+
mimeType: input.mimeType ?? file.mimeType ?? "application/octet-stream",
|
|
125
|
+
contentBase64: file.bytes.toString("base64"),
|
|
138
126
|
};
|
|
139
127
|
}
|
|
140
128
|
function attachmentPart(att) {
|