@sincpro/web-framework 3.18.0 → 3.20.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.
Files changed (68) hide show
  1. package/README.md +83 -54
  2. package/dist/core/copy.d.ts +14 -0
  3. package/dist/core/copy.js +57 -2
  4. package/dist/core/edit.d.ts +13 -0
  5. package/dist/core/edit.js +14 -0
  6. package/dist/core/explain.d.ts +4 -0
  7. package/dist/core/explain.js +4 -0
  8. package/dist/core/export.d.ts +29 -0
  9. package/dist/core/export.js +47 -0
  10. package/dist/core/groups.d.ts +3 -1
  11. package/dist/core/groups.js +7 -0
  12. package/dist/core/index.d.ts +4 -3
  13. package/dist/core/index.js +4 -3
  14. package/dist/core/lines.d.ts +10 -0
  15. package/dist/core/lines.js +24 -0
  16. package/dist/core/list.d.ts +12 -0
  17. package/dist/react/context.d.ts +44 -1
  18. package/dist/react/context.js +50 -1
  19. package/dist/react/index.d.ts +4 -2
  20. package/dist/react/index.js +4 -2
  21. package/dist/react/useCounts.d.ts +23 -0
  22. package/dist/react/useCounts.js +43 -0
  23. package/dist/react/useGroups.js +38 -5
  24. package/dist/react/useNameOf.d.ts +13 -0
  25. package/dist/react/useNameOf.js +32 -0
  26. package/dist/react/usePeopleOf.d.ts +14 -0
  27. package/dist/react/usePeopleOf.js +35 -0
  28. package/dist/react/useRecord.js +2 -2
  29. package/dist/react/useServiceReading.d.ts +8 -0
  30. package/dist/react/useServiceReading.js +12 -2
  31. package/dist/web/index.d.ts +4 -2
  32. package/dist/web/index.js +4 -2
  33. package/dist/web/list/EntityList.d.ts +36 -177
  34. package/dist/web/list/EntityList.js +175 -536
  35. package/dist/web/list/entityList/choosing.d.ts +50 -0
  36. package/dist/web/list/entityList/choosing.js +77 -0
  37. package/dist/web/list/entityList/faces.d.ts +53 -0
  38. package/dist/web/list/entityList/faces.js +155 -0
  39. package/dist/web/list/entityList/grouping.d.ts +50 -0
  40. package/dist/web/list/entityList/grouping.js +97 -0
  41. package/dist/web/list/entityList/opening.d.ts +68 -0
  42. package/dist/web/list/entityList/opening.js +149 -0
  43. package/dist/web/list/entityList/paging.d.ts +30 -0
  44. package/dist/web/list/entityList/paging.js +39 -0
  45. package/dist/web/list/entityList/props.d.ts +174 -0
  46. package/dist/web/list/entityList/props.js +16 -0
  47. package/dist/web/list/entityList/rowActions.d.ts +31 -0
  48. package/dist/web/list/entityList/rowActions.js +40 -0
  49. package/dist/web/list/export.d.ts +13 -0
  50. package/dist/web/list/export.js +61 -0
  51. package/dist/web/list/groups.d.ts +16 -0
  52. package/dist/web/list/groups.js +39 -0
  53. package/dist/web/list/useEntityList.d.ts +183 -0
  54. package/dist/web/list/useEntityList.js +225 -0
  55. package/dist/web/parts.d.ts +42 -0
  56. package/dist/web/parts.js +88 -0
  57. package/dist/web/record/lines.d.ts +3 -0
  58. package/dist/web/record/lines.js +75 -9
  59. package/dist/web/workspace/RecordScreen.d.ts +206 -0
  60. package/dist/web/workspace/RecordScreen.js +251 -0
  61. package/dist/web/workspace/SincproApp.d.ts +14 -2
  62. package/dist/web/workspace/SincproApp.js +27 -9
  63. package/dist/web/workspace/composer.js +1 -1
  64. package/dist/web/workspace/record.d.ts +21 -27
  65. package/dist/web/workspace/record.js +29 -77
  66. package/dist/web/workspace/workspace.d.ts +2 -0
  67. package/dist/web/workspace/workspace.js +1 -1
  68. package/package.json +7 -7
package/README.md CHANGED
@@ -33,11 +33,12 @@ be able to build it here, without asking us and without fighting us. So:
33
33
 
34
34
  1. **Defaults, never cages.** Every piece comes in three levels, and any of them can be skipped:
35
35
 
36
- | Level | What you write | Example |
37
- | ------------ | ------------------------------------------- | ---------------------------------------------------------- |
38
- | Declarative | names of fields and entities | `<EntityList listing={l} columns={["number", "state"]} />` |
39
- | Hooks | your own screen over our state | `useListing` + web-ui's `List` |
40
- | Loose pieces | straight to criteria, the transport, web-ui | `transport.list(route, criteria)` |
36
+ | Level | What you write | Example |
37
+ | ------------ | ------------------------------------------- | ------------------------------------------------------------------ |
38
+ | Declarative | names of fields and entities | `<EntityList listing={l} columns={["number", "state"]} />` |
39
+ | Parts | one region of the screen is yours | `<EntityList listing={l}><EntityList.Bar /><MyMap /></EntityList>` |
40
+ | Hooks | your own screen over our state | `useListing` + web-ui's `List` |
41
+ | Loose pieces | straight to criteria, the transport, web-ui | `transport.list(route, criteria)` |
41
42
 
42
43
  Adding a piece obliges nothing else; removing it breaks nothing else.
43
44
 
