@milaboratories/pl-model-middle-layer 1.21.0 → 1.22.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/block_meta/block_components.cjs +19 -26
- package/dist/block_meta/block_components.cjs.map +1 -1
- package/dist/block_meta/block_components.d.ts +46 -428
- package/dist/block_meta/block_components.d.ts.map +1 -1
- package/dist/block_meta/block_components.js +19 -23
- package/dist/block_meta/block_components.js.map +1 -1
- package/dist/block_meta/block_description.cjs +5 -3
- package/dist/block_meta/block_description.cjs.map +1 -1
- package/dist/block_meta/block_description.d.ts +402 -914
- package/dist/block_meta/block_description.d.ts.map +1 -1
- package/dist/block_meta/block_description.js +5 -3
- package/dist/block_meta/block_description.js.map +1 -1
- package/dist/block_meta/block_id.d.ts +4 -4
- package/dist/block_meta/block_manifest.cjs +10 -1
- package/dist/block_meta/block_manifest.cjs.map +1 -1
- package/dist/block_meta/block_manifest.d.ts +1045 -1623
- package/dist/block_meta/block_manifest.d.ts.map +1 -1
- package/dist/block_meta/block_manifest.js +11 -2
- package/dist/block_meta/block_manifest.js.map +1 -1
- package/dist/block_meta/block_meta.cjs.map +1 -1
- package/dist/block_meta/block_meta.d.ts +164 -246
- package/dist/block_meta/block_meta.d.ts.map +1 -1
- package/dist/block_meta/block_meta.js.map +1 -1
- package/dist/block_meta/content_types.cjs +25 -77
- package/dist/block_meta/content_types.cjs.map +1 -1
- package/dist/block_meta/content_types.d.ts +71 -387
- package/dist/block_meta/content_types.d.ts.map +1 -1
- package/dist/block_meta/content_types.js +26 -64
- package/dist/block_meta/content_types.js.map +1 -1
- package/dist/block_meta/index.d.ts +3 -3
- package/dist/block_registry/block_pack_spec.d.ts +16 -16
- package/dist/block_registry/overview.d.ts +1534 -1534
- package/dist/block_registry/registry_spec.d.ts +12 -12
- package/dist/index.cjs +1 -18
- package/dist/index.d.ts +4 -4
- package/dist/index.js +3 -3
- package/package.json +2 -2
- package/src/block_meta/block_components.ts +67 -42
- package/src/block_meta/block_description.ts +18 -3
- package/src/block_meta/block_manifest.ts +14 -3
- package/src/block_meta/block_meta.ts +40 -6
- package/src/block_meta/content_types.ts +149 -207
|
@@ -1,249 +1,191 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
|
|
3
3
|
//
|
|
4
|
-
//
|
|
4
|
+
// Canonical content types. TypeScript is the source of truth. The zod
|
|
5
|
+
// schemas below are boundary validators pegged to these types via
|
|
6
|
+
// `satisfies`; they exist only to parse external data (`package.json`,
|
|
7
|
+
// registry manifests, registry overview files).
|
|
5
8
|
//
|
|
6
9
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
/** Inlined plain string (e.g. a short text snippet or markdown body). */
|
|
11
|
+
export type ContentExplicitString = {
|
|
12
|
+
type: "explicit-string";
|
|
13
|
+
content: string;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/** Inlined binary blob carried as base64 (e.g. a serialized logo image). */
|
|
17
|
+
export type ContentExplicitBase64 = {
|
|
18
|
+
type: "explicit-base64";
|
|
19
|
+
/** MIME type used to interpret `content`. */
|
|
20
|
+
mimeType: string;
|
|
21
|
+
/** Base64-encoded binary payload. */
|
|
22
|
+
content: string;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/** Inlined binary blob carried as raw bytes. Wire form only; not used in JSON. */
|
|
26
|
+
export type ContentExplicitBytes = {
|
|
27
|
+
type: "explicit-bytes";
|
|
28
|
+
/** MIME type used to interpret `content`. */
|
|
29
|
+
mimeType: string;
|
|
30
|
+
content: Uint8Array;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/** Reference to a file by path relative to the carrying structure. */
|
|
34
|
+
export type ContentRelative = {
|
|
35
|
+
type: "relative";
|
|
36
|
+
path: string;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/** Reference to a file at an absolute local path. */
|
|
40
|
+
export type ContentAbsoluteFile = {
|
|
41
|
+
type: "absolute-file";
|
|
42
|
+
file: string;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Reference to a folder at an absolute local path. Used for UI bundles
|
|
47
|
+
* delivered as folders; the desktop "add block" dialog reads such folders on
|
|
48
|
+
* demand instead of pulling every UI bundle eagerly.
|
|
49
|
+
*/
|
|
50
|
+
export type ContentAbsoluteFolder = {
|
|
51
|
+
type: "absolute-folder";
|
|
52
|
+
folder: string;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/** Reference to a file by remote URL (e.g. served from the registry). */
|
|
56
|
+
export type ContentAbsoluteUrl = {
|
|
57
|
+
type: "absolute-url";
|
|
58
|
+
url: string;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
/** Canonical union of every content carrier shape used across the platform. */
|
|
62
|
+
export type Content =
|
|
63
|
+
| ContentExplicitString
|
|
64
|
+
| ContentExplicitBase64
|
|
65
|
+
| ContentExplicitBytes
|
|
66
|
+
| ContentRelative
|
|
67
|
+
| ContentAbsoluteFile
|
|
68
|
+
| ContentAbsoluteFolder
|
|
69
|
+
| ContentAbsoluteUrl;
|
|
14
70
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
.string()
|
|
20
|
-
.regex(/\w+\/[-+.\w]+/)
|
|
21
|
-
.describe("MIME type to interpret content"),
|
|
22
|
-
content: z.string().base64().describe("Base64 encoded binary value"),
|
|
23
|
-
})
|
|
24
|
-
.strict();
|
|
25
|
-
export type ContentExplicitBase64 = z.infer<typeof ContentExplicitBase64>;
|
|
71
|
+
//
|
|
72
|
+
// Slot-specific content unions. Each names a set of carriers allowed in a
|
|
73
|
+
// particular stage of the pipeline (boundary input, manifest, resolved).
|
|
74
|
+
//
|
|
26
75
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
76
|
+
/** Inlined or relative-path content (text/binary inlined, or relative path). */
|
|
77
|
+
export type ContentExplicitOrRelative =
|
|
78
|
+
| ContentExplicitString
|
|
79
|
+
| ContentExplicitBase64
|
|
80
|
+
| ContentRelative;
|
|
81
|
+
|
|
82
|
+
/** Any locally-resolvable content (inlined, relative path, or absolute file). */
|
|
83
|
+
export type ContentAnyLocal =
|
|
84
|
+
| ContentExplicitString
|
|
85
|
+
| ContentExplicitBase64
|
|
86
|
+
| ContentRelative
|
|
87
|
+
| ContentAbsoluteFile;
|
|
88
|
+
|
|
89
|
+
/** Text content available locally (inlined, relative path, or absolute file). */
|
|
90
|
+
export type ContentAnyTextLocal = ContentExplicitString | ContentRelative | ContentAbsoluteFile;
|
|
91
|
+
|
|
92
|
+
/** Binary content available locally (inlined base64, relative path, or absolute file). */
|
|
93
|
+
export type ContentAnyBinaryLocal = ContentExplicitBase64 | ContentRelative | ContentAbsoluteFile;
|
|
94
|
+
|
|
95
|
+
/** Binary content fully resolved (inlined base64 or absolute file). */
|
|
96
|
+
export type ContentAbsoluteBinaryLocal = ContentExplicitBase64 | ContentAbsoluteFile;
|
|
97
|
+
|
|
98
|
+
/** Text content fully resolved (inlined string or absolute file). */
|
|
99
|
+
export type ContentAbsoluteTextLocal = ContentExplicitString | ContentAbsoluteFile;
|
|
100
|
+
|
|
101
|
+
/** Binary content in manifest form (inlined base64 or path relative to the manifest). */
|
|
102
|
+
export type ContentRelativeBinary = ContentExplicitBase64 | ContentRelative;
|
|
103
|
+
|
|
104
|
+
/** Text content in manifest form (inlined string or path relative to the manifest). */
|
|
105
|
+
export type ContentRelativeText = ContentExplicitString | ContentRelative;
|
|
106
|
+
|
|
107
|
+
//
|
|
108
|
+
// Zod schemas — boundary validators only. The TS types above are the source
|
|
109
|
+
// of truth; each schema is pegged via `satisfies z.ZodType<T>`. Only the
|
|
110
|
+
// schemas referenced by sibling boundary files (`block_meta.ts`,
|
|
111
|
+
// `block_manifest.ts`) are exported.
|
|
112
|
+
//
|
|
38
113
|
|
|
39
114
|
const absPathRegex = new RegExp(`^(/|[A-Z]:\\\\)`);
|
|
40
115
|
|
|
41
|
-
|
|
116
|
+
const contentExplicitStringSchema = z
|
|
42
117
|
.object({
|
|
43
|
-
type: z.literal("
|
|
44
|
-
|
|
45
|
-
.string()
|
|
46
|
-
.regex(absPathRegex, "path to file must be absolute")
|
|
47
|
-
.describe("Absolute address of the file in local file system"),
|
|
118
|
+
type: z.literal("explicit-string"),
|
|
119
|
+
content: z.string(),
|
|
48
120
|
})
|
|
49
|
-
.strict()
|
|
50
|
-
export type ContentAbsoluteFile = z.infer<typeof ContentAbsoluteFile>;
|
|
121
|
+
.strict() satisfies z.ZodType<ContentExplicitString>;
|
|
51
122
|
|
|
52
|
-
export const
|
|
123
|
+
export const ContentExplicitBase64 = z
|
|
53
124
|
.object({
|
|
54
|
-
type: z.literal("
|
|
55
|
-
|
|
125
|
+
type: z.literal("explicit-base64"),
|
|
126
|
+
mimeType: z.string().regex(/\w+\/[-+.\w]+/),
|
|
127
|
+
content: z.string().base64(),
|
|
56
128
|
})
|
|
57
|
-
.strict()
|
|
58
|
-
export type ContentAbsoluteUrl = z.infer<typeof ContentAbsoluteUrl>;
|
|
59
|
-
|
|
60
|
-
//
|
|
61
|
-
// Special content types
|
|
62
|
-
//
|
|
129
|
+
.strict() satisfies z.ZodType<ContentExplicitBase64>;
|
|
63
130
|
|
|
64
131
|
export const ContentExplicitBytes = z
|
|
65
132
|
.object({
|
|
66
133
|
type: z.literal("explicit-bytes"),
|
|
67
|
-
mimeType: z
|
|
68
|
-
|
|
69
|
-
.regex(/\w+\/[-+.\w]+/)
|
|
70
|
-
.describe("MIME type to interpret content"),
|
|
71
|
-
content: z.instanceof(Uint8Array).describe("Raw content"),
|
|
134
|
+
mimeType: z.string().regex(/\w+\/[-+.\w]+/),
|
|
135
|
+
content: z.instanceof(Uint8Array),
|
|
72
136
|
})
|
|
73
|
-
.strict()
|
|
74
|
-
export type ContentExplicitBytes = z.infer<typeof ContentExplicitBytes>;
|
|
137
|
+
.strict() satisfies z.ZodType<ContentExplicitBytes>;
|
|
75
138
|
|
|
76
|
-
export const
|
|
139
|
+
export const ContentRelative = z
|
|
77
140
|
.object({
|
|
78
|
-
type: z.literal("
|
|
79
|
-
|
|
80
|
-
.string()
|
|
81
|
-
.regex(absPathRegex, "path to folder must be absolute")
|
|
82
|
-
.describe("Absolute address of the folder in local file system"),
|
|
141
|
+
type: z.literal("relative"),
|
|
142
|
+
path: z.string(),
|
|
83
143
|
})
|
|
84
|
-
.strict()
|
|
85
|
-
export type ContentAbsoluteFolder = z.infer<typeof ContentAbsoluteFolder>;
|
|
86
|
-
|
|
87
|
-
//
|
|
88
|
-
// Unions
|
|
89
|
-
//
|
|
144
|
+
.strict() satisfies z.ZodType<ContentRelative>;
|
|
90
145
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
]);
|
|
98
|
-
export type ContentAny = z.infer<typeof ContentAny>;
|
|
99
|
-
|
|
100
|
-
export const ContentExplicitOrRelative = z.discriminatedUnion("type", [
|
|
101
|
-
ContentExplicitString,
|
|
102
|
-
ContentExplicitBase64,
|
|
103
|
-
ContentRelative,
|
|
104
|
-
]);
|
|
105
|
-
export type ContentExplicitOrRelative = z.infer<typeof ContentExplicitOrRelative>;
|
|
106
|
-
|
|
107
|
-
export const ContentAnyLocal = z.discriminatedUnion("type", [
|
|
108
|
-
ContentExplicitString,
|
|
109
|
-
ContentExplicitBase64,
|
|
110
|
-
ContentRelative,
|
|
111
|
-
ContentAbsoluteFile,
|
|
112
|
-
]);
|
|
113
|
-
export type ContentAnyLocal = z.infer<typeof ContentAnyLocal>;
|
|
146
|
+
const contentAbsoluteFileSchema = z
|
|
147
|
+
.object({
|
|
148
|
+
type: z.literal("absolute-file"),
|
|
149
|
+
file: z.string().regex(absPathRegex, "path to file must be absolute"),
|
|
150
|
+
})
|
|
151
|
+
.strict() satisfies z.ZodType<ContentAbsoluteFile>;
|
|
114
152
|
|
|
115
|
-
export const
|
|
116
|
-
ContentExplicitString,
|
|
153
|
+
export const ContentRelativeBinary = z.discriminatedUnion("type", [
|
|
117
154
|
ContentExplicitBase64,
|
|
118
155
|
ContentRelative,
|
|
119
|
-
|
|
120
|
-
]);
|
|
121
|
-
export type ContentAnyRemote = z.infer<typeof ContentAnyRemote>;
|
|
122
|
-
|
|
123
|
-
//
|
|
124
|
-
// Narrow types with relative option
|
|
125
|
-
//
|
|
126
|
-
|
|
127
|
-
// export const ContentAnyBinaryRemote = z.discriminatedUnion('type', [
|
|
128
|
-
// ContentExplicitBase64,
|
|
129
|
-
// ContentRelative,
|
|
130
|
-
// ContentAbsoluteUrl
|
|
131
|
-
// ]);
|
|
132
|
-
// export type ContentAnyBinaryRemote = z.infer<typeof ContentAnyBinaryRemote>;
|
|
156
|
+
]) satisfies z.ZodType<ContentRelativeBinary>;
|
|
133
157
|
|
|
134
|
-
export const
|
|
135
|
-
|
|
136
|
-
ContentRelative,
|
|
137
|
-
ContentAbsoluteFile,
|
|
138
|
-
]);
|
|
139
|
-
export type ContentAnyBinaryLocal = z.infer<typeof ContentAnyBinaryLocal>;
|
|
140
|
-
|
|
141
|
-
// export const ContentAnyTextRemote = z.discriminatedUnion('type', [
|
|
142
|
-
// ContentExplicitString,
|
|
143
|
-
// ContentRelative,
|
|
144
|
-
// ContentAbsoluteUrl
|
|
145
|
-
// ]);
|
|
146
|
-
// export type ContentAnyTextRemote = z.infer<typeof ContentAnyTextRemote>;
|
|
147
|
-
|
|
148
|
-
export const ContentAnyTextLocal = z.discriminatedUnion("type", [
|
|
149
|
-
ContentExplicitString,
|
|
158
|
+
export const ContentRelativeText = z.discriminatedUnion("type", [
|
|
159
|
+
contentExplicitStringSchema,
|
|
150
160
|
ContentRelative,
|
|
151
|
-
|
|
152
|
-
]);
|
|
153
|
-
export type ContentAnyTextLocal = z.infer<typeof ContentAnyTextLocal>;
|
|
161
|
+
]) satisfies z.ZodType<ContentRelativeText>;
|
|
154
162
|
|
|
155
163
|
//
|
|
156
|
-
//
|
|
157
|
-
//
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
ContentExplicitBase64,
|
|
161
|
-
ContentAbsoluteUrl,
|
|
162
|
-
]);
|
|
163
|
-
export type ContentAbsoluteBinaryRemote = z.infer<typeof ContentAbsoluteBinaryRemote>;
|
|
164
|
-
|
|
165
|
-
export const ContentAbsoluteBinaryLocal = z.discriminatedUnion("type", [
|
|
166
|
-
ContentExplicitBase64,
|
|
167
|
-
ContentAbsoluteFile,
|
|
168
|
-
]);
|
|
169
|
-
export type ContentAbsoluteBinaryLocal = z.infer<typeof ContentAbsoluteBinaryLocal>;
|
|
170
|
-
|
|
171
|
-
export const ContentAbsoluteTextRemote = z.discriminatedUnion("type", [
|
|
172
|
-
ContentExplicitString,
|
|
173
|
-
ContentAbsoluteUrl,
|
|
174
|
-
]);
|
|
175
|
-
export type ContentAbsoluteTextRemote = z.infer<typeof ContentAbsoluteTextRemote>;
|
|
176
|
-
|
|
177
|
-
export const ContentAbsoluteTextLocal = z.discriminatedUnion("type", [
|
|
178
|
-
ContentExplicitString,
|
|
179
|
-
ContentAbsoluteFile,
|
|
180
|
-
]);
|
|
181
|
-
export type ContentAbsoluteTextLocal = z.infer<typeof ContentAbsoluteTextLocal>;
|
|
182
|
-
|
|
164
|
+
// Boundary normalizing transforms — parse the loose forms authors write in
|
|
165
|
+
// `package.json`. Bare strings with the `file:` prefix become a
|
|
166
|
+
// `ContentRelative`; bare strings without the prefix become a
|
|
167
|
+
// `ContentExplicitString` (text only).
|
|
183
168
|
//
|
|
184
|
-
// Narrow relative types
|
|
185
|
-
//
|
|
186
|
-
|
|
187
|
-
export const ContentRelativeBinary = z.discriminatedUnion("type", [
|
|
188
|
-
ContentExplicitBase64,
|
|
189
|
-
ContentRelative,
|
|
190
|
-
]);
|
|
191
|
-
export type ContentRelativeBinary = z.infer<typeof ContentRelativeBinary>;
|
|
192
|
-
|
|
193
|
-
export const ContentRelativeText = z.discriminatedUnion("type", [
|
|
194
|
-
ContentExplicitString,
|
|
195
|
-
ContentRelative,
|
|
196
|
-
]);
|
|
197
|
-
export type ContentRelativeText = z.infer<typeof ContentRelativeText>;
|
|
198
|
-
|
|
199
|
-
// export function ConstructContent(
|
|
200
|
-
// contentType: 'text',
|
|
201
|
-
// contextType: 'local'
|
|
202
|
-
// ): typeof ContentAnyTextLocal;
|
|
203
|
-
// export function ConstructContent(
|
|
204
|
-
// contentType: 'text',
|
|
205
|
-
// contextType: 'remote'
|
|
206
|
-
// ): typeof ContentAnyTextRemote;
|
|
207
|
-
// export function ConstructContent(
|
|
208
|
-
// contentType: 'binary',
|
|
209
|
-
// contextType: 'local'
|
|
210
|
-
// ): typeof ContentAnyBinaryLocal;
|
|
211
|
-
// export function ConstructContent(
|
|
212
|
-
// contentType: 'binary',
|
|
213
|
-
// contextType: 'remote'
|
|
214
|
-
// ): typeof ContentAnyBinaryRemote;
|
|
215
|
-
// export function ConstructContent(
|
|
216
|
-
// contentType: ContentType,
|
|
217
|
-
// contextType: ContextType
|
|
218
|
-
// ):
|
|
219
|
-
// | typeof ContentAnyTextLocal
|
|
220
|
-
// | typeof ContentAnyTextRemote
|
|
221
|
-
// | typeof ContentAnyBinaryLocal
|
|
222
|
-
// | typeof ContentAnyBinaryRemote;
|
|
223
|
-
// export function ConstructContent(contentType: ContentType, contextType: ContextType) {
|
|
224
|
-
// return contentType === 'text'
|
|
225
|
-
// ? contextType === 'local'
|
|
226
|
-
// ? ContentAnyTextLocal
|
|
227
|
-
// : ContentAnyTextRemote
|
|
228
|
-
// : contextType === 'local'
|
|
229
|
-
// ? ContentAnyBinaryLocal
|
|
230
|
-
// : ContentAnyBinaryRemote;
|
|
231
|
-
// }
|
|
232
169
|
|
|
233
170
|
export const DescriptionContentBinary = z.union([
|
|
234
171
|
z
|
|
235
172
|
.string()
|
|
236
173
|
.startsWith("file:")
|
|
237
|
-
.transform<ContentRelativeBinary>((value) => ({
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
174
|
+
.transform<ContentRelativeBinary>((value) => ({
|
|
175
|
+
type: "relative",
|
|
176
|
+
path: value.slice(5),
|
|
177
|
+
})),
|
|
178
|
+
z.discriminatedUnion("type", [ContentExplicitBase64, ContentRelative, contentAbsoluteFileSchema]),
|
|
179
|
+
]) satisfies z.ZodType<ContentAnyBinaryLocal, z.ZodTypeDef, any>;
|
|
241
180
|
|
|
242
181
|
export const DescriptionContentText = z.union([
|
|
243
182
|
z.string().transform<ContentRelativeText>((value) => {
|
|
244
183
|
if (value.startsWith("file:")) return { type: "relative", path: value.slice(5) };
|
|
245
|
-
|
|
184
|
+
return { type: "explicit-string", content: value };
|
|
246
185
|
}),
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
186
|
+
z.discriminatedUnion("type", [
|
|
187
|
+
contentExplicitStringSchema,
|
|
188
|
+
ContentRelative,
|
|
189
|
+
contentAbsoluteFileSchema,
|
|
190
|
+
]),
|
|
191
|
+
]) satisfies z.ZodType<ContentAnyTextLocal, z.ZodTypeDef, any>;
|