@superdurable/connector-constantcontact 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 +21 -0
- package/README.md +4 -2
- package/dex-connector.json +65 -0
- package/dist/chunk-EKDUUKZQ.js +133 -0
- package/dist/connection-fYrNM2Oe.d.ts +86 -0
- package/dist/index.d.ts +99 -0
- package/dist/index.js +331 -0
- package/dist/mock.d.ts +37 -0
- package/dist/mock.js +77 -0
- package/package.json +59 -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,5 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Constant Contact TypeScript connector
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The TypeScript package implements the Go-verified `getContact` Query. It reads a contact UUID, optional email address, names, and email permission. OAuth authorization requires `contact_data`; the connection refreshes tokens with `offline_access` and the app's Client Secret. See the [connector guide](../README.md) for setup and [contact inspection](examples/contact-inspection/README.md) for a runnable Flow.
|
|
4
|
+
|
|
5
|
+
TypeScript replays the Go provider recordings in `conformance/connectors/constantcontact/scenarios.json`. The package is an initial `v0.1.0` release candidate and is not published yet.
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"connectorId": "constantcontact",
|
|
3
|
+
"releaseTag": "connectors/constantcontact/go/v0.1.0",
|
|
4
|
+
"package": {
|
|
5
|
+
"ecosystem": "npm",
|
|
6
|
+
"name": "@superdurable/connector-constantcontact",
|
|
7
|
+
"version": "0.1.0"
|
|
8
|
+
},
|
|
9
|
+
"factories": [
|
|
10
|
+
{
|
|
11
|
+
"name": "newGetContactStep",
|
|
12
|
+
"kind": "query",
|
|
13
|
+
"operationId": "getContact",
|
|
14
|
+
"inputType": "GetContactInput",
|
|
15
|
+
"description": "Read one contact's ID, optional email address, names, and current email permission when present.",
|
|
16
|
+
"fields": {
|
|
17
|
+
"stepType": "stepType",
|
|
18
|
+
"annotations": "annotations",
|
|
19
|
+
"connectionName": "connectionName",
|
|
20
|
+
"resultAttribute": "resultAttribute"
|
|
21
|
+
},
|
|
22
|
+
"branches": [
|
|
23
|
+
{
|
|
24
|
+
"id": "found",
|
|
25
|
+
"field": "found",
|
|
26
|
+
"optional": false
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"id": "notFound",
|
|
30
|
+
"field": "notFound",
|
|
31
|
+
"optional": true
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"id": "providerRejected",
|
|
35
|
+
"field": "providerRejected",
|
|
36
|
+
"optional": true
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"id": "invalidResponse",
|
|
40
|
+
"field": "invalidResponse",
|
|
41
|
+
"optional": true
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"id": "defect",
|
|
45
|
+
"field": "defect",
|
|
46
|
+
"optional": true
|
|
47
|
+
}
|
|
48
|
+
],
|
|
49
|
+
"inputSchema": {
|
|
50
|
+
"additionalProperties": false,
|
|
51
|
+
"description": "GetContactInput selects a contact by the UUID in its V3 API resource.",
|
|
52
|
+
"properties": {
|
|
53
|
+
"contactId": {
|
|
54
|
+
"description": "ContactID is a non-secret V3 contact UUID.",
|
|
55
|
+
"type": "string"
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
"required": [
|
|
59
|
+
"contactId"
|
|
60
|
+
],
|
|
61
|
+
"type": "object"
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
]
|
|
65
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
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
|
+
function decodeCredentials(value) {
|
|
10
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) throw new TypeError("credential fields are invalid");
|
|
11
|
+
const fields = value;
|
|
12
|
+
const allowed = /* @__PURE__ */ new Set(["access_token", "oauth_client_id", "oauth_client_secret", "refresh_token"]);
|
|
13
|
+
if (Object.keys(fields).some((key) => !allowed.has(key))) throw new TypeError("stored credential does not match the connector credential fields");
|
|
14
|
+
if (fields["access_token"] != null && !(typeof fields["access_token"] === "string")) throw new TypeError("credential access_token has an invalid type");
|
|
15
|
+
if (fields["oauth_client_id"] != null && !(typeof fields["oauth_client_id"] === "string")) throw new TypeError("credential oauth_client_id has an invalid type");
|
|
16
|
+
if (fields["oauth_client_secret"] != null && !(typeof fields["oauth_client_secret"] === "string")) throw new TypeError("credential oauth_client_secret has an invalid type");
|
|
17
|
+
if (fields["refresh_token"] != null && !(typeof fields["refresh_token"] === "string")) throw new TypeError("credential refresh_token has an invalid type");
|
|
18
|
+
const credentials = {};
|
|
19
|
+
if (!fields["oauth_client_id"]) throw new TypeError("credential oauth_client_id is required");
|
|
20
|
+
credentials.oauthClientId = fields["oauth_client_id"] ?? "";
|
|
21
|
+
if (!fields["oauth_client_secret"]) throw new TypeError("credential oauth_client_secret is required");
|
|
22
|
+
credentials.oauthClientSecret = new SecretString(fields["oauth_client_secret"] ?? "");
|
|
23
|
+
if (!fields["access_token"]) throw new TypeError("credential access_token is required");
|
|
24
|
+
credentials.accessToken = new SecretString(fields["access_token"] ?? "");
|
|
25
|
+
if (!fields["refresh_token"]) throw new TypeError("credential refresh_token is required");
|
|
26
|
+
credentials.refreshToken = new SecretString(fields["refresh_token"] ?? "");
|
|
27
|
+
return credentials;
|
|
28
|
+
}
|
|
29
|
+
function decodeSharedCredentials(value) {
|
|
30
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) throw new TypeError("credential fields are invalid");
|
|
31
|
+
const fields = value;
|
|
32
|
+
const allowed = /* @__PURE__ */ new Set(["access_token", "oauth_client_id", "oauth_client_secret", "refresh_token"]);
|
|
33
|
+
if (Object.keys(fields).some((key) => !allowed.has(key))) throw new TypeError("stored credential does not match the connector credential fields");
|
|
34
|
+
if (fields["access_token"] != null && !(typeof fields["access_token"] === "string")) throw new TypeError("credential access_token has an invalid type");
|
|
35
|
+
if (fields["oauth_client_id"] != null && !(typeof fields["oauth_client_id"] === "string")) throw new TypeError("credential oauth_client_id has an invalid type");
|
|
36
|
+
if (fields["oauth_client_secret"] != null && !(typeof fields["oauth_client_secret"] === "string")) throw new TypeError("credential oauth_client_secret has an invalid type");
|
|
37
|
+
if (fields["refresh_token"] != null && !(typeof fields["refresh_token"] === "string")) throw new TypeError("credential refresh_token has an invalid type");
|
|
38
|
+
const credentials = {};
|
|
39
|
+
if (!fields["oauth_client_id"]) throw new TypeError("credential oauth_client_id is required");
|
|
40
|
+
credentials.oauthClientId = fields["oauth_client_id"] ?? "";
|
|
41
|
+
credentials.oauthClientSecret = new SecretString(fields["oauth_client_secret"] ?? "");
|
|
42
|
+
if (!fields["access_token"]) throw new TypeError("credential access_token is required");
|
|
43
|
+
credentials.accessToken = new SecretString(fields["access_token"] ?? "");
|
|
44
|
+
credentials.refreshToken = new SecretString(fields["refresh_token"] ?? "");
|
|
45
|
+
return credentials;
|
|
46
|
+
}
|
|
47
|
+
var GetContactInputSchema = z.strictObject({
|
|
48
|
+
"contactId": z.string()
|
|
49
|
+
});
|
|
50
|
+
var ContactMetadataSchema = z.strictObject({
|
|
51
|
+
"contactId": z.string(),
|
|
52
|
+
"emailAddress": z.string().optional(),
|
|
53
|
+
"firstName": z.string().optional(),
|
|
54
|
+
"lastName": z.string().optional(),
|
|
55
|
+
"emailPermission": z.string().optional()
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
// src/generated/definitions.ts
|
|
59
|
+
var ConnectorID = "constantcontact";
|
|
60
|
+
var ProviderID = "constantcontact";
|
|
61
|
+
var GetContactBranch = {
|
|
62
|
+
Found: "found",
|
|
63
|
+
NotFound: "notFound",
|
|
64
|
+
ProviderRejected: "providerRejected",
|
|
65
|
+
InvalidResponse: "invalidResponse",
|
|
66
|
+
Defect: "defect"
|
|
67
|
+
};
|
|
68
|
+
var GetContactBranchFound = GetContactBranch.Found;
|
|
69
|
+
var GetContactBranchNotFound = GetContactBranch.NotFound;
|
|
70
|
+
var GetContactBranchProviderRejected = GetContactBranch.ProviderRejected;
|
|
71
|
+
var GetContactBranchInvalidResponse = GetContactBranch.InvalidResponse;
|
|
72
|
+
var GetContactBranchDefect = GetContactBranch.Defect;
|
|
73
|
+
var GetContactDefinition = {
|
|
74
|
+
operation: { connectorId: ConnectorID, operationId: "getContact" },
|
|
75
|
+
branches: [
|
|
76
|
+
{ id: "found", description: "Constant Contact returned the contact." },
|
|
77
|
+
{ id: "notFound", description: "The contact does not exist or is inaccessible.", optional: true },
|
|
78
|
+
{ id: "providerRejected", description: "Constant Contact conclusively rejected the request.", optional: true },
|
|
79
|
+
{ id: "invalidResponse", description: "Constant Contact returned malformed or oversized JSON.", optional: true },
|
|
80
|
+
{ id: "defect", description: "Local input or connection credentials are invalid.", optional: true }
|
|
81
|
+
],
|
|
82
|
+
stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "async" }
|
|
83
|
+
};
|
|
84
|
+
var GetContactMetadata = { kind: "query", idempotency: "none", authorization: "required" };
|
|
85
|
+
|
|
86
|
+
// src/generated/connection.ts
|
|
87
|
+
import { ConnectionRefSchema } from "@superdurable/connectors-sdk";
|
|
88
|
+
import { newRefreshingCredentialProvider } from "@superdurable/connectors-sdk/projectconfig";
|
|
89
|
+
var Connection = class {
|
|
90
|
+
/** Stable provider and connection name. */
|
|
91
|
+
reference;
|
|
92
|
+
/** Bound provider operations. */
|
|
93
|
+
operations;
|
|
94
|
+
/** Validate a reference and bind operations. */
|
|
95
|
+
constructor(reference, operations) {
|
|
96
|
+
this.reference = ConnectionRefSchema.parse(reference);
|
|
97
|
+
if (this.reference.provider !== ProviderID) throw new TypeError("connection provider differs from the manifest");
|
|
98
|
+
if (!operations) throw new TypeError("connector operations are required");
|
|
99
|
+
this.operations = operations;
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
function newConnection(client, reference) {
|
|
103
|
+
if (!client) throw new TypeError("connector client is required");
|
|
104
|
+
return new Connection(reference, client);
|
|
105
|
+
}
|
|
106
|
+
function newConnectionWithOperations(operations, reference) {
|
|
107
|
+
return new Connection(reference, operations);
|
|
108
|
+
}
|
|
109
|
+
function newProjectCredentialProvider(project, connectionName, decode, encode, decodeShared) {
|
|
110
|
+
return newRefreshingCredentialProvider(project.connections, { connectorId: ConnectorID, connectionName }, decode, encode, decodeShared);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export {
|
|
114
|
+
ConfigSchema,
|
|
115
|
+
decodeCredentials,
|
|
116
|
+
decodeSharedCredentials,
|
|
117
|
+
GetContactInputSchema,
|
|
118
|
+
ContactMetadataSchema,
|
|
119
|
+
ConnectorID,
|
|
120
|
+
ProviderID,
|
|
121
|
+
GetContactBranch,
|
|
122
|
+
GetContactBranchFound,
|
|
123
|
+
GetContactBranchNotFound,
|
|
124
|
+
GetContactBranchProviderRejected,
|
|
125
|
+
GetContactBranchInvalidResponse,
|
|
126
|
+
GetContactBranchDefect,
|
|
127
|
+
GetContactDefinition,
|
|
128
|
+
GetContactMetadata,
|
|
129
|
+
Connection,
|
|
130
|
+
newConnection,
|
|
131
|
+
newConnectionWithOperations,
|
|
132
|
+
newProjectCredentialProvider
|
|
133
|
+
};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { SecretString, RefreshingCredentialProvider, Query, ConnectionRef } from '@superdurable/connectors-sdk';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
/** Connector configuration; omitted fields use manifest defaults. */
|
|
5
|
+
interface Config {
|
|
6
|
+
/** Constant Contact V3 API root as an absolute HTTPS URL. Blank uses the displayed public endpoint; override only for a trusted local test gateway. */
|
|
7
|
+
baseUrl?: string;
|
|
8
|
+
/** Maximum duration of one API request as a positive Go duration such as 15s. Blank uses the displayed default; increase for slow responses. Runtime value in milliseconds. */
|
|
9
|
+
timeoutMs?: number;
|
|
10
|
+
/** Maximum complete response in bytes as a positive integer. Blank uses the displayed default; raise only when contact responses are larger than expected. */
|
|
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 access token produced by Constant Contact OAuth and refreshed by Dex. Never enter it manually; blank requires authorization. */
|
|
22
|
+
accessToken: SecretString;
|
|
23
|
+
/** Non-secret API Key from https://app.constantcontact.com/pages/dma/portal/ > My Applications > select the V3 API app. Blank prevents authorization and refresh. */
|
|
24
|
+
oauthClientId: string;
|
|
25
|
+
/** Secret Client Secret from the same My Applications page. Copy it into this secret field only; blank prevents authorization and refresh. */
|
|
26
|
+
oauthClientSecret: SecretString;
|
|
27
|
+
/** Secret refresh token produced by Constant Contact OAuth and rotated by Dex. Never enter it manually; blank requires reauthorization. */
|
|
28
|
+
refreshToken: SecretString;
|
|
29
|
+
}
|
|
30
|
+
/** Decode private credential fields for the connector. */
|
|
31
|
+
declare function decodeCredentials(value: unknown): Credentials;
|
|
32
|
+
/** Decode shared credential fields for the connector. */
|
|
33
|
+
declare function decodeSharedCredentials(value: unknown): Credentials;
|
|
34
|
+
/** Host-owned source of private connector credentials. */
|
|
35
|
+
type CredentialSource = RefreshingCredentialProvider<Credentials>;
|
|
36
|
+
/** GetContactInput selects a contact by the UUID in its V3 API resource. */
|
|
37
|
+
interface GetContactInput {
|
|
38
|
+
/** ContactID is a non-secret V3 contact UUID. */
|
|
39
|
+
"contactId": string;
|
|
40
|
+
}
|
|
41
|
+
/** ContactMetadata contains one contact's identity and optional email permission state. */
|
|
42
|
+
interface ContactMetadata {
|
|
43
|
+
/** ContactID is the V3 contact UUID. */
|
|
44
|
+
"contactId": string;
|
|
45
|
+
/** EmailAddress is absent for a contact with no email channel. */
|
|
46
|
+
"emailAddress"?: string | undefined;
|
|
47
|
+
/** FirstName is the contact's optional given name. */
|
|
48
|
+
"firstName"?: string | undefined;
|
|
49
|
+
/** LastName is the contact's optional family name. */
|
|
50
|
+
"lastName"?: string | undefined;
|
|
51
|
+
/** EmailPermission is Constant Contact's permission_to_send state when an email channel exists. */
|
|
52
|
+
"emailPermission"?: string | undefined;
|
|
53
|
+
}
|
|
54
|
+
/** Runtime validator for GetContactInput. */
|
|
55
|
+
declare const GetContactInputSchema: z.ZodObject<{
|
|
56
|
+
contactId: z.ZodString;
|
|
57
|
+
}, z.core.$strict>;
|
|
58
|
+
/** Runtime validator for ContactMetadata. */
|
|
59
|
+
declare const ContactMetadataSchema: z.ZodObject<{
|
|
60
|
+
contactId: z.ZodString;
|
|
61
|
+
emailAddress: z.ZodOptional<z.ZodString>;
|
|
62
|
+
firstName: z.ZodOptional<z.ZodString>;
|
|
63
|
+
lastName: z.ZodOptional<z.ZodString>;
|
|
64
|
+
emailPermission: z.ZodOptional<z.ZodString>;
|
|
65
|
+
}, z.core.$strict>;
|
|
66
|
+
|
|
67
|
+
/** Typed operations supplied by a client or mock. */
|
|
68
|
+
interface Operations {
|
|
69
|
+
/** Invoke getContact through this connection. */
|
|
70
|
+
getContact(): Query<GetContactInput, ContactMetadata>;
|
|
71
|
+
}
|
|
72
|
+
/** Named connector connection kept outside Flow state. */
|
|
73
|
+
declare class Connection<BoundOperations = Operations> {
|
|
74
|
+
/** Stable provider and connection name. */
|
|
75
|
+
readonly reference: ConnectionRef;
|
|
76
|
+
/** Bound provider operations. */
|
|
77
|
+
readonly operations: BoundOperations;
|
|
78
|
+
/** Validate a reference and bind operations. */
|
|
79
|
+
constructor(reference: ConnectionRef, operations: BoundOperations);
|
|
80
|
+
}
|
|
81
|
+
/** Bind a client to a named connection. */
|
|
82
|
+
declare function newConnection(client: Operations, reference: ConnectionRef): Connection;
|
|
83
|
+
/** Bind scripted operations to a named connection. */
|
|
84
|
+
declare function newConnectionWithOperations(operations: Operations, reference: ConnectionRef): Connection;
|
|
85
|
+
|
|
86
|
+
export { type Config as C, type GetContactInput as G, type Operations as O, type Credentials as a, type ContactMetadata as b, Connection as c, ConfigSchema as d, ContactMetadataSchema as e, type CredentialSource as f, GetContactInputSchema as g, decodeCredentials as h, decodeSharedCredentials as i, newConnectionWithOperations as j, newConnection as n };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { C as Config, a as Credentials, G as GetContactInput, b as ContactMetadata, c as Connection, O as Operations } from './connection-fYrNM2Oe.js';
|
|
2
|
+
export { d as ConfigSchema, e as ContactMetadataSchema, f as CredentialSource, g as GetContactInputSchema, h as decodeCredentials, i as decodeSharedCredentials, n as newConnection, j as newConnectionWithOperations } from './connection-fYrNM2Oe.js';
|
|
3
|
+
import { QueryDefinition, CredentialProvider, CredentialRefreshDriver, Query, Call, QueryAttempt, QueryStepConfig, QueryResult, QueryStep } from '@superdurable/connectors-sdk';
|
|
4
|
+
import { ProviderRequest, ProviderResponse } from '@superdurable/connectors-sdk/providerhttp';
|
|
5
|
+
import { LoadedProject } from '@superdurable/connectors-sdk/projectconfig';
|
|
6
|
+
import { StepTarget } from '@superdurable/dex';
|
|
7
|
+
import 'zod';
|
|
8
|
+
|
|
9
|
+
/** Stable connector identity. */
|
|
10
|
+
declare const ConnectorID = "constantcontact";
|
|
11
|
+
/** Provider identity for named connections. */
|
|
12
|
+
declare const ProviderID = "constantcontact";
|
|
13
|
+
/** Branch IDs for getContact. */
|
|
14
|
+
declare const GetContactBranch: {
|
|
15
|
+
readonly Found: "found";
|
|
16
|
+
readonly NotFound: "notFound";
|
|
17
|
+
readonly ProviderRejected: "providerRejected";
|
|
18
|
+
readonly InvalidResponse: "invalidResponse";
|
|
19
|
+
readonly Defect: "defect";
|
|
20
|
+
};
|
|
21
|
+
/** Constant Contact returned the contact. */
|
|
22
|
+
declare const GetContactBranchFound: "found";
|
|
23
|
+
/** The contact does not exist or is inaccessible. */
|
|
24
|
+
declare const GetContactBranchNotFound: "notFound";
|
|
25
|
+
/** Constant Contact conclusively rejected the request. */
|
|
26
|
+
declare const GetContactBranchProviderRejected: "providerRejected";
|
|
27
|
+
/** Constant Contact returned malformed or oversized JSON. */
|
|
28
|
+
declare const GetContactBranchInvalidResponse: "invalidResponse";
|
|
29
|
+
/** Local input or connection credentials are invalid. */
|
|
30
|
+
declare const GetContactBranchDefect: "defect";
|
|
31
|
+
/** Manifest definition for getContact. */
|
|
32
|
+
declare const GetContactDefinition: QueryDefinition;
|
|
33
|
+
/** Manifest metadata for getContact. */
|
|
34
|
+
declare const GetContactMetadata: {
|
|
35
|
+
readonly kind: "query";
|
|
36
|
+
readonly idempotency: "none";
|
|
37
|
+
readonly authorization: "required";
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/** Injectable provider transport and token refresh dependencies. */
|
|
41
|
+
interface ConstantContactClientOptions {
|
|
42
|
+
/** Provider sender; omitted uses the SDK transport. */ send?: (request: ProviderRequest) => Promise<ProviderResponse>;
|
|
43
|
+
/** OAuth refresh driver; omitted uses the manifest declaration. */ refreshDriver?: CredentialRefreshDriver<Credentials>;
|
|
44
|
+
}
|
|
45
|
+
interface Exchange {
|
|
46
|
+
status: number;
|
|
47
|
+
body: Uint8Array;
|
|
48
|
+
retryAfterMs: number;
|
|
49
|
+
error?: 'credential' | 'refresh' | 'request' | 'read' | 'tooLarge';
|
|
50
|
+
}
|
|
51
|
+
/** Authenticated Constant Contact V3 client with renewable credentials. */
|
|
52
|
+
declare class ConstantContactClient {
|
|
53
|
+
private readonly credentials;
|
|
54
|
+
private readonly baseURL;
|
|
55
|
+
private readonly timeoutMs;
|
|
56
|
+
private readonly maxResponseBytes;
|
|
57
|
+
private readonly refreshDriver;
|
|
58
|
+
private readonly send;
|
|
59
|
+
/** Validate configuration without contacting the provider. */
|
|
60
|
+
constructor(config: Config, credentials: CredentialProvider<Credentials>, options?: ConstantContactClientOptions);
|
|
61
|
+
/** Bind the getContact Query. */ getContact(): GetContactOperation;
|
|
62
|
+
/** Resolve a token and send one bounded contact read. */
|
|
63
|
+
get(call: Call, contactID: string): Promise<Exchange>;
|
|
64
|
+
}
|
|
65
|
+
/** Read one contact's selected identity and email fields. */
|
|
66
|
+
declare class GetContactOperation implements Query<GetContactInput, ContactMetadata> {
|
|
67
|
+
private readonly client;
|
|
68
|
+
/** Bind the provider client. */ constructor(client: ConstantContactClient);
|
|
69
|
+
/** Return the generated Query definition. */ definition(): QueryDefinition;
|
|
70
|
+
/** Classify the provider outcome exactly as the Go implementation does. */
|
|
71
|
+
invoke(call: Call, input: GetContactInput): Promise<QueryAttempt<ContactMetadata>>;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** Open one renewable Constant Contact connection from Dex project configuration. */
|
|
75
|
+
declare function newProjectConnection(project: LoadedProject, connectionName: string, options?: ConstantContactClientOptions): Connection<Operations>;
|
|
76
|
+
|
|
77
|
+
/** Configuration for the getContact connector Step. */
|
|
78
|
+
interface GetContactStepConfig<StepInput, OperationInput = GetContactInput, OperationOutput = ContactMetadata> extends Omit<QueryStepConfig<StepInput, OperationInput, OperationOutput>, 'operation' | 'connection' | 'branches'> {
|
|
79
|
+
/** Named connection supplying this operation. */
|
|
80
|
+
connection: Connection<{
|
|
81
|
+
getContact(): Query<OperationInput, OperationOutput>;
|
|
82
|
+
}>;
|
|
83
|
+
/** Name matching the bound connection. */
|
|
84
|
+
connectionName: string;
|
|
85
|
+
/** Constant Contact returned the contact. */
|
|
86
|
+
found: StepTarget<QueryResult<OperationOutput>>;
|
|
87
|
+
/** The contact does not exist or is inaccessible. */
|
|
88
|
+
notFound?: StepTarget<QueryResult<OperationOutput>>;
|
|
89
|
+
/** Constant Contact conclusively rejected the request. */
|
|
90
|
+
providerRejected?: StepTarget<QueryResult<OperationOutput>>;
|
|
91
|
+
/** Constant Contact returned malformed or oversized JSON. */
|
|
92
|
+
invalidResponse?: StepTarget<QueryResult<OperationOutput>>;
|
|
93
|
+
/** Local input or connection credentials are invalid. */
|
|
94
|
+
defect?: StepTarget<QueryResult<OperationOutput>>;
|
|
95
|
+
}
|
|
96
|
+
/** Build the getContact Step from a named connection. */
|
|
97
|
+
declare function newGetContactStep<StepInput, OperationInput = GetContactInput, OperationOutput = ContactMetadata>(configuration: GetContactStepConfig<StepInput, OperationInput, OperationOutput>): QueryStep<StepInput, OperationInput, OperationOutput>;
|
|
98
|
+
|
|
99
|
+
export { Config, Connection, ConnectorID, ConstantContactClient, type ConstantContactClientOptions, ContactMetadata, Credentials, GetContactBranch, GetContactBranchDefect, GetContactBranchFound, GetContactBranchInvalidResponse, GetContactBranchNotFound, GetContactBranchProviderRejected, GetContactDefinition, GetContactInput, GetContactMetadata, GetContactOperation, type GetContactStepConfig, ProviderID, newGetContactStep, newProjectConnection };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ConfigSchema,
|
|
3
|
+
Connection,
|
|
4
|
+
ConnectorID,
|
|
5
|
+
ContactMetadataSchema,
|
|
6
|
+
GetContactBranch,
|
|
7
|
+
GetContactBranchDefect,
|
|
8
|
+
GetContactBranchFound,
|
|
9
|
+
GetContactBranchInvalidResponse,
|
|
10
|
+
GetContactBranchNotFound,
|
|
11
|
+
GetContactBranchProviderRejected,
|
|
12
|
+
GetContactDefinition,
|
|
13
|
+
GetContactInputSchema,
|
|
14
|
+
GetContactMetadata,
|
|
15
|
+
ProviderID,
|
|
16
|
+
decodeCredentials,
|
|
17
|
+
decodeSharedCredentials,
|
|
18
|
+
newConnection,
|
|
19
|
+
newConnectionWithOperations,
|
|
20
|
+
newProjectCredentialProvider
|
|
21
|
+
} from "./chunk-EKDUUKZQ.js";
|
|
22
|
+
|
|
23
|
+
// src/client.ts
|
|
24
|
+
import {
|
|
25
|
+
ReauthorizationRequiredError,
|
|
26
|
+
SecretString,
|
|
27
|
+
newQueryBranch,
|
|
28
|
+
newQueryRetry,
|
|
29
|
+
resolveCredential
|
|
30
|
+
} from "@superdurable/connectors-sdk";
|
|
31
|
+
import { ManifestCredentialRefreshDriver } from "@superdurable/connectors-sdk/oauthtoken";
|
|
32
|
+
import {
|
|
33
|
+
BodyTooLargeError,
|
|
34
|
+
ProviderTransportError,
|
|
35
|
+
isHeaderSafeCredential,
|
|
36
|
+
parseRetryAfter,
|
|
37
|
+
sendProviderRequest,
|
|
38
|
+
validateBaseURL
|
|
39
|
+
} from "@superdurable/connectors-sdk/providerhttp";
|
|
40
|
+
|
|
41
|
+
// src/generated/refresh.ts
|
|
42
|
+
var Authorization = {
|
|
43
|
+
"fields": [
|
|
44
|
+
{
|
|
45
|
+
"name": "oauth_client_id",
|
|
46
|
+
"required": true,
|
|
47
|
+
"type": "string"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"name": "oauth_client_secret",
|
|
51
|
+
"required": true,
|
|
52
|
+
"type": "secretString"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"name": "access_token",
|
|
56
|
+
"required": true,
|
|
57
|
+
"type": "secretString"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"name": "refresh_token",
|
|
61
|
+
"required": true,
|
|
62
|
+
"type": "secretString"
|
|
63
|
+
}
|
|
64
|
+
],
|
|
65
|
+
"oauth2": {
|
|
66
|
+
"clientIDCredential": "oauth_client_id",
|
|
67
|
+
"clientSecretCredential": "oauth_client_secret",
|
|
68
|
+
"credentialMappings": [
|
|
69
|
+
{
|
|
70
|
+
"credential": "access_token",
|
|
71
|
+
"source": "access_token"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"credential": "refresh_token",
|
|
75
|
+
"source": "refresh_token"
|
|
76
|
+
}
|
|
77
|
+
],
|
|
78
|
+
"refresh": {
|
|
79
|
+
"missingExpiry": "reject",
|
|
80
|
+
"requiredScopes": [
|
|
81
|
+
"contact_data"
|
|
82
|
+
],
|
|
83
|
+
"scopeSeparators": "whitespaceAndComma",
|
|
84
|
+
"storedMissingExpiry": "refresh",
|
|
85
|
+
"terminalErrorCodes": [
|
|
86
|
+
"invalid_grant",
|
|
87
|
+
"invalid_client",
|
|
88
|
+
"unauthorized_client"
|
|
89
|
+
],
|
|
90
|
+
"tokenExchangeTimeout": "15s"
|
|
91
|
+
},
|
|
92
|
+
"scopes": [
|
|
93
|
+
"contact_data",
|
|
94
|
+
"offline_access"
|
|
95
|
+
],
|
|
96
|
+
"tokenEndpoint": "https://authz.constantcontact.com/oauth2/default/v1/token",
|
|
97
|
+
"tokenEndpointAuthMethod": "client_secret_basic"
|
|
98
|
+
},
|
|
99
|
+
"refreshable": true,
|
|
100
|
+
"type": "oauth2"
|
|
101
|
+
};
|
|
102
|
+
var CredentialFields = {
|
|
103
|
+
"access_token": "accessToken",
|
|
104
|
+
"oauth_client_id": "oauthClientId",
|
|
105
|
+
"oauth_client_secret": "oauthClientSecret",
|
|
106
|
+
"refresh_token": "refreshToken"
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
// src/client.ts
|
|
110
|
+
var defaultBaseURL = "https://api.cc.email/v3";
|
|
111
|
+
var contactIDPattern = /^[a-fA-F0-9]{8}-(?:[a-fA-F0-9]{4}-){3}[a-fA-F0-9]{12}$/;
|
|
112
|
+
var emptyContact = () => ({ contactId: "" });
|
|
113
|
+
var ConstantContactClient = class {
|
|
114
|
+
/** Validate configuration without contacting the provider. */
|
|
115
|
+
constructor(config, credentials, options = {}) {
|
|
116
|
+
this.credentials = credentials;
|
|
117
|
+
if (!config || !credentials) throw new TypeError("Constant Contact configuration and credentials are required");
|
|
118
|
+
this.baseURL = validateBaseURL(config.baseUrl || defaultBaseURL);
|
|
119
|
+
this.timeoutMs = config.timeoutMs || 15e3;
|
|
120
|
+
this.maxResponseBytes = config.maxResponseBytes || 1048576;
|
|
121
|
+
if (!Number.isSafeInteger(this.timeoutMs) || this.timeoutMs <= 0 || !Number.isSafeInteger(this.maxResponseBytes) || this.maxResponseBytes <= 0)
|
|
122
|
+
throw new TypeError("Constant Contact request limits must be positive integers");
|
|
123
|
+
this.refreshDriver = options.refreshDriver ?? new ManifestCredentialRefreshDriver({
|
|
124
|
+
providerName: "Constant Contact",
|
|
125
|
+
auth: Authorization,
|
|
126
|
+
credentialFields: CredentialFields
|
|
127
|
+
});
|
|
128
|
+
this.send = options.send ?? sendProviderRequest;
|
|
129
|
+
}
|
|
130
|
+
credentials;
|
|
131
|
+
baseURL;
|
|
132
|
+
timeoutMs;
|
|
133
|
+
maxResponseBytes;
|
|
134
|
+
refreshDriver;
|
|
135
|
+
send;
|
|
136
|
+
/** Bind the getContact Query. */
|
|
137
|
+
getContact() {
|
|
138
|
+
return new GetContactOperation(this);
|
|
139
|
+
}
|
|
140
|
+
/** Resolve a token and send one bounded contact read. */
|
|
141
|
+
async get(call, contactID) {
|
|
142
|
+
let token;
|
|
143
|
+
try {
|
|
144
|
+
const credentials = await resolveCredential(this.credentials, call, this.refreshDriver, call.context.cancellationSignal);
|
|
145
|
+
token = credentials.accessToken instanceof SecretString ? credentials.accessToken.reveal() : "";
|
|
146
|
+
} catch (error) {
|
|
147
|
+
return emptyExchange(error instanceof ReauthorizationRequiredError ? "credential" : "refresh");
|
|
148
|
+
}
|
|
149
|
+
if (!token || !isHeaderSafeCredential(token)) return emptyExchange("credential");
|
|
150
|
+
const request = {
|
|
151
|
+
url: `${this.baseURL}/contacts/${contactID}`,
|
|
152
|
+
method: "GET",
|
|
153
|
+
headers: { Accept: "application/json", Authorization: `Bearer ${token}` },
|
|
154
|
+
maxResponseBytes: this.maxResponseBytes,
|
|
155
|
+
timeoutMs: this.timeoutMs,
|
|
156
|
+
addressPolicy: this.baseURL === defaultBaseURL ? "publicHTTPS" : "privateNetworkHTTP",
|
|
157
|
+
signal: call.context.cancellationSignal
|
|
158
|
+
};
|
|
159
|
+
let response;
|
|
160
|
+
let isTooLarge = false;
|
|
161
|
+
try {
|
|
162
|
+
response = await this.send(request);
|
|
163
|
+
} catch (error) {
|
|
164
|
+
if (error instanceof BodyTooLargeError && error.status !== void 0) {
|
|
165
|
+
response = { status: error.status, headers: error.headers ?? {}, body: new Uint8Array() };
|
|
166
|
+
isTooLarge = true;
|
|
167
|
+
} else if (error instanceof ProviderTransportError) return emptyExchange("request");
|
|
168
|
+
else return emptyExchange("request");
|
|
169
|
+
}
|
|
170
|
+
const retryAfterMs = parseRetryAfter(header(response.headers, "retry-after"));
|
|
171
|
+
if (isTooLarge || response.body.length > this.maxResponseBytes)
|
|
172
|
+
return { status: response.status, body: new Uint8Array(), retryAfterMs, error: "tooLarge" };
|
|
173
|
+
return { status: response.status, body: response.body, retryAfterMs };
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
var GetContactOperation = class {
|
|
177
|
+
/** Bind the provider client. */
|
|
178
|
+
constructor(client) {
|
|
179
|
+
this.client = client;
|
|
180
|
+
}
|
|
181
|
+
client;
|
|
182
|
+
/** Return the generated Query definition. */
|
|
183
|
+
definition() {
|
|
184
|
+
return GetContactDefinition;
|
|
185
|
+
}
|
|
186
|
+
/** Classify the provider outcome exactly as the Go implementation does. */
|
|
187
|
+
async invoke(call, input) {
|
|
188
|
+
if (!input || !contactIDPattern.test(input.contactId))
|
|
189
|
+
return terminal("defect", "VALIDATION", "contact ID must be a UUID");
|
|
190
|
+
const exchange = await this.client.get(call, input.contactId);
|
|
191
|
+
if (exchange.error === "credential") return terminal("defect", "AUTHENTICATION", "Constant Contact credentials are unavailable or invalid");
|
|
192
|
+
if (exchange.error === "refresh") return retry("AVAILABILITY", "Constant Contact credentials could not be refreshed");
|
|
193
|
+
if (exchange.error === "request") return retry("TRANSPORT", "Constant Contact request failed");
|
|
194
|
+
if (exchange.status === 429) return retry("RATE_LIMIT", "Constant Contact rate limited the request", exchange.retryAfterMs);
|
|
195
|
+
if (exchange.status === 408 || exchange.status >= 500)
|
|
196
|
+
return retry("AVAILABILITY", "Constant Contact is temporarily unavailable", exchange.retryAfterMs);
|
|
197
|
+
if (exchange.status === 404) return terminal("notFound", "NOT_FOUND", "Constant Contact did not find the contact");
|
|
198
|
+
if (exchange.status !== 200) return terminal("providerRejected", "PROVIDER_REJECTION", `Constant Contact rejected HTTP ${exchange.status}`);
|
|
199
|
+
if (exchange.error === "tooLarge") return terminal("invalidResponse", "RESPONSE_TOO_LARGE", "Constant Contact response exceeded the configured limit");
|
|
200
|
+
if (exchange.error) return retry("TRANSPORT", "Constant Contact response was interrupted");
|
|
201
|
+
const contact = decodeContact(exchange.body);
|
|
202
|
+
if (!contact) return terminal("invalidResponse", "PROTOCOL", "Constant Contact returned invalid JSON");
|
|
203
|
+
return newQueryBranch("found", contact);
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
function emptyExchange(error) {
|
|
207
|
+
return { status: 0, body: new Uint8Array(), retryAfterMs: 0, error };
|
|
208
|
+
}
|
|
209
|
+
function failure(kind, message) {
|
|
210
|
+
return { provider: "constantcontact", operation: "getContact", kind, message };
|
|
211
|
+
}
|
|
212
|
+
function terminal(branch, kind, message) {
|
|
213
|
+
return newQueryBranch(branch, emptyContact(), {}, failure(kind, message));
|
|
214
|
+
}
|
|
215
|
+
function retry(kind, message, delay = 0) {
|
|
216
|
+
return newQueryRetry(failure(kind, message), delay);
|
|
217
|
+
}
|
|
218
|
+
function header(headers, name) {
|
|
219
|
+
const entry = Object.entries(headers).find(([key]) => key.toLowerCase() === name.toLowerCase())?.[1];
|
|
220
|
+
return Array.isArray(entry) ? entry[0] ?? "" : entry ?? "";
|
|
221
|
+
}
|
|
222
|
+
function isObject(value) {
|
|
223
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
224
|
+
}
|
|
225
|
+
function optionalString(value) {
|
|
226
|
+
return value === void 0 || value === null || value === "" ? void 0 : typeof value === "string" ? value : void 0;
|
|
227
|
+
}
|
|
228
|
+
function decodeContact(body) {
|
|
229
|
+
let raw;
|
|
230
|
+
try {
|
|
231
|
+
raw = JSON.parse(Buffer.from(body).toString("utf8"));
|
|
232
|
+
} catch {
|
|
233
|
+
return void 0;
|
|
234
|
+
}
|
|
235
|
+
if (!isObject(raw) || typeof raw.contact_id !== "string" || !contactIDPattern.test(raw.contact_id)) return void 0;
|
|
236
|
+
const email = raw.email_address ?? {};
|
|
237
|
+
if (!isObject(email)) return void 0;
|
|
238
|
+
const fields = [raw.first_name, raw.last_name, email.address, email.permission_to_send];
|
|
239
|
+
if (fields.some((value) => value !== void 0 && value !== null && typeof value !== "string")) return void 0;
|
|
240
|
+
const result = { contactId: raw.contact_id };
|
|
241
|
+
const address = optionalString(email.address);
|
|
242
|
+
const firstName = optionalString(raw.first_name);
|
|
243
|
+
const lastName = optionalString(raw.last_name);
|
|
244
|
+
const permission = optionalString(email.permission_to_send);
|
|
245
|
+
if (address) result.emailAddress = address;
|
|
246
|
+
if (firstName) result.firstName = firstName;
|
|
247
|
+
if (lastName) result.lastName = lastName;
|
|
248
|
+
if (permission) result.emailPermission = permission;
|
|
249
|
+
return result;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// src/project.ts
|
|
253
|
+
import { z } from "zod";
|
|
254
|
+
function encodeCredentials(credentials) {
|
|
255
|
+
return {
|
|
256
|
+
oauth_client_id: credentials.oauthClientId,
|
|
257
|
+
oauth_client_secret: credentials.oauthClientSecret.reveal(),
|
|
258
|
+
access_token: credentials.accessToken.reveal(),
|
|
259
|
+
refresh_token: credentials.refreshToken.reveal()
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
function newProjectConnection(project, connectionName, options = {}) {
|
|
263
|
+
if (!project) throw new TypeError("Constant Contact project is required");
|
|
264
|
+
const selected = project.configuration.connections.find((entry) => entry.connectorId === "constantcontact" && entry.connectionName === connectionName);
|
|
265
|
+
if (!selected || selected.provider !== "constantcontact") throw new TypeError("Constant Contact project connection is not configured");
|
|
266
|
+
const fields = z.strictObject({
|
|
267
|
+
baseUrl: z.string().optional(),
|
|
268
|
+
timeout: z.union([z.string(), z.number().int()]).optional(),
|
|
269
|
+
maxResponseBytes: z.number().int().optional()
|
|
270
|
+
}).parse(selected.configuration);
|
|
271
|
+
const timeoutMs = typeof fields.timeout === "number" ? Math.ceil(fields.timeout / 1e6) : fields.timeout ? parseDurationMilliseconds(fields.timeout) : void 0;
|
|
272
|
+
const config = {
|
|
273
|
+
...fields.baseUrl !== void 0 ? { baseUrl: fields.baseUrl } : {},
|
|
274
|
+
...timeoutMs !== void 0 ? { timeoutMs } : {},
|
|
275
|
+
...fields.maxResponseBytes !== void 0 ? { maxResponseBytes: fields.maxResponseBytes } : {}
|
|
276
|
+
};
|
|
277
|
+
const provider = newProjectCredentialProvider(project, connectionName, decodeCredentials, encodeCredentials, decodeSharedCredentials);
|
|
278
|
+
return newConnection(new ConstantContactClient(config, provider, options), { provider: "constantcontact", name: connectionName });
|
|
279
|
+
}
|
|
280
|
+
function parseDurationMilliseconds(value) {
|
|
281
|
+
let remaining = value;
|
|
282
|
+
let milliseconds = 0;
|
|
283
|
+
const units = { ns: 1e-6, us: 1e-3, "\xB5s": 1e-3, ms: 1, s: 1e3, m: 6e4, h: 36e5 };
|
|
284
|
+
while (remaining) {
|
|
285
|
+
const part = /^(\d+(?:\.\d+)?)(ns|us|µs|ms|s|m|h)/.exec(remaining);
|
|
286
|
+
if (!part) throw new TypeError("Constant Contact timeout must be a positive Go duration");
|
|
287
|
+
milliseconds += Number(part[1]) * (units[part[2] ?? ""] ?? NaN);
|
|
288
|
+
remaining = remaining.slice(part[0].length);
|
|
289
|
+
}
|
|
290
|
+
if (!Number.isSafeInteger(milliseconds) || milliseconds <= 0)
|
|
291
|
+
throw new TypeError("Constant Contact timeout must resolve to positive whole milliseconds");
|
|
292
|
+
return milliseconds;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
// src/generated/steps.ts
|
|
296
|
+
import { goToBranch, newQueryStep } from "@superdurable/connectors-sdk";
|
|
297
|
+
function newGetContactStep(configuration) {
|
|
298
|
+
const { connection, connectionName, found, notFound, providerRejected, invalidResponse, defect, ...stepConfiguration } = configuration;
|
|
299
|
+
if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
|
|
300
|
+
return newQueryStep({ ...stepConfiguration, operation: connection.operations.getContact(), connection: connection.reference, branches: [
|
|
301
|
+
goToBranch("found", found),
|
|
302
|
+
...notFound ? [goToBranch("notFound", notFound)] : [],
|
|
303
|
+
...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
|
|
304
|
+
...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
|
|
305
|
+
...defect ? [goToBranch("defect", defect)] : []
|
|
306
|
+
] });
|
|
307
|
+
}
|
|
308
|
+
export {
|
|
309
|
+
ConfigSchema,
|
|
310
|
+
Connection,
|
|
311
|
+
ConnectorID,
|
|
312
|
+
ConstantContactClient,
|
|
313
|
+
ContactMetadataSchema,
|
|
314
|
+
GetContactBranch,
|
|
315
|
+
GetContactBranchDefect,
|
|
316
|
+
GetContactBranchFound,
|
|
317
|
+
GetContactBranchInvalidResponse,
|
|
318
|
+
GetContactBranchNotFound,
|
|
319
|
+
GetContactBranchProviderRejected,
|
|
320
|
+
GetContactDefinition,
|
|
321
|
+
GetContactInputSchema,
|
|
322
|
+
GetContactMetadata,
|
|
323
|
+
GetContactOperation,
|
|
324
|
+
ProviderID,
|
|
325
|
+
decodeCredentials,
|
|
326
|
+
decodeSharedCredentials,
|
|
327
|
+
newConnection,
|
|
328
|
+
newConnectionWithOperations,
|
|
329
|
+
newGetContactStep,
|
|
330
|
+
newProjectConnection
|
|
331
|
+
};
|
package/dist/mock.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { MockQuery, Case } from '@superdurable/connectors-sdk/connectormock';
|
|
2
|
+
import { Failure } from '@superdurable/connectors-sdk';
|
|
3
|
+
import { O as Operations, c as Connection, G as GetContactInput, b as ContactMetadata } from './connection-fYrNM2Oe.js';
|
|
4
|
+
import 'zod';
|
|
5
|
+
|
|
6
|
+
/** Go zero value for GetContactInput in scripted cases. */
|
|
7
|
+
declare const emptyGetContactInput: GetContactInput;
|
|
8
|
+
/** Go zero value for ContactMetadata in scripted cases. */
|
|
9
|
+
declare const emptyContactMetadata: ContactMetadata;
|
|
10
|
+
/** Script the found branch. */
|
|
11
|
+
declare function getContactFound(value: ContactMetadata, failure?: Failure): Case<ContactMetadata>;
|
|
12
|
+
/** Script the notFound branch. */
|
|
13
|
+
declare function getContactNotFound(value: ContactMetadata, failure?: Failure): Case<ContactMetadata>;
|
|
14
|
+
/** Script the providerRejected branch. */
|
|
15
|
+
declare function getContactProviderRejected(value: ContactMetadata, failure?: Failure): Case<ContactMetadata>;
|
|
16
|
+
/** Script the invalidResponse branch. */
|
|
17
|
+
declare function getContactInvalidResponse(value: ContactMetadata, failure?: Failure): Case<ContactMetadata>;
|
|
18
|
+
/** Script the defect branch. */
|
|
19
|
+
declare function getContactDefect(value: ContactMetadata, failure?: Failure): Case<ContactMetadata>;
|
|
20
|
+
/** Script a safe retry of getContact. */
|
|
21
|
+
declare function getContactRetry(failure: Failure, retryAfterMs?: number): Case<ContactMetadata>;
|
|
22
|
+
/** Manifest scenario foundDefault for getContact. */
|
|
23
|
+
declare function getContactFoundDefault(): Case<ContactMetadata>;
|
|
24
|
+
/** Default getContact scenario. */
|
|
25
|
+
declare function getContactDefault(): Case<ContactMetadata>;
|
|
26
|
+
/** Manifest scenario contactMissing for getContact. */
|
|
27
|
+
declare function getContactContactMissing(): Case<ContactMetadata>;
|
|
28
|
+
/** Scripted operations and manifest defaults for this connector. */
|
|
29
|
+
declare class GeneratedMock implements Operations {
|
|
30
|
+
#private;
|
|
31
|
+
constructor(connectionName: string);
|
|
32
|
+
connection(): Connection;
|
|
33
|
+
getContact(): MockQuery<GetContactInput, ContactMetadata>;
|
|
34
|
+
assertNoFailures(): void;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export { GeneratedMock, emptyContactMetadata, emptyGetContactInput, getContactContactMissing, getContactDefault, getContactDefect, getContactFound, getContactFoundDefault, getContactInvalidResponse, getContactNotFound, getContactProviderRejected, getContactRetry };
|
package/dist/mock.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ConnectorID,
|
|
3
|
+
ContactMetadataSchema,
|
|
4
|
+
GetContactDefinition,
|
|
5
|
+
GetContactInputSchema,
|
|
6
|
+
ProviderID,
|
|
7
|
+
newConnectionWithOperations
|
|
8
|
+
} from "./chunk-EKDUUKZQ.js";
|
|
9
|
+
|
|
10
|
+
// src/generated/mock.ts
|
|
11
|
+
import { branchCase, retryCase, newQuery } from "@superdurable/connectors-sdk/connectormock";
|
|
12
|
+
var emptyGetContactInput = GetContactInputSchema.parse({
|
|
13
|
+
"contactId": ""
|
|
14
|
+
});
|
|
15
|
+
var emptyContactMetadata = ContactMetadataSchema.parse({
|
|
16
|
+
"contactId": ""
|
|
17
|
+
});
|
|
18
|
+
function getContactFound(value, failure) {
|
|
19
|
+
return branchCase("found", value, failure);
|
|
20
|
+
}
|
|
21
|
+
function getContactNotFound(value, failure) {
|
|
22
|
+
return branchCase("notFound", value, failure);
|
|
23
|
+
}
|
|
24
|
+
function getContactProviderRejected(value, failure) {
|
|
25
|
+
return branchCase("providerRejected", value, failure);
|
|
26
|
+
}
|
|
27
|
+
function getContactInvalidResponse(value, failure) {
|
|
28
|
+
return branchCase("invalidResponse", value, failure);
|
|
29
|
+
}
|
|
30
|
+
function getContactDefect(value, failure) {
|
|
31
|
+
return branchCase("defect", value, failure);
|
|
32
|
+
}
|
|
33
|
+
function getContactRetry(failure, retryAfterMs = 0) {
|
|
34
|
+
return retryCase(failure, retryAfterMs);
|
|
35
|
+
}
|
|
36
|
+
function getContactFoundDefault() {
|
|
37
|
+
const value = ContactMetadataSchema.parse({ "contactId": "1898ae62-4752-11e9-9c8a-fa163e6b01c1", "emailAddress": "reader@example.com", "emailPermission": "explicit", "firstName": "Avery", "lastName": "Reader" });
|
|
38
|
+
return branchCase("found", value);
|
|
39
|
+
}
|
|
40
|
+
function getContactDefault() {
|
|
41
|
+
return getContactFoundDefault();
|
|
42
|
+
}
|
|
43
|
+
function getContactContactMissing() {
|
|
44
|
+
const value = emptyContactMetadata;
|
|
45
|
+
return branchCase("notFound", value, { kind: "NOT_FOUND", provider: ConnectorID, operation: "getContact", message: "Constant Contact did not find the contact." });
|
|
46
|
+
}
|
|
47
|
+
var GeneratedMock = class {
|
|
48
|
+
#getContact;
|
|
49
|
+
#connection;
|
|
50
|
+
constructor(connectionName) {
|
|
51
|
+
this.#getContact = newQuery(GetContactDefinition).default(getContactDefault());
|
|
52
|
+
this.#connection = newConnectionWithOperations(this, { provider: ProviderID, name: connectionName });
|
|
53
|
+
}
|
|
54
|
+
connection() {
|
|
55
|
+
return this.#connection;
|
|
56
|
+
}
|
|
57
|
+
getContact() {
|
|
58
|
+
return this.#getContact;
|
|
59
|
+
}
|
|
60
|
+
assertNoFailures() {
|
|
61
|
+
this.#getContact.assertNoFailures();
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
export {
|
|
65
|
+
GeneratedMock,
|
|
66
|
+
emptyContactMetadata,
|
|
67
|
+
emptyGetContactInput,
|
|
68
|
+
getContactContactMissing,
|
|
69
|
+
getContactDefault,
|
|
70
|
+
getContactDefect,
|
|
71
|
+
getContactFound,
|
|
72
|
+
getContactFoundDefault,
|
|
73
|
+
getContactInvalidResponse,
|
|
74
|
+
getContactNotFound,
|
|
75
|
+
getContactProviderRejected,
|
|
76
|
+
getContactRetry
|
|
77
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,61 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superdurable/connector-constantcontact",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"description": "Constant Contact connector for Dex TypeScript applications",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/superdurable/dex-connectors-library.git",
|
|
9
|
+
"directory": "connectors/constantcontact/typescript"
|
|
10
|
+
},
|
|
11
|
+
"type": "module",
|
|
12
|
+
"engines": {
|
|
13
|
+
"node": "^22.0.0 || ^24.0.0"
|
|
14
|
+
},
|
|
15
|
+
"module": "./dist/index.js",
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"import": "./dist/index.js"
|
|
21
|
+
},
|
|
22
|
+
"./mock": {
|
|
23
|
+
"types": "./dist/mock.d.ts",
|
|
24
|
+
"import": "./dist/mock.js"
|
|
25
|
+
},
|
|
26
|
+
"./dex-connector.json": "./dex-connector.json"
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"dist",
|
|
30
|
+
"README.md",
|
|
31
|
+
"LICENSE",
|
|
32
|
+
"dex-connector.json"
|
|
33
|
+
],
|
|
34
|
+
"scripts": {
|
|
35
|
+
"prepack": "npm run build",
|
|
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": "vitest run --exclude test/integration/**",
|
|
40
|
+
"test:integration": "vitest run test/integration/*.integration.test.ts",
|
|
41
|
+
"example:worker": "tsx examples/contact-inspection/worker.ts",
|
|
42
|
+
"example:start": "tsx examples/contact-inspection/start.ts",
|
|
43
|
+
"check": "npm run typecheck && npm run lint && npm test && npm run build"
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@superdurable/connectors-sdk": "0.7.0",
|
|
47
|
+
"@superdurable/dex": ">=1.28.0",
|
|
48
|
+
"zod": "^4.1.0"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@eslint/js": "^9.0.0",
|
|
52
|
+
"@types/node": "^22.0.0",
|
|
53
|
+
"eslint": "^9.0.0",
|
|
54
|
+
"tsup": "^8.0.0",
|
|
55
|
+
"tsx": "^4.23.15",
|
|
56
|
+
"typescript": "^5.9.0",
|
|
57
|
+
"typescript-eslint": "^8.0.0",
|
|
58
|
+
"vitest": "^3.0.0",
|
|
59
|
+
"yaml": "^2.9.1"
|
|
60
|
+
}
|
|
61
|
+
}
|