From 391927df37e551c83077b0b8b02c8fce98bf07f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vinko=20=C5=A0mid?= Date: Mon, 7 Oct 2024 15:22:19 +0200 Subject: [PATCH 1/6] Indexer deploy added to SDK & CLI --- apillon-sdk.code-workspace | 3 +- package-lock.json | 611 ++++++++++++++++-- .../src/modules/indexing/indexing.commands.ts | 19 + .../src/modules/indexing/indexing.service.ts | 15 + packages/sdk/package.json | 5 +- packages/sdk/src/index.ts | 2 + packages/sdk/src/modules/indexing/indexer.ts | 57 ++ packages/sdk/src/modules/indexing/indexing.ts | 12 + packages/sdk/src/tests/indexing.test.ts | 16 + packages/sdk/src/types/indexer.ts | 20 + packages/sdk/src/util/indexer-utils.ts | 116 ++++ 11 files changed, 807 insertions(+), 69 deletions(-) create mode 100644 packages/cli/src/modules/indexing/indexing.commands.ts create mode 100644 packages/cli/src/modules/indexing/indexing.service.ts create mode 100644 packages/sdk/src/modules/indexing/indexer.ts create mode 100644 packages/sdk/src/modules/indexing/indexing.ts create mode 100644 packages/sdk/src/tests/indexing.test.ts create mode 100644 packages/sdk/src/types/indexer.ts create mode 100644 packages/sdk/src/util/indexer-utils.ts diff --git a/apillon-sdk.code-workspace b/apillon-sdk.code-workspace index babfce6..a05d380 100644 --- a/apillon-sdk.code-workspace +++ b/apillon-sdk.code-workspace @@ -42,6 +42,7 @@ "**/.serverless": true, "**/.turbo": true, "**/node_modules": false - } + }, + "nuxt.isNuxtApp": false } } \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index f1c9354..3459bf3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -794,7 +794,6 @@ "version": "8.0.2", "resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz", "integrity": "sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==", - "dev": true, "dependencies": { "string-width": "^5.1.2", "string-width-cjs": "npm:string-width@^4.2.0", @@ -811,7 +810,6 @@ "version": "6.0.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz", "integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==", - "dev": true, "engines": { "node": ">=12" }, @@ -823,7 +821,6 @@ "version": "7.1.0", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", - "dev": true, "dependencies": { "ansi-regex": "^6.0.1" }, @@ -2426,6 +2423,42 @@ "node": ">=8" } }, + "node_modules/bl": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/bl/-/bl-1.2.3.tgz", + "integrity": "sha512-pvcNpa0UU69UT341rO6AYy4FVAIkUHuZXRIWbq+zHnsVcRzDDjIAhGuuYoi0d//cwIwtt4pkpKycWEfjdV+vww==", + "dependencies": { + "readable-stream": "^2.3.5", + "safe-buffer": "^5.1.1" + } + }, + "node_modules/bl/node_modules/readable-stream": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.8.tgz", + "integrity": "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==", + "dependencies": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "node_modules/bl/node_modules/safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + }, + "node_modules/bl/node_modules/string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dependencies": { + "safe-buffer": "~5.1.0" + } + }, "node_modules/blakejs": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/blakejs/-/blakejs-1.2.1.tgz", @@ -2440,7 +2473,6 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", - "dev": true, "dependencies": { "balanced-match": "^1.0.0" } @@ -2545,6 +2577,25 @@ "node-int64": "^0.4.0" } }, + "node_modules/buffer-alloc": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/buffer-alloc/-/buffer-alloc-1.2.0.tgz", + "integrity": "sha512-CFsHQgjtW1UChdXgbyJGtnm+O/uLQeZdtbDo8mfUgYXCHSM1wgrVxXm6bSyrUuErEb+4sYVGCzASBRot7zyrow==", + "dependencies": { + "buffer-alloc-unsafe": "^1.1.0", + "buffer-fill": "^1.0.0" + } + }, + "node_modules/buffer-alloc-unsafe": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/buffer-alloc-unsafe/-/buffer-alloc-unsafe-1.1.0.tgz", + "integrity": "sha512-TEM2iMIEQdJ2yjPJoSIsldnleVaAk1oW3DBVUykyOLsEsFmEc9kn+SFFPz+gl54KQNxlDnAwCXosOS9Okx2xAg==" + }, + "node_modules/buffer-fill": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/buffer-fill/-/buffer-fill-1.0.0.tgz", + "integrity": "sha512-T7zexNBwiiaCOGDg9xNX9PBmjrubblRkENuptryuI64URkXDFum9il/JGL8Lm8wYfAXpredVXXZz7eMHilimiQ==" + }, "node_modules/buffer-from": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", @@ -2656,6 +2707,11 @@ "node": ">= 6" } }, + "node_modules/chownr": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz", + "integrity": "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==" + }, "node_modules/ci-info": { "version": "3.8.0", "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.8.0.tgz", @@ -2799,6 +2855,11 @@ "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", "dev": true }, + "node_modules/core-util-is": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", + "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==" + }, "node_modules/create-hash": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz", @@ -2980,8 +3041,7 @@ "node_modules/eastasianwidth": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", - "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==", - "dev": true + "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==" }, "node_modules/electron-to-chromium": { "version": "1.4.537", @@ -3023,8 +3083,15 @@ "node_modules/emoji-regex": { "version": "9.2.2", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", - "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==", - "dev": true + "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==" + }, + "node_modules/end-of-stream": { + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", + "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==", + "dependencies": { + "once": "^1.4.0" + } }, "node_modules/error-ex": { "version": "1.3.2", @@ -3646,7 +3713,6 @@ "version": "3.1.1", "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.1.1.tgz", "integrity": "sha512-TMKDUnIte6bfb5nWv7V/caI169OHgvwjb7V4WkeUvbQQdjr5rWKqHFiKWb/fcOwB+CzBT+qbWjvj+DVwRskpIg==", - "dev": true, "dependencies": { "cross-spawn": "^7.0.0", "signal-exit": "^4.0.1" @@ -3671,6 +3737,11 @@ "node": ">= 6" } }, + "node_modules/fs-constants": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz", + "integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==" + }, "node_modules/fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", @@ -3991,7 +4062,6 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", - "dev": true, "engines": { "node": ">=8" } @@ -4044,6 +4114,11 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==" + }, "node_modules/isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", @@ -5065,15 +5140,33 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/minimist": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", + "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/minipass": { - "version": "7.0.4", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.0.4.tgz", - "integrity": "sha512-jYofLM5Dam9279rdkWzqHozUo4ybjdZmCsDHePy5V/PbBcVMiSZR97gmAy45aqi8CK1lG2ECd356FU86avfwUQ==", - "dev": true, + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.2.tgz", + "integrity": "sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==", "engines": { "node": ">=16 || 14 >=14.17" } }, + "node_modules/mkdirp": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", + "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", + "dependencies": { + "minimist": "^1.2.6" + }, + "bin": { + "mkdirp": "bin/cmd.js" + } + }, "node_modules/ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", @@ -5299,6 +5392,11 @@ "node": ">=6" } }, + "node_modules/package-json-from-dist": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.1.tgz", + "integrity": "sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw==" + }, "node_modules/parent-module": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", @@ -5546,6 +5644,11 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, + "node_modules/process-nextick-args": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==" + }, "node_modules/prompts": { "version": "2.4.2", "resolved": "https://registry.npmjs.org/prompts/-/prompts-2.4.2.tgz", @@ -5570,6 +5673,15 @@ "integrity": "sha512-77DZwxQmxKnu3aR542U+X8FypNzbfJ+C5XQDk3uWjWxn6151aIMGthWYRXTqT1E5oJvg+ljaa2OJi+VfvCOQ8w==", "dev": true }, + "node_modules/pump": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/pump/-/pump-1.0.3.tgz", + "integrity": "sha512-8k0JupWme55+9tCVE+FS5ULT3K6AbgqrGa58lTT49RpyfwwcGedHqaC5LlQNdEAumn/wFsu6aPwkuPMioy8kqw==", + "dependencies": { + "end-of-stream": "^1.1.0", + "once": "^1.3.1" + } + }, "node_modules/punycode": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.0.tgz", @@ -5916,7 +6028,6 @@ "version": "4.1.0", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", - "dev": true, "engines": { "node": ">=14" }, @@ -6021,7 +6132,6 @@ "version": "5.1.2", "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz", "integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==", - "dev": true, "dependencies": { "eastasianwidth": "^0.2.0", "emoji-regex": "^9.2.2", @@ -6039,7 +6149,6 @@ "version": "4.2.3", "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dev": true, "dependencies": { "emoji-regex": "^8.0.0", "is-fullwidth-code-point": "^3.0.0", @@ -6052,14 +6161,12 @@ "node_modules/string-width-cjs/node_modules/emoji-regex": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "dev": true + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" }, "node_modules/string-width/node_modules/ansi-regex": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz", "integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==", - "dev": true, "engines": { "node": ">=12" }, @@ -6071,7 +6178,6 @@ "version": "7.1.0", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", - "dev": true, "dependencies": { "ansi-regex": "^6.0.1" }, @@ -6098,7 +6204,6 @@ "version": "6.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dev": true, "dependencies": { "ansi-regex": "^5.0.1" }, @@ -6158,6 +6263,69 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/tar-fs": { + "version": "1.16.3", + "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-1.16.3.tgz", + "integrity": "sha512-NvCeXpYx7OsmOh8zIOP/ebG55zZmxLE0etfWRbWok+q2Qo8x/vOR/IJT1taADXPe+jsiu9axDb3X4B+iIgNlKw==", + "dependencies": { + "chownr": "^1.0.1", + "mkdirp": "^0.5.1", + "pump": "^1.0.0", + "tar-stream": "^1.1.2" + } + }, + "node_modules/tar-stream": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-1.6.2.tgz", + "integrity": "sha512-rzS0heiNf8Xn7/mpdSVVSMAWAoy9bfb1WOTYC78Z0UQKeKa/CWS8FOq0lKGNa8DWKAn9gxjCvMLYc5PGXYlK2A==", + "dependencies": { + "bl": "^1.0.0", + "buffer-alloc": "^1.2.0", + "end-of-stream": "^1.0.0", + "fs-constants": "^1.0.0", + "readable-stream": "^2.3.0", + "to-buffer": "^1.1.1", + "xtend": "^4.0.0" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/tar-stream/node_modules/readable-stream": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.8.tgz", + "integrity": "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==", + "dependencies": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "node_modules/tar-stream/node_modules/safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + }, + "node_modules/tar-stream/node_modules/string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dependencies": { + "safe-buffer": "~5.1.0" + } + }, + "node_modules/targz": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/targz/-/targz-1.0.1.tgz", + "integrity": "sha512-6q4tP9U55mZnRuMTBqnqc3nwYQY3kv+QthCFZuMk+Tn1qYUnMPmL/JZ/mzgXINzFpSqfU+242IFmFU9VPvqaQw==", + "dependencies": { + "tar-fs": "^1.8.1" + } + }, "node_modules/test-exclude": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-6.0.0.tgz", @@ -6225,6 +6393,11 @@ "integrity": "sha512-3f0uOEAQwIqGuWW2MVzYg8fV/QNnc/IpuJNG837rLuczAaLVHslWHZQj4IGiEl5Hs3kkbhwL9Ab7Hrsmuj+Smw==", "dev": true }, + "node_modules/to-buffer": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/to-buffer/-/to-buffer-1.1.1.tgz", + "integrity": "sha512-lx9B5iv7msuFYE3dytT+KE5tap+rNYw+K4jVkb9R/asAb+pbBSM17jtunHplhBe6RRJdZx3Pn2Jph24O32mOVg==" + }, "node_modules/to-fast-properties": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", @@ -6657,7 +6830,6 @@ "version": "8.1.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz", "integrity": "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==", - "dev": true, "dependencies": { "ansi-styles": "^6.1.0", "string-width": "^5.0.1", @@ -6675,7 +6847,6 @@ "version": "7.0.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", - "dev": true, "dependencies": { "ansi-styles": "^4.0.0", "string-width": "^4.1.0", @@ -6691,14 +6862,12 @@ "node_modules/wrap-ansi-cjs/node_modules/emoji-regex": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "dev": true + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" }, "node_modules/wrap-ansi-cjs/node_modules/string-width": { "version": "4.2.3", "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dev": true, "dependencies": { "emoji-regex": "^8.0.0", "is-fullwidth-code-point": "^3.0.0", @@ -6712,7 +6881,6 @@ "version": "6.0.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz", "integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==", - "dev": true, "engines": { "node": ">=12" }, @@ -6724,7 +6892,6 @@ "version": "6.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.1.tgz", "integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==", - "dev": true, "engines": { "node": ">=12" }, @@ -6736,7 +6903,6 @@ "version": "7.1.0", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", - "dev": true, "dependencies": { "ansi-regex": "^6.0.1" }, @@ -6792,6 +6958,14 @@ } } }, + "node_modules/xtend": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", + "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==", + "engines": { + "node": ">=0.4" + } + }, "node_modules/y18n": { "version": "5.0.8", "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", @@ -6919,7 +7093,10 @@ "dependencies": { "@polkadot/util-crypto": "^12.6.2", "axios": "^1.6.8", - "ethereumjs-util": "^7.1.5" + "ethereumjs-util": "^7.1.5", + "glob": "^11.0.0", + "ignore": "^6.0.2", + "targz": "^1.0.1" }, "devDependencies": { "@polkadot/keyring": "^12.6.2", @@ -6934,6 +7111,87 @@ "typedoc": "^0.25.13" } }, + "packages/sdk/node_modules/glob": { + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-11.0.0.tgz", + "integrity": "sha512-9UiX/Bl6J2yaBbxKoEBRm4Cipxgok8kQYcOPEhScPwebu2I0HoQOuYdIO6S3hLuWoZgpDpwQZMzTFxgpkyT76g==", + "dependencies": { + "foreground-child": "^3.1.0", + "jackspeak": "^4.0.1", + "minimatch": "^10.0.0", + "minipass": "^7.1.2", + "package-json-from-dist": "^1.0.0", + "path-scurry": "^2.0.0" + }, + "bin": { + "glob": "dist/esm/bin.mjs" + }, + "engines": { + "node": "20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "packages/sdk/node_modules/ignore": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-6.0.2.tgz", + "integrity": "sha512-InwqeHHN2XpumIkMvpl/DCJVrAHgCsG5+cn1XlnLWGwtZBm8QJfSusItfrwx81CTp5agNZqpKU2J/ccC5nGT4A==", + "engines": { + "node": ">= 4" + } + }, + "packages/sdk/node_modules/jackspeak": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-4.0.2.tgz", + "integrity": "sha512-bZsjR/iRjl1Nk1UkjGpAzLNfQtzuijhn2g+pbZb98HQ1Gk8vM9hfbxeMBP+M2/UUdwj0RqGG3mlvk2MsAqwvEw==", + "dependencies": { + "@isaacs/cliui": "^8.0.2" + }, + "engines": { + "node": "20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "packages/sdk/node_modules/lru-cache": { + "version": "11.0.1", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.0.1.tgz", + "integrity": "sha512-CgeuL5uom6j/ZVrg7G/+1IXqRY8JXX4Hghfy5YE0EhoYQWvndP1kufu58cmZLNIDKnRhZrXfdS9urVWx98AipQ==", + "engines": { + "node": "20 || >=22" + } + }, + "packages/sdk/node_modules/minimatch": { + "version": "10.0.1", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.0.1.tgz", + "integrity": "sha512-ethXTt3SGGR+95gudmqJ1eNhRO7eGEGIgYA9vnPatK4/etz2MEVDno5GMCibdMTuBMyElzIlgxMna3K94XDIDQ==", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": "20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "packages/sdk/node_modules/path-scurry": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-2.0.0.tgz", + "integrity": "sha512-ypGJsmGtdXUOeM5u93TyeIEfEhM6s+ljAhrk5vAvSx8uyY/02OvrZnA0YNGUrPXfpJMgI1ODd3nwz8Npx4O4cg==", + "dependencies": { + "lru-cache": "^11.0.0", + "minipass": "^7.1.2" + }, + "engines": { + "node": "20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "packages/tsconfig": { "version": "0.0.0" } @@ -6980,11 +7238,64 @@ "eslint-config-common": "*", "ethereumjs-util": "^7.1.5", "ethers": "^6.12.0", + "glob": "^11.0.0", + "ignore": "^6.0.2", "nodemon": "^3.1.0", "rimraf": "^5.0.5", + "targz": "^1.0.1", "ts-node": "^10.9.2", "tsconfig": "*", "typedoc": "^0.25.13" + }, + "dependencies": { + "glob": { + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-11.0.0.tgz", + "integrity": "sha512-9UiX/Bl6J2yaBbxKoEBRm4Cipxgok8kQYcOPEhScPwebu2I0HoQOuYdIO6S3hLuWoZgpDpwQZMzTFxgpkyT76g==", + "requires": { + "foreground-child": "^3.1.0", + "jackspeak": "^4.0.1", + "minimatch": "^10.0.0", + "minipass": "^7.1.2", + "package-json-from-dist": "^1.0.0", + "path-scurry": "^2.0.0" + } + }, + "ignore": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-6.0.2.tgz", + "integrity": "sha512-InwqeHHN2XpumIkMvpl/DCJVrAHgCsG5+cn1XlnLWGwtZBm8QJfSusItfrwx81CTp5agNZqpKU2J/ccC5nGT4A==" + }, + "jackspeak": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-4.0.2.tgz", + "integrity": "sha512-bZsjR/iRjl1Nk1UkjGpAzLNfQtzuijhn2g+pbZb98HQ1Gk8vM9hfbxeMBP+M2/UUdwj0RqGG3mlvk2MsAqwvEw==", + "requires": { + "@isaacs/cliui": "^8.0.2" + } + }, + "lru-cache": { + "version": "11.0.1", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.0.1.tgz", + "integrity": "sha512-CgeuL5uom6j/ZVrg7G/+1IXqRY8JXX4Hghfy5YE0EhoYQWvndP1kufu58cmZLNIDKnRhZrXfdS9urVWx98AipQ==" + }, + "minimatch": { + "version": "10.0.1", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.0.1.tgz", + "integrity": "sha512-ethXTt3SGGR+95gudmqJ1eNhRO7eGEGIgYA9vnPatK4/etz2MEVDno5GMCibdMTuBMyElzIlgxMna3K94XDIDQ==", + "requires": { + "brace-expansion": "^2.0.1" + } + }, + "path-scurry": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-2.0.0.tgz", + "integrity": "sha512-ypGJsmGtdXUOeM5u93TyeIEfEhM6s+ljAhrk5vAvSx8uyY/02OvrZnA0YNGUrPXfpJMgI1ODd3nwz8Npx4O4cg==", + "requires": { + "lru-cache": "^11.0.0", + "minipass": "^7.1.2" + } + } } }, "@babel/code-frame": { @@ -7555,7 +7866,6 @@ "version": "8.0.2", "resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz", "integrity": "sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==", - "dev": true, "requires": { "string-width": "^5.1.2", "string-width-cjs": "npm:string-width@^4.2.0", @@ -7568,14 +7878,12 @@ "ansi-regex": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz", - "integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==", - "dev": true + "integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==" }, "strip-ansi": { "version": "7.1.0", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", - "dev": true, "requires": { "ansi-regex": "^6.0.1" } @@ -8844,6 +9152,44 @@ "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", "dev": true }, + "bl": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/bl/-/bl-1.2.3.tgz", + "integrity": "sha512-pvcNpa0UU69UT341rO6AYy4FVAIkUHuZXRIWbq+zHnsVcRzDDjIAhGuuYoi0d//cwIwtt4pkpKycWEfjdV+vww==", + "requires": { + "readable-stream": "^2.3.5", + "safe-buffer": "^5.1.1" + }, + "dependencies": { + "readable-stream": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.8.tgz", + "integrity": "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==", + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "requires": { + "safe-buffer": "~5.1.0" + } + } + } + }, "blakejs": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/blakejs/-/blakejs-1.2.1.tgz", @@ -8858,7 +9204,6 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", - "dev": true, "requires": { "balanced-match": "^1.0.0" } @@ -8937,6 +9282,25 @@ "node-int64": "^0.4.0" } }, + "buffer-alloc": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/buffer-alloc/-/buffer-alloc-1.2.0.tgz", + "integrity": "sha512-CFsHQgjtW1UChdXgbyJGtnm+O/uLQeZdtbDo8mfUgYXCHSM1wgrVxXm6bSyrUuErEb+4sYVGCzASBRot7zyrow==", + "requires": { + "buffer-alloc-unsafe": "^1.1.0", + "buffer-fill": "^1.0.0" + } + }, + "buffer-alloc-unsafe": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/buffer-alloc-unsafe/-/buffer-alloc-unsafe-1.1.0.tgz", + "integrity": "sha512-TEM2iMIEQdJ2yjPJoSIsldnleVaAk1oW3DBVUykyOLsEsFmEc9kn+SFFPz+gl54KQNxlDnAwCXosOS9Okx2xAg==" + }, + "buffer-fill": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/buffer-fill/-/buffer-fill-1.0.0.tgz", + "integrity": "sha512-T7zexNBwiiaCOGDg9xNX9PBmjrubblRkENuptryuI64URkXDFum9il/JGL8Lm8wYfAXpredVXXZz7eMHilimiQ==" + }, "buffer-from": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", @@ -9007,6 +9371,11 @@ } } }, + "chownr": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz", + "integrity": "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==" + }, "ci-info": { "version": "3.8.0", "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.8.0.tgz", @@ -9118,6 +9487,11 @@ "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", "dev": true }, + "core-util-is": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", + "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==" + }, "create-hash": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz", @@ -9248,8 +9622,7 @@ "eastasianwidth": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", - "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==", - "dev": true + "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==" }, "electron-to-chromium": { "version": "1.4.537", @@ -9287,8 +9660,15 @@ "emoji-regex": { "version": "9.2.2", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", - "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==", - "dev": true + "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==" + }, + "end-of-stream": { + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", + "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==", + "requires": { + "once": "^1.4.0" + } }, "error-ex": { "version": "1.3.2", @@ -9766,7 +10146,6 @@ "version": "3.1.1", "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.1.1.tgz", "integrity": "sha512-TMKDUnIte6bfb5nWv7V/caI169OHgvwjb7V4WkeUvbQQdjr5rWKqHFiKWb/fcOwB+CzBT+qbWjvj+DVwRskpIg==", - "dev": true, "requires": { "cross-spawn": "^7.0.0", "signal-exit": "^4.0.1" @@ -9782,6 +10161,11 @@ "mime-types": "^2.1.12" } }, + "fs-constants": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz", + "integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==" + }, "fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", @@ -10013,8 +10397,7 @@ "is-fullwidth-code-point": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", - "dev": true + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==" }, "is-generator-fn": { "version": "2.1.0", @@ -10046,6 +10429,11 @@ "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==", "dev": true }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==" + }, "isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", @@ -10827,11 +11215,23 @@ "brace-expansion": "^2.0.1" } }, + "minimist": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", + "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==" + }, "minipass": { - "version": "7.0.4", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.0.4.tgz", - "integrity": "sha512-jYofLM5Dam9279rdkWzqHozUo4ybjdZmCsDHePy5V/PbBcVMiSZR97gmAy45aqi8CK1lG2ECd356FU86avfwUQ==", - "dev": true + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.2.tgz", + "integrity": "sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==" + }, + "mkdirp": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", + "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", + "requires": { + "minimist": "^1.2.6" + } }, "ms": { "version": "2.1.2", @@ -11000,6 +11400,11 @@ "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", "dev": true }, + "package-json-from-dist": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.1.tgz", + "integrity": "sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw==" + }, "parent-module": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", @@ -11170,6 +11575,11 @@ } } }, + "process-nextick-args": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==" + }, "prompts": { "version": "2.4.2", "resolved": "https://registry.npmjs.org/prompts/-/prompts-2.4.2.tgz", @@ -11191,6 +11601,15 @@ "integrity": "sha512-77DZwxQmxKnu3aR542U+X8FypNzbfJ+C5XQDk3uWjWxn6151aIMGthWYRXTqT1E5oJvg+ljaa2OJi+VfvCOQ8w==", "dev": true }, + "pump": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/pump/-/pump-1.0.3.tgz", + "integrity": "sha512-8k0JupWme55+9tCVE+FS5ULT3K6AbgqrGa58lTT49RpyfwwcGedHqaC5LlQNdEAumn/wFsu6aPwkuPMioy8kqw==", + "requires": { + "end-of-stream": "^1.1.0", + "once": "^1.3.1" + } + }, "punycode": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.0.tgz", @@ -11417,8 +11836,7 @@ "signal-exit": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", - "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", - "dev": true + "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==" }, "simple-update-notifier": { "version": "2.0.0", @@ -11501,7 +11919,6 @@ "version": "5.1.2", "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz", "integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==", - "dev": true, "requires": { "eastasianwidth": "^0.2.0", "emoji-regex": "^9.2.2", @@ -11511,14 +11928,12 @@ "ansi-regex": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz", - "integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==", - "dev": true + "integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==" }, "strip-ansi": { "version": "7.1.0", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", - "dev": true, "requires": { "ansi-regex": "^6.0.1" } @@ -11529,7 +11944,6 @@ "version": "npm:string-width@4.2.3", "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dev": true, "requires": { "emoji-regex": "^8.0.0", "is-fullwidth-code-point": "^3.0.0", @@ -11539,8 +11953,7 @@ "emoji-regex": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "dev": true + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" } } }, @@ -11556,7 +11969,6 @@ "version": "npm:strip-ansi@6.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dev": true, "requires": { "ansi-regex": "^5.0.1" } @@ -11592,6 +12004,68 @@ "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", "dev": true }, + "tar-fs": { + "version": "1.16.3", + "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-1.16.3.tgz", + "integrity": "sha512-NvCeXpYx7OsmOh8zIOP/ebG55zZmxLE0etfWRbWok+q2Qo8x/vOR/IJT1taADXPe+jsiu9axDb3X4B+iIgNlKw==", + "requires": { + "chownr": "^1.0.1", + "mkdirp": "^0.5.1", + "pump": "^1.0.0", + "tar-stream": "^1.1.2" + } + }, + "tar-stream": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-1.6.2.tgz", + "integrity": "sha512-rzS0heiNf8Xn7/mpdSVVSMAWAoy9bfb1WOTYC78Z0UQKeKa/CWS8FOq0lKGNa8DWKAn9gxjCvMLYc5PGXYlK2A==", + "requires": { + "bl": "^1.0.0", + "buffer-alloc": "^1.2.0", + "end-of-stream": "^1.0.0", + "fs-constants": "^1.0.0", + "readable-stream": "^2.3.0", + "to-buffer": "^1.1.1", + "xtend": "^4.0.0" + }, + "dependencies": { + "readable-stream": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.8.tgz", + "integrity": "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==", + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "requires": { + "safe-buffer": "~5.1.0" + } + } + } + }, + "targz": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/targz/-/targz-1.0.1.tgz", + "integrity": "sha512-6q4tP9U55mZnRuMTBqnqc3nwYQY3kv+QthCFZuMk+Tn1qYUnMPmL/JZ/mzgXINzFpSqfU+242IFmFU9VPvqaQw==", + "requires": { + "tar-fs": "^1.8.1" + } + }, "test-exclude": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-6.0.0.tgz", @@ -11649,6 +12123,11 @@ "integrity": "sha512-3f0uOEAQwIqGuWW2MVzYg8fV/QNnc/IpuJNG837rLuczAaLVHslWHZQj4IGiEl5Hs3kkbhwL9Ab7Hrsmuj+Smw==", "dev": true }, + "to-buffer": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/to-buffer/-/to-buffer-1.1.1.tgz", + "integrity": "sha512-lx9B5iv7msuFYE3dytT+KE5tap+rNYw+K4jVkb9R/asAb+pbBSM17jtunHplhBe6RRJdZx3Pn2Jph24O32mOVg==" + }, "to-fast-properties": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", @@ -11919,7 +12398,6 @@ "version": "8.1.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz", "integrity": "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==", - "dev": true, "requires": { "ansi-styles": "^6.1.0", "string-width": "^5.0.1", @@ -11929,20 +12407,17 @@ "ansi-regex": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz", - "integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==", - "dev": true + "integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==" }, "ansi-styles": { "version": "6.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.1.tgz", - "integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==", - "dev": true + "integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==" }, "strip-ansi": { "version": "7.1.0", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", - "dev": true, "requires": { "ansi-regex": "^6.0.1" } @@ -11953,7 +12428,6 @@ "version": "npm:wrap-ansi@7.0.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", - "dev": true, "requires": { "ansi-styles": "^4.0.0", "string-width": "^4.1.0", @@ -11963,14 +12437,12 @@ "emoji-regex": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "dev": true + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" }, "string-width": { "version": "4.2.3", "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dev": true, "requires": { "emoji-regex": "^8.0.0", "is-fullwidth-code-point": "^3.0.0", @@ -12009,6 +12481,11 @@ "dev": true, "requires": {} }, + "xtend": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", + "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==" + }, "y18n": { "version": "5.0.8", "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", diff --git a/packages/cli/src/modules/indexing/indexing.commands.ts b/packages/cli/src/modules/indexing/indexing.commands.ts new file mode 100644 index 0000000..27f1869 --- /dev/null +++ b/packages/cli/src/modules/indexing/indexing.commands.ts @@ -0,0 +1,19 @@ +import { Command } from 'commander'; +import { deployIndexer } from './indexing.service'; + +export function createNftsCommands(cli: Command) { + const indexing = cli + .command('indexing') + .description( + 'Commands for management & deployment of indexers on Apillon platform', + ); + + indexing + .command('deploy-indexer') + .description('Deploy and indexer') + .argument('', 'path to indexer root folder') + .requiredOption('-i, --indexer-uuid ', 'UUID of indexer') + .action(async function (path: string) { + await deployIndexer(path, this.optsWithGlobals()); + }); +} diff --git a/packages/cli/src/modules/indexing/indexing.service.ts b/packages/cli/src/modules/indexing/indexing.service.ts new file mode 100644 index 0000000..4425152 --- /dev/null +++ b/packages/cli/src/modules/indexing/indexing.service.ts @@ -0,0 +1,15 @@ +import { Indexing } from '@apillon/sdk'; +import { GlobalOptions } from '../../lib/types'; +import { withErrorHandler } from '../../lib/utils'; + +export async function deployIndexer( + path: string, + optsWithGlobals: GlobalOptions, +) { + await withErrorHandler(async () => { + console.log(`Deploying indexer: ${path}`); + await new Indexing(optsWithGlobals) + .indexer(optsWithGlobals.indexerUuid) + .deployIndexer({ indexerDir: path }); + }); +} diff --git a/packages/sdk/package.json b/packages/sdk/package.json index 59324c5..5254e51 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -46,7 +46,10 @@ "dependencies": { "@polkadot/util-crypto": "^12.6.2", "axios": "^1.6.8", - "ethereumjs-util": "^7.1.5" + "ethereumjs-util": "^7.1.5", + "glob": "^11.0.0", + "ignore": "^6.0.2", + "targz": "^1.0.1" }, "devDependencies": { "@polkadot/keyring": "^12.6.2", diff --git a/packages/sdk/src/index.ts b/packages/sdk/src/index.ts index d1dc0bd..63e2167 100644 --- a/packages/sdk/src/index.ts +++ b/packages/sdk/src/index.ts @@ -13,3 +13,5 @@ export * from './modules/identity/identity'; export * from './modules/computing/computing'; export * from './modules/social/social'; export * from './modules/project/project'; +export * from './modules/indexing/indexing'; +export * from './modules/indexing/indexer'; diff --git a/packages/sdk/src/modules/indexing/indexer.ts b/packages/sdk/src/modules/indexing/indexer.ts new file mode 100644 index 0000000..91c9e18 --- /dev/null +++ b/packages/sdk/src/modules/indexing/indexer.ts @@ -0,0 +1,57 @@ +import axios from 'axios'; +import fs from 'fs'; +import { ApillonModel } from '../../lib/apillon'; +import { ApillonApi } from '../../lib/apillon-api'; +import { compressIndexerSourceCode } from '../../util/indexer-utils'; + +export class Indexer extends ApillonModel { + /** + * User assigned name of the indexer. + */ + public name: string = null; + + /** + * User assigned description of the indexer. + */ + public description: string = null; + + /** + * Constructor which should only be called via Indexing class. + * @param uuid Unique identifier of the indexer. + * @param data Data to populate the indexer with. + */ + constructor(uuid: string, data?: Partial) { + super(uuid); + this.API_PREFIX = `/indexing/indexer/${uuid}`; + this.populate(data); + } + + public async deployIndexer(data: { indexerDir: string }): Promise { + //Get s3 URL for upload + const url = await ApillonApi.get( + `${this.API_PREFIX}/url-for-source-code-upload`, + ); + + //Create tar.gz file + const numOfFiles = await compressIndexerSourceCode( + data.indexerDir, + `${data.indexerDir}/builds/${this.uuid}.tar.gz`, + ); + + if (numOfFiles === 0) { + throw new Error('Source directory is empty'); + } + + //Upload tar.gz to s3 + const s3Api = axios.create(); + const content = fs.readFileSync( + `${data.indexerDir}/builds/${this.uuid}.tar.gz`, + ); + await s3Api.put(url, content, { + headers: { 'Content-Type': 'application/gzip' }, + }); + + //Call deploy API + await ApillonApi.post(`${this.API_PREFIX}/deploy`); + } +} diff --git a/packages/sdk/src/modules/indexing/indexing.ts b/packages/sdk/src/modules/indexing/indexing.ts new file mode 100644 index 0000000..06f2427 --- /dev/null +++ b/packages/sdk/src/modules/indexing/indexing.ts @@ -0,0 +1,12 @@ +import { ApillonModule } from '../../lib/apillon'; +import { Indexer } from './indexer'; + +export class Indexing extends ApillonModule { + /** + * @param uuid Unique bucket identifier. + * @returns An instance of StorageBucket. + */ + public indexer(uuid: string): Indexer { + return new Indexer(uuid); + } +} diff --git a/packages/sdk/src/tests/indexing.test.ts b/packages/sdk/src/tests/indexing.test.ts new file mode 100644 index 0000000..7ac2dd6 --- /dev/null +++ b/packages/sdk/src/tests/indexing.test.ts @@ -0,0 +1,16 @@ +import { Indexing } from '../modules/indexing/indexing'; +import { getConfig } from './helpers/helper'; + +describe('Indexing tests', () => { + let indexing: Indexing = undefined; + + beforeAll(async () => { + indexing = new Indexing(getConfig()); + }); + + test('Deploy a indexer', async () => { + await indexing + .indexer('5286ad99-9447-4f7f-8f29-2c8a3aef7a9f') + .deployIndexer({ indexerDir: 'D:\\Sqd\\moonbeam-squid' }); + }); +}); diff --git a/packages/sdk/src/types/indexer.ts b/packages/sdk/src/types/indexer.ts new file mode 100644 index 0000000..9a23d6e --- /dev/null +++ b/packages/sdk/src/types/indexer.ts @@ -0,0 +1,20 @@ +export interface IUrlForIndexerSourceCodeUpload { + url: string; +} + +export interface IDeployIndexer { + title: string; + /** + * Short description or content of the channel. + */ + body: string; + /** + * Comma separated tags associated with the channel. + */ + tags?: string; + /** + * Hub in which the channel will be created + * @default Apillon default hub + */ + hubUuid?: string; +} diff --git a/packages/sdk/src/util/indexer-utils.ts b/packages/sdk/src/util/indexer-utils.ts new file mode 100644 index 0000000..00ef942 --- /dev/null +++ b/packages/sdk/src/util/indexer-utils.ts @@ -0,0 +1,116 @@ +import fs from 'node:fs'; +import path from 'node:path'; +import { globSync } from 'glob'; +import ignore from 'ignore'; +import targz from 'targz'; + +export function createSquidIgnore(squidDir: string) { + const ig = ignore().add( + // default ignore patterns + ['node_modules', '.git'], + ); + + const ignoreFilePaths = globSync(['.squidignore', '**/.squidignore'], { + cwd: squidDir, + nodir: true, + posix: true, + }); + + if (!ignoreFilePaths.length) { + return ig.add([ + // squid uploaded archives directory + '/builds', + // squid built files + '/lib', + // IDE files + '.idea', + '.vscode', + ]); + } + + for (const ignoreFilePath of ignoreFilePaths) { + const raw = fs + .readFileSync(path.resolve(squidDir, ignoreFilePath)) + .toString(); + + const ignoreDir = path.dirname(ignoreFilePath); + const patterns = getIgnorePatterns(ignoreDir, raw); + + ig.add(patterns); + } + + return ig; +} + +export function getIgnorePatterns(ignoreDir: string, raw: string) { + const lines = raw.split('\n'); + + const patterns: string[] = []; + for (let line of lines) { + line = line.trim(); + + if (line.length === 0) continue; + if (line.startsWith('#')) continue; + + let pattern = + line.startsWith('/') || line.startsWith('*/') || line.startsWith('**/') + ? line + : `**/${line}`; + pattern = + ignoreDir === '.' + ? pattern + : `${toRootPattern(ignoreDir)}${toRootPattern(pattern)}`; + + patterns.push(pattern); + } + + return patterns; +} + +function toRootPattern(pattern: string) { + return pattern.startsWith('/') ? pattern : `/${pattern}`; +} + +export function compressIndexerSourceCode( + srcDir: string, + destDir: string, +): Promise { + const squidIgnore = createSquidIgnore(srcDir); + let filesCount = 0; + + return new Promise((resolve, reject) => { + targz.compress( + { + src: srcDir, + dest: destDir, + tar: { + ignore: (name) => { + const relativePath = path.relative( + path.resolve(srcDir), + path.resolve(name), + ); + + if (squidIgnore.ignores(relativePath)) { + console.log('ignoring ' + relativePath); + return true; + } else { + console.log('adding ' + relativePath); + filesCount++; + return false; + } + }, + }, + }, + function (err) { + if (err) { + console.error(err); + reject( + `Compression failed. ${err.message ? 'Error: ' + err.message : ''}`, + ); + } else { + resolve(filesCount); + } + }, + ); + }); +} From c1813bf684951940818da50934fb98844515beee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vinko=20=C5=A0mid?= Date: Thu, 24 Oct 2024 14:00:45 +0200 Subject: [PATCH 2/6] Fixes for CLI indexing command + Additinal tests for indexing in SDK. --- packages/cli/src/index.ts | 2 ++ .../src/modules/indexing/indexing.commands.ts | 8 ++--- .../src/modules/indexing/indexing.service.ts | 5 ++- packages/sdk/src/modules/indexing/indexer.ts | 33 ++++++++++++------- packages/sdk/src/tests/helpers/helper.ts | 4 +++ packages/sdk/src/tests/indexing.test.ts | 25 +++++++++++--- 6 files changed, 56 insertions(+), 21 deletions(-) diff --git a/packages/cli/src/index.ts b/packages/cli/src/index.ts index 7375da7..b960d3c 100644 --- a/packages/cli/src/index.ts +++ b/packages/cli/src/index.ts @@ -6,6 +6,7 @@ import config from './config'; import { createHostingCommands } from './modules/hosting/hosting.commands'; import { createNftsCommands } from './modules/nfts/nfts.commands'; import { createStorageCommands } from './modules/storage/storage.commands'; +import { createIndexingCommands } from './modules/indexing/indexing.commands'; const cli = new Command('apillon').version(config.VERSION); cli.addHelpText( @@ -47,5 +48,6 @@ cli.showHelpAfterError('Run with --help for additional information!'); createStorageCommands(cli); createHostingCommands(cli); createNftsCommands(cli); +createIndexingCommands(cli); cli.parse(); diff --git a/packages/cli/src/modules/indexing/indexing.commands.ts b/packages/cli/src/modules/indexing/indexing.commands.ts index 27f1869..5a778df 100644 --- a/packages/cli/src/modules/indexing/indexing.commands.ts +++ b/packages/cli/src/modules/indexing/indexing.commands.ts @@ -1,16 +1,14 @@ import { Command } from 'commander'; import { deployIndexer } from './indexing.service'; -export function createNftsCommands(cli: Command) { +export function createIndexingCommands(cli: Command) { const indexing = cli .command('indexing') - .description( - 'Commands for management & deployment of indexers on Apillon platform', - ); + .description('Commands for deployment of indexers on Apillon platform'); indexing .command('deploy-indexer') - .description('Deploy and indexer') + .description('Deploy an indexer') .argument('', 'path to indexer root folder') .requiredOption('-i, --indexer-uuid ', 'UUID of indexer') .action(async function (path: string) { diff --git a/packages/cli/src/modules/indexing/indexing.service.ts b/packages/cli/src/modules/indexing/indexing.service.ts index 4425152..3b38b21 100644 --- a/packages/cli/src/modules/indexing/indexing.service.ts +++ b/packages/cli/src/modules/indexing/indexing.service.ts @@ -10,6 +10,9 @@ export async function deployIndexer( console.log(`Deploying indexer: ${path}`); await new Indexing(optsWithGlobals) .indexer(optsWithGlobals.indexerUuid) - .deployIndexer({ indexerDir: path }); + .deployIndexer(path); + console.log( + `Indexer deployment successfully started! Check Apillon console for status.`, + ); }); } diff --git a/packages/sdk/src/modules/indexing/indexer.ts b/packages/sdk/src/modules/indexing/indexer.ts index 91c9e18..4df3017 100644 --- a/packages/sdk/src/modules/indexing/indexer.ts +++ b/packages/sdk/src/modules/indexing/indexer.ts @@ -22,36 +22,47 @@ export class Indexer extends ApillonModel { */ constructor(uuid: string, data?: Partial) { super(uuid); - this.API_PREFIX = `/indexing/indexer/${uuid}`; + this.API_PREFIX = `/indexing/indexers/${uuid}`; this.populate(data); } - public async deployIndexer(data: { indexerDir: string }): Promise { + /** + * + * @param path Path to the indexer source code directory. + */ + public async deployIndexer(path: string): Promise { + //Check directory and if squid.yaml exists in it + if (!fs.existsSync(path)) { + throw new Error('Path does not exist'); + } + if (!fs.existsSync(`${path}/squid.yaml`)) { + throw new Error('squid.yaml not found in directory'); + } + //Get s3 URL for upload - const url = await ApillonApi.get( - `${this.API_PREFIX}/url-for-source-code-upload`, - ); + const url = await ApillonApi.get(`${this.API_PREFIX}/upload-url`); //Create tar.gz file const numOfFiles = await compressIndexerSourceCode( - data.indexerDir, - `${data.indexerDir}/builds/${this.uuid}.tar.gz`, + path, + `${path}/builds/${this.uuid}.tar.gz`, ); if (numOfFiles === 0) { throw new Error('Source directory is empty'); } + console.info(`Compressed ${numOfFiles} files. Uploading to s3...`); //Upload tar.gz to s3 const s3Api = axios.create(); - const content = fs.readFileSync( - `${data.indexerDir}/builds/${this.uuid}.tar.gz`, - ); + const content = fs.readFileSync(`${path}/builds/${this.uuid}.tar.gz`); await s3Api.put(url, content, { headers: { 'Content-Type': 'application/gzip' }, }); + console.info('Upload complete. Deploying indexer...'); + //Call deploy API - await ApillonApi.post(`${this.API_PREFIX}/deploy`); + return await ApillonApi.post(`${this.API_PREFIX}/deploy`); } } diff --git a/packages/sdk/src/tests/helpers/helper.ts b/packages/sdk/src/tests/helpers/helper.ts index f8c2822..6fd193a 100644 --- a/packages/sdk/src/tests/helpers/helper.ts +++ b/packages/sdk/src/tests/helpers/helper.ts @@ -46,3 +46,7 @@ export function getDirectoryUUID() { export function getFileUUID() { return process.env['FILE_UUID']; } + +export function getIndexerUUID() { + return process.env['INDEXER_UUID']; +} diff --git a/packages/sdk/src/tests/indexing.test.ts b/packages/sdk/src/tests/indexing.test.ts index 7ac2dd6..7e30838 100644 --- a/packages/sdk/src/tests/indexing.test.ts +++ b/packages/sdk/src/tests/indexing.test.ts @@ -1,5 +1,5 @@ import { Indexing } from '../modules/indexing/indexing'; -import { getConfig } from './helpers/helper'; +import { getConfig, getIndexerUUID } from './helpers/helper'; describe('Indexing tests', () => { let indexing: Indexing = undefined; @@ -9,8 +9,25 @@ describe('Indexing tests', () => { }); test('Deploy a indexer', async () => { - await indexing - .indexer('5286ad99-9447-4f7f-8f29-2c8a3aef7a9f') - .deployIndexer({ indexerDir: 'D:\\Sqd\\moonbeam-squid' }); + const response = await indexing + .indexer(getIndexerUUID()) + .deployIndexer('D:\\Sqd\\moonbeam-squid'); + + expect(response).toBeDefined(); + expect(response.lastDeploymentId).toBeTruthy(); + expect(response.status).toBe(5); + expect(response.deployment).toBeDefined(); + }); + + test('Deploy a indexer with invalid path, should return error', async () => { + await expect( + indexing.indexer(getIndexerUUID()).deployIndexer('some invalid path'), + ).rejects.toThrow('Path does not exist'); + }); + + test('Deploy a indexer with valid path but invalid content, should return error', async () => { + await expect( + indexing.indexer(getIndexerUUID()).deployIndexer('D:\\Sqd'), + ).rejects.toThrow('squid.yaml not found in directory'); }); }); From b6dedeaf0cfaf9623078017089707a35ba8a83c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vinko=20=C5=A0mid?= Date: Mon, 28 Oct 2024 10:45:48 +0100 Subject: [PATCH 3/6] Fix to create builds directory, if it does not yet exists --- packages/sdk/src/util/indexer-utils.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/sdk/src/util/indexer-utils.ts b/packages/sdk/src/util/indexer-utils.ts index 00ef942..90ebec0 100644 --- a/packages/sdk/src/util/indexer-utils.ts +++ b/packages/sdk/src/util/indexer-utils.ts @@ -78,6 +78,8 @@ export function compressIndexerSourceCode( const squidIgnore = createSquidIgnore(srcDir); let filesCount = 0; + fs.mkdirSync(path.dirname(destDir), { recursive: true }); + return new Promise((resolve, reject) => { targz.compress( { From 746cc7f78fb0a83e1a2c209b28da5a9f57b8bc69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vinko=20=C5=A0mid?= Date: Mon, 28 Oct 2024 10:50:27 +0100 Subject: [PATCH 4/6] Added some comments and minor optimizations --- apillon-sdk.code-workspace | 3 +-- packages/sdk/src/modules/indexing/indexer.ts | 8 ++++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/apillon-sdk.code-workspace b/apillon-sdk.code-workspace index a05d380..babfce6 100644 --- a/apillon-sdk.code-workspace +++ b/apillon-sdk.code-workspace @@ -42,7 +42,6 @@ "**/.serverless": true, "**/.turbo": true, "**/node_modules": false - }, - "nuxt.isNuxtApp": false + } } } \ No newline at end of file diff --git a/packages/sdk/src/modules/indexing/indexer.ts b/packages/sdk/src/modules/indexing/indexer.ts index 4df3017..cb3fc4c 100644 --- a/packages/sdk/src/modules/indexing/indexer.ts +++ b/packages/sdk/src/modules/indexing/indexer.ts @@ -27,7 +27,7 @@ export class Indexer extends ApillonModel { } /** - * + * Prepare indexer source code, upload it to s3 and deploy the indexer. * @param path Path to the indexer source code directory. */ public async deployIndexer(path: string): Promise { @@ -39,9 +39,6 @@ export class Indexer extends ApillonModel { throw new Error('squid.yaml not found in directory'); } - //Get s3 URL for upload - const url = await ApillonApi.get(`${this.API_PREFIX}/upload-url`); - //Create tar.gz file const numOfFiles = await compressIndexerSourceCode( path, @@ -53,6 +50,9 @@ export class Indexer extends ApillonModel { } console.info(`Compressed ${numOfFiles} files. Uploading to s3...`); + //Get s3 URL for upload + const url = await ApillonApi.get(`${this.API_PREFIX}/upload-url`); + //Upload tar.gz to s3 const s3Api = axios.create(); const content = fs.readFileSync(`${path}/builds/${this.uuid}.tar.gz`); From 0abceea12d1c85235437d44d37fcd07b51d05b47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vinko=20=C5=A0mid?= Date: Mon, 28 Oct 2024 11:02:46 +0100 Subject: [PATCH 5/6] Added response type for indexerDeploy & coverage for some edge cases --- packages/sdk/src/modules/indexing/indexer.ts | 11 +++++++++- packages/sdk/src/types/indexer.ts | 23 ++++++++------------ 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/packages/sdk/src/modules/indexing/indexer.ts b/packages/sdk/src/modules/indexing/indexer.ts index cb3fc4c..22606c3 100644 --- a/packages/sdk/src/modules/indexing/indexer.ts +++ b/packages/sdk/src/modules/indexing/indexer.ts @@ -3,6 +3,7 @@ import fs from 'fs'; import { ApillonModel } from '../../lib/apillon'; import { ApillonApi } from '../../lib/apillon-api'; import { compressIndexerSourceCode } from '../../util/indexer-utils'; +import { IDeployIndexer } from '../../types/indexer'; export class Indexer extends ApillonModel { /** @@ -63,6 +64,14 @@ export class Indexer extends ApillonModel { console.info('Upload complete. Deploying indexer...'); //Call deploy API - return await ApillonApi.post(`${this.API_PREFIX}/deploy`); + const deployResponse = await ApillonApi.post( + `${this.API_PREFIX}/deploy`, + ); + if (deployResponse.deployment.failed != 'NO') { + console.error(deployResponse.deployment); + throw new Error('Indexer deployment failed!'); + } + + return deployResponse; } } diff --git a/packages/sdk/src/types/indexer.ts b/packages/sdk/src/types/indexer.ts index 9a23d6e..084784f 100644 --- a/packages/sdk/src/types/indexer.ts +++ b/packages/sdk/src/types/indexer.ts @@ -3,18 +3,13 @@ export interface IUrlForIndexerSourceCodeUpload { } export interface IDeployIndexer { - title: string; - /** - * Short description or content of the channel. - */ - body: string; - /** - * Comma separated tags associated with the channel. - */ - tags?: string; - /** - * Hub in which the channel will be created - * @default Apillon default hub - */ - hubUuid?: string; + indexer_uuid: string; + status: number; + lastDeploymentId: number; + deployment: { + id: number; + type: string; + status: string; + failed: string; + }; } From 5a53db5ef3d22e7b7a41c8b583edac84a007cc6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vinko=20=C5=A0mid?= Date: Mon, 28 Oct 2024 20:51:49 +0100 Subject: [PATCH 6/6] PR review fixes --- .../src/modules/indexing/indexing.commands.ts | 2 +- .../src/modules/indexing/indexing.service.ts | 11 ++-- packages/sdk/src/modules/indexing/indexer.ts | 25 +++++---- packages/sdk/src/modules/indexing/indexing.ts | 4 +- packages/sdk/src/tests/indexing.test.ts | 16 +++--- packages/sdk/src/types/indexer.ts | 54 +++++++++++++++++-- 6 files changed, 85 insertions(+), 27 deletions(-) diff --git a/packages/cli/src/modules/indexing/indexing.commands.ts b/packages/cli/src/modules/indexing/indexing.commands.ts index 5a778df..9bda306 100644 --- a/packages/cli/src/modules/indexing/indexing.commands.ts +++ b/packages/cli/src/modules/indexing/indexing.commands.ts @@ -7,7 +7,7 @@ export function createIndexingCommands(cli: Command) { .description('Commands for deployment of indexers on Apillon platform'); indexing - .command('deploy-indexer') + .command('deploy') .description('Deploy an indexer') .argument('', 'path to indexer root folder') .requiredOption('-i, --indexer-uuid ', 'UUID of indexer') diff --git a/packages/cli/src/modules/indexing/indexing.service.ts b/packages/cli/src/modules/indexing/indexing.service.ts index 3b38b21..ae647d5 100644 --- a/packages/cli/src/modules/indexing/indexing.service.ts +++ b/packages/cli/src/modules/indexing/indexing.service.ts @@ -8,11 +8,14 @@ export async function deployIndexer( ) { await withErrorHandler(async () => { console.log(`Deploying indexer: ${path}`); - await new Indexing(optsWithGlobals) + const res = await new Indexing(optsWithGlobals) .indexer(optsWithGlobals.indexerUuid) .deployIndexer(path); - console.log( - `Indexer deployment successfully started! Check Apillon console for status.`, - ); + + if (res) { + console.log( + `Indexer deployment successfully started! Check Apillon console for status.`, + ); + } }); } diff --git a/packages/sdk/src/modules/indexing/indexer.ts b/packages/sdk/src/modules/indexing/indexer.ts index 22606c3..5903242 100644 --- a/packages/sdk/src/modules/indexing/indexer.ts +++ b/packages/sdk/src/modules/indexing/indexer.ts @@ -2,8 +2,10 @@ import axios from 'axios'; import fs from 'fs'; import { ApillonModel } from '../../lib/apillon'; import { ApillonApi } from '../../lib/apillon-api'; -import { compressIndexerSourceCode } from '../../util/indexer-utils'; +import { ApillonLogger } from '../../lib/apillon-logger'; import { IDeployIndexer } from '../../types/indexer'; +import { compressIndexerSourceCode } from '../../util/indexer-utils'; +import { LogLevel } from '../../docs-index'; export class Indexer extends ApillonModel { /** @@ -27,6 +29,10 @@ export class Indexer extends ApillonModel { this.populate(data); } + override async get(): Promise { + throw new Error('Method not supported.'); + } + /** * Prepare indexer source code, upload it to s3 and deploy the indexer. * @param path Path to the indexer source code directory. @@ -34,10 +40,10 @@ export class Indexer extends ApillonModel { public async deployIndexer(path: string): Promise { //Check directory and if squid.yaml exists in it if (!fs.existsSync(path)) { - throw new Error('Path does not exist'); + return console.error('Invalid path'); } if (!fs.existsSync(`${path}/squid.yaml`)) { - throw new Error('squid.yaml not found in directory'); + return console.error('squid.yaml not found in directory'); } //Create tar.gz file @@ -47,29 +53,28 @@ export class Indexer extends ApillonModel { ); if (numOfFiles === 0) { - throw new Error('Source directory is empty'); + return console.error('Source directory is empty'); } - console.info(`Compressed ${numOfFiles} files. Uploading to s3...`); + ApillonLogger.log(`Compressed ${numOfFiles} files. Uploading to s3...`); //Get s3 URL for upload const url = await ApillonApi.get(`${this.API_PREFIX}/upload-url`); //Upload tar.gz to s3 - const s3Api = axios.create(); const content = fs.readFileSync(`${path}/builds/${this.uuid}.tar.gz`); - await s3Api.put(url, content, { + await axios.put(url, content, { headers: { 'Content-Type': 'application/gzip' }, }); - console.info('Upload complete. Deploying indexer...'); + ApillonLogger.log(`'Upload complete. Deploying indexer...'`); //Call deploy API const deployResponse = await ApillonApi.post( `${this.API_PREFIX}/deploy`, ); if (deployResponse.deployment.failed != 'NO') { - console.error(deployResponse.deployment); - throw new Error('Indexer deployment failed!'); + ApillonLogger.log(deployResponse.deployment, LogLevel.ERROR); + return console.error('Indexer deployment failed!'); } return deployResponse; diff --git a/packages/sdk/src/modules/indexing/indexing.ts b/packages/sdk/src/modules/indexing/indexing.ts index 06f2427..7f4818d 100644 --- a/packages/sdk/src/modules/indexing/indexing.ts +++ b/packages/sdk/src/modules/indexing/indexing.ts @@ -3,8 +3,8 @@ import { Indexer } from './indexer'; export class Indexing extends ApillonModule { /** - * @param uuid Unique bucket identifier. - * @returns An instance of StorageBucket. + * @param uuid Unique indexer identifier. + * @returns An instance of Indexer class. */ public indexer(uuid: string): Indexer { return new Indexer(uuid); diff --git a/packages/sdk/src/tests/indexing.test.ts b/packages/sdk/src/tests/indexing.test.ts index 7e30838..0dd3746 100644 --- a/packages/sdk/src/tests/indexing.test.ts +++ b/packages/sdk/src/tests/indexing.test.ts @@ -3,14 +3,16 @@ import { getConfig, getIndexerUUID } from './helpers/helper'; describe('Indexing tests', () => { let indexing: Indexing = undefined; + let indexer_uuid: string = undefined; beforeAll(async () => { indexing = new Indexing(getConfig()); + indexer_uuid = getIndexerUUID(); }); test('Deploy a indexer', async () => { const response = await indexing - .indexer(getIndexerUUID()) + .indexer(indexer_uuid) .deployIndexer('D:\\Sqd\\moonbeam-squid'); expect(response).toBeDefined(); @@ -20,14 +22,14 @@ describe('Indexing tests', () => { }); test('Deploy a indexer with invalid path, should return error', async () => { - await expect( - indexing.indexer(getIndexerUUID()).deployIndexer('some invalid path'), - ).rejects.toThrow('Path does not exist'); + const logSpy = jest.spyOn(global.console, 'error'); + await indexing.indexer(indexer_uuid).deployIndexer('some invalid path'); + expect(logSpy).toHaveBeenCalled(); }); test('Deploy a indexer with valid path but invalid content, should return error', async () => { - await expect( - indexing.indexer(getIndexerUUID()).deployIndexer('D:\\Sqd'), - ).rejects.toThrow('squid.yaml not found in directory'); + const logSpy = jest.spyOn(global.console, 'error'); + await indexing.indexer(indexer_uuid).deployIndexer('D:\\Sqd'); + expect(logSpy).toHaveBeenCalled(); }); }); diff --git a/packages/sdk/src/types/indexer.ts b/packages/sdk/src/types/indexer.ts index 084784f..50c7dc0 100644 --- a/packages/sdk/src/types/indexer.ts +++ b/packages/sdk/src/types/indexer.ts @@ -2,14 +2,62 @@ export interface IUrlForIndexerSourceCodeUpload { url: string; } +export enum DeploymentType { + DEPLOY = 'DEPLOY', + DEPLOY_HARD_RESET = 'DEPLOY_HARD_RESET', + RESTART = 'RESTART', + HIBERNATE = 'HIBERNATE', + DELETE = 'DELETE', + SCALE = 'SCALE', + SET_TAG = 'SET_TAG', + REMOVE_TAG = 'REMOVE_TAG', +} +export enum DeploymentStatus { + UNPACKING = 'UNPACKING', + IMAGE_BUILDING = 'IMAGE_BUILDING', + RESETTING = 'RESETTING', + ADDING_INGRESS = 'ADDING_INGRESS', + REMOVING_INGRESS = 'REMOVING_INGRESS', + SQUID_SYNCING = 'SQUID_SYNCING', + SQUID_DELETING = 'SQUID_DELETING', + ADDONS_SYNCING = 'ADDONS_SYNCING', + ADDONS_DELETING = 'ADDONS_DELETING', + OK = 'OK', + DEPLOYING = 'DEPLOYING', +} +export enum DeploymentFailed { + NO = 'NO', + UNEXPECTED = 'UNEXPECTED', + PERMISSIONS = 'PERMISSIONS', + REQUIREMENTS = 'REQUIREMENTS', + REQUIRED_SOURCE_FILE_MISSED = 'REQUIRED_SOURCE_FILE_MISSED', + REQUIRED_SOURCE_FILE_INVALID = 'REQUIRED_SOURCE_FILE_INVALID', + SOURCE_FILES_BUILD_FAILED = 'SOURCE_FILES_BUILD_FAILED', +} + export interface IDeployIndexer { + /** + * Indexer unique identifier. + */ indexer_uuid: string; + /** + * Indexer status (1 = draft, 5 = active) + */ status: number; + /** + * Indexer last deployment id - this is the deployment id from the sqd. + */ lastDeploymentId: number; + /** + * Indexer sqd deployment details. + */ deployment: { + /** + * Deployment id + */ id: number; - type: string; - status: string; - failed: string; + type: DeploymentType; + status: DeploymentStatus; + failed: DeploymentFailed; }; }