@milaboratories/pl-model-middle-layer 1.8.41 → 1.8.43
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 +4 -4
- package/dist/block_meta/block_components.cjs.map +1 -1
- package/dist/block_meta/block_components.d.ts +0 -1
- package/dist/block_meta/block_components.d.ts.map +1 -1
- package/dist/block_meta/block_components.js +4 -4
- package/dist/block_meta/block_components.js.map +1 -1
- package/dist/block_meta/block_description.cjs +2 -2
- package/dist/block_meta/block_description.cjs.map +1 -1
- package/dist/block_meta/block_description.d.ts +116 -115
- package/dist/block_meta/block_description.d.ts.map +1 -1
- package/dist/block_meta/block_description.js +2 -2
- package/dist/block_meta/block_description.js.map +1 -1
- package/dist/block_meta/block_id.cjs +1 -1
- package/dist/block_meta/block_id.cjs.map +1 -1
- package/dist/block_meta/block_id.js +1 -1
- package/dist/block_meta/block_id.js.map +1 -1
- package/dist/block_meta/block_manifest.cjs +2 -2
- package/dist/block_meta/block_manifest.cjs.map +1 -1
- package/dist/block_meta/block_manifest.d.ts +1 -1
- package/dist/block_meta/block_manifest.d.ts.map +1 -1
- package/dist/block_meta/block_manifest.js +2 -2
- package/dist/block_meta/block_manifest.js.map +1 -1
- package/dist/block_meta/block_meta.cjs +3 -3
- package/dist/block_meta/block_meta.cjs.map +1 -1
- package/dist/block_meta/block_meta.js +3 -3
- package/dist/block_meta/block_meta.js.map +1 -1
- package/dist/block_meta/content_conversion.cjs.map +1 -1
- package/dist/block_meta/content_conversion.d.ts +1 -1
- package/dist/block_meta/content_conversion.d.ts.map +1 -1
- package/dist/block_meta/content_conversion.js.map +1 -1
- package/dist/block_meta/content_types.cjs +23 -23
- package/dist/block_meta/content_types.cjs.map +1 -1
- package/dist/block_meta/content_types.js +23 -23
- package/dist/block_meta/content_types.js.map +1 -1
- package/dist/block_meta/semver.cjs.map +1 -1
- package/dist/block_meta/semver.js.map +1 -1
- package/dist/block_registry/block_pack_spec.cjs +5 -5
- package/dist/block_registry/block_pack_spec.cjs.map +1 -1
- package/dist/block_registry/block_pack_spec.js +5 -5
- package/dist/block_registry/block_pack_spec.js.map +1 -1
- package/dist/block_registry/overview.cjs +6 -6
- package/dist/block_registry/overview.cjs.map +1 -1
- package/dist/block_registry/overview.d.ts.map +1 -1
- package/dist/block_registry/overview.js +6 -6
- package/dist/block_registry/overview.js.map +1 -1
- package/dist/block_registry/registry_spec.cjs +5 -5
- package/dist/block_registry/registry_spec.cjs.map +1 -1
- package/dist/block_registry/registry_spec.js +5 -5
- package/dist/block_registry/registry_spec.js.map +1 -1
- package/dist/block_state.d.ts +2 -2
- package/dist/block_state.d.ts.map +1 -1
- package/dist/pframe/internal_api/api_factory.cjs.map +1 -1
- package/dist/pframe/internal_api/api_factory.d.ts +2 -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 +9 -8
- package/dist/pframe/internal_api/api_read.d.ts.map +1 -1
- package/dist/pframe/internal_api/common.d.ts +3 -1
- package/dist/pframe/internal_api/common.d.ts.map +1 -1
- package/dist/pframe/internal_api/create_table.d.ts +2 -2
- package/dist/pframe/internal_api/create_table.d.ts.map +1 -1
- package/dist/pframe/internal_api/delete_column.d.ts +1 -1
- package/dist/pframe/internal_api/delete_column.d.ts.map +1 -1
- package/dist/pframe/internal_api/find_columns.d.ts +2 -2
- package/dist/pframe/internal_api/find_columns.d.ts.map +1 -1
- package/dist/pframe/internal_api/http_helpers.cjs.map +1 -1
- package/dist/pframe/internal_api/http_helpers.d.ts +27 -27
- package/dist/pframe/internal_api/http_helpers.d.ts.map +1 -1
- package/dist/pframe/internal_api/http_helpers.js.map +1 -1
- package/dist/pframe/internal_api/pframe.d.ts +8 -5
- package/dist/pframe/internal_api/pframe.d.ts.map +1 -1
- package/dist/pframe/internal_api/table.d.ts +5 -5
- package/dist/pframe/internal_api/table.d.ts.map +1 -1
- package/dist/project_list.d.ts +1 -1
- package/dist/project_list.d.ts.map +1 -1
- package/dist/project_overview.d.ts +5 -5
- package/dist/project_overview.d.ts.map +1 -1
- package/dist/update_info.d.ts +1 -1
- package/dist/update_info.d.ts.map +1 -1
- package/package.json +7 -4
- package/src/block_meta/block_components.ts +6 -8
- package/src/block_meta/block_description.ts +8 -7
- package/src/block_meta/block_id.ts +4 -4
- package/src/block_meta/block_manifest.ts +5 -5
- package/src/block_meta/block_meta.ts +8 -8
- package/src/block_meta/content_conversion.ts +4 -4
- package/src/block_meta/content_types.ts +24 -24
- package/src/block_meta/semver.ts +1 -1
- package/src/block_registry/block_pack_spec.ts +5 -5
- package/src/block_registry/overview.ts +10 -9
- package/src/block_registry/registry_spec.ts +5 -5
- package/src/block_state.ts +3 -3
- package/src/pframe/internal_api/api_factory.ts +3 -6
- package/src/pframe/internal_api/api_read.ts +11 -10
- package/src/pframe/internal_api/common.ts +11 -2
- package/src/pframe/internal_api/create_table.ts +3 -3
- package/src/pframe/internal_api/delete_column.ts +1 -1
- package/src/pframe/internal_api/find_columns.ts +2 -2
- package/src/pframe/internal_api/http_helpers.ts +44 -44
- package/src/pframe/internal_api/pframe.ts +9 -6
- package/src/pframe/internal_api/table.ts +10 -10
- package/src/project_list.ts +1 -1
- package/src/project_overview.ts +5 -5
- package/src/update_info.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@milaboratories/pl-model-middle-layer",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.43",
|
|
4
4
|
"description": "Common model between middle layer and non-block UI code",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -20,19 +20,22 @@
|
|
|
20
20
|
"remeda": "^2.28.0",
|
|
21
21
|
"zod": "~3.23.8",
|
|
22
22
|
"utility-types": "^3.11.0",
|
|
23
|
-
"@milaboratories/pl-model-common": "1.21.
|
|
23
|
+
"@milaboratories/pl-model-common": "1.21.8"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
+
"eslint": "^9.25.1",
|
|
26
27
|
"typescript": "~5.6.3",
|
|
27
28
|
"@types/node": "~24.5.2",
|
|
28
|
-
"@milaboratories/ts-builder": "1.0.5",
|
|
29
29
|
"@milaboratories/build-configs": "1.0.8",
|
|
30
|
-
"@milaboratories/ts-configs": "1.0.6"
|
|
30
|
+
"@milaboratories/ts-configs": "1.0.6",
|
|
31
|
+
"@milaboratories/ts-builder": "1.0.5",
|
|
32
|
+
"@platforma-sdk/eslint-config": "1.1.0"
|
|
31
33
|
},
|
|
32
34
|
"scripts": {
|
|
33
35
|
"type-check": "ts-builder types --target node",
|
|
34
36
|
"build": "ts-builder build --target node",
|
|
35
37
|
"watch": "ts-builder build --target node --watch",
|
|
38
|
+
"lint": "eslint .",
|
|
36
39
|
"do-pack": "rm -f *.tgz && pnpm pack && mv *.tgz package.tgz"
|
|
37
40
|
}
|
|
38
41
|
}
|
|
@@ -2,12 +2,10 @@ import { z } from 'zod';
|
|
|
2
2
|
import { ContentRelativeBinary } from './content_types';
|
|
3
3
|
import { mapRemoteToAbsolute } from './content_conversion';
|
|
4
4
|
|
|
5
|
-
export type BlockPackComponents = {};
|
|
6
|
-
|
|
7
5
|
export function WorkflowV1<const Content extends z.ZodTypeAny>(contentType: Content) {
|
|
8
6
|
return z.object({
|
|
9
7
|
type: z.literal('workflow-v1'),
|
|
10
|
-
main: contentType.describe('Main workflow')
|
|
8
|
+
main: contentType.describe('Main workflow'),
|
|
11
9
|
});
|
|
12
10
|
}
|
|
13
11
|
|
|
@@ -17,22 +15,22 @@ export function Workflow<const Content extends z.ZodTypeAny>(contentType: Conten
|
|
|
17
15
|
contentType
|
|
18
16
|
.transform((value: z.infer<typeof contentType>) => ({
|
|
19
17
|
type: 'workflow-v1' as const,
|
|
20
|
-
main: value
|
|
18
|
+
main: value,
|
|
21
19
|
}))
|
|
22
20
|
.pipe(WorkflowV1(contentType)),
|
|
23
21
|
// structured objects are decoded as union with type descriptor
|
|
24
|
-
z.discriminatedUnion('type', [WorkflowV1(contentType)])
|
|
22
|
+
z.discriminatedUnion('type', [WorkflowV1(contentType)]),
|
|
25
23
|
]);
|
|
26
24
|
}
|
|
27
25
|
|
|
28
26
|
export function BlockComponents<
|
|
29
27
|
const WfAndModel extends z.ZodTypeAny,
|
|
30
|
-
const UI extends z.ZodTypeAny
|
|
28
|
+
const UI extends z.ZodTypeAny,
|
|
31
29
|
>(wfAndModel: WfAndModel, ui: UI) {
|
|
32
30
|
return z.object({
|
|
33
31
|
workflow: Workflow(wfAndModel),
|
|
34
32
|
model: wfAndModel,
|
|
35
|
-
ui
|
|
33
|
+
ui,
|
|
36
34
|
});
|
|
37
35
|
}
|
|
38
36
|
|
|
@@ -42,7 +40,7 @@ export type BlockComponentsDescriptionRaw = z.infer<typeof BlockComponentsDescri
|
|
|
42
40
|
export function BlockComponentsAbsoluteUrl(prefix: string) {
|
|
43
41
|
return BlockComponents(
|
|
44
42
|
ContentRelativeBinary.transform(mapRemoteToAbsolute(prefix)),
|
|
45
|
-
ContentRelativeBinary.transform(mapRemoteToAbsolute(prefix))
|
|
43
|
+
ContentRelativeBinary.transform(mapRemoteToAbsolute(prefix)),
|
|
46
44
|
);
|
|
47
45
|
}
|
|
48
46
|
export type BlockComponentsAbsolute = z.infer<ReturnType<typeof BlockComponentsAbsoluteUrl>>;
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ZodTypeAny } from 'zod';
|
|
2
|
+
import { z } from 'zod';
|
|
2
3
|
import { BlockComponentsDescriptionRaw } from './block_components';
|
|
3
4
|
import { BlockPackMetaDescriptionRaw } from './block_meta';
|
|
4
5
|
import { BlockPackId } from './block_id';
|
|
5
6
|
import * as R from 'remeda';
|
|
6
|
-
import { BlockCodeKnownFeatureFlags } from '@milaboratories/pl-model-common';
|
|
7
|
+
import type { BlockCodeKnownFeatureFlags } from '@milaboratories/pl-model-common';
|
|
7
8
|
|
|
8
9
|
/** Description, as appears in root block package.json file,
|
|
9
10
|
* `file:` references are parsed into relative content of corresponding type, depending on the context,
|
|
10
11
|
* strings are converted to explicit content type. */
|
|
11
12
|
export const BlockPackDescriptionFromPackageJsonRaw = z.object({
|
|
12
13
|
components: BlockComponentsDescriptionRaw,
|
|
13
|
-
meta: BlockPackMetaDescriptionRaw
|
|
14
|
+
meta: BlockPackMetaDescriptionRaw,
|
|
14
15
|
});
|
|
15
16
|
|
|
16
17
|
export const FeatureFlags = z.record(z.string(), z.union([z.boolean(), z.number()]))
|
|
@@ -18,25 +19,25 @@ export const FeatureFlags = z.record(z.string(), z.union([z.boolean(), z.number(
|
|
|
18
19
|
|
|
19
20
|
export function CreateBlockPackDescriptionSchema<
|
|
20
21
|
Components extends ZodTypeAny,
|
|
21
|
-
Meta extends ZodTypeAny
|
|
22
|
+
Meta extends ZodTypeAny,
|
|
22
23
|
>(components: Components, meta: Meta) {
|
|
23
24
|
return z.object({
|
|
24
25
|
id: BlockPackId,
|
|
25
26
|
components,
|
|
26
27
|
meta,
|
|
27
|
-
featureFlags: FeatureFlags.optional()
|
|
28
|
+
featureFlags: FeatureFlags.optional(),
|
|
28
29
|
}).passthrough();
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
export const BlockPackDescriptionRaw = CreateBlockPackDescriptionSchema(
|
|
32
33
|
BlockComponentsDescriptionRaw,
|
|
33
|
-
BlockPackMetaDescriptionRaw
|
|
34
|
+
BlockPackMetaDescriptionRaw,
|
|
34
35
|
);
|
|
35
36
|
export type BlockPackDescriptionRaw = z.infer<typeof BlockPackDescriptionRaw>;
|
|
36
37
|
|
|
37
38
|
export function overrideDescriptionVersion<T extends { id: BlockPackId }>(
|
|
38
39
|
manifest: T,
|
|
39
|
-
newVersion: string
|
|
40
|
+
newVersion: string,
|
|
40
41
|
): T {
|
|
41
42
|
return R.mergeDeep(manifest, { id: { version: newVersion } }) as T;
|
|
42
43
|
}
|
|
@@ -6,7 +6,7 @@ export const BlockPackId = z
|
|
|
6
6
|
.object({
|
|
7
7
|
organization: z.string(),
|
|
8
8
|
name: z.string(),
|
|
9
|
-
version: SemVer
|
|
9
|
+
version: SemVer,
|
|
10
10
|
})
|
|
11
11
|
.strict();
|
|
12
12
|
export type BlockPackId = z.infer<typeof BlockPackId>;
|
|
@@ -26,7 +26,7 @@ export function blockPackIdNoVersionToString(
|
|
|
26
26
|
bp: BlockPackIdNoVersion | undefined
|
|
27
27
|
): string | undefined;
|
|
28
28
|
export function blockPackIdNoVersionToString(
|
|
29
|
-
bp: BlockPackIdNoVersion | undefined
|
|
29
|
+
bp: BlockPackIdNoVersion | undefined,
|
|
30
30
|
): string | undefined {
|
|
31
31
|
if (bp === undefined) return undefined;
|
|
32
32
|
return `${bp.organization}:${bp.name}`;
|
|
@@ -34,7 +34,7 @@ export function blockPackIdNoVersionToString(
|
|
|
34
34
|
|
|
35
35
|
export function blockPackIdEquals(
|
|
36
36
|
bp1: BlockPackId | undefined,
|
|
37
|
-
bp2: BlockPackId | undefined
|
|
37
|
+
bp2: BlockPackId | undefined,
|
|
38
38
|
): boolean {
|
|
39
39
|
if (bp1 === undefined && bp2 === undefined) return true;
|
|
40
40
|
if (bp1 === undefined || bp2 === undefined) return false;
|
|
@@ -45,7 +45,7 @@ export function blockPackIdEquals(
|
|
|
45
45
|
|
|
46
46
|
export function blockPackIdNoVersionEquals(
|
|
47
47
|
bp1: BlockPackIdNoVersion | undefined,
|
|
48
|
-
bp2: BlockPackIdNoVersion | undefined
|
|
48
|
+
bp2: BlockPackIdNoVersion | undefined,
|
|
49
49
|
): boolean {
|
|
50
50
|
if (bp1 === undefined && bp2 === undefined) return true;
|
|
51
51
|
if (bp1 === undefined || bp2 === undefined) return false;
|
|
@@ -4,7 +4,7 @@ import { ContentRelative, ContentRelativeBinary, ContentRelativeText } from './c
|
|
|
4
4
|
import { CreateBlockPackDescriptionSchema } from './block_description';
|
|
5
5
|
import { BlockPackMeta } from './block_meta';
|
|
6
6
|
import * as R from 'remeda';
|
|
7
|
-
import { BlockPackId } from './block_id';
|
|
7
|
+
import type { BlockPackId } from './block_id';
|
|
8
8
|
|
|
9
9
|
export const BlockComponentsManifest = BlockComponents(ContentRelative, ContentRelative);
|
|
10
10
|
export type BlockComponentsManifest = z.infer<typeof BlockComponentsManifest>;
|
|
@@ -15,7 +15,7 @@ export type BlockPackMetaManifest = z.infer<typeof BlockPackMetaManifest>;
|
|
|
15
15
|
/** Block description to be used in block manifest */
|
|
16
16
|
export const BlockPackDescriptionManifest = CreateBlockPackDescriptionSchema(
|
|
17
17
|
BlockComponentsManifest,
|
|
18
|
-
BlockPackMetaManifest
|
|
18
|
+
BlockPackMetaManifest,
|
|
19
19
|
);
|
|
20
20
|
export type BlockPackDescriptionManifest = z.infer<typeof BlockPackDescriptionManifest>;
|
|
21
21
|
|
|
@@ -28,7 +28,7 @@ export const Sha256Schema = z
|
|
|
28
28
|
export const ManifestFileInfo = z.object({
|
|
29
29
|
name: z.string(),
|
|
30
30
|
size: z.number().int(),
|
|
31
|
-
sha256: Sha256Schema
|
|
31
|
+
sha256: Sha256Schema,
|
|
32
32
|
});
|
|
33
33
|
export type ManifestFileInfo = z.infer<typeof ManifestFileInfo>;
|
|
34
34
|
|
|
@@ -36,7 +36,7 @@ export const BlockPackManifest = z.object({
|
|
|
36
36
|
schema: z.literal('v2'),
|
|
37
37
|
description: BlockPackDescriptionManifest,
|
|
38
38
|
timestamp: z.number().optional(),
|
|
39
|
-
files: z.array(ManifestFileInfo)
|
|
39
|
+
files: z.array(ManifestFileInfo),
|
|
40
40
|
}).passthrough();
|
|
41
41
|
export type BlockPackManifest = z.infer<typeof BlockPackManifest>;
|
|
42
42
|
|
|
@@ -44,7 +44,7 @@ export const BlockPackManifestFile = 'manifest.json';
|
|
|
44
44
|
|
|
45
45
|
export function overrideManifestVersion<T extends { description: { id: BlockPackId } }>(
|
|
46
46
|
manifest: T,
|
|
47
|
-
newVersion: string
|
|
47
|
+
newVersion: string,
|
|
48
48
|
): T {
|
|
49
49
|
return R.mergeDeep(manifest, { description: { id: { version: newVersion } } }) as T;
|
|
50
50
|
}
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
ContentExplicitBase64,
|
|
4
4
|
ContentExplicitBytes,
|
|
5
5
|
DescriptionContentBinary,
|
|
6
|
-
DescriptionContentText
|
|
6
|
+
DescriptionContentText,
|
|
7
7
|
} from './content_types';
|
|
8
8
|
|
|
9
9
|
export const BlockPlatform = z.enum([
|
|
@@ -12,13 +12,13 @@ export const BlockPlatform = z.enum([
|
|
|
12
12
|
'macosx-x64',
|
|
13
13
|
'macosx-aarch64',
|
|
14
14
|
'linux-x64',
|
|
15
|
-
'linux-aarch64'
|
|
15
|
+
'linux-aarch64',
|
|
16
16
|
]);
|
|
17
17
|
export type BlockPlatform = z.infer<typeof BlockPlatform>;
|
|
18
18
|
|
|
19
19
|
export function BlockPackMeta<
|
|
20
20
|
const LongStringType extends z.ZodTypeAny,
|
|
21
|
-
const BinaryType extends z.ZodTypeAny
|
|
21
|
+
const BinaryType extends z.ZodTypeAny,
|
|
22
22
|
>(longString: LongStringType, binary: BinaryType) {
|
|
23
23
|
return z.object({
|
|
24
24
|
title: z.string(),
|
|
@@ -33,7 +33,7 @@ export function BlockPackMeta<
|
|
|
33
33
|
organization: z.object({
|
|
34
34
|
name: z.string(),
|
|
35
35
|
url: z.string().url(),
|
|
36
|
-
logo: binary.optional()
|
|
36
|
+
logo: binary.optional(),
|
|
37
37
|
}).passthrough(),
|
|
38
38
|
/**
|
|
39
39
|
* The order of blocks on the "marketplace" (higher values push block higher to the top of the list).
|
|
@@ -52,27 +52,27 @@ export function BlockPackMeta<
|
|
|
52
52
|
* Supported operating systems.
|
|
53
53
|
* If not provided, the block is supported on all operating systems.
|
|
54
54
|
*/
|
|
55
|
-
supportedPlatforms: z.array(BlockPlatform).optional()
|
|
55
|
+
supportedPlatforms: z.array(BlockPlatform).optional(),
|
|
56
56
|
});
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
// prettier-ignore
|
|
60
60
|
export const BlockPackMetaDescriptionRaw = BlockPackMeta(
|
|
61
61
|
DescriptionContentText,
|
|
62
|
-
DescriptionContentBinary
|
|
62
|
+
DescriptionContentBinary,
|
|
63
63
|
);
|
|
64
64
|
export type BlockPackMetaDescriptionRaw = z.infer<typeof BlockPackMetaDescriptionRaw>;
|
|
65
65
|
|
|
66
66
|
// prettier-ignore
|
|
67
67
|
export const BlockPackMetaEmbeddedBase64 = BlockPackMeta(
|
|
68
68
|
z.string(),
|
|
69
|
-
ContentExplicitBase64
|
|
69
|
+
ContentExplicitBase64,
|
|
70
70
|
);
|
|
71
71
|
export type BlockPackMetaEmbeddedBase64 = z.infer<typeof BlockPackMetaEmbeddedBase64>;
|
|
72
72
|
|
|
73
73
|
// prettier-ignore
|
|
74
74
|
export const BlockPackMetaEmbeddedBytes = BlockPackMeta(
|
|
75
75
|
z.string(),
|
|
76
|
-
ContentExplicitBytes
|
|
76
|
+
ContentExplicitBytes,
|
|
77
77
|
);
|
|
78
78
|
export type BlockPackMetaEmbeddedBytes = z.infer<typeof BlockPackMetaEmbeddedBytes>;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type {
|
|
2
2
|
ContentAbsoluteUrl,
|
|
3
3
|
ContentAnyLocal,
|
|
4
4
|
ContentExplicitOrRelative,
|
|
5
|
-
ContentRelative
|
|
5
|
+
ContentRelative,
|
|
6
6
|
} from './content_types';
|
|
7
7
|
|
|
8
8
|
export function mapRemoteToAbsolute(
|
|
9
|
-
rootUrl: string
|
|
9
|
+
rootUrl: string,
|
|
10
10
|
): <T extends ContentAnyLocal>(value: T) => Exclude<T, ContentRelative> | ContentAbsoluteUrl {
|
|
11
11
|
const rootWithSlash = rootUrl.endsWith('/') ? rootUrl : `${rootUrl}/`;
|
|
12
12
|
return <T extends ContentAnyLocal>(value: T) =>
|
|
@@ -23,7 +23,7 @@ export function mapRemoteToAbsolute(
|
|
|
23
23
|
* @param prefix prefix to add to the relaive path, slesh at the end will be added automatically if missed
|
|
24
24
|
*/
|
|
25
25
|
export function addPrefixToRelative(
|
|
26
|
-
prefix: string
|
|
26
|
+
prefix: string,
|
|
27
27
|
): <T extends ContentExplicitOrRelative>(value: T) => T {
|
|
28
28
|
const prefixWithSlash = prefix.endsWith('/') ? prefix : `${prefix}/`;
|
|
29
29
|
return <T extends ContentExplicitOrRelative>(value: T) =>
|
|
@@ -7,7 +7,7 @@ import { z } from 'zod';
|
|
|
7
7
|
export const ContentExplicitString = z
|
|
8
8
|
.object({
|
|
9
9
|
type: z.literal('explicit-string'),
|
|
10
|
-
content: z.string().describe('Actual string value')
|
|
10
|
+
content: z.string().describe('Actual string value'),
|
|
11
11
|
})
|
|
12
12
|
.strict();
|
|
13
13
|
export type ContentExplicitString = z.infer<typeof ContentExplicitString>;
|
|
@@ -19,7 +19,7 @@ export const ContentExplicitBase64 = z
|
|
|
19
19
|
.string()
|
|
20
20
|
.regex(/\w+\/[-+.\w]+/)
|
|
21
21
|
.describe('MIME type to interpret content'),
|
|
22
|
-
content: z.string().base64().describe('Base64 encoded binary value')
|
|
22
|
+
content: z.string().base64().describe('Base64 encoded binary value'),
|
|
23
23
|
})
|
|
24
24
|
.strict();
|
|
25
25
|
export type ContentExplicitBase64 = z.infer<typeof ContentExplicitBase64>;
|
|
@@ -30,8 +30,8 @@ export const ContentRelative = z
|
|
|
30
30
|
path: z
|
|
31
31
|
.string()
|
|
32
32
|
.describe(
|
|
33
|
-
'Address of the file, in most cases relative to the file which this structure is a part of'
|
|
34
|
-
)
|
|
33
|
+
'Address of the file, in most cases relative to the file which this structure is a part of',
|
|
34
|
+
),
|
|
35
35
|
})
|
|
36
36
|
.strict();
|
|
37
37
|
export type ContentRelative = z.infer<typeof ContentRelative>;
|
|
@@ -44,7 +44,7 @@ export const ContentAbsoluteFile = z
|
|
|
44
44
|
file: z
|
|
45
45
|
.string()
|
|
46
46
|
.regex(absPathRegex, 'path to file must be absolute')
|
|
47
|
-
.describe('Absolute address of the file in local file system')
|
|
47
|
+
.describe('Absolute address of the file in local file system'),
|
|
48
48
|
})
|
|
49
49
|
.strict();
|
|
50
50
|
export type ContentAbsoluteFile = z.infer<typeof ContentAbsoluteFile>;
|
|
@@ -52,7 +52,7 @@ export type ContentAbsoluteFile = z.infer<typeof ContentAbsoluteFile>;
|
|
|
52
52
|
export const ContentAbsoluteUrl = z
|
|
53
53
|
.object({
|
|
54
54
|
type: z.literal('absolute-url'),
|
|
55
|
-
url: z.string().url().describe('Global URL to reach the requested file')
|
|
55
|
+
url: z.string().url().describe('Global URL to reach the requested file'),
|
|
56
56
|
})
|
|
57
57
|
.strict();
|
|
58
58
|
export type ContentAbsoluteUrl = z.infer<typeof ContentAbsoluteUrl>;
|
|
@@ -68,7 +68,7 @@ export const ContentExplicitBytes = z
|
|
|
68
68
|
.string()
|
|
69
69
|
.regex(/\w+\/[-+.\w]+/)
|
|
70
70
|
.describe('MIME type to interpret content'),
|
|
71
|
-
content: z.instanceof(Uint8Array).describe('Raw content')
|
|
71
|
+
content: z.instanceof(Uint8Array).describe('Raw content'),
|
|
72
72
|
})
|
|
73
73
|
.strict();
|
|
74
74
|
export type ContentExplicitBytes = z.infer<typeof ContentExplicitBytes>;
|
|
@@ -79,7 +79,7 @@ export const ContentAbsoluteFolder = z
|
|
|
79
79
|
folder: z
|
|
80
80
|
.string()
|
|
81
81
|
.regex(absPathRegex, 'path to folder must be absolute')
|
|
82
|
-
.describe('Absolute address of the folder in local file system')
|
|
82
|
+
.describe('Absolute address of the folder in local file system'),
|
|
83
83
|
})
|
|
84
84
|
.strict();
|
|
85
85
|
export type ContentAbsoluteFolder = z.infer<typeof ContentAbsoluteFolder>;
|
|
@@ -93,14 +93,14 @@ export const ContentAny = z.discriminatedUnion('type', [
|
|
|
93
93
|
ContentExplicitBase64,
|
|
94
94
|
ContentRelative,
|
|
95
95
|
ContentAbsoluteFile,
|
|
96
|
-
ContentAbsoluteUrl
|
|
96
|
+
ContentAbsoluteUrl,
|
|
97
97
|
]);
|
|
98
98
|
export type ContentAny = z.infer<typeof ContentAny>;
|
|
99
99
|
|
|
100
100
|
export const ContentExplicitOrRelative = z.discriminatedUnion('type', [
|
|
101
101
|
ContentExplicitString,
|
|
102
102
|
ContentExplicitBase64,
|
|
103
|
-
ContentRelative
|
|
103
|
+
ContentRelative,
|
|
104
104
|
]);
|
|
105
105
|
export type ContentExplicitOrRelative = z.infer<typeof ContentExplicitOrRelative>;
|
|
106
106
|
|
|
@@ -108,7 +108,7 @@ export const ContentAnyLocal = z.discriminatedUnion('type', [
|
|
|
108
108
|
ContentExplicitString,
|
|
109
109
|
ContentExplicitBase64,
|
|
110
110
|
ContentRelative,
|
|
111
|
-
ContentAbsoluteFile
|
|
111
|
+
ContentAbsoluteFile,
|
|
112
112
|
]);
|
|
113
113
|
export type ContentAnyLocal = z.infer<typeof ContentAnyLocal>;
|
|
114
114
|
|
|
@@ -116,7 +116,7 @@ export const ContentAnyRemote = z.discriminatedUnion('type', [
|
|
|
116
116
|
ContentExplicitString,
|
|
117
117
|
ContentExplicitBase64,
|
|
118
118
|
ContentRelative,
|
|
119
|
-
ContentAbsoluteUrl
|
|
119
|
+
ContentAbsoluteUrl,
|
|
120
120
|
]);
|
|
121
121
|
export type ContentAnyRemote = z.infer<typeof ContentAnyRemote>;
|
|
122
122
|
|
|
@@ -134,7 +134,7 @@ export type ContentAnyRemote = z.infer<typeof ContentAnyRemote>;
|
|
|
134
134
|
export const ContentAnyBinaryLocal = z.discriminatedUnion('type', [
|
|
135
135
|
ContentExplicitBase64,
|
|
136
136
|
ContentRelative,
|
|
137
|
-
ContentAbsoluteFile
|
|
137
|
+
ContentAbsoluteFile,
|
|
138
138
|
]);
|
|
139
139
|
export type ContentAnyBinaryLocal = z.infer<typeof ContentAnyBinaryLocal>;
|
|
140
140
|
|
|
@@ -148,7 +148,7 @@ export type ContentAnyBinaryLocal = z.infer<typeof ContentAnyBinaryLocal>;
|
|
|
148
148
|
export const ContentAnyTextLocal = z.discriminatedUnion('type', [
|
|
149
149
|
ContentExplicitString,
|
|
150
150
|
ContentRelative,
|
|
151
|
-
ContentAbsoluteFile
|
|
151
|
+
ContentAbsoluteFile,
|
|
152
152
|
]);
|
|
153
153
|
export type ContentAnyTextLocal = z.infer<typeof ContentAnyTextLocal>;
|
|
154
154
|
|
|
@@ -158,25 +158,25 @@ export type ContentAnyTextLocal = z.infer<typeof ContentAnyTextLocal>;
|
|
|
158
158
|
|
|
159
159
|
export const ContentAbsoluteBinaryRemote = z.discriminatedUnion('type', [
|
|
160
160
|
ContentExplicitBase64,
|
|
161
|
-
ContentAbsoluteUrl
|
|
161
|
+
ContentAbsoluteUrl,
|
|
162
162
|
]);
|
|
163
163
|
export type ContentAbsoluteBinaryRemote = z.infer<typeof ContentAbsoluteBinaryRemote>;
|
|
164
164
|
|
|
165
165
|
export const ContentAbsoluteBinaryLocal = z.discriminatedUnion('type', [
|
|
166
166
|
ContentExplicitBase64,
|
|
167
|
-
ContentAbsoluteFile
|
|
167
|
+
ContentAbsoluteFile,
|
|
168
168
|
]);
|
|
169
169
|
export type ContentAbsoluteBinaryLocal = z.infer<typeof ContentAbsoluteBinaryLocal>;
|
|
170
170
|
|
|
171
171
|
export const ContentAbsoluteTextRemote = z.discriminatedUnion('type', [
|
|
172
172
|
ContentExplicitString,
|
|
173
|
-
ContentAbsoluteUrl
|
|
173
|
+
ContentAbsoluteUrl,
|
|
174
174
|
]);
|
|
175
175
|
export type ContentAbsoluteTextRemote = z.infer<typeof ContentAbsoluteTextRemote>;
|
|
176
176
|
|
|
177
177
|
export const ContentAbsoluteTextLocal = z.discriminatedUnion('type', [
|
|
178
178
|
ContentExplicitString,
|
|
179
|
-
ContentAbsoluteFile
|
|
179
|
+
ContentAbsoluteFile,
|
|
180
180
|
]);
|
|
181
181
|
export type ContentAbsoluteTextLocal = z.infer<typeof ContentAbsoluteTextLocal>;
|
|
182
182
|
|
|
@@ -186,13 +186,13 @@ export type ContentAbsoluteTextLocal = z.infer<typeof ContentAbsoluteTextLocal>;
|
|
|
186
186
|
|
|
187
187
|
export const ContentRelativeBinary = z.discriminatedUnion('type', [
|
|
188
188
|
ContentExplicitBase64,
|
|
189
|
-
ContentRelative
|
|
189
|
+
ContentRelative,
|
|
190
190
|
]);
|
|
191
191
|
export type ContentRelativeBinary = z.infer<typeof ContentRelativeBinary>;
|
|
192
192
|
|
|
193
193
|
export const ContentRelativeText = z.discriminatedUnion('type', [
|
|
194
194
|
ContentExplicitString,
|
|
195
|
-
ContentRelative
|
|
195
|
+
ContentRelative,
|
|
196
196
|
]);
|
|
197
197
|
export type ContentRelativeText = z.infer<typeof ContentRelativeText>;
|
|
198
198
|
|
|
@@ -234,16 +234,16 @@ export const DescriptionContentBinary = z.union([
|
|
|
234
234
|
z
|
|
235
235
|
.string()
|
|
236
236
|
.startsWith('file:')
|
|
237
|
-
.transform<ContentRelativeBinary>((value
|
|
238
|
-
ContentAnyBinaryLocal
|
|
237
|
+
.transform<ContentRelativeBinary>((value) => ({ type: 'relative', path: value.slice(5) })),
|
|
238
|
+
ContentAnyBinaryLocal,
|
|
239
239
|
]);
|
|
240
240
|
export type DescriptionContentBinary = z.infer<typeof DescriptionContentBinary>;
|
|
241
241
|
|
|
242
242
|
export const DescriptionContentText = z.union([
|
|
243
|
-
z.string().transform<ContentRelativeText>((value
|
|
243
|
+
z.string().transform<ContentRelativeText>((value) => {
|
|
244
244
|
if (value.startsWith('file:')) return { type: 'relative', path: value.slice(5) };
|
|
245
245
|
else return { type: 'explicit-string', content: value };
|
|
246
246
|
}),
|
|
247
|
-
ContentAnyTextLocal
|
|
247
|
+
ContentAnyTextLocal,
|
|
248
248
|
]);
|
|
249
249
|
export type DescriptionContentText = z.infer<typeof DescriptionContentText>;
|
package/src/block_meta/semver.ts
CHANGED
|
@@ -6,5 +6,5 @@ export const SemVer = z
|
|
|
6
6
|
.string()
|
|
7
7
|
.regex(
|
|
8
8
|
/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/,
|
|
9
|
-
'Wrong version format, please use valid semver'
|
|
9
|
+
'Wrong version format, please use valid semver',
|
|
10
10
|
);
|
|
@@ -6,7 +6,7 @@ import { BlockPackId } from '../block_meta';
|
|
|
6
6
|
export const BlockPackDevV1 = z.object({
|
|
7
7
|
type: z.literal('dev-v1'),
|
|
8
8
|
folder: z.string(),
|
|
9
|
-
mtime: z.string().optional()
|
|
9
|
+
mtime: z.string().optional(),
|
|
10
10
|
});
|
|
11
11
|
/** @deprecated don't use */
|
|
12
12
|
export type BlockPackDevV1 = z.infer<typeof BlockPackDevV1>;
|
|
@@ -15,7 +15,7 @@ export type BlockPackDevV1 = z.infer<typeof BlockPackDevV1>;
|
|
|
15
15
|
export const BlockPackDevV2 = z.object({
|
|
16
16
|
type: z.literal('dev-v2'),
|
|
17
17
|
folder: z.string(),
|
|
18
|
-
mtime: z.string().optional()
|
|
18
|
+
mtime: z.string().optional(),
|
|
19
19
|
});
|
|
20
20
|
export type BlockPackDevV2 = z.infer<typeof BlockPackDevV2>;
|
|
21
21
|
|
|
@@ -27,7 +27,7 @@ export type BlockPackDevV2 = z.infer<typeof BlockPackDevV2>;
|
|
|
27
27
|
export const BlockPackFromRegistryV1 = z.object({
|
|
28
28
|
type: z.literal('from-registry-v1'),
|
|
29
29
|
registryUrl: z.string(),
|
|
30
|
-
id: BlockPackId
|
|
30
|
+
id: BlockPackId,
|
|
31
31
|
});
|
|
32
32
|
/** @deprecated don't use */
|
|
33
33
|
export type BlockPackFromRegistryV1 = z.infer<typeof BlockPackFromRegistryV1>;
|
|
@@ -38,7 +38,7 @@ export const BlockPackFromRegistryV2 = z.object({
|
|
|
38
38
|
type: z.literal('from-registry-v2'),
|
|
39
39
|
registryUrl: z.string(),
|
|
40
40
|
id: BlockPackId,
|
|
41
|
-
channel: z.string().optional()
|
|
41
|
+
channel: z.string().optional(),
|
|
42
42
|
});
|
|
43
43
|
export type BlockPackFromRegistryV2 = z.infer<typeof BlockPackFromRegistryV2>;
|
|
44
44
|
|
|
@@ -47,6 +47,6 @@ export const BlockPackSpec = z.discriminatedUnion('type', [
|
|
|
47
47
|
BlockPackDevV1,
|
|
48
48
|
BlockPackDevV2,
|
|
49
49
|
BlockPackFromRegistryV1,
|
|
50
|
-
BlockPackFromRegistryV2
|
|
50
|
+
BlockPackFromRegistryV2,
|
|
51
51
|
]);
|
|
52
52
|
export type BlockPackSpec = z.infer<typeof BlockPackSpec>;
|
|
@@ -4,9 +4,10 @@ import {
|
|
|
4
4
|
BlockPackIdNoVersion,
|
|
5
5
|
BlockPackMetaEmbeddedBytes,
|
|
6
6
|
FeatureFlags,
|
|
7
|
-
SemVer
|
|
7
|
+
SemVer,
|
|
8
8
|
} from '../block_meta';
|
|
9
|
-
import { BlockPackFromRegistryV2
|
|
9
|
+
import type { BlockPackFromRegistryV2 } from './block_pack_spec';
|
|
10
|
+
import { BlockPackSpec } from './block_pack_spec';
|
|
10
11
|
import { RegistryEntry } from './registry_spec';
|
|
11
12
|
|
|
12
13
|
/**
|
|
@@ -17,7 +18,7 @@ export const BlockPackOverviewLegacy = z.object({
|
|
|
17
18
|
id: BlockPackId,
|
|
18
19
|
meta: BlockPackMetaEmbeddedBytes,
|
|
19
20
|
spec: BlockPackSpec,
|
|
20
|
-
otherVersions: z.array(SemVer)
|
|
21
|
+
otherVersions: z.array(SemVer),
|
|
21
22
|
}).passthrough();
|
|
22
23
|
export type BlockPackOverviewLegacy = z.infer<typeof BlockPackOverviewLegacy>;
|
|
23
24
|
|
|
@@ -26,7 +27,7 @@ export const StableChannel = 'stable';
|
|
|
26
27
|
|
|
27
28
|
export const VersionWithChannels = z.object({
|
|
28
29
|
version: SemVer,
|
|
29
|
-
channels: z.array(z.string())
|
|
30
|
+
channels: z.array(z.string()),
|
|
30
31
|
}).passthrough();
|
|
31
32
|
|
|
32
33
|
/**
|
|
@@ -47,8 +48,8 @@ export const BlockPackOverviewRaw = z.object({
|
|
|
47
48
|
id: BlockPackIdNoVersion,
|
|
48
49
|
latestByChannel: z.record(z.string(), SingleBlockPackOverview),
|
|
49
50
|
allVersions: z.array(VersionWithChannels),
|
|
50
|
-
registryId: z.string()
|
|
51
|
-
})
|
|
51
|
+
registryId: z.string(),
|
|
52
|
+
});
|
|
52
53
|
export const BlockPackOverview = BlockPackOverviewRaw.passthrough();
|
|
53
54
|
export type BlockPackOverview = z.infer<typeof BlockPackOverview>;
|
|
54
55
|
|
|
@@ -56,13 +57,13 @@ export const BlockPackOverviewNoRegistryId = BlockPackOverviewRaw.omit({ registr
|
|
|
56
57
|
export type BlockPackOverviewNoRegistryId = z.infer<typeof BlockPackOverviewNoRegistryId>;
|
|
57
58
|
|
|
58
59
|
export const RegistryStatus = RegistryEntry.extend({
|
|
59
|
-
status: z.union([z.literal('online'), z.literal('offline')])
|
|
60
|
+
status: z.union([z.literal('online'), z.literal('offline')]),
|
|
60
61
|
});
|
|
61
62
|
export type RegistryStatus = z.infer<typeof RegistryStatus>;
|
|
62
63
|
|
|
63
64
|
export const BlockPackListing = z.object({
|
|
64
65
|
registries: z.array(RegistryStatus),
|
|
65
|
-
blockPacks: z.array(BlockPackOverview)
|
|
66
|
+
blockPacks: z.array(BlockPackOverview),
|
|
66
67
|
});
|
|
67
68
|
export type BlockPackListing = z.infer<typeof BlockPackListing>;
|
|
68
69
|
|
|
@@ -77,6 +78,6 @@ export function blockPackOverviewToLegacy(bpo: BlockPackOverview): BlockPackOver
|
|
|
77
78
|
otherVersions: bpo.allVersions
|
|
78
79
|
.filter((v) => v.channels.indexOf(mainChannel) >= 0)
|
|
79
80
|
.map((v) => v.version),
|
|
80
|
-
registryId: bpo.registryId
|
|
81
|
+
registryId: bpo.registryId,
|
|
81
82
|
};
|
|
82
83
|
}
|
|
@@ -2,35 +2,35 @@ import { z } from 'zod';
|
|
|
2
2
|
|
|
3
3
|
export const LocalDevFolder = z.object({
|
|
4
4
|
type: z.literal('local-dev'),
|
|
5
|
-
path: z.string()
|
|
5
|
+
path: z.string(),
|
|
6
6
|
});
|
|
7
7
|
export type LocalDevFolder = z.infer<typeof LocalDevFolder>;
|
|
8
8
|
|
|
9
9
|
/** @deprecated don't use */
|
|
10
10
|
export const RemoteRegistryV1Spec = z.object({
|
|
11
11
|
type: z.literal('remote-v1'),
|
|
12
|
-
url: z.string().url()
|
|
12
|
+
url: z.string().url(),
|
|
13
13
|
});
|
|
14
14
|
/** @deprecated don't use */
|
|
15
15
|
export type RemoteRegistryV1Spec = z.infer<typeof RemoteRegistryV1Spec>;
|
|
16
16
|
|
|
17
17
|
export const RemoteRegistryV2Spec = z.object({
|
|
18
18
|
type: z.literal('remote-v2'),
|
|
19
|
-
url: z.string().url()
|
|
19
|
+
url: z.string().url(),
|
|
20
20
|
});
|
|
21
21
|
export type RemoteRegistryV2Spec = z.infer<typeof RemoteRegistryV2Spec>;
|
|
22
22
|
|
|
23
23
|
export const RegistrySpec = z.discriminatedUnion('type', [
|
|
24
24
|
RemoteRegistryV1Spec,
|
|
25
25
|
RemoteRegistryV2Spec,
|
|
26
|
-
LocalDevFolder
|
|
26
|
+
LocalDevFolder,
|
|
27
27
|
]);
|
|
28
28
|
export type RegistrySpec = z.infer<typeof RegistrySpec>;
|
|
29
29
|
|
|
30
30
|
export const RegistryEntry = z.object({
|
|
31
31
|
id: z.string(),
|
|
32
32
|
title: z.string().optional(),
|
|
33
|
-
spec: RegistrySpec
|
|
33
|
+
spec: RegistrySpec,
|
|
34
34
|
});
|
|
35
35
|
export type RegistryEntry = z.infer<typeof RegistryEntry>;
|
|
36
36
|
|
package/src/block_state.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { BlockOutputsBase, BlockState } from '@milaboratories/pl-model-common';
|
|
2
|
-
import { Optional } from 'utility-types';
|
|
1
|
+
import type { BlockOutputsBase, BlockState } from '@milaboratories/pl-model-common';
|
|
2
|
+
import type { Optional } from 'utility-types';
|
|
3
3
|
|
|
4
4
|
export type BlockStateInternal<
|
|
5
5
|
Args = unknown,
|
|
6
6
|
Outputs extends BlockOutputsBase = BlockOutputsBase,
|
|
7
7
|
UiState = unknown,
|
|
8
|
-
Href extends `/${string}` = `/${string}
|
|
8
|
+
Href extends `/${string}` = `/${string}`,
|
|
9
9
|
> = Optional<Readonly<BlockState<Args, Outputs, UiState, Href>>, 'outputs'>;
|