@upcoming/bee-js 0.3.0 → 0.5.0

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 (62) hide show
  1. package/dist/cjs/bee-dev.js +78 -0
  2. package/dist/cjs/bee.js +69 -113
  3. package/dist/cjs/feed/retrievable.js +4 -4
  4. package/dist/cjs/index.js +3 -1
  5. package/dist/cjs/modules/bytes.js +12 -4
  6. package/dist/cjs/modules/bzz.js +12 -27
  7. package/dist/cjs/modules/chunk.js +6 -3
  8. package/dist/cjs/modules/debug/connectivity.js +2 -1
  9. package/dist/cjs/modules/feed.js +1 -1
  10. package/dist/cjs/modules/grantee.js +9 -8
  11. package/dist/cjs/modules/pss.js +1 -1
  12. package/dist/cjs/modules/soc.js +4 -2
  13. package/dist/cjs/utils/collection.js +1 -1
  14. package/dist/cjs/utils/collection.node.js +0 -1
  15. package/dist/cjs/utils/expose.js +2 -1
  16. package/dist/cjs/utils/headers.js +61 -54
  17. package/dist/cjs/utils/http.js +9 -0
  18. package/dist/cjs/utils/tar-uploader.browser.js +2 -2
  19. package/dist/cjs/utils/tar-uploader.js +2 -2
  20. package/dist/cjs/utils/type.js +119 -191
  21. package/dist/index.browser.min.js +1 -1
  22. package/dist/index.browser.min.js.map +1 -1
  23. package/dist/mjs/bee-dev.js +98 -0
  24. package/dist/mjs/bee.js +75 -117
  25. package/dist/mjs/feed/retrievable.js +4 -4
  26. package/dist/mjs/index.js +2 -1
  27. package/dist/mjs/modules/bytes.js +13 -7
  28. package/dist/mjs/modules/bzz.js +9 -25
  29. package/dist/mjs/modules/chunk.js +7 -6
  30. package/dist/mjs/modules/debug/connectivity.js +1 -1
  31. package/dist/mjs/modules/feed.js +2 -2
  32. package/dist/mjs/modules/grantee.js +12 -11
  33. package/dist/mjs/modules/pss.js +2 -2
  34. package/dist/mjs/modules/soc.js +4 -4
  35. package/dist/mjs/utils/collection.js +1 -1
  36. package/dist/mjs/utils/collection.node.js +0 -1
  37. package/dist/mjs/utils/expose.js +1 -1
  38. package/dist/mjs/utils/headers.js +59 -50
  39. package/dist/mjs/utils/http.js +9 -0
  40. package/dist/mjs/utils/tar-uploader.browser.js +2 -2
  41. package/dist/mjs/utils/tar-uploader.js +2 -2
  42. package/dist/mjs/utils/type.js +202 -163
  43. package/dist/types/bee-dev.d.ts +5 -0
  44. package/dist/types/bee.d.ts +21 -21
  45. package/dist/types/feed/retrievable.d.ts +2 -2
  46. package/dist/types/index.d.ts +3 -1
  47. package/dist/types/modules/bytes.d.ts +4 -4
  48. package/dist/types/modules/bzz.d.ts +5 -10
  49. package/dist/types/modules/chunk.d.ts +2 -2
  50. package/dist/types/modules/debug/chequebook.d.ts +2 -2
  51. package/dist/types/modules/debug/connectivity.d.ts +2 -1
  52. package/dist/types/modules/grantee.d.ts +4 -4
  53. package/dist/types/types/debug.d.ts +0 -1
  54. package/dist/types/types/index.d.ts +12 -6
  55. package/dist/types/utils/collection.d.ts +1 -1
  56. package/dist/types/utils/collection.node.d.ts +0 -1
  57. package/dist/types/utils/expose.d.ts +1 -1
  58. package/dist/types/utils/headers.d.ts +2 -4
  59. package/dist/types/utils/tar-uploader.browser.d.ts +2 -2
  60. package/dist/types/utils/tar-uploader.d.ts +2 -2
  61. package/dist/types/utils/type.d.ts +12 -18
  62. package/package.json +2 -2
