Skip to content

Commit 24e53dc

Browse files
authored
chore(deps): vendor the client at sdk 07dba3d (#84)
The client asks the file selector only for its keys and reads nested columns. Shares accept the name_corrected assumption and the view states it as a corrected name.
1 parent 95731cd commit 24e53dc

7 files changed

Lines changed: 47 additions & 16 deletions

File tree

‎pnpm-lock.yaml‎

Lines changed: 6 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/lib/search/searchShareRequest.ts‎

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -91,25 +91,33 @@ const isEntityGroups = (value: any): value is Record<string, EntityGroup> =>
9191
// Keyed by every kind the wire names, so a kind Search adds fails the type
9292
// check until this list takes it.
9393
const ASSUMPTION_KINDS: Record<AssumptionKind, true> = {
94+
name_corrected: true,
9495
declared_default: true,
9596
open_role: true,
9697
place_scope: true,
9798
};
9899

99-
// Search's own bounds on an echoed `Assumption`: a text of 1 to 200 code
100-
// points, at most one ref of at most 1024 characters, a binding ref of at
101-
// most 1036 characters, and at most 67 items in a part's list. A share
102-
// storing one past them cannot open.
100+
// Search's own bounds on an echoed `Assumption`: a text, and an `asked`, of
101+
// 1 to 200 code points, at most one ref of at most 1024 characters, a binding
102+
// ref of at most 1036 characters, and at most 67 items in a part's list. A
103+
// share storing one past them cannot open.
103104
const ASSUMPTION_TEXT_MAX_LENGTH = 200;
104105
const ASSUMPTION_MAX_REFS = 1;
105106
const ASSUMPTION_REF_MAX_LENGTH = 1024;
106107
const ASSUMPTION_BINDING_REF_MAX_LENGTH = 1036;
107108
const ASSUMPTIONS_MAX = 67;
108109

110+
// Words within the bound span at most two UTF-16 units per code point.
111+
const isAssumptionWords = (value: unknown): boolean =>
112+
typeof value === 'string' &&
113+
value.length > 0 &&
114+
value.length <= ASSUMPTION_TEXT_MAX_LENGTH * 2 &&
115+
[...value].length <= ASSUMPTION_TEXT_MAX_LENGTH;
116+
109117
const isAssumption = (value: any): value is Assumption =>
110118
isPlainObject(value) &&
111119
Object.keys(value).every((member) =>
112-
['kind', 'binding_ref', 'refs', 'text'].includes(member),
120+
['kind', 'binding_ref', 'refs', 'text', 'asked'].includes(member),
113121
) &&
114122
typeof value.kind === 'string' &&
115123
hasKey(ASSUMPTION_KINDS, value.kind) &&
@@ -123,11 +131,9 @@ const isAssumption = (value: any): value is Assumption =>
123131
(ref: unknown) =>
124132
typeof ref === 'string' && ref.length <= ASSUMPTION_REF_MAX_LENGTH,
125133
))) &&
126-
typeof value.text === 'string' &&
127-
value.text.length > 0 &&
128-
// A text within the bound spans at most two UTF-16 units per code point.
129-
value.text.length <= ASSUMPTION_TEXT_MAX_LENGTH * 2 &&
130-
[...value.text].length <= ASSUMPTION_TEXT_MAX_LENGTH;
134+
isAssumptionWords(value.text) &&
135+
// `asked` is set on a corrected name only, and absent or null on the rest.
136+
(value.asked == null || isAssumptionWords(value.asked));
131137

132138
/** A part's echoed list as Search takes it: within the item cap, every item
133139
* an `Assumption` within its bounds. */

