@nosana/kit 0.1.2 → 0.1.4
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/index.d.ts +1 -1
- package/dist/index.js +4 -2
- package/dist/programs/JobsProgram.d.ts +15 -3
- package/dist/programs/JobsProgram.js +24 -8
- package/dist/solana/SolanaUtils.js +1 -4
- package/examples/browser/.gitlab-ci.yml +4 -4
- package/examples/browser/nuxt.config.ts +7 -1
- package/examples/browser/package-lock.json +2392 -2017
- package/examples/browser/package.json +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export * from './config/index.js';
|
|
|
17
17
|
export * from './errors/NosanaError.js';
|
|
18
18
|
export * from './logger/Logger.js';
|
|
19
19
|
export { JobsProgram } from './programs/JobsProgram.js';
|
|
20
|
-
export type { Job, Market, Run } from './programs/JobsProgram.js';
|
|
20
|
+
export type { Job, Market, Run, JobState, MarketQueueType } from './programs/JobsProgram.js';
|
|
21
21
|
export * from './ipfs/IPFS.js';
|
|
22
22
|
export * from './generated_clients/jobs/index.js';
|
|
23
23
|
export * from 'gill';
|
package/dist/index.js
CHANGED
|
@@ -52,7 +52,9 @@ export class NosanaClient {
|
|
|
52
52
|
// Only try file/environment loading in Node.js environment
|
|
53
53
|
if (typeof window === 'undefined') {
|
|
54
54
|
try {
|
|
55
|
-
|
|
55
|
+
// Use string concatenation to avoid bundler resolving this import at build time
|
|
56
|
+
const nodeModule = 'gill' + '/node';
|
|
57
|
+
const { loadKeypairSignerFromFile, loadKeypairSignerFromEnvironment, loadKeypairSignerFromEnvironmentBase58 } = await import(nodeModule);
|
|
56
58
|
// Try to load from file path
|
|
57
59
|
if (await this.isValidFilePath(wallet)) {
|
|
58
60
|
try {
|
|
@@ -153,5 +155,5 @@ export { JobsProgram } from './programs/JobsProgram.js';
|
|
|
153
155
|
export * from './ipfs/IPFS.js';
|
|
154
156
|
// Export all generated client types and functions
|
|
155
157
|
export * from './generated_clients/jobs/index.js';
|
|
156
|
-
// Export dependencies
|
|
158
|
+
// Export dependencies
|
|
157
159
|
export * from 'gill';
|
|
@@ -3,11 +3,23 @@ import { Address, Account } from 'gill';
|
|
|
3
3
|
import { NosanaClient } from '../index.js';
|
|
4
4
|
import * as programClient from "../generated_clients/jobs/index.js";
|
|
5
5
|
import { ConvertTypesForDb } from '../utils/index.js';
|
|
6
|
-
export
|
|
6
|
+
export declare enum JobState {
|
|
7
|
+
QUEUED = 0,
|
|
8
|
+
RUNNING = 1,
|
|
9
|
+
COMPLETED = 2,
|
|
10
|
+
STOPPED = 3
|
|
11
|
+
}
|
|
12
|
+
export declare enum MarketQueueType {
|
|
13
|
+
JOB_QUEUE = 0,
|
|
14
|
+
NODE_QUEUE = 1
|
|
15
|
+
}
|
|
16
|
+
export type Job = Omit<ConvertTypesForDb<programClient.JobAccountArgs>, 'state'> & {
|
|
7
17
|
address: Address;
|
|
18
|
+
state: JobState;
|
|
8
19
|
};
|
|
9
|
-
export type Market = ConvertTypesForDb<programClient.MarketAccountArgs> & {
|
|
20
|
+
export type Market = Omit<ConvertTypesForDb<programClient.MarketAccountArgs>, 'queueType'> & {
|
|
10
21
|
address: Address;
|
|
22
|
+
queueType: MarketQueueType;
|
|
11
23
|
};
|
|
12
24
|
export type Run = ConvertTypesForDb<programClient.RunAccountArgs> & {
|
|
13
25
|
address: Address;
|
|
@@ -36,7 +48,7 @@ export declare class JobsProgram extends BaseProgram {
|
|
|
36
48
|
* Fetch all job accounts
|
|
37
49
|
*/
|
|
38
50
|
all(filters?: {
|
|
39
|
-
state?:
|
|
51
|
+
state?: JobState;
|
|
40
52
|
market?: Address;
|
|
41
53
|
node?: Address;
|
|
42
54
|
project?: Address;
|
|
@@ -6,6 +6,18 @@ import { findAssociatedTokenPda, TOKEN_PROGRAM_ADDRESS } from '@solana-program/t
|
|
|
6
6
|
import bs58 from 'bs58';
|
|
7
7
|
import { IPFS } from '../ipfs/IPFS.js';
|
|
8
8
|
import { convertBigIntToNumber } from '../utils/index.js';
|
|
9
|
+
export var JobState;
|
|
10
|
+
(function (JobState) {
|
|
11
|
+
JobState[JobState["QUEUED"] = 0] = "QUEUED";
|
|
12
|
+
JobState[JobState["RUNNING"] = 1] = "RUNNING";
|
|
13
|
+
JobState[JobState["COMPLETED"] = 2] = "COMPLETED";
|
|
14
|
+
JobState[JobState["STOPPED"] = 3] = "STOPPED";
|
|
15
|
+
})(JobState || (JobState = {}));
|
|
16
|
+
export var MarketQueueType;
|
|
17
|
+
(function (MarketQueueType) {
|
|
18
|
+
MarketQueueType[MarketQueueType["JOB_QUEUE"] = 0] = "JOB_QUEUE";
|
|
19
|
+
MarketQueueType[MarketQueueType["NODE_QUEUE"] = 1] = "NODE_QUEUE";
|
|
20
|
+
})(MarketQueueType || (MarketQueueType = {}));
|
|
9
21
|
export class JobsProgram extends BaseProgram {
|
|
10
22
|
constructor(sdk) {
|
|
11
23
|
super(sdk);
|
|
@@ -21,12 +33,12 @@ export class JobsProgram extends BaseProgram {
|
|
|
21
33
|
try {
|
|
22
34
|
const jobAccount = await this.client.fetchJobAccount(this.sdk.solana.rpc, addr);
|
|
23
35
|
const job = this.transformJobAccount(jobAccount);
|
|
24
|
-
if (checkRun && job.state ===
|
|
36
|
+
if (checkRun && job.state === JobState.QUEUED) {
|
|
25
37
|
// If job is queued, check if there is a run account for the job
|
|
26
38
|
const runs = await this.runs({ job: job.address });
|
|
27
39
|
if (runs.length > 0) {
|
|
28
40
|
const run = runs[0];
|
|
29
|
-
job.state =
|
|
41
|
+
job.state = JobState.RUNNING;
|
|
30
42
|
job.timeStart = run.time;
|
|
31
43
|
job.node = run.node;
|
|
32
44
|
}
|
|
@@ -77,10 +89,10 @@ export class JobsProgram extends BaseProgram {
|
|
|
77
89
|
if (checkRuns) {
|
|
78
90
|
const runs = await this.runs();
|
|
79
91
|
jobs.forEach(job => {
|
|
80
|
-
if (job.state ===
|
|
92
|
+
if (job.state === JobState.QUEUED) {
|
|
81
93
|
const run = runs.find(run => run.job === job.address);
|
|
82
94
|
if (run) {
|
|
83
|
-
job.state =
|
|
95
|
+
job.state = JobState.RUNNING;
|
|
84
96
|
job.timeStart = run.time;
|
|
85
97
|
job.node = run.node;
|
|
86
98
|
}
|
|
@@ -168,10 +180,10 @@ export class JobsProgram extends BaseProgram {
|
|
|
168
180
|
if (checkRuns) {
|
|
169
181
|
const runs = await this.runs();
|
|
170
182
|
jobs.forEach(job => {
|
|
171
|
-
if (job.state ===
|
|
183
|
+
if (job.state === JobState.QUEUED) {
|
|
172
184
|
const run = runs.find(run => run.job === job.address);
|
|
173
185
|
if (run) {
|
|
174
|
-
job.state =
|
|
186
|
+
job.state = JobState.RUNNING;
|
|
175
187
|
job.timeStart = run.time;
|
|
176
188
|
job.node = run.node;
|
|
177
189
|
}
|
|
@@ -454,11 +466,13 @@ export class JobsProgram extends BaseProgram {
|
|
|
454
466
|
transformJobAccount(jobAccount) {
|
|
455
467
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
456
468
|
const { discriminator: _, ...jobAccountData } = jobAccount.data;
|
|
469
|
+
const converted = convertBigIntToNumber(jobAccountData);
|
|
457
470
|
return {
|
|
458
471
|
address: jobAccount.address,
|
|
459
|
-
...
|
|
472
|
+
...converted,
|
|
460
473
|
ipfsJob: IPFS.solHashToIpfsHash(jobAccountData.ipfsJob),
|
|
461
474
|
ipfsResult: IPFS.solHashToIpfsHash(jobAccountData.ipfsResult),
|
|
475
|
+
state: converted.state,
|
|
462
476
|
};
|
|
463
477
|
}
|
|
464
478
|
transformRunAccount(runAccount) {
|
|
@@ -472,9 +486,11 @@ export class JobsProgram extends BaseProgram {
|
|
|
472
486
|
transformMarketAccount(marketAccount) {
|
|
473
487
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
474
488
|
const { discriminator: _, ...marketAccountData } = marketAccount.data;
|
|
489
|
+
const converted = convertBigIntToNumber(marketAccountData);
|
|
475
490
|
return {
|
|
476
491
|
address: marketAccount.address,
|
|
477
|
-
...
|
|
492
|
+
...converted,
|
|
493
|
+
queueType: converted.queueType,
|
|
478
494
|
};
|
|
479
495
|
}
|
|
480
496
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createSolanaClient, address, getProgramDerivedAddress, getAddressEncoder,
|
|
1
|
+
import { createSolanaClient, address, getProgramDerivedAddress, getAddressEncoder, createTransaction, signTransactionMessageWithSigners, getExplorerLink, getSignatureFromTransaction } from 'gill';
|
|
2
2
|
import { NosanaError, ErrorCodes } from '../errors/NosanaError.js';
|
|
3
3
|
export class SolanaUtils {
|
|
4
4
|
constructor(sdk) {
|
|
@@ -32,9 +32,6 @@ export class SolanaUtils {
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
async getLatestBlockhash() {
|
|
35
|
-
console.log('testing gen key..');
|
|
36
|
-
const jobKey = await generateKeyPairSigner();
|
|
37
|
-
console.log('test', jobKey);
|
|
38
35
|
try {
|
|
39
36
|
const { value: blockhash } = await this.rpc.getLatestBlockhash().send();
|
|
40
37
|
return blockhash;
|
|
@@ -6,8 +6,8 @@ include:
|
|
|
6
6
|
|
|
7
7
|
variables:
|
|
8
8
|
NODE_VERSION: 22
|
|
9
|
-
OUTPUT_DIR:
|
|
10
|
-
PURGE_FILE:
|
|
9
|
+
OUTPUT_DIR: .output/public
|
|
10
|
+
PURGE_FILE: purge.json
|
|
11
11
|
|
|
12
12
|
.npm:
|
|
13
13
|
image: node:$NODE_VERSION
|
|
@@ -42,9 +42,9 @@ pages:
|
|
|
42
42
|
then
|
|
43
43
|
apt update
|
|
44
44
|
apt install -y jq
|
|
45
|
-
find $OUTPUT_DIR -type f | sed "s/${OUTPUT_DIR//\//\\/}/https:\/\/$FQDN/g" | jq -R -s -c 'split("\n")[:-1]' >
|
|
45
|
+
find $OUTPUT_DIR -type f | sed "s/${OUTPUT_DIR//\//\\/}/https:\/\/$FQDN/g" | jq -R -s -c 'split("\n")[:-1]' > ../../$PURGE_FILE
|
|
46
46
|
fi
|
|
47
|
-
- mv $OUTPUT_DIR public
|
|
47
|
+
- mv $OUTPUT_DIR ../../public
|
|
48
48
|
artifacts:
|
|
49
49
|
paths:
|
|
50
50
|
- public
|
|
@@ -16,9 +16,15 @@ export default defineNuxtConfig({
|
|
|
16
16
|
define: {
|
|
17
17
|
global: 'globalThis',
|
|
18
18
|
},
|
|
19
|
+
resolve: {
|
|
20
|
+
alias: {
|
|
21
|
+
// Force gill to use browser build instead of node build
|
|
22
|
+
'gill/node': 'gill/browser',
|
|
23
|
+
}
|
|
24
|
+
},
|
|
19
25
|
optimizeDeps: {
|
|
20
26
|
include: ['@nosana/kit'],
|
|
21
|
-
exclude: ['gill/node'
|
|
27
|
+
exclude: ['gill/node']
|
|
22
28
|
},
|
|
23
29
|
}
|
|
24
30
|
})
|