@azure/storage-file-datalake 12.12.0-beta.1 → 12.13.0-beta.1

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/index.js CHANGED
@@ -123,8 +123,8 @@ class AnonymousCredential extends Credential {
123
123
 
124
124
  // Copyright (c) Microsoft Corporation.
125
125
  // Licensed under the MIT license.
126
- const SDK_VERSION = "12.12.0-beta.1";
127
- const SERVICE_VERSION = "2021-12-02";
126
+ const SDK_VERSION = "12.13.0-beta.1";
127
+ const SERVICE_VERSION = "2022-11-02";
128
128
  const KB = 1024;
129
129
  const MB = KB * 1024;
130
130
  const DEFAULT_HIGH_LEVEL_CONCURRENCY = 5;
@@ -531,7 +531,8 @@ function appendToURLPath(url, name) {
531
531
  let path = urlParsed.getPath();
532
532
  path = path ? (path.endsWith("/") ? `${path}${name}` : `${path}/${name}`) : name;
533
533
  urlParsed.setPath(path);
534
- return urlParsed.toString();
534
+ const normalizedUrl = new URL(urlParsed.toString());
535
+ return normalizedUrl.toString();
535
536
  }
536
537
  /**
537
538
  * Append a string to URL query.
@@ -765,6 +766,7 @@ function isIpEndpointStyle(parsedUrl) {
765
766
  return (/^.*:.*:.*$|^localhost(:[0-9]+)?$|^(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])(\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])){3}(:[0-9]+)?$/.test(host) ||
766
767
  (parsedUrl.getPort() !== undefined && PathStylePorts.includes(parsedUrl.getPort())));
767
768
  }
769
+ const BugTimeBeginningInMS = 13322188800000;
768
770
  /**
769
771
  * This is to convert a Windows File Time ticks to a Date object.
770
772
  */
@@ -778,7 +780,14 @@ function windowsFileTimeTicksToTime(timeNumber) {
778
780
  // since 12:00 A.M. January 1, 1601 Coordinated Universal Time (UTC).
779
781
  // Date accepts a value that represents miliseconds from 12:00 A.M. January 1, 1970
780
782
  // Here should correct the year number after converting.
781
- const date = new Date(timeNumberInternal / 10000);
783
+ const timeNumerInMs = timeNumberInternal / 10000;
784
+ const date = new Date(timeNumerInMs);
785
+ // When initializing date from a miliseconds number the day after 2023-03-01 is still 2023-03-01.
786
+ // For example, 13322188799999 is 2023-03-01T23:59:59.999Z, while 13322188800000 is 2023-03-01T00:00:00.000Z
787
+ // Here is to work around the bug.
788
+ if (timeNumerInMs >= BugTimeBeginningInMS) {
789
+ date.setUTCDate(date.getUTCDate() + 1);
790
+ }
782
791
  date.setUTCFullYear(date.getUTCFullYear() - 369);
783
792
  return date;
784
793
  }
@@ -800,6 +809,22 @@ function EscapePath(pathName) {
800
809
  }
801
810
  return split.join("/");
802
811
  }
812
+ /**
813
+ * Parse value of encryption context from headers in raw response.
814
+ */
815
+ function ParseEncryptionContextHeaderValue(rawResponse) {
816
+ const response = rawResponse;
817
+ if (rawResponse._response) {
818
+ const headers = rawResponse._response.headers;
819
+ if (headers) {
820
+ response.encryptionContext = headers.get("x-ms-encryption-context");
821
+ if (response._response.parsedHeaders) {
822
+ response._response.parsedHeaders.encryptionContext = response.encryptionContext;
823
+ }
824
+ }
825
+ }
826
+ return response;
827
+ }
803
828
 
