@keystrokehq/salesforce 0.0.11 → 0.0.15

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 (53) hide show
  1. package/dist/_official/index.d.mts +3 -7
  2. package/dist/_official/index.mjs +1 -1
  3. package/dist/accounts.d.mts +11 -27
  4. package/dist/accounts.mjs +1 -1
  5. package/dist/associations.d.mts +5 -12
  6. package/dist/associations.mjs +3 -3
  7. package/dist/campaign-members.d.mts +11 -27
  8. package/dist/campaign-members.mjs +1 -1
  9. package/dist/campaigns.d.mts +11 -27
  10. package/dist/campaigns.mjs +1 -1
  11. package/dist/cases.d.mts +11 -27
  12. package/dist/cases.mjs +1 -1
  13. package/dist/client.d.mts +1 -1
  14. package/dist/client.mjs +2 -2
  15. package/dist/connection.d.mts +1 -1
  16. package/dist/connection.mjs +1 -1
  17. package/dist/contacts.d.mts +11 -27
  18. package/dist/contacts.mjs +1 -1
  19. package/dist/dashboards.d.mts +7 -17
  20. package/dist/dashboards.mjs +2 -2
  21. package/dist/factory-BGHapzgT.mjs +8 -0
  22. package/dist/integration-BDDBjdNG.d.mts +30 -0
  23. package/dist/integration-BzLQsPf-.mjs +60 -0
  24. package/dist/leads.d.mts +11 -27
  25. package/dist/leads.mjs +1 -1
  26. package/dist/notes.d.mts +11 -27
  27. package/dist/notes.mjs +1 -1
  28. package/dist/objects.d.mts +5 -12
  29. package/dist/objects.mjs +2 -2
  30. package/dist/opportunities.d.mts +11 -27
  31. package/dist/opportunities.mjs +1 -1
  32. package/dist/opportunity-line-items.d.mts +11 -27
  33. package/dist/opportunity-line-items.mjs +1 -1
  34. package/dist/ownership.d.mts +3 -7
  35. package/dist/ownership.mjs +3 -3
  36. package/dist/reports.d.mts +9 -22
  37. package/dist/reports.mjs +2 -2
  38. package/dist/schemas/index.mjs +1 -1
  39. package/dist/{shared-P5lushwa.mjs → shared-CM1r3Nii.mjs} +2 -2
  40. package/dist/soql.d.mts +5 -12
  41. package/dist/soql.mjs +3 -3
  42. package/dist/tasks.d.mts +11 -27
  43. package/dist/tasks.mjs +1 -1
  44. package/dist/triggers.d.mts +4 -59
  45. package/dist/triggers.mjs +5 -5
  46. package/dist/users.d.mts +3 -7
  47. package/dist/users.mjs +2 -2
  48. package/package.json +5 -6
  49. package/dist/dist-Bbp6t-WQ.mjs +0 -74
  50. package/dist/factory-CxfYmb6l.mjs +0 -7
  51. package/dist/integration-B9QIZuPh.mjs +0 -331
  52. package/dist/integration-CN_7-2E5.d.mts +0 -61
  53. /package/dist/{common-wiFkMAq5.mjs → common-BUAhHMqn.mjs} +0 -0
