@nosana/kit 0.1.1 → 0.1.3

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 (71) hide show
  1. package/.gitlab-ci.yml +6 -5
  2. package/dist/config/defaultConfigs.js +15 -18
  3. package/dist/config/index.js +3 -19
  4. package/dist/config/types.d.ts +1 -3
  5. package/dist/config/types.js +4 -7
  6. package/dist/config/utils.js +8 -13
  7. package/dist/errors/NosanaError.d.ts +1 -0
  8. package/dist/errors/NosanaError.js +3 -6
  9. package/dist/generated_clients/jobs/accounts/index.js +3 -19
  10. package/dist/generated_clients/jobs/accounts/jobAccount.js +46 -59
  11. package/dist/generated_clients/jobs/accounts/marketAccount.js +45 -57
  12. package/dist/generated_clients/jobs/accounts/runAccount.js +36 -49
  13. package/dist/generated_clients/jobs/errors/index.js +1 -17
  14. package/dist/generated_clients/jobs/errors/nosanaJobs.js +43 -48
  15. package/dist/generated_clients/jobs/index.js +5 -21
  16. package/dist/generated_clients/jobs/instructions/claim.js +17 -26
  17. package/dist/generated_clients/jobs/instructions/clean.js +17 -26
  18. package/dist/generated_clients/jobs/instructions/cleanAdmin.js +17 -26
  19. package/dist/generated_clients/jobs/instructions/close.js +17 -26
  20. package/dist/generated_clients/jobs/instructions/closeAdmin.js +17 -26
  21. package/dist/generated_clients/jobs/instructions/complete.js +21 -30
  22. package/dist/generated_clients/jobs/instructions/delist.js +17 -26
  23. package/dist/generated_clients/jobs/instructions/end.js +17 -26
  24. package/dist/generated_clients/jobs/instructions/extend.js +21 -30
  25. package/dist/generated_clients/jobs/instructions/finish.js +21 -30
  26. package/dist/generated_clients/jobs/instructions/index.js +18 -34
  27. package/dist/generated_clients/jobs/instructions/list.js +23 -32
  28. package/dist/generated_clients/jobs/instructions/open.js +29 -38
  29. package/dist/generated_clients/jobs/instructions/quit.js +17 -26
  30. package/dist/generated_clients/jobs/instructions/quitAdmin.js +17 -26
  31. package/dist/generated_clients/jobs/instructions/recover.js +17 -26
  32. package/dist/generated_clients/jobs/instructions/stop.js +17 -26
  33. package/dist/generated_clients/jobs/instructions/update.js +29 -38
  34. package/dist/generated_clients/jobs/instructions/work.js +17 -26
  35. package/dist/generated_clients/jobs/programs/index.js +1 -17
  36. package/dist/generated_clients/jobs/programs/nosanaJobs.js +29 -34
  37. package/dist/generated_clients/jobs/shared/index.js +13 -21
  38. package/dist/generated_clients/jobs/types/index.js +3 -19
  39. package/dist/generated_clients/jobs/types/jobState.js +9 -15
  40. package/dist/generated_clients/jobs/types/jobType.js +9 -15
  41. package/dist/generated_clients/jobs/types/queueType.js +9 -15
  42. package/dist/index.d.ts +5 -1
  43. package/dist/index.js +152 -36
  44. package/dist/ipfs/IPFS.js +5 -12
  45. package/dist/logger/Logger.js +1 -5
  46. package/dist/programs/BaseProgram.js +1 -5
  47. package/dist/programs/JobsProgram.d.ts +2 -3
  48. package/dist/programs/JobsProgram.js +35 -99
  49. package/dist/solana/SolanaUtils.d.ts +15 -1
  50. package/dist/solana/SolanaUtils.js +78 -14
  51. package/dist/utils/index.js +1 -4
  52. package/examples/browser/.gitlab-ci.yml +78 -0
  53. package/examples/browser/FEATURES.md +141 -0
  54. package/examples/browser/QUICK_START.md +76 -0
  55. package/examples/browser/README.md +182 -0
  56. package/examples/browser/app.vue +1840 -0
  57. package/examples/browser/assets/css/main.css +7 -0
  58. package/examples/browser/nuxt.config.ts +24 -0
  59. package/examples/browser/package-lock.json +11467 -0
  60. package/examples/browser/package.json +31 -0
  61. package/examples/browser/public/favicon.ico +0 -0
  62. package/examples/browser/public/robots.txt +2 -0
  63. package/examples/browser/start.sh +38 -0
  64. package/examples/browser/tailwind.config.js +26 -0
  65. package/examples/node/README.md +146 -0
  66. package/examples/node/example-keypair.json +1 -0
  67. package/examples/node/package-lock.json +500 -156
  68. package/examples/node/package.json +5 -3
  69. package/examples/node/post-job.ts +160 -0
  70. package/examples/node/set-wallet.ts +87 -0
  71. package/package.json +3 -1
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  /**
3
2
  * This code was AUTOGENERATED using the codama library.
4
3
  * Please DO NOT EDIT THIS FILE, instead use visitors
@@ -6,19 +5,12 @@
6
5
  *
7
6
  * @see https://github.com/codama-idl/codama
8
7
  */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.expectSome = expectSome;
