@tstdl/base 0.93.13 → 0.93.15

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.
@@ -0,0 +1,5 @@
1
+ ALTER TABLE "mail"."log" DROP COLUMN "revision";--> statement-breakpoint
2
+ ALTER TABLE "mail"."log" DROP COLUMN "revision_timestamp";--> statement-breakpoint
3
+ ALTER TABLE "mail"."log" DROP COLUMN "create_timestamp";--> statement-breakpoint
4
+ ALTER TABLE "mail"."log" DROP COLUMN "delete_timestamp";--> statement-breakpoint
5
+ ALTER TABLE "mail"."log" DROP COLUMN "attributes";
@@ -0,0 +1,69 @@
1
+ {
2
+ "id": "28ddafef-64f4-437d-9406-82a02c76570e",
3
+ "prevId": "f8cdba37-11b9-477a-9f5a-5ef4b5026011",
4
+ "version": "7",
5
+ "dialect": "postgresql",
6
+ "tables": {
7
+ "mail.log": {
8
+ "name": "log",
9
+ "schema": "mail",
10
+ "columns": {
11
+ "id": {
12
+ "name": "id",
13
+ "type": "uuid",
14
+ "primaryKey": true,
15
+ "notNull": true,
16
+ "default": "gen_random_uuid()"
17
+ },
18
+ "timestamp": {
19
+ "name": "timestamp",
20
+ "type": "timestamp with time zone",
21
+ "primaryKey": false,
22
+ "notNull": true
23
+ },
24
+ "template": {
25
+ "name": "template",
26
+ "type": "text",
27
+ "primaryKey": false,
28
+ "notNull": false
29
+ },
30
+ "data": {
31
+ "name": "data",
32
+ "type": "jsonb",
33
+ "primaryKey": false,
34
+ "notNull": true
35
+ },
36
+ "send_result": {
37
+ "name": "send_result",
38
+ "type": "jsonb",
39
+ "primaryKey": false,
40
+ "notNull": false
41
+ },
42
+ "errors": {
43
+ "name": "errors",
44
+ "type": "text[]",
45
+ "primaryKey": false,
46
+ "notNull": false
47
+ }
48
+ },
49
+ "indexes": {},
50
+ "foreignKeys": {},
51
+ "compositePrimaryKeys": {},
52
+ "uniqueConstraints": {},
53
+ "policies": {},
54
+ "checkConstraints": {},
55
+ "isRLSEnabled": false
56
+ }
57
+ },
58
+ "enums": {},
59
+ "schemas": {},
60
+ "sequences": {},
61
+ "roles": {},
62
+ "policies": {},
63
+ "views": {},
64
+ "_meta": {
65
+ "columns": {},
66
+ "schemas": {},
67
+ "tables": {}
68
+ }
69
+ }
@@ -8,6 +8,13 @@
8
8
  "when": 1740059198387,
9
9
  "tag": "0000_previous_malcolm_colcord",
10
10
  "breakpoints": true
11
+ },
12
+ {
13
+ "idx": 1,
14
+ "version": "7",
15
+ "when": 1761124592125,
16
+ "tag": "0001_flimsy_bloodscream",
17
+ "breakpoints": true
11
18
  }
12
19
  ]
13
20
  }
@@ -33,7 +33,7 @@ let MailService = class MailService {
33
33
  template: templateName ?? null,
34
34
  data,
35
35
  sendResult: null,
36
- errors: null
36
+ errors: null,
37
37
  });
