@superdurable/connector-resend 0.0.0-stage → 0.1.1
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 +17 -2
- package/dex-connector.json +135 -0
- package/dist/chunk-GNJAHMSJ.js +163 -0
- package/dist/connection-DSFknakP.d.ts +113 -0
- package/dist/index.d.ts +165 -0
- package/dist/index.js +349 -0
- package/dist/mock.d.ts +54 -0
- package/dist/mock.js +124 -0
- package/package.json +61 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Super Durable
|
|
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,3 +1,18 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Resend TypeScript connector
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`@superdurable/connector-resend` provides the `sendEmail` Mutation and `getEmail`
|
|
4
|
+
Query with the branches and defaults declared in `../connector.yaml`.
|
|
5
|
+
|
|
6
|
+
Create a named `resend` connection and add the operation-specific
|
|
7
|
+
`newSendEmailStep` or `newGetEmailStep` to a Dex Flow. See the runnable
|
|
8
|
+
[welcome email example](examples/welcome-email/README.md) for the complete
|
|
9
|
+
Step factory and Worker setup. Keep the API key in Dex Web Connections; the
|
|
10
|
+
Flow input contains only email content.
|
|
11
|
+
|
|
12
|
+
Project connection configuration uses the manifest `timeout` field as a Go
|
|
13
|
+
duration such as `30s` (or an integer count of nanoseconds). Direct
|
|
14
|
+
`ResendClient` configuration uses `timeoutMs` in milliseconds. `sendEmail`
|
|
15
|
+
forwards only `from`, `to`, `subject`, and `html` to Resend.
|
|
16
|
+
|
|
17
|
+
`npm run check` runs TypeScript, lint, provider replay, and unit tests.
|
|
18
|
+
`npm run integration:welcome` verifies the example against a local Dex stack.
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
{
|
|
2
|
+
"connectorId": "resend",
|
|
3
|
+
"releaseTag": "connectors/resend/go/v0.2.1",
|
|
4
|
+
"package": {
|
|
5
|
+
"ecosystem": "npm",
|
|
6
|
+
"name": "@superdurable/connector-resend",
|
|
7
|
+
"version": "0.1.1"
|
|
8
|
+
},
|
|
9
|
+
"factories": [
|
|
10
|
+
{
|
|
11
|
+
"name": "newSendEmailStep",
|
|
12
|
+
"kind": "mutation",
|
|
13
|
+
"operationId": "sendEmail",
|
|
14
|
+
"inputType": "SendEmailInput",
|
|
15
|
+
"description": "SendEmail through the Resend public JSON API.",
|
|
16
|
+
"fields": {
|
|
17
|
+
"stepType": "stepType",
|
|
18
|
+
"annotations": "annotations",
|
|
19
|
+
"connectionName": "connectionName",
|
|
20
|
+
"resultAttribute": "resultAttribute"
|
|
21
|
+
},
|
|
22
|
+
"branches": [
|
|
23
|
+
{
|
|
24
|
+
"id": "sent",
|
|
25
|
+
"field": "sent",
|
|
26
|
+
"optional": false
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"id": "providerRejected",
|
|
30
|
+
"field": "providerRejected",
|
|
31
|
+
"optional": true
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"id": "invalidResponse",
|
|
35
|
+
"field": "invalidResponse",
|
|
36
|
+
"optional": true
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"id": "defect",
|
|
40
|
+
"field": "defect",
|
|
41
|
+
"optional": true
|
|
42
|
+
}
|
|
43
|
+
],
|
|
44
|
+
"inputSchema": {
|
|
45
|
+
"additionalProperties": false,
|
|
46
|
+
"description": "SendEmailInput is the exact payload sent once per keyed email operation.",
|
|
47
|
+
"properties": {
|
|
48
|
+
"from": {
|
|
49
|
+
"description": "From is the verified sender email address.",
|
|
50
|
+
"type": "string"
|
|
51
|
+
},
|
|
52
|
+
"html": {
|
|
53
|
+
"description": "HTML is the HTML email body.",
|
|
54
|
+
"type": "string"
|
|
55
|
+
},
|
|
56
|
+
"subject": {
|
|
57
|
+
"description": "Subject is the email subject.",
|
|
58
|
+
"type": "string"
|
|
59
|
+
},
|
|
60
|
+
"to": {
|
|
61
|
+
"description": "To contains recipient email addresses.",
|
|
62
|
+
"items": {
|
|
63
|
+
"type": "string"
|
|
64
|
+
},
|
|
65
|
+
"type": [
|
|
66
|
+
"array",
|
|
67
|
+
"null"
|
|
68
|
+
]
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
"required": [
|
|
72
|
+
"from",
|
|
73
|
+
"html",
|
|
74
|
+
"subject",
|
|
75
|
+
"to"
|
|
76
|
+
],
|
|
77
|
+
"type": "object"
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"name": "newGetEmailStep",
|
|
82
|
+
"kind": "query",
|
|
83
|
+
"operationId": "getEmail",
|
|
84
|
+
"inputType": "GetEmailInput",
|
|
85
|
+
"description": "GetEmail through the Resend public JSON API.",
|
|
86
|
+
"fields": {
|
|
87
|
+
"stepType": "stepType",
|
|
88
|
+
"annotations": "annotations",
|
|
89
|
+
"connectionName": "connectionName",
|
|
90
|
+
"resultAttribute": "resultAttribute"
|
|
91
|
+
},
|
|
92
|
+
"branches": [
|
|
93
|
+
{
|
|
94
|
+
"id": "found",
|
|
95
|
+
"field": "found",
|
|
96
|
+
"optional": false
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
"id": "notFound",
|
|
100
|
+
"field": "notFound",
|
|
101
|
+
"optional": true
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"id": "providerRejected",
|
|
105
|
+
"field": "providerRejected",
|
|
106
|
+
"optional": true
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"id": "invalidResponse",
|
|
110
|
+
"field": "invalidResponse",
|
|
111
|
+
"optional": true
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
"id": "defect",
|
|
115
|
+
"field": "defect",
|
|
116
|
+
"optional": true
|
|
117
|
+
}
|
|
118
|
+
],
|
|
119
|
+
"inputSchema": {
|
|
120
|
+
"additionalProperties": false,
|
|
121
|
+
"description": "GetEmailInput identifies one sent email.",
|
|
122
|
+
"properties": {
|
|
123
|
+
"id": {
|
|
124
|
+
"description": "ID is the provider's stable resource identifier.",
|
|
125
|
+
"type": "string"
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
"required": [
|
|
129
|
+
"id"
|
|
130
|
+
],
|
|
131
|
+
"type": "object"
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
]
|
|
135
|
+
}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
// src/generated/models.ts
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { SecretString } from "@superdurable/connectors-sdk";
|
|
4
|
+
var ConfigSchema = z.object({
|
|
5
|
+
"baseUrl": z.string().optional(),
|
|
6
|
+
"timeoutMs": z.number().int().optional(),
|
|
7
|
+
"maxResponseBytes": z.number().int().optional()
|
|
8
|
+
});
|
|
9
|
+
var CredentialMaterialError = class extends TypeError {
|
|
10
|
+
constructor(message) {
|
|
11
|
+
super(message);
|
|
12
|
+
this.name = "CredentialMaterialError";
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
var sdkCredentialDecodingFailureMessages = /* @__PURE__ */ new Set([
|
|
16
|
+
"project credential decoding failed",
|
|
17
|
+
"shared project credential decoding failed",
|
|
18
|
+
"project credential decoding failed: this connector version does not support shared credentials"
|
|
19
|
+
]);
|
|
20
|
+
function isCredentialMaterialError(error) {
|
|
21
|
+
return error instanceof CredentialMaterialError || error instanceof TypeError && sdkCredentialDecodingFailureMessages.has(error.message);
|
|
22
|
+
}
|
|
23
|
+
function decodeCredentials(value) {
|
|
24
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) throw new CredentialMaterialError("credential fields are invalid");
|
|
25
|
+
const fields = value;
|
|
26
|
+
const allowed = /* @__PURE__ */ new Set(["api_key"]);
|
|
27
|
+
if (Object.keys(fields).some((key) => !allowed.has(key))) throw new CredentialMaterialError("stored credential does not match the connector credential fields");
|
|
28
|
+
if (fields["api_key"] != null && !(typeof fields["api_key"] === "string")) throw new CredentialMaterialError("credential api_key has an invalid type");
|
|
29
|
+
const credentials = {};
|
|
30
|
+
if (!fields["api_key"]) throw new CredentialMaterialError("credential api_key is required");
|
|
31
|
+
credentials.apiKey = new SecretString(fields["api_key"] ?? "");
|
|
32
|
+
return credentials;
|
|
33
|
+
}
|
|
34
|
+
var SendEmailInputSchema = z.strictObject({
|
|
35
|
+
"from": z.string(),
|
|
36
|
+
"to": z.array(z.string()).nullable(),
|
|
37
|
+
"subject": z.string(),
|
|
38
|
+
"html": z.string()
|
|
39
|
+
});
|
|
40
|
+
var SentEmailSchema = z.strictObject({
|
|
41
|
+
"id": z.string()
|
|
42
|
+
});
|
|
43
|
+
var GetEmailInputSchema = z.strictObject({
|
|
44
|
+
"id": z.string()
|
|
45
|
+
});
|
|
46
|
+
var EmailSchema = z.strictObject({
|
|
47
|
+
"id": z.string(),
|
|
48
|
+
"from": z.string(),
|
|
49
|
+
"to": z.array(z.string()).nullable(),
|
|
50
|
+
"subject": z.string(),
|
|
51
|
+
"created_at": z.string()
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
// src/generated/definitions.ts
|
|
55
|
+
var ConnectorID = "resend";
|
|
56
|
+
var ProviderID = "resend";
|
|
57
|
+
var SendEmailBranch = {
|
|
58
|
+
Sent: "sent",
|
|
59
|
+
ProviderRejected: "providerRejected",
|
|
60
|
+
InvalidResponse: "invalidResponse",
|
|
61
|
+
Defect: "defect"
|
|
62
|
+
};
|
|
63
|
+
var SendEmailBranchSent = SendEmailBranch.Sent;
|
|
64
|
+
var SendEmailBranchProviderRejected = SendEmailBranch.ProviderRejected;
|
|
65
|
+
var SendEmailBranchInvalidResponse = SendEmailBranch.InvalidResponse;
|
|
66
|
+
var SendEmailBranchDefect = SendEmailBranch.Defect;
|
|
67
|
+
var SendEmailDefinition = {
|
|
68
|
+
operation: { connectorId: ConnectorID, operationId: "sendEmail" },
|
|
69
|
+
branches: [
|
|
70
|
+
{ id: "sent", description: "Resend returned the requested result." },
|
|
71
|
+
{ id: "providerRejected", description: "The provider definitively rejected the request.", optional: true },
|
|
72
|
+
{ id: "invalidResponse", description: "Kept for compatibility and no longer selected: a malformed or oversized answer now retries, because the Idempotency-Key makes Resend replay the first send.", optional: true },
|
|
73
|
+
{ id: "defect", description: "Local input or connection credentials are invalid.", optional: true }
|
|
74
|
+
],
|
|
75
|
+
stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "async" }
|
|
76
|
+
};
|
|
77
|
+
var SendEmailMetadata = { kind: "mutation", idempotency: "required", authorization: "required" };
|
|
78
|
+
var GetEmailBranch = {
|
|
79
|
+
Found: "found",
|
|
80
|
+
NotFound: "notFound",
|
|
81
|
+
ProviderRejected: "providerRejected",
|
|
82
|
+
InvalidResponse: "invalidResponse",
|
|
83
|
+
Defect: "defect"
|
|
84
|
+
};
|
|
85
|
+
var GetEmailBranchFound = GetEmailBranch.Found;
|
|
86
|
+
var GetEmailBranchNotFound = GetEmailBranch.NotFound;
|
|
87
|
+
var GetEmailBranchProviderRejected = GetEmailBranch.ProviderRejected;
|
|
88
|
+
var GetEmailBranchInvalidResponse = GetEmailBranch.InvalidResponse;
|
|
89
|
+
var GetEmailBranchDefect = GetEmailBranch.Defect;
|
|
90
|
+
var GetEmailDefinition = {
|
|
91
|
+
operation: { connectorId: ConnectorID, operationId: "getEmail" },
|
|
92
|
+
branches: [
|
|
93
|
+
{ id: "found", description: "Resend returned the requested result." },
|
|
94
|
+
{ id: "notFound", description: "The requested resource does not exist.", optional: true },
|
|
95
|
+
{ id: "providerRejected", description: "The provider definitively rejected the request.", optional: true },
|
|
96
|
+
{ id: "invalidResponse", description: "The provider returned malformed or oversized JSON.", optional: true },
|
|
97
|
+
{ id: "defect", description: "Local input or connection credentials are invalid.", optional: true }
|
|
98
|
+
],
|
|
99
|
+
stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "async" }
|
|
100
|
+
};
|
|
101
|
+
var GetEmailMetadata = { kind: "query", idempotency: "none", authorization: "required" };
|
|
102
|
+
|
|
103
|
+
// src/generated/connection.ts
|
|
104
|
+
import { ConnectionRefSchema } from "@superdurable/connectors-sdk";
|
|
105
|
+
var Connection = class {
|
|
106
|
+
/** Stable provider and connection name. */
|
|
107
|
+
reference;
|
|
108
|
+
/** Bound provider operations. */
|
|
109
|
+
operations;
|
|
110
|
+
/** Validate a reference and bind operations. */
|
|
111
|
+
constructor(reference, operations) {
|
|
112
|
+
this.reference = ConnectionRefSchema.parse(reference);
|
|
113
|
+
if (this.reference.provider !== ProviderID) throw new TypeError("connection provider differs from the manifest");
|
|
114
|
+
if (!operations) throw new TypeError("connector operations are required");
|
|
115
|
+
this.operations = operations;
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
function newConnection(client, reference) {
|
|
119
|
+
if (!client) throw new TypeError("connector client is required");
|
|
120
|
+
return new Connection(reference, client);
|
|
121
|
+
}
|
|
122
|
+
function newConnectionWithOperations(operations, reference) {
|
|
123
|
+
return new Connection(reference, operations);
|
|
124
|
+
}
|
|
125
|
+
function newProjectConnection(project, connectionName, createClient) {
|
|
126
|
+
if (!project) throw new TypeError("loaded project is required");
|
|
127
|
+
const reference = ConnectionRefSchema.parse({ provider: ProviderID, name: connectionName });
|
|
128
|
+
const selected = project.configuration.connections.find((entry) => entry.connectorId === ConnectorID && entry.connectionName === connectionName);
|
|
129
|
+
if (!selected || selected.provider !== ProviderID) throw new TypeError("project connection is not configured");
|
|
130
|
+
return newConnection(createClient(project, connectionName), reference);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export {
|
|
134
|
+
ConfigSchema,
|
|
135
|
+
CredentialMaterialError,
|
|
136
|
+
isCredentialMaterialError,
|
|
137
|
+
decodeCredentials,
|
|
138
|
+
SendEmailInputSchema,
|
|
139
|
+
SentEmailSchema,
|
|
140
|
+
GetEmailInputSchema,
|
|
141
|
+
EmailSchema,
|
|
142
|
+
ConnectorID,
|
|
143
|
+
ProviderID,
|
|
144
|
+
SendEmailBranch,
|
|
145
|
+
SendEmailBranchSent,
|
|
146
|
+
SendEmailBranchProviderRejected,
|
|
147
|
+
SendEmailBranchInvalidResponse,
|
|
148
|
+
SendEmailBranchDefect,
|
|
149
|
+
SendEmailDefinition,
|
|
150
|
+
SendEmailMetadata,
|
|
151
|
+
GetEmailBranch,
|
|
152
|
+
GetEmailBranchFound,
|
|
153
|
+
GetEmailBranchNotFound,
|
|
154
|
+
GetEmailBranchProviderRejected,
|
|
155
|
+
GetEmailBranchInvalidResponse,
|
|
156
|
+
GetEmailBranchDefect,
|
|
157
|
+
GetEmailDefinition,
|
|
158
|
+
GetEmailMetadata,
|
|
159
|
+
Connection,
|
|
160
|
+
newConnection,
|
|
161
|
+
newConnectionWithOperations,
|
|
162
|
+
newProjectConnection
|
|
163
|
+
};
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { CredentialProvider, SecretString, Mutation, Query, ConnectionRef } from '@superdurable/connectors-sdk';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
/** Connector configuration; omitted fields use manifest defaults. */
|
|
5
|
+
interface Config {
|
|
6
|
+
/** Resend API base URL. Leave blank for the displayed public endpoint; override only for a compatible gateway or local test server. */
|
|
7
|
+
baseUrl?: string;
|
|
8
|
+
/** Maximum time for one HTTP request, as a positive Go duration such as 15s or 1m. Leave blank for the displayed default; override for slower gateways. Runtime value in milliseconds. */
|
|
9
|
+
timeoutMs?: number;
|
|
10
|
+
/** Maximum accepted response size in bytes. Leave blank for the displayed default; increase only for larger legitimate pages. */
|
|
11
|
+
maxResponseBytes?: number;
|
|
12
|
+
}
|
|
13
|
+
/** Runtime schema for manifest configuration. */
|
|
14
|
+
declare const ConfigSchema: z.ZodObject<{
|
|
15
|
+
baseUrl: z.ZodOptional<z.ZodString>;
|
|
16
|
+
timeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
17
|
+
maxResponseBytes: z.ZodOptional<z.ZodNumber>;
|
|
18
|
+
}, z.core.$strip>;
|
|
19
|
+
/** Private connector credentials resolved by the host. */
|
|
20
|
+
interface Credentials {
|
|
21
|
+
/** Secret Resend token. Start at https://resend.com/api-keys, follow API Keys > Create API Key. Create an API key with sending permission, then copy its secret value. It is an opaque secret string; blank prevents requests. It is sent only in the Authorization header. */
|
|
22
|
+
apiKey: SecretString;
|
|
23
|
+
}
|
|
24
|
+
/** Stored credential material that fails the connector credential checks, so no retry can succeed. */
|
|
25
|
+
declare class CredentialMaterialError extends TypeError {
|
|
26
|
+
constructor(message: string);
|
|
27
|
+
}
|
|
28
|
+
/** Report malformed stored credential material, also behind the SDK provider's decoding TypeError. */
|
|
29
|
+
declare function isCredentialMaterialError(error: unknown): boolean;
|
|
30
|
+
/** Decode private credential fields for the connector. */
|
|
31
|
+
declare function decodeCredentials(value: unknown): Credentials;
|
|
32
|
+
/** Host-owned source of private connector credentials. */
|
|
33
|
+
type CredentialSource = CredentialProvider<Credentials>;
|
|
34
|
+
/** SendEmailInput is the exact payload sent once per keyed email operation. */
|
|
35
|
+
interface SendEmailInput {
|
|
36
|
+
/** From is the verified sender email address. */
|
|
37
|
+
"from": string;
|
|
38
|
+
/** To contains recipient email addresses. */
|
|
39
|
+
"to": Array<string> | null;
|
|
40
|
+
/** Subject is the email subject. */
|
|
41
|
+
"subject": string;
|
|
42
|
+
/** HTML is the HTML email body. */
|
|
43
|
+
"html": string;
|
|
44
|
+
}
|
|
45
|
+
/** SentEmail identifies a queued email. */
|
|
46
|
+
interface SentEmail {
|
|
47
|
+
/** ID is the provider's stable resource identifier. */
|
|
48
|
+
"id": string;
|
|
49
|
+
}
|
|
50
|
+
/** GetEmailInput identifies one sent email. */
|
|
51
|
+
interface GetEmailInput {
|
|
52
|
+
/** ID is the provider's stable resource identifier. */
|
|
53
|
+
"id": string;
|
|
54
|
+
}
|
|
55
|
+
/** Email contains selected sent email fields. */
|
|
56
|
+
interface Email {
|
|
57
|
+
/** ID is the provider's stable resource identifier. */
|
|
58
|
+
"id": string;
|
|
59
|
+
/** From is the verified sender email address. */
|
|
60
|
+
"from": string;
|
|
61
|
+
/** To contains recipient email addresses. */
|
|
62
|
+
"to": Array<string> | null;
|
|
63
|
+
/** Subject is the email subject. */
|
|
64
|
+
"subject": string;
|
|
65
|
+
/** CreatedAt is the provider's creation timestamp. */
|
|
66
|
+
"created_at": string;
|
|
67
|
+
}
|
|
68
|
+
/** Runtime validator for SendEmailInput. */
|
|
69
|
+
declare const SendEmailInputSchema: z.ZodObject<{
|
|
70
|
+
from: z.ZodString;
|
|
71
|
+
to: z.ZodNullable<z.ZodArray<z.ZodString>>;
|
|
72
|
+
subject: z.ZodString;
|
|
73
|
+
html: z.ZodString;
|
|
74
|
+
}, z.core.$strict>;
|
|
75
|
+
/** Runtime validator for SentEmail. */
|
|
76
|
+
declare const SentEmailSchema: z.ZodObject<{
|
|
77
|
+
id: z.ZodString;
|
|
78
|
+
}, z.core.$strict>;
|
|
79
|
+
/** Runtime validator for GetEmailInput. */
|
|
80
|
+
declare const GetEmailInputSchema: z.ZodObject<{
|
|
81
|
+
id: z.ZodString;
|
|
82
|
+
}, z.core.$strict>;
|
|
83
|
+
/** Runtime validator for Email. */
|
|
84
|
+
declare const EmailSchema: z.ZodObject<{
|
|
85
|
+
id: z.ZodString;
|
|
86
|
+
from: z.ZodString;
|
|
87
|
+
to: z.ZodNullable<z.ZodArray<z.ZodString>>;
|
|
88
|
+
subject: z.ZodString;
|
|
89
|
+
created_at: z.ZodString;
|
|
90
|
+
}, z.core.$strict>;
|
|
91
|
+
|
|
92
|
+
/** Typed operations supplied by a client or mock. */
|
|
93
|
+
interface Operations {
|
|
94
|
+
/** Invoke sendEmail through this connection. */
|
|
95
|
+
sendEmail(): Mutation<SendEmailInput, SentEmail>;
|
|
96
|
+
/** Invoke getEmail through this connection. */
|
|
97
|
+
getEmail(): Query<GetEmailInput, Email>;
|
|
98
|
+
}
|
|
99
|
+
/** Named connector connection kept outside Flow state. */
|
|
100
|
+
declare class Connection<BoundOperations = Operations> {
|
|
101
|
+
/** Stable provider and connection name. */
|
|
102
|
+
readonly reference: ConnectionRef;
|
|
103
|
+
/** Bound provider operations. */
|
|
104
|
+
readonly operations: BoundOperations;
|
|
105
|
+
/** Validate a reference and bind operations. */
|
|
106
|
+
constructor(reference: ConnectionRef, operations: BoundOperations);
|
|
107
|
+
}
|
|
108
|
+
/** Bind a client to a named connection. */
|
|
109
|
+
declare function newConnection(client: Operations, reference: ConnectionRef): Connection;
|
|
110
|
+
/** Bind scripted operations to a named connection. */
|
|
111
|
+
declare function newConnectionWithOperations(operations: Operations, reference: ConnectionRef): Connection;
|
|
112
|
+
|
|
113
|
+
export { Connection as C, type Email as E, type GetEmailInput as G, type Operations as O, type SendEmailInput as S, type SentEmail as a, type Config as b, type Credentials as c, ConfigSchema as d, CredentialMaterialError as e, type CredentialSource as f, EmailSchema as g, GetEmailInputSchema as h, SendEmailInputSchema as i, SentEmailSchema as j, decodeCredentials as k, isCredentialMaterialError as l, newConnectionWithOperations as m, newConnection as n };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { G as GetEmailInput, E as Email, C as Connection, S as SendEmailInput, a as SentEmail, b as Config, c as Credentials, O as Operations } from './connection-DSFknakP.js';
|
|
2
|
+
export { d as ConfigSchema, e as CredentialMaterialError, f as CredentialSource, g as EmailSchema, h as GetEmailInputSchema, i as SendEmailInputSchema, j as SentEmailSchema, k as decodeCredentials, l as isCredentialMaterialError, n as newConnection, m as newConnectionWithOperations } from './connection-DSFknakP.js';
|
|
3
|
+
import * as _superdurable_connectors_sdk from '@superdurable/connectors-sdk';
|
|
4
|
+
import { QueryDefinition, MutationDefinition, QueryStepConfig, Query, QueryResult, MutationStepConfig, Mutation, MutationResult, QueryStep, MutationStep, Call, MutationAttempt, QueryAttempt, CredentialProvider } from '@superdurable/connectors-sdk';
|
|
5
|
+
import { StepTarget } from '@superdurable/dex';
|
|
6
|
+
import { LoadedProject } from '@superdurable/connectors-sdk/projectconfig';
|
|
7
|
+
import { ProviderRequest, ProviderResponse } from '@superdurable/connectors-sdk/providerhttp';
|
|
8
|
+
import 'zod';
|
|
9
|
+
|
|
10
|
+
/** Stable connector identity. */
|
|
11
|
+
declare const ConnectorID = "resend";
|
|
12
|
+
/** Provider identity for named connections. */
|
|
13
|
+
declare const ProviderID = "resend";
|
|
14
|
+
/** Branch IDs for sendEmail. */
|
|
15
|
+
declare const SendEmailBranch: {
|
|
16
|
+
readonly Sent: "sent";
|
|
17
|
+
readonly ProviderRejected: "providerRejected";
|
|
18
|
+
readonly InvalidResponse: "invalidResponse";
|
|
19
|
+
readonly Defect: "defect";
|
|
20
|
+
};
|
|
21
|
+
/** Resend returned the requested result. */
|
|
22
|
+
declare const SendEmailBranchSent: "sent";
|
|
23
|
+
/** The provider definitively rejected the request. */
|
|
24
|
+
declare const SendEmailBranchProviderRejected: "providerRejected";
|
|
25
|
+
/** Kept for compatibility and no longer selected: a malformed or oversized answer now retries, because the Idempotency-Key makes Resend replay the first send. */
|
|
26
|
+
declare const SendEmailBranchInvalidResponse: "invalidResponse";
|
|
27
|
+
/** Local input or connection credentials are invalid. */
|
|
28
|
+
declare const SendEmailBranchDefect: "defect";
|
|
29
|
+
/** Manifest definition for sendEmail. */
|
|
30
|
+
declare const SendEmailDefinition: MutationDefinition;
|
|
31
|
+
/** Manifest metadata for sendEmail. */
|
|
32
|
+
declare const SendEmailMetadata: {
|
|
33
|
+
readonly kind: "mutation";
|
|
34
|
+
readonly idempotency: "required";
|
|
35
|
+
readonly authorization: "required";
|
|
36
|
+
};
|
|
37
|
+
/** Branch IDs for getEmail. */
|
|
38
|
+
declare const GetEmailBranch: {
|
|
39
|
+
readonly Found: "found";
|
|
40
|
+
readonly NotFound: "notFound";
|
|
41
|
+
readonly ProviderRejected: "providerRejected";
|
|
42
|
+
readonly InvalidResponse: "invalidResponse";
|
|
43
|
+
readonly Defect: "defect";
|
|
44
|
+
};
|
|
45
|
+
/** Resend returned the requested result. */
|
|
46
|
+
declare const GetEmailBranchFound: "found";
|
|
47
|
+
/** The requested resource does not exist. */
|
|
48
|
+
declare const GetEmailBranchNotFound: "notFound";
|
|
49
|
+
/** The provider definitively rejected the request. */
|
|
50
|
+
declare const GetEmailBranchProviderRejected: "providerRejected";
|
|
51
|
+
/** The provider returned malformed or oversized JSON. */
|
|
52
|
+
declare const GetEmailBranchInvalidResponse: "invalidResponse";
|
|
53
|
+
/** Local input or connection credentials are invalid. */
|
|
54
|
+
declare const GetEmailBranchDefect: "defect";
|
|
55
|
+
/** Manifest definition for getEmail. */
|
|
56
|
+
declare const GetEmailDefinition: QueryDefinition;
|
|
57
|
+
/** Manifest metadata for getEmail. */
|
|
58
|
+
declare const GetEmailMetadata: {
|
|
59
|
+
readonly kind: "query";
|
|
60
|
+
readonly idempotency: "none";
|
|
61
|
+
readonly authorization: "required";
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
/** Configuration for the sendEmail connector Step. */
|
|
65
|
+
interface SendEmailStepConfig<StepInput, OperationInput = SendEmailInput, OperationOutput = SentEmail> extends Omit<MutationStepConfig<StepInput, OperationInput, OperationOutput>, 'operation' | 'connection' | 'branches'> {
|
|
66
|
+
/** Named connection supplying this operation. */
|
|
67
|
+
connection: Connection<{
|
|
68
|
+
sendEmail(): Mutation<OperationInput, OperationOutput>;
|
|
69
|
+
}>;
|
|
70
|
+
/** Name matching the bound connection. */
|
|
71
|
+
connectionName: string;
|
|
72
|
+
/** Resend returned the requested result. */
|
|
73
|
+
sent: StepTarget<MutationResult<OperationOutput>>;
|
|
74
|
+
/** The provider definitively rejected the request. */
|
|
75
|
+
providerRejected?: StepTarget<MutationResult<OperationOutput>>;
|
|
76
|
+
/** Kept for compatibility and no longer selected: a malformed or oversized answer now retries, because the Idempotency-Key makes Resend replay the first send. */
|
|
77
|
+
invalidResponse?: StepTarget<MutationResult<OperationOutput>>;
|
|
78
|
+
/** Local input or connection credentials are invalid. */
|
|
79
|
+
defect?: StepTarget<MutationResult<OperationOutput>>;
|
|
80
|
+
}
|
|
81
|
+
/** Build the sendEmail Step from a named connection. */
|
|
82
|
+
declare function newSendEmailStep<StepInput, OperationInput = SendEmailInput, OperationOutput = SentEmail>(configuration: SendEmailStepConfig<StepInput, OperationInput, OperationOutput>): MutationStep<StepInput, OperationInput, OperationOutput>;
|
|
83
|
+
/** Configuration for the getEmail connector Step. */
|
|
84
|
+
interface GetEmailStepConfig<StepInput, OperationInput = GetEmailInput, OperationOutput = Email> extends Omit<QueryStepConfig<StepInput, OperationInput, OperationOutput>, 'operation' | 'connection' | 'branches'> {
|
|
85
|
+
/** Named connection supplying this operation. */
|
|
86
|
+
connection: Connection<{
|
|
87
|
+
getEmail(): Query<OperationInput, OperationOutput>;
|
|
88
|
+
}>;
|
|
89
|
+
/** Name matching the bound connection. */
|
|
90
|
+
connectionName: string;
|
|
91
|
+
/** Resend returned the requested result. */
|
|
92
|
+
found: StepTarget<QueryResult<OperationOutput>>;
|
|
93
|
+
/** The requested resource does not exist. */
|
|
94
|
+
notFound?: StepTarget<QueryResult<OperationOutput>>;
|
|
95
|
+
/** The provider definitively rejected the request. */
|
|
96
|
+
providerRejected?: StepTarget<QueryResult<OperationOutput>>;
|
|
97
|
+
/** The provider returned malformed or oversized JSON. */
|
|
98
|
+
invalidResponse?: StepTarget<QueryResult<OperationOutput>>;
|
|
99
|
+
/** Local input or connection credentials are invalid. */
|
|
100
|
+
defect?: StepTarget<QueryResult<OperationOutput>>;
|
|
101
|
+
}
|
|
102
|
+
/** Build the getEmail Step from a named connection. */
|
|
103
|
+
declare function newGetEmailStep<StepInput, OperationInput = GetEmailInput, OperationOutput = Email>(configuration: GetEmailStepConfig<StepInput, OperationInput, OperationOutput>): QueryStep<StepInput, OperationInput, OperationOutput>;
|
|
104
|
+
|
|
105
|
+
/** Send one email with the stable Dex call ID as Resend's idempotency key. */
|
|
106
|
+
declare class SendEmailOperation implements Mutation<SendEmailInput, SentEmail> {
|
|
107
|
+
private readonly client;
|
|
108
|
+
/** Bind a validated Resend client. */ constructor(client: ResendClient);
|
|
109
|
+
/** Return the generated operation contract. */ definition(): _superdurable_connectors_sdk.QueryDefinition;
|
|
110
|
+
/** Derive the provider key from the stable call ID. */ idempotencyKey(callId: string): string;
|
|
111
|
+
/** Validate, send, and classify one attempt. */
|
|
112
|
+
invoke(call: Call, input: SendEmailInput): Promise<MutationAttempt<SentEmail>>;
|
|
113
|
+
}
|
|
114
|
+
/** Retrieve one sent email by its provider ID. */
|
|
115
|
+
declare class GetEmailOperation implements Query<GetEmailInput, Email> {
|
|
116
|
+
private readonly client;
|
|
117
|
+
/** Bind a validated Resend client. */ constructor(client: ResendClient);
|
|
118
|
+
/** Return the generated operation contract. */ definition(): _superdurable_connectors_sdk.QueryDefinition;
|
|
119
|
+
/** Validate, retrieve, and classify one attempt. */
|
|
120
|
+
invoke(call: Call, input: GetEmailInput): Promise<QueryAttempt<Email>>;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/** Provider sender, injectable for deterministic tests. */
|
|
124
|
+
type ResendRequestSender = (request: ProviderRequest) => Promise<ProviderResponse>;
|
|
125
|
+
/** HTTP dependencies supplied at construction. */
|
|
126
|
+
interface ResendClientOptions {
|
|
127
|
+
/** Override the transport for tests and compatible gateways. */
|
|
128
|
+
send?: ResendRequestSender;
|
|
129
|
+
}
|
|
130
|
+
/** One bounded Resend response, including a body-size classification. */
|
|
131
|
+
interface ResendResponse extends ProviderResponse {
|
|
132
|
+
/** True when a successful response exceeded the configured byte limit. */
|
|
133
|
+
isTooLarge: boolean;
|
|
134
|
+
}
|
|
135
|
+
/** Resend client that resolves current credentials for every operation attempt. */
|
|
136
|
+
declare class ResendClient {
|
|
137
|
+
private readonly endpoint;
|
|
138
|
+
private readonly timeoutMs;
|
|
139
|
+
private readonly maxResponseBytes;
|
|
140
|
+
private readonly credentials;
|
|
141
|
+
private readonly send;
|
|
142
|
+
/** Validate local configuration without calling Resend. */
|
|
143
|
+
constructor(config: Config, credentials: CredentialProvider<Credentials>, options?: ResendClientOptions);
|
|
144
|
+
/** Bind the keyed send mutation. */
|
|
145
|
+
sendEmail(): SendEmailOperation;
|
|
146
|
+
/** Bind the email lookup query. */
|
|
147
|
+
getEmail(): GetEmailOperation;
|
|
148
|
+
/** Resolve a safe API key; invalid and unavailable credentials are terminal. */
|
|
149
|
+
resolveAPIKey(call: Call): Promise<string | undefined>;
|
|
150
|
+
/**
|
|
151
|
+
* Resolve a safe API key, or report whether the failure may clear on a later attempt. Only reauthorization,
|
|
152
|
+
* a missing or unselected connection, a broker refusal, and unusable material are terminal.
|
|
153
|
+
*/
|
|
154
|
+
resolveAPIKeyResolution(call: Call): Promise<{
|
|
155
|
+
apiKey?: string;
|
|
156
|
+
isTransient: boolean;
|
|
157
|
+
}>;
|
|
158
|
+
/** Send one no-redirect request with Resend's authentication and content headers. */
|
|
159
|
+
exchange(call: Call, apiKey: string, method: 'GET' | 'POST', path: string, body?: Uint8Array): Promise<ResendResponse>;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/** Bind one static Resend connection from a loaded Dex project. */
|
|
163
|
+
declare function newProjectConnection(project: LoadedProject, connectionName: string, options?: ResendClientOptions): Connection<Operations>;
|
|
164
|
+
|
|
165
|
+
export { Config, Connection, ConnectorID, Credentials, Email, GetEmailBranch, GetEmailBranchDefect, GetEmailBranchFound, GetEmailBranchInvalidResponse, GetEmailBranchNotFound, GetEmailBranchProviderRejected, GetEmailDefinition, GetEmailInput, GetEmailMetadata, GetEmailOperation, type GetEmailStepConfig, ProviderID, ResendClient, type ResendClientOptions, type ResendRequestSender, SendEmailBranch, SendEmailBranchDefect, SendEmailBranchInvalidResponse, SendEmailBranchProviderRejected, SendEmailBranchSent, SendEmailDefinition, SendEmailInput, SendEmailMetadata, SendEmailOperation, type SendEmailStepConfig, SentEmail, newGetEmailStep, newProjectConnection, newSendEmailStep };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ConfigSchema,
|
|
3
|
+
Connection,
|
|
4
|
+
ConnectorID,
|
|
5
|
+
CredentialMaterialError,
|
|
6
|
+
EmailSchema,
|
|
7
|
+
GetEmailBranch,
|
|
8
|
+
GetEmailBranchDefect,
|
|
9
|
+
GetEmailBranchFound,
|
|
10
|
+
GetEmailBranchInvalidResponse,
|
|
11
|
+
GetEmailBranchNotFound,
|
|
12
|
+
GetEmailBranchProviderRejected,
|
|
13
|
+
GetEmailDefinition,
|
|
14
|
+
GetEmailInputSchema,
|
|
15
|
+
GetEmailMetadata,
|
|
16
|
+
ProviderID,
|
|
17
|
+
SendEmailBranch,
|
|
18
|
+
SendEmailBranchDefect,
|
|
19
|
+
SendEmailBranchInvalidResponse,
|
|
20
|
+
SendEmailBranchProviderRejected,
|
|
21
|
+
SendEmailBranchSent,
|
|
22
|
+
SendEmailDefinition,
|
|
23
|
+
SendEmailInputSchema,
|
|
24
|
+
SendEmailMetadata,
|
|
25
|
+
SentEmailSchema,
|
|
26
|
+
decodeCredentials,
|
|
27
|
+
isCredentialMaterialError,
|
|
28
|
+
newConnection,
|
|
29
|
+
newConnectionWithOperations,
|
|
30
|
+
newProjectConnection
|
|
31
|
+
} from "./chunk-GNJAHMSJ.js";
|
|
32
|
+
|
|
33
|
+
// src/generated/steps.ts
|
|
34
|
+
import { goToBranch, newMutationStep, newQueryStep } from "@superdurable/connectors-sdk";
|
|
35
|
+
function newSendEmailStep(configuration) {
|
|
36
|
+
const { connection, connectionName, sent, providerRejected, invalidResponse, defect, ...stepConfiguration } = configuration;
|
|
37
|
+
if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
|
|
38
|
+
return newMutationStep({ ...stepConfiguration, operation: connection.operations.sendEmail(), connection: connection.reference, branches: [
|
|
39
|
+
goToBranch("sent", sent),
|
|
40
|
+
...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
|
|
41
|
+
...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
|
|
42
|
+
...defect ? [goToBranch("defect", defect)] : []
|
|
43
|
+
] });
|
|
44
|
+
}
|
|
45
|
+
function newGetEmailStep(configuration) {
|
|
46
|
+
const { connection, connectionName, found, notFound, providerRejected, invalidResponse, defect, ...stepConfiguration } = configuration;
|
|
47
|
+
if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
|
|
48
|
+
return newQueryStep({ ...stepConfiguration, operation: connection.operations.getEmail(), connection: connection.reference, branches: [
|
|
49
|
+
goToBranch("found", found),
|
|
50
|
+
...notFound ? [goToBranch("notFound", notFound)] : [],
|
|
51
|
+
...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
|
|
52
|
+
...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
|
|
53
|
+
...defect ? [goToBranch("defect", defect)] : []
|
|
54
|
+
] });
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// src/project.ts
|
|
58
|
+
import { SecretString as SecretString2 } from "@superdurable/connectors-sdk";
|
|
59
|
+
import { z as z2 } from "zod";
|
|
60
|
+
|
|
61
|
+
// src/client.ts
|
|
62
|
+
import { BodyTooLargeError, isHeaderSafeCredential, sendProviderRequest, validateBaseURL } from "@superdurable/connectors-sdk/providerhttp";
|
|
63
|
+
import { ReauthorizationRequiredError, SecretString } from "@superdurable/connectors-sdk";
|
|
64
|
+
import { ConnectionNotSelectedError, CredentialBrokerRejectedError, ObjectNotFoundError } from "@superdurable/connectors-sdk/projectconfig";
|
|
65
|
+
import { z } from "zod";
|
|
66
|
+
|
|
67
|
+
// src/operations.ts
|
|
68
|
+
import { newMutationBranch, newMutationRetry, newQueryBranch, newQueryRetry } from "@superdurable/connectors-sdk";
|
|
69
|
+
import { parseRetryAfter } from "@superdurable/connectors-sdk/providerhttp";
|
|
70
|
+
var emptySent = { id: "" };
|
|
71
|
+
var emptyEmail = { id: "", from: "", to: [], subject: "", created_at: "" };
|
|
72
|
+
var SendEmailOperation = class {
|
|
73
|
+
/** Bind a validated Resend client. */
|
|
74
|
+
constructor(client) {
|
|
75
|
+
this.client = client;
|
|
76
|
+
}
|
|
77
|
+
client;
|
|
78
|
+
/** Return the generated operation contract. */
|
|
79
|
+
definition() {
|
|
80
|
+
return SendEmailDefinition;
|
|
81
|
+
}
|
|
82
|
+
/** Derive the provider key from the stable call ID. */
|
|
83
|
+
idempotencyKey(callId) {
|
|
84
|
+
return callId;
|
|
85
|
+
}
|
|
86
|
+
/** Validate, send, and classify one attempt. */
|
|
87
|
+
async invoke(call, input) {
|
|
88
|
+
const operation = "sendEmail";
|
|
89
|
+
if (!input || !input.from || !input.to?.length || !input.subject || !input.html) return newMutationBranch("defect", emptySent, {}, failure(operation, "VALIDATION", "from, to, subject, and html are required"));
|
|
90
|
+
if (input.to.some((recipient) => !recipient)) return newMutationBranch("defect", emptySent, {}, failure(operation, "VALIDATION", "recipient cannot be blank"));
|
|
91
|
+
if (!call.idempotencyKey || Buffer.byteLength(call.idempotencyKey) > 256) return newMutationBranch("defect", emptySent, {}, failure(operation, "VALIDATION", "idempotency key is invalid"));
|
|
92
|
+
const { apiKey, isTransient } = await this.client.resolveAPIKeyResolution(call);
|
|
93
|
+
if (isTransient) return newMutationRetry(failure(operation, "AVAILABILITY", "connection credentials are temporarily unavailable; nothing was sent"));
|
|
94
|
+
if (!apiKey) return credentialDefect(operation, emptySent);
|
|
95
|
+
let response;
|
|
96
|
+
try {
|
|
97
|
+
response = await this.client.exchange(call, apiKey, "POST", "/emails", Buffer.from(JSON.stringify({ from: input.from, to: input.to, subject: input.subject, html: input.html })));
|
|
98
|
+
} catch {
|
|
99
|
+
return newMutationRetry(failure(operation, "AVAILABILITY", "provider request failed"));
|
|
100
|
+
}
|
|
101
|
+
const retry = retryResponse(operation, response);
|
|
102
|
+
if (retry) return newMutationRetry(retry.failure, retry.delay);
|
|
103
|
+
if (![200, 201, 202].includes(response.status) && !definiteRefusalStatuses.has(response.status)) return newMutationRetry(failure(operation, "AVAILABILITY", `provider answered HTTP ${response.status}, so the outcome is unknown`));
|
|
104
|
+
if (![200, 201, 202].includes(response.status)) return newMutationBranch("providerRejected", emptySent, {}, failure(operation, "PROVIDER_REJECTION", `provider rejected the request with HTTP ${response.status}`));
|
|
105
|
+
if (response.isTooLarge) return newMutationRetry(failure(operation, "RESPONSE_TOO_LARGE", "provider response exceeded the configured limit"));
|
|
106
|
+
try {
|
|
107
|
+
const document = decodeObject(response.body);
|
|
108
|
+
if (typeof document.id !== "string" || !document.id) throw new TypeError("email ID missing");
|
|
109
|
+
return newMutationBranch("sent", { id: document.id }, {});
|
|
110
|
+
} catch {
|
|
111
|
+
return newMutationRetry(failure(operation, "PROTOCOL", "provider response is incomplete or malformed"));
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
var definiteRefusalStatuses = /* @__PURE__ */ new Set([400, 401, 403, 404, 411, 413, 414, 415, 422]);
|
|
116
|
+
var GetEmailOperation = class {
|
|
117
|
+
/** Bind a validated Resend client. */
|
|
118
|
+
constructor(client) {
|
|
119
|
+
this.client = client;
|
|
120
|
+
}
|
|
121
|
+
client;
|
|
122
|
+
/** Return the generated operation contract. */
|
|
123
|
+
definition() {
|
|
124
|
+
return GetEmailDefinition;
|
|
125
|
+
}
|
|
126
|
+
/** Validate, retrieve, and classify one attempt. */
|
|
127
|
+
async invoke(call, input) {
|
|
128
|
+
const operation = "getEmail";
|
|
129
|
+
if (!input?.id) return newQueryBranch("defect", emptyEmail, {}, failure(operation, "VALIDATION", "email ID is required"));
|
|
130
|
+
const { apiKey, isTransient } = await this.client.resolveAPIKeyResolution(call);
|
|
131
|
+
if (isTransient) return newQueryRetry(failure(operation, "AVAILABILITY", "connection credentials are temporarily unavailable"));
|
|
132
|
+
if (!apiKey) return credentialDefect(operation, emptyEmail);
|
|
133
|
+
let response;
|
|
134
|
+
try {
|
|
135
|
+
response = await this.client.exchange(call, apiKey, "GET", `/emails/${goPathEscape(input.id)}`);
|
|
136
|
+
} catch {
|
|
137
|
+
return newQueryRetry(failure(operation, "AVAILABILITY", "provider request failed"));
|
|
138
|
+
}
|
|
139
|
+
const retry = retryResponse(operation, response);
|
|
140
|
+
if (retry) return newQueryRetry(retry.failure, retry.delay);
|
|
141
|
+
if (response.status === 404) return newQueryBranch("notFound", emptyEmail, {}, failure(operation, "NOT_FOUND", "provider resource was not found"));
|
|
142
|
+
if (response.status !== 200) return newQueryBranch("providerRejected", emptyEmail, {}, failure(operation, "PROVIDER_REJECTION", `provider rejected the request with HTTP ${response.status}`));
|
|
143
|
+
if (response.isTooLarge) return invalidQuery(operation, "RESPONSE_TOO_LARGE");
|
|
144
|
+
try {
|
|
145
|
+
const document = decodeObject(response.body);
|
|
146
|
+
const required = document.id;
|
|
147
|
+
if (typeof required !== "string" || !required) throw new TypeError("email ID missing");
|
|
148
|
+
const from = stringField(document, "from");
|
|
149
|
+
const subject = stringField(document, "subject");
|
|
150
|
+
const createdAt = stringField(document, "created_at");
|
|
151
|
+
const to = document.to === void 0 || document.to === null ? [] : document.to;
|
|
152
|
+
if (!Array.isArray(to) || to.some((value) => typeof value !== "string")) throw new TypeError("invalid recipients");
|
|
153
|
+
return newQueryBranch("found", { id: required, from, to, subject, created_at: createdAt }, {});
|
|
154
|
+
} catch {
|
|
155
|
+
return invalidQuery(operation, "PROTOCOL");
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
function failure(operation, kind, message) {
|
|
160
|
+
return { provider: "resend", operation, kind, message };
|
|
161
|
+
}
|
|
162
|
+
function credentialDefect(operation, empty) {
|
|
163
|
+
return newQueryBranch("defect", empty, {}, failure(operation, "AUTHENTICATION", "connection credentials or request are invalid"));
|
|
164
|
+
}
|
|
165
|
+
function retryResponse(operation, response) {
|
|
166
|
+
if (response.status !== 429 && response.status !== 408 && response.status < 500) return void 0;
|
|
167
|
+
const isRateLimit = response.status === 429;
|
|
168
|
+
const header = response.headers["retry-after"];
|
|
169
|
+
return { failure: failure(operation, isRateLimit ? "RATE_LIMIT" : "AVAILABILITY", isRateLimit ? "provider rate limited the request" : "provider is temporarily unavailable"), delay: parseRetryAfter(Array.isArray(header) ? header[0] ?? "" : header ?? "") };
|
|
170
|
+
}
|
|
171
|
+
function invalidQuery(operation, kind) {
|
|
172
|
+
return newQueryBranch("invalidResponse", emptyEmail, {}, failure(operation, kind, kind === "PROTOCOL" ? "provider response is incomplete or malformed" : "provider response exceeded the configured limit"));
|
|
173
|
+
}
|
|
174
|
+
function decodeObject(body) {
|
|
175
|
+
const value = JSON.parse(Buffer.from(body).toString("utf8"));
|
|
176
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) throw new TypeError("invalid response object");
|
|
177
|
+
return value;
|
|
178
|
+
}
|
|
179
|
+
function stringField(document, name) {
|
|
180
|
+
const value = document[name];
|
|
181
|
+
if (value === void 0 || value === null) return "";
|
|
182
|
+
if (typeof value !== "string") throw new TypeError("invalid response field");
|
|
183
|
+
return value;
|
|
184
|
+
}
|
|
185
|
+
function goPathEscape(value) {
|
|
186
|
+
let result = "";
|
|
187
|
+
for (const byte of Buffer.from(value, "utf8")) {
|
|
188
|
+
if (byte >= 65 && byte <= 90 || byte >= 97 && byte <= 122 || byte >= 48 && byte <= 57 || "-._~$&+:=@".includes(String.fromCharCode(byte))) result += String.fromCharCode(byte);
|
|
189
|
+
else result += `%${byte.toString(16).toUpperCase().padStart(2, "0")}`;
|
|
190
|
+
}
|
|
191
|
+
return result;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// src/client.ts
|
|
195
|
+
var publicEndpoint = "https://api.resend.com";
|
|
196
|
+
var ResendClient = class {
|
|
197
|
+
endpoint;
|
|
198
|
+
timeoutMs;
|
|
199
|
+
maxResponseBytes;
|
|
200
|
+
credentials;
|
|
201
|
+
send;
|
|
202
|
+
/** Validate local configuration without calling Resend. */
|
|
203
|
+
constructor(config, credentials, options = {}) {
|
|
204
|
+
if (!config || !credentials) throw new TypeError("Resend configuration and credentials are required");
|
|
205
|
+
this.endpoint = validateBaseURL(config.baseUrl || publicEndpoint);
|
|
206
|
+
this.timeoutMs = config.timeoutMs || 15e3;
|
|
207
|
+
this.maxResponseBytes = config.maxResponseBytes || 2097152;
|
|
208
|
+
if (!Number.isSafeInteger(this.timeoutMs) || this.timeoutMs < 0 || !Number.isSafeInteger(this.maxResponseBytes) || this.maxResponseBytes < 0) {
|
|
209
|
+
throw new TypeError("Resend timeout and response limit must be nonnegative integers");
|
|
210
|
+
}
|
|
211
|
+
this.credentials = credentials;
|
|
212
|
+
this.send = options.send ?? sendProviderRequest;
|
|
213
|
+
}
|
|
214
|
+
/** Bind the keyed send mutation. */
|
|
215
|
+
sendEmail() {
|
|
216
|
+
return new SendEmailOperation(this);
|
|
217
|
+
}
|
|
218
|
+
/** Bind the email lookup query. */
|
|
219
|
+
getEmail() {
|
|
220
|
+
return new GetEmailOperation(this);
|
|
221
|
+
}
|
|
222
|
+
/** Resolve a safe API key; invalid and unavailable credentials are terminal. */
|
|
223
|
+
async resolveAPIKey(call) {
|
|
224
|
+
return (await this.resolveAPIKeyResolution(call)).apiKey;
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Resolve a safe API key, or report whether the failure may clear on a later attempt. Only reauthorization,
|
|
228
|
+
* a missing or unselected connection, a broker refusal, and unusable material are terminal.
|
|
229
|
+
*/
|
|
230
|
+
async resolveAPIKeyResolution(call) {
|
|
231
|
+
let credentials;
|
|
232
|
+
try {
|
|
233
|
+
credentials = await this.credentials.resolve(call, call.context.cancellationSignal);
|
|
234
|
+
} catch (error) {
|
|
235
|
+
return { isTransient: !isTerminalCredentialError(error) };
|
|
236
|
+
}
|
|
237
|
+
if (!(credentials?.apiKey instanceof SecretString)) return { isTransient: false };
|
|
238
|
+
const key = credentials.apiKey.reveal();
|
|
239
|
+
return key.trim() && isHeaderSafeCredential(key) ? { apiKey: key, isTransient: false } : { isTransient: false };
|
|
240
|
+
}
|
|
241
|
+
/** Send one no-redirect request with Resend's authentication and content headers. */
|
|
242
|
+
async exchange(call, apiKey, method, path, body) {
|
|
243
|
+
const headers = { Authorization: `Bearer ${apiKey}`, Accept: "application/json", "User-Agent": "superdurable-resend/0.1" };
|
|
244
|
+
if (body) headers["Content-Type"] = "application/json";
|
|
245
|
+
if (method === "POST") headers["Idempotency-Key"] = call.idempotencyKey ?? "";
|
|
246
|
+
const request = {
|
|
247
|
+
url: this.endpoint + path,
|
|
248
|
+
method,
|
|
249
|
+
headers,
|
|
250
|
+
maxResponseBytes: this.maxResponseBytes,
|
|
251
|
+
addressPolicy: this.endpoint === publicEndpoint ? "publicHTTPS" : "privateNetworkHTTP",
|
|
252
|
+
timeoutMs: this.timeoutMs,
|
|
253
|
+
signal: call.context.cancellationSignal,
|
|
254
|
+
...body ? { body } : {}
|
|
255
|
+
};
|
|
256
|
+
try {
|
|
257
|
+
return { ...await this.send(request), isTooLarge: false };
|
|
258
|
+
} catch (error) {
|
|
259
|
+
if (error instanceof BodyTooLargeError && error.status !== void 0 && error.headers !== void 0) {
|
|
260
|
+
return { status: error.status, headers: error.headers, body: new Uint8Array(), isTooLarge: true };
|
|
261
|
+
}
|
|
262
|
+
throw error;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
function isTerminalCredentialError(error) {
|
|
267
|
+
return error instanceof ReauthorizationRequiredError || error instanceof ObjectNotFoundError || error instanceof ConnectionNotSelectedError || error instanceof CredentialBrokerRejectedError || error instanceof z.ZodError || isCredentialMaterialError(error);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
// src/project.ts
|
|
271
|
+
var projectSettingsSchema = z2.strictObject({
|
|
272
|
+
baseUrl: z2.string().optional(),
|
|
273
|
+
timeout: z2.union([z2.string(), z2.number().int()]).optional(),
|
|
274
|
+
maxResponseBytes: z2.number().int().optional()
|
|
275
|
+
});
|
|
276
|
+
function newProjectConnection2(project, connectionName, options = {}) {
|
|
277
|
+
return newProjectConnection(project, connectionName, (loadedProject, name) => {
|
|
278
|
+
const selected = loadedProject.configuration.connections.find((entry) => entry.connectorId === "resend" && entry.connectionName === name);
|
|
279
|
+
if (!selected) throw new TypeError("Resend project connection is not configured");
|
|
280
|
+
const settings = projectSettingsSchema.parse(selected.configuration);
|
|
281
|
+
const timeoutMs = typeof settings.timeout === "number" ? Math.ceil(settings.timeout / 1e6) : settings.timeout !== void 0 ? parseDurationMilliseconds(settings.timeout) : void 0;
|
|
282
|
+
if (timeoutMs !== void 0 && (!Number.isSafeInteger(timeoutMs) || timeoutMs <= 0)) {
|
|
283
|
+
throw new TypeError("Resend timeout must resolve to positive whole milliseconds");
|
|
284
|
+
}
|
|
285
|
+
const config = {
|
|
286
|
+
...settings.baseUrl !== void 0 ? { baseUrl: settings.baseUrl } : {},
|
|
287
|
+
...timeoutMs !== void 0 ? { timeoutMs } : {},
|
|
288
|
+
...settings.maxResponseBytes !== void 0 ? { maxResponseBytes: settings.maxResponseBytes } : {}
|
|
289
|
+
};
|
|
290
|
+
const credentials = {
|
|
291
|
+
async resolve(call, signal) {
|
|
292
|
+
void call;
|
|
293
|
+
const fields = await loadedProject.resolveCredential("resend", name, signal);
|
|
294
|
+
const decoded = z2.object({ api_key: z2.string().min(1) }).parse(fields);
|
|
295
|
+
return { apiKey: new SecretString2(decoded.api_key) };
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
return new ResendClient(config, credentials, options);
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
function parseDurationMilliseconds(value) {
|
|
302
|
+
let remaining = value;
|
|
303
|
+
let milliseconds = 0;
|
|
304
|
+
const units = { ns: 1e-6, us: 1e-3, "\xB5s": 1e-3, ms: 1, s: 1e3, m: 6e4, h: 36e5 };
|
|
305
|
+
while (remaining) {
|
|
306
|
+
const component = /^(\d+(?:\.\d+)?)(ns|us|µs|ms|s|m|h)/.exec(remaining);
|
|
307
|
+
if (!component) throw new TypeError("Resend timeout must be a positive Go duration");
|
|
308
|
+
milliseconds += Number(component[1]) * (units[component[2] ?? ""] ?? NaN);
|
|
309
|
+
remaining = remaining.slice(component[0].length);
|
|
310
|
+
}
|
|
311
|
+
if (!Number.isSafeInteger(milliseconds) || milliseconds <= 0) throw new TypeError("Resend timeout must resolve to positive whole milliseconds");
|
|
312
|
+
return milliseconds;
|
|
313
|
+
}
|
|
314
|
+
export {
|
|
315
|
+
ConfigSchema,
|
|
316
|
+
Connection,
|
|
317
|
+
ConnectorID,
|
|
318
|
+
CredentialMaterialError,
|
|
319
|
+
EmailSchema,
|
|
320
|
+
GetEmailBranch,
|
|
321
|
+
GetEmailBranchDefect,
|
|
322
|
+
GetEmailBranchFound,
|
|
323
|
+
GetEmailBranchInvalidResponse,
|
|
324
|
+
GetEmailBranchNotFound,
|
|
325
|
+
GetEmailBranchProviderRejected,
|
|
326
|
+
GetEmailDefinition,
|
|
327
|
+
GetEmailInputSchema,
|
|
328
|
+
GetEmailMetadata,
|
|
329
|
+
GetEmailOperation,
|
|
330
|
+
ProviderID,
|
|
331
|
+
ResendClient,
|
|
332
|
+
SendEmailBranch,
|
|
333
|
+
SendEmailBranchDefect,
|
|
334
|
+
SendEmailBranchInvalidResponse,
|
|
335
|
+
SendEmailBranchProviderRejected,
|
|
336
|
+
SendEmailBranchSent,
|
|
337
|
+
SendEmailDefinition,
|
|
338
|
+
SendEmailInputSchema,
|
|
339
|
+
SendEmailMetadata,
|
|
340
|
+
SendEmailOperation,
|
|
341
|
+
SentEmailSchema,
|
|
342
|
+
decodeCredentials,
|
|
343
|
+
isCredentialMaterialError,
|
|
344
|
+
newConnection,
|
|
345
|
+
newConnectionWithOperations,
|
|
346
|
+
newGetEmailStep,
|
|
347
|
+
newProjectConnection2 as newProjectConnection,
|
|
348
|
+
newSendEmailStep
|
|
349
|
+
};
|
package/dist/mock.d.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { MockMutation, MockQuery, Case } from '@superdurable/connectors-sdk/connectormock';
|
|
2
|
+
import { Failure } from '@superdurable/connectors-sdk';
|
|
3
|
+
import { O as Operations, C as Connection, S as SendEmailInput, a as SentEmail, G as GetEmailInput, E as Email } from './connection-DSFknakP.js';
|
|
4
|
+
import 'zod';
|
|
5
|
+
|
|
6
|
+
/** Go zero value for SendEmailInput in scripted cases. */
|
|
7
|
+
declare const emptySendEmailInput: SendEmailInput;
|
|
8
|
+
/** Go zero value for SentEmail in scripted cases. */
|
|
9
|
+
declare const emptySentEmail: SentEmail;
|
|
10
|
+
/** Go zero value for GetEmailInput in scripted cases. */
|
|
11
|
+
declare const emptyGetEmailInput: GetEmailInput;
|
|
12
|
+
/** Go zero value for Email in scripted cases. */
|
|
13
|
+
declare const emptyEmail: Email;
|
|
14
|
+
/** Script the sent branch. */
|
|
15
|
+
declare function sendEmailSent(value: SentEmail, failure?: Failure): Case<SentEmail>;
|
|
16
|
+
/** Script the providerRejected branch. */
|
|
17
|
+
declare function sendEmailProviderRejected(value: SentEmail, failure?: Failure): Case<SentEmail>;
|
|
18
|
+
/** Script the invalidResponse branch. */
|
|
19
|
+
declare function sendEmailInvalidResponse(value: SentEmail, failure?: Failure): Case<SentEmail>;
|
|
20
|
+
/** Script the defect branch. */
|
|
21
|
+
declare function sendEmailDefect(value: SentEmail, failure?: Failure): Case<SentEmail>;
|
|
22
|
+
/** Script a safe retry of sendEmail. */
|
|
23
|
+
declare function sendEmailRetry(failure: Failure, retryAfterMs?: number): Case<SentEmail>;
|
|
24
|
+
/** Manifest scenario sendEmailDefault for sendEmail. */
|
|
25
|
+
declare function sendEmailSendEmailDefault(): Case<SentEmail>;
|
|
26
|
+
/** Default sendEmail scenario. */
|
|
27
|
+
declare function sendEmailDefault(): Case<SentEmail>;
|
|
28
|
+
/** Script the found branch. */
|
|
29
|
+
declare function getEmailFound(value: Email, failure?: Failure): Case<Email>;
|
|
30
|
+
/** Script the notFound branch. */
|
|
31
|
+
declare function getEmailNotFound(value: Email, failure?: Failure): Case<Email>;
|
|
32
|
+
/** Script the providerRejected branch. */
|
|
33
|
+
declare function getEmailProviderRejected(value: Email, failure?: Failure): Case<Email>;
|
|
34
|
+
/** Script the invalidResponse branch. */
|
|
35
|
+
declare function getEmailInvalidResponse(value: Email, failure?: Failure): Case<Email>;
|
|
36
|
+
/** Script the defect branch. */
|
|
37
|
+
declare function getEmailDefect(value: Email, failure?: Failure): Case<Email>;
|
|
38
|
+
/** Script a safe retry of getEmail. */
|
|
39
|
+
declare function getEmailRetry(failure: Failure, retryAfterMs?: number): Case<Email>;
|
|
40
|
+
/** Manifest scenario getEmailDefault for getEmail. */
|
|
41
|
+
declare function getEmailGetEmailDefault(): Case<Email>;
|
|
42
|
+
/** Default getEmail scenario. */
|
|
43
|
+
declare function getEmailDefault(): Case<Email>;
|
|
44
|
+
/** Scripted operations and manifest defaults for this connector. */
|
|
45
|
+
declare class GeneratedMock implements Operations {
|
|
46
|
+
#private;
|
|
47
|
+
constructor(connectionName: string);
|
|
48
|
+
connection(): Connection;
|
|
49
|
+
sendEmail(): MockMutation<SendEmailInput, SentEmail>;
|
|
50
|
+
getEmail(): MockQuery<GetEmailInput, Email>;
|
|
51
|
+
assertNoFailures(): void;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export { GeneratedMock, emptyEmail, emptyGetEmailInput, emptySendEmailInput, emptySentEmail, getEmailDefault, getEmailDefect, getEmailFound, getEmailGetEmailDefault, getEmailInvalidResponse, getEmailNotFound, getEmailProviderRejected, getEmailRetry, sendEmailDefault, sendEmailDefect, sendEmailInvalidResponse, sendEmailProviderRejected, sendEmailRetry, sendEmailSendEmailDefault, sendEmailSent };
|
package/dist/mock.js
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import {
|
|
2
|
+
EmailSchema,
|
|
3
|
+
GetEmailDefinition,
|
|
4
|
+
GetEmailInputSchema,
|
|
5
|
+
ProviderID,
|
|
6
|
+
SendEmailDefinition,
|
|
7
|
+
SendEmailInputSchema,
|
|
8
|
+
SentEmailSchema,
|
|
9
|
+
newConnectionWithOperations
|
|
10
|
+
} from "./chunk-GNJAHMSJ.js";
|
|
11
|
+
|
|
12
|
+
// src/generated/mock.ts
|
|
13
|
+
import { branchCase, retryCase, newMutation, newQuery } from "@superdurable/connectors-sdk/connectormock";
|
|
14
|
+
var emptySendEmailInput = SendEmailInputSchema.parse({
|
|
15
|
+
"from": "",
|
|
16
|
+
"to": [],
|
|
17
|
+
"subject": "",
|
|
18
|
+
"html": ""
|
|
19
|
+
});
|
|
20
|
+
var emptySentEmail = SentEmailSchema.parse({
|
|
21
|
+
"id": ""
|
|
22
|
+
});
|
|
23
|
+
var emptyGetEmailInput = GetEmailInputSchema.parse({
|
|
24
|
+
"id": ""
|
|
25
|
+
});
|
|
26
|
+
var emptyEmail = EmailSchema.parse({
|
|
27
|
+
"id": "",
|
|
28
|
+
"from": "",
|
|
29
|
+
"to": [],
|
|
30
|
+
"subject": "",
|
|
31
|
+
"created_at": ""
|
|
32
|
+
});
|
|
33
|
+
function sendEmailSent(value, failure) {
|
|
34
|
+
return branchCase("sent", value, failure);
|
|
35
|
+
}
|
|
36
|
+
function sendEmailProviderRejected(value, failure) {
|
|
37
|
+
return branchCase("providerRejected", value, failure);
|
|
38
|
+
}
|
|
39
|
+
function sendEmailInvalidResponse(value, failure) {
|
|
40
|
+
return branchCase("invalidResponse", value, failure);
|
|
41
|
+
}
|
|
42
|
+
function sendEmailDefect(value, failure) {
|
|
43
|
+
return branchCase("defect", value, failure);
|
|
44
|
+
}
|
|
45
|
+
function sendEmailRetry(failure, retryAfterMs = 0) {
|
|
46
|
+
return retryCase(failure, retryAfterMs);
|
|
47
|
+
}
|
|
48
|
+
function sendEmailSendEmailDefault() {
|
|
49
|
+
const value = SentEmailSchema.parse({ "id": "5f9f777d-04e0-482a-bb65-088bb5bd44a4" });
|
|
50
|
+
return branchCase("sent", value);
|
|
51
|
+
}
|
|
52
|
+
function sendEmailDefault() {
|
|
53
|
+
return sendEmailSendEmailDefault();
|
|
54
|
+
}
|
|
55
|
+
function getEmailFound(value, failure) {
|
|
56
|
+
return branchCase("found", value, failure);
|
|
57
|
+
}
|
|
58
|
+
function getEmailNotFound(value, failure) {
|
|
59
|
+
return branchCase("notFound", value, failure);
|
|
60
|
+
}
|
|
61
|
+
function getEmailProviderRejected(value, failure) {
|
|
62
|
+
return branchCase("providerRejected", value, failure);
|
|
63
|
+
}
|
|
64
|
+
function getEmailInvalidResponse(value, failure) {
|
|
65
|
+
return branchCase("invalidResponse", value, failure);
|
|
66
|
+
}
|
|
67
|
+
function getEmailDefect(value, failure) {
|
|
68
|
+
return branchCase("defect", value, failure);
|
|
69
|
+
}
|
|
70
|
+
function getEmailRetry(failure, retryAfterMs = 0) {
|
|
71
|
+
return retryCase(failure, retryAfterMs);
|
|
72
|
+
}
|
|
73
|
+
function getEmailGetEmailDefault() {
|
|
74
|
+
const value = EmailSchema.parse({ "created_at": "2026-10-26T12:00:00Z", "from": "Acme <hello@example.test>", "id": "5f9f777d-04e0-482a-bb65-088bb5bd44a4", "subject": "Welcome", "to": ["reader@example.test"] });
|
|
75
|
+
return branchCase("found", value);
|
|
76
|
+
}
|
|
77
|
+
function getEmailDefault() {
|
|
78
|
+
return getEmailGetEmailDefault();
|
|
79
|
+
}
|
|
80
|
+
var GeneratedMock = class {
|
|
81
|
+
#sendEmail;
|
|
82
|
+
#getEmail;
|
|
83
|
+
#connection;
|
|
84
|
+
constructor(connectionName) {
|
|
85
|
+
this.#sendEmail = newMutation(SendEmailDefinition).default(sendEmailDefault());
|
|
86
|
+
this.#getEmail = newQuery(GetEmailDefinition).default(getEmailDefault());
|
|
87
|
+
this.#connection = newConnectionWithOperations(this, { provider: ProviderID, name: connectionName });
|
|
88
|
+
}
|
|
89
|
+
connection() {
|
|
90
|
+
return this.#connection;
|
|
91
|
+
}
|
|
92
|
+
sendEmail() {
|
|
93
|
+
return this.#sendEmail;
|
|
94
|
+
}
|
|
95
|
+
getEmail() {
|
|
96
|
+
return this.#getEmail;
|
|
97
|
+
}
|
|
98
|
+
assertNoFailures() {
|
|
99
|
+
this.#sendEmail.assertNoFailures();
|
|
100
|
+
this.#getEmail.assertNoFailures();
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
export {
|
|
104
|
+
GeneratedMock,
|
|
105
|
+
emptyEmail,
|
|
106
|
+
emptyGetEmailInput,
|
|
107
|
+
emptySendEmailInput,
|
|
108
|
+
emptySentEmail,
|
|
109
|
+
getEmailDefault,
|
|
110
|
+
getEmailDefect,
|
|
111
|
+
getEmailFound,
|
|
112
|
+
getEmailGetEmailDefault,
|
|
113
|
+
getEmailInvalidResponse,
|
|
114
|
+
getEmailNotFound,
|
|
115
|
+
getEmailProviderRejected,
|
|
116
|
+
getEmailRetry,
|
|
117
|
+
sendEmailDefault,
|
|
118
|
+
sendEmailDefect,
|
|
119
|
+
sendEmailInvalidResponse,
|
|
120
|
+
sendEmailProviderRejected,
|
|
121
|
+
sendEmailRetry,
|
|
122
|
+
sendEmailSendEmailDefault,
|
|
123
|
+
sendEmailSent
|
|
124
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,63 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superdurable/connector-resend",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Resend email operations for Dex Flows",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/superdurable/dex-connectors-library.git",
|
|
8
|
+
"directory": "connectors/resend/typescript"
|
|
9
|
+
},
|
|
10
|
+
"type": "module",
|
|
11
|
+
"publishConfig": {
|
|
12
|
+
"access": "public",
|
|
13
|
+
"registry": "https://registry.npmjs.org"
|
|
14
|
+
},
|
|
15
|
+
"engines": {
|
|
16
|
+
"node": "^22.0.0 || ^24.0.0"
|
|
17
|
+
},
|
|
18
|
+
"module": "./dist/index.js",
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"import": "./dist/index.js"
|
|
24
|
+
},
|
|
25
|
+
"./mock": {
|
|
26
|
+
"types": "./dist/mock.d.ts",
|
|
27
|
+
"import": "./dist/mock.js"
|
|
28
|
+
},
|
|
29
|
+
"./dex-connector.json": "./dex-connector.json"
|
|
30
|
+
},
|
|
31
|
+
"files": [
|
|
32
|
+
"dist",
|
|
33
|
+
"dex-connector.json",
|
|
34
|
+
"README.md",
|
|
35
|
+
"LICENSE"
|
|
36
|
+
],
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "tsup src/index.ts src/mock.ts --format esm --dts --clean",
|
|
39
|
+
"typecheck": "tsc --noEmit",
|
|
40
|
+
"lint": "eslint src test examples",
|
|
41
|
+
"test": "npm run build && vitest run --exclude 'test/integration/**'",
|
|
42
|
+
"check": "npm test && npm run typecheck && npm run lint",
|
|
43
|
+
"example:welcome": "npm run build && tsx examples/welcome-email/main.ts",
|
|
44
|
+
"integration:welcome": "npm run build && tsx examples/welcome-email/integration.ts"
|
|
45
|
+
},
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"@superdurable/connectors-sdk": "0.1.0",
|
|
48
|
+
"@superdurable/dex": ">=1.28.0",
|
|
49
|
+
"zod": "^4.1.0"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@eslint/js": "^9.0.0",
|
|
53
|
+
"@types/node": "^22.0.0",
|
|
54
|
+
"eslint": "^9.0.0",
|
|
55
|
+
"tsup": "^8.0.0",
|
|
56
|
+
"tsx": "^4.23.15",
|
|
57
|
+
"typescript": "^5.9.0",
|
|
58
|
+
"typescript-eslint": "^8.0.0",
|
|
59
|
+
"vitest": "^3.0.0",
|
|
60
|
+
"yaml": "^2.9.1"
|
|
61
|
+
},
|
|
62
|
+
"license": "MIT"
|
|
63
|
+
}
|