azure-kusto-ingest 7.0.0-alpha.4 → 7.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.
- package/dist-esm/src/ingestionBlobInfo.js +5 -5
- package/dist-esm/src/ingestionBlobInfo.js.map +1 -1
- package/dist-esm/src/ingestionProperties.js.map +1 -1
- package/dist-esm/src/managedStreamingIngestClient.js +7 -7
- package/dist-esm/src/managedStreamingIngestClient.js.map +1 -1
- package/package.json +4 -4
- package/types/src/ingestionProperties.d.ts +1 -1
|
@@ -24,16 +24,16 @@ export class IngestionBlobInfo {
|
|
|
24
24
|
additionalProperties.authorizationContext = authContext;
|
|
25
25
|
const tags = [];
|
|
26
26
|
if (ingestionProperties.additionalTags) {
|
|
27
|
-
tags.
|
|
27
|
+
tags.push(...ingestionProperties.additionalTags);
|
|
28
28
|
}
|
|
29
29
|
if (ingestionProperties.dropByTags) {
|
|
30
|
-
tags.
|
|
30
|
+
tags.push(...ingestionProperties.dropByTags.map((t) => "drop-by:" + t));
|
|
31
31
|
}
|
|
32
32
|
if (ingestionProperties.ingestByTags) {
|
|
33
|
-
tags.
|
|
33
|
+
tags.push(...ingestionProperties.ingestByTags.map((t) => "ingest-by:" + t));
|
|
34
34
|
}
|
|
35
|
-
if (tags
|
|
36
|
-
additionalProperties.tags = tags;
|
|
35
|
+
if (tags.length > 0) {
|
|
36
|
+
additionalProperties.tags = JSON.stringify(tags);
|
|
37
37
|
}
|
|
38
38
|
if (ingestionProperties.ingestIfNotExists) {
|
|
39
39
|
additionalProperties.ingestIfNotExists = ingestionProperties.ingestIfNotExists;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ingestionBlobInfo.js","sourceRoot":"","sources":["../../src/ingestionBlobInfo.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AAKpC,MAAM,OAAO,iB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AAI,mBAAmB,CAAC,yBAAyB,EAAE,CAAC;YAChD,oBAAoB,CAAC,yBAAyB,GAAG,mBAAmB,CAAC,yBAAyB,CAAC;QACnG,CAAC;QAED,IAAI,mBAAmB,CAAC,oBAAoB,EAAE,CAAC;YAC3C,oBAAoB,CAAC,oBAAoB,GAAG,mBAAmB,CAAC,oBAAoB,CAAC;QACzF,CAAC;QAED,IAAI,mBAAmB,CAAC,gBAAgB,EAAE,CAAC;YACvC,oBAAoB,CAAC,gBAAgB,GAAG,mBAAmB,CAAC,gBAAgB,CAAC;QACjF,CAAC;QAED,IAAI,mBAAmB,CAAC,MAAM,EAAE,CAAC;YAC7B,oBAAoB,CAAC,MAAM,GAAG,mBAAmB,CAAC,MAAM,CAAC;QAC7D,CAAC;QACD,IAAI,mBAAmB,CAAC,iBAAiB,EAAE,CAAC;YACxC,oBAAoB,CAAC,iBAAiB,GAAG,mBAAmB,CAAC,iBAAiB,CAAC;QACnF,CAAC;QAED,IAAI,CAAC,oBAAoB,GAAG,oBAAoB,CAAC;IACrD,CAAC;CACJ;AAED,eAAe,iBAAiB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { v4 as uuidv4 } from \"uuid\";\nimport { BlobDescriptor } from \"./descriptors.js\";\nimport IngestionProperties, { ReportLevel, ReportMethod } from \"./ingestionProperties.js\";\nimport { IngestionStatusInTableDescription } from \"./ingestionResult.js\";\n\nexport class IngestionBlobInfo {\n BlobPath: string;\n RawDataSize: number | null;\n DatabaseName: string | null;\n TableName: string | null;\n RetainBlobOnSuccess: boolean;\n FlushImmediately: boolean;\n IgnoreSizeLimit: boolean;\n ReportLevel: ReportLevel | null;\n ReportMethod: ReportMethod | null;\n SourceMessageCreationTime: Date;\n Id: string;\n AdditionalProperties: { [additional: string]: any };\n IngestionStatusInTable: IngestionStatusInTableDescription | null = null;\n ApplicationForTracing?: string | null = null;\n ClientVersionForTracing?: string | null = null;\n\n constructor(\n blobDescriptor: BlobDescriptor,\n ingestionProperties: IngestionProperties,\n authContext: string | null = null,\n applicationForTracing: string | null = null,\n clientVersionForTracing: string | null = null,\n ) {\n this.BlobPath = blobDescriptor.path;\n this.RawDataSize = blobDescriptor.size;\n this.DatabaseName = ingestionProperties.database ?? null;\n this.TableName = ingestionProperties.table ?? null;\n this.RetainBlobOnSuccess = true;\n this.FlushImmediately = ingestionProperties.flushImmediately ?? false;\n this.IgnoreSizeLimit = false;\n this.ReportLevel = ingestionProperties.reportLevel ?? null;\n this.ReportMethod = ingestionProperties.reportMethod ?? null;\n this.SourceMessageCreationTime = new Date();\n this.Id = blobDescriptor.sourceId || uuidv4();\n this.ApplicationForTracing = applicationForTracing;\n this.ClientVersionForTracing = clientVersionForTracing;\n\n const additionalProperties = ingestionProperties.additionalProperties || {};\n additionalProperties.authorizationContext = authContext;\n\n const tags: string[] = [];\n if (ingestionProperties.additionalTags) {\n tags.push(...ingestionProperties.additionalTags);\n }\n if (ingestionProperties.dropByTags) {\n tags.push(...ingestionProperties.dropByTags.map((t) => \"drop-by:\" + t));\n }\n if (ingestionProperties.ingestByTags) {\n tags.push(...ingestionProperties.ingestByTags.map((t) => \"ingest-by:\" + t));\n }\n\n if (tags.length > 0) {\n additionalProperties.tags = JSON.stringify(tags);\n }\n\n if (ingestionProperties.ingestIfNotExists) {\n additionalProperties.ingestIfNotExists = ingestionProperties.ingestIfNotExists;\n }\n\n if (ingestionProperties.ingestionMappingColumns && ingestionProperties.ingestionMappingColumns.length > 0) {\n // server expects a string\n additionalProperties.ingestionMapping = JSON.stringify(ingestionProperties.ingestionMappingColumns.map((m) => m.toApiMapping()));\n }\n\n if (ingestionProperties.ingestionMappingReference) {\n additionalProperties.ingestionMappingReference = ingestionProperties.ingestionMappingReference;\n }\n\n if (ingestionProperties.ingestionMappingKind) {\n additionalProperties.ingestionMappingType = ingestionProperties.ingestionMappingKind;\n }\n\n if (ingestionProperties.validationPolicy) {\n additionalProperties.ValidationPolicy = ingestionProperties.validationPolicy;\n }\n\n if (ingestionProperties.format) {\n additionalProperties.format = ingestionProperties.format;\n }\n if (ingestionProperties.ignoreFirstRecord) {\n additionalProperties.ignoreFirstRecord = ingestionProperties.ignoreFirstRecord;\n }\n\n this.AdditionalProperties = additionalProperties;\n }\n}\n\nexport default IngestionBlobInfo;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ingestionProperties.js","sourceRoot":"","sources":["../../src/ingestionProperties.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,kCAAkC,EAAE,MAAM,aAAa,CAAC;AAGjE;;GAEG;AACH,MAAM,CAAN,IAAY,UAqEX;AArED,WAAY,UAAU;IAClB;;OAEG;IACH,yBAAW,CAAA;IACX;;OAEG;IACH,yBAAW,CAAA;IACX;;OAEG;IACH,2BAAa,CAAA;IACb;;OAEG;IACH,6BAAe,CAAA;IACf;;OAEG;IACH,yBAAW,CAAA;IACX;;OAEG;IACH,yBAAW,CAAA;IACX;;OAEG;IACH,yBAAW,CAAA;IACX;;OAEG;IACH,2BAAa,CAAA;IACb;;OAEG;IACH,2BAAa,CAAA;IACb;;OAEG;IACH,uCAAyB,CAAA;IACzB;;OAEG;IACH,qCAAuB,CAAA;IACvB;;OAEG;IACH,2BAAa,CAAA;IACb;;OAEG;IACH,iCAAmB,CAAA;IACnB;;OAEG;IACH,iCAAmB,CAAA;IACnB;;OAEG;IACH,yBAAW,CAAA;IACX;;OAEG;IACH,uCAAyB,CAAA;IACzB;;OAEG;IACH,uCAAyB,CAAA;AAC7B,CAAC,EArEW,UAAU,KAAV,UAAU,QAqErB;AAED,MAAM,CAAN,IAAY,oBASX;AATD,WAAY,oBAAoB;IAC5B,mCAAW,CAAA;IACX,qCAAa,CAAA;IACb,qCAAa,CAAA;IACb,2CAAmB,CAAA;IACnB,2CAAmB,CAAA;IACnB,mCAAW,CAAA;IACX,iDAAyB,CAAA;IACzB,iDAAyB,CAAA;AAC7B,CAAC,EAT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E,GAAG,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;YACzC,CAAC;QACL,CAAC;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;IAED,WAAW;QACP,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YACf,IAAI,CAAC,MAAM,GAAG,UAAU,CAAC,GAAG,CAAC;QACjC,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;YACpB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC,YAAY,CAAC;QAChD,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;YACrB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC,KAAK,CAAC;QAC3C,CAAC;IACL,CAAC;CACJ;AAID,MAAM,UAAU,0BAA0B,CAAC,mBAA8C;IACrF,IAAI,CAAC,mBAAmB,EAAE,CAAC;QACvB,mBAAmB,GAAG,EAAE,CAAC;IAC7B,CAAC;IACD,OAAO,CAAC,CACJ,mBAAmB,CAAC,MAAM,KAAK,MAAM;QACrC,mBAAmB,CAAC,MAAM,KAAK,SAAS;QACxC,mBAAmB,CAAC,MAAM,KAAK,KAAK;QACpC,mBAAmB,CAAC,MAAM,KAAK,YAAY;QAC3C,mBAAmB,CAAC,MAAM,KAAK,SAAS,CAC3C,CAAC;AACN,CAAC;AAED,eAAe,mBAAmB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { IngestionPropertiesValidationError } from \"./errors.js\";\nimport { ColumnMapping } from \"./columnMappings.js\";\n\n/**\n * Data formats supported for Kusto ingestion.\n */\nexport enum DataFormat {\n /**\n * Comma-separated value.\n */\n CSV = \"csv\",\n /**\n * Tab-separated value.\n */\n TSV = \"tsv\",\n /**\n * Semicolon-separated value (the unique Azure Storage log format).\n */\n SCSV = \"scsv\",\n /**\n * Start-Of-Header (CTRL-A)-separated value.\n */\n SOHSV = \"sohsv\",\n /**\n * Pipeline-separated value (used by Cosmos).\n */\n PSV = \"psv\",\n /**\n * Each record is a line and has just one field.\n */\n TXT = \"txt\",\n /**\n * Whole stream is a single record with a single field.\n */\n RAW = \"raw\",\n /**\n * Tab-separated value with '\\' escaping character.\n */\n TSVE = \"tsve\",\n /**\n * Data is in a JSON format, each line is record with a single JSON value.\n */\n JSON = \"json\",\n /**\n * Data stream holds a single JSON value -- newlines are regular whitespace.\n */\n SINGLEJSON = \"singlejson\",\n /**\n * The data stream is a concatenation of JSON documents (property bags all).\n */\n MULTIJSON = \"multijson\",\n /**\n * Avro format.\n */\n AVRO = \"avro\",\n /**\n * Parquet format.\n */\n PARQUET = \"parquet\",\n /**\n * Microsoft Cosmos structured streams format\n */\n SSTREAM = \"sstream\",\n /**\n * The Optimized Row Columnar (ORC)\n */\n ORC = \"orc\",\n /**\n * Avro format for ingesting through avro2json.\n */\n APACHEAVRO = \"apacheavro\",\n /**\n * W3C Extended Log File format.\n */\n W3CLogFile = \"w3clogfile\",\n}\n\nexport enum IngestionMappingKind {\n CSV = \"Csv\",\n JSON = \"Json\",\n AVRO = \"Avro\",\n PARQUET = \"Parquet\",\n SSTREAM = \"SStream\",\n ORC = \"orc\",\n APACHEAVRO = \"ApacheAvro\",\n W3CLOGFILE = \"W3CLogFile\",\n}\n\nexport const dataFormatMappingKind = (dataFormat: DataFormat): IngestionMappingKind => {\n switch (dataFormat) {\n case DataFormat.CSV:\n return IngestionMappingKind.CSV;\n case DataFormat.TSV:\n return IngestionMappingKind.CSV;\n case DataFormat.SCSV:\n return IngestionMappingKind.CSV;\n case DataFormat.SOHSV:\n return IngestionMappingKind.CSV;\n case DataFormat.PSV:\n return IngestionMappingKind.CSV;\n case DataFormat.TXT:\n return IngestionMappingKind.CSV;\n case DataFormat.RAW:\n return IngestionMappingKind.CSV;\n case DataFormat.TSVE:\n return IngestionMappingKind.CSV;\n case DataFormat.JSON:\n return IngestionMappingKind.JSON;\n case DataFormat.SINGLEJSON:\n return IngestionMappingKind.JSON;\n case DataFormat.MULTIJSON:\n return IngestionMappingKind.JSON;\n case DataFormat.AVRO:\n return IngestionMappingKind.AVRO;\n case DataFormat.PARQUET:\n return IngestionMappingKind.PARQUET;\n case DataFormat.SSTREAM:\n return IngestionMappingKind.SSTREAM;\n case DataFormat.ORC:\n return IngestionMappingKind.ORC;\n case DataFormat.APACHEAVRO:\n return IngestionMappingKind.APACHEAVRO;\n case DataFormat.W3CLogFile:\n return IngestionMappingKind.W3CLOGFILE;\n default:\n throw new IngestionPropertiesValidationError(`Unsupported data format: ${dataFormat}`);\n }\n};\n\nexport enum ValidationOptions {\n DoNotValidate = 0,\n ValidateCsvInputConstantColumns = 1,\n ValidateCsvInputColumnLevelOnly = 2,\n}\n\nexport enum ValidationImplications {\n Fail = 0,\n BestEffort = 1,\n}\n\nexport class ValidationPolicy {\n constructor(\n readonly validationOptions: ValidationOptions = ValidationOptions.DoNotValidate,\n readonly validationImplications: ValidationImplications = ValidationImplications.BestEffort,\n ) {}\n\n toJSON(): Record<string, number> {\n return {\n ValidationOptions: this.validationOptions,\n ValidationImplications: this.validationImplications,\n };\n }\n}\n\nexport enum ReportLevel {\n FailuresOnly = 0,\n DoNotReport = 1,\n FailuresAndSuccesses = 2,\n}\n\nexport enum ReportMethod {\n Queue = 0,\n Table,\n QueueAndTable,\n}\n\nexport interface IngestionPropertiesFields {\n database?: string;\n table?: string;\n format?: DataFormat;\n /**\n * @deprecated. Use ingestionMappingColumns instead.\n */\n ingestionMapping?: ColumnMapping[];\n ingestionMappingColumns?: ColumnMapping[];\n ingestionMappingReference?: string;\n /**\n * @deprecated. Use ingestionMappingKind instead.\n */\n ingestionMappingType?: IngestionMappingKind;\n ingestionMappingKind?: IngestionMappingKind;\n additionalTags?: string;\n ingestIfNotExists?: string;\n ingestByTags?: string[];\n dropByTags?: string[];\n flushImmediately?: boolean;\n ignoreFirstRecord?: boolean;\n reportLevel?: ReportLevel;\n reportMethod?: ReportMethod;\n validationPolicy?: ValidationPolicy;\n additionalProperties?: { [additional: string]: any } | null;\n}\n\n// This trick lets us avoid duplicating all the properties from the interface. See https://github.com/microsoft/TypeScript/issues/3407\n// eslint-disable-next-line @typescript-eslint/no-empty-interface\nexport interface IngestionProperties extends IngestionPropertiesFields {}\n\n// eslint-disable-next-line no-redeclare\nexport class IngestionProperties {\n constructor(data: Partial<IngestionPropertiesFields>) {\n Object.assign(this, data);\n }\n\n validate() {\n if (!this.database) throw new IngestionPropertiesValidationError(\"Must define a target database\");\n if (!this.table) throw new IngestionPropertiesValidationError(\"Must define a target table\");\n if (!this.format) throw new IngestionPropertiesValidationError(\"Must define a data format\");\n\n if (this.ingestionMappingType && !this.ingestionMappingKind) {\n this.ingestionMappingKind = this.ingestionMappingType;\n }\n\n if (this.ingestionMapping && !this.ingestionMappingColumns) {\n this.ingestionMappingColumns = this.ingestionMapping;\n }\n\n if (!this.ingestionMappingColumns && !this.ingestionMappingReference) {\n if (this.ingestionMappingKind) {\n throw new IngestionPropertiesValidationError(\n \"Cannot define ingestionMappingKind without either ingestionMappingColumns or\" + \" ingestionMappingReference\",\n );\n }\n } else {\n const mappingKind = dataFormatMappingKind(this.format);\n if (this.ingestionMappingKind && this.ingestionMappingKind !== mappingKind) {\n throw new IngestionPropertiesValidationError(\n `Mapping kind '${this.ingestionMappingKind}' does not match format '${this.format}' (should be '${mappingKind}')`,\n );\n }\n if (this.ingestionMappingColumns) {\n if (this.ingestionMappingReference) {\n throw new IngestionPropertiesValidationError(\"Cannot define both ingestionMappingColumns and ingestionMappingReference\");\n }\n\n if (this.ingestionMappingColumns.length === 0) {\n throw new IngestionPropertiesValidationError(\"Must define at least one column mapping\");\n }\n\n const wrongMappings = this.ingestionMappingColumns\n .filter((m) => m.mappingKind !== mappingKind)\n .map(\n (m) => `Mapping kind mismatch for column '${m.columnName}' - expected data format kind - '${mappingKind}', but was '${m.mappingKind}'`,\n );\n if (wrongMappings.length > 0) {\n throw new IngestionPropertiesValidationError(`Invalid columns:\\n${wrongMappings.join(\"\\n\")}`);\n }\n }\n }\n\n if (this.reportMethod !== ReportMethod.Queue && this.reportLevel === ReportLevel.FailuresOnly) {\n throw new IngestionPropertiesValidationError(\"ReportLevel.FailuresOnly is not supported with ReportMethod.Table\");\n }\n }\n\n merge(extraProps: IngestionPropertiesInput) {\n const merged = new IngestionProperties(this);\n\n if (!extraProps) {\n return merged;\n }\n\n const assign = <K extends keyof IngestionPropertiesFields, V extends IngestionPropertiesFields[K]>(\n obj: IngestionPropertiesFields,\n prop: K,\n value: V,\n ) => {\n obj[prop] = value;\n };\n\n for (const key of Object.keys(extraProps) as (keyof IngestionPropertiesFields)[]) {\n if (extraProps[key]) {\n assign(merged, key, extraProps[key]);\n }\n }\n\n return merged;\n }\n\n setDefaults() {\n if (!this.format) {\n this.format = DataFormat.CSV;\n }\n if (!this.reportLevel) {\n this.reportLevel = ReportLevel.FailuresOnly;\n }\n if (!this.reportMethod) {\n this.reportMethod = ReportMethod.Queue;\n }\n }\n}\n\nexport type IngestionPropertiesInput = IngestionProperties | IngestionPropertiesFields | null | undefined;\n\nexport function shouldCompressFileByFormat(ingestionProperties?: IngestionPropertiesInput): boolean {\n if (!ingestionProperties) {\n ingestionProperties = {};\n }\n return !(\n ingestionProperties.format === \"avro\" ||\n ingestionProperties.format === \"parquet\" ||\n ingestionProperties.format === \"orc\" ||\n ingestionProperties.format === \"apacheavro\" ||\n ingestionProperties.format === \"sstream\"\n );\n}\n\nexport default IngestionProperties;\n"]}
|
|
1
|
+
{"version":3,"file":"ingestionProperties.js","sourceRoot":"","sources":["../../src/ingestionProperties.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,kCAAkC,EAAE,MAAM,aAAa,CAAC;AAGjE;;GAEG;AACH,MAAM,CAAN,IAAY,UAqEX;AArED,WAAY,UAAU;IAClB;;OAEG;IACH,yBAAW,CAAA;IACX;;OAEG;IACH,yBAAW,CAAA;IACX;;OAEG;IACH,2BAAa,CAAA;IACb;;OAEG;IACH,6BAA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vB,mBAAmB,GAAG,EAAE,CAAC;IAC7B,CAAC;IACD,OAAO,CAAC,CACJ,mBAAmB,CAAC,MAAM,KAAK,MAAM;QACrC,mBAAmB,CAAC,MAAM,KAAK,SAAS;QACxC,mBAAmB,CAAC,MAAM,KAAK,KAAK;QACpC,mBAAmB,CAAC,MAAM,KAAK,YAAY;QAC3C,mBAAmB,CAAC,MAAM,KAAK,SAAS,CAC3C,CAAC;AACN,CAAC;AAED,eAAe,mBAAmB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { IngestionPropertiesValidationError } from \"./errors.js\";\nimport { ColumnMapping } from \"./columnMappings.js\";\n\n/**\n * Data formats supported for Kusto ingestion.\n */\nexport enum DataFormat {\n /**\n * Comma-separated value.\n */\n CSV = \"csv\",\n /**\n * Tab-separated value.\n */\n TSV = \"tsv\",\n /**\n * Semicolon-separated value (the unique Azure Storage log format).\n */\n SCSV = \"scsv\",\n /**\n * Start-Of-Header (CTRL-A)-separated value.\n */\n SOHSV = \"sohsv\",\n /**\n * Pipeline-separated value (used by Cosmos).\n */\n PSV = \"psv\",\n /**\n * Each record is a line and has just one field.\n */\n TXT = \"txt\",\n /**\n * Whole stream is a single record with a single field.\n */\n RAW = \"raw\",\n /**\n * Tab-separated value with '\\' escaping character.\n */\n TSVE = \"tsve\",\n /**\n * Data is in a JSON format, each line is record with a single JSON value.\n */\n JSON = \"json\",\n /**\n * Data stream holds a single JSON value -- newlines are regular whitespace.\n */\n SINGLEJSON = \"singlejson\",\n /**\n * The data stream is a concatenation of JSON documents (property bags all).\n */\n MULTIJSON = \"multijson\",\n /**\n * Avro format.\n */\n AVRO = \"avro\",\n /**\n * Parquet format.\n */\n PARQUET = \"parquet\",\n /**\n * Microsoft Cosmos structured streams format\n */\n SSTREAM = \"sstream\",\n /**\n * The Optimized Row Columnar (ORC)\n */\n ORC = \"orc\",\n /**\n * Avro format for ingesting through avro2json.\n */\n APACHEAVRO = \"apacheavro\",\n /**\n * W3C Extended Log File format.\n */\n W3CLogFile = \"w3clogfile\",\n}\n\nexport enum IngestionMappingKind {\n CSV = \"Csv\",\n JSON = \"Json\",\n AVRO = \"Avro\",\n PARQUET = \"Parquet\",\n SSTREAM = \"SStream\",\n ORC = \"orc\",\n APACHEAVRO = \"ApacheAvro\",\n W3CLOGFILE = \"W3CLogFile\",\n}\n\nexport const dataFormatMappingKind = (dataFormat: DataFormat): IngestionMappingKind => {\n switch (dataFormat) {\n case DataFormat.CSV:\n return IngestionMappingKind.CSV;\n case DataFormat.TSV:\n return IngestionMappingKind.CSV;\n case DataFormat.SCSV:\n return IngestionMappingKind.CSV;\n case DataFormat.SOHSV:\n return IngestionMappingKind.CSV;\n case DataFormat.PSV:\n return IngestionMappingKind.CSV;\n case DataFormat.TXT:\n return IngestionMappingKind.CSV;\n case DataFormat.RAW:\n return IngestionMappingKind.CSV;\n case DataFormat.TSVE:\n return IngestionMappingKind.CSV;\n case DataFormat.JSON:\n return IngestionMappingKind.JSON;\n case DataFormat.SINGLEJSON:\n return IngestionMappingKind.JSON;\n case DataFormat.MULTIJSON:\n return IngestionMappingKind.JSON;\n case DataFormat.AVRO:\n return IngestionMappingKind.AVRO;\n case DataFormat.PARQUET:\n return IngestionMappingKind.PARQUET;\n case DataFormat.SSTREAM:\n return IngestionMappingKind.SSTREAM;\n case DataFormat.ORC:\n return IngestionMappingKind.ORC;\n case DataFormat.APACHEAVRO:\n return IngestionMappingKind.APACHEAVRO;\n case DataFormat.W3CLogFile:\n return IngestionMappingKind.W3CLOGFILE;\n default:\n throw new IngestionPropertiesValidationError(`Unsupported data format: ${dataFormat}`);\n }\n};\n\nexport enum ValidationOptions {\n DoNotValidate = 0,\n ValidateCsvInputConstantColumns = 1,\n ValidateCsvInputColumnLevelOnly = 2,\n}\n\nexport enum ValidationImplications {\n Fail = 0,\n BestEffort = 1,\n}\n\nexport class ValidationPolicy {\n constructor(\n readonly validationOptions: ValidationOptions = ValidationOptions.DoNotValidate,\n readonly validationImplications: ValidationImplications = ValidationImplications.BestEffort,\n ) {}\n\n toJSON(): Record<string, number> {\n return {\n ValidationOptions: this.validationOptions,\n ValidationImplications: this.validationImplications,\n };\n }\n}\n\nexport enum ReportLevel {\n FailuresOnly = 0,\n DoNotReport = 1,\n FailuresAndSuccesses = 2,\n}\n\nexport enum ReportMethod {\n Queue = 0,\n Table,\n QueueAndTable,\n}\n\nexport interface IngestionPropertiesFields {\n database?: string;\n table?: string;\n format?: DataFormat;\n /**\n * @deprecated. Use ingestionMappingColumns instead.\n */\n ingestionMapping?: ColumnMapping[];\n ingestionMappingColumns?: ColumnMapping[];\n ingestionMappingReference?: string;\n /**\n * @deprecated. Use ingestionMappingKind instead.\n */\n ingestionMappingType?: IngestionMappingKind;\n ingestionMappingKind?: IngestionMappingKind;\n additionalTags?: string[];\n ingestIfNotExists?: string;\n ingestByTags?: string[];\n dropByTags?: string[];\n flushImmediately?: boolean;\n ignoreFirstRecord?: boolean;\n reportLevel?: ReportLevel;\n reportMethod?: ReportMethod;\n validationPolicy?: ValidationPolicy;\n additionalProperties?: { [additional: string]: any } | null;\n}\n\n// This trick lets us avoid duplicating all the properties from the interface. See https://github.com/microsoft/TypeScript/issues/3407\n// eslint-disable-next-line @typescript-eslint/no-empty-interface\nexport interface IngestionProperties extends IngestionPropertiesFields {}\n\n// eslint-disable-next-line no-redeclare\nexport class IngestionProperties {\n constructor(data: Partial<IngestionPropertiesFields>) {\n Object.assign(this, data);\n }\n\n validate() {\n if (!this.database) throw new IngestionPropertiesValidationError(\"Must define a target database\");\n if (!this.table) throw new IngestionPropertiesValidationError(\"Must define a target table\");\n if (!this.format) throw new IngestionPropertiesValidationError(\"Must define a data format\");\n\n if (this.ingestionMappingType && !this.ingestionMappingKind) {\n this.ingestionMappingKind = this.ingestionMappingType;\n }\n\n if (this.ingestionMapping && !this.ingestionMappingColumns) {\n this.ingestionMappingColumns = this.ingestionMapping;\n }\n\n if (!this.ingestionMappingColumns && !this.ingestionMappingReference) {\n if (this.ingestionMappingKind) {\n throw new IngestionPropertiesValidationError(\n \"Cannot define ingestionMappingKind without either ingestionMappingColumns or\" + \" ingestionMappingReference\",\n );\n }\n } else {\n const mappingKind = dataFormatMappingKind(this.format);\n if (this.ingestionMappingKind && this.ingestionMappingKind !== mappingKind) {\n throw new IngestionPropertiesValidationError(\n `Mapping kind '${this.ingestionMappingKind}' does not match format '${this.format}' (should be '${mappingKind}')`,\n );\n }\n if (this.ingestionMappingColumns) {\n if (this.ingestionMappingReference) {\n throw new IngestionPropertiesValidationError(\"Cannot define both ingestionMappingColumns and ingestionMappingReference\");\n }\n\n if (this.ingestionMappingColumns.length === 0) {\n throw new IngestionPropertiesValidationError(\"Must define at least one column mapping\");\n }\n\n const wrongMappings = this.ingestionMappingColumns\n .filter((m) => m.mappingKind !== mappingKind)\n .map(\n (m) => `Mapping kind mismatch for column '${m.columnName}' - expected data format kind - '${mappingKind}', but was '${m.mappingKind}'`,\n );\n if (wrongMappings.length > 0) {\n throw new IngestionPropertiesValidationError(`Invalid columns:\\n${wrongMappings.join(\"\\n\")}`);\n }\n }\n }\n\n if (this.reportMethod !== ReportMethod.Queue && this.reportLevel === ReportLevel.FailuresOnly) {\n throw new IngestionPropertiesValidationError(\"ReportLevel.FailuresOnly is not supported with ReportMethod.Table\");\n }\n }\n\n merge(extraProps: IngestionPropertiesInput) {\n const merged = new IngestionProperties(this);\n\n if (!extraProps) {\n return merged;\n }\n\n const assign = <K extends keyof IngestionPropertiesFields, V extends IngestionPropertiesFields[K]>(\n obj: IngestionPropertiesFields,\n prop: K,\n value: V,\n ) => {\n obj[prop] = value;\n };\n\n for (const key of Object.keys(extraProps) as (keyof IngestionPropertiesFields)[]) {\n if (extraProps[key]) {\n assign(merged, key, extraProps[key]);\n }\n }\n\n return merged;\n }\n\n setDefaults() {\n if (!this.format) {\n this.format = DataFormat.CSV;\n }\n if (!this.reportLevel) {\n this.reportLevel = ReportLevel.FailuresOnly;\n }\n if (!this.reportMethod) {\n this.reportMethod = ReportMethod.Queue;\n }\n }\n}\n\nexport type IngestionPropertiesInput = IngestionProperties | IngestionPropertiesFields | null | undefined;\n\nexport function shouldCompressFileByFormat(ingestionProperties?: IngestionPropertiesInput): boolean {\n if (!ingestionProperties) {\n ingestionProperties = {};\n }\n return !(\n ingestionProperties.format === \"avro\" ||\n ingestionProperties.format === \"parquet\" ||\n ingestionProperties.format === \"orc\" ||\n ingestionProperties.format === \"apacheavro\" ||\n ingestionProperties.format === \"sstream\"\n );\n}\n\nexport default IngestionProperties;\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
|
2
2
|
// Licensed under the MIT License.
|
|
3
|
-
import {
|
|
3
|
+
import { isNodeLike } from "@azure/core-util";
|
|
4
4
|
import { KustoConnectionStringBuilder } from "azure-kusto-data";
|
|
5
5
|
import { AbstractKustoClient } from "./abstractKustoClient.js";
|
|
6
6
|
import { BlobDescriptor, StreamDescriptor } from "./descriptors.js";
|
|
@@ -66,13 +66,13 @@ class KustoManagedStreamingIngestClient extends AbstractKustoClient {
|
|
|
66
66
|
this.ensureOpen();
|
|
67
67
|
const props = this._getMergedProps(ingestionProperties);
|
|
68
68
|
let descriptor = stream instanceof StreamDescriptor ? stream : new StreamDescriptor(stream);
|
|
69
|
-
let result =
|
|
69
|
+
let result = isNodeLike ? await tryStreamToArray(descriptor.stream, maxStreamSize) : descriptor.stream;
|
|
70
70
|
descriptor = new StreamDescriptor(result).merge(descriptor);
|
|
71
71
|
let streamingResult = null;
|
|
72
72
|
// tryStreamToArray returns a Buffer in NodeJS impl if stream size is small enouph
|
|
73
|
-
if ((
|
|
74
|
-
streamingResult = await this.streamWithRetries(
|
|
75
|
-
result =
|
|
73
|
+
if ((isNodeLike && result instanceof Buffer) || !isNodeLike) {
|
|
74
|
+
streamingResult = await this.streamWithRetries(isNodeLike ? ((_a = descriptor.size) !== null && _a !== void 0 ? _a : 0) : descriptor.stream.byteLength, descriptor, props, clientRequestId, result);
|
|
75
|
+
result = isNodeLike ? readableToStream(result) : descriptor.stream;
|
|
76
76
|
}
|
|
77
77
|
return streamingResult !== null && streamingResult !== void 0 ? streamingResult : this.queuedIngestClient.ingestFromStream(new StreamDescriptor(result).merge(descriptor), props);
|
|
78
78
|
}
|
|
@@ -104,7 +104,7 @@ class KustoManagedStreamingIngestClient extends AbstractKustoClient {
|
|
|
104
104
|
if (isBlob) {
|
|
105
105
|
return await this.streamingIngestClient.ingestFromBlob(descriptor, props, sourceId);
|
|
106
106
|
}
|
|
107
|
-
if (
|
|
107
|
+
if (isNodeLike) {
|
|
108
108
|
return await this.streamingIngestClient.ingestFromStream(new StreamDescriptor(readableToStream(stream)).merge(descriptor), props, sourceId);
|
|
109
109
|
}
|
|
110
110
|
return await this.streamingIngestClient.ingestFromStream(descriptor, props, sourceId);
|
|
@@ -117,7 +117,7 @@ class KustoManagedStreamingIngestClient extends AbstractKustoClient {
|
|
|
117
117
|
await retry.backoff();
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
|
-
stream = isBlob ? undefined :
|
|
120
|
+
stream = isBlob ? undefined : isNodeLike && stream ? readableToStream(stream) : descriptor.stream;
|
|
121
121
|
}
|
|
122
122
|
return null;
|
|
123
123
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"managedStreamingIngestClient.js","sourceRoot":"","sources":["../../src/managedStreamingIngestClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,4BAA4B,EAAwB,MAAM,kBAAkB,CAAC;AAEtF,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAsB,cAAc,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACxF,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,YAAY,MAAM,mBAAmB,CA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O,MAAM,IAAI,CAAC,qBAAqB,CAAC,cAAc,CAAC,UAA4B,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;oBAC1G,CAAC;oBAED,IAAI,MAAM,EAAE,CAAC;wBACT,OAAO,MAAM,IAAI,CAAC,qBAAqB,CAAC,gBAAgB,CACpD,IAAI,gBAAgB,CAAC,gBAAgB,CAAC,MAAO,CAAC,CAAC,CAAC,KAAK,CAAC,UAA8B,CAAC,EACrF,KAAK,EACL,QAAQ,CACX,CAAC;oBACN,CAAC;oBAED,OAAO,MAAM,IAAI,CAAC,qBAAqB,CAAC,gBAAgB,CAAC,UAA8B,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;gBAC9G,CAAC;gBAAC,OAAO,GAAY,EAAE,CAAC;oBACpB,MAAM,WAAW,GAAG,GAAiC,CAAC;oBACtD,IAAI,WAAW,CAAC,YAAY,CAAC,EAAE,CAAC;wBAC5B,MAAM,GAAG,CAAC;oBACd,CAAC;oBACD,MAAM,KAAK,CAAC,OAAO,EAAE,CAAC;gBAC1B,CAAC;YACL,CAAC;YAED,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,IAAI,MAAM,CAAC,CAAC,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAE,UAA+B,CAAC,MAAM,CAAC;QACxH,CAAC;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,KAAK;QACD,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;YAClB,IAAI,CAAC,qBAAqB,CAAC,KAAK,EAAE,CAAC;YACnC,IAAI,CAAC,kBAAkB,CAAC,KAAK,EAAE,CAAC;QACpC,CAAC;QACD,KAAK,CAAC,KAAK,EAAE,CAAC;IAClB,CAAC;CACJ;AAED,eAAe,iCAAiC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { IngestionPropertiesInput } from \"./ingestionProperties.js\";\n\nimport { isNode } from \"@azure/core-util\";\nimport { KustoConnectionStringBuilder, KustoResponseDataSet } from \"azure-kusto-data\";\nimport { Readable } from \"stream\";\nimport { AbstractKustoClient } from \"./abstractKustoClient.js\";\nimport { AbstractDescriptor, BlobDescriptor, StreamDescriptor } from \"./descriptors.js\";\nimport { FileDescriptor } from \"./fileDescriptor.js\";\nimport IngestClient from \"./ingestClient.js\";\nimport { ExponentialRetry } from \"./retry.js\";\nimport { readableToStream, tryFileToBuffer, tryStreamToArray } from \"./streamUtils.js\";\nimport StreamingIngestClient from \"./streamingIngestClient.js\";\nimport { IngestionResult } from \"./ingestionResult.js\";\n\nconst maxStreamSize = 1024 * 1024 * 4;\nconst attemptCount = 3;\nconst ingestPrefix = \"https://ingest-\";\n\nclass KustoManagedStreamingIngestClient extends AbstractKustoClient {\n private streamingIngestClient: StreamingIngestClient;\n private queuedIngestClient: IngestClient;\n private baseSleepTimeSecs = 1;\n private baseJitterSecs = 1;\n\n /**\n * Creates a KustoManagedStreamingIngestClient from a DM connection string.\n * This method infers the engine connection string.\n * For advanced usage, use the constructor that takes a DM connection string and an engine connection string.\n *\n * @param dmConnectionString The DM connection string.\n * @param defaultProps The default ingestion properties.\n */\n static fromDmConnectionString(\n dmConnectionString: KustoConnectionStringBuilder,\n defaultProps?: IngestionPropertiesInput,\n ): KustoManagedStreamingIngestClient {\n if (dmConnectionString.dataSource == null || !dmConnectionString.dataSource.startsWith(ingestPrefix)) {\n throw new Error(`DM connection string must include the prefix '${ingestPrefix}'`);\n }\n\n const engineConnectionString = KustoConnectionStringBuilder.fromExisting(dmConnectionString);\n engineConnectionString.dataSource = engineConnectionString.dataSource?.replace(ingestPrefix, \"https://\");\n\n return new KustoManagedStreamingIngestClient(engineConnectionString, dmConnectionString, defaultProps);\n }\n\n /**\n * Creates a KustoManagedStreamingIngestClient from a engine connection string.\n * This method infers the engine connection string.\n * For advanced usage, use the constructor that takes an engine connection string and an engine connection string.\n *\n * @param engineConnectionString The engine connection string.\n * @param defaultProps The default ingestion properties.\n */\n static fromEngineConnectionString(\n engineConnectionString: KustoConnectionStringBuilder,\n defaultProps?: IngestionPropertiesInput,\n ): KustoManagedStreamingIngestClient {\n if (engineConnectionString.dataSource == null || engineConnectionString.dataSource.startsWith(ingestPrefix)) {\n throw new Error(`Engine connection string must not include the prefix '${ingestPrefix}'`);\n }\n\n const dmConnectionString = KustoConnectionStringBuilder.fromExisting(engineConnectionString);\n dmConnectionString.dataSource = dmConnectionString.dataSource?.replace(\"https://\", ingestPrefix);\n\n return new KustoManagedStreamingIngestClient(engineConnectionString, dmConnectionString, defaultProps);\n }\n\n constructor(\n engineKcsb: string | KustoConnectionStringBuilder,\n dmKcsb: string | KustoConnectionStringBuilder,\n defaultProps?: IngestionPropertiesInput,\n autoCorrectEndpoint: boolean = true,\n ) {\n super(defaultProps);\n this.streamingIngestClient = new StreamingIngestClient(engineKcsb, defaultProps, autoCorrectEndpoint);\n this.queuedIngestClient = new IngestClient(dmKcsb, defaultProps, autoCorrectEndpoint);\n\n if (this.streamingIngestClient.defaultDatabase && this.streamingIngestClient.defaultDatabase !== this.queuedIngestClient.defaultDatabase) {\n throw new Error(\n `Default database for streaming ingest client (${this.streamingIngestClient.defaultDatabase}) must match default database for queued ingest client (${this.queuedIngestClient.defaultDatabase})`,\n );\n }\n\n this.defaultDatabase = this.streamingIngestClient.defaultDatabase;\n }\n\n /**\n * Use Readable for Node.js and ArrayBuffer in browser\n */\n async ingestFromStream(\n stream: StreamDescriptor | Readable | ArrayBuffer,\n ingestionProperties?: IngestionPropertiesInput,\n clientRequestId?: string,\n ): Promise<KustoResponseDataSet | IngestionResult> {\n this.ensureOpen();\n const props = this._getMergedProps(ingestionProperties);\n let descriptor = stream instanceof StreamDescriptor ? stream : new StreamDescriptor(stream);\n let result = isNode ? await tryStreamToArray(descriptor.stream as Readable, maxStreamSize) : descriptor.stream;\n descriptor = new StreamDescriptor(result).merge(descriptor);\n let streamingResult: Promise<any> | null = null;\n // tryStreamToArray returns a Buffer in NodeJS impl if stream size is small enouph\n if ((isNode && result instanceof Buffer) || !isNode) {\n streamingResult = await this.streamWithRetries(\n isNode ? (descriptor.size ?? 0) : (descriptor.stream as ArrayBuffer).byteLength,\n descriptor,\n props,\n clientRequestId,\n result,\n );\n\n result = isNode ? readableToStream(result) : descriptor.stream;\n }\n\n return streamingResult ?? this.queuedIngestClient.ingestFromStream(new StreamDescriptor(result).merge(descriptor), props);\n }\n\n /**\n * Use string for Node.js and Blob in browser\n */\n async ingestFromFile(\n file: FileDescriptor | string | Blob,\n ingestionProperties?: IngestionPropertiesInput,\n ): Promise<KustoResponseDataSet | IngestionResult> {\n this.ensureOpen();\n\n const stream = file instanceof FileDescriptor ? await tryFileToBuffer(file) : await tryFileToBuffer(new FileDescriptor(file));\n return await this.ingestFromStream(stream, ingestionProperties);\n }\n\n async ingestFromBlob(\n blob: string | BlobDescriptor,\n ingestionProperties?: IngestionPropertiesInput,\n clientRequestId?: string,\n ): Promise<KustoResponseDataSet | IngestionResult> {\n const props = this._getMergedProps(ingestionProperties);\n const descriptor = blob instanceof BlobDescriptor ? blob : new BlobDescriptor(blob);\n // No need to check blob size if it was given to us that it's not empty\n await descriptor.fillSize();\n\n const streamingResult = await this.streamWithRetries(descriptor.size ?? 0, descriptor, props, clientRequestId);\n return streamingResult ?? this.queuedIngestClient.ingestFromBlob(descriptor, props);\n }\n\n async streamWithRetries(\n length: number,\n descriptor: AbstractDescriptor,\n props?: IngestionPropertiesInput,\n clientRequestId?: string,\n stream?: Readable | ArrayBuffer,\n ): Promise<any> {\n const isBlob = descriptor instanceof BlobDescriptor;\n if (length <= maxStreamSize) {\n // If we get buffer that means it was less than the max size, so we can do streamingIngestion\n const retry = new ExponentialRetry(attemptCount, this.baseSleepTimeSecs, this.baseJitterSecs);\n while (retry.shouldTry()) {\n try {\n const sourceId =\n clientRequestId ??\n `KNC.executeManagedStreamingIngest${isBlob ? \"FromBlob\" : \"FromStream\"};${descriptor.sourceId};${retry.currentAttempt}`;\n if (isBlob) {\n return await this.streamingIngestClient.ingestFromBlob(descriptor as BlobDescriptor, props, sourceId);\n }\n\n if (isNode) {\n return await this.streamingIngestClient.ingestFromStream(\n new StreamDescriptor(readableToStream(stream!)).merge(descriptor as StreamDescriptor),\n props,\n sourceId,\n );\n }\n\n return await this.streamingIngestClient.ingestFromStream(descriptor as StreamDescriptor, props, sourceId);\n } catch (err: unknown) {\n const oneApiError = err as { \"@permanent\"?: boolean };\n if (oneApiError[\"@permanent\"]) {\n throw err;\n }\n await retry.backoff();\n }\n }\n\n stream = isBlob ? undefined : isNode && stream ? readableToStream(stream) : (descriptor as StreamDescriptor).stream;\n }\n\n return null;\n }\n\n close() {\n if (!this._isClosed) {\n this.streamingIngestClient.close();\n this.queuedIngestClient.close();\n }\n super.close();\n }\n}\n\nexport default KustoManagedStreamingIngestClient;\n"]}
|
|
1
|
+
{"version":3,"file":"managedStreamingIngestClient.js","sourceRoot":"","sources":["../../src/managedStreamingIngestClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,4BAA4B,EAAwB,MAAM,kBAAkB,CAAC;AAEtF,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAsB,cAAc,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACxF,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,YAAY,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACvF,OAAO,qBAAqB,MAAM,4BAA4B,CAAC;AAG/D,MAAM,aAAa,GAAG,IAAI,GAAG,IAAI,GAAG,CAAC,CAAC;AACtC,MAAM,YAAY,GAAG,CA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UAA8B,CAAC,EACrF,KAAK,EACL,QAAQ,CACX,CAAC;oBACN,CAAC;oBAED,OAAO,MAAM,IAAI,CAAC,qBAAqB,CAAC,gBAAgB,CAAC,UAA8B,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;gBAC9G,CAAC;gBAAC,OAAO,GAAY,EAAE,CAAC;oBACpB,MAAM,WAAW,GAAG,GAAiC,CAAC;oBACtD,IAAI,WAAW,CAAC,YAAY,CAAC,EAAE,CAAC;wBAC5B,MAAM,GAAG,CAAC;oBACd,CAAC;oBACD,MAAM,KAAK,CAAC,OAAO,EAAE,CAAC;gBAC1B,CAAC;YACL,CAAC;YAED,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,IAAI,MAAM,CAAC,CAAC,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAE,UAA+B,CAAC,MAAM,CAAC;QAC5H,CAAC;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,KAAK;QACD,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;YAClB,IAAI,CAAC,qBAAqB,CAAC,KAAK,EAAE,CAAC;YACnC,IAAI,CAAC,kBAAkB,CAAC,KAAK,EAAE,CAAC;QACpC,CAAC;QACD,KAAK,CAAC,KAAK,EAAE,CAAC;IAClB,CAAC;CACJ;AAED,eAAe,iCAAiC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { IngestionPropertiesInput } from \"./ingestionProperties.js\";\n\nimport { isNodeLike } from \"@azure/core-util\";\nimport { KustoConnectionStringBuilder, KustoResponseDataSet } from \"azure-kusto-data\";\nimport { Readable } from \"stream\";\nimport { AbstractKustoClient } from \"./abstractKustoClient.js\";\nimport { AbstractDescriptor, BlobDescriptor, StreamDescriptor } from \"./descriptors.js\";\nimport { FileDescriptor } from \"./fileDescriptor.js\";\nimport IngestClient from \"./ingestClient.js\";\nimport { ExponentialRetry } from \"./retry.js\";\nimport { readableToStream, tryFileToBuffer, tryStreamToArray } from \"./streamUtils.js\";\nimport StreamingIngestClient from \"./streamingIngestClient.js\";\nimport { IngestionResult } from \"./ingestionResult.js\";\n\nconst maxStreamSize = 1024 * 1024 * 4;\nconst attemptCount = 3;\nconst ingestPrefix = \"https://ingest-\";\n\nclass KustoManagedStreamingIngestClient extends AbstractKustoClient {\n private streamingIngestClient: StreamingIngestClient;\n private queuedIngestClient: IngestClient;\n private baseSleepTimeSecs = 1;\n private baseJitterSecs = 1;\n\n /**\n * Creates a KustoManagedStreamingIngestClient from a DM connection string.\n * This method infers the engine connection string.\n * For advanced usage, use the constructor that takes a DM connection string and an engine connection string.\n *\n * @param dmConnectionString The DM connection string.\n * @param defaultProps The default ingestion properties.\n */\n static fromDmConnectionString(\n dmConnectionString: KustoConnectionStringBuilder,\n defaultProps?: IngestionPropertiesInput,\n ): KustoManagedStreamingIngestClient {\n if (dmConnectionString.dataSource == null || !dmConnectionString.dataSource.startsWith(ingestPrefix)) {\n throw new Error(`DM connection string must include the prefix '${ingestPrefix}'`);\n }\n\n const engineConnectionString = KustoConnectionStringBuilder.fromExisting(dmConnectionString);\n engineConnectionString.dataSource = engineConnectionString.dataSource?.replace(ingestPrefix, \"https://\");\n\n return new KustoManagedStreamingIngestClient(engineConnectionString, dmConnectionString, defaultProps);\n }\n\n /**\n * Creates a KustoManagedStreamingIngestClient from a engine connection string.\n * This method infers the engine connection string.\n * For advanced usage, use the constructor that takes an engine connection string and an engine connection string.\n *\n * @param engineConnectionString The engine connection string.\n * @param defaultProps The default ingestion properties.\n */\n static fromEngineConnectionString(\n engineConnectionString: KustoConnectionStringBuilder,\n defaultProps?: IngestionPropertiesInput,\n ): KustoManagedStreamingIngestClient {\n if (engineConnectionString.dataSource == null || engineConnectionString.dataSource.startsWith(ingestPrefix)) {\n throw new Error(`Engine connection string must not include the prefix '${ingestPrefix}'`);\n }\n\n const dmConnectionString = KustoConnectionStringBuilder.fromExisting(engineConnectionString);\n dmConnectionString.dataSource = dmConnectionString.dataSource?.replace(\"https://\", ingestPrefix);\n\n return new KustoManagedStreamingIngestClient(engineConnectionString, dmConnectionString, defaultProps);\n }\n\n constructor(\n engineKcsb: string | KustoConnectionStringBuilder,\n dmKcsb: string | KustoConnectionStringBuilder,\n defaultProps?: IngestionPropertiesInput,\n autoCorrectEndpoint: boolean = true,\n ) {\n super(defaultProps);\n this.streamingIngestClient = new StreamingIngestClient(engineKcsb, defaultProps, autoCorrectEndpoint);\n this.queuedIngestClient = new IngestClient(dmKcsb, defaultProps, autoCorrectEndpoint);\n\n if (this.streamingIngestClient.defaultDatabase && this.streamingIngestClient.defaultDatabase !== this.queuedIngestClient.defaultDatabase) {\n throw new Error(\n `Default database for streaming ingest client (${this.streamingIngestClient.defaultDatabase}) must match default database for queued ingest client (${this.queuedIngestClient.defaultDatabase})`,\n );\n }\n\n this.defaultDatabase = this.streamingIngestClient.defaultDatabase;\n }\n\n /**\n * Use Readable for Node.js and ArrayBuffer in browser\n */\n async ingestFromStream(\n stream: StreamDescriptor | Readable | ArrayBuffer,\n ingestionProperties?: IngestionPropertiesInput,\n clientRequestId?: string,\n ): Promise<KustoResponseDataSet | IngestionResult> {\n this.ensureOpen();\n const props = this._getMergedProps(ingestionProperties);\n let descriptor = stream instanceof StreamDescriptor ? stream : new StreamDescriptor(stream);\n let result = isNodeLike ? await tryStreamToArray(descriptor.stream as Readable, maxStreamSize) : descriptor.stream;\n descriptor = new StreamDescriptor(result).merge(descriptor);\n let streamingResult: Promise<any> | null = null;\n // tryStreamToArray returns a Buffer in NodeJS impl if stream size is small enouph\n if ((isNodeLike && result instanceof Buffer) || !isNodeLike) {\n streamingResult = await this.streamWithRetries(\n isNodeLike ? (descriptor.size ?? 0) : (descriptor.stream as ArrayBuffer).byteLength,\n descriptor,\n props,\n clientRequestId,\n result,\n );\n\n result = isNodeLike ? readableToStream(result) : descriptor.stream;\n }\n\n return streamingResult ?? this.queuedIngestClient.ingestFromStream(new StreamDescriptor(result).merge(descriptor), props);\n }\n\n /**\n * Use string for Node.js and Blob in browser\n */\n async ingestFromFile(\n file: FileDescriptor | string | Blob,\n ingestionProperties?: IngestionPropertiesInput,\n ): Promise<KustoResponseDataSet | IngestionResult> {\n this.ensureOpen();\n\n const stream = file instanceof FileDescriptor ? await tryFileToBuffer(file) : await tryFileToBuffer(new FileDescriptor(file));\n return await this.ingestFromStream(stream, ingestionProperties);\n }\n\n async ingestFromBlob(\n blob: string | BlobDescriptor,\n ingestionProperties?: IngestionPropertiesInput,\n clientRequestId?: string,\n ): Promise<KustoResponseDataSet | IngestionResult> {\n const props = this._getMergedProps(ingestionProperties);\n const descriptor = blob instanceof BlobDescriptor ? blob : new BlobDescriptor(blob);\n // No need to check blob size if it was given to us that it's not empty\n await descriptor.fillSize();\n\n const streamingResult = await this.streamWithRetries(descriptor.size ?? 0, descriptor, props, clientRequestId);\n return streamingResult ?? this.queuedIngestClient.ingestFromBlob(descriptor, props);\n }\n\n async streamWithRetries(\n length: number,\n descriptor: AbstractDescriptor,\n props?: IngestionPropertiesInput,\n clientRequestId?: string,\n stream?: Readable | ArrayBuffer,\n ): Promise<any> {\n const isBlob = descriptor instanceof BlobDescriptor;\n if (length <= maxStreamSize) {\n // If we get buffer that means it was less than the max size, so we can do streamingIngestion\n const retry = new ExponentialRetry(attemptCount, this.baseSleepTimeSecs, this.baseJitterSecs);\n while (retry.shouldTry()) {\n try {\n const sourceId =\n clientRequestId ??\n `KNC.executeManagedStreamingIngest${isBlob ? \"FromBlob\" : \"FromStream\"};${descriptor.sourceId};${retry.currentAttempt}`;\n if (isBlob) {\n return await this.streamingIngestClient.ingestFromBlob(descriptor as BlobDescriptor, props, sourceId);\n }\n\n if (isNodeLike) {\n return await this.streamingIngestClient.ingestFromStream(\n new StreamDescriptor(readableToStream(stream!)).merge(descriptor as StreamDescriptor),\n props,\n sourceId,\n );\n }\n\n return await this.streamingIngestClient.ingestFromStream(descriptor as StreamDescriptor, props, sourceId);\n } catch (err: unknown) {\n const oneApiError = err as { \"@permanent\"?: boolean };\n if (oneApiError[\"@permanent\"]) {\n throw err;\n }\n await retry.backoff();\n }\n }\n\n stream = isBlob ? undefined : isNodeLike && stream ? readableToStream(stream) : (descriptor as StreamDescriptor).stream;\n }\n\n return null;\n }\n\n close() {\n if (!this._isClosed) {\n this.streamingIngestClient.close();\n this.queuedIngestClient.close();\n }\n super.close();\n }\n}\n\nexport default KustoManagedStreamingIngestClient;\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "azure-kusto-ingest",
|
|
3
|
-
"version": "7.0.0
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"description": "Azure Data Explorer Ingestion SDK",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist-esm/src/index.js",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"clean": "rimraf dist/* dist-esm/* types/*"
|
|
17
17
|
},
|
|
18
18
|
"engines": {
|
|
19
|
-
"node": ">=
|
|
19
|
+
"node": ">= 20.0.0"
|
|
20
20
|
},
|
|
21
21
|
"publishConfig": {
|
|
22
22
|
"access": "public"
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"@types/tmp": "^0.2.3",
|
|
71
71
|
"@types/uuid": "^8.3.4",
|
|
72
72
|
"@types/uuid-validate": "0.0.1",
|
|
73
|
-
"azure-kusto-data": "^7.0.0
|
|
73
|
+
"azure-kusto-data": "^7.0.0",
|
|
74
74
|
"browserify-zlib": "0.2.0",
|
|
75
75
|
"buffer": "^6.0.3",
|
|
76
76
|
"is-ip": "^3.1.0",
|
|
@@ -85,5 +85,5 @@
|
|
|
85
85
|
"@types/sinon": "^10.0.13",
|
|
86
86
|
"assert": "^2.0.0"
|
|
87
87
|
},
|
|
88
|
-
"gitHead": "
|
|
88
|
+
"gitHead": "2fdb411b765647356dcde15638f04d5cdf0b2158"
|
|
89
89
|
}
|
|
@@ -123,7 +123,7 @@ export interface IngestionPropertiesFields {
|
|
|
123
123
|
*/
|
|
124
124
|
ingestionMappingType?: IngestionMappingKind;
|
|
125
125
|
ingestionMappingKind?: IngestionMappingKind;
|
|
126
|
-
additionalTags?: string;
|
|
126
|
+
additionalTags?: string[];
|
|
127
127
|
ingestIfNotExists?: string;
|
|
128
128
|
ingestByTags?: string[];
|
|
129
129
|
dropByTags?: string[];
|