@lotics/cli 0.318.49 → 0.320.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/docs/examples.md CHANGED
@@ -230,7 +230,8 @@ among them: the `design` reference. Every key: `reference`, at the pages each se
230
230
  "parts_ready_on": {"type": "date"},
231
231
  "arrived_on": {"type": "date"},
232
232
  "hours": {"type": "number", "notation": {"style": "unit", "unit": "h"}},
233
- "completed_on": {"type": "date"}
233
+ "completed_on": {"type": "date"},
234
+ "length": {"type": "formula", "notation": {"style": "unit", "unit": "h"}}
234
235
  },
235
236
  "records": {
236
237
  "subtitle": ["scheduled_for", "ends_at"],
@@ -251,7 +252,11 @@ among them: the `design` reference. Every key: `reference`, at the pages each se
251
252
  {
252
253
  "ref": "engineer",
253
254
  "title": "name",
254
- "fields": {"name": {"type": "text"}, "base": {"type": "link", "table": "warehouse", "multi": false}},
255
+ "fields": {
256
+ "name": {"type": "text"},
257
+ "base": {"type": "link", "table": "warehouse", "multi": false},
258
+ "day_hours": {"type": "number", "notation": {"style": "unit", "unit": "h"}}
259
+ },
255
260
  "records": {"subtitle": ["base"], "party": "person"}
256
261
  }
257
262
  ],
@@ -274,7 +279,7 @@ among them: the `design` reference. Every key: `reference`, at the pages each se
274
279
  "entity": "service_visit",
275
280
  "columns": ["job"],
276
281
  "search": ["customer"],
277
- "layout": {"lanes": {"by": "engineer"}},
282
+ "layout": {"lanes": {"by": "engineer", "loads": {"length": "day_hours"}}},
278
283
  "create": ["engineer", "scheduled_for", "ends_at", "customer", "job"]
279
284
  }
280
285
  ],
@@ -290,6 +295,7 @@ among them: the `design` reference. Every key: `reference`, at the pages each se
290
295
  "children": [
291
296
  "engineer",
292
297
  "job",
298
+ "hours",
293
299
  {
294
300
  "type": "Act",
295
301
  "key": "to_booked_on",
@@ -333,7 +339,10 @@ among them: the `design` reference. Every key: `reference`, at the pages each se
333
339
  ]
334
340
  }
335
341
  ],
336
- "row": {"subtitle": [{"field": "scheduled_for", "edit": false}, {"field": "ends_at", "edit": false}]}
342
+ "row": {
343
+ "subtitle": [{"field": "scheduled_for", "edit": false}, {"field": "ends_at", "edit": false}],
344
+ "figure": false
345
+ }
337
346
  },
338
347
  {"type": "Record", "entity": "warehouse", "add": ["name", "city"]},
339
348
  {"type": "Record", "entity": "engineer", "add": ["name", "base"]},
@@ -408,22 +417,7 @@ among them: the `design` reference. Every key: `reference`, at the pages each se
408
417
  "filters": ["phu_trach", "khach_hang"],
409
418
  "layout": {"gantt": {"start": "ngay_giao"}},
410
419
  "create": false,
411
- "remove": false,
412
- "children": [
413
- {
414
- "type": "Reading",
415
- "key": "register_reading_0",
416
- "label": "Phiếu đang cho thuê",
417
- "where": {"trang_thai": ["dang_thue"]}
418
- },
419
- {
420
- "type": "Reading",
421
- "key": "register_reading_1",
422
- "label": "Tiền thuê đang chạy",
423
- "value": "tong_tien",
424
- "where": {"trang_thai": ["dang_thue"]}
425
- }
426
- ]
420
+ "remove": false
427
421
  }
428
422
  ],