804
829
  /**
805
830
  * StorageSharedKeyCredentialPolicy is a policy used to sign HTTP request with a shared key.
@@ -1310,6 +1335,13 @@ const Path$1 = {
1310
1335
  type: {
1311
1336
  name: "String"
1312
1337
  }
1338
+ },
1339
+ encryptionContext: {
1340
+ serializedName: "EncryptionContext",
1341
+ xmlName: "EncryptionContext",
1342
+ type: {
1343
+ name: "String"
1344
+ }
1313
1345
  }
1314
1346
  }
1315
1347
  }
@@ -3673,7 +3705,7 @@ const timeout = {
3673
3705
  const version = {
3674
3706
  parameterPath: "version",
3675
3707
  mapper: {
3676
- defaultValue: "2021-12-02",
3708
+ defaultValue: "2022-11-02",
3677
3709
  isConstant: true,
3678
3710
  serializedName: "x-ms-version",
3679
3711
  type: {
@@ -4143,6 +4175,16 @@ const expiresOn = {
4143
4175
  }
4144
4176
  }
4145
4177
  };
4178
+ const encryptionContext = {
4179
+ parameterPath: ["options", "encryptionContext"],
4180
+ mapper: {
4181
+ serializedName: "x-ms-encryption-context",
4182
+ xmlName: "x-ms-encryption-context",
4183
+ type: {
4184
+ name: "String"
4185
+ }
4186
+ }
4187
+ };
4146
4188
  const contentType1 = {
4147
4189
  parameterPath: ["options", "contentType"],
4148
4190
  mapper: {
@@ -4991,7 +5033,8 @@ const createOperationSpec = {
4991
5033
  proposedLeaseId,
4992
5034
  leaseDuration,
4993
5035
  expiryOptions,
4994
- expiresOn
5036
+ expiresOn,
5037
+ encryptionContext
4995
5038
  ],
4996
5039
  serializer
4997
5040
  };
@@ -5864,7 +5907,7 @@ class StorageClientContext extends coreHttp__namespace.ServiceClient {
5864
5907
  // Parameter assignments
5865
5908
  this.url = url;
5866
5909
  // Assigning values to Constant parameters
5867
- this.version = options.version || "2021-12-02";
5910
+ this.version = options.version || "2022-11-02";
5868
5911
  this.resource = options.resource || "filesystem";
5869
5912
  }
5870
5913
  }
@@ -8526,7 +8569,8 @@ class DataLakePathClient extends StorageClient {
8526
8569
  async getProperties(options = {}) {
8527
8570
  const { span, updatedOptions } = createSpan("DataLakePathClient-getProperties", options);
8528
8571
  try {
8529
- return await this.blobClient.getProperties(Object.assign(Object.assign({}, options), { customerProvidedKey: toBlobCpkInfo(options.customerProvidedKey), tracingOptions: updatedOptions.tracingOptions }));
8572
+ const response = (await this.blobClient.getProperties(Object.assign(Object.assign({}, options), { customerProvidedKey: toBlobCpkInfo(options.customerProvidedKey), tracingOptions: updatedOptions.tracingOptions })));
8573
+ return ParseEncryptionContextHeaderValue(response);
8530
8574
  }
8531
8575
  catch (e) {
8532
8576
  span.setStatus({
@@ -8707,7 +8751,7 @@ class DataLakeDirectoryClient extends DataLakePathClient {
8707
8751
  * @param subdirectoryName - Subdirectory name.
8708
8752
  */
8709
8753
  getSubdirectoryClient(subdirectoryName) {
8710
- return new DataLakeDirectoryClient(appendToURLPath(this.url, encodeURIComponent(subdirectoryName)), this.pipeline);
8754
+ return new DataLakeDirectoryClient(appendToURLPath(this.url, EscapePath(subdirectoryName)), this.pipeline);
8711
8755
  }
8712
8756
  /**
8713
8757
  * Creates a {@link DataLakeFileClient} object under current directory.
@@ -8717,7 +8761,7 @@ class DataLakeDirectoryClient extends DataLakePathClient {
8717
8761
  // Legacy, no way to fix the eslint error without breaking. Disable the rule for this line.
8718
8762
  /* eslint-disable-next-line @azure/azure-sdk/ts-naming-subclients */
8719
8763
  getFileClient(fileName) {
8720
- return new DataLakeFileClient(appendToURLPath(this.url, encodeURIComponent(fileName)), this.pipeline);
8764
+ return new DataLakeFileClient(appendToURLPath(this.url, EscapePath(fileName)), this.pipeline);
8721
8765
  }
