@major-tech/resource-client 0.2.42 → 0.2.44

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.
Files changed (265) hide show
  1. package/dist/index.cjs +1952 -45
  2. package/dist/index.cjs.map +4 -4
  3. package/dist/index.js +1952 -29
  4. package/dist/index.js.map +7 -1
  5. package/package.json +1 -1
  6. package/dist/base.cjs +0 -78
  7. package/dist/base.cjs.map +0 -7
  8. package/dist/base.js +0 -52
  9. package/dist/base.js.map +0 -1
  10. package/dist/clients/api-custom.cjs +0 -36
  11. package/dist/clients/api-custom.cjs.map +0 -7
  12. package/dist/clients/api-custom.js +0 -9
  13. package/dist/clients/api-custom.js.map +0 -1
  14. package/dist/clients/api-graphql.cjs +0 -40
  15. package/dist/clients/api-graphql.cjs.map +0 -7
  16. package/dist/clients/api-graphql.js +0 -13
  17. package/dist/clients/api-graphql.js.map +0 -1
  18. package/dist/clients/auth.cjs +0 -49
  19. package/dist/clients/auth.cjs.map +0 -7
  20. package/dist/clients/auth.js +0 -22
  21. package/dist/clients/auth.js.map +0 -1
  22. package/dist/clients/bigquery.cjs +0 -104
  23. package/dist/clients/bigquery.cjs.map +0 -7
  24. package/dist/clients/bigquery.js +0 -77
  25. package/dist/clients/bigquery.js.map +0 -1
  26. package/dist/clients/cosmosdb.cjs +0 -119
  27. package/dist/clients/cosmosdb.cjs.map +0 -7
  28. package/dist/clients/cosmosdb.js +0 -92
  29. package/dist/clients/cosmosdb.js.map +0 -1
  30. package/dist/clients/dynamodb.cjs +0 -36
  31. package/dist/clients/dynamodb.cjs.map +0 -7
  32. package/dist/clients/dynamodb.js +0 -9
  33. package/dist/clients/dynamodb.js.map +0 -1
  34. package/dist/clients/google-analytics.cjs +0 -101
  35. package/dist/clients/google-analytics.cjs.map +0 -7
  36. package/dist/clients/google-analytics.js +0 -74
  37. package/dist/clients/google-analytics.js.map +0 -1
  38. package/dist/clients/googlesheets.cjs +0 -122
  39. package/dist/clients/googlesheets.cjs.map +0 -7
  40. package/dist/clients/googlesheets.js +0 -95
  41. package/dist/clients/googlesheets.js.map +0 -1
  42. package/dist/clients/hubspot.cjs +0 -36
  43. package/dist/clients/hubspot.cjs.map +0 -7
  44. package/dist/clients/hubspot.js +0 -9
  45. package/dist/clients/hubspot.js.map +0 -1
  46. package/dist/clients/lambda.cjs +0 -81
  47. package/dist/clients/lambda.cjs.map +0 -7
  48. package/dist/clients/lambda.js +0 -54
  49. package/dist/clients/lambda.js.map +0 -1
  50. package/dist/clients/mssql.cjs +0 -59
  51. package/dist/clients/mssql.cjs.map +0 -7
  52. package/dist/clients/mssql.js +0 -32
  53. package/dist/clients/mssql.js.map +0 -1
  54. package/dist/clients/neo4j.cjs +0 -57
  55. package/dist/clients/neo4j.cjs.map +0 -7
  56. package/dist/clients/neo4j.js +0 -30
  57. package/dist/clients/neo4j.js.map +0 -1
  58. package/dist/clients/outreach.cjs +0 -51
  59. package/dist/clients/outreach.cjs.map +0 -7
  60. package/dist/clients/outreach.js +0 -24
  61. package/dist/clients/outreach.js.map +0 -1
  62. package/dist/clients/postgres.cjs +0 -59
  63. package/dist/clients/postgres.cjs.map +0 -7
  64. package/dist/clients/postgres.js +0 -32
  65. package/dist/clients/postgres.js.map +0 -1
  66. package/dist/clients/quickbooks.cjs +0 -65
  67. package/dist/clients/quickbooks.cjs.map +0 -7
  68. package/dist/clients/quickbooks.js +0 -38
  69. package/dist/clients/quickbooks.js.map +0 -1
  70. package/dist/clients/s3.cjs +0 -36
  71. package/dist/clients/s3.cjs.map +0 -7
  72. package/dist/clients/s3.js +0 -9
  73. package/dist/clients/s3.js.map +0 -1
  74. package/dist/clients/salesforce.cjs +0 -131
  75. package/dist/clients/salesforce.cjs.map +0 -7
  76. package/dist/clients/salesforce.js +0 -144
  77. package/dist/clients/salesforce.js.map +0 -1
  78. package/dist/clients/slack.cjs +0 -66
  79. package/dist/clients/slack.cjs.map +0 -7
  80. package/dist/clients/slack.js +0 -39
  81. package/dist/clients/slack.js.map +0 -1
  82. package/dist/clients/snowflake.cjs +0 -69
  83. package/dist/clients/snowflake.cjs.map +0 -7
  84. package/dist/clients/snowflake.js +0 -42
  85. package/dist/clients/snowflake.js.map +0 -1
  86. package/dist/errors.cjs +0 -38
  87. package/dist/errors.cjs.map +0 -7
  88. package/dist/errors.js +0 -15
  89. package/dist/errors.js.map +0 -1
  90. package/dist/payload-builders/auth.cjs +0 -44
  91. package/dist/payload-builders/auth.cjs.map +0 -7
  92. package/dist/payload-builders/auth.js +0 -25
  93. package/dist/payload-builders/auth.js.map +0 -1
  94. package/dist/payload-builders/bigquery.cjs +0 -103
  95. package/dist/payload-builders/bigquery.cjs.map +0 -7
  96. package/dist/payload-builders/bigquery.js +0 -103
  97. package/dist/payload-builders/bigquery.js.map +0 -1
  98. package/dist/payload-builders/cosmosdb.cjs +0 -126
  99. package/dist/payload-builders/cosmosdb.cjs.map +0 -7
  100. package/dist/payload-builders/cosmosdb.js +0 -112
  101. package/dist/payload-builders/cosmosdb.js.map +0 -1
  102. package/dist/payload-builders/custom.cjs +0 -38
  103. package/dist/payload-builders/custom.cjs.map +0 -7
  104. package/dist/payload-builders/custom.js +0 -19
  105. package/dist/payload-builders/custom.js.map +0 -1
  106. package/dist/payload-builders/dynamodb.cjs +0 -34
  107. package/dist/payload-builders/dynamodb.cjs.map +0 -7
  108. package/dist/payload-builders/dynamodb.js +0 -14
  109. package/dist/payload-builders/dynamodb.js.map +0 -1
  110. package/dist/payload-builders/from-extracted-params.cjs +0 -442
  111. package/dist/payload-builders/from-extracted-params.cjs.map +0 -7
  112. package/dist/payload-builders/from-extracted-params.js +0 -444
  113. package/dist/payload-builders/from-extracted-params.js.map +0 -1
  114. package/dist/payload-builders/google-analytics.cjs +0 -106
  115. package/dist/payload-builders/google-analytics.cjs.map +0 -7
  116. package/dist/payload-builders/google-analytics.js +0 -90
  117. package/dist/payload-builders/google-analytics.js.map +0 -1
  118. package/dist/payload-builders/googlesheets.cjs +0 -106
  119. package/dist/payload-builders/googlesheets.cjs.map +0 -7
  120. package/dist/payload-builders/googlesheets.js +0 -115
  121. package/dist/payload-builders/googlesheets.js.map +0 -1
  122. package/dist/payload-builders/graphql.cjs +0 -37
  123. package/dist/payload-builders/graphql.cjs.map +0 -7
  124. package/dist/payload-builders/graphql.js +0 -17
  125. package/dist/payload-builders/graphql.js.map +0 -1
  126. package/dist/payload-builders/hubspot.cjs +0 -37
  127. package/dist/payload-builders/hubspot.cjs.map +0 -7
  128. package/dist/payload-builders/hubspot.js +0 -18
  129. package/dist/payload-builders/hubspot.js.map +0 -1
  130. package/dist/payload-builders/index.cjs +0 -101
  131. package/dist/payload-builders/index.cjs.map +0 -7
  132. package/dist/payload-builders/index.js +0 -41
  133. package/dist/payload-builders/index.js.map +0 -1
  134. package/dist/payload-builders/lambda.cjs +0 -35
  135. package/dist/payload-builders/lambda.cjs.map +0 -7
  136. package/dist/payload-builders/lambda.js +0 -16
  137. package/dist/payload-builders/lambda.js.map +0 -1
  138. package/dist/payload-builders/mssql.cjs +0 -35
  139. package/dist/payload-builders/mssql.cjs.map +0 -7
  140. package/dist/payload-builders/mssql.js +0 -16
  141. package/dist/payload-builders/mssql.js.map +0 -1
  142. package/dist/payload-builders/neo4j.cjs +0 -35
  143. package/dist/payload-builders/neo4j.cjs.map +0 -7
  144. package/dist/payload-builders/neo4j.js +0 -16
  145. package/dist/payload-builders/neo4j.js.map +0 -1
  146. package/dist/payload-builders/outreach.cjs +0 -37
  147. package/dist/payload-builders/outreach.cjs.map +0 -7
  148. package/dist/payload-builders/outreach.js +0 -18
  149. package/dist/payload-builders/outreach.js.map +0 -1
  150. package/dist/payload-builders/postgres.cjs +0 -35
  151. package/dist/payload-builders/postgres.cjs.map +0 -7
  152. package/dist/payload-builders/postgres.js +0 -16
  153. package/dist/payload-builders/postgres.js.map +0 -1
  154. package/dist/payload-builders/quickbooks.cjs +0 -45
  155. package/dist/payload-builders/quickbooks.cjs.map +0 -7
  156. package/dist/payload-builders/quickbooks.js +0 -18
  157. package/dist/payload-builders/quickbooks.js.map +0 -1
  158. package/dist/payload-builders/s3.cjs +0 -35
  159. package/dist/payload-builders/s3.cjs.map +0 -7
  160. package/dist/payload-builders/s3.js +0 -16
  161. package/dist/payload-builders/s3.js.map +0 -1
  162. package/dist/payload-builders/salesforce.cjs +0 -87
  163. package/dist/payload-builders/salesforce.cjs.map +0 -7
  164. package/dist/payload-builders/salesforce.js +0 -91
  165. package/dist/payload-builders/salesforce.js.map +0 -1
  166. package/dist/payload-builders/slack.cjs +0 -59
  167. package/dist/payload-builders/slack.cjs.map +0 -7
  168. package/dist/payload-builders/slack.js +0 -35
  169. package/dist/payload-builders/slack.js.map +0 -1
  170. package/dist/payload-builders/snowflake.cjs +0 -70
  171. package/dist/payload-builders/snowflake.cjs.map +0 -7
  172. package/dist/payload-builders/snowflake.js +0 -57
  173. package/dist/payload-builders/snowflake.js.map +0 -1
  174. package/dist/schemas/api-custom.cjs +0 -17
  175. package/dist/schemas/api-custom.cjs.map +0 -7
  176. package/dist/schemas/api-custom.js +0 -2
  177. package/dist/schemas/api-custom.js.map +0 -1
  178. package/dist/schemas/api-googlesheets.cjs +0 -17
  179. package/dist/schemas/api-googlesheets.cjs.map +0 -7
  180. package/dist/schemas/api-googlesheets.js +0 -2
  181. package/dist/schemas/api-googlesheets.js.map +0 -1
  182. package/dist/schemas/api-graphql.cjs +0 -17
  183. package/dist/schemas/api-graphql.cjs.map +0 -7
  184. package/dist/schemas/api-graphql.js +0 -2
  185. package/dist/schemas/api-graphql.js.map +0 -1
  186. package/dist/schemas/api-hubspot.cjs +0 -17
  187. package/dist/schemas/api-hubspot.cjs.map +0 -7
  188. package/dist/schemas/api-hubspot.js +0 -2
  189. package/dist/schemas/api-hubspot.js.map +0 -1
  190. package/dist/schemas/api-outreach.cjs +0 -17
  191. package/dist/schemas/api-outreach.cjs.map +0 -7
  192. package/dist/schemas/api-outreach.js +0 -2
  193. package/dist/schemas/api-outreach.js.map +0 -1
  194. package/dist/schemas/api-quickbooks.cjs +0 -17
  195. package/dist/schemas/api-quickbooks.cjs.map +0 -7
  196. package/dist/schemas/api-quickbooks.js +0 -2
  197. package/dist/schemas/api-quickbooks.js.map +0 -1
  198. package/dist/schemas/api-salesforce.cjs +0 -17
  199. package/dist/schemas/api-salesforce.cjs.map +0 -7
  200. package/dist/schemas/api-salesforce.js +0 -2
  201. package/dist/schemas/api-salesforce.js.map +0 -1
  202. package/dist/schemas/api-slack.cjs +0 -17
  203. package/dist/schemas/api-slack.cjs.map +0 -7
  204. package/dist/schemas/api-slack.js +0 -2
  205. package/dist/schemas/api-slack.js.map +0 -1
  206. package/dist/schemas/auth.cjs +0 -17
  207. package/dist/schemas/auth.cjs.map +0 -7
  208. package/dist/schemas/auth.js +0 -5
  209. package/dist/schemas/auth.js.map +0 -1
  210. package/dist/schemas/bigquery.cjs +0 -17
  211. package/dist/schemas/bigquery.cjs.map +0 -7
  212. package/dist/schemas/bigquery.js +0 -5
  213. package/dist/schemas/bigquery.js.map +0 -1
  214. package/dist/schemas/common.cjs +0 -17
  215. package/dist/schemas/common.cjs.map +0 -7
  216. package/dist/schemas/common.js +0 -2
  217. package/dist/schemas/common.js.map +0 -1
  218. package/dist/schemas/cosmosdb.cjs +0 -17
  219. package/dist/schemas/cosmosdb.cjs.map +0 -7
  220. package/dist/schemas/cosmosdb.js +0 -2
  221. package/dist/schemas/cosmosdb.js.map +0 -1
  222. package/dist/schemas/dynamodb.cjs +0 -17
  223. package/dist/schemas/dynamodb.cjs.map +0 -7
  224. package/dist/schemas/dynamodb.js +0 -2
  225. package/dist/schemas/dynamodb.js.map +0 -1
  226. package/dist/schemas/google-analytics.cjs +0 -17
  227. package/dist/schemas/google-analytics.cjs.map +0 -7
  228. package/dist/schemas/google-analytics.js +0 -2
  229. package/dist/schemas/google-analytics.js.map +0 -1
  230. package/dist/schemas/index.cjs +0 -40
  231. package/dist/schemas/index.cjs.map +0 -7
  232. package/dist/schemas/index.js +0 -24
  233. package/dist/schemas/index.js.map +0 -1
  234. package/dist/schemas/lambda.cjs +0 -17
  235. package/dist/schemas/lambda.cjs.map +0 -7
  236. package/dist/schemas/lambda.js +0 -2
  237. package/dist/schemas/lambda.js.map +0 -1
  238. package/dist/schemas/mssql.cjs +0 -17
  239. package/dist/schemas/mssql.cjs.map +0 -7
  240. package/dist/schemas/mssql.js +0 -2
  241. package/dist/schemas/mssql.js.map +0 -1
  242. package/dist/schemas/neo4j.cjs +0 -17
  243. package/dist/schemas/neo4j.cjs.map +0 -7
  244. package/dist/schemas/neo4j.js +0 -2
  245. package/dist/schemas/neo4j.js.map +0 -1
  246. package/dist/schemas/postgres.cjs +0 -17
  247. package/dist/schemas/postgres.cjs.map +0 -7
  248. package/dist/schemas/postgres.js +0 -2
  249. package/dist/schemas/postgres.js.map +0 -1
  250. package/dist/schemas/request.cjs +0 -17
  251. package/dist/schemas/request.cjs.map +0 -7
  252. package/dist/schemas/request.js +0 -2
  253. package/dist/schemas/request.js.map +0 -1
  254. package/dist/schemas/response.cjs +0 -17
  255. package/dist/schemas/response.cjs.map +0 -7
  256. package/dist/schemas/response.js +0 -2
  257. package/dist/schemas/response.js.map +0 -1
  258. package/dist/schemas/s3.cjs +0 -17
  259. package/dist/schemas/s3.cjs.map +0 -7
  260. package/dist/schemas/s3.js +0 -2
  261. package/dist/schemas/s3.js.map +0 -1
  262. package/dist/schemas/snowflake.cjs +0 -17
  263. package/dist/schemas/snowflake.cjs.map +0 -7
  264. package/dist/schemas/snowflake.js +0 -2
  265. package/dist/schemas/snowflake.js.map +0 -1
