@akashnetwork/chain-sdk 1.0.0-alpha.22 → 1.0.0-alpha.23
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/README.md +42 -4
- package/dist/cjs/index.shared.cjs +1 -0
- package/dist/cjs/index.shared.cjs.map +2 -2
- package/dist/cjs/sdl/SDL/SDL.cjs +1 -1
- package/dist/cjs/sdl/SDL/SDL.cjs.map +2 -2
- package/dist/cjs/sdl/SDL/SdlValidationError.cjs.map +2 -2
- package/dist/cjs/sdl/index.cjs +6 -1
- package/dist/cjs/sdl/index.cjs.map +2 -2
- package/dist/cjs/sdl/manifest/generateManifest.cjs +241 -0
- package/dist/cjs/sdl/manifest/generateManifest.cjs.map +7 -0
- package/dist/cjs/sdl/manifest/generateManifestVersion.cjs +84 -0
- package/dist/cjs/sdl/manifest/generateManifestVersion.cjs.map +7 -0
- package/dist/cjs/sdl/manifest/manifestUtils.cjs +138 -0
- package/dist/cjs/sdl/manifest/manifestUtils.cjs.map +7 -0
- package/dist/cjs/sdl/types.cjs.map +1 -1
- package/dist/cjs/sdl/{SDL/utils.cjs.map → utils.cjs.map} +1 -1
- package/dist/cjs/sdl/{SDL/validateSDL → validateSDL}/validateSDL.cjs +20 -13
- package/dist/cjs/sdl/validateSDL/validateSDL.cjs.map +7 -0
- package/dist/cjs/sdl/{SDL/validateSDL → validateSDL}/validateSDLInput.cjs +3 -3
- package/dist/cjs/sdl/validateSDL/validateSDLInput.cjs.map +7 -0
- package/dist/cjs/utils/yaml.cjs +44 -0
- package/dist/cjs/utils/yaml.cjs.map +7 -0
- package/dist/esm/chunk-2XL6OX6E.js +1 -0
- package/dist/esm/chunk-2XL6OX6E.js.map +7 -0
- package/dist/esm/{chunk-K3L3J5XB.js → chunk-4D3QNKFB.js} +3 -3
- package/dist/esm/{chunk-DUCGLLTN.js → chunk-5DCYIWCG.js} +100 -100
- package/dist/esm/{chunk-DUCGLLTN.js.map → chunk-5DCYIWCG.js.map} +4 -4
- package/dist/esm/{chunk-BGBAJIKV.js → chunk-5YECXI3P.js} +2 -2
- package/dist/esm/{chunk-MEXNRJE4.js → chunk-BYQF33C6.js} +2 -2
- package/dist/esm/{chunk-R5DUC7IU.js → chunk-C7UQYVYH.js} +2 -2
- package/dist/esm/{chunk-726NIMPF.js → chunk-JISXXX24.js} +2 -2
- package/dist/esm/{chunk-6OEI5BYK.js → chunk-QSKWS3TI.js} +468 -54
- package/dist/esm/chunk-QSKWS3TI.js.map +7 -0
- package/dist/esm/{chunk-EYW7M3KV.js → chunk-SA4SEZ6F.js} +2 -2
- package/dist/esm/{chunk-ST2QQ72E.js → chunk-VRE72ZD5.js} +2 -2
- package/dist/esm/{chunk-A5CS5ZKQ.js → chunk-XFCN5LRY.js} +2 -2
- package/dist/esm/chunk-Z5KZUB7X.js +364 -0
- package/dist/esm/chunk-Z5KZUB7X.js.map +7 -0
- package/dist/esm/generated/protos/index.akash.v1.js +6 -6
- package/dist/esm/generated/protos/index.akash.v1beta4.js +14 -349
- package/dist/esm/generated/protos/index.akash.v1beta4.js.map +4 -4
- package/dist/esm/generated/protos/index.akash.v1beta5.js +5 -5
- package/dist/esm/generated/protos/index.provider.akash.v1.js +3 -3
- package/dist/esm/generated/protos/index.provider.akash.v2beta3.js +3 -2
- package/dist/esm/index.js +30 -4
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.web.js +29 -3
- package/dist/esm/index.web.js.map +1 -1
- package/dist/esm/{query_akash-XTPHUGJZ.js → query_akash-4CTLBKZR.js} +4 -4
- package/dist/esm/{query_akash-IXSQT2VJ.js → query_akash-DJ7LTLRE.js} +5 -5
- package/dist/esm/{service_akash-YMJ4ZYYX.js → service_akash-AZFAYT7H.js} +4 -4
- package/dist/esm/{service_akash-2EBLHFIP.js → service_akash-VMU3LNBA.js} +4 -4
- package/dist/esm/{service_akash-AYYJKBHS.js → service_akash-WRGOVR7I.js} +4 -4
- package/dist/sdl-schema.yaml +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/index.shared.d.ts +1 -0
- package/dist/types/sdl/SDL/SDL.d.ts +2 -0
- package/dist/types/sdl/SDL/SdlValidationError.d.ts +3 -0
- package/dist/types/sdl/index.d.ts +5 -2
- package/dist/types/sdl/manifest/generateManifest.d.ts +18 -0
- package/dist/types/sdl/manifest/generateManifestVersion.d.ts +3 -0
- package/dist/types/sdl/manifest/manifestUtils.d.ts +27 -0
- package/dist/types/sdl/types.d.ts +52 -0
- package/dist/types/sdl/{SDL/validateSDL → validateSDL}/validateSDL.d.ts +2 -2
- package/dist/types/utils/yaml.d.ts +38 -0
- package/package.json +1 -1
- package/dist/cjs/sdl/SDL/validateSDL/validateSDL.cjs.map +0 -7
- package/dist/cjs/sdl/SDL/validateSDL/validateSDLInput.cjs.map +0 -7
- package/dist/esm/chunk-6OEI5BYK.js.map +0 -7
- /package/dist/cjs/sdl/{SDL/utils.cjs → utils.cjs} +0 -0
- /package/dist/esm/{chunk-K3L3J5XB.js.map → chunk-4D3QNKFB.js.map} +0 -0
- /package/dist/esm/{chunk-BGBAJIKV.js.map → chunk-5YECXI3P.js.map} +0 -0
- /package/dist/esm/{chunk-MEXNRJE4.js.map → chunk-BYQF33C6.js.map} +0 -0
- /package/dist/esm/{chunk-R5DUC7IU.js.map → chunk-C7UQYVYH.js.map} +0 -0
- /package/dist/esm/{chunk-726NIMPF.js.map → chunk-JISXXX24.js.map} +0 -0
- /package/dist/esm/{chunk-EYW7M3KV.js.map → chunk-SA4SEZ6F.js.map} +0 -0
- /package/dist/esm/{chunk-ST2QQ72E.js.map → chunk-VRE72ZD5.js.map} +0 -0
- /package/dist/esm/{chunk-A5CS5ZKQ.js.map → chunk-XFCN5LRY.js.map} +0 -0
- /package/dist/esm/{query_akash-XTPHUGJZ.js.map → query_akash-4CTLBKZR.js.map} +0 -0
- /package/dist/esm/{query_akash-IXSQT2VJ.js.map → query_akash-DJ7LTLRE.js.map} +0 -0
- /package/dist/esm/{service_akash-YMJ4ZYYX.js.map → service_akash-AZFAYT7H.js.map} +0 -0
- /package/dist/esm/{service_akash-2EBLHFIP.js.map → service_akash-VMU3LNBA.js.map} +0 -0
- /package/dist/esm/{service_akash-AYYJKBHS.js.map → service_akash-WRGOVR7I.js.map} +0 -0
- /package/dist/types/sdl/{SDL/utils.d.ts → utils.d.ts} +0 -0
- /package/dist/types/sdl/{SDL/validateSDL → validateSDL}/validateSDLInput.d.ts +0 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/sdl/manifest/generateManifest.ts"],
|
|
4
|
+
"sourcesContent": ["import { PlacementRequirements, SignedBy } from \"../../generated/protos/akash/base/attributes/v1/attribute.ts\";\nimport { CPU } from \"../../generated/protos/akash/base/resources/v1beta4/cpu.ts\";\nimport { GPU } from \"../../generated/protos/akash/base/resources/v1beta4/gpu.ts\";\nimport { Memory } from \"../../generated/protos/akash/base/resources/v1beta4/memory.ts\";\nimport { Resources } from \"../../generated/protos/akash/base/resources/v1beta4/resources.ts\";\nimport { Storage } from \"../../generated/protos/akash/base/resources/v1beta4/storage.ts\";\nimport { GroupSpec } from \"../../generated/protos/akash/deployment/v1beta4/groupspec.ts\";\nimport { ResourceUnit } from \"../../generated/protos/akash/deployment/v1beta4/resourceunit.ts\";\nimport { Group } from \"../../generated/protos/akash/manifest/v2beta3/group.ts\";\nimport { ImageCredentials, Service, ServiceParams, StorageParams } from \"../../generated/protos/akash/manifest/v2beta3/service.ts\";\nimport { ServiceExpose } from \"../../generated/protos/akash/manifest/v2beta3/serviceexpose.ts\";\nimport { MAINNET_ID } from \"../../network/config.ts\";\nimport type { NetworkId } from \"../../network/types.ts\";\nimport type { ValidationError } from \"../../utils/jsonSchemaValidation.ts\";\nimport { castArray } from \"../utils.ts\";\nimport type { SDLInput } from \"../validateSDL/validateSDL.ts\";\nimport { validateSDL } from \"../validateSDL/validateSDL.ts\";\nimport {\n buildHttpOptions,\n buildResourceAttributes,\n buildServiceEndpoints,\n buildStorageAttributes,\n computeEndpointSequenceNumbers,\n encodeResourceValue,\n parseCpuUnits,\n parseGpuUnits,\n parseMemoryBytes,\n parseServiceProto,\n parseStorageBytes,\n type SDLCompute,\n type SDLService,\n transformGpuAttributes,\n} from \"./manifestUtils.ts\";\n\nexport interface BuildResult {\n groups: Group[];\n groupSpecs: GroupSpec[];\n}\n\nexport type Manifest = BuildResult[\"groups\"];\nexport type GenerateManifestResult =\n | { ok?: false; value: ValidationError[] }\n | { ok: true; value: BuildResult };\nexport function generateManifest(sdl: SDLInput, networkId: NetworkId = MAINNET_ID): GenerateManifestResult {\n const errors = validateSDL(sdl, networkId);\n if (errors) return { ok: false, value: errors };\n\n const endpointSequenceNumbers = computeEndpointSequenceNumbers(sdl.services);\n const groupsMap = new Map<string, {\n dgroup: GroupSpec;\n boundComputes: Record<string, number>;\n }>();\n const resourceIds = new Map<string, number>();\n\n const deploymentsByPlacement = new Map<string, [string, { profile: string; count: number }][]>();\n for (const [svcName, placements] of Object.entries(sdl.deployment)) {\n for (const [placementName, deployment] of Object.entries(placements)) {\n let list = deploymentsByPlacement.get(placementName);\n if (!list) {\n list = [];\n deploymentsByPlacement.set(placementName, list);\n }\n list.push([svcName, deployment]);\n }\n }\n for (const list of deploymentsByPlacement.values()) {\n list.sort(([a], [b]) => a.localeCompare(b));\n }\n\n const services = Object.entries(sdl.services).sort(([a], [b]) => a.localeCompare(b));\n\n for (const [svcName, service] of services) {\n for (const [placementName, svcdepl] of Object.entries(sdl.deployment[svcName])) {\n const compute = sdl.profiles.compute[svcdepl.profile];\n const infra = sdl.profiles.placement[placementName];\n const pricing = infra.pricing[svcdepl.profile];\n const price = {\n denom: pricing.denom,\n amount: pricing.amount?.toString(),\n };\n\n let group = groupsMap.get(placementName);\n\n if (!group) {\n group = {\n dgroup: GroupSpec.fromPartial({\n name: placementName,\n resources: [],\n requirements: PlacementRequirements.fromPartial({\n attributes: buildResourceAttributes(infra.attributes) ?? [],\n signedBy: SignedBy.fromPartial({\n allOf: infra.signedBy?.allOf,\n anyOf: infra.signedBy?.anyOf,\n }),\n }),\n }),\n boundComputes: {},\n };\n\n groupsMap.set(placementName, group);\n }\n\n const profileKey = `${placementName}:${svcdepl.profile}`;\n const location = group.boundComputes[svcdepl.profile];\n\n if (location === undefined) {\n const resId = group.dgroup.resources.length > 0\n ? group.dgroup.resources.length + 1\n : 1;\n\n resourceIds.set(profileKey, resId);\n\n const resources = buildResources(resId, compute, service, endpointSequenceNumbers);\n\n group.dgroup.resources.push(\n ResourceUnit.fromPartial({\n resource: resources,\n count: svcdepl.count,\n price,\n }),\n );\n\n group.boundComputes[svcdepl.profile] = group.dgroup.resources.length - 1;\n } else {\n if (!resourceIds.has(profileKey)) {\n resourceIds.set(profileKey, group.dgroup.resources[location].resource!.id);\n }\n\n group.dgroup.resources[location].count += svcdepl.count;\n group.dgroup.resources[location].resource!.endpoints.push(\n ...buildServiceEndpoints(service, endpointSequenceNumbers),\n );\n }\n }\n }\n\n for (const group of groupsMap.values()) {\n for (const resourceUnit of group.dgroup.resources) {\n resourceUnit.resource!.endpoints.sort(\n (a, b) => a.kind - b.kind || a.sequenceNumber - b.sequenceNumber,\n );\n }\n }\n\n const sortedGroupNames = [...groupsMap.keys()].sort();\n let groups: Group[] | undefined;\n let groupSpecs: GroupSpec[] | undefined;\n\n const manifest = {\n get groups() {\n groups ??= sortedGroupNames.map((placementName) => {\n const deployments = deploymentsByPlacement.get(placementName)!;\n\n return Group.fromPartial({\n name: placementName,\n services: deployments.map(([svcName]) => {\n const service = sdl.services[svcName];\n const deployment = sdl.deployment[svcName][placementName];\n const compute = sdl.profiles.compute[deployment.profile];\n const resourceId = resourceIds.get(`${placementName}:${deployment.profile}`) || 1;\n\n return buildManifestService(\n resourceId,\n svcName,\n service,\n compute,\n deployment.count,\n endpointSequenceNumbers,\n );\n }),\n });\n });\n return groups;\n },\n get groupSpecs() {\n groupSpecs ??= sortedGroupNames.map((name) => groupsMap.get(name)!.dgroup);\n return groupSpecs;\n },\n };\n\n return { ok: true, value: manifest };\n}\n\nfunction buildResources(\n id: number,\n compute: SDLCompute,\n service: SDLService,\n endpointSequenceNumbers: Record<string, number>,\n): Resources {\n const res = compute.resources;\n const cpuAttributes = buildResourceAttributes(res.cpu.attributes);\n const gpuAttributes = res.gpu?.attributes ? transformGpuAttributes(res.gpu.attributes) : [];\n\n return Resources.fromPartial({\n id,\n cpu: CPU.fromPartial({\n units: { val: encodeResourceValue(parseCpuUnits(res.cpu)) },\n attributes: cpuAttributes,\n }),\n memory: Memory.fromPartial({\n quantity: { val: encodeResourceValue(parseMemoryBytes(res.memory)) },\n }),\n storage: castArray(res.storage).map((s) =>\n Storage.fromPartial({\n name: s.name || \"default\",\n quantity: { val: encodeResourceValue(parseStorageBytes(s.size)) },\n attributes: buildStorageAttributes(s.attributes),\n }),\n ),\n gpu: GPU.fromPartial({\n units: { val: encodeResourceValue(parseGpuUnits(res.gpu)) },\n attributes: gpuAttributes,\n }),\n endpoints: buildServiceEndpoints(service, endpointSequenceNumbers),\n });\n}\n\nfunction buildManifestService(\n resourceId: number,\n name: string,\n service: SDLService,\n compute: SDLCompute,\n count: number,\n endpointSequenceNumbers: Record<string, number>,\n): Service {\n const credentials = service.credentials\n ? ImageCredentials.fromPartial({\n host: service.credentials.host,\n email: service.credentials.email || \"\",\n username: service.credentials.username,\n password: service.credentials.password,\n })\n : undefined;\n\n const params = buildParams(service);\n\n return Service.fromPartial({\n name,\n image: service.image,\n command: service.command || [],\n args: service.args || [],\n env: service.env || [],\n resources: buildResources(resourceId, compute, service, endpointSequenceNumbers),\n count,\n expose: buildManifestExpose(service, endpointSequenceNumbers),\n params,\n credentials,\n });\n}\n\nfunction buildParams(service: SDLService): ServiceParams | undefined {\n if (!service.params) return undefined;\n\n const storageEntries = Object.entries(service.params.storage ?? {});\n const result = ServiceParams.fromPartial({\n storage: storageEntries.map(([name, config]) =>\n StorageParams.fromPartial({\n name,\n mount: config.mount || \"\",\n readOnly: config.readOnly || false,\n }),\n ),\n });\n\n // Permissions are not in the protobuf type but need to be preserved\n if (service.params.permissions) {\n (result as unknown as Record<string, unknown>).permissions = service.params.permissions;\n }\n\n return result;\n}\n\nfunction buildManifestExpose(\n service: SDLService,\n endpointSequenceNumbers: Record<string, number>,\n): ServiceExpose[] {\n return (service.expose ?? [])\n .flatMap((expose) =>\n (expose.to ?? []).map((to) =>\n ServiceExpose.fromPartial({\n port: expose.port,\n externalPort: expose.as,\n proto: parseServiceProto(expose.proto),\n service: to.service || \"\",\n global: to.global || false,\n hosts: expose.accept || [],\n httpOptions: buildHttpOptions(expose.http_options),\n ip: to.ip || \"\",\n endpointSequenceNumber: endpointSequenceNumbers[to.ip!],\n }),\n ),\n )\n .sort((a, b) => {\n if (a.service !== b.service) return a.service.localeCompare(b.service);\n if (a.port !== b.port) return a.port - b.port;\n if (a.proto !== b.proto) return a.proto.localeCompare(b.proto);\n if (a.global !== b.global) return a.global ? -1 : 1;\n return 0;\n });\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAgD;AAChD,iBAAoB;AACpB,iBAAoB;AACpB,oBAAuB;AACvB,uBAA0B;AAC1B,qBAAwB;AACxB,uBAA0B;AAC1B,0BAA6B;AAC7B,mBAAsB;AACtB,qBAAwE;AACxE,2BAA8B;AAC9B,oBAA2B;AAG3B,mBAA0B;AAE1B,yBAA4B;AAC5B,2BAeO;AAWA,SAAS,iBAAiB,KAAe,YAAuB,0BAAoC;AACzG,QAAM,aAAS,gCAAY,KAAK,SAAS;AACzC,MAAI,OAAQ,QAAO,EAAE,IAAI,OAAO,OAAO,OAAO;AAE9C,QAAM,8BAA0B,qDAA+B,IAAI,QAAQ;AAC3E,QAAM,YAAY,oBAAI,IAGnB;AACH,QAAM,cAAc,oBAAI,IAAoB;AAE5C,QAAM,yBAAyB,oBAAI,IAA4D;AAC/F,aAAW,CAAC,SAAS,U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|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var generateManifestVersion_exports = {};
|
|
30
|
+
__export(generateManifestVersion_exports, {
|
|
31
|
+
generateManifestVersion: () => generateManifestVersion,
|
|
32
|
+
manifestToSortedJSON: () => manifestToSortedJSON
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(generateManifestVersion_exports);
|
|
35
|
+
var import_json_stable_stringify = __toESM(require("json-stable-stringify"), 1);
|
|
36
|
+
const decoder = new TextDecoder();
|
|
37
|
+
const encoder = new TextEncoder();
|
|
38
|
+
const NULLABLE_MANIFEST_KEYS = /* @__PURE__ */ new Set(["command", "args", "env", "hosts"]);
|
|
39
|
+
const OMITTED_MANIFEST_KEYS = /* @__PURE__ */ new Set(["kind", "attributes"]);
|
|
40
|
+
async function generateManifestVersion(manifest) {
|
|
41
|
+
const jsonStr = manifestToSortedJSON(manifest);
|
|
42
|
+
const sortedBytes = encoder.encode(jsonStr);
|
|
43
|
+
const sum = await crypto.subtle.digest("SHA-256", sortedBytes);
|
|
44
|
+
return new Uint8Array(sum);
|
|
45
|
+
}
|
|
46
|
+
function manifestToSortedJSON(manifest) {
|
|
47
|
+
const json = (0, import_json_stable_stringify.default)(manifest, { replacer: manifestReplacer }) || "";
|
|
48
|
+
return escapeHtml(renameFields(json));
|
|
49
|
+
}
|
|
50
|
+
function manifestReplacer(key, value) {
|
|
51
|
+
if (value && value instanceof Uint8Array) {
|
|
52
|
+
return decoder.decode(value);
|
|
53
|
+
}
|
|
54
|
+
if (typeof key !== "string") {
|
|
55
|
+
return value;
|
|
56
|
+
}
|
|
57
|
+
if (typeof this === "object" && this && Object.hasOwn(this, "command") && key === "credentials" && value == null) {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
if (NULLABLE_MANIFEST_KEYS.has(key) && (Array.isArray(value) && value.length === 0 || value == null)) {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
if (OMITTED_MANIFEST_KEYS.has(key) && (Array.isArray(value) && value.length === 0 || value === 0)) {
|
|
64
|
+
return void 0;
|
|
65
|
+
}
|
|
66
|
+
return value;
|
|
67
|
+
}
|
|
68
|
+
const MANIFEST_VERSION_FIELD_MAPPING = { quantity: "size", sequenceNumber: "sequence_number" };
|
|
69
|
+
const MANIFEST_VERSION_FIELD_REGEX = new RegExp(`"(${Object.keys(MANIFEST_VERSION_FIELD_MAPPING).join("|")})":`, "g");
|
|
70
|
+
function renameFields(jsonStr) {
|
|
71
|
+
MANIFEST_VERSION_FIELD_REGEX.lastIndex = 0;
|
|
72
|
+
return jsonStr.replace(MANIFEST_VERSION_FIELD_REGEX, (_, field) => `"${MANIFEST_VERSION_FIELD_MAPPING[field]}":`);
|
|
73
|
+
}
|
|
74
|
+
const htmlEscapes = {
|
|
75
|
+
"<": "\\u003c",
|
|
76
|
+
">": "\\u003e",
|
|
77
|
+
"&": "\\u0026"
|
|
78
|
+
};
|
|
79
|
+
const HTML_SPECIAL_CHARS_REGEX = new RegExp(`[${Object.keys(htmlEscapes).join("")}]`, "g");
|
|
80
|
+
function escapeHtml(raw) {
|
|
81
|
+
HTML_SPECIAL_CHARS_REGEX.lastIndex = 0;
|
|
82
|
+
return raw.replace(HTML_SPECIAL_CHARS_REGEX, (ch) => htmlEscapes[ch]);
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=generateManifestVersion.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/sdl/manifest/generateManifestVersion.ts"],
|
|
4
|
+
"sourcesContent": ["import { default as stableStringify } from \"json-stable-stringify\";\n\nimport type { Manifest } from \"./generateManifest.ts\";\n\nconst decoder = new TextDecoder();\nconst encoder = new TextEncoder();\nconst NULLABLE_MANIFEST_KEYS = new Set([\"command\", \"args\", \"env\", \"hosts\"]);\nconst OMITTED_MANIFEST_KEYS = new Set([\"kind\", \"attributes\"]);\n\nexport async function generateManifestVersion(manifest: Manifest): Promise<Uint8Array> {\n const jsonStr = manifestToSortedJSON(manifest);\n const sortedBytes = encoder.encode(jsonStr);\n const sum = await crypto.subtle.digest(\"SHA-256\", sortedBytes);\n return new Uint8Array(sum);\n}\n\nexport function manifestToSortedJSON(manifest: Manifest): string {\n const json = stableStringify(manifest, { replacer: manifestReplacer }) || \"\";\n return escapeHtml(renameFields(json));\n}\n\nfunction manifestReplacer(this: unknown, key: string | number, value: unknown): unknown {\n if (value && value instanceof Uint8Array) {\n return decoder.decode(value);\n }\n\n if (typeof key !== \"string\") {\n return value;\n }\n\n // only top-level \"credentials\" field can be null, credentials in params should be omitted\n if (typeof this === \"object\" && this && Object.hasOwn(this, \"command\") && key === \"credentials\" && value == null) {\n return null;\n }\n\n if (NULLABLE_MANIFEST_KEYS.has(key) && ((Array.isArray(value) && value.length === 0) || value == null)) {\n return null;\n }\n\n if (OMITTED_MANIFEST_KEYS.has(key) && ((Array.isArray(value) && value.length === 0) || value === 0)) {\n return undefined;\n }\n\n return value;\n}\n\nconst MANIFEST_VERSION_FIELD_MAPPING: Record<string, string> = { quantity: \"size\", sequenceNumber: \"sequence_number\" };\nconst MANIFEST_VERSION_FIELD_REGEX = new RegExp(`\"(${Object.keys(MANIFEST_VERSION_FIELD_MAPPING).join(\"|\")})\":`, \"g\");\nfunction renameFields(jsonStr: string): string {\n MANIFEST_VERSION_FIELD_REGEX.lastIndex = 0; // reset regex state\n return jsonStr.replace(MANIFEST_VERSION_FIELD_REGEX, (_, field) => `\"${MANIFEST_VERSION_FIELD_MAPPING[field]}\":`);\n}\n\nconst htmlEscapes: Record<string, string> = {\n \"<\": \"\\\\u003c\",\n \">\": \"\\\\u003e\",\n \"&\": \"\\\\u0026\",\n};\n\nconst HTML_SPECIAL_CHARS_REGEX = new RegExp(`[${Object.keys(htmlEscapes).join(\"\")}]`, \"g\");\nfunction escapeHtml(raw: string): string {\n HTML_SPECIAL_CHARS_REGEX.lastIndex = 0; // reset regex state\n return raw.replace(HTML_SPECIAL_CHARS_REGEX, (ch) => htmlEscapes[ch]);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mCAA2C;AAI3C,MAAM,UAAU,IAAI,YAAY;AAChC,MAAM,UAAU,IAAI,YAAY;AAChC,MAAM,yBAAyB,oBAAI,IAAI,CAAC,WAAW,QAAQ,OAAO,OAAO,CA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EA,MAAM,cAAsC;AAAA,EAC1C,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AACP;AAEA,MAAM,2BAA2B,IAAI,OAAO,IAAI,OAAO,KAAK,WAAW,EAAE,KAAK,EAAE,CAAC,KAAK,GAAG;AACzF,SAAS,WAAW,KAAqB;AACvC,2BAAyB,YAAY;AACrC,SAAO,IAAI,QAAQ,0BAA0B,CAAC,OAAO,YAAY,EAAE,CAAC;AACtE;",
|
|
6
|
+
"names": ["stableStringify"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var manifestUtils_exports = {};
|
|
20
|
+
__export(manifestUtils_exports, {
|
|
21
|
+
buildHttpOptions: () => buildHttpOptions,
|
|
22
|
+
buildResourceAttributes: () => buildResourceAttributes,
|
|
23
|
+
buildServiceEndpoints: () => buildServiceEndpoints,
|
|
24
|
+
buildStorageAttributes: () => buildStorageAttributes,
|
|
25
|
+
computeEndpointSequenceNumbers: () => computeEndpointSequenceNumbers,
|
|
26
|
+
encodeResourceValue: () => encodeResourceValue,
|
|
27
|
+
isIngress: () => isIngress,
|
|
28
|
+
parseCpuUnits: () => parseCpuUnits,
|
|
29
|
+
parseGpuUnits: () => parseGpuUnits,
|
|
30
|
+
parseMemoryBytes: () => parseMemoryBytes,
|
|
31
|
+
parseServiceProto: () => parseServiceProto,
|
|
32
|
+
parseStorageBytes: () => parseStorageBytes,
|
|
33
|
+
transformGpuAttributes: () => transformGpuAttributes
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(manifestUtils_exports);
|
|
36
|
+
var import_index_akash_v1beta4 = require("../../generated/protos/index.akash.v1beta4.cjs");
|
|
37
|
+
var import_index_provider_akash_v2beta3 = require("../../generated/protos/index.provider.akash.v2beta3.cjs");
|
|
38
|
+
var import_sizes = require("../sizes.cjs");
|
|
39
|
+
const encoder = new TextEncoder();
|
|
40
|
+
function encodeResourceValue(value) {
|
|
41
|
+
return encoder.encode(value.toString());
|
|
42
|
+
}
|
|
43
|
+
function computeEndpointSequenceNumbers(services) {
|
|
44
|
+
const endpointNames = [];
|
|
45
|
+
for (const service of Object.values(services)) {
|
|
46
|
+
if (!service.expose) continue;
|
|
47
|
+
for (const expose of service.expose) {
|
|
48
|
+
if (!expose.to) continue;
|
|
49
|
+
for (const to of expose.to) {
|
|
50
|
+
if (to.global && to.ip && to.ip.length > 0) {
|
|
51
|
+
endpointNames.push(to.ip);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return endpointNames.sort().reduce((result, name, seqNumber) => {
|
|
57
|
+
result[name] = seqNumber + 1;
|
|
58
|
+
return result;
|
|
59
|
+
}, {});
|
|
60
|
+
}
|
|
61
|
+
function isIngress(proto, global, externalPort, port) {
|
|
62
|
+
const effectivePort = externalPort === 0 ? port : externalPort;
|
|
63
|
+
return global && proto === "TCP" && effectivePort === 80;
|
|
64
|
+
}
|
|
65
|
+
function transformGpuAttributes(attributes) {
|
|
66
|
+
const vendor = attributes.vendor;
|
|
67
|
+
if (!vendor) return [];
|
|
68
|
+
return Object.entries(vendor).flatMap(
|
|
69
|
+
([vendorName, models]) => models ? models.map((model) => {
|
|
70
|
+
let key = `vendor/${vendorName}/model/${model.model}`;
|
|
71
|
+
if (model.ram) key += `/ram/${model.ram}`;
|
|
72
|
+
if (model.interface) key += `/interface/${model.interface}`;
|
|
73
|
+
return { key, value: "true" };
|
|
74
|
+
}) : [{ key: `vendor/${vendorName}/model/*`, value: "true" }]
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
function buildHttpOptions(httpOptions) {
|
|
78
|
+
return import_index_provider_akash_v2beta3.ServiceExposeHTTPOptions.fromPartial({
|
|
79
|
+
maxBodySize: httpOptions?.max_body_size ?? 1048576,
|
|
80
|
+
readTimeout: httpOptions?.read_timeout ?? 6e4,
|
|
81
|
+
sendTimeout: httpOptions?.send_timeout ?? 6e4,
|
|
82
|
+
nextTries: httpOptions?.next_tries ?? 3,
|
|
83
|
+
nextTimeout: httpOptions?.next_timeout ?? 0,
|
|
84
|
+
nextCases: httpOptions?.next_cases ?? ["error", "timeout"]
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
function buildStorageAttributes(attributes) {
|
|
88
|
+
if (!attributes) return [];
|
|
89
|
+
const pairs = Object.entries(attributes).map(([key, value]) => ({
|
|
90
|
+
key,
|
|
91
|
+
value: String(value)
|
|
92
|
+
}));
|
|
93
|
+
if (attributes.class === "ram" && !("persistent" in attributes)) {
|
|
94
|
+
pairs.push({ key: "persistent", value: "false" });
|
|
95
|
+
}
|
|
96
|
+
pairs.sort((a, b) => a.key.localeCompare(b.key));
|
|
97
|
+
return pairs;
|
|
98
|
+
}
|
|
99
|
+
function parseServiceProto(proto) {
|
|
100
|
+
return proto?.toUpperCase() || "TCP";
|
|
101
|
+
}
|
|
102
|
+
function buildServiceEndpoints(service, endpointSequenceNumbers) {
|
|
103
|
+
return (service.expose ?? []).flatMap(
|
|
104
|
+
(expose) => (expose.to ?? []).filter((to) => to.global).flatMap((to) => {
|
|
105
|
+
const externalPort = expose.as || 0;
|
|
106
|
+
const proto = parseServiceProto(expose.proto);
|
|
107
|
+
const kind = isIngress(proto, !!to.global, externalPort, expose.port) ? import_index_akash_v1beta4.Endpoint_Kind.SHARED_HTTP : import_index_akash_v1beta4.Endpoint_Kind.RANDOM_PORT;
|
|
108
|
+
const defaultEp = import_index_akash_v1beta4.Endpoint.fromPartial({
|
|
109
|
+
kind,
|
|
110
|
+
sequenceNumber: 0
|
|
111
|
+
});
|
|
112
|
+
const leasedEp = to.ip && to.ip.length > 0 ? import_index_akash_v1beta4.Endpoint.fromPartial({
|
|
113
|
+
kind: import_index_akash_v1beta4.Endpoint_Kind.LEASED_IP,
|
|
114
|
+
sequenceNumber: endpointSequenceNumbers[to.ip]
|
|
115
|
+
}) : void 0;
|
|
116
|
+
return leasedEp ? [defaultEp, leasedEp] : [defaultEp];
|
|
117
|
+
})
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
function parseCpuUnits(cpu) {
|
|
121
|
+
return typeof cpu.units === "string" ? (0, import_sizes.convertCpuResourceString)(cpu.units) : cpu.units * 1e3;
|
|
122
|
+
}
|
|
123
|
+
function parseMemoryBytes(memory) {
|
|
124
|
+
return (0, import_sizes.convertResourceString)(memory.size);
|
|
125
|
+
}
|
|
126
|
+
function parseStorageBytes(size) {
|
|
127
|
+
return (0, import_sizes.convertResourceString)(size);
|
|
128
|
+
}
|
|
129
|
+
function parseGpuUnits(gpu) {
|
|
130
|
+
const value = gpu?.units;
|
|
131
|
+
if (value === void 0 || value === null) return 0;
|
|
132
|
+
return typeof value === "string" ? parseInt(value, 10) : value;
|
|
133
|
+
}
|
|
134
|
+
function buildResourceAttributes(attributes) {
|
|
135
|
+
if (!attributes) return void 0;
|
|
136
|
+
return Object.entries(attributes).sort(([a], [b]) => a.localeCompare(b)).map(([key, value]) => ({ key, value: String(value) }));
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=manifestUtils.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/sdl/manifest/manifestUtils.ts"],
|
|
4
|
+
"sourcesContent": ["import type { Attribute } from \"../../generated/protos/index.akash.v1.ts\";\nimport {\n Endpoint,\n Endpoint_Kind,\n} from \"../../generated/protos/index.akash.v1beta4.ts\";\nimport {\n ServiceExposeHTTPOptions,\n} from \"../../generated/protos/index.provider.akash.v2beta3.ts\";\nimport { convertCpuResourceString, convertResourceString } from \"../sizes.ts\";\nimport type { SDLInput } from \"../validateSDL/validateSDL.ts\";\nimport type { StorageAttributesValidation } from \"../validateSDL/validateSDLInput.ts\";\n\ntype SDLService = SDLInput[\"services\"][string];\ntype SDLExpose = NonNullable<SDLService[\"expose\"]>[number];\ntype SDLExposeTo = NonNullable<SDLExpose[\"to\"]>[number];\ntype SDLHttpOptions = SDLExpose[\"http_options\"];\ntype SDLCompute = SDLInput[\"profiles\"][\"compute\"][string];\ntype SDLStorage = SDLCompute[\"resources\"][\"storage\"];\ntype SDLStorageVolume = SDLStorage extends (infer T)[] ? T : SDLStorage;\ntype SDLGpuAttributes = NonNullable<NonNullable<SDLCompute[\"resources\"][\"gpu\"]>[\"attributes\"]>;\n\nexport type { SDLCompute, SDLExpose, SDLExposeTo, SDLGpuAttributes, SDLHttpOptions, SDLService, SDLStorage, SDLStorageVolume };\n\nconst encoder = new TextEncoder();\n\nexport function encodeResourceValue(value: number): Uint8Array {\n return encoder.encode(value.toString());\n}\n\nexport function computeEndpointSequenceNumbers(services: SDLInput[\"services\"]): Record<string, number> {\n const endpointNames: string[] = [];\n\n for (const service of Object.values(services)) {\n if (!service.expose) continue;\n for (const expose of service.expose) {\n if (!expose.to) continue;\n for (const to of expose.to) {\n if (to.global && to.ip && to.ip.length > 0) {\n endpointNames.push(to.ip);\n }\n }\n }\n }\n\n return endpointNames.sort().reduce<Record<string, number>>((result, name, seqNumber) => {\n result[name] = seqNumber + 1;\n return result;\n }, {});\n}\n\nexport function isIngress(proto: string, global: boolean, externalPort: number, port: number): boolean {\n const effectivePort = externalPort === 0 ? port : externalPort;\n return global && proto === \"TCP\" && effectivePort === 80;\n}\n\nexport function transformGpuAttributes(attributes: SDLGpuAttributes): Attribute[] {\n const vendor = attributes.vendor;\n if (!vendor) return [];\n\n return Object.entries(vendor).flatMap(([vendorName, models]) =>\n models\n ? models.map((model) => {\n let key = `vendor/${vendorName}/model/${model.model}`;\n if (model.ram) key += `/ram/${model.ram}`;\n if (model.interface) key += `/interface/${model.interface}`;\n return { key, value: \"true\" };\n })\n : [{ key: `vendor/${vendorName}/model/*`, value: \"true\" }],\n );\n}\n\nexport function buildHttpOptions(httpOptions?: SDLHttpOptions): ServiceExposeHTTPOptions {\n return ServiceExposeHTTPOptions.fromPartial({\n maxBodySize: httpOptions?.max_body_size ?? 1048576,\n readTimeout: httpOptions?.read_timeout ?? 60000,\n sendTimeout: httpOptions?.send_timeout ?? 60000,\n nextTries: httpOptions?.next_tries ?? 3,\n nextTimeout: httpOptions?.next_timeout ?? 0,\n nextCases: httpOptions?.next_cases ?? [\"error\", \"timeout\"],\n });\n}\n\nexport function buildStorageAttributes(attributes?: StorageAttributesValidation): Attribute[] {\n if (!attributes) return [];\n\n const pairs: Attribute[] = Object.entries(attributes).map(([key, value]) => ({\n key,\n value: String(value),\n }));\n\n if (attributes.class === \"ram\" && !(\"persistent\" in attributes)) {\n pairs.push({ key: \"persistent\", value: \"false\" });\n }\n\n pairs.sort((a, b) => a.key.localeCompare(b.key));\n return pairs;\n}\n\nexport function parseServiceProto(proto?: string): string {\n return proto?.toUpperCase() || \"TCP\";\n}\n\nexport function buildServiceEndpoints(\n service: SDLService,\n endpointSequenceNumbers: Record<string, number>,\n): Endpoint[] {\n return (service.expose ?? []).flatMap((expose) =>\n (expose.to ?? [])\n .filter((to) => to.global)\n .flatMap((to) => {\n const externalPort = expose.as || 0;\n const proto = parseServiceProto(expose.proto);\n const kind = isIngress(proto, !!to.global, externalPort, expose.port)\n ? Endpoint_Kind.SHARED_HTTP\n : Endpoint_Kind.RANDOM_PORT;\n\n const defaultEp = Endpoint.fromPartial({\n kind,\n sequenceNumber: 0,\n });\n\n const leasedEp = to.ip && to.ip.length > 0\n ? Endpoint.fromPartial({\n kind: Endpoint_Kind.LEASED_IP,\n sequenceNumber: endpointSequenceNumbers[to.ip],\n })\n : undefined;\n\n return leasedEp ? [defaultEp, leasedEp] : [defaultEp];\n }),\n );\n}\n\nexport function parseCpuUnits(cpu: SDLCompute[\"resources\"][\"cpu\"]): number {\n return typeof cpu.units === \"string\"\n ? convertCpuResourceString(cpu.units)\n : cpu.units * 1000;\n}\n\nexport function parseMemoryBytes(memory: SDLCompute[\"resources\"][\"memory\"]): number {\n return convertResourceString(memory.size);\n}\n\nexport function parseStorageBytes(size: string): number {\n return convertResourceString(size);\n}\n\nexport function parseGpuUnits(gpu?: SDLCompute[\"resources\"][\"gpu\"]): number {\n const value = gpu?.units;\n if (value === undefined || value === null) return 0;\n return typeof value === \"string\" ? parseInt(value, 10) : value;\n}\n\nexport function buildResourceAttributes(attributes?: Record<string, unknown>): Attribute[] | undefined {\n if (!attributes) return undefined;\n return Object.entries(attributes)\n .sort(([a], [b]) => a.localeCompare(b))\n .map(([key, value]) => ({ key, value: String(value) }));\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,iCAGO;AACP,0CAEO;AACP,mBAAgE;AAehE,MAAM,UAAU,IAAI,YAAY;AAEzB,SAAS,oBAAoB,OAA2B;AAC7D,SAAO,QAAQ,OAAO,MAAM,SAAS,CAAC;AACxC;AAEO,SAAS,+BAA+B,UAAwD;AACrG,QAAM,gBAA0B,CAAC;AAEjC,aAAW,WAAW,OAAO,OAAO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;AACF;AAEO,SAAS,cAAc,KAA6C;AACzE,SAAO,OAAO,IAAI,UAAU,eACxB,uCAAyB,IAAI,KAAK,IAClC,IAAI,QAAQ;AAClB;AAEO,SAAS,iBAAiB,QAAmD;AAClF,aAAO,oCAAsB,OAAO,IAAI;AAC1C;AAEO,SAAS,kBAAkB,MAAsB;AACtD,aAAO,oCAAsB,IAAI;AACnC;AAEO,SAAS,cAAc,KAA8C;AAC1E,QAAM,QAAQ,KAAK;AACnB,MAAI,UAAU,UAAa,UAAU,KAAM,QAAO;AAClD,SAAO,OAAO,UAAU,WAAW,SAAS,OAAO,EAAE,IAAI;AAC3D;AAEO,SAAS,wBAAwB,YAA+D;AACrG,MAAI,CAAC,WAAY,QAAO;AACxB,SAAO,OAAO,QAAQ,UAAU,EAC7B,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,EACrC,IAAI,CAAC,CAAC,KAAK,KAAK,OAAO,EAAE,KAAK,OAAO,OAAO,KAAK,EAAE,EAAE;AAC1D;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/sdl/types.ts"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable @typescript-eslint/no-explicit-any */\nexport type v2Manifest = v2Group[];\n\nexport type v3Manifest = v3Group[];\n\nexport type v3Group = {\n name: string;\n services: v3ManifestService[];\n};\n\nexport type v2Group = {\n Name: string;\n Services: v2ManifestService[];\n};\n\nexport type v2ManifestService = {\n Name: string;\n Image: string;\n Command: string[] | null;\n Args: string[] | null;\n Env: string[] | null;\n Resources: ResourceUnits;\n Count: number;\n Expose: v2ServiceExpose[];\n params?: v2ManifestServiceParams;\n};\n\nexport type v3ManifestService = {\n name: string;\n image: string;\n command: string[] | null;\n args: string[] | null;\n env: string[] | null;\n resources: ResourceUnits;\n count: number;\n expose: v3ServiceExpose[];\n params?: v3ManifestServiceParams | null;\n credentials: v2ServiceImageCredentials | null;\n};\n\nexport type v2ServiceExposeHttpOptions = {\n MaxBodySize: number;\n ReadTimeout: number;\n SendTimeout: number;\n NextTries: number;\n NextTimeout: number;\n NextCases: string[];\n};\n\nexport type v3ServiceExposeHttpOptions = {\n maxBodySize: number;\n readTimeout: number;\n sendTimeout: number;\n nextTries: number;\n nextTimeout: number;\n nextCases: string[];\n};\n\nexport type ResourceUnits = Record<string, any>;\n\nexport type v2ServiceExpose = {\n Port: number;\n ExternalPort: number;\n Proto: string;\n Service: any;\n Global: boolean;\n Hosts: any;\n HTTPOptions: v2ServiceExposeHttpOptions;\n IP: string;\n EndpointSequenceNumber: number;\n};\n\nexport type v3ServiceExpose = {\n port: number;\n externalPort: number;\n proto: string;\n service: any;\n global: boolean;\n hosts: any;\n httpOptions: v3ServiceExposeHttpOptions;\n ip: string;\n endpointSequenceNumber: number;\n};\n\ntype v2ServicePermissionsScope = \"deployment\" | \"logs\";\n\nexport type v2ServicePermissions = {\n read?: v2ServicePermissionsScope[];\n};\n\nexport type v2ManifestServiceParams = {\n Storage: v2ServiceStorageParams[];\n Permissions?: v2ServicePermissions;\n};\n\nexport type v3ManifestServiceParams = {\n storage: v2ServiceStorageParams[];\n permissions?: v2ServicePermissions;\n};\n\nexport type v2Sdl = {\n services: Record<string, v2Service>;\n profiles: v2Profiles;\n deployment: Record<string, v2Deployment>;\n endpoints: Record<string, v2Endpoint>;\n};\n\nexport type v3Sdl = {\n services: Record<string, v2Service>;\n profiles: v3Profiles;\n deployment: Record<string, v2Deployment>;\n endpoints: Record<string, v2Endpoint>;\n};\n\nexport type v2Endpoint = {\n kind: string;\n};\n\nexport type v2ExposeTo = {\n service?: string;\n global?: boolean;\n http_options: v2HTTPOptions;\n ip: string;\n};\n\nexport type v2HTTPOptions = {\n max_body_size: number;\n read_timeout: number;\n send_timeout: number;\n next_tries: number;\n next_timeout: number;\n next_cases: string[];\n};\n\nexport type v2Accept = {\n items?: string[];\n};\n\nexport type v2Expose = {\n port: number;\n as: number;\n proto?: string;\n to?: v2ExposeTo[];\n accept: v2Accept;\n http_options: v2HTTPOptions;\n};\n\nexport type v2Dependency = {\n service: string;\n};\n\nexport type v2ServiceStorageParams = {\n name: string;\n mount: string;\n readOnly: boolean;\n};\n\nexport type v2ServiceParams = {\n storage?: Record<string, v2ServiceStorageParams>;\n permissions?: v2ServicePermissions;\n};\n\nexport type v2ServiceImageCredentials = {\n host: string;\n email?: string;\n username: string;\n password: string;\n};\n\nexport type v2Service = {\n image: string;\n command: string[] | null;\n args: string[] | null;\n env: string[] | null;\n expose: v2Expose[];\n dependencies?: v2Dependency[];\n params?: v2ServiceParams;\n credentials?: v2ServiceImageCredentials;\n};\n\nexport type v2ServiceDeployment = {\n profile: string;\n count: number;\n};\n\nexport type v2Deployment = Record<string, v2ServiceDeployment>;\n\nexport type v2CPUAttributes = Record<string, any>;\n\nexport type v2ResourceCPU = {\n units: number | string;\n attributes?: v2CPUAttributes;\n};\n\nexport type v2ResourceMemory = {\n size: string;\n attributes?: Record<string, any>;\n};\n\nexport type v3GPUAttributes = {\n vendor: {\n [vendor: string]: Array<{ model: string; ram?: string; interface?: string }>;\n };\n};\n\nexport type v3ResourceGPU = {\n units: number | string;\n attributes?: v3GPUAttributes;\n};\n\nexport type v2StorageAttributes = Record<string, any>;\n\nexport type v2ResourceStorage = {\n name: string;\n size: string;\n attributes: v2StorageAttributes;\n};\n\nexport type v2ResourceStorageArray = v2ResourceStorage[];\n\nexport type v2ComputeResources = {\n cpu: v2ResourceCPU;\n memory: v2ResourceMemory;\n storage: v2ResourceStorageArray | v2ResourceStorage;\n};\n\nexport type v3ComputeResources = {\n cpu: v2ResourceCPU;\n memory: v2ResourceMemory;\n storage: v2ResourceStorageArray | v2ResourceStorage;\n gpu: v3ResourceGPU;\n id: number;\n};\n\nexport type v2ProfileCompute = {\n resources: v2ComputeResources;\n};\n\nexport type v3ProfileCompute = {\n resources: v3ComputeResources;\n};\n\nexport type v2PlacementAttributes = Attributes;\n\nexport type v2Coin = {\n denom: string;\n value: number;\n amount: number;\n};\n\nexport type v2PlacementPricing = Record<string, v2Coin>;\n\nexport type SignedBy = {\n allOf: string[];\n anyOf: string[];\n};\n\nexport type v2ProfilePlacement = {\n attributes: v2PlacementAttributes;\n signedBy: SignedBy;\n pricing: v2PlacementPricing;\n};\n\nexport type v2Profiles = {\n compute: Record<string, v2ProfileCompute>;\n placement: Record<string, v2ProfilePlacement>;\n};\n\nexport type v3Profiles = {\n compute: Record<string, v3ProfileCompute>;\n placement: Record<string, v2ProfilePlacement>;\n};\n\nexport type Attribute = {\n key: string;\n value: string;\n};\n\nexport type v3DeploymentGroup = {\n name: string;\n resources: Array<{\n resource: v3ComputeResources;\n price: number;\n count: number;\n endpoints: Array<{ kind: number; sequence_number: number }>;\n }>;\n requirements: {\n attributes: Array<Attribute>;\n signedBy: {\n allOf: string[];\n anyOf: string[];\n };\n };\n};\n\nexport type Attributes = Attribute[];\n"],
|
|
4
|
+
"sourcesContent": ["/**\n * @deprecated will be removed in favor of `Manifest` type\n */\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\nexport type v2Manifest = v2Group[];\n\n/** @deprecated Use `Manifest` type instead. */\nexport type v3Manifest = v3Group[];\n\n/** @deprecated Use `Manifest` type instead. */\nexport type v3Group = {\n name: string;\n services: v3ManifestService[];\n};\n\n/** @deprecated will be removed in favor of `Manifest` type. */\nexport type v2Group = {\n Name: string;\n Services: v2ManifestService[];\n};\n\n/** @deprecated will be removed in favor of `Manifest` type. */\nexport type v2ManifestService = {\n Name: string;\n Image: string;\n Command: string[] | null;\n Args: string[] | null;\n Env: string[] | null;\n Resources: ResourceUnits;\n Count: number;\n Expose: v2ServiceExpose[];\n params?: v2ManifestServiceParams;\n};\n\n/** @deprecated Use `Manifest` type instead. */\nexport type v3ManifestService = {\n name: string;\n image: string;\n command: string[] | null;\n args: string[] | null;\n env: string[] | null;\n resources: ResourceUnits;\n count: number;\n expose: v3ServiceExpose[];\n params?: v3ManifestServiceParams | null;\n credentials: v2ServiceImageCredentials | null;\n};\n\n/** @deprecated will be removed in favor of `Manifest` type. */\nexport type v2ServiceExposeHttpOptions = {\n MaxBodySize: number;\n ReadTimeout: number;\n SendTimeout: number;\n NextTries: number;\n NextTimeout: number;\n NextCases: string[];\n};\n\n/** @deprecated Use `Manifest[number]['services'][number]['expose'][number]['httpOptions']` type instead. */\nexport type v3ServiceExposeHttpOptions = {\n maxBodySize: number;\n readTimeout: number;\n sendTimeout: number;\n nextTries: number;\n nextTimeout: number;\n nextCases: string[];\n};\n\n/** @deprecated will be removed in favor of `Manifest` type. */\nexport type ResourceUnits = Record<string, any>;\n\n/** @deprecated will be removed in favor of `Manifest` type. */\nexport type v2ServiceExpose = {\n Port: number;\n ExternalPort: number;\n Proto: string;\n Service: any;\n Global: boolean;\n Hosts: any;\n HTTPOptions: v2ServiceExposeHttpOptions;\n IP: string;\n EndpointSequenceNumber: number;\n};\n\n/** @deprecated Use `Manifest[number]['services'][number]['expose'][number]` type instead. */\nexport type v3ServiceExpose = {\n port: number;\n externalPort: number;\n proto: string;\n service: any;\n global: boolean;\n hosts: any;\n httpOptions: v3ServiceExposeHttpOptions;\n ip: string;\n endpointSequenceNumber: number;\n};\n\ntype v2ServicePermissionsScope = \"deployment\" | \"logs\";\n\n/** @deprecated will be removed in favor of `Manifest` type. */\nexport type v2ServicePermissions = {\n read?: v2ServicePermissionsScope[];\n};\n\n/** @deprecated will be removed in favor of `Manifest` type. */\nexport type v2ManifestServiceParams = {\n Storage: v2ServiceStorageParams[];\n Permissions?: v2ServicePermissions;\n};\n\n/** @deprecated Use `Manifest[number]['services'][number]['params']` type instead. */\nexport type v3ManifestServiceParams = {\n storage: v2ServiceStorageParams[];\n permissions?: v2ServicePermissions;\n};\n\n/** @deprecated will be removed in favor of `Manifest` type */\nexport type v2Sdl = {\n services: Record<string, v2Service>;\n profiles: v2Profiles;\n deployment: Record<string, v2Deployment>;\n endpoints: Record<string, v2Endpoint>;\n};\n\n/** @deprecated Use `SDLInput` type instead. */\nexport type v3Sdl = {\n services: Record<string, v2Service>;\n profiles: v3Profiles;\n deployment: Record<string, v2Deployment>;\n endpoints: Record<string, v2Endpoint>;\n};\n\n/** @deprecated will be removed. */\nexport type v2Endpoint = {\n kind: string;\n};\n\n/** @deprecated will be removed in favor of `SDLInput` and `Manifest` types. */\nexport type v2ExposeTo = {\n service?: string;\n global?: boolean;\n http_options: v2HTTPOptions;\n ip: string;\n};\n\n/** @deprecated will be removed in favor of `SDLInput` and `Manifest` types. */\nexport type v2HTTPOptions = {\n max_body_size: number;\n read_timeout: number;\n send_timeout: number;\n next_tries: number;\n next_timeout: number;\n next_cases: string[];\n};\n\n/** @deprecated will be removed in favor of `SDLInput` and `Manifest` types. */\nexport type v2Accept = {\n items?: string[];\n};\n\n/** @deprecated will be removed in favor of `SDLInput` and `Manifest` types. */\nexport type v2Expose = {\n port: number;\n as: number;\n proto?: string;\n to?: v2ExposeTo[];\n accept: v2Accept;\n http_options: v2HTTPOptions;\n};\n\n/** @deprecated will be removed in favor of `SDLInput` and `Manifest` types. */\nexport type v2Dependency = {\n service: string;\n};\n\n/** @deprecated will be removed in favor of `SDLInput` and `Manifest` types. */\nexport type v2ServiceStorageParams = {\n name: string;\n mount: string;\n readOnly: boolean;\n};\n\n/** @deprecated will be removed in favor of `SDLInput` and `Manifest` types. */\nexport type v2ServiceParams = {\n storage?: Record<string, v2ServiceStorageParams>;\n permissions?: v2ServicePermissions;\n};\n\n/** @deprecated will be removed in favor of `SDLInput` and `Manifest` types. */\nexport type v2ServiceImageCredentials = {\n host: string;\n email?: string;\n username: string;\n password: string;\n};\n\n/** @deprecated will be removed in favor of `SDLInput` and `Manifest` types. */\nexport type v2Service = {\n image: string;\n command: string[] | null;\n args: string[] | null;\n env: string[] | null;\n expose: v2Expose[];\n dependencies?: v2Dependency[];\n params?: v2ServiceParams;\n credentials?: v2ServiceImageCredentials;\n};\n\n/** @deprecated will be removed in favor of `SDLInput` and `Manifest` types. */\nexport type v2ServiceDeployment = {\n profile: string;\n count: number;\n};\n\n/** @deprecated will be removed in favor of `SDLInput` and `Manifest` types. */\nexport type v2Deployment = Record<string, v2ServiceDeployment>;\n\n/** @deprecated will be removed in favor of `SDLInput` and `Manifest` types. */\nexport type v2CPUAttributes = Record<string, any>;\n\n/** @deprecated will be removed in favor of `SDLInput` and `Manifest` types. */\nexport type v2ResourceCPU = {\n units: number | string;\n attributes?: v2CPUAttributes;\n};\n\n/** @deprecated will be removed in favor of `SDLInput` and `Manifest` types. */\nexport type v2ResourceMemory = {\n size: string;\n attributes?: Record<string, any>;\n};\n\n/** @deprecated will be removed in favor of `SDLInput` and `Manifest` types. */\nexport type v3GPUAttributes = {\n vendor: {\n [vendor: string]: Array<{ model: string; ram?: string; interface?: string }>;\n };\n};\n\n/** @deprecated will be removed in favor of `SDLInput` and `Manifest` types. */\nexport type v3ResourceGPU = {\n units: number | string;\n attributes?: v3GPUAttributes;\n};\n\n/** @deprecated will be removed in favor of `SDLInput` and `Manifest` types. */\nexport type v2StorageAttributes = Record<string, any>;\n\n/** @deprecated will be removed in favor of `SDLInput` and `Manifest` types. */\nexport type v2ResourceStorage = {\n name: string;\n size: string;\n attributes: v2StorageAttributes;\n};\n\n/** @deprecated will be removed in favor of `SDLInput` and `Manifest` types. */\nexport type v2ResourceStorageArray = v2ResourceStorage[];\n\n/** @deprecated will be removed in favor of `SDLInput` and `Manifest` types. */\nexport type v2ComputeResources = {\n cpu: v2ResourceCPU;\n memory: v2ResourceMemory;\n storage: v2ResourceStorageArray | v2ResourceStorage;\n};\n\n/** @deprecated will be removed in favor of `SDLInput` and `Manifest` types. */\nexport type v3ComputeResources = {\n cpu: v2ResourceCPU;\n memory: v2ResourceMemory;\n storage: v2ResourceStorageArray | v2ResourceStorage;\n gpu: v3ResourceGPU;\n id: number;\n};\n\n/** @deprecated will be removed in favor of `SDLInput` and `Manifest` types. */\nexport type v2ProfileCompute = {\n resources: v2ComputeResources;\n};\n\n/** @deprecated will be removed in favor of `SDLInput` and `Manifest` types. */\nexport type v3ProfileCompute = {\n resources: v3ComputeResources;\n};\n\n/** @deprecated will be removed in favor of `SDLInput` and `Manifest` types. */\nexport type v2PlacementAttributes = Attributes;\n\n/** @deprecated will be removed in favor of `SDLInput` and `Manifest` types. */\nexport type v2Coin = {\n denom: string;\n value: number;\n amount: number;\n};\n\n/** @deprecated will be removed in favor of `SDLInput` and `Manifest` types. */\nexport type v2PlacementPricing = Record<string, v2Coin>;\n\n/** @deprecated will be removed in favor of `SDLInput` and `Manifest` types. */\nexport type SignedBy = {\n allOf: string[];\n anyOf: string[];\n};\n\n/** @deprecated will be removed in favor of `SDLInput` and `Manifest` types. */\nexport type v2ProfilePlacement = {\n attributes: v2PlacementAttributes;\n signedBy: SignedBy;\n pricing: v2PlacementPricing;\n};\n\n/** @deprecated will be removed in favor of `SDLInput` and `Manifest` types. */\nexport type v2Profiles = {\n compute: Record<string, v2ProfileCompute>;\n placement: Record<string, v2ProfilePlacement>;\n};\n\n/** @deprecated will be removed in favor of `SDLInput` and `Manifest` types. */\nexport type v3Profiles = {\n compute: Record<string, v3ProfileCompute>;\n placement: Record<string, v2ProfilePlacement>;\n};\n\n/** @deprecated will be removed in favor of `SDLInput` and `Manifest` types. */\nexport type Attribute = {\n key: string;\n value: string;\n};\n\n/** @deprecated will be removed in favor of `SDLInput` and `Manifest` types. */\nexport type v3DeploymentGroup = {\n name: string;\n resources: Array<{\n resource: v3ComputeResources;\n price: number;\n count: number;\n endpoints: Array<{ kind: number; sequence_number: number }>;\n }>;\n requirements: {\n attributes: Array<Attribute>;\n signedBy: {\n allOf: string[];\n anyOf: string[];\n };\n };\n};\n\n/** @deprecated will be removed in favor of `SDLInput` and `Manifest` types. */\nexport type Attributes = Attribute[];\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["
|
|
3
|
+
"sources": ["../../../src/sdl/utils.ts"],
|
|
4
4
|
"sourcesContent": ["export function castArray<T>(value: T | T[] | undefined | null): T[] {\n if (value === undefined || value === null) return [];\n return Array.isArray(value) ? value : [value];\n}\n\nexport function stringToBoolean(str: string | boolean): boolean {\n if (typeof str === \"boolean\") {\n return str;\n }\n\n switch (str.toLowerCase()) {\n case \"false\":\n case \"no\":\n case \"0\":\n case \"\":\n return false;\n default:\n return true;\n }\n}\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,SAAS,UAAa,OAAwC;AACnE,MAAI,UAAU,UAAa,UAAU,KAAM,QAAO,CAAC;AACnD,SAAO,MAAM,QAAQ,KAAK,IAAI,QAAQ,CAAC,KAAK;AAC9C;AAEO,SAAS,gBAAgB,KAAgC;AAC9D,MAAI,OAAO,QAAQ,WAAW;AAC5B,WAAO;AAAA,EACT;AAEA,UAAQ,IAAI,YAAY,GAAG;AAAA,IACzB,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AACH,aAAO;AAAA,IACT;AACE,aAAO;AAAA,EACX;AACF;",
|
|
6
6
|
"names": []
|
|
@@ -30,11 +30,11 @@ __export(validateSDL_exports, {
|
|
|
30
30
|
validationSDLSchema: () => import_validateSDLInput.schema
|
|
31
31
|
});
|
|
32
32
|
module.exports = __toCommonJS(validateSDL_exports);
|
|
33
|
-
var import_network = require("
|
|
34
|
-
var import_jsonSchemaValidation = require("
|
|
33
|
+
var import_network = require("../../network/index.cjs");
|
|
34
|
+
var import_jsonSchemaValidation = require("../../utils/jsonSchemaValidation.cjs");
|
|
35
35
|
var import_utils = require("../utils.cjs");
|
|
36
36
|
var import_validateSDLInput = require("./validateSDLInput.cjs");
|
|
37
|
-
var _endpointsUsed, _portsUsed, _sdl, _errors, _SDLValidator_instances, validateDenom_fn, validateDeploymentWithRelations_fn, validateDeploymentRelations_fn, validateServiceStorages_fn, validateStorages_fn, validateGPU_fn, validateLeaseIP_fn, validateEndpoints_fn;
|
|
37
|
+
var _endpointsUsed, _portsUsed, _sdl, _errors, _SDLValidator_instances, validateDenom_fn, findInvalidUsdcDenom_fn, validateDeploymentWithRelations_fn, validateDeploymentRelations_fn, validateServiceStorages_fn, validateStorages_fn, validateGPU_fn, validateLeaseIP_fn, validateEndpoints_fn;
|
|
38
38
|
const ERROR_MESSAGES = {
|
|
39
39
|
"#/definitions/storageAttributesValidation"(error) {
|
|
40
40
|
return `"ram" storage${(0, import_jsonSchemaValidation.getErrorLocation)((0, import_jsonSchemaValidation.dirname)(error.instancePath))} cannot be persistent`;
|
|
@@ -81,26 +81,33 @@ _SDLValidator_instances = new WeakSet();
|
|
|
81
81
|
validateDenom_fn = function(networkId) {
|
|
82
82
|
if (!__privateGet(this, _sdl).profiles?.placement) return;
|
|
83
83
|
const usdcDenom = import_network.USDC_IBC_DENOMS[networkId];
|
|
84
|
-
const
|
|
85
|
-
if (!placement.pricing) return [];
|
|
86
|
-
return Object.entries(placement.pricing).map(([profile, pricing]) => ({
|
|
87
|
-
path: `/profiles/placement/${placementName}/pricing/${profile}/denom`,
|
|
88
|
-
denom: pricing.denom
|
|
89
|
-
}));
|
|
90
|
-
}).flat();
|
|
91
|
-
const invalidDenom = denoms.find(({ denom }) => denom !== import_network.AKT_DENOM && denom !== usdcDenom);
|
|
84
|
+
const invalidDenom = __privateMethod(this, _SDLValidator_instances, findInvalidUsdcDenom_fn).call(this, usdcDenom);
|
|
92
85
|
if (invalidDenom) {
|
|
93
86
|
__privateGet(this, _errors).push({
|
|
94
|
-
message: `Invalid
|
|
87
|
+
message: `Invalid format: "denom" at "${invalidDenom.path}" does not match pattern "^(uakt|uact|${usdcDenom})$"`,
|
|
95
88
|
instancePath: invalidDenom.path,
|
|
96
89
|
schemaPath: "#/definitions/priceCoin/properties/denom",
|
|
97
90
|
keyword: "pattern",
|
|
98
91
|
params: {
|
|
99
|
-
pattern: "^(uakt|ibc/.*)$"
|
|
92
|
+
pattern: "^(uakt|uact|ibc/.*)$"
|
|
100
93
|
}
|
|
101
94
|
});
|
|
102
95
|
}
|
|
103
96
|
};
|
|
97
|
+
findInvalidUsdcDenom_fn = function(usdcDenom) {
|
|
98
|
+
for (const [placementName, placement] of Object.entries(__privateGet(this, _sdl).profiles.placement)) {
|
|
99
|
+
if (!placement.pricing) continue;
|
|
100
|
+
for (const [profile, pricing] of Object.entries(placement.pricing)) {
|
|
101
|
+
if (pricing.denom.startsWith("ibc/") && pricing.denom !== usdcDenom) {
|
|
102
|
+
return {
|
|
103
|
+
path: `/profiles/placement/${placementName}/pricing/${profile}/denom`,
|
|
104
|
+
denom: pricing.denom
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return null;
|
|
110
|
+
};
|
|
104
111
|
validateDeploymentWithRelations_fn = function(serviceName) {
|
|
105
112
|
const deployment = __privateGet(this, _sdl).deployment[serviceName];
|
|
106
113
|
if (!deployment) {
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/sdl/validateSDL/validateSDL.ts"],
|
|
4
|
+
"sourcesContent": ["import { type NetworkId, USDC_IBC_DENOMS } from \"../../network/index.ts\";\nimport type { ErrorMessages, ValidationError, ValidationFunction } from \"../../utils/jsonSchemaValidation.ts\";\nimport { dirname, getErrorLocation, humanizeErrors } from \"../../utils/jsonSchemaValidation.ts\";\nimport { castArray, stringToBoolean } from \"../utils.ts\";\nimport { schema as validationSDLSchema, type SDLInput, validate as validateSDLInput } from \"./validateSDLInput.ts\";\n\nexport type { SDLInput };\nexport { validationSDLSchema };\n\nconst ERROR_MESSAGES: ErrorMessages = {\n \"#/definitions/storageAttributesValidation\"(error) {\n return `\"ram\" storage${getErrorLocation(dirname(error.instancePath))} cannot be persistent`;\n },\n \"#/definitions/exposeToWithIpEnforcesGlobal/then/properties/global/const\"() {\n return `If an IP is declared, the directive must be declared as global.`;\n },\n};\n\nexport function validateSDL(sdl: SDLInput, networkId: NetworkId): undefined | ValidationError[] {\n validateSDLInput(sdl);\n const schemaErrors = humanizeErrors((validateSDLInput as ValidationFunction).errors, validationSDLSchema, ERROR_MESSAGES);\n if (schemaErrors.length) return schemaErrors;\n\n const validator = new SDLValidator(sdl);\n const errors = validator.validate(networkId);\n\n const allErrors = schemaErrors.concat(errors);\n return allErrors.length ? allErrors : undefined;\n}\n\nclass SDLValidator {\n readonly #endpointsUsed = new Set<string>();\n readonly #portsUsed = new Map<string, string>();\n readonly #sdl: SDLInput;\n readonly #errors: ValidationError[] = [];\n\n constructor(sdl: SDLInput) {\n this.#sdl = sdl;\n }\n\n validate(networkId: NetworkId) {\n if (this.#sdl.services) {\n Object.keys(this.#sdl.services).forEach((serviceName) => {\n this.#validateDeploymentWithRelations(serviceName);\n this.#validateLeaseIP(serviceName);\n });\n }\n\n this.#validateDenom(networkId);\n this.#validateEndpoints();\n return this.#errors;\n }\n\n #validateDenom(networkId: NetworkId) {\n if (!this.#sdl.profiles?.placement) return;\n\n const usdcDenom = USDC_IBC_DENOMS[networkId];\n const invalidDenom = this.#findInvalidUsdcDenom(usdcDenom);\n\n if (invalidDenom) {\n this.#errors.push({\n message: `Invalid format: \"denom\" at \"${invalidDenom.path}\" does not match pattern \"^(uakt|uact|${usdcDenom})$\"`,\n instancePath: invalidDenom.path,\n schemaPath: \"#/definitions/priceCoin/properties/denom\",\n keyword: \"pattern\",\n params: {\n pattern: \"^(uakt|uact|ibc/.*)$\",\n },\n });\n }\n }\n\n #findInvalidUsdcDenom(usdcDenom: string): { denom: string; path: string } | null {\n for (const [placementName, placement] of Object.entries(this.#sdl.profiles.placement)) {\n if (!placement.pricing) continue;\n for (const [profile, pricing] of Object.entries(placement.pricing)) {\n if (pricing.denom.startsWith(\"ibc/\") && pricing.denom !== usdcDenom) {\n return {\n path: `/profiles/placement/${placementName}/pricing/${profile}/denom`,\n denom: pricing.denom,\n };\n }\n }\n }\n\n return null;\n }\n\n #validateDeploymentWithRelations(serviceName: string) {\n const deployment = this.#sdl.deployment[serviceName];\n if (!deployment) {\n this.#errors.push({\n message: `Service \"${serviceName}\" is not defined at \"/deployment\" section.`,\n instancePath: `/deployment`,\n schemaPath: \"#/properties/deployment\",\n keyword: \"required\",\n params: {\n missingProperty: serviceName,\n },\n });\n return;\n }\n\n Object.keys(this.#sdl.deployment[serviceName]).forEach((deploymentName) => {\n this.#validateDeploymentRelations(serviceName, deploymentName);\n this.#validateServiceStorages(serviceName, deploymentName);\n this.#validateStorages(serviceName, deploymentName);\n this.#validateGPU(serviceName, deploymentName);\n });\n }\n\n #validateDeploymentRelations(serviceName: string, deploymentName: string) {\n const serviceDeployment = this.#sdl.deployment?.[serviceName]?.[deploymentName];\n const compute = this.#sdl.profiles?.compute?.[serviceDeployment?.profile];\n const infra = this.#sdl.profiles?.placement?.[deploymentName];\n\n if (!infra) {\n this.#errors.push({\n message: `The placement \"${deploymentName}\" is not defined in the \"placement\" section.`,\n instancePath: `/profiles/placement`,\n schemaPath: \"#/properties/profiles/properties/placement\",\n keyword: \"required\",\n params: {\n missingProperty: deploymentName,\n },\n });\n }\n\n if (infra && !infra.pricing?.[serviceDeployment?.profile]) {\n this.#errors.push({\n message: `The pricing for the \"${serviceDeployment?.profile}\" profile is not defined in the \"${deploymentName}\" placement.`,\n instancePath: `/profiles/placement/${deploymentName}/pricing`,\n schemaPath: \"#/properties/profiles/properties/placement/additionalProperties/properties/pricing\",\n keyword: \"required\",\n params: {\n missingProperty: serviceDeployment?.profile,\n },\n });\n }\n\n if (!compute) {\n this.#errors.push({\n message: `The compute requirements for the \"${serviceDeployment?.profile}\" profile are not defined in the \"compute\" section.`,\n instancePath: `/profiles/compute`,\n schemaPath: \"#/properties/profiles/properties/compute\",\n keyword: \"required\",\n params: {\n missingProperty: serviceDeployment?.profile,\n },\n });\n }\n }\n\n #validateServiceStorages(serviceName: string, deploymentName: string) {\n const service = this.#sdl.services?.[serviceName];\n const mounts: Record<string, string> = {};\n const serviceDeployment = this.#sdl.deployment[serviceName][deploymentName];\n const compute = this.#sdl.profiles?.compute?.[serviceDeployment.profile];\n const storages = castArray(compute?.resources.storage);\n\n if (!service?.params?.storage) {\n return;\n }\n\n Object.entries(service.params.storage).forEach(([storageName, storage]) => {\n if (!storage) {\n this.#errors.push({\n message: `Storage \"${storageName}\" is not configured.`,\n instancePath: `/services/${serviceName}/params/storage/${storageName}`,\n schemaPath: \"#/properties/services/additionalProperties/properties/params/properties/storage/additionalProperties\",\n keyword: \"required\",\n params: {\n missingProperty: storageName,\n },\n });\n return;\n }\n const storageNameExists = storages.some(({ name }) => name === storageName);\n if (!storageNameExists) {\n this.#errors.push({\n message: `Service \"${serviceName}\" references non-existing compute volume \"${storageName}\".`,\n instancePath: `/profiles/compute/${serviceDeployment.profile}/resources/storage`,\n schemaPath: \"#/properties/profiles/properties/compute/additionalProperties/properties/resources/properties/storage\",\n keyword: \"required\",\n params: {\n missingProperty: storageName,\n },\n });\n return;\n }\n\n const mount = String(storage.mount);\n const volumeName = mounts[mount];\n\n if (volumeName && !storage.mount) {\n this.#errors.push({\n message: \"Multiple root ephemeral storages are not allowed.\",\n instancePath: `/services/${serviceName}/params/storage/${storageName}`,\n schemaPath: \"#/properties/services/additionalProperties/properties/params/properties/storage\",\n keyword: \"uniqueItems\",\n params: {\n duplicate: volumeName,\n },\n });\n }\n if (volumeName && storage.mount) {\n this.#errors.push({\n message: `Mount \"${mount}\" already in use by volume \"${volumeName}\".`,\n instancePath: `/services/${serviceName}/params/storage/${storageName}/mount`,\n schemaPath: \"#/properties/services/additionalProperties/properties/params/properties/storage/additionalProperties/properties/mount\",\n keyword: \"uniqueItems\",\n params: {\n duplicate: mount,\n },\n });\n }\n\n mounts[mount] = storageName;\n });\n }\n\n #validateStorages(serviceName: string, deploymentName: string) {\n const service = this.#sdl.services?.[serviceName];\n const serviceDeployment = this.#sdl.deployment[serviceName][deploymentName];\n const compute = this.#sdl.profiles?.compute?.[serviceDeployment.profile];\n const storages = castArray(compute?.resources.storage);\n\n storages.forEach((storage) => {\n const persistent = stringToBoolean(storage.attributes?.persistent as string | boolean || false);\n\n if (persistent && !service?.params?.storage?.[storage.name || \"\"]?.mount) {\n this.#errors.push({\n message: `Persistent storage \"${storage.name || \"default\"}\" requires a mount path in /services/${serviceName}/params/storage/${storage.name || \"default\"}/mount.`,\n instancePath: `/services/${serviceName}/params/storage/${storage.name || \"default\"}`,\n schemaPath: \"#/properties/services/additionalProperties/properties/params/properties/storage/additionalProperties/properties/mount\",\n keyword: \"required\",\n params: {\n missingProperty: \"mount\",\n },\n });\n }\n });\n }\n\n #validateGPU(serviceName: string, deploymentName: string) {\n const deployment = this.#sdl.deployment[serviceName];\n const compute = this.#sdl.profiles?.compute?.[deployment[deploymentName]?.profile];\n const gpu = compute?.resources.gpu;\n if (!gpu) return;\n\n const hasUnits = gpu.units !== undefined && gpu.units !== 0;\n const hasAttributes = typeof gpu.attributes !== \"undefined\";\n const hasVendor = hasAttributes && typeof gpu.attributes?.vendor !== \"undefined\";\n\n const profile = deployment[deploymentName]?.profile;\n const gpuPath = `/profiles/compute/${profile}/resources/gpu`;\n\n if (!hasUnits && hasAttributes) {\n this.#errors.push({\n message: \"GPU must not have attributes if units is 0.\",\n instancePath: `${gpuPath}/attributes`,\n schemaPath: \"#/properties/profiles/properties/compute/additionalProperties/properties/resources/properties/gpu/properties/attributes\",\n keyword: \"additionalProperties\",\n params: {\n additionalProperty: \"attributes\",\n },\n });\n }\n if (hasUnits && !hasAttributes) {\n this.#errors.push({\n message: \"GPU must have attributes if units is not 0.\",\n instancePath: gpuPath,\n schemaPath: \"#/properties/profiles/properties/compute/additionalProperties/properties/resources/properties/gpu\",\n keyword: \"required\",\n params: {\n missingProperty: \"attributes\",\n },\n });\n }\n if (hasUnits && !hasVendor) {\n this.#errors.push({\n message: \"GPU must specify a vendor if units is not 0.\",\n instancePath: `${gpuPath}/attributes`,\n schemaPath: \"#/properties/profiles/properties/compute/additionalProperties/properties/resources/properties/gpu/properties/attributes/properties/vendor\",\n keyword: \"required\",\n params: {\n missingProperty: \"vendor\",\n },\n });\n }\n }\n\n #validateLeaseIP(serviceName: string) {\n this.#sdl.services?.[serviceName]?.expose?.forEach((expose, exposeIndex) => {\n const proto = expose.proto?.toUpperCase() || \"TCP\";\n\n expose.to?.forEach((to, toIndex) => {\n if (to.ip?.length) {\n const toPath = `/services/${serviceName}/expose/${exposeIndex}/to/${toIndex}`;\n\n if (!to.global) {\n this.#errors.push({\n message: `If an IP is declared, the directive must be declared as global.`,\n instancePath: `${toPath}/global`,\n schemaPath: \"#/definitions/exposeToWithIpEnforcesGlobal/then/properties/global/const\",\n keyword: \"const\",\n params: {\n allowedValue: true,\n },\n });\n }\n if (!this.#sdl.endpoints?.[to.ip]) {\n this.#errors.push({\n message: `Unknown endpoint \"${to.ip}\" for service \"${serviceName}\". Add it to the \"endpoints\" section.`,\n instancePath: `/endpoints/${to.ip}`,\n schemaPath: \"#/properties/endpoints\",\n keyword: \"required\",\n params: {\n missingProperty: to.ip,\n },\n });\n }\n\n this.#endpointsUsed.add(to.ip);\n\n const externalPort = expose.as ?? expose.port;\n const portKey = `${to.ip}-${externalPort}-${proto}`;\n const otherServiceName = this.#portsUsed.get(portKey);\n\n if (this.#portsUsed.has(portKey)) {\n this.#errors.push({\n message: `IP endpoint \"${to.ip}\" port ${externalPort} protocol ${proto} already in use by service \"${otherServiceName}\".`,\n instancePath: `${toPath}/ip`,\n schemaPath: \"#/properties/services/additionalProperties/properties/expose/items/properties/to/items\",\n keyword: \"uniqueItems\",\n params: {\n duplicate: portKey,\n },\n });\n }\n this.#portsUsed.set(portKey, serviceName);\n }\n });\n });\n }\n\n #validateEndpoints() {\n if (!this.#sdl.endpoints) return;\n\n Object.keys(this.#sdl.endpoints).forEach((endpoint) => {\n if (!this.#endpointsUsed.has(endpoint)) {\n this.#errors.push({\n message: `Endpoint \"${endpoint}\" declared but never used.`,\n instancePath: `/endpoints/${endpoint}`,\n schemaPath: \"#/properties/endpoints\",\n keyword: \"additionalProperties\",\n params: {\n additionalProperty: endpoint,\n },\n });\n }\n });\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA,qDAAAA;AAAA;AAAA;AAAA,qBAAgD;AAEhD,kCAA0D;AAC1D,mBAA2C;AAC3C,8BAA2F;AAJ3F;AASA,MAAM,iBAAgC;AAAA,EACpC,4CAA4C,OAAO;AACjD,WAAO,oBAAgB,kDAAiB,qCAAQ,MAAM,YAAY,CAAC,CAAC;AAAA,EACtE;AAAA,EACA,4EAA4E;AAC1E,WAAO;AAAA,EACT;AACF;AAEO,SAAS,YAAY,KAAe,WAAqD;AAC9F,8BAAAC,UAAiB,GAAG;AACpB,QAAM,mBAAe,4CAAgB,wBAAAA,SAAwC,QAAQ,wBAAAC,QAAqB,cAAc;AACxH,MAAI,aAAa,OAAQ,QAAO;AAEhC,QAAM,YAAY,IAAI,aAAa,GAAG;AACtC,QAAM,SAAS,UAAU,SAAS,SAAS;AAE3C,QAAM,YAAY,aAAa,OAAO,MAAM;AAC5C,SAAO,UAAU,SAAS,YAAY;AACxC;AAEA,MAAM,aAAa;AAAA,EAMjB,YAAY,KAAe;AAN7B;AACE,uBAAS,gBAAiB,oBAAI,IAAY;AAC1C,uBAAS,YAAa,oBAAI,IAAoB;AAC9C,uBAAS;AACT,uBAAS,SAA6B,CAAC;AAGrC,uBAAK,MAAO;AAAA,EACd;AAAA,EAEA,SAAS,WAAsB;AAC7B,QAAI,mBAAK,MAAK,UAAU;AACtB,aAAO,KAAK,mBAAK,MAAK,QAAQ,EAAE,QAAQ,CAAC,gBAAgB;AACvD,8BAAK,6DAAL,WAAsC;AACtC,8BAAK,6CAAL,WAAsB;AAAA,MACxB,CAAC;AAAA,IACH;AAEA,0BAAK,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QACtB;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF,CAAC;AACH;",
|
|
6
|
+
"names": ["validationSDLSchema", "validateSDLInput", "validationSDLSchema"]
|
|
7
|
+
}
|
|
@@ -53,13 +53,13 @@ var require_ucs2length = __commonJS({
|
|
|
53
53
|
});
|
|
54
54
|
var validate = validate11;
|
|
55
55
|
var stdin_default = validate11;
|
|
56
|
-
var schema12 = { "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "description": "Schema for Akash Stack Definition Language (SDL) YAML input files.\n\nNote: This schema validates structure only. Semantic validations (cross-references,\nunused endpoints, profile references, etc.) are performed at runtime by the Go parser.\nSee README.md for details.\n", "definitions": { "stringArrayOrNull": { "description": "String array or null value (used for command args and env vars)", "oneOf": [{ "items": { "type": "string" }, "type": "array" }, { "type": "null" }] }, "portNumber": { "description": "Valid TCP/UDP port number (1-65535)", "type": "integer", "minimum": 1, "maximum": 65535 }, "httpErrorCode": { "description": "HTTP error codes for proxy retry logic", "enum": ["error", "timeout", "500", "502", "503", "504", "403", "404", "429", "off"], "type": "string" }, "priceCoin": { "description": "Price definition with amount and denomination", "additionalProperties": false, "properties": { "amount": { "oneOf": [{ "type": "string", "pattern": "^[0-9]+(\\.[0-9]+)?$", "description": "Positive number as string" }, { "type": "number", "minimum": 0, "description": "Positive number" }] }, "denom": { "pattern": "^(uakt|ibc/.*)$", "type": "string" } }, "required": ["denom", "amount"], "type": "object" }, "storageAttributesValidation": { "description": "Storage attributes validation:\n1. RAM class must not be persistent\n2. Non-RAM classes (beta1, beta2, beta3, default) require persistent=true\n", "additionalProperties": false, "properties": { "class": { "type": "string" }, "persistent": { "oneOf": [{ "type": "boolean" }, { "type": "string" }] } }, "not": { "properties": { "class": { "const": "ram" }, "persistent": { "oneOf": [{ "const": true }, { "const": "true" }] } }, "required": ["class", "persistent"] }, "type": "object" }, "storageVolume": { "description": "Storage volume definition with size and optional attributes", "additionalProperties": false, "properties": { "attributes": { "$ref": "#/definitions/storageAttributesValidation" }, "name": { "type": "string" }, "size": { "type": "string" } }, "required": ["size"], "type": "object" }, "absolutePath": { "description": "Absolute filesystem path starting with /", "type": "string", "minLength": 1, "pattern": "^/" }, "exposeToWithIpEnforcesGlobal": { "description": "Expose to with IP enforces global", "if": { "properties": { "ip": { "type": "string", "minLength": 1 } }, "required": ["ip"] }, "then": { "properties": { "global": { "const": true } }, "required": ["global"] } } }, "properties": { "deployment": { "additionalProperties": { "additionalProperties": { "additionalProperties": false, "properties": { "count": { "minimum": 1, "type": "integer" }, "profile": { "type": "string" } }, "required": ["profile", "count"], "type": "object" }, "type": "object" }, "type": "object" }, "endpoints": { "additionalProperties": false, "patternProperties": { "^[a-z]+[-_0-9a-z]+$": { "additionalProperties": false, "properties": { "kind": { "enum": ["ip"], "type": "string" } }, "required": ["kind"], "type": "object" } }, "type": "object" }, "include": { "description": "Optional list of files to include", "items": { "type": "string" }, "type": "array" }, "profiles": { "additionalProperties": false, "properties": { "compute": { "additionalProperties": { "additionalProperties": false, "properties": { "resources": { "additionalProperties": false, "properties": { "cpu": { "additionalProperties": false, "properties": { "attributes": { "type": "object" }, "units": { "oneOf": [{ "type": "string", "pattern": "^[0-9]+(\\.[0-9]+)?[a-zA-Z]*$", "not": { "pattern": "^0+(\\.0+)?m?$" } }, { "type": "number", "exclusiveMinimum": 0 }] } }, "required": ["units"], "type": "object" }, "gpu": { "description": "GPU resource specification.\n- units defaults to 0 if omitted\n- Bidirectional validation: units > 0 requires attributes, and attributes require units > 0\n", "additionalProperties": false, "properties": { "attributes": { "additionalProperties": false, "properties": { "vendor": { "additionalProperties": false, "minProperties": 1, "properties": { "nvidia": { "oneOf": [{ "type": "array", "items": { "additionalProperties": false, "properties": { "interface": { "enum": ["pcie", "sxm"], "type": "string" }, "model": { "type": "string" }, "ram": { "type": "string" } }, "type": "object" } }, { "type": "null" }] } }, "type": "object" } }, "type": "object" }, "units": { "oneOf": [{ "type": "string" }, { "type": "number" }] } }, "required": ["units"], "type": "object" }, "memory": { "additionalProperties": false, "properties": { "size": { "type": "string" } }, "required": ["size"], "type": "object" }, "storage": { "oneOf": [{ "$ref": "#/definitions/storageVolume" }, { "items": { "$ref": "#/definitions/storageVolume" }, "type": "array" }] } }, "required": ["cpu", "memory", "storage"], "type": "object" } }, "required": ["resources"], "type": "object" }, "type": "object" }, "placement": { "additionalProperties": { "additionalProperties": false, "properties": { "attributes": { "type": "object" }, "pricing": { "additionalProperties": { "$ref": "#/definitions/priceCoin" }, "type": "object" }, "signedBy": { "additionalProperties": false, "properties": { "allOf": { "items": { "type": "string" }, "type": "array" }, "anyOf": { "items": { "type": "string" }, "type": "array" } }, "type": "object" } }, "required": ["pricing"], "type": "object" }, "type": "object" } }, "required": ["compute", "placement"], "type": "object" }, "services": { "additionalProperties": { "properties": { "args": { "$ref": "#/definitions/stringArrayOrNull" }, "command": { "$ref": "#/definitions/stringArrayOrNull" }, "credentials": { "additionalProperties": false, "properties": { "email": { "type": "string", "minLength": 5 }, "host": { "type": "string", "minLength": 1 }, "password": { "type": "string", "minLength": 6 }, "username": { "type": "string", "minLength": 1 } }, "required": ["host", "username", "password"], "type": "object" }, "dependencies": { "items": { "additionalProperties": false, "properties": { "service": { "type": "string" } }, "type": "object" }, "type": "array" }, "env": { "$ref": "#/definitions/stringArrayOrNull" }, "expose": { "items": { "additionalProperties": false, "properties": { "accept": { "items": { "type": "string" }, "type": "array" }, "as": { "$ref": "#/definitions/portNumber" }, "http_options": { "additionalProperties": false, "properties": { "max_body_size": { "type": "integer", "minimum": 0, "maximum": 104857600, "description": "Maximum body size in bytes (max 100 MB)" }, "next_cases": { "oneOf": [{ "type": "array", "items": { "$ref": "#/definitions/httpErrorCode" }, "contains": { "const": "off" }, "maxItems": 1, "minItems": 1 }, { "type": "array", "items": { "$ref": "#/definitions/httpErrorCode" }, "not": { "contains": { "const": "off" } } }] }, "next_timeout": { "type": "integer", "minimum": 0 }, "next_tries": { "type": "integer", "minimum": 0 }, "read_timeout": { "type": "integer", "minimum": 0, "maximum": 6e4, "description": "Read timeout in milliseconds (max 60 seconds)" }, "send_timeout": { "type": "integer", "minimum": 0, "maximum": 6e4, "description": "Send timeout in milliseconds (max 60 seconds)" } }, "type": "object" }, "port": { "$ref": "#/definitions/portNumber" }, "proto": { "enum": ["TCP", "UDP", "tcp", "udp"], "type": "string" }, "to": { "items": { "additionalProperties": false, "properties": { "global": { "type": "boolean" }, "ip": { "minLength": 1, "type": "string" }, "service": { "type": "string" } }, "allOf": [{ "$ref": "#/definitions/exposeToWithIpEnforcesGlobal" }], "type": "object" }, "type": "array" } }, "required": ["port"], "type": "object" }, "type": "array" }, "image": { "type": "string", "minLength": 1 }, "params": { "additionalProperties": false, "properties": { "storage": { "additionalProperties": { "additionalProperties": false, "properties": { "mount": { "$ref": "#/definitions/absolutePath" }, "readOnly": { "type": "boolean" } }, "type": "object" }, "type": "object" }, "permissions": { "additionalProperties": false, "properties": { "read": { "items": { "type": "string", "enum": ["deployment", "logs"] }, "type": "array" } }, "type": "object" } }, "type": "object" } }, "required": ["image"], "type": "object", "additionalProperties": false }, "type": "object" }, "version": { "description": "SDL version", "enum": ["2.0", "2.1"], "type": "string" } }, "required": ["version", "services", "profiles", "deployment"], "title": "Akash SDL Input Schema", "type": "object" };
|
|
56
|
+
var schema12 = { "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "description": "Schema for Akash Stack Definition Language (SDL) YAML input files.\n\nNote: This schema validates structure only. Semantic validations (cross-references,\nunused endpoints, profile references, etc.) are performed at runtime by the Go parser.\nSee README.md for details.\n", "definitions": { "stringArrayOrNull": { "description": "String array or null value (used for command args and env vars)", "oneOf": [{ "items": { "type": "string" }, "type": "array" }, { "type": "null" }] }, "portNumber": { "description": "Valid TCP/UDP port number (1-65535)", "type": "integer", "minimum": 1, "maximum": 65535 }, "httpErrorCode": { "description": "HTTP error codes for proxy retry logic", "enum": ["error", "timeout", "500", "502", "503", "504", "403", "404", "429", "off"], "type": "string" }, "priceCoin": { "description": "Price definition with amount and denomination", "additionalProperties": false, "properties": { "amount": { "oneOf": [{ "type": "string", "pattern": "^[0-9]+(\\.[0-9]+)?$", "description": "Positive number as string" }, { "type": "number", "minimum": 0, "description": "Positive number" }] }, "denom": { "pattern": "^(uakt|uact|ibc/.*)$", "type": "string" } }, "required": ["denom", "amount"], "type": "object" }, "storageAttributesValidation": { "description": "Storage attributes validation:\n1. RAM class must not be persistent\n2. Non-RAM classes (beta1, beta2, beta3, default) require persistent=true\n", "additionalProperties": false, "properties": { "class": { "type": "string" }, "persistent": { "oneOf": [{ "type": "boolean" }, { "type": "string" }] } }, "not": { "properties": { "class": { "const": "ram" }, "persistent": { "oneOf": [{ "const": true }, { "const": "true" }] } }, "required": ["class", "persistent"] }, "type": "object" }, "storageVolume": { "description": "Storage volume definition with size and optional attributes", "additionalProperties": false, "properties": { "attributes": { "$ref": "#/definitions/storageAttributesValidation" }, "name": { "type": "string" }, "size": { "type": "string" } }, "required": ["size"], "type": "object" }, "absolutePath": { "description": "Absolute filesystem path starting with /", "type": "string", "minLength": 1, "pattern": "^/" }, "exposeToWithIpEnforcesGlobal": { "description": "Expose to with IP enforces global", "if": { "properties": { "ip": { "type": "string", "minLength": 1 } }, "required": ["ip"] }, "then": { "properties": { "global": { "const": true } }, "required": ["global"] } } }, "properties": { "deployment": { "additionalProperties": { "additionalProperties": { "additionalProperties": false, "properties": { "count": { "minimum": 1, "type": "integer" }, "profile": { "type": "string" } }, "required": ["profile", "count"], "type": "object" }, "type": "object" }, "type": "object" }, "endpoints": { "additionalProperties": false, "patternProperties": { "^[a-z]+[-_0-9a-z]+$": { "additionalProperties": false, "properties": { "kind": { "enum": ["ip"], "type": "string" } }, "required": ["kind"], "type": "object" } }, "type": "object" }, "include": { "description": "Optional list of files to include", "items": { "type": "string" }, "type": "array" }, "profiles": { "additionalProperties": false, "properties": { "compute": { "additionalProperties": { "additionalProperties": false, "properties": { "resources": { "additionalProperties": false, "properties": { "cpu": { "additionalProperties": false, "properties": { "attributes": { "type": "object" }, "units": { "oneOf": [{ "type": "string", "pattern": "^[0-9]+(\\.[0-9]+)?[a-zA-Z]*$", "not": { "pattern": "^0+(\\.0+)?m?$" } }, { "type": "number", "exclusiveMinimum": 0 }] } }, "required": ["units"], "type": "object" }, "gpu": { "description": "GPU resource specification.\n- units defaults to 0 if omitted\n- Bidirectional validation: units > 0 requires attributes, and attributes require units > 0\n", "additionalProperties": false, "properties": { "attributes": { "additionalProperties": false, "properties": { "vendor": { "additionalProperties": false, "minProperties": 1, "properties": { "nvidia": { "oneOf": [{ "type": "array", "items": { "additionalProperties": false, "properties": { "interface": { "enum": ["pcie", "sxm"], "type": "string" }, "model": { "type": "string" }, "ram": { "type": "string" } }, "type": "object" } }, { "type": "null" }] } }, "type": "object" } }, "type": "object" }, "units": { "oneOf": [{ "type": "string" }, { "type": "number" }] } }, "required": ["units"], "type": "object" }, "memory": { "additionalProperties": false, "properties": { "size": { "type": "string" } }, "required": ["size"], "type": "object" }, "storage": { "oneOf": [{ "$ref": "#/definitions/storageVolume" }, { "items": { "$ref": "#/definitions/storageVolume" }, "type": "array" }] } }, "required": ["cpu", "memory", "storage"], "type": "object" } }, "required": ["resources"], "type": "object" }, "type": "object" }, "placement": { "additionalProperties": { "additionalProperties": false, "properties": { "attributes": { "type": "object" }, "pricing": { "additionalProperties": { "$ref": "#/definitions/priceCoin" }, "type": "object" }, "signedBy": { "additionalProperties": false, "properties": { "allOf": { "items": { "type": "string" }, "type": "array" }, "anyOf": { "items": { "type": "string" }, "type": "array" } }, "type": "object" } }, "required": ["pricing"], "type": "object" }, "type": "object" } }, "required": ["compute", "placement"], "type": "object" }, "services": { "additionalProperties": { "properties": { "args": { "$ref": "#/definitions/stringArrayOrNull" }, "command": { "$ref": "#/definitions/stringArrayOrNull" }, "credentials": { "additionalProperties": false, "properties": { "email": { "type": "string", "minLength": 5 }, "host": { "type": "string", "minLength": 1 }, "password": { "type": "string", "minLength": 6 }, "username": { "type": "string", "minLength": 1 } }, "required": ["host", "username", "password"], "type": "object" }, "dependencies": { "items": { "additionalProperties": false, "properties": { "service": { "type": "string" } }, "type": "object" }, "type": "array" }, "env": { "$ref": "#/definitions/stringArrayOrNull" }, "expose": { "items": { "additionalProperties": false, "properties": { "accept": { "items": { "type": "string" }, "type": "array" }, "as": { "$ref": "#/definitions/portNumber" }, "http_options": { "additionalProperties": false, "properties": { "max_body_size": { "type": "integer", "minimum": 0, "maximum": 104857600, "description": "Maximum body size in bytes (max 100 MB)" }, "next_cases": { "oneOf": [{ "type": "array", "items": { "$ref": "#/definitions/httpErrorCode" }, "contains": { "const": "off" }, "maxItems": 1, "minItems": 1 }, { "type": "array", "items": { "$ref": "#/definitions/httpErrorCode" }, "not": { "contains": { "const": "off" } } }] }, "next_timeout": { "type": "integer", "minimum": 0 }, "next_tries": { "type": "integer", "minimum": 0 }, "read_timeout": { "type": "integer", "minimum": 0, "maximum": 6e4, "description": "Read timeout in milliseconds (max 60 seconds)" }, "send_timeout": { "type": "integer", "minimum": 0, "maximum": 6e4, "description": "Send timeout in milliseconds (max 60 seconds)" } }, "type": "object" }, "port": { "$ref": "#/definitions/portNumber" }, "proto": { "enum": ["TCP", "UDP", "tcp", "udp"], "type": "string" }, "to": { "items": { "additionalProperties": false, "properties": { "global": { "type": "boolean" }, "ip": { "minLength": 1, "type": "string" }, "service": { "type": "string" } }, "allOf": [{ "$ref": "#/definitions/exposeToWithIpEnforcesGlobal" }], "type": "object" }, "type": "array" } }, "required": ["port"], "type": "object" }, "type": "array" }, "image": { "type": "string", "minLength": 1 }, "params": { "additionalProperties": false, "properties": { "storage": { "additionalProperties": { "additionalProperties": false, "properties": { "mount": { "$ref": "#/definitions/absolutePath" }, "readOnly": { "type": "boolean" } }, "type": "object" }, "type": "object" }, "permissions": { "additionalProperties": false, "properties": { "read": { "items": { "type": "string", "enum": ["deployment", "logs"] }, "type": "array" } }, "type": "object" } }, "type": "object" } }, "required": ["image"], "type": "object", "additionalProperties": false }, "type": "object" }, "version": { "description": "SDL version", "enum": ["2.0", "2.1"], "type": "string" } }, "required": ["version", "services", "profiles", "deployment"], "title": "Akash SDL Input Schema", "type": "object" };
|
|
57
57
|
var schema20 = { "description": "HTTP error codes for proxy retry logic", "enum": ["error", "timeout", "500", "502", "503", "504", "403", "404", "429", "off"], "type": "string" };
|
|
58
58
|
var pattern2 = new RegExp("^[a-z]+[-_0-9a-z]+$", "u");
|
|
59
59
|
var pattern4 = new RegExp("^0+(\\.0+)?m?$", "u");
|
|
60
60
|
var pattern5 = new RegExp("^[0-9]+(\\.[0-9]+)?[a-zA-Z]*$", "u");
|
|
61
61
|
var pattern6 = new RegExp("^[0-9]+(\\.[0-9]+)?$", "u");
|
|
62
|
-
var pattern7 = new RegExp("^(uakt|ibc/.*)$", "u");
|
|
62
|
+
var pattern7 = new RegExp("^(uakt|uact|ibc/.*)$", "u");
|
|
63
63
|
var pattern8 = new RegExp("^/", "u");
|
|
64
64
|
function validate12(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) {
|
|
65
65
|
let vErrors = null;
|
|
@@ -1410,7 +1410,7 @@ function validate11(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
1410
1410
|
let data36 = data34.denom;
|
|
1411
1411
|
if (typeof data36 === "string") {
|
|
1412
1412
|
if (!pattern7.test(data36)) {
|
|
1413
|
-
const err83 = { instancePath: instancePath + "/profiles/placement/" + key17.replace(/~/g, "~0").replace(/\//g, "~1") + "/pricing/" + key19.replace(/~/g, "~0").replace(/\//g, "~1") + "/denom", schemaPath: "#/definitions/priceCoin/properties/denom/pattern", keyword: "pattern", params: { pattern: "^(uakt|ibc/.*)$" }, message: 'must match pattern "^(uakt|ibc/.*)$"' };
|
|
1413
|
+
const err83 = { instancePath: instancePath + "/profiles/placement/" + key17.replace(/~/g, "~0").replace(/\//g, "~1") + "/pricing/" + key19.replace(/~/g, "~0").replace(/\//g, "~1") + "/denom", schemaPath: "#/definitions/priceCoin/properties/denom/pattern", keyword: "pattern", params: { pattern: "^(uakt|uact|ibc/.*)$" }, message: 'must match pattern "^(uakt|uact|ibc/.*)$"' };
|
|
1414
1414
|
if (vErrors === null) {
|
|
1415
1415
|
vErrors = [err83];
|
|
1416
1416
|
} else {
|