azure-kusto-ingest 6.0.2 → 7.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/dist-esm/src/abstractKustoClient.js +8 -15
  2. package/dist-esm/src/abstractKustoClient.js.map +1 -1
  3. package/dist-esm/src/columnMappings.js +22 -34
  4. package/dist-esm/src/columnMappings.js.map +1 -1
  5. package/dist-esm/src/descriptors.js +15 -27
  6. package/dist-esm/src/descriptors.js.map +1 -1
  7. package/dist-esm/src/errors.js +1 -5
  8. package/dist-esm/src/errors.js.map +1 -1
  9. package/dist-esm/src/fileDescriptor.browser.js +9 -16
  10. package/dist-esm/src/fileDescriptor.browser.js.map +1 -1
  11. package/dist-esm/src/fileDescriptor.js +19 -26
  12. package/dist-esm/src/fileDescriptor.js.map +1 -1
  13. package/dist-esm/src/index.js +38 -73
  14. package/dist-esm/src/index.js.map +1 -1
  15. package/dist-esm/src/ingestClient.browser.js +11 -15
  16. package/dist-esm/src/ingestClient.browser.js.map +1 -1
  17. package/dist-esm/src/ingestClient.js +11 -15
  18. package/dist-esm/src/ingestClient.js.map +1 -1
  19. package/dist-esm/src/ingestClientBase.js +25 -32
  20. package/dist-esm/src/ingestClientBase.js.map +1 -1
  21. package/dist-esm/src/ingestionBlobInfo.js +4 -8
  22. package/dist-esm/src/ingestionBlobInfo.js.map +1 -1
  23. package/dist-esm/src/ingestionProperties.js +29 -36
  24. package/dist-esm/src/ingestionProperties.js.map +1 -1
  25. package/dist-esm/src/ingestionResult.js +10 -17
  26. package/dist-esm/src/ingestionResult.js.map +1 -1
  27. package/dist-esm/src/managedStreamingIngestClient.js +29 -34
  28. package/dist-esm/src/managedStreamingIngestClient.js.map +1 -1
  29. package/dist-esm/src/rankedStorageAccount.js +1 -5
  30. package/dist-esm/src/rankedStorageAccount.js.map +1 -1
  31. package/dist-esm/src/rankedStorageAccountSet.js +3 -7
  32. package/dist-esm/src/rankedStorageAccountSet.js.map +1 -1
  33. package/dist-esm/src/resourceManager.js +24 -31
  34. package/dist-esm/src/resourceManager.js.map +1 -1
  35. package/dist-esm/src/retry.js +3 -8
  36. package/dist-esm/src/retry.js.map +1 -1
  37. package/dist-esm/src/status.js +6 -11
  38. package/dist-esm/src/status.js.map +1 -1
  39. package/dist-esm/src/statusQ.js +3 -7
  40. package/dist-esm/src/statusQ.js.map +1 -1
  41. package/dist-esm/src/streamUtils.browser.js +8 -15
  42. package/dist-esm/src/streamUtils.browser.js.map +1 -1
  43. package/dist-esm/src/streamUtils.js +18 -28
  44. package/dist-esm/src/streamUtils.js.map +1 -1
  45. package/dist-esm/src/streamingIngestClient.browser.js +9 -11
  46. package/dist-esm/src/streamingIngestClient.browser.js.map +1 -1
  47. package/dist-esm/src/streamingIngestClient.js +12 -17
  48. package/dist-esm/src/streamingIngestClient.js.map +1 -1
  49. package/dist-esm/src/streamingIngestClientBase.js +7 -11
  50. package/dist-esm/src/streamingIngestClientBase.js.map +1 -1
  51. package/package.json +10 -6
  52. package/types/src/abstractKustoClient.d.ts +2 -2
  53. package/types/src/columnMappings.d.ts +1 -1
  54. package/types/src/descriptors.d.ts +2 -2
  55. package/types/src/fileDescriptor.browser.d.ts +2 -2
  56. package/types/src/fileDescriptor.d.ts +2 -2
  57. package/types/src/index.d.ts +13 -13
  58. package/types/src/ingestClient.browser.d.ts +5 -5
  59. package/types/src/ingestClient.d.ts +6 -6
  60. package/types/src/ingestClientBase.d.ts +5 -5
  61. package/types/src/ingestionBlobInfo.d.ts +3 -3
  62. package/types/src/ingestionProperties.d.ts +1 -1
  63. package/types/src/managedStreamingIngestClient.d.ts +6 -6
  64. package/types/src/rankedStorageAccountSet.d.ts +1 -1
  65. package/types/src/status.d.ts +2 -2
  66. package/types/src/statusQ.d.ts +2 -2
  67. package/types/src/streamUtils.browser.d.ts +3 -3
  68. package/types/src/streamUtils.d.ts +3 -3
  69. package/types/src/streamingIngestClient.browser.d.ts +4 -4
  70. package/types/src/streamingIngestClient.d.ts +5 -5
  71. package/types/src/streamingIngestClientBase.d.ts +3 -3
@@ -1 +1 @@
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,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;QACnD,MAAM,aAAa,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;QAC3C,IAAI,CAAC,qBAAqB,GAAG,aAAa,CAAC,yBAAyB,CAAC;QACrE,IAAI,CAAC,uBAAuB,GAAG,aAAa,CAAC,iBAAiB,CAAC;IACnE,CAAC;IAED,KAAK,CAAC,cAAc,CAChB,IAA6B,EAC7B,mBAA8C,EAC9C,aAAqB,qBAAqB,CAAC,wBAAwB;QAEnE,IAAI,CAAC,UAAU,EAAE,CAAC;QAClB,MAAM,KAAK,GAAG,IAAI,CAAC,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AE;oBAC/C,IAAI,UAAU,CAAC,MAAM,YAAY,MAAM,EAAE;wBACrC,MAAM,eAAe,CAAC,UAAU,CAAC,UAAU,CAAC,MAAgB,CAAC,CAAC;qBACjE;yBAAM;wBACH,MAAM,eAAe,CAAC,YAAY,CAAC,UAAU,CAAC,MAAkB,CAAC,CAAC;qBACrE;iBACJ;qBAAM;oBACH,MAAM,eAAe,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;iBAChD;gBACD,IAAI,CAAC,eAAe,CAAC,yBAAyB,CAAC,eAAe,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;gBAClF,OAAO,eAAe,CAAC,GAAG,CAAC;aAC9B;YAAC,OAAO,EAAE,EAAE;gBACT,IAAI,CAAC,eAAe,CAAC,yBAAyB,CAAC,eAAe,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;aACtF;SACJ;QAED,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;IACjD,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;;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"]}
1
+ {"version":3,"file":"ingestClientBase.js","sourceRoot":"","sources":["../../src/ingestClientBase.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,MAAM,IAAI,WAAW,EAAE,4BAA4B,EAAE,MAAM,kBAAkB,CAAC;AAEvF,OAAO,eAAe,MAAM,sBAAsB,CAAC;AAEnD,OAAO,iBAAiB,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,OAA4B,EAA4B,WAAW,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACpH,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAEH,0BAA0B,EAE1B,iCAAiC,EACjC,qBAAqB,EACrB,eAAe,EACf,gBAAgB,GACnB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpE,MAAM,O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W,EAAE,IAAI,CAAC,CAAC;gBAClF,OAAO,eAAe,CAAC,GAAG,CAAC;aAC9B;YAAC,OAAO,EAAE,EAAE;gBACT,IAAI,CAAC,eAAe,CAAC,yBAAyB,CAAC,eAAe,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;aACtF;SACJ;QAED,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;IACjD,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;;AAtIe,8CAAwB,GAAG,CAAC,CAAC;AAyIjD,eAAe,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.js\";\n\nimport IngestionBlobInfo from \"./ingestionBlobInfo.js\";\nimport { ContainerClient } from \"@azure/storage-blob\";\n\nimport { QueueClient } from \"@azure/storage-queue\";\n\nimport IngestionProperties, { IngestionPropertiesInput, ReportLevel, ReportMethod } from \"./ingestionProperties.js\";\nimport { AbstractKustoClient } from \"./abstractKustoClient.js\";\nimport {\n IngestionStatus,\n TableReportIngestionResult,\n IngestionResult,\n IngestionStatusInTableDescription,\n IngestionStatusResult,\n OperationStatus,\n putRecordInTable,\n} from \"./ingestionResult.js\";\nimport { Readable } from \"stream\";\n\nimport { BlobDescriptor, StreamDescriptor } from \"./descriptors.js\";\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"]}
@@ -1,10 +1,7 @@
1
- "use strict";
2
1
  // Copyright (c) Microsoft Corporation.
3
2
  // Licensed under the MIT License.
