azure-kusto-ingest 2.2.1 → 3.0.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 (54) hide show
  1. package/.eslintignore +5 -0
  2. package/.eslintrc.js +247 -0
  3. package/.mocharc.json +2 -2
  4. package/.prettierignore +8 -0
  5. package/.prettierrc.json +5 -0
  6. package/README.md +64 -62
  7. package/example.js +20 -30
  8. package/index.d.ts +24 -2
  9. package/index.js +46 -6
  10. package/index.js.map +1 -1
  11. package/package.json +70 -55
  12. package/source/abstractKustoClient.d.ts +2 -2
  13. package/source/abstractKustoClient.js +4 -2
  14. package/source/abstractKustoClient.js.map +1 -1
  15. package/source/columnMappings.d.ts +114 -0
  16. package/source/columnMappings.js +240 -0
  17. package/source/columnMappings.js.map +1 -0
  18. package/source/descriptors.d.ts +4 -3
  19. package/source/descriptors.js +17 -7
  20. package/source/descriptors.js.map +1 -1
  21. package/source/errors.d.ts +3 -0
  22. package/source/errors.js +13 -0
  23. package/source/errors.js.map +1 -0
  24. package/source/ingestClient.d.ts +2 -2
  25. package/source/ingestClient.js +1 -3
  26. package/source/ingestClient.js.map +1 -1
  27. package/source/ingestionBlobInfo.js +10 -7
  28. package/source/ingestionBlobInfo.js.map +1 -1
  29. package/source/ingestionProperties.d.ts +96 -40
  30. package/source/ingestionProperties.js +166 -84
  31. package/source/ingestionProperties.js.map +1 -1
  32. package/source/managedStreamingIngestClient.d.ts +36 -0
  33. package/source/managedStreamingIngestClient.js +106 -0
  34. package/source/managedStreamingIngestClient.js.map +1 -0
  35. package/source/resourceManager.d.ts +1 -1
  36. package/source/resourceManager.js +14 -16
  37. package/source/resourceManager.js.map +1 -1
  38. package/source/retry.d.ts +10 -0
  39. package/source/retry.js +44 -0
  40. package/source/retry.js.map +1 -0
  41. package/source/status.js +6 -17
  42. package/source/status.js.map +1 -1
  43. package/source/statusQ.js +7 -6
  44. package/source/statusQ.js.map +1 -1
  45. package/source/streamUtils.d.ts +6 -0
  46. package/source/streamUtils.js +61 -0
  47. package/source/streamUtils.js.map +1 -0
  48. package/source/streamingIngestClient.d.ts +2 -3
  49. package/source/streamingIngestClient.js +5 -14
  50. package/source/streamingIngestClient.js.map +1 -1
  51. package/tsconfig.json +16 -16
  52. package/tsconfig.tsbuildinfo +1 -7177
  53. package/index.ts +0 -48
  54. package/tslint.json +0 -18
@@ -1,24 +1,88 @@
1
+ import { ColumnMapping } from "./columnMappings";
2
+ /**
3
+ * Data formats supported for Kusto ingestion.
4
+ */
1
5
  export declare enum DataFormat {
6
+ /**
7
+ * Comma-separated value.
8
+ */
2
9
  CSV = "csv",
10
+ /**
11
+ * Tab-separated value.
12
+ */
3
13
  TSV = "tsv",
14
+ /**
15
+ * Semicolon-separated value (the unique Azure Storage log format).
16
+ */
4
17
  SCSV = "scsv",
18
+ /**
19
+ * Start-Of-Header (CTRL-A)-separated value.
20
+ */
5
21
  SOHSV = "sohsv",
22
+ /**
23
+ * Pipeline-separated value (used by Cosmos).
24
+ */
6
25
  PSV = "psv",
26
+ /**
27
+ * Each record is a line and has just one field.
28
+ */
7
29
  TXT = "txt",
30
+ /**
31
+ * Whole stream is a single record with a single field.
32
+ */
33
+ RAW = "raw",
34
+ /**
35
+ * Tab-separated value with '\' escaping character.
36
+ */
37
+ TSVE = "tsve",
38
+ /**
39
+ * Data is in a JSON format, each line is record with a single JSON value.
40
+ */
8
41
  JSON = "json",
42
+ /**
43
+ * Data stream holds a single JSON value -- newlines are regular whitespace.
44
+ */
9
45
  SINGLEJSON = "singlejson",
46
+ /**
47
+ * The data stream is a concatenation of JSON documents (property bags all).
48
+ */
49
+ MULTIJSON = "multijson",
50
+ /**
51
+ * Avro format.
52
+ */
10
53
  AVRO = "avro",
54
+ /**
55
+ * Parquet format.
56
+ */
11
57
  PARQUET = "parquet",
12
- TSVE = "tsve",
13
- ORC = "orc"
58
+ /**
59
+ * Microsoft Cosmos structured streams format
60
+ */
61
+ SSTREAM = "sstream",
62
+ /**
63
+ * The Optimized Row Columnar (ORC)
64
+ */
65
+ ORC = "orc",
66
+ /**
67
+ * Avro format for ingesting through avro2json.
68
+ */
69
+ APACHEAVRO = "apacheavro",
70
+ /**
71
+ * W3C Extended Log File format.
72
+ */
73
+ W3CLogFile = "w3clogfile"
14
74
  }
