@rwillians/qx 0.1.10 → 0.1.11

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,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createConsoleLogger = void 0;
4
+ const node_util_1 = require("node:util");
5
+ /**
6
+ * @public Creates a basic console logger that logs all queries.
7
+ * @since 0.1.0
8
+ * @version 1
9
+ */
10
+ const createConsoleLogger = () => ({
11
+ query: {
12
+ debug: (sql, params) => { process.stdout.write(sql + ' ' + (0, node_util_1.inspect)(params, false, null, true) + '\n'); },
13
+ },
14
+ });
15
+ exports.createConsoleLogger = createConsoleLogger;
@@ -1,4 +1,7 @@
1
1
  "use strict";
2
+ // // // // // // // // // // // // // // // // // // // // // // // //
3
+ // STANDARD SCHEMA SPEC //
4
+ // // // // // // // // // // // // // // // // // // // // // // // //
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.string = exports.strictObject = exports.number = exports.nullable = exports.integer = exports.instanceOf = exports.date = exports.boolean = exports.array = exports.parse = void 0;
4
7
  /**
@@ -0,0 +1,12 @@
1
+ import { inspect } from 'node:util';
2
+ import {} from './index';
3
+ /**
4
+ * @public Creates a basic console logger that logs all queries.
5
+ * @since 0.1.0
6
+ * @version 1
7
+ */
8
+ export const createConsoleLogger = () => ({
9
+ query: {
10
+ debug: (sql, params) => { process.stdout.write(sql + ' ' + inspect(params, false, null, true) + '\n'); },
11
+ },
12
+ });
@@ -1,4 +1,6 @@
1
- import * as std from '@standard-schema/spec';
1
+ // // // // // // // // // // // // // // // // // // // // // // // //
2
+ // STANDARD SCHEMA SPEC //
3
+ // // // // // // // // // // // // // // // // // // // // // // // //
2
4
  // // // // // // // // // // // // // // // // // // // // // // // //
3
5
  // STANDARD SCHEMA API //
4
6
  // // // // // // // // // // // // // // // // // // // // // // // //
@@ -7,7 +9,7 @@ import * as std from '@standard-schema/spec';
7
9
  * @since 0.1.0
8
10
  * @version 1
9
11
  */
10
- export {} from '@standard-schema/spec';
12
+ export {};
11
13
  /**
12
14
  * @public Use any standard schema to parse a value.
13
15
  * @since 0.1.0
@@ -4,4 +4,4 @@ import { type ILogger } from './index';
4
4
  * @since 0.1.0
5
5
  * @version 1
6
6
  */
7
- export declare const createPrettyLogger: () => ILogger;
7
+ export declare const createConsoleLogger: () => ILogger;
@@ -1,46 +1,78 @@
1
- import * as std from '@standard-schema/spec';
1
+ interface StandardSchemaV1<Input = unknown, Output = Input> {
2
+ readonly "~standard": StandardSchemaV1.Props<Input, Output>;
3
+ }
4
+ declare namespace StandardSchemaV1 {
5
+ export interface Props<Input = unknown, Output = Input> {
6
+ readonly version: 1;
7
+ readonly vendor: string;
8
+ readonly validate: (value: unknown) => Result<Output> | Promise<Result<Output>>;
9
+ readonly types?: Types<Input, Output> | undefined;
10
+ }
11
+ export type Result<Output> = SuccessResult<Output> | FailureResult;
12
+ export interface SuccessResult<Output> {
13
+ readonly value: Output;
14
+ readonly issues?: undefined;
15
+ }
16
+ export interface FailureResult {
17
+ readonly issues: ReadonlyArray<Issue>;
18
+ }
19
+ export interface Issue {
20
+ readonly message: string;
21
+ readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
22
+ }
23
+ export interface PathSegment {
24
+ readonly key: PropertyKey;
25
+ }
26
+ export interface Types<Input = unknown, Output = Input> {
27
+ readonly input: Input;
28
+ readonly output: Output;
29
+ }
30
+ export type InferInput<Schema extends StandardSchemaV1> = NonNullable<Schema["~standard"]["types"]>["input"];
31
+ export type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema["~standard"]["types"]>["output"];
32
+ export {};
33
+ }
2
34
  /**
3
35
  * @public The Standard Schema interface.
4
36
  * @since 0.1.0
5
37
  * @version 1
6
38
  */
