@filoz/repair-cli 0.0.1

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.
Files changed (127) hide show
  1. package/dist/src/cli.d.ts +3 -0
  2. package/dist/src/cli.d.ts.map +1 -0
  3. package/dist/src/cli.js +19 -0
  4. package/dist/src/cli.js.map +1 -0
  5. package/dist/src/commands/datasets.d.ts +9 -0
  6. package/dist/src/commands/datasets.d.ts.map +1 -0
  7. package/dist/src/commands/datasets.js +59 -0
  8. package/dist/src/commands/datasets.js.map +1 -0
  9. package/dist/src/commands/providers.d.ts +9 -0
  10. package/dist/src/commands/providers.d.ts.map +1 -0
  11. package/dist/src/commands/providers.js +84 -0
  12. package/dist/src/commands/providers.js.map +1 -0
  13. package/dist/src/commands/repair.d.ts +9 -0
  14. package/dist/src/commands/repair.d.ts.map +1 -0
  15. package/dist/src/commands/repair.js +170 -0
  16. package/dist/src/commands/repair.js.map +1 -0
  17. package/dist/src/commands/setup.d.ts +11 -0
  18. package/dist/src/commands/setup.d.ts.map +1 -0
  19. package/dist/src/commands/setup.js +127 -0
  20. package/dist/src/commands/setup.js.map +1 -0
  21. package/dist/src/commands/wallet.d.ts +9 -0
  22. package/dist/src/commands/wallet.d.ts.map +1 -0
  23. package/dist/src/commands/wallet.js +150 -0
  24. package/dist/src/commands/wallet.js.map +1 -0
  25. package/dist/src/db/get-pieces.d.ts +23 -0
  26. package/dist/src/db/get-pieces.d.ts.map +1 -0
  27. package/dist/src/db/get-pieces.js +84 -0
  28. package/dist/src/db/get-pieces.js.map +1 -0
  29. package/dist/src/db/get-providers-by-cid.d.ts +10 -0
  30. package/dist/src/db/get-providers-by-cid.d.ts.map +1 -0
  31. package/dist/src/db/get-providers-by-cid.js +45 -0
  32. package/dist/src/db/get-providers-by-cid.js.map +1 -0
  33. package/dist/src/db/get-repair-dataset.d.ts +9 -0
  34. package/dist/src/db/get-repair-dataset.d.ts.map +1 -0
  35. package/dist/src/db/get-repair-dataset.js +15 -0
  36. package/dist/src/db/get-repair-dataset.js.map +1 -0
  37. package/dist/src/db/get-repair-provider.d.ts +6 -0
  38. package/dist/src/db/get-repair-provider.d.ts.map +1 -0
  39. package/dist/src/db/get-repair-provider.js +28 -0
  40. package/dist/src/db/get-repair-provider.js.map +1 -0
  41. package/dist/src/db/get-target-dataset.d.ts +7 -0
  42. package/dist/src/db/get-target-dataset.d.ts.map +1 -0
  43. package/dist/src/db/get-target-dataset.js +27 -0
  44. package/dist/src/db/get-target-dataset.js.map +1 -0
  45. package/dist/src/db/repair-create.d.ts +7 -0
  46. package/dist/src/db/repair-create.d.ts.map +1 -0
  47. package/dist/src/db/repair-create.js +69 -0
  48. package/dist/src/db/repair-create.js.map +1 -0
  49. package/dist/src/db/repair-delete.d.ts +11 -0
  50. package/dist/src/db/repair-delete.d.ts.map +1 -0
  51. package/dist/src/db/repair-delete.js +22 -0
  52. package/dist/src/db/repair-delete.js.map +1 -0
  53. package/dist/src/db/repair-update.d.ts +10 -0
  54. package/dist/src/db/repair-update.d.ts.map +1 -0
  55. package/dist/src/db/repair-update.js +13 -0
  56. package/dist/src/db/repair-update.js.map +1 -0
  57. package/dist/src/db/sync-pieces-onchain.d.ts +10 -0
  58. package/dist/src/db/sync-pieces-onchain.d.ts.map +1 -0
  59. package/dist/src/db/sync-pieces-onchain.js +35 -0
  60. package/dist/src/db/sync-pieces-onchain.js.map +1 -0
  61. package/dist/src/db/update-operation.d.ts +11 -0
  62. package/dist/src/db/update-operation.d.ts.map +1 -0
  63. package/dist/src/db/update-operation.js +14 -0
  64. package/dist/src/db/update-operation.js.map +1 -0
  65. package/dist/src/db/upsert-operations.d.ts +8 -0
  66. package/dist/src/db/upsert-operations.d.ts.map +1 -0
  67. package/dist/src/db/upsert-operations.js +13 -0
  68. package/dist/src/db/upsert-operations.js.map +1 -0
  69. package/dist/src/error.d.ts +14 -0
  70. package/dist/src/error.d.ts.map +1 -0
  71. package/dist/src/error.js +27 -0
  72. package/dist/src/error.js.map +1 -0
  73. package/dist/src/indexer-schema.d.ts +549 -0
  74. package/dist/src/indexer-schema.d.ts.map +1 -0
  75. package/dist/src/indexer-schema.js +56 -0
  76. package/dist/src/indexer-schema.js.map +1 -0
  77. package/dist/src/local-schema.d.ts +456 -0
  78. package/dist/src/local-schema.d.ts.map +1 -0
  79. package/dist/src/local-schema.js +63 -0
  80. package/dist/src/local-schema.js.map +1 -0
  81. package/dist/src/middleware.d.ts +19 -0
  82. package/dist/src/middleware.d.ts.map +1 -0
  83. package/dist/src/middleware.js +28 -0
  84. package/dist/src/middleware.js.map +1 -0
  85. package/dist/src/pipeline/create-datasets.d.ts +10 -0
  86. package/dist/src/pipeline/create-datasets.d.ts.map +1 -0
  87. package/dist/src/pipeline/create-datasets.js +48 -0
  88. package/dist/src/pipeline/create-datasets.js.map +1 -0
  89. package/dist/src/pipeline/pull.d.ts +30 -0
  90. package/dist/src/pipeline/pull.d.ts.map +1 -0
  91. package/dist/src/pipeline/pull.js +169 -0
  92. package/dist/src/pipeline/pull.js.map +1 -0
  93. package/dist/src/types.d.ts +34 -0
  94. package/dist/src/types.d.ts.map +1 -0
  95. package/dist/src/types.js +1 -0
  96. package/dist/src/types.js.map +1 -0
  97. package/dist/src/utils.d.ts +11945 -0
  98. package/dist/src/utils.d.ts.map +1 -0
  99. package/dist/src/utils.js +121 -0
  100. package/dist/src/utils.js.map +1 -0
  101. package/package.json +135 -0
  102. package/readme.md +250 -0
  103. package/src/cli.ts +20 -0
  104. package/src/commands/datasets.ts +62 -0
  105. package/src/commands/providers.ts +99 -0
  106. package/src/commands/repair.ts +177 -0
  107. package/src/commands/setup.ts +142 -0
  108. package/src/commands/wallet.ts +159 -0
  109. package/src/db/get-pieces.ts +189 -0
  110. package/src/db/get-providers-by-cid.ts +75 -0
  111. package/src/db/get-repair-dataset.ts +44 -0
  112. package/src/db/get-repair-provider.ts +47 -0
  113. package/src/db/get-target-dataset.ts +47 -0
  114. package/src/db/repair-create.ts +101 -0
  115. package/src/db/repair-delete.ts +39 -0
  116. package/src/db/repair-update.ts +20 -0
  117. package/src/db/sync-pieces-onchain.ts +53 -0
  118. package/src/db/update-operation.ts +26 -0
  119. package/src/db/upsert-operations.ts +23 -0
  120. package/src/error.ts +33 -0
  121. package/src/indexer-schema.ts +77 -0
  122. package/src/local-schema.ts +91 -0
  123. package/src/middleware.ts +34 -0
  124. package/src/pipeline/create-datasets.ts +70 -0
  125. package/src/pipeline/pull.ts +255 -0
  126. package/src/types.ts +41 -0
  127. package/src/utils.ts +190 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACzD,OAAO,EAAE,KAAK,KAAK,EAAY,MAAM,4BAA4B,CAAA;AACjE,OAAO,IAAI,MAAM,MAAM,CAAA;AAEvB,OAAO,EAAmB,KAAK,GAAG,EAAO,MAAM,aAAa,CAAA;AAE5D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAC1D,OAAO,EAAE,CAAC,EAAE,MAAM,OAAO,CAAA;AAQzB,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAEvD,eAAO,MAAM,mBAAmB,kBAAkB,CAAA;AAElD,eAAO,MAAM,MAAM,cAoBjB,CAAA;AAEF,eAAO,MAAM,IAAI,QAAmB,CAAA;AACpC,eAAO,MAAM,OAAO,QAAsB,CAAA;AAgB1C,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM;;;;;;;;;;;;4TAJ7B,CAAC;0BAAuB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4TAAxB,CAAC;0BAAuB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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mBnC;AAMD,eAAO,MAAM,aAAa;;iBAExB,CAAA;AAEF,wBAAsB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAQhF;AAED,wBAAsB,oBAAoB,CAAC,EAAE,EAAE,aAAa;;;;;GAY3D;AASD,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,UAGlD;AAGD,wBAAgB,wBAAwB,IAAI,cAAc,CAKzD;AAKD,wBAAsB,QAAQ,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,mBAehG;AASD,wBAAsB,oBAAoB,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,MAAM,+BAe/E;AAED,eAAO,MAAM,0BAA0B,GAAI,CAAC,SAAS,OAAO,GAAG,WAAW,EAAE,CAAC,SAAS,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,EAC3G,OAAO,CAAC,EACR,UAAU,CAAC,EAAE,4BAed,CAAA"}
