@thisisagile/easy 12.22.11 → 12.22.14
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/dist/sql/Clause.d.ts +3 -0
- package/dist/sql/Clause.js +9 -3
- package/dist/sql/Clause.js.map +1 -1
- package/dist/sql/Column.js +7 -2
- package/dist/sql/Column.js.map +1 -1
- package/package.json +3 -3
- package/src/sql/Clause.ts +8 -2
- package/src/sql/Column.ts +10 -3
package/dist/sql/Clause.d.ts
CHANGED
|
@@ -10,5 +10,8 @@ export declare class Clause implements Text {
|
|
|
10
10
|
or: (other: Clause) => Clause;
|
|
11
11
|
toString(): string;
|
|
12
12
|
}
|
|
13
|
+
export declare class ParathesizedClause extends Clause {
|
|
14
|
+
toString(): string;
|
|
15
|
+
}
|
|
13
16
|
export declare const toClause: (first: unknown, operator: string, second: unknown, conv?: Convert) => Clause;
|
|
14
17
|
export declare const isClause: TypeGuard<Clause>;
|
package/dist/sql/Clause.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isClause = exports.toClause = exports.Clause = exports.quote = void 0;
|
|
3
|
+
exports.isClause = exports.toClause = exports.ParathesizedClause = exports.Clause = exports.quote = void 0;
|
|
4
4
|
const types_1 = require("../types");
|
|
5
5
|
const utils_1 = require("../utils");
|
|
6
6
|
const quote = (a) => ((0, types_1.isNumber)(a) || (0, types_1.isBoolean)(a) || (0, exports.isClause)(a) ? a.toString() : `'${a}'`);
|
|
@@ -10,14 +10,20 @@ class Clause {
|
|
|
10
10
|
this.first = first;
|
|
11
11
|
this.operator = operator;
|
|
12
12
|
this.second = second;
|
|
13
|
-
this.and = (other) =>
|
|
14
|
-
this.or = (other) =>
|
|
13
|
+
this.and = (other) => new ParathesizedClause(this, 'AND', other);
|
|
14
|
+
this.or = (other) => new ParathesizedClause(this, 'OR', other);
|
|
15
15
|
}
|
|
16
16
|
toString() {
|
|
17
17
|
return `${this.first} ${this.operator} ${(0, exports.quote)(this.second)}`;
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
exports.Clause = Clause;
|
|
21
|
+
class ParathesizedClause extends Clause {
|
|
22
|
+
toString() {
|
|
23
|
+
return `(${this.first} ${this.operator} ${(0, exports.quote)(this.second)})`;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.ParathesizedClause = ParathesizedClause;
|
|
21
27
|
const toClause = (first, operator, second, conv = utils_1.convert.default) => new Clause(first, operator, conv.from(second));
|
|
22
28
|
exports.toClause = toClause;
|
|
23
29
|
const isClause = (c) => (0, types_1.isA)(c, 'and', 'or');
|
package/dist/sql/Clause.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Clause.js","sourceRoot":"","sources":["../../src/sql/Clause.ts"],"names":[],"mappings":";;;AAAA,oCAAqE;AACrE,oCAA4C;AAErC,MAAM,KAAK,GAAG,CAAC,CAAU,EAAU,EAAE,CAAC,CAAC,IAAA,gBAAQ,EAAC,CAAC,CAAC,IAAI,IAAA,iBAAS,EAAC,CAAC,CAAC,IAAI,IAAA,gBAAQ,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,IAAI,CAAW,GAAG,CAAC,CAAC;AAAjH,QAAA,KAAK,SAA4G;AAE9H,MAAa,MAAM;IACjB,YAAqB,KAAc,EAAW,QAAgB,EAAW,MAAe;QAAnE,UAAK,GAAL,KAAK,CAAS;QAAW,aAAQ,GAAR,QAAQ,CAAQ;QAAW,WAAM,GAAN,MAAM,CAAS;QAExF,QAAG,GAAG,CAAC,KAAa,EAAU,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"Clause.js","sourceRoot":"","sources":["../../src/sql/Clause.ts"],"names":[],"mappings":";;;AAAA,oCAAqE;AACrE,oCAA4C;AAErC,MAAM,KAAK,GAAG,CAAC,CA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AC4B;AAE1C,MAAM,QAAQ,GAAsB,CAAC,CAAW,EAAe,EAAE,CAAC,IAAA,WAAG,EAAS,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;AAAxF,QAAA,QAAQ,YAAgF"}
|
package/dist/sql/Column.js
CHANGED
|
@@ -8,8 +8,13 @@ class Column extends utils_1.Property {
|
|
|
8
8
|
constructor(owner, property, options) {
|
|
9
9
|
super(property, options);
|
|
10
10
|
this.owner = owner;
|
|
11
|
-
this.in = (source = {}) =>
|
|
12
|
-
|
|
11
|
+
this.in = (source = {}) => (0, types_1.tryTo)(source)
|
|
12
|
+
.map(s => s[this.property] ?? (0, types_1.ofGet)(this.options?.dflt))
|
|
13
|
+
.map(v => this.options?.convert?.to(v))
|
|
14
|
+
.orElse();
|
|
15
|
+
this.out = (source = {}, key = '') => (0, types_1.tryTo)(source)
|
|
16
|
+
.map(s => this.options?.convert?.from(s[key]))
|
|
17
|
+
.orElse();
|
|
13
18
|
this.function = (func) => this.format(`${func}($name)`);
|
|
14
19
|
this.format = (pattern) => new PatternColumn(this, pattern);
|
|
15
20
|
this.is = (value) => this.clause('=', value);
|
package/dist/sql/Column.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Column.js","sourceRoot":"","sources":["../../src/sql/Column.ts"],"names":[],"mappings":";;;AAAA,oCAAqD;AACrD,qCAA4C;AAC5C,
|
|
1
|
+
{"version":3,"file":"Column.js","sourceRoot":"","sources":["../../src/sql/Column.ts"],"names":[],"mappings":";;;AAAA,oCAAqD;AACrD,qCAA4C;AAC5C,oCAA+D;AAG/D,MAAa,MAAO,SAAQ,gBAAQ;IAClC,YAAqB,KAAY,EAAE,QAAgB,EAAE,OAAyB;QAC5E,KAAK,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QADN,UAAK,GAAL,KAAK,CAAO;QAoCjC,OAAE,GAAG,CAAC,SAAe,EAAE,EAAa,EAAE,CACpC,IAAA,aAAK,EAAC,MAAM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,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC;IAED,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU,CAAgB,CAAC;IAChD,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,MAAM,CAAC,WAAW,CAAgB,CAAC;IACjD,CAAC;IAuCD,QAAQ;QACN,OAAO,GAAG,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;IAC1C,CAAC;CAGF;AA/ED,wBA+EC;AAED,MAAa,aAAc,SAAQ,MAAM;IACvC,YAAsB,GAAW,EAAY,OAAe;QAC1D,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAC;QADX,QAAG,GAAH,GAAG,CAAQ;QAAY,YAAO,GAAP,OAAO,CAAQ;IAE5D,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC1I,CAAC;CACF;AARD,sCAQC;AAED,MAAa,WAAY,SAAQ,aAAa;CAAG;AAAjD,kCAAiD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thisisagile/easy",
|
|
3
|
-
"version": "12.22.
|
|
3
|
+
"version": "12.22.14",
|
|
4
4
|
"description": "Straightforward library for building domain-driven microservice architectures",
|
|
5
5
|
"author": "Sander Hoogendoorn",
|
|
6
6
|
"license": "MIT",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"access": "public"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@thisisagile/easy-test": "12.22.
|
|
34
|
+
"@thisisagile/easy-test": "12.22.14",
|
|
35
35
|
"@types/form-urlencoded": "^4.4.0",
|
|
36
36
|
"@types/jsonwebtoken": "^8.5.9",
|
|
37
37
|
"@types/luxon": "3.1.0",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"@types/uuid": "^8.3.4",
|
|
42
42
|
"axios": "^0.27.2",
|
|
43
43
|
"form-urlencoded": "^6.1.0",
|
|
44
|
-
"jsonwebtoken": "^
|
|
44
|
+
"jsonwebtoken": "^9.0.0",
|
|
45
45
|
"luxon": "^3.2.1",
|
|
46
46
|
"reflect-metadata": "^0.1.13",
|
|
47
47
|
"uuid": "^8.3.2",
|
package/src/sql/Clause.ts
CHANGED
|
@@ -6,14 +6,20 @@ export const quote = (a: unknown): string => (isNumber(a) || isBoolean(a) || isC
|
|
|
6
6
|
export class Clause implements Text {
|
|
7
7
|
constructor(readonly first: unknown, readonly operator: string, readonly second: unknown) {}
|
|
8
8
|
|
|
9
|
-
and = (other: Clause): Clause =>
|
|
10
|
-
or = (other: Clause): Clause =>
|
|
9
|
+
and = (other: Clause): Clause => new ParathesizedClause(this, 'AND', other);
|
|
10
|
+
or = (other: Clause): Clause => new ParathesizedClause(this, 'OR', other);
|
|
11
11
|
|
|
12
12
|
toString(): string {
|
|
13
13
|
return `${this.first} ${this.operator} ${quote(this.second)}`;
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
export class ParathesizedClause extends Clause {
|
|
18
|
+
toString(): string {
|
|
19
|
+
return `(${this.first} ${this.operator} ${quote(this.second)})`;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
17
23
|
export const toClause = (first: unknown, operator: string, second: unknown, conv: Convert = convert.default): Clause =>
|
|
18
24
|
new Clause(first, operator, conv.from(second));
|
|
19
25
|
|
package/src/sql/Column.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Property, PropertyOptions } from '../utils';
|
|
2
2
|
import { Clause, toClause } from './Clause';
|
|
3
|
-
import { Json, JsonValue, ofGet, Text } from '../types';
|
|
3
|
+
import { Json, JsonValue, ofGet, Text, tryTo } from '../types';
|
|
4
4
|
import { Table } from './Table';
|
|
5
5
|
|
|
6
6
|
export class Column extends Property implements Text {
|
|
@@ -40,9 +40,16 @@ export class Column extends Property implements Text {
|
|
|
40
40
|
return this.format('$col DESC') as OrderColumn;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
in = (source: Json = {}): JsonValue =>
|
|
43
|
+
in = (source: Json = {}): JsonValue =>
|
|
44
|
+
tryTo(source)
|
|
45
|
+
.map(s => s[this.property] ?? ofGet(this.options?.dflt))
|
|
46
|
+
.map(v => this.options?.convert?.to(v))
|
|
47
|
+
.orElse();
|
|
44
48
|
|
|
45
|
-
out = (source: Json = {}, key = ''): JsonValue =>
|
|
49
|
+
out = (source: Json = {}, key = ''): JsonValue =>
|
|
50
|
+
tryTo(source)
|
|
51
|
+
.map(s => this.options?.convert?.from(s[key]))
|
|
52
|
+
.orElse();
|
|
46
53
|
|
|
47
54
|
function = (func: string): Column => this.format(`${func}($name)`);
|
|
48
55
|
|