@composable-os/sdk 0.1.0-beta.10 → 0.1.0-beta.13
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/acknowledge.d.ts +38 -0
- package/dist/acknowledge.js +30 -0
- package/dist/agreements.d.ts +80 -0
- package/dist/agreements.js +109 -0
- package/dist/allowance.d.ts +47 -5
- package/dist/allowance.js +59 -4
- package/dist/automation-check.d.ts +6 -1
- package/dist/automation-check.js +93 -8
- package/dist/automation.d.ts +62 -4
- package/dist/automation.js +32 -9
- package/dist/behaviour.js +25 -6
- package/dist/calendar-entry.d.ts +97 -0
- package/dist/calendar-entry.js +180 -0
- package/dist/capacity.d.ts +69 -0
- package/dist/capacity.js +63 -2
- package/dist/checklists.d.ts +41 -0
- package/dist/checklists.js +75 -0
- package/dist/contract.d.ts +527 -26
- package/dist/contract.js +21 -3
- package/dist/discount.d.ts +135 -0
- package/dist/discount.js +281 -0
- package/dist/document.d.ts +2 -1
- package/dist/document.js +2 -1
- package/dist/field-types.d.ts +1 -1
- package/dist/field-types.js +5 -0
- package/dist/formula/compile.d.ts +15 -0
- package/dist/formula/compile.js +9 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +17 -0
- package/dist/intake.d.ts +134 -0
- package/dist/intake.js +239 -0
- package/dist/journey-signals.d.ts +89 -0
- package/dist/journey-signals.js +151 -0
- package/dist/manifest.d.ts +1060 -60
- package/dist/manifest.js +1111 -61
- package/dist/mine.d.ts +45 -0
- package/dist/mine.js +119 -0
- package/dist/occupies.d.ts +64 -0
- package/dist/occupies.js +122 -0
- package/dist/questions.d.ts +179 -0
- package/dist/questions.js +514 -0
- package/dist/recurring.d.ts +33 -4
- package/dist/recurring.js +50 -3
- package/dist/restricted-fields.d.ts +15 -0
- package/dist/restricted-fields.js +97 -0
- package/dist/rich-text.d.ts +22 -0
- package/dist/rich-text.js +91 -0
- package/dist/routine-mail.d.ts +400 -0
- package/dist/routine-mail.js +955 -0
- package/dist/runtime.d.ts +5 -11
- package/dist/runtime.js +21 -11
- package/dist/screens.d.ts +3 -0
- package/dist/screens.js +74 -0
- package/dist/sellable.d.ts +231 -2
- package/dist/sellable.js +342 -1
- package/dist/slug.d.ts +2 -0
- package/dist/slug.js +6 -2
- package/dist/staffed.d.ts +178 -0
- package/dist/staffed.js +287 -0
- package/dist/states.d.ts +74 -4
- package/dist/states.js +154 -58
- package/dist/stock.d.ts +129 -0
- package/dist/stock.js +205 -0
- package/dist/team.d.ts +28 -0
- package/dist/team.js +52 -0
- package/dist/testing.d.ts +22 -1
- package/dist/testing.js +47 -5
- package/dist/worked-on.d.ts +42 -0
- package/dist/worked-on.js +79 -0
- package/package.json +9 -1
- package/src/acknowledge.ts +100 -0
- package/src/agreements.ts +185 -0
- package/src/allowance.ts +98 -8
- package/src/automation-check.ts +120 -9
- package/src/automation.ts +78 -10
- package/src/behaviour.ts +26 -6
- package/src/calendar-entry.ts +258 -0
- package/src/capacity.ts +103 -2
- package/src/checklists.ts +118 -0
- package/src/contract.ts +514 -27
- package/src/discount.ts +408 -0
- package/src/document.ts +4 -2
- package/src/field-types.ts +5 -0
- package/src/formula/compile.ts +10 -0
- package/src/index.ts +17 -0
- package/src/intake.ts +380 -0
- package/src/journey-signals.ts +215 -0
- package/src/manifest.ts +1313 -66
- package/src/mine.ts +161 -0
- package/src/occupies.ts +192 -0
- package/src/questions.ts +681 -0
- package/src/recurring.ts +90 -9
- package/src/restricted-fields.ts +129 -0
- package/src/rich-text.ts +112 -0
- package/src/routine-mail.ts +1272 -0
- package/src/runtime.ts +25 -12
- package/src/screens.ts +91 -0
- package/src/sellable.ts +595 -1
- package/src/slug.ts +7 -2
- package/src/staffed.ts +474 -0
- package/src/states.ts +220 -64
- package/src/stock.ts +332 -0
- package/src/team.ts +83 -0
- package/src/testing.ts +70 -6
- package/src/worked-on.ts +134 -0
package/src/contract.ts
CHANGED
|
@@ -2,15 +2,29 @@
|
|
|
2
2
|
// `defineExtension({...})`. Everything here is plain data plus tool/automation handlers, so the host
|
|
3
3
|
// can turn it into a JSON manifest, validate it, diff it and reconcile it to tables.
|
|
4
4
|
import type { z } from "zod";
|
|
5
|
+
import type { AcknowledgeSpec } from "./acknowledge.ts";
|
|
6
|
+
import type { AgreementsSpec, HealthNotesSpec } from "./agreements.ts";
|
|
5
7
|
import type { AllowanceSpec } from "./allowance.ts";
|
|
6
8
|
import type { AutomationSpec } from "./automation.ts";
|
|
9
|
+
import type { CalendarEntrySpec } from "./calendar-entry.ts";
|
|
7
10
|
import type { CapacitySpec, ClaimsSpec } from "./capacity.ts";
|
|
11
|
+
import type { ChecklistsSpec } from "./checklists.ts";
|
|
12
|
+
import type { DiscountSpec } from "./discount.ts";
|
|
8
13
|
import type { DocumentPathSpec, DocumentSchema } from "./document.ts";
|
|
9
14
|
import type { FieldTypeName } from "./field-types.ts";
|
|
15
|
+
import type { IntakeSpec } from "./intake.ts";
|
|
16
|
+
import type { JourneySignalSpec } from "./journey-signals.ts";
|
|
17
|
+
import type { MineSpec } from "./mine.ts";
|
|
18
|
+
import type { OccupiesSpec } from "./occupies.ts";
|
|
10
19
|
import type { RecurringScheduleSpec } from "./recurring.ts";
|
|
20
|
+
import type { RoutineMailModule, RoutineMailSpec } from "./routine-mail.ts";
|
|
11
21
|
import type { SellableSpec } from "./sellable.ts";
|
|
22
|
+
import type { StaffedSpec } from "./staffed.ts";
|
|
12
23
|
import type { StatesSpec } from "./states.ts";
|
|
24
|
+
import type { StockMovesSpec, StockSpec } from "./stock.ts";
|
|
25
|
+
import type { TeamSpec } from "./team.ts";
|
|
13
26
|
import type { UniqueSpec } from "./unique.ts";
|
|
27
|
+
import type { WorkedOnSpec } from "./worked-on.ts";
|
|
14
28
|
|
|
15
29
|
/** The contract version this SDK writes. The host accepts this and the previous version. */
|
|
16
30
|
export const CONTRACT_VERSION = 1;
|
|
@@ -39,7 +53,15 @@ export const GATEKEEPER_MODULES = [
|
|
|
39
53
|
export type GatekeeperModuleName = (typeof GATEKEEPER_MODULES)[number];
|
|
40
54
|
|
|
41
55
|
/** Host modules an extension can ask for (ADR 0025). There is no HTTP module. */
|
|
42
|
-
export const HOST_MODULES = [
|
|
56
|
+
export const HOST_MODULES = [
|
|
57
|
+
"ops",
|
|
58
|
+
"storage",
|
|
59
|
+
"log",
|
|
60
|
+
"ai",
|
|
61
|
+
// Routine mail (ADR 0590): a shipped pack's declared emails, in its automations only.
|
|
62
|
+
"routine-mail",
|
|
63
|
+
...GATEKEEPER_MODULES,
|
|
64
|
+
] as const;
|
|
43
65
|
export type HostModuleName = (typeof HOST_MODULES)[number];
|
|
44
66
|
|
|
45
67
|
/** Risk classes an extension tool may declare (schema and extension risks are host-only). */
|
|
@@ -166,6 +188,14 @@ export type FieldSpec =
|
|
|
166
188
|
type: "richText";
|
|
167
189
|
maxBytes?: number;
|
|
168
190
|
})
|
|
191
|
+
| (Omit<FieldBase, "default" | "defaultSetting"> & {
|
|
192
|
+
/**
|
|
193
|
+
* A checklist (stage 45 step 4b, ADR 0650): one of the business's checklist templates
|
|
194
|
+
* (Settings → Checklists), by id; only an active one may be picked. Named by an object's
|
|
195
|
+
* `checklists.template`, it gives each record a run of it to tick off.
|
|
196
|
+
*/
|
|
197
|
+
type: "checklist";
|
|
198
|
+
})
|
|
169
199
|
| (Omit<FieldBase, "default" | "defaultSetting"> & {
|
|
170
200
|
/**
|
|
171
201
|
* A record's address (stage 28, ADR 0442): lowercase letters and digits in words joined
|
|
@@ -246,11 +276,30 @@ export interface ObjectSpec {
|
|
|
246
276
|
capacity?: CapacitySpec;
|
|
247
277
|
/** Something that can be bought, and what a paid line grants (see SellableSpec, ADR 0435). */
|
|
248
278
|
sellable?: SellableSpec;
|
|
279
|
+
/** Things counted on a shelf, sold from a ledger the host keeps (see StockSpec, ADR 0680). */
|
|
280
|
+
stock?: StockSpec;
|
|
281
|
+
/** A record's state moves stock: received adds, a write-off removes, a count sets (see StockMovesSpec, ADR 0681). */
|
|
282
|
+
stockMoves?: StockMovesSpec;
|
|
249
283
|
/**
|
|
250
284
|
* Uses a record holds (a pass, a membership), or a record that spends one (a booking): see
|
|
251
285
|
* AllowanceSpec, ADRs 0493 and 0494. The host counts and refuses a spend past the limit.
|
|
252
286
|
*/
|
|
253
287
|
allowance?: AllowanceSpec;
|
|
288
|
+
/**
|
|
289
|
+
* Records that are discounts (see DiscountSpec, ADR 0693): a code or a member's price, worked out
|
|
290
|
+
* by the host when it prices an order, one deal per order, limits kept by the database.
|
|
291
|
+
*/
|
|
292
|
+
discount?: DiscountSpec;
|
|
293
|
+
/**
|
|
294
|
+
* An agreement point (see AgreementsSpec, ADR 0641): where a business may need a person to have
|
|
295
|
+
* agreed to its documents first. The business attaches the documents; the pack names the place.
|
|
296
|
+
*/
|
|
297
|
+
agreements?: AgreementsSpec;
|
|
298
|
+
/**
|
|
299
|
+
* A health-note list (see HealthNotesSpec, ADR 0643): this object's records make a list staff
|
|
300
|
+
* read (a class's bookings), on which the host may mark a yes on someone's health form.
|
|
301
|
+
*/
|
|
302
|
+
healthNotes?: HealthNotesSpec;
|
|
254
303
|
/** A fixed state machine (see StatesSpec, ADR 0425). An object has stages or states, not both. */
|
|
255
304
|
states?: StatesSpec;
|
|
256
305
|
/**
|
|
@@ -268,6 +317,48 @@ export interface ObjectSpec {
|
|
|
268
317
|
* ADR 0500): a timetable's series and its classes.
|
|
269
318
|
*/
|
|
270
319
|
recurring?: RecurringScheduleSpec;
|
|
320
|
+
/**
|
|
321
|
+
* A shift (see StaffedSpec, ADR 0621): who works the record, when, and on what kind of work.
|
|
322
|
+
* The host refuses, in the database, one account on two overlapping shifts, and answers each
|
|
323
|
+
* write with its warnings (away, not qualified, no one on it).
|
|
324
|
+
*/
|
|
325
|
+
staffed?: StaffedSpec;
|
|
326
|
+
/**
|
|
327
|
+
* Time can be recorded against the record (see WorkedOnSpec, ADR 0850): a job. Its time is the
|
|
328
|
+
* staff's time entries against it, read through the host; it keeps no hours of its own.
|
|
329
|
+
*/
|
|
330
|
+
workedOn?: WorkedOnSpec;
|
|
331
|
+
/**
|
|
332
|
+
* Who on the staff looks after the Person a record is about (see TeamSpec, ADR 0831): the
|
|
333
|
+
* accounts in its user fields while it is live. A pack role's `looksAfter` reaches records
|
|
334
|
+
* only for those People (ADR 0889). Only shipped extensions and an org's own may declare it.
|
|
335
|
+
*/
|
|
336
|
+
team?: TeamSpec;
|
|
337
|
+
/**
|
|
338
|
+
* A claim on a thing (see OccupiesSpec, ADR 0765): while live, the record takes the room (or
|
|
339
|
+
* chair, or hall) it names for its time. The host refuses, in the database, a second live
|
|
340
|
+
* record on the same thing at an overlapping time, whatever object it is.
|
|
341
|
+
*/
|
|
342
|
+
occupies?: OccupiesSpec;
|
|
343
|
+
/**
|
|
344
|
+
* Events in the customer's private calendar feed (see CalendarEntrySpec, ADR 0891): the record's
|
|
345
|
+
* start, end, public title and place as paths the customer may read, and the states in which it
|
|
346
|
+
* shows. The host reads them as the customer, through the visibility seam, and shows a live
|
|
347
|
+
* dependant's to their guardian. Only shipped extensions may declare it.
|
|
348
|
+
*/
|
|
349
|
+
calendarEntry?: CalendarEntrySpec;
|
|
350
|
+
/**
|
|
351
|
+
* The public-write door (see IntakeSpec, ADR 0720): a form the public answers, the submission
|
|
352
|
+
* the host makes from the answers, or another pack's record a form may also make. Only the
|
|
353
|
+
* host's `intake.submit` creates a submission; nothing else opens a write to the public.
|
|
354
|
+
*/
|
|
355
|
+
intake?: IntakeSpec;
|
|
356
|
+
/**
|
|
357
|
+
* A checklist the record's person ticks off (see ChecklistsSpec, ADR 0650): a run of the
|
|
358
|
+
* template its `template` field names, made by the host, ticked by the person (or by someone who
|
|
359
|
+
* rosters, for them), never changed once done, read only by the person and those who roster.
|
|
360
|
+
*/
|
|
361
|
+
checklists?: ChecklistsSpec;
|
|
271
362
|
/**
|
|
272
363
|
* The record's owner: a `user` field of this object (ADR 0246, stage 14). Assignment rules set
|
|
273
364
|
* it when a record is created without one, and stage 14's visibility policies read it.
|
|
@@ -286,9 +377,9 @@ export interface ObjectSpec {
|
|
|
286
377
|
* What the public may read of this object (ADR 0438): the fields in `read`, of the records that
|
|
287
378
|
* meet `when`. Deny by default: left out, the public sees nothing of it, and a record that does
|
|
288
379
|
* not meet `when` is not found. A signed-in customer reads it too, unless the object declares a
|
|
289
|
-
* `customer` (an object declares one or the other
|
|
290
|
-
*
|
|
291
|
-
* declare it.
|
|
380
|
+
* `customer` (an object declares one or the other, except a publishable object with an author:
|
|
381
|
+
* see `publishable`). The public reaches it only through a pack's tool open to them
|
|
382
|
+
* (`public.list`, `public.get`). Only shipped extensions and an org's own may declare it.
|
|
292
383
|
*/
|
|
293
384
|
public?: PublicSpec;
|
|
294
385
|
/**
|
|
@@ -326,6 +417,14 @@ export interface ObjectSpec {
|
|
|
326
417
|
* publish permission, never an AI actor); `record.versions` and `record.version` read them;
|
|
327
418
|
* `record.restoreVersion` copies one back into the working copy. Editing the working copy
|
|
328
419
|
* never changes a version. Records get read-only `publishedVersion` and `publishedAt`.
|
|
420
|
+
*
|
|
421
|
+
* With an author (ADR 0810): a publishable object may declare a `customer`, the record's author
|
|
422
|
+
* (a review's writer). The author reads and writes their working copy through `customer`; the
|
|
423
|
+
* public reads only the published version through `public` (which may then be declared too),
|
|
424
|
+
* listed by `content.list` and never by an address (no `slug`). The fields in `customer.write`
|
|
425
|
+
* are the author's alone: staff, the assistant, MCP clients, automations and the extension's own
|
|
426
|
+
* code are refused them on every path, so a published version is always the author's words.
|
|
427
|
+
* Staff still publish, unpublish and move the record's states.
|
|
329
428
|
*/
|
|
330
429
|
publishable?: PublishableSpec;
|
|
331
430
|
/** Position in the sidebar among extension objects (lower first). Default 100. */
|
|
@@ -360,7 +459,8 @@ export type StageType = (typeof STAGE_TYPES)[number];
|
|
|
360
459
|
* operations, so it applies to every actor: people, MCP clients, Code Mode, extensions.
|
|
361
460
|
*
|
|
362
461
|
* - Entering a stage needs the stage's required fields and `requiredByType[type]` to have values;
|
|
363
|
-
* otherwise the write is refused with a structured error naming the missing fields.
|
|
462
|
+
* otherwise the write is refused with a structured error naming the missing fields. A read-only
|
|
463
|
+
* field may be required: a fact the host sets, which no caller can supply (ADR 0750).
|
|
364
464
|
* - `group` must match the stage's group; a record given only a group starts in its first stage.
|
|
365
465
|
* - `probability.field` follows the stage's default probability unless it was set by hand
|
|
366
466
|
* (`probability.overridden` is then true; clearing that flag resets it).
|
|
@@ -558,6 +658,11 @@ export interface ExtensionContext {
|
|
|
558
658
|
ai: AiModule;
|
|
559
659
|
/** A gatekeeper declared in permissions.modules, e.g. `ctx.gatekeeper("email-send")`. */
|
|
560
660
|
gatekeeper(name: GatekeeperModuleName): GatekeeperModule;
|
|
661
|
+
/**
|
|
662
|
+
* Sends a routine email this extension declares (ADR 0590): in an automation of a shipped
|
|
663
|
+
* extension only. Declare the "routine-mail" module.
|
|
664
|
+
*/
|
|
665
|
+
routineMail: RoutineMailModule;
|
|
561
666
|
/** Who started this tool, from the host (ADR 0436). Absent in automations. */
|
|
562
667
|
caller?: StartedBy;
|
|
563
668
|
}
|
|
@@ -579,7 +684,8 @@ export interface ToolSpec<In extends z.ZodType = z.ZodType, Out extends z.ZodTyp
|
|
|
579
684
|
*/
|
|
580
685
|
recordAction?: RecordActionSpec;
|
|
581
686
|
/**
|
|
582
|
-
* Who may call the tool: a non-empty subset of `staff`, `customer`, `public
|
|
687
|
+
* Who may call the tool: a non-empty subset of `staff`, `customer`, `public`, or `device` alone
|
|
688
|
+
* (an enrolled device whose device role holds the tool's `permission`, ADR 0781). Left out, staff
|
|
583
689
|
* only. A tool open to `customer` or `public` must have risk `read` or `write`. Called by a
|
|
584
690
|
* customer, the tool runs as that customer: `ctx.ops` reaches only their own records, through
|
|
585
691
|
* `my.list`, `my.get`, `my.create` and `my.update`. Only shipped extensions and an org's own
|
|
@@ -597,9 +703,14 @@ export interface ToolSpec<In extends z.ZodType = z.ZodType, Out extends z.ZodTyp
|
|
|
597
703
|
* a role of this extension to hold (`roles`, ADR 0436). Admins and members hold it as they hold
|
|
598
704
|
* any tool (a viewer only when the tool's risk is `read`); a staff account given one of this
|
|
599
705
|
* extension's roles holds it only when the role lists it. Only shipped extensions and an org's
|
|
600
|
-
* own may declare it.
|
|
706
|
+
* own may declare it. A tool open to `device` names the permission a device role holds
|
|
707
|
+
* (`deviceRoles`, ADR 0781), and no staff role, grant or restriction names it.
|
|
708
|
+
*
|
|
709
|
+
* Or a list: any one of them opens the tool (ADR 0600). Bookings' day view is the coach's and
|
|
710
|
+
* the desk's (`["bookings:coach", "bookings:desk"]`): a coach reaches it through the role, held
|
|
711
|
+
* to the role's limits, and a coach granted the desk's permission reaches it through the grant.
|
|
601
712
|
*/
|
|
602
|
-
permission?: string;
|
|
713
|
+
permission?: string | readonly string[];
|
|
603
714
|
/**
|
|
604
715
|
* Only a person may call it (ADR 0512): the assistant, an MCP client, an automation and other
|
|
605
716
|
* extensions' code are refused by the host, as a core operation with `actors: ["human"]` is.
|
|
@@ -608,6 +719,49 @@ export interface ToolSpec<In extends z.ZodType = z.ZodType, Out extends z.ZodTyp
|
|
|
608
719
|
* any extension may declare it.
|
|
609
720
|
*/
|
|
610
721
|
humanOnly?: boolean;
|
|
722
|
+
/**
|
|
723
|
+
* A person approves it (ADR 0552): a person on the staff calls it as any tool, and anyone else's
|
|
724
|
+
* call (the assistant, an MCP client, an automation) always waits in the approval queue for a
|
|
725
|
+
* person, whatever the approval policy or preset says, and runs when a person approves it. For
|
|
726
|
+
* what an AI may propose but a person decides (cancelling a class). Staff only, and not a read.
|
|
727
|
+
*/
|
|
728
|
+
personApproves?: boolean;
|
|
729
|
+
/**
|
|
730
|
+
* A tool naming both a permission one of this extension's roles holds and a grantable one
|
|
731
|
+
* (ADR 0600) says so on purpose: an account given the grant calls it without the role's limits
|
|
732
|
+
* (Bookings' `day`, the desk's any day). Without it, such a tool is refused by the check, so a
|
|
733
|
+
* grantable permission added to a role's own tool never lifts the role's limits by accident.
|
|
734
|
+
*/
|
|
735
|
+
grantLiftsRoleLimits?: boolean;
|
|
736
|
+
/**
|
|
737
|
+
* Every staff account may call it, pack roles included (ADR 0652): a cleaner's `rostering.team`,
|
|
738
|
+
* a coach, the door, as well as admins and members. For a tool whose host operation decides
|
|
739
|
+
* who may do what by a rule of its own (Daily checklists' `today` and `tick`: the checklist's
|
|
740
|
+
* own "who may do it"), so no role or grant has to name it. A person's own act (`humanOnly`),
|
|
741
|
+
* for staff only, with no `permission` or `corePermission`. Only shipped extensions and an
|
|
742
|
+
* org's own may declare it.
|
|
743
|
+
*/
|
|
744
|
+
anyStaff?: boolean;
|
|
745
|
+
/**
|
|
746
|
+
* A core permission a staff caller needs instead of `records:read` or `records:write` (ADR
|
|
747
|
+
* 0652): one an admin may grant one by one (`checklists:write`). Admins and those granted it
|
|
748
|
+
* call the tool; nobody else does, and no pack role reaches it (a pack role holds no core
|
|
749
|
+
* permission). For staff only, with no `permission`. Only shipped extensions and an org's own
|
|
750
|
+
* may declare it.
|
|
751
|
+
*/
|
|
752
|
+
corePermission?: string;
|
|
753
|
+
/**
|
|
754
|
+
* Fields of the input the audit log never keeps (ADR 0626): a note about someone's leave. The
|
|
755
|
+
* call is still audited, with those fields shown as redacted. It only hides more, so any
|
|
756
|
+
* extension may declare it.
|
|
757
|
+
*/
|
|
758
|
+
redact?: readonly string[];
|
|
759
|
+
/**
|
|
760
|
+
* Keys of the tool's answer the host never keeps (ADR 0628): a secret shown once, such as a
|
|
761
|
+
* calendar feed's address. Never in the audit log, an approval's stored result or a stored
|
|
762
|
+
* reply an HTTP retry replays. It only hides more, so any extension may declare it.
|
|
763
|
+
*/
|
|
764
|
+
redactResult?: readonly string[];
|
|
611
765
|
handler(input: z.output<In>, ctx: ExtensionContext): Promise<z.input<Out>> | z.input<Out>;
|
|
612
766
|
}
|
|
613
767
|
|
|
@@ -627,39 +781,114 @@ export interface RoleSpec {
|
|
|
627
781
|
permissions: readonly string[];
|
|
628
782
|
/** Objects of this extension (`<id>.<object>`) whose records the role may read. */
|
|
629
783
|
read: readonly string[];
|
|
784
|
+
/**
|
|
785
|
+
* Objects whose records the role reaches only when a datetime on them falls on the
|
|
786
|
+
* day it is on (ADR 0553), by object: the moment, and optionally its end and zone, read through
|
|
787
|
+
* one relation at most: `{ "bookings.class": { at: "startsAt", until: "endsAt", zone:
|
|
788
|
+
* "timezone" } }`. A record is today's when its start falls on today's date in its zone (the
|
|
789
|
+
* organisation's when empty), or it has started and not yet ended. The host holds it on every
|
|
790
|
+
* call the account makes and every call of a tool run it started. Other staff are not limited.
|
|
791
|
+
*/
|
|
792
|
+
today?: Readonly<Record<string, string | { at: string; until?: string; zone?: string }>>;
|
|
793
|
+
/**
|
|
794
|
+
* Objects whose records the role reaches only for the People its holder looks after (ADR
|
|
795
|
+
* 0889), by object: its relation (one record) to `person`. Its holder looks after a Person
|
|
796
|
+
* when a live record of one of this extension's objects that declares a `team` names them in
|
|
797
|
+
* its staff fields (a client's assignment naming the coach). The host holds it on every call
|
|
798
|
+
* the account makes and every call of a tool run it started: a list holds only those People's
|
|
799
|
+
* records, a read or a change of another's is not found, a new record must be about one of
|
|
800
|
+
* them, and any other operation naming the object is refused. Other staff are not limited.
|
|
801
|
+
*/
|
|
802
|
+
looksAfter?: Readonly<Record<string, string>>;
|
|
803
|
+
/**
|
|
804
|
+
* Objects whose records the role reaches only through a live record of this extension naming
|
|
805
|
+
* its holder (ADR 0755), by object: that record's object (`through`), its user field naming the
|
|
806
|
+
* holder (`who`), the relations from it to the object reached (`path`), the states in which it
|
|
807
|
+
* counts (`live`) and a window around its datetimes (`within`). Jobs' crew reaches the jobs on
|
|
808
|
+
* which it has a crew place, from a week before the visit to a week after. The host holds it on
|
|
809
|
+
* every call the account makes and every call of a tool run it started: a list holds only those
|
|
810
|
+
* records, a read or a change of another is not found, and so is a write naming another in a
|
|
811
|
+
* relation, a new record is refused, a change to a field that decides the reach is refused, and
|
|
812
|
+
* so is any other operation. Every field deciding it is `personApproves`. Other staff are not
|
|
813
|
+
* limited.
|
|
814
|
+
*/
|
|
815
|
+
mine?: Readonly<Record<string, MineSpec>>;
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
/**
|
|
819
|
+
* A device role an extension declares (ADR 0781): what an enrolled device given it may do, with
|
|
820
|
+
* no person signed in. A human admin enrols a device for the role (`device.enrol { use: "role",
|
|
821
|
+
* role: "<id>.<name>" }`); its credential then calls exactly the tools whose permission the role
|
|
822
|
+
* lists (each open to `device` only) and `device.heartbeat`, and nothing else. It reads no
|
|
823
|
+
* record: its tools return only what their outputs declare. Bookings' check-in tablet:
|
|
824
|
+
* `{ permissions: ["bookings:checkin"], screen: { block: "bookings-checkin-tablet", export:
|
|
825
|
+
* "CheckInTablet" } }`. Only a shipped pack may declare one: a runtime extension's fails `cos ext
|
|
826
|
+
* check` and install, and is ignored at run time.
|
|
827
|
+
*/
|
|
828
|
+
export interface DeviceRoleSpec {
|
|
829
|
+
label: string;
|
|
830
|
+
/** What the device is for, shown to the admin who enrols it. */
|
|
831
|
+
description: string;
|
|
832
|
+
/** Permissions of this extension's device tools (`<id>:<word>`) the role holds. */
|
|
833
|
+
permissions: readonly string[];
|
|
834
|
+
/** The device's screen: a web block of this pack and the component it exports. */
|
|
835
|
+
screen: { block: string; export: string };
|
|
630
836
|
}
|
|
631
837
|
|
|
632
838
|
/**
|
|
633
839
|
* Who started a tool (ADR 0436), set by the host from the session it verified and never from the
|
|
634
|
-
* input: a staff user, a signed-in customer
|
|
635
|
-
*
|
|
636
|
-
*
|
|
840
|
+
* input: a staff user, a signed-in customer, the public, or an enrolled device holding one of
|
|
841
|
+
* this extension's device roles (ADR 0781: the device's id and the name an admin gave it, "Front
|
|
842
|
+
* door tablet"). A tool's own operation calls run as the extension (or as the customer, ADR
|
|
843
|
+
* 0414); this is for recording who asked, such as who checked a ticket in, or that a booking was
|
|
844
|
+
* ticked at the door. Absent in automations and in a manifest evaluation.
|
|
637
845
|
*/
|
|
638
846
|
export type StartedBy =
|
|
639
847
|
| { readonly kind: "staff"; readonly userId: string; readonly name: string }
|
|
640
848
|
| { readonly kind: "customer" }
|
|
641
|
-
| { readonly kind: "public" }
|
|
849
|
+
| { readonly kind: "public" }
|
|
850
|
+
| { readonly kind: "device"; readonly deviceId: string; readonly name: string };
|
|
642
851
|
|
|
643
|
-
/**
|
|
644
|
-
|
|
852
|
+
/**
|
|
853
|
+
* Who may call a tool. `staff` when nothing is declared (ADR 0402). `device` (ADR 0781): an
|
|
854
|
+
* enrolled device whose device role holds the tool's permission, on the desk origin only; a tool
|
|
855
|
+
* open to `device` is open to nobody else.
|
|
856
|
+
*/
|
|
857
|
+
export const TOOL_AUDIENCES = ["staff", "customer", "public", "device"] as const;
|
|
645
858
|
export type ToolAudience = (typeof TOOL_AUDIENCES)[number];
|
|
646
859
|
|
|
647
860
|
/**
|
|
648
|
-
*
|
|
649
|
-
* field) of the record itself, or, with `via`, of the record one of its relations points
|
|
650
|
-
*
|
|
861
|
+
* One condition of a `public` or `signedIn` declaration's `when` (ADRs 0438 and 0689): a state (a
|
|
862
|
+
* select field) of the record itself, or, with `via`, of the record one of its relations points
|
|
863
|
+
* to; or, `via` alone (in `public` only), that the record it points to is one the public reads
|
|
864
|
+
* (published, if its object is publishable, and meeting its own `when`): a variant while its item
|
|
865
|
+
* is published.
|
|
866
|
+
*/
|
|
867
|
+
export type PublicCondition =
|
|
868
|
+
| {
|
|
869
|
+
/** A relation of this object, to another object of this extension: test that record. */
|
|
870
|
+
via?: string;
|
|
871
|
+
/** A select field (of this record, or of the one `via` points to). */
|
|
872
|
+
field: string;
|
|
873
|
+
/** The values for which the record is public. */
|
|
874
|
+
in: readonly string[];
|
|
875
|
+
}
|
|
876
|
+
| {
|
|
877
|
+
/** A relation of this object, to another object of this extension that declares `public`. */
|
|
878
|
+
via: string;
|
|
879
|
+
field?: undefined;
|
|
880
|
+
in?: undefined;
|
|
881
|
+
};
|
|
882
|
+
|
|
883
|
+
/**
|
|
884
|
+
* What the public may read of an object (ADR 0438). `when` is a condition, or a list of up to
|
|
885
|
+
* three that must all hold (ADR 0689): an event while it is `on_sale`; a ticket type while its
|
|
886
|
+
* event is; a variant while it is `active` and its item is published.
|
|
651
887
|
*/
|
|
652
888
|
export interface PublicSpec {
|
|
653
889
|
read: readonly string[];
|
|
654
890
|
/** Left out, every live record is public (a catalogue item). */
|
|
655
|
-
when?:
|
|
656
|
-
/** A relation of this object, to another object of this extension: test that record. */
|
|
657
|
-
via?: string;
|
|
658
|
-
/** A select field (of this record, or of the one `via` points to). */
|
|
659
|
-
field: string;
|
|
660
|
-
/** The values for which the record is public. */
|
|
661
|
-
in: readonly string[];
|
|
662
|
-
};
|
|
891
|
+
when?: PublicCondition | readonly PublicCondition[];
|
|
663
892
|
}
|
|
664
893
|
|
|
665
894
|
/**
|
|
@@ -732,7 +961,9 @@ export interface PublishableSpec {
|
|
|
732
961
|
/**
|
|
733
962
|
* The record's address (stage 28, ADR 0442): a `slug` field of the object's own, not in
|
|
734
963
|
* `content`. The public reads a record by it (`content.get`); a published record whose slug
|
|
735
|
-
* changes keeps the old one as a redirect.
|
|
964
|
+
* changes keeps the old one as a redirect. Left out on an object the public reads, its records
|
|
965
|
+
* are listed only (`content.list`) and `content.get` finds none (ADR 0810). An object with an
|
|
966
|
+
* author (a `customer`) has none.
|
|
736
967
|
*/
|
|
737
968
|
slug?: string;
|
|
738
969
|
/**
|
|
@@ -741,6 +972,33 @@ export interface PublishableSpec {
|
|
|
741
972
|
* Set, it is kept: an imported post keeps its date.
|
|
742
973
|
*/
|
|
743
974
|
date?: string;
|
|
975
|
+
/**
|
|
976
|
+
* The states in which the record may be published (ADR 0810): values of the object's `states`
|
|
977
|
+
* field. A publish (or a scheduled one coming due) of a record in any other state is refused,
|
|
978
|
+
* and a record that moves out of them is unpublished in the same batch. A review without its
|
|
979
|
+
* author's consent is never published. Left out, any state.
|
|
980
|
+
*/
|
|
981
|
+
publishIn?: readonly string[];
|
|
982
|
+
/**
|
|
983
|
+
* Read and understood (stage 38, ADR 0702): the staff who must read a record confirm its
|
|
984
|
+
* current version with one tap, and a person publishing a later version says whether it asks
|
|
985
|
+
* them again (`readAgain`) or is a small fix. `who` names a `document` field of the object's
|
|
986
|
+
* own, outside `content`, with the schema `MUST_READ_SCHEMA`. `manage` names a permission of
|
|
987
|
+
* this extension's tools that is restricted and grantable: who holds it, and admins, read who
|
|
988
|
+
* has confirmed and change who must read a published record. Not on an object the public or a
|
|
989
|
+
* customer reads. `managed`, `owner` and `notices` (ADR 0706): more fields guarded as who
|
|
990
|
+
* must read is, the user field told weekly who has not confirmed, and the pack's words for the
|
|
991
|
+
* notices the host sends (`AcknowledgeSpec` in `acknowledge.ts`).
|
|
992
|
+
*/
|
|
993
|
+
acknowledge?: AcknowledgeSpec;
|
|
994
|
+
/**
|
|
995
|
+
* Staff read (stage 38, ADR 0701): every staff account reads the current published version,
|
|
996
|
+
* never the working copy, through `content.staffGet`, `content.staffList` and `content.search`,
|
|
997
|
+
* pack-role accounts (a coach, a cleaner, the door) included, which read nothing else outside
|
|
998
|
+
* their own pack. What they read is the `content` fields and the slug. Editors still edit the
|
|
999
|
+
* working copy on the record's page.
|
|
1000
|
+
*/
|
|
1001
|
+
staffRead?: boolean;
|
|
744
1002
|
}
|
|
745
1003
|
|
|
746
1004
|
/** An object's customer: see `ObjectSpec.customer`. */
|
|
@@ -760,6 +1018,21 @@ export interface CustomerSpec {
|
|
|
760
1018
|
* any tool.
|
|
761
1019
|
*/
|
|
762
1020
|
createOnly?: readonly string[];
|
|
1021
|
+
/**
|
|
1022
|
+
* Whether a customer may put one of their own records in the Trash, through a pack tool's
|
|
1023
|
+
* `my.delete` (ADR 0414, amended 2026-11-24): a logged set ticked by mistake. Left out, they
|
|
1024
|
+
* cannot. A reviewed change, as `customer` is.
|
|
1025
|
+
*/
|
|
1026
|
+
delete?: boolean;
|
|
1027
|
+
/**
|
|
1028
|
+
* The family link (ADR 0540): a signed-in guardian also reads their live dependants' records of
|
|
1029
|
+
* this object (a child's bookings), with the same `read` fields. With `write: true` they also
|
|
1030
|
+
* make records for a dependant (`my.create`'s `forPersonId`) and change the dependant's, with
|
|
1031
|
+
* the same `write` fields. `madeBy` names a relation to one person the host sets, on every
|
|
1032
|
+
* record a customer makes, to the Person who made it. Staff link guardians to dependants; the
|
|
1033
|
+
* seam checks the link in every read and write. A reviewed change, as `customer` is.
|
|
1034
|
+
*/
|
|
1035
|
+
guardians?: { write?: boolean; madeBy?: string };
|
|
763
1036
|
}
|
|
764
1037
|
|
|
765
1038
|
/** A tool shown as a button on a record page. */
|
|
@@ -859,13 +1132,227 @@ export interface ExtensionSpec {
|
|
|
859
1132
|
automations?: Record<string, AutomationSpec<any>>;
|
|
860
1133
|
/** Fixed staff roles an admin can give to a staff account (ADR 0436). */
|
|
861
1134
|
roles?: Record<string, RoleSpec>;
|
|
1135
|
+
/**
|
|
1136
|
+
* Device roles an admin can enrol a device for (ADR 0781): the business's own tablet, signed in
|
|
1137
|
+
* as nobody, calling only the tools the role holds (`audiences: ["device"]`).
|
|
1138
|
+
*/
|
|
1139
|
+
deviceRoles?: Record<string, DeviceRoleSpec>;
|
|
862
1140
|
/**
|
|
863
1141
|
* Permissions of this extension's tools (`<id>:<word>`) a human admin may grant to a staff
|
|
864
1142
|
* account one by one (ADR 0449), on top of its role: a coach who is a member granted the
|
|
865
1143
|
* permission of a tool a member could not otherwise call. Only shipped extensions and an org's
|
|
866
|
-
* own may declare them.
|
|
1144
|
+
* own may declare them. An account holding one of the installed packs' roles may be granted
|
|
1145
|
+
* them too: what it holds is the role and its grants, added up (ADR 0600). A permission one of
|
|
1146
|
+
* this extension's roles holds cannot be grantable (a grant never lifts a role's limits).
|
|
867
1147
|
*/
|
|
868
1148
|
grantable?: readonly string[];
|
|
1149
|
+
/**
|
|
1150
|
+
* Routine mail (ADR 0590): fixed emails about this extension's records that the host sends
|
|
1151
|
+
* without a person's approval, each a kind an admin can turn off. Only shipped extensions may
|
|
1152
|
+
* declare it, and only their automations send it (`ctx.routineMail.send`).
|
|
1153
|
+
*/
|
|
1154
|
+
routineMail?: Record<string, RoutineMailSpec>;
|
|
1155
|
+
/**
|
|
1156
|
+
* Journey signals (stage 53, ADR 0802): moments about a Person that a journey can start or stop
|
|
1157
|
+
* on, each a record of this extension's objects created or entering a state, and the field
|
|
1158
|
+
* naming its Person (`started: { label: "Membership started", object: "membership" }`). The
|
|
1159
|
+
* host records the last time each Person had each one, in the write's own batch. Only shipped
|
|
1160
|
+
* extensions may declare them.
|
|
1161
|
+
*/
|
|
1162
|
+
journeySignals?: Record<string, JourneySignalSpec>;
|
|
1163
|
+
/**
|
|
1164
|
+
* What each grantable permission gives, in plain words, shown to the admin who ticks it
|
|
1165
|
+
* (`{ "bookings:desk": "Works the front desk: ..." }`). Absent: the tools it opens are listed.
|
|
1166
|
+
*/
|
|
1167
|
+
grantableLabels?: Readonly<Record<string, string>>;
|
|
1168
|
+
/**
|
|
1169
|
+
* Permissions of this extension's tools (`<id>:<word>`) that are **restricted** (stage 45, ADR
|
|
1170
|
+
* 0625): a tool naming one is held by admins, and by a staff account a human admin granted it
|
|
1171
|
+
* (declare it `grantable` too), and by nobody else. Without it, every member holds every tool
|
|
1172
|
+
* (a tool's own permission only adds a way in). For pay totals and rostering other people. A
|
|
1173
|
+
* tool naming a restricted permission names only restricted ones; no role holds one; it is
|
|
1174
|
+
* never called by an automation or another extension's code. Only shipped extensions and an
|
|
1175
|
+
* org's own may declare them.
|
|
1176
|
+
*/
|
|
1177
|
+
restricted?: readonly string[];
|
|
1178
|
+
/**
|
|
1179
|
+
* The roster's rules this extension sets for the host (stage 45, ADR 0626): `rosters`, the
|
|
1180
|
+
* restricted permission whose holders roster other people's shifts (with admins: they are the
|
|
1181
|
+
* rosterers the host tells and lets roster), and the number settings of this extension the
|
|
1182
|
+
* host's rules read (the offer cut-off in minutes, the uncovered window in days). Only a
|
|
1183
|
+
* shipped extension or an org's own may declare it.
|
|
1184
|
+
*/
|
|
1185
|
+
staffing?: StaffingRulesSpec;
|
|
1186
|
+
/**
|
|
1187
|
+
* The staff screens of a shipped pack (stage 47, ADR 0660), by key: each a web block of this
|
|
1188
|
+
* pack that the product's admin builds in and shows to whoever could call every tool in its
|
|
1189
|
+
* `opens`. Only a shipped pack may declare them: its blocks are code in the repository,
|
|
1190
|
+
* reviewed like the rest of it. A runtime extension declaring `screens` fails `cos ext check`
|
|
1191
|
+
* and install, and the key is ignored at run time.
|
|
1192
|
+
*/
|
|
1193
|
+
screens?: Record<string, ScreenSpec>;
|
|
1194
|
+
/**
|
|
1195
|
+
* The numbers a shipped pack adds to the owner's Today (stage 60, ADR 0870), by key: each a
|
|
1196
|
+
* read-only query over `rec_*` views that the host runs for the business's local day and shows
|
|
1197
|
+
* to whoever could call every tool in its `opens`. Not `today`: that names a pack role's limit
|
|
1198
|
+
* (ADR 0553). Only a shipped pack may declare them, at most 8; a runtime extension declaring
|
|
1199
|
+
* `todayItems` fails `cos ext check` and install, and the key is ignored at run time.
|
|
1200
|
+
*/
|
|
1201
|
+
todayItems?: Record<string, TodayItemSpec>;
|
|
1202
|
+
/**
|
|
1203
|
+
* The pack's sections of My account (stage 48, ADR 0710), by key: the customer's own area on
|
|
1204
|
+
* the business's website and in its app. Each names a web and a native block of this pack, the
|
|
1205
|
+
* objects whose records mean "this customer has some" (`has`), and where it sits. The host lists
|
|
1206
|
+
* a section to a customer only when they, or a child linked to them where the object opens to
|
|
1207
|
+
* guardians, have one of those records (`me.portal`); `cos add web-account` copies the blocks and
|
|
1208
|
+
* writes the wiring. Only a shipped pack may declare sections: a runtime extension declaring
|
|
1209
|
+
* `portal` fails `cos ext check` and install, and the key is ignored at run time.
|
|
1210
|
+
*/
|
|
1211
|
+
portal?: Record<string, PortalSectionSpec>;
|
|
1212
|
+
}
|
|
1213
|
+
|
|
1214
|
+
/**
|
|
1215
|
+
* One section of My account a shipped pack adds (stage 48, ADR 0710). The client app's shell
|
|
1216
|
+
* renders `export` of the block, giving it the pack's hooks under the pack's id (`bookings`,
|
|
1217
|
+
* `memberships`) and the page's `returnUrl`: every other prop of the component is optional.
|
|
1218
|
+
*/
|
|
1219
|
+
export interface PortalSectionSpec {
|
|
1220
|
+
/** The section's heading: "Memberships and passes". */
|
|
1221
|
+
label: string;
|
|
1222
|
+
/** The website's block: a web block of this pack, and the component it exports. */
|
|
1223
|
+
web?: { block: string; export: string };
|
|
1224
|
+
/** The app's block: a native block of this pack (`<id>-native-<name>`), and its component. */
|
|
1225
|
+
native?: { block: string; export: string };
|
|
1226
|
+
/**
|
|
1227
|
+
* Where it sits among the sections, lower first: 1 to 59, so a pack's come before the base
|
|
1228
|
+
* sections (Orders at 60 onward).
|
|
1229
|
+
*/
|
|
1230
|
+
order: number;
|
|
1231
|
+
/**
|
|
1232
|
+
* This pack's objects (`<id>.<object>`) that declare a customer, whose records mean the
|
|
1233
|
+
* customer has something here: the section shows only then. Never empty: a page anyone may
|
|
1234
|
+
* open ("Buy a pass") is a page the client links to, not a section.
|
|
1235
|
+
*/
|
|
1236
|
+
has: readonly string[];
|
|
1237
|
+
}
|
|
1238
|
+
|
|
1239
|
+
/** How a Today item's value is shown. Money is never a pack's: it is the host's (stage 52). */
|
|
1240
|
+
export const TODAY_ITEM_FORMATS = ["count", "percent"] as const;
|
|
1241
|
+
export type TodayItemFormat = (typeof TODAY_ITEM_FORMATS)[number];
|
|
1242
|
+
|
|
1243
|
+
/** What a Today item's value is compared with: the same time yesterday or a week ago, or nothing. */
|
|
1244
|
+
export const TODAY_ITEM_COMPARES = ["yesterday", "lastWeek", "none"] as const;
|
|
1245
|
+
export type TodayItemCompare = (typeof TODAY_ITEM_COMPARES)[number];
|
|
1246
|
+
|
|
1247
|
+
/** The parameters the host binds into a Today item's SQL: the local day `[from, to)` and now. */
|
|
1248
|
+
export const TODAY_ITEM_PARAMS = ["today_from", "today_to", "now"] as const;
|
|
1249
|
+
|
|
1250
|
+
/**
|
|
1251
|
+
* One number a shipped pack adds to Today (stage 60, ADR 0870). The host binds `:today_from`,
|
|
1252
|
+
* `:today_to` (the business's local day, as instants) and `:now`, runs `sql` under the widget
|
|
1253
|
+
* rules (one `SELECT` or `WITH` over `rec_*` views, bound parameters, row and time limits) and
|
|
1254
|
+
* shows its one column, `value`. For the comparison it binds the earlier day's window instead.
|
|
1255
|
+
*/
|
|
1256
|
+
export interface TodayItemSpec {
|
|
1257
|
+
/** The card's label: "Came today". */
|
|
1258
|
+
label: string;
|
|
1259
|
+
/** Where it sits among every item on Today (lower first). Default 100. */
|
|
1260
|
+
order?: number;
|
|
1261
|
+
/** `count` or `percent`. No money format: a money number is a Finance reports figure. */
|
|
1262
|
+
format: TodayItemFormat;
|
|
1263
|
+
/** Read-only SQL returning one row with one column, `value`. */
|
|
1264
|
+
sql: string;
|
|
1265
|
+
/** Default `yesterday`. */
|
|
1266
|
+
compare?: TodayItemCompare;
|
|
1267
|
+
/** When the card needs attention: its value above or below a number. Left out, never. */
|
|
1268
|
+
attention?: { above: number } | { below: number };
|
|
1269
|
+
/**
|
|
1270
|
+
* The rows behind the number, at most 50: read-only SQL with the same parameters returning a
|
|
1271
|
+
* display column (`label`), optionally a secondary line (`detail`) and the id of a record of
|
|
1272
|
+
* `record.object` (one of this pack's objects, `person` or `organisation`) in column
|
|
1273
|
+
* `record.id`. Names and record ids only: never notes, health answers, pay or leave.
|
|
1274
|
+
*/
|
|
1275
|
+
rows?: {
|
|
1276
|
+
sql: string;
|
|
1277
|
+
label: string;
|
|
1278
|
+
detail?: string;
|
|
1279
|
+
record: { object: string; id: string };
|
|
1280
|
+
};
|
|
1281
|
+
/**
|
|
1282
|
+
* This pack's own tools, every one of which the viewer must be able to call to see the item,
|
|
1283
|
+
* as a screen's `opens` (ADR 0660). At least one is for staff only.
|
|
1284
|
+
*/
|
|
1285
|
+
opens: readonly string[];
|
|
1286
|
+
/** On the web, a card opens this screen of the pack (stage 47) rather than its rows. */
|
|
1287
|
+
web?: { screen: string };
|
|
1288
|
+
}
|
|
1289
|
+
|
|
1290
|
+
/**
|
|
1291
|
+
* One staff screen of a shipped pack (stage 47, ADR 0660). The admin renders `export` of the web
|
|
1292
|
+
* block `block` with the pack's hooks, inside its shell; the host lists the screen for a viewer
|
|
1293
|
+
* only when they could call every tool in `opens` (`screens.mine`).
|
|
1294
|
+
*/
|
|
1295
|
+
export interface ScreenSpec {
|
|
1296
|
+
/** The screen's name in the navigation and on its page: "Front desk". */
|
|
1297
|
+
label: string;
|
|
1298
|
+
/** A web block of this pack (`packs/<id>/blocks/<block>/`), never a native one. */
|
|
1299
|
+
block: string;
|
|
1300
|
+
/** The component the block exports that renders the screen: "Desk". */
|
|
1301
|
+
export: string;
|
|
1302
|
+
/**
|
|
1303
|
+
* Where it sits in the admin's navigation: a section headed `group`, in `order`. Left out, the
|
|
1304
|
+
* screen is reached only from a record (`record`) or a link.
|
|
1305
|
+
*/
|
|
1306
|
+
nav?: { group: string; order?: number };
|
|
1307
|
+
/**
|
|
1308
|
+
* The tools that decide who may open the screen: this pack's own, every one of which the viewer
|
|
1309
|
+
* must be able to call. Name those that decide (the screen's main read and the write its main
|
|
1310
|
+
* action makes), not every tool it calls: the host refuses the rest, and the block shows its own
|
|
1311
|
+
* state for that. "Could call these tools" is the gate, not a separate permission. At least one
|
|
1312
|
+
* is for staff only (never a customer's or the public's tool as the only gate), unless `writes`
|
|
1313
|
+
* gates the screen.
|
|
1314
|
+
*/
|
|
1315
|
+
opens?: readonly string[];
|
|
1316
|
+
/**
|
|
1317
|
+
* Objects of this pack the screen writes through the host's record operations rather than a
|
|
1318
|
+
* tool (a builder saving a course): the viewer must be able to write them (`record.update`), so
|
|
1319
|
+
* a viewer or a pack role never gets the screen. Gates beside `opens`; one of the two names
|
|
1320
|
+
* something.
|
|
1321
|
+
*/
|
|
1322
|
+
writes?: readonly string[];
|
|
1323
|
+
/**
|
|
1324
|
+
* A record screen: a tab on this object's record page (one of this pack's objects, `person` or
|
|
1325
|
+
* `organisation`), given the record's id as the prop `as`. With `nav` too, it is also listed in
|
|
1326
|
+
* the navigation, opened without a record: its block then chooses one itself.
|
|
1327
|
+
*/
|
|
1328
|
+
record?: { object: string; as: string };
|
|
1329
|
+
}
|
|
1330
|
+
|
|
1331
|
+
/** The roster's rules an extension sets for the host (ADR 0626): see `ExtensionSpec.staffing`. */
|
|
1332
|
+
export interface StaffingRulesSpec {
|
|
1333
|
+
/** A restricted permission of this extension's tools: who holds it (and admins) roster. */
|
|
1334
|
+
rosters: string;
|
|
1335
|
+
/**
|
|
1336
|
+
* A restricted, grantable permission of this extension's tools: who holds it (and admins) read
|
|
1337
|
+
* who is counted for pay, the pay periods' totals, and lock, reopen and export them (ADR 0627).
|
|
1338
|
+
*/
|
|
1339
|
+
pays?: string;
|
|
1340
|
+
/**
|
|
1341
|
+
* Settings of this extension the host reads, each `personApproves`; the host's defaults when
|
|
1342
|
+
* left out.
|
|
1343
|
+
*/
|
|
1344
|
+
settings?: {
|
|
1345
|
+
/** Minutes before a shift starts that offers close (default 60). A number setting. */
|
|
1346
|
+
offerCutoffMinutes?: string;
|
|
1347
|
+
/** Days ahead a shift with nobody on it is warned about and told (default 14). A number. */
|
|
1348
|
+
uncoveredDays?: string;
|
|
1349
|
+
/** The pay period: a select of `weekly`, `fortnightly`, `monthly` (ADR 0627). */
|
|
1350
|
+
payPeriod?: string;
|
|
1351
|
+
/** The local date (YYYY-MM-DD) one weekly or fortnightly period starts: a text setting. */
|
|
1352
|
+
payPeriodStart?: string;
|
|
1353
|
+
/** The day of the month (1 to 28) a monthly period starts: a number setting. */
|
|
1354
|
+
payPeriodDay?: string;
|
|
1355
|
+
};
|
|
869
1356
|
}
|
|
870
1357
|
|
|
871
1358
|
const EXTENSION = Symbol.for("ops.extension");
|