@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.
- package/README.md +10 -0
- package/package.json +20 -5
- package/src/create_sqlane.js +1 -0
- package/src/runner.js +137 -22
- package/src/store/mysql_final.js +23 -9
- package/src/store/postgres_final.js +27 -17
- package/src/store/store.js +7 -2
- package/types/adapters/mysql2.d.ts +13 -0
- package/types/adapters/pg.d.ts +16 -0
- package/types/backoff.d.ts +8 -0
- package/types/create_sqlane.d.ts +8 -0
- package/types/defaults.d.ts +18 -0
- package/types/define_job.d.ts +6 -0
- package/types/duration.d.ts +7 -0
- package/types/enqueue.d.ts +50 -0
- package/types/error_json.d.ts +21 -0
- package/types/errors.d.ts +129 -0
- package/types/hint_channel.d.ts +31 -0
- package/types/index.d.ts +72 -0
- package/types/migrations.d.ts +22 -0
- package/types/mutex_keys.d.ts +9 -0
- package/types/new_job.d.ts +40 -0
- package/types/payload.d.ts +10 -0
- package/types/registry.d.ts +72 -0
- package/types/runner.d.ts +92 -0
- package/types/schema/mysql.d.ts +10 -0
- package/types/schema/postgres.d.ts +10 -0
- package/types/store/mysql_enqueue.d.ts +9 -0
- package/types/store/mysql_final.d.ts +135 -0
- package/types/store/mysql_worker.d.ts +51 -0
- package/types/store/postgres_enqueue.d.ts +9 -0
- package/types/store/postgres_final.d.ts +135 -0
- package/types/store/postgres_worker.d.ts +45 -0
- package/types/store/store.d.ts +221 -0
- package/types/transient_error.d.ts +6 -0
- package/types/types.d.ts +651 -0
- package/types/validate.d.ts +76 -0
|
@@ -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;
|