wapi-client 0.10.2 → 0.10.6

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.
Files changed (61) hide show
  1. package/dist/api/base-client.browser.cjs +27 -8
  2. package/dist/api/base-client.browser.js +28 -9
  3. package/dist/api/base-client.cjs +27 -8
  4. package/dist/api/base-client.d.ts +6 -2
  5. package/dist/api/base-client.js +28 -9
  6. package/dist/api/http-client.browser.cjs +47 -21
  7. package/dist/api/http-client.browser.js +47 -21
  8. package/dist/api/http-client.cjs +47 -21
  9. package/dist/api/http-client.d.ts +2 -2
  10. package/dist/api/http-client.js +47 -21
  11. package/dist/api/index.d.ts +4 -0
  12. package/dist/api/ws-client.browser.cjs +26 -10
  13. package/dist/api/ws-client.browser.js +27 -11
  14. package/dist/api/ws-client.cjs +27 -11
  15. package/dist/api/ws-client.d.ts +5 -4
  16. package/dist/api/ws-client.js +28 -12
  17. package/dist/client.browser.cjs +90 -17
  18. package/dist/client.browser.js +91 -18
  19. package/dist/client.cjs +91 -18
  20. package/dist/client.d.ts +53 -5
  21. package/dist/client.js +92 -19
  22. package/dist/fns/list-exports/list-exports.browser.cjs +4 -7
  23. package/dist/fns/list-exports/list-exports.browser.js +9 -8
  24. package/dist/fns/list-exports/list-exports.cjs +4 -7
  25. package/dist/fns/list-exports/list-exports.enums.d.ts +9 -4
  26. package/dist/fns/list-exports/list-exports.js +9 -8
  27. package/dist/fns/list-exports/list-exports.schema.input.json +20 -2
  28. package/dist/fns/update-transfer/update-transfer.browser.cjs +2 -1
  29. package/dist/fns/update-transfer/update-transfer.browser.js +2 -1
  30. package/dist/fns/update-transfer/update-transfer.cjs +2 -1
  31. package/dist/fns/update-transfer/update-transfer.enums.d.ts +6 -0
  32. package/dist/fns/update-transfer/update-transfer.js +2 -1
  33. package/dist/fns/update-transfer/update-transfer.schema.input.json +3 -0
  34. package/dist/index.browser.cjs +3 -0
  35. package/dist/index.browser.js +3 -0
  36. package/dist/index.cjs +3 -0
  37. package/dist/index.d.ts +23 -5
  38. package/dist/index.js +3 -0
  39. package/dist/lib/errors.browser.cjs +21 -1
  40. package/dist/lib/errors.browser.js +21 -1
  41. package/dist/lib/errors.cjs +21 -1
  42. package/dist/lib/errors.d.ts +180 -109
  43. package/dist/lib/errors.js +21 -1
  44. package/dist/lib/utils.browser.cjs +24 -0
  45. package/dist/lib/utils.browser.js +24 -0
  46. package/dist/lib/utils.cjs +27 -0
  47. package/dist/lib/utils.d.ts +6 -0
  48. package/dist/lib/utils.js +24 -0
  49. package/dist/lib/validator.browser.cjs +3 -0
  50. package/dist/lib/validator.browser.js +4 -1
  51. package/dist/lib/validator.cjs +3 -0
  52. package/dist/lib/validator.js +4 -1
  53. package/dist/txs/get-export/get-export.enums.d.ts +2 -1
  54. package/dist/txs/get-export/get-export.schema.output.json +13 -2
  55. package/dist/txs/list-export-many/list-export-many.enums.d.ts +5 -5
  56. package/dist/txs/list-export-many/list-export-many.schema.input.json +5 -4
  57. package/dist/txs/update-transfer/update-transfer.schema.input.json +0 -4
  58. package/dist/types/index.d.ts +301 -137
  59. package/dist/wapi-client-web.iife.js +6 -6
  60. package/dist/wapi-client.iife.js +6 -6
  61. package/package.json +1 -1
package/dist/client.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { WapiConnectionOptions, WapiHttpConnectionOptions, WsClient, HttpClient } from './api';
1
+ import { WapiConnectionOptions, WapiHttpConnectionOptions, WsClient, HttpClient, ConnectionConfig } from './api';
2
2
  import { ClientHooks, ISocketId } from './api/base-client';
