@zveltio/sdk 3.0.0-beta.113 → 3.0.0-beta.122
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/README.md +6 -0
- package/dist/client.d.ts +24 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +15 -0
- package/dist/extension/capabilities.d.ts +1 -11
- package/dist/extension/capabilities.d.ts.map +1 -1
- package/dist/extension/capabilities.js +1 -11
- package/dist/extension/index.d.ts +90 -149
- package/dist/extension/index.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/schema-codegen.d.ts +3 -0
- package/dist/schema-codegen.d.ts.map +1 -1
- package/dist/schema-codegen.js +6 -2
- package/dist/tests/client.test.js +20 -0
- package/dist/tests/validate-manifest-actions.test.js +8 -0
- package/dist/tests/view-runtime.test.js +33 -1
- package/dist/tests/view.test.js +13 -1
- package/dist/validate/index.d.ts.map +1 -1
- package/dist/validate/index.js +13 -2
- package/dist/validate/shared-message-keys.d.ts +1 -1
- package/dist/validate/shared-message-keys.d.ts.map +1 -1
- package/dist/validate/shared-message-keys.js +2 -1
- package/dist/view/index.d.ts.map +1 -1
- package/dist/view/index.js +9 -2
- package/dist/view/runtime.d.ts +24 -1
- package/dist/view/runtime.d.ts.map +1 -1
- package/dist/view/runtime.js +55 -0
- package/dist/view/schema.d.ts.map +1 -1
- package/dist/view/schema.js +21 -1
- package/dist/view/types.generated.d.ts +33 -12
- package/dist/view/types.generated.d.ts.map +1 -1
- package/package.json +1 -1
- package/schemas/view-2.schema.json +100 -24
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACjE,YAAY,EACV,UAAU,EACV,YAAY,EACZ,iBAAiB,EACjB,cAA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AAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,YAAY,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,YAAY,EACV,gBAAgB,EAChB,gBAAgB,EAChB,oBAAoB,EACpB,kBAAkB,EAClB,WAAW,EACX,eAAe,EACf,mBAAmB,GACpB,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACnE,YAAY,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC/D,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAG1B,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACjE,YAAY,EAAE,gBAAgB,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC"}
|
package/dist/schema-codegen.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema-codegen.d.ts","sourceRoot":"","sources":["../src/schema-codegen.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,MAAM,WAAW,MAAM;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,mFAAmF;IACnF,MAAM,EAAE,MAAM,CAAC;IACf,qEAAqE;IACrE,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,KAAK;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,KAAK,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TYPES = {
|
|
|
422
422
|
uuid: 'string',
|
|
423
423
|
json: 'Record<string, any>',
|
|
424
424
|
richtext: 'string',
|
|
425
|
-
file: '{
|
|
425
|
+
file: '{ id: string; name: string; size?: number; type?: string }',
|
|
426
426
|
enum: 'string',
|
|
427
427
|
reference: 'string',
|
|
428
428
|
m2o: 'string',
|
|
@@ -471,7 +471,11 @@ export const CORE_FIELD_TS_TYPES = {
|
|
|
471
471
|
export function emitCollectionTypes(collection, tsTypeOf = (t) => CORE_FIELD_TS_TYPES[t]) {
|
|
472
472
|
const typeName = collection.name.charAt(0).toUpperCase() + collection.name.slice(1);
|
|
473
473
|
const inputFields = collection.fields
|
|
474
|
-
.map((f) =>
|
|
474
|
+
.map((f) => {
|
|
475
|
+
const one = tsTypeOf(f.type) || 'any';
|
|
476
|
+
// `options.multiple` stores a list of the type (a `file` field's files).
|
|
477
|
+
return ` ${f.name}${f.required ? '' : '?'}: ${f.options?.multiple ? `Array<${one}>` : one};`;
|
|
478
|
+
})
|
|
475
479
|
.join('\n');
|
|
476
480
|
return `export interface ${typeName}Input {
|
|
477
481
|
${inputFields}
|
|
@@ -27,6 +27,26 @@ describe('ZveltioClient URL building', () => {
|
|
|
27
27
|
'https://engine.test/api/data/products/a%2Fb',
|
|
28
28
|
]);
|
|
29
29
|
});
|
|
30
|
+
it('aggregate() names the route and the query the engine parses (ADR 0050)', async () => {
|
|
31
|
+
const urls = captureUrls();
|
|
32
|
+
const client = createZveltioClient({ baseUrl: 'https://engine.test' });
|
|
33
|
+
await client.collection('orders').aggregate({
|
|
34
|
+
fn: ['count', 'sum:total'],
|
|
35
|
+
groupBy: ['status', 'placed_at'],
|
|
36
|
+
bucket: 'placed_at:month',
|
|
37
|
+
filter: { status: { eq: 'open' } },
|
|
38
|
+
limit: 10,
|
|
39
|
+
});
|
|
40
|
+
const url = new URL(urls[0]);
|
|
41
|
+
expect(url.pathname).toBe('/api/data/orders/aggregate');
|
|
42
|
+
expect(Object.fromEntries(url.searchParams)).toEqual({
|
|
43
|
+
fn: 'count,sum:total',
|
|
44
|
+
group_by: 'status,placed_at',
|
|
45
|
+
bucket: 'placed_at:month',
|
|
46
|
+
filter: '{"status":{"eq":"open"}}',
|
|
47
|
+
limit: '10',
|
|
48
|
+
});
|
|
49
|
+
});
|
|
30
50
|
it('asks the engine who its key is at the route that answers it', async () => {
|
|
31
51
|
const urls = captureUrls();
|
|
32
52
|
const client = createZveltioClient({ baseUrl: 'https://engine.test', apiKey: 'zvk_x' });
|
|
@@ -89,4 +89,12 @@ describe('manifest collections', () => {
|
|
|
89
89
|
jobs: [slots(['mail']), { ...slots([{ name: 'mail', kind: 'tcp' }]), name: 'other' }],
|
|
90
90
|
})).toEqual(['job "other": slot "mail" is declared both "http" and "tcp"']);
|
|
91
91
|
});
|
|
92
|
+
it('refuses "*" in a job, and as an action\'s gate (ADR 0047)', () => {
|
|
93
|
+
const any = { ...action, enqueues: [], reads: ['*'], writes: ['*'] };
|
|
94
|
+
expect(errors({ actions: [any] })).toEqual([]);
|
|
95
|
+
expect(errors({ actions: [action], jobs: [{ ...job, reads: ['*'] }] })).toEqual([
|
|
96
|
+
'job "notify" lists "*" in reads: only an action reaches any collection, as its caller; a job lists each one',
|
|
97
|
+
]);
|
|
98
|
+
expect(errors({ actions: [{ ...any, permission: { resource: '*' } }] })).toHaveLength(1);
|
|
99
|
+
});
|
|
92
100
|
});
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { describe, expect, it } from 'bun:test';
|
|
4
4
|
import { readFileSync } from 'node:fs';
|
|
5
5
|
import { join } from 'node:path';
|
|
6
|
-
import { $, actionPath, defaultView, fallbackFor, isEditable, matches, readActionResult, resolveInput, toFilter, toSort, validateView, } from '../view/index.js';
|
|
6
|
+
import { $, actionPath, defaultView, fallbackFor, isBound, isEditable, matches, fileIds, readActionResult, resolveFiles, resolveInput, toFilter, toSort, validateView, } from '../view/index.js';
|
|
7
7
|
const scope = {
|
|
8
8
|
record: { id: 'r1', status: 'open', total: 5 },
|
|
9
9
|
selected: { folders: 'f9' },
|
|
@@ -37,6 +37,38 @@ describe('references', () => {
|
|
|
37
37
|
expect(toFilter([$.where('folder_id', 'eq', $.selected('other'))], scope)).toBeNull();
|
|
38
38
|
});
|
|
39
39
|
});
|
|
40
|
+
describe('a button whose reference has no value yet', () => {
|
|
41
|
+
const none = { ...scope, selected: {} };
|
|
42
|
+
it('is not bound while the pane it names has no selection, and is once it has', () => {
|
|
43
|
+
const b = { action: 'dismissScan', input: { scan_id: $.selected('folders') } };
|
|
44
|
+
expect(isBound(b, none)).toBe(false);
|
|
45
|
+
expect(isBound(b, scope)).toBe(true);
|
|
46
|
+
expect(isBound({ navigate: 'folder', params: { id: $.selected('folders') } }, none)).toBe(false);
|
|
47
|
+
expect(isBound({ action: 'a', files: { read: $.selected('folders') } }, none)).toBe(false);
|
|
48
|
+
});
|
|
49
|
+
it('counts no prompt, no literal, and no save button', () => {
|
|
50
|
+
expect(isBound({ action: 'scan', prompt: ['collection'] }, none)).toBe(true);
|
|
51
|
+
expect(isBound({ action: 'a', input: { n: 1 } }, {})).toBe(true);
|
|
52
|
+
expect(isBound({ save: true }, {})).toBe(true);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
describe('files a button hands its action ($files, ADR 0032)', () => {
|
|
56
|
+
const file = (id) => ({ id, name: `${id}.pdf`, size: 1, type: 'application/pdf' });
|
|
57
|
+
it("reads ids from an id, a file field's value, or a list of them", () => {
|
|
58
|
+
expect(fileIds('f1')).toEqual(['f1']);
|
|
59
|
+
expect(fileIds(file('f1'))).toEqual(['f1']);
|
|
60
|
+
expect(fileIds([file('f1'), 'f2', file('f1'), { name: 'no id' }, null])).toEqual(['f1', 'f2']);
|
|
61
|
+
expect(fileIds(null)).toEqual([]);
|
|
62
|
+
});
|
|
63
|
+
it('resolves read and write; hands nothing for an empty read; waits on an unresolved one', () => {
|
|
64
|
+
const s = { record: { a: [file('f1')], none: [], filename: 'x.pdf', size: '2048' } };
|
|
65
|
+
expect(resolveFiles({ read: $.record('a') }, s)).toEqual({ read: ['f1'] });
|
|
66
|
+
expect(resolveFiles({ read: $.record('none') }, s)).toBeUndefined();
|
|
67
|
+
expect(resolveFiles(undefined, s)).toBeUndefined();
|
|
68
|
+
expect(resolveFiles({ write: { name: $.record('filename'), maxBytes: $.record('size') } }, s)).toEqual({ write: { name: 'x.pdf', maxBytes: 2048 } });
|
|
69
|
+
expect(resolveFiles({ read: $.selected('nope') }, s)).toBeNull();
|
|
70
|
+
});
|
|
71
|
+
});
|
|
40
72
|
describe('toFilter', () => {
|
|
41
73
|
it('builds the data API JSON filter, several operators on one field', () => {
|
|
42
74
|
expect(toFilter([
|
package/dist/tests/view.test.js
CHANGED
|
@@ -130,21 +130,33 @@ describe('viewNameIssues', () => {
|
|
|
130
130
|
{
|
|
131
131
|
type: 'list',
|
|
132
132
|
collection: 'mail_messages',
|
|
133
|
-
fields: [
|
|
133
|
+
fields: [
|
|
134
|
+
'subject',
|
|
135
|
+
{ field: 'sujbect', label: 'Subject' },
|
|
136
|
+
{ field: 'subject', fallback: 'sbj' },
|
|
137
|
+
],
|
|
134
138
|
filter: [{ field: 'read', op: 'eq', value: false }],
|
|
135
139
|
sort: ['-created_at', 'sent'],
|
|
136
140
|
rowActions: [{ action: 'send', label: 'Send', input: { subject: 'x' } }],
|
|
137
141
|
},
|
|
138
142
|
{ type: 'board', collection: 'mail_messages', groupBy: 'folder', card: ['subject'] },
|
|
139
143
|
{ type: 'stat', source: { collection: 'mail_messages', aggregate: 'sum', field: 'size' } },
|
|
144
|
+
{
|
|
145
|
+
type: 'detail',
|
|
146
|
+
collection: 'mail_messages',
|
|
147
|
+
record: { $param: 'id' },
|
|
148
|
+
onOpen: { action: 'send', when: [{ field: 'unread', op: 'eq', value: true }] },
|
|
149
|
+
},
|
|
140
150
|
],
|
|
141
151
|
};
|
|
142
152
|
const fields = new Map([['mail_messages', ['id', 'created_at', 'subject', 'folder']]]);
|
|
143
153
|
expect(viewNameIssues(v, { ...names, fields }).map((i) => i.path)).toEqual([
|
|
144
154
|
'/panes/0/fields/1/field',
|
|
155
|
+
'/panes/0/fields/2/fallback',
|
|
145
156
|
'/panes/0/filter/0/field',
|
|
146
157
|
'/panes/0/sort/1',
|
|
147
158
|
'/panes/2/source/field',
|
|
159
|
+
'/panes/3/onOpen/when/0/field',
|
|
148
160
|
]);
|
|
149
161
|
expect(viewNameIssues(v, names)).toEqual([]);
|
|
150
162
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/validate/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAKH,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAK/D,MAAM,WAAW,eAAe;IAC9B,oEAAoE;IACpE,IAAI,EAAE,MAAM,CAAC;IACb,+BAA+B;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,+EAA+E;IAC/E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,6EAA6E;IAC7E,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CAChC;AAED,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,OAAO,CAAC;IACZ,MAAM,EAAE,eAAe,EAAE,CAAC;IAC1B,oDAAoD;IACpD,KAAK,EAAE;QACL,MAAM,EAAE,MAAM,CAAC;QACf,UAAU,EAAE,MAAM,CAAC;QACnB,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC;CACH;AAsDD,MAAM,WAAW,uBAAuB;IACtC,+DAA+D;IAC/D,QAAQ,EAAE,OAAO,CAAC;IAClB,0EAA0E;IAC1E,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,uBAAuB,GAAG,eAAe,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/validate/index.ts"],"names":[],"mappings":"AAAA;;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AE,GAAG,MAAM,EAAE,CAoBzE;AAID,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,uBAAuB,CAAC;IAClC,QAAQ,EAAE,uBAAuB,CAAC;IAClC,UAAU,EAAE,yBAAyB,CAAC;IACtC,YAAY,EAAE,iBAAiB,CAAC;IAChC,UAAU,CAAC,EAAE,eAAe,CAAC;IAC7B,qEAAqE;IACrE,KAAK,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC;CAC/C;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,GAAG,gBAAgB,CAkBjF"}
|
package/dist/validate/index.js
CHANGED
|
@@ -245,10 +245,21 @@ export function validateManifest(input) {
|
|
|
245
245
|
}
|
|
246
246
|
}
|
|
247
247
|
const jobs = entries('jobs', 'MANIFEST_BAD_JOB');
|
|
248
|
+
// ADR 0047: `"*"` reaches any collection as the caller — an action's, never a job's.
|
|
249
|
+
for (const j of jobs) {
|
|
250
|
+
for (const k of ['reads', 'writes']) {
|
|
251
|
+
if (Array.isArray(j[k]) && j[k].includes('*')) {
|
|
252
|
+
out.push(err('MANIFEST_BAD_JOB', `job "${j.name}" lists "*" in ${k}: only an action reaches any collection, as its caller; a job lists each one`));
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
248
256
|
const resources = Array.isArray(obj.resources) ? obj.resources : [];
|
|
249
257
|
const actions = entries('actions', 'MANIFEST_BAD_ACTION');
|
|
250
|
-
// A collection the actions or jobs read or write may gate an action too (extension
|
|
251
|
-
|
|
258
|
+
// A collection the actions or jobs read or write may gate an action too (extension
|
|
259
|
+
// model v3); `"*"` names none.
|
|
260
|
+
const collections = [...actions, ...jobs]
|
|
261
|
+
.flatMap((e) => ['reads', 'writes'].flatMap((k) => (Array.isArray(e[k]) ? e[k] : [])))
|
|
262
|
+
.filter((c) => c !== '*');
|
|
252
263
|
for (const a of actions) {
|
|
253
264
|
const p = a.permission;
|
|
254
265
|
if (!isObject(p) ||
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* host whose core catalogue happens to know about it, which is not a property
|
|
11
11
|
* an installable extension should depend on.
|
|
12
12
|
*
|
|
13
|
-
* Source: packages/studio/messages/core/en.json (
|
|
13
|
+
* Source: packages/studio/messages/core/en.json (212 keys)
|
|
14
14
|
*/
|
|
15
15
|
export declare const SHARED_MESSAGE_KEYS: ReadonlySet<string>;
|
|
16
16
|
//# sourceMappingURL=shared-message-keys.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared-message-keys.d.ts","sourceRoot":"","sources":["../../src/validate/shared-message-keys.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,mBAAmB,EAAE,WAAW,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"shared-message-keys.d.ts","sourceRoot":"","sources":["../../src/validate/shared-message-keys.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,mBAAmB,EAAE,WAAW,CAAC,MAAM,CAqNlD,CAAC"}
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* host whose core catalogue happens to know about it, which is not a property
|
|
11
11
|
* an installable extension should depend on.
|
|
12
12
|
*
|
|
13
|
-
* Source: packages/studio/messages/core/en.json (
|
|
13
|
+
* Source: packages/studio/messages/core/en.json (212 keys)
|
|
14
14
|
*/
|
|
15
15
|
export const SHARED_MESSAGE_KEYS = new Set([
|
|
16
16
|
'common.accessRestricted',
|
|
@@ -216,6 +216,7 @@ export const SHARED_MESSAGE_KEYS = new Set([
|
|
|
216
216
|
'ext.errorPrefix',
|
|
217
217
|
'ext.linkCopied',
|
|
218
218
|
'ext.loadFailed',
|
|
219
|
+
'ext.recordGone',
|
|
219
220
|
'ext.rejected',
|
|
220
221
|
'ext.reveal.copy',
|
|
221
222
|
'ext.reveal.note',
|
package/dist/view/index.d.ts.map
CHANGED
|
@@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(input, '', issues);
|
|
33
33
|
return issues.length === 0 ? { ok: true, view: input } : { ok: false, issues };
|
|
34
34
|
}
|
|
35
|
-
const CONDITION_LISTS = new Set(['filter', 'when', 'emphasisWhen']);
|
|
35
|
+
const CONDITION_LISTS = new Set(['filter', 'when', 'emphasisWhen', 'busyWhen']);
|
|
36
36
|
/**
|
|
37
37
|
* What the schema cannot say, checked across keys:
|
|
38
38
|
* - the data API takes one value per field and operator (`{"f":{"gt":1,"lt":9}}`),
|
|
@@ -109,7 +109,12 @@ function fieldRefs(v) {
|
|
|
109
109
|
const out = [];
|
|
110
110
|
const add = (at, x) => typeof x === 'string' && out.push([at, x]);
|
|
111
111
|
const fieldList = (x, at) => Array.isArray(x) &&
|
|
112
|
-
x.forEach((f, i) =>
|
|
112
|
+
x.forEach((f, i) => {
|
|
113
|
+
if (!isObj(f))
|
|
114
|
+
return add(`${at}/${i}`, f);
|
|
115
|
+
add(`${at}/${i}/field`, f.field);
|
|
116
|
+
add(`${at}/${i}/fallback`, f.fallback);
|
|
117
|
+
});
|
|
113
118
|
const conditions = (x, at) => Array.isArray(x) && x.forEach((c, i) => isObj(c) && add(`${at}/${i}/field`, c.field));
|
|
114
119
|
for (const k of ONE_FIELD[typeof v.type === 'string' ? v.type : ''] ?? [])
|
|
115
120
|
add(`/${k}`, v[k]);
|
|
@@ -120,6 +125,8 @@ function fieldRefs(v) {
|
|
|
120
125
|
}
|
|
121
126
|
conditions(v.filter, '/filter');
|
|
122
127
|
conditions(v.emphasisWhen, '/emphasisWhen');
|
|
128
|
+
if (isObj(v.onOpen))
|
|
129
|
+
conditions(v.onOpen.when, '/onOpen/when');
|
|
123
130
|
const sort = typeof v.sort === 'string' ? [v.sort] : v.sort;
|
|
124
131
|
if (Array.isArray(sort)) {
|
|
125
132
|
sort.forEach((x, i) => add(typeof v.sort === 'string' ? '/sort' : `/sort/${i}`, typeof x === 'string' ? x.replace(/^-/, '') : x));
|
package/dist/view/runtime.d.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* carries none. The data API and action paths below are the engine's, named by
|
|
10
10
|
* the front end; the engine's rules decide every call.
|
|
11
11
|
*/
|
|
12
|
-
import type { Conditions, Field, Fields, Input, Sort, Value, View } from './types.generated.js';
|
|
12
|
+
import type { Button, Conditions, Field, Fields, FileHandoff, Input, Sort, Value, View } from './types.generated.js';
|
|
13
13
|
/** What references read. Anything missing leaves the reference unresolved. */
|
|
14
14
|
export interface ViewScope {
|
|
15
15
|
/** The current record (`$record`). */
|
|
@@ -29,6 +29,29 @@ export interface ViewScope {
|
|
|
29
29
|
export declare function resolveValue(v: Value, s: ViewScope): unknown;
|
|
30
30
|
/** An action's input or a view's parameters, resolved; `null` when a reference is not. */
|
|
31
31
|
export declare function resolveInput(input: Input | undefined, s: ViewScope): Record<string, unknown> | null;
|
|
32
|
+
/**
|
|
33
|
+
* The ids of stored files in a value: an id, a `file` field's value
|
|
34
|
+
* (`{ id, name, size, type }`), or a list of either.
|
|
35
|
+
*/
|
|
36
|
+
export declare function fileIds(v: unknown): string[];
|
|
37
|
+
/**
|
|
38
|
+
* A button's `files` as the action request's `$files` (ADR 0032): `undefined`
|
|
39
|
+
* when it hands nothing (no button `files`, or a `read` with no file),
|
|
40
|
+
* `null` while a reference has no value yet.
|
|
41
|
+
*/
|
|
42
|
+
export declare function resolveFiles(files: FileHandoff | undefined, s: ViewScope): {
|
|
43
|
+
read?: string[];
|
|
44
|
+
write?: {
|
|
45
|
+
name: string;
|
|
46
|
+
maxBytes?: number;
|
|
47
|
+
};
|
|
48
|
+
} | null | undefined;
|
|
49
|
+
/**
|
|
50
|
+
* Every reference a button carries (`input`, `params`, `files`) has a value in
|
|
51
|
+
* `s`. A button that is not bound is drawn disabled and never sent (no row
|
|
52
|
+
* selected in the pane it names). What it `prompt`s for is no reference.
|
|
53
|
+
*/
|
|
54
|
+
export declare function isBound(b: Button, s: ViewScope): boolean;
|
|
32
55
|
/**
|
|
33
56
|
* Conditions as the data API's JSON `filter` (`{"field":{"op":value}}`); `null`
|
|
34
57
|
* while a reference has no value yet (no row selected in the pane it names).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/view/runtime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/view/runtime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EACV,MAAM,EAEN,UAAU,EACV,KAAK,EACL,MAAM,EACN,WAAW,EACX,KAAK,EAGL,IAAI,EACJ,KAAK,EACL,IAAI,EACL,MAAM,sBAAsB,CAAC;AAE9B,8EAA8E;AAC9E,MAAM,WAAW,SAAS;IACxB,sCAAsC;IACtC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,mEAAmE;IACnE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,kDAAkD;IAClD,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;IACtC,0DAA0D;IAC1D,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,yCAAyC;IACzC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,2DAA2D;IAC3D,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAWD,6EAA6E;AAC7E,wBAAgB,YAAY,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,SAAS,GAAG,OAAO,CAY5D;AAED,0FAA0F;AAC1F,wBAAgB,YAAY,CAC1B,KAAK,EAAE,KAAK,GAAG,SAAS,EACxB,CAAC,EAAE,SAAS,GACX,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAQhC;AAED;;;GAGG;AACH,wBAAgB,OAAO,CAAC,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gB,UAAU,CAAC,CAAC,EAAE,WAAW,GAAG,OAAO,CAElD;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,WAAW,EACjD,MAAM,EAAE,SAAS,CAAC,EAAE,EACpB,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,QAAQ,GAC/B,CAAC,EAAE,CAKL;AAED,sFAAsF;AACtF,wBAAgB,WAAW,CACzB,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,QAAQ,EAChC,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,SAAS,WAAW,EAAE,GAC7B,IAAI,CAKN;AAED,4EAA4E;AAC5E,wBAAgB,UAAU,CACxB,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,MAAM,EAAE,SAAS,WAAW,EAAE,EAC9B,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,QAAQ,GAC/B,MAAM,CAER;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,IAAI,GAAG,IAAI,CAK/E;AAED,4FAA4F;AAC5F,wBAAgB,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAQpE"}
|
package/dist/view/runtime.js
CHANGED
|
@@ -46,6 +46,61 @@ export function resolveInput(input, s) {
|
|
|
46
46
|
}
|
|
47
47
|
return out;
|
|
48
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* The ids of stored files in a value: an id, a `file` field's value
|
|
51
|
+
* (`{ id, name, size, type }`), or a list of either.
|
|
52
|
+
*/
|
|
53
|
+
export function fileIds(v) {
|
|
54
|
+
const one = (x) => typeof x === 'string' && x
|
|
55
|
+
? [x]
|
|
56
|
+
: typeof x === 'object' && x !== null && typeof x.id === 'string'
|
|
57
|
+
? [x.id]
|
|
58
|
+
: [];
|
|
59
|
+
return [...new Set(Array.isArray(v) ? v.flatMap(one) : one(v))];
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* A button's `files` as the action request's `$files` (ADR 0032): `undefined`
|
|
63
|
+
* when it hands nothing (no button `files`, or a `read` with no file),
|
|
64
|
+
* `null` while a reference has no value yet.
|
|
65
|
+
*/
|
|
66
|
+
export function resolveFiles(files, s) {
|
|
67
|
+
if (!files)
|
|
68
|
+
return undefined;
|
|
69
|
+
const out = {};
|
|
70
|
+
if (files.read !== undefined) {
|
|
71
|
+
const v = resolveValue(files.read, s);
|
|
72
|
+
if (v === undefined)
|
|
73
|
+
return null;
|
|
74
|
+
const ids = fileIds(v);
|
|
75
|
+
if (ids.length)
|
|
76
|
+
out.read = ids;
|
|
77
|
+
}
|
|
78
|
+
if (files.write) {
|
|
79
|
+
const name = resolveValue(files.write.name, s);
|
|
80
|
+
const max = files.write.maxBytes === undefined ? undefined : resolveValue(files.write.maxBytes, s);
|
|
81
|
+
if (name === undefined || (files.write.maxBytes !== undefined && max === undefined))
|
|
82
|
+
return null;
|
|
83
|
+
// A bigint column reads as a string through the data API.
|
|
84
|
+
const bytes = typeof max === 'string' && max.trim() !== '' ? Number(max) : max;
|
|
85
|
+
out.write = {
|
|
86
|
+
name: String(name),
|
|
87
|
+
...(typeof bytes === 'number' && Number.isFinite(bytes) ? { maxBytes: bytes } : {}),
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
return out.read || out.write ? out : undefined;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Every reference a button carries (`input`, `params`, `files`) has a value in
|
|
94
|
+
* `s`. A button that is not bound is drawn disabled and never sent (no row
|
|
95
|
+
* selected in the pane it names). What it `prompt`s for is no reference.
|
|
96
|
+
*/
|
|
97
|
+
export function isBound(b, s) {
|
|
98
|
+
if ('navigate' in b)
|
|
99
|
+
return resolveInput(b.params, s) !== null;
|
|
100
|
+
if ('action' in b)
|
|
101
|
+
return resolveInput(b.input, s) !== null && resolveFiles(b.files, s) !== null;
|
|
102
|
+
return true;
|
|
103
|
+
}
|
|
49
104
|
/**
|
|
50
105
|
* Conditions as the data API's JSON `filter` (`{"field":{"op":value}}`); `null`
|
|
51
106
|
* while a reference has no value yet (no row selected in the pane it names).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/view/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,eAAO,MAAM,SAAS,mBAAmB,CAAC;AA8B1C,KAAK,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/view/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,eAAO,MAAM,SAAS,mBAAmB,CAAC;AA8B1C,KAAK,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AA+btC,eAAO,MAAM,WAAW,EAAE,MAQzB,CAAC"}
|
package/dist/view/schema.js
CHANGED
|
@@ -51,7 +51,10 @@ const closed = (description, properties, required = []) => ({
|
|
|
51
51
|
const common = {
|
|
52
52
|
id: ref('PaneId'),
|
|
53
53
|
title: ref('Text'),
|
|
54
|
-
actions: {
|
|
54
|
+
actions: {
|
|
55
|
+
...ref('Buttons'),
|
|
56
|
+
description: "Toolbar actions of this view; a detail's act on the record it shows (`$record`).",
|
|
57
|
+
},
|
|
55
58
|
fallback: {
|
|
56
59
|
...ref('View'),
|
|
57
60
|
description: 'What a front end that does not know this view kind draws instead.',
|
|
@@ -177,6 +180,10 @@ const defs = {
|
|
|
177
180
|
additionalProperties: ref('Tone'),
|
|
178
181
|
},
|
|
179
182
|
readOnly: { type: 'boolean' },
|
|
183
|
+
fallback: {
|
|
184
|
+
...ref('Name'),
|
|
185
|
+
description: 'The field shown instead while this one is empty.',
|
|
186
|
+
},
|
|
180
187
|
}, ['field']),
|
|
181
188
|
],
|
|
182
189
|
},
|
|
@@ -198,6 +205,11 @@ const defs = {
|
|
|
198
205
|
prompt: { ...arrayOf(ref('Name'), 1), description: 'Input fields to ask for.' },
|
|
199
206
|
confirm: ref('Text'),
|
|
200
207
|
when: ref('Conditions'),
|
|
208
|
+
busyWhen: {
|
|
209
|
+
...ref('Conditions'),
|
|
210
|
+
description: 'While the record meets these, the work the action started is under way: the button is busy, and the front end reads the record again until it no longer does.',
|
|
211
|
+
},
|
|
212
|
+
files: ref('FileHandoff'),
|
|
201
213
|
}, ['action']),
|
|
202
214
|
closed('Opens another view.', {
|
|
203
215
|
navigate: ref('ViewId'),
|
|
@@ -209,6 +221,13 @@ const defs = {
|
|
|
209
221
|
],
|
|
210
222
|
},
|
|
211
223
|
Buttons: arrayOf(ref('Button'), 1),
|
|
224
|
+
FileHandoff: closed("Stored files the caller hands the action's job (`$files`, ADR 0032).", {
|
|
225
|
+
read: {
|
|
226
|
+
...ref('Value'),
|
|
227
|
+
description: "File ids the job may read, or a `file` field's value (its files' ids).",
|
|
228
|
+
},
|
|
229
|
+
write: closed('The one file the job may store.', { name: ref('Value'), maxBytes: ref('Value') }, ['name']),
|
|
230
|
+
}),
|
|
212
231
|
ListView: kind('list', 'Rows of a collection.', {
|
|
213
232
|
collection: ref('Name'),
|
|
214
233
|
fields: ref('Fields'),
|
|
@@ -246,6 +265,7 @@ const defs = {
|
|
|
246
265
|
record: ref('Ref'),
|
|
247
266
|
fields: ref('Fields'),
|
|
248
267
|
panels: arrayOf(ref('View'), 1),
|
|
268
|
+
onOpen: closed('Runs the action when a record is shown and meets `when`, once per record; its result is not shown.', { action: ref('ActionName'), input: ref('Input'), when: ref('Conditions') }, ['action']),
|
|
249
269
|
}, ['collection', 'record']),
|
|
250
270
|
BoardView: kind('board', 'Records grouped by a field (kanban).', {
|
|
251
271
|
collection: ref('Name'),
|
|
@@ -53,6 +53,8 @@ export type Field = Name | {
|
|
|
53
53
|
/** A tone per value (enum fields). */
|
|
54
54
|
tones?: Record<string, Tone>;
|
|
55
55
|
readOnly?: boolean;
|
|
56
|
+
/** The field shown instead while this one is empty. */
|
|
57
|
+
fallback?: Name;
|
|
56
58
|
};
|
|
57
59
|
export type Fields = Field[];
|
|
58
60
|
/** Runs an action. */
|
|
@@ -71,6 +73,9 @@ export type Button = {
|
|
|
71
73
|
prompt?: Name[];
|
|
72
74
|
confirm?: Text;
|
|
73
75
|
when?: Conditions;
|
|
76
|
+
/** While the record meets these, the work the action started is under way: the button is busy, and the front end reads the record again until it no longer does. */
|
|
77
|
+
busyWhen?: Conditions;
|
|
78
|
+
files?: FileHandoff;
|
|
74
79
|
} | {
|
|
75
80
|
navigate: ViewId;
|
|
76
81
|
params?: Input;
|
|
@@ -81,12 +86,22 @@ export type Button = {
|
|
|
81
86
|
label?: Text;
|
|
82
87
|
};
|
|
83
88
|
export type Buttons = Button[];
|
|
89
|
+
/** Stored files the caller hands the action's job (`$files`, ADR 0032). */
|
|
90
|
+
export type FileHandoff = {
|
|
91
|
+
/** File ids the job may read, or a `file` field's value (its files' ids). */
|
|
92
|
+
read?: Value;
|
|
93
|
+
/** The one file the job may store. */
|
|
94
|
+
write?: {
|
|
95
|
+
name: Value;
|
|
96
|
+
maxBytes?: Value;
|
|
97
|
+
};
|
|
98
|
+
};
|
|
84
99
|
/** Rows of a collection. */
|
|
85
100
|
export type ListView = {
|
|
86
101
|
type: 'list';
|
|
87
102
|
id?: PaneId;
|
|
88
103
|
title?: Text;
|
|
89
|
-
/** Toolbar actions of this view. */
|
|
104
|
+
/** Toolbar actions of this view; a detail's act on the record it shows (`$record`). */
|
|
90
105
|
actions?: Buttons;
|
|
91
106
|
/** What a front end that does not know this view kind draws instead. */
|
|
92
107
|
fallback?: View;
|
|
@@ -116,7 +131,7 @@ export type FormView = {
|
|
|
116
131
|
type: 'form';
|
|
117
132
|
id?: PaneId;
|
|
118
133
|
title?: Text;
|
|
119
|
-
/** Toolbar actions of this view. */
|
|
134
|
+
/** Toolbar actions of this view; a detail's act on the record it shows (`$record`). */
|
|
120
135
|
actions?: Buttons;
|
|
121
136
|
/** What a front end that does not know this view kind draws instead. */
|
|
122
137
|
fallback?: View;
|
|
@@ -143,7 +158,7 @@ export type FormView = {
|
|
|
143
158
|
type: 'form';
|
|
144
159
|
id?: PaneId;
|
|
145
160
|
title?: Text;
|
|
146
|
-
/** Toolbar actions of this view. */
|
|
161
|
+
/** Toolbar actions of this view; a detail's act on the record it shows (`$record`). */
|
|
147
162
|
actions?: Buttons;
|
|
148
163
|
/** What a front end that does not know this view kind draws instead. */
|
|
149
164
|
fallback?: View;
|
|
@@ -170,7 +185,7 @@ export type DetailView = {
|
|
|
170
185
|
type: 'detail';
|
|
171
186
|
id?: PaneId;
|
|
172
187
|
title?: Text;
|
|
173
|
-
/** Toolbar actions of this view. */
|
|
188
|
+
/** Toolbar actions of this view; a detail's act on the record it shows (`$record`). */
|
|
174
189
|
actions?: Buttons;
|
|
175
190
|
/** What a front end that does not know this view kind draws instead. */
|
|
176
191
|
fallback?: View;
|
|
@@ -178,13 +193,19 @@ export type DetailView = {
|
|
|
178
193
|
record: Ref;
|
|
179
194
|
fields?: Fields;
|
|
180
195
|
panels?: View[];
|
|
196
|
+
/** Runs the action when a record is shown and meets `when`, once per record; its result is not shown. */
|
|
197
|
+
onOpen?: {
|
|
198
|
+
action: ActionName;
|
|
199
|
+
input?: Input;
|
|
200
|
+
when?: Conditions;
|
|
201
|
+
};
|
|
181
202
|
};
|
|
182
203
|
/** Records grouped by a field (kanban). */
|
|
183
204
|
export type BoardView = {
|
|
184
205
|
type: 'board';
|
|
185
206
|
id?: PaneId;
|
|
186
207
|
title?: Text;
|
|
187
|
-
/** Toolbar actions of this view. */
|
|
208
|
+
/** Toolbar actions of this view; a detail's act on the record it shows (`$record`). */
|
|
188
209
|
actions?: Buttons;
|
|
189
210
|
/** What a front end that does not know this view kind draws instead. */
|
|
190
211
|
fallback?: View;
|
|
@@ -199,7 +220,7 @@ export type TimelineView = {
|
|
|
199
220
|
type: 'timeline';
|
|
200
221
|
id?: PaneId;
|
|
201
222
|
title?: Text;
|
|
202
|
-
/** Toolbar actions of this view. */
|
|
223
|
+
/** Toolbar actions of this view; a detail's act on the record it shows (`$record`). */
|
|
203
224
|
actions?: Buttons;
|
|
204
225
|
/** What a front end that does not know this view kind draws instead. */
|
|
205
226
|
fallback?: View;
|
|
@@ -216,7 +237,7 @@ export type TreeView = {
|
|
|
216
237
|
type: 'tree';
|
|
217
238
|
id?: PaneId;
|
|
218
239
|
title?: Text;
|
|
219
|
-
/** Toolbar actions of this view. */
|
|
240
|
+
/** Toolbar actions of this view; a detail's act on the record it shows (`$record`). */
|
|
220
241
|
actions?: Buttons;
|
|
221
242
|
/** What a front end that does not know this view kind draws instead. */
|
|
222
243
|
fallback?: View;
|
|
@@ -231,7 +252,7 @@ export type MatrixView = {
|
|
|
231
252
|
type: 'matrix';
|
|
232
253
|
id?: PaneId;
|
|
233
254
|
title?: Text;
|
|
234
|
-
/** Toolbar actions of this view. */
|
|
255
|
+
/** Toolbar actions of this view; a detail's act on the record it shows (`$record`). */
|
|
235
256
|
actions?: Buttons;
|
|
236
257
|
/** What a front end that does not know this view kind draws instead. */
|
|
237
258
|
fallback?: View;
|
|
@@ -246,7 +267,7 @@ export type MapView = {
|
|
|
246
267
|
type: 'map';
|
|
247
268
|
id?: PaneId;
|
|
248
269
|
title?: Text;
|
|
249
|
-
/** Toolbar actions of this view. */
|
|
270
|
+
/** Toolbar actions of this view; a detail's act on the record it shows (`$record`). */
|
|
250
271
|
actions?: Buttons;
|
|
251
272
|
/** What a front end that does not know this view kind draws instead. */
|
|
252
273
|
fallback?: View;
|
|
@@ -260,7 +281,7 @@ export type StatView = {
|
|
|
260
281
|
type: 'stat';
|
|
261
282
|
id?: PaneId;
|
|
262
283
|
title?: Text;
|
|
263
|
-
/** Toolbar actions of this view. */
|
|
284
|
+
/** Toolbar actions of this view; a detail's act on the record it shows (`$record`). */
|
|
264
285
|
actions?: Buttons;
|
|
265
286
|
/** What a front end that does not know this view kind draws instead. */
|
|
266
287
|
fallback?: View;
|
|
@@ -278,7 +299,7 @@ export type SplitView = {
|
|
|
278
299
|
type: 'split';
|
|
279
300
|
id?: PaneId;
|
|
280
301
|
title?: Text;
|
|
281
|
-
/** Toolbar actions of this view. */
|
|
302
|
+
/** Toolbar actions of this view; a detail's act on the record it shows (`$record`). */
|
|
282
303
|
actions?: Buttons;
|
|
283
304
|
/** What a front end that does not know this view kind draws instead. */
|
|
284
305
|
fallback?: View;
|
|
@@ -289,7 +310,7 @@ export type TabsView = {
|
|
|
289
310
|
type: 'tabs';
|
|
290
311
|
id?: PaneId;
|
|
291
312
|
title?: Text;
|
|
292
|
-
/** Toolbar actions of this view. */
|
|
313
|
+
/** Toolbar actions of this view; a detail's act on the record it shows (`$record`). */
|
|
293
314
|
actions?: Buttons;
|
|
294
315
|
/** What a front end that does not know this view kind draws instead. */
|
|
295
316
|
fallback?: View;
|