@@ -1,331 +0,0 @@
1
- import { CredentialSet, Operation } from "@keystrokehq/core";
2
- import { z } from "zod";
3
-
4
- //#region ../../packages/integration-authoring/dist/official/runtime.mjs
5
- const REGISTRY_KEY = "__ks_official_integration_metadata_registry";
6
- function getRegistry() {
7
- const globalStore = globalThis;
8
- if (!globalStore[REGISTRY_KEY]) globalStore[REGISTRY_KEY] = /* @__PURE__ */ new WeakMap();
9
- return globalStore[REGISTRY_KEY];
10
- }
11
- function registerOfficialOperation(operation, metadata) {
12
- getRegistry().set(operation, Object.freeze({ ...metadata }));
13
- }
14
-
15
- //#endregion
16
- //#region ../../packages/integration-authoring/dist/official/index.mjs
17
- const OFFICIAL_CREDENTIAL_SET_ID_PREFIX = "keystroke:";
18
- function officialCredentialSetId(id) {
19
- return `${OFFICIAL_CREDENTIAL_SET_ID_PREFIX}${id}`;
20
- }
21
- function stripOfficialCredentialSetIdPrefix(id) {
22
- return id.startsWith(OFFICIAL_CREDENTIAL_SET_ID_PREFIX) ? id.slice(10) : id;
23
- }
24
- /**
25
- * Creates a factory for Keystroke-official integration operations.
26
- *
27
- * It keeps the same flat `run(input, credentials)` ergonomics as the generic
28
- * operation factory, while registering official metadata for builder/runtime
29
- * operation metadata.
30
- */
31
- function createOfficialOperationFactory(credentialSet) {
32
- const integrationId = stripOfficialCredentialSetIdPrefix(credentialSet.id);
33
- return (config) => {
34
- const wrappedRun = async (input, ctx) => {
35
- const creds = ctx.credentials[credentialSet.id];
36
- return config.run(input, creds);
37
- };
38
- const operation = new Operation({
39
- id: config.id,
40
- name: config.name,
41
- description: config.description,
42
- input: config.input,
43
- output: config.output,
44
- credentialSets: [credentialSet],
45
- ...config.tags !== void 0 ? { tags: config.tags } : {},
46
- ...config.needsApproval !== void 0 ? { needsApproval: config.needsApproval } : {},
47
- ...config.requiredOAuthScopes !== void 0 ? { requiredOAuthScopes: config.requiredOAuthScopes } : {},
48
- ...config.retries !== void 0 ? { retries: config.retries } : {},
49
- ...config.timeout !== void 0 ? { timeout: config.timeout } : {},
50
- ...config.maxDurationMs !== void 0 ? { maxDurationMs: config.maxDurationMs } : {},
51
- run: wrappedRun
52
- });
53
- registerOfficialOperation(operation, { integrationId });
54
- return operation;
55
- };
56
- }
57
- /**
58
- * Creates an official integration bundle from a single config object.
59
- *
60
- * - Creates the public `CredentialSet` internally.
61
- * - Accepts optional `internal` fields for Keystroke-owned platform credentials.
62
- */
63
- function defineOfficialIntegration(config) {
64
- const internalCredentialSets = config.internal ?? {};
65
- const allInternalCredentialSets = [
66
- ...internalCredentialSets.providerApp ? [internalCredentialSets.providerApp] : [],
67
- ...internalCredentialSets.providerAppVariants ?? [],
68
- ...internalCredentialSets.webhookVerification ? [internalCredentialSets.webhookVerification] : [],
69
- ...internalCredentialSets.other ?? []
70
- ];
71
- const credentialSet = new CredentialSet({
72
- id: config.id,
73
- name: config.name,
74
- description: config.description,
75
- auth: config.auth,
76
- ...config.connections ? { connections: config.connections } : {},
77
- ...config.proxy ? { proxy: config.proxy } : {},
78
- ...config.needsRawSecret === true ? { needsRawSecret: true } : {}
79
- });
80
- return Object.freeze({
81
- integration: {
82
- id: config.id,
83
- name: config.name,
84
- ...config.description !== void 0 ? { description: config.description } : {},
85
- auth: config.auth,
86
- ...config.proxy ? { proxy: config.proxy } : {},
87
- ...config.needsRawSecret === true ? { needsRawSecret: true } : {},
88
- ...config.connections ? { connections: config.connections } : {}
89
- },
90
- credentialSet,
91
- internalCredentialSets,
92
- allInternalCredentialSets
93
- });
94
- }
95
-
96
- //#endregion
97
- //#region src/_official/provider-app.ts
98
- const salesforceAppCredentialSet = new CredentialSet({
99
- id: officialCredentialSetId("salesforce-app"),
100
- exposure: "platform-only",
101
- name: "Salesforce Connected App",
102
- auth: z.object({
103
- clientId: z.string().min(1),
104
- clientSecret: z.string().min(1)
105
- })
106
- });
107
- const salesforceOfficialProviderSeed = {
108
- provider: "salesforce",
109
- appRef: "salesforce-platform",
110
- displayName: "Salesforce Platform",
111
- credentialSetName: "Keystroke Salesforce Platform App",
112
- envShape: {
113
- KEYSTROKE_OFFICIAL_SALESFORCE_CLIENT_ID: z.string().optional(),
114
- KEYSTROKE_OFFICIAL_SALESFORCE_CLIENT_SECRET: z.string().optional(),
115
- KEYSTROKE_OFFICIAL_SALESFORCE_ENVIRONMENT: z.enum(["production", "sandbox"]).optional(),
116
- KEYSTROKE_OFFICIAL_SALESFORCE_LOGIN_BASE_URL: z.string().url().optional()
117
- },
118
- requiredEnvKeys: ["KEYSTROKE_OFFICIAL_SALESFORCE_CLIENT_ID", "KEYSTROKE_OFFICIAL_SALESFORCE_CLIENT_SECRET"],
119
- externalAppIdEnvKey: "KEYSTROKE_OFFICIAL_SALESFORCE_CLIENT_ID",
120
- buildCredentials: (env) => ({
121
- clientId: env.KEYSTROKE_OFFICIAL_SALESFORCE_CLIENT_ID,
122
- clientSecret: env.KEYSTROKE_OFFICIAL_SALESFORCE_CLIENT_SECRET
123
- }),
124
- buildMetadata: (env) => env.KEYSTROKE_OFFICIAL_SALESFORCE_ENVIRONMENT || env.KEYSTROKE_OFFICIAL_SALESFORCE_LOGIN_BASE_URL ? {
125
- ...env.KEYSTROKE_OFFICIAL_SALESFORCE_ENVIRONMENT ? { environment: env.KEYSTROKE_OFFICIAL_SALESFORCE_ENVIRONMENT } : {},
126
- ...env.KEYSTROKE_OFFICIAL_SALESFORCE_LOGIN_BASE_URL ? { loginBaseUrl: env.KEYSTROKE_OFFICIAL_SALESFORCE_LOGIN_BASE_URL } : {}
127
- } : void 0
128
- };
129
-
130
- //#endregion
131
- //#region ../../packages/credential-connection/dist/defaults-YE9AvLIc.mjs
132
- /**
133
- * Shared OAuth 2.0 token-response plumbing.
134
- *
135
- * `parseOAuthTokenResponse` handles the two common wire formats (JSON and
136
- * form-urlencoded, the latter used by GitHub unless you explicitly ask for
137
- * JSON). `normalizeOAuthTokens` pulls the standard fields out of the parsed
138
- * body in both the flat form and Slack's nested `authed_user.access_token`
139
- * form. These helpers are exposed so integration authors overriding
140
- * `exchangeCode` / `refreshToken` do not have to re-implement them.
141
- */
142
- var TokenExchangeError = class extends Error {
143
- httpStatus;
144
- constructor(httpStatus) {
145
- super(`Token exchange failed: HTTP ${httpStatus}`);
146
- this.name = "TokenExchangeError";
147
- this.httpStatus = httpStatus;
148
- }
149
- };
150
- async function parseOAuthTokenResponse(response) {
151
- const contentType = response.headers.get("content-type")?.toLowerCase() ?? "";
152
- if (contentType.includes("application/json")) return await response.json();
153
- const text = await response.text();
154
- if (!text.trim()) return {};
155
- if (contentType.includes("application/x-www-form-urlencoded") || text.includes("=")) {
156
- const params = new URLSearchParams(text);
157
- return Object.fromEntries(params.entries());
158
- }
159
- throw new Error(`Unsupported OAuth token response content type: ${contentType || "unknown"}`);
160
- }
161
- function normalizeOAuthTokens(tokenData) {
162
- const authedUser = tokenData.authed_user;
163
- const rawAccessToken = tokenData.access_token ?? authedUser?.access_token;
164
- const rawRefreshToken = tokenData.refresh_token;
165
- const rawExpiresIn = tokenData.expires_in;
166
- const rawInstanceUrl = tokenData.instance_url;
167
- return {
168
- accessToken: typeof rawAccessToken === "string" ? rawAccessToken : void 0,
169
- refreshToken: typeof rawRefreshToken === "string" ? rawRefreshToken : void 0,
170
- expiresIn: typeof rawExpiresIn === "number" ? rawExpiresIn : typeof rawExpiresIn === "string" ? Number(rawExpiresIn) || void 0 : void 0,
171
- instanceUrl: typeof rawInstanceUrl === "string" ? rawInstanceUrl : void 0
172
- };
173
- }
174
- function buildAuthUrl(ctx) {
175
- const { oauthClient, redirectUri, state, connection } = ctx;
176
- const scopes = ctx.requestedScopes ?? connection.scopes;
177
- const url = new URL(connection.authUrl);
178
- url.searchParams.set("client_id", oauthClient.clientId);
179
- url.searchParams.set("scope", scopes.join(" "));
180
- url.searchParams.set("redirect_uri", redirectUri);
181
- url.searchParams.set("state", state);
182
- url.searchParams.set("response_type", "code");
183
- return url.toString();
184
- }
185
- async function exchangeToken(params) {
186
- const response = await fetch(params.tokenUrl, {
187
- method: "POST",
188
- headers: {
189
- Accept: "application/json",
190
- "Content-Type": "application/x-www-form-urlencoded"
191
- },
192
- body: params.body
193
- });
194
- if (!response.ok) throw new TokenExchangeError(response.status);
195
- const raw = await parseOAuthTokenResponse(response);
196
- const { accessToken, refreshToken, expiresIn, instanceUrl } = normalizeOAuthTokens(raw);
197
- if (!accessToken) throw new Error("No access token in response");
198
- return {
199
- accessToken,
200
- refreshToken,
201
- expiresIn,
202
- instanceUrl,
203
- raw
204
- };
205
- }
206
- async function exchangeCode(ctx) {
207
- const { oauthClient, code, redirectUri, connection } = ctx;
208
- if (!code) throw new Error("Missing authorization code");
209
- return exchangeToken({
210
- tokenUrl: connection.tokenUrl,
211
- body: new URLSearchParams({
212
- code,
213
- client_id: oauthClient.clientId,
214
- client_secret: oauthClient.clientSecret,
215
- redirect_uri: redirectUri,
216
- grant_type: "authorization_code"
217
- })
218
- });
219
- }
220
- async function refreshToken(ctx) {
221
- const { oauthClient, refreshToken, connection } = ctx;
222
- return exchangeToken({
223
- tokenUrl: connection.tokenUrl,
224
- body: new URLSearchParams({
225
- grant_type: "refresh_token",
226
- refresh_token: refreshToken,
227
- client_id: oauthClient.clientId,
228
- client_secret: oauthClient.clientSecret
229
- })
230
- });
231
- }
232
- const oauthDefaults = {
233
- buildAuthUrl,
234
- exchangeCode,
235
- exchangeToken,
236
- refreshToken
237
- };
238
-
239
- //#endregion
240
- //#region src/oauth-connection.ts
241
- function getMetadataValue(metadata, key) {
242
- if (!metadata || typeof metadata !== "object" || !(key in metadata)) return;
243
- const value = metadata[key];
244
- if (typeof value === "string" || typeof value === "boolean") return value;
245
- }
246
- function resolveSalesforceLoginBaseUrl(metadata) {
247
- const explicitBaseUrl = getMetadataValue(metadata, "loginBaseUrl");
248
- if (typeof explicitBaseUrl === "string" && explicitBaseUrl.length > 0) return explicitBaseUrl;
249
- if (getMetadataValue(metadata, "environment") === "sandbox") return "https://test.salesforce.com";
250
- if (getMetadataValue(metadata, "sandbox") === true) return "https://test.salesforce.com";
251
- return "https://login.salesforce.com";
252
- }
253
- function buildSalesforceUrl(metadata, path) {
254
- return new URL(path, resolveSalesforceLoginBaseUrl(metadata)).toString();
255
- }
256
- const salesforceOAuthConnection = {
257
- kind: "oauth",
258
- tokenType: "refreshable",
259
- authUrl: "https://login.salesforce.com/services/oauth2/authorize",
260
- tokenUrl: "https://login.salesforce.com/services/oauth2/token",
261
- revokeUrl: null,
262
- scopes: [
263
- "api",
264
- "refresh_token",
265
- "offline_access"
266
- ],
267
- vault: {
268
- accessToken: "SALESFORCE_ACCESS_TOKEN",
269
- instanceUrl: "SALESFORCE_INSTANCE_URL"
270
- },
271
- buildAuthUrl({ oauthClient, redirectUri, state, connection, requestedScopes }) {
272
- const scopes = requestedScopes ?? connection.scopes;
273
- const url = new URL(buildSalesforceUrl(oauthClient.metadata, "/services/oauth2/authorize"));
274
- url.searchParams.set("client_id", oauthClient.clientId);
275
- url.searchParams.set("scope", scopes.join(" "));
276
- url.searchParams.set("redirect_uri", redirectUri);
277
- url.searchParams.set("state", state);
278
- url.searchParams.set("response_type", "code");
279
- return url.toString();
280
- },
281
- async exchangeCode({ oauthClient, code, redirectUri }) {
282
- if (!code) throw new Error("Missing authorization code");
283
- return oauthDefaults.exchangeToken({
284
- tokenUrl: buildSalesforceUrl(oauthClient.metadata, "/services/oauth2/token"),
285
- body: new URLSearchParams({
286
- code,
287
- client_id: oauthClient.clientId,
288
- client_secret: oauthClient.clientSecret,
289
- redirect_uri: redirectUri,
290
- grant_type: "authorization_code"
291
- })
292
- });
293
- },
294
- async refreshToken({ oauthClient, refreshToken }) {
295
- return oauthDefaults.exchangeToken({
296
- tokenUrl: buildSalesforceUrl(oauthClient.metadata, "/services/oauth2/token"),
297
- body: new URLSearchParams({
298
- grant_type: "refresh_token",
299
- refresh_token: refreshToken,
300
- client_id: oauthClient.clientId,
301
- client_secret: oauthClient.clientSecret
302
- })
303
- });
304
- }
305
- };
306
-
307
- //#endregion
308
- //#region src/integration.ts
309
- const salesforceAuthSchema = z.object({
310
- SALESFORCE_ACCESS_TOKEN: z.string().min(1),
311
- SALESFORCE_INSTANCE_URL: z.url()
312
- });
313
- const salesforceOfficialIntegration = {
314
- id: "salesforce",
315
- name: "Salesforce",
316
- description: "Salesforce CRM and platform automation",
317
- auth: salesforceAuthSchema,
318
- proxy: { hosts: ["*.salesforce.com", "*.force.com"] },
319
- connections: [{
320
- id: "oauth",
321
- ...salesforceOAuthConnection
322
- }]
323
- };
324
- const salesforceBundle = defineOfficialIntegration({
325
- ...salesforceOfficialIntegration,
326
- internal: { providerApp: salesforceAppCredentialSet }
327
- });
328
- const salesforce = salesforceBundle.credentialSet;
329
-
330
- //#endregion
331
- export { salesforceOfficialProviderSeed as a, salesforceAppCredentialSet as i, salesforceBundle as n, createOfficialOperationFactory as o, salesforceOfficialIntegration as r, salesforce as t };
@@ -1,61 +0,0 @@
1
- import * as _keystrokehq_core0 from "@keystrokehq/core";
2
- import { z } from "zod";
3
- import * as _keystrokehq_core_credential_set0 from "@keystrokehq/core/credential-set";
4
- import { InferCredentialSetAuth } from "@keystrokehq/core/credential-set";
5
-
6
- //#region src/integration.d.ts
7
- declare const salesforceOfficialIntegration: {
8
- id: "salesforce";
9
- name: string;
10
- description: string;
11
- auth: z.ZodObject<{
12
- SALESFORCE_ACCESS_TOKEN: z.ZodString;
13
- SALESFORCE_INSTANCE_URL: z.ZodURL;
14
- }, z.core.$strip>;
15
- proxy: {
16
- hosts: string[];
17
- };
18
- connections: {
19
- kind: "oauth";
20
- tokenType: "refreshable";
21
- authUrl: "https://login.salesforce.com/services/oauth2/authorize";
22
- tokenUrl: "https://login.salesforce.com/services/oauth2/token";
23
- revokeUrl: null;
24
- scopes: readonly ["api", "refresh_token", "offline_access"];
25
- vault: {
26
- readonly accessToken: "SALESFORCE_ACCESS_TOKEN";
27
- readonly instanceUrl: "SALESFORCE_INSTANCE_URL";
28
- };
29
- buildAuthUrl: ({
30
- oauthClient,
31
- redirectUri,
32
- state,
33
- connection,
34
- requestedScopes
35
- }: _keystrokehq_core_credential_set0.BuildAuthUrlContext) => string;
36
- exchangeCode: ({
37
- oauthClient,
38
- code,
39
- redirectUri
40
- }: _keystrokehq_core_credential_set0.ExchangeCodeContext) => Promise<_keystrokehq_core_credential_set0.TokenResult>;
41
- refreshToken: ({
42
- oauthClient,
43
- refreshToken
44
- }: _keystrokehq_core_credential_set0.RefreshTokenContext) => Promise<_keystrokehq_core_credential_set0.TokenResult>;
45
- id: string;
46
- }[];
47
- };
48
- declare const salesforceBundle: undefined<"salesforce", z.ZodObject<{
49
- SALESFORCE_ACCESS_TOKEN: z.ZodString;
50
- SALESFORCE_INSTANCE_URL: z.ZodURL;
51
- }, z.core.$strip>>;
52
- declare const salesforce: _keystrokehq_core0.CredentialSet<"salesforce", z.ZodObject<{
53
- SALESFORCE_ACCESS_TOKEN: z.ZodString;
54
- SALESFORCE_INSTANCE_URL: z.ZodURL;
55
- }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
56
- SALESFORCE_ACCESS_TOKEN: z.ZodString;
57
- SALESFORCE_INSTANCE_URL: z.ZodURL;
58
- }, z.core.$strip>>[] | undefined>;
59
- type SalesforceCredentials = InferCredentialSetAuth<typeof salesforce>;
60
- //#endregion
61
- export { salesforceOfficialIntegration as i, salesforce as n, salesforceBundle as r, SalesforceCredentials as t };