@larc-iu/plaid-client 0.2.0-alpha.14 → 0.2.0-alpha.16
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/index.d.ts +91 -22
- package/package.json +1 -1
- package/src/http.js +112 -95
- package/src/index.js +244 -192
- package/src/pagination.js +3 -7
- package/src/serviceSchema.js +27 -1
- package/src/services.js +14 -22
package/src/pagination.js
CHANGED
|
@@ -11,10 +11,9 @@
|
|
|
11
11
|
* headers, base URL, and response transforms all apply exactly as for any
|
|
12
12
|
* other request.
|
|
13
13
|
*
|
|
14
|
-
* A page is a read, so
|
|
15
|
-
* (see the
|
|
16
|
-
*
|
|
17
|
-
* pool, in order, against the state the batch has not committed yet.
|
|
14
|
+
* A page is a read, so it goes over the wire even when the helper is handed a
|
|
15
|
+
* batch (see the note at the top of http.js): each page is answered from the
|
|
16
|
+
* pool, in order, against the state no batch has committed yet.
|
|
18
17
|
*/
|
|
19
18
|
|
|
20
19
|
// Merge caller query params with paging params, dropping undefined/null so we
|
|
@@ -57,7 +56,6 @@ export async function listAll(client, path, { pageSize = 1000, query = {} } = {}
|
|
|
57
56
|
do {
|
|
58
57
|
const response = await client._request('GET', path, {
|
|
59
58
|
queryParams: buildQueryParams(query, pageSize, cursor),
|
|
60
|
-
bypassBatch: true,
|
|
61
59
|
});
|
|
62
60
|
all.push(...entriesOf(response, path));
|
|
63
61
|
prevCursor = cursor;
|
|
@@ -87,7 +85,6 @@ export async function listAll(client, path, { pageSize = 1000, query = {} } = {}
|
|
|
87
85
|
export async function listPage(client, path, { limit, cursor, query = {} } = {}) {
|
|
88
86
|
return client._request('GET', path, {
|
|
89
87
|
queryParams: buildQueryParams(query, limit, cursor),
|
|
90
|
-
bypassBatch: true,
|
|
91
88
|
});
|
|
92
89
|
}
|
|
93
90
|
|
|
@@ -108,7 +105,6 @@ export async function* iterPages(client, path, { pageSize = 1000, query = {} } =
|
|
|
108
105
|
do {
|
|
109
106
|
const response = await client._request('GET', path, {
|
|
110
107
|
queryParams: buildQueryParams(query, pageSize, cursor),
|
|
111
|
-
bypassBatch: true,
|
|
112
108
|
});
|
|
113
109
|
const entries = entriesOf(response, path);
|
|
114
110
|
// Suppress the trailing empty page that the server emits when a collection's
|
package/src/serviceSchema.js
CHANGED
|
@@ -22,10 +22,15 @@
|
|
|
22
22
|
* { key, label, type, description?, default?, required?,
|
|
23
23
|
* options?: [{value, label}], // enum / multiselect
|
|
24
24
|
* min?, max?, step?, slider?, // number (slider: drag, don't type)
|
|
25
|
-
* placeholder?, multiline
|
|
25
|
+
* placeholder?, multiline?, // string
|
|
26
|
+
* scope? } // field: 'Sentence' | 'Word' | 'Morpheme'
|
|
26
27
|
* ]
|
|
27
28
|
* }
|
|
28
29
|
*
|
|
30
|
+
* A `field` parameter names one of the project's annotation fields at its
|
|
31
|
+
* `scope`. A UI that knows the project offers those fields to choose from; to
|
|
32
|
+
* everything here, and to a UI that does not, it is a string.
|
|
33
|
+
*
|
|
29
34
|
* A parameter's `key` is a string VALUE, so it passes over the wire verbatim;
|
|
30
35
|
* the UI sends `{ [param.key]: value }` in the request data. Declare each `key`
|
|
31
36
|
* in your service's own convention (Python: snake_case; JS: camelCase) and read
|
|
@@ -50,6 +55,20 @@ export const TASKS = Object.freeze({
|
|
|
50
55
|
LINK_VOCAB: "link-vocab",
|
|
51
56
|
/** Propose an interlinear analysis (morpheme segmentation + glosses) for words. */
|
|
52
57
|
ANALYZE: "analyze",
|
|
58
|
+
/**
|
|
59
|
+
* Draft a meaning representation graph over the sentences of a document,
|
|
60
|
+
* for correction by hand. The request names a `scope` ('document' or
|
|
61
|
+
* 'sentence'), a `sentence` number when the scope is one sentence, and
|
|
62
|
+
* `overwrite`. See plaid-umr's drafting services.
|
|
63
|
+
*
|
|
64
|
+
* Apart from `analyze` on purpose. A task is the CONTRACT a spot offers a
|
|
65
|
+
* service against, and these two share almost none of it: an analyze
|
|
66
|
+
* request names the three token layers plus the language, metalanguage and
|
|
67
|
+
* orthography, and writes morphemes and glosses. Both claimed `analyze` for
|
|
68
|
+
* a while, so every app offering an analyze spot offered the other app's
|
|
69
|
+
* services, which could not answer the request they would have been given.
|
|
70
|
+
*/
|
|
71
|
+
DRAFT_GRAPH: "draft-graph",
|
|
53
72
|
/** Propose a free translation for each sentence. */
|
|
54
73
|
TRANSLATE: "translate",
|
|
55
74
|
/**
|
|
@@ -64,6 +83,13 @@ export const TASKS = Object.freeze({
|
|
|
64
83
|
DETECT_SPEECH: "detect-speech",
|
|
65
84
|
/** A conversational assistant over a project (chat turns; see plaid-agent). */
|
|
66
85
|
ASSIST: "assist",
|
|
86
|
+
/**
|
|
87
|
+
* Score one document's annotation against another document's of the same
|
|
88
|
+
* text (two annotators' copies), writing a report on the scored document's
|
|
89
|
+
* metadata and never an annotation. The request names the other document
|
|
90
|
+
* as `against`. See plaid-umr's AnCast service.
|
|
91
|
+
*/
|
|
92
|
+
COMPARE: "compare",
|
|
67
93
|
});
|
|
68
94
|
|
|
69
95
|
/**
|
package/src/services.js
CHANGED
|
@@ -92,14 +92,7 @@ export function serviceErrorMessage(error, serviceName = '', secrets = []) {
|
|
|
92
92
|
* @returns {Promise<Array>} [{serviceId, serviceName, description, extras, online, lastSeenAt}]
|
|
93
93
|
*/
|
|
94
94
|
export function discoverServices(client, projectId) {
|
|
95
|
-
|
|
96
|
-
// happens to be open on this shared client. The assistant's availability
|
|
97
|
-
// probe polls for 49 seconds after a mount and landed inside a Grew rewrite
|
|
98
|
-
// or an import, where the answer was `{batched: true}`, cached as the
|
|
99
|
-
// service list, and every later render threw on it until a reload.
|
|
100
|
-
return client._request('GET', `/api/v1/projects/${projectId}/services`, {
|
|
101
|
-
bypassBatch: true,
|
|
102
|
-
});
|
|
95
|
+
return client._request('GET', `/api/v1/projects/${projectId}/services`);
|
|
103
96
|
}
|
|
104
97
|
|
|
105
98
|
/**
|
|
@@ -113,17 +106,21 @@ export function discoverServices(client, projectId) {
|
|
|
113
106
|
* @returns {Promise<void>}
|
|
114
107
|
*/
|
|
115
108
|
export function discardService(client, projectId, serviceId) {
|
|
116
|
-
|
|
109
|
+
// outOfBand: the registry is not project data (see the note at the top of
|
|
110
|
+
// http.js).
|
|
111
|
+
return client._request('DELETE', `/api/v1/projects/${projectId}/services/${encodeURIComponent(serviceId)}`, {
|
|
112
|
+
outOfBand: true,
|
|
113
|
+
});
|
|
117
114
|
}
|
|
118
115
|
|
|
119
116
|
/**
|
|
120
117
|
* POST a progress, result or error event for an in-flight request; the server
|
|
121
118
|
* relays it to the waiting requester. The Python twin is `_report_event`.
|
|
122
119
|
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
120
|
+
* outOfBand: these are signals to whoever is waiting, not writes to the
|
|
121
|
+
* project (see the note at the top of http.js). A service may report them on
|
|
122
|
+
* the batch it is filling, where queueing them would hold every one back until
|
|
123
|
+
* submit, deliver none at all if the batch aborts, and take slots in the
|
|
127
124
|
* batch's results. The requester would hear nothing and wait out its idle
|
|
128
125
|
* timeout on work that had already finished.
|
|
129
126
|
*
|
|
@@ -137,7 +134,7 @@ export function reportRequestEvent(client, projectId, requestId, body) {
|
|
|
137
134
|
return client._request(
|
|
138
135
|
'POST',
|
|
139
136
|
`/api/v1/projects/${projectId}/service-requests/${encodeURIComponent(requestId)}/events`,
|
|
140
|
-
{ body,
|
|
137
|
+
{ body, outOfBand: true },
|
|
141
138
|
);
|
|
142
139
|
}
|
|
143
140
|
|
|
@@ -487,13 +484,8 @@ export function createCancelScope(isCancelled) {
|
|
|
487
484
|
* still ends with whatever the service then reports, on the stream of whoever
|
|
488
485
|
* is awaiting it. Rejects with 404 if unknown or expired, 409 once finished.
|
|
489
486
|
*
|
|
490
|
-
*
|
|
491
|
-
*
|
|
492
|
-
* data. The Stop button lives in the app's chrome, on the same client an
|
|
493
|
-
* import or a bulk edit is batching on, and a stop that waits for that batch to
|
|
494
|
-
* submit has stopped nothing (and if the batch aborts, it never arrives at
|
|
495
|
-
* all), while the queued DELETE shifts every result index the batch's caller
|
|
496
|
-
* reads back.
|
|
487
|
+
* outOfBand: a DELETE, but not a write. It signals a running service and
|
|
488
|
+
* changes no project data (see the note at the top of http.js).
|
|
497
489
|
*
|
|
498
490
|
* @param {Object} client - PlaidClient instance
|
|
499
491
|
* @param {string} projectId - Project UUID
|
|
@@ -504,7 +496,7 @@ export function cancelServiceRequest(client, projectId, requestId) {
|
|
|
504
496
|
return client._request(
|
|
505
497
|
'DELETE',
|
|
506
498
|
`/api/v1/projects/${projectId}/service-requests/${encodeURIComponent(requestId)}`,
|
|
507
|
-
{
|
|
499
|
+
{ outOfBand: true },
|
|
508
500
|
);
|
|
509
501
|
}
|
|
510
502
|
|