@percepta/utils 0.1.5 → 0.1.7
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/cjs/config/getEnvConfig.d.ts +164 -0
- package/dist/cjs/config/getEnvConfig.d.ts.map +1 -0
- package/dist/cjs/config/getEnvConfig.js +26 -0
- package/dist/cjs/config/getEnvConfig.js.map +1 -0
- package/dist/cjs/config/index.d.ts +2 -0
- package/dist/cjs/config/index.d.ts.map +1 -0
- package/dist/cjs/config/index.js +18 -0
- package/dist/cjs/config/index.js.map +1 -0
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/tsconfig.tsbuildinfo +1 -1
- package/dist/esnext/config/getEnvConfig.d.ts +164 -0
- package/dist/esnext/config/getEnvConfig.d.ts.map +1 -0
- package/dist/esnext/config/getEnvConfig.js +22 -0
- package/dist/esnext/config/getEnvConfig.js.map +1 -0
- package/dist/esnext/config/index.d.ts +2 -0
- package/dist/esnext/config/index.d.ts.map +1 -0
- package/dist/esnext/config/index.js +2 -0
- package/dist/esnext/config/index.js.map +1 -0
- package/dist/esnext/index.d.ts +1 -0
- package/dist/esnext/index.d.ts.map +1 -1
- package/dist/esnext/index.js +1 -0
- package/dist/esnext/index.js.map +1 -1
- package/dist/esnext/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -4
|
@@ -0,0 +1,164 @@
|
|
|
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.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.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.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.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.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.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.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.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.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.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.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.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.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
|
|
@@ -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;;;;;;;;;;;;iBAK1B,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.extend(extensionSchema.shape);
|
|
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,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"}
|
|
@@ -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"}
|
package/dist/cjs/index.d.ts
CHANGED
package/dist/cjs/index.d.ts.map
CHANGED
|
@@ -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
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -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"}
|