@larc-iu/plaid-client 0.2.0-alpha.30 → 0.2.0-alpha.33
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/package.json +1 -1
- package/src/apiServer.d.ts +5 -3
- package/src/apiServer.js +5 -3
- package/src/entryForms.d.ts +7 -2
- package/src/entryForms.js +18 -6
package/package.json
CHANGED
package/src/apiServer.d.ts
CHANGED
|
@@ -131,9 +131,11 @@ export function adminApi(client: import("./client.js").PlaidClient): {
|
|
|
131
131
|
server: () => Promise<ServerReport>;
|
|
132
132
|
/**
|
|
133
133
|
* Take a database backup right now, outside the nightly schedule.
|
|
134
|
-
* Resolves to the backup block with `ok`
|
|
135
|
-
*
|
|
136
|
-
*
|
|
134
|
+
* Resolves to the backup block, with `ok` true, once the backup is
|
|
135
|
+
* written. A backup the server could not write rejects with status 500,
|
|
136
|
+
* and the error's `responseData` is the backup block with `ok` false (the
|
|
137
|
+
* reason is in the server log). Uses VACUUM INTO, which only reads, so it
|
|
138
|
+
* is safe while people are working. Admin only.
|
|
137
139
|
*
|
|
138
140
|
* The server answers once the backup is written, which takes minutes on
|
|
139
141
|
* a large database, so this waits up to `BACKUP_TIMEOUT_MS` (30 minutes)
|
package/src/apiServer.js
CHANGED
|
@@ -186,9 +186,11 @@ export function adminApi(client) {
|
|
|
186
186
|
server: () => client._request("GET", "/api/v1/admin/server"),
|
|
187
187
|
/**
|
|
188
188
|
* Take a database backup right now, outside the nightly schedule.
|
|
189
|
-
* Resolves to the backup block with `ok`
|
|
190
|
-
*
|
|
191
|
-
*
|
|
189
|
+
* Resolves to the backup block, with `ok` true, once the backup is
|
|
190
|
+
* written. A backup the server could not write rejects with status 500,
|
|
191
|
+
* and the error's `responseData` is the backup block with `ok` false (the
|
|
192
|
+
* reason is in the server log). Uses VACUUM INTO, which only reads, so it
|
|
193
|
+
* is safe while people are working. Admin only.
|
|
192
194
|
*
|
|
193
195
|
* The server answers once the backup is written, which takes minutes on
|
|
194
196
|
* a large database, so this waits up to `BACKUP_TIMEOUT_MS` (30 minutes)
|
package/src/entryForms.d.ts
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* A form written the way FieldWorks writes a morph standing alone: "-ar" for
|
|
3
3
|
* a suffix, "ka-" for a prefix, "=ni" for an enclitic, unchanged for a stem or
|
|
4
|
-
* for a type outside the table or none.
|
|
4
|
+
* for a type outside the table or none. `equalsBefore` says a "=" was typed
|
|
5
|
+
* before the morph (plaid-igt's `metadata.equalsBefore`, R47): its leading
|
|
6
|
+
* marker is then "=", whatever its type says ("=c" for a stem or a suffix).
|
|
5
7
|
*
|
|
6
8
|
* @template {string | null | undefined} F
|
|
7
9
|
* @param {string | null | undefined} morphType
|
|
8
10
|
* @param {F} form
|
|
11
|
+
* @param {{ equalsBefore?: boolean }} [options]
|
|
9
12
|
* @returns {F | string}
|
|
10
13
|
*/
|
|
11
|
-
export function decorateWithAffixMarkers<F extends string | null | undefined>(morphType: string | null | undefined, form: F
|
|
14
|
+
export function decorateWithAffixMarkers<F extends string | null | undefined>(morphType: string | null | undefined, form: F, { equalsBefore }?: {
|
|
15
|
+
equalsBefore?: boolean;
|
|
16
|
+
}): F | string;
|
|
12
17
|
/**
|
|
13
18
|
* A morph form as FieldWorks writes it, read back: the inverse of
|
|
14
19
|
* decorateWithAffixMarkers. A morph of a known type loses exactly that type's
|
package/src/entryForms.js
CHANGED
|
@@ -69,17 +69,27 @@ const TYPE_BY_MARKERS = Object.freeze({
|
|
|
69
69
|
/**
|
|
70
70
|
* A form written the way FieldWorks writes a morph standing alone: "-ar" for
|
|
71
71
|
* a suffix, "ka-" for a prefix, "=ni" for an enclitic, unchanged for a stem or
|
|
72
|
-
* for a type outside the table or none.
|
|
72
|
+
* for a type outside the table or none. `equalsBefore` says a "=" was typed
|
|
73
|
+
* before the morph (plaid-igt's `metadata.equalsBefore`, R47): its leading
|
|
74
|
+
* marker is then "=", whatever its type says ("=c" for a stem or a suffix).
|
|
73
75
|
*
|
|
74
76
|
* @template {string | null | undefined} F
|
|
75
77
|
* @param {string | null | undefined} morphType
|
|
76
78
|
* @param {F} form
|
|
79
|
+
* @param {{ equalsBefore?: boolean }} [options]
|
|
77
80
|
* @returns {F | string}
|
|
78
81
|
*/
|
|
79
|
-
export function decorateWithAffixMarkers(
|
|
82
|
+
export function decorateWithAffixMarkers(
|
|
83
|
+
morphType,
|
|
84
|
+
form,
|
|
85
|
+
{ equalsBefore = false } = {},
|
|
86
|
+
) {
|
|
80
87
|
if (form == null || form === "") return form;
|
|
81
|
-
const marks = MORPH_TYPE_MARKERS[String(morphType ?? "").toLowerCase()]
|
|
82
|
-
|
|
88
|
+
const marks = MORPH_TYPE_MARKERS[String(morphType ?? "").toLowerCase()] ?? [
|
|
89
|
+
"",
|
|
90
|
+
"",
|
|
91
|
+
];
|
|
92
|
+
return `${equalsBefore ? "=" : marks[0]}${form}${marks[1]}`;
|
|
83
93
|
}
|
|
84
94
|
|
|
85
95
|
/** @param {string} form @param {string} type */
|
|
@@ -96,11 +106,13 @@ const strips = (form, type) => {
|
|
|
96
106
|
// A form whose bare middle holds whitespace is free text ("-du, du-"), so its
|
|
97
107
|
// markers name no type and stay. WHITESPACE spells out JS's \s, so the
|
|
98
108
|
// Python client's copy matches it character for character.
|
|
99
|
-
const WHITESPACE =
|
|
109
|
+
const WHITESPACE =
|
|
110
|
+
/[\t\n\v\f\r \u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]/u;
|
|
100
111
|
/** @param {string} form */
|
|
101
112
|
const markedType = (form) => {
|
|
102
113
|
const m = /^([-=]?)(.+?)([-=]?)$/su.exec(form);
|
|
103
|
-
const type =
|
|
114
|
+
const type =
|
|
115
|
+
m && !WHITESPACE.test(m[2]) && TYPE_BY_MARKERS[`${m[1]},${m[3]}`];
|
|
104
116
|
return type && m ? { form: m[2], morphType: type } : null;
|
|
105
117
|
};
|
|
106
118
|
|