@tstdl/base 0.92.86 → 0.92.88

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/ai/ai-file.service.js +8 -13
  2. package/ai/ai.service.d.ts +3 -3
  3. package/ai/ai.service.js +24 -11
  4. package/ai/types.d.ts +4 -3
  5. package/api/server/gateway.js +1 -1
  6. package/authentication/server/authentication-ancillary.service.d.ts +6 -4
  7. package/authentication/server/authentication-ancillary.service.js +5 -5
  8. package/context/context.d.ts +1 -9
  9. package/context/context.js +8 -5
  10. package/document-management/api/document-management.api.d.ts +48 -16
  11. package/document-management/models/document-category.model.d.ts +1 -1
  12. package/document-management/models/document-category.model.js +2 -0
  13. package/document-management/models/document-collection-document.model.js +7 -3
  14. package/document-management/models/document-property-value.model.d.ts +13 -14
  15. package/document-management/models/document-property-value.model.js +60 -27
  16. package/document-management/models/document-property.model.d.ts +2 -0
  17. package/document-management/models/document-property.model.js +4 -1
  18. package/document-management/models/document-request-assignment-task-collection.model.d.ts +7 -0
  19. package/document-management/models/{document-index.model.js → document-request-assignment-task-collection.model.js} +16 -16
  20. package/document-management/models/document-request-assignment-task.model.d.ts +14 -0
  21. package/document-management/models/document-request-assignment-task.model.js +72 -0
  22. package/document-management/models/document-request-collection.model.d.ts +1 -0
  23. package/document-management/models/document-request-collection.model.js +7 -3
  24. package/document-management/models/document-request-file.model.d.ts +6 -1
  25. package/document-management/models/document-request-file.model.js +27 -2
  26. package/document-management/models/document-request.model.d.ts +1 -0
  27. package/document-management/models/document-requests-template.js +2 -0
  28. package/document-management/models/document-type-property.model.js +7 -3
  29. package/document-management/models/document-type.model.d.ts +1 -1
  30. package/document-management/models/document-type.model.js +7 -3
  31. package/document-management/models/document.model.d.ts +4 -1
  32. package/document-management/models/document.model.js +19 -4
  33. package/document-management/models/index.d.ts +2 -0
  34. package/document-management/models/index.js +2 -0
  35. package/document-management/models/service-models/document.service-model.d.ts +35 -16
  36. package/document-management/models/service-models/document.service-model.js +11 -6
  37. package/document-management/models/service-models/document.view-model.d.ts +1 -1
  38. package/document-management/models/service-models/document.view-model.js +2 -2
  39. package/document-management/server/drizzle/{0000_useful_overlord.sql → 0000_cool_victor_mancha.sql} +97 -41
  40. package/document-management/server/drizzle/meta/0000_snapshot.json +514 -126
  41. package/document-management/server/drizzle/meta/_journal.json +2 -2
  42. package/document-management/server/index.d.ts +1 -0
  43. package/document-management/server/index.js +1 -0
  44. package/document-management/server/module.d.ts +2 -1
  45. package/document-management/server/module.js +3 -1
  46. package/document-management/server/schemas.d.ts +14 -11
  47. package/document-management/server/schemas.js +13 -10
  48. package/document-management/server/services/document-management-ancillary.service.d.ts +4 -0
  49. package/document-management/server/services/document-management-ancillary.service.js +13 -0
  50. package/document-management/server/services/document-management.service.d.ts +63 -28
  51. package/document-management/server/services/document-management.service.js +507 -108
  52. package/document-management/server/services/index.d.ts +1 -0
  53. package/document-management/server/services/index.js +1 -0
  54. package/eslint.config.js +1 -0
  55. package/examples/document-management/main.d.ts +5 -0
  56. package/examples/document-management/main.js +20 -2
  57. package/file/index.d.ts +1 -0
  58. package/file/index.js +1 -0
  59. package/file/temporary-file.d.ts +18 -0
  60. package/file/temporary-file.js +53 -0
  61. package/http/server/http-server-response.d.ts +2 -0
  62. package/http/server/http-server-response.js +13 -0
  63. package/injector/index.d.ts +1 -0
  64. package/injector/index.js +1 -0
  65. package/injector/injector.js +19 -7
  66. package/injector/interfaces.d.ts +1 -1
  67. package/injector/interfaces.js +1 -1
  68. package/injector/resolution.d.ts +15 -0
  69. package/injector/resolution.js +6 -0
  70. package/logger/console/logger.d.ts +1 -1
  71. package/logger/logger.d.ts +1 -1
  72. package/object-storage/object-storage.d.ts +5 -7
  73. package/object-storage/s3/s3.object-storage.d.ts +0 -1
  74. package/object-storage/s3/s3.object-storage.js +0 -3
  75. package/orm/{server/data-types → data-types}/numeric-date.js +2 -3
  76. package/orm/decorators.d.ts +13 -4
  77. package/orm/decorators.js +13 -7
  78. package/orm/entity.js +3 -7
  79. package/orm/index.d.ts +1 -0
  80. package/orm/index.js +1 -0
  81. package/orm/server/drizzle/schema-converter.js +48 -19
  82. package/orm/server/repository.d.ts +5 -4
  83. package/orm/server/repository.js +33 -22
  84. package/orm/server/sqls.d.ts +9 -1
  85. package/orm/server/sqls.js +13 -0
  86. package/orm/types.d.ts +3 -3
  87. package/orm/utils.d.ts +3 -0
  88. package/orm/utils.js +6 -0
  89. package/package.json +13 -11
  90. package/pdf/pdf.service.d.ts +0 -1
  91. package/pdf/pdf.service.js +1 -95
  92. package/pdf/utils.d.ts +3 -1
  93. package/pdf/utils.js +129 -4
  94. package/promise/lazy-promise.d.ts +3 -3
  95. package/queue/postgres/module.d.ts +1 -1
  96. package/queue/postgres/queue.js +10 -12
  97. package/queue/queue.d.ts +14 -0
  98. package/queue/queue.js +43 -0
  99. package/utils/date-time.d.ts +4 -2
  100. package/utils/date-time.js +10 -3
  101. package/utils/format-error.js +0 -1
  102. package/utils/object/lazy-property.js +0 -1
  103. package/utils/try-ignore.d.ts +9 -2
  104. package/utils/try-ignore.js +30 -6
  105. package/document-management/models/document-index.model.d.ts +0 -7
  106. /package/orm/{server/data-types → data-types}/bytea.d.ts +0 -0
  107. /package/orm/{server/data-types → data-types}/bytea.js +0 -0
  108. /package/orm/{server/data-types → data-types}/index.d.ts +0 -0
  109. /package/orm/{server/data-types → data-types}/index.js +0 -0
  110. /package/orm/{server/data-types → data-types}/numeric-date.d.ts +0 -0
  111. /package/orm/{server/data-types → data-types}/timestamp.d.ts +0 -0
  112. /package/orm/{server/data-types → data-types}/timestamp.js +0 -0
