@rwillians/qx 0.1.2 → 0.1.4

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,7 @@
1
+ import { type ILogger } from './index';
2
+ /**
3
+ * @public Creates a basic console logger that logs all queries.
4
+ * @since 0.1.0
5
+ * @version 1
6
+ */
7
+ export declare const createPrettyLogger: () => ILogger;
@@ -0,0 +1,157 @@
1
+ import * as std from '@standard-schema/spec';
2
+ /**
3
+ * @public The Standard Schema interface.
4
+ * @since 0.1.0
5
+ * @version 1
6
+ */
7
+ export { type StandardSchemaV1 as Schema } from '@standard-schema/spec';
8
+ /**
9
+ * @public Infers the input type of a Standard Schema.
10
+ * @since 0.1.0
11
+ * @version 1
12
+ */
13
+ export type input<T extends std.StandardSchemaV1> = std.StandardSchemaV1.InferInput<T>;
14
+ /**
15
+ * @public Infers the Input type of a Standard Schema.
16
+ * @since 0.1.0
17
+ * @version 1
18
+ */
19
+ export type output<T extends std.StandardSchemaV1> = std.StandardSchemaV1.InferOutput<T>;
20
+ /**
21
+ * @public Use any standard schema to parse a value.
22
+ * @since 0.1.0
23
+ * @version 1
24
+ */
25
+ export declare const parse: <T extends std.StandardSchemaV1>(schema: T, value: unknown) => std.StandardSchemaV1.Result<output<T>>;
26
+ /**
27
+ * @public Defines an array of a given standard schema.
28
+ * @since 0.1.0
29
+ * @version 1
30
+ */
31
+ export type QxArray<T extends std.StandardSchemaV1> = std.StandardSchemaV1<input<T>[], output<T>[]>;
32
+ /**
33
+ * @public Defines an array of a given standard schema.
34
+ * @since 0.1.0
35
+ * @version 1
36
+ */
37
+ export declare const array: <T extends std.StandardSchemaV1>(schema: T) => QxArray<T>;
38
+ /**
39
+ * @public Defines a standard schema for boolean values.
40
+ * @since 0.1.0
41
+ * @version 1
42
+ */
43
+ export type QxBoolean = std.StandardSchemaV1<boolean, boolean>;
44
+ /**
45
+ * @public Defines a standard schema for boolean values.
46
+ * @since 0.1.0
47
+ * @version 1
48
+ */
49
+ export declare const boolean: () => QxBoolean;
50
+ /**
51
+ * @public Defines a standard schema for Date values that can be
52
+ * coerced from ISO 8601 strings or epoch timestamps in
53
+ * milliseconds.
54
+ * @since 0.1.0
55
+ * @version 1
56
+ */
57
+ export type QxCoercibleDate = std.StandardSchemaV1<Date | string | number, Date>;
58
+ /**
59
+ * @public Defines a standard schema for Date values that can be
60
+ * coerced from ISO 8601 strings or epoch timestamps in
61
+ * milliseconds.
62
+ * @since 0.1.0
63
+ * @version 1
64
+ */
65
+ export declare const date: () => QxCoercibleDate;
66
+ /**
67
+ * @public Defines a standard schema that validates instances of a
68
+ * given class.
69
+ * @since 0.1.0
70
+ * @version 1
71
+ */
72
+ export type QxInstanceOf<T> = std.StandardSchemaV1<T, T>;
73
+ /**
74
+ * @public Defines a standard schema that validates instances of a
75
+ * given class.
76
+ * @since 0.1.0
77
+ * @version 1
78
+ */
79
+ export declare const instanceOf: <T>(ctor: new (...args: any[]) => T) => QxInstanceOf<T>;
80
+ /**
81
+ * @public Defines a standard schema for integers with optional min
82
+ * and max constraints.
83
+ * @since 0.1.0
84
+ * @version 1
85
+ */
86
+ export type QxInteger = std.StandardSchemaV1<number, number>;
87
+ /**
88
+ * @public Defines a standard schema for integers with optional min and max constraints.
89
+ * @since 0.1.0
90
+ * @version 1
91
+ */
92
+ export declare const integer: ({ min, max }?: {
93
+ min?: number;
94
+ max?: number;
95
+ }) => QxInteger;
96
+ /**
97
+ * @public Makes any standard schema nullable.
98
+ * @since 0.1.0
99
+ * @version 1
100
+ */
101
+ export type QxNullable<T extends std.StandardSchemaV1 = std.StandardSchemaV1> = std.StandardSchemaV1<input<T> | null, output<T> | null>;
102
+ /**
103
+ * @public Makes any standard schema accepts `null` as a valid value.
104
+ * @since 0.1.0
105
+ * @version 1
106
+ */
107
+ export declare const nullable: <T extends std.StandardSchemaV1>(schema: T) => QxNullable<T>;
108
+ /**
109
+ * @public Defines a standard schema for numbers with optional min
110
+ * and max constraints.
111
+ * @since 0.1.0
112
+ * @version 1
113
+ */
114
+ export type QxNumber = std.StandardSchemaV1<number, number>;
115
+ /**
116
+ * @public Defines a standard schema for numbers with optional min
117
+ * and max constraints.
118
+ * @since 0.1.0
119
+ * @version 1
120
+ */
121
+ export declare const number: ({ min, max }?: {
122
+ min?: number;
123
+ max?: number;
124
+ }) => QxNumber;
125
+ /**
126
+ * @public Defines an object schema that does not allow extra fields.
127
+ * @since 0.1.0
128
+ * @version 1
129
+ */
130
+ type QxStrictObject<T extends Record<string, std.StandardSchemaV1>> = std.StandardSchemaV1<{
131
+ [K in keyof T]: input<T[K]>;
132
+ }, {
133
+ [K in keyof T]: output<T[K]>;
134
+ }>;
135
+ /**
136
+ * @public Defines an object schema that does not allow extra fields.
137
+ * @since 0.1.0
138
+ * @version 1
139
+ */
140
+ export declare const strictObject: <T extends Record<string, std.StandardSchemaV1>>(shape: T) => QxStrictObject<T>;
141
+ /**
142
+ * @public Defines a standard schema for strings with optional min
143
+ * and max length constraints.
144
+ * @since 0.1.0
145
+ * @version 1
146
+ */
147
+ export type QxString = std.StandardSchemaV1<string, string>;
148
+ /**
149
+ * @public Defines a standard schema for strings with optional min
150
+ * and max length constraints.
151
+ * @since 0.1.0
152
+ * @version 1
153
+ */
154
+ export declare const string: ({ min, max }?: {
155
+ min?: number;
156
+ max?: number;
157
+ }) => QxString;
@@ -0,0 +1,50 @@
1
+ /**
2
+ * @private Converts a snake_case string to camelCase.
3
+ * @since 0.1.0
4
+ * @version 1
5
+ */
6
+ export declare const camelCase: (str: string) => string;
7
+ /**
8
+ * @private Simplified check for plain objects.
9
+ * @since 0.1.0
10
+ * @version 1
11
+ */
12
+ export declare const isPlainObject: (value: unknown) => value is Record<string, any>;
13
+ /**
14
+ * @private Throws an error if the given number is greater than the
15
+ * specified maximum.
16
+ * @since 0.1.0
17
+ * @version 1
18
+ */
19
+ export declare const lte: (n: number, max: number) => number;
20
+ /**
21
+ * @public Maps over the keys of an object.
22
+ * @since 0.1.0
23
+ * @version 1
24
+ */
25
+ export declare const mapKeys: <T extends Record<string, any>, U extends string>(obj: T, fn: (key: keyof T) => U) => { [K in U]: T[keyof T]; };
26
+ /**
27
+ * @private Maps over the values of an object.
28
+ * @since 0.1.0
29
+ * @version 1
30
+ */
31
+ export declare const mapValues: <T extends Record<string, any>, U>(obj: T, fn: (value: T[keyof T], key: keyof T) => U) => { [K in keyof T]: U; };
32
+ /**
33
+ * @private Resolves the given value or function to a value.
34
+ * @since 0.1.0
35
+ * @version 1
36
+ */
37
+ export declare const resolve: <T>(value: T | (() => T)) => T;
38
+ /**
39
+ * @private Converts a camelCase string to snake_case.
40
+ * @since 0.1.0
41
+ * @version 1
42
+ */
43
+ export declare const snakeCase: (str: string) => string;
44
+ /**
45
+ * @public Wraps the given value in an array, unless it's already an
46
+ * array.
47
+ * @since 0.1.0
48
+ * @version 1
49
+ */
50
+ export declare const wrap: <T>(value: T | T[]) => T[];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@rwillians/qx",
3
3
  "description": "A teeny tiny ORM for SQLite.",
4
- "version": "0.1.2",
4
+ "version": "0.1.4",
5
5
  "author": "Rafael Willians <me@rwillians.com>",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -25,16 +25,19 @@
25
25
  "files": ["dist/", "LICENSE"],
26
26
  "exports": {
27
27
  ".": {
28
+ "types": "./dist/types/index.d.ts",
28
29
  "import": "./dist/esm/index.js",
29
30
  "require": "./dist/cjs/index.js",
30
31
  "default": "./dist/cjs/index.js"
31
32
  },
32
33
  "./bun-sqlite": {
34
+ "types": "./dist/types/bun-sqlite.d.ts",
33
35
  "import": "./dist/esm/bun-sqlite.js",
34
36
  "require": "./dist/cjs/bun-sqlite.js",
35
37
  "default": "./dist/cjs/bun-sqlite.js"
36
38
  },
37
39
  "./pretty-logger": {
40
+ "types": "./dist/types/pretty-logger.d.ts",
38
41
  "import": "./dist/esm/pretty-logger.js",
39
42
  "require": "./dist/cjs/pretty-logger.js",
40
43
  "default": "./dist/cjs/pretty-logger.js"