@percepta/utils 0.1.4 → 0.1.6

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,38 @@
1
+ import { z } from "zod";
2
+ export declare const BASE_ENV_SCHEMA: z.ZodObject<{
3
+ NODE_ENV: z.ZodDefault<z.ZodEnum<["development", "production", "test"]>>;
4
+ LOG_LEVEL: z.ZodDefault<z.ZodEnum<["debug", "info", "warn", "error"]>>;
5
+ }, "strip", z.ZodTypeAny, {
6
+ NODE_ENV: "development" | "production" | "test";
7
+ LOG_LEVEL: "debug" | "info" | "warn" | "error";
8
+ }, {
9
+ NODE_ENV?: "development" | "production" | "test" | undefined;
10
+ LOG_LEVEL?: "debug" | "info" | "warn" | "error" | undefined;
11
+ }>;
12
+ export type BaseEnvConfig = z.infer<typeof BASE_ENV_SCHEMA>;
13
+ export declare function createEnvConfig<TExtension extends z.ZodRawShape>(extensionSchema: z.ZodObject<TExtension>): {
14
+ getEnvConfig: () => z.objectUtil.addQuestionMarks<z.baseObjectOutputType<z.objectUtil.extendShape<{
15
+ NODE_ENV: z.ZodDefault<z.ZodEnum<["development", "production", "test"]>>;
16
+ LOG_LEVEL: z.ZodDefault<z.ZodEnum<["debug", "info", "warn", "error"]>>;
17
+ }, TExtension>>, any> extends infer T ? { [k in keyof T]: z.objectUtil.addQuestionMarks<z.baseObjectOutputType<z.objectUtil.extendShape<{
18
+ NODE_ENV: z.ZodDefault<z.ZodEnum<["development", "production", "test"]>>;
19
+ LOG_LEVEL: z.ZodDefault<z.ZodEnum<["debug", "info", "warn", "error"]>>;
20
+ }, TExtension>>, any>[k]; } : never;
21
+ schema: z.ZodObject<z.objectUtil.extendShape<{
22
+ NODE_ENV: z.ZodDefault<z.ZodEnum<["development", "production", "test"]>>;
23
+ LOG_LEVEL: z.ZodDefault<z.ZodEnum<["debug", "info", "warn", "error"]>>;
24
+ }, TExtension>, z.UnknownKeysParam, z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<z.objectUtil.extendShape<{
25
+ NODE_ENV: z.ZodDefault<z.ZodEnum<["development", "production", "test"]>>;
26
+ LOG_LEVEL: z.ZodDefault<z.ZodEnum<["debug", "info", "warn", "error"]>>;
27
+ }, TExtension>>, any> extends infer T ? { [k in keyof T]: z.objectUtil.addQuestionMarks<z.baseObjectOutputType<z.objectUtil.extendShape<{
28
+ NODE_ENV: z.ZodDefault<z.ZodEnum<["development", "production", "test"]>>;
29
+ LOG_LEVEL: z.ZodDefault<z.ZodEnum<["debug", "info", "warn", "error"]>>;
30
+ }, TExtension>>, any>[k]; } : never, z.baseObjectInputType<z.objectUtil.extendShape<{
31
+ NODE_ENV: z.ZodDefault<z.ZodEnum<["development", "production", "test"]>>;
32
+ LOG_LEVEL: z.ZodDefault<z.ZodEnum<["debug", "info", "warn", "error"]>>;
33
+ }, TExtension>> extends infer T_1 ? { [k_1 in keyof T_1]: z.baseObjectInputType<z.objectUtil.extendShape<{
34
+ NODE_ENV: z.ZodDefault<z.ZodEnum<["development", "production", "test"]>>;
35
+ LOG_LEVEL: z.ZodDefault<z.ZodEnum<["debug", "info", "warn", "error"]>>;
36
+ }, TExtension>>[k_1]; } : never>;
37
+ };
38
+ //# sourceMappingURL=getEnvConfig.d.ts.map
@@ -0,0 +1 @@
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;;;;;;;;;EAK1B,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"}
@@ -0,0 +1,26 @@
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.enum(["debug", "info", "warn", "error"]).default("info"),
13
+ });
14
+ // Factory that creates a configured getEnvConfig
15
+ function createEnvConfig(extensionSchema) {
16
+ const schema = exports.BASE_ENV_SCHEMA.merge(extensionSchema);
17
+ let _cached;
18
+ function getEnvConfig() {
19
+ if (_cached == null) {
20
+ _cached = schema.parse(process.env);
21
+ }
22
+ return _cached;
23
+ }
24
+ return { getEnvConfig, schema };
25
+ }
26
+ //# sourceMappingURL=getEnvConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getEnvConfig.js","sourceRoot":"","sources":["../../../src/config/getEnvConfig.ts"],"names":[],"mappings":";;;AAcA,0CAgBC;AA9BD,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,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC;CACtE,CAAC,CAAC;AAIH,iDAAiD;AACjD,SAAgB,eAAe,CAC7B,eAAwC;IAExC,MAAM,MAAM,GAAG,uBAAe,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;IAGtD,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"}
@@ -0,0 +1,2 @@
1
+ export * from "./getEnvConfig";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/config/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC"}
@@ -0,0 +1,18 @@
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/config/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B"}
@@ -1,2 +1,3 @@
1
1
  export * from "./utils";
2
+ export * from "./config";
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC"}
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 CHANGED
@@ -15,4 +15,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./utils"), exports);
18
+ __exportStar(require("./config"), exports);
18
19
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,2CAAyB"}