@superdurable/connector-braintree 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/README.md +3 -1
- package/dex-connector.json +1356 -2
- package/dist/chunk-KA52AO5W.js +1036 -0
- package/dist/connection-Cn9eRQrg.d.ts +562 -0
- package/dist/index.d.ts +1333 -6
- package/dist/index.js +1750 -15
- package/dist/mock.d.ts +444 -5
- package/dist/mock.js +1073 -4
- package/package.json +3 -3
- package/dist/chunk-4EVX2UKI.js +0 -109
- package/dist/connection-B5NUruTy.d.ts +0 -74
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superdurable/connector-braintree",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Braintree 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/transaction-read/worker.ts",
|
|
42
42
|
"example:start": "tsx examples/transaction-read/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.12.0",
|
|
47
47
|
"@superdurable/dex": ">=1.28.0",
|
|
48
48
|
"zod": "^4.1.0"
|
|
49
49
|
},
|
package/dist/chunk-4EVX2UKI.js
DELETED
|
@@ -1,109 +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
|
-
"apiVersion": z.string().optional(),
|
|
7
|
-
"timeoutMs": z.number().int().optional(),
|
|
8
|
-
"maxResponseBytes": z.number().int().optional()
|
|
9
|
-
});
|
|
10
|
-
function decodeCredentials(value) {
|
|
11
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) throw new TypeError("credential fields are invalid");
|
|
12
|
-
const fields = value;
|
|
13
|
-
const allowed = /* @__PURE__ */ new Set(["privateKey", "publicKey"]);
|
|
14
|
-
if (Object.keys(fields).some((key) => !allowed.has(key))) throw new TypeError("stored credential does not match the connector credential fields");
|
|
15
|
-
if (fields["privateKey"] != null && !(typeof fields["privateKey"] === "string")) throw new TypeError("credential privateKey has an invalid type");
|
|
16
|
-
if (fields["publicKey"] != null && !(typeof fields["publicKey"] === "string")) throw new TypeError("credential publicKey has an invalid type");
|
|
17
|
-
const credentials = {};
|
|
18
|
-
if (!fields["publicKey"]) throw new TypeError("credential publicKey is required");
|
|
19
|
-
credentials.publicKey = fields["publicKey"] ?? "";
|
|
20
|
-
if (!fields["privateKey"]) throw new TypeError("credential privateKey is required");
|
|
21
|
-
credentials.privateKey = new SecretString(fields["privateKey"] ?? "");
|
|
22
|
-
return credentials;
|
|
23
|
-
}
|
|
24
|
-
var GetTransactionInputSchema = z.strictObject({
|
|
25
|
-
"transactionId": z.string()
|
|
26
|
-
});
|
|
27
|
-
var TransactionProfileSchema = z.strictObject({
|
|
28
|
-
"id": z.string(),
|
|
29
|
-
"status": z.string()
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
// src/generated/definitions.ts
|
|
33
|
-
var ConnectorID = "braintree";
|
|
34
|
-
var ProviderID = "braintree";
|
|
35
|
-
var GetTransactionBranch = {
|
|
36
|
-
Found: "found",
|
|
37
|
-
NotFound: "notFound",
|
|
38
|
-
ProviderRejected: "providerRejected",
|
|
39
|
-
InvalidResponse: "invalidResponse",
|
|
40
|
-
Defect: "defect"
|
|
41
|
-
};
|
|
42
|
-
var GetTransactionBranchFound = GetTransactionBranch.Found;
|
|
43
|
-
var GetTransactionBranchNotFound = GetTransactionBranch.NotFound;
|
|
44
|
-
var GetTransactionBranchProviderRejected = GetTransactionBranch.ProviderRejected;
|
|
45
|
-
var GetTransactionBranchInvalidResponse = GetTransactionBranch.InvalidResponse;
|
|
46
|
-
var GetTransactionBranchDefect = GetTransactionBranch.Defect;
|
|
47
|
-
var GetTransactionDefinition = {
|
|
48
|
-
operation: { connectorId: ConnectorID, operationId: "getTransaction" },
|
|
49
|
-
branches: [
|
|
50
|
-
{ id: "found", description: "Braintree returned the transaction." },
|
|
51
|
-
{ id: "notFound", description: "The node is absent or is another object type.", optional: true },
|
|
52
|
-
{ id: "providerRejected", description: "Braintree returned a definite GraphQL or HTTP rejection.", optional: true },
|
|
53
|
-
{ id: "invalidResponse", description: "Braintree returned malformed or oversized JSON.", optional: true },
|
|
54
|
-
{ id: "defect", description: "Local input or credentials are invalid.", optional: true }
|
|
55
|
-
],
|
|
56
|
-
stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "async" }
|
|
57
|
-
};
|
|
58
|
-
var GetTransactionMetadata = { kind: "query", idempotency: "none", authorization: "required" };
|
|
59
|
-
|
|
60
|
-
// src/generated/connection.ts
|
|
61
|
-
import { ConnectionRefSchema } from "@superdurable/connectors-sdk";
|
|
62
|
-
var Connection = class {
|
|
63
|
-
/** Stable provider and connection name. */
|
|
64
|
-
reference;
|
|
65
|
-
/** Bound provider operations. */
|
|
66
|
-
operations;
|
|
67
|
-
/** Validate a reference and bind operations. */
|
|
68
|
-
constructor(reference, operations) {
|
|
69
|
-
this.reference = ConnectionRefSchema.parse(reference);
|
|
70
|
-
if (this.reference.provider !== ProviderID) throw new TypeError("connection provider differs from the manifest");
|
|
71
|
-
if (!operations) throw new TypeError("connector operations are required");
|
|
72
|
-
this.operations = operations;
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
function newConnection(client, reference) {
|
|
76
|
-
if (!client) throw new TypeError("connector client is required");
|
|
77
|
-
return new Connection(reference, client);
|
|
78
|
-
}
|
|
79
|
-
function newConnectionWithOperations(operations, reference) {
|
|
80
|
-
return new Connection(reference, operations);
|
|
81
|
-
}
|
|
82
|
-
function newProjectConnection(project, connectionName, createClient) {
|
|
83
|
-
if (!project) throw new TypeError("loaded project is required");
|
|
84
|
-
const reference = ConnectionRefSchema.parse({ provider: ProviderID, name: connectionName });
|
|
85
|
-
const selected = project.configuration.connections.find((entry) => entry.connectorId === ConnectorID && entry.connectionName === connectionName);
|
|
86
|
-
if (!selected || selected.provider !== ProviderID) throw new TypeError("project connection is not configured");
|
|
87
|
-
return newConnection(createClient(project, connectionName), reference);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export {
|
|
91
|
-
ConfigSchema,
|
|
92
|
-
decodeCredentials,
|
|
93
|
-
GetTransactionInputSchema,
|
|
94
|
-
TransactionProfileSchema,
|
|
95
|
-
ConnectorID,
|
|
96
|
-
ProviderID,
|
|
97
|
-
GetTransactionBranch,
|
|
98
|
-
GetTransactionBranchFound,
|
|
99
|
-
GetTransactionBranchNotFound,
|
|
100
|
-
GetTransactionBranchProviderRejected,
|
|
101
|
-
GetTransactionBranchInvalidResponse,
|
|
102
|
-
GetTransactionBranchDefect,
|
|
103
|
-
GetTransactionDefinition,
|
|
104
|
-
GetTransactionMetadata,
|
|
105
|
-
Connection,
|
|
106
|
-
newConnection,
|
|
107
|
-
newConnectionWithOperations,
|
|
108
|
-
newProjectConnection
|
|
109
|
-
};
|
|
@@ -1,74 +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
|
-
/** Braintree GraphQL API root. Blank uses the displayed sandbox root; use the documented production root for live payments. Do not append /graphql or credentials. */
|
|
7
|
-
baseUrl?: string;
|
|
8
|
-
/** Braintree GraphQL schema date in YYYY-MM-DD format. Blank uses the displayed date; override only to match an existing integration's schema version. */
|
|
9
|
-
apiVersion?: string;
|
|
10
|
-
/** Maximum duration of one transaction query as a positive Go duration. Blank uses the displayed default; increase only for slow responses. Runtime value in milliseconds. */
|
|
11
|
-
timeoutMs?: number;
|
|
12
|
-
/** Maximum complete GraphQL JSON response in bytes as a positive integer. Blank uses the displayed default; increase only for large responses. */
|
|
13
|
-
maxResponseBytes?: number;
|
|
14
|
-
}
|
|
15
|
-
/** Runtime schema for manifest configuration. */
|
|
16
|
-
declare const ConfigSchema: z.ZodObject<{
|
|
17
|
-
baseUrl: z.ZodOptional<z.ZodString>;
|
|
18
|
-
apiVersion: z.ZodOptional<z.ZodString>;
|
|
19
|
-
timeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
20
|
-
maxResponseBytes: z.ZodOptional<z.ZodNumber>;
|
|
21
|
-
}, z.core.$strip>;
|
|
22
|
-
/** Private connector credentials resolved by the host. */
|
|
23
|
-
interface Credentials {
|
|
24
|
-
/** Secret API key from the same Braintree Control Panel > gear icon > API > API Keys > View in the Private Key column. Copy the complete value; blank prevents calls. Dex combines it with publicKey into a Basic header and never exposes it in Flow data. */
|
|
25
|
-
privateKey: SecretString;
|
|
26
|
-
/** Public API key from the matching Braintree sandbox or production Control Panel > gear icon > API > API Keys. Copy the complete value with no colon; blank prevents calls. This identifier is not secret but must match privateKey. */
|
|
27
|
-
publicKey: string;
|
|
28
|
-
}
|
|
29
|
-
/** Decode private credential fields for the connector. */
|
|
30
|
-
declare function decodeCredentials(value: unknown): Credentials;
|
|
31
|
-
/** Host-owned source of private connector credentials. */
|
|
32
|
-
type CredentialSource = CredentialProvider<Credentials>;
|
|
33
|
-
/** GetTransactionInput selects one Braintree GraphQL node by ID. */
|
|
34
|
-
interface GetTransactionInput {
|
|
35
|
-
/** TransactionID is the GraphQL transaction ID, not a legacy SDK ID. */
|
|
36
|
-
"transactionId": string;
|
|
37
|
-
}
|
|
38
|
-
/** TransactionProfile contains a transaction's ID and current payment status. */
|
|
39
|
-
interface TransactionProfile {
|
|
40
|
-
/** ID is the Braintree GraphQL transaction ID. */
|
|
41
|
-
"id": string;
|
|
42
|
-
/** Status is the Braintree PaymentStatus enum value. */
|
|
43
|
-
"status": string;
|
|
44
|
-
}
|
|
45
|
-
/** Runtime validator for GetTransactionInput. */
|
|
46
|
-
declare const GetTransactionInputSchema: z.ZodObject<{
|
|
47
|
-
transactionId: z.ZodString;
|
|
48
|
-
}, z.core.$strict>;
|
|
49
|
-
/** Runtime validator for TransactionProfile. */
|
|
50
|
-
declare const TransactionProfileSchema: z.ZodObject<{
|
|
51
|
-
id: z.ZodString;
|
|
52
|
-
status: z.ZodString;
|
|
53
|
-
}, z.core.$strict>;
|
|
54
|
-
|
|
55
|
-
/** Typed operations supplied by a client or mock. */
|
|
56
|
-
interface Operations {
|
|
57
|
-
/** Invoke getTransaction through this connection. */
|
|
58
|
-
getTransaction(): Query<GetTransactionInput, TransactionProfile>;
|
|
59
|
-
}
|
|
60
|
-
/** Named connector connection kept outside Flow state. */
|
|
61
|
-
declare class Connection<BoundOperations = Operations> {
|
|
62
|
-
/** Stable provider and connection name. */
|
|
63
|
-
readonly reference: ConnectionRef;
|
|
64
|
-
/** Bound provider operations. */
|
|
65
|
-
readonly operations: BoundOperations;
|
|
66
|
-
/** Validate a reference and bind operations. */
|
|
67
|
-
constructor(reference: ConnectionRef, operations: BoundOperations);
|
|
68
|
-
}
|
|
69
|
-
/** Bind a client to a named connection. */
|
|
70
|
-
declare function newConnection(client: Operations, reference: ConnectionRef): Connection;
|
|
71
|
-
/** Bind scripted operations to a named connection. */
|
|
72
|
-
declare function newConnectionWithOperations(operations: Operations, reference: ConnectionRef): Connection;
|
|
73
|
-
|
|
74
|
-
export { Connection as C, type GetTransactionInput as G, type Operations as O, type TransactionProfile as T, type Config as a, type Credentials as b, ConfigSchema as c, type CredentialSource as d, GetTransactionInputSchema as e, TransactionProfileSchema as f, decodeCredentials as g, newConnectionWithOperations as h, newConnection as n };
|