@bizjaya/finclient 0.2.0 → 0.2.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  # @bizjaya/finclient
2
2
 
3
- The official TypeScript SDK for FinCopy's public API, `https://api.fincopy.pro`. Version 0.2.0 uses numeric ACNO account
4
- paths under `/v1/fxs` and changes the 0.1 API; see the changelog before upgrading.
3
+ The official TypeScript SDK for FinCopy's public API, `https://api.fincopy.io`. Since version 0.2.0 it uses numeric ACNO
4
+ account paths under `/v1/fxs`, which changed the 0.1 API; see the changelog before upgrading.
5
5
 
6
6
  ```sh
7
7
  npm install @bizjaya/finclient
@@ -18,7 +18,7 @@ for (const account of accounts.items) console.log(account.Fleet?.Account?.ACNO,
18
18
  // await fin.copy.orders.make(52014125, { SYM: "EURUSD", ACT: "NEW", OTY: "OP_BUY", LOT: 0.01 });
19
19
  ```
20
20
 
21
- The client defaults to `https://api.fincopy.pro`. Account-scoped methods take the numeric ACNO, and paged list methods
21
+ The client defaults to `https://api.fincopy.io`. Account-scoped methods take the numeric ACNO, and paged list methods
22
22
  return `{ items, paging, ... }`. DTO fields keep the API's PascalCase names.
23
23
 
24
24
  - `copy.accounts`: settings and lifecycle, pairs, symbols, quotes, orders, history, DCA, performance, activity, strategy
@@ -43,7 +43,13 @@ const account = await fin.copy.accounts.get(52014125);
43
43
  ```
44
44
 
45
45
  The API accepts browser requests only from FinCopy's own sites. Session trade writes pass the member's trade-PIN gate on
46
- the server. The main entry uses no Node.js built-ins, so it runs in browsers, Node.js 18+, Deno and Bun.
46
+ the server. The main entry uses no Node.js built-ins, so it runs in browsers, Node.js 20+, Deno and Bun.
47
+
48
+ `copy.accounts.remove(acno, { TrPin }, options)` disconnects the hosted terminal, forgets its broker password and frees its seat.
49
+ Customer account settings and trade history remain so the login can be restored later; a free demo's account and terminal records
50
+ are deleted. Open orders stay at the broker, and virtual TP, SL and TS stop working while no terminal runs. Include the member's
51
+ trading PIN for a session account when its PIN is enabled; API-key requests do not use a session PIN. Pass an `idempotencyKey`
52
+ in `options` so retries receive the same operation.
47
53
 
48
54
  ## Results, errors and the stream
49
55
 
package/dist/index.cjs CHANGED
@@ -120,7 +120,7 @@ var FinHttpTransport = class {
120
120
  constructor(options) {
121
121
  this.apiKey = options.apiKey?.trim() ?? "";
122
122
  if (!this.apiKey && !options.fetch) throw new TypeError("apiKey is required unless a custom fetch authenticates the member session.");
123
- this.baseUrl = (options.baseUrl ?? "https://api.fincopy.pro").replace(/\/+$/, "");
123
+ this.baseUrl = (options.baseUrl ?? "https://api.fincopy.io").replace(/\/+$/, "");
124
124
  const base = new URL(this.baseUrl);
125
125
  if (!/^https?:$/.test(base.protocol) || base.search || base.hash) {
126
126
  throw new TypeError("baseUrl must be an absolute HTTP or HTTPS URL without a query or fragment.");
@@ -527,9 +527,11 @@ var AccountsResource = class {
527
527
  restart(acno, options = {}) {
528
528
  return this.operation(acno, "restart", options);
529
529
  }
530
- /** Queues account removal. */
531
- remove(acno, options = {}) {
532
- return this.http.request("DELETE", accountPath(acno), void 0, options);
530
+ remove(acno, commandOrOptions = {}, options = {}) {
531
+ const hasCommand = Object.prototype.hasOwnProperty.call(commandOrOptions, "TrPin");
532
+ const command = hasCommand ? commandOrOptions : { TrPin: null };
533
+ const requestOptions = hasCommand ? options : commandOrOptions;
534
+ return this.http.request("DELETE", accountPath(acno), command, requestOptions);
533
535
  }
534
536
  operation(acno, action, options) {
535
537
  return this.http.request("POST", `${accountPath(acno)}/${action}`, void 0, options);