@milaboratories/pl-model-middle-layer 1.20.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 +277 -789
- 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_manifest.cjs +10 -1
- package/dist/block_meta/block_manifest.cjs.map +1 -1
- package/dist/block_meta/block_manifest.d.ts +700 -1278
- 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 +92 -174
- 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 +67 -383
- 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 +8 -8
- package/dist/block_registry/overview.d.ts +200 -200
- package/dist/block_registry/registry_spec.d.ts +20 -20
- package/dist/index.cjs +1 -18
- package/dist/index.d.ts +4 -4
- package/dist/index.js +3 -3
- package/dist/pframe/internal_api/api_factory.cjs.map +1 -1
- package/dist/pframe/internal_api/api_factory.d.ts +36 -2
- package/dist/pframe/internal_api/api_factory.d.ts.map +1 -1
- package/dist/pframe/internal_api/api_factory.js.map +1 -1
- package/dist/pframe/internal_api/api_read.d.ts +40 -3
- package/dist/pframe/internal_api/api_read.d.ts.map +1 -1
- package/dist/pframe/internal_api/index.d.ts +5 -5
- package/dist/pframe/internal_api/pframe.d.ts +21 -3
- package/dist/pframe/internal_api/pframe.d.ts.map +1 -1
- package/dist/pframe/internal_api/table.d.ts +51 -1
- package/dist/pframe/internal_api/table.d.ts.map +1 -1
- package/package.json +3 -3
- 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
- package/src/pframe/internal_api/api_factory.ts +44 -0
- package/src/pframe/internal_api/api_read.ts +48 -1
- package/src/pframe/internal_api/pframe.ts +23 -2
- package/src/pframe/internal_api/table.ts +54 -0
|
@@ -1,108 +1,56 @@
|
|
|
1
1
|
require("../_virtual/_rolldown/runtime.cjs");
|
|
2
2
|
let zod = require("zod");
|
|
3
3
|
//#region src/block_meta/content_types.ts
|
|
4
|
-
const
|
|
4
|
+
const absPathRegex = new RegExp(`^(/|[A-Z]:\\\\)`);
|
|
5
|
+
const contentExplicitStringSchema = zod.z.object({
|
|
5
6
|
type: zod.z.literal("explicit-string"),
|
|
6
|
-
content: zod.z.string()
|
|
7
|
+
content: zod.z.string()
|
|
7
8
|
}).strict();
|
|
8
9
|
const ContentExplicitBase64 = zod.z.object({
|
|
9
10
|
type: zod.z.literal("explicit-base64"),
|
|
10
|
-
mimeType: zod.z.string().regex(/\w+\/[-+.\w]+/)
|
|
11
|
-
content: zod.z.string().base64()
|
|
11
|
+
mimeType: zod.z.string().regex(/\w+\/[-+.\w]+/),
|
|
12
|
+
content: zod.z.string().base64()
|
|
13
|
+
}).strict();
|
|
14
|
+
const ContentExplicitBytes = zod.z.object({
|
|
15
|
+
type: zod.z.literal("explicit-bytes"),
|
|
16
|
+
mimeType: zod.z.string().regex(/\w+\/[-+.\w]+/),
|
|
17
|
+
content: zod.z.instanceof(Uint8Array)
|
|
12
18
|
}).strict();
|
|
13
19
|
const ContentRelative = zod.z.object({
|
|
14
20
|
type: zod.z.literal("relative"),
|
|
15
|
-
path: zod.z.string()
|
|
21
|
+
path: zod.z.string()
|
|
16
22
|
}).strict();
|
|
17
|
-
const
|
|
18
|
-
const ContentAbsoluteFile = zod.z.object({
|
|
23
|
+
const contentAbsoluteFileSchema = zod.z.object({
|
|
19
24
|
type: zod.z.literal("absolute-file"),
|
|
20
|
-
file: zod.z.string().regex(absPathRegex, "path to file must be absolute")
|
|
21
|
-
}).strict();
|
|
22
|
-
const ContentAbsoluteUrl = zod.z.object({
|
|
23
|
-
type: zod.z.literal("absolute-url"),
|
|
24
|
-
url: zod.z.string().url().describe("Global URL to reach the requested file")
|
|
25
|
+
file: zod.z.string().regex(absPathRegex, "path to file must be absolute")
|
|
25
26
|
}).strict();
|
|
26
|
-
const ContentExplicitBytes = zod.z.object({
|
|
27
|
-
type: zod.z.literal("explicit-bytes"),
|
|
28
|
-
mimeType: zod.z.string().regex(/\w+\/[-+.\w]+/).describe("MIME type to interpret content"),
|
|
29
|
-
content: zod.z.instanceof(Uint8Array).describe("Raw content")
|
|
30
|
-
}).strict();
|
|
31
|
-
const ContentAbsoluteFolder = zod.z.object({
|
|
32
|
-
type: zod.z.literal("absolute-folder"),
|
|
33
|
-
folder: zod.z.string().regex(absPathRegex, "path to folder must be absolute").describe("Absolute address of the folder in local file system")
|
|
34
|
-
}).strict();
|
|
35
|
-
const ContentAny = zod.z.discriminatedUnion("type", [
|
|
36
|
-
ContentExplicitString,
|
|
37
|
-
ContentExplicitBase64,
|
|
38
|
-
ContentRelative,
|
|
39
|
-
ContentAbsoluteFile,
|
|
40
|
-
ContentAbsoluteUrl
|
|
41
|
-
]);
|
|
42
|
-
const ContentExplicitOrRelative = zod.z.discriminatedUnion("type", [
|
|
43
|
-
ContentExplicitString,
|
|
44
|
-
ContentExplicitBase64,
|
|
45
|
-
ContentRelative
|
|
46
|
-
]);
|
|
47
|
-
const ContentAnyLocal = zod.z.discriminatedUnion("type", [
|
|
48
|
-
ContentExplicitString,
|
|
49
|
-
ContentExplicitBase64,
|
|
50
|
-
ContentRelative,
|
|
51
|
-
ContentAbsoluteFile
|
|
52
|
-
]);
|
|
53
|
-
const ContentAnyRemote = zod.z.discriminatedUnion("type", [
|
|
54
|
-
ContentExplicitString,
|
|
55
|
-
ContentExplicitBase64,
|
|
56
|
-
ContentRelative,
|
|
57
|
-
ContentAbsoluteUrl
|
|
58
|
-
]);
|
|
59
|
-
const ContentAnyBinaryLocal = zod.z.discriminatedUnion("type", [
|
|
60
|
-
ContentExplicitBase64,
|
|
61
|
-
ContentRelative,
|
|
62
|
-
ContentAbsoluteFile
|
|
63
|
-
]);
|
|
64
|
-
const ContentAnyTextLocal = zod.z.discriminatedUnion("type", [
|
|
65
|
-
ContentExplicitString,
|
|
66
|
-
ContentRelative,
|
|
67
|
-
ContentAbsoluteFile
|
|
68
|
-
]);
|
|
69
|
-
const ContentAbsoluteBinaryRemote = zod.z.discriminatedUnion("type", [ContentExplicitBase64, ContentAbsoluteUrl]);
|
|
70
|
-
const ContentAbsoluteBinaryLocal = zod.z.discriminatedUnion("type", [ContentExplicitBase64, ContentAbsoluteFile]);
|
|
71
|
-
const ContentAbsoluteTextRemote = zod.z.discriminatedUnion("type", [ContentExplicitString, ContentAbsoluteUrl]);
|
|
72
|
-
const ContentAbsoluteTextLocal = zod.z.discriminatedUnion("type", [ContentExplicitString, ContentAbsoluteFile]);
|
|
73
27
|
const ContentRelativeBinary = zod.z.discriminatedUnion("type", [ContentExplicitBase64, ContentRelative]);
|
|
74
|
-
const ContentRelativeText = zod.z.discriminatedUnion("type", [
|
|
28
|
+
const ContentRelativeText = zod.z.discriminatedUnion("type", [contentExplicitStringSchema, ContentRelative]);
|
|
75
29
|
const DescriptionContentBinary = zod.z.union([zod.z.string().startsWith("file:").transform((value) => ({
|
|
76
30
|
type: "relative",
|
|
77
31
|
path: value.slice(5)
|
|
78
|
-
})),
|
|
32
|
+
})), zod.z.discriminatedUnion("type", [
|
|
33
|
+
ContentExplicitBase64,
|
|
34
|
+
ContentRelative,
|
|
35
|
+
contentAbsoluteFileSchema
|
|
36
|
+
])]);
|
|
79
37
|
const DescriptionContentText = zod.z.union([zod.z.string().transform((value) => {
|
|
80
38
|
if (value.startsWith("file:")) return {
|
|
81
39
|
type: "relative",
|
|
82
40
|
path: value.slice(5)
|
|
83
41
|
};
|
|
84
|
-
|
|
42
|
+
return {
|
|
85
43
|
type: "explicit-string",
|
|
86
44
|
content: value
|
|
87
45
|
};
|
|
88
|
-
}),
|
|
46
|
+
}), zod.z.discriminatedUnion("type", [
|
|
47
|
+
contentExplicitStringSchema,
|
|
48
|
+
ContentRelative,
|
|
49
|
+
contentAbsoluteFileSchema
|
|
50
|
+
])]);
|
|
89
51
|
//#endregion
|
|
90
|
-
exports.ContentAbsoluteBinaryLocal = ContentAbsoluteBinaryLocal;
|
|
91
|
-
exports.ContentAbsoluteBinaryRemote = ContentAbsoluteBinaryRemote;
|
|
92
|
-
exports.ContentAbsoluteFile = ContentAbsoluteFile;
|
|
93
|
-
exports.ContentAbsoluteFolder = ContentAbsoluteFolder;
|
|
94
|
-
exports.ContentAbsoluteTextLocal = ContentAbsoluteTextLocal;
|
|
95
|
-
exports.ContentAbsoluteTextRemote = ContentAbsoluteTextRemote;
|
|
96
|
-
exports.ContentAbsoluteUrl = ContentAbsoluteUrl;
|
|
97
|
-
exports.ContentAny = ContentAny;
|
|
98
|
-
exports.ContentAnyBinaryLocal = ContentAnyBinaryLocal;
|
|
99
|
-
exports.ContentAnyLocal = ContentAnyLocal;
|
|
100
|
-
exports.ContentAnyRemote = ContentAnyRemote;
|
|
101
|
-
exports.ContentAnyTextLocal = ContentAnyTextLocal;
|
|
102
52
|
exports.ContentExplicitBase64 = ContentExplicitBase64;
|
|
103
53
|
exports.ContentExplicitBytes = ContentExplicitBytes;
|
|
104
|
-
exports.ContentExplicitOrRelative = ContentExplicitOrRelative;
|
|
105
|
-
exports.ContentExplicitString = ContentExplicitString;
|
|
106
54
|
exports.ContentRelative = ContentRelative;
|
|
107
55
|
exports.ContentRelativeBinary = ContentRelativeBinary;
|
|
108
56
|
exports.ContentRelativeText = ContentRelativeText;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content_types.cjs","names":["z"],"sources":["../../src/block_meta/content_types.ts"],"sourcesContent":["import { z } from \"zod\";\n\n//\n// Base content types\n//\n\nexport const ContentExplicitString = z\n .object({\n type: z.literal(\"explicit-string\"),\n content: z.string().describe(\"Actual string value\"),\n })\n .strict();\nexport type ContentExplicitString = z.infer<typeof ContentExplicitString>;\n\nexport const ContentExplicitBase64 = z\n .object({\n type: z.literal(\"explicit-base64\"),\n mimeType: z\n .string()\n .regex(/\\w+\\/[-+.\\w]+/)\n .describe(\"MIME type to interpret content\"),\n content: z.string().base64().describe(\"Base64 encoded binary value\"),\n })\n .strict();\nexport type ContentExplicitBase64 = z.infer<typeof ContentExplicitBase64>;\n\nexport const ContentRelative = z\n .object({\n type: z.literal(\"relative\"),\n path: z\n .string()\n .describe(\n \"Address of the file, in most cases relative to the file which this structure is a part of\",\n ),\n })\n .strict();\nexport type ContentRelative = z.infer<typeof ContentRelative>;\n\nconst absPathRegex = new RegExp(`^(/|[A-Z]:\\\\\\\\)`);\n\nexport const ContentAbsoluteFile = z\n .object({\n type: z.literal(\"absolute-file\"),\n file: z\n .string()\n .regex(absPathRegex, \"path to file must be absolute\")\n .describe(\"Absolute address of the file in local file system\"),\n })\n .strict();\nexport type ContentAbsoluteFile = z.infer<typeof ContentAbsoluteFile>;\n\nexport const ContentAbsoluteUrl = z\n .object({\n type: z.literal(\"absolute-url\"),\n url: z.string().url().describe(\"Global URL to reach the requested file\"),\n })\n .strict();\nexport type ContentAbsoluteUrl = z.infer<typeof ContentAbsoluteUrl>;\n\n//\n// Special content types\n//\n\nexport const ContentExplicitBytes = z\n .object({\n type: z.literal(\"explicit-bytes\"),\n mimeType: z\n .string()\n .regex(/\\w+\\/[-+.\\w]+/)\n .describe(\"MIME type to interpret content\"),\n content: z.instanceof(Uint8Array).describe(\"Raw content\"),\n })\n .strict();\nexport type ContentExplicitBytes = z.infer<typeof ContentExplicitBytes>;\n\nexport const ContentAbsoluteFolder = z\n .object({\n type: z.literal(\"absolute-folder\"),\n folder: z\n .string()\n .regex(absPathRegex, \"path to folder must be absolute\")\n .describe(\"Absolute address of the folder in local file system\"),\n })\n .strict();\nexport type ContentAbsoluteFolder = z.infer<typeof ContentAbsoluteFolder>;\n\n//\n// Unions\n//\n\nexport const ContentAny = z.discriminatedUnion(\"type\", [\n ContentExplicitString,\n ContentExplicitBase64,\n ContentRelative,\n ContentAbsoluteFile,\n ContentAbsoluteUrl,\n]);\nexport type ContentAny = z.infer<typeof ContentAny>;\n\nexport const ContentExplicitOrRelative = z.discriminatedUnion(\"type\", [\n ContentExplicitString,\n ContentExplicitBase64,\n ContentRelative,\n]);\nexport type ContentExplicitOrRelative = z.infer<typeof ContentExplicitOrRelative>;\n\nexport const ContentAnyLocal = z.discriminatedUnion(\"type\", [\n ContentExplicitString,\n ContentExplicitBase64,\n ContentRelative,\n ContentAbsoluteFile,\n]);\nexport type ContentAnyLocal = z.infer<typeof ContentAnyLocal>;\n\nexport const ContentAnyRemote = z.discriminatedUnion(\"type\", [\n ContentExplicitString,\n ContentExplicitBase64,\n ContentRelative,\n ContentAbsoluteUrl,\n]);\nexport type ContentAnyRemote = z.infer<typeof ContentAnyRemote>;\n\n//\n// Narrow types with relative option\n//\n\n// export const ContentAnyBinaryRemote = z.discriminatedUnion('type', [\n// ContentExplicitBase64,\n// ContentRelative,\n// ContentAbsoluteUrl\n// ]);\n// export type ContentAnyBinaryRemote = z.infer<typeof ContentAnyBinaryRemote>;\n\nexport const ContentAnyBinaryLocal = z.discriminatedUnion(\"type\", [\n ContentExplicitBase64,\n ContentRelative,\n ContentAbsoluteFile,\n]);\nexport type ContentAnyBinaryLocal = z.infer<typeof ContentAnyBinaryLocal>;\n\n// export const ContentAnyTextRemote = z.discriminatedUnion('type', [\n// ContentExplicitString,\n// ContentRelative,\n// ContentAbsoluteUrl\n// ]);\n// export type ContentAnyTextRemote = z.infer<typeof ContentAnyTextRemote>;\n\nexport const ContentAnyTextLocal = z.discriminatedUnion(\"type\", [\n ContentExplicitString,\n ContentRelative,\n ContentAbsoluteFile,\n]);\nexport type ContentAnyTextLocal = z.infer<typeof ContentAnyTextLocal>;\n\n//\n// Narrow absolute types\n//\n\nexport const ContentAbsoluteBinaryRemote = z.discriminatedUnion(\"type\", [\n ContentExplicitBase64,\n ContentAbsoluteUrl,\n]);\nexport type ContentAbsoluteBinaryRemote = z.infer<typeof ContentAbsoluteBinaryRemote>;\n\nexport const ContentAbsoluteBinaryLocal = z.discriminatedUnion(\"type\", [\n ContentExplicitBase64,\n ContentAbsoluteFile,\n]);\nexport type ContentAbsoluteBinaryLocal = z.infer<typeof ContentAbsoluteBinaryLocal>;\n\nexport const ContentAbsoluteTextRemote = z.discriminatedUnion(\"type\", [\n ContentExplicitString,\n ContentAbsoluteUrl,\n]);\nexport type ContentAbsoluteTextRemote = z.infer<typeof ContentAbsoluteTextRemote>;\n\nexport const ContentAbsoluteTextLocal = z.discriminatedUnion(\"type\", [\n ContentExplicitString,\n ContentAbsoluteFile,\n]);\nexport type ContentAbsoluteTextLocal = z.infer<typeof ContentAbsoluteTextLocal>;\n\n//\n// Narrow relative types\n//\n\nexport const ContentRelativeBinary = z.discriminatedUnion(\"type\", [\n ContentExplicitBase64,\n ContentRelative,\n]);\nexport type ContentRelativeBinary = z.infer<typeof ContentRelativeBinary>;\n\nexport const ContentRelativeText = z.discriminatedUnion(\"type\", [\n ContentExplicitString,\n ContentRelative,\n]);\nexport type ContentRelativeText = z.infer<typeof ContentRelativeText>;\n\n// export function ConstructContent(\n// contentType: 'text',\n// contextType: 'local'\n// ): typeof ContentAnyTextLocal;\n// export function ConstructContent(\n// contentType: 'text',\n// contextType: 'remote'\n// ): typeof ContentAnyTextRemote;\n// export function ConstructContent(\n// contentType: 'binary',\n// contextType: 'local'\n// ): typeof ContentAnyBinaryLocal;\n// export function ConstructContent(\n// contentType: 'binary',\n// contextType: 'remote'\n// ): typeof ContentAnyBinaryRemote;\n// export function ConstructContent(\n// contentType: ContentType,\n// contextType: ContextType\n// ):\n// | typeof ContentAnyTextLocal\n// | typeof ContentAnyTextRemote\n// | typeof ContentAnyBinaryLocal\n// | typeof ContentAnyBinaryRemote;\n// export function ConstructContent(contentType: ContentType, contextType: ContextType) {\n// return contentType === 'text'\n// ? contextType === 'local'\n// ? ContentAnyTextLocal\n// : ContentAnyTextRemote\n// : contextType === 'local'\n// ? ContentAnyBinaryLocal\n// : ContentAnyBinaryRemote;\n// }\n\nexport const DescriptionContentBinary = z.union([\n z\n .string()\n .startsWith(\"file:\")\n .transform<ContentRelativeBinary>((value) => ({ type: \"relative\", path: value.slice(5) })),\n ContentAnyBinaryLocal,\n]);\nexport type DescriptionContentBinary = z.infer<typeof DescriptionContentBinary>;\n\nexport const DescriptionContentText = z.union([\n z.string().transform<ContentRelativeText>((value) => {\n if (value.startsWith(\"file:\")) return { type: \"relative\", path: value.slice(5) };\n else return { type: \"explicit-string\", content: value };\n }),\n ContentAnyTextLocal,\n]);\nexport type DescriptionContentText = z.infer<typeof DescriptionContentText>;\n"],"mappings":";;;AAMA,MAAa,wBAAwBA,IAAAA,EAClC,OAAO;CACN,MAAMA,IAAAA,EAAE,QAAQ,kBAAkB;CAClC,SAASA,IAAAA,EAAE,QAAQ,CAAC,SAAS,sBAAsB;CACpD,CAAC,CACD,QAAQ;AAGX,MAAa,wBAAwBA,IAAAA,EAClC,OAAO;CACN,MAAMA,IAAAA,EAAE,QAAQ,kBAAkB;CAClC,UAAUA,IAAAA,EACP,QAAQ,CACR,MAAM,gBAAgB,CACtB,SAAS,iCAAiC;CAC7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../../src/block_meta/content_types.ts"],"sourcesContent":["import { z } from \"zod\";\n\n//\n// Canonical content types. TypeScript is the source of truth. The zod\n// schemas below are boundary validators pegged to these types via\n// `satisfies`; they exist only to parse external data (`package.json`,\n// registry manifests, registry overview files).\n//\n\n/** Inlined plain string (e.g. a short text snippet or markdown body). */\nexport type ContentExplicitString = {\n type: \"explicit-string\";\n content: string;\n};\n\n/** Inlined binary blob carried as base64 (e.g. a serialized logo image). */\nexport type ContentExplicitBase64 = {\n type: \"explicit-base64\";\n /** MIME type used to interpret `content`. */\n mimeType: string;\n /** Base64-encoded binary payload. */\n content: string;\n};\n\n/** Inlined binary blob carried as raw bytes. Wire form only; not used in JSON. */\nexport type ContentExplicitBytes = {\n type: \"explicit-bytes\";\n /** MIME type used to interpret `content`. */\n mimeType: string;\n content: Uint8Array;\n};\n\n/** Reference to a file by path relative to the carrying structure. */\nexport type ContentRelative = {\n type: \"relative\";\n path: string;\n};\n\n/** Reference to a file at an absolute local path. */\nexport type ContentAbsoluteFile = {\n type: \"absolute-file\";\n file: string;\n};\n\n/**\n * Reference to a folder at an absolute local path. Used for UI bundles\n * delivered as folders; the desktop \"add block\" dialog reads such folders on\n * demand instead of pulling every UI bundle eagerly.\n */\nexport type ContentAbsoluteFolder = {\n type: \"absolute-folder\";\n folder: string;\n};\n\n/** Reference to a file by remote URL (e.g. served from the registry). */\nexport type ContentAbsoluteUrl = {\n type: \"absolute-url\";\n url: string;\n};\n\n/** Canonical union of every content carrier shape used across the platform. */\nexport type Content =\n | ContentExplicitString\n | ContentExplicitBase64\n | ContentExplicitBytes\n | ContentRelative\n | ContentAbsoluteFile\n | ContentAbsoluteFolder\n | ContentAbsoluteUrl;\n\n//\n// Slot-specific content unions. Each names a set of carriers allowed in a\n// particular stage of the pipeline (boundary input, manifest, resolved).\n//\n\n/** Inlined or relative-path content (text/binary inlined, or relative path). */\nexport type ContentExplicitOrRelative =\n | ContentExplicitString\n | ContentExplicitBase64\n | ContentRelative;\n\n/** Any locally-resolvable content (inlined, relative path, or absolute file). */\nexport type ContentAnyLocal =\n | ContentExplicitString\n | ContentExplicitBase64\n | ContentRelative\n | ContentAbsoluteFile;\n\n/** Text content available locally (inlined, relative path, or absolute file). */\nexport type ContentAnyTextLocal = ContentExplicitString | ContentRelative | ContentAbsoluteFile;\n\n/** Binary content available locally (inlined base64, relative path, or absolute file). */\nexport type ContentAnyBinaryLocal = ContentExplicitBase64 | ContentRelative | ContentAbsoluteFile;\n\n/** Binary content fully resolved (inlined base64 or absolute file). */\nexport type ContentAbsoluteBinaryLocal = ContentExplicitBase64 | ContentAbsoluteFile;\n\n/** Text content fully resolved (inlined string or absolute file). */\nexport type ContentAbsoluteTextLocal = ContentExplicitString | ContentAbsoluteFile;\n\n/** Binary content in manifest form (inlined base64 or path relative to the manifest). */\nexport type ContentRelativeBinary = ContentExplicitBase64 | ContentRelative;\n\n/** Text content in manifest form (inlined string or path relative to the manifest). */\nexport type ContentRelativeText = ContentExplicitString | ContentRelative;\n\n//\n// Zod schemas — boundary validators only. The TS types above are the source\n// of truth; each schema is pegged via `satisfies z.ZodType<T>`. Only the\n// schemas referenced by sibling boundary files (`block_meta.ts`,\n// `block_manifest.ts`) are exported.\n//\n\nconst absPathRegex = new RegExp(`^(/|[A-Z]:\\\\\\\\)`);\n\nconst contentExplicitStringSchema = z\n .object({\n type: z.literal(\"explicit-string\"),\n content: z.string(),\n })\n .strict() satisfies z.ZodType<ContentExplicitString>;\n\nexport const ContentExplicitBase64 = z\n .object({\n type: z.literal(\"explicit-base64\"),\n mimeType: z.string().regex(/\\w+\\/[-+.\\w]+/),\n content: z.string().base64(),\n })\n .strict() satisfies z.ZodType<ContentExplicitBase64>;\n\nexport const ContentExplicitBytes = z\n .object({\n type: z.literal(\"explicit-bytes\"),\n mimeType: z.string().regex(/\\w+\\/[-+.\\w]+/),\n content: z.instanceof(Uint8Array),\n })\n .strict() satisfies z.ZodType<ContentExplicitBytes>;\n\nexport const ContentRelative = z\n .object({\n type: z.literal(\"relative\"),\n path: z.string(),\n })\n .strict() satisfies z.ZodType<ContentRelative>;\n\nconst contentAbsoluteFileSchema = z\n .object({\n type: z.literal(\"absolute-file\"),\n file: z.string().regex(absPathRegex, \"path to file must be absolute\"),\n })\n .strict() satisfies z.ZodType<ContentAbsoluteFile>;\n\nexport const ContentRelativeBinary = z.discriminatedUnion(\"type\", [\n ContentExplicitBase64,\n ContentRelative,\n]) satisfies z.ZodType<ContentRelativeBinary>;\n\nexport const ContentRelativeText = z.discriminatedUnion(\"type\", [\n contentExplicitStringSchema,\n ContentRelative,\n]) satisfies z.ZodType<ContentRelativeText>;\n\n//\n// Boundary normalizing transforms — parse the loose forms authors write in\n// `package.json`. Bare strings with the `file:` prefix become a\n// `ContentRelative`; bare strings without the prefix become a\n// `ContentExplicitString` (text only).\n//\n\nexport const DescriptionContentBinary = z.union([\n z\n .string()\n .startsWith(\"file:\")\n .transform<ContentRelativeBinary>((value) => ({\n type: \"relative\",\n path: value.slice(5),\n })),\n z.discriminatedUnion(\"type\", [ContentExplicitBase64, ContentRelative, contentAbsoluteFileSchema]),\n]) satisfies z.ZodType<ContentAnyBinaryLocal, z.ZodTypeDef, any>;\n\nexport const DescriptionContentText = z.union([\n z.string().transform<ContentRelativeText>((value) => {\n if (value.startsWith(\"file:\")) return { type: \"relative\", path: value.slice(5) };\n return { type: \"explicit-string\", content: value };\n }),\n z.discriminatedUnion(\"type\", [\n contentExplicitStringSchema,\n ContentRelative,\n contentAbsoluteFileSchema,\n ]),\n]) satisfies z.ZodType<ContentAnyTextLocal, z.ZodTypeDef, any>;\n"],"mappings":";;;AAiHA,MAAM,eAAe,IAAI,OAAO,kBAAkB;AAElD,MAAM,8BAA8BA,IAAAA,EACjC,OAAO;CACN,MAAMA,IAAAA,EAAE,QAAQ,kBAAkB;CAClC,SAASA,IAAAA,EAAE,QAAQ;CACpB,CAAC,CACD,QAAQ;AAEX,MAAa,wBAAwBA,IAAAA,EAClC,OAAO;CACN,MAAMA,IAAAA,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