azure-kusto-ingest 5.1.0 → 5.2.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 (35) hide show
  1. package/README.md +56 -57
  2. package/dist-esm/src/abstractKustoClient.js.map +1 -0
  3. package/dist-esm/src/columnMappings.js.map +1 -0
  4. package/dist-esm/src/descriptors.js.map +1 -0
  5. package/dist-esm/src/errors.js.map +1 -0
  6. package/dist-esm/src/fileDescriptor.browser.js.map +1 -0
  7. package/dist-esm/src/fileDescriptor.js.map +1 -0
  8. package/dist-esm/src/index.js +7 -6
  9. package/dist-esm/src/index.js.map +1 -0
  10. package/dist-esm/src/ingestClient.browser.js.map +1 -0
  11. package/dist-esm/src/ingestClient.js.map +1 -0
  12. package/dist-esm/src/ingestClientBase.js.map +1 -0
  13. package/dist-esm/src/ingestionBlobInfo.js.map +1 -0
  14. package/dist-esm/src/ingestionProperties.js.map +1 -0
  15. package/dist-esm/src/managedStreamingIngestClient.js +8 -9
  16. package/dist-esm/src/managedStreamingIngestClient.js.map +1 -0
  17. package/dist-esm/src/resourceManager.js.map +1 -0
  18. package/dist-esm/src/retry.js.map +1 -0
  19. package/dist-esm/src/status.js.map +1 -0
  20. package/dist-esm/src/statusQ.js.map +1 -0
  21. package/dist-esm/src/streamUtils.browser.js +6 -1
  22. package/dist-esm/src/streamUtils.browser.js.map +1 -0
  23. package/dist-esm/src/streamUtils.js +6 -2
  24. package/dist-esm/src/streamUtils.js.map +1 -0
  25. package/dist-esm/src/streamingIngestClient.browser.js.map +1 -0
  26. package/dist-esm/src/streamingIngestClient.js +1 -1
  27. package/dist-esm/src/streamingIngestClient.js.map +1 -0
  28. package/dist-esm/src/streamingIngestClientBase.js.map +1 -0
  29. package/package.json +5 -3
  30. package/types/src/index.d.ts +3 -6
  31. package/types/src/managedStreamingIngestClient.d.ts +4 -5
  32. package/types/src/streamUtils.browser.d.ts +1 -0
  33. package/types/src/streamUtils.d.ts +2 -1
  34. package/types/src/streamingIngestClient.browser.d.ts +1 -2
  35. package/types/src/streamingIngestClient.d.ts +2 -3
package/README.md CHANGED
@@ -10,19 +10,19 @@
10
10
  const IngestClient = require("azure-kusto-ingest").IngestClient;
11
11
  const IngestionProps = require("azure-kusto-ingest").IngestionProperties;
12
12
  const KustoConnectionStringBuilder = require("azure-kusto-data").KustoConnectionStringBuilder;
13
- const { DataFormat, JsonColumnMapping } = require("azure-kusto-ingest");
13
+ const {DataFormat, JsonColumnMapping} = require("azure-kusto-ingest");
14
14
 
15
15
  const kcsb = KustoConnectionStringBuilder.withAadApplicationKeyAuthentication(`https://ingest-${cluster}.kusto.windows.net`, appId, appKey, authorityId);
16
16
 
17
17
  const ingestionProps = new IngestionProps({
18
- database: "Database",
19
- table: "Table",
20
- format: DataFormat.JSON,
21
- ingestionMapping: [
22
- new JsonColumnMapping("TargetColumn1", "$.sourceProp1"),
23
- new JsonColumnMapping("TargetColumn2", "$.sourceProp2"),
24
- new JsonColumnMapping("TargetColumn3", "$.sourceProp3"),
25
- ],
18
+ database: "Database",
19
+ table: "Table",
20
+ format: DataFormat.JSON,
21
+ ingestionMapping: [
22
+ JsonColumnMapping.withPath("TargetColumn1", "$.sourceProp1"),
23
+ JsonColumnMapping.withPath("TargetColumn2", "$.sourceProp2"),
24
+ JsonColumnMapping.withPath("TargetColumn3", "$.sourceProp3"),
25
+ ],
26
26
  });
27
27
 
28
28
  const ingestClient = new IngestClient(kcsb, ingestionProps);
@@ -120,9 +120,9 @@ Example props:
120
120
 
121
121
  ```javascript
122
122
  const ingestionProps = new IngestionProps("Database", "Table", DataFormat.JSON, [
123
- new JsonColumnMapping("TargetColumn1", "$.sourceProp1"),
124
- new JsonColumnMapping("TargetColumn2", "$.sourceProp2"),
125
- new JsonColumnMapping("TargetColumn3", "$.sourceProp3"),
123
+ JsonColumnMapping.withPath("TargetColumn1", "$.sourceProp1"),
124
+ JsonColumnMapping.withPath("TargetColumn2", "$.sourceProp2"),
125
+ JsonColumnMapping.withPath("TargetColumn3", "$.sourceProp3"),
126
126
  ]);
127
127
  ```
128
128
 
@@ -142,7 +142,7 @@ catch(err){
142
142
  console.log(err);
143
143
  }
144
144
  console.log("Ingestion from stream DONE");
145
-
145
+ ````
146
146
 
147
147
  #### From File
148
148
 
@@ -180,60 +180,59 @@ Enabling is done simply but setting the `reportLevel` Ingestion Property to `Rep
180
180
  For Example:
181
181
 
182
182
  ```javascript
183
- const IngestClient = require("azure-kusto-ingest").IngestClient;
184
- const IngestStatusQueues = require("azure-kusto-ingest").IngestStatusQueues;
185
- const IngestionProps = require("azure-kusto-ingest").IngestionProperties;
186
- const { ReportLevel, ReportMethod } = require("azure-kusto-ingest");
187
- const KustoConnectionStringBuilder = require("azure-kusto-data").KustoConnectionStringBuilder;
188
- const { DataFormat, JsonColumnMapping } = require("azure-kusto-ingest");
189
- const fs = require("fs");
183
+ const IngestClient = require('azure-kusto-ingest').IngestClient;
184
+ const IngestStatusQueues = require('azure-kusto-ingest').IngestStatusQueues;
185
+ const IngestionProps = require('azure-kusto-ingest').IngestionProperties;
186
+ const {ReportLevel, ReportMethod} = require('azure-kusto-ingest');
187
+ const KustoConnectionStringBuilder = require('azure-kusto-data').KustoConnectionStringBuilder;
188
+ const {DataFormat, JsonColumnMapping} = require('azure-kusto-ingest');
189
+ const fs = require('fs');
190
190
 
191
191
  const ingestClient = new IngestClient(
192
192
  KustoConnectionStringBuilder.withAadApplicationKeyAuthentication(`https://ingest-${clusterName}.kusto.windows.net`, appId, appKey, authorityId),
193
- new IngestionProps(
194
- "db",
195
- "table",
196
- DataFormat.JSON,
197
- [new JsonColumnMapping("Id", "$.id"), new JsonColumnMapping("Type", "$.type"), new JsonColumnMapping("Value", "$.type")],
198
- null,
199
- null,
200
- null,
201
- null,
202
- null,
203
- null,
204
- ReportLevel.FailuresAndSuccesses,
205
- ReportMethod.Queue
206
- )
193
+ new IngestionProps({
194
+ database: 'Database',
195
+ table: 'Table',
196
+ format: DataFormat.JSON,
197
+ ingestionMapping: [
198
+ JsonColumnMapping.withPath('TargetColumn1', '$.sourceProp1'),
199
+ JsonColumnMapping.withPath('TargetColumn2', '$.sourceProp2'),
200
+ JsonColumnMapping.withPath('TargetColumn3', '$.sourceProp3'),
201
+ ],
202
+ ingestionMappingType: IngestionMappingKind.JSON,
203
+ reportLevel: ReportLevel.FailuresAndSuccesses,
204
+ reportMethod: ReportMethod.Queue,
205
+ })
207
206
  );
208
207
 
209
208
  const statusQueues = new IngestStatusQueues(ingestClient);
210
209
 
211
210
  async function waitForStatus() {
212
- while ((await statusQueues.failure.isEmpty()) && (await statusQueues.success.isEmpty())) {
213
- await new Promise((resolve) => {
214
- setTimeout(resolve, 1000);
215
- });
216
- }
217
-
218
- const successes = statusQueues.success.pop();
219
- for (let success of successes) {
220
- console.log(JSON.stringify(success));
221
- }
222
-
223
- const failures = statusQueues.failure.pop();
224
- for (let failure of failures) {
225
- console.log(JSON.stringify(failure));
226
- }
211
+ while ((await statusQueues.failure.isEmpty()) && (await statusQueues.success.isEmpty())) {
212
+ await new Promise((resolve) => {
213
+ setTimeout(resolve, 1000);
214
+ });
215
+ }
216
+
217
+ const successes = statusQueues.success.pop();
218
+ for (let success of successes) {
219
+ console.log(JSON.stringify(success));
220
+ }
221
+
222
+ const failures = statusQueues.failure.pop();
223
+ for (let failure of failures) {
224
+ console.log(JSON.stringify(failure));
225
+ }
227
226
  }
228
227
 
229
228
  async function ingestFromFile() {
230
- try {
231
- await ingestClient.ingestFromFile("file.json", null);
232
- } catch (err) {
233
- console.log(err);
234
- }
235
- console.log("Wait for ingestion status...");
236
- await waitForStatus();
229
+ try {
230
+ await ingestClient.ingestFromFile('file.json', null);
231
+ } catch (err) {
232
+ console.log(err);
233
+ }
234
+ console.log('Wait for ingestion status...');
235
+ await waitForStatus();
237
236
  }
