@awesomate/sdk 0.85.0 → 0.89.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.d.ts CHANGED
@@ -26,7 +26,7 @@
26
26
  * Docs: https://hub.awesomate.ai/docs/sdk/
27
27
  */
28
28
  /** This package's version, sent to the hub with every server call. */
29
- export declare const VERSION = "0.85.0";
29
+ export declare const VERSION = "0.89.0";
30
30
  /** Augmented by the generated awesomate.d.ts, so each kind's rows are typed. */
31
31
  export interface Kinds {
32
32
  }
@@ -1278,7 +1278,16 @@ export declare class AwesomateClient {
1278
1278
  get: (id: string) => Promise<EmailDetail | null>;
1279
1279
  /**
1280
1280
  * A new draft to list `topic` (a key from `lists()`). `checks.blockers` must be empty before a
1281
- * person can approve it. `send_at` proposes when it goes (see `EmailDraftInput`).
1281
+ * person can approve it. `send_at` proposes when it goes (see `EmailDraftInput`). With no `topic`,
1282
+ * a one-to-one email to the people you name (needs `email_direct`): a service email about their
1283
+ * job, booking, quote or account, optionally about one `record`; a person sends it in the hub.
1284
+ *
1285
+ * @example
1286
+ * const draft = await db.emails.draft({ people: { ids: ['the-contact-id'] }, record: 'the-job-id', doc: {
1287
+ * kind: 'transactional', voice: 'personal', subject: 'Your job on Tuesday', preheader: 'We arrive at 9',
1288
+ * blocks: [{ type: 'paragraph', text: 'Hi {{first_name|there}}, we are coming on Tuesday at 9 to fix the hot water.' }],
1289
+ * } });
1290
+ * console.log(draft.record, draft.reviewUrl);
1282
1291
  */
1283
1292
  draft: (input: EmailDraftInput) => Promise<EmailDraft>;
1284
1293
  /**
@@ -2156,6 +2165,23 @@ export declare class AwesomateClient {
2156
2165
  * withheld, never "none".
2157
2166
  */
2158
2167
  businessJourney(): Promise<BusinessJourney>;
2168
+ /**
2169
+ * One journey step's queue: its open records, oldest first, 50 a page, each with its stage, when it
2170
+ * entered, the business hours it has waited, whether it is late, the contacts it links to, the last
2171
+ * contact with any of them (channel and direction) and the open task raised because it ran late. A
2172
+ * record at one of the step's ways out (`exits`) is in no step. `step` is the step's position on the
2173
+ * path. Ids, stage names and times only. hosting:read and the agentic business feature
2174
+ * (`feature_unavailable` otherwise). Only the owner's own full account key gets the records; any
2175
+ * other key gets the step with `recordsShown` false, which means withheld, never empty.
2176
+ *
2177
+ * ```ts
2178
+ * const q = await db.businessJourneyQueue(2);
2179
+ * for (const r of q.records.filter((x) => x.late)) console.log(r.id, r.waitedHours);
2180
+ * ```
2181
+ */
2182
+ businessJourneyQueue(step: number, opts?: {
2183
+ page?: number;
2184
+ }): Promise<BusinessJourneyQueue>;
2159
2185
  /**
2160
2186
  * The business's KPIs: each a number with a target and someone responsible for it, with where it
2161
2187
  * sits, who answers for it, its light against the target for the last complete period, the period
@@ -2696,6 +2722,53 @@ export interface BusinessJourneyFields {
2696
2722
  slug: string;
2697
2723
  title: string;
2698
2724
  } | null;
2725
+ /** Ways out: other stages of the step's kind where a record leaves the journey (such as Lost), each with the reasons a move there must pick from. */
2726
+ exits: BusinessJourneyExit[];
2727
+ }
2728
+ /** A way out of a step: a stage where a record leaves the journey, and the reasons a move there picks from. */
2729
+ export interface BusinessJourneyExit {
2730
+ kind: string;
2731
+ stage: string;
2732
+ reasons: string[];
2733
+ }
2734
+ /** One open record in a step's queue. */
2735
+ export interface BusinessJourneyQueueRecord {
2736
+ id: string;
2737
+ kind: string;
2738
+ stage: string | null;
2739
+ /** ISO time it entered the step's current stage (its creation for a step from creation); null: since unknown. */
2740
+ enteredAt: string | null;
2741
+ /** Business hours it has waited; null when since unknown. */
2742
+ waitedHours: number | null;
2743
+ late: boolean;
2744
+ /** Ids of the contacts it links to. */
2745
+ people: string[];
2746
+ /** The last contact with any of them, or null. */
2747
+ lastContact: {
2748
+ at: string;
2749
+ channel: 'email' | 'call' | 'chat';
2750
+ direction: 'in' | 'out';
2751
+ } | null;
2752
+ /** The open task raised because it ran late, if any. */
2753
+ roleTaskId: number | null;
2754
+ }
2755
+ /** A step's queue, as businessJourneyQueue() returns it. */
2756
+ export interface BusinessJourneyQueue {
2757
+ asOf: string;
2758
+ step: {
2759
+ position: number;
2760
+ label: string;
2761
+ kind: string | null;
2762
+ slaHours: number | null;
2763
+ };
2764
+ /** False when this key is not given the records: records is empty and total null, which never means "none". */
2765
+ recordsShown: boolean;
2766
+ /** Every open record in the step, not just this page; null when withheld. */
2767
+ total: number | null;
2768
+ page: number;
2769
+ records: BusinessJourneyQueueRecord[];
2770
+ /** The next page, or null when this is the last. */
2771
+ nextPage: number | null;
2699
2772
  }
