-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: rework functions implementation (#3)
- Loading branch information
1 parent
ffe8e28
commit 541ad2e
Showing
14 changed files
with
1,632 additions
and
205 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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"builder": { | ||
"esbuildControllerOptions": { | ||
"includeInBundle": ["webdav"] | ||
"includeInBundle": ["webdav", "radash"] | ||
} | ||
} | ||
} |
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
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
Large diffs are not rendered by default.
Oops, something went wrong.
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,84 @@ | ||
import { title } from 'radash'; | ||
|
||
export const NODES_CATEGORY = 'webdav'; | ||
export const NODES_COLOR = '#00A6FB'; | ||
export const NODES_ICONS = 'font-awesome/fa-folder-open'; | ||
|
||
type WebdavMethods = { | ||
methodName: string; | ||
label?: string; | ||
enabled?: boolean; | ||
}; | ||
|
||
export const webdavMethods: WebdavMethods[] = [ | ||
{ | ||
methodName: 'copyFile', | ||
}, | ||
{ | ||
methodName: 'createDirectory', | ||
}, | ||
{ | ||
methodName: 'createReadStream', | ||
}, | ||
{ | ||
methodName: 'createWriteStream', | ||
}, | ||
{ | ||
methodName: 'customRequest', | ||
}, | ||
{ | ||
methodName: 'deleteFile', | ||
label: 'Delete (Folder/File)', | ||
enabled: true, | ||
}, | ||
{ | ||
methodName: 'exists', | ||
}, | ||
{ | ||
methodName: 'getDirectoryContents', | ||
enabled: true, | ||
}, | ||
{ | ||
methodName: 'getFileContents', | ||
}, | ||
{ | ||
methodName: 'getFileDownloadLink', | ||
}, | ||
{ | ||
methodName: 'getFileUploadLink', | ||
}, | ||
{ | ||
methodName: 'getQuota', | ||
}, | ||
{ | ||
methodName: 'getStat', | ||
}, | ||
{ | ||
methodName: 'lock', | ||
}, | ||
{ | ||
methodName: 'moveFile', | ||
}, | ||
{ | ||
methodName: 'putFileContents', | ||
}, | ||
{ | ||
methodName: 'unlock', | ||
}, | ||
] as const; | ||
|
||
export const cleanWebdavMethods = webdavMethods | ||
.map((method) => { | ||
return { | ||
...method, | ||
label: method?.label || title(method.methodName), | ||
}; | ||
}) | ||
.filter((method) => method?.enabled); | ||
|
||
export const cleanWebdavMethodsForSelect = cleanWebdavMethods.map((method) => ({ | ||
value: method.methodName, | ||
text: method.label, | ||
})); | ||
|
||
export const methodsEnum = webdavMethods.filter((s) => s?.enabled).map((method) => method.methodName); |
This file was deleted.
Oops, something went wrong.
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,33 @@ | ||
import * as sstruct from 'superstruct'; | ||
import type { Infer } from 'superstruct'; | ||
import { methodsEnum } from './constants-client-side'; | ||
|
||
export const methodsSchema = sstruct.enums(methodsEnum); | ||
|
||
export const actionValidators = { | ||
getDirectoryContents: { | ||
schema: sstruct.object({ | ||
details: sstruct.optional(sstruct.boolean()), | ||
deep: sstruct.optional(sstruct.boolean()), | ||
directory: sstruct.string(), | ||
}), | ||
}, | ||
deleteFile: { | ||
schema: sstruct.object({ | ||
directory: sstruct.string(), | ||
}), | ||
}, | ||
}; | ||
|
||
export function validateAction(actionName: string, toValidate: Record<string, any>) { | ||
const [errValidate] = sstruct | ||
.assign( | ||
sstruct.object({ | ||
action: methodsSchema, | ||
}), | ||
actionValidators?.[actionName]?.schema || {}, | ||
) | ||
.validate({ action: actionName, ...toValidate }); | ||
|
||
return errValidate; | ||
} |
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
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
File renamed without changes.
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 |
---|---|---|
@@ -1,28 +1,81 @@ | ||
<div class="form-row"> | ||
<label for="node-input-webdavServer"><i class="fa fa-tv"></i> Server</label> | ||
<input type="text" id="node-input-webdavServer"/> | ||
<div class="dxp-form-row"> | ||
<div class="main"> | ||
<div> | ||
<i class="fa fa-tv"></i> | ||
<label for="node-input-webdavServer">Server</label> | ||
</div> | ||
<input type="text" id="node-input-webdavServer"/> | ||
</div> | ||
</div> | ||
<div class="form-row"> | ||
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label> | ||
<input type="text" id="node-input-name" placeholder="custom name"/> | ||
<div class="dxp-form-row"> | ||
<div class="main"> | ||
<div> | ||
<i class="fa fa-tag"></i> | ||
<label for="node-input-name">Name</label> | ||
</div> | ||
<input type="text" id="node-input-name"/> | ||
</div> | ||
</div> | ||
<div class="form-row"> | ||
<label for="node-input-action" ><i class="fa fa-target"></i> Action</label> | ||
<select id="node-input-action"> | ||
<option value=""></option> | ||
<option value="list">List</option> | ||
<option value="delete">Delete</option> | ||
</select> | ||
<div class="dxp-form-row"> | ||
<div class="main"> | ||
<div> | ||
<i class="fa fa-ellipsis-h"></i> | ||
<label for="node-input-entry">Property</label> | ||
</div> | ||
<input type="text" id="node-input-entry"> | ||
<input type="hidden" id="node-input-entryType"> | ||
</div> | ||
<div class="hint"> | ||
If empty, configuration below will be used. | ||
</div> | ||
</div> | ||
<div class="action-list hidden"> | ||
<div class="form-row"> | ||
<label for="node-input-listDirectory"><i class="fa fa-sitemap"></i> Directory</label> | ||
<input type="text" id="node-input-listDirectory" /> | ||
<div class="dxp-form-row"> | ||
<div class="main"> | ||
<div> | ||
<i class="fa fa-bolt"></i> | ||
<label for="node-input-action">Action</label> | ||
</div> | ||
<select id="node-input-action"></select> | ||
</div> | ||
</div> | ||
<div class="extra-params getDirectoryContents"> | ||
<div class="dxp-form-row"> | ||
<div class="main"> | ||
<div> | ||
<i class="fa fa-folder"></i> | ||
<label for="node-input-getDirectoryContents-directory">Directory</label> | ||
</div> | ||
<input type="text" id="node-input-getDirectoryContents-directory"/> | ||
</div> | ||
</div> | ||
<!-- <div class="dxp-form-row">--> | ||
<!-- <div class="main">--> | ||
<!-- <div>--> | ||
<!-- <label for="node-input-getDirectoryContents-deep">Deep</label>--> | ||
<!-- </div>--> | ||
<!-- <input type="checkbox" id="node-input-getDirectoryContents-deep"/>--> | ||
<!-- </div>--> | ||
<!-- </div>--> | ||
<div class="dxp-form-row"> | ||
<div class="main"> | ||
<div> | ||
<label for="node-input-getDirectoryContents-details">Details</label> | ||
</div> | ||
<input type="checkbox" id="node-input-getDirectoryContents-details"/> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="action-delete hidden"> | ||
<div class="form-row"> | ||
<label for="node-input-deleteDirectory"><i class="fa fa-sitemap"></i> Directory</label> | ||
<input type="text" id="node-input-deleteDirectory" /> | ||
<div class="extra-params deleteFile"> | ||
<div class="dxp-form-row"> | ||
<div class="main"> | ||
<div> | ||
<i class="fa fa-folder"></i> | ||
<label for="node-input-deleteFile-directory">Directory</label> | ||
</div> | ||
<input type="text" id="node-input-deleteFile-directory"/> | ||
</div> | ||
<div class="hint"> | ||
Folder/File. If folder, it must end with a slash. | ||
</div> | ||
</div> | ||
</div> |
Oops, something went wrong.