238
237
  ```
239
238
 
@@ -249,4 +248,4 @@ try {
249
248
  } catch (err) {
250
249
  console.log(err);
251
250
  }
252
- ```
251
+ ```
@@ -0,0 +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"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"columnMappings.js","sourceRoot":"","sources":["../../src/columnMappings.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC,gHAAgH;AAEhH,+DAA6D;AAE7D,IAAY,mBAMX;AAND,WAAY,mBAAmB;IAC3B,oFAA6D,CAAA;IAC7D,0EAAmD,CAAA;IACnD,oFAA6D,CAAA;IAC7D,oFAA6D,CAAA;IAC7D,kFAA2D,CAAA;AAC/D,CAAC,EANW,mBAAmB,GAAnB,2BAAmB,KAAnB,2BAAmB,QAM9B;AAED,IAAY,sBAGX;AAHD,WAAY,sBAAsB;IAC9B,2DAAiC,CAAA;IACjC,+DAAqC,CAAA;AACzC,CAAC,EAHW,sBAAsB,GAAtB,8BAAsB,KAAtB,8BAAsB,QAGjC;AAsBD,MAAsB,aAAa;IAC/B,YAA+B,UAAkB,EAAW,WAAoB,EAAW,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BD,4CA2BC;AAED,MAAa,iBAAkB,SAAQ,aAAa;IAChD,YAA6B,UAAkB,EAAE,WAAoB,EAAE,KAAc,EAAE,aAAkB,EAAE,SAA0B;QACjI,KAAK,CAAC,UAAU,EAAE,WAAW,aAAX,WAAW,cAAX,WAAW,GAAI,SAAS,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC,CAAC;QADtF,eAAU,GAAV,UAAU,CAAQ;QAgB/C,gBAAW,GAAG,0CAAoB,CAAC,UAAU,CAAC;IAd9C,CAAC;IAEM,MAAM,CAAC,SAAS,CAAC,UAAkB,EAAE,KAAa,EAAE,WAAoB,EAAE,SAA+B;QAC5G,OAAO,IAAI,iBAAiB,CAAC,UAAU,EAAE,WAAW,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;IACvF,CAAC;IAEM,MAAM,CAAC,iBAAiB,CAAC,UAAkB,EAAE,aAAiB,EAAE,WAAoB;QACvF,OAAO,IAAI,iBAAiB,CAAC,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,aAAa,CAAC,CAAC;IACpF,CAAC;IAEM,MAAM,CAAC,aAAa,CAAC,UAAkB,EAAE,SAAiC,EAAE,WAAoB;QACnG,OAAO,IAAI,iBAAiB,CAAC,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;IAC3F,CAAC;CAGJ;AAlBD,8CAkBC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n/* eslint-disable @typescript-eslint/ban-types -- We legitimately want to use {} as a \"any non-nullable type\" */\n\nimport { IngestionMappingKind } from \"./ingestionProperties\";\n\nexport enum FieldTransformation {\n PropertyBagArrayToDictionary = \"PropertyBagArrayToDictionary\",\n DateTimeFromUnixSeconds = \"DateTimeFromUnixSeconds\",\n DateTimeFromUnixMilliseconds = \"DateTimeFromUnixMilliseconds\",\n DateTimeFromUnixMicroseconds = \"DateTimeFromUnixMicroseconds\",\n DateTimeFromUnixNanoseconds = \"DateTimeFromUnixNanoseconds\",\n}\n\nexport enum ConstantTransformation {\n SourceLocation = \"SourceLocation\",\n SourceLineNumber = \"SourceLineNumber\",\n}\n\nexport type Transformation = FieldTransformation | ConstantTransformation;\n\ninterface MappingProperties {\n Field?: string;\n Path?: string;\n Ordinal?: number;\n ConstValue?: {};\n Transform?: Transformation;\n}\n\ntype MappingPropertiesStrings = {\n [key in keyof MappingProperties]: string;\n};\n\ninterface ApiColumnMapping {\n Column: string;\n DataType?: string;\n Properties?: MappingPropertiesStrings;\n}\n\nexport abstract class ColumnMapping {\n protected constructor(readonly columnName: string, readonly cslDataType?: string, readonly Properties?: MappingProperties) {}\n\n public abstract mappingKind: IngestionMappingKind;\n\n public toApiMapping(): ApiColumnMapping {\n const result: ApiColumnMapping = {\n Column: this.columnName,\n };\n if (this.cslDataType) {\n result.DataType = this.cslDataType;\n }\n\n if (this.Properties) {\n result.Properties = {};\n for (const key in this.Properties) {\n if (Object.prototype.hasOwnProperty.call(this.Properties, key)) {\n const typedKey = key as keyof MappingProperties;\n const property = this.Properties[typedKey];\n\n // We don't do if (property) because we '0' is a legitimate value\n if (property !== undefined && property !== null) {\n result.Properties[typedKey] = property.toString();\n }\n }\n }\n }\n return result;\n }\n}\n\nexport class CsvColumnMapping extends ColumnMapping {\n /**\n * @deprecated Use the factory methods instead.\n */\n protected constructor(readonly columnName: string, readonly cslDataType?: string, readonly ordinal?: string, constantValue?: {}) {\n super(columnName, cslDataType, {\n Ordinal: ordinal === undefined ? undefined : parseInt(ordinal, 10),\n ConstValue: constantValue,\n });\n }\n\n public static withOrdinal(columnName: string, ordinal: number, cslDataType?: string): CsvColumnMapping {\n return new CsvColumnMapping(columnName, cslDataType, ordinal.toString());\n }\n\n public static withConstantValue(columnName: string, constantValue: {}, cslDataType?: string): CsvColumnMapping {\n return new CsvColumnMapping(columnName, cslDataType, undefined, constantValue);\n }\n\n mappingKind = IngestionMappingKind.CSV;\n}\n\nexport class JsonColumnMapping extends ColumnMapping {\n /**\n * @deprecated Use the factory methods instead.\n */\n constructor(readonly columnName: string, readonly jsonPath?: string, cslDataType: string | null = null, constantValue?: {}, transform?: Transformation) {\n super(columnName, cslDataType ?? undefined, {\n Path: jsonPath,\n ConstValue: constantValue,\n Transform: transform,\n });\n }\n\n public static withPath(columnName: string, path: string, cslDataType?: string, transform?: FieldTransformation): JsonColumnMapping {\n return new JsonColumnMapping(columnName, path, cslDataType, undefined, transform);\n }\n\n public static withConstantValue(columnName: string, constantValue: {}, cslDataType?: string): JsonColumnMapping {\n return new JsonColumnMapping(columnName, undefined, cslDataType, constantValue);\n }\n\n public static withTransform(columnName: string, transform: ConstantTransformation, cslDataType?: string): JsonColumnMapping {\n return new JsonColumnMapping(columnName, undefined, cslDataType, undefined, transform);\n }\n\n mappingKind = IngestionMappingKind.JSON;\n}\n\nexport class AvroColumnMapping extends ColumnMapping {\n private constructor(readonly columnName: string, cslDataType?: string, path?: string, field?: string, constantValue?: {}, transform?: Transformation) {\n super(columnName, cslDataType ?? undefined, {\n Path: path,\n Field: field,\n ConstValue: constantValue,\n Transform: transform,\n });\n }\n\n public static withPath(columnName: string, path: string, cslDataType?: string, transform?: FieldTransformation): AvroColumnMapping {\n return new AvroColumnMapping(columnName, cslDataType, path, undefined, undefined, transform);\n }\n\n public static withField(columnName: string, field: string, cslDataType?: string, transform?: FieldTransformation): AvroColumnMapping {\n return new AvroColumnMapping(columnName, cslDataType, undefined, field, undefined, transform);\n }\n\n public static withConstantValue(columnName: string, constantValue: {}, cslDataType?: string): AvroColumnMapping {\n return new AvroColumnMapping(columnName, cslDataType, undefined, undefined, constantValue);\n }\n\n public static withTransform(columnName: string, transform: ConstantTransformation, cslDataType?: string): AvroColumnMapping {\n return new AvroColumnMapping(columnName, cslDataType, undefined, undefined, undefined, transform);\n }\n\n mappingKind = IngestionMappingKind.AVRO;\n}\n\nexport class ApacheAvroColumnMapping extends ColumnMapping {\n private constructor(readonly columnName: string, cslDataType?: string, path?: string, field?: string, constantValue?: {}, transform?: Transformation) {\n super(columnName, cslDataType ?? undefined, {\n Path: path,\n Field: field,\n ConstValue: constantValue,\n Transform: transform,\n });\n }\n\n public static withPath(columnName: string, path: string, cslDataType?: string, transform?: FieldTransformation): ApacheAvroColumnMapping {\n return new ApacheAvroColumnMapping(columnName, cslDataType, path, undefined, undefined, transform);\n }\n\n public static withField(columnName: string, field: string, cslDataType?: string, transform?: FieldTransformation): ApacheAvroColumnMapping {\n return new ApacheAvroColumnMapping(columnName, cslDataType, undefined, field, undefined, transform);\n }\n\n public static withConstantValue(columnName: string, constantValue: {}, cslDataType?: string): ApacheAvroColumnMapping {\n return new ApacheAvroColumnMapping(columnName, cslDataType, undefined, undefined, constantValue);\n }\n\n public static withTransform(columnName: string, transform: ConstantTransformation, cslDataType?: string): ApacheAvroColumnMapping {\n return new ApacheAvroColumnMapping(columnName, cslDataType, undefined, undefined, undefined, transform);\n }\n\n mappingKind = IngestionMappingKind.APACHEAVRO;\n}\n\nexport class SStreamColumnMapping extends ColumnMapping {\n private constructor(readonly columnName: string, cslDataType?: string, path?: string, field?: string, constantValue?: {}, transform?: Transformation) {\n super(columnName, cslDataType ?? undefined, {\n Path: path,\n Field: field,\n ConstValue: constantValue,\n Transform: transform,\n });\n }\n\n public static withPath(columnName: string, path: string, cslDataType?: string, transform?: FieldTransformation): SStreamColumnMapping {\n return new SStreamColumnMapping(columnName, cslDataType, path, undefined, undefined, transform);\n }\n\n public static withField(columnName: string, field: string, cslDataType?: string, transform?: FieldTransformation): SStreamColumnMapping {\n return new SStreamColumnMapping(columnName, cslDataType, undefined, field, undefined, transform);\n }\n\n public static withConstantValue(columnName: string, constantValue: {}, cslDataType?: string): SStreamColumnMapping {\n return new SStreamColumnMapping(columnName, cslDataType, undefined, undefined, constantValue);\n }\n\n public static withTransform(columnName: string, transform: ConstantTransformation, cslDataType?: string): SStreamColumnMapping {\n return new SStreamColumnMapping(columnName, cslDataType, undefined, undefined, undefined, transform);\n }\n\n mappingKind = IngestionMappingKind.SSTREAM;\n}\n\nexport class ParquetColumnMapping extends ColumnMapping {\n private constructor(readonly columnName: string, cslDataType?: string, path?: string, field?: string, constantValue?: {}, transform?: Transformation) {\n super(columnName, cslDataType ?? undefined, {\n Path: path,\n Field: field,\n ConstValue: constantValue,\n Transform: transform,\n });\n }\n\n public static withPath(columnName: string, path: string, cslDataType?: string, transform?: FieldTransformation): ParquetColumnMapping {\n return new ParquetColumnMapping(columnName, cslDataType, path, undefined, undefined, transform);\n }\n\n public static withField(columnName: string, field: string, cslDataType?: string, transform?: FieldTransformation): ParquetColumnMapping {\n return new ParquetColumnMapping(columnName, cslDataType, undefined, field, undefined, transform);\n }\n\n public static withConstantValue(columnName: string, constantValue: {}, cslDataType?: string): ParquetColumnMapping {\n return new ParquetColumnMapping(columnName, cslDataType, undefined, undefined, constantValue);\n }\n\n public static withTransform(columnName: string, transform: ConstantTransformation, cslDataType?: string): ParquetColumnMapping {\n return new ParquetColumnMapping(columnName, cslDataType, undefined, undefined, undefined, transform);\n }\n\n mappingKind = IngestionMappingKind.PARQUET;\n}\n\nexport class OrcColumnMapping extends ColumnMapping {\n private constructor(readonly columnName: string, cslDataType?: string, path?: string, field?: string, constantValue?: {}, transform?: Transformation) {\n super(columnName, cslDataType ?? undefined, {\n Path: path,\n Field: field,\n ConstValue: constantValue,\n Transform: transform,\n });\n }\n\n public static withPath(columnName: string, path: string, cslDataType?: string, transform?: FieldTransformation): OrcColumnMapping {\n return new OrcColumnMapping(columnName, cslDataType, path, undefined, undefined, transform);\n }\n\n public static withField(columnName: string, field: string, cslDataType?: string, transform?: FieldTransformation): OrcColumnMapping {\n return new OrcColumnMapping(columnName, cslDataType, undefined, field, undefined, transform);\n }\n\n public static withConstantValue(columnName: string, constantValue: {}, cslDataType?: string): OrcColumnMapping {\n return new OrcColumnMapping(columnName, cslDataType, undefined, undefined, constantValue);\n }\n\n public static withTransform(columnName: string, transform: ConstantTransformation, cslDataType?: string): OrcColumnMapping {\n return new OrcColumnMapping(columnName, cslDataType, undefined, undefined, undefined, transform);\n }\n\n mappingKind = IngestionMappingKind.ORC;\n}\n\nexport class W3CLogFileMapping extends ColumnMapping {\n private constructor(readonly columnName: string, cslDataType?: string, field?: string, constantValue?: {}, transform?: Transformation) {\n super(columnName, cslDataType ?? undefined, { Field: field, ConstValue: constantValue, Transform: transform });\n }\n\n public static withField(columnName: string, field: string, cslDataType?: string, transform?: FieldTransformation): W3CLogFileMapping {\n return new W3CLogFileMapping(columnName, cslDataType, field, undefined, transform);\n }\n\n public static withConstantValue(columnName: string, constantValue: {}, cslDataType?: string): W3CLogFileMapping {\n return new W3CLogFileMapping(columnName, cslDataType, undefined, constantValue);\n }\n\n public static withTransform(columnName: string, transform: ConstantTransformation, cslDataType?: string): W3CLogFileMapping {\n return new W3CLogFileMapping(columnName, cslDataType, undefined, undefined, transform);\n }\n\n mappingKind = IngestionMappingKind.W3CLOGFILE;\n}\n"]}
@@ -0,0 +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,GAAf,uBAAe,KAAf,uBAAe,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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AAC,CAAC;YAC7C,MAAM,SAAS,GAAG,MAAM,UAAU,CAAC,aAAa,EAAE,CAAC;YACnD,MAAM,MAAM,GAAG,SAAS,CAAC,aAAa,CAAC;YACvC,IAAI,MAAM,KAAK,SAAS,EAAE;gBACtB,IAAI,MAAM,KAAK,CAAC,EAAE;oBACd,MAAM,IAAI,KAAK,CAAC,aAAa,CAAC,CAAC;iBAClC;gBACD,IAAI,CAAC,IAAI,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 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"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC,MAAa,kCAAmC,SAAQ,KAAK;IACzD,YAAY,OAAe;QACvB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,oCAAoC,CAAC;IACrD,CAAC;CACJ;AALD,gFAKC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nexport class IngestionPropertiesValidationError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"IngestionPropertiesValidationError\";\n }\n}\n"]}
@@ -0,0 +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"]}
@@ -0,0 +1 @@
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,+CAAwF;AAExF;;GAEG;AACH,MAAa,cAAe,SAAQ,gCAAkB;IAKlD;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,CAAC,IAAI,CAAC,IAAc,CAAC,CAAC,WAAW,EAAE,CAAC;QAE5F,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,KAAK;QACP,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,MAAM,IAAA,kBAAO,EAAC,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAA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,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;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"]}
@@ -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.StreamDescriptor = exports.BlobDescriptor = exports.ColumnMapping = exports.FieldTransformation = exports.ConstantTransformation = exports.SStreamColumnMapping = exports.ApacheAvroColumnMapping = exports.CompressionType = exports.IngestionMappingKind = exports.DataFormat = exports.ValidationOptions = exports.ValidationImplications = exports.ReportMethod = exports.ReportLevel = exports.ValidationPolicy = exports.W3CLogFileMapping = exports.OrcColumnMapping = exports.ParquetColumnMapping = exports.AvroColumnMapping = exports.CsvColumnMapping = exports.JsonColumnMapping = exports.IngestionDescriptors = exports.IngestionProperties = exports.IngestStatusQueues = exports.ManagedStreamingIngestClient = exports.StreamingIngestClient = exports.IngestClient = void 0;
8
+ exports.IngestionPropertiesValidationError = exports.IngestionPropertiesEnums = 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"));
@@ -22,11 +22,6 @@ Object.defineProperty(exports, "ReportMethod", { enumerable: true, get: function
22
22
  Object.defineProperty(exports, "ValidationImplications", { enumerable: true, get: function () { return ingestionProperties_1.ValidationImplications; } });
23
23
  Object.defineProperty(exports, "ValidationOptions", { enumerable: true, get: function () { return ingestionProperties_1.ValidationOptions; } });
24
24
  Object.defineProperty(exports, "ValidationPolicy", { enumerable: true, get: function () { return ingestionProperties_1.ValidationPolicy; } });
25
- const descriptors_1 = require("./descriptors");
26
- Object.defineProperty(exports, "BlobDescriptor", { enumerable: true, get: function () { return descriptors_1.BlobDescriptor; } });
27
- Object.defineProperty(exports, "CompressionType", { enumerable: true, get: function () { return descriptors_1.CompressionType; } });
28
- Object.defineProperty(exports, "StreamDescriptor", { enumerable: true, get: function () { return descriptors_1.StreamDescriptor; } });
29
- const fileDescriptor_1 = require("./fileDescriptor");
30
25
  const columnMappings_1 = require("./columnMappings");
31
26
  Object.defineProperty(exports, "ApacheAvroColumnMapping", { enumerable: true, get: function () { return columnMappings_1.ApacheAvroColumnMapping; } });
32
27
  Object.defineProperty(exports, "AvroColumnMapping", { enumerable: true, get: function () { return columnMappings_1.AvroColumnMapping; } });
@@ -39,6 +34,12 @@ Object.defineProperty(exports, "OrcColumnMapping", { enumerable: true, get: func
39
34
  Object.defineProperty(exports, "ParquetColumnMapping", { enumerable: true, get: function () { return columnMappings_1.ParquetColumnMapping; } });
40
35
  Object.defineProperty(exports, "SStreamColumnMapping", { enumerable: true, get: function () { return columnMappings_1.SStreamColumnMapping; } });
41
36
  Object.defineProperty(exports, "W3CLogFileMapping", { enumerable: true, get: function () { return columnMappings_1.W3CLogFileMapping; } });
37
+ const descriptors_1 = require("./descriptors");
38
+ Object.defineProperty(exports, "BlobDescriptor", { enumerable: true, get: function () { return descriptors_1.BlobDescriptor; } });
39
+ Object.defineProperty(exports, "CompressionType", { enumerable: true, get: function () { return descriptors_1.CompressionType; } });
40
+ Object.defineProperty(exports, "StreamDescriptor", { enumerable: true, get: function () { return descriptors_1.StreamDescriptor; } });
41
+ const fileDescriptor_1 = require("./fileDescriptor");
42
+ Object.defineProperty(exports, "FileDescriptor", { enumerable: true, get: function () { return fileDescriptor_1.FileDescriptor; } });
42
43
  var ingestionProperties_2 = require("./ingestionProperties");
43
44
  Object.defineProperty(exports, "IngestionProperties", { enumerable: true, get: function () { return ingestionProperties_2.IngestionProperties; } });
44
45
  /**
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;;;AAElC,kEAA+C;AAqCtB,uBArClB,sBAAiB,CAqCa;AAnCrC,oFAA4D;AAsC/B,gCAtCtB,+BAAqB,CAsCsB;AApClD,kGAA0E;AAmCtC,uCAnC7B,sCAA4B,CAmC6B;AAjChE,sDAA+C;AAgChB,6BAhCxB,gBAAuB,CAgCmB;AA9BjD,+DAQ+B;AA4C3B,2FAnDA,gCAAU,OAmDA;AAGV,qGArDA,0CAAoB,OAqDA;AAIpB,4FAxDA,iCAAW,OAwDA;AACX,6FAxDA,kCAAY,OAwDA;AAGZ,uGA1DA,4CAAsB,OA0DA;AACtB,kGA1DA,uC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wCAAuB;IACvB,oBAAoB,EAApB,qCAAoB;IACpB,sBAAsB,EAAtB,uCAAsB;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} 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};\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"]}
@@ -0,0 +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,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,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;YACtD,UAAU,CAAC,OAAO,EAAE;YACpB,IAAI,CAAC,eAAe,CAAC,kBAAkB,CAAC,IAAA,8BAAgB,EAAC,UAAU,EAAE,KAAK,CAAC,CAAC;SAC/E,CAAC,CAAC;QAEH,MAAM,eAAe,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;QAC/C,OAAO,IAAI,CAAC,cAAc,CAAC,IAAI,4BAAc,CAAC,eAAe,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,CAAC;IAC/G,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;QAErD,MAAM,eAAe,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC;QAChF,MAAM,eAAe,CAAC,UAAU,CAAC,UAAU,CAAC,MAAqB,CAAC,CAAC;QACnE,OAAO,IAAI,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"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ingestClient.js","sourceRoot":"","sources":["../../src/ingestClient.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;A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gB,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,8BAAgB,CAAC,MAAM,CAAC,CAAC;QAEhH,MAAM,QAAQ,GAAG,IAAA,8BAAgB,EAAC,UAAU,EAAE,KAAK,CAAC,CAAC;QAErD,MAAM,eAAe,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,kBAAkB,CAAC,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"]}
@@ -0,0 +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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AAC,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"]}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AM,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;AA3ED,8CA2EC;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\";\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\n constructor(blobDescriptor: BlobDescriptor, ingestionProperties: IngestionProperties, authContext: string | null = null) {\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\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"]}
@@ -0,0 +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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,EACV,EAAE;YACA,GAAG,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;QACtB,CAAC,CAAC;QAEF,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,CAAwC,EAAE;YAC9E,IAAI,UAAU,CAAC,GAAG,CAAC,EAAE;gBACjB,MAAM,CAAC,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;AAvFD,kDAuFC;AAID,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\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 default IngestionProperties;\n"]}
@@ -5,16 +5,15 @@ 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
+ const core_util_1 = require("@azure/core-util");
9
+ const azure_kusto_data_1 = require("azure-kusto-data");
10
+ const abstractKustoClient_1 = require("./abstractKustoClient");
8
11
  const descriptors_1 = require("./descriptors");
9
12
  const fileDescriptor_1 = require("./fileDescriptor");
10
- const abstractKustoClient_1 = require("./abstractKustoClient");
11
- const azure_kusto_data_1 = require("azure-kusto-data");
12
- const streamingIngestClient_1 = __importDefault(require("./streamingIngestClient"));
13
- const streamUtils_1 = require("./streamUtils");
14
13
  const ingestClient_1 = __importDefault(require("./ingestClient"));
15
- const stream_array_1 = __importDefault(require("stream-array"));
16
14
  const retry_1 = require("./retry");
17
- const core_util_1 = require("@azure/core-util");
15
+ const streamUtils_1 = require("./streamUtils");
16
+ const streamingIngestClient_1 = __importDefault(require("./streamingIngestClient"));
18
17
  const maxStreamSize = 1024 * 1024 * 4;
19
18
  const attemptCount = 3;
20
19
  const ingestPrefix = "https://ingest-";
@@ -78,7 +77,7 @@ class KustoManagedStreamingIngestClient extends abstractKustoClient_1.AbstractKu
78
77
  // tryStreamToArray returns a Buffer in NodeJS impl if stream size is small enouph
79
78
  if ((core_util_1.isNode && result instanceof Buffer) || !core_util_1.isNode) {
80
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);
81
- result = core_util_1.isNode ? (0, stream_array_1.default)([result]) : descriptor.stream;
80
+ result = core_util_1.isNode ? (0, streamUtils_1.readableToStream)(result) : descriptor.stream;
82
81
  }
83
82
  return streamingResult !== null && streamingResult !== void 0 ? streamingResult : this.queuedIngestClient.ingestFromStream(new descriptors_1.StreamDescriptor(result).merge(descriptor), props);
84
83
  }
@@ -111,7 +110,7 @@ class KustoManagedStreamingIngestClient extends abstractKustoClient_1.AbstractKu
111
110
  return this.streamingIngestClient.ingestFromBlob(descriptor, props, sourceId);
112
111
  }
113
112
  if (core_util_1.isNode) {
114
- return await this.streamingIngestClient.ingestFromStream(new descriptors_1.StreamDescriptor((0, stream_array_1.default)([stream])).merge(descriptor), props, sourceId);
113
+ return await this.streamingIngestClient.ingestFromStream(new descriptors_1.StreamDescriptor((0, streamUtils_1.readableToStream)(stream)).merge(descriptor), props, sourceId);
115
114
  }
116
115
  return await this.streamingIngestClient.ingestFromStream(descriptor, props, sourceId);
117
116
  }
@@ -123,7 +122,7 @@ class KustoManagedStreamingIngestClient extends abstractKustoClient_1.AbstractKu
123
122
  await retry.backoff();
124
123
  }
125
124
  }
126
- stream = isBlob ? undefined : core_util_1.isNode ? (0, stream_array_1.default)([stream]) : descriptor.stream;
125
+ stream = isBlob ? undefined : core_util_1.isNode && stream ? (0, streamUtils_1.readableToStream)(stream) : descriptor.stream;
127
126
  }
128
127
  return null;
129
128
  }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"managedStreamingIngestClient.js","sourceRoot":"","sources":["../../src/managedStreamingIngestClient.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;;AAIlC,gDAA0C;AAE1C,uDAAsF;AAEtF,+DAA4D;AAC5D,+CAAqF;AACrF,qDAAkD;AAClD,kEAA0C;AAC1C,mCAA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,KAAK,CAAC,UAA8B,CAAC,EACrF,KAAK,EACL,QAAQ,CACX,CAAC;qBACL;oBAED,OAAO,MAAM,IAAI,CAAC,qBAAqB,CAAC,gBAAgB,CAAC,UAA8B,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;iBAC7G;gBAAC,OAAO,GAAY,EAAE;oBACnB,MAAM,WAAW,GAAG,GAAiC,CAAC;oBACtD,IAAI,WAAW,CAAC,YAAY,CAAC,EAAE;wBAC3B,MAAM,GAAG,CAAC;qBACb;oBACD,MAAM,KAAK,CAAC,OAAO,EAAE,CAAC;iBACzB;aACJ;YAED,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,kBAAM,IAAI,MAAM,CAAC,CAAC,CAAC,IAAA,8BAAgB,EAAC,MAAM,CAAC,CAAC,CAAC,CAAE,UAA+B,CAAC,MAAM,CAAC;SACvH;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,KAAK;QACD,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;YACjB,IAAI,CAAC,qBAAqB,CAAC,KAAK,EAAE,CAAC;YACnC,IAAI,CAAC,kBAAkB,CAAC,KAAK,EAAE,CAAC;SACnC;QACD,KAAK,CAAC,KAAK,EAAE,CAAC;IAClB,CAAC;CACJ;AAED,kBAAe,iCAAiC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { IngestionPropertiesInput } from \"./ingestionProperties\";\n\nimport { isNode } from \"@azure/core-util\";\nimport { QueueSendMessageResponse } from \"@azure/storage-queue\";\nimport { KustoConnectionStringBuilder, KustoResponseDataSet } from \"azure-kusto-data\";\nimport { Readable } from \"stream\";\nimport { AbstractKustoClient } from \"./abstractKustoClient\";\nimport { AbstractDescriptor, BlobDescriptor, StreamDescriptor } from \"./descriptors\";\nimport { FileDescriptor } from \"./fileDescriptor\";\nimport IngestClient from \"./ingestClient\";\nimport { ExponentialRetry } from \"./retry\";\nimport { readableToStream, tryFileToBuffer, tryStreamToArray } from \"./streamUtils\";\nimport StreamingIngestClient from \"./streamingIngestClient\";\n\nconst maxStreamSize = 1024 * 1024 * 4;\nconst attemptCount = 3;\nconst ingestPrefix = \"https://ingest-\";\n\nclass KustoManagedStreamingIngestClient extends AbstractKustoClient {\n private streamingIngestClient: StreamingIngestClient;\n private queuedIngestClient: IngestClient;\n private baseSleepTimeSecs = 1;\n private baseJitterSecs = 1;\n\n /**\n * Creates a KustoManagedStreamingIngestClient from a DM connection string.\n * This method infers the engine connection string.\n * For advanced usage, use the constructor that takes a DM connection string and an engine connection string.\n *\n * @param dmConnectionString The DM connection string.\n * @param defaultProps The default ingestion properties.\n */\n static fromDmConnectionString(\n dmConnectionString: KustoConnectionStringBuilder,\n defaultProps?: IngestionPropertiesInput\n ): KustoManagedStreamingIngestClient {\n if (dmConnectionString.dataSource == null || !dmConnectionString.dataSource.startsWith(ingestPrefix)) {\n throw new Error(`DM connection string must include the prefix '${ingestPrefix}'`);\n }\n\n const engineConnectionString = KustoConnectionStringBuilder.fromExisting(dmConnectionString);\n engineConnectionString.dataSource = engineConnectionString.dataSource?.replace(ingestPrefix, \"https://\");\n\n return new KustoManagedStreamingIngestClient(engineConnectionString, dmConnectionString, defaultProps);\n }\n\n /**\n * Creates a KustoManagedStreamingIngestClient from a engine connection string.\n * This method infers the engine connection string.\n * For advanced usage, use the constructor that takes an engine connection string and an engine connection string.\n *\n * @param engineConnectionString The engine connection string.\n * @param defaultProps The default ingestion properties.\n */\n static fromEngineConnectionString(\n engineConnectionString: KustoConnectionStringBuilder,\n defaultProps?: IngestionPropertiesInput\n ): KustoManagedStreamingIngestClient {\n if (engineConnectionString.dataSource == null || engineConnectionString.dataSource.startsWith(ingestPrefix)) {\n throw new Error(`Engine connection string must not include the prefix '${ingestPrefix}'`);\n }\n\n const dmConnectionString = KustoConnectionStringBuilder.fromExisting(engineConnectionString);\n dmConnectionString.dataSource = dmConnectionString.dataSource?.replace(\"https://\", ingestPrefix);\n\n return new KustoManagedStreamingIngestClient(engineConnectionString, dmConnectionString, defaultProps);\n }\n\n constructor(engineKcsb: string | KustoConnectionStringBuilder, dmKcsb: string | KustoConnectionStringBuilder, defaultProps?: IngestionPropertiesInput) {\n super(defaultProps);\n this.streamingIngestClient = new StreamingIngestClient(engineKcsb, defaultProps);\n this.queuedIngestClient = new IngestClient(dmKcsb, defaultProps);\n\n if (this.streamingIngestClient.defaultDatabase && this.streamingIngestClient.defaultDatabase !== this.queuedIngestClient.defaultDatabase) {\n throw new Error(\n `Default database for streaming ingest client (${this.streamingIngestClient.defaultDatabase}) must match default database for queued ingest client (${this.queuedIngestClient.defaultDatabase})`\n );\n }\n\n this.defaultDatabase = this.streamingIngestClient.defaultDatabase;\n }\n\n /**\n * Use Readable for Node.js and ArrayBuffer in browser\n */\n async ingestFromStream(\n stream: StreamDescriptor | Readable | ArrayBuffer,\n ingestionProperties?: IngestionPropertiesInput,\n clientRequestId?: string\n ): Promise<any> {\n this.ensureOpen();\n const props = this._getMergedProps(ingestionProperties);\n let descriptor = stream instanceof StreamDescriptor ? stream : new StreamDescriptor(stream);\n let result = isNode ? await tryStreamToArray(descriptor.stream as Readable, maxStreamSize) : descriptor.stream;\n descriptor = new StreamDescriptor(result).merge(descriptor);\n let streamingResult: Promise<any> | null = null;\n // tryStreamToArray returns a Buffer in NodeJS impl if stream size is small enouph\n if ((isNode && result instanceof Buffer) || !isNode) {\n streamingResult = await this.streamWithRetries(\n isNode ? descriptor.size ?? 0 : (descriptor.stream as ArrayBuffer).byteLength,\n descriptor,\n props,\n clientRequestId,\n result\n );\n\n result = isNode ? readableToStream(result) : descriptor.stream;\n }\n\n return streamingResult ?? this.queuedIngestClient.ingestFromStream(new StreamDescriptor(result).merge(descriptor), props);\n }\n\n /**\n * Use string for Node.js and Blob in browser\n */\n async ingestFromFile(\n file: FileDescriptor | string | Blob,\n ingestionProperties?: IngestionPropertiesInput\n ): Promise<KustoResponseDataSet | QueueSendMessageResponse> {\n this.ensureOpen();\n\n const stream = file instanceof FileDescriptor ? await tryFileToBuffer(file) : await tryFileToBuffer(new FileDescriptor(file));\n return await this.ingestFromStream(stream, ingestionProperties);\n }\n\n async ingestFromBlob(blob: string | BlobDescriptor, ingestionProperties?: IngestionPropertiesInput, clientRequestId?: string): Promise<any> {\n const props = this._getMergedProps(ingestionProperties);\n const descriptor = blob instanceof BlobDescriptor ? blob : new BlobDescriptor(blob);\n // No need to check blob size if it was given to us that it's not empty\n await descriptor.fillSize();\n\n const streamingResult = await this.streamWithRetries(descriptor.size ?? 0, descriptor, props, clientRequestId);\n return streamingResult ?? this.queuedIngestClient.ingestFromBlob(descriptor, props);\n }\n\n async streamWithRetries(\n length: number,\n descriptor: AbstractDescriptor,\n props?: IngestionPropertiesInput,\n clientRequestId?: string,\n stream?: Readable | ArrayBuffer\n ): Promise<any> {\n const isBlob = descriptor instanceof BlobDescriptor;\n if (length <= maxStreamSize) {\n // If we get buffer that means it was less than the max size, so we can do streamingIngestion\n const retry = new ExponentialRetry(attemptCount, this.baseSleepTimeSecs, this.baseJitterSecs);\n while (retry.shouldTry()) {\n try {\n const sourceId =\n clientRequestId ??\n `KNC.executeManagedStreamingIngest${isBlob ? \"FromBlob\" : \"FromStream\"};${descriptor.sourceId};${retry.currentAttempt}`;\n if (isBlob) {\n return this.streamingIngestClient.ingestFromBlob(descriptor as BlobDescriptor, props, sourceId);\n }\n\n if (isNode) {\n return await this.streamingIngestClient.ingestFromStream(\n new StreamDescriptor(readableToStream(stream!)).merge(descriptor as StreamDescriptor),\n props,\n sourceId\n );\n }\n\n return await this.streamingIngestClient.ingestFromStream(descriptor as StreamDescriptor, props, sourceId);\n } catch (err: unknown) {\n const oneApiError = err as { \"@permanent\"?: boolean };\n if (oneApiError[\"@permanent\"]) {\n throw err;\n }\n await retry.backoff();\n }\n }\n\n stream = isBlob ? undefined : isNode && stream ? readableToStream(stream) : (descriptor as StreamDescriptor).stream;\n }\n\n return null;\n }\n\n close() {\n if (!this._isClosed) {\n this.streamingIngestClient.close();\n this.queuedIngestClient.close();\n }\n super.close();\n }\n}\n\nexport default KustoManagedStreamingIngestClient;\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resourceManager.js","sourceRoot":"","sources":["../../src/resourceManager.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC,uDAAsE;AACtE,mCAA2C;AAC3C,sDAAsD;AAEtD,MAAM,aAAa,GAAG,CAAC,CAAC;AACxB,MAAa,WAAW;IACpB,YAAqB,GAAW;QAAX,QAAG,GAAH,GAAG,CAAQ;IAAG,CAAC;CACvC;AAFD,kCAEC;AAED,MAAa,qBAAqB;IAC9B,YACa,mCAAyD,IAAI,EAC7D,yBAA+C,IAAI,EACnD,6BAAmD,IAAI,EACvD,aAAmC,IAAI;QAHvC,qCAAgC,GAAhC,gCAAgC,CAA6B;QAC7D,2BAAsB,GAAtB,sBAAsB,CAA6B;QACnD,+BAA0B,GAA1B,0BAA0B,CAA6B;QACvD,eAAU,GAAV,UAAU,CAA6B;IACjD,CAAC;IAEJ,KAAK;QACD,MAAM,SAAS,GAAG,CAAC,IAAI,CAAC,gCAAgC,EAAE,IAAI,CAAC,sBAAsB,EAAE,IAAI,CAAC,sBAAsB,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QACrI,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,OAAO,CAAC,EAAE,IAAI,CAAC,CAAC;IAC1E,CAAC;CACJ;AAZD,sDAYC;AAED,MAAa,eAAe;IAWxB,YAAqB,WAAmB,EAAW,YAAqB,KAAK;QAAxD,gBAAW,GAAX,WAAW,CAAQ;QAAW,cAAS,GAAT,SAAS,CAAiB;QAHrE,sBAAiB,GAAG,CAAC,CAAC;QACtB,mBAAc,GAAG,CAAC,CAAC;QAGvB,IAAI,CAAC,aAAa,GAAG,4BAAS,CAAC,cAAc,CAAC,C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AU,IAAI,IAAI,EAAE;YACpB,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;SAC/C;QACD,MAAM,SAAS,GAAG,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;QAC5E,MAAM,eAAe,GAAG,IAAI,8BAAe,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;QAC3D,OAAO,eAAe,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC;IACxD,CAAC;IAED,KAAK;QACD,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;IAC7B,CAAC;CACJ;AA/JD,0CA+JC;AAED,kBAAe,eAAe,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { Client, KustoDataErrors, TimeUtils } from \"azure-kusto-data\";\nimport { ExponentialRetry } from \"./retry\";\nimport { ContainerClient } from \"@azure/storage-blob\";\n\nconst ATTEMPT_COUNT = 4;\nexport class ResourceURI {\n constructor(readonly uri: string) {}\n}\n\nexport class IngestClientResources {\n constructor(\n readonly securedReadyForAggregationQueues: ResourceURI[] | null = null,\n readonly failedIngestionsQueues: ResourceURI[] | null = null,\n readonly successfulIngestionsQueues: ResourceURI[] | null = null,\n readonly containers: ResourceURI[] | null = null\n ) {}\n\n valid() {\n const resources = [this.securedReadyForAggregationQueues, this.failedIngestionsQueues, this.failedIngestionsQueues, this.containers];\n return resources.reduce((prev, current) => !!(prev && current), true);\n }\n}\n\nexport class ResourceManager {\n public readonly refreshPeriod: number;\n public refreshPeriodOnError: number;\n public ingestClientResources: IngestClientResources | null;\n public ingestClientResourcesLastUpdate: number | null;\n public authorizationContext: string | null;\n public authorizationContextLastUpdate: number | null;\n\n private baseSleepTimeSecs = 1;\n private baseJitterSecs = 1;\n\n constructor(readonly kustoClient: Client, readonly isBrowser: boolean = false) {\n this.refreshPeriod = TimeUtils.toMilliseconds(1, 0, 0);\n this.refreshPeriodOnError = TimeUtils.toMilliseconds(0, 10, 0);\n\n this.ingestClientResources = null;\n this.ingestClientResourcesLastUpdate = null;\n\n this.authorizationContext = null;\n this.authorizationContextLastUpdate = null;\n }\n\n async refreshIngestClientResources(): Promise<IngestClientResources> {\n const error = await this.tryRefresh(false);\n if (!this.ingestClientResources) {\n throw new Error(`Failed to fetch ingestion resources from service. ${error?.message}.\\n ${error?.stack}`);\n }\n\n return this.ingestClientResources;\n }\n\n async getIngestClientResourcesFromService(): Promise<IngestClientResources> {\n const retry = new ExponentialRetry(ATTEMPT_COUNT, this.baseSleepTimeSecs, this.baseJitterSecs);\n while (retry.shouldTry()) {\n try {\n const cmd = `.get ingestion resources ${this.isBrowser ? `with (EnableBlobCors='true', EnableQueueCors='true', EnableTableCors='true')` : \"\"}`;\n const response = await this.kustoClient.execute(\"NetDefaultDB\", cmd);\n const table = response.primaryResults[0];\n const resoures = new IngestClientResources(\n this.getResourceByName(table, \"SecuredReadyForAggregationQueue\"),\n this.getResourceByName(table, \"FailedIngestionsQueue\"),\n this.getResourceByName(table, \"SuccessfulIngestionsQueue\"),\n this.getResourceByName(table, \"TempStorage\")\n );\n\n if (!resoures.valid()) {\n throw new Error(\"Unexpected error occured - fetched data returned missing resource\");\n }\n\n return resoures;\n } catch (error: unknown) {\n if (!(error instanceof KustoDataErrors.ThrottlingError)) {\n throw error;\n }\n await retry.backoff();\n }\n }\n throw new Error(`Failed to get ingestion resources from server - the request was throttled ${ATTEMPT_COUNT} times.`);\n }\n\n getResourceByName(table: { rows: () => any }, resourceName: string): ResourceURI[] {\n const result: ResourceURI[] = [];\n for (const row of table.rows()) {\n const typedRow = row as {\n ResourceTypeName: string;\n StorageRoot: string;\n };\n if (typedRow.ResourceTypeName === resourceName) {\n result.push(new ResourceURI(typedRow.StorageRoot));\n }\n }\n return result;\n }\n\n async refreshAuthorizationContext(): Promise<string> {\n const error = await this.tryRefresh(true);\n\n if (this.authorizationContext == null) {\n throw new Error(`Failed to fetch Authorization context from service. ${error?.message}.\\n ${error?.stack}`);\n }\n\n return this.authorizationContext;\n }\n\n async tryRefresh(isAuthContextFetch: boolean): Promise<Error | null> {\n const resource = isAuthContextFetch ? this.authorizationContext?.trim() : this.ingestClientResources;\n const lastRefresh = isAuthContextFetch ? this.authorizationContextLastUpdate : this.ingestClientResourcesLastUpdate;\n const now = Date.now();\n let error: Error | null = null;\n if (!resource || !lastRefresh || lastRefresh + this.refreshPeriod <= now) {\n try {\n if (isAuthContextFetch) {\n this.authorizationContext = await this.getAuthorizationContextFromService();\n this.authorizationContextLastUpdate = now;\n } else {\n this.ingestClientResources = await this.getIngestClientResourcesFromService();\n this.ingestClientResourcesLastUpdate = now;\n }\n } catch (e) {\n error = e as Error;\n }\n }\n\n return error;\n }\n\n async getAuthorizationContextFromService() {\n const retry = new ExponentialRetry(ATTEMPT_COUNT, this.baseSleepTimeSecs, this.baseJitterSecs);\n while (retry.shouldTry()) {\n try {\n const response = await this.kustoClient.execute(\"NetDefaultDB\", \".get kusto identity token\");\n const next = response.primaryResults[0].rows().next();\n if (next.done) {\n throw new Error(\"Failed to get authorization context - got empty results\");\n }\n return next.value.toJSON<{ AuthorizationContext: string }>().AuthorizationContext;\n } catch (error: unknown) {\n if (!(error instanceof KustoDataErrors.ThrottlingError)) {\n throw error;\n }\n await retry.backoff();\n }\n }\n throw new Error(`Failed to get identity token from server - the request was throttled ${ATTEMPT_COUNT} times.`);\n }\n\n async getIngestionQueues() {\n return (await this.refreshIngestClientResources()).securedReadyForAggregationQueues;\n }\n\n async getFailedIngestionsQueues() {\n return (await this.refreshIngestClientResources()).failedIngestionsQueues;\n }\n\n async getSuccessfulIngestionsQueues() {\n return (await this.refreshIngestClientResources()).successfulIngestionsQueues;\n }\n\n async getContainers() {\n return (await this.refreshIngestClientResources()).containers;\n }\n\n async getAuthorizationContext(): Promise<string> {\n return this.refreshAuthorizationContext();\n }\n\n async getBlockBlobClient(blobName: string) {\n const containers = await this.getContainers();\n if (containers == null) {\n throw new Error(\"Failed to get containers\");\n }\n const container = containers[Math.floor(Math.random() * containers.length)];\n const containerClient = new ContainerClient(container.uri);\n return containerClient.getBlockBlobClient(blobName);\n }\n\n close() {\n this.kustoClient.close();\n }\n}\n\nexport default ResourceManager;\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retry.js","sourceRoot":"","sources":["../../src/retry.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAE3B,MAAM,KAAK,GAAG,CAAC,EAAU,EAAiB,EAAE;IAC/C,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC3B,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IAC5B,CAAC,CAAC,CAAC;AACP,CAAC,CAAC;AAJW,QAAA,KAAK,SAIhB;AAEF,MAAa,gBAAgB;IAGzB,YAAmB,YAAoB,EAAS,aAAqB,EAAS,aAAqB;QAAhF,iBAAY,GAAZ,YAAY,CAAQ;QAAS,kBAAa,GAAb,aAAa,CAAQ;QAAS,kBAAa,GAAb,aAAa,CAAQ;QAC/F,IAAI,CAAC,cAAc,GAAG,CAAC,CAAC;IAC5B,CAAC;IAEM,KAAK,CAAC,OAAO;QAChB,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,EAAE;YACnB,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;SAC3C;QAED,IAAI,CAAC,cAAc,EAAE,CAAC;QAEtB,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,EAAE;YACnB,6CAA6C;YAC7C,OAAO;SACV;QAED,MAAM,IAAI,GAAG,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,cAAc,GAAG,CAAC,CAAC,CAAC;QACvE,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;QAC9D,MAAM,IAAA,aAAK,EAAC,IAAI,GAAG,CAAC,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC;IACxC,CAAC;IAEM,SAAS;QACZ,OAAO,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,YAAY,CAAC;IACnD,CAAC;CACJ;AA3BD,4CA2BC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nexport const sleep = (ms: number): Promise<void> => {\n return new Promise((resolve) => {\n setTimeout(resolve, ms);\n });\n};\n\nexport class ExponentialRetry {\n public currentAttempt: number;\n\n constructor(public attemptCount: number, public sleepBaseSecs: number, public maxJitterSecs: number) {\n this.currentAttempt = 0;\n }\n\n public async backoff(): Promise<void> {\n if (!this.shouldTry()) {\n throw new Error(\"Max retries exceeded\");\n }\n\n this.currentAttempt++;\n\n if (!this.shouldTry()) {\n // This was the last retry - no need to sleep\n return;\n }\n\n const base = this.sleepBaseSecs * Math.pow(2, this.currentAttempt - 1);\n const jitter = Math.floor(this.maxJitterSecs * Math.random());\n await sleep(1000 * (base + jitter));\n }\n\n public shouldTry(): boolean {\n return this.currentAttempt < this.attemptCount;\n }\n}\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status.js","sourceRoot":"","sources":["../../src/status.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC,uCAAwC;AAIxC,MAAa,aAAa;IAStB,YAAY,GAAQ,EAAE,GAAQ,EAAE,UAA2B;QACvD,IAAI,KAAK,GAAa,CAAC,aAAa,EAAE,UAAU,EAAE,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,gBAAgB,CAAC,CAAC;QAEzH,IAAI,UAAU,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE;YACrC,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;SACpC;QAED,MAAM,IAAI,GAAwB,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;QAEhF,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;YACtB,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC;SAC3B;IACL,CAAC;CACJ;AAtBD,sCAsBC;AAED,MAAM,cAAe,SAAQ,aAAa;IAGtC,YAAY,GAAQ,EAAE,GAAQ;QAC1B,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC;IACrC,CAAC;CACJ;AAED,MAAM,cAAe,SAAQ,aAAa;IAOtC,YAAY,GAAQ,EAAE,GAAQ;QAC1B,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,eAAe,EAAE,4BAA4B,EAAE,aAAa,CAAC,CAAC,CAAC;IACxH,CAAC;CACJ;AAED,MAAa,uBAAuB;IAGhC,YAAY,iBAAoC;QAC5C,IAAI,CAAC,OAAO,GAAG,IAAI,qBAAW,CAAC,GAAG,EAAE,CAAC,iBAAiB,CAAC,eAAe,CAAC,6BAA6B,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAkB,CAAC,EAAE,cAAc,CAAC,CAAC;QACxJ,IAAI,CAAC,OAAO,GAAG,IAAI,qBAAW,CAAC,GAAG,EAAE,CAAC,iBAAiB,CAAC,eAAe,CAAC,yBAAyB,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAkB,CAAC,EAAE,cAAc,CAAC,CAAC;IACxJ,CAAC;CACJ;AAPD,0DAOC;AAED,kBAAe,uBAAuB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { StatusQueue } from \"./statusQ\";\nimport KustoIngestClient from \"./ingestClient\";\nimport { ResourceURI } from \"./resourceManager\";\n\nexport class StatusMessage {\n OperationId?: string;\n Database?: string;\n Table?: string;\n IngestionSourceId?: string;\n IngestionSourcePath?: string;\n RootActivityId?: string;\n\n [other: string]: any;\n constructor(raw: any, obj: any, extraProps: string[] | null) {\n let props: string[] = [\"OperationId\", \"Database\", \"Table\", \"IngestionSourceId\", \"IngestionSourcePath\", \"RootActivityId\"];\n\n if (extraProps && extraProps.length > 0) {\n props = props.concat(extraProps);\n }\n\n const _obj: Record<string, any> = obj || JSON.parse(raw || JSON.stringify(raw));\n\n for (const prop of props) {\n this[prop] = _obj[prop];\n }\n }\n}\n\nclass SuccessMessage extends StatusMessage {\n SucceededOn?: string;\n\n constructor(raw: any, obj: any) {\n super(raw, obj, [\"SucceededOn\"]);\n }\n}\n\nclass FailureMessage extends StatusMessage {\n FailedOn?: string;\n Details?: string;\n ErrorCode?: string;\n FailureStatus?: string;\n OriginatesFromUpdatePolicy?: string;\n ShouldRetry?: string;\n constructor(raw: any, obj: any) {\n super(raw, obj, [\"FailedOn\", \"Details\", \"ErrorCode\", \"FailureStatus\", \"OriginatesFromUpdatePolicy\", \"ShouldRetry\"]);\n }\n}\n\nexport class KustoIngestStatusQueues {\n success: StatusQueue;\n failure: StatusQueue;\n constructor(kustoIngestClient: KustoIngestClient) {\n this.success = new StatusQueue(() => kustoIngestClient.resourceManager.getSuccessfulIngestionsQueues().then((r) => r as ResourceURI[]), SuccessMessage);\n this.failure = new StatusQueue(() => kustoIngestClient.resourceManager.getFailedIngestionsQueues().then((r) => r as ResourceURI[]), FailureMessage);\n }\n}\n\nexport default KustoIngestStatusQueues;\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"statusQ.js","sourceRoot":"","sources":["../../src/statusQ.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC,wDAAsE;AAItE,MAAM,YAAY;IACd,YAAqB,IAAY,EAAW,OAAoB;QAA3C,SAAI,GAAJ,IAAI,CAAQ;QAAW,YAAO,GAAP,OAAO,CAAa;IAAG,CAAC;CACvE;AAED,MAAM,OAAO,GAAG,CAAI,CA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,sDAAsD;QACtD,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;QAC1D,IAAI,OAAO,CAAC,IAAI,EAAE;YACd,OAAO,OAAO,CAAC,MAAM,CAAC;SACzB;QAED,MAAM,iBAAiB,GAAG,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC;QAEpD,2FAA2F;QAC3F,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,MAAA,OAAO,CAAC,MAAM,CAAC,UAAU,mCAAI,EAAE,EAAE,iBAAiB,EAAE,OAAO,CAAC,CAAC;QAC3F,OAAO,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAC/C,CAAC;CACJ;AApHD,kCAoHC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { PeekedMessageItem, QueueClient } from \"@azure/storage-queue\";\nimport { ResourceURI } from \"./resourceManager\";\nimport { StatusMessage } from \"./status\";\n\nclass QueueDetails {\n constructor(readonly name: string, readonly service: QueueClient) {}\n}\n\nconst shuffle = <T>(a: T[]): T[] => {\n for (let i = a.length - 1; i > 0; i--) {\n const j = Math.floor(Math.random() * (i + 1));\n const temp = a[j];\n a[j] = a[i];\n a[i] = temp;\n }\n\n return a;\n};\n\ninterface PeekParams {\n raw: boolean;\n}\n\ninterface PopParams {\n raw: boolean;\n remove: boolean;\n}\n\ntype Message = PeekedMessageItem | StatusMessage;\n\nexport class StatusQueue {\n constructor(readonly getQueuesFunc: () => Promise<ResourceURI[]>, readonly messageCls: typeof StatusMessage) {}\n\n _getQServices(queuesDetails: ResourceURI[]) {\n return queuesDetails.map((q) => {\n const fullUri = q.uri;\n if (!fullUri) {\n throw new Error(\"Empty or null connection string\");\n }\n // chop off sas\n const indexOfSas = q.uri.indexOf(\"?\");\n const name = indexOfSas > 0 ? q.uri.substring(0, indexOfSas) : q.uri;\n return new QueueDetails(name, new QueueClient(fullUri));\n });\n }\n\n async isEmpty() {\n const result = await this.peek(1, { raw: true });\n return !result || result.length === 0;\n }\n\n decodeContent(content: string) {\n return Buffer.from(content, \"base64\").toString(\"ascii\");\n }\n\n deserializeMessage(m: PeekedMessageItem): StatusMessage {\n return new this.messageCls(this.decodeContent(m.messageText), null, null);\n }\n\n async _peek(qs: QueueDetails[], n: number, options: PeekParams | null): Promise<{ result: Message[]; nonEmptyQs: QueueDetails[]; done: boolean }> {\n const result: Message[] = [];\n const nonEmptyQs: QueueDetails[] = [];\n\n for (const q of qs) {\n const response = await q.service.peekMessages();\n const messages = response.peekedMessageItems;\n\n if (messages && messages.length > 0) {\n nonEmptyQs.push(q);\n }\n\n for (const m of messages) {\n if (m && Object.keys(m).length > 0) {\n result.push(options && options.raw ? m : this.deserializeMessage(m));\n\n if (result.length === n) {\n return { done: true, nonEmptyQs, result };\n }\n }\n }\n }\n return { done: nonEmptyQs.length === 0, nonEmptyQs, result };\n }\n\n async peek(n = 1, options: PeekParams | null = null): Promise<Message[]> {\n const queues = await this.getQueuesFunc();\n const qServices: QueueDetails[] = shuffle(this._getQServices(queues));\n const perQ = qServices.length > 1 ? Math.floor(n / qServices.length) : qServices.length;\n\n // First, iterate evenly and randomly on status queues\n const partial = await this._peek(qServices, perQ, options);\n\n if (partial.done) {\n return partial.result;\n }\n const messagesLeftToPeek = n - partial.result.length;\n\n // In case queues are uneven, iterate again. This time, request for all n messages and trim\n return (await this._peek(partial.nonEmptyQs, messagesLeftToPeek, options)).result;\n }\n\n async _pop(\n qs: QueueDetails[],\n n: number,\n options: PopParams | null\n ): Promise<{ result: Message[] & { nonEmptyQs?: QueueDetails[] }; nonEmptyQs: any[]; done: boolean }> {\n const nonEmptyQs: any[] = [];\n const result = [];\n\n for (const q of qs) {\n const response = await q.service.receiveMessages({ numOfMessages: n });\n const messages = response.receivedMessageItems;\n for (const m of messages) {\n if (m && Object.keys(m).length > 0) {\n result.push(options && options.raw ? m : this.deserializeMessage(m));\n\n if (!(options && !options.remove)) {\n await q.service.deleteMessage(m.messageId, m.popReceipt);\n }\n if (result.length === n) {\n return { done: true, nonEmptyQs, result };\n }\n }\n }\n }\n\n return { done: nonEmptyQs.length === 0, nonEmptyQs, result };\n }\n\n async pop(n = 1, options: PopParams | null = null): Promise<Message[]> {\n const queues = await this.getQueuesFunc();\n const qServices = shuffle(this._getQServices(queues));\n const perQ = qServices.length > 1 ? Math.floor(n / qServices.length) : qServices.length;\n\n // First, iterate evenly and randomly on status queues\n const partial = await this._pop(qServices, perQ, options);\n if (partial.done) {\n return partial.result;\n }\n\n const messagesLeftToPop = n - partial.result.length;\n\n // In case queues are uneven, iterate again. This time, request for all n messages and trim\n const final = await this._pop(partial.result.nonEmptyQs ?? [], messagesLeftToPop, options);\n return partial.result.concat(final.result);\n }\n}\n"]}
@@ -2,7 +2,7 @@
2
2
  // Copyright (c) Microsoft Corporation.
3
3
  // Licensed under the MIT License.
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.tryStreamToArray = exports.tryFileToBuffer = exports.fileToStream = void 0;
5
+ exports.readableToStream = exports.tryStreamToArray = exports.tryFileToBuffer = exports.fileToStream = void 0;
6
6
  const descriptors_1 = require("./descriptors");
7
7
  const fileToStream = async (file) => {
8
8
  const streamFs = await file.file.arrayBuffer();
@@ -19,4 +19,9 @@ const tryStreamToArray = async (stream) => {
19
19
  return Promise.resolve(stream);
20
20
  };
21
21
  exports.tryStreamToArray = tryStreamToArray;
22
+ // NOT USED
23
+ const readableToStream = (stream) => {
24
+ return stream;
25
+ };
26
+ exports.readableToStream = readableToStream;
22
27
  //# sourceMappingURL=streamUtils.browser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"streamUtils.browser.js","sourceRoot":"","sources":["../../src/streamUtils.browser.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC,+CAAkE;AAG3D,MAAM,YAAY,GAAG,KAAK,EAAE,IAAoB,EAA6B,EAAE;IAClF,MAAM,QAAQ,GAAG,MAAO,IAAI,CAAC,IAAa,CAAC,WAAW,EAAE,CAAC;IACzD,MAAM,eAAe,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,6BAAe,CAAC,IAAI,CAAC,CAAC,CAAC,6BAAe,CAAC,IAAI,CAAC;IAClF,OAAO,IAAI,8BAAgB,CAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC;AAC1E,CAAC,CAAC;AAJW,QAAA,YAAY,gBAIvB;AAEK,MAAM,eAAe,GAAG,KAAK,EAAE,IAAoB,EAA6B,EAAE;IACrF,OAAO,MAAM,IAAA,oBAAY,EAAC,IAAI,CAAC,CAAC;AACpC,CAAC,CAAC;AAFW,QAAA,eAAe,mBAE1B;AAEF,WAAW;AACJ,MAAM,gBAAgB,GAAG,KAAK,EAAE,MAAW,EAAmB,EAAE;IACnE,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;AACnC,CAAC,CAAC;AAFW,QAAA,gBAAgB,oBAE3B;AAEF,WAAW;AACJ,MAAM,gBAAgB,GAAG,CAAC,MAAmB,EAAe,EAAE;IACjE,OAAO,MAAM,CAAC;AAClB,CAAC,CAAC;AAFW,QAAA,gBAAgB,oBAE3B","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { CompressionType, StreamDescriptor } from \"./descriptors\";\nimport { FileDescriptor } from \"./fileDescriptor.browser\";\n\nexport const fileToStream = async (file: FileDescriptor): Promise<StreamDescriptor> => {\n const streamFs = await (file.file as Blob).arrayBuffer();\n const compressionType = file.zipped ? CompressionType.GZIP : CompressionType.None;\n return new StreamDescriptor(streamFs, file.sourceId, compressionType);\n};\n\nexport const tryFileToBuffer = async (file: FileDescriptor): Promise<StreamDescriptor> => {\n return await fileToStream(file);\n};\n\n// NOT USED\nexport const tryStreamToArray = async (stream: any): Promise<Buffer> => {\n return Promise.resolve(stream);\n};\n\n// NOT USED\nexport const readableToStream = (stream: ArrayBuffer): ArrayBuffer => {\n return stream;\n};\n"]}
@@ -5,11 +5,11 @@ 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.tryStreamToArray = exports.tryFileToBuffer = exports.fileToStream = void 0;
9
- const descriptors_1 = require("./descriptors");
8
+ exports.readableToStream = exports.tryStreamToArray = exports.tryFileToBuffer = exports.fileToStream = void 0;
10
9
  const fs_1 = __importDefault(require("fs"));
11
10
  const stream_1 = require("stream");
12
11
  const stream_array_1 = __importDefault(require("stream-array"));
12
+ const descriptors_1 = require("./descriptors");
13
13
  // Returns fs.ReadStream for node and NodeJS.ReadableStream in browser
14
14
  const fileToStream = (fileDescriptor) => {
15
15
  const streamFs = fs_1.default.createReadStream(fileDescriptor.file);
@@ -63,4 +63,8 @@ const tryStreamToArray = async (stream, maxBufferSize) => {
63
63
  });
64
64
  };
65
65
  exports.tryStreamToArray = tryStreamToArray;
66
+ const readableToStream = (stream) => {
67
+ return (0, stream_array_1.default)([stream]);
68
+ };
69
+ exports.readableToStream = readableToStream;
66
70
  //# sourceMappingURL=streamUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"streamUtils.js","sourceRoot":"","sources":["../../src/streamUtils.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;;;AAElC,4CAAoB;AACpB,mCAA+C;AAC/C,gEAAqC;AACrC,+CAAkE;AAGlE,sEAAsE;AAC/D,MAAM,YAAY,GAAG,CAAC,cAA8B,EAA6B,EAAE;IACtF,MAAM,QAAQ,GAAG,YAAE,CAAC,gBAAgB,CAAC,cAAc,CAAC,IAAc,CAAC,CAAC;IACpE,MAAM,eAAe,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,6BAAe,CAAC,IAAI,CAAC,CAAC,CAAC,6BAAe,CAAC,IAA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Corporation.\n// Licensed under the MIT License.\n\nimport fs from \"fs\";\nimport { PassThrough, Readable } from \"stream\";\nimport streamify from \"stream-array\";\nimport { CompressionType, StreamDescriptor } from \"./descriptors\";\nimport { FileDescriptor } from \"./fileDescriptor\";\n\n// Returns fs.ReadStream for node and NodeJS.ReadableStream in browser\nexport const fileToStream = (fileDescriptor: FileDescriptor): Promise<StreamDescriptor> => {\n const streamFs = fs.createReadStream(fileDescriptor.file as string);\n const compressionType = fileDescriptor.zipped ? CompressionType.GZIP : CompressionType.None;\n return Promise.resolve(new StreamDescriptor(streamFs, fileDescriptor.sourceId, compressionType));\n};\n\n// Used in managed streaming where we buffer the file to memory for retries\nexport const tryFileToBuffer = async (fileDescriptor: FileDescriptor): Promise<StreamDescriptor> => {\n try {\n const buffer = fs.readFileSync(fileDescriptor.file as string);\n const compressionType = fileDescriptor.zipped ? CompressionType.GZIP : CompressionType.None;\n return new StreamDescriptor(buffer, fileDescriptor.sourceId, compressionType);\n } catch (error) {\n return await fileToStream(fileDescriptor);\n }\n};\n\nconst mergeStreams = (...streams: Readable[]): Readable => {\n let pass = new PassThrough();\n let waiting = streams.length;\n for (const stream of streams) {\n pass = stream.pipe(pass, { end: false });\n stream.once(\"end\", () => --waiting === 0 && pass.emit(\"end\"));\n }\n return pass;\n};\n\nexport const tryStreamToArray = async (stream: Readable, maxBufferSize: number): Promise<Buffer | Readable> => {\n if (stream instanceof Buffer) {\n return stream;\n }\n return await new Promise<Buffer | Readable>((resolve, reject) => {\n const result: Buffer[] = [];\n const endListener = () => resolve(Buffer.concat(result));\n const dataHandler = (chunk: Buffer) => {\n try {\n result.push(chunk);\n if (result.reduce((sum, b) => sum + b.length, 0) > maxBufferSize) {\n stream.removeListener(\"data\", dataHandler);\n stream.removeListener(\"end\", endListener);\n resolve(mergeStreams(streamify(result), stream));\n }\n } catch (e) {\n reject(e);\n }\n };\n stream.on(\"data\", dataHandler);\n stream.on(\"end\", endListener);\n });\n};\n\nexport const readableToStream = (stream: Readable | ArrayBuffer): Readable => {\n return streamify([stream]);\n};\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"streamingIngestClient.browser.js","sourceRoot":"","sources":["../../src/streamingIngestClient.browser.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;AAKlC,+CAAiD;AACjD,qEAA0D;AAC1D,+DAAwD;AACxD,2EAA6E;AAE7E,MAAM,0BAA2B,SAAQ,0DAA8B;IACnE,YAAY,IAA2C,EAAE,YAAuC;QAC5F,KAAK,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;IAC9B,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,gBAAgB,CAAC,MAAsC,EAAE,mBAA8C,EAAE,eAAwB;;QACnI,IAAI,CAAC,UAAU,EAAE,CAAC;QAElB,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,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,sBAAsB,CAChD,KAAK,CAAC,QAAkB,EACxB,KAAK,CAAC,KAAe,EACrB,UAAU,CAAC,MAAM,EACjB,KAAK,CAAC,MAAM,EACZ,MAAA,KAAK,CAAC,yBAAyB,mCAAI,IAAI,EACvC,eAAe,CAClB,CAAC;IACN,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,cAAc,CAAC,IAA2B,EAAE,mBAA8C;QAC5F,IAAI,CAAC,UAAU,EAAE,CAAC;QAElB,MAAM,UAAU,GAAmB,IAAI,YAAY,uCAAc,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,uCAAc,CAAC,IAAI,CAAC,CAAC;QACpG,OAAO,IAAI,CAAC,gBAAgB,CAAC,MAAM,IAAA,qCAAe,EAAC,UAAU,CAAC,EAAE,mBAAmB,CAAC,CAAC;IACzF,CAAC;CACJ;AAED,kBAAe,0BAA0B,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { IngestionPropertiesInput } from \"./ingestionProperties\";\n\nimport { KustoConnectionStringBuilder, KustoResponseDataSet } from \"azure-kusto-data\";\nimport { StreamDescriptor } from \"./descriptors\";\nimport { FileDescriptor } from \"./fileDescriptor.browser\";\nimport { tryFileToBuffer } from \"./streamUtils.browser\";\nimport { KustoStreamingIngestClientBase } from \"./streamingIngestClientBase\";\n\nclass KustoStreamingIngestClient extends KustoStreamingIngestClientBase {\n constructor(kcsb: string | KustoConnectionStringBuilder, defaultProps?: IngestionPropertiesInput) {\n super(kcsb, defaultProps);\n }\n\n /**\n * Use Readable for Node.js and ArrayBuffer in browser\n */\n async ingestFromStream(stream: StreamDescriptor | ArrayBuffer, ingestionProperties?: IngestionPropertiesInput, clientRequestId?: string): Promise<any> {\n this.ensureOpen();\n\n const props = this._getMergedProps(ingestionProperties);\n const descriptor: StreamDescriptor = stream instanceof StreamDescriptor ? stream : new StreamDescriptor(stream);\n return await this.kustoClient.executeStreamingIngest(\n props.database as string,\n props.table as string,\n descriptor.stream,\n props.format,\n props.ingestionMappingReference ?? null,\n clientRequestId\n );\n }\n\n /**\n * Use string for Node.js and Blob in browser\n */\n async ingestFromFile(file: FileDescriptor | Blob, ingestionProperties?: IngestionPropertiesInput): Promise<KustoResponseDataSet> {\n this.ensureOpen();\n\n const descriptor: FileDescriptor = file instanceof FileDescriptor ? file : new FileDescriptor(file);\n return this.ingestFromStream(await tryFileToBuffer(descriptor), ingestionProperties);\n }\n}\n\nexport default KustoStreamingIngestClient;\n"]}
@@ -5,9 +5,9 @@ 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
+ const zlib_1 = __importDefault(require("zlib"));
8
9
  const descriptors_1 = require("./descriptors");
9
10
  const fileDescriptor_1 = require("./fileDescriptor");
10
- const zlib_1 = __importDefault(require("zlib"));
11
11
  const streamUtils_1 = require("./streamUtils");
12
12
  const streamingIngestClientBase_1 = require("./streamingIngestClientBase");
13
13
  class KustoStreamingIngestClient extends streamingIngestClientBase_1.KustoStreamingIngestClientBase {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"streamingIngestClient.js","sourceRoot":"","sources":["../../src/streamingIngestClient.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;;AAMlC,gDAAwB;AACxB,+CAAkE;AAClE,qDAAkD;AAClD,+CAA6C;AAC7C,2EAA6E;AAE7E,MAAM,0BAA2B,SAAQ,0DAA8B;IACnE,YAAY,IAA2C,EAAE,YAAuC;QAC5F,KAAK,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;IAC9B,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,gBAAgB,CAClB,MAAiD,EACjD,mBAA8C,EAC9C,eAAwB;;QAExB,IAAI,CAAC,UAAU,EAAE,CAAC;QAElB,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;QAEhH,MAAM,gBAAgB,GAClB,UAAU,CAAC,eAAe,KAAK,6BAAe,CAAC,IAAI;YAC/C,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,YAAY,WAAW,CAAC;gBACzC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,cAAI,CAAC,UAAU,EAAE,CAAC;gBAC3C,CAAC,CAAC,UAAU,CAAC,MAAM;YACvB,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC;QAC5B,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,sBAAsB,CAChD,KAAK,CAAC,QAAkB,EACxB,KAAK,CAAC,KAAe,EACrB,gBAAgB,EAChB,KAAK,CAAC,MAAM,EACZ,MAAA,KAAK,CAAC,yBAAyB,mCAAI,IAAI,EACvC,eAAe,CAClB,CAAC;IACN,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,cAAc,CAAC,IAAoC,EAAE,mBAA8C;QACrG,IAAI,CAAC,UAAU,EAAE,CAAC;QAElB,MAAM,UAAU,GAAmB,IAAI,YAAY,+BAAc,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,+BAAc,CAAC,IAAI,CAAC,CAAC;QACpG,OAAO,IAAI,CAAC,gBAAgB,CAAC,MAAM,IAAA,0BAAY,EAAC,UAAU,CAAC,EAAE,mBAAmB,CAAC,CAAC;IACtF,CAAC;CACJ;AAED,kBAAe,0BAA0B,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { IngestionPropertiesInput } from \"./ingestionProperties\";\n\nimport { KustoConnectionStringBuilder, KustoResponseDataSet } from \"azure-kusto-data\";\nimport { Readable } from \"stream\";\nimport zlib from \"zlib\";\nimport { CompressionType, StreamDescriptor } from \"./descriptors\";\nimport { FileDescriptor } from \"./fileDescriptor\";\nimport { fileToStream } from \"./streamUtils\";\nimport { KustoStreamingIngestClientBase } from \"./streamingIngestClientBase\";\n\nclass KustoStreamingIngestClient extends KustoStreamingIngestClientBase {\n constructor(kcsb: string | KustoConnectionStringBuilder, defaultProps?: IngestionPropertiesInput) {\n super(kcsb, defaultProps);\n }\n\n /**\n * Use Readable for Node.js and ArrayBuffer in browser\n */\n async ingestFromStream(\n stream: StreamDescriptor | Readable | ArrayBuffer,\n ingestionProperties?: IngestionPropertiesInput,\n clientRequestId?: string\n ): Promise<any> {\n this.ensureOpen();\n\n const props = this._getMergedProps(ingestionProperties);\n const descriptor: StreamDescriptor = stream instanceof StreamDescriptor ? stream : new StreamDescriptor(stream);\n\n const compressedStream =\n descriptor.compressionType === CompressionType.None\n ? !(descriptor.stream instanceof ArrayBuffer)\n ? descriptor.stream.pipe(zlib.createGzip())\n : descriptor.stream\n : descriptor.stream;\n return await this.kustoClient.executeStreamingIngest(\n props.database as string,\n props.table as string,\n compressedStream,\n props.format,\n props.ingestionMappingReference ?? null,\n clientRequestId\n );\n }\n\n /**\n * Use string for Node.js and Blob in browser\n */\n async ingestFromFile(file: FileDescriptor | string | Blob, ingestionProperties?: IngestionPropertiesInput): Promise<KustoResponseDataSet> {\n this.ensureOpen();\n\n const descriptor: FileDescriptor = file instanceof FileDescriptor ? file : new FileDescriptor(file);\n return this.ingestFromStream(await fileToStream(descriptor), ingestionProperties);\n }\n}\n\nexport default KustoStreamingIngestClient;\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"streamingIngestClientBase.js","sourceRoot":"","sources":["../../src/streamingIngestClientBase.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAIlC,+CAA+C;AAC/C,+DAA4D;AAC5D,uDAAuF;AAEvF,MAAsB,8BAA+B,SAAQ,yCAAmB;IAE5E,YAAY,IAA2C,EAAE,YAAuC;QAC5F,KAAK,CAAC,YAAY,CAAC,CAAC;QACpB,IAAI,CAAC,WAAW,GAAG,IAAI,yBAAW,CAAC,IAAI,CAAC,CAAC;QACzC,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,WAAW,CAAC,eAAe,CAAC;IAC5D,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,IAA6B,EAAE,mBAA8C,EAAE,eAAwB;;QACxH,MAAM,KAAK,GAAG,IAAI,CAAC,eAAe,CAAC,mBAAmB,CAAC,CAAC;QACxD,MAAM,UAAU,GAAG,IAAI,YAAY,4BAAc,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,4BAAc,CAAC,IAAI,CAAC,CAAC;QACpF,uEAAuE;QACvE,MAAM,UAAU,CAAC,QAAQ,EAAE,CAAC;QAE5B,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,sBAAsB,CAChD,KAAK,CAAC,QAAkB,EACxB,KAAK,CAAC,KAAe,EACrB,SAAS,EACT,KAAK,CAAC,MAAM,EACZ,MAAA,KAAK,CAAC,yBAAyB,mCAAI,IAAI,EACvC,UAAU,CAAC,IAAI,EACf,eAAe,CAClB,CAAC;IACN,CAAC;IAED,KAAK;QACD,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;YACjB,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;SAC5B;QACD,KAAK,CAAC,KAAK,EAAE,CAAC;IAClB,CAAC;CACJ;AA/BD,wEA+BC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { IngestionPropertiesInput } from \"./ingestionProperties\";\n\nimport { BlobDescriptor } from \"./descriptors\";\nimport { AbstractKustoClient } from \"./abstractKustoClient\";\nimport { Client as KustoClient, KustoConnectionStringBuilder } from \"azure-kusto-data\";\n\nexport abstract class KustoStreamingIngestClientBase extends AbstractKustoClient {\n protected kustoClient: KustoClient;\n constructor(kcsb: string | KustoConnectionStringBuilder, defaultProps?: IngestionPropertiesInput) {\n super(defaultProps);\n this.kustoClient = new KustoClient(kcsb);\n this.defaultDatabase = this.kustoClient.defaultDatabase;\n }\n\n async ingestFromBlob(blob: string | BlobDescriptor, ingestionProperties?: IngestionPropertiesInput, clientRequestId?: string): Promise<any> {\n const props = this._getMergedProps(ingestionProperties);\n const descriptor = blob instanceof BlobDescriptor ? blob : new BlobDescriptor(blob);\n // No need to check blob size if it was given to us that it's not empty\n await descriptor.fillSize();\n\n return await this.kustoClient.executeStreamingIngest(\n props.database as string,\n props.table as string,\n undefined,\n props.format,\n props.ingestionMappingReference ?? null,\n descriptor.path,\n clientRequestId\n );\n }\n\n close() {\n if (!this._isClosed) {\n this.kustoClient.close();\n }\n super.close();\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "azure-kusto-ingest",
3
- "version": "5.1.0",
3
+ "version": "5.2.0",
4
4
  "description": "Azure Data Explorer Ingestion SDK",
5
5
  "module": "dist-esm/src/index.js",
6
6
  "types": "./types/src/index.d.ts",
@@ -31,6 +31,7 @@
31
31
  "directory": "azure-kusto-ingest"
32
32
  },
33
33
  "files": [
34
+ "dist-esm/src/*.js.map",
34
35
  "dist-esm/src/*.js",
35
36
  "types/src/*.d.ts",
36
37
  "tsconfig.tsbuildinfo"
@@ -61,8 +62,9 @@
61
62
  "@types/tmp": "^0.2.3",
62
63
  "@types/uuid": "^8.3.4",
63
64
  "@types/uuid-validate": "0.0.1",
64
- "azure-kusto-data": "^5.1.0",
65
+ "azure-kusto-data": "^5.2.0",
65
66
  "browserify-zlib": "0.2.0",
67
+ "buffer": "^6.0.3",
66
68
  "stream-array": "^1.1.2",
67
69
  "stream-browserify": "3.0.0",
68
70
  "stream-to-array": "^2.3.0",
@@ -74,5 +76,5 @@
74
76
  "@types/sinon": "^10.0.13",
75
77
  "assert": "^2.0.0"
76
78
  },
77
- "gitHead": "120a8d91fde4b0e520225e09895a28b085b85a7e"
79
+ "gitHead": "0d653678b2a70173739b6b140fc3a6e9e3b8bd78"
78
80
  }
@@ -3,15 +3,12 @@ import streamingIngestClient from "./streamingIngestClient";
3
3
  import managedStreamingIngestClient from "./managedStreamingIngestClient";
4
4
  import KustoIngestStatusQueues from "./status";
5
5
  import { DataFormat, IngestionMappingKind, ReportLevel, ReportMethod, ValidationImplications, ValidationOptions, ValidationPolicy } from "./ingestionProperties";
6
+ import { ApacheAvroColumnMapping, AvroColumnMapping, ColumnMapping, ConstantTransformation, CsvColumnMapping, FieldTransformation, JsonColumnMapping, OrcColumnMapping, ParquetColumnMapping, SStreamColumnMapping, W3CLogFileMapping } from "./columnMappings";
6
7
  import { BlobDescriptor, CompressionType, StreamDescriptor } from "./descriptors";
7
8
  import { FileDescriptor } from "./fileDescriptor";
8
- import { ApacheAvroColumnMapping, AvroColumnMapping, ColumnMapping, ConstantTransformation, CsvColumnMapping, FieldTransformation, JsonColumnMapping, OrcColumnMapping, ParquetColumnMapping, SStreamColumnMapping, W3CLogFileMapping } from "./columnMappings";
9
9
  export { Transformation as ColumnMappingTransformation } from "./columnMappings";
10
- export { KustoIngestClient as IngestClient };
11
- export { streamingIngestClient as StreamingIngestClient };
12
- export { managedStreamingIngestClient as ManagedStreamingIngestClient };
13
- export { KustoIngestStatusQueues as IngestStatusQueues };
14
10
  export { IngestionProperties } from "./ingestionProperties";
11
+ export { KustoIngestClient as IngestClient, KustoIngestStatusQueues as IngestStatusQueues, managedStreamingIngestClient as ManagedStreamingIngestClient, streamingIngestClient as StreamingIngestClient, };
15
12
  /**
16
13
  * @deprecated - import directly instead. Export const is not exporting type.
17
14
  */
@@ -20,7 +17,7 @@ export declare const IngestionDescriptors: {
20
17
  FileDescriptor: typeof FileDescriptor;
21
18
  StreamDescriptor: typeof StreamDescriptor;
22
19
  };
23
- export { JsonColumnMapping, CsvColumnMapping, AvroColumnMapping, ParquetColumnMapping, OrcColumnMapping, W3CLogFileMapping, ValidationPolicy, ReportLevel, ReportMethod, ValidationImplications, ValidationOptions, DataFormat, IngestionMappingKind, CompressionType, ApacheAvroColumnMapping, SStreamColumnMapping, ConstantTransformation, FieldTransformation, ColumnMapping, BlobDescriptor, StreamDescriptor, };
20
+ export { ApacheAvroColumnMapping, AvroColumnMapping, BlobDescriptor, ColumnMapping, CompressionType, ConstantTransformation, CsvColumnMapping, DataFormat, FieldTransformation, FileDescriptor, IngestionMappingKind, JsonColumnMapping, OrcColumnMapping, ParquetColumnMapping, ReportLevel, ReportMethod, SStreamColumnMapping, StreamDescriptor, ValidationImplications, ValidationOptions, ValidationPolicy, W3CLogFileMapping, };
24
21
  /**
25
22
  * @deprecated - import directly instead
26
23
  */
@@ -1,12 +1,11 @@
1
1
  /// <reference types="node" />
2
2
  import { IngestionPropertiesInput } from "./ingestionProperties";
3
- import { AbstractDescriptor, BlobDescriptor, StreamDescriptor } from "./descriptors";
4
- import { FileDescriptor } from "./fileDescriptor";
5
- import { AbstractKustoClient } from "./abstractKustoClient";
6
- import { KustoConnectionStringBuilder } from "azure-kusto-data";
7
- import { KustoResponseDataSet } from "azure-kusto-data/src/response";
8
3
  import { QueueSendMessageResponse } from "@azure/storage-queue";
4
+ import { KustoConnectionStringBuilder, KustoResponseDataSet } from "azure-kusto-data";
9
5
  import { Readable } from "stream";
6
+ import { AbstractKustoClient } from "./abstractKustoClient";
7
+ import { AbstractDescriptor, BlobDescriptor, StreamDescriptor } from "./descriptors";
8
+ import { FileDescriptor } from "./fileDescriptor";
10
9
  declare class KustoManagedStreamingIngestClient extends AbstractKustoClient {
11
10
  private streamingIngestClient;
12
11
  private queuedIngestClient;
@@ -4,4 +4,5 @@ import { FileDescriptor } from "./fileDescriptor.browser";
4
4
  export declare const fileToStream: (file: FileDescriptor) => Promise<StreamDescriptor>;
5
5
  export declare const tryFileToBuffer: (file: FileDescriptor) => Promise<StreamDescriptor>;
6
6
  export declare const tryStreamToArray: (stream: any) => Promise<Buffer>;
7
+ export declare const readableToStream: (stream: ArrayBuffer) => ArrayBuffer;
7
8
  //# sourceMappingURL=streamUtils.browser.d.ts.map
@@ -1,8 +1,9 @@
1
1
  /// <reference types="node" />
2
+ import { Readable } from "stream";
2
3
  import { StreamDescriptor } from "./descriptors";
3
4
  import { FileDescriptor } from "./fileDescriptor";
4
- import { Readable } from "stream";
5
5
  export declare const fileToStream: (fileDescriptor: FileDescriptor) => Promise<StreamDescriptor>;
6
6
  export declare const tryFileToBuffer: (fileDescriptor: FileDescriptor) => Promise<StreamDescriptor>;
7
7
  export declare const tryStreamToArray: (stream: Readable, maxBufferSize: number) => Promise<Buffer | Readable>;
8
+ export declare const readableToStream: (stream: Readable | ArrayBuffer) => Readable;
8
9
  //# sourceMappingURL=streamUtils.d.ts.map
@@ -1,8 +1,7 @@
1
1
  import { IngestionPropertiesInput } from "./ingestionProperties";
2
+ import { KustoConnectionStringBuilder, KustoResponseDataSet } from "azure-kusto-data";
2
3
  import { StreamDescriptor } from "./descriptors";
3
4
  import { FileDescriptor } from "./fileDescriptor.browser";
4
- import { KustoConnectionStringBuilder } from "azure-kusto-data";
5
- import { KustoResponseDataSet } from "azure-kusto-data/src/response";
6
5
  import { KustoStreamingIngestClientBase } from "./streamingIngestClientBase";
7
6
  declare class KustoStreamingIngestClient extends KustoStreamingIngestClientBase {
8
7
  constructor(kcsb: string | KustoConnectionStringBuilder, defaultProps?: IngestionPropertiesInput);
@@ -1,10 +1,9 @@
1
1
  /// <reference types="node" />
2
2
  import { IngestionPropertiesInput } from "./ingestionProperties";
3
+ import { KustoConnectionStringBuilder, KustoResponseDataSet } from "azure-kusto-data";
4
+ import { Readable } from "stream";
3
5
  import { StreamDescriptor } from "./descriptors";
4
6
  import { FileDescriptor } from "./fileDescriptor";
5
- import { KustoConnectionStringBuilder } from "azure-kusto-data";
6
- import { KustoResponseDataSet } from "azure-kusto-data/src/response";
7
- import { Readable } from "stream";
8
7
  import { KustoStreamingIngestClientBase } from "./streamingIngestClientBase";
9
8
  declare class KustoStreamingIngestClient extends KustoStreamingIngestClientBase {
10
9
  constructor(kcsb: string | KustoConnectionStringBuilder, defaultProps?: IngestionPropertiesInput);