@superdurable/connector-copper 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,7 @@
1
- # Temporary Holding Version
1
+ # Copper 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
+ This package implements `listLeadStatuses` and `getLead` for Dex TypeScript Flows. Both operations replay the Go reference's provider requests, branches, retries, and exact outputs through shared conformance scenarios. Custom fields and email addresses remain outside Flow results.
4
+
5
+ Sign in as an admin to [Copper](https://app.copper.com/), open **Settings > Integrations > API Keys**, generate a key, and save it in the Dex Web secret `api_key` field. Save the generating user's Copper login email in `user_email`. Leave `baseUrl` blank for the Developer API v1 default. The [connector README](../README.md) describes operation inputs and defaults; [lead status discovery](examples/lead-status-discovery/README.md) is the runnable Flow.
6
+
7
+ JavaScript numbers cannot represent Copper numeric IDs above the safe integer limit exactly; such provider responses select `invalidResponse`. Live Copper authorization and responses have not been verified locally. Package release is independent of the Go and Python releases.
@@ -0,0 +1,106 @@
1
+ {
2
+ "connectorId": "copper",
3
+ "releaseTag": "connectors/copper/go/v0.1.0",
4
+ "package": {
5
+ "ecosystem": "npm",
6
+ "name": "@superdurable/connector-copper",
7
+ "version": "0.1.0"
8
+ },
9
+ "factories": [
10
+ {
11
+ "name": "newListLeadStatusesStep",
12
+ "kind": "query",
13
+ "operationId": "listLeadStatuses",
14
+ "inputType": "ListLeadStatusesInput",
15
+ "description": "List stable IDs and names of Copper lead statuses.",
16
+ "fields": {
17
+ "stepType": "stepType",
18
+ "annotations": "annotations",
19
+ "connectionName": "connectionName",
20
+ "resultAttribute": "resultAttribute"
21
+ },
22
+ "branches": [
23
+ {
24
+ "id": "listed",
25
+ "field": "listed",
26
+ "optional": false
27
+ },
28
+ {
29
+ "id": "providerRejected",
30
+ "field": "providerRejected",
31
+ "optional": true
32
+ },
33
+ {
34
+ "id": "invalidResponse",
35
+ "field": "invalidResponse",
36
+ "optional": true
37
+ },
38
+ {
39
+ "id": "defect",
40
+ "field": "defect",
41
+ "optional": true
42
+ }
43
+ ],
44
+ "inputSchema": {
45
+ "additionalProperties": false,
46
+ "description": "ListLeadStatusesInput selects lead statuses visible to the connected Copper user.",
47
+ "properties": {},
48
+ "type": "object"
49
+ }
50
+ },
51
+ {
52
+ "name": "newGetLeadStep",
53
+ "kind": "query",
54
+ "operationId": "getLead",
55
+ "inputType": "GetLeadInput",
56
+ "description": "Read a Copper lead's ID, name, status, and company name by ID.",
57
+ "fields": {
58
+ "stepType": "stepType",
59
+ "annotations": "annotations",
60
+ "connectionName": "connectionName",
61
+ "resultAttribute": "resultAttribute"
62
+ },
63
+ "branches": [
64
+ {
65
+ "id": "found",
66
+ "field": "found",
67
+ "optional": false
68
+ },
69
+ {
70
+ "id": "notFound",
71
+ "field": "notFound",
72
+ "optional": true
73
+ },
74
+ {
75
+ "id": "providerRejected",
76
+ "field": "providerRejected",
77
+ "optional": true
78
+ },
79
+ {
80
+ "id": "invalidResponse",
81
+ "field": "invalidResponse",
82
+ "optional": true
83
+ },
84
+ {
85
+ "id": "defect",
86
+ "field": "defect",
87
+ "optional": true
88
+ }
89
+ ],
90
+ "inputSchema": {
91
+ "additionalProperties": false,
92
+ "description": "GetLeadInput selects a Copper lead by its numeric ID.",
93
+ "properties": {
94
+ "leadId": {
95
+ "description": "LeadID is the numeric ID shown on a Copper lead and returned by its API.",
96
+ "type": "string"
97
+ }
98
+ },
99
+ "required": [
100
+ "leadId"
101
+ ],
102
+ "type": "object"
103
+ }
104
+ }
105
+ ]
106
+ }
@@ -0,0 +1,149 @@
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(["api_key", "user_email"]);
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["api_key"] != null && !(typeof fields["api_key"] === "string")) throw new TypeError("credential api_key has an invalid type");
15
+ if (fields["user_email"] != null && !(typeof fields["user_email"] === "string")) throw new TypeError("credential user_email has an invalid type");
16
+ const credentials = {};
17
+ if (!fields["api_key"]) throw new TypeError("credential api_key is required");
18
+ credentials.apiKey = new SecretString(fields["api_key"] ?? "");
19
+ if (!fields["user_email"]) throw new TypeError("credential user_email is required");
20
+ credentials.userEmail = new SecretString(fields["user_email"] ?? "");
21
+ return credentials;
22
+ }
23
+ var ListLeadStatusesInputSchema = z.strictObject({});
24
+ var LeadStatusMetadataSchema = z.strictObject({
25
+ "id": z.number().int(),
26
+ "name": z.string()
27
+ });
28
+ var LeadStatusesListSchema = z.strictObject({
29
+ "statuses": z.array(LeadStatusMetadataSchema).nullable()
30
+ });
31
+ var GetLeadInputSchema = z.strictObject({
32
+ "leadId": z.string()
33
+ });
34
+ var LeadMetadataSchema = z.strictObject({
35
+ "id": z.number().int(),
36
+ "name": z.string(),
37
+ "status": z.string(),
38
+ "companyName": z.string()
39
+ });
40
+
41
+ // src/generated/definitions.ts
42
+ var ConnectorID = "copper";
43
+ var ProviderID = "copper";
44
+ var ListLeadStatusesBranch = {
45
+ Listed: "listed",
46
+ ProviderRejected: "providerRejected",
47
+ InvalidResponse: "invalidResponse",
48
+ Defect: "defect"
49
+ };
50
+ var ListLeadStatusesBranchListed = ListLeadStatusesBranch.Listed;
51
+ var ListLeadStatusesBranchProviderRejected = ListLeadStatusesBranch.ProviderRejected;
52
+ var ListLeadStatusesBranchInvalidResponse = ListLeadStatusesBranch.InvalidResponse;
53
+ var ListLeadStatusesBranchDefect = ListLeadStatusesBranch.Defect;
54
+ var ListLeadStatusesDefinition = {
55
+ operation: { connectorId: ConnectorID, operationId: "listLeadStatuses" },
56
+ branches: [
57
+ { id: "listed", description: "Copper returned lead statuses." },
58
+ { id: "providerRejected", description: "Copper conclusively rejected the request.", optional: true },
59
+ { id: "invalidResponse", description: "Copper returned malformed or oversized JSON.", optional: true },
60
+ { id: "defect", description: "Connection credentials are invalid.", optional: true }
61
+ ],
62
+ stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "async" }
63
+ };
64
+ var ListLeadStatusesMetadata = { kind: "query", idempotency: "none", authorization: "required" };
65
+ var GetLeadBranch = {
66
+ Found: "found",
67
+ NotFound: "notFound",
68
+ ProviderRejected: "providerRejected",
69
+ InvalidResponse: "invalidResponse",
70
+ Defect: "defect"
71
+ };
72
+ var GetLeadBranchFound = GetLeadBranch.Found;
73
+ var GetLeadBranchNotFound = GetLeadBranch.NotFound;
74
+ var GetLeadBranchProviderRejected = GetLeadBranch.ProviderRejected;
75
+ var GetLeadBranchInvalidResponse = GetLeadBranch.InvalidResponse;
76
+ var GetLeadBranchDefect = GetLeadBranch.Defect;
77
+ var GetLeadDefinition = {
78
+ operation: { connectorId: ConnectorID, operationId: "getLead" },
79
+ branches: [
80
+ { id: "found", description: "Copper returned the selected lead." },
81
+ { id: "notFound", description: "No lead matches this ID.", optional: true },
82
+ { id: "providerRejected", description: "Copper conclusively rejected the request.", optional: true },
83
+ { id: "invalidResponse", description: "Copper returned malformed or oversized JSON.", optional: true },
84
+ { id: "defect", description: "Invalid input or unavailable credentials.", optional: true }
85
+ ],
86
+ stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "async" }
87
+ };
88
+ var GetLeadMetadata = { kind: "query", idempotency: "none", authorization: "required" };
89
+
90
+ // src/generated/connection.ts
91
+ import { ConnectionRefSchema } from "@superdurable/connectors-sdk";
92
+ var Connection = class {
93
+ /** Stable provider and connection name. */
94
+ reference;
95
+ /** Bound provider operations. */
96
+ operations;
97
+ /** Validate a reference and bind operations. */
98
+ constructor(reference, operations) {
99
+ this.reference = ConnectionRefSchema.parse(reference);
100
+ if (this.reference.provider !== ProviderID) throw new TypeError("connection provider differs from the manifest");
101
+ if (!operations) throw new TypeError("connector operations are required");
102
+ this.operations = operations;
103
+ }
104
+ };
105
+ function newConnection(client, reference) {
106
+ if (!client) throw new TypeError("connector client is required");
107
+ return new Connection(reference, client);
108
+ }
109
+ function newConnectionWithOperations(operations, reference) {
110
+ return new Connection(reference, operations);
111
+ }
112
+ function newProjectConnection(project, connectionName, createClient) {
113
+ if (!project) throw new TypeError("loaded project is required");
114
+ const reference = ConnectionRefSchema.parse({ provider: ProviderID, name: connectionName });
115
+ const selected = project.configuration.connections.find((entry) => entry.connectorId === ConnectorID && entry.connectionName === connectionName);
116
+ if (!selected || selected.provider !== ProviderID) throw new TypeError("project connection is not configured");
117
+ return newConnection(createClient(project, connectionName), reference);
118
+ }
119
+
120
+ export {
121
+ ConfigSchema,
122
+ decodeCredentials,
123
+ ListLeadStatusesInputSchema,
124
+ LeadStatusMetadataSchema,
125
+ LeadStatusesListSchema,
126
+ GetLeadInputSchema,
127
+ LeadMetadataSchema,
128
+ ConnectorID,
129
+ ProviderID,
130
+ ListLeadStatusesBranch,
131
+ ListLeadStatusesBranchListed,
132
+ ListLeadStatusesBranchProviderRejected,
133
+ ListLeadStatusesBranchInvalidResponse,
134
+ ListLeadStatusesBranchDefect,
135
+ ListLeadStatusesDefinition,
136
+ ListLeadStatusesMetadata,
137
+ GetLeadBranch,
138
+ GetLeadBranchFound,
139
+ GetLeadBranchNotFound,
140
+ GetLeadBranchProviderRejected,
141
+ GetLeadBranchInvalidResponse,
142
+ GetLeadBranchDefect,
143
+ GetLeadDefinition,
144
+ GetLeadMetadata,
145
+ Connection,
146
+ newConnection,
147
+ newConnectionWithOperations,
148
+ newProjectConnection
149
+ };
@@ -0,0 +1,108 @@
1
+ import { SecretString, CredentialProvider, Query, ConnectionRef } from '@superdurable/connectors-sdk';
2
+ import { z } from 'zod';
3
+
4
+ /** Connector configuration; omitted fields use manifest defaults. */
5
+ interface Config {
6
+ /** HTTPS Copper Developer API v1 root. Blank uses the displayed default; override only for a compatible private test endpoint. */
7
+ baseUrl?: string;
8
+ /** Maximum duration of one API request as a positive Go duration such as 15s or 1m. Blank uses the displayed default; increase for slow responses. Runtime value in milliseconds. */
9
+ timeoutMs?: number;
10
+ /** Positive maximum complete API response in bytes. Blank uses the displayed default; increase for large status lists. Oversized responses select invalidResponse. */
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 API key from https://app.copper.com/ under Settings > Integrations > API Keys. Generate and copy the full token; blank makes calls select defect. Revoke it on that page when retired. */
22
+ apiKey: SecretString;
23
+ /** Email address of the Copper user who generated the API key. Use the generating user's Copper login email; enter a complete address such as user@example.com. Blank makes calls select defect. Stored as a credential and never placed in Flow state. */
24
+ userEmail: SecretString;
25
+ }
26
+ /** Decode private credential fields for the connector. */
27
+ declare function decodeCredentials(value: unknown): Credentials;
28
+ /** Host-owned source of private connector credentials. */
29
+ type CredentialSource = CredentialProvider<Credentials>;
30
+ /** ListLeadStatusesInput selects lead statuses visible to the connected Copper user. */
31
+ interface ListLeadStatusesInput {
32
+ }
33
+ /** LeadStatusMetadata identifies one Copper lead status without private fields. */
34
+ interface LeadStatusMetadata {
35
+ /** ID is the stable Copper status identifier. */
36
+ "id": number;
37
+ /** Name is the status display name. */
38
+ "name": string;
39
+ }
40
+ /** LeadStatusesList contains visible lead status identities. */
41
+ interface LeadStatusesList {
42
+ /** Statuses contains only IDs and names. */
43
+ "statuses": Array<LeadStatusMetadata> | null;
44
+ }
45
+ /** GetLeadInput selects a Copper lead by its numeric ID. */
46
+ interface GetLeadInput {
47
+ /** LeadID is the numeric ID shown on a Copper lead and returned by its API. */
48
+ "leadId": string;
49
+ }
50
+ /** LeadMetadata contains the lead's ID, name, status, and company name. */
51
+ interface LeadMetadata {
52
+ /** ID is the stable Copper lead identifier. */
53
+ "id": number;
54
+ /** Name is the lead display name. */
55
+ "name": string;
56
+ /** Status is the current lead status name. */
57
+ "status": string;
58
+ /** CompanyName is the associated company name when available. */
59
+ "companyName": string;
60
+ }
61
+ /** Runtime validator for ListLeadStatusesInput. */
62
+ declare const ListLeadStatusesInputSchema: z.ZodObject<{}, z.core.$strict>;
63
+ /** Runtime validator for LeadStatusMetadata. */
64
+ declare const LeadStatusMetadataSchema: z.ZodObject<{
65
+ id: z.ZodNumber;
66
+ name: z.ZodString;
67
+ }, z.core.$strict>;
68
+ /** Runtime validator for LeadStatusesList. */
69
+ declare const LeadStatusesListSchema: z.ZodObject<{
70
+ statuses: z.ZodNullable<z.ZodArray<z.ZodObject<{
71
+ id: z.ZodNumber;
72
+ name: z.ZodString;
73
+ }, z.core.$strict>>>;
74
+ }, z.core.$strict>;
75
+ /** Runtime validator for GetLeadInput. */
76
+ declare const GetLeadInputSchema: z.ZodObject<{
77
+ leadId: z.ZodString;
78
+ }, z.core.$strict>;
79
+ /** Runtime validator for LeadMetadata. */
80
+ declare const LeadMetadataSchema: z.ZodObject<{
81
+ id: z.ZodNumber;
82
+ name: z.ZodString;
83
+ status: z.ZodString;
84
+ companyName: z.ZodString;
85
+ }, z.core.$strict>;
86
+
87
+ /** Typed operations supplied by a client or mock. */
88
+ interface Operations {
89
+ /** Invoke listLeadStatuses through this connection. */
90
+ listLeadStatuses(): Query<ListLeadStatusesInput, LeadStatusesList>;
91
+ /** Invoke getLead through this connection. */
92
+ getLead(): Query<GetLeadInput, LeadMetadata>;
93
+ }
94
+ /** Named connector connection kept outside Flow state. */
95
+ declare class Connection<BoundOperations = Operations> {
96
+ /** Stable provider and connection name. */
97
+ readonly reference: ConnectionRef;
98
+ /** Bound provider operations. */
99
+ readonly operations: BoundOperations;
100
+ /** Validate a reference and bind operations. */
101
+ constructor(reference: ConnectionRef, operations: BoundOperations);
102
+ }
103
+ /** Bind a client to a named connection. */
104
+ declare function newConnection(client: Operations, reference: ConnectionRef): Connection;
105
+ /** Bind scripted operations to a named connection. */
106
+ declare function newConnectionWithOperations(operations: Operations, reference: ConnectionRef): Connection;
107
+
108
+ export { Connection as C, type GetLeadInput as G, type LeadMetadata as L, type Operations as O, type ListLeadStatusesInput as a, type LeadStatusesList as b, type Config as c, type Credentials as d, ConfigSchema as e, type CredentialSource as f, GetLeadInputSchema as g, LeadMetadataSchema as h, type LeadStatusMetadata as i, LeadStatusMetadataSchema as j, LeadStatusesListSchema as k, ListLeadStatusesInputSchema as l, decodeCredentials as m, newConnection as n, newConnectionWithOperations as o };
@@ -0,0 +1,149 @@
1
+ import { G as GetLeadInput, L as LeadMetadata, C as Connection, a as ListLeadStatusesInput, b as LeadStatusesList, O as Operations, c as Config, d as Credentials } from './connection-91oJS2hl.js';
2
+ export { e as ConfigSchema, f as CredentialSource, g as GetLeadInputSchema, h as LeadMetadataSchema, i as LeadStatusMetadata, j as LeadStatusMetadataSchema, k as LeadStatusesListSchema, l as ListLeadStatusesInputSchema, m as decodeCredentials, n as newConnection, o as newConnectionWithOperations } from './connection-91oJS2hl.js';
3
+ import { QueryDefinition, QueryStepConfig, Query, QueryResult, QueryStep, CredentialProvider, Call, QueryAttempt, Failure } from '@superdurable/connectors-sdk';
4
+ import { StepTarget } from '@superdurable/dex';
5
+ import { LoadedProject } from '@superdurable/connectors-sdk/projectconfig';
6
+ import { ProviderRequest, ProviderResponse } from '@superdurable/connectors-sdk/providerhttp';
7
+ import 'zod';
8
+
9
+ /** Stable connector identity. */
10
+ declare const ConnectorID = "copper";
11
+ /** Provider identity for named connections. */
12
+ declare const ProviderID = "copper";
13
+ /** Branch IDs for listLeadStatuses. */
14
+ declare const ListLeadStatusesBranch: {
15
+ readonly Listed: "listed";
16
+ readonly ProviderRejected: "providerRejected";
17
+ readonly InvalidResponse: "invalidResponse";
18
+ readonly Defect: "defect";
19
+ };
20
+ /** Copper returned lead statuses. */
21
+ declare const ListLeadStatusesBranchListed: "listed";
22
+ /** Copper conclusively rejected the request. */
23
+ declare const ListLeadStatusesBranchProviderRejected: "providerRejected";
24
+ /** Copper returned malformed or oversized JSON. */
25
+ declare const ListLeadStatusesBranchInvalidResponse: "invalidResponse";
26
+ /** Connection credentials are invalid. */
27
+ declare const ListLeadStatusesBranchDefect: "defect";
28
+ /** Manifest definition for listLeadStatuses. */
29
+ declare const ListLeadStatusesDefinition: QueryDefinition;
30
+ /** Manifest metadata for listLeadStatuses. */
31
+ declare const ListLeadStatusesMetadata: {
32
+ readonly kind: "query";
33
+ readonly idempotency: "none";
34
+ readonly authorization: "required";
35
+ };
36
+ /** Branch IDs for getLead. */
37
+ declare const GetLeadBranch: {
38
+ readonly Found: "found";
39
+ readonly NotFound: "notFound";
40
+ readonly ProviderRejected: "providerRejected";
41
+ readonly InvalidResponse: "invalidResponse";
42
+ readonly Defect: "defect";
43
+ };
44
+ /** Copper returned the selected lead. */
45
+ declare const GetLeadBranchFound: "found";
46
+ /** No lead matches this ID. */
47
+ declare const GetLeadBranchNotFound: "notFound";
48
+ /** Copper conclusively rejected the request. */
49
+ declare const GetLeadBranchProviderRejected: "providerRejected";
50
+ /** Copper returned malformed or oversized JSON. */
51
+ declare const GetLeadBranchInvalidResponse: "invalidResponse";
52
+ /** Invalid input or unavailable credentials. */
53
+ declare const GetLeadBranchDefect: "defect";
54
+ /** Manifest definition for getLead. */
55
+ declare const GetLeadDefinition: QueryDefinition;
56
+ /** Manifest metadata for getLead. */
57
+ declare const GetLeadMetadata: {
58
+ readonly kind: "query";
59
+ readonly idempotency: "none";
60
+ readonly authorization: "required";
61
+ };
62
+
63
+ /** Configuration for the listLeadStatuses connector Step. */
64
+ interface ListLeadStatusesStepConfig<StepInput, OperationInput = ListLeadStatusesInput, OperationOutput = LeadStatusesList> extends Omit<QueryStepConfig<StepInput, OperationInput, OperationOutput>, 'operation' | 'connection' | 'branches'> {
65
+ /** Named connection supplying this operation. */
66
+ connection: Connection<{
67
+ listLeadStatuses(): Query<OperationInput, OperationOutput>;
68
+ }>;
69
+ /** Name matching the bound connection. */
70
+ connectionName: string;
71
+ /** Copper returned lead statuses. */
72
+ listed: StepTarget<QueryResult<OperationOutput>>;
73
+ /** Copper conclusively rejected the request. */
74
+ providerRejected?: StepTarget<QueryResult<OperationOutput>>;
75
+ /** Copper returned malformed or oversized JSON. */
76
+ invalidResponse?: StepTarget<QueryResult<OperationOutput>>;
77
+ /** Connection credentials are invalid. */
78
+ defect?: StepTarget<QueryResult<OperationOutput>>;
79
+ }
80
+ /** Build the listLeadStatuses Step from a named connection. */
81
+ declare function newListLeadStatusesStep<StepInput, OperationInput = ListLeadStatusesInput, OperationOutput = LeadStatusesList>(configuration: ListLeadStatusesStepConfig<StepInput, OperationInput, OperationOutput>): QueryStep<StepInput, OperationInput, OperationOutput>;
82
+ /** Configuration for the getLead connector Step. */
83
+ interface GetLeadStepConfig<StepInput, OperationInput = GetLeadInput, OperationOutput = LeadMetadata> extends Omit<QueryStepConfig<StepInput, OperationInput, OperationOutput>, 'operation' | 'connection' | 'branches'> {
84
+ /** Named connection supplying this operation. */
85
+ connection: Connection<{
86
+ getLead(): Query<OperationInput, OperationOutput>;
87
+ }>;
88
+ /** Name matching the bound connection. */
89
+ connectionName: string;
90
+ /** Copper returned the selected lead. */
91
+ found: StepTarget<QueryResult<OperationOutput>>;
92
+ /** No lead matches this ID. */
93
+ notFound?: StepTarget<QueryResult<OperationOutput>>;
94
+ /** Copper conclusively rejected the request. */
95
+ providerRejected?: StepTarget<QueryResult<OperationOutput>>;
96
+ /** Copper returned malformed or oversized JSON. */
97
+ invalidResponse?: StepTarget<QueryResult<OperationOutput>>;
98
+ /** Invalid input or unavailable credentials. */
99
+ defect?: StepTarget<QueryResult<OperationOutput>>;
100
+ }
101
+ /** Build the getLead Step from a named connection. */
102
+ declare function newGetLeadStep<StepInput, OperationInput = GetLeadInput, OperationOutput = LeadMetadata>(configuration: GetLeadStepConfig<StepInput, OperationInput, OperationOutput>): QueryStep<StepInput, OperationInput, OperationOutput>;
103
+
104
+ /** Open one named Copper connection from Dex project configuration. */
105
+ declare function newProjectConnection(project: LoadedProject, connectionName: string): Connection<Operations>;
106
+
107
+ /** Optional transport dependency for provider tests and local Dex examples. */
108
+ interface CopperClientOptions {
109
+ /** One bounded provider request sender. */ send?: (request: ProviderRequest) => Promise<ProviderResponse>;
110
+ }
111
+ interface ProviderOutcome {
112
+ body?: Uint8Array;
113
+ branch?: string;
114
+ failure?: Failure;
115
+ retry?: boolean;
116
+ retryAfterMs?: number;
117
+ }
118
+ /** Authenticated Copper Developer API v1 client with call-time credential resolution. */
119
+ declare class CopperClient {
120
+ private readonly credentials;
121
+ private readonly baseUrl;
122
+ private readonly timeoutMs;
123
+ private readonly maxResponseBytes;
124
+ private readonly sendRequest;
125
+ /** Validate connection configuration without contacting Copper. */
126
+ constructor(config: Config, credentials: CredentialProvider<Credentials>, options?: CopperClientOptions);
127
+ /** Bind the lead status discovery Query. */ listLeadStatuses(): ListLeadStatusesOperation;
128
+ /** Bind the lead metadata Query. */ getLead(): GetLeadOperation;
129
+ /** Send one read and classify transport, HTTP, and response-size outcomes. */
130
+ exchange(call: Call, operation: string, path: string, hasNotFound: boolean): Promise<ProviderOutcome>;
131
+ }
132
+ /** List Copper lead status IDs and names without private fields. */
133
+ declare class ListLeadStatusesOperation implements Query<ListLeadStatusesInput, LeadStatusesList> {
134
+ private readonly client;
135
+ /** Bind the provider client. */ constructor(client: CopperClient);
136
+ /** Return the manifest-generated operation definition. */ definition(): QueryDefinition;
137
+ /** Read visible lead status identities. */
138
+ invoke(call: Call, input: ListLeadStatusesInput): Promise<QueryAttempt<LeadStatusesList>>;
139
+ }
140
+ /** Read one Copper lead's identity and status without custom fields. */
141
+ declare class GetLeadOperation implements Query<GetLeadInput, LeadMetadata> {
142
+ private readonly client;
143
+ /** Bind the provider client. */ constructor(client: CopperClient);
144
+ /** Return the manifest-generated operation definition. */ definition(): QueryDefinition;
145
+ /** Validate the lead ID and read its metadata. */
146
+ invoke(call: Call, input: GetLeadInput): Promise<QueryAttempt<LeadMetadata>>;
147
+ }
148
+
149
+ export { Config, Connection, ConnectorID, CopperClient, type CopperClientOptions, Credentials, GetLeadBranch, GetLeadBranchDefect, GetLeadBranchFound, GetLeadBranchInvalidResponse, GetLeadBranchNotFound, GetLeadBranchProviderRejected, GetLeadDefinition, GetLeadInput, GetLeadMetadata, GetLeadOperation, type GetLeadStepConfig, LeadMetadata, LeadStatusesList, ListLeadStatusesBranch, ListLeadStatusesBranchDefect, ListLeadStatusesBranchInvalidResponse, ListLeadStatusesBranchListed, ListLeadStatusesBranchProviderRejected, ListLeadStatusesDefinition, ListLeadStatusesInput, ListLeadStatusesMetadata, ListLeadStatusesOperation, type ListLeadStatusesStepConfig, ProviderID, newGetLeadStep, newListLeadStatusesStep, newProjectConnection };
package/dist/index.js ADDED
@@ -0,0 +1,278 @@
1
+ import {
2
+ ConfigSchema,
3
+ Connection,
4
+ ConnectorID,
5
+ GetLeadBranch,
6
+ GetLeadBranchDefect,
7
+ GetLeadBranchFound,
8
+ GetLeadBranchInvalidResponse,
9
+ GetLeadBranchNotFound,
10
+ GetLeadBranchProviderRejected,
11
+ GetLeadDefinition,
12
+ GetLeadInputSchema,
13
+ GetLeadMetadata,
14
+ LeadMetadataSchema,
15
+ LeadStatusMetadataSchema,
16
+ LeadStatusesListSchema,
17
+ ListLeadStatusesBranch,
18
+ ListLeadStatusesBranchDefect,
19
+ ListLeadStatusesBranchInvalidResponse,
20
+ ListLeadStatusesBranchListed,
21
+ ListLeadStatusesBranchProviderRejected,
22
+ ListLeadStatusesDefinition,
23
+ ListLeadStatusesInputSchema,
24
+ ListLeadStatusesMetadata,
25
+ ProviderID,
26
+ decodeCredentials,
27
+ newConnection,
28
+ newConnectionWithOperations,
29
+ newProjectConnection
30
+ } from "./chunk-ND3EMY5U.js";
31
+
32
+ // src/generated/steps.ts
33
+ import { goToBranch, newQueryStep } from "@superdurable/connectors-sdk";
34
+ function newListLeadStatusesStep(configuration) {
35
+ const { connection, connectionName, listed, providerRejected, invalidResponse, defect, ...stepConfiguration } = configuration;
36
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
37
+ return newQueryStep({ ...stepConfiguration, operation: connection.operations.listLeadStatuses(), connection: connection.reference, branches: [
38
+ goToBranch("listed", listed),
39
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
40
+ ...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
41
+ ...defect ? [goToBranch("defect", defect)] : []
42
+ ] });
43
+ }
44
+ function newGetLeadStep(configuration) {
45
+ const { connection, connectionName, found, notFound, providerRejected, invalidResponse, defect, ...stepConfiguration } = configuration;
46
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
47
+ return newQueryStep({ ...stepConfiguration, operation: connection.operations.getLead(), connection: connection.reference, branches: [
48
+ goToBranch("found", found),
49
+ ...notFound ? [goToBranch("notFound", notFound)] : [],
50
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
51
+ ...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
52
+ ...defect ? [goToBranch("defect", defect)] : []
53
+ ] });
54
+ }
55
+
56
+ // src/project.ts
57
+ import { SecretString as SecretString2 } from "@superdurable/connectors-sdk";
58
+ import { z } from "zod";
59
+
60
+ // src/client.ts
61
+ import { SecretString, newQueryBranch, newQueryRetry } from "@superdurable/connectors-sdk";
62
+ import { BodyTooLargeError, isHeaderSafeCredential, parseRetryAfter, sendProviderRequest, validateBaseURL } from "@superdurable/connectors-sdk/providerhttp";
63
+ var emptyStatuses = () => ({ statuses: [] });
64
+ var emptyLead = () => ({ id: 0, name: "", status: "", companyName: "" });
65
+ var userAgent = "Dex Connector (https://superdurable.io)";
66
+ var CopperClient = class {
67
+ /** Validate connection configuration without contacting Copper. */
68
+ constructor(config, credentials, options = {}) {
69
+ this.credentials = credentials;
70
+ if (!credentials) throw new TypeError("Copper credential source is required");
71
+ this.baseUrl = validateBaseURL(config.baseUrl || "https://api.copper.com/developer_api/v1");
72
+ this.timeoutMs = config.timeoutMs || 15e3;
73
+ this.maxResponseBytes = config.maxResponseBytes || 1048576;
74
+ if (!Number.isSafeInteger(this.timeoutMs) || this.timeoutMs <= 0) throw new TypeError("Copper timeout is invalid");
75
+ if (!Number.isSafeInteger(this.maxResponseBytes) || this.maxResponseBytes <= 0) throw new TypeError("Copper response limit is invalid");
76
+ this.sendRequest = options.send ?? sendProviderRequest;
77
+ }
78
+ credentials;
79
+ baseUrl;
80
+ timeoutMs;
81
+ maxResponseBytes;
82
+ sendRequest;
83
+ /** Bind the lead status discovery Query. */
84
+ listLeadStatuses() {
85
+ return new ListLeadStatusesOperation(this);
86
+ }
87
+ /** Bind the lead metadata Query. */
88
+ getLead() {
89
+ return new GetLeadOperation(this);
90
+ }
91
+ /** Send one read and classify transport, HTTP, and response-size outcomes. */
92
+ async exchange(call, operation, path, hasNotFound) {
93
+ let apiKey;
94
+ let userEmail;
95
+ try {
96
+ const resolved = await this.credentials.resolve(call, call.context.cancellationSignal);
97
+ apiKey = resolved.apiKey instanceof SecretString ? resolved.apiKey.reveal() : "";
98
+ userEmail = resolved.userEmail instanceof SecretString ? resolved.userEmail.reveal() : "";
99
+ } catch {
100
+ return { branch: "defect", failure: failure(operation, "AUTHENTICATION", "connection credentials are unavailable or invalid") };
101
+ }
102
+ if (!isHeaderSafeCredential(apiKey) || !isHeaderSafeCredential(userEmail) || !userEmail.includes("@") || userEmail.trim() !== userEmail) return { branch: "defect", failure: failure(operation, "AUTHENTICATION", "connection credentials are unavailable or invalid") };
103
+ const request = {
104
+ url: `${this.baseUrl}${path}`,
105
+ method: "GET",
106
+ headers: { Accept: "application/json", "Content-Type": "application/json", "X-PW-AccessToken": apiKey, "X-PW-Application": "developer_api", "X-PW-UserEmail": userEmail, "User-Agent": userAgent },
107
+ maxResponseBytes: this.maxResponseBytes,
108
+ timeoutMs: this.timeoutMs,
109
+ addressPolicy: this.baseUrl.startsWith("https://") ? "publicHTTPS" : "privateNetworkHTTP",
110
+ signal: call.context.cancellationSignal
111
+ };
112
+ let response;
113
+ try {
114
+ response = await this.sendRequest(request);
115
+ } catch (error) {
116
+ if (error instanceof BodyTooLargeError && error.status !== void 0) {
117
+ response = { status: error.status, headers: error.headers ?? {}, body: new Uint8Array() };
118
+ if (response.status === 200) return { branch: "invalidResponse", failure: failure(operation, "RESPONSE_TOO_LARGE", "Copper response exceeded the configured limit") };
119
+ } else return { retry: true, failure: failure(operation, "TRANSPORT", "Copper request failed") };
120
+ }
121
+ const status = response.status;
122
+ const retryAfter = parseRetryAfter(headerValue(response.headers["retry-after"]));
123
+ if (status === 429) return { retry: true, retryAfterMs: retryAfter, failure: failure(operation, "RATE_LIMIT", "Copper rate limited the request") };
124
+ if (status === 408 || status >= 500) return { retry: true, retryAfterMs: retryAfter, failure: failure(operation, "AVAILABILITY", "Copper is temporarily unavailable") };
125
+ if (status === 404 && hasNotFound) return { branch: "notFound", failure: failure(operation, "NOT_FOUND", "Copper did not find the resource") };
126
+ if (status !== 200) return { branch: "providerRejected", failure: failure(operation, "PROVIDER_REJECTION", `Copper rejected HTTP ${status}`) };
127
+ if (response.body.length > this.maxResponseBytes) return { branch: "invalidResponse", failure: failure(operation, "RESPONSE_TOO_LARGE", "Copper response exceeded the configured limit") };
128
+ return { body: response.body };
129
+ }
130
+ };
131
+ var ListLeadStatusesOperation = class {
132
+ /** Bind the provider client. */
133
+ constructor(client) {
134
+ this.client = client;
135
+ }
136
+ client;
137
+ /** Return the manifest-generated operation definition. */
138
+ definition() {
139
+ return ListLeadStatusesDefinition;
140
+ }
141
+ /** Read visible lead status identities. */
142
+ async invoke(call, input) {
143
+ if (!input || typeof input !== "object") return terminal("listLeadStatuses", "defect", "VALIDATION", "lead status list input is invalid", emptyStatuses());
144
+ const result = await this.client.exchange(call, "listLeadStatuses", "/lead_statuses", false);
145
+ if (result.retry) return newQueryRetry(result.failure, result.retryAfterMs);
146
+ if (result.failure) return newQueryBranch(result.branch, emptyStatuses(), {}, result.failure);
147
+ const document = parseJSON(result.body);
148
+ if (!Array.isArray(document)) return invalid("listLeadStatuses", emptyStatuses());
149
+ const statuses = [];
150
+ for (const item of document) {
151
+ if (!isObject(item) || !isPositiveSafeInteger(item.id) || typeof item.name !== "string" || !item.name) return invalid("listLeadStatuses", emptyStatuses());
152
+ statuses.push({ id: item.id, name: item.name });
153
+ }
154
+ return newQueryBranch("listed", { statuses });
155
+ }
156
+ };
157
+ var GetLeadOperation = class {
158
+ /** Bind the provider client. */
159
+ constructor(client) {
160
+ this.client = client;
161
+ }
162
+ client;
163
+ /** Return the manifest-generated operation definition. */
164
+ definition() {
165
+ return GetLeadDefinition;
166
+ }
167
+ /** Validate the lead ID and read its metadata. */
168
+ async invoke(call, input) {
169
+ if (!isValidLeadID(input)) return terminal("getLead", "defect", "VALIDATION", "lead ID must be a positive decimal identifier", emptyLead());
170
+ const result = await this.client.exchange(call, "getLead", `/leads/${input.leadId}`, true);
171
+ if (result.retry) return newQueryRetry(result.failure, result.retryAfterMs);
172
+ if (result.failure) return newQueryBranch(result.branch, emptyLead(), {}, result.failure);
173
+ const document = parseJSON(result.body);
174
+ if (!isObject(document) || !isPositiveSafeInteger(document.id) || typeof document.name !== "string" || !document.name || typeof document.status !== "string" || !document.status || document.company_name !== void 0 && document.company_name !== null && typeof document.company_name !== "string") return invalid("getLead", emptyLead());
175
+ return newQueryBranch("found", { id: document.id, name: document.name, status: document.status, companyName: document.company_name ?? "" });
176
+ }
177
+ };
178
+ function isValidLeadID(input) {
179
+ if (!input || typeof input.leadId !== "string" || !/^[0-9]+$/.test(input.leadId)) return false;
180
+ const significantDigits = input.leadId.replace(/^0+/, "");
181
+ return significantDigits.length > 0 && significantDigits.length <= 19 && BigInt(significantDigits) <= 9223372036854775807n;
182
+ }
183
+ function isPositiveSafeInteger(value) {
184
+ return typeof value === "number" && Number.isSafeInteger(value) && value > 0;
185
+ }
186
+ function failure(operation, kind, message) {
187
+ return { provider: "copper", operation, kind, message };
188
+ }
189
+ function terminal(operation, branch, kind, message, empty) {
190
+ return newQueryBranch(branch, empty, {}, failure(operation, kind, message));
191
+ }
192
+ function invalid(operation, empty) {
193
+ return terminal(operation, "invalidResponse", "PROTOCOL", "Copper returned invalid JSON", empty);
194
+ }
195
+ function isObject(value) {
196
+ return typeof value === "object" && value !== null && !Array.isArray(value);
197
+ }
198
+ function parseJSON(body) {
199
+ try {
200
+ return JSON.parse(Buffer.from(body).toString("utf8"));
201
+ } catch {
202
+ return void 0;
203
+ }
204
+ }
205
+ function headerValue(value) {
206
+ return Array.isArray(value) ? value[0] ?? "" : value ?? "";
207
+ }
208
+
209
+ // src/project.ts
210
+ function newProjectConnection2(project, connectionName) {
211
+ return newProjectConnection(project, connectionName, (loadedProject, name) => {
212
+ const selected = loadedProject.configuration.connections.find((entry) => entry.connectorId === "copper" && entry.connectionName === name);
213
+ if (!selected) throw new TypeError("Copper project connection is not configured");
214
+ 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);
215
+ const timeoutMs = typeof fields.timeout === "number" ? Math.ceil(fields.timeout / 1e6) : fields.timeout ? parseDurationMilliseconds(fields.timeout) : void 0;
216
+ const config = {
217
+ ...fields.baseUrl ? { baseUrl: fields.baseUrl } : {},
218
+ ...timeoutMs !== void 0 ? { timeoutMs } : {},
219
+ ...fields.maxResponseBytes !== void 0 ? { maxResponseBytes: fields.maxResponseBytes } : {}
220
+ };
221
+ const credentials = {
222
+ async resolve(_call, signal) {
223
+ const privateFields = await loadedProject.resolveCredential("copper", name, signal);
224
+ if (typeof privateFields.api_key !== "string" || typeof privateFields.user_email !== "string") throw new TypeError("Copper credentials are unavailable");
225
+ return { apiKey: new SecretString2(privateFields.api_key), userEmail: new SecretString2(privateFields.user_email) };
226
+ }
227
+ };
228
+ return new CopperClient(config, credentials);
229
+ });
230
+ }
231
+ function parseDurationMilliseconds(value) {
232
+ let remaining = value;
233
+ let milliseconds = 0;
234
+ const units = { ns: 1e-6, us: 1e-3, "\xB5s": 1e-3, ms: 1, s: 1e3, m: 6e4, h: 36e5 };
235
+ while (remaining) {
236
+ const part = /^(\d+(?:\.\d+)?)(ns|us|µs|ms|s|m|h)/.exec(remaining);
237
+ if (!part) throw new TypeError("Copper timeout must be a positive Go duration");
238
+ milliseconds += Number(part[1]) * (units[part[2] ?? ""] ?? NaN);
239
+ remaining = remaining.slice(part[0].length);
240
+ }
241
+ if (!Number.isSafeInteger(milliseconds) || milliseconds <= 0) throw new TypeError("Copper timeout must resolve to positive whole milliseconds");
242
+ return milliseconds;
243
+ }
244
+ export {
245
+ ConfigSchema,
246
+ Connection,
247
+ ConnectorID,
248
+ CopperClient,
249
+ GetLeadBranch,
250
+ GetLeadBranchDefect,
251
+ GetLeadBranchFound,
252
+ GetLeadBranchInvalidResponse,
253
+ GetLeadBranchNotFound,
254
+ GetLeadBranchProviderRejected,
255
+ GetLeadDefinition,
256
+ GetLeadInputSchema,
257
+ GetLeadMetadata,
258
+ GetLeadOperation,
259
+ LeadMetadataSchema,
260
+ LeadStatusMetadataSchema,
261
+ LeadStatusesListSchema,
262
+ ListLeadStatusesBranch,
263
+ ListLeadStatusesBranchDefect,
264
+ ListLeadStatusesBranchInvalidResponse,
265
+ ListLeadStatusesBranchListed,
266
+ ListLeadStatusesBranchProviderRejected,
267
+ ListLeadStatusesDefinition,
268
+ ListLeadStatusesInputSchema,
269
+ ListLeadStatusesMetadata,
270
+ ListLeadStatusesOperation,
271
+ ProviderID,
272
+ decodeCredentials,
273
+ newConnection,
274
+ newConnectionWithOperations,
275
+ newGetLeadStep,
276
+ newListLeadStatusesStep,
277
+ newProjectConnection2 as newProjectConnection
278
+ };
package/dist/mock.d.ts ADDED
@@ -0,0 +1,56 @@
1
+ import { MockQuery, Case } from '@superdurable/connectors-sdk/connectormock';
2
+ import { Failure } from '@superdurable/connectors-sdk';
3
+ import { O as Operations, C as Connection, a as ListLeadStatusesInput, b as LeadStatusesList, G as GetLeadInput, L as LeadMetadata, i as LeadStatusMetadata } from './connection-91oJS2hl.js';
4
+ import 'zod';
5
+
6
+ /** Go zero value for ListLeadStatusesInput in scripted cases. */
7
+ declare const emptyListLeadStatusesInput: ListLeadStatusesInput;
8
+ /** Go zero value for LeadStatusMetadata in scripted cases. */
9
+ declare const emptyLeadStatusMetadata: LeadStatusMetadata;
10
+ /** Go zero value for LeadStatusesList in scripted cases. */
11
+ declare const emptyLeadStatusesList: LeadStatusesList;
12
+ /** Go zero value for GetLeadInput in scripted cases. */
13
+ declare const emptyGetLeadInput: GetLeadInput;
14
+ /** Go zero value for LeadMetadata in scripted cases. */
15
+ declare const emptyLeadMetadata: LeadMetadata;
16
+ /** Script the listed branch. */
17
+ declare function listLeadStatusesListed(value: LeadStatusesList, failure?: Failure): Case<LeadStatusesList>;
18
+ /** Script the providerRejected branch. */
19
+ declare function listLeadStatusesProviderRejected(value: LeadStatusesList, failure?: Failure): Case<LeadStatusesList>;
20
+ /** Script the invalidResponse branch. */
21
+ declare function listLeadStatusesInvalidResponse(value: LeadStatusesList, failure?: Failure): Case<LeadStatusesList>;
22
+ /** Script the defect branch. */
23
+ declare function listLeadStatusesDefect(value: LeadStatusesList, failure?: Failure): Case<LeadStatusesList>;
24
+ /** Script a safe retry of listLeadStatuses. */
25
+ declare function listLeadStatusesRetry(failure: Failure, retryAfterMs?: number): Case<LeadStatusesList>;
26
+ /** Manifest scenario listedDefault for listLeadStatuses. */
27
+ declare function listLeadStatusesListedDefault(): Case<LeadStatusesList>;
28
+ /** Default listLeadStatuses scenario. */
29
+ declare function listLeadStatusesDefault(): Case<LeadStatusesList>;
30
+ /** Script the found branch. */
31
+ declare function getLeadFound(value: LeadMetadata, failure?: Failure): Case<LeadMetadata>;
32
+ /** Script the notFound branch. */
33
+ declare function getLeadNotFound(value: LeadMetadata, failure?: Failure): Case<LeadMetadata>;
34
+ /** Script the providerRejected branch. */
35
+ declare function getLeadProviderRejected(value: LeadMetadata, failure?: Failure): Case<LeadMetadata>;
36
+ /** Script the invalidResponse branch. */
37
+ declare function getLeadInvalidResponse(value: LeadMetadata, failure?: Failure): Case<LeadMetadata>;
38
+ /** Script the defect branch. */
39
+ declare function getLeadDefect(value: LeadMetadata, failure?: Failure): Case<LeadMetadata>;
40
+ /** Script a safe retry of getLead. */
41
+ declare function getLeadRetry(failure: Failure, retryAfterMs?: number): Case<LeadMetadata>;
42
+ /** Manifest scenario foundDefault for getLead. */
43
+ declare function getLeadFoundDefault(): Case<LeadMetadata>;
44
+ /** Default getLead scenario. */
45
+ declare function getLeadDefault(): Case<LeadMetadata>;
46
+ /** Scripted operations and manifest defaults for this connector. */
47
+ declare class GeneratedMock implements Operations {
48
+ #private;
49
+ constructor(connectionName: string);
50
+ connection(): Connection;
51
+ listLeadStatuses(): MockQuery<ListLeadStatusesInput, LeadStatusesList>;
52
+ getLead(): MockQuery<GetLeadInput, LeadMetadata>;
53
+ assertNoFailures(): void;
54
+ }
55
+
56
+ export { GeneratedMock, GeneratedMock as Mock, emptyGetLeadInput, emptyLeadMetadata, emptyLeadStatusMetadata, emptyLeadStatusesList, emptyListLeadStatusesInput, getLeadDefault, getLeadDefect, getLeadFound, getLeadFoundDefault, getLeadInvalidResponse, getLeadNotFound, getLeadProviderRejected, getLeadRetry, listLeadStatusesDefault, listLeadStatusesDefect, listLeadStatusesInvalidResponse, listLeadStatusesListed, listLeadStatusesListedDefault, listLeadStatusesProviderRejected, listLeadStatusesRetry };
package/dist/mock.js ADDED
@@ -0,0 +1,125 @@
1
+ import {
2
+ GetLeadDefinition,
3
+ GetLeadInputSchema,
4
+ LeadMetadataSchema,
5
+ LeadStatusMetadataSchema,
6
+ LeadStatusesListSchema,
7
+ ListLeadStatusesDefinition,
8
+ ListLeadStatusesInputSchema,
9
+ ProviderID,
10
+ newConnectionWithOperations
11
+ } from "./chunk-ND3EMY5U.js";
12
+
13
+ // src/generated/mock.ts
14
+ import { branchCase, retryCase, newQuery } from "@superdurable/connectors-sdk/connectormock";
15
+ var emptyListLeadStatusesInput = ListLeadStatusesInputSchema.parse({});
16
+ var emptyLeadStatusMetadata = LeadStatusMetadataSchema.parse({
17
+ "id": 0,
18
+ "name": ""
19
+ });
20
+ var emptyLeadStatusesList = LeadStatusesListSchema.parse({
21
+ "statuses": []
22
+ });
23
+ var emptyGetLeadInput = GetLeadInputSchema.parse({
24
+ "leadId": ""
25
+ });
26
+ var emptyLeadMetadata = LeadMetadataSchema.parse({
27
+ "id": 0,
28
+ "name": "",
29
+ "status": "",
30
+ "companyName": ""
31
+ });
32
+ function listLeadStatusesListed(value, failure) {
33
+ return branchCase("listed", value, failure);
34
+ }
35
+ function listLeadStatusesProviderRejected(value, failure) {
36
+ return branchCase("providerRejected", value, failure);
37
+ }
38
+ function listLeadStatusesInvalidResponse(value, failure) {
39
+ return branchCase("invalidResponse", value, failure);
40
+ }
41
+ function listLeadStatusesDefect(value, failure) {
42
+ return branchCase("defect", value, failure);
43
+ }
44
+ function listLeadStatusesRetry(failure, retryAfterMs = 0) {
45
+ return retryCase(failure, retryAfterMs);
46
+ }
47
+ function listLeadStatusesListedDefault() {
48
+ const value = LeadStatusesListSchema.parse({ "statuses": [{ "id": 208231, "name": "New" }] });
49
+ return branchCase("listed", value);
50
+ }
51
+ function listLeadStatusesDefault() {
52
+ return listLeadStatusesListedDefault();
53
+ }
54
+ function getLeadFound(value, failure) {
55
+ return branchCase("found", value, failure);
56
+ }
57
+ function getLeadNotFound(value, failure) {
58
+ return branchCase("notFound", value, failure);
59
+ }
60
+ function getLeadProviderRejected(value, failure) {
61
+ return branchCase("providerRejected", value, failure);
62
+ }
63
+ function getLeadInvalidResponse(value, failure) {
64
+ return branchCase("invalidResponse", value, failure);
65
+ }
66
+ function getLeadDefect(value, failure) {
67
+ return branchCase("defect", value, failure);
68
+ }
69
+ function getLeadRetry(failure, retryAfterMs = 0) {
70
+ return retryCase(failure, retryAfterMs);
71
+ }
72
+ function getLeadFoundDefault() {
73
+ const value = LeadMetadataSchema.parse({ "companyName": "Example Company", "id": 8894157, "name": "Sample Lead", "status": "New" });
74
+ return branchCase("found", value);
75
+ }
76
+ function getLeadDefault() {
77
+ return getLeadFoundDefault();
78
+ }
79
+ var GeneratedMock = class {
80
+ #listLeadStatuses;
81
+ #getLead;
82
+ #connection;
83
+ constructor(connectionName) {
84
+ this.#listLeadStatuses = newQuery(ListLeadStatusesDefinition).default(listLeadStatusesDefault());
85
+ this.#getLead = newQuery(GetLeadDefinition).default(getLeadDefault());
86
+ this.#connection = newConnectionWithOperations(this, { provider: ProviderID, name: connectionName });
87
+ }
88
+ connection() {
89
+ return this.#connection;
90
+ }
91
+ listLeadStatuses() {
92
+ return this.#listLeadStatuses;
93
+ }
94
+ getLead() {
95
+ return this.#getLead;
96
+ }
97
+ assertNoFailures() {
98
+ this.#listLeadStatuses.assertNoFailures();
99
+ this.#getLead.assertNoFailures();
100
+ }
101
+ };
102
+ export {
103
+ GeneratedMock,
104
+ GeneratedMock as Mock,
105
+ emptyGetLeadInput,
106
+ emptyLeadMetadata,
107
+ emptyLeadStatusMetadata,
108
+ emptyLeadStatusesList,
109
+ emptyListLeadStatusesInput,
110
+ getLeadDefault,
111
+ getLeadDefect,
112
+ getLeadFound,
113
+ getLeadFoundDefault,
114
+ getLeadInvalidResponse,
115
+ getLeadNotFound,
116
+ getLeadProviderRejected,
117
+ getLeadRetry,
118
+ listLeadStatusesDefault,
119
+ listLeadStatusesDefect,
120
+ listLeadStatusesInvalidResponse,
121
+ listLeadStatusesListed,
122
+ listLeadStatusesListedDefault,
123
+ listLeadStatusesProviderRejected,
124
+ listLeadStatusesRetry
125
+ };
package/package.json CHANGED
@@ -1,6 +1,61 @@
1
1
  {
2
2
  "name": "@superdurable/connector-copper",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "license": "MIT",
5
+ "description": "Copper connector for Dex TypeScript applications",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/superdurable/dex-connectors-library.git",
9
+ "directory": "connectors/copper/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/lead-status-discovery/worker.ts",
42
+ "example:start": "tsx examples/lead-status-discovery/start.ts",
43
+ "check": "npm run typecheck && npm run lint && npm test && npm run build"
44
+ },
45
+ "dependencies": {
46
+ "@superdurable/connectors-sdk": "0.1.1",
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
+ }