3
3
  import { AggregateQueryBuilder, UpdateQueryBuilder, ReverseQueryBuilder, QueryBuilder } from './lib/query-builder';
4
4
  import { StreamPromise } from './lib/stream-promise';
@@ -59,9 +59,10 @@ import { UpdateTransferGroupsFnFields, UpdateTransferGroupsFnMetadataFields, Upd
59
59
  import { UpdateTransfersFnInput, UpdateTransfersFnOutput, UpdateTransfersFnOptions, UpdateTransfersFnUpdateFields } from './fns/update-transfers/update-transfers.enums';
60
60
  import { UpdateTransfersFnFields, UpdateTransfersFnMetadataFields, UpdateTransfersFnStringFields, UpdateTransfersFnResultFields } from './fns/update-transfers/update-transfers';
61
61
  import { UpdateWalletFnInput, UpdateWalletFnOutput, UpdateWalletFnOptions } from './fns/update-wallet/update-wallet.enums';
62
- export interface ClientConfig {
62
+ export interface ClientConfig extends ConnectionConfig {
63
63
  token?: number | string;
64
64
  hooks?: ClientHooks;
65
+ sendingTimeout?: number;
65
66
  }
66
67
  export declare class Client {
67
68
  /**
@@ -112,13 +113,14 @@ export declare class Client {
112
113
  */
113
114
  setHook(hookName: keyof ClientHooks, value: (input?: unknown) => boolean | void): this;
114
115
  /**
115
- * Overwrite client configuration (default token, hooks)
116
+ * Overwrite client configuration (default token, default timeout, hooks)
116
117
  *
117
118
  *
118
119
  * ```javascript
119
120
  *
120
121
  * wapiClient.configure({
121
122
  * token: 'EURO',
123
+ * timeout: 45000,
122
124
  * hooks: {
123
125
  * disconnect: () => {}
124
126
  * },
@@ -136,7 +138,7 @@ export declare class Client {
136
138
  *
137
139
  * ```
138
140
  */
139
- getConfig(key: 'token'): number | string | undefined;
141
+ getConfig(key: keyof Omit<ClientConfig, 'hooks'>): number | string | undefined;
140
142
  /**
141
143
  *
142
144
  * Aggregate Transfers using either a simple filter or queryBuilder
@@ -805,6 +807,49 @@ export declare class Client {
805
807
  /**
806
808
  *
807
809
  *
810
+ * ```javascript
811
+ *
812
+ * // setup
813
+ * await wapiClient.createDeposit(
814
+ * {
815
+ * wallet: 'newWallet',
816
+ * amount: 10,
817
+ * status: 'pending',
818
+ * identifier: 'depositUSD',
819
+ * token: 'USD',
820
+ * },
821
+ * {
822
+ * create_wallet_if_not_exists: true,
823
+ * },
824
+ * );
825
+ * await wapiClient.updateTransfer({
826
+ * transfer: 'depositUSD',
827
+ * status: 'finished',
828
+ * });
829
+ *
830
+ * const result = await wapiClient.exportBalanceHistory(
831
+ * {
832
+ * wallet: 'newWallet',
833
+ * token: 'USD',
834
+ * },
835
+ * {
836
+ * limit: 0,
837
+ * select: [
838
+ * 'transfer_identifier',
839
+ * 'pending_amount',
840
+ * 'finished_amount',
841
+ * 'pending_amount_from',
842
+ * 'pending_amount_to',
843
+ * 'amount',
844
+ * ],
845
+ * offset: 0,
846
+ * order: 'desc',
847
+ * tracking_id: 'mylogId',
848
+ * // transaction_id: Transaction.identifier, // created transaction identifier
849
+ * },
850
+ * );
851
+ *
852
+ * ```
808
853
  *
809
854
  * @param {ExportBalanceHistoryFnInput} input
810
855
  * @param {ExportBalanceHistoryFnOptions} [options]
@@ -1582,8 +1627,11 @@ export declare class Client {
1582
1627
  * ```javascript
1583
1628
  *
1584
1629
  * const result = await wapiClient.listExports(
1585
- * {},
1586
1630
  * {
1631
+ * type: 'transfers',
1632
+ * },
1633
+ * {
1634
+ * order_by: 'created_at desc',
1587
1635
  * tracking_id: 'myLogId',
1588
1636
  * },
1589
1637
  * );
package/dist/client.js CHANGED
@@ -1,6 +1,4 @@
1
1
  var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
2
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
3
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
4
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
@@ -16,7 +14,6 @@ var __spreadValues = (a, b) => {
16
14
  }
17
15
  return a;
18
16
  };
19
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
17
  var __async = (__this, __arguments, generator) => {
21
18
  return new Promise((resolve, reject) => {
22
19
  var fulfilled = (value) => {
@@ -43,14 +40,14 @@ import {
43
40
  createHttpClient,
44
41
  createWsClient
45
42
  } from "./api";
46
- import { ValidationError } from "./lib/errors";
43
+ import { ConfigError, ValidationError } from "./lib/errors";
47
44
  import { ClientFunctions } from "./fns";
48
45
  import {
49
46
  isImportDataFnOptions,
50
47
  isImportDataFnInput
51
48
  } from "./fns/import-data/import-data.guards";
52
49
  var _a;
53
- var CLIENT_VERSION = (_a = '0.10.2') != null ? _a : "";
50
+ var CLIENT_VERSION = (_a = '0.10.6') != null ? _a : "";
54
51
  var Client = class {
55
52
  /**
56
53
  * @internal
@@ -60,16 +57,13 @@ var Client = class {
60
57
  this.api = _apiClient;
61
58
  this.$connect = _apiClient.$connect;
62
59
  if (initialConf) {
63
- if (initialConf.token) {
64
- this.config = __spreadProps(__spreadValues({}, this.config), {
65
- token: initialConf.token
66
- });
67
- }
68
- if (initialConf.hooks) {
69
- for (const [hookName, value] of Object.entries(initialConf.hooks)) {
70
- this.setHook(hookName, value);
71
- }
72
- }
60
+ this.configure(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, initialConf.token && { token: initialConf.token }), initialConf.sendingTimeout && {
61
+ sendingTimeout: initialConf.sendingTimeout
62
+ }), initialConf.connectingTimeout && {
63
+ connectingTimeout: initialConf.connectingTimeout
64
+ }), initialConf.reconnectingTimeout && {
65
+ reconnectingTimeout: initialConf.reconnectingTimeout
66
+ }), initialConf.hooks && { hooks: initialConf.hooks }));
73
67
  }
74
68
  }
75
69
  /**
@@ -119,13 +113,14 @@ var Client = class {
119
113
  return this;
120
114
  }
121
115
  /**
122
- * Overwrite client configuration (default token, hooks)
116
+ * Overwrite client configuration (default token, default timeout, hooks)
123
117
  *
124
118
  *
125
119
  * ```javascript
126
120
  *
127
121
  * wapiClient.configure({
128
122
  * token: 'EURO',
123
+ * timeout: 45000,
129
124
  * hooks: {
130
125
  * disconnect: () => {}
131
126
  * },
@@ -135,7 +130,33 @@ var Client = class {
135
130
  * @param {ClientConfig} newConf
136
131
  */
137
132
  configure(newConf) {
133
+ if (newConf.token && typeof newConf.token !== "string" && typeof newConf.token !== "number") {
134
+ throw new ConfigError("CONFIG_INVALID", {
135
+ field: "token",
136
+ error: `Must be a string|number, '${newConf.token}' provided`
137
+ });
138
+ }
139
+ ["sendingTimeout", "connectingTimeout", "reconnectingTimeout"].forEach(
140
+ (t) => {
141
+ if (newConf[t] && typeof newConf[t] !== "number") {
142
+ throw new ConfigError("CONFIG_INVALID", {
143
+ field: t,
144
+ error: `Must be a number, '${newConf[t]}' provided`
145
+ });
146
+ }
147
+ }
148
+ );
149
+ const hooks = newConf.hooks;
150
+ delete newConf.hooks;
138
151
  this.config = __spreadValues(__spreadValues({}, this.config), newConf);
152
+ if (this.config.sendingTimeout) {
153
+ this.api.sendingTimeout = this.config.sendingTimeout;
154
+ }
155
+ if (hooks) {
156
+ for (const [hookName, value] of Object.entries(hooks)) {
157
+ this.setHook(hookName, value);
158
+ }
159
+ }
139
160
  return this;
140
161
  }
141
162
  /**
@@ -762,6 +783,49 @@ var Client = class {
762
783
  /**
763
784
  *
764
785
  *
786
+ * ```javascript
787
+ *
788
+ * // setup
789
+ * await wapiClient.createDeposit(
790
+ * {
791
+ * wallet: 'newWallet',
792
+ * amount: 10,
793
+ * status: 'pending',
794
+ * identifier: 'depositUSD',
795
+ * token: 'USD',
796
+ * },
797
+ * {
798
+ * create_wallet_if_not_exists: true,
799
+ * },
800
+ * );
801
+ * await wapiClient.updateTransfer({
802
+ * transfer: 'depositUSD',
803
+ * status: 'finished',
804
+ * });
805
+ *
806
+ * const result = await wapiClient.exportBalanceHistory(
807
+ * {
808
+ * wallet: 'newWallet',
809
+ * token: 'USD',
810
+ * },
811
+ * {
812
+ * limit: 0,
813
+ * select: [
814
+ * 'transfer_identifier',
815
+ * 'pending_amount',
816
+ * 'finished_amount',
817
+ * 'pending_amount_from',
818
+ * 'pending_amount_to',
819
+ * 'amount',
820
+ * ],
821
+ * offset: 0,
822
+ * order: 'desc',
823
+ * tracking_id: 'mylogId',
824
+ * // transaction_id: Transaction.identifier, // created transaction identifier
825
+ * },
826
+ * );
827
+ *
828
+ * ```
765
829
  *
766
830
  * @param {ExportBalanceHistoryFnInput} input
767
831
  * @param {ExportBalanceHistoryFnOptions} [options]
@@ -1283,8 +1347,11 @@ var Client = class {
1283
1347
  * ```javascript
1284
1348
  *
1285
1349
  * const result = await wapiClient.listExports(
1286
- * {},
1287
1350
  * {
1351
+ * type: 'transfers',
1352
+ * },
1353
+ * {
1354
+ * order_by: 'created_at desc',
1288
1355
  * tracking_id: 'myLogId',
1289
1356
  * },
1290
1357
  * );
@@ -1725,11 +1792,17 @@ var Client = class {
1725
1792
  // CLIENTFNDEFS
1726
1793
  };
1727
1794
  function createClientWithWS(opts, config) {
1728
- const wsClient = createWsClient(opts);
1795
+ const wsClient = createWsClient(opts, {
1796
+ connectingTimeout: config == null ? void 0 : config.connectingTimeout,
1797
+ reconnectingTimeout: config == null ? void 0 : config.reconnectingTimeout
1798
+ });
1729
1799
  return new Client(wsClient, config);
1730
1800
  }
1731
1801
  function createClientWithHttp(opts, config) {
1732
- const httpClient = createHttpClient(opts);
1802
+ const httpClient = createHttpClient(opts, {
1803
+ connectingTimeout: config == null ? void 0 : config.connectingTimeout,
1804
+ reconnectingTimeout: config == null ? void 0 : config.reconnectingTimeout
1805
+ });
1733
1806
  return new Client(httpClient, config);
1734
1807
  }
1735
1808
  export {
@@ -36,15 +36,12 @@ function listExports(options, input, fnOptions) {
36
36
  if (error) {
37
37
  throw error;
38
38
  }
39
- const date = (() => {
40
- if (typeof inputCopy.date === "string") {
41
- return inputCopy.date;
42
- }
43
- return void 0;
44
- })();
39
+ const date = (0, import_utils.convertToString)(inputCopy == null ? void 0 : inputCopy.date);
40
+ fnOptions = (0, import_utils.checkFnOptionsOrderBy)(fnOptions);
45
41
  return client.api.listExportMany({
46
42
  export: {
47
- date
43
+ date,
44
+ type: inputCopy.type
48
45
  },
49
46
  options: fnOptions
50
47
  });
@@ -1,5 +1,9 @@
1
1
  // src/fns/list-exports/list-exports.ts
2
- import { validateClientFnInput } from "../../lib/utils.browser.js";
2
+ import {
3
+ checkFnOptionsOrderBy,
4
+ convertToString,
5
+ validateClientFnInput
6
+ } from "../../lib/utils.browser.js";
3
7
  import { getValidator, SchemaNames } from "../../lib/validator.browser.js";
4
8
  var validate = getValidator(SchemaNames.ListExportsFnInput);
5
9
  function listExports(options, input, fnOptions) {
@@ -12,15 +16,12 @@ function listExports(options, input, fnOptions) {
12
16
  if (error) {
13
17
  throw error;
14
18
  }
15
- const date = (() => {
16
- if (typeof inputCopy.date === "string") {
17
- return inputCopy.date;
18
- }
19
- return void 0;
20
- })();
19
+ const date = convertToString(inputCopy == null ? void 0 : inputCopy.date);
20
+ fnOptions = checkFnOptionsOrderBy(fnOptions);
21
21
  return client.api.listExportMany({
22
22
  export: {
23
- date
23
+ date,
24
+ type: inputCopy.type
24
25
  },
25
26
  options: fnOptions
26
27
  });
@@ -36,15 +36,12 @@ function listExports(options, input, fnOptions) {
36
36
  if (error) {
37
37
  throw error;
38
38
  }
39
- const date = (() => {
40
- if (typeof inputCopy.date === "string") {
41
- return inputCopy.date;
42
- }
43
- return void 0;
44
- })();
39
+ const date = (0, import_utils.convertToString)(inputCopy == null ? void 0 : inputCopy.date);
40
+ fnOptions = (0, import_utils.checkFnOptionsOrderBy)(fnOptions);
45
41
  return client.api.listExportMany({
46
42
  export: {
47
- date
43
+ date,
44
+ type: inputCopy.type
48
45
  },
49
46
  options: fnOptions
50
47
  });
@@ -1,8 +1,9 @@
1
- import { ListExportManyTxOutput } from '../../txs/list-export-many/list-export-many.enums';
1
+ import { ExportType } from '../../txs/get-export/get-export.enums';
2
+ import { ITxLimitingOptions, ITxGeneralOptions } from '../../txs/tx-consts.enums';
3
+ import { ListExportManyOrderingOptions, ListExportManyTxOutput } from '../../txs/list-export-many/list-export-many.enums';
4
+ import { IFnFindOptionsExtra } from '../fn-consts.enums';
2
5
  export type ListExportsFnInputStringFields = 'date';
3
- export interface ListExportsFnOptions {
4
- [k: string]: unknown;
5
- }
6
+ export type ListExportsFnOptions = ITxLimitingOptions & ITxGeneralOptions & ListExportManyOrderingOptions & IFnFindOptionsExtra;
6
7
  /**
7
8
  * Input for listExports
8
9
  *
@@ -13,6 +14,10 @@ export interface ListExportsFnInput {
13
14
  * Date of the export
14
15
  */
15
16
  date?: string;
17
+ /**
18
+ * Type of the export
19
+ */
20
+ type?: ExportType;
16
21
  options?: ListExportsFnOptions;
17
22
  }
18
23
  /**
@@ -1,5 +1,9 @@
1
1
  // src/fns/list-exports/list-exports.ts
2
- import { validateClientFnInput } from "../../lib/utils";
2
+ import {
3
+ checkFnOptionsOrderBy,
4
+ convertToString,
5
+ validateClientFnInput
6
+ } from "../../lib/utils";
3
7
  import { getValidator, SchemaNames } from "../../lib/validator";
4
8
  var validate = getValidator(SchemaNames.ListExportsFnInput);
5
9
  function listExports(options, input, fnOptions) {
@@ -12,15 +16,12 @@ function listExports(options, input, fnOptions) {
12
16
  if (error) {
13
17
  throw error;
14
18
  }
15
- const date = (() => {
16
- if (typeof inputCopy.date === "string") {
17
- return inputCopy.date;
18
- }
19
- return void 0;
20
- })();
19
+ const date = convertToString(inputCopy == null ? void 0 : inputCopy.date);
20
+ fnOptions = checkFnOptionsOrderBy(fnOptions);
21
21
  return client.api.listExportMany({
22
22
  export: {
23
- date
23
+ date,
24
+ type: inputCopy.type
24
25
  },
25
26
  options: fnOptions
26
27
  });
@@ -5,9 +5,14 @@
5
5
  "description": "Input for listExports",
6
6
  "type": "object",
7
7
  "properties": {
8
+ "type": {
9
+ "description": "Type of the export",
10
+ "$ref": "/txs/get-export/get-export.schema.output.json#/definitions/export_type"
11
+ },
8
12
  "date": {
9
13
  "description": "Date of the export",
10
- "type": ["string"]
14
+ "type": "string",
15
+ "format": "date"
11
16
  },
12
17
  "options": {
13
18
  "$ref": "#/definitions/list_exports_fn_options"
@@ -15,7 +20,20 @@
15
20
  },
16
21
  "definitions": {
17
22
  "list_exports_fn_options": {
18
- "$ref": "/txs/list-export-many/list-export-many.schema.input.json#/definitions/list_export_many_tx_options"
23
+ "allOf": [
24
+ {
25
+ "$ref": "/txs/tx-consts.schema.json#/definitions/i_tx_limiting_options"
26
+ },
27
+ {
28
+ "$ref": "/txs/tx-consts.schema.json#/definitions/i_tx_general_options"
29
+ },
30
+ {
31
+ "$ref": "/txs/list-export-many/list-export-many.schema.input.json#/definitions/list_export_many_ordering_options"
32
+ },
33
+ {
34
+ "$ref": "/fns/fn-consts.schema.json#/definitions/i_fn_find_options_extra"
35
+ }
36
+ ]
19
37
  }
20
38
  },
21
39
  "additionalProperties": false
@@ -40,7 +40,8 @@ function updateTransfer(options, input, fnOptions) {
40
40
  transfer: (0, import_utils.getIdentifierFilter)(inputCopy.transfer),
41
41
  update: {
42
42
  status: inputCopy.status,
43
- metadata: inputCopy.metadata
43
+ metadata: inputCopy.metadata,
44
+ extend_metadata: inputCopy.extend_metadata
44
45
  },
45
46
  options: inputCopy.options
46
47
  });
@@ -16,7 +16,8 @@ function updateTransfer(options, input, fnOptions) {
16
16
  transfer: getIdentifierFilter(inputCopy.transfer),
17
17
  update: {
18
18
  status: inputCopy.status,
19
- metadata: inputCopy.metadata
19
+ metadata: inputCopy.metadata,
20
+ extend_metadata: inputCopy.extend_metadata
20
21
  },
21
22
  options: inputCopy.options
22
23
  });
@@ -40,7 +40,8 @@ function updateTransfer(options, input, fnOptions) {
40
40
  transfer: (0, import_utils.getIdentifierFilter)(inputCopy.transfer),
41
41
  update: {
42
42
  status: inputCopy.status,
43
- metadata: inputCopy.metadata
43
+ metadata: inputCopy.metadata,
44
+ extend_metadata: inputCopy.extend_metadata
44
45
  },
45
46
  options: inputCopy.options
46
47
  });
@@ -21,6 +21,12 @@ export interface UpdateTransferFnInput {
21
21
  metadata?: {
22
22
  [k: string]: unknown;
23
23
  } | null;
24
+ /**
25
+ * Key/value object describing this transfer
26
+ */
27
+ extend_metadata?: {
28
+ [k: string]: unknown;
29
+ } | null;
24
30
  options?: UpdateTransferFnOptions;
25
31
  }
26
32
  /**
@@ -16,7 +16,8 @@ function updateTransfer(options, input, fnOptions) {
16
16
  transfer: getIdentifierFilter(inputCopy.transfer),
17
17
  update: {
18
18
  status: inputCopy.status,
19
- metadata: inputCopy.metadata
19
+ metadata: inputCopy.metadata,
20
+ extend_metadata: inputCopy.extend_metadata
20
21
  },
21
22
  options: inputCopy.options
22
23
  });
@@ -16,6 +16,9 @@
16
16
  "metadata": {
17
17
  "$ref": "/db/transfer/transfer.schema.json#/properties/metadata"
18
18
  },
19
+ "extend_metadata": {
20
+ "$ref": "/db/transfer/transfer.schema.json#/properties/metadata"
21
+ },
19
22
  "options": {
20
23
  "$ref": "#/definitions/update_transfer_fn_options"
21
24
  }
@@ -59,7 +59,10 @@ var WapiClientType = /* @__PURE__ */ ((WapiClientType2) => {
59
59
  return WapiClientType2;
60
60
  })(WapiClientType || {});
61
61
  function create(options) {
62
+ var _a;
62
63
  const config = options.config;
64
+ delete options.config;
65
+ (_a = options.client) != null ? _a : options.client = "ws" /* ws */;
63
66
  const { inputCopy, error } = validate(options);
64
67
  if (error) {
65
68
  throw error;
@@ -34,7 +34,10 @@ var WapiClientType = /* @__PURE__ */ ((WapiClientType2) => {
34
34
  return WapiClientType2;
35
35
  })(WapiClientType || {});
36
36
  function create(options) {
37
+ var _a;
37
38
  const config = options.config;
39
+ delete options.config;
40
+ (_a = options.client) != null ? _a : options.client = "ws" /* ws */;
38
41
  const { inputCopy, error } = validate(options);
39
42
  if (error) {
40
43
  throw error;
package/dist/index.cjs CHANGED
@@ -59,7 +59,10 @@ var WapiClientType = /* @__PURE__ */ ((WapiClientType2) => {
59
59
  return WapiClientType2;
60
60
  })(WapiClientType || {});
61
61
  function create(options) {
62
+ var _a;
62
63
  const config = options.config;
64
+ delete options.config;
65
+ (_a = options.client) != null ? _a : options.client = "ws" /* ws */;
63
66
  const { inputCopy, error } = validate(options);
64
67
  if (error) {
65
68
  throw error;
package/dist/index.d.ts CHANGED
@@ -10,7 +10,7 @@ export declare enum WapiClientType {
10
10
  https = "https"
11
11
  }
12
12
  export interface WapiClientWsOptions {
13
- client: WapiClientType.ws;
13
+ client?: WapiClientType.ws;
14
14
  connection: WapiConnectionOptions;
15
15
  config?: ClientConfig;
16
16
  }
@@ -35,32 +35,50 @@ export type WapiClientOptions = WapiClientWsOptions | WapiClientHttpOptions;
35
35
  * },
36
36
  * config: {
37
37
  * hooks: {
38
+ * // will fire after initial connection has been made
38
39
  * connected() {
39
40
  * console.log('connected');
40
41
  * },
42
+ * // will fire if the connection drops
41
43
  * disconnected() {
42
44
  * console.log('disconnected');
43
45
  * },
46
+ * // will fire before attempting to reconnect
47
+ * // if this function returns false it will not reconnect
44
48
  * reconnect() {
45
49
  * console.log('reconnect attempt');
46
50
  * // return false; from this hook to prevent reconnecting
47
51
  * },
52
+ * // will fire if there is a problem with reconnecting
48
53
  * reconnectError(err) {
49
54
  * console.error(err);
50
- * // this hook will fire if websocket disconnects and fails to reconnect
51
55
  * }
56
+ * // will fire before each message is sent to server
57
+ * // if this message returns false then the message is not sent
52
58
  * preflight(msg) => {
53
59
  * console.log('sending msg', msg);
54
- * return true; // allow
55
60
  * },
61
+ * // will fire when a message is received from the server
56
62
  * message(msg) => {
57
63
  * console.log('got msg', msg);
58
64
  * },
59
65
  * },
60
- * token: 'EUR', // default token
66
+ * // default token to be used in methods that require a token
67
+ * // allows you to skip specifying the token each time if you only care about one token
68
+ * token: 'EUR',
69
+ * // how long to wait on initial connection before throwing an error
70
+ * // default is to wait underlying network layer timeout
71
+ * connectingTimeout: 60000;
72
+ * // how long to wait on reconnect attempts before erroring
73
+ * // default is to wait underlying network layer timeout
74
+ * reconnectingTimeout: 60000;
75
+ * // how long to wait for server ACK response on sending a command
76
+ * // NB! erroring on this timeout does not mean the command is not executed
77
+ * // as the command might have gotten through, but return ACK did not
78
+ * sendingTimeout: 60000;
61
79
  * }
62
80
  * });
63
- *
81
+ * // this direct wait for connect is not required
64
82
  * await client.$connect;
65
83
  *
66
84
  * ```
package/dist/index.js CHANGED
@@ -34,7 +34,10 @@ var WapiClientType = /* @__PURE__ */ ((WapiClientType2) => {
34
34
  return WapiClientType2;
35
35
  })(WapiClientType || {});
36
36
  function create(options) {
37
+ var _a;
37
38
  const config = options.config;
39
+ delete options.config;
40
+ (_a = options.client) != null ? _a : options.client = "ws" /* ws */;
38
41
  const { inputCopy, error } = validate(options);
39
42
  if (error) {
40
43
  throw error;