38
38
  try {
39
39
  const result = await this.#mailClient.send(data, clientConfig);
@@ -53,14 +53,14 @@ let MailService = class MailService {
53
53
  async sendTemplate(keyOrTemplate, mailData, templateContext, clientConfig) {
54
54
  const { name, fields: { subject, html, text } } = await this.#templateService.render(keyOrTemplate, templateContext);
55
55
  const fullMailData = { ...mailData, subject, content: { html, text } };
56
- return this.send(fullMailData, clientConfig, name);
56
+ return await this.send(fullMailData, clientConfig, name);
57
57
  }
58
58
  };
59
59
  MailService = __decorate([
60
60
  Singleton({
61
61
  providers: [
62
62
  provide(EntityRepositoryConfig, { useValue: { schema: 'mail' } }),
63
- provide(DatabaseConfig, { useFactory: (_, context) => context.resolve(MailModuleConfig).database ?? context.resolve(DatabaseConfig, undefined, { skipSelf: true }) })
63
+ provide(DatabaseConfig, { useFactory: (_, context) => context.resolve(MailModuleConfig).database ?? context.resolve(DatabaseConfig, undefined, { skipSelf: true }) }),
64
64
  ]
65
65
  })
66
66
  ], MailService);
@@ -1,7 +1,7 @@
1
- import { Entity, type Json, type Timestamp } from '../../orm/index.js';
1
+ import { EntityWithoutMetadata, type Json, type Timestamp } from '../../orm/index.js';
2
2
  import type { MailData } from './mail-data.model.js';
3
3
  import type { MailSendResult } from './mail-send-result.model.js';
4
- export declare class MailLog extends Entity {
4
+ export declare class MailLog extends EntityWithoutMetadata {
5
5
  timestamp: Timestamp;
6
6
  template: string | null;
7
7
  data: Json<MailData>;
@@ -7,9 +7,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
7
7
  var __metadata = (this && this.__metadata) || function (k, v) {
8
8
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
9
  };
10
- import { Entity, JsonProperty, Table, TimestampProperty } from '../../orm/index.js';
10
+ import { EntityWithoutMetadata, JsonProperty, Table, TimestampProperty } from '../../orm/index.js';
11
11
  import { StringProperty } from '../../schema/index.js';
12
- let MailLog = class MailLog extends Entity {
12
+ let MailLog = class MailLog extends EntityWithoutMetadata {
13
13
  timestamp;
14
14
  template;
15
15
  data;
@@ -1,7 +1,8 @@
1
1
  import { MessageBusProvider } from '../message-bus-provider.js';
2
2
  import { LocalMessageBus } from './local-message-bus.js';
3
- export declare class LocalMessageBusProvider extends MessageBusProvider {
3
+ export declare class LocalMessageBusProvider extends MessageBusProvider implements Disposable {
4
4
  private readonly logger;
5
5
  private readonly channelSubjectsMap;
6
6
  get<T>(channel: string): LocalMessageBus<T>;
7
+ [Symbol.dispose](): void;
7
8
  }
@@ -10,7 +10,6 @@ import { WeakRefMap } from '../../data-structures/weak-ref-map.js';
10
10
  import { inject, Singleton } from '../../injector/index.js';
11
11
  import { Logger } from '../../logger/index.js';
12
12
  import { FactoryMap } from '../../utils/factory-map.js';
13
- import { isUndefined } from '../../utils/type-guards.js';
14
13
  import { MessageBusProvider } from '../message-bus-provider.js';
15
14
  import { LocalMessageBus } from './local-message-bus.js';
16
15
  let LocalMessageBusProvider = LocalMessageBusProvider_1 = class LocalMessageBusProvider extends MessageBusProvider {
@@ -18,11 +17,13 @@ let LocalMessageBusProvider = LocalMessageBusProvider_1 = class LocalMessageBusP
18
17
  channelSubjectsMap = new FactoryMap(() => new Subject(), WeakRefMap.supported ? new WeakRefMap() : undefined);
19
18
  get(channel) {
20
19
  const subject = this.channelSubjectsMap.get(channel);
21
- if (isUndefined(subject)) {
20
+ return new LocalMessageBus(subject, this.logger);
21
+ }
22
+ [Symbol.dispose]() {
23
+ for (const [channel, subject] of this.channelSubjectsMap.entries()) {
22
24
  this.channelSubjectsMap.delete(channel);
23
- return this.get(channel);
25
+ subject.complete();
24
26
  }
25
- return new LocalMessageBus(subject, this.logger);
26
27
  }
27
28
  };
28
29
  LocalMessageBusProvider = LocalMessageBusProvider_1 = __decorate([
@@ -26,9 +26,7 @@ let LocalMessageBus = class LocalMessageBus extends MessageBusBase {
26
26
  _publish(message) {
27
27
  this.subject.next({ source: this.source, message });
28
28
  }
29
- _dispose() {
30
- this.subject.complete();
31
- }
29
+ _dispose() { }
32
30
  };
33
31
  LocalMessageBus = __decorate([
34
32
  Injectable({
@@ -21,14 +21,14 @@ export class MessageBusBase extends MessageBus {
21
21
  }
22
22
  async publish(message) {
23
23
  if (this.disposeToken.isSet) {
24
- throw new Error('message-bus is disposed');
24
+ throw new Error('MessageBus is disposed.');
25
25
  }
26
26
  this.publishSubject.next(message);
27
27
  await this._publish(message);
28
28
  }
29
29
  async [Symbol.asyncDispose]() {
30
30
  if (this.disposeToken.isSet) {
31
- throw new Error('message-bus is disposed');
31
+ throw new Error('MessageBus is disposed.');
32
32
  }
33
33
  this.disposeToken.set();
34
34
  this.publishSubject.complete();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tstdl/base",
3
- "version": "0.93.13",
3
+ "version": "0.93.15",
4
4
  "author": "Patrick Hein",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -136,7 +136,7 @@
136
136
  },
137
137
  "peerDependencies": {
138
138
  "@google-cloud/storage": "^7.17",
139
- "@google/genai": "^1.25",
139
+ "@google/genai": "^1.26",
140
140
  "@tstdl/angular": "^0.93",
141
141
  "@zxcvbn-ts/core": "^3.0",
142
142
  "@zxcvbn-ts/language-common": "^3.0",
@@ -6,6 +6,7 @@ export type SimpleSchemaOptions<T> = SchemaOptions<T> & Coercible;
6
6
  type SimpleSchemaRefinements<T> = {
7
7
  coercers?: SimpleSchemaCoercers<T>;
8
8
  constraints?: (SimpleSchemaConstraint<T> | null)[];
9
+ transformers?: SimpleSchemaTransformer<T>;
9
10
  gotValueFormatter?: SimpleSchemaGotValueFormatter;
10
11
  };
11
12
  export type SimpleSchemaCoercers<T> = {
@@ -19,6 +20,7 @@ export type SimpleSchemaCoercers<T> = {
19
20
  };
20
21
  export type SimpleSchemaConstraint<T> = (value: T) => ConstraintResult;
21
22
  export type SimpleSchemaGotValueFormatter = (value: unknown) => string;
23
+ export type SimpleSchemaTransformer<T> = (value: T) => T;
22
24
  export declare abstract class SimpleSchema<T> extends Schema<T> {
23
25
  #private;
24
26
  constructor(expected: OneOrMany<string | AbstractConstructor>, guardFn: (value: any) => value is T, options?: SimpleSchemaOptions<T>, refinements?: SimpleSchemaRefinements<T>);
@@ -8,6 +8,7 @@ export class SimpleSchema extends Schema {
8
8
  #options;
9
9
  #coercers;
10
10
  #constraints;
11
+ #transformers;
11
12
  #gotValueFormatter;
12
13
  constructor(expected, guardFn, options = {}, refinements = {}) {
13
14
  super(options);
@@ -16,6 +17,7 @@ export class SimpleSchema extends Schema {
16
17
  this.#options = options;
17
18
  this.#coercers = refinements.coercers ?? {};
18
19
  this.#constraints = refinements.constraints?.filter(isNotNull) ?? [];
20
+ this.#transformers = refinements.transformers ?? ((value) => value);
19
21
  this.#gotValueFormatter = refinements.gotValueFormatter ?? typeOf;
20
22
  }
21
23
  _test(value, path, options) {
@@ -52,6 +54,7 @@ export class SimpleSchema extends Schema {
52
54
  return { valid: false, error: new SchemaError(`Constraint validation failed: ${constraintResult.error}`, { path, fast: options.fastErrors }) };
53
55
  }
54
56
  }
57
+ result.value = this.#transformers(result.value);
55
58
  return result;
56
59
  }
57
60
  }
@@ -1,4 +1,4 @@
1
- import { type SchemaPropertyDecorator, type SchemaDecoratorOptions } from '../decorators/index.js';
1
+ import { type SchemaDecoratorOptions, type SchemaPropertyDecorator } from '../decorators/index.js';
2
2
  import { SimpleSchema, type SimpleSchemaOptions } from './simple.js';
3
3
  export type StringSchemaOptions = SimpleSchemaOptions<string> & {
4
4
  pattern?: RegExp | string;
@@ -10,11 +10,14 @@ export class StringSchema extends SimpleSchema {
10
10
  coercers: {
11
11
  number: (value) => ({ success: true, value: globalThis.String(value), valid: true }),
12
12
  boolean: (value) => ({ success: true, value: globalThis.String(value), valid: true }),
13
- bigint: (value) => ({ success: true, value: globalThis.String(value), valid: true })
13
+ bigint: (value) => ({ success: true, value: globalThis.String(value), valid: true }),
14
14
  },
15
15
  constraints: [
16
- isDefined(options?.pattern) ? ((value) => this.pattern.test(value) ? ({ success: true }) : ({ success: false, error: 'Value did not match pattern.' })) : null
17
- ]
16
+ isDefined(options?.pattern)
17
+ ? (value) => this.pattern.test(value) ? ({ success: true }) : ({ success: false, error: 'Value did not match pattern.' })
18
+ : null,
19
+ ],
20
+ transformers: (options?.lowercase ?? false) ? (value) => value.toLowerCase() : undefined,
18
21
  });
19
22
  this.pattern = isString(options?.pattern)
20
23
  ? RegExp(options.pattern, 'u')
package/test2.js CHANGED
@@ -1,30 +1,14 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
1
  import { inject, Singleton } from './injector/index.js';
8
2
  import { Application } from './application/application.js';
9
3
  import { provideModule } from './application/providers.js';
10
4
  import { PrettyPrintLogFormatter, provideConsoleLogTransport } from './logger/index.js';
11
- let Foo = class Foo {
12
- bar = inject(Bar);
13
- };
14
- Foo = __decorate([
15
- Singleton()
16
- ], Foo);
17
- let Bar = class Bar {
18
- };
19
- Bar = __decorate([
20
- Singleton({
21
- argumentIdentityProvider() {
22
- throw new Error('haha');
23
- }
24
- })
25
- ], Bar);
5
+ import { object, string } from './schema/index.js';
6
+ const schema = object({
7
+ value: string({ lowercase: true })
8
+ });
26
9
  function main() {
27
- const foo = inject(Foo);
10
+ const value = schema.parse({ value: 'HELLO WORLD' });
11
+ console.log(value);
28
12
  }
29
13
  Application.run('Test', [
30
14
  provideModule(main),