@mosetta/build 0.0.33 → 0.0.35
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/CHANGELOG.md +17 -0
- package/package.json +6 -6
- package/src/build.mjs +59 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @mosetta/build
|
|
2
2
|
|
|
3
|
+
## 0.0.35
|
|
4
|
+
|
|
5
|
+
- Compile the identity, scoped content and private service contracts into distribution metadata.
|
|
6
|
+
- Keep icon and workbench capability declarations with the published palette.
|
|
7
|
+
|
|
8
|
+
## 0.0.34
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- The parts a palette plays in a workbench — its assistant, dictation — are the palette's own: `workbench` in `mosetta.json` (`{ "assistant": "<tile>.<action>", "transcribe": "<tile>.<action>" }`), carried by the palette's catalog entry, whichever way a site connects the palette. `service` is the grant alone; any other key in it is refused.
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
- @mosetta/server@0.0.34
|
|
15
|
+
- @mosetta/router@0.0.34
|
|
16
|
+
- @mosetta/runtime@0.0.34
|
|
17
|
+
- @mosetta/server-action@0.0.34
|
|
18
|
+
- @mosetta/tar@0.0.34
|
|
19
|
+
|
|
3
20
|
## 0.0.33
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mosetta/build",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.35",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "The core of the tile forge: builds a tile palette — its tile side artifacts, their dependency closure, the tile host descriptor. Environment-agnostic — the file system and the bundling engine are supplied from outside.",
|
|
6
6
|
"type": "module",
|
|
@@ -28,11 +28,11 @@
|
|
|
28
28
|
"scheduler": "*",
|
|
29
29
|
"systemjs": "^6.15.1",
|
|
30
30
|
"yaml": "^2.9.0",
|
|
31
|
-
"@mosetta/router": "0.0.
|
|
32
|
-
"@mosetta/
|
|
33
|
-
"@mosetta/server": "0.0.
|
|
34
|
-
"@mosetta/
|
|
35
|
-
"@mosetta/tar": "0.0.
|
|
31
|
+
"@mosetta/router": "0.0.35",
|
|
32
|
+
"@mosetta/server": "0.0.35",
|
|
33
|
+
"@mosetta/server-action": "0.0.35",
|
|
34
|
+
"@mosetta/runtime": "0.0.35",
|
|
35
|
+
"@mosetta/tar": "0.0.35"
|
|
36
36
|
},
|
|
37
37
|
"publishConfig": {
|
|
38
38
|
"access": "public"
|
package/src/build.mjs
CHANGED
|
@@ -375,10 +375,14 @@ export async function build(root, { mode = 'development', log, fileSystem, resol
|
|
|
375
375
|
for (const r of builtRoots) {
|
|
376
376
|
// the APP's own prefabs are its site's content (the picker's "prefabs of this site"), not a
|
|
377
377
|
// distribution: the app counts only for blocks of its own
|
|
378
|
-
// (a palette offering itself as a service
|
|
378
|
+
// (a palette offering itself as a service, or playing a part in a workbench, is named too: its
|
|
379
|
+
// offer and its parts are read here)
|
|
380
|
+
const cfg = readConfig(fileSystem, r.dir);
|
|
379
381
|
const brings = mods.some((m) => m.namespace === r.namespace)
|
|
380
382
|
|| (r.dir !== root && discoverPrefabsIn(fileSystem, r.dir, () => {}).length > 0)
|
|
381
|
-
||
|
|
383
|
+
|| cfg?.service !== undefined
|
|
384
|
+
|| cfg?.workbench !== undefined
|
|
385
|
+
|| cfg?.permissions !== undefined;
|
|
382
386
|
if (!brings) continue;
|
|
383
387
|
const descriptor = distributionDescriptor(fileSystem, r, (key, file) => {
|
|
384
388
|
watchFiles.add(file);
|
|
@@ -557,9 +561,11 @@ export function sourceLinkOf(repository) {
|
|
|
557
561
|
}
|
|
558
562
|
|
|
559
563
|
/** what a service may be granted on a site that takes it: palettes, a palette's tile, or the host's doors */
|
|
560
|
-
const SERVICE_GRANT_RE = /^(?:@(?:previews|media|code|
|
|
561
|
-
/**
|
|
562
|
-
const
|
|
564
|
+
const SERVICE_GRANT_RE = /^(?:@(?:previews|media|code|repositories)|[a-z][a-z0-9-]{0,62}(?:\/[a-z][A-Za-z0-9]{0,63})?)$/;
|
|
565
|
+
/** an action of the palette named for a workbench: `<tile>.<action>` */
|
|
566
|
+
const WORKBENCH_ACTION_RE = /^[a-z][A-Za-z0-9]{0,63}\.[A-Za-z][A-Za-z0-9_]{0,63}$/;
|
|
567
|
+
/** the parts a palette may play in a workbench (@mosetta/content/workbench) */
|
|
568
|
+
const WORKBENCH_ROLES = ['assistant', 'transcribe', 'tools', 'icon'];
|
|
563
569
|
|
|
564
570
|
/**
|
|
565
571
|
* A distribution's offer of itself as a service (mosetta.json `service: { grant: [...] }`): what it
|
|
@@ -568,19 +574,57 @@ const SERVICE_ACTION_RE = /^[a-z][A-Za-z0-9]{0,63}\.[A-Za-z][A-Za-z0-9_]{0,63}$/
|
|
|
568
574
|
*/
|
|
569
575
|
export function serviceOf(raw) {
|
|
570
576
|
if (raw === undefined) return null;
|
|
577
|
+
const unknown = raw !== null && typeof raw === 'object' ? Object.keys(raw).find((key) => key !== 'grant') : undefined;
|
|
578
|
+
if (unknown !== undefined) throw new Error(`mosetta.json: service.${unknown} is no part of a service's offer — it is { "grant": [...] }`);
|
|
571
579
|
const grant = raw?.grant ?? [];
|
|
572
580
|
if (!Array.isArray(grant) || grant.length > 32 || !grant.every((g) => typeof g === 'string' && SERVICE_GRANT_RE.test(g))) {
|
|
573
|
-
throw new Error('mosetta.json: service.grant is up to 32 palettes (`brand`), tiles (`brand/tile`) or host doors (`@previews`, `@media`, `@code`, `@
|
|
581
|
+
throw new Error('mosetta.json: service.grant is up to 32 palettes (`brand`), tiles (`brand/tile`) or host doors (`@previews`, `@media`, `@code`, `@repositories`) the service asks to call');
|
|
574
582
|
}
|
|
575
|
-
|
|
583
|
+
return { grant: [...new Set(grant)] };
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
/**
|
|
587
|
+
* The parts a palette plays in the workbench of a site it is connected to (mosetta.json
|
|
588
|
+
* `workbench: { assistant, transcribe, tools, icon }`): the assistant's turn, dictation, its own tools
|
|
589
|
+
* for the site's connector, the site's icon drawn — each an action of its own, `<tile>.<action>`. The palette's own, whichever way a site connects it — as code or as a
|
|
590
|
+
* service. A part named wrong stops the build: a palette that meant one must not ship without it.
|
|
591
|
+
*/
|
|
592
|
+
export function workbenchOf(raw) {
|
|
593
|
+
if (raw === undefined) return null;
|
|
594
|
+
if (raw === null || typeof raw !== 'object' || Array.isArray(raw)) throw new Error(`mosetta.json: workbench names the parts the palette plays in a workbench, each \`<tile>.<action>\`: ${WORKBENCH_ROLES.join(', ')}`);
|
|
595
|
+
const unknown = Object.keys(raw).find((role) => !WORKBENCH_ROLES.includes(role));
|
|
596
|
+
if (unknown !== undefined) throw new Error(`mosetta.json: workbench.${unknown} is no part of a workbench — the parts are ${WORKBENCH_ROLES.join(', ')}`);
|
|
576
597
|
const workbench = {};
|
|
577
|
-
for (const role of
|
|
578
|
-
const named = raw
|
|
598
|
+
for (const role of WORKBENCH_ROLES) {
|
|
599
|
+
const named = raw[role];
|
|
579
600
|
if (named === undefined) continue;
|
|
580
|
-
if (typeof named !== 'string' || !
|
|
601
|
+
if (typeof named !== 'string' || !WORKBENCH_ACTION_RE.test(named)) throw new Error(`mosetta.json: workbench.${role} names an action of the palette, \`<tile>.<action>\``);
|
|
581
602
|
workbench[role] = named;
|
|
582
603
|
}
|
|
583
|
-
return
|
|
604
|
+
return Object.keys(workbench).length ? workbench : null;
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
/** Operations a palette declares under its own brand for a project's role catalogue. */
|
|
608
|
+
export function permissionDefinitionsOf(brand, raw) {
|
|
609
|
+
if (raw === undefined) return [];
|
|
610
|
+
if (!Array.isArray(raw) || raw.length > 200) throw new Error(`mosetta.json: ${brand} permissions must be an array of at most 200 operations`);
|
|
611
|
+
const seen = new Set();
|
|
612
|
+
return raw.map((permission, index) => {
|
|
613
|
+
const at = `mosetta.json: ${brand} permissions[${index}]`;
|
|
614
|
+
if (!permission || typeof permission !== 'object' || Array.isArray(permission)
|
|
615
|
+
|| Object.keys(permission).some((key) => !['name', 'title', 'about', 'target'].includes(key))) {
|
|
616
|
+
throw new Error(`${at} requires name, title, about and target`);
|
|
617
|
+
}
|
|
618
|
+
const { name, title, about, target } = permission;
|
|
619
|
+
if (typeof name !== 'string' || name.length > 200 || !/^[a-z][a-z0-9-]*(?:\.[a-z][a-z0-9-]*)*$/.test(name)
|
|
620
|
+
|| !name.startsWith(`${brand}.`)) throw new Error(`${at} name must be an explicit operation under ${brand}.`);
|
|
621
|
+
if (typeof title !== 'string' || !title.trim() || title.length > 160
|
|
622
|
+
|| typeof about !== 'string' || !about.trim() || about.length > 2000) throw new Error(`${at} requires a title and description`);
|
|
623
|
+
if (target !== 'resource' && target !== 'project') throw new Error(`${at} target must be resource or project`);
|
|
624
|
+
if (seen.has(name)) throw new Error(`${at} duplicates operation ${name}`);
|
|
625
|
+
seen.add(name);
|
|
626
|
+
return { name, title: title.trim(), about: about.trim(), target };
|
|
627
|
+
});
|
|
584
628
|
}
|
|
585
629
|
|
|
586
630
|
/**
|
|
@@ -590,6 +634,7 @@ export function serviceOf(raw) {
|
|
|
590
634
|
*/
|
|
591
635
|
export function distributionDescriptor(fileSystem, root, ship) {
|
|
592
636
|
const cfg = readConfig(fileSystem, root.dir);
|
|
637
|
+
const permissions = permissionDefinitionsOf(root.namespace, cfg.permissions);
|
|
593
638
|
let pkg = {};
|
|
594
639
|
try {
|
|
595
640
|
pkg = fileSystem.readJson(path.join(root.dir, 'package.json'));
|
|
@@ -613,6 +658,9 @@ export function distributionDescriptor(fileSystem, root, ship) {
|
|
|
613
658
|
...(cfg.base === true ? { base: true } : {}),
|
|
614
659
|
// offered to other sites as a SERVICE: what it asks to call on a site that takes it
|
|
615
660
|
...(serviceOf(cfg.service) ? { service: serviceOf(cfg.service) } : {}),
|
|
661
|
+
// the parts it plays in a workbench (the assistant's turn, dictation)
|
|
662
|
+
...(workbenchOf(cfg.workbench) ? { workbench: workbenchOf(cfg.workbench) } : {}),
|
|
663
|
+
...(permissions.length ? { permissions } : {}),
|
|
616
664
|
...(text(cfg.description) ?? text(pkg.description) ? { description: text(cfg.description) ?? text(pkg.description) } : {}),
|
|
617
665
|
...(text(cfg.source) ?? sourceLinkOf(pkg.repository) ? { source: text(cfg.source) ?? sourceLinkOf(pkg.repository) } : {}),
|
|
618
666
|
...(changesOf(fileSystem, root) ? { changes: changesOf(fileSystem, root) } : {}),
|