@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.
- package/dist/cjs/bee-dev.js +78 -0
- package/dist/cjs/bee.js +69 -113
- package/dist/cjs/feed/retrievable.js +4 -4
- package/dist/cjs/index.js +3 -1
- package/dist/cjs/modules/bytes.js +12 -4
- package/dist/cjs/modules/bzz.js +12 -27
- package/dist/cjs/modules/chunk.js +6 -3
- package/dist/cjs/modules/debug/connectivity.js +2 -1
- package/dist/cjs/modules/feed.js +1 -1
- package/dist/cjs/modules/grantee.js +9 -8
- package/dist/cjs/modules/pss.js +1 -1
- package/dist/cjs/modules/soc.js +4 -2
- package/dist/cjs/utils/collection.js +1 -1
- package/dist/cjs/utils/collection.node.js +0 -1
- package/dist/cjs/utils/expose.js +2 -1
- package/dist/cjs/utils/headers.js +61 -54
- package/dist/cjs/utils/http.js +9 -0
- package/dist/cjs/utils/tar-uploader.browser.js +2 -2
- package/dist/cjs/utils/tar-uploader.js +2 -2
- package/dist/cjs/utils/type.js +119 -191
- package/dist/index.browser.min.js +1 -1
- package/dist/index.browser.min.js.map +1 -1
- package/dist/mjs/bee-dev.js +98 -0
- package/dist/mjs/bee.js +75 -117
- package/dist/mjs/feed/retrievable.js +4 -4
- package/dist/mjs/index.js +2 -1
- package/dist/mjs/modules/bytes.js +13 -7
- package/dist/mjs/modules/bzz.js +9 -25
- package/dist/mjs/modules/chunk.js +7 -6
- package/dist/mjs/modules/debug/connectivity.js +1 -1
- package/dist/mjs/modules/feed.js +2 -2
- package/dist/mjs/modules/grantee.js +12 -11
- package/dist/mjs/modules/pss.js +2 -2
- package/dist/mjs/modules/soc.js +4 -4
- package/dist/mjs/utils/collection.js +1 -1
- package/dist/mjs/utils/collection.node.js +0 -1
- package/dist/mjs/utils/expose.js +1 -1
- package/dist/mjs/utils/headers.js +59 -50
- package/dist/mjs/utils/http.js +9 -0
- package/dist/mjs/utils/tar-uploader.browser.js +2 -2
- package/dist/mjs/utils/tar-uploader.js +2 -2
- package/dist/mjs/utils/type.js +202 -163
- package/dist/types/bee-dev.d.ts +5 -0
- package/dist/types/bee.d.ts +21 -21
- package/dist/types/feed/retrievable.d.ts +2 -2
- package/dist/types/index.d.ts +3 -1
- package/dist/types/modules/bytes.d.ts +4 -4
- package/dist/types/modules/bzz.d.ts +5 -10
- package/dist/types/modules/chunk.d.ts +2 -2
- package/dist/types/modules/debug/chequebook.d.ts +2 -2
- package/dist/types/modules/debug/connectivity.d.ts +2 -1
- package/dist/types/modules/grantee.d.ts +4 -4
- package/dist/types/types/debug.d.ts +0 -1
- package/dist/types/types/index.d.ts +12 -6
- package/dist/types/utils/collection.d.ts +1 -1
- package/dist/types/utils/collection.node.d.ts +0 -1
- package/dist/types/utils/expose.d.ts +1 -1
- package/dist/types/utils/headers.d.ts +2 -4
- package/dist/types/utils/tar-uploader.browser.d.ts +2 -2
- package/dist/types/utils/tar-uploader.d.ts +2 -2
- package/dist/types/utils/type.d.ts +12 -18
- package/package.json +2 -2
package/dist/cjs/utils/type.js
CHANGED
|
@@ -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.
|
|
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
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
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
|
-
|
|
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
|
|
121
|
+
function preparePssMessageHandler(value) {
|
|
147
122
|
const object = cafe_utility_1.Types.asObject(value, { name: 'PssMessageHandler' });
|
|
148
|
-
|
|
149
|
-
|
|
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.
|
|
152
|
-
function
|
|
128
|
+
exports.preparePssMessageHandler = preparePssMessageHandler;
|
|
129
|
+
function prepareGsocMessageHandler(value) {
|
|
153
130
|
const object = cafe_utility_1.Types.asObject(value, { name: 'GsocMessageHandler' });
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
exports.
|
|
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
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
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(
|
|
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
|
-
|
|
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(
|
|
204
|
+
throw new TypeError(`Expected number | Tag | string from tagUid, got: ${tagUid}`);
|
|
277
205
|
}
|
|
278
206
|
exports.makeTagUid = makeTagUid;
|