azure-kusto-ingest 5.0.4 → 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 (48) 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 +28 -8
  5. package/dist-esm/src/descriptors.js.map +1 -0
  6. package/dist-esm/src/errors.js.map +1 -0
  7. package/dist-esm/src/fileDescriptor.browser.js +2 -3
  8. package/dist-esm/src/fileDescriptor.browser.js.map +1 -0
  9. package/dist-esm/src/fileDescriptor.js +2 -3
  10. package/dist-esm/src/fileDescriptor.js.map +1 -0
  11. package/dist-esm/src/index.js +14 -8
  12. package/dist-esm/src/index.js.map +1 -0
  13. package/dist-esm/src/ingestClient.browser.js.map +1 -0
  14. package/dist-esm/src/ingestClient.js +6 -1
  15. package/dist-esm/src/ingestClient.js.map +1 -0
  16. package/dist-esm/src/ingestClientBase.js.map +1 -0
  17. package/dist-esm/src/ingestionBlobInfo.js.map +1 -0
  18. package/dist-esm/src/ingestionProperties.js.map +1 -0
  19. package/dist-esm/src/managedStreamingIngestClient.js +47 -23
  20. package/dist-esm/src/managedStreamingIngestClient.js.map +1 -0
  21. package/dist-esm/src/resourceManager.js +33 -14
  22. package/dist-esm/src/resourceManager.js.map +1 -0
  23. package/dist-esm/src/retry.js.map +1 -0
  24. package/dist-esm/src/status.js.map +1 -0
  25. package/dist-esm/src/statusQ.js.map +1 -0
  26. package/dist-esm/src/streamUtils.browser.js +6 -1
  27. package/dist-esm/src/streamUtils.browser.js.map +1 -0
  28. package/dist-esm/src/streamUtils.js +6 -2
  29. package/dist-esm/src/streamUtils.js.map +1 -0
  30. package/dist-esm/src/streamingIngestClient.browser.js +3 -12
  31. package/dist-esm/src/streamingIngestClient.browser.js.map +1 -0
  32. package/dist-esm/src/streamingIngestClient.js +4 -13
  33. package/dist-esm/src/streamingIngestClient.js.map +1 -0
  34. package/dist-esm/src/streamingIngestClientBase.js +31 -0
  35. package/dist-esm/src/streamingIngestClientBase.js.map +1 -0
  36. package/package.json +5 -3
  37. package/types/src/abstractKustoClient.d.ts +2 -1
  38. package/types/src/descriptors.d.ts +9 -7
  39. package/types/src/fileDescriptor.browser.d.ts +2 -3
  40. package/types/src/fileDescriptor.d.ts +2 -4
  41. package/types/src/index.d.ts +6 -6
  42. package/types/src/managedStreamingIngestClient.d.ts +7 -6
  43. package/types/src/resourceManager.d.ts +2 -0
  44. package/types/src/streamUtils.browser.d.ts +1 -0
  45. package/types/src/streamUtils.d.ts +2 -1
  46. package/types/src/streamingIngestClient.browser.d.ts +3 -6
  47. package/types/src/streamingIngestClient.d.ts +4 -7
  48. package/types/src/streamingIngestClientBase.d.ts +11 -0
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,gHAAg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ACnG,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"]}
@@ -5,9 +5,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  return (mod && mod.__esModule) ? mod : { "default": mod };
6
6
  };
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.generateBlobName = exports.BlobDescriptor = exports.StreamDescriptor = exports.getSourceId = exports.CompressionType = void 0;
8
+ exports.generateBlobName = exports.BlobDescriptor = exports.StreamDescriptor = exports.AbstractDescriptor = exports.getSourceId = exports.CompressionType = void 0;
9
9
  const uuid_1 = require("uuid");
10
10
  const uuid_validate_1 = __importDefault(require("uuid-validate"));
11
+ const storage_blob_1 = require("@azure/storage-blob");
11
12
  var CompressionType;
