@planescrm/sdk 0.4.0 → 0.72.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.mjs CHANGED
@@ -166,6 +166,9 @@ var HttpClient = class {
166
166
  this.timeout = config.timeout ?? DEFAULT_TIMEOUT;
167
167
  this.retryOnRateLimit = config.retryOnRateLimit !== false;
168
168
  this.maxRetries = config.maxRetries ?? DEFAULT_MAX_RETRIES;
169
+ this.getAccessToken = config.getAccessToken;
170
+ this.onUnauthorized = config.onUnauthorized;
171
+ this.fetchImpl = config.fetch;
169
172
  if (config.clientId && config.clientSecret) {
170
173
  this.oauth = {
171
174
  clientId: config.clientId,
@@ -182,50 +185,68 @@ var HttpClient = class {
182
185
  let lastError;
183
186
  let didRefreshOn401 = false;
184
187
  for (let attempt = 0; attempt <= this.maxRetries; attempt++) {
188
+ const authHeaders = await this.resolveAuthHeaders();
185
189
  const headers = {
186
190
  "Content-Type": "application/json",
187
- ...await this.resolveAuthHeaders(),
191
+ ...authHeaders,
188
192
  ...options.headers
189
193
  };
194
+ if (options.idempotencyKey) headers["Idempotency-Key"] = options.idempotencyKey;
195
+ const timer = timeoutSignal(this.timeout);
190
196
  const fetchOptions = {
191
197
  method: options.method,
192
198
  headers,
193
- signal: AbortSignal.timeout(this.timeout)
199
+ signal: timer.signal
194
200
  };
195
201
  if (bodyStr !== void 0) {
196
202
  fetchOptions.body = bodyStr;
197
203
  }
198
- const response = await fetch(url, fetchOptions);
199
- if (response.ok) {
200
- if (response.status === 204) {
201
- return void 0;
204
+ try {
205
+ const response = await (this.fetchImpl ?? fetch)(url, fetchOptions);
206
+ if (response.ok) {
207
+ if (response.status === 204) {
208
+ return void 0;
209
+ }
210
+ if (options.responseType === "arrayBuffer") {
211
+ return await response.arrayBuffer();
212
+ }
213
+ return await response.json();
202
214
  }
203
- return await response.json();
204
- }
205
- if (response.status === 429 && this.retryOnRateLimit && attempt < this.maxRetries) {
206
- const retryAfter = this.parseRetryAfter(response);
207
- await this.sleep(retryAfter * 1e3);
208
- continue;
209
- }
210
- if (response.status === 401 && this.oauth && !didRefreshOn401) {
211
- didRefreshOn401 = true;
212
- await this.refreshTokens();
213
- attempt--;
214
- continue;
215
- }
216
- lastError = await this.mapError(response);
217
- if (response.status !== 429 || !this.retryOnRateLimit) {
218
- throw lastError;
215
+ if (response.status === 429 && this.retryOnRateLimit && attempt < this.maxRetries) {
216
+ const retryAfter = this.parseRetryAfter(response);
217
+ await this.sleep(retryAfter * 1e3);
218
+ continue;
219
+ }
220
+ if (response.status === 401 && this.oauth && !didRefreshOn401) {
221
+ didRefreshOn401 = true;
222
+ await this.refreshTokens();
223
+ attempt--;
224
+ continue;
225
+ }
226
+ if (response.status === 401 && this.onUnauthorized && !didRefreshOn401) {
227
+ didRefreshOn401 = true;
228
+ if (await this.recoverSession(authHeaders["Authorization"])) {
229
+ attempt--;
230
+ continue;
231
+ }
232
+ }
233
+ lastError = await this.mapError(response);
234
+ if (response.status !== 429 || !this.retryOnRateLimit) {
235
+ throw lastError;
236
+ }
237
+ } finally {
238
+ timer.clear();
219
239
  }
220
240
  }
221
241
  throw lastError ?? new RateLimitError();
222
242
  }
223
243
  getAuthHeaders() {
244
+ if (this.getAccessToken) return {};
224
245
  if (this.accessToken) {
225
246
  return { Authorization: `Bearer ${this.accessToken}` };
226
247
  }
227
248
  if (this.apiKey) {
228
- return { "X-API-Key": this.apiKey };
249
+ return { Authorization: `Bearer ${this.apiKey}` };
229
250
  }
230
251
  return {};
231
252
  }
@@ -236,6 +257,10 @@ var HttpClient = class {
236
257
  * the token is within the skew window of expiry.
237
258
  */
238
259
  async resolveAuthHeaders() {
260
+ if (this.getAccessToken) {
261
+ const token = await withTimeout(this.getAccessToken(), this.timeout, "getAccessToken");
262
+ return token ? { Authorization: `Bearer ${token}` } : {};
263
+ }
239
264
  if (!this.oauth) {
240
265
  return this.getAuthHeaders();
241
266
  }
@@ -299,6 +324,41 @@ var HttpClient = class {
299
324
  this.refreshInFlight = void 0;
300
325
  }
301
326
  }
327
+ /**
328
+ * Ask the app to refresh its session after a 401. Resolves `true` when the
329
+ * request should be retried.
330
+ * - Requests that got a 401 while a refresh is running share that one call.
331
+ * - A request whose 401 arrives after a refresh already finished (it was
332
+ * sent with the old token) doesn't start a second refresh: if the current
333
+ * token differs from the one it sent, it just retries with the new one.
334
+ * - A refresh that throws, or doesn't settle within the request timeout,
335
+ * counts as "still signed out": the original 401 surfaces.
336
+ */
337
+ async recoverSession(sentAuthorization) {
338
+ if (!this.onUnauthorized || !this.getAccessToken) return false;
339
+ if (!this.unauthorizedInFlight) {
340
+ try {
341
+ const current = await withTimeout(this.getAccessToken(), this.timeout, "getAccessToken");
342
+ if (current && `Bearer ${current}` !== sentAuthorization) return true;
343
+ } catch {
344
+ return false;
345
+ }
346
+ }
347
+ if (!this.unauthorizedInFlight) {
348
+ const call = this.onUnauthorized;
349
+ const inFlight = (async () => {
350
+ try {
351
+ return await withTimeout(call(), this.timeout, "onUnauthorized");
352
+ } catch {
353
+ return false;
354
+ }
355
+ })().finally(() => {
356
+ if (this.unauthorizedInFlight === inFlight) this.unauthorizedInFlight = void 0;
357
+ });
358
+ this.unauthorizedInFlight = inFlight;
359
+ }
360
+ return this.unauthorizedInFlight;
361
+ }
302
362
  buildUrl(path, params) {
303
363
  const url = new URL(`${this.baseUrl}${path}`);
304
364
  if (params) {
@@ -326,7 +386,8 @@ var HttpClient = class {
326
386
  body = await response.json();
327
387
  } catch {
328
388
  }
329
- const message = body["message"] ?? response.statusText ?? "Request failed";
389
+ const envelope = body["error"];
390
+ const message = (typeof body["message"] === "string" ? body["message"] : void 0) ?? (typeof envelope?.message === "string" ? envelope.message : void 0) ?? response.statusText ?? "Request failed";
330
391
  switch (response.status) {
331
392
  case 400: {
332
393
  const fieldErrors = body["errors"] ?? [];
@@ -349,231 +410,2483 @@ var HttpClient = class {
349
410
  return new PlanesError(message, response.status, "unknown_error");
350
411
  }
351
412
  }
352
- sleep(ms) {
353
- return new Promise((resolve) => setTimeout(resolve, ms));
413
+ sleep(ms) {
414
+ return new Promise((resolve) => setTimeout(resolve, ms));
415
+ }
416
+ };
417
+ function timeoutSignal(ms) {
418
+ if (typeof AbortSignal.timeout === "function") {
419
+ return { signal: AbortSignal.timeout(ms), clear: () => void 0 };
420
+ }
421
+ const controller = new AbortController();
422
+ const timer = setTimeout(() => controller.abort(), ms);
423
+ return { signal: controller.signal, clear: () => clearTimeout(timer) };
424
+ }
425
+ function withTimeout(promise, ms, what) {
426
+ return new Promise((resolve, reject) => {
427
+ const timer = setTimeout(() => reject(new Error(`${what} did not settle within ${ms}ms`)), ms);
428
+ Promise.resolve(promise).then(
429
+ (value) => {
430
+ clearTimeout(timer);
431
+ resolve(value);
432
+ },
433
+ (err) => {
434
+ clearTimeout(timer);
435
+ reject(err);
436
+ }
437
+ );
438
+ });
439
+ }
440
+
441
+ // src/resources/base-resource.ts
442
+ var ApiResource = class {
443
+ constructor(http2, basePath) {
444
+ this.http = http2;
445
+ this.basePath = basePath;
446
+ }
447
+ };
448
+ var BaseResource = class extends ApiResource {
449
+ /**
450
+ * List entities with optional filters and pagination.
451
+ */
452
+ async list(params) {
453
+ return this.http.request({
454
+ method: "GET",
455
+ path: this.basePath,
456
+ params
457
+ });
458
+ }
459
+ /**
460
+ * Get a single entity by ID.
461
+ */
462
+ async get(id) {
463
+ return this.http.request({
464
+ method: "GET",
465
+ path: `${this.basePath}/${id}`
466
+ });
467
+ }
468
+ /**
469
+ * Create a new entity. Pass `idempotencyKey` (a UUID you keep for retries) to
470
+ * make a retry safe on routes that honor it (customers, opportunities, contacts,
471
+ * tasks): a repeat returns the first response and creates nothing.
472
+ */
473
+ async create(data, options) {
474
+ return this.http.request({
475
+ method: "POST",
476
+ path: this.basePath,
477
+ body: data,
478
+ ...options?.idempotencyKey ? { idempotencyKey: options.idempotencyKey } : {}
479
+ });
480
+ }
481
+ /**
482
+ * Update an existing entity.
483
+ */
484
+ async update(id, data) {
485
+ return this.http.request({
486
+ method: "PATCH",
487
+ path: `${this.basePath}/${id}`,
488
+ body: data
489
+ });
490
+ }
491
+ /**
492
+ * Delete an entity by ID.
493
+ */
494
+ async delete(id) {
495
+ await this.http.request({
496
+ method: "DELETE",
497
+ path: `${this.basePath}/${id}`
498
+ });
499
+ }
500
+ };
501
+
502
+ // src/resources/query-params.ts
503
+ function toQueryParams(params) {
504
+ const out = {};
505
+ if (!params) return out;
506
+ for (const [key, value] of Object.entries(params)) {
507
+ if (value === void 0 || value === null) continue;
508
+ if (key === "customFields" && typeof value === "object" && !Array.isArray(value)) {
509
+ for (const [field, v] of Object.entries(value)) {
510
+ if (v !== void 0 && v !== null) out[`cf.${field}`] = String(v);
511
+ }
512
+ continue;
513
+ }
514
+ if (Array.isArray(value)) {
515
+ if (value.length === 0) continue;
516
+ out[key] = value.map(String).join(",");
517
+ } else {
518
+ out[key] = value;
519
+ }
520
+ }
521
+ return out;
522
+ }
523
+
524
+ // src/resources/opportunities.ts
525
+ var OpportunityResource = class extends BaseResource {
526
+ constructor(http2) {
527
+ super(http2, "/opportunities");
528
+ }
529
+ /**
530
+ * List opportunities. `tag_ids` is ANY-of and travels as one comma-separated
531
+ * query value (`?tag_ids=a,b`), which is what the API's filter schema parses.
532
+ */
533
+ async list(params) {
534
+ return this.http.request({
535
+ method: "GET",
536
+ path: this.basePath,
537
+ params: toQueryParams(params)
538
+ });
539
+ }
540
+ /**
541
+ * GET /opportunities/trade-options — the active trades a client can request
542
+ * (`requestedTradeIds` on create/update), sorted by name.
543
+ */
544
+ async tradeOptions() {
545
+ return this.http.request({
546
+ method: "GET",
547
+ path: `${this.basePath}/trade-options`
548
+ });
549
+ }
550
+ /** PUT /opportunities/{id} — partial update; stage moves go through workflow transitions. */
551
+ async update(id, data) {
552
+ return this.http.request({
553
+ method: "PUT",
554
+ path: `${this.basePath}/${id}`,
555
+ body: data
556
+ });
557
+ }
558
+ /** GET /opportunities/:id/transitions — the pipeline moves available from the current stage, for the caller's role. */
559
+ async listTransitions(id) {
560
+ return this.http.request({ method: "GET", path: `${this.basePath}/${id}/transitions` });
561
+ }
562
+ /**
563
+ * POST /opportunities/:id/transition — take one pipeline move, as the stage button does: required
564
+ * fields are checked, the move is logged, and the stage's automations run (they can send email).
565
+ */
566
+ async transition(id, data) {
567
+ return this.http.request({ method: "POST", path: `${this.basePath}/${id}/transition`, body: data });
568
+ }
569
+ /** GET /opportunities/:id/workflow — the pipeline instance with its transition history (404 if none). */
570
+ async getWorkflow(id) {
571
+ return this.http.request({ method: "GET", path: `${this.basePath}/${id}/workflow` });
572
+ }
573
+ };
574
+
575
+ // src/resources/customers.ts
576
+ var CustomerResource = class extends BaseResource {
577
+ constructor(http2) {
578
+ super(http2, "/customers");
579
+ }
580
+ /**
581
+ * Update a customer. The API route is `PUT /customers/{id}` (not PATCH like
582
+ * the other resources), so this overrides the base verb; the body is still a
583
+ * partial — send only the fields to change. See `UpdateCustomerDto.address`
584
+ * for how a service address resolves to a property.
585
+ */
586
+ async update(id, data) {
587
+ return this.http.request({
588
+ method: "PUT",
589
+ path: `/customers/${id}`,
590
+ body: data
591
+ });
592
+ }
593
+ /**
594
+ * List customers. `tag_ids` is ANY-of and travels as one comma-separated
595
+ * query value (`?tag_ids=a,b`), which is what the API's filter schema parses.
596
+ */
597
+ async list(params) {
598
+ return this.http.request({
599
+ method: "GET",
600
+ path: this.basePath,
601
+ params: toQueryParams(params)
602
+ });
603
+ }
604
+ /**
605
+ * Fold a duplicate company (`loserId`) into a survivor (`winnerId`).
606
+ *
607
+ * Everything hanging off the loser moves to the winner, the winner's empty
608
+ * fields are filled from the loser, and the loser is soft-deleted with a
609
+ * resolvable pointer — `GET /customers/{loserId}` afterwards returns the
610
+ * winner's detail with a `mergedFrom` pointer, so a stored loser id keeps
611
+ * working. Irreversible; requires admin scope.
612
+ */
613
+ async merge(winnerId, loserId) {
614
+ return this.http.request({
615
+ method: "POST",
616
+ path: `/customers/${winnerId}/merge/${loserId}`
617
+ });
618
+ }
619
+ /**
620
+ * POST /customers/{id}/convert-to-company — turn a person customer into a
621
+ * company. The person becomes the company's primary contact (their email and
622
+ * phone, with do-not-contact and marketing opt-outs carried over). A customer
623
+ * that's already a company is a 409 `ALREADY_COMPANY`.
624
+ */
625
+ async convertToCompany(id, data = {}) {
626
+ return this.http.request({
627
+ method: "POST",
628
+ path: `${this.basePath}/${id}/convert-to-company`,
629
+ body: data
630
+ });
631
+ }
632
+ };
633
+
634
+ // src/resources/properties.ts
635
+ var PropertyResource = class extends ApiResource {
636
+ constructor(http2) {
637
+ super(http2, "/properties");
638
+ }
639
+ /** GET /customers/{customerId}/properties — paginated (`page`, `limit` ≤ 100). */
640
+ async list(customerId, params) {
641
+ return this.http.request({
642
+ method: "GET",
643
+ path: `/customers/${customerId}/properties`,
644
+ params: toQueryParams(params)
645
+ });
646
+ }
647
+ /** GET /properties/{id} — one property, without naming its customer. */
648
+ async get(id) {
649
+ return this.http.request({
650
+ method: "GET",
651
+ path: `${this.basePath}/${id}`
652
+ });
653
+ }
654
+ /** POST /customers/{customerId}/properties — the property inherits the customer's org path. */
655
+ async create(customerId, data) {
656
+ return this.http.request({
657
+ method: "POST",
658
+ path: `/customers/${customerId}/properties`,
659
+ body: data
660
+ });
661
+ }
662
+ /** PUT /customers/{customerId}/properties/{id} — partial update. */
663
+ async update(customerId, id, data) {
664
+ return this.http.request({
665
+ method: "PUT",
666
+ path: `/customers/${customerId}/properties/${id}`,
667
+ body: data
668
+ });
669
+ }
670
+ /** GET /customers/:customerId/properties/:id — one property, checked against its customer (404 if it isn't theirs). */
671
+ async getForCustomer(customerId, id) {
672
+ return this.http.request({
673
+ method: "GET",
674
+ path: `/customers/${customerId}/properties/${id}`
675
+ });
676
+ }
677
+ /** POST /properties/:id/geocode — queue a fresh geocode of the property's address. */
678
+ async geocode(id) {
679
+ return this.http.request({ method: "POST", path: `${this.basePath}/${id}/geocode` });
680
+ }
681
+ /** DELETE /customers/{customerId}/properties/{id} — soft delete (204). */
682
+ async delete(customerId, id) {
683
+ await this.http.request({
684
+ method: "DELETE",
685
+ path: `/customers/${customerId}/properties/${id}`
686
+ });
687
+ }
688
+ };
689
+
690
+ // src/resources/calendar-events.ts
691
+ var CalendarEventResource = class extends BaseResource {
692
+ constructor(http2) {
693
+ super(http2, "/events");
694
+ }
695
+ async list(params) {
696
+ return this.http.request({
697
+ method: "GET",
698
+ path: this.basePath,
699
+ params: params ?? {}
700
+ });
701
+ }
702
+ /**
703
+ * PATCH /events/:id. For an occurrence of a recurring event, `editMode`
704
+ * picks which occurrences change (`this` when omitted — the server's
705
+ * default); it is ignored for one-time events.
706
+ */
707
+ async update(id, data, options = {}) {
708
+ return this.http.request({
709
+ method: "PATCH",
710
+ path: `${this.basePath}/${id}`,
711
+ params: { recurrence_edit_mode: options.editMode },
712
+ body: data
713
+ });
714
+ }
715
+ /**
716
+ * POST /events/:id/complete — marks the event completed and runs its "on
717
+ * complete" transition, best-effort. The event is completed even when the
718
+ * transition can't run; `workflow_trigger` says whether it fired, was
719
+ * skipped (none set, or `handled_by_pipeline_rule`: the pipeline's rule
720
+ * moves the record instead) or failed (with a reason).
721
+ */
722
+ async complete(id, body = {}) {
723
+ return this.http.request({
724
+ method: "POST",
725
+ path: `${this.basePath}/${id}/complete`,
726
+ body
727
+ });
728
+ }
729
+ /**
730
+ * POST /events/:id/cancel. For an occurrence of a recurring event, `editMode`
731
+ * picks which occurrences are cancelled (`this` when omitted). 409 if already
732
+ * cancelled; 422 for a completed event.
733
+ */
734
+ async cancel(id, options = {}) {
735
+ return this.http.request({
736
+ method: "POST",
737
+ path: `${this.basePath}/${id}/cancel`,
738
+ params: { recurrence_edit_mode: options.editMode }
739
+ });
740
+ }
741
+ /** POST /events/:id/participants — add a user, contact, crew or agent to the event. No invite is sent. */
742
+ async addParticipant(id, data) {
743
+ return this.http.request({
744
+ method: "POST",
745
+ path: `${this.basePath}/${id}/participants`,
746
+ body: data
747
+ });
748
+ }
749
+ /** PATCH /events/:id/participants/:participantId — set a participant's response. */
750
+ async updateParticipantStatus(id, participantId, status) {
751
+ return this.http.request({
752
+ method: "PATCH",
753
+ path: `${this.basePath}/${id}/participants/${participantId}`,
754
+ body: { status }
755
+ });
756
+ }
757
+ };
758
+
759
+ // src/resources/contracts.ts
760
+ var ContractResource = class extends BaseResource {
761
+ constructor(http2) {
762
+ super(http2, "/contracts");
763
+ }
764
+ /** POST /contracts/for-subject — a bare agreement for a customer or a service schedule (no opportunity, no line groups). */
765
+ async createForSubject(data) {
766
+ return this.http.request({ method: "POST", path: `${this.basePath}/for-subject`, body: data });
767
+ }
768
+ /** POST /contracts/flat — a contract on an opportunity with a manually entered total and a contract template, no estimates. */
769
+ async createFlat(data) {
770
+ return this.http.request({ method: "POST", path: `${this.basePath}/flat`, body: data });
771
+ }
772
+ /** POST /contracts/{id}/change-orders — a change order on a signed or fulfilled contract (409 otherwise). */
773
+ async createChangeOrder(id, data) {
774
+ return this.http.request({
775
+ method: "POST",
776
+ path: `${this.basePath}/${id}/change-orders`,
777
+ body: data
778
+ });
779
+ }
780
+ /**
781
+ * GET /contracts/{id}/change-orders — the change orders written against a
782
+ * contract, oldest first, each with its line groups. A change order has none
783
+ * of its own, so asking for one returns an empty list.
784
+ */
785
+ async listChangeOrders(id) {
786
+ return this.http.request({
787
+ method: "GET",
788
+ path: `${this.basePath}/${id}/change-orders`
789
+ });
790
+ }
791
+ /** POST /contracts/{id}/submit — submit for approval; auto-approved when under the tenant's threshold. */
792
+ async submit(id) {
793
+ return this.http.request({ method: "POST", path: `${this.basePath}/${id}/submit` });
794
+ }
795
+ /** POST /contracts/{id}/approve — approve a contract pending approval (needs the approve grant). */
796
+ async approve(id) {
797
+ return this.http.request({ method: "POST", path: `${this.basePath}/${id}/approve` });
798
+ }
799
+ /** POST /contracts/{id}/cancel — cancel a contract in any state before it's signed. */
800
+ async cancel(id) {
801
+ return this.http.request({ method: "POST", path: `${this.basePath}/${id}/cancel` });
802
+ }
803
+ /** POST /contracts/{id}/reopen — return a kicked-back contract to draft for review and re-send. */
804
+ async reopen(id) {
805
+ return this.http.request({ method: "POST", path: `${this.basePath}/${id}/reopen` });
806
+ }
807
+ /**
808
+ * POST /contracts/{id}/send — **emails the signer a "Review & Sign" link.**
809
+ * Snapshots the clauses and creates the signing token. An empty body
810
+ * addresses the customer; `signerContactId` sends it to that contact instead.
811
+ * The first send of a contract uses one unit of the tenant's e-signature
812
+ * allowance; a re-send doesn't. Not safe to retry blindly after a timeout: a
813
+ * repeat emails again.
814
+ */
815
+ async send(id, data = {}) {
816
+ return this.http.request({ method: "POST", path: `${this.basePath}/${id}/send`, body: data });
817
+ }
818
+ /**
819
+ * GET /contracts/{id}/pdf — the contract PDF bytes. `type: 'signed'` returns
820
+ * the stored signed copy (404 until it's signed); otherwise a preview renders.
821
+ */
822
+ async downloadPdf(id, options = {}) {
823
+ return this.http.request({
824
+ method: "GET",
825
+ path: `${this.basePath}/${id}/pdf`,
826
+ params: options.type ? { type: options.type } : {},
827
+ headers: { Accept: "application/pdf" },
828
+ responseType: "arrayBuffer"
829
+ });
830
+ }
831
+ };
832
+
833
+ // src/resources/jobs.ts
834
+ var JobResource = class extends ApiResource {
835
+ constructor(http2) {
836
+ super(http2, "/jobs");
837
+ }
838
+ /** The jobs under one opportunity — the same route as `listForOpportunity()`. */
839
+ async list(opportunityId, params) {
840
+ return this.listForOpportunity(opportunityId, params);
841
+ }
842
+ /**
843
+ * List the jobs under one opportunity — `GET /opportunities/{opportunityId}/jobs`,
844
+ * the API's job list route. Default order is `created_at` desc;
845
+ * `sort_by: 'recent'` puts the calling user's most recently opened jobs first.
846
+ */
847
+ async listForOpportunity(opportunityId, params) {
848
+ return this.http.request({
849
+ method: "GET",
850
+ path: `/opportunities/${opportunityId}/jobs`,
851
+ params: toQueryParams(params)
852
+ });
853
+ }
854
+ /** GET /opportunities/{opportunityId}/jobs/{id} */
855
+ async get(opportunityId, id) {
856
+ return this.http.request({
857
+ method: "GET",
858
+ path: `/opportunities/${opportunityId}/jobs/${id}`
859
+ });
860
+ }
861
+ /**
862
+ * POST /opportunities/{opportunityId}/jobs — 422 WORKFLOW_NOT_CONFIGURED when
863
+ * the trade has no published job workflow (check `getTradeCoverage()` first).
864
+ */
865
+ async create(opportunityId, data) {
866
+ return this.http.request({
867
+ method: "POST",
868
+ path: `/opportunities/${opportunityId}/jobs`,
869
+ body: data
870
+ });
871
+ }
872
+ /** PUT /opportunities/{opportunityId}/jobs/{id} — partial update (status, notes). */
873
+ async update(opportunityId, id, data) {
874
+ return this.http.request({
875
+ method: "PUT",
876
+ path: `/opportunities/${opportunityId}/jobs/${id}`,
877
+ body: data
878
+ });
879
+ }
880
+ /** DELETE /opportunities/{opportunityId}/jobs/{id} — soft delete (204). */
881
+ async delete(opportunityId, id) {
882
+ await this.http.request({
883
+ method: "DELETE",
884
+ path: `/opportunities/${opportunityId}/jobs/${id}`
885
+ });
886
+ }
887
+ /**
888
+ * GET /jobs/trade-coverage — every active trade with whether a job can be
889
+ * created under it (a published job workflow resolves: the trade's own or the
890
+ * generic one). Check before creating a job to avoid a 422
891
+ * WORKFLOW_NOT_CONFIGURED. Readable by any role that can create jobs (403
892
+ * otherwise); carries no workflow details.
893
+ */
894
+ async getTradeCoverage() {
895
+ return this.http.request({
896
+ method: "GET",
897
+ path: "/jobs/trade-coverage"
898
+ });
899
+ }
900
+ /** GET /jobs/{id}/workflow — the job's pipeline instance with its transition history (404 if none). */
901
+ async getWorkflow(id) {
902
+ return this.http.request({ method: "GET", path: `${this.basePath}/${id}/workflow` });
903
+ }
904
+ /**
905
+ * POST /jobs/{id}/transition — take one pipeline move, as the stage button
906
+ * does: required fields are checked, the move is logged, and **the
907
+ * transition's actions run**. A tenant can attach actions that create or send
908
+ * an invoice, charge a saved card, send a contract, or send email, SMS or a
909
+ * webhook. Not safe to retry blindly after a timeout: check `getWorkflow()`
910
+ * first, because a repeat runs the actions again.
911
+ */
912
+ async transition(id, data) {
913
+ return this.http.request({ method: "POST", path: `${this.basePath}/${id}/transition`, body: data });
914
+ }
915
+ /** GET /jobs/{id}/transitions — the pipeline moves available from the job's current stage, for the caller's role. */
916
+ async listTransitions(id) {
917
+ return this.http.request({
918
+ method: "GET",
919
+ path: `${this.basePath}/${id}/transitions`
920
+ });
921
+ }
922
+ };
923
+
924
+ // src/resources/estimates.ts
925
+ var EstimateResource = class extends ApiResource {
926
+ constructor(http2) {
927
+ super(http2, "/estimates");
928
+ }
929
+ /** GET /jobs/{jobId}/estimates — newest first, paginated (`page`, `limit` ≤ 100). */
930
+ async list(jobId, params) {
931
+ return this.http.request({
932
+ method: "GET",
933
+ path: `/jobs/${jobId}/estimates`,
934
+ params: toQueryParams(params)
935
+ });
936
+ }
937
+ /**
938
+ * Every estimate across all of one opportunity's jobs, in one request —
939
+ * `GET /opportunities/{opportunityId}/estimates`. Newest first; each row
940
+ * carries its `jobId`. Paginated with `page` / `limit` (max 100).
941
+ */
942
+ async listForOpportunity(opportunityId, params) {
943
+ return this.http.request({
944
+ method: "GET",
945
+ path: `/opportunities/${opportunityId}/estimates`,
946
+ params: toQueryParams(params)
947
+ });
948
+ }
949
+ /** GET /jobs/{jobId}/estimates/{id} — the estimate with its line items. */
950
+ async get(jobId, id) {
951
+ return this.http.request({
952
+ method: "GET",
953
+ path: `/jobs/${jobId}/estimates/${id}`
954
+ });
955
+ }
956
+ /** POST /jobs/{jobId}/estimates — optionally cloned from an estimate template. */
957
+ async create(jobId, data) {
958
+ return this.http.request({
959
+ method: "POST",
960
+ path: `/jobs/${jobId}/estimates`,
961
+ body: data
962
+ });
963
+ }
964
+ /** PUT /jobs/{jobId}/estimates/{id} — partial update (measurements, notes, discount, tax). */
965
+ async update(jobId, id, data) {
966
+ return this.http.request({
967
+ method: "PUT",
968
+ path: `/jobs/${jobId}/estimates/${id}`,
969
+ body: data
970
+ });
971
+ }
972
+ /** DELETE /jobs/{jobId}/estimates/{id} — soft delete (204). */
973
+ async delete(jobId, id) {
974
+ await this.http.request({
975
+ method: "DELETE",
976
+ path: `/jobs/${jobId}/estimates/${id}`
977
+ });
978
+ }
979
+ /** GET /estimates/{id}/workflow — the estimate's pipeline instance with its transition history (404 if none). */
980
+ async getWorkflow(id) {
981
+ return this.http.request({ method: "GET", path: `${this.basePath}/${id}/workflow` });
982
+ }
983
+ /**
984
+ * POST /estimates/{id}/transition — take one pipeline move. **The
985
+ * transition's actions run**, as for `jobs.transition()`: a tenant can attach
986
+ * actions that bill, charge, send a contract, or send email, SMS or a webhook.
987
+ * Not safe to retry blindly after a timeout: check `getWorkflow()` first.
988
+ */
989
+ async transition(id, data) {
990
+ return this.http.request({ method: "POST", path: `${this.basePath}/${id}/transition`, body: data });
991
+ }
992
+ /**
993
+ * PUT /jobs/{jobId}/estimates/{id}/status — move the estimate's status (see
994
+ * `UpdateEstimateStatusDto` for the allowed moves). The route itself sends
995
+ * nothing and creates no contract or invoice; a tenant's webhooks or
996
+ * automations on the status change can.
997
+ */
998
+ async updateStatus(jobId, id, data) {
999
+ return this.http.request({
1000
+ method: "PUT",
1001
+ path: `/jobs/${jobId}/estimates/${id}/status`,
1002
+ body: data
1003
+ });
1004
+ }
1005
+ /** GET /estimates/{id}/transitions — the pipeline moves available from the estimate's current stage, for the caller's role. */
1006
+ async listTransitions(id) {
1007
+ return this.http.request({
1008
+ method: "GET",
1009
+ path: `${this.basePath}/${id}/transitions`
1010
+ });
1011
+ }
1012
+ /**
1013
+ * POST /jobs/{jobId}/estimates/{estimateId}/line-items — add a line item. With
1014
+ * `materialCatalogId` or `tradeLaborItemId`, the catalog fills in description,
1015
+ * unit and price. The estimate's subtotal and total are recalculated.
1016
+ */
1017
+ async createLineItem(jobId, estimateId, data) {
1018
+ return this.http.request({
1019
+ method: "POST",
1020
+ path: `/jobs/${jobId}/estimates/${estimateId}/line-items`,
1021
+ body: data
1022
+ });
1023
+ }
1024
+ /** PUT /jobs/{jobId}/estimates/{estimateId}/line-items/{id} — partial update; totals are recalculated. */
1025
+ async updateLineItem(jobId, estimateId, id, data) {
1026
+ return this.http.request({
1027
+ method: "PUT",
1028
+ path: `/jobs/${jobId}/estimates/${estimateId}/line-items/${id}`,
1029
+ body: data
1030
+ });
1031
+ }
1032
+ /** DELETE /jobs/{jobId}/estimates/{estimateId}/line-items/{id} — totals are recalculated. */
1033
+ async deleteLineItem(jobId, estimateId, id) {
1034
+ await this.http.request({
1035
+ method: "DELETE",
1036
+ path: `/jobs/${jobId}/estimates/${estimateId}/line-items/${id}`
1037
+ });
1038
+ }
1039
+ /** PUT /jobs/{jobId}/estimates/{estimateId}/line-items/reorder — set each item's `sortOrder` (and optionally `section`) in one call. */
1040
+ async reorderLineItems(jobId, estimateId, data) {
1041
+ return this.http.request({
1042
+ method: "PUT",
1043
+ path: `/jobs/${jobId}/estimates/${estimateId}/line-items/reorder`,
1044
+ body: data
1045
+ });
1046
+ }
1047
+ };
1048
+
1049
+ // src/resources/invoices.ts
1050
+ var InvoiceResource = class extends BaseResource {
1051
+ constructor(http2) {
1052
+ super(http2, "/admin/invoices");
1053
+ }
1054
+ /** List invoices, newest first. Each row carries the customer's `customerName`. */
1055
+ async list(params) {
1056
+ return this.http.request({
1057
+ method: "GET",
1058
+ path: this.basePath,
1059
+ params
1060
+ });
1061
+ }
1062
+ /**
1063
+ * GET /admin/invoices/:id — the invoice with its line items, payments
1064
+ * (including any `needs_review` payment) and `payLink` state.
1065
+ */
1066
+ async get(id) {
1067
+ return this.http.request({
1068
+ method: "GET",
1069
+ path: `${this.basePath}/${id}`
1070
+ });
1071
+ }
1072
+ /**
1073
+ * POST /admin/invoices/:id/pay-link — issue a fresh durable pay link for a
1074
+ * `sent` or `partially_paid` invoice (Send Invoice grant) and return its URL,
1075
+ * e.g. to share by text. Rotates: the previously emailed link stops working.
1076
+ * Any other status → 409 `INVOICE_NOT_PAYABLE`.
1077
+ */
1078
+ async createPayLink(id) {
1079
+ return this.http.request({
1080
+ method: "POST",
1081
+ path: `${this.basePath}/${id}/pay-link`
1082
+ });
1083
+ }
1084
+ /**
1085
+ * GET /admin/invoices/:id/pdf — the invoice PDF bytes (Read Invoice grant).
1086
+ * A sent invoice returns the copy stored when it was sent; a draft renders on
1087
+ * demand with a DRAFT watermark.
1088
+ */
1089
+ async downloadPdf(id) {
1090
+ return this.http.request({
1091
+ method: "GET",
1092
+ path: `${this.basePath}/${id}/pdf`,
1093
+ headers: { Accept: "application/pdf" },
1094
+ responseType: "arrayBuffer"
1095
+ });
1096
+ }
1097
+ /**
1098
+ * GET /admin/invoices/overdue — sent / partially paid invoices with a balance
1099
+ * past their due date, most overdue first, each with `daysOverdue` and the
1100
+ * last overdue offset reached (E56-F8-S2). Read Invoice.
1101
+ */
1102
+ async listOverdue(params) {
1103
+ return this.http.request({
1104
+ method: "GET",
1105
+ path: `${this.basePath}/overdue`,
1106
+ params
1107
+ });
1108
+ }
1109
+ /** GET /admin/invoices/{invoiceId}/payments — every payment recorded against the invoice (Read Payment). */
1110
+ async listPayments(invoiceId) {
1111
+ return this.http.request({
1112
+ method: "GET",
1113
+ path: `${this.basePath}/${invoiceId}/payments`
1114
+ });
1115
+ }
1116
+ /**
1117
+ * GET /admin/payments/recording-settings — the tenant's resolved
1118
+ * payment-recording settings (whether manual recording is on, and which
1119
+ * methods). Read Invoice.
1120
+ */
1121
+ async getPaymentRecordingSettings() {
1122
+ return this.http.request({
1123
+ method: "GET",
1124
+ path: "/admin/payments/recording-settings"
1125
+ });
1126
+ }
1127
+ /** GET /admin/invoices/overdue/summary — `{ count, total }` of every overdue invoice. Read Invoice. */
1128
+ async overdueSummary() {
1129
+ return this.http.request({
1130
+ method: "GET",
1131
+ path: `${this.basePath}/overdue/summary`
1132
+ });
1133
+ }
1134
+ };
1135
+
1136
+ // src/resources/inventory.ts
1137
+ var InventoryResource = class extends BaseResource {
1138
+ constructor(http2) {
1139
+ super(http2, "/admin/inventory/items");
1140
+ }
1141
+ async list(params) {
1142
+ return this.http.request({
1143
+ method: "GET",
1144
+ path: this.basePath,
1145
+ params: toQueryParams(params)
1146
+ });
1147
+ }
1148
+ /** PUT /admin/inventory/items/{id} — partial update. */
1149
+ async update(id, data) {
1150
+ return this.http.request({
1151
+ method: "PUT",
1152
+ path: `${this.basePath}/${id}`,
1153
+ body: data
1154
+ });
1155
+ }
1156
+ // ---- Material used on a job (E64-S9). The routes live under /jobs/{jobId}. ----
1157
+ /**
1158
+ * POST /jobs/{jobId}/consumption — record stock drawn from a location for a
1159
+ * job. Each line lowers that location's on-hand quantity.
1160
+ */
1161
+ async recordJobConsumption(jobId, data) {
1162
+ return this.http.request({
1163
+ method: "POST",
1164
+ path: `/jobs/${jobId}/consumption`,
1165
+ body: data
1166
+ });
1167
+ }
1168
+ /**
1169
+ * GET /jobs/{jobId}/consumption — one page of the job's consume and return
1170
+ * movements (newest first by default), the job's totals across every page,
1171
+ * and page metadata. The rows are under `items`, not `data`.
1172
+ */
1173
+ async listJobConsumption(jobId, params) {
1174
+ return this.http.request({
1175
+ method: "GET",
1176
+ path: `/jobs/${jobId}/consumption`,
1177
+ params: toQueryParams(params)
1178
+ });
1179
+ }
1180
+ /** POST /jobs/{jobId}/return — put unused stock from a job back into a location. */
1181
+ async returnFromJob(jobId, data) {
1182
+ return this.http.request({
1183
+ method: "POST",
1184
+ path: `/jobs/${jobId}/return`,
1185
+ body: data
1186
+ });
1187
+ }
1188
+ /** GET /jobs/{jobId}/material-variance — estimated vs actual material for the job. */
1189
+ async getJobMaterialVariance(jobId) {
1190
+ return this.http.request({
1191
+ method: "GET",
1192
+ path: `/jobs/${jobId}/material-variance`
1193
+ });
1194
+ }
1195
+ };
1196
+
1197
+ // src/resources/contacts.ts
1198
+ var ContactChannelResource = class {
1199
+ constructor(http2, contactId) {
1200
+ this.http = http2;
1201
+ this.contactId = contactId;
1202
+ }
1203
+ /** Returns `{ channel, duplicateOf }` — `duplicateOf` is the dedup signal. */
1204
+ async create(data) {
1205
+ return this.http.request({
1206
+ method: "POST",
1207
+ path: `/contacts/${this.contactId}/channels`,
1208
+ body: data
1209
+ });
1210
+ }
1211
+ async update(channelId, data) {
1212
+ return this.http.request({
1213
+ method: "PATCH",
1214
+ path: `/contacts/${this.contactId}/channels/${channelId}`,
1215
+ body: data
1216
+ });
1217
+ }
1218
+ async delete(channelId) {
1219
+ await this.http.request({
1220
+ method: "DELETE",
1221
+ path: `/contacts/${this.contactId}/channels/${channelId}`
1222
+ });
1223
+ }
1224
+ };
1225
+ var ContactResource = class extends BaseResource {
1226
+ constructor(http2) {
1227
+ super(http2, "/contacts");
1228
+ }
1229
+ /**
1230
+ * List contacts. Typed against the real filter schema (customer_id /
1231
+ * property_id / q / sort_by / sort_order / page / limit / include) — the base
1232
+ * `list` would accept any key and let a typo reach the server as a 400.
1233
+ * `include: ['channels', 'links']` attaches each row's channels and active
1234
+ * links in the same response.
1235
+ */
1236
+ async list(params) {
1237
+ return this.http.request({
1238
+ method: "GET",
1239
+ path: this.basePath,
1240
+ params: toQueryParams(params)
1241
+ });
1242
+ }
1243
+ async merge(winnerId, loserId) {
1244
+ return this.http.request({
1245
+ method: "POST",
1246
+ path: `/contacts/${winnerId}/merge/${loserId}`
1247
+ });
1248
+ }
1249
+ /** GET /contacts/roles — the distinct roles in use on active links, for a role picker. */
1250
+ async listRoles() {
1251
+ return this.http.request({ method: "GET", path: "/contacts/roles" });
1252
+ }
1253
+ /** GET /contacts/:id/links — every link, active and ended (history). `get()` returns active links only. */
1254
+ async listLinks(contactId) {
1255
+ return this.http.request({ method: "GET", path: `/contacts/${contactId}/links` });
1256
+ }
1257
+ /** POST /contacts/:id/links — link the contact to a customer or property. */
1258
+ async addLink(contactId, data) {
1259
+ return this.http.request({ method: "POST", path: `/contacts/${contactId}/links`, body: data });
1260
+ }
1261
+ /** PATCH /contacts/:id/links/:linkId — change role/primary, or end the link (`endedAt`). */
1262
+ async updateLink(contactId, linkId, data) {
1263
+ return this.http.request({
1264
+ method: "PATCH",
1265
+ path: `/contacts/${contactId}/links/${linkId}`,
1266
+ body: data
1267
+ });
1268
+ }
1269
+ /** POST /contacts/:id/workflow/start — opt the contact into the relationship pipeline (409 if started). */
1270
+ async startWorkflow(contactId) {
1271
+ return this.http.request({ method: "POST", path: `/contacts/${contactId}/workflow/start` });
1272
+ }
1273
+ /** GET /contacts/:id/workflow — current stage and the transitions available from it. */
1274
+ async getWorkflow(contactId) {
1275
+ return this.http.request({ method: "GET", path: `/contacts/${contactId}/workflow` });
1276
+ }
1277
+ /** POST /contacts/:id/workflow/transitions/:transitionId — 422 for an invalid move or unmet required fields. */
1278
+ async transition(contactId, transitionId) {
1279
+ return this.http.request({
1280
+ method: "POST",
1281
+ path: `/contacts/${contactId}/workflow/transitions/${transitionId}`,
1282
+ body: {}
1283
+ });
1284
+ }
1285
+ /** GET /contacts/:id/workflow/history */
1286
+ async getWorkflowHistory(contactId) {
1287
+ return this.http.request({ method: "GET", path: `/contacts/${contactId}/workflow/history` });
1288
+ }
1289
+ channels(contactId) {
1290
+ return new ContactChannelResource(this.http, contactId);
1291
+ }
1292
+ };
1293
+
1294
+ // src/resources/activities.ts
1295
+ var ActivityResource = class {
1296
+ constructor(http2) {
1297
+ this.http = http2;
1298
+ }
1299
+ async create(data) {
1300
+ return this.http.request({
1301
+ method: "POST",
1302
+ path: "/activities",
1303
+ body: data
1304
+ });
1305
+ }
1306
+ async list(params) {
1307
+ return this.http.request({
1308
+ method: "GET",
1309
+ path: "/activities",
1310
+ params
1311
+ });
1312
+ }
1313
+ async listForEntity(entityType, entityId, params) {
1314
+ return this.http.request({
1315
+ method: "GET",
1316
+ path: `/${entityType}/${entityId}/activities`,
1317
+ params
1318
+ });
1319
+ }
1320
+ };
1321
+
1322
+ // src/resources/communications.ts
1323
+ var CommunicationsResource = class {
1324
+ constructor(http2) {
1325
+ this.http = http2;
1326
+ }
1327
+ async log(data) {
1328
+ return this.http.request({
1329
+ method: "POST",
1330
+ path: "/communications",
1331
+ body: data
1332
+ });
1333
+ }
1334
+ async list(params) {
1335
+ return this.http.request({
1336
+ method: "GET",
1337
+ path: "/communications",
1338
+ params
1339
+ });
1340
+ }
1341
+ async get(id) {
1342
+ return this.http.request({
1343
+ method: "GET",
1344
+ path: `/communications/${id}`
1345
+ });
1346
+ }
1347
+ async link(id, data) {
1348
+ return this.http.request({
1349
+ method: "POST",
1350
+ path: `/communications/${id}/link`,
1351
+ body: data
1352
+ });
1353
+ }
1354
+ };
1355
+
1356
+ // src/resources/conversations.ts
1357
+ var ConversationsResource = class {
1358
+ constructor(http2) {
1359
+ this.http = http2;
1360
+ }
1361
+ async log(data) {
1362
+ return this.http.request({ method: "POST", path: "/conversations", body: data });
1363
+ }
1364
+ async list(params) {
1365
+ return this.http.request({ method: "GET", path: "/conversations", params });
1366
+ }
1367
+ /** The review queue: `list()` pinned to `match_status: 'needs_review'`. */
1368
+ async reviewQueue(params) {
1369
+ return this.list({ ...params, match_status: "needs_review" });
1370
+ }
1371
+ async get(id) {
1372
+ return this.http.request({ method: "GET", path: `/conversations/${encodeURIComponent(id)}` });
1373
+ }
1374
+ async update(id, data) {
1375
+ return this.http.request({ method: "PATCH", path: `/conversations/${encodeURIComponent(id)}`, body: data });
1376
+ }
1377
+ async delete(id) {
1378
+ await this.http.request({ method: "DELETE", path: `/conversations/${encodeURIComponent(id)}` });
1379
+ }
1380
+ async link(id, data) {
1381
+ return this.http.request({ method: "POST", path: `/conversations/${encodeURIComponent(id)}/links`, body: data });
1382
+ }
1383
+ async unlink(id, linkId) {
1384
+ return this.http.request({
1385
+ method: "DELETE",
1386
+ path: `/conversations/${encodeURIComponent(id)}/links/${encodeURIComponent(linkId)}`
1387
+ });
1388
+ }
1389
+ async resolve(id, data) {
1390
+ return this.http.request({ method: "POST", path: `/conversations/${encodeURIComponent(id)}/resolve`, body: data });
1391
+ }
1392
+ async getInternalDomains() {
1393
+ return this.http.request({ method: "GET", path: "/conversations/settings/internal-domains" });
1394
+ }
1395
+ /** Requires an admin: the server checks `Update` on `Subject.Tenant` (tenant-wide matching config), not `Subject.Conversation`. */
1396
+ async setInternalDomains(data) {
1397
+ return this.http.request({ method: "PUT", path: "/conversations/settings/internal-domains", body: data });
1398
+ }
1399
+ /**
1400
+ * E57-F2-S4 — disconnect the CALLER's own Circleback connection (Update
1401
+ * Conversation). Another user's connection id is a 404. Connecting is the
1402
+ * interactive browser OAuth flow (Settings → Conversations), not an SDK call.
1403
+ */
1404
+ async disconnectCircleback(data) {
1405
+ return this.http.request({
1406
+ method: "POST",
1407
+ path: "/conversations/sources/circleback/disconnect",
1408
+ body: data
1409
+ });
1410
+ }
1411
+ /**
1412
+ * E57-F2-S8 — pull one company's meetings from every active teammate's
1413
+ * connected source (Update Conversation). 202, runs in the background.
1414
+ * 404 for a company you can't see; 409 `NO_SOURCES` when nobody has one.
1415
+ */
1416
+ async pull(data) {
1417
+ return this.http.request({ method: "POST", path: "/conversations/pull", body: data });
1418
+ }
1419
+ /**
1420
+ * E57-F2-S9 — whether a Pull has finished: pass the `job_ids` `pull()`
1421
+ * returned (1–50). Update Conversation, like `pull()`. 404
1422
+ * `PULL_NOT_FOUND` when none of them is readable (expired after ~2h,
1423
+ * unknown) — treat that as settled.
1424
+ */
1425
+ async getPullStatus(jobIds) {
1426
+ return this.http.request({
1427
+ method: "GET",
1428
+ path: "/conversations/pull/status",
1429
+ params: { job_ids: jobIds.join(",") }
1430
+ });
1431
+ }
1432
+ /** E57-F2-S8 — sync the caller's OWN Circleback connection now (deduplicated). 409 `NO_CONNECTION` when they have none. */
1433
+ async syncNow() {
1434
+ return this.http.request({ method: "POST", path: "/conversations/sources/circleback/sync-now" });
1435
+ }
1436
+ /** E57-F2-S8 — the caller's own connection, `has_sources`, and (admins only) the roster. */
1437
+ async syncStatus() {
1438
+ return this.http.request({ method: "GET", path: "/conversations/sync-status" });
1439
+ }
1440
+ /**
1441
+ * E57-F4-S1 — a synced meeting's transcript, fetched live from the meeting
1442
+ * recorder (never stored by Planes; the response is `Cache-Control:
1443
+ * no-store`). Read Conversation, plus the tenant's transcript-access rule:
1444
+ * 403 `TRANSCRIPT_OWNER_ONLY` under `owner` for a non-owner; 409
1445
+ * `TRANSCRIPT_SOURCE_UNAVAILABLE` (`owner_name` says who must reconnect) or
1446
+ * `TRANSCRIPT_NOT_AVAILABLE` (not a synced meeting); 404 when you can't see
1447
+ * the conversation. `segments: []` = no transcript yet.
1448
+ */
1449
+ async getTranscript(id) {
1450
+ return this.http.request({
1451
+ method: "GET",
1452
+ path: `/conversations/${encodeURIComponent(id)}/transcript`
1453
+ });
1454
+ }
1455
+ /** E57-F4-S1 — who can view transcripts: `owner` (default) or `viewers`. Read Conversation. */
1456
+ async getTranscriptAccess() {
1457
+ return this.http.request({ method: "GET", path: "/conversations/settings/transcript-access" });
1458
+ }
1459
+ /** E57-F4-S1 — requires an admin: the server checks `Update` on `Subject.Tenant`. */
1460
+ async setTranscriptAccess(value) {
1461
+ return this.http.request({
1462
+ method: "PUT",
1463
+ path: "/conversations/settings/transcript-access",
1464
+ body: { transcript_access: value }
1465
+ });
1466
+ }
1467
+ };
1468
+
1469
+ // src/resources/gmail.ts
1470
+ var GmailResource = class {
1471
+ constructor(http2) {
1472
+ this.http = http2;
1473
+ }
1474
+ /**
1475
+ * Send an email RIGHT NOW from the connected user's real Gmail address.
1476
+ * Hits `POST /admin/integrations/google/gmail/send` — final per Task 4
1477
+ * (`apps/api/src/modules/integrations/google/google-connection.controller.ts`).
1478
+ */
1479
+ async send(data) {
1480
+ return this.http.request({
1481
+ method: "POST",
1482
+ path: "/admin/integrations/google/gmail/send",
1483
+ body: data
1484
+ });
1485
+ }
1486
+ };
1487
+
1488
+ // src/resources/documents.ts
1489
+ var DocumentsResource = class {
1490
+ constructor(http2) {
1491
+ this.http = http2;
1492
+ }
1493
+ /** Attach an external (link-only) document — e.g. a Google Drive link — to a record. */
1494
+ async attachExternal(data) {
1495
+ return this.http.request({
1496
+ method: "POST",
1497
+ path: "/documents/external",
1498
+ body: data
1499
+ });
1500
+ }
1501
+ /** Documents filed directly on one record (uploaded + external), newest first. */
1502
+ async listForEntity(entityType, entityId) {
1503
+ return this.http.request({
1504
+ method: "GET",
1505
+ path: `/${entityType}/${entityId}/documents`
1506
+ });
1507
+ }
1508
+ };
1509
+
1510
+ // src/resources/tags.ts
1511
+ var TagResource = class extends ApiResource {
1512
+ constructor(http2) {
1513
+ super(http2, "/tags");
1514
+ }
1515
+ /** GET /tags */
1516
+ async list(params) {
1517
+ return this.http.request({
1518
+ method: "GET",
1519
+ path: this.basePath,
1520
+ params
1521
+ });
1522
+ }
1523
+ /** POST /tags — 409 on a case-insensitive duplicate name. */
1524
+ async create(data) {
1525
+ return this.http.request({ method: "POST", path: this.basePath, body: data });
1526
+ }
1527
+ /** PATCH /tags/:id — rename / recolor; 409 on a case-insensitive duplicate name. */
1528
+ async update(id, data) {
1529
+ return this.http.request({ method: "PATCH", path: `${this.basePath}/${id}`, body: data });
1530
+ }
1531
+ /** DELETE /tags/:id — cascades the tag off every record. */
1532
+ async delete(id) {
1533
+ await this.http.request({ method: "DELETE", path: `${this.basePath}/${id}` });
1534
+ }
1535
+ /**
1536
+ * POST /tags/:winnerId/merge/:loserId — fold a duplicate tag into another: records
1537
+ * move to the winner (`retagged`), duplicates are dropped (`dropped`), and the
1538
+ * loser is deleted. Irreversible.
1539
+ */
1540
+ async merge(winnerId, loserId) {
1541
+ return this.http.request({ method: "POST", path: `${this.basePath}/${winnerId}/merge/${loserId}` });
1542
+ }
1543
+ /** `TagsService.setEntityTags()` returns the final tag set wrapped in `{ tags }`. */
1544
+ async setEntityTags(entityType, entityId, data) {
1545
+ return this.http.request({
1546
+ method: "PUT",
1547
+ path: `/entities/${entityType}/${entityId}/tags`,
1548
+ body: data
1549
+ });
1550
+ }
1551
+ /**
1552
+ * POST /entities/:type/:id/tags — add ONE tag, keeping the record's other tags.
1553
+ * Safe to call concurrently with other tag changes on the same record (unlike
1554
+ * read-modify-write through `setEntityTags()`). Adding a tag the record already
1555
+ * carries is a no-op. Returns the record's full tag set.
1556
+ */
1557
+ async addEntityTag(entityType, entityId, ref) {
1558
+ const body = ref.tagId !== void 0 ? { tag_id: ref.tagId } : { tag_name: ref.tagName };
1559
+ return this.http.request({
1560
+ method: "POST",
1561
+ path: `/entities/${entityType}/${entityId}/tags`,
1562
+ body
1563
+ });
1564
+ }
1565
+ /**
1566
+ * DELETE /entities/:type/:id/tags/:tagId — remove ONE tag, keeping the rest.
1567
+ * Removing a tag the record doesn't carry is a no-op. Returns the record's
1568
+ * full tag set.
1569
+ */
1570
+ async removeEntityTag(entityType, entityId, tagId) {
1571
+ return this.http.request({
1572
+ method: "DELETE",
1573
+ path: `/entities/${entityType}/${entityId}/tags/${tagId}`
1574
+ });
1575
+ }
1576
+ async getEntityTags(entityType, entityId) {
1577
+ return this.http.request({
1578
+ method: "GET",
1579
+ path: `/entities/${entityType}/${entityId}/tags`
1580
+ });
1581
+ }
1582
+ async getEntities(tagId, params) {
1583
+ return this.http.request({
1584
+ method: "GET",
1585
+ path: `/tags/${tagId}/entities`,
1586
+ params
1587
+ });
1588
+ }
1589
+ };
1590
+
1591
+ // src/resources/lists.ts
1592
+ var ListsResource = class extends ApiResource {
1593
+ constructor(http2) {
1594
+ super(http2, "/lists");
1595
+ }
1596
+ /** GET /lists — every list, newest first, each with `member_count`. A bare array. */
1597
+ async list() {
1598
+ return this.http.request({ method: "GET", path: this.basePath });
1599
+ }
1600
+ /**
1601
+ * GET /lists/filter-fields — the standard fields, their types and the operators
1602
+ * each accepts for a smart list of this entity type, and whether custom fields
1603
+ * are accepted (E66-S3). A save that breaks these rules is a 400.
1604
+ */
1605
+ async filterFields(entityType) {
1606
+ return this.http.request({
1607
+ method: "GET",
1608
+ path: `${this.basePath}/filter-fields`,
1609
+ params: { entity_type: entityType }
1610
+ });
1611
+ }
1612
+ /** GET /lists/:id — one list with an on-demand `member_count`. */
1613
+ async get(id) {
1614
+ return this.http.request({ method: "GET", path: `${this.basePath}/${id}` });
1615
+ }
1616
+ /** POST /lists */
1617
+ async create(data) {
1618
+ return this.http.request({ method: "POST", path: this.basePath, body: data });
1619
+ }
1620
+ /** PATCH /lists/:id — rename, or replace a smart list's definition. */
1621
+ async update(id, data) {
1622
+ return this.http.request({ method: "PATCH", path: `${this.basePath}/${id}`, body: data });
1623
+ }
1624
+ /** DELETE /lists/:id — soft delete; the records on the list are untouched. */
1625
+ async delete(id) {
1626
+ await this.http.request({ method: "DELETE", path: `${this.basePath}/${id}` });
1627
+ }
1628
+ /** POST /lists/:id/members — static lists only; idempotent on duplicates. */
1629
+ async addMembers(id, members) {
1630
+ return this.http.request({
1631
+ method: "POST",
1632
+ path: `${this.basePath}/${id}/members`,
1633
+ body: { members }
1634
+ });
1635
+ }
1636
+ /** DELETE /lists/:id/members — static lists only. */
1637
+ async removeMembers(id, members) {
1638
+ return this.http.request({
1639
+ method: "DELETE",
1640
+ path: `${this.basePath}/${id}/members`,
1641
+ body: { members }
1642
+ });
1643
+ }
1644
+ /** GET /lists/:id/recipients — people (audience, contact and customer lists), with consent. */
1645
+ async getRecipients(id, params) {
1646
+ return this.http.request({
1647
+ method: "GET",
1648
+ path: `${this.basePath}/${id}/recipients`,
1649
+ params
1650
+ });
1651
+ }
1652
+ /** POST /lists/:id/export — queues a CSV export; a notification links the file when it's ready. */
1653
+ async export(id, options) {
1654
+ return this.http.request({
1655
+ method: "POST",
1656
+ path: `${this.basePath}/${id}/export`,
1657
+ body: options ?? {}
1658
+ });
1659
+ }
1660
+ };
1661
+
1662
+ // src/resources/lead-sources.ts
1663
+ var LeadSourcesResource = class extends ApiResource {
1664
+ constructor(http2) {
1665
+ super(http2, "/lead-sources");
1666
+ }
1667
+ /** GET /lead-sources — active ones by default, in display order. */
1668
+ async list(options) {
1669
+ const res = await this.http.request({
1670
+ method: "GET",
1671
+ path: this.basePath,
1672
+ ...options?.includeInactive ? { params: { includeInactive: "true" } } : {}
1673
+ });
1674
+ return res.data;
1675
+ }
1676
+ /** POST /lead-sources — 409 on a duplicate key. */
1677
+ async create(data) {
1678
+ const res = await this.http.request({ method: "POST", path: this.basePath, body: data });
1679
+ return res.data;
1680
+ }
1681
+ /** PATCH /lead-sources/:id — label, active flag or order; the key can't change. */
1682
+ async update(id, data) {
1683
+ const res = await this.http.request({
1684
+ method: "PATCH",
1685
+ path: `${this.basePath}/${id}`,
1686
+ body: data
1687
+ });
1688
+ return res.data;
1689
+ }
1690
+ /** DELETE /lead-sources/:id — soft delete. */
1691
+ async delete(id) {
1692
+ await this.http.request({ method: "DELETE", path: `${this.basePath}/${id}` });
1693
+ }
1694
+ };
1695
+
1696
+ // src/resources/tasks.ts
1697
+ var TaskResource = class extends ApiResource {
1698
+ constructor(http2) {
1699
+ super(http2, "/tasks");
1700
+ }
1701
+ async list(params) {
1702
+ return this.http.request({
1703
+ method: "GET",
1704
+ path: this.basePath,
1705
+ params
1706
+ });
1707
+ }
1708
+ /** GET /tasks/:id */
1709
+ async get(id) {
1710
+ return this.http.request({ method: "GET", path: `${this.basePath}/${id}` });
1711
+ }
1712
+ /** POST /tasks. Pass `idempotencyKey` to make a retry safe (E64-S6). */
1713
+ async create(data, options) {
1714
+ return this.http.request({
1715
+ method: "POST",
1716
+ path: this.basePath,
1717
+ body: data,
1718
+ ...options?.idempotencyKey ? { idempotencyKey: options.idempotencyKey } : {}
1719
+ });
1720
+ }
1721
+ /** PATCH /tasks/:id — non-terminal fields only; terminal status changes use the action methods. */
1722
+ async update(id, data) {
1723
+ return this.http.request({ method: "PATCH", path: `${this.basePath}/${id}`, body: data });
1724
+ }
1725
+ /**
1726
+ * POST /tasks/:id/complete — fires the linked workflow transition (best-effort).
1727
+ * The task always completes; `workflow_trigger` says whether the next step ran.
1728
+ */
1729
+ async complete(id) {
1730
+ return this.http.request({ method: "POST", path: `${this.basePath}/${id}/complete` });
1731
+ }
1732
+ /** POST /tasks/:id/cancel */
1733
+ async cancel(id) {
1734
+ return this.http.request({ method: "POST", path: `${this.basePath}/${id}/cancel` });
1735
+ }
1736
+ /** POST /tasks/:id/reopen — the sanctioned resurrect of a completed/cancelled task. */
1737
+ async reopen(id) {
1738
+ return this.http.request({ method: "POST", path: `${this.basePath}/${id}/reopen` });
1739
+ }
1740
+ };
1741
+
1742
+ // src/resources/record-views.ts
1743
+ var RecordViewsResource = class {
1744
+ constructor(http2) {
1745
+ this.http = http2;
1746
+ this.basePath = "/record-views";
1747
+ }
1748
+ /** POST /record-views — record that the calling user opened this record. Resolves on 204. */
1749
+ async touch(input) {
1750
+ await this.http.request({ method: "POST", path: this.basePath, body: input });
1751
+ }
1752
+ /** GET /record-views/recent — the calling user's most recently viewed records, newest first. */
1753
+ async recent(params) {
1754
+ return this.http.request({
1755
+ method: "GET",
1756
+ path: `${this.basePath}/recent`,
1757
+ params: toQueryParams(params)
1758
+ });
1759
+ }
1760
+ };
1761
+
1762
+ // src/resources/modules.ts
1763
+ var ModulesResource = class {
1764
+ constructor(http2) {
1765
+ this.http = http2;
1766
+ this.basePath = "/modules";
1767
+ }
1768
+ /** GET /modules — one entry per registered module key, in canonical order. */
1769
+ async list() {
1770
+ const res = await this.http.request({
1771
+ method: "GET",
1772
+ path: this.basePath
1773
+ });
1774
+ return res.data;
1775
+ }
1776
+ };
1777
+
1778
+ // src/resources/plan.ts
1779
+ var PlanResource = class {
1780
+ constructor(http2) {
1781
+ this.http = http2;
1782
+ this.basePath = "/plan";
1783
+ }
1784
+ /** GET /plan — plan, billing status and the plan's ceiling. */
1785
+ async get() {
1786
+ const res = await this.http.request({
1787
+ method: "GET",
1788
+ path: this.basePath
1789
+ });
1790
+ return res.data;
1791
+ }
1792
+ };
1793
+
1794
+ // src/resources/me.ts
1795
+ var MeResource = class {
1796
+ constructor(http2) {
1797
+ this.http = http2;
1798
+ this.basePath = "/me";
1799
+ }
1800
+ /**
1801
+ * GET /me/abilities — the caller's effective ability: for an API key, the key
1802
+ * role intersected with its acting agent's live role (`actingRole`).
1803
+ */
1804
+ async abilities() {
1805
+ return this.http.request({
1806
+ method: "GET",
1807
+ path: `${this.basePath}/abilities`
1808
+ });
1809
+ }
1810
+ };
1811
+
1812
+ // src/resources/roles.ts
1813
+ var RolesResource = class {
1814
+ constructor(http2) {
1815
+ this.http = http2;
1816
+ this.basePath = "/roles";
1817
+ }
1818
+ /** GET /roles — every role (not `system_agent`) with user and change counts. */
1819
+ async list() {
1820
+ return this.http.request({ method: "GET", path: this.basePath });
1821
+ }
1822
+ /** GET /roles/:key — one role's permission matrix, summary and grant version. */
1823
+ async get(key) {
1824
+ return this.http.request({
1825
+ method: "GET",
1826
+ path: `${this.basePath}/${encodeURIComponent(key)}`
1827
+ });
1828
+ }
1829
+ /**
1830
+ * PUT /roles/:key/grants — sparse per-cell changes, all validated before any
1831
+ * is written. 422 `GRANT_REQUIRED` / `GRANT_NOT_DELEGABLE` for locked cells,
1832
+ * `CONFIRMATION_REQUIRED` when a money action is granted without
1833
+ * `confirm: true` + `reason`, `ROLE_NOT_TUNABLE` for admin; 409
1834
+ * `ROLE_VERSION_CONFLICT` on a stale `baseVersion`. Returns the updated role.
1835
+ */
1836
+ async updateGrants(key, body) {
1837
+ return this.http.request({
1838
+ method: "PUT",
1839
+ path: `${this.basePath}/${encodeURIComponent(key)}/grants`,
1840
+ body
1841
+ });
1842
+ }
1843
+ /** DELETE /roles/:key/grants — back to the Planes defaults. Returns the reset role. */
1844
+ async reset(key) {
1845
+ return this.http.request({
1846
+ method: "DELETE",
1847
+ path: `${this.basePath}/${encodeURIComponent(key)}/grants`
1848
+ });
1849
+ }
1850
+ /** GET /roles/history — the change log, newest first; page with `cursor`. */
1851
+ async history(params) {
1852
+ return this.http.request({
1853
+ method: "GET",
1854
+ path: `${this.basePath}/history`,
1855
+ ...params ? { params } : {}
1856
+ });
1857
+ }
1858
+ };
1859
+
1860
+ // src/resources/invoice-settings.ts
1861
+ var InvoiceSettingsResource = class {
1862
+ constructor(http2) {
1863
+ this.http = http2;
1864
+ this.basePath = "/admin/invoice-settings";
1865
+ }
1866
+ /**
1867
+ * GET /admin/invoice-settings/offline-instructions — the plain-text
1868
+ * instructions shown on the pay page when online payment is unavailable,
1869
+ * or null when none are set.
1870
+ */
1871
+ async getOfflineInstructions() {
1872
+ const res = await this.http.request({
1873
+ method: "GET",
1874
+ path: `${this.basePath}/offline-instructions`
1875
+ });
1876
+ return res.instructions;
1877
+ }
1878
+ /**
1879
+ * PUT /admin/invoice-settings/offline-instructions — store plain text
1880
+ * (trimmed, at most 2,000 characters); null or blank clears it. Returns the
1881
+ * stored value.
1882
+ */
1883
+ async setOfflineInstructions(text) {
1884
+ const body = { instructions: text };
1885
+ const res = await this.http.request({
1886
+ method: "PUT",
1887
+ path: `${this.basePath}/offline-instructions`,
1888
+ body
1889
+ });
1890
+ return res.instructions;
1891
+ }
1892
+ /**
1893
+ * GET /admin/invoice-settings/overdue-offsets — the days after the due date
1894
+ * at which `invoice.overdue` fires, ascending (default `[3, 7, 14]`).
1895
+ */
1896
+ async getOverdueOffsets() {
1897
+ const res = await this.http.request({
1898
+ method: "GET",
1899
+ path: `${this.basePath}/overdue-offsets`
1900
+ });
1901
+ return res.offsets;
1902
+ }
1903
+ /**
1904
+ * PUT /admin/invoice-settings/overdue-offsets — replace the offsets: 1 to 5
1905
+ * unique whole days, each 1–90. Returns them sorted ascending. Admin only.
1906
+ */
1907
+ async setOverdueOffsets(offsets) {
1908
+ const body = { offsets };
1909
+ const res = await this.http.request({
1910
+ method: "PUT",
1911
+ path: `${this.basePath}/overdue-offsets`,
1912
+ body
1913
+ });
1914
+ return res.offsets;
1915
+ }
1916
+ /**
1917
+ * GET /admin/invoice-settings/attach-pdf — whether invoice emails carry the
1918
+ * invoice PDF (on unless an admin turned it off).
1919
+ */
1920
+ async getAttachPdf() {
1921
+ const res = await this.http.request({
1922
+ method: "GET",
1923
+ path: `${this.basePath}/attach-pdf`
1924
+ });
1925
+ return res.enabled;
1926
+ }
1927
+ /**
1928
+ * PUT /admin/invoice-settings/attach-pdf — turn the PDF attachment on
1929
+ * invoice emails on or off. Returns the stored value.
1930
+ */
1931
+ async setAttachPdf(enabled) {
1932
+ const body = { enabled };
1933
+ const res = await this.http.request({
1934
+ method: "PUT",
1935
+ path: `${this.basePath}/attach-pdf`,
1936
+ body
1937
+ });
1938
+ return res.enabled;
1939
+ }
1940
+ };
1941
+
1942
+ // src/resources/invoice-reminders.ts
1943
+ var InvoiceRemindersResource = class {
1944
+ constructor(http2) {
1945
+ this.http = http2;
1946
+ this.basePath = "/admin/invoice-reminders";
1947
+ }
1948
+ /** GET /admin/invoice-reminders — the rules, ascending by offset, and the overdue offsets. */
1949
+ async list() {
1950
+ return this.http.request({
1951
+ method: "GET",
1952
+ path: this.basePath
1953
+ });
1954
+ }
1955
+ /**
1956
+ * PUT /admin/invoice-reminders — replace the WHOLE rule set (a rule left out
1957
+ * is deleted): up to 5 rules at unique offsets. Templates may use only
1958
+ * `{{customerName}}`, `{{invoiceNumber}}`, `{{amountDue}}`, `{{total}}`,
1959
+ * `{{dueDate}}`, `{{daysOverdue}}` and `{{companyName}}`; any other is a 422
1960
+ * `REMINDER_TEMPLATE_INVALID` listing each one. Returns the stored set.
1961
+ */
1962
+ async update(rules) {
1963
+ return this.http.request({
1964
+ method: "PUT",
1965
+ path: this.basePath,
1966
+ body: { rules }
1967
+ });
1968
+ }
1969
+ /**
1970
+ * POST /admin/invoice-reminders/preview — render a subject and body exactly
1971
+ * as the reminder email would, against an invoice or a sample. Sends nothing.
1972
+ */
1973
+ async preview(params) {
1974
+ return this.http.request({
1975
+ method: "POST",
1976
+ path: `${this.basePath}/preview`,
1977
+ body: params
1978
+ });
1979
+ }
1980
+ };
1981
+
1982
+ // src/resources/event-automations.ts
1983
+ var EventAutomationsResource = class {
1984
+ constructor(http2) {
1985
+ this.http = http2;
1986
+ }
1987
+ // Each request spells its path out in full (no computed base path) so the
1988
+ // API's SDK route-parity audit (sdk-route-parity-audit.spec.ts) can read it.
1989
+ /** GET — enabled and disabled automations, oldest first, optionally by event type or owner. */
1990
+ async list(params = {}) {
1991
+ const query = {};
1992
+ if (params.owner_tag) query["owner_tag"] = params.owner_tag;
1993
+ if (params.event_type) query["event_type"] = params.event_type;
1994
+ const res = await this.http.request({
1995
+ method: "GET",
1996
+ path: "/admin/event-automations",
1997
+ params: query
1998
+ });
1999
+ return res.data;
2000
+ }
2001
+ /** GET /:id — 404 when it doesn't exist or was deleted. */
2002
+ async get(id) {
2003
+ return this.http.request({
2004
+ method: "GET",
2005
+ path: `/admin/event-automations/${encodeURIComponent(id)}`
2006
+ });
2007
+ }
2008
+ /**
2009
+ * POST — create (201). 400 `VALIDATION_FAILED` for a bad body, or a 400
2010
+ * naming the step whose `action_type` isn't allowed in automations.
2011
+ */
2012
+ async create(input) {
2013
+ return this.http.request({
2014
+ method: "POST",
2015
+ path: "/admin/event-automations",
2016
+ body: input
2017
+ });
2018
+ }
2019
+ /**
2020
+ * PATCH /:id — only the fields sent change. Sending `actions` replaces the
2021
+ * list: keep each existing step's `id` so a step that already ran isn't run
2022
+ * again. `{ enabled: false }` switches it off.
2023
+ */
2024
+ async update(id, input) {
2025
+ return this.http.request({
2026
+ method: "PATCH",
2027
+ path: `/admin/event-automations/${encodeURIComponent(id)}`,
2028
+ body: input
2029
+ });
2030
+ }
2031
+ /** DELETE /:id — soft delete; returns `{ id }` (200). */
2032
+ async delete(id) {
2033
+ return this.http.request({
2034
+ method: "DELETE",
2035
+ path: `/admin/event-automations/${encodeURIComponent(id)}`
2036
+ });
2037
+ }
2038
+ };
2039
+
2040
+ // src/resources/web-forms.ts
2041
+ var WebFormsResource = class {
2042
+ constructor(http2) {
2043
+ this.http = http2;
2044
+ this.submissions = new WebFormSubmissionsResource(http2);
2045
+ }
2046
+ // Each request spells its path out in full so the API's SDK route-parity
2047
+ // audit (sdk-route-parity-audit.spec.ts) can read it.
2048
+ /** GET — every form not archived, newest first. */
2049
+ async list() {
2050
+ const res = await this.http.request({ method: "GET", path: "/admin/web-forms" });
2051
+ return res.data;
2052
+ }
2053
+ /** GET /trade-options — the active trades a `trade` question offers, by current name. */
2054
+ async tradeOptions() {
2055
+ const res = await this.http.request({ method: "GET", path: "/admin/web-forms/trade-options" });
2056
+ return res.data;
2057
+ }
2058
+ /** GET /:id */
2059
+ async get(id) {
2060
+ return this.http.request({ method: "GET", path: `/admin/web-forms/${encodeURIComponent(id)}` });
2061
+ }
2062
+ /** POST — create (201) with its default routing. Pass `recipient_agent_ids`. */
2063
+ async create(input) {
2064
+ return this.http.request({ method: "POST", path: "/admin/web-forms", body: input });
2065
+ }
2066
+ /** PATCH /:id — only the fields sent change. `active: false` switches the form off. */
2067
+ async update(id, input) {
2068
+ return this.http.request({
2069
+ method: "PATCH",
2070
+ path: `/admin/web-forms/${encodeURIComponent(id)}`,
2071
+ body: input
2072
+ });
2073
+ }
2074
+ /** DELETE /:id — archive: the public URL stops working and routing stops. Returns `{ id }`. */
2075
+ async archive(id) {
2076
+ return this.http.request({ method: "DELETE", path: `/admin/web-forms/${encodeURIComponent(id)}` });
2077
+ }
2078
+ /** POST /:id/rotate-key — a new public key; the old embed stops working at once. */
2079
+ async rotateKey(id) {
2080
+ return this.http.request({
2081
+ method: "POST",
2082
+ path: `/admin/web-forms/${encodeURIComponent(id)}/rotate-key`
2083
+ });
2084
+ }
2085
+ };
2086
+ var WebFormSubmissionsResource = class {
2087
+ constructor(http2) {
2088
+ this.http = http2;
2089
+ }
2090
+ /** GET /submissions — the first page, newest first, with routing state. Use `listPage` to read on. */
2091
+ async list(params = {}) {
2092
+ return (await this.listPage(params)).data;
2093
+ }
2094
+ /**
2095
+ * GET /submissions — one page plus `next`, which is null on the last page.
2096
+ * Pass `next`'s `before` and `before_id` back in to read the following page.
2097
+ */
2098
+ async listPage(params = {}) {
2099
+ const query = {};
2100
+ for (const [k, v] of Object.entries(params)) if (v !== void 0) query[k] = v;
2101
+ const res = await this.http.request({
2102
+ method: "GET",
2103
+ path: "/admin/web-forms/submissions",
2104
+ params: query
2105
+ });
2106
+ return { data: res.data, next: res.next ?? null };
2107
+ }
2108
+ /** GET /submissions/:id — answers as seen, plus each routing step. */
2109
+ async get(id) {
2110
+ return this.http.request({
2111
+ method: "GET",
2112
+ path: `/admin/web-forms/submissions/${encodeURIComponent(id)}`
2113
+ });
2114
+ }
2115
+ /** PATCH /submissions/:id — set triage status. */
2116
+ async update(id, input) {
2117
+ return this.http.request({
2118
+ method: "PATCH",
2119
+ path: `/admin/web-forms/submissions/${encodeURIComponent(id)}`,
2120
+ body: input
2121
+ });
2122
+ }
2123
+ /** POST /submissions/:id/route — retry failed steps, run never-run ones (not email, text or webhook: `skipped`); safe to repeat. */
2124
+ async route(id) {
2125
+ return this.http.request({
2126
+ method: "POST",
2127
+ path: `/admin/web-forms/submissions/${encodeURIComponent(id)}/route`
2128
+ });
2129
+ }
2130
+ };
2131
+
2132
+ // src/resources/contact-sequences.ts
2133
+ var ContactSequencesResource = class {
2134
+ constructor(http2) {
2135
+ this.http = http2;
2136
+ this.basePath = "/contact-sequences";
2137
+ }
2138
+ /** GET /contact-sequences — `{ data, meta: { total } }`, name-sorted, max 100. */
2139
+ async list() {
2140
+ return this.http.request({
2141
+ method: "GET",
2142
+ path: this.basePath
2143
+ });
2144
+ }
2145
+ };
2146
+
2147
+ // src/resources/enrollments.ts
2148
+ var EnrollmentsResource = class {
2149
+ constructor(http2) {
2150
+ this.http = http2;
2151
+ }
2152
+ /**
2153
+ * POST /contacts/:id/enrollments — `{ workflow_id }`. 409 if the contact is
2154
+ * already active in the sequence; 422 if the sequence has no published version.
2155
+ */
2156
+ async enroll(contactId, workflowId) {
2157
+ return this.http.request({
2158
+ method: "POST",
2159
+ path: `/contacts/${contactId}/enrollments`,
2160
+ body: { workflow_id: workflowId }
2161
+ });
2162
+ }
2163
+ /** GET /contacts/:id/enrollments — a bare array, newest first; optional `status` filter. */
2164
+ async list(contactId, params) {
2165
+ return this.http.request({
2166
+ method: "GET",
2167
+ path: `/contacts/${contactId}/enrollments`,
2168
+ ...params ? { params } : {}
2169
+ });
2170
+ }
2171
+ /**
2172
+ * POST /enrollments/:id/exit — no body; the exit reason is recorded as
2173
+ * `'manual'`. Idempotent: an already-ended enrollment is returned unchanged.
2174
+ */
2175
+ async exit(enrollmentId) {
2176
+ return this.http.request({
2177
+ method: "POST",
2178
+ path: `/enrollments/${enrollmentId}/exit`
2179
+ });
2180
+ }
2181
+ };
2182
+
2183
+ // src/resources/workflow-event-rules.ts
2184
+ var WorkflowEventRulesResource = class {
2185
+ constructor(http2, workflowId) {
2186
+ this.http = http2;
2187
+ this.workflowId = workflowId;
2188
+ }
2189
+ // Each request spells its path out in full (no computed base path) so the
2190
+ // API's SDK route-parity audit (sdk-route-parity-audit.spec.ts) can read it.
2191
+ /** GET — a bare array of the workflow's live rules, newest first. 404 `WORKFLOW_NOT_FOUND`. */
2192
+ async list() {
2193
+ return this.http.request({
2194
+ method: "GET",
2195
+ path: `/admin/workflows/${encodeURIComponent(this.workflowId)}/event-rules`
2196
+ });
2197
+ }
2198
+ /**
2199
+ * POST — add a rule (201). `when` defaults to `{}` and `enabled` to true; use
2200
+ * `when: {}` for the creation types in `WORKFLOW_EVENT_RULE_MATCH_ALL_EVENT_TYPES`.
2201
+ * 400 `VALIDATION_FAILED` for a bad body; 404 `WORKFLOW_NOT_FOUND`.
2202
+ */
2203
+ async create(input) {
2204
+ return this.http.request({
2205
+ method: "POST",
2206
+ path: `/admin/workflows/${encodeURIComponent(this.workflowId)}/event-rules`,
2207
+ body: input
2208
+ });
2209
+ }
2210
+ /** PATCH /:id — only the fields sent change (at least one). 404 `EVENT_RULE_NOT_FOUND`. */
2211
+ async update(ruleId, input) {
2212
+ return this.http.request({
2213
+ method: "PATCH",
2214
+ path: `/admin/workflows/${encodeURIComponent(this.workflowId)}/event-rules/${encodeURIComponent(ruleId)}`,
2215
+ body: input
2216
+ });
2217
+ }
2218
+ /** DELETE /:id — soft delete; returns `{ id }` (200). 404 `EVENT_RULE_NOT_FOUND`. */
2219
+ async delete(ruleId) {
2220
+ return this.http.request({
2221
+ method: "DELETE",
2222
+ path: `/admin/workflows/${encodeURIComponent(this.workflowId)}/event-rules/${encodeURIComponent(ruleId)}`
2223
+ });
2224
+ }
2225
+ };
2226
+
2227
+ // src/resources/workflows.ts
2228
+ var WorkflowsResource = class {
2229
+ constructor(http2) {
2230
+ this.http = http2;
2231
+ this.basePath = "/workflows";
2232
+ this.adminPath = "/admin/workflows";
2233
+ }
2234
+ /**
2235
+ * GET /workflows/:id/stages — the ordered stages of one workflow version. Pass
2236
+ * a record's instance `workflowId` (e.g. from `GET /opportunities/:id/workflow`)
2237
+ * to get the stages of the version that record is pinned to, even an archived
2238
+ * one. 404 for an unknown or draft id; 403 if the caller cannot read the
2239
+ * workflow's record type.
2240
+ */
2241
+ async getStages(workflowId) {
2242
+ return this.http.request({
2243
+ method: "GET",
2244
+ path: `${this.basePath}/${encodeURIComponent(workflowId)}/stages`
2245
+ });
2246
+ }
2247
+ /**
2248
+ * GET /workflows/transitions — transition summaries of every published
2249
+ * workflow, or with `workflowId` of that one version (published or archived;
2250
+ * an unknown, draft or other-tenant id returns an empty list). Each summary
2251
+ * carries `workflow_id`, `workflow_version`, `lineage_workflow_id` and
2252
+ * `automatic_only`. Only pipelines whose record type the caller can read
2253
+ * are listed; an unreadable `workflowId` returns an empty list, not 403.
2254
+ */
2255
+ async listTransitions(params = {}) {
2256
+ const query = {};
2257
+ if (params.entityTypes && params.entityTypes.length > 0) query["entity_types"] = params.entityTypes.join(",");
2258
+ if (params.workflowId) query["workflow_id"] = params.workflowId;
2259
+ return this.http.request({
2260
+ method: "GET",
2261
+ path: `${this.basePath}/transitions`,
2262
+ params: query
2263
+ });
2264
+ }
2265
+ /**
2266
+ * POST /admin/workflows/:wid/transitions — add a transition to a draft
2267
+ * workflow. Pass `automaticOnly: true` for an edge only automation should
2268
+ * fire (e.g. an event rule advancing on "contract sent").
2269
+ */
2270
+ async createTransition(workflowId, input) {
2271
+ return this.http.request({
2272
+ method: "POST",
2273
+ path: `${this.adminPath}/${encodeURIComponent(workflowId)}/transitions`,
2274
+ body: input
2275
+ });
2276
+ }
2277
+ /**
2278
+ * The event rules of one workflow (`/admin/workflows/:wid/event-rules`) —
2279
+ * "advance automatically when…". Any version's id works; rules are keyed by
2280
+ * the lineage root.
2281
+ */
2282
+ eventRules(workflowId) {
2283
+ return new WorkflowEventRulesResource(this.http, workflowId);
2284
+ }
2285
+ /** PUT /admin/workflows/:wid/transitions/:tid — update a draft workflow's transition. */
2286
+ async updateTransition(workflowId, transitionId, input) {
2287
+ return this.http.request({
2288
+ method: "PUT",
2289
+ path: `${this.adminPath}/${encodeURIComponent(workflowId)}/transitions/${encodeURIComponent(transitionId)}`,
2290
+ body: input
2291
+ });
2292
+ }
2293
+ };
2294
+
2295
+ // src/resources/service-schedules.ts
2296
+ var ServiceSchedulesResource = class {
2297
+ constructor(http2) {
2298
+ this.http = http2;
2299
+ }
2300
+ // Each request spells its path out in full (no computed base path) so the
2301
+ // API's SDK route-parity audit (sdk-route-parity-audit.spec.ts) can read it.
2302
+ /** GET — the schedules of one customer or opportunity. */
2303
+ async list(subject_type, subject_id) {
2304
+ return this.http.request({
2305
+ method: "GET",
2306
+ path: "/service-schedules",
2307
+ params: { subject_type, subject_id }
2308
+ });
2309
+ }
2310
+ /** GET /:id — 404 when it doesn't exist or was deleted. */
2311
+ async get(id) {
2312
+ return this.http.request({
2313
+ method: "GET",
2314
+ path: `/service-schedules/${encodeURIComponent(id)}`
2315
+ });
2316
+ }
2317
+ /**
2318
+ * POST — create (201). The horizon's visits are generated straight away.
2319
+ * 400 `INVALID_RECURRENCE_RULE`, `SERVICE_TRADE_REQUIRED` or a validation error.
2320
+ */
2321
+ async create(input) {
2322
+ return this.http.request({
2323
+ method: "POST",
2324
+ path: "/service-schedules",
2325
+ body: input
2326
+ });
2327
+ }
2328
+ /**
2329
+ * PATCH /:id — only the fields sent change. A cadence, time, crew, duration
2330
+ * or horizon change regenerates future visits from today (`effective_from`,
2331
+ * which must be today) and reports it in `regeneration`; a visit someone changed is never
2332
+ * touched and is listed under `regeneration.protected`. The edit and its
2333
+ * regeneration succeed or fail together. 400 `INVALID_EFFECTIVE_FROM` for any
2334
+ * date but today.
2335
+ */
2336
+ async update(id, input) {
2337
+ return this.http.request({
2338
+ method: "PATCH",
2339
+ path: `/service-schedules/${encodeURIComponent(id)}`,
2340
+ body: input
2341
+ });
2342
+ }
2343
+ /** POST /:id/preview-update — what `update` with the same input would do. Writes nothing. */
2344
+ async previewUpdate(id, input) {
2345
+ return this.http.request({
2346
+ method: "POST",
2347
+ path: `/service-schedules/${encodeURIComponent(id)}/preview-update`,
2348
+ body: input
2349
+ });
2350
+ }
2351
+ /** PATCH /:id/status — pause, resume (`active`) or end. Resume generates the horizon at once. */
2352
+ async setStatus(id, status) {
2353
+ return this.http.request({
2354
+ method: "PATCH",
2355
+ path: `/service-schedules/${encodeURIComponent(id)}/status`,
2356
+ body: { status }
2357
+ });
2358
+ }
2359
+ /** DELETE /:id — soft-delete (204). */
2360
+ async delete(id) {
2361
+ await this.http.request({
2362
+ method: "DELETE",
2363
+ path: `/service-schedules/${encodeURIComponent(id)}`
2364
+ });
2365
+ }
2366
+ /**
2367
+ * POST /conflicts/preview — before booking people, see who is already on
2368
+ * another event (`conflicts`) and who would be outside their working hours
2369
+ * (`working_hours`). Read-only and warn-only: nothing is ever blocked. Give
2370
+ * exactly one of `windows` (single booking) or `schedule` (a cadence). 400 on
2371
+ * invalid input, INVALID_RECURRENCE_RULE, INVALID_TIMEZONE or
2372
+ * TOO_MANY_WINDOWS (> 400).
2373
+ */
2374
+ async previewConflicts(request) {
2375
+ return this.http.request({
2376
+ method: "POST",
2377
+ path: "/service-schedules/conflicts/preview",
2378
+ body: request
2379
+ });
2380
+ }
2381
+ /** GET /settings/crew-roles — which agent roles count as assignable crew. */
2382
+ async getCrewRoles() {
2383
+ return this.http.request({
2384
+ method: "GET",
2385
+ path: "/service-schedules/settings/crew-roles"
2386
+ });
2387
+ }
2388
+ /** PUT /settings/crew-roles — set the assignable roles (an override of the default). */
2389
+ async setCrewRoles(roles) {
2390
+ return this.http.request({
2391
+ method: "PUT",
2392
+ path: "/service-schedules/settings/crew-roles",
2393
+ body: { roles }
2394
+ });
2395
+ }
2396
+ /** GET /settings/crew — assignable crew with their home-base status. */
2397
+ async listCrew() {
2398
+ const res = await this.http.request({
2399
+ method: "GET",
2400
+ path: "/service-schedules/settings/crew"
2401
+ });
2402
+ return res.crew;
2403
+ }
2404
+ /** PUT /settings/crew/:agentId/home-address — set and geocode a crew member's home base. */
2405
+ async setCrewHomeAddress(agentId, address) {
2406
+ return this.http.request({
2407
+ method: "PUT",
2408
+ path: `/service-schedules/settings/crew/${encodeURIComponent(agentId)}/home-address`,
2409
+ body: { address }
2410
+ });
2411
+ }
2412
+ };
2413
+
2414
+ // src/resources/billing-schedules.ts
2415
+ var BillingScheduleResource = class extends BaseResource {
2416
+ constructor(http2) {
2417
+ super(http2, "/admin/billing-schedules");
2418
+ }
2419
+ /** GET /admin/billing-schedules — list rows (no lines; `line_count` and `next_amount` instead). */
2420
+ async list(params) {
2421
+ return this.http.request({
2422
+ method: "GET",
2423
+ path: this.basePath,
2424
+ params: toQueryParams(params)
2425
+ });
2426
+ }
2427
+ /** GET /admin/billing-schedules/:id — the schedule with its lines and next 3 periods. */
2428
+ async get(id) {
2429
+ return this.http.request({
2430
+ method: "GET",
2431
+ path: `${this.basePath}/${encodeURIComponent(id)}`
2432
+ });
2433
+ }
2434
+ /**
2435
+ * POST /admin/billing-schedules. `timezone` defaults to the tenant's. A
2436
+ * backdated `start_date` needs `backfill` ('skip' | 'draft'), else 400
2437
+ * `BACKFILL_REQUIRED`; `collection: 'autopay'` without a platform-managed
2438
+ * Stripe connection and a saved default card is 422 `AUTOPAY_UNAVAILABLE`
2439
+ * (`reason` `no_connect` | `no_saved_method`).
2440
+ */
2441
+ async create(data) {
2442
+ return this.http.request({
2443
+ method: "POST",
2444
+ path: this.basePath,
2445
+ body: data
2446
+ });
2447
+ }
2448
+ /**
2449
+ * PATCH /admin/billing-schedules/:id — partial. `lines` replaces every line
2450
+ * from `effective_from` (default: the next period not yet invoiced) as a new
2451
+ * line version. 409 `CADENCE_LOCKED`; 422 `EFFECTIVE_DATE_IN_GENERATED_PERIOD`
2452
+ * for a date inside an invoiced period.
2453
+ */
2454
+ async update(id, data) {
2455
+ return this.http.request({
2456
+ method: "PATCH",
2457
+ path: `${this.basePath}/${encodeURIComponent(id)}`,
2458
+ body: data
2459
+ });
2460
+ }
2461
+ /** DELETE /admin/billing-schedules/:id — only a schedule that never invoiced (else 409 `SCHEDULE_HAS_INVOICES`). */
2462
+ async delete(id) {
2463
+ await this.http.request({
2464
+ method: "DELETE",
2465
+ path: `${this.basePath}/${encodeURIComponent(id)}`
2466
+ });
2467
+ }
2468
+ /** GET /admin/billing-schedules/:id/versions — line version history, newest effective date first. */
2469
+ async listVersions(id) {
2470
+ return this.http.request({
2471
+ method: "GET",
2472
+ path: `${this.basePath}/${encodeURIComponent(id)}/versions`
2473
+ });
2474
+ }
2475
+ /**
2476
+ * POST /admin/billing-schedules/:id/adjustments — add a one-off amount
2477
+ * (signed; negative is a credit) to the schedule's next generated invoice.
2478
+ * Billed exactly once; no automatic proration. 422 `ADJUSTMENT_INVALID`
2479
+ * (zero, or the next invoice would go below zero) or `SCHEDULE_NOT_ACTIVE`.
2480
+ */
2481
+ async addAdjustment(id, data) {
2482
+ return this.http.request({
2483
+ method: "POST",
2484
+ path: `${this.basePath}/${encodeURIComponent(id)}/adjustments`,
2485
+ body: data
2486
+ });
2487
+ }
2488
+ /** GET /admin/billing-schedules/:id/adjustments — oldest first; default pending and consumed. */
2489
+ async listAdjustments(id, params) {
2490
+ return this.http.request({
2491
+ method: "GET",
2492
+ path: `${this.basePath}/${encodeURIComponent(id)}/adjustments`,
2493
+ params: toQueryParams(params)
2494
+ });
2495
+ }
2496
+ /**
2497
+ * DELETE /admin/billing-schedules/:id/adjustments/:adjustmentId — cancel a
2498
+ * pending adjustment (it never bills). Returns it; 409
2499
+ * `ADJUSTMENT_ALREADY_CONSUMED` once an invoice carries it.
2500
+ */
2501
+ async cancelAdjustment(id, adjustmentId) {
2502
+ return this.http.request({
2503
+ method: "DELETE",
2504
+ path: `${this.basePath}/${encodeURIComponent(id)}/adjustments/${encodeURIComponent(adjustmentId)}`
2505
+ });
2506
+ }
2507
+ /** POST /admin/billing-schedules/:id/pause — 409 `INVALID_STATUS_TRANSITION` unless active. */
2508
+ async pause(id) {
2509
+ return this.http.request({
2510
+ method: "POST",
2511
+ path: `${this.basePath}/${encodeURIComponent(id)}/pause`
2512
+ });
2513
+ }
2514
+ /** POST /admin/billing-schedules/:id/resume — periods that fell due while paused are skipped. */
2515
+ async resume(id) {
2516
+ return this.http.request({
2517
+ method: "POST",
2518
+ path: `${this.basePath}/${encodeURIComponent(id)}/resume`
2519
+ });
2520
+ }
2521
+ /** POST /admin/billing-schedules/:id/end — no further periods generate. */
2522
+ async end(id) {
2523
+ return this.http.request({
2524
+ method: "POST",
2525
+ path: `${this.basePath}/${encodeURIComponent(id)}/end`
2526
+ });
2527
+ }
2528
+ /** GET /admin/billing-schedules/:id/preview — the next `count` (1–24, default 6) periods from the first unbilled one. */
2529
+ async preview(id, params) {
2530
+ return this.http.request({
2531
+ method: "GET",
2532
+ path: `${this.basePath}/${encodeURIComponent(id)}/preview`,
2533
+ params: toQueryParams(params)
2534
+ });
2535
+ }
2536
+ /** GET /admin/billing-schedules/:id/periods — the period ledger, newest first. */
2537
+ async periods(id, params) {
2538
+ return this.http.request({
2539
+ method: "GET",
2540
+ path: `${this.basePath}/${encodeURIComponent(id)}/periods`,
2541
+ params: toQueryParams(params)
2542
+ });
2543
+ }
2544
+ /**
2545
+ * GET /admin/billing-schedules/periods/needs-review — tenant-wide: needs_review
2546
+ * rows plus failed and stuck (pending over 2h) deliveries.
2547
+ */
2548
+ async needsReview(params) {
2549
+ return this.http.request({
2550
+ method: "GET",
2551
+ path: `${this.basePath}/periods/needs-review`,
2552
+ params: toQueryParams(params)
2553
+ });
2554
+ }
2555
+ /**
2556
+ * GET /admin/billing-schedules/autopay-summary — what disconnecting Stripe
2557
+ * would touch: live autopay schedules, the distinct customers on them, and
2558
+ * active saved cards on the current Stripe connection. On disconnect, autopay
2559
+ * schedules that can no longer charge switch to emailed pay links.
2560
+ */
2561
+ async autopaySummary() {
2562
+ return this.http.request({
2563
+ method: "GET",
2564
+ path: `${this.basePath}/autopay-summary`
2565
+ });
2566
+ }
2567
+ /**
2568
+ * POST /admin/billing-schedules/:id/generate-now — bill the current due
2569
+ * period now. Idempotent (`already_generated`); 409 `NOTHING_DUE` or
2570
+ * `SCHEDULE_NOT_ACTIVE`.
2571
+ */
2572
+ async generateNow(id) {
2573
+ return this.http.request({
2574
+ method: "POST",
2575
+ path: `${this.basePath}/${encodeURIComponent(id)}/generate-now`
2576
+ });
2577
+ }
2578
+ /**
2579
+ * POST /admin/billing-schedules/:id/periods/:periodStart/skip — skip one
2580
+ * period (`periodStart` is `YYYY-MM-DD`). Returns the skipped ledger row;
2581
+ * 400 `NOT_A_PERIOD`, 409 `PERIOD_ALREADY_INVOICED`.
2582
+ */
2583
+ async skipPeriod(id, periodStart, data = {}) {
2584
+ return this.http.request({
2585
+ method: "POST",
2586
+ path: `${this.basePath}/${encodeURIComponent(id)}/periods/${encodeURIComponent(periodStart)}/skip`,
2587
+ body: data
2588
+ });
2589
+ }
2590
+ /**
2591
+ * POST /admin/billing-schedules/:id/periods/:periodStart/regenerate — re-bill
2592
+ * a period whose invoice was voided (new draft on the same ledger row).
2593
+ * 409 `INVOICE_NOT_VOID` or `CHECKOUT_IN_FLIGHT`.
2594
+ */
2595
+ async regeneratePeriod(id, periodStart) {
2596
+ return this.http.request({
2597
+ method: "POST",
2598
+ path: `${this.basePath}/${encodeURIComponent(id)}/periods/${encodeURIComponent(periodStart)}/regenerate`
2599
+ });
354
2600
  }
355
2601
  };
356
2602
 
357
- // src/resources/base-resource.ts
358
- var BaseResource = class {
359
- constructor(http2, basePath) {
2603
+ // src/resources/custom-fields.ts
2604
+ var CustomFieldsResource = class {
2605
+ constructor(http2) {
360
2606
  this.http = http2;
361
- this.basePath = basePath;
362
2607
  }
363
- /**
364
- * List entities with optional filters and pagination.
365
- */
2608
+ /** List definitions, optionally narrowed to one entity type. */
366
2609
  async list(params) {
367
2610
  return this.http.request({
368
2611
  method: "GET",
369
- path: this.basePath,
2612
+ path: "/custom-fields",
370
2613
  params
371
2614
  });
372
2615
  }
373
- /**
374
- * Get a single entity by ID.
375
- */
2616
+ /** GET /admin/custom-fields — the same list through the admin route (Manage grant). */
2617
+ async listAll(params) {
2618
+ return this.http.request({
2619
+ method: "GET",
2620
+ path: "/admin/custom-fields",
2621
+ params
2622
+ });
2623
+ }
2624
+ /** GET /admin/custom-fields/:id */
376
2625
  async get(id) {
377
2626
  return this.http.request({
378
2627
  method: "GET",
379
- path: `${this.basePath}/${id}`
2628
+ path: `/admin/custom-fields/${id}`
380
2629
  });
381
2630
  }
382
2631
  /**
383
- * Create a new entity.
2632
+ * POST /admin/custom-fields — define a new field. 400 for `job`, `vendor` or
2633
+ * `agent` (those records can't hold values yet, PRD D6). A `fieldKey` must be
2634
+ * unique per entity type: check `listAll({ entity_type, include_inactive: true })` first.
384
2635
  */
385
2636
  async create(data) {
386
2637
  return this.http.request({
387
2638
  method: "POST",
388
- path: this.basePath,
2639
+ path: "/admin/custom-fields",
389
2640
  body: data
390
2641
  });
391
2642
  }
392
- /**
393
- * Update an existing entity.
394
- */
2643
+ /** PATCH /admin/custom-fields/:id — `fieldKey` and `entityType` can't change. */
395
2644
  async update(id, data) {
396
2645
  return this.http.request({
397
2646
  method: "PATCH",
398
- path: `${this.basePath}/${id}`,
2647
+ path: `/admin/custom-fields/${id}`,
399
2648
  body: data
400
2649
  });
401
2650
  }
402
2651
  /**
403
- * Delete an entity by ID.
2652
+ * DELETE /admin/custom-fields/:id — deactivates the definition (204). Records
2653
+ * keep their stored values; `list({ include_inactive: true })` still shows it,
2654
+ * and `update(id, { active: true })` brings it back.
404
2655
  */
405
- async delete(id) {
2656
+ async deactivate(id) {
406
2657
  await this.http.request({
407
2658
  method: "DELETE",
408
- path: `${this.basePath}/${id}`
2659
+ path: `/admin/custom-fields/${id}`
409
2660
  });
410
2661
  }
411
2662
  };
412
2663
 
413
- // src/resources/opportunities.ts
414
- var OpportunityResource = class extends BaseResource {
415
- constructor(http2) {
416
- super(http2, "/opportunities");
417
- }
418
- };
419
-
420
- // src/resources/customers.ts
421
- var CustomerResource = class extends BaseResource {
422
- constructor(http2) {
423
- super(http2, "/customers");
424
- }
425
- };
426
-
427
- // src/resources/properties.ts
428
- var PropertyResource = class extends BaseResource {
429
- constructor(http2) {
430
- super(http2, "/properties");
431
- }
432
- };
433
-
434
- // src/resources/calendar-events.ts
435
- var CalendarEventResource = class extends BaseResource {
436
- constructor(http2) {
437
- super(http2, "/calendar-events");
438
- }
439
- };
440
-
441
- // src/resources/contracts.ts
442
- var ContractResource = class extends BaseResource {
443
- constructor(http2) {
444
- super(http2, "/contracts");
445
- }
446
- };
447
-
448
- // src/resources/jobs.ts
449
- var JobResource = class extends BaseResource {
450
- constructor(http2) {
451
- super(http2, "/jobs");
452
- }
453
- };
454
-
455
- // src/resources/estimates.ts
456
- var EstimateResource = class extends BaseResource {
457
- constructor(http2) {
458
- super(http2, "/estimates");
459
- }
460
- };
461
-
462
- // src/resources/invoices.ts
463
- var InvoiceResource = class extends BaseResource {
2664
+ // src/resources/ortto.ts
2665
+ var OrttoResource = class {
464
2666
  constructor(http2) {
465
- super(http2, "/invoices");
2667
+ this.http = http2;
2668
+ this.basePath = "/admin/integrations/ortto";
466
2669
  }
467
- };
468
-
469
- // src/resources/inventory.ts
470
- var InventoryResource = class extends BaseResource {
471
- constructor(http2) {
472
- super(http2, "/inventory/items");
2670
+ /** GET /admin/integrations/ortto/mappings — live mappings with their list names. */
2671
+ async listMappings() {
2672
+ const res = await this.http.request({
2673
+ method: "GET",
2674
+ path: `${this.basePath}/mappings`
2675
+ });
2676
+ return res.data;
473
2677
  }
474
- };
475
-
476
- // src/resources/contacts.ts
477
- var ContactChannelResource = class {
478
- constructor(http2, contactId) {
479
- this.http = http2;
480
- this.basePath = `/contacts/${contactId}/channels`;
2678
+ /** GET /admin/integrations/ortto/audiences — the connected account's audiences (cached 60 s). */
2679
+ async listAudiences(params) {
2680
+ const res = await this.http.request({
2681
+ method: "GET",
2682
+ path: `${this.basePath}/audiences`,
2683
+ params
2684
+ });
2685
+ return res.data;
481
2686
  }
482
- /** Returns `{ channel, duplicateOf }` — `duplicateOf` is the dedup signal. */
483
- async create(data) {
484
- return this.http.request({
2687
+ /** POST /admin/integrations/ortto/mappings — 409 when the list already has a mapping. */
2688
+ async createMapping(data) {
2689
+ const res = await this.http.request({
485
2690
  method: "POST",
486
- path: this.basePath,
2691
+ path: `${this.basePath}/mappings`,
487
2692
  body: data
488
2693
  });
2694
+ return res.data;
489
2695
  }
490
- async update(channelId, data) {
491
- return this.http.request({
2696
+ /** PATCH /admin/integrations/ortto/mappings/:id — `ortto_tag` and/or `create_unmatched`. */
2697
+ async updateMapping(id, data) {
2698
+ const res = await this.http.request({
492
2699
  method: "PATCH",
493
- path: `${this.basePath}/${channelId}`,
2700
+ path: `${this.basePath}/mappings/${id}`,
494
2701
  body: data
495
2702
  });
2703
+ return res.data;
496
2704
  }
497
- async delete(channelId) {
2705
+ /**
2706
+ * DELETE /admin/integrations/ortto/mappings/:id (204). A pull list becomes
2707
+ * editable again and keeps its members; a push tag is NOT removed from Ortto.
2708
+ */
2709
+ async deleteMapping(id) {
498
2710
  await this.http.request({
499
2711
  method: "DELETE",
500
- path: `${this.basePath}/${channelId}`
2712
+ path: `${this.basePath}/mappings/${id}`
501
2713
  });
502
2714
  }
503
- };
504
- var ContactResource = class extends BaseResource {
505
- constructor(http2) {
506
- super(http2, "/contacts");
507
- }
508
- async merge(winnerId, loserId) {
509
- return this.http.request({
2715
+ /**
2716
+ * POST /admin/integrations/ortto/sync (202) — queue a sync for one mapping or
2717
+ * the whole connection. Never calls Ortto in-request.
2718
+ */
2719
+ async sync(data = {}) {
2720
+ const res = await this.http.request({
510
2721
  method: "POST",
511
- path: `/contacts/${winnerId}/merge/${loserId}`
2722
+ path: `${this.basePath}/sync`,
2723
+ body: data
512
2724
  });
2725
+ return res.data;
513
2726
  }
514
- channels(contactId) {
515
- return new ContactChannelResource(this.http, contactId);
2727
+ /** GET /admin/integrations/ortto/sync-status — 404 when Ortto is not connected. */
2728
+ async syncStatus() {
2729
+ const res = await this.http.request({
2730
+ method: "GET",
2731
+ path: `${this.basePath}/sync-status`
2732
+ });
2733
+ return res.data;
516
2734
  }
517
2735
  };
518
2736
 
519
- // src/resources/activities.ts
520
- var ActivityResource = class {
2737
+ // src/resources/webhook-subscriptions.ts
2738
+ var WebhookSubscriptionsResource = class extends ApiResource {
521
2739
  constructor(http2) {
522
- this.http = http2;
2740
+ super(http2, "/admin/webhooks");
523
2741
  }
2742
+ /** POST /admin/webhooks — the returned `secret` is shown only this once. */
524
2743
  async create(data) {
525
- return this.http.request({
526
- method: "POST",
527
- path: "/activities",
528
- body: data
529
- });
2744
+ return this.http.request({ method: "POST", path: this.basePath, body: data });
530
2745
  }
2746
+ /** GET /admin/webhooks */
531
2747
  async list(params) {
532
2748
  return this.http.request({
533
2749
  method: "GET",
534
- path: "/activities",
2750
+ path: this.basePath,
535
2751
  params
536
2752
  });
537
2753
  }
538
- async listForEntity(entityType, entityId, params) {
2754
+ /** GET /admin/webhooks/:id */
2755
+ async get(id) {
2756
+ return this.http.request({ method: "GET", path: `${this.basePath}/${id}` });
2757
+ }
2758
+ /** PATCH /admin/webhooks/:id */
2759
+ async update(id, data) {
2760
+ return this.http.request({ method: "PATCH", path: `${this.basePath}/${id}`, body: data });
2761
+ }
2762
+ /** DELETE /admin/webhooks/:id */
2763
+ async delete(id) {
2764
+ return this.http.request({ method: "DELETE", path: `${this.basePath}/${id}` });
2765
+ }
2766
+ /** POST /admin/webhooks/:id/test — sends one signed test event to the URL now. */
2767
+ async test(id) {
2768
+ return this.http.request({ method: "POST", path: `${this.basePath}/${id}/test` });
2769
+ }
2770
+ /**
2771
+ * POST /admin/webhooks/:id/rotate-secret — replaces the signing secret and
2772
+ * returns the new one, shown only this once. New deliveries are signed with
2773
+ * it, but deliveries already queued (and their retries, for several minutes)
2774
+ * keep the old one. `verifyWebhookSignature` checks one secret, so for a few
2775
+ * minutes have your receiver try the new secret and fall back to the old one.
2776
+ */
2777
+ async rotateSecret(id) {
2778
+ return this.http.request({
2779
+ method: "POST",
2780
+ path: `${this.basePath}/${id}/rotate-secret`
2781
+ });
2782
+ }
2783
+ /** GET /admin/webhooks/:id/deliveries — newest first. */
2784
+ async listDeliveries(id, params) {
539
2785
  return this.http.request({
540
2786
  method: "GET",
541
- path: `/${entityType}/${entityId}/activities`,
2787
+ path: `${this.basePath}/${id}/deliveries`,
542
2788
  params
543
2789
  });
544
2790
  }
2791
+ /**
2792
+ * POST /admin/webhooks/:id/deliveries/:deliveryId/retry — queues a new
2793
+ * delivery of that event (202). The receiver sees the event again, so make
2794
+ * it idempotent on the event id.
2795
+ */
2796
+ async retryDelivery(id, deliveryId) {
2797
+ return this.http.request({
2798
+ method: "POST",
2799
+ path: `${this.basePath}/${id}/deliveries/${deliveryId}/retry`
2800
+ });
2801
+ }
545
2802
  };
546
2803
 
547
- // src/resources/tags.ts
548
- var TagResource = class extends BaseResource {
2804
+ // src/resources/users.ts
2805
+ var UsersResource = class extends ApiResource {
549
2806
  constructor(http2) {
550
- super(http2, "/tags");
551
- }
552
- /** `TagsService.setEntityTags()` returns the final tag set wrapped in `{ tags }`. */
553
- async setEntityTags(entityType, entityId, data) {
554
- return this.http.request({
555
- method: "PUT",
556
- path: `/entities/${entityType}/${entityId}/tags`,
557
- body: data
558
- });
2807
+ super(http2, "/users");
559
2808
  }
560
- async getEntityTags(entityType, entityId) {
2809
+ /** GET /users — paged, with email, role, status and org fields (read grant on users). */
2810
+ async list(params) {
561
2811
  return this.http.request({
562
2812
  method: "GET",
563
- path: `/entities/${entityType}/${entityId}/tags`
2813
+ path: this.basePath,
2814
+ params
564
2815
  });
565
2816
  }
566
- async getEntities(tagId, params) {
2817
+ /**
2818
+ * GET /users/directory — active users' ids, names and roles, for pickers and
2819
+ * for resolving an assignee. Every role can read it.
2820
+ */
2821
+ async directory(params) {
567
2822
  return this.http.request({
568
2823
  method: "GET",
569
- path: `/tags/${tagId}/entities`,
2824
+ path: `${this.basePath}/directory`,
570
2825
  params
571
2826
  });
572
2827
  }
2828
+ /**
2829
+ * GET /users/:id/working-hours — the user's own weekly hours and the tenant
2830
+ * default. A non-admin caller may read only their own (403 otherwise).
2831
+ */
2832
+ async getWorkingHours(id) {
2833
+ return this.http.request({ method: "GET", path: `${this.basePath}/${id}/working-hours` });
2834
+ }
2835
+ };
2836
+
2837
+ // src/resources/teams.ts
2838
+ var TeamsResource = class extends ApiResource {
2839
+ constructor(http2) {
2840
+ super(http2, "/teams");
2841
+ }
2842
+ /** GET /teams — every team, with `member_count`. */
2843
+ async list() {
2844
+ return this.http.request({ method: "GET", path: this.basePath });
2845
+ }
2846
+ /** GET /teams/:id — one team, with `members`. */
2847
+ async get(id) {
2848
+ return this.http.request({ method: "GET", path: `${this.basePath}/${id}` });
2849
+ }
573
2850
  };
574
2851
 
575
2852
  // src/webhooks.ts
576
2853
  import { createHmac, timingSafeEqual } from "crypto";
2854
+ var WEBHOOK_EVENT_TYPES = [
2855
+ "created",
2856
+ "updated",
2857
+ "deleted",
2858
+ "status_changed",
2859
+ "entity.tagged",
2860
+ "entity.untagged",
2861
+ "list.member_added",
2862
+ "list.member_removed",
2863
+ "entity.assigned",
2864
+ "entity.unassigned",
2865
+ "team.member_added",
2866
+ "team.member_removed",
2867
+ "task.created",
2868
+ "task.updated",
2869
+ "task.completed",
2870
+ "task.cancelled",
2871
+ "comment.created",
2872
+ "conversation.created",
2873
+ "conversation.matched",
2874
+ "conversation.deleted",
2875
+ "customer.merged",
2876
+ "workflow.instance_moved",
2877
+ "consent.changed",
2878
+ "billing_schedule.period_generated",
2879
+ "billing_schedule.period_needs_review",
2880
+ "billing_schedule.period_delivered",
2881
+ "billing_schedule.period_delivery_failed",
2882
+ "payment.on_void_invoice",
2883
+ "invoice.overdue",
2884
+ "integration_connection.deactivated",
2885
+ "customer_payment_method.invalidated",
2886
+ "invoice.autopay_succeeded",
2887
+ "invoice.autopay_failed",
2888
+ "received"
2889
+ ];
577
2890
  function verifyWebhookSignature(payload, signature, secret) {
578
2891
  if (!signature || !secret || !payload) {
579
2892
  return false;
@@ -743,12 +3056,192 @@ var PlanesClient = class {
743
3056
  }
744
3057
  return this._activities;
745
3058
  }
3059
+ get communications() {
3060
+ if (!this._communications) {
3061
+ this._communications = new CommunicationsResource(this.http);
3062
+ }
3063
+ return this._communications;
3064
+ }
3065
+ /** Logged meetings — manual + provider-synced, with company matching (E55). */
3066
+ get conversations() {
3067
+ if (!this._conversations) {
3068
+ this._conversations = new ConversationsResource(this.http);
3069
+ }
3070
+ return this._conversations;
3071
+ }
3072
+ get gmail() {
3073
+ if (!this._gmail) {
3074
+ this._gmail = new GmailResource(this.http);
3075
+ }
3076
+ return this._gmail;
3077
+ }
3078
+ get documents() {
3079
+ if (!this._documents) {
3080
+ this._documents = new DocumentsResource(this.http);
3081
+ }
3082
+ return this._documents;
3083
+ }
746
3084
  get tags() {
747
3085
  if (!this._tags) {
748
3086
  this._tags = new TagResource(this.http);
749
3087
  }
750
3088
  return this._tags;
751
3089
  }
3090
+ get lists() {
3091
+ if (!this._lists) {
3092
+ this._lists = new ListsResource(this.http);
3093
+ }
3094
+ return this._lists;
3095
+ }
3096
+ get leadSources() {
3097
+ if (!this._leadSources) {
3098
+ this._leadSources = new LeadSourcesResource(this.http);
3099
+ }
3100
+ return this._leadSources;
3101
+ }
3102
+ get tasks() {
3103
+ if (!this._tasks) {
3104
+ this._tasks = new TaskResource(this.http);
3105
+ }
3106
+ return this._tasks;
3107
+ }
3108
+ /** Record views — the "recently viewed" beacon + read (E41-F7). */
3109
+ get recordViews() {
3110
+ if (!this._recordViews) {
3111
+ this._recordViews = new RecordViewsResource(this.http);
3112
+ }
3113
+ return this._recordViews;
3114
+ }
3115
+ /** Module status — which modules are active for the caller's tenant (E51-F1-S1). */
3116
+ get modules() {
3117
+ if (!this._modules) {
3118
+ this._modules = new ModulesResource(this.http);
3119
+ }
3120
+ return this._modules;
3121
+ }
3122
+ /** The tenant's plan, billing status and plan ceiling — `plan.get()` (E54-F1-S2). */
3123
+ get plan() {
3124
+ if (!this._plan) {
3125
+ this._plan = new PlanResource(this.http);
3126
+ }
3127
+ return this._plan;
3128
+ }
3129
+ /** The authenticated caller — `me.abilities()` (E52-F1-S3). */
3130
+ get me() {
3131
+ if (!this._me) {
3132
+ this._me = new MeResource(this.http);
3133
+ }
3134
+ return this._me;
3135
+ }
3136
+ /** Settings → Roles, admin only — `roles.list/get/updateGrants/reset/history` (E52-F2-S5). */
3137
+ get roles() {
3138
+ if (!this._roles) {
3139
+ this._roles = new RolesResource(this.http);
3140
+ }
3141
+ return this._roles;
3142
+ }
3143
+ /** Invoice settings — `invoiceSettings.getOfflineInstructions/setOfflineInstructions` (E56-F5-S4). */
3144
+ get invoiceSettings() {
3145
+ if (!this._invoiceSettings) {
3146
+ this._invoiceSettings = new InvoiceSettingsResource(this.http);
3147
+ }
3148
+ return this._invoiceSettings;
3149
+ }
3150
+ /** Payment reminder settings, admin only — `invoiceReminders.list/update/preview` (E56-F8-S6). */
3151
+ get invoiceReminders() {
3152
+ if (!this._invoiceReminders) {
3153
+ this._invoiceReminders = new InvoiceRemindersResource(this.http);
3154
+ }
3155
+ return this._invoiceReminders;
3156
+ }
3157
+ /** Event automations, admin only — `eventAutomations.list/get/create/update/delete` (E60-S2). */
3158
+ get eventAutomations() {
3159
+ if (!this._eventAutomations) {
3160
+ this._eventAutomations = new EventAutomationsResource(this.http);
3161
+ }
3162
+ return this._eventAutomations;
3163
+ }
3164
+ /** Web forms and their submissions, admin only — `webForms.list/get/create/update/archive/rotateKey`, `webForms.submissions.list/get/update/route` (E60-S6). */
3165
+ get webForms() {
3166
+ if (!this._webForms) {
3167
+ this._webForms = new WebFormsResource(this.http);
3168
+ }
3169
+ return this._webForms;
3170
+ }
3171
+ /** Published sequences a contact can be enrolled in (E51-F2-S6). */
3172
+ get contactSequences() {
3173
+ if (!this._contactSequences) {
3174
+ this._contactSequences = new ContactSequencesResource(this.http);
3175
+ }
3176
+ return this._contactSequences;
3177
+ }
3178
+ /** Enroll a contact in a sequence, list its enrollments, exit one (E51-F2-S8). */
3179
+ get enrollments() {
3180
+ if (!this._enrollments) {
3181
+ this._enrollments = new EnrollmentsResource(this.http);
3182
+ }
3183
+ return this._enrollments;
3184
+ }
3185
+ /** Tenant-readable workflow reads — a workflow version's ordered stages. */
3186
+ get workflows() {
3187
+ if (!this._workflows) {
3188
+ this._workflows = new WorkflowsResource(this.http);
3189
+ }
3190
+ return this._workflows;
3191
+ }
3192
+ get serviceSchedules() {
3193
+ if (!this._serviceSchedules) {
3194
+ this._serviceSchedules = new ServiceSchedulesResource(this.http);
3195
+ }
3196
+ return this._serviceSchedules;
3197
+ }
3198
+ /**
3199
+ * Recurring billing schedules (E56-F3) — CRUD, pause/resume/end, preview,
3200
+ * the period ledger, Needs review, generate-now, skip and regenerate.
3201
+ */
3202
+ get billingSchedules() {
3203
+ if (!this._billingSchedules) {
3204
+ this._billingSchedules = new BillingScheduleResource(this.http);
3205
+ }
3206
+ return this._billingSchedules;
3207
+ }
3208
+ get customFields() {
3209
+ if (!this._customFields) {
3210
+ this._customFields = new CustomFieldsResource(this.http);
3211
+ }
3212
+ return this._customFields;
3213
+ }
3214
+ /** Ortto connector — list mappings, audiences, manual sync, sync status (E53). Admin-only. */
3215
+ get ortto() {
3216
+ if (!this._ortto) {
3217
+ this._ortto = new OrttoResource(this.http);
3218
+ }
3219
+ return this._ortto;
3220
+ }
3221
+ /**
3222
+ * Webhook subscriptions — where entity events are delivered (E64-S10). Admin
3223
+ * grants and the `open_api` feature. Not `webhooks`: that is the event router.
3224
+ */
3225
+ get webhookSubscriptions() {
3226
+ if (!this._webhookSubscriptions) {
3227
+ this._webhookSubscriptions = new WebhookSubscriptionsResource(this.http);
3228
+ }
3229
+ return this._webhookSubscriptions;
3230
+ }
3231
+ /** The tenant's users, read-only: list and directory (E64-S10). */
3232
+ get users() {
3233
+ if (!this._users) {
3234
+ this._users = new UsersResource(this.http);
3235
+ }
3236
+ return this._users;
3237
+ }
3238
+ /** Teams, read-only (E64-S10). */
3239
+ get teams() {
3240
+ if (!this._teams) {
3241
+ this._teams = new TeamsResource(this.http);
3242
+ }
3243
+ return this._teams;
3244
+ }
752
3245
  /**
753
3246
  * Ergonomic webhook event router — `client.webhooks.on(pattern, handler)`
754
3247
  * plus `client.webhooks.process({ body, signature, secret })`. Auth-independent
@@ -763,6 +3256,136 @@ var PlanesClient = class {
763
3256
  }
764
3257
  };
765
3258
 
3259
+ // src/types/billing-schedule-types.ts
3260
+ var BILLING_CADENCES = ["weekly", "every_n_weeks", "monthly", "quarterly", "annually"];
3261
+ var BILLING_SCHEDULE_STATUSES = ["active", "paused", "ended"];
3262
+ var BILL_TIMINGS = ["in_advance", "in_arrears"];
3263
+ var BILLING_DELIVERY_MODES = ["auto_send", "draft_for_review"];
3264
+ var BILLING_COLLECTION_MODES = ["send_link", "autopay"];
3265
+ var AUTOPAY_UNAVAILABLE_REASONS = ["no_connect", "no_saved_method"];
3266
+ var BILLING_AUTOPAY_STATUSES = [
3267
+ "not_applicable",
3268
+ "scheduled",
3269
+ "submitted",
3270
+ "succeeded",
3271
+ "failed",
3272
+ "auth_required",
3273
+ "retry_scheduled",
3274
+ "abandoned"
3275
+ ];
3276
+ var BILLING_BACKFILL_MODES = ["skip", "draft"];
3277
+ var BILLING_PERIOD_STATUSES = ["generated", "skipped", "needs_review", "failed", "voided"];
3278
+ var BILLING_PREVIEW_PERIOD_STATUSES = [...BILLING_PERIOD_STATUSES, "upcoming"];
3279
+ var BILLING_DELIVERY_STATUSES = ["pending", "sent", "failed", "not_applicable"];
3280
+ var BILLING_ADJUSTMENT_STATUSES = ["pending", "consumed", "cancelled"];
3281
+ var BILLING_ADJUSTMENT_TARGETS = ["next_invoice"];
3282
+
3283
+ // src/types/contact-types.ts
3284
+ var CONTACT_SORT_KEYS = ["name", "created_at", "recent", "updated_at"];
3285
+ var CONTACT_LIST_INCLUDES = ["channels", "links"];
3286
+
3287
+ // src/types/customer-types.ts
3288
+ var CUSTOMER_SORT_KEYS = ["created_at", "last_name", "first_name", "email", "phone", "source", "recent", "updated_at"];
3289
+
3290
+ // src/types/opportunity-types.ts
3291
+ var OPPORTUNITY_SORT_KEYS = ["created_at", "total", "title", "customer_name", "stage", "priority", "recent", "updated_at"];
3292
+ var OPPORTUNITY_STATES = ["open", "closed", "won", "lost"];
3293
+
3294
+ // src/types/job-types.ts
3295
+ var JOB_SORT_KEYS = ["created_at", "recent"];
3296
+
3297
+ // src/types/estimate-types.ts
3298
+ var ESTIMATE_STATUSES = ["draft", "sent", "approved", "rejected"];
3299
+
3300
+ // src/types/record-view-types.ts
3301
+ var RECORD_VIEW_ENTITY_TYPES = ["customer", "contact", "opportunity", "job"];
3302
+
3303
+ // src/types/module-types.ts
3304
+ var MODULE_KEYS = [
3305
+ "estimates",
3306
+ "contracts",
3307
+ "inventory",
3308
+ "production",
3309
+ "production_scheduling",
3310
+ "calendar",
3311
+ "service-schedules",
3312
+ "marketplace",
3313
+ "invoicing",
3314
+ "knocks",
3315
+ "accounting",
3316
+ "contacts",
3317
+ "tasks",
3318
+ "comments",
3319
+ "conversations",
3320
+ "web_forms"
3321
+ ];
3322
+
3323
+ // src/types/plan-types.ts
3324
+ var PLAN_KEYS = ["solo", "sales", "business", "operations", "legacy", "internal"];
3325
+ var BILLING_STATUSES = [
3326
+ "trialing",
3327
+ "active",
3328
+ "past_due",
3329
+ "unpaid",
3330
+ "paused",
3331
+ "canceled",
3332
+ "comped"
3333
+ ];
3334
+ var PLAN_SOURCES = ["stripe", "manual"];
3335
+ var BILLING_INTERVALS = ["month", "year"];
3336
+ var FEATURE_KEYS = [
3337
+ "calendar",
3338
+ "estimates",
3339
+ "contracts",
3340
+ "service_dispatch",
3341
+ "production_scheduling",
3342
+ "sub_management",
3343
+ "reports",
3344
+ "open_api",
3345
+ "workflow_builder",
3346
+ "integrations.quickbooks",
3347
+ "integrations.stripe",
3348
+ "integrations.hover",
3349
+ "integrations.ortto",
3350
+ "communications.marketing",
3351
+ "ai.scheduling",
3352
+ "ai.content_assist",
3353
+ "ai.documents",
3354
+ "ai.search",
3355
+ "inventory_management",
3356
+ "workflow_execution",
3357
+ "marketplace"
3358
+ ];
3359
+
3360
+ // src/types/me-types.ts
3361
+ var AGENT_ROLES = [
3362
+ "admin",
3363
+ "sales",
3364
+ "service",
3365
+ "production",
3366
+ "sub",
3367
+ "readonly",
3368
+ "system_agent"
3369
+ ];
3370
+
3371
+ // src/types/workflow-event-rule-types.ts
3372
+ var WORKFLOW_EVENT_RULE_EVENT_TYPES = [
3373
+ "contract.status_changed",
3374
+ "invoice.status_changed",
3375
+ "calendar_event.status_changed",
3376
+ /** "An event is booked": one-off events and recurring series masters. */
3377
+ "calendar_event.created"
3378
+ ];
3379
+ var WORKFLOW_EVENT_RULE_MATCH_ALL_EVENT_TYPES = [
3380
+ "calendar_event.created"
3381
+ ];
3382
+ var WORKFLOW_EVENT_RULE_CATCH_UP_EVENT_TYPES = [
3383
+ "calendar_event.created"
3384
+ ];
3385
+
3386
+ // src/types/task-types.ts
3387
+ var TASK_SORT_KEYS = ["due_at", "created_at", "updated_at"];
3388
+
766
3389
  // src/agent.ts
767
3390
  import * as http from "http";
768
3391
  function createActionServer(handlerMap, options) {
@@ -918,38 +3541,100 @@ function readBody(req) {
918
3541
  });
919
3542
  }
920
3543
  export {
3544
+ AGENT_ROLES,
3545
+ AUTOPAY_UNAVAILABLE_REASONS,
921
3546
  ActivityResource,
922
3547
  AgentApp,
3548
+ ApiResource,
923
3549
  AuthenticationError,
924
3550
  AuthorizationError,
3551
+ BILLING_ADJUSTMENT_STATUSES,
3552
+ BILLING_ADJUSTMENT_TARGETS,
3553
+ BILLING_AUTOPAY_STATUSES,
3554
+ BILLING_BACKFILL_MODES,
3555
+ BILLING_CADENCES,
3556
+ BILLING_COLLECTION_MODES,
3557
+ BILLING_DELIVERY_MODES,
3558
+ BILLING_DELIVERY_STATUSES,
3559
+ BILLING_INTERVALS,
3560
+ BILLING_PERIOD_STATUSES,
3561
+ BILLING_PREVIEW_PERIOD_STATUSES,
3562
+ BILLING_SCHEDULE_STATUSES,
3563
+ BILLING_STATUSES,
3564
+ BILL_TIMINGS,
925
3565
  BaseResource,
3566
+ BillingScheduleResource,
3567
+ CONTACT_LIST_INCLUDES,
3568
+ CONTACT_SORT_KEYS,
3569
+ CUSTOMER_SORT_KEYS,
926
3570
  CalendarEventResource,
3571
+ CommunicationsResource,
927
3572
  ContactChannelResource,
928
3573
  ContactResource,
3574
+ ContactSequencesResource,
929
3575
  ContractResource,
3576
+ ConversationsResource,
3577
+ CustomFieldsResource,
930
3578
  CustomerResource,
931
3579
  DEFAULT_BASE_URL,
932
3580
  DEFAULT_MAX_RETRIES,
933
3581
  DEFAULT_TIMEOUT,
934
3582
  DEFAULT_TOKEN_REFRESH_SKEW_MS,
3583
+ DocumentsResource,
3584
+ ESTIMATE_STATUSES,
3585
+ EnrollmentsResource,
935
3586
  EstimateResource,
3587
+ EventAutomationsResource,
3588
+ FEATURE_KEYS,
3589
+ GmailResource,
936
3590
  InventoryResource,
3591
+ InvoiceRemindersResource,
937
3592
  InvoiceResource,
3593
+ InvoiceSettingsResource,
3594
+ JOB_SORT_KEYS,
938
3595
  JobResource,
3596
+ LeadSourcesResource,
3597
+ ListsResource,
3598
+ MODULE_KEYS,
3599
+ MeResource,
939
3600
  MemoryTokenStorage,
3601
+ ModulesResource,
940
3602
  NotFoundError,
941
3603
  OAuthError,
3604
+ OPPORTUNITY_SORT_KEYS,
3605
+ OPPORTUNITY_STATES,
942
3606
  OpportunityResource,
3607
+ OrttoResource,
3608
+ PLAN_KEYS,
3609
+ PLAN_SOURCES,
3610
+ PlanResource,
943
3611
  Planes,
944
3612
  PlanesClient,
945
3613
  PlanesError,
946
3614
  PropertyResource,
3615
+ RECORD_VIEW_ENTITY_TYPES,
947
3616
  RateLimitError,
3617
+ RecordViewsResource,
3618
+ RolesResource,
948
3619
  ServerError,
3620
+ ServiceSchedulesResource,
3621
+ TASK_SORT_KEYS,
949
3622
  TagResource,
3623
+ TaskResource,
3624
+ TeamsResource,
3625
+ UsersResource,
950
3626
  ValidationError,
3627
+ WEBHOOK_EVENT_TYPES,
3628
+ WORKFLOW_EVENT_RULE_CATCH_UP_EVENT_TYPES,
3629
+ WORKFLOW_EVENT_RULE_EVENT_TYPES,
3630
+ WORKFLOW_EVENT_RULE_MATCH_ALL_EVENT_TYPES,
3631
+ WebFormSubmissionsResource,
3632
+ WebFormsResource,
951
3633
  WebhookRouter,
3634
+ WebhookSubscriptionsResource,
952
3635
  WebhookVerificationError,
3636
+ WorkflowEventRulesResource,
3637
+ WorkflowsResource,
953
3638
  buildAuthorizeUrl,
954
3639
  clientCredentialsGrant,
955
3640
  createAgentApp,