@awesomate/sdk 0.7.0 → 0.8.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 +14 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +8 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -146,6 +146,20 @@ and takes a fresh copy when it does. Up to 200 rows a list and 20 lists a connec
|
|
|
146
146
|
`{ onRows, onError }` to hear about a list the server refused (a column that does not exist).
|
|
147
147
|
Outside a browser, give it a WebSocket: `createAppClient({ publishableKey, WebSocket })`.
|
|
148
148
|
|
|
149
|
+
### Staff find a customer
|
|
150
|
+
|
|
151
|
+
People in an app read no contacts but their own, so by default staff cannot put a job under a
|
|
152
|
+
customer. Switch it on per app for the roles that need it (`awesomate_crm_apps`,
|
|
153
|
+
`customer_lookup`, never the role customers sign in with). Those roles can then search by name or
|
|
154
|
+
email and point a record at any customer:
|
|
155
|
+
|
|
156
|
+
```ts
|
|
157
|
+
const [jo] = await app.lookupCustomers({ q: 'jo' }); // or { ids: [...] }, up to 50
|
|
158
|
+
await app.write('job', { title: 'Gutters' }, { links: { customer: jo.id } });
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
Name, email and phone only, and nothing the owner marked sensitive. Anyone else is refused.
|
|
162
|
+
|
|
149
163
|
The rules are kept in your own database, which applies them to every read and write, so a mistake
|
|
150
164
|
in the app cannot show anyone more than their role allows. A disabled person is refused on their
|
|
151
165
|
next call. Sessions are kept in `localStorage`; in a Capacitor app pass `storage` (Preferences) and
|
package/dist/index.d.ts
CHANGED
|
@@ -370,6 +370,13 @@ export interface AppUser {
|
|
|
370
370
|
role: string;
|
|
371
371
|
contact_id: string | null;
|
|
372
372
|
}
|
|
373
|
+
/** A customer as lookupCustomers() returns them. A field the owner marked sensitive is null. */
|
|
374
|
+
export interface Customer {
|
|
375
|
+
id: string;
|
|
376
|
+
name: string | null;
|
|
377
|
+
email: string | null;
|
|
378
|
+
phone: string | null;
|
|
379
|
+
}
|
|
373
380
|
export interface AppClientOptions {
|
|
374
381
|
/** The app's publishable key (pk_...). Not a secret: it belongs in browser code. */
|
|
375
382
|
publishableKey: string;
|
|
@@ -485,6 +492,16 @@ export declare class AwesomateAppClient {
|
|
|
485
492
|
/** Create a record (returns its id) or change one with options.id, inside the kind's write rule for this user. */
|
|
486
493
|
write<K extends KindName>(kind: K, data: Partial<RowOf<K>> | Record<string, unknown>, options?: WriteOptions): Promise<string>;
|
|
487
494
|
archive<K extends KindName>(kind: K, id: string): Promise<void>;
|
|
495
|
+
/**
|
|
496
|
+
* Customers by name or email (two characters or more), or by id, so staff can find one and put
|
|
497
|
+
* a record under them. Only for a role the account lets look customers up in this app; anyone
|
|
498
|
+
* else gets a forbidden error. Name, email and phone only, at most 50.
|
|
499
|
+
*/
|
|
500
|
+
lookupCustomers(options: {
|
|
501
|
+
q?: string;
|
|
502
|
+
ids?: string[];
|
|
503
|
+
limit?: number;
|
|
504
|
+
}): Promise<Customer[]>;
|
|
488
505
|
/**
|
|
489
506
|
* A list kept current: onRows gets the whole list (up to 200 rows, the query's order) at first
|
|
490
507
|
* and again whenever a row in it is added, changed, removed, or stops being one this person may
|
package/dist/index.js
CHANGED
|
@@ -514,6 +514,14 @@ export class AwesomateAppClient {
|
|
|
514
514
|
async archive(kind, id) {
|
|
515
515
|
await this.data('POST', '/call', { fn: 'archive_record', args: { kind, id } });
|
|
516
516
|
}
|
|
517
|
+
/**
|
|
518
|
+
* Customers by name or email (two characters or more), or by id, so staff can find one and put
|
|
519
|
+
* a record under them. Only for a role the account lets look customers up in this app; anyone
|
|
520
|
+
* else gets a forbidden error. Name, email and phone only, at most 50.
|
|
521
|
+
*/
|
|
522
|
+
async lookupCustomers(options) {
|
|
523
|
+
return (await this.data('POST', '/customers/lookup', options)).customers;
|
|
524
|
+
}
|
|
517
525
|
/**
|
|
518
526
|
* A list kept current: onRows gets the whole list (up to 200 rows, the query's order) at first
|
|
519
527
|
* and again whenever a row in it is added, changed, removed, or stops being one this person may
|
package/package.json
CHANGED