@milaboratories/pl-model-middle-layer 1.2.20 → 1.3.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.d.ts +213 -77
- package/dist/block_meta/block_components.d.ts.map +1 -1
- package/dist/block_meta/block_description.d.ts +872 -0
- package/dist/block_meta/block_description.d.ts.map +1 -0
- package/dist/block_meta/{block_pack_id.d.ts → block_id.d.ts} +1 -1
- package/dist/block_meta/block_id.d.ts.map +1 -0
- package/dist/block_meta/block_manifest.d.ts +1245 -0
- package/dist/block_meta/block_manifest.d.ts.map +1 -0
- package/dist/block_meta/{meta.d.ts → block_meta.d.ts} +1 -167
- package/dist/block_meta/block_meta.d.ts.map +1 -0
- package/dist/block_meta/content_conversion.d.ts +9 -1
- package/dist/block_meta/content_conversion.d.ts.map +1 -1
- package/dist/block_meta/content_types.d.ts +40 -5
- package/dist/block_meta/content_types.d.ts.map +1 -1
- package/dist/block_meta/index.d.ts +6 -1665
- package/dist/block_meta/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +114 -104
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/block_meta/block_components.ts +2 -5
- package/src/block_meta/block_description.ts +29 -0
- package/src/block_meta/block_manifest.ts +38 -0
- package/src/block_meta/{meta.ts → block_meta.ts} +0 -13
- package/src/block_meta/content_conversion.ts +24 -4
- package/src/block_meta/content_types.ts +14 -3
- package/src/block_meta/index.ts +6 -52
- package/dist/block_meta/block_pack_id.d.ts.map +0 -1
- package/dist/block_meta/meta.d.ts.map +0 -1
- /package/src/block_meta/{block_pack_id.ts → block_id.ts} +0 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { BlockComponents } from './block_components';
|
|
3
|
+
import { ContentRelative, ContentRelativeBinary, ContentRelativeText } from './content_types';
|
|
4
|
+
import { CreateBlockPackDescriptionSchema } from './block_description';
|
|
5
|
+
import { BlockPackMeta } from './block_meta';
|
|
6
|
+
|
|
7
|
+
export const BlockComponentsManifest = BlockComponents(ContentRelative, ContentRelative);
|
|
8
|
+
export type BlockComponentsManifest = z.infer<typeof BlockComponentsManifest>;
|
|
9
|
+
|
|
10
|
+
export const BlockPackMetaManifest = BlockPackMeta(ContentRelativeText, ContentRelativeBinary);
|
|
11
|
+
export type BlockPackMetaManifest = z.infer<typeof BlockPackMetaManifest>;
|
|
12
|
+
|
|
13
|
+
/** Block description to be used in block manifest */
|
|
14
|
+
export const BlockPackDescriptionManifest = CreateBlockPackDescriptionSchema(
|
|
15
|
+
BlockComponentsManifest,
|
|
16
|
+
BlockPackMetaManifest
|
|
17
|
+
);
|
|
18
|
+
export type BlockPackDescriptionManifest = z.infer<typeof BlockPackDescriptionManifest>;
|
|
19
|
+
|
|
20
|
+
export const ManifestFileInfo = z.object({
|
|
21
|
+
name: z.string(),
|
|
22
|
+
size: z.number().int(),
|
|
23
|
+
sha256: z
|
|
24
|
+
.string()
|
|
25
|
+
.regex(/[0-9a-fA-F]/)
|
|
26
|
+
.toUpperCase()
|
|
27
|
+
.length(64) // 256 / 4 (bits per hex register)
|
|
28
|
+
});
|
|
29
|
+
export type ManifestFileInfo = z.infer<typeof ManifestFileInfo>;
|
|
30
|
+
|
|
31
|
+
export const BlockPackManifest = z.object({
|
|
32
|
+
schema: z.literal('v2'),
|
|
33
|
+
description: BlockPackDescriptionManifest,
|
|
34
|
+
files: z.array(ManifestFileInfo)
|
|
35
|
+
});
|
|
36
|
+
export type BlockPackManifest = z.infer<typeof BlockPackManifest>;
|
|
37
|
+
|
|
38
|
+
export const BlockPackManifestFile = 'manifest.json';
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import {
|
|
3
|
-
ContentAbsoluteBinaryLocal,
|
|
4
|
-
ContentAbsoluteTextLocal,
|
|
5
3
|
ContentExplicitBase64,
|
|
6
|
-
ContentExplicitString,
|
|
7
|
-
ContentRelative,
|
|
8
|
-
ContentRelativeBinary,
|
|
9
|
-
ContentRelativeText,
|
|
10
4
|
DescriptionContentBinary,
|
|
11
5
|
DescriptionContentText
|
|
12
6
|
} from './content_types';
|
|
@@ -39,13 +33,6 @@ export const BlockPackMetaDescriptionRaw = BlockPackMeta(
|
|
|
39
33
|
);
|
|
40
34
|
export type BlockPackMetaDescriptionRaw = z.infer<typeof BlockPackMetaDescriptionRaw>;
|
|
41
35
|
|
|
42
|
-
// prettier-ignore
|
|
43
|
-
export const BlockPackMetaManifest = BlockPackMeta(
|
|
44
|
-
ContentRelativeText,
|
|
45
|
-
ContentRelativeBinary
|
|
46
|
-
);
|
|
47
|
-
export type BlockPackMetaManifest = z.infer<typeof BlockPackMetaManifest>;
|
|
48
|
-
|
|
49
36
|
// prettier-ignore
|
|
50
37
|
export const BlockPackMetaEmbeddedContent = BlockPackMeta(
|
|
51
38
|
z.string(),
|
|
@@ -1,13 +1,33 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
ContentAbsoluteUrl,
|
|
3
|
+
ContentAnyLocal,
|
|
4
|
+
ContentExplicitOrRelative,
|
|
5
|
+
ContentRelative
|
|
6
|
+
} from './content_types';
|
|
2
7
|
|
|
3
8
|
export function mapRemoteToAbsolute(
|
|
4
9
|
rootUrl: string
|
|
5
|
-
): <T extends ContentAnyLocal>(
|
|
6
|
-
value: T
|
|
7
|
-
) => Exclude<T, ContentRelative> | ContentAbsoluteUrl {
|
|
10
|
+
): <T extends ContentAnyLocal>(value: T) => Exclude<T, ContentRelative> | ContentAbsoluteUrl {
|
|
8
11
|
const rootWithSlash = rootUrl.endsWith('/') ? rootUrl : `${rootUrl}/`;
|
|
9
12
|
return <T extends ContentAnyLocal>(value: T) =>
|
|
10
13
|
value.type === 'relative'
|
|
11
14
|
? { type: 'absolute-url', url: rootWithSlash + value.path }
|
|
12
15
|
: (value as Exclude<T, ContentRelative>);
|
|
13
16
|
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Creates transformer of relative content paths, that adds a specific prefix to the relative path.
|
|
20
|
+
*
|
|
21
|
+
* If prefix = "nested-path/", paths like "somefile.txt" will be transformed to "nested-path/somefile.txt".
|
|
22
|
+
*
|
|
23
|
+
* @param prefix prefix to add to the relaive path, slesh at the end will be added automatically if missed
|
|
24
|
+
*/
|
|
25
|
+
export function addPrefixToRelative(
|
|
26
|
+
prefix: string
|
|
27
|
+
): <T extends ContentExplicitOrRelative>(value: T) => T {
|
|
28
|
+
const prefixWithSlash = prefix.endsWith('/') ? prefix : `${prefix}/`;
|
|
29
|
+
return <T extends ContentExplicitOrRelative>(value: T) =>
|
|
30
|
+
(value.type === 'relative'
|
|
31
|
+
? { type: 'relative', path: prefixWithSlash + value.path }
|
|
32
|
+
: value) as T;
|
|
33
|
+
}
|
|
@@ -56,13 +56,17 @@ export type ContentAbsoluteUrl = z.infer<typeof ContentAbsoluteUrl>;
|
|
|
56
56
|
// Special content types
|
|
57
57
|
//
|
|
58
58
|
|
|
59
|
-
export const
|
|
59
|
+
export const ContentExplicitBytes = z
|
|
60
60
|
.object({
|
|
61
|
-
type: z.literal('explicit'),
|
|
61
|
+
type: z.literal('explicit-bytes'),
|
|
62
|
+
mimeType: z
|
|
63
|
+
.string()
|
|
64
|
+
.regex(/\w+\/[-+.\w]+/)
|
|
65
|
+
.describe('MIME type to interpret content'),
|
|
62
66
|
content: z.instanceof(Uint8Array).describe('Raw content')
|
|
63
67
|
})
|
|
64
68
|
.strict();
|
|
65
|
-
export type
|
|
69
|
+
export type ContentExplicitBytes = z.infer<typeof ContentExplicitBytes>;
|
|
66
70
|
|
|
67
71
|
export const ContentAbsoluteFolder = z
|
|
68
72
|
.object({
|
|
@@ -88,6 +92,13 @@ export const ContentAny = z.discriminatedUnion('type', [
|
|
|
88
92
|
]);
|
|
89
93
|
export type ContentAny = z.infer<typeof ContentAny>;
|
|
90
94
|
|
|
95
|
+
export const ContentExplicitOrRelative = z.discriminatedUnion('type', [
|
|
96
|
+
ContentExplicitString,
|
|
97
|
+
ContentExplicitBase64,
|
|
98
|
+
ContentRelative
|
|
99
|
+
]);
|
|
100
|
+
export type ContentExplicitOrRelative = z.infer<typeof ContentExplicitOrRelative>;
|
|
101
|
+
|
|
91
102
|
export const ContentAnyLocal = z.discriminatedUnion('type', [
|
|
92
103
|
ContentExplicitString,
|
|
93
104
|
ContentExplicitBase64,
|
package/src/block_meta/index.ts
CHANGED
|
@@ -1,57 +1,11 @@
|
|
|
1
|
-
import { ZodTypeAny, string, z } from 'zod';
|
|
2
|
-
import { BlockComponentsDescriptionRaw, BlockComponentsManifest } from './block_components';
|
|
3
|
-
import { BlockPackId } from './block_pack_id';
|
|
4
|
-
import { BlockPackMetaDescriptionRaw, BlockPackMetaManifest } from './meta';
|
|
5
|
-
|
|
6
|
-
export * from './block_components';
|
|
7
|
-
export * from './block_pack_id';
|
|
8
1
|
export * from './common';
|
|
9
2
|
export * from './content_types';
|
|
10
|
-
export * from './meta';
|
|
11
3
|
export * from './semver';
|
|
12
4
|
|
|
13
|
-
export
|
|
14
|
-
components: BlockComponentsDescriptionRaw,
|
|
15
|
-
meta: BlockPackMetaDescriptionRaw
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
export function CreateBlockPackDescriptionSchema<
|
|
19
|
-
Components extends ZodTypeAny,
|
|
20
|
-
Meta extends ZodTypeAny
|
|
21
|
-
>(components: Components, meta: Meta) {
|
|
22
|
-
return z.object({
|
|
23
|
-
id: BlockPackId,
|
|
24
|
-
components,
|
|
25
|
-
meta
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export const BlockPackDescriptionManifest = CreateBlockPackDescriptionSchema(
|
|
30
|
-
BlockComponentsManifest,
|
|
31
|
-
BlockPackMetaManifest
|
|
32
|
-
);
|
|
33
|
-
export type BlockPackDescriptionManifest = z.infer<typeof BlockPackDescriptionManifest>;
|
|
5
|
+
export * from './content_conversion';
|
|
34
6
|
|
|
35
|
-
export
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
export
|
|
40
|
-
|
|
41
|
-
export const ManifestFileInfo = z.object({
|
|
42
|
-
name: z.string(),
|
|
43
|
-
size: z.number().int(),
|
|
44
|
-
sha256: z
|
|
45
|
-
.string()
|
|
46
|
-
.regex(/[0-9a-fA-F]/)
|
|
47
|
-
.toUpperCase()
|
|
48
|
-
.length(64) // 256 / 4 (bits per hex register)
|
|
49
|
-
});
|
|
50
|
-
export type ManifestFileInfo = z.infer<typeof ManifestFileInfo>;
|
|
51
|
-
|
|
52
|
-
export const BlockPackManifest = z.object({
|
|
53
|
-
schema: z.literal('v1'),
|
|
54
|
-
description: BlockPackDescriptionManifest,
|
|
55
|
-
files: z.array(ManifestFileInfo)
|
|
56
|
-
});
|
|
57
|
-
export type BlockPackManifest = z.infer<typeof BlockPackManifest>;
|
|
7
|
+
export * from './block_id';
|
|
8
|
+
export * from './block_components';
|
|
9
|
+
export * from './block_meta';
|
|
10
|
+
export * from './block_description';
|
|
11
|
+
export * from './block_manifest';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"block_pack_id.d.ts","sourceRoot":"","sources":["../../src/block_meta/block_pack_id.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,qCAAqC;AACrC,eAAO,MAAM,WAAW;;;;;;;;;;;;EAMb,CAAC;AACZ,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAEtD,eAAO,MAAM,oBAAoB;;;;;;;;;;EAAsC,CAAC;AACxE,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../src/block_meta/meta.ts"],"names":[],"mappings":"AAAA,O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