7
- export { type StandardSchemaV1 as Schema } from '@standard-schema/spec';
39
+ export { type StandardSchemaV1 as Schema };
8
40
  /**
9
41
  * @public Infers the input type of a Standard Schema.
10
42
  * @since 0.1.0
11
43
  * @version 1
12
44
  */
13
- export type input<T extends std.StandardSchemaV1> = std.StandardSchemaV1.InferInput<T>;
45
+ export type input<T extends StandardSchemaV1> = StandardSchemaV1.InferInput<T>;
14
46
  /**
15
47
  * @public Infers the Input type of a Standard Schema.
16
48
  * @since 0.1.0
17
49
  * @version 1
18
50
  */
19
- export type output<T extends std.StandardSchemaV1> = std.StandardSchemaV1.InferOutput<T>;
51
+ export type output<T extends StandardSchemaV1> = StandardSchemaV1.InferOutput<T>;
20
52
  /**
21
53
  * @public Use any standard schema to parse a value.
22
54
  * @since 0.1.0
23
55
  * @version 1
24
56
  */
25
- export declare const parse: <T extends std.StandardSchemaV1>(schema: T, value: unknown) => std.StandardSchemaV1.Result<output<T>>;
57
+ export declare const parse: <T extends StandardSchemaV1>(schema: T, value: unknown) => StandardSchemaV1.Result<output<T>>;
26
58
  /**
27
59
  * @public Defines an array of a given standard schema.
28
60
  * @since 0.1.0
29
61
  * @version 1
30
62
  */
31
- export type QxArray<T extends std.StandardSchemaV1> = std.StandardSchemaV1<input<T>[], output<T>[]>;
63
+ export type QxArray<T extends StandardSchemaV1> = StandardSchemaV1<input<T>[], output<T>[]>;
32
64
  /**
33
65
  * @public Defines an array of a given standard schema.
34
66
  * @since 0.1.0
35
67
  * @version 1
36
68
  */
37
- export declare const array: <T extends std.StandardSchemaV1>(schema: T) => QxArray<T>;
69
+ export declare const array: <T extends StandardSchemaV1>(schema: T) => QxArray<T>;
38
70
  /**
39
71
  * @public Defines a standard schema for boolean values.
40
72
  * @since 0.1.0
41
73
  * @version 1
42
74
  */
43
- export type QxBoolean = std.StandardSchemaV1<boolean, boolean>;
75
+ export type QxBoolean = StandardSchemaV1<boolean, boolean>;
44
76
  /**
45
77
  * @public Defines a standard schema for boolean values.
46
78
  * @since 0.1.0
@@ -54,7 +86,7 @@ export declare const boolean: () => QxBoolean;
54
86
  * @since 0.1.0
55
87
  * @version 1
56
88
  */
57
- export type QxCoercibleDate = std.StandardSchemaV1<Date | string | number, Date>;
89
+ export type QxCoercibleDate = StandardSchemaV1<Date | string | number, Date>;
58
90
  /**
59
91
  * @public Defines a standard schema for Date values that can be
60
92
  * coerced from ISO 8601 strings or epoch timestamps in
@@ -69,7 +101,7 @@ export declare const date: () => QxCoercibleDate;
69
101
  * @since 0.1.0
70
102
  * @version 1
71
103
  */
72
- export type QxInstanceOf<T> = std.StandardSchemaV1<T, T>;
104
+ export type QxInstanceOf<T> = StandardSchemaV1<T, T>;
73
105
  /**
74
106
  * @public Defines a standard schema that validates instances of a
75
107
  * given class.
@@ -83,7 +115,7 @@ export declare const instanceOf: <T>(ctor: new (...args: any[]) => T) => QxInsta
83
115
  * @since 0.1.0
84
116
  * @version 1
85
117
  */
86
- export type QxInteger = std.StandardSchemaV1<number, number>;
118
+ export type QxInteger = StandardSchemaV1<number, number>;
87
119
  /**
88
120
  * @public Defines a standard schema for integers with optional min and max constraints.
89
121
  * @since 0.1.0
@@ -98,20 +130,20 @@ export declare const integer: ({ min, max }?: {
98
130
  * @since 0.1.0
99
131
  * @version 1
100
132
  */