package/pdf/utils.js CHANGED
@@ -1,11 +1,136 @@
1
+ var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
2
+ if (value !== null && value !== void 0) {
3
+ if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
4
+ var dispose, inner;
5
+ if (async) {
6
+ if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
7
+ dispose = value[Symbol.asyncDispose];
8
+ }
9
+ if (dispose === void 0) {
10
+ if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
11
+ dispose = value[Symbol.dispose];
12
+ if (async) inner = dispose;
13
+ }
14
+ if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
15
+ if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
16
+ env.stack.push({ value: value, dispose: dispose, async: async });
17
+ }
18
+ else if (async) {
19
+ env.stack.push({ async: true });
20
+ }
21
+ return value;
22
+ };
23
+ var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
24
+ return function (env) {
25
+ function fail(e) {
26
+ env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
27
+ env.hasError = true;
28
+ }
29
+ var r, s = 0;
30
+ function next() {
31
+ while (r = env.stack.pop()) {
32
+ try {
33
+ if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
34
+ if (r.dispose) {
35
+ var result = r.dispose.call(r.value);
36
+ if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
37
+ }
38
+ else s |= 1;
39
+ }
40
+ catch (e) {
41
+ fail(e);
42
+ }
43
+ }
44
+ if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
45
+ if (env.hasError) throw env.error;
46
+ }
47
+ return next();
48
+ };
49
+ })(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
50
+ var e = new Error(message);
51
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
52
+ });
53
+ import { TemporaryFile } from '../file/temporary-file.js';
1
54
  import { spawnCommand } from '../process/spawn.js';