8722
8766
  /**
8723
8767
  * Only available for clients constructed with a shared key credential.
@@ -8870,7 +8914,7 @@ class DataLakeFileClient extends DataLakePathClient {
8870
8914
  const { span, updatedOptions } = createSpan("DataLakeFileClient-read", options);
8871
8915
  try {
8872
8916
  const rawResponse = await this.blockBlobClientInternal.download(offset, count, Object.assign(Object.assign({}, updatedOptions), { customerProvidedKey: toBlobCpkInfo(updatedOptions.customerProvidedKey) }));
8873
- const response = rawResponse;
8917
+ const response = ParseEncryptionContextHeaderValue(rawResponse);
8874
8918
  if (!coreHttp.isNode && !response.contentAsBlob) {
8875
8919
  response.contentAsBlob = rawResponse.blobBody;
8876
8920
  }
@@ -8912,7 +8956,7 @@ class DataLakeFileClient extends DataLakePathClient {
8912
8956
  contentMD5: options.transactionalContentMD5,
8913
8957
  }, abortSignal: options.abortSignal, position: offset, contentLength: length, leaseAccessConditions: options.conditions, requestOptions: {
8914
8958
  onUploadProgress: options.onProgress,
8915
- }, cpkInfo: options.customerProvidedKey, flush: options.flush, proposedLeaseId: options.proposedLeaseId, leaseDuration: options.leaseDuration, leaseAction: options.leaseAction }, convertTracingToRequestOptionsBase(updatedOptions)));
8959
+ }, cpkInfo: options.customerProvidedKey, flush: options.flush, proposedLeaseId: options.proposedLeaseId, leaseDuration: options.leaseDurationInSeconds, leaseAction: options.leaseAction }, convertTracingToRequestOptionsBase(updatedOptions)));
8916
8960
  }
8917
8961
  catch (e) {
8918
8962
  span.setStatus({
@@ -8942,7 +8986,7 @@ class DataLakeFileClient extends DataLakePathClient {
8942
8986
  const { span, updatedOptions } = createSpan("DataLakeFileClient-flush", options);
8943
8987
  try {
8944
8988
  ensureCpkIfSpecified(options.customerProvidedKey, this.isHttps);
8945
- return await this.pathContextInternal.flushData(Object.assign(Object.assign(Object.assign({}, options), { position, contentLength: 0, leaseAccessConditions: options.conditions, modifiedAccessConditions: options.conditions, cpkInfo: options.customerProvidedKey, proposedLeaseId: options.proposedLeaseId, leaseDuration: options.leaseDuration, leaseAction: options.leaseAction }), convertTracingToRequestOptionsBase(updatedOptions)));
8989
+ return await this.pathContextInternal.flushData(Object.assign(Object.assign(Object.assign({}, options), { position, contentLength: 0, leaseAccessConditions: options.conditions, modifiedAccessConditions: options.conditions, cpkInfo: options.customerProvidedKey, proposedLeaseId: options.proposedLeaseId, leaseDuration: options.leaseDurationInSeconds, leaseAction: options.leaseAction }), convertTracingToRequestOptionsBase(updatedOptions)));
8946
8990
  }
8947
8991
  catch (e) {
8948
8992
  span.setStatus({
@@ -9046,6 +9090,7 @@ class DataLakeFileClient extends DataLakePathClient {
9046
9090
  pathHttpHeaders: options.pathHttpHeaders,
9047
9091
  customerProvidedKey: updatedOptions.customerProvidedKey,
9048
9092
  tracingOptions: updatedOptions.tracingOptions,
9093
+ encryptionContext: updatedOptions.encryptionContext,
9049
9094
  });
9050
9095
  // append() with empty data would return error, so do not continue
9051
9096
  if (size === 0) {
@@ -9170,6 +9215,7 @@ class DataLakeFileClient extends DataLakePathClient {
9170
9215
  pathHttpHeaders: options.pathHttpHeaders,
9171
9216
  customerProvidedKey: options.customerProvidedKey,
9172
9217
  tracingOptions: updatedOptions.tracingOptions,
9218
+ encryptionContext: updatedOptions.encryptionContext,
9173
9219
  });
9174
9220
  // After the File is Create, Lease ID is the only valid request parameter.
9175
9221
  options.conditions = { leaseId: (_a = options.conditions) === null || _a === void 0 ? void 0 : _a.leaseId };