@awesomate/sdk 0.63.0 → 0.65.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 +205 -10
- package/dist/index.js +54 -3
- package/package.json +1 -1
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.
|
|
29
|
+
export declare const VERSION = "0.65.0";
|
|
30
30
|
/** Augmented by the generated awesomate.d.ts, so each kind's rows are typed. */
|
|
31
31
|
export interface Kinds {
|
|
32
32
|
}
|
|
@@ -1111,16 +1111,13 @@ export declare class AwesomateClient {
|
|
|
1111
1111
|
* Null when there is none (an id that is not one never reaches the hub).
|
|
1112
1112
|
*/
|
|
1113
1113
|
get: (id: string) => Promise<EmailDetail | null>;
|
|
1114
|
-
/**
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1114
|
+
/**
|
|
1115
|
+
* A new draft to list `topic` (a key from `lists()`). `checks.blockers` must be empty before a
|
|
1116
|
+
* person can approve it. `send_at` proposes when it goes (see `EmailDraftInput`).
|
|
1117
|
+
*/
|
|
1118
|
+
draft: (input: EmailDraftInput) => Promise<EmailDraft>;
|
|
1119
1119
|
/** Replace a draft. Once someone approved it, it is refused: a person changes it in the hub. */
|
|
1120
|
-
update: (id: string, input:
|
|
1121
|
-
topic: string;
|
|
1122
|
-
doc: EmailDoc;
|
|
1123
|
-
}) => Promise<EmailDraft>;
|
|
1120
|
+
update: (id: string, input: EmailDraftInput) => Promise<EmailDraft>;
|
|
1124
1121
|
/**
|
|
1125
1122
|
* Throw a draft away. A draft only: an approved, sending or sent email throws `unavailable`
|
|
1126
1123
|
* (server code `not_a_draft`, the case in `reason`). Nothing is deleted: the draft is stopped
|
|
@@ -1640,6 +1637,52 @@ export declare class AwesomateClient {
|
|
|
1640
1637
|
* await db.archiveLink('vehicle', 'serviced_at');
|
|
1641
1638
|
*/
|
|
1642
1639
|
archiveLink(kind: string, key: string): Promise<KindDescription>;
|
|
1640
|
+
/**
|
|
1641
|
+
* Set this up for me: the hub's suggestion for one sentence about what the owner keeps track of
|
|
1642
|
+
* ("a job management system"), as a whole setup in the owner's words (fields, stages, lists,
|
|
1643
|
+
* links, small related things, the brief). Nothing is saved. Pass `kind` to ask about one of
|
|
1644
|
+
* their things: the suggestion then only adds to it, and `matched` says what it has already.
|
|
1645
|
+
* Edit it if you like, then checkSetup(). The account's token, crm:write, Support Plus and above,
|
|
1646
|
+
* with Set this up for me on the account; a few a person in ten minutes.
|
|
1647
|
+
*
|
|
1648
|
+
* @example
|
|
1649
|
+
* const proposal = await db.proposeSetup('property bookings');
|
|
1650
|
+
* console.log(proposal.sentence);
|
|
1651
|
+
*/
|
|
1652
|
+
proposeSetup(sentence: string, options?: {
|
|
1653
|
+
kind?: string;
|
|
1654
|
+
}): Promise<SetupProposal>;
|
|
1655
|
+
/**
|
|
1656
|
+
* Check a setup exactly as a click would, and read the sentence the owner should agree to before
|
|
1657
|
+
* applySetup(). Nothing is saved. On one of their things it is additions only, and answers
|
|
1658
|
+
* `base`, which applySetup() needs. A setup that does not fit throws `validation` naming the
|
|
1659
|
+
* item (`at`, like `fields.2`). The account's token, crm:write.
|
|
1660
|
+
*
|
|
1661
|
+
* @example
|
|
1662
|
+
* const proposal = await db.proposeSetup('a quote pipeline');
|
|
1663
|
+
* const check = await db.checkSetup(proposal.setup);
|
|
1664
|
+
* if (check.can_apply) console.log(check.sentence);
|
|
1665
|
+
*/
|
|
1666
|
+
checkSetup(setup: SetupSpec, options?: {
|
|
1667
|
+
replaceBrief?: boolean;
|
|
1668
|
+
}): Promise<SetupCheck>;
|
|
1669
|
+
/**
|
|
1670
|
+
* Set it up, all in one go or not at all: the thing, its fields, sections, stages, links, small
|
|
1671
|
+
* related things, lists and the brief. On one of their things it only adds (nothing is removed,
|
|
1672
|
+
* renamed or retyped) and needs `base` from checkSetup() (without it, `validation`, server code
|
|
1673
|
+
* `base_required`); if the thing changed since, it throws
|
|
1674
|
+
* `conflict` (server code `changed`): check again. Only an Owner's key may apply (anyone else's
|
|
1675
|
+
* throws `forbidden`, server code `owner_only`). Apply only what the owner agreed to.
|
|
1676
|
+
*
|
|
1677
|
+
* @example
|
|
1678
|
+
* const { setup } = await db.proposeSetup('property bookings');
|
|
1679
|
+
* const made = await db.applySetup(setup); // once the owner has agreed to checkSetup()'s sentence
|
|
1680
|
+
* console.log(made.kind.key, made.land);
|
|
1681
|
+
*/
|
|
1682
|
+
applySetup(setup: SetupSpec, options?: {
|
|
1683
|
+
base?: SetupBase;
|
|
1684
|
+
replaceBrief?: boolean;
|
|
1685
|
+
}): Promise<SetupApplied>;
|
|
1643
1686
|
/**
|
|
1644
1687
|
* Create a record (returns its id), or change one with options.id. Every value is checked
|
|
1645
1688
|
* against the kind. crm:write, Support Plus and above: the account's token, or an app key made
|
|
@@ -2666,6 +2709,132 @@ export interface LinkSpec {
|
|
|
2666
2709
|
/** Every record must set it. Only when added to a kind with no records yet; a link is never made required later. */
|
|
2667
2710
|
required?: boolean;
|
|
2668
2711
|
}
|
|
2712
|
+
/** A field in a setup, in the owner's words. */
|
|
2713
|
+
export interface SetupField {
|
|
2714
|
+
label: string;
|
|
2715
|
+
type: 'text' | 'long_text' | 'number' | 'money' | 'date' | 'datetime' | 'yes_no' | 'choice' | 'choices' | 'address' | 'phone' | 'email' | 'url';
|
|
2716
|
+
/** For choice and choices. */
|
|
2717
|
+
choices?: string[];
|
|
2718
|
+
required?: boolean;
|
|
2719
|
+
/** Whether AI may read it. Leave names, notes and contact details off unless the owner says so. */
|
|
2720
|
+
ai_may_read?: boolean;
|
|
2721
|
+
/** A section's label. */
|
|
2722
|
+
section?: string;
|
|
2723
|
+
}
|
|
2724
|
+
/**
|
|
2725
|
+
* A setup: what an owner keeps track of, in their own words, never keys. `thing` is a new thing
|
|
2726
|
+
* (`{label, label_plural?}`) or one of theirs to add to (`{kind}`). Limits: 6 sections, 15
|
|
2727
|
+
* fields, 2 to 8 stages, 4 links, 2 related things of up to 6 fields, 3 lists of up to 12
|
|
2728
|
+
* columns, a brief focus of up to 200 characters and 6 pins.
|
|
2729
|
+
*/
|
|
2730
|
+
export interface SetupSpec {
|
|
2731
|
+
thing: {
|
|
2732
|
+
label: string;
|
|
2733
|
+
label_plural?: string;
|
|
2734
|
+
} | {
|
|
2735
|
+
kind: string;
|
|
2736
|
+
};
|
|
2737
|
+
sections?: Array<{
|
|
2738
|
+
label: string;
|
|
2739
|
+
description?: string;
|
|
2740
|
+
}>;
|
|
2741
|
+
fields?: SetupField[];
|
|
2742
|
+
/** The stage field and its stages in order; `role` is a role on the business map, whose turn it is. */
|
|
2743
|
+
stages?: {
|
|
2744
|
+
field_label?: string;
|
|
2745
|
+
stages: Array<{
|
|
2746
|
+
name: string;
|
|
2747
|
+
colour?: 'grey' | 'blue' | 'green' | 'amber' | 'red' | 'purple';
|
|
2748
|
+
closed?: boolean;
|
|
2749
|
+
role?: string;
|
|
2750
|
+
}>;
|
|
2751
|
+
} | null;
|
|
2752
|
+
/** `to` is 'People', 'Companies' or one of the owner's things. */
|
|
2753
|
+
links?: Array<{
|
|
2754
|
+
to: string;
|
|
2755
|
+
label?: string;
|
|
2756
|
+
required?: boolean;
|
|
2757
|
+
}>;
|
|
2758
|
+
/** Small new things, each belonging to the main thing. */
|
|
2759
|
+
new_related?: Array<{
|
|
2760
|
+
label: string;
|
|
2761
|
+
label_plural?: string;
|
|
2762
|
+
fields?: SetupField[];
|
|
2763
|
+
link_label?: string;
|
|
2764
|
+
}>;
|
|
2765
|
+
lists?: Array<{
|
|
2766
|
+
name: string;
|
|
2767
|
+
display: 'table' | 'board' | 'calendar' | 'week' | 'timeline';
|
|
2768
|
+
group_by?: string;
|
|
2769
|
+
date_field?: string;
|
|
2770
|
+
columns?: string[];
|
|
2771
|
+
}>;
|
|
2772
|
+
/** What the summary at the top of each record leads with, and the fields pinned under it. */
|
|
2773
|
+
brief?: {
|
|
2774
|
+
focus?: string;
|
|
2775
|
+
pins?: string[];
|
|
2776
|
+
} | null;
|
|
2777
|
+
}
|
|
2778
|
+
/** What one of the owner's things has already, by the owner's labels. */
|
|
2779
|
+
export interface SetupMatched {
|
|
2780
|
+
fields: string[];
|
|
2781
|
+
links: string[];
|
|
2782
|
+
stages: string[];
|
|
2783
|
+
lists: string[];
|
|
2784
|
+
}
|
|
2785
|
+
/** The versions checkSetup() read a thing at; pass it to applySetup() as it came. */
|
|
2786
|
+
export type SetupBase = Record<string, unknown>;
|
|
2787
|
+
/** proposeSetup()'s answer. */
|
|
2788
|
+
export interface SetupProposal {
|
|
2789
|
+
setup: SetupSpec;
|
|
2790
|
+
/** What it would do, in plain words: show this to the owner. */
|
|
2791
|
+
sentence: string;
|
|
2792
|
+
/** How many suggested parts did not fit and were left out. */
|
|
2793
|
+
dropped: number;
|
|
2794
|
+
/** How many parts the thing has already (adding to one of theirs). */
|
|
2795
|
+
already: number;
|
|
2796
|
+
matched?: SetupMatched;
|
|
2797
|
+
notes?: string[];
|
|
2798
|
+
/** Set when the sentence named one of their things: the setup adds to it. */
|
|
2799
|
+
adds_to?: {
|
|
2800
|
+
key: string;
|
|
2801
|
+
label: string;
|
|
2802
|
+
label_plural: string;
|
|
2803
|
+
};
|
|
2804
|
+
}
|
|
2805
|
+
/** checkSetup()'s answer. */
|
|
2806
|
+
export interface SetupCheck {
|
|
2807
|
+
/** Exactly what applySetup() would do: the owner agrees to this. */
|
|
2808
|
+
sentence: string;
|
|
2809
|
+
setup: SetupSpec;
|
|
2810
|
+
/** Whether this key may apply it (an Owner's). */
|
|
2811
|
+
can_apply: boolean;
|
|
2812
|
+
makes: {
|
|
2813
|
+
key: string;
|
|
2814
|
+
related: string[];
|
|
2815
|
+
lists: number;
|
|
2816
|
+
stages: number;
|
|
2817
|
+
fields?: number;
|
|
2818
|
+
links?: number;
|
|
2819
|
+
};
|
|
2820
|
+
matched?: SetupMatched;
|
|
2821
|
+
notes?: string[];
|
|
2822
|
+
/** Adding to one of theirs: true when there is nothing to add. */
|
|
2823
|
+
nothing?: boolean;
|
|
2824
|
+
base?: SetupBase;
|
|
2825
|
+
}
|
|
2826
|
+
/** applySetup()'s answer: the thing set up, its related things, and the list to open first. */
|
|
2827
|
+
export interface SetupApplied {
|
|
2828
|
+
kind: {
|
|
2829
|
+
key: string;
|
|
2830
|
+
label_plural: string;
|
|
2831
|
+
};
|
|
2832
|
+
related: string[];
|
|
2833
|
+
land: {
|
|
2834
|
+
kind: string;
|
|
2835
|
+
list?: string;
|
|
2836
|
+
};
|
|
2837
|
+
}
|
|
2669
2838
|
/** A kind to define: a table an app keeps. */
|
|
2670
2839
|
export interface KindSpec {
|
|
2671
2840
|
key: string;
|
|
@@ -3465,6 +3634,19 @@ export interface EmailSeriesWrite {
|
|
|
3465
3634
|
pending?: true;
|
|
3466
3635
|
job_id?: string;
|
|
3467
3636
|
}
|
|
3637
|
+
/** What `emails.draft()` and `emails.update()` take. */
|
|
3638
|
+
export interface EmailDraftInput {
|
|
3639
|
+
/** The list's key, from `emails.lists()`. */
|
|
3640
|
+
topic: string;
|
|
3641
|
+
doc: EmailDoc;
|
|
3642
|
+
/**
|
|
3643
|
+
* A proposed time it goes: a date and time on the business's own clock (`'2026-10-21T09:00'`) or an
|
|
3644
|
+
* instant with its offset, a few minutes to 60 days ahead; `null` clears it. Only a proposal: the
|
|
3645
|
+
* person who approves it in the hub confirms or changes the time. Needs scheduled emails on the
|
|
3646
|
+
* account (`unavailable`, server code `feature_unavailable`, otherwise). A bad time saves nothing.
|
|
3647
|
+
*/
|
|
3648
|
+
send_at?: string | null;
|
|
3649
|
+
}
|
|
3468
3650
|
/** A draft, from `emails.draft()` or `emails.update()`. */
|
|
3469
3651
|
export interface EmailDraft {
|
|
3470
3652
|
id: string;
|
|
@@ -3483,6 +3665,13 @@ export interface EmailDraft {
|
|
|
3483
3665
|
reviewUrl: string;
|
|
3484
3666
|
/** What happens next, to tell the owner. */
|
|
3485
3667
|
next: string;
|
|
3668
|
+
/** The proposed time, when one was given and kept. */
|
|
3669
|
+
send_at?: string | null;
|
|
3670
|
+
send_tz?: string | null;
|
|
3671
|
+
/** "Wed 21 Oct, 9:00 am (Sydney time)". */
|
|
3672
|
+
send_when?: string | null;
|
|
3673
|
+
/** Set when the draft was saved but the time given with it was not: why, in a sentence to pass on. */
|
|
3674
|
+
send_at_refused?: string;
|
|
3486
3675
|
}
|
|
3487
3676
|
/** One email, from `emails.get()`. */
|
|
3488
3677
|
export interface EmailDetail {
|
|
@@ -3504,6 +3693,12 @@ export interface EmailDetail {
|
|
|
3504
3693
|
reviewUrl: string;
|
|
3505
3694
|
/** Opens, clicks, bounces and replies over time, once sent; null when it could not be read. */
|
|
3506
3695
|
timeline: unknown;
|
|
3696
|
+
/** When it goes: a draft's proposed time, or the approved one. Null to go when approved. */
|
|
3697
|
+
send_at?: string | null;
|
|
3698
|
+
/** The same time in words, in the zone it was chosen in. */
|
|
3699
|
+
send_when?: string | null;
|
|
3700
|
+
/** Approved and waiting for its time. */
|
|
3701
|
+
scheduled?: boolean;
|
|
3507
3702
|
}
|
|
3508
3703
|
/** `emails.discard()`: the draft is stopped and left out of the lists. */
|
|
3509
3704
|
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.
|
|
29
|
+
export const VERSION = '0.65.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;
|
|
@@ -130,7 +130,8 @@ function errorCode(status, server, body = {}) {
|
|
|
130
130
|
return 'rate_limited';
|
|
131
131
|
// stale: a form or webinar changed since it was read (update with version). not_draft: a webinar's
|
|
132
132
|
// registration is open, so it is fixed in Zoom. not_run: a recording goes only on a webinar that has run.
|
|
133
|
-
|
|
133
|
+
// changed: a thing a setup adds to changed since checkSetup().
|
|
134
|
+
if (server === 'conflict' || server === 'stale' || server === 'not_draft' || server === 'not_run' || server === 'changed')
|
|
134
135
|
return 'conflict';
|
|
135
136
|
if (status === 404 && server !== 'not_live')
|
|
136
137
|
return 'not_found';
|
|
@@ -800,7 +801,10 @@ export class AwesomateClient {
|
|
|
800
801
|
return null;
|
|
801
802
|
return nullIfMissing(this.request('GET', `/api/my-crm/v1/emails/${encodeURIComponent(String(id))}`));
|
|
802
803
|
},
|
|
803
|
-
/**
|
|
804
|
+
/**
|
|
805
|
+
* A new draft to list `topic` (a key from `lists()`). `checks.blockers` must be empty before a
|
|
806
|
+
* person can approve it. `send_at` proposes when it goes (see `EmailDraftInput`).
|
|
807
|
+
*/
|
|
804
808
|
draft: (input) => this.request('POST', '/api/my-crm/v1/emails', input, false),
|
|
805
809
|
/** Replace a draft. Once someone approved it, it is refused: a person changes it in the hub. */
|
|
806
810
|
update: async (id, input) => this.request('PATCH', `/api/my-crm/v1/emails/${emailId(id)}`, input, false),
|
|
@@ -1476,6 +1480,53 @@ export class AwesomateClient {
|
|
|
1476
1480
|
async archiveLink(kind, key) {
|
|
1477
1481
|
return (await this.request('DELETE', `/api/my-crm/v1/kinds/${encodeURIComponent(kind)}/links/${encodeURIComponent(key)}`, undefined, false)).kind;
|
|
1478
1482
|
}
|
|
1483
|
+
/**
|
|
1484
|
+
* Set this up for me: the hub's suggestion for one sentence about what the owner keeps track of
|
|
1485
|
+
* ("a job management system"), as a whole setup in the owner's words (fields, stages, lists,
|
|
1486
|
+
* links, small related things, the brief). Nothing is saved. Pass `kind` to ask about one of
|
|
1487
|
+
* their things: the suggestion then only adds to it, and `matched` says what it has already.
|
|
1488
|
+
* Edit it if you like, then checkSetup(). The account's token, crm:write, Support Plus and above,
|
|
1489
|
+
* with Set this up for me on the account; a few a person in ten minutes.
|
|
1490
|
+
*
|
|
1491
|
+
* @example
|
|
1492
|
+
* const proposal = await db.proposeSetup('property bookings');
|
|
1493
|
+
* console.log(proposal.sentence);
|
|
1494
|
+
*/
|
|
1495
|
+
async proposeSetup(sentence, options = {}) {
|
|
1496
|
+
return this.request('POST', '/api/my-crm/v1/setup/propose', { sentence, ...(options.kind ? { kind: options.kind } : {}) }, false);
|
|
1497
|
+
}
|
|
1498
|
+
/**
|
|
1499
|
+
* Check a setup exactly as a click would, and read the sentence the owner should agree to before
|
|
1500
|
+
* applySetup(). Nothing is saved. On one of their things it is additions only, and answers
|
|
1501
|
+
* `base`, which applySetup() needs. A setup that does not fit throws `validation` naming the
|
|
1502
|
+
* item (`at`, like `fields.2`). The account's token, crm:write.
|
|
1503
|
+
*
|
|
1504
|
+
* @example
|
|
1505
|
+
* const proposal = await db.proposeSetup('a quote pipeline');
|
|
1506
|
+
* const check = await db.checkSetup(proposal.setup);
|
|
1507
|
+
* if (check.can_apply) console.log(check.sentence);
|
|
1508
|
+
*/
|
|
1509
|
+
async checkSetup(setup, options = {}) {
|
|
1510
|
+
return this.request('POST', '/api/my-crm/v1/setup/check', { setup, ...(options.replaceBrief ? { replace_brief: true } : {}) }, false);
|
|
1511
|
+
}
|
|
1512
|
+
/**
|
|
1513
|
+
* Set it up, all in one go or not at all: the thing, its fields, sections, stages, links, small
|
|
1514
|
+
* related things, lists and the brief. On one of their things it only adds (nothing is removed,
|
|
1515
|
+
* renamed or retyped) and needs `base` from checkSetup() (without it, `validation`, server code
|
|
1516
|
+
* `base_required`); if the thing changed since, it throws
|
|
1517
|
+
* `conflict` (server code `changed`): check again. Only an Owner's key may apply (anyone else's
|
|
1518
|
+
* throws `forbidden`, server code `owner_only`). Apply only what the owner agreed to.
|
|
1519
|
+
*
|
|
1520
|
+
* @example
|
|
1521
|
+
* const { setup } = await db.proposeSetup('property bookings');
|
|
1522
|
+
* const made = await db.applySetup(setup); // once the owner has agreed to checkSetup()'s sentence
|
|
1523
|
+
* console.log(made.kind.key, made.land);
|
|
1524
|
+
*/
|
|
1525
|
+
async applySetup(setup, options = {}) {
|
|
1526
|
+
return this.request('POST', '/api/my-crm/v1/setup/apply', {
|
|
1527
|
+
setup, ...(options.base ? { base: options.base } : {}), ...(options.replaceBrief ? { replace_brief: true } : {}),
|
|
1528
|
+
}, false);
|
|
1529
|
+
}
|
|
1479
1530
|
/**
|
|
1480
1531
|
* Create a record (returns its id), or change one with options.id. Every value is checked
|
|
1481
1532
|
* against the kind. crm:write, Support Plus and above: the account's token, or an app key made
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@awesomate/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.65.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",
|