joist-utils 2.3.0-next.7 → 2.3.0-next.70
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/build/Deferred.cjs +44 -0
- package/build/Deferred.cjs.map +1 -0
- package/build/Deferred.d.cts +18 -0
- package/build/Deferred.d.cts.map +1 -0
- package/build/Deferred.d.mts +18 -0
- package/build/Deferred.d.mts.map +1 -0
- package/build/Deferred.js +42 -46
- package/build/Deferred.js.map +1 -1
- package/build/connection.cjs +48 -0
- package/build/connection.cjs.map +1 -0
- package/build/{connection.d.ts → connection.d.cts} +23 -18
- package/build/connection.d.cts.map +1 -0
- package/build/connection.d.mts +46 -0
- package/build/connection.d.mts.map +1 -0
- package/build/connection.js +43 -43
- package/build/connection.js.map +1 -1
- package/build/index.cjs +38 -0
- package/build/index.cjs.map +1 -0
- package/build/index.d.cts +12 -0
- package/build/index.d.cts.map +1 -0
- package/build/index.d.mts +12 -0
- package/build/index.d.mts.map +1 -0
- package/build/index.js +24 -34
- package/build/index.js.map +1 -1
- package/build/is-plain-object.cjs +24 -0
- package/build/is-plain-object.cjs.map +1 -0
- package/build/is-plain-object.d.cts +11 -0
- package/build/is-plain-object.d.cts.map +1 -0
- package/build/is-plain-object.d.mts +11 -0
- package/build/is-plain-object.d.mts.map +1 -0
- package/build/is-plain-object.js +17 -26
- package/build/is-plain-object.js.map +1 -1
- package/build/stripAnsi.cjs +10 -0
- package/build/stripAnsi.cjs.map +1 -0
- package/build/stripAnsi.d.cts +6 -0
- package/build/stripAnsi.d.cts.map +1 -0
- package/build/stripAnsi.d.mts +6 -0
- package/build/stripAnsi.d.mts.map +1 -0
- package/build/stripAnsi.js +5 -4
- package/build/stripAnsi.js.map +1 -1
- package/package.json +30 -11
- package/build/Deferred.d.ts +0 -15
- package/build/Deferred.d.ts.map +0 -1
- package/build/connection.d.ts.map +0 -1
- package/build/connection.test.d.ts +0 -2
- package/build/connection.test.d.ts.map +0 -1
- package/build/connection.test.js +0 -46
- package/build/connection.test.js.map +0 -1
- package/build/index.d.ts +0 -9
- package/build/index.d.ts.map +0 -1
- package/build/is-plain-object.d.ts +0 -8
- package/build/is-plain-object.d.ts.map +0 -1
- package/build/stripAnsi.d.ts +0 -3
- package/build/stripAnsi.d.ts.map +0 -1
- package/build/stripAnsi.test.d.ts +0 -2
- package/build/stripAnsi.test.d.ts.map +0 -1
- package/build/stripAnsi.test.js +0 -9
- package/build/stripAnsi.test.js.map +0 -1
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region src/Deferred.ts
|
|
3
|
+
var Deferred = class {
|
|
4
|
+
promise;
|
|
5
|
+
fate;
|
|
6
|
+
state;
|
|
7
|
+
_resolve;
|
|
8
|
+
_reject;
|
|
9
|
+
constructor() {
|
|
10
|
+
this.state = "pending";
|
|
11
|
+
this.fate = "unresolved";
|
|
12
|
+
this.promise = new Promise((resolve, reject) => {
|
|
13
|
+
this._resolve = resolve;
|
|
14
|
+
this._reject = reject;
|
|
15
|
+
});
|
|
16
|
+
this.promise.then(() => this.state = "fulfilled", () => this.state = "rejected");
|
|
17
|
+
}
|
|
18
|
+
resolve(value) {
|
|
19
|
+
if (this.fate === "resolved") throw "Deferred cannot be resolved twice";
|
|
20
|
+
this.fate = "resolved";
|
|
21
|
+
this._resolve(value);
|
|
22
|
+
}
|
|
23
|
+
reject(reason) {
|
|
24
|
+
if (this.fate === "resolved") throw "Deferred cannot be resolved twice";
|
|
25
|
+
this.fate = "resolved";
|
|
26
|
+
this._reject(reason);
|
|
27
|
+
}
|
|
28
|
+
isResolved() {
|
|
29
|
+
return this.fate === "resolved";
|
|
30
|
+
}
|
|
31
|
+
isPending() {
|
|
32
|
+
return this.state === "pending";
|
|
33
|
+
}
|
|
34
|
+
isFulfilled() {
|
|
35
|
+
return this.state === "fulfilled";
|
|
36
|
+
}
|
|
37
|
+
isRejected() {
|
|
38
|
+
return this.state === "rejected";
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
//#endregion
|
|
42
|
+
exports.Deferred = Deferred;
|
|
43
|
+
|
|
44
|
+
//# sourceMappingURL=Deferred.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Deferred.cjs","names":[],"sources":["../src/Deferred.ts"],"sourcesContent":["export class Deferred<T> {\n public promise: Promise<T>;\n private fate: \"resolved\" | \"unresolved\";\n private state: \"pending\" | \"fulfilled\" | \"rejected\";\n private _resolve!: Function;\n private _reject!: Function;\n\n constructor() {\n this.state = \"pending\";\n this.fate = \"unresolved\";\n this.promise = new Promise((resolve, reject) => {\n this._resolve = resolve;\n this._reject = reject;\n });\n this.promise.then(\n () => (this.state = \"fulfilled\"),\n () => (this.state = \"rejected\"),\n );\n }\n\n resolve(value?: any) {\n if (this.fate === \"resolved\") {\n throw \"Deferred cannot be resolved twice\";\n }\n this.fate = \"resolved\";\n this._resolve(value);\n }\n\n reject(reason?: any) {\n if (this.fate === \"resolved\") {\n throw \"Deferred cannot be resolved twice\";\n }\n this.fate = \"resolved\";\n this._reject(reason);\n }\n\n isResolved() {\n return this.fate === \"resolved\";\n }\n\n isPending() {\n return this.state === \"pending\";\n }\n\n isFulfilled() {\n return this.state === \"fulfilled\";\n }\n\n isRejected() {\n return this.state === \"rejected\";\n }\n}\n"],"mappings":";;AAAA,IAAa,WAAb,MAAyB;CACvB;CACA;CACA;CACA;CACA;CAEA,cAAc;EACZ,KAAK,QAAQ;EACb,KAAK,OAAO;EACZ,KAAK,UAAU,IAAI,SAAS,SAAS,WAAW;GAC9C,KAAK,WAAW;GAChB,KAAK,UAAU;EACjB,CAAC;EACD,KAAK,QAAQ,WACJ,KAAK,QAAQ,mBACb,KAAK,QAAQ,UACtB;CACF;CAEA,QAAQ,OAAa;EACnB,IAAI,KAAK,SAAS,YAChB,MAAM;EAER,KAAK,OAAO;EACZ,KAAK,SAAS,KAAK;CACrB;CAEA,OAAO,QAAc;EACnB,IAAI,KAAK,SAAS,YAChB,MAAM;EAER,KAAK,OAAO;EACZ,KAAK,QAAQ,MAAM;CACrB;CAEA,aAAa;EACX,OAAO,KAAK,SAAS;CACvB;CAEA,YAAY;EACV,OAAO,KAAK,UAAU;CACxB;CAEA,cAAc;EACZ,OAAO,KAAK,UAAU;CACxB;CAEA,aAAa;EACX,OAAO,KAAK,UAAU;CACxB;AACF"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//#region src/Deferred.d.ts
|
|
2
|
+
declare class Deferred<T> {
|
|
3
|
+
promise: Promise<T>;
|
|
4
|
+
private fate;
|
|
5
|
+
private state;
|
|
6
|
+
private _resolve;
|
|
7
|
+
private _reject;
|
|
8
|
+
constructor();
|
|
9
|
+
resolve(value?: any): void;
|
|
10
|
+
reject(reason?: any): void;
|
|
11
|
+
isResolved(): boolean;
|
|
12
|
+
isPending(): boolean;
|
|
13
|
+
isFulfilled(): boolean;
|
|
14
|
+
isRejected(): boolean;
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
export { Deferred };
|
|
18
|
+
//# sourceMappingURL=Deferred.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Deferred.d.cts","names":[],"sources":["../src/Deferred.ts"],"mappings":";cAAa,SAAS;EACb,SAAS,QAAQ;UAChB;UACA;UACA;UACA;EAER;EAaA,QAAQ;EAQR,OAAO;EAQP;EAIA;EAIA;EAIA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//#region src/Deferred.d.ts
|
|
2
|
+
declare class Deferred<T> {
|
|
3
|
+
promise: Promise<T>;
|
|
4
|
+
private fate;
|
|
5
|
+
private state;
|
|
6
|
+
private _resolve;
|
|
7
|
+
private _reject;
|
|
8
|
+
constructor();
|
|
9
|
+
resolve(value?: any): void;
|
|
10
|
+
reject(reason?: any): void;
|
|
11
|
+
isResolved(): boolean;
|
|
12
|
+
isPending(): boolean;
|
|
13
|
+
isFulfilled(): boolean;
|
|
14
|
+
isRejected(): boolean;
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
export { Deferred };
|
|
18
|
+
//# sourceMappingURL=Deferred.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Deferred.d.mts","names":[],"sources":["../src/Deferred.ts"],"mappings":";cAAa,SAAS;EACb,SAAS,QAAQ;UAChB;UACA;UACA;UACA;EAER;EAaA,QAAQ;EAQR,OAAO;EAQP;EAIA;EAIA;EAIA"}
|
package/build/Deferred.js
CHANGED
|
@@ -1,47 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
return this.state === "rejected";
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
exports.Deferred = Deferred;
|
|
1
|
+
//#region src/Deferred.ts
|
|
2
|
+
var Deferred = class {
|
|
3
|
+
promise;
|
|
4
|
+
fate;
|
|
5
|
+
state;
|
|
6
|
+
_resolve;
|
|
7
|
+
_reject;
|
|
8
|
+
constructor() {
|
|
9
|
+
this.state = "pending";
|
|
10
|
+
this.fate = "unresolved";
|
|
11
|
+
this.promise = new Promise((resolve, reject) => {
|
|
12
|
+
this._resolve = resolve;
|
|
13
|
+
this._reject = reject;
|
|
14
|
+
});
|
|
15
|
+
this.promise.then(() => this.state = "fulfilled", () => this.state = "rejected");
|
|
16
|
+
}
|
|
17
|
+
resolve(value) {
|
|
18
|
+
if (this.fate === "resolved") throw "Deferred cannot be resolved twice";
|
|
19
|
+
this.fate = "resolved";
|
|
20
|
+
this._resolve(value);
|
|
21
|
+
}
|
|
22
|
+
reject(reason) {
|
|
23
|
+
if (this.fate === "resolved") throw "Deferred cannot be resolved twice";
|
|
24
|
+
this.fate = "resolved";
|
|
25
|
+
this._reject(reason);
|
|
26
|
+
}
|
|
27
|
+
isResolved() {
|
|
28
|
+
return this.fate === "resolved";
|
|
29
|
+
}
|
|
30
|
+
isPending() {
|
|
31
|
+
return this.state === "pending";
|
|
32
|
+
}
|
|
33
|
+
isFulfilled() {
|
|
34
|
+
return this.state === "fulfilled";
|
|
35
|
+
}
|
|
36
|
+
isRejected() {
|
|
37
|
+
return this.state === "rejected";
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
//#endregion
|
|
41
|
+
export { Deferred };
|
|
42
|
+
|
|
47
43
|
//# sourceMappingURL=Deferred.js.map
|
package/build/Deferred.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Deferred.js","
|
|
1
|
+
{"version":3,"file":"Deferred.js","names":[],"sources":["../src/Deferred.ts"],"sourcesContent":["export class Deferred<T> {\n public promise: Promise<T>;\n private fate: \"resolved\" | \"unresolved\";\n private state: \"pending\" | \"fulfilled\" | \"rejected\";\n private _resolve!: Function;\n private _reject!: Function;\n\n constructor() {\n this.state = \"pending\";\n this.fate = \"unresolved\";\n this.promise = new Promise((resolve, reject) => {\n this._resolve = resolve;\n this._reject = reject;\n });\n this.promise.then(\n () => (this.state = \"fulfilled\"),\n () => (this.state = \"rejected\"),\n );\n }\n\n resolve(value?: any) {\n if (this.fate === \"resolved\") {\n throw \"Deferred cannot be resolved twice\";\n }\n this.fate = \"resolved\";\n this._resolve(value);\n }\n\n reject(reason?: any) {\n if (this.fate === \"resolved\") {\n throw \"Deferred cannot be resolved twice\";\n }\n this.fate = \"resolved\";\n this._reject(reason);\n }\n\n isResolved() {\n return this.fate === \"resolved\";\n }\n\n isPending() {\n return this.state === \"pending\";\n }\n\n isFulfilled() {\n return this.state === \"fulfilled\";\n }\n\n isRejected() {\n return this.state === \"rejected\";\n }\n}\n"],"mappings":";AAAA,IAAa,WAAb,MAAyB;CACvB;CACA;CACA;CACA;CACA;CAEA,cAAc;EACZ,KAAK,QAAQ;EACb,KAAK,OAAO;EACZ,KAAK,UAAU,IAAI,SAAS,SAAS,WAAW;GAC9C,KAAK,WAAW;GAChB,KAAK,UAAU;EACjB,CAAC;EACD,KAAK,QAAQ,WACJ,KAAK,QAAQ,mBACb,KAAK,QAAQ,UACtB;CACF;CAEA,QAAQ,OAAa;EACnB,IAAI,KAAK,SAAS,YAChB,MAAM;EAER,KAAK,OAAO;EACZ,KAAK,SAAS,KAAK;CACrB;CAEA,OAAO,QAAc;EACnB,IAAI,KAAK,SAAS,YAChB,MAAM;EAER,KAAK,OAAO;EACZ,KAAK,QAAQ,MAAM;CACrB;CAEA,aAAa;EACX,OAAO,KAAK,SAAS;CACvB;CAEA,YAAY;EACV,OAAO,KAAK,UAAU;CACxB;CAEA,cAAc;EACZ,OAAO,KAAK,UAAU;CACxB;CAEA,aAAa;EACX,OAAO,KAAK,UAAU;CACxB;AACF"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
let pg_connection_string = require("pg-connection-string");
|
|
3
|
+
//#region src/connection.ts
|
|
4
|
+
/**
|
|
5
|
+
* Returns the `ConnectionConfig` that joist will use to connect to pg.
|
|
6
|
+
*
|
|
7
|
+
* This reads environment variables, and can be either:
|
|
8
|
+
*
|
|
9
|
+
* - A single `DATABASE_URL` variable
|
|
10
|
+
* - Multiple `DB_USER`, `DB_PASSWORD`, `DB_DATABASE`, `DB_HOST`, `DB_PORT` variables
|
|
11
|
+
* The value can be either:
|
|
12
|
+
*
|
|
13
|
+
* Query pipelining is enabled by default. Set `pipeline: false` on the returned config to opt out.
|
|
14
|
+
*
|
|
15
|
+
* Note that users using a library for typed / validated environment variables, i.e.
|
|
16
|
+
* ts-app-env, you can pass in a specific `env` variable.
|
|
17
|
+
*/
|
|
18
|
+
function newPgConnectionConfig(env) {
|
|
19
|
+
if (process.env.DATABASE_URL || env && "DATABASE_URL" in env) {
|
|
20
|
+
const url = process.env.DATABASE_URL ?? env.DATABASE_URL;
|
|
21
|
+
const options = (0, pg_connection_string.parse)(url);
|
|
22
|
+
const { database, port, host, user, password } = options;
|
|
23
|
+
return {
|
|
24
|
+
user: user ?? void 0,
|
|
25
|
+
password: password ?? void 0,
|
|
26
|
+
database: database ?? void 0,
|
|
27
|
+
host: host ?? void 0,
|
|
28
|
+
port: port ? Number(port) : void 0,
|
|
29
|
+
ssl: options.ssl === true,
|
|
30
|
+
pipeline: true
|
|
31
|
+
};
|
|
32
|
+
} else if (process.env.DB_DATABASE || env && "DB_DATABASE" in env) {
|
|
33
|
+
const e = process.env.DB_DATABASE ? process.env : env;
|
|
34
|
+
return {
|
|
35
|
+
user: e.DB_USER,
|
|
36
|
+
password: e.DB_PASSWORD,
|
|
37
|
+
database: e.DB_DATABASE,
|
|
38
|
+
host: e.DB_HOST,
|
|
39
|
+
port: e.DB_PORT ? Number(e.DB_PORT) : void 0,
|
|
40
|
+
ssl: e.DB_SSL === "1" || e.DB_SSL === "true",
|
|
41
|
+
pipeline: true
|
|
42
|
+
};
|
|
43
|
+
} else throw new Error("No DATABASE_URL or DB_DATABASE/etc. environment variable found");
|
|
44
|
+
}
|
|
45
|
+
//#endregion
|
|
46
|
+
exports.newPgConnectionConfig = newPgConnectionConfig;
|
|
47
|
+
|
|
48
|
+
//# sourceMappingURL=connection.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection.cjs","names":["parse"],"sources":["../src/connection.ts"],"sourcesContent":["import { parse } from \"pg-connection-string\";\n\ntype DatabaseUrlEnv = { DATABASE_URL: string };\ntype DbSettingsEnv = {\n DB_USER: string;\n DB_PASSWORD: string;\n DB_HOST: string;\n DB_DATABASE: string;\n DB_PORT: string;\n DB_SSL?: string;\n};\n\nexport type ConnectionEnv = DatabaseUrlEnv | DbSettingsEnv;\n\n/**\n * A simple connection config compatible with both `pg.Pool` and knex.\n *\n * We use a plain object type instead of pg's `ConnectionConfig` to avoid\n * pulling in pg-specific fields (like `types`) that are incompatible with knex.\n */\nexport type ConnectionConfig = {\n user?: string;\n password?: string;\n database?: string;\n host?: string;\n port?: number;\n ssl?: boolean;\n pipeline?: boolean;\n};\n\n/**\n * Returns the `ConnectionConfig` that joist will use to connect to pg.\n *\n * This reads environment variables, and can be either:\n *\n * - A single `DATABASE_URL` variable\n * - Multiple `DB_USER`, `DB_PASSWORD`, `DB_DATABASE`, `DB_HOST`, `DB_PORT` variables\n * The value can be either:\n *\n * Query pipelining is enabled by default. Set `pipeline: false` on the returned config to opt out.\n *\n * Note that users using a library for typed / validated environment variables, i.e.\n * ts-app-env, you can pass in a specific `env` variable.\n */\nexport function newPgConnectionConfig(env?: ConnectionEnv): ConnectionConfig {\n if (process.env.DATABASE_URL || (env && \"DATABASE_URL\" in env)) {\n const url = process.env.DATABASE_URL ?? (env as DatabaseUrlEnv).DATABASE_URL;\n // It'd be great if `parse` returned ConnectionConfig directly\n const options = parse(url);\n const { database, port, host, user, password } = options;\n return {\n user: user ?? undefined,\n password: password ?? undefined,\n database: database ?? undefined,\n host: host ?? undefined,\n port: port ? Number(port) : undefined,\n ssl: options.ssl === true,\n pipeline: true,\n };\n } else if (process.env.DB_DATABASE || (env && \"DB_DATABASE\" in env)) {\n const e = process.env.DB_DATABASE ? process.env : (env as DbSettingsEnv);\n return {\n user: e.DB_USER,\n password: e.DB_PASSWORD,\n database: e.DB_DATABASE,\n host: e.DB_HOST,\n port: e.DB_PORT ? Number(e.DB_PORT) : undefined,\n ssl: e.DB_SSL === \"1\" || e.DB_SSL === \"true\",\n pipeline: true,\n };\n } else {\n throw new Error(\"No DATABASE_URL or DB_DATABASE/etc. environment variable found\");\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AA4CA,SAAgB,sBAAsB,KAAuC;CAC3E,IAAI,QAAQ,IAAI,gBAAiB,OAAO,kBAAkB,KAAM;EAC9D,MAAM,MAAM,QAAQ,IAAI,gBAAiB,IAAuB;EAEhE,MAAM,WAAA,GAAUA,qBAAAA,MAAAA,CAAM,GAAG;EACzB,MAAM,EAAE,UAAU,MAAM,MAAM,MAAM,aAAa;EACjD,OAAO;GACL,MAAM,QAAQ,KAAA;GACd,UAAU,YAAY,KAAA;GACtB,UAAU,YAAY,KAAA;GACtB,MAAM,QAAQ,KAAA;GACd,MAAM,OAAO,OAAO,IAAI,IAAI,KAAA;GAC5B,KAAK,QAAQ,QAAQ;GACrB,UAAU;EACZ;CACF,OAAO,IAAI,QAAQ,IAAI,eAAgB,OAAO,iBAAiB,KAAM;EACnE,MAAM,IAAI,QAAQ,IAAI,cAAc,QAAQ,MAAO;EACnD,OAAO;GACL,MAAM,EAAE;GACR,UAAU,EAAE;GACZ,UAAU,EAAE;GACZ,MAAM,EAAE;GACR,MAAM,EAAE,UAAU,OAAO,EAAE,OAAO,IAAI,KAAA;GACtC,KAAK,EAAE,WAAW,OAAO,EAAE,WAAW;GACtC,UAAU;EACZ;CACF,OACE,MAAM,IAAI,MAAM,gEAAgE;AAEpF"}
|
|
@@ -1,28 +1,30 @@
|
|
|
1
|
+
//#region src/connection.d.ts
|
|
1
2
|
type DatabaseUrlEnv = {
|
|
2
|
-
|
|
3
|
+
DATABASE_URL: string;
|
|
3
4
|
};
|
|
4
5
|
type DbSettingsEnv = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
DB_USER: string;
|
|
7
|
+
DB_PASSWORD: string;
|
|
8
|
+
DB_HOST: string;
|
|
9
|
+
DB_DATABASE: string;
|
|
10
|
+
DB_PORT: string;
|
|
11
|
+
DB_SSL?: string;
|
|
11
12
|
};
|
|
12
|
-
|
|
13
|
+
type ConnectionEnv = DatabaseUrlEnv | DbSettingsEnv;
|
|
13
14
|
/**
|
|
14
15
|
* A simple connection config compatible with both `pg.Pool` and knex.
|
|
15
16
|
*
|
|
16
17
|
* We use a plain object type instead of pg's `ConnectionConfig` to avoid
|
|
17
18
|
* pulling in pg-specific fields (like `types`) that are incompatible with knex.
|
|
18
19
|
*/
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
type ConnectionConfig = {
|
|
21
|
+
user?: string;
|
|
22
|
+
password?: string;
|
|
23
|
+
database?: string;
|
|
24
|
+
host?: string;
|
|
25
|
+
port?: number;
|
|
26
|
+
ssl?: boolean;
|
|
27
|
+
pipeline?: boolean;
|
|
26
28
|
};
|
|
27
29
|
/**
|
|
28
30
|
* Returns the `ConnectionConfig` that joist will use to connect to pg.
|
|
@@ -33,9 +35,12 @@ export type ConnectionConfig = {
|
|
|
33
35
|
* - Multiple `DB_USER`, `DB_PASSWORD`, `DB_DATABASE`, `DB_HOST`, `DB_PORT` variables
|
|
34
36
|
* The value can be either:
|
|
35
37
|
*
|
|
38
|
+
* Query pipelining is enabled by default. Set `pipeline: false` on the returned config to opt out.
|
|
39
|
+
*
|
|
36
40
|
* Note that users using a library for typed / validated environment variables, i.e.
|
|
37
41
|
* ts-app-env, you can pass in a specific `env` variable.
|
|
38
42
|
*/
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
43
|
+
declare function newPgConnectionConfig(env?: ConnectionEnv): ConnectionConfig;
|
|
44
|
+
//#endregion
|
|
45
|
+
export { ConnectionConfig, ConnectionEnv, newPgConnectionConfig };
|
|
46
|
+
//# sourceMappingURL=connection.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection.d.cts","names":[],"sources":["../src/connection.ts"],"mappings":";KAEK;EAAmB;;KACnB;EACH;EACA;EACA;EACA;EACA;EACA;;KAGU,gBAAgB,iBAAiB;;;;;;;KAQjC;EACV;EACA;EACA;EACA;EACA;EACA;EACA;;;;;;;;;;;;;;;;iBAiBc,sBAAsB,MAAM,gBAAgB"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
//#region src/connection.d.ts
|
|
2
|
+
type DatabaseUrlEnv = {
|
|
3
|
+
DATABASE_URL: string;
|
|
4
|
+
};
|
|
5
|
+
type DbSettingsEnv = {
|
|
6
|
+
DB_USER: string;
|
|
7
|
+
DB_PASSWORD: string;
|
|
8
|
+
DB_HOST: string;
|
|
9
|
+
DB_DATABASE: string;
|
|
10
|
+
DB_PORT: string;
|
|
11
|
+
DB_SSL?: string;
|
|
12
|
+
};
|
|
13
|
+
type ConnectionEnv = DatabaseUrlEnv | DbSettingsEnv;
|
|
14
|
+
/**
|
|
15
|
+
* A simple connection config compatible with both `pg.Pool` and knex.
|
|
16
|
+
*
|
|
17
|
+
* We use a plain object type instead of pg's `ConnectionConfig` to avoid
|
|
18
|
+
* pulling in pg-specific fields (like `types`) that are incompatible with knex.
|
|
19
|
+
*/
|
|
20
|
+
type ConnectionConfig = {
|
|
21
|
+
user?: string;
|
|
22
|
+
password?: string;
|
|
23
|
+
database?: string;
|
|
24
|
+
host?: string;
|
|
25
|
+
port?: number;
|
|
26
|
+
ssl?: boolean;
|
|
27
|
+
pipeline?: boolean;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Returns the `ConnectionConfig` that joist will use to connect to pg.
|
|
31
|
+
*
|
|
32
|
+
* This reads environment variables, and can be either:
|
|
33
|
+
*
|
|
34
|
+
* - A single `DATABASE_URL` variable
|
|
35
|
+
* - Multiple `DB_USER`, `DB_PASSWORD`, `DB_DATABASE`, `DB_HOST`, `DB_PORT` variables
|
|
36
|
+
* The value can be either:
|
|
37
|
+
*
|
|
38
|
+
* Query pipelining is enabled by default. Set `pipeline: false` on the returned config to opt out.
|
|
39
|
+
*
|
|
40
|
+
* Note that users using a library for typed / validated environment variables, i.e.
|
|
41
|
+
* ts-app-env, you can pass in a specific `env` variable.
|
|
42
|
+
*/
|
|
43
|
+
declare function newPgConnectionConfig(env?: ConnectionEnv): ConnectionConfig;
|
|
44
|
+
//#endregion
|
|
45
|
+
export { ConnectionConfig, ConnectionEnv, newPgConnectionConfig };
|
|
46
|
+
//# sourceMappingURL=connection.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection.d.mts","names":[],"sources":["../src/connection.ts"],"mappings":";KAEK;EAAmB;;KACnB;EACH;EACA;EACA;EACA;EACA;EACA;;KAGU,gBAAgB,iBAAiB;;;;;;;KAQjC;EACV;EACA;EACA;EACA;EACA;EACA;EACA;;;;;;;;;;;;;;;;iBAiBc,sBAAsB,MAAM,gBAAgB"}
|
package/build/connection.js
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.newPgConnectionConfig = newPgConnectionConfig;
|
|
4
|
-
const pg_connection_string_1 = require("pg-connection-string");
|
|
1
|
+
import { parse } from "pg-connection-string";
|
|
2
|
+
//#region src/connection.ts
|
|
5
3
|
/**
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
4
|
+
* Returns the `ConnectionConfig` that joist will use to connect to pg.
|
|
5
|
+
*
|
|
6
|
+
* This reads environment variables, and can be either:
|
|
7
|
+
*
|
|
8
|
+
* - A single `DATABASE_URL` variable
|
|
9
|
+
* - Multiple `DB_USER`, `DB_PASSWORD`, `DB_DATABASE`, `DB_HOST`, `DB_PORT` variables
|
|
10
|
+
* The value can be either:
|
|
11
|
+
*
|
|
12
|
+
* Query pipelining is enabled by default. Set `pipeline: false` on the returned config to opt out.
|
|
13
|
+
*
|
|
14
|
+
* Note that users using a library for typed / validated environment variables, i.e.
|
|
15
|
+
* ts-app-env, you can pass in a specific `env` variable.
|
|
16
|
+
*/
|
|
17
17
|
function newPgConnectionConfig(env) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
else {
|
|
44
|
-
throw new Error("No DATABASE_URL or DB_DATABASE/etc. environment variable found");
|
|
45
|
-
}
|
|
18
|
+
if (process.env.DATABASE_URL || env && "DATABASE_URL" in env) {
|
|
19
|
+
const url = process.env.DATABASE_URL ?? env.DATABASE_URL;
|
|
20
|
+
const options = parse(url);
|
|
21
|
+
const { database, port, host, user, password } = options;
|
|
22
|
+
return {
|
|
23
|
+
user: user ?? void 0,
|
|
24
|
+
password: password ?? void 0,
|
|
25
|
+
database: database ?? void 0,
|
|
26
|
+
host: host ?? void 0,
|
|
27
|
+
port: port ? Number(port) : void 0,
|
|
28
|
+
ssl: options.ssl === true,
|
|
29
|
+
pipeline: true
|
|
30
|
+
};
|
|
31
|
+
} else if (process.env.DB_DATABASE || env && "DB_DATABASE" in env) {
|
|
32
|
+
const e = process.env.DB_DATABASE ? process.env : env;
|
|
33
|
+
return {
|
|
34
|
+
user: e.DB_USER,
|
|
35
|
+
password: e.DB_PASSWORD,
|
|
36
|
+
database: e.DB_DATABASE,
|
|
37
|
+
host: e.DB_HOST,
|
|
38
|
+
port: e.DB_PORT ? Number(e.DB_PORT) : void 0,
|
|
39
|
+
ssl: e.DB_SSL === "1" || e.DB_SSL === "true",
|
|
40
|
+
pipeline: true
|
|
41
|
+
};
|
|
42
|
+
} else throw new Error("No DATABASE_URL or DB_DATABASE/etc. environment variable found");
|
|
46
43
|
}
|
|
44
|
+
//#endregion
|
|
45
|
+
export { newPgConnectionConfig };
|
|
46
|
+
|
|
47
47
|
//# sourceMappingURL=connection.js.map
|
package/build/connection.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection.js","
|
|
1
|
+
{"version":3,"file":"connection.js","names":[],"sources":["../src/connection.ts"],"sourcesContent":["import { parse } from \"pg-connection-string\";\n\ntype DatabaseUrlEnv = { DATABASE_URL: string };\ntype DbSettingsEnv = {\n DB_USER: string;\n DB_PASSWORD: string;\n DB_HOST: string;\n DB_DATABASE: string;\n DB_PORT: string;\n DB_SSL?: string;\n};\n\nexport type ConnectionEnv = DatabaseUrlEnv | DbSettingsEnv;\n\n/**\n * A simple connection config compatible with both `pg.Pool` and knex.\n *\n * We use a plain object type instead of pg's `ConnectionConfig` to avoid\n * pulling in pg-specific fields (like `types`) that are incompatible with knex.\n */\nexport type ConnectionConfig = {\n user?: string;\n password?: string;\n database?: string;\n host?: string;\n port?: number;\n ssl?: boolean;\n pipeline?: boolean;\n};\n\n/**\n * Returns the `ConnectionConfig` that joist will use to connect to pg.\n *\n * This reads environment variables, and can be either:\n *\n * - A single `DATABASE_URL` variable\n * - Multiple `DB_USER`, `DB_PASSWORD`, `DB_DATABASE`, `DB_HOST`, `DB_PORT` variables\n * The value can be either:\n *\n * Query pipelining is enabled by default. Set `pipeline: false` on the returned config to opt out.\n *\n * Note that users using a library for typed / validated environment variables, i.e.\n * ts-app-env, you can pass in a specific `env` variable.\n */\nexport function newPgConnectionConfig(env?: ConnectionEnv): ConnectionConfig {\n if (process.env.DATABASE_URL || (env && \"DATABASE_URL\" in env)) {\n const url = process.env.DATABASE_URL ?? (env as DatabaseUrlEnv).DATABASE_URL;\n // It'd be great if `parse` returned ConnectionConfig directly\n const options = parse(url);\n const { database, port, host, user, password } = options;\n return {\n user: user ?? undefined,\n password: password ?? undefined,\n database: database ?? undefined,\n host: host ?? undefined,\n port: port ? Number(port) : undefined,\n ssl: options.ssl === true,\n pipeline: true,\n };\n } else if (process.env.DB_DATABASE || (env && \"DB_DATABASE\" in env)) {\n const e = process.env.DB_DATABASE ? process.env : (env as DbSettingsEnv);\n return {\n user: e.DB_USER,\n password: e.DB_PASSWORD,\n database: e.DB_DATABASE,\n host: e.DB_HOST,\n port: e.DB_PORT ? Number(e.DB_PORT) : undefined,\n ssl: e.DB_SSL === \"1\" || e.DB_SSL === \"true\",\n pipeline: true,\n };\n } else {\n throw new Error(\"No DATABASE_URL or DB_DATABASE/etc. environment variable found\");\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA4CA,SAAgB,sBAAsB,KAAuC;CAC3E,IAAI,QAAQ,IAAI,gBAAiB,OAAO,kBAAkB,KAAM;EAC9D,MAAM,MAAM,QAAQ,IAAI,gBAAiB,IAAuB;EAEhE,MAAM,UAAU,MAAM,GAAG;EACzB,MAAM,EAAE,UAAU,MAAM,MAAM,MAAM,aAAa;EACjD,OAAO;GACL,MAAM,QAAQ,KAAA;GACd,UAAU,YAAY,KAAA;GACtB,UAAU,YAAY,KAAA;GACtB,MAAM,QAAQ,KAAA;GACd,MAAM,OAAO,OAAO,IAAI,IAAI,KAAA;GAC5B,KAAK,QAAQ,QAAQ;GACrB,UAAU;EACZ;CACF,OAAO,IAAI,QAAQ,IAAI,eAAgB,OAAO,iBAAiB,KAAM;EACnE,MAAM,IAAI,QAAQ,IAAI,cAAc,QAAQ,MAAO;EACnD,OAAO;GACL,MAAM,EAAE;GACR,UAAU,EAAE;GACZ,UAAU,EAAE;GACZ,MAAM,EAAE;GACR,MAAM,EAAE,UAAU,OAAO,EAAE,OAAO,IAAI,KAAA;GACtC,KAAK,EAAE,WAAW,OAAO,EAAE,WAAW;GACtC,UAAU;EACZ;CACF,OACE,MAAM,IAAI,MAAM,gEAAgE;AAEpF"}
|
package/build/index.cjs
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_Deferred = require("./Deferred.cjs");
|
|
3
|
+
const require_connection = require("./connection.cjs");
|
|
4
|
+
const require_is_plain_object = require("./is-plain-object.cjs");
|
|
5
|
+
const require_stripAnsi = require("./stripAnsi.cjs");
|
|
6
|
+
//#region src/index.ts
|
|
7
|
+
function fail(message) {
|
|
8
|
+
throw new Error(message || "Failed");
|
|
9
|
+
}
|
|
10
|
+
function groupBy(list, fn, valueFn) {
|
|
11
|
+
const result = {};
|
|
12
|
+
list.forEach((o) => {
|
|
13
|
+
const group = fn(o);
|
|
14
|
+
if (result[group] === void 0) result[group] = [];
|
|
15
|
+
result[group].push(valueFn === void 0 ? o : valueFn(o));
|
|
16
|
+
});
|
|
17
|
+
return result;
|
|
18
|
+
}
|
|
19
|
+
function keyBy(list, fnOrKey, valueFn) {
|
|
20
|
+
const result = {};
|
|
21
|
+
const fn = typeof fnOrKey === "function" ? fnOrKey : (x) => x[fnOrKey];
|
|
22
|
+
list.forEach((e, i, a) => {
|
|
23
|
+
const group = fn(e, i, a);
|
|
24
|
+
if (result[group] !== void 0) throw new Error(`${String(group)} already had a value assigned`);
|
|
25
|
+
result[group] = valueFn ? valueFn(e, i, a) : e;
|
|
26
|
+
});
|
|
27
|
+
return result;
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
exports.Deferred = require_Deferred.Deferred;
|
|
31
|
+
exports.fail = fail;
|
|
32
|
+
exports.groupBy = groupBy;
|
|
33
|
+
exports.isPlainObject = require_is_plain_object.isPlainObject;
|
|
34
|
+
exports.keyBy = keyBy;
|
|
35
|
+
exports.newPgConnectionConfig = require_connection.newPgConnectionConfig;
|
|
36
|
+
exports.stripAnsi = require_stripAnsi.stripAnsi;
|
|
37
|
+
|
|
38
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["export { type ConnectionConfig, newPgConnectionConfig } from \"./connection.ts\";\nexport { Deferred } from \"./Deferred.ts\";\nexport { isPlainObject } from \"./is-plain-object.ts\";\nexport { stripAnsi } from \"./stripAnsi.ts\";\n\nexport function fail(message?: string): never {\n throw new Error(message || \"Failed\");\n}\n\nexport function groupBy<T, Y = T>(\n list: readonly T[],\n fn: (x: T) => string,\n valueFn?: (x: T) => Y,\n): Record<string, Y[]> {\n const result: Record<string, Y[]> = {};\n list.forEach((o) => {\n const group = fn(o);\n if (result[group] === undefined) {\n result[group] = [];\n }\n result[group].push(valueFn === undefined ? (o as any as Y) : valueFn(o));\n });\n return result;\n}\n\nexport function keyBy<T, K extends PropertyKey, Y = T>(\n list: readonly T[],\n fnOrKey: CallbackFn<T, K> | keyof T[][number],\n valueFn?: CallbackFn<T, Y>,\n) {\n const result = {} as Record<K, Y>;\n const fn = typeof fnOrKey === \"function\" ? fnOrKey : (x: T) => x[fnOrKey] as K;\n list.forEach((e, i, a) => {\n const group = fn(e, i, a);\n if (result[group] !== undefined) {\n throw new Error(`${String(group)} already had a value assigned`);\n }\n result[group] = valueFn ? valueFn(e, i, a) : (e as any as Y);\n });\n return result;\n}\n\nexport type CallbackFn<T, R = any> = (element: T, index: number, array: readonly T[]) => R;\n"],"mappings":";;;;;;AAKA,SAAgB,KAAK,SAAyB;CAC5C,MAAM,IAAI,MAAM,WAAW,QAAQ;AACrC;AAEA,SAAgB,QACd,MACA,IACA,SACqB;CACrB,MAAM,SAA8B,CAAC;CACrC,KAAK,SAAS,MAAM;EAClB,MAAM,QAAQ,GAAG,CAAC;EAClB,IAAI,OAAO,WAAW,KAAA,GACpB,OAAO,SAAS,CAAC;EAEnB,OAAO,MAAM,CAAC,KAAK,YAAY,KAAA,IAAa,IAAiB,QAAQ,CAAC,CAAC;CACzE,CAAC;CACD,OAAO;AACT;AAEA,SAAgB,MACd,MACA,SACA,SACA;CACA,MAAM,SAAS,CAAC;CAChB,MAAM,KAAK,OAAO,YAAY,aAAa,WAAW,MAAS,EAAE;CACjE,KAAK,SAAS,GAAG,GAAG,MAAM;EACxB,MAAM,QAAQ,GAAG,GAAG,GAAG,CAAC;EACxB,IAAI,OAAO,WAAW,KAAA,GACpB,MAAM,IAAI,MAAM,GAAG,OAAO,KAAK,EAAE,8BAA8B;EAEjE,OAAO,SAAS,UAAU,QAAQ,GAAG,GAAG,CAAC,IAAK;CAChD,CAAC;CACD,OAAO;AACT"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Deferred } from "./Deferred.cjs";
|
|
2
|
+
import { ConnectionConfig, newPgConnectionConfig } from "./connection.cjs";
|
|
3
|
+
import { isPlainObject } from "./is-plain-object.cjs";
|
|
4
|
+
import { stripAnsi } from "./stripAnsi.cjs";
|
|
5
|
+
//#region src/index.d.ts
|
|
6
|
+
declare function fail(message?: string): never;
|
|
7
|
+
declare function groupBy<T, Y = T>(list: readonly T[], fn: (x: T) => string, valueFn?: (x: T) => Y): Record<string, Y[]>;
|
|
8
|
+
declare function keyBy<T, K extends PropertyKey, Y = T>(list: readonly T[], fnOrKey: CallbackFn<T, K> | keyof T[][number], valueFn?: CallbackFn<T, Y>): Record<K, Y>;
|
|
9
|
+
type CallbackFn<T, R = any> = (element: T, index: number, array: readonly T[]) => R;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { CallbackFn, type ConnectionConfig, Deferred, fail, groupBy, isPlainObject, keyBy, newPgConnectionConfig, stripAnsi };
|
|
12
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;iBAKgB,KAAK;iBAIL,QAAQ,GAAG,IAAI,GAC7B,eAAe,KACf,KAAK,GAAG,cACR,WAAW,GAAG,MAAM,IACnB,eAAe;iBAYF,MAAM,GAAG,UAAU,aAAa,IAAI,GAClD,eAAe,KACf,SAAS,WAAW,GAAG,WAAW,aAClC,UAAU,WAAW,GAAG,KAAE,OAAA,GAAA;KAchB,WAAW,GAAG,YAAY,SAAS,GAAG,eAAe,gBAAgB,QAAQ"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Deferred } from "./Deferred.mjs";
|
|
2
|
+
import { ConnectionConfig, newPgConnectionConfig } from "./connection.mjs";
|
|
3
|
+
import { isPlainObject } from "./is-plain-object.mjs";
|
|
4
|
+
import { stripAnsi } from "./stripAnsi.mjs";
|
|
5
|
+
//#region src/index.d.ts
|
|
6
|
+
declare function fail(message?: string): never;
|
|
7
|
+
declare function groupBy<T, Y = T>(list: readonly T[], fn: (x: T) => string, valueFn?: (x: T) => Y): Record<string, Y[]>;
|
|
8
|
+
declare function keyBy<T, K extends PropertyKey, Y = T>(list: readonly T[], fnOrKey: CallbackFn<T, K> | keyof T[][number], valueFn?: CallbackFn<T, Y>): Record<K, Y>;
|
|
9
|
+
type CallbackFn<T, R = any> = (element: T, index: number, array: readonly T[]) => R;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { CallbackFn, type ConnectionConfig, Deferred, fail, groupBy, isPlainObject, keyBy, newPgConnectionConfig, stripAnsi };
|
|
12
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;iBAKgB,KAAK;iBAIL,QAAQ,GAAG,IAAI,GAC7B,eAAe,KACf,KAAK,GAAG,cACR,WAAW,GAAG,MAAM,IACnB,eAAe;iBAYF,MAAM,GAAG,UAAU,aAAa,IAAI,GAClD,eAAe,KACf,SAAS,WAAW,GAAG,WAAW,aAClC,UAAU,WAAW,GAAG,KAAE,OAAA,GAAA;KAchB,WAAW,GAAG,YAAY,SAAS,GAAG,eAAe,gBAAgB,QAAQ"}
|
package/build/index.js
CHANGED
|
@@ -1,41 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
exports.keyBy = keyBy;
|
|
7
|
-
var connection_1 = require("./connection");
|
|
8
|
-
Object.defineProperty(exports, "newPgConnectionConfig", { enumerable: true, get: function () { return connection_1.newPgConnectionConfig; } });
|
|
9
|
-
var Deferred_1 = require("./Deferred");
|
|
10
|
-
Object.defineProperty(exports, "Deferred", { enumerable: true, get: function () { return Deferred_1.Deferred; } });
|
|
11
|
-
var is_plain_object_1 = require("./is-plain-object");
|
|
12
|
-
Object.defineProperty(exports, "isPlainObject", { enumerable: true, get: function () { return is_plain_object_1.isPlainObject; } });
|
|
13
|
-
var stripAnsi_1 = require("./stripAnsi");
|
|
14
|
-
Object.defineProperty(exports, "stripAnsi", { enumerable: true, get: function () { return stripAnsi_1.stripAnsi; } });
|
|
1
|
+
import { Deferred } from "./Deferred.js";
|
|
2
|
+
import { newPgConnectionConfig } from "./connection.js";
|
|
3
|
+
import { isPlainObject } from "./is-plain-object.js";
|
|
4
|
+
import { stripAnsi } from "./stripAnsi.js";
|
|
5
|
+
//#region src/index.ts
|
|
15
6
|
function fail(message) {
|
|
16
|
-
|
|
7
|
+
throw new Error(message || "Failed");
|
|
17
8
|
}
|
|
18
9
|
function groupBy(list, fn, valueFn) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
});
|
|
27
|
-
return result;
|
|
10
|
+
const result = {};
|
|
11
|
+
list.forEach((o) => {
|
|
12
|
+
const group = fn(o);
|
|
13
|
+
if (result[group] === void 0) result[group] = [];
|
|
14
|
+
result[group].push(valueFn === void 0 ? o : valueFn(o));
|
|
15
|
+
});
|
|
16
|
+
return result;
|
|
28
17
|
}
|
|
29
18
|
function keyBy(list, fnOrKey, valueFn) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
});
|
|
39
|
-
return result;
|
|
19
|
+
const result = {};
|
|
20
|
+
const fn = typeof fnOrKey === "function" ? fnOrKey : (x) => x[fnOrKey];
|
|
21
|
+
list.forEach((e, i, a) => {
|
|
22
|
+
const group = fn(e, i, a);
|
|
23
|
+
if (result[group] !== void 0) throw new Error(`${String(group)} already had a value assigned`);
|
|
24
|
+
result[group] = valueFn ? valueFn(e, i, a) : e;
|
|
25
|
+
});
|
|
26
|
+
return result;
|
|
40
27
|
}
|
|
28
|
+
//#endregion
|
|
29
|
+
export { Deferred, fail, groupBy, isPlainObject, keyBy, newPgConnectionConfig, stripAnsi };
|
|
30
|
+
|
|
41
31
|
//# sourceMappingURL=index.js.map
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["export { type ConnectionConfig, newPgConnectionConfig } from \"./connection.ts\";\nexport { Deferred } from \"./Deferred.ts\";\nexport { isPlainObject } from \"./is-plain-object.ts\";\nexport { stripAnsi } from \"./stripAnsi.ts\";\n\nexport function fail(message?: string): never {\n throw new Error(message || \"Failed\");\n}\n\nexport function groupBy<T, Y = T>(\n list: readonly T[],\n fn: (x: T) => string,\n valueFn?: (x: T) => Y,\n): Record<string, Y[]> {\n const result: Record<string, Y[]> = {};\n list.forEach((o) => {\n const group = fn(o);\n if (result[group] === undefined) {\n result[group] = [];\n }\n result[group].push(valueFn === undefined ? (o as any as Y) : valueFn(o));\n });\n return result;\n}\n\nexport function keyBy<T, K extends PropertyKey, Y = T>(\n list: readonly T[],\n fnOrKey: CallbackFn<T, K> | keyof T[][number],\n valueFn?: CallbackFn<T, Y>,\n) {\n const result = {} as Record<K, Y>;\n const fn = typeof fnOrKey === \"function\" ? fnOrKey : (x: T) => x[fnOrKey] as K;\n list.forEach((e, i, a) => {\n const group = fn(e, i, a);\n if (result[group] !== undefined) {\n throw new Error(`${String(group)} already had a value assigned`);\n }\n result[group] = valueFn ? valueFn(e, i, a) : (e as any as Y);\n });\n return result;\n}\n\nexport type CallbackFn<T, R = any> = (element: T, index: number, array: readonly T[]) => R;\n"],"mappings":";;;;;AAKA,SAAgB,KAAK,SAAyB;CAC5C,MAAM,IAAI,MAAM,WAAW,QAAQ;AACrC;AAEA,SAAgB,QACd,MACA,IACA,SACqB;CACrB,MAAM,SAA8B,CAAC;CACrC,KAAK,SAAS,MAAM;EAClB,MAAM,QAAQ,GAAG,CAAC;EAClB,IAAI,OAAO,WAAW,KAAA,GACpB,OAAO,SAAS,CAAC;EAEnB,OAAO,MAAM,CAAC,KAAK,YAAY,KAAA,IAAa,IAAiB,QAAQ,CAAC,CAAC;CACzE,CAAC;CACD,OAAO;AACT;AAEA,SAAgB,MACd,MACA,SACA,SACA;CACA,MAAM,SAAS,CAAC;CAChB,MAAM,KAAK,OAAO,YAAY,aAAa,WAAW,MAAS,EAAE;CACjE,KAAK,SAAS,GAAG,GAAG,MAAM;EACxB,MAAM,QAAQ,GAAG,GAAG,GAAG,CAAC;EACxB,IAAI,OAAO,WAAW,KAAA,GACpB,MAAM,IAAI,MAAM,GAAG,OAAO,KAAK,EAAE,8BAA8B;EAEjE,OAAO,SAAS,UAAU,QAAQ,GAAG,GAAG,CAAC,IAAK;CAChD,CAAC;CACD,OAAO;AACT"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region src/is-plain-object.ts
|
|
3
|
+
/*!
|
|
4
|
+
* is-plain-object <https://github.com/jonschlinkert/is-plain-object>
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) 2014-2017, Jon Schlinkert.
|
|
7
|
+
* Released under the MIT License.
|
|
8
|
+
*/
|
|
9
|
+
function isObject(o) {
|
|
10
|
+
return Object.prototype.toString.call(o) === "[object Object]";
|
|
11
|
+
}
|
|
12
|
+
function isPlainObject(o) {
|
|
13
|
+
if (isObject(o) === false) return false;
|
|
14
|
+
const ctor = o.constructor;
|
|
15
|
+
if (ctor === void 0) return true;
|
|
16
|
+
const prot = ctor.prototype;
|
|
17
|
+
if (isObject(prot) === false) return false;
|
|
18
|
+
if (prot.hasOwnProperty("isPrototypeOf") === false) return false;
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
exports.isPlainObject = isPlainObject;
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=is-plain-object.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-plain-object.cjs","names":[],"sources":["../src/is-plain-object.ts"],"sourcesContent":["/*!\n * is-plain-object <https://github.com/jonschlinkert/is-plain-object>\n *\n * Copyright (c) 2014-2017, Jon Schlinkert.\n * Released under the MIT License.\n */\n\n// See https://github.com/jonschlinkert/is-plain-object/issues/37\n\nfunction isObject(o: any): o is object {\n return Object.prototype.toString.call(o) === \"[object Object]\";\n}\n\nexport function isPlainObject(o: any): boolean {\n if (isObject(o) === false) return false;\n\n // If has modified constructor\n const ctor = o.constructor;\n if (ctor === undefined) return true;\n\n // If has modified prototype\n const prot = ctor.prototype;\n if (isObject(prot) === false) return false;\n\n // If constructor does not have an Object-specific method\n if (prot.hasOwnProperty(\"isPrototypeOf\") === false) {\n return false;\n }\n\n // Most likely a plain Object\n return true;\n}\n"],"mappings":";;;;;;;;AASA,SAAS,SAAS,GAAqB;CACrC,OAAO,OAAO,UAAU,SAAS,KAAK,CAAC,MAAM;AAC/C;AAEA,SAAgB,cAAc,GAAiB;CAC7C,IAAI,SAAS,CAAC,MAAM,OAAO,OAAO;CAGlC,MAAM,OAAO,EAAE;CACf,IAAI,SAAS,KAAA,GAAW,OAAO;CAG/B,MAAM,OAAO,KAAK;CAClB,IAAI,SAAS,IAAI,MAAM,OAAO,OAAO;CAGrC,IAAI,KAAK,eAAe,eAAe,MAAM,OAC3C,OAAO;CAIT,OAAO;AACT"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/is-plain-object.d.ts
|
|
2
|
+
/*!
|
|
3
|
+
* is-plain-object <https://github.com/jonschlinkert/is-plain-object>
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) 2014-2017, Jon Schlinkert.
|
|
6
|
+
* Released under the MIT License.
|
|
7
|
+
*/
|
|
8
|
+
declare function isPlainObject(o: any): boolean;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { isPlainObject };
|
|
11
|
+
//# sourceMappingURL=is-plain-object.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-plain-object.d.cts","names":[],"sources":["../src/is-plain-object.ts"],"mappings":";;;;;;;iBAagB,cAAc"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/is-plain-object.d.ts
|
|
2
|
+
/*!
|
|
3
|
+
* is-plain-object <https://github.com/jonschlinkert/is-plain-object>
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) 2014-2017, Jon Schlinkert.
|
|
6
|
+
* Released under the MIT License.
|
|
7
|
+
*/
|
|
8
|
+
declare function isPlainObject(o: any): boolean;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { isPlainObject };
|
|
11
|
+
//# sourceMappingURL=is-plain-object.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-plain-object.d.mts","names":[],"sources":["../src/is-plain-object.ts"],"mappings":";;;;;;;iBAagB,cAAc"}
|
package/build/is-plain-object.js
CHANGED
|
@@ -1,32 +1,23 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/is-plain-object.ts
|
|
2
2
|
/*!
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.isPlainObject = isPlainObject;
|
|
10
|
-
// See https://github.com/jonschlinkert/is-plain-object/issues/37
|
|
3
|
+
* is-plain-object <https://github.com/jonschlinkert/is-plain-object>
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) 2014-2017, Jon Schlinkert.
|
|
6
|
+
* Released under the MIT License.
|
|
7
|
+
*/
|
|
11
8
|
function isObject(o) {
|
|
12
|
-
|
|
9
|
+
return Object.prototype.toString.call(o) === "[object Object]";
|
|
13
10
|
}
|
|
14
11
|
function isPlainObject(o) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const prot = ctor.prototype;
|
|
23
|
-
if (isObject(prot) === false)
|
|
24
|
-
return false;
|
|
25
|
-
// If constructor does not have an Object-specific method
|
|
26
|
-
if (prot.hasOwnProperty("isPrototypeOf") === false) {
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
29
|
-
// Most likely a plain Object
|
|
30
|
-
return true;
|
|
12
|
+
if (isObject(o) === false) return false;
|
|
13
|
+
const ctor = o.constructor;
|
|
14
|
+
if (ctor === void 0) return true;
|
|
15
|
+
const prot = ctor.prototype;
|
|
16
|
+
if (isObject(prot) === false) return false;
|
|
17
|
+
if (prot.hasOwnProperty("isPrototypeOf") === false) return false;
|
|
18
|
+
return true;
|
|
31
19
|
}
|
|
20
|
+
//#endregion
|
|
21
|
+
export { isPlainObject };
|
|
22
|
+
|
|
32
23
|
//# sourceMappingURL=is-plain-object.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-plain-object.js","
|
|
1
|
+
{"version":3,"file":"is-plain-object.js","names":[],"sources":["../src/is-plain-object.ts"],"sourcesContent":["/*!\n * is-plain-object <https://github.com/jonschlinkert/is-plain-object>\n *\n * Copyright (c) 2014-2017, Jon Schlinkert.\n * Released under the MIT License.\n */\n\n// See https://github.com/jonschlinkert/is-plain-object/issues/37\n\nfunction isObject(o: any): o is object {\n return Object.prototype.toString.call(o) === \"[object Object]\";\n}\n\nexport function isPlainObject(o: any): boolean {\n if (isObject(o) === false) return false;\n\n // If has modified constructor\n const ctor = o.constructor;\n if (ctor === undefined) return true;\n\n // If has modified prototype\n const prot = ctor.prototype;\n if (isObject(prot) === false) return false;\n\n // If constructor does not have an Object-specific method\n if (prot.hasOwnProperty(\"isPrototypeOf\") === false) {\n return false;\n }\n\n // Most likely a plain Object\n return true;\n}\n"],"mappings":";;;;;;;AASA,SAAS,SAAS,GAAqB;CACrC,OAAO,OAAO,UAAU,SAAS,KAAK,CAAC,MAAM;AAC/C;AAEA,SAAgB,cAAc,GAAiB;CAC7C,IAAI,SAAS,CAAC,MAAM,OAAO,OAAO;CAGlC,MAAM,OAAO,EAAE;CACf,IAAI,SAAS,KAAA,GAAW,OAAO;CAG/B,MAAM,OAAO,KAAK;CAClB,IAAI,SAAS,IAAI,MAAM,OAAO,OAAO;CAGrC,IAAI,KAAK,eAAe,eAAe,MAAM,OAC3C,OAAO;CAIT,OAAO;AACT"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region src/stripAnsi.ts
|
|
3
|
+
/** Removes ANSI color codes from a string. */
|
|
4
|
+
function stripAnsi(value) {
|
|
5
|
+
return value.replace(/\u001B\[[0-?]*[ -/]*[@-~]/g, "");
|
|
6
|
+
}
|
|
7
|
+
//#endregion
|
|
8
|
+
exports.stripAnsi = stripAnsi;
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=stripAnsi.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stripAnsi.cjs","names":[],"sources":["../src/stripAnsi.ts"],"sourcesContent":["/** Removes ANSI color codes from a string. */\nexport function stripAnsi(value: string): string {\n return value.replace(/\\u001B\\[[0-?]*[ -/]*[@-~]/g, \"\");\n}\n"],"mappings":";;;AACA,SAAgB,UAAU,OAAuB;CAC/C,OAAO,MAAM,QAAQ,8BAA8B,EAAE;AACvD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stripAnsi.d.cts","names":[],"sources":["../src/stripAnsi.ts"],"mappings":";;iBACgB,UAAU"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stripAnsi.d.mts","names":[],"sources":["../src/stripAnsi.ts"],"mappings":";;iBACgB,UAAU"}
|
package/build/stripAnsi.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.stripAnsi = stripAnsi;
|
|
1
|
+
//#region src/stripAnsi.ts
|
|
4
2
|
/** Removes ANSI color codes from a string. */
|
|
5
3
|
function stripAnsi(value) {
|
|
6
|
-
|
|
4
|
+
return value.replace(/\u001B\[[0-?]*[ -/]*[@-~]/g, "");
|
|
7
5
|
}
|
|
6
|
+
//#endregion
|
|
7
|
+
export { stripAnsi };
|
|
8
|
+
|
|
8
9
|
//# sourceMappingURL=stripAnsi.js.map
|
package/build/stripAnsi.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stripAnsi.js","
|
|
1
|
+
{"version":3,"file":"stripAnsi.js","names":[],"sources":["../src/stripAnsi.ts"],"sourcesContent":["/** Removes ANSI color codes from a string. */\nexport function stripAnsi(value: string): string {\n return value.replace(/\\u001B\\[[0-?]*[ -/]*[@-~]/g, \"\");\n}\n"],"mappings":";;AACA,SAAgB,UAAU,OAAuB;CAC/C,OAAO,MAAM,QAAQ,8BAA8B,EAAE;AACvD"}
|
package/package.json
CHANGED
|
@@ -1,35 +1,54 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "joist-utils",
|
|
3
|
-
"version": "2.3.0-next.
|
|
3
|
+
"version": "2.3.0-next.70",
|
|
4
4
|
"license": "MIT",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"repository": {
|
|
6
7
|
"type": "git",
|
|
7
8
|
"url": "https://github.com/joist-orm/joist-orm.git",
|
|
8
9
|
"directory": "packages/utils"
|
|
9
10
|
},
|
|
10
|
-
"main": "build/index.
|
|
11
|
-
"
|
|
11
|
+
"main": "build/index.cjs",
|
|
12
|
+
"module": "build/index.js",
|
|
13
|
+
"types": "build/index.d.mts",
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"bun": {
|
|
17
|
+
"types": "./build/index.d.mts",
|
|
18
|
+
"default": "./build/index.js"
|
|
19
|
+
},
|
|
20
|
+
"module-sync": {
|
|
21
|
+
"types": "./build/index.d.mts",
|
|
22
|
+
"default": "./build/index.js"
|
|
23
|
+
},
|
|
24
|
+
"import": {
|
|
25
|
+
"types": "./build/index.d.mts",
|
|
26
|
+
"default": "./build/index.js"
|
|
27
|
+
},
|
|
28
|
+
"require": {
|
|
29
|
+
"types": "./build/index.d.cts",
|
|
30
|
+
"default": "./build/index.cjs"
|
|
31
|
+
},
|
|
32
|
+
"default": "./build/index.js"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
12
35
|
"files": [
|
|
13
36
|
"build"
|
|
14
37
|
],
|
|
15
38
|
"peerDependencies": {
|
|
16
|
-
"pg": "^8.
|
|
39
|
+
"pg": "^8.23.0",
|
|
17
40
|
"pg-connection-string": "^2.14.0"
|
|
18
41
|
},
|
|
19
42
|
"scripts": {
|
|
20
|
-
"format": "prettier --ignore-path ../../.prettierignore --write '{schema,migrations,src}/**/*.{ts,js,tsx,jsx,graphql}'",
|
|
21
43
|
"test": "jest"
|
|
22
44
|
},
|
|
23
45
|
"devDependencies": {
|
|
24
|
-
"@swc/core": "^1.
|
|
46
|
+
"@swc/core": "^1.16.1",
|
|
25
47
|
"@swc/jest": "^0.2.39",
|
|
26
48
|
"@types/jest": "^30.0.0",
|
|
27
|
-
"@types/node": "^26.0
|
|
49
|
+
"@types/node": "^26.2.0",
|
|
28
50
|
"jest": "30.4.2",
|
|
29
|
-
"prettier": "^3.8.4",
|
|
30
|
-
"prettier-plugin-organize-imports": "^4.3.0",
|
|
31
|
-
"ts-node-dev": "^2.0.0",
|
|
32
51
|
"tsconfig-paths": "^4.2.0",
|
|
33
|
-
"typescript": "
|
|
52
|
+
"typescript": "7.0.2"
|
|
34
53
|
}
|
|
35
54
|
}
|
package/build/Deferred.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export declare class Deferred<T> {
|
|
2
|
-
promise: Promise<T>;
|
|
3
|
-
private fate;
|
|
4
|
-
private state;
|
|
5
|
-
private _resolve;
|
|
6
|
-
private _reject;
|
|
7
|
-
constructor();
|
|
8
|
-
resolve(value?: any): void;
|
|
9
|
-
reject(reason?: any): void;
|
|
10
|
-
isResolved(): boolean;
|
|
11
|
-
isPending(): boolean;
|
|
12
|
-
isFulfilled(): boolean;
|
|
13
|
-
isRejected(): boolean;
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=Deferred.d.ts.map
|
package/build/Deferred.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Deferred.d.ts","sourceRoot":"","sources":["../src/Deferred.ts"],"names":[],"mappings":"AAAA,qBAAa,QAAQ,CAAC,CAAC;IACd,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IAC3B,OAAO,CAAC,IAAI,CAA4B;IACxC,OAAO,CAAC,KAAK,CAAuC;IACpD,OAAO,CAAC,QAAQ,CAAY;IAC5B,OAAO,CAAC,OAAO,CAAY;;IAe3B,OAAO,CAAC,KAAK,CAAC,EAAE,GAAG;IAQnB,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG;IAQnB,UAAU;IAIV,SAAS;IAIT,WAAW;IAIX,UAAU;CAGX"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../src/connection.ts"],"names":[],"mappings":"AAEA,KAAK,cAAc,GAAG;IAAE,YAAY,EAAE,MAAM,CAAA;CAAE,CAAC;AAC/C,KAAK,aAAa,GAAG;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,cAAc,GAAG,aAAa,CAAC;AAE3D;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,OAAO,CAAC;CACf,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,CAAC,EAAE,aAAa,GAAG,gBAAgB,CA2B3E"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"connection.test.d.ts","sourceRoot":"","sources":["../src/connection.test.ts"],"names":[],"mappings":""}
|
package/build/connection.test.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const connection_1 = require("./connection");
|
|
4
|
-
describe("connection", () => {
|
|
5
|
-
it("should parse single DATABASE_URL", () => {
|
|
6
|
-
const info = (0, connection_1.newPgConnectionConfig)({ DATABASE_URL: "postgres://joist:local@db:5432/joist" });
|
|
7
|
-
expect(info).toEqual({
|
|
8
|
-
database: "joist",
|
|
9
|
-
host: "db",
|
|
10
|
-
password: "local",
|
|
11
|
-
port: 5432,
|
|
12
|
-
user: "joist",
|
|
13
|
-
ssl: false,
|
|
14
|
-
});
|
|
15
|
-
});
|
|
16
|
-
it("should parse multiple DB variables", () => {
|
|
17
|
-
const info = (0, connection_1.newPgConnectionConfig)({
|
|
18
|
-
DB_USER: "joist",
|
|
19
|
-
DB_PASSWORD: "local",
|
|
20
|
-
DB_DATABASE: "joist",
|
|
21
|
-
DB_HOST: "db",
|
|
22
|
-
DB_PORT: "5432",
|
|
23
|
-
DB_SSL: "true",
|
|
24
|
-
});
|
|
25
|
-
expect(info).toEqual({
|
|
26
|
-
database: "joist",
|
|
27
|
-
host: "db",
|
|
28
|
-
password: "local",
|
|
29
|
-
port: 5432,
|
|
30
|
-
ssl: true,
|
|
31
|
-
user: "joist",
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
it("should parse a DATABASE_URL with ssl=true", () => {
|
|
35
|
-
const info = (0, connection_1.newPgConnectionConfig)({ DATABASE_URL: "postgres://joist:local@db:5432/joist?ssl=true" });
|
|
36
|
-
expect(info).toEqual({
|
|
37
|
-
database: "joist",
|
|
38
|
-
host: "db",
|
|
39
|
-
password: "local",
|
|
40
|
-
port: 5432,
|
|
41
|
-
user: "joist",
|
|
42
|
-
ssl: true,
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
//# sourceMappingURL=connection.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"connection.test.js","sourceRoot":"","sources":["../src/connection.test.ts"],"names":[],"mappings":";;AAAA,6CAAqD;AAErD,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;IAC1B,EAAE,CAAC,kCAAkC,EAAE,GAAG,EAAE;QAC1C,MAAM,IAAI,GAAG,IAAA,kCAAqB,EAAC,EAAE,YAAY,EAAE,sCAAsC,EAAE,CAAC,CAAC;QAC7F,MAAM,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC;YACnB,QAAQ,EAAE,OAAO;YACjB,IAAI,EAAE,IAAI;YACV,QAAQ,EAAE,OAAO;YACjB,IAAI,EAAE,IAAI;YACV,IAAI,EAAE,OAAO;YACb,GAAG,EAAE,KAAK;SACX,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,oCAAoC,EAAE,GAAG,EAAE;QAC5C,MAAM,IAAI,GAAG,IAAA,kCAAqB,EAAC;YACjC,OAAO,EAAE,OAAO;YAChB,WAAW,EAAE,OAAO;YACpB,WAAW,EAAE,OAAO;YACpB,OAAO,EAAE,IAAI;YACb,OAAO,EAAE,MAAM;YACf,MAAM,EAAE,MAAM;SACf,CAAC,CAAC;QACH,MAAM,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC;YACnB,QAAQ,EAAE,OAAO;YACjB,IAAI,EAAE,IAAI;YACV,QAAQ,EAAE,OAAO;YACjB,IAAI,EAAE,IAAI;YACV,GAAG,EAAE,IAAI;YACT,IAAI,EAAE,OAAO;SACd,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,2CAA2C,EAAE,GAAG,EAAE;QACnD,MAAM,IAAI,GAAG,IAAA,kCAAqB,EAAC,EAAE,YAAY,EAAE,+CAA+C,EAAE,CAAC,CAAC;QACtG,MAAM,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC;YACnB,QAAQ,EAAE,OAAO;YACjB,IAAI,EAAE,IAAI;YACV,QAAQ,EAAE,OAAO;YACjB,IAAI,EAAE,IAAI;YACV,IAAI,EAAE,OAAO;YACb,GAAG,EAAE,IAAI;SACV,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/build/index.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export { ConnectionConfig, newPgConnectionConfig } from "./connection";
|
|
2
|
-
export { Deferred } from "./Deferred";
|
|
3
|
-
export { isPlainObject } from "./is-plain-object";
|
|
4
|
-
export { stripAnsi } from "./stripAnsi";
|
|
5
|
-
export declare function fail(message?: string): never;
|
|
6
|
-
export declare function groupBy<T, Y = T>(list: readonly T[], fn: (x: T) => string, valueFn?: (x: T) => Y): Record<string, Y[]>;
|
|
7
|
-
export declare function keyBy<T, K extends PropertyKey, Y = T>(list: readonly T[], fnOrKey: CallbackFn<T, K> | keyof T[][number], valueFn?: CallbackFn<T, Y>): Record<K, Y>;
|
|
8
|
-
export type CallbackFn<T, R = any> = (element: T, index: number, array: readonly T[]) => R;
|
|
9
|
-
//# sourceMappingURL=index.d.ts.map
|
package/build/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACvE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,wBAAgB,IAAI,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,KAAK,CAE5C;AAED,wBAAgB,OAAO,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,EAC9B,IAAI,EAAE,SAAS,CAAC,EAAE,EAClB,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,MAAM,EACpB,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,GACpB,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,CAUrB;AAED,wBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC,SAAS,WAAW,EAAE,CAAC,GAAG,CAAC,EACnD,IAAI,EAAE,SAAS,CAAC,EAAE,EAClB,OAAO,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,EAC7C,OAAO,CAAC,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,gBAY3B;AAED,MAAM,MAAM,UAAU,CAAC,CAAC,EAAE,CAAC,GAAG,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,KAAK,CAAC,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* is-plain-object <https://github.com/jonschlinkert/is-plain-object>
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2014-2017, Jon Schlinkert.
|
|
5
|
-
* Released under the MIT License.
|
|
6
|
-
*/
|
|
7
|
-
export declare function isPlainObject(o: any): boolean;
|
|
8
|
-
//# sourceMappingURL=is-plain-object.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is-plain-object.d.ts","sourceRoot":"","sources":["../src/is-plain-object.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,wBAAgB,aAAa,CAAC,CAAC,EAAE,GAAG,GAAG,OAAO,CAkB7C"}
|
package/build/stripAnsi.d.ts
DELETED
package/build/stripAnsi.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stripAnsi.d.ts","sourceRoot":"","sources":["../src/stripAnsi.ts"],"names":[],"mappings":"AAAA,8CAA8C;AAC9C,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE/C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stripAnsi.test.d.ts","sourceRoot":"","sources":["../src/stripAnsi.test.ts"],"names":[],"mappings":""}
|
package/build/stripAnsi.test.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const stripAnsi_1 = require("./stripAnsi");
|
|
4
|
-
describe("stripAnsi", () => {
|
|
5
|
-
it("removes ANSI color codes", () => {
|
|
6
|
-
expect((0, stripAnsi_1.stripAnsi)("\u001B[31mred\u001B[0m")).toEqual("red");
|
|
7
|
-
});
|
|
8
|
-
});
|
|
9
|
-
//# sourceMappingURL=stripAnsi.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stripAnsi.test.js","sourceRoot":"","sources":["../src/stripAnsi.test.ts"],"names":[],"mappings":";;AAAA,2CAAwC;AAExC,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;IACzB,EAAE,CAAC,0BAA0B,EAAE,GAAG,EAAE;QAClC,MAAM,CAAC,IAAA,qBAAS,EAAC,wBAAwB,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC7D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|