12
13
  (function (CompressionType) {
13
14
  CompressionType["ZIP"] = ".zip";
@@ -24,15 +25,22 @@ const getSourceId = (sourceId) => {
24
25
  return (0, uuid_1.v4)();
25
26
  };
26
27
  exports.getSourceId = getSourceId;
27
- class StreamDescriptor {
28
+ class AbstractDescriptor {
29
+ constructor(sourceId = null, size = null) {
30
+ this.sourceId = sourceId;
31
+ this.size = size;
32
+ this.sourceId = (0, exports.getSourceId)(sourceId);
33
+ }
34
+ }
35
+ exports.AbstractDescriptor = AbstractDescriptor;
36
+ class StreamDescriptor extends AbstractDescriptor {
28
37
  /**
29
38
  * Use Readable for Node.js and ArrayBuffer in browser
30
39
  */
31
- constructor(stream, sourceId = null, compressionType = CompressionType.None) {
40
+ constructor(stream, sourceId = null, compressionType = CompressionType.None, size = null) {
41
+ super(sourceId, size);
32
42
  this.stream = stream;
33
- this.size = null;
34
43
  this.compressionType = compressionType;
35
- this.sourceId = (0, exports.getSourceId)(sourceId);
36
44
  }
37
45
  merge(other) {
38
46
  this.size = other.size;
@@ -46,11 +54,23 @@ class StreamDescriptor {
46
54
  }
47
55
  }
48
56
  exports.StreamDescriptor = StreamDescriptor;
49
- class BlobDescriptor {
57
+ class BlobDescriptor extends AbstractDescriptor {
50
58
  constructor(path, size = null, sourceId = null) {
59
+ super(sourceId, size);
51
60
  this.path = path;
52
- this.size = size;
53
- this.sourceId = (0, exports.getSourceId)(sourceId);
61
+ }
62
+ async fillSize() {
63
+ if (!this.size) {
64
+ const blobClient = new storage_blob_1.BlobClient(this.path);
65
+ const blobProps = await blobClient.getProperties();
66
+ const length = blobProps.contentLength;
67
+ if (length !== undefined) {
68
+ if (length === 0) {
69
+ throw new Error("Empty blob.");
70
+ }
71
+ this.size = length;
72
+ }
73
+ }
54
74
  }
55
75
  }
56
76
  exports.BlobDescriptor = BlobDescriptor;
@@ -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,QAAA,WAAW,eAQtB;AAEF,MAAsB,kBAAkB;IACpC,YAAmB,WAA0B,IAAI,EAAS,OAAsB,IAAI;QAAjE,aAAQ,GAAR,QAAQ,CAAsB;QAAS,SAAI,GAAJ,IAAI,CAAsB;QAChF,IAAI,CAAC,QAAQ,GAAG,IAAA,mBAAW,EAAC,QAAQ,CAAC,CAAC;IAC1C,CAAC;CACJ;AAJD,gDAIC;AAED,MAAa,gBAAiB,SAAQ,kBAAkB;IACpD;;OAEG;IACH,YACa,MAA8B,EACvC,WAA0B,IAAI,EACvB,kBAAmC,eAAe,CAAC,IAAI,EAC9D,OAAsB,IAAI;QAE1B,KAAK,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QALb,WAAM,GAAN,MAAM,CAAwB;QAEhC,oBAAe,GA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,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"]}
@@ -8,13 +8,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
8
8
  exports.FileDescriptor = void 0;
9
9
  const pako_1 = __importDefault(require("pako"));
10
10
  const descriptors_1 = require("./descriptors");
11
- class FileDescriptor {
11
+ class FileDescriptor extends descriptors_1.AbstractDescriptor {
12
12
  constructor(file, sourceId = null, size = null, compressionType = descriptors_1.CompressionType.None, extension, name) {
13
+ super(sourceId);
13
14
  this.file = file;
14
- this.sourceId = sourceId;
15
15
  this.extension = extension;
16
16
  this.name = name;
17
- this.sourceId = (0, descriptors_1.getSourceId)(sourceId);
18
17
  this.compressionType = compressionType;
19
18
  this.size = size || file.size;
20
19
  this.zipped = compressionType !== descriptors_1.CompressionType.None || this.extension === ".gz" || this.extension === ".zip";
@@ -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"]}
@@ -15,7 +15,7 @@ const descriptors_1 = require("./descriptors");
15
15
  /**
16
16
  * Describes a file to be ingested. Use string to describe a local path in Node.JS and Blob object in browsers
17
17
  */
18
- class FileDescriptor {
18
+ class FileDescriptor extends descriptors_1.AbstractDescriptor {
19
19
  constructor(
20
20
  /**
21
21
  * Use string in Node.JS and Blob in browser
@@ -23,14 +23,13 @@ class FileDescriptor {
23
23
  file, sourceId = null, size = null, compressionType = descriptors_1.CompressionType.None, extension, // Extracted from file name by default
24
24
  name // Extracted from file name by default
25
25
  ) {
26
+ super(sourceId, size);
26
27
  this.file = file;
27
28
  this.extension = extension;
28
29
  this.name = name;
29
- this.sourceId = (0, descriptors_1.getSourceId)(sourceId);
30
30
  this.compressionType = compressionType;
31
31
  this.name = name ? name : path_1.default.basename(this.file);
32
32
  this.extension = extension ? extension : path_1.default.extname(this.file).toLowerCase();
33
- this.size = size;
34
33
  this.zipped = compressionType !== descriptors_1.CompressionType.None || this.extension === ".gz" || this.extension === ".zip";
35
34
  }
36
35
  async _gzip() {
@@ -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,C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G,EAAE;gBACtB,OAAO,CAAC,IAAI,CAAC,CAAC;YAClB,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,KAAK,CAAC,OAAO;QACT,IAAI,IAAI,CAAC,MAAM,EAAE;YACb,MAAM,4BAA4B,GAAG,EAAE,CAAC;YACxC,MAAM,IAAI,CAAC,cAAc,CAAC,4BAA4B,CAAC,CAAC;YACxD,OAAO,IAAI,CAAC,IAAc,CAAC;SAC9B;QAED,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC;QAChC,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;QAC5B,OAAO,IAAI,CAAC;IAChB,CAAC;IAEO,KAAK,CAAC,cAAc,CAAC,WAAmB,CAAC;QAC7C,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,IAAI,IAAI,CAAC,IAAI,IAAI,CAAC,EAAE;YACrC,MAAM,SAAS,GAAG,IAAA,gBAAS,EAAC,YAAE,CAAC,IAAI,CAAC,CAAC;YACrC,IAAI,CAAC,IAAI,GAAG,CAAC,MAAM,SAAS,CAAC,IAAI,CAAC,IAAc,CAAC,CAAC,CAAC,IAAI,GAAG,QAAQ,CAAC;SACtE;IACL,CAAC;IAED,KAAK,CAAC,OAAO;QACT,IAAI,IAAI,CAAC,UAAU,EAAE;YACjB,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC;SAC3B;IACL,CAAC;IAED,oBAAoB;QAChB,OAAO,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;IACrE,CAAC;CACJ;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,11 +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
- exports.IngestionPropertiesValidationError = exports.IngestionPropertiesEnums = 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
+ exports.IngestClient = ingestClient_1.default;
10
11
  const streamingIngestClient_1 = __importDefault(require("./streamingIngestClient"));
12
+ exports.StreamingIngestClient = streamingIngestClient_1.default;
11
13
  const managedStreamingIngestClient_1 = __importDefault(require("./managedStreamingIngestClient"));
14
+ exports.ManagedStreamingIngestClient = managedStreamingIngestClient_1.default;
12
15
  const status_1 = __importDefault(require("./status"));
16
+ exports.IngestStatusQueues = status_1.default;
13
17
  const ingestionProperties_1 = require("./ingestionProperties");
14
18
  Object.defineProperty(exports, "DataFormat", { enumerable: true, get: function () { return ingestionProperties_1.DataFormat; } });
15
19
  Object.defineProperty(exports, "IngestionMappingKind", { enumerable: true, get: function () { return ingestionProperties_1.IngestionMappingKind; } });
@@ -18,9 +22,6 @@ Object.defineProperty(exports, "ReportMethod", { enumerable: true, get: function
18
22
  Object.defineProperty(exports, "ValidationImplications", { enumerable: true, get: function () { return ingestionProperties_1.ValidationImplications; } });
19
23
  Object.defineProperty(exports, "ValidationOptions", { enumerable: true, get: function () { return ingestionProperties_1.ValidationOptions; } });
20
24
  Object.defineProperty(exports, "ValidationPolicy", { enumerable: true, get: function () { return ingestionProperties_1.ValidationPolicy; } });
21
- const descriptors_1 = require("./descriptors");
22
- Object.defineProperty(exports, "CompressionType", { enumerable: true, get: function () { return descriptors_1.CompressionType; } });
23
- const fileDescriptor_1 = require("./fileDescriptor");
24
25
  const columnMappings_1 = require("./columnMappings");
25
26
  Object.defineProperty(exports, "ApacheAvroColumnMapping", { enumerable: true, get: function () { return columnMappings_1.ApacheAvroColumnMapping; } });
26
27
  Object.defineProperty(exports, "AvroColumnMapping", { enumerable: true, get: function () { return columnMappings_1.AvroColumnMapping; } });
@@ -33,12 +34,17 @@ Object.defineProperty(exports, "OrcColumnMapping", { enumerable: true, get: func
33
34
  Object.defineProperty(exports, "ParquetColumnMapping", { enumerable: true, get: function () { return columnMappings_1.ParquetColumnMapping; } });
34
35
  Object.defineProperty(exports, "SStreamColumnMapping", { enumerable: true, get: function () { return columnMappings_1.SStreamColumnMapping; } });
35
36
  Object.defineProperty(exports, "W3CLogFileMapping", { enumerable: true, get: function () { return columnMappings_1.W3CLogFileMapping; } });
36
- exports.IngestClient = ingestClient_1.default;
37
- exports.StreamingIngestClient = streamingIngestClient_1.default;
38
- exports.ManagedStreamingIngestClient = managedStreamingIngestClient_1.default;
39
- exports.IngestStatusQueues = status_1.default;
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; } });
40
43
  var ingestionProperties_2 = require("./ingestionProperties");
41
44
  Object.defineProperty(exports, "IngestionProperties", { enumerable: true, get: function () { return ingestionProperties_2.IngestionProperties; } });
45
+ /**
46
+ * @deprecated - import directly instead. Export const is not exporting type.
47
+ */
42
48
  exports.IngestionDescriptors = {
43
49
  BlobDescriptor: descriptors_1.BlobDescriptor,
44
50
  FileDescriptor: fileDescriptor_1.FileDescriptor,
@@ -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,uCAAiB,OA0DA;AACjB,iGA1DA,sCAAgB,OA0DA;AAvDpB,qDAY0B;AAuBtB,wGAlCA,wCAAuB,OAkCA;AACvB,kGAlCA,kCAAiB,OAkCA;AAEjB,8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AC;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"]}
@@ -36,7 +36,12 @@ class KustoIngestClient extends ingestClientBase_1.KustoIngestClientBase {
36
36
  const descriptor = stream instanceof descriptors_1.StreamDescriptor ? stream : new descriptors_1.StreamDescriptor(stream);
37
37
  const blobName = (0, descriptors_1.generateBlobName)(descriptor, props);
38
38
  const blockBlobClient = await this.resourceManager.getBlockBlobClient(blobName);
39
- await blockBlobClient.uploadStream(descriptor.stream);
39
+ if (descriptor.stream instanceof Buffer) {
40
+ await blockBlobClient.uploadData(descriptor.stream);
41
+ }
42
+ else {
43
+ await blockBlobClient.uploadStream(descriptor.stream);
44
+ }
40
45
  return this.ingestFromBlob(new descriptors_1.BlobDescriptor(blockBlobClient.url), props); // descriptor.size?
41
46
  }
42
47
  }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ingestClient.js","sourceRoot":"","sources":["../../src/ingestClient.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAIlC,+CAAmF;AACnF,qDAAkD;AAKlD,yDAA2D;AAG3D,MAAa,iBAAkB,SAAQ,wCAAqB;IACxD,YAAY,IAA2C,EAAE,YAAuC;QAC5F,KAAK,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;IAC9B,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,cAAc,CAAC,IAAoC,EAAE,mBAA8C;QACrG,IAAI,CAAC,UAAU,EAAE,CAAC;QAClB,MAAM,KAAK,GAAG,IAAI,CAAC,eAAe,CAAC,mBAAmB,CAAC,CAAC;QAExD,MAAM,UAAU,GAAG,IAAI,YAAY,+BAAc,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,+BAAc,CAAC,IAAI,CAAC,CAAC;QAEpF,IAAI;YACA,MAAM,QAAQ,GAAG,IAAA,8BAAgB,EAAC,UAAU,EAAE,KAAK,CAAC,CAAC;YACrD,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,IAAI,CAAC,eAAe,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;YACrI,MAAM,eAAe,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;YAC/C,OAAO,IAAI,CAAC,cAAc,CAAC,IAAI,4BAAc,CAAC,eAAe,CAAC,GAAG,EAAE,UAAU,CAAC,IAAI,EAAE,UAAU,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,CAAC;SACpH;gBAAS;YACN,MAAM,UAAU,CAAC,OAAO,EAAE,CAAC;SAC9B;IACL,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,gBAAgB,CAClB,MAAiD,EACjD,mBAA8C;QAE9C,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;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;A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SAAS,CAAC,iBAAiB,CAAC,CAAC;QAChE,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAEtE,OAAO,WAAW,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IAC5C,CAAC;IAED,KAAK;QACD,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;YACjB,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC;SAChC;QACD,KAAK,CAAC,KAAK,EAAE,CAAC;IAClB,CAAC;CACJ;AAxCD,sDAwCC;AAED,kBAAe,qBAAqB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { Client as KustoClient, KustoConnectionStringBuilder } from \"azure-kusto-data\";\n\nimport { BlobDescriptor } from \"./descriptors\";\n\nimport ResourceManager from \"./resourceManager\";\n\nimport IngestionBlobInfo from \"./ingestionBlobInfo\";\n\nimport { QueueClient, QueueSendMessageResponse } from \"@azure/storage-queue\";\n\nimport { IngestionPropertiesInput } from \"./ingestionProperties\";\nimport { AbstractKustoClient } from \"./abstractKustoClient\";\n\nexport abstract class KustoIngestClientBase extends AbstractKustoClient {\n resourceManager: ResourceManager;\n\n constructor(kcsb: string | KustoConnectionStringBuilder, defaultProps?: IngestionPropertiesInput, isBrowser?: boolean) {\n super(defaultProps);\n const kustoClient = new KustoClient(kcsb);\n this.resourceManager = new ResourceManager(kustoClient, isBrowser);\n this.defaultDatabase = kustoClient.defaultDatabase;\n }\n\n async ingestFromBlob(blob: string | BlobDescriptor, ingestionProperties?: IngestionPropertiesInput): Promise<QueueSendMessageResponse> {\n this.ensureOpen();\n\n const props = this._getMergedProps(ingestionProperties);\n\n const descriptor = blob instanceof BlobDescriptor ? blob : new BlobDescriptor(blob);\n const queues = await this.resourceManager.getIngestionQueues();\n if (queues == null) {\n throw new Error(\"Failed to get queues\");\n }\n\n const authorizationContext = await this.resourceManager.getAuthorizationContext();\n\n const queueDetails = queues[Math.floor(Math.random() * queues.length)];\n\n const queueClient = new QueueClient(queueDetails.uri);\n\n const ingestionBlobInfo = new IngestionBlobInfo(descriptor, props, authorizationContext);\n const ingestionBlobInfoJson = JSON.stringify(ingestionBlobInfo);\n const encoded = Buffer.from(ingestionBlobInfoJson).toString(\"base64\");\n\n return queueClient.sendMessage(encoded);\n }\n\n close() {\n if (!this._isClosed) {\n this.resourceManager.close();\n }\n super.close();\n }\n}\n\nexport default KustoIngestClientBase;\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ingestionBlobInfo.js","sourceRoot":"","sources":["../../src/ingestionBlobInfo.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC,+BAAoC;AAIpC,MAAa,iBAAiB;IAc1B,YAAY,cAA8B,EAAE,mBAAwC,EAAE,cAA6B,IAAI;;QACnH,IAAI,CAAC,QAAQ,GAAG,cAAc,CAAC,IAAI,CAAC;QACpC,IAAI,CAAC,WAAW,GAAG,cAAc,CAAC,IAAI,CAAC;QACvC,IAAI,CAAC,YAAY,GAAG,MAAA,mBAAmB,CAAC,QAAQ,mCAAI,IAAI,CAAC;QACzD,IAAI,CAAC,SAAS,GAAG,MAAA,mBAAmB,CAAC,KAAK,mCAAI,IAAI,CAAC;QACnD,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC;QAChC,IAAI,CAAC,gBAAgB,GAAG,MAAA,mBAAmB,CAAC,gBAAgB,mCAAI,KAAK,CAAC;QACtE,IAAI,CAAC,eAAe,GAAG,KAAK,CAAC;QAC7B,IAAI,CAAC,WAAW,GAAG,MAAA,mBAAmB,CAAC,WAAW,mCAAI,IAAI,CAAC;QAC3D,IAAI,CAAC,YAAY,GAAG,MAAA,mBAAmB,CAAC,YAAY,mCAAI,IAAI,CAAC;QAC7D,IAAI,CAAC,yBAAyB,GAAG,IAAI,IAAI,EAAE,CAAC;QAC5C,IAAI,CAAC,EAAE,GAAG,cAAc,CAAC,QA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AG,mBAAmB,CAAC,yBAAyB,CAAC;SAClG;QAED,IAAI,mBAAmB,CAAC,oBAAoB,EAAE;YAC1C,oBAAoB,CAAC,oBAAoB,GAAG,mBAAmB,CAAC,oBAAoB,CAAC;SACxF;QAED,IAAI,mBAAmB,CAAC,gBAAgB,EAAE;YACtC,oBAAoB,CAAC,gBAAgB,GAAG,mBAAmB,CAAC,gBAAgB,CAAC;SAChF;QAED,IAAI,mBAAmB,CAAC,MAAM,EAAE;YAC5B,oBAAoB,CAAC,MAAM,GAAG,mBAAmB,CAAC,MAAM,CAAC;SAC5D;QACD,IAAI,mBAAmB,CAAC,iBAAiB,EAAE;YACvC,oBAAoB,CAAC,iBAAiB,GAAG,mBAAmB,CAAC,iBAAiB,CAAC;SAClF;QAED,IAAI,CAAC,oBAAoB,GAAG,oBAAoB,CAAC;IACrD,CAAC;CACJ;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;AAC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,IAAI,2CAAkC,CAAC,qBAAqB,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;iBACjG;aACJ;SACJ;IACL,CAAC;IAED,KAAK,CAAC,UAAoC;QACtC,MAAM,MAAM,GAAG,IAAI,mBAAmB,CAAC,IAAI,CAAC,CAAC;QAE7C,IAAI,CAAC,UAAU,EAAE;YACb,OAAO,MAAM,CAAC;SACjB;QAED,MAAM,MAAM,GAAG,CACX,GAA8B,EAC9B,IAAO,EACP,KAAQ,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"]}