uranio 0.1.12 → 0.1.13

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.
@@ -23,6 +23,6 @@
23
23
  "typescript": "^5.2.2"
24
24
  },
25
25
  "dependencies": {
26
- "uranio": "0.1.12"
26
+ "uranio": "0.1.13"
27
27
  }
28
28
  }
@@ -9,15 +9,17 @@
9
9
  export * from './query';
10
10
 
11
11
  export interface atom {
12
- _id: primary<string>
12
+ _id: string
13
13
  }
14
14
 
15
- export type primary<T> = T & {__uranio: 'primary'};
15
+ // export type primary<T> = T & {__uranio: 'primary'};
16
16
 
17
17
  export type unique<T> = T & {__uranio: 'unique'};
18
18
 
19
- type PrimaryAttribute<A extends atom> = {
20
- [K in keyof A]: A[K] extends {__uranio: 'primary'} ? K : never;
21
- }[keyof A];
19
+ // type PrimaryAttribute<A extends atom> = {
20
+ // [K in keyof A]: A[K] extends {__uranio: 'primary'} ? K : never;
21
+ // }[keyof A];
22
22
 
23
- export type Shape<A extends atom> = Omit<A, PrimaryAttribute<A>>;
23
+ // export type Shape<A extends atom> = Omit<A, PrimaryAttribute<A>>;
24
+
25
+ export type Shape<A extends atom> = Omit<A, '_id'>;
package/dist/bin.js CHANGED
@@ -1,13 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
- var __importDefault = (this && this.__importDefault) || function (mod) {
4
- return (mod && mod.__esModule) ? mod : { "default": mod };
5
- };
6
3
  Object.defineProperty(exports, "__esModule", { value: true });
7
- const i0n_1 = __importDefault(require("i0n"));
8
- const log = i0n_1.default.create();
9
4
  const index_1 = require("./generate/index");
10
- const tsconfig_path = `/Users/x71c9/repos/uranio/builder/tsconfig.json`;
11
- const response = (0, index_1.generate)(tsconfig_path);
12
- log.debug(response);
5
+ const root = `/Users/x71c9/repos/uranio/builder`;
6
+ (0, index_1.generate)({ root });
13
7
  //# sourceMappingURL=bin.js.map
package/dist/bin.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";;;;;;AAEA,8CAAsB;AACtB,MAAM,GAAG,GAAG,aAAG,CAAC,MAAM,EAAE,CAAC;AACzB,4CAA0C;AAC1C,MAAM,aAAa,GAAG,iDAAiD,CAAC;AACxE,MAAM,QAAQ,GAAG,IAAA,gBAAQ,EAAC,aAAa,CAAC,CAAC;AACzC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC"}
1
+ {"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";;;AAEA,4CAA0C;AAC1C,MAAM,IAAI,GAAG,mCAAmC,CAAC;AACjD,IAAA,gBAAQ,EAAC,EAAC,IAAI,EAAC,CAAC,CAAC"}
@@ -3,4 +3,9 @@
3
3
  * Generate index module
4
4
  *
5
5
  */
6
- export declare function generate(tsconfig_path: string): import("plutonio/dist/scanner/types").Scanned;
6
+ type GenerateParams = {
7
+ root: string;
8
+ tsconfig_path?: string;
9
+ };
10
+ export declare function generate(params: GenerateParams): Promise<void>;
11
+ export {};
@@ -4,15 +4,66 @@
4
4
  * Generate index module
5
5
  *
6
6
  */
7
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
+ if (k2 === undefined) k2 = k;
9
+ var desc = Object.getOwnPropertyDescriptor(m, k);
10
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11
+ desc = { enumerable: true, get: function() { return m[k]; } };
12
+ }
13
+ Object.defineProperty(o, k2, desc);
14
+ }) : (function(o, m, k, k2) {
15
+ if (k2 === undefined) k2 = k;
16
+ o[k2] = m[k];
17
+ }));
18
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
19
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
20
+ }) : function(o, v) {
21
+ o["default"] = v;
22
+ });
23
+ var __importStar = (this && this.__importStar) || function (mod) {
24
+ if (mod && mod.__esModule) return mod;
25
+ var result = {};
26
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
27
+ __setModuleDefault(result, mod);
28
+ return result;
29
+ };
7
30
  var __importDefault = (this && this.__importDefault) || function (mod) {
8
31
  return (mod && mod.__esModule) ? mod : { "default": mod };
9
32
  };
