@azure/container-registry 1.1.1-alpha.20250619.1 → 1.1.1-alpha.20250730.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.
Files changed (130) hide show
  1. package/dist/browser/containerRegistryChallengeHandler.js +6 -3
  2. package/dist/browser/containerRegistryChallengeHandler.js.map +1 -1
  3. package/dist/browser/containerRegistryClient.js +42 -50
  4. package/dist/browser/containerRegistryClient.js.map +1 -1
  5. package/dist/browser/containerRegistryTokenCredential.js +9 -1
  6. package/dist/browser/containerRegistryTokenCredential.js.map +1 -1
  7. package/dist/browser/containerRepository.js +41 -46
  8. package/dist/browser/containerRepository.js.map +1 -1
  9. package/dist/browser/content/containerRegistryContentClient.js +34 -32
  10. package/dist/browser/content/containerRegistryContentClient.js.map +1 -1
  11. package/dist/browser/generated/generatedClient.js +12 -3
  12. package/dist/browser/generated/generatedClient.js.map +1 -1
  13. package/dist/browser/generated/generatedClientContext.js +9 -2
  14. package/dist/browser/generated/generatedClientContext.js.map +1 -1
  15. package/dist/browser/generated/models/mappers.js +63 -29
  16. package/dist/browser/generated/models/mappers.js.map +1 -1
  17. package/dist/browser/generated/operations/authentication.js +1 -0
  18. package/dist/browser/generated/operations/authentication.js.map +1 -1
  19. package/dist/browser/generated/operations/containerRegistry.js +1 -0
  20. package/dist/browser/generated/operations/containerRegistry.js.map +1 -1
  21. package/dist/browser/generated/operations/containerRegistryBlob.js +1 -0
  22. package/dist/browser/generated/operations/containerRegistryBlob.js.map +1 -1
  23. package/dist/browser/registryArtifact.js +69 -53
  24. package/dist/browser/registryArtifact.js.map +1 -1
  25. package/dist/browser/transformations.js +13 -3
  26. package/dist/browser/transformations.js.map +1 -1
  27. package/dist/browser/utils/helpers.js +19 -35
  28. package/dist/browser/utils/helpers.js.map +1 -1
  29. package/dist/browser/utils/retriableReadableStream.js +64 -56
  30. package/dist/browser/utils/retriableReadableStream.js.map +1 -1
  31. package/dist/browser/utils/tokenCycler.js +7 -6
  32. package/dist/browser/utils/tokenCycler.js.map +1 -1
  33. package/dist/commonjs/containerRegistryChallengeHandler.js +6 -3
  34. package/dist/commonjs/containerRegistryChallengeHandler.js.map +1 -1
  35. package/dist/commonjs/containerRegistryClient.js +42 -50
  36. package/dist/commonjs/containerRegistryClient.js.map +1 -1
  37. package/dist/commonjs/containerRegistryTokenCredential.js +9 -1
  38. package/dist/commonjs/containerRegistryTokenCredential.js.map +1 -1
  39. package/dist/commonjs/containerRepository.js +41 -46
  40. package/dist/commonjs/containerRepository.js.map +1 -1
  41. package/dist/commonjs/content/containerRegistryContentClient.js +34 -31
  42. package/dist/commonjs/content/containerRegistryContentClient.js.map +1 -1
  43. package/dist/commonjs/generated/generatedClient.js +12 -3
  44. package/dist/commonjs/generated/generatedClient.js.map +1 -1
  45. package/dist/commonjs/generated/generatedClientContext.js +9 -2
  46. package/dist/commonjs/generated/generatedClientContext.js.map +1 -1
  47. package/dist/commonjs/generated/models/mappers.js +63 -29
  48. package/dist/commonjs/generated/models/mappers.js.map +1 -1
  49. package/dist/commonjs/generated/operations/authentication.js +1 -0
  50. package/dist/commonjs/generated/operations/authentication.js.map +1 -1
  51. package/dist/commonjs/generated/operations/containerRegistry.js +1 -0
  52. package/dist/commonjs/generated/operations/containerRegistry.js.map +1 -1
  53. package/dist/commonjs/generated/operations/containerRegistryBlob.js +1 -0
  54. package/dist/commonjs/generated/operations/containerRegistryBlob.js.map +1 -1
  55. package/dist/commonjs/registryArtifact.js +69 -53
  56. package/dist/commonjs/registryArtifact.js.map +1 -1
  57. package/dist/commonjs/transformations.js +13 -3
  58. package/dist/commonjs/transformations.js.map +1 -1
  59. package/dist/commonjs/tsdoc-metadata.json +11 -11
  60. package/dist/commonjs/utils/helpers.js +19 -35
  61. package/dist/commonjs/utils/helpers.js.map +1 -1
  62. package/dist/commonjs/utils/retriableReadableStream.js +64 -56
  63. package/dist/commonjs/utils/retriableReadableStream.js.map +1 -1
  64. package/dist/commonjs/utils/tokenCycler.js +7 -6
  65. package/dist/commonjs/utils/tokenCycler.js.map +1 -1
  66. package/dist/esm/containerRegistryChallengeHandler.js +6 -3
  67. package/dist/esm/containerRegistryChallengeHandler.js.map +1 -1
  68. package/dist/esm/containerRegistryClient.js +42 -50
  69. package/dist/esm/containerRegistryClient.js.map +1 -1
  70. package/dist/esm/containerRegistryTokenCredential.js +9 -1
  71. package/dist/esm/containerRegistryTokenCredential.js.map +1 -1
  72. package/dist/esm/containerRepository.js +41 -46
  73. package/dist/esm/containerRepository.js.map +1 -1
  74. package/dist/esm/content/containerRegistryContentClient.js +34 -32
  75. package/dist/esm/content/containerRegistryContentClient.js.map +1 -1
  76. package/dist/esm/generated/generatedClient.js +12 -3
  77. package/dist/esm/generated/generatedClient.js.map +1 -1
  78. package/dist/esm/generated/generatedClientContext.js +9 -2
  79. package/dist/esm/generated/generatedClientContext.js.map +1 -1
  80. package/dist/esm/generated/models/mappers.js +63 -29
  81. package/dist/esm/generated/models/mappers.js.map +1 -1
  82. package/dist/esm/generated/operations/authentication.js +1 -0
  83. package/dist/esm/generated/operations/authentication.js.map +1 -1
  84. package/dist/esm/generated/operations/containerRegistry.js +1 -0
  85. package/dist/esm/generated/operations/containerRegistry.js.map +1 -1
  86. package/dist/esm/generated/operations/containerRegistryBlob.js +1 -0
  87. package/dist/esm/generated/operations/containerRegistryBlob.js.map +1 -1
  88. package/dist/esm/registryArtifact.js +69 -53
  89. package/dist/esm/registryArtifact.js.map +1 -1
  90. package/dist/esm/transformations.js +13 -3
  91. package/dist/esm/transformations.js.map +1 -1
  92. package/dist/esm/utils/helpers.js +19 -35
  93. package/dist/esm/utils/helpers.js.map +1 -1
  94. package/dist/esm/utils/retriableReadableStream.js +64 -56
  95. package/dist/esm/utils/retriableReadableStream.js.map +1 -1
  96. package/dist/esm/utils/tokenCycler.js +7 -6
  97. package/dist/esm/utils/tokenCycler.js.map +1 -1
  98. package/dist/react-native/containerRegistryChallengeHandler.js +6 -3
  99. package/dist/react-native/containerRegistryChallengeHandler.js.map +1 -1
  100. package/dist/react-native/containerRegistryClient.js +42 -50
  101. package/dist/react-native/containerRegistryClient.js.map +1 -1
  102. package/dist/react-native/containerRegistryTokenCredential.js +9 -1
  103. package/dist/react-native/containerRegistryTokenCredential.js.map +1 -1
  104. package/dist/react-native/containerRepository.js +41 -46
  105. package/dist/react-native/containerRepository.js.map +1 -1
  106. package/dist/react-native/content/containerRegistryContentClient.js +34 -32
  107. package/dist/react-native/content/containerRegistryContentClient.js.map +1 -1
  108. package/dist/react-native/generated/generatedClient.js +12 -3
  109. package/dist/react-native/generated/generatedClient.js.map +1 -1
  110. package/dist/react-native/generated/generatedClientContext.js +9 -2
  111. package/dist/react-native/generated/generatedClientContext.js.map +1 -1
  112. package/dist/react-native/generated/models/mappers.js +63 -29
  113. package/dist/react-native/generated/models/mappers.js.map +1 -1
  114. package/dist/react-native/generated/operations/authentication.js +1 -0
  115. package/dist/react-native/generated/operations/authentication.js.map +1 -1
  116. package/dist/react-native/generated/operations/containerRegistry.js +1 -0
  117. package/dist/react-native/generated/operations/containerRegistry.js.map +1 -1
  118. package/dist/react-native/generated/operations/containerRegistryBlob.js +1 -0
  119. package/dist/react-native/generated/operations/containerRegistryBlob.js.map +1 -1
  120. package/dist/react-native/registryArtifact.js +69 -53
  121. package/dist/react-native/registryArtifact.js.map +1 -1
  122. package/dist/react-native/transformations.js +13 -3
  123. package/dist/react-native/transformations.js.map +1 -1
  124. package/dist/react-native/utils/helpers.js +19 -35
  125. package/dist/react-native/utils/helpers.js.map +1 -1
  126. package/dist/react-native/utils/retriableReadableStream.js +64 -56
  127. package/dist/react-native/utils/retriableReadableStream.js.map +1 -1
  128. package/dist/react-native/utils/tokenCycler.js +7 -6
  129. package/dist/react-native/utils/tokenCycler.js.map +1 -1
  130. package/package.json +2 -2
