@superdurable/connector-adobe-marketo 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,7 +1,86 @@
1
1
  import {
2
+ ActivityMetadataSchema,
3
+ ActivityPageSchema,
4
+ ActivityPagingTokenSchema,
5
+ ActivityTypeSchema,
6
+ ActivityTypesSchema,
7
+ CompanyProfileSchema,
8
+ CompanyWriteResultSchema,
2
9
  ConfigSchema,
3
10
  Connection,
4
11
  ConnectorID,
12
+ CreateCompanyBranch,
13
+ CreateCompanyBranchAlreadyExists,
14
+ CreateCompanyBranchCreated,
15
+ CreateCompanyBranchDefect,
16
+ CreateCompanyBranchProviderRejected,
17
+ CreateCompanyBranchUncertain,
18
+ CreateCompanyDefinition,
19
+ CreateCompanyInputSchema,
20
+ CreateCompanyMetadata,
21
+ CreateLeadBranch,
22
+ CreateLeadBranchAlreadyExists,
23
+ CreateLeadBranchCreated,
24
+ CreateLeadBranchDefect,
25
+ CreateLeadBranchProviderRejected,
26
+ CreateLeadBranchUncertain,
27
+ CreateLeadDefinition,
28
+ CreateLeadInputSchema,
29
+ CreateLeadMetadata,
30
+ CreateOpportunityBranch,
31
+ CreateOpportunityBranchAlreadyExists,
32
+ CreateOpportunityBranchCreated,
33
+ CreateOpportunityBranchDefect,
34
+ CreateOpportunityBranchProviderRejected,
35
+ CreateOpportunityBranchUncertain,
36
+ CreateOpportunityDefinition,
37
+ CreateOpportunityInputSchema,
38
+ CreateOpportunityMetadata,
39
+ CreatedLeadSchema,
40
+ CredentialMaterialError,
41
+ DeleteCompanyBranch,
42
+ DeleteCompanyBranchDefect,
43
+ DeleteCompanyBranchDeleted,
44
+ DeleteCompanyBranchInvalidResponse,
45
+ DeleteCompanyBranchProviderRejected,
46
+ DeleteCompanyDefinition,
47
+ DeleteCompanyInputSchema,
48
+ DeleteCompanyMetadata,
49
+ DeleteOpportunityBranch,
50
+ DeleteOpportunityBranchDefect,
51
+ DeleteOpportunityBranchDeleted,
52
+ DeleteOpportunityBranchInvalidResponse,
53
+ DeleteOpportunityBranchProviderRejected,
54
+ DeleteOpportunityDefinition,
55
+ DeleteOpportunityInputSchema,
56
+ DeleteOpportunityMetadata,
57
+ DeletedCompanySchema,
58
+ DeletedOpportunitySchema,
59
+ FindLeadsByEmailBranch,
60
+ FindLeadsByEmailBranchDefect,
61
+ FindLeadsByEmailBranchFound,
62
+ FindLeadsByEmailBranchInvalidResponse,
63
+ FindLeadsByEmailBranchProviderRejected,
64
+ FindLeadsByEmailDefinition,
65
+ FindLeadsByEmailInputSchema,
66
+ FindLeadsByEmailMetadata,
67
+ GetActivityPagingTokenBranch,
68
+ GetActivityPagingTokenBranchDefect,
69
+ GetActivityPagingTokenBranchFound,
70
+ GetActivityPagingTokenBranchInvalidResponse,
71
+ GetActivityPagingTokenBranchProviderRejected,
72
+ GetActivityPagingTokenDefinition,
73
+ GetActivityPagingTokenInputSchema,
74
+ GetActivityPagingTokenMetadata,
75
+ GetCompanyByExternalIDBranch,
76
+ GetCompanyByExternalIDBranchDefect,
77
+ GetCompanyByExternalIDBranchFound,
78
+ GetCompanyByExternalIDBranchInvalidResponse,
79
+ GetCompanyByExternalIDBranchNotFound,
80
+ GetCompanyByExternalIDBranchProviderRejected,
81
+ GetCompanyByExternalIDDefinition,
82
+ GetCompanyByExternalIDInputSchema,
83
+ GetCompanyByExternalIDMetadata,
5
84
  GetLeadBranch,
6
85
  GetLeadBranchDefect,
7
86
  GetLeadBranchFound,
@@ -11,18 +90,221 @@ import {
11
90
  GetLeadDefinition,
12
91
  GetLeadInputSchema,
13
92
  GetLeadMetadata,
93
+ GetOpportunityByExternalIDBranch,
94
+ GetOpportunityByExternalIDBranchDefect,
95
+ GetOpportunityByExternalIDBranchFound,
96
+ GetOpportunityByExternalIDBranchInvalidResponse,
97
+ GetOpportunityByExternalIDBranchNotFound,
98
+ GetOpportunityByExternalIDBranchProviderRejected,
99
+ GetOpportunityByExternalIDDefinition,
100
+ GetOpportunityByExternalIDInputSchema,
101
+ GetOpportunityByExternalIDMetadata,
14
102
  LeadProfileSchema,
103
+ LeadProfilesPageSchema,
104
+ ListActivitiesBranch,
105
+ ListActivitiesBranchDefect,
106
+ ListActivitiesBranchFound,
107
+ ListActivitiesBranchInvalidResponse,
108
+ ListActivitiesBranchProviderRejected,
109
+ ListActivitiesDefinition,
110
+ ListActivitiesInputSchema,
111
+ ListActivitiesMetadata,
112
+ ListActivityTypesBranch,
113
+ ListActivityTypesBranchDefect,
114
+ ListActivityTypesBranchFound,
115
+ ListActivityTypesBranchInvalidResponse,
116
+ ListActivityTypesBranchProviderRejected,
117
+ ListActivityTypesDefinition,
118
+ ListActivityTypesInputSchema,
119
+ ListActivityTypesMetadata,
120
+ OpportunityProfileSchema,
121
+ OpportunityWriteResultSchema,
15
122
  ProviderID,
123
+ SyncedLeadSchema,
124
+ UpdateLeadBranch,
125
+ UpdateLeadBranchDefect,
126
+ UpdateLeadBranchInvalidResponse,
127
+ UpdateLeadBranchNotFound,
128
+ UpdateLeadBranchProviderRejected,
129
+ UpdateLeadBranchUpdated,
130
+ UpdateLeadDefinition,
131
+ UpdateLeadInputSchema,
132
+ UpdateLeadMetadata,
133
+ UpdatedLeadSchema,
134
+ UpsertCompanyBranch,
135
+ UpsertCompanyBranchDefect,
136
+ UpsertCompanyBranchInvalidResponse,
137
+ UpsertCompanyBranchProviderRejected,
138
+ UpsertCompanyBranchSynced,
139
+ UpsertCompanyDefinition,
140
+ UpsertCompanyInputSchema,
141
+ UpsertCompanyMetadata,
142
+ UpsertLeadByEmailBranch,
143
+ UpsertLeadByEmailBranchDefect,
144
+ UpsertLeadByEmailBranchInvalidResponse,
145
+ UpsertLeadByEmailBranchProviderRejected,
146
+ UpsertLeadByEmailBranchSynced,
147
+ UpsertLeadByEmailDefinition,
148
+ UpsertLeadByEmailInputSchema,
149
+ UpsertLeadByEmailMetadata,
150
+ UpsertOpportunityBranch,
151
+ UpsertOpportunityBranchDefect,
152
+ UpsertOpportunityBranchInvalidResponse,
153
+ UpsertOpportunityBranchProviderRejected,
154
+ UpsertOpportunityBranchSynced,
155
+ UpsertOpportunityDefinition,
156
+ UpsertOpportunityInputSchema,
157
+ UpsertOpportunityMetadata,
16
158
  decodeCredentials,
17
159
  decodeSharedCredentials,
160
+ decodeSignedInteger,
161
+ exactIntegerJSONCodec,
162
+ isCredentialMaterialError,
18
163
  newConnection,
19
164
  newConnectionWithOperations,
20
165
  newProjectConnection,
21
- newProjectCredentialProvider
22
- } from "./chunk-N4RSR7PL.js";
166
+ newProjectCredentialProvider,
167
+ parseExactIntegerJSON,
168
+ parseJSONNumberTokens
169
+ } from "./chunk-AYOHNIYZ.js";
23
170
 
24
171
  // src/generated/steps.ts
