@larc-iu/plaid-client 0.2.0-alpha.30 → 0.2.0-alpha.32

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@larc-iu/plaid-client",
3
- "version": "0.2.0-alpha.30",
3
+ "version": "0.2.0-alpha.32",
4
4
  "description": "JavaScript client for the Plaid annotation API",
5
5
  "type": "module",
6
6
  "repository": {
@@ -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` reporting whether the snapshot
135
- * succeeded. Uses VACUUM INTO, which only reads, so it is safe while
136
- * people are working. Admin only.
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` reporting whether the snapshot
190
- * succeeded. Uses VACUUM INTO, which only reads, so it is safe while
191
- * people are working. Admin only.
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)
@@ -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): F | string;
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(morphType, form) {
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
- return marks ? `${marks[0]}${form}${marks[1]}` : form;
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 = /[\t\n\v\f\r \u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]/u;
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 = m && !WHITESPACE.test(m[2]) && TYPE_BY_MARKERS[`${m[1]},${m[3]}`];
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