2700
2773
  /** Records in a step, or handed over between two: counts, times and the late ones' ids. */
2701
2774
  export interface BusinessJourneyCounts {
@@ -4404,6 +4477,20 @@ export interface ContactUpsertResult {
4404
4477
  tags_added: number;
4405
4478
  /** The history item this write made, when the account keeps history. */
4406
4479
  event_id?: string | null;
4480
+ /** What the tags did to lists that fill from a tag; there only when a tag was added. */
4481
+ lists?: TagListEffect;
4482
+ }
4483
+ /**
4484
+ * What a tag change did to the business's lists that fill from a tag, as list keys. Empty when the
4485
+ * account has no such list.
4486
+ */
4487
+ export interface TagListEffect {
4488
+ /** On the list now. */
4489
+ joined: string[];
4490
+ /** Held for later by the list's daily limit. */
4491
+ waiting: string[];
4492
+ /** Taking the tag off ended a place the tag gave them: no longer a customer, which is not an unsubscribe. */
4493
+ left: string[];
4407
4494
  }
4408
4495
  /** What contacts.addTags() and contacts.removeTags() did. */
4409
4496
  export interface ContactTagsResult {
@@ -4412,6 +4499,8 @@ export interface ContactTagsResult {
4412
4499
  added: number;
4413
4500
  /** Tags taken off them. */
4414
4501
  removed: number;
4502
+ /** What the change did to lists that fill from a tag; there only when a tag was added or taken off. */
4503
+ lists?: TagListEffect;
4415
4504
  }
4416
4505
  /** One link pointing at a row, from related(). */
4417
4506
  export interface RelatedRows {
@@ -4954,8 +5043,13 @@ export interface EmailSeriesWrite {
4954
5043
  }
4955
5044
  /** What `emails.draft()` and `emails.update()` take. */
4956
5045
  export interface EmailDraftInput {
4957
- /** The list's key, from `emails.lists()`. */
4958
- topic: string;
5046
+ /**
5047
+ * The list's key, from `emails.lists()`. Left out for a one-to-one email (needs `email_direct` on
5048
+ * the account): a service email (`doc.kind: 'transactional'`) to the people in `people` (by id, at
5049
+ * most 10), about their job, booking, quote or account. It can't carry an offer; a person sends it in
5050
+ * the hub.
5051
+ */
5052
+ topic?: string;
4959
5053
  doc: EmailDoc;
4960
5054
  /**
4961
5055
  * A proposed time it goes: a date and time on the business's own clock (`'2026-10-21T09:00'`) or an
@@ -4979,6 +5073,12 @@ export interface EmailDraftInput {
4979
5073
  } | {
4980
5074
  where: Record<string, unknown>;
4981
5075
  } | null;
5076
+ /**
5077
+ * A one-to-one email only: the id of the record it is about (their job, booking or quote), one linked
5078
+ * to someone it is to; `null` clears it. One that isn't, or that you can't read, is refused and nothing
5079
+ * is saved.
5080
+ */
5081
+ record?: string | null;
4982
5082
  }
4983
5083
  /** Who a picked-people email reaches, as a model may see it. */
4984
5084
  export interface EmailReach {
@@ -5009,6 +5109,11 @@ export interface EmailReach {
5009
5109
  email: string | null;
5010
5110
  reason: string | null;
5011
5111
  }>;
5112
+ /**
5113
+ * On a list email, when picked people aren't on its list and could have a one-to-one email instead
5114
+ * (`email_direct`, 10 or fewer picked): a sentence saying so. Ask the person before switching.
5115
+ */
5116
+ hint?: string;
5012
5117
  }
5013
5118
  /** From `emails.recipients()`. */
5014
5119
  export interface EmailRecipients extends Partial<EmailReach> {
@@ -5088,6 +5193,8 @@ export interface EmailDraft {
5088
5193
  reach?: EmailReach;
5089
5194
  /** Set when the draft was saved with picked people but who it reaches could not be read: ask `recipients()`. */
5090
5195
  reach_refused?: string;
5196
+ /** The record a one-to-one email is about, when `record` was given with it. */
5197
+ record?: string | null;
5091
5198
  }
5092
5199
  /** One email, from `emails.get()`. */
5093
5200
  export interface EmailDetail {
@@ -5115,6 +5222,10 @@ export interface EmailDetail {
5115
5222
  send_when?: string | null;
5116
5223
  /** Approved and waiting for its time. */
5117
5224
  scheduled?: boolean;
5225
+ /** A one-to-one email (people with no list), where the account has `email_direct`. */
5226
+ shape?: 'direct';
5227
+ /** A one-to-one email's record (the id of the job, booking or quote it is about), or null. */
5228
+ record?: string | null;
5118
5229
  }
5119
5230
  /** `emails.discard()`: the draft is stopped and left out of the lists. */
5120
5231
  export interface EmailDiscarded {
package/dist/index.js CHANGED
@@ -26,7 +26,7 @@
26
26
  * Docs: https://hub.awesomate.ai/docs/sdk/
27
27
  */
28
28
  /** This package's version, sent to the hub with every server call. */
29
- export const VERSION = '0.85.0';
29
+ export const VERSION = '0.89.0';
30
30
  const DEFAULT_BASE = 'https://hub.awesomate.ai';
31
31
  /** The one check for a platform `watch_url` (mirrored in the hub's awesomate-knowledge.ts and its MCP). */
32
32
  const WATCH_URL = /^https:\/\/[^\s"'<>]+$/i;
@@ -986,7 +986,16 @@ export class AwesomateClient {
986
986
  },
987
987
  /**
988
988
  * A new draft to list `topic` (a key from `lists()`). `checks.blockers` must be empty before a
989
- * person can approve it. `send_at` proposes when it goes (see `EmailDraftInput`).
989
+ * person can approve it. `send_at` proposes when it goes (see `EmailDraftInput`). With no `topic`,
990
+ * a one-to-one email to the people you name (needs `email_direct`): a service email about their
991
+ * job, booking, quote or account, optionally about one `record`; a person sends it in the hub.
992
+ *
993
+ * @example
994
+ * const draft = await db.emails.draft({ people: { ids: ['the-contact-id'] }, record: 'the-job-id', doc: {
995
+ * kind: 'transactional', voice: 'personal', subject: 'Your job on Tuesday', preheader: 'We arrive at 9',
996
+ * blocks: [{ type: 'paragraph', text: 'Hi {{first_name|there}}, we are coming on Tuesday at 9 to fix the hot water.' }],
997
+ * } });
998
+ * console.log(draft.record, draft.reviewUrl);
990
999
  */
991
1000
  draft: (input) => this.request('POST', '/api/my-crm/v1/emails', withPeople(input, 'draft'), false),
992
1001
  /**
@@ -2146,6 +2155,24 @@ export class AwesomateClient {
2146
2155
  async businessJourney() {
2147
2156
  return (await this.request('GET', '/api/my-business/v2/map/journey')).journey;
2148
2157
  }
2158
+ /**
2159
+ * One journey step's queue: its open records, oldest first, 50 a page, each with its stage, when it
2160
+ * entered, the business hours it has waited, whether it is late, the contacts it links to, the last
2161
+ * contact with any of them (channel and direction) and the open task raised because it ran late. A
2162
+ * record at one of the step's ways out (`exits`) is in no step. `step` is the step's position on the
2163
+ * path. Ids, stage names and times only. hosting:read and the agentic business feature
2164
+ * (`feature_unavailable` otherwise). Only the owner's own full account key gets the records; any
2165
+ * other key gets the step with `recordsShown` false, which means withheld, never empty.
2166
+ *
2167
+ * ```ts
2168
+ * const q = await db.businessJourneyQueue(2);
2169
+ * for (const r of q.records.filter((x) => x.late)) console.log(r.id, r.waitedHours);
2170
+ * ```
2171
+ */
2172
+ async businessJourneyQueue(step, opts = {}) {
2173
+ const q = opts.page ? `?page=${encodeURIComponent(String(opts.page))}` : '';
2174
+ return (await this.request('GET', `/api/my-business/v2/map/journey/steps/${encodeURIComponent(String(step))}/queue${q}`)).queue;
2175
+ }
2149
2176
  /**
2150
2177
  * The business's KPIs: each a number with a target and someone responsible for it, with where it
2151
2178
  * sits, who answers for it, its light against the target for the last complete period, the period
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awesomate/sdk",
3
- "version": "0.85.0",
3
+ "version": "0.89.0",
4
4
  "description": "Your own Awesomate data from Node and the browser: query contacts and app data with generated types, and sign your app's own users in",
5
5
  "license": "MIT",
6
6
  "type": "module",