package/dist/index.js CHANGED
@@ -1,29 +1,1952 @@
1
- // Export all schemas and types
2
- export * from "./schemas";
3
- // Export base client and config
4
- export { BaseResourceClient } from "./base";
5
- // Export errors
6
- export { ResourceInvokeError } from "./errors";
7
- // Export individual clients
8
- export { PostgresResourceClient } from "./clients/postgres";
9
- export { MssqlResourceClient } from "./clients/mssql";
10
- export { DynamoDBResourceClient } from "./clients/dynamodb";
11
- export { CosmosDBResourceClient } from "./clients/cosmosdb";
12
- export { SnowflakeResourceClient } from "./clients/snowflake";
13
- export { CustomApiResourceClient } from "./clients/api-custom";
14
- export { HubSpotResourceClient } from "./clients/hubspot";
15
- export { SalesforceResourceClient } from "./clients/salesforce";
16
- export { GoogleSheetsResourceClient } from "./clients/googlesheets";
17
- export { S3ResourceClient } from "./clients/s3";
18
- export { LambdaResourceClient } from "./clients/lambda";
19
- export { BigQueryResourceClient } from "./clients/bigquery";
20
- export { OutreachResourceClient } from "./clients/outreach";
21
- export { Neo4jResourceClient } from "./clients/neo4j";
22
- export { SlackResourceClient } from "./clients/slack";
23
- export { QuickBooksResourceClient } from "./clients/quickbooks";
24
- export { MajorAuthResourceClient } from "./clients/auth";
25
- export { GoogleAnalyticsResourceClient } from "./clients/google-analytics";
26
- export { GraphQLResourceClient } from "./clients/api-graphql";
27
- // Export payload builders (for use in testing UIs, etc.)
28
- export * from "./payload-builders";
29
- //# sourceMappingURL=index.js.map
1
+ // src/errors.ts
2
+ var ResourceInvokeError = class extends Error {
3
+ httpStatus;
4
+ requestId;
5
+ constructor(message, httpStatus, requestId) {
6
+ super(message);
7
+ this.name = "ResourceInvokeError";
8
+ this.httpStatus = httpStatus;
9
+ this.requestId = requestId;
10
+ }
11
+ };
12
+
13
+ // src/base.ts
14
+ var BaseResourceClient = class {
15
+ config;
16
+ constructor(config) {
17
+ if (!config.applicationId && !config.toolId) {
18
+ throw new Error("BaseResourceClient requires either applicationId or toolId");
19
+ }
20
+ this.config = {
21
+ baseUrl: config.baseUrl.replace(/\/$/, ""),
22
+ majorJwtToken: config.majorJwtToken,
23
+ applicationId: config.applicationId,
24
+ toolId: config.toolId,
25
+ resourceId: config.resourceId,
26
+ fetch: config.fetch || globalThis.fetch,
27
+ getHeaders: config.getHeaders
28
+ };
29
+ }
30
+ async invokeRaw(payload, invocationKey) {
31
+ const entityType = this.config.toolId ? "tools" : "apps";
32
+ const entityId = this.config.toolId || this.config.applicationId;
33
+ const url = `${this.config.baseUrl}/internal/${entityType}/v1/${entityId}/resource/${this.config.resourceId}/invoke`;
34
+ const body = {
35
+ payload,
36
+ invocationKey
37
+ };
38
+ let headers = {
39
+ "Content-Type": "application/json"
40
+ };
41
+ if (this.config.majorJwtToken) {
42
+ headers["x-major-jwt"] = this.config.majorJwtToken;
43
+ }
44
+ if (this.config.getHeaders) {
45
+ const extraHeaders = await this.config.getHeaders();
46
+ headers = { ...headers, ...extraHeaders };
47
+ }
48
+ try {
49
+ const response = await this.config.fetch(url, {
50
+ method: "POST",
51
+ headers,
52
+ credentials: "include",
53
+ body: JSON.stringify(body)
54
+ });
55
+ const data = await response.json();
56
+ return data;
57
+ } catch (error) {
58
+ const message = error instanceof Error ? error.message : String(error);
59
+ throw new ResourceInvokeError(`Failed to invoke resource: ${message}`);
60
+ }
61
+ }
62
+ };
63
+
64
+ // src/payload-builders/postgres.ts
65
+ function buildPostgresInvokePayload(sql, params, timeoutMs) {
66
+ return {
67
+ type: "database",
68
+ subtype: "postgresql",
69
+ sql,
70
+ params,
71
+ timeoutMs
72
+ };
73
+ }
74
+
75
+ // src/clients/postgres.ts
76
+ var PostgresResourceClient = class extends BaseResourceClient {
77
+ /**
78
+ * Execute a SQL query against PostgreSQL
79
+ * @param sql The SQL query to execute
80
+ * @param params Optional positional parameters ($1, $2, etc.)
81
+ * @param invocationKey Unique key for tracking this invocation
82
+ * @param timeoutMs Optional timeout in milliseconds
83
+ * @returns Typed response with rows of type T
84
+ *
85
+ * @example
86
+ * ```ts
87
+ * interface User { id: number; name: string; email: string }
88
+ *
89
+ * const response = await client.invoke<User>(
90
+ * "SELECT id, name, email FROM users WHERE id = $1",
91
+ * [123],
92
+ * "get-user-123"
93
+ * );
94
+ *
95
+ * if (response.ok) {
96
+ * const users: User[] = response.result.rows;
97
+ * }
98
+ * ```
99
+ */
100
+ async invoke(sql, params, invocationKey, timeoutMs) {
101
+ const payload = buildPostgresInvokePayload(sql, params, timeoutMs);
102
+ return this.invokeRaw(payload, invocationKey);
103
+ }
104
+ };
105
+
106
+ // src/payload-builders/mssql.ts
107
+ function buildMssqlInvokePayload(sql, params, timeoutMs) {
108
+ return {
109
+ type: "database",
110
+ subtype: "mssql",
111
+ sql,
112
+ params,
113
+ timeoutMs
114
+ };
115
+ }
116
+
117
+ // src/clients/mssql.ts
118
+ var MssqlResourceClient = class extends BaseResourceClient {
119
+ /**
120
+ * Execute a SQL query against MSSQL
121
+ * @param sql The SQL query to execute
122
+ * @param params Optional named parameters (e.g., { id: 123 } for @id in the query)
123
+ * @param invocationKey Unique key for tracking this invocation
124
+ * @param timeoutMs Optional timeout in milliseconds
125
+ * @returns Typed response with rows of type T
126
+ *
127
+ * @example
128
+ * ```ts
129
+ * interface User { id: number; name: string; email: string }
130
+ *
131
+ * const response = await client.invoke<User>(
132
+ * "SELECT id, name, email FROM users WHERE id = @id",
133
+ * { id: 123 },
134
+ * "get-user-123"
135
+ * );
136
+ *
137
+ * if (response.ok) {
138
+ * const users: User[] = response.result.rows;
139
+ * }
140
+ * ```
141
+ */
142
+ async invoke(sql, params, invocationKey, timeoutMs) {
143
+ const payload = buildMssqlInvokePayload(sql, params, timeoutMs);
144
+ return this.invokeRaw(payload, invocationKey);
145
+ }
146
+ };
147
+
148
+ // src/payload-builders/dynamodb.ts
149
+ function buildDynamoDBInvokePayload(command, params) {
150
+ return {
151
+ type: "database",
152
+ subtype: "dynamodb",
153
+ command,
154
+ params
155
+ };
156
+ }
157
+
158
+ // src/clients/dynamodb.ts
159
+ var DynamoDBResourceClient = class extends BaseResourceClient {
160
+ async invoke(command, params, invocationKey) {
161
+ const payload = buildDynamoDBInvokePayload(command, params);
162
+ return this.invokeRaw(payload, invocationKey);
163
+ }
164
+ };
165
+
166
+ // src/payload-builders/cosmosdb.ts
167
+ function buildCosmosDBInvokePayload(payload) {
168
+ return payload;
169
+ }
170
+ function buildCosmosDBQueryPayload(container, query, options) {
171
+ return {
172
+ type: "database",
173
+ subtype: "cosmosdb",
174
+ operation: "query",
175
+ container,
176
+ query,
177
+ parameters: options?.parameters,
178
+ partitionKey: options?.partitionKey,
179
+ maxItemCount: options?.maxItemCount,
180
+ continuationToken: options?.continuationToken,
181
+ timeoutMs: options?.timeoutMs
182
+ };
183
+ }
184
+ function buildCosmosDBReadPayload(container, id, options) {
185
+ return {
186
+ type: "database",
187
+ subtype: "cosmosdb",
188
+ operation: "read",
189
+ container,
190
+ id,
191
+ partitionKey: options?.partitionKey,
192
+ timeoutMs: options?.timeoutMs
193
+ };
194
+ }
195
+ function buildCosmosDBCreatePayload(container, body, options) {
196
+ return {
197
+ type: "database",
198
+ subtype: "cosmosdb",
199
+ operation: "create",
200
+ container,
201
+ body,
202
+ partitionKey: options?.partitionKey,
203
+ timeoutMs: options?.timeoutMs
204
+ };
205
+ }
206
+ function buildCosmosDBReplacePayload(container, id, body, options) {
207
+ return {
208
+ type: "database",
209
+ subtype: "cosmosdb",
210
+ operation: "replace",
211
+ container,
212
+ id,
213
+ body,
214
+ partitionKey: options?.partitionKey,
215
+ timeoutMs: options?.timeoutMs
216
+ };
217
+ }
218
+ function buildCosmosDBUpsertPayload(container, body, options) {
219
+ return {
220
+ type: "database",
221
+ subtype: "cosmosdb",
222
+ operation: "upsert",
223
+ container,
224
+ body,
225
+ partitionKey: options?.partitionKey,
226
+ timeoutMs: options?.timeoutMs
227
+ };
228
+ }
229
+ function buildCosmosDBDeletePayload(container, id, options) {
230
+ return {
231
+ type: "database",
232
+ subtype: "cosmosdb",
233
+ operation: "delete",
234
+ container,
235
+ id,
236
+ partitionKey: options?.partitionKey,
237
+ timeoutMs: options?.timeoutMs
238
+ };
239
+ }
240
+ function buildCosmosDBPatchPayload(container, id, patchOperations, options) {
241
+ return {
242
+ type: "database",
243
+ subtype: "cosmosdb",
244
+ operation: "patch",
245
+ container,
246
+ id,
247
+ patchOperations,
248
+ partitionKey: options?.partitionKey,
249
+ condition: options?.condition,
250
+ timeoutMs: options?.timeoutMs
251
+ };
252
+ }
253
+
254
+ // src/clients/cosmosdb.ts
255
+ var CosmosDBResourceClient = class extends BaseResourceClient {
256
+ /**
257
+ * Invoke a CosmosDB operation with a raw payload
258
+ * @param payload The complete operation payload
259
+ * @param invocationKey Unique key for tracking this invocation
260
+ */
261
+ async invoke(payload, invocationKey) {
262
+ return this.invokeRaw(buildCosmosDBInvokePayload(payload), invocationKey);
263
+ }
264
+ /**
265
+ * Execute a SQL query against a container
266
+ * @param container The container name
267
+ * @param query The SQL query string
268
+ * @param invocationKey Unique key for tracking this invocation
269
+ * @param options Query options (parameters, partitionKey, pagination)
270
+ */
271
+ async query(container, query, invocationKey, options) {
272
+ const payload = buildCosmosDBQueryPayload(container, query, options);
273
+ return this.invokeRaw(payload, invocationKey);
274
+ }
275
+ /**
276
+ * Read a single document by ID
277
+ * @param container The container name
278
+ * @param id The document ID
279
+ * @param invocationKey Unique key for tracking this invocation
280
+ * @param options Additional options (partitionKey, timeoutMs)
281
+ */
282
+ async read(container, id, invocationKey, options) {
283
+ const payload = buildCosmosDBReadPayload(container, id, options);
284
+ return this.invokeRaw(payload, invocationKey);
285
+ }
286
+ /**
287
+ * Create a new document
288
+ * @param container The container name
289
+ * @param body The document body (must include id and partition key properties)
290
+ * @param invocationKey Unique key for tracking this invocation
291
+ * @param options Additional options (partitionKey, timeoutMs)
292
+ */
293
+ async create(container, body, invocationKey, options) {
294
+ const payload = buildCosmosDBCreatePayload(container, body, options);
295
+ return this.invokeRaw(payload, invocationKey);
296
+ }
297
+ /**
298
+ * Replace an existing document
299
+ * @param container The container name
300
+ * @param id The document ID
301
+ * @param body The new document body
302
+ * @param invocationKey Unique key for tracking this invocation
303
+ * @param options Additional options (partitionKey, timeoutMs)
304
+ */
305
+ async replace(container, id, body, invocationKey, options) {
306
+ const payload = buildCosmosDBReplacePayload(container, id, body, options);
307
+ return this.invokeRaw(payload, invocationKey);
308
+ }
309
+ /**
310
+ * Upsert a document (insert or replace)
311
+ * @param container The container name
312
+ * @param body The document body (must include id and partition key properties)
313
+ * @param invocationKey Unique key for tracking this invocation
314
+ * @param options Additional options (partitionKey, timeoutMs)
315
+ */
316
+ async upsert(container, body, invocationKey, options) {
317
+ const payload = buildCosmosDBUpsertPayload(container, body, options);
318
+ return this.invokeRaw(payload, invocationKey);
319
+ }
320
+ /**
321
+ * Delete a document
322
+ * @param container The container name
323
+ * @param id The document ID
324
+ * @param invocationKey Unique key for tracking this invocation
325
+ * @param options Additional options (partitionKey, timeoutMs)
326
+ */
327
+ async delete(container, id, invocationKey, options) {
328
+ const payload = buildCosmosDBDeletePayload(container, id, options);
329
+ return this.invokeRaw(payload, invocationKey);
330
+ }
331
+ /**
332
+ * Patch a document with partial updates
333
+ * @param container The container name
334
+ * @param id The document ID
335
+ * @param patchOperations Array of patch operations
336
+ * @param invocationKey Unique key for tracking this invocation
337
+ * @param options Additional options (partitionKey, condition, timeoutMs)
338
+ */
339
+ async patch(container, id, patchOperations, invocationKey, options) {
340
+ const payload = buildCosmosDBPatchPayload(container, id, patchOperations, options);
341
+ return this.invokeRaw(payload, invocationKey);
342
+ }
343
+ };
344
+
345
+ // src/payload-builders/snowflake.ts
346
+ function buildSnowflakeInvokePayload(payload) {
347
+ return payload;
348
+ }
349
+ function buildSnowflakeExecutePayload(statement, options) {
350
+ return {
351
+ type: "database",
352
+ subtype: "snowflake",
353
+ operation: "execute",
354
+ statement,
355
+ bindings: options?.bindings,
356
+ database: options?.database,
357
+ schema: options?.schema,
358
+ warehouse: options?.warehouse,
359
+ role: options?.role,
360
+ timeout: options?.timeout,
361
+ async: options?.async,
362
+ parameters: options?.parameters,
363
+ nullable: options?.nullable,
364
+ requestId: options?.requestId
365
+ };
366
+ }
367
+ function buildSnowflakeStatusPayload(statementHandle, options) {
368
+ return {
369
+ type: "database",
370
+ subtype: "snowflake",
371
+ operation: "status",
372
+ statementHandle,
373
+ partition: options?.partition
374
+ };
375
+ }
376
+ function buildSnowflakeCancelPayload(statementHandle) {
377
+ return {
378
+ type: "database",
379
+ subtype: "snowflake",
380
+ operation: "cancel",
381
+ statementHandle
382
+ };
383
+ }
384
+
385
+ // src/clients/snowflake.ts
386
+ var SnowflakeResourceClient = class extends BaseResourceClient {
387
+ /**
388
+ * Invoke a Snowflake operation with a raw payload
389
+ * @param payload The complete operation payload
390
+ * @param invocationKey Unique key for tracking this invocation
391
+ */
392
+ async invoke(payload, invocationKey) {
393
+ return this.invokeRaw(buildSnowflakeInvokePayload(payload), invocationKey);
394
+ }
395
+ /**
396
+ * Execute a SQL statement
397
+ * @param statement The SQL statement to execute
398
+ * @param invocationKey Unique key for tracking this invocation
399
+ * @param options Execution options (bindings, database overrides, async, etc.)
400
+ */
401
+ async execute(statement, invocationKey, options = {}) {
402
+ const payload = buildSnowflakeExecutePayload(statement, options);
403
+ return this.invokeRaw(payload, invocationKey);
404
+ }
405
+ /**
406
+ * Get status or results of a statement
407
+ * @param statementHandle The statement handle from execute operation
408
+ * @param invocationKey Unique key for tracking this invocation
409
+ * @param options Status options (partition for paginated results)
410
+ */
411
+ async status(statementHandle, invocationKey, options = {}) {
412
+ const payload = buildSnowflakeStatusPayload(statementHandle, options);
413
+ return this.invokeRaw(payload, invocationKey);
414
+ }
415
+ /**
416
+ * Cancel a running statement
417
+ * @param statementHandle The statement handle to cancel
418
+ * @param invocationKey Unique key for tracking this invocation
419
+ */
420
+ async cancel(statementHandle, invocationKey) {
421
+ const payload = buildSnowflakeCancelPayload(statementHandle);
422
+ return this.invokeRaw(payload, invocationKey);
423
+ }
424
+ };
425
+
426
+ // src/payload-builders/custom.ts
427
+ function buildCustomApiInvokePayload(method, path, options) {
428
+ return {
429
+ type: "api",
430
+ subtype: "custom",
431
+ method,
432
+ path,
433
+ query: options?.query,
434
+ headers: options?.headers,
435
+ body: options?.body,
436
+ timeoutMs: options?.timeoutMs ?? 3e4
437
+ };
438
+ }
439
+
440
+ // src/clients/api-custom.ts
441
+ var CustomApiResourceClient = class extends BaseResourceClient {
442
+ async invoke(method, path, invocationKey, options = {}) {
443
+ const payload = buildCustomApiInvokePayload(method, path, options);
444
+ return this.invokeRaw(payload, invocationKey);
445
+ }
446
+ };
447
+
448
+ // src/payload-builders/hubspot.ts
449
+ function buildHubSpotInvokePayload(method, path, options) {
450
+ return {
451
+ type: "api",
452
+ subtype: "hubspot",
453
+ method,
454
+ path,
455
+ query: options?.query,
456
+ body: options?.body,
457
+ timeoutMs: options?.timeoutMs ?? 3e4
458
+ };
459
+ }
460
+
461
+ // src/clients/hubspot.ts
462
+ var HubSpotResourceClient = class extends BaseResourceClient {
463
+ async invoke(method, path, invocationKey, options = {}) {
464
+ const payload = buildHubSpotInvokePayload(method, path, options);
465
+ return this.invokeRaw(payload, invocationKey);
466
+ }
467
+ };
468
+
469
+ // src/payload-builders/salesforce.ts
470
+ function buildSalesforceInvokePayload(method, path, options) {
471
+ return {
472
+ type: "api",
473
+ subtype: "salesforce",
474
+ method,
475
+ path,
476
+ query: options?.query,
477
+ body: options?.body,
478
+ timeoutMs: options?.timeoutMs ?? 3e4
479
+ };
480
+ }
481
+ function buildSalesforceQueryPayload(query, options) {
482
+ return buildSalesforceInvokePayload("GET", "/services/data/v63.0/query", {
483
+ query: { q: [query] },
484
+ timeoutMs: options?.timeoutMs
485
+ });
486
+ }
487
+ function buildSalesforceGetRecordPayload(objectType, recordId, options) {
488
+ const query = {};
489
+ if (options?.fields && options.fields.length > 0) {
490
+ query.fields = [options.fields.join(",")];
491
+ }
492
+ return buildSalesforceInvokePayload(
493
+ "GET",
494
+ `/services/data/v63.0/sobjects/${objectType}/${recordId}`,
495
+ {
496
+ query: Object.keys(query).length > 0 ? query : void 0,
497
+ timeoutMs: options?.timeoutMs
498
+ }
499
+ );
500
+ }
501
+ function buildSalesforceCreateRecordPayload(objectType, data, options) {
502
+ return buildSalesforceInvokePayload(
503
+ "POST",
504
+ `/services/data/v63.0/sobjects/${objectType}`,
505
+ {
506
+ body: { type: "json", value: data },
507
+ timeoutMs: options?.timeoutMs
508
+ }
509
+ );
510
+ }
511
+ function buildSalesforceUpdateRecordPayload(objectType, recordId, data, options) {
512
+ return buildSalesforceInvokePayload(
513
+ "PATCH",
514
+ `/services/data/v63.0/sobjects/${objectType}/${recordId}`,
515
+ {
516
+ body: { type: "json", value: data },
517
+ timeoutMs: options?.timeoutMs
518
+ }
519
+ );
520
+ }
521
+ function buildSalesforceDeleteRecordPayload(objectType, recordId, options) {
522
+ return buildSalesforceInvokePayload(
523
+ "DELETE",
524
+ `/services/data/v63.0/sobjects/${objectType}/${recordId}`,
525
+ {
526
+ timeoutMs: options?.timeoutMs
527
+ }
528
+ );
529
+ }
530
+ function buildSalesforceDescribeObjectPayload(objectType, options) {
531
+ return buildSalesforceInvokePayload(
532
+ "GET",
533
+ `/services/data/v63.0/sobjects/${objectType}/describe`,
534
+ {
535
+ timeoutMs: options?.timeoutMs
536
+ }
537
+ );
538
+ }
539
+
540
+ // src/clients/salesforce.ts
541
+ var SalesforceResourceClient = class extends BaseResourceClient {
542
+ /**
543
+ * Invoke a Salesforce API request
544
+ *
545
+ * @param method - HTTP method (GET, POST, PATCH, DELETE)
546
+ * @param path - Salesforce API path (e.g., "/services/data/v63.0/query")
547
+ * @param invocationKey - Unique key for this invocation (for tracking)
548
+ * @param options - Optional query params, body, and timeout
549
+ * @returns The API response with status and body
550
+ */
551
+ async invoke(method, path, invocationKey, options = {}) {
552
+ const payload = buildSalesforceInvokePayload(method, path, options);
553
+ return this.invokeRaw(payload, invocationKey);
554
+ }
555
+ /**
556
+ * Execute a SOQL query
557
+ *
558
+ * @param query - SOQL query string
559
+ * @param invocationKey - Unique key for this invocation
560
+ * @param options - Optional timeout
561
+ * @returns Query results
562
+ *
563
+ * @example
564
+ * ```typescript
565
+ * const result = await client.query(
566
+ * "SELECT Id, Name, CreatedDate FROM Account WHERE CreatedDate > 2024-01-01T00:00:00Z",
567
+ * "recent-accounts"
568
+ * );
569
+ * ```
570
+ */
571
+ async query(query, invocationKey, options = {}) {
572
+ return this.invoke("GET", "/services/data/v63.0/query", invocationKey, {
573
+ query: { q: [query] },
574
+ timeoutMs: options.timeoutMs
575
+ });
576
+ }
577
+ /**
578
+ * Get a single record by ID
579
+ *
580
+ * @param objectType - Salesforce object type (e.g., "Account", "Contact")
581
+ * @param recordId - The record ID
582
+ * @param invocationKey - Unique key for this invocation
583
+ * @param options - Optional fields to retrieve and timeout
584
+ * @returns The record data
585
+ */
586
+ async getRecord(objectType, recordId, invocationKey, options = {}) {
587
+ const query = {};
588
+ if (options.fields && options.fields.length > 0) {
589
+ query.fields = [options.fields.join(",")];
590
+ }
591
+ return this.invoke(
592
+ "GET",
593
+ `/services/data/v63.0/sobjects/${objectType}/${recordId}`,
594
+ invocationKey,
595
+ { query: Object.keys(query).length > 0 ? query : void 0, timeoutMs: options.timeoutMs }
596
+ );
597
+ }
598
+ /**
599
+ * Create a new record
600
+ *
601
+ * @param objectType - Salesforce object type (e.g., "Account", "Contact")
602
+ * @param data - Record data
603
+ * @param invocationKey - Unique key for this invocation
604
+ * @param options - Optional timeout
605
+ * @returns The created record ID
606
+ */
607
+ async createRecord(objectType, data, invocationKey, options = {}) {
608
+ return this.invoke(
609
+ "POST",
610
+ `/services/data/v63.0/sobjects/${objectType}`,
611
+ invocationKey,
612
+ { body: { type: "json", value: data }, timeoutMs: options.timeoutMs }
613
+ );
614
+ }
615
+ /**
616
+ * Update an existing record
617
+ *
618
+ * @param objectType - Salesforce object type (e.g., "Account", "Contact")
619
+ * @param recordId - The record ID to update
620
+ * @param data - Fields to update
621
+ * @param invocationKey - Unique key for this invocation
622
+ * @param options - Optional timeout
623
+ * @returns Empty response on success
624
+ */
625
+ async updateRecord(objectType, recordId, data, invocationKey, options = {}) {
626
+ return this.invoke(
627
+ "PATCH",
628
+ `/services/data/v63.0/sobjects/${objectType}/${recordId}`,
629
+ invocationKey,
630
+ { body: { type: "json", value: data }, timeoutMs: options.timeoutMs }
631
+ );
632
+ }
633
+ /**
634
+ * Delete a record
635
+ *
636
+ * @param objectType - Salesforce object type (e.g., "Account", "Contact")
637
+ * @param recordId - The record ID to delete
638
+ * @param invocationKey - Unique key for this invocation
639
+ * @param options - Optional timeout
640
+ * @returns Empty response on success
641
+ */
642
+ async deleteRecord(objectType, recordId, invocationKey, options = {}) {
643
+ return this.invoke(
644
+ "DELETE",
645
+ `/services/data/v63.0/sobjects/${objectType}/${recordId}`,
646
+ invocationKey,
647
+ { timeoutMs: options.timeoutMs }
648
+ );
649
+ }
650
+ /**
651
+ * Describe an object to get its metadata
652
+ *
653
+ * @param objectType - Salesforce object type (e.g., "Account", "Contact")
654
+ * @param invocationKey - Unique key for this invocation
655
+ * @param options - Optional timeout
656
+ * @returns Object metadata including fields, relationships, etc.
657
+ */
658
+ async describeObject(objectType, invocationKey, options = {}) {
659
+ return this.invoke(
660
+ "GET",
661
+ `/services/data/v63.0/sobjects/${objectType}/describe`,
662
+ invocationKey,
663
+ { timeoutMs: options.timeoutMs }
664
+ );
665
+ }
666
+ };
667
+
668
+ // src/payload-builders/googlesheets.ts
669
+ function buildGoogleSheetsInvokePayload(method, path, options) {
670
+ return {
671
+ type: "api",
672
+ subtype: "googlesheets",
673
+ method,
674
+ path,
675
+ query: options?.query,
676
+ body: options?.body,
677
+ timeoutMs: options?.timeoutMs ?? 3e4
678
+ };
679
+ }
680
+ function buildGoogleSheetsGetValuesPayload(range, options) {
681
+ return buildGoogleSheetsInvokePayload("GET", `/values/${range}`, {
682
+ timeoutMs: options?.timeoutMs
683
+ });
684
+ }
685
+ function buildGoogleSheetsUpdateValuesPayload(range, values, valueInputOption = "USER_ENTERED", options) {
686
+ return buildGoogleSheetsInvokePayload("PUT", `/values/${range}`, {
687
+ query: { valueInputOption: [valueInputOption] },
688
+ body: { type: "json", value: { values } },
689
+ timeoutMs: options?.timeoutMs
690
+ });
691
+ }
692
+ function buildGoogleSheetsAppendValuesPayload(range, values, valueInputOption = "USER_ENTERED", options) {
693
+ return buildGoogleSheetsInvokePayload("POST", `/values/${range}:append`, {
694
+ query: { valueInputOption: [valueInputOption] },
695
+ body: { type: "json", value: { values } },
696
+ timeoutMs: options?.timeoutMs
697
+ });
698
+ }
699
+ function buildGoogleSheetsClearValuesPayload(range, options) {
700
+ return buildGoogleSheetsInvokePayload("POST", `/values/${range}:clear`, {
701
+ timeoutMs: options?.timeoutMs
702
+ });
703
+ }
704
+ function buildGoogleSheetsBatchGetValuesPayload(ranges, options) {
705
+ return buildGoogleSheetsInvokePayload("GET", "/values:batchGet", {
706
+ query: { ranges },
707
+ timeoutMs: options?.timeoutMs
708
+ });
709
+ }
710
+ function buildGoogleSheetsBatchUpdateValuesPayload(data, valueInputOption = "USER_ENTERED", options) {
711
+ return buildGoogleSheetsInvokePayload("POST", "/values:batchUpdate", {
712
+ body: {
713
+ type: "json",
714
+ value: {
715
+ valueInputOption,
716
+ data
717
+ }
718
+ },
719
+ timeoutMs: options?.timeoutMs
720
+ });
721
+ }
722
+ function buildGoogleSheetsGetSpreadsheetPayload(options) {
723
+ return buildGoogleSheetsInvokePayload("GET", "/", {
724
+ timeoutMs: options?.timeoutMs
725
+ });
726
+ }
727
+ function buildGoogleSheetsBatchUpdatePayload(requests, options) {
728
+ return buildGoogleSheetsInvokePayload("POST", "/:batchUpdate", {
729
+ body: { type: "json", value: { requests } },
730
+ timeoutMs: options?.timeoutMs
731
+ });
732
+ }
733
+
734
+ // src/clients/googlesheets.ts
735
+ var GoogleSheetsResourceClient = class extends BaseResourceClient {
736
+ async invoke(method, path, invocationKey, options = {}) {
737
+ const payload = buildGoogleSheetsInvokePayload(method, path, options);
738
+ return this.invokeRaw(payload, invocationKey);
739
+ }
740
+ /**
741
+ * Get values from a range in the spreadsheet
742
+ * @param range A1 notation range (e.g., "Sheet1!A1:D5")
743
+ * @param invocationKey Unique key for tracking this invocation
744
+ */
745
+ async getValues(range, invocationKey) {
746
+ return this.invoke("GET", `/values/${range}`, invocationKey);
747
+ }
748
+ /**
749
+ * Update values in a range in the spreadsheet
750
+ * @param range A1 notation range (e.g., "Sheet1!A1:D5")
751
+ * @param values 2D array of values to write
752
+ * @param invocationKey Unique key for tracking this invocation
753
+ * @param valueInputOption How to interpret input values ("RAW" or "USER_ENTERED")
754
+ */
755
+ async updateValues(range, values, invocationKey, valueInputOption = "USER_ENTERED") {
756
+ return this.invoke(
757
+ "PUT",
758
+ `/values/${range}`,
759
+ invocationKey,
760
+ {
761
+ query: { valueInputOption },
762
+ body: { type: "json", value: { values } }
763
+ }
764
+ );
765
+ }
766
+ /**
767
+ * Append values to a sheet
768
+ * @param range A1 notation range (e.g., "Sheet1!A1:D1")
769
+ * @param values 2D array of values to append
770
+ * @param invocationKey Unique key for tracking this invocation
771
+ * @param valueInputOption How to interpret input values ("RAW" or "USER_ENTERED")
772
+ */
773
+ async appendValues(range, values, invocationKey, valueInputOption = "USER_ENTERED") {
774
+ return this.invoke(
775
+ "POST",
776
+ `/values/${range}:append`,
777
+ invocationKey,
778
+ {
779
+ query: { valueInputOption },
780
+ body: { type: "json", value: { values } }
781
+ }
782
+ );
783
+ }
784
+ /**
785
+ * Clear values in a range
786
+ * @param range A1 notation range (e.g., "Sheet1!A1:D5")
787
+ * @param invocationKey Unique key for tracking this invocation
788
+ */
789
+ async clearValues(range, invocationKey) {
790
+ return this.invoke("POST", `/values/${range}:clear`, invocationKey);
791
+ }
792
+ /**
793
+ * Batch get multiple ranges
794
+ * @param ranges Array of A1 notation ranges
795
+ * @param invocationKey Unique key for tracking this invocation
796
+ */
797
+ async batchGetValues(ranges, invocationKey) {
798
+ return this.invoke("GET", "/values:batchGet", invocationKey, {
799
+ query: { ranges }
800
+ });
801
+ }
802
+ /**
803
+ * Batch update multiple ranges
804
+ * @param data Array of range updates
805
+ * @param invocationKey Unique key for tracking this invocation
806
+ * @param valueInputOption How to interpret input values ("RAW" or "USER_ENTERED")
807
+ */
808
+ async batchUpdateValues(data, invocationKey, valueInputOption = "USER_ENTERED") {
809
+ return this.invoke("POST", "/values:batchUpdate", invocationKey, {
810
+ body: {
811
+ type: "json",
812
+ value: {
813
+ valueInputOption,
814
+ data
815
+ }
816
+ }
817
+ });
818
+ }
819
+ /**
820
+ * Get spreadsheet metadata
821
+ * @param invocationKey Unique key for tracking this invocation
822
+ */
823
+ async getSpreadsheet(invocationKey) {
824
+ return this.invoke("GET", "/", invocationKey);
825
+ }
826
+ /**
827
+ * Batch update spreadsheet (for formatting, creating sheets, etc.)
828
+ * @param requests Array of update requests
829
+ * @param invocationKey Unique key for tracking this invocation
830
+ */
831
+ async batchUpdate(requests, invocationKey) {
832
+ return this.invoke("POST", "/:batchUpdate", invocationKey, {
833
+ body: { type: "json", value: { requests } }
834
+ });
835
+ }
836
+ };
837
+
838
+ // src/payload-builders/s3.ts
839
+ function buildS3InvokePayload(command, params, options) {
840
+ return {
841
+ type: "storage",
842
+ subtype: "s3",
843
+ command,
844
+ params,
845
+ timeoutMs: options?.timeoutMs
846
+ };
847
+ }
848
+
849
+ // src/clients/s3.ts
850
+ var S3ResourceClient = class extends BaseResourceClient {
851
+ async invoke(command, params, invocationKey, options = {}) {
852
+ const payload = buildS3InvokePayload(command, params, options);
853
+ return this.invokeRaw(payload, invocationKey);
854
+ }
855
+ };
856
+
857
+ // src/payload-builders/lambda.ts
858
+ function buildLambdaInvokePayload(functionName, payload, options) {
859
+ return {
860
+ type: "api",
861
+ subtype: "lambda",
862
+ FunctionName: functionName,
863
+ Payload: payload,
864
+ ...options
865
+ };
866
+ }
867
+
868
+ // src/clients/lambda.ts
869
+ var LambdaResourceClient = class extends BaseResourceClient {
870
+ /**
871
+ * Invoke a Lambda function
872
+ *
873
+ * @param functionName - The name, ARN, or partial ARN of the Lambda function
874
+ * @param payload - The JSON input for the Lambda function (optional)
875
+ * @param invocationKey - A unique key for tracking this invocation
876
+ * @param options - Additional invocation options
877
+ * @returns The Lambda invocation result
878
+ *
879
+ * @example
880
+ * ```typescript
881
+ * // Simple synchronous invocation
882
+ * const result = await lambdaClient.invoke(
883
+ * "my-function",
884
+ * { key: "value" },
885
+ * "process-data"
886
+ * );
887
+ *
888
+ * if (result.ok) {
889
+ * console.log("Response:", result.result.Payload);
890
+ * }
891
+ *
892
+ * // Asynchronous invocation
893
+ * const asyncResult = await lambdaClient.invoke(
894
+ * "my-function",
895
+ * { key: "value" },
896
+ * "async-process",
897
+ * { InvocationType: "Event" }
898
+ * );
899
+ *
900
+ * // With execution logs
901
+ * const debugResult = await lambdaClient.invoke(
902
+ * "my-function",
903
+ * { key: "value" },
904
+ * "debug-invocation",
905
+ * { LogType: "Tail" }
906
+ * );
907
+ *
908
+ * if (debugResult.ok) {
909
+ * // LogResult is base64 encoded
910
+ * const logs = atob(debugResult.result.LogResult || "");
911
+ * console.log("Execution logs:", logs);
912
+ * }
913
+ * ```
914
+ */
915
+ async invoke(functionName, payload, invocationKey, options = {}) {
916
+ const invokePayload = buildLambdaInvokePayload(functionName, payload, options);
917
+ return this.invokeRaw(invokePayload, invocationKey);
918
+ }
919
+ };
920
+
921
+ // src/payload-builders/bigquery.ts
922
+ function buildBigQueryQueryPayload(sql, params, options) {
923
+ return {
924
+ type: "database",
925
+ subtype: "bigquery",
926
+ operation: "query",
927
+ sql,
928
+ params,
929
+ timeoutMs: options?.timeoutMs,
930
+ maxResults: options?.maxResults
931
+ };
932
+ }
933
+ function buildBigQueryListDatasetsPayload(options) {
934
+ return {
935
+ type: "database",
936
+ subtype: "bigquery",
937
+ operation: "listDatasets",
938
+ maxResults: options?.maxResults
939
+ };
940
+ }
941
+ function buildBigQueryListTablesPayload(datasetId, options) {
942
+ return {
943
+ type: "database",
944
+ subtype: "bigquery",
945
+ operation: "listTables",
946
+ datasetId,
947
+ maxResults: options?.maxResults
948
+ };
949
+ }
950
+ function buildBigQueryGetTablePayload(datasetId, tableId) {
951
+ return {
952
+ type: "database",
953
+ subtype: "bigquery",
954
+ operation: "getTable",
955
+ datasetId,
956
+ tableId
957
+ };
958
+ }
959
+ function buildBigQueryInsertRowsPayload(datasetId, tableId, rows) {
960
+ return {
961
+ type: "database",
962
+ subtype: "bigquery",
963
+ operation: "insertRows",
964
+ datasetId,
965
+ tableId,
966
+ rows
967
+ };
968
+ }
969
+ function buildBigQueryCreateTablePayload(datasetId, tableId, schema, options) {
970
+ return {
971
+ type: "database",
972
+ subtype: "bigquery",
973
+ operation: "createTable",
974
+ datasetId,
975
+ tableId,
976
+ schema,
977
+ timeoutMs: options?.timeoutMs
978
+ };
979
+ }
980
+ function buildBigQueryInvokePayload(payload) {
981
+ return {
982
+ type: "database",
983
+ subtype: "bigquery",
984
+ ...payload
985
+ };
986
+ }
987
+
988
+ // src/clients/bigquery.ts
989
+ var BigQueryResourceClient = class extends BaseResourceClient {
990
+ /**
991
+ * Execute a SQL query
992
+ * @param sql The SQL query to execute
993
+ * @param params Optional query parameters (named parameters)
994
+ * @param invocationKey Unique key for tracking this invocation
995
+ * @param options Query options
996
+ */
997
+ async query(sql, params, invocationKey, options) {
998
+ const payload = buildBigQueryQueryPayload(sql, params, options);
999
+ return this.invokeRaw(payload, invocationKey);
1000
+ }
1001
+ /**
1002
+ * List all datasets in the project
1003
+ * @param invocationKey Unique key for tracking this invocation
1004
+ * @param options List options
1005
+ */
1006
+ async listDatasets(invocationKey, options) {
1007
+ const payload = buildBigQueryListDatasetsPayload(options);
1008
+ return this.invokeRaw(payload, invocationKey);
1009
+ }
1010
+ /**
1011
+ * List all tables in a dataset
1012
+ * @param datasetId The dataset ID
1013
+ * @param invocationKey Unique key for tracking this invocation
1014
+ * @param options List options
1015
+ */
1016
+ async listTables(datasetId, invocationKey, options) {
1017
+ const payload = buildBigQueryListTablesPayload(datasetId, options);
1018
+ return this.invokeRaw(payload, invocationKey);
1019
+ }
1020
+ /**
1021
+ * Get table metadata and schema
1022
+ * @param datasetId The dataset ID
1023
+ * @param tableId The table ID
1024
+ * @param invocationKey Unique key for tracking this invocation
1025
+ */
1026
+ async getTable(datasetId, tableId, invocationKey) {
1027
+ const payload = buildBigQueryGetTablePayload(datasetId, tableId);
1028
+ return this.invokeRaw(payload, invocationKey);
1029
+ }
1030
+ /**
1031
+ * Insert rows into a table (streaming insert)
1032
+ * @param datasetId The dataset ID
1033
+ * @param tableId The table ID
1034
+ * @param rows Array of rows to insert
1035
+ * @param invocationKey Unique key for tracking this invocation
1036
+ */
1037
+ async insertRows(datasetId, tableId, rows, invocationKey) {
1038
+ const payload = buildBigQueryInsertRowsPayload(datasetId, tableId, rows);
1039
+ return this.invokeRaw(payload, invocationKey);
1040
+ }
1041
+ /**
1042
+ * Create a new table
1043
+ * @param datasetId The dataset ID
1044
+ * @param tableId The table ID
1045
+ * @param schema Table schema definition
1046
+ * @param invocationKey Unique key for tracking this invocation
1047
+ * @param options Table creation options
1048
+ */
1049
+ async createTable(datasetId, tableId, schema, invocationKey, options) {
1050
+ const payload = buildBigQueryCreateTablePayload(datasetId, tableId, schema, options);
1051
+ return this.invokeRaw(payload, invocationKey);
1052
+ }
1053
+ /**
1054
+ * Raw invoke with a custom payload
1055
+ * @param payload The BigQuery payload
1056
+ * @param invocationKey Unique key for tracking this invocation
1057
+ */
1058
+ async invoke(payload, invocationKey) {
1059
+ const fullPayload = buildBigQueryInvokePayload(payload);
1060
+ return this.invokeRaw(fullPayload, invocationKey);
1061
+ }
1062
+ };
1063
+
1064
+ // src/clients/outreach.ts
1065
+ var OutreachResourceClient = class extends BaseResourceClient {
1066
+ /**
1067
+ * Invoke an Outreach API endpoint
1068
+ *
1069
+ * @param method - HTTP method (GET, POST, PUT, PATCH, DELETE)
1070
+ * @param path - Outreach API path (e.g., "/api/v2/prospects")
1071
+ * @param invocationKey - Unique key for this invocation (for idempotency/tracking)
1072
+ * @param options - Optional query params, body, and timeout
1073
+ */
1074
+ async invoke(method, path, invocationKey, options = {}) {
1075
+ const payload = {
1076
+ type: "api",
1077
+ subtype: "outreach",
1078
+ method,
1079
+ path,
1080
+ queryParams: options.queryParams,
1081
+ body: options.body,
1082
+ timeoutMs: options.timeoutMs || 3e4
1083
+ };
1084
+ return this.invokeRaw(payload, invocationKey);
1085
+ }
1086
+ };
1087
+
1088
+ // src/payload-builders/neo4j.ts
1089
+ function buildNeo4jInvokePayload(cypher, params, timeoutMs) {
1090
+ return {
1091
+ type: "database",
1092
+ subtype: "neo4j",
1093
+ cypher,
1094
+ params,
1095
+ timeoutMs
1096
+ };
1097
+ }
1098
+
1099
+ // src/clients/neo4j.ts
1100
+ var Neo4jResourceClient = class extends BaseResourceClient {
1101
+ /**
1102
+ * Execute a Cypher query against Neo4j
1103
+ * @param cypher The Cypher query to execute
1104
+ * @param params Optional named parameters for the query
1105
+ * @param invocationKey Unique key for tracking this invocation
1106
+ * @param timeoutMs Optional timeout in milliseconds
1107
+ * @returns Response with records and keys
1108
+ *
1109
+ * @example
1110
+ * ```ts
1111
+ * const response = await client.invoke(
1112
+ * "MATCH (n:Person {name: $name}) RETURN n",
1113
+ * { name: "Alice" },
1114
+ * "find-alice"
1115
+ * );
1116
+ *
1117
+ * if (response.ok) {
1118
+ * const records = response.result.records;
1119
+ * }
1120
+ * ```
1121
+ */
1122
+ async invoke(cypher, params, invocationKey, timeoutMs) {
1123
+ const payload = buildNeo4jInvokePayload(cypher, params, timeoutMs);
1124
+ return this.invokeRaw(payload, invocationKey);
1125
+ }
1126
+ };
1127
+
1128
+ // src/payload-builders/slack.ts
1129
+ function buildSlackInvokePayload(method, options) {
1130
+ return {
1131
+ type: "api",
1132
+ subtype: "slack",
1133
+ method,
1134
+ body: options?.body,
1135
+ timeoutMs: options?.timeoutMs ?? 3e4
1136
+ };
1137
+ }
1138
+ function buildSlackGetUploadURLPayload(filename, length, options) {
1139
+ return buildSlackInvokePayload("files.getUploadURLExternal", {
1140
+ body: {
1141
+ filename,
1142
+ length,
1143
+ alt_txt: options?.altText,
1144
+ snippet_type: options?.snippetType
1145
+ }
1146
+ });
1147
+ }
1148
+ function buildSlackCompleteUploadPayload(files, channelId, options) {
1149
+ return buildSlackInvokePayload("files.completeUploadExternal", {
1150
+ body: {
1151
+ files,
1152
+ channel_id: channelId,
1153
+ initial_comment: options?.initialComment,
1154
+ thread_ts: options?.threadTs
1155
+ }
1156
+ });
1157
+ }
1158
+
1159
+ // src/clients/slack.ts
1160
+ var SlackResourceClient = class extends BaseResourceClient {
1161
+ async invoke(method, invocationKey, options = {}) {
1162
+ const payload = buildSlackInvokePayload(method, options);
1163
+ return this.invokeRaw(payload, invocationKey);
1164
+ }
1165
+ /**
1166
+ * Get a pre-signed upload URL for uploading a file to Slack.
1167
+ * Step 1 of the file upload flow.
1168
+ * @see https://docs.slack.dev/reference/methods/files.getUploadURLExternal
1169
+ */
1170
+ async getUploadURL(filename, length, invocationKey, options) {
1171
+ return this.invoke("files.getUploadURLExternal", invocationKey, {
1172
+ body: {
1173
+ filename,
1174
+ length,
1175
+ alt_txt: options?.altText,
1176
+ snippet_type: options?.snippetType
1177
+ }
1178
+ });
1179
+ }
1180
+ /**
1181
+ * Complete a file upload and optionally share it to a channel.
1182
+ * Step 3 of the file upload flow (step 2 is uploading binary data to the URL from getUploadURL).
1183
+ * @see https://docs.slack.dev/reference/methods/files.completeUploadExternal
1184
+ */
1185
+ async completeUpload(files, channelId, invocationKey, options) {
1186
+ return this.invoke("files.completeUploadExternal", invocationKey, {
1187
+ body: {
1188
+ files,
1189
+ channel_id: channelId,
1190
+ initial_comment: options?.initialComment,
1191
+ thread_ts: options?.threadTs
1192
+ }
1193
+ });
1194
+ }
1195
+ };
1196
+
1197
+ // src/payload-builders/quickbooks.ts
1198
+ function buildQuickBooksInvokePayload(method, path, options) {
1199
+ return {
1200
+ type: "api",
1201
+ subtype: "quickbooks",
1202
+ method,
1203
+ path,
1204
+ query: options?.query,
1205
+ body: options?.body,
1206
+ timeoutMs: options?.timeoutMs ?? 3e4
1207
+ };
1208
+ }
1209
+ function buildQuickBooksQueryPayload(query, options) {
1210
+ return buildQuickBooksInvokePayload("GET", "/query", {
1211
+ query: { query: [query] },
1212
+ timeoutMs: options?.timeoutMs
1213
+ });
1214
+ }
1215
+
1216
+ // src/clients/quickbooks.ts
1217
+ var QuickBooksResourceClient = class extends BaseResourceClient {
1218
+ /**
1219
+ * Invoke a QuickBooks API request
1220
+ *
1221
+ * @param method - HTTP method (GET, POST, PUT, DELETE)
1222
+ * @param path - QuickBooks API path relative to /v3/company/{realmId}
1223
+ * @param invocationKey - Unique key for this invocation (for tracking)
1224
+ * @param options - Optional query params, body, and timeout
1225
+ * @returns The API response with status and body
1226
+ */
1227
+ async invoke(method, path, invocationKey, options = {}) {
1228
+ const payload = buildQuickBooksInvokePayload(method, path, options);
1229
+ return this.invokeRaw(payload, invocationKey);
1230
+ }
1231
+ /**
1232
+ * Execute a QuickBooks query using SQL-like syntax
1233
+ *
1234
+ * @param query - QuickBooks query string (e.g., "SELECT * FROM Customer WHERE DisplayName LIKE 'A%'")
1235
+ * @param invocationKey - Unique key for this invocation
1236
+ * @param options - Optional timeout
1237
+ * @returns Query results
1238
+ *
1239
+ * @example
1240
+ * ```typescript
1241
+ * const result = await client.query(
1242
+ * "SELECT * FROM Invoice WHERE TotalAmt > '100.00'",
1243
+ * "recent-invoices"
1244
+ * );
1245
+ * ```
1246
+ */
1247
+ async query(query, invocationKey, options = {}) {
1248
+ const payload = buildQuickBooksQueryPayload(query, options);
1249
+ return this.invokeRaw(payload, invocationKey);
1250
+ }
1251
+ };
1252
+
1253
+ // src/payload-builders/auth.ts
1254
+ function buildAuthShareAccessPayload(email) {
1255
+ return {
1256
+ type: "auth",
1257
+ subtype: "majorauth",
1258
+ action: "share",
1259
+ email
1260
+ };
1261
+ }
1262
+ function buildAuthRevokeAccessPayload(email) {
1263
+ return {
1264
+ type: "auth",
1265
+ subtype: "majorauth",
1266
+ action: "revoke",
1267
+ email
1268
+ };
1269
+ }
1270
+
1271
+ // src/clients/auth.ts
1272
+ var MajorAuthResourceClient = class extends BaseResourceClient {
1273
+ /**
1274
+ * Grant a user view access to this application by email.
1275
+ * If the user doesn't have an account, one will be created.
1276
+ * If the user isn't a member of the organization, they will be invited.
1277
+ */
1278
+ async shareAccess(email, invocationKey) {
1279
+ const payload = buildAuthShareAccessPayload(email);
1280
+ return this.invokeRaw(payload, invocationKey);
1281
+ }
1282
+ /**
1283
+ * Revoke a user's view access to this application by email.
1284
+ * Only removes app-level access; does not affect org membership or roles.
1285
+ */
1286
+ async revokeAccess(email, invocationKey) {
1287
+ const payload = buildAuthRevokeAccessPayload(email);
1288
+ return this.invokeRaw(payload, invocationKey);
1289
+ }
1290
+ };
1291
+
1292
+ // src/payload-builders/google-analytics.ts
1293
+ function buildGoogleAnalyticsRunReportPayload(dimensions, metrics, dateRanges, options) {
1294
+ return {
1295
+ type: "api",
1296
+ subtype: "googleanalytics",
1297
+ operation: "runReport",
1298
+ dimensions,
1299
+ metrics,
1300
+ dateRanges,
1301
+ dimensionFilter: options?.dimensionFilter,
1302
+ metricFilter: options?.metricFilter,
1303
+ orderBys: options?.orderBys,
1304
+ limit: options?.limit,
1305
+ offset: options?.offset
1306
+ };
1307
+ }
1308
+ function buildGoogleAnalyticsGetMetadataPayload() {
1309
+ return {
1310
+ type: "api",
1311
+ subtype: "googleanalytics",
1312
+ operation: "getMetadata"
1313
+ };
1314
+ }
1315
+ function buildGoogleAnalyticsRunRealtimeReportPayload(metrics, dimensions, limit) {
1316
+ return {
1317
+ type: "api",
1318
+ subtype: "googleanalytics",
1319
+ operation: "runRealtimeReport",
1320
+ metrics,
1321
+ dimensions,
1322
+ limit
1323
+ };
1324
+ }
1325
+ function buildGoogleAnalyticsListAccountsPayload(options) {
1326
+ return {
1327
+ type: "api",
1328
+ subtype: "googleanalytics",
1329
+ operation: "listAccounts",
1330
+ pageSize: options?.pageSize,
1331
+ pageToken: options?.pageToken
1332
+ };
1333
+ }
1334
+ function buildGoogleAnalyticsListPropertiesPayload(accountId, options) {
1335
+ return {
1336
+ type: "api",
1337
+ subtype: "googleanalytics",
1338
+ operation: "listProperties",
1339
+ accountId,
1340
+ pageSize: options?.pageSize,
1341
+ pageToken: options?.pageToken
1342
+ };
1343
+ }
1344
+ function buildGoogleAnalyticsListDataStreamsPayload(propertyId, options) {
1345
+ return {
1346
+ type: "api",
1347
+ subtype: "googleanalytics",
1348
+ operation: "listDataStreams",
1349
+ propertyId,
1350
+ pageSize: options?.pageSize,
1351
+ pageToken: options?.pageToken
1352
+ };
1353
+ }
1354
+ function buildGoogleAnalyticsInvokePayload(payload) {
1355
+ return {
1356
+ type: "api",
1357
+ subtype: "googleanalytics",
1358
+ ...payload
1359
+ };
1360
+ }
1361
+
1362
+ // src/clients/google-analytics.ts
1363
+ var GoogleAnalyticsResourceClient = class extends BaseResourceClient {
1364
+ /**
1365
+ * Run a GA4 report with dimensions, metrics, and date ranges
1366
+ * @param dimensions Dimensions to group by (e.g. [{name: 'country'}])
1367
+ * @param metrics Metrics to retrieve (e.g. [{name: 'activeUsers'}])
1368
+ * @param dateRanges Date ranges (e.g. [{startDate: '2024-01-01', endDate: '2024-01-31'}])
1369
+ * @param invocationKey Unique key for tracking this invocation
1370
+ * @param options Optional report options (filters, ordering, limit, offset)
1371
+ */
1372
+ async runReport(dimensions, metrics, dateRanges, invocationKey, options) {
1373
+ const payload = buildGoogleAnalyticsRunReportPayload(dimensions, metrics, dateRanges, options);
1374
+ return this.invokeRaw(payload, invocationKey);
1375
+ }
1376
+ /**
1377
+ * Get available dimensions and metrics for the GA4 property
1378
+ * @param invocationKey Unique key for tracking this invocation
1379
+ */
1380
+ async getMetadata(invocationKey) {
1381
+ const payload = buildGoogleAnalyticsGetMetadataPayload();
1382
+ return this.invokeRaw(payload, invocationKey);
1383
+ }
1384
+ /**
1385
+ * Run a realtime report showing current live user activity
1386
+ * @param metrics Metrics to retrieve (e.g. [{name: 'activeUsers'}])
1387
+ * @param invocationKey Unique key for tracking this invocation
1388
+ * @param dimensions Optional dimensions to group by
1389
+ * @param limit Optional row limit
1390
+ */
1391
+ async runRealtimeReport(metrics, invocationKey, dimensions, limit) {
1392
+ const payload = buildGoogleAnalyticsRunRealtimeReportPayload(metrics, dimensions, limit);
1393
+ return this.invokeRaw(payload, invocationKey);
1394
+ }
1395
+ /**
1396
+ * List all GA4 accounts accessible to the authenticated user
1397
+ * @param invocationKey Unique key for tracking this invocation
1398
+ * @param options Optional pagination options
1399
+ */
1400
+ async listAccounts(invocationKey, options) {
1401
+ const payload = buildGoogleAnalyticsListAccountsPayload(options);
1402
+ return this.invokeRaw(payload, invocationKey);
1403
+ }
1404
+ /**
1405
+ * List GA4 properties, optionally filtered by account
1406
+ * @param invocationKey Unique key for tracking this invocation
1407
+ * @param accountId Optional account filter (e.g. 'accounts/12345')
1408
+ * @param options Optional pagination options
1409
+ */
1410
+ async listProperties(invocationKey, accountId, options) {
1411
+ const payload = buildGoogleAnalyticsListPropertiesPayload(accountId, options);
1412
+ return this.invokeRaw(payload, invocationKey);
1413
+ }
1414
+ /**
1415
+ * List data streams for a GA4 property
1416
+ * @param invocationKey Unique key for tracking this invocation
1417
+ * @param propertyId Optional property ID (defaults to configured property)
1418
+ * @param options Optional pagination options
1419
+ */
1420
+ async listDataStreams(invocationKey, propertyId, options) {
1421
+ const payload = buildGoogleAnalyticsListDataStreamsPayload(propertyId, options);
1422
+ return this.invokeRaw(payload, invocationKey);
1423
+ }
1424
+ /**
1425
+ * Execute a raw Google Analytics operation
1426
+ * @param payload The raw operation payload
1427
+ * @param invocationKey Unique key for tracking this invocation
1428
+ */
1429
+ async invoke(payload, invocationKey) {
1430
+ const p = buildGoogleAnalyticsInvokePayload(payload);
1431
+ return this.invokeRaw(p, invocationKey);
1432
+ }
1433
+ };
1434
+
1435
+ // src/payload-builders/graphql.ts
1436
+ function buildGraphQLInvokePayload(query, options) {
1437
+ return {
1438
+ type: "api",
1439
+ subtype: "graphql",
1440
+ query,
1441
+ variables: options?.variables,
1442
+ operationName: options?.operationName,
1443
+ headers: options?.headers,
1444
+ timeoutMs: options?.timeoutMs ?? 3e4
1445
+ };
1446
+ }
1447
+
1448
+ // src/clients/api-graphql.ts
1449
+ var GraphQLResourceClient = class extends BaseResourceClient {
1450
+ async query(query, invocationKey, options = {}) {
1451
+ const payload = buildGraphQLInvokePayload(query, options);
1452
+ return this.invokeRaw(payload, invocationKey);
1453
+ }
1454
+ async mutate(mutation, invocationKey, options = {}) {
1455
+ const payload = buildGraphQLInvokePayload(mutation, options);
1456
+ return this.invokeRaw(payload, invocationKey);
1457
+ }
1458
+ };
1459
+
1460
+ // src/payload-builders/outreach.ts
1461
+ function buildOutreachInvokePayload(method, path, options) {
1462
+ return {
1463
+ type: "api",
1464
+ subtype: "outreach",
1465
+ method,
1466
+ path,
1467
+ queryParams: options?.queryParams,
1468
+ body: options?.body,
1469
+ timeoutMs: options?.timeoutMs ?? 3e4
1470
+ };
1471
+ }
1472
+
1473
+ // src/payload-builders/from-extracted-params.ts
1474
+ function isUndefinedParam(param) {
1475
+ return param.known === false && param.expression === "undefined";
1476
+ }
1477
+ function parseParamValue(value, valueType) {
1478
+ if (valueType === "object" || valueType === "list") {
1479
+ try {
1480
+ return JSON.parse(value);
1481
+ } catch {
1482
+ return value;
1483
+ }
1484
+ }
1485
+ if (valueType === "number") {
1486
+ const num = Number(value);
1487
+ return isNaN(num) ? value : num;
1488
+ }
1489
+ if (valueType === "boolean") {
1490
+ return value === "true";
1491
+ }
1492
+ return value;
1493
+ }
1494
+ function findParam(params, name) {
1495
+ const param = params.find((p) => p.name.toLowerCase() === name.toLowerCase());
1496
+ if (!param) return void 0;
1497
+ if (isUndefinedParam(param)) return void 0;
1498
+ return parseParamValue(param.value, param.valueType);
1499
+ }
1500
+ function buildPayloadFromExtractedParams(subtype, methodName, extractedParams) {
1501
+ switch (subtype) {
1502
+ // =========================================================================
1503
+ // PostgreSQL
1504
+ // =========================================================================
1505
+ case "postgresql": {
1506
+ const sql = findParam(extractedParams, "SQL");
1507
+ const params = findParam(extractedParams, "Params");
1508
+ const timeoutMs = findParam(extractedParams, "Timeout");
1509
+ return buildPostgresInvokePayload(sql, params, timeoutMs);
1510
+ }
1511
+ // =========================================================================
1512
+ // DynamoDB
1513
+ // =========================================================================
1514
+ case "dynamodb": {
1515
+ const command = findParam(extractedParams, "Command");
1516
+ const params = findParam(extractedParams, "Params");
1517
+ return buildDynamoDBInvokePayload(command, params);
1518
+ }
1519
+ // =========================================================================
1520
+ // CosmosDB
1521
+ // =========================================================================
1522
+ case "cosmosdb": {
1523
+ if (methodName === "invoke") {
1524
+ const payload2 = findParam(extractedParams, "Payload");
1525
+ return buildCosmosDBInvokePayload(payload2);
1526
+ }
1527
+ if (methodName === "query") {
1528
+ const container = findParam(extractedParams, "Container");
1529
+ const query = findParam(extractedParams, "Query");
1530
+ const options = findParam(extractedParams, "Options");
1531
+ return buildCosmosDBQueryPayload(container, query, options);
1532
+ }
1533
+ if (methodName === "read") {
1534
+ const container = findParam(extractedParams, "Container");
1535
+ const id = findParam(extractedParams, "Id");
1536
+ const options = findParam(extractedParams, "Options");
1537
+ return buildCosmosDBReadPayload(container, id, options);
1538
+ }
1539
+ if (methodName === "create") {
1540
+ const container = findParam(extractedParams, "Container");
1541
+ const body = findParam(extractedParams, "Body");
1542
+ const options = findParam(extractedParams, "Options");
1543
+ return buildCosmosDBCreatePayload(container, body, options);
1544
+ }
1545
+ if (methodName === "replace") {
1546
+ const container = findParam(extractedParams, "Container");
1547
+ const id = findParam(extractedParams, "Id");
1548
+ const body = findParam(extractedParams, "Body");
1549
+ const options = findParam(extractedParams, "Options");
1550
+ return buildCosmosDBReplacePayload(container, id, body, options);
1551
+ }
1552
+ if (methodName === "upsert") {
1553
+ const container = findParam(extractedParams, "Container");
1554
+ const body = findParam(extractedParams, "Body");
1555
+ const options = findParam(extractedParams, "Options");
1556
+ return buildCosmosDBUpsertPayload(container, body, options);
1557
+ }
1558
+ if (methodName === "delete") {
1559
+ const container = findParam(extractedParams, "Container");
1560
+ const id = findParam(extractedParams, "Id");
1561
+ const options = findParam(extractedParams, "Options");
1562
+ return buildCosmosDBDeletePayload(container, id, options);
1563
+ }
1564
+ if (methodName === "patch") {
1565
+ const container = findParam(extractedParams, "Container");
1566
+ const id = findParam(extractedParams, "Id");
1567
+ const patchOperations = findParam(extractedParams, "PatchOperations");
1568
+ const options = findParam(extractedParams, "Options");
1569
+ return buildCosmosDBPatchPayload(container, id, patchOperations, options);
1570
+ }
1571
+ const payload = findParam(extractedParams, "Payload");
1572
+ return buildCosmosDBInvokePayload(payload);
1573
+ }
1574
+ // =========================================================================
1575
+ // MSSQL
1576
+ // =========================================================================
1577
+ case "mssql": {
1578
+ const sql = findParam(extractedParams, "SQL");
1579
+ const params = findParam(extractedParams, "Params");
1580
+ const timeoutMs = findParam(extractedParams, "Timeout");
1581
+ return buildMssqlInvokePayload(sql, params, timeoutMs);
1582
+ }
1583
+ // =========================================================================
1584
+ // Snowflake
1585
+ // =========================================================================
1586
+ case "snowflake": {
1587
+ if (methodName === "invoke") {
1588
+ const payload2 = findParam(extractedParams, "Payload");
1589
+ return buildSnowflakeInvokePayload(payload2);
1590
+ }
1591
+ if (methodName === "execute") {
1592
+ const statement = findParam(extractedParams, "Statement");
1593
+ const options = findParam(extractedParams, "Options");
1594
+ return buildSnowflakeExecutePayload(statement, options);
1595
+ }
1596
+ if (methodName === "status") {
1597
+ const statementHandle = findParam(extractedParams, "StatementHandle");
1598
+ const options = findParam(extractedParams, "Options");
1599
+ return buildSnowflakeStatusPayload(statementHandle, options);
1600
+ }
1601
+ if (methodName === "cancel") {
1602
+ const statementHandle = findParam(extractedParams, "StatementHandle");
1603
+ return buildSnowflakeCancelPayload(statementHandle);
1604
+ }
1605
+ const payload = findParam(extractedParams, "Payload");
1606
+ return buildSnowflakeInvokePayload(payload);
1607
+ }
1608
+ // =========================================================================
1609
+ // S3
1610
+ // =========================================================================
1611
+ case "s3": {
1612
+ const command = findParam(extractedParams, "Command");
1613
+ const params = findParam(extractedParams, "Params");
1614
+ const options = findParam(extractedParams, "Options");
1615
+ return buildS3InvokePayload(command, params, options);
1616
+ }
1617
+ // =========================================================================
1618
+ // Lambda
1619
+ // =========================================================================
1620
+ case "lambda": {
1621
+ const functionName = findParam(extractedParams, "FunctionName");
1622
+ const payload = findParam(extractedParams, "Payload");
1623
+ const options = findParam(extractedParams, "Options");
1624
+ return buildLambdaInvokePayload(functionName, payload, options);
1625
+ }
1626
+ // =========================================================================
1627
+ // Google Sheets
1628
+ // =========================================================================
1629
+ case "googlesheets": {
1630
+ if (methodName === "getValues") {
1631
+ const range = findParam(extractedParams, "Range");
1632
+ return buildGoogleSheetsGetValuesPayload(range);
1633
+ }
1634
+ if (methodName === "updateValues") {
1635
+ const range = findParam(extractedParams, "Range");
1636
+ const values = findParam(extractedParams, "Values");
1637
+ const valueInputOption = findParam(extractedParams, "ValueInputOption") ?? "USER_ENTERED";
1638
+ return buildGoogleSheetsUpdateValuesPayload(range, values, valueInputOption);
1639
+ }
1640
+ if (methodName === "appendValues") {
1641
+ const range = findParam(extractedParams, "Range");
1642
+ const values = findParam(extractedParams, "Values");
1643
+ const valueInputOption = findParam(extractedParams, "ValueInputOption") ?? "USER_ENTERED";
1644
+ return buildGoogleSheetsAppendValuesPayload(range, values, valueInputOption);
1645
+ }
1646
+ if (methodName === "clearValues") {
1647
+ const range = findParam(extractedParams, "Range");
1648
+ return buildGoogleSheetsClearValuesPayload(range);
1649
+ }
1650
+ if (methodName === "batchGetValues") {
1651
+ const ranges = findParam(extractedParams, "Ranges");
1652
+ return buildGoogleSheetsBatchGetValuesPayload(ranges);
1653
+ }
1654
+ if (methodName === "batchUpdateValues") {
1655
+ const data = findParam(extractedParams, "Data");
1656
+ const valueInputOption = findParam(extractedParams, "ValueInputOption") ?? "USER_ENTERED";
1657
+ return buildGoogleSheetsBatchUpdateValuesPayload(data, valueInputOption);
1658
+ }
1659
+ if (methodName === "getSpreadsheet") {
1660
+ return buildGoogleSheetsGetSpreadsheetPayload();
1661
+ }
1662
+ if (methodName === "batchUpdate") {
1663
+ const requests = findParam(extractedParams, "Requests");
1664
+ return buildGoogleSheetsBatchUpdatePayload(requests);
1665
+ }
1666
+ const method = findParam(extractedParams, "Method");
1667
+ const path = findParam(extractedParams, "Path");
1668
+ const options = findParam(extractedParams, "Options");
1669
+ return buildGoogleSheetsInvokePayload(method, path, options);
1670
+ }
1671
+ // =========================================================================
1672
+ // HubSpot
1673
+ // =========================================================================
1674
+ case "hubspot": {
1675
+ const method = findParam(extractedParams, "Method");
1676
+ const path = findParam(extractedParams, "Path");
1677
+ const options = findParam(extractedParams, "Options");
1678
+ return buildHubSpotInvokePayload(method, path, options);
1679
+ }
1680
+ // =========================================================================
1681
+ // Salesforce
1682
+ // =========================================================================
1683
+ case "salesforce": {
1684
+ if (methodName === "query") {
1685
+ const query = findParam(extractedParams, "Query");
1686
+ return buildSalesforceQueryPayload(query);
1687
+ }
1688
+ if (methodName === "getRecord") {
1689
+ const objectType = findParam(extractedParams, "ObjectType");
1690
+ const recordId = findParam(extractedParams, "RecordId");
1691
+ return buildSalesforceGetRecordPayload(objectType, recordId);
1692
+ }
1693
+ if (methodName === "createRecord") {
1694
+ const objectType = findParam(extractedParams, "ObjectType");
1695
+ const data = findParam(extractedParams, "Data");
1696
+ return buildSalesforceCreateRecordPayload(objectType, data);
1697
+ }
1698
+ if (methodName === "updateRecord") {
1699
+ const objectType = findParam(extractedParams, "ObjectType");
1700
+ const recordId = findParam(extractedParams, "RecordId");
1701
+ const data = findParam(extractedParams, "Data");
1702
+ return buildSalesforceUpdateRecordPayload(objectType, recordId, data);
1703
+ }
1704
+ if (methodName === "deleteRecord") {
1705
+ const objectType = findParam(extractedParams, "ObjectType");
1706
+ const recordId = findParam(extractedParams, "RecordId");
1707
+ return buildSalesforceDeleteRecordPayload(objectType, recordId);
1708
+ }
1709
+ if (methodName === "describeObject") {
1710
+ const objectType = findParam(extractedParams, "ObjectType");
1711
+ return buildSalesforceDescribeObjectPayload(objectType);
1712
+ }
1713
+ const method = findParam(extractedParams, "Method");
1714
+ const path = findParam(extractedParams, "Path");
1715
+ const options = findParam(extractedParams, "Options");
1716
+ return buildSalesforceInvokePayload(method, path, options);
1717
+ }
1718
+ // =========================================================================
1719
+ // Custom API
1720
+ // =========================================================================
1721
+ case "custom": {
1722
+ const method = findParam(extractedParams, "Method");
1723
+ const path = findParam(extractedParams, "Path");
1724
+ const options = findParam(extractedParams, "Options");
1725
+ return buildCustomApiInvokePayload(method, path, options);
1726
+ }
1727
+ // =========================================================================
1728
+ // BigQuery
1729
+ // =========================================================================
1730
+ case "bigquery": {
1731
+ if (methodName === "query") {
1732
+ const sql = findParam(extractedParams, "SQL");
1733
+ const params = findParam(extractedParams, "Params");
1734
+ const options = findParam(extractedParams, "Options");
1735
+ return buildBigQueryQueryPayload(sql, params, options);
1736
+ }
1737
+ if (methodName === "listDatasets") {
1738
+ const options = findParam(extractedParams, "Options");
1739
+ return buildBigQueryListDatasetsPayload(options);
1740
+ }
1741
+ if (methodName === "listTables") {
1742
+ const datasetId = findParam(extractedParams, "DatasetId");
1743
+ const options = findParam(extractedParams, "Options");
1744
+ return buildBigQueryListTablesPayload(datasetId, options);
1745
+ }
1746
+ if (methodName === "getTable") {
1747
+ const datasetId = findParam(extractedParams, "DatasetId");
1748
+ const tableId = findParam(extractedParams, "TableId");
1749
+ return buildBigQueryGetTablePayload(datasetId, tableId);
1750
+ }
1751
+ if (methodName === "insertRows") {
1752
+ const datasetId = findParam(extractedParams, "DatasetId");
1753
+ const tableId = findParam(extractedParams, "TableId");
1754
+ const rows = findParam(extractedParams, "Rows");
1755
+ return buildBigQueryInsertRowsPayload(datasetId, tableId, rows);
1756
+ }
1757
+ if (methodName === "createTable") {
1758
+ const datasetId = findParam(extractedParams, "DatasetId");
1759
+ const tableId = findParam(extractedParams, "TableId");
1760
+ const schema = findParam(extractedParams, "Schema");
1761
+ const options = findParam(extractedParams, "Options");
1762
+ return buildBigQueryCreateTablePayload(datasetId, tableId, schema, options);
1763
+ }
1764
+ const payload = findParam(extractedParams, "Payload");
1765
+ return buildBigQueryInvokePayload(payload);
1766
+ }
1767
+ // =========================================================================
1768
+ // Outreach
1769
+ // =========================================================================
1770
+ case "outreach": {
1771
+ const method = findParam(extractedParams, "Method");
1772
+ const path = findParam(extractedParams, "Path");
1773
+ const options = findParam(extractedParams, "Options");
1774
+ return buildOutreachInvokePayload(method, path, options);
1775
+ }
1776
+ // =========================================================================
1777
+ // Neo4j
1778
+ // =========================================================================
1779
+ case "neo4j": {
1780
+ const cypher = findParam(extractedParams, "Cypher");
1781
+ const params = findParam(extractedParams, "Params");
1782
+ const timeoutMs = findParam(extractedParams, "Timeout");
1783
+ return buildNeo4jInvokePayload(cypher, params, timeoutMs);
1784
+ }
1785
+ // =========================================================================
1786
+ // Slack
1787
+ // =========================================================================
1788
+ case "slack": {
1789
+ if (methodName === "getUploadURL") {
1790
+ const filename = findParam(extractedParams, "Filename");
1791
+ const length = findParam(extractedParams, "Length");
1792
+ const options2 = findParam(extractedParams, "Options");
1793
+ return buildSlackGetUploadURLPayload(filename, length, options2);
1794
+ }
1795
+ if (methodName === "completeUpload") {
1796
+ const files = findParam(extractedParams, "Files");
1797
+ const channelId = findParam(extractedParams, "ChannelId");
1798
+ const options2 = findParam(extractedParams, "Options");
1799
+ return buildSlackCompleteUploadPayload(files, channelId, options2);
1800
+ }
1801
+ const method = findParam(extractedParams, "Method");
1802
+ const options = findParam(extractedParams, "Options");
1803
+ return buildSlackInvokePayload(method, options);
1804
+ }
1805
+ // =========================================================================
1806
+ // QuickBooks
1807
+ // =========================================================================
1808
+ case "quickbooks": {
1809
+ if (methodName === "query") {
1810
+ const query = findParam(extractedParams, "Query");
1811
+ return buildQuickBooksQueryPayload(query);
1812
+ }
1813
+ const method = findParam(extractedParams, "Method");
1814
+ const path = findParam(extractedParams, "Path");
1815
+ const options = findParam(extractedParams, "Options");
1816
+ return buildQuickBooksInvokePayload(method, path, options);
1817
+ }
1818
+ // =========================================================================
1819
+ // Major Auth
1820
+ // =========================================================================
1821
+ case "majorauth": {
1822
+ const email = findParam(extractedParams, "Email");
1823
+ if (methodName === "revokeAccess") {
1824
+ return buildAuthRevokeAccessPayload(email);
1825
+ }
1826
+ return buildAuthShareAccessPayload(email);
1827
+ }
1828
+ // =========================================================================
1829
+ // Google Analytics
1830
+ // =========================================================================
1831
+ case "googleanalytics": {
1832
+ if (methodName === "runReport") {
1833
+ const dimensions = findParam(extractedParams, "Dimensions");
1834
+ const metrics = findParam(extractedParams, "Metrics");
1835
+ const dateRanges = findParam(extractedParams, "DateRanges");
1836
+ const options = findParam(extractedParams, "Options");
1837
+ return buildGoogleAnalyticsRunReportPayload(
1838
+ dimensions ?? [],
1839
+ metrics ?? [],
1840
+ dateRanges ?? [],
1841
+ options
1842
+ );
1843
+ }
1844
+ if (methodName === "getMetadata") {
1845
+ return buildGoogleAnalyticsGetMetadataPayload();
1846
+ }
1847
+ if (methodName === "listAccounts") {
1848
+ const options = findParam(extractedParams, "Options");
1849
+ return buildGoogleAnalyticsListAccountsPayload(options);
1850
+ }
1851
+ if (methodName === "listProperties") {
1852
+ const accountId = findParam(extractedParams, "AccountId");
1853
+ const options = findParam(extractedParams, "Options");
1854
+ return buildGoogleAnalyticsListPropertiesPayload(accountId, options);
1855
+ }
1856
+ const payload = findParam(extractedParams, "Payload");
1857
+ return buildGoogleAnalyticsInvokePayload(payload);
1858
+ }
1859
+ // =========================================================================
1860
+ // GraphQL
1861
+ // =========================================================================
1862
+ case "graphql": {
1863
+ const query = findParam(extractedParams, "Query");
1864
+ const options = findParam(extractedParams, "Options");
1865
+ return buildGraphQLInvokePayload(query, options);
1866
+ }
1867
+ default:
1868
+ throw new Error(`Unsupported resource subtype: ${subtype}`);
1869
+ }
1870
+ }
1871
+ export {
1872
+ BaseResourceClient,
1873
+ BigQueryResourceClient,
1874
+ CosmosDBResourceClient,
1875
+ CustomApiResourceClient,
1876
+ DynamoDBResourceClient,
1877
+ GoogleAnalyticsResourceClient,
1878
+ GoogleSheetsResourceClient,
1879
+ GraphQLResourceClient,
1880
+ HubSpotResourceClient,
1881
+ LambdaResourceClient,
1882
+ MajorAuthResourceClient,
1883
+ MssqlResourceClient,
1884
+ Neo4jResourceClient,
1885
+ OutreachResourceClient,
1886
+ PostgresResourceClient,
1887
+ QuickBooksResourceClient,
1888
+ ResourceInvokeError,
1889
+ S3ResourceClient,
1890
+ SalesforceResourceClient,
1891
+ SlackResourceClient,
1892
+ SnowflakeResourceClient,
1893
+ buildAuthRevokeAccessPayload,
1894
+ buildAuthShareAccessPayload,
1895
+ buildBigQueryCreateTablePayload,
1896
+ buildBigQueryGetTablePayload,
1897
+ buildBigQueryInsertRowsPayload,
1898
+ buildBigQueryInvokePayload,
1899
+ buildBigQueryListDatasetsPayload,
1900
+ buildBigQueryListTablesPayload,
1901
+ buildBigQueryQueryPayload,
1902
+ buildCosmosDBCreatePayload,
1903
+ buildCosmosDBDeletePayload,
1904
+ buildCosmosDBInvokePayload,
1905
+ buildCosmosDBPatchPayload,
1906
+ buildCosmosDBQueryPayload,
1907
+ buildCosmosDBReadPayload,
1908
+ buildCosmosDBReplacePayload,
1909
+ buildCosmosDBUpsertPayload,
1910
+ buildCustomApiInvokePayload,
1911
+ buildDynamoDBInvokePayload,
1912
+ buildGoogleAnalyticsGetMetadataPayload,
1913
+ buildGoogleAnalyticsInvokePayload,
1914
+ buildGoogleAnalyticsListAccountsPayload,
1915
+ buildGoogleAnalyticsListDataStreamsPayload,
1916
+ buildGoogleAnalyticsListPropertiesPayload,
1917
+ buildGoogleAnalyticsRunRealtimeReportPayload,
1918
+ buildGoogleAnalyticsRunReportPayload,
1919
+ buildGoogleSheetsAppendValuesPayload,
1920
+ buildGoogleSheetsBatchGetValuesPayload,
1921
+ buildGoogleSheetsBatchUpdatePayload,
1922
+ buildGoogleSheetsBatchUpdateValuesPayload,
1923
+ buildGoogleSheetsClearValuesPayload,
1924
+ buildGoogleSheetsGetSpreadsheetPayload,
1925
+ buildGoogleSheetsGetValuesPayload,
1926
+ buildGoogleSheetsInvokePayload,
1927
+ buildGoogleSheetsUpdateValuesPayload,
1928
+ buildGraphQLInvokePayload,
1929
+ buildHubSpotInvokePayload,
1930
+ buildLambdaInvokePayload,
1931
+ buildMssqlInvokePayload,
1932
+ buildNeo4jInvokePayload,
1933
+ buildOutreachInvokePayload,
1934
+ buildPayloadFromExtractedParams,
1935
+ buildPostgresInvokePayload,
1936
+ buildQuickBooksInvokePayload,
1937
+ buildQuickBooksQueryPayload,
1938
+ buildS3InvokePayload,
1939
+ buildSalesforceCreateRecordPayload,
1940
+ buildSalesforceDeleteRecordPayload,
1941
+ buildSalesforceDescribeObjectPayload,
1942
+ buildSalesforceGetRecordPayload,
1943
+ buildSalesforceInvokePayload,
1944
+ buildSalesforceQueryPayload,
1945
+ buildSalesforceUpdateRecordPayload,
1946
+ buildSlackInvokePayload,
1947
+ buildSnowflakeCancelPayload,
1948
+ buildSnowflakeExecutePayload,
1949
+ buildSnowflakeInvokePayload,
1950
+ buildSnowflakeStatusPayload
1951
+ };
1952
+ //# sourceMappingURL=index.js.map