@zapier/zapier-sdk 0.0.1 → 0.0.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.
package/src/sdk.ts CHANGED
@@ -1,26 +1,26 @@
1
- import { createActionsSDK, ActionsSDK } from "../../actions-sdk/dist";
2
- import { BaseSDKOptions } from "../../shared-sdk/dist";
1
+ import { createActionsSdk, ActionsSdk } from "./actions-sdk";
2
+ import { BaseSdkOptions } from "./types";
3
3
 
4
- export interface ZapierSDK extends ActionsSDK {
4
+ export interface ZapierSdk extends ActionsSdk {
5
5
  // Future SDK namespaces will be added here
6
- // workflows: WorkflowsSDK
7
- // interfaces: InterfacesSDK
8
- // tables: TablesSDK
6
+ // workflows: WorkflowsSdk
7
+ // interfaces: InterfacesSdk
8
+ // tables: TablesSdk
9
9
  }
10
10
 
11
- export interface ZapierSDKOptions extends BaseSDKOptions {}
11
+ export interface ZapierSdkOptions extends BaseSdkOptions {}
12
12
 
13
- export function createZapierSDK(options: ZapierSDKOptions = {}): ZapierSDK {
13
+ export function createZapierSdk(options: ZapierSdkOptions = {}): ZapierSdk {
14
14
  // Create individual SDKs
15
- const actionsSDK = createActionsSDK(options);
15
+ const actionsSdk = createActionsSdk(options);
16
16
 
17
17
  // For now, we just return the actions SDK
18
18
  // Later we'll combine multiple SDKs here
19
19
  return {
20
- ...actionsSDK,
20
+ ...actionsSdk,
21
21
  // Future SDKs will be spread here:
22
- // ...workflowsSDK,
23
- // ...interfacesSDK,
24
- // ...tablesSDK,
22
+ // ...workflowsSdk,
23
+ // ...interfacesSdk,
24
+ // ...tablesSdk,
25
25
  };
26
26
  }
package/src/types.ts ADDED
@@ -0,0 +1,244 @@
1
+ export interface Integration {
2
+ key: string;
3
+ name: string;
4
+ description: string;
5
+ version: string;
6
+ category?: string;
7
+ actions: Action[];
8
+ triggers: Trigger[];
9
+ current_implementation_id?: string;
10
+ }
11
+
12
+ export interface Action {
13
+ key: string;
14
+ name: string;
15
+ description: string;
16
+ appKey: string;
17
+ type: "create" | "update" | "search" | "delete" | "read";
18
+ inputFields: Field[];
19
+ outputFields: Field[];
20
+ }
21
+
22
+ export interface Trigger {
23
+ key: string;
24
+ name: string;
25
+ description: string;
26
+ appKey: string;
27
+ type: "instant" | "polling" | "webhook";
28
+ outputFields: Field[];
29
+ }
30
+
31
+ export interface Field {
32
+ key: string;
33
+ label: string;
34
+ type:
35
+ | "string"
36
+ | "number"
37
+ | "boolean"
38
+ | "datetime"
39
+ | "file"
40
+ | "object"
41
+ | "array";
42
+ required: boolean;
43
+ description?: string;
44
+ choices?: Choice[];
45
+ }
46
+
47
+ export interface Choice {
48
+ value: string | number;
49
+ label: string;
50
+ }
51
+
52
+ export interface ListOptions {
53
+ category?: string;
54
+ appKey?: string;
55
+ type?: string;
56
+ limit?: number;
57
+ offset?: number;
58
+ }
59
+
60
+ export interface ActionExecutionOptions {
61
+ inputs?: Record<string, any>;
62
+ authId?: number;
63
+ }
64
+
65
+ export interface ActionExecutionResult {
66
+ success: boolean;
67
+ data?: any;
68
+ error?: string;
69
+ metadata?: {
70
+ executionTime?: number;
71
+ requestId?: string;
72
+ };
73
+ }
74
+
75
+ export interface ActionField {
76
+ key: string;
77
+ label?: string;
78
+ required: boolean;
79
+ type?: string;
80
+ helpText?: string;
81
+ helpTextHtml?: string;
82
+ choices?: ActionFieldChoice[];
83
+ default?: string;
84
+ placeholder?: string;
85
+ computed?: boolean;
86
+ customField?: boolean;
87
+ dependsOn?: string[];
88
+ format?: string;
89
+ inputFormat?: string[];
90
+ }
91
+
92
+ export interface ActionFieldChoice {
93
+ value: string | number;
94
+ label: string;
95
+ }
96
+
97
+ export interface NeedsRequest {
98
+ selected_api: string;
99
+ action: string;
100
+ type_of: string;
101
+ authentication_id?: number;
102
+ params?: Record<string, any>;
103
+ }
104
+
105
+ export interface NeedsResponse {
106
+ success: boolean;
107
+ needs?: ActionField[];
108
+ errors?: string[];
109
+ }
110
+
111
+ // Future extensibility types
112
+ export interface Workflow {
113
+ id: string;
114
+ name: string;
115
+ description: string;
116
+ steps: WorkflowStep[];
117
+ }
118
+
119
+ export interface WorkflowStep {
120
+ id: string;
121
+ type: "trigger" | "action";
122
+ appKey: string;
123
+ actionKey?: string;
124
+ triggerKey?: string;
125
+ }
126
+
127
+ export interface Interface {
128
+ key: string;
129
+ name: string;
130
+ fields: Field[];
131
+ }
132
+
133
+ export interface Table {
134
+ key: string;
135
+ name: string;
136
+ columns: TableColumn[];
137
+ }
138
+
139
+ export interface TableColumn {
140
+ key: string;
141
+ name: string;
142
+ type: string;
143
+ }
144
+
145
+ export interface Authentication {
146
+ id: number;
147
+ date: string;
148
+ lastchanged?: string;
149
+ account_id: number;
150
+ customuser_id?: number;
151
+ selected_api: string;
152
+ destination_selected_api?: string | null;
153
+ is_invite_only: boolean;
154
+ is_private: boolean;
155
+ shared_with_all: boolean;
156
+ is_stale?: string;
157
+ is_shared?: string;
158
+ marked_stale_at?: string | null;
159
+ label?: string | null;
160
+ identifier?: string | null;
161
+ title?: string | null;
162
+ url?: string;
163
+ groups?: string;
164
+ members?: string;
165
+ permissions?: Record<string, boolean>;
166
+ }
167
+
168
+ export interface AuthenticationsResponse {
169
+ count: number;
170
+ next?: string | null;
171
+ previous?: string | null;
172
+ results: Authentication[];
173
+ }
174
+
175
+ export interface AuthenticationListOptions {
176
+ account_id?: string;
177
+ owner?: string;
178
+ appKey?: string;
179
+ limit?: number;
180
+ offset?: number;
181
+ }
182
+
183
+ // Custom error classes for better error handling
184
+ export class ZapierSdkError extends Error {
185
+ constructor(
186
+ message: string,
187
+ public code?: string,
188
+ ) {
189
+ super(message);
190
+ this.name = "ZapierSdkError";
191
+ }
192
+ }
193
+
194
+ export class AppNotFoundError extends ZapierSdkError {
195
+ constructor(appKey: string) {
196
+ super(`App "${appKey}" not found`);
197
+ this.name = "AppNotFoundError";
198
+ this.code = "APP_NOT_FOUND";
199
+ }
200
+ }
201
+
202
+ export class ActionNotFoundError extends ZapierSdkError {
203
+ constructor(appKey: string, actionKey: string) {
204
+ super(`Action "${actionKey}" not found in app "${appKey}"`);
205
+ this.name = "ActionNotFoundError";
206
+ this.code = "ACTION_NOT_FOUND";
207
+ }
208
+ }
209
+
210
+ export class AuthenticationError extends ZapierSdkError {
211
+ constructor(message: string) {
212
+ super(message);
213
+ this.name = "AuthenticationError";
214
+ this.code = "AUTHENTICATION_ERROR";
215
+ }
216
+ }
217
+
218
+ // Auth configuration types
219
+ export interface AuthObject {
220
+ id: number;
221
+ }
222
+
223
+ // Common SDK interfaces
224
+ export interface BaseSdkOptions {
225
+ token?: string;
226
+ authentications?: {
227
+ [appKey: string]: AuthObject[];
228
+ };
229
+ fetch?: typeof fetch;
230
+ baseUrl?: string;
231
+ debug?: boolean;
232
+ }
233
+
234
+ export interface CombinedSdk {
235
+ [namespace: string]: any;
236
+ }
237
+
238
+ // Factory function type for creating individual SDKs
239
+ export type SdkFactory<T = any> = (options: BaseSdkOptions) => T;
240
+
241
+ // Utility function to combine multiple SDKs
242
+ export function combineSdks(sdks: Record<string, any>): CombinedSdk {
243
+ return { ...sdks };
244
+ }