@thisisagile/easy-domain 15.29.3
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 +282 -0
- package/dist/chunk-3N5M6QHW.mjs +132 -0
- package/dist/chunk-3N5M6QHW.mjs.map +1 -0
- package/dist/chunk-CKW4QYDN.mjs +16 -0
- package/dist/chunk-CKW4QYDN.mjs.map +1 -0
- package/dist/chunk-H2VHSGNX.mjs +35 -0
- package/dist/chunk-H2VHSGNX.mjs.map +1 -0
- package/dist/chunk-ODLLVCBP.mjs +6634 -0
- package/dist/chunk-ODLLVCBP.mjs.map +1 -0
- package/dist/chunk-RDITZTSA.mjs +41 -0
- package/dist/chunk-RDITZTSA.mjs.map +1 -0
- package/dist/chunk-SBXA2N6H.mjs +29 -0
- package/dist/chunk-SBXA2N6H.mjs.map +1 -0
- package/dist/chunk-VAHXDD2J.mjs +268 -0
- package/dist/chunk-VAHXDD2J.mjs.map +1 -0
- package/dist/chunk-XBORRJ6W.mjs +18 -0
- package/dist/chunk-XBORRJ6W.mjs.map +1 -0
- package/dist/enums/Country.d.ts +256 -0
- package/dist/enums/Country.mjs +8 -0
- package/dist/enums/Country.mjs.map +1 -0
- package/dist/enums/Currency.d.ts +124 -0
- package/dist/enums/Currency.mjs +8 -0
- package/dist/enums/Currency.mjs.map +1 -0
- package/dist/enums/Locale.d.ts +571 -0
- package/dist/enums/Locale.mjs +584 -0
- package/dist/enums/Locale.mjs.map +1 -0
- package/dist/enums/UnitOfMeasurement.d.ts +10 -0
- package/dist/enums/UnitOfMeasurement.mjs +8 -0
- package/dist/enums/UnitOfMeasurement.mjs.map +1 -0
- package/dist/enums/UnitOfWeight.d.ts +8 -0
- package/dist/enums/UnitOfWeight.mjs +8 -0
- package/dist/enums/UnitOfWeight.mjs.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +7997 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +18 -0
- package/dist/index.mjs.map +1 -0
- package/dist/structs/Address.d.ts +12 -0
- package/dist/structs/Address.mjs +47 -0
- package/dist/structs/Address.mjs.map +1 -0
- package/dist/structs/Box.d.ts +15 -0
- package/dist/structs/Box.mjs +44 -0
- package/dist/structs/Box.mjs.map +1 -0
- package/dist/structs/Dimension.d.ts +10 -0
- package/dist/structs/Dimension.mjs +9 -0
- package/dist/structs/Dimension.mjs.map +1 -0
- package/dist/structs/Money.d.ts +14 -0
- package/dist/structs/Money.mjs +48 -0
- package/dist/structs/Money.mjs.map +1 -0
- package/dist/structs/Name.d.ts +8 -0
- package/dist/structs/Name.mjs +26 -0
- package/dist/structs/Name.mjs.map +1 -0
- package/dist/structs/Weight.d.ts +13 -0
- package/dist/structs/Weight.mjs +43 -0
- package/dist/structs/Weight.mjs.map +1 -0
- package/dist/values/EAN.d.ts +5 -0
- package/dist/values/EAN.mjs +23 -0
- package/dist/values/EAN.mjs.map +1 -0
- package/dist/values/Email.d.ts +8 -0
- package/dist/values/Email.mjs +29 -0
- package/dist/values/Email.mjs.map +1 -0
- package/dist/values/IBAN.d.ts +5 -0
- package/dist/values/IBAN.mjs +23 -0
- package/dist/values/IBAN.mjs.map +1 -0
- package/dist/values/PostalCode.d.ts +8 -0
- package/dist/values/PostalCode.mjs +12 -0
- package/dist/values/PostalCode.mjs.map +1 -0
- package/dist/values/Slug.d.ts +6 -0
- package/dist/values/Slug.mjs +24 -0
- package/dist/values/Slug.mjs.map +1 -0
- package/dist/values/Url.d.ts +22 -0
- package/dist/values/Url.mjs +29 -0
- package/dist/values/Url.mjs.map +1 -0
- package/package.json +44 -0
- package/src/enums/Country.ts +269 -0
- package/src/enums/Currency.ts +131 -0
- package/src/enums/Locale.ts +584 -0
- package/src/enums/UnitOfMeasurement.ts +17 -0
- package/src/enums/UnitOfWeight.ts +15 -0
- package/src/enums/countries.json +251 -0
- package/src/enums/currencies.json +1073 -0
- package/src/enums/locales.json +565 -0
- package/src/index.ts +19 -0
- package/src/structs/Address.ts +23 -0
- package/src/structs/Box.ts +28 -0
- package/src/structs/Dimension.ts +24 -0
- package/src/structs/Money.ts +37 -0
- package/src/structs/Name.ts +13 -0
- package/src/structs/Weight.ts +34 -0
- package/src/values/EAN.ts +12 -0
- package/src/values/Email.ts +20 -0
- package/src/values/IBAN.ts +12 -0
- package/src/values/PostalCode.ts +17 -0
- package/src/values/Slug.ts +14 -0
- package/src/values/Url.ts +73 -0
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export * from "./enums/Country";
|
|
2
|
+
export * from "./enums/Currency";
|
|
3
|
+
export * from "./enums/Locale";
|
|
4
|
+
export * from "./enums/UnitOfMeasurement";
|
|
5
|
+
export * from "./enums/UnitOfWeight";
|
|
6
|
+
export * from "./structs/Address";
|
|
7
|
+
export * from "./structs/Box";
|
|
8
|
+
export * from "./structs/Dimension";
|
|
9
|
+
export * from "./structs/Money";
|
|
10
|
+
export * from "./structs/Name";
|
|
11
|
+
export * from "./structs/Weight";
|
|
12
|
+
export * from "./values/EAN";
|
|
13
|
+
export * from "./values/Email";
|
|
14
|
+
export * from "./values/IBAN";
|
|
15
|
+
export * from "./values/PostalCode";
|
|
16
|
+
export * from "./values/Slug";
|
|
17
|
+
export * from "./values/Url";
|
|
18
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from './enums/Country';\nexport * from './enums/Currency';\nexport * from './enums/Locale';\nexport * from './enums/UnitOfMeasurement';\nexport * from './enums/UnitOfWeight';\n\nexport * from './structs/Address';\nexport * from './structs/Box';\nexport * from './structs/Dimension';\nexport * from './structs/Money';\nexport * from './structs/Name';\nexport * from './structs/Weight';\n\nexport * from './values/EAN';\nexport * from './values/Email';\nexport * from './values/IBAN';\nexport * from './values/PostalCode';\nexport * from './values/Slug';\nexport * from './values/Url';\n"],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAEd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAEd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Struct } from '@thisisagile/easy';
|
|
2
|
+
import { Country } from '../enums/Country';
|
|
3
|
+
export declare class Address extends Struct {
|
|
4
|
+
readonly street: string;
|
|
5
|
+
readonly houseNumber: string;
|
|
6
|
+
readonly extension: string;
|
|
7
|
+
readonly postalCode: import("../values/PostalCode").PostalCode;
|
|
8
|
+
readonly city: string;
|
|
9
|
+
readonly country: Country;
|
|
10
|
+
toString(): string;
|
|
11
|
+
}
|
|
12
|
+
export declare const isAddress: (a?: unknown) => a is Address;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import {
|
|
2
|
+
postalCode
|
|
3
|
+
} from "../chunk-SBXA2N6H.mjs";
|
|
4
|
+
import "../chunk-ODLLVCBP.mjs";
|
|
5
|
+
import {
|
|
6
|
+
Country
|
|
7
|
+
} from "../chunk-VAHXDD2J.mjs";
|
|
8
|
+
import {
|
|
9
|
+
__decorateClass
|
|
10
|
+
} from "../chunk-RDITZTSA.mjs";
|
|
11
|
+
|
|
12
|
+
// src/structs/Address.ts
|
|
13
|
+
import { isEmpty, text, required, valid, Struct } from "@thisisagile/easy";
|
|
14
|
+
var Address = class extends Struct {
|
|
15
|
+
street = this.state.street;
|
|
16
|
+
houseNumber = this.state.houseNumber;
|
|
17
|
+
extension = this.state.extension;
|
|
18
|
+
postalCode = postalCode(this.state.postalCode, this.state.country);
|
|
19
|
+
city = this.state.city;
|
|
20
|
+
country = Country.byId(this.state.country);
|
|
21
|
+
toString() {
|
|
22
|
+
return text(this.street).with(" ", this.houseNumber, this.extension).with(", ", text(this.postalCode).with(" ", this.city, this.country?.name)).toString();
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
__decorateClass([
|
|
26
|
+
required()
|
|
27
|
+
], Address.prototype, "street", 2);
|
|
28
|
+
__decorateClass([
|
|
29
|
+
required()
|
|
30
|
+
], Address.prototype, "houseNumber", 2);
|
|
31
|
+
__decorateClass([
|
|
32
|
+
valid()
|
|
33
|
+
], Address.prototype, "postalCode", 2);
|
|
34
|
+
__decorateClass([
|
|
35
|
+
required()
|
|
36
|
+
], Address.prototype, "city", 2);
|
|
37
|
+
__decorateClass([
|
|
38
|
+
required()
|
|
39
|
+
], Address.prototype, "country", 2);
|
|
40
|
+
var isAddress = (a) => {
|
|
41
|
+
return !isEmpty(a) && a instanceof Address;
|
|
42
|
+
};
|
|
43
|
+
export {
|
|
44
|
+
Address,
|
|
45
|
+
isAddress
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=Address.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/structs/Address.ts"],"sourcesContent":["import { isEmpty, text, required, valid, Struct } from '@thisisagile/easy';\nimport { Country } from '../enums/Country';\nimport { postalCode } from '../values/PostalCode';\n\nexport class Address extends Struct {\n @required() readonly street = this.state.street as string;\n @required() readonly houseNumber = this.state.houseNumber as string;\n readonly extension = this.state.extension as string;\n @valid() readonly postalCode = postalCode(this.state.postalCode, this.state.country);\n @required() readonly city = this.state.city as string;\n @required() readonly country = Country.byId<Country>(this.state.country);\n\n toString(): string {\n return text(this.street)\n .with(' ', this.houseNumber, this.extension)\n .with(', ', text(this.postalCode).with(' ', this.city, this.country?.name))\n .toString();\n }\n}\n\nexport const isAddress = (a?: unknown): a is Address => {\n return !isEmpty(a) && a instanceof Address;\n};\n"],"mappings":";;;;;;;;;;;;AAAA,SAAS,SAAS,MAAM,UAAU,OAAO,cAAc;AAIhD,IAAM,UAAN,cAAsB,OAAO;AAAA,EACb,SAAS,KAAK,MAAM;AAAA,EACpB,cAAc,KAAK,MAAM;AAAA,EACrC,YAAY,KAAK,MAAM;AAAA,EACd,aAAa,WAAW,KAAK,MAAM,YAAY,KAAK,MAAM,OAAO;AAAA,EAC9D,OAAO,KAAK,MAAM;AAAA,EAClB,UAAU,QAAQ,KAAc,KAAK,MAAM,OAAO;AAAA,EAEvE,WAAmB;AACjB,WAAO,KAAK,KAAK,MAAM,EACpB,KAAK,KAAK,KAAK,aAAa,KAAK,SAAS,EAC1C,KAAK,MAAM,KAAK,KAAK,UAAU,EAAE,KAAK,KAAK,KAAK,MAAM,KAAK,SAAS,IAAI,CAAC,EACzE,SAAS;AAAA,EACd;AACF;AAbuB;AAAA,EAApB,SAAS;AAAA,GADC,QACU;AACA;AAAA,EAApB,SAAS;AAAA,GAFC,QAEU;AAEH;AAAA,EAAjB,MAAM;AAAA,GAJI,QAIO;AACG;AAAA,EAApB,SAAS;AAAA,GALC,QAKU;AACA;AAAA,EAApB,SAAS;AAAA,GANC,QAMU;AAUhB,IAAM,YAAY,CAAC,MAA8B;AACtD,SAAO,CAAC,QAAQ,CAAC,KAAK,aAAa;AACrC;","names":[]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Struct } from '@thisisagile/easy';
|
|
2
|
+
import { Dimension } from './Dimension';
|
|
3
|
+
export declare class Box extends Struct {
|
|
4
|
+
readonly l: Dimension;
|
|
5
|
+
readonly w: Dimension;
|
|
6
|
+
readonly h: Dimension;
|
|
7
|
+
private readonly sorted;
|
|
8
|
+
lowestDim: Dimension;
|
|
9
|
+
medianDim: Dimension;
|
|
10
|
+
maxDim: Dimension;
|
|
11
|
+
get isValid(): boolean;
|
|
12
|
+
static with: (l: Dimension, w: Dimension, h: Dimension) => Box;
|
|
13
|
+
stack(qty: number): Box;
|
|
14
|
+
fits(contents: Box, qty?: number): boolean;
|
|
15
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Dimension
|
|
3
|
+
} from "../chunk-H2VHSGNX.mjs";
|
|
4
|
+
import "../chunk-XBORRJ6W.mjs";
|
|
5
|
+
import {
|
|
6
|
+
__decorateClass
|
|
7
|
+
} from "../chunk-RDITZTSA.mjs";
|
|
8
|
+
|
|
9
|
+
// src/structs/Box.ts
|
|
10
|
+
import { Struct, required } from "@thisisagile/easy";
|
|
11
|
+
var _Box = class _Box extends Struct {
|
|
12
|
+
l = new Dimension(this.state.l);
|
|
13
|
+
w = new Dimension(this.state.w);
|
|
14
|
+
h = new Dimension(this.state.h);
|
|
15
|
+
sorted = [this.l, this.w, this.h].sort((n1, n2) => n1.inMilliMeters - n2.inMilliMeters);
|
|
16
|
+
lowestDim = this.sorted[0];
|
|
17
|
+
medianDim = this.sorted[1];
|
|
18
|
+
maxDim = this.sorted[2];
|
|
19
|
+
get isValid() {
|
|
20
|
+
return super.isValid && this.l.isValid && this.w.isValid && this.h.isValid;
|
|
21
|
+
}
|
|
22
|
+
static with = (l, w, h) => new _Box({ l, w, h });
|
|
23
|
+
stack(qty) {
|
|
24
|
+
return _Box.with(this.maxDim, this.medianDim, Dimension.with(this.lowestDim.value * qty, this.lowestDim.uom));
|
|
25
|
+
}
|
|
26
|
+
fits(contents, qty = 1) {
|
|
27
|
+
const stackedContent = contents.stack(qty);
|
|
28
|
+
return this.lowestDim.gte(stackedContent.lowestDim) && this.medianDim.gte(stackedContent.medianDim) && this.maxDim.gte(stackedContent.maxDim);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
__decorateClass([
|
|
32
|
+
required()
|
|
33
|
+
], _Box.prototype, "l", 2);
|
|
34
|
+
__decorateClass([
|
|
35
|
+
required()
|
|
36
|
+
], _Box.prototype, "w", 2);
|
|
37
|
+
__decorateClass([
|
|
38
|
+
required()
|
|
39
|
+
], _Box.prototype, "h", 2);
|
|
40
|
+
var Box = _Box;
|
|
41
|
+
export {
|
|
42
|
+
Box
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=Box.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/structs/Box.ts"],"sourcesContent":["import { Struct, required } from '@thisisagile/easy';\nimport { Dimension } from './Dimension';\n\nexport class Box extends Struct {\n @required() readonly l: Dimension = new Dimension(this.state.l);\n @required() readonly w: Dimension = new Dimension(this.state.w);\n @required() readonly h: Dimension = new Dimension(this.state.h);\n\n private readonly sorted: Dimension[] = [this.l, this.w, this.h].sort((n1, n2) => n1.inMilliMeters - n2.inMilliMeters);\n lowestDim: Dimension = this.sorted[0];\n medianDim: Dimension = this.sorted[1];\n maxDim: Dimension = this.sorted[2];\n\n get isValid(): boolean {\n return super.isValid && this.l.isValid && this.w.isValid && this.h.isValid;\n }\n\n static with = (l: Dimension, w: Dimension, h: Dimension) => new Box({ l, w, h });\n\n stack(qty: number): Box {\n return Box.with(this.maxDim, this.medianDim, Dimension.with(this.lowestDim.value * qty, this.lowestDim.uom));\n }\n\n fits(contents: Box, qty = 1): boolean {\n const stackedContent = contents.stack(qty);\n return this.lowestDim.gte(stackedContent.lowestDim) && this.medianDim.gte(stackedContent.medianDim) && this.maxDim.gte(stackedContent.maxDim);\n }\n}\n"],"mappings":";;;;;;;;;AAAA,SAAS,QAAQ,gBAAgB;AAG1B,IAAM,OAAN,MAAM,aAAY,OAAO;AAAA,EACT,IAAe,IAAI,UAAU,KAAK,MAAM,CAAC;AAAA,EACzC,IAAe,IAAI,UAAU,KAAK,MAAM,CAAC;AAAA,EACzC,IAAe,IAAI,UAAU,KAAK,MAAM,CAAC;AAAA,EAE7C,SAAsB,CAAC,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC,EAAE,KAAK,CAAC,IAAI,OAAO,GAAG,gBAAgB,GAAG,aAAa;AAAA,EACpH,YAAuB,KAAK,OAAO,CAAC;AAAA,EACpC,YAAuB,KAAK,OAAO,CAAC;AAAA,EACpC,SAAoB,KAAK,OAAO,CAAC;AAAA,EAEjC,IAAI,UAAmB;AACrB,WAAO,MAAM,WAAW,KAAK,EAAE,WAAW,KAAK,EAAE,WAAW,KAAK,EAAE;AAAA,EACrE;AAAA,EAEA,OAAO,OAAO,CAAC,GAAc,GAAc,MAAiB,IAAI,KAAI,EAAE,GAAG,GAAG,EAAE,CAAC;AAAA,EAE/E,MAAM,KAAkB;AACtB,WAAO,KAAI,KAAK,KAAK,QAAQ,KAAK,WAAW,UAAU,KAAK,KAAK,UAAU,QAAQ,KAAK,KAAK,UAAU,GAAG,CAAC;AAAA,EAC7G;AAAA,EAEA,KAAK,UAAe,MAAM,GAAY;AACpC,UAAM,iBAAiB,SAAS,MAAM,GAAG;AACzC,WAAO,KAAK,UAAU,IAAI,eAAe,SAAS,KAAK,KAAK,UAAU,IAAI,eAAe,SAAS,KAAK,KAAK,OAAO,IAAI,eAAe,MAAM;AAAA,EAC9I;AACF;AAvBuB;AAAA,EAApB,SAAS;AAAA,GADC,KACU;AACA;AAAA,EAApB,SAAS;AAAA,GAFC,KAEU;AACA;AAAA,EAApB,SAAS;AAAA,GAHC,KAGU;AAHhB,IAAM,MAAN;","names":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Struct } from '@thisisagile/easy';
|
|
2
|
+
import { UnitOfMeasurement } from '../enums/UnitOfMeasurement';
|
|
3
|
+
export declare class Dimension extends Struct {
|
|
4
|
+
readonly value: number;
|
|
5
|
+
readonly uom: UnitOfMeasurement;
|
|
6
|
+
static with: (value: number, uom?: UnitOfMeasurement) => Dimension;
|
|
7
|
+
sizeInMM(): number;
|
|
8
|
+
get inMilliMeters(): number;
|
|
9
|
+
gte(dim: Dimension): boolean;
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Struct } from '@thisisagile/easy';
|
|
2
|
+
import { Currency } from '../enums/Currency';
|
|
3
|
+
export declare class Money extends Struct {
|
|
4
|
+
readonly currency: Currency;
|
|
5
|
+
readonly value: number;
|
|
6
|
+
add(amount: number): Money;
|
|
7
|
+
subtract(amount: number): Money;
|
|
8
|
+
times(n: number): Money;
|
|
9
|
+
toString(): string;
|
|
10
|
+
static zero(currency: Currency): Money;
|
|
11
|
+
static amount(currency: Currency, value?: number): Money;
|
|
12
|
+
}
|
|
13
|
+
export declare const money: (currency: Currency, value: number) => Money;
|
|
14
|
+
export declare const isMoney: (m?: unknown) => m is Money;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Currency
|
|
3
|
+
} from "../chunk-3N5M6QHW.mjs";
|
|
4
|
+
import {
|
|
5
|
+
__decorateClass
|
|
6
|
+
} from "../chunk-RDITZTSA.mjs";
|
|
7
|
+
|
|
8
|
+
// src/structs/Money.ts
|
|
9
|
+
import { Struct, isEmpty, text, required } from "@thisisagile/easy";
|
|
10
|
+
var _Money = class _Money extends Struct {
|
|
11
|
+
currency = Currency.byId(this.state.currency);
|
|
12
|
+
value = this.state.value;
|
|
13
|
+
add(amount) {
|
|
14
|
+
return money(this.currency, this.value + amount);
|
|
15
|
+
}
|
|
16
|
+
subtract(amount) {
|
|
17
|
+
return money(this.currency, this.value - amount);
|
|
18
|
+
}
|
|
19
|
+
times(n) {
|
|
20
|
+
return money(this.currency, this.value * n);
|
|
21
|
+
}
|
|
22
|
+
toString() {
|
|
23
|
+
return text(this.currency?.code).with(" ", this.value?.toFixed(this.currency?.digits ?? 2)).toString();
|
|
24
|
+
}
|
|
25
|
+
static zero(currency) {
|
|
26
|
+
return _Money.amount(currency);
|
|
27
|
+
}
|
|
28
|
+
static amount(currency, value = 0) {
|
|
29
|
+
return money(currency, value);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
__decorateClass([
|
|
33
|
+
required()
|
|
34
|
+
], _Money.prototype, "currency", 2);
|
|
35
|
+
__decorateClass([
|
|
36
|
+
required()
|
|
37
|
+
], _Money.prototype, "value", 2);
|
|
38
|
+
var Money = _Money;
|
|
39
|
+
var money = (currency, value) => new Money({ currency: currency.id, value });
|
|
40
|
+
var isMoney = (m) => {
|
|
41
|
+
return !isEmpty(m) && m instanceof Money;
|
|
42
|
+
};
|
|
43
|
+
export {
|
|
44
|
+
Money,
|
|
45
|
+
isMoney,
|
|
46
|
+
money
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=Money.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/structs/Money.ts"],"sourcesContent":["import { Struct, isEmpty, text, required } from '@thisisagile/easy';\nimport { Currency } from '../enums/Currency';\n\nexport class Money extends Struct {\n @required() readonly currency = Currency.byId<Currency>(this.state.currency);\n @required() readonly value = this.state.value as number;\n\n add(amount: number): Money {\n return money(this.currency, this.value + amount);\n }\n subtract(amount: number): Money {\n return money(this.currency, this.value - amount);\n }\n times(n: number): Money {\n return money(this.currency, this.value * n);\n }\n\n toString(): string {\n return text(this.currency?.code)\n .with(' ', this.value?.toFixed(this.currency?.digits ?? 2))\n .toString();\n }\n\n static zero(currency: Currency): Money {\n return Money.amount(currency);\n }\n\n static amount(currency: Currency, value: number = 0): Money {\n return money(currency, value);\n }\n}\n\nexport const money = (currency: Currency, value: number): Money => new Money({ currency: currency.id, value });\n\nexport const isMoney = (m?: unknown): m is Money => {\n return !isEmpty(m) && m instanceof Money;\n};\n"],"mappings":";;;;;;;;AAAA,SAAS,QAAQ,SAAS,MAAM,gBAAgB;AAGzC,IAAM,SAAN,MAAM,eAAc,OAAO;AAAA,EACX,WAAW,SAAS,KAAe,KAAK,MAAM,QAAQ;AAAA,EACtD,QAAQ,KAAK,MAAM;AAAA,EAExC,IAAI,QAAuB;AACzB,WAAO,MAAM,KAAK,UAAU,KAAK,QAAQ,MAAM;AAAA,EACjD;AAAA,EACA,SAAS,QAAuB;AAC9B,WAAO,MAAM,KAAK,UAAU,KAAK,QAAQ,MAAM;AAAA,EACjD;AAAA,EACA,MAAM,GAAkB;AACtB,WAAO,MAAM,KAAK,UAAU,KAAK,QAAQ,CAAC;AAAA,EAC5C;AAAA,EAEA,WAAmB;AACjB,WAAO,KAAK,KAAK,UAAU,IAAI,EAC5B,KAAK,KAAK,KAAK,OAAO,QAAQ,KAAK,UAAU,UAAU,CAAC,CAAC,EACzD,SAAS;AAAA,EACd;AAAA,EAEA,OAAO,KAAK,UAA2B;AACrC,WAAO,OAAM,OAAO,QAAQ;AAAA,EAC9B;AAAA,EAEA,OAAO,OAAO,UAAoB,QAAgB,GAAU;AAC1D,WAAO,MAAM,UAAU,KAAK;AAAA,EAC9B;AACF;AA1BuB;AAAA,EAApB,SAAS;AAAA,GADC,OACU;AACA;AAAA,EAApB,SAAS;AAAA,GAFC,OAEU;AAFhB,IAAM,QAAN;AA6BA,IAAM,QAAQ,CAAC,UAAoB,UAAyB,IAAI,MAAM,EAAE,UAAU,SAAS,IAAI,MAAM,CAAC;AAEtG,IAAM,UAAU,CAAC,MAA4B;AAClD,SAAO,CAAC,QAAQ,CAAC,KAAK,aAAa;AACrC;","names":[]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__decorateClass
|
|
3
|
+
} from "../chunk-RDITZTSA.mjs";
|
|
4
|
+
|
|
5
|
+
// src/structs/Name.ts
|
|
6
|
+
import { Struct, text, required } from "@thisisagile/easy";
|
|
7
|
+
var Name = class extends Struct {
|
|
8
|
+
first = this.state.first;
|
|
9
|
+
middle = this.state.middle;
|
|
10
|
+
last = this.state.last;
|
|
11
|
+
toString() {
|
|
12
|
+
return text(this.first, "").add(this.middle, " ").add(this.last, " ").toString();
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
__decorateClass([
|
|
16
|
+
required()
|
|
17
|
+
], Name.prototype, "first", 2);
|
|
18
|
+
__decorateClass([
|
|
19
|
+
required()
|
|
20
|
+
], Name.prototype, "last", 2);
|
|
21
|
+
var name = (n) => new Name(n);
|
|
22
|
+
export {
|
|
23
|
+
Name,
|
|
24
|
+
name
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=Name.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/structs/Name.ts"],"sourcesContent":["import { Struct, Json, text, required } from '@thisisagile/easy';\n\nexport class Name extends Struct {\n @required() readonly first: string = this.state.first;\n readonly middle: string = this.state.middle;\n @required() readonly last: string = this.state.last;\n\n toString(): string {\n return text(this.first, '').add(this.middle, ' ').add(this.last, ' ').toString();\n }\n}\n\nexport const name = (n?: Json): Name => new Name(n);\n"],"mappings":";;;;;AAAA,SAAS,QAAc,MAAM,gBAAgB;AAEtC,IAAM,OAAN,cAAmB,OAAO;AAAA,EACV,QAAgB,KAAK,MAAM;AAAA,EACvC,SAAiB,KAAK,MAAM;AAAA,EAChB,OAAe,KAAK,MAAM;AAAA,EAE/C,WAAmB;AACjB,WAAO,KAAK,KAAK,OAAO,EAAE,EAAE,IAAI,KAAK,QAAQ,GAAG,EAAE,IAAI,KAAK,MAAM,GAAG,EAAE,SAAS;AAAA,EACjF;AACF;AAPuB;AAAA,EAApB,SAAS;AAAA,GADC,KACU;AAEA;AAAA,EAApB,SAAS;AAAA,GAHC,KAGU;AAOhB,IAAM,OAAO,CAAC,MAAmB,IAAI,KAAK,CAAC;","names":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { UnitOfWeight } from '../enums/UnitOfWeight';
|
|
2
|
+
import { Struct } from '@thisisagile/easy';
|
|
3
|
+
export declare class Weight extends Struct {
|
|
4
|
+
readonly value: number;
|
|
5
|
+
readonly uow: UnitOfWeight;
|
|
6
|
+
sizeInG(): number;
|
|
7
|
+
get inGrams(): number;
|
|
8
|
+
gte(w: Weight): boolean;
|
|
9
|
+
lte(w: Weight): boolean;
|
|
10
|
+
between(lower: Weight, upper?: Weight): boolean;
|
|
11
|
+
sum(add: Weight): Weight;
|
|
12
|
+
}
|
|
13
|
+
export declare const weight: (value: number, uow?: UnitOfWeight) => Weight;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import {
|
|
2
|
+
UnitOfWeight
|
|
3
|
+
} from "../chunk-CKW4QYDN.mjs";
|
|
4
|
+
import {
|
|
5
|
+
__decorateClass
|
|
6
|
+
} from "../chunk-RDITZTSA.mjs";
|
|
7
|
+
|
|
8
|
+
// src/structs/Weight.ts
|
|
9
|
+
import { Struct, required } from "@thisisagile/easy";
|
|
10
|
+
var Weight = class extends Struct {
|
|
11
|
+
value = this.state.value;
|
|
12
|
+
uow = UnitOfWeight.byId(this.state.uow, UnitOfWeight.G);
|
|
13
|
+
/**
|
|
14
|
+
@deprecated use inGrams getter instead
|
|
15
|
+
*/
|
|
16
|
+
sizeInG() {
|
|
17
|
+
return this.inGrams;
|
|
18
|
+
}
|
|
19
|
+
get inGrams() {
|
|
20
|
+
return this.value * this.uow.gMultiplier;
|
|
21
|
+
}
|
|
22
|
+
gte(w) {
|
|
23
|
+
return this.inGrams >= w.inGrams;
|
|
24
|
+
}
|
|
25
|
+
lte(w) {
|
|
26
|
+
return this.inGrams <= w.inGrams;
|
|
27
|
+
}
|
|
28
|
+
between(lower, upper = weight(Number.MAX_VALUE, this.uow)) {
|
|
29
|
+
return this.gte(lower) && this.lte(upper);
|
|
30
|
+
}
|
|
31
|
+
sum(add) {
|
|
32
|
+
return weight((this.inGrams + add.inGrams) / this.uow.gMultiplier, this.uow);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
__decorateClass([
|
|
36
|
+
required()
|
|
37
|
+
], Weight.prototype, "value", 2);
|
|
38
|
+
var weight = (value, uow) => new Weight({ value, uow });
|
|
39
|
+
export {
|
|
40
|
+
Weight,
|
|
41
|
+
weight
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=Weight.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/structs/Weight.ts"],"sourcesContent":["import { UnitOfWeight } from '../enums/UnitOfWeight';\nimport { Struct, required } from '@thisisagile/easy';\n\nexport class Weight extends Struct {\n @required() readonly value = this.state.value as number;\n readonly uow = UnitOfWeight.byId<UnitOfWeight>(this.state.uow, UnitOfWeight.G);\n\n /**\n @deprecated use inGrams getter instead\n */\n sizeInG(): number {\n return this.inGrams;\n }\n\n get inGrams(): number {\n return this.value * this.uow.gMultiplier;\n }\n\n gte(w: Weight): boolean {\n return this.inGrams >= w.inGrams;\n }\n lte(w: Weight): boolean {\n return this.inGrams <= w.inGrams;\n }\n\n between(lower: Weight, upper = weight(Number.MAX_VALUE, this.uow)) {\n return this.gte(lower) && this.lte(upper);\n }\n sum(add: Weight): Weight {\n return weight((this.inGrams + add.inGrams) / this.uow.gMultiplier, this.uow);\n }\n}\n\nexport const weight = (value: number, uow?: UnitOfWeight): Weight => new Weight({ value, uow });\n"],"mappings":";;;;;;;;AACA,SAAS,QAAQ,gBAAgB;AAE1B,IAAM,SAAN,cAAqB,OAAO;AAAA,EACZ,QAAQ,KAAK,MAAM;AAAA,EAC/B,MAAM,aAAa,KAAmB,KAAK,MAAM,KAAK,aAAa,CAAC;AAAA;AAAA;AAAA;AAAA,EAK7E,UAAkB;AAChB,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAI,UAAkB;AACpB,WAAO,KAAK,QAAQ,KAAK,IAAI;AAAA,EAC/B;AAAA,EAEA,IAAI,GAAoB;AACtB,WAAO,KAAK,WAAW,EAAE;AAAA,EAC3B;AAAA,EACA,IAAI,GAAoB;AACtB,WAAO,KAAK,WAAW,EAAE;AAAA,EAC3B;AAAA,EAEA,QAAQ,OAAe,QAAQ,OAAO,OAAO,WAAW,KAAK,GAAG,GAAG;AACjE,WAAO,KAAK,IAAI,KAAK,KAAK,KAAK,IAAI,KAAK;AAAA,EAC1C;AAAA,EACA,IAAI,KAAqB;AACvB,WAAO,QAAQ,KAAK,UAAU,IAAI,WAAW,KAAK,IAAI,aAAa,KAAK,GAAG;AAAA,EAC7E;AACF;AA3BuB;AAAA,EAApB,SAAS;AAAA,GADC,OACU;AA6BhB,IAAM,SAAS,CAAC,OAAe,QAA+B,IAAI,OAAO,EAAE,OAAO,IAAI,CAAC;","names":[]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {
|
|
2
|
+
require_validator
|
|
3
|
+
} from "../chunk-ODLLVCBP.mjs";
|
|
4
|
+
import {
|
|
5
|
+
__toESM
|
|
6
|
+
} from "../chunk-RDITZTSA.mjs";
|
|
7
|
+
|
|
8
|
+
// src/values/EAN.ts
|
|
9
|
+
var import_validator = __toESM(require_validator());
|
|
10
|
+
import { asString, isEmpty, Value } from "@thisisagile/easy";
|
|
11
|
+
var EAN = class extends Value {
|
|
12
|
+
get isValid() {
|
|
13
|
+
return isEAN(this.value);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
var isEAN = (ean) => {
|
|
17
|
+
return !isEmpty(ean) && (0, import_validator.isEAN)(asString(ean));
|
|
18
|
+
};
|
|
19
|
+
export {
|
|
20
|
+
EAN,
|
|
21
|
+
isEAN
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=EAN.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/values/EAN.ts"],"sourcesContent":["import { isEAN as validateEAN } from 'validator';\nimport { asString, isEmpty, Value } from '@thisisagile/easy';\n\nexport class EAN extends Value {\n get isValid(): boolean {\n return isEAN(this.value);\n }\n}\n\nexport const isEAN = (ean?: unknown): boolean => {\n return !isEmpty(ean) && validateEAN(asString(ean));\n};\n"],"mappings":";;;;;;;;AAAA,uBAAqC;AACrC,SAAS,UAAU,SAAS,aAAa;AAElC,IAAM,MAAN,cAAkB,MAAM;AAAA,EAC7B,IAAI,UAAmB;AACrB,WAAO,MAAM,KAAK,KAAK;AAAA,EACzB;AACF;AAEO,IAAM,QAAQ,CAAC,QAA2B;AAC/C,SAAO,CAAC,QAAQ,GAAG,SAAK,iBAAAA,OAAY,SAAS,GAAG,CAAC;AACnD;","names":["validateEAN"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Value } from '@thisisagile/easy';
|
|
2
|
+
export declare class Email extends Value {
|
|
3
|
+
constructor(email?: unknown);
|
|
4
|
+
get isValid(): boolean;
|
|
5
|
+
get name(): string;
|
|
6
|
+
}
|
|
7
|
+
export declare const email: (email?: unknown) => Email;
|
|
8
|
+
export declare const isEmail: (e?: unknown) => boolean;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import {
|
|
2
|
+
require_validator
|
|
3
|
+
} from "../chunk-ODLLVCBP.mjs";
|
|
4
|
+
import {
|
|
5
|
+
__toESM
|
|
6
|
+
} from "../chunk-RDITZTSA.mjs";
|
|
7
|
+
|
|
8
|
+
// src/values/Email.ts
|
|
9
|
+
var import_validator = __toESM(require_validator());
|
|
10
|
+
import { asString, isEmpty, text, Value } from "@thisisagile/easy";
|
|
11
|
+
var Email = class extends Value {
|
|
12
|
+
constructor(email2) {
|
|
13
|
+
super(asString(email2).trim().toLowerCase());
|
|
14
|
+
}
|
|
15
|
+
get isValid() {
|
|
16
|
+
return isEmail(this.value);
|
|
17
|
+
}
|
|
18
|
+
get name() {
|
|
19
|
+
return text(this.value.split("@")[0]).replace(".", " ").title.toString();
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
var email = (email2) => new Email(email2);
|
|
23
|
+
var isEmail = (e) => !isEmpty(e) && (0, import_validator.isEmail)(asString(e));
|
|
24
|
+
export {
|
|
25
|
+
Email,
|
|
26
|
+
email,
|
|
27
|
+
isEmail
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=Email.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/values/Email.ts"],"sourcesContent":["import { isEmail as validateEmail } from 'validator';\nimport { asString, isEmpty, text, Value } from '@thisisagile/easy';\n\nexport class Email extends Value {\n constructor(email?: unknown) {\n super(asString(email).trim().toLowerCase());\n }\n\n get isValid(): boolean {\n return isEmail(this.value);\n }\n\n get name(): string {\n return text(this.value.split('@')[0]).replace('.', ' ').title.toString();\n }\n}\n\nexport const email = (email?: unknown): Email => new Email(email);\n\nexport const isEmail = (e?: unknown): boolean => !isEmpty(e) && validateEmail(asString(e));\n"],"mappings":";;;;;;;;AAAA,uBAAyC;AACzC,SAAS,UAAU,SAAS,MAAM,aAAa;AAExC,IAAM,QAAN,cAAoB,MAAM;AAAA,EAC/B,YAAYA,QAAiB;AAC3B,UAAM,SAASA,MAAK,EAAE,KAAK,EAAE,YAAY,CAAC;AAAA,EAC5C;AAAA,EAEA,IAAI,UAAmB;AACrB,WAAO,QAAQ,KAAK,KAAK;AAAA,EAC3B;AAAA,EAEA,IAAI,OAAe;AACjB,WAAO,KAAK,KAAK,MAAM,MAAM,GAAG,EAAE,CAAC,CAAC,EAAE,QAAQ,KAAK,GAAG,EAAE,MAAM,SAAS;AAAA,EACzE;AACF;AAEO,IAAM,QAAQ,CAACA,WAA2B,IAAI,MAAMA,MAAK;AAEzD,IAAM,UAAU,CAAC,MAAyB,CAAC,QAAQ,CAAC,SAAK,iBAAAC,SAAc,SAAS,CAAC,CAAC;","names":["email","validateEmail"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {
|
|
2
|
+
require_validator
|
|
3
|
+
} from "../chunk-ODLLVCBP.mjs";
|
|
4
|
+
import {
|
|
5
|
+
__toESM
|
|
6
|
+
} from "../chunk-RDITZTSA.mjs";
|
|
7
|
+
|
|
8
|
+
// src/values/IBAN.ts
|
|
9
|
+
var import_validator = __toESM(require_validator());
|
|
10
|
+
import { asString, isEmpty, Value } from "@thisisagile/easy";
|
|
11
|
+
var IBAN = class extends Value {
|
|
12
|
+
get isValid() {
|
|
13
|
+
return isIBAN(this.value);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
var isIBAN = (iban) => {
|
|
17
|
+
return !isEmpty(iban) && (0, import_validator.isIBAN)(asString(iban));
|
|
18
|
+
};
|
|
19
|
+
export {
|
|
20
|
+
IBAN,
|
|
21
|
+
isIBAN
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=IBAN.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/values/IBAN.ts"],"sourcesContent":["import { isIBAN as validateIBAN } from 'validator';\nimport { asString, isEmpty, Value } from '@thisisagile/easy';\n\nexport class IBAN extends Value {\n get isValid(): boolean {\n return isIBAN(this.value);\n }\n}\n\nexport const isIBAN = (iban?: unknown): boolean => {\n return !isEmpty(iban) && validateIBAN(asString(iban));\n};\n"],"mappings":";;;;;;;;AAAA,uBAAuC;AACvC,SAAS,UAAU,SAAS,aAAa;AAElC,IAAM,OAAN,cAAmB,MAAM;AAAA,EAC9B,IAAI,UAAmB;AACrB,WAAO,OAAO,KAAK,KAAK;AAAA,EAC1B;AACF;AAEO,IAAM,SAAS,CAAC,SAA4B;AACjD,SAAO,CAAC,QAAQ,IAAI,SAAK,iBAAAA,QAAa,SAAS,IAAI,CAAC;AACtD;","names":["validateIBAN"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Id, Value } from '@thisisagile/easy';
|
|
2
|
+
import { Country } from '../enums/Country';
|
|
3
|
+
export declare class PostalCode extends Value {
|
|
4
|
+
readonly country: Country | Id;
|
|
5
|
+
constructor(postalCode?: unknown, country?: Country | Id);
|
|
6
|
+
get isValid(): boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare const postalCode: (postalCode?: unknown, country?: Country | Id) => PostalCode;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import {
|
|
2
|
+
PostalCode,
|
|
3
|
+
postalCode
|
|
4
|
+
} from "../chunk-SBXA2N6H.mjs";
|
|
5
|
+
import "../chunk-ODLLVCBP.mjs";
|
|
6
|
+
import "../chunk-VAHXDD2J.mjs";
|
|
7
|
+
import "../chunk-RDITZTSA.mjs";
|
|
8
|
+
export {
|
|
9
|
+
PostalCode,
|
|
10
|
+
postalCode
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=PostalCode.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import {
|
|
2
|
+
require_validator
|
|
3
|
+
} from "../chunk-ODLLVCBP.mjs";
|
|
4
|
+
import {
|
|
5
|
+
__toESM
|
|
6
|
+
} from "../chunk-RDITZTSA.mjs";
|
|
7
|
+
|
|
8
|
+
// src/values/Slug.ts
|
|
9
|
+
var import_validator = __toESM(require_validator());
|
|
10
|
+
import { isNotEmpty, text, Value } from "@thisisagile/easy";
|
|
11
|
+
var Slug = class extends Value {
|
|
12
|
+
constructor(slug) {
|
|
13
|
+
super(text(slug).slug.toString());
|
|
14
|
+
}
|
|
15
|
+
get isValid() {
|
|
16
|
+
return isNotEmpty(this.value) && (0, import_validator.isSlug)(this.value);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
var toSlug = (slug) => new Slug(slug);
|
|
20
|
+
export {
|
|
21
|
+
Slug,
|
|
22
|
+
toSlug
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=Slug.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/values/Slug.ts"],"sourcesContent":["import { isNotEmpty, text, Value } from '@thisisagile/easy';\nimport { isSlug } from 'validator';\n\nexport class Slug extends Value {\n constructor(slug?: unknown) {\n super(text(slug).slug.toString());\n }\n\n get isValid(): boolean {\n return isNotEmpty(this.value) && isSlug(this.value);\n }\n}\n\nexport const toSlug = (slug?: unknown): Slug => new Slug(slug);\n"],"mappings":";;;;;;;;AACA,uBAAuB;AADvB,SAAS,YAAY,MAAM,aAAa;AAGjC,IAAM,OAAN,cAAmB,MAAM;AAAA,EAC9B,YAAY,MAAgB;AAC1B,UAAM,KAAK,IAAI,EAAE,KAAK,SAAS,CAAC;AAAA,EAClC;AAAA,EAEA,IAAI,UAAmB;AACrB,WAAO,WAAW,KAAK,KAAK,SAAK,yBAAO,KAAK,KAAK;AAAA,EACpD;AACF;AAEO,IAAM,SAAS,CAAC,SAAyB,IAAI,KAAK,IAAI;","names":[]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Value } from '@thisisagile/easy';
|
|
2
|
+
export interface UrlOptions {
|
|
3
|
+
protocols?: string[];
|
|
4
|
+
require_tld?: boolean;
|
|
5
|
+
require_protocol?: boolean;
|
|
6
|
+
require_host?: boolean;
|
|
7
|
+
require_port?: boolean;
|
|
8
|
+
require_valid_protocol?: boolean;
|
|
9
|
+
allow_underscores?: boolean;
|
|
10
|
+
host_whitelist?: Array<string | RegExp>;
|
|
11
|
+
host_blacklist?: Array<string | RegExp>;
|
|
12
|
+
allow_trailing_dot?: boolean;
|
|
13
|
+
allow_protocol_relative_urls?: boolean;
|
|
14
|
+
disallow_auth?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export declare class Url extends Value {
|
|
17
|
+
readonly options?: UrlOptions | undefined;
|
|
18
|
+
constructor(value: unknown, options?: UrlOptions | undefined);
|
|
19
|
+
get isValid(): boolean;
|
|
20
|
+
}
|
|
21
|
+
export declare const url: (url: unknown, options?: UrlOptions) => Url;
|
|
22
|
+
export declare const isUrl: (url?: unknown, options?: UrlOptions) => boolean;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import {
|
|
2
|
+
require_validator
|
|
3
|
+
} from "../chunk-ODLLVCBP.mjs";
|
|
4
|
+
import {
|
|
5
|
+
__toESM
|
|
6
|
+
} from "../chunk-RDITZTSA.mjs";
|
|
7
|
+
|
|
8
|
+
// src/values/Url.ts
|
|
9
|
+
var import_validator = __toESM(require_validator());
|
|
10
|
+
import { asString, isEmpty, Value } from "@thisisagile/easy";
|
|
11
|
+
var Url = class extends Value {
|
|
12
|
+
constructor(value, options) {
|
|
13
|
+
super(asString(value));
|
|
14
|
+
this.options = options;
|
|
15
|
+
}
|
|
16
|
+
get isValid() {
|
|
17
|
+
return isUrl(this.value, this.options);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
var url = (url2, options) => new Url(url2, options);
|
|
21
|
+
var isUrl = (url2, options) => {
|
|
22
|
+
return !isEmpty(url2) && (0, import_validator.isURL)(asString(url2), options);
|
|
23
|
+
};
|
|
24
|
+
export {
|
|
25
|
+
Url,
|
|
26
|
+
isUrl,
|
|
27
|
+
url
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=Url.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/values/Url.ts"],"sourcesContent":["import { isURL as validateUrl } from 'validator';\nimport { asString, isEmpty, Value } from '@thisisagile/easy';\n\nexport interface UrlOptions {\n /**\n * @default ['http','https','ftp']\n */\n protocols?: string[];\n /**\n * @default true\n */\n require_tld?: boolean;\n /**\n * @default false\n */\n require_protocol?: boolean;\n /**\n * @default true\n */\n require_host?: boolean;\n /**\n * if set as true isURL will check if port is present in the URL\n * @default false\n */\n require_port?: boolean;\n /**\n * @default true\n */\n require_valid_protocol?: boolean;\n /**\n * @default false\n */\n allow_underscores?: boolean;\n /**\n * @default false\n */\n host_whitelist?: Array<string | RegExp>;\n /**\n * @default false\n */\n host_blacklist?: Array<string | RegExp>;\n /**\n * @default false\n */\n allow_trailing_dot?: boolean;\n /**\n * @default false\n */\n allow_protocol_relative_urls?: boolean;\n /**\n * @default false\n */\n disallow_auth?: boolean;\n}\n\nexport class Url extends Value {\n constructor(\n value: unknown,\n readonly options?: UrlOptions\n ) {\n super(asString(value));\n }\n\n get isValid(): boolean {\n return isUrl(this.value, this.options);\n }\n}\n\nexport const url = (url: unknown, options?: UrlOptions): Url => new Url(url, options);\n\nexport const isUrl = (url?: unknown, options?: UrlOptions): boolean => {\n return !isEmpty(url) && validateUrl(asString(url), options);\n};\n"],"mappings":";;;;;;;;AAAA,uBAAqC;AACrC,SAAS,UAAU,SAAS,aAAa;AAsDlC,IAAM,MAAN,cAAkB,MAAM;AAAA,EAC7B,YACE,OACS,SACT;AACA,UAAM,SAAS,KAAK,CAAC;AAFZ;AAAA,EAGX;AAAA,EAEA,IAAI,UAAmB;AACrB,WAAO,MAAM,KAAK,OAAO,KAAK,OAAO;AAAA,EACvC;AACF;AAEO,IAAM,MAAM,CAACA,MAAc,YAA8B,IAAI,IAAIA,MAAK,OAAO;AAE7E,IAAM,QAAQ,CAACA,MAAe,YAAkC;AACrE,SAAO,CAAC,QAAQA,IAAG,SAAK,iBAAAC,OAAY,SAASD,IAAG,GAAG,OAAO;AAC5D;","names":["url","validateUrl"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@thisisagile/easy-domain",
|
|
3
|
+
"version": "15.29.3",
|
|
4
|
+
"description": "Common domain objects for easy microservices",
|
|
5
|
+
"author": "Sander Hoogendoorn",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"main": "dist/index.js",
|
|
8
|
+
"module": "dist/index.mjs",
|
|
9
|
+
"types": "dist/index.d.ts",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git@github.com:thisisagile/easy.git"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"typescript",
|
|
16
|
+
"microservices",
|
|
17
|
+
"domain-driven-design",
|
|
18
|
+
"evolutionary-architecture"
|
|
19
|
+
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"lint": "yarn g:eslint . --ext .js,.jsx,.ts,.tsx --fix",
|
|
22
|
+
"format": "yarn g:prettier --check --write src test *.json",
|
|
23
|
+
"build": "yarn g:tsc ",
|
|
24
|
+
"build:tsup": "yarn g:tsup --onSuccess \"yarn g:tsc --emitDeclarationOnly --declaration\"",
|
|
25
|
+
"test": "yarn g:jest --coverage",
|
|
26
|
+
"prepack": "yarn g:copy-readme"
|
|
27
|
+
},
|
|
28
|
+
"sideEffects": false,
|
|
29
|
+
"files": [
|
|
30
|
+
"dist",
|
|
31
|
+
"src"
|
|
32
|
+
],
|
|
33
|
+
"publishConfig": {
|
|
34
|
+
"access": "public"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@thisisagile/easy-test": "15.29.3",
|
|
38
|
+
"@types/validator": "^13.11.9",
|
|
39
|
+
"validator": "^13.11.0"
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@thisisagile/easy": "15.29.3"
|
|
43
|
+
}
|
|
44
|
+
}
|