@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.
Files changed (31) hide show
  1. package/dist/block_meta/block_components.d.ts +213 -77
  2. package/dist/block_meta/block_components.d.ts.map +1 -1
  3. package/dist/block_meta/block_description.d.ts +872 -0
  4. package/dist/block_meta/block_description.d.ts.map +1 -0
  5. package/dist/block_meta/{block_pack_id.d.ts → block_id.d.ts} +1 -1
  6. package/dist/block_meta/block_id.d.ts.map +1 -0
  7. package/dist/block_meta/block_manifest.d.ts +1245 -0
  8. package/dist/block_meta/block_manifest.d.ts.map +1 -0
  9. package/dist/block_meta/{meta.d.ts → block_meta.d.ts} +1 -167
  10. package/dist/block_meta/block_meta.d.ts.map +1 -0
  11. package/dist/block_meta/content_conversion.d.ts +9 -1
  12. package/dist/block_meta/content_conversion.d.ts.map +1 -1
  13. package/dist/block_meta/content_types.d.ts +40 -5
  14. package/dist/block_meta/content_types.d.ts.map +1 -1
  15. package/dist/block_meta/index.d.ts +6 -1665
  16. package/dist/block_meta/index.d.ts.map +1 -1
  17. package/dist/index.js +1 -1
  18. package/dist/index.js.map +1 -1
  19. package/dist/index.mjs +114 -104
  20. package/dist/index.mjs.map +1 -1
  21. package/package.json +2 -2
  22. package/src/block_meta/block_components.ts +2 -5
  23. package/src/block_meta/block_description.ts +29 -0
  24. package/src/block_meta/block_manifest.ts +38 -0
  25. package/src/block_meta/{meta.ts → block_meta.ts} +0 -13
  26. package/src/block_meta/content_conversion.ts +24 -4
  27. package/src/block_meta/content_types.ts +14 -3
  28. package/src/block_meta/index.ts +6 -52
  29. package/dist/block_meta/block_pack_id.d.ts.map +0 -1
  30. package/dist/block_meta/meta.d.ts.map +0 -1
  31. /package/src/block_meta/{block_pack_id.ts → block_id.ts} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/block_meta/index.ts"],"names":[],"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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAI5B,CAAC;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/block_meta/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC;AAEzB,cAAc,sBAAsB,CAAC;AAErC,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC"}
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("zod"),s=t.z.object({type:t.z.literal("explicit-string"),content:t.z.string().describe("Actual string value")}).strict(),i=t.z.object({type:t.z.literal("explicit-base64"),mimeType:t.z.string().regex(/\w+\/[-+.\w]+/).describe("MIME type to interpret content"),content:t.z.string().base64().describe("Base64 encoded binary value")}).strict(),o=t.z.object({type:t.z.literal("relative"),path:t.z.string().describe("Address of the file, in most cases relative to the file which this structure is a part of")}).strict(),c=t.z.object({type:t.z.literal("absolute-file"),file:t.z.string().startsWith("/").describe("Absolute address of the file in local file system")}).strict(),r=t.z.object({type:t.z.literal("absolute-url"),url:t.z.string().url().describe("Global URL to reach the requested file")}).strict(),M=t.z.object({type:t.z.literal("explicit"),content:t.z.instanceof(Uint8Array).describe("Raw content")}).strict(),w=t.z.object({type:t.z.literal("absolute-folder"),folder:t.z.string().startsWith("/").describe("Absolute address of the folder in local file system")}).strict(),j=t.z.discriminatedUnion("type",[s,i,o,c,r]),v=t.z.discriminatedUnion("type",[s,i,o,c]),D=t.z.discriminatedUnion("type",[s,i,o,r]),y=t.z.discriminatedUnion("type",[i,o,c]),C=t.z.discriminatedUnion("type",[s,o,c]),U=t.z.discriminatedUnion("type",[i,r]),T=t.z.discriminatedUnion("type",[i,c]),L=t.z.discriminatedUnion("type",[s,r]),S=t.z.discriminatedUnion("type",[s,c]),a=t.z.discriminatedUnion("type",[i,o]),f=t.z.discriminatedUnion("type",[s,o]),g=t.z.union([t.z.string().startsWith("file:").transform((e,n)=>({type:"relative",path:e.slice(5)})),y]),B=t.z.union([t.z.string().transform((e,n)=>e.startsWith("file:")?{type:"relative",path:e.slice(5)}:{type:"explicit-string",content:e}),C]);function b(e){const n=e.endsWith("/")?e:`${e}/`;return z=>z.type==="relative"?{type:"absolute-url",url:n+z.path}:z}function F(e){return t.z.union([e.transform(n=>({type:"workflow-v1",main:n})),t.z.discriminatedUnion("type",[t.z.object({type:t.z.literal("workflow-v1"),main:e.describe("Main workflow")})])])}function l(e,n){return t.z.object({workflow:e,model:e,ui:n})}const d=l(t.z.string(),t.z.string()),A=l(o,o);function E(e){return l(a.transform(b(e)),a.transform(b(e)))}const P=t.z.string().regex(/^(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-]+)*))?$/,"Wrong version format, please use valid semver"),u=t.z.object({organization:t.z.string(),name:t.z.string(),version:P}).strict(),W=u.omit({version:!0});function p(e,n){return t.z.object({title:t.z.string(),description:t.z.string(),longDescription:e.optional(),logo:n.optional(),url:t.z.string().url().optional(),docs:t.z.string().url().optional(),support:t.z.union([t.z.string().url(),t.z.string().email()]).optional(),tags:t.z.array(t.z.string()).optional(),organization:t.z.object({name:t.z.string(),url:t.z.string().url(),logo:n.optional()})})}const m=p(B,g),h=p(f,a),I=p(t.z.string(),i),Z=t.z.object({components:d,meta:m});function k(e,n){return t.z.object({id:u,components:e,meta:n})}const x=k(A,h),V=k(d,m),R=t.z.object({name:t.z.string(),size:t.z.number().int(),sha256:t.z.string().regex(/[0-9a-fA-F]/).toUpperCase().length(64)}),_=t.z.object({schema:t.z.literal("v1"),description:x,files:t.z.array(R)}),O=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));exports.BlockComponents=l;exports.BlockComponentsAbsoluteUrl=E;exports.BlockComponentsDescriptionRaw=d;exports.BlockComponentsManifest=A;exports.BlockPackDescriptionFromPackageJsonRaw=Z;exports.BlockPackDescriptionManifest=x;exports.BlockPackDescriptionRaw=V;exports.BlockPackId=u;exports.BlockPackIdNoVersion=W;exports.BlockPackManifest=_;exports.BlockPackMeta=p;exports.BlockPackMetaDescriptionRaw=m;exports.BlockPackMetaEmbeddedContent=I;exports.BlockPackMetaManifest=h;exports.ContentAbsoluteBinaryLocal=T;exports.ContentAbsoluteBinaryRemote=U;exports.ContentAbsoluteFile=c;exports.ContentAbsoluteFolder=w;exports.ContentAbsoluteTextLocal=S;exports.ContentAbsoluteTextRemote=L;exports.ContentAbsoluteUrl=r;exports.ContentAny=j;exports.ContentAnyBinaryLocal=y;exports.ContentAnyLocal=v;exports.ContentAnyRemote=D;exports.ContentAnyTextLocal=C;exports.ContentExplicit=M;exports.ContentExplicitBase64=i;exports.ContentExplicitString=s;exports.ContentRelative=o;exports.ContentRelativeBinary=a;exports.ContentRelativeText=f;exports.CreateBlockPackDescriptionSchema=k;exports.DescriptionContentBinary=g;exports.DescriptionContentText=B;exports.ManifestFileInfo=R;exports.PFrameInternal=O;exports.SemVer=P;exports.Workflow=F;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("zod"),s=t.z.object({type:t.z.literal("explicit-string"),content:t.z.string().describe("Actual string value")}).strict(),i=t.z.object({type:t.z.literal("explicit-base64"),mimeType:t.z.string().regex(/\w+\/[-+.\w]+/).describe("MIME type to interpret content"),content:t.z.string().base64().describe("Base64 encoded binary value")}).strict(),o=t.z.object({type:t.z.literal("relative"),path:t.z.string().describe("Address of the file, in most cases relative to the file which this structure is a part of")}).strict(),r=t.z.object({type:t.z.literal("absolute-file"),file:t.z.string().startsWith("/").describe("Absolute address of the file in local file system")}).strict(),a=t.z.object({type:t.z.literal("absolute-url"),url:t.z.string().url().describe("Global URL to reach the requested file")}).strict(),v=t.z.object({type:t.z.literal("explicit-bytes"),mimeType:t.z.string().regex(/\w+\/[-+.\w]+/).describe("MIME type to interpret content"),content:t.z.instanceof(Uint8Array).describe("Raw content")}).strict(),w=t.z.object({type:t.z.literal("absolute-folder"),folder:t.z.string().startsWith("/").describe("Absolute address of the folder in local file system")}).strict(),j=t.z.discriminatedUnion("type",[s,i,o,r,a]),U=t.z.discriminatedUnion("type",[s,i,o]),D=t.z.discriminatedUnion("type",[s,i,o,r]),T=t.z.discriminatedUnion("type",[s,i,o,a]),b=t.z.discriminatedUnion("type",[i,o,r]),f=t.z.discriminatedUnion("type",[s,o,r]),E=t.z.discriminatedUnion("type",[i,a]),F=t.z.discriminatedUnion("type",[i,r]),S=t.z.discriminatedUnion("type",[s,a]),L=t.z.discriminatedUnion("type",[s,r]),l=t.z.discriminatedUnion("type",[i,o]),C=t.z.discriminatedUnion("type",[s,o]),g=t.z.union([t.z.string().startsWith("file:").transform((e,n)=>({type:"relative",path:e.slice(5)})),b]),B=t.z.union([t.z.string().transform((e,n)=>e.startsWith("file:")?{type:"relative",path:e.slice(5)}:{type:"explicit-string",content:e}),f]),A=t.z.string().regex(/^(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-]+)*))?$/,"Wrong version format, please use valid semver");function d(e){const n=e.endsWith("/")?e:`${e}/`;return c=>c.type==="relative"?{type:"absolute-url",url:n+c.path}:c}function W(e){const n=e.endsWith("/")?e:`${e}/`;return c=>c.type==="relative"?{type:"relative",path:n+c.path}:c}const m=t.z.object({organization:t.z.string(),name:t.z.string(),version:A}).strict(),I=m.omit({version:!0});function P(e){return t.z.union([e.transform(n=>({type:"workflow-v1",main:n})),t.z.discriminatedUnion("type",[t.z.object({type:t.z.literal("workflow-v1"),main:e.describe("Main workflow")})])])}function p(e,n){return t.z.object({workflow:P(e),model:e,ui:n})}const u=p(t.z.string(),t.z.string());function Z(e){return p(l.transform(d(e)),l.transform(d(e)))}function z(e,n){return t.z.object({title:t.z.string(),description:t.z.string(),longDescription:e.optional(),logo:n.optional(),url:t.z.string().url().optional(),docs:t.z.string().url().optional(),support:t.z.union([t.z.string().url(),t.z.string().email()]).optional(),tags:t.z.array(t.z.string()).optional(),organization:t.z.object({name:t.z.string(),url:t.z.string().url(),logo:n.optional()})})}const k=z(B,g),O=z(t.z.string(),i),V=t.z.object({components:u,meta:k});function y(e,n){return t.z.object({id:m,components:e,meta:n})}const _=y(u,k),h=p(o,o),x=z(C,l),R=y(h,x),M=t.z.object({name:t.z.string(),size:t.z.number().int(),sha256:t.z.string().regex(/[0-9a-fA-F]/).toUpperCase().length(64)}),$=t.z.object({schema:t.z.literal("v2"),description:R,files:t.z.array(M)}),q="manifest.json",J=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));exports.BlockComponents=p;exports.BlockComponentsAbsoluteUrl=Z;exports.BlockComponentsDescriptionRaw=u;exports.BlockComponentsManifest=h;exports.BlockPackDescriptionFromPackageJsonRaw=V;exports.BlockPackDescriptionManifest=R;exports.BlockPackDescriptionRaw=_;exports.BlockPackId=m;exports.BlockPackIdNoVersion=I;exports.BlockPackManifest=$;exports.BlockPackManifestFile=q;exports.BlockPackMeta=z;exports.BlockPackMetaDescriptionRaw=k;exports.BlockPackMetaEmbeddedContent=O;exports.BlockPackMetaManifest=x;exports.ContentAbsoluteBinaryLocal=F;exports.ContentAbsoluteBinaryRemote=E;exports.ContentAbsoluteFile=r;exports.ContentAbsoluteFolder=w;exports.ContentAbsoluteTextLocal=L;exports.ContentAbsoluteTextRemote=S;exports.ContentAbsoluteUrl=a;exports.ContentAny=j;exports.ContentAnyBinaryLocal=b;exports.ContentAnyLocal=D;exports.ContentAnyRemote=T;exports.ContentAnyTextLocal=f;exports.ContentExplicitBase64=i;exports.ContentExplicitBytes=v;exports.ContentExplicitOrRelative=U;exports.ContentExplicitString=s;exports.ContentRelative=o;exports.ContentRelativeBinary=l;exports.ContentRelativeText=C;exports.CreateBlockPackDescriptionSchema=y;exports.DescriptionContentBinary=g;exports.DescriptionContentText=B;exports.ManifestFileInfo=M;exports.PFrameInternal=J;exports.SemVer=A;exports.Workflow=P;exports.addPrefixToRelative=W;exports.mapRemoteToAbsolute=d;
2
2
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","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"],"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, string, z } from 'zod';\nimport { BlockComponentsDescriptionRaw, BlockComponentsManifest } from './block_components';\nimport { BlockPackId } from './block_pack_id';\nimport { BlockPackMetaDescriptionRaw, BlockPackMetaManifest } 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<\n Components extends ZodTypeAny,\n Meta extends ZodTypeAny\n>(components: Components, meta: Meta) {\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 ManifestFileInfo = z.object({\n name: z.string(),\n size: z.number().int(),\n sha256: z\n .string()\n .regex(/[0-9a-fA-F]/)\n .toUpperCase()\n .length(64) // 256 / 4 (bits per hex register)\n});\nexport type ManifestFileInfo = z.infer<typeof ManifestFileInfo>;\n\nexport const BlockPackManifest = z.object({\n schema: z.literal('v1'),\n description: BlockPackDescriptionManifest,\n files: z.array(ManifestFileInfo)\n});\nexport type BlockPackManifest = z.infer<typeof BlockPackManifest>;\n"],"names":["ContentExplicitString","z","ContentExplicitBase64","ContentRelative","ContentAbsoluteFile","ContentAbsoluteUrl","ContentExplicit","ContentAbsoluteFolder","ContentAny","ContentAnyLocal","ContentAnyRemote","ContentAnyBinaryLocal","ContentAnyTextLocal","ContentAbsoluteBinaryRemote","ContentAbsoluteBinaryLocal","ContentAbsoluteTextRemote","ContentAbsoluteTextLocal","ContentRelativeBinary","ContentRelativeText","DescriptionContentBinary","value","ctx","DescriptionContentText","mapRemoteToAbsolute","rootUrl","rootWithSlash","Workflow","contentType","BlockComponents","wfAndModel","ui","BlockComponentsDescriptionRaw","BlockComponentsManifest","BlockComponentsAbsoluteUrl","prefix","SemVer","BlockPackId","BlockPackIdNoVersion","BlockPackMeta","longString","binary","BlockPackMetaDescriptionRaw","BlockPackMetaManifest","BlockPackMetaEmbeddedContent","BlockPackDescriptionFromPackageJsonRaw","CreateBlockPackDescriptionSchema","components","meta","BlockPackDescriptionManifest","BlockPackDescriptionRaw","ManifestFileInfo","BlockPackManifest"],"mappings":"uGAMaA,EAAwBC,IAClC,OAAO,CACN,KAAMA,EAAAA,EAAE,QAAQ,iBAAiB,EACjC,QAASA,EAAAA,EAAE,SAAS,SAAS,qBAAqB,CACpD,CAAC,EACA,OAAO,EAGGC,EAAwBD,IAClC,OAAO,CACN,KAAMA,EAAAA,EAAE,QAAQ,iBAAiB,EACjC,SAAUA,IACP,OAAO,EACP,MAAM,eAAe,EACrB,SAAS,gCAAgC,EAC5C,QAASA,EAAE,EAAA,OAAA,EAAS,OAAO,EAAE,SAAS,6BAA6B,CACrE,CAAC,EACA,OAAO,EAGGE,EAAkBF,IAC5B,OAAO,CACN,KAAMA,EAAAA,EAAE,QAAQ,UAAU,EAC1B,KAAMA,EAAAA,EACH,OAAA,EACA,SACC,2FACF,CACJ,CAAC,EACA,OAAO,EAGGG,EAAsBH,IAChC,OAAO,CACN,KAAMA,EAAAA,EAAE,QAAQ,eAAe,EAC/B,KAAMA,IAAE,OAAO,EAAE,WAAW,GAAG,EAAE,SAAS,mDAAmD,CAC/F,CAAC,EACA,OAAO,EAGGI,EAAqBJ,IAC/B,OAAO,CACN,KAAMA,EAAAA,EAAE,QAAQ,cAAc,EAC9B,IAAKA,EAAE,EAAA,OAAA,EAAS,IAAI,EAAE,SAAS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C,KAAMA,IAAE,OAAO,EACf,KAAMA,EAAA,EAAE,OAAO,EAAE,IAAI,EACrB,OAAQA,EAAAA,EACL,OAAA,EACA,MAAM,aAAa,EACnB,YAAA,EACA,OAAO,EAAE,CACd,CAAC,EAGYkD,EAAoBlD,IAAE,OAAO,CACxC,OAAQA,EAAAA,EAAE,QAAQ,IAAI,EACtB,YAAa+C,EACb,MAAO/C,EAAAA,EAAE,MAAMiD,CAAgB,CACjC,CAAC"}
1
+ {"version":3,"file":"index.js","sources":["../src/block_meta/content_types.ts","../src/block_meta/semver.ts","../src/block_meta/content_conversion.ts","../src/block_meta/block_id.ts","../src/block_meta/block_components.ts","../src/block_meta/block_meta.ts","../src/block_meta/block_description.ts","../src/block_meta/block_manifest.ts"],"sourcesContent":["import { z } from 'zod';\n\n//\n// Base content types\n//\n\nexport const ContentExplicitString = z\n .object({\n type: z.literal('explicit-string'),\n content: z.string().describe('Actual string value')\n })\n .strict();\nexport type ContentExplicitString = z.infer<typeof ContentExplicitString>;\n\nexport const ContentExplicitBase64 = z\n .object({\n type: z.literal('explicit-base64'),\n mimeType: z\n .string()\n .regex(/\\w+\\/[-+.\\w]+/)\n .describe('MIME type to interpret content'),\n content: z.string().base64().describe('Base64 encoded binary value')\n })\n .strict();\nexport type ContentExplicitBase64 = z.infer<typeof ContentExplicitBase64>;\n\nexport const ContentRelative = z\n .object({\n type: z.literal('relative'),\n path: z\n .string()\n .describe(\n 'Address of the file, in most cases relative to the file which this structure is a part of'\n )\n })\n .strict();\nexport type ContentRelative = z.infer<typeof ContentRelative>;\n\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 ContentExplicitBytes = z\n .object({\n type: z.literal('explicit-bytes'),\n mimeType: z\n .string()\n .regex(/\\w+\\/[-+.\\w]+/)\n .describe('MIME type to interpret content'),\n content: z.instanceof(Uint8Array).describe('Raw content')\n })\n .strict();\nexport type ContentExplicitBytes = z.infer<typeof ContentExplicitBytes>;\n\nexport const ContentAbsoluteFolder = z\n .object({\n type: z.literal('absolute-folder'),\n folder: z\n .string()\n .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 ContentExplicitOrRelative = z.discriminatedUnion('type', [\n ContentExplicitString,\n ContentExplicitBase64,\n ContentRelative\n]);\nexport type ContentExplicitOrRelative = z.infer<typeof ContentExplicitOrRelative>;\n\nexport const ContentAnyLocal = z.discriminatedUnion('type', [\n ContentExplicitString,\n ContentExplicitBase64,\n ContentRelative,\n ContentAbsoluteFile\n]);\nexport type ContentAnyLocal = z.infer<typeof ContentAnyLocal>;\n\nexport const ContentAnyRemote = z.discriminatedUnion('type', [\n ContentExplicitString,\n ContentExplicitBase64,\n ContentRelative,\n ContentAbsoluteUrl\n]);\nexport type ContentAnyRemote = z.infer<typeof ContentAnyRemote>;\n\n//\n// Narrow types with relative option\n//\n\n// export const ContentAnyBinaryRemote = z.discriminatedUnion('type', [\n// ContentExplicitBase64,\n// ContentRelative,\n// ContentAbsoluteUrl\n// ]);\n// export type ContentAnyBinaryRemote = z.infer<typeof ContentAnyBinaryRemote>;\n\nexport const ContentAnyBinaryLocal = z.discriminatedUnion('type', [\n ContentExplicitBase64,\n ContentRelative,\n ContentAbsoluteFile\n]);\nexport type ContentAnyBinaryLocal = z.infer<typeof ContentAnyBinaryLocal>;\n\n// export const ContentAnyTextRemote = z.discriminatedUnion('type', [\n// ContentExplicitString,\n// ContentRelative,\n// ContentAbsoluteUrl\n// ]);\n// export type ContentAnyTextRemote = z.infer<typeof ContentAnyTextRemote>;\n\nexport const ContentAnyTextLocal = z.discriminatedUnion('type', [\n ContentExplicitString,\n ContentRelative,\n ContentAbsoluteFile\n]);\nexport type ContentAnyTextLocal = z.infer<typeof ContentAnyTextLocal>;\n\n//\n// Narrow absolute types\n//\n\nexport const ContentAbsoluteBinaryRemote = z.discriminatedUnion('type', [\n ContentExplicitBase64,\n ContentAbsoluteUrl\n]);\nexport type ContentAbsoluteBinaryRemote = z.infer<typeof ContentAbsoluteBinaryRemote>;\n\nexport const ContentAbsoluteBinaryLocal = z.discriminatedUnion('type', [\n ContentExplicitBase64,\n ContentAbsoluteFile\n]);\nexport type ContentAbsoluteBinaryLocal = z.infer<typeof ContentAbsoluteBinaryLocal>;\n\nexport const ContentAbsoluteTextRemote = z.discriminatedUnion('type', [\n ContentExplicitString,\n ContentAbsoluteUrl\n]);\nexport type ContentAbsoluteTextRemote = z.infer<typeof ContentAbsoluteTextRemote>;\n\nexport const ContentAbsoluteTextLocal = z.discriminatedUnion('type', [\n ContentExplicitString,\n ContentAbsoluteFile\n]);\nexport type ContentAbsoluteTextLocal = z.infer<typeof ContentAbsoluteTextLocal>;\n\n//\n// Narrow relative types\n//\n\nexport const ContentRelativeBinary = z.discriminatedUnion('type', [\n ContentExplicitBase64,\n ContentRelative\n]);\nexport type ContentRelativeBinary = z.infer<typeof ContentRelativeBinary>;\n\nexport const ContentRelativeText = z.discriminatedUnion('type', [\n ContentExplicitString,\n ContentRelative\n]);\nexport type ContentRelativeText = z.infer<typeof ContentRelativeText>;\n\n// export function ConstructContent(\n// contentType: 'text',\n// contextType: 'local'\n// ): typeof ContentAnyTextLocal;\n// export function ConstructContent(\n// contentType: 'text',\n// contextType: 'remote'\n// ): typeof ContentAnyTextRemote;\n// export function ConstructContent(\n// contentType: 'binary',\n// contextType: 'local'\n// ): typeof ContentAnyBinaryLocal;\n// export function ConstructContent(\n// contentType: 'binary',\n// contextType: 'remote'\n// ): typeof ContentAnyBinaryRemote;\n// export function ConstructContent(\n// contentType: ContentType,\n// contextType: ContextType\n// ):\n// | typeof ContentAnyTextLocal\n// | typeof ContentAnyTextRemote\n// | typeof ContentAnyBinaryLocal\n// | typeof ContentAnyBinaryRemote;\n// export function ConstructContent(contentType: ContentType, contextType: ContextType) {\n// return contentType === 'text'\n// ? contextType === 'local'\n// ? ContentAnyTextLocal\n// : ContentAnyTextRemote\n// : contextType === 'local'\n// ? ContentAnyBinaryLocal\n// : ContentAnyBinaryRemote;\n// }\n\nexport const DescriptionContentBinary = z.union([\n z\n .string()\n .startsWith('file:')\n .transform<ContentRelativeBinary>((value, 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 { 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 {\n ContentAbsoluteUrl,\n ContentAnyLocal,\n ContentExplicitOrRelative,\n ContentRelative\n} from './content_types';\n\nexport function mapRemoteToAbsolute(\n rootUrl: string\n): <T extends ContentAnyLocal>(value: T) => 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\n/**\n * Creates transformer of relative content paths, that adds a specific prefix to the relative path.\n *\n * If prefix = \"nested-path/\", paths like \"somefile.txt\" will be transformed to \"nested-path/somefile.txt\".\n *\n * @param prefix prefix to add to the relaive path, slesh at the end will be added automatically if missed\n */\nexport function addPrefixToRelative(\n prefix: string\n): <T extends ContentExplicitOrRelative>(value: T) => T {\n const prefixWithSlash = prefix.endsWith('/') ? prefix : `${prefix}/`;\n return <T extends ContentExplicitOrRelative>(value: T) =>\n (value.type === 'relative'\n ? { type: 'relative', path: prefixWithSlash + value.path }\n : value) as T;\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 { 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: 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 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';\nimport {\n ContentExplicitBase64,\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 BlockPackMetaEmbeddedContent = BlockPackMeta(\n z.string(),\n ContentExplicitBase64\n);\nexport type BlockPackMetaEmbeddedContent = z.infer<typeof BlockPackMetaEmbeddedContent>;\n","import { z, ZodTypeAny } from 'zod';\nimport { BlockComponentsDescriptionRaw } from './block_components';\nimport { BlockPackMetaDescriptionRaw } from './block_meta';\nimport { BlockPackId } from './block_id';\n\n/** Description, as appears in root block package.json file,\n * `file:` references are parsed into relative content of corresponding type, depending on the context,\n * strings are converted to explicit content type. */\nexport const BlockPackDescriptionFromPackageJsonRaw = z.object({\n components: BlockComponentsDescriptionRaw,\n meta: BlockPackMetaDescriptionRaw\n});\n\nexport function CreateBlockPackDescriptionSchema<\n Components extends ZodTypeAny,\n Meta extends ZodTypeAny\n>(components: Components, meta: Meta) {\n return z.object({\n id: BlockPackId,\n components,\n meta\n });\n}\n\nexport const BlockPackDescriptionRaw = CreateBlockPackDescriptionSchema(\n BlockComponentsDescriptionRaw,\n BlockPackMetaDescriptionRaw\n);\nexport type BlockPackDescriptionRaw = z.infer<typeof BlockPackDescriptionRaw>;\n","import { z } from 'zod';\nimport { BlockComponents } from './block_components';\nimport { ContentRelative, ContentRelativeBinary, ContentRelativeText } from './content_types';\nimport { CreateBlockPackDescriptionSchema } from './block_description';\nimport { BlockPackMeta } from './block_meta';\n\nexport const BlockComponentsManifest = BlockComponents(ContentRelative, ContentRelative);\nexport type BlockComponentsManifest = z.infer<typeof BlockComponentsManifest>;\n\nexport const BlockPackMetaManifest = BlockPackMeta(ContentRelativeText, ContentRelativeBinary);\nexport type BlockPackMetaManifest = z.infer<typeof BlockPackMetaManifest>;\n\n/** Block description to be used in block manifest */\nexport const BlockPackDescriptionManifest = CreateBlockPackDescriptionSchema(\n BlockComponentsManifest,\n BlockPackMetaManifest\n);\nexport type BlockPackDescriptionManifest = z.infer<typeof BlockPackDescriptionManifest>;\n\nexport const ManifestFileInfo = z.object({\n name: z.string(),\n size: z.number().int(),\n sha256: z\n .string()\n .regex(/[0-9a-fA-F]/)\n .toUpperCase()\n .length(64) // 256 / 4 (bits per hex register)\n});\nexport type ManifestFileInfo = z.infer<typeof ManifestFileInfo>;\n\nexport const BlockPackManifest = z.object({\n schema: z.literal('v2'),\n description: BlockPackDescriptionManifest,\n files: z.array(ManifestFileInfo)\n});\nexport type BlockPackManifest = z.infer<typeof BlockPackManifest>;\n\nexport const BlockPackManifestFile = 'manifest.json';\n"],"names":["ContentExplicitString","z","ContentExplicitBase64","ContentRelative","ContentAbsoluteFile","ContentAbsoluteUrl","ContentExplicitBytes","ContentAbsoluteFolder","ContentAny","ContentExplicitOrRelative","ContentAnyLocal","ContentAnyRemote","ContentAnyBinaryLocal","ContentAnyTextLocal","ContentAbsoluteBinaryRemote","ContentAbsoluteBinaryLocal","ContentAbsoluteTextRemote","ContentAbsoluteTextLocal","ContentRelativeBinary","ContentRelativeText","DescriptionContentBinary","value","ctx","DescriptionContentText","SemVer","mapRemoteToAbsolute","rootUrl","rootWithSlash","addPrefixToRelative","prefix","prefixWithSlash","BlockPackId","BlockPackIdNoVersion","Workflow","contentType","BlockComponents","wfAndModel","ui","BlockComponentsDescriptionRaw","BlockComponentsAbsoluteUrl","BlockPackMeta","longString","binary","BlockPackMetaDescriptionRaw","BlockPackMetaEmbeddedContent","BlockPackDescriptionFromPackageJsonRaw","CreateBlockPackDescriptionSchema","components","meta","BlockPackDescriptionRaw","BlockComponentsManifest","BlockPackMetaManifest","BlockPackDescriptionManifest","ManifestFileInfo","BlockPackManifest","BlockPackManifestFile"],"mappings":"uGAMaA,EAAwBC,IAClC,OAAO,CACN,KAAMA,EAAAA,EAAE,QAAQ,iBAAiB,EACjC,QAASA,EAAAA,EAAE,SAAS,SAAS,qBAAqB,CACpD,CAAC,EACA,OAAO,EAGGC,EAAwBD,IAClC,OAAO,CACN,KAAMA,EAAAA,EAAE,QAAQ,iBAAiB,EACjC,SAAUA,IACP,OAAO,EACP,MAAM,eAAe,EACrB,SAAS,gCAAgC,EAC5C,QAASA,EAAE,EAAA,OAAA,EAAS,OAAO,EAAE,SAAS,6BAA6B,CACrE,CAAC,EACA,OAAO,EAGGE,EAAkBF,IAC5B,OAAO,CACN,KAAMA,EAAAA,EAAE,QAAQ,UAAU,EAC1B,KAAMA,EAAAA,EACH,OAAA,EACA,SACC,2FACF,CACJ,CAAC,EACA,OAAO,EAGGG,EAAsBH,IAChC,OAAO,CACN,KAAMA,EAAAA,EAAE,QAAQ,eAAe,EAC/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,OAAO,EAAE,IAAI,EACpB,KAAMyC,EAAO,SAAS,CAAA,CACvB,CAAA,CACF,CACH,CAGO,MAAMC,EAA8BH,EACzCjB,EACAH,CACF,EAIawB,EAA+BJ,EAC1CvC,EAAAA,EAAE,OAAO,EACTC,CACF,EC/Ba2C,EAAyC5C,IAAE,OAAO,CAC7D,WAAYqC,EACZ,KAAMK,CACR,CAAC,EAEe,SAAAG,EAGdC,EAAwBC,EAAY,CACpC,OAAO/C,EAAAA,EAAE,OAAO,CACd,GAAI8B,EACJ,WAAAgB,EACA,KAAAC,CAAA,CACD,CACH,CAEO,MAAMC,EAA0BH,EACrCR,EACAK,CACF,ECrBaO,EAA0Bf,EAAgBhC,EAAiBA,CAAe,EAG1EgD,EAAwBX,EAAcrB,EAAqBD,CAAqB,EAIhFkC,EAA+BN,EAC1CI,EACAC,CACF,EAGaE,EAAmBpD,IAAE,OAAO,CACvC,KAAMA,IAAE,OAAO,EACf,KAAMA,EAAA,EAAE,OAAO,EAAE,IAAI,EACrB,OAAQA,EAAAA,EACL,OAAA,EACA,MAAM,aAAa,EACnB,YAAA,EACA,OAAO,EAAE,CACd,CAAC,EAGYqD,EAAoBrD,IAAE,OAAO,CACxC,OAAQA,EAAAA,EAAE,QAAQ,IAAI,EACtB,YAAamD,EACb,MAAOnD,EAAAA,EAAE,MAAMoD,CAAgB,CACjC,CAAC,EAGYE,EAAwB"}
package/dist/index.mjs CHANGED
@@ -2,81 +2,98 @@ import { z as t } from "zod";
2
2
  const s = t.object({
3
3
  type: t.literal("explicit-string"),
4
4
  content: t.string().describe("Actual string value")
5
- }).strict(), i = t.object({
5
+ }).strict(), o = t.object({
6
6
  type: t.literal("explicit-base64"),
7
7
  mimeType: t.string().regex(/\w+\/[-+.\w]+/).describe("MIME type to interpret content"),
8
8
  content: t.string().base64().describe("Base64 encoded binary value")
9
- }).strict(), o = t.object({
9
+ }).strict(), i = t.object({
10
10
  type: t.literal("relative"),
11
11
  path: t.string().describe(
12
12
  "Address of the file, in most cases relative to the file which this structure is a part of"
13
13
  )
14
- }).strict(), r = t.object({
14
+ }).strict(), c = t.object({
15
15
  type: t.literal("absolute-file"),
16
16
  file: t.string().startsWith("/").describe("Absolute address of the file in local file system")
17
- }).strict(), c = t.object({
17
+ }).strict(), a = t.object({
18
18
  type: t.literal("absolute-url"),
19
19
  url: t.string().url().describe("Global URL to reach the requested file")
20
- }).strict(), P = t.object({
21
- type: t.literal("explicit"),
20
+ }).strict(), M = t.object({
21
+ type: t.literal("explicit-bytes"),
22
+ mimeType: t.string().regex(/\w+\/[-+.\w]+/).describe("MIME type to interpret content"),
22
23
  content: t.instanceof(Uint8Array).describe("Raw content")
23
24
  }).strict(), R = t.object({
24
25
  type: t.literal("absolute-folder"),
25
26
  folder: t.string().startsWith("/").describe("Absolute address of the folder in local file system")
26
- }).strict(), M = t.discriminatedUnion("type", [
27
+ }).strict(), z = t.discriminatedUnion("type", [
27
28
  s,
28
- i,
29
29
  o,
30
- r,
31
- c
32
- ]), z = t.discriminatedUnion("type", [
33
- s,
34
30
  i,
31
+ c,
32
+ a
33
+ ]), W = t.discriminatedUnion("type", [
34
+ s,
35
35
  o,
36
- r
36
+ i
37
37
  ]), D = t.discriminatedUnion("type", [
38
38
  s,
39
- i,
40
39
  o,
40
+ i,
41
41
  c
42
- ]), y = t.discriminatedUnion("type", [
42
+ ]), T = t.discriminatedUnion("type", [
43
+ s,
44
+ o,
43
45
  i,
46
+ a
47
+ ]), g = t.discriminatedUnion("type", [
44
48
  o,
45
- r
49
+ i,
50
+ c
46
51
  ]), k = t.discriminatedUnion("type", [
47
52
  s,
48
- o,
49
- r
50
- ]), W = t.discriminatedUnion("type", [
51
53
  i,
52
54
  c
53
- ]), T = t.discriminatedUnion("type", [
54
- i,
55
- r
55
+ ]), E = t.discriminatedUnion("type", [
56
+ o,
57
+ a
56
58
  ]), F = t.discriminatedUnion("type", [
57
- s,
59
+ o,
58
60
  c
59
- ]), L = t.discriminatedUnion("type", [
61
+ ]), S = t.discriminatedUnion("type", [
62
+ s,
63
+ a
64
+ ]), I = t.discriminatedUnion("type", [
60
65
  s,
61
- r
66
+ c
62
67
  ]), l = t.discriminatedUnion("type", [
63
- i,
64
- o
65
- ]), C = t.discriminatedUnion("type", [
68
+ o,
69
+ i
70
+ ]), h = t.discriminatedUnion("type", [
66
71
  s,
67
- o
68
- ]), A = t.union([
72
+ i
73
+ ]), C = t.union([
69
74
  t.string().startsWith("file:").transform((e, n) => ({ type: "relative", path: e.slice(5) })),
70
- y
71
- ]), h = t.union([
75
+ g
76
+ ]), A = t.union([
72
77
  t.string().transform((e, n) => e.startsWith("file:") ? { type: "relative", path: e.slice(5) } : { type: "explicit-string", content: e }),
73
78
  k
74
- ]);
79
+ ]), B = t.string().regex(
80
+ /^(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-]+)*))?$/,
81
+ "Wrong version format, please use valid semver"
82
+ );
75
83
  function m(e) {
76
84
  const n = e.endsWith("/") ? e : `${e}/`;
77
- return (a) => a.type === "relative" ? { type: "absolute-url", url: n + a.path } : a;
85
+ return (r) => r.type === "relative" ? { type: "absolute-url", url: n + r.path } : r;
86
+ }
87
+ function L(e) {
88
+ const n = e.endsWith("/") ? e : `${e}/`;
89
+ return (r) => r.type === "relative" ? { type: "relative", path: n + r.path } : r;
78
90
  }