15
- export declare enum IngestionMappingType {
75
+ export declare enum IngestionMappingKind {
16
76
  CSV = "Csv",
17
- PARQUET = "Parquet",
18
- AVRO = "Avro",
19
77
  JSON = "Json",
20
- ORC = "orc"
78
+ AVRO = "Avro",
79
+ PARQUET = "Parquet",
80
+ SSTREAM = "SStream",
81
+ ORC = "orc",
82
+ APACHEAVRO = "ApacheAvro",
83
+ W3CLOGFILE = "W3CLogFile"
21
84
  }
85
+ export declare const dataFormatMappingKind: (dataFormat: DataFormat) => IngestionMappingKind;
22
86
  export declare enum ValidationOptions {
23
87
  DoNotValidate = 0,
24
88
  ValidateCsvInputConstantColumns = 1,
@@ -32,6 +96,7 @@ export declare class ValidationPolicy {
32
96
  readonly validationOptions: ValidationOptions;
33
97
  readonly validationImplications: ValidationImplications;
34
98
  constructor(validationOptions?: ValidationOptions, validationImplications?: ValidationImplications);
99
+ toJSON(): Record<string, number>;
35
100
  }
36
101
  export declare enum ReportLevel {
37
102
  FailuresOnly = 0,
@@ -41,43 +106,34 @@ export declare enum ReportLevel {
41
106
  export declare enum ReportMethod {
42
107
  Queue = 0
43
108
  }
44
- declare class ColumnMapping {
45
- }
46
- export declare class CsvColumnMapping extends ColumnMapping {
47
- readonly columnName: string;
48
- readonly cslDataType: string;
49
- readonly ordinal: string;
50
- constructor(columnName: string, cslDataType: string, ordinal: string);
51
- }
52
- export declare class JsonColumnMapping extends ColumnMapping {
53
- readonly columnName: string;
54
- readonly jsonPath: string;
55
- readonly cslDataType: string | null;
56
- constructor(columnName: string, jsonPath: string, cslDataType?: string | null);
57
- }
58
- declare class IngestionPropertiesFields {
59
- database?: string | null;
60
- table?: string | null;
61
- format?: string | null;
62
- ingestionMapping?: ColumnMapping[] | null;
63
- ingestionMappingReference?: string | null;
64
- ingestionMappingType?: string | null;
65
- additionalTags?: string | null;
66
- ingestIfNotExists?: string | null;
67
- ingestByTags?: string[] | null;
68
- dropByTags?: string[] | null;
69
- flushImmediately?: boolean | null;
70
- reportLevel?: ReportLevel | null;
71
- reportMethod?: ReportMethod | null;
72
- validationPolicy?: string | null;
109
+ export declare class IngestionProperties {
110
+ database?: string;
111
+ table?: string;
112
+ format: DataFormat;
113
+ /**
114
+ * @deprecated. Use ingestionMappingColumns instead.
115
+ */
116
+ ingestionMapping?: ColumnMapping[];
117
+ ingestionMappingColumns?: ColumnMapping[];
118
+ ingestionMappingReference?: string;
119
+ /**
120
+ * @deprecated. Use ingestionMappingKind instead.
121
+ */
122
+ ingestionMappingType?: IngestionMappingKind;
123
+ ingestionMappingKind?: IngestionMappingKind;
124
+ additionalTags?: string;
125
+ ingestIfNotExists?: string;
126
+ ingestByTags?: string[];
127
+ dropByTags?: string[];
128
+ flushImmediately: boolean;
129
+ reportLevel: ReportLevel;
130
+ reportMethod: ReportMethod;
131
+ validationPolicy?: ValidationPolicy;
73
132
  additionalProperties?: {
74
133
  [additional: string]: any;
75
134
  } | null;
76
- }
77
- export declare class IngestionProperties extends IngestionPropertiesFields {
78
- constructor({ database, table, format, ingestionMapping, ingestionMappingReference, ingestionMappingType, additionalTags, ingestIfNotExists, ingestByTags, dropByTags, flushImmediately, reportLevel, reportMethod, validationPolicy, additionalProperties }: IngestionPropertiesFields);
135
+ constructor(data: Partial<IngestionProperties>);
79
136
  validate(): void;
80
- [extraProps: string]: any;
81
- merge(extraProps: any): IngestionProperties;
137
+ merge(extraProps: IngestionProperties): IngestionProperties;
82
138
  }
83
139
  export default IngestionProperties;
@@ -2,30 +2,135 @@
2
2
  // Copyright (c) Microsoft Corporation.
3
3
  // Licensed under the MIT License.
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.IngestionProperties = exports.JsonColumnMapping = exports.CsvColumnMapping = exports.ReportMethod = exports.ReportLevel = exports.ValidationPolicy = exports.ValidationImplications = exports.ValidationOptions = exports.IngestionMappingType = exports.DataFormat = void 0;
5
+ exports.IngestionProperties = exports.ReportMethod = exports.ReportLevel = exports.ValidationPolicy = exports.ValidationImplications = exports.ValidationOptions = exports.dataFormatMappingKind = exports.IngestionMappingKind = exports.DataFormat = void 0;
6
+ /* eslint-disable max-classes-per-file -- the main class is IngestionProperties, ValidationPolicy is a tiny class */
7
+ const errors_1 = require("./errors");
8
+ /**
9
+ * Data formats supported for Kusto ingestion.
10
+ */
6
11
  var DataFormat;
7
12
  (function (DataFormat) {
13
+ /**
14
+ * Comma-separated value.
15
+ */
8
16
  DataFormat["CSV"] = "csv";
17
+ /**
18
+ * Tab-separated value.
19
+ */
9
20
  DataFormat["TSV"] = "tsv";
21
+ /**
22
+ * Semicolon-separated value (the unique Azure Storage log format).
23
+ */
10
24
  DataFormat["SCSV"] = "scsv";
25
+ /**
26
+ * Start-Of-Header (CTRL-A)-separated value.
27
+ */
11
28
  DataFormat["SOHSV"] = "sohsv";
29
+ /**
30
+ * Pipeline-separated value (used by Cosmos).
31
+ */
12
32
  DataFormat["PSV"] = "psv";
33
+ /**
34
+ * Each record is a line and has just one field.
35
+ */
13
36
  DataFormat["TXT"] = "txt";
37
+ /**
38
+ * Whole stream is a single record with a single field.
39
+ */
40
+ DataFormat["RAW"] = "raw";
41
+ /**
42
+ * Tab-separated value with '\' escaping character.
43
+ */
44
+ DataFormat["TSVE"] = "tsve";
45
+ /**
46
+ * Data is in a JSON format, each line is record with a single JSON value.
47
+ */
14
48
  DataFormat["JSON"] = "json";
49
+ /**
50
+ * Data stream holds a single JSON value -- newlines are regular whitespace.
51
+ */
15
52
  DataFormat["SINGLEJSON"] = "singlejson";
53
+ /**
54
+ * The data stream is a concatenation of JSON documents (property bags all).
55
+ */
56
+ DataFormat["MULTIJSON"] = "multijson";
57
+ /**
58
+ * Avro format.
59
+ */
16
60
  DataFormat["AVRO"] = "avro";
61
+ /**
62
+ * Parquet format.
63
+ */
17
64
  DataFormat["PARQUET"] = "parquet";
18
- DataFormat["TSVE"] = "tsve";
65
+ /**
66
+ * Microsoft Cosmos structured streams format
67
+ */
68
+ DataFormat["SSTREAM"] = "sstream";
69
+ /**
70
+ * The Optimized Row Columnar (ORC)
71
+ */
19
72
  DataFormat["ORC"] = "orc";
73
+ /**
74
+ * Avro format for ingesting through avro2json.
75
+ */
76
+ DataFormat["APACHEAVRO"] = "apacheavro";
77
+ /**
78
+ * W3C Extended Log File format.
79
+ */
80
+ DataFormat["W3CLogFile"] = "w3clogfile";
20
81
  })(DataFormat = exports.DataFormat || (exports.DataFormat = {}));
21
- var IngestionMappingType;
22
- (function (IngestionMappingType) {
23
- IngestionMappingType["CSV"] = "Csv";
24
- IngestionMappingType["PARQUET"] = "Parquet";
25
- IngestionMappingType["AVRO"] = "Avro";
26
- IngestionMappingType["JSON"] = "Json";
27
- IngestionMappingType["ORC"] = "orc";
28
- })(IngestionMappingType = exports.IngestionMappingType || (exports.IngestionMappingType = {}));
82
+ var IngestionMappingKind;
83
+ (function (IngestionMappingKind) {
84
+ IngestionMappingKind["CSV"] = "Csv";
85
+ IngestionMappingKind["JSON"] = "Json";
86
+ IngestionMappingKind["AVRO"] = "Avro";
87
+ IngestionMappingKind["PARQUET"] = "Parquet";
88
+ IngestionMappingKind["SSTREAM"] = "SStream";
89
+ IngestionMappingKind["ORC"] = "orc";
90
+ IngestionMappingKind["APACHEAVRO"] = "ApacheAvro";
91
+ IngestionMappingKind["W3CLOGFILE"] = "W3CLogFile";
92
+ })(IngestionMappingKind = exports.IngestionMappingKind || (exports.IngestionMappingKind = {}));
93
+ const dataFormatMappingKind = (dataFormat) => {
94
+ switch (dataFormat) {
95
+ case DataFormat.CSV:
96
+ return IngestionMappingKind.CSV;
97
+ case DataFormat.TSV:
98
+ return IngestionMappingKind.CSV;
99
+ case DataFormat.SCSV:
100
+ return IngestionMappingKind.CSV;
101
+ case DataFormat.SOHSV:
102
+ return IngestionMappingKind.CSV;
103
+ case DataFormat.PSV:
104
+ return IngestionMappingKind.CSV;
105
+ case DataFormat.TXT:
106
+ return IngestionMappingKind.CSV;
107
+ case DataFormat.RAW:
108
+ return IngestionMappingKind.CSV;
109
+ case DataFormat.TSVE:
110
+ return IngestionMappingKind.CSV;
111
+ case DataFormat.JSON:
112
+ return IngestionMappingKind.JSON;
113
+ case DataFormat.SINGLEJSON:
114
+ return IngestionMappingKind.JSON;
115
+ case DataFormat.MULTIJSON:
116
+ return IngestionMappingKind.JSON;
117
+ case DataFormat.AVRO:
118
+ return IngestionMappingKind.AVRO;
119
+ case DataFormat.PARQUET:
120
+ return IngestionMappingKind.PARQUET;
121
+ case DataFormat.SSTREAM:
122
+ return IngestionMappingKind.SSTREAM;
123
+ case DataFormat.ORC:
124
+ return IngestionMappingKind.ORC;
125
+ case DataFormat.APACHEAVRO:
126
+ return IngestionMappingKind.APACHEAVRO;
127
+ case DataFormat.W3CLogFile:
128
+ return IngestionMappingKind.W3CLOGFILE;
129
+ default:
130
+ throw new errors_1.IngestionPropertiesValidationError(`Unsupported data format: ${dataFormat}`);
131
+ }
132
+ };
133
+ exports.dataFormatMappingKind = dataFormatMappingKind;
29
134
  var ValidationOptions;
30
135
  (function (ValidationOptions) {
31
136
  ValidationOptions[ValidationOptions["DoNotValidate"] = 0] = "DoNotValidate";
@@ -42,6 +147,12 @@ class ValidationPolicy {
42
147
  this.validationOptions = validationOptions;
43
148
  this.validationImplications = validationImplications;
44
149
  }
150
+ toJSON() {
151
+ return {
152
+ ValidationOptions: this.validationOptions,
153
+ ValidationImplications: this.validationImplications,
154
+ };
155
+ }
45
156
  }
46
157
  exports.ValidationPolicy = ValidationPolicy;
47
158
  var ReportLevel;
@@ -54,89 +165,60 @@ var ReportMethod;
54
165
  (function (ReportMethod) {
55
166
  ReportMethod[ReportMethod["Queue"] = 0] = "Queue";
56
167
  })(ReportMethod = exports.ReportMethod || (exports.ReportMethod = {}));
57
- class ColumnMapping {
58
- }
59
- class CsvColumnMapping extends ColumnMapping {
60
- constructor(columnName, cslDataType, ordinal) {
61
- super();
62
- this.columnName = columnName;
63
- this.cslDataType = cslDataType;
64
- this.ordinal = ordinal;
65
- }
66
- }
67
- exports.CsvColumnMapping = CsvColumnMapping;
68
- class JsonColumnMapping extends ColumnMapping {
69
- constructor(columnName, jsonPath, cslDataType = null) {
70
- super();
71
- this.columnName = columnName;
72
- this.jsonPath = jsonPath;
73
- this.cslDataType = cslDataType;
74
- }
75
- }
76
- exports.JsonColumnMapping = JsonColumnMapping;
77
- class IngestionPropertiesFields {
78
- constructor() {
79
- this.database = null;
80
- this.table = null;
81
- this.format = null;
82
- this.ingestionMapping = null;
83
- this.ingestionMappingReference = null;
84
- this.ingestionMappingType = null;
85
- this.additionalTags = null;
86
- this.ingestIfNotExists = null;
87
- this.ingestByTags = null;
88
- this.dropByTags = null;
89
- this.flushImmediately = null;
90
- this.reportLevel = null;
91
- this.reportMethod = null;
92
- this.validationPolicy = null;
93
- this.additionalProperties = null;
94
- }
95
- }
96
- class IngestionProperties extends IngestionPropertiesFields {
97
- constructor({ database = null, table = null, format = null, ingestionMapping = null, ingestionMappingReference = null, ingestionMappingType = null, additionalTags = null, ingestIfNotExists = null, ingestByTags = null, dropByTags = null, flushImmediately = null, reportLevel = null, reportMethod = null, validationPolicy = null, additionalProperties = null }) {
98
- super();
99
- if (ingestionMapping && ingestionMappingReference)
100
- throw new Error("Both mapping and a mapping reference detected");
101
- this.database = database;
102
- this.table = table;
103
- this.format = format;
104
- this.ingestionMapping = ingestionMapping;
105
- this.ingestionMappingType = ingestionMappingType;
106
- this.ingestionMappingReference = ingestionMappingReference;
107
- this.additionalTags = additionalTags;
108
- this.ingestIfNotExists = ingestIfNotExists;
109
- this.ingestByTags = ingestByTags;
110
- this.dropByTags = dropByTags;
111
- this.flushImmediately = flushImmediately;
112
- this.reportLevel = reportLevel;
113
- this.reportMethod = reportMethod;
114
- this.validationPolicy = validationPolicy;
115
- this.additionalProperties = additionalProperties;
168
+ class IngestionProperties {
169
+ constructor(data) {
170
+ this.format = DataFormat.CSV;
171
+ this.flushImmediately = false;
172
+ this.reportLevel = ReportLevel.DoNotReport;
173
+ this.reportMethod = ReportMethod.Queue;
174
+ Object.assign(this, data);
116
175
  }
117
176
  validate() {
118
- if (!this.flushImmediately)
119
- this.flushImmediately = false;
120
- if (!this.reportLevel)
121
- this.reportLevel = ReportLevel.DoNotReport;
122
- if (!this.reportMethod)
123
- this.reportMethod = ReportMethod.Queue;
124
177
  if (!this.database)
125
- throw new Error("Must define a target database");
178
+ throw new errors_1.IngestionPropertiesValidationError("Must define a target database");
126
179
  if (!this.table)
127
- throw new Error("Must define a target table");
180
+ throw new errors_1.IngestionPropertiesValidationError("Must define a target table");
128
181
  if (!this.format)
129
- throw new Error("Must define a data format");
130
- if (this.ingestionMapping && this.ingestionMappingReference)
131
- throw new Error("Both mapping and a mapping reference detected");
132
- if (!this.ingestionMapping && !this.ingestionMappingReference && this.format === DataFormat.JSON)
133
- throw new Error("Json must have a mapping defined");
182
+ throw new errors_1.IngestionPropertiesValidationError("Must define a data format");
183
+ if (this.ingestionMappingType && !this.ingestionMappingKind) {
184
+ this.ingestionMappingKind = this.ingestionMappingType;
185
+ }
186
+ if (this.ingestionMapping && !this.ingestionMappingColumns) {
187
+ this.ingestionMappingColumns = this.ingestionMapping;
188
+ }
189
+ if (!this.ingestionMappingColumns && !this.ingestionMappingReference) {
190
+ if (this.ingestionMappingKind) {
191
+ throw new errors_1.IngestionPropertiesValidationError("Cannot define ingestionMappingKind without either ingestionMappingColumns or" + " ingestionMappingReference");
192
+ }
193
+ }
194
+ else {
195
+ const mappingKind = (0, exports.dataFormatMappingKind)(this.format);
196
+ if (this.ingestionMappingKind && this.ingestionMappingKind !== mappingKind) {
197
+ throw new errors_1.IngestionPropertiesValidationError(`Mapping kind '${this.ingestionMappingKind}' does not match format '${this.format}' (should be '${mappingKind}')`);
198
+ }
199
+ if (this.ingestionMappingColumns) {
200
+ if (this.ingestionMappingReference) {
201
+ throw new errors_1.IngestionPropertiesValidationError("Cannot define both ingestionMappingColumns and ingestionMappingReference");
202
+ }
203
+ if (this.ingestionMappingColumns.length === 0) {
204
+ throw new errors_1.IngestionPropertiesValidationError("Must define at least one column mapping");
205
+ }
206
+ const wrongMappings = this.ingestionMappingColumns
207
+ .filter((m) => m.mappingKind !== mappingKind)
208
+ .map((m) => `Mapping kind mismatch for column '${m.columnName}' - expected data format kind - '${mappingKind}', but was '${m.mappingKind}'`);
209
+ if (wrongMappings.length > 0) {
210
+ throw new errors_1.IngestionPropertiesValidationError(`Invalid columns:\n${wrongMappings.join("\n")}`);
211
+ }
212
+ }
213
+ }
134
214
  }
135
215
  merge(extraProps) {
136
216
  const merged = new IngestionProperties(this);
137
217
  for (const key of Object.keys(extraProps)) {
138
- if (extraProps[key] != null) {
139
- merged[key] = extraProps[key];
218
+ if (extraProps[key]) {
219
+ ((k) => {
220
+ merged[k] = extraProps[k];
221
+ })(key);
140
222
  }
141
223
  }
142
224
  return merged;
@@ -1 +1 @@
1
- {"version":3,"file":"ingestionProperties.js","sourceRoot":"","sources":["ingestionProperties.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC,IAAY,UAaX;AAbD,WAAY,UAAU;IAClB,yBAAW,CAAA;IACX,yBAAW,CAAA;IACX,2BAAa,CAAA;IACb,6BAAe,CAAA;IACf,yBAAW,CAAA;IACX,yBAAW,CAAA;IACX,2BAAa,CAAA;IACb,uCAAyB,CAAA;IACzB,2BAAa,CAAA;IACb,iCAAmB,CAAA;IACnB,2BAAa,CAAA;IACb,yBAAW,CAAA;AACf,CAAC,EAbW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAarB;AAED,IAAY,oBAMX;AAND,WAAY,oBAAoB;IAC5B,mCAAW,CAAA;IACX,2CAAmB,CAAA;IACnB,qCAAa,CAAA;IACb,qCAAa,CAAA;IACb,mCAAW,CAAA;AACf,CAAC,EANW,oBAAoB,GAAp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AC,+CAA+C,CAAC,CAAC;QACrE,IAAI,CAAC,IAAI,CAAC,gBAAgB,IAAI,CAAC,IAAI,CAAC,yBAAyB,IAAI,IAAI,CAAC,MAAM,KAAK,UAAU,CAAC,IAAI;YAC5F,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;IAC5D,CAAC;IAID,KAAK,CAAC,UAAe;QACjB,MAAM,MAAM,GAAG,IAAI,mBAAmB,CAAC,IAAI,CAAC,CAAC;QAE7C,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE;YACvC,IAAI,UAAU,CAAC,GAAG,CAAC,IAAI,IAAI,EAAE;gBACzB,MAAM,CAAC,GAAG,CAAC,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC;aACjC;SACJ;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ;AAlED,kDAkEC;AAED,kBAAe,mBAAmB,CAAC"}
1
+ {"version":3,"file":"ingestionProperties.js","sourceRoot":"","sources":["ingestionProperties.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC,oHAAoH;AAEpH,qCAA8D;AAG9D;;GAEG;AACH,IAAY,UAqEX;AArED,WAAY,UAAU;IAClB;;OAEG;IACH,yBAAW,CAAA;IACX;;OAEG;IACH,yBAAW,CAAA;IACX;;OAEG;IACH,2BAAa,CAAA;IACb;;OAEG;IACH,6BAAe,CAAA;IACf;;OAEG;IACH,yBAAW,CAAA;IACX;;OAEG;IACH,yBAAW,CAAA;IACX;;OAEG;IACH,yBAAW,CAAA;IACX;;OAEG;IACH,2BAAa,CAAA;IACb;;OAEG;IACH,2BAAa,CAAA;IACb;;OAEG;IACH,uCAAyB,CAAA;IACzB;;OAEG;IACH,qCAAuB,CAAA;IACvB;;OAEG;IACH,2BAAa,CAAA;IACb;;OAEG;IACH,iCAAmB,CAAA;IACnB;;OAEG;IACH,iCAAmB,CAAA;IACnB;;OAEG;IACH,yBAAW,CAAA;IAC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C,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;gBAC9B,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;aACX;SACJ;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ;AAzFD,kDAyFC;AAED,kBAAe,mBAAmB,CAAC"}
@@ -0,0 +1,36 @@
1
+ /// <reference types="node" />
2
+ import IngestionProperties from "./ingestionProperties";
3
+ import { FileDescriptor, StreamDescriptor } from "./descriptors";
4
+ import { AbstractKustoClient } from "./abstractKustoClient";
5
+ import { KustoConnectionStringBuilder } from "azure-kusto-data";
6
+ import { KustoResponseDataSet } from "azure-kusto-data/source/response";
7
+ import { QueueSendMessageResponse } from "@azure/storage-queue";
8
+ import { Readable } from "stream";
9
+ declare class KustoManagedStreamingIngestClient extends AbstractKustoClient {
10
+ private streamingIngestClient;
11
+ private queuedIngestClient;
12
+ private baseSleepTimeSecs;
13
+ private baseJitterSecs;
14
+ /**
15
+ * Creates a KustoManagedStreamingIngestClient from a DM connection string.
16
+ * This method infers the engine connection string.
17
+ * For advanced usage, use the constructor that takes a DM connection string and an engine connection string.
18
+ *
19
+ * @param dmConnectionString The DM connection string.
20
+ * @param defaultProps The default ingestion properties.
21
+ */
22
+ static fromDmConnectionString(dmConnectionString: KustoConnectionStringBuilder, defaultProps?: IngestionProperties | null): KustoManagedStreamingIngestClient;
23
+ /**
24
+ * Creates a KustoManagedStreamingIngestClient from a engine connection string.
25
+ * This method infers the engine connection string.
26
+ * For advanced usage, use the constructor that takes an engine connection string and an engine connection string.
27
+ *
28
+ * @param engineConnectionString The engine connection string.
29
+ * @param defaultProps The default ingestion properties.
30
+ */
31
+ static fromEngineConnectionString(engineConnectionString: KustoConnectionStringBuilder, defaultProps?: IngestionProperties | null): KustoManagedStreamingIngestClient;
32
+ constructor(engineKcsb: string | KustoConnectionStringBuilder, dmKcsb: string | KustoConnectionStringBuilder, defaultProps?: IngestionProperties | null);
33
+ ingestFromStream(stream: StreamDescriptor | Readable, ingestionProperties: IngestionProperties): Promise<any>;
34
+ ingestFromFile(file: FileDescriptor | string, ingestionProperties: IngestionProperties): Promise<KustoResponseDataSet | QueueSendMessageResponse>;
35
+ }
36
+ export default KustoManagedStreamingIngestClient;
@@ -0,0 +1,106 @@
1
+ "use strict";
2
+ // Copyright (c) Microsoft Corporation.
3
+ // Licensed under the MIT License.
4
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
5
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
6
+ return new (P || (P = Promise))(function (resolve, reject) {
7
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
8
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
9
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
10
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
11
+ });
12
+ };
13
+ var __importDefault = (this && this.__importDefault) || function (mod) {
14
+ return (mod && mod.__esModule) ? mod : { "default": mod };
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ const descriptors_1 = require("./descriptors");
18
+ const abstractKustoClient_1 = require("./abstractKustoClient");
19
+ const azure_kusto_data_1 = require("azure-kusto-data");
20
+ const streamUtils_1 = require("./streamUtils");
21
+ const streamingIngestClient_1 = __importDefault(require("./streamingIngestClient"));
22
+ const ingestClient_1 = __importDefault(require("./ingestClient"));
23
+ const stream_array_1 = __importDefault(require("stream-array"));
24
+ const retry_1 = require("./retry");
25
+ const maxStreamSize = 1024 * 1024 * 4;
26
+ const attemptCount = 3;
27
+ const ingestPrefix = "https://ingest-";
28
+ class KustoManagedStreamingIngestClient extends abstractKustoClient_1.AbstractKustoClient {
29
+ constructor(engineKcsb, dmKcsb, defaultProps = null) {
30
+ super(defaultProps);
31
+ this.baseSleepTimeSecs = 1;
32
+ this.baseJitterSecs = 1;
33
+ this.streamingIngestClient = new streamingIngestClient_1.default(engineKcsb, defaultProps);
34
+ this.queuedIngestClient = new ingestClient_1.default(dmKcsb, defaultProps);
35
+ }
36
+ /**
37
+ * Creates a KustoManagedStreamingIngestClient from a DM connection string.
38
+ * This method infers the engine connection string.
39
+ * For advanced usage, use the constructor that takes a DM connection string and an engine connection string.
40
+ *
41
+ * @param dmConnectionString The DM connection string.
42
+ * @param defaultProps The default ingestion properties.
43
+ */
44
+ static fromDmConnectionString(dmConnectionString, defaultProps = null) {
45
+ var _a;
46
+ if (dmConnectionString.dataSource == null || !dmConnectionString.dataSource.startsWith(ingestPrefix)) {
47
+ throw new Error(`DM connection string must include the prefix '${ingestPrefix}'`);
48
+ }
49
+ const engineConnectionString = azure_kusto_data_1.KustoConnectionStringBuilder.fromExisting(dmConnectionString);
50
+ engineConnectionString.dataSource = (_a = engineConnectionString.dataSource) === null || _a === void 0 ? void 0 : _a.replace(ingestPrefix, "https://");
51
+ return new KustoManagedStreamingIngestClient(engineConnectionString, dmConnectionString, defaultProps);
52
+ }
53
+ /**
54
+ * Creates a KustoManagedStreamingIngestClient from a engine connection string.
55
+ * This method infers the engine connection string.
56
+ * For advanced usage, use the constructor that takes an engine connection string and an engine connection string.
57
+ *
58
+ * @param engineConnectionString The engine connection string.
59
+ * @param defaultProps The default ingestion properties.
60
+ */
61
+ static fromEngineConnectionString(engineConnectionString, defaultProps = null) {
62
+ var _a;
63
+ if (engineConnectionString.dataSource == null || engineConnectionString.dataSource.startsWith(ingestPrefix)) {
64
+ throw new Error(`Engine connection string must not include the prefix '${ingestPrefix}'`);
65
+ }
66
+ const dmConnectionString = azure_kusto_data_1.KustoConnectionStringBuilder.fromExisting(engineConnectionString);
67
+ dmConnectionString.dataSource = (_a = dmConnectionString.dataSource) === null || _a === void 0 ? void 0 : _a.replace("https://", ingestPrefix);
68
+ return new KustoManagedStreamingIngestClient(engineConnectionString, dmConnectionString, defaultProps);
69
+ }
70
+ ingestFromStream(stream, ingestionProperties) {
71
+ return __awaiter(this, void 0, void 0, function* () {
72
+ const props = this._mergeProps(ingestionProperties);
73
+ props.validate();
74
+ const descriptor = stream instanceof descriptors_1.StreamDescriptor ? stream : new descriptors_1.StreamDescriptor(stream);
75
+ let result = yield (0, streamUtils_1.tryStreamToArray)(descriptor.stream, maxStreamSize);
76
+ if (result instanceof Buffer) {
77
+ // If we get buffer that means it was less than the max size, so we can do streamingIngestion
78
+ const retry = new retry_1.ExponentialRetry(attemptCount, this.baseSleepTimeSecs, this.baseJitterSecs);
79
+ while (retry.shouldTry()) {
80
+ try {
81
+ const sourceId = `KNC.executeManagedStreamingIngest;${descriptor.sourceId};${retry.currentAttempt}`;
82
+ return yield this.streamingIngestClient.ingestFromStream(new descriptors_1.StreamDescriptor((0, stream_array_1.default)([result])).merge(descriptor), ingestionProperties, sourceId);
83
+ }
84
+ catch (err) {
85
+ const oneApiError = err;
86
+ if (oneApiError["@permanent"]) {
87
+ throw err;
88
+ }
89
+ yield retry.backoff();
90
+ }
91
+ }
92
+ result = (0, stream_array_1.default)([result]);
93
+ }
94
+ return yield this.queuedIngestClient.ingestFromStream(new descriptors_1.StreamDescriptor(result).merge(descriptor), ingestionProperties);
95
+ });
96
+ }
97
+ ingestFromFile(file, ingestionProperties) {
98
+ return __awaiter(this, void 0, void 0, function* () {
99
+ const props = this._mergeProps(ingestionProperties);
100
+ props.validate();
101
+ return yield this.ingestFromStream((0, streamUtils_1.fileToStream)(file), ingestionProperties);
102
+ });
103
+ }
104
+ }
105
+ exports.default = KustoManagedStreamingIngestClient;
106
+ //# sourceMappingURL=managedStreamingIngestClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"managedStreamingIngestClient.js","sourceRoot":"","sources":["managedStreamingIngestClient.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;;;;;;;;;;;AAIlC,+CAAiE;AACjE,+DAA4D;AAC5D,uDAAgE;AAEhE,+CAA+D;AAC/D,oFAA4D;AAC5D,kEAA0C;AAE1C,gEAAqC;AAErC,mCAA2C;AAE3C,MAAM,aAAa,GAAG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