@sqlane/core 0.1.0 → 0.1.2

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,76 @@
1
+ /** A job name: no `:` (the job id is `<name>:<jobId>`), lowercase. */
2
+ export declare const JOB_NAME_REGEXP: RegExp;
3
+ /** A table prefix: the longest table name, `<prefix>migrations`, stays within the 63 characters of PostgreSQL. */
4
+ export declare const TABLE_PREFIX_REGEXP: RegExp;
5
+ /** Printable ASCII, no space at the ends: MySQL `ascii_bin` ignores trailing spaces in comparisons. */
6
+ export declare const PRINTABLE_ID_REGEXP: RegExp;
7
+ export type Scope = {
8
+ /**
9
+ * E.g. `defineJob("build_report")`.
10
+ */
11
+ where: string;
12
+ ErrorClass: new (message: string) => Error;
13
+ };
14
+ /**
15
+ * Where a check runs: for the error message and its class.
16
+ * @typedef {object} Scope
17
+ * @property {string} where E.g. `defineJob("build_report")`.
18
+ * @property {new (message: string) => Error} ErrorClass
19
+ */
20
+ /**
21
+ * @param {unknown} value
22
+ * @returns {value is Record<string, unknown>}
23
+ */
24
+ export declare function isPlainObject(value: unknown): value is Record<string, unknown>;
25
+ /**
26
+ * Throws if the value is not an object with only the allowed keys.
27
+ * @param {unknown} value
28
+ * @param {readonly string[]} allowedKeys
29
+ * @param {string} label E.g. `"options"`.
30
+ * @param {Scope} scope
31
+ * @returns {Record<string, unknown>}
32
+ */
33
+ export declare function checkObject(value: unknown, allowedKeys: readonly string[], label: string, { where, ErrorClass }: Scope): Record<string, unknown>;
34
+ /**
35
+ * @param {unknown} value
36
+ * @param {string} label
37
+ * @param {Scope} scope
38
+ * @param {number} [min] Default: 1.
39
+ */
40
+ export declare function checkInteger(value: unknown, label: string, { where, ErrorClass }: Scope, min?: number): void;
41
+ /**
42
+ * @param {unknown} value
43
+ * @param {string} label
44
+ * @param {Scope} scope
45
+ * @param {boolean} [positive] Default: false: 0 is a duration.
46
+ * @returns {number} Milliseconds.
47
+ */
48
+ export declare function checkDuration(value: unknown, label: string, { where, ErrorClass }: Scope, positive?: boolean): number;
49
+ /**
50
+ * @param {unknown} value
51
+ * @param {Scope} scope
52
+ */
53
+ export declare function checkBackoff(value: unknown, scope: Scope): void;
54
+ /**
55
+ * @param {unknown} value
56
+ * @param {Scope} scope
57
+ */
58
+ export declare function checkRetention(value: unknown, scope: Scope): void;
59
+ /**
60
+ * Checks the options that a definition, the instance defaults and an enqueue share.
61
+ * @param {Record<string, unknown>} options
62
+ * @param {Scope} scope
63
+ */
64
+ export declare function checkJobFields(options: Record<string, unknown>, scope: Scope): void;
65
+ /**
66
+ * @param {unknown} value A name, or a definition.
67
+ * @param {string} jobName The job that names it.
68
+ * @param {Scope} scope
69
+ * @returns {string} The name of the failure job.
70
+ */
71
+ export declare function checkFailureJob(value: unknown, jobName: string, { where, ErrorClass }: Scope): string;
72
+ /**
73
+ * @param {unknown} tablePrefix
74
+ * @param {Scope} scope
75
+ */
76
+ export declare function checkTablePrefix(tablePrefix: unknown, { where, ErrorClass }: Scope): void;