429
423
  "pages": [
@@ -444,7 +438,7 @@ among them: the `design` reference. Every key: `reference`, at the pages each se
444
438
  "at": ["dang_thue"],
445
439
  "children": [
446
440
  "so_ngay",
447
- "ngay_tra",
441
+ {"field": "ngay_tra", "edit": false},
448
442
  {
449
443
  "type": "Act",
450
444
  "key": "nhan_tra",
@@ -498,9 +492,27 @@ among them: the `design` reference. Every key: `reference`, at the pages each se
498
492
  {"alias": "phuc_hinh", "color": "orange"}
499
493
  ]
500
494
  },
501
- "dien_thoai": {"type": "text"}
495
+ "dien_thoai": {"type": "text"},
496
+ "ngay_lam": {
497
+ "type": "select",
498
+ "options": [
499
+ {"alias": "mon", "color": "blue"},
500
+ {"alias": "tue", "color": "blue"},
501
+ {"alias": "wed", "color": "blue"},
502
+ {"alias": "thu", "color": "blue"},
503
+ {"alias": "fri", "color": "blue"},
504
+ {"alias": "sat", "color": "blue"},
505
+ {"alias": "sun", "color": "blue"}
506
+ ],
507
+ "multi": true
508
+ },
509
+ "tu_ngay": {"type": "date"}
502
510
  },
503
- "records": {"subtitle": ["chuyen_mon"], "party": "person"}
511
+ "records": {
512
+ "subtitle": ["chuyen_mon"],
513
+ "party": "person",
514
+ "cadence": [{"entity": "lich_truc", "on": "ngay_lam", "from": "tu_ngay", "planned": "ke_hoach"}]
515
+ }
504
516
  },
505
517
  {
506
518
  "ref": "lich_truc",
@@ -517,9 +529,10 @@ among them: the `design` reference. Every key: `reference`, at the pages each se
517
529
  ]
518
530
  },
519
531
  "ngay": {"type": "date"},
520
- "ghe": {"type": "link", "table": "ghe", "multi": false}
532
+ "ghe": {"type": "link", "table": "ghe", "multi": false},
533
+ "ke_hoach": {"type": "date"}
521
534
  },
522
- "records": {"subtitle": ["ngay", "ghe"]}
535
+ "records": {"subtitle": ["ngay", "ghe"], "mark": "ca"}
523
536
  }
524
537
  ],
525
538
  "body": {
@@ -535,10 +548,38 @@ among them: the `design` reference. Every key: `reference`, at the pages each se
535
548
  "filters": ["chuyen_mon"],
536
549
  "layout": "roster",
537
550
  "create": ["ho_ten", "chuyen_mon", "dien_thoai"],
538
- "children": [{"type": "List", "entity": "lich_truc", "create": true, "remove": true}]
551
+ "children": [
552
+ {"type": "List", "entity": "lich_truc", "create": true, "remove": true},
553
+ {"type": "Act", "key": "tao_ca_truc_ds", "label": "Tạo ca trực", "on": "view", "makes": "lich_truc"},
554
+ {
555
+ "type": "Export",
556
+ "key": "lich_truc_thang",
557
+ "label": "Lịch trực tháng",
558
+ "template": "lich_truc_thang"
559
+ }
560
+ ]
539
561
  }
540
562
  ],
541
- "pages": [{"type": "Record", "entity": "lich_truc"}, {"type": "Record", "entity": "ghe", "add": ["ten", "phong"]}]
563
+ "pages": [
564
+ {
565
+ "type": "Record",
566
+ "entity": "nha_si",
567
+ "children": [
568
+ {
569
+ "type": "Section",
570
+ "key": "lich_tuan",
571
+ "title": "Lịch trực mỗi tuần",
572
+ "children": [
573
+ "ngay_lam",
574
+ "tu_ngay",
575
+ {"type": "Act", "key": "tao_ca_truc", "label": "Tạo ca trực", "makes": "lich_truc"}
576
+ ]
577
+ }
578
+ ]
579
+ },
580
+ {"type": "Record", "entity": "lich_truc"},
581
+ {"type": "Record", "entity": "ghe", "add": ["ten", "phong"]}
582
+ ]
542
583
  }
543
584
  }
