@nosana/api 0.1.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/README.md +0 -0
- package/dist/client/index.d.ts +9 -0
- package/dist/client/index.js +21 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/schema.d.ts +3551 -0
- package/dist/client/schema.js +6 -0
- package/dist/client/schema.js.map +1 -0
- package/dist/client/type.utils.d.ts +45 -0
- package/dist/client/type.utils.js +2 -0
- package/dist/client/type.utils.js.map +1 -0
- package/dist/credits/index.d.ts +4 -0
- package/dist/credits/index.js +14 -0
- package/dist/credits/index.js.map +1 -0
- package/dist/credits/types.d.ts +5 -0
- package/dist/credits/types.js +2 -0
- package/dist/credits/types.js.map +1 -0
- package/dist/defaults/index.d.ts +2 -0
- package/dist/defaults/index.js +6 -0
- package/dist/defaults/index.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/jobs/index.d.ts +4 -0
- package/dist/jobs/index.js +56 -0
- package/dist/jobs/index.js.map +1 -0
- package/dist/jobs/types.d.ts +13 -0
- package/dist/jobs/types.js +2 -0
- package/dist/jobs/types.js.map +1 -0
- package/dist/markets/index.d.ts +4 -0
- package/dist/markets/index.js +38 -0
- package/dist/markets/index.js.map +1 -0
- package/dist/markets/types.d.ts +8 -0
- package/dist/markets/types.js +2 -0
- package/dist/markets/types.js.map +1 -0
- package/dist/types.d.ts +15 -0
- package/dist/types.js +6 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/errorFormatter.d.ts +13 -0
- package/dist/utils/errorFormatter.js +23 -0
- package/dist/utils/errorFormatter.js.map +1 -0
- package/package.json +44 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/client/schema.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import createClient from "openapi-fetch";
|
|
2
|
+
export type EnumValues<T> = T[keyof T];
|
|
3
|
+
/**
|
|
4
|
+
* Utility type to remove header requirements from OpenAPI parameters
|
|
5
|
+
* This preserves the original structure but removes headers and makes undefined params optional
|
|
6
|
+
* We only modify the parameters, leaving responses and requestBody untouched
|
|
7
|
+
*/
|
|
8
|
+
type OmitHeaders<T> = T extends {
|
|
9
|
+
parameters: {
|
|
10
|
+
header?: any;
|
|
11
|
+
path?: infer Path;
|
|
12
|
+
query?: infer Query;
|
|
13
|
+
cookie?: infer Cookie;
|
|
14
|
+
};
|
|
15
|
+
responses?: infer Responses;
|
|
16
|
+
requestBody?: infer RequestBody;
|
|
17
|
+
} ? {
|
|
18
|
+
parameters: {
|
|
19
|
+
header?: never;
|
|
20
|
+
} & (Path extends undefined ? {} : {
|
|
21
|
+
path: Path;
|
|
22
|
+
}) & (Query extends undefined ? {} : {
|
|
23
|
+
query: Query;
|
|
24
|
+
}) & (Cookie extends undefined ? {} : {
|
|
25
|
+
cookie: Cookie;
|
|
26
|
+
});
|
|
27
|
+
} & (Responses extends undefined ? {} : {
|
|
28
|
+
responses: Responses;
|
|
29
|
+
}) & (RequestBody extends undefined ? {} : {
|
|
30
|
+
requestBody: RequestBody;
|
|
31
|
+
}) : T;
|
|
32
|
+
/**
|
|
33
|
+
* Type that removes header requirements from all endpoints in the paths
|
|
34
|
+
* This should preserve response types and other properties
|
|
35
|
+
*/
|
|
36
|
+
export type AuthenticatedPaths<Paths extends Record<string, any>> = {
|
|
37
|
+
[P in keyof Paths]: {
|
|
38
|
+
[M in keyof Paths[P]]: OmitHeaders<Paths[P][M]>;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Explicit client type that should preserve all response typing
|
|
43
|
+
*/
|
|
44
|
+
export type AuthenticatedClient<Paths extends Record<string, any>> = ReturnType<typeof createClient<AuthenticatedPaths<Paths>>>;
|
|
45
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.utils.js","sourceRoot":"","sources":["../../src/client/type.utils.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { errorFormatter } from '../utils/errorFormatter.js';
|
|
2
|
+
export * from "./types.js";
|
|
3
|
+
export function createNosanaCreditsApi(client) {
|
|
4
|
+
return {
|
|
5
|
+
async balance() {
|
|
6
|
+
const { data, error } = await client.GET('/api/credits/balance', {});
|
|
7
|
+
if (!data || error) {
|
|
8
|
+
throw errorFormatter('Failed to fetch balance', error);
|
|
9
|
+
}
|
|
10
|
+
return data;
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/credits/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAK5D,cAAc,YAAY,CAAA;AAE1B,MAAM,UAAU,sBAAsB,CAAC,MAAmB;IACxD,OAAO;QACL,KAAK,CAAC,OAAO;YACX,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,GAAG,CAAC,sBAAsB,EAAE,EAAE,CAAC,CAAC;YACrE,IAAI,CAAC,IAAI,IAAI,KAAK,EAAE,CAAC;gBACnB,MAAM,cAAc,CAAC,yBAAyB,EAAE,KAAK,CAAC,CAAC;YACzD,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/credits/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/defaults/index.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,aAAa,GAAkC;IAC1D,OAAO,EAAE,kCAAkC;IAC3C,MAAM,EAAE,kCAAkC;IAC1C,KAAK,EAAE,uBAAuB;CAC/B,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type NosanaJobsApi } from './jobs/index.js';
|
|
2
|
+
import { type NosanaCreditsApi } from './credits/index.js';
|
|
3
|
+
import { type NosanaMarketsApi } from './markets/index.js';
|
|
4
|
+
import type { ApiKeyAuth, SignerAuth, NosanaNetwork, CreateNosanaApiOptions } from './types.js';
|
|
5
|
+
export interface NosanaApi {
|
|
6
|
+
jobs: NosanaJobsApi;
|
|
7
|
+
credits: NosanaCreditsApi;
|
|
8
|
+
markets: NosanaMarketsApi;
|
|
9
|
+
}
|
|
10
|
+
export declare function createNosanaApi(environment: NosanaNetwork, signerAuth: SignerAuth, options?: CreateNosanaApiOptions): NosanaApi;
|
|
11
|
+
export declare function createNosanaApi(environment: NosanaNetwork, apiKeyAuth: ApiKeyAuth, options?: CreateNosanaApiOptions): NosanaApi;
|
|
12
|
+
export * from './types.js';
|
|
13
|
+
export type { ApiConfig } from './client/index.js';
|
|
14
|
+
export type * from './jobs/types.js';
|
|
15
|
+
export type * from './credits/types.js';
|
|
16
|
+
export type * from './markets/types.js';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import assert from 'node:assert';
|
|
2
|
+
import { createNosanaClient } from './client/index.js';
|
|
3
|
+
import { createNosanaJobsApi } from './jobs/index.js';
|
|
4
|
+
import { createNosanaCreditsApi } from './credits/index.js';
|
|
5
|
+
import { createNosanaMarketsApi } from './markets/index.js';
|
|
6
|
+
export function createNosanaApi(environment = 'mainnet', signerOrApiKey, options) {
|
|
7
|
+
assert(typeof signerOrApiKey === 'string' ||
|
|
8
|
+
('identifier' in signerOrApiKey && 'generateAuthHeader' in signerOrApiKey), 'Authentication parameters are required to create Nosana API client');
|
|
9
|
+
const client = createNosanaClient(environment, signerOrApiKey, options);
|
|
10
|
+
return {
|
|
11
|
+
jobs: createNosanaJobsApi(client),
|
|
12
|
+
credits: createNosanaCreditsApi(client),
|
|
13
|
+
markets: createNosanaMarketsApi(client),
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
// Export types
|
|
17
|
+
export * from './types.js';
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AAEjC,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAsB,MAAM,iBAAiB,CAAC;AAC1E,OAAO,EAAE,sBAAsB,EAAyB,MAAM,oBAAoB,CAAC;AACnF,OAAO,EAAE,sBAAsB,EAAyB,MAAM,oBAAoB,CAAC;AAanF,MAAM,UAAU,eAAe,CAC7B,cAA6B,SAAS,EACtC,cAAuC,EACvC,OAAgC;IAEhC,MAAM,CACJ,OAAO,cAAc,KAAK,QAAQ;QAClC,CAAC,YAAY,IAAI,cAAc,IAAI,oBAAoB,IAAI,cAAc,CAAC,EAC1E,oEAAoE,CACrE,CAAC;IAEF,MAAM,MAAM,GAAG,kBAAkB,CAAC,WAAW,EAAE,cAAc,EAAE,OAAO,CAAC,CAAC;IAExE,OAAO;QACL,IAAI,EAAE,mBAAmB,CAAC,MAAM,CAAC;QACjC,OAAO,EAAE,sBAAsB,CAAC,MAAM,CAAC;QACvC,OAAO,EAAE,sBAAsB,CAAC,MAAM,CAAC;KACxC,CAAC;AACJ,CAAC;AAED,eAAe;AACf,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { errorFormatter } from '../utils/errorFormatter.js';
|
|
2
|
+
export * from './types.js';
|
|
3
|
+
export function createNosanaJobsApi(client) {
|
|
4
|
+
return {
|
|
5
|
+
async get(jobAddress) {
|
|
6
|
+
const { data, error } = await client.GET('/api/jobs/{address}', {
|
|
7
|
+
params: {
|
|
8
|
+
path: {
|
|
9
|
+
address: jobAddress
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
if (!data || error) {
|
|
14
|
+
throw errorFormatter('Failed to get job', error);
|
|
15
|
+
}
|
|
16
|
+
return data;
|
|
17
|
+
},
|
|
18
|
+
async create(request) {
|
|
19
|
+
const { data, error } = await client.POST('/api/jobs/list', {
|
|
20
|
+
body: request,
|
|
21
|
+
});
|
|
22
|
+
if (!data || error) {
|
|
23
|
+
throw errorFormatter('Failed to create job', error);
|
|
24
|
+
}
|
|
25
|
+
return data;
|
|
26
|
+
},
|
|
27
|
+
async extend(jobAddress, request) {
|
|
28
|
+
const { data, error } = await client.POST('/api/jobs/{address}/extend', {
|
|
29
|
+
params: {
|
|
30
|
+
path: {
|
|
31
|
+
address: jobAddress
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
body: request,
|
|
35
|
+
});
|
|
36
|
+
if (!data || error) {
|
|
37
|
+
throw errorFormatter('Failed to extend job', error);
|
|
38
|
+
}
|
|
39
|
+
return data;
|
|
40
|
+
},
|
|
41
|
+
async stop(jobAddress) {
|
|
42
|
+
const { data, error } = await client.POST('/api/jobs/{address}/stop', {
|
|
43
|
+
params: {
|
|
44
|
+
path: {
|
|
45
|
+
address: jobAddress
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
if (!data || error) {
|
|
50
|
+
throw errorFormatter('Failed to stop job', error);
|
|
51
|
+
}
|
|
52
|
+
return data;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/jobs/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAa5D,cAAc,YAAY,CAAC;AAE3B,MAAM,UAAU,mBAAmB,CAAC,MAAmB;IACrD,OAAO;QACL,KAAK,CAAC,GAAG,CAAC,UAAkB;YAC1B,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,GAAG,CAAC,qBAAqB,EAAE;gBAC9D,MAAM,EAAE;oBACN,IAAI,EAAE;wBACJ,OAAO,EAAE,UAAU;qBACpB;iBACF;aACF,CAAC,CAAC;YAEH,IAAI,CAAC,IAAI,IAAI,KAAK,EAAE,CAAC;gBACnB,MAAM,cAAc,CAAC,mBAAmB,EAAE,KAAK,CAAC,CAAC;YACnD,CAAC;YAED,OAAO,IAAI,CAAC;QACd,CAAC;QACD,KAAK,CAAC,MAAM,CAAC,OAAoC;YAC/C,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,gBAAgB,EAAE;gBAC1D,IAAI,EAAE,OAAO;aACd,CAAC,CAAC;YAEH,IAAI,CAAC,IAAI,IAAI,KAAK,EAAE,CAAC;gBACnB,MAAM,cAAc,CAAC,sBAAsB,EAAE,KAAK,CAAC,CAAC;YACtD,CAAC;YAED,OAAO,IAAI,CAAC;QACd,CAAC;QACD,KAAK,CAAC,MAAM,CAAC,UAAkB,EAAE,OAAoC;YACnE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,4BAA4B,EAAE;gBACtE,MAAM,EAAE;oBACN,IAAI,EAAE;wBACJ,OAAO,EAAE,UAAU;qBACpB;iBACF;gBACD,IAAI,EAAE,OAAO;aACd,CAAC,CAAC;YAEH,IAAI,CAAC,IAAI,IAAI,KAAK,EAAE,CAAC;gBACnB,MAAM,cAAc,CAAC,sBAAsB,EAAE,KAAK,CAAC,CAAC;YACtD,CAAC;YAED,OAAO,IAAI,CAAC;QACd,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,UAAkB;YAC3B,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,0BAA0B,EAAE;gBACpE,MAAM,EAAE;oBACN,IAAI,EAAE;wBACJ,OAAO,EAAE,UAAU;qBACpB;iBACF;aACF,CAAC,CAAC;YAEH,IAAI,CAAC,IAAI,IAAI,KAAK,EAAE,CAAC;gBACnB,MAAM,cAAc,CAAC,oBAAoB,EAAE,KAAK,CAAC,CAAC;YACpD,CAAC;YAED,OAAO,IAAI,CAAC;QACd,CAAC;KACF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { operations } from "../client/schema.js";
|
|
2
|
+
export type CreateJobWithCreditsRequest = operations['postApiJobsList']['requestBody']['content']['application/json'];
|
|
3
|
+
export type ExtendJobWithCreditsRequest = operations['postApiJobsByAddressExtend']['requestBody']['content']['application/json'];
|
|
4
|
+
export type CreateJobWithCreditsResponse = operations['postApiJobsList']['responses'][200]['content']['application/json'];
|
|
5
|
+
export type ExtendJobWithCreditsResponse = operations['postApiJobsByAddressExtend']['responses'][200]['content']['application/json'];
|
|
6
|
+
export type StopJobWithCreditsResponse = operations['postApiJobsByAddressStop']['responses'][200]['content']['application/json'];
|
|
7
|
+
export type GetJobByAddressResponse = operations['getApiJobsByAddress']['responses'][200]['content']['application/json'];
|
|
8
|
+
export interface NosanaJobsApi {
|
|
9
|
+
get: (jobAddress: string) => Promise<GetJobByAddressResponse>;
|
|
10
|
+
create: (request: CreateJobWithCreditsRequest) => Promise<CreateJobWithCreditsResponse>;
|
|
11
|
+
extend: (jobAddress: string, request: ExtendJobWithCreditsRequest) => Promise<ExtendJobWithCreditsResponse>;
|
|
12
|
+
stop: (jobAddress: string) => Promise<StopJobWithCreditsResponse>;
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/jobs/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { errorFormatter } from '../utils/errorFormatter.js';
|
|
2
|
+
export * from './types.js';
|
|
3
|
+
export function createNosanaMarketsApi(client) {
|
|
4
|
+
return {
|
|
5
|
+
async list() {
|
|
6
|
+
const { data, error } = await client.GET('/api/markets/', {
|
|
7
|
+
params: { query: {} }
|
|
8
|
+
});
|
|
9
|
+
if (!data || error) {
|
|
10
|
+
throw errorFormatter('Failed to fetch markets', error);
|
|
11
|
+
}
|
|
12
|
+
return data;
|
|
13
|
+
},
|
|
14
|
+
async get(market) {
|
|
15
|
+
const { data, error } = await client.GET('/api/markets/{id}/', {
|
|
16
|
+
params: {
|
|
17
|
+
path: { id: market }
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
if (!data || error) {
|
|
21
|
+
throw errorFormatter('Failed to fetch market', error);
|
|
22
|
+
}
|
|
23
|
+
return data;
|
|
24
|
+
},
|
|
25
|
+
async getRequiredResources(market) {
|
|
26
|
+
const { data, error } = await client.GET('/api/markets/{id}/required-resources', {
|
|
27
|
+
params: {
|
|
28
|
+
path: { id: market }
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
if (!data || error) {
|
|
32
|
+
throw errorFormatter('Failed to fetch required resources', error);
|
|
33
|
+
}
|
|
34
|
+
return data;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/markets/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAK5D,cAAc,YAAY,CAAC;AAE3B,MAAM,UAAU,sBAAsB,CAAC,MAAmB;IACxD,OAAO;QACL,KAAK,CAAC,IAAI;YACR,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,GAAG,CAAC,eAAe,EAAE;gBACxD,MAAM,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE;aACtB,CAAC,CAAC;YAEH,IAAI,CAAC,IAAI,IAAI,KAAK,EAAE,CAAC;gBACnB,MAAM,cAAc,CAAC,yBAAyB,EAAE,KAAK,CAAC,CAAC;YACzD,CAAC;YAED,OAAO,IAAI,CAAC;QACd,CAAC;QACD,KAAK,CAAC,GAAG,CAAC,MAAc;YACtB,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,GAAG,CAAC,oBAAoB,EAAE;gBAC7D,MAAM,EAAE;oBACN,IAAI,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE;iBACrB;aACF,CAAC,CAAC;YAEH,IAAI,CAAC,IAAI,IAAI,KAAK,EAAE,CAAC;gBACnB,MAAM,cAAc,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAC;YACxD,CAAC;YAED,OAAO,IAAI,CAAC;QACd,CAAC;QACD,KAAK,CAAC,oBAAoB,CAAC,MAAc;YACvC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,GAAG,CAAC,sCAAsC,EAAE;gBAC/E,MAAM,EAAE;oBACN,IAAI,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE;iBACrB;aACF,CAAC,CAAC;YAEH,IAAI,CAAC,IAAI,IAAI,KAAK,EAAE,CAAC;gBACnB,MAAM,cAAc,CAAC,oCAAoC,EAAE,KAAK,CAAC,CAAC;YACpE,CAAC;YAED,OAAO,IAAI,CAAC;QACd,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { operations } from "../client/schema.js";
|
|
2
|
+
export type Market = operations['getApiMarkets']['responses'][200]['content']['application/json'][number];
|
|
3
|
+
export type MarketRequiredResources = operations['getApiMarketsByIdRequired-resources']['responses'][200]['content']['application/json'];
|
|
4
|
+
export interface NosanaMarketsApi {
|
|
5
|
+
list: () => Promise<Market[]>;
|
|
6
|
+
get: (market: string) => Promise<Market>;
|
|
7
|
+
getRequiredResources: (market: string) => Promise<MarketRequiredResources>;
|
|
8
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/markets/types.ts"],"names":[],"mappings":""}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const NosanaNetwork: {
|
|
2
|
+
readonly DEVNET: "devnet";
|
|
3
|
+
readonly MAINNET: "mainnet";
|
|
4
|
+
readonly LOCAL: "local";
|
|
5
|
+
};
|
|
6
|
+
export type NosanaNetwork = (typeof NosanaNetwork)[keyof typeof NosanaNetwork];
|
|
7
|
+
export type GenerateAuthHeaderFn = (message: string) => Promise<string>;
|
|
8
|
+
export type SignerAuth = {
|
|
9
|
+
identifier: string;
|
|
10
|
+
generateAuthHeader: GenerateAuthHeaderFn;
|
|
11
|
+
};
|
|
12
|
+
export type ApiKeyAuth = string;
|
|
13
|
+
export type CreateNosanaApiOptions = Partial<{
|
|
14
|
+
backend_url: string;
|
|
15
|
+
}>;
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,MAAM,EAAE,QAAQ;IAChB,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,OAAO;CACN,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface ApiError extends Error {
|
|
2
|
+
code?: string;
|
|
3
|
+
statusCode?: number;
|
|
4
|
+
details?: unknown;
|
|
5
|
+
}
|
|
6
|
+
interface ErrorResponse {
|
|
7
|
+
error?: string;
|
|
8
|
+
message?: string;
|
|
9
|
+
code?: string;
|
|
10
|
+
statusCode?: number;
|
|
11
|
+
}
|
|
12
|
+
export declare function errorFormatter(customMessage: string, errorObject?: ErrorResponse | unknown): ApiError;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export function errorFormatter(customMessage, errorObject) {
|
|
2
|
+
const err = new Error();
|
|
3
|
+
if (!errorObject) {
|
|
4
|
+
err.message = customMessage;
|
|
5
|
+
return err;
|
|
6
|
+
}
|
|
7
|
+
if (typeof errorObject === 'object' && errorObject !== null) {
|
|
8
|
+
const { error, message, code, statusCode } = errorObject;
|
|
9
|
+
err.message = `${customMessage}: ${error || message || 'Unknown error'}`;
|
|
10
|
+
err.code = code;
|
|
11
|
+
err.statusCode = statusCode;
|
|
12
|
+
err.details = errorObject;
|
|
13
|
+
return err;
|
|
14
|
+
}
|
|
15
|
+
if (typeof errorObject === 'string') {
|
|
16
|
+
err.message = `${customMessage}: ${errorObject}`;
|
|
17
|
+
return err;
|
|
18
|
+
}
|
|
19
|
+
err.message = customMessage;
|
|
20
|
+
err.details = errorObject;
|
|
21
|
+
return err;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=errorFormatter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errorFormatter.js","sourceRoot":"","sources":["../../src/utils/errorFormatter.ts"],"names":[],"mappings":"AAaA,MAAM,UAAU,cAAc,CAC5B,aAAqB,EACrB,WAAqC;IAErC,MAAM,GAAG,GAAG,IAAI,KAAK,EAAc,CAAC;IAEpC,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,GAAG,CAAC,OAAO,GAAG,aAAa,CAAC;QAC5B,OAAO,GAAG,CAAC;IACb,CAAC;IAED,IAAI,OAAO,WAAW,KAAK,QAAQ,IAAI,WAAW,KAAK,IAAI,EAAE,CAAC;QAC5D,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,WAA4B,CAAC;QAE1E,GAAG,CAAC,OAAO,GAAG,GAAG,aAAa,KAAK,KAAK,IAAI,OAAO,IAAI,eAAe,EAAE,CAAC;QACzE,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC;QAChB,GAAG,CAAC,UAAU,GAAG,UAAU,CAAC;QAC5B,GAAG,CAAC,OAAO,GAAG,WAAW,CAAC;QAE1B,OAAO,GAAG,CAAC;IACb,CAAC;IAED,IAAI,OAAO,WAAW,KAAK,QAAQ,EAAE,CAAC;QACpC,GAAG,CAAC,OAAO,GAAG,GAAG,aAAa,KAAK,WAAW,EAAE,CAAC;QACjD,OAAO,GAAG,CAAC;IACb,CAAC;IAED,GAAG,CAAC,OAAO,GAAG,aAAa,CAAC;IAC5B,GAAG,CAAC,OAAO,GAAG,WAAW,CAAC;IAC1B,OAAO,GAAG,CAAC;AACb,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nosana/api",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Nosana API module",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"author": "Nosana",
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist"
|
|
11
|
+
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "tsc",
|
|
14
|
+
"build:watch": "tsc --watch",
|
|
15
|
+
"clean": "rm -rf dist",
|
|
16
|
+
"generate:types:dev": "openapi-typescript https://dashboard.k8s.dev.nos.ci/api/swagger/json -o src/client/schema.ts",
|
|
17
|
+
"generate:types:prd": "openapi-typescript https://dashboard.k8s.prd.nos.ci/api/swagger/json -o src/client/schema.ts",
|
|
18
|
+
"generate:types:local": "openapi-typescript http://localhost:3000/api/swagger/json -o src/client/schema.ts",
|
|
19
|
+
"test": "vitest run",
|
|
20
|
+
"test:watch": "vitest",
|
|
21
|
+
"test:coverage": "vitest run --coverage",
|
|
22
|
+
"eslint": "eslint ./src",
|
|
23
|
+
"eslint:fix": "eslint --fix ./src",
|
|
24
|
+
"format": "npm run eslint",
|
|
25
|
+
"format:fix": "npm run eslint:fix",
|
|
26
|
+
"publish:public": "npm run build && npm publish --access public"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@types/node": "^24.0.14",
|
|
30
|
+
"@typescript-eslint/eslint-plugin": "^8.38.0",
|
|
31
|
+
"@typescript-eslint/parser": "^8.38.0",
|
|
32
|
+
"@vitest/coverage-v8": "^4.0.3",
|
|
33
|
+
"eslint": "^9.31.0",
|
|
34
|
+
"eslint-plugin-import": "^2.32.0",
|
|
35
|
+
"husky": "^9.1.7",
|
|
36
|
+
"openapi-typescript": "^7.8.0",
|
|
37
|
+
"typescript": "^5.8.3",
|
|
38
|
+
"vitest": "^4.0.3"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@nosana/authorization": "^0.0.4",
|
|
42
|
+
"openapi-fetch": "^0.14.0"
|
|
43
|
+
}
|
|
44
|
+
}
|