‎src/lib/search/test/searchShareRequest.test.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,17 @@ test('a part reads with its assumptions, [] and null included, and a malformed o
107107
const scope = { kind: 'place_scope', binding_ref: 'where:', refs: [], text: 'every country' };
108108
// The wire's `refs` is optional, so an item without it reads.
109109
const donors = { kind: 'open_role', binding_ref: 'origin:', text: 'every donor' };
110+
const germany = {
111+
kind: 'name_corrected',
112+
binding_ref: 'origin:',
113+
refs: ['country/DEU'],
114+
text: '"Germny" read as Germany',
115+
asked: 'Germny',
116+
};
110117

111118
assert.deepEqual(reads([oda, scope])?.assumptions, [oda, scope]);
112119
assert.deepEqual(reads([donors])?.assumptions, [donors]);
120+
assert.deepEqual(reads([germany])?.assumptions, [germany]);
113121
assert.deepEqual(reads([])?.assumptions, []);
114122
assert.equal(reads(null)?.assumptions, null);
115123
assert.ok(reads(undefined));
@@ -121,6 +129,9 @@ test('a part reads with its assumptions, [] and null included, and a malformed o
121129
[{ ...oda, refs: null }],
122130
[{ ...oda, text: null }],
123131
[{ ...oda, note: 'extra' }],
132+
[{ ...germany, asked: '' }],
133+
[{ ...germany, asked: 'a'.repeat(201) }],
134+
[{ ...germany, asked: 7 }],
124135
[{ ...oda, text: '' }],
125136
[{ ...oda, text: 'a'.repeat(201) }],
126137
[{ ...oda, refs: ['ODA', 'OOF'] }],

‎src/lib/search/test/why.test.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,14 @@ test('many variables: rows name the role scope and the list reads the members do
140140
{ label: 'Recipients', value: 'All 191 with data' },
141141
]);
142142
// No time_window_defaulted on the wire: the headline's year_named says it.
143+
assert.equal(
144+
scopeAssumptions(
145+
oda,
146+
[{ ...openRecipients, kind: 'name_corrected', text: '"Germny" read as Germany' }],
147+
[],
148+
)[0],
149+
'"Germny" read as Germany.',
150+
);
143151
assert.deepEqual(scopeAssumptions(oda, [openRecipients], odaWarnings), [
144152
'The question left this role open, so the answer covers every recipient from Germany.',
145153
'No year was named, so the counts are for 2024, the latest year with data.',

‎src/lib/search/types.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ export type DeclinedReason = wire.DeclinedAnswer['reason'];
116116
/** Which candidate universe the options door enumerates for a place role. */
117117
export type PlaceOptionsScope = Present<Known<wire.OptionsFor['scope']>>;
118118

119-
/** What an assumption fills: a declared default, an open flow role, or the place scope. */
119+
/** What an assumption fills: a corrected name, a declared default, an open flow role, or the place
120+
* scope. */
120121
export type AssumptionKind = Known<wire.Assumption['kind']>;
121122

122123
/** The block of the answer a sentence token belongs to. */

‎src/lib/search/view.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1259,6 +1259,9 @@ const lowerFirst = (text: string): string =>
12591259
const assumptionSentence = (spec: SpecReading, assumption: Assumption): string => {
12601260
const { kind, binding_ref: ref, text } = assumption;
12611261

1262+
// The text states the correction whole: '"Germny" read as Germany'.
1263+
if (kind === 'name_corrected') return `${text}.`;
1264+
12621265
if (kind === 'place_scope') return `No place was named, so the answer covers ${text}.`;
12631266

12641267
if (kind === 'open_role') {
@@ -1279,7 +1282,7 @@ const assumptionSentence = (spec: SpecReading, assumption: Assumption): string =
12791282
};
12801283

12811284
/** What a definite part's answer assumed: one sentence per item of the
1282-
* part's `assumptions` (a declared default, an open role, the place scope),
1285+
* part's `assumptions` (a corrected name, a declared default, an open role, the place scope),
12831286
* in the API's order, then the year. "About this answer" reads this list
12841287
* (through resultNotes's aboutAnswerNotes). The year sentence keys on
12851288
* `headline.year_named` as well as `time_window_defaulted`, since a
44.8 KB
Binary file not shown.

0 commit comments

Comments
 (0)