@awesomate/sdk 0.11.0 → 0.12.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/README.md CHANGED
@@ -30,6 +30,18 @@ const one = await db.get('contact', rows[0].id); // null if there is none
30
30
  const byPlan = await db.aggregate({ measures: [{ column: 'people', agg: 'count' }], dimensions: ['plan'] });
31
31
  ```
32
32
 
33
+ ## The business itself
34
+
35
+ ```js
36
+ const biz = await db.business();
37
+ biz.name; // 'Acme Plumbing'
38
+ for (const g of biz.groups) for (const f of g.facts) console.log(g.title, f.label, f.value, f.status, f.source);
39
+ biz.completeness; // { core_set: 7, core_total: 8, missing_core: ['logo'] }
40
+ const waiting = await db.businessSuggestions(); // details waiting for the owner's yes
41
+ ```
42
+
43
+ The details Awesomate keeps about the business: name, what it does, voice, colours, how customers reach it. Each one says where it came from. `confirmed` details are the ones agents and automations use. A `suggestion` waits for the owner, who confirms it on Knowledge, Your business in the hub. This needs the account's token, on every plan, never an app key.
44
+
33
45
  ## Writing app data (Support Plus and above)
34
46
 
35
47
  Define the tables an app keeps, then write to them. There's no migration and no SQL; every value is
package/dist/index.d.ts CHANGED
@@ -224,6 +224,15 @@ export declare class AwesomateClient {
224
224
  * Never retried: a write that may have landed is not safe to send twice.
225
225
  */
226
226
  call<R extends RecipeName>(recipe: R, args?: ArgsOf<R>): Promise<RecipeResult>;
227
+ /**
228
+ * The business itself: the details Awesomate keeps about it (name, what it does, voice, colours,
229
+ * how customers reach it), grouped, each with where it came from. `confirmed` details are the
230
+ * ones agents and automations use; `suggestion` ones wait for the owner. Needs the account's
231
+ * token (hosting:read, every plan), never an app key.
232
+ */
233
+ business(): Promise<BusinessIdentity>;
234
+ /** Details waiting for the owner's yes on Your business: from the website, the account, a team member or a file. */
235
+ businessSuggestions(): Promise<BusinessSuggestion[]>;
227
236
  /** Grouped numbers (counts, sums) in the Business Data API's shape. */
228
237
  aggregate(request: {
229
238
  measures: Array<{
@@ -251,6 +260,43 @@ export declare class AwesomateClient {
251
260
  limit?: number;
252
261
  }): Promise<Record<string, unknown>>;
253
262
  }
263
+ /** One detail about the business. */
264
+ export interface BusinessFact {
265
+ key: string;
266
+ label: string;
267
+ value: string;
268
+ /** confirmed: in use by agents and automations. suggestion: waiting for the owner. */
269
+ status: 'confirmed' | 'suggestion';
270
+ /** Where it came from, in words: "confirmed by the owner", "added by a team member", "website research"... */
271
+ source: string;
272
+ }
273
+ export interface BusinessIdentity {
274
+ account: string;
275
+ name: string | null;
276
+ groups: Array<{
277
+ id: string;
278
+ title: string;
279
+ facts: BusinessFact[];
280
+ }>;
281
+ /** The eight core details every business should have, and which are missing. */
282
+ completeness: {
283
+ core_set: number;
284
+ core_total: number;
285
+ missing_core: string[];
286
+ };
287
+ /** Whether each source could be read: 'read', 'empty' or 'unavailable'. */
288
+ sources: Record<'confirmed_details' | 'saved_details' | 'account_details' | 'website_research', string>;
289
+ how_to_change: string;
290
+ }
291
+ export interface BusinessSuggestion {
292
+ id: number;
293
+ key: string;
294
+ value: string;
295
+ /** website, research, import, team_member, staff, upload, legacy_variables... */
296
+ sourceKind: string;
297
+ sourceRef: string | null;
298
+ recordedAt: string;
299
+ }
254
300
  export interface AttributeSpec {
255
301
  key: string;
256
302
  label?: string;
package/dist/index.js CHANGED
@@ -215,6 +215,19 @@ export class AwesomateClient {
215
215
  async call(recipe, args = {}) {
216
216
  return (await this.request('POST', '/api/my-crm/v1/call', { fn: recipe, args }, false)).result;
217
217
  }
218
+ /**
219
+ * The business itself: the details Awesomate keeps about it (name, what it does, voice, colours,
220
+ * how customers reach it), grouped, each with where it came from. `confirmed` details are the
221
+ * ones agents and automations use; `suggestion` ones wait for the owner. Needs the account's
222
+ * token (hosting:read, every plan), never an app key.
223
+ */
224
+ business() {
225
+ return this.request('GET', '/api/my-business/v1/identity?format=json');
226
+ }
227
+ /** Details waiting for the owner's yes on Your business: from the website, the account, a team member or a file. */
228
+ async businessSuggestions() {
229
+ return (await this.request('GET', '/api/my-business/v1/proposals')).proposals;
230
+ }
218
231
  /** Grouped numbers (counts, sums) in the Business Data API's shape. */
219
232
  aggregate(request) {
220
233
  return this.request('POST', '/api/my-crm/v1/data/query', request);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awesomate/sdk",
3
- "version": "0.11.0",
3
+ "version": "0.12.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",