544
585
  ```
@@ -627,7 +668,6 @@ among them: the `design` reference. Every key: `reference`, at the pages each se
627
668
  {
628
669
  "type": "List",
629
670
  "entity": "stock_item",
630
- "columns": ["price"],
631
671
  "filters": ["on_hand"],
632
672
  "search": ["name", "sku"],
633
673
  "layout": "cards",
@@ -853,10 +893,7 @@ among them: the `design` reference. Every key: `reference`, at the pages each se
853
893
  "sort": {"field": "name"},
854
894
  "opens": {"tier": ["key", "standard"]},
855
895
  "create": ["name", "code", "credit_limit"],
856
- "children": [
857
- {"type": "Reading", "key": "register_reading_0", "value": "outstanding", "by": "tier"},
858
- {"type": "Reading", "key": "register_reading_1", "value": "outstanding", "by": "account_manager"}
859
- ]
896
+ "children": [{"type": "Reading", "key": "register_reading_1", "value": "outstanding", "by": "account_manager"}]
860
897
  }
861
898
  ],
862
899
  "pages": [
@@ -1219,7 +1256,7 @@ among them: the `design` reference. Every key: `reference`, at the pages each se
1219
1256
  {
1220
1257
  "type": "List",
1221
1258
  "entity": "ho_so",
1222
- "columns": ["doi_tuong", "xu_ly", "can_bo_sung"],
1259
+ "columns": ["can_bo_sung", "doi_tuong", "xu_ly"],
1223
1260
  "filters": ["xu_ly", "can_bo_sung"],
1224
1261
  "search": ["khach_hang", "ma_ho_so", "dien_thoai"],
1225
1262
  "create": ["khach_hang", "dich_vu", "doi_tuong", "tinh_trang_nha_o", "loai_can", "phi_dich_vu", "sale"],
@@ -1280,13 +1317,7 @@ among them: the `design` reference. Every key: `reference`, at the pages each se
1280
1317
  "type": "Fieldset",
1281
1318
  "key": "phu_trach",
1282
1319
  "label": "Phụ trách",
1283
- "children": ["sale", "xu_ly", "can_bo_sung"]
1284
- },
1285
- {
1286
- "type": "Fieldset",
1287
- "key": "moc",
1288
- "label": "Mốc hồ sơ",
1289
- "children": ["ngay_ky_hdmb", "ngay_ban_giao"]
1320
+ "children": ["sale", "xu_ly", "can_bo_sung", "phi_dich_vu"]
1290
1321
  },
1291
1322
  {
1292
1323
  "type": "List",
@@ -1412,7 +1443,8 @@ among them: the `design` reference. Every key: `reference`, at the pages each se
1412
1443
  {"type": "Check", "field": "con_no_phi"},
1413
1444
  {"type": "Check", "field": "vuot_thu_nhap"},
1414
1445
  {"type": "Check", "field": "da_hoan_tat", "on": ["doc_giay_to"]}
1415
- ]
1446
+ ],
1447
+ "row": {"figure": false}
1416
1448
  },
1417
1449
  {"type": "Record", "entity": "du_an", "add": ["ten_du_an", "chu_dau_tu", "so_can"]}
1418
1450
  ]
@@ -1896,7 +1928,6 @@ among them: the `design` reference. Every key: `reference`, at the pages each se
1896
1928
  {
1897
1929
  "type": "List",
1898
1930
  "entity": "de_nghi",
1899
- "columns": ["nguoi_de_nghi"],
1900
1931
  "filters": ["du_an"],
1901
1932
  "group": "du_an",
1902
1933
  "create": ["noi_dung", "loai", "du_an", "nha_cung_cap", "so_tien", "han_thanh_toan", "nguoi_de_nghi"],
@@ -7,9 +7,11 @@ The value `create_records` and `update_records` take for a field. A field is nam
7
7
  | Type | Value |
8
8
  |---|---|
9
9
  | `text` | `"hello"` |
10
+ | `time` | a `text` of this format: `"16:00"`, stored `HH:mm` on a 24-hour clock; `"8:00"` and `"08:00:00"` are stored `"08:00"`, any other text is refused |
10
11
  | `number` | `42` |
11
12
  | `boolean` | `true` |
12
13
  | `date` | `"2025-03-14"`, or a month `"2025-03"` or a year `"2025"`, stored as written and compared as its first day |
14
+ | `month` | `"2025-03"`; a full date written to it keeps its month, a bare year is refused |
13
15
  | `datetime` | a `date` of this format: `"2025-03-14T09:00"`, never a month or a year |
14
16
  | `date_range` | a `date` of this format: `"2025-03-01/2025-03-15"`, both halves full dates |
15
17
  | `datetime_range` | a `date` of this format: `"2025-03-01T09:00/2025-03-15T17:00"`, both halves full |
@@ -4,14 +4,16 @@ A workspace is where one business keeps what it knows and does its daily work. *
4
4
 
5
5
  Open the one page for the job. Pages are read with the `docs` tool (`docs path="design"`; `lotics docs design` on the CLI).
6
6
 
7
- - **Build a workspace from a description:** `docs path="first_build"`. A whole bakery built call by call: tables with a check, the paper, the app (which apps, a treatment per kind of row, what the check refuses, who gets it), the owner's rows, then pressing it.
8
- - **An app starts as one root List:** `{"type": "List", "entity": "order"}` in the App's `children` draws the page, the add and the Delete. The write's answer shows what it drew, placed or folded; change only the difference (`first_build`, § 3).
7
+ - **Build a workspace, or add an app:** `docs path="build"`. A bakery built call by call: tables with a check, the paper, the app, what the owner will ask an agent, the owner's rows, then pressing it.
8
+ - **Which apps a business needs, and who gets each:** `docs path="app_architecture"`.
9
+ - **Judge what you built:** `docs path="design/the-rubric"`. Six questions, each answered by a call.
9
10
  - **Change an app:** `docs path="reference/changing-an-app"`. `get_app`, then `set_app` with `nodes` and `base_version_id`. A table is changed with `get_table`, then `set_tables` with its `table_id` (`data_model`).
10
11
  - **Enforce a rule on a table:** `docs path="workflows/table-checks"`. A condition no create, update or delete may meet, whoever makes it, and the language it is written in.
11
12
  - **Make a document:** `docs path="document_templates"`. A template, its slots and loops, and the act that files it on a record.
12
13
  - **Enter data, count, answer a question:** `docs path="working_in_a_workspace"`. The right tool for each job; the value each field takes is `field_values`, choosing rows is `filters`.
14
+ - **Rows owed on a weekly pattern (a diary every weekday, a class every Tuesday):** `docs path="reference/cadence"` for a table's `records.cadence`; the Act that `makes` them is `reference/act-node`.
15
+ - **Rows an act proposes for a person to tick (a statement matched to the notes it pays):** the workflow body is `docs path="workflows/a-reviewed-act"`, calling the act is `agent_surface/a-reviewed-act`.
13
16
  - **Reach a connected service, or do what a button cannot:** `docs path="workflows"`. Triggers, steps and expressions; each service step is in `workflow_steps`.
14
- - **Share an app:** `docs path="first_build"`, § 3. `set_access`, and which app each person gets.
15
17
  - **Who can reach what, or why something was refused:** `docs path="permissions"`.
16
18
 
17
- Which apps a business needs is `first_build`, § 3 (a worked split: `app_architecture`); how each record is drawn is `design`; every key is in `reference`; each screen in a complete workspace is `examples`.
19
+ How each record is drawn is `design`; every key is in `reference`; each screen in a complete workspace is `examples`.
package/docs/workflows.md CHANGED
@@ -159,23 +159,24 @@ A body names a table or document template by its alias (`query_records({ table_i
159
159
  2. **An Act's own `workflow`** has the app's guards placed at the top of the body, between `<lotics:guards>` tags,
160
160
  replaced on every save: a save that leaves them out or edits them gets the app's again, at the top wherever the tags
161
161
  sat, so the act's row rule, `when`, `requires`, checks and locks always run first.
162
- 3. **A value is read as the record tools store it.** A single select reads as its option and a member as its id; an
163
- option is written by its alias wherever it meets a select — compared, listed, switched on, written — also beside a
164
- name set from the field (`const s = record.status; s == "done"`), and a select
165
- value handed on whole (returned, written to a text field) is its key. An option's alias searched for in a list the
166
- save cannot place it against (`includes(filter(record.tags, …), "hot")`) is refused: search the field itself. A link reads as the list of its row ids, a
162
+ 3. **A value is read as the record tools store it.** A single select reads as its option's alias and a member as its id;
163
+ an option is written by its alias wherever it meets a select — compared, listed, switched on, written — also beside a
164
+ name set from the field (`const s = record.status; s == "done"`) or in a list that search runs over
165
+ (`includes(filter(record.tags, …), "hot")`). A select value handed on whole (returned for a declared select, written to a
166
+ select field or a filter) is resolved to the option's key where it leaves the body; one handed to a text, a message or a
167
+ template carries the alias. An option key bound to a name and compared with a select is refused. A link reads as the list of its row ids, a
167
168
  one-row link too: `first(record.customer)` is the one id, and `record.customer` used as one id is refused at save,
168
169
  naming `first(record.customer)`. A one-row link is written with its one id or a list of one; a many-row link with a list. A lookup reads as one flat list of the values it looks up: `includes(record.owner,
169
- me)`; a looked-up link, as the ids of its rows, which `query_records` takes as `record_ids`. A select's value is one of another select's options only where that table shares its keys, by having been
170
- duplicated from it, not where an option merely shares its alias. A row that takes its parent's option gets it from
171
- `default_from`, and a lookup shows it.
170
+ me)`; a looked-up link, as the ids of its rows, which `query_records` takes as `record_ids`. A select's value is one of another select's options where the two state the same alias for it; two selects that
171
+ state no alias in common never hold one value, and a save that compares them or copies one into the other is refused.
172
+ A row that takes its parent's option gets it from `default_from`, and a lookup shows it.
172
173
  4. **What an app sends takes an option by alias or key.** An input or output drawn from a field (`field`, written
173
174
  `<table id>.<alias>`) compares and returns by alias in the body, and the run hands it on as the option's key. A
174
175
  refusal's `field_errors` and a `validate` check's `field_key` name a declared input or a field's alias.
175
176
  5. **`==` against a multi-select means "includes".** `record["tags"] == "urgent"` on a multi-select is stored as
176
177
  `includes(record["tags"], "urgent")`; either spelling works.
177
178
  6. **`option("<field>", "<option>")` names an option where no select is beside it** (a name set once and compared later,
178
- a list of options, a value handed to a tool). It reads as the option, typed as that select's, and is stored as its key.
179
+ a list of options, a value handed to a tool). It reads as the option, typed as that select's, and is stored as its alias.
179
180
  The field is looked up among the tables the body reaches; a field or option that does not exist is refused naming both, and
180
181
  a field alias that two tables state with different keys for that option is refused naming each table. A key
181
182
  option key written out still works, but write `option()`: a key is a value no one can read.
@@ -224,7 +225,7 @@ prefix `! -`.
224
225
  table filter compares stored values exactly.
225
226
  - `??` is `coalesce(left, right)`; `?.` reads through a null (`a?.b`, `a?.[0]`, and `s?.trim()` for the
226
227
  method names listed under **Helpers**). `x?.()` is refused: helpers and tools are not values.
227
- - Templates use backticks and `${...}`.
228
+ - Templates use backticks and `${...}`. `get_workflow` shows a template as `text(…)`, which writes its parts in order as the template does: `text("Missing: ", join(names, ", "), ".")`. A request whose body holds a template's `${…}` can be refused before it reaches Lotics, a 403 page rather than an answer; write that text with `text(…)`.
228
229
  - Destructuring — `const { status, name } = record;` binds each name. Renames
229
230
  (`{ status: s }`), quoted keys (`{ "ref": ref }`), array patterns with holes
230
231
  (`const [first, , third] = xs;`) and defaults (`{ note = "" }`, which apply on null too) work on
@@ -279,7 +280,7 @@ write `xs.toSorted(...)` or `[...xs].sort(...)`.
279
280
  stored, by field key, as every later change to its app or tables checks it: a body that types only through one of them is
280
281
  refused at save.
281
282
  - Narrow what is not typed (a connector's JSON is `unknown`) with `typeof`, `in`, `Array.isArray` and `isNull`.
282
- - `first(xs)` may be undefined; `requireFirst(xs)` is the list's first item or an error.
283
+ - `first(xs)` may be undefined; `requireFirst(xs)` is the list's first item or an error. A test of `first(xs)` covers no second `first(xs)`: bind it once (`const id = first(xs)`), then test `id`.
283
284
  - `obj[key]` needs `key` to be a key of `obj`, or `obj` to be a record with a string index.
284
285
 
285
286
  ## Helpers
@@ -330,7 +331,7 @@ The same work can be written with the helpers below, which are additions to Java
330
331
  - **Dates**, in the workspace's timezone: `now`, `formatDate`, `parseDate`, `addDays`, `subDays`,
331
332
  `addHours`, `subHours`, `addMinutes`, `subMinutes`, `startOfDay`, `endOfDay`, `startOfMonth`, `endOfMonth`,
332
333
  `addMonths` (a day past the target month's end lands on its last day), `differenceInCalendarDays`, `differenceInHours`, `differenceInMinutes`, `isBefore`, `isAfter`,
333
- `isSameDay`, `isToday`, `isWithinRange`, `meetsBounds`. A date beside a moment compares by day, so `<=` means
334
+ `isSameDay`, `isToday`, `isWithinRange`, `datesOn(from, until, days)` (the days from `from` to `until`, both included, falling on weekdays named `mon` to `sun`), `meetsBounds`. A date beside a moment compares by day, so `<=` means
334
335
  through that day; `startOfMonth` and `endOfMonth` of a date answer a day
335
336
  - **Other**: `formatCurrency(amount, locale, currency)`, `randomNumber(len)`,
336
337
  `randomAlphaNumeric(len)`, `sample(items)` (a random item)
@@ -540,11 +541,13 @@ await update_records({ table_id: "sheet_lines", record_ids: [line.id], set: { ou
540
541
  return({ status: "success", message: "Applied." });
541
542
  ```
542
543
 
544
+ ### A reviewed act
545
+
543
546
  A shop matches a bank statement to the notes it is owed by an act that states `review`. That act's workflow only
544
547
  proposes: its body calls steps that read and no other, and runs no agent — either is refused when the body is saved —
545
548
  and returns in `data.review` one changeset of the act's table, which the platform writes the approved rows of. Called
546
549
  with what the act asks, it answers the proposal and nothing is written; called again with
547
- `approved: { updates: [{ record_id, sha }], creates: [{ key, sha }] }`, the body runs again and the platform writes
550
+ `approved: { creates: [{ key, sha }], updates?: [{ record_id, sha }] }` (absent `updates` means none), the body runs again and the platform writes
548
551
  those rows as this second run proposes them, so the body never reads `approved`. The platform adds a `sha` to every row
549
552
  of the proposal it answers — the body states none, and one it states is dropped — and the caller echoes the `sha` of
550
553
  each row it approves. A row the second run proposes with other values than the `sha` was read from is left unwritten
@@ -682,6 +685,65 @@ if (isNull(record.no)) {
682
685
  }
683
686
  ```
684
687
 
688
+ ## Schedules
689
+
690
+ A weekly pattern made into dated rows is a parent's `records.cadence` and an Act `makes` it
691
+ (`reference/record-places-pins-and-cadence`), no body; pressed again it also moves the rows the pattern now makes otherwise that no one has touched. The rest of a timetable is a rule or a short body.
692
+
693
+ **A student in two places.** An enrolment reads its span and its days off its course, so one meeting at the same
694
+ time on a shared weekday as the student's other course is refused at save:
695
+
696
+ ```json
697
+ "no_overlap": { "from": "course.starts", "to": "course.ends", "by": ["student", "course.days"], "while": { "state": ["active"] } }
698
+ ```
699
+
700
+ **A swap.** One Act on a shift runs a `workflow` asking the other shift (an input `other` of `type: "link"`, `entity` the shifts) and writes both people in one call:
701
+
702
+ ```
703
+ const inputs = trigger.app_workflow.inputs;
704
+ const both = (await query_records({ table_id: "shifts", record_ids: [inputs.record_id, inputs.other] })).records;
705
+ const mine = requireFirst(filter(both, (one) => one.id == inputs.record_id));
706
+ const theirs = requireFirst(filter(both, (one) => one.id == inputs.other));
707
+ await update_records({
708
+ table_id: "shifts",
709
+ record_ids: [mine.id, theirs.id],
710
+ field_keys: ["person"],
711
+ rows: [[theirs.data["person"]], [mine.data["person"]]],
712
+ });
713
+ return({ status: "success", message: "Swapped." });
714
+ ```
715
+
716
+ **A rotation.** A pattern that turns over the days (teams taking nights in turn) is a body: `datesOn(from, until,
717
+ days)` lists the days of a range falling on the weekdays named.
718
+
719
+ ```
720
+ const inputs = trigger.app_workflow.inputs;
721
+ const days = datesOn(inputs.from, inputs.until, ["mon", "tue", "wed", "thu", "fri"]);
722
+ const teams = (await query_records({ table_id: "teams", record_ids: inputs.record_ids })).records;
723
+ const rows = days.flatMap((day, at) => teams.map((team, place) => ({ team: [team.id], day, kind: (at + place) % 2 == 0 ? "day" : "night" })));
724
+ for (let at = 0; at < size(rows); at += 1000) {
725
+ await create_records({ table_id: "shifts", records: slice(rows, at, at + 1000) });
726
+ }
727
+ return({ status: "success", message: `${size(rows)} shifts` });
728
+ ```
729
+
730
+ **Pay at the rate taught, and a month closed.** A lesson copies its teacher's rate when it is made (`"default_from":
731
+ "teacher.rate"`), so a rise later leaves the lessons already made alone; a formula multiplies it by the lesson's hours,
732
+ and a Tab's `totals` sums each teacher's month. A pay period is a row with its first and last day and a status; a check
733
+ on the lessons refuses every write inside a closed one:
734
+
735
+ ```json
736
+ "checks": { "month_closed": {
737
+ "on": ["create", "update", "delete"],
738
+ "lookups": { "period": { "table": "pay_periods", "limit": 1, "filter": { "node_type": "group", "logic": "and", "children": [
739
+ { "node_type": "condition", "field_key": "first_day", "operator": "on_or_before", "value": { "$expr": "record.starts_at" } },
740
+ { "node_type": "condition", "field_key": "last_day", "operator": "on_or_after", "value": { "$expr": "record.starts_at" } },
741
+ { "node_type": "condition", "field_key": "status", "operator": "has_any_of", "value": ["closed"] } ] } } },
742
+ "fail_when": "size(lookups.period) > 0",
743
+ "message": "\"This month's pay is closed.\""
744
+ } }
745
+ ```
746
+
685
747
  ## Reaching a connected service
686
748
 
687
749
  A service is reached only by a workflow step, and a step is called inside an app's workflow or an automation. From
@@ -4,7 +4,7 @@ Once tables and apps exist, an agent does the team's work through them. The mean
4
4
 
5
5
  | The work | The means | Why |
6
6
  |---|---|---|
7
- | A business operation: move an order on, issue a paper, notify someone | `run_app_workflow` on the app's act, `act_<key>` or the `workflow` it names | The outcome equals a person's press: status, stamps, documents, notifications. `update_records` on an act's field skips all of them. |
7
+ | A business operation: move an order on, issue a paper, notify someone | `run_app_workflow` on the app's act, `act_<key>` | The outcome equals a person's press: status, stamps, documents, notifications. `update_records` on an act's field skips all of them. |
8
8
  | Data entry, a correction, loading the owner's lists | `create_records`, `update_records` | The table's rules hold for every writer. |
9
9
  | A rule or policy the business wrote | `get_workspace` with `search`, then `read_knowledge` | The business's own words, not a guess. |
10
10
  | A file someone hands over | `view_files`; `upload_file` to keep it. A picture reaches a CLI as a note naming `download_file` and `lotics file download <file_id>` | Reads its content; the upload files it in the workspace. When your host passes no bytes, `upload_file` with `person: true` gives the person a link to drop it on. |
@@ -23,7 +23,7 @@ Find the means in this order: `get_workspace` maps the workspace; `search` it by
23
23
 
24
24
  `get_workspace` with kind `member` lists every member's name and id; an admin also sees each one's email, role, `managed` and `sign_in_name`, and, on kind `app`, `knowledge` or `template`, `not_listed`: how many more they can reach, which `all: true` lists. Listed docs and templates carry `access`. An admin also reads the credit limits there.
25
25
 
26
- `set_members` is an admin's: `members` is a map keyed by an email address, a member id or a managed member's sign-in name, and `groups` a map keyed by a group id or the name of a group to create. In `members`, an email no member holds invites that person (`role` is `member` or `admin`; the invitation email goes out), a current member's entry sets `name` and `role`, a removed member's entry restores them and takes only `name`, and `null` removes a member or cancels the invitation pending to that address. Sign-in names are compared in lowercase. A person adds a managed member and sets its password in Settings → Members. The organization keeps at least one admin: the last one cannot be demoted or removed. In `groups`, an entry sets `name`, `description` and the roster with `member_ids`, or with `add_member_ids` and `remove_member_ids` that leave the rest in place; a roster entry may be a key of `members`, so a person invited in the same call can join; `null` deletes the group. The whole input is checked before anything is written or sent; members are applied before groups, in the order given, and the caller's own step-down last. A member's tool list does not carry `set_members` or `set_workspace`.
26
+ `set_members` is an admin's: `members` is a map keyed by an email address, a member id or a managed member's sign-in name, and `groups` a map keyed by a group id, or by a group's name, which sets the group of that name or creates it (refused where several groups share it: key that entry by id). In `members`, an email no member holds invites that person (`role` is `member` or `admin`; the invitation email goes out), a current member's entry sets `name` and `role`, a removed member's entry restores them and takes only `name`, and `null` removes a member or cancels the invitation pending to that address. Sign-in names are compared in lowercase. A person adds a managed member and sets its password in Settings → Members. The organization keeps at least one admin: the last one cannot be demoted or removed. In `groups`, an entry sets `name`, `description` and the roster with `member_ids`, or with `add_member_ids` and `remove_member_ids` that leave the rest in place; a roster entry may be a key of `members`, so a person invited in the same call can join; `null` deletes the group. The whole input is checked before anything is written or sent; members are applied before groups, in the order given, and the caller's own step-down last. A member's tool list does not carry `set_members` or `set_workspace`.
27
27
 
28
28
  `set_access` gives members, groups or the whole organization a role on resources. Role `owner`, on one member, hands every resource listed to that member, whom only the resource's owner or an admin may name; a call cannot share an app and hand it over together, an app handed to or from a member loses its sharing, and an automation is turned off until its new owner turns it on. Handovers are applied one resource at a time, and a failure part-way names what was already applied. `set_workspace` takes `credit_limits` (`workspace`, `apps` by app id, `members` by member id; a number is the daily ceiling in credits, `null` removes it and asks for approval).
29
29
 
@@ -58,7 +58,7 @@ A write is put back by writing the value `query_audit_logs` shows before the cha
58
58
 
59
59
  `get_app` lists the app's acts as `act_<key>` (or the `workflow` an Act names) with what each takes. `run_app_workflow` with `dry_run: true` writes nothing
60
60
  and answers what the run would do; the same call without it runs. An act refuses a row its conditions do not hold for,
61
- and says why (`agent_surface` § A refusal).
61
+ and says why (`agent_surface/a-refusal`).
62
62
 
63
63
  ## Writing records
64
64
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lotics/cli",
3
- "version": "0.318.49",
3
+ "version": "0.320.0",
4
4
  "description": "Lotics SDK and CLI for AI agents",
5
5
  "type": "module",
6
6
  "bin": {