@iyulab/lowline-form 0.4.0 → 0.6.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/dist/client.d.ts CHANGED
@@ -5,9 +5,46 @@ export declare class LowlineError extends Error {
5
5
  readonly status: number;
6
6
  constructor(status: number, message: string);
7
7
  }
8
+ /** A threshold chosen on a replay of the settled records, and what the replay saw at it. */
9
+ export interface ThresholdChoice {
10
+ threshold: number;
11
+ /** The share of the replay's answers at this threshold that were right. */
12
+ precision: number;
13
+ /** The share of lookups answered at it. */
14
+ answer_rate: number;
15
+ answered: number;
16
+ lookups: number;
17
+ /** The precision over the latest records (`promiseOver` of them), on `promise_answered` independent answers. */
18
+ promise: number;
19
+ promise_answered: number;
20
+ }
21
+ /**
22
+ * How one decided field's replays went when its thresholds were chosen — `GET {src}/{form}/report`. A part with
23
+ * nothing to say is left out.
24
+ */
25
+ export interface FieldReport {
26
+ field: string;
27
+ lookups: number;
28
+ /** The threshold at which values settled alongside answer; absent while none was right often enough. */
29
+ key?: ThresholdChoice;
30
+ /** When `key` is absent, the closest the replay came; absent when too few were answered to say. */
31
+ closest?: ThresholdChoice;
32
+ /** The fields chosen to key it; absent when every field it rests on does. */
33
+ keyFields?: string[];
34
+ /** For a free text field, the threshold for one, two, … characters typed (`null` where none was right often enough). */
35
+ typed?: (ThresholdChoice | null)[];
36
+ coarse?: ThresholdChoice;
37
+ similar?: ThresholdChoice;
38
+ similarOffered: boolean;
39
+ promiseOver: number;
40
+ /** How many checks — answers held back while a person wrote the value — are among the records. */
41
+ checks: number;
42
+ /** What the precision was counted on: values settled with nothing in view and checks, or every settled value. */
43
+ counting: 'unprompted' | 'settled';
44
+ }
8
45
  /**
9
46
  * The routes a Lowline host maps (`MapLowline` in .NET): `POST {src}/{form}/propose` and `POST {src}/{form}/settle`,
10
- * and — when the host gave a model — `fill` and `judge`. The host decides the memory space and the choices a person may pick from the request
47
+ * `GET {src}/{form}/report`, and — when the host gave a model — `fill` and `judge`. The host decides the memory space and the choices a person may pick from the request
11
48
  * itself — its sign-in — so the calls carry the record only.
12
49
  */
13
50
  export declare class LowlineClient {
@@ -31,5 +68,8 @@ export declare class LowlineClient {
31
68
  * (`needs-judgement`) — 404 when the host gave no model.
32
69
  */
33
70
  judge(form: string, id: string, values: Values): Promise<Proposal[]>;
71
+ /** Per decided field, in the form's order, the thresholds chosen on this memory space's records and what the replay saw. */
72
+ report(form: string): Promise<FieldReport[]>;
34
73
  private post;
74
+ private send;
35
75
  }
package/dist/client.js CHANGED
@@ -8,7 +8,7 @@ export class LowlineError extends Error {
8
8
  }
9
9
  /**
10
10
  * The routes a Lowline host maps (`MapLowline` in .NET): `POST {src}/{form}/propose` and `POST {src}/{form}/settle`,
11
- * and — when the host gave a model — `fill` and `judge`. The host decides the memory space and the choices a person may pick from the request
11
+ * `GET {src}/{form}/report`, and — when the host gave a model — `fill` and `judge`. The host decides the memory space and the choices a person may pick from the request
12
12
  * itself — its sign-in — so the calls carry the record only.
13
13
  */
14
14
  export class LowlineClient {
@@ -38,14 +38,21 @@ export class LowlineClient {
38
38
  judge(form, id, values) {
39
39
  return this.post(form, 'judge', { id, values });
40
40
  }
41
- async post(form, route, body) {
42
- const url = `${this.src.replace(/\/+$/, '')}/${encodeURIComponent(form)}/${route}`;
43
- const response = await this.fetcher(url, {
41
+ /** Per decided field, in the form's order, the thresholds chosen on this memory space's records and what the replay saw. */
42
+ report(form) {
43
+ return this.send(form, 'report', { method: 'GET', credentials: 'same-origin' });
44
+ }
45
+ post(form, route, body) {
46
+ return this.send(form, route, {
44
47
  method: 'POST',
45
48
  headers: { 'content-type': 'application/json' },
46
49
  body: JSON.stringify(body),
47
50
  credentials: 'same-origin',
48
51
  });
52
+ }
53
+ async send(form, route, init) {
54
+ const url = `${this.src.replace(/\/+$/, '')}/${encodeURIComponent(form)}/${route}`;
55
+ const response = await this.fetcher(url, init);
49
56
  if (!response.ok) {
50
57
  const problem = await response.json().catch(() => undefined);
51
58
  throw new LowlineError(response.status, problem?.detail ?? `${route} answered ${response.status}`);
@@ -1,3 +1,3 @@
1
1
  export { Draft, valuesOf, type Suggestion, type Value, type Values } from './draft.js';
2
2
  export { Session, englishStrings, type Abstain, type Basis, type FieldState, type Proposal, type Round, type Strings } from './session.js';
3
- export { LowlineClient, LowlineError } from './client.js';
3
+ export { LowlineClient, LowlineError, type FieldReport, type ThresholdChoice } from './client.js';
package/dist/session.d.ts CHANGED
@@ -10,7 +10,7 @@ export type Basis = {
10
10
  similarity: number;
11
11
  };
12
12
  /** Why a decided field is shown no suggestion. */
13
- export type Abstain = 'off' | 'no-evidence' | 'unsure' | 'not-allowed' | 'needs-judgement' | 'not-a-choice' | 'malformed';
13
+ export type Abstain = 'off' | 'no-evidence' | 'unsure' | 'not-allowed' | 'needs-judgement' | 'not-a-choice' | 'malformed' | 'together';
14
14
  /** What the host's engine says to show for one decided field. */
15
15
  export interface Proposal {
16
16
  field: string;
@@ -21,6 +21,14 @@ export interface Proposal {
21
21
  basis?: Basis[];
22
22
  abstain: Abstain | null;
23
23
  asks?: [string, string][];
24
+ /** For `together`: the fields of its group, still open, that are shown no suggestion. */
25
+ with?: string[];
26
+ /**
27
+ * How often an answer of this kind for this field has been right — the replay's precision at the threshold the
28
+ * suggestion was held to. Absent with no suggestion, for a judgement or a value from elsewhere, and before thresholds
29
+ * were chosen.
30
+ */
31
+ promise?: number;
24
32
  }
25
33
  /** What a field shows, as formdown's `fieldStates` takes it. */
26
34
  export interface FieldState {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iyulab/lowline-form",
3
- "version": "0.4.0",
3
+ "version": "0.6.0",
4
4
  "description": "The Lowline form element: a formdown form whose decided fields are suggested from the records people confirmed, talking to a Lowline host's routes.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -40,7 +40,7 @@
40
40
  "bundle": "vite build --config vite.bundle.config.ts"
41
41
  },
42
42
  "dependencies": {
43
- "@formdown/ui": "^0.24.0",
43
+ "@formdown/ui": "^0.25.0",
44
44
  "lit": "^3.3.3"
45
45
  },
46
46
  "devDependencies": {