@@ -0,0 +1,121 @@
1
+ import { getChain } from '@filoz/synapse-core/chains';
2
+ import Conf from 'conf';
3
+ import { pushSQLiteSchema } from 'drizzle-kit/api';
4
+ import { getTableColumns, sql } from 'drizzle-orm';
5
+ import { drizzle } from 'drizzle-orm/libsql';
6
+ import { z } from 'incur';
7
+ import { request } from 'iso-web/http';
8
+ import pLocate from 'p-locate';
9
+ import terminalLink from 'terminal-link';
10
+ import { createWalletClient, http } from 'viem';
11
+ import { privateKeyToAccount } from 'viem/accounts';
12
+ import packageJson from '../package.json' with { type: 'json' };
13
+ import * as schema from "./local-schema.js";
14
+ export const EARLY_REPAIR_SOURCE = 'early-repair6';
15
+ export const config = new Conf({
16
+ projectName: packageJson.name,
17
+ projectSuffix: '',
18
+ schema: {
19
+ privateKey: {
20
+ type: 'string',
21
+ },
22
+ dbPath: {
23
+ type: 'string',
24
+ },
25
+ indexerMainnetUrl: {
26
+ type: 'string',
27
+ },
28
+ indexerCalibrationUrl: {
29
+ type: 'string',
30
+ },
31
+ chainId: {
32
+ type: 'number',
33
+ },
34
+ },
35
+ });
36
+ export const name = packageJson.name;
37
+ export const version = packageJson.version;
38
+ function privateKeyFromConfig() {
39
+ const privateKey = config.get('privateKey');
40
+ if (!privateKey) {
41
+ throw new Error('Private key not found. Please run `repair-cli setup` first.');
42
+ }
43
+ return privateKey;
44
+ }
45
+ export function getClient(chainId) {
46
+ const chain = getChain(chainId);
47
+ const privateKey = privateKeyFromConfig();
48
+ const account = privateKeyToAccount(privateKey);
49
+ const client = createWalletClient({
50
+ account,
51
+ chain,
52
+ transport: http(),
53
+ });
54
+ return {
55
+ client,
56
+ chain,
57
+ };
58
+ }
59
+ export const globalOptions = z.object({
60
+ debug: z.boolean().optional().default(false).describe('Debug mode'),
61
+ });
62
+ export async function createLocalDatabase(dbPath) {
63
+ const localDb = drizzle(`file:${dbPath}`, {
64
+ schema,
65
+ });
66
+ await localDb.$client.execute('PRAGMA journal_mode = WAL');
67
+ return localDb;
68
+ }
69
+ export async function migrateLocalDatabase(db) {
70
+ const result = await pushSQLiteSchema(schema, db);
71
+ if (result.hasDataLoss) {
72
+ throw new Error('Data loss detected during migration');
73
+ }
74
+ if (result.warnings.length > 0) {
75
+ throw new Error(`Warnings detected during migration:\n${result.warnings.join('\n')}`);
76
+ }
77
+ await result.apply();
78
+ return result;
79
+ }
80
+ export function hashLink(hash, chain) {
81
+ const link = terminalLink(hash, `${chain.blockExplorers?.default?.url}/tx/${hash}`);
82
+ return link;
83
+ }
84
+ export function getRepairDatasetMetadata() {
85
+ return {
86
+ source: EARLY_REPAIR_SOURCE,
87
+ withIPFSIndexing: '',
88
+ };
89
+ }
90
+ export async function getPiece({ pieceCid, serviceUrl }) {
91
+ const url = new URL(`/piece/${pieceCid}`, serviceUrl);
92
+ const response = await request.head(url, {
93
+ retry: {
94
+ retries: 2,
95
+ minTimeout: 250,
96
+ },
97
+ timeout: 3000,
98
+ });
99
+ if (response.error) {
100
+ throw response.error;
101
+ }
102
+ return pieceCid;
103
+ }
104
+ export async function findPieceOnProviders(providers, pieceCid) {
105
+ const result = await pLocate(providers.map((p) => getPiece({
106
+ serviceUrl: p,
107
+ pieceCid,
108
+ }).then(() => p, () => undefined)), (p) => p !== undefined, { concurrency: 5 });
109
+ return result;
110
+ }
111
+ export const buildConflictUpdateColumns = (table, columns) => {
112
+ const cls = getTableColumns(table);
113
+ const cols = columns ?? Object.keys(cls);
114
+ const r = cols.reduce((acc, column) => {
115
+ const colName = cls[column].name;
116
+ acc[column] = sql.raw(`excluded.${colName}`);
117
+ return acc;
118
+ }, {});
119
+ return r;
120
+ };
121
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAc,QAAQ,EAAE,MAAM,4BAA4B,CAAA;AACjE,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,EAAE,eAAe,EAAY,GAAG,EAAE,MAAM,aAAa,CAAA;AAC5D,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAG5C,OAAO,EAAE,CAAC,EAAE,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,OAAO,MAAM,UAAU,CAAA;AAC9B,OAAO,YAAY,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,kBAAkB,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AACnD,OAAO,WAAW,MAAM,iBAAiB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAA;AAC/D,OAAO,KAAK,MAAM,MAAM,mBAAm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,MAAM,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,YAAY,OAAO,EAAE,CAAC,CAAA;QAC5C,OAAO,GAAG,CAAA;IACZ,CAAC,EACD,EAAoB,CACrB,CAAA;IAED,OAAO,CAAC,CAAA;AACV,CAAC,CAAA"}
package/package.json ADDED
@@ -0,0 +1,135 @@
1
+ {
2
+ "name": "@filoz/repair-cli",
3
+ "version": "0.0.1",
4
+ "description": "Early repair for faulty service providers and datasets",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/FilOzone/early-repair.git"
8
+ },
9
+ "keywords": [
10
+ "filecoin",
11
+ "synapse",
12
+ "filecoin pay",
13
+ "filecoin onchain cloud",
14
+ "web3"
15
+ ],
16
+ "author": "Hugo Dias <hugomrdias@gmail.com>",
17
+ "license": "Apache-2.0 OR MIT",
18
+ "bugs": {
19
+ "url": "https://github.com/FilOzone/early-repair/issues"
20
+ },
21
+ "homepage": "https://github.com/FilOzone/early-repair/tree/main/packages/repair-cli",
22
+ "type": "module",
23
+ "main": "dist/src/cli.js",
24
+ "module": "dist/src/cli.js",
25
+ "types": "dist/src/cli.d.ts",
26
+ "bin": {
27
+ "repair": "./dist/cli.js",
28
+ "repair.src": "./src/cli.ts"
29
+ },
30
+ "sideEffects": false,
31
+ "exports": {
32
+ ".": {
33
+ "types": "./dist/src/cli.d.ts",
34
+ "default": "./dist/src/cli.js"
35
+ }
36
+ },
37
+ "files": [
38
+ "src",
39
+ "dist/src",
40
+ "dist/src/**/*.d.ts",
41
+ "dist/src/**/*.d.ts.map"
42
+ ],
43
+ "scripts": {
44
+ "build": "wireit",
45
+ "test": "wireit",
46
+ "test:node": "wireit",
47
+ "test:browser": "wireit",
48
+ "lint": "wireit",
49
+ "lint:fix": "biome check --fix .",
50
+ "update:msw": "pnpx msw init test/mocks/ --save"
51
+ },
52
+ "wireit": {
53
+ "build": {
54
+ "command": "tsc --build --pretty",
55
+ "clean": "if-file-deleted",
56
+ "files": [
57
+ "src/**/*.ts",
58
+ "test/**/*.ts",
59
+ "tsconfig.json"
60
+ ],
61
+ "output": [
62
+ "dist/**"
63
+ ]
64
+ },
65
+ "test": {
66
+ "command": "pnpm run test:node && pnpm run test:browser",
67
+ "files": [
68
+ "src/**/*.ts",
69
+ "test/**/*.ts"
70
+ ],
71
+ "output": [],
72
+ "dependencies": [
73
+ "lint"
74
+ ]
75
+ },
76
+ "test:node": {
77
+ "command": "playwright-test \"test/**/*.test.ts\" --mode node",
78
+ "files": [
79
+ "src/**/*.ts",
80
+ "test/**/*.ts"
81
+ ],
82
+ "output": []
83
+ },
84
+ "test:browser": {
85
+ "command": "playwright-test \"test/**/*.test.ts\" --assets ./test/mocks",
86
+ "files": [
87
+ "src/**/*.ts",
88
+ "test/**/*.ts"
89
+ ],
90
+ "output": []
91
+ },
92
+ "lint": {
93
+ "command": "biome check .",
94
+ "files": [
95
+ "src/**/*.ts",
96
+ "test/**/*.ts",
97
+ "../../biome.json"
98
+ ],
99
+ "output": [],
100
+ "dependencies": [
101
+ "build"
102
+ ]
103
+ }
104
+ },
105
+ "dependencies": {
106
+ "@clack/prompts": "^1.5.1",
107
+ "@filoz/repair-db": "workspace:*",
108
+ "@filoz/synapse-core": "^0.6.0",
109
+ "@libsql/client": "^0.17.3",
110
+ "conf": "^15.1.0",
111
+ "drizzle-kit": "^0.31.10",
112
+ "drizzle-orm": "catalog:",
113
+ "incur": "^0.4.6",
114
+ "iso-base": "^4.4.0",
115
+ "iso-web": "^3.1.2",
116
+ "p-all": "^5.0.1",
117
+ "p-locate": "^7.0.0",
118
+ "p-map": "^7.0.4",
119
+ "p-queue": "^9.3.0",
120
+ "pg": "^8.21.0",
121
+ "terminal-link": "^5.0.0"
122
+ },
123
+ "devDependencies": {
124
+ "@biomejs/biome": "catalog:",
125
+ "@types/node": "catalog:",
126
+ "@types/pg": "^8.20.0",
127
+ "playwright-test": "^14.1.12",
128
+ "type-fest": "^5.7.0",
129
+ "typescript": "catalog:",
130
+ "viem": "catalog:"
131
+ },
132
+ "publishConfig": {
133
+ "access": "public"
134
+ }
135
+ }
package/readme.md ADDED
@@ -0,0 +1,250 @@
1
+ # Early Repair CLI
2
+
3
+ [![NPM](https://nodei.co/npm/@filoz/repair-cli.svg?style=flat&data=n,v&color=blue)](https://nodei.co/npm/@filoz/repair-cli/)
4
+
5
+ > Early repair for faulty service providers and datasets
6
+
7
+ The `repair` CLI helps prepare and run repair jobs that move pieces away from a faulty Filecoin service provider and into a target PDP provider. It uses:
8
+
9
+ - an indexer Postgres database as the read-only source of providers, datasets, and pieces
10
+ - a local SQLite database to track repair jobs and per-piece operations
11
+ - a configured Filecoin wallet to create datasets and submit on-chain add-piece transactions
12
+
13
+ ## Installation
14
+
15
+ ```bash
16
+ pnpm add -g @filoz/repair-cli
17
+ ```
18
+
19
+ The package exposes the `repair` binary.
20
+
21
+ ```bash
22
+ repair --help
23
+ ```
24
+
25
+ ## Setup
26
+
27
+ Run setup before using any command that talks to the indexer, local database, or wallet.
28
+
29
+ ```bash
30
+ repair setup
31
+ ```
32
+
33
+ Setup prompts for:
34
+
35
+ - private key for the repair wallet
36
+ - mainnet indexer Postgres URL
37
+ - calibration indexer Postgres URL
38
+ - chain, either Filecoin Mainnet `314` or Filecoin Calibration `314159`
39
+ - local SQLite database path
40
+
41
+ The command stores these values in the CLI config and runs the local SQLite schema migration. It returns the configured wallet address.
42
+
43
+ Most commands also accept:
44
+
45
+ ```bash
46
+ --debug
47
+ ```
48
+
49
+ Use `--debug` when you want extra error output from wallet operations.
50
+
51
+ ## Command Reference
52
+
53
+ ### `repair setup`
54
+
55
+ Interactive configuration and local database setup.
56
+
57
+ ```bash
58
+ repair setup
59
+ ```
60
+
61
+ Use this whenever you need to initialize the CLI, change the active chain, update indexer URLs, or move the local SQLite database.
62
+
63
+ ### `repair wallet fund`
64
+
65
+ Funds the configured wallet from the Filecoin Calibration faucet.
66
+
67
+ ```bash
68
+ repair wallet fund
69
+ ```
70
+
71
+ This command only works on Calibration. It claims faucet tokens, waits for the transaction to be mined, and returns the wallet address and FIL balance.
72
+
73
+ ### `repair wallet balance`
74
+
75
+ Shows wallet and payment account balances.
76
+
77
+ ```bash
78
+ repair wallet balance
79
+ ```
80
+
81
+ The output includes the wallet address, FIL balance, USDFC balance, and Filecoin Pay account summary fields such as funds, available funds, debt, lockup rates, lockup totals, runway, and current epoch.
82
+
83
+ ### `repair wallet deposit <amount>`
84
+
85
+ Deposits USDFC from the configured wallet into the wallet's Filecoin Pay account.
86
+
87
+ ```bash
88
+ repair wallet deposit 100
89
+ ```
90
+
91
+ `amount` is a positive USDFC amount. The command submits the deposit and approval transaction, then waits for it to be mined.
92
+
93
+ ### `repair wallet withdraw <amount>`
94
+
95
+ Withdraws USDFC from the wallet's Filecoin Pay account.
96
+
97
+ ```bash
98
+ repair wallet withdraw 25
99
+ ```
100
+
101
+ `amount` is a positive USDFC amount. The command submits the withdraw transaction and waits for it to be mined.
102
+
103
+ ### `repair providers list`
104
+
105
+ Lists PDP providers from the configured indexer.
106
+
107
+ ```bash
108
+ repair providers list
109
+ ```
110
+
111
+ By default, the command returns active PDP providers that are approved or endorsed. Each provider includes:
112
+
113
+ - `id`
114
+ - `name`
115
+ - `serviceUrl`
116
+ - `approved`
117
+ - `endorsed`
118
+ - `pieceCount`, the number of active indexed pieces for that provider
119
+ - `totalSize`, the sum of active piece raw sizes formatted in decimal GB
120
+
121
+ Use `--all` to include every active PDP provider, even if it is not approved or endorsed.
122
+
123
+ ```bash
124
+ repair providers list --all
125
+ ```
126
+
127
+ ### `repair datasets list`
128
+
129
+ Lists datasets owned by the configured repair wallet.
130
+
131
+ ```bash
132
+ repair datasets list
133
+ ```
134
+
135
+ Each dataset includes its ID, CDN/IPFS indexing flags, source, provider URL, PDP end epoch, and piece count.
136
+
137
+ Filter by provider ID:
138
+
139
+ ```bash
140
+ repair datasets list --provider-id 123
141
+ ```
142
+
143
+ ### `repair repair create`
144
+
145
+ Creates a local repair plan for a source provider and a target provider.
146
+
147
+ ```bash
148
+ repair repair create --provider-id 101 --target-provider-id 202
149
+ ```
150
+
151
+ `--provider-id` is the faulty provider whose pieces should be repaired.
152
+
153
+ `--target-provider-id` is the provider that should receive the repaired pieces. It must be different from `--provider-id`.
154
+
155
+ The command snapshots the current chain block number, creates a local repair row, scans active pieces for the source provider, deduplicates them by CID, and creates local `add_piece` operations. Pieces with no alternate provider are marked `skipped`. The command returns a `repairId`.
156
+
157
+ ### `repair repair list`
158
+
159
+ Lists local repair jobs.
160
+
161
+ ```bash
162
+ repair repair list
163
+ ```
164
+
165
+ Each repair includes:
166
+
167
+ - repair ID and status
168
+ - source provider ID
169
+ - target provider ID and target provider URL
170
+ - target dataset ID, when one has been created or found
171
+ - block number used when the repair was created
172
+ - total operations and counts by `pending`, `failed`, `completed`, and `skipped`
173
+
174
+ ### `repair repair run <repairId>`
175
+
176
+ Runs a pending repair.
177
+
178
+ ```bash
179
+ repair repair run 1
180
+ ```
181
+
182
+ The command first ensures the target repair dataset exists for the configured wallet and target provider. If no matching dataset exists, it creates one with IPFS indexing enabled and CDN disabled. Then it processes pending `add_piece` operations by pulling pieces from alternate providers into the target provider and committing them on-chain.
183
+
184
+ Options:
185
+
186
+ - `--concurrency <number>` controls how many pull batches run at once. Defaults to `4`.
187
+ - `--batch-size <number>` controls the maximum number of `add_piece` operations per batch. Defaults to `40`.
188
+ - `--reset` retries failed `add_piece` operations as well as pending operations.
189
+
190
+ Example:
191
+
192
+ ```bash
193
+ repair repair run 1 --concurrency 8 --batch-size 100 --reset
194
+ ```
195
+
196
+ ### `repair repair delete <repairId>`
197
+
198
+ Deletes a local repair and its operations.
199
+
200
+ ```bash
201
+ repair repair delete 1
202
+ ```
203
+
204
+ This only deletes local SQLite state. It does not delete on-chain datasets or remove pieces from a provider.
205
+
206
+ ## Typical Workflow
207
+
208
+ 1. Configure the CLI.
209
+
210
+ ```bash
211
+ repair setup
212
+ ```
213
+
214
+ 1. On Calibration, fund the wallet if needed.
215
+
216
+ ```bash
217
+ repair wallet fund
218
+ ```
219
+
220
+ 1. Check balances and deposit USDFC into the payment account.
221
+
222
+ ```bash
223
+ repair wallet balance
224
+ repair wallet deposit 100
225
+ ```
226
+
227
+ 1. Pick source and target providers.
228
+
229
+ ```bash
230
+ repair providers list
231
+ ```
232
+
233
+ 1. Create, inspect, and run the repair.
234
+
235
+ ```bash
236
+ repair repair create --provider-id 101 --target-provider-id 202
237
+ repair repair list
238
+ repair repair run 1
239
+ ```
240
+
241
+ ## Contributing
242
+
243
+ Read contributing [guidelines](../../.github/CONTRIBUTING.md).
244
+
245
+ [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/FilOzone/early-repair)
246
+
247
+ ## License
248
+
249
+ Dual-licensed: [MIT](../../LICENSE.md), [Apache Software License v2](../../LICENSE.md) by way of the
250
+ [Permissive License Stack](https://protocol.ai/blog/announcing-the-permissive-license-stack/).
package/src/cli.ts ADDED
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env node
2
+ import { Cli } from 'incur'
3
+ import { datasets } from './commands/datasets.ts'
4
+ import { providers } from './commands/providers.ts'
5
+ import { repair } from './commands/repair.ts'
6
+ import { setup } from './commands/setup.ts'
7
+ import { wallet } from './commands/wallet.ts'
8
+ import { version } from './utils.ts'
9
+
10
+ const cli = Cli.create('repair', {
11
+ version,
12
+ description: 'Early repair for faulty service providers and datasets',
13
+ })
14
+
15
+ cli.command(setup)
16
+ cli.command(wallet)
17
+ cli.command(repair)
18
+ cli.command(datasets)
19
+ cli.command(providers)
20
+ cli.serve()
@@ -0,0 +1,62 @@
1
+ import { and, eq } from 'drizzle-orm'
2
+ import { Cli, z } from 'incur'
3
+ import { contextMiddleware, contextSchema } from '../middleware.ts'
4
+ import { globalOptions } from '../utils.ts'
5
+ export const datasets = Cli.create('datasets', {
6
+ description: 'Dataset commands',
7
+ options: globalOptions,
8
+ vars: contextSchema,
9
+ })
10
+
11
+ datasets.command('list', {
12
+ description: 'List all datasets owned by the repair wallet',
13
+ options: globalOptions.extend({
14
+ providerId: z.coerce.bigint().optional().describe('Filter datasets by provider ID'),
15
+ }),
16
+ middleware: [contextMiddleware],
17
+ run: async (c) => {
18
+ try {
19
+ const schema = c.var.indexerDb._.fullSchema
20
+ const conditions = [
21
+ eq(schema.dataSets.deleted, false),
22
+ eq(schema.dataSets.payer, c.var.client.account.address.toLowerCase()),
23
+ ]
24
+ if (c.options.providerId != null) {
25
+ conditions.push(eq(schema.dataSets.providerId, c.options.providerId))
26
+ }
27
+
28
+ const datasets = await c.var.indexerDb.query.dataSets.findMany({
29
+ where: and(...conditions),
30
+ with: {
31
+ provider: true,
32
+ pieces: true,
33
+ },
34
+ })
35
+
36
+ const datasetsFlattened = datasets.map((dataset) => {
37
+ const { provider, pieces } = dataset
38
+ return {
39
+ id: dataset.dataSetId,
40
+ withCdn: dataset.withCdn,
41
+ withIpfsIndexing: dataset.withIpfsIndexing,
42
+ source: dataset.source,
43
+ provider: provider.serviceUrl,
44
+ pdpEndEpoch: dataset.pdpEndEpoch,
45
+ pieces: pieces.length,
46
+ // metadata: JSON.stringify(dataset.metadata),
47
+ }
48
+ })
49
+
50
+ return c.ok({
51
+ datasets: datasetsFlattened,
52
+ })
53
+ } catch (error) {
54
+ console.error(error)
55
+ return c.error({
56
+ code: 'DATASETS_FAILED',
57
+ message: error instanceof Error ? error.message : 'Failed to list datasets',
58
+ retryable: true,
59
+ })
60
+ }
61
+ },
62
+ })