@tstdl/base 0.92.85 → 0.92.87

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 (152) hide show
  1. package/ai/ai.service.d.ts +4 -4
  2. package/ai/ai.service.js +27 -14
  3. package/ai/types.d.ts +5 -4
  4. package/api/server/gateway.js +1 -1
  5. package/authentication/authentication.api.d.ts +9 -9
  6. package/authentication/models/schemas.d.ts +2 -2
  7. package/authentication/server/authentication-ancillary.service.d.ts +6 -4
  8. package/authentication/server/authentication-ancillary.service.js +5 -5
  9. package/cancellation/token.d.ts +1 -1
  10. package/context/context.d.ts +1 -9
  11. package/context/context.js +8 -5
  12. package/document-management/api/document-management.api.d.ts +142 -110
  13. package/document-management/models/document-category.model.d.ts +1 -0
  14. package/document-management/models/document-category.model.js +2 -0
  15. package/document-management/models/document-collection-document.model.js +7 -3
  16. package/document-management/models/document-property-value.model.d.ts +13 -14
  17. package/document-management/models/document-property-value.model.js +60 -27
  18. package/document-management/models/document-property.model.d.ts +2 -0
  19. package/document-management/models/document-property.model.js +4 -1
  20. package/document-management/models/document-request-assignment-task-collection.model.d.ts +7 -0
  21. package/document-management/models/document-request-assignment-task-collection.model.js +32 -0
  22. package/document-management/models/document-request-assignment-task.model.d.ts +14 -0
  23. package/document-management/models/document-request-assignment-task.model.js +72 -0
  24. package/document-management/models/document-request-collection.model.d.ts +1 -0
  25. package/document-management/models/document-request-collection.model.js +7 -3
  26. package/document-management/models/document-request-file.model.d.ts +7 -2
  27. package/document-management/models/document-request-file.model.js +29 -4
  28. package/document-management/models/document-request.model.d.ts +1 -0
  29. package/document-management/models/document-requests-template.js +2 -0
  30. package/document-management/models/document-type-property.model.js +7 -3
  31. package/document-management/models/document-type.model.d.ts +1 -0
  32. package/document-management/models/document-type.model.js +7 -3
  33. package/document-management/models/document.model.d.ts +5 -2
  34. package/document-management/models/document.model.js +21 -6
  35. package/document-management/models/index.d.ts +2 -0
  36. package/document-management/models/index.js +2 -0
  37. package/document-management/models/service-models/document.service-model.d.ts +84 -65
  38. package/document-management/models/service-models/document.service-model.js +11 -6
  39. package/document-management/models/service-models/document.view-model.d.ts +1 -1
  40. package/document-management/models/service-models/document.view-model.js +2 -2
  41. package/document-management/server/drizzle/{0000_sloppy_fenris.sql → 0000_cool_victor_mancha.sql} +99 -43
  42. package/document-management/server/drizzle/meta/0000_snapshot.json +518 -130
  43. package/document-management/server/drizzle/meta/_journal.json +2 -2
  44. package/document-management/server/drizzle.config.js +1 -1
  45. package/document-management/server/module.d.ts +3 -2
  46. package/document-management/server/module.js +4 -2
  47. package/document-management/server/schemas.d.ts +36 -0
  48. package/document-management/server/schemas.js +37 -0
  49. package/document-management/server/services/document-management-ancillary.service.d.ts +4 -0
  50. package/document-management/server/services/document-management-ancillary.service.js +13 -0
  51. package/document-management/server/services/document-management.service.d.ts +71 -22
  52. package/document-management/server/services/document-management.service.js +528 -81
  53. package/document-management/server/services/index.d.ts +1 -0
  54. package/document-management/server/services/index.js +1 -0
  55. package/eslint.config.js +1 -0
  56. package/examples/document-management/main.d.ts +5 -0
  57. package/examples/document-management/main.js +20 -2
  58. package/examples/orm/schemas.d.ts +1 -1
  59. package/file/index.d.ts +1 -0
  60. package/file/index.js +1 -0
  61. package/file/temporary-file.d.ts +17 -0
  62. package/file/temporary-file.js +49 -0
  63. package/http/server/http-server-response.d.ts +2 -0
  64. package/http/server/http-server-response.js +13 -0
  65. package/injector/index.d.ts +1 -0
  66. package/injector/index.js +1 -0
  67. package/injector/injector.js +19 -7
  68. package/injector/interfaces.d.ts +1 -1
  69. package/injector/interfaces.js +1 -1
  70. package/injector/resolution.d.ts +15 -0
  71. package/injector/resolution.js +6 -0
  72. package/logger/console/logger.d.ts +1 -1
  73. package/logger/logger.d.ts +1 -1
  74. package/mail/drizzle.config.js +1 -1
  75. package/mail/models/schemas.d.ts +1 -1
  76. package/object-storage/object-storage.d.ts +5 -7
  77. package/object-storage/s3/s3.object-storage.d.ts +0 -1
  78. package/object-storage/s3/s3.object-storage.js +0 -3
  79. package/orm/{server/data-types → data-types}/numeric-date.js +2 -3
  80. package/orm/decorators.d.ts +17 -8
  81. package/orm/decorators.js +13 -7
  82. package/orm/entity.d.ts +5 -7
  83. package/orm/entity.js +11 -7
  84. package/orm/index.d.ts +2 -0
  85. package/orm/index.js +2 -0
  86. package/orm/query.d.ts +1 -3
  87. package/orm/query.js +0 -1
  88. package/orm/repository.types.d.ts +32 -0
  89. package/orm/repository.types.js +1 -0
  90. package/orm/server/database-schema.d.ts +4 -4
  91. package/orm/server/drizzle/schema-converter.d.ts +1 -1
  92. package/orm/server/drizzle/schema-converter.js +48 -19
  93. package/orm/server/index.d.ts +1 -0
  94. package/orm/server/index.js +1 -0
  95. package/orm/server/query-converter.d.ts +1 -2
  96. package/orm/server/query-converter.js +66 -61
  97. package/orm/server/repository.d.ts +80 -43
  98. package/orm/server/repository.js +219 -112
  99. package/orm/server/sqls.d.ts +15 -0
  100. package/orm/server/sqls.js +19 -0
  101. package/orm/server/types.d.ts +3 -3
  102. package/orm/types.d.ts +4 -4
  103. package/orm/utils.d.ts +3 -0
  104. package/orm/utils.js +6 -0
  105. package/package.json +23 -19
  106. package/pdf/pdf.service.d.ts +0 -1
  107. package/pdf/pdf.service.js +1 -95
  108. package/pdf/utils.d.ts +3 -1
  109. package/pdf/utils.js +129 -4
  110. package/promise/lazy-promise.d.ts +3 -3
  111. package/queue/enqueue-batch.d.ts +1 -0
  112. package/queue/enqueue-batch.js +1 -1
  113. package/queue/mongo/queue.d.ts +9 -4
  114. package/queue/mongo/queue.js +5 -6
  115. package/queue/postgres/drizzle/0000_zippy_moondragon.sql +11 -0
  116. package/queue/postgres/drizzle/meta/0000_snapshot.json +90 -0
  117. package/queue/postgres/drizzle/meta/_journal.json +13 -0
  118. package/queue/postgres/drizzle.config.d.ts +2 -0
  119. package/queue/postgres/drizzle.config.js +11 -0
  120. package/queue/postgres/index.d.ts +4 -0
  121. package/queue/postgres/index.js +4 -0
  122. package/queue/postgres/job.model.d.ts +13 -0
  123. package/queue/postgres/job.model.js +55 -0
  124. package/queue/postgres/module.d.ts +9 -0
  125. package/queue/postgres/module.js +29 -0
  126. package/queue/postgres/queue.d.ts +28 -0
  127. package/queue/postgres/queue.js +147 -0
  128. package/queue/postgres/queue.provider.d.ts +7 -0
  129. package/queue/postgres/queue.provider.js +21 -0
  130. package/queue/postgres/schemas.d.ts +3 -0
  131. package/queue/postgres/schemas.js +4 -0
  132. package/queue/provider.d.ts +2 -1
  133. package/queue/queue.d.ts +32 -6
  134. package/queue/queue.js +43 -0
  135. package/schema/schemas/object.d.ts +1 -1
  136. package/utils/date-time.d.ts +4 -2
  137. package/utils/date-time.js +10 -3
  138. package/utils/format-error.js +0 -1
  139. package/utils/object/lazy-property.js +0 -1
  140. package/utils/timing.d.ts +4 -3
  141. package/utils/timing.js +3 -1
  142. package/utils/try-ignore.d.ts +9 -2
  143. package/utils/try-ignore.js +30 -6
  144. package/document-management/models/schemas.d.ts +0 -33
  145. package/document-management/models/schemas.js +0 -34
  146. /package/orm/{server/data-types → data-types}/bytea.d.ts +0 -0
  147. /package/orm/{server/data-types → data-types}/bytea.js +0 -0
  148. /package/orm/{server/data-types → data-types}/index.d.ts +0 -0
  149. /package/orm/{server/data-types → data-types}/index.js +0 -0
  150. /package/orm/{server/data-types → data-types}/numeric-date.d.ts +0 -0
  151. /package/orm/{server/data-types → data-types}/timestamp.d.ts +0 -0
  152. /package/orm/{server/data-types → data-types}/timestamp.js +0 -0
