@metriport/shared 0.9.7-alpha.0 → 0.9.7
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/package.json +2 -2
- package/dist/common/file-downloader.d.ts +0 -14
- package/dist/common/file-downloader.d.ts.map +0 -1
- package/dist/common/file-downloader.js +0 -63
- package/dist/common/file-downloader.js.map +0 -1
- package/dist/common/stream.d.ts +0 -6
- package/dist/common/stream.d.ts.map +0 -1
- package/dist/common/stream.js +0 -18
- package/dist/common/stream.js.map +0 -1
- package/dist/common/uuid.d.ts +0 -2
- package/dist/common/uuid.d.ts.map +0 -1
- package/dist/common/uuid.js +0 -5
- package/dist/common/uuid.js.map +0 -1
- package/dist/net/__tests__/another.d.ts +0 -1
- package/dist/net/__tests__/another.d.ts.map +0 -1
- package/dist/net/__tests__/another.js +0 -2
- package/dist/net/__tests__/another.js.map +0 -1
- package/dist/net/net.d.ts +0 -2
- package/dist/net/net.d.ts.map +0 -1
- package/dist/net/net.js +0 -16
- package/dist/net/net.js.map +0 -1
- package/dist/net/stream.d.ts +0 -6
- package/dist/net/stream.d.ts.map +0 -1
- package/dist/net/stream.js +0 -18
- package/dist/net/stream.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metriport/shared",
|
|
3
|
-
"version": "0.9.7
|
|
3
|
+
"version": "0.9.7",
|
|
4
4
|
"description": "Common code shared across packages - by Metriport Inc.",
|
|
5
5
|
"author": "Metriport Inc. <contact@metriport.com>",
|
|
6
6
|
"homepage": "https://metriport.com/",
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@faker-js/faker": "^8.0.2"
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "9f433dc6769599d08e34010319d1ac4a8fed57df"
|
|
62
62
|
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
|
-
import * as stream from "stream";
|
|
4
|
-
export type DownloadFileParams = {
|
|
5
|
-
url: string;
|
|
6
|
-
outputStream: stream.Writable;
|
|
7
|
-
headers?: {
|
|
8
|
-
[index: string]: string;
|
|
9
|
-
};
|
|
10
|
-
timeout?: number;
|
|
11
|
-
};
|
|
12
|
-
export declare function downloadFileToMemory(params: Omit<DownloadFileParams, "outputStream">): Promise<Buffer>;
|
|
13
|
-
export declare function downloadFileToStream({ url, outputStream, headers, timeout, }: DownloadFileParams): Promise<boolean>;
|
|
14
|
-
//# sourceMappingURL=file-downloader.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"file-downloader.d.ts","sourceRoot":"","sources":["../../src/common/file-downloader.ts"],"names":[],"mappings":";;AACA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAKjC,MAAM,MAAM,kBAAkB,GAAG;IAC/B,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,EAAE,MAAM,CAAC,QAAQ,CAAC;IAC9B,OAAO,CAAC,EAAE;QACR,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;KACzB,CAAC;IACF,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,IAAI,CAAC,kBAAkB,EAAE,cAAc,CAAC,GAC/C,OAAO,CAAC,MAAM,CAAC,CAajB;AAED,wBAAsB,oBAAoB,CAAC,EACzC,GAAG,EACH,YAAY,EACZ,OAAO,EACP,OAAO,GACR,EAAE,kBAAkB,GAAG,OAAO,CAAC,OAAO,CAAC,CAYvC"}
|
|
@@ -1,63 +0,0 @@
|
|
|
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 (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.downloadFileToStream = exports.downloadFileToMemory = void 0;
|
|
30
|
-
const axios_1 = __importDefault(require("axios"));
|
|
31
|
-
const stream = __importStar(require("stream"));
|
|
32
|
-
const util = __importStar(require("util"));
|
|
33
|
-
const pipeline = util.promisify(stream.pipeline);
|
|
34
|
-
async function downloadFileToMemory(params) {
|
|
35
|
-
const buffers = Array();
|
|
36
|
-
const writableStream = new stream.Writable();
|
|
37
|
-
const buffer = streamToBuffer(writableStream);
|
|
38
|
-
writableStream.on("data", (chunk) => buffers.push(Buffer.from(chunk)));
|
|
39
|
-
writableStream.on("error", (err) => {
|
|
40
|
-
throw err;
|
|
41
|
-
});
|
|
42
|
-
writableStream.on("end", () => {
|
|
43
|
-
return Buffer.concat(buffers);
|
|
44
|
-
});
|
|
45
|
-
await downloadFileToStream({ ...params, outputStream: writableStream });
|
|
46
|
-
return Buffer.concat(buffers);
|
|
47
|
-
}
|
|
48
|
-
exports.downloadFileToMemory = downloadFileToMemory;
|
|
49
|
-
async function downloadFileToStream({ url, outputStream, headers, timeout, }) {
|
|
50
|
-
const requestConfig = {
|
|
51
|
-
responseType: "stream",
|
|
52
|
-
...(timeout ? { timeout } : undefined),
|
|
53
|
-
transitional: {
|
|
54
|
-
clarifyTimeoutError: true,
|
|
55
|
-
},
|
|
56
|
-
...(headers && { headers }),
|
|
57
|
-
};
|
|
58
|
-
const response = await axios_1.default.get(url, requestConfig);
|
|
59
|
-
await pipeline(response.data, outputStream);
|
|
60
|
-
return true;
|
|
61
|
-
}
|
|
62
|
-
exports.downloadFileToStream = downloadFileToStream;
|
|
63
|
-
//# sourceMappingURL=file-downloader.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"file-downloader.js","sourceRoot":"","sources":["../../src/common/file-downloader.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAAkD;AAClD,+CAAiC;AACjC,2CAA6B;AAE7B,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;AAW1C,KAAK,UAAU,oBAAoB,CACxC,MAAgD;IAEhD,MAAM,OAAO,GAAG,KAAK,EAAO,CAAC;IAC7B,MAAM,cAAc,GAAG,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;IAC7C,MAAM,MAAM,GAAG,cAAc,CAAC,cAAc,CAAC,CAAC;IAC9C,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACvE,cAAc,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;QACjC,MAAM,GAAG,CAAC;IACZ,CAAC,CAAC,CAAC;IACH,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE;QAC5B,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAChC,CAAC,CAAC,CAAC;IACH,MAAM,oBAAoB,CAAC,EAAE,GAAG,MAAM,EAAE,YAAY,EAAE,cAAc,EAAE,CAAC,CAAC;IACxE,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AAChC,CAAC;AAfD,oDAeC;AAEM,KAAK,UAAU,oBAAoB,CAAC,EACzC,GAAG,EACH,YAAY,EACZ,OAAO,EACP,OAAO,GACY;IACnB,MAAM,aAAa,GAAuB;QACxC,YAAY,EAAE,QAAQ;QACtB,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;QACtC,YAAY,EAAE;YACZ,mBAAmB,EAAE,IAAI;SAC1B;QACD,GAAG,CAAC,OAAO,IAAI,EAAE,OAAO,EAAE,CAAC;KAC5B,CAAC;IACF,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,GAAG,CAAC,GAAG,EAAE,aAAa,CAAC,CAAC;IACrD,MAAM,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;IAC5C,OAAO,IAAI,CAAC;AACd,CAAC;AAjBD,oDAiBC"}
|
package/dist/common/stream.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
|
-
import * as stream from "stream";
|
|
4
|
-
export declare function streamToBuffer(stream: stream.Readable): Promise<Buffer>;
|
|
5
|
-
export declare function streamToString(stream: stream.Readable): Promise<String>;
|
|
6
|
-
//# sourceMappingURL=stream.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../src/common/stream.ts"],"names":[],"mappings":";;AAAA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAEjC,wBAAsB,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,CAO7E;AAED,wBAAsB,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,CAG7E"}
|
package/dist/common/stream.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.streamToString = exports.streamToBuffer = void 0;
|
|
4
|
-
async function streamToBuffer(stream) {
|
|
5
|
-
const buffer = Array();
|
|
6
|
-
return new Promise((resolve, reject) => {
|
|
7
|
-
stream.on("data", chunk => buffer.push(Buffer.from(chunk)));
|
|
8
|
-
stream.on("error", err => reject(err));
|
|
9
|
-
stream.on("end", () => resolve(Buffer.concat(buffer)));
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
exports.streamToBuffer = streamToBuffer;
|
|
13
|
-
async function streamToString(stream) {
|
|
14
|
-
const buffer = await streamToBuffer(stream);
|
|
15
|
-
return buffer.toString();
|
|
16
|
-
}
|
|
17
|
-
exports.streamToString = streamToString;
|
|
18
|
-
//# sourceMappingURL=stream.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stream.js","sourceRoot":"","sources":["../../src/common/stream.ts"],"names":[],"mappings":";;;AAEO,KAAK,UAAU,cAAc,CAAC,MAAuB;IAC1D,MAAM,MAAM,GAAG,KAAK,EAAO,CAAC;IAC5B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAC5D,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;QACvC,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IACzD,CAAC,CAAC,CAAC;AACL,CAAC;AAPD,wCAOC;AAEM,KAAK,UAAU,cAAc,CAAC,MAAuB;IAC1D,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,MAAM,CAAC,CAAC;IAC5C,OAAO,MAAM,CAAC,QAAQ,EAAE,CAAC;AAC3B,CAAC;AAHD,wCAGC"}
|
package/dist/common/uuid.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"uuid.d.ts","sourceRoot":"","sources":["../../src/common/uuid.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,QAAmB,CAAC"}
|
package/dist/common/uuid.js
DELETED
package/dist/common/uuid.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"uuid.js","sourceRoot":"","sources":["../../src/common/uuid.ts"],"names":[],"mappings":";;;AAAa,QAAA,SAAS,GAAG,gBAAgB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=another.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"another.d.ts","sourceRoot":"","sources":["../../../src/net/__tests__/another.js"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"another.js","sourceRoot":"","sources":["../../../src/net/__tests__/another.js"],"names":[],"mappings":""}
|
package/dist/net/net.d.ts
DELETED
package/dist/net/net.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"net.d.ts","sourceRoot":"","sources":["../../src/net/net.ts"],"names":[],"mappings":"AAAA,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAQ3D"}
|
package/dist/net/net.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isValidUrl = void 0;
|
|
4
|
-
function isValidUrl(url) {
|
|
5
|
-
if (!url)
|
|
6
|
-
return false;
|
|
7
|
-
try {
|
|
8
|
-
new URL(url);
|
|
9
|
-
return true;
|
|
10
|
-
}
|
|
11
|
-
catch (e) {
|
|
12
|
-
return false;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
exports.isValidUrl = isValidUrl;
|
|
16
|
-
//# sourceMappingURL=net.js.map
|
package/dist/net/net.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"net.js","sourceRoot":"","sources":["../../src/net/net.ts"],"names":[],"mappings":";;;AAAA,SAAgB,UAAU,CAAC,GAAuB;IAChD,IAAI,CAAC,GAAG;QAAE,OAAO,KAAK,CAAC;IACvB,IAAI;QACF,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QACb,OAAO,IAAI,CAAC;KACb;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,KAAK,CAAC;KACd;AACH,CAAC;AARD,gCAQC"}
|
package/dist/net/stream.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
|
-
import * as stream from "stream";
|
|
4
|
-
export declare function streamToBuffer(stream: stream.Stream): Promise<Buffer>;
|
|
5
|
-
export declare function streamToString(stream: stream.Stream): Promise<String>;
|
|
6
|
-
//# sourceMappingURL=stream.d.ts.map
|
package/dist/net/stream.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../src/net/stream.ts"],"names":[],"mappings":";;AAAA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAEjC,wBAAsB,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAO3E;AAED,wBAAsB,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAG3E"}
|
package/dist/net/stream.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.streamToString = exports.streamToBuffer = void 0;
|
|
4
|
-
async function streamToBuffer(stream) {
|
|
5
|
-
const buffers = Array();
|
|
6
|
-
return new Promise((resolve, reject) => {
|
|
7
|
-
stream.on("data", chunk => buffers.push(Buffer.from(chunk)));
|
|
8
|
-
stream.on("error", err => reject(err));
|
|
9
|
-
stream.on("end", () => resolve(Buffer.concat(buffers)));
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
exports.streamToBuffer = streamToBuffer;
|
|
13
|
-
async function streamToString(stream) {
|
|
14
|
-
const buffer = await streamToBuffer(stream);
|
|
15
|
-
return buffer.toString();
|
|
16
|
-
}
|
|
17
|
-
exports.streamToString = streamToString;
|
|
18
|
-
//# sourceMappingURL=stream.js.map
|
package/dist/net/stream.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stream.js","sourceRoot":"","sources":["../../src/net/stream.ts"],"names":[],"mappings":";;;AAEO,KAAK,UAAU,cAAc,CAAC,MAAqB;IACxD,MAAM,OAAO,GAAG,KAAK,EAAO,CAAC;IAC7B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAC7D,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;QACvC,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAC1D,CAAC,CAAC,CAAC;AACL,CAAC;AAPD,wCAOC;AAEM,KAAK,UAAU,cAAc,CAAC,MAAqB;IACxD,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,MAAM,CAAC,CAAC;IAC5C,OAAO,MAAM,CAAC,QAAQ,EAAE,CAAC;AAC3B,CAAC;AAHD,wCAGC"}
|