@kyco-utils/enums 0.1.2 → 0.2.0

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/README.md CHANGED
@@ -1,7 +1,26 @@
1
1
  # @kyco-utils/enums
2
2
 
3
- A set of utilities for TS projects.
3
+ Shared runtime enums and their [Zod](https://zod.dev) schemas.
4
+
5
+ ## Install
6
+
7
+ ```sh
8
+ pnpm add @kyco-utils/enums zod
9
+ ```
10
+
11
+ Requires `zod` v4 as a peer dependency. ESM only.
12
+
13
+ ## Usage
14
+
15
+ ```ts
16
+ import { ColorMode, zColorMode } from '@kyco-utils/enums'
17
+
18
+ const mode: ColorMode = ColorMode.DARK // 'dark'
19
+ zColorMode.safeParse('blue').success // false
20
+ ```
21
+
22
+ See the [API reference](https://kyco.github.io/kyco-utils/api/@kyco-utils/enums) for all exports.
4
23
 
5
24
  ## License
6
25
 
7
- [MIT](LICENSE)
26
+ [MIT](https://github.com/kyco/kyco-utils/blob/main/LICENSE)
package/dist/index.d.mts CHANGED
@@ -1,26 +1,67 @@
1
1
  import * as z from "zod";
2
2
  /**
3
- * Supported color modes available.
3
+ * Color modes a user can choose for the UI.
4
+ *
5
+ * @enum
6
+ * @example
7
+ * ```ts
8
+ * import { ColorMode } from '@kyco-utils/enums'
9
+ *
10
+ * const mode: ColorMode = ColorMode.DARK // 'dark'
11
+ * ```
4
12
  */
5
13
  export declare const ColorMode: {
6
14
  readonly SYSTEM: 'system';
7
15
  readonly LIGHT: 'light';
8
16
  readonly DARK: 'dark';
9
17
  };
18
+ /**
19
+ * Zod schema that validates a {@link ColorMode}.
20
+ *
21
+ * @group Schemas
22
+ * @example
23
+ * ```ts
24
+ * import { zColorMode } from '@kyco-utils/enums'
25
+ *
26
+ * zColorMode.parse('dark') // 'dark'
27
+ * zColorMode.safeParse('blue').success // false
28
+ * ```
29
+ */
10
30
  export declare const zColorMode: z.ZodEnum<{
11
- dark: "dark";
12
- light: "light";
13
- system: "system";
31
+ readonly SYSTEM: 'system';
32
+ readonly LIGHT: 'light';
33
+ readonly DARK: 'dark';
14
34
  }>;
15
35
  export type ColorMode = z.infer<typeof zColorMode>;
16
36
  /**
17
- * Supported locales available. Follows [BCP 47](https://developer.mozilla.org/en-US/docs/Glossary/BCP_47_language_tag) language tags,
18
- * i.e. generally in the format of `{ISO 639-1}-{ISO 3166-1}`.
37
+ * Locales supported across kyco-utils, as [BCP 47](https://developer.mozilla.org/en-US/docs/Glossary/BCP_47_language_tag)
38
+ * language tags in the form `{language}-{region}`: an [ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639_language_codes)
39
+ * language code and an [ISO 3166-1](https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes) region code.
40
+ *
41
+ * @enum
42
+ * @example
43
+ * ```ts
44
+ * import { UserLocale } from '@kyco-utils/enums'
45
+ *
46
+ * const locale: UserLocale = UserLocale.DE_DE // 'de-DE'
47
+ * ```
19
48
  */
20
49
  export declare const UserLocale: {
21
50
  readonly EN_GB: 'en-GB';
22
51
  readonly DE_DE: 'de-DE';
23
52
  };
53
+ /**
54
+ * Zod schema that validates a {@link UserLocale}.
55
+ *
56
+ * @group Schemas
57
+ * @example
58
+ * ```ts
59
+ * import { zUserLocale } from '@kyco-utils/enums'
60
+ *
61
+ * zUserLocale.parse('en-GB') // 'en-GB'
62
+ * zUserLocale.safeParse('fr-FR').success // false
63
+ * ```
64
+ */
24
65
  export declare const zUserLocale: z.ZodEnum<{
25
66
  readonly EN_GB: 'en-GB';
26
67
  readonly DE_DE: 'de-DE';
package/dist/index.mjs CHANGED
@@ -1,26 +1,63 @@
1
1
  import * as z from "zod";
2
2
  // src/index.ts
3
3
  /**
4
- * Supported color modes available.
4
+ * Color modes a user can choose for the UI.
5
+ *
6
+ * @enum
7
+ * @example
8
+ * ```ts
9
+ * import { ColorMode } from '@kyco-utils/enums'
10
+ *
11
+ * const mode: ColorMode = ColorMode.DARK // 'dark'
12
+ * ```
5
13
  */
6
14
  const ColorMode = {
7
15
  SYSTEM: "system",
8
16
  LIGHT: "light",
9
17
  DARK: "dark"
10
18
  };
11
- const zColorMode = z.enum([
12
- ColorMode.SYSTEM,
13
- ColorMode.LIGHT,
14
- ColorMode.DARK
15
- ]);
16
19
  /**
17
- * Supported locales available. Follows [BCP 47](https://developer.mozilla.org/en-US/docs/Glossary/BCP_47_language_tag) language tags,
18
- * i.e. generally in the format of `{ISO 639-1}-{ISO 3166-1}`.
20
+ * Zod schema that validates a {@link ColorMode}.
21
+ *
22
+ * @group Schemas
23
+ * @example
24
+ * ```ts
25
+ * import { zColorMode } from '@kyco-utils/enums'
26
+ *
27
+ * zColorMode.parse('dark') // 'dark'
28
+ * zColorMode.safeParse('blue').success // false
29
+ * ```
30
+ */
31
+ const zColorMode = z.enum(ColorMode);
32
+ /**
33
+ * Locales supported across kyco-utils, as [BCP 47](https://developer.mozilla.org/en-US/docs/Glossary/BCP_47_language_tag)
34
+ * language tags in the form `{language}-{region}`: an [ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639_language_codes)
35
+ * language code and an [ISO 3166-1](https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes) region code.
36
+ *
37
+ * @enum
38
+ * @example
39
+ * ```ts
40
+ * import { UserLocale } from '@kyco-utils/enums'
41
+ *
42
+ * const locale: UserLocale = UserLocale.DE_DE // 'de-DE'
43
+ * ```
19
44
  */
20
45
  const UserLocale = {
21
46
  EN_GB: "en-GB",
22
47
  DE_DE: "de-DE"
23
48
  };
49
+ /**
50
+ * Zod schema that validates a {@link UserLocale}.
51
+ *
52
+ * @group Schemas
53
+ * @example
54
+ * ```ts
55
+ * import { zUserLocale } from '@kyco-utils/enums'
56
+ *
57
+ * zUserLocale.parse('en-GB') // 'en-GB'
58
+ * zUserLocale.safeParse('fr-FR').success // false
59
+ * ```
60
+ */
24
61
  const zUserLocale = z.enum(UserLocale);
25
62
  export { ColorMode, UserLocale, zColorMode, zUserLocale };
26
63
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["import * as z from 'zod'\n\n// -------------------------------------------------------\n\n/**\n * Supported color modes available.\n */\nexport const ColorMode = {\n SYSTEM: 'system',\n LIGHT: 'light',\n DARK: 'dark',\n} as const\n\nexport const zColorMode = z.enum([ColorMode.SYSTEM, ColorMode.LIGHT, ColorMode.DARK] as const)\n\nexport type ColorMode = z.infer<typeof zColorMode>\n\n// -------------------------------------------------------\n\n/**\n * Supported locales available. Follows [BCP 47](https://developer.mozilla.org/en-US/docs/Glossary/BCP_47_language_tag) language tags,\n * i.e. generally in the format of `{ISO 639-1}-{ISO 3166-1}`.\n */\nexport const UserLocale = {\n // @locale-updates\n EN_GB: 'en-GB',\n DE_DE: 'de-DE',\n} as const\n\nexport const zUserLocale = z.enum(UserLocale)\n\nexport type UserLocale = z.infer<typeof zUserLocale>\n\n// -------------------------------------------------------\n"],"mappings":";;;;;AAOA,MAAa,YAAY;CACvB,QAAQ;CACR,OAAO;CACP,MAAM;AACR;AAEA,MAAa,aAAa,EAAE,KAAK;CAAC,UAAU;CAAQ,UAAU;CAAO,UAAU;AAAI,CAAU;;;;;AAU7F,MAAa,aAAa;CAExB,OAAO;CACP,OAAO;AACT;AAEA,MAAa,cAAc,EAAE,KAAK,UAAU"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["import * as z from 'zod'\n\n// -------------------------------------------------------\n\n/**\n * Color modes a user can choose for the UI.\n *\n * @enum\n * @example\n * ```ts\n * import { ColorMode } from '@kyco-utils/enums'\n *\n * const mode: ColorMode = ColorMode.DARK // 'dark'\n * ```\n */\nexport const ColorMode = {\n SYSTEM: 'system',\n LIGHT: 'light',\n DARK: 'dark',\n} as const\n\n/**\n * Zod schema that validates a {@link ColorMode}.\n *\n * @group Schemas\n * @example\n * ```ts\n * import { zColorMode } from '@kyco-utils/enums'\n *\n * zColorMode.parse('dark') // 'dark'\n * zColorMode.safeParse('blue').success // false\n * ```\n */\nexport const zColorMode = z.enum(ColorMode)\n\nexport type ColorMode = z.infer<typeof zColorMode>\n\n// -------------------------------------------------------\n\n/**\n * Locales supported across kyco-utils, as [BCP 47](https://developer.mozilla.org/en-US/docs/Glossary/BCP_47_language_tag)\n * language tags in the form `{language}-{region}`: an [ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639_language_codes)\n * language code and an [ISO 3166-1](https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes) region code.\n *\n * @enum\n * @example\n * ```ts\n * import { UserLocale } from '@kyco-utils/enums'\n *\n * const locale: UserLocale = UserLocale.DE_DE // 'de-DE'\n * ```\n */\nexport const UserLocale = {\n // @locale-updates\n EN_GB: 'en-GB',\n DE_DE: 'de-DE',\n} as const\n\n/**\n * Zod schema that validates a {@link UserLocale}.\n *\n * @group Schemas\n * @example\n * ```ts\n * import { zUserLocale } from '@kyco-utils/enums'\n *\n * zUserLocale.parse('en-GB') // 'en-GB'\n * zUserLocale.safeParse('fr-FR').success // false\n * ```\n */\nexport const zUserLocale = z.enum(UserLocale)\n\nexport type UserLocale = z.infer<typeof zUserLocale>\n\n// -------------------------------------------------------\n"],"mappings":";;;;;;;;;;;;;AAeA,MAAa,YAAY;CACvB,QAAQ;CACR,OAAO;CACP,MAAM;AACR;;;;;;;;;;;;;AAcA,MAAa,aAAa,EAAE,KAAK,SAAS;;;;;;;;;;;;;;AAmB1C,MAAa,aAAa;CAExB,OAAO;CACP,OAAO;AACT;;;;;;;;;;;;;AAcA,MAAa,cAAc,EAAE,KAAK,UAAU"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kyco-utils/enums",
3
- "version": "0.1.2",
3
+ "version": "0.2.0",
4
4
  "description": "Shared runtime enums and Zod schemas for kyco-utils.",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -17,19 +17,10 @@
17
17
  "exports": {
18
18
  ".": {
19
19
  "@kyco-utils/source": "./src/index.ts",
20
- "import": {
21
- "types": "./dist/index.d.mts",
22
- "default": "./dist/index.mjs"
23
- },
24
- "require": {
25
- "types": "./dist/index.d.cts",
26
- "default": "./dist/index.cjs"
27
- }
20
+ "types": "./dist/index.d.mts",
21
+ "default": "./dist/index.mjs"
28
22
  }
29
23
  },
30
- "main": "./dist/index.cjs",
31
- "module": "./dist/index.mjs",
32
- "types": "./dist/index.d.cts",
33
24
  "peerDependencies": {
34
25
  "zod": "^4.0.0"
35
26
  },
@@ -43,7 +34,6 @@
43
34
  "scripts": {
44
35
  "build": "vp pack",
45
36
  "dev": "vp pack --watch",
46
- "typecheck": "tsc --noEmit",
47
- "lint": "biome check ."
37
+ "typecheck": "tsc --noEmit"
48
38
  }
49
39
  }
package/dist/index.cjs DELETED
@@ -1,53 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- // \0rolldown/runtime.js
3
- var __create = Object.create;
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getProtoOf = Object.getPrototypeOf;
8
- var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
- key = keys[i];
12
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
13
- get: ((k) => from[k]).bind(null, key),
14
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
- });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
20
- value: mod,
21
- enumerable: true
22
- }) : target, mod));
23
- let zod = require("zod");
24
- zod = __toESM(zod, 1);
25
- // src/index.ts
26
- /**
27
- * Supported color modes available.
28
- */
29
- const ColorMode = {
30
- SYSTEM: "system",
31
- LIGHT: "light",
32
- DARK: "dark"
33
- };
34
- const zColorMode = zod.enum([
35
- ColorMode.SYSTEM,
36
- ColorMode.LIGHT,
37
- ColorMode.DARK
38
- ]);
39
- /**
40
- * Supported locales available. Follows [BCP 47](https://developer.mozilla.org/en-US/docs/Glossary/BCP_47_language_tag) language tags,
41
- * i.e. generally in the format of `{ISO 639-1}-{ISO 3166-1}`.
42
- */
43
- const UserLocale = {
44
- EN_GB: "en-GB",
45
- DE_DE: "de-DE"
46
- };
47
- const zUserLocale = zod.enum(UserLocale);
48
- exports.ColorMode = ColorMode;
49
- exports.UserLocale = UserLocale;
50
- exports.zColorMode = zColorMode;
51
- exports.zUserLocale = zUserLocale;
52
-
53
- //# sourceMappingURL=index.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.cjs","names":["z"],"sources":["../src/index.ts"],"sourcesContent":["import * as z from 'zod'\n\n// -------------------------------------------------------\n\n/**\n * Supported color modes available.\n */\nexport const ColorMode = {\n SYSTEM: 'system',\n LIGHT: 'light',\n DARK: 'dark',\n} as const\n\nexport const zColorMode = z.enum([ColorMode.SYSTEM, ColorMode.LIGHT, ColorMode.DARK] as const)\n\nexport type ColorMode = z.infer<typeof zColorMode>\n\n// -------------------------------------------------------\n\n/**\n * Supported locales available. Follows [BCP 47](https://developer.mozilla.org/en-US/docs/Glossary/BCP_47_language_tag) language tags,\n * i.e. generally in the format of `{ISO 639-1}-{ISO 3166-1}`.\n */\nexport const UserLocale = {\n // @locale-updates\n EN_GB: 'en-GB',\n DE_DE: 'de-DE',\n} as const\n\nexport const zUserLocale = z.enum(UserLocale)\n\nexport type UserLocale = z.infer<typeof zUserLocale>\n\n// -------------------------------------------------------\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,MAAa,YAAY;CACvB,QAAQ;CACR,OAAO;CACP,MAAM;AACR;AAEA,MAAa,aAAaA,IAAE,KAAK;CAAC,UAAU;CAAQ,UAAU;CAAO,UAAU;AAAI,CAAU;;;;;AAU7F,MAAa,aAAa;CAExB,OAAO;CACP,OAAO;AACT;AAEA,MAAa,cAAcA,IAAE,KAAK,UAAU"}
package/dist/index.d.cts DELETED
@@ -1,29 +0,0 @@
1
- import * as z from "zod";
2
- /**
3
- * Supported color modes available.
4
- */
5
- export declare const ColorMode: {
6
- readonly SYSTEM: 'system';
7
- readonly LIGHT: 'light';
8
- readonly DARK: 'dark';
9
- };
10
- export declare const zColorMode: z.ZodEnum<{
11
- dark: "dark";
12
- light: "light";
13
- system: "system";
14
- }>;
15
- export type ColorMode = z.infer<typeof zColorMode>;
16
- /**
17
- * Supported locales available. Follows [BCP 47](https://developer.mozilla.org/en-US/docs/Glossary/BCP_47_language_tag) language tags,
18
- * i.e. generally in the format of `{ISO 639-1}-{ISO 3166-1}`.
19
- */
20
- export declare const UserLocale: {
21
- readonly EN_GB: 'en-GB';
22
- readonly DE_DE: 'de-DE';
23
- };
24
- export declare const zUserLocale: z.ZodEnum<{
25
- readonly EN_GB: 'en-GB';
26
- readonly DE_DE: 'de-DE';
27
- }>;
28
- export type UserLocale = z.infer<typeof zUserLocale>;
29
- //# sourceMappingURL=index.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":";;;;qBAOa;WACX;WACA;WACA;;qBAGW,YAAU,EAAA;;;;;YAEX,YAAY,EAAE,aAAa;;;;;qBAQ1B;WAEX;WACA;;qBAGW,aAAW,EAAA;WAJf;WACA;;YAKG,aAAa,EAAE,aAAa"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;;qBAOa;WACX;WACA;WACA;;qBAGW,YAAU,EAAA;;;;;YAEX,YAAY,EAAE,aAAa;;;;;qBAQ1B;WAEX;WACA;;qBAGW,aAAW,EAAA;WAJf;WACA;;YAKG,aAAa,EAAE,aAAa"}