@@ -44,7 +44,7 @@ export declare class AiService implements Resolvable<AiServiceArgument> {
44
44
  processFiles(fileInputs: FileInput[]): Promise<FileContentPart[]>;
45
45
  getFileById(id: string): FileContentPart;
46
46
  classify<T extends EnumerationType>(parts: OneOrMany<ContentPart>, types: T, options?: GenerationOptions & Pick<GenerationRequest, 'model'>): Promise<SpecializedGenerationResult<ClassificationResult<T>>>;
47
- getClassifyConents(parts: OneOrMany<ContentPart>): Content[];
47
+ getClassifyContents(parts: OneOrMany<ContentPart>): Content[];
48
48
  extractData<T>(parts: OneOrMany<ContentPart>, schema: SchemaTestable<T>, options?: GenerationOptions & Pick<GenerationRequest, 'model'>): Promise<SpecializedGenerationResult<T>>;
49
49
  getExtractDataConents(parts: OneOrMany<ContentPart>): Content[];
50
50
  analyzeContent<T extends EnumerationType>(parts: OneOrMany<ContentPart>, types: T, options?: GenerationOptions & {
@@ -54,8 +54,8 @@ export declare class AiService implements Resolvable<AiServiceArgument> {
54
54
  getAnalyzeContentConents(parts: OneOrMany<ContentPart>): Content[];
55
55
  callFunctions<const T extends SchemaFunctionDeclarations>(options: CallFunctionsOptions<T>): Promise<SpecializedGenerationResult<SchemaFunctionDeclarationsResult<T>[]>>;
56
56
  callFunctionsStream<const T extends SchemaFunctionDeclarations>(options: CallFunctionsOptions<T>): SpecializedGenerationResultGenerator<SchemaFunctionDeclarationsResult<T>>;
57
- generate(request: GenerationRequest): Promise<GenerationResult>;
58
- generateStream(request: GenerationRequest): AsyncGenerator<GenerationResult>;
57
+ generate<S>(request: GenerationRequest<S>): Promise<GenerationResult<S>>;
58
+ generateStream<S>(request: GenerationRequest<S>): AsyncGenerator<GenerationResult<S>>;
59
59
  private _callFunctionsStream;
60
60
  private convertContents;
61
61
  private convertContent;
@@ -63,4 +63,4 @@ export declare class AiService implements Resolvable<AiServiceArgument> {
63
63
  private convertGoogleContent;
64
64
  private getModel;
65
65
  }
66
- export declare function mergeGenerationStreamItems(items: GenerationResult[]): GenerationResult;
66
+ export declare function mergeGenerationStreamItems<S>(items: GenerationResult<S>[], schema?: SchemaTestable<S>): GenerationResult<S>;
package/ai/ai.service.js CHANGED
@@ -13,13 +13,14 @@ import { getShutdownSignal } from '../process-shutdown.js';
13
13
  import { DeferredPromise } from '../promise/deferred-promise.js';
14
14
  import { LazyPromise } from '../promise/lazy-promise.js';
15
15
  import { convertToOpenApiSchema } from '../schema/converters/openapi-converter.js';
16
- import { array, enumeration, nullable, object, string } from '../schema/index.js';
16
+ import { array, enumeration, nullable, object, Schema, string } from '../schema/index.js';
17
17
  import { toArray } from '../utils/array/array.js';
18
18
  import { mapAsync } from '../utils/async-iterable-helpers/map.js';
19
19
  import { toArrayAsync } from '../utils/async-iterable-helpers/to-array.js';
20
+ import { lazyObject } from '../utils/object/lazy-property.js';
20
21
  import { hasOwnProperty, objectEntries } from '../utils/object/object.js';
21
22
  import { cancelableTimeout } from '../utils/timing.js';
22
- import { assertDefinedPass, assertNotNullPass, isDefined, isError, isNotNull, isUndefined } from '../utils/type-guards.js';
23
+ import { assertDefinedPass, assertNotNullPass, isDefined, isError, isNotNull, isNull, isUndefined } from '../utils/type-guards.js';
23
24
  import { millisecondsPerSecond } from '../utils/units.js';
24
25
  import { resolveValueOrAsyncProvider } from '../utils/value-or-provider.js';
25
26
  import { AiFileService } from './ai-file.service.js';
@@ -43,7 +44,7 @@ let AiService = class AiService {
43
44
  #genAI = (isDefined(this.#options.vertex)
44
45
  ? new VertexAI({ project: this.#options.vertex.project, location: this.#options.vertex.location, googleAuthOptions: { apiKey: this.#options.apiKey, keyFile: this.#options.keyFile } })
45
46
  : new GoogleGenerativeAI(assertDefinedPass(this.#options.apiKey, 'Api key not defined')));
46
- defaultModel = this.#options.defaultModel ?? 'gemini-2.0-flash-exp';
47
+ defaultModel = this.#options.defaultModel ?? 'gemini-2.0-flash';
47
48
  createSession() {
48
49
  return new AiSession(this);
49
50
  }
@@ -72,14 +73,14 @@ let AiService = class AiService {
72
73
  },
73
74
  generationSchema,
74
75
  systemInstruction: 'You are a highly accurate document classification AI. Your task is to analyze the content of a given document and determine its type based on a predefined list of possible document types.',
75
- contents: this.getClassifyConents(parts)
76
+ contents: this.getClassifyContents(parts)
76
77
  });
77
78
  return {
78
79
  result: JSON.parse(assertNotNullPass(generation.text, 'No text returned.')),
79
80
  raw: generation
80
81
  };
81
82
  }
82
- getClassifyConents(parts) {
83
+ getClassifyContents(parts) {
83
84
  return [{
84
85
  role: 'user',
85
86
  parts: [
@@ -192,7 +193,7 @@ Always output the content and tags in ${options?.targetLanguage ?? 'the same lan
192
193
  }
193
194
  async generate(request) {
194
195
  const items = await toArrayAsync(this.generateStream(request));
195
- return mergeGenerationStreamItems(items);
196
+ return mergeGenerationStreamItems(items, request.generationSchema);
196
197
  }
197
198
  async *generateStream(request) {
198
199
  const googleFunctionDeclarations = isDefined(request.functions) ? await this.convertFunctions(request.functions) : undefined;
@@ -261,6 +262,9 @@ Always output the content and tags in ${options?.targetLanguage ?? 'the same lan
261
262
  }
262
263
  return text;
263
264
  },
265
+ get json() {
266
+ throw new NotSupportedError('JSON not supported in streamed items. Use mergeGenerationStreamItems to combine all streamed items.');
267
+ },
264
268
  get functionCalls() {
265
269
  if (isUndefined(functionCallParts)) {
266
270
  functionCallParts = content.parts.filter((part) => hasOwnProperty(part, 'functionCall')).map((part) => part.functionCall);
@@ -390,26 +394,35 @@ AiService = __decorate([
390
394
  Singleton()
391
395
  ], AiService);
392
396
  export { AiService };
393
- export function mergeGenerationStreamItems(items) {
397
+ export function mergeGenerationStreamItems(items, schema) {
394
398
  const parts = items.flatMap((item) => item.content.parts);
395
399
  let text;
396
400
  let functionCallParts;
397
- return {
398
- content: { role: 'model', parts },
399
- get text() {
401
+ return lazyObject({
402
+ content: { value: { role: 'model', parts } },
403
+ text() {
400
404
  if (isUndefined(text)) {
401
405
  const textParts = parts.filter((part) => hasOwnProperty(part, 'text')).map((part) => part.text);
402
406
  text = (textParts.length > 0) ? textParts.join('') : null;
403
407
  }
404
408
  return text;
405
409
  },
406
- get functionCalls() {
410
+ json() {
411
+ if (isUndefined(schema)) {
412
+ return undefined;
413
+ }
414
+ if (isNull(this.text)) {
415
+ throw new Error('No text to parse available.');
416
+ }
417
+ return Schema.parse(schema, JSON.parse(this.text));
418
+ },
419
+ functionCalls() {
407
420
  if (isUndefined(functionCallParts)) {
408
421
  functionCallParts = parts.filter((part) => hasOwnProperty(part, 'functionCall')).map((part) => part.functionCall);
409
422
  }
410
423
  return functionCallParts;
411
424
  },
412
- finishReason: items.at(-1).finishReason,
413
- usage: items.at(-1).usage
414
- };
425
+ finishReason: { value: items.at(-1).finishReason },
426
+ usage: { value: items.at(-1).usage }
427
+ });
415
428
  }
package/ai/types.d.ts CHANGED
@@ -52,7 +52,7 @@ export type Content = {
52
52
  };
53
53
  export type FunctionCallingMode = 'auto' | 'force' | 'none';
54
54
  export type FinishReason = 'stop' | 'maxTokens' | 'unknown';
55
- export type AiModel = LiteralUnion<'gemini-2.0-flash-exp' | 'gemini-exp-1206' | 'gemini-2.0-flash-thinking-exp-1219', string>;
55
+ export type AiModel = LiteralUnion<'gemini-2.0-flash' | 'gemini-2.0-flash-lite' | 'gemini-2.0-pro-exp-02-05' | 'gemini-2.0-flash-thinking-exp-01-21', string>;
56
56
  export type GenerationOptions = {
57
57
  maxOutputTokens?: number;
58
58
  temperature?: number;
@@ -60,13 +60,13 @@ export type GenerationOptions = {
60
60
  topK?: number;
61
61
  frequencyPenalty?: number;
62
62
  };
63
- export type GenerationRequest = {
63
+ export type GenerationRequest<S = unknown> = {
64
64
  model?: AiModel;
65
65
  systemInstruction?: string;
66
66
  contents: Content | readonly Content[];
67
67
  functions?: SchemaFunctionDeclarations;
68
68
  functionCallingMode?: FunctionCallingMode;
69
- generationSchema?: SchemaTestable;
69
+ generationSchema?: SchemaTestable<S>;
70
70
  generationOptions?: GenerationOptions;
71
71
  };
72
72
  export type GenerationUsage = {
@@ -75,9 +75,10 @@ export type GenerationUsage = {
75
75
  output: number;
76
76
  total: number;
77
77
  };
78
- export type GenerationResult = {
78
+ export type GenerationResult<S = unknown> = {
79
79
  content: Content;
80
80
  text: string | null;
81
+ json: S;
81
82
  functionCalls: FunctionCall[];
82
83
  finishReason: FinishReason;
83
84
  usage: GenerationUsage;
@@ -10,7 +10,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
10
10
  var __param = (this && this.__param) || function (paramIndex, decorator) {
11
11
  return function (target, key) { decorator(target, key, paramIndex); }
12
12
  };
13
- import 'urlpattern-polyfill'; // eslint-disable-line import/no-unassigned-import
13
+ import 'urlpattern-polyfill';
14
14
  import { BadRequestError } from '../../errors/bad-request.error.js';
15
15
  import { NotFoundError } from '../../errors/not-found.error.js';
16
16
  import { NotImplementedError } from '../../errors/not-implemented.error.js';
@@ -84,8 +84,8 @@ export declare const authenticationApiDefinition: {
84
84
  resource: string;
85
85
  method: "POST";
86
86
  parameters: ObjectSchema<{
87
- readonly token: string;
88
- readonly newSecret: string;
87
+ token: string;
88
+ newSecret: string;
89
89
  }>;
90
90
  result: import("../schema/index.js").LiteralSchema<"ok">;
91
91
  };
@@ -93,7 +93,7 @@ export declare const authenticationApiDefinition: {
93
93
  resource: string;
94
94
  method: "POST";
95
95
  parameters: ObjectSchema<{
96
- readonly secret: string;
96
+ secret: string;
97
97
  }>;
98
98
  result: typeof SecretCheckResult;
99
99
  };
@@ -179,8 +179,8 @@ export declare function getAuthenticationApiDefinition<AdditionalTokenPayload ex
179
179
  resource: string;
180
180
  method: "POST";
181
181
  parameters: ObjectSchema<{
182
- readonly token: string;
183
- readonly newSecret: string;
182
+ token: string;
183
+ newSecret: string;
184
184
  }>;
185
185
  result: import("../schema/index.js").LiteralSchema<"ok">;
186
186
  };
@@ -188,7 +188,7 @@ export declare function getAuthenticationApiDefinition<AdditionalTokenPayload ex
188
188
  resource: string;
189
189
  method: "POST";
190
190
  parameters: ObjectSchema<{
191
- readonly secret: string;
191
+ secret: string;
192
192
  }>;
193
193
  result: typeof SecretCheckResult;
194
194
  };
@@ -272,8 +272,8 @@ export declare function getAuthenticationApiEndpointsDefinition<AdditionalTokenP
272
272
  resource: string;
273
273
  method: "POST";
274
274
  parameters: ObjectSchema<{
275
- readonly token: string;
276
- readonly newSecret: string;
275
+ token: string;
276
+ newSecret: string;
277
277
  }>;
278
278
  result: import("../schema/index.js").LiteralSchema<"ok">;
279
279
  };
@@ -281,7 +281,7 @@ export declare function getAuthenticationApiEndpointsDefinition<AdditionalTokenP
281
281
  resource: string;
282
282
  method: "POST";
283
283
  parameters: ObjectSchema<{
284
- readonly secret: string;
284
+ secret: string;
285
285
  }>;
286
286
  result: typeof SecretCheckResult;
287
287
  };
@@ -1,5 +1,5 @@
1
1
  import { AuthenticationCredentials } from './authentication-credentials.model.js';
2
2
  import { AuthenticationSession } from './authentication-session.model.js';
3
3
  export declare const authenticationSchema: import("../../orm/server/database-schema.js").DatabaseSchema<"authentication">;
4
- export declare const authenticationCredentials: import("../../orm/server/types.js").PgTableFromType<"authentication", typeof AuthenticationCredentials>;
5
- export declare const authenticationSession: import("../../orm/server/types.js").PgTableFromType<"authentication", typeof AuthenticationSession>;
4
+ export declare const authenticationCredentials: import("../../orm/server/types.js").PgTableFromType<typeof AuthenticationCredentials, "authentication">;
5
+ export declare const authenticationSession: import("../../orm/server/types.js").PgTableFromType<typeof AuthenticationSession, "authentication">;
@@ -1,10 +1,12 @@
1
+ import { type EnumType } from '../../enumeration/enumeration.js';
1
2
  import type { Record } from '../../types.js';
2
3
  import type { TokenPayload } from '../index.js';
3
4
  import type { InitSecretResetData } from '../models/init-secret-reset-data.model.js';
4
- export declare enum GetTokenPayloadContextAction {
5
- GetToken = 0,
6
- Refresh = 1
7
- }
5
+ export declare const GetTokenPayloadContextAction: {
6
+ readonly GetToken: "get-token";
7
+ readonly Refresh: "refresh";
8
+ };
9
+ export type GetTokenPayloadContextAction = EnumType<typeof GetTokenPayloadContextAction>;
8
10
  export type GetTokenPayloadContext = {
9
11
  action: GetTokenPayloadContextAction;
10
12
  };
@@ -1,7 +1,7 @@
1
- export var GetTokenPayloadContextAction;
2
- (function (GetTokenPayloadContextAction) {
3
- GetTokenPayloadContextAction[GetTokenPayloadContextAction["GetToken"] = 0] = "GetToken";
4
- GetTokenPayloadContextAction[GetTokenPayloadContextAction["Refresh"] = 1] = "Refresh";
5
- })(GetTokenPayloadContextAction || (GetTokenPayloadContextAction = {}));
1
+ import { defineEnum } from '../../enumeration/enumeration.js';
2
+ export const GetTokenPayloadContextAction = defineEnum('GetTokenPayloadContextAction', {
3
+ GetToken: 'get-token',
4
+ Refresh: 'refresh'
5
+ });
6
6
  export class AuthenticationAncillaryService {
7
7
  }
@@ -81,7 +81,7 @@ export declare class CancellationSignal implements PromiseLike<void>, Subscribab
81
81
  * @param target receiver to connect
82
82
  */
83
83
  connect(target: CancellationToken, config?: ConnectConfig): void;
84
- then<TResult>(onfulfilled?: ((value: void) => TResult | PromiseLike<TResult>) | undefined | null): Promise<TResult>;
84
+ then<TResult>(onfulfilled?: ((value: void) => TResult | PromiseLike<TResult>) | null): Promise<TResult>;
85
85
  subscribe(observer: Partial<Observer<void>>): Unsubscribable;
86
86
  }
87
87
  export declare class CancellationToken extends CancellationSignal {
@@ -7,12 +7,4 @@ export declare function createContextProvider<Context, const Name extends string
7
7
  (required: true, debugFn: Function): Context;
8
8
  (required?: false, debugFn?: Function): Context | null;
9
9
  (required: boolean, debugFn: Function): Context | null;
10
- }> & Record<`setCurrent${Name}Context`, (context: Context | null) => Context | null> & Record<`runIn${Name}Context`, <ReturnT>(context: Context, fn: () => ReturnT) => ReturnT> & Record<`isIn${Name}Context`, {
11
- (required: true, debugFn: Function): Context;
12
- (required?: false, debugFn?: Function): Context | null;
13
- (required: boolean, debugFn: Function): Context | null;
14
- }> & Record<`assertIn${Name}Context`, {
15
- (required: true, debugFn: Function): Context;
16
- (required?: false, debugFn?: Function): Context | null;
17
- (required: boolean, debugFn: Function): Context | null;
18
- }>>;
10
+ }> & Record<`setCurrent${Name}Context`, (context: Context | null) => Context | null> & Record<`runIn${Name}Context`, <ReturnT>(context: Context, fn: () => ReturnT) => ReturnT> & Record<`isIn${Name}Context`, () => boolean> & Record<`assertIn${Name}Context`, (debugFnOrMessage: Function | string) => void>>;
@@ -1,4 +1,4 @@
1
- import { isNotNull } from '../utils/type-guards.js';
1
+ import { isNotNull, isString } from '../utils/type-guards.js';
2
2
  /**
3
3
  * Creates a new context provider
4
4
  * @param name name of of the context used for function names
@@ -48,16 +48,19 @@ export function createContextProvider(name) {
48
48
  *
49
49
  * @param debugFn a reference to the function making the assertion (used for the error message).
50
50
  */
51
- function assertInContext(debugFn) {
51
+ function assertInContext(debugFnOrMessage) {
52
52
  if (!isInContext()) {
53
- throw new Error(`${debugFn.name}() can only be used within an ${name}Context via \`runIn${name}Context\`.`);
53
+ const message = isString(debugFnOrMessage)
54
+ ? debugFnOrMessage
55
+ : `${debugFnOrMessage.name}() can only be used within an ${name}Context via \`runIn${name}Context\`.`;
56
+ throw new Error(message);
54
57
  }
55
58
  }
56
59
  return {
57
60
  [`getCurrent${name}Context`]: getCurrentContext,
58
61
  [`setCurrent${name}Context`]: setCurrentContext,
59
62
  [`runIn${name}Context`]: runInContext,
60
- [`isIn${name}Context`]: getCurrentContext,
61
- [`assertIn${name}Context`]: getCurrentContext
63
+ [`isIn${name}Context`]: isInContext,
64
+ [`assertIn${name}Context`]: assertInContext
62
65
  };
63
66
  }