@superdurable/connector-braintree 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +2 -2
- package/dex-connector.json +65 -0
- package/dist/chunk-4EVX2UKI.js +109 -0
- package/dist/connection-B5NUruTy.d.ts +74 -0
- package/dist/index.d.ts +98 -0
- package/dist/index.js +255 -0
- package/dist/mock.d.ts +35 -0
- package/dist/mock.js +73 -0
- package/package.json +59 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Super Durable
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Braintree TypeScript connector
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Implements `getTransaction`, returning one GraphQL transaction ID and status. Go-recorded conformance checks exact requests, branches, retries, and outputs. Configure `publicKey` and secret `privateKey` using the [connection guide](../README.md). See the [runnable Dex Flow](examples/transaction-read/README.md). Live provider authorization remains unverified.
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"connectorId": "braintree",
|
|
3
|
+
"releaseTag": "connectors/braintree/go/v0.1.0",
|
|
4
|
+
"package": {
|
|
5
|
+
"ecosystem": "npm",
|
|
6
|
+
"name": "@superdurable/connector-braintree",
|
|
7
|
+
"version": "0.1.0"
|
|
8
|
+
},
|
|
9
|
+
"factories": [
|
|
10
|
+
{
|
|
11
|
+
"name": "newGetTransactionStep",
|
|
12
|
+
"kind": "query",
|
|
13
|
+
"operationId": "getTransaction",
|
|
14
|
+
"inputType": "GetTransactionInput",
|
|
15
|
+
"description": "Return one Braintree transaction's GraphQL ID and status.",
|
|
16
|
+
"fields": {
|
|
17
|
+
"stepType": "stepType",
|
|
18
|
+
"annotations": "annotations",
|
|
19
|
+
"connectionName": "connectionName",
|
|
20
|
+
"resultAttribute": "resultAttribute"
|
|
21
|
+
},
|
|
22
|
+
"branches": [
|
|
23
|
+
{
|
|
24
|
+
"id": "found",
|
|
25
|
+
"field": "found",
|
|
26
|
+
"optional": false
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"id": "notFound",
|
|
30
|
+
"field": "notFound",
|
|
31
|
+
"optional": true
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"id": "providerRejected",
|
|
35
|
+
"field": "providerRejected",
|
|
36
|
+
"optional": true
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"id": "invalidResponse",
|
|
40
|
+
"field": "invalidResponse",
|
|
41
|
+
"optional": true
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"id": "defect",
|
|
45
|
+
"field": "defect",
|
|
46
|
+
"optional": true
|
|
47
|
+
}
|
|
48
|
+
],
|
|
49
|
+
"inputSchema": {
|
|
50
|
+
"additionalProperties": false,
|
|
51
|
+
"description": "GetTransactionInput selects one Braintree GraphQL node by ID.",
|
|
52
|
+
"properties": {
|
|
53
|
+
"transactionId": {
|
|
54
|
+
"description": "TransactionID is the GraphQL transaction ID, not a legacy SDK ID.",
|
|
55
|
+
"type": "string"
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
"required": [
|
|
59
|
+
"transactionId"
|
|
60
|
+
],
|
|
61
|
+
"type": "object"
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
]
|
|
65
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
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 };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { G as GetTransactionInput, T as TransactionProfile, C as Connection, O as Operations, a as Config, b as Credentials } from './connection-B5NUruTy.js';
|
|
2
|
+
export { c as ConfigSchema, d as CredentialSource, e as GetTransactionInputSchema, f as TransactionProfileSchema, g as decodeCredentials, n as newConnection, h as newConnectionWithOperations } from './connection-B5NUruTy.js';
|
|
3
|
+
import { QueryDefinition, QueryStepConfig, Query, QueryResult, QueryStep, CredentialProvider, Call, QueryAttempt } 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 = "braintree";
|
|
11
|
+
/** Provider identity for named connections. */
|
|
12
|
+
declare const ProviderID = "braintree";
|
|
13
|
+
/** Branch IDs for getTransaction. */
|
|
14
|
+
declare const GetTransactionBranch: {
|
|
15
|
+
readonly Found: "found";
|
|
16
|
+
readonly NotFound: "notFound";
|
|
17
|
+
readonly ProviderRejected: "providerRejected";
|
|
18
|
+
readonly InvalidResponse: "invalidResponse";
|
|
19
|
+
readonly Defect: "defect";
|
|
20
|
+
};
|
|
21
|
+
/** Braintree returned the transaction. */
|
|
22
|
+
declare const GetTransactionBranchFound: "found";
|
|
23
|
+
/** The node is absent or is another object type. */
|
|
24
|
+
declare const GetTransactionBranchNotFound: "notFound";
|
|
25
|
+
/** Braintree returned a definite GraphQL or HTTP rejection. */
|
|
26
|
+
declare const GetTransactionBranchProviderRejected: "providerRejected";
|
|
27
|
+
/** Braintree returned malformed or oversized JSON. */
|
|
28
|
+
declare const GetTransactionBranchInvalidResponse: "invalidResponse";
|
|
29
|
+
/** Local input or credentials are invalid. */
|
|
30
|
+
declare const GetTransactionBranchDefect: "defect";
|
|
31
|
+
/** Manifest definition for getTransaction. */
|
|
32
|
+
declare const GetTransactionDefinition: QueryDefinition;
|
|
33
|
+
/** Manifest metadata for getTransaction. */
|
|
34
|
+
declare const GetTransactionMetadata: {
|
|
35
|
+
readonly kind: "query";
|
|
36
|
+
readonly idempotency: "none";
|
|
37
|
+
readonly authorization: "required";
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/** Configuration for the getTransaction connector Step. */
|
|
41
|
+
interface GetTransactionStepConfig<StepInput, OperationInput = GetTransactionInput, OperationOutput = TransactionProfile> extends Omit<QueryStepConfig<StepInput, OperationInput, OperationOutput>, 'operation' | 'connection' | 'branches'> {
|
|
42
|
+
/** Named connection supplying this operation. */
|
|
43
|
+
connection: Connection<{
|
|
44
|
+
getTransaction(): Query<OperationInput, OperationOutput>;
|
|
45
|
+
}>;
|
|
46
|
+
/** Name matching the bound connection. */
|
|
47
|
+
connectionName: string;
|
|
48
|
+
/** Braintree returned the transaction. */
|
|
49
|
+
found: StepTarget<QueryResult<OperationOutput>>;
|
|
50
|
+
/** The node is absent or is another object type. */
|
|
51
|
+
notFound?: StepTarget<QueryResult<OperationOutput>>;
|
|
52
|
+
/** Braintree returned a definite GraphQL or HTTP rejection. */
|
|
53
|
+
providerRejected?: StepTarget<QueryResult<OperationOutput>>;
|
|
54
|
+
/** Braintree returned malformed or oversized JSON. */
|
|
55
|
+
invalidResponse?: StepTarget<QueryResult<OperationOutput>>;
|
|
56
|
+
/** Local input or credentials are invalid. */
|
|
57
|
+
defect?: StepTarget<QueryResult<OperationOutput>>;
|
|
58
|
+
}
|
|
59
|
+
/** Build the getTransaction Step from a named connection. */
|
|
60
|
+
declare function newGetTransactionStep<StepInput, OperationInput = GetTransactionInput, OperationOutput = TransactionProfile>(configuration: GetTransactionStepConfig<StepInput, OperationInput, OperationOutput>): QueryStep<StepInput, OperationInput, OperationOutput>;
|
|
61
|
+
|
|
62
|
+
/** Open one named Braintree connection from Dex project configuration. */
|
|
63
|
+
declare function newProjectConnection(project: LoadedProject, connectionName: string): Connection<Operations>;
|
|
64
|
+
|
|
65
|
+
/** Injectable provider sender for tests and local applications. */
|
|
66
|
+
interface BraintreeClientOptions {
|
|
67
|
+
/** Provider sender; omitted uses the SDK transport. */ send?: (request: ProviderRequest) => Promise<ProviderResponse>;
|
|
68
|
+
}
|
|
69
|
+
interface Exchange {
|
|
70
|
+
status: number;
|
|
71
|
+
body: Uint8Array;
|
|
72
|
+
retryAfterMs: number;
|
|
73
|
+
error?: 'credential' | 'request' | 'tooLarge';
|
|
74
|
+
}
|
|
75
|
+
/** Authenticated Braintree GraphQL client for transaction lookups. */
|
|
76
|
+
declare class BraintreeClient {
|
|
77
|
+
private readonly credentials;
|
|
78
|
+
private readonly baseURL;
|
|
79
|
+
private readonly timeoutMs;
|
|
80
|
+
private readonly apiVersion;
|
|
81
|
+
private readonly maxResponseBytes;
|
|
82
|
+
private readonly send;
|
|
83
|
+
/** Validate provider configuration without contacting Braintree. */
|
|
84
|
+
constructor(config: Config, credentials: CredentialProvider<Credentials>, options?: BraintreeClientOptions);
|
|
85
|
+
/** Bind the getTransaction Query. */ getTransaction(): GetTransactionOperation;
|
|
86
|
+
/** Resolve credentials and send one bounded transaction lookup. */
|
|
87
|
+
get(call: Call, input: GetTransactionInput): Promise<Exchange>;
|
|
88
|
+
}
|
|
89
|
+
/** Read one transaction by its Braintree GraphQL ID. */
|
|
90
|
+
declare class GetTransactionOperation implements Query<GetTransactionInput, TransactionProfile> {
|
|
91
|
+
private readonly client;
|
|
92
|
+
/** Bind the provider client. */ constructor(client: BraintreeClient);
|
|
93
|
+
/** Return the generated Query definition. */ definition(): QueryDefinition;
|
|
94
|
+
/** Classify provider outcomes consistently with Go. */
|
|
95
|
+
invoke(call: Call, input: GetTransactionInput): Promise<QueryAttempt<TransactionProfile>>;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export { BraintreeClient, type BraintreeClientOptions, Config, Connection, ConnectorID, Credentials, GetTransactionBranch, GetTransactionBranchDefect, GetTransactionBranchFound, GetTransactionBranchInvalidResponse, GetTransactionBranchNotFound, GetTransactionBranchProviderRejected, GetTransactionDefinition, GetTransactionInput, GetTransactionMetadata, GetTransactionOperation, type GetTransactionStepConfig, ProviderID, TransactionProfile, newGetTransactionStep, newProjectConnection };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ConfigSchema,
|
|
3
|
+
Connection,
|
|
4
|
+
ConnectorID,
|
|
5
|
+
GetTransactionBranch,
|
|
6
|
+
GetTransactionBranchDefect,
|
|
7
|
+
GetTransactionBranchFound,
|
|
8
|
+
GetTransactionBranchInvalidResponse,
|
|
9
|
+
GetTransactionBranchNotFound,
|
|
10
|
+
GetTransactionBranchProviderRejected,
|
|
11
|
+
GetTransactionDefinition,
|
|
12
|
+
GetTransactionInputSchema,
|
|
13
|
+
GetTransactionMetadata,
|
|
14
|
+
ProviderID,
|
|
15
|
+
TransactionProfileSchema,
|
|
16
|
+
decodeCredentials,
|
|
17
|
+
newConnection,
|
|
18
|
+
newConnectionWithOperations,
|
|
19
|
+
newProjectConnection
|
|
20
|
+
} from "./chunk-4EVX2UKI.js";
|
|
21
|
+
|
|
22
|
+
// src/generated/steps.ts
|
|
23
|
+
import { goToBranch, newQueryStep } from "@superdurable/connectors-sdk";
|
|
24
|
+
function newGetTransactionStep(configuration) {
|
|
25
|
+
const { connection, connectionName, found, notFound, providerRejected, invalidResponse, defect, ...stepConfiguration } = configuration;
|
|
26
|
+
if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
|
|
27
|
+
return newQueryStep({ ...stepConfiguration, operation: connection.operations.getTransaction(), connection: connection.reference, branches: [
|
|
28
|
+
goToBranch("found", found),
|
|
29
|
+
...notFound ? [goToBranch("notFound", notFound)] : [],
|
|
30
|
+
...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
|
|
31
|
+
...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
|
|
32
|
+
...defect ? [goToBranch("defect", defect)] : []
|
|
33
|
+
] });
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// src/project.ts
|
|
37
|
+
import { SecretString as SecretString2 } from "@superdurable/connectors-sdk";
|
|
38
|
+
import { z } from "zod";
|
|
39
|
+
|
|
40
|
+
// src/client.ts
|
|
41
|
+
import { Buffer } from "buffer";
|
|
42
|
+
import { SecretString, newQueryBranch, newQueryRetry } from "@superdurable/connectors-sdk";
|
|
43
|
+
import { BodyTooLargeError, isHeaderSafeCredential, parseRetryAfter, sendProviderRequest, validateBaseURL } from "@superdurable/connectors-sdk/providerhttp";
|
|
44
|
+
var emptyTransaction = () => ({ id: "", status: "" });
|
|
45
|
+
var getTransactionGraphQL = "query GetTransaction($id: ID!) { node(id: $id) { __typename ... on Transaction { id status } } }";
|
|
46
|
+
var BraintreeClient = class {
|
|
47
|
+
/** Validate provider configuration without contacting Braintree. */
|
|
48
|
+
constructor(config, credentials, options = {}) {
|
|
49
|
+
this.credentials = credentials;
|
|
50
|
+
if (!config || !credentials) throw new TypeError("Braintree configuration and credentials are required");
|
|
51
|
+
this.baseURL = validateBaseURL(config.baseUrl ?? "https://payments.sandbox.braintree-api.com").replace(/\/$/, "");
|
|
52
|
+
this.apiVersion = config.apiVersion ?? "2019-01-01";
|
|
53
|
+
if (!/^\d{4}-\d{2}-\d{2}$/.test(this.apiVersion) || !Number.isFinite(Date.parse(this.apiVersion)) || new Date(this.apiVersion).toISOString().slice(0, 10) !== this.apiVersion) throw new TypeError("Braintree API version must be YYYY-MM-DD");
|
|
54
|
+
this.timeoutMs = config.timeoutMs ?? 15e3;
|
|
55
|
+
this.maxResponseBytes = config.maxResponseBytes ?? 1048576;
|
|
56
|
+
if (!Number.isSafeInteger(this.timeoutMs) || this.timeoutMs <= 0 || !Number.isSafeInteger(this.maxResponseBytes) || this.maxResponseBytes <= 0)
|
|
57
|
+
throw new TypeError("Braintree request limits must be positive integers");
|
|
58
|
+
this.send = options.send ?? sendProviderRequest;
|
|
59
|
+
}
|
|
60
|
+
credentials;
|
|
61
|
+
baseURL;
|
|
62
|
+
timeoutMs;
|
|
63
|
+
apiVersion;
|
|
64
|
+
maxResponseBytes;
|
|
65
|
+
send;
|
|
66
|
+
/** Bind the getTransaction Query. */
|
|
67
|
+
getTransaction() {
|
|
68
|
+
return new GetTransactionOperation(this);
|
|
69
|
+
}
|
|
70
|
+
/** Resolve credentials and send one bounded transaction lookup. */
|
|
71
|
+
async get(call, input) {
|
|
72
|
+
let publicKey;
|
|
73
|
+
let privateKey;
|
|
74
|
+
try {
|
|
75
|
+
const credentials = await this.credentials.resolve(call, call.context.cancellationSignal);
|
|
76
|
+
publicKey = credentials.publicKey;
|
|
77
|
+
privateKey = credentials.privateKey instanceof SecretString ? credentials.privateKey.reveal() : "";
|
|
78
|
+
} catch {
|
|
79
|
+
return emptyExchange("credential");
|
|
80
|
+
}
|
|
81
|
+
if (!isHeaderSafeCredential(publicKey) || publicKey.includes(":") || !isHeaderSafeCredential(privateKey)) return emptyExchange("credential");
|
|
82
|
+
const authorization = `Basic ${Buffer.from(`${publicKey}:${privateKey}`, "utf8").toString("base64")}`;
|
|
83
|
+
const url = new URL(`${this.baseURL}/graphql`);
|
|
84
|
+
const request = {
|
|
85
|
+
url: url.toString(),
|
|
86
|
+
method: "POST",
|
|
87
|
+
headers: { Accept: "application/json", "Content-Type": "application/json", "Braintree-Version": this.apiVersion, Authorization: authorization },
|
|
88
|
+
body: new TextEncoder().encode(JSON.stringify({ query: getTransactionGraphQL, variables: { id: input.transactionId } })),
|
|
89
|
+
maxResponseBytes: this.maxResponseBytes,
|
|
90
|
+
timeoutMs: this.timeoutMs,
|
|
91
|
+
addressPolicy: this.baseURL.startsWith("https://") ? "publicHTTPS" : "privateNetworkHTTP",
|
|
92
|
+
signal: call.context.cancellationSignal
|
|
93
|
+
};
|
|
94
|
+
let response;
|
|
95
|
+
let isTooLarge = false;
|
|
96
|
+
try {
|
|
97
|
+
response = await this.send(request);
|
|
98
|
+
} catch (error) {
|
|
99
|
+
if (error instanceof BodyTooLargeError && error.status !== void 0) {
|
|
100
|
+
response = { status: error.status, headers: error.headers ?? {}, body: new Uint8Array() };
|
|
101
|
+
isTooLarge = true;
|
|
102
|
+
} else return emptyExchange("request");
|
|
103
|
+
}
|
|
104
|
+
const retryAfterMs = parseRetryAfter(header(response.headers, "retry-after"));
|
|
105
|
+
if (isTooLarge || response.body.length > this.maxResponseBytes)
|
|
106
|
+
return { status: response.status, body: new Uint8Array(), retryAfterMs, error: "tooLarge" };
|
|
107
|
+
return { status: response.status, body: response.body, retryAfterMs };
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
var GetTransactionOperation = class {
|
|
111
|
+
/** Bind the provider client. */
|
|
112
|
+
constructor(client) {
|
|
113
|
+
this.client = client;
|
|
114
|
+
}
|
|
115
|
+
client;
|
|
116
|
+
/** Return the generated Query definition. */
|
|
117
|
+
definition() {
|
|
118
|
+
return GetTransactionDefinition;
|
|
119
|
+
}
|
|
120
|
+
/** Classify provider outcomes consistently with Go. */
|
|
121
|
+
async invoke(call, input) {
|
|
122
|
+
if (!isValidGraphQLID(input?.transactionId))
|
|
123
|
+
return terminal("defect", "VALIDATION", "transactionId must contain 1\u2013128 printable characters");
|
|
124
|
+
const exchange = await this.client.get(call, input);
|
|
125
|
+
if (exchange.error === "credential") return terminal("defect", "AUTHENTICATION", "Braintree credentials are unavailable or invalid");
|
|
126
|
+
if (exchange.error === "request") return retry("TRANSPORT", "Braintree request failed");
|
|
127
|
+
if (exchange.status === 429) return retry("RATE_LIMIT", "Braintree rate limited the request", exchange.retryAfterMs);
|
|
128
|
+
if (exchange.status === 408 || exchange.status >= 500) return retry("AVAILABILITY", "Braintree is temporarily unavailable", exchange.retryAfterMs);
|
|
129
|
+
if (exchange.status !== 200) return terminal("providerRejected", "PROVIDER_REJECTION", `Braintree rejected HTTP ${exchange.status}`);
|
|
130
|
+
if (exchange.error === "tooLarge") return terminal("invalidResponse", "RESPONSE_TOO_LARGE", "Braintree response exceeded the configured limit");
|
|
131
|
+
const transaction = decodeTransaction(exchange.body, input.transactionId);
|
|
132
|
+
if (transaction === "rejected") return terminal("providerRejected", "PROVIDER_REJECTION", "Braintree rejected the GraphQL query");
|
|
133
|
+
if (transaction === "unavailable") return retry("AVAILABILITY", "Braintree reported a temporary GraphQL failure", exchange.retryAfterMs);
|
|
134
|
+
if (transaction === "rateLimited") return retry("RATE_LIMIT", "Braintree reported a resource limit", exchange.retryAfterMs);
|
|
135
|
+
if (transaction === "graphQLNotFound") return terminal("notFound", "NOT_FOUND", "Braintree did not find the transaction");
|
|
136
|
+
if (transaction === void 0) return terminal("invalidResponse", "PROTOCOL", "Braintree returned invalid transaction JSON");
|
|
137
|
+
if (transaction === null) return terminal("notFound", "NOT_FOUND", "Braintree did not expose the transaction");
|
|
138
|
+
return newQueryBranch("found", transaction);
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
function isValidGraphQLID(value) {
|
|
142
|
+
return typeof value === "string" && value.length > 0 && value.trim() === value && new TextEncoder().encode(value).length <= 128 && ![...value].some((character) => character.codePointAt(0) < 32 || character.codePointAt(0) === 127) && !/(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF])/.test(value);
|
|
143
|
+
}
|
|
144
|
+
function emptyExchange(error) {
|
|
145
|
+
return { status: 0, body: new Uint8Array(), retryAfterMs: 0, error };
|
|
146
|
+
}
|
|
147
|
+
function failure(kind, message) {
|
|
148
|
+
return { provider: "braintree", operation: "getTransaction", kind, message };
|
|
149
|
+
}
|
|
150
|
+
function terminal(branch, kind, message) {
|
|
151
|
+
return newQueryBranch(branch, emptyTransaction(), {}, failure(kind, message));
|
|
152
|
+
}
|
|
153
|
+
function retry(kind, message, delay = 0) {
|
|
154
|
+
return newQueryRetry(failure(kind, message), delay);
|
|
155
|
+
}
|
|
156
|
+
function header(headers, name) {
|
|
157
|
+
const entry = Object.entries(headers).find(([key]) => key.toLowerCase() === name.toLowerCase())?.[1];
|
|
158
|
+
return Array.isArray(entry) ? entry[0] ?? "" : entry ?? "";
|
|
159
|
+
}
|
|
160
|
+
function isObject(value) {
|
|
161
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
162
|
+
}
|
|
163
|
+
function classifyGraphQLErrors(errors) {
|
|
164
|
+
const precedence = ["graphQLNotFound", "rateLimited", "unavailable"];
|
|
165
|
+
let outcome = 0;
|
|
166
|
+
for (const error of errors) {
|
|
167
|
+
const extensions = isObject(error) ? error.extensions : void 0;
|
|
168
|
+
if (extensions !== void 0 && extensions !== null && !isObject(extensions)) return "rejected";
|
|
169
|
+
const errorClass = isObject(extensions) ? extensions.errorClass : void 0;
|
|
170
|
+
if (errorClass === "NOT_FOUND") continue;
|
|
171
|
+
if (errorClass === "RESOURCE_LIMIT") outcome = Math.max(outcome, 1);
|
|
172
|
+
else if (errorClass === "INTERNAL" || errorClass === "SERVICE_AVAILABILITY") outcome = Math.max(outcome, 2);
|
|
173
|
+
else return "rejected";
|
|
174
|
+
}
|
|
175
|
+
return precedence[outcome];
|
|
176
|
+
}
|
|
177
|
+
function decodeTransaction(body, transactionID) {
|
|
178
|
+
let raw;
|
|
179
|
+
try {
|
|
180
|
+
raw = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(body));
|
|
181
|
+
} catch {
|
|
182
|
+
return void 0;
|
|
183
|
+
}
|
|
184
|
+
if (!isObject(raw)) return void 0;
|
|
185
|
+
if (raw.errors !== void 0 && raw.errors !== null && !Array.isArray(raw.errors)) return void 0;
|
|
186
|
+
if (Array.isArray(raw.errors) && raw.errors.length > 0) return classifyGraphQLErrors(raw.errors);
|
|
187
|
+
if (!isObject(raw.data)) return void 0;
|
|
188
|
+
const node = raw.data.node;
|
|
189
|
+
if (node === null) return null;
|
|
190
|
+
if (!isObject(node)) return void 0;
|
|
191
|
+
if (typeof node.__typename !== "string" || !node.__typename) return void 0;
|
|
192
|
+
if (node.__typename !== "Transaction") return null;
|
|
193
|
+
if (node.id !== transactionID || typeof node.status !== "string" || !node.status) return void 0;
|
|
194
|
+
return { id: node.id, status: node.status };
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// src/project.ts
|
|
198
|
+
function newProjectConnection2(project, connectionName) {
|
|
199
|
+
return newProjectConnection(project, connectionName, (loadedProject, name) => {
|
|
200
|
+
const selected = loadedProject.configuration.connections.find((entry) => entry.connectorId === "braintree" && entry.connectionName === name);
|
|
201
|
+
if (!selected) throw new TypeError("Braintree project connection is not configured");
|
|
202
|
+
const fields = z.strictObject({ baseUrl: z.string().optional(), apiVersion: z.string().optional(), timeout: z.union([z.string(), z.number().int()]).optional(), maxResponseBytes: z.number().int().optional() }).parse(selected.configuration);
|
|
203
|
+
const timeoutMs = typeof fields.timeout === "number" ? Math.ceil(fields.timeout / 1e6) : fields.timeout ? parseDurationMilliseconds(fields.timeout) : void 0;
|
|
204
|
+
const config = {
|
|
205
|
+
...fields.baseUrl ? { baseUrl: fields.baseUrl } : {},
|
|
206
|
+
...fields.apiVersion ? { apiVersion: fields.apiVersion } : {},
|
|
207
|
+
...timeoutMs !== void 0 ? { timeoutMs } : {},
|
|
208
|
+
...fields.maxResponseBytes !== void 0 ? { maxResponseBytes: fields.maxResponseBytes } : {}
|
|
209
|
+
};
|
|
210
|
+
const credentials = {
|
|
211
|
+
async resolve(_call, signal) {
|
|
212
|
+
const privateFields = await loadedProject.resolveCredential("braintree", name, signal);
|
|
213
|
+
if (typeof privateFields.publicKey !== "string" || typeof privateFields.privateKey !== "string") throw new TypeError("Braintree credentials are unavailable");
|
|
214
|
+
return { publicKey: privateFields.publicKey, privateKey: new SecretString2(privateFields.privateKey) };
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
return new BraintreeClient(config, credentials);
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
function parseDurationMilliseconds(value) {
|
|
221
|
+
let remaining = value;
|
|
222
|
+
let milliseconds = 0;
|
|
223
|
+
const units = { ns: 1e-6, us: 1e-3, "\xB5s": 1e-3, ms: 1, s: 1e3, m: 6e4, h: 36e5 };
|
|
224
|
+
while (remaining) {
|
|
225
|
+
const part = /^(\d+(?:\.\d+)?)(ns|us|µs|ms|s|m|h)/.exec(remaining);
|
|
226
|
+
if (!part) throw new TypeError("Braintree timeout must be a positive Go duration");
|
|
227
|
+
milliseconds += Number(part[1]) * (units[part[2] ?? ""] ?? NaN);
|
|
228
|
+
remaining = remaining.slice(part[0].length);
|
|
229
|
+
}
|
|
230
|
+
if (!Number.isSafeInteger(milliseconds) || milliseconds <= 0) throw new TypeError("Braintree timeout must resolve to positive whole milliseconds");
|
|
231
|
+
return milliseconds;
|
|
232
|
+
}
|
|
233
|
+
export {
|
|
234
|
+
BraintreeClient,
|
|
235
|
+
ConfigSchema,
|
|
236
|
+
Connection,
|
|
237
|
+
ConnectorID,
|
|
238
|
+
GetTransactionBranch,
|
|
239
|
+
GetTransactionBranchDefect,
|
|
240
|
+
GetTransactionBranchFound,
|
|
241
|
+
GetTransactionBranchInvalidResponse,
|
|
242
|
+
GetTransactionBranchNotFound,
|
|
243
|
+
GetTransactionBranchProviderRejected,
|
|
244
|
+
GetTransactionDefinition,
|
|
245
|
+
GetTransactionInputSchema,
|
|
246
|
+
GetTransactionMetadata,
|
|
247
|
+
GetTransactionOperation,
|
|
248
|
+
ProviderID,
|
|
249
|
+
TransactionProfileSchema,
|
|
250
|
+
decodeCredentials,
|
|
251
|
+
newConnection,
|
|
252
|
+
newConnectionWithOperations,
|
|
253
|
+
newGetTransactionStep,
|
|
254
|
+
newProjectConnection2 as newProjectConnection
|
|
255
|
+
};
|
package/dist/mock.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { MockQuery, Case } from '@superdurable/connectors-sdk/connectormock';
|
|
2
|
+
import { Failure } from '@superdurable/connectors-sdk';
|
|
3
|
+
import { O as Operations, C as Connection, G as GetTransactionInput, T as TransactionProfile } from './connection-B5NUruTy.js';
|
|
4
|
+
import 'zod';
|
|
5
|
+
|
|
6
|
+
/** Go zero value for GetTransactionInput in scripted cases. */
|
|
7
|
+
declare const emptyGetTransactionInput: GetTransactionInput;
|
|
8
|
+
/** Go zero value for TransactionProfile in scripted cases. */
|
|
9
|
+
declare const emptyTransactionProfile: TransactionProfile;
|
|
10
|
+
/** Script the found branch. */
|
|
11
|
+
declare function getTransactionFound(value: TransactionProfile, failure?: Failure): Case<TransactionProfile>;
|
|
12
|
+
/** Script the notFound branch. */
|
|
13
|
+
declare function getTransactionNotFound(value: TransactionProfile, failure?: Failure): Case<TransactionProfile>;
|
|
14
|
+
/** Script the providerRejected branch. */
|
|
15
|
+
declare function getTransactionProviderRejected(value: TransactionProfile, failure?: Failure): Case<TransactionProfile>;
|
|
16
|
+
/** Script the invalidResponse branch. */
|
|
17
|
+
declare function getTransactionInvalidResponse(value: TransactionProfile, failure?: Failure): Case<TransactionProfile>;
|
|
18
|
+
/** Script the defect branch. */
|
|
19
|
+
declare function getTransactionDefect(value: TransactionProfile, failure?: Failure): Case<TransactionProfile>;
|
|
20
|
+
/** Script a safe retry of getTransaction. */
|
|
21
|
+
declare function getTransactionRetry(failure: Failure, retryAfterMs?: number): Case<TransactionProfile>;
|
|
22
|
+
/** Manifest scenario foundDefault for getTransaction. */
|
|
23
|
+
declare function getTransactionFoundDefault(): Case<TransactionProfile>;
|
|
24
|
+
/** Default getTransaction scenario. */
|
|
25
|
+
declare function getTransactionDefault(): Case<TransactionProfile>;
|
|
26
|
+
/** Scripted operations and manifest defaults for this connector. */
|
|
27
|
+
declare class GeneratedMock implements Operations {
|
|
28
|
+
#private;
|
|
29
|
+
constructor(connectionName: string);
|
|
30
|
+
connection(): Connection;
|
|
31
|
+
getTransaction(): MockQuery<GetTransactionInput, TransactionProfile>;
|
|
32
|
+
assertNoFailures(): void;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export { GeneratedMock, GeneratedMock as Mock, emptyGetTransactionInput, emptyTransactionProfile, getTransactionDefault, getTransactionDefect, getTransactionFound, getTransactionFoundDefault, getTransactionInvalidResponse, getTransactionNotFound, getTransactionProviderRejected, getTransactionRetry };
|
package/dist/mock.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import {
|
|
2
|
+
GetTransactionDefinition,
|
|
3
|
+
GetTransactionInputSchema,
|
|
4
|
+
ProviderID,
|
|
5
|
+
TransactionProfileSchema,
|
|
6
|
+
newConnectionWithOperations
|
|
7
|
+
} from "./chunk-4EVX2UKI.js";
|
|
8
|
+
|
|
9
|
+
// src/generated/mock.ts
|
|
10
|
+
import { branchCase, retryCase, newQuery } from "@superdurable/connectors-sdk/connectormock";
|
|
11
|
+
var emptyGetTransactionInput = GetTransactionInputSchema.parse({
|
|
12
|
+
"transactionId": ""
|
|
13
|
+
});
|
|
14
|
+
var emptyTransactionProfile = TransactionProfileSchema.parse({
|
|
15
|
+
"id": "",
|
|
16
|
+
"status": ""
|
|
17
|
+
});
|
|
18
|
+
function getTransactionFound(value, failure) {
|
|
19
|
+
return branchCase("found", value, failure);
|
|
20
|
+
}
|
|
21
|
+
function getTransactionNotFound(value, failure) {
|
|
22
|
+
return branchCase("notFound", value, failure);
|
|
23
|
+
}
|
|
24
|
+
function getTransactionProviderRejected(value, failure) {
|
|
25
|
+
return branchCase("providerRejected", value, failure);
|
|
26
|
+
}
|
|
27
|
+
function getTransactionInvalidResponse(value, failure) {
|
|
28
|
+
return branchCase("invalidResponse", value, failure);
|
|
29
|
+
}
|
|
30
|
+
function getTransactionDefect(value, failure) {
|
|
31
|
+
return branchCase("defect", value, failure);
|
|
32
|
+
}
|
|
33
|
+
function getTransactionRetry(failure, retryAfterMs = 0) {
|
|
34
|
+
return retryCase(failure, retryAfterMs);
|
|
35
|
+
}
|
|
36
|
+
function getTransactionFoundDefault() {
|
|
37
|
+
const value = TransactionProfileSchema.parse({ "id": "txn-1", "status": "SETTLED" });
|
|
38
|
+
return branchCase("found", value);
|
|
39
|
+
}
|
|
40
|
+
function getTransactionDefault() {
|
|
41
|
+
return getTransactionFoundDefault();
|
|
42
|
+
}
|
|
43
|
+
var GeneratedMock = class {
|
|
44
|
+
#getTransaction;
|
|
45
|
+
#connection;
|
|
46
|
+
constructor(connectionName) {
|
|
47
|
+
this.#getTransaction = newQuery(GetTransactionDefinition).default(getTransactionDefault());
|
|
48
|
+
this.#connection = newConnectionWithOperations(this, { provider: ProviderID, name: connectionName });
|
|
49
|
+
}
|
|
50
|
+
connection() {
|
|
51
|
+
return this.#connection;
|
|
52
|
+
}
|
|
53
|
+
getTransaction() {
|
|
54
|
+
return this.#getTransaction;
|
|
55
|
+
}
|
|
56
|
+
assertNoFailures() {
|
|
57
|
+
this.#getTransaction.assertNoFailures();
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
export {
|
|
61
|
+
GeneratedMock,
|
|
62
|
+
GeneratedMock as Mock,
|
|
63
|
+
emptyGetTransactionInput,
|
|
64
|
+
emptyTransactionProfile,
|
|
65
|
+
getTransactionDefault,
|
|
66
|
+
getTransactionDefect,
|
|
67
|
+
getTransactionFound,
|
|
68
|
+
getTransactionFoundDefault,
|
|
69
|
+
getTransactionInvalidResponse,
|
|
70
|
+
getTransactionNotFound,
|
|
71
|
+
getTransactionProviderRejected,
|
|
72
|
+
getTransactionRetry
|
|
73
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,61 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superdurable/connector-braintree",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"description": "Braintree connector for Dex TypeScript applications",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/superdurable/dex-connectors-library.git",
|
|
9
|
+
"directory": "connectors/braintree/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/transaction-read/worker.ts",
|
|
42
|
+
"example:start": "tsx examples/transaction-read/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
|
+
}
|