10
33
  Object.defineProperty(exports, "__esModule", { value: true });
11
34
  exports.generate = void 0;
35
+ const r4y_1 = __importDefault(require("r4y"));
12
36
  const plutonio_1 = __importDefault(require("plutonio"));
13
- function generate(tsconfig_path) {
14
- const scanned = plutonio_1.default.scanner(tsconfig_path);
15
- return scanned;
37
+ const index_1 = require("./log/index");
38
+ const utils = __importStar(require("../utils/index"));
39
+ r4y_1.default.config.set({
40
+ debug: true,
41
+ });
42
+ async function generate(params) {
43
+ await _copy_dot_uranio(params);
44
+ await _update_dot_uranio(params);
45
+ await _build_dot_uranio(params);
16
46
  }
17
47
  exports.generate = generate;
48
+ async function _copy_dot_uranio(params) {
49
+ const dot_path = `${params.root}/node_modules/uranio/.uranio`;
50
+ const destination_path = `${params.root}/node_modules/.uranio`;
51
+ await r4y_1.default.execute(`rm -rf ${destination_path}`);
52
+ await r4y_1.default.execute(`cp -rf ${dot_path} ${destination_path}`);
53
+ }
54
+ async function _update_dot_uranio(params) {
55
+ const tsconfig_path = _resolve_tsconfig_path(params);
56
+ const scanned = plutonio_1.default.scanner(tsconfig_path);
57
+ index_1.log.info(scanned);
58
+ }
59
+ async function _build_dot_uranio(params) {
60
+ const copied_dot_uranio_tsconfig_path = `${params.root}/node_modules/.uranio/tsconfig.json`;
61
+ await r4y_1.default.execute(`yarn tsc --project ${copied_dot_uranio_tsconfig_path}`);
62
+ }
63
+ function _resolve_tsconfig_path(params) {
64
+ if (utils.valid.string(params.tsconfig_path)) {
65
+ return params.tsconfig_path;
66
+ }
67
+ return `${params.root}/tsconfig.json`;
68
+ }
18
69
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/generate/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;AAEH,wDAAgC;AAEhC,SAAgB,QAAQ,CAAC,aAAqB;IAC5C,MAAM,OAAO,GAAG,kBAAQ,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IAChD,OAAO,OAAO,CAAC;AACjB,CAAC;AAHD,4BAGC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/generate/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,8CAAsB;AACtB,wDAAgC;AAChC,uCAAgC;AAChC,sDAAwC;AAExC,aAAG,CAAC,MAAM,CAAC,GAAG,CAAC;IACb,KAAK,EAAE,IAAI;CACZ,CAAC,CAAC;AAOI,KAAK,UAAU,QAAQ,CAAC,MAAsB;IACnD,MAAM,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAC/B,MAAM,kBAAkB,CAAC,MAAM,CAAC,CAAC;IACjC,MAAM,iBAAiB,CAAC,MAAM,CAAC,CAAC;AAClC,CAAC;AAJD,4BAIC;AAED,KAAK,UAAU,gBAAgB,CAAC,MAAsB;IACpD,MAAM,QAAQ,GAAG,GAAG,MAAM,CAAC,IAAI,8BAA8B,CAAC;IAC9D,MAAM,gBAAgB,GAAG,GAAG,MAAM,CAAC,IAAI,uBAAuB,CAAC;IAC/D,MAAM,aAAG,CAAC,OAAO,CAAC,UAAU,gBAAgB,EAAE,CAAC,CAAC;IAChD,MAAM,aAAG,CAAC,OAAO,CAAC,UAAU,QAAQ,IAAI,gBAAgB,EAAE,CAAC,CAAC;AAC9D,CAAC;AAED,KAAK,UAAU,kBAAkB,CAAC,MAAsB;IACtD,MAAM,aAAa,GAAG,sBAAsB,CAAC,MAAM,CAAC,CAAC;IACrD,MAAM,OAAO,GAAG,kBAAQ,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IAChD,WAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AACpB,CAAC;AAED,KAAK,UAAU,iBAAiB,CAAC,MAAsB;IACrD,MAAM,+BAA+B,GAAG,GAAG,MAAM,CAAC,IAAI,qCAAqC,CAAC;IAC5F,MAAM,aAAG,CAAC,OAAO,CAAC,sBAAsB,+BAA+B,EAAE,CAAC,CAAC;AAC7E,CAAC;AAED,SAAS,sBAAsB,CAAC,MAAsB;IACpD,IAAG,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,EAAC,CAAC;QAC3C,OAAO,MAAM,CAAC,aAAa,CAAC;IAC9B,CAAC;IACD,OAAO,GAAG,MAAM,CAAC,IAAI,gBAAgB,CAAC;AACxC,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ *
3
+ * Log index module
4
+ *
5
+ * @packageDocumentation
6
+ *
7
+ */
8
+ export declare const log: import("i0n/dist/class").Ion;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ /**
3
+ *
4
+ * Log index module
5
+ *
6
+ * @packageDocumentation
7
+ *
8
+ */
9
+ var __importDefault = (this && this.__importDefault) || function (mod) {
10
+ return (mod && mod.__esModule) ? mod : { "default": mod };
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.log = void 0;
14
+ const i0n_1 = __importDefault(require("i0n"));
15
+ exports.log = i0n_1.default.create({
16
+ log_level: i0n_1.default.LOG_LEVEL.TRACE
17
+ });
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/generate/log/index.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;AAEH,8CAAsB;AACT,QAAA,GAAG,GAAG,aAAG,CAAC,MAAM,CAAC;IAC5B,SAAS,EAAE,aAAG,CAAC,SAAS,CAAC,KAAK;CAC/B,CAAC,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ *
3
+ * Utils index module
4
+ *
5
+ * @packageDocumentation
6
+ */
7
+ import * as valid from './valid';
8
+ export { valid };
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ /**
3
+ *
4
+ * Utils index module
5
+ *
6
+ * @packageDocumentation
7
+ */
8
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
+ if (k2 === undefined) k2 = k;
10
+ var desc = Object.getOwnPropertyDescriptor(m, k);
11
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
+ desc = { enumerable: true, get: function() { return m[k]; } };
13
+ }
14
+ Object.defineProperty(o, k2, desc);
15
+ }) : (function(o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ o[k2] = m[k];
18
+ }));
19
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
20
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
21
+ }) : function(o, v) {
22
+ o["default"] = v;
23
+ });
24
+ var __importStar = (this && this.__importStar) || function (mod) {
25
+ if (mod && mod.__esModule) return mod;
26
+ var result = {};
27
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
28
+ __setModuleDefault(result, mod);
29
+ return result;
30
+ };
31
+ Object.defineProperty(exports, "__esModule", { value: true });
32
+ exports.valid = void 0;
33
+ const valid = __importStar(require("./valid"));
34
+ exports.valid = valid;
35
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,+CAAiC;AACzB,sBAAK"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ *
3
+ * Valid module
4
+ *
5
+ * @packageDocumentation
6
+ */
7
+ /**
8
+ * Check if
9
+ * typeof s === 'string' && s !== ''
10
+ */
11
+ export declare function string(s: unknown): s is string;
12
+ /**
13
+ * Check if
14
+ * !!o && typeof o === 'object
15
+ */
16
+ export declare function object(o: unknown): o is Record<string, any>;
17
+ /**
18
+ * Check if
19
+ * typeof n === 'number' && !isNaN(n);
20
+ */
21
+ export declare function number(n: unknown): n is number;
22
+ /**
23
+ * Check if
24
+ * typeof n === 'boolean';
25
+ */
26
+ export declare function boolean(b: unknown): b is boolean;
27
+ /**
28
+ * Check if string is a valid email
29
+ * /^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$/
30
+ */
31
+ export declare function email(e: unknown): e is string;
32
+ /**
33
+ * Check if string is a alphanumeric only (including space)
34
+ * /^[a-zA-Z0-9\s]+$/
35
+ */
36
+ export declare function alphanumeric(s: unknown): s is string;
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ /**
3
+ *
4
+ * Valid module
5
+ *
6
+ * @packageDocumentation
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.alphanumeric = exports.email = exports.boolean = exports.number = exports.object = exports.string = void 0;
10
+ /**
11
+ * Check if
12
+ * typeof s === 'string' && s !== ''
13
+ */
14
+ function string(s) {
15
+ return typeof s === 'string' && s !== '';
16
+ }
17
+ exports.string = string;
18
+ /**
19
+ * Check if
20
+ * !!o && typeof o === 'object
21
+ */
22
+ function object(o) {
23
+ return !!o && typeof o === 'object';
24
+ }
25
+ exports.object = object;
26
+ /**
27
+ * Check if
28
+ * typeof n === 'number' && !isNaN(n);
29
+ */
30
+ function number(n) {
31
+ return typeof n === 'number' && !isNaN(n);
32
+ }
33
+ exports.number = number;
34
+ /**
35
+ * Check if
36
+ * typeof n === 'boolean';
37
+ */
38
+ function boolean(b) {
39
+ return typeof b === 'boolean';
40
+ }
41
+ exports.boolean = boolean;
42
+ /**
43
+ * Check if string is a valid email
44
+ * /^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$/
45
+ */
46
+ function email(e) {
47
+ if (typeof e !== 'string') {
48
+ return false;
49
+ }
50
+ const pattern = /^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$/;
51
+ return pattern.test(e);
52
+ }
53
+ exports.email = email;
54
+ /**
55
+ * Check if string is a alphanumeric only (including space)
56
+ * /^[a-zA-Z0-9\s]+$/
57
+ */
58
+ function alphanumeric(s) {
59
+ if (typeof s !== 'string') {
60
+ return false;
61
+ }
62
+ const pattern = /^[a-zA-Z0-9\s]+$/;
63
+ return pattern.test(s);
64
+ }
65
+ exports.alphanumeric = alphanumeric;
66
+ //# sourceMappingURL=valid.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"valid.js","sourceRoot":"","sources":["../../src/utils/valid.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH;;;GAGG;AACH,SAAgB,MAAM,CAAC,CAAU;IAC/B,OAAO,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,EAAE,CAAC;AAC3C,CAAC;AAFD,wBAEC;AAED;;;GAGG;AACH,SAAgB,MAAM,CAAC,CAAU;IAC/B,OAAO,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,KAAK,QAAQ,CAAC;AACtC,CAAC;AAFD,wBAEC;AAED;;;GAGG;AACH,SAAgB,MAAM,CAAC,CAAU;IAC/B,OAAO,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAC5C,CAAC;AAFD,wBAEC;AAED;;;GAGG;AACH,SAAgB,OAAO,CAAC,CAAU;IAChC,OAAO,OAAO,CAAC,KAAK,SAAS,CAAC;AAChC,CAAC;AAFD,0BAEC;AAED;;;GAGG;AACH,SAAgB,KAAK,CAAC,CAAU;IAC9B,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE,CAAC;QAC1B,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,OAAO,GAAG,kDAAkD,CAAC;IACnE,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACzB,CAAC;AAND,sBAMC;AAED;;;GAGG;AACH,SAAgB,YAAY,CAAC,CAAU;IACrC,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE,CAAC;QAC1B,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,OAAO,GAAG,kBAAkB,CAAC;IACnC,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACzB,CAAC;AAND,oCAMC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "uranio",
3
- "version": "0.1.12",
3
+ "version": "0.1.13",
4
4
  "description": "Uranio is a type-safe ODM for MongoDB",