79
- function S(e) {
91
+ const u = t.object({
92
+ organization: t.string(),
93
+ name: t.string(),
94
+ version: B
95
+ }).strict(), Z = u.omit({ version: !0 });
96
+ function x(e) {
80
97
  return t.union([
81
98
  // string is converted to v1 workflow
82
99
  e.transform((n) => ({
@@ -94,26 +111,18 @@ function S(e) {
94
111
  }
95
112
  function p(e, n) {
96
113
  return t.object({
97
- workflow: e,
114
+ workflow: x(e),
98
115
  model: e,
99
116
  ui: n
100
117
  });
101
118
  }
102
- const u = p(t.string(), t.string()), B = p(o, o);
103
- function Z(e) {
119
+ const y = p(t.string(), t.string());
120
+ function _(e) {
104
121
  return p(
105
122
  l.transform(m(e)),
106
123
  l.transform(m(e))
107
124
  );
108
125
  }
109
- const j = t.string().regex(
110
- /^(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-]+)*))?$/,
111
- "Wrong version format, please use valid semver"
112
- ), b = t.object({
113
- organization: t.string(),
114
- name: t.string(),
115
- version: j
116
- }).strict(), E = b.omit({ version: !0 });
117
126
  function d(e, n) {
118
127
  return t.object({
119
128
  title: t.string(),
@@ -131,83 +140,84 @@ function d(e, n) {
131
140
  })
132
141
  });
133
142
  }
134
- const f = d(
135
- h,
136
- A
137
- ), x = d(
138
- C,
139
- l
140
- ), I = d(
143
+ const b = d(
144
+ A,
145
+ C
146
+ ), O = d(
141
147
  t.string(),
142
- i
143
- ), _ = t.object({
144
- components: u,
145
- meta: f
148
+ o
149
+ ), $ = t.object({
150
+ components: y,
151
+ meta: b
146
152
  });
147
- function g(e, n) {
153
+ function f(e, n) {
148
154
  return t.object({
149
- id: b,
155
+ id: u,
150
156
  components: e,
151
157
  meta: n
152
158
  });
153
159
  }
154
- const w = g(
155
- B,
156
- x
157
- ), O = g(
158
- u,
159
- f
160
- ), v = t.object({
160
+ const V = f(
161
+ y,
162
+ b
163
+ ), j = p(i, i), w = d(h, l), v = f(
164
+ j,
165
+ w
166
+ ), P = t.object({
161
167
  name: t.string(),
162
168
  size: t.number().int(),
163
169
  sha256: t.string().regex(/[0-9a-fA-F]/).toUpperCase().length(64)
164
170
  // 256 / 4 (bits per hex register)
165
- }), V = t.object({
166
- schema: t.literal("v1"),
167
- description: w,
168
- files: t.array(v)
169
- }), $ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
171
+ }), q = t.object({
172
+ schema: t.literal("v2"),
173
+ description: v,
174
+ files: t.array(P)
175
+ }), G = "manifest.json", J = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
170
176
  __proto__: null
171
177
  }, Symbol.toStringTag, { value: "Module" }));
172
178
  export {
173
179
  p as BlockComponents,
174
- Z as BlockComponentsAbsoluteUrl,
175
- u as BlockComponentsDescriptionRaw,
176
- B as BlockComponentsManifest,
177
- _ as BlockPackDescriptionFromPackageJsonRaw,
178
- w as BlockPackDescriptionManifest,
179
- O as BlockPackDescriptionRaw,
180
- b as BlockPackId,
181
- E as BlockPackIdNoVersion,
182
- V as BlockPackManifest,
180
+ _ as BlockComponentsAbsoluteUrl,
181
+ y as BlockComponentsDescriptionRaw,
182
+ j as BlockComponentsManifest,
183
+ $ as BlockPackDescriptionFromPackageJsonRaw,
184
+ v as BlockPackDescriptionManifest,
185
+ V as BlockPackDescriptionRaw,
186
+ u as BlockPackId,
187
+ Z as BlockPackIdNoVersion,
188
+ q as BlockPackManifest,
189
+ G as BlockPackManifestFile,
183
190
  d as BlockPackMeta,
184
- f as BlockPackMetaDescriptionRaw,
185
- I as BlockPackMetaEmbeddedContent,
186
- x as BlockPackMetaManifest,
187
- T as ContentAbsoluteBinaryLocal,
188
- W as ContentAbsoluteBinaryRemote,
189
- r as ContentAbsoluteFile,
191
+ b as BlockPackMetaDescriptionRaw,
192
+ O as BlockPackMetaEmbeddedContent,
193
+ w as BlockPackMetaManifest,
194
+ F as ContentAbsoluteBinaryLocal,
195
+ E as ContentAbsoluteBinaryRemote,
196
+ c as ContentAbsoluteFile,
190
197
  R as ContentAbsoluteFolder,
191
- L as ContentAbsoluteTextLocal,
192
- F as ContentAbsoluteTextRemote,
193
- c as ContentAbsoluteUrl,
194
- M as ContentAny,
195
- y as ContentAnyBinaryLocal,
196
- z as ContentAnyLocal,
197
- D as ContentAnyRemote,
198
+ I as ContentAbsoluteTextLocal,
199
+ S as ContentAbsoluteTextRemote,
200
+ a as ContentAbsoluteUrl,
201
+ z as ContentAny,
202
+ g as ContentAnyBinaryLocal,
203
+ D as ContentAnyLocal,
204
+ T as ContentAnyRemote,
198
205
  k as ContentAnyTextLocal,
199
- P as ContentExplicit,
200
- i as ContentExplicitBase64,
206
+ o as ContentExplicitBase64,
207
+ M as ContentExplicitBytes,
208
+ W as ContentExplicitOrRelative,
201
209
  s as ContentExplicitString,
202
- o as ContentRelative,
210
+ i as ContentRelative,
203
211
  l as ContentRelativeBinary,
204
- C as ContentRelativeText,
205
- g as CreateBlockPackDescriptionSchema,
206
- A as DescriptionContentBinary,
207
- h as DescriptionContentText,
208
- v as ManifestFileInfo,
209
- $ as PFrameInternal,
210
- j as SemVer,
211
- S as Workflow
212
+ h as ContentRelativeText,
213
+ f as CreateBlockPackDescriptionSchema,
214
+ C as DescriptionContentBinary,
215
+ A as DescriptionContentText,
216
+ P as ManifestFileInfo,
217
+ J as PFrameInternal,
218
+ B as SemVer,
219
+ x as Workflow,
220
+ L as addPrefixToRelative,
221
+ m as mapRemoteToAbsolute
212
222
  };
213
223
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","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"],"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, string, z } from 'zod';\nimport { BlockComponentsDescriptionRaw, BlockComponentsManifest } from './block_components';\nimport { BlockPackId } from './block_pack_id';\nimport { BlockPackMetaDescriptionRaw, BlockPackMetaManifest } 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<\n Components extends ZodTypeAny,\n Meta extends ZodTypeAny\n>(components: Components, meta: Meta) {\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 ManifestFileInfo = z.object({\n name: z.string(),\n size: z.number().int(),\n sha256: z\n .string()\n .regex(/[0-9a-fA-F]/)\n .toUpperCase()\n .length(64) // 256 / 4 (bits per hex register)\n});\nexport type ManifestFileInfo = z.infer<typeof ManifestFileInfo>;\n\nexport const BlockPackManifest = z.object({\n schema: z.literal('v1'),\n description: BlockPackDescriptionManifest,\n files: z.array(ManifestFileInfo)\n});\nexport type BlockPackManifest = z.infer<typeof BlockPackManifest>;\n"],"names":["ContentExplicitString","z","ContentExplicitBase64","ContentRelative","ContentAbsoluteFile","ContentAbsoluteUrl","ContentExplicit","ContentAbsoluteFolder","ContentAny","ContentAnyLocal","ContentAnyRemote","ContentAnyBinaryLocal","ContentAnyTextLocal","ContentAbsoluteBinaryRemote","ContentAbsoluteBinaryLocal","ContentAbsoluteTextRemote","ContentAbsoluteTextLocal","ContentRelativeBinary","ContentRelativeText","DescriptionContentBinary","value","ctx","DescriptionContentText","mapRemoteToAbsolute","rootUrl","rootWithSlash","Workflow","contentType","BlockComponents","wfAndModel","ui","BlockComponentsDescriptionRaw","BlockComponentsManifest","BlockComponentsAbsoluteUrl","prefix","SemVer","BlockPackId","BlockPackIdNoVersion","BlockPackMeta","longString","binary","BlockPackMetaDescriptionRaw","BlockPackMetaManifest","BlockPackMetaEmbeddedContent","BlockPackDescriptionFromPackageJsonRaw","CreateBlockPackDescriptionSchema","components","meta","BlockPackDescriptionManifest","BlockPackDescriptionRaw","ManifestFileInfo","BlockPackManifest"],"mappings":";AAMa,MAAAA,IAAwBC,EAClC,OAAO;AAAA,EACN,MAAMA,EAAE,QAAQ,iBAAiB;AAAA,EACjC,SAASA,EAAE,SAAS,SAAS,qBAAqB;AACpD,CAAC,EACA,OAAO,GAGGC,IAAwBD,EAClC,OAAO;AAAA,EACN,MAAMA,EAAE,QAAQ,iBAAiB;AAAA,EACjC,UAAUA,EACP,OAAO,EACP,MAAM,eAAe,EACrB,SAAS,gCAAgC;AAAA,EAC5C,SAASA,EAAE,OAAA,EAAS,OAAO,EAAE,SAAS,6BAA6B;AACrE,CAAC,EACA,OAAO,GAGGE,IAAkBF,EAC5B,OAAO;AAAA,EACN,MAAMA,EAAE,QAAQ,UAAU;AAAA,EAC1B,MAAMA,EACH,OAAA,EACA;AAAA,IACC;AAAA,EACF;AACJ,CAAC,EACA,OAAO,GAGGG,IAAsBH,EAChC,OAAO;AAAA,EACN,MAAMA,EAAE,QAAQ,eAAe;AAAA,EAC/B,MAAMA,EAAE,OAAO,EAAE,WAAW,GAAG,EAAE,SAAS,mDAAmD;AAC/F,CAAC,EACA,OAAO,GAGGI,IAAqBJ,EAC/B,OAAO;AAAA,EACN,MAAMA,EAAE,QAAQ,cAAc;AAAA,EAC9B,K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,EAAE,OAAO;AAAA,EACTC;AACF,GCxCa0C,IAAyC3C,EAAE,OAAO;AAAA,EAC7D,YAAY8B;AAAA,EACZ,MAAMU;AACR,CAAC;AAEe,SAAAI,EAGdC,GAAwBC,GAAY;AACpC,SAAO9C,EAAE,OAAO;AAAA,IACd,IAAImC;AAAA,IACJ,YAAAU;AAAA,IACA,MAAAC;AAAA,EAAA,CACD;AACH;AAEO,MAAMC,IAA+BH;AAAA,EAC1Cb;AAAA,EACAU;AACF,GAGaO,IAA0BJ;AAAA,EACrCd;AAAA,EACAU;AACF,GAGaS,IAAmBjD,EAAE,OAAO;AAAA,EACvC,MAAMA,EAAE,OAAO;AAAA,EACf,MAAMA,EAAE,OAAO,EAAE,IAAI;AAAA,EACrB,QAAQA,EACL,OAAA,EACA,MAAM,aAAa,EACnB,YAAA,EACA,OAAO,EAAE;AAAA;AACd,CAAC,GAGYkD,IAAoBlD,EAAE,OAAO;AAAA,EACxC,QAAQA,EAAE,QAAQ,IAAI;AAAA,EACtB,aAAa+C;AAAA,EACb,OAAO/C,EAAE,MAAMiD,CAAgB;AACjC,CAAC;;;"}
1
+ {"version":3,"file":"index.mjs","sources":["../src/block_meta/content_types.ts","../src/block_meta/semver.ts","../src/block_meta/content_conversion.ts","../src/block_meta/block_id.ts","../src/block_meta/block_components.ts","../src/block_meta/block_meta.ts","../src/block_meta/block_description.ts","../src/block_meta/block_manifest.ts"],"sourcesContent":["import { z } from 'zod';\n\n//\n// Base content types\n//\n\nexport const ContentExplicitString = z\n .object({\n type: z.literal('explicit-string'),\n content: z.string().describe('Actual string value')\n })\n .strict();\nexport type ContentExplicitString = z.infer<typeof ContentExplicitString>;\n\nexport const ContentExplicitBase64 = z\n .object({\n type: z.literal('explicit-base64'),\n mimeType: z\n .string()\n .regex(/\\w+\\/[-+.\\w]+/)\n .describe('MIME type to interpret content'),\n content: z.string().base64().describe('Base64 encoded binary value')\n })\n .strict();\nexport type ContentExplicitBase64 = z.infer<typeof ContentExplicitBase64>;\n\nexport const ContentRelative = z\n .object({\n type: z.literal('relative'),\n path: z\n .string()\n .describe(\n 'Address of the file, in most cases relative to the file which this structure is a part of'\n )\n })\n .strict();\nexport type ContentRelative = z.infer<typeof ContentRelative>;\n\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 ContentExplicitBytes = z\n .object({\n type: z.literal('explicit-bytes'),\n mimeType: z\n .string()\n .regex(/\\w+\\/[-+.\\w]+/)\n .describe('MIME type to interpret content'),\n content: z.instanceof(Uint8Array).describe('Raw content')\n })\n .strict();\nexport type ContentExplicitBytes = z.infer<typeof ContentExplicitBytes>;\n\nexport const ContentAbsoluteFolder = z\n .object({\n type: z.literal('absolute-folder'),\n folder: z\n .string()\n .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 ContentExplicitOrRelative = z.discriminatedUnion('type', [\n ContentExplicitString,\n ContentExplicitBase64,\n ContentRelative\n]);\nexport type ContentExplicitOrRelative = z.infer<typeof ContentExplicitOrRelative>;\n\nexport const ContentAnyLocal = z.discriminatedUnion('type', [\n ContentExplicitString,\n ContentExplicitBase64,\n ContentRelative,\n ContentAbsoluteFile\n]);\nexport type ContentAnyLocal = z.infer<typeof ContentAnyLocal>;\n\nexport const ContentAnyRemote = z.discriminatedUnion('type', [\n ContentExplicitString,\n ContentExplicitBase64,\n ContentRelative,\n ContentAbsoluteUrl\n]);\nexport type ContentAnyRemote = z.infer<typeof ContentAnyRemote>;\n\n//\n// Narrow types with relative option\n//\n\n// export const ContentAnyBinaryRemote = z.discriminatedUnion('type', [\n// ContentExplicitBase64,\n// ContentRelative,\n// ContentAbsoluteUrl\n// ]);\n// export type ContentAnyBinaryRemote = z.infer<typeof ContentAnyBinaryRemote>;\n\nexport const ContentAnyBinaryLocal = z.discriminatedUnion('type', [\n ContentExplicitBase64,\n ContentRelative,\n ContentAbsoluteFile\n]);\nexport type ContentAnyBinaryLocal = z.infer<typeof ContentAnyBinaryLocal>;\n\n// export const ContentAnyTextRemote = z.discriminatedUnion('type', [\n// ContentExplicitString,\n// ContentRelative,\n// ContentAbsoluteUrl\n// ]);\n// export type ContentAnyTextRemote = z.infer<typeof ContentAnyTextRemote>;\n\nexport const ContentAnyTextLocal = z.discriminatedUnion('type', [\n ContentExplicitString,\n ContentRelative,\n ContentAbsoluteFile\n]);\nexport type ContentAnyTextLocal = z.infer<typeof ContentAnyTextLocal>;\n\n//\n// Narrow absolute types\n//\n\nexport const ContentAbsoluteBinaryRemote = z.discriminatedUnion('type', [\n ContentExplicitBase64,\n ContentAbsoluteUrl\n]);\nexport type ContentAbsoluteBinaryRemote = z.infer<typeof ContentAbsoluteBinaryRemote>;\n\nexport const ContentAbsoluteBinaryLocal = z.discriminatedUnion('type', [\n ContentExplicitBase64,\n ContentAbsoluteFile\n]);\nexport type ContentAbsoluteBinaryLocal = z.infer<typeof ContentAbsoluteBinaryLocal>;\n\nexport const ContentAbsoluteTextRemote = z.discriminatedUnion('type', [\n ContentExplicitString,\n ContentAbsoluteUrl\n]);\nexport type ContentAbsoluteTextRemote = z.infer<typeof ContentAbsoluteTextRemote>;\n\nexport const ContentAbsoluteTextLocal = z.discriminatedUnion('type', [\n ContentExplicitString,\n ContentAbsoluteFile\n]);\nexport type ContentAbsoluteTextLocal = z.infer<typeof ContentAbsoluteTextLocal>;\n\n//\n// Narrow relative types\n//\n\nexport const ContentRelativeBinary = z.discriminatedUnion('type', [\n ContentExplicitBase64,\n ContentRelative\n]);\nexport type ContentRelativeBinary = z.infer<typeof ContentRelativeBinary>;\n\nexport const ContentRelativeText = z.discriminatedUnion('type', [\n ContentExplicitString,\n ContentRelative\n]);\nexport type ContentRelativeText = z.infer<typeof ContentRelativeText>;\n\n// export function ConstructContent(\n// contentType: 'text',\n// contextType: 'local'\n// ): typeof ContentAnyTextLocal;\n// export function ConstructContent(\n// contentType: 'text',\n// contextType: 'remote'\n// ): typeof ContentAnyTextRemote;\n// export function ConstructContent(\n// contentType: 'binary',\n// contextType: 'local'\n// ): typeof ContentAnyBinaryLocal;\n// export function ConstructContent(\n// contentType: 'binary',\n// contextType: 'remote'\n// ): typeof ContentAnyBinaryRemote;\n// export function ConstructContent(\n// contentType: ContentType,\n// contextType: ContextType\n// ):\n// | typeof ContentAnyTextLocal\n// | typeof ContentAnyTextRemote\n// | typeof ContentAnyBinaryLocal\n// | typeof ContentAnyBinaryRemote;\n// export function ConstructContent(contentType: ContentType, contextType: ContextType) {\n// return contentType === 'text'\n// ? contextType === 'local'\n// ? ContentAnyTextLocal\n// : ContentAnyTextRemote\n// : contextType === 'local'\n// ? ContentAnyBinaryLocal\n// : ContentAnyBinaryRemote;\n// }\n\nexport const DescriptionContentBinary = z.union([\n z\n .string()\n .startsWith('file:')\n .transform<ContentRelativeBinary>((value, 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 { 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 {\n ContentAbsoluteUrl,\n ContentAnyLocal,\n ContentExplicitOrRelative,\n ContentRelative\n} from './content_types';\n\nexport function mapRemoteToAbsolute(\n rootUrl: string\n): <T extends ContentAnyLocal>(value: T) => 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\n/**\n * Creates transformer of relative content paths, that adds a specific prefix to the relative path.\n *\n * If prefix = \"nested-path/\", paths like \"somefile.txt\" will be transformed to \"nested-path/somefile.txt\".\n *\n * @param prefix prefix to add to the relaive path, slesh at the end will be added automatically if missed\n */\nexport function addPrefixToRelative(\n prefix: string\n): <T extends ContentExplicitOrRelative>(value: T) => T {\n const prefixWithSlash = prefix.endsWith('/') ? prefix : `${prefix}/`;\n return <T extends ContentExplicitOrRelative>(value: T) =>\n (value.type === 'relative'\n ? { type: 'relative', path: prefixWithSlash + value.path }\n : value) as T;\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 { 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: 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 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';\nimport {\n ContentExplicitBase64,\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 BlockPackMetaEmbeddedContent = BlockPackMeta(\n z.string(),\n ContentExplicitBase64\n);\nexport type BlockPackMetaEmbeddedContent = z.infer<typeof BlockPackMetaEmbeddedContent>;\n","import { z, ZodTypeAny } from 'zod';\nimport { BlockComponentsDescriptionRaw } from './block_components';\nimport { BlockPackMetaDescriptionRaw } from './block_meta';\nimport { BlockPackId } from './block_id';\n\n/** Description, as appears in root block package.json file,\n * `file:` references are parsed into relative content of corresponding type, depending on the context,\n * strings are converted to explicit content type. */\nexport const BlockPackDescriptionFromPackageJsonRaw = z.object({\n components: BlockComponentsDescriptionRaw,\n meta: BlockPackMetaDescriptionRaw\n});\n\nexport function CreateBlockPackDescriptionSchema<\n Components extends ZodTypeAny,\n Meta extends ZodTypeAny\n>(components: Components, meta: Meta) {\n return z.object({\n id: BlockPackId,\n components,\n meta\n });\n}\n\nexport const BlockPackDescriptionRaw = CreateBlockPackDescriptionSchema(\n BlockComponentsDescriptionRaw,\n BlockPackMetaDescriptionRaw\n);\nexport type BlockPackDescriptionRaw = z.infer<typeof BlockPackDescriptionRaw>;\n","import { z } from 'zod';\nimport { BlockComponents } from './block_components';\nimport { ContentRelative, ContentRelativeBinary, ContentRelativeText } from './content_types';\nimport { CreateBlockPackDescriptionSchema } from './block_description';\nimport { BlockPackMeta } from './block_meta';\n\nexport const BlockComponentsManifest = BlockComponents(ContentRelative, ContentRelative);\nexport type BlockComponentsManifest = z.infer<typeof BlockComponentsManifest>;\n\nexport const BlockPackMetaManifest = BlockPackMeta(ContentRelativeText, ContentRelativeBinary);\nexport type BlockPackMetaManifest = z.infer<typeof BlockPackMetaManifest>;\n\n/** Block description to be used in block manifest */\nexport const BlockPackDescriptionManifest = CreateBlockPackDescriptionSchema(\n BlockComponentsManifest,\n BlockPackMetaManifest\n);\nexport type BlockPackDescriptionManifest = z.infer<typeof BlockPackDescriptionManifest>;\n\nexport const ManifestFileInfo = z.object({\n name: z.string(),\n size: z.number().int(),\n sha256: z\n .string()\n .regex(/[0-9a-fA-F]/)\n .toUpperCase()\n .length(64) // 256 / 4 (bits per hex register)\n});\nexport type ManifestFileInfo = z.infer<typeof ManifestFileInfo>;\n\nexport const BlockPackManifest = z.object({\n schema: z.literal('v2'),\n description: BlockPackDescriptionManifest,\n files: z.array(ManifestFileInfo)\n});\nexport type BlockPackManifest = z.infer<typeof BlockPackManifest>;\n\nexport const BlockPackManifestFile = 'manifest.json';\n"],"names":["ContentExplicitString","z","ContentExplicitBase64","ContentRelative","ContentAbsoluteFile","ContentAbsoluteUrl","ContentExplicitBytes","ContentAbsoluteFolder","ContentAny","ContentExplicitOrRelative","ContentAnyLocal","ContentAnyRemote","ContentAnyBinaryLocal","ContentAnyTextLocal","ContentAbsoluteBinaryRemote","ContentAbsoluteBinaryLocal","ContentAbsoluteTextRemote","ContentAbsoluteTextLocal","ContentRelativeBinary","ContentRelativeText","DescriptionContentBinary","value","ctx","DescriptionContentText","SemVer","mapRemoteToAbsolute","rootUrl","rootWithSlash","addPrefixToRelative","prefix","prefixWithSlash","BlockPackId","BlockPackIdNoVersion","Workflow","contentType","BlockComponents","wfAndModel","ui","BlockComponentsDescriptionRaw","BlockComponentsAbsoluteUrl","BlockPackMeta","longString","binary","BlockPackMetaDescriptionRaw","BlockPackMetaEmbeddedContent","BlockPackDescriptionFromPackageJsonRaw","CreateBlockPackDescriptionSchema","components","meta","BlockPackDescriptionRaw","BlockComponentsManifest","BlockPackMetaManifest","BlockPackDescriptionManifest","ManifestFileInfo","BlockPackManifest","BlockPackManifestFile"],"mappings":";AAMa,MAAAA,IAAwBC,EAClC,OAAO;AAAA,EACN,MAAMA,EAAE,QAAQ,iBAAiB;AAAA,EACjC,SAASA,EAAE,SAAS,SAAS,qBAAqB;AACpD,CAAC,EACA,OAAO,GAGGC,IAAwBD,EA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X,EAAcrB,GAAqBD,CAAqB,GAIhFkC,IAA+BN;AAAA,EAC1CI;AAAA,EACAC;AACF,GAGaE,IAAmBpD,EAAE,OAAO;AAAA,EACvC,MAAMA,EAAE,OAAO;AAAA,EACf,MAAMA,EAAE,OAAO,EAAE,IAAI;AAAA,EACrB,QAAQA,EACL,OAAA,EACA,MAAM,aAAa,EACnB,YAAA,EACA,OAAO,EAAE;AAAA;AACd,CAAC,GAGYqD,IAAoBrD,EAAE,OAAO;AAAA,EACxC,QAAQA,EAAE,QAAQ,IAAI;AAAA,EACtB,aAAamD;AAAA,EACb,OAAOnD,EAAE,MAAMoD,CAAgB;AACjC,CAAC,GAGYE,IAAwB;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@milaboratories/pl-model-middle-layer",
3
- "version": "1.2.20",
3
+ "version": "1.3.0",
4
4
  "description": "Common model between middle layer and non-block UI code",
5
5
  "types": "./dist/index.d.ts",
6
6
  "main": "./dist/index.js",
@@ -23,7 +23,7 @@
23
23
  },
24
24
  "devDependencies": {
25
25
  "typescript": "~5.5.4",
26
- "vite": "^5.4.7",
26
+ "vite": "^5.4.8",
27
27
  "@milaboratories/platforma-build-configs": "1.0.1"
28
28
  },
29
29
  "scripts": {
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { ContentRelative, ContentRelativeBinary } from './content_types';
2
+ import { ContentRelativeBinary } from './content_types';
3
3
  import { mapRemoteToAbsolute } from './content_conversion';
4
4
 
5
5
  export type BlockPackComponents = {};
@@ -26,7 +26,7 @@ export function BlockComponents<
26
26
  const UI extends z.ZodTypeAny
27
27
  >(wfAndModel: WfAndModel, ui: UI) {
28
28
  return z.object({
29
- workflow: wfAndModel,
29
+ workflow: Workflow(wfAndModel),
30
30
  model: wfAndModel,
31
31
  ui
32
32
  });
@@ -35,9 +35,6 @@ export function BlockComponents<
35
35
  export const BlockComponentsDescriptionRaw = BlockComponents(z.string(), z.string());
36
36
  export type BlockComponentsDescriptionRaw = z.infer<typeof BlockComponentsDescriptionRaw>;
37
37
 
38
- export const BlockComponentsManifest = BlockComponents(ContentRelative, ContentRelative);
39
- export type BlockComponentsManifest = z.infer<typeof BlockComponentsManifest>;
40
-
41
38
  export function BlockComponentsAbsoluteUrl(prefix: string) {
42
39
  return BlockComponents(
43
40
  ContentRelativeBinary.transform(mapRemoteToAbsolute(prefix)),
@@ -0,0 +1,29 @@
1
+ import { z, ZodTypeAny } from 'zod';
2
+ import { BlockComponentsDescriptionRaw } from './block_components';
3
+ import { BlockPackMetaDescriptionRaw } from './block_meta';
4
+ import { BlockPackId } from './block_id';
5
+
6
+ /** Description, as appears in root block package.json file,
7
+ * `file:` references are parsed into relative content of corresponding type, depending on the context,
8
+ * strings are converted to explicit content type. */
9
+ export const BlockPackDescriptionFromPackageJsonRaw = z.object({
10
+ components: BlockComponentsDescriptionRaw,
11
+ meta: BlockPackMetaDescriptionRaw
12
+ });
13
+
14
+ export function CreateBlockPackDescriptionSchema<
15
+ Components extends ZodTypeAny,
16
+ Meta extends ZodTypeAny
17
+ >(components: Components, meta: Meta) {
18
+ return z.object({
19
+ id: BlockPackId,
20
+ components,
21
+ meta
22
+ });
23
+ }
24
+
25
+ export const BlockPackDescriptionRaw = CreateBlockPackDescriptionSchema(
26
+ BlockComponentsDescriptionRaw,
27
+ BlockPackMetaDescriptionRaw
28
+ );
29
+ export type BlockPackDescriptionRaw = z.infer<typeof BlockPackDescriptionRaw>;