@@ -23,12 +23,12 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.makeTagUid = exports.assertAllTagsOptions = exports.assertFileData = exports.assertData = exports.assertCashoutOptions = exports.assertTransactionOptions = exports.assertPostageBatchOptions = exports.assertGsocMessageHandler = exports.assertPssMessageHandler = exports.isTag = exports.assertCollectionUploadOptions = exports.assertFileUploadOptions = exports.assertUploadOptions = exports.assertRequestOptions = exports.assertNonNegativeInteger = exports.assertInteger = exports.assertBoolean = exports.assertStrictlyObject = exports.isStrictlyObject = exports.isObject = exports.isInteger = exports.asNumberString = exports.isReadable = void 0;
26
+ exports.makeTagUid = exports.prepareAllTagsOptions = exports.assertFileData = exports.assertData = exports.prepareTransactionOptions = exports.preparePostageBatchOptions = exports.prepareGsocMessageHandler = exports.preparePssMessageHandler = exports.isTag = exports.prepareCollectionUploadOptions = exports.prepareFileUploadOptions = exports.prepareRedundantUploadOptions = exports.prepareUploadOptions = exports.prepareDownloadOptions = exports.prepareBeeRequestOptions = exports.asNumberString = exports.isReadable = void 0;
27
27
  const cafe_utility_1 = require("cafe-utility");
28
28
  const stream = __importStar(require("stream"));
29
29
  const types_1 = require("../types");
30
- const error_1 = require("./error");
31
30
  const file_1 = require("./file");
31
+ const typed_bytes_1 = require("./typed-bytes");
32
32
  function isReadable(obj) {
33
33
  return typeof stream.Readable !== 'undefined' && obj instanceof stream.Readable;
34
34
  }
@@ -40,166 +40,119 @@ function asNumberString(value, options) {
40
40
  return cafe_utility_1.Types.asIntegerString(value, options);
41
41
  }
42
42
  exports.asNumberString = asNumberString;