4
- Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.IngestionBlobInfo = void 0;
6
- const uuid_1 = require("uuid");
7
- class IngestionBlobInfo {
3
+ import { v4 as uuidv4 } from "uuid";
4
+ export class IngestionBlobInfo {
8
5
  constructor(blobDescriptor, ingestionProperties, authContext = null, applicationForTracing = null, clientVersionForTracing = null) {
9
6
  var _a, _b, _c, _d, _e;
10
7
  this.IngestionStatusInTable = null;
@@ -20,7 +17,7 @@ class IngestionBlobInfo {
20
17
  this.ReportLevel = (_d = ingestionProperties.reportLevel) !== null && _d !== void 0 ? _d : null;
21
18
  this.ReportMethod = (_e = ingestionProperties.reportMethod) !== null && _e !== void 0 ? _e : null;
22
19
  this.SourceMessageCreationTime = new Date();
23
- this.Id = blobDescriptor.sourceId || (0, uuid_1.v4)();
20
+ this.Id = blobDescriptor.sourceId || uuidv4();
24
21
  this.ApplicationForTracing = applicationForTracing;
25
22
  this.ClientVersionForTracing = clientVersionForTracing;
26
23
  const additionalProperties = ingestionProperties.additionalProperties || {};
@@ -63,6 +60,5 @@ class IngestionBlobInfo {
63
60
  this.AdditionalProperties = additionalProperties;
64
61
  }
65
62
  }
66
- exports.IngestionBlobInfo = IngestionBlobInfo;
67
- exports.default = IngestionBlobInfo;
63
+ export default IngestionBlobInfo;
68
64
  //# sourceMappingURL=ingestionBlobInfo.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ingestionBlobInfo.js","sourceRoot":"","sources":["../../src/ingestionBlobInfo.ts"],"names":[],"mappings":";AAAA,uCAAu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C,oBAAoB,CAAC,gBAAgB,GAAG,mBAAmB,CAAC,gBAAgB,CAAC;SAChF;QAED,IAAI,mBAAmB,CAAC,MAAM,EAAE;YAC5B,oBAAoB,CAAC,MAAM,GAAG,mBAAmB,CAAC,MAAM,CAAC;SAC5D;QACD,IAAI,mBAAmB,CAAC,iBAAiB,EAAE;YACvC,oBAAoB,CAAC,iBAAiB,GAAG,mBAAmB,CAAC,iBAAiB,CAAC;SAClF;QAED,IAAI,CAAC,oBAAoB,GAAG,oBAAoB,CAAC;IACrD,CAAC;CACJ;AAtFD,8CAsFC;AAED,kBAAe,iBAAiB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { v4 as uuidv4 } from \"uuid\";\nimport { BlobDescriptor } from \"./descriptors\";\nimport IngestionProperties, { ReportLevel, ReportMethod } from \"./ingestionProperties\";\nimport { IngestionStatusInTableDescription } from \"./ingestionResult\";\n\nexport class IngestionBlobInfo {\n BlobPath: string;\n RawDataSize: number | null;\n DatabaseName: string | null;\n TableName: string | null;\n RetainBlobOnSuccess: boolean;\n FlushImmediately: boolean;\n IgnoreSizeLimit: boolean;\n ReportLevel: ReportLevel | null;\n ReportMethod: ReportMethod | null;\n SourceMessageCreationTime: Date;\n Id: string;\n AdditionalProperties: { [additional: string]: any };\n IngestionStatusInTable: IngestionStatusInTableDescription | null = null;\n ApplicationForTracing?: string | null = null;\n ClientVersionForTracing?: string | null = null;\n\n constructor(\n blobDescriptor: BlobDescriptor,\n ingestionProperties: IngestionProperties,\n authContext: string | null = null,\n applicationForTracing: string | null = null,\n clientVersionForTracing: string | null = null\n ) {\n this.BlobPath = blobDescriptor.path;\n this.RawDataSize = blobDescriptor.size;\n this.DatabaseName = ingestionProperties.database ?? null;\n this.TableName = ingestionProperties.table ?? null;\n this.RetainBlobOnSuccess = true;\n this.FlushImmediately = ingestionProperties.flushImmediately ?? false;\n this.IgnoreSizeLimit = false;\n this.ReportLevel = ingestionProperties.reportLevel ?? null;\n this.ReportMethod = ingestionProperties.reportMethod ?? null;\n this.SourceMessageCreationTime = new Date();\n this.Id = blobDescriptor.sourceId || uuidv4();\n this.ApplicationForTracing = applicationForTracing;\n this.ClientVersionForTracing = clientVersionForTracing;\n\n const additionalProperties = ingestionProperties.additionalProperties || {};\n additionalProperties.authorizationContext = authContext;\n\n const tags: string[] = [];\n if (ingestionProperties.additionalTags) {\n tags.concat(ingestionProperties.additionalTags);\n }\n if (ingestionProperties.dropByTags) {\n tags.concat(ingestionProperties.dropByTags.map((t) => \"drop-by:\" + t));\n }\n if (ingestionProperties.ingestByTags) {\n tags.concat(ingestionProperties.ingestByTags.map((t) => \"ingest-by:\" + t));\n }\n\n if (tags && tags.length > 0) {\n additionalProperties.tags = tags;\n }\n\n if (ingestionProperties.ingestIfNotExists) {\n additionalProperties.ingestIfNotExists = ingestionProperties.ingestIfNotExists;\n }\n\n if (ingestionProperties.ingestionMappingColumns && ingestionProperties.ingestionMappingColumns.length > 0) {\n // server expects a string\n additionalProperties.ingestionMapping = JSON.stringify(ingestionProperties.ingestionMappingColumns.map((m) => m.toApiMapping()));\n }\n\n if (ingestionProperties.ingestionMappingReference) {\n additionalProperties.ingestionMappingReference = ingestionProperties.ingestionMappingReference;\n }\n\n if (ingestionProperties.ingestionMappingKind) {\n additionalProperties.ingestionMappingType = ingestionProperties.ingestionMappingKind;\n }\n\n if (ingestionProperties.validationPolicy) {\n additionalProperties.ValidationPolicy = ingestionProperties.validationPolicy;\n }\n\n if (ingestionProperties.format) {\n additionalProperties.format = ingestionProperties.format;\n }\n if (ingestionProperties.ignoreFirstRecord) {\n additionalProperties.ignoreFirstRecord = ingestionProperties.ignoreFirstRecord;\n }\n\n this.AdditionalProperties = additionalProperties;\n }\n}\n\nexport default IngestionBlobInfo;\n"]}
1
+ {"version":3,"file":"ingestionBlobInfo.js","sourceRoot":"","sources":["../../src/ingestionBlobInfo.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,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C,gBAAgB,EAAE;YACtC,oBAAoB,CAAC,gBAAgB,GAAG,mBAAmB,CAAC,gBAAgB,CAAC;SAChF;QAED,IAAI,mBAAmB,CAAC,MAAM,EAAE;YAC5B,oBAAoB,CAAC,MAAM,GAAG,mBAAmB,CAAC,MAAM,CAAC;SAC5D;QACD,IAAI,mBAAmB,CAAC,iBAAiB,EAAE;YACvC,oBAAoB,CAAC,iBAAiB,GAAG,mBAAmB,CAAC,iBAAiB,CAAC;SAClF;QAED,IAAI,CAAC,oBAAoB,GAAG,oBAAoB,CAAC;IACrD,CAAC;CACJ;AAED,eAAe,iBAAiB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { v4 as uuidv4 } from \"uuid\";\nimport { BlobDescriptor } from \"./descriptors.js\";\nimport IngestionProperties, { ReportLevel, ReportMethod } from \"./ingestionProperties.js\";\nimport { IngestionStatusInTableDescription } from \"./ingestionResult.js\";\n\nexport class IngestionBlobInfo {\n BlobPath: string;\n RawDataSize: number | null;\n DatabaseName: string | null;\n TableName: string | null;\n RetainBlobOnSuccess: boolean;\n FlushImmediately: boolean;\n IgnoreSizeLimit: boolean;\n ReportLevel: ReportLevel | null;\n ReportMethod: ReportMethod | null;\n SourceMessageCreationTime: Date;\n Id: string;\n AdditionalProperties: { [additional: string]: any };\n IngestionStatusInTable: IngestionStatusInTableDescription | null = null;\n ApplicationForTracing?: string | null = null;\n ClientVersionForTracing?: string | null = null;\n\n constructor(\n blobDescriptor: BlobDescriptor,\n ingestionProperties: IngestionProperties,\n authContext: string | null = null,\n applicationForTracing: string | null = null,\n clientVersionForTracing: string | null = null\n ) {\n this.BlobPath = blobDescriptor.path;\n this.RawDataSize = blobDescriptor.size;\n this.DatabaseName = ingestionProperties.database ?? null;\n this.TableName = ingestionProperties.table ?? null;\n this.RetainBlobOnSuccess = true;\n this.FlushImmediately = ingestionProperties.flushImmediately ?? false;\n this.IgnoreSizeLimit = false;\n this.ReportLevel = ingestionProperties.reportLevel ?? null;\n this.ReportMethod = ingestionProperties.reportMethod ?? null;\n this.SourceMessageCreationTime = new Date();\n this.Id = blobDescriptor.sourceId || uuidv4();\n this.ApplicationForTracing = applicationForTracing;\n this.ClientVersionForTracing = clientVersionForTracing;\n\n const additionalProperties = ingestionProperties.additionalProperties || {};\n additionalProperties.authorizationContext = authContext;\n\n const tags: string[] = [];\n if (ingestionProperties.additionalTags) {\n tags.concat(ingestionProperties.additionalTags);\n }\n if (ingestionProperties.dropByTags) {\n tags.concat(ingestionProperties.dropByTags.map((t) => \"drop-by:\" + t));\n }\n if (ingestionProperties.ingestByTags) {\n tags.concat(ingestionProperties.ingestByTags.map((t) => \"ingest-by:\" + t));\n }\n\n if (tags && tags.length > 0) {\n additionalProperties.tags = tags;\n }\n\n if (ingestionProperties.ingestIfNotExists) {\n additionalProperties.ingestIfNotExists = ingestionProperties.ingestIfNotExists;\n }\n\n if (ingestionProperties.ingestionMappingColumns && ingestionProperties.ingestionMappingColumns.length > 0) {\n // server expects a string\n additionalProperties.ingestionMapping = JSON.stringify(ingestionProperties.ingestionMappingColumns.map((m) => m.toApiMapping()));\n }\n\n if (ingestionProperties.ingestionMappingReference) {\n additionalProperties.ingestionMappingReference = ingestionProperties.ingestionMappingReference;\n }\n\n if (ingestionProperties.ingestionMappingKind) {\n additionalProperties.ingestionMappingType = ingestionProperties.ingestionMappingKind;\n }\n\n if (ingestionProperties.validationPolicy) {\n additionalProperties.ValidationPolicy = ingestionProperties.validationPolicy;\n }\n\n if (ingestionProperties.format) {\n additionalProperties.format = ingestionProperties.format;\n }\n if (ingestionProperties.ignoreFirstRecord) {\n additionalProperties.ignoreFirstRecord = ingestionProperties.ignoreFirstRecord;\n }\n\n this.AdditionalProperties = additionalProperties;\n }\n}\n\nexport default IngestionBlobInfo;\n"]}
@@ -1,13 +1,10 @@
1
- "use strict";
2
1
  // Copyright (c) Microsoft Corporation.
3
2
  // Licensed under the MIT License.
4
- Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.shouldCompressFileByFormat = exports.IngestionProperties = exports.ReportMethod = exports.ReportLevel = exports.ValidationPolicy = exports.ValidationImplications = exports.ValidationOptions = exports.dataFormatMappingKind = exports.IngestionMappingKind = exports.DataFormat = void 0;
6
- const errors_1 = require("./errors");
3
+ import { IngestionPropertiesValidationError } from "./errors.js";
7
4
  /**
8
5
  * Data formats supported for Kusto ingestion.
9
6
  */
10
- var DataFormat;
7
+ export var DataFormat;
11
8
  (function (DataFormat) {
12
9
  /**
13
10
  * Comma-separated value.
@@ -77,8 +74,8 @@ var DataFormat;
77
74
  * W3C Extended Log File format.
78
75
  */
79
76
  DataFormat["W3CLogFile"] = "w3clogfile";
80
- })(DataFormat || (exports.DataFormat = DataFormat = {}));
81
- var IngestionMappingKind;
77
+ })(DataFormat || (DataFormat = {}));
78
+ export var IngestionMappingKind;
82
79
  (function (IngestionMappingKind) {
83
80
  IngestionMappingKind["CSV"] = "Csv";
84
81
  IngestionMappingKind["JSON"] = "Json";
@@ -88,8 +85,8 @@ var IngestionMappingKind;
88
85
  IngestionMappingKind["ORC"] = "orc";
89
86
  IngestionMappingKind["APACHEAVRO"] = "ApacheAvro";
90
87
  IngestionMappingKind["W3CLOGFILE"] = "W3CLogFile";
91
- })(IngestionMappingKind || (exports.IngestionMappingKind = IngestionMappingKind = {}));
92
- const dataFormatMappingKind = (dataFormat) => {
88
+ })(IngestionMappingKind || (IngestionMappingKind = {}));
89
+ export const dataFormatMappingKind = (dataFormat) => {
93
90
  switch (dataFormat) {
94
91
  case DataFormat.CSV:
95
92
  return IngestionMappingKind.CSV;
@@ -126,22 +123,21 @@ const dataFormatMappingKind = (dataFormat) => {
126
123
  case DataFormat.W3CLogFile:
127
124
  return IngestionMappingKind.W3CLOGFILE;
128
125
  default:
129
- throw new errors_1.IngestionPropertiesValidationError(`Unsupported data format: ${dataFormat}`);
126
+ throw new IngestionPropertiesValidationError(`Unsupported data format: ${dataFormat}`);
130
127
  }
131
128
  };
132
- exports.dataFormatMappingKind = dataFormatMappingKind;
133
- var ValidationOptions;
129
+ export var ValidationOptions;
134
130
  (function (ValidationOptions) {
135
131
  ValidationOptions[ValidationOptions["DoNotValidate"] = 0] = "DoNotValidate";
136
132
  ValidationOptions[ValidationOptions["ValidateCsvInputConstantColumns"] = 1] = "ValidateCsvInputConstantColumns";
137
133
  ValidationOptions[ValidationOptions["ValidateCsvInputColumnLevelOnly"] = 2] = "ValidateCsvInputColumnLevelOnly";
138
- })(ValidationOptions || (exports.ValidationOptions = ValidationOptions = {}));
139
- var ValidationImplications;
134
+ })(ValidationOptions || (ValidationOptions = {}));
135
+ export var ValidationImplications;
140
136
  (function (ValidationImplications) {
141
137
  ValidationImplications[ValidationImplications["Fail"] = 0] = "Fail";
142
138
  ValidationImplications[ValidationImplications["BestEffort"] = 1] = "BestEffort";
143
- })(ValidationImplications || (exports.ValidationImplications = ValidationImplications = {}));
144
- class ValidationPolicy {
139
+ })(ValidationImplications || (ValidationImplications = {}));
140
+ export class ValidationPolicy {
145
141
  constructor(validationOptions = ValidationOptions.DoNotValidate, validationImplications = ValidationImplications.BestEffort) {
146
142
  this.validationOptions = validationOptions;
147
143
  this.validationImplications = validationImplications;
@@ -153,31 +149,30 @@ class ValidationPolicy {
153
149
  };
154
150
  }
155
151
  }
