@superdurable/connector-brevo 0.0.0-stage → 0.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/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,25 @@
1
- # Temporary Holding Version
1
+ # Brevo TypeScript connector
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Install `@superdurable/connector-brevo@0.1.0` for Dex TypeScript applications.
4
+ The package implements `createOrUpdateContact` and `getContact`, and exports
5
+ typed Step factories, connection helpers, generated models, and manifest mocks.
6
+ Both operations accept plain RFC 5322 addresses using the same parsed-address check as the Go connector.
7
+
8
+ The [contact sync example](examples/contact-sync) is the runnable application.
9
+ It binds a Dex Web connection named `brevo-contacts`, writes a contact by email,
10
+ reads the contact back, and returns its ID and email. The API key is resolved
11
+ privately for each call. Configure it in [Brevo API keys](https://app.brevo.com/settings/keys/api)
12
+ under **Settings > SMTP & API > API keys**; do not put it in Flow input.
13
+
14
+ `createOrUpdateContact` retries transport failures, 408, 409, 429, and 5xx.
15
+ Brevo's `updateEnabled` option makes the write repeatable. A 201 response returns
16
+ its new ID; a 204 update returns the email and `created: false`. `getContact`
17
+ returns `notFound` for 404. Malformed or oversized responses choose
18
+ `invalidResponse`; local validation chooses `defect`. Other provider rejections
19
+ choose `providerRejected`. Optional branches are unwired by default and fail
20
+ the Flow when selected.
21
+
22
+ Run `npm ci`, `npm run check`, and the example's real Dex integration test.
23
+ Go-recorded provider scenarios are in
24
+ [`conformance/connectors/brevo/scenarios.json`](../../../conformance/connectors/brevo/scenarios.json).
25
+ Live Brevo authorization and real-provider calls have not been verified.
@@ -0,0 +1,82 @@
1
+ {
2
+ "connectorId": "brevo",
3
+ "releaseTag": "connectors/brevo/go/v0.2.0",
4
+ "package": {
5
+ "ecosystem": "npm",
6
+ "name": "@superdurable/connector-brevo",
7
+ "version": "0.1.0"
8
+ },
9
+ "factories": [
10
+ {
11
+ "name": "newCreateOrUpdateContactStep",
12
+ "kind": "mutation",
13
+ "operationId": "createOrUpdateContact",
14
+ "fields": {
15
+ "stepType": "stepType",
16
+ "annotations": "annotations",
17
+ "connectionName": "connectionName",
18
+ "resultAttribute": "resultAttribute"
19
+ },
20
+ "branches": [
21
+ {
22
+ "id": "saved",
23
+ "field": "saved",
24
+ "optional": false
25
+ },
26
+ {
27
+ "id": "providerRejected",
28
+ "field": "providerRejected",
29
+ "optional": true
30
+ },
31
+ {
32
+ "id": "invalidResponse",
33
+ "field": "invalidResponse",
34
+ "optional": true
35
+ },
36
+ {
37
+ "id": "defect",
38
+ "field": "defect",
39
+ "optional": true
40
+ }
41
+ ]
42
+ },
43
+ {
44
+ "name": "newGetContactStep",
45
+ "kind": "query",
46
+ "operationId": "getContact",
47
+ "fields": {
48
+ "stepType": "stepType",
49
+ "annotations": "annotations",
50
+ "connectionName": "connectionName",
51
+ "resultAttribute": "resultAttribute"
52
+ },
53
+ "branches": [
54
+ {
55
+ "id": "found",
56
+ "field": "found",
57
+ "optional": false
58
+ },
59
+ {
60
+ "id": "notFound",
61
+ "field": "notFound",
62
+ "optional": true
63
+ },
64
+ {
65
+ "id": "providerRejected",
66
+ "field": "providerRejected",
67
+ "optional": true
68
+ },
69
+ {
70
+ "id": "invalidResponse",
71
+ "field": "invalidResponse",
72
+ "optional": true
73
+ },
74
+ {
75
+ "id": "defect",
76
+ "field": "defect",
77
+ "optional": true
78
+ }
79
+ ]
80
+ }
81
+ ]
82
+ }
@@ -0,0 +1,131 @@
1
+ // src/generated/models.ts
2
+ import { z } from "zod";
3
+ var ConfigSchema = z.object({
4
+ "baseUrl": z.string().optional(),
5
+ "timeoutMs": z.number().int().optional(),
6
+ "maxResponseBytes": z.number().int().optional()
7
+ });
8
+ var CreateOrUpdateContactInputSchema = z.strictObject({
9
+ "email": z.string(),
10
+ "attributes": z.record(z.string(), z.string()).optional()
11
+ });
12
+ var ContactWriteResultSchema = z.strictObject({
13
+ "id": z.number().int().optional(),
14
+ "email": z.string(),
15
+ "created": z.boolean()
16
+ });
17
+ var GetContactInputSchema = z.strictObject({
18
+ "email": z.string()
19
+ });
20
+ var ContactSchema = z.strictObject({
21
+ "id": z.number().int(),
22
+ "email": z.string()
23
+ });
24
+
25
+ // src/generated/definitions.ts
26
+ var ConnectorID = "brevo";
27
+ var ProviderID = "brevo";
28
+ var CreateOrUpdateContactBranch = {
29
+ Saved: "saved",
30
+ ProviderRejected: "providerRejected",
31
+ InvalidResponse: "invalidResponse",
32
+ Defect: "defect"
33
+ };
34
+ var CreateOrUpdateContactBranchSaved = CreateOrUpdateContactBranch.Saved;
35
+ var CreateOrUpdateContactBranchProviderRejected = CreateOrUpdateContactBranch.ProviderRejected;
36
+ var CreateOrUpdateContactBranchInvalidResponse = CreateOrUpdateContactBranch.InvalidResponse;
37
+ var CreateOrUpdateContactBranchDefect = CreateOrUpdateContactBranch.Defect;
38
+ var CreateOrUpdateContactDefinition = {
39
+ operation: { connectorId: ConnectorID, operationId: "createOrUpdateContact" },
40
+ branches: [
41
+ { id: "saved", description: "Brevo created or updated the contact." },
42
+ { id: "providerRejected", description: "Brevo rejected the contact or credentials.", optional: true },
43
+ { id: "invalidResponse", description: "Brevo returned malformed or oversized data.", optional: true },
44
+ { id: "defect", description: "Local input or credentials are invalid.", optional: true }
45
+ ],
46
+ stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "async" }
47
+ };
48
+ var CreateOrUpdateContactMetadata = { kind: "mutation", idempotency: "required", authorization: "required" };
49
+ var GetContactBranch = {
50
+ Found: "found",
51
+ NotFound: "notFound",
52
+ ProviderRejected: "providerRejected",
53
+ InvalidResponse: "invalidResponse",
54
+ Defect: "defect"
55
+ };
56
+ var GetContactBranchFound = GetContactBranch.Found;
57
+ var GetContactBranchNotFound = GetContactBranch.NotFound;
58
+ var GetContactBranchProviderRejected = GetContactBranch.ProviderRejected;
59
+ var GetContactBranchInvalidResponse = GetContactBranch.InvalidResponse;
60
+ var GetContactBranchDefect = GetContactBranch.Defect;
61
+ var GetContactDefinition = {
62
+ operation: { connectorId: ConnectorID, operationId: "getContact" },
63
+ branches: [
64
+ { id: "found", description: "Brevo returned the contact." },
65
+ { id: "notFound", description: "No contact has that email.", optional: true },
66
+ { id: "providerRejected", description: "Brevo rejected the request or credentials.", optional: true },
67
+ { id: "invalidResponse", description: "Brevo returned malformed or oversized data.", optional: true },
68
+ { id: "defect", description: "Local input or credentials are invalid.", optional: true }
69
+ ],
70
+ stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "async" }
71
+ };
72
+ var GetContactMetadata = { kind: "query", idempotency: "none", authorization: "required" };
73
+
74
+ // src/generated/connection.ts
75
+ import { ConnectionRefSchema } from "@superdurable/connectors-sdk";
76
+ var Connection = class {
77
+ /** Stable provider and connection name. */
78
+ reference;
79
+ /** Bound provider operations. */
80
+ operations;
81
+ /** Validate a reference and bind operations. */
82
+ constructor(reference, operations) {
83
+ this.reference = ConnectionRefSchema.parse(reference);
84
+ if (this.reference.provider !== ProviderID) throw new TypeError("connection provider differs from the manifest");
85
+ if (!operations) throw new TypeError("connector operations are required");
86
+ this.operations = operations;
87
+ }
88
+ };
89
+ function newConnection(client, reference) {
90
+ if (!client) throw new TypeError("connector client is required");
91
+ return new Connection(reference, client);
92
+ }
93
+ function newConnectionWithOperations(operations, reference) {
94
+ return new Connection(reference, operations);
95
+ }
96
+ function newProjectConnection(project, connectionName, createClient) {
97
+ if (!project) throw new TypeError("loaded project is required");
98
+ const reference = ConnectionRefSchema.parse({ provider: ProviderID, name: connectionName });
99
+ const selected = project.configuration.connections.find((entry) => entry.connectorId === ConnectorID && entry.connectionName === connectionName);
100
+ if (!selected || selected.provider !== ProviderID) throw new TypeError("project connection is not configured");
101
+ return newConnection(createClient(project, connectionName), reference);
102
+ }
103
+
104
+ export {
105
+ ConfigSchema,
106
+ CreateOrUpdateContactInputSchema,
107
+ ContactWriteResultSchema,
108
+ GetContactInputSchema,
109
+ ContactSchema,
110
+ ConnectorID,
111
+ ProviderID,
112
+ CreateOrUpdateContactBranch,
113
+ CreateOrUpdateContactBranchSaved,
114
+ CreateOrUpdateContactBranchProviderRejected,
115
+ CreateOrUpdateContactBranchInvalidResponse,
116
+ CreateOrUpdateContactBranchDefect,
117
+ CreateOrUpdateContactDefinition,
118
+ CreateOrUpdateContactMetadata,
119
+ GetContactBranch,
120
+ GetContactBranchFound,
121
+ GetContactBranchNotFound,
122
+ GetContactBranchProviderRejected,
123
+ GetContactBranchInvalidResponse,
124
+ GetContactBranchDefect,
125
+ GetContactDefinition,
126
+ GetContactMetadata,
127
+ Connection,
128
+ newConnection,
129
+ newConnectionWithOperations,
130
+ newProjectConnection
131
+ };
@@ -0,0 +1,98 @@
1
+ import { SecretString, CredentialProvider, 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
+ /** Brevo v3 API base URL; leave blank for the public endpoint, or enter a compatible HTTPS gateway URL for a custom deployment. */
7
+ baseUrl?: string;
8
+ /** Positive Go duration limiting each HTTP request; leave blank for the displayed default, or override for a slower network. Runtime value in milliseconds. */
9
+ timeoutMs?: number;
10
+ /** Maximum response bytes as a positive integer; leave blank for the displayed safety limit, or raise it for larger contact responses. */
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 Brevo API key from https://app.brevo.com/settings/keys/api after Settings > SMTP & API > API keys > Generate a new API key; copy the displayed string once. Blank prevents requests. */
22
+ apiKey: SecretString;
23
+ }
24
+ /** Host-owned source of private connector credentials. */
25
+ type CredentialSource = CredentialProvider<Credentials>;
26
+ /** CreateOrUpdateContactInput supplies an email and absolute attribute values. */
27
+ interface CreateOrUpdateContactInput {
28
+ /** Email identifies the contact and must be a plain email address. */
29
+ "email": string;
30
+ /** Attributes sets existing Brevo contact attributes by their uppercase names. */
31
+ "attributes"?: {
32
+ [key: string]: string;
33
+ } | undefined;
34
+ }
35
+ /** ContactWriteResult confirms a contact create or update without exposing provider data. */
36
+ interface ContactWriteResult {
37
+ /** ID is available when Brevo created the contact. */
38
+ "id"?: number | undefined;
39
+ /** Email is the submitted contact email. */
40
+ "email": string;
41
+ /** Created distinguishes a 201 create from a 204 update. */
42
+ "created": boolean;
43
+ }
44
+ /** GetContactInput identifies a contact by email. */
45
+ interface GetContactInput {
46
+ /** Email is a plain email address. */
47
+ "email": string;
48
+ }
49
+ /** Contact contains the minimal non-secret contact identity returned by Brevo. */
50
+ interface Contact {
51
+ /** ID is Brevo's contact identifier. */
52
+ "id": number;
53
+ /** Email is the contact email. */
54
+ "email": string;
55
+ }
56
+ /** Runtime validator for CreateOrUpdateContactInput. */
57
+ declare const CreateOrUpdateContactInputSchema: z.ZodObject<{
58
+ email: z.ZodString;
59
+ attributes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
60
+ }, z.core.$strict>;
61
+ /** Runtime validator for ContactWriteResult. */
62
+ declare const ContactWriteResultSchema: z.ZodObject<{
63
+ id: z.ZodOptional<z.ZodNumber>;
64
+ email: z.ZodString;
65
+ created: z.ZodBoolean;
66
+ }, z.core.$strict>;
67
+ /** Runtime validator for GetContactInput. */
68
+ declare const GetContactInputSchema: z.ZodObject<{
69
+ email: z.ZodString;
70
+ }, z.core.$strict>;
71
+ /** Runtime validator for Contact. */
72
+ declare const ContactSchema: z.ZodObject<{
73
+ id: z.ZodNumber;
74
+ email: z.ZodString;
75
+ }, z.core.$strict>;
76
+
77
+ /** Typed operations supplied by a client or mock. */
78
+ interface Operations {
79
+ /** Invoke createOrUpdateContact through this connection. */
80
+ createOrUpdateContact(): Mutation<CreateOrUpdateContactInput, ContactWriteResult>;
81
+ /** Invoke getContact through this connection. */
82
+ getContact(): Query<GetContactInput, Contact>;
83
+ }
84
+ /** Named connector connection kept outside Flow state. */
85
+ declare class Connection<BoundOperations = Operations> {
86
+ /** Stable provider and connection name. */
87
+ readonly reference: ConnectionRef;
88
+ /** Bound provider operations. */
89
+ readonly operations: BoundOperations;
90
+ /** Validate a reference and bind operations. */
91
+ constructor(reference: ConnectionRef, operations: BoundOperations);
92
+ }
93
+ /** Bind a client to a named connection. */
94
+ declare function newConnection(client: Operations, reference: ConnectionRef): Connection;
95
+ /** Bind scripted operations to a named connection. */
96
+ declare function newConnectionWithOperations(operations: Operations, reference: ConnectionRef): Connection;
97
+
98
+ export { type CreateOrUpdateContactInput as C, type GetContactInput as G, type Operations as O, type ContactWriteResult as a, Connection as b, type Contact as c, type Config as d, type Credentials as e, ConfigSchema as f, ContactSchema as g, ContactWriteResultSchema as h, CreateOrUpdateContactInputSchema as i, type CredentialSource as j, GetContactInputSchema as k, newConnectionWithOperations as l, newConnection as n };
@@ -0,0 +1,168 @@
1
+ import { C as CreateOrUpdateContactInput, a as ContactWriteResult, b as Connection, G as GetContactInput, c as Contact, O as Operations, d as Config, e as Credentials } from './connection-BmKZ2txn.js';
2
+ export { f as ConfigSchema, g as ContactSchema, h as ContactWriteResultSchema, i as CreateOrUpdateContactInputSchema, j as CredentialSource, k as GetContactInputSchema, n as newConnection, l as newConnectionWithOperations } from './connection-BmKZ2txn.js';
3
+ import * as _superdurable_connectors_sdk from '@superdurable/connectors-sdk';
4
+ import { MutationDefinition, QueryDefinition, MutationStepConfig, Mutation, MutationResult, QueryStepConfig, Query, QueryResult, MutationStep, QueryStep, Call, MutationAttempt, QueryAttempt, CredentialProvider, Failure } 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 = "brevo";
12
+ /** Provider identity for named connections. */
13
+ declare const ProviderID = "brevo";
14
+ /** Branch IDs for createOrUpdateContact. */
15
+ declare const CreateOrUpdateContactBranch: {
16
+ readonly Saved: "saved";
17
+ readonly ProviderRejected: "providerRejected";
18
+ readonly InvalidResponse: "invalidResponse";
19
+ readonly Defect: "defect";
20
+ };
21
+ /** Brevo created or updated the contact. */
22
+ declare const CreateOrUpdateContactBranchSaved: "saved";
23
+ /** Brevo rejected the contact or credentials. */
24
+ declare const CreateOrUpdateContactBranchProviderRejected: "providerRejected";
25
+ /** Brevo returned malformed or oversized data. */
26
+ declare const CreateOrUpdateContactBranchInvalidResponse: "invalidResponse";
27
+ /** Local input or credentials are invalid. */
28
+ declare const CreateOrUpdateContactBranchDefect: "defect";
29
+ /** Manifest definition for createOrUpdateContact. */
30
+ declare const CreateOrUpdateContactDefinition: MutationDefinition;
31
+ /** Manifest metadata for createOrUpdateContact. */
32
+ declare const CreateOrUpdateContactMetadata: {
33
+ readonly kind: "mutation";
34
+ readonly idempotency: "required";
35
+ readonly authorization: "required";
36
+ };
37
+ /** Branch IDs for getContact. */
38
+ declare const GetContactBranch: {
39
+ readonly Found: "found";
40
+ readonly NotFound: "notFound";
41
+ readonly ProviderRejected: "providerRejected";
42
+ readonly InvalidResponse: "invalidResponse";
43
+ readonly Defect: "defect";
44
+ };
45
+ /** Brevo returned the contact. */
46
+ declare const GetContactBranchFound: "found";
47
+ /** No contact has that email. */
48
+ declare const GetContactBranchNotFound: "notFound";
49
+ /** Brevo rejected the request or credentials. */
50
+ declare const GetContactBranchProviderRejected: "providerRejected";
51
+ /** Brevo returned malformed or oversized data. */
52
+ declare const GetContactBranchInvalidResponse: "invalidResponse";
53
+ /** Local input or credentials are invalid. */
54
+ declare const GetContactBranchDefect: "defect";
55
+ /** Manifest definition for getContact. */
56
+ declare const GetContactDefinition: QueryDefinition;
57
+ /** Manifest metadata for getContact. */
58
+ declare const GetContactMetadata: {
59
+ readonly kind: "query";
60
+ readonly idempotency: "none";
61
+ readonly authorization: "required";
62
+ };
63
+
64
+ /** Configuration for the createOrUpdateContact connector Step. */
65
+ interface CreateOrUpdateContactStepConfig<StepInput, OperationInput = CreateOrUpdateContactInput, OperationOutput = ContactWriteResult> extends Omit<MutationStepConfig<StepInput, OperationInput, OperationOutput>, 'operation' | 'connection' | 'branches'> {
66
+ /** Named connection supplying this operation. */
67
+ connection: Connection<{
68
+ createOrUpdateContact(): Mutation<OperationInput, OperationOutput>;
69
+ }>;
70
+ /** Name matching the bound connection. */
71
+ connectionName: string;
72
+ /** Brevo created or updated the contact. */
73
+ saved: StepTarget<MutationResult<OperationOutput>>;
74
+ /** Brevo rejected the contact or credentials. */
75
+ providerRejected?: StepTarget<MutationResult<OperationOutput>>;
76
+ /** Brevo returned malformed or oversized data. */
77
+ invalidResponse?: StepTarget<MutationResult<OperationOutput>>;
78
+ /** Local input or credentials are invalid. */
79
+ defect?: StepTarget<MutationResult<OperationOutput>>;
80
+ }
81
+ /** Build the createOrUpdateContact Step from a named connection. */
82
+ declare function newCreateOrUpdateContactStep<StepInput, OperationInput = CreateOrUpdateContactInput, OperationOutput = ContactWriteResult>(configuration: CreateOrUpdateContactStepConfig<StepInput, OperationInput, OperationOutput>): MutationStep<StepInput, OperationInput, OperationOutput>;
83
+ /** Configuration for the getContact connector Step. */
84
+ interface GetContactStepConfig<StepInput, OperationInput = GetContactInput, OperationOutput = Contact> extends Omit<QueryStepConfig<StepInput, OperationInput, OperationOutput>, 'operation' | 'connection' | 'branches'> {
85
+ /** Named connection supplying this operation. */
86
+ connection: Connection<{
87
+ getContact(): Query<OperationInput, OperationOutput>;
88
+ }>;
89
+ /** Name matching the bound connection. */
90
+ connectionName: string;
91
+ /** Brevo returned the contact. */
92
+ found: StepTarget<QueryResult<OperationOutput>>;
93
+ /** No contact has that email. */
94
+ notFound?: StepTarget<QueryResult<OperationOutput>>;
95
+ /** Brevo rejected the request or credentials. */
96
+ providerRejected?: StepTarget<QueryResult<OperationOutput>>;
97
+ /** Brevo returned malformed or oversized data. */
98
+ invalidResponse?: StepTarget<QueryResult<OperationOutput>>;
99
+ /** Local input or credentials are invalid. */
100
+ defect?: StepTarget<QueryResult<OperationOutput>>;
101
+ }
102
+ /** Build the getContact Step from a named connection. */
103
+ declare function newGetContactStep<StepInput, OperationInput = GetContactInput, OperationOutput = Contact>(configuration: GetContactStepConfig<StepInput, OperationInput, OperationOutput>): QueryStep<StepInput, OperationInput, OperationOutput>;
104
+
105
+ /** Open a named Brevo connection declared in a Dex project. */
106
+ declare function newProjectConnection(project: LoadedProject, connectionName: string): Connection<Operations>;
107
+
108
+ /** Repeat-safe Brevo contact creation or absolute-attribute update. */
109
+ declare class CreateOrUpdateContactOperation implements Mutation<CreateOrUpdateContactInput, ContactWriteResult> {
110
+ private readonly client;
111
+ /** Bind one authenticated client. */
112
+ constructor(client: BrevoClient);
113
+ /** Return the manifest definition. */
114
+ definition(): _superdurable_connectors_sdk.QueryDefinition;
115
+ /** Use the stable Dex Call ID; Brevo has no idempotency header. */
116
+ idempotencyKey(callId: string): string;
117
+ /** Send and classify one contact upsert attempt. */
118
+ invoke(call: Call, input: CreateOrUpdateContactInput): Promise<MutationAttempt<ContactWriteResult>>;
119
+ }
120
+ /** Retrieve one Brevo contact by email. */
121
+ declare class GetContactOperation implements Query<GetContactInput, Contact> {
122
+ private readonly client;
123
+ /** Bind one authenticated client. */
124
+ constructor(client: BrevoClient);
125
+ /** Return the manifest definition. */
126
+ definition(): _superdurable_connectors_sdk.QueryDefinition;
127
+ /** Send and classify one contact lookup attempt. */
128
+ invoke(call: Call, input: GetContactInput): Promise<QueryAttempt<Contact>>;
129
+ }
130
+
131
+ /** Provider sender injected for deterministic tests. */
132
+ type BrevoRequestSender = (request: ProviderRequest) => Promise<ProviderResponse>;
133
+ /** Optional transport and clock dependencies. */
134
+ interface BrevoClientOptions {
135
+ /** Bounded provider sender; the SDK transport is used by default. */
136
+ send?: BrevoRequestSender;
137
+ /** Clock for Retry-After HTTP dates. */
138
+ now?: () => Date;
139
+ }
140
+ /** One bounded provider exchange or a classified local or transport error. */
141
+ type BrevoExchange = {
142
+ response: ProviderResponse;
143
+ } | {
144
+ failure: Failure;
145
+ classification: 'defect' | 'invalidResponse' | 'retry';
146
+ retryAfterMs: number;
147
+ };
148
+ /** Brevo HTTP client with immutable settings and per-call credential resolution. */
149
+ declare class BrevoClient {
150
+ private readonly baseUrl;
151
+ private readonly timeoutMs;
152
+ private readonly maxResponseBytes;
153
+ private readonly credentials;
154
+ private readonly send;
155
+ private readonly now;
156
+ /** Validate connection settings before any provider call. */
157
+ constructor(config: Config, credentials: CredentialProvider<Credentials>, options?: BrevoClientOptions);
158
+ /** Bind the repeat-safe contact upsert. */
159
+ createOrUpdateContact(): CreateOrUpdateContactOperation;
160
+ /** Bind the contact lookup. */
161
+ getContact(): GetContactOperation;
162
+ /** Send one authenticated request and classify transport failures. */
163
+ exchange(call: Call, operation: string, method: string, path: string, body?: Uint8Array): Promise<BrevoExchange>;
164
+ /** Parse a provider-directed retry delay. */
165
+ retryAfter(response: ProviderResponse): number;
166
+ }
167
+
168
+ export { BrevoClient, type BrevoClientOptions, type BrevoRequestSender, Config, Connection, ConnectorID, Contact, ContactWriteResult, CreateOrUpdateContactBranch, CreateOrUpdateContactBranchDefect, CreateOrUpdateContactBranchInvalidResponse, CreateOrUpdateContactBranchProviderRejected, CreateOrUpdateContactBranchSaved, CreateOrUpdateContactDefinition, CreateOrUpdateContactInput, CreateOrUpdateContactMetadata, CreateOrUpdateContactOperation, type CreateOrUpdateContactStepConfig, Credentials, GetContactBranch, GetContactBranchDefect, GetContactBranchFound, GetContactBranchInvalidResponse, GetContactBranchNotFound, GetContactBranchProviderRejected, GetContactDefinition, GetContactInput, GetContactMetadata, GetContactOperation, type GetContactStepConfig, ProviderID, newCreateOrUpdateContactStep, newGetContactStep, newProjectConnection };
package/dist/index.js ADDED
@@ -0,0 +1,302 @@
1
+ import {
2
+ ConfigSchema,
3
+ Connection,
4
+ ConnectorID,
5
+ ContactSchema,
6
+ ContactWriteResultSchema,
7
+ CreateOrUpdateContactBranch,
8
+ CreateOrUpdateContactBranchDefect,
9
+ CreateOrUpdateContactBranchInvalidResponse,
10
+ CreateOrUpdateContactBranchProviderRejected,
11
+ CreateOrUpdateContactBranchSaved,
12
+ CreateOrUpdateContactDefinition,
13
+ CreateOrUpdateContactInputSchema,
14
+ CreateOrUpdateContactMetadata,
15
+ GetContactBranch,
16
+ GetContactBranchDefect,
17
+ GetContactBranchFound,
18
+ GetContactBranchInvalidResponse,
19
+ GetContactBranchNotFound,
20
+ GetContactBranchProviderRejected,
21
+ GetContactDefinition,
22
+ GetContactInputSchema,
23
+ GetContactMetadata,
24
+ ProviderID,
25
+ newConnection,
26
+ newConnectionWithOperations,
27
+ newProjectConnection
28
+ } from "./chunk-NI2F5J36.js";
29
+
30
+ // src/generated/steps.ts
31
+ import { goToBranch, newMutationStep, newQueryStep } from "@superdurable/connectors-sdk";
32
+ function newCreateOrUpdateContactStep(configuration) {
33
+ const { connection, connectionName, saved, providerRejected, invalidResponse, defect, ...stepConfiguration } = configuration;
34
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
35
+ return newMutationStep({ ...stepConfiguration, operation: connection.operations.createOrUpdateContact(), connection: connection.reference, branches: [
36
+ goToBranch("saved", saved),
37
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
38
+ ...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
39
+ ...defect ? [goToBranch("defect", defect)] : []
40
+ ] });
41
+ }
42
+ function newGetContactStep(configuration) {
43
+ const { connection, connectionName, found, notFound, providerRejected, invalidResponse, defect, ...stepConfiguration } = configuration;
44
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
45
+ return newQueryStep({ ...stepConfiguration, operation: connection.operations.getContact(), connection: connection.reference, branches: [
46
+ goToBranch("found", found),
47
+ ...notFound ? [goToBranch("notFound", notFound)] : [],
48
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
49
+ ...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
50
+ ...defect ? [goToBranch("defect", defect)] : []
51
+ ] });
52
+ }
53
+
54
+ // src/project.ts
55
+ import { SecretString as SecretString2 } from "@superdurable/connectors-sdk";
56
+ import { z } from "zod";
57
+
58
+ // src/client.ts
59
+ import { BodyTooLargeError, isHeaderSafeCredential, parseRetryAfter, sendProviderRequest, validateBaseURL } from "@superdurable/connectors-sdk/providerhttp";
60
+ import { SecretString } from "@superdurable/connectors-sdk";
61
+ import emailAddresses from "email-addresses";
62
+
63
+ // src/operations.ts
64
+ import { newMutationBranch, newMutationRetry, newQueryBranch, newQueryRetry } from "@superdurable/connectors-sdk";
65
+ var emptyWrite = { email: "", created: false };
66
+ var emptyContact = { id: 0, email: "" };
67
+ var CreateOrUpdateContactOperation = class {
68
+ /** Bind one authenticated client. */
69
+ constructor(client) {
70
+ this.client = client;
71
+ }
72
+ client;
73
+ /** Return the manifest definition. */
74
+ definition() {
75
+ return CreateOrUpdateContactDefinition;
76
+ }
77
+ /** Use the stable Dex Call ID; Brevo has no idempotency header. */
78
+ idempotencyKey(callId) {
79
+ return callId;
80
+ }
81
+ /** Send and classify one contact upsert attempt. */
82
+ async invoke(call, input) {
83
+ const operation = "createOrUpdateContact";
84
+ if (!isPlainEmail(input.email)) return newMutationBranch("defect", emptyWrite, {}, brevoFailure(operation, "VALIDATION", "a plain email address is required"));
85
+ if (input.attributes && Object.keys(input.attributes).some((key) => !key || key.toUpperCase() !== key)) {
86
+ return newMutationBranch("defect", emptyWrite, {}, brevoFailure(operation, "VALIDATION", "attribute names must be uppercase"));
87
+ }
88
+ let body;
89
+ try {
90
+ body = Buffer.from(JSON.stringify({ email: input.email, ...input.attributes && Object.keys(input.attributes).length ? { attributes: input.attributes } : {}, updateEnabled: true }));
91
+ } catch {
92
+ return newMutationBranch("defect", emptyWrite, {}, brevoFailure(operation, "VALIDATION", "contact payload is invalid or too large"));
93
+ }
94
+ if (body.byteLength > 1 << 20) return newMutationBranch("defect", emptyWrite, {}, brevoFailure(operation, "VALIDATION", "contact payload is invalid or too large"));
95
+ const exchange = await this.client.exchange(call, operation, "POST", "/contacts", body);
96
+ if ("failure" in exchange) {
97
+ if (exchange.classification === "retry") return newMutationRetry(exchange.failure);
98
+ return newMutationBranch(exchange.classification === "invalidResponse" ? "invalidResponse" : "defect", emptyWrite, {}, exchange.failure);
99
+ }
100
+ const { response } = exchange;
101
+ if (isRetryableStatus(response.status)) return newMutationRetry(brevoFailure(operation, "AVAILABILITY", "Brevo contact request is temporarily unavailable"), this.client.retryAfter(response));
102
+ if (response.status !== 201 && response.status !== 204) return newMutationBranch("providerRejected", emptyWrite, {}, brevoFailure(operation, rejectionFailureKind(response.status), `Brevo rejected contact request with HTTP ${response.status}`));
103
+ if (response.status === 204) return newMutationBranch("saved", { email: input.email, created: false });
104
+ try {
105
+ const decoded = JSON.parse(Buffer.from(response.body).toString("utf8"));
106
+ if (!decoded || typeof decoded !== "object" || !("id" in decoded) || typeof decoded.id !== "number" || !Number.isSafeInteger(decoded.id) || decoded.id <= 0) throw new TypeError("invalid ID");
107
+ return newMutationBranch("saved", { id: decoded.id, email: input.email, created: true });
108
+ } catch {
109
+ return newMutationBranch("invalidResponse", emptyWrite, {}, brevoFailure(operation, "PROTOCOL", "Brevo returned an invalid contact ID"));
110
+ }
111
+ }
112
+ };
113
+ var GetContactOperation = class {
114
+ /** Bind one authenticated client. */
115
+ constructor(client) {
116
+ this.client = client;
117
+ }
118
+ client;
119
+ /** Return the manifest definition. */
120
+ definition() {
121
+ return GetContactDefinition;
122
+ }
123
+ /** Send and classify one contact lookup attempt. */
124
+ async invoke(call, input) {
125
+ const operation = "getContact";
126
+ if (!isPlainEmail(input.email)) return newQueryBranch("defect", emptyContact, {}, brevoFailure(operation, "VALIDATION", "a plain email address is required"));
127
+ const exchange = await this.client.exchange(call, operation, "GET", `/contacts/${escapeContactEmailPath(input.email)}`);
128
+ if ("failure" in exchange) {
129
+ if (exchange.classification === "retry") return newQueryRetry(exchange.failure);
130
+ return newQueryBranch(exchange.classification === "invalidResponse" ? "invalidResponse" : "defect", emptyContact, {}, exchange.failure);
131
+ }
132
+ const { response } = exchange;
133
+ if (isRetryableStatus(response.status)) return newQueryRetry(brevoFailure(operation, "AVAILABILITY", "Brevo contact lookup is temporarily unavailable"), this.client.retryAfter(response));
134
+ if (response.status === 404) return newQueryBranch("notFound", emptyContact, {}, brevoFailure(operation, "NOT_FOUND", "Brevo contact was not found"));
135
+ if (response.status !== 200) return newQueryBranch("providerRejected", emptyContact, {}, brevoFailure(operation, rejectionFailureKind(response.status), `Brevo rejected contact lookup with HTTP ${response.status}`));
136
+ try {
137
+ const decoded = JSON.parse(Buffer.from(response.body).toString("utf8"));
138
+ if (!decoded || typeof decoded !== "object" || !("id" in decoded) || typeof decoded.id !== "number" || !Number.isSafeInteger(decoded.id) || decoded.id <= 0 || !("email" in decoded) || typeof decoded.email !== "string" || !isPlainEmail(decoded.email)) throw new TypeError("invalid contact");
139
+ return newQueryBranch("found", { id: decoded.id, email: decoded.email });
140
+ } catch {
141
+ return newQueryBranch("invalidResponse", emptyContact, {}, brevoFailure(operation, "PROTOCOL", "Brevo returned an invalid contact"));
142
+ }
143
+ }
144
+ };
145
+ function escapeContactEmailPath(email) {
146
+ return encodeURIComponent(email).replace(/[!'()*]/g, (character) => `%${character.charCodeAt(0).toString(16).toUpperCase()}`).replace(/%(24|26|2B|3A|3D|40)/gi, (encoded) => String.fromCharCode(Number.parseInt(encoded.slice(1), 16)));
147
+ }
148
+
149
+ // src/client.ts
150
+ var publicEndpoint = "https://api.brevo.com/v3";
151
+ var defaultTimeoutMs = 15e3;
152
+ var defaultMaxResponseBytes = 2097152;
153
+ var BrevoClient = class {
154
+ baseUrl;
155
+ timeoutMs;
156
+ maxResponseBytes;
157
+ credentials;
158
+ send;
159
+ now;
160
+ /** Validate connection settings before any provider call. */
161
+ constructor(config, credentials, options = {}) {
162
+ if (!credentials) throw new TypeError("Brevo credential provider is required");
163
+ this.baseUrl = validateBaseURL(config.baseUrl || publicEndpoint);
164
+ this.timeoutMs = config.timeoutMs || defaultTimeoutMs;
165
+ this.maxResponseBytes = config.maxResponseBytes || defaultMaxResponseBytes;
166
+ if (!Number.isSafeInteger(this.timeoutMs) || this.timeoutMs <= 0) throw new TypeError("Brevo timeout must be positive milliseconds");
167
+ if (!Number.isSafeInteger(this.maxResponseBytes) || this.maxResponseBytes <= 0) throw new TypeError("Brevo maxResponseBytes must be positive");
168
+ this.credentials = credentials;
169
+ this.send = options.send ?? sendProviderRequest;
170
+ this.now = options.now ?? (() => /* @__PURE__ */ new Date());
171
+ }
172
+ /** Bind the repeat-safe contact upsert. */
173
+ createOrUpdateContact() {
174
+ return new CreateOrUpdateContactOperation(this);
175
+ }
176
+ /** Bind the contact lookup. */
177
+ getContact() {
178
+ return new GetContactOperation(this);
179
+ }
180
+ /** Send one authenticated request and classify transport failures. */
181
+ async exchange(call, operation, method, path, body) {
182
+ let apiKey;
183
+ try {
184
+ const credentials = await this.credentials.resolve(call, call.context.cancellationSignal);
185
+ if (!(credentials.apiKey instanceof SecretString)) throw new TypeError("missing key");
186
+ apiKey = credentials.apiKey.reveal();
187
+ if (!isHeaderSafeCredential(apiKey)) throw new TypeError("invalid key");
188
+ } catch {
189
+ return { failure: brevoFailure(operation, "AUTHENTICATION", "Brevo connection credentials are unavailable or invalid"), classification: "defect", retryAfterMs: 0 };
190
+ }
191
+ try {
192
+ const response = await this.send({
193
+ url: this.baseUrl + path,
194
+ method,
195
+ headers: { "api-key": apiKey, Accept: "application/json", "Content-Type": "application/json" },
196
+ ...body ? { body } : {},
197
+ maxResponseBytes: this.maxResponseBytes,
198
+ timeoutMs: this.timeoutMs,
199
+ addressPolicy: this.baseUrl === publicEndpoint ? "publicHTTPS" : "privateNetworkHTTP",
200
+ signal: call.context.cancellationSignal
201
+ });
202
+ return { response };
203
+ } catch (error) {
204
+ if (error instanceof BodyTooLargeError) {
205
+ if (error.status !== void 0 && error.status !== 200 && error.status !== 201) {
206
+ return { response: { status: error.status, headers: error.headers ?? {}, body: new Uint8Array() } };
207
+ }
208
+ return { failure: brevoFailure(operation, "RESPONSE_TOO_LARGE", "Brevo contact response exceeded the limit"), classification: "invalidResponse", retryAfterMs: 0 };
209
+ }
210
+ return { failure: brevoFailure(operation, "TRANSPORT", "Brevo contact response is unavailable"), classification: "retry", retryAfterMs: 0 };
211
+ }
212
+ }
213
+ /** Parse a provider-directed retry delay. */
214
+ retryAfter(response) {
215
+ const value = response.headers["retry-after"];
216
+ return parseRetryAfter(Array.isArray(value) ? value[0] ?? "" : value ?? "", this.now());
217
+ }
218
+ };
219
+ function brevoFailure(operation, kind, message) {
220
+ return { kind, provider: "brevo", operation, message };
221
+ }
222
+ function isPlainEmail(value) {
223
+ const address = emailAddresses.parseOneAddress({ input: value, rfc6532: true });
224
+ return address?.type === "mailbox" && address.address === value && value.includes("@");
225
+ }
226
+ function isRetryableStatus(status) {
227
+ return status === 408 || status === 409 || status === 429 || status >= 500;
228
+ }
229
+ function rejectionFailureKind(status) {
230
+ if (status === 401) return "AUTHENTICATION";
231
+ if (status === 403) return "AUTHORIZATION";
232
+ return "PROVIDER_REJECTION";
233
+ }
234
+
235
+ // src/project.ts
236
+ function newProjectConnection2(project, connectionName) {
237
+ return newProjectConnection(project, connectionName, (loadedProject, name) => {
238
+ const selected = loadedProject.configuration.connections.find((entry) => entry.connectorId === "brevo" && entry.connectionName === name);
239
+ if (!selected) throw new TypeError("Brevo project connection is not configured");
240
+ const fields = z.strictObject({ baseUrl: z.string().optional(), timeout: z.union([z.string(), z.number().int()]).optional(), maxResponseBytes: z.number().int().optional() }).parse(selected.configuration);
241
+ const timeoutMs = typeof fields.timeout === "number" ? Math.ceil(fields.timeout / 1e6) : fields.timeout ? parseDurationMilliseconds(fields.timeout) : void 0;
242
+ const config = {
243
+ ...fields.baseUrl !== void 0 ? { baseUrl: fields.baseUrl } : {},
244
+ ...timeoutMs !== void 0 ? { timeoutMs } : {},
245
+ ...fields.maxResponseBytes !== void 0 ? { maxResponseBytes: fields.maxResponseBytes } : {}
246
+ };
247
+ const credentials = {
248
+ async resolve(_call, signal) {
249
+ const privateFields = await loadedProject.resolveCredential("brevo", name, signal);
250
+ if (typeof privateFields.api_key !== "string") throw new TypeError("Brevo API key is unavailable");
251
+ return { apiKey: new SecretString2(privateFields.api_key) };
252
+ }
253
+ };
254
+ return new BrevoClient(config, credentials);
255
+ });
256
+ }
257
+ function parseDurationMilliseconds(value) {
258
+ let remaining = value;
259
+ let milliseconds = 0;
260
+ const units = { ns: 1e-6, us: 1e-3, "\xB5s": 1e-3, ms: 1, s: 1e3, m: 6e4, h: 36e5 };
261
+ while (remaining) {
262
+ const part = /^(\d+(?:\.\d+)?)(ns|us|µs|ms|s|m|h)/.exec(remaining);
263
+ if (!part) throw new TypeError("Brevo timeout must be a positive Go duration");
264
+ milliseconds += Number(part[1]) * (units[part[2] ?? ""] ?? NaN);
265
+ remaining = remaining.slice(part[0].length);
266
+ }
267
+ if (!Number.isSafeInteger(milliseconds) || milliseconds <= 0) throw new TypeError("Brevo timeout must resolve to positive whole milliseconds");
268
+ return milliseconds;
269
+ }
270
+ export {
271
+ BrevoClient,
272
+ ConfigSchema,
273
+ Connection,
274
+ ConnectorID,
275
+ ContactSchema,
276
+ ContactWriteResultSchema,
277
+ CreateOrUpdateContactBranch,
278
+ CreateOrUpdateContactBranchDefect,
279
+ CreateOrUpdateContactBranchInvalidResponse,
280
+ CreateOrUpdateContactBranchProviderRejected,
281
+ CreateOrUpdateContactBranchSaved,
282
+ CreateOrUpdateContactDefinition,
283
+ CreateOrUpdateContactInputSchema,
284
+ CreateOrUpdateContactMetadata,
285
+ CreateOrUpdateContactOperation,
286
+ GetContactBranch,
287
+ GetContactBranchDefect,
288
+ GetContactBranchFound,
289
+ GetContactBranchInvalidResponse,
290
+ GetContactBranchNotFound,
291
+ GetContactBranchProviderRejected,
292
+ GetContactDefinition,
293
+ GetContactInputSchema,
294
+ GetContactMetadata,
295
+ GetContactOperation,
296
+ ProviderID,
297
+ newConnection,
298
+ newConnectionWithOperations,
299
+ newCreateOrUpdateContactStep,
300
+ newGetContactStep,
301
+ newProjectConnection2 as newProjectConnection
302
+ };
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, b as Connection, C as CreateOrUpdateContactInput, a as ContactWriteResult, G as GetContactInput, c as Contact } from './connection-BmKZ2txn.js';
4
+ import 'zod';
5
+
6
+ /** Go zero value for CreateOrUpdateContactInput in scripted cases. */
7
+ declare const emptyCreateOrUpdateContactInput: CreateOrUpdateContactInput;
8
+ /** Go zero value for ContactWriteResult in scripted cases. */
9
+ declare const emptyContactWriteResult: ContactWriteResult;
10
+ /** Go zero value for GetContactInput in scripted cases. */
11
+ declare const emptyGetContactInput: GetContactInput;
12
+ /** Go zero value for Contact in scripted cases. */
13
+ declare const emptyContact: Contact;
14
+ /** Script the saved branch. */
15
+ declare function createOrUpdateContactSaved(value: ContactWriteResult, failure?: Failure): Case<ContactWriteResult>;
16
+ /** Script the providerRejected branch. */
17
+ declare function createOrUpdateContactProviderRejected(value: ContactWriteResult, failure?: Failure): Case<ContactWriteResult>;
18
+ /** Script the invalidResponse branch. */
19
+ declare function createOrUpdateContactInvalidResponse(value: ContactWriteResult, failure?: Failure): Case<ContactWriteResult>;
20
+ /** Script the defect branch. */
21
+ declare function createOrUpdateContactDefect(value: ContactWriteResult, failure?: Failure): Case<ContactWriteResult>;
22
+ /** Script a safe retry of createOrUpdateContact. */
23
+ declare function createOrUpdateContactRetry(failure: Failure, retryAfterMs?: number): Case<ContactWriteResult>;
24
+ /** Manifest scenario savedDefaultContact for createOrUpdateContact. */
25
+ declare function createOrUpdateContactSavedDefaultContact(): Case<ContactWriteResult>;
26
+ /** Default createOrUpdateContact scenario. */
27
+ declare function createOrUpdateContactDefault(): Case<ContactWriteResult>;
28
+ /** Script the found branch. */
29
+ declare function getContactFound(value: Contact, failure?: Failure): Case<Contact>;
30
+ /** Script the notFound branch. */
31
+ declare function getContactNotFound(value: Contact, failure?: Failure): Case<Contact>;
32
+ /** Script the providerRejected branch. */
33
+ declare function getContactProviderRejected(value: Contact, failure?: Failure): Case<Contact>;
34
+ /** Script the invalidResponse branch. */
35
+ declare function getContactInvalidResponse(value: Contact, failure?: Failure): Case<Contact>;
36
+ /** Script the defect branch. */
37
+ declare function getContactDefect(value: Contact, failure?: Failure): Case<Contact>;
38
+ /** Script a safe retry of getContact. */
39
+ declare function getContactRetry(failure: Failure, retryAfterMs?: number): Case<Contact>;
40
+ /** Manifest scenario foundDefaultContact for getContact. */
41
+ declare function getContactFoundDefaultContact(): Case<Contact>;
42
+ /** Default getContact scenario. */
43
+ declare function getContactDefault(): Case<Contact>;
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
+ createOrUpdateContact(): MockMutation<CreateOrUpdateContactInput, ContactWriteResult>;
50
+ getContact(): MockQuery<GetContactInput, Contact>;
51
+ assertNoFailures(): void;
52
+ }
53
+
54
+ export { GeneratedMock, createOrUpdateContactDefault, createOrUpdateContactDefect, createOrUpdateContactInvalidResponse, createOrUpdateContactProviderRejected, createOrUpdateContactRetry, createOrUpdateContactSaved, createOrUpdateContactSavedDefaultContact, emptyContact, emptyContactWriteResult, emptyCreateOrUpdateContactInput, emptyGetContactInput, getContactDefault, getContactDefect, getContactFound, getContactFoundDefaultContact, getContactInvalidResponse, getContactNotFound, getContactProviderRejected, getContactRetry };
package/dist/mock.js ADDED
@@ -0,0 +1,119 @@
1
+ import {
2
+ ContactSchema,
3
+ ContactWriteResultSchema,
4
+ CreateOrUpdateContactDefinition,
5
+ CreateOrUpdateContactInputSchema,
6
+ GetContactDefinition,
7
+ GetContactInputSchema,
8
+ ProviderID,
9
+ newConnectionWithOperations
10
+ } from "./chunk-NI2F5J36.js";
11
+
12
+ // src/generated/mock.ts
13
+ import { branchCase, retryCase, newMutation, newQuery } from "@superdurable/connectors-sdk/connectormock";
14
+ var emptyCreateOrUpdateContactInput = CreateOrUpdateContactInputSchema.parse({
15
+ "email": ""
16
+ });
17
+ var emptyContactWriteResult = ContactWriteResultSchema.parse({
18
+ "email": "",
19
+ "created": false
20
+ });
21
+ var emptyGetContactInput = GetContactInputSchema.parse({
22
+ "email": ""
23
+ });
24
+ var emptyContact = ContactSchema.parse({
25
+ "id": 0,
26
+ "email": ""
27
+ });
28
+ function createOrUpdateContactSaved(value, failure) {
29
+ return branchCase("saved", value, failure);
30
+ }
31
+ function createOrUpdateContactProviderRejected(value, failure) {
32
+ return branchCase("providerRejected", value, failure);
33
+ }
34
+ function createOrUpdateContactInvalidResponse(value, failure) {
35
+ return branchCase("invalidResponse", value, failure);
36
+ }
37
+ function createOrUpdateContactDefect(value, failure) {
38
+ return branchCase("defect", value, failure);
39
+ }
40
+ function createOrUpdateContactRetry(failure, retryAfterMs = 0) {
41
+ return retryCase(failure, retryAfterMs);
42
+ }
43
+ function createOrUpdateContactSavedDefaultContact() {
44
+ const value = ContactWriteResultSchema.parse({ "created": true, "email": "member@meridian.example", "id": 21 });
45
+ return branchCase("saved", value);
46
+ }
47
+ function createOrUpdateContactDefault() {
48
+ return createOrUpdateContactSavedDefaultContact();
49
+ }
50
+ function getContactFound(value, failure) {
51
+ return branchCase("found", value, failure);
52
+ }
53
+ function getContactNotFound(value, failure) {
54
+ return branchCase("notFound", value, failure);
55
+ }
56
+ function getContactProviderRejected(value, failure) {
57
+ return branchCase("providerRejected", value, failure);
58
+ }
59
+ function getContactInvalidResponse(value, failure) {
60
+ return branchCase("invalidResponse", value, failure);
61
+ }
62
+ function getContactDefect(value, failure) {
63
+ return branchCase("defect", value, failure);
64
+ }
65
+ function getContactRetry(failure, retryAfterMs = 0) {
66
+ return retryCase(failure, retryAfterMs);
67
+ }
68
+ function getContactFoundDefaultContact() {
69
+ const value = ContactSchema.parse({ "email": "member@meridian.example", "id": 21 });
70
+ return branchCase("found", value);
71
+ }
72
+ function getContactDefault() {
73
+ return getContactFoundDefaultContact();
74
+ }
75
+ var GeneratedMock = class {
76
+ #createOrUpdateContact;
77
+ #getContact;
78
+ #connection;
79
+ constructor(connectionName) {
80
+ this.#createOrUpdateContact = newMutation(CreateOrUpdateContactDefinition).default(createOrUpdateContactDefault());
81
+ this.#getContact = newQuery(GetContactDefinition).default(getContactDefault());
82
+ this.#connection = newConnectionWithOperations(this, { provider: ProviderID, name: connectionName });
83
+ }
84
+ connection() {
85
+ return this.#connection;
86
+ }
87
+ createOrUpdateContact() {
88
+ return this.#createOrUpdateContact;
89
+ }
90
+ getContact() {
91
+ return this.#getContact;
92
+ }
93
+ assertNoFailures() {
94
+ this.#createOrUpdateContact.assertNoFailures();
95
+ this.#getContact.assertNoFailures();
96
+ }
97
+ };
98
+ export {
99
+ GeneratedMock,
100
+ createOrUpdateContactDefault,
101
+ createOrUpdateContactDefect,
102
+ createOrUpdateContactInvalidResponse,
103
+ createOrUpdateContactProviderRejected,
104
+ createOrUpdateContactRetry,
105
+ createOrUpdateContactSaved,
106
+ createOrUpdateContactSavedDefaultContact,
107
+ emptyContact,
108
+ emptyContactWriteResult,
109
+ emptyCreateOrUpdateContactInput,
110
+ emptyGetContactInput,
111
+ getContactDefault,
112
+ getContactDefect,
113
+ getContactFound,
114
+ getContactFoundDefaultContact,
115
+ getContactInvalidResponse,
116
+ getContactNotFound,
117
+ getContactProviderRejected,
118
+ getContactRetry
119
+ };
package/package.json CHANGED
@@ -1,6 +1,62 @@
1
1
  {
2
2
  "name": "@superdurable/connector-brevo",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Brevo contact operations for Dex Flows",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/superdurable/dex-connectors-library.git",
8
+ "directory": "connectors/brevo/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
+ },
30
+ "files": [
31
+ "dist",
32
+ "dex-connector.json",
33
+ "README.md"
34
+ ],
35
+ "scripts": {
36
+ "build": "tsup src/index.ts src/mock.ts --format esm --dts --clean",
37
+ "typecheck": "tsc --noEmit",
38
+ "lint": "eslint src test examples",
39
+ "test": "npm run build && vitest run --exclude 'test/integration/**'",
40
+ "test:integration": "npm run build && vitest run test/integration/*.integration.test.ts",
41
+ "check": "npm test && npm run typecheck && npm run lint",
42
+ "example:sync": "npm run build && tsx examples/contact-sync/main.ts",
43
+ "example:sync:start": "npm run build && tsx examples/contact-sync/start.ts"
44
+ },
45
+ "dependencies": {
46
+ "@superdurable/connectors-sdk": "0.1.0",
47
+ "@superdurable/dex": ">=1.28.0",
48
+ "email-addresses": "5.0.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
+ }