-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
70 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
type Bundle<T> = Array<Main<T> | Delta<T> | { dimensions: [{ [dimension: string]: Dimension }] }>; | ||
|
||
type Context = { [dimension: string]: string }; | ||
|
||
type Delta<T> = { | ||
settings: Settings<[`${string}:${string}`, ...Array<`${string}:${string}`>]>; | ||
} & DeepPartial<T>; | ||
|
||
type DeepPartial<T> = T extends object | ||
? { | ||
[P in keyof T]?: DeepPartial<T[P]>; | ||
} | ||
: T; | ||
|
||
type Dimension = { [dimension: string]: Dimension | null }; | ||
|
||
type Main<T> = { settings: Settings<['main' | 'master']> } & T; | ||
|
||
type Schedule = { start?: string; end?: string }; | ||
|
||
type Settings<T> = T | { dimensions: T; schedule?: Schedule }; | ||
|
||
declare module 'ycb' { | ||
class Ycb<T extends Object> { | ||
constructor(bundle: Bundle<T>, options?: { logContext?: string }); | ||
read( | ||
context: Context, | ||
options?: { | ||
applySubstitutions?: boolean; | ||
}, | ||
): T; | ||
readNoMerge( | ||
context: Context, | ||
options?: { | ||
applySubstitutions?: boolean; | ||
}, | ||
): T[]; | ||
readTimeAware( | ||
context: Context, | ||
time: number, | ||
options?: { | ||
applySubstitutions?: boolean; | ||
cacheInfo?: boolean; | ||
}, | ||
): T; | ||
readNoMergeTimeAware( | ||
context: Context, | ||
time: number, | ||
options?: { | ||
applySubstitutions?: boolean; | ||
cacheInfo?: boolean; | ||
}, | ||
): T[]; | ||
} | ||
|
||
function read<T>(bundle: Bundle<T>, context: Context, validate?: boolean, debug?: boolean): T; | ||
function readNoMerge<T>(bundle: Bundle<T>, context: Context, validate?: boolean, debug?: boolean): T; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,36 +2,37 @@ | |
"name": "ycb", | ||
"version": "2.2.0", | ||
"description": "YCB is a multi-dimensional configuration library that builds bundles from resource files describing a variety of values.", | ||
"author": "Ric Allinson <[email protected]>", | ||
"bugs": "https://github.com/yahoo/ycb/issues", | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/yahoo/ycb.git" | ||
}, | ||
"license": "BSD", | ||
"author": "Ric Allinson <[email protected]>", | ||
"contributors": [ | ||
"Drew Folta <[email protected]>", | ||
"Michael Ridgway <[email protected]>", | ||
"Caridy Patino <[email protected]>", | ||
"Isao Yagi <[email protected]>" | ||
], | ||
"main": "index", | ||
"types": "index.d.ts", | ||
"scripts": { | ||
"cover": "nyc npm run test", | ||
"lint": "eslint . && prettier --check .", | ||
"lint:fix": "eslint . --fix && prettier --write .", | ||
"pretest": "npm run lint", | ||
"test": "mocha tests/unit --recursive --reporter spec" | ||
}, | ||
"prettier": { | ||
"printWidth": 120, | ||
"singleQuote": true, | ||
"tabWidth": 4 | ||
}, | ||
"devDependencies": { | ||
"eslint": "^9.0.0", | ||
"mocha": "^10.0.0", | ||
"nyc": "^17.0.0", | ||
"prettier": "^3.0.0" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/yahoo/ycb.git" | ||
}, | ||
"bugs": "https://github.com/yahoo/ycb/issues", | ||
"prettier": { | ||
"printWidth": 120, | ||
"singleQuote": true, | ||
"tabWidth": 4 | ||
} | ||
} |