@bessemer/cornerstone 0.5.86 → 0.5.88
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/aspect-ratio.d.ts +7 -4
- package/dist/aspect-ratio.d.ts.map +1 -1
- package/dist/aspect-ratio.js +16 -7
- package/dist/aspect-ratio.js.map +1 -1
- package/dist/async.d.ts +1 -1
- package/dist/async.d.ts.map +1 -1
- package/dist/async.js +1 -1
- package/dist/async.js.map +1 -1
- package/dist/cache.d.ts +7 -6
- package/dist/cache.d.ts.map +1 -1
- package/dist/cache.js +12 -12
- package/dist/cache.js.map +1 -1
- package/dist/comparator.js +1 -1
- package/dist/comparator.js.map +1 -1
- package/dist/content.d.ts +5 -5
- package/dist/content.d.ts.map +1 -1
- package/dist/content.js.map +1 -1
- package/dist/data-size.d.ts +2 -2
- package/dist/data-size.d.ts.map +1 -1
- package/dist/data-size.js.map +1 -1
- package/dist/{error-event.d.ts → error/error-event.d.ts} +42 -23
- package/dist/error/error-event.d.ts.map +1 -0
- package/dist/{error-event.js → error/error-event.js} +82 -60
- package/dist/error/error-event.js.map +1 -0
- package/dist/error/error-type.d.ts +11 -0
- package/dist/error/error-type.d.ts.map +1 -0
- package/dist/error/error-type.js +20 -0
- package/dist/error/error-type.js.map +1 -0
- package/dist/error/error.d.ts.map +1 -0
- package/dist/{error.js → error/error.js} +1 -1
- package/dist/error/error.js.map +1 -0
- package/dist/expression.d.ts +2 -2
- package/dist/expression.d.ts.map +1 -1
- package/dist/expression.js.map +1 -1
- package/dist/glob.d.ts +7 -3
- package/dist/glob.d.ts.map +1 -1
- package/dist/glob.js +23 -15
- package/dist/glob.js.map +1 -1
- package/dist/hash.d.ts +2 -2
- package/dist/hash.d.ts.map +1 -1
- package/dist/hash.js.map +1 -1
- package/dist/hex-code.d.ts +7 -4
- package/dist/hex-code.d.ts.map +1 -1
- package/dist/hex-code.js +19 -5
- package/dist/hex-code.js.map +1 -1
- package/dist/index.d.ts +12 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -4
- package/dist/index.js.map +1 -1
- package/dist/intl/country-code.d.ts +7 -4
- package/dist/intl/country-code.d.ts.map +1 -1
- package/dist/intl/country-code.js +52 -43
- package/dist/intl/country-code.js.map +1 -1
- package/dist/intl/country-subdivision-code.d.ts +7 -4
- package/dist/intl/country-subdivision-code.d.ts.map +1 -1
- package/dist/intl/country-subdivision-code.js +16 -5
- package/dist/intl/country-subdivision-code.js.map +1 -1
- package/dist/intl/currency-code.d.ts +7 -4
- package/dist/intl/currency-code.d.ts.map +1 -1
- package/dist/intl/currency-code.js +20 -11
- package/dist/intl/currency-code.js.map +1 -1
- package/dist/intl/language-code.d.ts +7 -4
- package/dist/intl/language-code.d.ts.map +1 -1
- package/dist/intl/language-code.js +39 -30
- package/dist/intl/language-code.js.map +1 -1
- package/dist/intl/locale.d.ts +8 -5
- package/dist/intl/locale.d.ts.map +1 -1
- package/dist/intl/locale.js +37 -30
- package/dist/intl/locale.js.map +1 -1
- package/dist/math.d.ts +2 -0
- package/dist/math.d.ts.map +1 -1
- package/dist/math.js +12 -1
- package/dist/math.js.map +1 -1
- package/dist/mime-type.d.ts +7 -4
- package/dist/mime-type.d.ts.map +1 -1
- package/dist/mime-type.js +44 -35
- package/dist/mime-type.js.map +1 -1
- package/dist/monetary-amount.d.ts +3 -3
- package/dist/monetary-amount.d.ts.map +1 -1
- package/dist/monetary-amount.js +4 -4
- package/dist/monetary-amount.js.map +1 -1
- package/dist/object/object-path.d.ts +2 -2
- package/dist/object/object-path.d.ts.map +1 -1
- package/dist/object/object-path.js.map +1 -1
- package/dist/object/type-path.d.ts +2 -2
- package/dist/object/type-path.d.ts.map +1 -1
- package/dist/object/type-path.js.map +1 -1
- package/dist/object.d.ts +2 -2
- package/dist/object.d.ts.map +1 -1
- package/dist/object.js +3 -2
- package/dist/object.js.map +1 -1
- package/dist/range.d.ts +2 -2
- package/dist/range.d.ts.map +1 -1
- package/dist/range.js.map +1 -1
- package/dist/reference.d.ts +2 -2
- package/dist/reference.d.ts.map +1 -1
- package/dist/reference.js.map +1 -1
- package/dist/resource-key.d.ts +17 -8
- package/dist/resource-key.d.ts.map +1 -1
- package/dist/resource-key.js +42 -13
- package/dist/resource-key.js.map +1 -1
- package/dist/result.d.ts +6 -5
- package/dist/result.d.ts.map +1 -1
- package/dist/result.js +4 -4
- package/dist/result.js.map +1 -1
- package/dist/retry.d.ts +1 -1
- package/dist/retry.d.ts.map +1 -1
- package/dist/retry.js +1 -1
- package/dist/retry.js.map +1 -1
- package/dist/rich-text.d.ts +2 -2
- package/dist/rich-text.d.ts.map +1 -1
- package/dist/rich-text.js.map +1 -1
- package/dist/signature.d.ts.map +1 -1
- package/dist/signature.js +5 -1
- package/dist/signature.js.map +1 -1
- package/dist/sql.d.ts +2 -2
- package/dist/sql.d.ts.map +1 -1
- package/dist/sql.js.map +1 -1
- package/dist/tag.d.ts +3 -3
- package/dist/tag.d.ts.map +1 -1
- package/dist/tag.js.map +1 -1
- package/dist/temporal/chrono.d.ts +34 -0
- package/dist/temporal/chrono.d.ts.map +1 -0
- package/dist/temporal/chrono.js +34 -0
- package/dist/temporal/chrono.js.map +1 -0
- package/dist/temporal/clock.d.ts +21 -0
- package/dist/temporal/clock.d.ts.map +1 -0
- package/dist/temporal/clock.js +76 -0
- package/dist/temporal/clock.js.map +1 -0
- package/dist/temporal/date.d.ts +2 -0
- package/dist/temporal/date.d.ts.map +1 -0
- package/dist/temporal/date.js +8 -0
- package/dist/temporal/date.js.map +1 -0
- package/dist/temporal/duration.d.ts +54 -0
- package/dist/temporal/duration.d.ts.map +1 -0
- package/dist/temporal/duration.js +162 -0
- package/dist/temporal/duration.js.map +1 -0
- package/dist/temporal/instant.d.ts +35 -0
- package/dist/temporal/instant.d.ts.map +1 -0
- package/dist/temporal/instant.js +91 -0
- package/dist/temporal/instant.js.map +1 -0
- package/dist/temporal/plain-time.d.ts +49 -0
- package/dist/temporal/plain-time.d.ts.map +1 -0
- package/dist/temporal/plain-time.js +110 -0
- package/dist/temporal/plain-time.js.map +1 -0
- package/dist/temporal/time-zone-id.d.ts +12 -0
- package/dist/temporal/time-zone-id.d.ts.map +1 -0
- package/dist/temporal/time-zone-id.js +35 -0
- package/dist/temporal/time-zone-id.js.map +1 -0
- package/dist/temporal/time-zone-offset.d.ts +22 -0
- package/dist/temporal/time-zone-offset.d.ts.map +1 -0
- package/dist/temporal/time-zone-offset.js +145 -0
- package/dist/temporal/time-zone-offset.js.map +1 -0
- package/dist/types.d.ts +12 -12
- package/dist/types.d.ts.map +1 -1
- package/dist/ulid.d.ts +7 -4
- package/dist/ulid.d.ts.map +1 -1
- package/dist/ulid.js +14 -5
- package/dist/ulid.js.map +1 -1
- package/dist/unit.d.ts +2 -2
- package/dist/unit.d.ts.map +1 -1
- package/dist/unit.js.map +1 -1
- package/dist/uri.d.ts +2 -2
- package/dist/uri.d.ts.map +1 -1
- package/dist/uri.js.map +1 -1
- package/dist/uuid.d.ts +7 -4
- package/dist/uuid.d.ts.map +1 -1
- package/dist/uuid.js +14 -5
- package/dist/uuid.js.map +1 -1
- package/dist/zod-util.d.ts +5 -0
- package/dist/zod-util.d.ts.map +1 -1
- package/dist/zod-util.js +28 -2
- package/dist/zod-util.js.map +1 -1
- package/package.json +2 -2
- package/dist/date.d.ts +0 -13
- package/dist/date.d.ts.map +0 -1
- package/dist/date.js +0 -40
- package/dist/date.js.map +0 -1
- package/dist/duration.d.ts +0 -18
- package/dist/duration.d.ts.map +0 -1
- package/dist/duration.js +0 -53
- package/dist/duration.js.map +0 -1
- package/dist/error-event.d.ts.map +0 -1
- package/dist/error-event.js.map +0 -1
- package/dist/error.d.ts.map +0 -1
- package/dist/error.js.map +0 -1
- /package/dist/{error.d.ts → error/error.d.ts} +0 -0
package/dist/date.js
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
// src/date.ts
|
2
|
-
import { addHours as _addHours, addMilliseconds as _addMilliseconds, isAfter as _isAfter, isBefore as _isBefore, parseISO } from "date-fns";
|
3
|
-
import { toMilliseconds } from "@bessemer/cornerstone/duration";
|
4
|
-
import Zod from "zod";
|
5
|
-
var Schema = Zod.union([
|
6
|
-
Zod.string().trim().regex(/^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})?)?$/, `Invalid Date. Use YYYY-MM-DD or YYYY-MM-DDTHH:MM:SS.sssZ`),
|
7
|
-
Zod.date()
|
8
|
-
]).transform((isoString) => {
|
9
|
-
const date = new Date(isoString);
|
10
|
-
if (isNaN(date.getTime())) {
|
11
|
-
throw new Error("Invalid date");
|
12
|
-
}
|
13
|
-
return date;
|
14
|
-
});
|
15
|
-
var isDate = (value) => {
|
16
|
-
return value instanceof Date && !isNaN(value.getTime());
|
17
|
-
};
|
18
|
-
var now = () => {
|
19
|
-
return /* @__PURE__ */ new Date();
|
20
|
-
};
|
21
|
-
var of = (dateString) => {
|
22
|
-
return parseISO(dateString);
|
23
|
-
};
|
24
|
-
var addMilliseconds = _addMilliseconds;
|
25
|
-
var addHours = _addHours;
|
26
|
-
var isBefore = _isBefore;
|
27
|
-
var isAfter = _isAfter;
|
28
|
-
var addDuration = (date, duration) => addMilliseconds(date, toMilliseconds(duration));
|
29
|
-
export {
|
30
|
-
Schema,
|
31
|
-
addDuration,
|
32
|
-
addHours,
|
33
|
-
addMilliseconds,
|
34
|
-
isAfter,
|
35
|
-
isBefore,
|
36
|
-
isDate,
|
37
|
-
now,
|
38
|
-
of
|
39
|
-
};
|
40
|
-
//# sourceMappingURL=date.js.map
|
package/dist/date.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../src/date.ts"],"sourcesContent":["import { addHours as _addHours, addMilliseconds as _addMilliseconds, isAfter as _isAfter, isBefore as _isBefore, parseISO } from 'date-fns'\nimport { Duration, toMilliseconds } from '@bessemer/cornerstone/duration'\nimport Zod from 'zod'\n\nexport const Schema = Zod.union([\n Zod.string()\n .trim()\n .regex(/^\\d{4}-\\d{2}-\\d{2}(T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(Z|[+-]\\d{2}:\\d{2})?)?$/, `Invalid Date. Use YYYY-MM-DD or YYYY-MM-DDTHH:MM:SS.sssZ`),\n Zod.date(),\n]).transform((isoString) => {\n const date = new Date(isoString)\n // Additional check to ensure the parsed date is valid\n if (isNaN(date.getTime())) {\n throw new Error('Invalid date')\n }\n return date\n})\n\nexport const isDate = (value: unknown): value is Date => {\n return value instanceof Date && !isNaN(value.getTime())\n}\n\nexport const now = (): Date => {\n return new Date()\n}\n\nexport const of = (dateString: string): Date => {\n return parseISO(dateString)\n}\n\nexport const addMilliseconds = _addMilliseconds\nexport const addHours = _addHours\nexport const isBefore = _isBefore\nexport const isAfter = _isAfter\nexport const addDuration = (date: Date, duration: Duration): Date => addMilliseconds(date, toMilliseconds(duration))\n"],"mappings":";AAAA,SAAS,YAAY,WAAW,mBAAmB,kBAAkB,WAAW,UAAU,YAAY,WAAW,gBAAgB;AACjI,SAAmB,sBAAsB;AACzC,OAAO,SAAS;AAET,IAAM,SAAS,IAAI,MAAM;AAAA,EAC9B,IAAI,OAAO,EACR,KAAK,EACL,MAAM,wEAAwE,0DAA0D;AAAA,EAC3I,IAAI,KAAK;AACX,CAAC,EAAE,UAAU,CAAC,cAAc;AAC1B,QAAM,OAAO,IAAI,KAAK,SAAS;AAE/B,MAAI,MAAM,KAAK,QAAQ,CAAC,GAAG;AACzB,UAAM,IAAI,MAAM,cAAc;AAAA,EAChC;AACA,SAAO;AACT,CAAC;AAEM,IAAM,SAAS,CAAC,UAAkC;AACvD,SAAO,iBAAiB,QAAQ,CAAC,MAAM,MAAM,QAAQ,CAAC;AACxD;AAEO,IAAM,MAAM,MAAY;AAC7B,SAAO,oBAAI,KAAK;AAClB;AAEO,IAAM,KAAK,CAAC,eAA6B;AAC9C,SAAO,SAAS,UAAU;AAC5B;AAEO,IAAM,kBAAkB;AACxB,IAAM,WAAW;AACjB,IAAM,WAAW;AACjB,IAAM,UAAU;AAChB,IAAM,cAAc,CAAC,MAAY,aAA6B,gBAAgB,MAAM,eAAe,QAAQ,CAAC;","names":[]}
|
package/dist/duration.d.ts
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
import { TaggedType } from '@bessemer/cornerstone/types';
|
2
|
-
import Zod from 'zod';
|
3
|
-
export type Duration = TaggedType<number, 'Duration'>;
|
4
|
-
export declare const fromMilliseconds: (value: number) => Duration;
|
5
|
-
export declare const Schema: Zod.ZodPipe<Zod.ZodNumber, Zod.ZodTransform<Duration, number>>;
|
6
|
-
export declare const toMilliseconds: (duration: Duration) => number;
|
7
|
-
export declare const fromSeconds: (value: number) => Duration;
|
8
|
-
export declare const toSeconds: (duration: Duration) => number;
|
9
|
-
export declare const fromMinutes: (value: number) => Duration;
|
10
|
-
export declare const toMinutes: (duration: Duration) => number;
|
11
|
-
export declare const fromHours: (value: number) => Duration;
|
12
|
-
export declare const toHours: (duration: Duration) => number;
|
13
|
-
export declare const fromDays: (value: number) => Duration;
|
14
|
-
export declare const toDays: (duration: Duration) => number;
|
15
|
-
export declare const Zero: Duration;
|
16
|
-
export declare const OneDay: Duration;
|
17
|
-
export declare const OneHour: Duration;
|
18
|
-
//# sourceMappingURL=duration.d.ts.map
|
package/dist/duration.d.ts.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"duration.d.ts","sourceRoot":"","sources":["../src/duration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AACxD,OAAO,GAAG,MAAM,KAAK,CAAA;AAErB,MAAM,MAAM,QAAQ,GAAG,UAAU,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;AAErD,eAAO,MAAM,gBAAgB,GAAI,OAAO,MAAM,KAAG,QAEhD,CAAA;AAED,eAAO,MAAM,MAAM,gEAA2C,CAAA;AAE9D,eAAO,MAAM,cAAc,GAAI,UAAU,QAAQ,KAAG,MAEnD,CAAA;AAED,eAAO,MAAM,WAAW,GAAI,OAAO,MAAM,KAAG,QAE3C,CAAA;AAED,eAAO,MAAM,SAAS,GAAI,UAAU,QAAQ,KAAG,MAE9C,CAAA;AAED,eAAO,MAAM,WAAW,GAAI,OAAO,MAAM,KAAG,QAE3C,CAAA;AAED,eAAO,MAAM,SAAS,GAAI,UAAU,QAAQ,KAAG,MAE9C,CAAA;AAED,eAAO,MAAM,SAAS,GAAI,OAAO,MAAM,KAAG,QAEzC,CAAA;AAED,eAAO,MAAM,OAAO,GAAI,UAAU,QAAQ,KAAG,MAE5C,CAAA;AAED,eAAO,MAAM,QAAQ,GAAI,OAAO,MAAM,KAAG,QAExC,CAAA;AAED,eAAO,MAAM,MAAM,GAAI,UAAU,QAAQ,KAAG,MAE3C,CAAA;AAED,eAAO,MAAM,IAAI,UAAsB,CAAA;AACvC,eAAO,MAAM,MAAM,UAAc,CAAA;AACjC,eAAO,MAAM,OAAO,UAAe,CAAA"}
|
package/dist/duration.js
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
// src/duration.ts
|
2
|
-
import Zod from "zod";
|
3
|
-
var fromMilliseconds = (value) => {
|
4
|
-
return value;
|
5
|
-
};
|
6
|
-
var Schema = Zod.number().transform(fromMilliseconds);
|
7
|
-
var toMilliseconds = (duration) => {
|
8
|
-
return duration;
|
9
|
-
};
|
10
|
-
var fromSeconds = (value) => {
|
11
|
-
return fromMilliseconds(value * 1e3);
|
12
|
-
};
|
13
|
-
var toSeconds = (duration) => {
|
14
|
-
return toMilliseconds(duration) / 1e3;
|
15
|
-
};
|
16
|
-
var fromMinutes = (value) => {
|
17
|
-
return fromSeconds(value * 60);
|
18
|
-
};
|
19
|
-
var toMinutes = (duration) => {
|
20
|
-
return toSeconds(duration) / 60;
|
21
|
-
};
|
22
|
-
var fromHours = (value) => {
|
23
|
-
return fromMinutes(value * 60);
|
24
|
-
};
|
25
|
-
var toHours = (duration) => {
|
26
|
-
return toMinutes(duration) / 60;
|
27
|
-
};
|
28
|
-
var fromDays = (value) => {
|
29
|
-
return fromHours(value * 24);
|
30
|
-
};
|
31
|
-
var toDays = (duration) => {
|
32
|
-
return toHours(duration) / 24;
|
33
|
-
};
|
34
|
-
var Zero = fromMilliseconds(0);
|
35
|
-
var OneDay = fromDays(1);
|
36
|
-
var OneHour = fromHours(1);
|
37
|
-
export {
|
38
|
-
OneDay,
|
39
|
-
OneHour,
|
40
|
-
Schema,
|
41
|
-
Zero,
|
42
|
-
fromDays,
|
43
|
-
fromHours,
|
44
|
-
fromMilliseconds,
|
45
|
-
fromMinutes,
|
46
|
-
fromSeconds,
|
47
|
-
toDays,
|
48
|
-
toHours,
|
49
|
-
toMilliseconds,
|
50
|
-
toMinutes,
|
51
|
-
toSeconds
|
52
|
-
};
|
53
|
-
//# sourceMappingURL=duration.js.map
|
package/dist/duration.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../src/duration.ts"],"sourcesContent":["import { TaggedType } from '@bessemer/cornerstone/types'\nimport Zod from 'zod'\n\nexport type Duration = TaggedType<number, 'Duration'>\n\nexport const fromMilliseconds = (value: number): Duration => {\n return value as Duration\n}\n\nexport const Schema = Zod.number().transform(fromMilliseconds)\n\nexport const toMilliseconds = (duration: Duration): number => {\n return duration\n}\n\nexport const fromSeconds = (value: number): Duration => {\n return fromMilliseconds(value * 1000)\n}\n\nexport const toSeconds = (duration: Duration): number => {\n return toMilliseconds(duration) / 1000\n}\n\nexport const fromMinutes = (value: number): Duration => {\n return fromSeconds(value * 60)\n}\n\nexport const toMinutes = (duration: Duration): number => {\n return toSeconds(duration) / 60\n}\n\nexport const fromHours = (value: number): Duration => {\n return fromMinutes(value * 60)\n}\n\nexport const toHours = (duration: Duration): number => {\n return toMinutes(duration) / 60\n}\n\nexport const fromDays = (value: number): Duration => {\n return fromHours(value * 24)\n}\n\nexport const toDays = (duration: Duration): number => {\n return toHours(duration) / 24\n}\n\nexport const Zero = fromMilliseconds(0)\nexport const OneDay = fromDays(1)\nexport const OneHour = fromHours(1)\n"],"mappings":";AACA,OAAO,SAAS;AAIT,IAAM,mBAAmB,CAAC,UAA4B;AAC3D,SAAO;AACT;AAEO,IAAM,SAAS,IAAI,OAAO,EAAE,UAAU,gBAAgB;AAEtD,IAAM,iBAAiB,CAAC,aAA+B;AAC5D,SAAO;AACT;AAEO,IAAM,cAAc,CAAC,UAA4B;AACtD,SAAO,iBAAiB,QAAQ,GAAI;AACtC;AAEO,IAAM,YAAY,CAAC,aAA+B;AACvD,SAAO,eAAe,QAAQ,IAAI;AACpC;AAEO,IAAM,cAAc,CAAC,UAA4B;AACtD,SAAO,YAAY,QAAQ,EAAE;AAC/B;AAEO,IAAM,YAAY,CAAC,aAA+B;AACvD,SAAO,UAAU,QAAQ,IAAI;AAC/B;AAEO,IAAM,YAAY,CAAC,UAA4B;AACpD,SAAO,YAAY,QAAQ,EAAE;AAC/B;AAEO,IAAM,UAAU,CAAC,aAA+B;AACrD,SAAO,UAAU,QAAQ,IAAI;AAC/B;AAEO,IAAM,WAAW,CAAC,UAA4B;AACnD,SAAO,UAAU,QAAQ,EAAE;AAC7B;AAEO,IAAM,SAAS,CAAC,aAA+B;AACpD,SAAO,QAAQ,QAAQ,IAAI;AAC7B;AAEO,IAAM,OAAO,iBAAiB,CAAC;AAC/B,IAAM,SAAS,SAAS,CAAC;AACzB,IAAM,UAAU,UAAU,CAAC;","names":[]}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"error-event.d.ts","sourceRoot":"","sources":["../src/error-event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAA;AAChF,OAAO,EAAyC,eAAe,EAAE,MAAM,8BAA8B,CAAA;AACrG,OAAO,GAAG,EAAE,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AAClC,OAAO,EAAY,SAAS,EAAE,MAAM,4BAA4B,CAAA;AAUhE,MAAM,MAAM,SAAS,GAAG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AUrD,CAAA;AAEH,eAAO,MAAM,SAAS,GAAI,UAAU,iBAAiB,eAUlD,CAAA;AAEH,eAAO,MAAM,UAAU,GAAI,UAAU,iBAAiB,eAUnD,CAAA;AAEH,wBAAgB,aAAa,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,GAAE,SAAS,CAAC,iBAAiB,GAAG,SAAS,CAAmB,GAAG,OAAO,CAAC,KAAK,IAAI,WAAW,CAAC,CAAC,CAAC,CAI/I;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,GAAE,SAAS,CAAC,iBAAiB,GAAG,SAAS,CAAmB,GAAG,OAAO,CAAC,KAAK,IAAI,IAAI,CAI3I;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,GAAE,SAAS,CAAC,iBAAiB,GAAG,SAAS,CAAmB,GAAG,OAAO,CAAC,KAAK,IAAI,IAAI,CAI1I;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,GAAE,SAAS,CAAC,iBAAiB,GAAG,SAAS,CAAmB,GAAG,OAAO,CAAC,KAAK,IAAI,IAAI,CAItI;AAED,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,CAAC,iBAAiB,CAAC,GAAG,OAAO,CAAC,KAAK,IAAI,IAAI,CAInG"}
|
package/dist/error-event.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../src/error-event.ts"],"sourcesContent":["import { Dictionary, NominalType, Throwable } from '@bessemer/cornerstone/types'\nimport { deepMerge, isNil, isObject, isPresent, RecordAttribute } from '@bessemer/cornerstone/object'\nimport Zod, { ZodType } from 'zod'\nimport { evaluate, LazyValue } from '@bessemer/cornerstone/lazy'\nimport { findInCausalChain as errorsFindInCausalChain, isError } from '@bessemer/cornerstone/error'\nimport { isPromise } from '@bessemer/cornerstone/promise'\nimport { first } from '@bessemer/cornerstone/array'\n\n/*\n Represents a structured error event. The code can be mapped to a unique type of error while the\n message and attributes can provide contextual information about the error. Finally,\n an ErrorEvent could have multiple causes which get aggregated into a single parent error.\n */\nexport type ErrorCode = NominalType<string, 'ErrorCode'>\nexport const ErrorCodeSchema: ZodType<ErrorCode> = Zod.string()\n\nexport type ErrorAttribute<Type = unknown> = RecordAttribute<Type, 'ErrorAttribute'>\nexport const ErrorAttributeSchema: ZodType<ErrorAttribute, string> = Zod.string()\n\nconst baseErrorEventSchema = Zod.object({\n code: ErrorCodeSchema,\n message: Zod.string(),\n attributes: Zod.record(ErrorAttributeSchema, Zod.unknown()),\n})\n\nexport type ErrorEvent = Zod.infer<typeof baseErrorEventSchema> & {\n causes: Array<ErrorEvent>\n}\n\nconst ErrorEventSchema: ZodType<ErrorEvent> = baseErrorEventSchema.extend({\n causes: Zod.lazy(() => Zod.array(ErrorEventSchema)),\n})\n\n// Builder object that allows for 'partial' representation of ErrorEvents\nexport type ErrorEventBuilder = {\n code: ErrorCode\n message?: string | null\n attributes?: Record<ErrorAttribute, unknown>\n causes?: Array<ErrorEvent>\n}\n\nexport type ErrorEventAugment = Partial<ErrorEventBuilder>\n\n// An exception type that contains an ErrorEvent\nexport class ErrorEventException extends Error {\n readonly errorEvent: ErrorEvent\n\n constructor(errorEvent: ErrorEvent, cause?: unknown) {\n super(errorEvent.message ?? '', { cause })\n this.name = this.constructor.name\n this.errorEvent = errorEvent\n }\n}\n\nexport const isErrorEvent = (throwable: Throwable): throwable is ErrorEvent => {\n if (!isObject(throwable)) {\n return false\n }\n\n return 'code' in throwable && 'message' in throwable && 'attributes' in throwable && 'causes' in throwable\n}\n\nexport const isErrorEventException = (throwable: Throwable): throwable is ErrorEventException => {\n return throwable instanceof ErrorEventException\n}\n\nexport const of = (builder: ErrorEventBuilder): ErrorEvent => {\n const code = builder.code\n\n return {\n code,\n message: builder.message ?? code,\n attributes: builder.attributes ?? {},\n causes: builder.causes ?? [],\n }\n}\n\nexport const from = (throwable: Throwable): ErrorEvent => {\n if (isErrorEvent(throwable)) {\n return throwable\n }\n\n if (!isError(throwable)) {\n return unhandled()\n }\n\n const errorEventException = errorsFindInCausalChain(throwable, isErrorEventException) as ErrorEventException | undefined\n if (isNil(errorEventException)) {\n return unhandled()\n }\n\n return errorEventException.errorEvent\n}\n\nexport function withPropagation<ReturnType>(runnable: () => ReturnType, attributes: LazyValue<Dictionary<unknown>>): ReturnType\nexport function withPropagation<ReturnType>(runnable: () => Promise<ReturnType>, attributes: LazyValue<Dictionary<unknown>>): Promise<ReturnType>\nexport function withPropagation<ReturnType>(\n runnable: () => ReturnType | Promise<ReturnType>,\n attributes: LazyValue<Dictionary<unknown>>\n): ReturnType | Promise<ReturnType> {\n try {\n let result = runnable()\n if (isPromise(result)) {\n return result.then((it) => it).catch((it) => propagate(it, evaluate(attributes)))\n } else {\n return result\n }\n } catch (throwable: Throwable) {\n throw propagate(throwable, evaluate(attributes))\n }\n}\n\nexport const propagate = (throwable: Throwable, attributes: Dictionary<unknown>): never => {\n if (isErrorEventException(throwable)) {\n // We just mutate the existing error event to avoid nested exceptions\n const errorEvent = throwable.errorEvent\n errorEvent.attributes = { ...errorEvent.attributes, ...attributes }\n throw throwable\n } else {\n const errorEvent = from(throwable)\n const contextualizedEvent = of({ ...errorEvent, attributes: { ...errorEvent.attributes, ...attributes } })\n throw new ErrorEventException(contextualizedEvent, throwable)\n }\n}\n\nexport const findByCodeInCausalChain = (error: ErrorEvent, code: string): ErrorEvent | undefined => {\n return findInCausalChain(error, (it) => it.code === code)\n}\n\n/*\n Traverses the causal chain of the ErrorEvent, searching for a predicate that matches (including matching on the parent error event)\n This is useful if you want to find whether or not a given error was caused by a specific failure. The search executes depth-first and\n will return te first matching instance that satisfies the predicate, or undefined otherwise\n */\nexport const findInCausalChain = (error: ErrorEvent, predicate: (error: ErrorEvent) => boolean): ErrorEvent | undefined => {\n if (predicate(error)) {\n return error\n }\n\n return first(error.causes.map((it) => findInCausalChain(it, predicate)).filter(isPresent))\n}\n\nexport const aggregate = (builder: ErrorEventBuilder, causes: Array<ErrorEvent>): ErrorEvent | undefined => {\n if (causes.length === 0) {\n return undefined\n }\n\n return of({ ...builder, causes })\n}\n\nexport const UnhandledErrorCode: ErrorCode = 'error-event.unhandled'\nexport const NotFoundErrorCode: ErrorCode = 'error-event.not-found'\nexport const ForbiddenErrorCode: ErrorCode = 'error-event.forbidden'\nexport const UnauthorizedErrorCode: ErrorCode = 'error-event.unauthorized'\nexport const BadRequestErrorCode: ErrorCode = 'error-event.bad-request'\n\nexport const RequestCorrelationIdAttribute: ErrorAttribute<string> = 'requestCorrelationId'\nexport const HttpStatusCodeAttribute: ErrorAttribute<number> = 'httpStatusCode'\n\nexport const unhandled = (builder?: ErrorEventAugment) =>\n of(\n deepMerge(\n {\n code: UnhandledErrorCode,\n message: 'An Unhandled Error has occurred.',\n attributes: { [HttpStatusCodeAttribute]: 500 },\n },\n builder\n )\n )\n\nexport const notFound = (builder?: ErrorEventAugment) =>\n of(\n deepMerge(\n {\n code: NotFoundErrorCode,\n message: 'The requested Resource could not be found.',\n attributes: { [HttpStatusCodeAttribute]: 404 },\n },\n builder\n )\n )\n\nexport const unauthorized = (builder?: ErrorEventAugment) =>\n of(\n deepMerge(\n {\n code: UnauthorizedErrorCode,\n message: 'The requested Resource requires authentication.',\n attributes: { [HttpStatusCodeAttribute]: 401 },\n },\n builder\n )\n )\n\nexport const forbidden = (builder?: ErrorEventAugment) =>\n of(\n deepMerge(\n {\n code: ForbiddenErrorCode,\n message: 'The requested Resource requires additional permissions to access.',\n attributes: { [HttpStatusCodeAttribute]: 403 },\n },\n builder\n )\n )\n\nexport const badRequest = (builder?: ErrorEventAugment) =>\n of(\n deepMerge(\n {\n code: BadRequestErrorCode,\n message: 'The request is invalid and cannot be processed.',\n attributes: { [HttpStatusCodeAttribute]: 400 },\n },\n builder\n )\n )\n\nexport function assertPresent<T>(value: T, builder: LazyValue<ErrorEventAugment | undefined> = () => undefined): asserts value is NonNullable<T> {\n if (isNil(value)) {\n throw new ErrorEventException(notFound(evaluate(builder)))\n }\n}\n\nexport function assertAuthorized(value: boolean, builder: LazyValue<ErrorEventAugment | undefined> = () => undefined): asserts value is true {\n if (!value) {\n throw new ErrorEventException(unauthorized(evaluate(builder)))\n }\n}\n\nexport function assertPermitted(value: boolean, builder: LazyValue<ErrorEventAugment | undefined> = () => undefined): asserts value is true {\n if (!value) {\n throw new ErrorEventException(forbidden(evaluate(builder)))\n }\n}\n\nexport function assertValid(value: boolean, builder: LazyValue<ErrorEventAugment | undefined> = () => undefined): asserts value is true {\n if (!value) {\n throw new ErrorEventException(badRequest(evaluate(builder)))\n }\n}\n\nexport function assert(value: boolean, builder: LazyValue<ErrorEventBuilder>): asserts value is true {\n if (!value) {\n throw new ErrorEventException(of(evaluate(builder)))\n }\n}\n"],"mappings":";AACA,SAAS,WAAW,OAAO,UAAU,iBAAkC;AACvE,OAAO,SAAsB;AAC7B,SAAS,gBAA2B;AACpC,SAAS,qBAAqB,yBAAyB,eAAe;AACtE,SAAS,iBAAiB;AAC1B,SAAS,aAAa;AAQf,IAAM,kBAAsC,IAAI,OAAO;AAGvD,IAAM,uBAAwD,IAAI,OAAO;AAEhF,IAAM,uBAAuB,IAAI,OAAO;AAAA,EACtC,MAAM;AAAA,EACN,SAAS,IAAI,OAAO;AAAA,EACpB,YAAY,IAAI,OAAO,sBAAsB,IAAI,QAAQ,CAAC;AAC5D,CAAC;AAMD,IAAM,mBAAwC,qBAAqB,OAAO;AAAA,EACxE,QAAQ,IAAI,KAAK,MAAM,IAAI,MAAM,gBAAgB,CAAC;AACpD,CAAC;AAaM,IAAM,sBAAN,cAAkC,MAAM;AAAA,EACpC;AAAA,EAET,YAAY,YAAwB,OAAiB;AACnD,UAAM,WAAW,WAAW,IAAI,EAAE,MAAM,CAAC;AACzC,SAAK,OAAO,KAAK,YAAY;AAC7B,SAAK,aAAa;AAAA,EACpB;AACF;AAEO,IAAM,eAAe,CAAC,cAAkD;AAC7E,MA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AA,EACF;AACF;AAEK,IAAM,YAAY,CAAC,YACxB;AAAA,EACE;AAAA,IACE;AAAA,MACE,MAAM;AAAA,MACN,SAAS;AAAA,MACT,YAAY,EAAE,CAAC,uBAAuB,GAAG,IAAI;AAAA,IAC/C;AAAA,IACA;AAAA,EACF;AACF;AAEK,IAAM,aAAa,CAAC,YACzB;AAAA,EACE;AAAA,IACE;AAAA,MACE,MAAM;AAAA,MACN,SAAS;AAAA,MACT,YAAY,EAAE,CAAC,uBAAuB,GAAG,IAAI;AAAA,IAC/C;AAAA,IACA;AAAA,EACF;AACF;AAEK,SAAS,cAAiB,OAAU,UAAoD,MAAM,QAA4C;AAC/I,MAAI,MAAM,KAAK,GAAG;AAChB,UAAM,IAAI,oBAAoB,SAAS,SAAS,OAAO,CAAC,CAAC;AAAA,EAC3D;AACF;AAEO,SAAS,iBAAiB,OAAgB,UAAoD,MAAM,QAAkC;AAC3I,MAAI,CAAC,OAAO;AACV,UAAM,IAAI,oBAAoB,aAAa,SAAS,OAAO,CAAC,CAAC;AAAA,EAC/D;AACF;AAEO,SAAS,gBAAgB,OAAgB,UAAoD,MAAM,QAAkC;AAC1I,MAAI,CAAC,OAAO;AACV,UAAM,IAAI,oBAAoB,UAAU,SAAS,OAAO,CAAC,CAAC;AAAA,EAC5D;AACF;AAEO,SAAS,YAAY,OAAgB,UAAoD,MAAM,QAAkC;AACtI,MAAI,CAAC,OAAO;AACV,UAAM,IAAI,oBAAoB,WAAW,SAAS,OAAO,CAAC,CAAC;AAAA,EAC7D;AACF;AAEO,SAAS,OAAO,OAAgB,SAA8D;AACnG,MAAI,CAAC,OAAO;AACV,UAAM,IAAI,oBAAoB,GAAG,SAAS,OAAO,CAAC,CAAC;AAAA,EACrD;AACF;","names":[]}
|
package/dist/error.d.ts.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,OAAO,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,KAEjD,CAAA;AAED,eAAO,MAAM,cAAc,GAAI,OAAO,KAAK,KAAG,KAAK,CAAC,KAAK,CAexD,CAAA;AAED,eAAO,MAAM,iBAAiB,GAAI,OAAO,KAAK,EAAE,WAAW,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,KAAG,KAAK,GAAG,SAE9F,CAAA"}
|
package/dist/error.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../src/error.ts"],"sourcesContent":["import { isPresent } from '@bessemer/cornerstone/object'\nimport { Throwable } from '@bessemer/cornerstone/types'\n\nexport const isError = (value: unknown): value is Error => {\n return value instanceof Error\n}\n\nexport const getCausalChain = (error: Error): Array<Error> => {\n const chain: Array<Error> = []\n let current: Error = error\n\n while (true) {\n chain.push(current)\n\n if (!isPresent(current.cause) || !isError(current.cause)) {\n break\n }\n\n current = current.cause\n }\n\n return chain\n}\n\nexport const findInCausalChain = (error: Error, predicate: (error: Error) => boolean): Error | undefined => {\n return getCausalChain(error).find(predicate)\n}\n\nconst serializeError = (error: Throwable): any => {\n if (!isPresent(error)) {\n return undefined\n }\n\n if (!isError(error)) {\n return error\n }\n\n const cause = isPresent(error.cause) ? serializeError(error.cause) : undefined\n\n const serialized = {\n name: error.name,\n message: error.message,\n stack: error.stack,\n cause,\n }\n\n return serialized\n}\n"],"mappings":";AAAA,SAAS,iBAAiB;AAGnB,IAAM,UAAU,CAAC,UAAmC;AACzD,SAAO,iBAAiB;AAC1B;AAEO,IAAM,iBAAiB,CAAC,UAA+B;AAC5D,QAAM,QAAsB,CAAC;AAC7B,MAAI,UAAiB;AAErB,SAAO,MAAM;AACX,UAAM,KAAK,OAAO;AAElB,QAAI,CAAC,UAAU,QAAQ,KAAK,KAAK,CAAC,QAAQ,QAAQ,KAAK,GAAG;AACxD;AAAA,IACF;AAEA,cAAU,QAAQ;AAAA,EACpB;AAEA,SAAO;AACT;AAEO,IAAM,oBAAoB,CAAC,OAAc,cAA4D;AAC1G,SAAO,eAAe,KAAK,EAAE,KAAK,SAAS;AAC7C;","names":[]}
|
File without changes
|