@@ -1,6 +1,5 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
2
  // Licensed under the MIT License.
3
- import { __asyncValues } from "tslib";
4
3
  import { bearerTokenAuthenticationPolicy, RestError } from "@azure/core-rest-pipeline";
5
4
  import { GeneratedClient } from "../generated/index.js";
6
5
  import { ChallengeHandler } from "../containerRegistryChallengeHandler.js";
@@ -45,6 +44,15 @@ export class DigestMismatchError extends Error {
45
44
  * The Azure Container Registry blob client, responsible for uploading and downloading blobs and manifests, the building blocks of artifacts.
46
45
  */
47
46
  export class ContainerRegistryContentClient {
47
+ /**
48
+ * The Azure Container Registry endpoint.
49
+ */
50
+ endpoint;
51
+ /**
52
+ * The name of the repository that logically groups the artifact parts.
53
+ */
54
+ repositoryName;
55
+ client;
48
56
  /**
49
57
  * Creates an instance of a ContainerRegistryContentClient for managing container images and artifacts.
50
58
  *
@@ -67,13 +75,14 @@ export class ContainerRegistryContentClient {
67
75
  * @param options - optional configuration used to send requests to the service
68
76
  */
69
77
  constructor(endpoint, repositoryName, credential, options = {}) {
70
- var _a, _b;
71
78
  if (!endpoint) {
72
79
  throw new Error("invalid endpoint");
73
80
  }
74
81
  this.endpoint = endpoint;
75
82
  this.repositoryName = repositoryName;
76
- const internalPipelineOptions = Object.assign(Object.assign({}, options), { loggingOptions: {
83
+ const internalPipelineOptions = {
84
+ ...options,
85
+ loggingOptions: {
77
86
  logger: logger.info,
78
87
  // This array contains header names we want to log that are not already
79
88
  // included as safe. Unknown/unsafe headers are logged as "<REDACTED>".
@@ -85,9 +94,10 @@ export class ContainerRegistryContentClient {
85
94
  "_nouploadcache",
86
95
  "_state",
87
96
  ],
88
- } });
89
- const defaultScope = `${(_a = options.audience) !== null && _a !== void 0 ? _a : "https://containerregistry.azure.net"}/.default`;
90
- const serviceVersion = (_b = options.serviceVersion) !== null && _b !== void 0 ? _b : LATEST_API_VERSION;
97
+ },
98
+ };
99
+ const defaultScope = `${options.audience ?? "https://containerregistry.azure.net"}/.default`;
100
+ const serviceVersion = options.serviceVersion ?? LATEST_API_VERSION;
91
101
  const authClient = new GeneratedClient(endpoint, serviceVersion, internalPipelineOptions);
92
102
  this.client = new GeneratedClient(endpoint, serviceVersion, internalPipelineOptions);
93
103
  this.client.pipeline.addPolicy(bearerTokenAuthenticationPolicy({
@@ -113,22 +123,24 @@ export class ContainerRegistryContentClient {
113
123
  */
114
124
  async setManifest(manifest, options = {}) {
115
125
  return tracingClient.withSpan("ContainerRegistryContentClient.uploadManifest", options, async (updatedOptions) => {
116
- var _a;
117
126
  let manifestBody;
118
- let tagOrDigest = options === null || options === void 0 ? void 0 : options.tag;
127
+ let tagOrDigest = options?.tag;
119
128
  if (Buffer.isBuffer(manifest)) {
120
129
  manifestBody = manifest;
121
- tagOrDigest !== null && tagOrDigest !== void 0 ? tagOrDigest : (tagOrDigest = await calculateDigest(manifest));
130
+ tagOrDigest ??= await calculateDigest(manifest);
122
131
  }
123
132
  else if (isReadableStream(manifest)) {
124
133
  manifestBody = await readStreamToEnd(manifest);
125
- tagOrDigest !== null && tagOrDigest !== void 0 ? tagOrDigest : (tagOrDigest = await calculateDigest(manifestBody));
134
+ tagOrDigest ??= await calculateDigest(manifestBody);
126
135
  }
127
136
  else {
128
137
  manifestBody = Buffer.from(JSON.stringify(manifest));
129
- tagOrDigest !== null && tagOrDigest !== void 0 ? tagOrDigest : (tagOrDigest = await calculateDigest(manifestBody));
138
+ tagOrDigest ??= await calculateDigest(manifestBody);
130
139
  }
131
- const createManifestResult = await this.client.containerRegistry.createManifest(this.repositoryName, tagOrDigest, manifestBody, Object.assign({ contentType: (_a = options === null || options === void 0 ? void 0 : options.mediaType) !== null && _a !== void 0 ? _a : KnownManifestMediaType.OciImageManifest }, updatedOptions));
140
+ const createManifestResult = await this.client.containerRegistry.createManifest(this.repositoryName, tagOrDigest, manifestBody, {
141
+ contentType: options?.mediaType ?? KnownManifestMediaType.OciImageManifest,
142
+ ...updatedOptions,
143
+ });
132
144
  assertHasProperty(createManifestResult, "dockerContentDigest");
133
145
  return { digest: createManifestResult.dockerContentDigest };
134
146
  });
@@ -141,7 +153,10 @@ export class ContainerRegistryContentClient {
141
153
  */
142
154
  async getManifest(tagOrDigest, options = {}) {
143
155
  return tracingClient.withSpan("ContainerRegistryContentClient.downloadManifest", options, async (updatedOptions) => {
144
- const response = await this.client.containerRegistry.getManifest(this.repositoryName, tagOrDigest, Object.assign({ accept: ACCEPTED_MANIFEST_MEDIA_TYPES.join(", ") }, updatedOptions));
156
+ const response = await this.client.containerRegistry.getManifest(this.repositoryName, tagOrDigest, {
157
+ accept: ACCEPTED_MANIFEST_MEDIA_TYPES.join(", "),
158
+ ...updatedOptions,
159
+ });
145
160
  assertHasProperty(response, "mediaType");
146
161
  const content = response.readableStreamBody
147
162
  ? await readStreamToEnd(response.readableStreamBody, MAX_MANIFEST_SIZE_BYTES)
@@ -179,7 +194,6 @@ export class ContainerRegistryContentClient {
179
194
  */
180
195
  async uploadBlob(blob, options = {}) {
181
196
  return tracingClient.withSpan("ContainerRegistryContentClient.uploadBlob", options, async (updatedOptions) => {
182
- var _a, e_1, _b, _c;
183
197
  const blobStream = Buffer.isBuffer(blob) ? Readable.from(blob) : blob;
184
198
  const startUploadResult = await this.client.containerRegistryBlob.startUpload(this.repositoryName, updatedOptions);
185
199
  assertHasProperty(startUploadResult, "location");
@@ -187,24 +201,12 @@ export class ContainerRegistryContentClient {
187
201
  const chunks = readChunksFromStream(blobStream, CHUNK_SIZE);
188
202
  const hash = crypto.createHash("sha256");
189
203
  let bytesUploaded = 0;
190
- try {
191
- for (var _d = true, chunks_1 = __asyncValues(chunks), chunks_1_1; chunks_1_1 = await chunks_1.next(), _a = chunks_1_1.done, !_a; _d = true) {
192
- _c = chunks_1_1.value;
193
- _d = false;
194
- const chunk = _c;
195
- hash.write(chunk);
196
- const result = await this.client.containerRegistryBlob.uploadChunk(location, chunk, updatedOptions);
197
- bytesUploaded += chunk.byteLength;
198
- assertHasProperty(result, "location");
199
- location = result.location.substring(1);
200
- }
201
- }
202
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
203
- finally {
204
- try {
205
- if (!_d && !_a && (_b = chunks_1.return)) await _b.call(chunks_1);
206
- }
207
- finally { if (e_1) throw e_1.error; }
204
+ for await (const chunk of chunks) {
205
+ hash.write(chunk);
206
+ const result = await this.client.containerRegistryBlob.uploadChunk(location, chunk, updatedOptions);
207
+ bytesUploaded += chunk.byteLength;
208
+ assertHasProperty(result, "location");
209
+ location = result.location.substring(1);
208
210
  }
209
211
  hash.end();
210
212
  const digest = `sha256:${hash.digest("hex")}`;
@@ -1 +1 @@
1
- {"version":3,"file":"containerRegistryContentClient.js","sourceRoot":"","sources":["../../../src/content/containerRegistryContentClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AAGlC,OAAO,EAAE,+BAA+B,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAEvF,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAC3E,OAAO,EAAE,uCAAuC,EAAE,MAAM,wCAAwC,CAAC;AACjG,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAcrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAErD,OAAO,EAAE,QAAQ,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtF,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAE9E,MAAM,kBAAkB,GAAG,YAAY,CAAC;AAExC,MAAM,UAAU,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC,OAAO;AAC3C,MAAM,uBAAuB,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC,OAAO;AAExD,MAAM,6BAA6B,GAAG;IACpC,sBAA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,CAAC,CAAC;oBACvD,OAAO,aAAa,CAAC,kBAAkB,CAAC;gBAC1C,CAAC,EACD,CAAC,EACD,eAAe,CAAC,aAAa,EAC7B;oBACE,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;oBAClC,KAAK,EAAE,GAAG,EAAE;wBACV,IAAI,CAAC,GAAG,EAAE,CAAC;wBACX,MAAM,gBAAgB,GAAG,UAAU,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;wBAExD,IAAI,MAAM,KAAK,gBAAgB,EAAE,CAAC;4BAChC,MAAM,IAAI,mBAAmB,CAC3B,iFAAiF,CAClF,CAAC;wBACJ,CAAC;oBACH,CAAC;iBACF,CACF;aACF,CAAC;QACJ,CAAC,CACF,CAAC;IACJ,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { InternalPipelineOptions } from \"@azure/core-rest-pipeline\";\nimport { bearerTokenAuthenticationPolicy, RestError } from \"@azure/core-rest-pipeline\";\nimport type { TokenCredential } from \"@azure/core-auth\";\nimport { GeneratedClient } from \"../generated/index.js\";\nimport { ChallengeHandler } from \"../containerRegistryChallengeHandler.js\";\nimport { ContainerRegistryRefreshTokenCredential } from \"../containerRegistryTokenCredential.js\";\nimport { logger } from \"../logger.js\";\nimport { calculateDigest } from \"../utils/digest.js\";\nimport type {\n DeleteBlobOptions,\n DeleteManifestOptions,\n DownloadBlobOptions,\n DownloadBlobResult,\n GetManifestOptions,\n GetManifestResult,\n UploadBlobOptions,\n UploadBlobResult,\n SetManifestOptions,\n SetManifestResult,\n OciImageManifest,\n} from \"./models.js\";\nimport { KnownManifestMediaType } from \"./models.js\";\nimport type { CommonClientOptions } from \"@azure/core-client\";\nimport { isDigest, readChunksFromStream, readStreamToEnd } from \"../utils/helpers.js\";\nimport { Readable } from \"node:stream\";\nimport { tracingClient } from \"../tracing.js\";\nimport crypto from \"node:crypto\";\nimport { RetriableReadableStream } from \"../utils/retriableReadableStream.js\";\n\nconst LATEST_API_VERSION = \"2021-07-01\";\n\nconst CHUNK_SIZE = 4 * 1024 * 1024; // 4 MB\nconst MAX_MANIFEST_SIZE_BYTES = 4 * 1024 * 1024; // 4 MB\n\nconst ACCEPTED_MANIFEST_MEDIA_TYPES = [\n KnownManifestMediaType.OciImageManifest,\n KnownManifestMediaType.DockerManifest,\n \"application/vnd.oci.image.index.v1+json\",\n \"application/vnd.docker.distribution.manifest.list.v2+json\",\n \"application/vnd.docker.container.image.v1+json\",\n];\n\nfunction isReadableStream(body: any): body is NodeJS.ReadableStream {\n return body && typeof body.pipe === \"function\";\n}\n\nfunction assertHasProperty<T, U extends keyof T>(\n obj: T,\n property: U,\n): asserts obj is T & Required<Pick<T, U>> {\n if (!Object.prototype.hasOwnProperty.call(obj, property)) {\n throw new RestError(`Expected property ${String(property)} to be defined.`);\n }\n}\n\n/**\n * Error thrown when the Docker content digest returned from the\n * server does not match the digest calculated from the content.\n */\nexport class DigestMismatchError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"DigestMismatchError\";\n }\n}\n\n/**\n * Client options used to configure Container Registry Blob API requests.\n */\nexport interface ContainerRegistryContentClientOptions extends CommonClientOptions {\n /**\n * Gets or sets the audience to use for authentication with Azure Active Directory.\n * The authentication scope will be set from this audience.\n * See {@link KnownContainerRegistryAudience} for known audience values.\n */\n audience?: string;\n /**\n * The version of service API to make calls against.\n */\n serviceVersion?: \"2021-07-01\";\n}\n\n/**\n * The Azure Container Registry blob client, responsible for uploading and downloading blobs and manifests, the building blocks of artifacts.\n */\nexport class ContainerRegistryContentClient {\n /**\n * The Azure Container Registry endpoint.\n */\n public readonly endpoint: string;\n\n /**\n * The name of the repository that logically groups the artifact parts.\n */\n public readonly repositoryName: string;\n\n private client: GeneratedClient;\n\n /**\n * Creates an instance of a ContainerRegistryContentClient for managing container images and artifacts.\n *\n * Example usage:\n * ```ts snippet:SampleReadmeCreateContainerRegistryContentClient\n * import { ContainerRegistryContentClient } from \"@azure/container-registry\";\n * import { DefaultAzureCredential } from \"@azure/identity\";\n *\n * const endpoint = \"https://myregistryname.azurecr.io\";\n * const repository = \"library/hello-world\";\n * const client = new ContainerRegistryContentClient(\n * endpoint,\n * repository,\n * new DefaultAzureCredential(),\n * );\n * ```\n * @param endpoint - the URL endpoint of the container registry\n * @param repositoryName - the name of the repository that logically groups the artifact parts\n * @param credential - used to authenticate requests to the service\n * @param options - optional configuration used to send requests to the service\n */\n constructor(\n endpoint: string,\n repositoryName: string,\n credential: TokenCredential,\n options: ContainerRegistryContentClientOptions = {},\n ) {\n if (!endpoint) {\n throw new Error(\"invalid endpoint\");\n }\n\n this.endpoint = endpoint;\n this.repositoryName = repositoryName;\n\n const internalPipelineOptions: InternalPipelineOptions = {\n ...options,\n loggingOptions: {\n logger: logger.info,\n // This array contains header names we want to log that are not already\n // included as safe. Unknown/unsafe headers are logged as \"<REDACTED>\".\n additionalAllowedQueryParameters: [\n \"last\",\n \"n\",\n \"orderby\",\n \"digest\",\n \"_nouploadcache\",\n \"_state\",\n ],\n },\n };\n\n const defaultScope = `${options.audience ?? \"https://containerregistry.azure.net\"}/.default`;\n const serviceVersion = options.serviceVersion ?? LATEST_API_VERSION;\n const authClient = new GeneratedClient(endpoint, serviceVersion, internalPipelineOptions);\n this.client = new GeneratedClient(endpoint, serviceVersion, internalPipelineOptions);\n this.client.pipeline.addPolicy(\n bearerTokenAuthenticationPolicy({\n credential,\n scopes: [defaultScope],\n challengeCallbacks: new ChallengeHandler(\n new ContainerRegistryRefreshTokenCredential(authClient, defaultScope, credential),\n ),\n }),\n );\n }\n\n /**\n * Delete a blob.\n * @param digest - the digest of the blob to delete\n * @param options - optional configuration used to send requests to the service\n */\n public async deleteBlob(digest: string, options: DeleteBlobOptions = {}): Promise<void> {\n return tracingClient.withSpan(\n \"ContainerRegistryContentClient.deleteBlob\",\n options,\n async (updatedOptions) => {\n await this.client.containerRegistryBlob.deleteBlob(\n this.repositoryName,\n digest,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Upload a manifest for an OCI artifact.\n *\n * @param manifest - the manifest to upload.\n */\n public async setManifest(\n manifest: Buffer | NodeJS.ReadableStream | OciImageManifest | Record<string, unknown>,\n options: SetManifestOptions = {},\n ): Promise<SetManifestResult> {\n return tracingClient.withSpan(\n \"ContainerRegistryContentClient.uploadManifest\",\n options,\n async (updatedOptions) => {\n let manifestBody: Buffer | (() => NodeJS.ReadableStream);\n let tagOrDigest: string | undefined = options?.tag;\n\n if (Buffer.isBuffer(manifest)) {\n manifestBody = manifest;\n tagOrDigest ??= await calculateDigest(manifest);\n } else if (isReadableStream(manifest)) {\n manifestBody = await readStreamToEnd(manifest);\n tagOrDigest ??= await calculateDigest(manifestBody);\n } else {\n manifestBody = Buffer.from(JSON.stringify(manifest));\n tagOrDigest ??= await calculateDigest(manifestBody);\n }\n\n const createManifestResult = await this.client.containerRegistry.createManifest(\n this.repositoryName,\n tagOrDigest,\n manifestBody,\n {\n contentType: options?.mediaType ?? KnownManifestMediaType.OciImageManifest,\n ...updatedOptions,\n },\n );\n\n assertHasProperty(createManifestResult, \"dockerContentDigest\");\n\n return { digest: createManifestResult.dockerContentDigest };\n },\n );\n }\n\n /**\n * Downloads the manifest for an OCI artifact.\n *\n * @param tagOrDigest - a tag or digest that identifies the artifact\n * @returns - the downloaded manifest.\n */\n public async getManifest(\n tagOrDigest: string,\n options: GetManifestOptions = {},\n ): Promise<GetManifestResult> {\n return tracingClient.withSpan(\n \"ContainerRegistryContentClient.downloadManifest\",\n options,\n async (updatedOptions) => {\n const response = await this.client.containerRegistry.getManifest(\n this.repositoryName,\n tagOrDigest,\n {\n accept: ACCEPTED_MANIFEST_MEDIA_TYPES.join(\", \"),\n ...updatedOptions,\n },\n );\n\n assertHasProperty(response, \"mediaType\");\n\n const content = response.readableStreamBody\n ? await readStreamToEnd(response.readableStreamBody, MAX_MANIFEST_SIZE_BYTES)\n : Buffer.alloc(0);\n\n const expectedDigest = await calculateDigest(content);\n\n if (isDigest(tagOrDigest) && expectedDigest !== tagOrDigest) {\n throw new DigestMismatchError(\n \"Digest of downloaded manifest does not match the input digest\",\n );\n }\n\n if (response.dockerContentDigest !== expectedDigest) {\n throw new DigestMismatchError(\n \"Computed digest of downloaded manifest does not match the value of the Docker-Content-Digest header\",\n );\n }\n\n return {\n digest: response.dockerContentDigest,\n mediaType: response.mediaType,\n content,\n manifest: JSON.parse(content.toString(\"utf-8\")),\n };\n },\n );\n }\n\n /**\n * Delete a manifest. Doing so effectively deletes an artifact from the registry.\n *\n * @param digest - the digest of the manifest to delete\n * @param options - optional configuration used to send requests to the service\n */\n public async deleteManifest(digest: string, options: DeleteManifestOptions = {}): Promise<void> {\n return tracingClient.withSpan(\n \"ContainerRegistryContentClient.deleteManifest\",\n options,\n async (updatedOptions) => {\n await this.client.containerRegistry.deleteManifest(\n this.repositoryName,\n digest,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Upload an artifact blob.\n *\n * @param blobStream - the stream containing the blob data.\n */\n public async uploadBlob(\n blob: NodeJS.ReadableStream | Buffer,\n options: UploadBlobOptions = {},\n ): Promise<UploadBlobResult> {\n return tracingClient.withSpan(\n \"ContainerRegistryContentClient.uploadBlob\",\n options,\n async (updatedOptions) => {\n const blobStream = Buffer.isBuffer(blob) ? Readable.from(blob) : blob;\n\n const startUploadResult = await this.client.containerRegistryBlob.startUpload(\n this.repositoryName,\n updatedOptions,\n );\n\n assertHasProperty(startUploadResult, \"location\");\n let location = startUploadResult.location.substring(1);\n\n const chunks = readChunksFromStream(blobStream, CHUNK_SIZE);\n const hash = crypto.createHash(\"sha256\");\n\n let bytesUploaded = 0;\n\n for await (const chunk of chunks) {\n hash.write(chunk);\n const result = await this.client.containerRegistryBlob.uploadChunk(\n location,\n chunk,\n updatedOptions,\n );\n\n bytesUploaded += chunk.byteLength;\n\n assertHasProperty(result, \"location\");\n location = result.location.substring(1);\n }\n\n hash.end();\n const digest = `sha256:${hash.digest(\"hex\")}`;\n\n const { dockerContentDigest: digestFromResponse } =\n await this.client.containerRegistryBlob.completeUpload(digest, location, updatedOptions);\n\n if (digest !== digestFromResponse) {\n throw new DigestMismatchError(\n \"Digest of blob to upload does not match the digest from the server.\",\n );\n }\n\n return { digest, sizeInBytes: bytesUploaded };\n },\n );\n }\n\n /**\n * Download a blob that is part of an artifact.\n *\n * @param digest - the digest of the blob to download\n * @param options - optional configuration used to send requests to the service\n * @returns - the downloaded blob\n */\n public async downloadBlob(\n digest: string,\n options: DownloadBlobOptions = {},\n ): Promise<DownloadBlobResult> {\n return tracingClient.withSpan(\n \"ContainerRegistryContentClient.downloadBlob\",\n options,\n async (updatedOptions) => {\n const initialResponse = await this.client.containerRegistryBlob.getBlob(\n this.repositoryName,\n digest,\n updatedOptions,\n );\n\n assertHasProperty(initialResponse, \"readableStreamBody\");\n assertHasProperty(initialResponse, \"contentLength\");\n\n const hash = crypto.createHash(\"sha256\");\n\n return {\n digest,\n content: new RetriableReadableStream(\n initialResponse.readableStreamBody,\n async (pos) => {\n const retryResponse = await this.client.containerRegistryBlob.getChunk(\n this.repositoryName,\n digest,\n `${pos}-`,\n updatedOptions,\n );\n\n assertHasProperty(retryResponse, \"readableStreamBody\");\n return retryResponse.readableStreamBody;\n },\n 0,\n initialResponse.contentLength,\n {\n onData: (data) => hash.write(data),\n onEnd: () => {\n hash.end();\n const calculatedDigest = `sha256:${hash.digest(\"hex\")}`;\n\n if (digest !== calculatedDigest) {\n throw new DigestMismatchError(\n \"Digest calculated from downloaded blob content does not match digest requested.\",\n );\n }\n },\n },\n ),\n };\n },\n );\n }\n}\n"]}
1
+ {"version":3,"file":"containerRegistryContentClient.js","sourceRoot":"","sources":["../../../src/content/containerRegistryContentClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,+BAA+B,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAEvF,OAAO,EAAE,eAAe,EAAE,MA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EAAE,EAAE;YACvB,MAAM,eAAe,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,qBAAqB,CAAC,OAAO,CACrE,IAAI,CAAC,cAAc,EACnB,MAAM,EACN,cAAc,CACf,CAAC;YAEF,iBAAiB,CAAC,eAAe,EAAE,oBAAoB,CAAC,CAAC;YACzD,iBAAiB,CAAC,eAAe,EAAE,eAAe,CAAC,CAAC;YAEpD,MAAM,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;YAEzC,OAAO;gBACL,MAAM;gBACN,OAAO,EAAE,IAAI,uBAAuB,CAClC,eAAe,CAAC,kBAAkB,EAClC,KAAK,EAAE,GAAG,EAAE,EAAE;oBACZ,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,qBAAqB,CAAC,QAAQ,CACpE,IAAI,CAAC,cAAc,EACnB,MAAM,EACN,GAAG,GAAG,GAAG,EACT,cAAc,CACf,CAAC;oBAEF,iBAAiB,CAAC,aAAa,EAAE,oBAAoB,CAAC,CAAC;oBACvD,OAAO,aAAa,CAAC,kBAAkB,CAAC;gBAC1C,CAAC,EACD,CAAC,EACD,eAAe,CAAC,aAAa,EAC7B;oBACE,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;oBAClC,KAAK,EAAE,GAAG,EAAE;wBACV,IAAI,CAAC,GAAG,EAAE,CAAC;wBACX,MAAM,gBAAgB,GAAG,UAAU,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;wBAExD,IAAI,MAAM,KAAK,gBAAgB,EAAE,CAAC;4BAChC,MAAM,IAAI,mBAAmB,CAC3B,iFAAiF,CAClF,CAAC;wBACJ,CAAC;oBACH,CAAC;iBACF,CACF;aACF,CAAC;QACJ,CAAC,CACF,CAAC;IACJ,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { InternalPipelineOptions } from \"@azure/core-rest-pipeline\";\nimport { bearerTokenAuthenticationPolicy, RestError } from \"@azure/core-rest-pipeline\";\nimport type { TokenCredential } from \"@azure/core-auth\";\nimport { GeneratedClient } from \"../generated/index.js\";\nimport { ChallengeHandler } from \"../containerRegistryChallengeHandler.js\";\nimport { ContainerRegistryRefreshTokenCredential } from \"../containerRegistryTokenCredential.js\";\nimport { logger } from \"../logger.js\";\nimport { calculateDigest } from \"../utils/digest.js\";\nimport type {\n DeleteBlobOptions,\n DeleteManifestOptions,\n DownloadBlobOptions,\n DownloadBlobResult,\n GetManifestOptions,\n GetManifestResult,\n UploadBlobOptions,\n UploadBlobResult,\n SetManifestOptions,\n SetManifestResult,\n OciImageManifest,\n} from \"./models.js\";\nimport { KnownManifestMediaType } from \"./models.js\";\nimport type { CommonClientOptions } from \"@azure/core-client\";\nimport { isDigest, readChunksFromStream, readStreamToEnd } from \"../utils/helpers.js\";\nimport { Readable } from \"node:stream\";\nimport { tracingClient } from \"../tracing.js\";\nimport crypto from \"node:crypto\";\nimport { RetriableReadableStream } from \"../utils/retriableReadableStream.js\";\n\nconst LATEST_API_VERSION = \"2021-07-01\";\n\nconst CHUNK_SIZE = 4 * 1024 * 1024; // 4 MB\nconst MAX_MANIFEST_SIZE_BYTES = 4 * 1024 * 1024; // 4 MB\n\nconst ACCEPTED_MANIFEST_MEDIA_TYPES = [\n KnownManifestMediaType.OciImageManifest,\n KnownManifestMediaType.DockerManifest,\n \"application/vnd.oci.image.index.v1+json\",\n \"application/vnd.docker.distribution.manifest.list.v2+json\",\n \"application/vnd.docker.container.image.v1+json\",\n];\n\nfunction isReadableStream(body: any): body is NodeJS.ReadableStream {\n return body && typeof body.pipe === \"function\";\n}\n\nfunction assertHasProperty<T, U extends keyof T>(\n obj: T,\n property: U,\n): asserts obj is T & Required<Pick<T, U>> {\n if (!Object.prototype.hasOwnProperty.call(obj, property)) {\n throw new RestError(`Expected property ${String(property)} to be defined.`);\n }\n}\n\n/**\n * Error thrown when the Docker content digest returned from the\n * server does not match the digest calculated from the content.\n */\nexport class DigestMismatchError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"DigestMismatchError\";\n }\n}\n\n/**\n * Client options used to configure Container Registry Blob API requests.\n */\nexport interface ContainerRegistryContentClientOptions extends CommonClientOptions {\n /**\n * Gets or sets the audience to use for authentication with Azure Active Directory.\n * The authentication scope will be set from this audience.\n * See {@link KnownContainerRegistryAudience} for known audience values.\n */\n audience?: string;\n /**\n * The version of service API to make calls against.\n */\n serviceVersion?: \"2021-07-01\";\n}\n\n/**\n * The Azure Container Registry blob client, responsible for uploading and downloading blobs and manifests, the building blocks of artifacts.\n */\nexport class ContainerRegistryContentClient {\n /**\n * The Azure Container Registry endpoint.\n */\n public readonly endpoint: string;\n\n /**\n * The name of the repository that logically groups the artifact parts.\n */\n public readonly repositoryName: string;\n\n private client: GeneratedClient;\n\n /**\n * Creates an instance of a ContainerRegistryContentClient for managing container images and artifacts.\n *\n * Example usage:\n * ```ts snippet:SampleReadmeCreateContainerRegistryContentClient\n * import { ContainerRegistryContentClient } from \"@azure/container-registry\";\n * import { DefaultAzureCredential } from \"@azure/identity\";\n *\n * const endpoint = \"https://myregistryname.azurecr.io\";\n * const repository = \"library/hello-world\";\n * const client = new ContainerRegistryContentClient(\n * endpoint,\n * repository,\n * new DefaultAzureCredential(),\n * );\n * ```\n * @param endpoint - the URL endpoint of the container registry\n * @param repositoryName - the name of the repository that logically groups the artifact parts\n * @param credential - used to authenticate requests to the service\n * @param options - optional configuration used to send requests to the service\n */\n constructor(\n endpoint: string,\n repositoryName: string,\n credential: TokenCredential,\n options: ContainerRegistryContentClientOptions = {},\n ) {\n if (!endpoint) {\n throw new Error(\"invalid endpoint\");\n }\n\n this.endpoint = endpoint;\n this.repositoryName = repositoryName;\n\n const internalPipelineOptions: InternalPipelineOptions = {\n ...options,\n loggingOptions: {\n logger: logger.info,\n // This array contains header names we want to log that are not already\n // included as safe. Unknown/unsafe headers are logged as \"<REDACTED>\".\n additionalAllowedQueryParameters: [\n \"last\",\n \"n\",\n \"orderby\",\n \"digest\",\n \"_nouploadcache\",\n \"_state\",\n ],\n },\n };\n\n const defaultScope = `${options.audience ?? \"https://containerregistry.azure.net\"}/.default`;\n const serviceVersion = options.serviceVersion ?? LATEST_API_VERSION;\n const authClient = new GeneratedClient(endpoint, serviceVersion, internalPipelineOptions);\n this.client = new GeneratedClient(endpoint, serviceVersion, internalPipelineOptions);\n this.client.pipeline.addPolicy(\n bearerTokenAuthenticationPolicy({\n credential,\n scopes: [defaultScope],\n challengeCallbacks: new ChallengeHandler(\n new ContainerRegistryRefreshTokenCredential(authClient, defaultScope, credential),\n ),\n }),\n );\n }\n\n /**\n * Delete a blob.\n * @param digest - the digest of the blob to delete\n * @param options - optional configuration used to send requests to the service\n */\n public async deleteBlob(digest: string, options: DeleteBlobOptions = {}): Promise<void> {\n return tracingClient.withSpan(\n \"ContainerRegistryContentClient.deleteBlob\",\n options,\n async (updatedOptions) => {\n await this.client.containerRegistryBlob.deleteBlob(\n this.repositoryName,\n digest,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Upload a manifest for an OCI artifact.\n *\n * @param manifest - the manifest to upload.\n */\n public async setManifest(\n manifest: Buffer | NodeJS.ReadableStream | OciImageManifest | Record<string, unknown>,\n options: SetManifestOptions = {},\n ): Promise<SetManifestResult> {\n return tracingClient.withSpan(\n \"ContainerRegistryContentClient.uploadManifest\",\n options,\n async (updatedOptions) => {\n let manifestBody: Buffer | (() => NodeJS.ReadableStream);\n let tagOrDigest: string | undefined = options?.tag;\n\n if (Buffer.isBuffer(manifest)) {\n manifestBody = manifest;\n tagOrDigest ??= await calculateDigest(manifest);\n } else if (isReadableStream(manifest)) {\n manifestBody = await readStreamToEnd(manifest);\n tagOrDigest ??= await calculateDigest(manifestBody);\n } else {\n manifestBody = Buffer.from(JSON.stringify(manifest));\n tagOrDigest ??= await calculateDigest(manifestBody);\n }\n\n const createManifestResult = await this.client.containerRegistry.createManifest(\n this.repositoryName,\n tagOrDigest,\n manifestBody,\n {\n contentType: options?.mediaType ?? KnownManifestMediaType.OciImageManifest,\n ...updatedOptions,\n },\n );\n\n assertHasProperty(createManifestResult, \"dockerContentDigest\");\n\n return { digest: createManifestResult.dockerContentDigest };\n },\n );\n }\n\n /**\n * Downloads the manifest for an OCI artifact.\n *\n * @param tagOrDigest - a tag or digest that identifies the artifact\n * @returns - the downloaded manifest.\n */\n public async getManifest(\n tagOrDigest: string,\n options: GetManifestOptions = {},\n ): Promise<GetManifestResult> {\n return tracingClient.withSpan(\n \"ContainerRegistryContentClient.downloadManifest\",\n options,\n async (updatedOptions) => {\n const response = await this.client.containerRegistry.getManifest(\n this.repositoryName,\n tagOrDigest,\n {\n accept: ACCEPTED_MANIFEST_MEDIA_TYPES.join(\", \"),\n ...updatedOptions,\n },\n );\n\n assertHasProperty(response, \"mediaType\");\n\n const content = response.readableStreamBody\n ? await readStreamToEnd(response.readableStreamBody, MAX_MANIFEST_SIZE_BYTES)\n : Buffer.alloc(0);\n\n const expectedDigest = await calculateDigest(content);\n\n if (isDigest(tagOrDigest) && expectedDigest !== tagOrDigest) {\n throw new DigestMismatchError(\n \"Digest of downloaded manifest does not match the input digest\",\n );\n }\n\n if (response.dockerContentDigest !== expectedDigest) {\n throw new DigestMismatchError(\n \"Computed digest of downloaded manifest does not match the value of the Docker-Content-Digest header\",\n );\n }\n\n return {\n digest: response.dockerContentDigest,\n mediaType: response.mediaType,\n content,\n manifest: JSON.parse(content.toString(\"utf-8\")),\n };\n },\n );\n }\n\n /**\n * Delete a manifest. Doing so effectively deletes an artifact from the registry.\n *\n * @param digest - the digest of the manifest to delete\n * @param options - optional configuration used to send requests to the service\n */\n public async deleteManifest(digest: string, options: DeleteManifestOptions = {}): Promise<void> {\n return tracingClient.withSpan(\n \"ContainerRegistryContentClient.deleteManifest\",\n options,\n async (updatedOptions) => {\n await this.client.containerRegistry.deleteManifest(\n this.repositoryName,\n digest,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Upload an artifact blob.\n *\n * @param blobStream - the stream containing the blob data.\n */\n public async uploadBlob(\n blob: NodeJS.ReadableStream | Buffer,\n options: UploadBlobOptions = {},\n ): Promise<UploadBlobResult> {\n return tracingClient.withSpan(\n \"ContainerRegistryContentClient.uploadBlob\",\n options,\n async (updatedOptions) => {\n const blobStream = Buffer.isBuffer(blob) ? Readable.from(blob) : blob;\n\n const startUploadResult = await this.client.containerRegistryBlob.startUpload(\n this.repositoryName,\n updatedOptions,\n );\n\n assertHasProperty(startUploadResult, \"location\");\n let location = startUploadResult.location.substring(1);\n\n const chunks = readChunksFromStream(blobStream, CHUNK_SIZE);\n const hash = crypto.createHash(\"sha256\");\n\n let bytesUploaded = 0;\n\n for await (const chunk of chunks) {\n hash.write(chunk);\n const result = await this.client.containerRegistryBlob.uploadChunk(\n location,\n chunk,\n updatedOptions,\n );\n\n bytesUploaded += chunk.byteLength;\n\n assertHasProperty(result, \"location\");\n location = result.location.substring(1);\n }\n\n hash.end();\n const digest = `sha256:${hash.digest(\"hex\")}`;\n\n const { dockerContentDigest: digestFromResponse } =\n await this.client.containerRegistryBlob.completeUpload(digest, location, updatedOptions);\n\n if (digest !== digestFromResponse) {\n throw new DigestMismatchError(\n \"Digest of blob to upload does not match the digest from the server.\",\n );\n }\n\n return { digest, sizeInBytes: bytesUploaded };\n },\n );\n }\n\n /**\n * Download a blob that is part of an artifact.\n *\n * @param digest - the digest of the blob to download\n * @param options - optional configuration used to send requests to the service\n * @returns - the downloaded blob\n */\n public async downloadBlob(\n digest: string,\n options: DownloadBlobOptions = {},\n ): Promise<DownloadBlobResult> {\n return tracingClient.withSpan(\n \"ContainerRegistryContentClient.downloadBlob\",\n options,\n async (updatedOptions) => {\n const initialResponse = await this.client.containerRegistryBlob.getBlob(\n this.repositoryName,\n digest,\n updatedOptions,\n );\n\n assertHasProperty(initialResponse, \"readableStreamBody\");\n assertHasProperty(initialResponse, \"contentLength\");\n\n const hash = crypto.createHash(\"sha256\");\n\n return {\n digest,\n content: new RetriableReadableStream(\n initialResponse.readableStreamBody,\n async (pos) => {\n const retryResponse = await this.client.containerRegistryBlob.getChunk(\n this.repositoryName,\n digest,\n `${pos}-`,\n updatedOptions,\n );\n\n assertHasProperty(retryResponse, \"readableStreamBody\");\n return retryResponse.readableStreamBody;\n },\n 0,\n initialResponse.contentLength,\n {\n onData: (data) => hash.write(data),\n onEnd: () => {\n hash.end();\n const calculatedDigest = `sha256:${hash.digest(\"hex\")}`;\n\n if (digest !== calculatedDigest) {\n throw new DigestMismatchError(\n \"Digest calculated from downloaded blob content does not match digest requested.\",\n );\n }\n },\n },\n ),\n };\n },\n );\n }\n}\n"]}
@@ -9,6 +9,8 @@ import * as coreClient from "@azure/core-client";
9
9
  import { ContainerRegistryImpl, ContainerRegistryBlobImpl, AuthenticationImpl } from "./operations/index.js";
10
10
  /** @internal */
11
11
  export class GeneratedClient extends coreClient.ServiceClient {
12
+ url;
13
+ apiVersion;
12
14
  /**
13
15
  * Initializes a new instance of the GeneratedClient class.
14
16
  * @param url Registry login URL
@@ -16,7 +18,6 @@ export class GeneratedClient extends coreClient.ServiceClient {
16
18
  * @param options The parameter options
17
19
  */
18
20
  constructor(url, apiVersion, options) {
19
- var _a, _b;
20
21
  if (url === undefined) {
21
22
  throw new Error("'url' cannot be null");
22
23
  }
@@ -34,9 +35,14 @@ export class GeneratedClient extends coreClient.ServiceClient {
34
35
  const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
35
36
  ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`
36
37
  : `${packageDetails}`;
37
- const optionsWithDefaults = Object.assign(Object.assign(Object.assign({}, defaults), options), { userAgentOptions: {
38
+ const optionsWithDefaults = {
39
+ ...defaults,
40
+ ...options,
41
+ userAgentOptions: {
38
42
  userAgentPrefix
39
- }, endpoint: (_b = (_a = options.endpoint) !== null && _a !== void 0 ? _a : options.baseUri) !== null && _b !== void 0 ? _b : "{url}" });
43
+ },
44
+ endpoint: options.endpoint ?? options.baseUri ?? "{url}"
45
+ };
40
46
  super(optionsWithDefaults);
41
47
  // Parameter assignments
42
48
  this.url = url;
@@ -71,5 +77,8 @@ export class GeneratedClient extends coreClient.ServiceClient {
71
77
  };
72
78
  this.pipeline.addPolicy(apiVersionPolicy);
73
79
  }
80
+ containerRegistry;
81
+ containerRegistryBlob;
82
+ authentication;
74
83
  }
75
84
  //# sourceMappingURL=generatedClient.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"generatedClient.js","sourceRoot":"","sources":["../../../src/generated/generatedClient.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,UAAU,MAAM,oBAAoB,CAAC;AAMjD,OAAO,EACL,qBAAqB,EACrB,yBAAyB,EACzB,kBAAkB,EACnB,MAAM,uBAAuB,CAAC;AAQ/B,gBAAgB;AAChB,MAAM,OAAO,eAAgB,SAAQ,UAAU,CAAC,aAAa;IAI3D;;;;;OAKG;IACH,YACE,GAAW,EACX,UAA8B,EAC9B,OAAuC;;QAEvC,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;QAC1C,CAAC;QACD,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;YAC7B,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;QACjD,CAAC;QAED,0CAA0C;QAC1C,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO,GAAG,EAAE,CAAC;QACf,CAAC;QACD,MAAM,QAAQ,GAAkC;YAC9C,kBAAkB,EAAE,iCAAiC;SACtD,CAAC;QAEF,MAAM,cAAc,GAAG,0CAA0C,CAAC;QAClE,MAAM,eAAe,GACnB,OAAO,CAAC,gBAAgB,IAAI,OAAO,CAAC,gBAAgB,CAAC,eAAe;YAClE,CAAC,CAAC,GAAG,OAAO,CAAC,gBAAgB,CAAC,eAAe,IAAI,cAAc,EAAE;YACjE,CAAC,CAAC,GAAG,cAAc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AAC;wBACd,CAAC;oBACH,CAAC,CAAC,CAAC;oBACH,OAAO,CAAC,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;gBACrD,CAAC;gBACD,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;YACvB,CAAC;SACF,CAAC;QACF,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC;IAC5C,CAAC;CAKF","sourcesContent":["/*\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n *\n * Code generated by Microsoft (R) AutoRest Code Generator.\n * Changes may cause incorrect behavior and will be lost if the code is regenerated.\n */\n\nimport * as coreClient from \"@azure/core-client\";\nimport {\n PipelineRequest,\n PipelineResponse,\n SendRequest\n} from \"@azure/core-rest-pipeline\";\nimport {\n ContainerRegistryImpl,\n ContainerRegistryBlobImpl,\n AuthenticationImpl\n} from \"./operations/index.js\";\nimport {\n ContainerRegistry,\n ContainerRegistryBlob,\n Authentication\n} from \"./operationsInterfaces/index.js\";\nimport { ApiVersion20210701, GeneratedClientOptionalParams } from \"./models/index.js\";\n\n/** @internal */\nexport class GeneratedClient extends coreClient.ServiceClient {\n url: string;\n apiVersion: ApiVersion20210701;\n\n /**\n * Initializes a new instance of the GeneratedClient class.\n * @param url Registry login URL\n * @param apiVersion Api Version\n * @param options The parameter options\n */\n constructor(\n url: string,\n apiVersion: ApiVersion20210701,\n options?: GeneratedClientOptionalParams\n ) {\n if (url === undefined) {\n throw new Error(\"'url' cannot be null\");\n }\n if (apiVersion === undefined) {\n throw new Error(\"'apiVersion' cannot be null\");\n }\n\n // Initializing default values for options\n if (!options) {\n options = {};\n }\n const defaults: GeneratedClientOptionalParams = {\n requestContentType: \"application/json; charset=utf-8\"\n };\n\n const packageDetails = `azsdk-js-container-registry/1.1.0-beta.4`;\n const userAgentPrefix =\n options.userAgentOptions && options.userAgentOptions.userAgentPrefix\n ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`\n : `${packageDetails}`;\n\n const optionsWithDefaults = {\n ...defaults,\n ...options,\n userAgentOptions: {\n userAgentPrefix\n },\n endpoint: options.endpoint ?? options.baseUri ?? \"{url}\"\n };\n super(optionsWithDefaults);\n // Parameter assignments\n this.url = url;\n this.apiVersion = apiVersion;\n this.containerRegistry = new ContainerRegistryImpl(this);\n this.containerRegistryBlob = new ContainerRegistryBlobImpl(this);\n this.authentication = new AuthenticationImpl(this);\n this.addCustomApiVersionPolicy(apiVersion);\n }\n\n /** A function that adds a policy that sets the api-version (or equivalent) to reflect the library version. */\n private addCustomApiVersionPolicy(apiVersion?: string) {\n if (!apiVersion) {\n return;\n }\n const apiVersionPolicy = {\n name: \"CustomApiVersionPolicy\",\n async sendRequest(\n request: PipelineRequest,\n next: SendRequest\n ): Promise<PipelineResponse> {\n const param = request.url.split(\"?\");\n if (param.length > 1) {\n const newParams = param[1].split(\"&\").map((item) => {\n if (item.indexOf(\"api-version\") > -1) {\n return \"api-version=\" + apiVersion;\n } else {\n return item;\n }\n });\n request.url = param[0] + \"?\" + newParams.join(\"&\");\n }\n return next(request);\n }\n };\n this.pipeline.addPolicy(apiVersionPolicy);\n }\n\n containerRegistry: ContainerRegistry;\n containerRegistryBlob: ContainerRegistryBlob;\n authentication: Authentication;\n}\n"]}
1
+ {"version":3,"file":"generatedClient.js","sourceRoot":"","sources":["../../../src/generated/generatedClient.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,UAAU,MAAM,oBAAoB,CAAC;AAMjD,OAAO,EACL,qBAAqB,EACrB,yBAAyB,EACzB,kBAAkB,EACnB,MAAM,uBAAuB,CAAC;AAQ/B,gBAAgB;AAChB,MAAM,OAAO,eAAgB,SAAQ,UAAU,CAAC,aAAa;IAC3D,GAAG,CAAS;IACZ,UAAU,CAAqB;IAE/B;;;;;OAKG;IACH,YACE,GAAW,EACX,UAA8B,EAC9B,OAAuC;QAEvC,IAA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AAmB;QACnD,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,OAAO;QACT,CAAC;QACD,MAAM,gBAAgB,GAAG;YACvB,IAAI,EAAE,wBAAwB;YAC9B,KAAK,CAAC,WAAW,CACf,OAAwB,EACxB,IAAiB;gBAEjB,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;gBACrC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBACrB,MAAM,SAAS,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;wBACjD,IAAI,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;4BACrC,OAAO,cAAc,GAAG,UAAU,CAAC;wBACrC,CAAC;6BAAM,CAAC;4BACN,OAAO,IAAI,CAAC;wBACd,CAAC;oBACH,CAAC,CAAC,CAAC;oBACH,OAAO,CAAC,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;gBACrD,CAAC;gBACD,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;YACvB,CAAC;SACF,CAAC;QACF,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC;IAC5C,CAAC;IAED,iBAAiB,CAAoB;IACrC,qBAAqB,CAAwB;IAC7C,cAAc,CAAiB;CAChC","sourcesContent":["/*\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n *\n * Code generated by Microsoft (R) AutoRest Code Generator.\n * Changes may cause incorrect behavior and will be lost if the code is regenerated.\n */\n\nimport * as coreClient from \"@azure/core-client\";\nimport {\n PipelineRequest,\n PipelineResponse,\n SendRequest\n} from \"@azure/core-rest-pipeline\";\nimport {\n ContainerRegistryImpl,\n ContainerRegistryBlobImpl,\n AuthenticationImpl\n} from \"./operations/index.js\";\nimport {\n ContainerRegistry,\n ContainerRegistryBlob,\n Authentication\n} from \"./operationsInterfaces/index.js\";\nimport { ApiVersion20210701, GeneratedClientOptionalParams } from \"./models/index.js\";\n\n/** @internal */\nexport class GeneratedClient extends coreClient.ServiceClient {\n url: string;\n apiVersion: ApiVersion20210701;\n\n /**\n * Initializes a new instance of the GeneratedClient class.\n * @param url Registry login URL\n * @param apiVersion Api Version\n * @param options The parameter options\n */\n constructor(\n url: string,\n apiVersion: ApiVersion20210701,\n options?: GeneratedClientOptionalParams\n ) {\n if (url === undefined) {\n throw new Error(\"'url' cannot be null\");\n }\n if (apiVersion === undefined) {\n throw new Error(\"'apiVersion' cannot be null\");\n }\n\n // Initializing default values for options\n if (!options) {\n options = {};\n }\n const defaults: GeneratedClientOptionalParams = {\n requestContentType: \"application/json; charset=utf-8\"\n };\n\n const packageDetails = `azsdk-js-container-registry/1.1.0-beta.4`;\n const userAgentPrefix =\n options.userAgentOptions && options.userAgentOptions.userAgentPrefix\n ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`\n : `${packageDetails}`;\n\n const optionsWithDefaults = {\n ...defaults,\n ...options,\n userAgentOptions: {\n userAgentPrefix\n },\n endpoint: options.endpoint ?? options.baseUri ?? \"{url}\"\n };\n super(optionsWithDefaults);\n // Parameter assignments\n this.url = url;\n this.apiVersion = apiVersion;\n this.containerRegistry = new ContainerRegistryImpl(this);\n this.containerRegistryBlob = new ContainerRegistryBlobImpl(this);\n this.authentication = new AuthenticationImpl(this);\n this.addCustomApiVersionPolicy(apiVersion);\n }\n\n /** A function that adds a policy that sets the api-version (or equivalent) to reflect the library version. */\n private addCustomApiVersionPolicy(apiVersion?: string) {\n if (!apiVersion) {\n return;\n }\n const apiVersionPolicy = {\n name: \"CustomApiVersionPolicy\",\n async sendRequest(\n request: PipelineRequest,\n next: SendRequest\n ): Promise<PipelineResponse> {\n const param = request.url.split(\"?\");\n if (param.length > 1) {\n const newParams = param[1].split(\"&\").map((item) => {\n if (item.indexOf(\"api-version\") > -1) {\n return \"api-version=\" + apiVersion;\n } else {\n return item;\n }\n });\n request.url = param[0] + \"?\" + newParams.join(\"&\");\n }\n return next(request);\n }\n };\n this.pipeline.addPolicy(apiVersionPolicy);\n }\n\n containerRegistry: ContainerRegistry;\n containerRegistryBlob: ContainerRegistryBlob;\n authentication: Authentication;\n}\n"]}
@@ -8,6 +8,8 @@
8
8
  import * as coreClient from "@azure/core-client";
9
9
  /** @internal */
10
10
  export class GeneratedClientContext extends coreClient.ServiceClient {
11
+ url;
12
+ apiVersion;
11
13
  /**
12
14
  * Initializes a new instance of the GeneratedClientContext class.
13
15
  * @param url Registry login URL
@@ -32,9 +34,14 @@ export class GeneratedClientContext extends coreClient.ServiceClient {
32
34
  const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
33
35
  ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`
34
36
  : `${packageDetails}`;
35
- const optionsWithDefaults = Object.assign(Object.assign(Object.assign({}, defaults), options), { userAgentOptions: {
37
+ const optionsWithDefaults = {
38
+ ...defaults,
39
+ ...options,
40
+ userAgentOptions: {
36
41
  userAgentPrefix
37
- }, baseUri: options.endpoint || "{url}" });
42
+ },
43
+ baseUri: options.endpoint || "{url}"
44
+ };
38
45
  super(optionsWithDefaults);
39
46
  // Parameter assignments
40
47
  this.url = url;
@@ -1 +1 @@
1
- {"version":3,"file":"generatedClientContext.js","sourceRoot":"","sources":["../../../src/generated/generatedClientContext.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,UAAU,MAAM,oBAAoB,CAAC;AAGjD,gBAAgB;AAChB,MAAM,OAAO,sBAAuB,SAAQ,UAAU,CAAC,aAAa;IAIlE;;;;;OAKG;IACH,YACE,GAAW,EACX,UAA8B,EAC9B,OAAuC;QAEvC,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;QAC1C,CAAC;QACD,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;YAC7B,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;QACjD,CAAC;QAED,0CAA0C;QAC1C,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO,GAAG,EAAE,CAAC;QACf,CAAC;QACD,MAAM,QAAQ,GAAkC;YAC9C,kBAAkB,EAAE,iCAAiC;SACtD,CAAC;QAEF,MAAM,cAAc,GAAG,mCAAmC,CAAC;QAC3D,MAAM,eAAe,GACnB,OAAO,CAAC,gBAAgB,IAAI,OAAO,CAAC,gBAAgB,CAAC,eAAe;YAClE,CAAC,CAAC,GAAG,OAAO,CAAC,gBAAgB,CAAC,eAAe,IAAI,cAAc,EAAE;YACjE,CAAC,CAAC,GAAG,cAAc,EAAE,CAAC;QAE1B,MAAM,mBAAmB,iDACpB,QAAQ,GACR,OAAO,KACV,gBAAgB,EAAE;gBAChB,eAAe;aAChB,EACD,OAAO,EAAE,OAAO,CAAC,QAAQ,IAAI,OAAO,GACrC,CAAC;QACF,KAAK,CAAC,mBAAmB,CAAC,CAAC;QAC3B,wBAAwB;QACxB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;CACF","sourcesContent":["/*\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n *\n * Code generated by Microsoft (R) AutoRest Code Generator.\n * Changes may cause incorrect behavior and will be lost if the code is regenerated.\n */\n\nimport * as coreClient from \"@azure/core-client\";\nimport { ApiVersion20210701, GeneratedClientOptionalParams } from \"./models/index.js\";\n\n/** @internal */\nexport class GeneratedClientContext extends coreClient.ServiceClient {\n url: string;\n apiVersion: ApiVersion20210701;\n\n /**\n * Initializes a new instance of the GeneratedClientContext class.\n * @param url Registry login URL\n * @param apiVersion Api Version\n * @param options The parameter options\n */\n constructor(\n url: string,\n apiVersion: ApiVersion20210701,\n options?: GeneratedClientOptionalParams\n ) {\n if (url === undefined) {\n throw new Error(\"'url' cannot be null\");\n }\n if (apiVersion === undefined) {\n throw new Error(\"'apiVersion' cannot be null\");\n }\n\n // Initializing default values for options\n if (!options) {\n options = {};\n }\n const defaults: GeneratedClientOptionalParams = {\n requestContentType: \"application/json; charset=utf-8\"\n };\n\n const packageDetails = `azsdk-js-container-registry/1.1.1`;\n const userAgentPrefix =\n options.userAgentOptions && options.userAgentOptions.userAgentPrefix\n ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`\n : `${packageDetails}`;\n\n const optionsWithDefaults = {\n ...defaults,\n ...options,\n userAgentOptions: {\n userAgentPrefix\n },\n baseUri: options.endpoint || \"{url}\"\n };\n super(optionsWithDefaults);\n // Parameter assignments\n this.url = url;\n this.apiVersion = apiVersion;\n }\n}\n"]}
1
+ {"version":3,"file":"generatedClientContext.js","sourceRoot":"","sources":["../../../src/generated/generatedClientContext.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,UAAU,MAAM,oBAAoB,CAAC;AAGjD,gBAAgB;AAChB,MAAM,OAAO,sBAAuB,SAAQ,UAAU,CAAC,aAAa;IAClE,GAAG,CAAS;IACZ,UAAU,CAAqB;IAE/B;;;;;OAKG;IACH,YACE,GAAW,EACX,UAA8B,EAC9B,OAAuC;QAEvC,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;QAC1C,CAAC;QACD,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;YAC7B,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;QACjD,CAAC;QAED,0CAA0C;QAC1C,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO,GAAG,EAAE,CAAC;QACf,CAAC;QACD,MAAM,QAAQ,GAAkC;YAC9C,kBAAkB,EAAE,iCAAiC;SACtD,CAAC;QAEF,MAAM,cAAc,GAAG,mCAAmC,CAAC;QAC3D,MAAM,eAAe,GACnB,OAAO,CAAC,gBAAgB,IAAI,OAAO,CAAC,gBAAgB,CAAC,eAAe;YAClE,CAAC,CAAC,GAAG,OAAO,CAAC,gBAAgB,CAAC,eAAe,IAAI,cAAc,EAAE;YACjE,CAAC,CAAC,GAAG,cAAc,EAAE,CAAC;QAE1B,MAAM,mBAAmB,GAAG;YAC1B,GAAG,QAAQ;YACX,GAAG,OAAO;YACV,gBAAgB,EAAE;gBAChB,eAAe;aAChB;YACD,OAAO,EAAE,OAAO,CAAC,QAAQ,IAAI,OAAO;SACrC,CAAC;QACF,KAAK,CAAC,mBAAmB,CAAC,CAAC;QAC3B,wBAAwB;QACxB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;CACF","sourcesContent":["/*\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n *\n * Code generated by Microsoft (R) AutoRest Code Generator.\n * Changes may cause incorrect behavior and will be lost if the code is regenerated.\n */\n\nimport * as coreClient from \"@azure/core-client\";\nimport { ApiVersion20210701, GeneratedClientOptionalParams } from \"./models/index.js\";\n\n/** @internal */\nexport class GeneratedClientContext extends coreClient.ServiceClient {\n url: string;\n apiVersion: ApiVersion20210701;\n\n /**\n * Initializes a new instance of the GeneratedClientContext class.\n * @param url Registry login URL\n * @param apiVersion Api Version\n * @param options The parameter options\n */\n constructor(\n url: string,\n apiVersion: ApiVersion20210701,\n options?: GeneratedClientOptionalParams\n ) {\n if (url === undefined) {\n throw new Error(\"'url' cannot be null\");\n }\n if (apiVersion === undefined) {\n throw new Error(\"'apiVersion' cannot be null\");\n }\n\n // Initializing default values for options\n if (!options) {\n options = {};\n }\n const defaults: GeneratedClientOptionalParams = {\n requestContentType: \"application/json; charset=utf-8\"\n };\n\n const packageDetails = `azsdk-js-container-registry/1.1.1`;\n const userAgentPrefix =\n options.userAgentOptions && options.userAgentOptions.userAgentPrefix\n ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`\n : `${packageDetails}`;\n\n const optionsWithDefaults = {\n ...defaults,\n ...options,\n userAgentOptions: {\n userAgentPrefix\n },\n baseUri: options.endpoint || \"{url}\"\n };\n super(optionsWithDefaults);\n // Parameter assignments\n this.url = url;\n this.apiVersion = apiVersion;\n }\n}\n"]}
@@ -1309,12 +1309,15 @@ export const ManifestWrapper = {
1309
1309
  type: {
1310
1310
  name: "Composite",
1311
1311
  className: "ManifestWrapper",
1312
- modelProperties: Object.assign(Object.assign({}, Manifest.type.modelProperties), { mediaType: {
1312
+ modelProperties: {
1313
+ ...Manifest.type.modelProperties,
1314
+ mediaType: {
1313
1315
  serializedName: "mediaType",
1314
1316
  type: {
1315
1317
  name: "String"
1316
1318
  }
1317
- }, manifests: {
1319
+ },
1320
+ manifests: {
1318
1321
  serializedName: "manifests",
1319
1322
  type: {
1320
1323
  name: "Sequence",
@@ -1325,13 +1328,15 @@ export const ManifestWrapper = {
1325
1328
  }
1326
1329
  }
1327
1330
  }
1328
- }, config: {
1331
+ },
1332
+ config: {
1329
1333
  serializedName: "config",
1330
1334
  type: {
1331
1335
  name: "Composite",
1332
1336
  className: "Descriptor"
1333
1337
  }
1334
- }, layers: {
1338
+ },
1339
+ layers: {
1335
1340
  serializedName: "layers",
1336
1341
  type: {
1337
1342
  name: "Sequence",
@@ -1342,28 +1347,33 @@ export const ManifestWrapper = {
1342
1347
  }
1343
1348
  }
1344
1349
  }
1345
- }, annotations: {
1350
+ },
1351
+ annotations: {
1346
1352
  serializedName: "annotations",
1347
1353
  type: {
1348
1354
  name: "Composite",
1349
1355
  className: "Annotations"
1350
1356
  }
1351
- }, architecture: {
1357
+ },
1358
+ architecture: {
1352
1359
  serializedName: "architecture",
1353
1360
  type: {
1354
1361
  name: "String"
1355
1362
  }
1356
- }, name: {
1363
+ },
1364
+ name: {
1357
1365
  serializedName: "name",
1358
1366
  type: {
1359
1367
  name: "String"
1360
1368
  }
1361
- }, tag: {
1369
+ },
1370
+ tag: {
1362
1371
  serializedName: "tag",
1363
1372
  type: {
1364
1373
  name: "String"
1365
1374
  }
1366
- }, fsLayers: {
1375
+ },
1376
+ fsLayers: {
1367
1377
  serializedName: "fsLayers",
1368
1378
  type: {
1369
1379
  name: "Sequence",
@@ -1374,7 +1384,8 @@ export const ManifestWrapper = {
1374
1384
  }
1375
1385
  }
1376
1386
  }
1377
- }, history: {
1387
+ },
1388
+ history: {
1378
1389
  serializedName: "history",
1379
1390
  type: {
1380
1391
  name: "Sequence",
@@ -1385,7 +1396,8 @@ export const ManifestWrapper = {
1385
1396
  }
1386
1397
  }
1387
1398
  }
1388
- }, signatures: {
1399
+ },
1400
+ signatures: {
1389
1401
  serializedName: "signatures",
1390
1402
  type: {
1391
1403
  name: "Sequence",
@@ -1396,7 +1408,8 @@ export const ManifestWrapper = {
1396
1408
  }
1397
1409
  }
1398
1410
  }
1399
- } })
1411
+ }
1412
+ }
1400
1413
  }
1401
1414
  };
1402
1415
  export const ManifestList = {
@@ -1404,12 +1417,15 @@ export const ManifestList = {
1404
1417
  type: {
1405
1418
  name: "Composite",
1406
1419
  className: "ManifestList",
1407
- modelProperties: Object.assign(Object.assign({}, Manifest.type.modelProperties), { mediaType: {
1420
+ modelProperties: {
1421
+ ...Manifest.type.modelProperties,
1422
+ mediaType: {
1408
1423
  serializedName: "mediaType",
1409
1424
  type: {
1410
1425
  name: "String"
1411
1426
  }
1412
- }, manifests: {
1427
+ },
1428
+ manifests: {
1413
1429
  serializedName: "manifests",
1414
1430
  type: {
1415
1431
  name: "Sequence",
@@ -1420,7 +1436,8 @@ export const ManifestList = {
1420
1436
  }
1421
1437
  }
1422
1438
  }
1423
- } })
1439
+ }
1440
+ }
1424
1441
  }
1425
1442
  };
1426
1443
  export const V2Manifest = {
@@ -1428,18 +1445,22 @@ export const V2Manifest = {
1428
1445
  type: {
1429
1446
  name: "Composite",
1430
1447
  className: "V2Manifest",
1431
- modelProperties: Object.assign(Object.assign({}, Manifest.type.modelProperties), { mediaType: {
1448
+ modelProperties: {
1449
+ ...Manifest.type.modelProperties,
1450
+ mediaType: {
1432
1451
  serializedName: "mediaType",
1433
1452
  type: {
1434
1453
  name: "String"
1435
1454
  }
1436
- }, config: {
1455
+ },
1456
+ config: {
1437
1457
  serializedName: "config",
1438
1458
  type: {
1439
1459
  name: "Composite",
1440
1460
  className: "Descriptor"
1441
1461
  }
1442
- }, layers: {
1462
+ },
1463
+ layers: {
1443
1464
  serializedName: "layers",
1444
1465
  type: {
1445
1466
  name: "Sequence",
@@ -1450,7 +1471,8 @@ export const V2Manifest = {
1450
1471
  }
1451
1472
  }
1452
1473
  }
1453
- } })
1474
+ }
1475
+ }
1454
1476
  }
1455
1477
  };
1456
1478
  export const OCIIndex = {
@@ -1458,7 +1480,9 @@ export const OCIIndex = {
1458
1480
  type: {
1459
1481
  name: "Composite",
1460
1482
  className: "OCIIndex",
1461
- modelProperties: Object.assign(Object.assign({}, Manifest.type.modelProperties), { manifests: {
1483
+ modelProperties: {
1484
+ ...Manifest.type.modelProperties,
1485
+ manifests: {
1462
1486
  serializedName: "manifests",
1463
1487
  type: {
1464
1488
  name: "Sequence",
@@ -1469,13 +1493,15 @@ export const OCIIndex = {
1469
1493
  }
1470
1494
  }
1471
1495
  }
1472
- }, annotations: {
1496
+ },
1497
+ annotations: {
1473
1498
  serializedName: "annotations",
1474
1499
  type: {
1475
1500
  name: "Composite",
1476
1501
  className: "Annotations"
1477
1502
  }
1478
- } })
1503
+ }
1504
+ }
1479
1505
  }
1480
1506
  };
1481
1507
  export const V1Manifest = {
@@ -1483,22 +1509,27 @@ export const V1Manifest = {
1483
1509
  type: {
1484
1510
  name: "Composite",
1485
1511
  className: "V1Manifest",
1486
- modelProperties: Object.assign(Object.assign({}, Manifest.type.modelProperties), { architecture: {
1512
+ modelProperties: {
1513
+ ...Manifest.type.modelProperties,
1514
+ architecture: {
1487
1515
  serializedName: "architecture",
1488
1516
  type: {
1489
1517
  name: "String"
1490
1518
  }
1491
- }, name: {
1519
+ },
1520
+ name: {
1492
1521
  serializedName: "name",
1493
1522
  type: {
1494
1523
  name: "String"
1495
1524
  }
1496
- }, tag: {
1525
+ },
1526
+ tag: {
1497
1527
  serializedName: "tag",
1498
1528
  type: {
1499
1529
  name: "String"
1500
1530
  }
1501
- }, fsLayers: {
1531
+ },
1532
+ fsLayers: {
1502
1533
  serializedName: "fsLayers",
1503
1534
  type: {
1504
1535
  name: "Sequence",
@@ -1509,7 +1540,8 @@ export const V1Manifest = {
1509
1540
  }
1510
1541
  }
1511
1542
  }
1512
- }, history: {
1543
+ },
1544
+ history: {
1513
1545
  serializedName: "history",
1514
1546
  type: {
1515
1547
  name: "Sequence",
@@ -1520,7 +1552,8 @@ export const V1Manifest = {
1520
1552
  }
1521
1553
  }
1522
1554
  }
1523
- }, signatures: {
1555
+ },
1556
+ signatures: {
1524
1557
  serializedName: "signatures",
1525
1558
  type: {
1526
1559
  name: "Sequence",
@@ -1531,7 +1564,8 @@ export const V1Manifest = {
1531
1564
  }
1532
1565
  }
1533
1566
  }
1534
- } })
1567
+ }
1568
+ }
1535
1569
  }
1536
1570
  };
1537
1571
  export const ContainerRegistryGetManifestHeaders = {