@wfgraph/plugins 0.0.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.
@@ -0,0 +1,45 @@
1
+ import { n as describeSlackFailure, r as readSlackError, t as callSlack } from "./client-DDDCNLId.js";
2
+ import { callExternalAsync } from "@wfgraph/core/plugin";
3
+ import { Schema } from "effect";
4
+ //#region src/slack/test.ts
5
+ const authTestSchema = Schema.Struct({ team: Schema.optionalKey(Schema.String) });
6
+ async function testSlack(credentials) {
7
+ const apiKey = credentials.SLACK_API_KEY;
8
+ if (!apiKey) return {
9
+ success: false,
10
+ error: "SLACK_API_KEY is required"
11
+ };
12
+ const result = await callExternalAsync(callSlack(apiKey, "auth.test", authTestSchema, { safeToRepeat: true }), (error) => error);
13
+ if (result.ok) return { success: true };
14
+ const { failure } = result;
15
+ if (failure._tag === "ExternalUnreachable") return {
16
+ success: false,
17
+ error: failure.message,
18
+ details: {
19
+ kind: "unreachable",
20
+ message: failure.message
21
+ }
22
+ };
23
+ const slackError = failure._tag === "ExternalRejected" ? readSlackError(failure.payload) : void 0;
24
+ if (slackError === void 0) return {
25
+ success: false,
26
+ error: `API validation failed: HTTP ${failure.status}`,
27
+ details: {
28
+ kind: "http",
29
+ status: failure.status,
30
+ message: describeSlackFailure(failure)
31
+ }
32
+ };
33
+ return {
34
+ success: false,
35
+ error: slackError,
36
+ details: {
37
+ kind: "rejected",
38
+ status: failure.status,
39
+ slackError,
40
+ message: describeSlackFailure(failure)
41
+ }
42
+ };
43
+ }
44
+ //#endregion
45
+ export { testSlack };
@@ -0,0 +1,38 @@
1
+ import { n as listResendDomains, r as readResendError } from "./client-C2NIQxhb.js";
2
+ import { callExternalAsync } from "@wfgraph/core/plugin";
3
+ //#region src/resend/test.ts
4
+ async function testResend(credentials) {
5
+ const apiKey = credentials.RESEND_API_KEY;
6
+ if (!(apiKey && apiKey.startsWith("re_"))) return {
7
+ success: false,
8
+ error: "Invalid API key format. Resend API keys start with 're_'"
9
+ };
10
+ const result = await callExternalAsync(listResendDomains(apiKey), (error) => error);
11
+ if (result.ok) return { success: true };
12
+ const { failure } = result;
13
+ if (failure._tag === "ExternalUnreachable") return {
14
+ success: false,
15
+ error: failure.message,
16
+ details: { message: failure.message }
17
+ };
18
+ const body = failure._tag === "ExternalRejected" ? readResendError(failure.payload) : void 0;
19
+ if (body?.name === "restricted_api_key") return { success: true };
20
+ const status = body?.statusCode ?? failure.status;
21
+ const details = {
22
+ statusCode: status,
23
+ errorName: body?.name,
24
+ errorMessage: body?.message ?? `HTTP ${failure.status}`
25
+ };
26
+ if (status === 401 || status === 403) return {
27
+ success: false,
28
+ error: "Invalid API key. Please check your Resend API key.",
29
+ details
30
+ };
31
+ return {
32
+ success: false,
33
+ error: `API validation failed: HTTP ${status}`,
34
+ details
35
+ };
36
+ }
37
+ //#endregion
38
+ export { testResend };
@@ -0,0 +1,36 @@
1
+ import { n as toLinearError } from "./errors-C4i6-DQE.js";
2
+ import { LinearErrorType } from "@linear/sdk";
3
+ //#region src/linear/test.ts
4
+ async function testLinear(credentials, createClient) {
5
+ try {
6
+ const apiKey = credentials.LINEAR_API_KEY;
7
+ if (!apiKey) return {
8
+ success: false,
9
+ error: "LINEAR_API_KEY is required"
10
+ };
11
+ if (!(await createClient(apiKey).viewer)?.id) return {
12
+ success: false,
13
+ error: "Failed to verify Linear connection"
14
+ };
15
+ return { success: true };
16
+ } catch (error) {
17
+ const linearError = toLinearError(error);
18
+ const details = {
19
+ type: linearError.type,
20
+ message: linearError.message,
21
+ errors: linearError.errors
22
+ };
23
+ if (linearError.type === LinearErrorType.AuthenticationError) return {
24
+ success: false,
25
+ error: "Invalid API key. Please check your Linear API key.",
26
+ details
27
+ };
28
+ return {
29
+ success: false,
30
+ error: linearError.errors?.[0]?.message || linearError.message || (error instanceof Error ? error.message : String(error)),
31
+ details
32
+ };
33
+ }
34
+ }
35
+ //#endregion
36
+ export { testLinear };
@@ -0,0 +1,32 @@
1
+ import { n as getClerkApiErrorMessage, t as createClerkBackendClient } from "./client-BEcFnbOB.js";
2
+ //#region src/clerk/test.ts
3
+ async function testClerk(credentials) {
4
+ try {
5
+ const secretKey = credentials.CLERK_SECRET_KEY;
6
+ if (!secretKey) return {
7
+ success: false,
8
+ error: "Secret key is required"
9
+ };
10
+ if (!(secretKey.startsWith("sk_live_") || secretKey.startsWith("sk_test_"))) return {
11
+ success: false,
12
+ error: "Invalid secret key format. Clerk secret keys start with 'sk_live_' or 'sk_test_'"
13
+ };
14
+ await createClerkBackendClient(secretKey).users.getUserList({ limit: 1 });
15
+ return { success: true };
16
+ } catch (error) {
17
+ const details = {};
18
+ if (error && typeof error === "object") {
19
+ const clerkError = error;
20
+ if (clerkError.status !== void 0) details.status = clerkError.status;
21
+ if (clerkError.errors !== void 0) details.errors = clerkError.errors;
22
+ if (clerkError.message !== void 0) details.message = clerkError.message;
23
+ }
24
+ return {
25
+ success: false,
26
+ error: getClerkApiErrorMessage(error),
27
+ details
28
+ };
29
+ }
30
+ }
31
+ //#endregion
32
+ export { testClerk };
@@ -0,0 +1,35 @@
1
+ import { i as getAcuityErrorMessage } from "./client-DkPUX0ps.js";
2
+ import { AcuityError } from "@fountain-bio/acuity";
3
+ //#region src/acuity/test.ts
4
+ async function testAcuity(credentials, createSdk) {
5
+ try {
6
+ const userId = credentials.ACUITY_USER_ID?.trim();
7
+ const apiKey = credentials.ACUITY_API_KEY?.trim();
8
+ if (!(userId && apiKey)) return {
9
+ success: false,
10
+ error: "ACUITY_USER_ID and ACUITY_API_KEY are required"
11
+ };
12
+ await createSdk(userId, apiKey).appointments.types();
13
+ return { success: true };
14
+ } catch (error) {
15
+ const message = getAcuityErrorMessage(error, error instanceof Error ? error.message : String(error));
16
+ const details = { message: error instanceof Error ? error.message : String(error) };
17
+ if (error instanceof AcuityError) {
18
+ details.status = error.status;
19
+ details.code = error.code;
20
+ details.payload = error.payload;
21
+ }
22
+ if (message.toLowerCase().includes("unauthorized")) return {
23
+ success: false,
24
+ error: "Invalid Acuity credentials. Please check your User ID and API key.",
25
+ details
26
+ };
27
+ return {
28
+ success: false,
29
+ error: message,
30
+ details
31
+ };
32
+ }
33
+ }
34
+ //#endregion
35
+ export { testAcuity };
@@ -0,0 +1,35 @@
1
+ import { i as readTwilioError, n as describeTwilioFailure, r as fetchTwilioAccount } from "./client-DJGI9f53.js";
2
+ import { callExternalAsync } from "@wfgraph/core/plugin";
3
+ //#region src/twilio/test.ts
4
+ async function testTwilio(credentials) {
5
+ const accountSid = credentials.TWILIO_ACCOUNT_SID;
6
+ const authToken = credentials.TWILIO_AUTH_TOKEN;
7
+ if (!(accountSid && authToken)) return {
8
+ success: false,
9
+ error: "TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN are required"
10
+ };
11
+ const result = await callExternalAsync(fetchTwilioAccount({
12
+ accountSid,
13
+ authToken
14
+ }), (error) => error);
15
+ if (result.ok) return { success: true };
16
+ const { failure } = result;
17
+ if (failure._tag === "ExternalUnreachable") return {
18
+ success: false,
19
+ error: failure.message,
20
+ details: { message: failure.message }
21
+ };
22
+ const body = failure._tag === "ExternalRejected" ? readTwilioError(failure.payload) : void 0;
23
+ return {
24
+ success: false,
25
+ error: `API validation failed: HTTP ${failure.status}`,
26
+ details: {
27
+ status: failure.status,
28
+ code: body?.code,
29
+ moreInfo: body?.more_info,
30
+ message: describeTwilioFailure(failure)
31
+ }
32
+ };
33
+ }
34
+ //#endregion
35
+ export { testTwilio };
package/dist/ui.d.ts ADDED
@@ -0,0 +1,73 @@
1
+ import { ComponentType } from "react";
2
+ //#region src/acuity/icon.d.ts
3
+ declare function AcuityIcon({ className }: {
4
+ className?: string;
5
+ }): import("react").JSX.Element;
6
+ //#endregion
7
+ //#region src/clerk/components/user-card.d.ts
8
+ declare function UserCard({ output }: ResultComponentProps): import("react").JSX.Element | null;
9
+ //#endregion
10
+ //#region src/clerk/icon.d.ts
11
+ declare function ClerkIcon({ className }: {
12
+ className?: string;
13
+ }): import("react").JSX.Element;
14
+ //#endregion
15
+ //#region src/linear/icon.d.ts
16
+ declare function LinearIcon({ className }: {
17
+ className?: string;
18
+ }): import("react").JSX.Element;
19
+ //#endregion
20
+ //#region src/resend/icon.d.ts
21
+ declare function ResendIcon({ className }: {
22
+ className?: string;
23
+ }): import("react").JSX.Element;
24
+ //#endregion
25
+ //#region src/slack/icon.d.ts
26
+ declare function SlackIcon({ className }: {
27
+ className?: string;
28
+ }): import("react").JSX.Element;
29
+ //#endregion
30
+ //#region src/twilio/icon.d.ts
31
+ declare function TwilioIcon({ className }: {
32
+ className?: string;
33
+ }): import("react").JSX.Element;
34
+ //#endregion
35
+ //#region src/ui.d.ts
36
+ /** Props passed to a custom output renderer. */
37
+ type ResultComponentProps = {
38
+ output: unknown;
39
+ input?: unknown;
40
+ };
41
+ type IntegrationUi = {
42
+ icon: ComponentType<{
43
+ className?: string;
44
+ }>;
45
+ outputComponents?: Record<string, ComponentType<ResultComponentProps>>;
46
+ };
47
+ declare const integrationUi: {
48
+ acuity: {
49
+ icon: typeof AcuityIcon;
50
+ };
51
+ clerk: {
52
+ icon: typeof ClerkIcon;
53
+ outputComponents: {
54
+ "get-user": typeof UserCard;
55
+ "create-user": typeof UserCard;
56
+ "update-user": typeof UserCard;
57
+ };
58
+ };
59
+ linear: {
60
+ icon: typeof LinearIcon;
61
+ };
62
+ resend: {
63
+ icon: typeof ResendIcon;
64
+ };
65
+ slack: {
66
+ icon: typeof SlackIcon;
67
+ };
68
+ twilio: {
69
+ icon: typeof TwilioIcon;
70
+ };
71
+ };
72
+ //#endregion
73
+ export { IntegrationUi, ResultComponentProps, integrationUi };