55
+ import { isString } from '../utils/type-guards.js';
2
56
  export async function getPdfPageCount(file) {
3
- const process = await spawnCommand('qpdf', ['--show-npages', file]);
57
+ const env_1 = { stack: [], error: void 0, hasError: false };
58
+ try {
59
+ const fileIsPath = isString(file);
60
+ const tmpFile = __addDisposableResource(env_1, fileIsPath ? await TemporaryFile.from(file) : undefined, true);
61
+ const path = fileIsPath ? file : tmpFile.path;
62
+ const process = await spawnCommand('qpdf', ['--show-npages', path]);
63
+ const { code } = await process.wait();
64
+ if (code != 0) {
65
+ const errorOutput = await process.readError();
66
+ throw new Error(errorOutput.trim());
67
+ }
68
+ const output = await process.readOutput();
69
+ return Number(output);
70
+ }
71
+ catch (e_1) {
72
+ env_1.error = e_1;
73
+ env_1.hasError = true;
74
+ }
75
+ finally {
76
+ const result_1 = __disposeResources(env_1);
77
+ if (result_1)
78
+ await result_1;
79
+ }
80
+ }
81
+ export async function mergePdfs(pdfs) {
82
+ const env_2 = { stack: [], error: void 0, hasError: false };
83
+ try {
84
+ const stack = __addDisposableResource(env_2, new AsyncDisposableStack(), true);
85
+ const resultFile = __addDisposableResource(env_2, TemporaryFile.create(), true);
86
+ const sourceFiles = await getPdfSourceFiles(pdfs, stack);
87
+ await pdfunite(sourceFiles, resultFile);
88
+ return await resultFile.read();
89
+ }
90
+ catch (e_2) {
91
+ env_2.error = e_2;
92
+ env_2.hasError = true;
93
+ }
94
+ finally {
95
+ const result_2 = __disposeResources(env_2);
96
+ if (result_2)
97
+ await result_2;
98
+ }
99
+ }
100
+ export async function mergePdfsStream(pdfs) {
101
+ const env_3 = { stack: [], error: void 0, hasError: false };
102
+ try {
103
+ const stack = __addDisposableResource(env_3, new AsyncDisposableStack(), true);
104
+ const resultFile = __addDisposableResource(env_3, TemporaryFile.create(), true);
105
+ const sourceFiles = await getPdfSourceFiles(pdfs, stack);
106
+ await pdfunite(sourceFiles, resultFile);
107
+ return resultFile.readStream();
108
+ }
109
+ catch (e_3) {
110
+ env_3.error = e_3;
111
+ env_3.hasError = true;
112
+ }
113
+ finally {
114
+ const result_3 = __disposeResources(env_3);
115
+ if (result_3)
116
+ await result_3;
117
+ }
118
+ }
119
+ async function getPdfSourceFiles(pdfs, stack) {
120
+ return await Promise.all(pdfs.map(async (pdf) => {
121
+ if (isString(pdf)) {
122
+ return pdf;
123
+ }
124
+ const tmpFile = await TemporaryFile.from(pdf);
125
+ stack.use(tmpFile);
126
+ return tmpFile.path;
127
+ }));
128
+ }
129
+ async function pdfunite(sourceFiles, resultFile) {
130
+ const process = await spawnCommand('pdfunite', [...sourceFiles, resultFile.path]);
4
131
  const { code } = await process.wait();
5
132
  if (code != 0) {
6
133
  const errorOutput = await process.readError();
7
- throw new Error(errorOutput.trim());
134
+ throw new Error(errorOutput);
8
135
  }
9
- const output = await process.readOutput();
10
- return Number(output);
11
136
  }
@@ -4,8 +4,8 @@ export declare class LazyPromise<T> extends CustomPromise<T> {
4
4
  #private;
5
5
  readonly [Symbol.toStringTag] = "LazyPromise";
6
6
  constructor(executorOrPromiseProvider: PromiseExecutor<T> | (() => PromiseLike<T>));
7
- then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined): Promise<TResult1 | TResult2>;
8
- catch<TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null | undefined): Promise<T | TResult>;
9
- finally(onfinally?: (() => void) | null | undefined): Promise<T>;
7
+ then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
8
+ catch<TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null): Promise<T | TResult>;
9
+ finally(onfinally?: (() => void) | null): Promise<T>;
10
10
  private execute;
11
11
  }
@@ -5,5 +5,5 @@ export declare class PostgresQueueModuleConfig {
5
5
  /**
6
6
  * configure mail module
7
7
  */
8
- export declare function configurePostgresQueue(config: PostgresQueueModuleConfig, register?: boolean): void;
8
+ export declare function configurePostgresQueue(config?: PostgresQueueModuleConfig, register?: boolean): void;
9
9
  export declare function migratePostgresQueueSchema(): Promise<void>;
@@ -11,7 +11,7 @@ import { inject, injectArgument, provide, Singleton } from '../../injector/index
11
11
  import { MessageBus } from '../../message-bus/index.js';
12
12
  import { DatabaseConfig, EntityRepositoryConfig, injectRepository, interval, RANDOM_UUID, TRANSACTION_TIMESTAMP } from '../../orm/server/index.js';
13
13
  import { cancelableTimeout } from '../../utils/timing.js';
14
- import { isString } from '../../utils/type-guards.js';
14
+ import { isDefined, isString } from '../../utils/type-guards.js';
15
15
  import { millisecondsPerSecond } from '../../utils/units.js';
16
16
  import { defaultQueueConfig, Queue, UniqueTagStrategy } from '../queue.js';
17
17
  import { PostgresJob } from './job.model.js';
@@ -35,13 +35,13 @@ let PostgresQueue = class PostgresQueue extends Queue {
35
35
  lastDequeueTimestamp: null,
36
36
  data: sql `excluded.data`
37
37
  };
38
- #dequeueQuery = and(eq(job.queue, this.#queueName), lt(job.tries, this.#maxTries), or(isSqlNull(job.lastDequeueTimestamp), lte(job.lastDequeueTimestamp, sql `${job.lastDequeueTimestamp} + ${interval(this.#processTimeout, 'milliseconds')}`)));
38
+ #dequeueQuery = and(eq(job.queue, this.#queueName), lt(job.tries, this.#maxTries), or(isSqlNull(job.lastDequeueTimestamp), lte(sql `${job.lastDequeueTimestamp} + ${interval(this.#processTimeout, 'milliseconds')}`, TRANSACTION_TIMESTAMP)));
39
39
  #dequeueUpdate = {
40
40
  tries: sql `${job.tries} + 1`,
41
41
  lastDequeueTimestamp: TRANSACTION_TIMESTAMP
42
42
  };
43
43
  async enqueue(data, options) {
44
- const jobs = await this.enqueueMany([{ data, tag: options?.tag, priority: options?.priority }], { returnJobs: true });
44
+ const jobs = await this.enqueueMany([{ data, tag: options?.tag, priority: options?.priority }], { uniqueTag: options?.uniqueTag, returnJobs: true });
45
45
  return jobs[0];
46
46
  }
47
47
  async enqueueMany(items, options) {
@@ -96,11 +96,13 @@ let PostgresQueue = class PostgresQueue extends Queue {
96
96
  const rows = await this.#repository.session
97
97
  .update(job)
98
98
  .set(this.#dequeueUpdate)
99
- .where(inArray(job.id, this.#repository.session.select({ id: job.id })
99
+ .where(inArray(job.id, this.#repository.session
100
+ .select({ id: job.id })
100
101
  .from(job)
101
102
  .where(this.#dequeueQuery)
102
103
  .orderBy(asc(job.priority), asc(job.enqueueTimestamp), asc(job.lastDequeueTimestamp), asc(job.tries))
103
- .limit(count)))
104
+ .limit(count)
105
+ .for('update')))
104
106
  .returning();
105
107
  return this.#repository.$mapManyToEntity(rows); // eslint-disable-line @typescript-eslint/no-unsafe-argument
106
108
  }
@@ -115,15 +117,11 @@ let PostgresQueue = class PostgresQueue extends Queue {
115
117
  const continue$ = merge(this.#messageBus.allMessages$, cancellationSignal);
116
118
  while (cancellationSignal.isUnset) {
117
119
  const job = await this.dequeue();
118
- if (job != undefined) {
120
+ if (isDefined(job)) {
119
121
  yield job;
122
+ continue;
120
123
  }
121
- else {
122
- const cancelled = await cancelableTimeout(5 * millisecondsPerSecond, continue$);
123
- if (cancelled) {
124
- break;
125
- }
126
- }
124
+ await cancelableTimeout(5 * millisecondsPerSecond, continue$);
127
125
  }
128
126
  }
129
127
  async *getBatchConsumer(size, cancellationSignal) {
package/queue/queue.d.ts CHANGED
@@ -1,6 +1,9 @@
1
1
  import type { CancellationSignal } from '../cancellation/token.js';
2
2
  import type { Resolvable, resolveArgumentType } from '../injector/interfaces.js';
3
+ import type { Logger } from '../logger/logger.js';
3
4
  import { QueueEnqueueBatch } from './enqueue-batch.js';
5
+ export type ProcessWorker<T> = (job: Job<T>) => void | Promise<void>;
6
+ export type ProcessBatchWorker<T> = (jobs: Job<T>[]) => void | Promise<void>;
4
7
  export type JobTag = string | null;
5
8
  export type Job<T> = {
6
9
  id: string;
@@ -66,4 +69,15 @@ export declare abstract class Queue<T> implements Resolvable<QueueArgument> {
66
69
  abstract acknowledgeMany(jobs: Job<T>[]): Promise<void>;
67
70
  abstract getConsumer(cancellationSignal: CancellationSignal): AsyncIterableIterator<Job<T>>;
68
71
  abstract getBatchConsumer(size: number, cancellationSignal: CancellationSignal): AsyncIterableIterator<Job<T>[]>;
72
+ process({ concurrency, cancellationSignal }: {
73
+ concurrency?: number;
74
+ cancellationSignal: CancellationSignal;
75
+ }, handler: ProcessWorker<T>, errorHandler?: Logger | ((error: unknown) => void | Promise<void>)): void;
76
+ processBatch({ batchSize, concurrency, cancellationSignal }: {
77
+ batchSize?: number;
78
+ concurrency?: number;
79
+ cancellationSignal: CancellationSignal;
80
+ }, handler: ProcessBatchWorker<T>, errorHandler?: Logger | ((error: unknown) => void | Promise<void>)): void;
81
+ private processWorker;
82
+ private processBatchWorker;
69
83
  }
package/queue/queue.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { isDefined, isFunction } from '../utils/type-guards.js';
1
2
  import { millisecondsPerMinute } from '../utils/units.js';
2
3
  import { QueueEnqueueBatch } from './enqueue-batch.js';
3
4
  export const defaultJobPriority = 1000;
@@ -14,4 +15,46 @@ export class Queue {
14
15
  batch() {
15
16
  return new QueueEnqueueBatch(this);
16
17
  }
18
+ process({ concurrency = 1, cancellationSignal }, handler, errorHandler) {
19
+ const handleError = isFunction(errorHandler)
20
+ ? errorHandler
21
+ : isDefined(errorHandler)
22
+ ? (error) => errorHandler.error(error)
23
+ : undefined;
24
+ for (let i = 0; i < concurrency; i++) {
25
+ void this.processWorker(cancellationSignal, handler, handleError);
26
+ }
27
+ }
28
+ processBatch({ batchSize = 10, concurrency = 1, cancellationSignal }, handler, errorHandler) {
29
+ const handleError = isFunction(errorHandler)
30
+ ? errorHandler
31
+ : isDefined(errorHandler)
32
+ ? (error) => errorHandler.error(error)
33
+ : undefined;
34
+ for (let i = 0; i < concurrency; i++) {
35
+ void this.processBatchWorker(batchSize, cancellationSignal, handler, handleError);
36
+ }
37
+ }
38
+ async processWorker(cancellationSignal, handler, errorHandler) {
39
+ for await (const job of this.getConsumer(cancellationSignal)) {
40
+ try {
41
+ await handler(job);
42
+ await this.acknowledge(job);
43
+ }
44
+ catch (error) {
45
+ await errorHandler?.(error);
46
+ }
47
+ }
48
+ }
49
+ async processBatchWorker(size, cancellationSignal, handler, errorHandler) {
50
+ for await (const jobs of this.getBatchConsumer(size, cancellationSignal)) {
51
+ try {
52
+ await handler(jobs);
53
+ await this.acknowledgeMany(jobs);
54
+ }
55
+ catch (error) {
56
+ await errorHandler?.(error);
57
+ }
58
+ }
59
+ }
17
60
  }
@@ -42,13 +42,15 @@ export declare function timeObjectToNumericTime(time: Partial<TimeObject>): numb
42
42
  export declare function numericTimeToTimeObject(time: number): TimeObject;
43
43
  export declare function timestampToNumericDateAndTime(timestamp: number): NumericDateTime;
44
44
  export declare function numericDateToTimestamp(numericDate: number): number;
45
- export declare function numericDateToDate(numericDate: number): {
45
+ export declare function numericDateToDate(numericDate: number): Date;
46
+ export declare function numericDateToDateObject(numericDate: number): {
46
47
  year: number;
47
48
  month: number;
48
49
  day: number;
49
50
  };
50
51
  export declare function numericDateTimeToTimestamp({ date, time }: NumericDateTime): number;
51
- export declare function zonedDateObjectToDateTime(zonedDate: ZonedDateObject, units?: DateObjectUnits, options?: DateTimeJSOptions): DateTime;
52
+ export declare function dateObjectToDateTime(dateObject: ZonedDateObject, units?: DateObjectUnits, options?: DateTimeJSOptions): DateTime;
53
+ export declare function dateObjectToNumericDate(dateObject: DateObject): number;
52
54
  export declare function dateTimeToNumericDate(dateTime: DateTime): number;
53
55
  export declare function numericDateToDateTime(numericDate: number, units?: DateObjectUnits, options?: DateTimeJSOptions): DateTime;
54
56
  export declare function dateTimeToTime(dateTime: DateTime): number;
@@ -74,7 +74,10 @@ export function numericDateToTimestamp(numericDate) {
74
74
  }
75
75
  export function numericDateToDate(numericDate) {
76
76
  const timestamp = numericDateToTimestamp(numericDate);
77
- const date = new Date(timestamp);
77
+ return new Date(timestamp);
78
+ }
79
+ export function numericDateToDateObject(numericDate) {
80
+ const date = numericDateToDate(numericDate);
78
81
  return {
79
82
  year: date.getUTCFullYear(),
80
83
  month: date.getUTCMonth() + 1,
@@ -84,8 +87,12 @@ export function numericDateToDate(numericDate) {
84
87
  export function numericDateTimeToTimestamp({ date, time }) {
85
88
  return numericDateToTimestamp(date) + time;
86
89
  }
87
- export function zonedDateObjectToDateTime(zonedDate, units, options) {
88
- return DateTime.fromObject({ ...zonedDate, ...units }, options);
90
+ export function dateObjectToDateTime(dateObject, units, options) {
91
+ return DateTime.fromObject({ ...dateObject, ...units }, options);
92
+ }
93
+ export function dateObjectToNumericDate(dateObject) {
94
+ const dateTime = DateTime.fromObject({ ...dateObject }, { zone: 'UTC' });
95
+ return dateTimeToNumericDate(dateTime);
89
96
  }
90
97
  export function dateTimeToNumericDate(dateTime) {
91
98
  const timestamp = dateTime.toUTC(undefined, { keepLocalTime: true }).toMillis();
@@ -2,7 +2,6 @@ import { unwrapError } from '../errors/utils.js';
2
2
  import { decycle } from './object/decycle.js';
3
3
  import { objectKeys } from './object/object.js';
4
4
  import { isDefined, isFunction, isUndefined } from './type-guards.js';
5
- // eslint-disable-next-line max-statements, complexity
6
5
  export function formatError(error, options = {}) {
7
6
  const { includeRest = 'if-no-extra-info', includeExtraInfo = true, includeStack = true } = options;
8
7
  let name;
@@ -36,7 +36,6 @@ export function lazyProperty(object, propertyKey, initializer, descriptor = {})
36
36
  configurable
37
37
  });
38
38
  }
39
- // eslint-disable-next-line max-statements, max-lines-per-function
40
39
  export function lazyObject(initializers) {
41
40
  const object = {};
42
41
  for (const [key, value] of objectEntries(initializers)) {
@@ -1,2 +1,9 @@
1
- export declare function tryIgnore(fn: () => any): void;
2
- export declare function tryIgnoreAsync(fn: () => Promise<any>): Promise<void>;
1
+ import type { Logger } from '../logger/logger.js';
2
+ export declare function tryIgnore<R>(fn: () => R): R;
3
+ export declare function tryIgnore<R, F>(fn: () => R, fallback: F): R | F;
4
+ export declare function tryIgnoreAsync<R>(fn: () => Promise<R>): Promise<R>;
5
+ export declare function tryIgnoreAsync<R, F>(fn: () => Promise<R>, fallback: F): Promise<F>;
6
+ export declare function tryIgnoreLog<R>(fn: () => R, logger: Logger): R;
7
+ export declare function tryIgnoreLog<R, F>(fn: () => R, logger: Logger, fallback: F): R | F;
8
+ export declare function tryIgnoreLogAsync<R>(fn: () => Promise<R>, logger: Logger): Promise<R>;
9
+ export declare function tryIgnoreLogAsync<R, F>(fn: () => Promise<R>, logger: Logger, fallback: F): Promise<F>;
@@ -1,12 +1,36 @@
1
- export function tryIgnore(fn) {
1
+ export function tryIgnore(fn, fallback) {
2
2
  try {
3
- fn();
3
+ return fn();
4
+ }
5
+ catch {
6
+ return fallback;
7
+ }
8
+ }
9
+ export async function tryIgnoreAsync(fn, fallback) {
10
+ try {
11
+ const value = await fn();
12
+ return value;
13
+ }
14
+ catch {
15
+ return fallback;
4
16
  }
5
- catch { /* ignore */ }
6
17
  }
7
- export async function tryIgnoreAsync(fn) {
18
+ export function tryIgnoreLog(fn, logger, fallback) {
8
19
  try {
9
- await fn();
20
+ return fn();
21
+ }
22
+ catch (error) {
23
+ logger.error(error);
24
+ return fallback;
25
+ }
26
+ }
27
+ export async function tryIgnoreLogAsync(fn, logger, fallback) {
28
+ try {
29
+ const value = await fn();
30
+ return value;
31
+ }
32
+ catch (error) {
33
+ logger.error(error);
34
+ return fallback;
10
35
  }
11
- catch { /* ignore */ }
12
36
  }
@@ -1,7 +0,0 @@
1
- import { Entity } from '../../orm/entity.js';
2
- import { Uuid } from '../../orm/types.js';
3
- export declare class DocumentIndex extends Entity {
4
- documentId: Uuid;
5
- summary: string;
6
- tags: string[];
7
- }
File without changes
File without changes