@fieldia/core 0.28.0 → 0.29.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 +125 -1
- package/package.json +1 -1
- package/schema/page.schema.json +263 -6
- package/src/index.d.mts +8 -2
- package/src/index.d.ts +8 -2
- package/src/index.js +29 -2
- package/src/index.js.map +1 -1
- package/src/index.mjs +11 -2
- package/src/index.mjs.map +1 -1
- package/src/lib/format/approval-checks.d.mts +8 -0
- package/src/lib/format/approval-checks.d.ts +8 -0
- package/src/lib/format/approval-checks.js +29 -0
- package/src/lib/format/approval-checks.js.map +1 -0
- package/src/lib/format/approval-checks.mjs +26 -0
- package/src/lib/format/approval-checks.mjs.map +1 -0
- package/src/lib/format/approval.d.mts +20 -0
- package/src/lib/format/approval.d.ts +20 -0
- package/src/lib/format/approval.js +25 -0
- package/src/lib/format/approval.js.map +1 -0
- package/src/lib/format/approval.mjs +22 -0
- package/src/lib/format/approval.mjs.map +1 -0
- package/src/lib/format/assist-checks.d.mts +14 -0
- package/src/lib/format/assist-checks.d.ts +14 -0
- package/src/lib/format/assist-checks.js +68 -0
- package/src/lib/format/assist-checks.js.map +1 -0
- package/src/lib/format/assist-checks.mjs +64 -0
- package/src/lib/format/assist-checks.mjs.map +1 -0
- package/src/lib/format/assist.d.mts +41 -0
- package/src/lib/format/assist.d.ts +41 -0
- package/src/lib/format/assist.js +29 -0
- package/src/lib/format/assist.js.map +1 -0
- package/src/lib/format/assist.mjs +26 -0
- package/src/lib/format/assist.mjs.map +1 -0
- package/src/lib/format/editable-checks.d.mts +8 -0
- package/src/lib/format/editable-checks.d.ts +8 -0
- package/src/lib/format/editable-checks.js +38 -0
- package/src/lib/format/editable-checks.js.map +1 -0
- package/src/lib/format/editable-checks.mjs +35 -0
- package/src/lib/format/editable-checks.mjs.map +1 -0
- package/src/lib/format/field.d.mts +86 -0
- package/src/lib/format/field.d.ts +86 -0
- package/src/lib/format/field.js +56 -10
- package/src/lib/format/field.js.map +1 -1
- package/src/lib/format/field.mjs +55 -9
- package/src/lib/format/field.mjs.map +1 -1
- package/src/lib/format/languages-checks.d.mts +8 -0
- package/src/lib/format/languages-checks.d.ts +8 -0
- package/src/lib/format/languages-checks.js +40 -0
- package/src/lib/format/languages-checks.js.map +1 -0
- package/src/lib/format/languages-checks.mjs +37 -0
- package/src/lib/format/languages-checks.mjs.map +1 -0
- package/src/lib/format/later-checks.d.mts +4 -3
- package/src/lib/format/later-checks.d.ts +4 -3
- package/src/lib/format/later-checks.js +4 -3
- package/src/lib/format/later-checks.js.map +1 -1
- package/src/lib/format/later-checks.mjs +4 -3
- package/src/lib/format/later-checks.mjs.map +1 -1
- package/src/lib/format/layout.d.mts +100 -26
- package/src/lib/format/layout.d.ts +100 -26
- package/src/lib/format/layout.js +19 -3
- package/src/lib/format/layout.js.map +1 -1
- package/src/lib/format/layout.mjs +17 -1
- package/src/lib/format/layout.mjs.map +1 -1
- package/src/lib/format/layout.types.d.mts +2 -1
- package/src/lib/format/layout.types.d.ts +2 -1
- package/src/lib/format/list-editable.d.mts +20 -0
- package/src/lib/format/list-editable.d.ts +20 -0
- package/src/lib/format/list-editable.js +33 -0
- package/src/lib/format/list-editable.js.map +1 -0
- package/src/lib/format/list-editable.mjs +28 -0
- package/src/lib/format/list-editable.mjs.map +1 -0
- package/src/lib/format/page.d.mts +84 -9
- package/src/lib/format/page.d.ts +84 -9
- package/src/lib/format/page.js +4 -0
- package/src/lib/format/page.js.map +1 -1
- package/src/lib/format/page.mjs +4 -0
- package/src/lib/format/page.mjs.map +1 -1
- package/src/lib/format/photos-options.d.mts +29 -0
- package/src/lib/format/photos-options.d.ts +29 -0
- package/src/lib/format/photos-options.js +49 -0
- package/src/lib/format/photos-options.js.map +1 -0
- package/src/lib/format/photos-options.mjs +45 -0
- package/src/lib/format/photos-options.mjs.map +1 -0
- package/src/lib/format/references.js +31 -1
- package/src/lib/format/references.js.map +1 -1
- package/src/lib/format/references.mjs +31 -1
- package/src/lib/format/references.mjs.map +1 -1
- package/src/lib/format/scan-checks.d.mts +12 -0
- package/src/lib/format/scan-checks.d.ts +12 -0
- package/src/lib/format/scan-checks.js +89 -0
- package/src/lib/format/scan-checks.js.map +1 -0
- package/src/lib/format/scan-checks.mjs +86 -0
- package/src/lib/format/scan-checks.mjs.map +1 -0
- package/src/lib/format/scan-options.d.mts +84 -0
- package/src/lib/format/scan-options.d.ts +84 -0
- package/src/lib/format/scan-options.js +58 -0
- package/src/lib/format/scan-options.js.map +1 -0
- package/src/lib/format/scan-options.mjs +54 -0
- package/src/lib/format/scan-options.mjs.map +1 -0
- package/src/lib/format/upgrade.d.mts +4 -2
- package/src/lib/format/upgrade.d.ts +4 -2
- package/src/lib/format/upgrade.js +4 -2
- package/src/lib/format/upgrade.js.map +1 -1
- package/src/lib/format/upgrade.mjs +4 -2
- package/src/lib/format/upgrade.mjs.map +1 -1
- package/src/lib/format/version.d.mts +2 -2
- package/src/lib/format/version.d.ts +2 -2
- package/src/lib/format/version.js +2 -2
- package/src/lib/format/version.js.map +1 -1
- package/src/lib/format/version.mjs +2 -2
- package/src/lib/format/version.mjs.map +1 -1
- package/src/lib/record/approvals-part.d.mts +6 -0
- package/src/lib/record/approvals-part.d.ts +6 -0
- package/src/lib/record/approvals-part.js +14 -0
- package/src/lib/record/approvals-part.js.map +1 -0
- package/src/lib/record/approvals-part.mjs +7 -0
- package/src/lib/record/approvals-part.mjs.map +1 -0
- package/src/lib/record/approving.d.mts +45 -0
- package/src/lib/record/approving.d.ts +45 -0
- package/src/lib/record/approving.js +10 -0
- package/src/lib/record/approving.js.map +1 -0
- package/src/lib/record/approving.mjs +7 -0
- package/src/lib/record/approving.mjs.map +1 -0
- package/src/lib/record/check.js +4 -0
- package/src/lib/record/check.js.map +1 -1
- package/src/lib/record/check.mjs +4 -0
- package/src/lib/record/check.mjs.map +1 -1
- package/src/lib/record/data-source.d.mts +270 -0
- package/src/lib/record/data-source.d.ts +270 -0
- package/src/lib/record/data-source.js.map +1 -1
- package/src/lib/record/data-source.mjs.map +1 -1
- package/src/lib/record/files-part.d.mts +7 -0
- package/src/lib/record/files-part.d.ts +7 -0
- package/src/lib/record/files-part.js +167 -0
- package/src/lib/record/files-part.js.map +1 -0
- package/src/lib/record/files-part.mjs +163 -0
- package/src/lib/record/files-part.mjs.map +1 -0
- package/src/lib/record/filter.d.mts +5 -0
- package/src/lib/record/filter.d.ts +5 -0
- package/src/lib/record/filter.js +1 -0
- package/src/lib/record/filter.js.map +1 -1
- package/src/lib/record/filter.mjs +1 -1
- package/src/lib/record/filter.mjs.map +1 -1
- package/src/lib/record/form-approvals.d.mts +47 -0
- package/src/lib/record/form-approvals.d.ts +47 -0
- package/src/lib/record/form-approvals.js +186 -0
- package/src/lib/record/form-approvals.js.map +1 -0
- package/src/lib/record/form-approvals.mjs +180 -0
- package/src/lib/record/form-approvals.mjs.map +1 -0
- package/src/lib/record/form.d.mts +32 -1
- package/src/lib/record/form.d.ts +32 -1
- package/src/lib/record/form.js +49 -5
- package/src/lib/record/form.js.map +1 -1
- package/src/lib/record/form.mjs +49 -5
- package/src/lib/record/form.mjs.map +1 -1
- package/src/lib/record/languages-part.d.mts +32 -0
- package/src/lib/record/languages-part.d.ts +32 -0
- package/src/lib/record/languages-part.js +104 -0
- package/src/lib/record/languages-part.js.map +1 -0
- package/src/lib/record/languages-part.mjs +96 -0
- package/src/lib/record/languages-part.mjs.map +1 -0
- package/src/lib/record/languages.d.mts +26 -0
- package/src/lib/record/languages.d.ts +26 -0
- package/src/lib/record/languages.js +20 -0
- package/src/lib/record/languages.js.map +1 -0
- package/src/lib/record/languages.mjs +15 -0
- package/src/lib/record/languages.mjs.map +1 -0
- package/src/lib/record/locales/ar.js +5 -0
- package/src/lib/record/locales/ar.js.map +1 -1
- package/src/lib/record/locales/ar.mjs +5 -0
- package/src/lib/record/locales/ar.mjs.map +1 -1
- package/src/lib/record/locales/de.js +5 -0
- package/src/lib/record/locales/de.js.map +1 -1
- package/src/lib/record/locales/de.mjs +5 -0
- package/src/lib/record/locales/de.mjs.map +1 -1
- package/src/lib/record/locales/fr.js +5 -0
- package/src/lib/record/locales/fr.js.map +1 -1
- package/src/lib/record/locales/fr.mjs +5 -0
- package/src/lib/record/locales/fr.mjs.map +1 -1
- package/src/lib/record/memory-approvals.d.mts +47 -0
- package/src/lib/record/memory-approvals.d.ts +47 -0
- package/src/lib/record/memory-approvals.js +78 -0
- package/src/lib/record/memory-approvals.js.map +1 -0
- package/src/lib/record/memory-approvals.mjs +75 -0
- package/src/lib/record/memory-approvals.mjs.map +1 -0
- package/src/lib/record/memory-assist.d.mts +53 -0
- package/src/lib/record/memory-assist.d.ts +53 -0
- package/src/lib/record/memory-assist.js +519 -0
- package/src/lib/record/memory-assist.js.map +1 -0
- package/src/lib/record/memory-assist.mjs +513 -0
- package/src/lib/record/memory-assist.mjs.map +1 -0
- package/src/lib/record/memory-clusters.d.mts +18 -0
- package/src/lib/record/memory-clusters.d.ts +18 -0
- package/src/lib/record/memory-clusters.js +83 -0
- package/src/lib/record/memory-clusters.js.map +1 -0
- package/src/lib/record/memory-clusters.mjs +80 -0
- package/src/lib/record/memory-clusters.mjs.map +1 -0
- package/src/lib/record/memory-data-source.d.mts +43 -3
- package/src/lib/record/memory-data-source.d.ts +43 -3
- package/src/lib/record/memory-data-source.js +105 -19
- package/src/lib/record/memory-data-source.js.map +1 -1
- package/src/lib/record/memory-data-source.mjs +105 -19
- package/src/lib/record/memory-data-source.mjs.map +1 -1
- package/src/lib/record/memory-later.d.mts +1 -1
- package/src/lib/record/memory-later.d.ts +1 -1
- package/src/lib/record/memory-later.js +4 -1
- package/src/lib/record/memory-later.js.map +1 -1
- package/src/lib/record/memory-later.mjs +4 -1
- package/src/lib/record/memory-later.mjs.map +1 -1
- package/src/lib/record/messages.d.mts +14 -0
- package/src/lib/record/messages.d.ts +14 -0
- package/src/lib/record/messages.js +5 -0
- package/src/lib/record/messages.js.map +1 -1
- package/src/lib/record/messages.mjs +5 -0
- package/src/lib/record/messages.mjs.map +1 -1
- package/src/lib/record/uploads.d.mts +35 -9
- package/src/lib/record/uploads.d.ts +35 -9
- package/src/lib/record/uploads.js +49 -169
- package/src/lib/record/uploads.js.map +1 -1
- package/src/lib/record/uploads.mjs +42 -164
- package/src/lib/record/uploads.mjs.map +1 -1
- package/src/lib/record/values.d.mts +23 -0
- package/src/lib/record/values.d.ts +23 -0
- package/src/lib/record/values.js +4 -0
- package/src/lib/record/values.js.map +1 -1
- package/src/lib/record/values.mjs +4 -0
- package/src/lib/record/values.mjs.map +1 -1
- package/src/runtime.d.mts +12 -5
- package/src/runtime.d.ts +12 -5
- package/src/runtime.js +18 -3
- package/src/runtime.js.map +1 -1
- package/src/runtime.mjs +7 -1
- package/src/runtime.mjs.map +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { FilterCondition, Fields, Option, PropertyDefinition } from '../format/field';
|
|
2
2
|
import type { JsonValue } from '../format/json';
|
|
3
|
+
import type { Page } from '../format/page';
|
|
3
4
|
import type { FileValue, RecordId, RelatedRecord, Values } from './values';
|
|
4
5
|
import type { RunStop } from './run';
|
|
5
6
|
import type { DateInterval } from './periods';
|
|
@@ -164,6 +165,275 @@ export interface DataSource {
|
|
|
164
165
|
saveDraft?(request: SaveDraftRequest): Promise<SavedDraft>;
|
|
165
166
|
/** A draft kept by `saveDraft`, by its key: what the viewer's `resume` opens. Null when there is none (sent, or gone). */
|
|
166
167
|
loadDraft?(request: LoadDraftRequest): Promise<StoredDraft | null>;
|
|
168
|
+
/**
|
|
169
|
+
* A record's approvals, for a page with `approval`: the levels it must pass — each with who may approve it there,
|
|
170
|
+
* whether any one of them or all must, and where it stands — what was decided so far, and the levels this person may
|
|
171
|
+
* decide now. Asked as a saved record is shown, again after each save and each decision. Who is asked, and in what
|
|
172
|
+
* order, is the app's to decide — or the approval engine's behind it: Fieldia says it and asks. Without it, nothing
|
|
173
|
+
* is asked and nothing shows; no levels, and nothing shows either.
|
|
174
|
+
*/
|
|
175
|
+
approvals?(request: ApprovalsRequest): Promise<Approvals>;
|
|
176
|
+
/**
|
|
177
|
+
* A decision at a level this person may decide (`Approvals.mine`): approved, or rejected with why (`reason`, always
|
|
178
|
+
* given with a rejection). Answer with the approvals as they stand now, or nothing: they are asked again. The record
|
|
179
|
+
* is loaded again after it, as the decision may have moved it on (its state, what may be changed). Refuse with
|
|
180
|
+
* `saveRefused` (a `rule`, with why) and nothing is decided. Without it, no Approve or Reject shows.
|
|
181
|
+
*/
|
|
182
|
+
decide?(request: DecideRequest): Promise<Approvals | void>;
|
|
183
|
+
/**
|
|
184
|
+
* Values for a form, read by the app's own model from words a person gives — an e-mail, a signature, a message — or
|
|
185
|
+
* from files: what a page's `suggest` (its "Fill from text") asks. Answer with the values proposed, by field — a
|
|
186
|
+
* table of lines' as the lines to add, each its values — and, if you like, why in a sentence. Nothing you answer is
|
|
187
|
+
* kept unasked: each value is shown on its field for the person to accept or reject first, and a field they typed
|
|
188
|
+
* in meanwhile keeps what they typed. Fieldia ships no model and no keys. Without it, no "Fill from text" shows.
|
|
189
|
+
*/
|
|
190
|
+
suggest?(request: SuggestRequest): Promise<SuggestResult>;
|
|
191
|
+
/**
|
|
192
|
+
* A text field's words written by the app's own model: a draft of it from the record (`how: "draft"`), the words
|
|
193
|
+
* the person wrote made clearer (`polish`), or a tool of the app's own the page names. What you answer is shown
|
|
194
|
+
* under the field for the person to accept or reject; it is never kept unasked, and typing in the field meanwhile
|
|
195
|
+
* lets it go. Without it, a field's `rewrite` tools are hidden.
|
|
196
|
+
*/
|
|
197
|
+
rewrite?(request: RewriteRequest): Promise<RewriteResult>;
|
|
198
|
+
/**
|
|
199
|
+
* A search typed in plain words — "villas in New Cairo under 15M" — read by the app's own model as conditions on
|
|
200
|
+
* the list's fields: what a list's `searchToFilter` asks. Each condition becomes a filter the person sees and may
|
|
201
|
+
* take away, and Undo puts their words back. Without it, the list searches the words as typed, as before.
|
|
202
|
+
*/
|
|
203
|
+
searchToFilter?(request: SearchToFilterRequest): Promise<SearchToFilterResult>;
|
|
204
|
+
/**
|
|
205
|
+
* A list's map, its records gathered on the server where they crowd: for the view the map shows (`bbox`, `zoom`),
|
|
206
|
+
* the bubbles — each where its records' middle is, how many it holds and the box they lie in — and the records that
|
|
207
|
+
* stand alone, with the fields their pins and cards show. Asked as a search changes and again a moment after the map
|
|
208
|
+
* stops moving, so a map shows every record a search finds, however many, never loading them: thousands of homes, a
|
|
209
|
+
* city's orders. Answer `false` to let the map load the search's records and gather them itself, as it does without
|
|
210
|
+
* this (a search that finds few, a model your server does not gather). To fail, throw: the map says so.
|
|
211
|
+
*/
|
|
212
|
+
clusters?(request: ClustersRequest): Promise<ClustersResult | false>;
|
|
213
|
+
}
|
|
214
|
+
/** Whose approvals are asked: the record shown, and the person, as the app told the form. */
|
|
215
|
+
export interface ApprovalsRequest {
|
|
216
|
+
model: string;
|
|
217
|
+
/** The record shown, saved: a new one has none. */
|
|
218
|
+
recordId: RecordId;
|
|
219
|
+
/** The person as the app told the form (`user`), where it did: a server knows them by its own sign-in first. */
|
|
220
|
+
user?: {
|
|
221
|
+
id: RecordId | null;
|
|
222
|
+
name?: string;
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
/** What was decided at a level: approved, or rejected. */
|
|
226
|
+
export type ApprovalDecision = 'approved' | 'rejected';
|
|
227
|
+
/**
|
|
228
|
+
* Where a level stands: `waiting` for its approvers now, `later` — after the levels before it, or until the record is
|
|
229
|
+
* sent for approval — `approved`, `rejected`, or `skipped`, not needed for this record.
|
|
230
|
+
*/
|
|
231
|
+
export type ApprovalLevelState = 'waiting' | 'later' | 'approved' | 'rejected' | 'skipped';
|
|
232
|
+
/** One who may approve at a level, and what they decided there, where they did. */
|
|
233
|
+
export interface Approver {
|
|
234
|
+
/** Their id, where the app has one: the form's `user` is matched by it. */
|
|
235
|
+
id?: RecordId;
|
|
236
|
+
/** Their name, as people know them: "Mona Adel". */
|
|
237
|
+
name: string;
|
|
238
|
+
/** What they decided at this level, in the round of asking now; none while they have not. */
|
|
239
|
+
decision?: ApprovalDecision;
|
|
240
|
+
/** When, as an ISO date and time. */
|
|
241
|
+
at?: string;
|
|
242
|
+
}
|
|
243
|
+
/** A level a record must pass: Manager, Finance, the CFO, Legal. */
|
|
244
|
+
export interface ApprovalLevel {
|
|
245
|
+
/** The level's own id, as `decide` and the history name it: "finance". */
|
|
246
|
+
id: string;
|
|
247
|
+
/** Its name, in the person's language: "Finance". */
|
|
248
|
+
name: string;
|
|
249
|
+
/** Who may approve it there. */
|
|
250
|
+
approvers: Approver[];
|
|
251
|
+
/** Met by any one of them (`any`, the default) or by every one (`all`): said in words ("Mona Adel or Omar Said"). */
|
|
252
|
+
needs?: 'any' | 'all';
|
|
253
|
+
state: ApprovalLevelState;
|
|
254
|
+
}
|
|
255
|
+
/** What happened on a record's way to approval: sent for it, or a decision at a level — who, when, and why. */
|
|
256
|
+
export interface ApprovalEntry {
|
|
257
|
+
/** A decision at a level, or the record sent for approval (`requested`): each round of asking starts with one. */
|
|
258
|
+
decision: ApprovalDecision | 'requested';
|
|
259
|
+
/** The level decided at, by its id; none for `requested`. */
|
|
260
|
+
level?: string;
|
|
261
|
+
/** The level's name, where it is no longer among the record's levels: its id is said otherwise. */
|
|
262
|
+
levelName?: string;
|
|
263
|
+
/** Who, by the name people know them by. */
|
|
264
|
+
by: string;
|
|
265
|
+
/** When, as an ISO date and time. */
|
|
266
|
+
at: string;
|
|
267
|
+
/** Why, as they wrote it: always with a rejection, where one approving wrote any. */
|
|
268
|
+
reason?: string;
|
|
269
|
+
}
|
|
270
|
+
/** A record's approvals, as `approvals` and `decide` answer. */
|
|
271
|
+
export interface Approvals {
|
|
272
|
+
/** The levels it must pass, in their order: none, and it needs no approval — nothing shows. */
|
|
273
|
+
levels: ApprovalLevel[];
|
|
274
|
+
/** True: the levels are asked all at once, each waiting together; else one after another, in their order. Words alone. */
|
|
275
|
+
together?: boolean;
|
|
276
|
+
/** What happened so far, oldest first: shown beside the record and in its conversation. */
|
|
277
|
+
history?: ApprovalEntry[];
|
|
278
|
+
/** The levels this person may decide now, by id: Approve and Reject for each. None: they only see where it stands. */
|
|
279
|
+
mine?: string[];
|
|
280
|
+
/** Why it needs approval, in the person's language, said with it: "Orders over EGP 50,000 go to Finance, then the CFO." */
|
|
281
|
+
why?: string;
|
|
282
|
+
}
|
|
283
|
+
/** A decision at a level: what `decide` is asked. */
|
|
284
|
+
export interface DecideRequest {
|
|
285
|
+
model: string;
|
|
286
|
+
recordId: RecordId;
|
|
287
|
+
/** The level decided at, by its id: one of `Approvals.mine`. */
|
|
288
|
+
level: string;
|
|
289
|
+
decision: ApprovalDecision;
|
|
290
|
+
/** Why, as the person wrote it: always given with a rejection. */
|
|
291
|
+
reason?: string;
|
|
292
|
+
/** The person as the app told the form (`user`), where it did. */
|
|
293
|
+
user?: {
|
|
294
|
+
id: RecordId | null;
|
|
295
|
+
name?: string;
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
/** What `suggest` is asked: the page and its values now, the fields a proposal may fill, and what the person gave. */
|
|
299
|
+
export interface SuggestRequest {
|
|
300
|
+
pageId: string;
|
|
301
|
+
/** The page's model; empty for a page of responses. */
|
|
302
|
+
model: string;
|
|
303
|
+
/** The record shown; null while it is new. */
|
|
304
|
+
recordId: RecordId | null;
|
|
305
|
+
/** The page as it is shown, in the reader's words: its fields' labels, kinds and options, for the model to read. */
|
|
306
|
+
page: Page;
|
|
307
|
+
/** The record's values now. */
|
|
308
|
+
values: Values;
|
|
309
|
+
/** The fields a proposal may fill, by name: those the page's `suggest` names, else those shown that a person can set. */
|
|
310
|
+
fields: string[];
|
|
311
|
+
/** What the person gave: words pasted or typed, files picked. */
|
|
312
|
+
from: {
|
|
313
|
+
text?: string;
|
|
314
|
+
files?: UploadFile[];
|
|
315
|
+
};
|
|
316
|
+
/** The page's language, by tag: what the values proposed are written in. */
|
|
317
|
+
language: string;
|
|
318
|
+
/**
|
|
319
|
+
* For each field it may fill that keeps its text in several languages (`translate`), the one language a proposal
|
|
320
|
+
* fills, by tag — the one shown in its switch, else the reader's: answer that language's text alone, as a string.
|
|
321
|
+
* Never the others: each language is typed by a person, never translated by a machine.
|
|
322
|
+
*/
|
|
323
|
+
languages?: Record<string, string>;
|
|
324
|
+
}
|
|
325
|
+
/** Values proposed for a form, each shown on its field to accept or reject. */
|
|
326
|
+
export interface SuggestResult {
|
|
327
|
+
/**
|
|
328
|
+
* By field: a value as the field holds one — a link as `{ id, label }`, or its name, looked for as typing looks for
|
|
329
|
+
* it; a choice by its value or its label; a day as "2026-10-20" — and a table of lines' as the lines to add, each
|
|
330
|
+
* its values. A field not asked, or one the person cannot set, is left out.
|
|
331
|
+
*/
|
|
332
|
+
values: Values;
|
|
333
|
+
/** Why, in a sentence of the app's: shown over the values proposed. */
|
|
334
|
+
why?: string;
|
|
335
|
+
}
|
|
336
|
+
/** What `rewrite` is asked: the text field, what was pressed, its words now and the record they belong to. */
|
|
337
|
+
export interface RewriteRequest {
|
|
338
|
+
pageId: string;
|
|
339
|
+
model: string;
|
|
340
|
+
recordId: RecordId | null;
|
|
341
|
+
/** The page as it is shown, in the reader's words. */
|
|
342
|
+
page: Page;
|
|
343
|
+
/** The record's values now: what a draft is written from. */
|
|
344
|
+
values: Values;
|
|
345
|
+
/** The text field, by name. */
|
|
346
|
+
field: string;
|
|
347
|
+
/** `draft` (write it from the record), `polish` (make the words there clearer), or a tool of the app's own, by its `how`. */
|
|
348
|
+
how: string;
|
|
349
|
+
/** The field's words now: empty for a draft of an empty field. */
|
|
350
|
+
text: string;
|
|
351
|
+
/**
|
|
352
|
+
* The page's language, by tag — for a text kept in several languages (`translate`), the one shown in its switch: the
|
|
353
|
+
* words given are that language's, and the words answered fill it alone, never another (each typed by a person).
|
|
354
|
+
*/
|
|
355
|
+
language: string;
|
|
356
|
+
}
|
|
357
|
+
/** A text field's words proposed: shown under it to accept or reject. */
|
|
358
|
+
export interface RewriteResult {
|
|
359
|
+
text: string;
|
|
360
|
+
/** Why, in a sentence of the app's: shown with the words proposed. */
|
|
361
|
+
why?: string;
|
|
362
|
+
}
|
|
363
|
+
/** What `searchToFilter` is asked: the words typed, and the fields a condition may name. */
|
|
364
|
+
export interface SearchToFilterRequest {
|
|
365
|
+
pageId: string;
|
|
366
|
+
model: string;
|
|
367
|
+
/** The page as it is shown, in the reader's words: its fields' labels, kinds and options. */
|
|
368
|
+
page: Page;
|
|
369
|
+
/** The words typed: "villas in New Cairo under 15M". */
|
|
370
|
+
text: string;
|
|
371
|
+
/** The fields a condition may name: the list's columns, search fields and filter fields. */
|
|
372
|
+
fields: string[];
|
|
373
|
+
/** The page's language, by tag. */
|
|
374
|
+
language: string;
|
|
375
|
+
}
|
|
376
|
+
/** A plain-words search as conditions, each shown as a filter the person may take away. */
|
|
377
|
+
export interface SearchToFilterResult {
|
|
378
|
+
/**
|
|
379
|
+
* Conditions on the fields asked, all holding together: `=` a value (a choice by its value, a link by its id), `in`
|
|
380
|
+
* several, `>=`, `<=`, `>`, `<` or `between` [from, to] for a number or a day, `contains` for a record of links,
|
|
381
|
+
* `ilike` words in a text. One a field was not asked of, or an `op` the list cannot show, is left out and said.
|
|
382
|
+
*/
|
|
383
|
+
filter: ResolvedFilterCondition[];
|
|
384
|
+
/** Words to search for as typed, besides: what was left of the words that names no field. */
|
|
385
|
+
text?: string;
|
|
386
|
+
/** Why, in a sentence of the app's: shown with the filters made. */
|
|
387
|
+
why?: string;
|
|
388
|
+
}
|
|
389
|
+
/** A box on the earth, its edges in degrees: west beyond east when it crosses the antimeridian, -180 and 180 the world round. */
|
|
390
|
+
export interface GeoBox {
|
|
391
|
+
south: number;
|
|
392
|
+
west: number;
|
|
393
|
+
north: number;
|
|
394
|
+
east: number;
|
|
395
|
+
}
|
|
396
|
+
/** What a list's map asks `clusters`: the search, where its records are, and the view it shows. */
|
|
397
|
+
export interface ClustersRequest {
|
|
398
|
+
model: string;
|
|
399
|
+
/** The list's search, as `list` gets it; the view is not among it. */
|
|
400
|
+
filter: ResolvedFilter[];
|
|
401
|
+
/** Where each record is: a field holding a GeoJSON point, or a latitude whose longitude is in `longitude` — as a `near` order names them. */
|
|
402
|
+
field: string;
|
|
403
|
+
longitude?: string;
|
|
404
|
+
/** The view: the records within it are gathered. */
|
|
405
|
+
bbox: GeoBox;
|
|
406
|
+
/** The map's zoom: 0 the world in one 256-pixel image, each step twice as close (Web Mercator, every web map's). */
|
|
407
|
+
zoom: number;
|
|
408
|
+
/** How near two pins come, in pixels at this zoom, before they crowd: the cell of a grid a server gathers by. */
|
|
409
|
+
radius: number;
|
|
410
|
+
/** The fields a record standing alone carries: its place, its pin's and its card's. */
|
|
411
|
+
fields: string[];
|
|
412
|
+
/** A number field to add up in each bubble (`MapCluster.weight`): what a heat map from afar weighs its records by. */
|
|
413
|
+
weight?: string;
|
|
414
|
+
/** Aborted when the map moves on before the answer comes: stop, and reject with an error named `AbortError`. */
|
|
415
|
+
signal?: UploadSignal;
|
|
416
|
+
}
|
|
417
|
+
/** Records gathered where they crowd, for one view of a list's map. */
|
|
418
|
+
export interface ClustersResult {
|
|
419
|
+
/** The bubbles: each two records or more, drawn with its count; pressed, the map zooms to its `bbox`. */
|
|
420
|
+
clusters: MapCluster[];
|
|
421
|
+
/** The records that stand alone, each drawn as its own pin, its card opened from it: `{ id, values }` with the fields asked. */
|
|
422
|
+
points?: ListedRecord[];
|
|
423
|
+
/** How many records the search finds that have no place: said under the map ("2 without a place, not on the map"). */
|
|
424
|
+
unplaced?: number;
|
|
425
|
+
}
|
|
426
|
+
/** A bubble: records close together, counted where they stand. */
|
|
427
|
+
export interface MapCluster {
|
|
428
|
+
/** Where it is drawn: its records' middle. */
|
|
429
|
+
lat: number;
|
|
430
|
+
lng: number;
|
|
431
|
+
/** How many records it holds. */
|
|
432
|
+
count: number;
|
|
433
|
+
/** The box its records lie in: a press zooms there, and a new search fits the map to its bubbles' boxes. Without it, a press zooms two steps in. */
|
|
434
|
+
bbox?: GeoBox;
|
|
435
|
+
/** With `weight` asked: that field added up over its records. */
|
|
436
|
+
weight?: number;
|
|
167
437
|
}
|
|
168
438
|
/** Whose possible duplicates were let be: what `notDuplicates` is asked. */
|
|
169
439
|
export interface NotDuplicatesRequest {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-source.js","sourceRoot":"","sources":["../../../../../../libs/core/src/lib/record/data-source.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"data-source.js","sourceRoot":"","sources":["../../../../../../libs/core/src/lib/record/data-source.ts"],"names":[],"mappings":";;;AAysBA,oCAEC;AAGD,wCAGC;AA+ZD,kCAEC;AAGD,sCAMC;AAgDD,sCAOC;AA1eD,6GAA6G;AAC7G,SAAgB,YAAY,CAAC,MAAc,EAAE,OAA6D,EAAE;IAC1G,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;AAC/H,CAAC;AAED,6HAA6H;AAC7H,SAAgB,cAAc,CAAC,MAA6B;IAC1D,MAAM,MAAM,GAAG,MAA+B,CAAC;IAC/C,OAAO,MAAM,CAAC,OAAO,KAAK,IAAI,IAAI,MAAM,CAAC,MAAM,KAAK,IAAI,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAE,MAAuB,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAgB,EAAE,CAAC;AACzK,CAAC;AA6YD;;;;;GAKG;AACH,MAAa,aAAc,SAAQ,KAAK;IAC7B,QAAQ,CAAe;IACvB,OAAO,CAAc;IAC9B,YAAY,QAAs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AE,CAAC;QACnD,IAAI,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,KAAK,WAAW;YAAE,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAE,KAAyB,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;;YACjK,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;IACpC,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;AACtD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-source.mjs","sourceRoot":"","sources":["../../../../../../libs/core/src/lib/record/data-source.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"data-source.mjs","sourceRoot":"","sources":["../../../../../../libs/core/src/lib/record/data-source.ts"],"names":[],"mappings":"AAwsBA,6GAA6G;AAC7G,MAAM,UAAU,YAAY,CAAC,MAAc,EAAE,OAA6D,EAAE;IAC1G,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;AAC/H,CAAC;AAED,6HAA6H;AAC7H,MAAM,UAAU,cAAc,CAAC,MAA6B;IAC1D,MAAM,MAAM,GAAG,MAA+B,CAAC;IAC/C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ClH,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;AACpC,CAAC;AA2CD;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,KAAa,EAAE,MAAc,EAAE,MAAc;IACzE,MAAM,OAAO,GAAkB,EAAE,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;IACpE,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QACnD,IAAI,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,KAAK,WAAW;YAAE,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAE,KAAyB,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;;YACjK,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;IACpC,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;AACtD,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { UploadFile } from './data-source.mjs';
|
|
2
|
+
import { type UploadsRun } from './uploads.mjs';
|
|
3
|
+
import type { FileValue } from './values.mjs';
|
|
4
|
+
/** A file held as its bytes, as the store takes a file: its name, size, kind and bytes. */
|
|
5
|
+
export declare function fileFromBytes(file: FileValue): UploadFile;
|
|
6
|
+
/** The next file made ready, one at a time, and the next to go, three at a time: the uploads' own pump, once this part came. */
|
|
7
|
+
export declare function pumpUploads(run: UploadsRun): void;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { UploadFile } from './data-source';
|
|
2
|
+
import { type UploadsRun } from './uploads';
|
|
3
|
+
import type { FileValue } from './values';
|
|
4
|
+
/** A file held as its bytes, as the store takes a file: its name, size, kind and bytes. */
|
|
5
|
+
export declare function fileFromBytes(file: FileValue): UploadFile;
|
|
6
|
+
/** The next file made ready, one at a time, and the next to go, three at a time: the uploads' own pump, once this part came. */
|
|
7
|
+
export declare function pumpUploads(run: UploadsRun): void;
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fileFromBytes = fileFromBytes;
|
|
4
|
+
exports.pumpUploads = pumpUploads;
|
|
5
|
+
const data_source_1 = require("./data-source");
|
|
6
|
+
const uploads_1 = require("./uploads");
|
|
7
|
+
/**
|
|
8
|
+
* The uploads' work (uploads.ts), a part of its own: each file made ready, one at a time (a photo made smaller), and
|
|
9
|
+
* sent to the app's store, three at a time — its bar told as it goes, Cancel stopping it — then its stored link put in
|
|
10
|
+
* its field in the order the files were picked, in place of the bytes a save stores, the words beside them kept. It
|
|
11
|
+
* comes with the files part, and the first time a form sends a file: a page with no file never downloads it.
|
|
12
|
+
*/
|
|
13
|
+
/** The host's `AbortController`: every browser's, and Node's. Core names no DOM types. */
|
|
14
|
+
const stopper = () => new globalThis.AbortController();
|
|
15
|
+
const sameFile = (a, b) => a.name === b.name && a.data === b.data && a.url === b.url;
|
|
16
|
+
/** The bytes a base64 text holds. */
|
|
17
|
+
function bytesOf(data) {
|
|
18
|
+
const text = globalThis.atob(data);
|
|
19
|
+
const bytes = new Uint8Array(text.length);
|
|
20
|
+
for (let i = 0; i < text.length; i++)
|
|
21
|
+
bytes[i] = text.charCodeAt(i);
|
|
22
|
+
return bytes;
|
|
23
|
+
}
|
|
24
|
+
/** A file held as its bytes, as the store takes a file: its name, size, kind and bytes. */
|
|
25
|
+
function fileFromBytes(file) {
|
|
26
|
+
const bytes = bytesOf(file.data ?? '');
|
|
27
|
+
return { name: file.name, size: bytes.length, type: file.type, arrayBuffer: async () => bytes.slice().buffer };
|
|
28
|
+
}
|
|
29
|
+
/** A stored file with the words its bytes had beside them as they stand now — a caption, a signature's evidence — never their link's. */
|
|
30
|
+
const keeping = (stored, was) => {
|
|
31
|
+
const file = { ...stored };
|
|
32
|
+
for (const [key, value] of Object.entries(was))
|
|
33
|
+
if (!['data', 'url', 'name', 'size', 'type', 'fileId'].includes(key))
|
|
34
|
+
file[key] = value;
|
|
35
|
+
return file;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* A field's files with a stored one put in: in place of the bytes it was
|
|
39
|
+
* stored for (nothing, when those are gone), with what stands beside them
|
|
40
|
+
* now; in place of a field's one file; or among several before the first
|
|
41
|
+
* that was picked after it.
|
|
42
|
+
*/
|
|
43
|
+
function placed(current, stored, how) {
|
|
44
|
+
if (how.replaces) {
|
|
45
|
+
const was = how.replaces;
|
|
46
|
+
if (Array.isArray(current)) {
|
|
47
|
+
const at = current.findIndex((file) => (0, uploads_1.isFile)(file) && sameFile(file, was));
|
|
48
|
+
return at < 0 ? undefined : current.map((file, i) => (i === at ? keeping(stored, file) : file));
|
|
49
|
+
}
|
|
50
|
+
return (0, uploads_1.isFile)(current) && sameFile(current, was) ? keeping(stored, current) : undefined;
|
|
51
|
+
}
|
|
52
|
+
if (!how.several)
|
|
53
|
+
return stored;
|
|
54
|
+
const files = (0, uploads_1.filesIn)(current);
|
|
55
|
+
const at = files.findIndex(how.pickedAfter);
|
|
56
|
+
const list = at < 0 ? [...files, stored] : [...files.slice(0, at), stored, ...files.slice(at)];
|
|
57
|
+
return list;
|
|
58
|
+
}
|
|
59
|
+
/** The next file made ready, one at a time, and the next to go, three at a time: the uploads' own pump, once this part came. */
|
|
60
|
+
function pumpUploads(run) {
|
|
61
|
+
if (!run.entries.some((entry) => entry.status === 'preparing')) {
|
|
62
|
+
const next = run.entries.find((entry) => entry.status === 'waiting' && !entry.ready);
|
|
63
|
+
if (next)
|
|
64
|
+
void prepare(run, next);
|
|
65
|
+
}
|
|
66
|
+
for (let next = nextToSend(run); next && run.entries.filter((entry) => entry.status === 'uploading').length < uploads_1.UPLOADS_AT_ONCE; next = nextToSend(run))
|
|
67
|
+
void send(run, next);
|
|
68
|
+
}
|
|
69
|
+
const nextToSend = (run) => run.entries.find((entry) => entry.status === 'waiting' && entry.ready);
|
|
70
|
+
async function prepare(run, entry) {
|
|
71
|
+
entry.status = 'preparing';
|
|
72
|
+
run.tell();
|
|
73
|
+
const original = entry.file;
|
|
74
|
+
let refused = null;
|
|
75
|
+
try {
|
|
76
|
+
entry.file = await entry.prepare(original);
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
// A file that cannot be made ready goes as it is, never lost — unless the field refuses it as it is (too large still).
|
|
80
|
+
const problem = (0, data_source_1.saveProblemOf)(error);
|
|
81
|
+
if (problem.kind === 'rule')
|
|
82
|
+
refused = problem.message;
|
|
83
|
+
entry.file = original;
|
|
84
|
+
}
|
|
85
|
+
entry.ready = true;
|
|
86
|
+
if (!run.entries.includes(entry))
|
|
87
|
+
return;
|
|
88
|
+
entry.status = refused === null ? 'waiting' : 'refused';
|
|
89
|
+
if (refused !== null) {
|
|
90
|
+
entry.error = refused;
|
|
91
|
+
entry.end?.();
|
|
92
|
+
}
|
|
93
|
+
run.tell();
|
|
94
|
+
pumpUploads(run);
|
|
95
|
+
}
|
|
96
|
+
async function send(run, entry) {
|
|
97
|
+
const source = run.host.source();
|
|
98
|
+
if (!source?.upload)
|
|
99
|
+
return;
|
|
100
|
+
const stop = stopper();
|
|
101
|
+
entry.status = 'uploading';
|
|
102
|
+
entry.sent = 0;
|
|
103
|
+
entry.total = null;
|
|
104
|
+
delete entry.error;
|
|
105
|
+
entry.stop = () => stop.abort();
|
|
106
|
+
run.tell();
|
|
107
|
+
const lineId = entry.line ? run.host.lineId(entry.line.field, entry.line.key) : undefined;
|
|
108
|
+
const under = run.host.under ?? '';
|
|
109
|
+
const request = {
|
|
110
|
+
model: run.host.model(),
|
|
111
|
+
// A line's field is named on its own, its table where it sits.
|
|
112
|
+
field: entry.line ? entry.field : `${under}${entry.field}`,
|
|
113
|
+
recordId: run.host.recordId(),
|
|
114
|
+
...(entry.line ? { line: { ...entry.line, field: `${under}${entry.line.field}`, ...(lineId !== undefined ? { id: lineId } : {}) } } : {}),
|
|
115
|
+
signal: stop.signal,
|
|
116
|
+
onProgress: (sent, total) => {
|
|
117
|
+
if (entry.status !== 'uploading' || !run.entries.includes(entry))
|
|
118
|
+
return;
|
|
119
|
+
// Told when the bar would move: a whole per cent, or the end.
|
|
120
|
+
const was = entry.total ? Math.floor((entry.sent * 100) / entry.total) : -1;
|
|
121
|
+
const now = total ? Math.floor((sent * 100) / total) : -1;
|
|
122
|
+
entry.sent = sent;
|
|
123
|
+
entry.total = total;
|
|
124
|
+
if (now !== was || sent === total)
|
|
125
|
+
run.tell();
|
|
126
|
+
},
|
|
127
|
+
};
|
|
128
|
+
try {
|
|
129
|
+
const stored = await source.upload(entry.file, request);
|
|
130
|
+
if (!run.entries.includes(entry))
|
|
131
|
+
return;
|
|
132
|
+
run.entries = run.entries.filter((other) => other !== entry);
|
|
133
|
+
put(run, entry, stored);
|
|
134
|
+
entry.end?.();
|
|
135
|
+
}
|
|
136
|
+
catch (error) {
|
|
137
|
+
if (!run.entries.includes(entry) || stop.signal.aborted || error?.name === 'AbortError') {
|
|
138
|
+
if (run.entries.includes(entry))
|
|
139
|
+
run.drop(entry);
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
const problem = (0, data_source_1.saveProblemOf)(error);
|
|
143
|
+
entry.status = problem.kind === 'rule' ? 'refused' : 'failed';
|
|
144
|
+
entry.error = problem.message;
|
|
145
|
+
entry.end?.();
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
finally {
|
|
149
|
+
delete entry.stop;
|
|
150
|
+
run.tell();
|
|
151
|
+
pumpUploads(run);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
/** The stored file in its field: exactly what the store gave — the words beside the bytes it stands in for kept. */
|
|
155
|
+
function put(run, entry, stored) {
|
|
156
|
+
const def = run.host.fileField(entry.field, entry.line);
|
|
157
|
+
const file = { ...stored };
|
|
158
|
+
run.order.set(file.url ?? '', entry.seq);
|
|
159
|
+
const value = placed(run.host.read(entry.field, entry.line), file, {
|
|
160
|
+
several: def?.multiple === true,
|
|
161
|
+
...(entry.replaces ? { replaces: entry.replaces } : {}),
|
|
162
|
+
pickedAfter: (other) => (run.order.get(other.url ?? '') ?? -1) > entry.seq,
|
|
163
|
+
});
|
|
164
|
+
if (value !== undefined)
|
|
165
|
+
run.host.write(entry.field, entry.line, value, !!entry.replaces);
|
|
166
|
+
}
|
|
167
|
+
//# sourceMappingURL=files-part.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files-part.js","sourceRoot":"","sources":["../../../../../../libs/core/src/lib/record/files-part.ts"],"names":[],"mappings":";;AAyBA,sCAGC;AAgCD,kCAMC;AAjED,+CAA8C;AAC9C,uCAA0F;AAG1F;;;;;GAKG;AAEH,0FAA0F;AAC1F,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC,IAAK,UAAgG,CAAC,eAAe,EAAE,CAAC;AAE9I,MAAM,QAAQ,GAAG,CAAC,CAAY,EAAE,CAAY,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,GAAG,CAAC;AAC3G,qCAAqC;AACrC,SAAS,OAAO,CAAC,IAAY;IAC3B,MAAM,IAAI,GAAI,UAAwD,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAClF,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC1C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,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