buckyos / cyfs-ts-sdk Goto Github PK
View Code? Open in Web Editor NEWLicense: BSD 2-Clause "Simplified" License
License: BSD 2-Clause "Simplified" License
This code is error。if pid === undefined should process.exit(1); Because dec app is not running
Add list method to path-op-env & single-op-env
Integrate CYFS Stack task context and group
The purpose of the task
Implement new Perf module, as it is in CYFS
Implement cyfs-cip as it is in CYFS rust code
Describe the bug
If I use cyfs-ts-sdk,There are some compile error
cyfs-ts-sdk/src/sdk/cyfs-base-meta/tx/nft_desc.ts:118:93 - error TS2347: Untyped function calls may not accept type arguments.
118 const ret: [NFTDesc, Uint8Array] = [NFTDesc.FileDesc2([filedesc2.index(0), filedesc2.index<ObjectId>(1)]), buf];
When running cyfs deploy, if an http request timeout occurs with the meta chain, the code will directly throw an exception. It is recommended to add a retry mechanism, as http request timeouts may be very common.
I re-execute cyfs deploy and it can be released successfully.
[2023-04-14 15:17:38.804344] ERROR [ThreadId(11)] [cyfs_meta_lib::client] http connect error! host=http://nightly.meta.cyfs.com:1423/, err=future has timed out
[2023-04-14 15:17:38.804755] WARN [ThreadId(11)] [cyfs_client::named_data_client] cannot get file desc 5aSixgM3hFBdnefL7W67Gemq8XJzwxJscpTLF17JpdP7
[2023-04-14 15:17:38.805017] ERROR [ThreadId(11)] [cyfs_client::actions] put err: err: (NotFound, , None)
node:internal/errors:857
const err = new Error(message);
^
Error: Command failed: "C:\Users\bucky\AppData\Roaming\cyfs\services\runtime\tools\cyfs-client" put "dist" -f "fid" -o "E:\githubSpace\cyfs-dec-app-test\owner\nightly\people" --use-stack-sn --tcp
at checkExecSyncError (node:child_process:861:11)
at Object.execSync (node:child_process:932:15)
at Object.exec (C:\Users\bucky\AppData\Roaming\npm\node_modules\cyfs-tool-nightly\cyfs.js:3527:29)
at upload_dec_app (C:\Users\bucky\AppData\Roaming\npm\node_modules\cyfs-tool-nightly\cyfs.js:262:12)
at deploy_dec_app (C:\Users\bucky\AppData\Roaming\npm\node_modules\cyfs-tool-nightly\cyfs.js:441:5)
at run (C:\Users\bucky\AppData\Roaming\npm\node_modules\cyfs-tool-nightly\cyfs.js:475:11)
at Command.<anonymous> (C:\Users\bucky\AppData\Roaming\npm\node_modules\cyfs-tool-nightly\cyfs.js:467:15)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Command.parseAsync (C:\Users\bucky\AppData\Roaming\npm\node_modules\cyfs-tool-nightly\node_modules\commander\lib\command.js:923:5) {
status: 1,
signal: null,
output: [ null, null, null ],
pid: 2356,
stdout: null,
stderr: null
}
Describe the bug
IsolatePath/OpEnvStubSingleOpEnvStub/PathOpEnvStub all use GlobalStateRequestor to send requests, and the logs printed by GlobalStateRequestor should be controlled by parameters instead of randomly printing OpEnv types
[[cyfs-ts-sdk] https://github.com/buckyos/cyfs-ts-sdk/src/sdk/cyfs-lib/root_state/requestor.ts](https://github.com/buckyos/cyfs-ts-sdk/blob/beta/src/sdk/cyfs-lib/root_state/requestor.ts)
To Reproduce
For example : IsolatePath/PathOpEnvStub can call this function,why the log just print path_op_env ,This is a bad log, which will cause the user to view the log and cannot distinguish the OpEnv type
public async load(req: OpEnvLoadOutputRequest): Promise<BuckyResult<void>> {
if (this.op_env_type_ !== ObjectMapOpEnvType.Single && this.op_env_type_ !== ObjectMapOpEnvType.IsolatePath) {
const err_msg = `load method only valid for single_op_env and isolate_path_op_env! sid = ${this.sid_}`;
console.log(err_msg);
return Ok(undefined);
}
console.info(
`will load for path_op_env: sid=${this.sid_}, target=${req.target}`
);
const http_req = this.encode_load_request(req);
const r = await this.requestor_.request(http_req);
if (r.err) {
console.error(
`load for path_op_env request failed: sid=${this.sid_}, target=${req.target}, ret=${r}`
);
return r;
}
const resp = r.unwrap();
if (http_status_code_ok(resp.status)) {
console.info(
`load for path_op_env success: sid=${this.sid_}, target=${req.target}`
);
return Ok(undefined);
} else {
const e = await RequestorHelper.error_from_resp(resp);
console.error(
`load for path_op_env failed: sid=${this.sid_}, target=${req.target}, err=${e}`
);
return Err(e);
}
}
Expected behavior
OpEnvRequestor can identify the specific OpEnv type through op_env_type_, it is recommended to optimize the log
System information
[[cyfs-ts-sdk] https://github.com/buckyos/cyfs-ts-sdk/src/sdk/cyfs-lib/root_state/requestor.ts](https://github.com/buckyos/cyfs-ts-sdk/blob/beta/src/sdk/cyfs-lib/root_state/requestor.ts)
StateStorage already has an implementation of the rust version in cyfs-lib, and needs to have an equivalent implementation in ts
** General Question**
CYFS SDK cyfs-lib supports two programming languages, Rust and TypeScript. I want to develop a Dec app using Rust, how can I integrate it with app-manager? Is there any documentation for this?
Refactoring Private Key with node-forge, as node-rsa not support create rsa key with custom rngs
This part of the code may cause compilation errors
cyfs-ts-sdk/src/sdk/cyfs-base/base/buffer.ts
Lines 30 to 33 in 057244a
Describe the bug
../../cyfs-ts-sdk/src/sdk/cyfs-base/base/buffer.ts:32:66 - error TS7006: Parameter 'x' implicitly has an 'any' type.
32 return Array.prototype.map.call(new Uint8Array(this.buffer), x => ('00' + x.toString(16)).slice(-2)).join('');
There are two ways to solve this problem:
+Set the x parameter type to number
return Array.prototype.map.call(new Uint8Array(this.buffer), (x: number) => ('00' + x.toString(16)).slice(-2)).join('');
{
"compilerOptions": {
"noImplicitAny": false
}
}
We need to add support for the ts-sdk side of this feature buckyos/CYFS#175, mainly including changes related to the cyfs-lib side, involving the following.
protoc.exe --proto_path=./common_base/codec/protos --js_out=import_style=commonjs,binary:./common_base/codec/protos --ts_out=./common_base/codec/protos ./common_base/codec/protos/dec_objects.proto
'protoc-gen-js' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
--js_out: protoc-gen-js: Plugin failed with status code 1.
Suggest cyfs-ts-sdk Description Compatible protoc version range
protoc-3.20.1 can be used normally
Describe the bug
upload directory specified -e ood
args, then use get download dir failed
To Reproduce
1、cyfs upload "[path]" -e ood -t ood
output: cyfs://o/5r4MYfFJGt5gQsdGz3NRL3YrKbgZET2Lv1ru2xfhCuM1/95RvaS5a85pUzbvWXZ39qTBHf44SXud2cGKfgv5iuGQn
2、cyfs get cyfs://o/5r4MYfFJGt5gQsdGz3NRL3YrKbgZET2Lv1ru2xfhCuM1/95RvaS5a85pUzbvWXZ39qTBHf44SXud2cGKfgv5iuGQn -s "[save path]"
Expected behavior
cyfs get cyfs://o/5r4MYfFJGt5gQsdGz3NRL3YrKbgZET2Lv1ru2xfhCuM1/95RvaS5a85pUzbvWXZ39qTBHf44SXud2cGKfgv5iuGQn -s "[save path]" execute success, output data to save path
System information
v0.5.6
Additional context
[error],[2022-06-07 16:55:56.694],<>,get_object_by_path error err: (4, get_by_path but not found! dec=9tGpLNnDpa8deXEk2NaWGccEu4yFQ2DrTZJPLYLT7gj4, path=/upload_map/95RvaS5a85pUzbvWXZ39qTBHf44SXud2cGKfgv5iuGQn, undefined), index.js:72543
[info],[2022-06-07 16:55:56.694],<>,get root state path /upload_map/95RvaS5a85pUzbvWXZ39qTBHf44SXud2cGKfgv5iuGQn err err: (4, get_by_path but not found! dec=9tGpLNnDpa8deXEk2NaWGccEu4yFQ2DrTZJPLYLT7gj4, path=/upload_map/95RvaS5a85pUzbvWXZ39qTBHf44SXud2cGKfgv5iuGQn, undefined), cyfs.js:690
[info],[2022-06-07 16:55:56.695],<>,search not found files, cyfs.js:870
CYFS Stack make a new event handler, Implement it in ts sdk
Unusable in most cases
[info],[2022-06-20 18:36:16.361],<>,get object from non service success: 5r4MYfFb42i8TFKUiCj9BzuBfbqWXyM86ptCmrQdV2md, index.js:68139
[info],[2022-06-20 18:36:16.365],<>,upload use owner 5r4MYfFb42i8TFKUiCj9BzuBfbqWXyM86ptCmrQdV2md, cyfs.js:758
[info],[2022-06-20 18:36:16.370],<>,download file C:\Temp\index.html.file object: 7Tk94YfJYEgLdTheh5h1CRXTXfSfwovq7fvfmuQqSA37, on (ObjectId: 5aSixgLjnoGY4ESRXZ7anBjUgrPiB5tF14EJmUoenQzd, obj_type:1), cyfs.js:822
[info],[2022-06-20 18:36:16.371],<>,will start trans task http://127.0.0.1:1322/trans/task [object Object], index.js:71754
[error],[2022-06-20 18:36:16.373],<>,start_task to non stack failed, status=404, err={"code":"4","msg":"noc get object but not found: 7Tk94YfJYEgLdTheh5h1CRXTXfSfwovq7fvfmuQqSA37"}, index.js:71768
[error],[2022-06-20 18:36:16.374],<>,start task on target: (ObjectId: 5aSixgLjnoGY4ESRXZ7anBjUgrPiB5tF14EJmUoenQzd, obj_type:1) err err: (4, noc get object but not found: 7Tk94YfJYEgLdTheh5h1CRXTXfSfwovq7fvfmuQqSA37, undefined), cyfs.js:839
And I can open cyfs://eips/index.html in CYFS Browser~
Adapt the same optimization in the CYFS repository, see buckyos/CYFS#154
For some historical reasons, many interfaces in the TS SDK still retain the Option signature and return value. Is it possible to change these signatures to the more familiar T|undefined for TypeScript?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.