@azure/app-configuration-importer 1.0.0-preview → 1.0.1-preview

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 (86) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +67 -0
  3. package/dist/index.js +77 -10
  4. package/dist/index.js.map +1 -1
  5. package/dist-esm/src/appConfigurationImporter.js +157 -0
  6. package/dist-esm/src/appConfigurationImporter.js.map +1 -0
  7. package/dist-esm/src/enums.js +28 -0
  8. package/dist-esm/src/enums.js.map +1 -0
  9. package/dist-esm/src/errors.js +35 -0
  10. package/dist-esm/src/errors.js.map +1 -0
  11. package/dist-esm/src/importOptions.js +4 -0
  12. package/dist-esm/src/importOptions.js.map +1 -0
  13. package/dist-esm/src/index.js +9 -0
  14. package/dist-esm/src/index.js.map +1 -0
  15. package/dist-esm/src/internal/adaptiveTaskManager.js +69 -0
  16. package/dist-esm/src/internal/adaptiveTaskManager.js.map +1 -0
  17. package/dist-esm/src/internal/constants.js +29 -0
  18. package/dist-esm/src/internal/constants.js.map +1 -0
  19. package/dist-esm/src/internal/parsers/configurationSettingsConverter.js +4 -0
  20. package/dist-esm/src/internal/parsers/configurationSettingsConverter.js.map +1 -0
  21. package/dist-esm/src/internal/parsers/defaultConfigurationSettingsConverter.js +200 -0
  22. package/dist-esm/src/internal/parsers/defaultConfigurationSettingsConverter.js.map +1 -0
  23. package/dist-esm/src/internal/parsers/kvSetConfigurationSettingsConverter.js +66 -0
  24. package/dist-esm/src/internal/parsers/kvSetConfigurationSettingsConverter.js.map +1 -0
  25. package/dist-esm/src/internal/stream.browser.js +16 -0
  26. package/dist-esm/src/internal/stream.browser.js.map +1 -0
  27. package/dist-esm/src/internal/stream.js +15 -0
  28. package/dist-esm/src/internal/stream.js.map +1 -0
  29. package/dist-esm/src/internal/utils.js +129 -0
  30. package/dist-esm/src/internal/utils.js.map +1 -0
  31. package/dist-esm/src/models.js +4 -0
  32. package/dist-esm/src/models.js.map +1 -0
  33. package/dist-esm/src/settingsImport/configurationSettingsSource.js +4 -0
  34. package/dist-esm/src/settingsImport/configurationSettingsSource.js.map +1 -0
  35. package/dist-esm/src/settingsImport/iterableConfigurationSettingsSource.js +83 -0
  36. package/dist-esm/src/settingsImport/iterableConfigurationSettingsSource.js.map +1 -0
  37. package/dist-esm/src/settingsImport/readableStreamConfigurationSettingsSource.js +49 -0
  38. package/dist-esm/src/settingsImport/readableStreamConfigurationSettingsSource.js.map +1 -0
  39. package/dist-esm/src/settingsImport/stringConfigurationSettingsSource.js +92 -0
  40. package/dist-esm/src/settingsImport/stringConfigurationSettingsSource.js.map +1 -0
  41. package/package.json +19 -5
  42. package/types/src/appConfigurationImporter.d.ts +37 -0
  43. package/types/src/appConfigurationImporter.d.ts.map +1 -0
  44. package/types/src/enums.d.ts +23 -0
  45. package/types/src/enums.d.ts.map +1 -0
  46. package/types/src/errors.d.ts +25 -0
  47. package/types/src/errors.d.ts.map +1 -0
  48. package/types/src/importOptions.d.ts +39 -0
  49. package/types/src/importOptions.d.ts.map +1 -0
  50. package/types/src/index.d.ts +10 -0
  51. package/types/src/index.d.ts.map +1 -0
  52. package/types/src/internal/adaptiveTaskManager.d.ts +20 -0
  53. package/types/src/internal/adaptiveTaskManager.d.ts.map +1 -0
  54. package/types/src/internal/constants.d.ts +8 -0
  55. package/types/src/internal/constants.d.ts.map +1 -0
  56. package/types/src/internal/parsers/configurationSettingsConverter.d.ts +11 -0
  57. package/types/src/internal/parsers/configurationSettingsConverter.d.ts.map +1 -0
  58. package/types/src/internal/parsers/defaultConfigurationSettingsConverter.d.ts +20 -0
  59. package/types/src/internal/parsers/defaultConfigurationSettingsConverter.d.ts.map +1 -0
  60. package/types/src/internal/parsers/kvSetConfigurationSettingsConverter.d.ts +15 -0
  61. package/types/src/internal/parsers/kvSetConfigurationSettingsConverter.d.ts.map +1 -0
  62. package/types/src/internal/stream.browser.d.ts +4 -0
  63. package/types/src/internal/stream.browser.d.ts.map +1 -0
  64. package/types/src/internal/stream.d.ts +4 -0
  65. package/types/src/internal/stream.d.ts.map +1 -0
  66. package/types/src/internal/utils.d.ts +17 -0
  67. package/types/src/internal/utils.d.ts.map +1 -0
  68. package/types/src/models.d.ts +42 -0
  69. package/types/src/models.d.ts.map +1 -0
  70. package/types/src/settingsImport/configurationSettingsSource.d.ts +19 -0
  71. package/types/src/settingsImport/configurationSettingsSource.d.ts.map +1 -0
  72. package/types/src/settingsImport/iterableConfigurationSettingsSource.d.ts +14 -0
  73. package/types/src/settingsImport/iterableConfigurationSettingsSource.d.ts.map +1 -0
  74. package/types/src/settingsImport/readableStreamConfigurationSettingsSource.d.ts +11 -0
  75. package/types/src/settingsImport/readableStreamConfigurationSettingsSource.d.ts.map +1 -0
  76. package/types/src/settingsImport/stringConfigurationSettingsSource.d.ts +24 -0
  77. package/types/src/settingsImport/stringConfigurationSettingsSource.d.ts.map +1 -0
  78. package/NOTICE.txt +0 -370
  79. package/app-configuration-importer.test.log +0 -164
  80. package/dist/app-configuration-importer.api.md +0 -136
  81. package/examples/README.md +0 -59
  82. package/examples/package.json +0 -32
  83. package/examples/sample.env +0 -6
  84. package/examples/testFiles/default.json +0 -24
  85. package/examples/testFiles/kvset.json +0 -35
  86. package/types/tsdoc-metadata.json +0 -11
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Microsoft Corporation.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE
package/README.md ADDED
@@ -0,0 +1,67 @@
1
+ # Azure App Configuration - JavaScript Importer
2
+
3
+ The [Azure App Configuration](https://docs.microsoft.com/azure/azure-app-configuration/overview) Importer for JavaScript enables developers to import their configuration settings from a configuration sources to Azure App Configuration service.
4
+
5
+ Key links:
6
+
7
+ - [Source code](https://github.com/Azure/AppConfiguration-JavaScriptImporter/tree/main/libraries/azure-app-configuration-importer)
8
+ - [Package (NPM)](https://www.npmjs.com/package/@azure/app-configuration-importer)
9
+ - [Product documentation](https://docs.microsoft.com/azure/azure-app-configuration/)
10
+ - [Examples](https://github.com/Azure/AppConfiguration-JavaScriptImporter/tree/main/libraries/azure-app-configuration-importer/examples)
11
+
12
+ ## Getting started
13
+
14
+ ### Currently supported environments
15
+
16
+ - [LTS versions of Node.js](https://github.com/nodejs/release#release-schedule)
17
+ - Latest versions of Safari, Chrome, Edge, and Firefox.
18
+
19
+ ### Prerequisites
20
+
21
+ - An [Azure Subscription](https://azure.microsoft.com)
22
+ - An [App Configuration store](https://learn.microsoft.com/azure/azure-app-configuration/quickstart-azure-app-configuration-create?tabs=azure-portal) resource
23
+
24
+ ### Install the package
25
+
26
+ ```bash
27
+ npm install @azure/app-configuration-importer
28
+ ```
29
+
30
+ ### Use the API
31
+
32
+ ```ts
33
+ import { AppConfigurationImporter, StringConfigurationSettingsSource } from "@azure/app-configuration-importer";
34
+
35
+ const client = new AppConfigurationClient("<app-configuration-connection-string>");
36
+ const appConfigurationImporterClient = new AppConfigurationImporter(client);
37
+
38
+ // Import settings
39
+ const result = await appConfigurationImporterClient.Import(new StringConfigurationSettingsSource({data: "{\"app:Settings:FontSize\": \"45\"}", format: ConfigurationFormat.Json}));
40
+ ```
41
+
42
+
43
+ ## Examples
44
+
45
+ See code snippets under [examples/](./examples/) folder.
46
+
47
+ ## Contributing
48
+
49
+ This project welcomes contributions and suggestions. Most contributions require you to agree to a
50
+ Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
51
+ the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.
52
+
53
+ When you submit a pull request, a CLA bot will automatically determine whether you need to provide
54
+ a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions
55
+ provided by the bot. You will only need to do this once across all repos using our CLA.
56
+
57
+ This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
58
+ For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
59
+ contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
60
+
61
+ ## Trademarks
62
+
63
+ This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft
64
+ trademarks or logos is subject to and must follow
65
+ [Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/legal/intellectualproperty/trademarks/usage/general).
66
+ Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.
67
+ Any use of third-party trademarks or logos are subject to those third-party's policies.
package/dist/index.js CHANGED
@@ -1,8 +1,12 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('stream')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'stream'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["azure-app-configuration-importer"] = {}, global.stream));
5
- })(this, (function (exports, stream) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('node:crypto'), require('stream')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'node:crypto', 'stream'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["azure-app-configuration-importer"] = {}, global.crypto, global.stream));
5
+ })(this, (function (exports, crypto, stream) { 'use strict';
6
+
7
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
+
9
+ var crypto__default = /*#__PURE__*/_interopDefaultLegacy(crypto);
6
10
 
7
11
  /******************************************************************************
8
12
  Copyright (c) Microsoft Corporation.
@@ -18157,7 +18161,8 @@
18157
18161
  "__",
18158
18162
  "/",
18159
18163
  ":"
18160
- ]
18164
+ ],
18165
+ CorrelationRequestIdHeader: "x-ms-correlation-request-id"
18161
18166
  };
18162
18167
 
18163
18168
  // Copyright (c) Microsoft Corporation.
@@ -18283,6 +18288,59 @@
18283
18288
  };
18284
18289
  }
18285
18290
 
18291
+ /**
18292
+ * Convert array of 16 byte values to UUID string format of the form:
18293
+ * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
18294
+ */
18295
+ const byteToHex = [];
18296
+ for (let i = 0; i < 256; ++i) {
18297
+ byteToHex.push((i + 0x100).toString(16).slice(1));
18298
+ }
18299
+ function unsafeStringify(arr, offset = 0) {
18300
+ // Note: Be careful editing this code! It's been tuned for performance
18301
+ // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
18302
+ //
18303
+ // Note to future-self: No, you can't remove the `toLowerCase()` call.
18304
+ // REF: https://github.com/uuidjs/uuid/pull/677#issuecomment-1757351351
18305
+ return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
18306
+ }
18307
+
18308
+ const rnds8Pool = new Uint8Array(256); // # of random values to pre-allocate
18309
+ let poolPtr = rnds8Pool.length;
18310
+ function rng() {
18311
+ if (poolPtr > rnds8Pool.length - 16) {
18312
+ crypto__default["default"].randomFillSync(rnds8Pool);
18313
+ poolPtr = 0;
18314
+ }
18315
+ return rnds8Pool.slice(poolPtr, poolPtr += 16);
18316
+ }
18317
+
18318
+ var native = {
18319
+ randomUUID: crypto__default["default"].randomUUID
18320
+ };
18321
+
18322
+ function v4(options, buf, offset) {
18323
+ if (native.randomUUID && !buf && !options) {
18324
+ return native.randomUUID();
18325
+ }
18326
+ options = options || {};
18327
+ const rnds = options.random || (options.rng || rng)();
18328
+
18329
+ // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
18330
+ rnds[6] = rnds[6] & 0x0f | 0x40;
18331
+ rnds[8] = rnds[8] & 0x3f | 0x80;
18332
+
18333
+ // Copy bytes to buffer, if provided
18334
+ if (buf) {
18335
+ offset = offset || 0;
18336
+ for (let i = 0; i < 16; ++i) {
18337
+ buf[offset + i] = rnds[i];
18338
+ }
18339
+ return buf;
18340
+ }
18341
+ return unsafeStringify(rnds);
18342
+ }
18343
+
18286
18344
  // Copyright (c) Microsoft Corporation.
18287
18345
  /**
18288
18346
  * Entrypoint class for sync configuration
@@ -18328,9 +18386,18 @@
18328
18386
  }
18329
18387
  srcKeyLabelLookUp[config.key][config.label || ""] = true;
18330
18388
  });
18389
+ // generate correlationRequestId for operations in the same activity
18390
+ const customCorrelationRequestId = v4();
18391
+ const customHeadersOption = {
18392
+ requestOptions: {
18393
+ customHeaders: {
18394
+ [Constants.CorrelationRequestIdHeader]: customCorrelationRequestId
18395
+ }
18396
+ }
18397
+ };
18331
18398
  if (strict || importMode == exports.ImportMode.IgnoreMatch) {
18332
18399
  try {
18333
- for (var _d = true, _e = __asyncValues(this.configurationClient.listConfigurationSettings(configSettingsSource.FilterOptions)), _f; _f = await _e.next(), _a = _f.done, !_a;) {
18400
+ for (var _d = true, _e = __asyncValues(this.configurationClient.listConfigurationSettings(Object.assign(Object.assign({}, configSettingsSource.FilterOptions), customHeadersOption))), _f; _f = await _e.next(), _a = _f.done, !_a;) {
18334
18401
  _c = _f.value;
18335
18402
  _d = false;
18336
18403
  try {
@@ -18364,7 +18431,7 @@
18364
18431
  this.printUpdatesToConsole(configSettings, configurationSettingToDelete);
18365
18432
  }
18366
18433
  else {
18367
- await this.applyUpdatesToServer(configSettings, configurationSettingToDelete, timeout, progressCallback);
18434
+ await this.applyUpdatesToServer(configSettings, configurationSettingToDelete, timeout, customHeadersOption, progressCallback);
18368
18435
  }
18369
18436
  }
18370
18437
  printUpdatesToConsole(settingsToAdd, settingsToDelete) {
@@ -18377,14 +18444,14 @@
18377
18444
  console.log(JSON.stringify({ key: setting.key, label: setting.label, contentType: setting.contentType, tags: setting.tags }));
18378
18445
  }
18379
18446
  }
18380
- async applyUpdatesToServer(settingsToAdd, settingsToDelete, timeout, progressCallback) {
18381
- const deleteTaskManager = this.newAdaptiveTaskManager((setting) => this.configurationClient.deleteConfigurationSetting(setting), settingsToDelete);
18447
+ async applyUpdatesToServer(settingsToAdd, settingsToDelete, timeout, options, progressCallback) {
18448
+ const deleteTaskManager = this.newAdaptiveTaskManager((setting) => this.configurationClient.deleteConfigurationSetting(setting, options), settingsToDelete);
18382
18449
  const startTime = Date.now();
18383
18450
  await this.executeTasksWithTimeout(deleteTaskManager, timeout);
18384
18451
  const endTime = Date.now();
18385
18452
  const deleteTimeConsumed = (endTime - startTime) / 1000;
18386
18453
  timeout -= deleteTimeConsumed;
18387
- const importTaskManager = this.newAdaptiveTaskManager((setting) => this.configurationClient.setConfigurationSetting(setting), settingsToAdd);
18454
+ const importTaskManager = this.newAdaptiveTaskManager((setting) => this.configurationClient.setConfigurationSetting(setting, options), settingsToAdd);
18388
18455
  await this.executeTasksWithTimeout(importTaskManager, timeout, progressCallback);
18389
18456
  }
18390
18457
  newAdaptiveTaskManager(task, configurationSettings) {