@akashnetwork/chain-sdk 1.0.0-alpha.28 → 1.0.0-alpha.29

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.
@@ -76,7 +76,7 @@ class CertificateManager {
76
76
  const { prvKeyObj, pubKeyObj } = rs.KEYUTIL.generateKeypair("EC", "secp256r1");
77
77
  const cert = new rs.KJUR.asn1.x509.Certificate({
78
78
  version: 3,
79
- serial: { int: Math.floor(Date.now() * 1e3) },
79
+ serial: { int: options?.serial ?? Math.floor(Date.now() * 1e3) },
80
80
  issuer: { str: "/CN=" + address },
81
81
  notbefore: notBeforeStr,
82
82
  notafter: notAfterStr,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/sdk/provider/auth/mtls/CertificateManager.ts"],
4
- "sourcesContent": ["import type * as rs from \"jsrsasign\";\n\n/**\n * Represents the PEM encoded certificate, public key, and private key.\n */\nexport interface CertificatePem {\n cert: string;\n publicKey: string;\n privateKey: string;\n}\n\n/**\n * Represents the information extracted from a certificate.\n */\nexport interface CertificateInfo {\n hSerial: string;\n sIssuer: string;\n sSubject: string;\n sNotBefore: string;\n sNotAfter: string;\n issuedOn: Date;\n expiresOn: Date;\n}\n\n/**\n * Options for specifying the validity range of a certificate.\n */\nexport interface ValidityRangeOptions {\n validFrom?: Date;\n validTo?: Date;\n}\n\n/**\n * Manages the creation and parsing of certificates.\n */\nexport class CertificateManager {\n /**\n * Parses a PEM encoded certificate and extracts its information.\n * @param certPEM - The PEM encoded certificate string.\n * @returns An object containing the certificate information.\n * @example\n * const certificateManager = new CertificateManager();\n * const pem = certificateManager.generatePEM('exampleAddress');\n * const certInfo = certificateManager.parsePem(pem.cert);\n * console.log(certInfo);\n */\n async parsePem(certPEM: string): Promise<CertificateInfo> {\n const rs = await getRSASignLib();\n const certificate = new rs.X509();\n certificate.readCertPEM(certPEM);\n\n return {\n hSerial: certificate.getSerialNumberHex(),\n sIssuer: certificate.getIssuerString(),\n sSubject: certificate.getSubjectString(),\n sNotBefore: certificate.getNotBefore(),\n sNotAfter: certificate.getNotAfter(),\n issuedOn: strToDate(certificate.getNotBefore()),\n expiresOn: strToDate(certificate.getNotAfter()),\n };\n }\n\n /**\n * Generates a PEM encoded certificate, public key, and private key.\n * @param address - The address to be used as the certificate's subject and issuer.\n * @param options - Optional validity range for the certificate.\n * @returns An object containing the PEM encoded certificate, public key, and private key.\n * @example\n * const certificateManager = new CertificateManager();\n * const pem = certificateManager.generatePEM('exampleAddress');\n * console.log('Certificate:', pem.cert);\n * console.log('Public Key:', pem.publicKey);\n * console.log('Private Key:', pem.privateKey);\n */\n async generatePEM(address: string, options?: ValidityRangeOptions): Promise<CertificatePem> {\n const rs = await getRSASignLib();\n const { notBeforeStr, notAfterStr } = this.createValidityRange(options);\n const { prvKeyObj, pubKeyObj } = rs.KEYUTIL.generateKeypair(\"EC\", \"secp256r1\");\n const cert = new rs.KJUR.asn1.x509.Certificate({\n version: 3,\n serial: { int: Math.floor(Date.now() * 1000) },\n issuer: { str: \"/CN=\" + address },\n notbefore: notBeforeStr,\n notafter: notAfterStr,\n subject: { str: \"/CN=\" + address },\n sbjpubkey: pubKeyObj,\n ext: [\n { extname: \"keyUsage\", critical: true, names: [\"keyEncipherment\", \"dataEncipherment\"] },\n {\n extname: \"extKeyUsage\",\n array: [{ name: \"clientAuth\" }],\n },\n { extname: \"basicConstraints\", cA: true, critical: true },\n ],\n sigalg: \"SHA256withECDSA\",\n cakey: prvKeyObj,\n });\n const publicKey = rs.KEYUTIL.getPEM(pubKeyObj, \"PKCS8PUB\" as rs.PrivateKeyOutputFormatType).replaceAll(\"PUBLIC KEY\", \"EC PUBLIC KEY\");\n const certPEM = cert.getPEM();\n\n return {\n cert: certPEM,\n publicKey,\n privateKey: rs.KEYUTIL.getPEM(prvKeyObj, \"PKCS8PRV\"),\n };\n }\n\n /**\n * Creates a validity range for a certificate.\n * @param options - Optional validity range options.\n * @returns An object containing the notBefore and notAfter date strings.\n */\n private createValidityRange(options?: ValidityRangeOptions) {\n const notBefore = options?.validFrom || new Date();\n const notAfter = options?.validTo || new Date();\n\n if (!options?.validTo) {\n notAfter.setFullYear(notBefore.getFullYear() + 1);\n }\n\n const notBeforeStr = dateToStr(notBefore);\n const notAfterStr = dateToStr(notAfter);\n\n return { notBeforeStr, notAfterStr };\n }\n}\n\n/**\n * Converts a Date object to a string in the format YYMMDDHHMMSSZ.\n * @private\n * @param date - The date to convert.\n * @returns The formatted date string.\n * @example\n * const certificateManager = new CertificateManager();\n * const dateStr = certificateManager.dateToStr(new Date('2024-05-07T12:23:50.000Z'));\n * console.log(dateStr); // \"240507122350Z\"\n */\nexport function dateToStr(date: Date): string {\n const year = date.getUTCFullYear().toString().slice(2).padStart(2, \"0\");\n const month = (date.getUTCMonth() + 1).toString().padStart(2, \"0\");\n const day = date.getUTCDate().toString().padStart(2, \"0\");\n const hours = date.getUTCHours().toString().padStart(2, \"0\");\n const minutes = date.getUTCMinutes().toString().padStart(2, \"0\");\n const secs = date.getUTCSeconds().toString().padStart(2, \"0\");\n\n return `${year}${month}${day}${hours}${minutes}${secs}Z`;\n}\n\n/**\n * Converts a string in the format YYMMDDHHMMSSZ to a Date object.\n * @private\n * @param str - The string to convert.\n * @returns The corresponding Date object.\n * @example\n * const certificateManager = new CertificateManager();\n * const date = certificateManager.strToDate(\"240507122350Z\");\n * console.log(date.toISOString()); // \"2024-05-07T12:23:50.000Z\"\n */\nexport function strToDate(str: string): Date {\n const year = parseInt(`20${str.substring(0, 2)}`);\n const month = parseInt(str.substring(2, 4)) - 1;\n const day = parseInt(str.substring(4, 6));\n const hours = parseInt(str.substring(6, 8));\n const minutes = parseInt(str.substring(8, 10));\n const secs = parseInt(str.substring(10, 12));\n\n return new Date(Date.UTC(year, month, day, hours, minutes, secs));\n}\n\nlet rsasignLib: Promise<typeof rs>;\nfunction getRSASignLib() {\n rsasignLib ??= import(\"jsrsasign\");\n return rsasignLib;\n}\n"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,GAAG,KAAK,GAAG,GAAG,GAAG,KAAK,GAAG,OAAO,GAAG,IAAI;AACvD;AAYO,SAAS,UAAU,KAAmB;AAC3C,QAAM,OAAO,SAAS,KAAK,IAAI,UAAU,GAAG,CAAC,CAAC,EAAE;AAChD,QAAM,QAAQ,SAAS,IAAI,UAAU,GAAG,CAAC,CAAC,IAAI;AAC9C,QAAM,MAAM,SAAS,IAAI,UAAU,GAAG,CAAC,CAAC;AACxC,QAAM,QAAQ,SAAS,IAAI,UAAU,GAAG,CAAC,CAAC;AAC1C,QAAM,UAAU,SAAS,IAAI,UAAU,GAAG,EAAE,CAAC;AAC7C,QAAM,OAAO,SAAS,IAAI,UAAU,IAAI,EAAE,CAAC;AAE3C,SAAO,IAAI,KAAK,KAAK,IAAI,MAAM,OAAO,KAAK,OAAO,SAAS,IAAI,CAAC;AAClE;AAEA,IAAI;AACJ,SAAS,gBAAgB;AACvB,8BAAe,6CAAO,WAAW;AACjC,SAAO;AACT;",
4
+ "sourcesContent": ["import type * as rs from \"jsrsasign\";\n\n/**\n * Represents the PEM encoded certificate, public key, and private key.\n */\nexport interface CertificatePem {\n cert: string;\n publicKey: string;\n privateKey: string;\n}\n\n/**\n * Represents the information extracted from a certificate.\n */\nexport interface CertificateInfo {\n hSerial: string;\n sIssuer: string;\n sSubject: string;\n sNotBefore: string;\n sNotAfter: string;\n issuedOn: Date;\n expiresOn: Date;\n}\n\n/**\n * Options for specifying the validity range of a certificate.\n */\nexport interface ValidityRangeOptions {\n serial?: number;\n validFrom?: Date;\n validTo?: Date;\n}\n\n/**\n * Manages the creation and parsing of certificates.\n */\nexport class CertificateManager {\n /**\n * Parses a PEM encoded certificate and extracts its information.\n * @param certPEM - The PEM encoded certificate string.\n * @returns An object containing the certificate information.\n * @example\n * const certificateManager = new CertificateManager();\n * const pem = certificateManager.generatePEM('exampleAddress');\n * const certInfo = certificateManager.parsePem(pem.cert);\n * console.log(certInfo);\n */\n async parsePem(certPEM: string): Promise<CertificateInfo> {\n const rs = await getRSASignLib();\n const certificate = new rs.X509();\n certificate.readCertPEM(certPEM);\n\n return {\n hSerial: certificate.getSerialNumberHex(),\n sIssuer: certificate.getIssuerString(),\n sSubject: certificate.getSubjectString(),\n sNotBefore: certificate.getNotBefore(),\n sNotAfter: certificate.getNotAfter(),\n issuedOn: strToDate(certificate.getNotBefore()),\n expiresOn: strToDate(certificate.getNotAfter()),\n };\n }\n\n /**\n * Generates a PEM encoded certificate, public key, and private key.\n * @param address - The address to be used as the certificate's subject and issuer.\n * @param options - Optional validity range for the certificate.\n * @returns An object containing the PEM encoded certificate, public key, and private key.\n * @example\n * const certificateManager = new CertificateManager();\n * const pem = certificateManager.generatePEM('exampleAddress');\n * console.log('Certificate:', pem.cert);\n * console.log('Public Key:', pem.publicKey);\n * console.log('Private Key:', pem.privateKey);\n */\n async generatePEM(address: string, options?: ValidityRangeOptions): Promise<CertificatePem> {\n const rs = await getRSASignLib();\n const { notBeforeStr, notAfterStr } = this.createValidityRange(options);\n const { prvKeyObj, pubKeyObj } = rs.KEYUTIL.generateKeypair(\"EC\", \"secp256r1\");\n const cert = new rs.KJUR.asn1.x509.Certificate({\n version: 3,\n serial: { int: options?.serial ?? Math.floor(Date.now() * 1000) },\n issuer: { str: \"/CN=\" + address },\n notbefore: notBeforeStr,\n notafter: notAfterStr,\n subject: { str: \"/CN=\" + address },\n sbjpubkey: pubKeyObj,\n ext: [\n { extname: \"keyUsage\", critical: true, names: [\"keyEncipherment\", \"dataEncipherment\"] },\n {\n extname: \"extKeyUsage\",\n array: [{ name: \"clientAuth\" }],\n },\n { extname: \"basicConstraints\", cA: true, critical: true },\n ],\n sigalg: \"SHA256withECDSA\",\n cakey: prvKeyObj,\n });\n const publicKey = rs.KEYUTIL.getPEM(pubKeyObj, \"PKCS8PUB\" as rs.PrivateKeyOutputFormatType).replaceAll(\"PUBLIC KEY\", \"EC PUBLIC KEY\");\n const certPEM = cert.getPEM();\n\n return {\n cert: certPEM,\n publicKey,\n privateKey: rs.KEYUTIL.getPEM(prvKeyObj, \"PKCS8PRV\"),\n };\n }\n\n /**\n * Creates a validity range for a certificate.\n * @param options - Optional validity range options.\n * @returns An object containing the notBefore and notAfter date strings.\n */\n private createValidityRange(options?: ValidityRangeOptions) {\n const notBefore = options?.validFrom || new Date();\n const notAfter = options?.validTo || new Date();\n\n if (!options?.validTo) {\n notAfter.setFullYear(notBefore.getFullYear() + 1);\n }\n\n const notBeforeStr = dateToStr(notBefore);\n const notAfterStr = dateToStr(notAfter);\n\n return { notBeforeStr, notAfterStr };\n }\n}\n\n/**\n * Converts a Date object to a string in the format YYMMDDHHMMSSZ.\n * @private\n * @param date - The date to convert.\n * @returns The formatted date string.\n * @example\n * const certificateManager = new CertificateManager();\n * const dateStr = certificateManager.dateToStr(new Date('2024-05-07T12:23:50.000Z'));\n * console.log(dateStr); // \"240507122350Z\"\n */\nexport function dateToStr(date: Date): string {\n const year = date.getUTCFullYear().toString().slice(2).padStart(2, \"0\");\n const month = (date.getUTCMonth() + 1).toString().padStart(2, \"0\");\n const day = date.getUTCDate().toString().padStart(2, \"0\");\n const hours = date.getUTCHours().toString().padStart(2, \"0\");\n const minutes = date.getUTCMinutes().toString().padStart(2, \"0\");\n const secs = date.getUTCSeconds().toString().padStart(2, \"0\");\n\n return `${year}${month}${day}${hours}${minutes}${secs}Z`;\n}\n\n/**\n * Converts a string in the format YYMMDDHHMMSSZ to a Date object.\n * @private\n * @param str - The string to convert.\n * @returns The corresponding Date object.\n * @example\n * const certificateManager = new CertificateManager();\n * const date = certificateManager.strToDate(\"240507122350Z\");\n * console.log(date.toISOString()); // \"2024-05-07T12:23:50.000Z\"\n */\nexport function strToDate(str: string): Date {\n const year = parseInt(`20${str.substring(0, 2)}`);\n const month = parseInt(str.substring(2, 4)) - 1;\n const day = parseInt(str.substring(4, 6));\n const hours = parseInt(str.substring(6, 8));\n const minutes = parseInt(str.substring(8, 10));\n const secs = parseInt(str.substring(10, 12));\n\n return new Date(Date.UTC(year, month, day, hours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S,EAAE,SAAS,GAAG,GAAG;AAC/D,QAAM,OAAO,KAAK,cAAc,EAAE,SAAS,EAAE,SAAS,GAAG,GAAG;AAE5D,SAAO,GAAG,IAAI,GAAG,KAAK,GAAG,GAAG,GAAG,KAAK,GAAG,OAAO,GAAG,IAAI;AACvD;AAYO,SAAS,UAAU,KAAmB;AAC3C,QAAM,OAAO,SAAS,KAAK,IAAI,UAAU,GAAG,CAAC,CAAC,EAAE;AAChD,QAAM,QAAQ,SAAS,IAAI,UAAU,GAAG,CAAC,CAAC,IAAI;AAC9C,QAAM,MAAM,SAAS,IAAI,UAAU,GAAG,CAAC,CAAC;AACxC,QAAM,QAAQ,SAAS,IAAI,UAAU,GAAG,CAAC,CAAC;AAC1C,QAAM,UAAU,SAAS,IAAI,UAAU,GAAG,EAAE,CAAC;AAC7C,QAAM,OAAO,SAAS,IAAI,UAAU,IAAI,EAAE,CAAC;AAE3C,SAAO,IAAI,KAAK,KAAK,IAAI,MAAM,OAAO,KAAK,OAAO,SAAS,IAAI,CAAC;AAClE;AAEA,IAAI;AACJ,SAAS,gBAAgB;AACvB,8BAAe,6CAAO,WAAW;AACjC,SAAO;AACT;",
6
6
  "names": []
7
7
  }
@@ -31,7 +31,7 @@ const RETRIABLE_ERROR_CODES = /* @__PURE__ */ new Set([
31
31
  import_TransportError.TransportError.Code.Unknown
32
32
  ]);
33
33
  function createRetryInterceptor(options) {
34
- const retryPolicy = (0, import_cockatiel.retry)((0, import_cockatiel.handleWhen)((error) => error instanceof import_TransportError.TransportError && RETRIABLE_ERROR_CODES.has(error.code)), {
34
+ const retryPolicy = (0, import_cockatiel.retry)((0, import_cockatiel.handleWhen)((error) => error instanceof import_TransportError.TransportError && RETRIABLE_ERROR_CODES.has(error.code) || isConnectionError(error)), {
35
35
  maxAttempts: Math.min(3, options.maxAttempts),
36
36
  backoff: new import_cockatiel.ExponentialBackoff({
37
37
  initialDelay: 250,
@@ -43,4 +43,14 @@ function createRetryInterceptor(options) {
43
43
  function isRetryEnabled(options) {
44
44
  return !!options?.maxAttempts && !Number.isNaN(options.maxAttempts) && options.maxAttempts > 0;
45
45
  }
46
+ const RETRIABLE_NETWORK_ERROR_CODES = /* @__PURE__ */ new Set([
47
+ "ECONNREFUSED",
48
+ "ECONNRESET",
49
+ "ETIMEDOUT",
50
+ "ESOCKETTIMEDOUT",
51
+ "UND_ERR_SOCKET"
52
+ ]);
53
+ function isConnectionError(error) {
54
+ return "code" in error && RETRIABLE_NETWORK_ERROR_CODES.has(error.code) || !!error.cause && isConnectionError(error.cause) || !!error.errors?.some(isConnectionError);
55
+ }
46
56
  //# sourceMappingURL=retry.cjs.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/sdk/transport/interceptors/retry.ts"],
4
- "sourcesContent": ["import type { Interceptor } from \"@connectrpc/connect\";\nimport {\n ExponentialBackoff,\n handleWhen,\n retry,\n} from \"cockatiel\";\n\nimport { TransportError } from \"../TransportError.ts\";\n\nconst RETRIABLE_ERROR_CODES = new Set([\n TransportError.Code.Unavailable,\n TransportError.Code.DeadlineExceeded,\n TransportError.Code.Internal,\n TransportError.Code.Unknown,\n]);\nexport function createRetryInterceptor(options: RetryOptions): Interceptor {\n const retryPolicy = retry(handleWhen((error) => error instanceof TransportError && RETRIABLE_ERROR_CODES.has(error.code)), {\n maxAttempts: Math.min(3, options.maxAttempts),\n backoff: new ExponentialBackoff({\n initialDelay: 250,\n maxDelay: options.maxDelayMs ?? 5_000,\n }),\n });\n\n return (next) => async (req) => retryPolicy.execute(() => next(req));\n}\n\nexport function isRetryEnabled(options: RetryOptions | undefined): options is RetryOptions {\n return !!options?.maxAttempts && !Number.isNaN(options.maxAttempts) && options.maxAttempts > 0;\n}\n\nexport interface RetryOptions {\n /**\n * Maximum number of attempts to make after first failure.\n * Maximum allowed value is 3.\n */\n maxAttempts: number;\n /**\n * Maximum delay between attempts in milliseconds. Used to restrict exponential backoff calculated value.\n * Default value is 5000ms.\n */\n maxDelayMs?: number;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,uBAIO;AAEP,4BAA+B;AAE/B,MAAM,wBAAwB,oBAAI,IAAI;AAAA,EACpC,qCAAe,KAAK;AAAA,EACpB,qCAAe,KAAK;AAAA,EACpB,qCAAe,KAAK;AAAA,EACpB,qCAAe,KAAK;AACtB,CAAC;AACM,SAAS,uBAAuB,SAAoC;AACzE,QAAM,kBAAc,4BAAM,6BAAW,CAAC,UAAU,iBAAiB,wCAAkB,sBAAsB,IAAI,MAAM,IAAI,CAAC,GAAG;AAAA,IACzH,aAAa,KAAK,IAAI,GAAG,QAAQ,WAAW;AAAA,IAC5C,SAAS,IAAI,oCAAmB;AAAA,MAC9B,cAAc;AAAA,MACd,UAAU,QAAQ,cAAc;AAAA,IAClC,CAAC;AAAA,EACH,CAAC;AAED,SAAO,CAAC,SAAS,OAAO,QAAQ,YAAY,QAAQ,MAAM,KAAK,GAAG,CAAC;AACrE;AAEO,SAAS,eAAe,SAA4D;AACzF,SAAO,CAAC,CAAC,SAAS,eAAe,CAAC,OAAO,MAAM,QAAQ,WAAW,KAAK,QAAQ,cAAc;AAC/F;",
4
+ "sourcesContent": ["import type { Interceptor } from \"@connectrpc/connect\";\nimport {\n ExponentialBackoff,\n handleWhen,\n retry,\n} from \"cockatiel\";\n\nimport { TransportError } from \"../TransportError.ts\";\n\nconst RETRIABLE_ERROR_CODES = new Set([\n TransportError.Code.Unavailable,\n TransportError.Code.DeadlineExceeded,\n TransportError.Code.Internal,\n TransportError.Code.Unknown,\n]);\nexport function createRetryInterceptor(options: RetryOptions): Interceptor {\n const retryPolicy = retry(handleWhen((error) => (error instanceof TransportError && RETRIABLE_ERROR_CODES.has(error.code)) || isConnectionError(error)), {\n maxAttempts: Math.min(3, options.maxAttempts),\n backoff: new ExponentialBackoff({\n initialDelay: 250,\n maxDelay: options.maxDelayMs ?? 5_000,\n }),\n });\n\n return (next) => async (req) => retryPolicy.execute(() => next(req));\n}\n\nexport function isRetryEnabled(options: RetryOptions | undefined): options is RetryOptions {\n return !!options?.maxAttempts && !Number.isNaN(options.maxAttempts) && options.maxAttempts > 0;\n}\n\nexport interface RetryOptions {\n /**\n * Maximum number of attempts to make after first failure.\n * Maximum allowed value is 3.\n */\n maxAttempts: number;\n /**\n * Maximum delay between attempts in milliseconds. Used to restrict exponential backoff calculated value.\n * Default value is 5000ms.\n */\n maxDelayMs?: number;\n}\n\nconst RETRIABLE_NETWORK_ERROR_CODES = new Set([\n \"ECONNREFUSED\",\n \"ECONNRESET\",\n \"ETIMEDOUT\",\n \"ESOCKETTIMEDOUT\",\n \"UND_ERR_SOCKET\",\n]);\n\nfunction isConnectionError(error: Error): boolean {\n return (\"code\" in error && RETRIABLE_NETWORK_ERROR_CODES.has(error.code as string))\n || (!!error.cause && isConnectionError(error.cause as Error))\n || !!(error as Error & { errors?: Error[] }).errors?.some(isConnectionError)\n ;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,uBAIO;AAEP,4BAA+B;AAE/B,MAAM,wBAAwB,oBAAI,IAAI;AAAA,EACpC,qCAAe,KAAK;AAAA,EACpB,qCAAe,KAAK;AAAA,EACpB,qCAAe,KAAK;AAAA,EACpB,qCAAe,KAAK;AACtB,CAAC;AACM,SAAS,uBAAuB,SAAoC;AACzE,QAAM,kBAAc,4BAAM,6BAAW,CAAC,UAAW,iBAAiB,wCAAkB,sBAAsB,IAAI,MAAM,IAAI,KAAM,kBAAkB,KAAK,CAAC,GAAG;AAAA,IACvJ,aAAa,KAAK,IAAI,GAAG,QAAQ,WAAW;AAAA,IAC5C,SAAS,IAAI,oCAAmB;AAAA,MAC9B,cAAc;AAAA,MACd,UAAU,QAAQ,cAAc;AAAA,IAClC,CAAC;AAAA,EACH,CAAC;AAED,SAAO,CAAC,SAAS,OAAO,QAAQ,YAAY,QAAQ,MAAM,KAAK,GAAG,CAAC;AACrE;AAEO,SAAS,eAAe,SAA4D;AACzF,SAAO,CAAC,CAAC,SAAS,eAAe,CAAC,OAAO,MAAM,QAAQ,WAAW,KAAK,QAAQ,cAAc;AAC/F;AAeA,MAAM,gCAAgC,oBAAI,IAAI;AAAA,EAC5C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAED,SAAS,kBAAkB,OAAuB;AAChD,SAAQ,UAAU,SAAS,8BAA8B,IAAI,MAAM,IAAc,KAC3E,CAAC,CAAC,MAAM,SAAS,kBAAkB,MAAM,KAAc,KACxD,CAAC,CAAE,MAAuC,QAAQ,KAAK,iBAAiB;AAE/E;",
6
6
  "names": []
7
7
  }
@@ -452,9 +452,9 @@ const _SDL = class _SDL {
452
452
  computeEndpointSequenceNumbers(sdl) {
453
453
  return Object.fromEntries(
454
454
  Object.values(sdl.services).flatMap(
455
- (service) => service.expose.flatMap(
455
+ (service) => service.expose?.flatMap(
456
456
  (expose) => expose.to ? expose.to.filter((to) => to.global && to.ip?.length > 0).map((to) => to.ip).sort().map((ip, index) => [ip, index + 1]) : []
457
- )
457
+ ) ?? []
458
458
  )
459
459
  );
460
460
  }
@@ -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 || 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,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,YAAuB,0BACvB;AAHgB;AACA;AAhCb;AAmCH,UAAM,aAAS,gCAAY,MAA6B,SAAS;AACjE,QAAI,OAAQ,OAAM,IAAI,6CAAmB,OAAO,CAAC,EAAE,OAAO;AAAA,EAC5D;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;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,UAAU,IAAI,uBAAuB;AAE7E,sBAAU,KAAK,EAAE,MAAY,iBAAiB,EAAE,CAAC;AAAA,UACnD,CAAC;AAAA,QACL,CAAC;AAED,kBAAU,UAAU,YAAY;AAChC,cAAM,UAAU,KAAK,SAAS;AAAA,MAChC,CAAC;AAAA,IACH,CAAC;AAED,WAAO,OAAO,KAAK,MAAM,EACtB,KAAK,CAAC,GAAG,MAAO,IAAI,IAAI,IAAI,CAAE,EAC9B,IAAI,CAAC,SAAS,OAAO,IAAI,CAAC;AAAA,EAC/B;AAAA,EAkBA,qBAAqB;AACnB,UAAM,WAAW,KAAK,SAAS,IAAI;AACnC,QAAI,UAAU,KAAK,UAAU,QAAQ;AAErC,QAAI,SAAS;AACX,gBAAU,QAAQ,WAAW,oBAAuB,cAAiB;AAAA,IACvE;AAEA,WAAO,sBAAK,+BAAL,eAAiB,6BAAAC,SAAgB,KAAK,MAAM,OAAO,CAAC,KAAK;AAAA,EAClE;AAAA,EAEA,MAAM,kBAAkB;AACtB,UAAM,UAAU,KAAK,mBAAmB;AACxC,UAAM,MAAM,IAAI,YAAY;AAC5B,UAAM,cAAc,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;",
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,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,SA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,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
  }
@@ -36,10 +36,10 @@ var import_utils = require("../utils.cjs");
36
36
  var import_validateSDLInput = require("./validateSDLInput.cjs");
37
37
  var _endpointsUsed, _portsUsed, _sdl, _errors, _SDLValidator_instances, validateDenom_fn, findInvalidUsdcDenom_fn, validateDeploymentWithRelations_fn, validateDeploymentRelations_fn, validateServiceStorages_fn, validateStorages_fn, validateGPU_fn, validateLeaseIP_fn, validateEndpoints_fn;
38
38
  const ERROR_MESSAGES = {
39
- "#/definitions/storageAttributesValidation"(error) {
39
+ "#/definitions/storageRamClassMustNotBePersistent"(error) {
40
40
  return `"ram" storage${(0, import_jsonSchemaValidation.getErrorLocation)((0, import_jsonSchemaValidation.dirname)(error.instancePath))} cannot be persistent`;
41
41
  },
42
- "#/definitions/exposeToWithIpEnforcesGlobal/then/properties/global/const"() {
42
+ "#/definitions/exposeToWithIpEnforcesGlobal"() {
43
43
  return `If an IP is declared, the directive must be declared as global.`;
44
44
  }
45
45
  };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/sdl/validateSDL/validateSDL.ts"],
4
- "sourcesContent": ["import { type NetworkId, USDC_IBC_DENOMS } from \"../../network/index.ts\";\nimport type { ErrorMessages, ValidationError, ValidationFunction } from \"../../utils/jsonSchemaValidation.ts\";\nimport { dirname, getErrorLocation, humanizeErrors } from \"../../utils/jsonSchemaValidation.ts\";\nimport { castArray, stringToBoolean } from \"../utils.ts\";\nimport { schema as validationSDLSchema, type SDLInput, validate as validateSDLInput } from \"./validateSDLInput.ts\";\n\nexport type { SDLInput };\nexport { validationSDLSchema };\n\nconst ERROR_MESSAGES: ErrorMessages = {\n \"#/definitions/storageAttributesValidation\"(error) {\n return `\"ram\" storage${getErrorLocation(dirname(error.instancePath))} cannot be persistent`;\n },\n \"#/definitions/exposeToWithIpEnforcesGlobal/then/properties/global/const\"() {\n return `If an IP is declared, the directive must be declared as global.`;\n },\n};\n\nexport function validateSDL(sdl: SDLInput, networkId: NetworkId): undefined | ValidationError[] {\n validateSDLInput(sdl);\n const schemaErrors = humanizeErrors((validateSDLInput as ValidationFunction).errors, validationSDLSchema, ERROR_MESSAGES);\n if (schemaErrors.length) return schemaErrors;\n\n const validator = new SDLValidator(sdl);\n const errors = validator.validate(networkId);\n\n const allErrors = schemaErrors.concat(errors);\n return allErrors.length ? allErrors : undefined;\n}\n\nclass SDLValidator {\n readonly #endpointsUsed = new Set<string>();\n readonly #portsUsed = new Map<string, string>();\n readonly #sdl: SDLInput;\n readonly #errors: ValidationError[] = [];\n\n constructor(sdl: SDLInput) {\n this.#sdl = sdl;\n }\n\n validate(networkId: NetworkId) {\n if (this.#sdl.services) {\n Object.keys(this.#sdl.services).forEach((serviceName) => {\n this.#validateDeploymentWithRelations(serviceName);\n this.#validateLeaseIP(serviceName);\n });\n }\n\n this.#validateDenom(networkId);\n this.#validateEndpoints();\n return this.#errors;\n }\n\n #validateDenom(networkId: NetworkId) {\n if (!this.#sdl.profiles?.placement) return;\n\n const usdcDenom = USDC_IBC_DENOMS[networkId];\n const invalidDenom = this.#findInvalidUsdcDenom(usdcDenom);\n\n if (invalidDenom) {\n this.#errors.push({\n message: `Invalid format: \"denom\" at \"${invalidDenom.path}\" does not match pattern \"^(uakt|uact|${usdcDenom})$\"`,\n instancePath: invalidDenom.path,\n schemaPath: \"#/definitions/priceCoin/properties/denom\",\n keyword: \"pattern\",\n params: {\n pattern: \"^(uakt|uact|ibc/.*)$\",\n },\n });\n }\n }\n\n #findInvalidUsdcDenom(usdcDenom: string): { denom: string; path: string } | null {\n for (const [placementName, placement] of Object.entries(this.#sdl.profiles.placement)) {\n if (!placement.pricing) continue;\n for (const [profile, pricing] of Object.entries(placement.pricing)) {\n if (pricing.denom.startsWith(\"ibc/\") && pricing.denom !== usdcDenom) {\n return {\n path: `/profiles/placement/${placementName}/pricing/${profile}/denom`,\n denom: pricing.denom,\n };\n }\n }\n }\n\n return null;\n }\n\n #validateDeploymentWithRelations(serviceName: string) {\n const deployment = this.#sdl.deployment[serviceName];\n if (!deployment) {\n this.#errors.push({\n message: `Service \"${serviceName}\" is not defined at \"/deployment\" section.`,\n instancePath: `/deployment`,\n schemaPath: \"#/properties/deployment\",\n keyword: \"required\",\n params: {\n missingProperty: serviceName,\n },\n });\n return;\n }\n\n Object.keys(this.#sdl.deployment[serviceName]).forEach((deploymentName) => {\n this.#validateDeploymentRelations(serviceName, deploymentName);\n this.#validateServiceStorages(serviceName, deploymentName);\n this.#validateStorages(serviceName, deploymentName);\n this.#validateGPU(serviceName, deploymentName);\n });\n }\n\n #validateDeploymentRelations(serviceName: string, deploymentName: string) {\n const serviceDeployment = this.#sdl.deployment?.[serviceName]?.[deploymentName];\n const compute = this.#sdl.profiles?.compute?.[serviceDeployment?.profile];\n const infra = this.#sdl.profiles?.placement?.[deploymentName];\n\n if (!infra) {\n this.#errors.push({\n message: `The placement \"${deploymentName}\" is not defined in the \"placement\" section.`,\n instancePath: `/profiles/placement`,\n schemaPath: \"#/properties/profiles/properties/placement\",\n keyword: \"required\",\n params: {\n missingProperty: deploymentName,\n },\n });\n }\n\n if (infra && !infra.pricing?.[serviceDeployment?.profile]) {\n this.#errors.push({\n message: `The pricing for the \"${serviceDeployment?.profile}\" profile is not defined in the \"${deploymentName}\" placement.`,\n instancePath: `/profiles/placement/${deploymentName}/pricing`,\n schemaPath: \"#/properties/profiles/properties/placement/additionalProperties/properties/pricing\",\n keyword: \"required\",\n params: {\n missingProperty: serviceDeployment?.profile,\n },\n });\n }\n\n if (!compute) {\n this.#errors.push({\n message: `The compute requirements for the \"${serviceDeployment?.profile}\" profile are not defined in the \"compute\" section.`,\n instancePath: `/profiles/compute`,\n schemaPath: \"#/properties/profiles/properties/compute\",\n keyword: \"required\",\n params: {\n missingProperty: serviceDeployment?.profile,\n },\n });\n }\n }\n\n #validateServiceStorages(serviceName: string, deploymentName: string) {\n const service = this.#sdl.services?.[serviceName];\n const mounts: Record<string, string> = {};\n const serviceDeployment = this.#sdl.deployment[serviceName][deploymentName];\n const compute = this.#sdl.profiles?.compute?.[serviceDeployment.profile];\n const storages = castArray(compute?.resources.storage);\n\n if (!service?.params?.storage) {\n return;\n }\n\n Object.entries(service.params.storage).forEach(([storageName, storage]) => {\n if (!storage) {\n this.#errors.push({\n message: `Storage \"${storageName}\" is not configured.`,\n instancePath: `/services/${serviceName}/params/storage/${storageName}`,\n schemaPath: \"#/properties/services/additionalProperties/properties/params/properties/storage/additionalProperties\",\n keyword: \"required\",\n params: {\n missingProperty: storageName,\n },\n });\n return;\n }\n const storageNameExists = storages.some(({ name }) => name === storageName);\n if (!storageNameExists) {\n this.#errors.push({\n message: `Service \"${serviceName}\" references non-existing compute volume \"${storageName}\".`,\n instancePath: `/profiles/compute/${serviceDeployment.profile}/resources/storage`,\n schemaPath: \"#/properties/profiles/properties/compute/additionalProperties/properties/resources/properties/storage\",\n keyword: \"required\",\n params: {\n missingProperty: storageName,\n },\n });\n return;\n }\n\n const mount = String(storage.mount);\n const volumeName = mounts[mount];\n\n if (volumeName && !storage.mount) {\n this.#errors.push({\n message: \"Multiple root ephemeral storages are not allowed.\",\n instancePath: `/services/${serviceName}/params/storage/${storageName}`,\n schemaPath: \"#/properties/services/additionalProperties/properties/params/properties/storage\",\n keyword: \"uniqueItems\",\n params: {\n duplicate: volumeName,\n },\n });\n }\n if (volumeName && storage.mount) {\n this.#errors.push({\n message: `Mount \"${mount}\" already in use by volume \"${volumeName}\".`,\n instancePath: `/services/${serviceName}/params/storage/${storageName}/mount`,\n schemaPath: \"#/properties/services/additionalProperties/properties/params/properties/storage/additionalProperties/properties/mount\",\n keyword: \"uniqueItems\",\n params: {\n duplicate: mount,\n },\n });\n }\n\n mounts[mount] = storageName;\n });\n }\n\n #validateStorages(serviceName: string, deploymentName: string) {\n const service = this.#sdl.services?.[serviceName];\n const serviceDeployment = this.#sdl.deployment[serviceName][deploymentName];\n const compute = this.#sdl.profiles?.compute?.[serviceDeployment.profile];\n const storages = castArray(compute?.resources.storage);\n\n storages.forEach((storage) => {\n const persistent = stringToBoolean(storage.attributes?.persistent as string | boolean || false);\n\n if (persistent && !service?.params?.storage?.[storage.name || \"\"]?.mount) {\n this.#errors.push({\n message: `Persistent storage \"${storage.name || \"default\"}\" requires a mount path in /services/${serviceName}/params/storage/${storage.name || \"default\"}/mount.`,\n instancePath: `/services/${serviceName}/params/storage/${storage.name || \"default\"}`,\n schemaPath: \"#/properties/services/additionalProperties/properties/params/properties/storage/additionalProperties/properties/mount\",\n keyword: \"required\",\n params: {\n missingProperty: \"mount\",\n },\n });\n }\n });\n }\n\n #validateGPU(serviceName: string, deploymentName: string) {\n const deployment = this.#sdl.deployment[serviceName];\n const compute = this.#sdl.profiles?.compute?.[deployment[deploymentName]?.profile];\n const gpu = compute?.resources.gpu;\n if (!gpu) return;\n\n const hasUnits = gpu.units !== undefined && gpu.units !== 0;\n const hasAttributes = typeof gpu.attributes !== \"undefined\";\n const hasVendor = hasAttributes && typeof gpu.attributes?.vendor !== \"undefined\";\n\n const profile = deployment[deploymentName]?.profile;\n const gpuPath = `/profiles/compute/${profile}/resources/gpu`;\n\n if (!hasUnits && hasAttributes) {\n this.#errors.push({\n message: \"GPU must not have attributes if units is 0.\",\n instancePath: `${gpuPath}/attributes`,\n schemaPath: \"#/properties/profiles/properties/compute/additionalProperties/properties/resources/properties/gpu/properties/attributes\",\n keyword: \"additionalProperties\",\n params: {\n additionalProperty: \"attributes\",\n },\n });\n }\n if (hasUnits && !hasAttributes) {\n this.#errors.push({\n message: \"GPU must have attributes if units is not 0.\",\n instancePath: gpuPath,\n schemaPath: \"#/properties/profiles/properties/compute/additionalProperties/properties/resources/properties/gpu\",\n keyword: \"required\",\n params: {\n missingProperty: \"attributes\",\n },\n });\n }\n if (hasUnits && !hasVendor) {\n this.#errors.push({\n message: \"GPU must specify a vendor if units is not 0.\",\n instancePath: `${gpuPath}/attributes`,\n schemaPath: \"#/properties/profiles/properties/compute/additionalProperties/properties/resources/properties/gpu/properties/attributes/properties/vendor\",\n keyword: \"required\",\n params: {\n missingProperty: \"vendor\",\n },\n });\n }\n }\n\n #validateLeaseIP(serviceName: string) {\n this.#sdl.services?.[serviceName]?.expose?.forEach((expose, exposeIndex) => {\n const proto = expose.proto?.toUpperCase() || \"TCP\";\n\n expose.to?.forEach((to, toIndex) => {\n if (to.ip?.length) {\n const toPath = `/services/${serviceName}/expose/${exposeIndex}/to/${toIndex}`;\n\n if (!to.global) {\n this.#errors.push({\n message: `If an IP is declared, the directive must be declared as global.`,\n instancePath: `${toPath}/global`,\n schemaPath: \"#/definitions/exposeToWithIpEnforcesGlobal/then/properties/global/const\",\n keyword: \"const\",\n params: {\n allowedValue: true,\n },\n });\n }\n if (!this.#sdl.endpoints?.[to.ip]) {\n this.#errors.push({\n message: `Unknown endpoint \"${to.ip}\" for service \"${serviceName}\". Add it to the \"endpoints\" section.`,\n instancePath: `/endpoints/${to.ip}`,\n schemaPath: \"#/properties/endpoints\",\n keyword: \"required\",\n params: {\n missingProperty: to.ip,\n },\n });\n }\n\n this.#endpointsUsed.add(to.ip);\n\n const externalPort = expose.as ?? expose.port;\n const portKey = `${to.ip}-${externalPort}-${proto}`;\n const otherServiceName = this.#portsUsed.get(portKey);\n\n if (this.#portsUsed.has(portKey)) {\n this.#errors.push({\n message: `IP endpoint \"${to.ip}\" port ${externalPort} protocol ${proto} already in use by service \"${otherServiceName}\".`,\n instancePath: `${toPath}/ip`,\n schemaPath: \"#/properties/services/additionalProperties/properties/expose/items/properties/to/items\",\n keyword: \"uniqueItems\",\n params: {\n duplicate: portKey,\n },\n });\n }\n this.#portsUsed.set(portKey, serviceName);\n }\n });\n });\n }\n\n #validateEndpoints() {\n if (!this.#sdl.endpoints) return;\n\n Object.keys(this.#sdl.endpoints).forEach((endpoint) => {\n if (!this.#endpointsUsed.has(endpoint)) {\n this.#errors.push({\n message: `Endpoint \"${endpoint}\" declared but never used.`,\n instancePath: `/endpoints/${endpoint}`,\n schemaPath: \"#/properties/endpoints\",\n keyword: \"additionalProperties\",\n params: {\n additionalProperty: endpoint,\n },\n });\n }\n });\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA,qDAAAA;AAAA;AAAA;AAAA,qBAAgD;AAEhD,kCAA0D;AAC1D,mBAA2C;AAC3C,8BAA2F;AAJ3F;AASA,MAAM,iBAAgC;AAAA,EACpC,4CAA4C,OAAO;AACjD,WAAO,oBAAgB,kDAAiB,qCAAQ,MAAM,YAAY,CAAC,CAAC;AAAA,EACtE;AAAA,EACA,4EAA4E;AAC1E,WAAO;AAAA,EACT;AACF;AAEO,SAAS,YAAY,KAAe,WAAqD;AAC9F,8BAAAC,UAAiB,GAAG;AACpB,QAAM,mBAAe,4CAAgB,wBAAAA,SAAwC,QAAQ,wBAAAC,QAAqB,cAAc;AACxH,MAAI,aAAa,OAAQ,QAAO;AAEhC,QAAM,YAAY,IAAI,aAAa,GAAG;AACtC,QAAM,SAAS,UAAU,SAAS,SAAS;AAE3C,QAAM,YAAY,aAAa,OAAO,MAAM;AAC5C,SAAO,UAAU,SAAS,YAAY;AACxC;AAEA,MAAM,aAAa;AAAA,EAMjB,YAAY,KAAe;AAN7B;AACE,uBAAS,gBAAiB,oBAAI,IAAY;AAC1C,uBAAS,YAAa,oBAAI,IAAoB;AAC9C,uBAAS;AACT,uBAAS,SAA6B,CAAC;AAGrC,uBAAK,MAAO;AAAA,EACd;AAAA,EAEA,SAAS,WAAsB;AAC7B,QAAI,mBAAK,MAAK,UAAU;AACtB,aAAO,K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,KAAK;AAAA,QAChB,SAAS,aAAa,QAAQ;AAAA,QAC9B,cAAc,cAAc,QAAQ;AAAA,QACpC,YAAY;AAAA,QACZ,SAAS;AAAA,QACT,QAAQ;AAAA,UACN,oBAAoB;AAAA,QACtB;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF,CAAC;AACH;",
4
+ "sourcesContent": ["import { type NetworkId, USDC_IBC_DENOMS } from \"../../network/index.ts\";\nimport type { ErrorMessages, ValidationError, ValidationFunction } from \"../../utils/jsonSchemaValidation.ts\";\nimport { dirname, getErrorLocation, humanizeErrors } from \"../../utils/jsonSchemaValidation.ts\";\nimport { castArray, stringToBoolean } from \"../utils.ts\";\nimport { schema as validationSDLSchema, type SDLInput, validate as validateSDLInput } from \"./validateSDLInput.ts\";\n\nexport type { SDLInput };\nexport { validationSDLSchema };\n\nconst ERROR_MESSAGES: ErrorMessages = {\n \"#/definitions/storageRamClassMustNotBePersistent\"(error) {\n return `\"ram\" storage${getErrorLocation(dirname(error.instancePath))} cannot be persistent`;\n },\n \"#/definitions/exposeToWithIpEnforcesGlobal\"() {\n return `If an IP is declared, the directive must be declared as global.`;\n },\n};\n\nexport function validateSDL(sdl: SDLInput, networkId: NetworkId): undefined | ValidationError[] {\n validateSDLInput(sdl);\n const schemaErrors = humanizeErrors((validateSDLInput as ValidationFunction).errors, validationSDLSchema, ERROR_MESSAGES);\n if (schemaErrors.length) return schemaErrors;\n\n const validator = new SDLValidator(sdl);\n const errors = validator.validate(networkId);\n\n const allErrors = schemaErrors.concat(errors);\n return allErrors.length ? allErrors : undefined;\n}\n\nclass SDLValidator {\n readonly #endpointsUsed = new Set<string>();\n readonly #portsUsed = new Map<string, string>();\n readonly #sdl: SDLInput;\n readonly #errors: ValidationError[] = [];\n\n constructor(sdl: SDLInput) {\n this.#sdl = sdl;\n }\n\n validate(networkId: NetworkId) {\n if (this.#sdl.services) {\n Object.keys(this.#sdl.services).forEach((serviceName) => {\n this.#validateDeploymentWithRelations(serviceName);\n this.#validateLeaseIP(serviceName);\n });\n }\n\n this.#validateDenom(networkId);\n this.#validateEndpoints();\n return this.#errors;\n }\n\n #validateDenom(networkId: NetworkId) {\n if (!this.#sdl.profiles?.placement) return;\n\n const usdcDenom = USDC_IBC_DENOMS[networkId];\n const invalidDenom = this.#findInvalidUsdcDenom(usdcDenom);\n\n if (invalidDenom) {\n this.#errors.push({\n message: `Invalid format: \"denom\" at \"${invalidDenom.path}\" does not match pattern \"^(uakt|uact|${usdcDenom})$\"`,\n instancePath: invalidDenom.path,\n schemaPath: \"#/definitions/priceCoin/properties/denom\",\n keyword: \"pattern\",\n params: {\n pattern: \"^(uakt|uact|ibc/.*)$\",\n },\n });\n }\n }\n\n #findInvalidUsdcDenom(usdcDenom: string): { denom: string; path: string } | null {\n for (const [placementName, placement] of Object.entries(this.#sdl.profiles.placement)) {\n if (!placement.pricing) continue;\n for (const [profile, pricing] of Object.entries(placement.pricing)) {\n if (pricing.denom.startsWith(\"ibc/\") && pricing.denom !== usdcDenom) {\n return {\n path: `/profiles/placement/${placementName}/pricing/${profile}/denom`,\n denom: pricing.denom,\n };\n }\n }\n }\n\n return null;\n }\n\n #validateDeploymentWithRelations(serviceName: string) {\n const deployment = this.#sdl.deployment[serviceName];\n if (!deployment) {\n this.#errors.push({\n message: `Service \"${serviceName}\" is not defined at \"/deployment\" section.`,\n instancePath: `/deployment`,\n schemaPath: \"#/properties/deployment\",\n keyword: \"required\",\n params: {\n missingProperty: serviceName,\n },\n });\n return;\n }\n\n Object.keys(this.#sdl.deployment[serviceName]).forEach((deploymentName) => {\n this.#validateDeploymentRelations(serviceName, deploymentName);\n this.#validateServiceStorages(serviceName, deploymentName);\n this.#validateStorages(serviceName, deploymentName);\n this.#validateGPU(serviceName, deploymentName);\n });\n }\n\n #validateDeploymentRelations(serviceName: string, deploymentName: string) {\n const serviceDeployment = this.#sdl.deployment?.[serviceName]?.[deploymentName];\n const compute = this.#sdl.profiles?.compute?.[serviceDeployment?.profile];\n const infra = this.#sdl.profiles?.placement?.[deploymentName];\n\n if (!infra) {\n this.#errors.push({\n message: `The placement \"${deploymentName}\" is not defined in the \"placement\" section.`,\n instancePath: `/profiles/placement`,\n schemaPath: \"#/properties/profiles/properties/placement\",\n keyword: \"required\",\n params: {\n missingProperty: deploymentName,\n },\n });\n }\n\n if (infra && !infra.pricing?.[serviceDeployment?.profile]) {\n this.#errors.push({\n message: `The pricing for the \"${serviceDeployment?.profile}\" profile is not defined in the \"${deploymentName}\" placement.`,\n instancePath: `/profiles/placement/${deploymentName}/pricing`,\n schemaPath: \"#/properties/profiles/properties/placement/additionalProperties/properties/pricing\",\n keyword: \"required\",\n params: {\n missingProperty: serviceDeployment?.profile,\n },\n });\n }\n\n if (!compute) {\n this.#errors.push({\n message: `The compute requirements for the \"${serviceDeployment?.profile}\" profile are not defined in the \"compute\" section.`,\n instancePath: `/profiles/compute`,\n schemaPath: \"#/properties/profiles/properties/compute\",\n keyword: \"required\",\n params: {\n missingProperty: serviceDeployment?.profile,\n },\n });\n }\n }\n\n #validateServiceStorages(serviceName: string, deploymentName: string) {\n const service = this.#sdl.services?.[serviceName];\n const mounts: Record<string, string> = {};\n const serviceDeployment = this.#sdl.deployment[serviceName][deploymentName];\n const compute = this.#sdl.profiles?.compute?.[serviceDeployment.profile];\n const storages = castArray(compute?.resources.storage);\n\n if (!service?.params?.storage) {\n return;\n }\n\n Object.entries(service.params.storage).forEach(([storageName, storage]) => {\n if (!storage) {\n this.#errors.push({\n message: `Storage \"${storageName}\" is not configured.`,\n instancePath: `/services/${serviceName}/params/storage/${storageName}`,\n schemaPath: \"#/properties/services/additionalProperties/properties/params/properties/storage/additionalProperties\",\n keyword: \"required\",\n params: {\n missingProperty: storageName,\n },\n });\n return;\n }\n const storageNameExists = storages.some(({ name }) => name === storageName);\n if (!storageNameExists) {\n this.#errors.push({\n message: `Service \"${serviceName}\" references non-existing compute volume \"${storageName}\".`,\n instancePath: `/profiles/compute/${serviceDeployment.profile}/resources/storage`,\n schemaPath: \"#/properties/profiles/properties/compute/additionalProperties/properties/resources/properties/storage\",\n keyword: \"required\",\n params: {\n missingProperty: storageName,\n },\n });\n return;\n }\n\n const mount = String(storage.mount);\n const volumeName = mounts[mount];\n\n if (volumeName && !storage.mount) {\n this.#errors.push({\n message: \"Multiple root ephemeral storages are not allowed.\",\n instancePath: `/services/${serviceName}/params/storage/${storageName}`,\n schemaPath: \"#/properties/services/additionalProperties/properties/params/properties/storage\",\n keyword: \"uniqueItems\",\n params: {\n duplicate: volumeName,\n },\n });\n }\n if (volumeName && storage.mount) {\n this.#errors.push({\n message: `Mount \"${mount}\" already in use by volume \"${volumeName}\".`,\n instancePath: `/services/${serviceName}/params/storage/${storageName}/mount`,\n schemaPath: \"#/properties/services/additionalProperties/properties/params/properties/storage/additionalProperties/properties/mount\",\n keyword: \"uniqueItems\",\n params: {\n duplicate: mount,\n },\n });\n }\n\n mounts[mount] = storageName;\n });\n }\n\n #validateStorages(serviceName: string, deploymentName: string) {\n const service = this.#sdl.services?.[serviceName];\n const serviceDeployment = this.#sdl.deployment[serviceName][deploymentName];\n const compute = this.#sdl.profiles?.compute?.[serviceDeployment.profile];\n const storages = castArray(compute?.resources.storage);\n\n storages.forEach((storage) => {\n const persistent = stringToBoolean(storage.attributes?.persistent as string | boolean || false);\n\n if (persistent && !service?.params?.storage?.[storage.name || \"\"]?.mount) {\n this.#errors.push({\n message: `Persistent storage \"${storage.name || \"default\"}\" requires a mount path in /services/${serviceName}/params/storage/${storage.name || \"default\"}/mount.`,\n instancePath: `/services/${serviceName}/params/storage/${storage.name || \"default\"}`,\n schemaPath: \"#/properties/services/additionalProperties/properties/params/properties/storage/additionalProperties/properties/mount\",\n keyword: \"required\",\n params: {\n missingProperty: \"mount\",\n },\n });\n }\n });\n }\n\n #validateGPU(serviceName: string, deploymentName: string) {\n const deployment = this.#sdl.deployment[serviceName];\n const compute = this.#sdl.profiles?.compute?.[deployment[deploymentName]?.profile];\n const gpu = compute?.resources.gpu;\n if (!gpu) return;\n\n const hasUnits = gpu.units !== undefined && gpu.units !== 0;\n const hasAttributes = typeof gpu.attributes !== \"undefined\";\n const hasVendor = hasAttributes && typeof gpu.attributes?.vendor !== \"undefined\";\n\n const profile = deployment[deploymentName]?.profile;\n const gpuPath = `/profiles/compute/${profile}/resources/gpu`;\n\n if (!hasUnits && hasAttributes) {\n this.#errors.push({\n message: \"GPU must not have attributes if units is 0.\",\n instancePath: `${gpuPath}/attributes`,\n schemaPath: \"#/properties/profiles/properties/compute/additionalProperties/properties/resources/properties/gpu/properties/attributes\",\n keyword: \"additionalProperties\",\n params: {\n additionalProperty: \"attributes\",\n },\n });\n }\n if (hasUnits && !hasAttributes) {\n this.#errors.push({\n message: \"GPU must have attributes if units is not 0.\",\n instancePath: gpuPath,\n schemaPath: \"#/properties/profiles/properties/compute/additionalProperties/properties/resources/properties/gpu\",\n keyword: \"required\",\n params: {\n missingProperty: \"attributes\",\n },\n });\n }\n if (hasUnits && !hasVendor) {\n this.#errors.push({\n message: \"GPU must specify a vendor if units is not 0.\",\n instancePath: `${gpuPath}/attributes`,\n schemaPath: \"#/properties/profiles/properties/compute/additionalProperties/properties/resources/properties/gpu/properties/attributes/properties/vendor\",\n keyword: \"required\",\n params: {\n missingProperty: \"vendor\",\n },\n });\n }\n }\n\n #validateLeaseIP(serviceName: string) {\n this.#sdl.services?.[serviceName]?.expose?.forEach((expose, exposeIndex) => {\n const proto = expose.proto?.toUpperCase() || \"TCP\";\n\n expose.to?.forEach((to, toIndex) => {\n if (to.ip?.length) {\n const toPath = `/services/${serviceName}/expose/${exposeIndex}/to/${toIndex}`;\n\n if (!to.global) {\n this.#errors.push({\n message: `If an IP is declared, the directive must be declared as global.`,\n instancePath: `${toPath}/global`,\n schemaPath: \"#/definitions/exposeToWithIpEnforcesGlobal/then/properties/global/const\",\n keyword: \"const\",\n params: {\n allowedValue: true,\n },\n });\n }\n if (!this.#sdl.endpoints?.[to.ip]) {\n this.#errors.push({\n message: `Unknown endpoint \"${to.ip}\" for service \"${serviceName}\". Add it to the \"endpoints\" section.`,\n instancePath: `/endpoints/${to.ip}`,\n schemaPath: \"#/properties/endpoints\",\n keyword: \"required\",\n params: {\n missingProperty: to.ip,\n },\n });\n }\n\n this.#endpointsUsed.add(to.ip);\n\n const externalPort = expose.as ?? expose.port;\n const portKey = `${to.ip}-${externalPort}-${proto}`;\n const otherServiceName = this.#portsUsed.get(portKey);\n\n if (this.#portsUsed.has(portKey)) {\n this.#errors.push({\n message: `IP endpoint \"${to.ip}\" port ${externalPort} protocol ${proto} already in use by service \"${otherServiceName}\".`,\n instancePath: `${toPath}/ip`,\n schemaPath: \"#/properties/services/additionalProperties/properties/expose/items/properties/to/items\",\n keyword: \"uniqueItems\",\n params: {\n duplicate: portKey,\n },\n });\n }\n this.#portsUsed.set(portKey, serviceName);\n }\n });\n });\n }\n\n #validateEndpoints() {\n if (!this.#sdl.endpoints) return;\n\n Object.keys(this.#sdl.endpoints).forEach((endpoint) => {\n if (!this.#endpointsUsed.has(endpoint)) {\n this.#errors.push({\n message: `Endpoint \"${endpoint}\" declared but never used.`,\n instancePath: `/endpoints/${endpoint}`,\n schemaPath: \"#/properties/endpoints\",\n keyword: \"additionalProperties\",\n params: {\n additionalProperty: endpoint,\n },\n });\n }\n });\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA,qDAAAA;AAAA;AAAA;AAAA,qBAAgD;AAEhD,kCAA0D;AAC1D,mBAA2C;AAC3C,8BAA2F;AAJ3F;AASA,MAAM,iBAAgC;AAAA,EACpC,mDAAmD,OAAO;AACxD,WAAO,oBAAgB,kDAAiB,qCAAQ,MAAM,YAAY,CAAC,CAAC;AAAA,EACtE;AAAA,EACA,+CAA+C;AAC7C,WAAO;AAAA,EACT;AACF;AAEO,SAAS,YAAY,KAAe,WAAqD;AAC9F,8BAAAC,UAAiB,GAAG;AACpB,QAAM,mBAAe,4CAAgB,wBAAAA,SAAwC,QAAQ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