@milaboratories/pl-model-middle-layer 1.2.16

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/index.cjs ADDED
@@ -0,0 +1,249 @@
1
+ 'use strict';
2
+
3
+ var zod = require('zod');
4
+
5
+ // src/block_meta/index.ts
6
+ var ContentExplicitString = zod.z.object({
7
+ type: zod.z.literal("explicit-string"),
8
+ content: zod.z.string().describe("Actual string value")
9
+ }).strict();
10
+ var ContentExplicitBase64 = zod.z.object({
11
+ type: zod.z.literal("explicit-base64"),
12
+ mimeType: zod.z.string().regex(/\w+\/[-+.\w]+/).describe("MIME type to interpret content"),
13
+ content: zod.z.string().base64().describe("Base64 encoded binary value")
14
+ }).strict();
15
+ var ContentRelative = zod.z.object({
16
+ type: zod.z.literal("relative"),
17
+ path: zod.z.string().describe(
18
+ "Address of the file, in most cases relative to the file which this structure is a part of"
19
+ )
20
+ }).strict();
21
+ var ContentAbsoluteFile = zod.z.object({
22
+ type: zod.z.literal("absolute-file"),
23
+ file: zod.z.string().startsWith("/").describe("Absolute address of the file in local file system")
24
+ }).strict();
25
+ var ContentAbsoluteUrl = zod.z.object({
26
+ type: zod.z.literal("absolute-url"),
27
+ url: zod.z.string().url().describe("Global URL to reach the requested file")
28
+ }).strict();
29
+ var ContentExplicit = zod.z.object({
30
+ type: zod.z.literal("explicit"),
31
+ content: zod.z.instanceof(Uint8Array).describe("Raw content")
32
+ }).strict();
33
+ var ContentAbsoluteFolder = zod.z.object({
34
+ type: zod.z.literal("absolute-folder"),
35
+ folder: zod.z.string().startsWith("/").describe("Absolute address of the folder in local file system")
36
+ }).strict();
37
+ var ContentAny = zod.z.discriminatedUnion("type", [
38
+ ContentExplicitString,
39
+ ContentExplicitBase64,
40
+ ContentRelative,
41
+ ContentAbsoluteFile,
42
+ ContentAbsoluteUrl
43
+ ]);
44
+ var ContentAnyLocal = zod.z.discriminatedUnion("type", [
45
+ ContentExplicitString,
46
+ ContentExplicitBase64,
47
+ ContentRelative,
48
+ ContentAbsoluteFile
49
+ ]);
50
+ var ContentAnyRemote = zod.z.discriminatedUnion("type", [
51
+ ContentExplicitString,
52
+ ContentExplicitBase64,
53
+ ContentRelative,
54
+ ContentAbsoluteUrl
55
+ ]);
56
+ var ContentAnyBinaryLocal = zod.z.discriminatedUnion("type", [
57
+ ContentExplicitBase64,
58
+ ContentRelative,
59
+ ContentAbsoluteFile
60
+ ]);
61
+ var ContentAnyTextLocal = zod.z.discriminatedUnion("type", [
62
+ ContentExplicitString,
63
+ ContentRelative,
64
+ ContentAbsoluteFile
65
+ ]);
66
+ var ContentAbsoluteBinaryRemote = zod.z.discriminatedUnion("type", [
67
+ ContentExplicitBase64,
68
+ ContentAbsoluteUrl
69
+ ]);
70
+ var ContentAbsoluteBinaryLocal = zod.z.discriminatedUnion("type", [
71
+ ContentExplicitBase64,
72
+ ContentAbsoluteFile
73
+ ]);
74
+ var ContentAbsoluteTextRemote = zod.z.discriminatedUnion("type", [
75
+ ContentExplicitString,
76
+ ContentAbsoluteUrl
77
+ ]);
78
+ var ContentAbsoluteTextLocal = zod.z.discriminatedUnion("type", [
79
+ ContentExplicitString,
80
+ ContentAbsoluteFile
81
+ ]);
82
+ var ContentRelativeBinary = zod.z.discriminatedUnion("type", [
83
+ ContentExplicitBase64,
84
+ ContentRelative
85
+ ]);
86
+ var ContentRelativeText = zod.z.discriminatedUnion("type", [
87
+ ContentExplicitString,
88
+ ContentRelative
89
+ ]);
90
+ var DescriptionContentBinary = zod.z.union([
91
+ zod.z.string().startsWith("file:").transform((value, ctx) => ({ type: "relative", path: value.slice(5) })),
92
+ ContentAnyBinaryLocal
93
+ ]);
94
+ var DescriptionContentText = zod.z.union([
95
+ zod.z.string().transform((value, ctx) => {
96
+ if (value.startsWith("file:")) return { type: "relative", path: value.slice(5) };
97
+ else return { type: "explicit-string", content: value };
98
+ }),
99
+ ContentAnyTextLocal
100
+ ]);
101
+
102
+ // src/block_meta/content_conversion.ts
103
+ function mapRemoteToAbsolute(rootUrl) {
104
+ const rootWithSlash = rootUrl.endsWith("/") ? rootUrl : `${rootUrl}/`;
105
+ return (value) => value.type === "relative" ? { type: "absolute-url", url: rootWithSlash + value.path } : value;
106
+ }
107
+
108
+ // src/block_meta/block_components.ts
109
+ function Workflow(contentType) {
110
+ return zod.z.union([
111
+ // string is converted to v1 workflow
112
+ contentType.transform((value) => ({
113
+ type: "workflow-v1",
114
+ main: value
115
+ })),
116
+ // structured objects are decoded as union with type descriptor
117
+ zod.z.discriminatedUnion("type", [
118
+ zod.z.object({
119
+ type: zod.z.literal("workflow-v1"),
120
+ main: contentType.describe("Main workflow")
121
+ })
122
+ ])
123
+ ]);
124
+ }
125
+ function BlockComponents(wfAndModel, ui) {
126
+ return zod.z.object({
127
+ workflow: wfAndModel,
128
+ model: wfAndModel,
129
+ ui
130
+ });
131
+ }
132
+ var BlockComponentsDescriptionRaw = BlockComponents(zod.z.string(), zod.z.string());
133
+ var BlockComponentsManifest = BlockComponents(ContentRelative, ContentRelative);
134
+ function BlockComponentsAbsoluteUrl(prefix) {
135
+ return BlockComponents(
136
+ ContentRelativeBinary.transform(mapRemoteToAbsolute(prefix)),
137
+ ContentRelativeBinary.transform(mapRemoteToAbsolute(prefix))
138
+ );
139
+ }
140
+ var SemVer = zod.z.string().regex(
141
+ /^(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-]+)*))?$/,
142
+ "Wrong version format, please use valid semver"
143
+ );
144
+
145
+ // src/block_meta/block_pack_id.ts
146
+ var BlockPackId = zod.z.object({
147
+ organization: zod.z.string(),
148
+ name: zod.z.string(),
149
+ version: SemVer
150
+ }).strict();
151
+ var BlockPackIdNoVersion = BlockPackId.omit({ version: true });
152
+ function BlockPackMeta(longString, binary) {
153
+ return zod.z.object({
154
+ title: zod.z.string(),
155
+ description: zod.z.string(),
156
+ longDescription: longString.optional(),
157
+ logo: binary.optional(),
158
+ url: zod.z.string().url().optional(),
159
+ docs: zod.z.string().url().optional(),
160
+ support: zod.z.union([zod.z.string().url(), zod.z.string().email()]).optional(),
161
+ tags: zod.z.array(zod.z.string()).optional(),
162
+ organization: zod.z.object({
163
+ name: zod.z.string(),
164
+ url: zod.z.string().url(),
165
+ logo: binary.optional()
166
+ })
167
+ });
168
+ }
169
+ var BlockPackMetaDescriptionRaw = BlockPackMeta(
170
+ DescriptionContentText,
171
+ DescriptionContentBinary
172
+ );
173
+ var BlockPackMetaManifest = BlockPackMeta(
174
+ ContentRelativeText,
175
+ ContentRelativeBinary
176
+ );
177
+ var BlockPackMetaEmbeddedContent = BlockPackMeta(
178
+ zod.z.string(),
179
+ ContentExplicitBase64
180
+ );
181
+
182
+ // src/block_meta/index.ts
183
+ var BlockPackDescriptionFromPackageJsonRaw = zod.z.object({
184
+ components: BlockComponentsDescriptionRaw,
185
+ meta: BlockPackMetaDescriptionRaw
186
+ });
187
+ function CreateBlockPackDescriptionSchema(components, meta) {
188
+ return zod.z.object({
189
+ id: BlockPackId,
190
+ components,
191
+ meta
192
+ });
193
+ }
194
+ var BlockPackDescriptionManifest = CreateBlockPackDescriptionSchema(
195
+ BlockComponentsManifest,
196
+ BlockPackMetaManifest
197
+ );
198
+ var BlockPackDescriptionRaw = CreateBlockPackDescriptionSchema(
199
+ BlockComponentsDescriptionRaw,
200
+ BlockPackMetaDescriptionRaw
201
+ );
202
+ var BlockPackManifest = BlockPackDescriptionManifest.extend({
203
+ schema: zod.z.literal("v1"),
204
+ files: zod.z.array(zod.z.string())
205
+ });
206
+
207
+ // src/pframe/internal_api/index.ts
208
+ var internal_api_exports = {};
209
+
210
+ exports.BlockComponents = BlockComponents;
211
+ exports.BlockComponentsAbsoluteUrl = BlockComponentsAbsoluteUrl;
212
+ exports.BlockComponentsDescriptionRaw = BlockComponentsDescriptionRaw;
213
+ exports.BlockComponentsManifest = BlockComponentsManifest;
214
+ exports.BlockPackDescriptionFromPackageJsonRaw = BlockPackDescriptionFromPackageJsonRaw;
215
+ exports.BlockPackDescriptionManifest = BlockPackDescriptionManifest;
216
+ exports.BlockPackDescriptionRaw = BlockPackDescriptionRaw;
217
+ exports.BlockPackId = BlockPackId;
218
+ exports.BlockPackIdNoVersion = BlockPackIdNoVersion;
219
+ exports.BlockPackManifest = BlockPackManifest;
220
+ exports.BlockPackMeta = BlockPackMeta;
221
+ exports.BlockPackMetaDescriptionRaw = BlockPackMetaDescriptionRaw;
222
+ exports.BlockPackMetaEmbeddedContent = BlockPackMetaEmbeddedContent;
223
+ exports.BlockPackMetaManifest = BlockPackMetaManifest;
224
+ exports.ContentAbsoluteBinaryLocal = ContentAbsoluteBinaryLocal;
225
+ exports.ContentAbsoluteBinaryRemote = ContentAbsoluteBinaryRemote;
226
+ exports.ContentAbsoluteFile = ContentAbsoluteFile;
227
+ exports.ContentAbsoluteFolder = ContentAbsoluteFolder;
228
+ exports.ContentAbsoluteTextLocal = ContentAbsoluteTextLocal;
229
+ exports.ContentAbsoluteTextRemote = ContentAbsoluteTextRemote;
230
+ exports.ContentAbsoluteUrl = ContentAbsoluteUrl;
231
+ exports.ContentAny = ContentAny;
232
+ exports.ContentAnyBinaryLocal = ContentAnyBinaryLocal;
233
+ exports.ContentAnyLocal = ContentAnyLocal;
234
+ exports.ContentAnyRemote = ContentAnyRemote;
235
+ exports.ContentAnyTextLocal = ContentAnyTextLocal;
236
+ exports.ContentExplicit = ContentExplicit;
237
+ exports.ContentExplicitBase64 = ContentExplicitBase64;
238
+ exports.ContentExplicitString = ContentExplicitString;
239
+ exports.ContentRelative = ContentRelative;
240
+ exports.ContentRelativeBinary = ContentRelativeBinary;
241
+ exports.ContentRelativeText = ContentRelativeText;
242
+ exports.CreateBlockPackDescriptionSchema = CreateBlockPackDescriptionSchema;
243
+ exports.DescriptionContentBinary = DescriptionContentBinary;
244
+ exports.DescriptionContentText = DescriptionContentText;
245
+ exports.PFrameInternal = internal_api_exports;
246
+ exports.SemVer = SemVer;
247
+ exports.Workflow = Workflow;
248
+ //# sourceMappingURL=index.cjs.map
249
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/block_meta/content_types.ts","../src/block_meta/content_conversion.ts","../src/block_meta/block_components.ts","../src/block_meta/semver.ts","../src/block_meta/block_pack_id.ts","../src/block_meta/meta.ts","../src/block_meta/index.ts","../src/pframe/internal_api/index.ts"],"names":["z"],"mappings":";;;;;AAMa,IAAA,qBAAA,GAAwBA,MAClC,MAAO,CAAA;AAAA,EACN,IAAA,EAAMA,KAAE,CAAA,OAAA,CAAQ,iBAAiB,CAAA;AAAA,EACjC,OAAS,EAAAA,KAAA,CAAE,MAAO,EAAA,CAAE,SAAS,qBAAqB,CAAA;AACpD,CAAC,EACA,MAAO,GAAA;AAGG,IAAA,qBAAA,GAAwBA,MAClC,MAAO,CAAA;AAAA,EACN,IAAA,EAAMA,KAAE,CAAA,OAAA,CAAQ,iBAAiB,CAAA;AAAA,EACjC,QAAA,EAAUA,MACP,MAAO,EAAA,CACP,MAAM,eAAe,CAAA,CACrB,SAAS,gCAAgC,CAAA;AAAA,EAC5C,SAASA,KAAE,CAAA,MAAA,GAAS,MAAO,EAAA,CAAE,SAAS,6BAA6B,CAAA;AACrE,CAAC,EACA,MAAO,GAAA;AAGG,IAAA,eAAA,GAAkBA,MAC5B,MAAO,CAAA;AAAA,EACN,IAAA,EAAMA,KAAE,CAAA,OAAA,CAAQ,UAAU,CAAA;AAAA,EAC1B,IAAA,EAAMA,KACH,CAAA,MAAA,EACA,CAAA,QAAA;AAAA,IACC,2FAAA;AAAA,GACF;AACJ,CAAC,EACA,MAAO,GAAA;AAGG,IAAA,mBAAA,GAAsBA,MAChC,MAAO,CAAA;AAAA,EACN,IAAA,EAAMA,KAAE,CAAA,OAAA,C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,CAAA,CAAA;AACH,CAAA;AAEO,IAAM,4BAA+B,GAAA,gCAAA;AAAA,EAC1C,uBAAA;AAAA,EACA,qBAAA;AACF,EAAA;AAGO,IAAM,uBAA0B,GAAA,gCAAA;AAAA,EACrC,6BAAA;AAAA,EACA,2BAAA;AACF,EAAA;AAGa,IAAA,iBAAA,GAAoB,6BAA6B,MAAO,CAAA;AAAA,EACnE,MAAA,EAAQA,KAAE,CAAA,OAAA,CAAQ,IAAI,CAAA;AAAA,EACtB,KAAOA,EAAAA,KAAAA,CAAE,KAAMA,CAAAA,KAAAA,CAAE,QAAQ,CAAA;AAC3B,CAAC,EAAA;;;ACjDD,IAAA,oBAAA,GAAA","file":"index.cjs","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\nexport const ContentAbsoluteFile = z\n .object({\n type: z.literal('absolute-file'),\n file: z.string().startsWith('/').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 ContentExplicit = z\n .object({\n type: z.literal('explicit'),\n content: z.instanceof(Uint8Array).describe('Raw content')\n })\n .strict();\nexport type ContentExplicit = z.infer<typeof ContentExplicit>;\n\nexport const ContentAbsoluteFolder = z\n .object({\n type: z.literal('absolute-folder'),\n folder: z\n .string()\n .startsWith('/')\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 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, ctx) => ({ 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, ctx) => {\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","import { ContentAbsoluteUrl, ContentAnyLocal, ContentRelative } from \"./content_types\";\n\nexport function mapRemoteToAbsolute(\n rootUrl: string\n): <T extends ContentAnyLocal>(\n value: T\n) => Exclude<T, ContentRelative> | ContentAbsoluteUrl {\n const rootWithSlash = rootUrl.endsWith('/') ? rootUrl : `${rootUrl}/`;\n return <T extends ContentAnyLocal>(value: T) =>\n value.type === 'relative'\n ? { type: 'absolute-url', url: rootWithSlash + value.path }\n : (value as Exclude<T, ContentRelative>);\n}\n","import { z } from 'zod';\nimport { ContentRelative, ContentRelativeBinary } from './content_types';\nimport { mapRemoteToAbsolute } from './content_conversion';\n\nexport type BlockPackComponents = {};\n\nexport function Workflow<const Content extends z.ZodTypeAny>(contentType: Content) {\n return z.union([\n // string is converted to v1 workflow\n contentType.transform((value) => ({\n type: 'workflow-v1',\n main: value\n })),\n // structured objects are decoded as union with type descriptor\n z.discriminatedUnion('type', [\n z.object({\n type: z.literal('workflow-v1'),\n main: contentType.describe('Main workflow')\n })\n ])\n ]);\n}\n\nexport function BlockComponents<\n const WfAndModel extends z.ZodTypeAny,\n const UI extends z.ZodTypeAny\n>(wfAndModel: WfAndModel, ui: UI) {\n return z.object({\n workflow: wfAndModel,\n model: wfAndModel,\n ui\n });\n}\n\nexport const BlockComponentsDescriptionRaw = BlockComponents(z.string(), z.string());\nexport type BlockComponentsDescriptionRaw = z.infer<typeof BlockComponentsDescriptionRaw>;\n\nexport const BlockComponentsManifest = BlockComponents(ContentRelative, ContentRelative);\nexport type BlockComponentsManifest = z.infer<typeof BlockComponentsManifest>;\n\nexport function BlockComponentsAbsoluteUrl(prefix: string) {\n return BlockComponents(\n ContentRelativeBinary.transform(mapRemoteToAbsolute(prefix)),\n ContentRelativeBinary.transform(mapRemoteToAbsolute(prefix))\n );\n}\nexport type BlockComponentsAbsolute = z.infer<ReturnType<typeof BlockComponentsAbsoluteUrl>>;\n","import { z } from 'zod';\n\n// Regex taken from here:\n// https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string\nexport const SemVer = z\n .string()\n .regex(\n /^(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-]+)*))?$/,\n 'Wrong version format, please use valid semver'\n );\n","import { z } from 'zod';\nimport { SemVer } from './semver';\n\n/** Global identifier of the block */\nexport const BlockPackId = z\n .object({\n organization: z.string(),\n name: z.string(),\n version: SemVer\n })\n .strict();\nexport type BlockPackId = z.infer<typeof BlockPackId>;\n\nexport const BlockPackIdNoVersion = BlockPackId.omit({ version: true });\nexport type BlockPackIdNoVersion = z.infer<typeof BlockPackIdNoVersion>;\n","import { z } from 'zod';\nimport {\n ContentAbsoluteBinaryLocal,\n ContentAbsoluteTextLocal,\n ContentExplicitBase64,\n ContentExplicitString,\n ContentRelative,\n ContentRelativeBinary,\n ContentRelativeText,\n DescriptionContentBinary,\n DescriptionContentText\n} from './content_types';\n\nexport function BlockPackMeta<\n const LongStringType extends z.ZodTypeAny,\n const BinaryType extends z.ZodTypeAny\n>(longString: LongStringType, binary: BinaryType) {\n return z.object({\n title: z.string(),\n description: z.string(),\n longDescription: longString.optional(),\n logo: binary.optional(),\n url: z.string().url().optional(),\n docs: z.string().url().optional(),\n support: z.union([z.string().url(), z.string().email()]).optional(),\n tags: z.array(z.string()).optional(),\n organization: z.object({\n name: z.string(),\n url: z.string().url(),\n logo: binary.optional()\n })\n });\n}\n\n// prettier-ignore\nexport const BlockPackMetaDescriptionRaw = BlockPackMeta(\n DescriptionContentText,\n DescriptionContentBinary\n);\nexport type BlockPackMetaDescriptionRaw = z.infer<typeof BlockPackMetaDescriptionRaw>;\n\n// prettier-ignore\nexport const BlockPackMetaManifest = BlockPackMeta(\n ContentRelativeText,\n ContentRelativeBinary\n);\nexport type BlockPackMetaManifest = z.infer<typeof BlockPackMetaManifest>;\n\n// prettier-ignore\nexport const BlockPackMetaEmbeddedContent = BlockPackMeta(\n z.string(),\n ContentExplicitBase64\n);\nexport type BlockPackMetaEmbeddedContent = z.infer<typeof BlockPackMetaEmbeddedContent>;\n","import { ZodTypeAny, z } from 'zod';\nimport {\n BlockComponentsDescriptionRaw,\n BlockComponentsManifest\n} from './block_components';\nimport { BlockPackId } from './block_pack_id';\nimport {\n BlockPackMetaDescriptionRaw,\n BlockPackMetaManifest\n} from './meta';\n\nexport * from './block_components'\nexport * from './block_pack_id'\nexport * from './common'\nexport * from './content_types'\nexport * from './meta'\nexport * from './semver'\n\nexport const BlockPackDescriptionFromPackageJsonRaw = z.object({\n components: BlockComponentsDescriptionRaw,\n meta: BlockPackMetaDescriptionRaw\n});\n\nexport function CreateBlockPackDescriptionSchema<Components extends ZodTypeAny, Meta extends ZodTypeAny>(\n components: Components,\n meta: Meta\n) {\n return z.object({\n id: BlockPackId,\n components,\n meta\n });\n}\n\nexport const BlockPackDescriptionManifest = CreateBlockPackDescriptionSchema(\n BlockComponentsManifest,\n BlockPackMetaManifest\n);\nexport type BlockPackDescriptionManifest = z.infer<typeof BlockPackDescriptionManifest>;\n\nexport const BlockPackDescriptionRaw = CreateBlockPackDescriptionSchema(\n BlockComponentsDescriptionRaw,\n BlockPackMetaDescriptionRaw\n);\nexport type BlockPackDescriptionRaw = z.infer<typeof BlockPackDescriptionRaw>;\n\nexport const BlockPackManifest = BlockPackDescriptionManifest.extend({\n schema: z.literal('v1'),\n files: z.array(z.string())\n});\nexport type BlockPackManifest = z.infer<typeof BlockPackManifest>;\n","export * from './api_read';\nexport * from './api_factory';\nexport * from './common';\nexport * from './create_table';\nexport * from './delete_column';\nexport * from './find_columns';\nexport * from './table';\n\nexport * from './pframe';\n"]}
package/dist/index.js ADDED
@@ -0,0 +1,210 @@
1
+ import { z } from 'zod';
2
+
3
+ // src/block_meta/index.ts
4
+ var ContentExplicitString = z.object({
5
+ type: z.literal("explicit-string"),
6
+ content: z.string().describe("Actual string value")
7
+ }).strict();
8
+ var ContentExplicitBase64 = z.object({
9
+ type: z.literal("explicit-base64"),
10
+ mimeType: z.string().regex(/\w+\/[-+.\w]+/).describe("MIME type to interpret content"),
11
+ content: z.string().base64().describe("Base64 encoded binary value")
12
+ }).strict();
13
+ var ContentRelative = z.object({
14
+ type: z.literal("relative"),
15
+ path: z.string().describe(
16
+ "Address of the file, in most cases relative to the file which this structure is a part of"
17
+ )
18
+ }).strict();
19
+ var ContentAbsoluteFile = z.object({
20
+ type: z.literal("absolute-file"),
21
+ file: z.string().startsWith("/").describe("Absolute address of the file in local file system")
22
+ }).strict();
23
+ var ContentAbsoluteUrl = z.object({
24
+ type: z.literal("absolute-url"),
25
+ url: z.string().url().describe("Global URL to reach the requested file")
26
+ }).strict();
27
+ var ContentExplicit = z.object({
28
+ type: z.literal("explicit"),
29
+ content: z.instanceof(Uint8Array).describe("Raw content")
30
+ }).strict();
31
+ var ContentAbsoluteFolder = z.object({
32
+ type: z.literal("absolute-folder"),
33
+ folder: z.string().startsWith("/").describe("Absolute address of the folder in local file system")
34
+ }).strict();
35
+ var ContentAny = z.discriminatedUnion("type", [
36
+ ContentExplicitString,
37
+ ContentExplicitBase64,
38
+ ContentRelative,
39
+ ContentAbsoluteFile,
40
+ ContentAbsoluteUrl
41
+ ]);
42
+ var ContentAnyLocal = z.discriminatedUnion("type", [
43
+ ContentExplicitString,
44
+ ContentExplicitBase64,
45
+ ContentRelative,
46
+ ContentAbsoluteFile
47
+ ]);
48
+ var ContentAnyRemote = z.discriminatedUnion("type", [
49
+ ContentExplicitString,
50
+ ContentExplicitBase64,
51
+ ContentRelative,
52
+ ContentAbsoluteUrl
53
+ ]);
54
+ var ContentAnyBinaryLocal = z.discriminatedUnion("type", [
55
+ ContentExplicitBase64,
56
+ ContentRelative,
57
+ ContentAbsoluteFile
58
+ ]);
59
+ var ContentAnyTextLocal = z.discriminatedUnion("type", [
60
+ ContentExplicitString,
61
+ ContentRelative,
62
+ ContentAbsoluteFile
63
+ ]);
64
+ var ContentAbsoluteBinaryRemote = z.discriminatedUnion("type", [
65
+ ContentExplicitBase64,
66
+ ContentAbsoluteUrl
67
+ ]);
68
+ var ContentAbsoluteBinaryLocal = z.discriminatedUnion("type", [
69
+ ContentExplicitBase64,
70
+ ContentAbsoluteFile
71
+ ]);
72
+ var ContentAbsoluteTextRemote = z.discriminatedUnion("type", [
73
+ ContentExplicitString,
74
+ ContentAbsoluteUrl
75
+ ]);
76
+ var ContentAbsoluteTextLocal = z.discriminatedUnion("type", [
77
+ ContentExplicitString,
78
+ ContentAbsoluteFile
79
+ ]);
80
+ var ContentRelativeBinary = z.discriminatedUnion("type", [
81
+ ContentExplicitBase64,
82
+ ContentRelative
83
+ ]);
84
+ var ContentRelativeText = z.discriminatedUnion("type", [
85
+ ContentExplicitString,
86
+ ContentRelative
87
+ ]);
88
+ var DescriptionContentBinary = z.union([
89
+ z.string().startsWith("file:").transform((value, ctx) => ({ type: "relative", path: value.slice(5) })),
90
+ ContentAnyBinaryLocal
91
+ ]);
92
+ var DescriptionContentText = z.union([
93
+ z.string().transform((value, ctx) => {
94
+ if (value.startsWith("file:")) return { type: "relative", path: value.slice(5) };
95
+ else return { type: "explicit-string", content: value };
96
+ }),
97
+ ContentAnyTextLocal
98
+ ]);
99
+
100
+ // src/block_meta/content_conversion.ts
101
+ function mapRemoteToAbsolute(rootUrl) {
102
+ const rootWithSlash = rootUrl.endsWith("/") ? rootUrl : `${rootUrl}/`;
103
+ return (value) => value.type === "relative" ? { type: "absolute-url", url: rootWithSlash + value.path } : value;
104
+ }
105
+
106
+ // src/block_meta/block_components.ts
107
+ function Workflow(contentType) {
108
+ return z.union([
109
+ // string is converted to v1 workflow
110
+ contentType.transform((value) => ({
111
+ type: "workflow-v1",
112
+ main: value
113
+ })),
114
+ // structured objects are decoded as union with type descriptor
115
+ z.discriminatedUnion("type", [
116
+ z.object({
117
+ type: z.literal("workflow-v1"),
118
+ main: contentType.describe("Main workflow")
119
+ })
120
+ ])
121
+ ]);
122
+ }
123
+ function BlockComponents(wfAndModel, ui) {
124
+ return z.object({
125
+ workflow: wfAndModel,
126
+ model: wfAndModel,
127
+ ui
128
+ });
129
+ }
130
+ var BlockComponentsDescriptionRaw = BlockComponents(z.string(), z.string());
131
+ var BlockComponentsManifest = BlockComponents(ContentRelative, ContentRelative);
132
+ function BlockComponentsAbsoluteUrl(prefix) {
133
+ return BlockComponents(
134
+ ContentRelativeBinary.transform(mapRemoteToAbsolute(prefix)),
135
+ ContentRelativeBinary.transform(mapRemoteToAbsolute(prefix))
136
+ );
137
+ }
138
+ var SemVer = z.string().regex(
139
+ /^(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-]+)*))?$/,
140
+ "Wrong version format, please use valid semver"
141
+ );
142
+
143
+ // src/block_meta/block_pack_id.ts
144
+ var BlockPackId = z.object({
145
+ organization: z.string(),
146
+ name: z.string(),
147
+ version: SemVer
148
+ }).strict();
149
+ var BlockPackIdNoVersion = BlockPackId.omit({ version: true });
150
+ function BlockPackMeta(longString, binary) {
151
+ return z.object({
152
+ title: z.string(),
153
+ description: z.string(),
154
+ longDescription: longString.optional(),
155
+ logo: binary.optional(),
156
+ url: z.string().url().optional(),
157
+ docs: z.string().url().optional(),
158
+ support: z.union([z.string().url(), z.string().email()]).optional(),
159
+ tags: z.array(z.string()).optional(),
160
+ organization: z.object({
161
+ name: z.string(),
162
+ url: z.string().url(),
163
+ logo: binary.optional()
164
+ })
165
+ });
166
+ }
167
+ var BlockPackMetaDescriptionRaw = BlockPackMeta(
168
+ DescriptionContentText,
169
+ DescriptionContentBinary
170
+ );
171
+ var BlockPackMetaManifest = BlockPackMeta(
172
+ ContentRelativeText,
173
+ ContentRelativeBinary
174
+ );
175
+ var BlockPackMetaEmbeddedContent = BlockPackMeta(
176
+ z.string(),
177
+ ContentExplicitBase64
178
+ );
179
+
180
+ // src/block_meta/index.ts
181
+ var BlockPackDescriptionFromPackageJsonRaw = z.object({
182
+ components: BlockComponentsDescriptionRaw,
183
+ meta: BlockPackMetaDescriptionRaw
184
+ });
185
+ function CreateBlockPackDescriptionSchema(components, meta) {
186
+ return z.object({
187
+ id: BlockPackId,
188
+ components,
189
+ meta
190
+ });
191
+ }
192
+ var BlockPackDescriptionManifest = CreateBlockPackDescriptionSchema(
193
+ BlockComponentsManifest,
194
+ BlockPackMetaManifest
195
+ );
196
+ var BlockPackDescriptionRaw = CreateBlockPackDescriptionSchema(
197
+ BlockComponentsDescriptionRaw,
198
+ BlockPackMetaDescriptionRaw
199
+ );
200
+ var BlockPackManifest = BlockPackDescriptionManifest.extend({
201
+ schema: z.literal("v1"),
202
+ files: z.array(z.string())
203
+ });
204
+
205
+ // src/pframe/internal_api/index.ts
206
+ var internal_api_exports = {};
207
+
208
+ export { BlockComponents, BlockComponentsAbsoluteUrl, BlockComponentsDescriptionRaw, BlockComponentsManifest, BlockPackDescriptionFromPackageJsonRaw, BlockPackDescriptionManifest, BlockPackDescriptionRaw, BlockPackId, BlockPackIdNoVersion, BlockPackManifest, BlockPackMeta, BlockPackMetaDescriptionRaw, BlockPackMetaEmbeddedContent, BlockPackMetaManifest, ContentAbsoluteBinaryLocal, ContentAbsoluteBinaryRemote, ContentAbsoluteFile, ContentAbsoluteFolder, ContentAbsoluteTextLocal, ContentAbsoluteTextRemote, ContentAbsoluteUrl, ContentAny, ContentAnyBinaryLocal, ContentAnyLocal, ContentAnyRemote, ContentAnyTextLocal, ContentExplicit, ContentExplicitBase64, ContentExplicitString, ContentRelative, ContentRelativeBinary, ContentRelativeText, CreateBlockPackDescriptionSchema, DescriptionContentBinary, DescriptionContentText, internal_api_exports as PFrameInternal, SemVer, Workflow };
209
+ //# sourceMappingURL=index.js.map
210
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/block_meta/content_types.ts","../src/block_meta/content_conversion.ts","../src/block_meta/block_components.ts","../src/block_meta/semver.ts","../src/block_meta/block_pack_id.ts","../src/block_meta/meta.ts","../src/block_meta/index.ts","../src/pframe/internal_api/index.ts"],"names":["z"],"mappings":";;;AAMa,IAAA,qBAAA,GAAwB,EAClC,MAAO,CAAA;AAAA,EACN,IAAA,EAAM,CAAE,CAAA,OAAA,CAAQ,iBAAiB,CAAA;AAAA,EACjC,OAAS,EAAA,CAAA,CAAE,MAAO,EAAA,CAAE,SAAS,qBAAqB,CAAA;AACpD,CAAC,EACA,MAAO,GAAA;AAGG,IAAA,qBAAA,GAAwB,EAClC,MAAO,CAAA;AAAA,EACN,IAAA,EAAM,CAAE,CAAA,OAAA,CAAQ,iBAAiB,CAAA;AAAA,EACjC,QAAA,EAAU,EACP,MAAO,EAAA,CACP,MAAM,eAAe,CAAA,CACrB,SAA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mBAAA;AAAA,EACA,qBAAA;AACF,EAAA;AAIO,IAAM,4BAA+B,GAAA,aAAA;AAAA,EAC1CA,EAAE,MAAO,EAAA;AAAA,EACT,qBAAA;AACF,EAAA;;;AClCa,IAAA,sCAAA,GAAyCA,EAAE,MAAO,CAAA;AAAA,EAC7D,UAAY,EAAA,6BAAA;AAAA,EACZ,IAAM,EAAA,2BAAA;AACR,CAAC,EAAA;AAEM,SAAS,gCAAA,CACd,YACA,IACA,EAAA;AACA,EAAA,OAAOA,EAAE,MAAO,CAAA;AAAA,IACd,EAAI,EAAA,WAAA;AAAA,IACJ,UAAA;AAAA,IACA,IAAA;AAAA,GACD,CAAA,CAAA;AACH,CAAA;AAEO,IAAM,4BAA+B,GAAA,gCAAA;AAAA,EAC1C,uBAAA;AAAA,EACA,qBAAA;AACF,EAAA;AAGO,IAAM,uBAA0B,GAAA,gCAAA;AAAA,EACrC,6BAAA;AAAA,EACA,2BAAA;AACF,EAAA;AAGa,IAAA,iBAAA,GAAoB,6BAA6B,MAAO,CAAA;AAAA,EACnE,MAAA,EAAQA,CAAE,CAAA,OAAA,CAAQ,IAAI,CAAA;AAAA,EACtB,KAAOA,EAAAA,CAAAA,CAAE,KAAMA,CAAAA,CAAAA,CAAE,QAAQ,CAAA;AAC3B,CAAC,EAAA;;;ACjDD,IAAA,oBAAA,GAAA","file":"index.js","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\nexport const ContentAbsoluteFile = z\n .object({\n type: z.literal('absolute-file'),\n file: z.string().startsWith('/').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 ContentExplicit = z\n .object({\n type: z.literal('explicit'),\n content: z.instanceof(Uint8Array).describe('Raw content')\n })\n .strict();\nexport type ContentExplicit = z.infer<typeof ContentExplicit>;\n\nexport const ContentAbsoluteFolder = z\n .object({\n type: z.literal('absolute-folder'),\n folder: z\n .string()\n .startsWith('/')\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 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, ctx) => ({ 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, ctx) => {\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","import { ContentAbsoluteUrl, ContentAnyLocal, ContentRelative } from \"./content_types\";\n\nexport function mapRemoteToAbsolute(\n rootUrl: string\n): <T extends ContentAnyLocal>(\n value: T\n) => Exclude<T, ContentRelative> | ContentAbsoluteUrl {\n const rootWithSlash = rootUrl.endsWith('/') ? rootUrl : `${rootUrl}/`;\n return <T extends ContentAnyLocal>(value: T) =>\n value.type === 'relative'\n ? { type: 'absolute-url', url: rootWithSlash + value.path }\n : (value as Exclude<T, ContentRelative>);\n}\n","import { z } from 'zod';\nimport { ContentRelative, ContentRelativeBinary } from './content_types';\nimport { mapRemoteToAbsolute } from './content_conversion';\n\nexport type BlockPackComponents = {};\n\nexport function Workflow<const Content extends z.ZodTypeAny>(contentType: Content) {\n return z.union([\n // string is converted to v1 workflow\n contentType.transform((value) => ({\n type: 'workflow-v1',\n main: value\n })),\n // structured objects are decoded as union with type descriptor\n z.discriminatedUnion('type', [\n z.object({\n type: z.literal('workflow-v1'),\n main: contentType.describe('Main workflow')\n })\n ])\n ]);\n}\n\nexport function BlockComponents<\n const WfAndModel extends z.ZodTypeAny,\n const UI extends z.ZodTypeAny\n>(wfAndModel: WfAndModel, ui: UI) {\n return z.object({\n workflow: wfAndModel,\n model: wfAndModel,\n ui\n });\n}\n\nexport const BlockComponentsDescriptionRaw = BlockComponents(z.string(), z.string());\nexport type BlockComponentsDescriptionRaw = z.infer<typeof BlockComponentsDescriptionRaw>;\n\nexport const BlockComponentsManifest = BlockComponents(ContentRelative, ContentRelative);\nexport type BlockComponentsManifest = z.infer<typeof BlockComponentsManifest>;\n\nexport function BlockComponentsAbsoluteUrl(prefix: string) {\n return BlockComponents(\n ContentRelativeBinary.transform(mapRemoteToAbsolute(prefix)),\n ContentRelativeBinary.transform(mapRemoteToAbsolute(prefix))\n );\n}\nexport type BlockComponentsAbsolute = z.infer<ReturnType<typeof BlockComponentsAbsoluteUrl>>;\n","import { z } from 'zod';\n\n// Regex taken from here:\n// https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string\nexport const SemVer = z\n .string()\n .regex(\n /^(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-]+)*))?$/,\n 'Wrong version format, please use valid semver'\n );\n","import { z } from 'zod';\nimport { SemVer } from './semver';\n\n/** Global identifier of the block */\nexport const BlockPackId = z\n .object({\n organization: z.string(),\n name: z.string(),\n version: SemVer\n })\n .strict();\nexport type BlockPackId = z.infer<typeof BlockPackId>;\n\nexport const BlockPackIdNoVersion = BlockPackId.omit({ version: true });\nexport type BlockPackIdNoVersion = z.infer<typeof BlockPackIdNoVersion>;\n","import { z } from 'zod';\nimport {\n ContentAbsoluteBinaryLocal,\n ContentAbsoluteTextLocal,\n ContentExplicitBase64,\n ContentExplicitString,\n ContentRelative,\n ContentRelativeBinary,\n ContentRelativeText,\n DescriptionContentBinary,\n DescriptionContentText\n} from './content_types';\n\nexport function BlockPackMeta<\n const LongStringType extends z.ZodTypeAny,\n const BinaryType extends z.ZodTypeAny\n>(longString: LongStringType, binary: BinaryType) {\n return z.object({\n title: z.string(),\n description: z.string(),\n longDescription: longString.optional(),\n logo: binary.optional(),\n url: z.string().url().optional(),\n docs: z.string().url().optional(),\n support: z.union([z.string().url(), z.string().email()]).optional(),\n tags: z.array(z.string()).optional(),\n organization: z.object({\n name: z.string(),\n url: z.string().url(),\n logo: binary.optional()\n })\n });\n}\n\n// prettier-ignore\nexport const BlockPackMetaDescriptionRaw = BlockPackMeta(\n DescriptionContentText,\n DescriptionContentBinary\n);\nexport type BlockPackMetaDescriptionRaw = z.infer<typeof BlockPackMetaDescriptionRaw>;\n\n// prettier-ignore\nexport const BlockPackMetaManifest = BlockPackMeta(\n ContentRelativeText,\n ContentRelativeBinary\n);\nexport type BlockPackMetaManifest = z.infer<typeof BlockPackMetaManifest>;\n\n// prettier-ignore\nexport const BlockPackMetaEmbeddedContent = BlockPackMeta(\n z.string(),\n ContentExplicitBase64\n);\nexport type BlockPackMetaEmbeddedContent = z.infer<typeof BlockPackMetaEmbeddedContent>;\n","import { ZodTypeAny, z } from 'zod';\nimport {\n BlockComponentsDescriptionRaw,\n BlockComponentsManifest\n} from './block_components';\nimport { BlockPackId } from './block_pack_id';\nimport {\n BlockPackMetaDescriptionRaw,\n BlockPackMetaManifest\n} from './meta';\n\nexport * from './block_components'\nexport * from './block_pack_id'\nexport * from './common'\nexport * from './content_types'\nexport * from './meta'\nexport * from './semver'\n\nexport const BlockPackDescriptionFromPackageJsonRaw = z.object({\n components: BlockComponentsDescriptionRaw,\n meta: BlockPackMetaDescriptionRaw\n});\n\nexport function CreateBlockPackDescriptionSchema<Components extends ZodTypeAny, Meta extends ZodTypeAny>(\n components: Components,\n meta: Meta\n) {\n return z.object({\n id: BlockPackId,\n components,\n meta\n });\n}\n\nexport const BlockPackDescriptionManifest = CreateBlockPackDescriptionSchema(\n BlockComponentsManifest,\n BlockPackMetaManifest\n);\nexport type BlockPackDescriptionManifest = z.infer<typeof BlockPackDescriptionManifest>;\n\nexport const BlockPackDescriptionRaw = CreateBlockPackDescriptionSchema(\n BlockComponentsDescriptionRaw,\n BlockPackMetaDescriptionRaw\n);\nexport type BlockPackDescriptionRaw = z.infer<typeof BlockPackDescriptionRaw>;\n\nexport const BlockPackManifest = BlockPackDescriptionManifest.extend({\n schema: z.literal('v1'),\n files: z.array(z.string())\n});\nexport type BlockPackManifest = z.infer<typeof BlockPackManifest>;\n","export * from './api_read';\nexport * from './api_factory';\nexport * from './common';\nexport * from './create_table';\nexport * from './delete_column';\nexport * from './find_columns';\nexport * from './table';\n\nexport * from './pframe';\n"]}
package/package.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "@milaboratories/pl-model-middle-layer",
3
+ "version": "1.2.16",
4
+ "description": "Common model between middle layer and non-block UI code",
5
+ "type": "module",
6
+ "exports": {
7
+ ".": {
8
+ "types": "./src/index.ts",
9
+ "import": "./dist/index.js",
10
+ "require": "./dist/index.cjs"
11
+ }
12
+ },
13
+ "files": [
14
+ "./dist/**/*",
15
+ "./src/**/*"
16
+ ],
17
+ "dependencies": {
18
+ "zod": "^3.23.8",
19
+ "utility-types": "^3.11.0",
20
+ "@milaboratories/pl-model-common": "^1.3.9"
21
+ },
22
+ "devDependencies": {
23
+ "tsup": "~8.2.4",
24
+ "typescript": "^5.6.2",
25
+ "@milaboratories/platforma-build-configs": "1.0.0"
26
+ },
27
+ "scripts": {
28
+ "build": "tsup"
29
+ }
30
+ }
@@ -0,0 +1,10 @@
1
+ /** Structure to help resolve conflicts if multiple participants writes to
2
+ * the same state */
3
+ export interface AuthorMarker {
4
+ /** Unique identifier of client or even a specific window that sets this
5
+ * particular state */
6
+ authorId: string;
7
+
8
+ /** Sequential version of the state local to the author */
9
+ localVersion: number;
10
+ }
@@ -0,0 +1,47 @@
1
+ import { z } from 'zod';
2
+ import { ContentRelative, ContentRelativeBinary } from './content_types';
3
+ import { mapRemoteToAbsolute } from './content_conversion';
4
+
5
+ export type BlockPackComponents = {};
6
+
7
+ export function Workflow<const Content extends z.ZodTypeAny>(contentType: Content) {
8
+ return z.union([
9
+ // string is converted to v1 workflow
10
+ contentType.transform((value) => ({
11
+ type: 'workflow-v1',
12
+ main: value
13
+ })),
14
+ // structured objects are decoded as union with type descriptor
15
+ z.discriminatedUnion('type', [
16
+ z.object({
17
+ type: z.literal('workflow-v1'),
18
+ main: contentType.describe('Main workflow')
19
+ })
20
+ ])
21
+ ]);
22
+ }
23
+
24
+ export function BlockComponents<
25
+ const WfAndModel extends z.ZodTypeAny,
26
+ const UI extends z.ZodTypeAny
27
+ >(wfAndModel: WfAndModel, ui: UI) {
28
+ return z.object({
29
+ workflow: wfAndModel,
30
+ model: wfAndModel,
31
+ ui
32
+ });
33
+ }
34
+
35
+ export const BlockComponentsDescriptionRaw = BlockComponents(z.string(), z.string());
36
+ export type BlockComponentsDescriptionRaw = z.infer<typeof BlockComponentsDescriptionRaw>;
37
+
38
+ export const BlockComponentsManifest = BlockComponents(ContentRelative, ContentRelative);
39
+ export type BlockComponentsManifest = z.infer<typeof BlockComponentsManifest>;
40
+
41
+ export function BlockComponentsAbsoluteUrl(prefix: string) {
42
+ return BlockComponents(
43
+ ContentRelativeBinary.transform(mapRemoteToAbsolute(prefix)),
44
+ ContentRelativeBinary.transform(mapRemoteToAbsolute(prefix))
45
+ );
46
+ }
47
+ export type BlockComponentsAbsolute = z.infer<ReturnType<typeof BlockComponentsAbsoluteUrl>>;
@@ -0,0 +1,15 @@
1
+ import { z } from 'zod';
2
+ import { SemVer } from './semver';
3
+
4
+ /** Global identifier of the block */
5
+ export const BlockPackId = z
6
+ .object({
7
+ organization: z.string(),
8
+ name: z.string(),
9
+ version: SemVer
10
+ })
11
+ .strict();
12
+ export type BlockPackId = z.infer<typeof BlockPackId>;
13
+
14
+ export const BlockPackIdNoVersion = BlockPackId.omit({ version: true });
15
+ export type BlockPackIdNoVersion = z.infer<typeof BlockPackIdNoVersion>;
@@ -0,0 +1,2 @@
1
+ export type ContextType = 'local' | 'remote';
2
+ export type ContentType = 'text' | 'binary';