@@ -272,7 +273,25 @@ const views = [
272
273
  ```
273
274
 
274
275
  They are defaults, not cages: give your own screens, or keep `EntityRecord` and choose what it
275
- shows.
276
+ shows. A screen of your own is written with the framework's **parts** — what is not written is
277
+ not there, a part written empty is the framework's, and a block of yours reads the record with
278
+ `useScreenRecord` (the list: `EntityList.*` and `useScreenListing`; see `docs/PATTERNS.md`):
279
+
280
+ ```tsx
281
+ function InvoiceView(props: ViewProps) {
282
+ return (
283
+ <RecordScreen entity={invoices} {...props}>
284
+ <RecordScreen.Rail />
285
+ <RecordScreen.Paper>
286
+ <RecordScreen.Notices />
287
+ <InvoiceTotals /> {/* useScreenRecord(invoices) */}
288
+ <RecordScreen.Fields names={["customer_id", "due_date"]} />
289
+ <RecordScreen.Audit />
290
+ </RecordScreen.Paper>
291
+ </RecordScreen>
292
+ );
293
+ }
294
+ ```
276
295
 
277
296
  ```ts
278
297
  const views = [
@@ -683,54 +702,64 @@ find .next/static -name '*.map' -delete
683
702
  Each answers one question, and each comes in the three levels — use the component, drop to the
684
703
  hook and draw your own, or go straight to the loose piece.
685
704
 
686
- | Question | Declarative | Hook | Loose piece |
687
- | -------------------------------- | --------------------------------------------------------------- | ------------------------------------- | ----------------------------------------------------------- |
688
- | Where is the data? | `entity()` (client-framework) | — | `restTransport`, `memoryTransport` |
689
- | The application's logic | its `Feature`s and `ApplicationService`s (client-framework) | `useService` | `project.Issues.close(…)` |
690
- | Read through a use case | its `Feature`s (client-framework) | `useServiceReading` | `project.Accounts.balance(…)` |
691
- | Read it on the server first | the same use case, before the page is drawn | `useServiceReading(…, { initial })` | `readOnServer`, `ServerRead` |
692
- | A record read on the server | `EntityRecord initial` | `useRecord(…, { initial })` | `readRecordOnServer`, `RecordRead` |
693
- | What every use case runs with | `processContext`, `project.context` (client-framework) | `useContextValues` | `ContextStore` |
694
- | What happened, what broke | `./telemetry`, `./errors` (optional) | — | `configureProcess({ tracer, reporter })` |
695
- | What happened, on the server | `configureServerProcess` (`./telemetry/server`, optional) | — | `registerServerTracing`, `serverTracer` |
696
- | What broke, on the server | `reportRequestError` (`./errors/server`, optional) | — | `registerServerErrors`, `serverReporter` |
697
- | A page that broke | `RouteError`, in the route's error boundary | — | `reportError` (client-framework) |
698
- | What is each field? | `Meta` from the server, or `defineMeta` | — | `textOf`, `viewOf`, `metaFromSchema` |
699
- | A value outside a model | — | `useTextOf` | `moneyTextOf`, `dayTextOf`, `instantTextOf`, `numberTextOf` |
700
- | A file or a photo it holds | `EntityList`, `RecordField`: by its widget, as a `FileValue` | — | `attachmentOf`, `storedFileOf`, `renditionUrl` |
701
- | A file given in the record | `RecordField` with `uploads`: `FileControl` (`DropZone`) | `useUpload` | `sendFile`, `uploadRefusalOf` |
702
- | Formatted text | `RecordField` (`widget: "html"`), `factsOf`: `RichTextControl` | — | `richTextPlainOf`, `holdsRichText` |
703
- | A person, read | `RecordField`, `factsOf`: `PersonValue` (`UserChip`) | `useSummaryOf` | `isPersonEntity` |
704
- | A choice's tag outside a list | `ChoiceTag` | — | `choiceTagOf` |
705
- | What is a record, at any size? | `cardOf`, `relationOf` | `useSummaryOf` | `summaryOf` |
706
- | How does a record look? | `presented(entity, { option, row, card, tile })` | — | `presentationOf` |
707
- | N records: search, filter, page | `EntityList`, `EntitySearchBar` | `useListing`, `useGroups` | `transport.list(route, criteria)` |
708
- | A named slice (to collect, …) | `defineList` + `listView` | `useListing(list)` | `scopeOf` |
709
- | A record's whole screen | `EntityRecord`, `entityView` without `record` | `useRecordScreen` | `formOf` |
710
- | Previous / next from a record | `EntityRecord` (from a list) | — | `placeOf`, `stepIn` (`Trail`) |
711
- | How much each group adds up | `EntityList sums` | `useGroups` (`sums`) | `sumsOf`, `detailOf` |
712
- | One record: read, edit, save | `RecordField`, `factsOf`, `RecordLines` | `useRecord` | `transport.one`, `transport.send` |
713
- | Its lines: add, edit, remove | `RecordField name="lines"` (`LineItems`) | `useRecord` (`edit.cell`, `errorAt`) | `lineKey`, `editableLines`, `pathOf` |
714
- | Its relations, inside it | `RelatedList` | `useRelated` | `relatedOf` |
715
- | What other records hold of it | web-ui's `SmartButton` opening `entity.listRef(cut, name)` | `useCount` | `entity.listRef` (client-framework) |
716
- | Choose one (literal search) | `EntityPicker`, `chooserIn` | `useLookup` | `lookupOf` + criteria's `matching` |
717
- | Choose several (many2many) | `EntityTags` | `useLookup` (`values`) | `lookupOf` |
718
- | A relation, from the model alone | `RecordField name="customer_id"` | `useEntityFor` | `relationFieldOf`, `entityFor` |
719
- | Open it where it belongs | `RelatedRecord`, `entityView`, `EntityList openTargets` | — | `openIn`, `targetsFor`, `OpenInMenu` |
720
- | Look at the set several ways | `EntityList views` (table, rows, board, sheet, tiles) | — | web-ui's `List.*` |
721
- | Cross it by two fields | `EntityList pivot` | `usePivot` | `pivotOf` |
722
- | Order by several fields | the bar's criteria builder | `listing.orderBy([...])` | criteria's `order` |
723
- | Act on it (with a dry run) | `ServiceButton` (a use case), `CommandButton`, row commands | `useService`, `useCommand` | `transport.send` |
724
- | What is chosen in a list | `EntityList selectable selection` | `useSelection` | `Selection`, `chosen`, `allMatching` (client-framework) |
725
- | Act on each chosen one | `BatchProgress`, `selectionActions={(chosen) => …}` | `useBatchCommand` | `runBatch`, `keysOf` (client-framework), `sendRoute` |
726
- | A list's actions, by the style | `EntityList actions`, `selectionActions` (`DockAction`s) | — | web-ui's `List.Dock`, `ViewStyleProvider` |
727
- | A record's actions, by the style | `EntityRecord actions`, web-ui's `Record.Dock` | `useRecordLifecycleActions` | `DockedAction`, `ActionLook` |
728
- | A use case or a Command, there | `ServiceButton`, `CommandButton` (as buttons) | `useServiceAction`/`useCommandAction` | — |
729
- | Delete it | `EntityRecord` (`RecordLifecycle`) | `useRecordLifecycle` | `entity.delete`, `useRouteCommand` |
730
- | Its trash | `EntityRecord` (`RecordLifecycle`), `listView(trashOf(entity))` | `useRecordLifecycle` | `entity.archive`, `entity.restore`, `trashOf` |
731
- | Read again when it was written | every reading of this package, by itself | `useWrites` | `processChanges` (client-framework) |
732
- | What happened to it | `Record.Activity` fed by `useHistory` | `useHistory` | `historyOf` |
733
- | The application context | `SincproApp` | `useRecordInWorkspace`, `useFollowed` | `FrameworkProvider`, `webUiSkin` |
705
+ | Question | Declarative | Hook | Loose piece |
706
+ | -------------------------------- | -------------------------------------------------------------------------- | ------------------------------------- | ------------------------------------------------------------ |
707
+ | Where is the data? | `entity()` (client-framework) | — | `restTransport`, `memoryTransport` |
708
+ | The application's logic | its `Feature`s and `ApplicationService`s (client-framework) | `useService` | `project.Issues.close(…)` |
709
+ | Read through a use case | its `Feature`s (client-framework) | `useServiceReading` | `project.Accounts.balance(…)` |
710
+ | Read it on the server first | the same use case, before the page is drawn | `useServiceReading(…, { initial })` | `readOnServer`, `ServerRead` |
711
+ | A record read on the server | `EntityRecord initial` | `useRecord(…, { initial })` | `readRecordOnServer`, `RecordRead` |
712
+ | What every use case runs with | `processContext`, `project.context` (client-framework) | `useContextValues` | `ContextStore` |
713
+ | What happened, what broke | `./telemetry`, `./errors` (optional) | — | `configureProcess({ tracer, reporter })` |
714
+ | What happened, on the server | `configureServerProcess` (`./telemetry/server`, optional) | — | `registerServerTracing`, `serverTracer` |
715
+ | What broke, on the server | `reportRequestError` (`./errors/server`, optional) | — | `registerServerErrors`, `serverReporter` |
716
+ | A page that broke | `RouteError`, in the route's error boundary | — | `reportError` (client-framework) |
717
+ | What is each field? | `Meta` from the server, or `defineMeta` | — | `textOf`, `viewOf`, `metaFromSchema` |
718
+ | A value outside a model | — | `useTextOf` | `moneyTextOf`, `dayTextOf`, `instantTextOf`, `numberTextOf` |
719
+ | A file or a photo it holds | `EntityList`, `RecordField`: by its widget, as a `FileValue` | — | `attachmentOf`, `storedFileOf`, `renditionUrl` |
720
+ | A file given in the record | `RecordField` with `uploads`: `FileControl` (`DropZone`) | `useUpload` | `sendFile`, `uploadRefusalOf` |
721
+ | Formatted text | `RecordField` (`widget: "html"`), `factsOf`: `RichTextControl` | — | `richTextPlainOf`, `holdsRichText` |
722
+ | A person, read | `RecordField`, `factsOf`: `PersonValue` (`UserChip`) | `useSummaryOf` | `isPersonEntity` |
723
+ | A choice's tag outside a list | `ChoiceTag` | — | `choiceTagOf` |
724
+ | What is a record, at any size? | `cardOf`, `relationOf` | `useSummaryOf` | `summaryOf` |
725
+ | How does a record look? | `presented(entity, { option, row, card, tile })` | — | `presentationOf` |
726
+ | N records: search, filter, page | `EntityList`, `EntitySearchBar` | `useListing`, `useGroups` | `transport.list(route, criteria)` |
727
+ | A named slice (to collect, …) | `defineList` + `listView` | `useListing(list)` | `scopeOf` |
728
+ | A record's whole screen | `EntityRecord`, `entityView` without `record` | `useRecordScreen` | `formOf` |
729
+ | One region of a record screen | `RecordScreen.*` (`Rail`, `Paper`, `Fields`, `Pages`, `Audit`…) | `useScreenRecord` | web-ui's `Record.*` |
730
+ | One region of a list | `EntityList.*` (`Bar`, `Search`, `Table`, `Board`, `Pager`…) | `useScreenListing`, `useEntityList` | web-ui's `List.*` |
731
+ | The models a face brings | `ModelDefinitions entities metas events`; `SincproApp` without `transport` | — | `metasOf`, `eventMetasOf` (client-framework) |
732
+ | What a record screen says of it | `RecordScreen title subtitle tag creating moment actions` | `useRecordScreen` (same options) | web-ui's `Record identity`, `Record.Dock moment` |
733
+ | What hangs off a record, counted | `RecordScreen links` (`RelatedLink`: entity, `where`, title) | `useCounts` | `listRef` |
734
+ | A block laid out as the form | — | `useScreenColumns` | — |
735
+ | Who is who in a history | `SincproApp people`, `FrameworkProvider people`, `ModelDefinitions people` | `usePeopleOf` | the application's use case |
736
+ | «New» in the business's words | `EntityList create="Nueva noticia"` | — | `canCreate` (`create` or `Edit`) |
737
+ | The list as a spreadsheet | `EntityList` «Exportar» (the entity's `export`) | — | `csvOf`, `exportColumnsOf`; `exportRoute` (client-framework) |
738
+ | Spanish in tú | `SincproApp voice="tú"` | — | `SPANISH_FRAMEWORK_COPY_TU`, web-ui's `SPANISH_COPY_TU` |
739
+ | Previous / next from a record | `EntityRecord` (from a list) | — | `placeOf`, `stepIn` (`Trail`) |
740
+ | How much each group adds up | `EntityList sums` | `useGroups` (`sums`) | `sumsOf`, `detailOf` |
741
+ | One record: read, edit, save | `RecordField`, `factsOf`, `RecordLines` | `useRecord` | `transport.one`, `transport.send` |
742
+ | Its lines: add, edit, remove | `RecordField name="lines"` (`LineItems`) | `useRecord` (`edit.cell`, `errorAt`) | `lineKey`, `editableLines`, `pathOf` |
743
+ | Its relations, inside it | `RelatedList` | `useRelated` | `relatedOf` |
744
+ | What other records hold of it | web-ui's `SmartButton` opening `entity.listRef(cut, name)` | `useCount` | `entity.listRef` (client-framework) |
745
+ | Choose one (literal search) | `EntityPicker`, `chooserIn` | `useLookup` | `lookupOf` + criteria's `matching` |
746
+ | Choose several (many2many) | `EntityTags` | `useLookup` (`values`) | `lookupOf` |
747
+ | A relation, from the model alone | `RecordField name="customer_id"` | `useEntityFor` | `relationFieldOf`, `entityFor` |
748
+ | Open it where it belongs | `RelatedRecord`, `entityView`, `EntityList openTargets` | — | `openIn`, `targetsFor`, `OpenInMenu` |
749
+ | Look at the set several ways | `EntityList views` (table, rows, board, sheet, tiles) | — | web-ui's `List.*` |
750
+ | Cross it by two fields | `EntityList pivot` | `usePivot` | `pivotOf` |
751
+ | Order by several fields | the bar's criteria builder | `listing.orderBy([...])` | criteria's `order` |
752
+ | Act on it (with a dry run) | `ServiceButton` (a use case), `CommandButton`, row commands | `useService`, `useCommand` | `transport.send` |
753
+ | What is chosen in a list | `EntityList selectable selection` | `useSelection` | `Selection`, `chosen`, `allMatching` (client-framework) |
754
+ | Act on each chosen one | `BatchProgress`, `selectionActions={(chosen) => …}` | `useBatchCommand` | `runBatch`, `keysOf` (client-framework), `sendRoute` |
755
+ | A list's actions, by the style | `EntityList actions`, `selectionActions` (`DockAction`s) | — | web-ui's `List.Dock`, `ViewStyleProvider` |
756
+ | A record's actions, by the style | `EntityRecord actions`, web-ui's `Record.Dock` | `useRecordLifecycleActions` | `DockedAction`, `ActionLook` |
757
+ | A use case or a Command, there | `ServiceButton`, `CommandButton` (as buttons) | `useServiceAction`/`useCommandAction` | — |
758
+ | Delete it | `EntityRecord` (`RecordLifecycle`) | `useRecordLifecycle` | `entity.delete`, `useRouteCommand` |
759
+ | Its trash | `EntityRecord` (`RecordLifecycle`), `listView(trashOf(entity))` | `useRecordLifecycle` | `entity.archive`, `entity.restore`, `trashOf` |
760
+ | Read again when it was written | every reading of this package, by itself | `useWrites` | `processChanges` (client-framework) |
761
+ | What happened to it | `Record.Activity` fed by `useHistory` | `useHistory` | `historyOf` |
762
+ | The application context | `SincproApp` | `useRecordInWorkspace`, `useFollowed` | `FrameworkProvider`, `webUiSkin` |
734
763
 
735
764
  The rules behind them, in short:
736
765
 
@@ -24,6 +24,8 @@ export type FrameworkCopy = {
24
24
  empty: string;
25
25
  emptyFiltered: string;
26
26
  search: string;
27
+ /** The list's records, filtered and ordered as on screen, as a spreadsheet. */
28
+ export: string;
27
29
  /** The search bar, which also takes `#` to pick a field. */
28
30
  searchBar: string;
29
31
  /** The title of the criteria builder's window. */
@@ -66,6 +68,8 @@ export type FrameworkCopy = {
66
68
  create: string;
67
69
  /** A record's one2many: the button that opens the form of a new related record. */
68
70
  add: string;
71
+ /** Under a record's lines: choose several records, one new line for each. */
72
+ addMany: string;
69
73
  /** The record's own `Delete` (its dry run is shown before it runs). */
70
74
  delete: string;
71
75
  /** Into the entity's trash (`Archive`): out of every reading, nothing lost. */
@@ -177,4 +181,14 @@ export declare const frameworkCopy: () => FrameworkCopy;
177
181
  export declare const routeCopy: () => RouteCopy;
178
182
  /** The words of a file not taken: the installed table's, or English when it has none. */
179
183
  export declare const uploadCopy: () => UploadCopy;
184
+ /**
185
+ * The framework's Spanish in tú — what most of the region writes (Bolivia, Perú, México…);
186
+ * `SPANISH_FRAMEWORK_COPY` is in vos, as Argentina and Uruguay write. Installed with web-ui's
187
+ * `SPANISH_COPY_TU` (`SincproApp voice="tú"`): two voices on one screen read as two authors.
188
+ *
189
+ * Only what is said TO the person changes; every other word is the vos table's, so the two never
190
+ * drift. A new sentence that tells the person to do something goes in both
191
+ * (`tests/voice.test.ts`).
192
+ */
193
+ export declare const SPANISH_FRAMEWORK_COPY_TU: FrameworkCopy;
180
194
  export {};
package/dist/core/copy.js CHANGED
@@ -28,6 +28,7 @@ export const ENGLISH_FRAMEWORK_COPY = {
28
28
  empty: "Nothing here yet.",
29
29
  emptyFiltered: "Nothing matches.",
30
30
  search: "Search",
31
+ export: "Export",
31
32
  searchBar: "Search, or # to pick a field…",
32
33
  builder: "Criteria builder",
33
34
  capped: (shown) => `Showing the first ${shown}. Narrow the search to see the rest.`,
@@ -50,6 +51,7 @@ export const ENGLISH_FRAMEWORK_COPY = {
50
51
  creating: (name) => (name ? `${name} · new` : "New"),
51
52
  create: "New",
52
53
  add: "Add",
54
+ addMany: "Add several…",
53
55
  delete: "Delete",
54
56
  archive: "Move to the trash",
55
57
  restore: "Restore",
@@ -93,7 +95,7 @@ export const ENGLISH_FRAMEWORK_COPY = {
93
95
  retry: "Retry",
94
96
  kind: {
95
97
  invalid: "The request is not valid",
96
- unauthenticated: "Sign in again",
98
+ unauthenticated: "We could not identify you",
97
99
  permission_denied: "You do not have access",
98
100
  not_found: "It does not exist",
99
101
  conflict: "Someone changed it first",
@@ -106,6 +108,7 @@ export const ENGLISH_FRAMEWORK_COPY = {
106
108
  internal: "Something failed on the server",
107
109
  },
108
110
  next: {
111
+ unauthenticated: "If the session expired, sign in again.",
109
112
  permission_denied: "Ask whoever administers it for access.",
110
113
  not_found: "It may have been deleted, or the link is old.",
111
114
  conflict: "Read it again before changing it.",
@@ -134,6 +137,7 @@ export const SPANISH_FRAMEWORK_COPY = {
134
137
  empty: "Todavía no hay nada.",
135
138
  emptyFiltered: "Nada coincide.",
136
139
  search: "Buscar",
140
+ export: "Exportar",
137
141
  searchBar: "Buscar, o # para elegir el campo…",
138
142
  builder: "Constructor de criteria",
139
143
  capped: (shown) => `Se muestran los primeros ${shown}. Refiná la búsqueda para ver el resto.`,
@@ -156,6 +160,7 @@ export const SPANISH_FRAMEWORK_COPY = {
156
160
  creating: (name) => (name ? `${name} · nuevo` : "Nuevo"),
157
161
  create: "Nuevo",
158
162
  add: "Agregar",
163
+ addMany: "Agregar varios…",
159
164
  delete: "Eliminar",
160
165
  archive: "Mover a la papelera",
161
166
  restore: "Restaurar",
@@ -199,7 +204,7 @@ export const SPANISH_FRAMEWORK_COPY = {
199
204
  retry: "Reintentar",
200
205
  kind: {
201
206
  invalid: "El pedido no es válido",
202
- unauthenticated: "Volvé a iniciar sesión",
207
+ unauthenticated: "No pudimos identificarte",
203
208
  permission_denied: "No tenés acceso",
204
209
  not_found: "No existe",
205
210
  conflict: "Alguien lo cambió antes",
@@ -212,6 +217,7 @@ export const SPANISH_FRAMEWORK_COPY = {
212
217
  internal: "Algo falló en el servidor",
213
218
  },
214
219
  next: {
220
+ unauthenticated: "Si la sesión venció, hay que iniciarla de nuevo.",
215
221
  permission_denied: "Pedí acceso a quien lo administra.",
216
222
  not_found: "Puede que lo hayan eliminado, o el enlace es viejo.",
217
223
  conflict: "Volvé a leerlo antes de cambiarlo.",
@@ -251,3 +257,52 @@ export const frameworkCopy = () => installed;
251
257
  export const routeCopy = () => installed.route ?? ENGLISH_ROUTE;
252
258
  /** The words of a file not taken: the installed table's, or English when it has none. */
253
259
  export const uploadCopy = () => installed.upload ?? ENGLISH_UPLOAD;
260
+ /**
261
+ * The framework's Spanish in tú — what most of the region writes (Bolivia, Perú, México…);
262
+ * `SPANISH_FRAMEWORK_COPY` is in vos, as Argentina and Uruguay write. Installed with web-ui's
263
+ * `SPANISH_COPY_TU` (`SincproApp voice="tú"`): two voices on one screen read as two authors.
264
+ *
265
+ * Only what is said TO the person changes; every other word is the vos table's, so the two never
266
+ * drift. A new sentence that tells the person to do something goes in both
267
+ * (`tests/voice.test.ts`).
268
+ */
269
+ export const SPANISH_FRAMEWORK_COPY_TU = {
270
+ ...SPANISH_FRAMEWORK_COPY,
271
+ list: {
272
+ ...SPANISH_FRAMEWORK_COPY.list,
273
+ capped: (shown) => `Se muestran los primeros ${shown}. Refina la búsqueda para ver el resto.`,
274
+ groupsCapped: (shown) => `Los primeros ${shown} grupos. Acota la búsqueda para ver el resto.`,
275
+ },
276
+ record: {
277
+ ...SPANISH_FRAMEWORK_COPY.record,
278
+ restored: "Volvió un borrador que guardaste. Guárdalo o descártalo.",
279
+ conflict: "Alguien guardó este registro después de que lo abriste. No se pisó nada: vuelve a leerlo.",
280
+ },
281
+ batch: {
282
+ ...SPANISH_FRAMEWORK_COPY.batch,
283
+ tooMany: (size, limit) => `${size === null ? "Son más de " + limit : "Son " + size} registros elegidos; a la vez, como mucho ${limit}. Acota la búsqueda.`,
284
+ },
285
+ failure: {
286
+ ...SPANISH_FRAMEWORK_COPY.failure,
287
+ kind: { ...SPANISH_FRAMEWORK_COPY.failure.kind, permission_denied: "No tienes acceso" },
288
+ next: {
289
+ ...SPANISH_FRAMEWORK_COPY.failure.next,
290
+ permission_denied: "Pide acceso a quien lo administra.",
291
+ conflict: "Vuelve a leerlo antes de cambiarlo.",
292
+ in_progress: "Espera un momento y vuelve a mirar.",
293
+ key_reused: "Vuelve a leerlo para ver si se hizo.",
294
+ exhausted: "Espera un momento y reintenta.",
295
+ unavailable: "Reintenta en unos minutos.",
296
+ unknown_outcome: "Vuelve a leerlo antes de repetirlo.",
297
+ internal: "Si vuelve a pasar, avisa a soporte.",
298
+ },
299
+ },
300
+ upload: {
301
+ ...(SPANISH_FRAMEWORK_COPY.upload ?? ENGLISH_UPLOAD),
302
+ expired: "La subida tardó demasiado. Elige el archivo de nuevo.",
303
+ },
304
+ route: {
305
+ ...(SPANISH_FRAMEWORK_COPY.route ?? ENGLISH_ROUTE),
306
+ sentence: "No es algo que hayas hecho. Intenta de nuevo; si vuelve a pasar, avisa a soporte.",
307
+ },
308
+ };
@@ -107,6 +107,19 @@ export declare function defaultsOf(meta: Meta | null | undefined): AnyRecord;
107
107
  * the stored record. Both travel.
108
108
  */
109
109
  export declare function creationOf(meta: Meta | null | undefined, values: AnyRecord): AnyRecord;
110
+ /**
111
+ * Whether a new record of `entity` can be stored: by its `create`, or by sincpro_framework's
112
+ * `Edit` under a key the client mints (`newEntityId`) — `Edit` names a record by `id`, so only a
113
+ * model keyed by `id`; one keyed by another field (an invoice's number, the server's to give) is
114
+ * created through `create` alone.
115
+ *
116
+ * Context: a list offered «Nuevo» only for `create`, while the record screen it opened could
117
+ * create through `Edit`: an application that speaks `Edit` wrote its own «Nuevo» (quipu).
118
+ */
119
+ export declare function canCreate(entity: {
120
+ create?: unknown;
121
+ edit?: unknown;
122
+ }, meta: Meta | null | undefined): boolean;
110
123
  /**
111
124
  * What an edit of a STORED record sends (sincpro_framework's `Edit`): the fields the person
112
125
  * changed, and inside them nothing the model marks `readonly` — a line keeps only its identity,
package/dist/core/edit.js CHANGED
@@ -183,6 +183,20 @@ export function creationOf(meta, values) {
183
183
  }
184
184
  return sent;
185
185
  }
186
+ /**
187
+ * Whether a new record of `entity` can be stored: by its `create`, or by sincpro_framework's
188
+ * `Edit` under a key the client mints (`newEntityId`) — `Edit` names a record by `id`, so only a
189
+ * model keyed by `id`; one keyed by another field (an invoice's number, the server's to give) is
190
+ * created through `create` alone.
191
+ *
192
+ * Context: a list offered «Nuevo» only for `create`, while the record screen it opened could
193
+ * create through `Edit`: an application that speaks `Edit` wrote its own «Nuevo» (quipu).
194
+ */
195
+ export function canCreate(entity, meta) {
196
+ if (entity.create !== undefined)
197
+ return true;
198
+ return entity.edit !== undefined && (meta?.get_id || meta?.identity || "id") === "id";
199
+ }
186
200
  /**
187
201
  * What an edit of a STORED record sends (sincpro_framework's `Edit`): the fields the person
188
202
  * changed, and inside them nothing the model marks `readonly` — a line keeps only its identity,
@@ -15,6 +15,10 @@
15
15
  * default `guidance` too — so the heading and the generic next step are the copy's, and the
16
16
  * server's words are kept where only it knows them: what happened, and how to fix a refusal of
17
17
  * its own. quipu drew its own box because the server's English headed every refusal.
18
+ *
19
+ * `unauthenticated` has a fixed next step too: the server's default guidance for it is English,
20
+ * and appended it mixed two languages in one sentence. Its heading does not assume an expired
21
+ * session — on a sign-in form a 401 answers the credentials just typed.
18
22
  */
19
23
  export declare function explain(error: unknown): {
20
24
  heading: string;
@@ -18,6 +18,10 @@ import { NotGrouped } from "./groups.js";
18
18
  * default `guidance` too — so the heading and the generic next step are the copy's, and the
19
19
  * server's words are kept where only it knows them: what happened, and how to fix a refusal of
20
20
  * its own. quipu drew its own box because the server's English headed every refusal.
21
+ *
22
+ * `unauthenticated` has a fixed next step too: the server's default guidance for it is English,
23
+ * and appended it mixed two languages in one sentence. Its heading does not assume an expired
24
+ * session — on a sign-in form a 401 answers the credentials just typed.
21
25
  */
22
26
  export function explain(error) {
23
27
  const copy = frameworkCopy().failure;
@@ -0,0 +1,29 @@
1
+ import type { Meta } from "@sincpro/criteria";
2
+ /**
3
+ * A list exported for a person: the records of the list's question — its filter and its order —
4
+ * as the server exports them (JSON Lines), written as a CSV a spreadsheet opens the region's way.
5
+ *
6
+ * const csv = csvOf(jsonLines, exportColumnsOf(meta, "es"), "es-BO");
7
+ * // BOM + "Número;Cliente;Total\nF-2026-0001;Globex Bolivia;1150,50\n…"
8
+ *
9
+ * Context: sincpro_framework exports Parquet, Arrow or JSON Lines (web-framework#32) — formats for
10
+ * analysis. Whoever asks «export it for the accountant» opens a spreadsheet: a CSV with the
11
+ * model's words as its headers. Where the region writes a decimal comma (`es-BO`: «1150,50»), a
12
+ * spreadsheet expects `;` between cells, so that is what is written; a BOM in front keeps the
13
+ * accents. A value is written as it is — a number without thousands, a day as `2026-11-30` —: a
14
+ * spreadsheet reads them as numbers and dates, not as text a person typed.
15
+ */
16
+ /** One column of an export: the field it reads, and the header a person reads. */
17
+ export type ExportColumn = {
18
+ field: string;
19
+ label: string;
20
+ };
21
+ /** The model's fields a list shows, each headed by its label in `locale`. */
22
+ export declare function exportColumnsOf(meta: Meta | null | undefined, locale?: string): ExportColumn[];
23
+ /** How the region writes a decimal: «,» in `es-BO`, «.» in `en-US`. */
24
+ export declare function decimalOf(region: string | undefined): string;
25
+ /**
26
+ * The CSV of JSON Lines — one record per line, blank lines skipped —: the headers, then a row per
27
+ * record with each column's value.
28
+ */
29
+ export declare function csvOf(jsonLines: Iterable<string>, columns: readonly ExportColumn[], region: string | undefined): string;
@@ -0,0 +1,47 @@
1
+ import { labelOf } from "@sincpro/criteria";
2
+ import { frameworkCopy } from "./copy.js";
3
+ import { defaultFields } from "./present.js";
4
+ /** The model's fields a list shows, each headed by its label in `locale`. */
5
+ export function exportColumnsOf(meta, locale) {
6
+ return defaultFields(meta).map((field) => ({ field, label: labelOf(meta, field, locale) }));
7
+ }
8
+ /** How the region writes a decimal: «,» in `es-BO`, «.» in `en-US`. */
9
+ export function decimalOf(region) {
10
+ return (1.5).toLocaleString(region).includes(",") ? "," : ".";
11
+ }
12
+ /** In front of the file: a spreadsheet reads it as UTF-8, and the accents stay. */
13
+ const BOM = String.fromCharCode(0xfeff);
14
+ /** One cell: quoted when it holds the separator, a quote or a line break. */
15
+ function cellOf(value, separator, decimal) {
16
+ const copy = frameworkCopy().value;
17
+ const text = value === null || value === undefined
18
+ ? ""
19
+ : typeof value === "number"
20
+ ? String(value).replace(".", decimal)
21
+ : typeof value === "boolean"
22
+ ? value
23
+ ? copy.yes
24
+ : copy.no
25
+ : typeof value === "object"
26
+ ? JSON.stringify(value)
27
+ : String(value);
28
+ return /["\n\r]/.test(text) || text.includes(separator)
29
+ ? `"${text.replaceAll('"', '""')}"`
30
+ : text;
31
+ }
32
+ /**
33
+ * The CSV of JSON Lines — one record per line, blank lines skipped —: the headers, then a row per
34
+ * record with each column's value.
35
+ */
36
+ export function csvOf(jsonLines, columns, region) {
37
+ const decimal = decimalOf(region);
38
+ const separator = decimal === "," ? ";" : ",";
39
+ const rows = [columns.map((one) => cellOf(one.label, separator, decimal)).join(separator)];
40
+ for (const line of jsonLines) {
41
+ if (line.trim() === "")
42
+ continue;
43
+ const record = JSON.parse(line);
44
+ rows.push(columns.map((one) => cellOf(record[one.field], separator, decimal)).join(separator));
45
+ }
46
+ return `${BOM}${rows.join("\n")}\n`;
47
+ }
@@ -1,4 +1,4 @@
1
- import type { AnyRecord, Bucket, Criteria, Measure } from "@sincpro/criteria";
1
+ import { type AnyRecord, type Bucket, type Criteria, type Measure, type Sort } from "@sincpro/criteria";
2
2
  import type { GroupLevel } from "./list.js";
3
3
  /**
4
4
  * Whether an answer to a grouped question holds groups — each with how many records it holds
@@ -55,6 +55,8 @@ export type GroupPage = {
55
55
  export declare function levelQuestion<T extends AnyRecord>(base: Criteria<T>, level: GroupLevel, page: GroupPage, options?: {
56
56
  measures?: Readonly<Record<string, Measure>>;
57
57
  counted?: boolean;
58
+ /** How the groups come back; only what orders THIS level is asked (see below). */
59
+ order?: readonly Sort<T>[];
58
60
  }): Criteria<T>;
59
61
  /**
60
62
  * The question for the rows of a group of the deepest level: its own criteria, a page of rows.
@@ -1,3 +1,4 @@
1
+ import { GROUP_COUNT, } from "@sincpro/criteria";
1
2
  import { frameworkCopy } from "./copy.js";
2
3
  /**
3
4
  * Whether an answer to a grouped question holds groups — each with how many records it holds
@@ -62,6 +63,11 @@ export function levelQuestion(base, level, page, options = {}) {
62
63
  // question that made it (its empty grouping, its page of no rows).
63
64
  const { pagination: _page, grouping: _grouping, count: _count, ...own } = base;
64
65
  const offset = page.offset ?? 0;
66
+ // A level's groups are ordered by its own field, a figure it adds up or its count: any other
67
+ // name is refused by the server, so another level's sort is not sent with this one.
68
+ const order = (options.order ?? []).filter((one) => one.field === level.field ||
69
+ one.field === GROUP_COUNT ||
70
+ (options.measures !== undefined && one.field in options.measures));
65
71
  return {
66
72
  ...own,
67
73
  count: options.counted === true ? "exact" : "none",
@@ -70,6 +76,7 @@ export function levelQuestion(base, level, page, options = {}) {
70
76
  ...(options.measures === undefined || Object.keys(options.measures).length === 0
71
77
  ? {}
72
78
  : { measures: { ...options.measures } }),
79
+ ...(order.length === 0 ? {} : { order: order.map((one) => ({ ...one })) }),
73
80
  pagination: {
74
81
  limit: page.limit,
75
82
  ...(offset > 0 ? { strategy: { rows: offset } } : {}),
@@ -9,14 +9,15 @@
9
9
  */
10
10
  export { type CachedTransport, cachedTransport, type CacheOptions, } from "./cache.js";
11
11
  export { sendRoute } from "./command.js";
12
- export { ENGLISH_FRAMEWORK_COPY, type FrameworkCopy, frameworkCopy, installFrameworkCopy, SPANISH_FRAMEWORK_COPY, } from "./copy.js";
13
- export { type Advice, adviceAt, changesOf, computedLocally, creationOf, defaultsOf, editedOf, errorAt, errorsByField, type FieldState, fieldStateOf, type FieldStates, isEmptyValue, linePlacesOf, lineStatesOf, missingOf, needsPreview, pathOf, type ServerFieldState, } from "./edit.js";
12
+ export { ENGLISH_FRAMEWORK_COPY, type FrameworkCopy, frameworkCopy, installFrameworkCopy, SPANISH_FRAMEWORK_COPY, SPANISH_FRAMEWORK_COPY_TU, } from "./copy.js";
13
+ export { type Advice, adviceAt, canCreate, changesOf, computedLocally, creationOf, defaultsOf, editedOf, errorAt, errorsByField, type FieldState, fieldStateOf, type FieldStates, isEmptyValue, linePlacesOf, lineStatesOf, missingOf, needsPreview, pathOf, type ServerFieldState, } from "./edit.js";
14
14
  export { explain } from "./explain.js";
15
+ export { csvOf, decimalOf, type ExportColumn, exportColumnsOf, } from "./export.js";
15
16
  export { FILE_WIDGETS, holdsFile, type Published, renditionUrl, type RenditionValue, sendFile, storedFileOf, type StoredFileValue, type UploadAbout, uploadRefusalOf, type Uploads, } from "./files.js";
16
17
  export { type FormLayout, formOf } from "./form.js";
17
18
  export { areGroups, groupKeyOf, type GroupPage, isGroupedAnswer, levelQuestion, nextGroups, NotGrouped, rowsQuestion, } from "./groups.js";
18
19
  export { FACT_TONES, type FactTone, type HistoryChange, type HistoryEntry, historyOf, toneOfFact, } from "./history.js";
19
- export { addingOf, type AddingRule, blankLine, type Declared, editableLines, isReference, type LineAdding, lineFields, lineKey, linesAnswered, moved, sameLine, writtenInCell, } from "./lines.js";
20
+ export { addingOf, type AddingRule, addManyOf, blankLine, type Declared, editableLines, isReference, type LineAdding, lineFields, lineKey, linesAnswered, moved, sameLine, writtenInCell, } from "./lines.js";
20
21
  export { CHOOSE_MANY, choosesMany, defineList, type GroupLevel, isList, type ListDefinition, listingAsk, type ListingQuestion, type ListSpec, type NamedFilter, readListing, scopeOf, trashOf, } from "./list.js";
21
22
  export { lookupOf, type LookupOption } from "./lookup.js";
22
23
  export { detailOf, measuresOf, sumsOf, type Total, totalOf, } from "./measure.js";
@@ -9,14 +9,15 @@
9
9
  */
10
10
  export { cachedTransport, } from "./cache.js";
11
11
  export { sendRoute } from "./command.js";
12
- export { ENGLISH_FRAMEWORK_COPY, frameworkCopy, installFrameworkCopy, SPANISH_FRAMEWORK_COPY, } from "./copy.js";
13
- export { adviceAt, changesOf, computedLocally, creationOf, defaultsOf, editedOf, errorAt, errorsByField, fieldStateOf, isEmptyValue, linePlacesOf, lineStatesOf, missingOf, needsPreview, pathOf, } from "./edit.js";
12
+ export { ENGLISH_FRAMEWORK_COPY, frameworkCopy, installFrameworkCopy, SPANISH_FRAMEWORK_COPY, SPANISH_FRAMEWORK_COPY_TU, } from "./copy.js";
13
+ export { adviceAt, canCreate, changesOf, computedLocally, creationOf, defaultsOf, editedOf, errorAt, errorsByField, fieldStateOf, isEmptyValue, linePlacesOf, lineStatesOf, missingOf, needsPreview, pathOf, } from "./edit.js";
14
14
  export { explain } from "./explain.js";
15
+ export { csvOf, decimalOf, exportColumnsOf, } from "./export.js";
15
16
  export { FILE_WIDGETS, holdsFile, renditionUrl, sendFile, storedFileOf, uploadRefusalOf, } from "./files.js";
16
17
  export { formOf } from "./form.js";
17
18
  export { areGroups, groupKeyOf, isGroupedAnswer, levelQuestion, nextGroups, NotGrouped, rowsQuestion, } from "./groups.js";
18
19
  export { FACT_TONES, historyOf, toneOfFact, } from "./history.js";
19
- export { addingOf, blankLine, editableLines, isReference, lineFields, lineKey, linesAnswered, moved, sameLine, writtenInCell, } from "./lines.js";
20
+ export { addingOf, addManyOf, blankLine, editableLines, isReference, lineFields, lineKey, linesAnswered, moved, sameLine, writtenInCell, } from "./lines.js";
20
21
  export { CHOOSE_MANY, choosesMany, defineList, isList, listingAsk, readListing, scopeOf, trashOf, } from "./list.js";
21
22
  export { lookupOf } from "./lookup.js";
22
23
  export { detailOf, measuresOf, sumsOf, totalOf, } from "./measure.js";
@@ -40,6 +40,16 @@ export declare function lineFields(definition: Meta | null): string[];
40
40
  * An embedded value or anything the table has no control for needs the dialog's room.
41
41
  */
42
42
  export declare function writtenInCell(definition: Meta, field: string, declared: Declared): boolean;
43
+ /**
44
+ * The many2one «Add several…» fills — one new line per record chosen —: the one the screen names
45
+ * (`asked`), else the line's ONLY to-one relation a person writes whose entity the application
46
+ * declared (a product). `false` from the screen, or none or several to choose from: none — two
47
+ * candidates are a question only the screen can answer.
48
+ *
49
+ * addManyOf(lineMeta, declared) // "product_code"
50
+ * addManyOf(lineMeta, declared, "warehouse_id") // the screen's
51
+ */
52
+ export declare function addManyOf(definition: Meta | null, declared: Declared, asked?: string | false): string | undefined;
43
53
  /** What decides where a line is written, besides its model. */
44
54
  export type AddingRule = {
45
55
  /** Whether the application declared the entity a relation points at. */