@superdurable/connector-constantcontact 0.1.0 → 0.2.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdurable/connector-constantcontact",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "license": "MIT",
5
5
  "description": "Constant Contact connector for Dex TypeScript applications",
6
6
  "repository": {
@@ -36,14 +36,14 @@
36
36
  "build": "tsup src/index.ts src/mock.ts --format esm --dts --clean",
37
37
  "typecheck": "tsc --noEmit",
38
38
  "lint": "eslint src test examples",
39
- "test": "vitest run --exclude test/integration/**",
39
+ "test": "vitest run --exclude 'test/integration/**'",
40
40
  "test:integration": "vitest run test/integration/*.integration.test.ts",
41
41
  "example:worker": "tsx examples/contact-inspection/worker.ts",
42
42
  "example:start": "tsx examples/contact-inspection/start.ts",
43
43
  "check": "npm run typecheck && npm run lint && npm test && npm run build"
44
44
  },
45
45
  "dependencies": {
46
- "@superdurable/connectors-sdk": "0.7.0",
46
+ "@superdurable/connectors-sdk": "0.13.0",
47
47
  "@superdurable/dex": ">=1.28.0",
48
48
  "zod": "^4.1.0"
49
49
  },
@@ -1,133 +0,0 @@
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
- };
@@ -1,86 +0,0 @@
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 };