@milaboratories/pl-model-backend 1.0.1
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.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +94 -0
- package/dist/index.mjs.map +1 -0
- package/dist/template_data_v2.d.ts +50 -0
- package/dist/template_data_v2.d.ts.map +1 -0
- package/dist/template_resources_v1.d.ts +67 -0
- package/dist/template_resources_v1.d.ts.map +1 -0
- package/package.json +35 -0
- package/src/index.ts +2 -0
- package/src/template_data_v2.ts +72 -0
- package/src/template_resources_v1.ts +129 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("node:zlib"),d=require("canonicalize"),a=require("@milaboratories/pl-client"),f=new TextEncoder,u=new TextDecoder;function s(e){const t=JSON.parse(u.decode(l.gunzipSync(e)));if(t.type!=="pl.tengo-template.v2")throw new Error("malformed template");return t}function p(e){return l.gzipSync(f.encode(d(e)),{chunkSize:256*1024,level:9})}exports.PlTemplateLibV1=void 0;(e=>{e.type=a.resourceType("TengoLib","1");function t(r){return{data:{Name:r.name,Version:r.version,Code:Buffer.from(r.src,"utf8").toString("base64")}}}e.fromV2Data=t})(exports.PlTemplateLibV1||(exports.PlTemplateLibV1={}));exports.PlTemplateSoftwareV1=void 0;(e=>{e.type=a.resourceType("SoftwareInfo","1"),e.metaNameKey="ctl/runner/package/name";function t(r){return{data:r.src,name:{Name:r.name,Version:r.version}}}e.fromV2Data=t})(exports.PlTemplateSoftwareV1||(exports.PlTemplateSoftwareV1={}));exports.PlTemplateV1=void 0;(e=>{e.type=a.resourceType("TengoTemplate","1"),e.libPrefix="lib",e.softPrefix="soft",e.tplPrefix="tpl";function t(n,o){return a.field(n,`${e.libPrefix}/${o}`)}e.libField=t;function r(n,o){return a.field(n,`${e.tplPrefix}/${o}`)}e.tplField=r;function i(n,o){return a.field(n,`${e.softPrefix}/${o}`)}e.swField=i;function c(n){return{data:{Name:n.name,Version:n.version,Code:Buffer.from(n.src,"utf8").toString("base64")}}}e.fromV2Data=c})(exports.PlTemplateV1||(exports.PlTemplateV1={}));exports.PlTemplateOverrideV1=void 0;(e=>{e.type=a.resourceType("TengoTemplateOverride","1");function t(i){return a.field(i,"tpl")}e.tplField=t;function r(i){if(!i.hashOverride)throw new Error("template tree rendering error: template has no hash override, cannot generate PlTemplateOverrideV1.ResourceStructure from template data");return{data:{OverrideUUID:i.hashOverride}}}e.fromV2Data=r})(exports.PlTemplateOverrideV1||(exports.PlTemplateOverrideV1={}));exports.parseTemplate=s;exports.serializeTemplate=p;
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/template_data_v2.ts","../src/template_resources_v1.ts"],"sourcesContent":["import { gunzipSync, gzipSync } from 'node:zlib';\nimport canonicalize from 'canonicalize';\n\nconst templateArchiveEncoder = new TextEncoder();\nconst templateArchiveDecoder = new TextDecoder();\n\nexport function parseTemplate(content: Uint8Array): TemplateData {\n const data = JSON.parse(templateArchiveDecoder.decode(gunzipSync(content))) as TemplateData;\n if (data.type !== 'pl.tengo-template.v2') {\n throw new Error('malformed template');\n }\n\n return data;\n}\n\nexport function serializeTemplate(data: TemplateData): Uint8Array {\n return gzipSync(templateArchiveEncoder.encode(canonicalize(data)), { chunkSize: 256 * 1024, level: 9 });\n}\n\nexport interface TemplateLibData {\n /** i.e. @milaboratory/some-package:lib1 */\n name: string;\n /** i.e. 1.2.3 */\n version: string;\n /** full source code */\n src: string;\n}\n\nexport interface TemplateSoftwareData {\n /** i.e. @milaboratory/mixcr:main */\n name: string;\n /** i.e. 4.2.3 */\n version: string;\n /** full contents of software dependency description */\n src: string;\n}\n\nexport interface TemplateAssetData {\n /** i.e. @milaboratory/mixcr:main */\n name: string;\n /** i.e. 4.2.3 */\n version: string;\n /** full contents of asset dependency description */\n src: string;\n}\n\nexport interface TemplateData {\n /** Discriminator for future use */\n type: 'pl.tengo-template.v2';\n\n /** i.e. @milaboratory/some-package:template */\n name: string;\n /** i.e. 1.2.3 */\n version: string;\n\n /**\n * Custom hash token of the template for deduplication purposes. Can be set with 'hash_override' compiler option.\n * Dangerous! Remember: great power comes with great responsibility.\n */\n hashOverride?: string;\n\n /** i.e. @milaboratory/some-package:some-lib -> normalized library source code */\n libs: Record<string, TemplateLibData>;\n /** i.e. @milaboratory/some-package:some-lib -> to nested template data */\n templates: Record<string, TemplateData>;\n /** i.e. @milaboratory/mixcr:main -> software metadata */\n software: Record<string, TemplateSoftwareData>;\n /** i.e. @milaboratory/genome:human -> asset metadata */\n assets: Record<string, TemplateAssetData>;\n /** Template source code */\n src: string;\n}\n","import type { AnyFieldRef, AnyResourceRef } from '@milaboratories/pl-client';\nimport { field, resourceType } from '@milaboratories/pl-client';\nimport type * as infoV2 from './template_data_v2';\n\nexport namespace PlTemplateLibV1 {\n export const type = resourceType('TengoLib', '1');\n\n export type ResourceStructure = {\n data: Data;\n };\n\n export type Data = {\n /** i.e. @milaboratory/some-package:lib1 */\n Name: string;\n /** i.e. 1.2.3 */\n Version: string;\n /** Full source code encoded with Base64 */\n Code: string;\n };\n\n export function fromV2Data(info: infoV2.TemplateLibData): ResourceStructure {\n return {\n data: {\n Name: info.name,\n Version: info.version,\n Code: Buffer.from(info.src, 'utf8').toString('base64'),\n },\n };\n }\n}\n\nexport namespace PlTemplateSoftwareV1 {\n export const type = resourceType('SoftwareInfo', '1');\n\n export type ResourceStructure = {\n data: Data;\n name: MetaName;\n };\n\n /** Raw entrypoint descriptor encoded with Base64 */\n export type Data = string;\n\n export const metaNameKey = 'ctl/runner/package/name';\n export type MetaName = {\n /** i.e. @milaboratory/some-package:sw1 */\n Name: string;\n /** i.e. 1.2.3 */\n Version: string;\n };\n\n export function fromV2Data(info: infoV2.TemplateSoftwareData | infoV2.TemplateAssetData): ResourceStructure {\n return {\n data: info.src,\n name: {\n Name: info.name,\n Version: info.version,\n },\n };\n }\n}\n\nexport namespace PlTemplateV1 {\n export const type = resourceType('TengoTemplate', '1');\n\n export type ResourceStructure = {\n data: Data;\n };\n\n export const libPrefix = 'lib';\n export const softPrefix = 'soft';\n export const tplPrefix = 'tpl';\n\n export function libField(ref: AnyResourceRef, libId: string): AnyFieldRef {\n return field(ref, `${libPrefix}/${libId}`);\n }\n export function tplField(ref: AnyResourceRef, tplId: string): AnyFieldRef {\n return field(ref, `${tplPrefix}/${tplId}`);\n }\n export function swField(ref: AnyResourceRef, softwareId: string): AnyFieldRef {\n return field(ref, `${softPrefix}/${softwareId}`);\n }\n\n export type Data = {\n /** i.e. @milaboratory/some-package:tpl1 */\n Name: string;\n /** i.e. 1.2.3 */\n Version: string;\n /** Full source code encoded with Base64 */\n Code: string;\n };\n\n export function fromV2Data(info: infoV2.TemplateData): ResourceStructure {\n return {\n data: {\n Name: info.name,\n Version: info.version,\n Code: Buffer.from(info.src, 'utf8').toString('base64'),\n },\n };\n }\n}\n\nexport namespace PlTemplateOverrideV1 {\n export const type = resourceType('TengoTemplateOverride', '1');\n\n export type ResourceStructure = {\n data: Data;\n };\n\n export function tplField(ref: AnyResourceRef): AnyFieldRef {\n return field(ref, 'tpl');\n }\n\n export type Data = {\n OverrideUUID: string;\n };\n\n export function fromV2Data(info: infoV2.TemplateData): ResourceStructure {\n if (!info.hashOverride) {\n throw new Error(`template tree rendering error: template has no hash override, cannot generate PlTemplateOverrideV1.ResourceStructure from template data`);\n }\n\n return {\n data: {\n OverrideUUID: info.hashOverride,\n },\n };\n }\n}\n"],"names":["templateArchiveEncoder","templateArchiveDecoder","parseTemplate","content","data","gunzipSync","serializeTemplate","gzipSync","canonicalize","PlTemplateLibV1","resourceType","fromV2Data","info","PlTemplateSoftwareV1","PlTemplateV1","libField","ref","libId","field","tplField","tplId","swField","softwareId","PlTemplateOverrideV1"],"mappings":"8KAGMA,EAAyB,IAAI,YAC7BC,EAAyB,IAAI,YAE5B,SAASC,EAAcC,EAAmC,CACzD,MAAAC,EAAO,KAAK,MAAMH,EAAuB,OAAOI,EAAW,WAAAF,CAAO,CAAC,CAAC,EACtE,GAAAC,EAAK,OAAS,uBACV,MAAA,IAAI,MAAM,oBAAoB,EAG/B,OAAAA,CACT,CAEO,SAASE,EAAkBF,EAAgC,CAChE,OAAOG,EAAS,SAAAP,EAAuB,OAAOQ,EAAaJ,CAAI,CAAC,EAAG,CAAE,UAAW,IAAM,KAAM,MAAO,EAAG,CACxG,CCbiBK,QAAAA,gBAAAA,QAAAA,GAAV,CACQA,EAAA,KAAOC,eAAa,WAAY,GAAG,EAezC,SAASC,EAAWC,EAAiD,CACnE,MAAA,CACL,KAAM,CACJ,KAAMA,EAAK,KACX,QAASA,EAAK,QACd,KAAM,OAAO,KAAKA,EAAK,IAAK,MAAM,EAAE,SAAS,QAAQ,CAAA,CAEzD,CAAA,CAPKH,EAAS,WAAAE,CAAA,GAhBDF,QAAA,kBAAAA,wBAAA,CAAA,EAAA,EA2BAI,QAAAA,qBAAAA,QAAAA,GAAV,CACQA,EAAA,KAAOH,eAAa,eAAgB,GAAG,EAUvCG,EAAA,YAAc,0BAQpB,SAASF,EAAWC,EAAiF,CACnG,MAAA,CACL,KAAMA,EAAK,IACX,KAAM,CACJ,KAAMA,EAAK,KACX,QAASA,EAAK,OAAA,CAElB,CAAA,CAPKC,EAAS,WAAAF,CAAA,GAnBDE,QAAA,uBAAAA,6BAAA,CAAA,EAAA,EA8BAC,QAAAA,aAAAA,QAAAA,GAAV,CACQA,EAAA,KAAOJ,eAAa,gBAAiB,GAAG,EAMxCI,EAAA,UAAY,MACZA,EAAA,WAAa,OACbA,EAAA,UAAY,MAET,SAAAC,EAASC,EAAqBC,EAA4B,CACxE,OAAOC,QAAMF,EAAK,GAAGF,EAAA,SAAS,IAAIG,CAAK,EAAE,CAAA,CADpCH,EAAS,SAAAC,EAGA,SAAAI,EAASH,EAAqBI,EAA4B,CACxE,OAAOF,QAAMF,EAAK,GAAGF,EAAA,SAAS,IAAIM,CAAK,EAAE,CAAA,CADpCN,EAAS,SAAAK,EAGA,SAAAE,EAAQL,EAAqBM,EAAiC,CAC5E,OAAOJ,QAAMF,EAAK,GAAGF,EAAA,UAAU,IAAIQ,CAAU,EAAE,CAAA,CAD1CR,EAAS,QAAAO,EAaT,SAASV,EAAWC,EAA8C,CAChE,MAAA,CACL,KAAM,CACJ,KAAMA,EAAK,KACX,QAASA,EAAK,QACd,KAAM,OAAO,KAAKA,EAAK,IAAK,MAAM,EAAE,SAAS,QAAQ,CAAA,CAEzD,CAAA,CAPKE,EAAS,WAAAH,CAAA,GA9BDG,QAAA,eAAAA,qBAAA,CAAA,EAAA,EAyCAS,QAAAA,qBAAAA,QAAAA,GAAV,CACQA,EAAA,KAAOb,eAAa,wBAAyB,GAAG,EAMtD,SAASS,EAASH,EAAkC,CAClD,OAAAE,EAAA,MAAMF,EAAK,KAAK,CAAA,CADlBO,EAAS,SAAAJ,EAQT,SAASR,EAAWC,EAA8C,CACnE,GAAA,CAACA,EAAK,aACF,MAAA,IAAI,MAAM,yIAAyI,EAGpJ,MAAA,CACL,KAAM,CACJ,aAAcA,EAAK,YAAA,CAEvB,CAAA,CATKW,EAAS,WAAAZ,CAAA,GAfDY,QAAA,uBAAAA,6BAAA,CAAA,EAAA"}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { gunzipSync as p, gzipSync as l } from "node:zlib";
|
|
2
|
+
import v from "canonicalize";
|
|
3
|
+
import { resourceType as f, field as i } from "@milaboratories/pl-client";
|
|
4
|
+
const h = new TextEncoder(), g = new TextDecoder();
|
|
5
|
+
function b(e) {
|
|
6
|
+
const t = JSON.parse(g.decode(p(e)));
|
|
7
|
+
if (t.type !== "pl.tengo-template.v2")
|
|
8
|
+
throw new Error("malformed template");
|
|
9
|
+
return t;
|
|
10
|
+
}
|
|
11
|
+
function w(e) {
|
|
12
|
+
return l(h.encode(v(e)), { chunkSize: 256 * 1024, level: 9 });
|
|
13
|
+
}
|
|
14
|
+
var c;
|
|
15
|
+
((e) => {
|
|
16
|
+
e.type = f("TengoLib", "1");
|
|
17
|
+
function t(r) {
|
|
18
|
+
return {
|
|
19
|
+
data: {
|
|
20
|
+
Name: r.name,
|
|
21
|
+
Version: r.version,
|
|
22
|
+
Code: Buffer.from(r.src, "utf8").toString("base64")
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
e.fromV2Data = t;
|
|
27
|
+
})(c || (c = {}));
|
|
28
|
+
var d;
|
|
29
|
+
((e) => {
|
|
30
|
+
e.type = f("SoftwareInfo", "1"), e.metaNameKey = "ctl/runner/package/name";
|
|
31
|
+
function t(r) {
|
|
32
|
+
return {
|
|
33
|
+
data: r.src,
|
|
34
|
+
name: {
|
|
35
|
+
Name: r.name,
|
|
36
|
+
Version: r.version
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
e.fromV2Data = t;
|
|
41
|
+
})(d || (d = {}));
|
|
42
|
+
var u;
|
|
43
|
+
((e) => {
|
|
44
|
+
e.type = f("TengoTemplate", "1"), e.libPrefix = "lib", e.softPrefix = "soft", e.tplPrefix = "tpl";
|
|
45
|
+
function t(n, a) {
|
|
46
|
+
return i(n, `${e.libPrefix}/${a}`);
|
|
47
|
+
}
|
|
48
|
+
e.libField = t;
|
|
49
|
+
function r(n, a) {
|
|
50
|
+
return i(n, `${e.tplPrefix}/${a}`);
|
|
51
|
+
}
|
|
52
|
+
e.tplField = r;
|
|
53
|
+
function o(n, a) {
|
|
54
|
+
return i(n, `${e.softPrefix}/${a}`);
|
|
55
|
+
}
|
|
56
|
+
e.swField = o;
|
|
57
|
+
function s(n) {
|
|
58
|
+
return {
|
|
59
|
+
data: {
|
|
60
|
+
Name: n.name,
|
|
61
|
+
Version: n.version,
|
|
62
|
+
Code: Buffer.from(n.src, "utf8").toString("base64")
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
e.fromV2Data = s;
|
|
67
|
+
})(u || (u = {}));
|
|
68
|
+
var m;
|
|
69
|
+
((e) => {
|
|
70
|
+
e.type = f("TengoTemplateOverride", "1");
|
|
71
|
+
function t(o) {
|
|
72
|
+
return i(o, "tpl");
|
|
73
|
+
}
|
|
74
|
+
e.tplField = t;
|
|
75
|
+
function r(o) {
|
|
76
|
+
if (!o.hashOverride)
|
|
77
|
+
throw new Error("template tree rendering error: template has no hash override, cannot generate PlTemplateOverrideV1.ResourceStructure from template data");
|
|
78
|
+
return {
|
|
79
|
+
data: {
|
|
80
|
+
OverrideUUID: o.hashOverride
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
e.fromV2Data = r;
|
|
85
|
+
})(m || (m = {}));
|
|
86
|
+
export {
|
|
87
|
+
c as PlTemplateLibV1,
|
|
88
|
+
m as PlTemplateOverrideV1,
|
|
89
|
+
d as PlTemplateSoftwareV1,
|
|
90
|
+
u as PlTemplateV1,
|
|
91
|
+
b as parseTemplate,
|
|
92
|
+
w as serializeTemplate
|
|
93
|
+
};
|
|
94
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../src/template_data_v2.ts","../src/template_resources_v1.ts"],"sourcesContent":["import { gunzipSync, gzipSync } from 'node:zlib';\nimport canonicalize from 'canonicalize';\n\nconst templateArchiveEncoder = new TextEncoder();\nconst templateArchiveDecoder = new TextDecoder();\n\nexport function parseTemplate(content: Uint8Array): TemplateData {\n const data = JSON.parse(templateArchiveDecoder.decode(gunzipSync(content))) as TemplateData;\n if (data.type !== 'pl.tengo-template.v2') {\n throw new Error('malformed template');\n }\n\n return data;\n}\n\nexport function serializeTemplate(data: TemplateData): Uint8Array {\n return gzipSync(templateArchiveEncoder.encode(canonicalize(data)), { chunkSize: 256 * 1024, level: 9 });\n}\n\nexport interface TemplateLibData {\n /** i.e. @milaboratory/some-package:lib1 */\n name: string;\n /** i.e. 1.2.3 */\n version: string;\n /** full source code */\n src: string;\n}\n\nexport interface TemplateSoftwareData {\n /** i.e. @milaboratory/mixcr:main */\n name: string;\n /** i.e. 4.2.3 */\n version: string;\n /** full contents of software dependency description */\n src: string;\n}\n\nexport interface TemplateAssetData {\n /** i.e. @milaboratory/mixcr:main */\n name: string;\n /** i.e. 4.2.3 */\n version: string;\n /** full contents of asset dependency description */\n src: string;\n}\n\nexport interface TemplateData {\n /** Discriminator for future use */\n type: 'pl.tengo-template.v2';\n\n /** i.e. @milaboratory/some-package:template */\n name: string;\n /** i.e. 1.2.3 */\n version: string;\n\n /**\n * Custom hash token of the template for deduplication purposes. Can be set with 'hash_override' compiler option.\n * Dangerous! Remember: great power comes with great responsibility.\n */\n hashOverride?: string;\n\n /** i.e. @milaboratory/some-package:some-lib -> normalized library source code */\n libs: Record<string, TemplateLibData>;\n /** i.e. @milaboratory/some-package:some-lib -> to nested template data */\n templates: Record<string, TemplateData>;\n /** i.e. @milaboratory/mixcr:main -> software metadata */\n software: Record<string, TemplateSoftwareData>;\n /** i.e. @milaboratory/genome:human -> asset metadata */\n assets: Record<string, TemplateAssetData>;\n /** Template source code */\n src: string;\n}\n","import type { AnyFieldRef, AnyResourceRef } from '@milaboratories/pl-client';\nimport { field, resourceType } from '@milaboratories/pl-client';\nimport type * as infoV2 from './template_data_v2';\n\nexport namespace PlTemplateLibV1 {\n export const type = resourceType('TengoLib', '1');\n\n export type ResourceStructure = {\n data: Data;\n };\n\n export type Data = {\n /** i.e. @milaboratory/some-package:lib1 */\n Name: string;\n /** i.e. 1.2.3 */\n Version: string;\n /** Full source code encoded with Base64 */\n Code: string;\n };\n\n export function fromV2Data(info: infoV2.TemplateLibData): ResourceStructure {\n return {\n data: {\n Name: info.name,\n Version: info.version,\n Code: Buffer.from(info.src, 'utf8').toString('base64'),\n },\n };\n }\n}\n\nexport namespace PlTemplateSoftwareV1 {\n export const type = resourceType('SoftwareInfo', '1');\n\n export type ResourceStructure = {\n data: Data;\n name: MetaName;\n };\n\n /** Raw entrypoint descriptor encoded with Base64 */\n export type Data = string;\n\n export const metaNameKey = 'ctl/runner/package/name';\n export type MetaName = {\n /** i.e. @milaboratory/some-package:sw1 */\n Name: string;\n /** i.e. 1.2.3 */\n Version: string;\n };\n\n export function fromV2Data(info: infoV2.TemplateSoftwareData | infoV2.TemplateAssetData): ResourceStructure {\n return {\n data: info.src,\n name: {\n Name: info.name,\n Version: info.version,\n },\n };\n }\n}\n\nexport namespace PlTemplateV1 {\n export const type = resourceType('TengoTemplate', '1');\n\n export type ResourceStructure = {\n data: Data;\n };\n\n export const libPrefix = 'lib';\n export const softPrefix = 'soft';\n export const tplPrefix = 'tpl';\n\n export function libField(ref: AnyResourceRef, libId: string): AnyFieldRef {\n return field(ref, `${libPrefix}/${libId}`);\n }\n export function tplField(ref: AnyResourceRef, tplId: string): AnyFieldRef {\n return field(ref, `${tplPrefix}/${tplId}`);\n }\n export function swField(ref: AnyResourceRef, softwareId: string): AnyFieldRef {\n return field(ref, `${softPrefix}/${softwareId}`);\n }\n\n export type Data = {\n /** i.e. @milaboratory/some-package:tpl1 */\n Name: string;\n /** i.e. 1.2.3 */\n Version: string;\n /** Full source code encoded with Base64 */\n Code: string;\n };\n\n export function fromV2Data(info: infoV2.TemplateData): ResourceStructure {\n return {\n data: {\n Name: info.name,\n Version: info.version,\n Code: Buffer.from(info.src, 'utf8').toString('base64'),\n },\n };\n }\n}\n\nexport namespace PlTemplateOverrideV1 {\n export const type = resourceType('TengoTemplateOverride', '1');\n\n export type ResourceStructure = {\n data: Data;\n };\n\n export function tplField(ref: AnyResourceRef): AnyFieldRef {\n return field(ref, 'tpl');\n }\n\n export type Data = {\n OverrideUUID: string;\n };\n\n export function fromV2Data(info: infoV2.TemplateData): ResourceStructure {\n if (!info.hashOverride) {\n throw new Error(`template tree rendering error: template has no hash override, cannot generate PlTemplateOverrideV1.ResourceStructure from template data`);\n }\n\n return {\n data: {\n OverrideUUID: info.hashOverride,\n },\n };\n }\n}\n"],"names":["templateArchiveEncoder","templateArchiveDecoder","parseTemplate","content","data","gunzipSync","serializeTemplate","gzipSync","canonicalize","PlTemplateLibV1","resourceType","fromV2Data","info","PlTemplateSoftwareV1","PlTemplateV1","libField","ref","libId","field","tplField","tplId","swField","softwareId","PlTemplateOverrideV1"],"mappings":";;;AAGA,MAAMA,IAAyB,IAAI,YAAY,GACzCC,IAAyB,IAAI,YAAY;AAExC,SAASC,EAAcC,GAAmC;AACzD,QAAAC,IAAO,KAAK,MAAMH,EAAuB,OAAOI,EAAWF,CAAO,CAAC,CAAC;AACtE,MAAAC,EAAK,SAAS;AACV,UAAA,IAAI,MAAM,oBAAoB;AAG/B,SAAAA;AACT;AAEO,SAASE,EAAkBF,GAAgC;AAChE,SAAOG,EAASP,EAAuB,OAAOQ,EAAaJ,CAAI,CAAC,GAAG,EAAE,WAAW,MAAM,MAAM,OAAO,GAAG;AACxG;ACbiB,IAAAK;AAAA,CAAV,CAAUA,MAAV;AACQA,EAAAA,EAAA,OAAOC,EAAa,YAAY,GAAG;AAezC,WAASC,EAAWC,GAAiD;AACnE,WAAA;AAAA,MACL,MAAM;AAAA,QACJ,MAAMA,EAAK;AAAA,QACX,SAASA,EAAK;AAAA,QACd,MAAM,OAAO,KAAKA,EAAK,KAAK,MAAM,EAAE,SAAS,QAAQ;AAAA,MAAA;AAAA,IAEzD;AAAA,EAAA;AAPKH,EAAAA,EAAS,aAAAE;AAAA,GAhBDF,MAAAA,IAAA,CAAA,EAAA;AA2BA,IAAAI;AAAA,CAAV,CAAUA,MAAV;AACQA,EAAAA,EAAA,OAAOH,EAAa,gBAAgB,GAAG,GAUvCG,EAAA,cAAc;AAQpB,WAASF,EAAWC,GAAiF;AACnG,WAAA;AAAA,MACL,MAAMA,EAAK;AAAA,MACX,MAAM;AAAA,QACJ,MAAMA,EAAK;AAAA,QACX,SAASA,EAAK;AAAA,MAAA;AAAA,IAElB;AAAA,EAAA;AAPKC,EAAAA,EAAS,aAAAF;AAAA,GAnBDE,MAAAA,IAAA,CAAA,EAAA;AA8BA,IAAAC;AAAA,CAAV,CAAUA,MAAV;AACQA,EAAAA,EAAA,OAAOJ,EAAa,iBAAiB,GAAG,GAMxCI,EAAA,YAAY,OACZA,EAAA,aAAa,QACbA,EAAA,YAAY;AAET,WAAAC,EAASC,GAAqBC,GAA4B;AACxE,WAAOC,EAAMF,GAAK,GAAGF,EAAA,SAAS,IAAIG,CAAK,EAAE;AAAA,EAAA;AADpCH,EAAAA,EAAS,WAAAC;AAGA,WAAAI,EAASH,GAAqBI,GAA4B;AACxE,WAAOF,EAAMF,GAAK,GAAGF,EAAA,SAAS,IAAIM,CAAK,EAAE;AAAA,EAAA;AADpCN,EAAAA,EAAS,WAAAK;AAGA,WAAAE,EAAQL,GAAqBM,GAAiC;AAC5E,WAAOJ,EAAMF,GAAK,GAAGF,EAAA,UAAU,IAAIQ,CAAU,EAAE;AAAA,EAAA;AAD1CR,EAAAA,EAAS,UAAAO;AAaT,WAASV,EAAWC,GAA8C;AAChE,WAAA;AAAA,MACL,MAAM;AAAA,QACJ,MAAMA,EAAK;AAAA,QACX,SAASA,EAAK;AAAA,QACd,MAAM,OAAO,KAAKA,EAAK,KAAK,MAAM,EAAE,SAAS,QAAQ;AAAA,MAAA;AAAA,IAEzD;AAAA,EAAA;AAPKE,EAAAA,EAAS,aAAAH;AAAA,GA9BDG,MAAAA,IAAA,CAAA,EAAA;AAyCA,IAAAS;AAAA,CAAV,CAAUA,MAAV;AACQA,EAAAA,EAAA,OAAOb,EAAa,yBAAyB,GAAG;AAMtD,WAASS,EAASH,GAAkC;AAClD,WAAAE,EAAMF,GAAK,KAAK;AAAA,EAAA;AADlBO,EAAAA,EAAS,WAAAJ;AAQT,WAASR,EAAWC,GAA8C;AACnE,QAAA,CAACA,EAAK;AACF,YAAA,IAAI,MAAM,yIAAyI;AAGpJ,WAAA;AAAA,MACL,MAAM;AAAA,QACJ,cAAcA,EAAK;AAAA,MAAA;AAAA,IAEvB;AAAA,EAAA;AATKW,EAAAA,EAAS,aAAAZ;AAAA,GAfDY,MAAAA,IAAA,CAAA,EAAA;"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export declare function parseTemplate(content: Uint8Array): TemplateData;
|
|
2
|
+
export declare function serializeTemplate(data: TemplateData): Uint8Array;
|
|
3
|
+
export interface TemplateLibData {
|
|
4
|
+
/** i.e. @milaboratory/some-package:lib1 */
|
|
5
|
+
name: string;
|
|
6
|
+
/** i.e. 1.2.3 */
|
|
7
|
+
version: string;
|
|
8
|
+
/** full source code */
|
|
9
|
+
src: string;
|
|
10
|
+
}
|
|
11
|
+
export interface TemplateSoftwareData {
|
|
12
|
+
/** i.e. @milaboratory/mixcr:main */
|
|
13
|
+
name: string;
|
|
14
|
+
/** i.e. 4.2.3 */
|
|
15
|
+
version: string;
|
|
16
|
+
/** full contents of software dependency description */
|
|
17
|
+
src: string;
|
|
18
|
+
}
|
|
19
|
+
export interface TemplateAssetData {
|
|
20
|
+
/** i.e. @milaboratory/mixcr:main */
|
|
21
|
+
name: string;
|
|
22
|
+
/** i.e. 4.2.3 */
|
|
23
|
+
version: string;
|
|
24
|
+
/** full contents of asset dependency description */
|
|
25
|
+
src: string;
|
|
26
|
+
}
|
|
27
|
+
export interface TemplateData {
|
|
28
|
+
/** Discriminator for future use */
|
|
29
|
+
type: 'pl.tengo-template.v2';
|
|
30
|
+
/** i.e. @milaboratory/some-package:template */
|
|
31
|
+
name: string;
|
|
32
|
+
/** i.e. 1.2.3 */
|
|
33
|
+
version: string;
|
|
34
|
+
/**
|
|
35
|
+
* Custom hash token of the template for deduplication purposes. Can be set with 'hash_override' compiler option.
|
|
36
|
+
* Dangerous! Remember: great power comes with great responsibility.
|
|
37
|
+
*/
|
|
38
|
+
hashOverride?: string;
|
|
39
|
+
/** i.e. @milaboratory/some-package:some-lib -> normalized library source code */
|
|
40
|
+
libs: Record<string, TemplateLibData>;
|
|
41
|
+
/** i.e. @milaboratory/some-package:some-lib -> to nested template data */
|
|
42
|
+
templates: Record<string, TemplateData>;
|
|
43
|
+
/** i.e. @milaboratory/mixcr:main -> software metadata */
|
|
44
|
+
software: Record<string, TemplateSoftwareData>;
|
|
45
|
+
/** i.e. @milaboratory/genome:human -> asset metadata */
|
|
46
|
+
assets: Record<string, TemplateAssetData>;
|
|
47
|
+
/** Template source code */
|
|
48
|
+
src: string;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=template_data_v2.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template_data_v2.d.ts","sourceRoot":"","sources":["../src/template_data_v2.ts"],"names":[],"mappings":"AAMA,wBAAgB,aAAa,CAAC,OAAO,EAAE,UAAU,GAAG,YAAY,CAO/D;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,YAAY,GAAG,UAAU,CAEhE;AAED,MAAM,WAAW,eAAe;IAC9B,2CAA2C;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,iBAAiB;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,uBAAuB;IACvB,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,oBAAoB;IACnC,oCAAoC;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,iBAAiB;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,uDAAuD;IACvD,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,iBAAiB;IAChC,oCAAoC;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,iBAAiB;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,oDAAoD;IACpD,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,YAAY;IAC3B,mCAAmC;IACnC,IAAI,EAAE,sBAAsB,CAAC;IAE7B,+CAA+C;IAC/C,IAAI,EAAE,MAAM,CAAC;IACb,iBAAiB;IACjB,OAAO,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,iFAAiF;IACjF,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IACtC,0EAA0E;IAC1E,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACxC,yDAAyD;IACzD,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;IAC/C,wDAAwD;IACxD,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IAC1C,2BAA2B;IAC3B,GAAG,EAAE,MAAM,CAAC;CACb"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { AnyFieldRef, AnyResourceRef } from '@milaboratories/pl-client';
|
|
2
|
+
import type * as infoV2 from './template_data_v2';
|
|
3
|
+
export declare namespace PlTemplateLibV1 {
|
|
4
|
+
const type: import("@milaboratories/pl-client").ResourceType;
|
|
5
|
+
type ResourceStructure = {
|
|
6
|
+
data: Data;
|
|
7
|
+
};
|
|
8
|
+
type Data = {
|
|
9
|
+
/** i.e. @milaboratory/some-package:lib1 */
|
|
10
|
+
Name: string;
|
|
11
|
+
/** i.e. 1.2.3 */
|
|
12
|
+
Version: string;
|
|
13
|
+
/** Full source code encoded with Base64 */
|
|
14
|
+
Code: string;
|
|
15
|
+
};
|
|
16
|
+
function fromV2Data(info: infoV2.TemplateLibData): ResourceStructure;
|
|
17
|
+
}
|
|
18
|
+
export declare namespace PlTemplateSoftwareV1 {
|
|
19
|
+
const type: import("@milaboratories/pl-client").ResourceType;
|
|
20
|
+
type ResourceStructure = {
|
|
21
|
+
data: Data;
|
|
22
|
+
name: MetaName;
|
|
23
|
+
};
|
|
24
|
+
/** Raw entrypoint descriptor encoded with Base64 */
|
|
25
|
+
type Data = string;
|
|
26
|
+
const metaNameKey = "ctl/runner/package/name";
|
|
27
|
+
type MetaName = {
|
|
28
|
+
/** i.e. @milaboratory/some-package:sw1 */
|
|
29
|
+
Name: string;
|
|
30
|
+
/** i.e. 1.2.3 */
|
|
31
|
+
Version: string;
|
|
32
|
+
};
|
|
33
|
+
function fromV2Data(info: infoV2.TemplateSoftwareData | infoV2.TemplateAssetData): ResourceStructure;
|
|
34
|
+
}
|
|
35
|
+
export declare namespace PlTemplateV1 {
|
|
36
|
+
const type: import("@milaboratories/pl-client").ResourceType;
|
|
37
|
+
type ResourceStructure = {
|
|
38
|
+
data: Data;
|
|
39
|
+
};
|
|
40
|
+
const libPrefix = "lib";
|
|
41
|
+
const softPrefix = "soft";
|
|
42
|
+
const tplPrefix = "tpl";
|
|
43
|
+
function libField(ref: AnyResourceRef, libId: string): AnyFieldRef;
|
|
44
|
+
function tplField(ref: AnyResourceRef, tplId: string): AnyFieldRef;
|
|
45
|
+
function swField(ref: AnyResourceRef, softwareId: string): AnyFieldRef;
|
|
46
|
+
type Data = {
|
|
47
|
+
/** i.e. @milaboratory/some-package:tpl1 */
|
|
48
|
+
Name: string;
|
|
49
|
+
/** i.e. 1.2.3 */
|
|
50
|
+
Version: string;
|
|
51
|
+
/** Full source code encoded with Base64 */
|
|
52
|
+
Code: string;
|
|
53
|
+
};
|
|
54
|
+
function fromV2Data(info: infoV2.TemplateData): ResourceStructure;
|
|
55
|
+
}
|
|
56
|
+
export declare namespace PlTemplateOverrideV1 {
|
|
57
|
+
const type: import("@milaboratories/pl-client").ResourceType;
|
|
58
|
+
type ResourceStructure = {
|
|
59
|
+
data: Data;
|
|
60
|
+
};
|
|
61
|
+
function tplField(ref: AnyResourceRef): AnyFieldRef;
|
|
62
|
+
type Data = {
|
|
63
|
+
OverrideUUID: string;
|
|
64
|
+
};
|
|
65
|
+
function fromV2Data(info: infoV2.TemplateData): ResourceStructure;
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=template_resources_v1.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template_resources_v1.d.ts","sourceRoot":"","sources":["../src/template_resources_v1.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAE7E,OAAO,KAAK,KAAK,MAAM,MAAM,oBAAoB,CAAC;AAElD,yBAAiB,eAAe,CAAC;IACxB,MAAM,IAAI,kDAAgC,CAAC;IAElD,KAAY,iBAAiB,GAAG;QAC9B,IAAI,EAAE,IAAI,CAAC;KACZ,CAAC;IAEF,KAAY,IAAI,GAAG;QACjB,2CAA2C;QAC3C,IAAI,EAAE,MAAM,CAAC;QACb,iBAAiB;QACjB,OAAO,EAAE,MAAM,CAAC;QAChB,2CAA2C;QAC3C,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;IAEF,SAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,eAAe,GAAG,iBAAiB,CAQ1E;CACF;AAED,yBAAiB,oBAAoB,CAAC;IAC7B,MAAM,IAAI,kDAAoC,CAAC;IAEtD,KAAY,iBAAiB,GAAG;QAC9B,IAAI,EAAE,IAAI,CAAC;QACX,IAAI,EAAE,QAAQ,CAAC;KAChB,CAAC;IAEF,oDAAoD;IACpD,KAAY,IAAI,GAAG,MAAM,CAAC;IAEnB,MAAM,WAAW,4BAA4B,CAAC;IACrD,KAAY,QAAQ,GAAG;QACrB,0CAA0C;QAC1C,IAAI,EAAE,MAAM,CAAC;QACb,iBAAiB;QACjB,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;IAEF,SAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,oBAAoB,GAAG,MAAM,CAAC,iBAAiB,GAAG,iBAAiB,CAQ1G;CACF;AAED,yBAAiB,YAAY,CAAC;IACrB,MAAM,IAAI,kDAAqC,CAAC;IAEvD,KAAY,iBAAiB,GAAG;QAC9B,IAAI,EAAE,IAAI,CAAC;KACZ,CAAC;IAEK,MAAM,SAAS,QAAQ,CAAC;IACxB,MAAM,UAAU,SAAS,CAAC;IAC1B,MAAM,SAAS,QAAQ,CAAC;IAE/B,SAAgB,QAAQ,CAAC,GAAG,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,GAAG,WAAW,CAExE;IACD,SAAgB,QAAQ,CAAC,GAAG,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,GAAG,WAAW,CAExE;IACD,SAAgB,OAAO,CAAC,GAAG,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,GAAG,WAAW,CAE5E;IAED,KAAY,IAAI,GAAG;QACjB,2CAA2C;QAC3C,IAAI,EAAE,MAAM,CAAC;QACb,iBAAiB;QACjB,OAAO,EAAE,MAAM,CAAC;QAChB,2CAA2C;QAC3C,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;IAEF,SAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,YAAY,GAAG,iBAAiB,CAQvE;CACF;AAED,yBAAiB,oBAAoB,CAAC;IAC7B,MAAM,IAAI,kDAA6C,CAAC;IAE/D,KAAY,iBAAiB,GAAG;QAC9B,IAAI,EAAE,IAAI,CAAC;KACZ,CAAC;IAEF,SAAgB,QAAQ,CAAC,GAAG,EAAE,cAAc,GAAG,WAAW,CAEzD;IAED,KAAY,IAAI,GAAG;QACjB,YAAY,EAAE,MAAM,CAAC;KACtB,CAAC;IAEF,SAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,YAAY,GAAG,iBAAiB,CAUvE;CACF"}
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@milaboratories/pl-model-backend",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Backend model for Platforma.bio",
|
|
5
|
+
"types": "./dist/index.d.ts",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.mjs",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.mjs",
|
|
12
|
+
"require": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"./dist/**/*",
|
|
17
|
+
"./src/**/*"
|
|
18
|
+
],
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"canonicalize": "^2.0.0",
|
|
21
|
+
"@milaboratories/pl-client": ""
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@types/node": "~20.16.15",
|
|
25
|
+
"typescript": "~5.5.4",
|
|
26
|
+
"vite": "^5.4.11",
|
|
27
|
+
"@milaboratories/eslint-config": "^1.0.1",
|
|
28
|
+
"@milaboratories/platforma-build-configs": "1.0.2"
|
|
29
|
+
},
|
|
30
|
+
"scripts": {
|
|
31
|
+
"type-check": "tsc --noEmit --composite false",
|
|
32
|
+
"build": "vite build",
|
|
33
|
+
"do-pack": "rm -f *.tgz && pnpm pack && mv *.tgz package.tgz"
|
|
34
|
+
}
|
|
35
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { gunzipSync, gzipSync } from 'node:zlib';
|
|
2
|
+
import canonicalize from 'canonicalize';
|
|
3
|
+
|
|
4
|
+
const templateArchiveEncoder = new TextEncoder();
|
|
5
|
+
const templateArchiveDecoder = new TextDecoder();
|
|
6
|
+
|
|
7
|
+
export function parseTemplate(content: Uint8Array): TemplateData {
|
|
8
|
+
const data = JSON.parse(templateArchiveDecoder.decode(gunzipSync(content))) as TemplateData;
|
|
9
|
+
if (data.type !== 'pl.tengo-template.v2') {
|
|
10
|
+
throw new Error('malformed template');
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return data;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function serializeTemplate(data: TemplateData): Uint8Array {
|
|
17
|
+
return gzipSync(templateArchiveEncoder.encode(canonicalize(data)), { chunkSize: 256 * 1024, level: 9 });
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface TemplateLibData {
|
|
21
|
+
/** i.e. @milaboratory/some-package:lib1 */
|
|
22
|
+
name: string;
|
|
23
|
+
/** i.e. 1.2.3 */
|
|
24
|
+
version: string;
|
|
25
|
+
/** full source code */
|
|
26
|
+
src: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface TemplateSoftwareData {
|
|
30
|
+
/** i.e. @milaboratory/mixcr:main */
|
|
31
|
+
name: string;
|
|
32
|
+
/** i.e. 4.2.3 */
|
|
33
|
+
version: string;
|
|
34
|
+
/** full contents of software dependency description */
|
|
35
|
+
src: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface TemplateAssetData {
|
|
39
|
+
/** i.e. @milaboratory/mixcr:main */
|
|
40
|
+
name: string;
|
|
41
|
+
/** i.e. 4.2.3 */
|
|
42
|
+
version: string;
|
|
43
|
+
/** full contents of asset dependency description */
|
|
44
|
+
src: string;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface TemplateData {
|
|
48
|
+
/** Discriminator for future use */
|
|
49
|
+
type: 'pl.tengo-template.v2';
|
|
50
|
+
|
|
51
|
+
/** i.e. @milaboratory/some-package:template */
|
|
52
|
+
name: string;
|
|
53
|
+
/** i.e. 1.2.3 */
|
|
54
|
+
version: string;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Custom hash token of the template for deduplication purposes. Can be set with 'hash_override' compiler option.
|
|
58
|
+
* Dangerous! Remember: great power comes with great responsibility.
|
|
59
|
+
*/
|
|
60
|
+
hashOverride?: string;
|
|
61
|
+
|
|
62
|
+
/** i.e. @milaboratory/some-package:some-lib -> normalized library source code */
|
|
63
|
+
libs: Record<string, TemplateLibData>;
|
|
64
|
+
/** i.e. @milaboratory/some-package:some-lib -> to nested template data */
|
|
65
|
+
templates: Record<string, TemplateData>;
|
|
66
|
+
/** i.e. @milaboratory/mixcr:main -> software metadata */
|
|
67
|
+
software: Record<string, TemplateSoftwareData>;
|
|
68
|
+
/** i.e. @milaboratory/genome:human -> asset metadata */
|
|
69
|
+
assets: Record<string, TemplateAssetData>;
|
|
70
|
+
/** Template source code */
|
|
71
|
+
src: string;
|
|
72
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import type { AnyFieldRef, AnyResourceRef } from '@milaboratories/pl-client';
|
|
2
|
+
import { field, resourceType } from '@milaboratories/pl-client';
|
|
3
|
+
import type * as infoV2 from './template_data_v2';
|
|
4
|
+
|
|
5
|
+
export namespace PlTemplateLibV1 {
|
|
6
|
+
export const type = resourceType('TengoLib', '1');
|
|
7
|
+
|
|
8
|
+
export type ResourceStructure = {
|
|
9
|
+
data: Data;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export type Data = {
|
|
13
|
+
/** i.e. @milaboratory/some-package:lib1 */
|
|
14
|
+
Name: string;
|
|
15
|
+
/** i.e. 1.2.3 */
|
|
16
|
+
Version: string;
|
|
17
|
+
/** Full source code encoded with Base64 */
|
|
18
|
+
Code: string;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export function fromV2Data(info: infoV2.TemplateLibData): ResourceStructure {
|
|
22
|
+
return {
|
|
23
|
+
data: {
|
|
24
|
+
Name: info.name,
|
|
25
|
+
Version: info.version,
|
|
26
|
+
Code: Buffer.from(info.src, 'utf8').toString('base64'),
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export namespace PlTemplateSoftwareV1 {
|
|
33
|
+
export const type = resourceType('SoftwareInfo', '1');
|
|
34
|
+
|
|
35
|
+
export type ResourceStructure = {
|
|
36
|
+
data: Data;
|
|
37
|
+
name: MetaName;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/** Raw entrypoint descriptor encoded with Base64 */
|
|
41
|
+
export type Data = string;
|
|
42
|
+
|
|
43
|
+
export const metaNameKey = 'ctl/runner/package/name';
|
|
44
|
+
export type MetaName = {
|
|
45
|
+
/** i.e. @milaboratory/some-package:sw1 */
|
|
46
|
+
Name: string;
|
|
47
|
+
/** i.e. 1.2.3 */
|
|
48
|
+
Version: string;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export function fromV2Data(info: infoV2.TemplateSoftwareData | infoV2.TemplateAssetData): ResourceStructure {
|
|
52
|
+
return {
|
|
53
|
+
data: info.src,
|
|
54
|
+
name: {
|
|
55
|
+
Name: info.name,
|
|
56
|
+
Version: info.version,
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export namespace PlTemplateV1 {
|
|
63
|
+
export const type = resourceType('TengoTemplate', '1');
|
|
64
|
+
|
|
65
|
+
export type ResourceStructure = {
|
|
66
|
+
data: Data;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export const libPrefix = 'lib';
|
|
70
|
+
export const softPrefix = 'soft';
|
|
71
|
+
export const tplPrefix = 'tpl';
|
|
72
|
+
|
|
73
|
+
export function libField(ref: AnyResourceRef, libId: string): AnyFieldRef {
|
|
74
|
+
return field(ref, `${libPrefix}/${libId}`);
|
|
75
|
+
}
|
|
76
|
+
export function tplField(ref: AnyResourceRef, tplId: string): AnyFieldRef {
|
|
77
|
+
return field(ref, `${tplPrefix}/${tplId}`);
|
|
78
|
+
}
|
|
79
|
+
export function swField(ref: AnyResourceRef, softwareId: string): AnyFieldRef {
|
|
80
|
+
return field(ref, `${softPrefix}/${softwareId}`);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export type Data = {
|
|
84
|
+
/** i.e. @milaboratory/some-package:tpl1 */
|
|
85
|
+
Name: string;
|
|
86
|
+
/** i.e. 1.2.3 */
|
|
87
|
+
Version: string;
|
|
88
|
+
/** Full source code encoded with Base64 */
|
|
89
|
+
Code: string;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
export function fromV2Data(info: infoV2.TemplateData): ResourceStructure {
|
|
93
|
+
return {
|
|
94
|
+
data: {
|
|
95
|
+
Name: info.name,
|
|
96
|
+
Version: info.version,
|
|
97
|
+
Code: Buffer.from(info.src, 'utf8').toString('base64'),
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export namespace PlTemplateOverrideV1 {
|
|
104
|
+
export const type = resourceType('TengoTemplateOverride', '1');
|
|
105
|
+
|
|
106
|
+
export type ResourceStructure = {
|
|
107
|
+
data: Data;
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
export function tplField(ref: AnyResourceRef): AnyFieldRef {
|
|
111
|
+
return field(ref, 'tpl');
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export type Data = {
|
|
115
|
+
OverrideUUID: string;
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
export function fromV2Data(info: infoV2.TemplateData): ResourceStructure {
|
|
119
|
+
if (!info.hashOverride) {
|
|
120
|
+
throw new Error(`template tree rendering error: template has no hash override, cannot generate PlTemplateOverrideV1.ResourceStructure from template data`);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return {
|
|
124
|
+
data: {
|
|
125
|
+
OverrideUUID: info.hashOverride,
|
|
126
|
+
},
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
}
|