@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 { __asyncDelegator, __asyncGenerator, __asyncValues, __await } from "tslib";
4
3
  import { tracingClient } from "./tracing.js";
5
4
  import { RegistryArtifactImpl } from "./registryArtifact.js";
6
5
  import { toArtifactManifestProperties, toServiceManifestOrderBy } from "./transformations.js";
@@ -10,6 +9,15 @@ import { extractNextLink } from "./utils/helpers.js";
10
9
  * @internal
11
10
  */
12
11
  export class ContainerRepositoryImpl {
12
+ client;
13
+ /**
14
+ * The Azure Container Registry endpoint.
15
+ */
16
+ registryEndpoint;
17
+ /**
18
+ * Repository name.
19
+ */
20
+ name;
13
21
  /**
14
22
  * Creates an instance of a ContainerRepository.
15
23
  * @param registryEndpoint - the URL to the Container Registry endpoint
@@ -80,7 +88,7 @@ export class ContainerRepositoryImpl {
80
88
  canList: options.canList,
81
89
  canRead: options.canRead,
82
90
  };
83
- return tracingClient.withSpan("ContainerRepositoryImpl.updateProperties", Object.assign(Object.assign({}, options), { value }), (updatedOptions) => {
91
+ return tracingClient.withSpan("ContainerRepositoryImpl.updateProperties", { ...options, value }, (updatedOptions) => {
84
92
  return this.client.containerRegistry.updateProperties(this.name, updatedOptions);
85
93
  });
86
94
  }
@@ -119,53 +127,40 @@ export class ContainerRepositoryImpl {
119
127
  byPage: (settings = {}) => this.listManifestsPage(settings, options),
120
128
  };
121
129
  }
122
- listManifestsItems() {
123
- return __asyncGenerator(this, arguments, function* listManifestsItems_1(options = {}) {
124
- var _a, e_1, _b, _c;
125
- try {
126
- for (var _d = true, _e = __asyncValues(this.listManifestsPage({}, options)), _f; _f = yield __await(_e.next()), _a = _f.done, !_a; _d = true) {
127
- _c = _f.value;
128
- _d = false;
129
- const page = _c;
130
- yield __await(yield* __asyncDelegator(__asyncValues(page)));
131
- }
132
- }
133
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
134
- finally {
135
- try {
136
- if (!_d && !_a && (_b = _e.return)) yield __await(_b.call(_e));
137
- }
138
- finally { if (e_1) throw e_1.error; }
139
- }
140
- });
130
+ async *listManifestsItems(options = {}) {
131
+ for await (const page of this.listManifestsPage({}, options)) {
132
+ yield* page;
133
+ }
141
134
  }
142
- listManifestsPage(continuationState_1) {
143
- return __asyncGenerator(this, arguments, function* listManifestsPage_1(continuationState, options = {}) {
144
- const orderby = toServiceManifestOrderBy(options.order);
145
- if (!continuationState.continuationToken) {
146
- const optionsComplete = Object.assign(Object.assign({}, options), { n: continuationState.maxPageSize, orderby });
147
- const currentPage = yield __await(this.client.containerRegistry.getManifests(this.name, optionsComplete));
148
- continuationState.continuationToken = extractNextLink(currentPage.link);
149
- if (currentPage.manifests) {
150
- const array = currentPage.manifests.map((t) => toArtifactManifestProperties(t, this.name, currentPage.registryLoginServer));
151
- yield yield __await(Object.defineProperty(array, "continuationToken", {
152
- value: continuationState.continuationToken,
153
- enumerable: true,
154
- }));
155
- }
135
+ async *listManifestsPage(continuationState, options = {}) {
136
+ const orderby = toServiceManifestOrderBy(options.order);
137
+ if (!continuationState.continuationToken) {
138
+ const optionsComplete = {
139
+ ...options,
140
+ n: continuationState.maxPageSize,
141
+ orderby,
142
+ };
143
+ const currentPage = await this.client.containerRegistry.getManifests(this.name, optionsComplete);
144
+ continuationState.continuationToken = extractNextLink(currentPage.link);
145
+ if (currentPage.manifests) {
146
+ const array = currentPage.manifests.map((t) => toArtifactManifestProperties(t, this.name, currentPage.registryLoginServer));
147
+ yield Object.defineProperty(array, "continuationToken", {
148
+ value: continuationState.continuationToken,
149
+ enumerable: true,
150
+ });
156
151
  }
157
- while (continuationState.continuationToken) {
158
- const currentPage = yield __await(this.client.containerRegistry.getManifestsNext(this.name, continuationState.continuationToken, options));
159
- continuationState.continuationToken = extractNextLink(currentPage.link);
160
- if (currentPage.manifests) {
161
- const array = currentPage.manifests.map((t) => toArtifactManifestProperties(t, this.name, currentPage.registryLoginServer));
162
- yield yield __await(Object.defineProperty(array, "continuationToken", {
163
- value: continuationState.continuationToken,
164
- enumerable: true,
165
- }));
166
- }
152
+ }
153
+ while (continuationState.continuationToken) {
154
+ const currentPage = await this.client.containerRegistry.getManifestsNext(this.name, continuationState.continuationToken, options);
155
+ continuationState.continuationToken = extractNextLink(currentPage.link);
156
+ if (currentPage.manifests) {
157
+ const array = currentPage.manifests.map((t) => toArtifactManifestProperties(t, this.name, currentPage.registryLoginServer));
158
+ yield Object.defineProperty(array, "continuationToken", {
159
+ value: continuationState.continuationToken,
160
+ enumerable: true,
161
+ });
167
162
  }
168
- });
163
+ }
169
164
  }
170
165
  }
171
166
  //# sourceMappingURL=containerRepository.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"containerRepository.js","sourceRoot":"","sources":["../../src/containerRepository.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AAQlC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAQ7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,4BAA4B,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAC9F,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAqHrD;;;GAGG;AACH,MAAM,OAAO,uBAAuB;IAWlC;;;;;OAKG;IACH,YAAY,gBAAwB,EAAE,IAAY,EAAE,MAAuB;QACzE,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QACzC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QAEjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,MAAM,CAAC,UAAmC,EAAE;QACvD,OAAO,aAAa,CAAC,QAAQ,CAC3B,gCAAgC,EAChC,OAAO,EACP,KAAK,EAAE,cAAc,EAAE,EAAE;YACvB,MAAM,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;QAClF,CAAC,CACF,CAAC;IACJ,CAAC;IAED;;;OAGG;IACI,WAAW,CAAC,WAAmB;QACpC,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,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AAC,KAAK,EAAE,mBAAmB,EAAE;wBACtD,KAAK,EAAE,iBAAiB,CAAC,iBAAiB;wBAC1C,UAAU,EAAE,IAAI;qBACjB,CAAC,CAAA,CAAC;gBACL,CAAC;YACH,CAAC;YACD,OAAO,iBAAiB,CAAC,iBAAiB,EAAE,CAAC;gBAC3C,MAAM,WAAW,GAAG,cAAM,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,gBAAgB,CACtE,IAAI,CAAC,IAAI,EACT,iBAAiB,CAAC,iBAAiB,EACnC,OAAO,CACR,CAAA,CAAC;gBACF,iBAAiB,CAAC,iBAAiB,GAAG,eAAe,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;gBACxE,IAAI,WAAW,CAAC,SAAS,EAAE,CAAC;oBAC1B,MAAM,KAAK,GAAG,WAAW,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAC5C,4BAA4B,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,EAAE,WAAW,CAAC,mBAAoB,CAAC,CAC7E,CAAC;oBACF,oBAAM,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,mBAAmB,EAAE;wBACtD,KAAK,EAAE,iBAAiB,CAAC,iBAAiB;wBAC1C,UAAU,EAAE,IAAI;qBACjB,CAAC,CAAA,CAAC;gBACL,CAAC;YACH,CAAC;QACH,CAAC;KAAA;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n/// <reference lib=\"esnext.asynciterable\" />\n\nimport type { OperationOptions } from \"@azure/core-client\";\nimport type { PageSettings, PagedAsyncIterableIterator } from \"@azure/core-paging\";\n\nimport type { GeneratedClient, RepositoryWriteableProperties } from \"./generated/index.js\";\nimport { tracingClient } from \"./tracing.js\";\nimport type {\n ArtifactManifestOrder,\n ContainerRepositoryProperties,\n ArtifactManifestProperties,\n ManifestPageResponse,\n} from \"./models.js\";\nimport type { RegistryArtifact } from \"./registryArtifact.js\";\nimport { RegistryArtifactImpl } from \"./registryArtifact.js\";\nimport { toArtifactManifestProperties, toServiceManifestOrderBy } from \"./transformations.js\";\nimport { extractNextLink } from \"./utils/helpers.js\";\n\n/**\n * Options for delete repository operation.\n */\nexport interface DeleteRepositoryOptions extends OperationOptions {}\n/**\n * Options for the `listRegistryArtifacts` method of `ContainerRepository`.\n */\nexport interface ListManifestPropertiesOptions extends OperationOptions {\n /** order in which the manifest properties are returned */\n order?: ArtifactManifestOrder;\n}\n/**\n * Options for the `getProperties` method of `ContainerRepository`.\n */\nexport interface GetRepositoryPropertiesOptions extends OperationOptions {}\n/**\n * Options for the `setProperties` method of `ContainerRepository`.\n */\nexport interface UpdateRepositoryPropertiesOptions extends OperationOptions {\n /** Whether or not this repository can be deleted */\n canDelete?: boolean;\n /** Whether or not this repository can be written to */\n canWrite?: boolean;\n /** Whether or not include this repository when listing repositories */\n canList?: boolean;\n /** Whether or not this repository can be read */\n canRead?: boolean;\n}\n\n/**\n * A `repository` in a container registry is a logical grouping of images or artifacts that share the same name. For example,\n * different versions of a `hello-world` application could have tags `v1` and `v2`, and be grouped by the repository `hello-world`.\n *\n * The {@link ContainerRepository} interface is a helper that groups information and operations about a repository in this\n * container registry.\n */\nexport interface ContainerRepository {\n /**\n * The Azure Container Registry endpoint.\n */\n readonly registryEndpoint: string;\n /**\n * Repository name.\n */\n readonly name: string;\n /**\n * Deletes this repository and all artifacts that are part of its logical group.\n *\n * @param options - optional configuration for the operation\n */\n delete(options?: DeleteRepositoryOptions): Promise<void>;\n /**\n * Returns an helper instance of {@link RegistryArtifact} for the given tag or digest.\n * @param tagOrDigest - the tag or digest of the artifact\n */\n getArtifact(tagOrDigest: string): RegistryArtifact;\n /**\n * Retrieves the properties of this repository.\n * @param options - The options for the operation.\n */\n getProperties(options?: GetRepositoryPropertiesOptions): Promise<ContainerRepositoryProperties>;\n /**\n * Updates the properties of this repository.\n *\n * Example usage:\n *\n * ```ts snippet:ContainerRepositoryUpdateProperties\n * import { ContainerRegistryClient } from \"@azure/container-registry\";\n * import { DefaultAzureCredential } from \"@azure/identity\";\n *\n * const endpoint = \"https://myregistryname.azurecr.io\";\n * const repositoryName = \"library/hello-world\";\n * const client = new ContainerRegistryClient(endpoint, new DefaultAzureCredential());\n * const repository = client.getRepository(repositoryName);\n *\n * const updated = await repository.updateProperties({\n * canDelete: false,\n * canList: false,\n * canRead: false,\n * canWrite: false,\n * });\n * ```\n * @param options - The options for the operation.\n */\n updateProperties(\n options: UpdateRepositoryPropertiesOptions,\n ): Promise<ContainerRepositoryProperties>;\n /**\n * Returns an async iterable iterator to list manifest properties.\n * This is useful for determining the collection of artifacts associated with\n * this repository, as each artifact is uniquely identified by its manifest.\n *\n * Example using `for-await-of` syntax:\n *\n * ```ts snippet:ContainerRepositoryListManifestProperties\n * import { ContainerRegistryClient } from \"@azure/container-registry\";\n * import { DefaultAzureCredential } from \"@azure/identity\";\n *\n * const endpoint = \"https://myregistryname.azurecr.io\";\n * const repositoryName = \"library/hello-world\";\n * const client = new ContainerRegistryClient(endpoint, new DefaultAzureCredential());\n * const repository = client.getRepository(repositoryName);\n *\n * for await (const manifest of repository.listManifestProperties()) {\n * console.log(\"manifest: \", manifest);\n * }\n * ```\n *\n * @param options - The options for the operation.\n */\n listManifestProperties(\n options?: ListManifestPropertiesOptions,\n ): PagedAsyncIterableIterator<ArtifactManifestProperties>;\n}\n\n/**\n * The client class used to interact with the Container Registry service.\n * @internal\n */\nexport class ContainerRepositoryImpl {\n private readonly client: GeneratedClient;\n /**\n * The Azure Container Registry endpoint.\n */\n public readonly registryEndpoint: string;\n /**\n * Repository name.\n */\n public readonly name: string;\n\n /**\n * Creates an instance of a ContainerRepository.\n * @param registryEndpoint - the URL to the Container Registry endpoint\n * @param name - the name of the repository\n * @param client - the generated client that interacts with service\n */\n constructor(registryEndpoint: string, name: string, client: GeneratedClient) {\n this.registryEndpoint = registryEndpoint;\n this.name = name;\n\n this.client = client;\n }\n\n /**\n * Deletes this repository and all artifacts that are part of its logical group.\n *\n * @param options - optional configuration for the operation\n */\n public async delete(options: DeleteRepositoryOptions = {}): Promise<void> {\n return tracingClient.withSpan(\n \"ContainerRepositoryImpl.delete\",\n options,\n async (updatedOptions) => {\n await this.client.containerRegistry.deleteRepository(this.name, updatedOptions);\n },\n );\n }\n\n /**\n * Returns an helper instance of {@link RegistryArtifact} for the given tag or digest.\n * @param tagOrDigest - the tag or digest of the artifact\n */\n public getArtifact(tagOrDigest: string): RegistryArtifact {\n if (!tagOrDigest) {\n throw new Error(\"invalid tagOrDigest\");\n }\n return new RegistryArtifactImpl(this.registryEndpoint, this.name, tagOrDigest, this.client);\n }\n\n /**\n * Retrieves the properties of this repository.\n * @param options - The options for the operation.\n */\n public async getProperties(\n options: GetRepositoryPropertiesOptions = {},\n ): Promise<ContainerRepositoryProperties> {\n return tracingClient.withSpan(\n \"ContainerRepositoryImpl.getProperties\",\n options,\n (updatedOptions) => {\n return this.client.containerRegistry.getProperties(this.name, updatedOptions);\n },\n );\n }\n\n /**\n * Updates the properties of this repository.\n *\n * Example usage:\n *\n * ```ts snippet:ContainerRepositoryUpdateProperties\n * import { ContainerRegistryClient } from \"@azure/container-registry\";\n * import { DefaultAzureCredential } from \"@azure/identity\";\n *\n * const endpoint = \"https://myregistryname.azurecr.io\";\n * const repositoryName = \"library/hello-world\";\n * const client = new ContainerRegistryClient(endpoint, new DefaultAzureCredential());\n * const repository = client.getRepository(repositoryName);\n *\n * const updated = await repository.updateProperties({\n * canDelete: false,\n * canList: false,\n * canRead: false,\n * canWrite: false,\n * });\n * ```\n * @param options - The options for the operation.\n */\n public async updateProperties(\n options: UpdateRepositoryPropertiesOptions,\n ): Promise<ContainerRepositoryProperties> {\n const value: RepositoryWriteableProperties = {\n canDelete: options.canDelete,\n canWrite: options.canWrite,\n canList: options.canList,\n canRead: options.canRead,\n };\n\n return tracingClient.withSpan(\n \"ContainerRepositoryImpl.updateProperties\",\n { ...options, value },\n (updatedOptions) => {\n return this.client.containerRegistry.updateProperties(this.name, updatedOptions);\n },\n );\n }\n\n /**\n * Returns an async iterable iterator to list manifest properties.\n * This is useful for determining the collection of artifacts associated with\n * this repository, as each artifact is uniquely identified by its manifest.\n *\n * Example using `for-await-of` syntax:\n *\n * ```ts snippet:ContainerRepositoryListManifestProperties\n * import { ContainerRegistryClient } from \"@azure/container-registry\";\n * import { DefaultAzureCredential } from \"@azure/identity\";\n *\n * const endpoint = \"https://myregistryname.azurecr.io\";\n * const repositoryName = \"library/hello-world\";\n * const client = new ContainerRegistryClient(endpoint, new DefaultAzureCredential());\n * const repository = client.getRepository(repositoryName);\n *\n * for await (const manifest of repository.listManifestProperties()) {\n * console.log(\"manifest: \", manifest);\n * }\n * ```\n *\n * @param options - The options for the operation.\n */\n public listManifestProperties(\n options: ListManifestPropertiesOptions = {},\n ): PagedAsyncIterableIterator<ArtifactManifestProperties, ManifestPageResponse> {\n const iter = this.listManifestsItems(options);\n\n return {\n next() {\n return iter.next();\n },\n [Symbol.asyncIterator]() {\n return this;\n },\n byPage: (settings: PageSettings = {}) => this.listManifestsPage(settings, options),\n };\n }\n\n private async *listManifestsItems(\n options: ListManifestPropertiesOptions = {},\n ): AsyncIterableIterator<ArtifactManifestProperties> {\n for await (const page of this.listManifestsPage({}, options)) {\n yield* page;\n }\n }\n\n private async *listManifestsPage(\n continuationState: PageSettings,\n options: ListManifestPropertiesOptions = {},\n ): AsyncIterableIterator<ManifestPageResponse> {\n const orderby = toServiceManifestOrderBy(options.order);\n if (!continuationState.continuationToken) {\n const optionsComplete = {\n ...options,\n n: continuationState.maxPageSize,\n orderby,\n };\n const currentPage = await this.client.containerRegistry.getManifests(\n this.name,\n optionsComplete,\n );\n continuationState.continuationToken = extractNextLink(currentPage.link);\n if (currentPage.manifests) {\n const array = currentPage.manifests.map((t) =>\n toArtifactManifestProperties(t, this.name, currentPage.registryLoginServer!),\n );\n yield Object.defineProperty(array, \"continuationToken\", {\n value: continuationState.continuationToken,\n enumerable: true,\n });\n }\n }\n while (continuationState.continuationToken) {\n const currentPage = await this.client.containerRegistry.getManifestsNext(\n this.name,\n continuationState.continuationToken,\n options,\n );\n continuationState.continuationToken = extractNextLink(currentPage.link);\n if (currentPage.manifests) {\n const array = currentPage.manifests.map((t) =>\n toArtifactManifestProperties(t, this.name, currentPage.registryLoginServer!),\n );\n yield Object.defineProperty(array, \"continuationToken\", {\n value: continuationState.continuationToken,\n enumerable: true,\n });\n }\n }\n }\n}\n"]}
1
+ {"version":3,"file":"containerRepository.js","sourceRoot":"","sources":["../../src/containerRepository.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAQlC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAQ7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,4BAA4B,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAC9F,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAqHrD;;;GAGG;AACH,MAAM,OAAO,uBAAuB;IACjB,MAAM,CAAkB;IACzC;;OAEG;IACa,gBAAgB,CAAS;IACzC;;OAEG;IACa,IAAI,CAAS;IAE7B;;;;;OAKG;IACH,YAAY,gBAAwB,EAAE,IAAY,EAAE,MAAuB;QACzE,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QACzC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QAEjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,MAAM,CAAC,UAAmC,EAAE;QACvD,OAAO,aAAa,CAAC,QAAQ,CAC3B,gCAAgC,EAChC,OAAO,EACP,KAAK,EAAE,cAAc,EAAE,EAAE;YACvB,MAAM,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;QAClF,CAAC,CACF,CAAC;IACJ,CAAC;IAED;;;OAGG;IACI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AK,EAAE,mBAAmB,EAAE;oBACtD,KAAK,EAAE,iBAAiB,CAAC,iBAAiB;oBAC1C,UAAU,EAAE,IAAI;iBACjB,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QACD,OAAO,iBAAiB,CAAC,iBAAiB,EAAE,CAAC;YAC3C,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,gBAAgB,CACtE,IAAI,CAAC,IAAI,EACT,iBAAiB,CAAC,iBAAiB,EACnC,OAAO,CACR,CAAC;YACF,iBAAiB,CAAC,iBAAiB,GAAG,eAAe,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;YACxE,IAAI,WAAW,CAAC,SAAS,EAAE,CAAC;gBAC1B,MAAM,KAAK,GAAG,WAAW,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAC5C,4BAA4B,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,EAAE,WAAW,CAAC,mBAAoB,CAAC,CAC7E,CAAC;gBACF,MAAM,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,mBAAmB,EAAE;oBACtD,KAAK,EAAE,iBAAiB,CAAC,iBAAiB;oBAC1C,UAAU,EAAE,IAAI;iBACjB,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n/// <reference lib=\"esnext.asynciterable\" />\n\nimport type { OperationOptions } from \"@azure/core-client\";\nimport type { PageSettings, PagedAsyncIterableIterator } from \"@azure/core-paging\";\n\nimport type { GeneratedClient, RepositoryWriteableProperties } from \"./generated/index.js\";\nimport { tracingClient } from \"./tracing.js\";\nimport type {\n ArtifactManifestOrder,\n ContainerRepositoryProperties,\n ArtifactManifestProperties,\n ManifestPageResponse,\n} from \"./models.js\";\nimport type { RegistryArtifact } from \"./registryArtifact.js\";\nimport { RegistryArtifactImpl } from \"./registryArtifact.js\";\nimport { toArtifactManifestProperties, toServiceManifestOrderBy } from \"./transformations.js\";\nimport { extractNextLink } from \"./utils/helpers.js\";\n\n/**\n * Options for delete repository operation.\n */\nexport interface DeleteRepositoryOptions extends OperationOptions {}\n/**\n * Options for the `listRegistryArtifacts` method of `ContainerRepository`.\n */\nexport interface ListManifestPropertiesOptions extends OperationOptions {\n /** order in which the manifest properties are returned */\n order?: ArtifactManifestOrder;\n}\n/**\n * Options for the `getProperties` method of `ContainerRepository`.\n */\nexport interface GetRepositoryPropertiesOptions extends OperationOptions {}\n/**\n * Options for the `setProperties` method of `ContainerRepository`.\n */\nexport interface UpdateRepositoryPropertiesOptions extends OperationOptions {\n /** Whether or not this repository can be deleted */\n canDelete?: boolean;\n /** Whether or not this repository can be written to */\n canWrite?: boolean;\n /** Whether or not include this repository when listing repositories */\n canList?: boolean;\n /** Whether or not this repository can be read */\n canRead?: boolean;\n}\n\n/**\n * A `repository` in a container registry is a logical grouping of images or artifacts that share the same name. For example,\n * different versions of a `hello-world` application could have tags `v1` and `v2`, and be grouped by the repository `hello-world`.\n *\n * The {@link ContainerRepository} interface is a helper that groups information and operations about a repository in this\n * container registry.\n */\nexport interface ContainerRepository {\n /**\n * The Azure Container Registry endpoint.\n */\n readonly registryEndpoint: string;\n /**\n * Repository name.\n */\n readonly name: string;\n /**\n * Deletes this repository and all artifacts that are part of its logical group.\n *\n * @param options - optional configuration for the operation\n */\n delete(options?: DeleteRepositoryOptions): Promise<void>;\n /**\n * Returns an helper instance of {@link RegistryArtifact} for the given tag or digest.\n * @param tagOrDigest - the tag or digest of the artifact\n */\n getArtifact(tagOrDigest: string): RegistryArtifact;\n /**\n * Retrieves the properties of this repository.\n * @param options - The options for the operation.\n */\n getProperties(options?: GetRepositoryPropertiesOptions): Promise<ContainerRepositoryProperties>;\n /**\n * Updates the properties of this repository.\n *\n * Example usage:\n *\n * ```ts snippet:ContainerRepositoryUpdateProperties\n * import { ContainerRegistryClient } from \"@azure/container-registry\";\n * import { DefaultAzureCredential } from \"@azure/identity\";\n *\n * const endpoint = \"https://myregistryname.azurecr.io\";\n * const repositoryName = \"library/hello-world\";\n * const client = new ContainerRegistryClient(endpoint, new DefaultAzureCredential());\n * const repository = client.getRepository(repositoryName);\n *\n * const updated = await repository.updateProperties({\n * canDelete: false,\n * canList: false,\n * canRead: false,\n * canWrite: false,\n * });\n * ```\n * @param options - The options for the operation.\n */\n updateProperties(\n options: UpdateRepositoryPropertiesOptions,\n ): Promise<ContainerRepositoryProperties>;\n /**\n * Returns an async iterable iterator to list manifest properties.\n * This is useful for determining the collection of artifacts associated with\n * this repository, as each artifact is uniquely identified by its manifest.\n *\n * Example using `for-await-of` syntax:\n *\n * ```ts snippet:ContainerRepositoryListManifestProperties\n * import { ContainerRegistryClient } from \"@azure/container-registry\";\n * import { DefaultAzureCredential } from \"@azure/identity\";\n *\n * const endpoint = \"https://myregistryname.azurecr.io\";\n * const repositoryName = \"library/hello-world\";\n * const client = new ContainerRegistryClient(endpoint, new DefaultAzureCredential());\n * const repository = client.getRepository(repositoryName);\n *\n * for await (const manifest of repository.listManifestProperties()) {\n * console.log(\"manifest: \", manifest);\n * }\n * ```\n *\n * @param options - The options for the operation.\n */\n listManifestProperties(\n options?: ListManifestPropertiesOptions,\n ): PagedAsyncIterableIterator<ArtifactManifestProperties>;\n}\n\n/**\n * The client class used to interact with the Container Registry service.\n * @internal\n */\nexport class ContainerRepositoryImpl {\n private readonly client: GeneratedClient;\n /**\n * The Azure Container Registry endpoint.\n */\n public readonly registryEndpoint: string;\n /**\n * Repository name.\n */\n public readonly name: string;\n\n /**\n * Creates an instance of a ContainerRepository.\n * @param registryEndpoint - the URL to the Container Registry endpoint\n * @param name - the name of the repository\n * @param client - the generated client that interacts with service\n */\n constructor(registryEndpoint: string, name: string, client: GeneratedClient) {\n this.registryEndpoint = registryEndpoint;\n this.name = name;\n\n this.client = client;\n }\n\n /**\n * Deletes this repository and all artifacts that are part of its logical group.\n *\n * @param options - optional configuration for the operation\n */\n public async delete(options: DeleteRepositoryOptions = {}): Promise<void> {\n return tracingClient.withSpan(\n \"ContainerRepositoryImpl.delete\",\n options,\n async (updatedOptions) => {\n await this.client.containerRegistry.deleteRepository(this.name, updatedOptions);\n },\n );\n }\n\n /**\n * Returns an helper instance of {@link RegistryArtifact} for the given tag or digest.\n * @param tagOrDigest - the tag or digest of the artifact\n */\n public getArtifact(tagOrDigest: string): RegistryArtifact {\n if (!tagOrDigest) {\n throw new Error(\"invalid tagOrDigest\");\n }\n return new RegistryArtifactImpl(this.registryEndpoint, this.name, tagOrDigest, this.client);\n }\n\n /**\n * Retrieves the properties of this repository.\n * @param options - The options for the operation.\n */\n public async getProperties(\n options: GetRepositoryPropertiesOptions = {},\n ): Promise<ContainerRepositoryProperties> {\n return tracingClient.withSpan(\n \"ContainerRepositoryImpl.getProperties\",\n options,\n (updatedOptions) => {\n return this.client.containerRegistry.getProperties(this.name, updatedOptions);\n },\n );\n }\n\n /**\n * Updates the properties of this repository.\n *\n * Example usage:\n *\n * ```ts snippet:ContainerRepositoryUpdateProperties\n * import { ContainerRegistryClient } from \"@azure/container-registry\";\n * import { DefaultAzureCredential } from \"@azure/identity\";\n *\n * const endpoint = \"https://myregistryname.azurecr.io\";\n * const repositoryName = \"library/hello-world\";\n * const client = new ContainerRegistryClient(endpoint, new DefaultAzureCredential());\n * const repository = client.getRepository(repositoryName);\n *\n * const updated = await repository.updateProperties({\n * canDelete: false,\n * canList: false,\n * canRead: false,\n * canWrite: false,\n * });\n * ```\n * @param options - The options for the operation.\n */\n public async updateProperties(\n options: UpdateRepositoryPropertiesOptions,\n ): Promise<ContainerRepositoryProperties> {\n const value: RepositoryWriteableProperties = {\n canDelete: options.canDelete,\n canWrite: options.canWrite,\n canList: options.canList,\n canRead: options.canRead,\n };\n\n return tracingClient.withSpan(\n \"ContainerRepositoryImpl.updateProperties\",\n { ...options, value },\n (updatedOptions) => {\n return this.client.containerRegistry.updateProperties(this.name, updatedOptions);\n },\n );\n }\n\n /**\n * Returns an async iterable iterator to list manifest properties.\n * This is useful for determining the collection of artifacts associated with\n * this repository, as each artifact is uniquely identified by its manifest.\n *\n * Example using `for-await-of` syntax:\n *\n * ```ts snippet:ContainerRepositoryListManifestProperties\n * import { ContainerRegistryClient } from \"@azure/container-registry\";\n * import { DefaultAzureCredential } from \"@azure/identity\";\n *\n * const endpoint = \"https://myregistryname.azurecr.io\";\n * const repositoryName = \"library/hello-world\";\n * const client = new ContainerRegistryClient(endpoint, new DefaultAzureCredential());\n * const repository = client.getRepository(repositoryName);\n *\n * for await (const manifest of repository.listManifestProperties()) {\n * console.log(\"manifest: \", manifest);\n * }\n * ```\n *\n * @param options - The options for the operation.\n */\n public listManifestProperties(\n options: ListManifestPropertiesOptions = {},\n ): PagedAsyncIterableIterator<ArtifactManifestProperties, ManifestPageResponse> {\n const iter = this.listManifestsItems(options);\n\n return {\n next() {\n return iter.next();\n },\n [Symbol.asyncIterator]() {\n return this;\n },\n byPage: (settings: PageSettings = {}) => this.listManifestsPage(settings, options),\n };\n }\n\n private async *listManifestsItems(\n options: ListManifestPropertiesOptions = {},\n ): AsyncIterableIterator<ArtifactManifestProperties> {\n for await (const page of this.listManifestsPage({}, options)) {\n yield* page;\n }\n }\n\n private async *listManifestsPage(\n continuationState: PageSettings,\n options: ListManifestPropertiesOptions = {},\n ): AsyncIterableIterator<ManifestPageResponse> {\n const orderby = toServiceManifestOrderBy(options.order);\n if (!continuationState.continuationToken) {\n const optionsComplete = {\n ...options,\n n: continuationState.maxPageSize,\n orderby,\n };\n const currentPage = await this.client.containerRegistry.getManifests(\n this.name,\n optionsComplete,\n );\n continuationState.continuationToken = extractNextLink(currentPage.link);\n if (currentPage.manifests) {\n const array = currentPage.manifests.map((t) =>\n toArtifactManifestProperties(t, this.name, currentPage.registryLoginServer!),\n );\n yield Object.defineProperty(array, \"continuationToken\", {\n value: continuationState.continuationToken,\n enumerable: true,\n });\n }\n }\n while (continuationState.continuationToken) {\n const currentPage = await this.client.containerRegistry.getManifestsNext(\n this.name,\n continuationState.continuationToken,\n options,\n );\n continuationState.continuationToken = extractNextLink(currentPage.link);\n if (currentPage.manifests) {\n const array = currentPage.manifests.map((t) =>\n toArtifactManifestProperties(t, this.name, currentPage.registryLoginServer!),\n );\n yield Object.defineProperty(array, \"continuationToken\", {\n value: continuationState.continuationToken,\n enumerable: true,\n });\n }\n }\n }\n}\n"]}
@@ -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,a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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"]}
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,sBAAsB,CAAC,gBAAgB;IACvC,sBAAsB,CAAC,cAAc;IACrC,yCAAyC;IACzC,2DAA2D;IAC3D,gDAAgD;CACjD,CAAC;AAEF,SAAS,gBAAgB,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,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,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AAC;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;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/generat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C,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"]}