@superdurable/connector-aweber 0.0.0-stage → 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/LICENSE +21 -0
- package/README.md +4 -2
- package/dex-connector.json +61 -0
- package/dist/chunk-GPA62WB3.js +134 -0
- package/dist/connection-C55dNn1o.d.ts +101 -0
- package/dist/index.d.ts +98 -0
- package/dist/index.js +285 -0
- package/dist/mock.d.ts +35 -0
- package/dist/mock.js +75 -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,5 @@
|
|
|
1
|
-
#
|
|
1
|
+
# AWeber connector for TypeScript
|
|
2
2
|
|
|
3
|
-
This
|
|
3
|
+
This package implements `listAccounts` with the shared [manifest](../connector.yaml) and Go-recorded provider scenarios. See the [connector guide](../README.md) for OAuth setup and rate-limit behavior. The [runnable account Flow](examples/accounts/README.md) uses the static `aweber` Dex Web connection.
|
|
4
|
+
|
|
5
|
+
Run `npm ci` and `npm run check` from this directory. Live AWeber authorization and Dex Web field rendering have not been verified.
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"connectorId": "aweber",
|
|
3
|
+
"releaseTag": "connectors/aweber/go/v0.2.0",
|
|
4
|
+
"package": {
|
|
5
|
+
"ecosystem": "npm",
|
|
6
|
+
"name": "@superdurable/connector-aweber",
|
|
7
|
+
"version": "0.2.0"
|
|
8
|
+
},
|
|
9
|
+
"factories": [
|
|
10
|
+
{
|
|
11
|
+
"name": "newListAccountsStep",
|
|
12
|
+
"kind": "query",
|
|
13
|
+
"operationId": "listAccounts",
|
|
14
|
+
"inputType": "ListAccountsInput",
|
|
15
|
+
"description": "Return the authorized customer's account ID and company name.",
|
|
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": "ListAccountsInput selects an offset-based page of authorized accounts.",
|
|
47
|
+
"properties": {
|
|
48
|
+
"limit": {
|
|
49
|
+
"description": "Limit is the maximum account count; zero uses the provider default of 100.",
|
|
50
|
+
"type": "integer"
|
|
51
|
+
},
|
|
52
|
+
"offset": {
|
|
53
|
+
"description": "Offset is the zero-based number of accounts to skip; zero starts at the first account.",
|
|
54
|
+
"type": "integer"
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
"type": "object"
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
]
|
|
61
|
+
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
// src/generated/models.ts
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { SecretString } from "@superdurable/connectors-sdk";
|
|
4
|
+
var ConfigSchema = z.object({
|
|
5
|
+
"baseUrl": z.string().optional(),
|
|
6
|
+
"timeoutMs": z.number().int().optional(),
|
|
7
|
+
"maxResponseBytes": z.number().int().optional()
|
|
8
|
+
});
|
|
9
|
+
function decodeCredentials(value) {
|
|
10
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) throw new TypeError("credential fields are invalid");
|
|
11
|
+
const fields = value;
|
|
12
|
+
const allowed = /* @__PURE__ */ new Set(["access_token", "oauth_client_id", "oauth_client_secret", "refresh_token"]);
|
|
13
|
+
if (Object.keys(fields).some((key) => !allowed.has(key))) throw new TypeError("stored credential does not match the connector credential fields");
|
|
14
|
+
if (fields["access_token"] != null && !(typeof fields["access_token"] === "string")) throw new TypeError("credential access_token has an invalid type");
|
|
15
|
+
if (fields["oauth_client_id"] != null && !(typeof fields["oauth_client_id"] === "string")) throw new TypeError("credential oauth_client_id has an invalid type");
|
|
16
|
+
if (fields["oauth_client_secret"] != null && !(typeof fields["oauth_client_secret"] === "string")) throw new TypeError("credential oauth_client_secret has an invalid type");
|
|
17
|
+
if (fields["refresh_token"] != null && !(typeof fields["refresh_token"] === "string")) throw new TypeError("credential refresh_token has an invalid type");
|
|
18
|
+
const credentials = {};
|
|
19
|
+
if (!fields["oauth_client_id"]) throw new TypeError("credential oauth_client_id is required");
|
|
20
|
+
credentials.oauthClientId = fields["oauth_client_id"] ?? "";
|
|
21
|
+
if (!fields["oauth_client_secret"]) throw new TypeError("credential oauth_client_secret is required");
|
|
22
|
+
credentials.oauthClientSecret = new SecretString(fields["oauth_client_secret"] ?? "");
|
|
23
|
+
if (!fields["access_token"]) throw new TypeError("credential access_token is required");
|
|
24
|
+
credentials.accessToken = new SecretString(fields["access_token"] ?? "");
|
|
25
|
+
if (!fields["refresh_token"]) throw new TypeError("credential refresh_token is required");
|
|
26
|
+
credentials.refreshToken = new SecretString(fields["refresh_token"] ?? "");
|
|
27
|
+
return credentials;
|
|
28
|
+
}
|
|
29
|
+
function decodeSharedCredentials(value) {
|
|
30
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) throw new TypeError("credential fields are invalid");
|
|
31
|
+
const fields = value;
|
|
32
|
+
const allowed = /* @__PURE__ */ new Set(["access_token", "oauth_client_id", "oauth_client_secret", "refresh_token"]);
|
|
33
|
+
if (Object.keys(fields).some((key) => !allowed.has(key))) throw new TypeError("stored credential does not match the connector credential fields");
|
|
34
|
+
if (fields["access_token"] != null && !(typeof fields["access_token"] === "string")) throw new TypeError("credential access_token has an invalid type");
|
|
35
|
+
if (fields["oauth_client_id"] != null && !(typeof fields["oauth_client_id"] === "string")) throw new TypeError("credential oauth_client_id has an invalid type");
|
|
36
|
+
if (fields["oauth_client_secret"] != null && !(typeof fields["oauth_client_secret"] === "string")) throw new TypeError("credential oauth_client_secret has an invalid type");
|
|
37
|
+
if (fields["refresh_token"] != null && !(typeof fields["refresh_token"] === "string")) throw new TypeError("credential refresh_token has an invalid type");
|
|
38
|
+
const credentials = {};
|
|
39
|
+
if (!fields["oauth_client_id"]) throw new TypeError("credential oauth_client_id is required");
|
|
40
|
+
credentials.oauthClientId = fields["oauth_client_id"] ?? "";
|
|
41
|
+
credentials.oauthClientSecret = new SecretString(fields["oauth_client_secret"] ?? "");
|
|
42
|
+
if (!fields["access_token"]) throw new TypeError("credential access_token is required");
|
|
43
|
+
credentials.accessToken = new SecretString(fields["access_token"] ?? "");
|
|
44
|
+
credentials.refreshToken = new SecretString(fields["refresh_token"] ?? "");
|
|
45
|
+
return credentials;
|
|
46
|
+
}
|
|
47
|
+
var ListAccountsInputSchema = z.strictObject({
|
|
48
|
+
"offset": z.number().int().optional(),
|
|
49
|
+
"limit": z.number().int().optional()
|
|
50
|
+
});
|
|
51
|
+
var AccountSchema = z.strictObject({
|
|
52
|
+
"id": z.string(),
|
|
53
|
+
"company": z.string()
|
|
54
|
+
});
|
|
55
|
+
var AccountsPageSchema = z.strictObject({
|
|
56
|
+
"accounts": z.array(AccountSchema).nullable(),
|
|
57
|
+
"offset": z.number().int(),
|
|
58
|
+
"limit": z.number().int(),
|
|
59
|
+
"total": z.number().int()
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
// src/generated/definitions.ts
|
|
63
|
+
var ConnectorID = "aweber";
|
|
64
|
+
var ProviderID = "aweber";
|
|
65
|
+
var ListAccountsBranch = {
|
|
66
|
+
Listed: "listed",
|
|
67
|
+
ProviderRejected: "providerRejected",
|
|
68
|
+
InvalidResponse: "invalidResponse",
|
|
69
|
+
Defect: "defect"
|
|
70
|
+
};
|
|
71
|
+
var ListAccountsBranchListed = ListAccountsBranch.Listed;
|
|
72
|
+
var ListAccountsBranchProviderRejected = ListAccountsBranch.ProviderRejected;
|
|
73
|
+
var ListAccountsBranchInvalidResponse = ListAccountsBranch.InvalidResponse;
|
|
74
|
+
var ListAccountsBranchDefect = ListAccountsBranch.Defect;
|
|
75
|
+
var ListAccountsDefinition = {
|
|
76
|
+
operation: { connectorId: ConnectorID, operationId: "listAccounts" },
|
|
77
|
+
branches: [
|
|
78
|
+
{ id: "listed", description: "AWeber returned the selected account page." },
|
|
79
|
+
{ id: "providerRejected", description: "AWeber conclusively rejected the read.", optional: true },
|
|
80
|
+
{ id: "invalidResponse", description: "AWeber returned malformed or oversized account JSON.", optional: true },
|
|
81
|
+
{ id: "defect", description: "Local page input or connection credentials are invalid.", optional: true }
|
|
82
|
+
],
|
|
83
|
+
stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "async" }
|
|
84
|
+
};
|
|
85
|
+
var ListAccountsMetadata = { kind: "query", idempotency: "none", authorization: "required" };
|
|
86
|
+
|
|
87
|
+
// src/generated/connection.ts
|
|
88
|
+
import { ConnectionRefSchema } from "@superdurable/connectors-sdk";
|
|
89
|
+
import { newRefreshingCredentialProvider } from "@superdurable/connectors-sdk/projectconfig";
|
|
90
|
+
var Connection = class {
|
|
91
|
+
/** Stable provider and connection name. */
|
|
92
|
+
reference;
|
|
93
|
+
/** Bound provider operations. */
|
|
94
|
+
operations;
|
|
95
|
+
/** Validate a reference and bind operations. */
|
|
96
|
+
constructor(reference, operations) {
|
|
97
|
+
this.reference = ConnectionRefSchema.parse(reference);
|
|
98
|
+
if (this.reference.provider !== ProviderID) throw new TypeError("connection provider differs from the manifest");
|
|
99
|
+
if (!operations) throw new TypeError("connector operations are required");
|
|
100
|
+
this.operations = operations;
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
function newConnection(client, reference) {
|
|
104
|
+
if (!client) throw new TypeError("connector client is required");
|
|
105
|
+
return new Connection(reference, client);
|
|
106
|
+
}
|
|
107
|
+
function newConnectionWithOperations(operations, reference) {
|
|
108
|
+
return new Connection(reference, operations);
|
|
109
|
+
}
|
|
110
|
+
function newProjectCredentialProvider(project, connectionName, decode, encode, decodeShared) {
|
|
111
|
+
return newRefreshingCredentialProvider(project.connections, { connectorId: ConnectorID, connectionName }, decode, encode, decodeShared);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export {
|
|
115
|
+
ConfigSchema,
|
|
116
|
+
decodeCredentials,
|
|
117
|
+
decodeSharedCredentials,
|
|
118
|
+
ListAccountsInputSchema,
|
|
119
|
+
AccountSchema,
|
|
120
|
+
AccountsPageSchema,
|
|
121
|
+
ConnectorID,
|
|
122
|
+
ProviderID,
|
|
123
|
+
ListAccountsBranch,
|
|
124
|
+
ListAccountsBranchListed,
|
|
125
|
+
ListAccountsBranchProviderRejected,
|
|
126
|
+
ListAccountsBranchInvalidResponse,
|
|
127
|
+
ListAccountsBranchDefect,
|
|
128
|
+
ListAccountsDefinition,
|
|
129
|
+
ListAccountsMetadata,
|
|
130
|
+
Connection,
|
|
131
|
+
newConnection,
|
|
132
|
+
newConnectionWithOperations,
|
|
133
|
+
newProjectCredentialProvider
|
|
134
|
+
};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { SecretString, RefreshingCredentialProvider, Query, ConnectionRef } from '@superdurable/connectors-sdk';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
/** Connector configuration; omitted fields use manifest defaults. */
|
|
5
|
+
interface Config {
|
|
6
|
+
/** AWeber API HTTPS origin. Blank uses the displayed provider endpoint; override only for a trusted test gateway. */
|
|
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 only for a slow gateway. Runtime value in milliseconds. */
|
|
9
|
+
timeoutMs?: number;
|
|
10
|
+
/** Positive maximum complete JSON response in bytes. Blank uses the displayed default; increase only for unusually large account pages. */
|
|
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 Bearer token supplied by AWeber consent and rotated by Dex. Never enter it manually; blank requires authorization. */
|
|
22
|
+
accessToken: SecretString;
|
|
23
|
+
/** Non-secret Client ID from https://labs.aweber.com/apps > your confidential integration. Blank prevents authorization or refresh. */
|
|
24
|
+
oauthClientId: string;
|
|
25
|
+
/** Secret Client Secret from https://labs.aweber.com/apps > your confidential integration. Save only in Dex; blank prevents authorization or refresh. */
|
|
26
|
+
oauthClientSecret: SecretString;
|
|
27
|
+
/** Secret refresh token supplied by AWeber consent and rotated by Dex. Never enter it manually; blank requires reauthorization. */
|
|
28
|
+
refreshToken: SecretString;
|
|
29
|
+
}
|
|
30
|
+
/** Decode private credential fields for the connector. */
|
|
31
|
+
declare function decodeCredentials(value: unknown): Credentials;
|
|
32
|
+
/** Decode shared credential fields for the connector. */
|
|
33
|
+
declare function decodeSharedCredentials(value: unknown): Credentials;
|
|
34
|
+
/** Host-owned source of private connector credentials. */
|
|
35
|
+
type CredentialSource = RefreshingCredentialProvider<Credentials>;
|
|
36
|
+
/** ListAccountsInput selects an offset-based page of authorized accounts. */
|
|
37
|
+
interface ListAccountsInput {
|
|
38
|
+
/** Offset is the zero-based number of accounts to skip; zero starts at the first account. */
|
|
39
|
+
"offset"?: number | undefined;
|
|
40
|
+
/** Limit is the maximum account count; zero uses the provider default of 100. */
|
|
41
|
+
"limit"?: number | undefined;
|
|
42
|
+
}
|
|
43
|
+
/** Account contains the stable account ID and display company. */
|
|
44
|
+
interface Account {
|
|
45
|
+
/** ID is the AWeber account's numeric identifier. */
|
|
46
|
+
"id": string;
|
|
47
|
+
/** Company is the customer account's display name. */
|
|
48
|
+
"company": string;
|
|
49
|
+
}
|
|
50
|
+
/** AccountsPage is one offset-based account page. */
|
|
51
|
+
interface AccountsPage {
|
|
52
|
+
/** Accounts contains the visible customer accounts. */
|
|
53
|
+
"accounts": Array<Account> | null;
|
|
54
|
+
/** Offset is the zero-based offset used for this request. */
|
|
55
|
+
"offset": number;
|
|
56
|
+
/** Limit is the maximum account count used for this request. */
|
|
57
|
+
"limit": number;
|
|
58
|
+
/** Total is the provider's full account count. */
|
|
59
|
+
"total": number;
|
|
60
|
+
}
|
|
61
|
+
/** Runtime validator for ListAccountsInput. */
|
|
62
|
+
declare const ListAccountsInputSchema: z.ZodObject<{
|
|
63
|
+
offset: z.ZodOptional<z.ZodNumber>;
|
|
64
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
65
|
+
}, z.core.$strict>;
|
|
66
|
+
/** Runtime validator for Account. */
|
|
67
|
+
declare const AccountSchema: z.ZodObject<{
|
|
68
|
+
id: z.ZodString;
|
|
69
|
+
company: z.ZodString;
|
|
70
|
+
}, z.core.$strict>;
|
|
71
|
+
/** Runtime validator for AccountsPage. */
|
|
72
|
+
declare const AccountsPageSchema: z.ZodObject<{
|
|
73
|
+
accounts: z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
74
|
+
id: z.ZodString;
|
|
75
|
+
company: z.ZodString;
|
|
76
|
+
}, z.core.$strict>>>;
|
|
77
|
+
offset: z.ZodNumber;
|
|
78
|
+
limit: z.ZodNumber;
|
|
79
|
+
total: z.ZodNumber;
|
|
80
|
+
}, z.core.$strict>;
|
|
81
|
+
|
|
82
|
+
/** Typed operations supplied by a client or mock. */
|
|
83
|
+
interface Operations {
|
|
84
|
+
/** Invoke listAccounts through this connection. */
|
|
85
|
+
listAccounts(): Query<ListAccountsInput, AccountsPage>;
|
|
86
|
+
}
|
|
87
|
+
/** Named connector connection kept outside Flow state. */
|
|
88
|
+
declare class Connection<BoundOperations = Operations> {
|
|
89
|
+
/** Stable provider and connection name. */
|
|
90
|
+
readonly reference: ConnectionRef;
|
|
91
|
+
/** Bound provider operations. */
|
|
92
|
+
readonly operations: BoundOperations;
|
|
93
|
+
/** Validate a reference and bind operations. */
|
|
94
|
+
constructor(reference: ConnectionRef, operations: BoundOperations);
|
|
95
|
+
}
|
|
96
|
+
/** Bind a client to a named connection. */
|
|
97
|
+
declare function newConnection(client: Operations, reference: ConnectionRef): Connection;
|
|
98
|
+
/** Bind scripted operations to a named connection. */
|
|
99
|
+
declare function newConnectionWithOperations(operations: Operations, reference: ConnectionRef): Connection;
|
|
100
|
+
|
|
101
|
+
export { type AccountsPage as A, Connection as C, type ListAccountsInput as L, type Operations as O, type Config as a, type Credentials as b, type Account as c, AccountSchema as d, AccountsPageSchema as e, ConfigSchema as f, type CredentialSource as g, ListAccountsInputSchema as h, decodeCredentials as i, decodeSharedCredentials as j, newConnectionWithOperations as k, newConnection as n };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { L as ListAccountsInput, A as AccountsPage, C as Connection, a as Config, b as Credentials, O as Operations } from './connection-C55dNn1o.js';
|
|
2
|
+
export { c as Account, d as AccountSchema, e as AccountsPageSchema, f as ConfigSchema, g as CredentialSource, h as ListAccountsInputSchema, i as decodeCredentials, j as decodeSharedCredentials, n as newConnection, k as newConnectionWithOperations } from './connection-C55dNn1o.js';
|
|
3
|
+
import { QueryDefinition, QueryStepConfig, Query, QueryResult, QueryStep, Call, QueryAttempt, CredentialProvider, CredentialRefreshDriver } 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 = "aweber";
|
|
11
|
+
/** Provider identity for named connections. */
|
|
12
|
+
declare const ProviderID = "aweber";
|
|
13
|
+
/** Branch IDs for listAccounts. */
|
|
14
|
+
declare const ListAccountsBranch: {
|
|
15
|
+
readonly Listed: "listed";
|
|
16
|
+
readonly ProviderRejected: "providerRejected";
|
|
17
|
+
readonly InvalidResponse: "invalidResponse";
|
|
18
|
+
readonly Defect: "defect";
|
|
19
|
+
};
|
|
20
|
+
/** AWeber returned the selected account page. */
|
|
21
|
+
declare const ListAccountsBranchListed: "listed";
|
|
22
|
+
/** AWeber conclusively rejected the read. */
|
|
23
|
+
declare const ListAccountsBranchProviderRejected: "providerRejected";
|
|
24
|
+
/** AWeber returned malformed or oversized account JSON. */
|
|
25
|
+
declare const ListAccountsBranchInvalidResponse: "invalidResponse";
|
|
26
|
+
/** Local page input or connection credentials are invalid. */
|
|
27
|
+
declare const ListAccountsBranchDefect: "defect";
|
|
28
|
+
/** Manifest definition for listAccounts. */
|
|
29
|
+
declare const ListAccountsDefinition: QueryDefinition;
|
|
30
|
+
/** Manifest metadata for listAccounts. */
|
|
31
|
+
declare const ListAccountsMetadata: {
|
|
32
|
+
readonly kind: "query";
|
|
33
|
+
readonly idempotency: "none";
|
|
34
|
+
readonly authorization: "required";
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/** Configuration for the listAccounts connector Step. */
|
|
38
|
+
interface ListAccountsStepConfig<StepInput, OperationInput = ListAccountsInput, OperationOutput = AccountsPage> extends Omit<QueryStepConfig<StepInput, OperationInput, OperationOutput>, 'operation' | 'connection' | 'branches'> {
|
|
39
|
+
/** Named connection supplying this operation. */
|
|
40
|
+
connection: Connection<{
|
|
41
|
+
listAccounts(): Query<OperationInput, OperationOutput>;
|
|
42
|
+
}>;
|
|
43
|
+
/** Name matching the bound connection. */
|
|
44
|
+
connectionName: string;
|
|
45
|
+
/** AWeber returned the selected account page. */
|
|
46
|
+
listed: StepTarget<QueryResult<OperationOutput>>;
|
|
47
|
+
/** AWeber conclusively rejected the read. */
|
|
48
|
+
providerRejected?: StepTarget<QueryResult<OperationOutput>>;
|
|
49
|
+
/** AWeber returned malformed or oversized account JSON. */
|
|
50
|
+
invalidResponse?: StepTarget<QueryResult<OperationOutput>>;
|
|
51
|
+
/** Local page input or connection credentials are invalid. */
|
|
52
|
+
defect?: StepTarget<QueryResult<OperationOutput>>;
|
|
53
|
+
}
|
|
54
|
+
/** Build the listAccounts Step from a named connection. */
|
|
55
|
+
declare function newListAccountsStep<StepInput, OperationInput = ListAccountsInput, OperationOutput = AccountsPage>(configuration: ListAccountsStepConfig<StepInput, OperationInput, OperationOutput>): QueryStep<StepInput, OperationInput, OperationOutput>;
|
|
56
|
+
|
|
57
|
+
/** Read one page of the OAuth-authorized customer's accounts. */
|
|
58
|
+
declare class ListAccountsOperation implements Query<ListAccountsInput, AccountsPage> {
|
|
59
|
+
private readonly client;
|
|
60
|
+
/** Bind the provider client. */ constructor(client: AWeberClient);
|
|
61
|
+
/** Return the generated Query contract. */ definition(): QueryDefinition;
|
|
62
|
+
/** Project account IDs and company names from a bounded JSON response. */
|
|
63
|
+
invoke(call: Call, input: ListAccountsInput): Promise<QueryAttempt<AccountsPage>>;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** Injectable AWeber transport and OAuth refresh dependencies. */
|
|
67
|
+
interface AWeberClientOptions {
|
|
68
|
+
/** Provider sender; omitted uses the SDK HTTP transport. */ send?: (request: ProviderRequest) => Promise<ProviderResponse>;
|
|
69
|
+
/** Refresh driver; omitted uses the manifest declaration. */ refreshDriver?: CredentialRefreshDriver<Credentials>;
|
|
70
|
+
/** Clock used for Retry-After dates. */ now?: () => Date;
|
|
71
|
+
}
|
|
72
|
+
/** One bounded provider response or a classified local failure. */
|
|
73
|
+
interface AWeberExchange {
|
|
74
|
+
/** HTTP status, or zero before response headers. */ status: number;
|
|
75
|
+
/** Response bytes retained only during this call. */ body: Uint8Array;
|
|
76
|
+
/** Retry-After delay in milliseconds. */ retryAfterMs: number;
|
|
77
|
+
/** Safe local failure class. */ error?: 'credential' | 'refresh' | 'request' | 'tooLarge';
|
|
78
|
+
}
|
|
79
|
+
/** AWeber client resolving renewable OAuth credentials for each call. */
|
|
80
|
+
declare class AWeberClient {
|
|
81
|
+
private readonly credentials;
|
|
82
|
+
private readonly baseURL;
|
|
83
|
+
private readonly timeoutMs;
|
|
84
|
+
private readonly maxResponseBytes;
|
|
85
|
+
private readonly refreshDriver;
|
|
86
|
+
private readonly sendRequest;
|
|
87
|
+
private readonly now;
|
|
88
|
+
/** Validate settings without contacting AWeber. */
|
|
89
|
+
constructor(config: Config, credentials: CredentialProvider<Credentials>, options?: AWeberClientOptions);
|
|
90
|
+
/** Bind the account page Query. */ listAccounts(): ListAccountsOperation;
|
|
91
|
+
/** Send one bounded GET with a bearer token held outside Flow state. */
|
|
92
|
+
get(call: Call, path: string): Promise<AWeberExchange>;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** Open a statically named renewable Accounts connection from Dex project configuration. */
|
|
96
|
+
declare function newProjectConnection(project: LoadedProject, connectionName: string, options?: AWeberClientOptions): Connection<Operations>;
|
|
97
|
+
|
|
98
|
+
export { AWeberClient, type AWeberClientOptions, AccountsPage, Config, Connection, ConnectorID, Credentials, ListAccountsBranch, ListAccountsBranchDefect, ListAccountsBranchInvalidResponse, ListAccountsBranchListed, ListAccountsBranchProviderRejected, ListAccountsDefinition, ListAccountsInput, ListAccountsMetadata, ListAccountsOperation, type ListAccountsStepConfig, ProviderID, newListAccountsStep, newProjectConnection };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AccountSchema,
|
|
3
|
+
AccountsPageSchema,
|
|
4
|
+
ConfigSchema,
|
|
5
|
+
Connection,
|
|
6
|
+
ConnectorID,
|
|
7
|
+
ListAccountsBranch,
|
|
8
|
+
ListAccountsBranchDefect,
|
|
9
|
+
ListAccountsBranchInvalidResponse,
|
|
10
|
+
ListAccountsBranchListed,
|
|
11
|
+
ListAccountsBranchProviderRejected,
|
|
12
|
+
ListAccountsDefinition,
|
|
13
|
+
ListAccountsInputSchema,
|
|
14
|
+
ListAccountsMetadata,
|
|
15
|
+
ProviderID,
|
|
16
|
+
decodeCredentials,
|
|
17
|
+
decodeSharedCredentials,
|
|
18
|
+
newConnection,
|
|
19
|
+
newConnectionWithOperations,
|
|
20
|
+
newProjectCredentialProvider
|
|
21
|
+
} from "./chunk-GPA62WB3.js";
|
|
22
|
+
|
|
23
|
+
// src/generated/steps.ts
|
|
24
|
+
import { goToBranch, newQueryStep } from "@superdurable/connectors-sdk";
|
|
25
|
+
function newListAccountsStep(configuration) {
|
|
26
|
+
const { connection, connectionName, listed, providerRejected, invalidResponse, defect, ...stepConfiguration } = configuration;
|
|
27
|
+
if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
|
|
28
|
+
return newQueryStep({ ...stepConfiguration, operation: connection.operations.listAccounts(), connection: connection.reference, branches: [
|
|
29
|
+
goToBranch("listed", listed),
|
|
30
|
+
...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
|
|
31
|
+
...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
|
|
32
|
+
...defect ? [goToBranch("defect", defect)] : []
|
|
33
|
+
] });
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// src/client.ts
|
|
37
|
+
import { SecretString, ReauthorizationRequiredError, resolveCredential } from "@superdurable/connectors-sdk";
|
|
38
|
+
import { ManifestCredentialRefreshDriver } from "@superdurable/connectors-sdk/oauthtoken";
|
|
39
|
+
import { BodyTooLargeError, ProviderTransportError, isHeaderSafeCredential, parseRetryAfter, sendProviderRequest, validateBaseURL } from "@superdurable/connectors-sdk/providerhttp";
|
|
40
|
+
|
|
41
|
+
// src/generated/refresh.ts
|
|
42
|
+
var Authorization = {
|
|
43
|
+
"fields": [
|
|
44
|
+
{
|
|
45
|
+
"name": "oauth_client_id",
|
|
46
|
+
"required": true,
|
|
47
|
+
"type": "string"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"name": "oauth_client_secret",
|
|
51
|
+
"required": true,
|
|
52
|
+
"type": "secretString"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"name": "access_token",
|
|
56
|
+
"required": true,
|
|
57
|
+
"type": "secretString"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"name": "refresh_token",
|
|
61
|
+
"required": true,
|
|
62
|
+
"type": "secretString"
|
|
63
|
+
}
|
|
64
|
+
],
|
|
65
|
+
"oauth2": {
|
|
66
|
+
"clientIDCredential": "oauth_client_id",
|
|
67
|
+
"clientSecretCredential": "oauth_client_secret",
|
|
68
|
+
"credentialMappings": [
|
|
69
|
+
{
|
|
70
|
+
"credential": "access_token",
|
|
71
|
+
"source": "access_token"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"credential": "refresh_token",
|
|
75
|
+
"source": "refresh_token"
|
|
76
|
+
}
|
|
77
|
+
],
|
|
78
|
+
"refresh": {
|
|
79
|
+
"missingExpiry": "reject",
|
|
80
|
+
"storedMissingExpiry": "refresh",
|
|
81
|
+
"terminalErrorCodes": [
|
|
82
|
+
"invalid_grant",
|
|
83
|
+
"invalid_client",
|
|
84
|
+
"unauthorized_client"
|
|
85
|
+
],
|
|
86
|
+
"tokenExchangeTimeout": "15s"
|
|
87
|
+
},
|
|
88
|
+
"scopes": [
|
|
89
|
+
"account.read"
|
|
90
|
+
],
|
|
91
|
+
"tokenEndpoint": "https://auth.aweber.com/oauth2/token",
|
|
92
|
+
"tokenEndpointAuthMethod": "client_secret_basic"
|
|
93
|
+
},
|
|
94
|
+
"refreshable": true,
|
|
95
|
+
"type": "oauth2"
|
|
96
|
+
};
|
|
97
|
+
var CredentialFields = {
|
|
98
|
+
"access_token": "accessToken",
|
|
99
|
+
"oauth_client_id": "oauthClientId",
|
|
100
|
+
"oauth_client_secret": "oauthClientSecret",
|
|
101
|
+
"refresh_token": "refreshToken"
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
// src/operations.ts
|
|
105
|
+
import { newQueryBranch, newQueryRetry } from "@superdurable/connectors-sdk";
|
|
106
|
+
var emptyPage = () => ({ accounts: [], offset: 0, limit: 0, total: 0 });
|
|
107
|
+
var ListAccountsOperation = class {
|
|
108
|
+
/** Bind the provider client. */
|
|
109
|
+
constructor(client) {
|
|
110
|
+
this.client = client;
|
|
111
|
+
}
|
|
112
|
+
client;
|
|
113
|
+
/** Return the generated Query contract. */
|
|
114
|
+
definition() {
|
|
115
|
+
return ListAccountsDefinition;
|
|
116
|
+
}
|
|
117
|
+
/** Project account IDs and company names from a bounded JSON response. */
|
|
118
|
+
async invoke(call, input) {
|
|
119
|
+
const offset = input?.offset ?? 0;
|
|
120
|
+
if (!input || !Number.isSafeInteger(offset) || offset < 0 || input.limit !== void 0 && (!Number.isSafeInteger(input.limit) || input.limit < 0 || input.limit > 100))
|
|
121
|
+
return branch("defect", "VALIDATION", "offset or limit is invalid");
|
|
122
|
+
const limit = input.limit || 100;
|
|
123
|
+
const query = new URLSearchParams({ "ws.size": String(limit), "ws.start": String(offset) });
|
|
124
|
+
const exchange = await this.client.get(call, `/1.0/accounts?${query.toString()}`);
|
|
125
|
+
const failed = classifyRead(exchange);
|
|
126
|
+
if (failed) return failed;
|
|
127
|
+
const document = parseDocument(exchange.body);
|
|
128
|
+
if (!document || !Array.isArray(document.entries) || typeof document.start !== "number" || !Number.isSafeInteger(document.start) || document.start !== offset || typeof document.total_size !== "number" || !Number.isSafeInteger(document.total_size) || document.total_size < document.entries.length)
|
|
129
|
+
return branch("invalidResponse", "PROTOCOL", "AWeber returned invalid account JSON");
|
|
130
|
+
const accounts = [];
|
|
131
|
+
for (const item of document.entries) {
|
|
132
|
+
if (!isObject(item) || typeof item.id !== "number" || !Number.isSafeInteger(item.id) || item.id <= 0 || item.id > 2147483647 || typeof item.company !== "string")
|
|
133
|
+
return branch("invalidResponse", "PROTOCOL", "AWeber returned invalid account JSON");
|
|
134
|
+
accounts.push({ id: String(item.id), company: item.company });
|
|
135
|
+
}
|
|
136
|
+
return newQueryBranch("listed", { accounts, offset, limit, total: document.total_size });
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
function classifyRead(exchange) {
|
|
140
|
+
if (exchange.error === "credential") return branch("defect", "AUTHENTICATION", "connection credentials are unavailable or invalid");
|
|
141
|
+
if (exchange.error === "refresh" || exchange.error === "request") return retry("TRANSPORT", "AWeber request failed");
|
|
142
|
+
if (exchange.status === 429) return retry("RATE_LIMIT", "AWeber rate limited the request", exchange.retryAfterMs);
|
|
143
|
+
if (exchange.status === 408 || exchange.status >= 500) return retry("AVAILABILITY", "AWeber is temporarily unavailable", exchange.retryAfterMs);
|
|
144
|
+
if (exchange.error === "tooLarge") return branch("invalidResponse", "RESPONSE_TOO_LARGE", "AWeber response exceeded the configured limit");
|
|
145
|
+
if (exchange.status === 403 && isRateLimit(exchange.body)) return retry("RATE_LIMIT", "AWeber rate limited the request", exchange.retryAfterMs);
|
|
146
|
+
if (exchange.status !== 200) return branch("providerRejected", "PROVIDER_REJECTION", `AWeber rejected HTTP ${exchange.status}`);
|
|
147
|
+
return void 0;
|
|
148
|
+
}
|
|
149
|
+
function isRateLimit(body) {
|
|
150
|
+
const document = parseDocument(body);
|
|
151
|
+
return isObject(document?.error) && document.error.type === "ForbiddenError" && typeof document.error.message === "string" && document.error.message.toLowerCase() === "rate limit error";
|
|
152
|
+
}
|
|
153
|
+
function parseDocument(body) {
|
|
154
|
+
try {
|
|
155
|
+
const value = JSON.parse(Buffer.from(body).toString("utf8"));
|
|
156
|
+
return isObject(value) ? value : void 0;
|
|
157
|
+
} catch {
|
|
158
|
+
return void 0;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
function isObject(value) {
|
|
162
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
163
|
+
}
|
|
164
|
+
function branch(branchId, kind, message) {
|
|
165
|
+
return newQueryBranch(branchId, emptyPage(), {}, failure(kind, message));
|
|
166
|
+
}
|
|
167
|
+
function retry(kind, message, delay = 0) {
|
|
168
|
+
return newQueryRetry(failure(kind, message), delay);
|
|
169
|
+
}
|
|
170
|
+
function failure(kind, message) {
|
|
171
|
+
return { kind, provider: "aweber", operation: "listAccounts", message };
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// src/client.ts
|
|
175
|
+
var AWeberClient = class {
|
|
176
|
+
/** Validate settings without contacting AWeber. */
|
|
177
|
+
constructor(config, credentials, options = {}) {
|
|
178
|
+
this.credentials = credentials;
|
|
179
|
+
if (!config || !credentials) throw new TypeError("AWeber configuration and credentials are required");
|
|
180
|
+
this.baseURL = validateBaseURL(config.baseUrl || "https://api.aweber.com");
|
|
181
|
+
this.timeoutMs = config.timeoutMs || 15e3;
|
|
182
|
+
this.maxResponseBytes = config.maxResponseBytes || 1048576;
|
|
183
|
+
if (!Number.isSafeInteger(this.timeoutMs) || this.timeoutMs <= 0 || !Number.isSafeInteger(this.maxResponseBytes) || this.maxResponseBytes <= 0)
|
|
184
|
+
throw new TypeError("AWeber request limits are invalid");
|
|
185
|
+
this.refreshDriver = options.refreshDriver ?? new ManifestCredentialRefreshDriver({
|
|
186
|
+
providerName: "AWeber",
|
|
187
|
+
auth: Authorization,
|
|
188
|
+
credentialFields: CredentialFields
|
|
189
|
+
});
|
|
190
|
+
this.sendRequest = options.send ?? sendProviderRequest;
|
|
191
|
+
this.now = options.now ?? (() => /* @__PURE__ */ new Date());
|
|
192
|
+
}
|
|
193
|
+
credentials;
|
|
194
|
+
baseURL;
|
|
195
|
+
timeoutMs;
|
|
196
|
+
maxResponseBytes;
|
|
197
|
+
refreshDriver;
|
|
198
|
+
sendRequest;
|
|
199
|
+
now;
|
|
200
|
+
/** Bind the account page Query. */
|
|
201
|
+
listAccounts() {
|
|
202
|
+
return new ListAccountsOperation(this);
|
|
203
|
+
}
|
|
204
|
+
/** Send one bounded GET with a bearer token held outside Flow state. */
|
|
205
|
+
async get(call, path) {
|
|
206
|
+
let token;
|
|
207
|
+
try {
|
|
208
|
+
const resolved = await resolveCredential(this.credentials, call, this.refreshDriver, call.context.cancellationSignal);
|
|
209
|
+
token = resolved.accessToken instanceof SecretString ? resolved.accessToken.reveal() : "";
|
|
210
|
+
if (!token || !isHeaderSafeCredential(token)) return failedExchange("credential");
|
|
211
|
+
} catch (error) {
|
|
212
|
+
return failedExchange(error instanceof ReauthorizationRequiredError ? "credential" : "refresh");
|
|
213
|
+
}
|
|
214
|
+
const request = {
|
|
215
|
+
url: this.baseURL + path,
|
|
216
|
+
method: "GET",
|
|
217
|
+
headers: { Accept: "application/json", Authorization: `Bearer ${token}` },
|
|
218
|
+
maxResponseBytes: this.maxResponseBytes,
|
|
219
|
+
timeoutMs: this.timeoutMs,
|
|
220
|
+
addressPolicy: this.baseURL.startsWith("https://") ? "publicHTTPS" : "privateNetworkHTTP",
|
|
221
|
+
signal: call.context.cancellationSignal
|
|
222
|
+
};
|
|
223
|
+
let response;
|
|
224
|
+
try {
|
|
225
|
+
response = await this.sendRequest(request);
|
|
226
|
+
} catch (error) {
|
|
227
|
+
if (error instanceof BodyTooLargeError && error.status !== void 0)
|
|
228
|
+
return { ...failedExchange("tooLarge"), status: error.status, retryAfterMs: parseRetryAfter(header(error.headers ?? {}, "retry-after"), this.now()) };
|
|
229
|
+
if (error instanceof ProviderTransportError) return failedExchange("request");
|
|
230
|
+
return failedExchange("request");
|
|
231
|
+
}
|
|
232
|
+
const retryAfterMs = parseRetryAfter(header(response.headers, "retry-after"), this.now());
|
|
233
|
+
if (Buffer.from(response.body).includes(token)) return { ...failedExchange("credential"), status: response.status, retryAfterMs };
|
|
234
|
+
return { status: response.status, body: response.body, retryAfterMs };
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
function failedExchange(error) {
|
|
238
|
+
return { status: 0, body: new Uint8Array(), retryAfterMs: 0, error };
|
|
239
|
+
}
|
|
240
|
+
function header(headers, name) {
|
|
241
|
+
const value = Object.entries(headers).find(([key]) => key.toLowerCase() === name.toLowerCase())?.[1];
|
|
242
|
+
return Array.isArray(value) ? value[0] ?? "" : value ?? "";
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// src/project.ts
|
|
246
|
+
function encodeCredentials(credentials) {
|
|
247
|
+
return {
|
|
248
|
+
oauth_client_id: credentials.oauthClientId,
|
|
249
|
+
oauth_client_secret: credentials.oauthClientSecret.reveal(),
|
|
250
|
+
access_token: credentials.accessToken.reveal(),
|
|
251
|
+
refresh_token: credentials.refreshToken.reveal()
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
function newProjectConnection(project, connectionName, options = {}) {
|
|
255
|
+
if (!project) throw new TypeError("Accounts project is required");
|
|
256
|
+
const selected = project.configuration.connections.find((entry) => entry.connectorId === "aweber" && entry.connectionName === connectionName);
|
|
257
|
+
if (!selected || selected.provider !== "aweber") throw new TypeError("Accounts project connection is not configured");
|
|
258
|
+
const config = ConfigSchema.parse(selected.configuration);
|
|
259
|
+
const provider = newProjectCredentialProvider(project, connectionName, decodeCredentials, encodeCredentials, decodeSharedCredentials);
|
|
260
|
+
return newConnection(new AWeberClient(config, provider, options), { provider: "aweber", name: connectionName });
|
|
261
|
+
}
|
|
262
|
+
export {
|
|
263
|
+
AWeberClient,
|
|
264
|
+
AccountSchema,
|
|
265
|
+
AccountsPageSchema,
|
|
266
|
+
ConfigSchema,
|
|
267
|
+
Connection,
|
|
268
|
+
ConnectorID,
|
|
269
|
+
ListAccountsBranch,
|
|
270
|
+
ListAccountsBranchDefect,
|
|
271
|
+
ListAccountsBranchInvalidResponse,
|
|
272
|
+
ListAccountsBranchListed,
|
|
273
|
+
ListAccountsBranchProviderRejected,
|
|
274
|
+
ListAccountsDefinition,
|
|
275
|
+
ListAccountsInputSchema,
|
|
276
|
+
ListAccountsMetadata,
|
|
277
|
+
ListAccountsOperation,
|
|
278
|
+
ProviderID,
|
|
279
|
+
decodeCredentials,
|
|
280
|
+
decodeSharedCredentials,
|
|
281
|
+
newConnection,
|
|
282
|
+
newConnectionWithOperations,
|
|
283
|
+
newListAccountsStep,
|
|
284
|
+
newProjectConnection
|
|
285
|
+
};
|
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, L as ListAccountsInput, A as AccountsPage, c as Account } from './connection-C55dNn1o.js';
|
|
4
|
+
import 'zod';
|
|
5
|
+
|
|
6
|
+
/** Go zero value for ListAccountsInput in scripted cases. */
|
|
7
|
+
declare const emptyListAccountsInput: ListAccountsInput;
|
|
8
|
+
/** Go zero value for Account in scripted cases. */
|
|
9
|
+
declare const emptyAccount: Account;
|
|
10
|
+
/** Go zero value for AccountsPage in scripted cases. */
|
|
11
|
+
declare const emptyAccountsPage: AccountsPage;
|
|
12
|
+
/** Script the listed branch. */
|
|
13
|
+
declare function listAccountsListed(value: AccountsPage, failure?: Failure): Case<AccountsPage>;
|
|
14
|
+
/** Script the providerRejected branch. */
|
|
15
|
+
declare function listAccountsProviderRejected(value: AccountsPage, failure?: Failure): Case<AccountsPage>;
|
|
16
|
+
/** Script the invalidResponse branch. */
|
|
17
|
+
declare function listAccountsInvalidResponse(value: AccountsPage, failure?: Failure): Case<AccountsPage>;
|
|
18
|
+
/** Script the defect branch. */
|
|
19
|
+
declare function listAccountsDefect(value: AccountsPage, failure?: Failure): Case<AccountsPage>;
|
|
20
|
+
/** Script a safe retry of listAccounts. */
|
|
21
|
+
declare function listAccountsRetry(failure: Failure, retryAfterMs?: number): Case<AccountsPage>;
|
|
22
|
+
/** Manifest scenario listedDefault for listAccounts. */
|
|
23
|
+
declare function listAccountsListedDefault(): Case<AccountsPage>;
|
|
24
|
+
/** Default listAccounts scenario. */
|
|
25
|
+
declare function listAccountsDefault(): Case<AccountsPage>;
|
|
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
|
+
listAccounts(): MockQuery<ListAccountsInput, AccountsPage>;
|
|
32
|
+
assertNoFailures(): void;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export { GeneratedMock, GeneratedMock as Mock, emptyAccount, emptyAccountsPage, emptyListAccountsInput, listAccountsDefault, listAccountsDefect, listAccountsInvalidResponse, listAccountsListed, listAccountsListedDefault, listAccountsProviderRejected, listAccountsRetry };
|
package/dist/mock.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AccountSchema,
|
|
3
|
+
AccountsPageSchema,
|
|
4
|
+
ListAccountsDefinition,
|
|
5
|
+
ListAccountsInputSchema,
|
|
6
|
+
ProviderID,
|
|
7
|
+
newConnectionWithOperations
|
|
8
|
+
} from "./chunk-GPA62WB3.js";
|
|
9
|
+
|
|
10
|
+
// src/generated/mock.ts
|
|
11
|
+
import { branchCase, retryCase, newQuery } from "@superdurable/connectors-sdk/connectormock";
|
|
12
|
+
var emptyListAccountsInput = ListAccountsInputSchema.parse({});
|
|
13
|
+
var emptyAccount = AccountSchema.parse({
|
|
14
|
+
"id": "",
|
|
15
|
+
"company": ""
|
|
16
|
+
});
|
|
17
|
+
var emptyAccountsPage = AccountsPageSchema.parse({
|
|
18
|
+
"accounts": [],
|
|
19
|
+
"offset": 0,
|
|
20
|
+
"limit": 0,
|
|
21
|
+
"total": 0
|
|
22
|
+
});
|
|
23
|
+
function listAccountsListed(value, failure) {
|
|
24
|
+
return branchCase("listed", value, failure);
|
|
25
|
+
}
|
|
26
|
+
function listAccountsProviderRejected(value, failure) {
|
|
27
|
+
return branchCase("providerRejected", value, failure);
|
|
28
|
+
}
|
|
29
|
+
function listAccountsInvalidResponse(value, failure) {
|
|
30
|
+
return branchCase("invalidResponse", value, failure);
|
|
31
|
+
}
|
|
32
|
+
function listAccountsDefect(value, failure) {
|
|
33
|
+
return branchCase("defect", value, failure);
|
|
34
|
+
}
|
|
35
|
+
function listAccountsRetry(failure, retryAfterMs = 0) {
|
|
36
|
+
return retryCase(failure, retryAfterMs);
|
|
37
|
+
}
|
|
38
|
+
function listAccountsListedDefault() {
|
|
39
|
+
const value = AccountsPageSchema.parse({ "accounts": [{ "company": "Example Company", "id": "123" }], "limit": 100, "offset": 0, "total": 1 });
|
|
40
|
+
return branchCase("listed", value);
|
|
41
|
+
}
|
|
42
|
+
function listAccountsDefault() {
|
|
43
|
+
return listAccountsListedDefault();
|
|
44
|
+
}
|
|
45
|
+
var GeneratedMock = class {
|
|
46
|
+
#listAccounts;
|
|
47
|
+
#connection;
|
|
48
|
+
constructor(connectionName) {
|
|
49
|
+
this.#listAccounts = newQuery(ListAccountsDefinition).default(listAccountsDefault());
|
|
50
|
+
this.#connection = newConnectionWithOperations(this, { provider: ProviderID, name: connectionName });
|
|
51
|
+
}
|
|
52
|
+
connection() {
|
|
53
|
+
return this.#connection;
|
|
54
|
+
}
|
|
55
|
+
listAccounts() {
|
|
56
|
+
return this.#listAccounts;
|
|
57
|
+
}
|
|
58
|
+
assertNoFailures() {
|
|
59
|
+
this.#listAccounts.assertNoFailures();
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
export {
|
|
63
|
+
GeneratedMock,
|
|
64
|
+
GeneratedMock as Mock,
|
|
65
|
+
emptyAccount,
|
|
66
|
+
emptyAccountsPage,
|
|
67
|
+
emptyListAccountsInput,
|
|
68
|
+
listAccountsDefault,
|
|
69
|
+
listAccountsDefect,
|
|
70
|
+
listAccountsInvalidResponse,
|
|
71
|
+
listAccountsListed,
|
|
72
|
+
listAccountsListedDefault,
|
|
73
|
+
listAccountsProviderRejected,
|
|
74
|
+
listAccountsRetry
|
|
75
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,61 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superdurable/connector-aweber",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
6
|
-
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"description": "AWeber connector for Dex TypeScript applications",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/superdurable/dex-connectors-library.git",
|
|
9
|
+
"directory": "connectors/aweber/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/accounts/worker.ts",
|
|
42
|
+
"example:start": "tsx examples/accounts/start.ts",
|
|
43
|
+
"check": "npm run typecheck && npm run lint && npm test && npm run build"
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@superdurable/connectors-sdk": "0.7.0",
|
|
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
|
+
}
|