azure-kusto-ingest 5.2.2 → 6.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/dist-esm/src/abstractKustoClient.js +33 -0
  2. package/dist-esm/src/abstractKustoClient.js.map +1 -1
  3. package/dist-esm/src/descriptors.js +5 -1
  4. package/dist-esm/src/descriptors.js.map +1 -1
  5. package/dist-esm/src/fileDescriptor.browser.js +5 -2
  6. package/dist-esm/src/fileDescriptor.browser.js.map +1 -1
  7. package/dist-esm/src/fileDescriptor.js +5 -2
  8. package/dist-esm/src/fileDescriptor.js.map +1 -1
  9. package/dist-esm/src/index.js +4 -1
  10. package/dist-esm/src/index.js.map +1 -1
  11. package/dist-esm/src/ingestClient.browser.js +8 -11
  12. package/dist-esm/src/ingestClient.browser.js.map +1 -1
  13. package/dist-esm/src/ingestClient.js +8 -13
  14. package/dist-esm/src/ingestClient.js.map +1 -1
  15. package/dist-esm/src/ingestClientBase.js +93 -9
  16. package/dist-esm/src/ingestClientBase.js.map +1 -1
  17. package/dist-esm/src/ingestionBlobInfo.js +6 -1
  18. package/dist-esm/src/ingestionBlobInfo.js.map +1 -1
  19. package/dist-esm/src/ingestionProperties.js +15 -1
  20. package/dist-esm/src/ingestionProperties.js.map +1 -1
  21. package/dist-esm/src/ingestionResult.js +60 -0
  22. package/dist-esm/src/ingestionResult.js.map +1 -0
  23. package/dist-esm/src/managedStreamingIngestClient.js +4 -4
  24. package/dist-esm/src/managedStreamingIngestClient.js.map +1 -1
  25. package/dist-esm/src/rankedStorageAccount.js +73 -0
  26. package/dist-esm/src/rankedStorageAccount.js.map +1 -0
  27. package/dist-esm/src/rankedStorageAccountSet.js +61 -0
  28. package/dist-esm/src/rankedStorageAccountSet.js.map +1 -0
  29. package/dist-esm/src/resourceManager.js +108 -16
  30. package/dist-esm/src/resourceManager.js.map +1 -1
  31. package/dist-esm/src/streamingIngestClient.browser.js +2 -2
  32. package/dist-esm/src/streamingIngestClient.browser.js.map +1 -1
  33. package/dist-esm/src/streamingIngestClient.js +2 -2
  34. package/dist-esm/src/streamingIngestClient.js.map +1 -1
  35. package/dist-esm/src/streamingIngestClientBase.js +7 -1
  36. package/dist-esm/src/streamingIngestClientBase.js.map +1 -1
  37. package/package.json +7 -4
  38. package/types/src/abstractKustoClient.d.ts +3 -0
  39. package/types/src/descriptors.d.ts +1 -0
  40. package/types/src/fileDescriptor.browser.d.ts +3 -1
  41. package/types/src/fileDescriptor.d.ts +3 -1
  42. package/types/src/index.d.ts +2 -1
  43. package/types/src/ingestClient.browser.d.ts +4 -4
  44. package/types/src/ingestClient.d.ts +4 -4
  45. package/types/src/ingestClientBase.d.ts +10 -4
  46. package/types/src/ingestionBlobInfo.d.ts +5 -1
  47. package/types/src/ingestionProperties.d.ts +1 -0
  48. package/types/src/ingestionResult.d.ts +41 -0
  49. package/types/src/managedStreamingIngestClient.d.ts +5 -5
  50. package/types/src/rankedStorageAccount.d.ts +15 -0
  51. package/types/src/rankedStorageAccountSet.d.ts +18 -0
  52. package/types/src/resourceManager.d.ts +21 -4
  53. package/types/src/streamingIngestClient.browser.d.ts +1 -1
  54. package/types/src/streamingIngestClient.d.ts +1 -1
  55. package/types/src/streamingIngestClientBase.d.ts +1 -1
@@ -1,9 +1,15 @@
1
1
  "use strict";
2
2
  // Copyright (c) Microsoft Corporation.
3
3
  // Licensed under the MIT License.
4
+ var __importDefault = (this && this.__importDefault) || function (mod) {
5
+ return (mod && mod.__esModule) ? mod : { "default": mod };
6
+ };
4
7
  Object.defineProperty(exports, "__esModule", { value: true });
5
8
  exports.AbstractKustoClient = void 0;
6
9
  const ingestionProperties_1 = require("./ingestionProperties");
10
+ const is_ip_1 = __importDefault(require("is-ip"));
11
+ const INGEST_PREFIX = "ingest-";
12
+ const PROTOCOL_SUFFIX = "://";
7
13
  class AbstractKustoClient {
8
14
  constructor(defaultProps) {
9
15
  this._isClosed = false;
@@ -34,6 +40,33 @@ class AbstractKustoClient {
34
40
  throw new Error("Client is closed");
35
41
  }
36
42
  }
43
+ getIngestionEndpoint(clusterUrl) {
44
+ if (!clusterUrl || clusterUrl.includes(INGEST_PREFIX) || this.isReservedHostname(clusterUrl)) {
45
+ return clusterUrl;
46
+ }
47
+ return clusterUrl.replace(PROTOCOL_SUFFIX, PROTOCOL_SUFFIX + INGEST_PREFIX);
48
+ }
49
+ getQueryEndpoint(clusterUrl) {
50
+ if (clusterUrl && clusterUrl.includes(INGEST_PREFIX)) {
51
+ return clusterUrl.replace(INGEST_PREFIX, "");
52
+ }
53
+ return clusterUrl;
54
+ }
55
+ isReservedHostname(clusterUrl) {
56
+ try {
57
+ const parsedUrl = new URL(clusterUrl);
58
+ const authority = parsedUrl.hostname;
59
+ if (!authority) {
60
+ return true;
61
+ }
62
+ const is_ip = (0, is_ip_1.default)(authority);
63
+ const is_localhost = authority.includes("localhost");
64
+ return is_localhost || is_ip || authority.toLowerCase() === "onebox.dev.kusto.windows.net";
65
+ }
66
+ catch (_a) {
67
+ return false;
68
+ }
69
+ }
37
70
  }
38
71
  exports.AbstractKustoClient = AbstractKustoClient;
39
72
  //# sourceMappingURL=abstractKustoClient.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"abstractKustoClient.js","sourceRoot":"","sources":["../../src/abstractKustoClient.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC,+DAAsF;AAGtF,MAAsB,mBAAmB;IAKrC,YAAsB,YAAsC;QAFlD,cAAS,GAAY,KAAK,CAAC;QAGjC,IAAI,CAAC,YAAY,EAAE;YACf,IAAI,CAAC,YAAY,GAAG,IAAI,yCAAmB,CAAC,EAAE,CAAC,CAAC;SACnD;aAAM,IAAI,CAAC,CAAC,YAAY,YAAY,yCAAmB,CAAC,EAAE;YACvD,IAAI,CAAC,YAAY,GAAG,IAAI,yCAAmB,CAAC,YAAY,CAAC,CAAC;SAC7D;aAAM;YACH,IAAI,CAAC,YAAY,GAAG,IAAI,yCAAmB,CAAC,YAAY,CAAC,CAAC;SAC7D;IACL,CAAC;IAED,eAAe,CAAC,aAAwC;QACpD,MAAM,KAAK,GAAG,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;QACrD,KAAK,CAAC,WAAW,EAAE,CAAC;QACpB,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE;YACjB,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAC,eAAe,CAAC;SACzC;QAED,KAAK,CAAC,QAAQ,EAAE,CAAC;QACjB,OAAO,KAAK,CAAC;IACjB,CAAC;IAQM,KAAK;QACR,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IAC1B,CAAC;IAES,UAAU;QAChB,IAAI,IAAI,CAAC,SAAS,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;SACvC;IACL,CAAC;CACJ;AAzCD,kDAyCC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { IngestionProperties, IngestionPropertiesInput } from \"./ingestionProperties\";\nimport { StreamDescriptor, FileDescriptorBase, BlobDescriptor } from \"./descriptors\";\n\nexport abstract class AbstractKustoClient {\n public defaultProps: IngestionProperties;\n public defaultDatabase?: string;\n protected _isClosed: boolean = false;\n\n protected constructor(defaultProps: IngestionPropertiesInput) {\n if (!defaultProps) {\n this.defaultProps = new IngestionProperties({});\n } else if (!(defaultProps instanceof IngestionProperties)) {\n this.defaultProps = new IngestionProperties(defaultProps);\n } else {\n this.defaultProps = new IngestionProperties(defaultProps);\n }\n }\n\n _getMergedProps(newProperties?: IngestionPropertiesInput): IngestionProperties {\n const props = this.defaultProps.merge(newProperties);\n props.setDefaults();\n if (!props.database) {\n props.database = this.defaultDatabase;\n }\n\n props.validate();\n return props;\n }\n\n abstract ingestFromStream(stream: StreamDescriptor, ingestionProperties: IngestionPropertiesInput): Promise<any>;\n\n abstract ingestFromFile(file: FileDescriptorBase | string | Blob, ingestionProperties: IngestionPropertiesInput): Promise<any>;\n\n abstract ingestFromBlob(blob: string | BlobDescriptor, ingestionProperties?: IngestionPropertiesInput): Promise<any>;\n\n public close(): void {\n this._isClosed = true;\n }\n\n protected ensureOpen() {\n if (this._isClosed) {\n throw new Error(\"Client is closed\");\n }\n }\n}\n"]}
1
+ {"version":3,"file":"abstractKustoClient.js","sourceRoot":"","sources":["../../src/abstractKustoClient.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;;;AAElC,+DAAsF;AAEtF,kDAAyB;AAEzB,MAAM,aAAa,GAAG,SAAS,CAAC;AAChC,MAAM,eAAe,GAAG,KAAK,CAAC;AAE9B,MAAsB,mBAAmB;IAKrC,YAAsB,YAAsC;QAFlD,cAAS,GAAY,KAAK,CAAC;QAGjC,IAAI,CAAC,YAAY,EAAE;YACf,IAAI,CAAC,YAAY,GAAG,IAAI,yCAAmB,CAAC,EAAE,CAAC,CAAC;SACnD;aAAM,IAAI,CAAC,CAAC,YAAY,YAAY,yCAAmB,CAAC,EAAE;YACvD,IAAI,CAAC,YAAY,GAAG,IAAI,yCAAmB,CAAC,YAAY,CAAC,CAAC;SAC7D;aAAM;YACH,IAAI,CAAC,YAAY,GAAG,IAAI,yCAAmB,CAAC,YAAY,CAAC,CAAC;SAC7D;IACL,CAAC;IAED,eAAe,CAAC,aAAwC;QACpD,MAAM,KAAK,GAAG,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;QACrD,KAAK,CAAC,WAAW,EAAE,CAAC;QACpB,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE;YACjB,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAC,eAAe,CAAC;SACzC;QAED,KAAK,CAAC,QAAQ,EAAE,CAAC;QACjB,OAAO,KAAK,CAAC;IACjB,CAAC;IAQM,KAAK;QACR,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IAC1B,CAAC;IAES,UAAU;QAChB,IAAI,IAAI,CAAC,SAAS,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;SACvC;IACL,CAAC;IAED,oBAAoB,CAAC,UAAmB;QACpC,IAAI,CAAC,UAAU,IAAI,UAAU,CAAC,QAAQ,CAAC,aAAa,CAAC,IAAI,IAAI,CAAC,kBAAkB,CAAC,UAAU,CAAC,EAAE;YAC1F,OAAO,UAAU,CAAC;SACrB;QACD,OAAO,UAAU,CAAC,OAAO,CAAC,eAAe,EAAE,eAAe,GAAG,aAAa,CAAC,CAAC;IAChF,CAAC;IAED,gBAAgB,CAAC,UAAmB;QAChC,IAAI,UAAU,IAAI,UAAU,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAE;YAClD,OAAO,UAAU,CAAC,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;SAChD;QACD,OAAO,UAAU,CAAC;IACtB,CAAC;IAED,kBAAkB,CAAC,UAAkB;QACjC,IAAI;YACA,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,CAAC;YACtC,MAAM,SAAS,GAAG,SAAS,CAAC,QAAQ,CAAC;YACrC,IAAI,CAAC,SAAS,EAAE;gBACZ,OAAO,IAAI,CAAC;aACf;YACD,MAAM,KAAK,GAAG,IAAA,eAAI,EAAC,SAAS,CAAC,CAAC;YAC9B,MAAM,YAAY,GAAG,SAAS,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;YACrD,OAAO,YAAY,IAAI,KAAK,IAAI,SAAS,CAAC,WAAW,EAAE,KAAK,8BAA8B,CAAC;SAC9F;QAAC,WAAM;YACJ,OAAO,KAAK,CAAC;SAChB;IACL,CAAC;CACJ;AAtED,kDAsEC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { IngestionProperties, IngestionPropertiesInput } from \"./ingestionProperties\";\nimport { StreamDescriptor, FileDescriptorBase, BlobDescriptor } from \"./descriptors\";\nimport isIP from \"is-ip\";\n\nconst INGEST_PREFIX = \"ingest-\";\nconst PROTOCOL_SUFFIX = \"://\";\n\nexport abstract class AbstractKustoClient {\n public defaultProps: IngestionProperties;\n public defaultDatabase?: string;\n protected _isClosed: boolean = false;\n\n protected constructor(defaultProps: IngestionPropertiesInput) {\n if (!defaultProps) {\n this.defaultProps = new IngestionProperties({});\n } else if (!(defaultProps instanceof IngestionProperties)) {\n this.defaultProps = new IngestionProperties(defaultProps);\n } else {\n this.defaultProps = new IngestionProperties(defaultProps);\n }\n }\n\n _getMergedProps(newProperties?: IngestionPropertiesInput): IngestionProperties {\n const props = this.defaultProps.merge(newProperties);\n props.setDefaults();\n if (!props.database) {\n props.database = this.defaultDatabase;\n }\n\n props.validate();\n return props;\n }\n\n abstract ingestFromStream(stream: StreamDescriptor, ingestionProperties: IngestionPropertiesInput): Promise<any>;\n\n abstract ingestFromFile(file: FileDescriptorBase | string | Blob, ingestionProperties: IngestionPropertiesInput): Promise<any>;\n\n abstract ingestFromBlob(blob: string | BlobDescriptor, ingestionProperties?: IngestionPropertiesInput): Promise<any>;\n\n public close(): void {\n this._isClosed = true;\n }\n\n protected ensureOpen() {\n if (this._isClosed) {\n throw new Error(\"Client is closed\");\n }\n }\n\n getIngestionEndpoint(clusterUrl?: string): string | undefined {\n if (!clusterUrl || clusterUrl.includes(INGEST_PREFIX) || this.isReservedHostname(clusterUrl)) {\n return clusterUrl;\n }\n return clusterUrl.replace(PROTOCOL_SUFFIX, PROTOCOL_SUFFIX + INGEST_PREFIX);\n }\n\n getQueryEndpoint(clusterUrl?: string): string | undefined {\n if (clusterUrl && clusterUrl.includes(INGEST_PREFIX)) {\n return clusterUrl.replace(INGEST_PREFIX, \"\");\n }\n return clusterUrl;\n }\n\n isReservedHostname(clusterUrl: string): boolean {\n try {\n const parsedUrl = new URL(clusterUrl);\n const authority = parsedUrl.hostname;\n if (!authority) {\n return true;\n }\n const is_ip = isIP(authority);\n const is_localhost = authority.includes(\"localhost\");\n return is_localhost || is_ip || authority.toLowerCase() === \"onebox.dev.kusto.windows.net\";\n } catch {\n return false;\n }\n }\n}\n"]}
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  return (mod && mod.__esModule) ? mod : { "default": mod };
6
6
  };
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.generateBlobName = exports.BlobDescriptor = exports.StreamDescriptor = exports.AbstractDescriptor = exports.getSourceId = exports.CompressionType = void 0;
8
+ exports.generateBlobName = exports.BlobDescriptor = exports.StreamDescriptor = exports.AbstractDescriptor = exports.shouldCompressFileByExtension = exports.getSourceId = exports.CompressionType = void 0;
9
9
  const uuid_1 = require("uuid");
