@tstdl/base 0.93.12 → 0.93.14

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tstdl/base",
3
- "version": "0.93.12",
3
+ "version": "0.93.14",
4
4
  "author": "Patrick Hein",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -0,0 +1,2 @@
1
+ DROP INDEX "queue"."job_queue_tag_idx";--> statement-breakpoint
2
+ ALTER TABLE "queue"."job" ADD CONSTRAINT "job_queue_tag_unique" UNIQUE("queue","tag");
@@ -0,0 +1,90 @@
1
+ {
2
+ "id": "74e8909c-3a81-46a3-9fe7-176e263da2df",
3
+ "prevId": "ecc50ddb-e593-48ae-abe8-ec5d1b8d5970",
4
+ "version": "7",
5
+ "dialect": "postgresql",
6
+ "tables": {
7
+ "queue.job": {
8
+ "name": "job",
9
+ "schema": "queue",
10
+ "columns": {
11
+ "id": {
12
+ "name": "id",
13
+ "type": "uuid",
14
+ "primaryKey": true,
15
+ "notNull": true,
16
+ "default": "gen_random_uuid()"
17
+ },
18
+ "queue": {
19
+ "name": "queue",
20
+ "type": "text",
21
+ "primaryKey": false,
22
+ "notNull": true
23
+ },
24
+ "tag": {
25
+ "name": "tag",
26
+ "type": "text",
27
+ "primaryKey": false,
28
+ "notNull": false
29
+ },
30
+ "priority": {
31
+ "name": "priority",
32
+ "type": "integer",
33
+ "primaryKey": false,
34
+ "notNull": true
35
+ },
36
+ "enqueue_timestamp": {
37
+ "name": "enqueue_timestamp",
38
+ "type": "timestamp with time zone",
39
+ "primaryKey": false,
40
+ "notNull": true
41
+ },
42
+ "tries": {
43
+ "name": "tries",
44
+ "type": "integer",
45
+ "primaryKey": false,
46
+ "notNull": true
47
+ },
48
+ "last_dequeue_timestamp": {
49
+ "name": "last_dequeue_timestamp",
50
+ "type": "timestamp with time zone",
51
+ "primaryKey": false,
52
+ "notNull": false
53
+ },
54
+ "data": {
55
+ "name": "data",
56
+ "type": "jsonb",
57
+ "primaryKey": false,
58
+ "notNull": true
59
+ }
60
+ },
61
+ "indexes": {},
62
+ "foreignKeys": {},
63
+ "compositePrimaryKeys": {},
64
+ "uniqueConstraints": {
65
+ "job_queue_tag_unique": {
66
+ "name": "job_queue_tag_unique",
67
+ "nullsNotDistinct": false,
68
+ "columns": [
69
+ "queue",
70
+ "tag"
71
+ ]
72
+ }
73
+ },
74
+ "policies": {},
75
+ "checkConstraints": {},
76
+ "isRLSEnabled": false
77
+ }
78
+ },
79
+ "enums": {},
80
+ "schemas": {},
81
+ "sequences": {},
82
+ "roles": {},
83
+ "policies": {},
84
+ "views": {},
85
+ "_meta": {
86
+ "columns": {},
87
+ "schemas": {},
88
+ "tables": {}
89
+ }
90
+ }
@@ -15,6 +15,13 @@
15
15
  "when": 1741944766334,
16
16
  "tag": "0001_certain_wild_pack",
17
17
  "breakpoints": true
18
+ },
19
+ {
20
+ "idx": 2,
21
+ "version": "7",
22
+ "when": 1760974453539,
23
+ "tag": "0002_dear_meggan",
24
+ "breakpoints": true
18
25
  }
19
26
  ]
20
27
  }
@@ -7,7 +7,7 @@ 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 { EntityWithoutMetadata, Index, JsonProperty, Table, TimestampProperty } from '../../orm/index.js';
10
+ import { EntityWithoutMetadata, JsonProperty, Table, TimestampProperty, Unique } from '../../orm/index.js';
11
11
  import { Integer, StringProperty } from '../../schema/index.js';
