@percepta/utils 0.1.8 → 0.1.11
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.
- package/dist/config/getEnvConfig.cjs +32 -0
- package/dist/config/getEnvConfig.cjs.map +1 -0
- package/dist/config/getEnvConfig.d.cts +72 -0
- package/dist/config/getEnvConfig.d.cts.map +1 -0
- package/dist/config/getEnvConfig.d.ts +72 -0
- package/dist/config/getEnvConfig.d.ts.map +1 -0
- package/dist/config/getEnvConfig.js +31 -0
- package/dist/config/getEnvConfig.js.map +1 -0
- package/dist/config/index.d.cts +1 -0
- package/dist/config/index.d.ts +1 -0
- package/dist/index.cjs +16 -0
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +8 -0
- package/dist/utils/assertNever.cjs +8 -0
- package/dist/utils/assertNever.cjs.map +1 -0
- package/dist/utils/assertNever.d.cts +5 -0
- package/dist/utils/assertNever.d.cts.map +1 -0
- package/dist/utils/assertNever.d.ts +5 -0
- package/dist/utils/assertNever.d.ts.map +1 -0
- package/dist/utils/assertNever.js +8 -0
- package/dist/utils/assertNever.js.map +1 -0
- package/dist/utils/batchAsync.cjs +16 -0
- package/dist/utils/batchAsync.cjs.map +1 -0
- package/dist/utils/batchAsync.d.cts +5 -0
- package/dist/utils/batchAsync.d.cts.map +1 -0
- package/dist/utils/batchAsync.d.ts +5 -0
- package/dist/utils/batchAsync.d.ts.map +1 -0
- package/dist/utils/batchAsync.js +16 -0
- package/dist/utils/batchAsync.js.map +1 -0
- package/dist/utils/index.d.cts +6 -0
- package/dist/utils/index.d.ts +6 -0
- package/dist/utils/logNever.cjs +9 -0
- package/dist/utils/logNever.cjs.map +1 -0
- package/dist/utils/logNever.d.cts +6 -0
- package/dist/utils/logNever.d.cts.map +1 -0
- package/dist/utils/logNever.d.ts +6 -0
- package/dist/utils/logNever.d.ts.map +1 -0
- package/dist/utils/logNever.js +9 -0
- package/dist/utils/logNever.js.map +1 -0
- package/dist/utils/promiseAllValues.cjs +9 -0
- package/dist/utils/promiseAllValues.cjs.map +1 -0
- package/dist/utils/promiseAllValues.d.cts +6 -0
- package/dist/utils/promiseAllValues.d.cts.map +1 -0
- package/dist/utils/promiseAllValues.d.ts +6 -0
- package/dist/utils/promiseAllValues.d.ts.map +1 -0
- package/dist/utils/promiseAllValues.js +9 -0
- package/dist/utils/promiseAllValues.js.map +1 -0
- package/dist/utils/replaceAt.cjs +18 -0
- package/dist/utils/replaceAt.cjs.map +1 -0
- package/dist/{esnext/utils/replaceAt.d.ts → utils/replaceAt.d.cts} +5 -2
- package/dist/utils/replaceAt.d.cts.map +1 -0
- package/dist/{cjs/utils → utils}/replaceAt.d.ts +4 -1
- package/dist/utils/replaceAt.d.ts.map +1 -0
- package/dist/utils/replaceAt.js +18 -0
- package/dist/utils/replaceAt.js.map +1 -0
- package/dist/utils/zodKeyedTypeUnion.cjs +16 -0
- package/dist/utils/zodKeyedTypeUnion.cjs.map +1 -0
- package/dist/utils/zodKeyedTypeUnion.d.cts +18 -0
- package/dist/utils/zodKeyedTypeUnion.d.cts.map +1 -0
- package/dist/utils/zodKeyedTypeUnion.d.ts +18 -0
- package/dist/utils/zodKeyedTypeUnion.d.ts.map +1 -0
- package/dist/utils/zodKeyedTypeUnion.js +16 -0
- package/dist/utils/zodKeyedTypeUnion.js.map +1 -0
- package/package.json +28 -18
- package/dist/cjs/config/getEnvConfig.d.ts +0 -164
- package/dist/cjs/config/getEnvConfig.d.ts.map +0 -1
- package/dist/cjs/config/getEnvConfig.js +0 -30
- package/dist/cjs/config/getEnvConfig.js.map +0 -1
- package/dist/cjs/config/index.d.ts +0 -2
- package/dist/cjs/config/index.d.ts.map +0 -1
- package/dist/cjs/config/index.js +0 -18
- package/dist/cjs/config/index.js.map +0 -1
- package/dist/cjs/index.d.ts +0 -3
- package/dist/cjs/index.d.ts.map +0 -1
- package/dist/cjs/index.js +0 -19
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/tsconfig.tsbuildinfo +0 -1
- package/dist/cjs/utils/__tests__/assertNever.test.d.ts +0 -2
- package/dist/cjs/utils/__tests__/assertNever.test.d.ts.map +0 -1
- package/dist/cjs/utils/__tests__/assertNever.test.js +0 -21
- package/dist/cjs/utils/__tests__/assertNever.test.js.map +0 -1
- package/dist/cjs/utils/assertNever.d.ts +0 -2
- package/dist/cjs/utils/assertNever.d.ts.map +0 -1
- package/dist/cjs/utils/assertNever.js +0 -7
- package/dist/cjs/utils/assertNever.js.map +0 -1
- package/dist/cjs/utils/index.d.ts +0 -6
- package/dist/cjs/utils/index.d.ts.map +0 -1
- package/dist/cjs/utils/index.js +0 -22
- package/dist/cjs/utils/index.js.map +0 -1
- package/dist/cjs/utils/logNever.d.ts +0 -3
- package/dist/cjs/utils/logNever.d.ts.map +0 -1
- package/dist/cjs/utils/logNever.js +0 -8
- package/dist/cjs/utils/logNever.js.map +0 -1
- package/dist/cjs/utils/promiseAllValues.d.ts +0 -6
- package/dist/cjs/utils/promiseAllValues.d.ts.map +0 -1
- package/dist/cjs/utils/promiseAllValues.js +0 -12
- package/dist/cjs/utils/promiseAllValues.js.map +0 -1
- package/dist/cjs/utils/replaceAt.d.ts.map +0 -1
- package/dist/cjs/utils/replaceAt.js +0 -17
- package/dist/cjs/utils/replaceAt.js.map +0 -1
- package/dist/cjs/utils/zodKeyedTypeUnion.d.ts +0 -17
- package/dist/cjs/utils/zodKeyedTypeUnion.d.ts.map +0 -1
- package/dist/cjs/utils/zodKeyedTypeUnion.js +0 -15
- package/dist/cjs/utils/zodKeyedTypeUnion.js.map +0 -1
- package/dist/esnext/config/getEnvConfig.d.ts +0 -164
- package/dist/esnext/config/getEnvConfig.d.ts.map +0 -1
- package/dist/esnext/config/getEnvConfig.js +0 -26
- package/dist/esnext/config/getEnvConfig.js.map +0 -1
- package/dist/esnext/config/index.d.ts +0 -2
- package/dist/esnext/config/index.d.ts.map +0 -1
- package/dist/esnext/config/index.js +0 -2
- package/dist/esnext/config/index.js.map +0 -1
- package/dist/esnext/index.d.ts +0 -3
- package/dist/esnext/index.d.ts.map +0 -1
- package/dist/esnext/index.js +0 -3
- package/dist/esnext/index.js.map +0 -1
- package/dist/esnext/tsconfig.tsbuildinfo +0 -1
- package/dist/esnext/utils/__tests__/assertNever.test.d.ts +0 -2
- package/dist/esnext/utils/__tests__/assertNever.test.d.ts.map +0 -1
- package/dist/esnext/utils/__tests__/assertNever.test.js +0 -19
- package/dist/esnext/utils/__tests__/assertNever.test.js.map +0 -1
- package/dist/esnext/utils/assertNever.d.ts +0 -2
- package/dist/esnext/utils/assertNever.d.ts.map +0 -1
- package/dist/esnext/utils/assertNever.js +0 -4
- package/dist/esnext/utils/assertNever.js.map +0 -1
- package/dist/esnext/utils/index.d.ts +0 -6
- package/dist/esnext/utils/index.d.ts.map +0 -1
- package/dist/esnext/utils/index.js +0 -6
- package/dist/esnext/utils/index.js.map +0 -1
- package/dist/esnext/utils/logNever.d.ts +0 -3
- package/dist/esnext/utils/logNever.d.ts.map +0 -1
- package/dist/esnext/utils/logNever.js +0 -5
- package/dist/esnext/utils/logNever.js.map +0 -1
- package/dist/esnext/utils/promiseAllValues.d.ts +0 -6
- package/dist/esnext/utils/promiseAllValues.d.ts.map +0 -1
- package/dist/esnext/utils/promiseAllValues.js +0 -9
- package/dist/esnext/utils/promiseAllValues.js.map +0 -1
- package/dist/esnext/utils/replaceAt.d.ts.map +0 -1
- package/dist/esnext/utils/replaceAt.js +0 -14
- package/dist/esnext/utils/replaceAt.js.map +0 -1
- package/dist/esnext/utils/zodKeyedTypeUnion.d.ts +0 -17
- package/dist/esnext/utils/zodKeyedTypeUnion.d.ts.map +0 -1
- package/dist/esnext/utils/zodKeyedTypeUnion.js +0 -12
- package/dist/esnext/utils/zodKeyedTypeUnion.js.map +0 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
let zod = require("zod");
|
|
2
|
+
//#region src/utils/zodKeyedTypeUnion.ts
|
|
3
|
+
function zodKeyedTypeUnion(schemasByType, typeKey = "type") {
|
|
4
|
+
/**
|
|
5
|
+
* There are a lot of casts here because of our fancy generics.
|
|
6
|
+
* We won't worry about them for now; we'll just use our tests to ensure runtime safety.
|
|
7
|
+
*/
|
|
8
|
+
return zod.z.discriminatedUnion(typeKey, Object.entries(schemasByType).map(([type, schema]) => zod.z.object({
|
|
9
|
+
[typeKey]: zod.z.literal(type),
|
|
10
|
+
[type]: schema
|
|
11
|
+
})));
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
exports.zodKeyedTypeUnion = zodKeyedTypeUnion;
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=zodKeyedTypeUnion.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zodKeyedTypeUnion.cjs","names":["z"],"sources":["../../src/utils/zodKeyedTypeUnion.ts"],"sourcesContent":["import { type KeyedTypeUnion, type ValueForTypeKey } from \"keyed-type-union\";\nimport { z } from \"zod\";\n\ntype SchemasByType<\n TTypeUnion extends KeyedTypeUnion<Record<string, unknown>, TTypeKey>,\n TTypeKey extends string = \"type\",\n> = {\n [TType in TTypeUnion[TTypeKey]]: z.ZodType<\n ValueForTypeKey<TTypeUnion, TType, TTypeKey>\n >;\n};\n\n/**\n * Creates a Zod schema for a discriminated union of type-union types.\n * We can use this util alongside keyed-type-union for stricter type union patterns.\n *\n * @param schemasByType A record of type keys to their corresponding Zod schemas.\n * @param typeKey The optional key used to discriminate between the different types in the union.\n * @returns A Zod schema for the discriminated union.\n */\nexport function zodKeyedTypeUnion<\n TTypeUnion extends KeyedTypeUnion<Record<string, unknown>>,\n>(schemasByType: SchemasByType<TTypeUnion>): z.ZodType<TTypeUnion>;\nexport function zodKeyedTypeUnion<\n TTypeUnion extends KeyedTypeUnion<Record<string, unknown>, TTypeKey>,\n TTypeKey extends string,\n>(\n schemasByType: SchemasByType<TTypeUnion, TTypeKey>,\n typeKey: TTypeKey,\n): z.ZodType<TTypeUnion>;\nexport function zodKeyedTypeUnion<\n TTypeUnion extends KeyedTypeUnion<Record<string, unknown>, TTypeKey>,\n TTypeKey extends string,\n>(\n schemasByType: SchemasByType<TTypeUnion, TTypeKey>,\n typeKey: TTypeKey = \"type\" as never,\n): z.ZodType<TTypeUnion> {\n /**\n * There are a lot of casts here because of our fancy generics.\n * We won't worry about them for now; we'll just use our tests to ensure runtime safety.\n */\n return z.discriminatedUnion(\n typeKey,\n Object.entries(schemasByType).map(([type, schema]) =>\n z.object({\n [typeKey]: z.literal(type),\n [type]: schema as never,\n }),\n ) as never,\n ) as never;\n}\n"],"mappings":";;AA8BA,SAAgB,kBAId,eACA,UAAoB,QACG;;;;;AAKvB,QAAOA,IAAAA,EAAE,mBACP,SACA,OAAO,QAAQ,cAAc,CAAC,KAAK,CAAC,MAAM,YACxCA,IAAAA,EAAE,OAAO;GACN,UAAUA,IAAAA,EAAE,QAAQ,KAAK;GACzB,OAAO;EACT,CAAC,CACH,CACF"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { KeyedTypeUnion, ValueForTypeKey } from "keyed-type-union";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
|
|
4
|
+
//#region src/utils/zodKeyedTypeUnion.d.ts
|
|
5
|
+
type SchemasByType<TTypeUnion extends KeyedTypeUnion<Record<string, unknown>, TTypeKey>, TTypeKey extends string = "type"> = { [TType in TTypeUnion[TTypeKey]]: z.ZodType<ValueForTypeKey<TTypeUnion, TType, TTypeKey>> };
|
|
6
|
+
/**
|
|
7
|
+
* Creates a Zod schema for a discriminated union of type-union types.
|
|
8
|
+
* We can use this util alongside keyed-type-union for stricter type union patterns.
|
|
9
|
+
*
|
|
10
|
+
* @param schemasByType A record of type keys to their corresponding Zod schemas.
|
|
11
|
+
* @param typeKey The optional key used to discriminate between the different types in the union.
|
|
12
|
+
* @returns A Zod schema for the discriminated union.
|
|
13
|
+
*/
|
|
14
|
+
declare function zodKeyedTypeUnion<TTypeUnion extends KeyedTypeUnion<Record<string, unknown>>>(schemasByType: SchemasByType<TTypeUnion>): z.ZodType<TTypeUnion>;
|
|
15
|
+
declare function zodKeyedTypeUnion<TTypeUnion extends KeyedTypeUnion<Record<string, unknown>, TTypeKey>, TTypeKey extends string>(schemasByType: SchemasByType<TTypeUnion, TTypeKey>, typeKey: TTypeKey): z.ZodType<TTypeUnion>;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { zodKeyedTypeUnion };
|
|
18
|
+
//# sourceMappingURL=zodKeyedTypeUnion.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zodKeyedTypeUnion.d.cts","names":[],"sources":["../../src/utils/zodKeyedTypeUnion.ts"],"mappings":";;;;KAGK,aAAA,oBACgB,cAAA,CAAe,MAAA,mBAAyB,QAAA,mDAGjD,UAAA,CAAW,QAAA,IAAY,CAAA,CAAE,OAAA,CACjC,eAAA,CAAgB,UAAA,EAAY,KAAA,EAAO,QAAA;;;;;;;;;iBAYvB,iBAAA,oBACK,cAAA,CAAe,MAAA,mBAAA,CAClC,aAAA,EAAe,aAAA,CAAc,UAAA,IAAc,CAAA,CAAE,OAAA,CAAQ,UAAA;AAAA,iBACvC,iBAAA,oBACK,cAAA,CAAe,MAAA,mBAAyB,QAAA,2BAAA,CAG3D,aAAA,EAAe,aAAA,CAAc,UAAA,EAAY,QAAA,GACzC,OAAA,EAAS,QAAA,GACR,CAAA,CAAE,OAAA,CAAQ,UAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { KeyedTypeUnion, ValueForTypeKey } from "keyed-type-union";
|
|
3
|
+
|
|
4
|
+
//#region src/utils/zodKeyedTypeUnion.d.ts
|
|
5
|
+
type SchemasByType<TTypeUnion extends KeyedTypeUnion<Record<string, unknown>, TTypeKey>, TTypeKey extends string = "type"> = { [TType in TTypeUnion[TTypeKey]]: z.ZodType<ValueForTypeKey<TTypeUnion, TType, TTypeKey>> };
|
|
6
|
+
/**
|
|
7
|
+
* Creates a Zod schema for a discriminated union of type-union types.
|
|
8
|
+
* We can use this util alongside keyed-type-union for stricter type union patterns.
|
|
9
|
+
*
|
|
10
|
+
* @param schemasByType A record of type keys to their corresponding Zod schemas.
|
|
11
|
+
* @param typeKey The optional key used to discriminate between the different types in the union.
|
|
12
|
+
* @returns A Zod schema for the discriminated union.
|
|
13
|
+
*/
|
|
14
|
+
declare function zodKeyedTypeUnion<TTypeUnion extends KeyedTypeUnion<Record<string, unknown>>>(schemasByType: SchemasByType<TTypeUnion>): z.ZodType<TTypeUnion>;
|
|
15
|
+
declare function zodKeyedTypeUnion<TTypeUnion extends KeyedTypeUnion<Record<string, unknown>, TTypeKey>, TTypeKey extends string>(schemasByType: SchemasByType<TTypeUnion, TTypeKey>, typeKey: TTypeKey): z.ZodType<TTypeUnion>;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { zodKeyedTypeUnion };
|
|
18
|
+
//# sourceMappingURL=zodKeyedTypeUnion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zodKeyedTypeUnion.d.ts","names":[],"sources":["../../src/utils/zodKeyedTypeUnion.ts"],"mappings":";;;;KAGK,aAAA,oBACgB,cAAA,CAAe,MAAA,mBAAyB,QAAA,mDAGjD,UAAA,CAAW,QAAA,IAAY,CAAA,CAAE,OAAA,CACjC,eAAA,CAAgB,UAAA,EAAY,KAAA,EAAO,QAAA;;;;;;;;;iBAYvB,iBAAA,oBACK,cAAA,CAAe,MAAA,mBAAA,CAClC,aAAA,EAAe,aAAA,CAAc,UAAA,IAAc,CAAA,CAAE,OAAA,CAAQ,UAAA;AAAA,iBACvC,iBAAA,oBACK,cAAA,CAAe,MAAA,mBAAyB,QAAA,2BAAA,CAG3D,aAAA,EAAe,aAAA,CAAc,UAAA,EAAY,QAAA,GACzC,OAAA,EAAS,QAAA,GACR,CAAA,CAAE,OAAA,CAAQ,UAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
//#region src/utils/zodKeyedTypeUnion.ts
|
|
3
|
+
function zodKeyedTypeUnion(schemasByType, typeKey = "type") {
|
|
4
|
+
/**
|
|
5
|
+
* There are a lot of casts here because of our fancy generics.
|
|
6
|
+
* We won't worry about them for now; we'll just use our tests to ensure runtime safety.
|
|
7
|
+
*/
|
|
8
|
+
return z.discriminatedUnion(typeKey, Object.entries(schemasByType).map(([type, schema]) => z.object({
|
|
9
|
+
[typeKey]: z.literal(type),
|
|
10
|
+
[type]: schema
|
|
11
|
+
})));
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { zodKeyedTypeUnion };
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=zodKeyedTypeUnion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zodKeyedTypeUnion.js","names":[],"sources":["../../src/utils/zodKeyedTypeUnion.ts"],"sourcesContent":["import { type KeyedTypeUnion, type ValueForTypeKey } from \"keyed-type-union\";\nimport { z } from \"zod\";\n\ntype SchemasByType<\n TTypeUnion extends KeyedTypeUnion<Record<string, unknown>, TTypeKey>,\n TTypeKey extends string = \"type\",\n> = {\n [TType in TTypeUnion[TTypeKey]]: z.ZodType<\n ValueForTypeKey<TTypeUnion, TType, TTypeKey>\n >;\n};\n\n/**\n * Creates a Zod schema for a discriminated union of type-union types.\n * We can use this util alongside keyed-type-union for stricter type union patterns.\n *\n * @param schemasByType A record of type keys to their corresponding Zod schemas.\n * @param typeKey The optional key used to discriminate between the different types in the union.\n * @returns A Zod schema for the discriminated union.\n */\nexport function zodKeyedTypeUnion<\n TTypeUnion extends KeyedTypeUnion<Record<string, unknown>>,\n>(schemasByType: SchemasByType<TTypeUnion>): z.ZodType<TTypeUnion>;\nexport function zodKeyedTypeUnion<\n TTypeUnion extends KeyedTypeUnion<Record<string, unknown>, TTypeKey>,\n TTypeKey extends string,\n>(\n schemasByType: SchemasByType<TTypeUnion, TTypeKey>,\n typeKey: TTypeKey,\n): z.ZodType<TTypeUnion>;\nexport function zodKeyedTypeUnion<\n TTypeUnion extends KeyedTypeUnion<Record<string, unknown>, TTypeKey>,\n TTypeKey extends string,\n>(\n schemasByType: SchemasByType<TTypeUnion, TTypeKey>,\n typeKey: TTypeKey = \"type\" as never,\n): z.ZodType<TTypeUnion> {\n /**\n * There are a lot of casts here because of our fancy generics.\n * We won't worry about them for now; we'll just use our tests to ensure runtime safety.\n */\n return z.discriminatedUnion(\n typeKey,\n Object.entries(schemasByType).map(([type, schema]) =>\n z.object({\n [typeKey]: z.literal(type),\n [type]: schema as never,\n }),\n ) as never,\n ) as never;\n}\n"],"mappings":";;AA8BA,SAAgB,kBAId,eACA,UAAoB,QACG;;;;;AAKvB,QAAO,EAAE,mBACP,SACA,OAAO,QAAQ,cAAc,CAAC,KAAK,CAAC,MAAM,YACxC,EAAE,OAAO;GACN,UAAU,EAAE,QAAQ,KAAK;GACzB,OAAO;EACT,CAAC,CACH,CACF"}
|
package/package.json
CHANGED
|
@@ -1,18 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@percepta/utils",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.11",
|
|
4
4
|
"private": false,
|
|
5
|
-
"publishConfig": {
|
|
6
|
-
"access": "public"
|
|
7
|
-
},
|
|
8
5
|
"description": "Shared utils for Mosaic",
|
|
9
|
-
"sideEffects": false,
|
|
10
|
-
"main": "dist/cjs/index.js",
|
|
11
|
-
"module": "dist/esnext/index.js",
|
|
12
|
-
"types": "dist/esnext/index.d.ts",
|
|
13
6
|
"files": [
|
|
14
|
-
"dist
|
|
7
|
+
"dist"
|
|
15
8
|
],
|
|
9
|
+
"type": "module",
|
|
10
|
+
"sideEffects": false,
|
|
11
|
+
"main": "./dist/index.cjs",
|
|
12
|
+
"module": "./dist/index.js",
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"import": {
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"default": "./dist/index.js"
|
|
19
|
+
},
|
|
20
|
+
"require": {
|
|
21
|
+
"types": "./dist/index.d.cts",
|
|
22
|
+
"default": "./dist/index.cjs"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"./package.json": "./package.json"
|
|
26
|
+
},
|
|
27
|
+
"publishConfig": {
|
|
28
|
+
"access": "public"
|
|
29
|
+
},
|
|
16
30
|
"dependencies": {
|
|
17
31
|
"keyed-type-union": "^0.1.0",
|
|
18
32
|
"lodash-es": "^4.17.21",
|
|
@@ -20,17 +34,13 @@
|
|
|
20
34
|
},
|
|
21
35
|
"devDependencies": {
|
|
22
36
|
"@types/lodash-es": "^4.17.12",
|
|
23
|
-
"@percepta/build": "0.
|
|
24
|
-
},
|
|
25
|
-
"lint-staged": {
|
|
26
|
-
"**/*.ts": "eslint --fix"
|
|
37
|
+
"@percepta/build": "0.5.0"
|
|
27
38
|
},
|
|
28
39
|
"scripts": {
|
|
29
|
-
"build": "
|
|
30
|
-
"dev": "
|
|
40
|
+
"build": "tsdown",
|
|
41
|
+
"dev": "tsdown --watch",
|
|
31
42
|
"clean": "rimraf dist",
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"test": "jest"
|
|
43
|
+
"typecheck": "tsc --noEmit",
|
|
44
|
+
"test": "vitest run"
|
|
35
45
|
}
|
|
36
46
|
}
|
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
export declare const BASE_ENV_SCHEMA: z.ZodObject<{
|
|
3
|
-
NODE_ENV: z.ZodDefault<z.ZodEnum<{
|
|
4
|
-
development: "development";
|
|
5
|
-
production: "production";
|
|
6
|
-
test: "test";
|
|
7
|
-
}>>;
|
|
8
|
-
LOG_LEVEL: z.ZodDefault<z.ZodPipe<z.ZodString, z.ZodEnum<{
|
|
9
|
-
debug: "debug";
|
|
10
|
-
info: "info";
|
|
11
|
-
warn: "warn";
|
|
12
|
-
error: "error";
|
|
13
|
-
}>>>;
|
|
14
|
-
}, z.core.$strip>;
|
|
15
|
-
export type BaseEnvConfig = z.infer<typeof BASE_ENV_SCHEMA>;
|
|
16
|
-
export declare function createEnvConfig<TExtension extends z.ZodRawShape>(extensionSchema: z.ZodObject<TExtension>): {
|
|
17
|
-
getEnvConfig: () => z.core.$InferObjectOutput<(("NODE_ENV" | "LOG_LEVEL") & keyof TExtension extends never ? {
|
|
18
|
-
NODE_ENV: z.ZodDefault<z.ZodEnum<{
|
|
19
|
-
development: "development";
|
|
20
|
-
production: "production";
|
|
21
|
-
test: "test";
|
|
22
|
-
}>>;
|
|
23
|
-
LOG_LEVEL: z.ZodDefault<z.ZodPipe<z.ZodString, z.ZodEnum<{
|
|
24
|
-
debug: "debug";
|
|
25
|
-
info: "info";
|
|
26
|
-
warn: "warn";
|
|
27
|
-
error: "error";
|
|
28
|
-
}>>>;
|
|
29
|
-
} & TExtension : ({
|
|
30
|
-
NODE_ENV: z.ZodDefault<z.ZodEnum<{
|
|
31
|
-
development: "development";
|
|
32
|
-
production: "production";
|
|
33
|
-
test: "test";
|
|
34
|
-
}>>;
|
|
35
|
-
LOG_LEVEL: z.ZodDefault<z.ZodPipe<z.ZodString, z.ZodEnum<{
|
|
36
|
-
debug: "debug";
|
|
37
|
-
info: "info";
|
|
38
|
-
warn: "warn";
|
|
39
|
-
error: "error";
|
|
40
|
-
}>>>;
|
|
41
|
-
} extends infer T_2 extends z.core.util.SomeObject ? { [K in keyof T_2 as K extends keyof TExtension ? never : K]: {
|
|
42
|
-
NODE_ENV: z.ZodDefault<z.ZodEnum<{
|
|
43
|
-
development: "development";
|
|
44
|
-
production: "production";
|
|
45
|
-
test: "test";
|
|
46
|
-
}>>;
|
|
47
|
-
LOG_LEVEL: z.ZodDefault<z.ZodPipe<z.ZodString, z.ZodEnum<{
|
|
48
|
-
debug: "debug";
|
|
49
|
-
info: "info";
|
|
50
|
-
warn: "warn";
|
|
51
|
-
error: "error";
|
|
52
|
-
}>>>;
|
|
53
|
-
}[K]; } : never) & { [K_1 in keyof TExtension]: TExtension[K_1]; }) extends infer T ? { [k in keyof T]: (("NODE_ENV" | "LOG_LEVEL") & keyof TExtension extends never ? {
|
|
54
|
-
NODE_ENV: z.ZodDefault<z.ZodEnum<{
|
|
55
|
-
development: "development";
|
|
56
|
-
production: "production";
|
|
57
|
-
test: "test";
|
|
58
|
-
}>>;
|
|
59
|
-
LOG_LEVEL: z.ZodDefault<z.ZodPipe<z.ZodString, z.ZodEnum<{
|
|
60
|
-
debug: "debug";
|
|
61
|
-
info: "info";
|
|
62
|
-
warn: "warn";
|
|
63
|
-
error: "error";
|
|
64
|
-
}>>>;
|
|
65
|
-
} & TExtension : ({
|
|
66
|
-
NODE_ENV: z.ZodDefault<z.ZodEnum<{
|
|
67
|
-
development: "development";
|
|
68
|
-
production: "production";
|
|
69
|
-
test: "test";
|
|
70
|
-
}>>;
|
|
71
|
-
LOG_LEVEL: z.ZodDefault<z.ZodPipe<z.ZodString, z.ZodEnum<{
|
|
72
|
-
debug: "debug";
|
|
73
|
-
info: "info";
|
|
74
|
-
warn: "warn";
|
|
75
|
-
error: "error";
|
|
76
|
-
}>>>;
|
|
77
|
-
} extends infer T_1 extends z.core.util.SomeObject ? { [K in keyof T_1 as K extends keyof TExtension ? never : K]: {
|
|
78
|
-
NODE_ENV: z.ZodDefault<z.ZodEnum<{
|
|
79
|
-
development: "development";
|
|
80
|
-
production: "production";
|
|
81
|
-
test: "test";
|
|
82
|
-
}>>;
|
|
83
|
-
LOG_LEVEL: z.ZodDefault<z.ZodPipe<z.ZodString, z.ZodEnum<{
|
|
84
|
-
debug: "debug";
|
|
85
|
-
info: "info";
|
|
86
|
-
warn: "warn";
|
|
87
|
-
error: "error";
|
|
88
|
-
}>>>;
|
|
89
|
-
}[K]; } : never) & { [K_1 in keyof TExtension]: TExtension[K_1]; })[k]; } : never, {}>;
|
|
90
|
-
schema: z.ZodObject<(("NODE_ENV" | "LOG_LEVEL") & keyof TExtension extends never ? {
|
|
91
|
-
NODE_ENV: z.ZodDefault<z.ZodEnum<{
|
|
92
|
-
development: "development";
|
|
93
|
-
production: "production";
|
|
94
|
-
test: "test";
|
|
95
|
-
}>>;
|
|
96
|
-
LOG_LEVEL: z.ZodDefault<z.ZodPipe<z.ZodString, z.ZodEnum<{
|
|
97
|
-
debug: "debug";
|
|
98
|
-
info: "info";
|
|
99
|
-
warn: "warn";
|
|
100
|
-
error: "error";
|
|
101
|
-
}>>>;
|
|
102
|
-
} & TExtension : ({
|
|
103
|
-
NODE_ENV: z.ZodDefault<z.ZodEnum<{
|
|
104
|
-
development: "development";
|
|
105
|
-
production: "production";
|
|
106
|
-
test: "test";
|
|
107
|
-
}>>;
|
|
108
|
-
LOG_LEVEL: z.ZodDefault<z.ZodPipe<z.ZodString, z.ZodEnum<{
|
|
109
|
-
debug: "debug";
|
|
110
|
-
info: "info";
|
|
111
|
-
warn: "warn";
|
|
112
|
-
error: "error";
|
|
113
|
-
}>>>;
|
|
114
|
-
} extends infer T_2 extends z.core.util.SomeObject ? { [K in keyof T_2 as K extends keyof TExtension ? never : K]: {
|
|
115
|
-
NODE_ENV: z.ZodDefault<z.ZodEnum<{
|
|
116
|
-
development: "development";
|
|
117
|
-
production: "production";
|
|
118
|
-
test: "test";
|
|
119
|
-
}>>;
|
|
120
|
-
LOG_LEVEL: z.ZodDefault<z.ZodPipe<z.ZodString, z.ZodEnum<{
|
|
121
|
-
debug: "debug";
|
|
122
|
-
info: "info";
|
|
123
|
-
warn: "warn";
|
|
124
|
-
error: "error";
|
|
125
|
-
}>>>;
|
|
126
|
-
}[K]; } : never) & { [K_1 in keyof TExtension]: TExtension[K_1]; }) extends infer T ? { [k in keyof T]: (("NODE_ENV" | "LOG_LEVEL") & keyof TExtension extends never ? {
|
|
127
|
-
NODE_ENV: z.ZodDefault<z.ZodEnum<{
|
|
128
|
-
development: "development";
|
|
129
|
-
production: "production";
|
|
130
|
-
test: "test";
|
|
131
|
-
}>>;
|
|
132
|
-
LOG_LEVEL: z.ZodDefault<z.ZodPipe<z.ZodString, z.ZodEnum<{
|
|
133
|
-
debug: "debug";
|
|
134
|
-
info: "info";
|
|
135
|
-
warn: "warn";
|
|
136
|
-
error: "error";
|
|
137
|
-
}>>>;
|
|
138
|
-
} & TExtension : ({
|
|
139
|
-
NODE_ENV: z.ZodDefault<z.ZodEnum<{
|
|
140
|
-
development: "development";
|
|
141
|
-
production: "production";
|
|
142
|
-
test: "test";
|
|
143
|
-
}>>;
|
|
144
|
-
LOG_LEVEL: z.ZodDefault<z.ZodPipe<z.ZodString, z.ZodEnum<{
|
|
145
|
-
debug: "debug";
|
|
146
|
-
info: "info";
|
|
147
|
-
warn: "warn";
|
|
148
|
-
error: "error";
|
|
149
|
-
}>>>;
|
|
150
|
-
} extends infer T_1 extends z.core.util.SomeObject ? { [K in keyof T_1 as K extends keyof TExtension ? never : K]: {
|
|
151
|
-
NODE_ENV: z.ZodDefault<z.ZodEnum<{
|
|
152
|
-
development: "development";
|
|
153
|
-
production: "production";
|
|
154
|
-
test: "test";
|
|
155
|
-
}>>;
|
|
156
|
-
LOG_LEVEL: z.ZodDefault<z.ZodPipe<z.ZodString, z.ZodEnum<{
|
|
157
|
-
debug: "debug";
|
|
158
|
-
info: "info";
|
|
159
|
-
warn: "warn";
|
|
160
|
-
error: "error";
|
|
161
|
-
}>>>;
|
|
162
|
-
}[K]; } : never) & { [K_1 in keyof TExtension]: TExtension[K_1]; })[k]; } : never, z.core.$strip>;
|
|
163
|
-
};
|
|
164
|
-
//# sourceMappingURL=getEnvConfig.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getEnvConfig.d.ts","sourceRoot":"","sources":["../../../src/config/getEnvConfig.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,eAAe;;;;;;;;;;;;iBAS1B,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAG5D,wBAAgB,eAAe,CAAC,UAAU,SAAS,CAAC,CAAC,WAAW,EAC9D,eAAe,EAAE,CAAC,CAAC,SAAS,CAAC,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAezC"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BASE_ENV_SCHEMA = void 0;
|
|
4
|
-
exports.createEnvConfig = createEnvConfig;
|
|
5
|
-
// @percepta/config/src/createEnvConfig.ts
|
|
6
|
-
const zod_1 = require("zod");
|
|
7
|
-
// Base schema that all apps get
|
|
8
|
-
exports.BASE_ENV_SCHEMA = zod_1.z.object({
|
|
9
|
-
NODE_ENV: zod_1.z
|
|
10
|
-
.enum(["development", "production", "test"])
|
|
11
|
-
.default("development"),
|
|
12
|
-
LOG_LEVEL: zod_1.z
|
|
13
|
-
.string()
|
|
14
|
-
.toLowerCase()
|
|
15
|
-
.pipe(zod_1.z.enum(["debug", "info", "warn", "error"]))
|
|
16
|
-
.default("info"),
|
|
17
|
-
});
|
|
18
|
-
// Factory that creates a configured getEnvConfig
|
|
19
|
-
function createEnvConfig(extensionSchema) {
|
|
20
|
-
const schema = exports.BASE_ENV_SCHEMA.extend(extensionSchema.shape);
|
|
21
|
-
let _cached;
|
|
22
|
-
function getEnvConfig() {
|
|
23
|
-
if (_cached == null) {
|
|
24
|
-
_cached = schema.parse(process.env);
|
|
25
|
-
}
|
|
26
|
-
return _cached;
|
|
27
|
-
}
|
|
28
|
-
return { getEnvConfig, schema };
|
|
29
|
-
}
|
|
30
|
-
//# sourceMappingURL=getEnvConfig.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getEnvConfig.js","sourceRoot":"","sources":["../../../src/config/getEnvConfig.ts"],"names":[],"mappings":";;;AAkBA,0CAgBC;AAlCD,0CAA0C;AAC1C,6BAAwB;AAExB,gCAAgC;AACnB,QAAA,eAAe,GAAG,OAAC,CAAC,MAAM,CAAC;IACtC,QAAQ,EAAE,OAAC;SACR,IAAI,CAAC,CAAC,aAAa,EAAE,YAAY,EAAE,MAAM,CAAC,CAAC;SAC3C,OAAO,CAAC,aAAa,CAAC;IACzB,SAAS,EAAE,OAAC;SACT,MAAM,EAAE;SACR,WAAW,EAAE;SACb,IAAI,CAAC,OAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;SAChD,OAAO,CAAC,MAAM,CAAC;CACnB,CAAC,CAAC;AAIH,iDAAiD;AACjD,SAAgB,eAAe,CAC7B,eAAwC;IAExC,MAAM,MAAM,GAAG,uBAAe,CAAC,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;IAG7D,IAAI,OAA2B,CAAC;IAEhC,SAAS,YAAY;QACnB,IAAI,OAAO,IAAI,IAAI,EAAE,CAAC;YACpB,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACtC,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,CAAC;AAClC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/config/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC"}
|
package/dist/cjs/config/index.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./getEnvConfig"), exports);
|
|
18
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/config/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B"}
|
package/dist/cjs/index.d.ts
DELETED
package/dist/cjs/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC"}
|
package/dist/cjs/index.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./utils"), exports);
|
|
18
|
-
__exportStar(require("./config"), exports);
|
|
19
|
-
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,2CAAyB"}
|