5
5
  "main": "dist/index.js",
6
6
  "repository": {
@@ -43,6 +43,7 @@
43
43
  "dependencies": {
44
44
  "i0n": "^0.7.3",
45
45
  "mongodb": "^6.3.0",
46
- "plutonio": "^0.4.1"
46
+ "plutonio": "^0.4.1",
47
+ "r4y": "^0.5.1"
47
48
  }
48
49
  }
package/src/bin.ts CHANGED
@@ -1,8 +1,5 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import ion from 'i0n';
4
- const log = ion.create();
5
3
  import {generate} from './generate/index';
6
- const tsconfig_path = `/Users/x71c9/repos/uranio/builder/tsconfig.json`;
7
- const response = generate(tsconfig_path);
8
- log.debug(response);
4
+ const root = `/Users/x71c9/repos/uranio/builder`;
5
+ generate({root});
@@ -4,10 +4,47 @@
4
4
  *
5
5
  */
6
6
 
7
+ import ray from 'r4y';
7
8
  import plutonio from 'plutonio';
9
+ import {log} from './log/index';
10
+ import * as utils from '../utils/index';
8
11
 
9
- export function generate(tsconfig_path: string){
12
+ ray.config.set({
13
+ debug: true,
14
+ });
15
+
16
+ type GenerateParams = {
17
+ root: string
18
+ tsconfig_path?: string
19
+ }
20
+
21
+ export async function generate(params: GenerateParams){
22
+ await _copy_dot_uranio(params);
23
+ await _update_dot_uranio(params);
24
+ await _build_dot_uranio(params);
25
+ }
26
+
27
+ async function _copy_dot_uranio(params: GenerateParams){
28
+ const dot_path = `${params.root}/node_modules/uranio/.uranio`;
29
+ const destination_path = `${params.root}/node_modules/.uranio`;
30
+ await ray.execute(`rm -rf ${destination_path}`);
31
+ await ray.execute(`cp -rf ${dot_path} ${destination_path}`);
32
+ }
33
+
34
+ async function _update_dot_uranio(params: GenerateParams){
35
+ const tsconfig_path = _resolve_tsconfig_path(params);
10
36
  const scanned = plutonio.scanner(tsconfig_path);
11
- return scanned;
37
+ log.info(scanned);
12
38
  }
13
39
 
40
+ async function _build_dot_uranio(params: GenerateParams){
41
+ const copied_dot_uranio_tsconfig_path = `${params.root}/node_modules/.uranio/tsconfig.json`;
42
+ await ray.execute(`yarn tsc --project ${copied_dot_uranio_tsconfig_path}`);
43
+ }
44
+
45
+ function _resolve_tsconfig_path(params: GenerateParams){
46
+ if(utils.valid.string(params.tsconfig_path)){
47
+ return params.tsconfig_path;
48
+ }
49
+ return `${params.root}/tsconfig.json`;
50
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ *
3
+ * Log index module
4
+ *
5
+ * @packageDocumentation
6
+ *
7
+ */
8
+
9
+ import ion from 'i0n';
10
+ export const log = ion.create({
11
+ log_level: ion.LOG_LEVEL.TRACE
12
+ });
@@ -0,0 +1,9 @@
1
+ /**
2
+ *
3
+ * Utils index module
4
+ *
5
+ * @packageDocumentation
6
+ */
7
+
8
+ import * as valid from './valid';
9
+ export {valid};
@@ -0,0 +1,62 @@
1
+ /**
2
+ *
3
+ * Valid module
4
+ *
5
+ * @packageDocumentation
6
+ */
7
+
8
+ /**
9
+ * Check if
10
+ * typeof s === 'string' && s !== ''
11
+ */
12
+ export function string(s: unknown): s is string {
13
+ return typeof s === 'string' && s !== '';
14
+ }
15
+
16
+ /**
17
+ * Check if
18
+ * !!o && typeof o === 'object
19
+ */
20
+ export function object(o: unknown): o is Record<string, any> {
21
+ return !!o && typeof o === 'object';
22
+ }
23
+
24
+ /**
25
+ * Check if
26
+ * typeof n === 'number' && !isNaN(n);
27
+ */
28
+ export function number(n: unknown): n is number {
29
+ return typeof n === 'number' && !isNaN(n);
30
+ }
31
+
32
+ /**
33
+ * Check if
34
+ * typeof n === 'boolean';
35
+ */
36
+ export function boolean(b: unknown): b is boolean {
37
+ return typeof b === 'boolean';
38
+ }
39
+
40
+ /**
41
+ * Check if string is a valid email
42
+ * /^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$/
43
+ */
44
+ export function email(e: unknown): e is string {
45
+ if (typeof e !== 'string') {
46
+ return false;
47
+ }
48
+ const pattern = /^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$/;
49
+ return pattern.test(e);
50
+ }
51
+
52
+ /**
53
+ * Check if string is a alphanumeric only (including space)
54
+ * /^[a-zA-Z0-9\s]+$/
55
+ */
56
+ export function alphanumeric(s: unknown): s is string {
57
+ if (typeof s !== 'string') {
58
+ return false;
59
+ }
60
+ const pattern = /^[a-zA-Z0-9\s]+$/;
61
+ return pattern.test(s);
62
+ }