@mostra/protocol 0.13.0 → 0.15.0
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/dist/artifact-path.d.ts +22 -0
- package/dist/artifact-path.d.ts.map +1 -0
- package/dist/artifact-path.js +39 -0
- package/dist/artifact-path.js.map +1 -0
- package/dist/diagnostics/codes/index.d.ts +5 -2
- package/dist/diagnostics/codes/index.d.ts.map +1 -1
- package/dist/diagnostics/codes/index.js +7 -1
- package/dist/diagnostics/codes/index.js.map +1 -1
- package/dist/diagnostics/codes/license.d.ts +8 -0
- package/dist/diagnostics/codes/license.d.ts.map +1 -0
- package/dist/diagnostics/codes/license.js +55 -0
- package/dist/diagnostics/codes/license.js.map +1 -0
- package/dist/diagnostics/codes/pack.d.ts +8 -0
- package/dist/diagnostics/codes/pack.d.ts.map +1 -0
- package/dist/diagnostics/codes/pack.js +110 -0
- package/dist/diagnostics/codes/pack.js.map +1 -0
- package/dist/diagnostics/codes/plugin.d.ts +8 -0
- package/dist/diagnostics/codes/plugin.d.ts.map +1 -0
- package/dist/diagnostics/codes/plugin.js +154 -0
- package/dist/diagnostics/codes/plugin.js.map +1 -0
- package/dist/diagnostics/diagnostic.d.ts +1 -1
- package/dist/diagnostics/diagnostic.d.ts.map +1 -1
- package/dist/diagnostics/diagnostic.js +4 -1
- package/dist/diagnostics/diagnostic.js.map +1 -1
- package/dist/index.d.ts +13 -1
- package/dist/index.js +13 -1
- package/dist/methods/deps/add.d.ts +6 -0
- package/dist/methods/deps/add.d.ts.map +1 -1
- package/dist/methods/deps/add.js +1 -0
- package/dist/methods/deps/add.js.map +1 -1
- package/dist/methods/index.d.ts.map +1 -1
- package/dist/methods/index.js +15 -1
- package/dist/methods/index.js.map +1 -1
- package/dist/methods/mostra/initialize.d.ts +7 -0
- package/dist/methods/mostra/initialize.d.ts.map +1 -1
- package/dist/methods/mostra/initialize.js +4 -2
- package/dist/methods/mostra/initialize.js.map +1 -1
- package/dist/methods/pack/add.d.ts +80 -0
- package/dist/methods/pack/add.d.ts.map +1 -0
- package/dist/methods/pack/add.js +59 -0
- package/dist/methods/pack/add.js.map +1 -0
- package/dist/methods/plugin/add.d.ts +43 -0
- package/dist/methods/plugin/add.d.ts.map +1 -0
- package/dist/methods/plugin/add.js +39 -0
- package/dist/methods/plugin/add.js.map +1 -0
- package/dist/methods/plugin/commands.d.ts +38 -0
- package/dist/methods/plugin/commands.d.ts.map +1 -0
- package/dist/methods/plugin/commands.js +33 -0
- package/dist/methods/plugin/commands.js.map +1 -0
- package/dist/methods/plugin/export.d.ts +58 -0
- package/dist/methods/plugin/export.d.ts.map +1 -0
- package/dist/methods/plugin/export.js +57 -0
- package/dist/methods/plugin/export.js.map +1 -0
- package/dist/methods/plugin/list.d.ts +26 -0
- package/dist/methods/plugin/list.d.ts.map +1 -0
- package/dist/methods/plugin/list.js +30 -0
- package/dist/methods/plugin/list.js.map +1 -0
- package/dist/methods/plugin/remove.d.ts +32 -0
- package/dist/methods/plugin/remove.d.ts.map +1 -0
- package/dist/methods/plugin/remove.js +33 -0
- package/dist/methods/plugin/remove.js.map +1 -0
- package/dist/methods/plugin/validate.d.ts +35 -0
- package/dist/methods/plugin/validate.d.ts.map +1 -0
- package/dist/methods/plugin/validate.js +33 -0
- package/dist/methods/plugin/validate.js.map +1 -0
- package/dist/plugin/contract-versions.generated.js +14 -0
- package/dist/plugin/contract-versions.generated.js.map +1 -0
- package/dist/plugin/contracts.d.ts +51 -0
- package/dist/plugin/contracts.d.ts.map +1 -0
- package/dist/plugin/contracts.js +129 -0
- package/dist/plugin/contracts.js.map +1 -0
- package/dist/plugin/license.d.ts +87 -0
- package/dist/plugin/license.d.ts.map +1 -0
- package/dist/plugin/license.js +243 -0
- package/dist/plugin/license.js.map +1 -0
- package/dist/plugin/manifest.d.ts +141 -0
- package/dist/plugin/manifest.d.ts.map +1 -0
- package/dist/plugin/manifest.js +281 -0
- package/dist/plugin/manifest.js.map +1 -0
- package/dist/plugin/registry-item.d.ts +171 -0
- package/dist/plugin/registry-item.d.ts.map +1 -0
- package/dist/plugin/registry-item.js +162 -0
- package/dist/plugin/registry-item.js.map +1 -0
- package/dist/plugin/spdx.generated.d.ts +9 -0
- package/dist/plugin/spdx.generated.d.ts.map +1 -0
- package/dist/plugin/spdx.generated.js +846 -0
- package/dist/plugin/spdx.generated.js.map +1 -0
- package/dist/plugin.d.ts +7 -0
- package/dist/plugin.js +6 -0
- package/dist/plugins.d.ts +118 -0
- package/dist/plugins.d.ts.map +1 -0
- package/dist/plugins.js +109 -0
- package/dist/plugins.js.map +1 -0
- package/package.json +19 -4
- package/schemas/plugin-manifest.draft-07.json +611 -0
- package/schemas/plugin-manifest.schema.json +607 -0
- package/schemas/protocol.draft-07.json +899 -1
- package/schemas/protocol.schema.json +875 -1
- package/src/artifact-path.ts +46 -0
- package/src/diagnostics/codes/index.ts +14 -2
- package/src/diagnostics/codes/license.ts +65 -0
- package/src/diagnostics/codes/pack.ts +125 -0
- package/src/diagnostics/codes/plugin.ts +173 -0
- package/src/diagnostics/diagnostic.ts +7 -1
- package/src/index.ts +57 -0
- package/src/methods/deps/add.ts +7 -0
- package/src/methods/index.ts +14 -0
- package/src/methods/mostra/initialize.ts +9 -1
- package/src/methods/pack/add.ts +133 -0
- package/src/methods/plugin/add.ts +70 -0
- package/src/methods/plugin/commands.ts +67 -0
- package/src/methods/plugin/export.ts +100 -0
- package/src/methods/plugin/list.ts +45 -0
- package/src/methods/plugin/remove.ts +58 -0
- package/src/methods/plugin/validate.ts +60 -0
- package/src/plugin/contract-versions.generated.ts +15 -0
- package/src/plugin/contracts.ts +171 -0
- package/src/plugin/license.ts +320 -0
- package/src/plugin/manifest.ts +546 -0
- package/src/plugin/registry-item.ts +330 -0
- package/src/plugin/spdx-tables.ts +74 -0
- package/src/plugin/spdx.generated.ts +844 -0
- package/src/plugin.ts +77 -0
- package/src/plugins.ts +239 -0
- package/LICENSE +0 -202
|
@@ -3,6 +3,7 @@ import { Diagnostic } from "../../diagnostics/diagnostic.ts";
|
|
|
3
3
|
import { SubmitChannel } from "../../interaction.ts";
|
|
4
4
|
import { SubmissionPolicy } from "../../manifest.ts";
|
|
5
5
|
import { defineMethod, type MethodDefinition } from "../../method.ts";
|
|
6
|
+
import { LicensePolicy } from "../../plugins.ts";
|
|
6
7
|
import { OwnerLinkInfo } from "../../remote.ts";
|
|
7
8
|
import { Revision } from "../../revision.ts";
|
|
8
9
|
import { wireRegistry } from "../../wire-registry.ts";
|
|
@@ -89,6 +90,12 @@ export interface HomeConfig {
|
|
|
89
90
|
* allowed. A host's `trustedControls` port answers per view instead, when it is connected.
|
|
90
91
|
*/
|
|
91
92
|
readonly submitChannels?: readonly SubmitChannel[];
|
|
93
|
+
/**
|
|
94
|
+
* The licenses the host accepts for every plugin and pack install (D31), kept in `config.json`:
|
|
95
|
+
* an install that brings one of them needs no `--accept-license`, and the lockfile records it as
|
|
96
|
+
* accepted by the host. `{ accept: ["*"] }` accepts any; `{ accept: [] }` clears the policy.
|
|
97
|
+
*/
|
|
98
|
+
readonly licenses?: LicensePolicy;
|
|
92
99
|
}
|
|
93
100
|
|
|
94
101
|
/** How packages enter an artifact's lockfile (D43). */
|
|
@@ -193,11 +200,12 @@ export const HomeConfig: z.ZodType<HomeConfig> = z
|
|
|
193
200
|
submission: SubmissionPolicy.exactOptional(),
|
|
194
201
|
ports: z.array(PortName).max(32).readonly().exactOptional(),
|
|
195
202
|
submitChannels: z.array(SubmitChannel).min(1).max(2).readonly().exactOptional(),
|
|
203
|
+
licenses: LicensePolicy.exactOptional(),
|
|
196
204
|
})
|
|
197
205
|
.register(wireRegistry, {
|
|
198
206
|
id: "HomeConfig",
|
|
199
207
|
description:
|
|
200
|
-
"Home settings from a spawning host; path is a check against the instance's home (D84), dependencies the dependency policy (D43), submission the home's policy (D102), ports those the host always provides (D105).",
|
|
208
|
+
"Home settings from a spawning host; path is a check against the instance's home (D84), dependencies the dependency policy (D43), submission the home's policy (D102), ports those the host always provides (D105), licenses those it accepts for every install (D31).",
|
|
201
209
|
});
|
|
202
210
|
|
|
203
211
|
/** The Zod schema of the `InstanceInfo` type. */
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
import { SourceRef } from "../../artifact.ts";
|
|
3
|
+
import { Diagnostic } from "../../diagnostics/diagnostic.ts";
|
|
4
|
+
import { defineMethod, type MethodDefinition } from "../../method.ts";
|
|
5
|
+
import { LicenseDisclosure } from "../../plugins.ts";
|
|
6
|
+
import { wireRegistry } from "../../wire-registry.ts";
|
|
7
|
+
import { AddedPackage } from "../deps/add.ts";
|
|
8
|
+
|
|
9
|
+
/** The params of `pack/add` (INTERFACES §14). */
|
|
10
|
+
export interface PackAddParams {
|
|
11
|
+
/** The artifact the items' files are copied into. */
|
|
12
|
+
readonly artifact: SourceRef;
|
|
13
|
+
/**
|
|
14
|
+
* What to add, in shadcn's address forms: an item's URL, a local `.json` item, a GitHub item
|
|
15
|
+
* (`owner/repo/item[#ref]`), or `@namespace/item` from the artifact's `components.json`
|
|
16
|
+
* `registries`. Anything else is an npm spec, added as `deps/add` adds it.
|
|
17
|
+
*/
|
|
18
|
+
readonly specs: readonly string[];
|
|
19
|
+
/** Replace files the artifact already has with other content (shadcn's `--overwrite`). */
|
|
20
|
+
readonly overwrite?: boolean;
|
|
21
|
+
/** Licenses acknowledged for the items and the npm packages they bring (D31). */
|
|
22
|
+
readonly acceptLicenses?: readonly string[];
|
|
23
|
+
/**
|
|
24
|
+
* The caller's values of the variables reading the items needs, which win over the instance's
|
|
25
|
+
* own environment (a daemon started before they were set): those `components.json` names as
|
|
26
|
+
* `${VAR}`, `GH_TOKEN`, `GITHUB_TOKEN`, `REGISTRY_URL` and the proxy variables
|
|
27
|
+
* (`packVariables` in `@mostra/protocol/plugin` lists them).
|
|
28
|
+
*/
|
|
29
|
+
readonly environment?: Readonly<Record<string, string>>;
|
|
30
|
+
/** Makes retries idempotent: a repeated `requestId` returns the recorded result (H-03). */
|
|
31
|
+
readonly requestId?: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** One item `pack/add` installed. */
|
|
35
|
+
export interface PackItemSummary {
|
|
36
|
+
/** The item's `name`. */
|
|
37
|
+
readonly name: string;
|
|
38
|
+
/** Its `type` (`registry:ui` …). */
|
|
39
|
+
readonly type: string;
|
|
40
|
+
/** The address it was asked for by, or a dependency's. */
|
|
41
|
+
readonly address: string;
|
|
42
|
+
/** Where it was read: a URL, or a file. */
|
|
43
|
+
readonly source: string;
|
|
44
|
+
/** The item that needed it, for a registry dependency. */
|
|
45
|
+
readonly requiredBy?: string;
|
|
46
|
+
/** The field IDs its components introduce, from its `mostra` block. */
|
|
47
|
+
readonly fields?: readonly string[];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** One file `pack/add` wrote. */
|
|
51
|
+
export interface PackFileChange {
|
|
52
|
+
/** Its path in the artifact, `/`-separated. */
|
|
53
|
+
readonly path: string;
|
|
54
|
+
/** `created`, `overwritten` (with `overwrite`), `unchanged` (it already held this content), or `updated` (a stylesheet the items' CSS joined). */
|
|
55
|
+
readonly action: "created" | "overwritten" | "unchanged" | "updated";
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** The result of `pack/add`. */
|
|
59
|
+
export interface PackAddResult {
|
|
60
|
+
/** The items installed, registry dependencies included, in install order. */
|
|
61
|
+
readonly items: readonly PackItemSummary[];
|
|
62
|
+
/** Every file written. */
|
|
63
|
+
readonly files: readonly PackFileChange[];
|
|
64
|
+
/** The npm packages added, the items' and the plain specs', as `deps/add` answers them. */
|
|
65
|
+
readonly packages: readonly AddedPackage[];
|
|
66
|
+
/** The licenses of those packages, with their classes (D31). */
|
|
67
|
+
readonly licenses: readonly LicenseDisclosure[];
|
|
68
|
+
/** The lockfile's digest after the change, when packages were added. */
|
|
69
|
+
readonly lockDigest?: string;
|
|
70
|
+
/**
|
|
71
|
+
* What the items asked for that Mostra applied otherwise or not at all (environment variables,
|
|
72
|
+
* Tailwind 3 configuration, a stylesheet the entry doesn't import), as warnings and hints.
|
|
73
|
+
*/
|
|
74
|
+
readonly notes: readonly Diagnostic[];
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const PackItemSummary: z.ZodType<PackItemSummary> = z
|
|
78
|
+
.object({
|
|
79
|
+
name: z.string(),
|
|
80
|
+
type: z.string(),
|
|
81
|
+
address: z.string(),
|
|
82
|
+
source: z.string(),
|
|
83
|
+
requiredBy: z.string().exactOptional(),
|
|
84
|
+
fields: z.array(z.string()).readonly().exactOptional(),
|
|
85
|
+
})
|
|
86
|
+
.register(wireRegistry, { id: "PackItemSummary" });
|
|
87
|
+
|
|
88
|
+
const PackFileChange: z.ZodType<PackFileChange> = z
|
|
89
|
+
.object({
|
|
90
|
+
path: z.string().min(1),
|
|
91
|
+
action: z.enum(["created", "overwritten", "unchanged", "updated"]),
|
|
92
|
+
})
|
|
93
|
+
.register(wireRegistry, { id: "PackFileChange" });
|
|
94
|
+
|
|
95
|
+
const params: z.ZodType<PackAddParams> = z
|
|
96
|
+
.object({
|
|
97
|
+
artifact: SourceRef,
|
|
98
|
+
specs: z.array(z.string().min(1)).min(1).readonly(),
|
|
99
|
+
overwrite: z.boolean().exactOptional(),
|
|
100
|
+
acceptLicenses: z.array(z.string().min(1).max(256)).readonly().exactOptional(),
|
|
101
|
+
environment: z.record(z.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/), z.string()).exactOptional(),
|
|
102
|
+
requestId: z.string().min(1).exactOptional(),
|
|
103
|
+
})
|
|
104
|
+
.register(wireRegistry, { id: "PackAddParams" });
|
|
105
|
+
|
|
106
|
+
const result: z.ZodType<PackAddResult> = z
|
|
107
|
+
.object({
|
|
108
|
+
items: z.array(PackItemSummary).readonly(),
|
|
109
|
+
files: z.array(PackFileChange).readonly(),
|
|
110
|
+
packages: z.array(AddedPackage).readonly(),
|
|
111
|
+
licenses: z.array(LicenseDisclosure).readonly(),
|
|
112
|
+
lockDigest: z
|
|
113
|
+
.string()
|
|
114
|
+
.regex(/^[0-9a-f]{64}$/)
|
|
115
|
+
.exactOptional(),
|
|
116
|
+
notes: z.array(Diagnostic).readonly(),
|
|
117
|
+
})
|
|
118
|
+
.register(wireRegistry, { id: "PackAddResult" });
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* `pack/add`: copies source-pack items (shadcn registry items, with or without a `mostra` block,
|
|
122
|
+
* EX-03) into an artifact's source, with their registry dependencies, merges their CSS into its
|
|
123
|
+
* stylesheet, and adds their npm dependencies, and any plain npm specs, as `deps/add` does. Every
|
|
124
|
+
* file is checked before any is written, and none is replaced without `overwrite`. The method
|
|
125
|
+
* behind `mostra add`.
|
|
126
|
+
*/
|
|
127
|
+
export const packAddMethod: MethodDefinition<PackAddParams, PackAddResult> = defineMethod({
|
|
128
|
+
method: "pack/add",
|
|
129
|
+
direction: "client-to-instance",
|
|
130
|
+
mutating: true,
|
|
131
|
+
params,
|
|
132
|
+
result,
|
|
133
|
+
});
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
import { SourceRef } from "../../artifact.ts";
|
|
3
|
+
import { defineMethod, type MethodDefinition } from "../../method.ts";
|
|
4
|
+
import { LicenseDisclosure, PluginSummary } from "../../plugins.ts";
|
|
5
|
+
import { wireRegistry } from "../../wire-registry.ts";
|
|
6
|
+
|
|
7
|
+
/** The params of `plugin/add` (INTERFACES §14). */
|
|
8
|
+
export interface PluginAddParams {
|
|
9
|
+
/** The artifact whose lockfile records the plugins; exactly one of `artifact` and `home`. */
|
|
10
|
+
readonly artifact?: SourceRef;
|
|
11
|
+
/** Install for the whole home instead (exporters and CLI commands only, ROUND-3 §6.4). */
|
|
12
|
+
readonly home?: boolean;
|
|
13
|
+
/** npm specs of the plugins: `name`, `name@version`, `name@range` or `name@tag`. */
|
|
14
|
+
readonly packages: readonly string[];
|
|
15
|
+
/**
|
|
16
|
+
* Licenses acknowledged for this install (`LicenseRef-Remotion`), as `--accept-license` gives
|
|
17
|
+
* them (D31): recorded in the lockfile with when.
|
|
18
|
+
*/
|
|
19
|
+
readonly acceptLicenses?: readonly string[];
|
|
20
|
+
/** Makes retries idempotent: a repeated `requestId` returns the recorded result (H-03). */
|
|
21
|
+
readonly requestId?: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** The result of `plugin/add`. */
|
|
25
|
+
export interface PluginAddResult {
|
|
26
|
+
/** The scope's plugins after the change, in load order (the order they were added). */
|
|
27
|
+
readonly plugins: readonly PluginSummary[];
|
|
28
|
+
/** The packages this call added or moved to another version. */
|
|
29
|
+
readonly added: readonly string[];
|
|
30
|
+
/** Every license the added plugins bring, with its class, shown before anything was recorded. */
|
|
31
|
+
readonly licenses: readonly LicenseDisclosure[];
|
|
32
|
+
/** The SHA-256 of the scope's lockfile after the change: an artifact's next publish uses it. */
|
|
33
|
+
readonly lockDigest: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const params: z.ZodType<PluginAddParams> = z
|
|
37
|
+
.object({
|
|
38
|
+
artifact: SourceRef.exactOptional(),
|
|
39
|
+
home: z.boolean().exactOptional(),
|
|
40
|
+
packages: z.array(z.string().min(1)).min(1).readonly(),
|
|
41
|
+
acceptLicenses: z.array(z.string().min(1).max(256)).readonly().exactOptional(),
|
|
42
|
+
requestId: z.string().min(1).exactOptional(),
|
|
43
|
+
})
|
|
44
|
+
.register(wireRegistry, { id: "PluginAddParams" });
|
|
45
|
+
|
|
46
|
+
const result: z.ZodType<PluginAddResult> = z
|
|
47
|
+
.object({
|
|
48
|
+
plugins: z.array(PluginSummary).readonly(),
|
|
49
|
+
added: z.array(z.string()).readonly(),
|
|
50
|
+
licenses: z.array(LicenseDisclosure).readonly(),
|
|
51
|
+
lockDigest: z.string().regex(/^[0-9a-f]{64}$/),
|
|
52
|
+
})
|
|
53
|
+
.register(wireRegistry, { id: "PluginAddResult" });
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* `plugin/add`: installs plugins (npm packages with a `"mostra"` manifest) for an artifact or the
|
|
57
|
+
* home (EX-01, EX-04, ROUND-3 §6.4). Each must implement contract ranges this release serves,
|
|
58
|
+
* contribute IDs no other plugin of the scope has, and export stamped definitions; every license
|
|
59
|
+
* its installed dependencies bring is classed, and one that needs an acknowledgment refuses the
|
|
60
|
+
* install (`MOSTRA_LICENSE_UNACCEPTED`) unless `acceptLicenses` or the home's policy accepts it.
|
|
61
|
+
* Nothing is recorded until all of that holds; then the plugins, in load order, and the
|
|
62
|
+
* acknowledgments join the lockfile in one step. The method behind `mostra plugin add`.
|
|
63
|
+
*/
|
|
64
|
+
export const pluginAddMethod: MethodDefinition<PluginAddParams, PluginAddResult> = defineMethod({
|
|
65
|
+
method: "plugin/add",
|
|
66
|
+
direction: "client-to-instance",
|
|
67
|
+
mutating: true,
|
|
68
|
+
params,
|
|
69
|
+
result,
|
|
70
|
+
});
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
import { AbsolutePath, SourceRef } from "../../artifact.ts";
|
|
3
|
+
import { defineMethod, type MethodDefinition } from "../../method.ts";
|
|
4
|
+
import { PluginScope } from "../../plugins.ts";
|
|
5
|
+
import { wireRegistry } from "../../wire-registry.ts";
|
|
6
|
+
|
|
7
|
+
/** The params of `plugin/commands` (INTERFACES §14). */
|
|
8
|
+
export interface PluginCommandsParams {
|
|
9
|
+
/** The artifact whose plugins' commands count too, besides the home's. */
|
|
10
|
+
readonly artifact?: SourceRef;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** One CLI command a plugin contributes, where its definition loads from. */
|
|
14
|
+
export interface PluginCommandInfo {
|
|
15
|
+
/** Its words after `mostra`, joined by spaces: `term record`. */
|
|
16
|
+
readonly command: string;
|
|
17
|
+
/** The plugin's npm package. */
|
|
18
|
+
readonly package: string;
|
|
19
|
+
/** Its installed version. */
|
|
20
|
+
readonly version: string;
|
|
21
|
+
/** Whether the artifact's lockfile or the home's records it. */
|
|
22
|
+
readonly scope: PluginScope;
|
|
23
|
+
/** The module that exports its definition (absolute). */
|
|
24
|
+
readonly file: string;
|
|
25
|
+
/** The export that holds it. */
|
|
26
|
+
readonly export: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** The result of `plugin/commands`. */
|
|
30
|
+
export interface PluginCommandsResult {
|
|
31
|
+
/** Every command the home's plugins and the artifact's contribute, those that load. */
|
|
32
|
+
readonly commands: readonly PluginCommandInfo[];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const params: z.ZodType<PluginCommandsParams> = z
|
|
36
|
+
.object({ artifact: SourceRef.exactOptional() })
|
|
37
|
+
.register(wireRegistry, { id: "PluginCommandsParams" });
|
|
38
|
+
|
|
39
|
+
const PluginCommandInfo: z.ZodType<PluginCommandInfo> = z
|
|
40
|
+
.object({
|
|
41
|
+
command: z.string().min(1),
|
|
42
|
+
package: z.string().min(1),
|
|
43
|
+
version: z.string().min(1),
|
|
44
|
+
scope: PluginScope,
|
|
45
|
+
file: AbsolutePath,
|
|
46
|
+
export: z.string().min(1),
|
|
47
|
+
})
|
|
48
|
+
.register(wireRegistry, { id: "PluginCommandInfo" });
|
|
49
|
+
|
|
50
|
+
const result: z.ZodType<PluginCommandsResult> = z
|
|
51
|
+
.object({ commands: z.array(PluginCommandInfo).readonly() })
|
|
52
|
+
.register(wireRegistry, { id: "PluginCommandsResult" });
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* `plugin/commands`: the CLI commands plugins contribute (`@mostra/contract-cli-command`), the
|
|
56
|
+
* home's and an artifact's, with the module each loads from. The CLI runs a command it doesn't
|
|
57
|
+
* know as one of them, in its own process, as a git subcommand runs: the command talks to the
|
|
58
|
+
* instance through the CLI's own session.
|
|
59
|
+
*/
|
|
60
|
+
export const pluginCommandsMethod: MethodDefinition<PluginCommandsParams, PluginCommandsResult> =
|
|
61
|
+
defineMethod({
|
|
62
|
+
method: "plugin/commands",
|
|
63
|
+
direction: "client-to-instance",
|
|
64
|
+
mutating: false,
|
|
65
|
+
params,
|
|
66
|
+
result,
|
|
67
|
+
});
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
import { ArtifactRef } from "../../artifact.ts";
|
|
3
|
+
import { defineMethod, type MethodDefinition } from "../../method.ts";
|
|
4
|
+
import { wireRegistry } from "../../wire-registry.ts";
|
|
5
|
+
|
|
6
|
+
/** The params of `plugin/export` (INTERFACES §14). */
|
|
7
|
+
export interface PluginExportParams {
|
|
8
|
+
/** The artifact: its ID, or a source path it was published from. */
|
|
9
|
+
readonly artifact: ArtifactRef;
|
|
10
|
+
/** The version: a number or a version ID; the latest when absent. */
|
|
11
|
+
readonly version?: number | string;
|
|
12
|
+
/** The exporter's ID: one the artifact's plugins or the home's contribute. */
|
|
13
|
+
readonly exporter: string;
|
|
14
|
+
/** Where: an absolute path, which must not exist yet, or be an empty directory. */
|
|
15
|
+
readonly out: string;
|
|
16
|
+
/** The exporter's options, as JSON its `options` schema describes. */
|
|
17
|
+
readonly options?: Readonly<Record<string, unknown>>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** The result of `plugin/export`. */
|
|
21
|
+
export interface PluginExportResult {
|
|
22
|
+
/** What it wrote, as absolute paths. */
|
|
23
|
+
readonly files: readonly string[];
|
|
24
|
+
/** The file to open first, when the exporter names one. */
|
|
25
|
+
readonly entry?: string;
|
|
26
|
+
/** The version exported. */
|
|
27
|
+
readonly versionId: string;
|
|
28
|
+
/** The exporter, and the plugin that contributes it. */
|
|
29
|
+
readonly exporter: { readonly id: string; readonly package: string };
|
|
30
|
+
/** What the exporter reported, in its own codes (`@mostra/contract-exporter`'s `Finding`). */
|
|
31
|
+
readonly findings: readonly PluginFinding[];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Something a plugin's contribution reported, in the plugin's own code. */
|
|
35
|
+
export interface PluginFinding {
|
|
36
|
+
/** The plugin's code: upper-case letters, digits and `_`. */
|
|
37
|
+
readonly code: string;
|
|
38
|
+
/** How serious it is: `error` means the export is wrong, `warning` and `hint` inform. */
|
|
39
|
+
readonly severity: "error" | "warning" | "hint";
|
|
40
|
+
/** What it found. */
|
|
41
|
+
readonly message: string;
|
|
42
|
+
/** What to do, in one sentence. */
|
|
43
|
+
readonly hint?: string;
|
|
44
|
+
/** Where, in the version's files. */
|
|
45
|
+
readonly location?: { readonly file: string; readonly line?: number; readonly column?: number };
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const PluginFinding: z.ZodType<PluginFinding> = z
|
|
49
|
+
.object({
|
|
50
|
+
code: z.string().min(1).max(64),
|
|
51
|
+
severity: z.enum(["error", "warning", "hint"]),
|
|
52
|
+
message: z.string(),
|
|
53
|
+
hint: z.string().exactOptional(),
|
|
54
|
+
location: z
|
|
55
|
+
.object({
|
|
56
|
+
file: z.string(),
|
|
57
|
+
line: z.int().min(1).exactOptional(),
|
|
58
|
+
column: z.int().min(1).exactOptional(),
|
|
59
|
+
})
|
|
60
|
+
.exactOptional(),
|
|
61
|
+
})
|
|
62
|
+
.register(wireRegistry, {
|
|
63
|
+
id: "PluginFinding",
|
|
64
|
+
description: "Something a plugin's contribution reported, in the plugin's own code.",
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
const params: z.ZodType<PluginExportParams> = z
|
|
68
|
+
.object({
|
|
69
|
+
artifact: ArtifactRef,
|
|
70
|
+
version: z.union([z.int().min(1), z.string().min(1)]).exactOptional(),
|
|
71
|
+
exporter: z.string().regex(/^[a-z0-9][a-z0-9._-]{0,63}$/),
|
|
72
|
+
out: z.string().min(1),
|
|
73
|
+
options: z.record(z.string(), z.unknown()).exactOptional(),
|
|
74
|
+
})
|
|
75
|
+
.register(wireRegistry, { id: "PluginExportParams" });
|
|
76
|
+
|
|
77
|
+
const result: z.ZodType<PluginExportResult> = z
|
|
78
|
+
.object({
|
|
79
|
+
files: z.array(z.string()).readonly(),
|
|
80
|
+
entry: z.string().exactOptional(),
|
|
81
|
+
versionId: z.string(),
|
|
82
|
+
exporter: z.object({ id: z.string(), package: z.string() }),
|
|
83
|
+
findings: z.array(PluginFinding).readonly(),
|
|
84
|
+
})
|
|
85
|
+
.register(wireRegistry, { id: "PluginExportResult" });
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* `plugin/export`: runs an exporter a plugin contributes (`@mostra/contract-exporter`) on a
|
|
89
|
+
* published version's client build, in a plugin child of the instance, and writes the files it
|
|
90
|
+
* returns under `out`. `mostra export --as <id>` calls it for every exporter Mostra doesn't build
|
|
91
|
+
* in.
|
|
92
|
+
*/
|
|
93
|
+
export const pluginExportMethod: MethodDefinition<PluginExportParams, PluginExportResult> =
|
|
94
|
+
defineMethod({
|
|
95
|
+
method: "plugin/export",
|
|
96
|
+
direction: "client-to-instance",
|
|
97
|
+
mutating: false,
|
|
98
|
+
params,
|
|
99
|
+
result,
|
|
100
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
import { SourceRef } from "../../artifact.ts";
|
|
3
|
+
import { defineMethod, type MethodDefinition } from "../../method.ts";
|
|
4
|
+
import { LicenseDisclosure, PluginSummary } from "../../plugins.ts";
|
|
5
|
+
import { wireRegistry } from "../../wire-registry.ts";
|
|
6
|
+
|
|
7
|
+
/** The params of `plugin/list` (INTERFACES §14). */
|
|
8
|
+
export interface PluginListParams {
|
|
9
|
+
/** The artifact whose plugins to list; exactly one of `artifact` and `home`. */
|
|
10
|
+
readonly artifact?: SourceRef;
|
|
11
|
+
/** List the home's own plugins instead. */
|
|
12
|
+
readonly home?: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** The result of `plugin/list`. */
|
|
16
|
+
export interface PluginListResult {
|
|
17
|
+
/** The scope's plugins in load order, each checked against this release as it is now. */
|
|
18
|
+
readonly plugins: readonly PluginSummary[];
|
|
19
|
+
/** Every license they bring, and where its acknowledgment stands. */
|
|
20
|
+
readonly licenses: readonly LicenseDisclosure[];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const params: z.ZodType<PluginListParams> = z
|
|
24
|
+
.object({ artifact: SourceRef.exactOptional(), home: z.boolean().exactOptional() })
|
|
25
|
+
.register(wireRegistry, { id: "PluginListParams" });
|
|
26
|
+
|
|
27
|
+
const result: z.ZodType<PluginListResult> = z
|
|
28
|
+
.object({
|
|
29
|
+
plugins: z.array(PluginSummary).readonly(),
|
|
30
|
+
licenses: z.array(LicenseDisclosure).readonly(),
|
|
31
|
+
})
|
|
32
|
+
.register(wireRegistry, { id: "PluginListResult" });
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* `plugin/list`: an artifact's plugins, or the home's, in load order, each loaded as `verify`
|
|
36
|
+
* and `publish` would load it now, with the licenses they bring. The method behind
|
|
37
|
+
* `mostra plugin list`.
|
|
38
|
+
*/
|
|
39
|
+
export const pluginListMethod: MethodDefinition<PluginListParams, PluginListResult> = defineMethod({
|
|
40
|
+
method: "plugin/list",
|
|
41
|
+
direction: "client-to-instance",
|
|
42
|
+
mutating: false,
|
|
43
|
+
params,
|
|
44
|
+
result,
|
|
45
|
+
});
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
import { SourceRef } from "../../artifact.ts";
|
|
3
|
+
import { defineMethod, type MethodDefinition } from "../../method.ts";
|
|
4
|
+
import { PluginSummary } from "../../plugins.ts";
|
|
5
|
+
import { wireRegistry } from "../../wire-registry.ts";
|
|
6
|
+
|
|
7
|
+
/** The params of `plugin/remove` (INTERFACES §14). */
|
|
8
|
+
export interface PluginRemoveParams {
|
|
9
|
+
/** The artifact whose plugins to remove; exactly one of `artifact` and `home`. */
|
|
10
|
+
readonly artifact?: SourceRef;
|
|
11
|
+
/** Remove from the home's own plugins instead. */
|
|
12
|
+
readonly home?: boolean;
|
|
13
|
+
/** The plugins' package names. */
|
|
14
|
+
readonly packages: readonly string[];
|
|
15
|
+
/** Makes retries idempotent: a repeated `requestId` returns the recorded result (H-03). */
|
|
16
|
+
readonly requestId?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** The result of `plugin/remove`. */
|
|
20
|
+
export interface PluginRemoveResult {
|
|
21
|
+
/** The packages removed. */
|
|
22
|
+
readonly removed: readonly string[];
|
|
23
|
+
/** The scope's plugins after the change, in load order. */
|
|
24
|
+
readonly plugins: readonly PluginSummary[];
|
|
25
|
+
/** The SHA-256 of the scope's lockfile after the change. */
|
|
26
|
+
readonly lockDigest: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const params: z.ZodType<PluginRemoveParams> = z
|
|
30
|
+
.object({
|
|
31
|
+
artifact: SourceRef.exactOptional(),
|
|
32
|
+
home: z.boolean().exactOptional(),
|
|
33
|
+
packages: z.array(z.string().min(1)).min(1).readonly(),
|
|
34
|
+
requestId: z.string().min(1).exactOptional(),
|
|
35
|
+
})
|
|
36
|
+
.register(wireRegistry, { id: "PluginRemoveParams" });
|
|
37
|
+
|
|
38
|
+
const result: z.ZodType<PluginRemoveResult> = z
|
|
39
|
+
.object({
|
|
40
|
+
removed: z.array(z.string()).readonly(),
|
|
41
|
+
plugins: z.array(PluginSummary).readonly(),
|
|
42
|
+
lockDigest: z.string().regex(/^[0-9a-f]{64}$/),
|
|
43
|
+
})
|
|
44
|
+
.register(wireRegistry, { id: "PluginRemoveResult" });
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* `plugin/remove`: takes plugins out of an artifact's lockfile (or the home's), with the license
|
|
48
|
+
* acknowledgments no remaining plugin needs; a package the artifact's source still imports stays
|
|
49
|
+
* in its lockfile as an ordinary package. The method behind `mostra plugin remove`.
|
|
50
|
+
*/
|
|
51
|
+
export const pluginRemoveMethod: MethodDefinition<PluginRemoveParams, PluginRemoveResult> =
|
|
52
|
+
defineMethod({
|
|
53
|
+
method: "plugin/remove",
|
|
54
|
+
direction: "client-to-instance",
|
|
55
|
+
mutating: true,
|
|
56
|
+
params,
|
|
57
|
+
result,
|
|
58
|
+
});
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
import { AbsolutePath } from "../../artifact.ts";
|
|
3
|
+
import { Diagnostic } from "../../diagnostics/diagnostic.ts";
|
|
4
|
+
import { defineMethod, type MethodDefinition } from "../../method.ts";
|
|
5
|
+
import { PluginSummary } from "../../plugins.ts";
|
|
6
|
+
import { wireRegistry } from "../../wire-registry.ts";
|
|
7
|
+
|
|
8
|
+
/** The params of `plugin/validate` (INTERFACES §14). */
|
|
9
|
+
export interface PluginValidateParams {
|
|
10
|
+
/** The plugin's package directory, which holds its `package.json` (absolute). */
|
|
11
|
+
readonly path: string;
|
|
12
|
+
/**
|
|
13
|
+
* Licenses acknowledged for what the package brings (D31): its entries are loaded only once
|
|
14
|
+
* every license that needs an acknowledgment has one, as an install would load them.
|
|
15
|
+
*/
|
|
16
|
+
readonly acceptLicenses?: readonly string[];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** The result of `plugin/validate`. */
|
|
20
|
+
export interface PluginValidateResult {
|
|
21
|
+
/** Whether the plugin loads in this release: no diagnostic is an error. */
|
|
22
|
+
readonly valid: boolean;
|
|
23
|
+
/** The plugin as Mostra reads it, when its manifest has no error. */
|
|
24
|
+
readonly plugin?: PluginSummary;
|
|
25
|
+
/**
|
|
26
|
+
* Every problem, each with its location in `package.json` or the module it concerns: the
|
|
27
|
+
* manifest's fields, contract ranges, entries and their stamps, licenses.
|
|
28
|
+
*/
|
|
29
|
+
readonly diagnostics: readonly Diagnostic[];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const params: z.ZodType<PluginValidateParams> = z
|
|
33
|
+
.object({
|
|
34
|
+
path: AbsolutePath,
|
|
35
|
+
acceptLicenses: z.array(z.string().min(1).max(256)).readonly().exactOptional(),
|
|
36
|
+
})
|
|
37
|
+
.register(wireRegistry, { id: "PluginValidateParams" });
|
|
38
|
+
|
|
39
|
+
const result: z.ZodType<PluginValidateResult> = z
|
|
40
|
+
.object({
|
|
41
|
+
valid: z.boolean(),
|
|
42
|
+
plugin: PluginSummary.exactOptional(),
|
|
43
|
+
diagnostics: z.array(Diagnostic).readonly(),
|
|
44
|
+
})
|
|
45
|
+
.register(wireRegistry, { id: "PluginValidateResult" });
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* `plugin/validate`: checks a plugin package as Mostra would load it (EX-02), reporting every
|
|
49
|
+
* invalid field of its `"mostra"` manifest, every contract range this release doesn't implement,
|
|
50
|
+
* and every entry that doesn't export a definition stamped with its contract, without installing
|
|
51
|
+
* anything. The method behind `mostra plugin validate`.
|
|
52
|
+
*/
|
|
53
|
+
export const pluginValidateMethod: MethodDefinition<PluginValidateParams, PluginValidateResult> =
|
|
54
|
+
defineMethod({
|
|
55
|
+
method: "plugin/validate",
|
|
56
|
+
direction: "client-to-instance",
|
|
57
|
+
mutating: false,
|
|
58
|
+
params,
|
|
59
|
+
result,
|
|
60
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Written by `node tools/release/versions.ts sync` from each `@mostra/contract-*` package's
|
|
3
|
+
* version. Don't edit: the release's version step keeps it equal to the packages.
|
|
4
|
+
*/
|
|
5
|
+
import type { ContractName } from "../plugins.ts";
|
|
6
|
+
|
|
7
|
+
/** The version of each contract package this release implements. */
|
|
8
|
+
export const CONTRACT_VERSIONS: Readonly<Record<ContractName, string>> = {
|
|
9
|
+
"anchor-provider": "0.1.0",
|
|
10
|
+
"cli-command": "0.1.0",
|
|
11
|
+
connector: "0.1.0",
|
|
12
|
+
"embed-engine": "0.1.0",
|
|
13
|
+
exporter: "0.1.0",
|
|
14
|
+
"verify-check": "0.1.0",
|
|
15
|
+
};
|