Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@storm-stack/errors

Package Overview
Dependencies
Maintainers
2
Versions
99
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@storm-stack/errors - npm Package Compare versions

Comparing version 1.2.0 to 1.2.1

1537

dist/legacy/index-beta.d.ts

@@ -1,1492 +0,153 @@

import { DestinationStream } from 'pino';
import { LoggerOptions as LoggerOptions_2 } from 'pino';
import { StormConfig } from '@storm-software/config-tools';
import { Temporal } from '@js-temporal/polyfill';
import * as z from 'zod';
/**
* The input types that can be used to create a DateTime object
* Creates a new StormError instance
*
* @param cause - The cause of the error
* @returns The newly created StormError
*/
declare type DateTimeInput =
| StormDateTime
| Temporal.Instant
| Date
| string
| number
| bigint
| null
| undefined;
declare function createStormError<TCode extends string = string>({ code, name, message, cause, stack, data }: StormErrorOptions & {
code: TCode;
}): StormError<TCode>;
export { createStormError }
export { createStormError as createStormError_alias_1 }
/**
* The options to use when creating a new DateTime object
* Deserializes a JSON object into a StormError
*
* @param error - The error to deserialize
* @returns The deserialized error
*/
declare interface DateTimeOptions {
/**
* The time zone to use. If not specified, the default time zone for the runtime is used.
*/
timeZone?: Temporal.TimeZoneLike;
declare function deserializeStormError(json: JsonValue): StormError;
export { deserializeStormError }
export { deserializeStormError as deserializeStormError_alias_1 }
export { deserializeStormError as deserializeStormError_alias_2 }
/**
* The calendar to use. If not specified, the default calendar for the runtime is used.
*/
calendar?: Temporal.CalendarLike;
declare type ErrorCode = "success" | "missing_issue_code" | "invalid_config" | "failed_to_load_file" | "missing_context" | "record_not_found" | "required_field_missing" | "database_query_error" | "model_validation_error" | "field_validation_error" | "invalid_parameter" | "invalid_request" | "type_error" | "processing_error" | "internal_server_error" | "user_not_logged_in" | "unknown_cause";
/**
* If false, the current date and time is defaulted when undefined or null is passed. If true, the current date and time is not defaulted.
*
* @default false
*/
skipDefaulting?: boolean;
}
declare const ErrorCode: {
success: ErrorCode;
missing_issue_code: ErrorCode;
invalid_config: ErrorCode;
failed_to_load_file: ErrorCode;
missing_context: ErrorCode;
record_not_found: ErrorCode;
required_field_missing: ErrorCode;
database_query_error: ErrorCode;
model_validation_error: ErrorCode;
field_validation_error: ErrorCode;
invalid_parameter: ErrorCode;
invalid_request: ErrorCode;
type_error: ErrorCode;
processing_error: ErrorCode;
internal_server_error: ErrorCode;
user_not_logged_in: ErrorCode;
unknown_cause: ErrorCode;
};
export { ErrorCode }
export { ErrorCode as ErrorCode_alias_1 }
/**
* Convert the log level label to a log level
* Gets the cause of an unknown error and returns it as a StormError
*
* @param label - The log level label to convert
* @returns The log level
* @param cause - The cause of the error in an unknown type
* @returns The cause of the error in a StormError object or undefined
*/
export declare const getLogLevel: (label: string) => LogLevel;
declare function getCauseFromUnknown(cause: unknown): StormError;
export { getCauseFromUnknown }
export { getCauseFromUnknown as getCauseFromUnknown_alias_1 }
/**
* Convert the log level to a log level label
* Type-check to determine if `obj` is a `StormError` object
*
* @param logLevel - The log level to convert
* @returns The log level label
* @param value - the object to check
* @returns The function isStormError is returning a boolean value.
*/
export declare const getLogLevelLabel: (logLevel: number) => LogLevelLabel;
declare function isStormError<TCode extends string = any>(value: unknown): value is StormError<TCode>;
export { isStormError }
export { isStormError as isStormError_alias_1 }
export { isStormError as isStormError_alias_2 }
/**
* Get the Pino transports for the logger
*
* @param config - The workspace config
* @param name - The name of the logger to get the options for
* @returns The options for the logger
*/
declare const getTransports: (config: StormConfig<"logging", LoggingConfig>, name?: string) => any;
export { getTransports }
export { getTransports as getTransports_alias_1 }
export { getTransports as getTransports_alias_2 }
declare interface JsonArray extends Array<JsonValue> {}
declare interface ILogger {
/**
* Write a success message to the logs.
*
* @param message - The message to print.
* @returns Either a promise that resolves to void or void.
*/
success?: (message: string) => MaybePromise<void>;
/**
* Write a fatal message to the logs.
*
* @param message - The fatal message to be displayed.
* @returns Either a promise that resolves to void or void.
*/
fatal?: (message: string) => MaybePromise<void>;
/**
* Write an error message to the logs.
*
* @param message - The message to be displayed.
* @returns Either a promise that resolves to void or void.
*/
error: (message: string) => MaybePromise<void>;
/**
* Write an exception message to the logs.
*
* @param message - The message to be displayed.
* @returns Either a promise that resolves to void or void.
*/
exception?: (message: string) => MaybePromise<void>;
/**
* Write a warning message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
warn: (message: string) => MaybePromise<void>;
/**
* Write an informational message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
info: (message: string) => MaybePromise<void>;
/**
* Write a debug message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
debug?: (message: string) => MaybePromise<void>;
/**
* Write a trace message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
trace?: (message: string) => MaybePromise<void>;
/**
* Write an informational message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
log?: (message: string) => MaybePromise<void>;
declare interface JsonObject {
[key: string]: JsonValue;
}
export { ILogger }
export { ILogger as ILogger_alias_1 }
declare interface ILoggerWrapper {
/**
* Write a success message to the logs.
*
* @param message - The message to print.
* @returns Either a promise that resolves to void or void.
*/
success: (message: any) => MaybePromise<void>;
/**
* Write a fatal message to the logs.
*
* @param message - The fatal message to be displayed.
* @returns Either a promise that resolves to void or void.
*/
fatal: (error: string | Error) => MaybePromise<void>;
/**
* Write an error message to the logs.
*
* @param message - The message to be displayed.
* @returns Either a promise that resolves to void or void.
*/
error: (error: string | Error) => MaybePromise<void>;
/**
* Write an exception message to the logs.
*
* @param message - The message to be displayed.
* @returns Either a promise that resolves to void or void.
*/
exception: (error: string | Error) => MaybePromise<void>;
/**
* Write a warning message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
warn: (message: any) => MaybePromise<void>;
/**
* Write an informational message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
info: (message: any) => MaybePromise<void>;
/**
* Write a debug message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
debug: (message: any) => MaybePromise<void>;
/**
* Write a trace message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
trace: (message: any) => MaybePromise<void>;
/**
* Write an informational message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
log: (message: any) => MaybePromise<void>;
}
export { ILoggerWrapper }
export { ILoggerWrapper as ILoggerWrapper_alias_1 }
declare type JsonValue = PrimitiveJsonValue | JsonArray | JsonObject;
declare interface IStormLog {
/**
* Write a success message to the logs.
*
* @param message - The message to print.
* @returns Either a promise that resolves to void or void.
*/
success: (...message: any[]) => MaybePromise<void>;
/**
* Write a fatal message to the logs.
*
* @param message - The fatal message to be displayed.
* @returns Either a promise that resolves to void or void.
*/
fatal: (...message: any[]) => MaybePromise<void>;
/**
* Write an error message to the logs.
*
* @param message - The message to be displayed.
* @returns Either a promise that resolves to void or void.
*/
error: (...message: any[]) => MaybePromise<void>;
/**
* Write an exception message to the logs.
*
* @param message - The message to be displayed.
* @returns Either a promise that resolves to void or void.
*/
exception: (...message: any[]) => MaybePromise<void>;
/**
* Write a warning message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
warn: (...message: any[]) => MaybePromise<void>;
/**
* Write an informational message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
info: (...message: any[]) => MaybePromise<void>;
/**
* Write a debug message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
debug: (...message: any[]) => MaybePromise<void>;
/**
* Write a trace message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
trace: (...message: any[]) => MaybePromise<void>;
/**
* Write an informational message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
log: (...message: any[]) => MaybePromise<void>;
}
export { IStormLog }
export { IStormLog as IStormLog_alias_1 }
declare type PrimitiveJsonValue = string | number | boolean | undefined | null;
declare type LoggerOptions = {
options: LoggerOptions_2;
stream?: DestinationStream;
};
export { LoggerOptions }
export { LoggerOptions as LoggerOptions_alias_1 }
export { LoggerOptions as LoggerOptions_alias_2 }
/**
* A wrapper for a logger class.
* Serializes a StormError into a JSON object
*
* @param error - The error to serialize
* @returns The serialized error
*/
declare class LoggerWrapper implements ILoggerWrapper {
#private;
/**
* Wrap a logger.
*
* @param logger - The logger to wrap.
* @param config - The logging configuration.
* @param name - The logger's name.
* @returns The wrapped logger.
*/
static wrap: (logger: ILogger, config: LoggingConfig, name?: string) => LoggerWrapper;
private constructor();
/**
* Write a success message to the logs.
*
* @param message - The message to print.
* @returns Either a promise that resolves to void or void.
*/
success: (message: string) => MaybePromise<void>;
/**
* Write a fatal message to the logs.
*
* @param error - The fatal message to be displayed.
* @returns Either a promise that resolves to void or void.
*/
fatal: (error: string | Error) => MaybePromise<void>;
/**
* Write an error message to the logs.
*
* @param error - The message to be displayed.
* @returns Either a promise that resolves to void or void.
*/
exception: (error: string | Error) => MaybePromise<void>;
/**
* Write an error message to the logs.
*
* @param error - The message to be displayed.
* @returns Either a promise that resolves to void or void.
*/
error: (error: string | Error) => MaybePromise<void>;
/**
* Write a warning message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
warn: (message: string) => MaybePromise<void>;
/**
* Write an informational message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
info: (message: string) => MaybePromise<void>;
/**
* Write a debug message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
debug: (message: string) => MaybePromise<void>;
/**
* Write a trace message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
trace: (message: string) => MaybePromise<void>;
/**
* Write a log message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
log: (message: string) => MaybePromise<void>;
/**
* Format an error message.
*
* @param obj - The error to format.
* @returns The formatted error message.
*/
protected getErrorMessage: (obj?: string | Error | null) => string;
}
export { LoggerWrapper }
export { LoggerWrapper as LoggerWrapper_alias_1 }
export { LoggerWrapper as LoggerWrapper_alias_2 }
declare function serializeStormError(error: StormError): JsonValue;
export { serializeStormError }
export { serializeStormError as serializeStormError_alias_1 }
export { serializeStormError as serializeStormError_alias_2 }
declare type LoggingConfig = z.infer<typeof LoggingConfigSchema>;
export { LoggingConfig }
export { LoggingConfig as LoggingConfig_alias_1 }
/**
* Storm base schema used to represent a package's config (either workspace or project)
*/
export declare const LoggingConfigSchema: z.ZodObject<{
stacktrace: z.ZodOptional<z.ZodBoolean>;
fileName: z.ZodDefault<z.ZodOptional<z.ZodString>>;
fileExtension: z.ZodDefault<z.ZodString>;
path: z.ZodOptional<z.ZodString>;
loki: z.ZodOptional<z.ZodObject<{
host: z.ZodDefault<z.ZodString>;
username: z.ZodString;
password: z.ZodString;
}, "strip", z.ZodTypeAny, {
host: string;
username: string;
password: string;
}, {
username: string;
password: string;
host?: string | undefined;
}>>;
}, "strip", z.ZodTypeAny, {
fileName: string;
fileExtension: string;
stacktrace?: boolean | undefined;
path?: string | undefined;
loki?: {
host: string;
username: string;
password: string;
} | undefined;
}, {
stacktrace?: boolean | undefined;
fileName?: string | undefined;
fileExtension?: string | undefined;
path?: string | undefined;
loki?: {
username: string;
password: string;
host?: string | undefined;
} | undefined;
}>;
export declare type LogLevel = 0 | 10 | 20 | 30 | 40 | 60 | 70;
export declare const LogLevel: {
readonly SILENT: LogLevel;
readonly FATAL: LogLevel;
readonly ERROR: LogLevel;
readonly WARN: LogLevel;
readonly INFO: LogLevel;
readonly DEBUG: LogLevel;
readonly TRACE: LogLevel;
};
export declare type LogLevelLabel = "silent" | "fatal" | "error" | "warn" | "info" | "debug" | "trace";
export declare const LogLevelLabel: {
readonly SILENT: LogLevelLabel;
readonly FATAL: LogLevelLabel;
readonly ERROR: LogLevelLabel;
readonly WARN: LogLevelLabel;
readonly INFO: LogLevelLabel;
readonly DEBUG: LogLevelLabel;
readonly TRACE: LogLevelLabel;
};
/**
* Storm schema used to represent a the required config needed to use Loki
*/
export declare const LokiConfigSchema: z.ZodObject<{
host: z.ZodDefault<z.ZodString>;
username: z.ZodString;
password: z.ZodString;
}, "strip", z.ZodTypeAny, {
host: string;
username: string;
password: string;
}, {
username: string;
password: string;
host?: string | undefined;
}>;
declare type MaybePromise<T> = T | Promise<T>;
/**
* A wrapper of the and Date class used by Storm Software to provide Date-Time values
* A wrapper around the base JavaScript Error class to be used by Storm Software
*
* @decorator `@Serializable()`
*/
declare @Serializable({
serialize: serializeStormDateTime,
deserialize: deserializeStormDateTime
})
class StormDateTime extends Date {
/**
* The current function returns a new StormDateTime object with the current date and time
* @returns A new instance of StormDateTime with the current date and time.
*/
public static override now(): number {
return StormDateTime.current().epochMilliseconds;
}
/**
* The current function returns a new StormDateTime object with the current date and time
* @returns A new instance of StormDateTime with the current date and time.
*/
public static current(): StormDateTime {
return StormDateTime.create(Temporal.Now.instant());
}
/**
* Creates a new instance of StormDateTime from a string with a specified format.
*
* @param dateTime - The input value used to determine the current date and time
* @param options - The options to use when creating the StormDateTime object
* @returns A new instance of StormDateTime with the current date and time.
*/
public static create = (
dateTime?: DateTimeInput,
options?: DateTimeOptions
) =>
new StormDateTime(dateTime, {
timeZone:
(isDateTime(dateTime) ? dateTime.timeZoneId : options?.timeZone) ??
process.env.STORM_TIMEZONE ??
Temporal.Now.timeZoneId(),
calendar: isDateTime(dateTime) ? dateTime.calendarId : options?.calendar
});
/**
* A private accessor that stores the `Temporal.Instant` object of the DateTime object
*/
#instant: Temporal.Instant = Temporal.Now.instant();
/**
* A private accessor that stores the `Temporal.ZonedDateTime` object of the DateTime object
*/
#zonedDateTime: Temporal.ZonedDateTime = Temporal.Now.zonedDateTime(
process.env.STORM_TIMEZONE ?? Temporal.Now.timeZoneId()
);
/**
* A private accessor that stores the input value used to create the DateTime object
*/
#input: DateTimeInput;
/**
* A private accessor that stores the options used to create the DateTime object
*/
#options: DateTimeOptions;
public constructor(dateTime?: DateTimeInput, options?: DateTimeOptions) {
const input = dateTime;
if (!dateTime && !options?.skipDefaulting) {
dateTime = Temporal.Now.instant();
}
const instant = !dateTime
? undefined
: isDateTime(dateTime)
? dateTime.instant
: Temporal.Instant.from(
isDate(dateTime)
? dateTime.toJSON()
: isNumber(dateTime) || isBigInt(dateTime)
? new Date(Number(dateTime)).toISOString()
: dateTime
);
super(instant ? Number(instant.epochMilliseconds) : "MISSING_DATE");
if (instant && this.validate(dateTime, options)) {
this.#instant = instant;
const timeZone = options?.timeZone
? options?.timeZone
: process.env.TZ
? process.env.TZ
: Temporal.Now.timeZoneId();
this.#zonedDateTime = options?.calendar
? this.#instant.toZonedDateTime({
timeZone,
calendar: options.calendar
})
: this.#instant.toZonedDateTimeISO(timeZone);
}
this.#input = input;
this.#options = options ?? {};
}
/**
* An accessor that returns the epoch milliseconds of the DateTime object
*/
public get epochMilliseconds(): number {
return this.instant.epochMilliseconds;
}
/**
* An accessor that returns the `Temporal.Instant` object of the DateTime object
*/
public get instant(): Temporal.Instant {
return this.#instant;
}
/**
* An accessor that sets the `Temporal.Instant` object of the DateTime object
*/
protected set instant(_instant: Temporal.Instant) {
this.#instant = _instant;
}
/**
* An accessor that returns the `Temporal.ZonedDateTime` object of the DateTime object
*/
public get zonedDateTime(): Temporal.ZonedDateTime {
return this.#zonedDateTime;
}
/**
* An accessor that sets the `Temporal.ZonedDateTime` object of the DateTime object
*/
protected set zonedDateTime(_zonedDateTime: Temporal.ZonedDateTime) {
this.#zonedDateTime = _zonedDateTime;
}
/**
* An accessor that returns the `calendarId` string of the DateTime object
*/
public get calendarId(): string {
return this.#zonedDateTime.calendarId;
}
/**
* An accessor that returns the `timeZoneId` string of the DateTime object
*/
public get timeZoneId(): string {
return this.#zonedDateTime.timeZoneId;
}
/**
* An accessor that returns the `isValid` boolean of the DateTime object
*/
public get isValid(): boolean {
return this.validate(this.#zonedDateTime.epochMilliseconds, this.#options);
}
/**
* Returns the input value used to create the DateTime object
*/
public get input(): DateTimeInput {
return this.#input;
}
/**
* Returns the options used to create the DateTime object
*/
public get options(): DateTimeOptions {
return this.#options;
}
/**
* Validate the input date value
*
* @param dateTime - The date value to validate
* @param options - The options to use
* @returns A boolean representing whether the value is a valid *date-time*
*/
protected validate(
dateTime?: DateTimeInput,
options?: DateTimeOptions
): boolean {
return validateDateTime(dateTime, options);
}
/**
* Returns the stored time value in milliseconds since midnight, January 1, 1970 UTC.
*/
public override getTime(): number {
return this.epochMilliseconds;
}
/**
* Gets the year, using local time.
*/
public override getFullYear(): number {
return this.#zonedDateTime.year;
}
/**
* Gets the year using Universal Coordinated Time (UTC).
*/
public override getUTCFullYear(): number {
return this.#instant.toZonedDateTimeISO("UTC").year;
}
/**
* Gets the month, using local time.
*/
public override getMonth(): number {
return this.#zonedDateTime.month;
}
/**
* Gets the month of a Date object using Universal Coordinated Time (UTC).
*/
public override getUTCMonth(): number {
return this.#instant.toZonedDateTimeISO("UTC").month;
}
/**
* Gets the day-of-the-month, using local time.
*/
public override getDate(): number {
return this.#zonedDateTime.day;
}
/**
* Gets the day-of-the-month, using Universal Coordinated Time (UTC).
*/
public override getUTCDate(): number {
return this.#instant.toZonedDateTimeISO("UTC").day;
}
/**
* Gets the day of the week, using local time.
*/
public override getDay(): number {
return this.#zonedDateTime.dayOfWeek;
}
/**
* Gets the day of the week using Universal Coordinated Time (UTC).
*/
public override getUTCDay(): number {
return this.#instant.toZonedDateTimeISO("UTC").dayOfWeek;
}
/**
* Gets the hours in a date, using local time.
*/
public override getHours(): number {
return this.#zonedDateTime.hour;
}
/**
* Gets the hours value in a Date object using Universal Coordinated Time (UTC).
*/
public override getUTCHours(): number {
return this.#instant.toZonedDateTimeISO("UTC").hour;
}
/**
* Gets the minutes of a Date object, using local time.
*/
public override getMinutes(): number {
return this.#zonedDateTime.minute;
}
/**
* Gets the minutes of a Date object using Universal Coordinated Time (UTC).
*/
public override getUTCMinutes(): number {
return this.#instant.toZonedDateTimeISO("UTC").minute;
}
/**
* Gets the seconds of a Date object, using local time.
*/
public override getSeconds(): number {
return this.#zonedDateTime.second;
}
/**
* Gets the seconds of a Date object using Universal Coordinated Time (UTC).
*/
public override getUTCSeconds(): number {
return this.#instant.toZonedDateTimeISO("UTC").second;
}
/**
* Gets the milliseconds of a Date, using local time.
*/
public override getMilliseconds(): number {
return this.#zonedDateTime.millisecond;
}
/**
* Gets the milliseconds of a Date object using Universal Coordinated Time (UTC).
*/
public override getUTCMilliseconds(): number {
return this.#instant.toZonedDateTimeISO("UTC").millisecond;
}
/**
* Gets the difference in minutes between the time on the local computer and Universal Coordinated Time (UTC).
*/
public override getTimezoneOffset(): number {
return this.#zonedDateTime.offsetNanoseconds / 1000000;
}
/**
* Sets the date and time value in the Date object.
* @param time - A numeric value representing the number of elapsed milliseconds since midnight, January 1, 1970 GMT.
*/
public override setTime(time: number): number {
this.#zonedDateTime = this.#zonedDateTime.add({
milliseconds: time - this.epochMilliseconds
});
this.#instant = this.#zonedDateTime.toInstant();
return super.setTime(this.#instant.epochMilliseconds);
}
/**
* Sets the milliseconds value in the Date object using local time.
* @param millisecond - A numeric value equal to the millisecond value.
*/
public override setMilliseconds(millisecond: number): number {
this.#zonedDateTime = this.#zonedDateTime.with({ millisecond });
this.#instant = this.#zonedDateTime.toInstant();
return super.setMilliseconds(
this.#instant.toZonedDateTimeISO("UTC").millisecond
);
}
/**
* Sets the milliseconds value in the Date object using Universal Coordinated Time (UTC).
* @param millisecond - A numeric value equal to the millisecond value.
*/
public override setUTCMilliseconds(millisecond: number): number {
this.#instant = this.#instant
.toZonedDateTimeISO("UTC")
.with({ millisecond })
.toInstant();
this.#zonedDateTime = this.#instant.toZonedDateTime({
timeZone: this.timeZoneId,
calendar: this.calendarId
});
return super.setUTCMilliseconds(
this.#instant.toZonedDateTimeISO("UTC").millisecond
);
}
/**
* Sets the seconds value in the Date object using local time.
* @param second - A numeric value equal to the seconds value.
* @param millisecond - A numeric value equal to the milliseconds value.
*/
public override setSeconds(second: number, millisecond?: number): number {
this.#zonedDateTime = this.#zonedDateTime.with({ second, millisecond });
this.#instant = this.#zonedDateTime.toInstant();
return super.setSeconds(
this.#zonedDateTime.second,
this.#zonedDateTime.millisecond
);
}
/**
* Sets the seconds value in the Date object using Universal Coordinated Time (UTC).
* @param second - A numeric value equal to the seconds value.
* @param millisecond - A numeric value equal to the milliseconds value.
*/
public override setUTCSeconds(second: number, millisecond?: number): number {
this.#instant = this.#instant
.toZonedDateTimeISO("UTC")
.with({ second, millisecond })
.toInstant();
this.#zonedDateTime = this.#instant.toZonedDateTime({
timeZone: this.timeZoneId,
calendar: this.calendarId
});
const utcDateTime = this.#instant.toZonedDateTimeISO("UTC");
return super.setUTCSeconds(utcDateTime.second, utcDateTime.millisecond);
}
/**
* Sets the minutes value in the Date object using local time.
* @param minute - A numeric value equal to the minutes value.
* @param second - A numeric value equal to the seconds value.
* @param millisecond - A numeric value equal to the milliseconds value.
*/
public override setMinutes(
minute: number,
second?: number,
millisecond?: number
): number {
this.#zonedDateTime = this.#zonedDateTime.with({
minute,
second,
millisecond
});
this.#instant = this.#zonedDateTime.toInstant();
return super.setMinutes(
this.#zonedDateTime.minute,
this.#zonedDateTime.second,
this.#zonedDateTime.millisecond
);
}
/**
* Sets the minutes value in the Date object using Universal Coordinated Time (UTC).
* @param minute - A numeric value equal to the minutes value.
* @param second - A numeric value equal to the seconds value.
* @param millisecond - A numeric value equal to the milliseconds value.
*/
public override setUTCMinutes(
minute: number,
second?: number,
millisecond?: number
): number {
this.#instant = this.#instant
.toZonedDateTimeISO("UTC")
.with({ minute, second, millisecond })
.toInstant();
this.#zonedDateTime = this.#instant.toZonedDateTime({
timeZone: this.timeZoneId,
calendar: this.calendarId
});
const utcDateTime = this.#instant.toZonedDateTimeISO("UTC");
return super.setUTCMinutes(
utcDateTime.minute,
utcDateTime.second,
utcDateTime.millisecond
);
}
/**
* Sets the hour value in the Date object using local time.
*
* @param hour - A numeric value equal to the hours value.
* @param minute - A numeric value equal to the minutes value.
* @param second - A numeric value equal to the seconds value.
* @param millisecond - A numeric value equal to the milliseconds value.
*/
public override setHours(
hour: number,
minute: number,
second?: number,
millisecond?: number
): number {
this.#zonedDateTime = this.#zonedDateTime.with({
hour,
minute,
second,
millisecond
});
this.#instant = this.#zonedDateTime.toInstant();
return super.setHours(
this.#zonedDateTime.hour,
this.#zonedDateTime.minute,
this.#zonedDateTime.second,
this.#zonedDateTime.millisecond
);
}
/**
* Sets the hours value in the Date object using Universal Coordinated Time (UTC).
*
* @param hour - A numeric value equal to the hours value.
* @param minute - A numeric value equal to the minutes value.
* @param second - A numeric value equal to the seconds value.
* @param millisecond - A numeric value equal to the milliseconds value.
*/
public override setUTCHours(
hour: number,
minute: number,
second?: number,
millisecond?: number
): number {
this.#instant = this.#instant
.toZonedDateTimeISO("UTC")
.with({ hour, minute, second, millisecond })
.toInstant();
this.#zonedDateTime = this.#instant.toZonedDateTime({
timeZone: this.timeZoneId,
calendar: this.calendarId
});
const utcDateTime = this.#instant.toZonedDateTimeISO("UTC");
return super.setUTCHours(
utcDateTime.hour,
utcDateTime.minute,
utcDateTime.second,
utcDateTime.millisecond
);
}
/**
* Sets the numeric day-of-the-month value of the Date object using local time.
*
* @param day - A numeric value equal to the day of the month.
*/
public override setDate(day: number): number {
this.#zonedDateTime = this.#zonedDateTime.with({
day
});
this.#instant = this.#zonedDateTime.toInstant();
return super.setDate(this.#zonedDateTime.day);
}
/**
* Sets the numeric day of the month in the Date object using Universal Coordinated Time (UTC).
*
* @param day - A numeric value equal to the day of the month.
*/
public override setUTCDate(day: number): number {
this.#instant = this.#instant
.toZonedDateTimeISO("UTC")
.with({ day })
.toInstant();
this.#zonedDateTime = this.#instant.toZonedDateTime({
timeZone: this.timeZoneId,
calendar: this.calendarId
});
return super.setUTCDate(this.#instant.toZonedDateTimeISO("UTC").day);
}
/**
* Sets the month value in the Date object using local time.
*
* @param month - A numeric value equal to the month. The value for January is 0, and other month values follow consecutively.
* @param day - A numeric value representing the day of the month. If this value is not supplied, the value from a call to the getDate method is used.
*/
public override setMonth(month: number, day?: number): number {
this.#zonedDateTime = this.#zonedDateTime.with({ month, day });
this.#instant = this.#zonedDateTime.toInstant();
return super.setMonth(this.#zonedDateTime.month, this.#zonedDateTime.day);
}
/**
* Sets the month value in the Date object using Universal Coordinated Time (UTC).
*
* @param month - A numeric value equal to the month. The value for January is 0, and other month values follow consecutively.
* @param day - A numeric value representing the day of the month. If it is not supplied, the value from a call to the getUTCDate method is used.
*/
public override setUTCMonth(month: number, day?: number): number {
this.#instant = this.#instant
.toZonedDateTimeISO("UTC")
.with({ month, day })
.toInstant();
this.#zonedDateTime = this.#instant.toZonedDateTime({
timeZone: this.timeZoneId,
calendar: this.calendarId
});
const utcDateTime = this.#instant.toZonedDateTimeISO("UTC");
return super.setUTCMonth(utcDateTime.month, utcDateTime.day);
}
/**
* Sets the year of the Date object using local time.
* @param year - A numeric value for the year.
* @param month - A zero-based numeric value for the month (0 for January, 11 for December). Must be specified if numDate is specified.
* @param day - A numeric value equal for the day of the month.
*/
public override setFullYear(
year: number,
month?: number,
day?: number
): number {
this.#zonedDateTime = this.#zonedDateTime.with({ year, month, day });
this.#instant = this.#zonedDateTime.toInstant();
return super.setFullYear(
this.#zonedDateTime.year,
this.#zonedDateTime.month,
this.#zonedDateTime.day
);
}
/**
* Sets the year value in the Date object using Universal Coordinated Time (UTC).
*
* @param year - A numeric value equal to the year.
* @param month - A numeric value equal to the month. The value for January is 0, and other month values follow consecutively. Must be supplied if numDate is supplied.
* @param day - A numeric value equal to the day of the month.
*/
public override setUTCFullYear(
year: number,
month?: number,
day?: number
): number {
this.#instant = this.#instant
.toZonedDateTimeISO("UTC")
.with({ year, month, day })
.toInstant();
this.#zonedDateTime = this.#instant.toZonedDateTime({
timeZone: this.timeZoneId,
calendar: this.calendarId
});
const utcDateTime = this.#instant.toZonedDateTimeISO("UTC");
return super.setUTCFullYear(
utcDateTime.year,
utcDateTime.month,
utcDateTime.day
);
}
/**
* It returns a plain date object from a DateTime object
*
* @returns A PlainDate object.
*/
public getPlainDate(): StormDateTime {
return StormDateTime.create(
this.#zonedDateTime.toPlainDate().toZonedDateTime({
timeZone: Temporal.Now.timeZoneId(),
plainTime: undefined
}).epochMilliseconds,
{
timeZone: this.#zonedDateTime.timeZoneId,
calendar: this.#zonedDateTime.calendarId
}
);
}
/**
* `getPlainTime` returns a `PlainTime` object from a `DateTime` object
*
* @returns A PlainTime object.
*/
public getPlainTime(): StormDateTime {
return StormDateTime.create(
this.#zonedDateTime.toPlainTime().toZonedDateTime({
timeZone: Temporal.Now.timeZoneId(),
plainDate: Temporal.PlainDate.from({
year: 1970,
month: 0,
day: 1
})
}).epochMilliseconds,
{
timeZone: this.#zonedDateTime.timeZoneId,
calendar: this.#zonedDateTime.calendarId
}
);
}
/**
* It returns the duration between two dates.
*
* @param dateTimeTo - DateTime = DateTime.current
* @returns A duration object.
*/
public since(
dateTimeTo: StormDateTime = StormDateTime.current()
): Temporal.Duration {
return this.#instant.since(dateTimeTo.instant);
}
/**
* It returns the duration between two date times.
*
* @param dateTimeTo - DateTime = DateTime.current
* @returns A duration object.
*/
public getDuration(
dateTimeTo: StormDateTime = StormDateTime.current()
): Temporal.Duration {
return this.instant.since(dateTimeTo.instant);
}
}
/**
* The default logger class.
*
* @remarks
* This logger writes to the console.
*/
declare class StormLog implements IStormLog {
declare class StormError<TCode extends string = string> extends Error {
#private;
private static logger;
private static logLevel;
private static logLevelLabel;
private static getLoggers;
__proto__: ErrorConstructor;
/**
* Initialize the logger.
*
* @param config - The Storm config
* @param name - The name of the project to initialized the loggers for
* @returns The initialized loggers
* The error code
*/
private static initialize;
code: TCode;
/**
* The Singleton's constructor should always be private to prevent direct
* construction calls with the `new` operator.
* The cause of the error
*/
private constructor();
cause?: StormError;
/**
* Create a new instance of the logger
*
* @param config - The Storm config
* @param name - The name of the project to initialized the loggers for
* @param additionalLoggers - Additional loggers to use
* @returns The initialized logger
* Additional data to be passed with the error
*/
static create(config: StormConfig<"logging", LoggingConfig>, name?: string, additionalLoggers?: ILoggerWrapper[]): StormLog;
data?: any;
constructor(code: TCode, { name, message, cause, stack, data }?: StormErrorOptions);
/**
* Write a success message to the logs.
* Prints a displayable, formatted the stack trace
*
* @param message - The message to print.
* @returns Either a promise that resolves to void or void.
* @returns The stack trace string
*/
static success(message: any): void;
get stack(): string;
/**
* Write a fatal message to the logs.
*
* @param message - The fatal message to be displayed.
* @returns Either a promise that resolves to void or void.
* Store the stack trace
*/
static fatal(message: any): void;
set stack(_stack: string);
/**
* Write an error message to the logs.
* The unformatted stack trace
*
* @param message - The message to be displayed.
* @returns Either a promise that resolves to void or void.
* @returns The stack trace string
*/
static error(message: any): void;
get originalStack(): string;
/**
* Write an exception message to the logs.
* Prints the display error message string
*
* @param message - The message to be displayed.
* @returns Either a promise that resolves to void or void.
* @returns The display error message string
*/
static exception(message: any): void;
print(): string;
/**
* Write a warning message to the logs.
* Prints the error message and stack trace
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
* @returns The error message and stack trace string
*/
static warn(message: any): void;
/**
* Write an informational message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
static info(message: any): void;
/**
* Write a debug message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
static debug(message: any): void;
/**
* Write a trace message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
static trace(message: any): void;
/**
* Write an informational message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
static log(message: any): void;
/**
* Write an message to the logs specifying how long it took to complete a process
* @param startTime - The start time of the process
* @param name - The name of the process
*/
static stopwatch(startTime: StormTime, name?: string): void;
/**
* Write a success message to the logs.
*
* @param message - The message to print.
* @returns Either a promise that resolves to void or void.
*/
success(message: any): void;
/**
* Write a fatal message to the logs.
*
* @param message - The fatal message to be displayed.
* @returns Either a promise that resolves to void or void.
*/
fatal(message: any): void;
/**
* Write an error message to the logs.
*
* @param message - The message to be displayed.
* @returns Either a promise that resolves to void or void.
*/
error(message: any): void;
/**
* Write an exception message to the logs.
*
* @param message - The message to be displayed.
* @returns Either a promise that resolves to void or void.
*/
exception(message: any): void;
/**
* Write a warning message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
warn(message: any): void;
/**
* Write an informational message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
info(message: any): void;
/**
* Write a debug message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
debug(message: any): void;
/**
* Write a trace message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
trace(message: any): void;
/**
* Write an informational message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
log(message: any): void;
/**
* Start a process
*
* @param name - The name of the process
*/
start(name: string): void;
/**
* Write an message to the logs specifying how long it took to complete a process
*
* @param name - The name of the process
* @param startTime - The start time of the process
*/
stopwatch(name?: string, startTime?: StormTime): void;
/**
* Add a logger wrapper to the internal loggers list
*
* @param wrapper - The logger wrapper to use
*/
addWrappedLogger(wrapper: ILoggerWrapper): void;
/**
* Add a logger to the internal loggers list
*
* @param logger - The logger to add
*/
addLogger(logger: ILogger): void;
toString(): string;
}
export { StormLog }
export { StormLog as StormLog_alias_1 }
export { StormError }
export { StormError as StormError_alias_1 }
/**
* A wrapper of the and Date class used by Storm Software to provide Date-Time values
*
* @decorator `@Serializable()`
*/
declare @Serializable({
serialize: serializeStormTime,
deserialize: deserializeStormTime
})
class StormTime extends StormDateTime {
/**
* The current function returns a new DateTime object with the current date and time
* @returns A new instance of DateTime with the current date and time.
*/
public static override now(): number {
return StormDateTime.current().epochMilliseconds;
}
/**
* The current function returns a new DateTime object with the current date and time
* @returns A new instance of DateTime with the current date and time.
*/
public static override current(): StormTime {
return StormTime.create(Temporal.Now.instant());
}
/**
* Creates a new instance of DateTime from a string with a specified format.
*
* @param time - The input value used to determine the current time
* @param options - The options to use
* @returns A new instance of StormTime with the time provided in the time parameter.
*/
public static override create = (
time?: DateTimeInput,
options?: DateTimeOptions
) =>
new StormTime(time, {
timeZone:
(isDateTime(time) ? time.timeZoneId : options?.timeZone) ??
Temporal.Now.timeZoneId(),
calendar: isDateTime(time) ? time.calendarId : options?.calendar
});
public constructor(dateTime?: DateTimeInput, options?: DateTimeOptions) {
super(dateTime, options);
this.instant = this.instant
.toZonedDateTimeISO("UTC")
.with({
year: 1970,
month: 1,
day: 1
})
.toInstant();
this.zonedDateTime = this.zonedDateTime.with({
year: 1970,
month: 1,
day: 1
});
}
/**
* Validate the input time value
*
* @param dateTime - The date value to validate
* @param options - The options to use
* @returns A boolean representing whether the value is a valid *date-time*
*/
protected override validate(
dateTime?: DateTimeInput,
options?: DateTimeOptions
): boolean {
return validateTime(dateTime, options);
}
/**
* Gets the year, using local time.
*/
public override getFullYear(): number {
return 1970;
}
/**
* Gets the year using Universal Coordinated Time (UTC).
*/
public override getUTCFullYear(): number {
return 1970;
}
/**
* Gets the month, using local time.
*/
public override getMonth(): number {
return 1;
}
/**
* Gets the month of a Date object using Universal Coordinated Time (UTC).
*/
public override getUTCMonth(): number {
return 1;
}
/**
* Gets the day-of-the-month, using local time.
*/
public override getDate(): number {
return 1;
}
/**
* Gets the day-of-the-month, using Universal Coordinated Time (UTC).
*/
public override getUTCDate(): number {
return 1;
}
/**
* Gets the day of the week, using local time.
*/
public override getDay(): number {
return 1;
}
/**
* Gets the day of the week using Universal Coordinated Time (UTC).
*/
public override getUTCDay(): number {
return 1;
}
/**
* It returns the duration between two dates.
*
* @param dateTimeTo - DateTime = DateTime.current
* @returns A duration object.
*/
public override getDuration(
dateTimeTo: StormTime = StormTime.current()
): Temporal.Duration {
return this.instant.since(dateTimeTo.instant);
}
declare interface StormErrorOptions {
name?: string;
message?: string;
cause?: unknown;
stack?: string;
data?: any;
}
export { StormErrorOptions }
export { StormErrorOptions as StormErrorOptions_alias_1 }
export { }

@@ -1,1492 +0,153 @@

import { DestinationStream } from 'pino';
import { LoggerOptions as LoggerOptions_2 } from 'pino';
import { StormConfig } from '@storm-software/config-tools';
import { Temporal } from '@js-temporal/polyfill';
import * as z from 'zod';
/**
* The input types that can be used to create a DateTime object
* Creates a new StormError instance
*
* @param cause - The cause of the error
* @returns The newly created StormError
*/
declare type DateTimeInput =
| StormDateTime
| Temporal.Instant
| Date
| string
| number
| bigint
| null
| undefined;
declare function createStormError<TCode extends string = string>({ code, name, message, cause, stack, data }: StormErrorOptions & {
code: TCode;
}): StormError<TCode>;
export { createStormError }
export { createStormError as createStormError_alias_1 }
/**
* The options to use when creating a new DateTime object
* Deserializes a JSON object into a StormError
*
* @param error - The error to deserialize
* @returns The deserialized error
*/
declare interface DateTimeOptions {
/**
* The time zone to use. If not specified, the default time zone for the runtime is used.
*/
timeZone?: Temporal.TimeZoneLike;
declare function deserializeStormError(json: JsonValue): StormError;
export { deserializeStormError }
export { deserializeStormError as deserializeStormError_alias_1 }
export { deserializeStormError as deserializeStormError_alias_2 }
/**
* The calendar to use. If not specified, the default calendar for the runtime is used.
*/
calendar?: Temporal.CalendarLike;
declare type ErrorCode = "success" | "missing_issue_code" | "invalid_config" | "failed_to_load_file" | "missing_context" | "record_not_found" | "required_field_missing" | "database_query_error" | "model_validation_error" | "field_validation_error" | "invalid_parameter" | "invalid_request" | "type_error" | "processing_error" | "internal_server_error" | "user_not_logged_in" | "unknown_cause";
/**
* If false, the current date and time is defaulted when undefined or null is passed. If true, the current date and time is not defaulted.
*
* @default false
*/
skipDefaulting?: boolean;
}
declare const ErrorCode: {
success: ErrorCode;
missing_issue_code: ErrorCode;
invalid_config: ErrorCode;
failed_to_load_file: ErrorCode;
missing_context: ErrorCode;
record_not_found: ErrorCode;
required_field_missing: ErrorCode;
database_query_error: ErrorCode;
model_validation_error: ErrorCode;
field_validation_error: ErrorCode;
invalid_parameter: ErrorCode;
invalid_request: ErrorCode;
type_error: ErrorCode;
processing_error: ErrorCode;
internal_server_error: ErrorCode;
user_not_logged_in: ErrorCode;
unknown_cause: ErrorCode;
};
export { ErrorCode }
export { ErrorCode as ErrorCode_alias_1 }
/**
* Convert the log level label to a log level
* Gets the cause of an unknown error and returns it as a StormError
*
* @param label - The log level label to convert
* @returns The log level
* @param cause - The cause of the error in an unknown type
* @returns The cause of the error in a StormError object or undefined
*/
export declare const getLogLevel: (label: string) => LogLevel;
declare function getCauseFromUnknown(cause: unknown): StormError;
export { getCauseFromUnknown }
export { getCauseFromUnknown as getCauseFromUnknown_alias_1 }
/**
* Convert the log level to a log level label
* Type-check to determine if `obj` is a `StormError` object
*
* @param logLevel - The log level to convert
* @returns The log level label
* @param value - the object to check
* @returns The function isStormError is returning a boolean value.
*/
export declare const getLogLevelLabel: (logLevel: number) => LogLevelLabel;
declare function isStormError<TCode extends string = any>(value: unknown): value is StormError<TCode>;
export { isStormError }
export { isStormError as isStormError_alias_1 }
export { isStormError as isStormError_alias_2 }
/**
* Get the Pino transports for the logger
*
* @param config - The workspace config
* @param name - The name of the logger to get the options for
* @returns The options for the logger
*/
declare const getTransports: (config: StormConfig<"logging", LoggingConfig>, name?: string) => any;
export { getTransports }
export { getTransports as getTransports_alias_1 }
export { getTransports as getTransports_alias_2 }
declare interface JsonArray extends Array<JsonValue> {}
declare interface ILogger {
/**
* Write a success message to the logs.
*
* @param message - The message to print.
* @returns Either a promise that resolves to void or void.
*/
success?: (message: string) => MaybePromise<void>;
/**
* Write a fatal message to the logs.
*
* @param message - The fatal message to be displayed.
* @returns Either a promise that resolves to void or void.
*/
fatal?: (message: string) => MaybePromise<void>;
/**
* Write an error message to the logs.
*
* @param message - The message to be displayed.
* @returns Either a promise that resolves to void or void.
*/
error: (message: string) => MaybePromise<void>;
/**
* Write an exception message to the logs.
*
* @param message - The message to be displayed.
* @returns Either a promise that resolves to void or void.
*/
exception?: (message: string) => MaybePromise<void>;
/**
* Write a warning message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
warn: (message: string) => MaybePromise<void>;
/**
* Write an informational message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
info: (message: string) => MaybePromise<void>;
/**
* Write a debug message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
debug?: (message: string) => MaybePromise<void>;
/**
* Write a trace message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
trace?: (message: string) => MaybePromise<void>;
/**
* Write an informational message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
log?: (message: string) => MaybePromise<void>;
declare interface JsonObject {
[key: string]: JsonValue;
}
export { ILogger }
export { ILogger as ILogger_alias_1 }
declare interface ILoggerWrapper {
/**
* Write a success message to the logs.
*
* @param message - The message to print.
* @returns Either a promise that resolves to void or void.
*/
success: (message: any) => MaybePromise<void>;
/**
* Write a fatal message to the logs.
*
* @param message - The fatal message to be displayed.
* @returns Either a promise that resolves to void or void.
*/
fatal: (error: string | Error) => MaybePromise<void>;
/**
* Write an error message to the logs.
*
* @param message - The message to be displayed.
* @returns Either a promise that resolves to void or void.
*/
error: (error: string | Error) => MaybePromise<void>;
/**
* Write an exception message to the logs.
*
* @param message - The message to be displayed.
* @returns Either a promise that resolves to void or void.
*/
exception: (error: string | Error) => MaybePromise<void>;
/**
* Write a warning message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
warn: (message: any) => MaybePromise<void>;
/**
* Write an informational message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
info: (message: any) => MaybePromise<void>;
/**
* Write a debug message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
debug: (message: any) => MaybePromise<void>;
/**
* Write a trace message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
trace: (message: any) => MaybePromise<void>;
/**
* Write an informational message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
log: (message: any) => MaybePromise<void>;
}
export { ILoggerWrapper }
export { ILoggerWrapper as ILoggerWrapper_alias_1 }
declare type JsonValue = PrimitiveJsonValue | JsonArray | JsonObject;
declare interface IStormLog {
/**
* Write a success message to the logs.
*
* @param message - The message to print.
* @returns Either a promise that resolves to void or void.
*/
success: (...message: any[]) => MaybePromise<void>;
/**
* Write a fatal message to the logs.
*
* @param message - The fatal message to be displayed.
* @returns Either a promise that resolves to void or void.
*/
fatal: (...message: any[]) => MaybePromise<void>;
/**
* Write an error message to the logs.
*
* @param message - The message to be displayed.
* @returns Either a promise that resolves to void or void.
*/
error: (...message: any[]) => MaybePromise<void>;
/**
* Write an exception message to the logs.
*
* @param message - The message to be displayed.
* @returns Either a promise that resolves to void or void.
*/
exception: (...message: any[]) => MaybePromise<void>;
/**
* Write a warning message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
warn: (...message: any[]) => MaybePromise<void>;
/**
* Write an informational message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
info: (...message: any[]) => MaybePromise<void>;
/**
* Write a debug message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
debug: (...message: any[]) => MaybePromise<void>;
/**
* Write a trace message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
trace: (...message: any[]) => MaybePromise<void>;
/**
* Write an informational message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
log: (...message: any[]) => MaybePromise<void>;
}
export { IStormLog }
export { IStormLog as IStormLog_alias_1 }
declare type PrimitiveJsonValue = string | number | boolean | undefined | null;
declare type LoggerOptions = {
options: LoggerOptions_2;
stream?: DestinationStream;
};
export { LoggerOptions }
export { LoggerOptions as LoggerOptions_alias_1 }
export { LoggerOptions as LoggerOptions_alias_2 }
/**
* A wrapper for a logger class.
* Serializes a StormError into a JSON object
*
* @param error - The error to serialize
* @returns The serialized error
*/
declare class LoggerWrapper implements ILoggerWrapper {
#private;
/**
* Wrap a logger.
*
* @param logger - The logger to wrap.
* @param config - The logging configuration.
* @param name - The logger's name.
* @returns The wrapped logger.
*/
static wrap: (logger: ILogger, config: LoggingConfig, name?: string) => LoggerWrapper;
private constructor();
/**
* Write a success message to the logs.
*
* @param message - The message to print.
* @returns Either a promise that resolves to void or void.
*/
success: (message: string) => MaybePromise<void>;
/**
* Write a fatal message to the logs.
*
* @param error - The fatal message to be displayed.
* @returns Either a promise that resolves to void or void.
*/
fatal: (error: string | Error) => MaybePromise<void>;
/**
* Write an error message to the logs.
*
* @param error - The message to be displayed.
* @returns Either a promise that resolves to void or void.
*/
exception: (error: string | Error) => MaybePromise<void>;
/**
* Write an error message to the logs.
*
* @param error - The message to be displayed.
* @returns Either a promise that resolves to void or void.
*/
error: (error: string | Error) => MaybePromise<void>;
/**
* Write a warning message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
warn: (message: string) => MaybePromise<void>;
/**
* Write an informational message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
info: (message: string) => MaybePromise<void>;
/**
* Write a debug message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
debug: (message: string) => MaybePromise<void>;
/**
* Write a trace message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
trace: (message: string) => MaybePromise<void>;
/**
* Write a log message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
log: (message: string) => MaybePromise<void>;
/**
* Format an error message.
*
* @param obj - The error to format.
* @returns The formatted error message.
*/
protected getErrorMessage: (obj?: string | Error | null) => string;
}
export { LoggerWrapper }
export { LoggerWrapper as LoggerWrapper_alias_1 }
export { LoggerWrapper as LoggerWrapper_alias_2 }
declare function serializeStormError(error: StormError): JsonValue;
export { serializeStormError }
export { serializeStormError as serializeStormError_alias_1 }
export { serializeStormError as serializeStormError_alias_2 }
declare type LoggingConfig = z.infer<typeof LoggingConfigSchema>;
export { LoggingConfig }
export { LoggingConfig as LoggingConfig_alias_1 }
/**
* Storm base schema used to represent a package's config (either workspace or project)
*/
export declare const LoggingConfigSchema: z.ZodObject<{
stacktrace: z.ZodOptional<z.ZodBoolean>;
fileName: z.ZodDefault<z.ZodOptional<z.ZodString>>;
fileExtension: z.ZodDefault<z.ZodString>;
path: z.ZodOptional<z.ZodString>;
loki: z.ZodOptional<z.ZodObject<{
host: z.ZodDefault<z.ZodString>;
username: z.ZodString;
password: z.ZodString;
}, "strip", z.ZodTypeAny, {
host: string;
username: string;
password: string;
}, {
username: string;
password: string;
host?: string | undefined;
}>>;
}, "strip", z.ZodTypeAny, {
fileName: string;
fileExtension: string;
stacktrace?: boolean | undefined;
path?: string | undefined;
loki?: {
host: string;
username: string;
password: string;
} | undefined;
}, {
stacktrace?: boolean | undefined;
fileName?: string | undefined;
fileExtension?: string | undefined;
path?: string | undefined;
loki?: {
username: string;
password: string;
host?: string | undefined;
} | undefined;
}>;
export declare type LogLevel = 0 | 10 | 20 | 30 | 40 | 60 | 70;
export declare const LogLevel: {
readonly SILENT: LogLevel;
readonly FATAL: LogLevel;
readonly ERROR: LogLevel;
readonly WARN: LogLevel;
readonly INFO: LogLevel;
readonly DEBUG: LogLevel;
readonly TRACE: LogLevel;
};
export declare type LogLevelLabel = "silent" | "fatal" | "error" | "warn" | "info" | "debug" | "trace";
export declare const LogLevelLabel: {
readonly SILENT: LogLevelLabel;
readonly FATAL: LogLevelLabel;
readonly ERROR: LogLevelLabel;
readonly WARN: LogLevelLabel;
readonly INFO: LogLevelLabel;
readonly DEBUG: LogLevelLabel;
readonly TRACE: LogLevelLabel;
};
/**
* Storm schema used to represent a the required config needed to use Loki
*/
export declare const LokiConfigSchema: z.ZodObject<{
host: z.ZodDefault<z.ZodString>;
username: z.ZodString;
password: z.ZodString;
}, "strip", z.ZodTypeAny, {
host: string;
username: string;
password: string;
}, {
username: string;
password: string;
host?: string | undefined;
}>;
declare type MaybePromise<T> = T | Promise<T>;
/**
* A wrapper of the and Date class used by Storm Software to provide Date-Time values
* A wrapper around the base JavaScript Error class to be used by Storm Software
*
* @decorator `@Serializable()`
*/
declare @Serializable({
serialize: serializeStormDateTime,
deserialize: deserializeStormDateTime
})
class StormDateTime extends Date {
/**
* The current function returns a new StormDateTime object with the current date and time
* @returns A new instance of StormDateTime with the current date and time.
*/
public static override now(): number {
return StormDateTime.current().epochMilliseconds;
}
/**
* The current function returns a new StormDateTime object with the current date and time
* @returns A new instance of StormDateTime with the current date and time.
*/
public static current(): StormDateTime {
return StormDateTime.create(Temporal.Now.instant());
}
/**
* Creates a new instance of StormDateTime from a string with a specified format.
*
* @param dateTime - The input value used to determine the current date and time
* @param options - The options to use when creating the StormDateTime object
* @returns A new instance of StormDateTime with the current date and time.
*/
public static create = (
dateTime?: DateTimeInput,
options?: DateTimeOptions
) =>
new StormDateTime(dateTime, {
timeZone:
(isDateTime(dateTime) ? dateTime.timeZoneId : options?.timeZone) ??
process.env.STORM_TIMEZONE ??
Temporal.Now.timeZoneId(),
calendar: isDateTime(dateTime) ? dateTime.calendarId : options?.calendar
});
/**
* A private accessor that stores the `Temporal.Instant` object of the DateTime object
*/
#instant: Temporal.Instant = Temporal.Now.instant();
/**
* A private accessor that stores the `Temporal.ZonedDateTime` object of the DateTime object
*/
#zonedDateTime: Temporal.ZonedDateTime = Temporal.Now.zonedDateTime(
process.env.STORM_TIMEZONE ?? Temporal.Now.timeZoneId()
);
/**
* A private accessor that stores the input value used to create the DateTime object
*/
#input: DateTimeInput;
/**
* A private accessor that stores the options used to create the DateTime object
*/
#options: DateTimeOptions;
public constructor(dateTime?: DateTimeInput, options?: DateTimeOptions) {
const input = dateTime;
if (!dateTime && !options?.skipDefaulting) {
dateTime = Temporal.Now.instant();
}
const instant = !dateTime
? undefined
: isDateTime(dateTime)
? dateTime.instant
: Temporal.Instant.from(
isDate(dateTime)
? dateTime.toJSON()
: isNumber(dateTime) || isBigInt(dateTime)
? new Date(Number(dateTime)).toISOString()
: dateTime
);
super(instant ? Number(instant.epochMilliseconds) : "MISSING_DATE");
if (instant && this.validate(dateTime, options)) {
this.#instant = instant;
const timeZone = options?.timeZone
? options?.timeZone
: process.env.TZ
? process.env.TZ
: Temporal.Now.timeZoneId();
this.#zonedDateTime = options?.calendar
? this.#instant.toZonedDateTime({
timeZone,
calendar: options.calendar
})
: this.#instant.toZonedDateTimeISO(timeZone);
}
this.#input = input;
this.#options = options ?? {};
}
/**
* An accessor that returns the epoch milliseconds of the DateTime object
*/
public get epochMilliseconds(): number {
return this.instant.epochMilliseconds;
}
/**
* An accessor that returns the `Temporal.Instant` object of the DateTime object
*/
public get instant(): Temporal.Instant {
return this.#instant;
}
/**
* An accessor that sets the `Temporal.Instant` object of the DateTime object
*/
protected set instant(_instant: Temporal.Instant) {
this.#instant = _instant;
}
/**
* An accessor that returns the `Temporal.ZonedDateTime` object of the DateTime object
*/
public get zonedDateTime(): Temporal.ZonedDateTime {
return this.#zonedDateTime;
}
/**
* An accessor that sets the `Temporal.ZonedDateTime` object of the DateTime object
*/
protected set zonedDateTime(_zonedDateTime: Temporal.ZonedDateTime) {
this.#zonedDateTime = _zonedDateTime;
}
/**
* An accessor that returns the `calendarId` string of the DateTime object
*/
public get calendarId(): string {
return this.#zonedDateTime.calendarId;
}
/**
* An accessor that returns the `timeZoneId` string of the DateTime object
*/
public get timeZoneId(): string {
return this.#zonedDateTime.timeZoneId;
}
/**
* An accessor that returns the `isValid` boolean of the DateTime object
*/
public get isValid(): boolean {
return this.validate(this.#zonedDateTime.epochMilliseconds, this.#options);
}
/**
* Returns the input value used to create the DateTime object
*/
public get input(): DateTimeInput {
return this.#input;
}
/**
* Returns the options used to create the DateTime object
*/
public get options(): DateTimeOptions {
return this.#options;
}
/**
* Validate the input date value
*
* @param dateTime - The date value to validate
* @param options - The options to use
* @returns A boolean representing whether the value is a valid *date-time*
*/
protected validate(
dateTime?: DateTimeInput,
options?: DateTimeOptions
): boolean {
return validateDateTime(dateTime, options);
}
/**
* Returns the stored time value in milliseconds since midnight, January 1, 1970 UTC.
*/
public override getTime(): number {
return this.epochMilliseconds;
}
/**
* Gets the year, using local time.
*/
public override getFullYear(): number {
return this.#zonedDateTime.year;
}
/**
* Gets the year using Universal Coordinated Time (UTC).
*/
public override getUTCFullYear(): number {
return this.#instant.toZonedDateTimeISO("UTC").year;
}
/**
* Gets the month, using local time.
*/
public override getMonth(): number {
return this.#zonedDateTime.month;
}
/**
* Gets the month of a Date object using Universal Coordinated Time (UTC).
*/
public override getUTCMonth(): number {
return this.#instant.toZonedDateTimeISO("UTC").month;
}
/**
* Gets the day-of-the-month, using local time.
*/
public override getDate(): number {
return this.#zonedDateTime.day;
}
/**
* Gets the day-of-the-month, using Universal Coordinated Time (UTC).
*/
public override getUTCDate(): number {
return this.#instant.toZonedDateTimeISO("UTC").day;
}
/**
* Gets the day of the week, using local time.
*/
public override getDay(): number {
return this.#zonedDateTime.dayOfWeek;
}
/**
* Gets the day of the week using Universal Coordinated Time (UTC).
*/
public override getUTCDay(): number {
return this.#instant.toZonedDateTimeISO("UTC").dayOfWeek;
}
/**
* Gets the hours in a date, using local time.
*/
public override getHours(): number {
return this.#zonedDateTime.hour;
}
/**
* Gets the hours value in a Date object using Universal Coordinated Time (UTC).
*/
public override getUTCHours(): number {
return this.#instant.toZonedDateTimeISO("UTC").hour;
}
/**
* Gets the minutes of a Date object, using local time.
*/
public override getMinutes(): number {
return this.#zonedDateTime.minute;
}
/**
* Gets the minutes of a Date object using Universal Coordinated Time (UTC).
*/
public override getUTCMinutes(): number {
return this.#instant.toZonedDateTimeISO("UTC").minute;
}
/**
* Gets the seconds of a Date object, using local time.
*/
public override getSeconds(): number {
return this.#zonedDateTime.second;
}
/**
* Gets the seconds of a Date object using Universal Coordinated Time (UTC).
*/
public override getUTCSeconds(): number {
return this.#instant.toZonedDateTimeISO("UTC").second;
}
/**
* Gets the milliseconds of a Date, using local time.
*/
public override getMilliseconds(): number {
return this.#zonedDateTime.millisecond;
}
/**
* Gets the milliseconds of a Date object using Universal Coordinated Time (UTC).
*/
public override getUTCMilliseconds(): number {
return this.#instant.toZonedDateTimeISO("UTC").millisecond;
}
/**
* Gets the difference in minutes between the time on the local computer and Universal Coordinated Time (UTC).
*/
public override getTimezoneOffset(): number {
return this.#zonedDateTime.offsetNanoseconds / 1000000;
}
/**
* Sets the date and time value in the Date object.
* @param time - A numeric value representing the number of elapsed milliseconds since midnight, January 1, 1970 GMT.
*/
public override setTime(time: number): number {
this.#zonedDateTime = this.#zonedDateTime.add({
milliseconds: time - this.epochMilliseconds
});
this.#instant = this.#zonedDateTime.toInstant();
return super.setTime(this.#instant.epochMilliseconds);
}
/**
* Sets the milliseconds value in the Date object using local time.
* @param millisecond - A numeric value equal to the millisecond value.
*/
public override setMilliseconds(millisecond: number): number {
this.#zonedDateTime = this.#zonedDateTime.with({ millisecond });
this.#instant = this.#zonedDateTime.toInstant();
return super.setMilliseconds(
this.#instant.toZonedDateTimeISO("UTC").millisecond
);
}
/**
* Sets the milliseconds value in the Date object using Universal Coordinated Time (UTC).
* @param millisecond - A numeric value equal to the millisecond value.
*/
public override setUTCMilliseconds(millisecond: number): number {
this.#instant = this.#instant
.toZonedDateTimeISO("UTC")
.with({ millisecond })
.toInstant();
this.#zonedDateTime = this.#instant.toZonedDateTime({
timeZone: this.timeZoneId,
calendar: this.calendarId
});
return super.setUTCMilliseconds(
this.#instant.toZonedDateTimeISO("UTC").millisecond
);
}
/**
* Sets the seconds value in the Date object using local time.
* @param second - A numeric value equal to the seconds value.
* @param millisecond - A numeric value equal to the milliseconds value.
*/
public override setSeconds(second: number, millisecond?: number): number {
this.#zonedDateTime = this.#zonedDateTime.with({ second, millisecond });
this.#instant = this.#zonedDateTime.toInstant();
return super.setSeconds(
this.#zonedDateTime.second,
this.#zonedDateTime.millisecond
);
}
/**
* Sets the seconds value in the Date object using Universal Coordinated Time (UTC).
* @param second - A numeric value equal to the seconds value.
* @param millisecond - A numeric value equal to the milliseconds value.
*/
public override setUTCSeconds(second: number, millisecond?: number): number {
this.#instant = this.#instant
.toZonedDateTimeISO("UTC")
.with({ second, millisecond })
.toInstant();
this.#zonedDateTime = this.#instant.toZonedDateTime({
timeZone: this.timeZoneId,
calendar: this.calendarId
});
const utcDateTime = this.#instant.toZonedDateTimeISO("UTC");
return super.setUTCSeconds(utcDateTime.second, utcDateTime.millisecond);
}
/**
* Sets the minutes value in the Date object using local time.
* @param minute - A numeric value equal to the minutes value.
* @param second - A numeric value equal to the seconds value.
* @param millisecond - A numeric value equal to the milliseconds value.
*/
public override setMinutes(
minute: number,
second?: number,
millisecond?: number
): number {
this.#zonedDateTime = this.#zonedDateTime.with({
minute,
second,
millisecond
});
this.#instant = this.#zonedDateTime.toInstant();
return super.setMinutes(
this.#zonedDateTime.minute,
this.#zonedDateTime.second,
this.#zonedDateTime.millisecond
);
}
/**
* Sets the minutes value in the Date object using Universal Coordinated Time (UTC).
* @param minute - A numeric value equal to the minutes value.
* @param second - A numeric value equal to the seconds value.
* @param millisecond - A numeric value equal to the milliseconds value.
*/
public override setUTCMinutes(
minute: number,
second?: number,
millisecond?: number
): number {
this.#instant = this.#instant
.toZonedDateTimeISO("UTC")
.with({ minute, second, millisecond })
.toInstant();
this.#zonedDateTime = this.#instant.toZonedDateTime({
timeZone: this.timeZoneId,
calendar: this.calendarId
});
const utcDateTime = this.#instant.toZonedDateTimeISO("UTC");
return super.setUTCMinutes(
utcDateTime.minute,
utcDateTime.second,
utcDateTime.millisecond
);
}
/**
* Sets the hour value in the Date object using local time.
*
* @param hour - A numeric value equal to the hours value.
* @param minute - A numeric value equal to the minutes value.
* @param second - A numeric value equal to the seconds value.
* @param millisecond - A numeric value equal to the milliseconds value.
*/
public override setHours(
hour: number,
minute: number,
second?: number,
millisecond?: number
): number {
this.#zonedDateTime = this.#zonedDateTime.with({
hour,
minute,
second,
millisecond
});
this.#instant = this.#zonedDateTime.toInstant();
return super.setHours(
this.#zonedDateTime.hour,
this.#zonedDateTime.minute,
this.#zonedDateTime.second,
this.#zonedDateTime.millisecond
);
}
/**
* Sets the hours value in the Date object using Universal Coordinated Time (UTC).
*
* @param hour - A numeric value equal to the hours value.
* @param minute - A numeric value equal to the minutes value.
* @param second - A numeric value equal to the seconds value.
* @param millisecond - A numeric value equal to the milliseconds value.
*/
public override setUTCHours(
hour: number,
minute: number,
second?: number,
millisecond?: number
): number {
this.#instant = this.#instant
.toZonedDateTimeISO("UTC")
.with({ hour, minute, second, millisecond })
.toInstant();
this.#zonedDateTime = this.#instant.toZonedDateTime({
timeZone: this.timeZoneId,
calendar: this.calendarId
});
const utcDateTime = this.#instant.toZonedDateTimeISO("UTC");
return super.setUTCHours(
utcDateTime.hour,
utcDateTime.minute,
utcDateTime.second,
utcDateTime.millisecond
);
}
/**
* Sets the numeric day-of-the-month value of the Date object using local time.
*
* @param day - A numeric value equal to the day of the month.
*/
public override setDate(day: number): number {
this.#zonedDateTime = this.#zonedDateTime.with({
day
});
this.#instant = this.#zonedDateTime.toInstant();
return super.setDate(this.#zonedDateTime.day);
}
/**
* Sets the numeric day of the month in the Date object using Universal Coordinated Time (UTC).
*
* @param day - A numeric value equal to the day of the month.
*/
public override setUTCDate(day: number): number {
this.#instant = this.#instant
.toZonedDateTimeISO("UTC")
.with({ day })
.toInstant();
this.#zonedDateTime = this.#instant.toZonedDateTime({
timeZone: this.timeZoneId,
calendar: this.calendarId
});
return super.setUTCDate(this.#instant.toZonedDateTimeISO("UTC").day);
}
/**
* Sets the month value in the Date object using local time.
*
* @param month - A numeric value equal to the month. The value for January is 0, and other month values follow consecutively.
* @param day - A numeric value representing the day of the month. If this value is not supplied, the value from a call to the getDate method is used.
*/
public override setMonth(month: number, day?: number): number {
this.#zonedDateTime = this.#zonedDateTime.with({ month, day });
this.#instant = this.#zonedDateTime.toInstant();
return super.setMonth(this.#zonedDateTime.month, this.#zonedDateTime.day);
}
/**
* Sets the month value in the Date object using Universal Coordinated Time (UTC).
*
* @param month - A numeric value equal to the month. The value for January is 0, and other month values follow consecutively.
* @param day - A numeric value representing the day of the month. If it is not supplied, the value from a call to the getUTCDate method is used.
*/
public override setUTCMonth(month: number, day?: number): number {
this.#instant = this.#instant
.toZonedDateTimeISO("UTC")
.with({ month, day })
.toInstant();
this.#zonedDateTime = this.#instant.toZonedDateTime({
timeZone: this.timeZoneId,
calendar: this.calendarId
});
const utcDateTime = this.#instant.toZonedDateTimeISO("UTC");
return super.setUTCMonth(utcDateTime.month, utcDateTime.day);
}
/**
* Sets the year of the Date object using local time.
* @param year - A numeric value for the year.
* @param month - A zero-based numeric value for the month (0 for January, 11 for December). Must be specified if numDate is specified.
* @param day - A numeric value equal for the day of the month.
*/
public override setFullYear(
year: number,
month?: number,
day?: number
): number {
this.#zonedDateTime = this.#zonedDateTime.with({ year, month, day });
this.#instant = this.#zonedDateTime.toInstant();
return super.setFullYear(
this.#zonedDateTime.year,
this.#zonedDateTime.month,
this.#zonedDateTime.day
);
}
/**
* Sets the year value in the Date object using Universal Coordinated Time (UTC).
*
* @param year - A numeric value equal to the year.
* @param month - A numeric value equal to the month. The value for January is 0, and other month values follow consecutively. Must be supplied if numDate is supplied.
* @param day - A numeric value equal to the day of the month.
*/
public override setUTCFullYear(
year: number,
month?: number,
day?: number
): number {
this.#instant = this.#instant
.toZonedDateTimeISO("UTC")
.with({ year, month, day })
.toInstant();
this.#zonedDateTime = this.#instant.toZonedDateTime({
timeZone: this.timeZoneId,
calendar: this.calendarId
});
const utcDateTime = this.#instant.toZonedDateTimeISO("UTC");
return super.setUTCFullYear(
utcDateTime.year,
utcDateTime.month,
utcDateTime.day
);
}
/**
* It returns a plain date object from a DateTime object
*
* @returns A PlainDate object.
*/
public getPlainDate(): StormDateTime {
return StormDateTime.create(
this.#zonedDateTime.toPlainDate().toZonedDateTime({
timeZone: Temporal.Now.timeZoneId(),
plainTime: undefined
}).epochMilliseconds,
{
timeZone: this.#zonedDateTime.timeZoneId,
calendar: this.#zonedDateTime.calendarId
}
);
}
/**
* `getPlainTime` returns a `PlainTime` object from a `DateTime` object
*
* @returns A PlainTime object.
*/
public getPlainTime(): StormDateTime {
return StormDateTime.create(
this.#zonedDateTime.toPlainTime().toZonedDateTime({
timeZone: Temporal.Now.timeZoneId(),
plainDate: Temporal.PlainDate.from({
year: 1970,
month: 0,
day: 1
})
}).epochMilliseconds,
{
timeZone: this.#zonedDateTime.timeZoneId,
calendar: this.#zonedDateTime.calendarId
}
);
}
/**
* It returns the duration between two dates.
*
* @param dateTimeTo - DateTime = DateTime.current
* @returns A duration object.
*/
public since(
dateTimeTo: StormDateTime = StormDateTime.current()
): Temporal.Duration {
return this.#instant.since(dateTimeTo.instant);
}
/**
* It returns the duration between two date times.
*
* @param dateTimeTo - DateTime = DateTime.current
* @returns A duration object.
*/
public getDuration(
dateTimeTo: StormDateTime = StormDateTime.current()
): Temporal.Duration {
return this.instant.since(dateTimeTo.instant);
}
}
/**
* The default logger class.
*
* @remarks
* This logger writes to the console.
*/
declare class StormLog implements IStormLog {
declare class StormError<TCode extends string = string> extends Error {
#private;
private static logger;
private static logLevel;
private static logLevelLabel;
private static getLoggers;
__proto__: ErrorConstructor;
/**
* Initialize the logger.
*
* @param config - The Storm config
* @param name - The name of the project to initialized the loggers for
* @returns The initialized loggers
* The error code
*/
private static initialize;
code: TCode;
/**
* The Singleton's constructor should always be private to prevent direct
* construction calls with the `new` operator.
* The cause of the error
*/
private constructor();
cause?: StormError;
/**
* Create a new instance of the logger
*
* @param config - The Storm config
* @param name - The name of the project to initialized the loggers for
* @param additionalLoggers - Additional loggers to use
* @returns The initialized logger
* Additional data to be passed with the error
*/
static create(config: StormConfig<"logging", LoggingConfig>, name?: string, additionalLoggers?: ILoggerWrapper[]): StormLog;
data?: any;
constructor(code: TCode, { name, message, cause, stack, data }?: StormErrorOptions);
/**
* Write a success message to the logs.
* Prints a displayable, formatted the stack trace
*
* @param message - The message to print.
* @returns Either a promise that resolves to void or void.
* @returns The stack trace string
*/
static success(message: any): void;
get stack(): string;
/**
* Write a fatal message to the logs.
*
* @param message - The fatal message to be displayed.
* @returns Either a promise that resolves to void or void.
* Store the stack trace
*/
static fatal(message: any): void;
set stack(_stack: string);
/**
* Write an error message to the logs.
* The unformatted stack trace
*
* @param message - The message to be displayed.
* @returns Either a promise that resolves to void or void.
* @returns The stack trace string
*/
static error(message: any): void;
get originalStack(): string;
/**
* Write an exception message to the logs.
* Prints the display error message string
*
* @param message - The message to be displayed.
* @returns Either a promise that resolves to void or void.
* @returns The display error message string
*/
static exception(message: any): void;
print(): string;
/**
* Write a warning message to the logs.
* Prints the error message and stack trace
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
* @returns The error message and stack trace string
*/
static warn(message: any): void;
/**
* Write an informational message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
static info(message: any): void;
/**
* Write a debug message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
static debug(message: any): void;
/**
* Write a trace message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
static trace(message: any): void;
/**
* Write an informational message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
static log(message: any): void;
/**
* Write an message to the logs specifying how long it took to complete a process
* @param startTime - The start time of the process
* @param name - The name of the process
*/
static stopwatch(startTime: StormTime, name?: string): void;
/**
* Write a success message to the logs.
*
* @param message - The message to print.
* @returns Either a promise that resolves to void or void.
*/
success(message: any): void;
/**
* Write a fatal message to the logs.
*
* @param message - The fatal message to be displayed.
* @returns Either a promise that resolves to void or void.
*/
fatal(message: any): void;
/**
* Write an error message to the logs.
*
* @param message - The message to be displayed.
* @returns Either a promise that resolves to void or void.
*/
error(message: any): void;
/**
* Write an exception message to the logs.
*
* @param message - The message to be displayed.
* @returns Either a promise that resolves to void or void.
*/
exception(message: any): void;
/**
* Write a warning message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
warn(message: any): void;
/**
* Write an informational message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
info(message: any): void;
/**
* Write a debug message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
debug(message: any): void;
/**
* Write a trace message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
trace(message: any): void;
/**
* Write an informational message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
log(message: any): void;
/**
* Start a process
*
* @param name - The name of the process
*/
start(name: string): void;
/**
* Write an message to the logs specifying how long it took to complete a process
*
* @param name - The name of the process
* @param startTime - The start time of the process
*/
stopwatch(name?: string, startTime?: StormTime): void;
/**
* Add a logger wrapper to the internal loggers list
*
* @param wrapper - The logger wrapper to use
*/
addWrappedLogger(wrapper: ILoggerWrapper): void;
/**
* Add a logger to the internal loggers list
*
* @param logger - The logger to add
*/
addLogger(logger: ILogger): void;
toString(): string;
}
export { StormLog }
export { StormLog as StormLog_alias_1 }
export { StormError }
export { StormError as StormError_alias_1 }
/**
* A wrapper of the and Date class used by Storm Software to provide Date-Time values
*
* @decorator `@Serializable()`
*/
declare @Serializable({
serialize: serializeStormTime,
deserialize: deserializeStormTime
})
class StormTime extends StormDateTime {
/**
* The current function returns a new DateTime object with the current date and time
* @returns A new instance of DateTime with the current date and time.
*/
public static override now(): number {
return StormDateTime.current().epochMilliseconds;
}
/**
* The current function returns a new DateTime object with the current date and time
* @returns A new instance of DateTime with the current date and time.
*/
public static override current(): StormTime {
return StormTime.create(Temporal.Now.instant());
}
/**
* Creates a new instance of DateTime from a string with a specified format.
*
* @param time - The input value used to determine the current time
* @param options - The options to use
* @returns A new instance of StormTime with the time provided in the time parameter.
*/
public static override create = (
time?: DateTimeInput,
options?: DateTimeOptions
) =>
new StormTime(time, {
timeZone:
(isDateTime(time) ? time.timeZoneId : options?.timeZone) ??
Temporal.Now.timeZoneId(),
calendar: isDateTime(time) ? time.calendarId : options?.calendar
});
public constructor(dateTime?: DateTimeInput, options?: DateTimeOptions) {
super(dateTime, options);
this.instant = this.instant
.toZonedDateTimeISO("UTC")
.with({
year: 1970,
month: 1,
day: 1
})
.toInstant();
this.zonedDateTime = this.zonedDateTime.with({
year: 1970,
month: 1,
day: 1
});
}
/**
* Validate the input time value
*
* @param dateTime - The date value to validate
* @param options - The options to use
* @returns A boolean representing whether the value is a valid *date-time*
*/
protected override validate(
dateTime?: DateTimeInput,
options?: DateTimeOptions
): boolean {
return validateTime(dateTime, options);
}
/**
* Gets the year, using local time.
*/
public override getFullYear(): number {
return 1970;
}
/**
* Gets the year using Universal Coordinated Time (UTC).
*/
public override getUTCFullYear(): number {
return 1970;
}
/**
* Gets the month, using local time.
*/
public override getMonth(): number {
return 1;
}
/**
* Gets the month of a Date object using Universal Coordinated Time (UTC).
*/
public override getUTCMonth(): number {
return 1;
}
/**
* Gets the day-of-the-month, using local time.
*/
public override getDate(): number {
return 1;
}
/**
* Gets the day-of-the-month, using Universal Coordinated Time (UTC).
*/
public override getUTCDate(): number {
return 1;
}
/**
* Gets the day of the week, using local time.
*/
public override getDay(): number {
return 1;
}
/**
* Gets the day of the week using Universal Coordinated Time (UTC).
*/
public override getUTCDay(): number {
return 1;
}
/**
* It returns the duration between two dates.
*
* @param dateTimeTo - DateTime = DateTime.current
* @returns A duration object.
*/
public override getDuration(
dateTimeTo: StormTime = StormTime.current()
): Temporal.Duration {
return this.instant.since(dateTimeTo.instant);
}
declare interface StormErrorOptions {
name?: string;
message?: string;
cause?: unknown;
stack?: string;
data?: any;
}
export { StormErrorOptions }
export { StormErrorOptions as StormErrorOptions_alias_1 }
export { }

@@ -1,1492 +0,153 @@

import { DestinationStream } from 'pino';
import { LoggerOptions as LoggerOptions_2 } from 'pino';
import { StormConfig } from '@storm-software/config-tools';
import { Temporal } from '@js-temporal/polyfill';
import * as z from 'zod';
/**
* The input types that can be used to create a DateTime object
* Creates a new StormError instance
*
* @param cause - The cause of the error
* @returns The newly created StormError
*/
declare type DateTimeInput =
| StormDateTime
| Temporal.Instant
| Date
| string
| number
| bigint
| null
| undefined;
declare function createStormError<TCode extends string = string>({ code, name, message, cause, stack, data }: StormErrorOptions & {
code: TCode;
}): StormError<TCode>;
export { createStormError }
export { createStormError as createStormError_alias_1 }
/**
* The options to use when creating a new DateTime object
* Deserializes a JSON object into a StormError
*
* @param error - The error to deserialize
* @returns The deserialized error
*/
declare interface DateTimeOptions {
/**
* The time zone to use. If not specified, the default time zone for the runtime is used.
*/
timeZone?: Temporal.TimeZoneLike;
declare function deserializeStormError(json: JsonValue): StormError;
export { deserializeStormError }
export { deserializeStormError as deserializeStormError_alias_1 }
export { deserializeStormError as deserializeStormError_alias_2 }
/**
* The calendar to use. If not specified, the default calendar for the runtime is used.
*/
calendar?: Temporal.CalendarLike;
declare type ErrorCode = "success" | "missing_issue_code" | "invalid_config" | "failed_to_load_file" | "missing_context" | "record_not_found" | "required_field_missing" | "database_query_error" | "model_validation_error" | "field_validation_error" | "invalid_parameter" | "invalid_request" | "type_error" | "processing_error" | "internal_server_error" | "user_not_logged_in" | "unknown_cause";
/**
* If false, the current date and time is defaulted when undefined or null is passed. If true, the current date and time is not defaulted.
*
* @default false
*/
skipDefaulting?: boolean;
}
declare const ErrorCode: {
success: ErrorCode;
missing_issue_code: ErrorCode;
invalid_config: ErrorCode;
failed_to_load_file: ErrorCode;
missing_context: ErrorCode;
record_not_found: ErrorCode;
required_field_missing: ErrorCode;
database_query_error: ErrorCode;
model_validation_error: ErrorCode;
field_validation_error: ErrorCode;
invalid_parameter: ErrorCode;
invalid_request: ErrorCode;
type_error: ErrorCode;
processing_error: ErrorCode;
internal_server_error: ErrorCode;
user_not_logged_in: ErrorCode;
unknown_cause: ErrorCode;
};
export { ErrorCode }
export { ErrorCode as ErrorCode_alias_1 }
/**
* Convert the log level label to a log level
* Gets the cause of an unknown error and returns it as a StormError
*
* @param label - The log level label to convert
* @returns The log level
* @param cause - The cause of the error in an unknown type
* @returns The cause of the error in a StormError object or undefined
*/
export declare const getLogLevel: (label: string) => LogLevel;
declare function getCauseFromUnknown(cause: unknown): StormError;
export { getCauseFromUnknown }
export { getCauseFromUnknown as getCauseFromUnknown_alias_1 }
/**
* Convert the log level to a log level label
* Type-check to determine if `obj` is a `StormError` object
*
* @param logLevel - The log level to convert
* @returns The log level label
* @param value - the object to check
* @returns The function isStormError is returning a boolean value.
*/
export declare const getLogLevelLabel: (logLevel: number) => LogLevelLabel;
declare function isStormError<TCode extends string = any>(value: unknown): value is StormError<TCode>;
export { isStormError }
export { isStormError as isStormError_alias_1 }
export { isStormError as isStormError_alias_2 }
/**
* Get the Pino transports for the logger
*
* @param config - The workspace config
* @param name - The name of the logger to get the options for
* @returns The options for the logger
*/
declare const getTransports: (config: StormConfig<"logging", LoggingConfig>, name?: string) => any;
export { getTransports }
export { getTransports as getTransports_alias_1 }
export { getTransports as getTransports_alias_2 }
declare interface JsonArray extends Array<JsonValue> {}
declare interface ILogger {
/**
* Write a success message to the logs.
*
* @param message - The message to print.
* @returns Either a promise that resolves to void or void.
*/
success?: (message: string) => MaybePromise<void>;
/**
* Write a fatal message to the logs.
*
* @param message - The fatal message to be displayed.
* @returns Either a promise that resolves to void or void.
*/
fatal?: (message: string) => MaybePromise<void>;
/**
* Write an error message to the logs.
*
* @param message - The message to be displayed.
* @returns Either a promise that resolves to void or void.
*/
error: (message: string) => MaybePromise<void>;
/**
* Write an exception message to the logs.
*
* @param message - The message to be displayed.
* @returns Either a promise that resolves to void or void.
*/
exception?: (message: string) => MaybePromise<void>;
/**
* Write a warning message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
warn: (message: string) => MaybePromise<void>;
/**
* Write an informational message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
info: (message: string) => MaybePromise<void>;
/**
* Write a debug message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
debug?: (message: string) => MaybePromise<void>;
/**
* Write a trace message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
trace?: (message: string) => MaybePromise<void>;
/**
* Write an informational message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
log?: (message: string) => MaybePromise<void>;
declare interface JsonObject {
[key: string]: JsonValue;
}
export { ILogger }
export { ILogger as ILogger_alias_1 }
declare interface ILoggerWrapper {
/**
* Write a success message to the logs.
*
* @param message - The message to print.
* @returns Either a promise that resolves to void or void.
*/
success: (message: any) => MaybePromise<void>;
/**
* Write a fatal message to the logs.
*
* @param message - The fatal message to be displayed.
* @returns Either a promise that resolves to void or void.
*/
fatal: (error: string | Error) => MaybePromise<void>;
/**
* Write an error message to the logs.
*
* @param message - The message to be displayed.
* @returns Either a promise that resolves to void or void.
*/
error: (error: string | Error) => MaybePromise<void>;
/**
* Write an exception message to the logs.
*
* @param message - The message to be displayed.
* @returns Either a promise that resolves to void or void.
*/
exception: (error: string | Error) => MaybePromise<void>;
/**
* Write a warning message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
warn: (message: any) => MaybePromise<void>;
/**
* Write an informational message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
info: (message: any) => MaybePromise<void>;
/**
* Write a debug message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
debug: (message: any) => MaybePromise<void>;
/**
* Write a trace message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
trace: (message: any) => MaybePromise<void>;
/**
* Write an informational message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
log: (message: any) => MaybePromise<void>;
}
export { ILoggerWrapper }
export { ILoggerWrapper as ILoggerWrapper_alias_1 }
declare type JsonValue = PrimitiveJsonValue | JsonArray | JsonObject;
declare interface IStormLog {
/**
* Write a success message to the logs.
*
* @param message - The message to print.
* @returns Either a promise that resolves to void or void.
*/
success: (...message: any[]) => MaybePromise<void>;
/**
* Write a fatal message to the logs.
*
* @param message - The fatal message to be displayed.
* @returns Either a promise that resolves to void or void.
*/
fatal: (...message: any[]) => MaybePromise<void>;
/**
* Write an error message to the logs.
*
* @param message - The message to be displayed.
* @returns Either a promise that resolves to void or void.
*/
error: (...message: any[]) => MaybePromise<void>;
/**
* Write an exception message to the logs.
*
* @param message - The message to be displayed.
* @returns Either a promise that resolves to void or void.
*/
exception: (...message: any[]) => MaybePromise<void>;
/**
* Write a warning message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
warn: (...message: any[]) => MaybePromise<void>;
/**
* Write an informational message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
info: (...message: any[]) => MaybePromise<void>;
/**
* Write a debug message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
debug: (...message: any[]) => MaybePromise<void>;
/**
* Write a trace message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
trace: (...message: any[]) => MaybePromise<void>;
/**
* Write an informational message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
log: (...message: any[]) => MaybePromise<void>;
}
export { IStormLog }
export { IStormLog as IStormLog_alias_1 }
declare type PrimitiveJsonValue = string | number | boolean | undefined | null;
declare type LoggerOptions = {
options: LoggerOptions_2;
stream?: DestinationStream;
};
export { LoggerOptions }
export { LoggerOptions as LoggerOptions_alias_1 }
export { LoggerOptions as LoggerOptions_alias_2 }
/**
* A wrapper for a logger class.
* Serializes a StormError into a JSON object
*
* @param error - The error to serialize
* @returns The serialized error
*/
declare class LoggerWrapper implements ILoggerWrapper {
#private;
/**
* Wrap a logger.
*
* @param logger - The logger to wrap.
* @param config - The logging configuration.
* @param name - The logger's name.
* @returns The wrapped logger.
*/
static wrap: (logger: ILogger, config: LoggingConfig, name?: string) => LoggerWrapper;
private constructor();
/**
* Write a success message to the logs.
*
* @param message - The message to print.
* @returns Either a promise that resolves to void or void.
*/
success: (message: string) => MaybePromise<void>;
/**
* Write a fatal message to the logs.
*
* @param error - The fatal message to be displayed.
* @returns Either a promise that resolves to void or void.
*/
fatal: (error: string | Error) => MaybePromise<void>;
/**
* Write an error message to the logs.
*
* @param error - The message to be displayed.
* @returns Either a promise that resolves to void or void.
*/
exception: (error: string | Error) => MaybePromise<void>;
/**
* Write an error message to the logs.
*
* @param error - The message to be displayed.
* @returns Either a promise that resolves to void or void.
*/
error: (error: string | Error) => MaybePromise<void>;
/**
* Write a warning message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
warn: (message: string) => MaybePromise<void>;
/**
* Write an informational message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
info: (message: string) => MaybePromise<void>;
/**
* Write a debug message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
debug: (message: string) => MaybePromise<void>;
/**
* Write a trace message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
trace: (message: string) => MaybePromise<void>;
/**
* Write a log message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
log: (message: string) => MaybePromise<void>;
/**
* Format an error message.
*
* @param obj - The error to format.
* @returns The formatted error message.
*/
protected getErrorMessage: (obj?: string | Error | null) => string;
}
export { LoggerWrapper }
export { LoggerWrapper as LoggerWrapper_alias_1 }
export { LoggerWrapper as LoggerWrapper_alias_2 }
declare function serializeStormError(error: StormError): JsonValue;
export { serializeStormError }
export { serializeStormError as serializeStormError_alias_1 }
export { serializeStormError as serializeStormError_alias_2 }
declare type LoggingConfig = z.infer<typeof LoggingConfigSchema>;
export { LoggingConfig }
export { LoggingConfig as LoggingConfig_alias_1 }
/**
* Storm base schema used to represent a package's config (either workspace or project)
*/
export declare const LoggingConfigSchema: z.ZodObject<{
stacktrace: z.ZodOptional<z.ZodBoolean>;
fileName: z.ZodDefault<z.ZodOptional<z.ZodString>>;
fileExtension: z.ZodDefault<z.ZodString>;
path: z.ZodOptional<z.ZodString>;
loki: z.ZodOptional<z.ZodObject<{
host: z.ZodDefault<z.ZodString>;
username: z.ZodString;
password: z.ZodString;
}, "strip", z.ZodTypeAny, {
host: string;
username: string;
password: string;
}, {
username: string;
password: string;
host?: string | undefined;
}>>;
}, "strip", z.ZodTypeAny, {
fileName: string;
fileExtension: string;
stacktrace?: boolean | undefined;
path?: string | undefined;
loki?: {
host: string;
username: string;
password: string;
} | undefined;
}, {
stacktrace?: boolean | undefined;
fileName?: string | undefined;
fileExtension?: string | undefined;
path?: string | undefined;
loki?: {
username: string;
password: string;
host?: string | undefined;
} | undefined;
}>;
export declare type LogLevel = 0 | 10 | 20 | 30 | 40 | 60 | 70;
export declare const LogLevel: {
readonly SILENT: LogLevel;
readonly FATAL: LogLevel;
readonly ERROR: LogLevel;
readonly WARN: LogLevel;
readonly INFO: LogLevel;
readonly DEBUG: LogLevel;
readonly TRACE: LogLevel;
};
export declare type LogLevelLabel = "silent" | "fatal" | "error" | "warn" | "info" | "debug" | "trace";
export declare const LogLevelLabel: {
readonly SILENT: LogLevelLabel;
readonly FATAL: LogLevelLabel;
readonly ERROR: LogLevelLabel;
readonly WARN: LogLevelLabel;
readonly INFO: LogLevelLabel;
readonly DEBUG: LogLevelLabel;
readonly TRACE: LogLevelLabel;
};
/**
* Storm schema used to represent a the required config needed to use Loki
*/
export declare const LokiConfigSchema: z.ZodObject<{
host: z.ZodDefault<z.ZodString>;
username: z.ZodString;
password: z.ZodString;
}, "strip", z.ZodTypeAny, {
host: string;
username: string;
password: string;
}, {
username: string;
password: string;
host?: string | undefined;
}>;
declare type MaybePromise<T> = T | Promise<T>;
/**
* A wrapper of the and Date class used by Storm Software to provide Date-Time values
* A wrapper around the base JavaScript Error class to be used by Storm Software
*
* @decorator `@Serializable()`
*/
declare @Serializable({
serialize: serializeStormDateTime,
deserialize: deserializeStormDateTime
})
class StormDateTime extends Date {
/**
* The current function returns a new StormDateTime object with the current date and time
* @returns A new instance of StormDateTime with the current date and time.
*/
public static override now(): number {
return StormDateTime.current().epochMilliseconds;
}
/**
* The current function returns a new StormDateTime object with the current date and time
* @returns A new instance of StormDateTime with the current date and time.
*/
public static current(): StormDateTime {
return StormDateTime.create(Temporal.Now.instant());
}
/**
* Creates a new instance of StormDateTime from a string with a specified format.
*
* @param dateTime - The input value used to determine the current date and time
* @param options - The options to use when creating the StormDateTime object
* @returns A new instance of StormDateTime with the current date and time.
*/
public static create = (
dateTime?: DateTimeInput,
options?: DateTimeOptions
) =>
new StormDateTime(dateTime, {
timeZone:
(isDateTime(dateTime) ? dateTime.timeZoneId : options?.timeZone) ??
process.env.STORM_TIMEZONE ??
Temporal.Now.timeZoneId(),
calendar: isDateTime(dateTime) ? dateTime.calendarId : options?.calendar
});
/**
* A private accessor that stores the `Temporal.Instant` object of the DateTime object
*/
#instant: Temporal.Instant = Temporal.Now.instant();
/**
* A private accessor that stores the `Temporal.ZonedDateTime` object of the DateTime object
*/
#zonedDateTime: Temporal.ZonedDateTime = Temporal.Now.zonedDateTime(
process.env.STORM_TIMEZONE ?? Temporal.Now.timeZoneId()
);
/**
* A private accessor that stores the input value used to create the DateTime object
*/
#input: DateTimeInput;
/**
* A private accessor that stores the options used to create the DateTime object
*/
#options: DateTimeOptions;
public constructor(dateTime?: DateTimeInput, options?: DateTimeOptions) {
const input = dateTime;
if (!dateTime && !options?.skipDefaulting) {
dateTime = Temporal.Now.instant();
}
const instant = !dateTime
? undefined
: isDateTime(dateTime)
? dateTime.instant
: Temporal.Instant.from(
isDate(dateTime)
? dateTime.toJSON()
: isNumber(dateTime) || isBigInt(dateTime)
? new Date(Number(dateTime)).toISOString()
: dateTime
);
super(instant ? Number(instant.epochMilliseconds) : "MISSING_DATE");
if (instant && this.validate(dateTime, options)) {
this.#instant = instant;
const timeZone = options?.timeZone
? options?.timeZone
: process.env.TZ
? process.env.TZ
: Temporal.Now.timeZoneId();
this.#zonedDateTime = options?.calendar
? this.#instant.toZonedDateTime({
timeZone,
calendar: options.calendar
})
: this.#instant.toZonedDateTimeISO(timeZone);
}
this.#input = input;
this.#options = options ?? {};
}
/**
* An accessor that returns the epoch milliseconds of the DateTime object
*/
public get epochMilliseconds(): number {
return this.instant.epochMilliseconds;
}
/**
* An accessor that returns the `Temporal.Instant` object of the DateTime object
*/
public get instant(): Temporal.Instant {
return this.#instant;
}
/**
* An accessor that sets the `Temporal.Instant` object of the DateTime object
*/
protected set instant(_instant: Temporal.Instant) {
this.#instant = _instant;
}
/**
* An accessor that returns the `Temporal.ZonedDateTime` object of the DateTime object
*/
public get zonedDateTime(): Temporal.ZonedDateTime {
return this.#zonedDateTime;
}
/**
* An accessor that sets the `Temporal.ZonedDateTime` object of the DateTime object
*/
protected set zonedDateTime(_zonedDateTime: Temporal.ZonedDateTime) {
this.#zonedDateTime = _zonedDateTime;
}
/**
* An accessor that returns the `calendarId` string of the DateTime object
*/
public get calendarId(): string {
return this.#zonedDateTime.calendarId;
}
/**
* An accessor that returns the `timeZoneId` string of the DateTime object
*/
public get timeZoneId(): string {
return this.#zonedDateTime.timeZoneId;
}
/**
* An accessor that returns the `isValid` boolean of the DateTime object
*/
public get isValid(): boolean {
return this.validate(this.#zonedDateTime.epochMilliseconds, this.#options);
}
/**
* Returns the input value used to create the DateTime object
*/
public get input(): DateTimeInput {
return this.#input;
}
/**
* Returns the options used to create the DateTime object
*/
public get options(): DateTimeOptions {
return this.#options;
}
/**
* Validate the input date value
*
* @param dateTime - The date value to validate
* @param options - The options to use
* @returns A boolean representing whether the value is a valid *date-time*
*/
protected validate(
dateTime?: DateTimeInput,
options?: DateTimeOptions
): boolean {
return validateDateTime(dateTime, options);
}
/**
* Returns the stored time value in milliseconds since midnight, January 1, 1970 UTC.
*/
public override getTime(): number {
return this.epochMilliseconds;
}
/**
* Gets the year, using local time.
*/
public override getFullYear(): number {
return this.#zonedDateTime.year;
}
/**
* Gets the year using Universal Coordinated Time (UTC).
*/
public override getUTCFullYear(): number {
return this.#instant.toZonedDateTimeISO("UTC").year;
}
/**
* Gets the month, using local time.
*/
public override getMonth(): number {
return this.#zonedDateTime.month;
}
/**
* Gets the month of a Date object using Universal Coordinated Time (UTC).
*/
public override getUTCMonth(): number {
return this.#instant.toZonedDateTimeISO("UTC").month;
}
/**
* Gets the day-of-the-month, using local time.
*/
public override getDate(): number {
return this.#zonedDateTime.day;
}
/**
* Gets the day-of-the-month, using Universal Coordinated Time (UTC).
*/
public override getUTCDate(): number {
return this.#instant.toZonedDateTimeISO("UTC").day;
}
/**
* Gets the day of the week, using local time.
*/
public override getDay(): number {
return this.#zonedDateTime.dayOfWeek;
}
/**
* Gets the day of the week using Universal Coordinated Time (UTC).
*/
public override getUTCDay(): number {
return this.#instant.toZonedDateTimeISO("UTC").dayOfWeek;
}
/**
* Gets the hours in a date, using local time.
*/
public override getHours(): number {
return this.#zonedDateTime.hour;
}
/**
* Gets the hours value in a Date object using Universal Coordinated Time (UTC).
*/
public override getUTCHours(): number {
return this.#instant.toZonedDateTimeISO("UTC").hour;
}
/**
* Gets the minutes of a Date object, using local time.
*/
public override getMinutes(): number {
return this.#zonedDateTime.minute;
}
/**
* Gets the minutes of a Date object using Universal Coordinated Time (UTC).
*/
public override getUTCMinutes(): number {
return this.#instant.toZonedDateTimeISO("UTC").minute;
}
/**
* Gets the seconds of a Date object, using local time.
*/
public override getSeconds(): number {
return this.#zonedDateTime.second;
}
/**
* Gets the seconds of a Date object using Universal Coordinated Time (UTC).
*/
public override getUTCSeconds(): number {
return this.#instant.toZonedDateTimeISO("UTC").second;
}
/**
* Gets the milliseconds of a Date, using local time.
*/
public override getMilliseconds(): number {
return this.#zonedDateTime.millisecond;
}
/**
* Gets the milliseconds of a Date object using Universal Coordinated Time (UTC).
*/
public override getUTCMilliseconds(): number {
return this.#instant.toZonedDateTimeISO("UTC").millisecond;
}
/**
* Gets the difference in minutes between the time on the local computer and Universal Coordinated Time (UTC).
*/
public override getTimezoneOffset(): number {
return this.#zonedDateTime.offsetNanoseconds / 1000000;
}
/**
* Sets the date and time value in the Date object.
* @param time - A numeric value representing the number of elapsed milliseconds since midnight, January 1, 1970 GMT.
*/
public override setTime(time: number): number {
this.#zonedDateTime = this.#zonedDateTime.add({
milliseconds: time - this.epochMilliseconds
});
this.#instant = this.#zonedDateTime.toInstant();
return super.setTime(this.#instant.epochMilliseconds);
}
/**
* Sets the milliseconds value in the Date object using local time.
* @param millisecond - A numeric value equal to the millisecond value.
*/
public override setMilliseconds(millisecond: number): number {
this.#zonedDateTime = this.#zonedDateTime.with({ millisecond });
this.#instant = this.#zonedDateTime.toInstant();
return super.setMilliseconds(
this.#instant.toZonedDateTimeISO("UTC").millisecond
);
}
/**
* Sets the milliseconds value in the Date object using Universal Coordinated Time (UTC).
* @param millisecond - A numeric value equal to the millisecond value.
*/
public override setUTCMilliseconds(millisecond: number): number {
this.#instant = this.#instant
.toZonedDateTimeISO("UTC")
.with({ millisecond })
.toInstant();
this.#zonedDateTime = this.#instant.toZonedDateTime({
timeZone: this.timeZoneId,
calendar: this.calendarId
});
return super.setUTCMilliseconds(
this.#instant.toZonedDateTimeISO("UTC").millisecond
);
}
/**
* Sets the seconds value in the Date object using local time.
* @param second - A numeric value equal to the seconds value.
* @param millisecond - A numeric value equal to the milliseconds value.
*/
public override setSeconds(second: number, millisecond?: number): number {
this.#zonedDateTime = this.#zonedDateTime.with({ second, millisecond });
this.#instant = this.#zonedDateTime.toInstant();
return super.setSeconds(
this.#zonedDateTime.second,
this.#zonedDateTime.millisecond
);
}
/**
* Sets the seconds value in the Date object using Universal Coordinated Time (UTC).
* @param second - A numeric value equal to the seconds value.
* @param millisecond - A numeric value equal to the milliseconds value.
*/
public override setUTCSeconds(second: number, millisecond?: number): number {
this.#instant = this.#instant
.toZonedDateTimeISO("UTC")
.with({ second, millisecond })
.toInstant();
this.#zonedDateTime = this.#instant.toZonedDateTime({
timeZone: this.timeZoneId,
calendar: this.calendarId
});
const utcDateTime = this.#instant.toZonedDateTimeISO("UTC");
return super.setUTCSeconds(utcDateTime.second, utcDateTime.millisecond);
}
/**
* Sets the minutes value in the Date object using local time.
* @param minute - A numeric value equal to the minutes value.
* @param second - A numeric value equal to the seconds value.
* @param millisecond - A numeric value equal to the milliseconds value.
*/
public override setMinutes(
minute: number,
second?: number,
millisecond?: number
): number {
this.#zonedDateTime = this.#zonedDateTime.with({
minute,
second,
millisecond
});
this.#instant = this.#zonedDateTime.toInstant();
return super.setMinutes(
this.#zonedDateTime.minute,
this.#zonedDateTime.second,
this.#zonedDateTime.millisecond
);
}
/**
* Sets the minutes value in the Date object using Universal Coordinated Time (UTC).
* @param minute - A numeric value equal to the minutes value.
* @param second - A numeric value equal to the seconds value.
* @param millisecond - A numeric value equal to the milliseconds value.
*/
public override setUTCMinutes(
minute: number,
second?: number,
millisecond?: number
): number {
this.#instant = this.#instant
.toZonedDateTimeISO("UTC")
.with({ minute, second, millisecond })
.toInstant();
this.#zonedDateTime = this.#instant.toZonedDateTime({
timeZone: this.timeZoneId,
calendar: this.calendarId
});
const utcDateTime = this.#instant.toZonedDateTimeISO("UTC");
return super.setUTCMinutes(
utcDateTime.minute,
utcDateTime.second,
utcDateTime.millisecond
);
}
/**
* Sets the hour value in the Date object using local time.
*
* @param hour - A numeric value equal to the hours value.
* @param minute - A numeric value equal to the minutes value.
* @param second - A numeric value equal to the seconds value.
* @param millisecond - A numeric value equal to the milliseconds value.
*/
public override setHours(
hour: number,
minute: number,
second?: number,
millisecond?: number
): number {
this.#zonedDateTime = this.#zonedDateTime.with({
hour,
minute,
second,
millisecond
});
this.#instant = this.#zonedDateTime.toInstant();
return super.setHours(
this.#zonedDateTime.hour,
this.#zonedDateTime.minute,
this.#zonedDateTime.second,
this.#zonedDateTime.millisecond
);
}
/**
* Sets the hours value in the Date object using Universal Coordinated Time (UTC).
*
* @param hour - A numeric value equal to the hours value.
* @param minute - A numeric value equal to the minutes value.
* @param second - A numeric value equal to the seconds value.
* @param millisecond - A numeric value equal to the milliseconds value.
*/
public override setUTCHours(
hour: number,
minute: number,
second?: number,
millisecond?: number
): number {
this.#instant = this.#instant
.toZonedDateTimeISO("UTC")
.with({ hour, minute, second, millisecond })
.toInstant();
this.#zonedDateTime = this.#instant.toZonedDateTime({
timeZone: this.timeZoneId,
calendar: this.calendarId
});
const utcDateTime = this.#instant.toZonedDateTimeISO("UTC");
return super.setUTCHours(
utcDateTime.hour,
utcDateTime.minute,
utcDateTime.second,
utcDateTime.millisecond
);
}
/**
* Sets the numeric day-of-the-month value of the Date object using local time.
*
* @param day - A numeric value equal to the day of the month.
*/
public override setDate(day: number): number {
this.#zonedDateTime = this.#zonedDateTime.with({
day
});
this.#instant = this.#zonedDateTime.toInstant();
return super.setDate(this.#zonedDateTime.day);
}
/**
* Sets the numeric day of the month in the Date object using Universal Coordinated Time (UTC).
*
* @param day - A numeric value equal to the day of the month.
*/
public override setUTCDate(day: number): number {
this.#instant = this.#instant
.toZonedDateTimeISO("UTC")
.with({ day })
.toInstant();
this.#zonedDateTime = this.#instant.toZonedDateTime({
timeZone: this.timeZoneId,
calendar: this.calendarId
});
return super.setUTCDate(this.#instant.toZonedDateTimeISO("UTC").day);
}
/**
* Sets the month value in the Date object using local time.
*
* @param month - A numeric value equal to the month. The value for January is 0, and other month values follow consecutively.
* @param day - A numeric value representing the day of the month. If this value is not supplied, the value from a call to the getDate method is used.
*/
public override setMonth(month: number, day?: number): number {
this.#zonedDateTime = this.#zonedDateTime.with({ month, day });
this.#instant = this.#zonedDateTime.toInstant();
return super.setMonth(this.#zonedDateTime.month, this.#zonedDateTime.day);
}
/**
* Sets the month value in the Date object using Universal Coordinated Time (UTC).
*
* @param month - A numeric value equal to the month. The value for January is 0, and other month values follow consecutively.
* @param day - A numeric value representing the day of the month. If it is not supplied, the value from a call to the getUTCDate method is used.
*/
public override setUTCMonth(month: number, day?: number): number {
this.#instant = this.#instant
.toZonedDateTimeISO("UTC")
.with({ month, day })
.toInstant();
this.#zonedDateTime = this.#instant.toZonedDateTime({
timeZone: this.timeZoneId,
calendar: this.calendarId
});
const utcDateTime = this.#instant.toZonedDateTimeISO("UTC");
return super.setUTCMonth(utcDateTime.month, utcDateTime.day);
}
/**
* Sets the year of the Date object using local time.
* @param year - A numeric value for the year.
* @param month - A zero-based numeric value for the month (0 for January, 11 for December). Must be specified if numDate is specified.
* @param day - A numeric value equal for the day of the month.
*/
public override setFullYear(
year: number,
month?: number,
day?: number
): number {
this.#zonedDateTime = this.#zonedDateTime.with({ year, month, day });
this.#instant = this.#zonedDateTime.toInstant();
return super.setFullYear(
this.#zonedDateTime.year,
this.#zonedDateTime.month,
this.#zonedDateTime.day
);
}
/**
* Sets the year value in the Date object using Universal Coordinated Time (UTC).
*
* @param year - A numeric value equal to the year.
* @param month - A numeric value equal to the month. The value for January is 0, and other month values follow consecutively. Must be supplied if numDate is supplied.
* @param day - A numeric value equal to the day of the month.
*/
public override setUTCFullYear(
year: number,
month?: number,
day?: number
): number {
this.#instant = this.#instant
.toZonedDateTimeISO("UTC")
.with({ year, month, day })
.toInstant();
this.#zonedDateTime = this.#instant.toZonedDateTime({
timeZone: this.timeZoneId,
calendar: this.calendarId
});
const utcDateTime = this.#instant.toZonedDateTimeISO("UTC");
return super.setUTCFullYear(
utcDateTime.year,
utcDateTime.month,
utcDateTime.day
);
}
/**
* It returns a plain date object from a DateTime object
*
* @returns A PlainDate object.
*/
public getPlainDate(): StormDateTime {
return StormDateTime.create(
this.#zonedDateTime.toPlainDate().toZonedDateTime({
timeZone: Temporal.Now.timeZoneId(),
plainTime: undefined
}).epochMilliseconds,
{
timeZone: this.#zonedDateTime.timeZoneId,
calendar: this.#zonedDateTime.calendarId
}
);
}
/**
* `getPlainTime` returns a `PlainTime` object from a `DateTime` object
*
* @returns A PlainTime object.
*/
public getPlainTime(): StormDateTime {
return StormDateTime.create(
this.#zonedDateTime.toPlainTime().toZonedDateTime({
timeZone: Temporal.Now.timeZoneId(),
plainDate: Temporal.PlainDate.from({
year: 1970,
month: 0,
day: 1
})
}).epochMilliseconds,
{
timeZone: this.#zonedDateTime.timeZoneId,
calendar: this.#zonedDateTime.calendarId
}
);
}
/**
* It returns the duration between two dates.
*
* @param dateTimeTo - DateTime = DateTime.current
* @returns A duration object.
*/
public since(
dateTimeTo: StormDateTime = StormDateTime.current()
): Temporal.Duration {
return this.#instant.since(dateTimeTo.instant);
}
/**
* It returns the duration between two date times.
*
* @param dateTimeTo - DateTime = DateTime.current
* @returns A duration object.
*/
public getDuration(
dateTimeTo: StormDateTime = StormDateTime.current()
): Temporal.Duration {
return this.instant.since(dateTimeTo.instant);
}
}
/**
* The default logger class.
*
* @remarks
* This logger writes to the console.
*/
declare class StormLog implements IStormLog {
declare class StormError<TCode extends string = string> extends Error {
#private;
private static logger;
private static logLevel;
private static logLevelLabel;
private static getLoggers;
__proto__: ErrorConstructor;
/**
* Initialize the logger.
*
* @param config - The Storm config
* @param name - The name of the project to initialized the loggers for
* @returns The initialized loggers
* The error code
*/
private static initialize;
code: TCode;
/**
* The Singleton's constructor should always be private to prevent direct
* construction calls with the `new` operator.
* The cause of the error
*/
private constructor();
cause?: StormError;
/**
* Create a new instance of the logger
*
* @param config - The Storm config
* @param name - The name of the project to initialized the loggers for
* @param additionalLoggers - Additional loggers to use
* @returns The initialized logger
* Additional data to be passed with the error
*/
static create(config: StormConfig<"logging", LoggingConfig>, name?: string, additionalLoggers?: ILoggerWrapper[]): StormLog;
data?: any;
constructor(code: TCode, { name, message, cause, stack, data }?: StormErrorOptions);
/**
* Write a success message to the logs.
* Prints a displayable, formatted the stack trace
*
* @param message - The message to print.
* @returns Either a promise that resolves to void or void.
* @returns The stack trace string
*/
static success(message: any): void;
get stack(): string;
/**
* Write a fatal message to the logs.
*
* @param message - The fatal message to be displayed.
* @returns Either a promise that resolves to void or void.
* Store the stack trace
*/
static fatal(message: any): void;
set stack(_stack: string);
/**
* Write an error message to the logs.
* The unformatted stack trace
*
* @param message - The message to be displayed.
* @returns Either a promise that resolves to void or void.
* @returns The stack trace string
*/
static error(message: any): void;
get originalStack(): string;
/**
* Write an exception message to the logs.
* Prints the display error message string
*
* @param message - The message to be displayed.
* @returns Either a promise that resolves to void or void.
* @returns The display error message string
*/
static exception(message: any): void;
print(): string;
/**
* Write a warning message to the logs.
* Prints the error message and stack trace
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
* @returns The error message and stack trace string
*/
static warn(message: any): void;
/**
* Write an informational message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
static info(message: any): void;
/**
* Write a debug message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
static debug(message: any): void;
/**
* Write a trace message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
static trace(message: any): void;
/**
* Write an informational message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
static log(message: any): void;
/**
* Write an message to the logs specifying how long it took to complete a process
* @param startTime - The start time of the process
* @param name - The name of the process
*/
static stopwatch(startTime: StormTime, name?: string): void;
/**
* Write a success message to the logs.
*
* @param message - The message to print.
* @returns Either a promise that resolves to void or void.
*/
success(message: any): void;
/**
* Write a fatal message to the logs.
*
* @param message - The fatal message to be displayed.
* @returns Either a promise that resolves to void or void.
*/
fatal(message: any): void;
/**
* Write an error message to the logs.
*
* @param message - The message to be displayed.
* @returns Either a promise that resolves to void or void.
*/
error(message: any): void;
/**
* Write an exception message to the logs.
*
* @param message - The message to be displayed.
* @returns Either a promise that resolves to void or void.
*/
exception(message: any): void;
/**
* Write a warning message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
warn(message: any): void;
/**
* Write an informational message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
info(message: any): void;
/**
* Write a debug message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
debug(message: any): void;
/**
* Write a trace message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
trace(message: any): void;
/**
* Write an informational message to the logs.
*
* @param message - The message to be printed.
* @returns Either a promise that resolves to void or void.
*/
log(message: any): void;
/**
* Start a process
*
* @param name - The name of the process
*/
start(name: string): void;
/**
* Write an message to the logs specifying how long it took to complete a process
*
* @param name - The name of the process
* @param startTime - The start time of the process
*/
stopwatch(name?: string, startTime?: StormTime): void;
/**
* Add a logger wrapper to the internal loggers list
*
* @param wrapper - The logger wrapper to use
*/
addWrappedLogger(wrapper: ILoggerWrapper): void;
/**
* Add a logger to the internal loggers list
*
* @param logger - The logger to add
*/
addLogger(logger: ILogger): void;
toString(): string;
}
export { StormLog }
export { StormLog as StormLog_alias_1 }
export { StormError }
export { StormError as StormError_alias_1 }
/**
* A wrapper of the and Date class used by Storm Software to provide Date-Time values
*
* @decorator `@Serializable()`
*/
declare @Serializable({
serialize: serializeStormTime,
deserialize: deserializeStormTime
})
class StormTime extends StormDateTime {
/**
* The current function returns a new DateTime object with the current date and time
* @returns A new instance of DateTime with the current date and time.
*/
public static override now(): number {
return StormDateTime.current().epochMilliseconds;
}
/**
* The current function returns a new DateTime object with the current date and time
* @returns A new instance of DateTime with the current date and time.
*/
public static override current(): StormTime {
return StormTime.create(Temporal.Now.instant());
}
/**
* Creates a new instance of DateTime from a string with a specified format.
*
* @param time - The input value used to determine the current time
* @param options - The options to use
* @returns A new instance of StormTime with the time provided in the time parameter.
*/
public static override create = (
time?: DateTimeInput,
options?: DateTimeOptions
) =>
new StormTime(time, {
timeZone:
(isDateTime(time) ? time.timeZoneId : options?.timeZone) ??
Temporal.Now.timeZoneId(),
calendar: isDateTime(time) ? time.calendarId : options?.calendar
});
public constructor(dateTime?: DateTimeInput, options?: DateTimeOptions) {
super(dateTime, options);
this.instant = this.instant
.toZonedDateTimeISO("UTC")
.with({
year: 1970,
month: 1,
day: 1
})
.toInstant();
this.zonedDateTime = this.zonedDateTime.with({
year: 1970,
month: 1,
day: 1
});
}
/**
* Validate the input time value
*
* @param dateTime - The date value to validate
* @param options - The options to use
* @returns A boolean representing whether the value is a valid *date-time*
*/
protected override validate(
dateTime?: DateTimeInput,
options?: DateTimeOptions
): boolean {
return validateTime(dateTime, options);
}
/**
* Gets the year, using local time.
*/
public override getFullYear(): number {
return 1970;
}
/**
* Gets the year using Universal Coordinated Time (UTC).
*/
public override getUTCFullYear(): number {
return 1970;
}
/**
* Gets the month, using local time.
*/
public override getMonth(): number {
return 1;
}
/**
* Gets the month of a Date object using Universal Coordinated Time (UTC).
*/
public override getUTCMonth(): number {
return 1;
}
/**
* Gets the day-of-the-month, using local time.
*/
public override getDate(): number {
return 1;
}
/**
* Gets the day-of-the-month, using Universal Coordinated Time (UTC).
*/
public override getUTCDate(): number {
return 1;
}
/**
* Gets the day of the week, using local time.
*/
public override getDay(): number {
return 1;
}
/**
* Gets the day of the week using Universal Coordinated Time (UTC).
*/
public override getUTCDay(): number {
return 1;
}
/**
* It returns the duration between two dates.
*
* @param dateTimeTo - DateTime = DateTime.current
* @returns A duration object.
*/
public override getDuration(
dateTimeTo: StormTime = StormTime.current()
): Temporal.Duration {
return this.instant.since(dateTimeTo.instant);
}
declare interface StormErrorOptions {
name?: string;
message?: string;
cause?: unknown;
stack?: string;
data?: any;
}
export { StormErrorOptions }
export { StormErrorOptions as StormErrorOptions_alias_1 }
export { }

2

package.json
{
"name": "@storm-stack/errors",
"version": "1.2.0",
"version": "1.2.1",
"private": false,

@@ -5,0 +5,0 @@ "description": "This package includes a base error class and various utility functions for working with errors.",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc