{"_id":"@andyrmitchell/typed-config","name":"@andyrmitchell/typed-config","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@andyrmitchell/typed-config","version":"0.1.0","description":"Get/set data from a config file with full TypeScript IDE autocomplete and TypeScript + Zod schema checking","exports":{".":{"module":"./dist/index.mjs","require":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"import":{"types":"./dist/index.d.mts","default":"./dist/index.mjs"},"types":"./dist/index.d.ts"}},"main":"./dist/index.js","module":"./dist/index.mjs","types":"./dist/index.d.ts","type":"commonjs","publishConfig":{"access":"public"},"scripts":{"build_release":"npm run build_prepare && np","build":"tsup","pkglint":"./build/publint_pipeable.sh","build_prepare":"npm run build && npm run pkglint","prepublishOnly":"npm run build_prepare","test":"jest","test:watch":"jest --watch","test_cli:user_input":"npx tsup-node --no-config --format esm --entry.test_cli_user_input ./src/user-input/examples/index.ts && node ./dist/test_cli_user_input.mjs && rm ./dist/test_cli_user_input.mjs"},"author":{"name":"andymitchell"},"license":"MIT","devDependencies":{"@babel/core":"^7.23.9","@babel/preset-env":"^7.23.9","@babel/preset-typescript":"^7.23.3","@supabase/supabase-js":"^2.43.4","@types/jest":"^29.5.12","@types/lodash-es":"^4.17.12","@types/node":"^20.14.0","@types/proper-lockfile":"^4.1.4","babel-jest":"^29.7.0","babel-plugin-transform-import-meta":"^2.2.1","jest":"^29.7.0","ts-jest":"^29.1.2","tsup":"^8.0.1","typescript":"^5.4.5"},"dependencies":{"@andyrmitchell/file-io":"^0.4.0","@andyrmitchell/objects":"^0.4.12","@andyrmitchell/utils":"^0.4.1","dot-prop":"^9.0.0","lodash-es":"^4.17.21","proper-lockfile":"^4.1.2","zod":"^3.23.8"},"keywords":["conf","config","configuration","environment","typescript","zod","schema"],"repository":{"type":"git","url":"git+https://github.com/andymitchell/typed-config.git"},"_id":"@andyrmitchell/typed-config@0.1.0","gitHead":"97d3f2229490fc6d1e0396282f6805996fc7893f","bugs":{"url":"https://github.com/andymitchell/typed-config/issues"},"homepage":"https://github.com/andymitchell/typed-config#readme","_nodeVersion":"18.18.2","_npmVersion":"9.8.1","dist":{"integrity":"sha512-DwSc+uwjvg2CbZzgVbNVaigUD5qqtqwqvxnm4RSnqrP387hj8vSY4x1mS6TrWNDbC/NARMJCMk3BeE64jAAX0A==","shasum":"d0ee087764e21ae37e0f0c9771556086590e3832","tarball":"https://registry.npmjs.org/@andyrmitchell/typed-config/-/typed-config-0.1.0.tgz","fileCount":7,"unpackedSize":22425,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDxL1E0g+sKKWKy7bA52df0Eqs9axT3k2nrHuCB/lzP1gIgUOY8xglpvcwWTsALNCRMDp3uNDO7/7h3OMt8SkCY05o="}]},"_npmUser":{"name":"andyrmitchell","email":"a.r.mitchell@gmail.com"},"directories":{},"maintainers":[{"name":"andyrmitchell","email":"a.r.mitchell@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/typed-config_0.1.0_1717588358244_0.3584375813419012"},"_hasShrinkwrap":false}},"time":{"created":"2024-06-05T11:52:38.098Z","0.1.0":"2024-06-05T11:52:38.414Z","modified":"2024-06-05T11:52:38.711Z"},"maintainers":[{"name":"andyrmitchell","email":"a.r.mitchell@gmail.com"}],"description":"Get/set data from a config file with full TypeScript IDE autocomplete and TypeScript + Zod schema checking","homepage":"https://github.com/andymitchell/typed-config#readme","keywords":["conf","config","configuration","environment","typescript","zod","schema"],"repository":{"type":"git","url":"git+https://github.com/andymitchell/typed-config.git"},"author":{"name":"andymitchell"},"bugs":{"url":"https://github.com/andymitchell/typed-config/issues"},"license":"MIT","readme":"## Typed Config\n\nGet/set data from a config file with full TypeScript IDE autocomplete and TypeScript + Zod schema checking\n\n### Supported Environments\n\n- Node \n- Deno (if imported with npm: prefix)\n\n## Install\n\n`npm i @andyrmitchell/typed-config`\n\n## How it works \n\nThe basic approach\n\n```typescript\n\nimport {TypedConfig} from '@andyrmitchell/typed-config';\n\n// The very basic approach\nconst confBasic = new TypedConfig();\nawait confBasic.set('dot.prop.path.to.value', 'hello world');\nconst valueBasic = confBasic.getSync('dot.prop.path.to.value'); // 'hello world'\n\n```\n\n\nMore examples\n\n```typescript\nimport {TypedConfig} from '@andyrmitchell/typed-config';\nimport { z } from 'zod';\n\nasync function main() {\n\n    // Customise location, to store in /<path-to-your-package>/config_store/confCustom.json\n    const confCustomStore = new TypedConfig({type: 'file', file: 'confCustom.json', path_from_package_root: 'config_store'});\n\n    // Make 'get' wait until any writes are complete on the file (i.e. lock file released)\n    const confAwaitGet = new TypedConfig();\n    await confAwaitGet.set('dot.prop.path.to.value', 'hello world');\n    const valueAwaitGet = await confAwaitGet.get('dot.prop.path.to.value'); // 'hello world'\n\n    // Let TypeScript hint/autocomplete/check your values\n    const confTyped = new TypedConfig<{name: string}>();\n    const valueTyped = confTyped.getSync('name'); // Path is now locked to 'name', per given type\n\n    // Use a schema to check values at runtime (and auto infer type)\n    const confSchemaBound = new TypedConfig(undefined, undefined, z.object({name: z.string()}));\n    const valueSchemaBound = confSchemaBound.get('name'); // Path is locked to 'name'\n    // EXPECT FAIL DUE TO NUMBER INSTEAD OF STRING: await confSchemaBound.set('name', 41);\n    // EXPECT FAIL DUE TO UNKNOWN KEY: await confSchemaBound.set('other', 'Bob');\n    await confSchemaBound.set('name', 'Bob');\n\n    // Use defaults (useful for more complex schemas where values are required)\n    const confSchemaBoundAndDefaultsFail = new TypedConfig(undefined, undefined, z.object({name: z.string(), age: z.number()}));\n    confSchemaBoundAndDefaultsFail.set('age', 41); // EXPECT FAIL DUE TO NO NAME PROVIDED, BUT SCHEMA REQUIRES\n    const confSchemaBoundAndDefaults = new TypedConfig(undefined, {name: 'Alice', age: 40}, z.object({name: z.string(), age: z.number()}));\n    confSchemaBoundAndDefaults.set('age', 41); // Works because name was set in default\n\n}\n```\n\n## Roadmap\n\n### Abstract the storage mechanism with an adapter\n\nE.g. be able to write to Postgres, be Deno native, etc. \n\n","readmeFilename":"README.MD"}