156
- exports.ValidationPolicy = ValidationPolicy;
157
- var ReportLevel;
152
+ export var ReportLevel;
158
153
  (function (ReportLevel) {
159
154
  ReportLevel[ReportLevel["FailuresOnly"] = 0] = "FailuresOnly";
160
155
  ReportLevel[ReportLevel["DoNotReport"] = 1] = "DoNotReport";
161
156
  ReportLevel[ReportLevel["FailuresAndSuccesses"] = 2] = "FailuresAndSuccesses";
162
- })(ReportLevel || (exports.ReportLevel = ReportLevel = {}));
163
- var ReportMethod;
157
+ })(ReportLevel || (ReportLevel = {}));
158
+ export var ReportMethod;
164
159
  (function (ReportMethod) {
165
160
  ReportMethod[ReportMethod["Queue"] = 0] = "Queue";
166
161
  ReportMethod[ReportMethod["Table"] = 1] = "Table";
167
162
  ReportMethod[ReportMethod["QueueAndTable"] = 2] = "QueueAndTable";
168
- })(ReportMethod || (exports.ReportMethod = ReportMethod = {}));
163
+ })(ReportMethod || (ReportMethod = {}));
169
164
  // eslint-disable-next-line no-redeclare
170
- class IngestionProperties {
165
+ export class IngestionProperties {
171
166
  constructor(data) {
172
167
  Object.assign(this, data);
173
168
  }
174
169
  validate() {
175
170
  if (!this.database)
176
- throw new errors_1.IngestionPropertiesValidationError("Must define a target database");
171
+ throw new IngestionPropertiesValidationError("Must define a target database");
177
172
  if (!this.table)
178
- throw new errors_1.IngestionPropertiesValidationError("Must define a target table");
173
+ throw new IngestionPropertiesValidationError("Must define a target table");
179
174
  if (!this.format)
180
- throw new errors_1.IngestionPropertiesValidationError("Must define a data format");
175
+ throw new IngestionPropertiesValidationError("Must define a data format");
181
176
  if (this.ingestionMappingType && !this.ingestionMappingKind) {
182
177
  this.ingestionMappingKind = this.ingestionMappingType;
183
178
  }
@@ -186,31 +181,31 @@ class IngestionProperties {
186
181
  }
187
182
  if (!this.ingestionMappingColumns && !this.ingestionMappingReference) {
188
183
  if (this.ingestionMappingKind) {
189
- throw new errors_1.IngestionPropertiesValidationError("Cannot define ingestionMappingKind without either ingestionMappingColumns or" + " ingestionMappingReference");
184
+ throw new IngestionPropertiesValidationError("Cannot define ingestionMappingKind without either ingestionMappingColumns or" + " ingestionMappingReference");
190
185
  }
191
186
  }
192
187
  else {
193
- const mappingKind = (0, exports.dataFormatMappingKind)(this.format);
188
+ const mappingKind = dataFormatMappingKind(this.format);
194
189
  if (this.ingestionMappingKind && this.ingestionMappingKind !== mappingKind) {
195
- throw new errors_1.IngestionPropertiesValidationError(`Mapping kind '${this.ingestionMappingKind}' does not match format '${this.format}' (should be '${mappingKind}')`);
190
+ throw new IngestionPropertiesValidationError(`Mapping kind '${this.ingestionMappingKind}' does not match format '${this.format}' (should be '${mappingKind}')`);
196
191
  }
197
192
  if (this.ingestionMappingColumns) {
198
193
  if (this.ingestionMappingReference) {
199
- throw new errors_1.IngestionPropertiesValidationError("Cannot define both ingestionMappingColumns and ingestionMappingReference");
194
+ throw new IngestionPropertiesValidationError("Cannot define both ingestionMappingColumns and ingestionMappingReference");
200
195
  }
201
196
  if (this.ingestionMappingColumns.length === 0) {
202
- throw new errors_1.IngestionPropertiesValidationError("Must define at least one column mapping");
197
+ throw new IngestionPropertiesValidationError("Must define at least one column mapping");
203
198
  }
204
199
  const wrongMappings = this.ingestionMappingColumns
205
200
  .filter((m) => m.mappingKind !== mappingKind)
206
201
  .map((m) => `Mapping kind mismatch for column '${m.columnName}' - expected data format kind - '${mappingKind}', but was '${m.mappingKind}'`);
207
202
  if (wrongMappings.length > 0) {
208
- throw new errors_1.IngestionPropertiesValidationError(`Invalid columns:\n${wrongMappings.join("\n")}`);
203
+ throw new IngestionPropertiesValidationError(`Invalid columns:\n${wrongMappings.join("\n")}`);
209
204
  }
210
205
  }
211
206
  }
212
207
  if (this.reportMethod !== ReportMethod.Queue && this.reportLevel === ReportLevel.FailuresOnly) {
213
- throw new errors_1.IngestionPropertiesValidationError("ReportLevel.FailuresOnly is not supported with ReportMethod.Table");
208
+ throw new IngestionPropertiesValidationError("ReportLevel.FailuresOnly is not supported with ReportMethod.Table");
214
209
  }
215
210
  }
216
211
  merge(extraProps) {
@@ -240,8 +235,7 @@ class IngestionProperties {
240
235
  }
241
236
  }
242
237
  }
243
- exports.IngestionProperties = IngestionProperties;
244
- function shouldCompressFileByFormat(ingestionProperties) {
238
+ export function shouldCompressFileByFormat(ingestionProperties) {
245
239
  if (!ingestionProperties) {
246
240
  ingestionProperties = {};
247
241
  }
@@ -251,6 +245,5 @@ function shouldCompressFileByFormat(ingestionProperties) {
251
245
  ingestionProperties.format === "apacheavro" ||
252
246
  ingestionProperties.format === "sstream");
253
247
  }
254
- exports.shouldCompressFileByFormat = shouldCompressFileByFormat;
255
- exports.default = IngestionProperties;
248
+ export default IngestionProperties;
256
249
  //# sourceMappingURL=ingestionProperties.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ingestionProperties.js","sourceRoot":"","sources":["../../src/ingestionProperties.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC,qCAA8D;AAG9D;;GAEG;AACH,IAAY,UAqEX;AArED,WAAY,UAAU;IAClB;;OAEG;IACH,yBAAW,CAAA;IACX;;OAEG;IACH,yBAAW,CAAA;IACX;;OAEG;IACH,2BAAa,CAAA;IACb;;OAEG;IACH,6BAAe,CAAA;IACf;;OAEG;IACH,yBAAW,CAAA;IACX;;OAEG;IACH,yBAAW,CAAA;IACX;;OAEG;IACH,yBAAW,CAAA;IACX;;OAEG;IACH,2BAAa,CAAA;IACb;;OAEG;IACH,2BAAa,CAAA;IACb;;OAEG;IACH,uCAAyB,CAAA;IACzB;;OAEG;IACH,qCAAuB,CAAA;IACvB;;OAEG;IACH,2BAAa,CAAA;IACb;;OAEG;IACH,iCAAmB,CAAA;IACnB;;OAEG;IACH,iCAAmB,CAAA;IACnB;;OAEG;IACH,yBAAW,CAAA;IACX;;OAEG;IACH,uCAAyB,CAAA;IACzB;;OAEG;IACH,uCAAyB,CAAA;AAC7B,CAAC,EArEW,UAAU,0BAAV,UAAU,QAqErB;AAED,IAAY,oBASX;AATD,WAAY,oBAAoB;IAC5B,mCAAW,CAAA;IACX,qCAAa,CAAA;IACb,qCAAa,CAAA;IACb,2CAAmB,CAAA;IACnB,2CAAmB,CAAA;IACnB,mCAAW,CAAA;IACX,iDAAyB,CAAA;IACzB,iDAAyB,CAAA;AAC7B,CAAC,EATW,oBAAoB,oCAApB,oBAAoB,QAS/B;AAEM,MAAM,qBAAqB,GAAG,CAAC,UAAsB,EAAwB,EAAE;IAClF,QAAQ,UAAU,EAAE;QAChB,KAAK,UAAU,CAAC,GAAG;YACf,OAAO,oBAAoB,CAAC,GAAG,CAAC;QACpC,KAAK,UAAU,CAAC,GAAG;YACf,OAAO,oBAAoB,CAAC,GAAG,CAAC;QACpC,KAAK,UAAU,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,SAAgB,0BAA0B,CAAC,mBAA8C;IACrF,IAAI,CAAC,mBAAmB,EAAE;QACtB,mBAAmB,GAAG,EAAE,CAAC;KAC5B;IACD,OAAO,CAAC,CACJ,mBAAmB,CAAC,MAAM,KAAK,MAAM;QACrC,mBAAmB,CAAC,MAAM,KAAK,SAAS;QACxC,mBAAmB,CAAC,MAAM,KAAK,KAAK;QACpC,mBAAmB,CAAC,MAAM,KAAK,YAAY;QAC3C,mBAAmB,CAAC,MAAM,KAAK,SAAS,CAC3C,CAAC;AACN,CAAC;AAXD,gEAWC;AAED,kBAAe,mBAAmB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { IngestionPropertiesValidationError } from \"./errors\";\nimport { ColumnMapping } from \"./columnMappings\";\n\n/**\n * Data formats supported for Kusto ingestion.\n */\nexport enum DataFormat {\n /**\n * Comma-separated value.\n */\n CSV = \"csv\",\n /**\n * Tab-separated value.\n */\n TSV = \"tsv\",\n /**\n * Semicolon-separated value (the unique Azure Storage log format).\n */\n SCSV = \"scsv\",\n /**\n * Start-Of-Header (CTRL-A)-separated value.\n */\n SOHSV = \"sohsv\",\n /**\n * Pipeline-separated value (used by Cosmos).\n */\n PSV = \"psv\",\n /**\n * Each record is a line and has just one field.\n */\n TXT = \"txt\",\n /**\n * Whole stream is a single record with a single field.\n */\n RAW = \"raw\",\n /**\n * Tab-separated value with '\\' escaping character.\n */\n TSVE = \"tsve\",\n /**\n * Data is in a JSON format, each line is record with a single JSON value.\n */\n JSON = \"json\",\n /**\n * Data stream holds a single JSON value -- newlines are regular whitespace.\n */\n SINGLEJSON = \"singlejson\",\n /**\n * The data stream is a concatenation of JSON documents (property bags all).\n */\n MULTIJSON = \"multijson\",\n /**\n * Avro format.\n */\n AVRO = \"avro\",\n /**\n * Parquet format.\n */\n PARQUET = \"parquet\",\n /**\n * Microsoft Cosmos structured streams format\n */\n SSTREAM = \"sstream\",\n /**\n * The Optimized Row Columnar (ORC)\n */\n ORC = \"orc\",\n /**\n * Avro format for ingesting through avro2json.\n */\n APACHEAVRO = \"apacheavro\",\n /**\n * W3C Extended Log File format.\n */\n W3CLogFile = \"w3clogfile\",\n}\n\nexport enum IngestionMappingKind {\n CSV = \"Csv\",\n JSON = \"Json\",\n AVRO = \"Avro\",\n PARQUET = \"Parquet\",\n SSTREAM = \"SStream\",\n ORC = \"orc\",\n APACHEAVRO = \"ApacheAvro\",\n W3CLOGFILE = \"W3CLogFile\",\n}\n\nexport const dataFormatMappingKind = (dataFormat: DataFormat): IngestionMappingKind => {\n switch (dataFormat) {\n case DataFormat.CSV:\n return IngestionMappingKind.CSV;\n case DataFormat.TSV:\n return IngestionMappingKind.CSV;\n case DataFormat.SCSV:\n return IngestionMappingKind.CSV;\n case DataFormat.SOHSV:\n return IngestionMappingKind.CSV;\n case DataFormat.PSV:\n return IngestionMappingKind.CSV;\n case DataFormat.TXT:\n return IngestionMappingKind.CSV;\n case DataFormat.RAW:\n return IngestionMappingKind.CSV;\n case DataFormat.TSVE:\n return IngestionMappingKind.CSV;\n case DataFormat.JSON:\n return IngestionMappingKind.JSON;\n case DataFormat.SINGLEJSON:\n return IngestionMappingKind.JSON;\n case DataFormat.MULTIJSON:\n return IngestionMappingKind.JSON;\n case DataFormat.AVRO:\n return IngestionMappingKind.AVRO;\n case DataFormat.PARQUET:\n return IngestionMappingKind.PARQUET;\n case DataFormat.SSTREAM:\n return IngestionMappingKind.SSTREAM;\n case DataFormat.ORC:\n return IngestionMappingKind.ORC;\n case DataFormat.APACHEAVRO:\n return IngestionMappingKind.APACHEAVRO;\n case DataFormat.W3CLogFile:\n return IngestionMappingKind.W3CLOGFILE;\n default:\n throw new IngestionPropertiesValidationError(`Unsupported data format: ${dataFormat}`);\n }\n};\n\nexport enum ValidationOptions {\n DoNotValidate = 0,\n ValidateCsvInputConstantColumns = 1,\n ValidateCsvInputColumnLevelOnly = 2,\n}\n\nexport enum ValidationImplications {\n Fail = 0,\n BestEffort = 1,\n}\n\nexport class ValidationPolicy {\n constructor(\n readonly validationOptions: ValidationOptions = ValidationOptions.DoNotValidate,\n readonly validationImplications: ValidationImplications = ValidationImplications.BestEffort\n ) {}\n\n toJSON(): Record<string, number> {\n return {\n ValidationOptions: this.validationOptions,\n ValidationImplications: this.validationImplications,\n };\n }\n}\n\nexport enum ReportLevel {\n FailuresOnly = 0,\n DoNotReport = 1,\n FailuresAndSuccesses = 2,\n}\n\nexport enum ReportMethod {\n Queue = 0,\n Table,\n QueueAndTable,\n}\n\nexport interface IngestionPropertiesFields {\n database?: string;\n table?: string;\n format?: DataFormat;\n /**\n * @deprecated. Use ingestionMappingColumns instead.\n */\n ingestionMapping?: ColumnMapping[];\n ingestionMappingColumns?: ColumnMapping[];\n ingestionMappingReference?: string;\n /**\n * @deprecated. Use ingestionMappingKind instead.\n */\n ingestionMappingType?: IngestionMappingKind;\n ingestionMappingKind?: IngestionMappingKind;\n additionalTags?: string;\n ingestIfNotExists?: string;\n ingestByTags?: string[];\n dropByTags?: string[];\n flushImmediately?: boolean;\n ignoreFirstRecord?: boolean;\n reportLevel?: ReportLevel;\n reportMethod?: ReportMethod;\n validationPolicy?: ValidationPolicy;\n additionalProperties?: { [additional: string]: any } | null;\n}\n\n// This trick lets us avoid duplicating all the properties from the interface. See https://github.com/microsoft/TypeScript/issues/3407\n// eslint-disable-next-line @typescript-eslint/no-empty-interface\nexport interface IngestionProperties extends IngestionPropertiesFields {}\n\n// eslint-disable-next-line no-redeclare\nexport class IngestionProperties {\n constructor(data: Partial<IngestionPropertiesFields>) {\n Object.assign(this, data);\n }\n\n validate() {\n if (!this.database) throw new IngestionPropertiesValidationError(\"Must define a target database\");\n if (!this.table) throw new IngestionPropertiesValidationError(\"Must define a target table\");\n if (!this.format) throw new IngestionPropertiesValidationError(\"Must define a data format\");\n\n if (this.ingestionMappingType && !this.ingestionMappingKind) {\n this.ingestionMappingKind = this.ingestionMappingType;\n }\n\n if (this.ingestionMapping && !this.ingestionMappingColumns) {\n this.ingestionMappingColumns = this.ingestionMapping;\n }\n\n if (!this.ingestionMappingColumns && !this.ingestionMappingReference) {\n if (this.ingestionMappingKind) {\n throw new IngestionPropertiesValidationError(\n \"Cannot define ingestionMappingKind without either ingestionMappingColumns or\" + \" ingestionMappingReference\"\n );\n }\n } else {\n const mappingKind = dataFormatMappingKind(this.format);\n if (this.ingestionMappingKind && this.ingestionMappingKind !== mappingKind) {\n throw new IngestionPropertiesValidationError(\n `Mapping kind '${this.ingestionMappingKind}' does not match format '${this.format}' (should be '${mappingKind}')`\n );\n }\n if (this.ingestionMappingColumns) {\n if (this.ingestionMappingReference) {\n throw new IngestionPropertiesValidationError(\"Cannot define both ingestionMappingColumns and ingestionMappingReference\");\n }\n\n if (this.ingestionMappingColumns.length === 0) {\n throw new IngestionPropertiesValidationError(\"Must define at least one column mapping\");\n }\n\n const wrongMappings = this.ingestionMappingColumns\n .filter((m) => m.mappingKind !== mappingKind)\n .map(\n (m) => `Mapping kind mismatch for column '${m.columnName}' - expected data format kind - '${mappingKind}', but was '${m.mappingKind}'`\n );\n if (wrongMappings.length > 0) {\n throw new IngestionPropertiesValidationError(`Invalid columns:\\n${wrongMappings.join(\"\\n\")}`);\n }\n }\n }\n\n if (this.reportMethod !== ReportMethod.Queue && this.reportLevel === ReportLevel.FailuresOnly) {\n throw new IngestionPropertiesValidationError(\"ReportLevel.FailuresOnly is not supported with ReportMethod.Table\");\n }\n }\n\n merge(extraProps: IngestionPropertiesInput) {\n const merged = new IngestionProperties(this);\n\n if (!extraProps) {\n return merged;\n }\n\n const assign = <K extends keyof IngestionPropertiesFields, V extends IngestionPropertiesFields[K]>(\n obj: IngestionPropertiesFields,\n prop: K,\n value: V\n ) => {\n obj[prop] = value;\n };\n\n for (const key of Object.keys(extraProps) as (keyof IngestionPropertiesFields)[]) {\n if (extraProps[key]) {\n assign(merged, key, extraProps[key]);\n }\n }\n\n return merged;\n }\n\n setDefaults() {\n if (!this.format) {\n this.format = DataFormat.CSV;\n }\n if (!this.reportLevel) {\n this.reportLevel = ReportLevel.FailuresOnly;\n }\n if (!this.reportMethod) {\n this.reportMethod = ReportMethod.Queue;\n }\n }\n}\n\nexport type IngestionPropertiesInput = IngestionProperties | IngestionPropertiesFields | null | undefined;\n\nexport function shouldCompressFileByFormat(ingestionProperties?: IngestionPropertiesInput): boolean {\n if (!ingestionProperties) {\n ingestionProperties = {};\n }\n return !(\n ingestionProperties.format === \"avro\" ||\n ingestionProperties.format === \"parquet\" ||\n ingestionProperties.format === \"orc\" ||\n ingestionProperties.format === \"apacheavro\" ||\n ingestionProperties.format === \"sstream\"\n );\n}\n\nexport default IngestionProperties;\n"]}
1
+ {"version":3,"file":"ingestionProperties.js","sourceRoot":"","sources":["../../src/ingestionProperties.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,kCAAkC,EAAE,MAAM,aAAa,CAAC;AAGjE;;GAEG;AACH,MAAM,CAAN,IAAY,UAqEX;AArED,WAAY,UAAU;IAClB;;OAEG;IACH,yBAAW,CAAA;IACX;;OAEG;IACH,yBAAW,CAAA;IACX;;OAEG;IACH,2BAAa,CAAA;IACb;;OAEG;IACH,6BAAe,CAAA;IACf;;OAEG;IACH,yBAAW,CAAA;IACX;;OAEG;IACH,yBAAW,CAAA;IACX;;OAEG;IACH,yBAAW,CAAA;IACX;;OAEG;IACH,2BAAa,CAAA;IACb;;OAEG;IACH,2BAAa,CAAA;IACb;;OAEG;IACH,uCAAyB,CAAA;IACzB;;OAEG;IACH,qCAAuB,CAAA;IACvB;;OAEG;IACH,2BAAa,CAAA;IACb;;OAEG;IACH,iCAAmB,CAAA;IACnB;;OAEG;IACH,iCAAmB,CAAA;IACnB;;OAEG;IACH,yBAAW,CAAA;IACX;;OAEG;IACH,uCAAyB,CAAA;IACzB;;OAEG;IACH,uCAAyB,CAAA;AAC7B,CAAC,EArEW,UAAU,KAAV,UAAU,QAqErB;AAED,MAAM,CAAN,IAAY,oBASX;AATD,WAAY,o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MAAM,EAAE,GAAG,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;aACxC;SACJ;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;IAED,WAAW;QACP,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;YACd,IAAI,CAAC,MAAM,GAAG,UAAU,CAAC,GAAG,CAAC;SAChC;QACD,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;YACnB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC,YAAY,CAAC;SAC/C;QACD,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE;YACpB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC,KAAK,CAAC;SAC1C;IACL,CAAC;CACJ;AAID,MAAM,UAAU,0BAA0B,CAAC,mBAA8C;IACrF,IAAI,CAAC,mBAAmB,EAAE;QACtB,mBAAmB,GAAG,EAAE,CAAC;KAC5B;IACD,OAAO,CAAC,CACJ,mBAAmB,CAAC,MAAM,KAAK,MAAM;QACrC,mBAAmB,CAAC,MAAM,KAAK,SAAS;QACxC,mBAAmB,CAAC,MAAM,KAAK,KAAK;QACpC,mBAAmB,CAAC,MAAM,KAAK,YAAY;QAC3C,mBAAmB,CAAC,MAAM,KAAK,SAAS,CAC3C,CAAC;AACN,CAAC;AAED,eAAe,mBAAmB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { IngestionPropertiesValidationError } from \"./errors.js\";\nimport { ColumnMapping } from \"./columnMappings.js\";\n\n/**\n * Data formats supported for Kusto ingestion.\n */\nexport enum DataFormat {\n /**\n * Comma-separated value.\n */\n CSV = \"csv\",\n /**\n * Tab-separated value.\n */\n TSV = \"tsv\",\n /**\n * Semicolon-separated value (the unique Azure Storage log format).\n */\n SCSV = \"scsv\",\n /**\n * Start-Of-Header (CTRL-A)-separated value.\n */\n SOHSV = \"sohsv\",\n /**\n * Pipeline-separated value (used by Cosmos).\n */\n PSV = \"psv\",\n /**\n * Each record is a line and has just one field.\n */\n TXT = \"txt\",\n /**\n * Whole stream is a single record with a single field.\n */\n RAW = \"raw\",\n /**\n * Tab-separated value with '\\' escaping character.\n */\n TSVE = \"tsve\",\n /**\n * Data is in a JSON format, each line is record with a single JSON value.\n */\n JSON = \"json\",\n /**\n * Data stream holds a single JSON value -- newlines are regular whitespace.\n */\n SINGLEJSON = \"singlejson\",\n /**\n * The data stream is a concatenation of JSON documents (property bags all).\n */\n MULTIJSON = \"multijson\",\n /**\n * Avro format.\n */\n AVRO = \"avro\",\n /**\n * Parquet format.\n */\n PARQUET = \"parquet\",\n /**\n * Microsoft Cosmos structured streams format\n */\n SSTREAM = \"sstream\",\n /**\n * The Optimized Row Columnar (ORC)\n */\n ORC = \"orc\",\n /**\n * Avro format for ingesting through avro2json.\n */\n APACHEAVRO = \"apacheavro\",\n /**\n * W3C Extended Log File format.\n */\n W3CLogFile = \"w3clogfile\",\n}\n\nexport enum IngestionMappingKind {\n CSV = \"Csv\",\n JSON = \"Json\",\n AVRO = \"Avro\",\n PARQUET = \"Parquet\",\n SSTREAM = \"SStream\",\n ORC = \"orc\",\n APACHEAVRO = \"ApacheAvro\",\n W3CLOGFILE = \"W3CLogFile\",\n}\n\nexport const dataFormatMappingKind = (dataFormat: DataFormat): IngestionMappingKind => {\n switch (dataFormat) {\n case DataFormat.CSV:\n return IngestionMappingKind.CSV;\n case DataFormat.TSV:\n return IngestionMappingKind.CSV;\n case DataFormat.SCSV:\n return IngestionMappingKind.CSV;\n case DataFormat.SOHSV:\n return IngestionMappingKind.CSV;\n case DataFormat.PSV:\n return IngestionMappingKind.CSV;\n case DataFormat.TXT:\n return IngestionMappingKind.CSV;\n case DataFormat.RAW:\n return IngestionMappingKind.CSV;\n case DataFormat.TSVE:\n return IngestionMappingKind.CSV;\n case DataFormat.JSON:\n return IngestionMappingKind.JSON;\n case DataFormat.SINGLEJSON:\n return IngestionMappingKind.JSON;\n case DataFormat.MULTIJSON:\n return IngestionMappingKind.JSON;\n case DataFormat.AVRO:\n return IngestionMappingKind.AVRO;\n case DataFormat.PARQUET:\n return IngestionMappingKind.PARQUET;\n case DataFormat.SSTREAM:\n return IngestionMappingKind.SSTREAM;\n case DataFormat.ORC:\n return IngestionMappingKind.ORC;\n case DataFormat.APACHEAVRO:\n return IngestionMappingKind.APACHEAVRO;\n case DataFormat.W3CLogFile:\n return IngestionMappingKind.W3CLOGFILE;\n default:\n throw new IngestionPropertiesValidationError(`Unsupported data format: ${dataFormat}`);\n }\n};\n\nexport enum ValidationOptions {\n DoNotValidate = 0,\n ValidateCsvInputConstantColumns = 1,\n ValidateCsvInputColumnLevelOnly = 2,\n}\n\nexport enum ValidationImplications {\n Fail = 0,\n BestEffort = 1,\n}\n\nexport class ValidationPolicy {\n constructor(\n readonly validationOptions: ValidationOptions = ValidationOptions.DoNotValidate,\n readonly validationImplications: ValidationImplications = ValidationImplications.BestEffort\n ) {}\n\n toJSON(): Record<string, number> {\n return {\n ValidationOptions: this.validationOptions,\n ValidationImplications: this.validationImplications,\n };\n }\n}\n\nexport enum ReportLevel {\n FailuresOnly = 0,\n DoNotReport = 1,\n FailuresAndSuccesses = 2,\n}\n\nexport enum ReportMethod {\n Queue = 0,\n Table,\n QueueAndTable,\n}\n\nexport interface IngestionPropertiesFields {\n database?: string;\n table?: string;\n format?: DataFormat;\n /**\n * @deprecated. Use ingestionMappingColumns instead.\n */\n ingestionMapping?: ColumnMapping[];\n ingestionMappingColumns?: ColumnMapping[];\n ingestionMappingReference?: string;\n /**\n * @deprecated. Use ingestionMappingKind instead.\n */\n ingestionMappingType?: IngestionMappingKind;\n ingestionMappingKind?: IngestionMappingKind;\n additionalTags?: string;\n ingestIfNotExists?: string;\n ingestByTags?: string[];\n dropByTags?: string[];\n flushImmediately?: boolean;\n ignoreFirstRecord?: boolean;\n reportLevel?: ReportLevel;\n reportMethod?: ReportMethod;\n validationPolicy?: ValidationPolicy;\n additionalProperties?: { [additional: string]: any } | null;\n}\n\n// This trick lets us avoid duplicating all the properties from the interface. See https://github.com/microsoft/TypeScript/issues/3407\n// eslint-disable-next-line @typescript-eslint/no-empty-interface\nexport interface IngestionProperties extends IngestionPropertiesFields {}\n\n// eslint-disable-next-line no-redeclare\nexport class IngestionProperties {\n constructor(data: Partial<IngestionPropertiesFields>) {\n Object.assign(this, data);\n }\n\n validate() {\n if (!this.database) throw new IngestionPropertiesValidationError(\"Must define a target database\");\n if (!this.table) throw new IngestionPropertiesValidationError(\"Must define a target table\");\n if (!this.format) throw new IngestionPropertiesValidationError(\"Must define a data format\");\n\n if (this.ingestionMappingType && !this.ingestionMappingKind) {\n this.ingestionMappingKind = this.ingestionMappingType;\n }\n\n if (this.ingestionMapping && !this.ingestionMappingColumns) {\n this.ingestionMappingColumns = this.ingestionMapping;\n }\n\n if (!this.ingestionMappingColumns && !this.ingestionMappingReference) {\n if (this.ingestionMappingKind) {\n throw new IngestionPropertiesValidationError(\n \"Cannot define ingestionMappingKind without either ingestionMappingColumns or\" + \" ingestionMappingReference\"\n );\n }\n } else {\n const mappingKind = dataFormatMappingKind(this.format);\n if (this.ingestionMappingKind && this.ingestionMappingKind !== mappingKind) {\n throw new IngestionPropertiesValidationError(\n `Mapping kind '${this.ingestionMappingKind}' does not match format '${this.format}' (should be '${mappingKind}')`\n );\n }\n if (this.ingestionMappingColumns) {\n if (this.ingestionMappingReference) {\n throw new IngestionPropertiesValidationError(\"Cannot define both ingestionMappingColumns and ingestionMappingReference\");\n }\n\n if (this.ingestionMappingColumns.length === 0) {\n throw new IngestionPropertiesValidationError(\"Must define at least one column mapping\");\n }\n\n const wrongMappings = this.ingestionMappingColumns\n .filter((m) => m.mappingKind !== mappingKind)\n .map(\n (m) => `Mapping kind mismatch for column '${m.columnName}' - expected data format kind - '${mappingKind}', but was '${m.mappingKind}'`\n );\n if (wrongMappings.length > 0) {\n throw new IngestionPropertiesValidationError(`Invalid columns:\\n${wrongMappings.join(\"\\n\")}`);\n }\n }\n }\n\n if (this.reportMethod !== ReportMethod.Queue && this.reportLevel === ReportLevel.FailuresOnly) {\n throw new IngestionPropertiesValidationError(\"ReportLevel.FailuresOnly is not supported with ReportMethod.Table\");\n }\n }\n\n merge(extraProps: IngestionPropertiesInput) {\n const merged = new IngestionProperties(this);\n\n if (!extraProps) {\n return merged;\n }\n\n const assign = <K extends keyof IngestionPropertiesFields, V extends IngestionPropertiesFields[K]>(\n obj: IngestionPropertiesFields,\n prop: K,\n value: V\n ) => {\n obj[prop] = value;\n };\n\n for (const key of Object.keys(extraProps) as (keyof IngestionPropertiesFields)[]) {\n if (extraProps[key]) {\n assign(merged, key, extraProps[key]);\n }\n }\n\n return merged;\n }\n\n setDefaults() {\n if (!this.format) {\n this.format = DataFormat.CSV;\n }\n if (!this.reportLevel) {\n this.reportLevel = ReportLevel.FailuresOnly;\n }\n if (!this.reportMethod) {\n this.reportMethod = ReportMethod.Queue;\n }\n }\n}\n\nexport type IngestionPropertiesInput = IngestionProperties | IngestionPropertiesFields | null | undefined;\n\nexport function shouldCompressFileByFormat(ingestionProperties?: IngestionPropertiesInput): boolean {\n if (!ingestionProperties) {\n ingestionProperties = {};\n }\n return !(\n ingestionProperties.format === \"avro\" ||\n ingestionProperties.format === \"parquet\" ||\n ingestionProperties.format === \"orc\" ||\n ingestionProperties.format === \"apacheavro\" ||\n ingestionProperties.format === \"sstream\"\n );\n}\n\nexport default IngestionProperties;\n"]}
@@ -1,12 +1,9 @@
1
- "use strict";
2
1
  // Copyright (c) Microsoft Corporation.
3
2
  // Licensed under the MIT License.
4
- Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.IngestionStatusInTableDescription = exports.IngestionStatusResult = exports.TableReportIngestionResult = exports.OperationStatus = exports.putRecordInTable = void 0;
6
- const retry_1 = require("./retry");
7
- const resourceManager_1 = require("./resourceManager");
8
- const putRecordInTable = async (tableClient, entity) => {
9
- const retry = new retry_1.ExponentialRetry(3, 1, 1);
3
+ import { ExponentialRetry } from "./retry.js";
4
+ import { createStatusTableClient } from "./resourceManager.js";
5
+ export const putRecordInTable = async (tableClient, entity) => {
6
+ const retry = new ExponentialRetry(3, 1, 1);
10
7
  while (retry.shouldTry()) {
11
8
  try {
12
9
  await tableClient.createEntity(entity);
@@ -16,8 +13,7 @@ const putRecordInTable = async (tableClient, entity) => {
16
13
  }
17
14
  }
18
15
  };
19
- exports.putRecordInTable = putRecordInTable;
20
- var OperationStatus;
16
+ export var OperationStatus;
21
17
  (function (OperationStatus) {
22
18
  OperationStatus["Pending"] = "Pending";
23
19
  OperationStatus["Succeede"] = "Succeeded";
@@ -25,21 +21,20 @@ var OperationStatus;
25
21
  OperationStatus["Queued"] = "Queued";
26
22
  OperationStatus["Skipped"] = "Skipped";
27
23
  OperationStatus["PartiallySucceeded"] = "PartiallySucceeded";
28
- })(OperationStatus || (exports.OperationStatus = OperationStatus = {}));
29
- class TableReportIngestionResult {
24
+ })(OperationStatus || (OperationStatus = {}));
25
+ export class TableReportIngestionResult {
30
26
  constructor(ingestionStatusInTableDescription, tableClient = null) {
31
27
  this.ingestionStatusInTableDescription = ingestionStatusInTableDescription;
32
28
  this.tableClient = tableClient;
33
29
  }
34
30
  async getIngestionStatusCollection() {
35
31
  if (!this.tableClient) {
36
- this.tableClient = (0, resourceManager_1.createStatusTableClient)(this.ingestionStatusInTableDescription.tableConnectionString);
32
+ this.tableClient = createStatusTableClient(this.ingestionStatusInTableDescription.tableConnectionString);
37
33
  }
38
34
  return await this.tableClient.getEntity(this.ingestionStatusInTableDescription.partitionKey, this.ingestionStatusInTableDescription.rowKey);
39
35
  }
40
36
  }
41
- exports.TableReportIngestionResult = TableReportIngestionResult;
42
- class IngestionStatusResult {
37
+ export class IngestionStatusResult {
43
38
  constructor(ingestionStatus) {
44
39
  this.ingestionStatus = ingestionStatus;
45
40
  this.ingestionStatus = ingestionStatus;
@@ -48,13 +43,11 @@ class IngestionStatusResult {
48
43
  return Promise.resolve(this.ingestionStatus);
49
44
  }
50
45
  }
51
- exports.IngestionStatusResult = IngestionStatusResult;
52
- class IngestionStatusInTableDescription {
46
+ export class IngestionStatusInTableDescription {
53
47
  constructor(tableConnectionString, partitionKey, rowKey) {
54
48
  this.tableConnectionString = tableConnectionString;
55
49
  this.partitionKey = partitionKey;
56
50
  this.rowKey = rowKey;
57
51
  }
58
52
  }
59
- exports.IngestionStatusInTableDescription = IngestionStatusInTableDescription;
60
53
  //# sourceMappingURL=ingestionResult.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ingestionResult.js","sourceRoot":"","sources":["../../src/ingestionResult.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAGlC,mCAA2C;AAC3C,uDAA4D;AASrD,MAAM,gBAAgB,GAAG,KAAK,EAAE,WAAwB,EAAE,MAAoC,EAAiB,EAAE;IACpH,MAAM,KAAK,GAAG,IAAI,wBAAgB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAC5C,OAAO,KAAK,CAAC,SAAS,EAAE,EAAE;QACtB,IAAI;YACA,MAAM,WAAW,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;SAC1C;QAAC,OAAO,EAAE,EAAE;YACT,MAAM,KAAK,CAAC,OAAO,EAAE,CAAC;SACzB;KACJ;AACL,CAAC,CAAC;AATW,QAAA,gBAAgB,oBAS3B;AAEF,IAAY,eAOX;AAPD,WAAY,eAAe;IACvB,sCAAmB,CAAA;IACnB,yCAAsB,CAAA;IACtB,oCAAiB,CAAA;IACjB,oCAAiB,CAAA;IACjB,sCAAmB,CAAA;IACnB,4DAAyC,CAAA;AAC7C,CAAC,EAPW,eAAe,+BAAf,eAAe,QAO1B;AAED,MAAa,0BAA0B;IACnC,YAA2B,iCAAoE,EAAS,cAAkC,IAAI;QAAnH,sCAAiC,GAAjC,iCAAiC,CAAmC;QAAS,gBAAW,GAAX,WAAW,CAA2B;IAAG,CAAC;IAE3I,KAAK,CAAC,4BAA4B;QACrC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;YACnB,IAAI,CAAC,WAAW,GAAG,IAAA,yCAAuB,EAAC,IAAI,CAAC,iCAAiC,CAAC,qBAAqB,CAAC,CAAC;SAC5G;QAED,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,SAAS,CACnC,IAAI,CAAC,iCAAiC,CAAC,YAAY,EACnD,IAAI,CAAC,iCAAiC,CAAC,MAAM,CAChD,CAAC;IACN,CAAC;CACJ;AAbD,gEAaC;AAED,MAAa,qBAAqB;IAC9B,YAAoB,eAAgC;QAAhC,oBAAe,GAAf,eAAe,CAAiB;QAChD,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;IAC3C,CAAC;IAEM,4BAA4B;QAC/B,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IACjD,CAAC;CACJ;AARD,sDAQC;AAED,MAAa,iCAAiC;IAC1C,YAAmB,qBAA6B,EAAS,YAAoB,EAAS,MAAc;QAAjF,0BAAqB,GAArB,qBAAqB,CAAQ;QAAS,iBAAY,GAAZ,YAAY,CAAQ;QAAS,WAAM,GAAN,MAAM,CAAQ;IAAG,CAAC;CAC3G;AAFD,8EAEC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { TableClient, TableEntity } from \"@azure/data-tables\";\nimport { ExponentialRetry } from \"./retry\";\nimport { createStatusTableClient } from \"./resourceManager\";\nexport interface IngestionResult {\n /// <summary>\n /// Retrieves the detailed ingestion status of\n /// all data ingestion operations into Kusto associated with this IKustoIngestionResult instance.\n /// </summary>\n getIngestionStatusCollection(): Promise<IngestionStatus>;\n}\n\nexport const putRecordInTable = async (tableClient: TableClient, entity: TableEntity<IngestionStatus>): Promise<void> => {\n const retry = new ExponentialRetry(3, 1, 1);\n while (retry.shouldTry()) {\n try {\n await tableClient.createEntity(entity);\n } catch (ex) {\n await retry.backoff();\n }\n }\n};\n\nexport enum OperationStatus {\n Pending = \"Pending\",\n Succeede = \"Succeeded\",\n Failed = \"Failed\",\n Queued = \"Queued\",\n Skipped = \"Skipped\",\n PartiallySucceeded = \"PartiallySucceeded\",\n}\n\nexport class TableReportIngestionResult implements IngestionResult {\n public constructor(private ingestionStatusInTableDescription: IngestionStatusInTableDescription, public tableClient: TableClient | null = null) {}\n\n public async getIngestionStatusCollection(): Promise<IngestionStatus> {\n if (!this.tableClient) {\n this.tableClient = createStatusTableClient(this.ingestionStatusInTableDescription.tableConnectionString);\n }\n\n return await this.tableClient.getEntity<IngestionStatus>(\n this.ingestionStatusInTableDescription.partitionKey,\n this.ingestionStatusInTableDescription.rowKey\n );\n }\n}\n\nexport class IngestionStatusResult implements IngestionResult {\n constructor(private ingestionStatus: IngestionStatus) {\n this.ingestionStatus = ingestionStatus;\n }\n\n public getIngestionStatusCollection(): Promise<IngestionStatus> {\n return Promise.resolve(this.ingestionStatus);\n }\n}\n\nexport class IngestionStatusInTableDescription {\n constructor(public tableConnectionString: string, public partitionKey: string, public rowKey: string) {}\n}\n\nexport interface IngestionStatus {\n Timestamp: string;\n Status: OperationStatus;\n IngestionSourceId: string;\n IngestionSourcePath: string;\n Database: string;\n Table: string;\n UpdatedOn: string;\n Details: string;\n}\n"]}
1
+ {"version":3,"file":"ingestionResult.js","sourceRoot":"","sources":["../../src/ingestionResult.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAS/D,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,EAAE,WAAwB,EAAE,MAAoC,EAAiB,EAAE;IACpH,MAAM,KAAK,GAAG,IAAI,gBAAgB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAC5C,OAAO,KAAK,CAAC,SAAS,EAAE,EAAE;QACtB,IAAI;YACA,MAAM,WAAW,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;SAC1C;QAAC,OAAO,EAAE,EAAE;YACT,MAAM,KAAK,CAAC,O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from \"@azure/data-tables\";\nimport { ExponentialRetry } from \"./retry.js\";\nimport { createStatusTableClient } from \"./resourceManager.js\";\nexport interface IngestionResult {\n /// <summary>\n /// Retrieves the detailed ingestion status of\n /// all data ingestion operations into Kusto associated with this IKustoIngestionResult instance.\n /// </summary>\n getIngestionStatusCollection(): Promise<IngestionStatus>;\n}\n\nexport const putRecordInTable = async (tableClient: TableClient, entity: TableEntity<IngestionStatus>): Promise<void> => {\n const retry = new ExponentialRetry(3, 1, 1);\n while (retry.shouldTry()) {\n try {\n await tableClient.createEntity(entity);\n } catch (ex) {\n await retry.backoff();\n }\n }\n};\n\nexport enum OperationStatus {\n Pending = \"Pending\",\n Succeede = \"Succeeded\",\n Failed = \"Failed\",\n Queued = \"Queued\",\n Skipped = \"Skipped\",\n PartiallySucceeded = \"PartiallySucceeded\",\n}\n\nexport class TableReportIngestionResult implements IngestionResult {\n public constructor(private ingestionStatusInTableDescription: IngestionStatusInTableDescription, public tableClient: TableClient | null = null) {}\n\n public async getIngestionStatusCollection(): Promise<IngestionStatus> {\n if (!this.tableClient) {\n this.tableClient = createStatusTableClient(this.ingestionStatusInTableDescription.tableConnectionString);\n }\n\n return await this.tableClient.getEntity<IngestionStatus>(\n this.ingestionStatusInTableDescription.partitionKey,\n this.ingestionStatusInTableDescription.rowKey\n );\n }\n}\n\nexport class IngestionStatusResult implements IngestionResult {\n constructor(private ingestionStatus: IngestionStatus) {\n this.ingestionStatus = ingestionStatus;\n }\n\n public getIngestionStatusCollection(): Promise<IngestionStatus> {\n return Promise.resolve(this.ingestionStatus);\n }\n}\n\nexport class IngestionStatusInTableDescription {\n constructor(public tableConnectionString: string, public partitionKey: string, public rowKey: string) {}\n}\n\nexport interface IngestionStatus {\n Timestamp: string;\n Status: OperationStatus;\n IngestionSourceId: string;\n IngestionSourcePath: string;\n Database: string;\n Table: string;\n UpdatedOn: string;\n Details: string;\n}\n"]}
@@ -1,23 +1,18 @@
1
- "use strict";
2
1
  // Copyright (c) Microsoft Corporation.
3
2
  // Licensed under the MIT License.
4
- var __importDefault = (this && this.__importDefault) || function (mod) {
5
- return (mod && mod.__esModule) ? mod : { "default": mod };
6
- };
7
- Object.defineProperty(exports, "__esModule", { value: true });
8
- const core_util_1 = require("@azure/core-util");
9
- const azure_kusto_data_1 = require("azure-kusto-data");
10
- const abstractKustoClient_1 = require("./abstractKustoClient");
11
- const descriptors_1 = require("./descriptors");
12
- const fileDescriptor_1 = require("./fileDescriptor");
13
- const ingestClient_1 = __importDefault(require("./ingestClient"));
14
- const retry_1 = require("./retry");
15
- const streamUtils_1 = require("./streamUtils");
16
- const streamingIngestClient_1 = __importDefault(require("./streamingIngestClient"));
3
+ import { isNode } from "@azure/core-util";
4
+ import { KustoConnectionStringBuilder } from "azure-kusto-data";
5
+ import { AbstractKustoClient } from "./abstractKustoClient.js";
6
+ import { BlobDescriptor, StreamDescriptor } from "./descriptors.js";
7
+ import { FileDescriptor } from "./fileDescriptor.js";
8
+ import IngestClient from "./ingestClient.js";
9
+ import { ExponentialRetry } from "./retry.js";
10
+ import { readableToStream, tryFileToBuffer, tryStreamToArray } from "./streamUtils.js";
11
+ import StreamingIngestClient from "./streamingIngestClient.js";
17
12
  const maxStreamSize = 1024 * 1024 * 4;
18
13
  const attemptCount = 3;
19
14
  const ingestPrefix = "https://ingest-";
20
- class KustoManagedStreamingIngestClient extends abstractKustoClient_1.AbstractKustoClient {
15
+ class KustoManagedStreamingIngestClient extends AbstractKustoClient {
21
16
  /**
22
17
  * Creates a KustoManagedStreamingIngestClient from a DM connection string.
23
18
  * This method infers the engine connection string.
@@ -31,7 +26,7 @@ class KustoManagedStreamingIngestClient extends abstractKustoClient_1.AbstractKu
31
26
  if (dmConnectionString.dataSource == null || !dmConnectionString.dataSource.startsWith(ingestPrefix)) {
32
27
  throw new Error(`DM connection string must include the prefix '${ingestPrefix}'`);
33
28
  }
34
- const engineConnectionString = azure_kusto_data_1.KustoConnectionStringBuilder.fromExisting(dmConnectionString);
29
+ const engineConnectionString = KustoConnectionStringBuilder.fromExisting(dmConnectionString);
35
30
  engineConnectionString.dataSource = (_a = engineConnectionString.dataSource) === null || _a === void 0 ? void 0 : _a.replace(ingestPrefix, "https://");
36
31
  return new KustoManagedStreamingIngestClient(engineConnectionString, dmConnectionString, defaultProps);
37
32
  }
@@ -48,7 +43,7 @@ class KustoManagedStreamingIngestClient extends abstractKustoClient_1.AbstractKu
48
43
  if (engineConnectionString.dataSource == null || engineConnectionString.dataSource.startsWith(ingestPrefix)) {
49
44
  throw new Error(`Engine connection string must not include the prefix '${ingestPrefix}'`);
50
45
  }
51
- const dmConnectionString = azure_kusto_data_1.KustoConnectionStringBuilder.fromExisting(engineConnectionString);
46
+ const dmConnectionString = KustoConnectionStringBuilder.fromExisting(engineConnectionString);
52
47
  dmConnectionString.dataSource = (_a = dmConnectionString.dataSource) === null || _a === void 0 ? void 0 : _a.replace("https://", ingestPrefix);
53
48
  return new KustoManagedStreamingIngestClient(engineConnectionString, dmConnectionString, defaultProps);
54
49
  }
@@ -56,8 +51,8 @@ class KustoManagedStreamingIngestClient extends abstractKustoClient_1.AbstractKu
56
51
  super(defaultProps);
57
52
  this.baseSleepTimeSecs = 1;
58
53
  this.baseJitterSecs = 1;
59
- this.streamingIngestClient = new streamingIngestClient_1.default(engineKcsb, defaultProps, autoCorrectEndpoint);
60
- this.queuedIngestClient = new ingestClient_1.default(dmKcsb, defaultProps, autoCorrectEndpoint);
54
+ this.streamingIngestClient = new StreamingIngestClient(engineKcsb, defaultProps, autoCorrectEndpoint);
55
+ this.queuedIngestClient = new IngestClient(dmKcsb, defaultProps, autoCorrectEndpoint);
61
56
  if (this.streamingIngestClient.defaultDatabase && this.streamingIngestClient.defaultDatabase !== this.queuedIngestClient.defaultDatabase) {
62
57
  throw new Error(`Default database for streaming ingest client (${this.streamingIngestClient.defaultDatabase}) must match default database for queued ingest client (${this.queuedIngestClient.defaultDatabase})`);
63
58
  }
@@ -70,47 +65,47 @@ class KustoManagedStreamingIngestClient extends abstractKustoClient_1.AbstractKu
70
65
  var _a;
71
66
  this.ensureOpen();
72
67
  const props = this._getMergedProps(ingestionProperties);
73
- let descriptor = stream instanceof descriptors_1.StreamDescriptor ? stream : new descriptors_1.StreamDescriptor(stream);
74
- let result = core_util_1.isNode ? await (0, streamUtils_1.tryStreamToArray)(descriptor.stream, maxStreamSize) : descriptor.stream;
75
- descriptor = new descriptors_1.StreamDescriptor(result).merge(descriptor);
68
+ let descriptor = stream instanceof StreamDescriptor ? stream : new StreamDescriptor(stream);
69
+ let result = isNode ? await tryStreamToArray(descriptor.stream, maxStreamSize) : descriptor.stream;
70
+ descriptor = new StreamDescriptor(result).merge(descriptor);
76
71
  let streamingResult = null;
77
72
  // tryStreamToArray returns a Buffer in NodeJS impl if stream size is small enouph
78
- if ((core_util_1.isNode && result instanceof Buffer) || !core_util_1.isNode) {
79
- streamingResult = await this.streamWithRetries(core_util_1.isNode ? (_a = descriptor.size) !== null && _a !== void 0 ? _a : 0 : descriptor.stream.byteLength, descriptor, props, clientRequestId, result);
80
- result = core_util_1.isNode ? (0, streamUtils_1.readableToStream)(result) : descriptor.stream;
73
+ if ((isNode && result instanceof Buffer) || !isNode) {
74
+ streamingResult = await this.streamWithRetries(isNode ? (_a = descriptor.size) !== null && _a !== void 0 ? _a : 0 : descriptor.stream.byteLength, descriptor, props, clientRequestId, result);
75
+ result = isNode ? readableToStream(result) : descriptor.stream;
81
76
  }
82
- return streamingResult !== null && streamingResult !== void 0 ? streamingResult : this.queuedIngestClient.ingestFromStream(new descriptors_1.StreamDescriptor(result).merge(descriptor), props);
77
+ return streamingResult !== null && streamingResult !== void 0 ? streamingResult : this.queuedIngestClient.ingestFromStream(new StreamDescriptor(result).merge(descriptor), props);
83
78
  }
84
79
  /**
85
80
  * Use string for Node.js and Blob in browser
86
81
  */
87
82
  async ingestFromFile(file, ingestionProperties) {
88
83
  this.ensureOpen();
89
- const stream = file instanceof fileDescriptor_1.FileDescriptor ? await (0, streamUtils_1.tryFileToBuffer)(file) : await (0, streamUtils_1.tryFileToBuffer)(new fileDescriptor_1.FileDescriptor(file));
84
+ const stream = file instanceof FileDescriptor ? await tryFileToBuffer(file) : await tryFileToBuffer(new FileDescriptor(file));
90
85
  return await this.ingestFromStream(stream, ingestionProperties);
91
86
  }
92
87
  async ingestFromBlob(blob, ingestionProperties, clientRequestId) {
93
88
  var _a;
94
89
  const props = this._getMergedProps(ingestionProperties);
95
- const descriptor = blob instanceof descriptors_1.BlobDescriptor ? blob : new descriptors_1.BlobDescriptor(blob);
90
+ const descriptor = blob instanceof BlobDescriptor ? blob : new BlobDescriptor(blob);
96
91
  // No need to check blob size if it was given to us that it's not empty
97
92
  await descriptor.fillSize();
98
93
  const streamingResult = await this.streamWithRetries((_a = descriptor.size) !== null && _a !== void 0 ? _a : 0, descriptor, props, clientRequestId);
99
94
  return streamingResult !== null && streamingResult !== void 0 ? streamingResult : this.queuedIngestClient.ingestFromBlob(descriptor, props);
100
95
  }
101
96
  async streamWithRetries(length, descriptor, props, clientRequestId, stream) {
102
- const isBlob = descriptor instanceof descriptors_1.BlobDescriptor;
97
+ const isBlob = descriptor instanceof BlobDescriptor;
103
98
  if (length <= maxStreamSize) {
104
99
  // If we get buffer that means it was less than the max size, so we can do streamingIngestion
105
- const retry = new retry_1.ExponentialRetry(attemptCount, this.baseSleepTimeSecs, this.baseJitterSecs);
100
+ const retry = new ExponentialRetry(attemptCount, this.baseSleepTimeSecs, this.baseJitterSecs);
106
101
  while (retry.shouldTry()) {
107
102
  try {
108
103
  const sourceId = clientRequestId !== null && clientRequestId !== void 0 ? clientRequestId : `KNC.executeManagedStreamingIngest${isBlob ? "FromBlob" : "FromStream"};${descriptor.sourceId};${retry.currentAttempt}`;
109
104
  if (isBlob) {
110
105
  return await this.streamingIngestClient.ingestFromBlob(descriptor, props, sourceId);
111
106
  }
112
- if (core_util_1.isNode) {
113
- return await this.streamingIngestClient.ingestFromStream(new descriptors_1.StreamDescriptor((0, streamUtils_1.readableToStream)(stream)).merge(descriptor), props, sourceId);
107
+ if (isNode) {
108
+ return await this.streamingIngestClient.ingestFromStream(new StreamDescriptor(readableToStream(stream)).merge(descriptor), props, sourceId);
114
109
  }
115
110
  return await this.streamingIngestClient.ingestFromStream(descriptor, props, sourceId);
116
111
  }
@@ -122,7 +117,7 @@ class KustoManagedStreamingIngestClient extends abstractKustoClient_1.AbstractKu
122
117
  await retry.backoff();
123
118
  }
124
119
  }
125
- stream = isBlob ? undefined : core_util_1.isNode && stream ? (0, streamUtils_1.readableToStream)(stream) : descriptor.stream;
120
+ stream = isBlob ? undefined : isNode && stream ? readableToStream(stream) : descriptor.stream;
126
121
  }
127
122
  return null;
128
123
  }
@@ -134,5 +129,5 @@ class KustoManagedStreamingIngestClient extends abstractKustoClient_1.AbstractKu
134
129
  super.close();
135
130
  }
136
131
  }
137
- exports.default = KustoManagedStreamingIngestClient;
132
+ export default KustoManagedStreamingIngestClient;
138
133
  //# sourceMappingURL=managedStreamingIngestClient.js.map