@milaboratories/pl-model-common 1.19.7 → 1.19.8
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/author_marker.d.ts +0 -1
- package/dist/base32_encode.cjs +56 -0
- package/dist/base32_encode.cjs.map +1 -0
- package/dist/base32_encode.d.ts +0 -1
- package/dist/base32_encode.js +54 -0
- package/dist/base32_encode.js.map +1 -0
- package/dist/block_state.d.ts +0 -1
- package/dist/bmodel/block_config.cjs +15 -0
- package/dist/bmodel/block_config.cjs.map +1 -0
- package/dist/bmodel/block_config.d.ts +0 -1
- package/dist/bmodel/block_config.js +13 -0
- package/dist/bmodel/block_config.js.map +1 -0
- package/dist/bmodel/code.d.ts +0 -1
- package/dist/bmodel/container.d.ts +0 -1
- package/dist/bmodel/index.d.ts +0 -1
- package/dist/bmodel/normalization.cjs +86 -0
- package/dist/bmodel/normalization.cjs.map +1 -0
- package/dist/bmodel/normalization.d.ts +0 -1
- package/dist/bmodel/normalization.js +84 -0
- package/dist/bmodel/normalization.js.map +1 -0
- package/dist/bmodel/types.d.ts +0 -1
- package/dist/branding.d.ts +0 -1
- package/dist/common_types.d.ts +0 -1
- package/dist/driver_kit.d.ts +0 -1
- package/dist/drivers/blob.cjs +27 -0
- package/dist/drivers/blob.cjs.map +1 -0
- package/dist/drivers/blob.d.ts +0 -1
- package/dist/drivers/blob.js +23 -0
- package/dist/drivers/blob.js.map +1 -0
- package/dist/drivers/index.d.ts +0 -1
- package/dist/drivers/interfaces.d.ts +0 -1
- package/dist/drivers/log.cjs +9 -0
- package/dist/drivers/log.cjs.map +1 -0
- package/dist/drivers/log.d.ts +0 -1
- package/dist/drivers/log.js +7 -0
- package/dist/drivers/log.js.map +1 -0
- package/dist/drivers/ls.cjs +39 -0
- package/dist/drivers/ls.cjs.map +1 -0
- package/dist/drivers/ls.d.ts +0 -1
- package/dist/drivers/ls.js +34 -0
- package/dist/drivers/ls.js.map +1 -0
- package/dist/drivers/pframe/column_filter.d.ts +0 -1
- package/dist/drivers/pframe/data_info.cjs +275 -0
- package/dist/drivers/pframe/data_info.cjs.map +1 -0
- package/dist/drivers/pframe/data_info.d.ts +0 -1
- package/dist/drivers/pframe/data_info.js +266 -0
- package/dist/drivers/pframe/data_info.js.map +1 -0
- package/dist/drivers/pframe/data_types.cjs +91 -0
- package/dist/drivers/pframe/data_types.cjs.map +1 -0
- package/dist/drivers/pframe/data_types.d.ts +0 -1
- package/dist/drivers/pframe/data_types.js +83 -0
- package/dist/drivers/pframe/data_types.js.map +1 -0
- package/dist/drivers/pframe/driver.d.ts +0 -1
- package/dist/drivers/pframe/find_columns.d.ts +0 -1
- package/dist/drivers/pframe/index.d.ts +0 -1
- package/dist/drivers/pframe/linker_columns.cjs +218 -0
- package/dist/drivers/pframe/linker_columns.cjs.map +1 -0
- package/dist/drivers/pframe/linker_columns.d.ts +0 -1
- package/dist/drivers/pframe/linker_columns.js +216 -0
- package/dist/drivers/pframe/linker_columns.js.map +1 -0
- package/dist/drivers/pframe/pframe.d.ts +0 -1
- package/dist/drivers/pframe/spec/anchored.cjs +234 -0
- package/dist/drivers/pframe/spec/anchored.cjs.map +1 -0
- package/dist/drivers/pframe/spec/anchored.d.ts +0 -1
- package/dist/drivers/pframe/spec/anchored.js +231 -0
- package/dist/drivers/pframe/spec/anchored.js.map +1 -0
- package/dist/drivers/pframe/spec/filtered_column.cjs +13 -0
- package/dist/drivers/pframe/spec/filtered_column.cjs.map +1 -0
- package/dist/drivers/pframe/spec/filtered_column.d.ts +0 -1
- package/dist/drivers/pframe/spec/filtered_column.js +11 -0
- package/dist/drivers/pframe/spec/filtered_column.js.map +1 -0
- package/dist/drivers/pframe/spec/ids.cjs +24 -0
- package/dist/drivers/pframe/spec/ids.cjs.map +1 -0
- package/dist/drivers/pframe/spec/ids.d.ts +0 -1
- package/dist/drivers/pframe/spec/ids.js +21 -0
- package/dist/drivers/pframe/spec/ids.js.map +1 -0
- package/dist/drivers/pframe/spec/index.d.ts +0 -1
- package/dist/drivers/pframe/spec/native_id.cjs +20 -0
- package/dist/drivers/pframe/spec/native_id.cjs.map +1 -0
- package/dist/drivers/pframe/spec/native_id.d.ts +0 -1
- package/dist/drivers/pframe/spec/native_id.js +18 -0
- package/dist/drivers/pframe/spec/native_id.js.map +1 -0
- package/dist/drivers/pframe/spec/selectors.cjs +120 -0
- package/dist/drivers/pframe/spec/selectors.cjs.map +1 -0
- package/dist/drivers/pframe/spec/selectors.d.ts +0 -1
- package/dist/drivers/pframe/spec/selectors.js +116 -0
- package/dist/drivers/pframe/spec/selectors.js.map +1 -0
- package/dist/drivers/pframe/spec/spec.cjs +361 -0
- package/dist/drivers/pframe/spec/spec.cjs.map +1 -0
- package/dist/drivers/pframe/spec/spec.d.ts +0 -1
- package/dist/drivers/pframe/spec/spec.js +332 -0
- package/dist/drivers/pframe/spec/spec.js.map +1 -0
- package/dist/drivers/pframe/table.d.ts +0 -1
- package/dist/drivers/pframe/table_calculate.cjs +43 -0
- package/dist/drivers/pframe/table_calculate.cjs.map +1 -0
- package/dist/drivers/pframe/table_calculate.d.ts +0 -1
- package/dist/drivers/pframe/table_calculate.js +40 -0
- package/dist/drivers/pframe/table_calculate.js.map +1 -0
- package/dist/drivers/pframe/table_common.cjs +19 -0
- package/dist/drivers/pframe/table_common.cjs.map +1 -0
- package/dist/drivers/pframe/table_common.d.ts +0 -1
- package/dist/drivers/pframe/table_common.js +17 -0
- package/dist/drivers/pframe/table_common.js.map +1 -0
- package/dist/drivers/pframe/type_util.d.ts +0 -1
- package/dist/drivers/pframe/unique_values.d.ts +0 -1
- package/dist/drivers/upload.d.ts +0 -1
- package/dist/drivers/urls.cjs +14 -0
- package/dist/drivers/urls.cjs.map +1 -0
- package/dist/drivers/urls.d.ts +0 -1
- package/dist/drivers/urls.js +11 -0
- package/dist/drivers/urls.js.map +1 -0
- package/dist/errors.cjs +141 -0
- package/dist/errors.cjs.map +1 -0
- package/dist/errors.d.ts +0 -1
- package/dist/errors.js +121 -0
- package/dist/errors.js.map +1 -0
- package/dist/flags/block_flags.cjs +8 -0
- package/dist/flags/block_flags.cjs.map +1 -0
- package/dist/flags/block_flags.d.ts +0 -1
- package/dist/flags/block_flags.js +5 -0
- package/dist/flags/block_flags.js.map +1 -0
- package/dist/flags/flag_utils.cjs +100 -0
- package/dist/flags/flag_utils.cjs.map +1 -0
- package/dist/flags/flag_utils.d.ts +0 -1
- package/dist/flags/flag_utils.js +94 -0
- package/dist/flags/flag_utils.js.map +1 -0
- package/dist/flags/index.d.ts +0 -1
- package/dist/flags/type_utils.d.ts +0 -1
- package/dist/index.cjs +151 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +10 -12
- package/dist/index.js +27 -1
- package/dist/index.js.map +1 -1
- package/dist/json.cjs +18 -0
- package/dist/json.cjs.map +1 -0
- package/dist/json.d.ts +0 -1
- package/dist/json.js +14 -0
- package/dist/json.js.map +1 -0
- package/dist/navigation.cjs +6 -0
- package/dist/navigation.cjs.map +1 -0
- package/dist/navigation.d.ts +0 -1
- package/dist/navigation.js +4 -0
- package/dist/navigation.js.map +1 -0
- package/dist/plid.cjs +37 -0
- package/dist/plid.cjs.map +1 -0
- package/dist/plid.d.ts +0 -1
- package/dist/plid.js +30 -0
- package/dist/plid.js.map +1 -0
- package/dist/pool/entry.d.ts +0 -1
- package/dist/pool/index.d.ts +0 -1
- package/dist/pool/query.cjs +49 -0
- package/dist/pool/query.cjs.map +1 -0
- package/dist/pool/query.d.ts +0 -1
- package/dist/pool/query.js +47 -0
- package/dist/pool/query.js.map +1 -0
- package/dist/pool/spec.cjs +67 -0
- package/dist/pool/spec.cjs.map +1 -0
- package/dist/pool/spec.d.ts +0 -1
- package/dist/pool/spec.js +59 -0
- package/dist/pool/spec.js.map +1 -0
- package/dist/ref.cjs +88 -0
- package/dist/ref.cjs.map +1 -0
- package/dist/ref.d.ts +0 -1
- package/dist/ref.js +82 -0
- package/dist/ref.js.map +1 -0
- package/dist/utag.d.ts +0 -1
- package/dist/util.cjs +8 -0
- package/dist/util.cjs.map +1 -0
- package/dist/util.d.ts +0 -1
- package/dist/util.js +6 -0
- package/dist/util.js.map +1 -0
- package/dist/value_or_error.cjs +8 -0
- package/dist/value_or_error.cjs.map +1 -0
- package/dist/value_or_error.d.ts +0 -1
- package/dist/value_or_error.js +6 -0
- package/dist/value_or_error.js.map +1 -0
- package/package.json +13 -11
- package/src/index.ts +10 -11
- package/dist/author_marker.d.ts.map +0 -1
- package/dist/base32_encode.d.ts.map +0 -1
- package/dist/block_state.d.ts.map +0 -1
- package/dist/bmodel/block_config.d.ts.map +0 -1
- package/dist/bmodel/code.d.ts.map +0 -1
- package/dist/bmodel/container.d.ts.map +0 -1
- package/dist/bmodel/index.d.ts.map +0 -1
- package/dist/bmodel/normalization.d.ts.map +0 -1
- package/dist/bmodel/types.d.ts.map +0 -1
- package/dist/branding.d.ts.map +0 -1
- package/dist/common_types.d.ts.map +0 -1
- package/dist/driver_kit.d.ts.map +0 -1
- package/dist/drivers/blob.d.ts.map +0 -1
- package/dist/drivers/index.d.ts.map +0 -1
- package/dist/drivers/interfaces.d.ts.map +0 -1
- package/dist/drivers/log.d.ts.map +0 -1
- package/dist/drivers/ls.d.ts.map +0 -1
- package/dist/drivers/pframe/column_filter.d.ts.map +0 -1
- package/dist/drivers/pframe/data_info.d.ts.map +0 -1
- package/dist/drivers/pframe/data_types.d.ts.map +0 -1
- package/dist/drivers/pframe/driver.d.ts.map +0 -1
- package/dist/drivers/pframe/find_columns.d.ts.map +0 -1
- package/dist/drivers/pframe/index.d.ts.map +0 -1
- package/dist/drivers/pframe/linker_columns.d.ts.map +0 -1
- package/dist/drivers/pframe/pframe.d.ts.map +0 -1
- package/dist/drivers/pframe/spec/anchored.d.ts.map +0 -1
- package/dist/drivers/pframe/spec/filtered_column.d.ts.map +0 -1
- package/dist/drivers/pframe/spec/ids.d.ts.map +0 -1
- package/dist/drivers/pframe/spec/index.d.ts.map +0 -1
- package/dist/drivers/pframe/spec/native_id.d.ts.map +0 -1
- package/dist/drivers/pframe/spec/selectors.d.ts.map +0 -1
- package/dist/drivers/pframe/spec/spec.d.ts.map +0 -1
- package/dist/drivers/pframe/table.d.ts.map +0 -1
- package/dist/drivers/pframe/table_calculate.d.ts.map +0 -1
- package/dist/drivers/pframe/table_common.d.ts.map +0 -1
- package/dist/drivers/pframe/type_util.d.ts.map +0 -1
- package/dist/drivers/pframe/unique_values.d.ts.map +0 -1
- package/dist/drivers/upload.d.ts.map +0 -1
- package/dist/drivers/urls.d.ts.map +0 -1
- package/dist/errors.d.ts.map +0 -1
- package/dist/flags/block_flags.d.ts.map +0 -1
- package/dist/flags/flag_utils.d.ts.map +0 -1
- package/dist/flags/index.d.ts.map +0 -1
- package/dist/flags/type_utils.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.mjs +0 -1587
- package/dist/index.mjs.map +0 -1
- package/dist/json.d.ts.map +0 -1
- package/dist/navigation.d.ts.map +0 -1
- package/dist/plid.d.ts.map +0 -1
- package/dist/pool/entry.d.ts.map +0 -1
- package/dist/pool/index.d.ts.map +0 -1
- package/dist/pool/query.d.ts.map +0 -1
- package/dist/pool/spec.d.ts.map +0 -1
- package/dist/ref.d.ts.map +0 -1
- package/dist/utag.d.ts.map +0 -1
- package/dist/util.d.ts.map +0 -1
- package/dist/value_or_error.d.ts.map +0 -1
package/dist/author_marker.d.ts
CHANGED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function toDataView(data) {
|
|
4
|
+
if (data instanceof Int8Array || data instanceof Uint8Array || data instanceof Uint8ClampedArray)
|
|
5
|
+
return new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
6
|
+
if (data instanceof ArrayBuffer)
|
|
7
|
+
return new DataView(data);
|
|
8
|
+
throw new TypeError('Expected `data` to be an ArrayBuffer, Buffer, Int8Array, Uint8Array or Uint8ClampedArray');
|
|
9
|
+
}
|
|
10
|
+
const RFC4648 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567';
|
|
11
|
+
const RFC4648_HEX = '0123456789ABCDEFGHIJKLMNOPQRSTUV';
|
|
12
|
+
const CROCKFORD = '0123456789ABCDEFGHJKMNPQRSTVWXYZ';
|
|
13
|
+
function base32Encode(data, variant, options) {
|
|
14
|
+
options = options || {};
|
|
15
|
+
let alphabet, defaultPadding;
|
|
16
|
+
switch (variant) {
|
|
17
|
+
case 'RFC3548':
|
|
18
|
+
case 'RFC4648':
|
|
19
|
+
alphabet = RFC4648;
|
|
20
|
+
defaultPadding = true;
|
|
21
|
+
break;
|
|
22
|
+
case 'RFC4648-HEX':
|
|
23
|
+
alphabet = RFC4648_HEX;
|
|
24
|
+
defaultPadding = true;
|
|
25
|
+
break;
|
|
26
|
+
case 'Crockford':
|
|
27
|
+
alphabet = CROCKFORD;
|
|
28
|
+
defaultPadding = false;
|
|
29
|
+
break;
|
|
30
|
+
default:
|
|
31
|
+
throw new Error('Unknown base32 variant: ' + String(variant));
|
|
32
|
+
}
|
|
33
|
+
const padding = options.padding !== undefined ? options.padding : defaultPadding;
|
|
34
|
+
const view = toDataView(data);
|
|
35
|
+
let bits = 0;
|
|
36
|
+
let value = 0;
|
|
37
|
+
let output = '';
|
|
38
|
+
for (let i = 0; i < view.byteLength; i++) {
|
|
39
|
+
value = (value << 8) | view.getUint8(i);
|
|
40
|
+
bits += 8;
|
|
41
|
+
while (bits >= 5) {
|
|
42
|
+
output += alphabet[(value >>> (bits - 5)) & 31];
|
|
43
|
+
bits -= 5;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
if (bits > 0)
|
|
47
|
+
output += alphabet[(value << (5 - bits)) & 31];
|
|
48
|
+
if (padding)
|
|
49
|
+
while (output.length % 8 !== 0) {
|
|
50
|
+
output += '=';
|
|
51
|
+
}
|
|
52
|
+
return output;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
exports.base32Encode = base32Encode;
|
|
56
|
+
//# sourceMappingURL=base32_encode.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base32_encode.cjs","sources":["../src/base32_encode.ts"],"sourcesContent":["type Data = Int8Array | Uint8Array | Uint8ClampedArray | ArrayBuffer;\n\nfunction toDataView(data: Data) {\n if (data instanceof Int8Array || data instanceof Uint8Array || data instanceof Uint8ClampedArray)\n return new DataView(data.buffer, data.byteOffset, data.byteLength);\n\n if (data instanceof ArrayBuffer) return new DataView(data);\n\n throw new TypeError(\n 'Expected `data` to be an ArrayBuffer, Buffer, Int8Array, Uint8Array or Uint8ClampedArray',\n );\n}\n\ninterface Options {\n /** If set, forcefully enable or disable padding. The default behavior is to follow the default of the selected variant. */\n padding?: boolean;\n}\n\nconst RFC4648 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567';\nconst RFC4648_HEX = '0123456789ABCDEFGHIJKLMNOPQRSTUV';\nconst CROCKFORD = '0123456789ABCDEFGHJKMNPQRSTVWXYZ';\n\nexport function base32Encode(\n data: Data,\n variant: 'RFC3548' | 'RFC4648' | 'RFC4648-HEX' | 'Crockford',\n options?: Options,\n) {\n options = options || {};\n let alphabet, defaultPadding;\n\n switch (variant) {\n case 'RFC3548':\n case 'RFC4648':\n alphabet = RFC4648;\n defaultPadding = true;\n break;\n case 'RFC4648-HEX':\n alphabet = RFC4648_HEX;\n defaultPadding = true;\n break;\n case 'Crockford':\n alphabet = CROCKFORD;\n defaultPadding = false;\n break;\n default:\n throw new Error('Unknown base32 variant: ' + String(variant));\n }\n\n const padding = options.padding !== undefined ? options.padding : defaultPadding;\n const view = toDataView(data);\n\n let bits = 0;\n let value = 0;\n let output = '';\n\n for (let i = 0; i < view.byteLength; i++) {\n value = (value << 8) | view.getUint8(i);\n bits += 8;\n\n while (bits >= 5) {\n output += alphabet[(value >>> (bits - 5)) & 31];\n bits -= 5;\n }\n }\n\n if (bits > 0) output += alphabet[(value << (5 - bits)) & 31];\n\n if (padding)\n while (output.length % 8 !== 0) {\n output += '=';\n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E;AAEf,IAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC,EAAE,EAAE;AACxC,QAAA,KAAK,GAAG,CAAC,KAAK,IAAI,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;QACvC,IAAI,IAAI,CAAC;AAET,QAAA,OAAO,IAAI,IAAI,CAAC,EAAE;AAChB,YAAA,MAAM,IAAI,QAAQ,CAAC,CAAC,KAAK,MAAM,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;YAC/C,IAAI,IAAI,CAAC;QACX;IACF;IAEA,IAAI,IAAI,GAAG,CAAC;AAAE,QAAA,MAAM,IAAI,QAAQ,CAAC,CAAC,KAAK,KAAK,CAAC,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;AAE5D,IAAA,IAAI,OAAO;QACT,OAAO,MAAM,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC,EAAE;YAC9B,MAAM,IAAI,GAAG;QACf;AAEF,IAAA,OAAO,MAAM;AACf;;;;"}
|
package/dist/base32_encode.d.ts
CHANGED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
function toDataView(data) {
|
|
2
|
+
if (data instanceof Int8Array || data instanceof Uint8Array || data instanceof Uint8ClampedArray)
|
|
3
|
+
return new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
4
|
+
if (data instanceof ArrayBuffer)
|
|
5
|
+
return new DataView(data);
|
|
6
|
+
throw new TypeError('Expected `data` to be an ArrayBuffer, Buffer, Int8Array, Uint8Array or Uint8ClampedArray');
|
|
7
|
+
}
|
|
8
|
+
const RFC4648 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567';
|
|
9
|
+
const RFC4648_HEX = '0123456789ABCDEFGHIJKLMNOPQRSTUV';
|
|
10
|
+
const CROCKFORD = '0123456789ABCDEFGHJKMNPQRSTVWXYZ';
|
|
11
|
+
function base32Encode(data, variant, options) {
|
|
12
|
+
options = options || {};
|
|
13
|
+
let alphabet, defaultPadding;
|
|
14
|
+
switch (variant) {
|
|
15
|
+
case 'RFC3548':
|
|
16
|
+
case 'RFC4648':
|
|
17
|
+
alphabet = RFC4648;
|
|
18
|
+
defaultPadding = true;
|
|
19
|
+
break;
|
|
20
|
+
case 'RFC4648-HEX':
|
|
21
|
+
alphabet = RFC4648_HEX;
|
|
22
|
+
defaultPadding = true;
|
|
23
|
+
break;
|
|
24
|
+
case 'Crockford':
|
|
25
|
+
alphabet = CROCKFORD;
|
|
26
|
+
defaultPadding = false;
|
|
27
|
+
break;
|
|
28
|
+
default:
|
|
29
|
+
throw new Error('Unknown base32 variant: ' + String(variant));
|
|
30
|
+
}
|
|
31
|
+
const padding = options.padding !== undefined ? options.padding : defaultPadding;
|
|
32
|
+
const view = toDataView(data);
|
|
33
|
+
let bits = 0;
|
|
34
|
+
let value = 0;
|
|
35
|
+
let output = '';
|
|
36
|
+
for (let i = 0; i < view.byteLength; i++) {
|
|
37
|
+
value = (value << 8) | view.getUint8(i);
|
|
38
|
+
bits += 8;
|
|
39
|
+
while (bits >= 5) {
|
|
40
|
+
output += alphabet[(value >>> (bits - 5)) & 31];
|
|
41
|
+
bits -= 5;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (bits > 0)
|
|
45
|
+
output += alphabet[(value << (5 - bits)) & 31];
|
|
46
|
+
if (padding)
|
|
47
|
+
while (output.length % 8 !== 0) {
|
|
48
|
+
output += '=';
|
|
49
|
+
}
|
|
50
|
+
return output;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export { base32Encode };
|
|
54
|
+
//# sourceMappingURL=base32_encode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base32_encode.js","sources":["../src/base32_encode.ts"],"sourcesContent":["type Data = Int8Array | Uint8Array | Uint8ClampedArray | ArrayBuffer;\n\nfunction toDataView(data: Data) {\n if (data instanceof Int8Array || data instanceof Uint8Array || data instanceof Uint8ClampedArray)\n return new DataView(data.buffer, data.byteOffset, data.byteLength);\n\n if (data instanceof ArrayBuffer) return new DataView(data);\n\n throw new TypeError(\n 'Expected `data` to be an ArrayBuffer, Buffer, Int8Array, Uint8Array or Uint8ClampedArray',\n );\n}\n\ninterface Options {\n /** If set, forcefully enable or disable padding. The default behavior is to follow the default of the selected variant. */\n padding?: boolean;\n}\n\nconst RFC4648 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567';\nconst RFC4648_HEX = '0123456789ABCDEFGHIJKLMNOPQRSTUV';\nconst CROCKFORD = '0123456789ABCDEFGHJKMNPQRSTVWXYZ';\n\nexport function base32Encode(\n data: Data,\n variant: 'RFC3548' | 'RFC4648' | 'RFC4648-HEX' | 'Crockford',\n options?: Options,\n) {\n options = options || {};\n let alphabet, defaultPadding;\n\n switch (variant) {\n case 'RFC3548':\n case 'RFC4648':\n alphabet = RFC4648;\n defaultPadding = true;\n break;\n case 'RFC4648-HEX':\n alphabet = RFC4648_HEX;\n defaultPadding = true;\n break;\n case 'Crockford':\n alphabet = CROCKFORD;\n defaultPadding = false;\n break;\n default:\n throw new Error('Unknown base32 variant: ' + String(variant));\n }\n\n const padding = options.padding !== undefined ? options.padding : defaultPadding;\n const view = toDataView(data);\n\n let bits = 0;\n let value = 0;\n let output = '';\n\n for (let i = 0; i < view.byteLength; i++) {\n value = (value << 8) | view.getUint8(i);\n bits += 8;\n\n while (bits >= 5) {\n output += alphabet[(value >>> (bits - 5)) & 31];\n bits -= 5;\n }\n }\n\n if (bits > 0) output += alphabet[(value << (5 - bits)) & 31];\n\n if (padding)\n while (output.length % 8 !== 0) {\n output += '=';\n }\n\n return output;\n}\n"],"names":[],"mappings":"AAEA,SAAS,UAAU,CAAC,IAAU,EAAA;IAC5B,IAAI,IAAI,YAAY,SAAS,IAAI,IAAI,YAAY,UAAU,IAAI,IAAI,YAAY,iBAAiB;AAC9F,QAAA,OAAO,IAAI,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,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;AAET,QAAA,OAAO,IAAI,IAAI,CAAC,EAAE;AAChB,YAAA,MAAM,IAAI,QAAQ,CAAC,CAAC,KAAK,MAAM,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;YAC/C,IAAI,IAAI,CAAC;QACX;IACF;IAEA,IAAI,IAAI,GAAG,CAAC;AAAE,QAAA,MAAM,IAAI,QAAQ,CAAC,CAAC,KAAK,KAAK,CAAC,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;AAE5D,IAAA,IAAI,OAAO;QACT,OAAO,MAAM,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC,EAAE;YAC9B,MAAM,IAAI,GAAG;QACf;AAEF,IAAA,OAAO,MAAM;AACf;;;;"}
|
package/dist/block_state.d.ts
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// TODO BroadActiveHandleDescriptor must be removed
|
|
4
|
+
function extractCodeWithInfo(cfg) {
|
|
5
|
+
if (cfg.code === undefined)
|
|
6
|
+
return undefined;
|
|
7
|
+
return {
|
|
8
|
+
code: cfg.code,
|
|
9
|
+
sdkVersion: cfg.sdkVersion,
|
|
10
|
+
featureFlags: cfg.featureFlags,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
exports.extractCodeWithInfo = extractCodeWithInfo;
|
|
15
|
+
//# sourceMappingURL=block_config.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"block_config.cjs","sources":["../../src/bmodel/block_config.ts"],"sourcesContent":["// TODO BroadActiveHandleDescriptor must be removed\n\nimport type { BlockCodeFeatureFlags } from '../flags';\nimport type { BlockCodeWithInfo, Code } from './code';\nimport type { BlockRenderingMode } from './types';\n\n/**\n * BroadActiveHandleDescriptor = TypedConfigOrConfigLambda,\n * NarrowActiveHandleDescriptor = ConfigRenderLambda\n */\nexport type BlockConfigV3Generic<\n Args = unknown,\n UiState = unknown,\n BroadActiveHandleDescriptor = unknown,\n NarrowActiveHandleDescriptor extends BroadActiveHandleDescriptor = BroadActiveHandleDescriptor,\n Outputs extends Record<string, BroadActiveHandleDescriptor> = Record<string, BroadActiveHandleDescriptor>,\n> = {\n /** SDK version used by the block */\n readonly sdkVersion: string;\n\n /** Main rendering mode for the block */\n readonly renderingMode: BlockRenderingMode;\n\n /** Initial value for the args when block is added to the project */\n readonly initialArgs: Args;\n\n /** Initial value for the args when block is added to the project */\n readonly initialUiState: UiState;\n\n /**\n * Config to determine whether the block can be executed with current\n * arguments.\n *\n * Optional to support earlier SDK version configs.\n * */\n readonly inputsValid: BroadActiveHandleDescriptor;\n\n /** Configuration to derive list of section for the left overview panel */\n readonly sections: BroadActiveHandleDescriptor;\n\n /** Lambda to derive block title */\n readonly title?: NarrowActiveHandleDescriptor;\n\n /**\n * Lambda returning list of upstream blocks this block enriches with its exports,\n * influences dependency graph construction\n * */\n readonly enrichmentTargets?: NarrowActiveHandleDescriptor;\n\n /** Configuration for the output cells */\n readonly outputs: Outputs;\n\n /** Config code bundle */\n readonly code?: Code;\n\n /** Feature flags for the block Model and UI code. */\n readonly featureFlags?: BlockCodeFeatureFlags;\n};\n\nexport type BlockConfigGeneric = BlockConfigV3Generic;\n\nexport function extractCodeWithInfo(cfg: BlockConfigV3Generic): BlockCodeWithInfo | undefined {\n if (cfg.code === undefined) return undefined;\n return {\n code: cfg.code,\n sdkVersion: cfg.sdkVersion,\n featureFlags: cfg.featureFlags,\n };\n}\n"],"names":[],"mappings":";;AAAA;AA6DM,SAAU,mBAAmB,CAAC,GAAyB,EAAA;AAC3D,IAAA,IAAI,GAAG,CAAC,IAAI,KAAK,SAAS;AAAE,QAAA,OAAO,SAAS;IAC5C,OAAO;QACL,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,UAAU,EAAE,GAAG,CAAC,UAAU;QAC1B,YAAY,EAAE,GAAG,CAAC,YAAY;KAC/B;AACH;;;;"}
|
|
@@ -39,4 +39,3 @@ export type BlockConfigV3Generic<Args = unknown, UiState = unknown, BroadActiveH
|
|
|
39
39
|
};
|
|
40
40
|
export type BlockConfigGeneric = BlockConfigV3Generic;
|
|
41
41
|
export declare function extractCodeWithInfo(cfg: BlockConfigV3Generic): BlockCodeWithInfo | undefined;
|
|
42
|
-
//# sourceMappingURL=block_config.d.ts.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// TODO BroadActiveHandleDescriptor must be removed
|
|
2
|
+
function extractCodeWithInfo(cfg) {
|
|
3
|
+
if (cfg.code === undefined)
|
|
4
|
+
return undefined;
|
|
5
|
+
return {
|
|
6
|
+
code: cfg.code,
|
|
7
|
+
sdkVersion: cfg.sdkVersion,
|
|
8
|
+
featureFlags: cfg.featureFlags,
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export { extractCodeWithInfo };
|
|
13
|
+
//# sourceMappingURL=block_config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"block_config.js","sources":["../../src/bmodel/block_config.ts"],"sourcesContent":["// TODO BroadActiveHandleDescriptor must be removed\n\nimport type { BlockCodeFeatureFlags } from '../flags';\nimport type { BlockCodeWithInfo, Code } from './code';\nimport type { BlockRenderingMode } from './types';\n\n/**\n * BroadActiveHandleDescriptor = TypedConfigOrConfigLambda,\n * NarrowActiveHandleDescriptor = ConfigRenderLambda\n */\nexport type BlockConfigV3Generic<\n Args = unknown,\n UiState = unknown,\n BroadActiveHandleDescriptor = unknown,\n NarrowActiveHandleDescriptor extends BroadActiveHandleDescriptor = BroadActiveHandleDescriptor,\n Outputs extends Record<string, BroadActiveHandleDescriptor> = Record<string, BroadActiveHandleDescriptor>,\n> = {\n /** SDK version used by the block */\n readonly sdkVersion: string;\n\n /** Main rendering mode for the block */\n readonly renderingMode: BlockRenderingMode;\n\n /** Initial value for the args when block is added to the project */\n readonly initialArgs: Args;\n\n /** Initial value for the args when block is added to the project */\n readonly initialUiState: UiState;\n\n /**\n * Config to determine whether the block can be executed with current\n * arguments.\n *\n * Optional to support earlier SDK version configs.\n * */\n readonly inputsValid: BroadActiveHandleDescriptor;\n\n /** Configuration to derive list of section for the left overview panel */\n readonly sections: BroadActiveHandleDescriptor;\n\n /** Lambda to derive block title */\n readonly title?: NarrowActiveHandleDescriptor;\n\n /**\n * Lambda returning list of upstream blocks this block enriches with its exports,\n * influences dependency graph construction\n * */\n readonly enrichmentTargets?: NarrowActiveHandleDescriptor;\n\n /** Configuration for the output cells */\n readonly outputs: Outputs;\n\n /** Config code bundle */\n readonly code?: Code;\n\n /** Feature flags for the block Model and UI code. */\n readonly featureFlags?: BlockCodeFeatureFlags;\n};\n\nexport type BlockConfigGeneric = BlockConfigV3Generic;\n\nexport function extractCodeWithInfo(cfg: BlockConfigV3Generic): BlockCodeWithInfo | undefined {\n if (cfg.code === undefined) return undefined;\n return {\n code: cfg.code,\n sdkVersion: cfg.sdkVersion,\n featureFlags: cfg.featureFlags,\n };\n}\n"],"names":[],"mappings":"AAAA;AA6DM,SAAU,mBAAmB,CAAC,GAAyB,EAAA;AAC3D,IAAA,IAAI,GAAG,CAAC,IAAI,KAAK,SAAS;AAAE,QAAA,OAAO,SAAS;IAC5C,OAAO;QACL,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,UAAU,EAAE,GAAG,CAAC,UAAU;QAC1B,YAAY,EAAE,GAAG,CAAC,YAAY;KAC/B;AACH;;;;"}
|
package/dist/bmodel/code.d.ts
CHANGED
package/dist/bmodel/index.d.ts
CHANGED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function upgradeCfgOrLambda(data) {
|
|
4
|
+
if (data === undefined)
|
|
5
|
+
return undefined;
|
|
6
|
+
if (typeof data === 'string')
|
|
7
|
+
return { __renderLambda: true, handle: data, retentive: false };
|
|
8
|
+
return data;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Takes universal config, and converts it into latest config structure.
|
|
12
|
+
*
|
|
13
|
+
* **Important**: This operation is not meant to be executed recusively.
|
|
14
|
+
* In no circumstance result of this function should be persisted!
|
|
15
|
+
* */
|
|
16
|
+
function extractConfigGeneric(cfg) {
|
|
17
|
+
if (cfg.v3 !== undefined) {
|
|
18
|
+
// version 3
|
|
19
|
+
const { initialArgs, initialUiState, inputsValid, outputs, renderingMode, sdkVersion, featureFlags, sections, title, enrichmentTargets, } = cfg.v3;
|
|
20
|
+
const { code } = cfg;
|
|
21
|
+
return {
|
|
22
|
+
initialArgs,
|
|
23
|
+
initialUiState,
|
|
24
|
+
inputsValid,
|
|
25
|
+
outputs,
|
|
26
|
+
renderingMode,
|
|
27
|
+
sdkVersion,
|
|
28
|
+
featureFlags,
|
|
29
|
+
sections,
|
|
30
|
+
title,
|
|
31
|
+
code,
|
|
32
|
+
enrichmentTargets,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
else if (cfg.inputsValid !== undefined) {
|
|
36
|
+
// version 2
|
|
37
|
+
const { sdkVersion, renderingMode, outputs, inputsValid, sections, initialArgs, code } = cfg;
|
|
38
|
+
const fields = Object.keys(cfg);
|
|
39
|
+
if (sdkVersion === undefined
|
|
40
|
+
|| renderingMode === undefined
|
|
41
|
+
|| outputs === undefined
|
|
42
|
+
|| inputsValid === undefined
|
|
43
|
+
|| sections === undefined
|
|
44
|
+
|| initialArgs === undefined)
|
|
45
|
+
throw new Error(`Malformed config v2. SDK version ${sdkVersion}; Fields = ${fields.join(', ')}`);
|
|
46
|
+
return {
|
|
47
|
+
sdkVersion,
|
|
48
|
+
renderingMode,
|
|
49
|
+
initialArgs,
|
|
50
|
+
outputs: Object.fromEntries(Object.entries(outputs).map(([key, value]) => [key, upgradeCfgOrLambda(value)])),
|
|
51
|
+
inputsValid: upgradeCfgOrLambda(inputsValid),
|
|
52
|
+
sections: upgradeCfgOrLambda(sections),
|
|
53
|
+
initialUiState: undefined,
|
|
54
|
+
code,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
else if (cfg.renderingMode !== undefined) {
|
|
58
|
+
// version 1
|
|
59
|
+
const { sdkVersion, canRun, renderingMode, outputs, sections, initialArgs, code } = cfg;
|
|
60
|
+
const fields = Object.keys(cfg);
|
|
61
|
+
if (renderingMode === undefined
|
|
62
|
+
|| outputs === undefined
|
|
63
|
+
|| canRun === undefined
|
|
64
|
+
|| sections === undefined
|
|
65
|
+
|| initialArgs === undefined)
|
|
66
|
+
throw new Error(`Malformed config v1. SDK version ${sdkVersion}; Fields = ${fields.join(', ')}`);
|
|
67
|
+
return {
|
|
68
|
+
sdkVersion: sdkVersion ?? 'unknown',
|
|
69
|
+
renderingMode,
|
|
70
|
+
initialArgs,
|
|
71
|
+
outputs: Object.fromEntries(Object.entries(outputs).map(([key, value]) => [key, upgradeCfgOrLambda(value)])),
|
|
72
|
+
inputsValid: upgradeCfgOrLambda(canRun),
|
|
73
|
+
sections: upgradeCfgOrLambda(sections),
|
|
74
|
+
initialUiState: undefined,
|
|
75
|
+
code,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
const { sdkVersion } = cfg;
|
|
80
|
+
const fields = Object.keys(cfg);
|
|
81
|
+
throw new Error(`Config format not supported: SDK = ${sdkVersion}; Fields = ${fields.join(', ')}`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
exports.extractConfigGeneric = extractConfigGeneric;
|
|
86
|
+
//# sourceMappingURL=normalization.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalization.cjs","sources":["../../src/bmodel/normalization.ts"],"sourcesContent":["import type { BlockConfigGeneric } from './block_config';\nimport type { BlockConfigContainer } from './container';\n\nfunction upgradeCfgOrLambda(data: any): any;\nfunction upgradeCfgOrLambda(\n data: any | undefined\n): any | undefined;\nfunction upgradeCfgOrLambda(\n data: any | undefined,\n): any | undefined {\n if (data === undefined) return undefined;\n if (typeof data === 'string') return { __renderLambda: true, handle: data, retentive: false };\n return data;\n}\n\n/**\n * Takes universal config, and converts it into latest config structure.\n *\n * **Important**: This operation is not meant to be executed recusively.\n * In no circumstance result of this function should be persisted!\n * */\nexport function extractConfigGeneric(cfg: BlockConfigContainer): BlockConfigGeneric {\n if (cfg.v3 !== undefined) {\n // version 3\n const {\n initialArgs,\n initialUiState,\n inputsValid,\n outputs,\n renderingMode,\n sdkVersion,\n featureFlags,\n sections,\n title,\n enrichmentTargets,\n } = cfg.v3;\n const { code } = cfg;\n return {\n initialArgs,\n initialUiState,\n inputsValid,\n outputs,\n renderingMode,\n sdkVersion,\n featureFlags,\n sections,\n title,\n code,\n enrichmentTargets,\n };\n } else if (cfg.inputsValid !== undefined) {\n // version 2\n const { sdkVersion, renderingMode, outputs, inputsValid, sections, initialArgs, code } = cfg;\n const fields = Object.keys(cfg);\n if (\n sdkVersion === undefined\n || renderingMode === undefined\n || outputs === undefined\n || inputsValid === undefined\n || sections === undefined\n || initialArgs === undefined\n )\n throw new Error(\n `Malformed config v2. SDK version ${sdkVersion}; Fields = ${fields.join(', ')}`,\n );\n return {\n sdkVersion,\n renderingMode,\n initialArgs,\n outputs: Object.fromEntries(\n Object.entries(outputs).map(([key, value]) => [key, upgradeCfgOrLambda(value)]),\n ),\n inputsValid: upgradeCfgOrLambda(inputsValid),\n sections: upgradeCfgOrLambda(sections),\n initialUiState: undefined,\n code,\n };\n } else if (cfg.renderingMode !== undefined) {\n // version 1\n const { sdkVersion, canRun, renderingMode, outputs, sections, initialArgs, code } = cfg;\n const fields = Object.keys(cfg);\n if (\n renderingMode === undefined\n || outputs === undefined\n || canRun === undefined\n || sections === undefined\n || initialArgs === undefined\n )\n throw new Error(\n `Malformed config v1. SDK version ${sdkVersion}; Fields = ${fields.join(', ')}`,\n );\n return {\n sdkVersion: sdkVersion ?? 'unknown',\n renderingMode,\n initialArgs,\n outputs: Object.fromEntries(\n Object.entries(outputs).map(([key, value]) => [key, upgradeCfgOrLambda(value)]),\n ),\n inputsValid: upgradeCfgOrLambda(canRun),\n sections: upgradeCfgOrLambda(sections),\n initialUiState: undefined,\n code,\n };\n } else {\n const { sdkVersion } = cfg;\n const fields = Object.keys(cfg);\n throw new Error(\n `Config format not supported: SDK = ${sdkVersion}; Fields = ${fields.join(', ')}`,\n );\n }\n}\n"],"names":[],"mappings":";;AAOA,SAAS,kBAAkB,CACzB,IAAqB,EAAA;IAErB,IAAI,IAAI,KAAK,SAAS;AAAE,QAAA,OAAO,SAAS;IACxC,IAAI,OAAO,IAAI,KAAK,QAAQ;AAAE,QAAA,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE;AAC7F,IAAA,OAAO,IAAI;AACb;AAEA;;;;;AAKK;AACC,SAAU,oBAAoB,CAAC,GAAyB,EAAA;AAC5D,IAAA,IAAI,GAAG,CAAC,EAAE,KAAK,SAAS,EAAE;;QAExB,MAAM,EACJ,WAAW,EACX,cAAc,EACd,WAAW,EACX,OAAO,EACP,aAAa,EACb,UAAU,EACV,YAAY,EACZ,QAAQ,EACR,KAAK,EACL,iBAAiB,GAClB,GAAG,GAAG,CAAC,EAAE;AACV,QAAA,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG;QACpB,OAAO;YACL,WAAW;YACX,cAAc;YACd,WAAW;YACX,OAAO;YACP,aAAa;YACb,UAAU;YACV,YAAY;YACZ,QAAQ;YACR,KAAK;YACL,IAAI;YACJ,iBAAiB;SAClB;IACH;AAAO,SAAA,IAAI,GAAG,CAAC,WAAW,KAAK,SAAS,EAAE;;AAExC,QAAA,MAAM,EAAE,UAAU,EAAE,aAAa,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,WAAW,EAAE,IAAI,EAAE,GAAG,GAAG;QAC5F,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;QAC/B,IACE,UAAU,KAAK;AACZ,eAAA,aAAa,KAAK;AAClB,eAAA,OAAO,KAAK;AACZ,eAAA,WAAW,KAAK;AACh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CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC,CAChF;AACD,YAAA,WAAW,EAAE,kBAAkB,CAAC,MAAM,CAAC;AACvC,YAAA,QAAQ,EAAE,kBAAkB,CAAC,QAAQ,CAAC;AACtC,YAAA,cAAc,EAAE,SAAS;YACzB,IAAI;SACL;IACH;SAAO;AACL,QAAA,MAAM,EAAE,UAAU,EAAE,GAAG,GAAG;QAC1B,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;AAC/B,QAAA,MAAM,IAAI,KAAK,CACb,CAAA,mCAAA,EAAsC,UAAU,CAAA,WAAA,EAAc,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA,CAAE,CAClF;IACH;AACF;;;;"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
function upgradeCfgOrLambda(data) {
|
|
2
|
+
if (data === undefined)
|
|
3
|
+
return undefined;
|
|
4
|
+
if (typeof data === 'string')
|
|
5
|
+
return { __renderLambda: true, handle: data, retentive: false };
|
|
6
|
+
return data;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Takes universal config, and converts it into latest config structure.
|
|
10
|
+
*
|
|
11
|
+
* **Important**: This operation is not meant to be executed recusively.
|
|
12
|
+
* In no circumstance result of this function should be persisted!
|
|
13
|
+
* */
|
|
14
|
+
function extractConfigGeneric(cfg) {
|
|
15
|
+
if (cfg.v3 !== undefined) {
|
|
16
|
+
// version 3
|
|
17
|
+
const { initialArgs, initialUiState, inputsValid, outputs, renderingMode, sdkVersion, featureFlags, sections, title, enrichmentTargets, } = cfg.v3;
|
|
18
|
+
const { code } = cfg;
|
|
19
|
+
return {
|
|
20
|
+
initialArgs,
|
|
21
|
+
initialUiState,
|
|
22
|
+
inputsValid,
|
|
23
|
+
outputs,
|
|
24
|
+
renderingMode,
|
|
25
|
+
sdkVersion,
|
|
26
|
+
featureFlags,
|
|
27
|
+
sections,
|
|
28
|
+
title,
|
|
29
|
+
code,
|
|
30
|
+
enrichmentTargets,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
else if (cfg.inputsValid !== undefined) {
|
|
34
|
+
// version 2
|
|
35
|
+
const { sdkVersion, renderingMode, outputs, inputsValid, sections, initialArgs, code } = cfg;
|
|
36
|
+
const fields = Object.keys(cfg);
|
|
37
|
+
if (sdkVersion === undefined
|
|
38
|
+
|| renderingMode === undefined
|
|
39
|
+
|| outputs === undefined
|
|
40
|
+
|| inputsValid === undefined
|
|
41
|
+
|| sections === undefined
|
|
42
|
+
|| initialArgs === undefined)
|
|
43
|
+
throw new Error(`Malformed config v2. SDK version ${sdkVersion}; Fields = ${fields.join(', ')}`);
|
|
44
|
+
return {
|
|
45
|
+
sdkVersion,
|
|
46
|
+
renderingMode,
|
|
47
|
+
initialArgs,
|
|
48
|
+
outputs: Object.fromEntries(Object.entries(outputs).map(([key, value]) => [key, upgradeCfgOrLambda(value)])),
|
|
49
|
+
inputsValid: upgradeCfgOrLambda(inputsValid),
|
|
50
|
+
sections: upgradeCfgOrLambda(sections),
|
|
51
|
+
initialUiState: undefined,
|
|
52
|
+
code,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
else if (cfg.renderingMode !== undefined) {
|
|
56
|
+
// version 1
|
|
57
|
+
const { sdkVersion, canRun, renderingMode, outputs, sections, initialArgs, code } = cfg;
|
|
58
|
+
const fields = Object.keys(cfg);
|
|
59
|
+
if (renderingMode === undefined
|
|
60
|
+
|| outputs === undefined
|
|
61
|
+
|| canRun === undefined
|
|
62
|
+
|| sections === undefined
|
|
63
|
+
|| initialArgs === undefined)
|
|
64
|
+
throw new Error(`Malformed config v1. SDK version ${sdkVersion}; Fields = ${fields.join(', ')}`);
|
|
65
|
+
return {
|
|
66
|
+
sdkVersion: sdkVersion ?? 'unknown',
|
|
67
|
+
renderingMode,
|
|
68
|
+
initialArgs,
|
|
69
|
+
outputs: Object.fromEntries(Object.entries(outputs).map(([key, value]) => [key, upgradeCfgOrLambda(value)])),
|
|
70
|
+
inputsValid: upgradeCfgOrLambda(canRun),
|
|
71
|
+
sections: upgradeCfgOrLambda(sections),
|
|
72
|
+
initialUiState: undefined,
|
|
73
|
+
code,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
const { sdkVersion } = cfg;
|
|
78
|
+
const fields = Object.keys(cfg);
|
|
79
|
+
throw new Error(`Config format not supported: SDK = ${sdkVersion}; Fields = ${fields.join(', ')}`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export { extractConfigGeneric };
|
|
84
|
+
//# sourceMappingURL=normalization.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalization.js","sources":["../../src/bmodel/normalization.ts"],"sourcesContent":["import type { BlockConfigGeneric } from './block_config';\nimport type { BlockConfigContainer } from './container';\n\nfunction upgradeCfgOrLambda(data: any): any;\nfunction upgradeCfgOrLambda(\n data: any | undefined\n): any | undefined;\nfunction upgradeCfgOrLambda(\n data: any | undefined,\n): any | undefined {\n if (data === undefined) return undefined;\n if (typeof data === 'string') return { __renderLambda: true, handle: data, retentive: false };\n return data;\n}\n\n/**\n * Takes universal config, and converts it into latest config structure.\n *\n * **Important**: This operation is not meant to be executed recusively.\n * In no circumstance result of this function should be persisted!\n * */\nexport function extractConfigGeneric(cfg: BlockConfigContainer): BlockConfigGeneric {\n if (cfg.v3 !== undefined) {\n // version 3\n const {\n initialArgs,\n initialUiState,\n inputsValid,\n outputs,\n renderingMode,\n sdkVersion,\n featureFlags,\n sections,\n title,\n enrichmentTargets,\n } = cfg.v3;\n const { code } = cfg;\n return {\n initialArgs,\n initialUiState,\n inputsValid,\n outputs,\n renderingMode,\n sdkVersion,\n featureFlags,\n sections,\n title,\n code,\n enrichmentTargets,\n };\n } else if (cfg.inputsValid !== undefined) {\n // version 2\n const { sdkVersion, renderingMode, outputs, inputsValid, sections, initialArgs, code } = cfg;\n const fields = Object.keys(cfg);\n if (\n sdkVersion === undefined\n || renderingMode === undefined\n || outputs === undefined\n || inputsValid === undefined\n || sections === undefined\n || initialArgs === undefined\n )\n throw new Error(\n `Malformed config v2. SDK version ${sdkVersion}; Fields = ${fields.join(', ')}`,\n );\n return {\n sdkVersion,\n renderingMode,\n initialArgs,\n outputs: Object.fromEntries(\n Object.entries(outputs).map(([key, value]) => [key, upgradeCfgOrLambda(value)]),\n ),\n inputsValid: upgradeCfgOrLambda(inputsValid),\n sections: upgradeCfgOrLambda(sections),\n initialUiState: undefined,\n code,\n };\n } else if (cfg.renderingMode !== undefined) {\n // version 1\n const { sdkVersion, canRun, renderingMode, outputs, sections, initialArgs, code } = cfg;\n const fields = Object.keys(cfg);\n if (\n renderingMode === undefined\n || outputs === undefined\n || canRun === undefined\n || sections === undefined\n || initialArgs === undefined\n )\n throw new Error(\n `Malformed config v1. SDK version ${sdkVersion}; Fields = ${fields.join(', ')}`,\n );\n return {\n sdkVersion: sdkVersion ?? 'unknown',\n renderingMode,\n initialArgs,\n outputs: Object.fromEntries(\n Object.entries(outputs).map(([key, value]) => [key, upgradeCfgOrLambda(value)]),\n ),\n inputsValid: upgradeCfgOrLambda(canRun),\n sections: upgradeCfgOrLambda(sections),\n initialUiState: undefined,\n code,\n };\n } else {\n const { sdkVersion } = cfg;\n const fields = Object.keys(cfg);\n throw new Error(\n `Config format not supported: SDK = ${sdkVersion}; Fields = ${fields.join(', ')}`,\n );\n }\n}\n"],"names":[],"mappings":"AAOA,SAAS,kBAAkB,CACzB,IAAqB,EAAA;IAErB,IAAI,IAAI,KAAK,SAAS;AAAE,QAAA,OAAO,SAAS;IACxC,IAAI,OAAO,IAAI,KAAK,QAAQ;AAAE,QAAA,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE;AAC7F,IAAA,OAAO,IAA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AAK,CACb,CAAA,mCAAA,EAAsC,UAAU,CAAA,WAAA,EAAc,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA,CAAE,CAClF;IACH;AACF;;;;"}
|
package/dist/bmodel/types.d.ts
CHANGED
package/dist/branding.d.ts
CHANGED
package/dist/common_types.d.ts
CHANGED
package/dist/driver_kit.d.ts
CHANGED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var zod = require('zod');
|
|
4
|
+
|
|
5
|
+
/** Range in bytes, from should be less or equal than to. */
|
|
6
|
+
const RangeBytes = zod.z.object({
|
|
7
|
+
/** Included left border. */
|
|
8
|
+
from: zod.z.number(),
|
|
9
|
+
/** Excluded right border. */
|
|
10
|
+
to: zod.z.number(),
|
|
11
|
+
});
|
|
12
|
+
function newRangeBytesOpt(from, to) {
|
|
13
|
+
if (from == undefined || to == undefined) {
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
return { from, to };
|
|
17
|
+
}
|
|
18
|
+
function validateRangeBytes(range, errMsg) {
|
|
19
|
+
if (range.from < 0 || range.to < 0 || range.from >= range.to) {
|
|
20
|
+
throw new Error(`${errMsg}: invalid bytes range: ${range}`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
exports.RangeBytes = RangeBytes;
|
|
25
|
+
exports.newRangeBytesOpt = newRangeBytesOpt;
|
|
26
|
+
exports.validateRangeBytes = validateRangeBytes;
|
|
27
|
+
//# sourceMappingURL=blob.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blob.cjs","sources":["../../src/drivers/blob.ts"],"sourcesContent":["import type { Branded } from '../branding';\nimport { z } from 'zod';\n\n/** Handle of locally downloaded blob. This handle is issued only after the\n * blob's content is downloaded locally, and ready for quick access. */\nexport type LocalBlobHandle = Branded<string, 'LocalBlobHandle'>;\n\n/** Handle of remote blob. This handle is issued as soon as the data becomes\n * available on the remote server. */\nexport type RemoteBlobHandle = Branded<string, 'RemoteBlobHandle'>;\n\n/** Being configured inside the output structure provides information about\n * blob's content and means to retrieve it when needed. */\nexport interface BlobHandleAndSize<\n H extends LocalBlobHandle | RemoteBlobHandle = | LocalBlobHandle\n | RemoteBlobHandle,\n> {\n /** Handle to retrieve block content using {@link BlobDriver.getContent()} */\n readonly handle: H;\n\n /** Blob size in bytes. */\n readonly size: number;\n}\n\n/** Range in bytes, from should be less or equal than to. */\nexport const RangeBytes = z.object({\n /** Included left border. */\n from: z.number(),\n /** Excluded right border. */\n to: z.number(),\n});\n\nexport type RangeBytes = z.infer<typeof RangeBytes>;\n\nexport function newRangeBytesOpt(from?: number, to?: number): RangeBytes | undefined {\n if (from == undefined || to == undefined) {\n return undefined;\n }\n\n return { from, to };\n}\n\nexport function validateRangeBytes(range: RangeBytes, errMsg: string) {\n if (range.from < 0 || range.to < 0 || range.from >= range.to) {\n throw new Error(`${errMsg}: invalid bytes range: ${range}`);\n }\n}\n\n/** Being configured inside the output structure provides information about\n * locally downloaded blob and means to retrieve it's content when needed. This\n * structure is created only after the blob's content is downloaded locally, and\n * ready for quick access. */\nexport type LocalBlobHandleAndSize = BlobHandleAndSize<LocalBlobHandle>;\n\n/** Being configured inside the output structure provides information about\n * remote blob and means to retrieve it's content when needed. This structure\n * is created as soon as remote blob becomes available. */\nexport type RemoteBlobHandleAndSize = BlobHandleAndSize<RemoteBlobHandle>;\n\n/** Defines API of blob driver as it is seen from the block UI code. */\nexport interface BlobDriver {\n /** Given the blob handle returns its content. Depending on the handle type,\n * content will be served from locally downloaded file, or directly from\n * remote platforma storage. */\n getContent(handle: LocalBlobHandle | RemoteBlobHandle, range?: RangeBytes): Promise<Uint8Array>;\n}\n"],"names":["z"],"mappings":";;;;AAwBA;AACO,MAAM,UAAU,GAAGA,KAAC,CAAC,MAAM,CAAC;;AAEjC,IAAA,IAAI,EAAEA,KAAC,CAAC,MAAM,EAAE;;AAEhB,IAAA,EAAE,EAAEA,KAAC,CAAC,MAAM,EAAE;AACf,CAAA;AAIK,SAAU,gBAAgB,CAAC,IAAa,EAAE,EAAW,EAAA;IACzD,IAAI,IAAI,IAAI,SAAS,IAAI,EAAE,IAAI,SAAS,EAAE;AACxC,QAAA,OAAO,SAAS;IAClB;AAEA,IAAA,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE;AACrB;AAEM,SAAU,kBAAkB,CAAC,KAAiB,EAAE,MAAc,EAAA;IAClE,IAAI,KAAK,CAAC,IAAI,GAAG,CAAC,IAAI,KAAK,CAAC,EAAE,GAAG,CAAC,IAAI,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,EAAE,EAAE;QAC5D,MAAM,IAAI,KAAK,CAAC,CAAA,EAAG,MAAM,CAAA,uBAAA,EAA0B,KAAK,CAAA,CAAE,CAAC;IAC7D;AACF;;;;;;"}
|
package/dist/drivers/blob.d.ts
CHANGED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
/** Range in bytes, from should be less or equal than to. */
|
|
4
|
+
const RangeBytes = z.object({
|
|
5
|
+
/** Included left border. */
|
|
6
|
+
from: z.number(),
|
|
7
|
+
/** Excluded right border. */
|
|
8
|
+
to: z.number(),
|
|
9
|
+
});
|
|
10
|
+
function newRangeBytesOpt(from, to) {
|
|
11
|
+
if (from == undefined || to == undefined) {
|
|
12
|
+
return undefined;
|
|
13
|
+
}
|
|
14
|
+
return { from, to };
|
|
15
|
+
}
|
|
16
|
+
function validateRangeBytes(range, errMsg) {
|
|
17
|
+
if (range.from < 0 || range.to < 0 || range.from >= range.to) {
|
|
18
|
+
throw new Error(`${errMsg}: invalid bytes range: ${range}`);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export { RangeBytes, newRangeBytesOpt, validateRangeBytes };
|
|
23
|
+
//# sourceMappingURL=blob.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blob.js","sources":["../../src/drivers/blob.ts"],"sourcesContent":["import type { Branded } from '../branding';\nimport { z } from 'zod';\n\n/** Handle of locally downloaded blob. This handle is issued only after the\n * blob's content is downloaded locally, and ready for quick access. */\nexport type LocalBlobHandle = Branded<string, 'LocalBlobHandle'>;\n\n/** Handle of remote blob. This handle is issued as soon as the data becomes\n * available on the remote server. */\nexport type RemoteBlobHandle = Branded<string, 'RemoteBlobHandle'>;\n\n/** Being configured inside the output structure provides information about\n * blob's content and means to retrieve it when needed. */\nexport interface BlobHandleAndSize<\n H extends LocalBlobHandle | RemoteBlobHandle = | LocalBlobHandle\n | RemoteBlobHandle,\n> {\n /** Handle to retrieve block content using {@link BlobDriver.getContent()} */\n readonly handle: H;\n\n /** Blob size in bytes. */\n readonly size: number;\n}\n\n/** Range in bytes, from should be less or equal than to. */\nexport const RangeBytes = z.object({\n /** Included left border. */\n from: z.number(),\n /** Excluded right border. */\n to: z.number(),\n});\n\nexport type RangeBytes = z.infer<typeof RangeBytes>;\n\nexport function newRangeBytesOpt(from?: number, to?: number): RangeBytes | undefined {\n if (from == undefined || to == undefined) {\n return undefined;\n }\n\n return { from, to };\n}\n\nexport function validateRangeBytes(range: RangeBytes, errMsg: string) {\n if (range.from < 0 || range.to < 0 || range.from >= range.to) {\n throw new Error(`${errMsg}: invalid bytes range: ${range}`);\n }\n}\n\n/** Being configured inside the output structure provides information about\n * locally downloaded blob and means to retrieve it's content when needed. This\n * structure is created only after the blob's content is downloaded locally, and\n * ready for quick access. */\nexport type LocalBlobHandleAndSize = BlobHandleAndSize<LocalBlobHandle>;\n\n/** Being configured inside the output structure provides information about\n * remote blob and means to retrieve it's content when needed. This structure\n * is created as soon as remote blob becomes available. */\nexport type RemoteBlobHandleAndSize = BlobHandleAndSize<RemoteBlobHandle>;\n\n/** Defines API of blob driver as it is seen from the block UI code. */\nexport interface BlobDriver {\n /** Given the blob handle returns its content. Depending on the handle type,\n * content will be served from locally downloaded file, or directly from\n * remote platforma storage. */\n getContent(handle: LocalBlobHandle | RemoteBlobHandle, range?: RangeBytes): Promise<Uint8Array>;\n}\n"],"names":[],"mappings":";;AAwBA;AACO,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,CAAC;;AAEjC,IAAA,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;;AAEhB,IAAA,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE;AACf,CAAA;AAIK,SAAU,gBAAgB,CAAC,IAAa,EAAE,EAAW,EAAA;IACzD,IAAI,IAAI,IAAI,SAAS,IAAI,EAAE,IAAI,SAAS,EAAE;AACxC,QAAA,OAAO,SAAS;IAClB;AAEA,IAAA,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE;AACrB;AAEM,SAAU,kBAAkB,CAAC,KAAiB,EAAE,MAAc,EAAA;IAClE,IAAI,KAAK,CAAC,IAAI,GAAG,CAAC,IAAI,KAAK,CAAC,EAAE,GAAG,CAAC,IAAI,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,EAAE,EAAE;QAC5D,MAAM,IAAI,KAAK,CAAC,CAAA,EAAG,MAAM,CAAA,uBAAA,EAA0B,KAAK,CAAA,CAAE,CAAC;IAC7D;AACF;;;;"}
|
package/dist/drivers/index.d.ts
CHANGED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/** Type guard to check if log is live, and corresponding porcess is not finished. */
|
|
4
|
+
function isLiveLog(handle) {
|
|
5
|
+
return handle !== undefined && handle.startsWith('log+live://log/');
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
exports.isLiveLog = isLiveLog;
|
|
9
|
+
//# sourceMappingURL=log.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log.cjs","sources":["../../src/drivers/log.ts"],"sourcesContent":["/** Handle of logs. This handle should be passed\n * to the driver for retrieving logs. */\nexport type AnyLogHandle = LiveLogHandle | ReadyLogHandle;\n\n/** Handle of the live logs of a program.\n * The resource that represents a log can be deleted,\n * in this case the handle should be refreshed. */\nexport type LiveLogHandle = `log+live://log/${string}`;\n\n/** Handle of the ready logs of a program. */\nexport type ReadyLogHandle = `log+ready://log/${string}`;\n\n/** Type guard to check if log is live, and corresponding porcess is not finished. */\nexport function isLiveLog(handle: AnyLogHandle | undefined): handle is LiveLogHandle {\n return handle !== undefined && handle.startsWith('log+live://log/');\n}\n\n/** Driver to retrieve logs given log handle */\nexport interface LogsDriver {\n lastLines(\n /** A handle that was issued previously. */\n handle: AnyLogHandle,\n\n /** Allows client to limit total data sent from server. */\n lineCount: number,\n\n /** Makes streamer to perform seek operation to given offset before sending the contents.\n * Client can just use the <new_offset> value of the last response from server to continue streaming after reconnection.\n * If undefined, then starts from the end. */\n offsetBytes?: number,\n\n /** Is substring for line search pattern.\n * This option makes controller to send to the client only lines, that\n * have given substring. */\n searchStr?: string\n ): Promise<StreamingApiResponse>;\n\n readText(\n /** A handle that was issued previously. */\n handle: AnyLogHandle,\n\n /** Allows client to limit total data sent from server. */\n lineCount: number,\n\n /** Makes streamer to perform seek operation to given offset before sending the contents.\n * Client can just use the <new_offset> value of the last response from server to continue streaming after reconnection.\n * If undefined of 0, then starts from the beginning. */\n offsetBytes?: number,\n\n /** Is substring for line search pattern.\n * This option makes controller to send to the client only lines, that\n * have given substring. */\n searchStr?: string\n ): Promise<StreamingApiResponse>;\n}\n\n/** Response of the driver.\n * The caller should give a handle to retrieve it.\n * It can be OK or outdated, in which case the handle\n * should be issued again. */\nexport type StreamingApiResponse = StreamingApiResponseOk | StreamingApiResponseHandleOutdated;\n\nexport type StreamingApiResponseOk = {\n /** The handle don't have to be updated,\n * the response is OK. */\n shouldUpdateHandle: false;\n\n /** Whether the log can still grow or it's in a final state. */\n live: boolean;\n\n /** Data of the response, in bytes. */\n data: Uint8Array;\n /** Current size of the file. It can grow if it's still live. */\n size: number;\n /** Offset in bytes from the beginning of a file. */\n newOffset: number;\n};\n\n/** The handle should be issued again, this one is done. */\nexport type StreamingApiResponseHandleOutdated = {\n shouldUpdateHandle: true;\n};\n\nexport type ProgressLogWithInfo = {\n progressLine?: string;\n live: boolean;\n};\n"],"names":[],"mappings":";;AAYA;AACM,SAAU,SAAS,CAAC,MAAgC,EAAA;IACxD,OAAO,MAAM,KAAK,SAAS,IAAI,MAAM,CAAC,UAAU,CAAC,iBAAiB,CAAC;AACrE;;;;"}
|
package/dist/drivers/log.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log.js","sources":["../../src/drivers/log.ts"],"sourcesContent":["/** Handle of logs. This handle should be passed\n * to the driver for retrieving logs. */\nexport type AnyLogHandle = LiveLogHandle | ReadyLogHandle;\n\n/** Handle of the live logs of a program.\n * The resource that represents a log can be deleted,\n * in this case the handle should be refreshed. */\nexport type LiveLogHandle = `log+live://log/${string}`;\n\n/** Handle of the ready logs of a program. */\nexport type ReadyLogHandle = `log+ready://log/${string}`;\n\n/** Type guard to check if log is live, and corresponding porcess is not finished. */\nexport function isLiveLog(handle: AnyLogHandle | undefined): handle is LiveLogHandle {\n return handle !== undefined && handle.startsWith('log+live://log/');\n}\n\n/** Driver to retrieve logs given log handle */\nexport interface LogsDriver {\n lastLines(\n /** A handle that was issued previously. */\n handle: AnyLogHandle,\n\n /** Allows client to limit total data sent from server. */\n lineCount: number,\n\n /** Makes streamer to perform seek operation to given offset before sending the contents.\n * Client can just use the <new_offset> value of the last response from server to continue streaming after reconnection.\n * If undefined, then starts from the end. */\n offsetBytes?: number,\n\n /** Is substring for line search pattern.\n * This option makes controller to send to the client only lines, that\n * have given substring. */\n searchStr?: string\n ): Promise<StreamingApiResponse>;\n\n readText(\n /** A handle that was issued previously. */\n handle: AnyLogHandle,\n\n /** Allows client to limit total data sent from server. */\n lineCount: number,\n\n /** Makes streamer to perform seek operation to given offset before sending the contents.\n * Client can just use the <new_offset> value of the last response from server to continue streaming after reconnection.\n * If undefined of 0, then starts from the beginning. */\n offsetBytes?: number,\n\n /** Is substring for line search pattern.\n * This option makes controller to send to the client only lines, that\n * have given substring. */\n searchStr?: string\n ): Promise<StreamingApiResponse>;\n}\n\n/** Response of the driver.\n * The caller should give a handle to retrieve it.\n * It can be OK or outdated, in which case the handle\n * should be issued again. */\nexport type StreamingApiResponse = StreamingApiResponseOk | StreamingApiResponseHandleOutdated;\n\nexport type StreamingApiResponseOk = {\n /** The handle don't have to be updated,\n * the response is OK. */\n shouldUpdateHandle: false;\n\n /** Whether the log can still grow or it's in a final state. */\n live: boolean;\n\n /** Data of the response, in bytes. */\n data: Uint8Array;\n /** Current size of the file. It can grow if it's still live. */\n size: number;\n /** Offset in bytes from the beginning of a file. */\n newOffset: number;\n};\n\n/** The handle should be issued again, this one is done. */\nexport type StreamingApiResponseHandleOutdated = {\n shouldUpdateHandle: true;\n};\n\nexport type ProgressLogWithInfo = {\n progressLine?: string;\n live: boolean;\n};\n"],"names":[],"mappings":"AAYA;AACM,SAAU,SAAS,CAAC,MAAgC,EAAA;IACxD,OAAO,MAAM,KAAK,SAAS,IAAI,MAAM,CAAC,UAAU,CAAC,iBAAiB,CAAC;AACrE;;;;"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var util = require('../util.cjs');
|
|
4
|
+
|
|
5
|
+
const uploadPrefix = 'upload://upload/';
|
|
6
|
+
const indexPrefix = 'index://index/';
|
|
7
|
+
function isImportFileHandleUpload(handle) {
|
|
8
|
+
return handle.startsWith(uploadPrefix);
|
|
9
|
+
}
|
|
10
|
+
function isImportFileHandleIndex(handle) {
|
|
11
|
+
return handle.startsWith(indexPrefix);
|
|
12
|
+
}
|
|
13
|
+
/** Gets a file path from an import handle. */
|
|
14
|
+
function getFilePathFromHandle(handle) {
|
|
15
|
+
if (isImportFileHandleIndex(handle)) {
|
|
16
|
+
const trimmed = handle.slice(indexPrefix.length);
|
|
17
|
+
const data = JSON.parse(decodeURIComponent(trimmed));
|
|
18
|
+
return data.path;
|
|
19
|
+
}
|
|
20
|
+
else if (isImportFileHandleUpload(handle)) {
|
|
21
|
+
const trimmed = handle.slice(uploadPrefix.length);
|
|
22
|
+
const data = JSON.parse(decodeURIComponent(trimmed));
|
|
23
|
+
return data.localPath;
|
|
24
|
+
}
|
|
25
|
+
util.assertNever(handle);
|
|
26
|
+
}
|
|
27
|
+
function extractFileName(filePath) {
|
|
28
|
+
return filePath.replace(/^.*[\\/]/, '');
|
|
29
|
+
}
|
|
30
|
+
/** Gets a file name from an import handle. */
|
|
31
|
+
function getFileNameFromHandle(handle) {
|
|
32
|
+
return extractFileName(getFilePathFromHandle(handle));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
exports.getFileNameFromHandle = getFileNameFromHandle;
|
|
36
|
+
exports.getFilePathFromHandle = getFilePathFromHandle;
|
|
37
|
+
exports.isImportFileHandleIndex = isImportFileHandleIndex;
|
|
38
|
+
exports.isImportFileHandleUpload = isImportFileHandleUpload;
|
|
39
|
+
//# sourceMappingURL=ls.cjs.map
|