@abyss-project/main 34.1.2 → 34.3.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/billing-metric-label/billing-metric-label.labels.d.ts +10 -0
- package/dist/billing-metric-label/billing-metric-label.labels.js +10 -0
- package/dist/billing-metric-label/billing-metric-label.labels.js.map +1 -1
- package/dist/constants/billing-catalog.constants.js +23 -0
- package/dist/constants/billing-catalog.constants.js.map +1 -1
- package/dist/constants/catalog-plan-quotas.constants.js +11 -0
- package/dist/constants/catalog-plan-quotas.constants.js.map +1 -1
- package/dist/constants/enforcement-registry.constants.js +28 -0
- package/dist/constants/enforcement-registry.constants.js.map +1 -1
- package/dist/constants/public-plans.constants.js +126 -0
- package/dist/constants/public-plans.constants.js.map +1 -1
- package/dist/constants/quota-metric-kind.constants.js +7 -0
- package/dist/constants/quota-metric-kind.constants.js.map +1 -1
- package/dist/constants/tests/billing-catalog.constants.spec.js +75 -0
- package/dist/constants/tests/billing-catalog.constants.spec.js.map +1 -1
- package/dist/server/archive/archive-seal.util.d.ts +7 -0
- package/dist/server/archive/archive-seal.util.js +75 -0
- package/dist/server/archive/archive-seal.util.js.map +1 -0
- package/dist/server/archive/archive-stream.service.d.ts +31 -0
- package/dist/server/archive/archive-stream.service.js +259 -0
- package/dist/server/archive/archive-stream.service.js.map +1 -0
- package/dist/server/archive/archive-upload-session.d.ts +5 -0
- package/dist/server/archive/archive-upload-session.js +3 -0
- package/dist/server/archive/archive-upload-session.js.map +1 -0
- package/dist/server/archive/index.d.ts +4 -0
- package/dist/server/archive/index.js +21 -0
- package/dist/server/archive/index.js.map +1 -0
- package/dist/server/archive/tests/archive-fixture.spec.d.ts +1 -0
- package/dist/server/archive/tests/archive-fixture.spec.js +84 -0
- package/dist/server/archive/tests/archive-fixture.spec.js.map +1 -0
- package/dist/server/archive/tests/archive-seal.util.spec.d.ts +1 -0
- package/dist/server/archive/tests/archive-seal.util.spec.js +98 -0
- package/dist/server/archive/tests/archive-seal.util.spec.js.map +1 -0
- package/dist/server/archive/tests/archive-stream.service.spec.d.ts +1 -0
- package/dist/server/archive/tests/archive-stream.service.spec.js +309 -0
- package/dist/server/archive/tests/archive-stream.service.spec.js.map +1 -0
- package/dist/server/archive/zstd.util.d.ts +19 -0
- package/dist/server/archive/zstd.util.js +43 -0
- package/dist/server/archive/zstd.util.js.map +1 -0
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +1 -0
- package/dist/server/index.js.map +1 -1
- package/dist/translate/en.translate.d.ts +4 -0
- package/dist/translate/en.translate.js +4 -0
- package/dist/translate/en.translate.js.map +1 -1
- package/dist/translate/fr.translate.d.ts +4 -0
- package/dist/translate/fr.translate.js +4 -0
- package/dist/translate/fr.translate.js.map +1 -1
- package/dist/translate/tests/flow-rehydration-ready.spec.d.ts +1 -0
- package/dist/translate/tests/flow-rehydration-ready.spec.js +18 -0
- package/dist/translate/tests/flow-rehydration-ready.spec.js.map +1 -0
- package/dist/types/enum/organization-billing.enum.d.ts +5 -0
- package/dist/types/enum/organization-billing.enum.js +5 -0
- package/dist/types/enum/organization-billing.enum.js.map +1 -1
- package/dist/types/enum/user-notification-category.enum.js +1 -0
- package/dist/types/enum/user-notification-category.enum.js.map +1 -1
- package/dist/types/enum/user-notification-content-type.enum.d.ts +9 -0
- package/dist/types/enum/user-notification-content-type.enum.js +2 -1
- package/dist/types/enum/user-notification-content-type.enum.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./archive-seal.util"), exports);
|
|
18
|
+
__exportStar(require("./archive-stream.service"), exports);
|
|
19
|
+
__exportStar(require("./archive-upload-session"), exports);
|
|
20
|
+
__exportStar(require("./zstd.util"), exports);
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/server/archive/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sDAAoC;AACpC,2DAAyC;AACzC,2DAAyC;AACzC,8CAA4B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
const crypto = __importStar(require("crypto"));
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
const stream_1 = require("stream");
|
|
40
|
+
const archive_seal_util_1 = require("../archive-seal.util");
|
|
41
|
+
const archive_stream_service_1 = require("../archive-stream.service");
|
|
42
|
+
const FIXTURES = path.join(__dirname, 'fixtures');
|
|
43
|
+
const object = fs.readFileSync(path.join(FIXTURES, 'archive-object.bin'));
|
|
44
|
+
const expected = JSON.parse(fs.readFileSync(path.join(FIXTURES, 'archive-object.expected.json'), 'utf8'));
|
|
45
|
+
const key = Buffer.from(expected.keyHex, 'hex');
|
|
46
|
+
const decodeAll = async (source) => {
|
|
47
|
+
const rows = [];
|
|
48
|
+
for await (const { part, sealed } of (0, archive_stream_service_1.splitArchiveFrames)(source, expected.parts)) {
|
|
49
|
+
const decoded = [];
|
|
50
|
+
for await (const row of (0, archive_stream_service_1.decodeArchiveFrame)(sealed, key)) {
|
|
51
|
+
decoded.push(row);
|
|
52
|
+
}
|
|
53
|
+
expect(decoded).toHaveLength(part.rowCount);
|
|
54
|
+
expect(decoded[0].dateValue).toBe(part.firstTimestamp);
|
|
55
|
+
rows.push(...decoded);
|
|
56
|
+
}
|
|
57
|
+
return rows;
|
|
58
|
+
};
|
|
59
|
+
describe('archive object written by Monitor before the move', () => {
|
|
60
|
+
it('has the shape the fixture claims', () => {
|
|
61
|
+
expect(expected.parts.length).toBeGreaterThanOrEqual(2);
|
|
62
|
+
expect(object.length).toBe(expected.totalBytes);
|
|
63
|
+
expect(expected.parts.reduce((total, part) => total + part.bytes, 0)).toBe(object.length);
|
|
64
|
+
});
|
|
65
|
+
it('has the sha256 the writer recorded', () => {
|
|
66
|
+
expect(crypto.createHash('sha256').update(object).digest('hex')).toBe(expected.sha256);
|
|
67
|
+
});
|
|
68
|
+
it('unwraps the stored organization key with the master key', () => {
|
|
69
|
+
expect((0, archive_seal_util_1.unwrapKey)(expected.wrappedKey, Buffer.from(expected.masterKey, 'hex')).toString('hex')).toBe(expected.keyHex);
|
|
70
|
+
});
|
|
71
|
+
it('reads back to the exact rows, part by part', async () => {
|
|
72
|
+
const rows = await decodeAll(stream_1.Readable.from([object]));
|
|
73
|
+
expect(rows).toEqual(expected.rows);
|
|
74
|
+
expect(rows).toHaveLength(expected.totalRows);
|
|
75
|
+
});
|
|
76
|
+
it('is read the same when the stream arrives in arbitrary chunks', async () => {
|
|
77
|
+
const chunks = [];
|
|
78
|
+
for (let offset = 0; offset < object.length; offset += 97) {
|
|
79
|
+
chunks.push(object.subarray(offset, offset + 97));
|
|
80
|
+
}
|
|
81
|
+
expect(await decodeAll(stream_1.Readable.from(chunks))).toEqual(expected.rows);
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
//# sourceMappingURL=archive-fixture.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"archive-fixture.spec.js","sourceRoot":"","sources":["../../../../src/server/archive/tests/arch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AAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QAEtD,MAAM,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACpC,MAAM,CAAC,IAAI,CAAC,CAAC,YAAY,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;IAChD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,8DAA8D,EAAE,KAAK,IAAI,EAAE;QAC5E,MAAM,MAAM,GAAa,EAAE,CAAC;QAC5B,KAAK,IAAI,MAAM,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,IAAI,EAAE,EAAE,CAAC;YAC1D,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,EAAE,CAAC,CAAC,CAAC;QACpD,CAAC;QAED,MAAM,CAAC,MAAM,SAAS,CAAC,iBAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IACxE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
const crypto = __importStar(require("crypto"));
|
|
37
|
+
const archive_seal_util_1 = require("../archive-seal.util");
|
|
38
|
+
describe('seal / unseal', () => {
|
|
39
|
+
it('round-trips', () => {
|
|
40
|
+
const key = crypto.randomBytes(32);
|
|
41
|
+
const plaintext = Buffer.from('a log line with an Authorization header in it');
|
|
42
|
+
expect((0, archive_seal_util_1.unseal)((0, archive_seal_util_1.seal)(plaintext, key), key)).toEqual(plaintext);
|
|
43
|
+
});
|
|
44
|
+
it('produces an exact frame length: iv (12 o) + authTag (16 o) + ciphertext', () => {
|
|
45
|
+
const key = crypto.randomBytes(32);
|
|
46
|
+
const plaintext = crypto.randomBytes(1024 * 1024);
|
|
47
|
+
const sealed = (0, archive_seal_util_1.seal)(plaintext, key);
|
|
48
|
+
expect(sealed.length).toBe(12 + 16 + plaintext.length);
|
|
49
|
+
expect((0, archive_seal_util_1.unseal)(sealed, key)).toEqual(plaintext);
|
|
50
|
+
});
|
|
51
|
+
it('produces a different payload every time, so identical inputs do not look identical', () => {
|
|
52
|
+
const key = crypto.randomBytes(32);
|
|
53
|
+
const plaintext = Buffer.from('same input');
|
|
54
|
+
expect((0, archive_seal_util_1.seal)(plaintext, key)).not.toEqual((0, archive_seal_util_1.seal)(plaintext, key));
|
|
55
|
+
});
|
|
56
|
+
it('refuses a tampered payload instead of returning garbage', () => {
|
|
57
|
+
const key = crypto.randomBytes(32);
|
|
58
|
+
const sealed = (0, archive_seal_util_1.seal)(Buffer.from('trustworthy'), key);
|
|
59
|
+
const tampered = Buffer.from(sealed);
|
|
60
|
+
tampered[tampered.length - 1] ^= 0xff;
|
|
61
|
+
expect(() => (0, archive_seal_util_1.unseal)(tampered, key)).toThrow();
|
|
62
|
+
});
|
|
63
|
+
it('refuses the wrong key', () => {
|
|
64
|
+
const sealed = (0, archive_seal_util_1.seal)(Buffer.from('secret'), crypto.randomBytes(32));
|
|
65
|
+
expect(() => (0, archive_seal_util_1.unseal)(sealed, crypto.randomBytes(32))).toThrow();
|
|
66
|
+
});
|
|
67
|
+
it('refuses a payload shorter than its iv and tag', () => {
|
|
68
|
+
expect(() => (0, archive_seal_util_1.unseal)(Buffer.alloc(27), crypto.randomBytes(32))).toThrow('Malformed sealed payload');
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
describe('organization key wrapping', () => {
|
|
72
|
+
it('generates 32-byte keys, different every time', () => {
|
|
73
|
+
const a = (0, archive_seal_util_1.generateArchiveKey)();
|
|
74
|
+
expect(a.length).toBe(32);
|
|
75
|
+
expect((0, archive_seal_util_1.generateArchiveKey)()).not.toEqual(a);
|
|
76
|
+
});
|
|
77
|
+
it('wraps to base64 and unwraps to the same key, without storing it in the clear', () => {
|
|
78
|
+
const master = crypto.randomBytes(32);
|
|
79
|
+
const key = (0, archive_seal_util_1.generateArchiveKey)();
|
|
80
|
+
const wrapped = (0, archive_seal_util_1.wrapKey)(key, master);
|
|
81
|
+
const raw = Buffer.from(wrapped, 'base64');
|
|
82
|
+
expect((0, archive_seal_util_1.unwrapKey)(wrapped, master)).toEqual(key);
|
|
83
|
+
expect(raw.includes(key)).toBe(false);
|
|
84
|
+
expect(raw.length).toBe(12 + 16 + key.length);
|
|
85
|
+
});
|
|
86
|
+
it('does not unwrap with another master key', () => {
|
|
87
|
+
const wrapped = (0, archive_seal_util_1.wrapKey)((0, archive_seal_util_1.generateArchiveKey)(), crypto.randomBytes(32));
|
|
88
|
+
expect(() => (0, archive_seal_util_1.unwrapKey)(wrapped, crypto.randomBytes(32))).toThrow();
|
|
89
|
+
});
|
|
90
|
+
it('parses a 32-byte hex master key', () => {
|
|
91
|
+
const master = crypto.randomBytes(32);
|
|
92
|
+
expect((0, archive_seal_util_1.parseMasterKey)(master.toString('hex'), 'SOME_MASTER_KEY')).toEqual(master);
|
|
93
|
+
});
|
|
94
|
+
it('refuses a short master key and names the variable', () => {
|
|
95
|
+
expect(() => (0, archive_seal_util_1.parseMasterKey)('abcd', 'SOME_MASTER_KEY')).toThrow('SOME_MASTER_KEY must be 32 bytes of hex (64 characters), got 2 bytes');
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
//# sourceMappingURL=archive-seal.util.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"archive-seal.util.spec.js","sourceRoot":"","sources":["../../../../src/server/archive/tests/archive-seal.util.spec.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAiC;AACjC,4DAO8B;AAE9B,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;IAC7B,EAAE,CAAC,aAAa,EAAE,GAAG,EAAE;QACrB,MAAM,GAAG,GAAG,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;QACnC,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,+CAA+C,CAAC,CAAC;QAE/E,MAAM,CAA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C;IACpF,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,mDAAmD,EAAE,GAAG,EAAE;QAC3D,MAAM,CAAC,GAAG,EAAE,CAAC,IAAA,kCAAc,EAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC,CAAC,OAAO,CAC7D,sEAAsE,CACvE,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
const crypto = __importStar(require("crypto"));
|
|
37
|
+
const stream_1 = require("stream");
|
|
38
|
+
const archive_seal_util_1 = require("../archive-seal.util");
|
|
39
|
+
const archive_stream_service_1 = require("../archive-stream.service");
|
|
40
|
+
const COMPRESSION_LEVEL = 1;
|
|
41
|
+
const TIME_COLUMN = 'dateValue';
|
|
42
|
+
const DAY_START = Date.UTC(2026, 0, 10);
|
|
43
|
+
const newKey = () => crypto.randomBytes(32);
|
|
44
|
+
const recordingSession = () => {
|
|
45
|
+
const payloads = new Map();
|
|
46
|
+
return {
|
|
47
|
+
payloads,
|
|
48
|
+
putPart: jest.fn(async (partNumber, payload) => {
|
|
49
|
+
payloads.set(partNumber, Buffer.from(payload));
|
|
50
|
+
}),
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
const noise = (seed, length) => {
|
|
54
|
+
let text = '';
|
|
55
|
+
for (let counter = 0; text.length < length; counter += 1) {
|
|
56
|
+
text += crypto.createHash('sha256').update(`${seed}:${counter}`).digest('base64');
|
|
57
|
+
}
|
|
58
|
+
return text.slice(0, length);
|
|
59
|
+
};
|
|
60
|
+
const makeRows = (count, messageLength = () => 24) => Array.from({ length: count }, (_, index) => ({
|
|
61
|
+
id: `row-${index}`,
|
|
62
|
+
applicationId: 'application-under-test',
|
|
63
|
+
level: index % 6,
|
|
64
|
+
message: `message ${index} ${noise(index, messageLength(index))}`,
|
|
65
|
+
dateValue: new Date(DAY_START + index * 1000),
|
|
66
|
+
}));
|
|
67
|
+
async function* inBatches(rows, size) {
|
|
68
|
+
for (let start = 0; start < rows.length; start += size) {
|
|
69
|
+
yield rows.slice(start, start + size);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
const asArchived = (rows) => JSON.parse(JSON.stringify(rows));
|
|
73
|
+
const decodeAll = async (sealed, key) => {
|
|
74
|
+
const rows = [];
|
|
75
|
+
for await (const row of (0, archive_stream_service_1.decodeArchiveFrame)(sealed, key)) {
|
|
76
|
+
rows.push(row);
|
|
77
|
+
}
|
|
78
|
+
return rows;
|
|
79
|
+
};
|
|
80
|
+
const sha256Of = (buffers) => crypto.createHash('sha256').update(Buffer.concat(buffers)).digest('hex');
|
|
81
|
+
const payloadsInOrder = (session, parts) => parts.map((part) => session.payloads.get(part.partNumber));
|
|
82
|
+
describe('archive-stream.service', () => {
|
|
83
|
+
describe('writeArchiveStream', () => {
|
|
84
|
+
it('cuts a day bigger than a part into parts that each decode alone and give the day back in order', async () => {
|
|
85
|
+
const key = newKey();
|
|
86
|
+
const session = recordingSession();
|
|
87
|
+
const rows = makeRows(50_000);
|
|
88
|
+
const partMaxBytes = 16 * 1024;
|
|
89
|
+
const result = await (0, archive_stream_service_1.writeArchiveStream)(inBatches(rows, 1000), {
|
|
90
|
+
key,
|
|
91
|
+
session,
|
|
92
|
+
timeColumn: TIME_COLUMN,
|
|
93
|
+
compressionLevel: COMPRESSION_LEVEL,
|
|
94
|
+
partMaxBytes,
|
|
95
|
+
});
|
|
96
|
+
expect(result.parts.length).toBeGreaterThanOrEqual(3);
|
|
97
|
+
expect(result.parts.map((part) => part.partNumber)).toEqual(result.parts.map((_, index) => index + 1));
|
|
98
|
+
expect([...session.payloads.keys()]).toEqual(result.parts.map((part) => part.partNumber));
|
|
99
|
+
const decoded = [];
|
|
100
|
+
for (const part of result.parts) {
|
|
101
|
+
const sealed = session.payloads.get(part.partNumber);
|
|
102
|
+
const partRows = await decodeAll(sealed, key);
|
|
103
|
+
expect(sealed.length).toBeLessThanOrEqual(partMaxBytes);
|
|
104
|
+
expect(part.bytes).toBe(sealed.length);
|
|
105
|
+
expect(part.rowCount).toBe(partRows.length);
|
|
106
|
+
expect(part.firstTimestamp).toBe(partRows[0].dateValue);
|
|
107
|
+
decoded.push(...partRows);
|
|
108
|
+
}
|
|
109
|
+
expect(decoded).toEqual(asArchived(rows));
|
|
110
|
+
expect(result.totalRows).toBe(rows.length);
|
|
111
|
+
const stored = payloadsInOrder(session, result.parts);
|
|
112
|
+
expect(result.totalBytes).toBe(stored.reduce((total, sealed) => total + sealed.length, 0));
|
|
113
|
+
expect(result.sha256).toBe(sha256Of(stored));
|
|
114
|
+
});
|
|
115
|
+
it('never holds more rows at once than one batch', async () => {
|
|
116
|
+
const batchSize = 250;
|
|
117
|
+
let handedOut = 0;
|
|
118
|
+
let encoded = 0;
|
|
119
|
+
let mostAlive = 0;
|
|
120
|
+
const observe = () => {
|
|
121
|
+
mostAlive = Math.max(mostAlive, handedOut - encoded);
|
|
122
|
+
};
|
|
123
|
+
const rows = makeRows(20_000).map((row) => ({
|
|
124
|
+
...row,
|
|
125
|
+
toJSON: () => {
|
|
126
|
+
encoded += 1;
|
|
127
|
+
observe();
|
|
128
|
+
return row;
|
|
129
|
+
},
|
|
130
|
+
}));
|
|
131
|
+
async function* spiedBatches() {
|
|
132
|
+
for (let start = 0; start < rows.length; start += batchSize) {
|
|
133
|
+
const batch = rows.slice(start, start + batchSize);
|
|
134
|
+
handedOut += batch.length;
|
|
135
|
+
observe();
|
|
136
|
+
yield batch;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
const result = await (0, archive_stream_service_1.writeArchiveStream)(spiedBatches(), {
|
|
140
|
+
key: newKey(),
|
|
141
|
+
session: recordingSession(),
|
|
142
|
+
timeColumn: TIME_COLUMN,
|
|
143
|
+
compressionLevel: COMPRESSION_LEVEL,
|
|
144
|
+
partMaxBytes: 16 * 1024,
|
|
145
|
+
});
|
|
146
|
+
expect(result.totalRows).toBe(rows.length);
|
|
147
|
+
expect(encoded).toBe(rows.length);
|
|
148
|
+
expect(mostAlive).toBe(batchSize);
|
|
149
|
+
});
|
|
150
|
+
it('cuts on the bytes written, never on a number of rows', async () => {
|
|
151
|
+
const session = recordingSession();
|
|
152
|
+
const partMaxBytes = 16 * 1024;
|
|
153
|
+
const rows = makeRows(3_000, (index) => 50 + ((index * 7919) % 1500));
|
|
154
|
+
const result = await (0, archive_stream_service_1.writeArchiveStream)(inBatches(rows, 500), {
|
|
155
|
+
key: newKey(),
|
|
156
|
+
session,
|
|
157
|
+
timeColumn: TIME_COLUMN,
|
|
158
|
+
compressionLevel: COMPRESSION_LEVEL,
|
|
159
|
+
partMaxBytes,
|
|
160
|
+
});
|
|
161
|
+
const sizes = payloadsInOrder(session, result.parts).map((sealed) => sealed.length);
|
|
162
|
+
for (const size of sizes) {
|
|
163
|
+
expect(size).toBeLessThanOrEqual(partMaxBytes);
|
|
164
|
+
}
|
|
165
|
+
for (const size of sizes.slice(0, -1)) {
|
|
166
|
+
expect(size).toBeGreaterThan(partMaxBytes * 0.75);
|
|
167
|
+
}
|
|
168
|
+
expect(new Set(result.parts.map((part) => part.rowCount)).size).toBeGreaterThan(1);
|
|
169
|
+
});
|
|
170
|
+
it('refuses a single row larger than a part rather than sending an oversized part', async () => {
|
|
171
|
+
const session = recordingSession();
|
|
172
|
+
await expect((0, archive_stream_service_1.writeArchiveStream)(inBatches(makeRows(1, () => 8_000), 1), {
|
|
173
|
+
key: newKey(),
|
|
174
|
+
session,
|
|
175
|
+
timeColumn: TIME_COLUMN,
|
|
176
|
+
compressionLevel: COMPRESSION_LEVEL,
|
|
177
|
+
partMaxBytes: 2048,
|
|
178
|
+
})).rejects.toThrow(/above the 2048-byte part size/);
|
|
179
|
+
expect(session.putPart).not.toHaveBeenCalled();
|
|
180
|
+
});
|
|
181
|
+
it('refuses rows that go back in time, rather than writing an index that lies', async () => {
|
|
182
|
+
const [first, second, ...rest] = makeRows(10);
|
|
183
|
+
await expect((0, archive_stream_service_1.writeArchiveStream)(inBatches([second, first, ...rest], 10), {
|
|
184
|
+
key: newKey(),
|
|
185
|
+
session: recordingSession(),
|
|
186
|
+
timeColumn: TIME_COLUMN,
|
|
187
|
+
compressionLevel: COMPRESSION_LEVEL,
|
|
188
|
+
partMaxBytes: 16 * 1024,
|
|
189
|
+
})).rejects.toThrow(/ordered by dateValue/);
|
|
190
|
+
});
|
|
191
|
+
it("orders and indexes on the table's own time column, which is not always dateValue", async () => {
|
|
192
|
+
const key = newKey();
|
|
193
|
+
const session = recordingSession();
|
|
194
|
+
const rows = Array.from({ length: 3_000 }, (_, index) => ({
|
|
195
|
+
id: `history-${index}`,
|
|
196
|
+
applicationCronTaskId: 'cron-task-under-test',
|
|
197
|
+
startDate: new Date(DAY_START + index * 1000),
|
|
198
|
+
responseBody: noise(index, 40),
|
|
199
|
+
}));
|
|
200
|
+
const result = await (0, archive_stream_service_1.writeArchiveStream)(inBatches(rows, 500), {
|
|
201
|
+
key,
|
|
202
|
+
session,
|
|
203
|
+
timeColumn: 'startDate',
|
|
204
|
+
compressionLevel: COMPRESSION_LEVEL,
|
|
205
|
+
partMaxBytes: 8 * 1024,
|
|
206
|
+
});
|
|
207
|
+
expect(result.parts.length).toBeGreaterThanOrEqual(3);
|
|
208
|
+
for (const part of result.parts) {
|
|
209
|
+
const partRows = await decodeAll(session.payloads.get(part.partNumber), key);
|
|
210
|
+
expect(part.firstTimestamp).toBe(partRows[0].startDate);
|
|
211
|
+
}
|
|
212
|
+
const [first, second, ...rest] = rows;
|
|
213
|
+
await expect((0, archive_stream_service_1.writeArchiveStream)(inBatches([second, first, ...rest], 500), {
|
|
214
|
+
key,
|
|
215
|
+
session: recordingSession(),
|
|
216
|
+
timeColumn: 'startDate',
|
|
217
|
+
compressionLevel: COMPRESSION_LEVEL,
|
|
218
|
+
partMaxBytes: 8 * 1024,
|
|
219
|
+
})).rejects.toThrow(/ordered by startDate/);
|
|
220
|
+
});
|
|
221
|
+
it('refuses a row without a usable dateValue, which the index could not place', async () => {
|
|
222
|
+
await expect((0, archive_stream_service_1.writeArchiveStream)(inBatches([{ id: 'no-date', message: 'orphan' }], 1), {
|
|
223
|
+
key: newKey(),
|
|
224
|
+
session: recordingSession(),
|
|
225
|
+
timeColumn: TIME_COLUMN,
|
|
226
|
+
compressionLevel: COMPRESSION_LEVEL,
|
|
227
|
+
partMaxBytes: 16 * 1024,
|
|
228
|
+
})).rejects.toThrow(/no usable dateValue/);
|
|
229
|
+
});
|
|
230
|
+
it('writes no part for a day without rows', async () => {
|
|
231
|
+
const session = recordingSession();
|
|
232
|
+
const result = await (0, archive_stream_service_1.writeArchiveStream)(inBatches([], 10), {
|
|
233
|
+
key: newKey(),
|
|
234
|
+
session,
|
|
235
|
+
timeColumn: TIME_COLUMN,
|
|
236
|
+
compressionLevel: COMPRESSION_LEVEL,
|
|
237
|
+
partMaxBytes: 16 * 1024,
|
|
238
|
+
});
|
|
239
|
+
expect(result).toEqual({ parts: [], totalRows: 0, totalBytes: 0, sha256: sha256Of([]) });
|
|
240
|
+
expect(session.putPart).not.toHaveBeenCalled();
|
|
241
|
+
});
|
|
242
|
+
it('accounts for exactly what seal adds to a frame', () => {
|
|
243
|
+
expect((0, archive_seal_util_1.seal)(Buffer.alloc(1234), newKey()).length).toBe(1234 + archive_stream_service_1.SEAL_OVERHEAD_BYTES);
|
|
244
|
+
});
|
|
245
|
+
});
|
|
246
|
+
describe('decodeArchiveFrame', () => {
|
|
247
|
+
it('refuses a tampered part instead of returning rows from it', async () => {
|
|
248
|
+
const key = newKey();
|
|
249
|
+
const session = recordingSession();
|
|
250
|
+
await (0, archive_stream_service_1.writeArchiveStream)(inBatches(makeRows(100), 100), {
|
|
251
|
+
key,
|
|
252
|
+
session,
|
|
253
|
+
timeColumn: TIME_COLUMN,
|
|
254
|
+
compressionLevel: COMPRESSION_LEVEL,
|
|
255
|
+
partMaxBytes: 16 * 1024,
|
|
256
|
+
});
|
|
257
|
+
const tampered = Buffer.from(session.payloads.get(1));
|
|
258
|
+
tampered[tampered.length - 1] ^= 0xff;
|
|
259
|
+
await expect(decodeAll(tampered, key)).rejects.toThrow();
|
|
260
|
+
});
|
|
261
|
+
});
|
|
262
|
+
describe('splitArchiveFrames', () => {
|
|
263
|
+
const writeObject = async () => {
|
|
264
|
+
const key = newKey();
|
|
265
|
+
const session = recordingSession();
|
|
266
|
+
const result = await (0, archive_stream_service_1.writeArchiveStream)(inBatches(makeRows(5_000), 1000), {
|
|
267
|
+
key,
|
|
268
|
+
session,
|
|
269
|
+
timeColumn: TIME_COLUMN,
|
|
270
|
+
compressionLevel: COMPRESSION_LEVEL,
|
|
271
|
+
partMaxBytes: 4 * 1024,
|
|
272
|
+
});
|
|
273
|
+
return { key, parts: result.parts, stored: payloadsInOrder(session, result.parts) };
|
|
274
|
+
};
|
|
275
|
+
const streamed = (bytes, chunkBytes = 333) => {
|
|
276
|
+
const chunks = [];
|
|
277
|
+
for (let offset = 0; offset < bytes.length; offset += chunkBytes) {
|
|
278
|
+
chunks.push(bytes.subarray(offset, offset + chunkBytes));
|
|
279
|
+
}
|
|
280
|
+
return stream_1.Readable.from(chunks);
|
|
281
|
+
};
|
|
282
|
+
const drain = async (source, parts) => {
|
|
283
|
+
const frames = [];
|
|
284
|
+
for await (const frame of (0, archive_stream_service_1.splitArchiveFrames)(source, parts)) {
|
|
285
|
+
frames.push(frame.sealed);
|
|
286
|
+
}
|
|
287
|
+
return frames;
|
|
288
|
+
};
|
|
289
|
+
it('cuts an object streamed in arbitrary chunks back into its parts', async () => {
|
|
290
|
+
const { key, parts, stored } = await writeObject();
|
|
291
|
+
expect(parts.length).toBeGreaterThanOrEqual(3);
|
|
292
|
+
const frames = await drain(streamed(Buffer.concat(stored)), parts);
|
|
293
|
+
expect(frames).toEqual(stored);
|
|
294
|
+
const decoded = (await Promise.all(frames.map((frame) => decodeAll(frame, key)))).flat();
|
|
295
|
+
expect(decoded).toHaveLength(5_000);
|
|
296
|
+
});
|
|
297
|
+
it('refuses an object shorter than its index', async () => {
|
|
298
|
+
const { parts, stored } = await writeObject();
|
|
299
|
+
const truncated = Buffer.concat(stored).subarray(0, -10);
|
|
300
|
+
await expect(drain(streamed(truncated), parts)).rejects.toThrow(/ends inside part/);
|
|
301
|
+
});
|
|
302
|
+
it('refuses an object longer than its index', async () => {
|
|
303
|
+
const { parts, stored } = await writeObject();
|
|
304
|
+
const extended = Buffer.concat([...stored, Buffer.from('trailing bytes')]);
|
|
305
|
+
await expect(drain(streamed(extended), parts)).rejects.toThrow(/longer than its/);
|
|
306
|
+
});
|
|
307
|
+
});
|
|
308
|
+
});
|
|
309
|
+
//# sourceMappingURL=archive-stream.service.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"archive-stream.service.spec.js","sourceRoot":"","sources":["../../../../src/server/archive/tests/archive-stream.service.spec.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAiC;AACjC,mCAAkC;AAClC,4DAA4C;AAC5C,sEAOmC;AAWnC,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAE5B,MAAM,WAAW,GAAG,WAAW,CAAC;AAChC,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;AAExC,MAAM,MAAM,GAAG,GAAW,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;AAEpD,MAAM,gBAAgB,GAAG,GAAG,EAAE;IAC5B,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC3C,OAAO;QACL,QAAQ;QACR,OAAO,EAAE,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,UAAkB,EAAE,OAAe,EAAE,EAAE;YAC7D,QAAQ,CAAC,GAAG,CAAC,UAAU,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;QACjD,CAAC,CAAC;KACH,CAAC;AACJ,CAAC,CAAC;AAGF,MAAM,KAAK,GAAG,CAAC,IAAY,EAAE,MAAc,EAAU,EAAE;IACrD,IAAI,IAAI,GAAG,EAAE,CA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CAAC,CAAC,IAAI,EAAE,CAAC;YACzF,MAAM,CAAC,OAAO,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;QACtC,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,0CAA0C,EAAE,KAAK,IAAI,EAAE;YACxD,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,WAAW,EAAE,CAAC;YAC9C,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;YAEzD,MAAM,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;QACtF,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,yCAAyC,EAAE,KAAK,IAAI,EAAE;YACvD,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,WAAW,EAAE,CAAC;YAC9C,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC;YAE3E,MAAM,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;QACpF,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Transform } from 'stream';
|
|
2
|
+
export interface ZstdOptions {
|
|
3
|
+
params: Record<number, number>;
|
|
4
|
+
}
|
|
5
|
+
export interface ZstdCompressStream extends Transform {
|
|
6
|
+
flush(callback: (error?: Error | null) => void): void;
|
|
7
|
+
}
|
|
8
|
+
interface ZstdBindings {
|
|
9
|
+
createZstdCompress(options: ZstdOptions): ZstdCompressStream;
|
|
10
|
+
createZstdDecompress(): Transform;
|
|
11
|
+
zstdCompressSync(buffer: Buffer, options: ZstdOptions): Buffer;
|
|
12
|
+
zstdDecompressSync(buffer: Buffer): Buffer;
|
|
13
|
+
constants: {
|
|
14
|
+
ZSTD_c_compressionLevel: number;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export declare const zstd: ZstdBindings;
|
|
18
|
+
export declare const zstdCompressionOptions: (compressionLevel: number) => ZstdOptions;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.zstdCompressionOptions = exports.zstd = void 0;
|
|
37
|
+
const zlib = __importStar(require("zlib"));
|
|
38
|
+
exports.zstd = zlib;
|
|
39
|
+
const zstdCompressionOptions = (compressionLevel) => ({
|
|
40
|
+
params: { [exports.zstd.constants.ZSTD_c_compressionLevel]: compressionLevel },
|
|
41
|
+
});
|
|
42
|
+
exports.zstdCompressionOptions = zstdCompressionOptions;
|
|
43
|
+
//# sourceMappingURL=zstd.util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zstd.util.js","sourceRoot":"","sources":["../../../src/server/archive/zstd.util.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,2CAA6B;AAiChB,QAAA,IAAI,GAAG,IAA+B,CAAC;AAG7C,MAAM,sBAAsB,GAAG,CAAC,gBAAwB,EAAe,EAAE,CAAC,CAAC;IAChF,MAAM,EAAE,EAAE,CAAC,YAAI,CAAC,SAAS,CAAC,uBAAuB,CAAC,EAAE,gBAAgB,EAAE;CACvE,CAAC,CAAC;AAFU,QAAA,sBAAsB,0BAEhC"}
|
package/dist/server/index.d.ts
CHANGED
package/dist/server/index.js
CHANGED
|
@@ -22,4 +22,5 @@ __exportStar(require("./explore/field-catalog.types"), exports);
|
|
|
22
22
|
__exportStar(require("./explore/sql-translator"), exports);
|
|
23
23
|
__exportStar(require("./explore/like-escape"), exports);
|
|
24
24
|
__exportStar(require("./abyss-signature.util"), exports);
|
|
25
|
+
__exportStar(require("./archive"), exports);
|
|
25
26
|
//# sourceMappingURL=index.js.map
|