SDL (Stack Definition Language) parser and validator Handles parsing and validation of Akash deployment manifests

import { SDL } from './SDL';

const yaml = `
version: "2.0"
services:
web:
image: nginx
expose:
- port: 80
as: 80
to:
- global: true
`;

// Parse SDL from YAML string
const sdl = SDL.fromString(yaml);

// Get deployment manifest
const manifest = sdl.manifest();

// Get deployment groups
const groups = sdl.groups();

Constructors

  • Parameters

    • data: v2Sdl
    • version: NetworkVersion = "beta2"
    • networkId: NetworkId = MAINNET_ID

    Returns SDL

Properties

data: v2Sdl
version: NetworkVersion = "beta2"

Methods

  • Computes the endpoint sequence numbers for the given SDL.

    Parameters

    • sdl: v2Sdl

      The SDL data.

    Returns { [k: string]: number }

    An object mapping IPs to their sequence numbers.

    const sequenceNumbers = sdl.computeEndpointSequenceNumbers(sdlData);
    // sequenceNumbers might be { "192.168.1.1": 1, "192.168.1.2": 2 }
  • Returns Record<string, v2Deployment>

  • Parameters

    • placement: string

    Returns [string, any][]

  • Escapes HTML characters in a string.

    Parameters

    • raw: string

      The raw string to escape.

    Returns string

    The escaped string.

    const escaped = sdl.escapeHtml("<div>Hello</div>");
    // escaped is "\\u003cdiv\\u003eHello\\u003c/div\\u003e"
  • Parameters

    • expose: { externalPort: number; global: boolean; port: number; proto: string }

    Returns boolean

  • Parameters

    • resource: undefined | v2ComputeResources
    • asString: boolean

    Returns any

  • Parameters

    • asString: boolean = false

    Returns v2Manifest | v3Manifest

  • Parameters

    • to: v2ExposeTo

    Returns boolean

  • Parameters

    • expose: v2Expose

    Returns v2Accept

  • Parameters

    • to: v2ExposeTo

    Returns string

  • Returns Promise<Uint8Array<ArrayBuffer>>

  • Parses the service protocol.

    Parameters

    • Optionalproto: string

      The protocol string (e.g., "TCP", "UDP").

    Returns string

    The parsed protocol.

    Will throw an error if the protocol is unsupported.

    const protocol = SDL.parseServiceProto("TCP");
    // protocol is "TCP"
  • Returns Record<string, v2ProfilePlacement>

  • Parameters

    • val: string
    • asString: boolean

    Returns { val: string } | { val: number }

  • Parameters

    • computeResources: v2ComputeResources
    • asString: boolean

    Returns {
        attributes: undefined | { key: string; value: any }[];
        units: { val: null | string | Uint8Array<ArrayBufferLike> };
    }

  • Parameters

    • computeResources: v3ComputeResources
    • asString: boolean

    Returns {
        attributes: undefined | { key: string; value: string }[];
        units: { val: null | string | Uint8Array<ArrayBufferLike> };
    }

  • Parameters

    • computeResources: v2ComputeResources
    • asString: boolean

    Returns {
        attributes: undefined | { key: string; value: any }[];
        quantity: { val: null | string | Uint8Array<ArrayBufferLike> };
    }

  • Parameters

    • computeResources: v2ComputeResources
    • asString: boolean

    Returns {
        attributes: undefined | { key: string; value: any }[];
        name: string;
        quantity: { val: null | string | Uint8Array<ArrayBufferLike> };
    }[]

  • Parameters

    • value: null | { toString: () => string }
    • asString: boolean

    Returns null | string | Uint8Array<ArrayBufferLike>

  • Parameters

    • Optionalattributes: Record<string, any>

    Returns undefined | { key: string; value: any }[]

  • Parameters

    • resource: v2ResourceCPU

    Returns
        | {
            attributes: undefined
            | { key: string; value: any }[];
            units: { val: string };
        }
        | { attributes?: undefined; units: { val: string } }

  • Parameters

    • resource: undefined | v3ResourceGPU
    • asString: boolean

    Returns
        | {
            attributes: { key: string; value: string }[];
            units: { val: string } | { val: number | Buffer };
        }
        | {
            attributes?: undefined;
            units: { val: string }
            | { val: number | Buffer };
        }

  • Parameters

    • resource: v2ResourceMemory
    • asString: boolean

    Returns
        | {
            attributes: undefined
            | { key: string; value: any }[];
            [key: string]:
                | undefined
                | { val: string }
                | { val: number }
                | { key: string; value: any }[];
        }
        | {
            attributes?: undefined;
            [key: string]: { val: string }
            | { val: number };
        }

  • Parameters

    • profile: v2ProfileCompute
    • service: v2Service
    • asString: boolean = false

    Returns {
        cpu:
            | {
                attributes: undefined
                | { key: string; value: any }[];
                units: { val: string };
            }
            | { attributes?: undefined; units: { val: string } };
        endpoints: null | { kind: number; sequence_number: number }[];
        memory:
            | {
                attributes: undefined
                | { key: string; value: any }[];
                [key: string]:
                    | undefined
                    | { val: string }
                    | { val: number }
                    | { key: string; value: any }[];
            }
            | {
                attributes?: undefined;
                [key: string]: { val: string }
                | { val: number };
            };
        storage: (
            | {
                attributes: undefined
                | { key: string; value: any }[];
                name: string;
                [key: string]:
                    | undefined
                    | string
                    | { val: string }
                    | { val: number }
                    | { key: string; value: any }[];
            }
            | {
                attributes?: undefined;
                name: string;
                [key: string]: string
                | { val: string }
                | { val: number };
            }
        )[];
    }

  • Parameters

    • id: number
    • profile: v3ProfileCompute
    • service: v2Service
    • asString: boolean = false

    Returns {
        cpu:
            | {
                attributes: undefined
                | { key: string; value: any }[];
                units: { val: string };
            }
            | { attributes?: undefined; units: { val: string } };
        endpoints: (
            | { kind: number; sequence_number: number }
            | { kind?: undefined; sequence_number: number }
        )[];
        gpu:
            | {
                attributes: { key: string; value: string }[];
                units: { val: string } | { val: number | Buffer };
            }
            | {
                attributes?: undefined;
                units: { val: string }
                | { val: number | Buffer };
            };
        id: number;
        memory: | {
            attributes: undefined
            | { key: string; value: any }[];
            [key: string]:
                | undefined
                | { val: string }
                | { val: number }
                | { key: string; value: any }[];
        }
        | {
            attributes?: undefined;
            [key: string]: { val: string }
            | { val: number };
        };
        storage: (
            | {
                attributes: undefined
                | { key: string; value: any }[];
                name: string;
                [key: string]:
                    | undefined
                    | string
                    | { val: string }
                    | { val: number }
                    | { key: string; value: any }[];
            }
            | {
                attributes?: undefined;
                name: string;
                [key: string]: string
                | { val: string }
                | { val: number };
            }
        )[];
    }

  • Parameters

    • resource: v2ResourceStorage | v2ResourceStorageArray
    • asString: boolean

    Returns (
        | {
            attributes: undefined
            | { key: string; value: any }[];
            name: string;
            [key: string]:
                | undefined
                | string
                | { val: string }
                | { val: number }
                | { key: string; value: any }[];
        }
        | {
            attributes?: undefined;
            name: string;
            [key: string]: string
            | { val: string }
            | { val: number };
        }
    )[]

  • Parameters

    • Optionalattributes: v2StorageAttributes

    Returns undefined | { key: string; value: any }[]

  • Parameters

    • attributes: v3GPUAttributes

    Returns { key: string; value: string }[]

  • Parameters

    • http_options: undefined | v2HTTPOptions

    Returns {
        MaxBodySize: number;
        NextCases: string[];
        NextTimeout: number;
        NextTries: number;
        ReadTimeout: number;
        SendTimeout: number;
    }

  • Parameters

    • asString: boolean = false

    Returns v2Manifest

  • Parameters

    • service: v2Service

    Returns v2ServiceExpose[]

  • Parameters

    • expose: v2Expose

    Returns v2ServiceExposeHttpOptions

  • Parameters

    • placement: string
    • name: string
    • asString: boolean

    Returns v2ManifestService

  • Parameters

    • params: v2ServiceParams

    Returns undefined | v2ManifestServiceParams

  • Parameters

    • service: v2Service

    Returns null | { kind: number; sequence_number: number }[]

  • Parameters

    • http_options: undefined | v2HTTPOptions

    Returns {
        maxBodySize: number;
        nextCases: string[];
        nextTimeout: number;
        nextTries: number;
        readTimeout: number;
        sendTimeout: number;
    }

  • Parameters

    • asString: boolean = false

    Returns v3Manifest

  • Parameters

    • service: v2Service

    Returns v3ServiceExpose[]

  • Parameters

    • expose: v2Expose

    Returns v3ServiceExposeHttpOptions

  • Parameters

    • id: number
    • placement: string
    • name: string
    • asString: boolean

    Returns v3ManifestService

  • Parameters

    • params: undefined | v2ServiceParams

    Returns null | v3ManifestServiceParams

  • Parameters

    • service: v2Service

    Returns (
        | { kind: number; sequence_number: number }
        | { kind?: undefined; sequence_number: number }
    )[]

  • Creates an SDL instance from a YAML string.

    Parameters

    • yaml: string

      The YAML string containing the SDL definition.

    • Optionalversion: NetworkVersion = "beta2"

      The SDL version (beta2 or beta3).

    • OptionalnetworkId: NetworkId = MAINNET_ID

      The network ID to validate against.

    Returns SDL

    An instance of the SDL class.

    const yaml = `
    version: "2.0"
    services:
    web:
    image: nginx
    expose:
    - port: 80
    as: 80
    to:
    - global: true
    `;
    const sdl = SDL.fromString(yaml);
  • Validates SDL YAML string (deprecated)

    Parameters

    • yaml: string

    Returns v3Sdl

    Use SDL.constructor directly

  • Validates the GPU configuration for a given service profile.

    Parameters

    • name: string

      The name of the service profile.

    • gpu: undefined | v3ResourceGPU

      The GPU resource configuration.

    Returns void

    Will throw an error if the GPU configuration is invalid.

    const gpuConfig = { units: "1", attributes: { vendor: { nvidia: [{ model: "RTX 3080", ram: "10GB" }] } } };
    SDL.validateGPU("web", gpuConfig);
  • Validates the storage configuration for a given service.

    Parameters

    • name: string

      The name of the service.

    • Optionalstorage: v2ResourceStorage | v2ResourceStorageArray

      The storage resource configuration.

    Returns void

    Will throw an error if the storage configuration is invalid.

    const storageConfig = { size: "10Gi", attributes: { class: "ssd" } };
    SDL.validateStorage("web", storageConfig);