43
- function isInteger(value) {
44
- return ((typeof value === 'string' && /^-?(0|[1-9][0-9]*)$/g.test(value)) ||
45
- (typeof value === 'number' &&
46
- value > Number.MIN_SAFE_INTEGER &&
47
- value < Number.MAX_SAFE_INTEGER &&
48
- Number.isInteger(value)));
49
- }
50
- exports.isInteger = isInteger;
51
- function isObject(value) {
52
- return value !== null && typeof value === 'object';
53
- }
54
- exports.isObject = isObject;
55
- function isStrictlyObject(value) {
56
- return isObject(value) && !Array.isArray(value);
57
- }
58
- exports.isStrictlyObject = isStrictlyObject;
59
- function assertStrictlyObject(value, name = 'value') {
60
- if (!isStrictlyObject(value)) {
61
- throw new TypeError(`${name} has to be an object that is not null nor array!`);
62
- }
63
- }
64
- exports.assertStrictlyObject = assertStrictlyObject;
65
- function assertBoolean(value, name = 'value') {
66
- if (value !== true && value !== false)
67
- throw new TypeError(`${name} is not boolean`);
68
- }
69
- exports.assertBoolean = assertBoolean;
70
- function assertInteger(value, name = 'value') {
71
- if (!isInteger(value))
72
- throw new TypeError(`${name} is not integer`);
73
- }
74
- exports.assertInteger = assertInteger;
75
- function assertNonNegativeInteger(value, name = 'Value') {
76
- assertInteger(value, name);
77
- if (Number(value) < 0)
78
- throw new error_1.BeeArgumentError(`${name} has to be bigger or equal to zero`, value);
79
- }
80
- exports.assertNonNegativeInteger = assertNonNegativeInteger;
81
- function assertRequestOptions(value, name = 'RequestOptions') {
82
- if (value === undefined) {
83
- return;
84
- }
85
- if (!isStrictlyObject(value)) {
86
- throw new TypeError(`${name} has to be an object!`);
87
- }
88
- const options = value;
89
- if (options.timeout) {
90
- assertNonNegativeInteger(options.timeout, `${name}.timeout`);
91
- }
92
- }
93
- exports.assertRequestOptions = assertRequestOptions;
94
- function assertUploadOptions(value, name = 'UploadOptions') {
95
- if (!isStrictlyObject(value)) {
96
- throw new TypeError(`${name} has to be an object!`);
97
- }
98
- assertRequestOptions(value, name);
99
- const options = value;
100
- if (options.pin && typeof options.pin !== 'boolean') {
101
- throw new TypeError(`options.pin property in ${name} has to be boolean or undefined!`);
102
- }
103
- if (options.encrypt && typeof options.encrypt !== 'boolean') {
104
- throw new TypeError(`options.encrypt property in ${name} has to be boolean or undefined!`);
105
- }
106
- if (options.tag) {
107
- if (typeof options.tag !== 'number') {
108
- throw new TypeError(`options.tag property in ${name} has to be number or undefined!`);
109
- }
110
- assertNonNegativeInteger(options.tag, 'options.tag');
111
- }
112
- }
113
- exports.assertUploadOptions = assertUploadOptions;
114
- function assertFileUploadOptions(value) {
115
- assertUploadOptions(value, 'FileUploadOptions');
116
- const options = value;
117
- if (options.size) {
118
- if (typeof options.size !== 'number') {
119
- throw new TypeError('tag property in FileUploadOptions has to be number or undefined!');
120
- }
121
- assertNonNegativeInteger(options.size, 'options.size');
122
- }
123
- if (options.contentType && typeof options.contentType !== 'string') {
124
- throw new TypeError('contentType property in FileUploadOptions has to be string or undefined!');
125
- }
126
- }
127
- exports.assertFileUploadOptions = assertFileUploadOptions;
128
- function assertCollectionUploadOptions(value) {
129
- assertUploadOptions(value, 'CollectionUploadOptions');
130
- const options = value;
131
- if (options.indexDocument && typeof options.indexDocument !== 'string') {
132
- throw new TypeError('indexDocument property in CollectionUploadOptions has to be string or undefined!');
133
- }
134
- if (options.errorDocument && typeof options.errorDocument !== 'string') {
135
- throw new TypeError('errorDocument property in CollectionUploadOptions has to be string or undefined!');
136
- }
137
- }
138
- exports.assertCollectionUploadOptions = assertCollectionUploadOptions;
43
+ function prepareBeeRequestOptions(value) {
44
+ const object = cafe_utility_1.Types.asObject(value, { name: 'BeeRequestOptions' });
45
+ return {
46
+ baseURL: cafe_utility_1.Types.asOptional(x => cafe_utility_1.Types.asString(x, { name: 'baseURL' }), object.baseURL),
47
+ timeout: cafe_utility_1.Types.asOptional(x => cafe_utility_1.Types.asInteger(x, { name: 'timeout', min: 0 }), object.timeout),
48
+ headers: cafe_utility_1.Types.asOptional(x => cafe_utility_1.Types.asStringMap(x, { name: 'headers' }), object.headers),
49
+ onRequest: cafe_utility_1.Types.asOptional(x => cafe_utility_1.Types.asFunction(x, { name: 'onRequest' }), object.onRequest),
50
+ httpAgent: object.httpAgent,
51
+ httpsAgent: object.httpsAgent,
52
+ endlesslyRetry: cafe_utility_1.Types.asOptional(x => cafe_utility_1.Types.asBoolean(x, { name: 'endlesslyRetry' }), object.endlesslyRetry),
53
+ };
54
+ }
55
+ exports.prepareBeeRequestOptions = prepareBeeRequestOptions;
56
+ function prepareDownloadOptions(value) {
57
+ const object = cafe_utility_1.Types.asObject(value, { name: 'DownloadOptions' });
58
+ return {
59
+ redundancyStrategy: cafe_utility_1.Types.asOptional(x => cafe_utility_1.Types.asInteger(x, { name: 'redundancyStrategy' }), object.redundancyStrategy),
60
+ fallback: cafe_utility_1.Types.asOptional(x => cafe_utility_1.Types.asBoolean(x, { name: 'fallback' }), object.fallback),
61
+ timeoutMs: cafe_utility_1.Types.asOptional(x => cafe_utility_1.Types.asInteger(x, { name: 'timeoutMs', min: 0 }), object.timeoutMs),
62
+ actPublisher: cafe_utility_1.Types.asOptional(x => new typed_bytes_1.PublicKey(x), object.actPublisher),
63
+ actHistoryAddress: cafe_utility_1.Types.asOptional(x => new typed_bytes_1.Reference(x), object.actHistoryAddress),
64
+ actTimestamp: cafe_utility_1.Types.asOptional(x => cafe_utility_1.Types.asNumber(x, { name: 'actTimestamp' }), object.actTimestamp),
65
+ };
66
+ }
67
+ exports.prepareDownloadOptions = prepareDownloadOptions;
68
+ function prepareUploadOptions(value, name = 'UploadOptions') {
69
+ const object = cafe_utility_1.Types.asObject(value, { name });
70
+ return {
71
+ act: cafe_utility_1.Types.asOptional(x => cafe_utility_1.Types.asBoolean(x, { name: 'act' }), object.act),
72
+ deferred: cafe_utility_1.Types.asOptional(x => cafe_utility_1.Types.asBoolean(x, { name: 'deferred' }), object.deferred),
73
+ encrypt: cafe_utility_1.Types.asOptional(x => cafe_utility_1.Types.asBoolean(x, { name: 'encrypt' }), object.encrypt),
74
+ pin: cafe_utility_1.Types.asOptional(x => cafe_utility_1.Types.asBoolean(x, { name: 'pin' }), object.pin),
75
+ tag: cafe_utility_1.Types.asOptional(x => cafe_utility_1.Types.asInteger(x, { name: 'tag', min: 0 }), object.tag),
76
+ };
77
+ }
78
+ exports.prepareUploadOptions = prepareUploadOptions;
79
+ function prepareRedundantUploadOptions(value, name = 'UploadOptions') {
80
+ const uploadOptions = prepareUploadOptions(value, name);
81
+ const object = cafe_utility_1.Types.asObject(value, { name });
82
+ return {
83
+ ...uploadOptions,
84
+ redundancyLevel: cafe_utility_1.Types.asOptional(x => cafe_utility_1.Types.asInteger(x, { name: 'redundancyLevel', min: 0 }), object.redundancyLevel),
85
+ };
86
+ }
87
+ exports.prepareRedundantUploadOptions = prepareRedundantUploadOptions;
88
+ function prepareFileUploadOptions(value) {
89
+ const uploadOptions = prepareUploadOptions(value, 'FileUploadOptions');
90
+ const object = cafe_utility_1.Types.asObject(value, { name: 'FileUploadOptions' });
91
+ return {
92
+ ...uploadOptions,
93
+ size: cafe_utility_1.Types.asOptional(x => cafe_utility_1.Types.asInteger(x, { name: 'size', min: 0 }), object.size),
94
+ contentType: cafe_utility_1.Types.asOptional(x => cafe_utility_1.Types.asString(x, { name: 'contentType' }), object.contentType),
95
+ redundancyLevel: cafe_utility_1.Types.asOptional(x => cafe_utility_1.Types.asInteger(x, { name: 'redundancyLevel', min: 0 }), object.redundancyLevel),
96
+ };
97
+ }
98
+ exports.prepareFileUploadOptions = prepareFileUploadOptions;
99
+ function prepareCollectionUploadOptions(value) {
100
+ const uploadOptions = prepareUploadOptions(value, 'CollectionUploadOptions');
101
+ const object = cafe_utility_1.Types.asObject(value, { name: 'CollectionUploadOptions' });
102
+ return {
103
+ ...uploadOptions,
104
+ errorDocument: cafe_utility_1.Types.asOptional(x => cafe_utility_1.Types.asString(x, { name: 'errorDocument' }), object.errorDocument),
105
+ indexDocument: cafe_utility_1.Types.asOptional(x => cafe_utility_1.Types.asString(x, { name: 'indexDocument' }), object.indexDocument),
106
+ redundancyLevel: cafe_utility_1.Types.asOptional(x => cafe_utility_1.Types.asInteger(x, { name: 'redundancyLevel', min: 0 }), object.redundancyLevel),
107
+ };
108
+ }
109
+ exports.prepareCollectionUploadOptions = prepareCollectionUploadOptions;
139
110
  function isTag(value) {
140
- if (!isStrictlyObject(value)) {
111
+ try {
112
+ const object = cafe_utility_1.Types.asObject(value, { name: 'Tag' });
113
+ cafe_utility_1.Types.asInteger(object.uid, { name: 'Tag.uid' });
114
+ return true;
115
+ }
116
+ catch {
141
117
  return false;
142
118
  }
143
- return Boolean(value.uid);
144
119
  }
145
120
  exports.isTag = isTag;
146
- function assertPssMessageHandler(value) {
121
+ function preparePssMessageHandler(value) {
147
122
  const object = cafe_utility_1.Types.asObject(value, { name: 'PssMessageHandler' });
148
- cafe_utility_1.Types.asFunction(object.onMessage, { name: 'onMessage' });
149
- cafe_utility_1.Types.asFunction(object.onError, { name: 'onError' });
123
+ return {
124
+ onMessage: cafe_utility_1.Types.asFunction(object.onMessage, { name: 'onMessage' }),
125
+ onError: cafe_utility_1.Types.asFunction(object.onError, { name: 'onError' }),
126
+ };
150
127
  }
151
- exports.assertPssMessageHandler = assertPssMessageHandler;
152
- function assertGsocMessageHandler(value) {
128
+ exports.preparePssMessageHandler = preparePssMessageHandler;
129
+ function prepareGsocMessageHandler(value) {
153
130
  const object = cafe_utility_1.Types.asObject(value, { name: 'GsocMessageHandler' });
154
- cafe_utility_1.Types.asFunction(object.onMessage, { name: 'onMessage' });
155
- cafe_utility_1.Types.asFunction(object.onError, { name: 'onError' });
156
- }
157
- exports.assertGsocMessageHandler = assertGsocMessageHandler;
158
- function assertPostageBatchOptions(value) {
159
- if (value === undefined) {
160
- return;
161
- }
162
- assertStrictlyObject(value);
163
- const options = value;
164
- assertRequestOptions(options, 'PostageBatchOptions');
165
- if (options?.gasPrice) {
166
- assertNonNegativeInteger(options.gasPrice);
167
- }
168
- if (options?.immutableFlag !== undefined) {
169
- assertBoolean(options.immutableFlag);
170
- }
171
- if (options?.waitForUsable !== undefined) {
172
- assertBoolean(options.waitForUsable);
173
- }
174
- if (options?.waitForUsableTimeout !== undefined) {
175
- assertNonNegativeInteger(options.waitForUsableTimeout, 'options.waitForUsableTimeout');
176
- }
177
- }
178
- exports.assertPostageBatchOptions = assertPostageBatchOptions;
179
- function assertTransactionOptions(value, name = 'TransactionOptions') {
180
- if (value === undefined) {
181
- return;
182
- }
183
- assertStrictlyObject(value, name);
184
- const options = value;
185
- if (options?.gasLimit) {
186
- assertNonNegativeInteger(options.gasLimit, name);
187
- }
188
- if (options?.gasPrice) {
189
- assertNonNegativeInteger(options.gasPrice, name);
190
- }
191
- }
192
- exports.assertTransactionOptions = assertTransactionOptions;
193
- function assertCashoutOptions(value) {
194
- if (value === undefined) {
195
- return;
196
- }
197
- assertStrictlyObject(value);
198
- const options = value;
199
- assertRequestOptions(options, 'CashoutOptions');
200
- assertTransactionOptions(options, 'CashoutOptions');
201
- }
202
- exports.assertCashoutOptions = assertCashoutOptions;
131
+ return {
132
+ onMessage: cafe_utility_1.Types.asFunction(object.onMessage, { name: 'onMessage' }),
133
+ onError: cafe_utility_1.Types.asFunction(object.onError, { name: 'onError' }),
134
+ };
135
+ }
136
+ exports.prepareGsocMessageHandler = prepareGsocMessageHandler;
137
+ function preparePostageBatchOptions(value) {
138
+ const object = cafe_utility_1.Types.asObject(value, { name: 'PostageBatchOptions' });
139
+ return {
140
+ gasPrice: cafe_utility_1.Types.asOptional(x => asNumberString(x, { name: 'gasPrice' }), object.gasPrice),
141
+ immutableFlag: cafe_utility_1.Types.asOptional(x => cafe_utility_1.Types.asBoolean(x, { name: 'immutableFlag' }), object.immutableFlag),
142
+ label: cafe_utility_1.Types.asOptional(x => cafe_utility_1.Types.asString(x, { name: 'label' }), object.label),
143
+ waitForUsable: cafe_utility_1.Types.asOptional(x => cafe_utility_1.Types.asBoolean(x, { name: 'waitForUsable' }), object.waitForUsable),
144
+ waitForUsableTimeout: cafe_utility_1.Types.asOptional(x => cafe_utility_1.Types.asInteger(x, { name: 'waitForUsableTimeout', min: 0 }), object.waitForUsableTimeout),
145
+ };
146
+ }
147
+ exports.preparePostageBatchOptions = preparePostageBatchOptions;
148
+ function prepareTransactionOptions(value, name = 'TransactionOptions') {
149
+ const object = cafe_utility_1.Types.asObject(value, { name });
150
+ return {
151
+ gasLimit: cafe_utility_1.Types.asOptional(x => asNumberString(x, { name: 'gasLimit', min: 0n }), object.gasLimit),
152
+ gasPrice: cafe_utility_1.Types.asOptional(x => asNumberString(x, { name: 'gasPrice', min: 0n }), object.gasPrice),
153
+ };
154
+ }
155
+ exports.prepareTransactionOptions = prepareTransactionOptions;
203
156
  /**
204
157
  * Check whether the given parameter is valid data to upload
205
158
  * @param value
@@ -226,53 +179,28 @@ exports.assertFileData = assertFileData;
226
179
  * Checks whether optional options for AllTags query are valid
227
180
  * @param options
228
181
  */
229
- function assertAllTagsOptions(entry) {
230
- if (entry !== undefined && !isStrictlyObject(entry)) {
231
- throw new TypeError('options has to be an object or undefined!');
232
- }
233
- assertRequestOptions(entry, 'AllTagsOptions');
234
- const options = entry;
235
- if (options?.limit !== undefined) {
236
- if (typeof options.limit !== 'number') {
237
- throw new TypeError('AllTagsOptions.limit has to be a number or undefined!');
238
- }
239
- if (options.limit < types_1.TAGS_LIMIT_MIN) {
240
- throw new error_1.BeeArgumentError(`AllTagsOptions.limit has to be at least ${types_1.TAGS_LIMIT_MIN}`, options.limit);
241
- }
242
- if (options.limit > types_1.TAGS_LIMIT_MAX) {
243
- throw new error_1.BeeArgumentError(`AllTagsOptions.limit has to be at most ${types_1.TAGS_LIMIT_MAX}`, options.limit);
244
- }
245
- }
246
- if (options?.offset !== undefined) {
247
- assertNonNegativeInteger(options.offset, 'AllTagsOptions.offset');
248
- }
249
- }
250
- exports.assertAllTagsOptions = assertAllTagsOptions;
182
+ function prepareAllTagsOptions(value) {
183
+ const object = cafe_utility_1.Types.asObject(value, { name: 'AllTagsOptions' });
184
+ return {
185
+ limit: cafe_utility_1.Types.asOptional(x => cafe_utility_1.Types.asInteger(x, { name: 'limit', min: types_1.TAGS_LIMIT_MIN, max: types_1.TAGS_LIMIT_MAX }), object.limit),
186
+ offset: cafe_utility_1.Types.asOptional(x => cafe_utility_1.Types.asInteger(x, { name: 'offset', min: 0 }), object.offset),
187
+ };
188
+ }
189
+ exports.prepareAllTagsOptions = prepareAllTagsOptions;
251
190
  /**
252
191
  * Utility functions that return Tag UID
253
192
  * @param tagUid
254
193
  */
255
194
  function makeTagUid(tagUid) {
256
195
  if (tagUid === undefined || tagUid === null) {
257
- throw new TypeError('TagUid was expected but got undefined or null instead!');
196
+ throw new TypeError(`Expected number | Tag | string from tagUid, got: ${tagUid}`);
258
197
  }
259
198
  if (isTag(tagUid)) {
260
199
  return tagUid.uid;
261
200
  }
262
- else if (typeof tagUid === 'number') {
263
- assertNonNegativeInteger(tagUid, 'UID');
264
- return tagUid;
265
- }
266
- else if (typeof tagUid === 'string') {
267
- const int = parseInt(tagUid);
268
- if (isNaN(int)) {
269
- throw new TypeError('Passed tagUid string is not valid integer!');
270
- }
271
- if (int < 0) {
272
- throw new TypeError(`TagUid was expected to be positive non-negative integer! Got ${int}`);
273
- }
274
- return int;
201
+ else if (typeof tagUid === 'number' || typeof tagUid === 'string') {
202
+ return cafe_utility_1.Types.asNumber(tagUid, { name: 'tagUid', min: 0 });
275
203
  }
276
- throw new TypeError('tagUid has to be either Tag or a number (UID)!');
204
+ throw new TypeError(`Expected number | Tag | string from tagUid, got: ${tagUid}`);
277
205
  }
278
206
  exports.makeTagUid = makeTagUid;