@sincpro/web-framework 4.0.0 → 4.1.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 +6 -6
- package/dist/core/index.d.ts +2 -1
- package/dist/core/index.js +2 -1
- package/dist/core/models.d.ts +16 -0
- package/dist/core/models.js +18 -0
- package/dist/core/names.js +2 -1
- package/dist/react/context.js +11 -1
- package/dist/react/useBatchCommand.js +2 -1
- package/dist/react/useHistory.js +2 -1
- package/dist/react/useListing.js +3 -2
- package/dist/react/useLookup.js +3 -2
- package/dist/react/useRecord.js +5 -4
- package/dist/react/useSummary.js +2 -1
- package/dist/web/list/records.js +4 -3
- package/dist/web/record/CommandButton.js +2 -1
- package/dist/web/record/EntityPicker.js +2 -1
- package/dist/web/record/EntityTags.js +3 -2
- package/dist/web/record/ServiceButton.js +6 -1
- package/dist/web/record/choice.js +2 -1
- package/dist/web/record/edit.js +2 -1
- package/dist/web/record/lines.js +2 -1
- package/dist/web/workspace/composer.d.ts +2 -2
- package/dist/web/workspace/composer.js +3 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -205,10 +205,11 @@ export const transport = restTransport({
|
|
|
205
205
|
export const operations = restOperations(transport); // JSON-RPC: jsonRpcOperations(…)
|
|
206
206
|
```
|
|
207
207
|
|
|
208
|
-
The definition of every model — its fields, operators, hints, widgets, formulas —
|
|
209
|
-
contract (`
|
|
210
|
-
|
|
211
|
-
nothing reads a model at runtime.
|
|
208
|
+
The definition of every model — its fields, operators, hints, widgets, formulas — is the
|
|
209
|
+
contract's, and each generated entity carries its own (`meta`): a face that imports an entity has
|
|
210
|
+
its model, with nothing to declare and no contract to download. An answer says only its
|
|
211
|
+
`model_version`, and nothing reads a model at runtime. `metas` (on `SincproApp`,
|
|
212
|
+
`FrameworkProvider` or `ModelDefinitions`) only replaces one. A form computes a published formula itself and asks the server
|
|
212
213
|
for a preview only when a change reaches something it cannot answer.
|
|
213
214
|
|
|
214
215
|
**3. The entities** — written by `sincpro-client generate` from the contract («From the
|
|
@@ -316,7 +317,6 @@ words), cache, toasts and the workspace, in one place. `transport` is only where
|
|
|
316
317
|
```tsx
|
|
317
318
|
<SincproApp
|
|
318
319
|
operations={operations}
|
|
319
|
-
metas={metasOf(salesContract, "sales")}
|
|
320
320
|
transport={transport}
|
|
321
321
|
views={views}
|
|
322
322
|
entities={[invoices, customers]} // a relation of a model resolves to one of these, alone
|
|
@@ -855,7 +855,7 @@ moves to the generated one — is [`docs/ADOPTION.md`](docs/ADOPTION.md).
|
|
|
855
855
|
| `selection` | Filters named as criteria 2.0 and the backend read them, the search bar's included | ✅ |
|
|
856
856
|
| `useListing`, `EntityList` | N records: criteria, search bar, builder, paging | ✅ |
|
|
857
857
|
| `useRecord`, `factsOf`, `RecordLines` | One record: facts, relations with their real total | ✅ |
|
|
858
|
-
| Definitions |
|
|
858
|
+
| Definitions | Each generated entity carries its model (`meta`); `metas` replaces one; no answer carries one | ✅ |
|
|
859
859
|
| `useLookup`, `EntityPicker` | Literal search: a many2one select, ⌘K | ✅ |
|
|
860
860
|
| `useRecord` + `RecordField`, `dirtyOf` | Editing: hints evaluated live, preview, save with version (409), server drafts | ✅ |
|
|
861
861
|
| `useCommand`, `CommandButton` | An entity's actions, with a dry run before what destroys | ✅ |
|
package/dist/core/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* @sincpro/client-framework's — the same on every platform — and are imported from there.
|
|
9
9
|
*/
|
|
10
10
|
export { type CachedOperations, cachedOperations, type CacheOptions, } from "./cache.js";
|
|
11
|
-
export { type AnswerOf, callFor, type InputOf } from "./command.js";
|
|
11
|
+
export { type AnswerOf, type BodyOf, callFor, type CommandName, type CommandsOf, type InputOf, } from "./command.js";
|
|
12
12
|
export { ENGLISH_FRAMEWORK_COPY, type FrameworkCopy, frameworkCopy, installFrameworkCopy, SPANISH_FRAMEWORK_COPY, SPANISH_FRAMEWORK_COPY_TU, } from "./copy.js";
|
|
13
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";
|
|
@@ -21,6 +21,7 @@ export { addingOf, type AddingRule, addManyOf, blankLine, type Declared, editabl
|
|
|
21
21
|
export { CHOOSE_MANY, choosesMany, defineList, type GroupLevel, isList, type ListDefinition, listingAsk, type ListingQuestion, type ListSpec, type NamedFilter, readListing, scopeOf, trashOf, } from "./list.js";
|
|
22
22
|
export { lookupOf, type LookupOption } from "./lookup.js";
|
|
23
23
|
export { detailOf, measuresOf, sumsOf, type Total, totalOf, } from "./measure.js";
|
|
24
|
+
export { knownModelOf, modelsOf } from "./models.js";
|
|
24
25
|
export { amountTextOf, BOOKKEEPING, currencyNow, type DateStyle, dateStyleNow, dayTextOf, defaultFields, fieldAt, fieldMetaOf, type FieldView, installCurrency, installDateStyle, installRegion, instantTextOf, moneyTextOf, numberTextOf, regionNow, shortTextOf, sortKeyOf, STAMPS, textOf, valueAt, viewOf, } from "./present.js";
|
|
25
26
|
export { type Related, relatedOf } from "./related.js";
|
|
26
27
|
export { backReference, entityFor, relatedScope, type RelationField, relationFieldOf, } from "./relation.js";
|
package/dist/core/index.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* @sincpro/client-framework's — the same on every platform — and are imported from there.
|
|
9
9
|
*/
|
|
10
10
|
export { cachedOperations, } from "./cache.js";
|
|
11
|
-
export { callFor } from "./command.js";
|
|
11
|
+
export { callFor, } from "./command.js";
|
|
12
12
|
export { ENGLISH_FRAMEWORK_COPY, frameworkCopy, installFrameworkCopy, SPANISH_FRAMEWORK_COPY, SPANISH_FRAMEWORK_COPY_TU, } from "./copy.js";
|
|
13
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";
|
|
@@ -21,6 +21,7 @@ export { addingOf, addManyOf, blankLine, editableLines, isReference, lineFields,
|
|
|
21
21
|
export { CHOOSE_MANY, choosesMany, defineList, isList, listingAsk, readListing, scopeOf, trashOf, } from "./list.js";
|
|
22
22
|
export { lookupOf } from "./lookup.js";
|
|
23
23
|
export { detailOf, measuresOf, sumsOf, totalOf, } from "./measure.js";
|
|
24
|
+
export { knownModelOf, modelsOf } from "./models.js";
|
|
24
25
|
export { amountTextOf, BOOKKEEPING, currencyNow, dateStyleNow, dayTextOf, defaultFields, fieldAt, fieldMetaOf, installCurrency, installDateStyle, installRegion, instantTextOf, moneyTextOf, numberTextOf, regionNow, shortTextOf, sortKeyOf, STAMPS, textOf, valueAt, viewOf, } from "./present.js";
|
|
25
26
|
export { relatedOf } from "./related.js";
|
|
26
27
|
export { backReference, entityFor, relatedScope, relationFieldOf, } from "./relation.js";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Entity, MetaStore } from "@sincpro/client-framework";
|
|
2
|
+
import type { Meta } from "@sincpro/criteria";
|
|
3
|
+
/**
|
|
4
|
+
* An entity's model as the screens know it: what the provider's store holds for its key — the
|
|
5
|
+
* contract's, or what a face brought (`ModelDefinitions`) —, else the one the entity carries (a
|
|
6
|
+
* generated entity always does, `meta`).
|
|
7
|
+
*
|
|
8
|
+
* knownModelOf(metas, invoices) -> the invoices' model, with nothing declared
|
|
9
|
+
*
|
|
10
|
+
* Context: a server's answer never carries its model, so a screen draws with the contract's. A
|
|
11
|
+
* generated entity carries it, so a face that imports the entity has it — no contract imported,
|
|
12
|
+
* no `metasOf` wired. The store still wins: a face may bring a model of its own for a key.
|
|
13
|
+
*/
|
|
14
|
+
export declare function knownModelOf(metas: Pick<MetaStore, "get">, entity: Pick<Entity, "key" | "meta">): Meta | undefined;
|
|
15
|
+
/** The models the entities carry, by their keys: what a provider starts its store with. */
|
|
16
|
+
export declare function modelsOf(entities: readonly Pick<Entity, "key" | "meta">[]): Record<string, Meta>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An entity's model as the screens know it: what the provider's store holds for its key — the
|
|
3
|
+
* contract's, or what a face brought (`ModelDefinitions`) —, else the one the entity carries (a
|
|
4
|
+
* generated entity always does, `meta`).
|
|
5
|
+
*
|
|
6
|
+
* knownModelOf(metas, invoices) -> the invoices' model, with nothing declared
|
|
7
|
+
*
|
|
8
|
+
* Context: a server's answer never carries its model, so a screen draws with the contract's. A
|
|
9
|
+
* generated entity carries it, so a face that imports the entity has it — no contract imported,
|
|
10
|
+
* no `metasOf` wired. The store still wins: a face may bring a model of its own for a key.
|
|
11
|
+
*/
|
|
12
|
+
export function knownModelOf(metas, entity) {
|
|
13
|
+
return metas.get(entity.key) ?? entity.meta;
|
|
14
|
+
}
|
|
15
|
+
/** The models the entities carry, by their keys: what a provider starts its store with. */
|
|
16
|
+
export function modelsOf(entities) {
|
|
17
|
+
return Object.fromEntries(entities.flatMap((one) => (one.meta === undefined ? [] : [[one.key, one.meta]])));
|
|
18
|
+
}
|
package/dist/core/names.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { readPage, } from "@sincpro/client-framework";
|
|
2
2
|
import { touches } from "./changes.js";
|
|
3
3
|
import { lookupOf } from "./lookup.js";
|
|
4
|
+
import { knownModelOf } from "./models.js";
|
|
4
5
|
/** The most keys one request asks for. */
|
|
5
6
|
const SLICE = 100;
|
|
6
7
|
/** Whether an entity is searched on its own — not only under a record of another model. */
|
|
@@ -18,7 +19,7 @@ export function nameBook(transport, metas) {
|
|
|
18
19
|
return;
|
|
19
20
|
asking.delete(entityKey);
|
|
20
21
|
const { entity, waiting } = batch;
|
|
21
|
-
const meta = metas
|
|
22
|
+
const meta = knownModelOf(metas, entity);
|
|
22
23
|
const field = meta?.get_id || meta?.identity || "id";
|
|
23
24
|
const keys = [...waiting.keys()];
|
|
24
25
|
for (let at = 0; at < keys.length; at += SLICE) {
|
package/dist/react/context.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { installTimeZone, metaStore, processChanges, processContext, screensOperations, } from "@sincpro/client-framework";
|
|
4
|
+
import { modelsOf } from "../core/models.js";
|
|
4
5
|
import { nameBook } from "../core/names.js";
|
|
5
6
|
import { installCurrency, installDateStyle, installRegion, } from "../core/present.js";
|
|
6
7
|
import { entityFor } from "../core/relation.js";
|
|
@@ -42,7 +43,8 @@ export function FrameworkProvider({ operations, transport, locale, metas: seed,
|
|
|
42
43
|
}
|
|
43
44
|
// One store for the provider's life: a new seed object on a re-render must not forget what
|
|
44
45
|
// the screens already learned.
|
|
45
|
-
|
|
46
|
+
// What the entities carry (a generated entity has its model), under what the app gives.
|
|
47
|
+
const [metas] = useState(() => metaStore({ ...modelsOf(entities), ...seed }));
|
|
46
48
|
const [trails] = useState(() => new Map());
|
|
47
49
|
// What the screens read and write is a use case of `screens` (`screensOperations`,
|
|
48
50
|
// client-framework): each call traced, carrying the process's context (the company, the
|
|
@@ -136,12 +138,20 @@ export function ModelDefinitions({ entities, metas, events, people, children, })
|
|
|
136
138
|
const above = useFramework();
|
|
137
139
|
// Added while rendering, before the screens under it render: they read the store as they draw.
|
|
138
140
|
const brought = useRef(undefined);
|
|
141
|
+
const carried = useRef(undefined);
|
|
139
142
|
if (metas !== undefined && brought.current !== metas) {
|
|
140
143
|
for (const [key, meta] of Object.entries(metas))
|
|
141
144
|
if (above.metas.get(key) === undefined)
|
|
142
145
|
above.metas.set(key, meta);
|
|
143
146
|
brought.current = metas;
|
|
144
147
|
}
|
|
148
|
+
// The models its entities carry, under what it brought: a face's entities are its models.
|
|
149
|
+
if (entities !== undefined && carried.current !== entities) {
|
|
150
|
+
for (const [key, meta] of Object.entries(modelsOf(entities)))
|
|
151
|
+
if (above.metas.get(key) === undefined)
|
|
152
|
+
above.metas.set(key, meta);
|
|
153
|
+
carried.current = entities;
|
|
154
|
+
}
|
|
145
155
|
const value = useMemo(() => entities === undefined && events === undefined && people === undefined
|
|
146
156
|
? above
|
|
147
157
|
: {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { keysOf, retryKeys, runBatch, } from "@sincpro/client-framework";
|
|
3
3
|
import { callFor, } from "../core/command.js";
|
|
4
|
+
import { knownModelOf } from "../core/models.js";
|
|
4
5
|
import { useFramework } from "./context.js";
|
|
5
6
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
6
7
|
/** The most records a Command runs on at once from a screen, unless the screen says otherwise. */
|
|
@@ -83,7 +84,7 @@ export function useBatchCommand(entity, name, options = {}) {
|
|
|
83
84
|
return {
|
|
84
85
|
run: async (selection, body) => {
|
|
85
86
|
setError(null);
|
|
86
|
-
const meta = metas
|
|
87
|
+
const meta = knownModelOf(metas, entity);
|
|
87
88
|
let keys;
|
|
88
89
|
try {
|
|
89
90
|
keys = await keysOf(selection, {
|
package/dist/react/useHistory.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { readHistory } from "@sincpro/client-framework";
|
|
3
3
|
import { historyOf, } from "../core/history.js";
|
|
4
|
+
import { knownModelOf } from "../core/models.js";
|
|
4
5
|
import { useFramework } from "./context.js";
|
|
5
6
|
import { useWrites } from "./useWrites.js";
|
|
6
7
|
import { useEffect, useState } from "react";
|
|
@@ -46,7 +47,7 @@ export function useHistory(entity, id, deps = [], options = {}) {
|
|
|
46
47
|
};
|
|
47
48
|
readHistory(operations, entity, id, criteria, { signal: aborter.signal }).then((page) => aborter.signal.aborted ||
|
|
48
49
|
setEntries(historyOf(page.rows, page.meta, locale, {
|
|
49
|
-
record: metas
|
|
50
|
+
record: knownModelOf(metas, entity),
|
|
50
51
|
events,
|
|
51
52
|
tones,
|
|
52
53
|
})), () => aborter.signal.aborted || setEntries(undefined));
|
package/dist/react/useListing.js
CHANGED
|
@@ -3,6 +3,7 @@ import { readPage, } from "@sincpro/client-framework";
|
|
|
3
3
|
import { merge, resource, resumingFrom, searchOver, } from "@sincpro/criteria";
|
|
4
4
|
import { useReading } from "@sincpro/criteria-react";
|
|
5
5
|
import { isList, listingAsk } from "../core/list.js";
|
|
6
|
+
import { knownModelOf } from "../core/models.js";
|
|
6
7
|
import { useFramework } from "./context.js";
|
|
7
8
|
import { useListScope } from "./scope.js";
|
|
8
9
|
import { useWrites } from "./useWrites.js";
|
|
@@ -25,14 +26,14 @@ export function useListing(given, own = {}) {
|
|
|
25
26
|
signal,
|
|
26
27
|
input,
|
|
27
28
|
// Read when asked: a definition a face brought later (`ModelDefinitions`) counts.
|
|
28
|
-
meta: metas
|
|
29
|
+
meta: knownModelOf(metas, entity) ?? null,
|
|
29
30
|
})),
|
|
30
31
|
// `input` is the caller's literal: its content is what counts.
|
|
31
32
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
32
33
|
[operations, entity, metas, inputKey]);
|
|
33
34
|
// A definition already known — the contract's, a face's — draws the columns before the first
|
|
34
35
|
// page arrives.
|
|
35
|
-
const [preloaded] = useState(() => metas
|
|
36
|
+
const [preloaded] = useState(() => knownModelOf(metas, entity));
|
|
36
37
|
const paging = own.paging ?? "pages";
|
|
37
38
|
const size = asked.pagination?.limit ?? 50;
|
|
38
39
|
const maxRows = own.maxRows ?? 500;
|
package/dist/react/useLookup.js
CHANGED
|
@@ -3,6 +3,7 @@ import { readPage } from "@sincpro/client-framework";
|
|
|
3
3
|
import { merge } from "@sincpro/criteria";
|
|
4
4
|
import { isList } from "../core/list.js";
|
|
5
5
|
import { lookupOf } from "../core/lookup.js";
|
|
6
|
+
import { knownModelOf } from "../core/models.js";
|
|
6
7
|
import { useFramework } from "./context.js";
|
|
7
8
|
import { useListing } from "./useListing.js";
|
|
8
9
|
import { useEffect, useRef, useState } from "react";
|
|
@@ -30,9 +31,9 @@ entity, options = {}) {
|
|
|
30
31
|
// answer — then this renders again and the reading starts over without the excluded.
|
|
31
32
|
const [definition, setDefinition] = useState(() => ({
|
|
32
33
|
key: base.key,
|
|
33
|
-
meta: metas
|
|
34
|
+
meta: knownModelOf(metas, base),
|
|
34
35
|
}));
|
|
35
|
-
const keyed = definition.key === base.key ? definition.meta : metas
|
|
36
|
+
const keyed = definition.key === base.key ? definition.meta : knownModelOf(metas, base);
|
|
36
37
|
const scope = excluding(options.criteria, options.exclude, keyed);
|
|
37
38
|
// «More», not pages: a choice list grows downwards, and its ceiling keeps it light.
|
|
38
39
|
const listing = useListing(entity, {
|
package/dist/react/useRecord.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { newEntityId, readRecord, retryKeys, startingValuesOf, TransportError, WITH_PARAM, } from "@sincpro/client-framework";
|
|
3
3
|
import { canCreate, changesOf, computedLocally, creationOf, defaultsOf, editedOf, errorsByField, fieldStateOf, lineStatesOf, missingOf, needsPreview, withTargetsOf, } from "../core/edit.js";
|
|
4
4
|
import { linesAnswered } from "../core/lines.js";
|
|
5
|
+
import { knownModelOf } from "../core/models.js";
|
|
5
6
|
import { useFramework } from "./context.js";
|
|
6
7
|
import { useWrites } from "./useWrites.js";
|
|
7
8
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
@@ -28,7 +29,7 @@ export function useRecord(entity, opened, options = {}) {
|
|
|
28
29
|
const startedFrom = (read) => {
|
|
29
30
|
if (read.meta)
|
|
30
31
|
metas.set(entity.key, read.meta);
|
|
31
|
-
const meta = read.meta ?? metas
|
|
32
|
+
const meta = read.meta ?? knownModelOf(metas, entity) ?? null;
|
|
32
33
|
const starting = start === undefined ? {} : startingValuesOf({ params: { [WITH_PARAM]: start } });
|
|
33
34
|
return {
|
|
34
35
|
status: "ready",
|
|
@@ -109,7 +110,7 @@ export function useRecord(entity, opened, options = {}) {
|
|
|
109
110
|
setState((now) => ({ status: "loading", record: null, meta: now.meta, error: null }));
|
|
110
111
|
if (isNew) {
|
|
111
112
|
// Nothing to read but the model: the contract's, or a face's (`ModelDefinitions`).
|
|
112
|
-
Promise.resolve(metas
|
|
113
|
+
Promise.resolve(knownModelOf(metas, entity) ?? null).then((meta) => {
|
|
113
114
|
if (meta)
|
|
114
115
|
metas.set(entity.key, meta);
|
|
115
116
|
if (aborter.signal.aborted)
|
|
@@ -134,7 +135,7 @@ export function useRecord(entity, opened, options = {}) {
|
|
|
134
135
|
}
|
|
135
136
|
readRecord(operations, entity, id, {
|
|
136
137
|
signal: aborter.signal,
|
|
137
|
-
meta: metas
|
|
138
|
+
meta: knownModelOf(metas, entity) ?? null,
|
|
138
139
|
}).then((answer) => {
|
|
139
140
|
if (answer.meta)
|
|
140
141
|
metas.set(entity.key, answer.meta);
|
|
@@ -150,7 +151,7 @@ export function useRecord(entity, opened, options = {}) {
|
|
|
150
151
|
setState({
|
|
151
152
|
status: "ready",
|
|
152
153
|
record: answer.record,
|
|
153
|
-
meta: answer.meta ?? metas
|
|
154
|
+
meta: answer.meta ?? knownModelOf(metas, entity) ?? null,
|
|
154
155
|
error: null,
|
|
155
156
|
});
|
|
156
157
|
}, (error) => {
|
package/dist/react/useSummary.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {} from "@sincpro/client-framework";
|
|
3
|
+
import { knownModelOf } from "../core/models.js";
|
|
3
4
|
import { summaryOf } from "../core/summary.js";
|
|
4
5
|
import { useFramework } from "./context.js";
|
|
5
6
|
import { useCallback } from "react";
|
|
@@ -16,7 +17,7 @@ import { useCallback } from "react";
|
|
|
16
17
|
*/
|
|
17
18
|
export function useSummaryOf(entity) {
|
|
18
19
|
const { metas, locale } = useFramework();
|
|
19
|
-
return useCallback((record, meta) => summaryOf(meta ?? metas
|
|
20
|
+
return useCallback((record, meta) => summaryOf(meta ?? knownModelOf(metas, entity) ?? null, record, {
|
|
20
21
|
fields: entity.summary,
|
|
21
22
|
...(locale === undefined ? {} : { locale }),
|
|
22
23
|
}), [metas, entity, locale]);
|
package/dist/web/list/records.js
CHANGED
|
@@ -5,6 +5,7 @@ import { matching } from "@sincpro/criteria";
|
|
|
5
5
|
import { frameworkCopy } from "../../core/copy.js";
|
|
6
6
|
import { explain } from "../../core/explain.js";
|
|
7
7
|
import { lookupOf } from "../../core/lookup.js";
|
|
8
|
+
import { knownModelOf } from "../../core/models.js";
|
|
8
9
|
import { searchedAlone } from "../../core/names.js";
|
|
9
10
|
import { entityFor } from "../../core/relation.js";
|
|
10
11
|
import { summaryOf } from "../../core/summary.js";
|
|
@@ -70,7 +71,7 @@ export function recordsSearch(framework, locale) {
|
|
|
70
71
|
})));
|
|
71
72
|
if (!searchedAlone(entity))
|
|
72
73
|
return [];
|
|
73
|
-
const meta = framework.metas
|
|
74
|
+
const meta = knownModelOf(framework.metas, entity);
|
|
74
75
|
if (meta === undefined)
|
|
75
76
|
return [];
|
|
76
77
|
const choices = await findChoices(framework.operations, entity, meta, text, locale, {
|
|
@@ -112,7 +113,7 @@ export function modelLoader(framework, root, locale) {
|
|
|
112
113
|
const entity = typeof field.relation === "string"
|
|
113
114
|
? entityFor(framework.entities, field.relation, framework.metas.get)
|
|
114
115
|
: undefined;
|
|
115
|
-
return entity === undefined ? undefined : framework.metas
|
|
116
|
+
return entity === undefined ? undefined : knownModelOf(framework.metas, entity);
|
|
116
117
|
};
|
|
117
118
|
return async (path) => {
|
|
118
119
|
let meta = root;
|
|
@@ -149,7 +150,7 @@ export function recordsBrowser(framework, open, names, refused) {
|
|
|
149
150
|
const entity = entityFor(framework.entities, browse.relation, framework.metas.get);
|
|
150
151
|
if (entity === undefined)
|
|
151
152
|
return;
|
|
152
|
-
const meta = framework.metas
|
|
153
|
+
const meta = knownModelOf(framework.metas, entity);
|
|
153
154
|
const identity = meta?.get_id || meta?.identity || "id";
|
|
154
155
|
const chosen = browse.chosen.map((one) => String(one.id));
|
|
155
156
|
const scope = chosen.length === 0
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import {} from "@sincpro/client-framework";
|
|
4
|
+
import { knownModelOf } from "../../core/models.js";
|
|
4
5
|
import { entityFor } from "../../core/relation.js";
|
|
5
6
|
import { useFramework } from "../../react/context.js";
|
|
6
7
|
import { useCommand } from "../../react/useCommand.js";
|
|
@@ -49,7 +50,7 @@ function useCommandBehind({ entity, command, id, body, destructive = false, ask,
|
|
|
49
50
|
const form = ask === undefined
|
|
50
51
|
? undefined
|
|
51
52
|
: askFormOf(ask, {
|
|
52
|
-
meta: metas
|
|
53
|
+
meta: knownModelOf(metas, entity),
|
|
53
54
|
locale,
|
|
54
55
|
record,
|
|
55
56
|
entityFor: (target) => entityFor(entities, target, metas.get),
|
|
@@ -4,6 +4,7 @@ import {} from "@sincpro/client-framework";
|
|
|
4
4
|
import { nameOf } from "@sincpro/criteria";
|
|
5
5
|
import { frameworkCopy } from "../../core/copy.js";
|
|
6
6
|
import { isList } from "../../core/list.js";
|
|
7
|
+
import { knownModelOf } from "../../core/models.js";
|
|
7
8
|
import { useFramework } from "../../react/context.js";
|
|
8
9
|
import { useListing } from "../../react/useListing.js";
|
|
9
10
|
import { excluding, useLookup } from "../../react/useLookup.js";
|
|
@@ -63,7 +64,7 @@ export function EntityPicker({ entity, value, onChange, onOpen, openTargets, onB
|
|
|
63
64
|
...(exclude === undefined ? {} : { exclude }),
|
|
64
65
|
});
|
|
65
66
|
// The chooser opens after the picker read the definition: it excludes from its first page.
|
|
66
|
-
const scope = excluding(criteria, exclude, metas
|
|
67
|
+
const scope = excluding(criteria, exclude, knownModelOf(metas, base));
|
|
67
68
|
const person = base.summary.person === true;
|
|
68
69
|
const nothing = none === undefined || none === false || lookup.text !== ""
|
|
69
70
|
? []
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { keysOf } from "@sincpro/client-framework";
|
|
4
4
|
import { isList } from "../../core/list.js";
|
|
5
|
+
import { knownModelOf } from "../../core/models.js";
|
|
5
6
|
import { useFramework } from "../../react/context.js";
|
|
6
7
|
import { BATCH_LIMIT } from "../../react/useBatchCommand.js";
|
|
7
8
|
import { excluding, useLookup } from "../../react/useLookup.js";
|
|
@@ -52,7 +53,7 @@ export function EntityTags({ entity, value, onChange, criteria, onOpen, openTarg
|
|
|
52
53
|
};
|
|
53
54
|
/** The keys of what a chooser of several answered — in hand, or read once with a ceiling. */
|
|
54
55
|
const addChosen = (selection) => {
|
|
55
|
-
const meta = metas
|
|
56
|
+
const meta = knownModelOf(metas, base);
|
|
56
57
|
keysOf(selection, {
|
|
57
58
|
transport: operations,
|
|
58
59
|
entity: base,
|
|
@@ -60,7 +61,7 @@ export function EntityTags({ entity, value, onChange, criteria, onOpen, openTarg
|
|
|
60
61
|
limit: BATCH_LIMIT,
|
|
61
62
|
}).then(add, (failure) => toast?.show(refusalNotice(failure)));
|
|
62
63
|
};
|
|
63
|
-
const scope = () => chooserScopeOf(entity, excluding(criteria, value, metas
|
|
64
|
+
const scope = () => chooserScopeOf(entity, excluding(criteria, value, knownModelOf(metas, base)));
|
|
64
65
|
const { choose, chooseMany } = opening ?? {};
|
|
65
66
|
const browseAll = onBrowseAll ??
|
|
66
67
|
(chooseMany !== undefined
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { knownModelOf } from "../../core/models.js";
|
|
3
4
|
import { entityFor } from "../../core/relation.js";
|
|
4
5
|
import { useFrameworkIfAny } from "../../react/context.js";
|
|
5
6
|
import { useService } from "../../react/useService.js";
|
|
@@ -47,7 +48,11 @@ function useServiceBehind({ run, rehearse, ask, entity, record }) {
|
|
|
47
48
|
const form = ask === undefined
|
|
48
49
|
? undefined
|
|
49
50
|
: askFormOf(ask, {
|
|
50
|
-
meta: entity === undefined
|
|
51
|
+
meta: entity === undefined
|
|
52
|
+
? undefined
|
|
53
|
+
: framework === null
|
|
54
|
+
? undefined
|
|
55
|
+
: knownModelOf(framework.metas, entity),
|
|
51
56
|
locale: framework?.locale,
|
|
52
57
|
record,
|
|
53
58
|
...(framework === null
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { knownModelOf } from "../../core/models.js";
|
|
3
4
|
import { textOf } from "../../core/present.js";
|
|
4
5
|
import { useFrameworkIfAny } from "../../react/context.js";
|
|
5
6
|
import { presentationOf } from "../list/presentation.js";
|
|
@@ -30,7 +31,7 @@ export function choiceTagOf(entity, meta, field, value, locale) {
|
|
|
30
31
|
*/
|
|
31
32
|
export function ChoiceTag({ entity, field, value, meta, }) {
|
|
32
33
|
const framework = useFrameworkIfAny();
|
|
33
|
-
const model = meta ?? framework
|
|
34
|
+
const model = meta ?? (framework === null ? undefined : knownModelOf(framework.metas, entity)) ?? null;
|
|
34
35
|
const look = choiceTagOf(entity, model, field, value, framework?.locale);
|
|
35
36
|
return _jsx(Tag, { tone: look.tone, children: look.label });
|
|
36
37
|
}
|
package/dist/web/record/edit.js
CHANGED
|
@@ -20,6 +20,7 @@ import { isPersonEntity, PersonValue } from "./person.js";
|
|
|
20
20
|
import { RecordLines } from "./record.js";
|
|
21
21
|
import { RelatedList } from "./RelatedList.js";
|
|
22
22
|
import { RichTextControl } from "./richText.js";
|
|
23
|
+
import { knownModelOf } from "../../core/models.js";
|
|
23
24
|
import { Checkbox, Field, FileValue, FormSection, ReadValue, RelationValue, useFormStyle, } from "@sincpro/web-ui";
|
|
24
25
|
import { useId } from "react";
|
|
25
26
|
/** `value` with `path` (`numero`, or `emisor.nit`) set to `next` — a new object, the rest kept. */
|
|
@@ -152,7 +153,7 @@ export function RecordField({ record, name, as, bare = false, lines: look, list:
|
|
|
152
153
|
? {}
|
|
153
154
|
: (() => {
|
|
154
155
|
const refOf = (row) => {
|
|
155
|
-
const known = metas
|
|
156
|
+
const known = knownModelOf(metas, target);
|
|
156
157
|
const key = known?.get_id || known?.identity || "id";
|
|
157
158
|
return target.ref(String(row[key]));
|
|
158
159
|
};
|
package/dist/web/record/lines.js
CHANGED
|
@@ -5,6 +5,7 @@ import { choicesOf } from "@sincpro/criteria";
|
|
|
5
5
|
import { frameworkCopy } from "../../core/copy.js";
|
|
6
6
|
import { adviceAt, defaultsOf, errorAt, linePlacesOf, pathOf, } from "../../core/edit.js";
|
|
7
7
|
import { addingOf, addManyOf, blankLine, lineFields, lineKey, moved, sameLine, writtenInCell, } from "../../core/lines.js";
|
|
8
|
+
import { knownModelOf } from "../../core/models.js";
|
|
8
9
|
import { textOf, viewOf } from "../../core/present.js";
|
|
9
10
|
import { entityFor, relationFieldOf, } from "../../core/relation.js";
|
|
10
11
|
import { useEntityFor, useFramework } from "../../react/context.js";
|
|
@@ -175,7 +176,7 @@ export function RecordLinesEditor({ record, name, lines, look = {}, }) {
|
|
|
175
176
|
const addMany = manyKey === undefined || manyEntity === undefined || chooseMany === undefined
|
|
176
177
|
? undefined
|
|
177
178
|
: () => chooseMany(manyEntity, (selection) => {
|
|
178
|
-
const meta = metas
|
|
179
|
+
const meta = knownModelOf(metas, manyEntity);
|
|
179
180
|
keysOf(selection, {
|
|
180
181
|
transport: operations,
|
|
181
182
|
entity: manyEntity,
|
|
@@ -21,8 +21,8 @@ import { type ComponentType } from "react";
|
|
|
21
21
|
* ⌘K asks the server with `matching` — 8 records — the same question a many2one asks. Each hit
|
|
22
22
|
* says what it is (`noun`, composer's) and, beside it, what tells it apart: the entity's own
|
|
23
23
|
* `option` look, else its summary's description or type — never its key, which tells a person
|
|
24
|
-
* nothing a UUID long («María Fernanda Apaza Quispe 01a1ebd4…»). Its model is `meta`, else the
|
|
25
|
-
*
|
|
24
|
+
* nothing a UUID long («María Fernanda Apaza Quispe 01a1ebd4…»). Its model is `meta`, else the
|
|
25
|
+
* workspace's, else the one the entity carries (a generated entity always does). A search that answers a SCOPE by a field of its input (forge's projects
|
|
26
26
|
* without `tenant_id` are the projects with NO tenant) is searched in the one ⌘K should see:
|
|
27
27
|
* `search: { input }`.
|
|
28
28
|
*
|
|
@@ -4,6 +4,7 @@ import { isEntityId, NEW_PARAM, processContext, scopeNameOf, scopeOfRef, screens
|
|
|
4
4
|
import { nameOf } from "@sincpro/criteria";
|
|
5
5
|
import { usePhone, } from "@sincpro/web-composer";
|
|
6
6
|
import { CHOOSE_MANY } from "../../core/list.js";
|
|
7
|
+
import { knownModelOf } from "../../core/models.js";
|
|
7
8
|
import { useFramework } from "../../react/context.js";
|
|
8
9
|
import { ListScopeProvider } from "../../react/scope.js";
|
|
9
10
|
import { useListing } from "../../react/useListing.js";
|
|
@@ -134,7 +135,8 @@ export function entityView(entity, options) {
|
|
|
134
135
|
search: async (query) => {
|
|
135
136
|
if (query.trim() === "")
|
|
136
137
|
return [];
|
|
137
|
-
meta ??=
|
|
138
|
+
meta ??=
|
|
139
|
+
(mounted.metas === null ? entity.meta : knownModelOf(mounted.metas, entity)) ?? null;
|
|
138
140
|
if (meta?.search == null)
|
|
139
141
|
return [];
|
|
140
142
|
// A hit reads as a choice anywhere a record is picked by name: its name and what tells it
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sincpro/web-framework",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"description": "The web client of sincpro_framework: entities, lists and records bound to the metadata the server publishes, drawn with @sincpro/web-ui and arranged with @sincpro/web-composer.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"@opentelemetry/sdk-trace": "^3.1.0",
|
|
52
52
|
"@sentry/browser": "^11.11.0",
|
|
53
53
|
"@sentry/core": "^11.11.0",
|
|
54
|
-
"@sincpro/client-framework": "^3.
|
|
54
|
+
"@sincpro/client-framework": "^3.2.0",
|
|
55
55
|
"@sincpro/criteria": "^2.6.0",
|
|
56
56
|
"@sincpro/criteria-react": "^2.5.1",
|
|
57
57
|
"@sincpro/web-composer": "^1.7.0",
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
"@opentelemetry/sdk-trace": "3.1.0",
|
|
96
96
|
"@sentry/browser": "11.11.0",
|
|
97
97
|
"@sentry/core": "11.11.0",
|
|
98
|
-
"@sincpro/client-framework": "^3.
|
|
98
|
+
"@sincpro/client-framework": "^3.2.0",
|
|
99
99
|
"@sincpro/criteria": "^2.6.0",
|
|
100
100
|
"@sincpro/criteria-react": "^2.5.1",
|
|
101
101
|
"@sincpro/web-composer": "^1.9.0",
|