@superdurable/connector-copper 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/dex-connector.json +1661 -7
- package/dist/chunk-HEWAN7RM.js +1335 -0
- package/dist/connection-Sm_oLyz3.d.ts +830 -0
- package/dist/index.d.ts +1679 -25
- package/dist/index.js +1902 -45
- package/dist/mock.d.ts +584 -5
- package/dist/mock.js +1417 -5
- package/package.json +3 -3
- package/dist/chunk-ND3EMY5U.js +0 -149
- package/dist/connection-91oJS2hl.d.ts +0 -108
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superdurable/connector-copper",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Copper 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/lead-status-discovery/worker.ts",
|
|
42
42
|
"example:start": "tsx examples/lead-status-discovery/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.
|
|
46
|
+
"@superdurable/connectors-sdk": "0.13.0",
|
|
47
47
|
"@superdurable/dex": ">=1.28.0",
|
|
48
48
|
"zod": "^4.1.0"
|
|
49
49
|
},
|
package/dist/chunk-ND3EMY5U.js
DELETED
|
@@ -1,149 +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(["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
|
-
};
|
|
@@ -1,108 +0,0 @@
|
|
|
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 };
|