@azure/app-configuration-importer-file-source 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.
@@ -0,0 +1,33 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
3
+ import * as fs from "fs";
4
+ import { StringConfigurationSettingsSource, ArgumentNullError } from "@azure/app-configuration-importer";
5
+ /**
6
+ * ConfigurationSettingsSource implementation of file configuration source
7
+ */
8
+ export class FileConfigurationSettingsSource extends StringConfigurationSettingsSource {
9
+ constructor(fileOptions) {
10
+ super(Object.assign({ data: "" }, fileOptions));
11
+ if (!fileOptions) {
12
+ throw new ArgumentNullError("fileOptions argument is required.");
13
+ }
14
+ if (!fileOptions.filePath || fileOptions.filePath.trim().length <= 0) {
15
+ throw new ArgumentNullError("fileOptions.filePath cannot be null or empty.");
16
+ }
17
+ this.filePath = fileOptions.filePath;
18
+ }
19
+ /**
20
+ * @inheritdoc
21
+ */
22
+ async GetConfigurationSettings() {
23
+ try {
24
+ const data = fs.readFileSync(this.filePath).toString();
25
+ return super.getConfigurationSettingsInternal(data);
26
+ }
27
+ catch (error) {
28
+ error.message = `Error while importing configuration settings from ${this.filePath}: ${error.message}`;
29
+ throw error;
30
+ }
31
+ }
32
+ }
33
+ //# sourceMappingURL=fileConfigurationSettingsSource.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fileConfigurationSettingsSource.js","sourceRoot":"","sources":["../../src/fileConfigurationSettingsSource.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AAGzB,OAAO,EAAE,iCAAiC,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAEzG;;GAEG;AACH,MAAM,OAAO,+BAAgC,SAAQ,iCAAiC;IAGpF,YAAY,WAA8B;QACxC,KAAK,iBACH,IAAI,EAAE,EAAE,IACL,WAA4B,EAC/B,CAAC;QAEH,IAAI,CAAC,WAAW,EAAE;YAChB,MAAM,IAAI,iBAAiB,CAAC,mCAAmC,CAAC,CAAC;SAClE;QAED,IAAI,CAAC,WAAW,CAAC,QAAQ,IAAI,WAAW,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,MAAM,IAAI,CAAC,EAAE;YACpE,MAAM,IAAI,iBAAiB,CAAC,+CAA+C,CAAC,CAAC;SAC9E;QAED,IAAI,CAAC,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAC;IACvC,CAAC;IAED;;OAEG;IACa,KAAK,CAAC,wBAAwB;QAC5C,IAAI;YACF,MAAM,IAAI,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,QAAQ,EAAE,CAAC;YACvD,OAAO,KAAK,CAAC,gCAAgC,CAAC,IAAI,CAAC,CAAC;SACrD;QACD,OAAO,KAAU,EAAE;YACjB,KAAK,CAAC,OAAO,GAAG,qDAAqD,IAAI,CAAC,QAAQ,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC;YACvG,MAAM,KAAK,CAAC;SACb;IACH,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport * as fs from \"fs\";\nimport { SetConfigurationSettingParam, FeatureFlagValue, SecretReferenceValue } from \"@azure/app-configuration\";\nimport { FileSourceOptions, SourceOptions } from \"./fileSourceOptions\";\nimport { StringConfigurationSettingsSource, ArgumentNullError } from \"@azure/app-configuration-importer\";\n\n/**\n * ConfigurationSettingsSource implementation of file configuration source\n */\nexport class FileConfigurationSettingsSource extends StringConfigurationSettingsSource {\n private filePath: string;\n\n constructor(fileOptions: FileSourceOptions) {\n super({\n data: \"\",\n ...fileOptions as SourceOptions\n });\n\n if (!fileOptions) {\n throw new ArgumentNullError(\"fileOptions argument is required.\");\n }\n\n if (!fileOptions.filePath || fileOptions.filePath.trim().length <= 0) {\n throw new ArgumentNullError(\"fileOptions.filePath cannot be null or empty.\");\n }\n\n this.filePath = fileOptions.filePath;\n }\n\n /**\n * @inheritdoc\n */\n public override async GetConfigurationSettings(): Promise<SetConfigurationSettingParam<string | FeatureFlagValue | SecretReferenceValue>[]> {\n try {\n const data = fs.readFileSync(this.filePath).toString();\n return super.getConfigurationSettingsInternal(data);\n }\n catch (error: any) {\n error.message = `Error while importing configuration settings from ${this.filePath}: ${error.message}`;\n throw error;\n }\n }\n}"]}
@@ -0,0 +1,4 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+ export {};
4
+ //# sourceMappingURL=fileSourceOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fileSourceOptions.js","sourceRoot":"","sources":["../../src/fileSourceOptions.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { ConfigurationFormat, ConfigurationProfile } from \"@azure/app-configuration-importer\";\nimport { Tags } from \"./tags\";\n/**\n * Base options for configuration import\n *\n * @internal\n */\nexport type SourceOptions = {\n format: ConfigurationFormat;\n separator?: string;\n depth?: number;\n profile?: ConfigurationProfile;\n label?: string;\n skipFeatureFlags?: boolean;\n prefix?: string;\n contentType?: string;\n tags?: Tags;\n}\n\nexport type FileSourceOptions = SourceOptions & { filePath: string; };\n"]}
@@ -0,0 +1,4 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
3
+ export { FileConfigurationSettingsSource } from "./fileConfigurationSettingsSource";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,+BAA+B,EAAE,MAAM,mCAAmC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nexport { FileSourceOptions as FileConfigurationSyncOptions } from \"./fileSourceOptions\";\nexport { FileConfigurationSettingsSource } from \"./fileConfigurationSettingsSource\";\n"]}
@@ -0,0 +1,4 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+ export {};
4
+ //# sourceMappingURL=tags.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tags.js","sourceRoot":"","sources":["../../src/tags.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nexport interface Tags {\n [propertyName: string]: string;\n}"]}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@azure/app-configuration-importer-file-source",
3
3
  "author": "Microsoft Corporation",
