@camerontaylor/paseo-protocol 0.11.0-beta.3.fork.1 → 0.11.1-fork.2

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.
@@ -0,0 +1,50 @@
1
+ /** Presentation contract for author-controlled registry content, independent of the UI runtime. */
2
+ export const pluginOverviewPolicy = {
3
+ rawHtml: false,
4
+ elements: [
5
+ "p",
6
+ "br",
7
+ "hr",
8
+ "h1",
9
+ "h2",
10
+ "h3",
11
+ "h4",
12
+ "h5",
13
+ "h6",
14
+ "blockquote",
15
+ "ul",
16
+ "ol",
17
+ "li",
18
+ "strong",
19
+ "em",
20
+ "del",
21
+ "pre",
22
+ "code",
23
+ "a",
24
+ "img",
25
+ "table",
26
+ "thead",
27
+ "tbody",
28
+ "tr",
29
+ "th",
30
+ "td",
31
+ ],
32
+ link: { rel: "noopener noreferrer nofollow", target: "_blank" },
33
+ };
34
+ /** Validate decoded Markdown destinations; never resolve against the reader's page or repository. */
35
+ export function pluginOverviewUrl(value) {
36
+ // URL parsers discard controls and normalize backslashes; reject those ambiguous spellings.
37
+ // eslint-disable-next-line no-control-regex
38
+ if (!value || !/^https:\/\/[^/?#]/i.test(value) || /[\u0000-\u0020\u007f\\]/.test(value))
39
+ return undefined;
40
+ try {
41
+ const url = new URL(value);
42
+ if (url.protocol !== "https:" || !url.hostname || url.username || url.password)
43
+ return undefined;
44
+ return value;
45
+ }
46
+ catch {
47
+ return undefined;
48
+ }
49
+ }
50
+ //# sourceMappingURL=plugin-overview.js.map
@@ -0,0 +1,147 @@
1
+ import { z } from "zod";
2
+ export declare const PluginRegistryIdSchema: z.ZodString;
3
+ export declare const PluginRegistryIdentitySchema: z.ZodObject<{
4
+ url: z.ZodString;
5
+ id: z.ZodString;
6
+ }, z.core.$strip>;
7
+ export declare const PluginRegistriesSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
8
+ authorization: z.ZodString;
9
+ }, z.core.$strip>>;
10
+ export declare const PluginRegistryArtifactSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
11
+ kind: z.ZodLiteral<"npm">;
12
+ package: z.ZodString;
13
+ version: z.ZodString;
14
+ resolved: z.ZodString;
15
+ integrity: z.ZodString;
16
+ }, z.core.$strip>, z.ZodObject<{
17
+ kind: z.ZodLiteral<"git">;
18
+ remote: z.ZodString;
19
+ commit: z.ZodString;
20
+ pluginPath: z.ZodOptional<z.ZodString>;
21
+ }, z.core.$strip>], "kind">;
22
+ export declare const PublishedPluginSchema: z.ZodObject<{
23
+ id: z.ZodString;
24
+ name: z.ZodString;
25
+ description: z.ZodString;
26
+ license: z.ZodOptional<z.ZodString>;
27
+ categories: z.ZodArray<z.ZodString>;
28
+ author: z.ZodObject<{
29
+ github: z.ZodString;
30
+ name: z.ZodOptional<z.ZodString>;
31
+ npm: z.ZodOptional<z.ZodString>;
32
+ }, z.core.$strip>;
33
+ repository: z.ZodObject<{
34
+ url: z.ZodString;
35
+ commit: z.ZodOptional<z.ZodString>;
36
+ }, z.core.$strip>;
37
+ artifact: z.ZodDiscriminatedUnion<[z.ZodObject<{
38
+ kind: z.ZodLiteral<"npm">;
39
+ package: z.ZodString;
40
+ version: z.ZodString;
41
+ resolved: z.ZodString;
42
+ integrity: z.ZodString;
43
+ }, z.core.$strip>, z.ZodObject<{
44
+ kind: z.ZodLiteral<"git">;
45
+ remote: z.ZodString;
46
+ commit: z.ZodString;
47
+ pluginPath: z.ZodOptional<z.ZodString>;
48
+ }, z.core.$strip>], "kind">;
49
+ icon: z.ZodOptional<z.ZodString>;
50
+ media: z.ZodArray<z.ZodString>;
51
+ submittedAt: z.ZodString;
52
+ reviewedAt: z.ZodString;
53
+ updatedAt: z.ZodString;
54
+ publishedAt: z.ZodString;
55
+ installs: z.ZodOptional<z.ZodNumber>;
56
+ }, z.core.$strip>;
57
+ /** Whether a registry media entry is a video or an image, from its path extension. */
58
+ export declare function pluginMediaKind(url: string): "image" | "video";
59
+ export declare const PublishedPluginDetailSchema: z.ZodObject<{
60
+ id: z.ZodString;
61
+ name: z.ZodString;
62
+ description: z.ZodString;
63
+ license: z.ZodOptional<z.ZodString>;
64
+ categories: z.ZodArray<z.ZodString>;
65
+ author: z.ZodObject<{
66
+ github: z.ZodString;
67
+ name: z.ZodOptional<z.ZodString>;
68
+ npm: z.ZodOptional<z.ZodString>;
69
+ }, z.core.$strip>;
70
+ repository: z.ZodObject<{
71
+ url: z.ZodString;
72
+ commit: z.ZodOptional<z.ZodString>;
73
+ }, z.core.$strip>;
74
+ artifact: z.ZodDiscriminatedUnion<[z.ZodObject<{
75
+ kind: z.ZodLiteral<"npm">;
76
+ package: z.ZodString;
77
+ version: z.ZodString;
78
+ resolved: z.ZodString;
79
+ integrity: z.ZodString;
80
+ }, z.core.$strip>, z.ZodObject<{
81
+ kind: z.ZodLiteral<"git">;
82
+ remote: z.ZodString;
83
+ commit: z.ZodString;
84
+ pluginPath: z.ZodOptional<z.ZodString>;
85
+ }, z.core.$strip>], "kind">;
86
+ icon: z.ZodOptional<z.ZodString>;
87
+ media: z.ZodArray<z.ZodString>;
88
+ submittedAt: z.ZodString;
89
+ reviewedAt: z.ZodString;
90
+ updatedAt: z.ZodString;
91
+ publishedAt: z.ZodString;
92
+ installs: z.ZodOptional<z.ZodNumber>;
93
+ readme: z.ZodString;
94
+ }, z.core.$strip>;
95
+ export declare const PluginRegistryIndexSchema: z.ZodObject<{
96
+ schemaVersion: z.ZodLiteral<1>;
97
+ registry: z.ZodObject<{
98
+ name: z.ZodString;
99
+ url: z.ZodString;
100
+ }, z.core.$strip>;
101
+ categories: z.ZodArray<z.ZodObject<{
102
+ slug: z.ZodString;
103
+ label: z.ZodString;
104
+ description: z.ZodOptional<z.ZodString>;
105
+ }, z.core.$strip>>;
106
+ plugins: z.ZodArray<z.ZodObject<{
107
+ id: z.ZodString;
108
+ name: z.ZodString;
109
+ description: z.ZodString;
110
+ license: z.ZodOptional<z.ZodString>;
111
+ categories: z.ZodArray<z.ZodString>;
112
+ author: z.ZodObject<{
113
+ github: z.ZodString;
114
+ name: z.ZodOptional<z.ZodString>;
115
+ npm: z.ZodOptional<z.ZodString>;
116
+ }, z.core.$strip>;
117
+ repository: z.ZodObject<{
118
+ url: z.ZodString;
119
+ commit: z.ZodOptional<z.ZodString>;
120
+ }, z.core.$strip>;
121
+ artifact: z.ZodDiscriminatedUnion<[z.ZodObject<{
122
+ kind: z.ZodLiteral<"npm">;
123
+ package: z.ZodString;
124
+ version: z.ZodString;
125
+ resolved: z.ZodString;
126
+ integrity: z.ZodString;
127
+ }, z.core.$strip>, z.ZodObject<{
128
+ kind: z.ZodLiteral<"git">;
129
+ remote: z.ZodString;
130
+ commit: z.ZodString;
131
+ pluginPath: z.ZodOptional<z.ZodString>;
132
+ }, z.core.$strip>], "kind">;
133
+ icon: z.ZodOptional<z.ZodString>;
134
+ media: z.ZodArray<z.ZodString>;
135
+ submittedAt: z.ZodString;
136
+ reviewedAt: z.ZodString;
137
+ updatedAt: z.ZodString;
138
+ publishedAt: z.ZodString;
139
+ installs: z.ZodOptional<z.ZodNumber>;
140
+ }, z.core.$strip>>;
141
+ featured: z.ZodArray<z.ZodString>;
142
+ generatedAt: z.ZodString;
143
+ }, z.core.$strip>;
144
+ export type PluginRegistryIdentity = z.infer<typeof PluginRegistryIdentitySchema>;
145
+ export type PluginRegistries = z.infer<typeof PluginRegistriesSchema>;
146
+ export declare function parsePluginRegistryReference(source: string, defaultUrl?: string): PluginRegistryIdentity | null;
147
+ //# sourceMappingURL=plugin-registry.d.ts.map
@@ -0,0 +1,75 @@
1
+ import { z } from "zod";
2
+ export const PluginRegistryIdSchema = z
3
+ .string()
4
+ .regex(/^[a-z0-9]+(?:-[a-z0-9]+)*\/[a-z0-9]+(?:-[a-z0-9]+)*$/);
5
+ export const PluginRegistryIdentitySchema = z.object({
6
+ url: z.string().url(),
7
+ id: PluginRegistryIdSchema,
8
+ });
9
+ export const PluginRegistriesSchema = z.record(z.string(), z.object({ authorization: z.string().min(1) }));
10
+ export const PluginRegistryArtifactSchema = z.discriminatedUnion("kind", [
11
+ z.object({
12
+ kind: z.literal("npm"),
13
+ package: z.string().regex(/^(?:@[a-z0-9][\w.-]*\/)?[a-z0-9][\w.-]*$/),
14
+ version: z.string().regex(/^\d+\.\d+\.\d+(?:-[\w.-]+)?(?:\+[\w.-]+)?$/),
15
+ resolved: z.string().url(),
16
+ integrity: z.string().regex(/^sha512-[A-Za-z0-9+/]+=*$/),
17
+ }),
18
+ z.object({
19
+ kind: z.literal("git"),
20
+ remote: z.string().min(1),
21
+ commit: z.string().regex(/^[0-9a-f]{40,64}$/),
22
+ pluginPath: z
23
+ .string()
24
+ .regex(/^[^\\:]+$/)
25
+ .optional(),
26
+ }),
27
+ ]);
28
+ export const PublishedPluginSchema = z.object({
29
+ id: PluginRegistryIdSchema,
30
+ name: z.string(),
31
+ description: z.string(),
32
+ license: z.string().optional(),
33
+ categories: z.array(z.string()),
34
+ author: z.object({ github: z.string(), name: z.string().optional(), npm: z.string().optional() }),
35
+ repository: z.object({ url: z.string().url(), commit: z.string().optional() }),
36
+ artifact: PluginRegistryArtifactSchema,
37
+ icon: z.string().url().optional(),
38
+ /** Images and videos in display order; see `pluginMediaKind`. */
39
+ media: z.array(z.string().url()),
40
+ submittedAt: z.string(),
41
+ reviewedAt: z.string(),
42
+ updatedAt: z.string(),
43
+ publishedAt: z.string(),
44
+ installs: z.number().int().nonnegative().optional(),
45
+ });
46
+ const VIDEO_EXTENSIONS = new Set(["mp4", "webm"]);
47
+ /** Whether a registry media entry is a video or an image, from its path extension. */
48
+ export function pluginMediaKind(url) {
49
+ const extension = new URL(url).pathname.split(".").pop()?.toLowerCase() ?? "";
50
+ return VIDEO_EXTENSIONS.has(extension) ? "video" : "image";
51
+ }
52
+ export const PublishedPluginDetailSchema = PublishedPluginSchema.extend({ readme: z.string() });
53
+ export const PluginRegistryIndexSchema = z.object({
54
+ schemaVersion: z.literal(1),
55
+ registry: z.object({ name: z.string(), url: z.string().url() }),
56
+ categories: z.array(z.object({ slug: z.string(), label: z.string(), description: z.string().optional() })),
57
+ plugins: z.array(PublishedPluginSchema),
58
+ /** Plugin IDs the maintainer features, in display order. An ID may name a plugin that is not listed. */
59
+ featured: z.array(z.string()),
60
+ generatedAt: z.string(),
61
+ });
62
+ export function parsePluginRegistryReference(source, defaultUrl = "https://plugins.paseo.sh") {
63
+ const segments = source.split("/");
64
+ if (segments.length === 2 && PluginRegistryIdSchema.safeParse(source).success)
65
+ return { url: defaultUrl.replace(/\/+$/, ""), id: source };
66
+ const [host, ...rest] = segments;
67
+ if (segments.length !== 3 || !host || !/[.:]/.test(host) || /[@?#\\]/.test(host))
68
+ return null;
69
+ const id = rest.join("/");
70
+ if (!PluginRegistryIdSchema.safeParse(id).success)
71
+ return null;
72
+ const url = new URL(`https://${host}`);
73
+ return { url: url.origin, id };
74
+ }
75
+ //# sourceMappingURL=plugin-registry.js.map
@@ -1,5 +1,6 @@
1
1
  import type { PluginInstallation } from "./messages.js";
2
2
  export interface PluginSourceReference {
3
+ kind: "directory" | "managed";
3
4
  source: string;
4
5
  pluginPath: string | undefined;
5
6
  }
@@ -1,8 +1,14 @@
1
+ import { parsePluginRegistryReference } from "./plugin-registry.js";
1
2
  export function parsePluginSourceReference(reference) {
2
3
  const prefix = /^(npm:|github:|git:(?!\/\/))/.exec(reference)?.[0];
3
4
  const source = prefix ? reference.slice(prefix.length) : reference;
4
5
  const parsed = splitPluginPath(source, { scp: prefix !== "npm:" });
5
- return { ...parsed, source: `${prefix ?? ""}${parsed.source}` };
6
+ if (!prefix && /^(\.\.?(?:[/\\]|$)|\/|~|[A-Za-z]:[/\\]|\\\\)/.test(parsed.source)) {
7
+ return { kind: "directory", ...parsed };
8
+ }
9
+ if (parsePluginRegistryReference(reference))
10
+ return { kind: "managed", source: reference, pluginPath: undefined };
11
+ return { kind: "managed", ...parsed, source: `${prefix ?? ""}${parsed.source}` };
6
12
  }
7
13
  function splitPluginPath(reference, options) {
8
14
  const separator = reference.lastIndexOf(":");
@@ -47,6 +53,8 @@ function isPortableRelativePluginPath(pluginPath) {
47
53
  export function formatPluginIdentity(identity) {
48
54
  if (identity.kind === "directory")
49
55
  return identity.path;
56
+ if (identity.registry)
57
+ return `${new URL(identity.registry.url).host}/${identity.registry.id}`;
50
58
  const source = identity.kind === "npm" ? `npm:${identity.packageName}` : `git:${identity.remote}`;
51
59
  return identity.pluginPath === "." ? source : `${source}:${identity.pluginPath}`;
52
60
  }
@@ -112,13 +112,13 @@ export declare const ScheduleCreateResponseSchema: z.ZodObject<{
112
112
  schedule: z.ZodNullable<z.ZodObject<{
113
113
  name: z.ZodNullable<z.ZodString>;
114
114
  id: z.ZodString;
115
+ updatedAt: z.ZodString;
115
116
  status: z.ZodEnum<{
116
117
  completed: "completed";
117
118
  active: "active";
118
119
  paused: "paused";
119
120
  }>;
120
121
  createdAt: z.ZodString;
121
- updatedAt: z.ZodString;
122
122
  cadence: z.ZodDiscriminatedUnion<[z.ZodObject<{
123
123
  type: z.ZodLiteral<"every">;
124
124
  everyMs: z.ZodNumber;
@@ -167,13 +167,13 @@ export declare const ScheduleListResponseSchema: z.ZodObject<{
167
167
  schedules: z.ZodArray<z.ZodObject<{
168
168
  name: z.ZodNullable<z.ZodString>;
169
169
  id: z.ZodString;
170
+ updatedAt: z.ZodString;
170
171
  status: z.ZodEnum<{
171
172
  completed: "completed";
172
173
  active: "active";
173
174
  paused: "paused";
174
175
  }>;
175
176
  createdAt: z.ZodString;
176
- updatedAt: z.ZodString;
177
177
  cadence: z.ZodDiscriminatedUnion<[z.ZodObject<{
178
178
  type: z.ZodLiteral<"every">;
179
179
  everyMs: z.ZodNumber;
@@ -314,13 +314,13 @@ export declare const SchedulePauseResponseSchema: z.ZodObject<{
314
314
  schedule: z.ZodNullable<z.ZodObject<{
315
315
  name: z.ZodNullable<z.ZodString>;
316
316
  id: z.ZodString;
317
+ updatedAt: z.ZodString;
317
318
  status: z.ZodEnum<{
318
319
  completed: "completed";
319
320
  active: "active";
320
321
  paused: "paused";
321
322
  }>;
322
323
  createdAt: z.ZodString;
323
- updatedAt: z.ZodString;
324
324
  cadence: z.ZodDiscriminatedUnion<[z.ZodObject<{
325
325
  type: z.ZodLiteral<"every">;
326
326
  everyMs: z.ZodNumber;
@@ -369,13 +369,13 @@ export declare const ScheduleResumeResponseSchema: z.ZodObject<{
369
369
  schedule: z.ZodNullable<z.ZodObject<{
370
370
  name: z.ZodNullable<z.ZodString>;
371
371
  id: z.ZodString;
372
+ updatedAt: z.ZodString;
372
373
  status: z.ZodEnum<{
373
374
  completed: "completed";
374
375
  active: "active";
375
376
  paused: "paused";
376
377
  }>;
377
378
  createdAt: z.ZodString;
378
- updatedAt: z.ZodString;
379
379
  cadence: z.ZodDiscriminatedUnion<[z.ZodObject<{
380
380
  type: z.ZodLiteral<"every">;
381
381
  everyMs: z.ZodNumber;
@@ -121,13 +121,13 @@ export type StoredSchedule = z.infer<typeof StoredScheduleSchema>;
121
121
  export declare const ScheduleSummarySchema: z.ZodObject<{
122
122
  name: z.ZodNullable<z.ZodString>;
123
123
  id: z.ZodString;
124
+ updatedAt: z.ZodString;
124
125
  status: z.ZodEnum<{
125
126
  completed: "completed";
126
127
  active: "active";
127
128
  paused: "paused";
128
129
  }>;
129
130
  createdAt: z.ZodString;
130
- updatedAt: z.ZodString;
131
131
  cadence: z.ZodDiscriminatedUnion<[z.ZodObject<{
132
132
  type: z.ZodLiteral<"every">;
133
133
  everyMs: z.ZodNumber;