@bessemer/cornerstone 0.5.95 → 0.5.97
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/error/error-event.d.ts +2 -1
- package/dist/error/error-event.d.ts.map +1 -1
- package/dist/error/error-event.js +14 -3
- package/dist/error/error-event.js.map +1 -1
- package/dist/temporal/plain-date-time.d.ts +1 -1
- package/dist/temporal/plain-date-time.d.ts.map +1 -1
- package/dist/temporal/plain-date-time.js +2 -2
- package/dist/temporal/plain-date-time.js.map +1 -1
- package/dist/temporal/plain-date.d.ts +1 -1
- package/dist/temporal/plain-date.d.ts.map +1 -1
- package/dist/temporal/plain-date.js +2 -2
- package/dist/temporal/plain-date.js.map +1 -1
- package/dist/temporal/plain-time.d.ts +1 -1
- package/dist/temporal/plain-time.d.ts.map +1 -1
- package/dist/temporal/plain-time.js +2 -2
- package/dist/temporal/plain-time.js.map +1 -1
- package/package.json +1 -1
@@ -65,11 +65,12 @@ export declare const unhandled: (builder?: ErrorEventAugment) => ErrorEvent;
|
|
65
65
|
export declare const required: (builder?: ErrorEventAugment) => ErrorEvent;
|
66
66
|
export declare const unauthorized: (builder?: ErrorEventAugment) => ErrorEvent;
|
67
67
|
export declare const forbidden: (builder?: ErrorEventAugment) => ErrorEvent;
|
68
|
+
export declare const badRequest: (builder?: ErrorEventAugment) => ErrorEvent;
|
68
69
|
export declare const invalidValue: (value: unknown, builder?: ErrorEventAugment) => ErrorEvent;
|
69
70
|
export declare function assertPresent<T>(value: T, builder?: LazyValue<ErrorEventAugment | undefined>): asserts value is NonNullable<T>;
|
70
71
|
export declare function assertAuthorized(value: boolean, builder?: LazyValue<ErrorEventAugment | undefined>): asserts value is true;
|
71
72
|
export declare function assertPermitted(value: boolean, builder?: LazyValue<ErrorEventAugment | undefined>): asserts value is true;
|
72
|
-
export declare function assertValid(
|
73
|
+
export declare function assertValid(value: boolean, builder?: LazyValue<ErrorEventAugment | undefined>): asserts value is true;
|
73
74
|
export declare function assert(value: boolean, builder: LazyValue<ErrorEventBuilder>): asserts value is true;
|
74
75
|
export declare const unpackResult: <T>(result: Result<T, ErrorEvent>) => T;
|
75
76
|
//# sourceMappingURL=error-event.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"error-event.d.ts","sourceRoot":"","sources":["../../src/error/error-event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAA;AACnE,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;AAGhE,OAAO,EAAkC,aAAa,EAAE,iBAAiB,EAAkB,MAAM,oCAAoC,CAAA;AACrI,OAAO,EAAE,SAAS,EAA8D,MAAM,wCAAwC,CAAA;AAC9H,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAA;AAOrD,MAAM,MAAM,SAAS,GAAG,aAAa,CAAC,SAAS,CAAC,CAAA;AAChD,eAAO,MAAM,eAAe,gFAAiE,CAAA;AAE7F,eAAO,MAAM,cAAc,GAAI,MAAM,SAAS,KAAG,CAAC,SAAS,EAAE,iBAAiB,CAE7E,CAAA;AAED,eAAO,MAAM,gBAAgB,GAAI,MAAM,SAAS,KAAG,SAGlD,CAAA;AAED,MAAM,MAAM,gBAAgB,GACxB;IACE,IAAI,EAAE,SAAS,CAAA;CAChB,GACD;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,SAAS,CAAC,EAAE,iBAAiB,CAAA;CAAE,CAAA;AAEtD,eAAO,MAAM,cAAc,GAAI,SAAS,gBAAgB,KAAG,SAM1D,CAAA;AAED,MAAM,MAAM,cAAc,CAAC,IAAI,GAAG,OAAO,IAAI,eAAe,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAA;AACpF,eAAO,MAAM,oBAAoB,EAAE,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B,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;AAED,eAAO,MAAM,YAAY,GAAI,CAAC,EAAE,QAAQ,MAAM,CAAC,CAAC,EAAE,UAAU,CAAC,KAAG,CAM/D,CAAA"}
|
@@ -156,6 +156,16 @@ var forbidden = (builder) => of(
|
|
156
156
|
builder
|
157
157
|
)
|
158
158
|
);
|
159
|
+
var badRequest = (builder) => of(
|
160
|
+
deepMerge(
|
161
|
+
{
|
162
|
+
type: InvalidValue,
|
163
|
+
message: "The format is invalid and cannot be processed.",
|
164
|
+
attributes: { [HttpStatusCodeAttribute]: 400 }
|
165
|
+
},
|
166
|
+
builder
|
167
|
+
)
|
168
|
+
);
|
159
169
|
var invalidValue = (value, builder) => of(
|
160
170
|
deepMerge(
|
161
171
|
{
|
@@ -181,9 +191,9 @@ function assertPermitted(value, builder = () => void 0) {
|
|
181
191
|
throw new ErrorEventException(forbidden(evaluate(builder)));
|
182
192
|
}
|
183
193
|
}
|
184
|
-
function assertValid(
|
185
|
-
if (!
|
186
|
-
throw new ErrorEventException(
|
194
|
+
function assertValid(value, builder = () => void 0) {
|
195
|
+
if (!value) {
|
196
|
+
throw new ErrorEventException(badRequest(evaluate(builder)));
|
187
197
|
}
|
188
198
|
}
|
189
199
|
function assert(value, builder) {
|
@@ -211,6 +221,7 @@ export {
|
|
211
221
|
assertPermitted,
|
212
222
|
assertPresent,
|
213
223
|
assertValid,
|
224
|
+
badRequest,
|
214
225
|
buildErrorCode,
|
215
226
|
forbidden,
|
216
227
|
from,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/error/error-event.ts"],"sourcesContent":["import { Dictionary, 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/error'\nimport { isPromise } from '@bessemer/cornerstone/promise'\nimport { applyNamespace, emptyNamespace, NamespacedKey, ResourceNamespace, splitNamespace } from '@bessemer/cornerstone/resource-key'\nimport { ErrorType, Forbidden, InvalidValue, Required, Unauthorized, Unhandled } from '@bessemer/cornerstone/error/error-type'\nimport { Result } from '@bessemer/cornerstone/result'\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 = NamespacedKey<ErrorType>\nexport const ErrorCodeSchema = Zod.string().transform((it) => it as NamespacedKey<ErrorType>)\n\nexport const splitErrorCode = (code: ErrorCode): [ErrorType, ResourceNamespace] => {\n return splitNamespace(code)\n}\n\nexport const getErrorCodeType = (code: ErrorCode): ErrorType => {\n const [errorType] = splitErrorCode(code)\n return errorType\n}\n\nexport type ErrorCodeBuilder =\n | {\n code: ErrorCode\n }\n | { type: ErrorType; namespace?: ResourceNamespace }\n\nexport const buildErrorCode = (builder: ErrorCodeBuilder): ErrorCode => {\n if ('code' in builder) {\n return builder.code\n } else {\n return applyNamespace(builder.type, builder.namespace ?? emptyNamespace())\n }\n}\n\nexport type ErrorAttribute<Type = unknown> = RecordAttribute<Type, 'ErrorAttribute'>\nexport const ErrorAttributeSchema: ZodType<ErrorAttribute, string> = Zod.string()\n\nexport const ErrorEventCauseSchema = Zod.object({\n code: ErrorCodeSchema,\n message: Zod.string(),\n attributes: Zod.record(Zod.string(), Zod.unknown()),\n})\n\nexport type ErrorEventCause = Zod.infer<typeof ErrorEventCauseSchema>\n\nexport const Schema = Zod.object({\n message: Zod.string(),\n causes: Zod.array(ErrorEventCauseSchema),\n attributes: Zod.record(ErrorAttributeSchema, Zod.unknown()),\n})\n\nexport type ErrorEvent = Zod.infer<typeof Schema>\n\nexport type ErrorEventCauseBuilder = ErrorCodeBuilder & {\n message: string\n attributes?: Dictionary<unknown>\n}\n\nexport type ErrorEventBuilder = {\n attributes?: Record<ErrorAttribute, unknown>\n} & (\n | {\n causes: Array<ErrorEventCauseBuilder>\n message: string\n }\n | (ErrorCodeBuilder & {\n message: string\n })\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 const errorEvent = throwable as ErrorEvent\n return isPresent(errorEvent.message) && isPresent(errorEvent.attributes) && isPresent(errorEvent.causes)\n}\n\nexport const isErrorEventException = (throwable: Throwable): throwable is ErrorEventException => {\n return throwable instanceof ErrorEventException\n}\n\nexport const of = (builder: ErrorEventBuilder): ErrorEvent => {\n if ('causes' in builder) {\n return {\n causes: builder.causes.map((it) => {\n return {\n code: buildErrorCode(it),\n message: it.message,\n attributes: it.attributes ?? {},\n }\n }),\n message: builder.message,\n attributes: builder.attributes ?? {},\n }\n } else {\n return {\n causes: [\n {\n code: buildErrorCode(builder),\n message: builder.message,\n attributes: {},\n },\n ],\n message: builder.message,\n attributes: builder.attributes ?? {},\n }\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 ValueAttribute: ErrorAttribute = 'value'\nexport const RequestCorrelationIdAttribute: ErrorAttribute<string> = 'requestCorrelationId'\nexport const HttpStatusCodeAttribute: ErrorAttribute<number> = 'httpStatusCode'\n\nexport const unhandled = (builder?: ErrorEventAugment): ErrorEvent =>\n of(\n deepMerge(\n {\n type: Unhandled,\n message: 'An Unhandled Error has occurred.',\n attributes: { [HttpStatusCodeAttribute]: 500 },\n },\n builder\n )\n )\n\nexport const required = (builder?: ErrorEventAugment): ErrorEvent =>\n of(\n deepMerge(\n {\n type: Required,\n message: 'The resource is required.',\n attributes: { [HttpStatusCodeAttribute]: 404 },\n },\n builder\n )\n )\n\nexport const unauthorized = (builder?: ErrorEventAugment): ErrorEvent =>\n of(\n deepMerge(\n {\n type: Unauthorized,\n message: 'The requested Resource requires authentication.',\n attributes: { [HttpStatusCodeAttribute]: 401 },\n },\n builder\n )\n )\n\nexport const forbidden = (builder?: ErrorEventAugment): ErrorEvent =>\n of(\n deepMerge(\n {\n type: Forbidden,\n message: 'The requested Resource requires additional permissions to access.',\n attributes: { [HttpStatusCodeAttribute]: 403 },\n },\n builder\n )\n )\n\nexport const invalidValue = (value: unknown, builder?: ErrorEventAugment): ErrorEvent =>\n of(\n deepMerge(\n {\n type: InvalidValue,\n message: 'The format is invalid and cannot be processed.',\n attributes: { [HttpStatusCodeAttribute]: 400, [ValueAttribute]: value },\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(required(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(\n valid: boolean,\n value: unknown,\n builder: LazyValue<ErrorEventAugment | undefined> = () => undefined\n): asserts value is true {\n if (!valid) {\n throw new ErrorEventException(invalidValue(value, 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\nexport const unpackResult = <T>(result: Result<T, ErrorEvent>): T => {\n if (!result.isSuccess) {\n throw new ErrorEventException(result.value)\n }\n\n return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AAG,IAAI;AAAA,IAC/C;AAAA,IACA;AAAA,EACF;AACF;AAEK,IAAM,eAAe,CAAC,OAAgB,YAC3C;AAAA,EACE;AAAA,IACE;AAAA,MACE,MAAM;AAAA,MACN,SAAS;AAAA,MACT,YAAY,EAAE,CAAC,uBAAuB,GAAG,KAAK,CAAC,cAAc,GAAG,MAAM;AAAA,IACxE;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,YACd,OACA,OACA,UAAoD,MAAM,QACnC;AACvB,MAAI,CAAC,OAAO;AACV,UAAM,IAAI,oBAAoB,aAAa,OAAO,SAAS,OAAO,CAAC,CAAC;AAAA,EACtE;AACF;AAEO,SAAS,OAAO,OAAgB,SAA8D;AACnG,MAAI,CAAC,OAAO;AACV,UAAM,IAAI,oBAAoB,GAAG,SAAS,OAAO,CAAC,CAAC;AAAA,EACrD;AACF;AAEO,IAAM,eAAe,CAAI,WAAqC;AACnE,MAAI,CAAC,OAAO,WAAW;AACrB,UAAM,IAAI,oBAAoB,OAAO,KAAK;AAAA,EAC5C;AAEA,SAAO,OAAO;AAChB;","names":[]}
|
1
|
+
{"version":3,"sources":["../../src/error/error-event.ts"],"sourcesContent":["import { Dictionary, 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/error'\nimport { isPromise } from '@bessemer/cornerstone/promise'\nimport { applyNamespace, emptyNamespace, NamespacedKey, ResourceNamespace, splitNamespace } from '@bessemer/cornerstone/resource-key'\nimport { ErrorType, Forbidden, InvalidValue, Required, Unauthorized, Unhandled } from '@bessemer/cornerstone/error/error-type'\nimport { Result } from '@bessemer/cornerstone/result'\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 = NamespacedKey<ErrorType>\nexport const ErrorCodeSchema = Zod.string().transform((it) => it as NamespacedKey<ErrorType>)\n\nexport const splitErrorCode = (code: ErrorCode): [ErrorType, ResourceNamespace] => {\n return splitNamespace(code)\n}\n\nexport const getErrorCodeType = (code: ErrorCode): ErrorType => {\n const [errorType] = splitErrorCode(code)\n return errorType\n}\n\nexport type ErrorCodeBuilder =\n | {\n code: ErrorCode\n }\n | { type: ErrorType; namespace?: ResourceNamespace }\n\nexport const buildErrorCode = (builder: ErrorCodeBuilder): ErrorCode => {\n if ('code' in builder) {\n return builder.code\n } else {\n return applyNamespace(builder.type, builder.namespace ?? emptyNamespace())\n }\n}\n\nexport type ErrorAttribute<Type = unknown> = RecordAttribute<Type, 'ErrorAttribute'>\nexport const ErrorAttributeSchema: ZodType<ErrorAttribute, string> = Zod.string()\n\nexport const ErrorEventCauseSchema = Zod.object({\n code: ErrorCodeSchema,\n message: Zod.string(),\n attributes: Zod.record(Zod.string(), Zod.unknown()),\n})\n\nexport type ErrorEventCause = Zod.infer<typeof ErrorEventCauseSchema>\n\nexport const Schema = Zod.object({\n message: Zod.string(),\n causes: Zod.array(ErrorEventCauseSchema),\n attributes: Zod.record(ErrorAttributeSchema, Zod.unknown()),\n})\n\nexport type ErrorEvent = Zod.infer<typeof Schema>\n\nexport type ErrorEventCauseBuilder = ErrorCodeBuilder & {\n message: string\n attributes?: Dictionary<unknown>\n}\n\nexport type ErrorEventBuilder = {\n attributes?: Record<ErrorAttribute, unknown>\n} & (\n | {\n causes: Array<ErrorEventCauseBuilder>\n message: string\n }\n | (ErrorCodeBuilder & {\n message: string\n })\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 const errorEvent = throwable as ErrorEvent\n return isPresent(errorEvent.message) && isPresent(errorEvent.attributes) && isPresent(errorEvent.causes)\n}\n\nexport const isErrorEventException = (throwable: Throwable): throwable is ErrorEventException => {\n return throwable instanceof ErrorEventException\n}\n\nexport const of = (builder: ErrorEventBuilder): ErrorEvent => {\n if ('causes' in builder) {\n return {\n causes: builder.causes.map((it) => {\n return {\n code: buildErrorCode(it),\n message: it.message,\n attributes: it.attributes ?? {},\n }\n }),\n message: builder.message,\n attributes: builder.attributes ?? {},\n }\n } else {\n return {\n causes: [\n {\n code: buildErrorCode(builder),\n message: builder.message,\n attributes: {},\n },\n ],\n message: builder.message,\n attributes: builder.attributes ?? {},\n }\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 ValueAttribute: ErrorAttribute = 'value'\nexport const RequestCorrelationIdAttribute: ErrorAttribute<string> = 'requestCorrelationId'\nexport const HttpStatusCodeAttribute: ErrorAttribute<number> = 'httpStatusCode'\n\nexport const unhandled = (builder?: ErrorEventAugment): ErrorEvent =>\n of(\n deepMerge(\n {\n type: Unhandled,\n message: 'An Unhandled Error has occurred.',\n attributes: { [HttpStatusCodeAttribute]: 500 },\n },\n builder\n )\n )\n\nexport const required = (builder?: ErrorEventAugment): ErrorEvent =>\n of(\n deepMerge(\n {\n type: Required,\n message: 'The resource is required.',\n attributes: { [HttpStatusCodeAttribute]: 404 },\n },\n builder\n )\n )\n\nexport const unauthorized = (builder?: ErrorEventAugment): ErrorEvent =>\n of(\n deepMerge(\n {\n type: Unauthorized,\n message: 'The requested Resource requires authentication.',\n attributes: { [HttpStatusCodeAttribute]: 401 },\n },\n builder\n )\n )\n\nexport const forbidden = (builder?: ErrorEventAugment): ErrorEvent =>\n of(\n deepMerge(\n {\n type: Forbidden,\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): ErrorEvent =>\n of(\n deepMerge(\n {\n type: InvalidValue,\n message: 'The format is invalid and cannot be processed.',\n attributes: { [HttpStatusCodeAttribute]: 400 },\n },\n builder\n )\n )\n\nexport const invalidValue = (value: unknown, builder?: ErrorEventAugment): ErrorEvent =>\n of(\n deepMerge(\n {\n type: InvalidValue,\n message: 'The format is invalid and cannot be processed.',\n attributes: { [HttpStatusCodeAttribute]: 400, [ValueAttribute]: value },\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(required(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\nexport const unpackResult = <T>(result: Result<T, ErrorEvent>): T => {\n if (!result.isSuccess) {\n throw new ErrorEventException(result.value)\n }\n\n return result.value\n}\n"],"mappings":";AACA,SAAS,WAAW,OAAO,UAAU,iBAAkC;AACvE,OAAO,SAAsB;AAC7B,SAAS,gBAA2B;AACpC,SAAS,qBAAqB,yBAAyB,eAAe;AACtE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const SchemaLiteral: Zod.ZodPipe<Zod.ZodString, Zod.ZodTransform<PlainDateTimeLiteral, string>>;
|
33
33
|
export declare const SchemaInstance: Zod.ZodPipe<Zod.ZodString, Zod.ZodTransform<Temporal.PlainDateTime, string>>;
|
34
34
|
export declare const isPlainDateTime: (value: unknown) => value is PlainDateTime;
|
35
|
-
export declare const now: (clock?: {
|
35
|
+
export declare const now: (zone: TimeZoneId, clock?: {
|
36
36
|
readonly zone: TimeZoneId;
|
37
37
|
instant(): import("@bessemer/cornerstone/temporal/instant").Instant;
|
38
38
|
withZone(zone: TimeZoneId): import("@bessemer/cornerstone/temporal/clock").Clock;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"plain-date-time.d.ts","sourceRoot":"","sources":["../../src/temporal/plain-date-time.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAEhD,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAA;AAE7D,OAAO,EAAsB,MAAM,EAAW,MAAM,8BAA8B,CAAA;AAClF,OAAO,EAAE,UAAU,EAA8B,MAAM,yCAAyC,CAAA;AAGhG,OAAO,GAAG,MAAM,KAAK,CAAA;AAErB,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAyB,MAAM,yCAAyC,CAAA;AACvG,OAAO,EAAwB,WAAW,EAAE,MAAM,wCAAwC,CAAA;AAC1F,OAAO,EAAE,UAAU,EAAE,MAAM,6CAA6C,CAAA;AACxE,OAAO,EAAE,QAAQ,EAAE,MAAM,uCAAuC,CAAA;AAGhE,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAA;AAC/F,OAAO,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAA;AAC1D,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,2CAA2C,CAAA;AAE/F,MAAM,MAAM,aA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AI,SAAS,iBAAiB,EAAE,QAAQ,MAAM,EAAE,SAAS,qBAAqB,KAAG,MAgBnG,CAAA"}
|
@@ -55,8 +55,8 @@ var SchemaInstance = structuredTransform(Zod.string(), parseString);
|
|
55
55
|
var isPlainDateTime = (value) => {
|
56
56
|
return value instanceof Temporal.PlainDateTime;
|
57
57
|
};
|
58
|
-
var now = (clock = DefaultClock) => {
|
59
|
-
return fromInstant(clock.instant(),
|
58
|
+
var now = (zone, clock = DefaultClock) => {
|
59
|
+
return fromInstant(clock.instant(), zone);
|
60
60
|
};
|
61
61
|
var merge = (element, builder) => {
|
62
62
|
return from(element).with(builder);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/temporal/plain-date-time.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill'\nimport { namespace } from '@bessemer/cornerstone/resource-key'\nimport { NominalType } from '@bessemer/cornerstone/types'\nimport { Comparator } from '@bessemer/cornerstone/comparator'\nimport { fromComparator } from '@bessemer/cornerstone/equalitor'\nimport { failure, mapResult, Result, success } from '@bessemer/cornerstone/result'\nimport { ErrorEvent, invalidValue, unpackResult } from '@bessemer/cornerstone/error/error-event'\nimport { isError } from '@bessemer/cornerstone/error/error'\nimport { structuredTransform } from '@bessemer/cornerstone/zod-util'\nimport Zod from 'zod'\nimport { Default as DefaultClock } from '@bessemer/cornerstone/temporal/clock'\nimport { Duration, DurationLike, from as _fromDuration } from '@bessemer/cornerstone/temporal/duration'\nimport { from as _fromInstant, InstantLike } from '@bessemer/cornerstone/temporal/instant'\nimport { TimeZoneId } from '@bessemer/cornerstone/temporal/time-zone-id'\nimport { TimeUnit } from '@bessemer/cornerstone/temporal/chrono'\nimport { isString } from '@bessemer/cornerstone/string'\nimport { isNil } from '@bessemer/cornerstone/object'\nimport { PlainTimeBuilder, TimeFormatOptions } from '@bessemer/cornerstone/temporal/plain-time'\nimport { Locale } from '@bessemer/cornerstone/intl/locale'\nimport { DateFormatOptions, PlainDateBuilder } from '@bessemer/cornerstone/temporal/plain-date'\n\nexport type PlainDateTime = Temporal.PlainDateTime\nexport const Namespace = namespace('plain-date-time')\nexport type PlainDateTimeLiteral = NominalType<string, typeof Namespace>\nexport type PlainDateTimeBuilder = PlainDateBuilder & PlainTimeBuilder\n\nexport type PlainDateTimeLike = PlainDateTime | PlainDateTimeLiteral | PlainDateTimeBuilder\n\nexport function from(value: PlainDateTimeLike): PlainDateTime\nexport function from(value: PlainDateTimeLike | null): PlainDateTime | null\nexport function from(value: PlainDateTimeLike | undefined): PlainDateTime | undefined\nexport function from(value: PlainDateTimeLike | null | undefined): PlainDateTime | null | undefined\nexport function from(value: PlainDateTimeLike | null | undefined): PlainDateTime | null | undefined {\n if (isNil(value)) {\n return value\n }\n\n if (value instanceof Temporal.PlainDateTime) {\n return value\n }\n\n if (isString(value)) {\n return fromString(value)\n }\n\n return Temporal.PlainDateTime.from(value)\n}\n\nexport const CompareBy: Comparator<PlainDateTime> = (first: PlainDateTime, second: PlainDateTime): number =>\n Temporal.PlainDateTime.compare(first, second)\nexport const EqualBy = fromComparator(CompareBy)\n\nexport const parseString = (value: string): Result<PlainDateTime, ErrorEvent> => {\n try {\n return success(Temporal.PlainDateTime.from(value))\n } catch (e) {\n if (!isError(e)) {\n throw e\n }\n\n return failure(invalidValue(value, { namespace: Namespace, message: e.message }))\n }\n}\n\nexport const fromString = (value: string): PlainDateTime => {\n return unpackResult(parseString(value))\n}\n\nexport const fromInstant = (instant: InstantLike, zone: TimeZoneId): PlainDateTime => {\n return _fromInstant(instant).toZonedDateTimeISO(zone).toPlainDateTime()\n}\n\nexport function toLiteral(likeValue: PlainDateTimeLike): PlainDateTimeLiteral\nexport function toLiteral(likeValue: PlainDateTimeLike | null): PlainDateTimeLiteral | null\nexport function toLiteral(likeValue: PlainDateTimeLike | undefined): PlainDateTimeLiteral | undefined\nexport function toLiteral(likeValue: PlainDateTimeLike | null | undefined): PlainDateTimeLiteral | null | undefined\nexport function toLiteral(likeValue: PlainDateTimeLike | null | undefined): PlainDateTimeLiteral | null | undefined {\n if (isNil(likeValue)) {\n return likeValue\n }\n\n const value = from(likeValue)\n return value.toString() as PlainDateTimeLiteral\n}\n\nexport const SchemaLiteral = structuredTransform(Zod.string(), (it: string) => mapResult(parseString(it), (it) => toLiteral(it)))\nexport const SchemaInstance = structuredTransform(Zod.string(), parseString)\n\nexport const isPlainDateTime = (value: unknown): value is PlainDateTime => {\n return value instanceof Temporal.PlainDateTime\n}\n\nexport const now = (clock = DefaultClock): PlainDateTime => {\n return fromInstant(clock.instant(),
|
1
|
+
{"version":3,"sources":["../../src/temporal/plain-date-time.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill'\nimport { namespace } from '@bessemer/cornerstone/resource-key'\nimport { NominalType } from '@bessemer/cornerstone/types'\nimport { Comparator } from '@bessemer/cornerstone/comparator'\nimport { fromComparator } from '@bessemer/cornerstone/equalitor'\nimport { failure, mapResult, Result, success } from '@bessemer/cornerstone/result'\nimport { ErrorEvent, invalidValue, unpackResult } from '@bessemer/cornerstone/error/error-event'\nimport { isError } from '@bessemer/cornerstone/error/error'\nimport { structuredTransform } from '@bessemer/cornerstone/zod-util'\nimport Zod from 'zod'\nimport { Default as DefaultClock } from '@bessemer/cornerstone/temporal/clock'\nimport { Duration, DurationLike, from as _fromDuration } from '@bessemer/cornerstone/temporal/duration'\nimport { from as _fromInstant, InstantLike } from '@bessemer/cornerstone/temporal/instant'\nimport { TimeZoneId } from '@bessemer/cornerstone/temporal/time-zone-id'\nimport { TimeUnit } from '@bessemer/cornerstone/temporal/chrono'\nimport { isString } from '@bessemer/cornerstone/string'\nimport { isNil } from '@bessemer/cornerstone/object'\nimport { PlainTimeBuilder, TimeFormatOptions } from '@bessemer/cornerstone/temporal/plain-time'\nimport { Locale } from '@bessemer/cornerstone/intl/locale'\nimport { DateFormatOptions, PlainDateBuilder } from '@bessemer/cornerstone/temporal/plain-date'\n\nexport type PlainDateTime = Temporal.PlainDateTime\nexport const Namespace = namespace('plain-date-time')\nexport type PlainDateTimeLiteral = NominalType<string, typeof Namespace>\nexport type PlainDateTimeBuilder = PlainDateBuilder & PlainTimeBuilder\n\nexport type PlainDateTimeLike = PlainDateTime | PlainDateTimeLiteral | PlainDateTimeBuilder\n\nexport function from(value: PlainDateTimeLike): PlainDateTime\nexport function from(value: PlainDateTimeLike | null): PlainDateTime | null\nexport function from(value: PlainDateTimeLike | undefined): PlainDateTime | undefined\nexport function from(value: PlainDateTimeLike | null | undefined): PlainDateTime | null | undefined\nexport function from(value: PlainDateTimeLike | null | undefined): PlainDateTime | null | undefined {\n if (isNil(value)) {\n return value\n }\n\n if (value instanceof Temporal.PlainDateTime) {\n return value\n }\n\n if (isString(value)) {\n return fromString(value)\n }\n\n return Temporal.PlainDateTime.from(value)\n}\n\nexport const CompareBy: Comparator<PlainDateTime> = (first: PlainDateTime, second: PlainDateTime): number =>\n Temporal.PlainDateTime.compare(first, second)\nexport const EqualBy = fromComparator(CompareBy)\n\nexport const parseString = (value: string): Result<PlainDateTime, ErrorEvent> => {\n try {\n return success(Temporal.PlainDateTime.from(value))\n } catch (e) {\n if (!isError(e)) {\n throw e\n }\n\n return failure(invalidValue(value, { namespace: Namespace, message: e.message }))\n }\n}\n\nexport const fromString = (value: string): PlainDateTime => {\n return unpackResult(parseString(value))\n}\n\nexport const fromInstant = (instant: InstantLike, zone: TimeZoneId): PlainDateTime => {\n return _fromInstant(instant).toZonedDateTimeISO(zone).toPlainDateTime()\n}\n\nexport function toLiteral(likeValue: PlainDateTimeLike): PlainDateTimeLiteral\nexport function toLiteral(likeValue: PlainDateTimeLike | null): PlainDateTimeLiteral | null\nexport function toLiteral(likeValue: PlainDateTimeLike | undefined): PlainDateTimeLiteral | undefined\nexport function toLiteral(likeValue: PlainDateTimeLike | null | undefined): PlainDateTimeLiteral | null | undefined\nexport function toLiteral(likeValue: PlainDateTimeLike | null | undefined): PlainDateTimeLiteral | null | undefined {\n if (isNil(likeValue)) {\n return likeValue\n }\n\n const value = from(likeValue)\n return value.toString() as PlainDateTimeLiteral\n}\n\nexport const SchemaLiteral = structuredTransform(Zod.string(), (it: string) => mapResult(parseString(it), (it) => toLiteral(it)))\nexport const SchemaInstance = structuredTransform(Zod.string(), parseString)\n\nexport const isPlainDateTime = (value: unknown): value is PlainDateTime => {\n return value instanceof Temporal.PlainDateTime\n}\n\nexport const now = (zone: TimeZoneId, clock = DefaultClock): PlainDateTime => {\n return fromInstant(clock.instant(), zone)\n}\n\nexport const merge = (element: PlainDateTimeLike, builder: PlainDateTimeBuilder): PlainDateTime => {\n return from(element).with(builder)\n}\n\nexport const add = (element: PlainDateTimeLike, duration: DurationLike): PlainDateTime => {\n return from(element).add(_fromDuration(duration))\n}\n\nexport const subtract = (element: PlainDateTimeLike, duration: DurationLike): PlainDateTime => {\n return from(element).subtract(_fromDuration(duration))\n}\n\nexport const until = (element: PlainDateTimeLike, other: PlainDateTimeLike): Duration => {\n return from(element).until(from(other))\n}\n\nexport const round = (element: PlainDateTimeLike, unit: TimeUnit): PlainDateTime => {\n return from(element).round({ smallestUnit: unit })\n}\n\nexport function isEqual(element: PlainDateTimeLike, other: PlainDateTimeLike): boolean\nexport function isEqual(element: PlainDateTimeLike | null, other: PlainDateTimeLike | null): boolean\nexport function isEqual(element: PlainDateTimeLike | undefined, other: PlainDateTimeLike | undefined): boolean\nexport function isEqual(element: PlainDateTimeLike | null | undefined, other: PlainDateTimeLike | null | undefined): boolean {\n if (isNil(element) || isNil(other)) {\n return element === other\n }\n\n return EqualBy(from(element), from(other))\n}\n\nexport const isBefore = (element: PlainDateTimeLike, other: PlainDateTimeLike): boolean => {\n return CompareBy(from(element), from(other)) < 0\n}\n\nexport const isAfter = (element: PlainDateTimeLike, other: PlainDateTimeLike): boolean => {\n return CompareBy(from(element), from(other)) > 0\n}\n\nexport type DateTimeFormatOptions = DateFormatOptions & TimeFormatOptions\n\nexport const format = (element: PlainDateTimeLike, locale: Locale, options: DateTimeFormatOptions): string => {\n const plainDateTime = from(element)\n\n // Convert PlainDateTime to Date\n const date = new Date(\n plainDateTime.year,\n plainDateTime.month - 1, // Date months are 0-based\n plainDateTime.day,\n plainDateTime.hour,\n plainDateTime.minute,\n plainDateTime.second,\n plainDateTime.millisecond\n )\n\n const formatter = new Intl.DateTimeFormat(locale, options)\n return formatter.format(date)\n}\n"],"mappings":";AAAA,SAAS,gBAAgB;AACzB,SAAS,iBAAiB;AAG1B,SAAS,sBAAsB;AAC/B,SAAS,SAAS,WAAmB,eAAe;AACpD,SAAqB,cAAc,oBAAoB;AACvD,SAAS,eAAe;AACxB,SAAS,2BAA2B;AACpC,OAAO,SAAS;AAChB,SAAS,WAAW,oBAAoB;AACxC,SAAiC,QAAQ,qBAAqB;AAC9D,SAAS,QAAQ,oBAAiC;AAGlD,SAAS,gBAAgB;AACzB,SAAS,aAAa;AAMf,IAAM,YAAY,UAAU,iBAAiB;AAU7C,SAAS,KAAK,OAA+E;AAClG,MAAI,MAAM,KAAK,GAAG;AAChB,WAAO;AAAA,EACT;AAEA,MAAI,iBAAiB,SAAS,eAAe;AAC3C,WAAO;AAAA,EACT;AAEA,MAAI,SAAS,KAAK,GAAG;AACnB,WAAO,WAAW,KAAK;AAAA,EACzB;AAEA,SAAO,SAAS,cAAc,KAAK,KAAK;AAC1C;AAEO,IAAM,YAAuC,CAAC,OAAsB,WACzE,SAAS,cAAc,QAAQ,OAAO,MAAM;AACvC,IAAM,UAAU,eAAe,SAAS;AAExC,IAAM,cAAc,CAAC,UAAqD;AAC/E,MAAI;AACF,WAAO,QAAQ,SAAS,cAAc,KAAK,KAAK,CAAC;AAAA,EACnD,SAAS,GAAG;AACV,QAAI,CAAC,QAAQ,CAAC,GAAG;AACf,YAAM;AAAA,IACR;AAEA,WAAO,QAAQ,aAAa,OAAO,EAAE,WAAW,WAAW,SAAS,EAAE,QAAQ,CAAC,CAAC;AAAA,EAClF;AACF;AAEO,IAAM,aAAa,CAAC,UAAiC;AAC1D,SAAO,aAAa,YAAY,KAAK,CAAC;AACxC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AK,KAAK,CAAC;AAC3C;AAEO,IAAM,WAAW,CAAC,SAA4B,UAAsC;AACzF,SAAO,UAAU,KAAK,OAAO,GAAG,KAAK,KAAK,CAAC,IAAI;AACjD;AAEO,IAAM,UAAU,CAAC,SAA4B,UAAsC;AACxF,SAAO,UAAU,KAAK,OAAO,GAAG,KAAK,KAAK,CAAC,IAAI;AACjD;AAIO,IAAM,SAAS,CAAC,SAA4B,QAAgB,YAA2C;AAC5G,QAAM,gBAAgB,KAAK,OAAO;AAGlC,QAAM,OAAO,IAAI;AAAA,IACf,cAAc;AAAA,IACd,cAAc,QAAQ;AAAA;AAAA,IACtB,cAAc;AAAA,IACd,cAAc;AAAA,IACd,cAAc;AAAA,IACd,cAAc;AAAA,IACd,cAAc;AAAA,EAChB;AAEA,QAAM,YAAY,IAAI,KAAK,eAAe,QAAQ,OAAO;AACzD,SAAO,UAAU,OAAO,IAAI;AAC9B;","names":["it"]}
|
@@ -33,7 +33,7 @@ export declare function toLiteral(likeValue: PlainDateLike | null | undefined):
|
|
33
33
|
export declare const SchemaLiteral: Zod.ZodPipe<Zod.ZodString, Zod.ZodTransform<PlainDateLiteral, string>>;
|
34
34
|
export declare const SchemaInstance: Zod.ZodPipe<Zod.ZodString, Zod.ZodTransform<Temporal.PlainDate, string>>;
|
35
35
|
export declare const isPlainDateTime: (value: unknown) => value is PlainDate;
|
36
|
-
export declare const now: (clock?: {
|
36
|
+
export declare const now: (zone: TimeZoneId, clock?: {
|
37
37
|
readonly zone: TimeZoneId;
|
38
38
|
instant(): import("@bessemer/cornerstone/temporal/instant").Instant;
|
39
39
|
withZone(zone: TimeZoneId): import("@bessemer/cornerstone/temporal/clock").Clock;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"plain-date.d.ts","sourceRoot":"","sources":["../../src/temporal/plain-date.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAEhD,OAAO,EAAE,WAAW,EAAE,MAAM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AG,SAAS,GAAG,OAAO,CAAA;AAStG,eAAO,MAAM,QAAQ,GAAI,SAAS,aAAa,EAAE,OAAO,SAAS,KAAG,OAEnE,CAAA;AAED,eAAO,MAAM,OAAO,GAAI,SAAS,aAAa,EAAE,OAAO,SAAS,KAAG,OAElE,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC9B,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,SAAS,CAAA;IAC7C,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,SAAS,CAAA;IACjD,IAAI,CAAC,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,CAAA;IACxC,KAAK,CAAC,EAAE,SAAS,GAAG,SAAS,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,SAAS,CAAA;IACvE,GAAG,CAAC,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,CAAA;CACxC,CAAA;AAED,eAAO,MAAM,MAAM,GAAI,SAAS,aAAa,EAAE,QAAQ,MAAM,EAAE,SAAS,iBAAiB,KAAG,MAY3F,CAAA"}
|
@@ -55,8 +55,8 @@ var SchemaInstance = structuredTransform(Zod.string(), parseString);
|
|
55
55
|
var isPlainDateTime = (value) => {
|
56
56
|
return value instanceof Temporal.PlainDateTime;
|
57
57
|
};
|
58
|
-
var now = (clock = DefaultClock) => {
|
59
|
-
return fromInstant(clock.instant(),
|
58
|
+
var now = (zone, clock = DefaultClock) => {
|
59
|
+
return fromInstant(clock.instant(), zone);
|
60
60
|
};
|
61
61
|
var merge = (element, builder) => {
|
62
62
|
return from(element).with(builder);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/temporal/plain-date.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill'\nimport { namespace } from '@bessemer/cornerstone/resource-key'\nimport { NominalType } from '@bessemer/cornerstone/types'\nimport { Comparator } from '@bessemer/cornerstone/comparator'\nimport { fromComparator } from '@bessemer/cornerstone/equalitor'\nimport { failure, mapResult, Result, success } from '@bessemer/cornerstone/result'\nimport { ErrorEvent, invalidValue, unpackResult } from '@bessemer/cornerstone/error/error-event'\nimport { isError } from '@bessemer/cornerstone/error/error'\nimport { structuredTransform } from '@bessemer/cornerstone/zod-util'\nimport Zod from 'zod'\nimport { Default as DefaultClock } from '@bessemer/cornerstone/temporal/clock'\nimport { Duration, DurationLike, from as _fromDuration } from '@bessemer/cornerstone/temporal/duration'\nimport { from as _fromInstant, InstantLike } from '@bessemer/cornerstone/temporal/instant'\nimport { TimeZoneId } from '@bessemer/cornerstone/temporal/time-zone-id'\nimport { isString } from '@bessemer/cornerstone/string'\nimport { isNil } from '@bessemer/cornerstone/object'\nimport { Locale } from '@bessemer/cornerstone/intl/locale'\n\nexport type PlainDate = Temporal.PlainDate\nexport const Namespace = namespace('plain-date')\nexport type PlainDateLiteral = NominalType<string, typeof Namespace>\nexport type PlainDateBuilder = {\n year?: number\n month?: number\n day?: number\n}\n\nexport type PlainDateLike = PlainDate | PlainDateLiteral | PlainDateBuilder\n\nexport function from(value: PlainDateLike): PlainDate\nexport function from(value: PlainDateLike | null): PlainDate | null\nexport function from(value: PlainDateLike | undefined): PlainDate | undefined\nexport function from(value: PlainDateLike | null | undefined): PlainDate | null | undefined\nexport function from(value: PlainDateLike | null | undefined): PlainDate | null | undefined {\n if (isNil(value)) {\n return value\n }\n\n if (value instanceof Temporal.PlainDate) {\n return value\n }\n\n if (isString(value)) {\n return fromString(value)\n }\n\n return Temporal.PlainDate.from(value)\n}\n\nexport const CompareBy: Comparator<PlainDate> = (first: PlainDate, second: PlainDate): number => Temporal.PlainDateTime.compare(first, second)\nexport const EqualBy = fromComparator(CompareBy)\n\nexport const parseString = (value: string): Result<PlainDate, ErrorEvent> => {\n try {\n return success(Temporal.PlainDate.from(value))\n } catch (e) {\n if (!isError(e)) {\n throw e\n }\n\n return failure(invalidValue(value, { namespace: Namespace, message: e.message }))\n }\n}\n\nexport const fromString = (value: string): PlainDate => {\n return unpackResult(parseString(value))\n}\n\nexport const fromInstant = (instant: InstantLike, zone: TimeZoneId): PlainDate => {\n return _fromInstant(instant).toZonedDateTimeISO(zone).toPlainDate()\n}\n\nexport function toLiteral(likeValue: PlainDateLike): PlainDateLiteral\nexport function toLiteral(likeValue: PlainDateLike | null): PlainDateLiteral | null\nexport function toLiteral(likeValue: PlainDateLike | undefined): PlainDateLiteral | undefined\nexport function toLiteral(likeValue: PlainDateLike | null | undefined): PlainDateLiteral | null | undefined\nexport function toLiteral(likeValue: PlainDateLike | null | undefined): PlainDateLiteral | null | undefined {\n if (isNil(likeValue)) {\n return likeValue\n }\n\n const value = from(likeValue)\n return value.toString() as PlainDateLiteral\n}\n\nexport const SchemaLiteral = structuredTransform(Zod.string(), (it: string) => mapResult(parseString(it), (it) => toLiteral(it)))\nexport const SchemaInstance = structuredTransform(Zod.string(), parseString)\n\nexport const isPlainDateTime = (value: unknown): value is PlainDate => {\n return value instanceof Temporal.PlainDateTime\n}\n\nexport const now = (clock = DefaultClock): PlainDate => {\n return fromInstant(clock.instant(),
|
1
|
+
{"version":3,"sources":["../../src/temporal/plain-date.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill'\nimport { namespace } from '@bessemer/cornerstone/resource-key'\nimport { NominalType } from '@bessemer/cornerstone/types'\nimport { Comparator } from '@bessemer/cornerstone/comparator'\nimport { fromComparator } from '@bessemer/cornerstone/equalitor'\nimport { failure, mapResult, Result, success } from '@bessemer/cornerstone/result'\nimport { ErrorEvent, invalidValue, unpackResult } from '@bessemer/cornerstone/error/error-event'\nimport { isError } from '@bessemer/cornerstone/error/error'\nimport { structuredTransform } from '@bessemer/cornerstone/zod-util'\nimport Zod from 'zod'\nimport { Default as DefaultClock } from '@bessemer/cornerstone/temporal/clock'\nimport { Duration, DurationLike, from as _fromDuration } from '@bessemer/cornerstone/temporal/duration'\nimport { from as _fromInstant, InstantLike } from '@bessemer/cornerstone/temporal/instant'\nimport { TimeZoneId } from '@bessemer/cornerstone/temporal/time-zone-id'\nimport { isString } from '@bessemer/cornerstone/string'\nimport { isNil } from '@bessemer/cornerstone/object'\nimport { Locale } from '@bessemer/cornerstone/intl/locale'\n\nexport type PlainDate = Temporal.PlainDate\nexport const Namespace = namespace('plain-date')\nexport type PlainDateLiteral = NominalType<string, typeof Namespace>\nexport type PlainDateBuilder = {\n year?: number\n month?: number\n day?: number\n}\n\nexport type PlainDateLike = PlainDate | PlainDateLiteral | PlainDateBuilder\n\nexport function from(value: PlainDateLike): PlainDate\nexport function from(value: PlainDateLike | null): PlainDate | null\nexport function from(value: PlainDateLike | undefined): PlainDate | undefined\nexport function from(value: PlainDateLike | null | undefined): PlainDate | null | undefined\nexport function from(value: PlainDateLike | null | undefined): PlainDate | null | undefined {\n if (isNil(value)) {\n return value\n }\n\n if (value instanceof Temporal.PlainDate) {\n return value\n }\n\n if (isString(value)) {\n return fromString(value)\n }\n\n return Temporal.PlainDate.from(value)\n}\n\nexport const CompareBy: Comparator<PlainDate> = (first: PlainDate, second: PlainDate): number => Temporal.PlainDateTime.compare(first, second)\nexport const EqualBy = fromComparator(CompareBy)\n\nexport const parseString = (value: string): Result<PlainDate, ErrorEvent> => {\n try {\n return success(Temporal.PlainDate.from(value))\n } catch (e) {\n if (!isError(e)) {\n throw e\n }\n\n return failure(invalidValue(value, { namespace: Namespace, message: e.message }))\n }\n}\n\nexport const fromString = (value: string): PlainDate => {\n return unpackResult(parseString(value))\n}\n\nexport const fromInstant = (instant: InstantLike, zone: TimeZoneId): PlainDate => {\n return _fromInstant(instant).toZonedDateTimeISO(zone).toPlainDate()\n}\n\nexport function toLiteral(likeValue: PlainDateLike): PlainDateLiteral\nexport function toLiteral(likeValue: PlainDateLike | null): PlainDateLiteral | null\nexport function toLiteral(likeValue: PlainDateLike | undefined): PlainDateLiteral | undefined\nexport function toLiteral(likeValue: PlainDateLike | null | undefined): PlainDateLiteral | null | undefined\nexport function toLiteral(likeValue: PlainDateLike | null | undefined): PlainDateLiteral | null | undefined {\n if (isNil(likeValue)) {\n return likeValue\n }\n\n const value = from(likeValue)\n return value.toString() as PlainDateLiteral\n}\n\nexport const SchemaLiteral = structuredTransform(Zod.string(), (it: string) => mapResult(parseString(it), (it) => toLiteral(it)))\nexport const SchemaInstance = structuredTransform(Zod.string(), parseString)\n\nexport const isPlainDateTime = (value: unknown): value is PlainDate => {\n return value instanceof Temporal.PlainDateTime\n}\n\nexport const now = (zone: TimeZoneId, clock = DefaultClock): PlainDate => {\n return fromInstant(clock.instant(), zone)\n}\n\nexport const merge = (element: PlainDateLike, builder: PlainDateBuilder): PlainDate => {\n return from(element).with(builder)\n}\n\nexport const add = (element: PlainDateLike, duration: DurationLike): PlainDate => {\n return from(element).add(_fromDuration(duration))\n}\n\nexport const subtract = (element: PlainDateLike, duration: DurationLike): PlainDate => {\n return from(element).subtract(_fromDuration(duration))\n}\n\nexport const until = (element: PlainDateLike, other: PlainDateLike): Duration => {\n return from(element).until(from(other))\n}\n\nexport function isEqual(element: PlainDateLike, other: PlainDateLike): boolean\nexport function isEqual(element: PlainDateLike | null, other: PlainDateLike | null): boolean\nexport function isEqual(element: PlainDateLike | undefined, other: PlainDateLike | undefined): boolean\nexport function isEqual(element: PlainDateLike | null | undefined, other: PlainDateLike | null | undefined): boolean {\n if (isNil(element) || isNil(other)) {\n return element === other\n }\n\n return EqualBy(from(element), from(other))\n}\n\nexport const isBefore = (element: PlainDateLike, other: PlainDate): boolean => {\n return CompareBy(from(element), from(other)) < 0\n}\n\nexport const isAfter = (element: PlainDateLike, other: PlainDate): boolean => {\n return CompareBy(from(element), from(other)) > 0\n}\n\nexport type DateFormatOptions = {\n era?: 'long' | 'short' | 'narrow' | undefined\n weekday?: 'long' | 'short' | 'narrow' | undefined\n year?: 'numeric' | '2-digit' | undefined\n month?: 'numeric' | '2-digit' | 'long' | 'short' | 'narrow' | undefined\n day?: 'numeric' | '2-digit' | undefined\n}\n\nexport const format = (element: PlainDateLike, locale: Locale, options: DateFormatOptions): string => {\n const plainDate = from(element)\n\n // Convert PlainDateTime to Date\n const date = new Date(\n plainDate.year,\n plainDate.month - 1, // Date months are 0-based\n plainDate.day\n )\n\n const formatter = new Intl.DateTimeFormat(locale, options)\n return formatter.format(date)\n}\n"],"mappings":";AAAA,SAAS,gBAAgB;AACzB,SAAS,iBAAiB;AAG1B,SAAS,sBAAsB;AAC/B,SAAS,SAAS,WAAmB,eAAe;AACpD,SAAqB,cAAc,oBAAoB;AACvD,SAAS,eAAe;AACxB,SAAS,2BAA2B;AACpC,OAAO,SAAS;AAChB,SAAS,WAAW,oBAAoB;AACxC,SAAiC,QAAQ,qBAAqB;AAC9D,SAAS,QAAQ,oBAAiC;AAElD,SAAS,gBAAgB;AACzB,SAAS,aAAa;AAIf,IAAM,YAAY,UAAU,YAAY;AAcxC,SAAS,KAAK,OAAuE;AAC1F,MAAI,MAAM,KAAK,GAAG;AAChB,WAAO;AAAA,EACT;AAEA,MAAI,iBAAiB,SAAS,WAAW;AACvC,WAAO;AAAA,EACT;AAEA,MAAI,SAAS,KAAK,GAAG;AACnB,WAAO,WAAW,KAAK;AAAA,EACzB;AAEA,SAAO,SAAS,UAAU,KAAK,KAAK;AACtC;AAEO,IAAM,YAAmC,CAAC,OAAkB,WAA8B,SAAS,cAAc,QAAQ,OAAO,MAAM;AACtI,IAAM,UAAU,eAAe,SAAS;AAExC,IAAM,cAAc,CAAC,UAAiD;AAC3E,MAAI;AACF,WAAO,QAAQ,SAAS,UAAU,KAAK,KAAK,CAAC;AAAA,EAC/C,SAAS,GAAG;AACV,QAAI,CAAC,QAAQ,CAAC,GAAG;AACf,YAAM;AAAA,IACR;AAEA,WAAO,QAAQ,aAAa,OAAO,EAAE,WAAW,WAAW,SAAS,EAAE,QAAQ,CAAC,CAAC;AAAA,EAClF;AACF;AAEO,IAAM,aAAa,CAAC,UAA6B;AACtD,SAAO,aAAa,YAAY,KAAK,CAAC;AACxC;AAEO,IAAM,cAAc,CAAC,SAAsB,SAAgC;AAChF,SA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B,UAA8B;AAC5E,SAAO,UAAU,KAAK,OAAO,GAAG,KAAK,KAAK,CAAC,IAAI;AACjD;AAUO,IAAM,SAAS,CAAC,SAAwB,QAAgB,YAAuC;AACpG,QAAM,YAAY,KAAK,OAAO;AAG9B,QAAM,OAAO,IAAI;AAAA,IACf,UAAU;AAAA,IACV,UAAU,QAAQ;AAAA;AAAA,IAClB,UAAU;AAAA,EACZ;AAEA,QAAM,YAAY,IAAI,KAAK,eAAe,QAAQ,OAAO;AACzD,SAAO,UAAU,OAAO,IAAI;AAC9B;","names":["it"]}
|
@@ -38,7 +38,7 @@ export declare function toLiteral(likeValue: PlainTimeLike | null | undefined):
|
|
38
38
|
export declare const SchemaLiteral: Zod.ZodPipe<Zod.ZodString, Zod.ZodTransform<PlainTimeLiteral, string>>;
|
39
39
|
export declare const SchemaInstance: Zod.ZodPipe<Zod.ZodString, Zod.ZodTransform<Temporal.PlainTime, string>>;
|
40
40
|
export declare const isPlainTime: (value: unknown) => value is PlainTime;
|
41
|
-
export declare const now: (clock?: {
|
41
|
+
export declare const now: (zone: TimeZoneId, clock?: {
|
42
42
|
readonly zone: TimeZoneId;
|
43
43
|
instant(): import("@bessemer/cornerstone/temporal/instant").Instant;
|
44
44
|
withZone(zone: TimeZoneId): import("@bessemer/cornerstone/temporal/clock").Clock;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"plain-time.d.ts","sourceRoot":"","sources":["../../src/temporal/plain-time.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAEhD,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAA;AAE7D,OAAO,EAAsB,MAAM,EAAW,MAAM,8BAA8B,CAAA;AAClF,OAAO,EAAE,UAAU,EAA8B,MAAM,yCAAyC,CAAA;AAGhG,OAAO,GAAG,MAAM,KAAK,CAAA;AAErB,OAAO,EAAE,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,CAAA;AAED,wBAAgB,OAAO,CAAC,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,aAAa,GAAG,OAAO,CAAA;AAC9E,wBAAgB,OAAO,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,EAAE,KAAK,EAAE,aAAa,GAAG,IAAI,GAAG,OAAO,CAAA;AAC5F,wBAAgB,OAAO,CAAC,OAAO,EAAE,aAAa,GAAG,SAAS,EAAE,KAAK,EAAE,aAAa,GAAG,SAAS,GAAG,OAAO,CAAA;AAStG,eAAO,MAAM,QAAQ,GAAI,SAAS,aAAa,EAAE,OAAO,aAAa,KAAG,OAEvE,CAAA;AAED,eAAO,MAAM,OAAO,GAAI,SAAS,aAAa,EAAE,OAAO,aAAa,KAAG,OAEtE,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC9B,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;IAC5B,IAAI,CAAC,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,CAAA;IACxC,MAAM,CAAC,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,CAAA;IAC1C,MAAM,CAAC,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,CAAA;CAC3C,CAAA;AAED,eAAO,MAAM,MAAM,GAAI,SAAS,aAAa,EAAE,QAAQ,MAAM,EAAE,UAAU,iBAAiB,KAAG,MAY5F,CAAA;AAED,eAAO,MAAM,QAAQ,oBAA0B,CAAA;AAC/C,eAAO,MAAM,IAAI,oBAAqB,CAAA"}
|
@@ -61,8 +61,8 @@ var SchemaInstance = structuredTransform(Zod.string(), parseString);
|
|
61
61
|
var isPlainTime = (value) => {
|
62
62
|
return value instanceof Temporal.PlainTime;
|
63
63
|
};
|
64
|
-
var now = (clock = DefaultClock) => {
|
65
|
-
return fromInstant(clock.instant(),
|
64
|
+
var now = (zone, clock = DefaultClock) => {
|
65
|
+
return fromInstant(clock.instant(), zone);
|
66
66
|
};
|
67
67
|
var merge = (element, builder) => {
|
68
68
|
return from(element).with(builder);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/temporal/plain-time.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill'\nimport { namespace } from '@bessemer/cornerstone/resource-key'\nimport { NominalType } from '@bessemer/cornerstone/types'\nimport { Comparator } from '@bessemer/cornerstone/comparator'\nimport { fromComparator } from '@bessemer/cornerstone/equalitor'\nimport { failure, mapResult, Result, success } from '@bessemer/cornerstone/result'\nimport { ErrorEvent, invalidValue, unpackResult } from '@bessemer/cornerstone/error/error-event'\nimport { isError } from '@bessemer/cornerstone/error/error'\nimport { structuredTransform } from '@bessemer/cornerstone/zod-util'\nimport Zod from 'zod'\nimport { Default as DefaultClock } from '@bessemer/cornerstone/temporal/clock'\nimport { Duration, DurationLike, from as _fromDuration } from '@bessemer/cornerstone/temporal/duration'\nimport { from as _fromInstant, InstantLike } from '@bessemer/cornerstone/temporal/instant'\nimport { TimeZoneId } from '@bessemer/cornerstone/temporal/time-zone-id'\nimport { TimeUnit } from '@bessemer/cornerstone/temporal/chrono'\nimport { isString } from '@bessemer/cornerstone/string'\nimport { isNil } from '@bessemer/cornerstone/object'\nimport { Locale } from '@bessemer/cornerstone/intl/locale'\n\nexport type PlainTime = Temporal.PlainTime\nexport const Namespace = namespace('plain-time')\nexport type PlainTimeLiteral = NominalType<string, typeof Namespace>\nexport type PlainTimeBuilder = {\n hour?: number\n minute?: number\n second?: number\n millisecond?: number\n microsecond?: number\n nanosecond?: number\n}\nexport type PlainTimeLike = PlainTime | PlainTimeLiteral | PlainTimeBuilder\n\nexport function from(value: PlainTimeLike): PlainTime\nexport function from(value: PlainTimeLike | null): PlainTime | null\nexport function from(value: PlainTimeLike | undefined): PlainTime | undefined\nexport function from(value: PlainTimeLike | null | undefined): PlainTime | null | undefined\nexport function from(value: PlainTimeLike | null | undefined): PlainTime | null | undefined {\n if (isNil(value)) {\n return value\n }\n\n if (value instanceof Temporal.PlainTime) {\n return value\n }\n if (isString(value)) {\n return fromString(value)\n }\n\n return Temporal.PlainTime.from(value)\n}\n\nexport const CompareBy: Comparator<PlainTime> = (first: PlainTime, second: PlainTime): number => Temporal.PlainTime.compare(first, second)\nexport const EqualBy = fromComparator(CompareBy)\n\nexport const parseString = (value: string): Result<PlainTime, ErrorEvent> => {\n try {\n return success(Temporal.PlainTime.from(value))\n } catch (e) {\n if (!isError(e)) {\n throw e\n }\n\n return failure(invalidValue(value, { namespace: Namespace, message: e.message }))\n }\n}\n\nexport const fromString = (value: string): PlainTime => {\n return unpackResult(parseString(value))\n}\n\nexport const fromDuration = (duration: DurationLike): PlainTime => {\n return Midnight.add(_fromDuration(duration))\n}\n\nexport const fromInstant = (instant: InstantLike, zone: TimeZoneId): PlainTime => {\n return _fromInstant(instant).toZonedDateTimeISO(zone).toPlainTime()\n}\n\nexport function toLiteral(likeValue: PlainTimeLike): PlainTimeLiteral\nexport function toLiteral(likeValue: PlainTimeLike | null): PlainTimeLiteral | null\nexport function toLiteral(likeValue: PlainTimeLike | undefined): PlainTimeLiteral | undefined\nexport function toLiteral(likeValue: PlainTimeLike | null | undefined): PlainTimeLiteral | null | undefined\nexport function toLiteral(likeValue: PlainTimeLike | null | undefined): PlainTimeLiteral | null | undefined {\n if (isNil(likeValue)) {\n return likeValue\n }\n\n const value = from(likeValue)\n\n if (value.second === 0 && value.millisecond === 0 && value.microsecond === 0 && value.nanosecond === 0) {\n return `${value.hour.toString().padStart(2, '0')}:${value.minute.toString().padStart(2, '0')}` as PlainTimeLiteral\n }\n\n return value.toString() as PlainTimeLiteral\n}\n\nexport const SchemaLiteral = structuredTransform(Zod.string(), (it: string) => mapResult(parseString(it), (it) => toLiteral(it)))\nexport const SchemaInstance = structuredTransform(Zod.string(), parseString)\n\nexport const isPlainTime = (value: unknown): value is PlainTime => {\n return value instanceof Temporal.PlainTime\n}\n\nexport const now = (clock = DefaultClock): PlainTime => {\n return fromInstant(clock.instant(),
|
1
|
+
{"version":3,"sources":["../../src/temporal/plain-time.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill'\nimport { namespace } from '@bessemer/cornerstone/resource-key'\nimport { NominalType } from '@bessemer/cornerstone/types'\nimport { Comparator } from '@bessemer/cornerstone/comparator'\nimport { fromComparator } from '@bessemer/cornerstone/equalitor'\nimport { failure, mapResult, Result, success } from '@bessemer/cornerstone/result'\nimport { ErrorEvent, invalidValue, unpackResult } from '@bessemer/cornerstone/error/error-event'\nimport { isError } from '@bessemer/cornerstone/error/error'\nimport { structuredTransform } from '@bessemer/cornerstone/zod-util'\nimport Zod from 'zod'\nimport { Default as DefaultClock } from '@bessemer/cornerstone/temporal/clock'\nimport { Duration, DurationLike, from as _fromDuration } from '@bessemer/cornerstone/temporal/duration'\nimport { from as _fromInstant, InstantLike } from '@bessemer/cornerstone/temporal/instant'\nimport { TimeZoneId } from '@bessemer/cornerstone/temporal/time-zone-id'\nimport { TimeUnit } from '@bessemer/cornerstone/temporal/chrono'\nimport { isString } from '@bessemer/cornerstone/string'\nimport { isNil } from '@bessemer/cornerstone/object'\nimport { Locale } from '@bessemer/cornerstone/intl/locale'\n\nexport type PlainTime = Temporal.PlainTime\nexport const Namespace = namespace('plain-time')\nexport type PlainTimeLiteral = NominalType<string, typeof Namespace>\nexport type PlainTimeBuilder = {\n hour?: number\n minute?: number\n second?: number\n millisecond?: number\n microsecond?: number\n nanosecond?: number\n}\nexport type PlainTimeLike = PlainTime | PlainTimeLiteral | PlainTimeBuilder\n\nexport function from(value: PlainTimeLike): PlainTime\nexport function from(value: PlainTimeLike | null): PlainTime | null\nexport function from(value: PlainTimeLike | undefined): PlainTime | undefined\nexport function from(value: PlainTimeLike | null | undefined): PlainTime | null | undefined\nexport function from(value: PlainTimeLike | null | undefined): PlainTime | null | undefined {\n if (isNil(value)) {\n return value\n }\n\n if (value instanceof Temporal.PlainTime) {\n return value\n }\n if (isString(value)) {\n return fromString(value)\n }\n\n return Temporal.PlainTime.from(value)\n}\n\nexport const CompareBy: Comparator<PlainTime> = (first: PlainTime, second: PlainTime): number => Temporal.PlainTime.compare(first, second)\nexport const EqualBy = fromComparator(CompareBy)\n\nexport const parseString = (value: string): Result<PlainTime, ErrorEvent> => {\n try {\n return success(Temporal.PlainTime.from(value))\n } catch (e) {\n if (!isError(e)) {\n throw e\n }\n\n return failure(invalidValue(value, { namespace: Namespace, message: e.message }))\n }\n}\n\nexport const fromString = (value: string): PlainTime => {\n return unpackResult(parseString(value))\n}\n\nexport const fromDuration = (duration: DurationLike): PlainTime => {\n return Midnight.add(_fromDuration(duration))\n}\n\nexport const fromInstant = (instant: InstantLike, zone: TimeZoneId): PlainTime => {\n return _fromInstant(instant).toZonedDateTimeISO(zone).toPlainTime()\n}\n\nexport function toLiteral(likeValue: PlainTimeLike): PlainTimeLiteral\nexport function toLiteral(likeValue: PlainTimeLike | null): PlainTimeLiteral | null\nexport function toLiteral(likeValue: PlainTimeLike | undefined): PlainTimeLiteral | undefined\nexport function toLiteral(likeValue: PlainTimeLike | null | undefined): PlainTimeLiteral | null | undefined\nexport function toLiteral(likeValue: PlainTimeLike | null | undefined): PlainTimeLiteral | null | undefined {\n if (isNil(likeValue)) {\n return likeValue\n }\n\n const value = from(likeValue)\n\n if (value.second === 0 && value.millisecond === 0 && value.microsecond === 0 && value.nanosecond === 0) {\n return `${value.hour.toString().padStart(2, '0')}:${value.minute.toString().padStart(2, '0')}` as PlainTimeLiteral\n }\n\n return value.toString() as PlainTimeLiteral\n}\n\nexport const SchemaLiteral = structuredTransform(Zod.string(), (it: string) => mapResult(parseString(it), (it) => toLiteral(it)))\nexport const SchemaInstance = structuredTransform(Zod.string(), parseString)\n\nexport const isPlainTime = (value: unknown): value is PlainTime => {\n return value instanceof Temporal.PlainTime\n}\n\nexport const now = (zone: TimeZoneId, clock = DefaultClock): PlainTime => {\n return fromInstant(clock.instant(), zone)\n}\n\nexport const merge = (element: PlainTimeLike, builder: PlainTimeBuilder): PlainTime => {\n return from(element).with(builder)\n}\n\nexport const add = (element: PlainTimeLike, duration: DurationLike): PlainTime => {\n return from(element).add(_fromDuration(duration))\n}\n\nexport const subtract = (element: PlainTimeLike, duration: DurationLike): PlainTime => {\n return from(element).subtract(_fromDuration(duration))\n}\n\nexport const until = (element: PlainTimeLike, other: PlainTimeLike): Duration => {\n return from(element).until(from(other))\n}\n\nexport const round = (element: PlainTimeLike, unit: TimeUnit): PlainTime => {\n return from(element).round({ smallestUnit: unit })\n}\n\nexport function isEqual(element: PlainTimeLike, other: PlainTimeLike): boolean\nexport function isEqual(element: PlainTimeLike | null, other: PlainTimeLike | null): boolean\nexport function isEqual(element: PlainTimeLike | undefined, other: PlainTimeLike | undefined): boolean\nexport function isEqual(element: PlainTimeLike | null | undefined, other: PlainTimeLike | null | undefined): boolean {\n if (isNil(element) || isNil(other)) {\n return element === other\n }\n\n return EqualBy(from(element), from(other))\n}\n\nexport const isBefore = (element: PlainTimeLike, other: PlainTimeLike): boolean => {\n return CompareBy(from(element), from(other)) < 0\n}\n\nexport const isAfter = (element: PlainTimeLike, other: PlainTimeLike): boolean => {\n return CompareBy(from(element), from(other)) > 0\n}\n\nexport type TimeFormatOptions = {\n hour12?: boolean | undefined\n hour?: 'numeric' | '2-digit' | undefined\n minute?: 'numeric' | '2-digit' | undefined\n second?: 'numeric' | '2-digit' | undefined\n}\n\nexport const format = (element: PlainTimeLike, locale: Locale, options?: TimeFormatOptions): string => {\n const plainTime = from(element)\n\n // Create a Date at Unix epoch with the time components\n const date = new Date(1970, 0, 1, plainTime.hour, plainTime.minute, plainTime.second, plainTime.millisecond)\n\n if (isNil(options) || (isNil(options.hour) && isNil(options.minute) && isNil(options.second))) {\n options = { ...options, hour: 'numeric', minute: '2-digit', ...(plainTime.second > 0 || plainTime.millisecond > 0 ? { second: '2-digit' } : {}) }\n }\n\n const formatter = new Intl.DateTimeFormat(locale, options)\n return formatter.format(date)\n}\n\nexport const Midnight = from({ nanosecond: 0 })\nexport const Noon = from({ hour: 12 })\n"],"mappings":";AAAA,SAAS,gBAAgB;AACzB,SAAS,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