-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f932321
commit 8912aa8
Showing
15 changed files
with
917 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"presets": [ | ||
[ | ||
"@nx/react/babel", | ||
{ | ||
"runtime": "automatic", | ||
"useBuiltIns": "usage" | ||
} | ||
] | ||
], | ||
"plugins": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"extends": ["plugin:@nx/react", "../../.eslintrc.json"], | ||
"ignorePatterns": ["!**/*"], | ||
"rules": { | ||
"@nx/dependency-checks": [ | ||
"error", | ||
{ | ||
"ignoredFiles": ["libs/renterd-js/rollup.config.js"] | ||
} | ||
] | ||
}, | ||
"overrides": [ | ||
{ | ||
"files": ["*.json"], | ||
"parser": "jsonc-eslint-parser", | ||
"rules": { | ||
"@nx/dependency-checks": "error" | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# renterd-js | ||
|
||
SDK for interacting with `renterd`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* eslint-disable */ | ||
export default { | ||
displayName: 'renterd-js', | ||
preset: '../../jest.preset.js', | ||
transform: { | ||
'^(?!.*\\.(js|jsx|ts|tsx|css|json)$)': '@nx/react/plugins/jest', | ||
'^.+\\.[tj]sx?$': [ | ||
'babel-jest', | ||
{ | ||
presets: ['@nx/next/babel'], | ||
plugins: ['@babel/plugin-transform-private-methods'], | ||
}, | ||
], | ||
}, | ||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'], | ||
coverageDirectory: '../../coverage/libs/renterd-js', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"name": "@siafoundation/renterd-js", | ||
"description": "SDK for interacting with `renterd`.", | ||
"version": "0.0.0", | ||
"license": "MIT", | ||
"dependencies": { | ||
"@siafoundation/renterd-types": "0.0.0", | ||
"@siafoundation/request": "0.0.0", | ||
"axios": "^0.27.2" | ||
}, | ||
"types": "./src/index.d.ts" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{ | ||
"name": "renterd-js", | ||
"$schema": "../../node_modules/nx/schemas/project-schema.json", | ||
"sourceRoot": "libs/renterd-js/src", | ||
"projectType": "library", | ||
"tags": [], | ||
"targets": { | ||
"build": { | ||
"executor": "@nx/rollup:rollup", | ||
"outputs": ["{options.outputPath}"], | ||
"options": { | ||
"outputPath": "dist/libs/renterd-js", | ||
"tsConfig": "libs/renterd-js/tsconfig.lib.json", | ||
"project": "libs/renterd-js/package.json", | ||
"entryFile": "libs/renterd-js/src/index.ts", | ||
"external": ["react/jsx-runtime"], | ||
"compiler": "tsc", | ||
"outputFileName": "index.js", | ||
"rollupConfig": "libs/renterd-js/rollup.config.js", | ||
"assets": [ | ||
{ | ||
"glob": "libs/renterd-js/*.md", | ||
"input": ".", | ||
"output": "." | ||
} | ||
] | ||
}, | ||
"configurations": {} | ||
}, | ||
"lint": { | ||
"executor": "@nx/eslint:lint", | ||
"outputs": ["{options.outputFile}"] | ||
}, | ||
"test": { | ||
"executor": "@nx/jest:jest", | ||
"outputs": ["{workspaceRoot}/coverage/libs/renterd-js"], | ||
"options": { | ||
"jestConfig": "libs/renterd-js/jest.config.ts" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
const preserveDirectives = require('rollup-plugin-preserve-directives') | ||
|
||
// https://github.com/rollup/rollup/issues/4699#issuecomment-1465302665 | ||
function getRollupOptions(options) { | ||
return { | ||
...options, | ||
output: { | ||
...options.output, | ||
preserveModules: true, | ||
format: 'esm', | ||
sourcemap: true, | ||
}, | ||
plugins: options.plugins.concat(preserveDirectives.default()), | ||
} | ||
} | ||
|
||
module.exports = getRollupOptions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { | ||
AutopilotConfigParams, | ||
AutopilotConfigPayload, | ||
AutopilotConfigResponse, | ||
AutopilotConfigUpdateParams, | ||
AutopilotConfigUpdatePayload, | ||
AutopilotConfigUpdateResponse, | ||
AutopilotHostsSearchParams, | ||
AutopilotHostsSearchPayload, | ||
AutopilotHostsSearchResponse, | ||
AutopilotStateParams, | ||
AutopilotStatePayload, | ||
AutopilotStateResponse, | ||
AutopilotTriggerParams, | ||
AutopilotTriggerPayload, | ||
AutopilotTriggerResponse, | ||
autopilotConfigKey, | ||
autopilotHostsKey, | ||
autopilotStateKey, | ||
autopilotTriggerKey, | ||
} from '@siafoundation/renterd-types' | ||
import { buildRequestHandler } from '@siafoundation/request' | ||
import { Axios } from 'axios' | ||
|
||
export function Autopilot(api?: string) { | ||
const axios = new Axios({ baseURL: api }) | ||
return { | ||
state: buildRequestHandler< | ||
AutopilotStateParams, | ||
AutopilotStatePayload, | ||
AutopilotStateResponse | ||
>(axios, 'get', autopilotStateKey), | ||
confg: buildRequestHandler< | ||
AutopilotConfigParams, | ||
AutopilotConfigPayload, | ||
AutopilotConfigResponse | ||
>(axios, 'get', autopilotConfigKey), | ||
configUpdate: buildRequestHandler< | ||
AutopilotConfigUpdateParams, | ||
AutopilotConfigUpdatePayload, | ||
AutopilotConfigUpdateResponse | ||
>(axios, 'put', autopilotConfigKey), | ||
hostsSearch: buildRequestHandler< | ||
AutopilotHostsSearchParams, | ||
AutopilotHostsSearchPayload, | ||
AutopilotHostsSearchResponse | ||
>(axios, 'post', autopilotHostsKey), | ||
trigger: buildRequestHandler< | ||
AutopilotTriggerParams, | ||
AutopilotTriggerPayload, | ||
AutopilotTriggerResponse | ||
>(axios, 'post', autopilotTriggerKey), | ||
} | ||
} |
Oops, something went wrong.