101
- export type QxNullable<T extends std.StandardSchemaV1 = std.StandardSchemaV1> = std.StandardSchemaV1<input<T> | null, output<T> | null>;
133
+ export type QxNullable<T extends StandardSchemaV1 = StandardSchemaV1> = StandardSchemaV1<input<T> | null, output<T> | null>;
102
134
  /**
103
135
  * @public Makes any standard schema accepts `null` as a valid value.
104
136
  * @since 0.1.0
105
137
  * @version 1
106
138
  */
107
- export declare const nullable: <T extends std.StandardSchemaV1>(schema: T) => QxNullable<T>;
139
+ export declare const nullable: <T extends StandardSchemaV1>(schema: T) => QxNullable<T>;
108
140
  /**
109
141
  * @public Defines a standard schema for numbers with optional min
110
142
  * and max constraints.
111
143
  * @since 0.1.0
112
144
  * @version 1
113
145
  */
114
- export type QxNumber = std.StandardSchemaV1<number, number>;
146
+ export type QxNumber = StandardSchemaV1<number, number>;
115
147
  /**
116
148
  * @public Defines a standard schema for numbers with optional min
117
149
  * and max constraints.
@@ -127,7 +159,7 @@ export declare const number: ({ min, max }?: {
127
159
  * @since 0.1.0
128
160
  * @version 1
129
161
  */
130
- type QxStrictObject<T extends Record<string, std.StandardSchemaV1>> = std.StandardSchemaV1<{
162
+ type QxStrictObject<T extends Record<string, StandardSchemaV1>> = StandardSchemaV1<{
131
163
  [K in keyof T]: input<T[K]>;
132
164
  }, {
133
165
  [K in keyof T]: output<T[K]>;
@@ -137,14 +169,14 @@ type QxStrictObject<T extends Record<string, std.StandardSchemaV1>> = std.Standa
137
169
  * @since 0.1.0
138
170
  * @version 1
139
171
  */
140
- export declare const strictObject: <T extends Record<string, std.StandardSchemaV1>>(shape: T) => QxStrictObject<T>;
172
+ export declare const strictObject: <T extends Record<string, StandardSchemaV1>>(shape: T) => QxStrictObject<T>;
141
173
  /**
142
174
  * @public Defines a standard schema for strings with optional min
143
175
  * and max length constraints.
144
176
  * @since 0.1.0
145
177
  * @version 1
146
178
  */
147
- export type QxString = std.StandardSchemaV1<string, string>;
179
+ export type QxString = StandardSchemaV1<string, string>;
148
180
  /**
149
181
  * @public Defines a standard schema for strings with optional min
150
182
  * and max length constraints.
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.10",
4
+ "version": "0.1.11",
5
5
  "author": "Rafael Willians <me@rwillians.com>",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -54,10 +54,6 @@
54
54
  "build:cjs": "bun run --bun tsc --project tsconfig-cjs.json",
55
55
  "build:esm": "bun run --bun tsc --project tsconfig-esm.json"
56
56
  },
57
- "dependencies": {
58
- "@standard-schema/spec": "^1.0.0",
59
- "sql-highlight": "^6.1.0"
60
- },
61
57
  "devDependencies": {
62
58
  "@types/bun": "latest"
63
59
  },
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createPrettyLogger = void 0;
4
- const node_util_1 = require("node:util");
5
- const sql_highlight_1 = require("sql-highlight");
6
- /**
7
- * @public Creates a basic console logger that logs all queries.
8
- * @since 0.1.0
9
- * @version 1
10
- */
11
- const createPrettyLogger = () => ({
12
- query: {
13
- debug: (sql, params) => { process.stdout.write((0, sql_highlight_1.highlight)(sql) + ' ' + (0, node_util_1.inspect)(params, false, null, true) + '\n'); },
14
- },
15
- });
16
- exports.createPrettyLogger = createPrettyLogger;
@@ -1,13 +0,0 @@
1
- import { inspect } from 'node:util';
2
- import { highlight } from 'sql-highlight';
3
- import {} from './index';
4
- /**
5
- * @public Creates a basic console logger that logs all queries.
6
- * @since 0.1.0
7
- * @version 1
8
- */
9
- export const createPrettyLogger = () => ({
10
- query: {
11
- debug: (sql, params) => { process.stdout.write(highlight(sql) + ' ' + inspect(params, false, null, true) + '\n'); },
12
- },
13
- });