@akashnetwork/chain-sdk 1.0.0-alpha.22 → 1.0.0-alpha.24
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 +12 -12
- 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-RIIYZIXM.js} +479 -65
- package/dist/esm/chunk-RIIYZIXM.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 +53 -1
- 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
|
@@ -1,6 +1,31 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Group,
|
|
3
|
+
ImageCredentials,
|
|
4
|
+
Service,
|
|
5
|
+
ServiceExpose,
|
|
6
|
+
ServiceExposeHTTPOptions,
|
|
7
|
+
ServiceParams,
|
|
8
|
+
StorageParams
|
|
9
|
+
} from "./chunk-VRE72ZD5.js";
|
|
1
10
|
import {
|
|
2
11
|
TxRaw
|
|
3
12
|
} from "./chunk-XIHNXIBW.js";
|
|
13
|
+
import {
|
|
14
|
+
GroupSpec,
|
|
15
|
+
ResourceUnit
|
|
16
|
+
} from "./chunk-5YECXI3P.js";
|
|
17
|
+
import {
|
|
18
|
+
CPU,
|
|
19
|
+
Endpoint,
|
|
20
|
+
GPU,
|
|
21
|
+
Memory,
|
|
22
|
+
Resources,
|
|
23
|
+
Storage
|
|
24
|
+
} from "./chunk-5DCYIWCG.js";
|
|
25
|
+
import {
|
|
26
|
+
PlacementRequirements,
|
|
27
|
+
SignedBy
|
|
28
|
+
} from "./chunk-JGBH2EPB.js";
|
|
4
29
|
import {
|
|
5
30
|
__privateAdd,
|
|
6
31
|
__privateGet,
|
|
@@ -20,31 +45,7 @@ var USDC_IBC_DENOMS = {
|
|
|
20
45
|
};
|
|
21
46
|
var AKT_DENOM = "uakt";
|
|
22
47
|
|
|
23
|
-
// src/sdl/
|
|
24
|
-
var SdlValidationError = class _SdlValidationError extends Error {
|
|
25
|
-
/**
|
|
26
|
-
* Asserts a condition and throws an `SdlValidationError` if the condition is false.
|
|
27
|
-
* @param condition - The condition to assert.
|
|
28
|
-
* @param message - The error message to throw if the assertion fails.
|
|
29
|
-
* @example
|
|
30
|
-
* SdlValidationError.assert(someCondition, "Condition failed");
|
|
31
|
-
*/
|
|
32
|
-
static assert(condition, message) {
|
|
33
|
-
if (!condition) {
|
|
34
|
-
throw new _SdlValidationError(message);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Creates an instance of `SdlValidationError`.
|
|
39
|
-
* @param message - The error message.
|
|
40
|
-
*/
|
|
41
|
-
constructor(message) {
|
|
42
|
-
super(message);
|
|
43
|
-
this.name = "SdlValidationError";
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
// src/sdl/SDL/validateSDL/validateSDLInput.ts
|
|
48
|
+
// src/sdl/validateSDL/validateSDLInput.ts
|
|
48
49
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
49
50
|
var __commonJS = (cb, mod) => function __require() {
|
|
50
51
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
@@ -74,13 +75,13 @@ var require_ucs2length = __commonJS({
|
|
|
74
75
|
}
|
|
75
76
|
});
|
|
76
77
|
var validate = validate11;
|
|
77
|
-
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" };
|
|
78
|
+
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" };
|
|
78
79
|
var schema20 = { "description": "HTTP error codes for proxy retry logic", "enum": ["error", "timeout", "500", "502", "503", "504", "403", "404", "429", "off"], "type": "string" };
|
|
79
80
|
var pattern2 = new RegExp("^[a-z]+[-_0-9a-z]+$", "u");
|
|
80
81
|
var pattern4 = new RegExp("^0+(\\.0+)?m?$", "u");
|
|
81
82
|
var pattern5 = new RegExp("^[0-9]+(\\.[0-9]+)?[a-zA-Z]*$", "u");
|
|
82
83
|
var pattern6 = new RegExp("^[0-9]+(\\.[0-9]+)?$", "u");
|
|
83
|
-
var pattern7 = new RegExp("^(uakt|ibc/.*)$", "u");
|
|
84
|
+
var pattern7 = new RegExp("^(uakt|uact|ibc/.*)$", "u");
|
|
84
85
|
var pattern8 = new RegExp("^/", "u");
|
|
85
86
|
function validate12(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) {
|
|
86
87
|
let vErrors = null;
|
|
@@ -1431,7 +1432,7 @@ function validate11(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
1431
1432
|
let data36 = data34.denom;
|
|
1432
1433
|
if (typeof data36 === "string") {
|
|
1433
1434
|
if (!pattern7.test(data36)) {
|
|
1434
|
-
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/.*)$"' };
|
|
1435
|
+
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/.*)$"' };
|
|
1435
1436
|
if (vErrors === null) {
|
|
1436
1437
|
vErrors = [err83];
|
|
1437
1438
|
} else {
|
|
@@ -3049,7 +3050,7 @@ function getErrorLocation(path) {
|
|
|
3049
3050
|
return path ? ` at "${path}"` : "";
|
|
3050
3051
|
}
|
|
3051
3052
|
|
|
3052
|
-
// src/sdl/
|
|
3053
|
+
// src/sdl/utils.ts
|
|
3053
3054
|
function castArray(value) {
|
|
3054
3055
|
if (value === void 0 || value === null) return [];
|
|
3055
3056
|
return Array.isArray(value) ? value : [value];
|
|
@@ -3069,7 +3070,7 @@ function stringToBoolean(str) {
|
|
|
3069
3070
|
}
|
|
3070
3071
|
}
|
|
3071
3072
|
|
|
3072
|
-
// src/sdl/
|
|
3073
|
+
// src/sdl/validateSDL/validateSDL.ts
|
|
3073
3074
|
var ERROR_MESSAGES = {
|
|
3074
3075
|
"#/definitions/storageAttributesValidation"(error) {
|
|
3075
3076
|
return `"ram" storage${getErrorLocation(dirname(error.instancePath))} cannot be persistent`;
|
|
@@ -3087,7 +3088,7 @@ function validateSDL(sdl, networkId) {
|
|
|
3087
3088
|
const allErrors = schemaErrors.concat(errors);
|
|
3088
3089
|
return allErrors.length ? allErrors : void 0;
|
|
3089
3090
|
}
|
|
3090
|
-
var _endpointsUsed, _portsUsed, _sdl, _errors, _SDLValidator_instances, validateDenom_fn, validateDeploymentWithRelations_fn, validateDeploymentRelations_fn, validateServiceStorages_fn, validateStorages_fn, validateGPU_fn, validateLeaseIP_fn, validateEndpoints_fn;
|
|
3091
|
+
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;
|
|
3091
3092
|
var SDLValidator = class {
|
|
3092
3093
|
constructor(sdl) {
|
|
3093
3094
|
__privateAdd(this, _SDLValidator_instances);
|
|
@@ -3117,26 +3118,33 @@ _SDLValidator_instances = new WeakSet();
|
|
|
3117
3118
|
validateDenom_fn = function(networkId) {
|
|
3118
3119
|
if (!__privateGet(this, _sdl).profiles?.placement) return;
|
|
3119
3120
|
const usdcDenom = USDC_IBC_DENOMS[networkId];
|
|
3120
|
-
const
|
|
3121
|
-
if (!placement.pricing) return [];
|
|
3122
|
-
return Object.entries(placement.pricing).map(([profile, pricing]) => ({
|
|
3123
|
-
path: `/profiles/placement/${placementName}/pricing/${profile}/denom`,
|
|
3124
|
-
denom: pricing.denom
|
|
3125
|
-
}));
|
|
3126
|
-
}).flat();
|
|
3127
|
-
const invalidDenom = denoms.find(({ denom }) => denom !== AKT_DENOM && denom !== usdcDenom);
|
|
3121
|
+
const invalidDenom = __privateMethod(this, _SDLValidator_instances, findInvalidUsdcDenom_fn).call(this, usdcDenom);
|
|
3128
3122
|
if (invalidDenom) {
|
|
3129
3123
|
__privateGet(this, _errors).push({
|
|
3130
|
-
message: `Invalid
|
|
3124
|
+
message: `Invalid format: "denom" at "${invalidDenom.path}" does not match pattern "^(uakt|uact|${usdcDenom})$"`,
|
|
3131
3125
|
instancePath: invalidDenom.path,
|
|
3132
3126
|
schemaPath: "#/definitions/priceCoin/properties/denom",
|
|
3133
3127
|
keyword: "pattern",
|
|
3134
3128
|
params: {
|
|
3135
|
-
pattern: "^(uakt|ibc/.*)$"
|
|
3129
|
+
pattern: "^(uakt|uact|ibc/.*)$"
|
|
3136
3130
|
}
|
|
3137
3131
|
});
|
|
3138
3132
|
}
|
|
3139
3133
|
};
|
|
3134
|
+
findInvalidUsdcDenom_fn = function(usdcDenom) {
|
|
3135
|
+
for (const [placementName, placement] of Object.entries(__privateGet(this, _sdl).profiles.placement)) {
|
|
3136
|
+
if (!placement.pricing) continue;
|
|
3137
|
+
for (const [profile, pricing] of Object.entries(placement.pricing)) {
|
|
3138
|
+
if (pricing.denom.startsWith("ibc/") && pricing.denom !== usdcDenom) {
|
|
3139
|
+
return {
|
|
3140
|
+
path: `/profiles/placement/${placementName}/pricing/${profile}/denom`,
|
|
3141
|
+
denom: pricing.denom
|
|
3142
|
+
};
|
|
3143
|
+
}
|
|
3144
|
+
}
|
|
3145
|
+
}
|
|
3146
|
+
return null;
|
|
3147
|
+
};
|
|
3140
3148
|
validateDeploymentWithRelations_fn = function(serviceName) {
|
|
3141
3149
|
const deployment = __privateGet(this, _sdl).deployment[serviceName];
|
|
3142
3150
|
if (!deployment) {
|
|
@@ -3387,6 +3395,30 @@ validateEndpoints_fn = function() {
|
|
|
3387
3395
|
});
|
|
3388
3396
|
};
|
|
3389
3397
|
|
|
3398
|
+
// src/sdl/SDL/SdlValidationError.ts
|
|
3399
|
+
var SdlValidationError = class _SdlValidationError extends Error {
|
|
3400
|
+
/**
|
|
3401
|
+
* Asserts a condition and throws an `SdlValidationError` if the condition is false.
|
|
3402
|
+
* @param condition - The condition to assert.
|
|
3403
|
+
* @param message - The error message to throw if the assertion fails.
|
|
3404
|
+
* @example
|
|
3405
|
+
* SdlValidationError.assert(someCondition, "Condition failed");
|
|
3406
|
+
*/
|
|
3407
|
+
static assert(condition, message) {
|
|
3408
|
+
if (!condition) {
|
|
3409
|
+
throw new _SdlValidationError(message);
|
|
3410
|
+
}
|
|
3411
|
+
}
|
|
3412
|
+
/**
|
|
3413
|
+
* Creates an instance of `SdlValidationError`.
|
|
3414
|
+
* @param message - The error message.
|
|
3415
|
+
*/
|
|
3416
|
+
constructor(message) {
|
|
3417
|
+
super(message);
|
|
3418
|
+
this.name = "SdlValidationError";
|
|
3419
|
+
}
|
|
3420
|
+
};
|
|
3421
|
+
|
|
3390
3422
|
// src/sdl/SDL/SDL.ts
|
|
3391
3423
|
import YAML from "js-yaml";
|
|
3392
3424
|
import { default as stableStringify } from "json-stable-stringify";
|
|
@@ -3469,8 +3501,8 @@ var _SDL = class _SDL {
|
|
|
3469
3501
|
* const sdl = SDL.fromString(yaml);
|
|
3470
3502
|
* ```
|
|
3471
3503
|
*/
|
|
3472
|
-
static fromString(
|
|
3473
|
-
const data = YAML.load(
|
|
3504
|
+
static fromString(yaml2, version = "beta3", networkId = MAINNET_ID) {
|
|
3505
|
+
const data = YAML.load(yaml2);
|
|
3474
3506
|
return new _SDL(data, version, networkId);
|
|
3475
3507
|
}
|
|
3476
3508
|
services() {
|
|
@@ -3511,8 +3543,8 @@ var _SDL = class _SDL {
|
|
|
3511
3543
|
return value;
|
|
3512
3544
|
}
|
|
3513
3545
|
const strVal = value.toString();
|
|
3514
|
-
const
|
|
3515
|
-
return asString ? strVal :
|
|
3546
|
+
const encoder3 = new TextEncoder();
|
|
3547
|
+
return asString ? strVal : encoder3.encode(strVal);
|
|
3516
3548
|
}
|
|
3517
3549
|
serviceResourceCpu(resource) {
|
|
3518
3550
|
const units = isString(resource.units) ? convertCpuResourceString(resource.units) : resource.units * 1e3;
|
|
@@ -3745,20 +3777,20 @@ var _SDL = class _SDL {
|
|
|
3745
3777
|
};
|
|
3746
3778
|
}
|
|
3747
3779
|
v3ManifestServiceParams(params) {
|
|
3748
|
-
if (params === void 0) {
|
|
3780
|
+
if (params === void 0 || Object.keys(params).length === 0) {
|
|
3749
3781
|
return null;
|
|
3750
3782
|
}
|
|
3751
|
-
|
|
3752
|
-
storage: Object.keys(params
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
readOnly: params.storage[name]?.readOnly || false
|
|
3758
|
-
};
|
|
3759
|
-
}),
|
|
3760
|
-
...params?.permissions ? { permissions: params.permissions } : {}
|
|
3783
|
+
const res = {
|
|
3784
|
+
storage: params.storage && Object.keys(params.storage).length > 0 ? Object.keys(params.storage).map((name) => ({
|
|
3785
|
+
name,
|
|
3786
|
+
mount: params.storage[name]?.mount,
|
|
3787
|
+
readOnly: params.storage[name]?.readOnly || false
|
|
3788
|
+
})) : null
|
|
3761
3789
|
};
|
|
3790
|
+
if (params.permissions) {
|
|
3791
|
+
res.permissions = params.permissions;
|
|
3792
|
+
}
|
|
3793
|
+
return res;
|
|
3762
3794
|
}
|
|
3763
3795
|
v2ManifestService(placement, name, asString) {
|
|
3764
3796
|
const service = this.data.services[name];
|
|
@@ -4100,6 +4132,384 @@ escapeHtml_fn = function(raw) {
|
|
|
4100
4132
|
};
|
|
4101
4133
|
var SDL = _SDL;
|
|
4102
4134
|
|
|
4135
|
+
// src/sdl/manifest/manifestUtils.ts
|
|
4136
|
+
var encoder = new TextEncoder();
|
|
4137
|
+
function encodeResourceValue(value) {
|
|
4138
|
+
return encoder.encode(value.toString());
|
|
4139
|
+
}
|
|
4140
|
+
function computeEndpointSequenceNumbers(services) {
|
|
4141
|
+
const endpointNames = [];
|
|
4142
|
+
for (const service of Object.values(services)) {
|
|
4143
|
+
if (!service.expose) continue;
|
|
4144
|
+
for (const expose of service.expose) {
|
|
4145
|
+
if (!expose.to) continue;
|
|
4146
|
+
for (const to of expose.to) {
|
|
4147
|
+
if (to.global && to.ip && to.ip.length > 0) {
|
|
4148
|
+
endpointNames.push(to.ip);
|
|
4149
|
+
}
|
|
4150
|
+
}
|
|
4151
|
+
}
|
|
4152
|
+
}
|
|
4153
|
+
return endpointNames.sort().reduce((result, name, seqNumber) => {
|
|
4154
|
+
result[name] = seqNumber + 1;
|
|
4155
|
+
return result;
|
|
4156
|
+
}, {});
|
|
4157
|
+
}
|
|
4158
|
+
function isIngress(proto, global, externalPort, port) {
|
|
4159
|
+
const effectivePort = externalPort === 0 ? port : externalPort;
|
|
4160
|
+
return global && proto === "TCP" && effectivePort === 80;
|
|
4161
|
+
}
|
|
4162
|
+
function transformGpuAttributes(attributes) {
|
|
4163
|
+
const vendor = attributes.vendor;
|
|
4164
|
+
if (!vendor) return [];
|
|
4165
|
+
return Object.entries(vendor).flatMap(
|
|
4166
|
+
([vendorName, models]) => models ? models.map((model) => {
|
|
4167
|
+
let key = `vendor/${vendorName}/model/${model.model}`;
|
|
4168
|
+
if (model.ram) key += `/ram/${model.ram}`;
|
|
4169
|
+
if (model.interface) key += `/interface/${model.interface}`;
|
|
4170
|
+
return { key, value: "true" };
|
|
4171
|
+
}) : [{ key: `vendor/${vendorName}/model/*`, value: "true" }]
|
|
4172
|
+
);
|
|
4173
|
+
}
|
|
4174
|
+
function buildHttpOptions(httpOptions) {
|
|
4175
|
+
return ServiceExposeHTTPOptions.fromPartial({
|
|
4176
|
+
maxBodySize: httpOptions?.max_body_size ?? 1048576,
|
|
4177
|
+
readTimeout: httpOptions?.read_timeout ?? 6e4,
|
|
4178
|
+
sendTimeout: httpOptions?.send_timeout ?? 6e4,
|
|
4179
|
+
nextTries: httpOptions?.next_tries ?? 3,
|
|
4180
|
+
nextTimeout: httpOptions?.next_timeout ?? 0,
|
|
4181
|
+
nextCases: httpOptions?.next_cases ?? ["error", "timeout"]
|
|
4182
|
+
});
|
|
4183
|
+
}
|
|
4184
|
+
function buildStorageAttributes(attributes) {
|
|
4185
|
+
if (!attributes) return [];
|
|
4186
|
+
const pairs = Object.entries(attributes).map(([key, value]) => ({
|
|
4187
|
+
key,
|
|
4188
|
+
value: String(value)
|
|
4189
|
+
}));
|
|
4190
|
+
if (attributes.class === "ram" && !("persistent" in attributes)) {
|
|
4191
|
+
pairs.push({ key: "persistent", value: "false" });
|
|
4192
|
+
}
|
|
4193
|
+
pairs.sort((a, b) => a.key.localeCompare(b.key));
|
|
4194
|
+
return pairs;
|
|
4195
|
+
}
|
|
4196
|
+
function parseServiceProto(proto) {
|
|
4197
|
+
return proto?.toUpperCase() || "TCP";
|
|
4198
|
+
}
|
|
4199
|
+
function buildServiceEndpoints(service, endpointSequenceNumbers) {
|
|
4200
|
+
return (service.expose ?? []).flatMap(
|
|
4201
|
+
(expose) => (expose.to ?? []).filter((to) => to.global).flatMap((to) => {
|
|
4202
|
+
const externalPort = expose.as || 0;
|
|
4203
|
+
const proto = parseServiceProto(expose.proto);
|
|
4204
|
+
const kind = isIngress(proto, !!to.global, externalPort, expose.port) ? 0 /* SHARED_HTTP */ : 1 /* RANDOM_PORT */;
|
|
4205
|
+
const defaultEp = Endpoint.fromPartial({
|
|
4206
|
+
kind,
|
|
4207
|
+
sequenceNumber: 0
|
|
4208
|
+
});
|
|
4209
|
+
const leasedEp = to.ip && to.ip.length > 0 ? Endpoint.fromPartial({
|
|
4210
|
+
kind: 2 /* LEASED_IP */,
|
|
4211
|
+
sequenceNumber: endpointSequenceNumbers[to.ip]
|
|
4212
|
+
}) : void 0;
|
|
4213
|
+
return leasedEp ? [defaultEp, leasedEp] : [defaultEp];
|
|
4214
|
+
})
|
|
4215
|
+
);
|
|
4216
|
+
}
|
|
4217
|
+
function parseCpuUnits(cpu) {
|
|
4218
|
+
return typeof cpu.units === "string" ? convertCpuResourceString(cpu.units) : cpu.units * 1e3;
|
|
4219
|
+
}
|
|
4220
|
+
function parseMemoryBytes(memory) {
|
|
4221
|
+
return convertResourceString(memory.size);
|
|
4222
|
+
}
|
|
4223
|
+
function parseStorageBytes(size) {
|
|
4224
|
+
return convertResourceString(size);
|
|
4225
|
+
}
|
|
4226
|
+
function parseGpuUnits(gpu) {
|
|
4227
|
+
const value = gpu?.units;
|
|
4228
|
+
if (value === void 0 || value === null) return 0;
|
|
4229
|
+
return typeof value === "string" ? parseInt(value, 10) : value;
|
|
4230
|
+
}
|
|
4231
|
+
function buildResourceAttributes(attributes) {
|
|
4232
|
+
if (!attributes) return void 0;
|
|
4233
|
+
return Object.entries(attributes).sort(([a], [b]) => a.localeCompare(b)).map(([key, value]) => ({ key, value: String(value) }));
|
|
4234
|
+
}
|
|
4235
|
+
|
|
4236
|
+
// src/sdl/manifest/generateManifest.ts
|
|
4237
|
+
function generateManifest(sdl, networkId = MAINNET_ID) {
|
|
4238
|
+
const errors = validateSDL(sdl, networkId);
|
|
4239
|
+
if (errors) return { ok: false, value: errors };
|
|
4240
|
+
const endpointSequenceNumbers = computeEndpointSequenceNumbers(sdl.services);
|
|
4241
|
+
const groupsMap = /* @__PURE__ */ new Map();
|
|
4242
|
+
const resourceIds = /* @__PURE__ */ new Map();
|
|
4243
|
+
const deploymentsByPlacement = /* @__PURE__ */ new Map();
|
|
4244
|
+
for (const [svcName, placements] of Object.entries(sdl.deployment)) {
|
|
4245
|
+
for (const [placementName, deployment] of Object.entries(placements)) {
|
|
4246
|
+
let list = deploymentsByPlacement.get(placementName);
|
|
4247
|
+
if (!list) {
|
|
4248
|
+
list = [];
|
|
4249
|
+
deploymentsByPlacement.set(placementName, list);
|
|
4250
|
+
}
|
|
4251
|
+
list.push([svcName, deployment]);
|
|
4252
|
+
}
|
|
4253
|
+
}
|
|
4254
|
+
for (const list of deploymentsByPlacement.values()) {
|
|
4255
|
+
list.sort(([a], [b]) => a.localeCompare(b));
|
|
4256
|
+
}
|
|
4257
|
+
const services = Object.entries(sdl.services).sort(([a], [b]) => a.localeCompare(b));
|
|
4258
|
+
for (const [svcName, service] of services) {
|
|
4259
|
+
for (const [placementName, svcdepl] of Object.entries(sdl.deployment[svcName])) {
|
|
4260
|
+
const compute = sdl.profiles.compute[svcdepl.profile];
|
|
4261
|
+
const infra = sdl.profiles.placement[placementName];
|
|
4262
|
+
const pricing = infra.pricing[svcdepl.profile];
|
|
4263
|
+
const price = {
|
|
4264
|
+
denom: pricing.denom,
|
|
4265
|
+
amount: pricing.amount?.toString()
|
|
4266
|
+
};
|
|
4267
|
+
let group = groupsMap.get(placementName);
|
|
4268
|
+
if (!group) {
|
|
4269
|
+
group = {
|
|
4270
|
+
dgroup: GroupSpec.fromPartial({
|
|
4271
|
+
name: placementName,
|
|
4272
|
+
resources: [],
|
|
4273
|
+
requirements: PlacementRequirements.fromPartial({
|
|
4274
|
+
attributes: buildResourceAttributes(infra.attributes) ?? [],
|
|
4275
|
+
signedBy: SignedBy.fromPartial({
|
|
4276
|
+
allOf: infra.signedBy?.allOf,
|
|
4277
|
+
anyOf: infra.signedBy?.anyOf
|
|
4278
|
+
})
|
|
4279
|
+
})
|
|
4280
|
+
}),
|
|
4281
|
+
boundComputes: {}
|
|
4282
|
+
};
|
|
4283
|
+
groupsMap.set(placementName, group);
|
|
4284
|
+
}
|
|
4285
|
+
const profileKey = `${placementName}:${svcdepl.profile}`;
|
|
4286
|
+
const location = group.boundComputes[svcdepl.profile];
|
|
4287
|
+
if (location === void 0) {
|
|
4288
|
+
const resId = group.dgroup.resources.length > 0 ? group.dgroup.resources.length + 1 : 1;
|
|
4289
|
+
resourceIds.set(profileKey, resId);
|
|
4290
|
+
const resources = buildResources(resId, compute, service, endpointSequenceNumbers);
|
|
4291
|
+
group.dgroup.resources.push(
|
|
4292
|
+
ResourceUnit.fromPartial({
|
|
4293
|
+
resource: resources,
|
|
4294
|
+
count: svcdepl.count,
|
|
4295
|
+
price
|
|
4296
|
+
})
|
|
4297
|
+
);
|
|
4298
|
+
group.boundComputes[svcdepl.profile] = group.dgroup.resources.length - 1;
|
|
4299
|
+
} else {
|
|
4300
|
+
if (!resourceIds.has(profileKey)) {
|
|
4301
|
+
resourceIds.set(profileKey, group.dgroup.resources[location].resource.id);
|
|
4302
|
+
}
|
|
4303
|
+
group.dgroup.resources[location].count += svcdepl.count;
|
|
4304
|
+
group.dgroup.resources[location].resource.endpoints.push(
|
|
4305
|
+
...buildServiceEndpoints(service, endpointSequenceNumbers)
|
|
4306
|
+
);
|
|
4307
|
+
}
|
|
4308
|
+
}
|
|
4309
|
+
}
|
|
4310
|
+
for (const group of groupsMap.values()) {
|
|
4311
|
+
for (const resourceUnit of group.dgroup.resources) {
|
|
4312
|
+
resourceUnit.resource.endpoints.sort(
|
|
4313
|
+
(a, b) => a.kind - b.kind || a.sequenceNumber - b.sequenceNumber
|
|
4314
|
+
);
|
|
4315
|
+
}
|
|
4316
|
+
}
|
|
4317
|
+
const sortedGroupNames = [...groupsMap.keys()].sort();
|
|
4318
|
+
let groups;
|
|
4319
|
+
let groupSpecs;
|
|
4320
|
+
const manifest = {
|
|
4321
|
+
get groups() {
|
|
4322
|
+
groups ?? (groups = sortedGroupNames.map((placementName) => {
|
|
4323
|
+
const deployments = deploymentsByPlacement.get(placementName);
|
|
4324
|
+
return Group.fromPartial({
|
|
4325
|
+
name: placementName,
|
|
4326
|
+
services: deployments.map(([svcName]) => {
|
|
4327
|
+
const service = sdl.services[svcName];
|
|
4328
|
+
const deployment = sdl.deployment[svcName][placementName];
|
|
4329
|
+
const compute = sdl.profiles.compute[deployment.profile];
|
|
4330
|
+
const resourceId = resourceIds.get(`${placementName}:${deployment.profile}`) || 1;
|
|
4331
|
+
return buildManifestService(
|
|
4332
|
+
resourceId,
|
|
4333
|
+
svcName,
|
|
4334
|
+
service,
|
|
4335
|
+
compute,
|
|
4336
|
+
deployment.count,
|
|
4337
|
+
endpointSequenceNumbers
|
|
4338
|
+
);
|
|
4339
|
+
})
|
|
4340
|
+
});
|
|
4341
|
+
}));
|
|
4342
|
+
return groups;
|
|
4343
|
+
},
|
|
4344
|
+
get groupSpecs() {
|
|
4345
|
+
groupSpecs ?? (groupSpecs = sortedGroupNames.map((name) => groupsMap.get(name).dgroup));
|
|
4346
|
+
return groupSpecs;
|
|
4347
|
+
}
|
|
4348
|
+
};
|
|
4349
|
+
return { ok: true, value: manifest };
|
|
4350
|
+
}
|
|
4351
|
+
function buildResources(id, compute, service, endpointSequenceNumbers) {
|
|
4352
|
+
const res = compute.resources;
|
|
4353
|
+
const cpuAttributes = buildResourceAttributes(res.cpu.attributes);
|
|
4354
|
+
const gpuAttributes = res.gpu?.attributes ? transformGpuAttributes(res.gpu.attributes) : [];
|
|
4355
|
+
return Resources.fromPartial({
|
|
4356
|
+
id,
|
|
4357
|
+
cpu: CPU.fromPartial({
|
|
4358
|
+
units: { val: encodeResourceValue(parseCpuUnits(res.cpu)) },
|
|
4359
|
+
attributes: cpuAttributes
|
|
4360
|
+
}),
|
|
4361
|
+
memory: Memory.fromPartial({
|
|
4362
|
+
quantity: { val: encodeResourceValue(parseMemoryBytes(res.memory)) }
|
|
4363
|
+
}),
|
|
4364
|
+
storage: castArray(res.storage).map(
|
|
4365
|
+
(s) => Storage.fromPartial({
|
|
4366
|
+
name: s.name || "default",
|
|
4367
|
+
quantity: { val: encodeResourceValue(parseStorageBytes(s.size)) },
|
|
4368
|
+
attributes: buildStorageAttributes(s.attributes)
|
|
4369
|
+
})
|
|
4370
|
+
),
|
|
4371
|
+
gpu: GPU.fromPartial({
|
|
4372
|
+
units: { val: encodeResourceValue(parseGpuUnits(res.gpu)) },
|
|
4373
|
+
attributes: gpuAttributes
|
|
4374
|
+
}),
|
|
4375
|
+
endpoints: buildServiceEndpoints(service, endpointSequenceNumbers)
|
|
4376
|
+
});
|
|
4377
|
+
}
|
|
4378
|
+
function buildManifestService(resourceId, name, service, compute, count, endpointSequenceNumbers) {
|
|
4379
|
+
const credentials = service.credentials ? ImageCredentials.fromPartial({
|
|
4380
|
+
host: service.credentials.host,
|
|
4381
|
+
email: service.credentials.email || "",
|
|
4382
|
+
username: service.credentials.username,
|
|
4383
|
+
password: service.credentials.password
|
|
4384
|
+
}) : void 0;
|
|
4385
|
+
const params = buildParams(service);
|
|
4386
|
+
return Service.fromPartial({
|
|
4387
|
+
name,
|
|
4388
|
+
image: service.image,
|
|
4389
|
+
command: service.command || [],
|
|
4390
|
+
args: service.args || [],
|
|
4391
|
+
env: service.env || [],
|
|
4392
|
+
resources: buildResources(resourceId, compute, service, endpointSequenceNumbers),
|
|
4393
|
+
count,
|
|
4394
|
+
expose: buildManifestExpose(service, endpointSequenceNumbers),
|
|
4395
|
+
params,
|
|
4396
|
+
credentials
|
|
4397
|
+
});
|
|
4398
|
+
}
|
|
4399
|
+
function buildParams(service) {
|
|
4400
|
+
if (!service.params) return void 0;
|
|
4401
|
+
const storageEntries = Object.entries(service.params.storage ?? {});
|
|
4402
|
+
const result = ServiceParams.fromPartial({
|
|
4403
|
+
storage: storageEntries.map(
|
|
4404
|
+
([name, config]) => StorageParams.fromPartial({
|
|
4405
|
+
name,
|
|
4406
|
+
mount: config.mount || "",
|
|
4407
|
+
readOnly: config.readOnly || false
|
|
4408
|
+
})
|
|
4409
|
+
)
|
|
4410
|
+
});
|
|
4411
|
+
if (service.params.permissions) {
|
|
4412
|
+
result.permissions = service.params.permissions;
|
|
4413
|
+
}
|
|
4414
|
+
return result;
|
|
4415
|
+
}
|
|
4416
|
+
function buildManifestExpose(service, endpointSequenceNumbers) {
|
|
4417
|
+
return (service.expose ?? []).flatMap(
|
|
4418
|
+
(expose) => (expose.to ?? []).map(
|
|
4419
|
+
(to) => ServiceExpose.fromPartial({
|
|
4420
|
+
port: expose.port,
|
|
4421
|
+
externalPort: expose.as,
|
|
4422
|
+
proto: parseServiceProto(expose.proto),
|
|
4423
|
+
service: to.service || "",
|
|
4424
|
+
global: to.global || false,
|
|
4425
|
+
hosts: expose.accept || [],
|
|
4426
|
+
httpOptions: buildHttpOptions(expose.http_options),
|
|
4427
|
+
ip: to.ip || "",
|
|
4428
|
+
endpointSequenceNumber: endpointSequenceNumbers[to.ip]
|
|
4429
|
+
})
|
|
4430
|
+
)
|
|
4431
|
+
).sort((a, b) => {
|
|
4432
|
+
if (a.service !== b.service) return a.service.localeCompare(b.service);
|
|
4433
|
+
if (a.port !== b.port) return a.port - b.port;
|
|
4434
|
+
if (a.proto !== b.proto) return a.proto.localeCompare(b.proto);
|
|
4435
|
+
if (a.global !== b.global) return a.global ? -1 : 1;
|
|
4436
|
+
return 0;
|
|
4437
|
+
});
|
|
4438
|
+
}
|
|
4439
|
+
|
|
4440
|
+
// src/sdl/manifest/generateManifestVersion.ts
|
|
4441
|
+
import { default as stableStringify2 } from "json-stable-stringify";
|
|
4442
|
+
var decoder = new TextDecoder();
|
|
4443
|
+
var encoder2 = new TextEncoder();
|
|
4444
|
+
var NULLABLE_MANIFEST_KEYS = /* @__PURE__ */ new Set(["command", "args", "env", "hosts"]);
|
|
4445
|
+
var OMITTED_MANIFEST_KEYS = /* @__PURE__ */ new Set(["kind", "attributes"]);
|
|
4446
|
+
async function generateManifestVersion(manifest) {
|
|
4447
|
+
const jsonStr = manifestToSortedJSON(manifest);
|
|
4448
|
+
const sortedBytes = encoder2.encode(jsonStr);
|
|
4449
|
+
const sum = await crypto.subtle.digest("SHA-256", sortedBytes);
|
|
4450
|
+
return new Uint8Array(sum);
|
|
4451
|
+
}
|
|
4452
|
+
function manifestToSortedJSON(manifest) {
|
|
4453
|
+
const json = stableStringify2(manifest, { replacer: manifestReplacer }) || "";
|
|
4454
|
+
return escapeHtml(renameFields(json));
|
|
4455
|
+
}
|
|
4456
|
+
function manifestReplacer(key, value) {
|
|
4457
|
+
if (value && value instanceof Uint8Array) {
|
|
4458
|
+
return decoder.decode(value);
|
|
4459
|
+
}
|
|
4460
|
+
if (typeof key !== "string") {
|
|
4461
|
+
return value;
|
|
4462
|
+
}
|
|
4463
|
+
if (typeof this === "object" && this && Object.hasOwn(this, "command") && key === "credentials" && value == null) {
|
|
4464
|
+
return null;
|
|
4465
|
+
}
|
|
4466
|
+
if (NULLABLE_MANIFEST_KEYS.has(key) && (Array.isArray(value) && value.length === 0 || value == null)) {
|
|
4467
|
+
return null;
|
|
4468
|
+
}
|
|
4469
|
+
if (OMITTED_MANIFEST_KEYS.has(key) && (Array.isArray(value) && value.length === 0 || value === 0)) {
|
|
4470
|
+
return void 0;
|
|
4471
|
+
}
|
|
4472
|
+
return value;
|
|
4473
|
+
}
|
|
4474
|
+
var MANIFEST_VERSION_FIELD_MAPPING = { quantity: "size", sequenceNumber: "sequence_number" };
|
|
4475
|
+
var MANIFEST_VERSION_FIELD_REGEX = new RegExp(`"(${Object.keys(MANIFEST_VERSION_FIELD_MAPPING).join("|")})":`, "g");
|
|
4476
|
+
function renameFields(jsonStr) {
|
|
4477
|
+
MANIFEST_VERSION_FIELD_REGEX.lastIndex = 0;
|
|
4478
|
+
return jsonStr.replace(MANIFEST_VERSION_FIELD_REGEX, (_, field) => `"${MANIFEST_VERSION_FIELD_MAPPING[field]}":`);
|
|
4479
|
+
}
|
|
4480
|
+
var htmlEscapes = {
|
|
4481
|
+
"<": "\\u003c",
|
|
4482
|
+
">": "\\u003e",
|
|
4483
|
+
"&": "\\u0026"
|
|
4484
|
+
};
|
|
4485
|
+
var HTML_SPECIAL_CHARS_REGEX = new RegExp(`[${Object.keys(htmlEscapes).join("")}]`, "g");
|
|
4486
|
+
function escapeHtml(raw) {
|
|
4487
|
+
HTML_SPECIAL_CHARS_REGEX.lastIndex = 0;
|
|
4488
|
+
return raw.replace(HTML_SPECIAL_CHARS_REGEX, (ch) => htmlEscapes[ch]);
|
|
4489
|
+
}
|
|
4490
|
+
|
|
4491
|
+
// src/utils/yaml.ts
|
|
4492
|
+
import { load } from "js-yaml";
|
|
4493
|
+
function yaml(chunks, ...args) {
|
|
4494
|
+
const str = chunks.reduce((acc, chunk, i) => {
|
|
4495
|
+
const value = args[i];
|
|
4496
|
+
const intermediateResult = acc + chunk;
|
|
4497
|
+
if (value === void 0) return intermediateResult;
|
|
4498
|
+
return intermediateResult + JSON.stringify(value);
|
|
4499
|
+
}, "");
|
|
4500
|
+
return load(str);
|
|
4501
|
+
}
|
|
4502
|
+
yaml.template = function yamlTemplate(template, vars) {
|
|
4503
|
+
const finalYaml = template.replace(/\$\{(\w+)\}/g, (_, varName) => {
|
|
4504
|
+
const value = vars?.[varName];
|
|
4505
|
+
if (value === void 0) {
|
|
4506
|
+
throw new ReferenceError(`Variable "${varName}" is not provided to yaml template`);
|
|
4507
|
+
}
|
|
4508
|
+
return JSON.stringify(value);
|
|
4509
|
+
});
|
|
4510
|
+
return load(finalYaml);
|
|
4511
|
+
};
|
|
4512
|
+
|
|
4103
4513
|
// src/sdk/transport/TransportError.ts
|
|
4104
4514
|
import { Code, ConnectError } from "@connectrpc/connect";
|
|
4105
4515
|
var TransportErrorCode = /* @__PURE__ */ ((TransportErrorCode2) => {
|
|
@@ -5927,7 +6337,7 @@ var JwtValidator = class {
|
|
|
5927
6337
|
};
|
|
5928
6338
|
|
|
5929
6339
|
// src/sdk/provider/auth/jwt/jwt-token.ts
|
|
5930
|
-
import { default as
|
|
6340
|
+
import { default as stableStringify3 } from "json-stable-stringify";
|
|
5931
6341
|
|
|
5932
6342
|
// src/sdk/provider/auth/jwt/wallet-utils.ts
|
|
5933
6343
|
function createOfflineDataSigner(wallet) {
|
|
@@ -6002,8 +6412,8 @@ var JwtTokenManager = class {
|
|
|
6002
6412
|
if (!validationResult.isValid) {
|
|
6003
6413
|
throw new Error(`Invalid payload: ${validationResult.errors?.join(", ")}`);
|
|
6004
6414
|
}
|
|
6005
|
-
const header = base64UrlEncode(
|
|
6006
|
-
const stringPayload = base64UrlEncode(
|
|
6415
|
+
const header = base64UrlEncode(stableStringify3({ alg: this.signer.algorithm || "ES256KADR36", typ: "JWT" }));
|
|
6416
|
+
const stringPayload = base64UrlEncode(stableStringify3(inputPayload));
|
|
6007
6417
|
const { signature } = await this.signer.signArbitrary(options.iss, `${header}.${stringPayload}`);
|
|
6008
6418
|
const token = `${header}.${stringPayload}.${toBase64Url(signature)}`;
|
|
6009
6419
|
return token;
|
|
@@ -8163,14 +8573,14 @@ var serviceLoader2 = createServiceLoader([
|
|
|
8163
8573
|
() => import("./service_akash-KPU6LPVP.js").then((m) => m.Msg),
|
|
8164
8574
|
() => import("./query_akash-LWCKZPHL.js").then((m) => m.Query),
|
|
8165
8575
|
() => import("./service_akash-5O4BYIF2.js").then((m) => m.Msg),
|
|
8166
|
-
() => import("./query_akash-
|
|
8167
|
-
() => import("./service_akash-
|
|
8576
|
+
() => import("./query_akash-4CTLBKZR.js").then((m) => m.Query),
|
|
8577
|
+
() => import("./service_akash-AZFAYT7H.js").then((m) => m.Msg),
|
|
8168
8578
|
() => import("./query_akash-GYTMDAAY.js").then((m) => m.Query),
|
|
8169
8579
|
() => import("./query_akash-KKNAAUKF.js").then((m) => m.Query),
|
|
8170
8580
|
() => import("./query_akash-4OVOGRBT.js").then((m) => m.Query),
|
|
8171
8581
|
() => import("./service_akash-KKV7TGYK.js").then((m) => m.Msg),
|
|
8172
|
-
() => import("./query_akash-
|
|
8173
|
-
() => import("./service_akash-
|
|
8582
|
+
() => import("./query_akash-DJ7LTLRE.js").then((m) => m.Query),
|
|
8583
|
+
() => import("./service_akash-WRGOVR7I.js").then((m) => m.Msg),
|
|
8174
8584
|
() => import("./query_akash-RGYTHUNZ.js").then((m) => m.Query),
|
|
8175
8585
|
() => import("./service_akash-RQDCQLQH.js").then((m) => m.Msg),
|
|
8176
8586
|
() => import("./query_akash-ERHU5RE6.js").then((m) => m.Query),
|
|
@@ -8881,10 +9291,14 @@ export {
|
|
|
8881
9291
|
TESTNET_ID,
|
|
8882
9292
|
USDC_IBC_DENOMS,
|
|
8883
9293
|
AKT_DENOM,
|
|
8884
|
-
SdlValidationError,
|
|
8885
9294
|
schema,
|
|
8886
9295
|
validateSDL,
|
|
9296
|
+
SdlValidationError,
|
|
8887
9297
|
SDL,
|
|
9298
|
+
generateManifest,
|
|
9299
|
+
generateManifestVersion,
|
|
9300
|
+
manifestToSortedJSON,
|
|
9301
|
+
yaml,
|
|
8888
9302
|
TransportErrorCode,
|
|
8889
9303
|
TransportError,
|
|
8890
9304
|
TxError,
|
|
@@ -8908,4 +9322,4 @@ export {
|
|
|
8908
9322
|
isRetryEnabled,
|
|
8909
9323
|
createTxTransport
|
|
8910
9324
|
};
|
|
8911
|
-
//# sourceMappingURL=chunk-
|
|
9325
|
+
//# sourceMappingURL=chunk-RIIYZIXM.js.map
|