10
10
  const uuid_validate_1 = __importDefault(require("uuid-validate"));
11
11
  const storage_blob_1 = require("@azure/storage-blob");
@@ -25,6 +25,10 @@ const getSourceId = (sourceId) => {
25
25
  return (0, uuid_1.v4)();
26
26
  };
27
27
  exports.getSourceId = getSourceId;
28
+ function shouldCompressFileByExtension(extension) {
29
+ return !(extension === ".avro" || extension === ".apacheavro" || extension === ".parquet" || extension === ".sstream" || extension === ".orc");
30
+ }
31
+ exports.shouldCompressFileByExtension = shouldCompressFileByExtension;
28
32
  class AbstractDescriptor {
29
33
  constructor(sourceId = null, size = null) {
30
34
  this.sourceId = sourceId;
@@ -1 +1 @@
1
- {"version":3,"file":"descriptors.js","sourceRoot":"","sources":["../../src/descriptors.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;;;AAElC,+BAAoC;AACpC,kEAAyC;AAGzC,sDAAiD;AAEjD,IAAY,eAIX;AAJD,WAAY,eAAe;IACvB,+BAAY,CAAA;IACZ,+BAAY,CAAA;IACZ,4BAAS,CAAA;AACb,CAAC,EAJW,eAAe,+BAAf,eAAe,QAI1B;AAEM,MAAM,WAAW,GAAG,CAAC,QAAuB,EAAU,EAAE;IAC3D,IAAI,QAAQ,EAAE;QACV,IAAI,CAAC,IAAA,uBAAY,EAAC,QAAQ,EAAE,CAAC,CAAC,EAAE;YAC5B,MAAM,KAAK,CAAC,iC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v4 } from \"uuid\";\nimport uuidValidate from \"uuid-validate\";\nimport { Readable } from \"stream\";\nimport IngestionProperties from \"./ingestionProperties\";\nimport { BlobClient } from \"@azure/storage-blob\";\n\nexport enum CompressionType {\n ZIP = \".zip\",\n GZIP = \".gz\",\n None = \"\",\n}\n\nexport const getSourceId = (sourceId: string | null): string => {\n if (sourceId) {\n if (!uuidValidate(sourceId, 4)) {\n throw Error(\"sourceId is not a valid uuid/v4\");\n }\n return sourceId;\n }\n return uuidv4();\n};\n\nexport abstract class AbstractDescriptor {\n constructor(public sourceId: string | null = null, public size: number | null = null) {\n this.sourceId = getSourceId(sourceId);\n }\n}\n\nexport class StreamDescriptor extends AbstractDescriptor {\n /**\n * Use Readable for Node.js and ArrayBuffer in browser\n */\n constructor(\n readonly stream: Readable | ArrayBuffer,\n sourceId: string | null = null,\n public compressionType: CompressionType = CompressionType.None,\n size: number | null = null\n ) {\n super(sourceId, size);\n }\n\n merge(other: StreamDescriptor) {\n this.size = other.size;\n this.compressionType = other.compressionType;\n this.sourceId = other.sourceId;\n return this;\n }\n\n // Currently streams are not compressed by us\n getCompressionSuffix() {\n return this.compressionType ? `.${this.compressionType}` : \"\";\n }\n}\n\nexport class BlobDescriptor extends AbstractDescriptor {\n constructor(readonly path: string, size: number | null = null, sourceId: string | null = null) {\n super(sourceId, size);\n }\n\n async fillSize(): Promise<void> {\n if (!this.size) {\n const blobClient = new BlobClient(this.path);\n const blobProps = await blobClient.getProperties();\n const length = blobProps.contentLength;\n if (length !== undefined) {\n if (length === 0) {\n throw new Error(\"Empty blob.\");\n }\n this.size = length;\n }\n }\n }\n}\n\nexport interface FileDescriptorBase {\n size: number | null;\n zipped: boolean;\n compressionType: CompressionType;\n cleanupTmp?: () => Promise<void>;\n extension?: string;\n name?: string;\n sourceId: string | null;\n getCompressionSuffix: () => string;\n}\n\nexport const generateBlobName = (desc: StreamDescriptor | FileDescriptorBase, props: IngestionProperties): string => {\n const extension = desc instanceof StreamDescriptor ? null : `${desc.name ? \"__\" + desc.name : `${desc.extension ? \".\" + desc.extension : \"\"}`}`;\n\n const formatSuffix = props.format ? `.${props.format}` : \".csv\";\n const compressionString = desc.getCompressionSuffix();\n return `${props.database}__${props.table}__${desc.sourceId}${extension || formatSuffix}${compressionString}`;\n};\n"]}
1
+ {"version":3,"file":"descriptors.js","sourceRoot":"","sources":["../../src/descriptors.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;;;AAElC,+BAAoC;AACpC,kEAAyC;AAGzC,sDAAiD;AAEjD,IAAY,eAIX;AAJD,WAAY,eAAe;IACvB,+BAAY,CAAA;IACZ,+BAAY,CAAA;IACZ,4BAAS,CAAA;AACb,CAAC,EAJW,eAAe,+BAAf,eAAe,QAI1B;AAEM,MAAM,WAAW,GAAG,CAAC,QAAuB,EAAU,EAAE;IAC3D,IAAI,QAAQ,EAAE;QACV,IAAI,CAAC,IAAA,uBAAY,EAAC,QAAQ,EAAE,CAAC,CAAC,EAAE;YAC5B,MAAM,KAAK,CAAC,iCAAiC,CAAC,CAAC;SAClD;QACD,OAAO,QAAQ,CAAC;KACnB;IACD,OAAO,IAAA,SAAM,GAAE,CAAC;AACpB,CAAC,CAAC;AARW,QAAA,WAAW,eAQtB;AAEF,SAAgB,6BAA6B,CAAC,SAAkB;IAC5D,OAAO,CAAC,CAAC,SAAS,KAAK,OAAO,IAAI,SAAS,KAAK,aAAa,IAAI,SAAS,KAAK,UAAU,IAAI,SAAS,KAAK,UAAU,IAAI,SAAS,KAAK,MAAM,CAAC,CAAC;AACnJ,CAAC;AAFD,sEAEC;AAED,MAAsB,kBAAkB;IACpC,YAAmB,WAA0B,IAAI,EAAS,OAAsB,IAAI;QAAjE,aAAQ,GAAR,QAAQ,CAAsB;QAAS,SAAI,GAAJ,IAAI,CAAsB;QAChF,IAAI,CAAC,QAAQ,GAAG,IAAA,mBAAW,EAAC,QAAQ,CAAC,CAAC;IAC1C,CAAC;CACJ;AAJD,gDAIC;AAED,MAAa,gB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I,GAAG,MAAM,CAAC;aACtB;SACJ;IACL,CAAC;CACJ;AAlBD,wCAkBC;AAaM,MAAM,gBAAgB,GAAG,CAAC,IAA2C,EAAE,KAA0B,EAAU,EAAE;IAChH,MAAM,SAAS,GAAG,IAAI,YAAY,gBAAgB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC;IAEhJ,MAAM,YAAY,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;IAChE,MAAM,iBAAiB,GAAG,IAAI,CAAC,oBAAoB,EAAE,CAAC;IACtD,OAAO,GAAG,KAAK,CAAC,QAAQ,KAAK,KAAK,CAAC,KAAK,KAAK,IAAI,CAAC,QAAQ,GAAG,SAAS,IAAI,YAAY,GAAG,iBAAiB,EAAE,CAAC;AACjH,CAAC,CAAC;AANW,QAAA,gBAAgB,oBAM3B","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { v4 as uuidv4 } from \"uuid\";\nimport uuidValidate from \"uuid-validate\";\nimport { Readable } from \"stream\";\nimport IngestionProperties from \"./ingestionProperties\";\nimport { BlobClient } from \"@azure/storage-blob\";\n\nexport enum CompressionType {\n ZIP = \".zip\",\n GZIP = \".gz\",\n None = \"\",\n}\n\nexport const getSourceId = (sourceId: string | null): string => {\n if (sourceId) {\n if (!uuidValidate(sourceId, 4)) {\n throw Error(\"sourceId is not a valid uuid/v4\");\n }\n return sourceId;\n }\n return uuidv4();\n};\n\nexport function shouldCompressFileByExtension(extension?: string): boolean {\n return !(extension === \".avro\" || extension === \".apacheavro\" || extension === \".parquet\" || extension === \".sstream\" || extension === \".orc\");\n}\n\nexport abstract class AbstractDescriptor {\n constructor(public sourceId: string | null = null, public size: number | null = null) {\n this.sourceId = getSourceId(sourceId);\n }\n}\n\nexport class StreamDescriptor extends AbstractDescriptor {\n /**\n * Use Readable for Node.js and ArrayBuffer in browser\n */\n constructor(\n readonly stream: Readable | ArrayBuffer,\n sourceId: string | null = null,\n public compressionType: CompressionType = CompressionType.None,\n size: number | null = null\n ) {\n super(sourceId, size);\n }\n\n merge(other: StreamDescriptor) {\n this.size = other.size;\n this.compressionType = other.compressionType;\n this.sourceId = other.sourceId;\n return this;\n }\n\n // Currently streams are not compressed by us\n getCompressionSuffix() {\n return this.compressionType ? `.${this.compressionType}` : \"\";\n }\n}\n\nexport class BlobDescriptor extends AbstractDescriptor {\n constructor(readonly path: string, size: number | null = null, sourceId: string | null = null) {\n super(sourceId, size);\n }\n\n async fillSize(): Promise<void> {\n if (!this.size) {\n const blobClient = new BlobClient(this.path);\n const blobProps = await blobClient.getProperties();\n const length = blobProps.contentLength;\n if (length !== undefined) {\n if (length === 0) {\n throw new Error(\"Empty blob.\");\n }\n this.size = length;\n }\n }\n }\n}\n\nexport interface FileDescriptorBase {\n size: number | null;\n zipped: boolean;\n compressionType: CompressionType;\n cleanupTmp?: () => Promise<void>;\n extension?: string;\n name?: string;\n sourceId: string | null;\n getCompressionSuffix: () => string;\n}\n\nexport const generateBlobName = (desc: StreamDescriptor | FileDescriptorBase, props: IngestionProperties): string => {\n const extension = desc instanceof StreamDescriptor ? null : `${desc.name ? \"__\" + desc.name : `${desc.extension ? \".\" + desc.extension : \"\"}`}`;\n\n const formatSuffix = props.format ? `.${props.format}` : \".csv\";\n const compressionString = desc.getCompressionSuffix();\n return `${props.database}__${props.table}__${desc.sourceId}${extension || formatSuffix}${compressionString}`;\n};\n"]}
@@ -8,6 +8,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
8
8
  exports.FileDescriptor = void 0;
9
9
  const pako_1 = __importDefault(require("pako"));
10
10
  const descriptors_1 = require("./descriptors");
11
+ const ingestionProperties_1 = require("./ingestionProperties");
11
12
  class FileDescriptor extends descriptors_1.AbstractDescriptor {
12
13
  constructor(file, sourceId = null, size = null, compressionType = descriptors_1.CompressionType.None, extension, name) {
13
14
  super(sourceId);
@@ -17,9 +18,11 @@ class FileDescriptor extends descriptors_1.AbstractDescriptor {
17
18
  this.compressionType = compressionType;
18
19
  this.size = size || file.size;
19
20
  this.zipped = compressionType !== descriptors_1.CompressionType.None || this.extension === ".gz" || this.extension === ".zip";
21
+ this.shouldNotCompress = !(0, descriptors_1.shouldCompressFileByExtension)(this.extension);
20
22
  }
21
- async prepare() {
22
- if (!this.zipped) {
23
+ async prepare(ingestionProperties) {
24
+ const shouldNotCompressByFormat = !(0, ingestionProperties_1.shouldCompressFileByFormat)(ingestionProperties);
25
+ if (!this.zipped && !this.shouldNotCompress && !shouldNotCompressByFormat) {
23
26
  try {
24
27
  const gzipped = pako_1.default.gzip(await this.file.arrayBuffer());
25
28
  return new Blob([gzipped]);
@@ -1 +1 @@
1
- {"version":3,"file":"fileDescriptor.browser.js","sourceRoot":"","sources":["../../src/fileDescriptor.browser.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;;;AAElC,gDAAwB;AACxB,+CAAwF;AAExF,MAAa,cAAe,SAAQ,gCAAkB;IAMlD,YACa,IAAU,EACnB,WAA0B,IAAI,EAC9B,OAAsB,IAAI,EAC1B,kBAAmC,6BAAe,CAAC,IAAI,EAC9C,SAAkB,EAClB,IAAa;QAEtB,KAAK,CAAC,QAAQ,CAAC,CAAC;QAPP,SAAI,GAAJ,IAAI,CAAM;QAIV,cAAS,GAAT,SAAS,CAAS;QAClB,SAAI,GAAJ,IAAI,CAAS;QAGtB,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACvC,IAAI,CAAC,IAAI,GAAG,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC;QAC9B,IAAI,CAAC,MAAM,GAAG,eAAe,KAAK,6BAAe,CAAC,IAAI,IAAI,IAAI,CAAC,SAAS,KAAK,KAAK,IAAI,IAAI,CAAC,SAAS,KAAK,MAAM,CAAC;IACpH,CAAC;IAED,KAAK,CAAC,OAAO;QACT,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;YACd,IAAI;gBACA,MAAM,OAAO,GAAG,cAAI,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;gBACzD,OAAO,IAAI,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;aAC9B;YAAC,OAAO,CAAC,EAAE;gBACR,kCAAkC;aACrC;SACJ;QAED,OAAO,IAAI,CAAC,IAAI,CAAC;IACrB,CAAC;IAED,KAAK,CAAC,OAAO;QACT,IAAI,IAAI,CAAC,UAAU,EAAE;YACjB,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC;SAC3B;IACL,CAAC;IAED,oBAAoB;QAChB,OAAO,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;IACrE,CAAC;CACJ;AA1CD,wCA0CC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport pako from \"pako\";\nimport { AbstractDescriptor, CompressionType, FileDescriptorBase } from \"./descriptors\";\n\nexport class FileDescriptor extends AbstractDescriptor implements FileDescriptorBase {\n size: number | null;\n zipped: boolean;\n compressionType: CompressionType;\n cleanupTmp?: () => Promise<void>;\n\n constructor(\n readonly file: Blob,\n sourceId: string | null = null,\n size: number | null = null,\n compressionType: CompressionType = CompressionType.None,\n readonly extension?: string,\n readonly name?: string\n ) {\n super(sourceId);\n this.compressionType = compressionType;\n this.size = size || file.size;\n this.zipped = compressionType !== CompressionType.None || this.extension === \".gz\" || this.extension === \".zip\";\n }\n\n async prepare(): Promise<Blob> {\n if (!this.zipped) {\n try {\n const gzipped = pako.gzip(await this.file.arrayBuffer());\n return new Blob([gzipped]);\n } catch (e) {\n // Ignore - return the file itself\n }\n }\n\n return this.file;\n }\n\n async cleanup(): Promise<void> {\n if (this.cleanupTmp) {\n await this.cleanupTmp();\n }\n }\n\n getCompressionSuffix() {\n return this.compressionType ? `.${this.compressionType}` : \".gz\";\n }\n}\n"]}
1
+ {"version":3,"file":"fileDescriptor.browser.js","sourceRoot":"","sources":["../../src/fileDescriptor.browser.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;;;AAElC,gDAAwB;AACxB,+CAAuH;AACvH,+DAA6F;AAE7F,MAAa,cAAe,SAAQ,gCAAkB;IAOlD,YACa,IAAU,EACnB,WAA0B,IAAI,EAC9B,OAAsB,IAAI,EAC1B,kBAAmC,6BAAe,CAAC,IAAI,EAC9C,SAAkB,EAClB,IAAa;QAEtB,KAAK,CAAC,QAAQ,CAAC,CAAC;QAPP,SAAI,GAAJ,IAAI,CAAM;QAIV,cAAS,GAAT,SAAS,CAAS;QAClB,SAAI,GAAJ,IAAI,CAAS;QAGtB,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACvC,IAAI,CAAC,IAAI,GAAG,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC;QAC9B,IAAI,CAAC,MAAM,GAAG,eAAe,KAAK,6BAAe,CAAC,IAAI,IAAI,IAAI,CAAC,SAAS,KAAK,KAAK,IAAI,IAAI,CAAC,SAAS,KAAK,MAAM,CAAC;QAChH,IAAI,CAAC,iBAAiB,GAAG,CAAC,IAAA,2CAA6B,EAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC5E,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,mBAA8C;QACxD,MAAM,yBAAyB,GAAG,CAAC,IAAA,gDAA0B,EAAC,mBAAmB,CAAC,CAAC;QACnF,IAAI,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,iBAAiB,IAAI,CAAC,yBAAyB,EAAE;YACvE,IAAI;gBACA,MAAM,OAAO,GAAG,cAAI,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;gBACzD,OAAO,IAAI,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;aAC9B;YAAC,OAAO,CAAC,EAAE;gBACR,kCAAkC;aACrC;SACJ;QAED,OAAO,IAAI,CAAC,IAAI,CAAC;IACrB,CAAC;IAED,KAAK,CAAC,OAAO;QACT,IAAI,IAAI,CAAC,UAAU,EAAE;YACjB,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC;SAC3B;IACL,CAAC;IAED,oBAAoB;QAChB,OAAO,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;IACrE,CAAC;CACJ;AA7CD,wCA6CC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport pako from \"pako\";\nimport { AbstractDescriptor, CompressionType, FileDescriptorBase, shouldCompressFileByExtension } from \"./descriptors\";\nimport { IngestionPropertiesInput, shouldCompressFileByFormat } from \"./ingestionProperties\";\n\nexport class FileDescriptor extends AbstractDescriptor implements FileDescriptorBase {\n size: number | null;\n zipped: boolean;\n compressionType: CompressionType;\n shouldNotCompress: boolean;\n cleanupTmp?: () => Promise<void>;\n\n constructor(\n readonly file: Blob,\n sourceId: string | null = null,\n size: number | null = null,\n compressionType: CompressionType = CompressionType.None,\n readonly extension?: string,\n readonly name?: string\n ) {\n super(sourceId);\n this.compressionType = compressionType;\n this.size = size || file.size;\n this.zipped = compressionType !== CompressionType.None || this.extension === \".gz\" || this.extension === \".zip\";\n this.shouldNotCompress = !shouldCompressFileByExtension(this.extension);\n }\n\n async prepare(ingestionProperties?: IngestionPropertiesInput): Promise<Blob> {\n const shouldNotCompressByFormat = !shouldCompressFileByFormat(ingestionProperties);\n if (!this.zipped && !this.shouldNotCompress && !shouldNotCompressByFormat) {\n try {\n const gzipped = pako.gzip(await this.file.arrayBuffer());\n return new Blob([gzipped]);\n } catch (e) {\n // Ignore - return the file itself\n }\n }\n\n return this.file;\n }\n\n async cleanup(): Promise<void> {\n if (this.cleanupTmp) {\n await this.cleanupTmp();\n }\n }\n\n getCompressionSuffix() {\n return this.compressionType ? `.${this.compressionType}` : \".gz\";\n }\n}\n"]}
@@ -12,6 +12,7 @@ const fs_1 = __importDefault(require("fs"));
12
12
  const tmp_promise_1 = require("tmp-promise");
13
13
  const util_1 = require("util");
14
14
  const descriptors_1 = require("./descriptors");
15
+ const ingestionProperties_1 = require("./ingestionProperties");
15
16
  /**
16
17
  * Describes a file to be ingested. Use string to describe a local path in Node.JS and Blob object in browsers
17
18
  */
@@ -31,6 +32,7 @@ class FileDescriptor extends descriptors_1.AbstractDescriptor {
31
32
  this.name = name ? name : path_1.default.basename(this.file);
32
33
  this.extension = extension ? extension : path_1.default.extname(this.file).toLowerCase();
33
34
  this.zipped = compressionType !== descriptors_1.CompressionType.None || this.extension === ".gz" || this.extension === ".zip";
35
+ this.shouldNotCompress = !(0, descriptors_1.shouldCompressFileByExtension)(this.extension);
34
36
  }
35
37
  async _gzip() {
36
38
  const { path, cleanup } = await (0, tmp_promise_1.file)({ postfix: ".gz", keep: false });
@@ -51,8 +53,9 @@ class FileDescriptor extends descriptors_1.AbstractDescriptor {
51
53
  });
52
54
  return path;
53
55
  }
54
- async prepare() {
55
- if (this.zipped) {
56
+ async prepare(ingestionProperties) {
57
+ const shouldNotCompressByFormat = !(0, ingestionProperties_1.shouldCompressFileByFormat)(ingestionProperties);
58
+ if (this.zipped || this.shouldNotCompress || shouldNotCompressByFormat) {
56
59
  const estimatedCompressionModifier = 11;
57
60
  await this._calculateSize(estimatedCompressionModifier);
58
61
  return this.file;
@@ -1 +1 @@
1
- {"version":3,"file":"fileDescriptor.js","sourceRoot":"","sources":["../../src/fileDescriptor.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;;;AAElC,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,KAAK,CAAC,OAAO;QACT,IAAI,IAAI,CAAC,UAAU,EAAE;YACjB,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC;SAC3B;IACL,CAAC;IAED,oBAAoB;QAChB,OAAO,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;IACrE,CAAC;CACJ;AA3ED,wCA2EC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport zlib from \"zlib\";\nimport pathlib from \"path\";\nimport fs from \"fs\";\nimport { file as tmpFile } from \"tmp-promise\";\nimport { promisify } from \"util\";\nimport { AbstractDescriptor, CompressionType, FileDescriptorBase } from \"./descriptors\";\n\n/**\n * Describes a file to be ingested. Use string to describe a local path in Node.JS and Blob object in browsers\n */\nexport class FileDescriptor extends AbstractDescriptor implements FileDescriptorBase {\n zipped: boolean;\n compressionType: CompressionType;\n cleanupTmp?: () => Promise<void>;\n\n constructor(\n /**\n * Use string in Node.JS and Blob in browser\n */\n readonly file: string | Blob,\n sourceId: string | null = null,\n size: number | null = null,\n compressionType: CompressionType = CompressionType.None,\n readonly extension?: string, // Extracted from file name by default\n readonly name?: string // Extracted from file name by default\n ) {\n super(sourceId, size);\n this.compressionType = compressionType;\n this.name = name ? name : pathlib.basename(this.file as string);\n this.extension = extension ? extension : pathlib.extname(this.file as string).toLowerCase();\n\n this.zipped = compressionType !== CompressionType.None || this.extension === \".gz\" || this.extension === \".zip\";\n }\n\n async _gzip(): Promise<string> {\n const { path, cleanup } = await tmpFile({ postfix: \".gz\", keep: false });\n this.cleanupTmp = cleanup;\n\n const zipper = zlib.createGzip();\n const input = fs.createReadStream(this.file as string, { autoClose: true });\n const output = fs.createWriteStream(path);\n\n await new Promise((resolve, reject) => {\n input\n .pipe(zipper)\n .pipe(output)\n .on(\"error\", (err) => {\n reject(err);\n });\n output.once(\"close\", () => {\n resolve(null);\n });\n });\n\n return path;\n }\n\n async prepare(): Promise<string> {\n if (this.zipped) {\n const estimatedCompressionModifier = 11;\n await this._calculateSize(estimatedCompressionModifier);\n return this.file as string;\n }\n\n const path = await this._gzip();\n await this._calculateSize();\n return path;\n }\n\n private async _calculateSize(modifier: number = 1): Promise<void> {\n if (this.size == null || this.size <= 0) {\n const asyncStat = promisify(fs.stat);\n this.size = (await asyncStat(this.file as string)).size * modifier;\n }\n }\n\n async cleanup(): Promise<void> {\n if (this.cleanupTmp) {\n await this.cleanupTmp();\n }\n }\n\n getCompressionSuffix() {\n return this.compressionType ? `.${this.compressionType}` : \".gz\";\n }\n}\n"]}
1
+ {"version":3,"file":"fileDescriptor.js","sourceRoot":"","sources":["../../src/fileDescriptor.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;;;AAElC,gDAAwB;AACxB,gDAA2B;AAC3B,4CAAoB;AACpB,6CAA8C;AAC9C,+BAAiC;AACjC,+CAAuH;AACvH,+DAA6F;AAE7F;;GAEG;AACH,MAAa,cAAe,SAAQ,gCAAkB;IAMlD;IACI;;OAEG;IACM,IAAmB,EAC5B,WAA0B,IAAI,EAC9B,OAAsB,IAAI,EAC1B,kBAAmC,6BAAe,CAAC,IAAI,EAC9C,SAAkB,EAAE,sCAAsC;IAC1D,IAAa,CAAC,sCAAsC;;QAE7D,KAAK,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QAPb,SAAI,GAAJ,IAAI,CAAe;QAInB,cAAS,GAAT,SAAS,CAAS;QAClB,SAAI,GAAJ,IAAI,CAAS;QAGtB,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACvC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,cAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAc,CAAC,CAAC;QAChE,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,cAAO,CAAC,OAAO,CAA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,CAAC,IAAA,gDAA0B,EAAC,mBAAmB,CAAC,CAAC;QACnF,IAAI,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,iBAAiB,IAAI,yBAAyB,EAAE;YACpE,MAAM,4BAA4B,GAAG,EAAE,CAAC;YACxC,MAAM,IAAI,CAAC,cAAc,CAAC,4BAA4B,CAAC,CAAC;YACxD,OAAO,IAAI,CAAC,IAAc,CAAC;SAC9B;QAED,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC;QAChC,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;QAC5B,OAAO,IAAI,CAAC;IAChB,CAAC;IAEO,KAAK,CAAC,cAAc,CAAC,WAAmB,CAAC;QAC7C,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,IAAI,IAAI,CAAC,IAAI,IAAI,CAAC,EAAE;YACrC,MAAM,SAAS,GAAG,IAAA,gBAAS,EAAC,YAAE,CAAC,IAAI,CAAC,CAAC;YACrC,IAAI,CAAC,IAAI,GAAG,CAAC,MAAM,SAAS,CAAC,IAAI,CAAC,IAAc,CAAC,CAAC,CAAC,IAAI,GAAG,QAAQ,CAAC;SACtE;IACL,CAAC;IAED,KAAK,CAAC,OAAO;QACT,IAAI,IAAI,CAAC,UAAU,EAAE;YACjB,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC;SAC3B;IACL,CAAC;IAED,oBAAoB;QAChB,OAAO,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;IACrE,CAAC;CACJ;AA9ED,wCA8EC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport zlib from \"zlib\";\nimport pathlib from \"path\";\nimport fs from \"fs\";\nimport { file as tmpFile } from \"tmp-promise\";\nimport { promisify } from \"util\";\nimport { AbstractDescriptor, CompressionType, FileDescriptorBase, shouldCompressFileByExtension } from \"./descriptors\";\nimport { IngestionPropertiesInput, shouldCompressFileByFormat } from \"./ingestionProperties\";\n\n/**\n * Describes a file to be ingested. Use string to describe a local path in Node.JS and Blob object in browsers\n */\nexport class FileDescriptor extends AbstractDescriptor implements FileDescriptorBase {\n zipped: boolean;\n compressionType: CompressionType;\n shouldNotCompress: boolean;\n cleanupTmp?: () => Promise<void>;\n\n constructor(\n /**\n * Use string in Node.JS and Blob in browser\n */\n readonly file: string | Blob,\n sourceId: string | null = null,\n size: number | null = null,\n compressionType: CompressionType = CompressionType.None,\n readonly extension?: string, // Extracted from file name by default\n readonly name?: string // Extracted from file name by default\n ) {\n super(sourceId, size);\n this.compressionType = compressionType;\n this.name = name ? name : pathlib.basename(this.file as string);\n this.extension = extension ? extension : pathlib.extname(this.file as string).toLowerCase();\n\n this.zipped = compressionType !== CompressionType.None || this.extension === \".gz\" || this.extension === \".zip\";\n this.shouldNotCompress = !shouldCompressFileByExtension(this.extension);\n }\n\n async _gzip(): Promise<string> {\n const { path, cleanup } = await tmpFile({ postfix: \".gz\", keep: false });\n this.cleanupTmp = cleanup;\n\n const zipper = zlib.createGzip();\n const input = fs.createReadStream(this.file as string, { autoClose: true });\n const output = fs.createWriteStream(path);\n\n await new Promise((resolve, reject) => {\n input\n .pipe(zipper)\n .pipe(output)\n .on(\"error\", (err) => {\n reject(err);\n });\n output.once(\"close\", () => {\n resolve(null);\n });\n });\n\n return path;\n }\n\n async prepare(ingestionProperties?: IngestionPropertiesInput): Promise<string> {\n const shouldNotCompressByFormat = !shouldCompressFileByFormat(ingestionProperties);\n if (this.zipped || this.shouldNotCompress || shouldNotCompressByFormat) {\n const estimatedCompressionModifier = 11;\n await this._calculateSize(estimatedCompressionModifier);\n return this.file as string;\n }\n\n const path = await this._gzip();\n await this._calculateSize();\n return path;\n }\n\n private async _calculateSize(modifier: number = 1): Promise<void> {\n if (this.size == null || this.size <= 0) {\n const asyncStat = promisify(fs.stat);\n this.size = (await asyncStat(this.file as string)).size * modifier;\n }\n }\n\n async cleanup(): Promise<void> {\n if (this.cleanupTmp) {\n await this.cleanupTmp();\n }\n }\n\n getCompressionSuffix() {\n return this.compressionType ? `.${this.compressionType}` : \".gz\";\n }\n}\n"]}
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  return (mod && mod.__esModule) ? mod : { "default": mod };
6
6
  };
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.IngestionPropertiesValidationError = exports.IngestionPropertiesEnums = exports.dataFormatMappingKind = exports.W3CLogFileMapping = exports.ValidationPolicy = exports.ValidationOptions = exports.ValidationImplications = exports.StreamDescriptor = exports.SStreamColumnMapping = exports.ReportMethod = exports.ReportLevel = exports.ParquetColumnMapping = exports.OrcColumnMapping = exports.JsonColumnMapping = exports.IngestionMappingKind = exports.FileDescriptor = exports.FieldTransformation = exports.DataFormat = exports.CsvColumnMapping = exports.ConstantTransformation = exports.CompressionType = exports.ColumnMapping = exports.BlobDescriptor = exports.AvroColumnMapping = exports.ApacheAvroColumnMapping = exports.IngestionDescriptors = exports.StreamingIngestClient = exports.ManagedStreamingIngestClient = exports.IngestStatusQueues = exports.IngestClient = exports.IngestionProperties = void 0;
8
+ exports.IngestionPropertiesValidationError = exports.IngestionPropertiesEnums = exports.IngestionStatusInTableDescription = exports.OperationStatus = exports.dataFormatMappingKind = exports.W3CLogFileMapping = exports.ValidationPolicy = exports.ValidationOptions = exports.ValidationImplications = exports.StreamDescriptor = exports.SStreamColumnMapping = exports.ReportMethod = exports.ReportLevel = exports.ParquetColumnMapping = exports.OrcColumnMapping = exports.JsonColumnMapping = exports.IngestionMappingKind = exports.FileDescriptor = exports.FieldTransformation = exports.DataFormat = exports.CsvColumnMapping = exports.ConstantTransformation = exports.CompressionType = exports.ColumnMapping = exports.BlobDescriptor = exports.AvroColumnMapping = exports.ApacheAvroColumnMapping = exports.IngestionDescriptors = exports.StreamingIngestClient = exports.ManagedStreamingIngestClient = exports.IngestStatusQueues = exports.IngestClient = exports.IngestionProperties = void 0;
9
9
  const ingestClient_1 = __importDefault(require("./ingestClient"));
10
10
  exports.IngestClient = ingestClient_1.default;
11
11
  const streamingIngestClient_1 = __importDefault(require("./streamingIngestClient"));
@@ -14,6 +14,9 @@ const managedStreamingIngestClient_1 = __importDefault(require("./managedStreami
14
14
  exports.ManagedStreamingIngestClient = managedStreamingIngestClient_1.default;
15
15
  const status_1 = __importDefault(require("./status"));
16
16
  exports.IngestStatusQueues = status_1.default;
17
+ const ingestionResult_1 = require("./ingestionResult");
18
+ Object.defineProperty(exports, "OperationStatus", { enumerable: true, get: function () { return ingestionResult_1.OperationStatus; } });
19
+ Object.defineProperty(exports, "IngestionStatusInTableDescription", { enumerable: true, get: function () { return ingestionResult_1.IngestionStatusInTableDescription; } });
17
20
  const ingestionProperties_1 = require("./ingestionProperties");
18
21
  Object.defineProperty(exports, "DataFormat", { enumerable: true, get: function () { return ingestionProperties_1.DataFormat; } });
19
22
  Object.defineProperty(exports, "IngestionMappingKind", { enumerable: true, get: function () { return ingestionProperties_1.IngestionMappingKind; } });
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;;;AAElC,kEAA+C;AAsCtB,uBAtClB,sBAAiB,CAsCa;AApCrC,oFAA4D;AAuC/B,gCAvCtB,+BAAqB,CAuCsB;AArClD,kGAA0E;AAoCtC,uCApC7B,sCAA4B,CAoC6B;AAlChE,sDAA+C;AAiChB,6BAjCxB,gBAAuB,CAiCmB;AA/BjD,+DAS+B;AA4C3B,2FApDA,gCAAU,OAoDA;AAGV,qGAtDA,0CAAoB,OAsDA;AAIpB,4FAzDA,iCAAW,OAyDA;AACX,6FAzDA,kCAAY,OAyDA;AAGZ,uGA3DA,4CAAsB,OA2DA;AACtB,kGA3DA,uCAAiB,OA2DA;AACjB,iGA3DA,sCAAgB,OA2DA;AAEhB,sGA5DA,2CAAqB,OA4DA;AAzDzB,qDAY0B;AAuBtB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IACtB,mBAAmB,EAAnB,oCAAmB;IACnB,aAAa,EAAb,8BAAa;CAChB,CAAC;AAEF,mCAA8D;AAArD,4HAAA,kCAAkC,OAAA;AAC3C,sCAAsC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport KustoIngestClient from \"./ingestClient\";\n\nimport streamingIngestClient from \"./streamingIngestClient\";\n\nimport managedStreamingIngestClient from \"./managedStreamingIngestClient\";\n\nimport KustoIngestStatusQueues from \"./status\";\n\nimport {\n DataFormat,\n IngestionMappingKind,\n ReportLevel,\n ReportMethod,\n ValidationImplications,\n ValidationOptions,\n ValidationPolicy,\n dataFormatMappingKind,\n} from \"./ingestionProperties\";\n\nimport {\n ApacheAvroColumnMapping,\n AvroColumnMapping,\n ColumnMapping,\n ConstantTransformation,\n CsvColumnMapping,\n FieldTransformation,\n JsonColumnMapping,\n OrcColumnMapping,\n ParquetColumnMapping,\n SStreamColumnMapping,\n W3CLogFileMapping,\n} from \"./columnMappings\";\nimport { BlobDescriptor, CompressionType, StreamDescriptor } from \"./descriptors\";\nimport { FileDescriptor } from \"./fileDescriptor\";\n\nexport { Transformation as ColumnMappingTransformation } from \"./columnMappings\";\nexport { IngestionProperties } from \"./ingestionProperties\";\nexport {\n KustoIngestClient as IngestClient,\n KustoIngestStatusQueues as IngestStatusQueues,\n managedStreamingIngestClient as ManagedStreamingIngestClient,\n streamingIngestClient as StreamingIngestClient,\n};\n\n/**\n * @deprecated - import directly instead. Export const is not exporting type.\n */\nexport const IngestionDescriptors = {\n BlobDescriptor,\n FileDescriptor,\n StreamDescriptor,\n};\n\nexport {\n ApacheAvroColumnMapping,\n AvroColumnMapping,\n BlobDescriptor,\n ColumnMapping,\n CompressionType,\n ConstantTransformation,\n CsvColumnMapping,\n DataFormat,\n FieldTransformation,\n FileDescriptor,\n IngestionMappingKind,\n JsonColumnMapping,\n OrcColumnMapping,\n ParquetColumnMapping,\n ReportLevel,\n ReportMethod,\n SStreamColumnMapping,\n StreamDescriptor,\n ValidationImplications,\n ValidationOptions,\n ValidationPolicy,\n W3CLogFileMapping,\n dataFormatMappingKind,\n};\n\n/**\n * @deprecated - import directly instead\n */\nexport const IngestionPropertiesEnums = {\n JsonColumnMapping,\n CsvColumnMapping,\n AvroColumnMapping,\n ParquetColumnMapping,\n OrcColumnMapping,\n W3CLogFileMapping,\n ValidationPolicy,\n ReportLevel,\n ReportMethod,\n ValidationImplications,\n ValidationOptions,\n DataFormat,\n /**\n * @deprecated - use IngestionMappingKind instead\n */\n IngestionMappingType: IngestionMappingKind,\n IngestionMappingKind,\n CompressionType,\n ApacheAvroColumnMapping,\n SStreamColumnMapping,\n ConstantTransformation,\n FieldTransformation,\n ColumnMapping,\n};\n\nexport { IngestionPropertiesValidationError } from \"./errors\";\n// eslint-disable-next-line no-console\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;;;AAElC,kEAA+C;AAuCtB,uBAvClB,sBAAiB,CAuCa;AArCrC,oFAA4D;AAwC/B,gCAxCtB,+BAAqB,CAwCsB;AAtClD,kGAA0E;AAqCtC,uCArC7B,sCAA4B,CAqC6B;AAnChE,sDAA+C;AAkChB,6BAlCxB,gBAAuB,CAkCmB;AAhCjD,uDAAyH;AAuErH,gGAvEsB,iCAAe,OAuEtB;AAEf,kHAzEwD,mDAAiC,OAyExD;AAxErC,+DAS+B;AA4C3B,2FApDA,gCAAU,OAoDA;AAGV,qGAtDA,0CAAoB,OAsDA;AAIpB,4FAzDA,iCAAW,OAyDA;AACX,6FAzDA,kCAAY,OAyDA;AAGZ,uGA3DA,4CAAsB,OA2DA;AACtB,kGA3DA,uCAAiB,OA2DA;AACjB,iGA3DA,sCAAgB,OA2DA;AAEhB,sGA5DA,2CAAqB,OA4DA;AAzDzB,qDAY0B;AAuBtB,wGAlCA,wCAAuB,OAkCA;AACvB,kGAlCA,kCAAiB,OAkCA;AAEjB,8FAn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AAEF,mCAA8D;AAArD,4HAAA,kCAAkC,OAAA;AAC3C,sCAAsC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport KustoIngestClient from \"./ingestClient\";\n\nimport streamingIngestClient from \"./streamingIngestClient\";\n\nimport managedStreamingIngestClient from \"./managedStreamingIngestClient\";\n\nimport KustoIngestStatusQueues from \"./status\";\n\nimport { IngestionResult, OperationStatus, IngestionStatus, IngestionStatusInTableDescription } from \"./ingestionResult\";\nimport {\n DataFormat,\n IngestionMappingKind,\n ReportLevel,\n ReportMethod,\n ValidationImplications,\n ValidationOptions,\n ValidationPolicy,\n dataFormatMappingKind,\n} from \"./ingestionProperties\";\n\nimport {\n ApacheAvroColumnMapping,\n AvroColumnMapping,\n ColumnMapping,\n ConstantTransformation,\n CsvColumnMapping,\n FieldTransformation,\n JsonColumnMapping,\n OrcColumnMapping,\n ParquetColumnMapping,\n SStreamColumnMapping,\n W3CLogFileMapping,\n} from \"./columnMappings\";\nimport { BlobDescriptor, CompressionType, StreamDescriptor } from \"./descriptors\";\nimport { FileDescriptor } from \"./fileDescriptor\";\n\nexport { Transformation as ColumnMappingTransformation } from \"./columnMappings\";\nexport { IngestionProperties } from \"./ingestionProperties\";\nexport {\n KustoIngestClient as IngestClient,\n KustoIngestStatusQueues as IngestStatusQueues,\n managedStreamingIngestClient as ManagedStreamingIngestClient,\n streamingIngestClient as StreamingIngestClient,\n};\n\n/**\n * @deprecated - import directly instead. Export const is not exporting type.\n */\nexport const IngestionDescriptors = {\n BlobDescriptor,\n FileDescriptor,\n StreamDescriptor,\n};\n\nexport {\n ApacheAvroColumnMapping,\n AvroColumnMapping,\n BlobDescriptor,\n ColumnMapping,\n CompressionType,\n ConstantTransformation,\n CsvColumnMapping,\n DataFormat,\n FieldTransformation,\n FileDescriptor,\n IngestionMappingKind,\n JsonColumnMapping,\n OrcColumnMapping,\n ParquetColumnMapping,\n ReportLevel,\n ReportMethod,\n SStreamColumnMapping,\n StreamDescriptor,\n ValidationImplications,\n ValidationOptions,\n ValidationPolicy,\n W3CLogFileMapping,\n dataFormatMappingKind,\n IngestionResult,\n OperationStatus,\n IngestionStatus,\n IngestionStatusInTableDescription,\n};\n\n/**\n * @deprecated - import directly instead\n */\nexport const IngestionPropertiesEnums = {\n JsonColumnMapping,\n CsvColumnMapping,\n AvroColumnMapping,\n ParquetColumnMapping,\n OrcColumnMapping,\n W3CLogFileMapping,\n ValidationPolicy,\n ReportLevel,\n ReportMethod,\n ValidationImplications,\n ValidationOptions,\n DataFormat,\n /**\n * @deprecated - use IngestionMappingKind instead\n */\n IngestionMappingType: IngestionMappingKind,\n IngestionMappingKind,\n CompressionType,\n ApacheAvroColumnMapping,\n SStreamColumnMapping,\n ConstantTransformation,\n FieldTransformation,\n ColumnMapping,\n};\n\nexport { IngestionPropertiesValidationError } from \"./errors\";\n// eslint-disable-next-line no-console\n"]}
@@ -7,8 +7,8 @@ const descriptors_1 = require("./descriptors");
7
7
  const fileDescriptor_browser_1 = require("./fileDescriptor.browser");
8
8
  const ingestClientBase_1 = require("./ingestClientBase");
9
9
  class KustoIngestClient extends ingestClientBase_1.KustoIngestClientBase {
10
- constructor(kcsb, defaultProps) {
11
- super(kcsb, defaultProps, true);
10
+ constructor(kcsb, defaultProps, autoCorrectEndpoint) {
11
+ super(kcsb, defaultProps, autoCorrectEndpoint, true);
12
12
  }
13
13
  /**
14
14
  * Use string for Node.js and Blob in browser
@@ -18,12 +18,10 @@ class KustoIngestClient extends ingestClientBase_1.KustoIngestClientBase {
18
18
  const descriptor = file instanceof fileDescriptor_browser_1.FileDescriptor ? file : new fileDescriptor_browser_1.FileDescriptor(file);
19
19
  const blob = descriptor.file;
20
20
  const props = this._getMergedProps(ingestionProperties);
21
- const [fileToUpload, blockBlobClient] = await Promise.all([
22
- descriptor.prepare(),
23
- this.resourceManager.getBlockBlobClient((0, descriptors_1.generateBlobName)(descriptor, props)),
24
- ]);
25
- await blockBlobClient.uploadData(fileToUpload);
26
- return this.ingestFromBlob(new descriptors_1.BlobDescriptor(blockBlobClient.url, blob.size, descriptor.sourceId), props);
21
+ const fileToUpload = await descriptor.prepare(ingestionProperties);
22
+ const blobName = (0, descriptors_1.generateBlobName)(descriptor, props);
23
+ const blobUri = await this.uploadToBlobWithRetry(fileToUpload, blobName);
24
+ return this.ingestFromBlob(new descriptors_1.BlobDescriptor(blobUri, blob.size, descriptor.sourceId), props);
27
25
  }
28
26
  /**
29
27
  * Use Readable for Node.js and ArrayBuffer in browser
@@ -33,9 +31,8 @@ class KustoIngestClient extends ingestClientBase_1.KustoIngestClientBase {
33
31
  const props = this._getMergedProps(ingestionProperties);
34
32
  const descriptor = stream instanceof descriptors_1.StreamDescriptor ? stream : new descriptors_1.StreamDescriptor(stream);
35
33
  const blobName = (0, descriptors_1.generateBlobName)(descriptor, props);
36
- const blockBlobClient = await this.resourceManager.getBlockBlobClient(blobName);
37
- await blockBlobClient.uploadData(descriptor.stream);
38
- return this.ingestFromBlob(new descriptors_1.BlobDescriptor(blockBlobClient.url), props); // descriptor.size?
34
+ const blobUri = await this.uploadToBlobWithRetry(descriptor.stream, blobName);
35
+ return this.ingestFromBlob(new descriptors_1.BlobDescriptor(blobUri, descriptor.size, descriptor.sourceId), props);
39
36
  }
40
37
  }
41
38
  exports.KustoIngestClient = KustoIngestClient;
@@ -1 +1 @@
1
- {"version":3,"file":"ingestClient.browser.js","sourceRoot":"","sources":["../../src/ingestClient.browser.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAIlC,+CAAmF;AACnF,qEAA0D;AAI1D,yDAA2D;AAE3D,MAAa,iBAAkB,SAAQ,wCAAqB;IACxD,YAAY,IAA2C,EAAE,YAAuC;QAC5F,KAAK,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,CAAC,CAAC;IACpC,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,cAAc,CAAC,IAA2B,EAAE,mBAA8C;QAC5F,IAAI,CAAC,UAAU,EAAE,CAA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CAAC,cAAc,CAAC,IAAI,4BAAc,CAAC,eAAe,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,mBAAmB;IACnG,CAAC;CACJ;AArCD,8CAqCC;AAED,kBAAe,iBAAiB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { KustoConnectionStringBuilder } from \"azure-kusto-data\";\n\nimport { BlobDescriptor, generateBlobName, StreamDescriptor } from \"./descriptors\";\nimport { FileDescriptor } from \"./fileDescriptor.browser\";\nimport { QueueSendMessageResponse } from \"@azure/storage-queue\";\n\nimport { IngestionPropertiesInput } from \"./ingestionProperties\";\nimport { KustoIngestClientBase } from \"./ingestClientBase\";\n\nexport class KustoIngestClient extends KustoIngestClientBase {\n constructor(kcsb: string | KustoConnectionStringBuilder, defaultProps?: IngestionPropertiesInput) {\n super(kcsb, defaultProps, true);\n }\n\n /**\n * Use string for Node.js and Blob in browser\n */\n async ingestFromFile(file: Blob | FileDescriptor, ingestionProperties?: IngestionPropertiesInput): Promise<QueueSendMessageResponse> {\n this.ensureOpen();\n const descriptor = file instanceof FileDescriptor ? file : new FileDescriptor(file);\n\n const blob = descriptor.file as Blob;\n const props = this._getMergedProps(ingestionProperties);\n\n const [fileToUpload, blockBlobClient] = await Promise.all([\n descriptor.prepare(),\n this.resourceManager.getBlockBlobClient(generateBlobName(descriptor, props)),\n ]);\n\n await blockBlobClient.uploadData(fileToUpload);\n return this.ingestFromBlob(new BlobDescriptor(blockBlobClient.url, blob.size, descriptor.sourceId), props);\n }\n\n /**\n * Use Readable for Node.js and ArrayBuffer in browser\n */\n async ingestFromStream(stream: ArrayBuffer | StreamDescriptor, ingestionProperties?: IngestionPropertiesInput): Promise<QueueSendMessageResponse> {\n this.ensureOpen();\n const props = this._getMergedProps(ingestionProperties);\n const descriptor: StreamDescriptor = stream instanceof StreamDescriptor ? stream : new StreamDescriptor(stream);\n const blobName = generateBlobName(descriptor, props);\n\n const blockBlobClient = await this.resourceManager.getBlockBlobClient(blobName);\n await blockBlobClient.uploadData(descriptor.stream as ArrayBuffer);\n return this.ingestFromBlob(new BlobDescriptor(blockBlobClient.url), props); // descriptor.size?\n }\n}\n\nexport default KustoIngestClient;\n"]}
1
+ {"version":3,"file":"ingestClient.browser.js","sourceRoot":"","sources":["../../src/ingestClient.browser.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAIlC,+CAAmF;AACnF,qEAA0D;AAG1D,yDAA2D;AAG3D,MAAa,iBAAkB,SAAQ,wCAAqB;IACxD,YAAY,IAA2C,EAAE,YAAuC,EAAE,mBAA6B;QAC3H,KAAK,CAAC,IAAI,EAAE,YAAY,EAAE,mBAAmB,EAAE,IAAI,CAAC,CAAC;IACzD,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,cAAc,CAAC,IAA2B,EAAE,mBAA8C;QAC5F,IAAI,CAAC,UAAU,EAAE,CAAC;QAClB,MAAM,UAAU,GAAG,IAAI,YAAY,uCAAc,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,uCAAc,CAAC,IAAI,CAAC,CAAC;QAEpF,MAAM,IAAI,GAAG,UAAU,CAAC,IAAY,CAAC;QACrC,MAAM,KAAK,GAAG,IAAI,CAAC,eAAe,CAAC,mBAAmB,CAAC,CAAC;QAExD,MAAM,YAAY,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;QACnE,MAAM,QAAQ,GAAG,IAAA,8BAAgB,EAAC,UAAU,EAAE,KAAK,CAAC,CAAC;QAErD,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,qBAAqB,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;QAEzE,OAAO,IAAI,CAAC,cAAc,CAAC,IAAI,4BAAc,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,CAAC;IACnG,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,gBAAgB,CAAC,MAAsC,EAAE,mBAA8C;QACzG,IAAI,CAAC,UAAU,EAAE,CAAC;QAClB,MAAM,KAAK,GAAG,IAAI,CAAC,eAAe,CAAC,mBAAmB,CAAC,CAAC;QACxD,MAAM,UAAU,GAAqB,MAAM,YAAY,8BAAgB,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,8BAAgB,CAAC,MAAM,CAAC,CAAC;QAChH,MAAM,QAAQ,GAAG,IAAA,8BAAgB,EAAC,UAAU,EAAE,KAAK,CAAC,CAAC;QACrD,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,qBAAqB,CAAC,UAAU,CAAC,MAAqB,EAAE,QAAQ,CAAC,CAAC;QAC7F,OAAO,IAAI,CAAC,cAAc,CAAC,IAAI,4BAAc,CAAC,OAAO,EAAE,UAAU,CAAC,IAAI,EAAE,UAAU,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,CAAC;IACzG,CAAC;CACJ;AAlCD,8CAkCC;AAED,kBAAe,iBAAiB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { KustoConnectionStringBuilder } from \"azure-kusto-data\";\n\nimport { BlobDescriptor, generateBlobName, StreamDescriptor } from \"./descriptors\";\nimport { FileDescriptor } from \"./fileDescriptor.browser\";\n\nimport { IngestionPropertiesInput } from \"./ingestionProperties\";\nimport { KustoIngestClientBase } from \"./ingestClientBase\";\nimport { IngestionResult } from \"./ingestionResult\";\n\nexport class KustoIngestClient extends KustoIngestClientBase {\n constructor(kcsb: string | KustoConnectionStringBuilder, defaultProps?: IngestionPropertiesInput, autoCorrectEndpoint?: boolean) {\n super(kcsb, defaultProps, autoCorrectEndpoint, true);\n }\n\n /**\n * Use string for Node.js and Blob in browser\n */\n async ingestFromFile(file: Blob | FileDescriptor, ingestionProperties?: IngestionPropertiesInput): Promise<IngestionResult> {\n this.ensureOpen();\n const descriptor = file instanceof FileDescriptor ? file : new FileDescriptor(file);\n\n const blob = descriptor.file as Blob;\n const props = this._getMergedProps(ingestionProperties);\n\n const fileToUpload = await descriptor.prepare(ingestionProperties);\n const blobName = generateBlobName(descriptor, props);\n\n const blobUri = await this.uploadToBlobWithRetry(fileToUpload, blobName);\n\n return this.ingestFromBlob(new BlobDescriptor(blobUri, blob.size, descriptor.sourceId), props);\n }\n\n /**\n * Use Readable for Node.js and ArrayBuffer in browser\n */\n async ingestFromStream(stream: ArrayBuffer | StreamDescriptor, ingestionProperties?: IngestionPropertiesInput): Promise<IngestionResult> {\n this.ensureOpen();\n const props = this._getMergedProps(ingestionProperties);\n const descriptor: StreamDescriptor = stream instanceof StreamDescriptor ? stream : new StreamDescriptor(stream);\n const blobName = generateBlobName(descriptor, props);\n const blobUri = await this.uploadToBlobWithRetry(descriptor.stream as ArrayBuffer, blobName);\n return this.ingestFromBlob(new BlobDescriptor(blobUri, descriptor.size, descriptor.sourceId), props);\n }\n}\n\nexport default KustoIngestClient;\n"]}
@@ -7,8 +7,8 @@ const descriptors_1 = require("./descriptors");
7
7
  const fileDescriptor_1 = require("./fileDescriptor");
8
8
  const ingestClientBase_1 = require("./ingestClientBase");
9
9
  class KustoIngestClient extends ingestClientBase_1.KustoIngestClientBase {
10
- constructor(kcsb, defaultProps) {
11
- super(kcsb, defaultProps);
10
+ constructor(kcsb, defaultProps, autoCorrectEndpoint) {
11
+ super(kcsb, defaultProps, autoCorrectEndpoint);
12
12
  }
13
13
  /**
14
14
  * Use string in Node.JS and Blob in browser
@@ -19,9 +19,9 @@ class KustoIngestClient extends ingestClientBase_1.KustoIngestClientBase {
19
19
  const descriptor = file instanceof fileDescriptor_1.FileDescriptor ? file : new fileDescriptor_1.FileDescriptor(file);
20
20
  try {
21
21
  const blobName = (0, descriptors_1.generateBlobName)(descriptor, props);
22
- const [fileToUpload, blockBlobClient] = await Promise.all([descriptor.prepare(), this.resourceManager.getBlockBlobClient(blobName)]);
23
- await blockBlobClient.uploadFile(fileToUpload);
24
- return this.ingestFromBlob(new descriptors_1.BlobDescriptor(blockBlobClient.url, descriptor.size, descriptor.sourceId), props);
22
+ const fileToUpload = await descriptor.prepare(ingestionProperties);
23
+ const blobUri = await this.uploadToBlobWithRetry(fileToUpload, blobName);
24
+ return this.ingestFromBlob(new descriptors_1.BlobDescriptor(blobUri, descriptor.size, descriptor.sourceId), props);
25
25
  }
26
26
  finally {
27
27
  await descriptor.cleanup();
@@ -34,15 +34,10 @@ class KustoIngestClient extends ingestClientBase_1.KustoIngestClientBase {
34
34
  this.ensureOpen();
35
35
  const props = this._getMergedProps(ingestionProperties);
36
36
  const descriptor = stream instanceof descriptors_1.StreamDescriptor ? stream : new descriptors_1.StreamDescriptor(stream);
37
+ // TODO we don't gzip on stream here, just ont streamingIngestClient
37
38
  const blobName = (0, descriptors_1.generateBlobName)(descriptor, props);
38
- const blockBlobClient = await this.resourceManager.getBlockBlobClient(blobName);
39
- if (descriptor.stream instanceof Buffer) {
40
- await blockBlobClient.uploadData(descriptor.stream);
41
- }
42
- else {
43
- await blockBlobClient.uploadStream(descriptor.stream);
44
- }
45
- return this.ingestFromBlob(new descriptors_1.BlobDescriptor(blockBlobClient.url), props); // descriptor.size?
39
+ const blobUri = await this.uploadToBlobWithRetry(descriptor, blobName);
40
+ return this.ingestFromBlob(new descriptors_1.BlobDescriptor(blobUri), props); // descriptor.size?
46
41
  }
47
42
  }
48
43
  exports.KustoIngestClient = KustoIngestClient;
@@ -1 +1 @@
1
- {"version":3,"file":"ingestClient.js","sourceRoot":"","sources":["../../src/ingestClient.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAIlC,+CAAmF;AACnF,qDAAkD;AAKlD,yDAA2D;AAG3D,MAAa,iBAAkB,SAAQ,wCAAqB;IACxD,YAAY,IAA2C,EAAE,YAAuC;QAC5F,KAAK,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;IAC9B,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,cAAc,CAAC,IAAoC,EA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C,QAAQ,CAAC,CAAC;QAChF,IAAI,UAAU,CAAC,MAAM,YAAY,MAAM,EAAE;YACrC,MAAM,eAAe,CAAC,UAAU,CAAC,UAAU,CAAC,MAAgB,CAAC,CAAC;SACjE;aAAM;YACH,MAAM,eAAe,CAAC,YAAY,CAAC,UAAU,CAAC,MAAkB,CAAC,CAAC;SACrE;QAED,OAAO,IAAI,CAAC,cAAc,CAAC,IAAI,4BAAc,CAAC,eAAe,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,mBAAmB;IACnG,CAAC;CACJ;AA9CD,8CA8CC;AAED,kBAAe,iBAAiB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { KustoConnectionStringBuilder } from \"azure-kusto-data\";\n\nimport { BlobDescriptor, generateBlobName, StreamDescriptor } from \"./descriptors\";\nimport { FileDescriptor } from \"./fileDescriptor\";\n\nimport { QueueSendMessageResponse } from \"@azure/storage-queue\";\n\nimport { IngestionPropertiesInput } from \"./ingestionProperties\";\nimport { KustoIngestClientBase } from \"./ingestClientBase\";\nimport { Readable } from \"stream\";\n\nexport class KustoIngestClient extends KustoIngestClientBase {\n constructor(kcsb: string | KustoConnectionStringBuilder, defaultProps?: IngestionPropertiesInput) {\n super(kcsb, defaultProps);\n }\n\n /**\n * Use string in Node.JS and Blob in browser\n */\n async ingestFromFile(file: FileDescriptor | string | Blob, ingestionProperties?: IngestionPropertiesInput): Promise<QueueSendMessageResponse> {\n this.ensureOpen();\n const props = this._getMergedProps(ingestionProperties);\n\n const descriptor = file instanceof FileDescriptor ? file : new FileDescriptor(file);\n\n try {\n const blobName = generateBlobName(descriptor, props);\n const [fileToUpload, blockBlobClient] = await Promise.all([descriptor.prepare(), this.resourceManager.getBlockBlobClient(blobName)]);\n await blockBlobClient.uploadFile(fileToUpload);\n return this.ingestFromBlob(new BlobDescriptor(blockBlobClient.url, descriptor.size, descriptor.sourceId), props);\n } finally {\n await descriptor.cleanup();\n }\n }\n\n /**\n * Use Readable in Node.JS and ArrayBuffer in browser\n */\n async ingestFromStream(\n stream: StreamDescriptor | Readable | ArrayBuffer,\n ingestionProperties?: IngestionPropertiesInput\n ): Promise<QueueSendMessageResponse> {\n this.ensureOpen();\n const props = this._getMergedProps(ingestionProperties);\n const descriptor: StreamDescriptor = stream instanceof StreamDescriptor ? stream : new StreamDescriptor(stream);\n\n const blobName = generateBlobName(descriptor, props);\n\n const blockBlobClient = await this.resourceManager.getBlockBlobClient(blobName);\n if (descriptor.stream instanceof Buffer) {\n await blockBlobClient.uploadData(descriptor.stream as Buffer);\n } else {\n await blockBlobClient.uploadStream(descriptor.stream as Readable);\n }\n\n return this.ingestFromBlob(new BlobDescriptor(blockBlobClient.url), props); // descriptor.size?\n }\n}\n\nexport default KustoIngestClient;\n"]}
1
+ {"version":3,"file":"ingestClient.js","sourceRoot":"","sources":["../../src/ingestClient.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAIlC,+CAAmF;AACnF,qDAAkD;AAGlD,yDAA2D;AAI3D,MAAa,iBAAkB,SAAQ,wCAAqB;IACxD,YAAY,IAA2C,EAAE,YAAuC,EAAE,mBAA6B;QAC3H,KAAK,CAAC,IAAI,EAAE,YAAY,EAAE,mBAAmB,CAAC,CAAC;IACnD,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,cAAc,CAAC,IAAoC,EAAE,mBAA8C;QACrG,IAAI,CAAC,UAAU,EAAE,CAAC;QAClB,MAAM,KAAK,GAAG,IAAI,CAAC,eAAe,CAAC,mBAAmB,CAAC,CAAC;QAExD,MAAM,UAAU,GAAG,IAAI,YAAY,+BAAc,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,+BAAc,CAAC,IAAI,CAAC,CAAC;QAEpF,IAAI;YACA,MAAM,QAAQ,GAAG,IAAA,8BAAgB,EAAC,UAAU,EAAE,KAAK,CAAC,CAAC;YACrD,MAAM,YAAY,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;YACnE,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,qBAAqB,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;YACzE,OAAO,IAAI,CAAC,cAAc,CAAC,IAAI,4BAAc,CAAC,OAAO,EAAE,UAAU,CAAC,IAAI,EAAE,UAAU,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,CAAC;SACxG;gBAAS;YACN,MAAM,UAAU,CAAC,OAAO,EAAE,CAAC;SAC9B;IACL,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,gBAAgB,CAAC,MAAiD,EAAE,mBAA8C;QACpH,IAAI,CAAC,UAAU,EAAE,CAAC;QAClB,MAAM,KAAK,GAAG,IAAI,CAAC,eAAe,CAAC,mBAAmB,CAAC,CAAC;QACxD,MAAM,UAAU,GAAqB,MAAM,YAAY,8BAAgB,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,8BAAgB,CAAC,MAAM,CAAC,CAAC;QAChH,oEAAoE;QACpE,MAAM,QAAQ,GAAG,IAAA,8BAAgB,EAAC,UAAU,EAAE,KAAK,CAAC,CAAC;QAErD,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,qBAAqB,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QAEvE,OAAO,IAAI,CAAC,cAAc,CAAC,IAAI,4BAAc,CAAC,OAAO,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,mBAAmB;IACvF,CAAC;CACJ;AAtCD,8CAsCC;AAED,kBAAe,iBAAiB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { KustoConnectionStringBuilder } from \"azure-kusto-data\";\n\nimport { BlobDescriptor, generateBlobName, StreamDescriptor } from \"./descriptors\";\nimport { FileDescriptor } from \"./fileDescriptor\";\n\nimport { IngestionPropertiesInput } from \"./ingestionProperties\";\nimport { KustoIngestClientBase } from \"./ingestClientBase\";\nimport { Readable } from \"stream\";\nimport { IngestionResult } from \"./ingestionResult\";\n\nexport class KustoIngestClient extends KustoIngestClientBase {\n constructor(kcsb: string | KustoConnectionStringBuilder, defaultProps?: IngestionPropertiesInput, autoCorrectEndpoint?: boolean) {\n super(kcsb, defaultProps, autoCorrectEndpoint);\n }\n\n /**\n * Use string in Node.JS and Blob in browser\n */\n async ingestFromFile(file: FileDescriptor | string | Blob, ingestionProperties?: IngestionPropertiesInput): Promise<IngestionResult> {\n this.ensureOpen();\n const props = this._getMergedProps(ingestionProperties);\n\n const descriptor = file instanceof FileDescriptor ? file : new FileDescriptor(file);\n\n try {\n const blobName = generateBlobName(descriptor, props);\n const fileToUpload = await descriptor.prepare(ingestionProperties);\n const blobUri = await this.uploadToBlobWithRetry(fileToUpload, blobName);\n return this.ingestFromBlob(new BlobDescriptor(blobUri, descriptor.size, descriptor.sourceId), props);\n } finally {\n await descriptor.cleanup();\n }\n }\n\n /**\n * Use Readable in Node.JS and ArrayBuffer in browser\n */\n async ingestFromStream(stream: StreamDescriptor | Readable | ArrayBuffer, ingestionProperties?: IngestionPropertiesInput): Promise<IngestionResult> {\n this.ensureOpen();\n const props = this._getMergedProps(ingestionProperties);\n const descriptor: StreamDescriptor = stream instanceof StreamDescriptor ? stream : new StreamDescriptor(stream);\n // TODO we don't gzip on stream here, just ont streamingIngestClient\n const blobName = generateBlobName(descriptor, props);\n\n const blobUri = await this.uploadToBlobWithRetry(descriptor, blobName);\n\n return this.ingestFromBlob(new BlobDescriptor(blobUri), props); // descriptor.size?\n }\n}\n\nexport default KustoIngestClient;\n"]}
@@ -7,33 +7,116 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
8
  exports.KustoIngestClientBase = void 0;
9
9
  const azure_kusto_data_1 = require("azure-kusto-data");
10
- const descriptors_1 = require("./descriptors");
11
10
  const resourceManager_1 = __importDefault(require("./resourceManager"));
12
11
  const ingestionBlobInfo_1 = __importDefault(require("./ingestionBlobInfo"));
12
+ const storage_blob_1 = require("@azure/storage-blob");
13
13
  const storage_queue_1 = require("@azure/storage-queue");
14
+ const ingestionProperties_1 = require("./ingestionProperties");
14
15
  const abstractKustoClient_1 = require("./abstractKustoClient");
16
+ const ingestionResult_1 = require("./ingestionResult");
17
+ const descriptors_1 = require("./descriptors");
15
18
  class KustoIngestClientBase extends abstractKustoClient_1.AbstractKustoClient {
16
- constructor(kcsb, defaultProps, isBrowser) {
19
+ constructor(kcsb, defaultProps, autoCorrectEndpoint = true, isBrowser) {
17
20
  super(defaultProps);
21
+ if (typeof kcsb === "string") {
22
+ kcsb = new azure_kusto_data_1.KustoConnectionStringBuilder(kcsb);
23
+ }
24
+ if (autoCorrectEndpoint) {
25
+ kcsb.dataSource = this.getIngestionEndpoint(kcsb.dataSource);
26
+ }
18
27
  const kustoClient = new azure_kusto_data_1.Client(kcsb);
19
28
  this.resourceManager = new resourceManager_1.default(kustoClient, isBrowser);
20
29
  this.defaultDatabase = kustoClient.defaultDatabase;
30
+ const clientDetails = kcsb.clientDetails();
31
+ this.applicationForTracing = clientDetails.applicationNameForTracing;
32
+ this.clientVersionForTracing = clientDetails.versionForTracing;
21
33
  }
22
- async ingestFromBlob(blob, ingestionProperties) {
34
+ async ingestFromBlob(blob, ingestionProperties, maxRetries = KustoIngestClientBase.MaxNumberOfRetryAttempts) {
23
35
  this.ensureOpen();
24
36
  const props = this._getMergedProps(ingestionProperties);
25
37
  const descriptor = blob instanceof descriptors_1.BlobDescriptor ? blob : new descriptors_1.BlobDescriptor(blob);
38
+ const authorizationContext = await this.resourceManager.getAuthorizationContext();
39
+ const ingestionBlobInfo = new ingestionBlobInfo_1.default(descriptor, props, authorizationContext, this.applicationForTracing, this.clientVersionForTracing);
40
+ const reportToTable = props.reportLevel !== ingestionProperties_1.ReportLevel.DoNotReport && props.reportMethod !== ingestionProperties_1.ReportMethod.Queue;
41
+ if (reportToTable) {
42
+ const statusTableClient = await this.resourceManager.createStatusTable();
43
+ const status = this.createStatusObject(props, ingestionResult_1.OperationStatus.Pending, ingestionBlobInfo);
44
+ await (0, ingestionResult_1.putRecordInTable)(statusTableClient, Object.assign(Object.assign({}, status), { partitionKey: ingestionBlobInfo.Id, rowKey: ingestionBlobInfo.Id }));
45
+ const desc = new ingestionResult_1.IngestionStatusInTableDescription(statusTableClient.url, ingestionBlobInfo.Id, ingestionBlobInfo.Id);
46
+ ingestionBlobInfo.IngestionStatusInTable = desc;
47
+ await this.sendQueueMessage(maxRetries, ingestionBlobInfo);
48
+ return new ingestionResult_1.TableReportIngestionResult(desc, statusTableClient);
49
+ }
50
+ await this.sendQueueMessage(maxRetries, ingestionBlobInfo);
51
+ return new ingestionResult_1.IngestionStatusResult(this.createStatusObject(props, ingestionResult_1.OperationStatus.Queued, ingestionBlobInfo));
52
+ }
53
+ async sendQueueMessage(maxRetries, blobInfo) {
26
54
  const queues = await this.resourceManager.getIngestionQueues();
27
55
  if (queues == null) {
28
56
  throw new Error("Failed to get queues");
29
57
  }
30
- const authorizationContext = await this.resourceManager.getAuthorizationContext();
31
- const queueDetails = queues[Math.floor(Math.random() * queues.length)];
32
- const queueClient = new storage_queue_1.QueueClient(queueDetails.uri);
33
- const ingestionBlobInfo = new ingestionBlobInfo_1.default(descriptor, props, authorizationContext);
34
- const ingestionBlobInfoJson = JSON.stringify(ingestionBlobInfo);
58
+ const ingestionBlobInfoJson = JSON.stringify(blobInfo);
35
59
  const encoded = Buffer.from(ingestionBlobInfoJson).toString("base64");
36
- return queueClient.sendMessage(encoded);
60
+ const retryCount = Math.min(maxRetries, queues.length);
61
+ for (let i = 0; i < retryCount; i++) {
62
+ const queueClient = new storage_queue_1.QueueClient(queues[i].uri);
63
+ try {
64
+ const queueResponse = await queueClient.sendMessage(encoded);
65
+ this.resourceManager.reportResourceUsageResult(queueClient.accountName, true);
66
+ return queueResponse;
67
+ }
68
+ catch (_) {
69
+ this.resourceManager.reportResourceUsageResult(queueClient.accountName, false);
70
+ }
71
+ }
72
+ throw new Error("Failed to send message to queue.");
73
+ }
74
+ createStatusObject(props, status, ingestionBlobInfo) {
75
+ const time = Date.now().toString();
76
+ return {
77
+ Status: status,
78
+ Timestamp: time,
79
+ IngestionSourceId: ingestionBlobInfo.Id,
80
+ IngestionSourcePath: ingestionBlobInfo.BlobPath.split(/[?;]/)[0],
81
+ Database: props.database,
82
+ Table: props.table,
83
+ UpdatedOn: time,
84
+ Details: "",
85
+ };
86
+ }
87
+ async uploadToBlobWithRetry(descriptor, blobName, maxRetries = KustoIngestClientBase.MaxNumberOfRetryAttempts) {
88
+ const containers = await this.resourceManager.getContainers();
89
+ if (containers == null || containers.length === 0) {
90
+ throw new Error("Failed to get containers");
91
+ }
92
+ const retryCount = Math.min(maxRetries, containers.length);
93
+ // Go over all containers and try to upload the file to the first one that succeeds
94
+ for (let i = 0; i < retryCount; i++) {
95
+ const containerClient = new storage_blob_1.ContainerClient(containers[i].uri);
96
+ const blockBlobClient = containerClient.getBlockBlobClient(blobName);
97
+ try {
98
+ if (typeof descriptor == "string") {
99
+ await blockBlobClient.uploadFile(descriptor);
100
+ }
101
+ else if (descriptor instanceof descriptors_1.StreamDescriptor) {
102
+ if (descriptor.stream instanceof Buffer) {
103
+ await blockBlobClient.uploadData(descriptor.stream);
104
+ }
105
+ else {
106
+ await blockBlobClient.uploadStream(descriptor.stream);
107
+ }
108
+ }
109
+ else {
110
+ await blockBlobClient.uploadData(descriptor);
111
+ }
112
+ this.resourceManager.reportResourceUsageResult(containerClient.accountName, true);
113
+ return blockBlobClient.url;
114
+ }
115
+ catch (ex) {
116
+ this.resourceManager.reportResourceUsageResult(containerClient.accountName, false);
117
+ }
118
+ }
119
+ throw new Error("Failed to upload to blob.");
37
120
  }
38
121
  close() {
39
122
  if (!this._isClosed) {
@@ -43,5 +126,6 @@ class KustoIngestClientBase extends abstractKustoClient_1.AbstractKustoClient {
43
126
  }
44
127
  }
45
128
  exports.KustoIngestClientBase = KustoIngestClientBase;
129
+ KustoIngestClientBase.MaxNumberOfRetryAttempts = 3;
46
130
  exports.default = KustoIngestClientBase;
47
131
  //# sourceMappingURL=ingestClientBase.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ingestClientBase.js","sourceRoot":"","sources":["../../src/ingestClientBase.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;;;AAElC,uDAAuF;AAEvF,+CAA+C;AAE/C,wEAAgD;AAEhD,4EAAoD;AAEpD,wDAA6E;AAG7E,+DAA4D;AAE5D,MAAsB,qBAAsB,SAAQ,yCAAmB;IAGnE,YAAY,IAA2C,EAAE,YAAuC,EAAE,SAAmB;QACjH,KAAK,CAAC,YAAY,CAAC,CAAC;QACpB,MAAM,WAAW,GAAG,IAAI,yBAAW,CAAC,IAAI,CAAC,CAAC;QAC1C,IAAI,CAAC,eAAe,GAAG,IAAI,yBAAe,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;QACnE,IAAI,CAAC,eAAe,GAAG,WAAW,CAAC,eAAe,CAAC;IACvD,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,IAA6B,EAAE,mBAA8C;QAC9F,IAAI,CAAC,UAAU,EAAE,CAAC;QAElB,MAAM,KAAK,GAAG,IAAI,CAAC,eAAe,CAAC,mBAAmB,CAAC,CAAC;QAExD,MAAM,UAAU,GAAG,IAAI,YAAY,4BAAc,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,4BAAc,CAAC,IAAI,CAAC,CAAC;QACpF,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,kBAAkB,EAAE,CAAC;QAC/D,IAAI,MAAM,IAAI,IAAI,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;SAC3C;QAED,MAAM,oBAAoB,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,uBAAuB,EAAE,CAAC;QAElF,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;QAEvE,MAAM,WAAW,GAAG,IAAI,2BAAW,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;QAEtD,MAAM,iBAAiB,GAAG,IAAI,2BAAiB,CAAC,UAAU,EAAE,KAAK,EAAE,oBAAoB,CAAC,CAAC;QACzF,MAAM,qBAAqB,GAAG,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC;QAChE,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAEtE,OAAO,WAAW,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IAC5C,CAAC;IAED,KAAK;QACD,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;YACjB,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC;SAChC;QACD,KAAK,CAAC,KAAK,EAAE,CAAC;IAClB,CAAC;CACJ;AAxCD,sDAwCC;AAED,kBAAe,qBAAqB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { Client as KustoClient, KustoConnectionStringBuilder } from \"azure-kusto-data\";\n\nimport { BlobDescriptor } from \"./descriptors\";\n\nimport ResourceManager from \"./resourceManager\";\n\nimport IngestionBlobInfo from \"./ingestionBlobInfo\";\n\nimport { QueueClient, QueueSendMessageResponse } from \"@azure/storage-queue\";\n\nimport { IngestionPropertiesInput } from \"./ingestionProperties\";\nimport { AbstractKustoClient } from \"./abstractKustoClient\";\n\nexport abstract class KustoIngestClientBase extends AbstractKustoClient {\n resourceManager: ResourceManager;\n\n constructor(kcsb: string | KustoConnectionStringBuilder, defaultProps?: IngestionPropertiesInput, isBrowser?: boolean) {\n super(defaultProps);\n const kustoClient = new KustoClient(kcsb);\n this.resourceManager = new ResourceManager(kustoClient, isBrowser);\n this.defaultDatabase = kustoClient.defaultDatabase;\n }\n\n async ingestFromBlob(blob: string | BlobDescriptor, ingestionProperties?: IngestionPropertiesInput): Promise<QueueSendMessageResponse> {\n this.ensureOpen();\n\n const props = this._getMergedProps(ingestionProperties);\n\n const descriptor = blob instanceof BlobDescriptor ? blob : new BlobDescriptor(blob);\n const queues = await this.resourceManager.getIngestionQueues();\n if (queues == null) {\n throw new Error(\"Failed to get queues\");\n }\n\n const authorizationContext = await this.resourceManager.getAuthorizationContext();\n\n const queueDetails = queues[Math.floor(Math.random() * queues.length)];\n\n const queueClient = new QueueClient(queueDetails.uri);\n\n const ingestionBlobInfo = new IngestionBlobInfo(descriptor, props, authorizationContext);\n const ingestionBlobInfoJson = JSON.stringify(ingestionBlobInfo);\n const encoded = Buffer.from(ingestionBlobInfoJson).toString(\"base64\");\n\n return queueClient.sendMessage(encoded);\n }\n\n close() {\n if (!this._isClosed) {\n this.resourceManager.close();\n }\n super.close();\n }\n}\n\nexport default KustoIngestClientBase;\n"]}
1
+ {"version":3,"file":"ingestClientBase.js","sourceRoot":"","sources":["../../src/ingestClientBase.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;;;AAElC,uDAAuF;AAEvF,wEAAgD;AAEhD,4EAAoD;AACpD,sDAAsD;AAEtD,wDAAmD;AAEnD,+DAAiH;AACjH,+DAA4D;AAC5D,uDAQ2B;AAG3B,+CAAiE;AAEjE,MAAsB,qBAAsB,SAAQ,yCAAmB;IAMnE,YACI,IAA2C,EAC3C,YAAuC,EACvC,sBAA+B,IAAI,EACnC,SAAmB;QAEnB,KAAK,CAAC,YAAY,CAAC,CAAC;QACpB,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;YAC1B,IAAI,GAAG,IAAI,+CAA4B,CAAC,IAAI,CAAC,CAAC;SACjD;QACD,IAAI,mBAAmB,EAAE;YACrB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;SAChE;QACD,MAAM,WAAW,GAAG,IAAI,yBAAW,CA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AK,EAAE,CAAC;IAClB,CAAC;;AA1IL,sDA2IC;AAvImB,8CAAwB,GAAG,CAAC,CAAC;AAyIjD,kBAAe,qBAAqB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { Client as KustoClient, KustoConnectionStringBuilder } from \"azure-kusto-data\";\n\nimport ResourceManager from \"./resourceManager\";\n\nimport IngestionBlobInfo from \"./ingestionBlobInfo\";\nimport { ContainerClient } from \"@azure/storage-blob\";\n\nimport { QueueClient } from \"@azure/storage-queue\";\n\nimport IngestionProperties, { IngestionPropertiesInput, ReportLevel, ReportMethod } from \"./ingestionProperties\";\nimport { AbstractKustoClient } from \"./abstractKustoClient\";\nimport {\n IngestionStatus,\n TableReportIngestionResult,\n IngestionResult,\n IngestionStatusInTableDescription,\n IngestionStatusResult,\n OperationStatus,\n putRecordInTable,\n} from \"./ingestionResult\";\nimport { Readable } from \"stream\";\n\nimport { BlobDescriptor, StreamDescriptor } from \"./descriptors\";\n\nexport abstract class KustoIngestClientBase extends AbstractKustoClient {\n resourceManager: ResourceManager;\n applicationForTracing: string | null;\n clientVersionForTracing: string | null;\n static readonly MaxNumberOfRetryAttempts = 3;\n\n constructor(\n kcsb: string | KustoConnectionStringBuilder,\n defaultProps?: IngestionPropertiesInput,\n autoCorrectEndpoint: boolean = true,\n isBrowser?: boolean\n ) {\n super(defaultProps);\n if (typeof kcsb === \"string\") {\n kcsb = new KustoConnectionStringBuilder(kcsb);\n }\n if (autoCorrectEndpoint) {\n kcsb.dataSource = this.getIngestionEndpoint(kcsb.dataSource);\n }\n const kustoClient = new KustoClient(kcsb);\n this.resourceManager = new ResourceManager(kustoClient, isBrowser);\n this.defaultDatabase = kustoClient.defaultDatabase;\n const clientDetails = kcsb.clientDetails();\n this.applicationForTracing = clientDetails.applicationNameForTracing;\n this.clientVersionForTracing = clientDetails.versionForTracing;\n }\n\n async ingestFromBlob(\n blob: string | BlobDescriptor,\n ingestionProperties?: IngestionPropertiesInput,\n maxRetries: number = KustoIngestClientBase.MaxNumberOfRetryAttempts\n ): Promise<IngestionResult> {\n this.ensureOpen();\n const props = this._getMergedProps(ingestionProperties);\n\n const descriptor = blob instanceof BlobDescriptor ? blob : new BlobDescriptor(blob);\n\n const authorizationContext = await this.resourceManager.getAuthorizationContext();\n const ingestionBlobInfo = new IngestionBlobInfo(descriptor, props, authorizationContext, this.applicationForTracing, this.clientVersionForTracing);\n\n const reportToTable = props.reportLevel !== ReportLevel.DoNotReport && props.reportMethod !== ReportMethod.Queue;\n\n if (reportToTable) {\n const statusTableClient = await this.resourceManager.createStatusTable();\n const status = this.createStatusObject(props, OperationStatus.Pending, ingestionBlobInfo);\n await putRecordInTable(statusTableClient, { ...status, partitionKey: ingestionBlobInfo.Id, rowKey: ingestionBlobInfo.Id });\n\n const desc = new IngestionStatusInTableDescription(statusTableClient.url, ingestionBlobInfo.Id, ingestionBlobInfo.Id);\n ingestionBlobInfo.IngestionStatusInTable = desc;\n await this.sendQueueMessage(maxRetries, ingestionBlobInfo);\n return new TableReportIngestionResult(desc, statusTableClient);\n }\n\n await this.sendQueueMessage(maxRetries, ingestionBlobInfo);\n return new IngestionStatusResult(this.createStatusObject(props, OperationStatus.Queued, ingestionBlobInfo));\n }\n\n private async sendQueueMessage(maxRetries: number, blobInfo: IngestionBlobInfo) {\n const queues = await this.resourceManager.getIngestionQueues();\n if (queues == null) {\n throw new Error(\"Failed to get queues\");\n }\n const ingestionBlobInfoJson = JSON.stringify(blobInfo);\n const encoded = Buffer.from(ingestionBlobInfoJson).toString(\"base64\");\n const retryCount = Math.min(maxRetries, queues.length);\n\n for (let i = 0; i < retryCount; i++) {\n const queueClient = new QueueClient(queues[i].uri);\n try {\n const queueResponse = await queueClient.sendMessage(encoded);\n this.resourceManager.reportResourceUsageResult(queueClient.accountName, true);\n return queueResponse;\n } catch (_) {\n this.resourceManager.reportResourceUsageResult(queueClient.accountName, false);\n }\n }\n\n throw new Error(\"Failed to send message to queue.\");\n }\n\n private createStatusObject(props: IngestionProperties, status: OperationStatus, ingestionBlobInfo: IngestionBlobInfo): IngestionStatus {\n const time = Date.now().toString();\n return {\n Status: status,\n Timestamp: time,\n IngestionSourceId: ingestionBlobInfo.Id,\n IngestionSourcePath: ingestionBlobInfo.BlobPath.split(/[?;]/)[0],\n Database: props.database,\n Table: props.table,\n UpdatedOn: time,\n Details: \"\",\n } as IngestionStatus;\n }\n\n async uploadToBlobWithRetry(\n descriptor: string | Blob | ArrayBuffer | StreamDescriptor,\n blobName: string,\n maxRetries: number = KustoIngestClientBase.MaxNumberOfRetryAttempts\n ): Promise<string> {\n const containers = await this.resourceManager.getContainers();\n\n if (containers == null || containers.length === 0) {\n throw new Error(\"Failed to get containers\");\n }\n\n const retryCount = Math.min(maxRetries, containers.length);\n\n // Go over all containers and try to upload the file to the first one that succeeds\n for (let i = 0; i < retryCount; i++) {\n const containerClient = new ContainerClient(containers[i].uri);\n const blockBlobClient = containerClient.getBlockBlobClient(blobName);\n try {\n if (typeof descriptor == \"string\") {\n await blockBlobClient.uploadFile(descriptor);\n } else if (descriptor instanceof StreamDescriptor) {\n if (descriptor.stream instanceof Buffer) {\n await blockBlobClient.uploadData(descriptor.stream as Buffer);\n } else {\n await blockBlobClient.uploadStream(descriptor.stream as Readable);\n }\n } else {\n await blockBlobClient.uploadData(descriptor);\n }\n this.resourceManager.reportResourceUsageResult(containerClient.accountName, true);\n return blockBlobClient.url;\n } catch (ex) {\n this.resourceManager.reportResourceUsageResult(containerClient.accountName, false);\n }\n }\n\n throw new Error(\"Failed to upload to blob.\");\n }\n\n close() {\n if (!this._isClosed) {\n this.resourceManager.close();\n }\n super.close();\n }\n}\n\nexport default KustoIngestClientBase;\n"]}
@@ -5,8 +5,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
5
5
  exports.IngestionBlobInfo = void 0;
6
6
  const uuid_1 = require("uuid");
7
7
  class IngestionBlobInfo {
8
- constructor(blobDescriptor, ingestionProperties, authContext = null) {
8
+ constructor(blobDescriptor, ingestionProperties, authContext = null, applicationForTracing = null, clientVersionForTracing = null) {
9
9
  var _a, _b, _c, _d, _e;
10
+ this.IngestionStatusInTable = null;
11
+ this.ApplicationForTracing = null;
12
+ this.ClientVersionForTracing = null;
10
13
  this.BlobPath = blobDescriptor.path;
11
14
  this.RawDataSize = blobDescriptor.size;
12
15
  this.DatabaseName = (_a = ingestionProperties.database) !== null && _a !== void 0 ? _a : null;
@@ -18,6 +21,8 @@ class IngestionBlobInfo {
18
21
  this.ReportMethod = (_e = ingestionProperties.reportMethod) !== null && _e !== void 0 ? _e : null;
19
22
  this.SourceMessageCreationTime = new Date();
20
23
  this.Id = blobDescriptor.sourceId || (0, uuid_1.v4)();
24
+ this.ApplicationForTracing = applicationForTracing;
25
+ this.ClientVersionForTracing = clientVersionForTracing;
21
26
  const additionalProperties = ingestionProperties.additionalProperties || {};
22
27
  additionalProperties.authorizationContext = authContext;
23
28
  const tags = [];