25
- import { goToBranch, newQueryStep } from "@superdurable/connectors-sdk";
172
+ import { goToBranch, newMutationStep, newQueryStep } from "@superdurable/connectors-sdk";
173
+ function newGetOpportunityByExternalIDStep(configuration) {
174
+ const { connection, connectionName, found, notFound, providerRejected, invalidResponse, defect, ...stepConfiguration } = configuration;
175
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
176
+ return newQueryStep({ ...stepConfiguration, operation: connection.operations.getOpportunityByExternalID(), connection: connection.reference, branches: [
177
+ goToBranch("found", found),
178
+ ...notFound ? [goToBranch("notFound", notFound)] : [],
179
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
180
+ ...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
181
+ ...defect ? [goToBranch("defect", defect)] : []
182
+ ] });
183
+ }
184
+ function newCreateOpportunityStep(configuration) {
185
+ const { connection, connectionName, created, alreadyExists, providerRejected, uncertain, defect, ...stepConfiguration } = configuration;
186
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
187
+ return newMutationStep({ ...stepConfiguration, operation: connection.operations.createOpportunity(), connection: connection.reference, branches: [
188
+ goToBranch("created", created),
189
+ ...alreadyExists ? [goToBranch("alreadyExists", alreadyExists)] : [],
190
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
191
+ ...uncertain ? [goToBranch("uncertain", uncertain)] : [],
192
+ ...defect ? [goToBranch("defect", defect)] : []
193
+ ] });
194
+ }
195
+ function newUpsertOpportunityStep(configuration) {
196
+ const { connection, connectionName, synced, providerRejected, invalidResponse, defect, maxSends, ...stepConfiguration } = configuration;
197
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
198
+ return newMutationStep({ ...stepConfiguration, operation: connection.operations.upsertOpportunity(), connection: connection.reference, branches: [
199
+ goToBranch("synced", synced),
200
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
201
+ ...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
202
+ ...defect ? [goToBranch("defect", defect)] : []
203
+ ] });
204
+ }
205
+ function newDeleteOpportunityStep(configuration) {
206
+ const { connection, connectionName, deleted, providerRejected, invalidResponse, defect, maxSends, ...stepConfiguration } = configuration;
207
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
208
+ return newMutationStep({ ...stepConfiguration, operation: connection.operations.deleteOpportunity(), connection: connection.reference, branches: [
209
+ goToBranch("deleted", deleted),
210
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
211
+ ...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
212
+ ...defect ? [goToBranch("defect", defect)] : []
213
+ ] });
214
+ }
215
+ function newGetCompanyByExternalIDStep(configuration) {
216
+ const { connection, connectionName, found, notFound, providerRejected, invalidResponse, defect, ...stepConfiguration } = configuration;
217
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
218
+ return newQueryStep({ ...stepConfiguration, operation: connection.operations.getCompanyByExternalID(), connection: connection.reference, branches: [
219
+ goToBranch("found", found),
220
+ ...notFound ? [goToBranch("notFound", notFound)] : [],
221
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
222
+ ...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
223
+ ...defect ? [goToBranch("defect", defect)] : []
224
+ ] });
225
+ }
226
+ function newCreateCompanyStep(configuration) {
227
+ const { connection, connectionName, created, alreadyExists, providerRejected, uncertain, defect, ...stepConfiguration } = configuration;
228
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
229
+ return newMutationStep({ ...stepConfiguration, operation: connection.operations.createCompany(), connection: connection.reference, branches: [
230
+ goToBranch("created", created),
231
+ ...alreadyExists ? [goToBranch("alreadyExists", alreadyExists)] : [],
232
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
233
+ ...uncertain ? [goToBranch("uncertain", uncertain)] : [],
234
+ ...defect ? [goToBranch("defect", defect)] : []
235
+ ] });
236
+ }
237
+ function newUpsertCompanyStep(configuration) {
238
+ const { connection, connectionName, synced, providerRejected, invalidResponse, defect, maxSends, ...stepConfiguration } = configuration;
239
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
240
+ return newMutationStep({ ...stepConfiguration, operation: connection.operations.upsertCompany(), connection: connection.reference, branches: [
241
+ goToBranch("synced", synced),
242
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
243
+ ...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
244
+ ...defect ? [goToBranch("defect", defect)] : []
245
+ ] });
246
+ }
247
+ function newDeleteCompanyStep(configuration) {
248
+ const { connection, connectionName, deleted, providerRejected, invalidResponse, defect, maxSends, ...stepConfiguration } = configuration;
249
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
250
+ return newMutationStep({ ...stepConfiguration, operation: connection.operations.deleteCompany(), connection: connection.reference, branches: [
251
+ goToBranch("deleted", deleted),
252
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
253
+ ...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
254
+ ...defect ? [goToBranch("defect", defect)] : []
255
+ ] });
256
+ }
257
+ function newGetActivityPagingTokenStep(configuration) {
258
+ const { connection, connectionName, found, providerRejected, invalidResponse, defect, ...stepConfiguration } = configuration;
259
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
260
+ return newQueryStep({ ...stepConfiguration, operation: connection.operations.getActivityPagingToken(), connection: connection.reference, branches: [
261
+ goToBranch("found", found),
262
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
263
+ ...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
264
+ ...defect ? [goToBranch("defect", defect)] : []
265
+ ] });
266
+ }
267
+ function newListActivityTypesStep(configuration) {
268
+ const { connection, connectionName, found, providerRejected, invalidResponse, defect, ...stepConfiguration } = configuration;
269
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
270
+ return newQueryStep({ ...stepConfiguration, operation: connection.operations.listActivityTypes(), connection: connection.reference, branches: [
271
+ goToBranch("found", found),
272
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
273
+ ...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
274
+ ...defect ? [goToBranch("defect", defect)] : []
275
+ ] });
276
+ }
277
+ function newListActivitiesStep(configuration) {
278
+ const { connection, connectionName, found, providerRejected, invalidResponse, defect, ...stepConfiguration } = configuration;
279
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
280
+ return newQueryStep({ ...stepConfiguration, operation: connection.operations.listActivities(), connection: connection.reference, branches: [
281
+ goToBranch("found", found),
282
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
283
+ ...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
284
+ ...defect ? [goToBranch("defect", defect)] : []
285
+ ] });
286
+ }
287
+ function newCreateLeadStep(configuration) {
288
+ const { connection, connectionName, created, alreadyExists, providerRejected, uncertain, defect, ...stepConfiguration } = configuration;
289
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
290
+ return newMutationStep({ ...stepConfiguration, operation: connection.operations.createLead(), connection: connection.reference, branches: [
291
+ goToBranch("created", created),
292
+ ...alreadyExists ? [goToBranch("alreadyExists", alreadyExists)] : [],
293
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
294
+ ...uncertain ? [goToBranch("uncertain", uncertain)] : [],
295
+ ...defect ? [goToBranch("defect", defect)] : []
296
+ ] });
297
+ }
298
+ function newUpsertLeadByEmailStep(configuration) {
299
+ const { connection, connectionName, synced, providerRejected, invalidResponse, defect, maxSends, ...stepConfiguration } = configuration;
300
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
301
+ return newMutationStep({ ...stepConfiguration, operation: connection.operations.upsertLeadByEmail(), connection: connection.reference, branches: [
302
+ goToBranch("synced", synced),
303
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
304
+ ...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
305
+ ...defect ? [goToBranch("defect", defect)] : []
306
+ ] });
307
+ }
26
308
  function newGetLeadStep(configuration) {
27
309
  const { connection, connectionName, found, notFound, providerRejected, invalidResponse, defect, ...stepConfiguration } = configuration;
28
310
  if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
@@ -34,14 +316,35 @@ function newGetLeadStep(configuration) {
34
316
  ...defect ? [goToBranch("defect", defect)] : []
35
317
  ] });
36
318
  }
319
+ function newFindLeadsByEmailStep(configuration) {
320
+ const { connection, connectionName, found, providerRejected, invalidResponse, defect, ...stepConfiguration } = configuration;
321
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
322
+ return newQueryStep({ ...stepConfiguration, operation: connection.operations.findLeadsByEmail(), connection: connection.reference, branches: [
323
+ goToBranch("found", found),
324
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
325
+ ...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
326
+ ...defect ? [goToBranch("defect", defect)] : []
327
+ ] });
328
+ }
329
+ function newUpdateLeadStep(configuration) {
330
+ const { connection, connectionName, updated, notFound, providerRejected, invalidResponse, defect, maxSends, ...stepConfiguration } = configuration;
331
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
332
+ return newMutationStep({ ...stepConfiguration, operation: connection.operations.updateLead(), connection: connection.reference, branches: [
333
+ goToBranch("updated", updated),
334
+ ...notFound ? [goToBranch("notFound", notFound)] : [],
335
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
336
+ ...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
337
+ ...defect ? [goToBranch("defect", defect)] : []
338
+ ] });
339
+ }
37
340
 
38
341
  // src/project.ts
39
342
  import { z } from "zod";
40
343
 
41
344
  // src/client.ts
42
- import { ReauthorizationRequiredError, SecretString, newQueryBranch, newQueryRetry, resolveCredential } from "@superdurable/connectors-sdk";
345
+ import { ReauthorizationRequiredError, SecretString, newQueryBranch as newQueryBranch2, newQueryRetry as newQueryRetry2, resolveCredential } from "@superdurable/connectors-sdk";
43
346
  import { ManifestCredentialRefreshDriver } from "@superdurable/connectors-sdk/oauthtoken";
44
- import { BodyTooLargeError, isHeaderSafeCredential, parseRetryAfter, sendProviderRequest, validateBaseURL } from "@superdurable/connectors-sdk/providerhttp";
347
+ import { BodyTooLargeError, ProviderTransportError, isHeaderSafeCredential, parseRetryAfter, sendProviderRequest, validateBaseURL } from "@superdurable/connectors-sdk/providerhttp";
45
348
 
