New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@app-config/core

Package Overview
Dependencies
Maintainers
2
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@app-config/core - npm Package Compare versions

Comparing version 2.5.1 to 2.5.2

3

dist/common.d.ts
import { JsonObject } from '@app-config/utils';
export declare type KeyFormatter = (key: string, separator: string) => string;
/** Strategy used in 'app-config vars' for variable names */
export declare function camelToScreamingCase(key: string, separator?: string): string;
/** Strategy used in 'app-config vars' to extract variable names from hierachy */
export declare function flattenObjectTree(obj: JsonObject, prefix?: string, separator?: string, formatter?: KeyFormatter): {
[key: string]: string;
};
/** Strategy for renaming keys, used for 'app-config vars' */
export declare function renameInFlattenedTree(flattened: {
[key: string]: string;
}, renames?: string[], keepOriginalKeys?: boolean): typeof flattened;

@@ -6,2 +6,3 @@ "use strict";

const logging_1 = require("@app-config/logging");
/** Strategy used in 'app-config vars' for variable names */
function camelToScreamingCase(key, separator = '_') {

@@ -15,2 +16,3 @@ return key

exports.camelToScreamingCase = camelToScreamingCase;
/** Strategy used in 'app-config vars' to extract variable names from hierachy */
function flattenObjectTree(obj, prefix = '', separator = '_', formatter = camelToScreamingCase) {

@@ -38,2 +40,3 @@ return Object.entries(obj).reduce((merged, [key, value]) => {

exports.flattenObjectTree = flattenObjectTree;
/** Strategy for renaming keys, used for 'app-config vars' */
function renameInFlattenedTree(flattened, renames = [], keepOriginalKeys = false) {

@@ -40,0 +43,0 @@ for (const rename of renames) {

import { Json } from '@app-config/utils';
import { ParsedValue, ParsingContext, ParsingExtension } from './parsed-value';
/**
* File formats that app-config supports.
*/
export declare enum FileType {

@@ -45,5 +48,17 @@ YAML = "YAML",

}
/**
* Converts a JSON object to a string, using specified file type.
*/
export declare function stringify(config: Json, fileType: FileType, minimal?: boolean): string;
/**
* Returns which file type to use, based on the file extension.
*/
export declare function filePathAssumedType(filePath: string): FileType;
/**
* Parses string based on a file format.
*/
export declare function parseRawString(contents: string, fileType: FileType): Promise<Json>;
/**
* Try to parse string as different file formats, returning the first that worked.
*/
export declare function guessFileType(contents: string): Promise<FileType>;

@@ -11,2 +11,5 @@ "use strict";

const errors_1 = require("./errors");
/**
* File formats that app-config supports.
*/
var FileType;

@@ -139,2 +142,5 @@ (function (FileType) {

exports.FallbackSource = FallbackSource;
/**
* Converts a JSON object to a string, using specified file type.
*/
function stringify(config, fileType, minimal = false) {

@@ -164,2 +170,5 @@ switch (fileType) {

exports.stringify = stringify;
/**
* Returns which file type to use, based on the file extension.
*/
function filePathAssumedType(filePath) {

@@ -181,2 +190,5 @@ switch (path_1.extname(filePath).toLowerCase().slice(1)) {

exports.filePathAssumedType = filePathAssumedType;
/**
* Parses string based on a file format.
*/
async function parseRawString(contents, fileType) {

@@ -198,2 +210,5 @@ var _a;

exports.parseRawString = parseRawString;
/**
* Try to parse string as different file formats, returning the first that worked.
*/
async function guessFileType(contents) {

@@ -200,0 +215,0 @@ for (const tryType of [FileType.JSON, FileType.TOML, FileType.JSON5, FileType.YAML]) {

import { JsonObject } from '@app-config/utils';
export declare type KeyFormatter = (key: string, separator: string) => string;
/** Strategy used in 'app-config vars' for variable names */
export declare function camelToScreamingCase(key: string, separator?: string): string;
/** Strategy used in 'app-config vars' to extract variable names from hierachy */
export declare function flattenObjectTree(obj: JsonObject, prefix?: string, separator?: string, formatter?: KeyFormatter): {
[key: string]: string;
};
/** Strategy for renaming keys, used for 'app-config vars' */
export declare function renameInFlattenedTree(flattened: {
[key: string]: string;
}, renames?: string[], keepOriginalKeys?: boolean): typeof flattened;
import { isObject } from '@app-config/utils';
import { logger } from '@app-config/logging';
/** Strategy used in 'app-config vars' for variable names */
export function camelToScreamingCase(key, separator = '_') {

@@ -10,2 +11,3 @@ return key

}
/** Strategy used in 'app-config vars' to extract variable names from hierachy */
export function flattenObjectTree(obj, prefix = '', separator = '_', formatter = camelToScreamingCase) {

@@ -32,2 +34,3 @@ return Object.entries(obj).reduce((merged, [key, value]) => {

}
/** Strategy for renaming keys, used for 'app-config vars' */
export function renameInFlattenedTree(flattened, renames = [], keepOriginalKeys = false) {

@@ -34,0 +37,0 @@ for (const rename of renames) {

import { Json } from '@app-config/utils';
import { ParsedValue, ParsingContext, ParsingExtension } from './parsed-value';
/**
* File formats that app-config supports.
*/
export declare enum FileType {

@@ -45,5 +48,17 @@ YAML = "YAML",

}
/**
* Converts a JSON object to a string, using specified file type.
*/
export declare function stringify(config: Json, fileType: FileType, minimal?: boolean): string;
/**
* Returns which file type to use, based on the file extension.
*/
export declare function filePathAssumedType(filePath: string): FileType;
/**
* Parses string based on a file format.
*/
export declare function parseRawString(contents: string, fileType: FileType): Promise<Json>;
/**
* Try to parse string as different file formats, returning the first that worked.
*/
export declare function guessFileType(contents: string): Promise<FileType>;

@@ -8,2 +8,5 @@ import { extname } from 'path';

import { AppConfigError, NotFoundError, ParsingError, BadFileType } from './errors';
/**
* File formats that app-config supports.
*/
export var FileType;

@@ -132,2 +135,5 @@ (function (FileType) {

}
/**
* Converts a JSON object to a string, using specified file type.
*/
export function stringify(config, fileType, minimal = false) {

@@ -156,2 +162,5 @@ switch (fileType) {

}
/**
* Returns which file type to use, based on the file extension.
*/
export function filePathAssumedType(filePath) {

@@ -172,2 +181,5 @@ switch (extname(filePath).toLowerCase().slice(1)) {

}
/**
* Parses string based on a file format.
*/
export async function parseRawString(contents, fileType) {

@@ -187,2 +199,5 @@ switch (fileType) {

}
/**
* Try to parse string as different file formats, returning the first that worked.
*/
export async function guessFileType(contents) {

@@ -189,0 +204,0 @@ for (const tryType of [FileType.JSON, FileType.TOML, FileType.JSON5, FileType.YAML]) {

@@ -11,6 +11,18 @@ /// <reference types="node" />

export declare const Root: unique symbol;
/** Descriptor for what "key" that a value was defined under within JSON */
export declare type ParsingExtensionKey = [typeof InObject, string] | [typeof InArray, number] | [typeof Root];
/**
* Arbitrary context that's passed through the hierachy during parsing, only downwards.
*
* This is used for environment overrides and other options, so that parsing below some
* level in an object tree can override what the current environment is.
*/
export interface ParsingContext {
[k: string]: string | string[] | undefined | ParsingContext;
}
/**
* Performs transformations on raw values that were read.
*
* See https://app-config.dev/guide/intro/extensions.html
*/
export interface ParsingExtension {

@@ -25,3 +37,7 @@ (value: Json, key: ParsingExtensionKey, parentKeys: ParsingExtensionKey[], context: ParsingContext): ParsingExtensionTransform | false;

}
/**
* Callback that will process and potentially transform a value.
*/
export declare type ParsingExtensionTransform = (parse: (value: Json, metadata?: ParsedValueMetadata, source?: ConfigSource, extensions?: ParsingExtension[], context?: ParsingContext) => Promise<ParsedValue>, parent: JsonObject | Json[] | undefined, source: ConfigSource, extensions: ParsingExtension[], root: Json) => Promise<ParsedValue> | ParsedValue;
/** Values associated with a ParsedValue */
export interface ParsedValueMetadata {

@@ -46,21 +62,37 @@ [key: string]: any;

static parseLiteral(raw: Json, extensions?: ParsingExtension[]): Promise<ParsedValue>;
/** Deep merge two ParsedValue objects */
static merge(a: ParsedValue, b: ParsedValue): ParsedValue;
/** Returns the first ConfigSource that is of some instance type */
getSource<CS extends ConfigSource>(clazz: new (...args: any[]) => CS): CS | undefined;
/** Returns the first ConfigSource that is of some instance type */
assertSource<CS extends ConfigSource>(clazz: new (...args: any[]) => CS): CS;
/** Returns all ConfigSource objects that contributed to this value (including nested) */
allSources(): Set<ConfigSource>;
/** Adds metadata to the ParsedValue */
assignMeta(metadata: ParsedValueMetadata): this;
/** Removes metadata by key */
removeMeta(key: string): this;
/** Lookup property by nested key */
/** Lookup property by nested key name(s) */
property([key, ...rest]: string[]): ParsedValue | undefined;
/** Returns JSON object if the value is one */
asObject(): {
[key: string]: ParsedValue;
} | undefined;
/** Returns JSON array if the value is one */
asArray(): ParsedValue[] | undefined;
/** Returns JSON primitive value if the value is one */
asPrimitive(): JsonPrimitive | undefined;
/** Returns if the underlying value is an object */
isObject(): boolean;
/** Returns if the underlying value is an array */
isArray(): boolean;
/** Returns if the underlying value is a primitive */
isPrimitive(): boolean;
/** Deep clones underlying value */
clone(): ParsedValue;
/** Deep clones underlying value, depending on a predicate function */
cloneWhere(filter: (value: ParsedValue) => boolean): ParsedValue;
/** Calls the function, with every nested ParsedValue */
visitAll(callback: (value: ParsedValue) => void): void;
/** Extracts underlying JSON value from the wrapper */
toJSON(): Json;

@@ -70,3 +102,4 @@ [inspect.custom](): string;

}
/** Same as ParsedValue.parse */
export declare function parseValue(value: Json, source: ConfigSource, extensions?: ParsingExtension[], metadata?: ParsedValueMetadata, context?: ParsingContext): Promise<ParsedValue>;
export {};

@@ -33,2 +33,3 @@ import { inspect } from 'util';

}
/** Deep merge two ParsedValue objects */
static merge(a, b) {

@@ -78,2 +79,3 @@ const meta = merge(a.meta, b.meta);

}
/** Returns the first ConfigSource that is of some instance type */
getSource(clazz) {

@@ -86,2 +88,3 @@ for (const source of this.sources) {

}
/** Returns the first ConfigSource that is of some instance type */
assertSource(clazz) {

@@ -94,2 +97,3 @@ const source = this.getSource(clazz);

}
/** Returns all ConfigSource objects that contributed to this value (including nested) */
allSources() {

@@ -113,2 +117,3 @@ const sources = new Set(this.sources);

}
/** Adds metadata to the ParsedValue */
assignMeta(metadata) {

@@ -118,2 +123,3 @@ Object.assign(this.meta, metadata);

}
/** Removes metadata by key */
removeMeta(key) {

@@ -123,3 +129,3 @@ delete this.meta[key];

}
/** Lookup property by nested key */
/** Lookup property by nested key name(s) */
property([key, ...rest]) {

@@ -136,2 +142,3 @@ if (key === '')

}
/** Returns JSON object if the value is one */
asObject() {

@@ -142,2 +149,3 @@ if (typeof this.value === 'object' && this.value !== null && !Array.isArray(this.value)) {

}
/** Returns JSON array if the value is one */
asArray() {

@@ -147,2 +155,3 @@ if (Array.isArray(this.value))

}
/** Returns JSON primitive value if the value is one */
asPrimitive() {

@@ -153,14 +162,19 @@ if ((typeof this.value !== 'object' || this.value === null) && !Array.isArray(this.value)) {

}
/** Returns if the underlying value is an object */
isObject() {
return this.asObject() !== undefined;
}
/** Returns if the underlying value is an array */
isArray() {
return this.asArray() !== undefined;
}
/** Returns if the underlying value is a primitive */
isPrimitive() {
return this.asPrimitive() !== undefined;
}
/** Deep clones underlying value */
clone() {
return this.cloneWhere(() => true);
}
/** Deep clones underlying value, depending on a predicate function */
cloneWhere(filter) {

@@ -189,2 +203,3 @@ if (Array.isArray(this.value)) {

}
/** Calls the function, with every nested ParsedValue */
visitAll(callback) {

@@ -203,2 +218,3 @@ callback(this);

}
/** Extracts underlying JSON value from the wrapper */
toJSON() {

@@ -251,2 +267,3 @@ if (Array.isArray(this.value)) {

}
/** Same as ParsedValue.parse */
export async function parseValue(value, source, extensions = [], metadata = {}, context = {}) {

@@ -253,0 +270,0 @@ return parseValueInner(value, source, extensions, metadata, context, [[Root]], value);

@@ -11,6 +11,18 @@ /// <reference types="node" />

export declare const Root: unique symbol;
/** Descriptor for what "key" that a value was defined under within JSON */
export declare type ParsingExtensionKey = [typeof InObject, string] | [typeof InArray, number] | [typeof Root];
/**
* Arbitrary context that's passed through the hierachy during parsing, only downwards.
*
* This is used for environment overrides and other options, so that parsing below some
* level in an object tree can override what the current environment is.
*/
export interface ParsingContext {
[k: string]: string | string[] | undefined | ParsingContext;
}
/**
* Performs transformations on raw values that were read.
*
* See https://app-config.dev/guide/intro/extensions.html
*/
export interface ParsingExtension {

@@ -25,3 +37,7 @@ (value: Json, key: ParsingExtensionKey, parentKeys: ParsingExtensionKey[], context: ParsingContext): ParsingExtensionTransform | false;

}
/**
* Callback that will process and potentially transform a value.
*/
export declare type ParsingExtensionTransform = (parse: (value: Json, metadata?: ParsedValueMetadata, source?: ConfigSource, extensions?: ParsingExtension[], context?: ParsingContext) => Promise<ParsedValue>, parent: JsonObject | Json[] | undefined, source: ConfigSource, extensions: ParsingExtension[], root: Json) => Promise<ParsedValue> | ParsedValue;
/** Values associated with a ParsedValue */
export interface ParsedValueMetadata {

@@ -46,21 +62,37 @@ [key: string]: any;

static parseLiteral(raw: Json, extensions?: ParsingExtension[]): Promise<ParsedValue>;
/** Deep merge two ParsedValue objects */
static merge(a: ParsedValue, b: ParsedValue): ParsedValue;
/** Returns the first ConfigSource that is of some instance type */
getSource<CS extends ConfigSource>(clazz: new (...args: any[]) => CS): CS | undefined;
/** Returns the first ConfigSource that is of some instance type */
assertSource<CS extends ConfigSource>(clazz: new (...args: any[]) => CS): CS;
/** Returns all ConfigSource objects that contributed to this value (including nested) */
allSources(): Set<ConfigSource>;
/** Adds metadata to the ParsedValue */
assignMeta(metadata: ParsedValueMetadata): this;
/** Removes metadata by key */
removeMeta(key: string): this;
/** Lookup property by nested key */
/** Lookup property by nested key name(s) */
property([key, ...rest]: string[]): ParsedValue | undefined;
/** Returns JSON object if the value is one */
asObject(): {
[key: string]: ParsedValue;
} | undefined;
/** Returns JSON array if the value is one */
asArray(): ParsedValue[] | undefined;
/** Returns JSON primitive value if the value is one */
asPrimitive(): JsonPrimitive | undefined;
/** Returns if the underlying value is an object */
isObject(): boolean;
/** Returns if the underlying value is an array */
isArray(): boolean;
/** Returns if the underlying value is a primitive */
isPrimitive(): boolean;
/** Deep clones underlying value */
clone(): ParsedValue;
/** Deep clones underlying value, depending on a predicate function */
cloneWhere(filter: (value: ParsedValue) => boolean): ParsedValue;
/** Calls the function, with every nested ParsedValue */
visitAll(callback: (value: ParsedValue) => void): void;
/** Extracts underlying JSON value from the wrapper */
toJSON(): Json;

@@ -70,3 +102,4 @@ [inspect.custom](): string;

}
/** Same as ParsedValue.parse */
export declare function parseValue(value: Json, source: ConfigSource, extensions?: ParsingExtension[], metadata?: ParsedValueMetadata, context?: ParsingContext): Promise<ParsedValue>;
export {};

@@ -39,2 +39,3 @@ "use strict";

}
/** Deep merge two ParsedValue objects */
static merge(a, b) {

@@ -85,2 +86,3 @@ var _a, _b;

}
/** Returns the first ConfigSource that is of some instance type */
getSource(clazz) {

@@ -93,2 +95,3 @@ for (const source of this.sources) {

}
/** Returns the first ConfigSource that is of some instance type */
assertSource(clazz) {

@@ -101,2 +104,3 @@ const source = this.getSource(clazz);

}
/** Returns all ConfigSource objects that contributed to this value (including nested) */
allSources() {

@@ -120,2 +124,3 @@ const sources = new Set(this.sources);

}
/** Adds metadata to the ParsedValue */
assignMeta(metadata) {

@@ -125,2 +130,3 @@ Object.assign(this.meta, metadata);

}
/** Removes metadata by key */
removeMeta(key) {

@@ -130,3 +136,3 @@ delete this.meta[key];

}
/** Lookup property by nested key */
/** Lookup property by nested key name(s) */
property([key, ...rest]) {

@@ -144,2 +150,3 @@ var _a, _b;

}
/** Returns JSON object if the value is one */
asObject() {

@@ -150,2 +157,3 @@ if (typeof this.value === 'object' && this.value !== null && !Array.isArray(this.value)) {

}
/** Returns JSON array if the value is one */
asArray() {

@@ -155,2 +163,3 @@ if (Array.isArray(this.value))

}
/** Returns JSON primitive value if the value is one */
asPrimitive() {

@@ -161,14 +170,19 @@ if ((typeof this.value !== 'object' || this.value === null) && !Array.isArray(this.value)) {

}
/** Returns if the underlying value is an object */
isObject() {
return this.asObject() !== undefined;
}
/** Returns if the underlying value is an array */
isArray() {
return this.asArray() !== undefined;
}
/** Returns if the underlying value is a primitive */
isPrimitive() {
return this.asPrimitive() !== undefined;
}
/** Deep clones underlying value */
clone() {
return this.cloneWhere(() => true);
}
/** Deep clones underlying value, depending on a predicate function */
cloneWhere(filter) {

@@ -197,2 +211,3 @@ if (Array.isArray(this.value)) {

}
/** Calls the function, with every nested ParsedValue */
visitAll(callback) {

@@ -211,2 +226,3 @@ callback(this);

}
/** Extracts underlying JSON value from the wrapper */
toJSON() {

@@ -260,2 +276,3 @@ if (Array.isArray(this.value)) {

}
/** Same as ParsedValue.parse */
async function parseValue(value, source, extensions = [], metadata = {}, context = {}) {

@@ -262,0 +279,0 @@ return parseValueInner(value, source, extensions, metadata, context, [[exports.Root]], value);

8

package.json
{
"name": "@app-config/core",
"description": "Core logic for App Config",
"version": "2.5.1",
"version": "2.5.2",
"license": "MPL-2.0",

@@ -33,4 +33,4 @@ "author": {

"dependencies": {
"@app-config/logging": "^2.5.1",
"@app-config/utils": "^2.5.1",
"@app-config/logging": "^2.5.2",
"@app-config/utils": "^2.5.2",
"@iarna/toml": "3",

@@ -42,3 +42,3 @@ "js-yaml": "^3.13.1",

"devDependencies": {
"@app-config/test-utils": "^2.5.1",
"@app-config/test-utils": "^2.5.2",
"@types/js-yaml": "3",

@@ -45,0 +45,0 @@ "@types/lodash.merge": "4"

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc