@tstdl/base 0.93.64 → 0.93.66

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -228,7 +228,8 @@ let DocumentManagementAiService = DocumentManagementAiService_1 = class Document
228
228
  if (isNull(result.output)) {
229
229
  throw new Error(`AI returned null output for document "${document.id}".`);
230
230
  }
231
- return result.output.content;
231
+ const markdownBlockStripped = result.output.content.trim().replaceAll(/^```\w*\s*|```$/gi, '').trim();
232
+ return markdownBlockStripped;
232
233
  }
233
234
  catch (e_1) {
234
235
  env_1.error = e_1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tstdl/base",
3
- "version": "0.93.64",
3
+ "version": "0.93.66",
4
4
  "author": "Patrick Hein",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -56,3 +56,9 @@ export declare function dateTimeToNumericDate(dateTime: DateTime): number;
56
56
  export declare function numericDateToDateTime(numericDate: number, units?: DateObjectUnits, options?: DateTimeJSOptions): DateTime;
57
57
  export declare function dateTimeToTime(dateTime: DateTime): number;
58
58
  export declare function numericDateTimeToDateTime({ date, time }: NumericDateTime, zone?: string): DateTime;
59
+ /** Converts a timestamp, Date, DateTime, ISO date string, or DateObject to a numeric date */
60
+ export declare function toNumericDate(value: number | Date | DateTime | string | DateObject): number;
61
+ export declare function toNumericDate<N extends null | undefined>(value: number | Date | DateTime | string | DateObject | N): number | N;
62
+ /** Converts a numeric date to an ISO date string (YYYY-MM-DD) */
63
+ export declare function numericDateToIsoDate(numericDate: number): string;
64
+ export declare function numericDateToIsoDate<N extends null | undefined>(numericDate: number | N): string | N;
@@ -1,6 +1,7 @@
1
1
  import { NotSupportedError } from '../errors/not-supported.error.js';
2
2
  import { DateTime } from 'luxon';
3
- import { isDate, isNumber } from './type-guards.js';
3
+ import { hasOwnProperty } from './object/object.js';
4
+ import { isDate, isNullOrUndefined, isNumber, isString } from './type-guards.js';
4
5
  import { typeOf } from './type-of.js';
5
6
  import { millisecondsPerDay, millisecondsPerHour, millisecondsPerMinute, millisecondsPerSecond } from './units.js';
6
7
  export function now() {
@@ -126,3 +127,37 @@ export function dateTimeToTime(dateTime) {
126
127
  export function numericDateTimeToDateTime({ date, time }, zone) {
127
128
  return numericDateToDateTime(date, undefined, { zone }).set({ millisecond: time });
128
129
  }
130
+ export function toNumericDate(value) {
131
+ if (isNullOrUndefined(value)) {
132
+ return value;
133
+ }
134
+ if (isNumber(value)) {
135
+ return timestampToNumericDate(value);
136
+ }
137
+ if (isDate(value)) {
138
+ return dateToNumericDate(value);
139
+ }
140
+ if (DateTime.isDateTime(value)) {
141
+ return dateTimeToNumericDate(value);
142
+ }
143
+ if (isString(value)) {
144
+ const dateTime = DateTime.fromISO(value, { zone: 'UTC' });
145
+ if (!dateTime.isValid) {
146
+ throw new Error(`Invalid ISO date string "${value}": ${dateTime.invalidExplanation}`);
147
+ }
148
+ return dateTimeToNumericDate(dateTime);
149
+ }
150
+ if (hasOwnProperty(value, 'year') && hasOwnProperty(value, 'month') && hasOwnProperty(value, 'day')) {
151
+ return dateObjectToNumericDate(value);
152
+ }
153
+ throw new NotSupportedError(`Unsupported input type "${typeOf(value)}".`);
154
+ }
155
+ export function numericDateToIsoDate(numericDate) {
156
+ if (isNullOrUndefined(numericDate)) {
157
+ return numericDate;
158
+ }
159
+ const { year, month, day } = numericDateToDateObject(numericDate);
160
+ const monthString = month.toString().padStart(2, '0');
161
+ const dayString = day.toString().padStart(2, '0');
162
+ return `${year}-${monthString}-${dayString}`;
163
+ }