@genobank/biofs 3.21.1 → 3.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/inventory-delegate/index.d.ts +28 -0
- package/dist/commands/inventory-delegate/index.d.ts.map +1 -0
- package/dist/commands/inventory-delegate/index.js +171 -0
- package/dist/commands/inventory-delegate/index.js.map +1 -0
- package/dist/commands/inventory-list/index.d.ts +33 -0
- package/dist/commands/inventory-list/index.d.ts.map +1 -0
- package/dist/commands/inventory-list/index.js +74 -0
- package/dist/commands/inventory-list/index.js.map +1 -0
- package/dist/commands/inventory-register/index.d.ts +8 -0
- package/dist/commands/inventory-register/index.d.ts.map +1 -0
- package/dist/commands/inventory-register/index.js +57 -0
- package/dist/commands/inventory-register/index.js.map +1 -0
- package/dist/commands/job-view/index.d.ts +15 -0
- package/dist/commands/job-view/index.d.ts.map +1 -0
- package/dist/commands/job-view/index.js +88 -0
- package/dist/commands/job-view/index.js.map +1 -0
- package/dist/commands/neoantigen-pipeline/index.d.ts +35 -1
- package/dist/commands/neoantigen-pipeline/index.d.ts.map +1 -1
- package/dist/commands/neoantigen-pipeline/index.js +107 -1
- package/dist/commands/neoantigen-pipeline/index.js.map +1 -1
- package/dist/commands/parabricks/index.d.ts +83 -0
- package/dist/commands/parabricks/index.d.ts.map +1 -0
- package/dist/commands/parabricks/index.js +340 -0
- package/dist/commands/parabricks/index.js.map +1 -0
- package/dist/commands/parabricks/registry.json +15100 -0
- package/dist/commands/whoami.d.ts +1 -0
- package/dist/commands/whoami.d.ts.map +1 -1
- package/dist/commands/whoami.js +20 -0
- package/dist/commands/whoami.js.map +1 -1
- package/dist/index.js +134 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/utils/node_roles.d.ts +16 -0
- package/dist/lib/utils/node_roles.d.ts.map +1 -0
- package/dist/lib/utils/node_roles.js +34 -0
- package/dist/lib/utils/node_roles.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export interface DelegateOptions {
|
|
2
|
+
from: string;
|
|
3
|
+
to: string;
|
|
4
|
+
attest: string;
|
|
5
|
+
operator?: string[];
|
|
6
|
+
signature?: string;
|
|
7
|
+
nonce?: string;
|
|
8
|
+
expires?: string;
|
|
9
|
+
expiresHours?: string;
|
|
10
|
+
yes?: boolean;
|
|
11
|
+
json?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface DelegationFields {
|
|
14
|
+
from: string;
|
|
15
|
+
to: string;
|
|
16
|
+
operators: string[];
|
|
17
|
+
biocids: string[];
|
|
18
|
+
attestation: string;
|
|
19
|
+
nonce: string;
|
|
20
|
+
expires: string;
|
|
21
|
+
}
|
|
22
|
+
export declare const biocidsDigest: (biocids: string[]) => string;
|
|
23
|
+
export declare const attestationDigest: (text: string) => string;
|
|
24
|
+
export declare function buildMessage(f: DelegationFields): string;
|
|
25
|
+
export declare function buildFields(biocids: string[], o: DelegateOptions, callerWallet: string, nowMs: number): DelegationFields;
|
|
26
|
+
export declare function buildDelegateBody(f: DelegationFields, signature: string, yes: boolean): Record<string, unknown>;
|
|
27
|
+
export declare function inventoryDelegateCommand(biocids: string[], options: DelegateOptions): Promise<void>;
|
|
28
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/inventory-delegate/index.ts"],"names":[],"mappings":"AAwBA,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,EAAE,CAAC;IAAC,OAAO,EAAE,MAAM,EAAE,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;CACvH;AAID,eAAO,MAAM,aAAa,GAAI,SAAS,MAAM,EAAE,KAAG,MAAgD,CAAC;AACnG,eAAO,MAAM,iBAAiB,GAAI,MAAM,MAAM,KAAG,MAAgE,CAAC;AAElH,wBAAgB,YAAY,CAAC,CAAC,EAAE,gBAAgB,GAAG,MAAM,CAcxD;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,gBAAgB,CAqBxH;AAED,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAG/G;AAED,wBAAsB,wBAAwB,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAkCzG"}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.attestationDigest = exports.biocidsDigest = void 0;
|
|
40
|
+
exports.buildMessage = buildMessage;
|
|
41
|
+
exports.buildFields = buildFields;
|
|
42
|
+
exports.buildDelegateBody = buildDelegateBody;
|
|
43
|
+
exports.inventoryDelegateCommand = inventoryDelegateCommand;
|
|
44
|
+
/**
|
|
45
|
+
* biofs inventory-delegate <biocids...> --from <owner wallet> --to <new owner wallet> --attest "<basis>" [--operator <wallet...>] [--signature 0x..] [--nonce n --expires iso] [--yes]
|
|
46
|
+
*
|
|
47
|
+
* OWNERSHIP DELEGATION by signature. The current owner (a MetaMask wallet) signs one personal_sign message that hands the named biofiles to a new owner wallet while naming the operator
|
|
48
|
+
* wallet(s) that keep the right to run bioinformatics pipelines on them and deliver the results into the new owner's tree. Two steps, one verb:
|
|
49
|
+
* 1. without --signature: prints the exact message (and saves it) plus the nonce and expiry; nothing is sent.
|
|
50
|
+
* 2. with --signature (the MetaMask personal_sign result), --nonce and --expires from step 1: biofs-node (POST /agent/inventory_delegate) rebuilds the same message, recovers the signer,
|
|
51
|
+
* and moves a row only when its present owner is that signer. Dry run unless --yes. Ownerless rows are refused, never given an owner. Previous values are kept (claim_prev).
|
|
52
|
+
* A thin client: the message builder below must stay byte-identical to the node's src/lib/inventory_delegate.js (test vectors in both repos).
|
|
53
|
+
*/
|
|
54
|
+
const axios_1 = __importDefault(require("axios"));
|
|
55
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
56
|
+
const crypto_1 = require("crypto");
|
|
57
|
+
const fs = __importStar(require("fs"));
|
|
58
|
+
const os = __importStar(require("os"));
|
|
59
|
+
const path = __importStar(require("path"));
|
|
60
|
+
const credentials_1 = require("../../lib/auth/credentials");
|
|
61
|
+
const node_roles_1 = require("../../lib/utils/node_roles");
|
|
62
|
+
const BIOFS_NODE_BASE = process.env.BIOFS_NODE_URL
|
|
63
|
+
|| `${process.env.GENOBANK_API_URL || 'https://genobank.app'}/api_biofs_node`;
|
|
64
|
+
const BIOCID_RE = /^biocid:\/\/[A-Za-z0-9_-]+\/0x[0-9a-fA-F]{40}\/[A-Za-z0-9_-]+\/\S+$/;
|
|
65
|
+
const WALLET_RE = /^0x[0-9a-fA-F]{40}$/;
|
|
66
|
+
const sha256 = (s) => (0, crypto_1.createHash)('sha256').update(s, 'utf8').digest('hex');
|
|
67
|
+
const lc = (s) => String(s || '').toLowerCase();
|
|
68
|
+
const biocidsDigest = (biocids) => sha256([...biocids].sort().join('\n'));
|
|
69
|
+
exports.biocidsDigest = biocidsDigest;
|
|
70
|
+
const attestationDigest = (text) => sha256(String(text || '').replace(/\s+/g, ' ').trim());
|
|
71
|
+
exports.attestationDigest = attestationDigest;
|
|
72
|
+
function buildMessage(f) {
|
|
73
|
+
const ops = [...new Set(f.operators.map(lc))].sort().join(', ');
|
|
74
|
+
return [
|
|
75
|
+
'GenoBank.io ownership delegation v1',
|
|
76
|
+
'Action: hand ownership of the listed biofiles to the new owner; the named operators keep the right to run pipelines on them and deliver results to the new owner',
|
|
77
|
+
`From owner: ${lc(f.from)}`,
|
|
78
|
+
`To owner: ${lc(f.to)}`,
|
|
79
|
+
`Operators retained: ${ops}`,
|
|
80
|
+
`Files: ${f.biocids.length}`,
|
|
81
|
+
`Files digest (sha256 of the sorted biocids, one per line): ${(0, exports.biocidsDigest)(f.biocids)}`,
|
|
82
|
+
`Attestation digest (sha256): ${(0, exports.attestationDigest)(f.attestation)}`,
|
|
83
|
+
`Nonce: ${f.nonce}`,
|
|
84
|
+
`Expires: ${f.expires}`,
|
|
85
|
+
].join('\n');
|
|
86
|
+
}
|
|
87
|
+
function buildFields(biocids, o, callerWallet, nowMs) {
|
|
88
|
+
if (!biocids.length)
|
|
89
|
+
throw new Error('give at least one biocid');
|
|
90
|
+
if (biocids.length > 50)
|
|
91
|
+
throw new Error('at most 50 biocids per delegation');
|
|
92
|
+
if (new Set(biocids).size !== biocids.length)
|
|
93
|
+
throw new Error('duplicate biocids');
|
|
94
|
+
for (const b of biocids)
|
|
95
|
+
if (!BIOCID_RE.test(b))
|
|
96
|
+
throw new Error(`not a biocid (a gs:// path, URL or file name is never accepted): ${b}`);
|
|
97
|
+
if (!WALLET_RE.test(o.from || ''))
|
|
98
|
+
throw new Error('--from must be the current owner\'s wallet (0x plus 40 hex)');
|
|
99
|
+
if (!WALLET_RE.test(o.to || ''))
|
|
100
|
+
throw new Error('--to must be the new owner\'s wallet (0x plus 40 hex)');
|
|
101
|
+
if (lc(o.from) === lc(o.to))
|
|
102
|
+
throw new Error('--from and --to are the same wallet');
|
|
103
|
+
const attestation = String(o.attest || '').replace(/\s+/g, ' ').trim();
|
|
104
|
+
if (attestation.length < 20 || attestation.length > 600)
|
|
105
|
+
throw new Error('--attest needs 20 to 600 characters: the basis on which the owner hands these files over');
|
|
106
|
+
const operators = (o.operator && o.operator.length ? o.operator : [o.from, callerWallet]).filter(Boolean);
|
|
107
|
+
for (const w of operators)
|
|
108
|
+
if (!WALLET_RE.test(w))
|
|
109
|
+
throw new Error(`--operator is not a wallet: ${w}`);
|
|
110
|
+
const nonce = o.nonce || (0, crypto_1.randomBytes)(16).toString('hex');
|
|
111
|
+
if (!/^[0-9a-f]{32}$/.test(nonce))
|
|
112
|
+
throw new Error('--nonce must be 32 lowercase hex characters');
|
|
113
|
+
let expires = o.expires;
|
|
114
|
+
if (!expires) {
|
|
115
|
+
const h = o.expiresHours === undefined ? 24 : parseFloat(o.expiresHours);
|
|
116
|
+
if (!Number.isFinite(h) || h <= 0 || h > 168)
|
|
117
|
+
throw new Error('--expires-hours must be between 0 and 168 (7 days)');
|
|
118
|
+
expires = new Date(nowMs + Math.round(h * 3600 * 1000)).toISOString();
|
|
119
|
+
}
|
|
120
|
+
return { from: o.from, to: o.to, operators, biocids, attestation, nonce, expires };
|
|
121
|
+
}
|
|
122
|
+
function buildDelegateBody(f, signature, yes) {
|
|
123
|
+
if (!/^0x[0-9a-fA-F]{130}$/.test(signature))
|
|
124
|
+
throw new Error('--signature must be the personal_sign result (0x plus 130 hex characters)');
|
|
125
|
+
return { biocids: f.biocids, from: f.from, to: f.to, operators: f.operators, attestation: f.attestation, nonce: f.nonce, expires: f.expires, signature, dry_run: !yes };
|
|
126
|
+
}
|
|
127
|
+
async function inventoryDelegateCommand(biocids, options) {
|
|
128
|
+
const credentials = await (0, credentials_1.getCredentials)();
|
|
129
|
+
if (!credentials)
|
|
130
|
+
throw new Error('Not authenticated. Run "biofs login" first.');
|
|
131
|
+
if (options.signature && !(options.nonce && options.expires))
|
|
132
|
+
throw new Error('with --signature give the --nonce and --expires printed by the first step (they are part of what was signed)');
|
|
133
|
+
const f = buildFields(biocids, options, credentials.wallet_address, Date.now());
|
|
134
|
+
const message = buildMessage(f);
|
|
135
|
+
if (!options.signature) {
|
|
136
|
+
const dir = path.join(os.homedir(), '.biofs', 'delegations');
|
|
137
|
+
fs.mkdirSync(dir, { recursive: true, mode: 0o700 });
|
|
138
|
+
const file = path.join(dir, `${f.nonce}.txt`);
|
|
139
|
+
fs.writeFileSync(file, message + '\n', { mode: 0o600 });
|
|
140
|
+
console.log(chalk_1.default.bold('Step 1 of 2. Nothing was sent. Sign this exact message with personal_sign in the wallet of the current owner (MetaMask):'));
|
|
141
|
+
console.log('');
|
|
142
|
+
console.log(message);
|
|
143
|
+
console.log('');
|
|
144
|
+
console.log(chalk_1.default.gray(`Saved to ${file}. It is valid until ${f.expires}; the nonce can be used once.`));
|
|
145
|
+
console.log(chalk_1.default.bold('Step 2: send it (dry run first, then add --yes):'));
|
|
146
|
+
console.log(` biofs inventory-delegate ${biocids.join(' ')} --from ${f.from} --to ${f.to} --operator ${f.operators.join(' ')} --attest "${f.attestation}" --nonce ${f.nonce} --expires ${f.expires} --signature <0x...>`);
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
const body = buildDelegateBody(f, options.signature, !!options.yes);
|
|
150
|
+
const headers = { 'X-Biofs-Wallet': credentials.wallet_address, 'X-Biofs-Signature': credentials.user_signature };
|
|
151
|
+
const r = await axios_1.default.post(`${BIOFS_NODE_BASE}/inventory_delegate`, body, { headers, timeout: 60000, validateStatus: (s) => s < 500 });
|
|
152
|
+
if (r.status >= 400)
|
|
153
|
+
throw new Error((0, node_roles_1.nodeErrorMessage)(r.status, r.data?.error));
|
|
154
|
+
if (options.json) {
|
|
155
|
+
console.log(JSON.stringify(r.data, null, 2));
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
const d = r.data;
|
|
159
|
+
console.log(chalk_1.default.bold(d.dry_run ? 'Dry run: nothing was written. Add --yes to delegate.' : 'Delegated.'));
|
|
160
|
+
for (const x of d.delegated || [])
|
|
161
|
+
console.log(chalk_1.default.green(` ${d.dry_run ? 'would delegate' : 'delegated'} ${x.biocid} ${x.previous_owner} -> ${x.new_owner}${x.registry_row ? ' (registry row too)' : ''}`));
|
|
162
|
+
for (const x of d.exists || [])
|
|
163
|
+
console.log(chalk_1.default.gray(` already owned by the new owner ${x}`));
|
|
164
|
+
for (const x of d.errors || [])
|
|
165
|
+
console.log(chalk_1.default.red(` refused ${x.biocid}: ${x.reason}`));
|
|
166
|
+
if (d.refused_all)
|
|
167
|
+
console.log(chalk_1.default.red(' Nothing was written: one refused file stops the whole delegation.'));
|
|
168
|
+
if ((d.errors || []).length)
|
|
169
|
+
process.exitCode = 1;
|
|
170
|
+
}
|
|
171
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/inventory-delegate/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8CA,oCAcC;AAED,kCAqBC;AAED,8CAGC;AAED,4DAkCC;AA5HD;;;;;;;;;GASG;AACH,kDAA0B;AAC1B,kDAA0B;AAC1B,mCAAiD;AACjD,uCAAyB;AACzB,uCAAyB;AACzB,2CAA6B;AAC7B,4DAA4D;AAC5D,2DAA8D;AAE9D,MAAM,eAAe,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc;OAC7C,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,sBAAsB,iBAAiB,CAAC;AAChF,MAAM,SAAS,GAAG,qEAAqE,CAAC;AACxF,MAAM,SAAS,GAAG,qBAAqB,CAAC;AAmBxC,MAAM,MAAM,GAAG,CAAC,CAAS,EAAU,EAAE,CAAC,IAAA,mBAAU,EAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK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AClG,KAAK,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,IAAI,EAAE;QAAE,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IAC9F,IAAI,CAAC,CAAC,WAAW;QAAE,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,GAAG,CAAC,qEAAqE,CAAC,CAAC,CAAC;IACjH,IAAI,CAAC,CAAC,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,MAAM;QAAE,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACpD,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export interface InventoryListOptions {
|
|
2
|
+
serial?: string[];
|
|
3
|
+
lab?: string;
|
|
4
|
+
type?: string[];
|
|
5
|
+
limit?: string;
|
|
6
|
+
json?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface InventoryRow {
|
|
9
|
+
biocid: string | null;
|
|
10
|
+
sample_serial: string | null;
|
|
11
|
+
filetype: string | null;
|
|
12
|
+
owner_wallet: string | null;
|
|
13
|
+
originlab: string | null;
|
|
14
|
+
bucket: string | null;
|
|
15
|
+
object: string | null;
|
|
16
|
+
size: number | null;
|
|
17
|
+
hierarchy_role: string | null;
|
|
18
|
+
orphan_status: string | null;
|
|
19
|
+
}
|
|
20
|
+
export declare function buildInventoryListBody(options: InventoryListOptions): Record<string, unknown>;
|
|
21
|
+
/** One line per distinct file (serial, type, object name); the number of copies and the distinct buckets are kept. */
|
|
22
|
+
export declare function groupRows(rows: InventoryRow[]): Array<{
|
|
23
|
+
serial: string;
|
|
24
|
+
type: string;
|
|
25
|
+
name: string;
|
|
26
|
+
size: number | null;
|
|
27
|
+
owner: string | null;
|
|
28
|
+
copies: number;
|
|
29
|
+
buckets: string[];
|
|
30
|
+
biocids: string[];
|
|
31
|
+
}>;
|
|
32
|
+
export declare function inventoryListCommand(options: InventoryListOptions): Promise<void>;
|
|
33
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/inventory-list/index.ts"],"names":[],"mappings":"AAcA,MAAM,WAAW,oBAAoB;IACnC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACpI,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;CAChI;AAED,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,oBAAoB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAW7F;AAED,sHAAsH;AACtH,wBAAgB,SAAS,CAAC,IAAI,EAAE,YAAY,EAAE,GAAG,KAAK,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,EAAE,CAAC;IAAC,OAAO,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CAYtM;AAED,wBAAsB,oBAAoB,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC,CAavF"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.buildInventoryListBody = buildInventoryListBody;
|
|
7
|
+
exports.groupRows = groupRows;
|
|
8
|
+
exports.inventoryListCommand = inventoryListCommand;
|
|
9
|
+
/**
|
|
10
|
+
* biofs inventory-list (--serial <s...> | --lab <name>) [--type <t...>] [--limit n] [--json]
|
|
11
|
+
*
|
|
12
|
+
* NODE OPERATOR verb, read-only. Lists the file rows of bioroutes.inventory for given sample serials or one lab (never the whole inventory), so a pipeline can name its inputs by
|
|
13
|
+
* biocid. Copies of one file in several buckets are grouped. A thin client: biofs-node (POST /agent/inventory_list) checks the signer is a node operator and reads the table.
|
|
14
|
+
*/
|
|
15
|
+
const axios_1 = __importDefault(require("axios"));
|
|
16
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
17
|
+
const credentials_1 = require("../../lib/auth/credentials");
|
|
18
|
+
const node_roles_1 = require("../../lib/utils/node_roles");
|
|
19
|
+
const BIOFS_NODE_BASE = process.env.BIOFS_NODE_URL
|
|
20
|
+
|| `${process.env.GENOBANK_API_URL || 'https://genobank.app'}/api_biofs_node`;
|
|
21
|
+
function buildInventoryListBody(options) {
|
|
22
|
+
const serials = options.serial || [];
|
|
23
|
+
if (!serials.length && !options.lab)
|
|
24
|
+
throw new Error('give --serial <serial...> or --lab <name> (the whole inventory is never listed)');
|
|
25
|
+
const body = { serials, types: (options.type || []).map((t) => t.toLowerCase()) };
|
|
26
|
+
if (options.lab)
|
|
27
|
+
body.lab = options.lab;
|
|
28
|
+
if (options.limit !== undefined) {
|
|
29
|
+
const n = parseInt(options.limit, 10);
|
|
30
|
+
if (!Number.isFinite(n) || n < 1)
|
|
31
|
+
throw new Error('--limit must be a positive number');
|
|
32
|
+
body.limit = n;
|
|
33
|
+
}
|
|
34
|
+
return body;
|
|
35
|
+
}
|
|
36
|
+
/** One line per distinct file (serial, type, object name); the number of copies and the distinct buckets are kept. */
|
|
37
|
+
function groupRows(rows) {
|
|
38
|
+
const m = new Map();
|
|
39
|
+
for (const r of rows) {
|
|
40
|
+
const name = (r.object || '').split('/').pop() || '';
|
|
41
|
+
const key = `${r.sample_serial}|${r.filetype}|${name}|${r.size}`;
|
|
42
|
+
let g = m.get(key);
|
|
43
|
+
if (!g) {
|
|
44
|
+
g = { serial: r.sample_serial || '', type: r.filetype || '', name, size: r.size, owner: r.owner_wallet, copies: 0, buckets: [], biocids: [] };
|
|
45
|
+
m.set(key, g);
|
|
46
|
+
}
|
|
47
|
+
g.copies += 1;
|
|
48
|
+
if (r.bucket && !g.buckets.includes(r.bucket))
|
|
49
|
+
g.buckets.push(r.bucket);
|
|
50
|
+
if (r.biocid)
|
|
51
|
+
g.biocids.push(r.biocid);
|
|
52
|
+
}
|
|
53
|
+
return [...m.values()].sort((a, b) => (a.serial + a.type + a.name).localeCompare(b.serial + b.type + b.name));
|
|
54
|
+
}
|
|
55
|
+
async function inventoryListCommand(options) {
|
|
56
|
+
const body = buildInventoryListBody(options);
|
|
57
|
+
const credentials = await (0, credentials_1.getCredentials)();
|
|
58
|
+
if (!credentials)
|
|
59
|
+
throw new Error('Not authenticated. Run "biofs login" first.');
|
|
60
|
+
const headers = { 'X-Biofs-Wallet': credentials.wallet_address, 'X-Biofs-Signature': credentials.user_signature };
|
|
61
|
+
const r = await axios_1.default.post(`${BIOFS_NODE_BASE}/inventory_list`, body, { headers, timeout: 60000, validateStatus: (s) => s < 500 });
|
|
62
|
+
if (r.status >= 400)
|
|
63
|
+
throw new Error((0, node_roles_1.nodeErrorMessage)(r.status, r.data?.error));
|
|
64
|
+
if (options.json) {
|
|
65
|
+
console.log(JSON.stringify(r.data, null, 2));
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const groups = groupRows(r.data.rows);
|
|
69
|
+
for (const g of groups) {
|
|
70
|
+
console.log(`${chalk_1.default.bold(g.serial)} ${g.type.padEnd(8)} ${g.name} ${g.size ?? '?'} bytes owner ${g.owner} ${g.copies} cop${g.copies === 1 ? 'y' : 'ies'} in ${g.buckets.join(', ')}`);
|
|
71
|
+
}
|
|
72
|
+
console.log(chalk_1.default.gray(`${r.data.count} rows, ${groups.length} distinct files${r.data.truncated ? ' (truncated: raise --limit)' : ''}. Use --json for the biocids.`));
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/inventory-list/index.ts"],"names":[],"mappings":";;;;;AA2BA,wDAWC;AAGD,8BAYC;AAED,oDAaC;AApED;;;;;GAKG;AACH,kDAA0B;AAC1B,kDAA0B;AAC1B,4DAA4D;AAC5D,2DAA8D;AAE9D,MAAM,eAAe,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc;OAC7C,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,sBAAsB,iBAAiB,CAAC;AAehF,SAAgB,sBAAsB,CAAC,OAA6B;IAClE,MAAM,OAAO,GAAG,OAAO,CAAC,MAAM,IAAI,EAAE,CAAC;IACrC,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG;QAAE,MAAM,IAAI,KAAK,CAAC,iFAAiF,CAAC,CAAC;IACxI,MAAM,IAAI,GAA4B,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,OAAO,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,C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
|
1
|
+
export interface InventoryRegisterOptions {
|
|
2
|
+
attest: string;
|
|
3
|
+
yes?: boolean;
|
|
4
|
+
json?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare function buildInventoryRegisterBody(biocids: string[], options: InventoryRegisterOptions): Record<string, unknown>;
|
|
7
|
+
export declare function inventoryRegisterCommand(biocids: string[], options: InventoryRegisterOptions): Promise<void>;
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/inventory-register/index.ts"],"names":[],"mappings":"AAgBA,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,wBAAwB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAMxH;AAED,wBAAsB,wBAAwB,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,wBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC,CAclH"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.buildInventoryRegisterBody = buildInventoryRegisterBody;
|
|
7
|
+
exports.inventoryRegisterCommand = inventoryRegisterCommand;
|
|
8
|
+
/**
|
|
9
|
+
* biofs inventory-register <biocid...> --attest "<basis>" [--yes] [--json]
|
|
10
|
+
*
|
|
11
|
+
* NODE OPERATOR verb. Copies file rows that already sit in bioroutes.inventory into biocid_registry, the table jobs resolve their inputs through. Ownership is never changed: the
|
|
12
|
+
* registry row carries the inventory row's own owner. The rows are marked consent "custodian" and carry the operator's attestation. A dry run is the default; --yes writes.
|
|
13
|
+
* A thin client: biofs-node (POST /agent/inventory_register) checks the signer is a node operator, reads both tables and writes only what it validates.
|
|
14
|
+
*/
|
|
15
|
+
const axios_1 = __importDefault(require("axios"));
|
|
16
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
17
|
+
const credentials_1 = require("../../lib/auth/credentials");
|
|
18
|
+
const node_roles_1 = require("../../lib/utils/node_roles");
|
|
19
|
+
const BIOFS_NODE_BASE = process.env.BIOFS_NODE_URL
|
|
20
|
+
|| `${process.env.GENOBANK_API_URL || 'https://genobank.app'}/api_biofs_node`;
|
|
21
|
+
const BIOCID_RE = /^biocid:\/\/[A-Za-z0-9_-]+\/0x[0-9a-fA-F]{40}\/[A-Za-z0-9_-]+\/\S+$/;
|
|
22
|
+
function buildInventoryRegisterBody(biocids, options) {
|
|
23
|
+
if (!biocids.length)
|
|
24
|
+
throw new Error('give at least one biocid');
|
|
25
|
+
for (const b of biocids)
|
|
26
|
+
if (!BIOCID_RE.test(b))
|
|
27
|
+
throw new Error(`not a biocid (a gs:// path, URL or file name is never accepted): ${b}`);
|
|
28
|
+
const attestation = String(options.attest || '').replace(/\s+/g, ' ').trim();
|
|
29
|
+
if (attestation.length < 20)
|
|
30
|
+
throw new Error('--attest needs at least 20 characters: the basis on which GenoBank.io holds and uses these files');
|
|
31
|
+
return { biocids, attestation, dry_run: !options.yes };
|
|
32
|
+
}
|
|
33
|
+
async function inventoryRegisterCommand(biocids, options) {
|
|
34
|
+
const body = buildInventoryRegisterBody(biocids, options);
|
|
35
|
+
const credentials = await (0, credentials_1.getCredentials)();
|
|
36
|
+
if (!credentials)
|
|
37
|
+
throw new Error('Not authenticated. Run "biofs login" first.');
|
|
38
|
+
const headers = { 'X-Biofs-Wallet': credentials.wallet_address, 'X-Biofs-Signature': credentials.user_signature };
|
|
39
|
+
const r = await axios_1.default.post(`${BIOFS_NODE_BASE}/inventory_register`, body, { headers, timeout: 60000, validateStatus: (s) => s < 500 });
|
|
40
|
+
if (r.status >= 400)
|
|
41
|
+
throw new Error((0, node_roles_1.nodeErrorMessage)(r.status, r.data?.error));
|
|
42
|
+
if (options.json) {
|
|
43
|
+
console.log(JSON.stringify(r.data, null, 2));
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const d = r.data;
|
|
47
|
+
console.log(chalk_1.default.bold(d.dry_run ? 'Dry run: nothing was written. Add --yes to register.' : 'Registered.'));
|
|
48
|
+
for (const x of d.registered || [])
|
|
49
|
+
console.log(chalk_1.default.green(` ${d.dry_run ? 'would register' : 'registered'} ${x.biocid} owner ${x.owner_wallet} ${x.file_size} bytes`));
|
|
50
|
+
for (const x of d.exists || [])
|
|
51
|
+
console.log(chalk_1.default.gray(` already registered ${x}`));
|
|
52
|
+
for (const x of d.errors || [])
|
|
53
|
+
console.log(chalk_1.default.red(` refused ${x.biocid}: ${x.reason}`));
|
|
54
|
+
if ((d.errors || []).length)
|
|
55
|
+
process.exitCode = 1;
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/inventory-register/index.ts"],"names":[],"mappings":";;;;;AAsBA,gEAMC;AAED,4DAcC;AA5CD;;;;;;GAMG;AACH,kDAA0B;AAC1B,kDAA0B;AAC1B,4DAA4D;AAC5D,2DAA8D;AAE9D,MAAM,eAAe,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc;OAC7C,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,sBAAsB,iBAAiB,CAAC;AAChF,MAAM,SAAS,GAAG,qEAAqE,CAAC;AAQxF,SAAgB,0BAA0B,CAAC,OAAiB,EAAE,OAAiC;IAC7F,IAAI,CAAC,OAAO,CAAC,MAAM;QAAE,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;IACjE,KA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
|
+
export interface JobLogOptions {
|
|
6
|
+
follow?: boolean;
|
|
7
|
+
from?: string;
|
|
8
|
+
json?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare function buildJobsPath(o: JobsOptions): string;
|
|
11
|
+
export declare function buildLogPath(job: string, from: number): string;
|
|
12
|
+
export declare function elapsed(a?: string | number | null, b?: string | number | null): string;
|
|
13
|
+
export declare function jobsCommand(o: JobsOptions): Promise<void>;
|
|
14
|
+
export declare function jobLogCommand(job: string, o: JobLogOptions, sleep?: (ms: number) => Promise<void>): Promise<void>;
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/job-view/index.ts"],"names":[],"mappings":"AAeA,MAAM,WAAW,WAAW;IAAG,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,OAAO,CAAA;CAAE;AAC/D,MAAM,WAAW,aAAa;IAAG,MAAM,CAAC,EAAE,OAAO,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,OAAO,CAAA;CAAE;AAElF,wBAAgB,aAAa,CAAC,CAAC,EAAE,WAAW,GAAG,MAAM,CAKpD;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAI9D;AAED,wBAAgB,OAAO,CAAC,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,MAAM,CAMtF;AAWD,wBAAsB,WAAW,CAAC,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAQ/D;AAED,wBAAsB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,aAAa,EAAE,KAAK,GAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAiD,GAAG,OAAO,CAAC,IAAI,CAAC,CAWtK"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.buildJobsPath = buildJobsPath;
|
|
7
|
+
exports.buildLogPath = buildLogPath;
|
|
8
|
+
exports.elapsed = elapsed;
|
|
9
|
+
exports.jobsCommand = jobsCommand;
|
|
10
|
+
exports.jobLogCommand = jobLogCommand;
|
|
11
|
+
/**
|
|
12
|
+
* biofs jobs [--limit n] [--json] the governed jobs you may see (as owner, submitter, node operator or node viewer), newest first
|
|
13
|
+
* biofs job-log <job> [--follow] [--from n] [--json] the run log of a job (pbrun's own output), live with --follow; also: biofs pbrun logs <job>
|
|
14
|
+
*
|
|
15
|
+
* Read-only CLIENT verbs over biofs-node (GET /agent/jobs_recent, GET /agent/job_log). The node decides who may see a job; a job you may not see is "not found".
|
|
16
|
+
*/
|
|
17
|
+
const axios_1 = __importDefault(require("axios"));
|
|
18
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
19
|
+
const credentials_1 = require("../../lib/auth/credentials");
|
|
20
|
+
const node_roles_1 = require("../../lib/utils/node_roles");
|
|
21
|
+
const BIOFS_NODE_BASE = process.env.BIOFS_NODE_URL
|
|
22
|
+
|| `${process.env.GENOBANK_API_URL || 'https://genobank.app'}/api_biofs_node`;
|
|
23
|
+
const JOB_RE = /^neo-[0-9a-f-]{36}$/;
|
|
24
|
+
function buildJobsPath(o) {
|
|
25
|
+
if (o.limit === undefined)
|
|
26
|
+
return '/jobs_recent';
|
|
27
|
+
const n = parseInt(o.limit, 10);
|
|
28
|
+
if (!Number.isFinite(n) || n < 1 || n > 100)
|
|
29
|
+
throw new Error('--limit must be between 1 and 100');
|
|
30
|
+
return `/jobs_recent?limit=${n}`;
|
|
31
|
+
}
|
|
32
|
+
function buildLogPath(job, from) {
|
|
33
|
+
if (!JOB_RE.test(job))
|
|
34
|
+
throw new Error('give a job id of the form neo-<uuid>');
|
|
35
|
+
if (!Number.isInteger(from) || from < 0)
|
|
36
|
+
throw new Error('--from must be a non-negative integer');
|
|
37
|
+
return `/job_log?neoantigen_job_id=${job}&from=${from}`;
|
|
38
|
+
}
|
|
39
|
+
function elapsed(a, b) {
|
|
40
|
+
if (!a)
|
|
41
|
+
return '';
|
|
42
|
+
const t0 = typeof a === 'number' ? a * 1000 : Date.parse(a);
|
|
43
|
+
const t1 = b ? (typeof b === 'number' ? b * 1000 : Date.parse(b)) : Date.now();
|
|
44
|
+
const s = Math.max(0, Math.round((t1 - t0) / 1000));
|
|
45
|
+
return s >= 3600 ? `${Math.floor(s / 3600)}h${String(Math.floor((s % 3600) / 60)).padStart(2, '0')}m` : s >= 60 ? `${Math.floor(s / 60)}m${String(s % 60).padStart(2, '0')}s` : `${s}s`;
|
|
46
|
+
}
|
|
47
|
+
async function get(path) {
|
|
48
|
+
const credentials = await (0, credentials_1.getCredentials)();
|
|
49
|
+
if (!credentials)
|
|
50
|
+
throw new Error('Not authenticated. Run "biofs login" first.');
|
|
51
|
+
const headers = { 'X-Biofs-Wallet': credentials.wallet_address, 'X-Biofs-Signature': credentials.user_signature };
|
|
52
|
+
const r = await axios_1.default.get(`${BIOFS_NODE_BASE}${path}`, { headers, timeout: 30000, validateStatus: (s) => s < 500 });
|
|
53
|
+
if (r.status >= 400)
|
|
54
|
+
throw new Error((0, node_roles_1.nodeErrorMessage)(r.status, r.data?.error));
|
|
55
|
+
return r.data;
|
|
56
|
+
}
|
|
57
|
+
async function jobsCommand(o) {
|
|
58
|
+
const d = await get(buildJobsPath(o));
|
|
59
|
+
if (o.json) {
|
|
60
|
+
console.log(JSON.stringify(d, null, 2));
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
for (const j of d.jobs) {
|
|
64
|
+
const st = j.status === 'done' ? chalk_1.default.green(j.status) : j.status === 'failed' ? chalk_1.default.red(j.status) : chalk_1.default.yellow(j.status || '?');
|
|
65
|
+
console.log(`${j.neoantigen_job_id} ${st.padEnd(9)} ${(j.tool || j.kind || '').padEnd(14)} ${(j.case_id || '').padEnd(14)} ${elapsed(j.started_at || j.created_at, j.finished_at).padEnd(8)} ${j.stage || j.error || ''}`);
|
|
66
|
+
}
|
|
67
|
+
console.log(chalk_1.default.gray(`${d.count} jobs`));
|
|
68
|
+
}
|
|
69
|
+
async function jobLogCommand(job, o, sleep = (ms) => new Promise((r) => setTimeout(r, ms))) {
|
|
70
|
+
let from = o.from === undefined ? 0 : parseInt(o.from, 10);
|
|
71
|
+
for (;;) {
|
|
72
|
+
const d = await get(buildLogPath(job, from));
|
|
73
|
+
if (o.json)
|
|
74
|
+
console.log(JSON.stringify(d));
|
|
75
|
+
else if (d.text)
|
|
76
|
+
process.stdout.write(d.text);
|
|
77
|
+
from = d.next;
|
|
78
|
+
if (!o.follow) {
|
|
79
|
+
if (!o.json && !d.finished)
|
|
80
|
+
console.error(chalk_1.default.gray(`\n[${d.status}${d.stage ? ': ' + d.stage : ''}; next offset ${d.next}; add --follow to stream]`));
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
if (d.finished && !d.text)
|
|
84
|
+
return;
|
|
85
|
+
await sleep(d.text ? 500 : 3000);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/job-view/index.ts"],"names":[],"mappings":";;;;;AAkBA,sCAKC;AAED,oCAIC;AAED,0BAMC;AAWD,kCAQC;AAED,sCAWC;AArED;;;;;GAKG;AACH,kDAA0B;AAC1B,kDAA0B;AAC1B,4DAA4D;AAC5D,2DAA8D;AAE9D,MAAM,eAAe,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc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CAAC,IAAI,2BAA2B,CAAC,CAAC,CAAC;YAAC,OAAO;QAAC,CAAC;QACnL,IAAI,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,CAAC,IAAI;YAAE,OAAO;QAClC,MAAM,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IACnC,CAAC;AACH,CAAC"}
|
|
@@ -108,6 +108,15 @@ export interface SynapsePullOptions {
|
|
|
108
108
|
wait?: boolean;
|
|
109
109
|
json?: boolean;
|
|
110
110
|
}
|
|
111
|
+
export interface PublicFetchOptions {
|
|
112
|
+
accession?: string;
|
|
113
|
+
outName?: string;
|
|
114
|
+
pairs?: string;
|
|
115
|
+
maxTotalBytes?: string;
|
|
116
|
+
owner?: string;
|
|
117
|
+
wait?: boolean;
|
|
118
|
+
json?: boolean;
|
|
119
|
+
}
|
|
111
120
|
export interface TeslaGateOptions {
|
|
112
121
|
outcomes: string;
|
|
113
122
|
features: string[];
|
|
@@ -127,12 +136,14 @@ export declare function parseSynIds(list: string | undefined, flag: string): str
|
|
|
127
136
|
export declare function parseSuffixes(list: string | undefined): string[];
|
|
128
137
|
/** Third-party controlled-access data from Synapse onto a worker: the Synapse token lives only on the worker, never in this request, and the job never runs on the node that holds the registry. */
|
|
129
138
|
export declare function buildSynapseBody(caseId: string, o: SynapsePullOptions, wallet: string, signature: string): Record<string, unknown>;
|
|
139
|
+
/** biofs public-fetch: a PUBLIC ENA paired FASTQ run onto a governed worker. The body names an accession and nothing that names a place (no URL, no host): the worker asks the archive. */
|
|
140
|
+
export declare function buildPublicFetchBody(caseId: string, o: PublicFetchOptions, wallet: string, signature: string): Record<string, unknown>;
|
|
130
141
|
export declare function parseSha256(flag: string, v: string): string;
|
|
131
142
|
/** "1=biocid://...,2=biocid://..." (repeatable): TESLA patient id to the biocid of that subject's neoantigen-evidence features table. */
|
|
132
143
|
export declare function parseFeatures(items: string[] | string | undefined): Record<string, string>;
|
|
133
144
|
/** The registered test of the case 1 evidence gate on the TESLA subjects. The code hash, protocol hash and ledger record must be the frozen ones; the worker refuses code that differs. */
|
|
134
145
|
export declare function buildTeslaGateBody(caseId: string, o: TeslaGateOptions, wallet: string, signature: string): Record<string, unknown>;
|
|
135
|
-
type Kind = 'evidence' | 'design' | 'hla' | 'fusion' | 'indel' | 'synapse' | 'tesla_gate';
|
|
146
|
+
type Kind = 'evidence' | 'design' | 'hla' | 'fusion' | 'indel' | 'synapse' | 'tesla_gate' | 'parabricks' | 'public_fetch' | 'identity';
|
|
136
147
|
/** One line about the on-chain proof of a finished job. Never blank for a finished job: an unanchored job must not look anchored. */
|
|
137
148
|
export declare function anchorLine(row: any): string | null;
|
|
138
149
|
export declare function neoantigenEvidenceSubmitCommand(caseId: string, options: NeoantigenEvidenceOptions): Promise<void>;
|
|
@@ -141,7 +152,30 @@ export declare function neoantigenHlaSubmitCommand(caseId: string, options: Neoa
|
|
|
141
152
|
export declare function neoantigenFusionSubmitCommand(caseId: string, options: NeoantigenFusionOptions): Promise<void>;
|
|
142
153
|
export declare function neoantigenIndelSubmitCommand(caseId: string, options: NeoantigenIndelOptions): Promise<void>;
|
|
143
154
|
export declare function synapsePullSubmitCommand(caseId: string, options: SynapsePullOptions): Promise<void>;
|
|
155
|
+
export declare function publicFetchSubmitCommand(caseId: string, options: PublicFetchOptions): Promise<void>;
|
|
156
|
+
export interface IdentityOptions {
|
|
157
|
+
sample: string[];
|
|
158
|
+
codeSha256: string;
|
|
159
|
+
protocolSha256: string;
|
|
160
|
+
ledgerRecord: string;
|
|
161
|
+
minDepth?: string;
|
|
162
|
+
minGq?: string;
|
|
163
|
+
executor?: string;
|
|
164
|
+
owner?: string;
|
|
165
|
+
wait?: boolean;
|
|
166
|
+
json?: boolean;
|
|
167
|
+
}
|
|
168
|
+
/** label=biocid entries, 2 to 8, labels of letters, digits, _ and - (never a person name), no biocid twice. */
|
|
169
|
+
export declare function parseSamples(items: string[] | string | undefined): Record<string, string>;
|
|
170
|
+
/** Are these samples the same individual? The registered identity protocol: the code hash, protocol hash and ledger record must be the frozen ones; the worker refuses code that differs. */
|
|
171
|
+
export declare function buildIdentityBody(caseId: string, o: IdentityOptions, wallet: string, signature: string): Record<string, unknown>;
|
|
172
|
+
export declare function identitySubmitCommand(caseId: string, options: IdentityOptions): Promise<void>;
|
|
144
173
|
export declare function teslaGateSubmitCommand(caseId: string, options: TeslaGateOptions): Promise<void>;
|
|
174
|
+
/** Used by the pbrun verbs (commands/parabricks): sign, submit the job body, optionally wait. The body is built and checked by the caller. */
|
|
175
|
+
export declare function parabricksSubmit(buildBody: (wallet: string, signature: string) => Record<string, unknown>, options: {
|
|
176
|
+
wait?: boolean;
|
|
177
|
+
json?: boolean;
|
|
178
|
+
}): Promise<void>;
|
|
145
179
|
export declare function neoantigenStatusCommand(kind: Kind, id: string, options: {
|
|
146
180
|
wait?: boolean;
|
|
147
181
|
json?: boolean;
|