46
349
  // src/generated/refresh.ts
47
350
  var Authorization = {
@@ -93,6 +396,656 @@ var CredentialFields = {
93
396
  "client_secret": "clientSecret"
94
397
  };
95
398
 
399
+ // src/management.ts
400
+ import { isIP } from "net";
401
+ import {
402
+ definitionMaxSends,
403
+ newMutationBranch,
404
+ newMutationRetry,
405
+ newMutationUncertain,
406
+ newQueryBranch,
407
+ newQueryRetry
408
+ } from "@superdurable/connectors-sdk";
409
+ import { Fence } from "@superdurable/connectors-sdk/singledispatch";
410
+ var transientRates = /* @__PURE__ */ new Set(["602", "606", "607", "615"]);
411
+ var transientAvailability = /* @__PURE__ */ new Set(["604", "608", "611", "614", "500", "502"]);
412
+ var refusalStatuses = /* @__PURE__ */ new Set([400, 401, 403, 404, 411, 413, 414, 415, 422]);
413
+ var leadsPath = "/v1/leads.json";
414
+ var leadFields = "id,firstName,lastName";
415
+ var company = {
416
+ path: "/v1/companies.json",
417
+ deletePath: "/v1/companies/delete.json",
418
+ externalField: "externalCompanyId",
419
+ identityField: "id",
420
+ nameField: "company",
421
+ externalLimit: 255
422
+ };
423
+ var opportunity = {
424
+ path: "/v1/opportunities.json",
425
+ deletePath: "/v1/opportunities/delete.json",
426
+ externalField: "externalOpportunityId",
427
+ identityField: "marketoGUID",
428
+ nameField: "name",
429
+ externalLimit: 50
430
+ };
431
+ var Operation = class {
432
+ /** Bind the provider client. */
433
+ constructor(client) {
434
+ this.client = client;
435
+ }
436
+ client;
437
+ failure(issue) {
438
+ return { kind: issue.kind, provider: "adobe-marketo", operation: this.operation, message: issue.message };
439
+ }
440
+ };
441
+ var ReadOperation = class extends Operation {
442
+ /** Return the manifest-generated Query definition. */
443
+ definition() {
444
+ return this.contract;
445
+ }
446
+ defect(empty, message) {
447
+ return newQueryBranch("defect", empty, {}, this.failure({ kind: "VALIDATION", message }));
448
+ }
449
+ async read(call, request) {
450
+ const exchange = await this.client.request(call, "GET", request.path);
451
+ let issue = exchangeProblem(exchange, request.resource ?? false, request.authBranch);
452
+ if (!issue) {
453
+ try {
454
+ const envelope = readEnvelope(exchange.body);
455
+ if (!envelope.success) issue = transientCode(
456
+ errorCode(envelope, "errors", request.resource),
457
+ exchange.retryAfterMs
458
+ ) ?? rejected();
459
+ else {
460
+ const value = request.decode(envelope);
461
+ return value === void 0 ? newQueryBranch("notFound", request.empty) : newQueryBranch("found", value);
462
+ }
463
+ } catch {
464
+ issue = invalid();
465
+ }
466
+ }
467
+ return issue.branch ? newQueryBranch(issue.branch, request.empty, {}, this.failure(issue)) : newQueryRetry(this.failure(issue), issue.delay);
468
+ }
469
+ };
470
+ var WriteOperation = class extends Operation {
471
+ /** Return the manifest-generated Mutation definition. */
472
+ definition() {
473
+ return this.contract;
474
+ }
475
+ /** Correlate attempts with the original Dex call. */
476
+ idempotencyKey(callID) {
477
+ return callID;
478
+ }
479
+ outcome(empty, issue) {
480
+ if (issue.branch && issue.branch !== "invalidResponse")
481
+ return newMutationBranch(issue.branch, empty, {}, this.failure(issue));
482
+ return newMutationRetry(this.failure(issue), issue.delay);
483
+ }
484
+ defect(empty, message) {
485
+ return this.outcome(empty, { kind: "VALIDATION", message, branch: "defect" });
486
+ }
487
+ async safeWrite(call, request) {
488
+ const { empty, resource, updateId, branch } = request;
489
+ const exchange = await this.client.request(call, "POST", request.path, request.payload);
490
+ const first = (call.context.attempt ?? 1) === 1;
491
+ if (exchange.error === "credential" && !first || ![0, 200, 429, 503].includes(exchange.status) && (!first || !definiteRefusal(exchange)))
492
+ return this.outcome(empty, transport(resource ? exchange.retryAfterMs : 0));
493
+ const issue = exchangeProblem(exchange, Boolean(resource));
494
+ if (issue) return this.outcome(empty, issue);
495
+ let result;
496
+ try {
497
+ result = readWrite(exchange.body, resource, updateId !== void 0);
498
+ } catch {
499
+ return this.outcome(empty, invalid());
500
+ }
501
+ const transient = transientCode(result.code, exchange.retryAfterMs);
502
+ if (transient) return this.outcome(empty, transient);
503
+ if (updateId !== void 0 && result.code === "702") return this.outcome(empty, first ? { branch: "notFound", kind: "NOT_FOUND", message: "Marketo lead was not found" } : { kind: "NOT_FOUND", message: "Marketo lead update is inconclusive" });
504
+ let valid;
505
+ if (branch === "deleted") valid = result.code === "1013" || !result.code && result.status === "deleted";
506
+ else if (branch === "updated") valid = !result.code && idText(result.identity) === idText(updateId) && result.status === "updated";
507
+ else {
508
+ if (!resource && ["1005", "1007"].includes(result.code) || resource && first && result.code === "1005")
509
+ return this.outcome(empty, rejected());
510
+ valid = !result.code && hasIdentity(result.identity) && ["created", "updated"].includes(result.status);
511
+ }
512
+ if (!valid) return this.outcome(empty, invalid());
513
+ return newMutationBranch(branch, request.convert(result), receipt(call, idText(result.identity)));
514
+ }
515
+ async limited(call, request) {
516
+ const { empty, resource } = request;
517
+ const maxSends = call.maxSendsOverride ?? definitionMaxSends(this.contract);
518
+ let fence;
519
+ try {
520
+ fence = new Fence(call, this.contract.stepDefaults.executeMethodTimeoutMs, { maxSends });
521
+ } catch {
522
+ return this.outcome(empty, { branch: "defect", kind: "LOCAL_DEFECT", message: "dispatch fence is unavailable" });
523
+ }
524
+ const decision = fence.decide();
525
+ const checkpoint = { kind: "AVAILABILITY", message: "Marketo creation checkpoint is unavailable" };
526
+ if (decision.kind === "failClosed") return this.outcome(empty, checkpoint);
527
+ if (decision.kind === "readBackRequired") return this.uncertain(call, empty, "TRANSPORT");
528
+ const prior = decision.priorSendUpperBound ?? 0;
529
+ const unknown = (kind) => prior + 1 >= maxSends ? this.uncertain(call, empty, kind) : this.outcome(empty, { kind, message: "Marketo create outcome is unknown" });
530
+ let exchange;
531
+ try {
532
+ exchange = await fence.dispatch((signal) => this.client.request(call, "POST", request.path, request.payload, signal));
533
+ } catch {
534
+ return this.outcome(empty, checkpoint);
535
+ }
536
+ const protocol = resource ? "TRANSPORT" : "PROTOCOL";
537
+ if (exchange.error === "credential" || exchange.error === "refresh") {
538
+ if (prior || decision.marker?.providerId) return unknown(resource ? "TRANSPORT" : "AUTHENTICATION");
539
+ if (!await recordRefusal(fence)) return this.outcome(empty, checkpoint);
540
+ return this.outcome(empty, exchange.error === "credential" ? authorization() : transport());
541
+ }
542
+ if (exchange.error === "request") return unknown("TRANSPORT");
543
+ if (exchange.status === 429 || exchange.status === 503) {
544
+ if (!await recordRefusal(fence)) return this.outcome(empty, checkpoint);
545
+ return this.outcome(empty, temporary(exchange.status, exchange.retryAfterMs));
546
+ }
547
+ if (exchange.status !== 200) {
548
+ if (!prior && definiteRefusal(exchange)) {
549
+ if (!await recordRefusal(fence)) return this.outcome(empty, checkpoint);
550
+ return this.outcome(empty, rejected());
551
+ }
552
+ return unknown(resource ? "TRANSPORT" : "AVAILABILITY");
553
+ }
554
+ if (exchange.error) return unknown(protocol);
555
+ let result;
556
+ try {
557
+ result = readWrite(exchange.body, resource);
558
+ } catch {
559
+ return unknown(protocol);
560
+ }
561
+ const transient = transientCode(result.code, exchange.retryAfterMs);
562
+ if (transient) return this.outcome(empty, transient);
563
+ if (result.code === "1005") {
564
+ if (prior) return unknown("TRANSPORT");
565
+ if (!await recordRefusal(fence)) return this.outcome(empty, checkpoint);
566
+ return this.outcome(empty, { branch: "alreadyExists", kind: "PROVIDER_REJECTION", message: "Marketo already has this record" });
567
+ }
568
+ if (result.code || !hasIdentity(result.identity) || result.status !== "created") return unknown(protocol);
569
+ const id = idText(result.identity);
570
+ try {
571
+ await fence.recordProviderId(id);
572
+ } catch {
573
+ }
574
+ return newMutationBranch("created", request.convert(result), receipt(call, id));
575
+ }
576
+ uncertain(call, empty, kind) {
577
+ return newMutationUncertain(
578
+ empty,
579
+ this.failure({ kind, message: "Marketo create reached the send cap without confirmation" }),
580
+ receipt(call, this.operation === "createOpportunity" ? "" : "0")
581
+ );
582
+ }
583
+ };
584
+ var GetOpportunityByExternalIDOperation = class extends ReadOperation {
585
+ operation = "getOpportunityByExternalID";
586
+ contract = GetOpportunityByExternalIDDefinition;
587
+ /** Read one opportunity GUID and name by its external ID. */
588
+ async invoke(call, input) {
589
+ const empty = { marketoGUID: "", name: "" };
590
+ if (!validExternalID(opportunity, input.externalOpportunityId)) return this.defect(empty, "Marketo external ID is invalid");
591
+ return this.read(call, {
592
+ path: lookupPath(opportunity, input.externalOpportunityId),
593
+ empty,
594
+ decode: opportunityProfile,
595
+ resource: true
596
+ });
597
+ }
598
+ };
599
+ var CreateOpportunityOperation = class extends WriteOperation {
600
+ operation = "createOpportunity";
601
+ contract = CreateOpportunityDefinition;
602
+ /** Create one opportunity by external ID with bounded sends. */
603
+ async invoke(call, input) {
604
+ const empty = { marketoGUID: "", status: "" };
605
+ if (!validExternalID(opportunity, input.externalOpportunityId) || !validName(input.name))
606
+ return this.defect(empty, "Marketo external ID or name is invalid");
607
+ return this.limited(call, {
608
+ path: opportunity.path,
609
+ payload: resourceBody(opportunity, "createOnly", input.externalOpportunityId, input.name),
610
+ empty,
611
+ convert: (result) => ({ marketoGUID: idText(result.identity), status: result.status }),
612
+ resource: opportunity
613
+ });
614
+ }
615
+ };
616
+ var UpsertOpportunityOperation = class extends WriteOperation {
617
+ operation = "upsertOpportunity";
618
+ contract = UpsertOpportunityDefinition;
619
+ /** Create or replace an opportunity name using its external ID. */
620
+ async invoke(call, input) {
621
+ const empty = { marketoGUID: "", status: "" };
622
+ if (!validExternalID(opportunity, input.externalOpportunityId) || !validName(input.name))
623
+ return this.defect(empty, "Marketo external ID or name is invalid");
624
+ return this.safeWrite(call, {
625
+ path: opportunity.path,
626
+ payload: resourceBody(opportunity, "createOrUpdate", input.externalOpportunityId, input.name),
627
+ empty,
628
+ branch: "synced",
629
+ convert: (result) => ({ marketoGUID: idText(result.identity), status: result.status }),
630
+ resource: opportunity
631
+ });
632
+ }
633
+ };
634
+ var DeleteOpportunityOperation = class extends WriteOperation {
635
+ operation = "deleteOpportunity";
636
+ contract = DeleteOpportunityDefinition;
637
+ /** Delete an opportunity by external ID. */
638
+ async invoke(call, input) {
639
+ const empty = { deleted: false };
640
+ if (!validExternalID(opportunity, input.externalOpportunityId)) return this.defect(empty, "Marketo external ID is invalid");
641
+ return this.safeWrite(call, {
642
+ path: opportunity.deletePath,
643
+ payload: resourceDelete(opportunity, input.externalOpportunityId),
644
+ empty,
645
+ branch: "deleted",
646
+ convert: () => ({ deleted: true }),
647
+ resource: opportunity
648
+ });
649
+ }
650
+ };
651
+ var GetCompanyByExternalIDOperation = class extends ReadOperation {
652
+ operation = "getCompanyByExternalID";
653
+ contract = GetCompanyByExternalIDDefinition;
654
+ /** Read one company ID and name by its external company ID. */
655
+ async invoke(call, input) {
656
+ const empty = { id: 0, company: "" };
657
+ if (!validExternalID(company, input.externalCompanyId)) return this.defect(empty, "Marketo external ID is invalid");
658
+ return this.read(call, {
659
+ path: lookupPath(company, input.externalCompanyId),
660
+ empty,
661
+ decode: companyProfile,
662
+ resource: true
663
+ });
664
+ }
665
+ };
666
+ var CreateCompanyOperation = class extends WriteOperation {
667
+ operation = "createCompany";
668
+ contract = CreateCompanyDefinition;
669
+ /** Create one company by external ID with bounded sends. */
670
+ async invoke(call, input) {
671
+ const empty = { id: 0, status: "" };
672
+ if (!validExternalID(company, input.externalCompanyId) || !validName(input.company))
673
+ return this.defect(empty, "Marketo external ID or name is invalid");
674
+ return this.limited(call, {
675
+ path: company.path,
676
+ payload: resourceBody(company, "createOnly", input.externalCompanyId, input.company),
677
+ empty,
678
+ convert: (result) => ({ id: decodeSignedInteger(result.identity), status: result.status }),
679
+ resource: company
680
+ });
681
+ }
682
+ };
683
+ var UpsertCompanyOperation = class extends WriteOperation {
684
+ operation = "upsertCompany";
685
+ contract = UpsertCompanyDefinition;
686
+ /** Create or replace a company's name using its external ID. */
687
+ async invoke(call, input) {
688
+ const empty = { id: 0, status: "" };
689
+ if (!validExternalID(company, input.externalCompanyId) || !validName(input.company))
690
+ return this.defect(empty, "Marketo external ID or name is invalid");
691
+ return this.safeWrite(call, {
692
+ path: company.path,
693
+ payload: resourceBody(company, "createOrUpdate", input.externalCompanyId, input.company),
694
+ empty,
695
+ branch: "synced",
696
+ convert: (result) => ({ id: decodeSignedInteger(result.identity), status: result.status }),
697
+ resource: company
698
+ });
699
+ }
700
+ };
701
+ var DeleteCompanyOperation = class extends WriteOperation {
702
+ operation = "deleteCompany";
703
+ contract = DeleteCompanyDefinition;
704
+ /** Delete a company by external ID. */
705
+ async invoke(call, input) {
706
+ const empty = { deleted: false };
707
+ if (!validExternalID(company, input.externalCompanyId)) return this.defect(empty, "Marketo external ID is invalid");
708
+ return this.safeWrite(call, {
709
+ path: company.deletePath,
710
+ payload: resourceDelete(company, input.externalCompanyId),
711
+ empty,
712
+ branch: "deleted",
713
+ convert: () => ({ deleted: true }),
714
+ resource: company
715
+ });
716
+ }
717
+ };
718
+ var GetActivityPagingTokenOperation = class extends ReadOperation {
719
+ operation = "getActivityPagingToken";
720
+ contract = GetActivityPagingTokenDefinition;
721
+ /** Get an activity cursor for an ISO 8601 date and time. */
722
+ async invoke(call, input) {
723
+ const empty = { nextPageToken: "" };
724
+ if (!validDate(input.sinceDatetime)) return this.defect(empty, "activity timestamp must use RFC 3339 with a timezone");
725
+ return this.read(call, {
726
+ path: withQuery("/v1/activities/pagingtoken.json", { sinceDatetime: input.sinceDatetime }),
727
+ empty,
728
+ decode: pagingToken,
729
+ authBranch: "providerRejected"
730
+ });
731
+ }
732
+ };
733
+ var ListActivityTypesOperation = class extends ReadOperation {
734
+ operation = "listActivityTypes";
735
+ contract = ListActivityTypesDefinition;
736
+ /** List activity type IDs and names without provider attributes. */
737
+ async invoke(call, _input) {
738
+ void _input;
739
+ return this.read(call, { path: "/v1/activities/types.json", empty: { types: [] }, decode: activityTypes });
740
+ }
741
+ };
742
+ var ListActivitiesOperation = class extends ReadOperation {
743
+ operation = "listActivities";
744
+ contract = ListActivitiesDefinition;
745
+ /** Read one page of activity IDs, lead IDs, types, and dates without activity attributes. */
746
+ async invoke(call, input) {
747
+ const empty = { activities: [], nextPageToken: "", moreResult: false };
748
+ const { nextPageToken, activityTypeIds: ids } = input;
749
+ if (!validToken(nextPageToken) || !ids?.length || ids.length > 10 || !ids.every(positive))
750
+ return this.defect(empty, "activity cursor or type IDs are invalid");
751
+ return this.read(call, {
752
+ path: withQuery("/v1/activities.json", { nextPageToken, activityTypeIds: ids.map(idText).join(",") }),
753
+ empty,
754
+ decode: activityPage,
755
+ authBranch: "providerRejected"
756
+ });
757
+ }
758
+ };
759
+ var CreateLeadOperation = class extends WriteOperation {
760
+ operation = "createLead";
761
+ contract = CreateLeadDefinition;
762
+ /** Create one lead by email with createOnly and bounded sends. */
763
+ async invoke(call, input) {
764
+ const empty = { id: 0, status: "" };
765
+ if (!ascii(input.email) || !validEmail(input.email)) return this.defect(empty, "email must be a valid ASCII address");
766
+ return this.limited(call, {
767
+ path: leadsPath,
768
+ payload: leadBody("createOnly", "email", input.email, input.firstName, input.lastName),
769
+ empty,
770
+ convert: (result) => ({ id: decodeSignedInteger(result.identity), status: result.status })
771
+ });
772
+ }
773
+ };
774
+ var UpsertLeadByEmailOperation = class extends WriteOperation {
775
+ operation = "upsertLeadByEmail";
776
+ contract = UpsertLeadByEmailDefinition;
777
+ /** Create or replace selected names on the lead matching one email. */
778
+ async invoke(call, input) {
779
+ const empty = { id: 0, status: "" };
780
+ if (!ascii(input.email) || !validEmail(input.email) || input.firstName == null && input.lastName == null)
781
+ return this.defect(empty, "email or name fields are invalid");
782
+ return this.safeWrite(call, {
783
+ path: leadsPath,
784
+ payload: leadBody("createOrUpdate", "email", input.email, input.firstName, input.lastName),
785
+ empty,
786
+ branch: "synced",
787
+ convert: (result) => ({ id: decodeSignedInteger(result.identity), status: result.status })
788
+ });
789
+ }
790
+ };
791
+ var FindLeadsByEmailOperation = class extends ReadOperation {
792
+ operation = "findLeadsByEmail";
793
+ contract = FindLeadsByEmailDefinition;
794
+ /** Find a cursor page of leads by email, returning only IDs and names. */
795
+ async invoke(call, input) {
796
+ const empty = { leads: [], nextPageToken: "" };
797
+ const nextPageToken = input.nextPageToken ?? "";
798
+ if (!validEmail(input.email) || !validToken(nextPageToken, true)) return this.defect(empty, "email or page token is invalid");
799
+ const query = { filterType: "email", filterValues: input.email, fields: leadFields, ...nextPageToken ? { nextPageToken } : {} };
800
+ return this.read(call, { path: withQuery(leadsPath, query), empty, decode: leadPage });
801
+ }
802
+ };
803
+ var UpdateLeadOperation = class extends WriteOperation {
804
+ operation = "updateLead";
805
+ contract = UpdateLeadDefinition;
806
+ /** Set one lead's selected names by ID using Marketo updateOnly. */
807
+ async invoke(call, input) {
808
+ const empty = { id: 0, status: "" };
809
+ if (!positive(input.leadId) || input.firstName == null && input.lastName == null)
810
+ return this.defect(empty, "lead ID or names are invalid");
811
+ return this.safeWrite(call, {
812
+ path: leadsPath,
813
+ payload: leadBody("updateOnly", "id", input.leadId, input.firstName, input.lastName),
814
+ empty,
815
+ branch: "updated",
816
+ updateId: input.leadId,
817
+ convert: (result) => ({ id: decodeSignedInteger(result.identity), status: result.status })
818
+ });
819
+ }
820
+ };
821
+ function receipt(call, id) {
822
+ return {
823
+ callId: call.id,
824
+ provider: "adobe-marketo",
825
+ observedAt: (/* @__PURE__ */ new Date()).toISOString(),
826
+ ...id ? { providerObjectId: id } : {},
827
+ ...call.idempotencyKey ? { idempotencyKey: call.idempotencyKey } : {}
828
+ };
829
+ }
830
+ function invalid() {
831
+ return { branch: "invalidResponse", kind: "PROTOCOL", message: "Marketo returned incomplete or invalid data" };
832
+ }
833
+ function rejected() {
834
+ return { branch: "providerRejected", kind: "PROVIDER_REJECTION", message: "Marketo rejected the request" };
835
+ }
836
+ function authorization(branch = "defect") {
837
+ return { branch, kind: "AUTHENTICATION", message: "Marketo connection needs authorization" };
838
+ }
839
+ function transport(delay = 0) {
840
+ return { kind: "TRANSPORT", message: "Marketo request or credential refresh failed", delay };
841
+ }
842
+ function temporary(status, delay) {
843
+ return { kind: status === 429 ? "RATE_LIMIT" : "AVAILABILITY", message: "Marketo is temporarily unavailable", delay };
844
+ }
845
+ function exchangeProblem(exchange, resource, authBranch = "defect") {
846
+ if (exchange.error === "credential") return authorization(authBranch);
847
+ if (exchange.error === "refresh" || exchange.error === "request") return transport(resource ? exchange.retryAfterMs : 0);
848
+ if (exchange.status === 408 || exchange.status === 429 || exchange.status >= 500)
849
+ return temporary(exchange.status, exchange.retryAfterMs);
850
+ if (exchange.status !== 200) return rejected();
851
+ if (exchange.error && resource) return invalid();
852
+ if (exchange.error === "tooLarge")
853
+ return { branch: "invalidResponse", kind: "RESPONSE_TOO_LARGE", message: "Marketo response exceeded the configured limit" };
854
+ if (exchange.error) return transport();
855
+ return void 0;
856
+ }
857
+ function transientCode(code, delay) {
858
+ if (transientRates.has(code)) return temporary(429, delay);
859
+ if (transientAvailability.has(code)) return temporary(503, delay);
860
+ return void 0;
861
+ }
862
+ function definiteRefusal(exchange) {
863
+ if (exchange.error || !refusalStatuses.has(exchange.status)) return false;
864
+ try {
865
+ const envelope = readEnvelope(exchange.body);
866
+ return envelope.success === false && Boolean(errorCode(envelope, "errors"));
867
+ } catch {
868
+ return false;
869
+ }
870
+ }
871
+ async function recordRefusal(fence) {
872
+ try {
873
+ await fence.recordCanResend();
874
+ return true;
875
+ } catch {
876
+ return false;
877
+ }
878
+ }
879
+ function withQuery(path, values) {
880
+ const params = new URLSearchParams(values);
881
+ params.sort();
882
+ return path + "?" + params.toString().replaceAll("*", "%2A").replaceAll("%7E", "~");
883
+ }
884
+ function lookupPath(resource, id) {
885
+ return withQuery(resource.path, {
886
+ filterType: resource.externalField,
887
+ filterValues: id,
888
+ fields: `${resource.identityField},${resource.nameField}`
889
+ });
890
+ }
891
+ function ascii(value) {
892
+ return [...value].every((character) => character.charCodeAt(0) < 128);
893
+ }
894
+ function validExternalID(resource, id) {
895
+ return Boolean(id) && id.length <= resource.externalLimit && ascii(id) && id.trim() === id;
896
+ }
897
+ function validName(name) {
898
+ return Boolean(name) && Buffer.byteLength(name) <= 255 && name.trim() === name;
899
+ }
900
+ function validEmail(value) {
901
+ const separator = value.indexOf("@");
902
+ if (separator < 1 || /[\uD800-\uDFFF]/u.test(value) || !emailAtom(value.slice(0, separator))) return false;
903
+ const domain = value.slice(separator + 1);
904
+ if (domain.startsWith("[") && domain.endsWith("]")) {
905
+ const literal = domain.slice(1, -1);
906
+ return !literal.includes("%") && isIP(literal) !== 0;
907
+ }
908
+ return emailAtom(domain);
909
+ }
910
+ function emailAtom(value) {
911
+ const excluded = '()<>[]:;@\\,"';
912
+ return Boolean(value) && value.trim() === value && !value.startsWith(".") && !value.endsWith(".") && !value.includes("..") && [...value].every((character) => character.charCodeAt(0) >= 128 || character >= "!" && character <= "~" && !excluded.includes(character));
913
+ }
914
+ function validDate(value) {
915
+ const match = /^(\d{4})-(\d{2})-(\d{2})T(\d{1,2}):(\d{2}):(\d{2})(?:[.,]\d+)?(?:Z|[+-](\d{2}):(\d{2}))(?![\s\S])/.exec(value);
916
+ if (!match) return false;
917
+ const year = Number(match[1]), month = Number(match[2]), day = Number(match[3]);
918
+ const hour = Number(match[4]), minute = Number(match[5]), second = Number(match[6]);
919
+ const offsetHour = Number(match[7] ?? "0"), offsetMinute = Number(match[8] ?? "0");
920
+ const leap = year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
921
+ const days = [31, leap ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
922
+ return month >= 1 && month <= 12 && day >= 1 && day <= days[month - 1] && hour < 24 && minute < 60 && second < 60 && offsetHour <= 24 && offsetMinute <= 60;
923
+ }
924
+ function validToken(value, optional = false) {
925
+ return Boolean(value || optional) && Buffer.byteLength(value) <= 2048 && !/[\r\n]/.test(value);
926
+ }
927
+ function resourceBody(resource, action, id, name) {
928
+ return { action, dedupeBy: "dedupeFields", input: [{ [resource.externalField]: id, [resource.nameField]: name }] };
929
+ }
930
+ function resourceDelete(resource, id) {
931
+ return { deleteBy: "dedupeFields", input: [{ [resource.externalField]: id }] };
932
+ }
933
+ function leadBody(action, lookupField, id, first, last) {
934
+ const record = { [lookupField]: id };
935
+ if (first != null) record.firstName = first;
936
+ if (last != null) record.lastName = last;
937
+ return { action, lookupField, input: [record] };
938
+ }
939
+ function idText(id) {
940
+ return typeof id === "object" ? id.rawJSON : String(id);
941
+ }
942
+ function positive(value) {
943
+ try {
944
+ return BigInt(idText(decodeSignedInteger(value))) > 0n;
945
+ } catch {
946
+ return false;
947
+ }
948
+ }
949
+ function hasIdentity(id) {
950
+ return typeof id === "string" ? id !== "" : positive(id);
951
+ }
952
+ function document(value) {
953
+ if (!value || typeof value !== "object" || Array.isArray(value) || JSON.isRawJSON(value))
954
+ throw new TypeError("expected Marketo object");
955
+ return value;
956
+ }
957
+ function readEnvelope(body) {
958
+ const envelope = document(parseJSONNumberTokens(new TextDecoder("utf-8", { fatal: true }).decode(body)));
959
+ if (typeof envelope.success !== "boolean") throw new TypeError("invalid Marketo success flag");
960
+ return envelope;
961
+ }
962
+ function text(row, key) {
963
+ const value = row[key];
964
+ if (value == null) return "";
965
+ if (typeof value !== "string") throw new TypeError(`invalid Marketo text ${key}`);
966
+ return value;
967
+ }
968
+ function integer(row, key) {
969
+ return decodeSignedInteger(row[key] ?? 0);
970
+ }
971
+ function rows(envelope, key = "result") {
972
+ const values = envelope[key];
973
+ if (!Array.isArray(values)) throw new TypeError(`missing Marketo ${key}`);
974
+ return values.map((value) => value === null ? {} : document(value));
975
+ }
976
+ function errorCode(envelope, key, allowEmpty = false) {
977
+ if (allowEmpty && envelope[key] == null) return "";
978
+ const values = rows(envelope, key);
979
+ if (values.length) return text(values[0], "code");
980
+ if (allowEmpty) return "";
981
+ throw new TypeError("missing Marketo error code");
982
+ }
983
+ function readWrite(body, resource, updateOnly = false) {
984
+ const envelope = readEnvelope(body);
985
+ const zero = resource?.identityField === "marketoGUID" ? "" : 0;
986
+ if (!envelope.success) return { identity: zero, status: "", code: errorCode(envelope, "errors") || "unknown" };
987
+ const values = rows(envelope);
988
+ if (values.length !== 1) throw new TypeError("unexpected Marketo write result count");
989
+ const row = values[0];
990
+ const identity = resource?.identityField === "marketoGUID" ? text(row, "marketoGUID") : integer(row, "id");
991
+ const status = text(row, "status");
992
+ const code = status === "skipped" && !updateOnly ? errorCode(row, "reasons") || "unknown" : "";
993
+ return { identity, status, code };
994
+ }
995
+ function resourceRow(envelope) {
996
+ const values = rows(envelope);
997
+ if (values.length > 1) throw new TypeError("Marketo returned multiple matches");
998
+ return values[0];
999
+ }
1000
+ function companyProfile(envelope) {
1001
+ const row = resourceRow(envelope);
1002
+ if (!row) return void 0;
1003
+ const id = integer(row, "id");
1004
+ if (!positive(id)) throw new TypeError("Marketo company ID is missing");
1005
+ return { id, company: text(row, "company") };
1006
+ }
1007
+ function opportunityProfile(envelope) {
1008
+ const row = resourceRow(envelope);
1009
+ if (!row) return void 0;
1010
+ const marketoGUID = text(row, "marketoGUID");
1011
+ if (!marketoGUID) throw new TypeError("Marketo opportunity GUID is missing");
1012
+ return { marketoGUID, name: text(row, "name") };
1013
+ }
1014
+ function pagingToken(envelope) {
1015
+ const nextPageToken = text(envelope, "nextPageToken");
1016
+ if (!validToken(nextPageToken)) throw new TypeError("invalid Marketo activity cursor");
1017
+ return { nextPageToken };
1018
+ }
1019
+ function activityTypes(envelope) {
1020
+ return { types: rows(envelope).map((row) => {
1021
+ const id = integer(row, "id"), name = text(row, "name");
1022
+ if (!positive(id) || !name) throw new TypeError("invalid Marketo activity type");
1023
+ return { id, name };
1024
+ }) };
1025
+ }
1026
+ function activityPage(envelope) {
1027
+ const moreResult = envelope.moreResult;
1028
+ if (typeof moreResult !== "boolean") throw new TypeError("invalid Marketo activity pagination");
1029
+ const { nextPageToken } = pagingToken(envelope);
1030
+ const activities = rows(envelope).map((row) => {
1031
+ const id = integer(row, "id");
1032
+ const marketoGUID = text(row, "marketoGUID") || (positive(id) ? idText(id) : "");
1033
+ const leadId = integer(row, "leadId"), activityTypeId = integer(row, "activityTypeId");
1034
+ const activityDate = text(row, "activityDate");
1035
+ if (!marketoGUID || !positive(leadId) || !positive(activityTypeId) || !activityDate)
1036
+ throw new TypeError("invalid Marketo activity");
1037
+ return { marketoGUID, leadId, activityTypeId, activityDate };
1038
+ });
1039
+ return { activities, nextPageToken, moreResult };
1040
+ }
1041
+ function leadPage(envelope) {
1042
+ return { nextPageToken: text(envelope, "nextPageToken"), leads: rows(envelope).map((row) => {
1043
+ const id = integer(row, "id");
1044
+ if (!positive(id)) throw new TypeError("Marketo lead ID is missing");
1045
+ return { id, firstName: text(row, "firstName"), lastName: text(row, "lastName") };
1046
+ }) };
1047
+ }
1048
+
96
1049
  // src/client.ts
97
1050
  var emptyProfile = () => ({ id: 0, firstName: "", lastName: "" });
98
1051
  function subscriptionURL(value, suffix) {
@@ -134,25 +1087,95 @@ var MarketoClient = class {
134
1087
  getLead() {
135
1088
  return new GetLeadOperation(this);
136
1089
  }
1090
+ /** Bind the getOpportunityByExternalID operation. */
1091
+ getOpportunityByExternalID() {
1092
+ return new GetOpportunityByExternalIDOperation(this);
1093
+ }
1094
+ /** Bind the createOpportunity operation. */
1095
+ createOpportunity() {
1096
+ return new CreateOpportunityOperation(this);
1097
+ }
1098
+ /** Bind the upsertOpportunity operation. */
1099
+ upsertOpportunity() {
1100
+ return new UpsertOpportunityOperation(this);
1101
+ }
1102
+ /** Bind the deleteOpportunity operation. */
1103
+ deleteOpportunity() {
1104
+ return new DeleteOpportunityOperation(this);
1105
+ }
1106
+ /** Bind the getCompanyByExternalID operation. */
1107
+ getCompanyByExternalID() {
1108
+ return new GetCompanyByExternalIDOperation(this);
1109
+ }
1110
+ /** Bind the createCompany operation. */
1111
+ createCompany() {
1112
+ return new CreateCompanyOperation(this);
1113
+ }
1114
+ /** Bind the upsertCompany operation. */
1115
+ upsertCompany() {
1116
+ return new UpsertCompanyOperation(this);
1117
+ }
1118
+ /** Bind the deleteCompany operation. */
1119
+ deleteCompany() {
1120
+ return new DeleteCompanyOperation(this);
1121
+ }
1122
+ /** Bind the getActivityPagingToken operation. */
1123
+ getActivityPagingToken() {
1124
+ return new GetActivityPagingTokenOperation(this);
1125
+ }
1126
+ /** Bind the listActivityTypes operation. */
1127
+ listActivityTypes() {
1128
+ return new ListActivityTypesOperation(this);
1129
+ }
1130
+ /** Bind the listActivities operation. */
1131
+ listActivities() {
1132
+ return new ListActivitiesOperation(this);
1133
+ }
1134
+ /** Bind the createLead operation. */
1135
+ createLead() {
1136
+ return new CreateLeadOperation(this);
1137
+ }
1138
+ /** Bind the upsertLeadByEmail operation. */
1139
+ upsertLeadByEmail() {
1140
+ return new UpsertLeadByEmailOperation(this);
1141
+ }
1142
+ /** Bind the findLeadsByEmail operation. */
1143
+ findLeadsByEmail() {
1144
+ return new FindLeadsByEmailOperation(this);
1145
+ }
1146
+ /** Bind the updateLead operation. */
1147
+ updateLead() {
1148
+ return new UpdateLeadOperation(this);
1149
+ }
137
1150
  /** Resolve the token and perform one bounded lead lookup. */
138
- async get(call, leadID) {
1151
+ get(call, leadID) {
1152
+ const query = new URLSearchParams({ fields: "id,firstName,lastName" });
1153
+ return this.request(call, "GET", `/v1/lead/${canonicalID(leadID)}.json?${query}`);
1154
+ }
1155
+ /** Resolve the token and send a bounded Marketo REST request. */
1156
+ async request(call, method, path, payload, signal = call.context.cancellationSignal) {
1157
+ if (!path.startsWith("/v1/")) return emptyExchange("request");
139
1158
  let token;
140
1159
  try {
141
1160
  const credentials = await resolveCredential(this.credentials, call, this.refreshDriver, call.context.cancellationSignal);
142
1161
  token = credentials.accessToken instanceof SecretString ? credentials.accessToken.reveal() : "";
143
1162
  } catch (error) {
144
- return emptyExchange(error instanceof ReauthorizationRequiredError ? "credential" : "request");
1163
+ return emptyExchange(error instanceof ReauthorizationRequiredError ? "credential" : "refresh");
145
1164
  }
146
1165
  if (!isHeaderSafeCredential(token)) return emptyExchange("credential");
147
- const query = new URLSearchParams({ fields: "id,firstName,lastName" });
148
1166
  const request = {
149
- url: `${this.restEndpoint}/v1/lead/${leadID}.json?${query}`,
150
- method: "GET",
151
- headers: { Accept: "application/json", Authorization: `Bearer ${token}` },
1167
+ url: this.restEndpoint + path,
1168
+ method,
1169
+ headers: {
1170
+ Accept: "application/json",
1171
+ Authorization: `Bearer ${token}`,
1172
+ ...payload === void 0 ? {} : { "Content-Type": "application/json" }
1173
+ },
1174
+ ...payload === void 0 ? {} : { body: Buffer.from(JSON.stringify(payload)) },
152
1175
  maxResponseBytes: this.maxResponseBytes,
153
1176
  timeoutMs: this.timeoutMs,
154
1177
  addressPolicy: "publicHTTPS",
155
- signal: call.context.cancellationSignal
1178
+ signal
156
1179
  };
157
1180
  let response;
158
1181
  let isTooLarge = false;
@@ -162,6 +1185,13 @@ var MarketoClient = class {
162
1185
  if (error instanceof BodyTooLargeError && error.status !== void 0) {
163
1186
  response = { status: error.status, headers: error.headers ?? {}, body: new Uint8Array() };
164
1187
  isTooLarge = true;
1188
+ } else if (error instanceof ProviderTransportError && error.status !== void 0) {
1189
+ return {
1190
+ status: error.status,
1191
+ body: new Uint8Array(),
1192
+ retryAfterMs: parseRetryAfter(header(error.headers ?? {}, "retry-after")),
1193
+ error: "read"
1194
+ };
165
1195
  } else return emptyExchange("request");
166
1196
  }
167
1197
  const retryAfterMs = parseRetryAfter(header(response.headers, "retry-after"));
@@ -182,17 +1212,18 @@ var GetLeadOperation = class {
182
1212
  }
183
1213
  /** Classify lead lookup outcomes consistently with Go. */
184
1214
  async invoke(call, input) {
185
- if (!Number.isSafeInteger(input?.leadId) || input.leadId <= 0)
1215
+ if (!input || !positiveID(input.leadId))
186
1216
  return terminal("defect", "VALIDATION", "Marketo lead ID must be positive");
187
1217
  const exchange = await this.client.get(call, input.leadId);
188
1218
  if (exchange.error === "credential") return terminal("defect", "AUTHENTICATION", "Marketo connection needs authorization");
189
- if (exchange.error === "request") return retry("TRANSPORT", "Marketo request failed");
1219
+ if (exchange.error === "request" || exchange.error === "refresh") return retry("TRANSPORT", "Marketo request failed");
190
1220
  if (exchange.status === 429) return retry("RATE_LIMIT", "Marketo rate limited the request", exchange.retryAfterMs);
191
1221
  if (exchange.status === 408 || exchange.status >= 500) return retry("AVAILABILITY", "Marketo is temporarily unavailable", exchange.retryAfterMs);
192
1222
  if (exchange.status !== 200) return terminal("providerRejected", "PROVIDER_REJECTION", `Marketo rejected HTTP ${exchange.status}`);
193
1223
  if (exchange.error === "tooLarge") return terminal("invalidResponse", "RESPONSE_TOO_LARGE", "Marketo response exceeded the configured limit");
1224
+ if (exchange.error === "read") return retry("TRANSPORT", "Marketo response was interrupted");
194
1225
  const decoded = decodeLead(exchange.body, input.leadId);
195
- if (decoded.kind === "found") return newQueryBranch("found", decoded.profile);
1226
+ if (decoded.kind === "found") return newQueryBranch2("found", decoded.profile);
196
1227
  if (decoded.kind === "rateLimit") return retry("RATE_LIMIT", "Marketo quota or concurrency limit was reached", exchange.retryAfterMs);
197
1228
  if (decoded.kind === "availability") return retry("AVAILABILITY", "Marketo is temporarily unavailable", exchange.retryAfterMs);
198
1229
  if (decoded.kind === "tokenExpired") return retry("AUTHENTICATION", "Marketo access token expired", exchange.retryAfterMs);
@@ -202,7 +1233,7 @@ var GetLeadOperation = class {
202
1233
  function decodeLead(body, requestedID) {
203
1234
  let raw;
204
1235
  try {
205
- raw = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(body));
1236
+ raw = parseJSONNumberTokens(new TextDecoder("utf-8", { fatal: true }).decode(body));
206
1237
  } catch {
207
1238
  return { kind: "invalidResponse", failure: "PROTOCOL" };
208
1239
  }
@@ -220,10 +1251,20 @@ function decodeLead(body, requestedID) {
220
1251
  if (!Array.isArray(raw.result) || raw.result.length > 1) return { kind: "invalidResponse", failure: "PROTOCOL" };
221
1252
  if (raw.result.length === 0) return { kind: "notFound", failure: "NOT_FOUND" };
222
1253
  const lead = raw.result[0];
223
- if (!isObject(lead) || !Number.isSafeInteger(lead.id) || lead.id !== requestedID || !optionalString(lead.firstName) || !optionalString(lead.lastName))
1254
+ if (!isObject(lead) || !positiveID(lead.id) || canonicalID(lead.id) !== canonicalID(requestedID) || !optionalString(lead.firstName) || !optionalString(lead.lastName))
224
1255
  return { kind: "invalidResponse", failure: "PROTOCOL" };
225
1256
  return { kind: "found", profile: { id: requestedID, firstName: typeof lead.firstName === "string" ? lead.firstName : "", lastName: typeof lead.lastName === "string" ? lead.lastName : "" } };
226
1257
  }
1258
+ function positiveID(value) {
1259
+ try {
1260
+ return BigInt(canonicalID(decodeSignedInteger(value))) > 0n;
1261
+ } catch {
1262
+ return false;
1263
+ }
1264
+ }
1265
+ function canonicalID(value) {
1266
+ return typeof value === "number" ? String(value) : value.rawJSON;
1267
+ }
227
1268
  function optionalString(value) {
228
1269
  return value === void 0 || value === null || typeof value === "string";
229
1270
  }
@@ -237,10 +1278,10 @@ function failure(kind, message) {
237
1278
  return { provider: "adobe-marketo", operation: "getLead", kind, message };
238
1279
  }
239
1280
  function terminal(branch, kind, message) {
240
- return newQueryBranch(branch, emptyProfile(), {}, failure(kind, message));
1281
+ return newQueryBranch2(branch, emptyProfile(), {}, failure(kind, message));
241
1282
  }
242
1283
  function retry(kind, message, delay = 0) {
243
- return newQueryRetry(failure(kind, message), delay);
1284
+ return newQueryRetry2(failure(kind, message), delay);
244
1285
  }
245
1286
  function header(headers, name) {
246
1287
  const entry = Object.entries(headers).find(([key]) => key.toLowerCase() === name)?.[1];
@@ -281,9 +1322,96 @@ function parseDurationMilliseconds(value) {
281
1322
  return milliseconds;
282
1323
  }
283
1324
  export {
1325
+ ActivityMetadataSchema,
1326
+ ActivityPageSchema,
1327
+ ActivityPagingTokenSchema,
1328
+ ActivityTypeSchema,
1329
+ ActivityTypesSchema,
1330
+ CompanyProfileSchema,
1331
+ CompanyWriteResultSchema,
284
1332
  ConfigSchema,
285
1333
  Connection,
286
1334
  ConnectorID,
1335
+ CreateCompanyBranch,
1336
+ CreateCompanyBranchAlreadyExists,
1337
+ CreateCompanyBranchCreated,
1338
+ CreateCompanyBranchDefect,
1339
+ CreateCompanyBranchProviderRejected,
1340
+ CreateCompanyBranchUncertain,
1341
+ CreateCompanyDefinition,
1342
+ CreateCompanyInputSchema,
1343
+ CreateCompanyMetadata,
1344
+ CreateCompanyOperation,
1345
+ CreateLeadBranch,
1346
+ CreateLeadBranchAlreadyExists,
1347
+ CreateLeadBranchCreated,
1348
+ CreateLeadBranchDefect,
1349
+ CreateLeadBranchProviderRejected,
1350
+ CreateLeadBranchUncertain,
1351
+ CreateLeadDefinition,
1352
+ CreateLeadInputSchema,
1353
+ CreateLeadMetadata,
1354
+ CreateLeadOperation,
1355
+ CreateOpportunityBranch,
1356
+ CreateOpportunityBranchAlreadyExists,
1357
+ CreateOpportunityBranchCreated,
1358
+ CreateOpportunityBranchDefect,
1359
+ CreateOpportunityBranchProviderRejected,
1360
+ CreateOpportunityBranchUncertain,
1361
+ CreateOpportunityDefinition,
1362
+ CreateOpportunityInputSchema,
1363
+ CreateOpportunityMetadata,
1364
+ CreateOpportunityOperation,
1365
+ CreatedLeadSchema,
1366
+ CredentialMaterialError,
1367
+ DeleteCompanyBranch,
1368
+ DeleteCompanyBranchDefect,
1369
+ DeleteCompanyBranchDeleted,
1370
+ DeleteCompanyBranchInvalidResponse,
1371
+ DeleteCompanyBranchProviderRejected,
1372
+ DeleteCompanyDefinition,
1373
+ DeleteCompanyInputSchema,
1374
+ DeleteCompanyMetadata,
1375
+ DeleteCompanyOperation,
1376
+ DeleteOpportunityBranch,
1377
+ DeleteOpportunityBranchDefect,
1378
+ DeleteOpportunityBranchDeleted,
1379
+ DeleteOpportunityBranchInvalidResponse,
1380
+ DeleteOpportunityBranchProviderRejected,
1381
+ DeleteOpportunityDefinition,
1382
+ DeleteOpportunityInputSchema,
1383
+ DeleteOpportunityMetadata,
1384
+ DeleteOpportunityOperation,
1385
+ DeletedCompanySchema,
1386
+ DeletedOpportunitySchema,
1387
+ FindLeadsByEmailBranch,
1388
+ FindLeadsByEmailBranchDefect,
1389
+ FindLeadsByEmailBranchFound,
1390
+ FindLeadsByEmailBranchInvalidResponse,
1391
+ FindLeadsByEmailBranchProviderRejected,
1392
+ FindLeadsByEmailDefinition,
1393
+ FindLeadsByEmailInputSchema,
1394
+ FindLeadsByEmailMetadata,
1395
+ FindLeadsByEmailOperation,
1396
+ GetActivityPagingTokenBranch,
1397
+ GetActivityPagingTokenBranchDefect,
1398
+ GetActivityPagingTokenBranchFound,
1399
+ GetActivityPagingTokenBranchInvalidResponse,
1400
+ GetActivityPagingTokenBranchProviderRejected,
1401
+ GetActivityPagingTokenDefinition,
1402
+ GetActivityPagingTokenInputSchema,
1403
+ GetActivityPagingTokenMetadata,
1404
+ GetActivityPagingTokenOperation,
1405
+ GetCompanyByExternalIDBranch,
1406
+ GetCompanyByExternalIDBranchDefect,
1407
+ GetCompanyByExternalIDBranchFound,
1408
+ GetCompanyByExternalIDBranchInvalidResponse,
1409
+ GetCompanyByExternalIDBranchNotFound,
1410
+ GetCompanyByExternalIDBranchProviderRejected,
1411
+ GetCompanyByExternalIDDefinition,
1412
+ GetCompanyByExternalIDInputSchema,
1413
+ GetCompanyByExternalIDMetadata,
1414
+ GetCompanyByExternalIDOperation,
287
1415
  GetLeadBranch,
288
1416
  GetLeadBranchDefect,
289
1417
  GetLeadBranchFound,
@@ -294,13 +1422,103 @@ export {
294
1422
  GetLeadInputSchema,
295
1423
  GetLeadMetadata,
296
1424
  GetLeadOperation,
1425
+ GetOpportunityByExternalIDBranch,
1426
+ GetOpportunityByExternalIDBranchDefect,
1427
+ GetOpportunityByExternalIDBranchFound,
1428
+ GetOpportunityByExternalIDBranchInvalidResponse,
1429
+ GetOpportunityByExternalIDBranchNotFound,
1430
+ GetOpportunityByExternalIDBranchProviderRejected,
1431
+ GetOpportunityByExternalIDDefinition,
1432
+ GetOpportunityByExternalIDInputSchema,
1433
+ GetOpportunityByExternalIDMetadata,
1434
+ GetOpportunityByExternalIDOperation,
297
1435
  LeadProfileSchema,
1436
+ LeadProfilesPageSchema,
1437
+ ListActivitiesBranch,
1438
+ ListActivitiesBranchDefect,
1439
+ ListActivitiesBranchFound,
1440
+ ListActivitiesBranchInvalidResponse,
1441
+ ListActivitiesBranchProviderRejected,
1442
+ ListActivitiesDefinition,
1443
+ ListActivitiesInputSchema,
1444
+ ListActivitiesMetadata,
1445
+ ListActivitiesOperation,
1446
+ ListActivityTypesBranch,
1447
+ ListActivityTypesBranchDefect,
1448
+ ListActivityTypesBranchFound,
1449
+ ListActivityTypesBranchInvalidResponse,
1450
+ ListActivityTypesBranchProviderRejected,
1451
+ ListActivityTypesDefinition,
1452
+ ListActivityTypesInputSchema,
1453
+ ListActivityTypesMetadata,
1454
+ ListActivityTypesOperation,
298
1455
  MarketoClient,
1456
+ OpportunityProfileSchema,
1457
+ OpportunityWriteResultSchema,
299
1458
  ProviderID,
1459
+ SyncedLeadSchema,
1460
+ UpdateLeadBranch,
1461
+ UpdateLeadBranchDefect,
1462
+ UpdateLeadBranchInvalidResponse,
1463
+ UpdateLeadBranchNotFound,
1464
+ UpdateLeadBranchProviderRejected,
1465
+ UpdateLeadBranchUpdated,
1466
+ UpdateLeadDefinition,
1467
+ UpdateLeadInputSchema,
1468
+ UpdateLeadMetadata,
1469
+ UpdateLeadOperation,
1470
+ UpdatedLeadSchema,
1471
+ UpsertCompanyBranch,
1472
+ UpsertCompanyBranchDefect,
1473
+ UpsertCompanyBranchInvalidResponse,
1474
+ UpsertCompanyBranchProviderRejected,
1475
+ UpsertCompanyBranchSynced,
1476
+ UpsertCompanyDefinition,
1477
+ UpsertCompanyInputSchema,
1478
+ UpsertCompanyMetadata,
1479
+ UpsertCompanyOperation,
1480
+ UpsertLeadByEmailBranch,
1481
+ UpsertLeadByEmailBranchDefect,
1482
+ UpsertLeadByEmailBranchInvalidResponse,
1483
+ UpsertLeadByEmailBranchProviderRejected,
1484
+ UpsertLeadByEmailBranchSynced,
1485
+ UpsertLeadByEmailDefinition,
1486
+ UpsertLeadByEmailInputSchema,
1487
+ UpsertLeadByEmailMetadata,
1488
+ UpsertLeadByEmailOperation,
1489
+ UpsertOpportunityBranch,
1490
+ UpsertOpportunityBranchDefect,
1491
+ UpsertOpportunityBranchInvalidResponse,
1492
+ UpsertOpportunityBranchProviderRejected,
1493
+ UpsertOpportunityBranchSynced,
1494
+ UpsertOpportunityDefinition,
1495
+ UpsertOpportunityInputSchema,
1496
+ UpsertOpportunityMetadata,
1497
+ UpsertOpportunityOperation,
300
1498
  decodeCredentials,
301
1499
  decodeSharedCredentials,
1500
+ decodeSignedInteger,
1501
+ exactIntegerJSONCodec,
1502
+ isCredentialMaterialError,
302
1503
  newConnection,
303
1504
  newConnectionWithOperations,
1505
+ newCreateCompanyStep,
1506
+ newCreateLeadStep,
1507
+ newCreateOpportunityStep,
1508
+ newDeleteCompanyStep,
1509
+ newDeleteOpportunityStep,
1510
+ newFindLeadsByEmailStep,
1511
+ newGetActivityPagingTokenStep,
1512
+ newGetCompanyByExternalIDStep,
304
1513
  newGetLeadStep,
305
- newProjectConnection2 as newProjectConnection
1514
+ newGetOpportunityByExternalIDStep,
1515
+ newListActivitiesStep,
1516
+ newListActivityTypesStep,
1517
+ newProjectConnection2 as newProjectConnection,
1518
+ newUpdateLeadStep,
1519
+ newUpsertCompanyStep,
1520
+ newUpsertLeadByEmailStep,
1521
+ newUpsertOpportunityStep,
1522
+ parseExactIntegerJSON,
1523
+ parseJSONNumberTokens
306
1524
  };