4
4
  "description": "A client library for importing/exporting key-values between configuration file sources and Azure App Configuration service",
5
- "version": "1.0.0-preview",
5
+ "version": "1.0.1-preview",
6
6
  "sdk-type": "client",
7
7
  "keywords": [
8
8
  "node",
@@ -13,6 +13,17 @@
13
13
  "main": "./dist/index.js",
14
14
  "module": "./dist-esm/src/index.js",
15
15
  "types": "./types/azure-app-configuration-importer-file-source.d.ts",
16
+ "files": [
17
+ "dist/**/*.js",
18
+ "dist/**/*.js.map",
19
+ "dist-esm/src/**/*.js",
20
+ "dist-esm/src/**/*.js.map",
21
+ "types/src/**/*d.ts",
22
+ "types/src/**/*d.ts.map",
23
+ "types/azure-app-configuration-importer-file-source.d.ts",
24
+ "README.md",
25
+ "LICENSE"
26
+ ],
16
27
  "scripts": {
17
28
  "build": "npm run clean && tsc -p . && rollup -c && api-extractor run --local",
18
29
  "test": "cross-env TS_NODE_PROJECT=\"tsconfig.test.json\" mocha -r ts-node/register 'tests/**/*.ts'",
@@ -0,0 +1,15 @@
1
+ import { SetConfigurationSettingParam, FeatureFlagValue, SecretReferenceValue } from "@azure/app-configuration";
2
+ import { FileSourceOptions } from "./fileSourceOptions";
3
+ import { StringConfigurationSettingsSource } from "@azure/app-configuration-importer";
4
+ /**
5
+ * ConfigurationSettingsSource implementation of file configuration source
6
+ */
7
+ export declare class FileConfigurationSettingsSource extends StringConfigurationSettingsSource {
8
+ private filePath;
9
+ constructor(fileOptions: FileSourceOptions);
10
+ /**
11
+ * @inheritdoc
12
+ */
13
+ GetConfigurationSettings(): Promise<SetConfigurationSettingParam<string | FeatureFlagValue | SecretReferenceValue>[]>;
14
+ }
15
+ //# sourceMappingURL=fileConfigurationSettingsSource.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fileConfigurationSettingsSource.d.ts","sourceRoot":"","sources":["../../src/fileConfigurationSettingsSource.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,4BAA4B,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChH,OAAO,EAAE,iBAAiB,EAAiB,MAAM,qBAAqB,CAAC;AACvE,OAAO,EAAE,iCAAiC,EAAqB,MAAM,mCAAmC,CAAC;AAEzG;;GAEG;AACH,qBAAa,+BAAgC,SAAQ,iCAAiC;IACpF,OAAO,CAAC,QAAQ,CAAS;gBAEb,WAAW,EAAE,iBAAiB;IAiB1C;;OAEG;IACmB,wBAAwB,IAAI,OAAO,CAAC,4BAA4B,CAAC,MAAM,GAAG,gBAAgB,GAAG,oBAAoB,CAAC,EAAE,CAAC;CAU5I"}
@@ -0,0 +1,22 @@
1
+ import { ConfigurationFormat, ConfigurationProfile } from "@azure/app-configuration-importer";
2
+ import { Tags } from "./tags";
3
+ /**
4
+ * Base options for configuration import
5
+ *
6
+ * @internal
7
+ */
8
+ export type SourceOptions = {
9
+ format: ConfigurationFormat;
10
+ separator?: string;
11
+ depth?: number;
12
+ profile?: ConfigurationProfile;
13
+ label?: string;
14
+ skipFeatureFlags?: boolean;
15
+ prefix?: string;
16
+ contentType?: string;
17
+ tags?: Tags;
18
+ };
19
+ export type FileSourceOptions = SourceOptions & {
20
+ filePath: string;
21
+ };
22
+ //# sourceMappingURL=fileSourceOptions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fileSourceOptions.d.ts","sourceRoot":"","sources":["../../src/fileSourceOptions.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAC9F,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAAG;IACxB,MAAM,EAAE,mBAAmB,CAAC;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,oBAAoB,CAAC;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,IAAI,CAAC;CACf,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG,aAAa,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;CAAE,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { FileSourceOptions as FileConfigurationSyncOptions } from "./fileSourceOptions";
2
+ export { FileConfigurationSettingsSource } from "./fileConfigurationSettingsSource";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,IAAI,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AACxF,OAAO,EAAE,+BAA+B,EAAE,MAAM,mCAAmC,CAAC"}
@@ -0,0 +1,4 @@
1
+ export interface Tags {
2
+ [propertyName: string]: string;
3
+ }
4
+ //# sourceMappingURL=tags.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tags.d.ts","sourceRoot":"","sources":["../../src/tags.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,IAAI;IACnB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAAC;CAChC"}
@@ -1,20 +0,0 @@
1
- Invoking: cross-env TS_NODE_PROJECT="tsconfig.test.json" mocha -r ts-node/register 'tests/**/*.ts'
2
-
3
-
4
- File configuration source test
5
- ✔ Throw argument error when set unexpected option when the profile is kvset
6
- ✔ Throw argument error if format is not json when the profile is kvset
7
- ✔ Throw argument error if depth is set but separator is not
8
- ✔ Throw argument error if separator is not valid
9
- ✔ Throw error if file is not UTF8 encode
10
- ✔ Throw error if file is not valid json file
11
- ✔ Throw error if file is not valid yaml file
12
- ✔ Throw error if file content is not valid object
13
- ✔ Throw error if format is not json when the contentType is json
14
- ✔ Throw error if file path is empty or whitespace
15
- ✔ Ignore comments in json file
16
- ✔ Handle null value present in json file
17
-
18
-
19
- 12 passing (13ms)
20
-
@@ -1,30 +0,0 @@
1
- ## API Report File for "@azure/app-configuration-importer-file-source"
2
-
3
- > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4
-
5
- ```ts
6
-
7
- import { ConfigurationFormat } from '@azure/app-configuration-importer';
8
- import { ConfigurationProfile } from '@azure/app-configuration-importer';
9
- import { FeatureFlagValue } from '@azure/app-configuration';
10
- import { SecretReferenceValue } from '@azure/app-configuration';
11
- import { SetConfigurationSettingParam } from '@azure/app-configuration';
12
- import { StringConfigurationSettingsSource } from '@azure/app-configuration-importer';
13
-
14
- // @public
15
- export class FileConfigurationSettingsSource extends StringConfigurationSettingsSource {
16
- constructor(fileOptions: FileConfigurationSyncOptions);
17
- // (undocumented)
18
- GetConfigurationSettings(): Promise<SetConfigurationSettingParam<string | FeatureFlagValue | SecretReferenceValue>[]>;
19
- }
20
-
21
- // Warning: (ae-forgotten-export) The symbol "SourceOptions" needs to be exported by the entry point index.d.ts
22
- //
23
- // @public (undocumented)
24
- export type FileConfigurationSyncOptions = SourceOptions & {
25
- filePath: string;
26
- };
27
-
28
- // (No @packageDocumentation comment for this package)
29
-
30
- ```
@@ -1,11 +0,0 @@
1
- // This file is read by tools that parse documentation comments conforming to the TSDoc standard.
2
- // It should be published with your NPM package. It should not be tracked by Git.
3
- {
4
- "tsdocVersion": "0.12",
5
- "toolPackages": [
6
- {
7
- "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.47.0"
9
- }
10
- ]
11
- }