@akashnetwork/chain-sdk 1.0.0-alpha.23 → 1.0.0-alpha.25
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 +25 -0
- package/dist/cjs/generated/createCosmosSDK.cjs +237 -237
- package/dist/cjs/generated/createCosmosSDK.cjs.map +2 -2
- package/dist/cjs/generated/createIbc-goSDK.cjs +91 -91
- package/dist/cjs/generated/createIbc-goSDK.cjs.map +2 -2
- package/dist/cjs/generated/createNodeSDK.cjs +68 -61
- package/dist/cjs/generated/createNodeSDK.cjs.map +2 -2
- package/dist/cjs/generated/createProviderSDK.cjs +18 -11
- package/dist/cjs/generated/createProviderSDK.cjs.map +2 -2
- package/dist/cjs/generated/patches/providerCustomTypePatches.cjs +34 -0
- package/dist/cjs/generated/patches/providerCustomTypePatches.cjs.map +7 -0
- package/dist/cjs/generated/patches/providerPatchMessage.cjs +38 -0
- package/dist/cjs/generated/patches/providerPatchMessage.cjs.map +7 -0
- package/dist/cjs/generated/protos/akash/bme/v1/filters.cjs +125 -0
- package/dist/cjs/generated/protos/akash/bme/v1/filters.cjs.map +7 -0
- package/dist/cjs/generated/protos/akash/bme/v1/params.cjs +26 -10
- package/dist/cjs/generated/protos/akash/bme/v1/params.cjs.map +2 -2
- package/dist/cjs/generated/protos/akash/bme/v1/query.cjs +233 -0
- package/dist/cjs/generated/protos/akash/bme/v1/query.cjs.map +2 -2
- package/dist/cjs/generated/protos/akash/bme/v1/query_akash.cjs +9 -0
- package/dist/cjs/generated/protos/akash/bme/v1/query_akash.cjs.map +2 -2
- package/dist/cjs/generated/protos/akash/manifest/v2beta3/service.cjs +67 -2
- package/dist/cjs/generated/protos/akash/manifest/v2beta3/service.cjs.map +2 -2
- package/dist/cjs/generated/protos/akash/market/v1beta5/params.cjs +17 -2
- package/dist/cjs/generated/protos/akash/market/v1beta5/params.cjs.map +2 -2
- package/dist/cjs/generated/protos/akash/market/v1beta5/resourcesoffer.cjs +266 -3
- package/dist/cjs/generated/protos/akash/market/v1beta5/resourcesoffer.cjs.map +2 -2
- package/dist/cjs/generated/protos/akash/oracle/v1/params.cjs +53 -1
- package/dist/cjs/generated/protos/akash/oracle/v1/params.cjs.map +2 -2
- package/dist/cjs/generated/protos/akash/provider/v1/service_akash.cjs +9 -0
- package/dist/cjs/generated/protos/akash/provider/v1/service_akash.cjs.map +2 -2
- package/dist/cjs/generated/protos/akash/provider/v1/validation.cjs +195 -0
- package/dist/cjs/generated/protos/akash/provider/v1/validation.cjs.map +7 -0
- package/dist/cjs/generated/protos/google/protobuf/descriptor.cjs +6 -0
- package/dist/cjs/generated/protos/google/protobuf/descriptor.cjs.map +2 -2
- package/dist/cjs/generated/protos/index.akash.v1.cjs +11 -5
- package/dist/cjs/generated/protos/index.akash.v1.cjs.map +3 -3
- package/dist/cjs/generated/protos/index.akash.v1beta5.cjs +4 -1
- package/dist/cjs/generated/protos/index.akash.v1beta5.cjs.map +2 -2
- package/dist/cjs/generated/protos/index.provider.akash.v1.cjs +3 -0
- package/dist/cjs/generated/protos/index.provider.akash.v1.cjs.map +2 -2
- package/dist/cjs/generated/protos/index.provider.akash.v2beta3.cjs +1 -0
- package/dist/cjs/generated/protos/index.provider.akash.v2beta3.cjs.map +2 -2
- package/dist/cjs/sdk/chain/createChainNodeSDK.cjs +2 -1
- package/dist/cjs/sdk/chain/createChainNodeSDK.cjs.map +2 -2
- package/dist/cjs/sdk/chain/createChainNodeWebSDK.cjs +2 -1
- package/dist/cjs/sdk/chain/createChainNodeWebSDK.cjs.map +2 -2
- package/dist/cjs/sdk/chain/helpers.cjs +56 -0
- package/dist/cjs/sdk/chain/helpers.cjs.map +7 -0
- package/dist/cjs/sdk/client/sdkMetadata.cjs.map +2 -2
- package/dist/cjs/sdk/index.cjs.map +2 -2
- package/dist/cjs/sdk/index.shared.cjs +4 -1
- package/dist/cjs/sdk/index.shared.cjs.map +2 -2
- package/dist/cjs/sdk/index.web.cjs.map +2 -2
- package/dist/cjs/sdk/transport/tx/createTxTransport.cjs +1 -1
- package/dist/cjs/sdk/transport/tx/createTxTransport.cjs.map +2 -2
- package/dist/cjs/sdl/SDL/SDL.cjs +11 -11
- package/dist/cjs/sdl/SDL/SDL.cjs.map +2 -2
- package/dist/cjs/sdl/manifest/generateManifest.cjs +8 -6
- package/dist/cjs/sdl/manifest/generateManifest.cjs.map +2 -2
- package/dist/cjs/sdl/manifest/generateManifestVersion.cjs.map +2 -2
- package/dist/cjs/sdl/manifest/manifestUtils.cjs +16 -9
- package/dist/cjs/sdl/manifest/manifestUtils.cjs.map +2 -2
- package/dist/cjs/sdl/types.cjs.map +1 -1
- package/dist/cjs/utils/yaml.cjs +10 -3
- package/dist/cjs/utils/yaml.cjs.map +2 -2
- package/dist/esm/{chunk-BYQF33C6.js → chunk-5YIS3XNX.js} +2 -2
- package/dist/esm/{chunk-JISXXX24.js → chunk-6CIH635G.js} +2 -2
- package/dist/esm/{chunk-GUNMCW7A.js → chunk-BWGYKJLS.js} +2 -2
- package/dist/esm/{chunk-MQPC6TDF.js → chunk-C3DBWOZD.js} +53 -1
- package/dist/esm/{chunk-MQPC6TDF.js.map → chunk-C3DBWOZD.js.map} +2 -2
- package/dist/esm/{chunk-TCVGOF7L.js → chunk-DJASDN6A.js} +2 -2
- package/dist/esm/{chunk-5DCYIWCG.js → chunk-E76SLJJ3.js} +3 -1
- package/dist/esm/{chunk-4D3QNKFB.js → chunk-EKFJV4QU.js} +6 -4
- package/dist/esm/{chunk-4D3QNKFB.js.map → chunk-EKFJV4QU.js.map} +1 -1
- package/dist/esm/{chunk-XFCN5LRY.js → chunk-H5WUFEMM.js} +2 -2
- package/dist/esm/{chunk-YSMDEW4E.js → chunk-JZTFWLSX.js} +178 -2
- package/dist/esm/{chunk-YSMDEW4E.js.map → chunk-JZTFWLSX.js.map} +4 -4
- package/dist/esm/{chunk-C7UQYVYH.js → chunk-KFWTFROT.js} +21 -79
- package/dist/esm/chunk-KFWTFROT.js.map +7 -0
- package/dist/esm/{chunk-IZQCYKLD.js → chunk-LGAXM6RX.js} +27 -11
- package/dist/esm/chunk-LGAXM6RX.js.map +7 -0
- package/dist/esm/{chunk-VRE72ZD5.js → chunk-M2ZK7HEC.js} +69 -4
- package/dist/esm/chunk-M2ZK7HEC.js.map +7 -0
- package/dist/esm/{chunk-Z5KZUB7X.js → chunk-MVADLHLI.js} +2 -2
- package/dist/esm/chunk-OL4JUIQC.js +702 -0
- package/dist/esm/chunk-OL4JUIQC.js.map +7 -0
- package/dist/esm/{chunk-5YECXI3P.js → chunk-RUC3LXDX.js} +2 -2
- package/dist/esm/{chunk-SA4SEZ6F.js → chunk-TXQ2BR6G.js} +5 -3
- package/dist/esm/{chunk-SA4SEZ6F.js.map → chunk-TXQ2BR6G.js.map} +1 -1
- package/dist/esm/{chunk-IJSLZIPC.js → chunk-UFJRY3ID.js} +2 -2
- package/dist/esm/chunk-Y7JCYDLU.js +346 -0
- package/dist/esm/chunk-Y7JCYDLU.js.map +7 -0
- package/dist/esm/{chunk-RON4KFMD.js → chunk-ZQDAXUFL.js} +6 -1
- package/dist/esm/chunk-ZQDAXUFL.js.map +7 -0
- package/dist/esm/{chunk-QSKWS3TI.js → chunk-ZRM47VCZ.js} +409 -349
- package/dist/esm/chunk-ZRM47VCZ.js.map +7 -0
- package/dist/esm/generated/protos/index.akash.v1.js +18 -8
- package/dist/esm/generated/protos/index.akash.v1.js.map +1 -1
- package/dist/esm/generated/protos/index.akash.v1beta4.js +5 -5
- package/dist/esm/generated/protos/index.akash.v1beta5.js +16 -8
- package/dist/esm/generated/protos/index.akash.v1beta5.js.map +1 -1
- package/dist/esm/generated/protos/index.cosmos.v1.js +1 -1
- package/dist/esm/generated/protos/index.provider.akash.v1.js +10 -4
- package/dist/esm/generated/protos/index.provider.akash.v2beta3.js +4 -2
- package/dist/esm/index.js +33 -21
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/index.web.js +13 -8
- package/dist/esm/index.web.js.map +2 -2
- package/dist/esm/{query_akash-RGYTHUNZ.js → query_akash-745M5I3X.js} +3 -3
- package/dist/esm/{query_akash-N2BNNOTD.js → query_akash-EHAEDYOH.js} +15 -3
- package/dist/esm/query_akash-EHAEDYOH.js.map +7 -0
- package/dist/esm/{query_akash-DJ7LTLRE.js → query_akash-FYNRLU72.js} +6 -5
- package/dist/esm/{query_akash-DJ7LTLRE.js.map → query_akash-FYNRLU72.js.map} +1 -1
- package/dist/esm/{query_akash-4CTLBKZR.js → query_akash-LW3YJGS6.js} +4 -4
- package/dist/esm/{reflection_akash-WUBSNT7I.js → reflection_akash-YHEVUIB6.js} +2 -2
- package/dist/esm/{service_akash-KPU6LPVP.js → service_akash-2VS4VW6P.js} +3 -3
- package/dist/esm/{service_akash-AZFAYT7H.js → service_akash-5JSE44LJ.js} +4 -4
- package/dist/esm/{service_akash-VMU3LNBA.js → service_akash-FI6WXDZP.js} +4 -4
- package/dist/esm/{service_akash-WRGOVR7I.js → service_akash-QEN5EQUY.js} +5 -4
- package/dist/esm/{service_akash-WRGOVR7I.js.map → service_akash-QEN5EQUY.js.map} +1 -1
- package/dist/esm/{service_akash-CQVYVSHE.js → service_akash-UDPD4GFX.js} +18 -2
- package/dist/esm/service_akash-UDPD4GFX.js.map +7 -0
- package/dist/esm/{service_akash-RQDCQLQH.js → service_akash-VFDQVHZD.js} +3 -3
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/generated/createNodeSDK.d.ts +11 -0
- package/dist/types/generated/createProviderSDK.d.ts +11 -0
- package/dist/types/generated/patches/providerCustomTypePatches.d.ts +7 -0
- package/dist/types/generated/patches/providerPatchMessage.d.ts +2 -0
- package/dist/types/generated/protos/akash/bme/v1/filters.d.ts +17 -0
- package/dist/types/generated/protos/akash/bme/v1/params.d.ts +6 -1
- package/dist/types/generated/protos/akash/bme/v1/query.d.ts +31 -1
- package/dist/types/generated/protos/akash/bme/v1/query_akash.d.ts +8 -1
- package/dist/types/generated/protos/akash/manifest/v2beta3/service.d.ts +10 -0
- package/dist/types/generated/protos/akash/market/v1beta5/params.d.ts +6 -1
- package/dist/types/generated/protos/akash/market/v1beta5/resourcesoffer.d.ts +91 -0
- package/dist/types/generated/protos/akash/oracle/v1/params.d.ts +14 -0
- package/dist/types/generated/protos/akash/provider/v1/service_akash.d.ts +7 -0
- package/dist/types/generated/protos/akash/provider/v1/validation.d.ts +30 -0
- package/dist/types/generated/protos/google/protobuf/descriptor.d.ts +2 -0
- package/dist/types/generated/protos/index.akash.v1.d.ts +3 -2
- package/dist/types/generated/protos/index.akash.v1beta5.d.ts +1 -1
- package/dist/types/generated/protos/index.provider.akash.v1.d.ts +1 -0
- package/dist/types/generated/protos/index.provider.akash.v2beta3.d.ts +1 -1
- package/dist/types/sdk/chain/createChainNodeSDK.d.ts +3 -0
- package/dist/types/sdk/chain/createChainNodeWebSDK.d.ts +3 -0
- package/dist/types/sdk/chain/helpers.d.ts +14 -0
- package/dist/types/sdk/client/sdkMetadata.d.ts +5 -2
- package/dist/types/sdk/index.d.ts +2 -0
- package/dist/types/sdk/index.shared.d.ts +2 -0
- package/dist/types/sdk/index.web.d.ts +2 -0
- package/dist/types/sdl/manifest/generateManifest.d.ts +3 -3
- package/dist/types/sdl/manifest/generateManifestVersion.d.ts +2 -2
- package/dist/types/sdl/types.d.ts +1 -1
- package/dist/types/utils/yaml.d.ts +3 -0
- package/package.json +1 -1
- package/dist/esm/chunk-C7UQYVYH.js.map +0 -7
- package/dist/esm/chunk-IZQCYKLD.js.map +0 -7
- package/dist/esm/chunk-QSKWS3TI.js.map +0 -7
- package/dist/esm/chunk-RON4KFMD.js.map +0 -7
- package/dist/esm/chunk-VRE72ZD5.js.map +0 -7
- package/dist/esm/chunk-XPIWBE65.js +0 -362
- package/dist/esm/chunk-XPIWBE65.js.map +0 -7
- package/dist/esm/query_akash-N2BNNOTD.js.map +0 -7
- package/dist/esm/service_akash-CQVYVSHE.js.map +0 -7
- /package/dist/esm/{chunk-BYQF33C6.js.map → chunk-5YIS3XNX.js.map} +0 -0
- /package/dist/esm/{chunk-JISXXX24.js.map → chunk-6CIH635G.js.map} +0 -0
- /package/dist/esm/{chunk-GUNMCW7A.js.map → chunk-BWGYKJLS.js.map} +0 -0
- /package/dist/esm/{chunk-TCVGOF7L.js.map → chunk-DJASDN6A.js.map} +0 -0
- /package/dist/esm/{chunk-5DCYIWCG.js.map → chunk-E76SLJJ3.js.map} +0 -0
- /package/dist/esm/{chunk-XFCN5LRY.js.map → chunk-H5WUFEMM.js.map} +0 -0
- /package/dist/esm/{chunk-Z5KZUB7X.js.map → chunk-MVADLHLI.js.map} +0 -0
- /package/dist/esm/{chunk-5YECXI3P.js.map → chunk-RUC3LXDX.js.map} +0 -0
- /package/dist/esm/{chunk-IJSLZIPC.js.map → chunk-UFJRY3ID.js.map} +0 -0
- /package/dist/esm/{query_akash-RGYTHUNZ.js.map → query_akash-745M5I3X.js.map} +0 -0
- /package/dist/esm/{query_akash-4CTLBKZR.js.map → query_akash-LW3YJGS6.js.map} +0 -0
- /package/dist/esm/{reflection_akash-WUBSNT7I.js.map → reflection_akash-YHEVUIB6.js.map} +0 -0
- /package/dist/esm/{service_akash-KPU6LPVP.js.map → service_akash-2VS4VW6P.js.map} +0 -0
- /package/dist/esm/{service_akash-AZFAYT7H.js.map → service_akash-5JSE44LJ.js.map} +0 -0
- /package/dist/esm/{service_akash-VMU3LNBA.js.map → service_akash-FI6WXDZP.js.map} +0 -0
- /package/dist/esm/{service_akash-RQDCQLQH.js.map → service_akash-VFDQVHZD.js.map} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/sdl/SDL/SDL.ts"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport YAML from \"js-yaml\";\nimport { default as stableStringify } from \"json-stable-stringify\";\n\nimport { MAINNET_ID } from \"../../network/config.ts\";\nimport type { NetworkId } from \"../../network/types.ts\";\nimport { convertCpuResourceString, convertResourceString } from \"../sizes.ts\";\nimport type {\n v2ComputeResources,\n v2Expose,\n v2ExposeTo,\n v2HTTPOptions,\n v2Manifest,\n v2ManifestService,\n v2ManifestServiceParams,\n v2ProfileCompute,\n v2ResourceCPU,\n v2ResourceMemory,\n v2ResourceStorage,\n v2ResourceStorageArray,\n v2Sdl,\n v2Service,\n v2ServiceExpose,\n v2ServiceExposeHttpOptions,\n v2ServiceParams,\n v2StorageAttributes,\n v3ComputeResources,\n v3DeploymentGroup,\n v3GPUAttributes,\n v3Manifest,\n v3ManifestService,\n v3ManifestServiceParams,\n v3ProfileCompute,\n v3ResourceGPU,\n v3Sdl,\n v3ServiceExpose,\n v3ServiceExposeHttpOptions } from \"../types.ts\";\nimport type { SDLInput } from \"../validateSDL/validateSDL.ts\";\nimport { validateSDL } from \"../validateSDL/validateSDL.ts\";\nimport { SdlValidationError } from \"./SdlValidationError.ts\";\n\nconst Endpoint_SHARED_HTTP = 0;\nconst Endpoint_RANDOM_PORT = 1;\nconst Endpoint_LEASED_IP = 2;\n\nfunction isArray<T>(obj: any): obj is Array<T> {\n return Array.isArray(obj);\n}\n\nfunction isString(str: any): str is string {\n return typeof str === \"string\";\n}\n\ntype NetworkVersion = \"beta2\" | \"beta3\";\n\n/**\n * SDL (Stack Definition Language) parser and validator\n * Handles parsing and validation of Akash deployment manifests\n *\n * @deprecated Use `generateManifest` instead.\n *\n * @example\n * ```ts\n * import { SDL } from './SDL';\n *\n * const yaml = `\n * version: \"2.0\"\n * services:\n * web:\n * image: nginx\n * expose:\n * - port: 80\n * as: 80\n * to:\n * - global: true\n * `;\n *\n * // Parse SDL from YAML string\n * const sdl = SDL.fromString(yaml);\n *\n * // Get deployment manifest\n * const manifest = sdl.manifest();\n *\n * // Get deployment groups\n * const groups = sdl.groups();\n * ```\n */\nexport class SDL {\n /**\n * Creates an SDL instance from a YAML string.\n *\n * @param {string} yaml - The YAML string containing the SDL definition.\n * @param {NetworkVersion} [version=\"beta3\"] - The SDL version (beta2 or beta3).\n * @param {NetworkId} [networkId=MAINNET_ID] - The network ID to validate against.\n * @returns {SDL} An instance of the SDL class.\n *\n * @example\n * ```ts\n * const yaml = `\n * version: \"2.0\"\n * services:\n * web:\n * image: nginx\n * expose:\n * - port: 80\n * as: 80\n * to:\n * - global: true\n * `;\n * const sdl = SDL.fromString(yaml);\n * ```\n */\n static fromString(yaml: string, version: NetworkVersion = \"beta3\", networkId: NetworkId = MAINNET_ID): SDL {\n const data = YAML.load(yaml) as v3Sdl;\n return new SDL(data, version, networkId);\n }\n\n constructor(\n public readonly data: v2Sdl,\n public readonly version: NetworkVersion = \"beta2\",\n networkId: NetworkId = MAINNET_ID,\n ) {\n const errors = validateSDL(data as unknown as SDLInput, networkId);\n if (errors) throw new SdlValidationError(errors[0].message);\n }\n\n services() {\n if (this.data) {\n return this.data.services;\n }\n\n return {};\n }\n\n deployments() {\n if (this.data) {\n return this.data.deployment;\n }\n\n return {};\n }\n\n profiles() {\n if (this.data) {\n return this.data.profiles;\n }\n\n return {};\n }\n\n placements() {\n const { placement } = this.data.profiles;\n\n return placement || {};\n }\n\n serviceNames() {\n const names = this.data ? Object.keys(this.data.services) : [];\n\n // TODO: sort these\n return names;\n }\n\n deploymentsByPlacement(placement: string) {\n const deployments = this.data ? this.data.deployment : [];\n\n return Object.entries(deployments as object).filter(({ 1: deployment }) => Object.prototype.hasOwnProperty.call(deployment, placement));\n }\n\n resourceUnit(val: string, asString: boolean) {\n return asString ? { val: `${convertResourceString(val)}` } : { val: convertResourceString(val) };\n }\n\n resourceValue(value: { toString: () => string } | null, asString: boolean) {\n if (value === null) {\n return value;\n }\n\n const strVal = value.toString();\n const encoder = new TextEncoder();\n\n return asString ? strVal : encoder.encode(strVal);\n }\n\n serviceResourceCpu(resource: v2ResourceCPU) {\n const units = isString(resource.units) ? convertCpuResourceString(resource.units) : resource.units * 1000;\n\n return resource.attributes\n ? {\n units: { val: `${units}` },\n attributes: this.serviceResourceAttributes(resource.attributes),\n }\n : {\n units: { val: `${units}` },\n };\n }\n\n serviceResourceMemory(resource: v2ResourceMemory, asString: boolean) {\n const key = asString ? \"quantity\" : \"size\";\n\n return resource.attributes\n ? {\n [key]: this.resourceUnit(resource.size, asString),\n attributes: this.serviceResourceAttributes(resource.attributes),\n }\n : {\n [key]: this.resourceUnit(resource.size, asString),\n };\n }\n\n serviceResourceStorage(resource: v2ResourceStorageArray | v2ResourceStorage, asString: boolean) {\n const key = asString ? \"quantity\" : \"size\";\n const storage = isArray(resource) ? resource : [resource];\n\n return storage.map((storage) =>\n storage.attributes\n ? {\n name: storage.name || \"default\",\n [key]: this.resourceUnit(storage.size, asString),\n attributes: this.serviceResourceStorageAttributes(storage.attributes),\n }\n : {\n name: storage.name || \"default\",\n [key]: this.resourceUnit(storage.size, asString),\n },\n );\n }\n\n serviceResourceAttributes(attributes?: Record<string, any>) {\n return (\n attributes\n && Object.keys(attributes)\n .sort()\n .map((key) => ({ key, value: attributes[key].toString() }))\n );\n }\n\n serviceResourceStorageAttributes(attributes?: v2StorageAttributes) {\n if (!attributes) return undefined;\n\n const pairs = Object.keys(attributes).map((key) => ({ key, value: attributes[key].toString() }));\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\n return pairs;\n }\n\n serviceResourceGpu(resource: v3ResourceGPU | undefined, asString: boolean) {\n const value = resource?.units || 0;\n const numVal = isString(value) ? Buffer.from(value, \"ascii\") : value;\n const strVal = !isString(value) ? value.toString() : value;\n\n return resource?.attributes\n ? {\n units: asString ? { val: strVal } : { val: numVal },\n attributes: this.transformGpuAttributes(resource?.attributes),\n }\n : {\n units: asString ? { val: strVal } : { val: numVal },\n };\n }\n\n v2ServiceResourceEndpoints(service: v2Service) {\n const endpointSequenceNumbers = this.computeEndpointSequenceNumbers(this.data);\n const endpoints = service.expose.flatMap((expose) =>\n expose.to\n ? expose.to\n .filter((to) => to.global && to.ip?.length > 0)\n .map((to) => ({\n kind: Endpoint_LEASED_IP,\n sequence_number: endpointSequenceNumbers[to.ip] || 0,\n }))\n : [],\n );\n\n return endpoints.length > 0 ? endpoints : null;\n }\n\n v3ServiceResourceEndpoints(service: v2Service) {\n const endpointSequenceNumbers = this.computeEndpointSequenceNumbers(this.data);\n const endpoints = service.expose.flatMap((expose) =>\n expose.to\n ? expose.to\n .filter((to) => to.global)\n .flatMap((to) => {\n const exposeSpec = {\n port: expose.port,\n externalPort: expose.as || 0,\n proto: this.parseServiceProto(expose.proto),\n global: !!to.global,\n };\n\n const kind = this.exposeShouldBeIngress(exposeSpec) ? Endpoint_SHARED_HTTP : Endpoint_RANDOM_PORT;\n\n const defaultEp = kind !== 0 ? { kind: kind, sequence_number: 0 } : { sequence_number: 0 };\n\n const leasedEp\n = to.ip?.length > 0\n ? {\n kind: Endpoint_LEASED_IP,\n sequence_number: endpointSequenceNumbers[to.ip] || 0,\n }\n : undefined;\n\n return leasedEp ? [defaultEp, leasedEp] : [defaultEp];\n })\n : [],\n );\n\n return endpoints;\n }\n\n serviceResourcesBeta2(profile: v2ProfileCompute, service: v2Service, asString: boolean = false) {\n return {\n cpu: this.serviceResourceCpu(profile.resources.cpu),\n memory: this.serviceResourceMemory(profile.resources.memory, asString),\n storage: this.serviceResourceStorage(profile.resources.storage, asString),\n endpoints: this.v2ServiceResourceEndpoints(service),\n };\n }\n\n serviceResourcesBeta3(id: number, profile: v3ProfileCompute, service: v2Service, asString: boolean = false) {\n return {\n id: id,\n cpu: this.serviceResourceCpu(profile.resources.cpu),\n memory: this.serviceResourceMemory(profile.resources.memory, asString),\n storage: this.serviceResourceStorage(profile.resources.storage, asString),\n gpu: this.serviceResourceGpu(profile.resources.gpu, asString),\n endpoints: this.v3ServiceResourceEndpoints(service),\n };\n }\n\n /**\n * Parses the service protocol.\n *\n * @param proto - The protocol string (e.g., \"TCP\", \"UDP\").\n * @returns The parsed protocol.\n * @throws Will throw an error if the protocol is unsupported.\n *\n * @example\n * ```ts\n * const protocol = SDL.parseServiceProto(\"TCP\");\n * // protocol is \"TCP\"\n * ```\n */\n parseServiceProto(proto?: string): string {\n const raw = proto?.toUpperCase() || \"TCP\";\n if (raw === \"TCP\" || raw === \"UDP\") return raw;\n\n throw new SdlValidationError(`Unsupported service protocol: \"${proto}\". Supported protocols are \"TCP\" and \"UDP\".`);\n }\n\n manifestExposeService(to: v2ExposeTo) {\n return to.service || \"\";\n }\n\n manifestExposeGlobal(to: v2ExposeTo) {\n return to.global || false;\n }\n\n manifestExposeHosts(expose: v2Expose) {\n return expose.accept || null;\n }\n\n v2HttpOptions(http_options: v2HTTPOptions | undefined) {\n const defaults = {\n MaxBodySize: 1048576,\n ReadTimeout: 60000,\n SendTimeout: 60000,\n NextTries: 3,\n NextTimeout: 0,\n NextCases: [\"error\", \"timeout\"],\n };\n\n if (!http_options) {\n return { ...defaults };\n }\n\n return {\n MaxBodySize: http_options.max_body_size || defaults.MaxBodySize,\n ReadTimeout: http_options.read_timeout || defaults.ReadTimeout,\n SendTimeout: http_options.send_timeout || defaults.SendTimeout,\n NextTries: http_options.next_tries || defaults.NextTries,\n NextTimeout: http_options.next_timeout || defaults.NextTimeout,\n NextCases: http_options.next_cases || defaults.NextCases,\n };\n }\n\n v3HttpOptions(http_options: v2HTTPOptions | undefined) {\n const defaults = {\n maxBodySize: 1048576,\n readTimeout: 60000,\n sendTimeout: 60000,\n nextTries: 3,\n nextTimeout: 0,\n nextCases: [\"error\", \"timeout\"],\n };\n\n if (!http_options) {\n return { ...defaults };\n }\n\n return {\n maxBodySize: http_options.max_body_size || defaults.maxBodySize,\n readTimeout: http_options.read_timeout || defaults.readTimeout,\n sendTimeout: http_options.send_timeout || defaults.sendTimeout,\n nextTries: http_options.next_tries || defaults.nextTries,\n nextTimeout: http_options.next_timeout || defaults.nextTimeout,\n nextCases: http_options.next_cases || defaults.nextCases,\n };\n }\n\n v2ManifestExposeHttpOptions(expose: v2Expose): v2ServiceExposeHttpOptions {\n return this.v2HttpOptions(expose.http_options);\n }\n\n v3ManifestExposeHttpOptions(expose: v2Expose): v3ServiceExposeHttpOptions {\n return this.v3HttpOptions(expose.http_options);\n }\n\n v2ManifestExpose(service: v2Service): v2ServiceExpose[] {\n const endpointSequenceNumbers = this.computeEndpointSequenceNumbers(this.data);\n return service.expose.flatMap((expose) =>\n expose.to\n ? expose.to.map((to) => ({\n Port: expose.port,\n ExternalPort: expose.as || 0,\n Proto: this.parseServiceProto(expose.proto),\n Service: this.manifestExposeService(to),\n Global: this.manifestExposeGlobal(to),\n Hosts: this.manifestExposeHosts(expose),\n HTTPOptions: this.v2ManifestExposeHttpOptions(expose),\n IP: to.ip || \"\",\n EndpointSequenceNumber: endpointSequenceNumbers[to.ip] || 0,\n }))\n : [],\n );\n }\n\n v3ManifestExpose(service: v2Service): v3ServiceExpose[] {\n const endpointSequenceNumbers = this.computeEndpointSequenceNumbers(this.data);\n return service.expose\n .flatMap((expose) =>\n expose.to\n ? expose.to.map((to) => ({\n port: expose.port,\n externalPort: expose.as || 0,\n proto: this.parseServiceProto(expose.proto),\n service: this.manifestExposeService(to),\n global: this.manifestExposeGlobal(to),\n hosts: this.manifestExposeHosts(expose),\n httpOptions: this.v3ManifestExposeHttpOptions(expose),\n ip: to.ip || \"\",\n endpointSequenceNumber: endpointSequenceNumbers[to.ip] || 0,\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\n return 0;\n });\n }\n\n v2ManifestServiceParams(params: v2ServiceParams): v2ManifestServiceParams | undefined {\n return {\n Storage: Object.keys(params?.storage ?? {}).map((name) => {\n if (!params?.storage) throw new Error(\"Storage is undefined\");\n return {\n name: name,\n mount: params.storage[name].mount,\n readOnly: params.storage[name].readOnly || false,\n };\n }),\n ...(params?.permissions ? { Permissions: params.permissions } : {}),\n };\n }\n\n v3ManifestServiceParams(params: v2ServiceParams | undefined): v3ManifestServiceParams | null {\n if (params === undefined) {\n return null;\n }\n\n return {\n storage: Object.keys(params?.storage ?? {}).map((name) => {\n if (!params?.storage) throw new Error(\"Storage is undefined\");\n return {\n name: name,\n mount: params.storage[name]?.mount,\n readOnly: params.storage[name]?.readOnly || false,\n };\n }),\n ...(params?.permissions ? { permissions: params.permissions } : {}),\n };\n }\n\n v2ManifestService(placement: string, name: string, asString: boolean): v2ManifestService {\n const service = this.data.services[name];\n const deployment = this.data.deployment[name];\n const profile = this.data.profiles.compute[deployment[placement].profile];\n\n const manifestService: v2ManifestService = {\n Name: name,\n Image: service.image,\n Command: service.command || null,\n Args: service.args || null,\n Env: service.env || null,\n Resources: this.serviceResourcesBeta2(profile, service, asString),\n Count: deployment[placement].count,\n Expose: this.v2ManifestExpose(service),\n };\n\n if (service.params) {\n manifestService.params = this.v2ManifestServiceParams(service.params);\n }\n\n return manifestService;\n }\n\n v3ManifestService(id: number, placement: string, name: string, asString: boolean): v3ManifestService {\n const service = this.data.services[name];\n const deployment = this.data.deployment[name];\n const profile = this.data.profiles.compute[deployment[placement].profile];\n const credentials = service.credentials || null;\n\n if (credentials && !credentials.email) {\n credentials.email = \"\";\n }\n\n const manifestService: v3ManifestService = {\n name: name,\n image: service.image,\n command: service.command || null,\n args: service.args || null,\n env: service.env || null,\n resources: this.serviceResourcesBeta3(id, profile as v3ProfileCompute, service, asString),\n count: deployment[placement].count,\n expose: this.v3ManifestExpose(service),\n params: this.v3ManifestServiceParams(service.params),\n credentials,\n };\n\n if (!manifestService.params) {\n delete manifestService.params;\n }\n\n return manifestService;\n }\n\n v2Manifest(asString: boolean = false): v2Manifest {\n return Object.keys(this.placements()).map((name) => ({\n Name: name,\n Services: this.deploymentsByPlacement(name).map(([service]) => this.v2ManifestService(name, service, asString)),\n }));\n }\n\n v3Manifest(asString: boolean = false): v3Manifest {\n const groups = this.v3Groups();\n const serviceId = (pIdx: number, sIdx: number) => groups[pIdx].resources[sIdx].resource.id;\n\n return Object.keys(this.placements()).map((name, pIdx) => ({\n name: name,\n services: this.deploymentsByPlacement(name)\n .sort(([a], [b]) => a.localeCompare(b))\n .map(([service], idx) => this.v3ManifestService(serviceId(pIdx, idx), name, service, asString)),\n }));\n }\n\n manifest(asString: boolean = false): v2Manifest | v3Manifest {\n return this.version === \"beta2\" ? this.v2Manifest(asString) : this.v3Manifest(asString);\n }\n\n /**\n * Computes the endpoint sequence numbers for the given SDL.\n *\n * @param sdl - The SDL data.\n * @returns An object mapping IPs to their sequence numbers.\n *\n * @example\n * ```ts\n * const sequenceNumbers = sdl.computeEndpointSequenceNumbers(sdlData);\n * // sequenceNumbers might be { \"192.168.1.1\": 1, \"192.168.1.2\": 2 }\n * ```\n */\n computeEndpointSequenceNumbers(sdl: v2Sdl) {\n return Object.fromEntries(\n Object.values(sdl.services).flatMap((service) =>\n service.expose.flatMap((expose) =>\n expose.to\n ? expose.to\n .filter((to) => to.global && to.ip?.length > 0)\n .map((to) => to.ip)\n .sort()\n .map((ip, index) => [ip, index + 1])\n : [],\n ),\n ),\n );\n }\n\n resourceUnitCpu(computeResources: v2ComputeResources, asString: boolean) {\n const attributes = computeResources.cpu.attributes;\n const cpu = isString(computeResources.cpu.units) ? convertCpuResourceString(computeResources.cpu.units) : computeResources.cpu.units * 1000;\n\n return {\n units: { val: this.resourceValue(cpu, asString) },\n attributes:\n attributes\n && Object.entries(attributes)\n .sort(([k0], [k1]) => k0.localeCompare(k1))\n .map(([key, value]) => ({\n key: key,\n value: value.toString(),\n })),\n };\n }\n\n resourceUnitMemory(computeResources: v2ComputeResources, asString: boolean) {\n const attributes = computeResources.memory.attributes;\n\n return {\n quantity: {\n val: this.resourceValue(convertResourceString(computeResources.memory.size), asString),\n },\n attributes:\n attributes\n && Object.entries(attributes)\n .sort(([k0], [k1]) => k0.localeCompare(k1))\n .map(([key, value]) => ({\n key: key,\n value: value.toString(),\n })),\n };\n }\n\n resourceUnitStorage(computeResources: v2ComputeResources, asString: boolean) {\n const storages = isArray(computeResources.storage) ? computeResources.storage : [computeResources.storage];\n\n return storages.map((storage) => ({\n name: storage.name || \"default\",\n quantity: {\n val: this.resourceValue(convertResourceString(storage.size), asString),\n },\n attributes: this.serviceResourceStorageAttributes(storage.attributes),\n }));\n }\n\n transformGpuAttributes(attributes: v3GPUAttributes): Array<{ key: string; value: string }> {\n return Object.entries(attributes.vendor).flatMap(([vendor, models]) =>\n models\n ? models.map((model) => {\n let key = `vendor/${vendor}/model/${model.model}`;\n\n if (model.ram) {\n key += `/ram/${model.ram}`;\n }\n\n if (model.interface) {\n key += `/interface/${model.interface}`;\n }\n\n return {\n key: key,\n value: \"true\",\n };\n })\n : [\n {\n key: `vendor/${vendor}/model/*`,\n value: \"true\",\n },\n ],\n );\n }\n\n resourceUnitGpu(computeResources: v3ComputeResources, asString: boolean) {\n const attributes = computeResources.gpu?.attributes;\n const units = computeResources.gpu?.units || \"0\";\n const gpu = isString(units) ? parseInt(units) : units;\n\n return {\n units: { val: this.resourceValue(gpu, asString) },\n attributes: attributes && this.transformGpuAttributes(attributes),\n };\n }\n\n groupResourceUnits(resource: v2ComputeResources | undefined, asString: boolean) {\n if (!resource) return {};\n\n const units = {\n endpoints: null,\n } as any;\n\n if (resource.cpu) {\n units.cpu = this.resourceUnitCpu(resource, asString);\n }\n\n if (resource.memory) {\n units.memory = this.resourceUnitMemory(resource, asString);\n }\n\n if (resource.storage) {\n units.storage = this.resourceUnitStorage(resource, asString);\n }\n\n if (this.version === \"beta3\") {\n units.gpu = this.resourceUnitGpu(resource as v3ComputeResources, asString);\n }\n\n return units;\n }\n\n exposeShouldBeIngress(expose: { proto: string; global: boolean; externalPort: number; port: number }) {\n const externalPort = expose.externalPort === 0 ? expose.port : expose.externalPort;\n\n return expose.global && expose.proto === \"TCP\" && externalPort === 80;\n }\n\n groups() {\n return this.version === \"beta2\" ? this.v2Groups() : this.v3Groups();\n }\n\n v3Groups() {\n const groups = new Map<\n string,\n {\n dgroup: v3DeploymentGroup;\n boundComputes: Record<string, Record<string, number>>;\n }\n >();\n const services = Object.entries(this.data.services).sort(([a], [b]) => a.localeCompare(b));\n\n for (const [svcName, service] of services) {\n for (const [placementName, svcdepl] of Object.entries(this.data.deployment[svcName])) {\n // objects below have been ensured to exist\n const compute = this.data.profiles.compute[svcdepl.profile];\n const infra = this.data.profiles.placement[placementName];\n const pricing = infra.pricing[svcdepl.profile];\n const price = {\n ...pricing,\n amount: pricing.amount?.toString(),\n };\n\n let group = groups.get(placementName);\n\n if (!group) {\n const attributes = (infra.attributes\n ? Object.entries(infra.attributes).map(([key, value]) => ({\n key,\n value,\n }))\n : []) as unknown as Array<{ key: string; value: string }>;\n\n attributes.sort((a, b) => a.key.localeCompare(b.key));\n\n group = {\n dgroup: {\n name: placementName,\n resources: [],\n requirements: {\n attributes: attributes,\n signedBy: {\n allOf: infra.signedBy?.allOf || [],\n anyOf: infra.signedBy?.anyOf || [],\n },\n },\n },\n boundComputes: {},\n };\n\n groups.set(placementName, group);\n }\n\n if (!group.boundComputes[placementName]) {\n group.boundComputes[placementName] = {};\n }\n\n // const resources = this.serviceResourcesBeta3(0, compute as v3ProfileCompute, service, false);\n const location = group.boundComputes[placementName][svcdepl.profile];\n\n if (!location) {\n const res = this.groupResourceUnits(compute.resources, false);\n res.endpoints = this.v3ServiceResourceEndpoints(service);\n\n const resID = group.dgroup.resources.length > 0 ? group.dgroup.resources.length + 1 : 1;\n res.id = resID;\n // resources.id = res.id;\n\n group.dgroup.resources.push({\n resource: res,\n price: price,\n count: svcdepl.count,\n } as any);\n\n group.boundComputes[placementName][svcdepl.profile] = group.dgroup.resources.length - 1;\n } else {\n const endpoints = this.v3ServiceResourceEndpoints(service);\n // resources.id = group.dgroup.resources[location].id;\n\n group.dgroup.resources[location].count += svcdepl.count;\n group.dgroup.resources[location].endpoints += endpoints as any;\n group.dgroup.resources[location].endpoints.sort();\n }\n }\n }\n\n // keep ordering stable\n const names: string[] = [...groups.keys()].sort();\n return names.map((name) => groups.get(name)).map((group) => (group ? (group.dgroup as typeof group.dgroup) : {})) as Array<v3DeploymentGroup>;\n }\n\n v2Groups() {\n const yamlJson = this.data;\n const ipEndpointNames = this.computeEndpointSequenceNumbers(yamlJson);\n\n const groups = {} as any;\n\n Object.keys(yamlJson.services).forEach((svcName) => {\n const svc = yamlJson.services[svcName];\n const depl = yamlJson.deployment[svcName];\n\n Object.keys(depl).forEach((placementName) => {\n const svcdepl = depl[placementName];\n const compute = yamlJson.profiles.compute[svcdepl.profile];\n const infra = yamlJson.profiles.placement[placementName];\n\n const pricing = infra.pricing[svcdepl.profile];\n const price = {\n ...pricing,\n amount: pricing.amount.toString(),\n };\n\n let group = groups[placementName];\n\n if (!group) {\n group = {\n name: placementName,\n requirements: {\n attributes: infra.attributes\n ? Object.entries(infra.attributes).map(([key, value]) => ({\n key,\n value,\n }))\n : [],\n signedBy: {\n allOf: infra.signedBy?.allOf || [],\n anyOf: infra.signedBy?.anyOf || [],\n },\n },\n resources: [],\n };\n\n if (group.requirements.attributes) {\n group.requirements.attributes = group.requirements.attributes.sort((a: any, b: any) => a.key < b.key);\n }\n\n groups[group.name] = group;\n }\n\n const resources = {\n resources: this.groupResourceUnits(compute.resources, false), // Changed resources => unit\n price: price,\n count: svcdepl.count,\n };\n\n const endpoints = [] as any[];\n svc?.expose?.forEach((expose) => {\n expose?.to\n ?.filter((to) => to.global)\n .forEach((to) => {\n const exposeSpec = {\n port: expose.port,\n externalPort: expose.as || 0,\n proto: this.parseServiceProto(expose.proto),\n global: !!to.global,\n };\n\n if (to.ip?.length > 0) {\n const seqNo = ipEndpointNames[to.ip];\n endpoints.push({\n kind: Endpoint_LEASED_IP,\n sequence_number: seqNo,\n });\n }\n\n const kind = this.exposeShouldBeIngress(exposeSpec) ? Endpoint_SHARED_HTTP : Endpoint_RANDOM_PORT;\n\n endpoints.push({ kind: kind, sequence_number: 0 });\n });\n });\n\n resources.resources.endpoints = endpoints;\n group.resources.push(resources);\n });\n });\n\n return Object.keys(groups)\n .sort((a, b) => (a < b ? 1 : 0))\n .map((name) => groups[name]);\n }\n\n /**\n * Escapes HTML characters in a string.\n *\n * @param raw - The raw string to escape.\n * @returns The escaped string.\n *\n * @example\n * ```ts\n * const escaped = sdl.escapeHtml(\"<div>Hello</div>\");\n * // escaped is \"\\\\u003cdiv\\\\u003eHello\\\\u003c/div\\\\u003e\"\n * ```\n */\n #escapeHtml(raw: string) {\n return raw.replace(/</g, \"\\\\u003c\").replace(/>/g, \"\\\\u003e\").replace(/&/g, \"\\\\u0026\");\n }\n\n manifestSortedJSON() {\n const manifest = this.manifest(true);\n let jsonStr = JSON.stringify(manifest);\n\n if (jsonStr) {\n jsonStr = jsonStr.replaceAll(\"\\\"quantity\\\":{\\\"val\", \"\\\"size\\\":{\\\"val\");\n }\n\n return this.#escapeHtml(stableStringify(JSON.parse(jsonStr)) || \"\");\n }\n\n async manifestVersion() {\n const jsonStr = this.manifestSortedJSON();\n const enc = new TextEncoder();\n const sortedBytes = enc.encode(jsonStr);\n const sum = await crypto.subtle.digest(\"SHA-256\", sortedBytes);\n\n return new Uint8Array(sum);\n }\n\n manifestSorted() {\n const sorted = this.manifestSortedJSON();\n return JSON.parse(sorted);\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,qBAAiB;AACjB,mCAA2C;AAE3C,oBAA2B;AAE3B,mBAAgE;AAgChE,yBAA4B;AAC5B,gCAAmC;AAvCnC;AAyCA,MAAM,uBAAuB;AAC7B,MAAM,uBAAuB;AAC7B,MAAM,qBAAqB;AAE3B,SAAS,QAAW,KAA2B;AAC7C,SAAO,MAAM,QAAQ,GAAG;AAC1B;AAEA,SAAS,SAAS,KAAyB;AACzC,SAAO,OAAO,QAAQ;AACxB;AAoCO,MAAM,OAAN,MAAM,KAAI;AAAA,EA8Bf,YACkB,MACA,UAA0B,SAC1C,YAA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,IAAI,QAAQ,MAAM,SAAS,EAAE,QAAQ,MAAM,SAAS,EAAE,QAAQ,MAAM,SAAS;AACtF;AAn0BK,IAAM,MAAN;",
|
|
4
|
+
"sourcesContent": ["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport YAML from \"js-yaml\";\nimport { default as stableStringify } from \"json-stable-stringify\";\n\nimport { MAINNET_ID } from \"../../network/config.ts\";\nimport type { NetworkId } from \"../../network/types.ts\";\nimport { convertCpuResourceString, convertResourceString } from \"../sizes.ts\";\nimport type {\n v2ComputeResources,\n v2Expose,\n v2ExposeTo,\n v2HTTPOptions,\n v2Manifest,\n v2ManifestService,\n v2ManifestServiceParams,\n v2ProfileCompute,\n v2ResourceCPU,\n v2ResourceMemory,\n v2ResourceStorage,\n v2ResourceStorageArray,\n v2Sdl,\n v2Service,\n v2ServiceExpose,\n v2ServiceExposeHttpOptions,\n v2ServiceParams,\n v2StorageAttributes,\n v3ComputeResources,\n v3DeploymentGroup,\n v3GPUAttributes,\n v3Manifest,\n v3ManifestService,\n v3ManifestServiceParams,\n v3ProfileCompute,\n v3ResourceGPU,\n v3Sdl,\n v3ServiceExpose,\n v3ServiceExposeHttpOptions } from \"../types.ts\";\nimport type { SDLInput } from \"../validateSDL/validateSDL.ts\";\nimport { validateSDL } from \"../validateSDL/validateSDL.ts\";\nimport { SdlValidationError } from \"./SdlValidationError.ts\";\n\nconst Endpoint_SHARED_HTTP = 0;\nconst Endpoint_RANDOM_PORT = 1;\nconst Endpoint_LEASED_IP = 2;\n\nfunction isArray<T>(obj: any): obj is Array<T> {\n return Array.isArray(obj);\n}\n\nfunction isString(str: any): str is string {\n return typeof str === \"string\";\n}\n\ntype NetworkVersion = \"beta2\" | \"beta3\";\n\n/**\n * SDL (Stack Definition Language) parser and validator\n * Handles parsing and validation of Akash deployment manifests\n *\n * @deprecated Use `generateManifest` instead.\n *\n * @example\n * ```ts\n * import { SDL } from './SDL';\n *\n * const yaml = `\n * version: \"2.0\"\n * services:\n * web:\n * image: nginx\n * expose:\n * - port: 80\n * as: 80\n * to:\n * - global: true\n * `;\n *\n * // Parse SDL from YAML string\n * const sdl = SDL.fromString(yaml);\n *\n * // Get deployment manifest\n * const manifest = sdl.manifest();\n *\n * // Get deployment groups\n * const groups = sdl.groups();\n * ```\n */\nexport class SDL {\n /**\n * Creates an SDL instance from a YAML string.\n *\n * @param {string} yaml - The YAML string containing the SDL definition.\n * @param {NetworkVersion} [version=\"beta3\"] - The SDL version (beta2 or beta3).\n * @param {NetworkId} [networkId=MAINNET_ID] - The network ID to validate against.\n * @returns {SDL} An instance of the SDL class.\n *\n * @example\n * ```ts\n * const yaml = `\n * version: \"2.0\"\n * services:\n * web:\n * image: nginx\n * expose:\n * - port: 80\n * as: 80\n * to:\n * - global: true\n * `;\n * const sdl = SDL.fromString(yaml);\n * ```\n */\n static fromString(yaml: string, version: NetworkVersion = \"beta3\", networkId: NetworkId = MAINNET_ID): SDL {\n const data = YAML.load(yaml) as v3Sdl;\n return new SDL(data, version, networkId);\n }\n\n constructor(\n public readonly data: v2Sdl,\n public readonly version: NetworkVersion = \"beta2\",\n networkId: NetworkId = MAINNET_ID,\n ) {\n const errors = validateSDL(data as unknown as SDLInput, networkId);\n if (errors) throw new SdlValidationError(errors[0].message);\n }\n\n services() {\n if (this.data) {\n return this.data.services;\n }\n\n return {};\n }\n\n deployments() {\n if (this.data) {\n return this.data.deployment;\n }\n\n return {};\n }\n\n profiles() {\n if (this.data) {\n return this.data.profiles;\n }\n\n return {};\n }\n\n placements() {\n const { placement } = this.data.profiles;\n\n return placement || {};\n }\n\n serviceNames() {\n const names = this.data ? Object.keys(this.data.services) : [];\n\n // TODO: sort these\n return names;\n }\n\n deploymentsByPlacement(placement: string) {\n const deployments = this.data ? this.data.deployment : [];\n\n return Object.entries(deployments as object).filter(({ 1: deployment }) => Object.prototype.hasOwnProperty.call(deployment, placement));\n }\n\n resourceUnit(val: string, asString: boolean) {\n return asString ? { val: `${convertResourceString(val)}` } : { val: convertResourceString(val) };\n }\n\n resourceValue(value: { toString: () => string } | null, asString: boolean) {\n if (value === null) {\n return value;\n }\n\n const strVal = value.toString();\n const encoder = new TextEncoder();\n\n return asString ? strVal : encoder.encode(strVal);\n }\n\n serviceResourceCpu(resource: v2ResourceCPU) {\n const units = isString(resource.units) ? convertCpuResourceString(resource.units) : resource.units * 1000;\n\n return resource.attributes\n ? {\n units: { val: `${units}` },\n attributes: this.serviceResourceAttributes(resource.attributes),\n }\n : {\n units: { val: `${units}` },\n };\n }\n\n serviceResourceMemory(resource: v2ResourceMemory, asString: boolean) {\n const key = asString ? \"quantity\" : \"size\";\n\n return resource.attributes\n ? {\n [key]: this.resourceUnit(resource.size, asString),\n attributes: this.serviceResourceAttributes(resource.attributes),\n }\n : {\n [key]: this.resourceUnit(resource.size, asString),\n };\n }\n\n serviceResourceStorage(resource: v2ResourceStorageArray | v2ResourceStorage, asString: boolean) {\n const key = asString ? \"quantity\" : \"size\";\n const storage = isArray(resource) ? resource : [resource];\n\n return storage.map((storage) =>\n storage.attributes\n ? {\n name: storage.name || \"default\",\n [key]: this.resourceUnit(storage.size, asString),\n attributes: this.serviceResourceStorageAttributes(storage.attributes),\n }\n : {\n name: storage.name || \"default\",\n [key]: this.resourceUnit(storage.size, asString),\n },\n );\n }\n\n serviceResourceAttributes(attributes?: Record<string, any>) {\n return (\n attributes\n && Object.keys(attributes)\n .sort()\n .map((key) => ({ key, value: attributes[key].toString() }))\n );\n }\n\n serviceResourceStorageAttributes(attributes?: v2StorageAttributes) {\n if (!attributes) return undefined;\n\n const pairs = Object.keys(attributes).map((key) => ({ key, value: attributes[key].toString() }));\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\n return pairs;\n }\n\n serviceResourceGpu(resource: v3ResourceGPU | undefined, asString: boolean) {\n const value = resource?.units || 0;\n const numVal = isString(value) ? Buffer.from(value, \"ascii\") : value;\n const strVal = !isString(value) ? value.toString() : value;\n\n return resource?.attributes\n ? {\n units: asString ? { val: strVal } : { val: numVal },\n attributes: this.transformGpuAttributes(resource?.attributes),\n }\n : {\n units: asString ? { val: strVal } : { val: numVal },\n };\n }\n\n v2ServiceResourceEndpoints(service: v2Service) {\n const endpointSequenceNumbers = this.computeEndpointSequenceNumbers(this.data);\n const endpoints = service.expose.flatMap((expose) =>\n expose.to\n ? expose.to\n .filter((to) => to.global && to.ip?.length > 0)\n .map((to) => ({\n kind: Endpoint_LEASED_IP,\n sequence_number: endpointSequenceNumbers[to.ip] || 0,\n }))\n : [],\n );\n\n return endpoints.length > 0 ? endpoints : null;\n }\n\n v3ServiceResourceEndpoints(service: v2Service) {\n const endpointSequenceNumbers = this.computeEndpointSequenceNumbers(this.data);\n const endpoints = service.expose.flatMap((expose) =>\n expose.to\n ? expose.to\n .filter((to) => to.global)\n .flatMap((to) => {\n const exposeSpec = {\n port: expose.port,\n externalPort: expose.as || 0,\n proto: this.parseServiceProto(expose.proto),\n global: !!to.global,\n };\n\n const kind = this.exposeShouldBeIngress(exposeSpec) ? Endpoint_SHARED_HTTP : Endpoint_RANDOM_PORT;\n\n const defaultEp = kind !== 0 ? { kind: kind, sequence_number: 0 } : { sequence_number: 0 };\n\n const leasedEp\n = to.ip?.length > 0\n ? {\n kind: Endpoint_LEASED_IP,\n sequence_number: endpointSequenceNumbers[to.ip] || 0,\n }\n : undefined;\n\n return leasedEp ? [defaultEp, leasedEp] : [defaultEp];\n })\n : [],\n );\n\n return endpoints;\n }\n\n serviceResourcesBeta2(profile: v2ProfileCompute, service: v2Service, asString: boolean = false) {\n return {\n cpu: this.serviceResourceCpu(profile.resources.cpu),\n memory: this.serviceResourceMemory(profile.resources.memory, asString),\n storage: this.serviceResourceStorage(profile.resources.storage, asString),\n endpoints: this.v2ServiceResourceEndpoints(service),\n };\n }\n\n serviceResourcesBeta3(id: number, profile: v3ProfileCompute, service: v2Service, asString: boolean = false) {\n return {\n id: id,\n cpu: this.serviceResourceCpu(profile.resources.cpu),\n memory: this.serviceResourceMemory(profile.resources.memory, asString),\n storage: this.serviceResourceStorage(profile.resources.storage, asString),\n gpu: this.serviceResourceGpu(profile.resources.gpu, asString),\n endpoints: this.v3ServiceResourceEndpoints(service),\n };\n }\n\n /**\n * Parses the service protocol.\n *\n * @param proto - The protocol string (e.g., \"TCP\", \"UDP\").\n * @returns The parsed protocol.\n * @throws Will throw an error if the protocol is unsupported.\n *\n * @example\n * ```ts\n * const protocol = SDL.parseServiceProto(\"TCP\");\n * // protocol is \"TCP\"\n * ```\n */\n parseServiceProto(proto?: string): string {\n const raw = proto?.toUpperCase() || \"TCP\";\n if (raw === \"TCP\" || raw === \"UDP\") return raw;\n\n throw new SdlValidationError(`Unsupported service protocol: \"${proto}\". Supported protocols are \"TCP\" and \"UDP\".`);\n }\n\n manifestExposeService(to: v2ExposeTo) {\n return to.service || \"\";\n }\n\n manifestExposeGlobal(to: v2ExposeTo) {\n return to.global || false;\n }\n\n manifestExposeHosts(expose: v2Expose) {\n return expose.accept || null;\n }\n\n v2HttpOptions(http_options: v2HTTPOptions | undefined) {\n const defaults = {\n MaxBodySize: 1048576,\n ReadTimeout: 60000,\n SendTimeout: 60000,\n NextTries: 3,\n NextTimeout: 0,\n NextCases: [\"error\", \"timeout\"],\n };\n\n if (!http_options) {\n return { ...defaults };\n }\n\n return {\n MaxBodySize: http_options.max_body_size || defaults.MaxBodySize,\n ReadTimeout: http_options.read_timeout || defaults.ReadTimeout,\n SendTimeout: http_options.send_timeout || defaults.SendTimeout,\n NextTries: http_options.next_tries || defaults.NextTries,\n NextTimeout: http_options.next_timeout || defaults.NextTimeout,\n NextCases: http_options.next_cases || defaults.NextCases,\n };\n }\n\n v3HttpOptions(http_options: v2HTTPOptions | undefined) {\n const defaults = {\n maxBodySize: 1048576,\n readTimeout: 60000,\n sendTimeout: 60000,\n nextTries: 3,\n nextTimeout: 0,\n nextCases: [\"error\", \"timeout\"],\n };\n\n if (!http_options) {\n return { ...defaults };\n }\n\n return {\n maxBodySize: http_options.max_body_size || defaults.maxBodySize,\n readTimeout: http_options.read_timeout || defaults.readTimeout,\n sendTimeout: http_options.send_timeout || defaults.sendTimeout,\n nextTries: http_options.next_tries || defaults.nextTries,\n nextTimeout: http_options.next_timeout || defaults.nextTimeout,\n nextCases: http_options.next_cases || defaults.nextCases,\n };\n }\n\n v2ManifestExposeHttpOptions(expose: v2Expose): v2ServiceExposeHttpOptions {\n return this.v2HttpOptions(expose.http_options);\n }\n\n v3ManifestExposeHttpOptions(expose: v2Expose): v3ServiceExposeHttpOptions {\n return this.v3HttpOptions(expose.http_options);\n }\n\n v2ManifestExpose(service: v2Service): v2ServiceExpose[] {\n const endpointSequenceNumbers = this.computeEndpointSequenceNumbers(this.data);\n return service.expose.flatMap((expose) =>\n expose.to\n ? expose.to.map((to) => ({\n Port: expose.port,\n ExternalPort: expose.as || 0,\n Proto: this.parseServiceProto(expose.proto),\n Service: this.manifestExposeService(to),\n Global: this.manifestExposeGlobal(to),\n Hosts: this.manifestExposeHosts(expose),\n HTTPOptions: this.v2ManifestExposeHttpOptions(expose),\n IP: to.ip || \"\",\n EndpointSequenceNumber: endpointSequenceNumbers[to.ip] || 0,\n }))\n : [],\n );\n }\n\n v3ManifestExpose(service: v2Service): v3ServiceExpose[] {\n const endpointSequenceNumbers = this.computeEndpointSequenceNumbers(this.data);\n return service.expose\n .flatMap((expose) =>\n expose.to\n ? expose.to.map((to) => ({\n port: expose.port,\n externalPort: expose.as || 0,\n proto: this.parseServiceProto(expose.proto),\n service: this.manifestExposeService(to),\n global: this.manifestExposeGlobal(to),\n hosts: this.manifestExposeHosts(expose),\n httpOptions: this.v3ManifestExposeHttpOptions(expose),\n ip: to.ip || \"\",\n endpointSequenceNumber: endpointSequenceNumbers[to.ip] || 0,\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\n return 0;\n });\n }\n\n v2ManifestServiceParams(params: v2ServiceParams): v2ManifestServiceParams | undefined {\n return {\n Storage: Object.keys(params?.storage ?? {}).map((name) => {\n if (!params?.storage) throw new Error(\"Storage is undefined\");\n return {\n name: name,\n mount: params.storage[name].mount,\n readOnly: params.storage[name].readOnly || false,\n };\n }),\n ...(params?.permissions ? { Permissions: params.permissions } : {}),\n };\n }\n\n v3ManifestServiceParams(params: v2ServiceParams | undefined): v3ManifestServiceParams | null {\n if (params === undefined || Object.keys(params).length === 0) {\n return null;\n }\n\n const res: v3ManifestServiceParams = {\n storage:\n params.storage && Object.keys(params.storage).length > 0\n ? Object.keys(params.storage).map((name) => ({\n name: name,\n mount: params.storage![name]?.mount,\n readOnly: params.storage![name]?.readOnly || false,\n }))\n : null,\n };\n\n if (params.permissions) {\n res.permissions = params.permissions;\n }\n\n return res;\n }\n\n v2ManifestService(placement: string, name: string, asString: boolean): v2ManifestService {\n const service = this.data.services[name];\n const deployment = this.data.deployment[name];\n const profile = this.data.profiles.compute[deployment[placement].profile];\n\n const manifestService: v2ManifestService = {\n Name: name,\n Image: service.image,\n Command: service.command || null,\n Args: service.args || null,\n Env: service.env || null,\n Resources: this.serviceResourcesBeta2(profile, service, asString),\n Count: deployment[placement].count,\n Expose: this.v2ManifestExpose(service),\n };\n\n if (service.params) {\n manifestService.params = this.v2ManifestServiceParams(service.params);\n }\n\n return manifestService;\n }\n\n v3ManifestService(id: number, placement: string, name: string, asString: boolean): v3ManifestService {\n const service = this.data.services[name];\n const deployment = this.data.deployment[name];\n const profile = this.data.profiles.compute[deployment[placement].profile];\n const credentials = service.credentials || null;\n\n if (credentials && !credentials.email) {\n credentials.email = \"\";\n }\n\n const manifestService: v3ManifestService = {\n name: name,\n image: service.image,\n command: service.command || null,\n args: service.args || null,\n env: service.env || null,\n resources: this.serviceResourcesBeta3(id, profile as v3ProfileCompute, service, asString),\n count: deployment[placement].count,\n expose: this.v3ManifestExpose(service),\n params: this.v3ManifestServiceParams(service.params),\n credentials,\n };\n\n if (!manifestService.params) {\n delete manifestService.params;\n }\n\n return manifestService;\n }\n\n v2Manifest(asString: boolean = false): v2Manifest {\n return Object.keys(this.placements()).map((name) => ({\n Name: name,\n Services: this.deploymentsByPlacement(name).map(([service]) => this.v2ManifestService(name, service, asString)),\n }));\n }\n\n v3Manifest(asString: boolean = false): v3Manifest {\n const groups = this.v3Groups();\n const serviceId = (pIdx: number, sIdx: number) => groups[pIdx].resources[sIdx].resource.id;\n\n return Object.keys(this.placements()).map((name, pIdx) => ({\n name: name,\n services: this.deploymentsByPlacement(name)\n .sort(([a], [b]) => a.localeCompare(b))\n .map(([service], idx) => this.v3ManifestService(serviceId(pIdx, idx), name, service, asString)),\n }));\n }\n\n manifest(asString: boolean = false): v2Manifest | v3Manifest {\n return this.version === \"beta2\" ? this.v2Manifest(asString) : this.v3Manifest(asString);\n }\n\n /**\n * Computes the endpoint sequence numbers for the given SDL.\n *\n * @param sdl - The SDL data.\n * @returns An object mapping IPs to their sequence numbers.\n *\n * @example\n * ```ts\n * const sequenceNumbers = sdl.computeEndpointSequenceNumbers(sdlData);\n * // sequenceNumbers might be { \"192.168.1.1\": 1, \"192.168.1.2\": 2 }\n * ```\n */\n computeEndpointSequenceNumbers(sdl: v2Sdl) {\n return Object.fromEntries(\n Object.values(sdl.services).flatMap((service) =>\n service.expose.flatMap((expose) =>\n expose.to\n ? expose.to\n .filter((to) => to.global && to.ip?.length > 0)\n .map((to) => to.ip)\n .sort()\n .map((ip, index) => [ip, index + 1])\n : [],\n ),\n ),\n );\n }\n\n resourceUnitCpu(computeResources: v2ComputeResources, asString: boolean) {\n const attributes = computeResources.cpu.attributes;\n const cpu = isString(computeResources.cpu.units) ? convertCpuResourceString(computeResources.cpu.units) : computeResources.cpu.units * 1000;\n\n return {\n units: { val: this.resourceValue(cpu, asString) },\n attributes:\n attributes\n && Object.entries(attributes)\n .sort(([k0], [k1]) => k0.localeCompare(k1))\n .map(([key, value]) => ({\n key: key,\n value: value.toString(),\n })),\n };\n }\n\n resourceUnitMemory(computeResources: v2ComputeResources, asString: boolean) {\n const attributes = computeResources.memory.attributes;\n\n return {\n quantity: {\n val: this.resourceValue(convertResourceString(computeResources.memory.size), asString),\n },\n attributes:\n attributes\n && Object.entries(attributes)\n .sort(([k0], [k1]) => k0.localeCompare(k1))\n .map(([key, value]) => ({\n key: key,\n value: value.toString(),\n })),\n };\n }\n\n resourceUnitStorage(computeResources: v2ComputeResources, asString: boolean) {\n const storages = isArray(computeResources.storage) ? computeResources.storage : [computeResources.storage];\n\n return storages.map((storage) => ({\n name: storage.name || \"default\",\n quantity: {\n val: this.resourceValue(convertResourceString(storage.size), asString),\n },\n attributes: this.serviceResourceStorageAttributes(storage.attributes),\n }));\n }\n\n transformGpuAttributes(attributes: v3GPUAttributes): Array<{ key: string; value: string }> {\n return Object.entries(attributes.vendor).flatMap(([vendor, models]) =>\n models\n ? models.map((model) => {\n let key = `vendor/${vendor}/model/${model.model}`;\n\n if (model.ram) {\n key += `/ram/${model.ram}`;\n }\n\n if (model.interface) {\n key += `/interface/${model.interface}`;\n }\n\n return {\n key: key,\n value: \"true\",\n };\n })\n : [\n {\n key: `vendor/${vendor}/model/*`,\n value: \"true\",\n },\n ],\n );\n }\n\n resourceUnitGpu(computeResources: v3ComputeResources, asString: boolean) {\n const attributes = computeResources.gpu?.attributes;\n const units = computeResources.gpu?.units || \"0\";\n const gpu = isString(units) ? parseInt(units) : units;\n\n return {\n units: { val: this.resourceValue(gpu, asString) },\n attributes: attributes && this.transformGpuAttributes(attributes),\n };\n }\n\n groupResourceUnits(resource: v2ComputeResources | undefined, asString: boolean) {\n if (!resource) return {};\n\n const units = {\n endpoints: null,\n } as any;\n\n if (resource.cpu) {\n units.cpu = this.resourceUnitCpu(resource, asString);\n }\n\n if (resource.memory) {\n units.memory = this.resourceUnitMemory(resource, asString);\n }\n\n if (resource.storage) {\n units.storage = this.resourceUnitStorage(resource, asString);\n }\n\n if (this.version === \"beta3\") {\n units.gpu = this.resourceUnitGpu(resource as v3ComputeResources, asString);\n }\n\n return units;\n }\n\n exposeShouldBeIngress(expose: { proto: string; global: boolean; externalPort: number; port: number }) {\n const externalPort = expose.externalPort === 0 ? expose.port : expose.externalPort;\n\n return expose.global && expose.proto === \"TCP\" && externalPort === 80;\n }\n\n groups() {\n return this.version === \"beta2\" ? this.v2Groups() : this.v3Groups();\n }\n\n v3Groups() {\n const groups = new Map<\n string,\n {\n dgroup: v3DeploymentGroup;\n boundComputes: Record<string, Record<string, number>>;\n }\n >();\n const services = Object.entries(this.data.services).sort(([a], [b]) => a.localeCompare(b));\n\n for (const [svcName, service] of services) {\n for (const [placementName, svcdepl] of Object.entries(this.data.deployment[svcName])) {\n // objects below have been ensured to exist\n const compute = this.data.profiles.compute[svcdepl.profile];\n const infra = this.data.profiles.placement[placementName];\n const pricing = infra.pricing[svcdepl.profile];\n const price = {\n ...pricing,\n amount: pricing.amount?.toString(),\n };\n\n let group = groups.get(placementName);\n\n if (!group) {\n const attributes = (infra.attributes\n ? Object.entries(infra.attributes).map(([key, value]) => ({\n key,\n value,\n }))\n : []) as unknown as Array<{ key: string; value: string }>;\n\n attributes.sort((a, b) => a.key.localeCompare(b.key));\n\n group = {\n dgroup: {\n name: placementName,\n resources: [],\n requirements: {\n attributes: attributes,\n signedBy: {\n allOf: infra.signedBy?.allOf || [],\n anyOf: infra.signedBy?.anyOf || [],\n },\n },\n },\n boundComputes: {},\n };\n\n groups.set(placementName, group);\n }\n\n if (!group.boundComputes[placementName]) {\n group.boundComputes[placementName] = {};\n }\n\n // const resources = this.serviceResourcesBeta3(0, compute as v3ProfileCompute, service, false);\n const location = group.boundComputes[placementName][svcdepl.profile];\n\n if (!location) {\n const res = this.groupResourceUnits(compute.resources, false);\n res.endpoints = this.v3ServiceResourceEndpoints(service);\n\n const resID = group.dgroup.resources.length > 0 ? group.dgroup.resources.length + 1 : 1;\n res.id = resID;\n // resources.id = res.id;\n\n group.dgroup.resources.push({\n resource: res,\n price: price,\n count: svcdepl.count,\n } as any);\n\n group.boundComputes[placementName][svcdepl.profile] = group.dgroup.resources.length - 1;\n } else {\n const endpoints = this.v3ServiceResourceEndpoints(service);\n // resources.id = group.dgroup.resources[location].id;\n\n group.dgroup.resources[location].count += svcdepl.count;\n group.dgroup.resources[location].endpoints += endpoints as any;\n group.dgroup.resources[location].endpoints.sort();\n }\n }\n }\n\n // keep ordering stable\n const names: string[] = [...groups.keys()].sort();\n return names.map((name) => groups.get(name)).map((group) => (group ? (group.dgroup as typeof group.dgroup) : {})) as Array<v3DeploymentGroup>;\n }\n\n v2Groups() {\n const yamlJson = this.data;\n const ipEndpointNames = this.computeEndpointSequenceNumbers(yamlJson);\n\n const groups = {} as any;\n\n Object.keys(yamlJson.services).forEach((svcName) => {\n const svc = yamlJson.services[svcName];\n const depl = yamlJson.deployment[svcName];\n\n Object.keys(depl).forEach((placementName) => {\n const svcdepl = depl[placementName];\n const compute = yamlJson.profiles.compute[svcdepl.profile];\n const infra = yamlJson.profiles.placement[placementName];\n\n const pricing = infra.pricing[svcdepl.profile];\n const price = {\n ...pricing,\n amount: pricing.amount.toString(),\n };\n\n let group = groups[placementName];\n\n if (!group) {\n group = {\n name: placementName,\n requirements: {\n attributes: infra.attributes\n ? Object.entries(infra.attributes).map(([key, value]) => ({\n key,\n value,\n }))\n : [],\n signedBy: {\n allOf: infra.signedBy?.allOf || [],\n anyOf: infra.signedBy?.anyOf || [],\n },\n },\n resources: [],\n };\n\n if (group.requirements.attributes) {\n group.requirements.attributes = group.requirements.attributes.sort((a: any, b: any) => a.key < b.key);\n }\n\n groups[group.name] = group;\n }\n\n const resources = {\n resources: this.groupResourceUnits(compute.resources, false), // Changed resources => unit\n price: price,\n count: svcdepl.count,\n };\n\n const endpoints = [] as any[];\n svc?.expose?.forEach((expose) => {\n expose?.to\n ?.filter((to) => to.global)\n .forEach((to) => {\n const exposeSpec = {\n port: expose.port,\n externalPort: expose.as || 0,\n proto: this.parseServiceProto(expose.proto),\n global: !!to.global,\n };\n\n if (to.ip?.length > 0) {\n const seqNo = ipEndpointNames[to.ip];\n endpoints.push({\n kind: Endpoint_LEASED_IP,\n sequence_number: seqNo,\n });\n }\n\n const kind = this.exposeShouldBeIngress(exposeSpec) ? Endpoint_SHARED_HTTP : Endpoint_RANDOM_PORT;\n\n endpoints.push({ kind: kind, sequence_number: 0 });\n });\n });\n\n resources.resources.endpoints = endpoints;\n group.resources.push(resources);\n });\n });\n\n return Object.keys(groups)\n .sort((a, b) => (a < b ? 1 : 0))\n .map((name) => groups[name]);\n }\n\n /**\n * Escapes HTML characters in a string.\n *\n * @param raw - The raw string to escape.\n * @returns The escaped string.\n *\n * @example\n * ```ts\n * const escaped = sdl.escapeHtml(\"<div>Hello</div>\");\n * // escaped is \"\\\\u003cdiv\\\\u003eHello\\\\u003c/div\\\\u003e\"\n * ```\n */\n #escapeHtml(raw: string) {\n return raw.replace(/</g, \"\\\\u003c\").replace(/>/g, \"\\\\u003e\").replace(/&/g, \"\\\\u0026\");\n }\n\n manifestSortedJSON() {\n const manifest = this.manifest(true);\n let jsonStr = JSON.stringify(manifest);\n\n if (jsonStr) {\n jsonStr = jsonStr.replaceAll(\"\\\"quantity\\\":{\\\"val\", \"\\\"size\\\":{\\\"val\");\n }\n\n return this.#escapeHtml(stableStringify(JSON.parse(jsonStr)) || \"\");\n }\n\n async manifestVersion() {\n const jsonStr = this.manifestSortedJSON();\n const enc = new TextEncoder();\n const sortedBytes = enc.encode(jsonStr);\n const sum = await crypto.subtle.digest(\"SHA-256\", sortedBytes);\n\n return new Uint8Array(sum);\n }\n\n manifestSorted() {\n const sorted = this.manifestSortedJSON();\n return JSON.parse(sorted);\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,qBAAiB;AACjB,mCAA2C;AAE3C,oBA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,IAAI,OAAO,OAAO;AACtC,UAAM,MAAM,MAAM,OAAO,OAAO,OAAO,WAAW,WAAW;AAE7D,WAAO,IAAI,WAAW,GAAG;AAAA,EAC3B;AAAA,EAEA,iBAAiB;AACf,UAAM,SAAS,KAAK,mBAAmB;AACvC,WAAO,KAAK,MAAM,MAAM;AAAA,EAC1B;AACF;AAl2BO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAs0BL,gBAAW,SAAC,KAAa;AACvB,SAAO,IAAI,QAAQ,MAAM,SAAS,EAAE,QAAQ,MAAM,SAAS,EAAE,QAAQ,MAAM,SAAS;AACtF;AAx0BK,IAAM,MAAN;",
|
|
6
6
|
"names": ["YAML", "storage", "stableStringify"]
|
|
7
7
|
}
|
|
@@ -73,7 +73,7 @@ function generateManifest(sdl, networkId = import_config.MAINNET_ID) {
|
|
|
73
73
|
name: placementName,
|
|
74
74
|
resources: [],
|
|
75
75
|
requirements: import_attribute.PlacementRequirements.fromPartial({
|
|
76
|
-
attributes: (0, import_manifestUtils.buildResourceAttributes)(infra.attributes)
|
|
76
|
+
attributes: (0, import_manifestUtils.buildResourceAttributes)(infra.attributes),
|
|
77
77
|
signedBy: import_attribute.SignedBy.fromPartial({
|
|
78
78
|
allOf: infra.signedBy?.allOf,
|
|
79
79
|
anyOf: infra.signedBy?.anyOf
|
|
@@ -200,15 +200,17 @@ function buildManifestService(resourceId, name, service, compute, count, endpoin
|
|
|
200
200
|
}
|
|
201
201
|
function buildParams(service) {
|
|
202
202
|
if (!service.params) return void 0;
|
|
203
|
-
const
|
|
203
|
+
const storage = service.params.storage || {};
|
|
204
|
+
const storageNames = service.params.storage ? Object.keys(storage).sort() : [];
|
|
204
205
|
const result = import_service.ServiceParams.fromPartial({
|
|
205
|
-
storage:
|
|
206
|
-
|
|
206
|
+
storage: storageNames.map((name) => {
|
|
207
|
+
const config = storage[name];
|
|
208
|
+
return import_service.StorageParams.fromPartial({
|
|
207
209
|
name,
|
|
208
210
|
mount: config.mount || "",
|
|
209
211
|
readOnly: config.readOnly || false
|
|
210
|
-
})
|
|
211
|
-
)
|
|
212
|
+
});
|
|
213
|
+
})
|
|
212
214
|
});
|
|
213
215
|
if (service.params.permissions) {
|
|
214
216
|
result.permissions = service.params.permissions;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
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,UAAU,KAAK,OAAO,QAAQ,IAAI,UAAU,GAAG;AAClE,eAAW,CAAC,eAAe,UAAU,KAAK,OAAO,QAAQ,UAAU,GAAG;AACpE,UAAI,OAAO,uBAAuB,IAAI,aAAa;AACnD,UAAI,CAAC,MAAM;AACT,eAAO,CAAC;AACR,+BAAuB,IAAI,eAAe,IAAI;AAAA,MAChD;AACA,WAAK,KAAK,CAAC,SAAS,UAAU,CAAC;AAAA,IACjC;AAAA,EACF;AACA,aAAW,QAAQ,uBAAuB,OAAO,GAAG;AAClD,SAAK,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;AAAA,EAC5C;AAEA,QAAM,WAAW,OAAO,QAAQ,IAAI,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;AAEnF,aAAW,CAAC,SAAS,OAAO,KAAK,UAAU;AACzC,eAAW,CAAC,eAAe,OAAO,KAAK,OAAO,QAAQ,IAAI,WAAW,OAAO,CAAC,GAAG;AAC9E,YAAM,UAAU,IAAI,SAAS,QAAQ,QAAQ,OAAO;AACpD,YAAM,QAAQ,IAAI,SAAS,UAAU,aAAa;AAClD,YAAM,UAAU,MAAM,QAAQ,QAAQ,OAAO;AAC7C,YAAM,QAAQ;AAAA,QACZ,OAAO,QAAQ;AAAA,QACf,QAAQ,QAAQ,QAAQ,SAAS;AAAA,MACnC;AAEA,UAAI,QAAQ,UAAU,IAAI,aAAa;AAEvC,UAAI,CAAC,OAAO;AACV,gBAAQ;AAAA,UACN,QAAQ,2BAAU,YAAY;AAAA,YAC5B,MAAM;AAAA,YACN,WAAW,CAAC;AAAA,YACZ,cAAc,uCAAsB,YAAY;AAAA,cAC9C,gBAAY,8CAAwB,MAAM,UAAU
|
|
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 GenerateManifestOkResult {\n groups: Group[];\n groupSpecs: GroupSpec[];\n}\n\nexport type Manifest = GenerateManifestOkResult[\"groups\"];\nexport type GenerateManifestResult =\n | { ok?: false; value: ValidationError[] }\n | { ok: true; value: GenerateManifestOkResult };\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 storage = service.params.storage || {};\n const storageNames = service.params.storage ? Object.keys(storage).sort() : [];\n const result = ServiceParams.fromPartial({\n storage: storageNames.map((name) => {\n const config = storage[name];\n return 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,UAAU,KAAK,OAAO,QAAQ,IAAI,UAAU,GAAG;AAClE,eAAW,CAAC,eAAe,UAAU,KAAK,OAAO,QAAQ,UAAU,GAAG;AACpE,UAAI,OAAO,uBAAuB,IAAI,aAAa;AACnD,UAAI,CAAC,MAAM;AACT,eAAO,CAAC;AACR,+BAAuB,IAAI,eAAe,IAAI;AAAA,MAChD;AACA,WAAK,KAAK,CAAC,SAAS,UAAU,CAAC;AAAA,IACjC;AAAA,EACF;AACA,aAAW,QAAQ,uBAAuB,OAAO,GAAG;AAClD,SAAK,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;AAAA,EAC5C;AAEA,QAAM,WAAW,OAAO,QAAQ,IAAI,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,EAA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Ac,YAAY;AAAA,QACxB,MAAM,OAAO;AAAA,QACb,cAAc,OAAO;AAAA,QACrB,WAAO,wCAAkB,OAAO,KAAK;AAAA,QACrC,SAAS,GAAG,WAAW;AAAA,QACvB,QAAQ,GAAG,UAAU;AAAA,QACrB,OAAO,OAAO,UAAU,CAAC;AAAA,QACzB,iBAAa,uCAAiB,OAAO,YAAY;AAAA,QACjD,IAAI,GAAG,MAAM;AAAA,QACb,wBAAwB,wBAAwB,GAAG,EAAG;AAAA,MACxD,CAAC;AAAA,IACH;AAAA,EACF,EACC,KAAK,CAAC,GAAG,MAAM;AACd,QAAI,EAAE,YAAY,EAAE,QAAS,QAAO,EAAE,QAAQ,cAAc,EAAE,OAAO;AACrE,QAAI,EAAE,SAAS,EAAE,KAAM,QAAO,EAAE,OAAO,EAAE;AACzC,QAAI,EAAE,UAAU,EAAE,MAAO,QAAO,EAAE,MAAM,cAAc,EAAE,KAAK;AAC7D,QAAI,EAAE,WAAW,EAAE,OAAQ,QAAO,EAAE,SAAS,KAAK;AAClD,WAAO;AAAA,EACT,CAAC;AACL;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
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,CAAC;AAC1E,MAAM,wBAAwB,oBAAI,IAAI,CAAC,QAAQ,YAAY,CAAC;AAE5D,eAAsB,wBAAwB,UAAyC;AACrF,QAAM,UAAU,qBAAqB,QAAQ;AAC7C,QAAM,cAAc,QAAQ,OAAO,OAAO;AAC1C,QAAM,MAAM,MAAM,OAAO,OAAO,OAAO,WAAW,WAAW;AAC7D,SAAO,IAAI,WAAW,GAAG;AAC3B;AAEO,SAAS,qBAAqB,
|
|
4
|
+
"sourcesContent": ["import { default as stableStringify } from \"json-stable-stringify\";\n\nimport type { GenerateManifestOkResult, 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 | GenerateManifestOkResult[\"groupSpecs\"]): 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,CAAC;AAC1E,MAAM,wBAAwB,oBAAI,IAAI,CAAC,QAAQ,YAAY,CAAC;AAE5D,eAAsB,wBAAwB,UAAyC;AACrF,QAAM,UAAU,qBAAqB,QAAQ;AAC7C,QAAM,cAAc,QAAQ,OAAO,OAAO;AAC1C,QAAM,MAAM,MAAM,OAAO,OAAO,OAAO,WAAW,WAAW;AAC7D,SAAO,IAA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BAA0B,CAAC,OAAO,YAAY,EAAE,CAAC;AACtE;",
|
|
6
6
|
"names": ["stableStringify"]
|
|
7
7
|
}
|
|
@@ -65,14 +65,18 @@ function isIngress(proto, global, externalPort, port) {
|
|
|
65
65
|
function transformGpuAttributes(attributes) {
|
|
66
66
|
const vendor = attributes.vendor;
|
|
67
67
|
if (!vendor) return [];
|
|
68
|
-
return Object.
|
|
69
|
-
|
|
68
|
+
return Object.keys(vendor).sort((a, b) => a.localeCompare(b)).flatMap((vendorName) => {
|
|
69
|
+
const models = vendor[vendorName];
|
|
70
|
+
if (!models) {
|
|
71
|
+
return [{ key: `vendor/${vendorName}/model/*`, value: "true" }];
|
|
72
|
+
}
|
|
73
|
+
return models.map((model) => {
|
|
70
74
|
let key = `vendor/${vendorName}/model/${model.model}`;
|
|
71
75
|
if (model.ram) key += `/ram/${model.ram}`;
|
|
72
76
|
if (model.interface) key += `/interface/${model.interface}`;
|
|
73
77
|
return { key, value: "true" };
|
|
74
|
-
})
|
|
75
|
-
);
|
|
78
|
+
});
|
|
79
|
+
});
|
|
76
80
|
}
|
|
77
81
|
function buildHttpOptions(httpOptions) {
|
|
78
82
|
return import_index_provider_akash_v2beta3.ServiceExposeHTTPOptions.fromPartial({
|
|
@@ -109,11 +113,14 @@ function buildServiceEndpoints(service, endpointSequenceNumbers) {
|
|
|
109
113
|
kind,
|
|
110
114
|
sequenceNumber: 0
|
|
111
115
|
});
|
|
112
|
-
|
|
116
|
+
if (!to.ip?.length) {
|
|
117
|
+
return [defaultEp];
|
|
118
|
+
}
|
|
119
|
+
const leasedEp = import_index_akash_v1beta4.Endpoint.fromPartial({
|
|
113
120
|
kind: import_index_akash_v1beta4.Endpoint_Kind.LEASED_IP,
|
|
114
|
-
sequenceNumber: endpointSequenceNumbers[to.ip]
|
|
115
|
-
})
|
|
116
|
-
return
|
|
121
|
+
sequenceNumber: endpointSequenceNumbers[to.ip] ?? 0
|
|
122
|
+
});
|
|
123
|
+
return [defaultEp, leasedEp];
|
|
117
124
|
})
|
|
118
125
|
);
|
|
119
126
|
}
|
|
@@ -133,6 +140,6 @@ function parseGpuUnits(gpu) {
|
|
|
133
140
|
}
|
|
134
141
|
function buildResourceAttributes(attributes) {
|
|
135
142
|
if (!attributes) return void 0;
|
|
136
|
-
return Object.
|
|
143
|
+
return Object.keys(attributes).sort((a, b) => a.localeCompare(b)).map((key) => ({ key, value: String(attributes[key]) }));
|
|
137
144
|
}
|
|
138
145
|
//# sourceMappingURL=manifestUtils.cjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
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.
|
|
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,QAAQ,GAAG;AAC7C,QAAI,CAAC,QAAQ,OAAQ;AACrB,eAAW,UAAU,QAAQ,QAAQ;AACnC,UAAI,CAAC,OAAO,GAAI;AAChB,iBAAW,MAAM,OAAO,IAAI;AAC1B,YAAI,GAAG,UAAU,GAAG,MAAM,GAAG,GAAG,SAAS,GAAG;AAC1C,wBAAc,KAAK,GAAG,EAAE;AAAA,QAC1B;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,SAAO,cAAc,KAAK,EAAE,OAA+B,CAAC,QAAQ,MAAM,cAAc;AACtF,WAAO,IAAI,IAAI,YAAY;AAC3B,WAAO;AAAA,EACT,GAAG,CAAC,CAAC;AACP;AAEO,SAAS,UAAU,OAAe,QAAiB,cAAsB,MAAuB;AACrG,QAAM,gBAAgB,iBAAiB,IAAI,OAAO;AAClD,SAAO,UAAU,UAAU,SAAS,kBAAkB;AACxD;AAEO,SAAS,uBAAuB,YAA2C;AAChF,QAAM,SAAS,WAAW;AAC1B,MAAI,CAAC,OAAQ,QAAO,CAAC;AAErB,SAAO,OAAO,
|
|
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.keys(vendor)\n .sort((a, b) => a.localeCompare(b))\n .flatMap((vendorName) => {\n const models = vendor[vendorName as keyof typeof vendor];\n if (!models) {\n return [{ key: `vendor/${vendorName}/model/*`, value: \"true\" }];\n }\n\n return 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 });\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 if (!to.ip?.length) {\n return [defaultEp];\n }\n\n const leasedEp = Endpoint.fromPartial({\n kind: Endpoint_Kind.LEASED_IP,\n sequenceNumber: endpointSequenceNumbers[to.ip] ?? 0,\n });\n\n return [defaultEp, leasedEp];\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.keys(attributes)\n .sort((a, b) => a.localeCompare(b))\n .map((key) => ({ key, value: String(attributes[key]) }));\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAA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I,IAChE,yCAAc,cACd,yCAAc;AAElB,YAAM,YAAY,oCAAS,YAAY;AAAA,QACrC;AAAA,QACA,gBAAgB;AAAA,MAClB,CAAC;AAED,UAAI,CAAC,GAAG,IAAI,QAAQ;AAClB,eAAO,CAAC,SAAS;AAAA,MACnB;AAEA,YAAM,WAAW,oCAAS,YAAY;AAAA,QACpC,MAAM,yCAAc;AAAA,QACpB,gBAAgB,wBAAwB,GAAG,EAAE,KAAK;AAAA,MACpD,CAAC;AAED,aAAO,CAAC,WAAW,QAAQ;AAAA,IAC7B,CAAC;AAAA,EACL;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,KAAK,UAAU,EAC1B,KAAK,CAAC,GAAG,MAAM,EAAE,cAAc,CAAC,CAAC,EACjC,IAAI,CAAC,SAAS,EAAE,KAAK,OAAO,OAAO,WAAW,GAAG,CAAC,EAAE,EAAE;AAC3D;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/sdl/types.ts"],
|
|
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"],
|
|
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[] | null;\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
|
}
|
package/dist/cjs/utils/yaml.cjs
CHANGED
|
@@ -24,10 +24,17 @@ module.exports = __toCommonJS(yaml_exports);
|
|
|
24
24
|
var import_js_yaml = require("js-yaml");
|
|
25
25
|
function yaml(chunks, ...args) {
|
|
26
26
|
const str = chunks.reduce((acc, chunk, i) => {
|
|
27
|
-
const value = args[i];
|
|
28
27
|
const intermediateResult = acc + chunk;
|
|
29
|
-
if (
|
|
30
|
-
|
|
28
|
+
if (i >= args.length) return intermediateResult;
|
|
29
|
+
const value = args[i];
|
|
30
|
+
if (value !== void 0) {
|
|
31
|
+
return intermediateResult + JSON.stringify(value);
|
|
32
|
+
}
|
|
33
|
+
const lastNewlineIndex = intermediateResult.lastIndexOf("\n");
|
|
34
|
+
if (lastNewlineIndex !== -1) {
|
|
35
|
+
return intermediateResult.slice(0, lastNewlineIndex);
|
|
36
|
+
}
|
|
37
|
+
return intermediateResult;
|
|
31
38
|
}, "");
|
|
32
39
|
return (0, import_js_yaml.load)(str);
|
|
33
40
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/utils/yaml.ts"],
|
|
4
|
-
"sourcesContent": ["import { load } from \"js-yaml\";\n\n/**\n * @example\n * ```ts\n * const version = \"2.1\";\n * const expose = [{ port: 80, as: 80, to: [{ global: true }] }];\n * const pricing = { web: { denom: \"uakt\", amount: 1000 } };\n *\n * const sdl: SDLInput = yaml`\n * version: ${version}\n * services:\n * web:\n * image: nginx\n * expose: ${expose}\n * profiles:\n * compute:\n * web:\n * resources:\n * cpu:\n * units: 0.5\n * memory:\n * size: 512Mi\n * storage:\n * size: 1Gi\n * placement:\n * dcloud:\n * pricing: ${pricing}\n * deployment:\n * web:\n * dcloud:\n * profile: web\n * count: 1\n * `;\n * ```\n */\nexport function yaml<T>(chunks: TemplateStringsArray, ...args: unknown[]): T {\n const str = chunks.reduce((acc, chunk, i) => {\n const
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAqB;
|
|
4
|
+
"sourcesContent": ["import { load } from \"js-yaml\";\n\n/**\n * Generate YAML string from template literal and parse it into object of type T.\n * If some interpolated value is undefined, the whole line containing it will be removed from the resulting YAML string.\n *\n * @example\n * ```ts\n * const version = \"2.1\";\n * const expose = [{ port: 80, as: 80, to: [{ global: true }] }];\n * const pricing = { web: { denom: \"uakt\", amount: 1000 } };\n *\n * const sdl: SDLInput = yaml`\n * version: ${version}\n * services:\n * web:\n * image: nginx\n * expose: ${expose}\n * profiles:\n * compute:\n * web:\n * resources:\n * cpu:\n * units: 0.5\n * memory:\n * size: 512Mi\n * storage:\n * size: 1Gi\n * placement:\n * dcloud:\n * pricing: ${pricing}\n * deployment:\n * web:\n * dcloud:\n * profile: web\n * count: 1\n * `;\n * ```\n */\nexport function yaml<T>(chunks: TemplateStringsArray, ...args: unknown[]): T {\n const str = chunks.reduce((acc, chunk, i) => {\n const intermediateResult = acc + chunk;\n if (i >= args.length) return intermediateResult;\n\n const value = args[i];\n if (value !== undefined) {\n return intermediateResult + JSON.stringify(value);\n }\n\n const lastNewlineIndex = intermediateResult.lastIndexOf(\"\\n\");\n if (lastNewlineIndex !== -1) {\n return intermediateResult.slice(0, lastNewlineIndex);\n }\n\n return intermediateResult;\n }, \"\");\n\n return load(str) as T;\n}\n\n/**\n * Use this function to parse YAML template defined in external resource (e.g., file, http response, etc.).\n * Prefer `yaml` function for inline YAML templates defined in code, as it provides better ergonomics.\n */\nyaml.template = function yamlTemplate<T>(template: string, vars?: Record<string, unknown>): T {\n const finalYaml = template.replace(/\\$\\{(\\w+)\\}/g, (_, varName) => {\n const value = vars?.[varName];\n if (value === undefined) {\n throw new ReferenceError(`Variable \"${varName}\" is not provided to yaml template`);\n }\n return JSON.stringify(value);\n });\n return load(finalYaml) as T;\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAqB;AAuCd,SAAS,KAAQ,WAAiC,MAAoB;AAC3E,QAAM,MAAM,OAAO,OAAO,CAAC,KAAK,OAAO,MAAM;AAC3C,UAAM,qBAAqB,MAAM;AACjC,QAAI,KAAK,KAAK,OAAQ,QAAO;AAE7B,UAAM,QAAQ,KAAK,CAAC;AACpB,QAAI,UAAU,QAAW;AACvB,aAAO,qBAAqB,KAAK,UAAU,KAAK;AAAA,IAClD;AAEA,UAAM,mBAAmB,mBAAmB,YAAY,IAAI;AAC5D,QAAI,qBAAqB,IAAI;AAC3B,aAAO,mBAAmB,MAAM,GAAG,gBAAgB;AAAA,IACrD;AAEA,WAAO;AAAA,EACT,GAAG,EAAE;AAEL,aAAO,qBAAK,GAAG;AACjB;AAMA,KAAK,WAAW,SAAS,aAAgB,UAAkB,MAAmC;AAC5F,QAAM,YAAY,SAAS,QAAQ,gBAAgB,CAAC,GAAG,YAAY;AACjE,UAAM,QAAQ,OAAO,OAAO;AAC5B,QAAI,UAAU,QAAW;AACvB,YAAM,IAAI,eAAe,aAAa,OAAO,oCAAoC;AAAA,IACnF;AACA,WAAO,KAAK,UAAU,KAAK;AAAA,EAC7B,CAAC;AACD,aAAO,qBAAK,SAAS;AACvB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|