@superdurable/connector-klaviyo 0.0.0-stage → 0.1.1
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 +15 -2
- package/dex-connector.json +121 -0
- package/dist/chunk-GC6YRQKN.js +155 -0
- package/dist/connection-BvS1Rfu-.d.ts +103 -0
- package/dist/index.d.ts +148 -0
- package/dist/index.js +313 -0
- package/dist/mock.d.ts +52 -0
- package/dist/mock.js +114 -0
- package/package.json +62 -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,16 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Klaviyo connector for TypeScript
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Install with `npm install @superdurable/connector-klaviyo@0.1.1`. This package implements `getProfile` and `createEvent` with generated operation-specific Step factories and the Go connector's branches.
|
|
4
|
+
|
|
5
|
+
| Operation | Factory | Happy branch | Optional branches |
|
|
6
|
+
| --- | --- | --- | --- |
|
|
7
|
+
| `getProfile` | `newGetProfileStep` | `found` | `notFound`, `providerRejected`, `invalidResponse`, `defect` |
|
|
8
|
+
| `createEvent` | `newCreateEventStep` | `accepted` | `providerRejected`, `defect` |
|
|
9
|
+
|
|
10
|
+
`createEvent` hashes Dex's stable call ID into the Klaviyo `unique_id`; retries use the same ID. HTTP 202 confirms acceptance for asynchronous processing. Both operations retry transport failures, 408, 409, 429, and 5xx; `createEvent` also retries every status other than 202 and a definite refusal (400, 401, 403, 404, 411, 413, 414, 415, 422). Missing, invalid, or malformed stored credentials select `defect`; 401 and 403 select `providerRejected`.
|
|
11
|
+
|
|
12
|
+
`getProfile` treats the profile ID as an opaque URL path segment. It percent-encodes punctuation such as commas, semicolons, and exclamation marks before sending the request.
|
|
13
|
+
|
|
14
|
+
Create the private API key through the [connector authorization guide](../README.md#authorization). The key is resolved on each attempt and sent only in the `Authorization` header.
|
|
15
|
+
|
|
16
|
+
The [runnable profile event example](examples/profile-event/README.md) binds the static `klaviyo-profile-events` connection. Run `npm run check` for package tests, type checking, and lint; run `npm run test:integration` against a local Dex CLI dev server. The Go-recorded provider scenarios replay through this package's conformance test.
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
{
|
|
2
|
+
"connectorId": "klaviyo",
|
|
3
|
+
"releaseTag": "connectors/klaviyo/go/v0.2.1",
|
|
4
|
+
"package": {
|
|
5
|
+
"ecosystem": "npm",
|
|
6
|
+
"name": "@superdurable/connector-klaviyo",
|
|
7
|
+
"version": "0.1.1"
|
|
8
|
+
},
|
|
9
|
+
"factories": [
|
|
10
|
+
{
|
|
11
|
+
"name": "newGetProfileStep",
|
|
12
|
+
"kind": "query",
|
|
13
|
+
"operationId": "getProfile",
|
|
14
|
+
"inputType": "GetProfileInput",
|
|
15
|
+
"description": "Get one profile by Klaviyo ID.",
|
|
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": "GetProfileInput identifies a Klaviyo profile.",
|
|
52
|
+
"properties": {
|
|
53
|
+
"id": {
|
|
54
|
+
"description": "ID is Klaviyo's opaque profile ID.",
|
|
55
|
+
"type": "string"
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
"required": [
|
|
59
|
+
"id"
|
|
60
|
+
],
|
|
61
|
+
"type": "object"
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"name": "newCreateEventStep",
|
|
66
|
+
"kind": "mutation",
|
|
67
|
+
"operationId": "createEvent",
|
|
68
|
+
"inputType": "CreateEventInput",
|
|
69
|
+
"description": "Submit a profile event with a unique_id derived from Dex's stable call identity.",
|
|
70
|
+
"fields": {
|
|
71
|
+
"stepType": "stepType",
|
|
72
|
+
"annotations": "annotations",
|
|
73
|
+
"connectionName": "connectionName",
|
|
74
|
+
"resultAttribute": "resultAttribute"
|
|
75
|
+
},
|
|
76
|
+
"branches": [
|
|
77
|
+
{
|
|
78
|
+
"id": "accepted",
|
|
79
|
+
"field": "accepted",
|
|
80
|
+
"optional": false
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"id": "providerRejected",
|
|
84
|
+
"field": "providerRejected",
|
|
85
|
+
"optional": true
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"id": "defect",
|
|
89
|
+
"field": "defect",
|
|
90
|
+
"optional": true
|
|
91
|
+
}
|
|
92
|
+
],
|
|
93
|
+
"inputSchema": {
|
|
94
|
+
"additionalProperties": false,
|
|
95
|
+
"description": "CreateEventInput associates one event with a profile email and metric.",
|
|
96
|
+
"properties": {
|
|
97
|
+
"email": {
|
|
98
|
+
"description": "Email identifies the profile. Klaviyo silently drops some test-domain events after accepting them.",
|
|
99
|
+
"type": "string"
|
|
100
|
+
},
|
|
101
|
+
"metricName": {
|
|
102
|
+
"description": "MetricName names the event metric.",
|
|
103
|
+
"type": "string"
|
|
104
|
+
},
|
|
105
|
+
"properties": {
|
|
106
|
+
"additionalProperties": {
|
|
107
|
+
"type": "string"
|
|
108
|
+
},
|
|
109
|
+
"description": "Properties contains optional non-secret string event properties.",
|
|
110
|
+
"type": "object"
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
"required": [
|
|
114
|
+
"email",
|
|
115
|
+
"metricName"
|
|
116
|
+
],
|
|
117
|
+
"type": "object"
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
]
|
|
121
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
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
|
+
var CredentialMaterialError = class extends TypeError {
|
|
10
|
+
constructor(message) {
|
|
11
|
+
super(message);
|
|
12
|
+
this.name = "CredentialMaterialError";
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
var sdkCredentialDecodingFailureMessages = /* @__PURE__ */ new Set([
|
|
16
|
+
"project credential decoding failed",
|
|
17
|
+
"shared project credential decoding failed",
|
|
18
|
+
"project credential decoding failed: this connector version does not support shared credentials"
|
|
19
|
+
]);
|
|
20
|
+
function isCredentialMaterialError(error) {
|
|
21
|
+
return error instanceof CredentialMaterialError || error instanceof TypeError && sdkCredentialDecodingFailureMessages.has(error.message);
|
|
22
|
+
}
|
|
23
|
+
function decodeCredentials(value) {
|
|
24
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) throw new CredentialMaterialError("credential fields are invalid");
|
|
25
|
+
const fields = value;
|
|
26
|
+
const allowed = /* @__PURE__ */ new Set(["private_api_key"]);
|
|
27
|
+
if (Object.keys(fields).some((key) => !allowed.has(key))) throw new CredentialMaterialError("stored credential does not match the connector credential fields");
|
|
28
|
+
if (fields["private_api_key"] != null && !(typeof fields["private_api_key"] === "string")) throw new CredentialMaterialError("credential private_api_key has an invalid type");
|
|
29
|
+
const credentials = {};
|
|
30
|
+
if (!fields["private_api_key"]) throw new CredentialMaterialError("credential private_api_key is required");
|
|
31
|
+
credentials.privateApiKey = new SecretString(fields["private_api_key"] ?? "");
|
|
32
|
+
return credentials;
|
|
33
|
+
}
|
|
34
|
+
var GetProfileInputSchema = z.strictObject({
|
|
35
|
+
"id": z.string()
|
|
36
|
+
});
|
|
37
|
+
var ProfileSchema = z.strictObject({
|
|
38
|
+
"id": z.string(),
|
|
39
|
+
"email": z.string().optional()
|
|
40
|
+
});
|
|
41
|
+
var CreateEventInputSchema = z.strictObject({
|
|
42
|
+
"email": z.string(),
|
|
43
|
+
"metricName": z.string(),
|
|
44
|
+
"properties": z.record(z.string(), z.string()).optional()
|
|
45
|
+
});
|
|
46
|
+
var EventAcceptanceSchema = z.strictObject({
|
|
47
|
+
"accepted": z.boolean()
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
// src/generated/definitions.ts
|
|
51
|
+
var ConnectorID = "klaviyo";
|
|
52
|
+
var ProviderID = "klaviyo";
|
|
53
|
+
var GetProfileBranch = {
|
|
54
|
+
Found: "found",
|
|
55
|
+
NotFound: "notFound",
|
|
56
|
+
ProviderRejected: "providerRejected",
|
|
57
|
+
InvalidResponse: "invalidResponse",
|
|
58
|
+
Defect: "defect"
|
|
59
|
+
};
|
|
60
|
+
var GetProfileBranchFound = GetProfileBranch.Found;
|
|
61
|
+
var GetProfileBranchNotFound = GetProfileBranch.NotFound;
|
|
62
|
+
var GetProfileBranchProviderRejected = GetProfileBranch.ProviderRejected;
|
|
63
|
+
var GetProfileBranchInvalidResponse = GetProfileBranch.InvalidResponse;
|
|
64
|
+
var GetProfileBranchDefect = GetProfileBranch.Defect;
|
|
65
|
+
var GetProfileDefinition = {
|
|
66
|
+
operation: { connectorId: ConnectorID, operationId: "getProfile" },
|
|
67
|
+
branches: [
|
|
68
|
+
{ id: "found", description: "Klaviyo returned the profile." },
|
|
69
|
+
{ id: "notFound", description: "No profile has that ID.", optional: true },
|
|
70
|
+
{ id: "providerRejected", description: "Klaviyo rejected the request or key.", optional: true },
|
|
71
|
+
{ id: "invalidResponse", description: "Klaviyo returned malformed or oversized data.", optional: true },
|
|
72
|
+
{ id: "defect", description: "Local input or credentials are invalid.", optional: true }
|
|
73
|
+
],
|
|
74
|
+
stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "async" }
|
|
75
|
+
};
|
|
76
|
+
var GetProfileMetadata = { kind: "query", idempotency: "none", authorization: "required" };
|
|
77
|
+
var CreateEventBranch = {
|
|
78
|
+
Accepted: "accepted",
|
|
79
|
+
ProviderRejected: "providerRejected",
|
|
80
|
+
Defect: "defect"
|
|
81
|
+
};
|
|
82
|
+
var CreateEventBranchAccepted = CreateEventBranch.Accepted;
|
|
83
|
+
var CreateEventBranchProviderRejected = CreateEventBranch.ProviderRejected;
|
|
84
|
+
var CreateEventBranchDefect = CreateEventBranch.Defect;
|
|
85
|
+
var CreateEventDefinition = {
|
|
86
|
+
operation: { connectorId: ConnectorID, operationId: "createEvent" },
|
|
87
|
+
branches: [
|
|
88
|
+
{ id: "accepted", description: "Klaviyo accepted the deduplicated event for asynchronous processing." },
|
|
89
|
+
{ id: "providerRejected", description: "Klaviyo rejected the event or key.", optional: true },
|
|
90
|
+
{ id: "defect", description: "Local input or credentials are invalid.", optional: true }
|
|
91
|
+
],
|
|
92
|
+
stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "async" }
|
|
93
|
+
};
|
|
94
|
+
var CreateEventMetadata = { kind: "mutation", idempotency: "required", authorization: "required" };
|
|
95
|
+
|
|
96
|
+
// src/generated/connection.ts
|
|
97
|
+
import { ConnectionRefSchema } from "@superdurable/connectors-sdk";
|
|
98
|
+
var Connection = class {
|
|
99
|
+
/** Stable provider and connection name. */
|
|
100
|
+
reference;
|
|
101
|
+
/** Bound provider operations. */
|
|
102
|
+
operations;
|
|
103
|
+
/** Validate a reference and bind operations. */
|
|
104
|
+
constructor(reference, operations) {
|
|
105
|
+
this.reference = ConnectionRefSchema.parse(reference);
|
|
106
|
+
if (this.reference.provider !== ProviderID) throw new TypeError("connection provider differs from the manifest");
|
|
107
|
+
if (!operations) throw new TypeError("connector operations are required");
|
|
108
|
+
this.operations = operations;
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
function newConnection(client, reference) {
|
|
112
|
+
if (!client) throw new TypeError("connector client is required");
|
|
113
|
+
return new Connection(reference, client);
|
|
114
|
+
}
|
|
115
|
+
function newConnectionWithOperations(operations, reference) {
|
|
116
|
+
return new Connection(reference, operations);
|
|
117
|
+
}
|
|
118
|
+
function newProjectConnection(project, connectionName, createClient) {
|
|
119
|
+
if (!project) throw new TypeError("loaded project is required");
|
|
120
|
+
const reference = ConnectionRefSchema.parse({ provider: ProviderID, name: connectionName });
|
|
121
|
+
const selected = project.configuration.connections.find((entry) => entry.connectorId === ConnectorID && entry.connectionName === connectionName);
|
|
122
|
+
if (!selected || selected.provider !== ProviderID) throw new TypeError("project connection is not configured");
|
|
123
|
+
return newConnection(createClient(project, connectionName), reference);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export {
|
|
127
|
+
ConfigSchema,
|
|
128
|
+
CredentialMaterialError,
|
|
129
|
+
isCredentialMaterialError,
|
|
130
|
+
decodeCredentials,
|
|
131
|
+
GetProfileInputSchema,
|
|
132
|
+
ProfileSchema,
|
|
133
|
+
CreateEventInputSchema,
|
|
134
|
+
EventAcceptanceSchema,
|
|
135
|
+
ConnectorID,
|
|
136
|
+
ProviderID,
|
|
137
|
+
GetProfileBranch,
|
|
138
|
+
GetProfileBranchFound,
|
|
139
|
+
GetProfileBranchNotFound,
|
|
140
|
+
GetProfileBranchProviderRejected,
|
|
141
|
+
GetProfileBranchInvalidResponse,
|
|
142
|
+
GetProfileBranchDefect,
|
|
143
|
+
GetProfileDefinition,
|
|
144
|
+
GetProfileMetadata,
|
|
145
|
+
CreateEventBranch,
|
|
146
|
+
CreateEventBranchAccepted,
|
|
147
|
+
CreateEventBranchProviderRejected,
|
|
148
|
+
CreateEventBranchDefect,
|
|
149
|
+
CreateEventDefinition,
|
|
150
|
+
CreateEventMetadata,
|
|
151
|
+
Connection,
|
|
152
|
+
newConnection,
|
|
153
|
+
newConnectionWithOperations,
|
|
154
|
+
newProjectConnection
|
|
155
|
+
};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { SecretString, CredentialProvider, Query, Mutation, ConnectionRef } from '@superdurable/connectors-sdk';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
/** Connector configuration; omitted fields use manifest defaults. */
|
|
5
|
+
interface Config {
|
|
6
|
+
/** Klaviyo REST API base URL; leave blank for the public endpoint, or enter a compatible HTTPS gateway URL for a custom deployment. */
|
|
7
|
+
baseUrl?: string;
|
|
8
|
+
/** Positive Go duration limiting each HTTP request; leave blank for the displayed default, or override for a slower network. Runtime value in milliseconds. */
|
|
9
|
+
timeoutMs?: number;
|
|
10
|
+
/** Maximum response bytes as a positive integer; leave blank for the displayed safety limit, or raise it for larger profiles. */
|
|
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 Klaviyo private API key starting pk_ from https://www.klaviyo.com/settings/account/api-keys after Settings > API keys > Create Private API Key; grant profiles:read and events:write. Blank prevents requests. */
|
|
22
|
+
privateApiKey: SecretString;
|
|
23
|
+
}
|
|
24
|
+
/** Stored credential material that fails the connector credential checks, so no retry can succeed. */
|
|
25
|
+
declare class CredentialMaterialError extends TypeError {
|
|
26
|
+
constructor(message: string);
|
|
27
|
+
}
|
|
28
|
+
/** Report malformed stored credential material, also behind the SDK provider's decoding TypeError. */
|
|
29
|
+
declare function isCredentialMaterialError(error: unknown): boolean;
|
|
30
|
+
/** Decode private credential fields for the connector. */
|
|
31
|
+
declare function decodeCredentials(value: unknown): Credentials;
|
|
32
|
+
/** Host-owned source of private connector credentials. */
|
|
33
|
+
type CredentialSource = CredentialProvider<Credentials>;
|
|
34
|
+
/** GetProfileInput identifies a Klaviyo profile. */
|
|
35
|
+
interface GetProfileInput {
|
|
36
|
+
/** ID is Klaviyo's opaque profile ID. */
|
|
37
|
+
"id": string;
|
|
38
|
+
}
|
|
39
|
+
/** Profile contains the identity fields returned for a Klaviyo profile. */
|
|
40
|
+
interface Profile {
|
|
41
|
+
/** ID is Klaviyo's opaque profile ID. */
|
|
42
|
+
"id": string;
|
|
43
|
+
/** Email is the profile's email address, when present. */
|
|
44
|
+
"email"?: string | undefined;
|
|
45
|
+
}
|
|
46
|
+
/** CreateEventInput associates one event with a profile email and metric. */
|
|
47
|
+
interface CreateEventInput {
|
|
48
|
+
/** Email identifies the profile. Klaviyo silently drops some test-domain events after accepting them. */
|
|
49
|
+
"email": string;
|
|
50
|
+
/** MetricName names the event metric. */
|
|
51
|
+
"metricName": string;
|
|
52
|
+
/** Properties contains optional non-secret string event properties. */
|
|
53
|
+
"properties"?: {
|
|
54
|
+
[key: string]: string;
|
|
55
|
+
} | undefined;
|
|
56
|
+
}
|
|
57
|
+
/** EventAcceptance confirms submission, not completion of asynchronous processing. */
|
|
58
|
+
interface EventAcceptance {
|
|
59
|
+
/** Accepted means Klaviyo returned HTTP 202. */
|
|
60
|
+
"accepted": boolean;
|
|
61
|
+
}
|
|
62
|
+
/** Runtime validator for GetProfileInput. */
|
|
63
|
+
declare const GetProfileInputSchema: z.ZodObject<{
|
|
64
|
+
id: z.ZodString;
|
|
65
|
+
}, z.core.$strict>;
|
|
66
|
+
/** Runtime validator for Profile. */
|
|
67
|
+
declare const ProfileSchema: z.ZodObject<{
|
|
68
|
+
id: z.ZodString;
|
|
69
|
+
email: z.ZodOptional<z.ZodString>;
|
|
70
|
+
}, z.core.$strict>;
|
|
71
|
+
/** Runtime validator for CreateEventInput. */
|
|
72
|
+
declare const CreateEventInputSchema: z.ZodObject<{
|
|
73
|
+
email: z.ZodString;
|
|
74
|
+
metricName: z.ZodString;
|
|
75
|
+
properties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
76
|
+
}, z.core.$strict>;
|
|
77
|
+
/** Runtime validator for EventAcceptance. */
|
|
78
|
+
declare const EventAcceptanceSchema: z.ZodObject<{
|
|
79
|
+
accepted: z.ZodBoolean;
|
|
80
|
+
}, z.core.$strict>;
|
|
81
|
+
|
|
82
|
+
/** Typed operations supplied by a client or mock. */
|
|
83
|
+
interface Operations {
|
|
84
|
+
/** Invoke getProfile through this connection. */
|
|
85
|
+
getProfile(): Query<GetProfileInput, Profile>;
|
|
86
|
+
/** Invoke createEvent through this connection. */
|
|
87
|
+
createEvent(): Mutation<CreateEventInput, EventAcceptance>;
|
|
88
|
+
}
|
|
89
|
+
/** Named connector connection kept outside Flow state. */
|
|
90
|
+
declare class Connection<BoundOperations = Operations> {
|
|
91
|
+
/** Stable provider and connection name. */
|
|
92
|
+
readonly reference: ConnectionRef;
|
|
93
|
+
/** Bound provider operations. */
|
|
94
|
+
readonly operations: BoundOperations;
|
|
95
|
+
/** Validate a reference and bind operations. */
|
|
96
|
+
constructor(reference: ConnectionRef, operations: BoundOperations);
|
|
97
|
+
}
|
|
98
|
+
/** Bind a client to a named connection. */
|
|
99
|
+
declare function newConnection(client: Operations, reference: ConnectionRef): Connection;
|
|
100
|
+
/** Bind scripted operations to a named connection. */
|
|
101
|
+
declare function newConnectionWithOperations(operations: Operations, reference: ConnectionRef): Connection;
|
|
102
|
+
|
|
103
|
+
export { type CreateEventInput as C, type EventAcceptance as E, type GetProfileInput as G, type Operations as O, type Profile as P, Connection as a, type Config as b, type Credentials as c, ConfigSchema as d, CreateEventInputSchema as e, CredentialMaterialError as f, type CredentialSource as g, EventAcceptanceSchema as h, GetProfileInputSchema as i, ProfileSchema as j, decodeCredentials as k, isCredentialMaterialError as l, newConnectionWithOperations as m, newConnection as n };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { C as CreateEventInput, E as EventAcceptance, a as Connection, G as GetProfileInput, P as Profile, O as Operations, b as Config, c as Credentials } from './connection-BvS1Rfu-.js';
|
|
2
|
+
export { d as ConfigSchema, e as CreateEventInputSchema, f as CredentialMaterialError, g as CredentialSource, h as EventAcceptanceSchema, i as GetProfileInputSchema, j as ProfileSchema, k as decodeCredentials, l as isCredentialMaterialError, n as newConnection, m as newConnectionWithOperations } from './connection-BvS1Rfu-.js';
|
|
3
|
+
import * as _superdurable_connectors_sdk from '@superdurable/connectors-sdk';
|
|
4
|
+
import { MutationDefinition, QueryDefinition, MutationStepConfig, Mutation, MutationResult, QueryStepConfig, Query, QueryResult, MutationStep, QueryStep, Call, QueryAttempt, MutationAttempt, CredentialProvider } from '@superdurable/connectors-sdk';
|
|
5
|
+
import { StepTarget } from '@superdurable/dex';
|
|
6
|
+
import { LoadedProject } from '@superdurable/connectors-sdk/projectconfig';
|
|
7
|
+
import { ProviderRequest, ProviderResponse } from '@superdurable/connectors-sdk/providerhttp';
|
|
8
|
+
import 'zod';
|
|
9
|
+
|
|
10
|
+
/** Stable connector identity. */
|
|
11
|
+
declare const ConnectorID = "klaviyo";
|
|
12
|
+
/** Provider identity for named connections. */
|
|
13
|
+
declare const ProviderID = "klaviyo";
|
|
14
|
+
/** Branch IDs for getProfile. */
|
|
15
|
+
declare const GetProfileBranch: {
|
|
16
|
+
readonly Found: "found";
|
|
17
|
+
readonly NotFound: "notFound";
|
|
18
|
+
readonly ProviderRejected: "providerRejected";
|
|
19
|
+
readonly InvalidResponse: "invalidResponse";
|
|
20
|
+
readonly Defect: "defect";
|
|
21
|
+
};
|
|
22
|
+
/** Klaviyo returned the profile. */
|
|
23
|
+
declare const GetProfileBranchFound: "found";
|
|
24
|
+
/** No profile has that ID. */
|
|
25
|
+
declare const GetProfileBranchNotFound: "notFound";
|
|
26
|
+
/** Klaviyo rejected the request or key. */
|
|
27
|
+
declare const GetProfileBranchProviderRejected: "providerRejected";
|
|
28
|
+
/** Klaviyo returned malformed or oversized data. */
|
|
29
|
+
declare const GetProfileBranchInvalidResponse: "invalidResponse";
|
|
30
|
+
/** Local input or credentials are invalid. */
|
|
31
|
+
declare const GetProfileBranchDefect: "defect";
|
|
32
|
+
/** Manifest definition for getProfile. */
|
|
33
|
+
declare const GetProfileDefinition: QueryDefinition;
|
|
34
|
+
/** Manifest metadata for getProfile. */
|
|
35
|
+
declare const GetProfileMetadata: {
|
|
36
|
+
readonly kind: "query";
|
|
37
|
+
readonly idempotency: "none";
|
|
38
|
+
readonly authorization: "required";
|
|
39
|
+
};
|
|
40
|
+
/** Branch IDs for createEvent. */
|
|
41
|
+
declare const CreateEventBranch: {
|
|
42
|
+
readonly Accepted: "accepted";
|
|
43
|
+
readonly ProviderRejected: "providerRejected";
|
|
44
|
+
readonly Defect: "defect";
|
|
45
|
+
};
|
|
46
|
+
/** Klaviyo accepted the deduplicated event for asynchronous processing. */
|
|
47
|
+
declare const CreateEventBranchAccepted: "accepted";
|
|
48
|
+
/** Klaviyo rejected the event or key. */
|
|
49
|
+
declare const CreateEventBranchProviderRejected: "providerRejected";
|
|
50
|
+
/** Local input or credentials are invalid. */
|
|
51
|
+
declare const CreateEventBranchDefect: "defect";
|
|
52
|
+
/** Manifest definition for createEvent. */
|
|
53
|
+
declare const CreateEventDefinition: MutationDefinition;
|
|
54
|
+
/** Manifest metadata for createEvent. */
|
|
55
|
+
declare const CreateEventMetadata: {
|
|
56
|
+
readonly kind: "mutation";
|
|
57
|
+
readonly idempotency: "required";
|
|
58
|
+
readonly authorization: "required";
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
/** Configuration for the getProfile connector Step. */
|
|
62
|
+
interface GetProfileStepConfig<StepInput, OperationInput = GetProfileInput, OperationOutput = Profile> extends Omit<QueryStepConfig<StepInput, OperationInput, OperationOutput>, 'operation' | 'connection' | 'branches'> {
|
|
63
|
+
/** Named connection supplying this operation. */
|
|
64
|
+
connection: Connection<{
|
|
65
|
+
getProfile(): Query<OperationInput, OperationOutput>;
|
|
66
|
+
}>;
|
|
67
|
+
/** Name matching the bound connection. */
|
|
68
|
+
connectionName: string;
|
|
69
|
+
/** Klaviyo returned the profile. */
|
|
70
|
+
found: StepTarget<QueryResult<OperationOutput>>;
|
|
71
|
+
/** No profile has that ID. */
|
|
72
|
+
notFound?: StepTarget<QueryResult<OperationOutput>>;
|
|
73
|
+
/** Klaviyo rejected the request or key. */
|
|
74
|
+
providerRejected?: StepTarget<QueryResult<OperationOutput>>;
|
|
75
|
+
/** Klaviyo returned malformed or oversized data. */
|
|
76
|
+
invalidResponse?: StepTarget<QueryResult<OperationOutput>>;
|
|
77
|
+
/** Local input or credentials are invalid. */
|
|
78
|
+
defect?: StepTarget<QueryResult<OperationOutput>>;
|
|
79
|
+
}
|
|
80
|
+
/** Build the getProfile Step from a named connection. */
|
|
81
|
+
declare function newGetProfileStep<StepInput, OperationInput = GetProfileInput, OperationOutput = Profile>(configuration: GetProfileStepConfig<StepInput, OperationInput, OperationOutput>): QueryStep<StepInput, OperationInput, OperationOutput>;
|
|
82
|
+
/** Configuration for the createEvent connector Step. */
|
|
83
|
+
interface CreateEventStepConfig<StepInput, OperationInput = CreateEventInput, OperationOutput = EventAcceptance> extends Omit<MutationStepConfig<StepInput, OperationInput, OperationOutput>, 'operation' | 'connection' | 'branches'> {
|
|
84
|
+
/** Named connection supplying this operation. */
|
|
85
|
+
connection: Connection<{
|
|
86
|
+
createEvent(): Mutation<OperationInput, OperationOutput>;
|
|
87
|
+
}>;
|
|
88
|
+
/** Name matching the bound connection. */
|
|
89
|
+
connectionName: string;
|
|
90
|
+
/** Klaviyo accepted the deduplicated event for asynchronous processing. */
|
|
91
|
+
accepted: StepTarget<MutationResult<OperationOutput>>;
|
|
92
|
+
/** Klaviyo rejected the event or key. */
|
|
93
|
+
providerRejected?: StepTarget<MutationResult<OperationOutput>>;
|
|
94
|
+
/** Local input or credentials are invalid. */
|
|
95
|
+
defect?: StepTarget<MutationResult<OperationOutput>>;
|
|
96
|
+
}
|
|
97
|
+
/** Build the createEvent Step from a named connection. */
|
|
98
|
+
declare function newCreateEventStep<StepInput, OperationInput = CreateEventInput, OperationOutput = EventAcceptance>(configuration: CreateEventStepConfig<StepInput, OperationInput, OperationOutput>): MutationStep<StepInput, OperationInput, OperationOutput>;
|
|
99
|
+
|
|
100
|
+
/** Open a static Klaviyo connection declared in a Dex project. */
|
|
101
|
+
declare function newProjectConnection(project: LoadedProject, connectionName: string): Connection<Operations>;
|
|
102
|
+
|
|
103
|
+
/** Read a profile by its opaque Klaviyo ID. */
|
|
104
|
+
declare class GetProfileOperation implements Query<GetProfileInput, Profile> {
|
|
105
|
+
private readonly client;
|
|
106
|
+
/** Bind an authenticated client. */ constructor(client: KlaviyoClient);
|
|
107
|
+
/** Return generated manifest metadata. */ definition(): _superdurable_connectors_sdk.QueryDefinition;
|
|
108
|
+
/** Validate, send, and classify one lookup attempt. */
|
|
109
|
+
invoke(call: Call, input: GetProfileInput): Promise<QueryAttempt<Profile>>;
|
|
110
|
+
}
|
|
111
|
+
/** Submit one deduplicated Klaviyo event. */
|
|
112
|
+
declare class CreateEventOperation implements Mutation<CreateEventInput, EventAcceptance> {
|
|
113
|
+
private readonly client;
|
|
114
|
+
/** Bind an authenticated client. */ constructor(client: KlaviyoClient);
|
|
115
|
+
/** Return generated manifest metadata. */ definition(): _superdurable_connectors_sdk.QueryDefinition;
|
|
116
|
+
/** Derive the provider unique ID from Dex's stable Call ID. */ idempotencyKey(callId: string): string;
|
|
117
|
+
/** Validate, send, and classify one event submission attempt. */
|
|
118
|
+
invoke(call: Call, input: CreateEventInput): Promise<MutationAttempt<EventAcceptance>>;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** Injectable sender for provider replay and local integration tests. */
|
|
122
|
+
type KlaviyoRequestSender = (request: ProviderRequest) => Promise<ProviderResponse>;
|
|
123
|
+
/** Optional request transport and clock dependencies. */
|
|
124
|
+
interface KlaviyoClientOptions {
|
|
125
|
+
/** Replaces the production HTTP transport for tests. */
|
|
126
|
+
send?: KlaviyoRequestSender;
|
|
127
|
+
/** Supplies the clock for Retry-After parsing. */
|
|
128
|
+
now?: () => Date;
|
|
129
|
+
}
|
|
130
|
+
/** One authenticated Klaviyo API client. */
|
|
131
|
+
declare class KlaviyoClient {
|
|
132
|
+
private readonly credentials;
|
|
133
|
+
private readonly baseUrl;
|
|
134
|
+
private readonly timeoutMs;
|
|
135
|
+
private readonly maxResponseBytes;
|
|
136
|
+
private readonly send;
|
|
137
|
+
readonly now: () => Date;
|
|
138
|
+
/** Validate configuration and retain a call-time credential source. */
|
|
139
|
+
constructor(config: Config, credentials: CredentialProvider<Credentials>, options?: KlaviyoClientOptions);
|
|
140
|
+
/** Bind a profile lookup. */
|
|
141
|
+
getProfile(): GetProfileOperation;
|
|
142
|
+
/** Bind an event submission. */
|
|
143
|
+
createEvent(): CreateEventOperation;
|
|
144
|
+
/** Send one authenticated request, preserving transport and body-limit failures for classification. */
|
|
145
|
+
request(call: Call, method: 'GET' | 'POST', path: string, body?: Uint8Array): Promise<ProviderResponse>;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export { Config, Connection, ConnectorID, CreateEventBranch, CreateEventBranchAccepted, CreateEventBranchDefect, CreateEventBranchProviderRejected, CreateEventDefinition, CreateEventInput, CreateEventMetadata, CreateEventOperation, type CreateEventStepConfig, Credentials, EventAcceptance, GetProfileBranch, GetProfileBranchDefect, GetProfileBranchFound, GetProfileBranchInvalidResponse, GetProfileBranchNotFound, GetProfileBranchProviderRejected, GetProfileDefinition, GetProfileInput, GetProfileMetadata, GetProfileOperation, type GetProfileStepConfig, KlaviyoClient, type KlaviyoClientOptions, type KlaviyoRequestSender, Profile, ProviderID, newCreateEventStep, newGetProfileStep, newProjectConnection };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ConfigSchema,
|
|
3
|
+
Connection,
|
|
4
|
+
ConnectorID,
|
|
5
|
+
CreateEventBranch,
|
|
6
|
+
CreateEventBranchAccepted,
|
|
7
|
+
CreateEventBranchDefect,
|
|
8
|
+
CreateEventBranchProviderRejected,
|
|
9
|
+
CreateEventDefinition,
|
|
10
|
+
CreateEventInputSchema,
|
|
11
|
+
CreateEventMetadata,
|
|
12
|
+
CredentialMaterialError,
|
|
13
|
+
EventAcceptanceSchema,
|
|
14
|
+
GetProfileBranch,
|
|
15
|
+
GetProfileBranchDefect,
|
|
16
|
+
GetProfileBranchFound,
|
|
17
|
+
GetProfileBranchInvalidResponse,
|
|
18
|
+
GetProfileBranchNotFound,
|
|
19
|
+
GetProfileBranchProviderRejected,
|
|
20
|
+
GetProfileDefinition,
|
|
21
|
+
GetProfileInputSchema,
|
|
22
|
+
GetProfileMetadata,
|
|
23
|
+
ProfileSchema,
|
|
24
|
+
ProviderID,
|
|
25
|
+
decodeCredentials,
|
|
26
|
+
isCredentialMaterialError,
|
|
27
|
+
newConnection,
|
|
28
|
+
newConnectionWithOperations,
|
|
29
|
+
newProjectConnection
|
|
30
|
+
} from "./chunk-GC6YRQKN.js";
|
|
31
|
+
|
|
32
|
+
// src/generated/steps.ts
|
|
33
|
+
import { goToBranch, newMutationStep, newQueryStep } from "@superdurable/connectors-sdk";
|
|
34
|
+
function newGetProfileStep(configuration) {
|
|
35
|
+
const { connection, connectionName, found, notFound, providerRejected, invalidResponse, defect, ...stepConfiguration } = configuration;
|
|
36
|
+
if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
|
|
37
|
+
return newQueryStep({ ...stepConfiguration, operation: connection.operations.getProfile(), connection: connection.reference, branches: [
|
|
38
|
+
goToBranch("found", found),
|
|
39
|
+
...notFound ? [goToBranch("notFound", notFound)] : [],
|
|
40
|
+
...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
|
|
41
|
+
...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
|
|
42
|
+
...defect ? [goToBranch("defect", defect)] : []
|
|
43
|
+
] });
|
|
44
|
+
}
|
|
45
|
+
function newCreateEventStep(configuration) {
|
|
46
|
+
const { connection, connectionName, accepted, providerRejected, defect, ...stepConfiguration } = configuration;
|
|
47
|
+
if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
|
|
48
|
+
return newMutationStep({ ...stepConfiguration, operation: connection.operations.createEvent(), connection: connection.reference, branches: [
|
|
49
|
+
goToBranch("accepted", accepted),
|
|
50
|
+
...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
|
|
51
|
+
...defect ? [goToBranch("defect", defect)] : []
|
|
52
|
+
] });
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// src/project.ts
|
|
56
|
+
import { SecretString as SecretString2 } from "@superdurable/connectors-sdk";
|
|
57
|
+
import { z as z2 } from "zod";
|
|
58
|
+
|
|
59
|
+
// src/client.ts
|
|
60
|
+
import { isHeaderSafeCredential, sendProviderRequest, validateBaseURL } from "@superdurable/connectors-sdk/providerhttp";
|
|
61
|
+
import { ReauthorizationRequiredError, SecretString } from "@superdurable/connectors-sdk";
|
|
62
|
+
import { ConnectionNotSelectedError, CredentialBrokerRejectedError, ObjectNotFoundError } from "@superdurable/connectors-sdk/projectconfig";
|
|
63
|
+
import { z } from "zod";
|
|
64
|
+
|
|
65
|
+
// src/operations.ts
|
|
66
|
+
import { createHash } from "crypto";
|
|
67
|
+
import { newMutationBranch, newMutationRetry, newQueryBranch, newQueryRetry } from "@superdurable/connectors-sdk";
|
|
68
|
+
import { BodyTooLargeError, parseRetryAfter } from "@superdurable/connectors-sdk/providerhttp";
|
|
69
|
+
var emptyProfile = { id: "" };
|
|
70
|
+
var emptyAcceptance = { accepted: false };
|
|
71
|
+
function failure(operation, kind, message) {
|
|
72
|
+
return { kind, provider: "klaviyo", operation, message };
|
|
73
|
+
}
|
|
74
|
+
function queryFailure(branch, kind, message) {
|
|
75
|
+
return newQueryBranch(branch, emptyProfile, {}, failure("getProfile", kind, message));
|
|
76
|
+
}
|
|
77
|
+
function mutationFailure(branch, kind, message) {
|
|
78
|
+
return newMutationBranch(branch, emptyAcceptance, {}, failure("createEvent", kind, message));
|
|
79
|
+
}
|
|
80
|
+
function isRetryStatus(status) {
|
|
81
|
+
return status === 408 || status === 409 || status === 429 || status >= 500;
|
|
82
|
+
}
|
|
83
|
+
function rejectionKind(status) {
|
|
84
|
+
return status === 401 ? "AUTHENTICATION" : status === 403 ? "AUTHORIZATION" : "PROVIDER_REJECTION";
|
|
85
|
+
}
|
|
86
|
+
function retryHeader(headers) {
|
|
87
|
+
const value = headers["retry-after"];
|
|
88
|
+
return Array.isArray(value) ? String(value[0] ?? "") : typeof value === "string" ? value : "";
|
|
89
|
+
}
|
|
90
|
+
function pathEscape(value) {
|
|
91
|
+
return Buffer.from(value, "utf8").reduce((result, byte) => result + (/[A-Za-z0-9\-._~$&+=:@]/.test(String.fromCharCode(byte)) ? String.fromCharCode(byte) : `%${byte.toString(16).toUpperCase().padStart(2, "0")}`), "");
|
|
92
|
+
}
|
|
93
|
+
function validEmail(value) {
|
|
94
|
+
const atom = "[A-Za-z0-9!#$%&'*+/=?^_`{|}~\\-\\p{L}\\p{N}\\p{M}\\p{S}]+";
|
|
95
|
+
return new RegExp(`^${atom}(?:\\.${atom})*@(?:${atom}(?:\\.${atom})*|\\[[0-9]+(?:\\.[0-9]+){3}\\])$`, "u").test(value);
|
|
96
|
+
}
|
|
97
|
+
var GetProfileOperation = class {
|
|
98
|
+
/** Bind an authenticated client. */
|
|
99
|
+
constructor(client) {
|
|
100
|
+
this.client = client;
|
|
101
|
+
}
|
|
102
|
+
client;
|
|
103
|
+
/** Return generated manifest metadata. */
|
|
104
|
+
definition() {
|
|
105
|
+
return GetProfileDefinition;
|
|
106
|
+
}
|
|
107
|
+
/** Validate, send, and classify one lookup attempt. */
|
|
108
|
+
async invoke(call, input) {
|
|
109
|
+
if (!input.id.trim() || /[/?&#]/.test(input.id)) return queryFailure("defect", "VALIDATION", "profile ID is invalid");
|
|
110
|
+
let response;
|
|
111
|
+
try {
|
|
112
|
+
response = await this.client.request(call, "GET", `/profiles/${pathEscape(input.id)}`);
|
|
113
|
+
} catch (error) {
|
|
114
|
+
if (error instanceof UnavailableKlaviyoCredentialError) return newQueryRetry(failure("getProfile", "AVAILABILITY", error.message));
|
|
115
|
+
if (error instanceof InvalidKlaviyoCredentialError) return queryFailure("defect", "AUTHENTICATION", "Klaviyo credentials are unavailable or invalid");
|
|
116
|
+
if (error instanceof BodyTooLargeError && error.status !== void 0) {
|
|
117
|
+
if (isRetryStatus(error.status)) return newQueryRetry(failure("getProfile", "AVAILABILITY", "Klaviyo profile lookup is temporarily unavailable"), parseRetryAfter(retryHeader(error.headers ?? {}), this.client.now()));
|
|
118
|
+
if (error.status === 404) return queryFailure("notFound", "NOT_FOUND", "Klaviyo profile was not found");
|
|
119
|
+
if (error.status !== 200) return queryFailure("providerRejected", rejectionKind(error.status), `Klaviyo rejected profile lookup with HTTP ${error.status}`);
|
|
120
|
+
return queryFailure("invalidResponse", "RESPONSE_TOO_LARGE", "Klaviyo profile response exceeded the limit");
|
|
121
|
+
}
|
|
122
|
+
return newQueryRetry(failure("getProfile", "TRANSPORT", "Klaviyo profile response is unavailable"));
|
|
123
|
+
}
|
|
124
|
+
if (isRetryStatus(response.status)) return newQueryRetry(failure("getProfile", "AVAILABILITY", "Klaviyo profile lookup is temporarily unavailable"), parseRetryAfter(retryHeader(response.headers), this.client.now()));
|
|
125
|
+
if (response.status === 404) return queryFailure("notFound", "NOT_FOUND", "Klaviyo profile was not found");
|
|
126
|
+
if (response.status !== 200) return queryFailure("providerRejected", rejectionKind(response.status), `Klaviyo rejected profile lookup with HTTP ${response.status}`);
|
|
127
|
+
try {
|
|
128
|
+
const wire = JSON.parse(Buffer.from(response.body).toString("utf8"));
|
|
129
|
+
if (!wire || typeof wire !== "object" || !("data" in wire) || !wire.data || typeof wire.data !== "object") throw new Error("invalid profile");
|
|
130
|
+
const data = wire.data;
|
|
131
|
+
if (data.type !== "profile" || typeof data.id !== "string" || !data.id) throw new Error("invalid profile");
|
|
132
|
+
const attributes = data.attributes && typeof data.attributes === "object" ? data.attributes : {};
|
|
133
|
+
return newQueryBranch("found", { id: data.id, ...typeof attributes.email === "string" && attributes.email ? { email: attributes.email } : {} });
|
|
134
|
+
} catch {
|
|
135
|
+
return queryFailure("invalidResponse", "PROTOCOL", "Klaviyo returned an invalid profile");
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
var CreateEventOperation = class {
|
|
140
|
+
/** Bind an authenticated client. */
|
|
141
|
+
constructor(client) {
|
|
142
|
+
this.client = client;
|
|
143
|
+
}
|
|
144
|
+
client;
|
|
145
|
+
/** Return generated manifest metadata. */
|
|
146
|
+
definition() {
|
|
147
|
+
return CreateEventDefinition;
|
|
148
|
+
}
|
|
149
|
+
/** Derive the provider unique ID from Dex's stable Call ID. */
|
|
150
|
+
idempotencyKey(callId) {
|
|
151
|
+
return createHash("sha256").update(callId).digest("hex");
|
|
152
|
+
}
|
|
153
|
+
/** Validate, send, and classify one event submission attempt. */
|
|
154
|
+
async invoke(call, input) {
|
|
155
|
+
if (!validEmail(input.email) || !input.metricName.trim() || !call.idempotencyKey) return mutationFailure("defect", "VALIDATION", "email, metric name, and stable call identity are required");
|
|
156
|
+
const payload = Buffer.from(JSON.stringify({ data: { type: "event", attributes: { properties: input.properties ?? null, metric: { data: { type: "metric", attributes: { name: input.metricName } } }, profile: { data: { type: "profile", attributes: { email: input.email } } }, unique_id: call.idempotencyKey } } }), "utf8");
|
|
157
|
+
if (payload.length > 1 << 20) return mutationFailure("defect", "VALIDATION", "event payload is invalid or too large");
|
|
158
|
+
let response;
|
|
159
|
+
try {
|
|
160
|
+
response = await this.client.request(call, "POST", "/events", payload);
|
|
161
|
+
} catch (error) {
|
|
162
|
+
if (error instanceof UnavailableKlaviyoCredentialError) return newMutationRetry(failure("createEvent", "AVAILABILITY", `${error.message}; nothing was sent`));
|
|
163
|
+
if (error instanceof InvalidKlaviyoCredentialError) return mutationFailure("defect", "AUTHENTICATION", "Klaviyo credentials are unavailable or invalid");
|
|
164
|
+
if (error instanceof BodyTooLargeError && error.status !== void 0) {
|
|
165
|
+
if (isRetryStatus(error.status)) return newMutationRetry(failure("createEvent", "AVAILABILITY", "Klaviyo event submission is temporarily unavailable"), parseRetryAfter(retryHeader(error.headers ?? {}), this.client.now()));
|
|
166
|
+
if (error.status === 202) return newMutationBranch("accepted", { accepted: true });
|
|
167
|
+
return unknownEventOutcome(error.status);
|
|
168
|
+
}
|
|
169
|
+
return newMutationRetry(failure("createEvent", "TRANSPORT", "Klaviyo event response is unavailable"));
|
|
170
|
+
}
|
|
171
|
+
if (isRetryStatus(response.status)) return newMutationRetry(failure("createEvent", "AVAILABILITY", "Klaviyo event submission is temporarily unavailable"), parseRetryAfter(retryHeader(response.headers), this.client.now()));
|
|
172
|
+
if (response.status === 202) return newMutationBranch("accepted", { accepted: true });
|
|
173
|
+
if (!definiteRefusalStatuses.has(response.status)) return unknownEventOutcome(response.status);
|
|
174
|
+
return mutationFailure("providerRejected", rejectionKind(response.status), `Klaviyo rejected event submission with HTTP ${response.status}`);
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
var definiteRefusalStatuses = /* @__PURE__ */ new Set([400, 401, 403, 404, 411, 413, 414, 415, 422]);
|
|
178
|
+
function unknownEventOutcome(status) {
|
|
179
|
+
return newMutationRetry(failure("createEvent", "AVAILABILITY", `Klaviyo answered event submission with HTTP ${status}, so its outcome is unknown`));
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// src/client.ts
|
|
183
|
+
var defaultBaseUrl = "https://a.klaviyo.com/api";
|
|
184
|
+
var KlaviyoClient = class {
|
|
185
|
+
/** Validate configuration and retain a call-time credential source. */
|
|
186
|
+
constructor(config, credentials, options = {}) {
|
|
187
|
+
this.credentials = credentials;
|
|
188
|
+
if (!credentials) throw new TypeError("Klaviyo credential source is required");
|
|
189
|
+
this.baseUrl = validateBaseURL(config.baseUrl || defaultBaseUrl);
|
|
190
|
+
this.timeoutMs = config.timeoutMs || 15e3;
|
|
191
|
+
this.maxResponseBytes = config.maxResponseBytes || 2097152;
|
|
192
|
+
if (!Number.isSafeInteger(this.timeoutMs) || this.timeoutMs < 0 || !Number.isSafeInteger(this.maxResponseBytes) || this.maxResponseBytes < 0) throw new TypeError("Klaviyo limits must be positive integers");
|
|
193
|
+
this.send = options.send ?? sendProviderRequest;
|
|
194
|
+
this.now = options.now ?? (() => /* @__PURE__ */ new Date());
|
|
195
|
+
}
|
|
196
|
+
credentials;
|
|
197
|
+
baseUrl;
|
|
198
|
+
timeoutMs;
|
|
199
|
+
maxResponseBytes;
|
|
200
|
+
send;
|
|
201
|
+
now;
|
|
202
|
+
/** Bind a profile lookup. */
|
|
203
|
+
getProfile() {
|
|
204
|
+
return new GetProfileOperation(this);
|
|
205
|
+
}
|
|
206
|
+
/** Bind an event submission. */
|
|
207
|
+
createEvent() {
|
|
208
|
+
return new CreateEventOperation(this);
|
|
209
|
+
}
|
|
210
|
+
/** Send one authenticated request, preserving transport and body-limit failures for classification. */
|
|
211
|
+
async request(call, method, path, body) {
|
|
212
|
+
let credentials;
|
|
213
|
+
try {
|
|
214
|
+
credentials = await this.credentials.resolve(call, call.context.cancellationSignal);
|
|
215
|
+
} catch (error) {
|
|
216
|
+
throw isTerminalCredentialError(error) ? new InvalidKlaviyoCredentialError() : new UnavailableKlaviyoCredentialError();
|
|
217
|
+
}
|
|
218
|
+
if (!(credentials.privateApiKey instanceof SecretString) || !isHeaderSafeCredential(credentials.privateApiKey.reveal())) throw new InvalidKlaviyoCredentialError();
|
|
219
|
+
const request = {
|
|
220
|
+
url: `${this.baseUrl}${path}`,
|
|
221
|
+
method,
|
|
222
|
+
headers: { Authorization: `Klaviyo-API-Key ${credentials.privateApiKey.reveal()}`, Accept: "application/vnd.api+json", "Content-Type": "application/vnd.api+json", revision: "2026-10-15" },
|
|
223
|
+
maxResponseBytes: this.maxResponseBytes,
|
|
224
|
+
timeoutMs: this.timeoutMs,
|
|
225
|
+
addressPolicy: this.baseUrl === defaultBaseUrl ? "publicHTTPS" : "privateNetworkHTTP",
|
|
226
|
+
signal: call.context.cancellationSignal,
|
|
227
|
+
...body ? { body } : {}
|
|
228
|
+
};
|
|
229
|
+
return this.send(request);
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
var InvalidKlaviyoCredentialError = class extends Error {
|
|
233
|
+
/** Construct a secret-safe credential error. */
|
|
234
|
+
constructor() {
|
|
235
|
+
super("Klaviyo credentials are unavailable or invalid");
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
var UnavailableKlaviyoCredentialError = class extends Error {
|
|
239
|
+
/** Construct a secret-safe transient credential error. */
|
|
240
|
+
constructor() {
|
|
241
|
+
super("Klaviyo credentials are temporarily unavailable");
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
function isTerminalCredentialError(error) {
|
|
245
|
+
return error instanceof ReauthorizationRequiredError || error instanceof ObjectNotFoundError || error instanceof ConnectionNotSelectedError || error instanceof CredentialBrokerRejectedError || error instanceof z.ZodError || isCredentialMaterialError(error);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
// src/project.ts
|
|
249
|
+
function newProjectConnection2(project, connectionName) {
|
|
250
|
+
return newProjectConnection(project, connectionName, (loadedProject, name) => {
|
|
251
|
+
const selected = loadedProject.configuration.connections.find((entry) => entry.connectorId === "klaviyo" && entry.connectionName === name);
|
|
252
|
+
if (!selected) throw new TypeError("Klaviyo project connection is not configured");
|
|
253
|
+
const config = z2.object({ baseUrl: z2.string().optional(), timeout: z2.union([z2.string(), z2.number().int()]).optional(), maxResponseBytes: z2.number().int().optional() }).parse(selected.configuration);
|
|
254
|
+
const timeoutMs = typeof config.timeout === "number" ? Math.ceil(config.timeout / 1e6) : config.timeout ? parseDurationMilliseconds(config.timeout) : void 0;
|
|
255
|
+
const clientConfig = { ...config.baseUrl !== void 0 ? { baseUrl: config.baseUrl } : {}, ...timeoutMs !== void 0 ? { timeoutMs } : {}, ...config.maxResponseBytes !== void 0 ? { maxResponseBytes: config.maxResponseBytes } : {} };
|
|
256
|
+
const credentials = {
|
|
257
|
+
async resolve(_call, signal) {
|
|
258
|
+
const fields = await loadedProject.resolveCredential("klaviyo", name, signal);
|
|
259
|
+
const decoded = z2.object({ private_api_key: z2.string().min(1) }).parse(fields);
|
|
260
|
+
return { privateApiKey: new SecretString2(decoded.private_api_key) };
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
return new KlaviyoClient(clientConfig, credentials);
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
function parseDurationMilliseconds(value) {
|
|
267
|
+
let remaining = value;
|
|
268
|
+
let milliseconds = 0;
|
|
269
|
+
const units = { ns: 1e-6, us: 1e-3, "\xB5s": 1e-3, ms: 1, s: 1e3, m: 6e4, h: 36e5 };
|
|
270
|
+
while (remaining) {
|
|
271
|
+
const component = /^(\d+(?:\.\d+)?)(ns|us|µs|ms|s|m|h)/.exec(remaining);
|
|
272
|
+
if (!component) throw new TypeError("Klaviyo timeout must be a positive Go duration");
|
|
273
|
+
milliseconds += Number(component[1]) * (units[component[2] ?? ""] ?? NaN);
|
|
274
|
+
remaining = remaining.slice(component[0].length);
|
|
275
|
+
}
|
|
276
|
+
if (!Number.isSafeInteger(milliseconds) || milliseconds <= 0) throw new TypeError("Klaviyo timeout must resolve to positive milliseconds");
|
|
277
|
+
return milliseconds;
|
|
278
|
+
}
|
|
279
|
+
export {
|
|
280
|
+
ConfigSchema,
|
|
281
|
+
Connection,
|
|
282
|
+
ConnectorID,
|
|
283
|
+
CreateEventBranch,
|
|
284
|
+
CreateEventBranchAccepted,
|
|
285
|
+
CreateEventBranchDefect,
|
|
286
|
+
CreateEventBranchProviderRejected,
|
|
287
|
+
CreateEventDefinition,
|
|
288
|
+
CreateEventInputSchema,
|
|
289
|
+
CreateEventMetadata,
|
|
290
|
+
CreateEventOperation,
|
|
291
|
+
CredentialMaterialError,
|
|
292
|
+
EventAcceptanceSchema,
|
|
293
|
+
GetProfileBranch,
|
|
294
|
+
GetProfileBranchDefect,
|
|
295
|
+
GetProfileBranchFound,
|
|
296
|
+
GetProfileBranchInvalidResponse,
|
|
297
|
+
GetProfileBranchNotFound,
|
|
298
|
+
GetProfileBranchProviderRejected,
|
|
299
|
+
GetProfileDefinition,
|
|
300
|
+
GetProfileInputSchema,
|
|
301
|
+
GetProfileMetadata,
|
|
302
|
+
GetProfileOperation,
|
|
303
|
+
KlaviyoClient,
|
|
304
|
+
ProfileSchema,
|
|
305
|
+
ProviderID,
|
|
306
|
+
decodeCredentials,
|
|
307
|
+
isCredentialMaterialError,
|
|
308
|
+
newConnection,
|
|
309
|
+
newConnectionWithOperations,
|
|
310
|
+
newCreateEventStep,
|
|
311
|
+
newGetProfileStep,
|
|
312
|
+
newProjectConnection2 as newProjectConnection
|
|
313
|
+
};
|
package/dist/mock.d.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { MockQuery, MockMutation, Case } from '@superdurable/connectors-sdk/connectormock';
|
|
2
|
+
import { Failure } from '@superdurable/connectors-sdk';
|
|
3
|
+
import { O as Operations, a as Connection, G as GetProfileInput, P as Profile, C as CreateEventInput, E as EventAcceptance } from './connection-BvS1Rfu-.js';
|
|
4
|
+
import 'zod';
|
|
5
|
+
|
|
6
|
+
/** Go zero value for GetProfileInput in scripted cases. */
|
|
7
|
+
declare const emptyGetProfileInput: GetProfileInput;
|
|
8
|
+
/** Go zero value for Profile in scripted cases. */
|
|
9
|
+
declare const emptyProfile: Profile;
|
|
10
|
+
/** Go zero value for CreateEventInput in scripted cases. */
|
|
11
|
+
declare const emptyCreateEventInput: CreateEventInput;
|
|
12
|
+
/** Go zero value for EventAcceptance in scripted cases. */
|
|
13
|
+
declare const emptyEventAcceptance: EventAcceptance;
|
|
14
|
+
/** Script the found branch. */
|
|
15
|
+
declare function getProfileFound(value: Profile, failure?: Failure): Case<Profile>;
|
|
16
|
+
/** Script the notFound branch. */
|
|
17
|
+
declare function getProfileNotFound(value: Profile, failure?: Failure): Case<Profile>;
|
|
18
|
+
/** Script the providerRejected branch. */
|
|
19
|
+
declare function getProfileProviderRejected(value: Profile, failure?: Failure): Case<Profile>;
|
|
20
|
+
/** Script the invalidResponse branch. */
|
|
21
|
+
declare function getProfileInvalidResponse(value: Profile, failure?: Failure): Case<Profile>;
|
|
22
|
+
/** Script the defect branch. */
|
|
23
|
+
declare function getProfileDefect(value: Profile, failure?: Failure): Case<Profile>;
|
|
24
|
+
/** Script a safe retry of getProfile. */
|
|
25
|
+
declare function getProfileRetry(failure: Failure, retryAfterMs?: number): Case<Profile>;
|
|
26
|
+
/** Manifest scenario foundDefaultProfile for getProfile. */
|
|
27
|
+
declare function getProfileFoundDefaultProfile(): Case<Profile>;
|
|
28
|
+
/** Default getProfile scenario. */
|
|
29
|
+
declare function getProfileDefault(): Case<Profile>;
|
|
30
|
+
/** Script the accepted branch. */
|
|
31
|
+
declare function createEventAccepted(value: EventAcceptance, failure?: Failure): Case<EventAcceptance>;
|
|
32
|
+
/** Script the providerRejected branch. */
|
|
33
|
+
declare function createEventProviderRejected(value: EventAcceptance, failure?: Failure): Case<EventAcceptance>;
|
|
34
|
+
/** Script the defect branch. */
|
|
35
|
+
declare function createEventDefect(value: EventAcceptance, failure?: Failure): Case<EventAcceptance>;
|
|
36
|
+
/** Script a safe retry of createEvent. */
|
|
37
|
+
declare function createEventRetry(failure: Failure, retryAfterMs?: number): Case<EventAcceptance>;
|
|
38
|
+
/** Manifest scenario acceptedDefaultEvent for createEvent. */
|
|
39
|
+
declare function createEventAcceptedDefaultEvent(): Case<EventAcceptance>;
|
|
40
|
+
/** Default createEvent scenario. */
|
|
41
|
+
declare function createEventDefault(): Case<EventAcceptance>;
|
|
42
|
+
/** Scripted operations and manifest defaults for this connector. */
|
|
43
|
+
declare class GeneratedMock implements Operations {
|
|
44
|
+
#private;
|
|
45
|
+
constructor(connectionName: string);
|
|
46
|
+
connection(): Connection;
|
|
47
|
+
getProfile(): MockQuery<GetProfileInput, Profile>;
|
|
48
|
+
createEvent(): MockMutation<CreateEventInput, EventAcceptance>;
|
|
49
|
+
assertNoFailures(): void;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export { GeneratedMock, createEventAccepted, createEventAcceptedDefaultEvent, createEventDefault, createEventDefect, createEventProviderRejected, createEventRetry, emptyCreateEventInput, emptyEventAcceptance, emptyGetProfileInput, emptyProfile, getProfileDefault, getProfileDefect, getProfileFound, getProfileFoundDefaultProfile, getProfileInvalidResponse, getProfileNotFound, getProfileProviderRejected, getProfileRetry };
|
package/dist/mock.js
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CreateEventDefinition,
|
|
3
|
+
CreateEventInputSchema,
|
|
4
|
+
EventAcceptanceSchema,
|
|
5
|
+
GetProfileDefinition,
|
|
6
|
+
GetProfileInputSchema,
|
|
7
|
+
ProfileSchema,
|
|
8
|
+
ProviderID,
|
|
9
|
+
newConnectionWithOperations
|
|
10
|
+
} from "./chunk-GC6YRQKN.js";
|
|
11
|
+
|
|
12
|
+
// src/generated/mock.ts
|
|
13
|
+
import { branchCase, retryCase, newMutation, newQuery } from "@superdurable/connectors-sdk/connectormock";
|
|
14
|
+
var emptyGetProfileInput = GetProfileInputSchema.parse({
|
|
15
|
+
"id": ""
|
|
16
|
+
});
|
|
17
|
+
var emptyProfile = ProfileSchema.parse({
|
|
18
|
+
"id": ""
|
|
19
|
+
});
|
|
20
|
+
var emptyCreateEventInput = CreateEventInputSchema.parse({
|
|
21
|
+
"email": "",
|
|
22
|
+
"metricName": ""
|
|
23
|
+
});
|
|
24
|
+
var emptyEventAcceptance = EventAcceptanceSchema.parse({
|
|
25
|
+
"accepted": false
|
|
26
|
+
});
|
|
27
|
+
function getProfileFound(value, failure) {
|
|
28
|
+
return branchCase("found", value, failure);
|
|
29
|
+
}
|
|
30
|
+
function getProfileNotFound(value, failure) {
|
|
31
|
+
return branchCase("notFound", value, failure);
|
|
32
|
+
}
|
|
33
|
+
function getProfileProviderRejected(value, failure) {
|
|
34
|
+
return branchCase("providerRejected", value, failure);
|
|
35
|
+
}
|
|
36
|
+
function getProfileInvalidResponse(value, failure) {
|
|
37
|
+
return branchCase("invalidResponse", value, failure);
|
|
38
|
+
}
|
|
39
|
+
function getProfileDefect(value, failure) {
|
|
40
|
+
return branchCase("defect", value, failure);
|
|
41
|
+
}
|
|
42
|
+
function getProfileRetry(failure, retryAfterMs = 0) {
|
|
43
|
+
return retryCase(failure, retryAfterMs);
|
|
44
|
+
}
|
|
45
|
+
function getProfileFoundDefaultProfile() {
|
|
46
|
+
const value = ProfileSchema.parse({ "email": "member@meridian.co", "id": "profile-meridian-1" });
|
|
47
|
+
return branchCase("found", value);
|
|
48
|
+
}
|
|
49
|
+
function getProfileDefault() {
|
|
50
|
+
return getProfileFoundDefaultProfile();
|
|
51
|
+
}
|
|
52
|
+
function createEventAccepted(value, failure) {
|
|
53
|
+
return branchCase("accepted", value, failure);
|
|
54
|
+
}
|
|
55
|
+
function createEventProviderRejected(value, failure) {
|
|
56
|
+
return branchCase("providerRejected", value, failure);
|
|
57
|
+
}
|
|
58
|
+
function createEventDefect(value, failure) {
|
|
59
|
+
return branchCase("defect", value, failure);
|
|
60
|
+
}
|
|
61
|
+
function createEventRetry(failure, retryAfterMs = 0) {
|
|
62
|
+
return retryCase(failure, retryAfterMs);
|
|
63
|
+
}
|
|
64
|
+
function createEventAcceptedDefaultEvent() {
|
|
65
|
+
const value = EventAcceptanceSchema.parse({ "accepted": true });
|
|
66
|
+
return branchCase("accepted", value);
|
|
67
|
+
}
|
|
68
|
+
function createEventDefault() {
|
|
69
|
+
return createEventAcceptedDefaultEvent();
|
|
70
|
+
}
|
|
71
|
+
var GeneratedMock = class {
|
|
72
|
+
#getProfile;
|
|
73
|
+
#createEvent;
|
|
74
|
+
#connection;
|
|
75
|
+
constructor(connectionName) {
|
|
76
|
+
this.#getProfile = newQuery(GetProfileDefinition).default(getProfileDefault());
|
|
77
|
+
this.#createEvent = newMutation(CreateEventDefinition).default(createEventDefault());
|
|
78
|
+
this.#connection = newConnectionWithOperations(this, { provider: ProviderID, name: connectionName });
|
|
79
|
+
}
|
|
80
|
+
connection() {
|
|
81
|
+
return this.#connection;
|
|
82
|
+
}
|
|
83
|
+
getProfile() {
|
|
84
|
+
return this.#getProfile;
|
|
85
|
+
}
|
|
86
|
+
createEvent() {
|
|
87
|
+
return this.#createEvent;
|
|
88
|
+
}
|
|
89
|
+
assertNoFailures() {
|
|
90
|
+
this.#getProfile.assertNoFailures();
|
|
91
|
+
this.#createEvent.assertNoFailures();
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
export {
|
|
95
|
+
GeneratedMock,
|
|
96
|
+
createEventAccepted,
|
|
97
|
+
createEventAcceptedDefaultEvent,
|
|
98
|
+
createEventDefault,
|
|
99
|
+
createEventDefect,
|
|
100
|
+
createEventProviderRejected,
|
|
101
|
+
createEventRetry,
|
|
102
|
+
emptyCreateEventInput,
|
|
103
|
+
emptyEventAcceptance,
|
|
104
|
+
emptyGetProfileInput,
|
|
105
|
+
emptyProfile,
|
|
106
|
+
getProfileDefault,
|
|
107
|
+
getProfileDefect,
|
|
108
|
+
getProfileFound,
|
|
109
|
+
getProfileFoundDefaultProfile,
|
|
110
|
+
getProfileInvalidResponse,
|
|
111
|
+
getProfileNotFound,
|
|
112
|
+
getProfileProviderRejected,
|
|
113
|
+
getProfileRetry
|
|
114
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,64 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superdurable/connector-klaviyo",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Klaviyo profile and event operations for Dex Flows",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/superdurable/dex-connectors-library.git",
|
|
9
|
+
"directory": "connectors/klaviyo/typescript"
|
|
10
|
+
},
|
|
11
|
+
"type": "module",
|
|
12
|
+
"publishConfig": {
|
|
13
|
+
"access": "public",
|
|
14
|
+
"registry": "https://registry.npmjs.org"
|
|
15
|
+
},
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": "^22.0.0 || ^24.0.0"
|
|
18
|
+
},
|
|
19
|
+
"module": "./dist/index.js",
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"import": "./dist/index.js"
|
|
25
|
+
},
|
|
26
|
+
"./mock": {
|
|
27
|
+
"types": "./dist/mock.d.ts",
|
|
28
|
+
"import": "./dist/mock.js"
|
|
29
|
+
},
|
|
30
|
+
"./dex-connector.json": "./dex-connector.json"
|
|
31
|
+
},
|
|
32
|
+
"files": [
|
|
33
|
+
"dist",
|
|
34
|
+
"dex-connector.json",
|
|
35
|
+
"LICENSE",
|
|
36
|
+
"README.md"
|
|
37
|
+
],
|
|
38
|
+
"scripts": {
|
|
39
|
+
"build": "tsup src/index.ts src/mock.ts --format esm --dts --clean",
|
|
40
|
+
"typecheck": "tsc --noEmit",
|
|
41
|
+
"lint": "eslint src test examples",
|
|
42
|
+
"test": "npm run build && vitest run --exclude 'test/integration/**'",
|
|
43
|
+
"test:integration": "npm run build && vitest run test/integration/*.integration.test.ts",
|
|
44
|
+
"check": "npm test && npm run typecheck && npm run lint",
|
|
45
|
+
"example:profile": "npm run build && tsx examples/profile-event/main.ts",
|
|
46
|
+
"example:profile:start": "npm run build && tsx examples/profile-event/start.ts"
|
|
47
|
+
},
|
|
48
|
+
"dependencies": {
|
|
49
|
+
"@superdurable/connectors-sdk": "0.1.0",
|
|
50
|
+
"@superdurable/dex": ">=1.28.0",
|
|
51
|
+
"zod": "^4.1.0"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@eslint/js": "^9.0.0",
|
|
55
|
+
"@types/node": "^22.0.0",
|
|
56
|
+
"eslint": "^9.0.0",
|
|
57
|
+
"tsup": "^8.0.0",
|
|
58
|
+
"tsx": "^4.23.15",
|
|
59
|
+
"typescript": "^5.9.0",
|
|
60
|
+
"typescript-eslint": "^8.0.0",
|
|
61
|
+
"vitest": "^3.0.0",
|
|
62
|
+
"yaml": "^2.9.1"
|
|
63
|
+
}
|
|
64
|
+
}
|