@sincpro/web-framework 3.19.0 → 3.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +59 -51
- package/dist/core/copy.d.ts +12 -0
- package/dist/core/copy.js +51 -0
- package/dist/core/edit.d.ts +13 -0
- package/dist/core/edit.js +14 -0
- package/dist/core/export.d.ts +29 -0
- package/dist/core/export.js +47 -0
- package/dist/core/groups.js +1 -4
- package/dist/core/index.d.ts +3 -2
- package/dist/core/index.js +3 -2
- package/dist/react/context.d.ts +16 -2
- package/dist/react/context.js +7 -4
- package/dist/react/index.d.ts +3 -1
- package/dist/react/index.js +2 -0
- package/dist/react/useCounts.d.ts +23 -0
- package/dist/react/useCounts.js +43 -0
- package/dist/react/usePeopleOf.d.ts +14 -0
- package/dist/react/usePeopleOf.js +35 -0
- package/dist/react/useRecord.js +2 -2
- package/dist/web/index.d.ts +2 -2
- package/dist/web/index.js +2 -2
- package/dist/web/list/entityList/opening.d.ts +1 -1
- package/dist/web/list/entityList/opening.js +7 -2
- package/dist/web/list/entityList/props.d.ts +3 -2
- package/dist/web/list/export.d.ts +13 -0
- package/dist/web/list/export.js +61 -0
- package/dist/web/record/lines.js +6 -6
- package/dist/web/workspace/RecordScreen.d.ts +73 -7
- package/dist/web/workspace/RecordScreen.js +101 -23
- package/dist/web/workspace/SincproApp.d.ts +11 -1
- package/dist/web/workspace/SincproApp.js +8 -8
- package/dist/web/workspace/record.d.ts +17 -5
- package/dist/web/workspace/record.js +24 -7
- package/dist/web/workspace/workspace.d.ts +2 -0
- package/dist/web/workspace/workspace.js +1 -1
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -702,57 +702,65 @@ find .next/static -name '*.map' -delete
|
|
|
702
702
|
Each answers one question, and each comes in the three levels — use the component, drop to the
|
|
703
703
|
hook and draw your own, or go straight to the loose piece.
|
|
704
704
|
|
|
705
|
-
| Question
|
|
706
|
-
|
|
|
707
|
-
| Where is the data?
|
|
708
|
-
| The application's logic
|
|
709
|
-
| Read through a use case
|
|
710
|
-
| Read it on the server first
|
|
711
|
-
| A record read on the server
|
|
712
|
-
| What every use case runs with
|
|
713
|
-
| What happened, what broke
|
|
714
|
-
| What happened, on the server
|
|
715
|
-
| What broke, on the server
|
|
716
|
-
| A page that broke
|
|
717
|
-
| What is each field?
|
|
718
|
-
| A value outside a model
|
|
719
|
-
| A file or a photo it holds
|
|
720
|
-
| A file given in the record
|
|
721
|
-
| Formatted text
|
|
722
|
-
| A person, read
|
|
723
|
-
| A choice's tag outside a list
|
|
724
|
-
| What is a record, at any size?
|
|
725
|
-
| How does a record look?
|
|
726
|
-
| N records: search, filter, page
|
|
727
|
-
| A named slice (to collect, …)
|
|
728
|
-
| A record's whole screen
|
|
729
|
-
| One region of a record screen
|
|
730
|
-
| One region of a list
|
|
731
|
-
| The models a face brings
|
|
732
|
-
|
|
|
733
|
-
|
|
|
734
|
-
|
|
|
735
|
-
|
|
|
736
|
-
|
|
|
737
|
-
|
|
|
738
|
-
|
|
|
739
|
-
|
|
|
740
|
-
|
|
|
741
|
-
|
|
|
742
|
-
|
|
|
743
|
-
|
|
|
744
|
-
|
|
|
745
|
-
|
|
|
746
|
-
|
|
|
747
|
-
|
|
|
748
|
-
| A
|
|
749
|
-
|
|
|
750
|
-
|
|
|
751
|
-
|
|
|
752
|
-
|
|
|
753
|
-
|
|
|
754
|
-
| What
|
|
755
|
-
|
|
|
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
|
+
| The notices, on a hand-written screen | — | `useRecordNotices` | web-ui's `Record.Notice` |
|
|
735
|
+
| A block laid out as the form | — | `useScreenColumns` | — |
|
|
736
|
+
| Who is who in a history | `SincproApp people`, `FrameworkProvider people`, `ModelDefinitions people` | `usePeopleOf` | the application's use case |
|
|
737
|
+
| «New» in the business's words | `EntityList create="Nueva noticia"` | — | `canCreate` (`create` or `Edit`) |
|
|
738
|
+
| The list as a spreadsheet | `EntityList` «Exportar» (the entity's `export`) | — | `csvOf`, `exportColumnsOf`; `exportRoute` (client-framework) |
|
|
739
|
+
| Spanish in tú | `SincproApp voice="tú"` | — | `SPANISH_FRAMEWORK_COPY_TU`, web-ui's `SPANISH_COPY_TU` |
|
|
740
|
+
| Previous / next from a record | `EntityRecord` (from a list) | — | `placeOf`, `stepIn` (`Trail`) |
|
|
741
|
+
| How much each group adds up | `EntityList sums` | `useGroups` (`sums`) | `sumsOf`, `detailOf` |
|
|
742
|
+
| One record: read, edit, save | `RecordField`, `factsOf`, `RecordLines` | `useRecord` | `transport.one`, `transport.send` |
|
|
743
|
+
| Its lines: add, edit, remove | `RecordField name="lines"` (`LineItems`) | `useRecord` (`edit.cell`, `errorAt`) | `lineKey`, `editableLines`, `pathOf` |
|
|
744
|
+
| Its relations, inside it | `RelatedList` | `useRelated` | `relatedOf` |
|
|
745
|
+
| What other records hold of it | web-ui's `SmartButton` opening `entity.listRef(cut, name)` | `useCount` | `entity.listRef` (client-framework) |
|
|
746
|
+
| Choose one (literal search) | `EntityPicker`, `chooserIn` | `useLookup` | `lookupOf` + criteria's `matching` |
|
|
747
|
+
| Choose several (many2many) | `EntityTags` | `useLookup` (`values`) | `lookupOf` |
|
|
748
|
+
| A relation, from the model alone | `RecordField name="customer_id"` | `useEntityFor` | `relationFieldOf`, `entityFor` |
|
|
749
|
+
| Open it where it belongs | `RelatedRecord`, `entityView`, `EntityList openTargets` | — | `openIn`, `targetsFor`, `OpenInMenu` |
|
|
750
|
+
| Look at the set several ways | `EntityList views` (table, rows, board, sheet, tiles) | — | web-ui's `List.*` |
|
|
751
|
+
| Cross it by two fields | `EntityList pivot` | `usePivot` | `pivotOf` |
|
|
752
|
+
| Order by several fields | the bar's criteria builder | `listing.orderBy([...])` | criteria's `order` |
|
|
753
|
+
| Act on it (with a dry run) | `ServiceButton` (a use case), `CommandButton`, row commands | `useService`, `useCommand` | `transport.send` |
|
|
754
|
+
| What is chosen in a list | `EntityList selectable selection` | `useSelection` | `Selection`, `chosen`, `allMatching` (client-framework) |
|
|
755
|
+
| Act on each chosen one | `BatchProgress`, `selectionActions={(chosen) => …}` | `useBatchCommand` | `runBatch`, `keysOf` (client-framework), `sendRoute` |
|
|
756
|
+
| A list's actions, by the style | `EntityList actions`, `selectionActions` (`DockAction`s) | — | web-ui's `List.Dock`, `ViewStyleProvider` |
|
|
757
|
+
| A record's actions, by the style | `EntityRecord actions`, web-ui's `Record.Dock` | `useRecordLifecycleActions` | `DockedAction`, `ActionLook` |
|
|
758
|
+
| A use case or a Command, there | `ServiceButton`, `CommandButton` (as buttons) | `useServiceAction`/`useCommandAction` | — |
|
|
759
|
+
| Delete it | `EntityRecord` (`RecordLifecycle`) | `useRecordLifecycle` | `entity.delete`, `useRouteCommand` |
|
|
760
|
+
| Its trash | `EntityRecord` (`RecordLifecycle`), `listView(trashOf(entity))` | `useRecordLifecycle` | `entity.archive`, `entity.restore`, `trashOf` |
|
|
761
|
+
| Read again when it was written | every reading of this package, by itself | `useWrites` | `processChanges` (client-framework) |
|
|
762
|
+
| What happened to it | `Record.Activity` fed by `useHistory` | `useHistory` | `historyOf` |
|
|
763
|
+
| The application context | `SincproApp` | `useRecordInWorkspace`, `useFollowed` | `FrameworkProvider`, `webUiSkin` |
|
|
756
764
|
|
|
757
765
|
The rules behind them, in short:
|
|
758
766
|
|
package/dist/core/copy.d.ts
CHANGED
|
@@ -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. */
|
|
@@ -179,4 +181,14 @@ export declare const frameworkCopy: () => FrameworkCopy;
|
|
|
179
181
|
export declare const routeCopy: () => RouteCopy;
|
|
180
182
|
/** The words of a file not taken: the installed table's, or English when it has none. */
|
|
181
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;
|
|
182
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.`,
|
|
@@ -136,6 +137,7 @@ export const SPANISH_FRAMEWORK_COPY = {
|
|
|
136
137
|
empty: "Todavía no hay nada.",
|
|
137
138
|
emptyFiltered: "Nada coincide.",
|
|
138
139
|
search: "Buscar",
|
|
140
|
+
export: "Exportar",
|
|
139
141
|
searchBar: "Buscar, o # para elegir el campo…",
|
|
140
142
|
builder: "Constructor de criteria",
|
|
141
143
|
capped: (shown) => `Se muestran los primeros ${shown}. Refiná la búsqueda para ver el resto.`,
|
|
@@ -255,3 +257,52 @@ export const frameworkCopy = () => installed;
|
|
|
255
257
|
export const routeCopy = () => installed.route ?? ENGLISH_ROUTE;
|
|
256
258
|
/** The words of a file not taken: the installed table's, or English when it has none. */
|
|
257
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
|
+
};
|
package/dist/core/edit.d.ts
CHANGED
|
@@ -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,
|
|
@@ -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
|
+
}
|
package/dist/core/groups.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {} from "@sincpro/criteria";
|
|
1
|
+
import { GROUP_COUNT, } from "@sincpro/criteria";
|
|
2
2
|
import { frameworkCopy } from "./copy.js";
|
|
3
3
|
/**
|
|
4
4
|
* Whether an answer to a grouped question holds groups — each with how many records it holds
|
|
@@ -41,9 +41,6 @@ export class NotGrouped extends Error {
|
|
|
41
41
|
this.name = "NotGrouped";
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
-
/** What every group answers without being asked — criteria's `GROUP_COUNT`, which its public
|
|
45
|
-
* entry does not export. */
|
|
46
|
-
const GROUP_COUNT = "count";
|
|
47
44
|
/**
|
|
48
45
|
* The question for ONE level of groups — the first page of it, or the next.
|
|
49
46
|
*
|
package/dist/core/index.d.ts
CHANGED
|
@@ -9,9 +9,10 @@
|
|
|
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";
|
package/dist/core/index.js
CHANGED
|
@@ -9,9 +9,10 @@
|
|
|
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";
|
package/dist/react/context.d.ts
CHANGED
|
@@ -58,8 +58,12 @@ type FrameworkContextValue = {
|
|
|
58
58
|
richText: RichTextSettings;
|
|
59
59
|
/** Where a file a person gives goes — the application's (`FrameworkProvider uploads`). */
|
|
60
60
|
uploads: Uploads | undefined;
|
|
61
|
+
/** Who is who — the application's (`FrameworkProvider people`). */
|
|
62
|
+
people: People | undefined;
|
|
61
63
|
};
|
|
62
|
-
|
|
64
|
+
/** Who is who: usernames → the names a person reads, for every username asked at once. */
|
|
65
|
+
export type People = (who: readonly string[]) => Promise<Readonly<Record<string, string>>>;
|
|
66
|
+
export declare function FrameworkProvider({ transport, locale, metas: seed, entities, timeZone, dateStyle, currency, region, events, richText, uploads, people, changes, children, }: {
|
|
63
67
|
transport: Transport;
|
|
64
68
|
/** The language labels and values are read in (`"es"`); the model's `default` without it. */
|
|
65
69
|
locale?: string;
|
|
@@ -95,6 +99,13 @@ export declare function FrameworkProvider({ transport, locale, metas: seed, enti
|
|
|
95
99
|
* rich text takes no pictures.
|
|
96
100
|
*/
|
|
97
101
|
uploads?: Uploads;
|
|
102
|
+
/**
|
|
103
|
+
* Who is who: the names of the people a record's history and authorship name by username
|
|
104
|
+
* («jperez» → «Juana Pérez»). The application's use case answers them — the accounts are its
|
|
105
|
+
* bounded context's —, asked once for every username a screen shows. Without it, the
|
|
106
|
+
* usernames are shown.
|
|
107
|
+
*/
|
|
108
|
+
people?: People;
|
|
98
109
|
/** Where writes are announced — the process's (`processChanges`) unless a test gives another. */
|
|
99
110
|
changes?: ChangeFeed;
|
|
100
111
|
children: ReactNode;
|
|
@@ -125,13 +136,16 @@ export declare function useEntityFor(target: string | undefined): Entity | undef
|
|
|
125
136
|
* them, as if the server had sent them. `entities` (what a relation is resolved to) and `events`
|
|
126
137
|
* (the facts of a history) are added over the provider's for the screens under this one only.
|
|
127
138
|
*/
|
|
128
|
-
export declare function ModelDefinitions({ entities, metas, events, children, }: {
|
|
139
|
+
export declare function ModelDefinitions({ entities, metas, events, people, children, }: {
|
|
129
140
|
/** Its entities: a relation of one of its models is drawn with them. */
|
|
130
141
|
entities?: readonly Entity[] | undefined;
|
|
131
142
|
/** Each entity's model by its key (`metasOf(contract)`): drawn with no request for it. */
|
|
132
143
|
metas?: Readonly<Record<string, Meta>> | undefined;
|
|
133
144
|
/** Each domain event's definition by its name (`eventMetasOf(contract)`). */
|
|
134
145
|
events?: Readonly<Record<string, Meta>> | undefined;
|
|
146
|
+
/** Who is who on this face's screens (`FrameworkProvider people`), when the face names its
|
|
147
|
+
* people and the provider around it does not. */
|
|
148
|
+
people?: People | undefined;
|
|
135
149
|
children?: ReactNode;
|
|
136
150
|
}): import("react").JSX.Element;
|
|
137
151
|
export {};
|
package/dist/react/context.js
CHANGED
|
@@ -7,7 +7,7 @@ import { entityFor } from "../core/relation.js";
|
|
|
7
7
|
import { useContextValues } from "./useContextValues.js";
|
|
8
8
|
import { createContext, useContext, useEffect, useMemo, useRef, useState, } from "react";
|
|
9
9
|
const FrameworkContext = createContext(null);
|
|
10
|
-
export function FrameworkProvider({ transport, locale, metas: seed, entities = NO_ENTITIES, timeZone, dateStyle = "numeric", currency, region, events = NO_EVENTS, richText = NO_RICH_TEXT, uploads, changes = processChanges, children, }) {
|
|
10
|
+
export function FrameworkProvider({ transport, locale, metas: seed, entities = NO_ENTITIES, timeZone, dateStyle = "numeric", currency, region, events = NO_EVENTS, richText = NO_RICH_TEXT, uploads, people, changes = processChanges, children, }) {
|
|
11
11
|
// Installed before the children draw, and again when it changes (another company): the
|
|
12
12
|
// formatters read it, so it cannot wait for an effect.
|
|
13
13
|
const zoned = useRef(null);
|
|
@@ -72,6 +72,7 @@ export function FrameworkProvider({ transport, locale, metas: seed, entities = N
|
|
|
72
72
|
events,
|
|
73
73
|
richText,
|
|
74
74
|
uploads,
|
|
75
|
+
people,
|
|
75
76
|
}), [
|
|
76
77
|
screens,
|
|
77
78
|
locale,
|
|
@@ -86,6 +87,7 @@ export function FrameworkProvider({ transport, locale, metas: seed, entities = N
|
|
|
86
87
|
events,
|
|
87
88
|
richText,
|
|
88
89
|
uploads,
|
|
90
|
+
people,
|
|
89
91
|
]);
|
|
90
92
|
return _jsx(FrameworkContext.Provider, { value: value, children: children });
|
|
91
93
|
}
|
|
@@ -128,7 +130,7 @@ export function useEntityFor(target) {
|
|
|
128
130
|
* them, as if the server had sent them. `entities` (what a relation is resolved to) and `events`
|
|
129
131
|
* (the facts of a history) are added over the provider's for the screens under this one only.
|
|
130
132
|
*/
|
|
131
|
-
export function ModelDefinitions({ entities, metas, events, children, }) {
|
|
133
|
+
export function ModelDefinitions({ entities, metas, events, people, children, }) {
|
|
132
134
|
const above = useFramework();
|
|
133
135
|
// Added while rendering, before the screens under it render: they read the store as they draw.
|
|
134
136
|
const brought = useRef(undefined);
|
|
@@ -138,7 +140,7 @@ export function ModelDefinitions({ entities, metas, events, children, }) {
|
|
|
138
140
|
above.metas.set(key, meta);
|
|
139
141
|
brought.current = metas;
|
|
140
142
|
}
|
|
141
|
-
const value = useMemo(() => entities === undefined && events === undefined
|
|
143
|
+
const value = useMemo(() => entities === undefined && events === undefined && people === undefined
|
|
142
144
|
? above
|
|
143
145
|
: {
|
|
144
146
|
...above,
|
|
@@ -151,6 +153,7 @@ export function ModelDefinitions({ entities, metas, events, children, }) {
|
|
|
151
153
|
],
|
|
152
154
|
}),
|
|
153
155
|
...(events === undefined ? {} : { events: { ...above.events, ...events } }),
|
|
154
|
-
|
|
156
|
+
...(people === undefined ? {} : { people }),
|
|
157
|
+
}, [above, entities, events, people]);
|
|
155
158
|
return _jsx(FrameworkContext.Provider, { value: value, children: children });
|
|
156
159
|
}
|
package/dist/react/index.d.ts
CHANGED
|
@@ -3,17 +3,19 @@
|
|
|
3
3
|
* DOM, no design system — so a screen can drop `EntityList` and still keep it. `make doctor`
|
|
4
4
|
* keeps it that way.
|
|
5
5
|
*/
|
|
6
|
-
export { FrameworkProvider, ModelDefinitions, useEntityFor, useFramework, } from "./context.js";
|
|
6
|
+
export { FrameworkProvider, ModelDefinitions, type People, useEntityFor, useFramework, } from "./context.js";
|
|
7
7
|
export { type ListScope, ListScopeProvider, useListScope, } from "./scope.js";
|
|
8
8
|
export { BATCH_LIMIT, type BatchCommandState, useBatchCommand, } from "./useBatchCommand.js";
|
|
9
9
|
export { type AnswerOf, type CommandState, type Rehearsal, useCommand, useRouteCommand, } from "./useCommand.js";
|
|
10
10
|
export { useContextValues } from "./useContextValues.js";
|
|
11
11
|
export { useCount } from "./useCount.js";
|
|
12
|
+
export { type CountAsked, useCounts } from "./useCounts.js";
|
|
12
13
|
export { type Groups, useGroups } from "./useGroups.js";
|
|
13
14
|
export { useHistory } from "./useHistory.js";
|
|
14
15
|
export { type Listing, type ListingOptions, type Paging, useListing, } from "./useListing.js";
|
|
15
16
|
export { excluding, type Lookup, useLookup } from "./useLookup.js";
|
|
16
17
|
export { useNameOf, useNamesOf } from "./useNameOf.js";
|
|
18
|
+
export { usePeopleOf } from "./usePeopleOf.js";
|
|
17
19
|
export { type PivotAxes, type PivotReading, usePivot, } from "./usePivot.js";
|
|
18
20
|
export { type Editing, type RecordReading, type RecordState, useRecord, } from "./useRecord.js";
|
|
19
21
|
export { type LifecycleAction, type RecordLifecycleActions, useRecordLifecycle, } from "./useRecordLifecycle.js";
|
package/dist/react/index.js
CHANGED
|
@@ -9,11 +9,13 @@ export { BATCH_LIMIT, useBatchCommand, } from "./useBatchCommand.js";
|
|
|
9
9
|
export { useCommand, useRouteCommand, } from "./useCommand.js";
|
|
10
10
|
export { useContextValues } from "./useContextValues.js";
|
|
11
11
|
export { useCount } from "./useCount.js";
|
|
12
|
+
export { useCounts } from "./useCounts.js";
|
|
12
13
|
export { useGroups } from "./useGroups.js";
|
|
13
14
|
export { useHistory } from "./useHistory.js";
|
|
14
15
|
export { useListing, } from "./useListing.js";
|
|
15
16
|
export { excluding, useLookup } from "./useLookup.js";
|
|
16
17
|
export { useNameOf, useNamesOf } from "./useNameOf.js";
|
|
18
|
+
export { usePeopleOf } from "./usePeopleOf.js";
|
|
17
19
|
export { usePivot, } from "./usePivot.js";
|
|
18
20
|
export { useRecord, } from "./useRecord.js";
|
|
19
21
|
export { useRecordLifecycle, } from "./useRecordLifecycle.js";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type Entity } from "@sincpro/client-framework";
|
|
2
|
+
import type { Expression } from "@sincpro/criteria";
|
|
3
|
+
/** One question to count: the records of `entity` that `where` keeps. */
|
|
4
|
+
export type CountAsked = {
|
|
5
|
+
entity: Entity;
|
|
6
|
+
where: Expression;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* How many records each question keeps, asked together — a record's smart buttons («Sus pagos 4»,
|
|
10
|
+
* «Cuotas pendientes 2»), as many as the record has. `null` while it is asked, or when the server
|
|
11
|
+
* did not answer one.
|
|
12
|
+
*
|
|
13
|
+
* const [pagos, cuotas] = useCounts([
|
|
14
|
+
* { entity: pagos, where: { field: "colegiado_id", operator: "=", value: id } },
|
|
15
|
+
* { entity: cuotas, where: pendientesDe(id) },
|
|
16
|
+
* ]);
|
|
17
|
+
*
|
|
18
|
+
* Context: `useCount` is a listing of one, so a screen counted one question per hook — and a
|
|
19
|
+
* record's links, whose number and questions depend on the record, ended as hooks an application
|
|
20
|
+
* passed as data (`useEnlaces`). The questions here are data, read again when they or the
|
|
21
|
+
* process's context change.
|
|
22
|
+
*/
|
|
23
|
+
export declare function useCounts(asked: readonly CountAsked[]): readonly (number | null)[];
|