@azure/container-registry 1.0.0-beta.6 → 1.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/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Release History
2
2
 
3
+ ## 1.0.0 (2022-01-11)
4
+
5
+ This release marks the general availability release of Azure Container Registry client SDK library.
6
+
7
+ ### Breaking Changes
8
+
9
+ - `TagOrderBy` is renamed to `ArtifactTagOrder`.
10
+ - `ManifestOrderBy` is renamed to `ArtifactManifestOrder`.
11
+ - `size` property in `ArtifactManifestProperties` is renamed to `sizeInBytes`.
12
+
3
13
  ## 1.0.0-beta.6 (2021-11-09)
4
14
 
5
15
  ### Features Added
package/README.md CHANGED
@@ -219,9 +219,9 @@ async function main() {
219
219
  const repositoryNames = client.listRepositoryNames();
220
220
  for await (const repositoryName of repositoryNames) {
221
221
  const repository = client.getRepository(repositoryName);
222
- // Obtain the images ordered from newest to oldest by passing the `orderBy` option
222
+ // Obtain the images ordered from newest to oldest by passing the `order` option
223
223
  const imageManifests = repository.listManifestProperties({
224
- orderBy: "LastUpdatedOnDescending"
224
+ order: "LastUpdatedOnDescending"
225
225
  });
226
226
  const imagesToKeep = 3;
227
227
  let imageCount = 0;
package/dist/index.js CHANGED
@@ -3214,7 +3214,7 @@ class GeneratedClientContext extends coreClient.ServiceClient {
3214
3214
  const defaults = {
3215
3215
  requestContentType: "application/json; charset=utf-8"
3216
3216
  };
3217
- const packageDetails = `azsdk-js-container-registry/1.0.0-beta.6`;
3217
+ const packageDetails = `azsdk-js-container-registry/1.0.0`;
3218
3218
  const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
3219
3219
  ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`
3220
3220
  : `${packageDetails}`;
@@ -3262,7 +3262,7 @@ class GeneratedClient extends GeneratedClientContext {
3262
3262
  */
3263
3263
  const createSpan = coreTracing.createSpanFunction({
3264
3264
  namespace: "Azure.Containers",
3265
- packagePrefix: "Azure.Containers.ContainerRegistry"
3265
+ packagePrefix: "Azure.Containers.ContainerRegistry",
3266
3266
  });
3267
3267
 
3268
3268
  // Copyright (c) Microsoft Corporation.
@@ -3315,7 +3315,7 @@ function delay(t, value) {
3315
3315
  const DEFAULT_CYCLER_OPTIONS = {
3316
3316
  forcedRefreshWindowInMs: 1000,
3317
3317
  retryIntervalInMs: 3000,
3318
- refreshWindowInMs: 1000 * 60 * 2 // Start refreshing 2m before expiry
3318
+ refreshWindowInMs: 1000 * 60 * 2, // Start refreshing 2m before expiry
3319
3319
  };
3320
3320
  /**
3321
3321
  * Converts an an unreliable access token getter (which may resolve with null)
@@ -3399,7 +3399,7 @@ function createTokenCycler(credential, tokenCyclerOptions) {
3399
3399
  */
3400
3400
  get mustRefresh() {
3401
3401
  return (token === null || token.expiresOnTimestamp - options.forcedRefreshWindowInMs < Date.now());
3402
- }
3402
+ },
3403
3403
  };
3404
3404
  /**
3405
3405
  * Starts a refresh job or returns the existing job if one is already
@@ -3451,7 +3451,7 @@ function createTokenCycler(credential, tokenCyclerOptions) {
3451
3451
  refresh(scopes, tokenOptions);
3452
3452
  }
3453
3453
  return token;
3454
- }
3454
+ },
3455
3455
  };
3456
3456
  }
3457
3457
 
@@ -3480,7 +3480,7 @@ class ChallengeHandler {
3480
3480
  this.credential = credential;
3481
3481
  this.options = options;
3482
3482
  this.cycler = createTokenCycler(credential, {
3483
- refreshWindowInMs: fiveMinutesInMs
3483
+ refreshWindowInMs: fiveMinutesInMs,
3484
3484
  });
3485
3485
  }
3486
3486
  authorizeRequest(_options) {
@@ -3534,14 +3534,14 @@ function toManifestWritableProperties(from) {
3534
3534
  canDelete: from.canDelete,
3535
3535
  canList: from.canList,
3536
3536
  canRead: from.canRead,
3537
- canWrite: from.canWrite
3537
+ canWrite: from.canWrite,
3538
3538
  }
3539
3539
  : undefined;
3540
3540
  }
3541
3541
  function toArtifactManifestProperties(from, repositoryName, registryLoginServer) {
3542
3542
  var _a, _b, _c, _d;
3543
3543
  return Object.assign({ registryLoginServer,
3544
- repositoryName, digest: from.digest, size: from.size, createdOn: from.createdOn, lastUpdatedOn: from.lastUpdatedOn, architecture: (_a = from.architecture) !== null && _a !== void 0 ? _a : undefined, operatingSystem: (_b = from.operatingSystem) !== null && _b !== void 0 ? _b : undefined, relatedArtifacts: (_c = from.relatedArtifacts) !== null && _c !== void 0 ? _c : [], tags: (_d = from.tags) !== null && _d !== void 0 ? _d : [] }, toManifestWritableProperties(from));
3544
+ repositoryName, digest: from.digest, sizeInBytes: from.size, createdOn: from.createdOn, lastUpdatedOn: from.lastUpdatedOn, architecture: (_a = from.architecture) !== null && _a !== void 0 ? _a : undefined, operatingSystem: (_b = from.operatingSystem) !== null && _b !== void 0 ? _b : undefined, relatedArtifacts: (_c = from.relatedArtifacts) !== null && _c !== void 0 ? _c : [], tags: (_d = from.tags) !== null && _d !== void 0 ? _d : [] }, toManifestWritableProperties(from));
3545
3545
  }
3546
3546
  function toServiceTagOrderBy(orderBy) {
3547
3547
  return orderBy === "LastUpdatedOnAscending"
@@ -3678,7 +3678,7 @@ class RegistryArtifactImpl {
3678
3678
  canDelete: options.canDelete,
3679
3679
  canWrite: options.canWrite,
3680
3680
  canList: options.canList,
3681
- canRead: options.canRead
3681
+ canRead: options.canRead,
3682
3682
  } }));
3683
3683
  try {
3684
3684
  const result = await this.client.containerRegistry.updateManifestProperties(this.repositoryName, await this.getDigest(), updatedOptions);
@@ -3739,7 +3739,7 @@ class RegistryArtifactImpl {
3739
3739
  canDelete: options.canDelete,
3740
3740
  canWrite: options.canWrite,
3741
3741
  canList: options.canList,
3742
- canRead: options.canRead
3742
+ canRead: options.canRead,
3743
3743
  } }));
3744
3744
  try {
3745
3745
  return await this.client.containerRegistry.updateTagAttributes(this.repositoryName, tag, updatedOptions);
@@ -3804,7 +3804,7 @@ class RegistryArtifactImpl {
3804
3804
  [Symbol.asyncIterator]() {
3805
3805
  return this;
3806
3806
  },
3807
- byPage: (settings = {}) => this.listTagsPage(settings, options)
3807
+ byPage: (settings = {}) => this.listTagsPage(settings, options),
3808
3808
  };
3809
3809
  }
3810
3810
  listTagsItems(options = {}) {
@@ -3827,7 +3827,7 @@ class RegistryArtifactImpl {
3827
3827
  }
3828
3828
  listTagsPage(continuationState, options = {}) {
3829
3829
  return tslib.__asyncGenerator(this, arguments, function* listTagsPage_1() {
3830
- const orderby = toServiceTagOrderBy(options.orderBy);
3830
+ const orderby = toServiceTagOrderBy(options.order);
3831
3831
  if (!continuationState.continuationToken) {
3832
3832
  const optionsComplete = Object.assign(Object.assign({}, options), { n: continuationState.maxPageSize, orderby });
3833
3833
  const currentPage = yield tslib.__await(this.client.containerRegistry.getTags(this.repositoryName, optionsComplete));
@@ -3838,7 +3838,7 @@ class RegistryArtifactImpl {
3838
3838
  });
3839
3839
  yield yield tslib.__await(Object.defineProperty(array, "continuationToken", {
3840
3840
  value: continuationState.continuationToken,
3841
- enumerable: true
3841
+ enumerable: true,
3842
3842
  }));
3843
3843
  }
3844
3844
  }
@@ -3851,7 +3851,7 @@ class RegistryArtifactImpl {
3851
3851
  });
3852
3852
  yield yield tslib.__await(Object.defineProperty(array, "continuationToken", {
3853
3853
  value: continuationState.continuationToken,
3854
- enumerable: true
3854
+ enumerable: true,
3855
3855
  }));
3856
3856
  }
3857
3857
  }
@@ -3943,7 +3943,7 @@ class ContainerRepositoryImpl {
3943
3943
  canDelete: options.canDelete,
3944
3944
  canWrite: options.canWrite,
3945
3945
  canList: options.canList,
3946
- canRead: options.canRead
3946
+ canRead: options.canRead,
3947
3947
  };
3948
3948
  const { span, updatedOptions } = createSpan("ContainerRepository-updateProperties", Object.assign(Object.assign({}, options), { value }));
3949
3949
  try {
@@ -4010,7 +4010,7 @@ class ContainerRepositoryImpl {
4010
4010
  [Symbol.asyncIterator]() {
4011
4011
  return this;
4012
4012
  },
4013
- byPage: (settings = {}) => this.listManifestsPage(settings, options)
4013
+ byPage: (settings = {}) => this.listManifestsPage(settings, options),
4014
4014
  };
4015
4015
  }
4016
4016
  listManifestsItems(options = {}) {
@@ -4033,7 +4033,7 @@ class ContainerRepositoryImpl {
4033
4033
  }
4034
4034
  listManifestsPage(continuationState, options = {}) {
4035
4035
  return tslib.__asyncGenerator(this, arguments, function* listManifestsPage_1() {
4036
- const orderby = toServiceManifestOrderBy(options.orderBy);
4036
+ const orderby = toServiceManifestOrderBy(options.order);
4037
4037
  if (!continuationState.continuationToken) {
4038
4038
  const optionsComplete = Object.assign(Object.assign({}, options), { n: continuationState.maxPageSize, orderby });
4039
4039
  const currentPage = yield tslib.__await(this.client.containerRegistry.getManifests(this.name, optionsComplete));
@@ -4042,7 +4042,7 @@ class ContainerRepositoryImpl {
4042
4042
  const array = currentPage.manifests.map((t) => toArtifactManifestProperties(t, this.name, currentPage.registryLoginServer));
4043
4043
  yield yield tslib.__await(Object.defineProperty(array, "continuationToken", {
4044
4044
  value: continuationState.continuationToken,
4045
- enumerable: true
4045
+ enumerable: true,
4046
4046
  }));
4047
4047
  }
4048
4048
  }
@@ -4053,7 +4053,7 @@ class ContainerRepositoryImpl {
4053
4053
  const array = currentPage.manifests.map((t) => toArtifactManifestProperties(t, this.name, currentPage.registryLoginServer));
4054
4054
  yield yield tslib.__await(Object.defineProperty(array, "continuationToken", {
4055
4055
  value: continuationState.continuationToken,
4056
- enumerable: true
4056
+ enumerable: true,
4057
4057
  }));
4058
4058
  }
4059
4059
  }
@@ -4093,74 +4093,12 @@ class ContainerRegistryRefreshTokenCredential {
4093
4093
  return this.tokenService.ExchangeAadAccessTokenForAcrRefreshTokenAsync(aadToken.token, options.service, options);
4094
4094
  }
4095
4095
  }
4096
- const customExchangeAadTokenForAcrRefreshTokenOperationSpec = {
4097
- path: "/oauth2/exchange",
4098
- httpMethod: "POST",
4099
- responses: {
4100
- 200: {
4101
- bodyMapper: AcrRefreshToken
4102
- },
4103
- default: {
4104
- bodyMapper: AcrErrors
4105
- }
4106
- },
4107
- // formDataParameters: [Parameters.aadAccesstoken],
4108
- requestBody: {
4109
- parameterPath: ["options", "payload"],
4110
- mapper: {
4111
- type: {
4112
- name: "Stream"
4113
- }
4114
- }
4115
- },
4116
- urlParameters: [url],
4117
- headerParameters: [contentType3, accept4],
4118
- serializer: coreClient.createSerializer(Mappers, /* isXml */ false)
4119
- };
4120
- const customExchangeAcrRefreshTokenForAcrAccessTokenOperationSpec = {
4121
- path: "/oauth2/token",
4122
- httpMethod: "POST",
4123
- responses: {
4124
- 200: {
4125
- bodyMapper: AcrAccessToken
4126
- },
4127
- default: {
4128
- bodyMapper: AcrErrors
4129
- }
4130
- },
4131
- // formDataParameters: [Parameters.acrRefreshToken],
4132
- requestBody: {
4133
- parameterPath: ["options", "payload"],
4134
- mapper: {
4135
- type: {
4136
- name: "Stream"
4137
- }
4138
- }
4139
- },
4140
- urlParameters: [url],
4141
- headerParameters: [contentType3, accept4],
4142
- serializer: coreClient.createSerializer(Mappers, /* isXml */ false)
4143
- };
4144
4096
  class ContainerRegistryTokenService {
4145
4097
  constructor(authClient) {
4146
4098
  this.authClient = authClient;
4147
4099
  }
4148
4100
  async ExchangeAadAccessTokenForAcrRefreshTokenAsync(aadAccessToken, service, options) {
4149
- // const acrRefreshToken = await this.authClient.authentication.exchangeAadTokenForAcrRefreshToken(
4150
- // {
4151
- // aadAccesstoken: {
4152
- // grantType: "access_token",
4153
- // service,
4154
- // aadAccesstoken: aadAccessToken,
4155
- // }
4156
- // }
4157
- // );
4158
- // TODO: (jeremymeng) revert custom sendOperationRequest call after FormData is working in core
4159
- const payload = `grant_type=access_token&service=${encodeURIComponent(service)}&access_token=${encodeURIComponent(aadAccessToken)}`;
4160
- const customOptions = {
4161
- payload
4162
- };
4163
- const acrRefreshToken = await this.authClient.sendOperationRequest({ options: Object.assign(Object.assign({}, options), customOptions) }, customExchangeAadTokenForAcrRefreshTokenOperationSpec);
4101
+ const acrRefreshToken = await this.authClient.authentication.exchangeAadAccessTokenForAcrRefreshToken("access_token", service, Object.assign(Object.assign({}, options), { accessToken: aadAccessToken }));
4164
4102
  if (!acrRefreshToken.refreshToken) {
4165
4103
  throw new Error("Failed to exchange AAD access token for an ACR refresh token.");
4166
4104
  }
@@ -4180,26 +4118,11 @@ class ContainerRegistryTokenService {
4180
4118
  const expiry = Number.parseInt(jwtPayload.exp) * 1000;
4181
4119
  return {
4182
4120
  token: acrRefreshToken.refreshToken,
4183
- expiresOnTimestamp: expiry
4121
+ expiresOnTimestamp: expiry,
4184
4122
  };
4185
4123
  }
4186
4124
  async ExchangeAcrRefreshTokenForAcrAccessTokenAsync(acrRefreshToken, service, scope, grantType, options) {
4187
- // const acrAccessToken = await this.authClient.authentication.exchangeAcrRefreshTokenForAcrAccessToken(
4188
- // {
4189
- // acrRefreshToken: {
4190
- // grantType: "refresh_token",
4191
- // acrRefreshToken,
4192
- // service,
4193
- // scope
4194
- // }
4195
- // }
4196
- // );
4197
- // TODO: (jeremymeng) revert custom sendOperationRequest call after FormData is working in core
4198
- const payload = `grant_type=${grantType}&service=${encodeURIComponent(service)}&refresh_token=${acrRefreshToken ? encodeURIComponent(acrRefreshToken) : ""}&scope=${encodeURIComponent(scope)}`;
4199
- const customOptions = {
4200
- payload
4201
- };
4202
- const acrAccessToken = await this.authClient.sendOperationRequest({ options: Object.assign(Object.assign({}, options), customOptions) }, customExchangeAcrRefreshTokenForAcrAccessTokenOperationSpec);
4125
+ const acrAccessToken = await this.authClient.authentication.exchangeAcrRefreshTokenForAcrAccessToken(service, scope, acrRefreshToken, grantType, options);
4203
4126
  if (!acrAccessToken.accessToken) {
4204
4127
  throw new Error("Failed to exchange ACR refresh token for an ACR access token");
4205
4128
  }
@@ -4232,7 +4155,7 @@ class ContainerRegistryClient {
4232
4155
  logger: logger.info,
4233
4156
  // This array contains header names we want to log that are not already
4234
4157
  // included as safe. Unknown/unsafe headers are logged as "<REDACTED>".
4235
- additionalAllowedQueryParameters: ["last", "n", "orderby", "digest"]
4158
+ additionalAllowedQueryParameters: ["last", "n", "orderby", "digest"],
4236
4159
  } });
4237
4160
  // Require audience now until we have a default ACR audience from the service.
4238
4161
  if (!options.audience) {
@@ -4245,7 +4168,7 @@ class ContainerRegistryClient {
4245
4168
  this.client.pipeline.addPolicy(coreRestPipeline.bearerTokenAuthenticationPolicy({
4246
4169
  credential,
4247
4170
  scopes: [defaultScope],
4248
- challengeCallbacks: new ChallengeHandler(new ContainerRegistryRefreshTokenCredential(authClient, defaultScope, credential))
4171
+ challengeCallbacks: new ChallengeHandler(new ContainerRegistryRefreshTokenCredential(authClient, defaultScope, credential)),
4249
4172
  }));
4250
4173
  }
4251
4174
  /**
@@ -4345,7 +4268,7 @@ class ContainerRegistryClient {
4345
4268
  [Symbol.asyncIterator]() {
4346
4269
  return this;
4347
4270
  },
4348
- byPage: (settings = {}) => this.listRepositoriesPage(settings, options)
4271
+ byPage: (settings = {}) => this.listRepositoriesPage(settings, options),
4349
4272
  };
4350
4273
  }
4351
4274
  listRepositoryItems(options = {}) {
@@ -4376,7 +4299,7 @@ class ContainerRegistryClient {
4376
4299
  const array = currentPage.repositories;
4377
4300
  yield yield tslib.__await(Object.defineProperty(array, "continuationToken", {
4378
4301
  value: continuationState.continuationToken,
4379
- enumerable: true
4302
+ enumerable: true,
4380
4303
  }));
4381
4304
  }
4382
4305
  }
@@ -4387,7 +4310,7 @@ class ContainerRegistryClient {
4387
4310
  const array = currentPage.repositories;
4388
4311
  yield yield tslib.__await(Object.defineProperty(array, "continuationToken", {
4389
4312
  value: continuationState.continuationToken,
4390
- enumerable: true
4313
+ enumerable: true,
4391
4314
  }));
4392
4315
  }
4393
4316
  }