12
12
  let PostgresJob = class PostgresJob extends EntityWithoutMetadata {
13
13
  queue;
@@ -48,6 +48,6 @@ __decorate([
48
48
  ], PostgresJob.prototype, "data", void 0);
49
49
  PostgresJob = __decorate([
50
50
  Table('job'),
51
- Index(['queue', 'tag'])
51
+ Unique(['queue', 'tag'])
52
52
  ], PostgresJob);
53
53
  export { PostgresJob };
@@ -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')
@@ -0,0 +1,2 @@
1
+ DROP INDEX "test"."test_title_content_tags_idx";--> statement-breakpoint
2
+ CREATE INDEX "test_title_content_tags_idx" ON "test"."test" USING gin ((setweight(to_tsvector('simple', "title"), 'A') || setweight(to_tsvector('simple', "content"), 'B') || setweight(to_tsvector('simple', "tags"), 'C')));
@@ -0,0 +1,79 @@
1
+ {
2
+ "id": "3949ca77-11a4-4ca4-a404-1529e02d058c",
3
+ "prevId": "5c221821-4273-489d-b533-2f49653ab8d1",
4
+ "version": "7",
5
+ "dialect": "postgresql",
6
+ "tables": {
7
+ "test.test": {
8
+ "name": "test",
9
+ "schema": "test",
10
+ "columns": {
11
+ "id": {
12
+ "name": "id",
13
+ "type": "uuid",
14
+ "primaryKey": true,
15
+ "notNull": true,
16
+ "default": "gen_random_uuid()"
17
+ },
18
+ "title": {
19
+ "name": "title",
20
+ "type": "text",
21
+ "primaryKey": false,
22
+ "notNull": true
23
+ },
24
+ "content": {
25
+ "name": "content",
26
+ "type": "text",
27
+ "primaryKey": false,
28
+ "notNull": true
29
+ },
30
+ "tags": {
31
+ "name": "tags",
32
+ "type": "text",
33
+ "primaryKey": false,
34
+ "notNull": true
35
+ },
36
+ "language": {
37
+ "name": "language",
38
+ "type": "text",
39
+ "primaryKey": false,
40
+ "notNull": true
41
+ }
42
+ },
43
+ "indexes": {
44
+ "test_title_content_tags_idx": {
45
+ "name": "test_title_content_tags_idx",
46
+ "columns": [
47
+ {
48
+ "expression": "(setweight(to_tsvector('simple', \"title\"), 'A') || setweight(to_tsvector('simple', \"content\"), 'B') || setweight(to_tsvector('simple', \"tags\"), 'C'))",
49
+ "asc": true,
50
+ "isExpression": true,
51
+ "nulls": "last"
52
+ }
53
+ ],
54
+ "isUnique": false,
55
+ "concurrently": false,
56
+ "method": "gin",
57
+ "with": {}
58
+ }
59
+ },
60
+ "foreignKeys": {},
61
+ "compositePrimaryKeys": {},
62
+ "uniqueConstraints": {},
63
+ "policies": {},
64
+ "checkConstraints": {},
65
+ "isRLSEnabled": false
66
+ }
67
+ },
68
+ "enums": {},
69
+ "schemas": {},
70
+ "sequences": {},
71
+ "roles": {},
72
+ "policies": {},
73
+ "views": {},
74
+ "_meta": {
75
+ "columns": {},
76
+ "schemas": {},
77
+ "tables": {}
78
+ }
79
+ }
@@ -8,6 +8,13 @@
8
8
  "when": 1760697525756,
9
9
  "tag": "0000_sudden_sphinx",
10
10
  "breakpoints": true
11
+ },
12
+ {
13
+ "idx": 1,
14
+ "version": "7",
15
+ "when": 1760974454017,
16
+ "tag": "0001_organic_rhodey",
17
+ "breakpoints": true
11
18
  }
12
19
  ]
13
20
  }
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),