@zapier/zapier-sdk 0.5.1 → 0.5.2

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.
@@ -10,7 +10,7 @@ interface AppFactoryOptions {
10
10
 
11
11
  // Base action type proxy for regular actions
12
12
  interface BaseActionTypeProxy {
13
- [action: string]: (options?: ActionExecutionOptions) => any;
13
+ [action: string]: (options?: ActionExecutionOptions) => unknown;
14
14
  }
15
15
 
16
16
  // Special fetch function type
@@ -1,5 +1,5 @@
1
1
  import type { Plugin, GetSdkType } from "../../types/plugin";
2
- import type { ApiClient } from "../../api";
2
+ import type { ApiClient, Implementation } from "../../api";
3
3
  import type { ActionItem } from "../../types/domain";
4
4
  import { normalizeActionItem } from "../../utils/domain-utils";
5
5
  import {
@@ -57,24 +57,27 @@ export const listActionsPlugin: Plugin<
57
57
  selected_apis: implementationId,
58
58
  };
59
59
 
60
- const data = await api.get("/api/v4/implementations/", {
61
- searchParams,
62
- customErrorHandler: ({ status }) => {
63
- if (status === 401) {
64
- return new ZapierAuthenticationError(
65
- `Authentication failed. Your token may not have permission to access implementations or may be expired. (HTTP ${status})`,
66
- { statusCode: status },
67
- );
68
- }
69
- if (status === 403) {
70
- return new ZapierAuthenticationError(
71
- `Access forbidden. Your token may not have the required scopes to list implementations. (HTTP ${status})`,
72
- { statusCode: status },
73
- );
74
- }
75
- return undefined;
60
+ const data = await api.get<{ results: Implementation[] }>(
61
+ "/api/v4/implementations/",
62
+ {
63
+ searchParams,
64
+ customErrorHandler: ({ status }) => {
65
+ if (status === 401) {
66
+ return new ZapierAuthenticationError(
67
+ `Authentication failed. Your token may not have permission to access implementations or may be expired. (HTTP ${status})`,
68
+ { statusCode: status },
69
+ );
70
+ }
71
+ if (status === 403) {
72
+ return new ZapierAuthenticationError(
73
+ `Access forbidden. Your token may not have the required scopes to list implementations. (HTTP ${status})`,
74
+ { statusCode: status },
75
+ );
76
+ }
77
+ return undefined;
78
+ },
76
79
  },
77
- });
80
+ );
78
81
 
79
82
  let allActions: ActionItem[] = [];
80
83
 
@@ -87,14 +87,17 @@ async function executeAction(actionOptions: ExecuteActionOptions): Promise<{
87
87
  data: runRequestData,
88
88
  };
89
89
 
90
- const runData = await api.post("/api/actions/v1/runs", runRequest);
90
+ const runData = await api.post<{ data: { id: string } }>(
91
+ "/api/actions/v1/runs",
92
+ runRequest,
93
+ );
91
94
  const runId = runData.data.id;
92
95
 
93
96
  // Step 2: Poll GET /actions/v1/runs/{run_id} for results
94
97
  return await api.poll(`/api/actions/v1/runs/${runId}`, {
95
98
  successStatus: 200,
96
99
  pendingStatus: 202,
97
- resultExtractor: (result: { data: unknown }) => result.data,
100
+ resultExtractor: (result: unknown) => (result as { data: unknown }).data,
98
101
  });
99
102
  }
100
103
 
@@ -65,10 +65,13 @@ export const InputFieldItemSchema = withFormatter(
65
65
  if (item.choices && item.choices.length > 0) {
66
66
  const choiceText =
67
67
  item.choices.length <= 3
68
- ? `Choices: ${item.choices.map((c: any) => c.label || c.value).join(", ")}`
68
+ ? `Choices: ${item.choices.map((c: { label?: string; value: string | number }) => c.label || c.value).join(", ")}`
69
69
  : `Choices: ${item.choices
70
70
  .slice(0, 3)
71
- .map((c: any) => c.label || c.value)
71
+ .map(
72
+ (c: { label?: string; value: string | number }) =>
73
+ c.label || c.value,
74
+ )
72
75
  .join(", ")} (+${item.choices.length - 3} more)`;
73
76
  details.push({ text: choiceText, style: "accent" as const });
74
77
  }
@@ -6,8 +6,8 @@ export interface ApiError {
6
6
  code: string;
7
7
  title: string;
8
8
  detail: string;
9
- source?: any;
10
- meta?: any;
9
+ source?: unknown;
10
+ meta?: unknown;
11
11
  }
12
12
 
13
13
  /**
@@ -17,7 +17,7 @@ export interface ErrorOptions {
17
17
  statusCode?: number;
18
18
  errors?: ApiError[];
19
19
  cause?: unknown;
20
- response?: any;
20
+ response?: unknown;
21
21
  }
22
22
 
23
23
  /**
@@ -29,7 +29,7 @@ export abstract class ZapierError extends Error {
29
29
  public statusCode?: number;
30
30
  public errors?: ApiError[];
31
31
  public cause?: unknown;
32
- public response?: any;
32
+ public response?: unknown;
33
33
 
34
34
  constructor(message: string, options: ErrorOptions = {}) {
35
35
  super(message);
@@ -74,9 +74,12 @@ export class ZapierAppNotFoundError extends ZapierError {
74
74
  */
75
75
  export class ZapierValidationError extends ZapierError {
76
76
  readonly name = "ZapierValidationError";
77
- public details?: any;
77
+ public details?: unknown;
78
78
 
79
- constructor(message: string, options: ErrorOptions & { details?: any } = {}) {
79
+ constructor(
80
+ message: string,
81
+ options: ErrorOptions & { details?: unknown } = {},
82
+ ) {
80
83
  super(message, options);
81
84
  this.details = options.details;
82
85
  }
@@ -8,7 +8,7 @@
8
8
  // Generic event system
9
9
  export interface SdkEvent {
10
10
  type: string;
11
- payload?: Record<string, any>;
11
+ payload?: Record<string, unknown>;
12
12
  timestamp?: number;
13
13
  }
14
14
 
@@ -42,7 +42,8 @@ describe("validation utilities", () => {
42
42
  expect((error as ZapierValidationError).message).toContain("name:");
43
43
  expect((error as ZapierValidationError).message).toContain("age:");
44
44
  expect(
45
- (error as ZapierValidationError).details.zodErrors,
45
+ ((error as ZapierValidationError).details as { zodErrors: unknown })
46
+ ?.zodErrors,
46
47
  ).toBeDefined();
47
48
  }
48
49
  });