11
- exports.expectAddress = expectAddress;
12
- exports.expectProgramDerivedAddress = expectProgramDerivedAddress;
13
- exports.expectTransactionSigner = expectTransactionSigner;
14
- exports.getAccountMetaFactory = getAccountMetaFactory;
15
- exports.isTransactionSigner = isTransactionSigner;
16
- const kit_1 = require("@solana/kit");
8
+ import { AccountRole, isProgramDerivedAddress, isTransactionSigner as kitIsTransactionSigner, upgradeRoleToSigner, } from '@solana/kit';
17
9
  /**
18
10
  * Asserts that the given value is not null or undefined.
19
11
  * @internal
20
12
  */
21
- function expectSome(value) {
13
+ export function expectSome(value) {
22
14
  if (value == null) {
23
15
  throw new Error('Expected a value but received null or undefined.');
24
16
  }
@@ -28,7 +20,7 @@ function expectSome(value) {
28
20
  * Asserts that the given value is a PublicKey.
29
21
  * @internal
30
22
  */
31
- function expectAddress(value) {
23
+ export function expectAddress(value) {
32
24
  if (!value) {
33
25
  throw new Error('Expected a Address.');
34
26
  }
@@ -44,8 +36,8 @@ function expectAddress(value) {
44
36
  * Asserts that the given value is a PDA.
45
37
  * @internal
46
38
  */
47
- function expectProgramDerivedAddress(value) {
48
- if (!value || !Array.isArray(value) || !(0, kit_1.isProgramDerivedAddress)(value)) {
39
+ export function expectProgramDerivedAddress(value) {
40
+ if (!value || !Array.isArray(value) || !isProgramDerivedAddress(value)) {
49
41
  throw new Error('Expected a ProgramDerivedAddress.');
50
42
  }
51
43
  return value;
@@ -54,7 +46,7 @@ function expectProgramDerivedAddress(value) {
54
46
  * Asserts that the given value is a TransactionSigner.
55
47
  * @internal
56
48
  */
57
- function expectTransactionSigner(value) {
49
+ export function expectTransactionSigner(value) {
58
50
  if (!value || !isTransactionSigner(value)) {
59
51
  throw new Error('Expected a TransactionSigner.');
60
52
  }
@@ -64,31 +56,31 @@ function expectTransactionSigner(value) {
64
56
  * Get account metas and signers from resolved accounts.
65
57
  * @internal
66
58
  */
67
- function getAccountMetaFactory(programAddress, optionalAccountStrategy) {
59
+ export function getAccountMetaFactory(programAddress, optionalAccountStrategy) {
68
60
  return (account) => {
69
61
  if (!account.value) {
70
62
  if (optionalAccountStrategy === 'omitted')
71
63
  return;
72
64
  return Object.freeze({
73
65
  address: programAddress,
74
- role: kit_1.AccountRole.READONLY,
66
+ role: AccountRole.READONLY,
75
67
  });
76
68
  }
77
69
  const writableRole = account.isWritable
78
- ? kit_1.AccountRole.WRITABLE
79
- : kit_1.AccountRole.READONLY;
70
+ ? AccountRole.WRITABLE
71
+ : AccountRole.READONLY;
80
72
  return Object.freeze({
81
73
  address: expectAddress(account.value),
82
74
  role: isTransactionSigner(account.value)
83
- ? (0, kit_1.upgradeRoleToSigner)(writableRole)
75
+ ? upgradeRoleToSigner(writableRole)
84
76
  : writableRole,
85
77
  ...(isTransactionSigner(account.value) ? { signer: account.value } : {}),
86
78
  });
87
79
  };
88
80
  }
89
- function isTransactionSigner(value) {
81
+ export function isTransactionSigner(value) {
90
82
  return (!!value &&
91
83
  typeof value === 'object' &&
92
84
  'address' in value &&
93
- (0, kit_1.isTransactionSigner)(value));
85
+ kitIsTransactionSigner(value));
94
86
  }
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  /**
3
2
  * This code was AUTOGENERATED using the codama library.
4
3
  * Please DO NOT EDIT THIS FILE, instead use visitors
@@ -6,21 +5,6 @@
6
5
  *
7
6
  * @see https://github.com/codama-idl/codama
8
7
  */
9
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- var desc = Object.getOwnPropertyDescriptor(m, k);
12
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
- desc = { enumerable: true, get: function() { return m[k]; } };
14
- }
15
- Object.defineProperty(o, k2, desc);
16
- }) : (function(o, m, k, k2) {
17
- if (k2 === undefined) k2 = k;
18
- o[k2] = m[k];
19
- }));
20
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
21
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
22
- };
23
- Object.defineProperty(exports, "__esModule", { value: true });
24
- __exportStar(require("./jobState"), exports);
25
- __exportStar(require("./jobType"), exports);
26
- __exportStar(require("./queueType"), exports);
8
+ export * from './jobState';
9
+ export * from './jobType';
10
+ export * from './queueType';
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  /**
3
2
  * This code was AUTOGENERATED using the codama library.
4
3
  * Please DO NOT EDIT THIS FILE, instead use visitors
@@ -6,25 +5,20 @@
6
5
  *
7
6
  * @see https://github.com/codama-idl/codama
8
7
  */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.JobState = void 0;
11
- exports.getJobStateEncoder = getJobStateEncoder;
12
- exports.getJobStateDecoder = getJobStateDecoder;
13
- exports.getJobStateCodec = getJobStateCodec;
14
- const kit_1 = require("@solana/kit");
8
+ import { combineCodec, getEnumDecoder, getEnumEncoder, } from '@solana/kit';
15
9
  /** The `JobState` describes the status of a job. */
16
- var JobState;
10
+ export var JobState;
17
11
  (function (JobState) {
18
12
  JobState[JobState["Queued"] = 0] = "Queued";
19
13
  JobState[JobState["Done"] = 1] = "Done";
20
14
  JobState[JobState["Stopped"] = 2] = "Stopped";
21
- })(JobState || (exports.JobState = JobState = {}));
22
- function getJobStateEncoder() {
23
- return (0, kit_1.getEnumEncoder)(JobState);
15
+ })(JobState || (JobState = {}));
16
+ export function getJobStateEncoder() {
17
+ return getEnumEncoder(JobState);
24
18
  }
25
- function getJobStateDecoder() {
26
- return (0, kit_1.getEnumDecoder)(JobState);
19
+ export function getJobStateDecoder() {
20
+ return getEnumDecoder(JobState);
27
21
  }
28
- function getJobStateCodec() {
29
- return (0, kit_1.combineCodec)(getJobStateEncoder(), getJobStateDecoder());
22
+ export function getJobStateCodec() {
23
+ return combineCodec(getJobStateEncoder(), getJobStateDecoder());
30
24
  }
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  /**
3
2
  * This code was AUTOGENERATED using the codama library.
4
3
  * Please DO NOT EDIT THIS FILE, instead use visitors
@@ -6,14 +5,9 @@
6
5
  *
7
6
  * @see https://github.com/codama-idl/codama
8
7
  */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.JobType = void 0;
11
- exports.getJobTypeEncoder = getJobTypeEncoder;
12
- exports.getJobTypeDecoder = getJobTypeDecoder;
13
- exports.getJobTypeCodec = getJobTypeCodec;
14
- const kit_1 = require("@solana/kit");
8
+ import { combineCodec, getEnumDecoder, getEnumEncoder, } from '@solana/kit';
15
9
  /** The `JobType` describes the type of any job. */
16
- var JobType;
10
+ export var JobType;
17
11
  (function (JobType) {
18
12
  JobType[JobType["Default"] = 0] = "Default";
19
13
  JobType[JobType["Small"] = 1] = "Small";
@@ -21,13 +15,13 @@ var JobType;
21
15
  JobType[JobType["Large"] = 3] = "Large";
22
16
  JobType[JobType["Gpu"] = 4] = "Gpu";
23
17
  JobType[JobType["Unknown"] = 5] = "Unknown";
24
- })(JobType || (exports.JobType = JobType = {}));
25
- function getJobTypeEncoder() {
26
- return (0, kit_1.getEnumEncoder)(JobType);
18
+ })(JobType || (JobType = {}));
19
+ export function getJobTypeEncoder() {
20
+ return getEnumEncoder(JobType);
27
21
  }
28
- function getJobTypeDecoder() {
29
- return (0, kit_1.getEnumDecoder)(JobType);
22
+ export function getJobTypeDecoder() {
23
+ return getEnumDecoder(JobType);
30
24
  }
31
- function getJobTypeCodec() {
32
- return (0, kit_1.combineCodec)(getJobTypeEncoder(), getJobTypeDecoder());
25
+ export function getJobTypeCodec() {
26
+ return combineCodec(getJobTypeEncoder(), getJobTypeDecoder());
33
27
  }
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  /**
3
2
  * This code was AUTOGENERATED using the codama library.
4
3
  * Please DO NOT EDIT THIS FILE, instead use visitors
@@ -6,25 +5,20 @@
6
5
  *
7
6
  * @see https://github.com/codama-idl/codama
8
7
  */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.QueueType = void 0;
11
- exports.getQueueTypeEncoder = getQueueTypeEncoder;
12
- exports.getQueueTypeDecoder = getQueueTypeDecoder;
13
- exports.getQueueTypeCodec = getQueueTypeCodec;
14
- const kit_1 = require("@solana/kit");
8
+ import { combineCodec, getEnumDecoder, getEnumEncoder, } from '@solana/kit';
15
9
  /** The `QueueType` describes the type of queue */
16
- var QueueType;
10
+ export var QueueType;
17
11
  (function (QueueType) {
18
12
  QueueType[QueueType["Job"] = 0] = "Job";
19
13
  QueueType[QueueType["Node"] = 1] = "Node";
20
14
  QueueType[QueueType["Empty"] = 2] = "Empty";
21
- })(QueueType || (exports.QueueType = QueueType = {}));
22
- function getQueueTypeEncoder() {
23
- return (0, kit_1.getEnumEncoder)(QueueType);
15
+ })(QueueType || (QueueType = {}));
16
+ export function getQueueTypeEncoder() {
17
+ return getEnumEncoder(QueueType);
24
18
  }
25
- function getQueueTypeDecoder() {
26
- return (0, kit_1.getEnumDecoder)(QueueType);
19
+ export function getQueueTypeDecoder() {
20
+ return getEnumDecoder(QueueType);
27
21
  }
28
- function getQueueTypeCodec() {
29
- return (0, kit_1.combineCodec)(getQueueTypeEncoder(), getQueueTypeDecoder());
22
+ export function getQueueTypeCodec() {
23
+ return combineCodec(getQueueTypeEncoder(), getQueueTypeDecoder());
30
24
  }
package/dist/index.d.ts CHANGED
@@ -1,13 +1,17 @@
1
- import { ClientConfig, NosanaNetwork, PartialClientConfig } from './config/index.js';
1
+ import { ClientConfig, NosanaNetwork, PartialClientConfig, WalletConfig } from './config/index.js';
2
2
  import { Logger } from './logger/Logger.js';
3
3
  import { JobsProgram } from './programs/JobsProgram.js';
4
4
  import { SolanaUtils } from './solana/SolanaUtils.js';
5
+ import { KeyPairSigner } from 'gill';
5
6
  export declare class NosanaClient {
6
7
  readonly config: ClientConfig;
7
8
  readonly jobs: JobsProgram;
8
9
  readonly solana: SolanaUtils;
9
10
  readonly logger: Logger;
11
+ wallet: KeyPairSigner | undefined;
10
12
  constructor(network?: NosanaNetwork, customConfig?: PartialClientConfig);
13
+ setWallet(wallet: WalletConfig): Promise<KeyPairSigner | undefined>;
14
+ private isValidFilePath;
11
15
  }
12
16
  export * from './config/index.js';
13
17
  export * from './errors/NosanaError.js';
package/dist/index.js CHANGED
@@ -1,43 +1,159 @@
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]; } };
1
+ import { Buffer } from 'buffer';
2
+ if (typeof window !== 'undefined' && typeof window.Buffer === 'undefined') {
3
+ window.Buffer = Buffer;
4
+ }
5
+ import { getNosanaConfig, NosanaNetwork } from './config/index.js';
6
+ import { Logger } from './logger/Logger.js';
7
+ import { JobsProgram } from './programs/JobsProgram.js';
8
+ import { SolanaUtils } from './solana/SolanaUtils.js';
9
+ import { createKeyPairSignerFromBytes } from 'gill';
10
+ import { NosanaError, ErrorCodes } from './errors/NosanaError.js';
11
+ import bs58 from 'bs58';
12
+ export class NosanaClient {
13
+ constructor(network = NosanaNetwork.MAINNET, customConfig) {
14
+ this.config = getNosanaConfig(network, customConfig);
15
+ if (this.config.wallet) {
16
+ this.setWallet(this.config.wallet);
17
+ }
18
+ this.jobs = new JobsProgram(this);
19
+ this.logger = Logger.getInstance();
20
+ this.solana = new SolanaUtils(this);
21
+ }
22
+ async setWallet(wallet) {
23
+ try {
24
+ // Check if we already have a KeyPairSigner type
25
+ if (wallet && typeof wallet === 'object' && 'address' in wallet && 'signMessages' in wallet) {
26
+ this.wallet = wallet;
27
+ return this.wallet;
28
+ }
29
+ // Check if it's a browser wallet adapter (has publicKey and signTransaction/signMessage)
30
+ if (wallet && typeof wallet === 'object' && 'publicKey' in wallet && ('signTransaction' in wallet || 'signMessage' in wallet)) {
31
+ // Convert browser wallet adapter to KeyPairSigner-like interface
32
+ const browserWallet = wallet;
33
+ this.wallet = {
34
+ address: browserWallet.publicKey.toString(),
35
+ signMessages: async (messages) => {
36
+ if (browserWallet.signMessage) {
37
+ return Promise.all(messages.map(msg => browserWallet.signMessage(msg)));
38
+ }
39
+ throw new Error('Browser wallet does not support message signing');
40
+ },
41
+ signTransactions: async (transactions) => {
42
+ if (browserWallet.signTransaction) {
43
+ return Promise.all(transactions.map(tx => browserWallet.signTransaction(tx)));
44
+ }
45
+ throw new Error('Browser wallet does not support transaction signing');
46
+ }
47
+ };
48
+ return this.wallet;
49
+ }
50
+ // If it's a string, try multiple conversion methods
51
+ if (typeof wallet === 'string') {
52
+ // Only try file/environment loading in Node.js environment
53
+ if (typeof window === 'undefined') {
54
+ try {
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);
58
+ // Try to load from file path
59
+ if (await this.isValidFilePath(wallet)) {
60
+ try {
61
+ this.wallet = await loadKeypairSignerFromFile(wallet);
62
+ return this.wallet;
63
+ }
64
+ catch (error) {
65
+ this.logger.debug(`Failed to load keypair from file: ${error}`);
66
+ }
67
+ }
68
+ // Try to load from environment variable
69
+ try {
70
+ this.wallet = await loadKeypairSignerFromEnvironment(wallet);
71
+ return this.wallet;
72
+ }
73
+ catch (error) {
74
+ this.logger.debug(`Failed to load keypair from environment: ${error}`);
75
+ }
76
+ // Try to load from environment variable as base58
77
+ try {
78
+ this.wallet = await loadKeypairSignerFromEnvironmentBase58(wallet);
79
+ return this.wallet;
80
+ }
81
+ catch (error) {
82
+ this.logger.debug(`Failed to load keypair from environment base58: ${error}`);
83
+ }
84
+ }
85
+ catch (error) {
86
+ this.logger.debug(`Node.js modules not available: ${error}`);
87
+ }
88
+ }
89
+ // Try to parse as JSON array
90
+ if (wallet.startsWith('[')) {
91
+ try {
92
+ const key = JSON.parse(wallet);
93
+ this.wallet = await createKeyPairSignerFromBytes(new Uint8Array(key));
94
+ return this.wallet;
95
+ }
96
+ catch (error) {
97
+ this.logger.debug(`Failed to parse as JSON array: ${error}`);
98
+ }
99
+ }
100
+ // Try to decode as base58
101
+ try {
102
+ const key = Buffer.from(bs58.decode(wallet)).toJSON().data;
103
+ this.wallet = await createKeyPairSignerFromBytes(new Uint8Array(key));
104
+ return this.wallet;
105
+ }
106
+ catch (error) {
107
+ this.logger.debug(`Failed to decode as base58: ${error}`);
108
+ }
109
+ }
110
+ // If it's an array, try to create from bytes
111
+ if (Array.isArray(wallet)) {
112
+ try {
113
+ this.wallet = await createKeyPairSignerFromBytes(new Uint8Array(wallet));
114
+ return this.wallet;
115
+ }
116
+ catch (error) {
117
+ this.logger.debug(`Failed to create from byte array: ${error}`);
118
+ }
119
+ }
120
+ // If we get here, none of the conversion methods worked
121
+ throw new Error('Unable to convert wallet to KeyPairSigner using any available method');
122
+ }
123
+ catch (error) {
124
+ throw new NosanaError(`Failed to convert wallet to KeyPairSigner: ${error instanceof Error ? error.message : 'Unknown error'}`, ErrorCodes.WALLET_CONVERSION_ERROR, error);
125
+ }
7
126
  }
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.JobsProgram = exports.NosanaClient = void 0;
18
- const index_js_1 = require("./config/index.js");
19
- const Logger_js_1 = require("./logger/Logger.js");
20
- const JobsProgram_js_1 = require("./programs/JobsProgram.js");
21
- const SolanaUtils_js_1 = require("./solana/SolanaUtils.js");
22
- class NosanaClient {
23
- constructor(network = index_js_1.NosanaNetwork.MAINNET, customConfig) {
24
- this.config = (0, index_js_1.getNosanaConfig)(network, customConfig);
25
- this.jobs = new JobsProgram_js_1.JobsProgram(this);
26
- this.logger = Logger_js_1.Logger.getInstance();
27
- this.solana = new SolanaUtils_js_1.SolanaUtils(this);
127
+ async isValidFilePath(filePath) {
128
+ // Only validate file paths in Node.js environment
129
+ if (typeof window !== 'undefined') {
130
+ return false; // Browser environment, no file system access
131
+ }
132
+ try {
133
+ const [fs, path] = await Promise.all([
134
+ import('fs'),
135
+ import('path')
136
+ ]);
137
+ if (!path.isAbsolute(filePath) && !filePath.startsWith('./') && !filePath.startsWith('../')) {
138
+ return false;
139
+ }
140
+ const stats = await fs.promises.stat(filePath);
141
+ return stats.isFile();
142
+ }
143
+ catch {
144
+ return false;
145
+ }
28
146
  }
29
147
  }
30
- exports.NosanaClient = NosanaClient;
31
148
  // Export types and configuration
32
- __exportStar(require("./config/index.js"), exports);
33
- __exportStar(require("./errors/NosanaError.js"), exports);
34
- __exportStar(require("./logger/Logger.js"), exports);
149
+ export * from './config/index.js';
150
+ export * from './errors/NosanaError.js';
151
+ export * from './logger/Logger.js';
35
152
  // Export JobsProgram and related types
36
- var JobsProgram_js_2 = require("./programs/JobsProgram.js");
37
- Object.defineProperty(exports, "JobsProgram", { enumerable: true, get: function () { return JobsProgram_js_2.JobsProgram; } });
153
+ export { JobsProgram } from './programs/JobsProgram.js';
38
154
  // Export IPFS utilities
39
- __exportStar(require("./ipfs/IPFS.js"), exports);
155
+ export * from './ipfs/IPFS.js';
40
156
  // Export all generated client types and functions
41
- __exportStar(require("./generated_clients/jobs/index.js"), exports);
42
- // Export dependencies
43
- __exportStar(require("gill"), exports);
157
+ export * from './generated_clients/jobs/index.js';
158
+ // Export dependencies
159
+ export * from 'gill';
package/dist/ipfs/IPFS.js CHANGED
@@ -1,15 +1,9 @@
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.IPFS = void 0;
7
- const bs58_1 = __importDefault(require("bs58"));
1
+ import bs58 from 'bs58';
8
2
  /**
9
3
  * Class to interact with Pinata Cloud
10
4
  * https://www.pinata.cloud/
11
5
  */
12
- class IPFS {
6
+ export class IPFS {
13
7
  /**
14
8
  * Convert the ipfs bytes from a solana job to a CID
15
9
  * It prepends the 0x1220 (18,32) to make it 34 bytes and Base58 encodes it.
@@ -28,7 +22,7 @@ class IPFS {
28
22
  // Use the array as-is if it's not 32 bytes
29
23
  finalArray = new Uint8Array(hashArray);
30
24
  }
31
- return bs58_1.default.encode(Buffer.from(finalArray));
25
+ return bs58.encode(Buffer.from(finalArray));
32
26
  }
33
27
  /**
34
28
  * Converts IPFS hash to byte array needed to submit results
@@ -37,11 +31,10 @@ class IPFS {
37
31
  */
38
32
  static IpfsHashToByteArray(hash) {
39
33
  if (hash.length === 34) {
40
- return new Uint8Array([...bs58_1.default.decode(hash).subarray(2)]);
34
+ return new Uint8Array([...bs58.decode(hash).subarray(2)]);
41
35
  }
42
36
  else {
43
- return new Uint8Array([...bs58_1.default.decode(hash)]);
37
+ return new Uint8Array([...bs58.decode(hash)]);
44
38
  }
45
39
  }
46
40
  }
47
- exports.IPFS = IPFS;
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Logger = void 0;
4
- class Logger {
1
+ export class Logger {
5
2
  constructor(options) {
6
3
  this.level = 'info';
7
4
  this.prefix = '[Nosana]';
@@ -60,4 +57,3 @@ class Logger {
60
57
  this.enabled = false;
61
58
  }
62
59
  }
63
- exports.Logger = Logger;
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BaseProgram = void 0;
4
- class BaseProgram {
1
+ export class BaseProgram {
5
2
  /**
6
3
  * Gets the static accounts, initializing them if needed.
7
4
  */
@@ -36,4 +33,3 @@ class BaseProgram {
36
33
  this.sdk = sdk;
37
34
  }
38
35
  }
39
- exports.BaseProgram = BaseProgram;
@@ -1,5 +1,5 @@
1
1
  import { BaseProgram } from './BaseProgram.js';
2
- import { Address, Signature, Account } from 'gill';
2
+ 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';
@@ -62,8 +62,7 @@ export declare class JobsProgram extends BaseProgram {
62
62
  timeout: number | bigint;
63
63
  ipfsHash: string;
64
64
  node?: Address;
65
- instructionOnly?: boolean;
66
- }): Promise<ReturnType<typeof this.client.getListInstruction> | Signature>;
65
+ }): Promise<ReturnType<typeof this.client.getListInstruction>>;
67
66
  /**
68
67
  * Monitor program account updates using callback functions
69
68
  * Uses WebSocket subscriptions with automatic restart on failure