@tstdl/base 0.93.20 → 0.93.22
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/application/application.js +1 -1
- package/audit/auditor.js +1 -1
- package/authentication/server/authentication.service.js +1 -1
- package/authentication/server/module.d.ts +1 -1
- package/authentication/server/module.js +1 -6
- package/document-management/api/document-management.api.d.ts +0 -4
- package/document-management/server/services/singleton.js +1 -1
- package/document-management/service-models/document.service-model.d.ts +0 -2
- package/injector/injector.d.ts +1 -1
- package/injector/injector.js +25 -13
- package/injector/types.d.ts +1 -1
- package/key-value-store/postgres/key-value-store.service.js +1 -1
- package/lock/postgres/provider.js +1 -1
- package/logger/manager.js +3 -3
- package/mail/mail.service.js +1 -1
- package/orm/data-types/bytea.d.ts +4 -14
- package/orm/data-types/bytea.js +2 -2
- package/orm/data-types/common.d.ts +18 -0
- package/orm/data-types/common.js +11 -0
- package/orm/data-types/index.d.ts +1 -0
- package/orm/data-types/index.js +1 -0
- package/orm/data-types/numeric-date.d.ts +4 -15
- package/orm/data-types/numeric-date.js +2 -2
- package/orm/data-types/timestamp.d.ts +4 -15
- package/orm/data-types/timestamp.js +2 -2
- package/orm/data-types/tsvector.d.ts +3 -13
- package/orm/data-types/tsvector.js +2 -2
- package/orm/decorators.d.ts +16 -54
- package/orm/decorators.js +24 -37
- package/orm/entity.d.ts +6 -9
- package/orm/entity.js +1 -2
- package/orm/query.d.ts +199 -61
- package/orm/query.js +2 -2
- package/orm/repository.types.d.ts +38 -9
- package/orm/server/drizzle/schema-converter.js +40 -118
- package/orm/server/query-converter.d.ts +21 -7
- package/orm/server/query-converter.js +194 -38
- package/orm/server/repository.d.ts +39 -22
- package/orm/server/repository.js +141 -71
- package/orm/server/types.d.ts +10 -2
- package/orm/sqls.d.ts +14 -16
- package/orm/sqls.js +34 -17
- package/package.json +2 -2
- package/queue/postgres/queue.js +1 -1
- package/test/drizzle/0000_nervous_iron_monger.sql +9 -0
- package/test/drizzle/meta/0000_snapshot.json +27 -7
- package/test/drizzle/meta/_journal.json +2 -44
- package/test/test.model.js +2 -6
- package/test1.js +18 -5
- package/test6.js +21 -35
- package/types/types.d.ts +8 -5
- package/utils/equals.js +2 -2
- package/utils/format-error.js +2 -2
- package/utils/helpers.js +3 -2
- package/utils/object/object.d.ts +4 -4
- package/test/drizzle/0000_sudden_sphinx.sql +0 -9
- package/test/drizzle/0001_organic_rhodey.sql +0 -2
- package/test/drizzle/0002_nice_squadron_supreme.sql +0 -1
- package/test/drizzle/0003_serious_mockingbird.sql +0 -1
- package/test/drizzle/0004_complete_pixie.sql +0 -1
- package/test/drizzle/0005_bumpy_sabra.sql +0 -1
- package/test/drizzle/0006_overrated_post.sql +0 -6
- package/test/drizzle/meta/0001_snapshot.json +0 -79
- package/test/drizzle/meta/0002_snapshot.json +0 -63
- package/test/drizzle/meta/0003_snapshot.json +0 -73
- package/test/drizzle/meta/0004_snapshot.json +0 -89
- package/test/drizzle/meta/0005_snapshot.json +0 -104
- package/test/drizzle/meta/0006_snapshot.json +0 -104
package/orm/sqls.js
CHANGED
|
@@ -213,7 +213,7 @@ export function similarity(left, right) {
|
|
|
213
213
|
}
|
|
214
214
|
/**
|
|
215
215
|
* Creates a PostgreSQL `word_similarity` function call (from pg_trgm extension).
|
|
216
|
-
* Calculates the
|
|
216
|
+
* Calculates the greatest similarity between the set of trigrams in the first string and any continuous extent of an ordered set of trigrams in the second string.
|
|
217
217
|
* @param left The first text column or expression.
|
|
218
218
|
* @param right The second text value or expression to compare against.
|
|
219
219
|
* @returns A Drizzle SQL object representing the similarity score (0 to 1).
|
|
@@ -224,27 +224,44 @@ export function wordSimilarity(left, right) {
|
|
|
224
224
|
return sql `word_similarity(${leftSql}, ${rightSql})`;
|
|
225
225
|
}
|
|
226
226
|
/**
|
|
227
|
-
* Creates a PostgreSQL
|
|
228
|
-
*
|
|
229
|
-
* @param left The text column or expression.
|
|
230
|
-
* @param right The text value or expression to compare against.
|
|
231
|
-
* @returns A Drizzle SQL object representing
|
|
227
|
+
* Creates a PostgreSQL `strict_word_similarity` function call (from pg_trgm extension).
|
|
228
|
+
* Same as `word_similarity`, but forces extent boundaries to match word boundaries.
|
|
229
|
+
* @param left The first text column or expression.
|
|
230
|
+
* @param right The second text value or expression to compare against.
|
|
231
|
+
* @returns A Drizzle SQL object representing the similarity score (0 to 1).
|
|
232
232
|
*/
|
|
233
|
+
export function strictWordSimilarity(left, right) {
|
|
234
|
+
const leftSql = isString(left) ? sql `${left}` : left;
|
|
235
|
+
const rightSql = isString(right) ? sql `${right}` : right;
|
|
236
|
+
return sql `strict_word_similarity(${leftSql}, ${rightSql})`;
|
|
237
|
+
}
|
|
233
238
|
export function isSimilar(left, right) {
|
|
234
239
|
const leftSql = isString(left) ? sql `${left}` : left;
|
|
235
240
|
const rightSql = isString(right) ? sql `${right}` : right;
|
|
236
|
-
return sql `(${leftSql}
|
|
241
|
+
return sql `(${leftSql} % ${rightSql})`;
|
|
237
242
|
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
243
|
+
export function isWordSimilar(left, right) {
|
|
244
|
+
const leftSql = isString(left) ? sql `${left}` : left;
|
|
245
|
+
const rightSql = isString(right) ? sql `${right}` : right;
|
|
246
|
+
return sql `(${leftSql} <% ${rightSql})`;
|
|
247
|
+
}
|
|
248
|
+
export function isStrictWordSimilar(left, right) {
|
|
249
|
+
const leftSql = isString(left) ? sql `${left}` : left;
|
|
250
|
+
const rightSql = isString(right) ? sql `${right}` : right;
|
|
251
|
+
return sql `(${leftSql} <<% ${rightSql})`;
|
|
252
|
+
}
|
|
253
|
+
export function distance(left, right) {
|
|
254
|
+
const leftSql = isString(left) ? sql `${left}` : left;
|
|
255
|
+
const rightSql = isString(right) ? sql `${right}` : right;
|
|
256
|
+
return sql `(${leftSql} <-> ${rightSql})`;
|
|
257
|
+
}
|
|
258
|
+
export function wordDistance(left, right) {
|
|
259
|
+
const leftSql = isString(left) ? sql `${left}` : left;
|
|
260
|
+
const rightSql = isString(right) ? sql `${right}` : right;
|
|
261
|
+
return sql `(${leftSql} <<-> ${rightSql})`;
|
|
262
|
+
}
|
|
263
|
+
export function strictWordDistance(left, right) {
|
|
247
264
|
const leftSql = isString(left) ? sql `${left}` : left;
|
|
248
265
|
const rightSql = isString(right) ? sql `${right}` : right;
|
|
249
|
-
return sql `(${leftSql}
|
|
266
|
+
return sql `(${leftSql} <<<-> ${rightSql})`;
|
|
250
267
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tstdl/base",
|
|
3
|
-
"version": "0.93.
|
|
3
|
+
"version": "0.93.22",
|
|
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.
|
|
139
|
+
"@google/genai": "^1.28",
|
|
140
140
|
"@tstdl/angular": "^0.93",
|
|
141
141
|
"@zxcvbn-ts/core": "^3.0",
|
|
142
142
|
"@zxcvbn-ts/language-common": "^3.0",
|
package/queue/postgres/queue.js
CHANGED
|
@@ -157,7 +157,7 @@ PostgresQueue = __decorate([
|
|
|
157
157
|
argumentIdentityProvider: JSON.stringify,
|
|
158
158
|
providers: [
|
|
159
159
|
provide(EntityRepositoryConfig, { useValue: { schema: 'queue' } }),
|
|
160
|
-
provide(DatabaseConfig, { useFactory: (_, context) => context.resolve(PostgresQueueModuleConfig).database ?? context.resolve(DatabaseConfig, undefined, { skipSelf:
|
|
160
|
+
provide(DatabaseConfig, { useFactory: (_, context) => context.resolve(PostgresQueueModuleConfig).database ?? context.resolve(DatabaseConfig, undefined, { skipSelf: true }) }),
|
|
161
161
|
],
|
|
162
162
|
})
|
|
163
163
|
], PostgresQueue);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
CREATE TABLE "test"."test" (
|
|
2
|
+
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
3
|
+
"title" text NOT NULL,
|
|
4
|
+
"content" text NOT NULL,
|
|
5
|
+
"tags" text NOT NULL,
|
|
6
|
+
"language" text NOT NULL
|
|
7
|
+
);
|
|
8
|
+
--> statement-breakpoint
|
|
9
|
+
CREATE INDEX "test_id_title_content_tags_idx" ON "test"."test" USING bm25 ("id","title","content","tags") WITH (key_field='id');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"id": "
|
|
2
|
+
"id": "e703ecc5-9f40-4ecb-848d-c1f3663d484c",
|
|
3
3
|
"prevId": "00000000-0000-0000-0000-000000000000",
|
|
4
4
|
"version": "7",
|
|
5
5
|
"dialect": "postgresql",
|
|
@@ -41,20 +41,40 @@
|
|
|
41
41
|
}
|
|
42
42
|
},
|
|
43
43
|
"indexes": {
|
|
44
|
-
"
|
|
45
|
-
"name": "
|
|
44
|
+
"test_id_title_content_tags_idx": {
|
|
45
|
+
"name": "test_id_title_content_tags_idx",
|
|
46
46
|
"columns": [
|
|
47
47
|
{
|
|
48
|
-
"expression": "
|
|
48
|
+
"expression": "id",
|
|
49
|
+
"isExpression": false,
|
|
50
|
+
"asc": true,
|
|
51
|
+
"nulls": "last"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"expression": "title",
|
|
55
|
+
"isExpression": false,
|
|
56
|
+
"asc": true,
|
|
57
|
+
"nulls": "last"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"expression": "content",
|
|
61
|
+
"isExpression": false,
|
|
62
|
+
"asc": true,
|
|
63
|
+
"nulls": "last"
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"expression": "tags",
|
|
67
|
+
"isExpression": false,
|
|
49
68
|
"asc": true,
|
|
50
|
-
"isExpression": true,
|
|
51
69
|
"nulls": "last"
|
|
52
70
|
}
|
|
53
71
|
],
|
|
54
72
|
"isUnique": false,
|
|
55
73
|
"concurrently": false,
|
|
56
|
-
"method": "
|
|
57
|
-
"with": {
|
|
74
|
+
"method": "bm25",
|
|
75
|
+
"with": {
|
|
76
|
+
"key_field": "'id'"
|
|
77
|
+
}
|
|
58
78
|
}
|
|
59
79
|
},
|
|
60
80
|
"foreignKeys": {},
|
|
@@ -5,50 +5,8 @@
|
|
|
5
5
|
{
|
|
6
6
|
"idx": 0,
|
|
7
7
|
"version": "7",
|
|
8
|
-
"when":
|
|
9
|
-
"tag": "
|
|
10
|
-
"breakpoints": true
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
"idx": 1,
|
|
14
|
-
"version": "7",
|
|
15
|
-
"when": 1760974454017,
|
|
16
|
-
"tag": "0001_organic_rhodey",
|
|
17
|
-
"breakpoints": true
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
"idx": 2,
|
|
21
|
-
"version": "7",
|
|
22
|
-
"when": 1761138612314,
|
|
23
|
-
"tag": "0002_nice_squadron_supreme",
|
|
24
|
-
"breakpoints": true
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
"idx": 3,
|
|
28
|
-
"version": "7",
|
|
29
|
-
"when": 1761142229231,
|
|
30
|
-
"tag": "0003_serious_mockingbird",
|
|
31
|
-
"breakpoints": true
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
"idx": 4,
|
|
35
|
-
"version": "7",
|
|
36
|
-
"when": 1761143426736,
|
|
37
|
-
"tag": "0004_complete_pixie",
|
|
38
|
-
"breakpoints": true
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
"idx": 5,
|
|
42
|
-
"version": "7",
|
|
43
|
-
"when": 1761153443342,
|
|
44
|
-
"tag": "0005_bumpy_sabra",
|
|
45
|
-
"breakpoints": true
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
"idx": 6,
|
|
49
|
-
"version": "7",
|
|
50
|
-
"when": 1761153500086,
|
|
51
|
-
"tag": "0006_overrated_post",
|
|
8
|
+
"when": 1761843226770,
|
|
9
|
+
"tag": "0000_nervous_iron_monger",
|
|
52
10
|
"breakpoints": true
|
|
53
11
|
}
|
|
54
12
|
]
|
package/test/test.model.js
CHANGED
|
@@ -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 { BaseEntity,
|
|
10
|
+
import { BaseEntity, Index } from '../orm/index.js';
|
|
11
11
|
import { StringProperty } from '../schema/index.js';
|
|
12
12
|
let Test = class Test extends BaseEntity {
|
|
13
13
|
title;
|
|
@@ -32,11 +32,7 @@ __decorate([
|
|
|
32
32
|
__metadata("design:type", String)
|
|
33
33
|
], Test.prototype, "language", void 0);
|
|
34
34
|
Test = __decorate([
|
|
35
|
-
|
|
36
|
-
source: ['title', 'content', 'tags'],
|
|
37
|
-
vector: { weights: { title: 'A', content: 'B', tags: 'C' } },
|
|
38
|
-
trigram: {},
|
|
39
|
-
})
|
|
35
|
+
Index(['id', 'title', 'content', 'tags'], { using: 'bm25', with: { key_field: `'id'` } })
|
|
40
36
|
], Test);
|
|
41
37
|
export { Test };
|
|
42
38
|
export const testData = [
|
package/test1.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import './polyfills.js';
|
|
2
2
|
import { Application, provideInitializer, provideModule, provideSignalHandler } from './application/index.js';
|
|
3
3
|
import { migrateAuditSchema } from './audit/index.js';
|
|
4
|
-
import {
|
|
4
|
+
import { AuthenticationService } from './authentication/server/authentication.service.js';
|
|
5
|
+
import { configureAuthenticationServer } from './authentication/server/module.js';
|
|
6
|
+
import { inject, injectAsync, Injector, runInInjectionContext } from './injector/index.js';
|
|
7
|
+
import { configurePostgresKeyValueStore, migratePostgresKeyValueStoreSchema } from './key-value-store/postgres/module.js';
|
|
5
8
|
import { configurePostgresLock, migratePostgresLockSchema } from './lock/postgres/index.js';
|
|
6
9
|
import { PrettyPrintLogFormatter, provideConsoleLogTransport } from './logger/index.js';
|
|
7
10
|
import { configureOrm, injectRepository } from './orm/server/index.js';
|
|
@@ -32,8 +35,15 @@ async function bootstrap() {
|
|
|
32
35
|
database: config.database.database,
|
|
33
36
|
},
|
|
34
37
|
});
|
|
38
|
+
configureAuthenticationServer({
|
|
39
|
+
serviceOptions: {
|
|
40
|
+
secret: '6fze56uz5e6ufrtzufrtu',
|
|
41
|
+
},
|
|
42
|
+
});
|
|
35
43
|
configurePostgresLock();
|
|
36
44
|
configurePostgresQueue();
|
|
45
|
+
configurePostgresKeyValueStore();
|
|
46
|
+
await runInInjectionContext(injector, migratePostgresKeyValueStoreSchema);
|
|
37
47
|
await runInInjectionContext(injector, migratePostgresLockSchema);
|
|
38
48
|
await runInInjectionContext(injector, migratePostgresQueueSchema);
|
|
39
49
|
await runInInjectionContext(injector, migrateAuditSchema);
|
|
@@ -41,13 +51,16 @@ async function bootstrap() {
|
|
|
41
51
|
}
|
|
42
52
|
async function main(_cancellationSignal) {
|
|
43
53
|
const repository = injectRepository(Test);
|
|
54
|
+
const authService = await injectAsync(AuthenticationService);
|
|
44
55
|
if (await repository.count() == 0) {
|
|
45
56
|
await repository.insertMany(testData);
|
|
46
57
|
}
|
|
47
|
-
const result = await repository.
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
58
|
+
const result = await repository.search({
|
|
59
|
+
query: {
|
|
60
|
+
$parade: {
|
|
61
|
+
all: null,
|
|
62
|
+
},
|
|
63
|
+
},
|
|
51
64
|
});
|
|
52
65
|
console.log(result);
|
|
53
66
|
}
|
package/test6.js
CHANGED
|
@@ -4,50 +4,36 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
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
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
-
};
|
|
10
7
|
import { Application } from './application/application.js';
|
|
11
8
|
import { provideModule, provideSignalHandler } from './application/providers.js';
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
console.log('meta', type, data);
|
|
18
|
-
}
|
|
19
|
-
function integer() {
|
|
20
|
-
if (isInschemaContext()) {
|
|
21
|
-
return { type: 'integer' };
|
|
22
|
-
}
|
|
23
|
-
return undefined;
|
|
24
|
-
}
|
|
9
|
+
import { Singleton } from './injector/decorators.js';
|
|
10
|
+
import { inject } from './injector/index.js';
|
|
11
|
+
import { injectionToken } from './injector/token.js';
|
|
12
|
+
import { PrettyPrintLogFormatter, provideConsoleLogTransport } from './logger/index.js';
|
|
13
|
+
const MY_INTEGER = injectionToken('MyInteger');
|
|
25
14
|
// current method
|
|
26
15
|
let Foo = class Foo {
|
|
27
|
-
|
|
16
|
+
bar = inject(Bar);
|
|
28
17
|
};
|
|
29
|
-
__decorate([
|
|
30
|
-
Integer(),
|
|
31
|
-
__metadata("design:type", Number)
|
|
32
|
-
], Foo.prototype, "age", void 0);
|
|
33
18
|
Foo = __decorate([
|
|
34
|
-
|
|
19
|
+
Singleton({
|
|
20
|
+
providers: [
|
|
21
|
+
{ provide: MY_INTEGER, useValue: 42 },
|
|
22
|
+
],
|
|
23
|
+
})
|
|
35
24
|
], Foo);
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
console.log(
|
|
45
|
-
console.log(new Bar());
|
|
46
|
-
runInschemaContext(undefined, () => {
|
|
47
|
-
console.log(new Bar());
|
|
48
|
-
});
|
|
25
|
+
let Bar = class Bar {
|
|
26
|
+
myInteger = inject(MY_INTEGER);
|
|
27
|
+
};
|
|
28
|
+
Bar = __decorate([
|
|
29
|
+
Singleton()
|
|
30
|
+
], Bar);
|
|
31
|
+
function main() {
|
|
32
|
+
const foo = inject(Foo);
|
|
33
|
+
console.log(foo);
|
|
49
34
|
}
|
|
50
35
|
Application.run('Test', [
|
|
51
36
|
provideModule(main),
|
|
37
|
+
provideConsoleLogTransport(PrettyPrintLogFormatter),
|
|
52
38
|
provideSignalHandler(),
|
|
53
39
|
]);
|
package/types/types.d.ts
CHANGED
|
@@ -83,6 +83,9 @@ export type StringNumberMap<T = any> = {
|
|
|
83
83
|
};
|
|
84
84
|
export type OneOrMany<T> = T | readonly T[];
|
|
85
85
|
export type WritableOneOrMany<T> = T | T[];
|
|
86
|
+
export type Entries<T> = Extract<{
|
|
87
|
+
[K in keyof T]: [K, T[K]];
|
|
88
|
+
}[keyof T], any[]>[];
|
|
86
89
|
type FromEntriesEntryValue<T extends readonly (readonly [any, any])[], K> = Extract<T[number], readonly [K, any]>[1];
|
|
87
90
|
export type FromEntries<T> = T extends readonly (readonly [infer Key, any])[] ? {
|
|
88
91
|
[K in Cast<Key, PropertyKey>]: Fallback<FromEntriesEntryValue<T, K>, T[number][1]>;
|
|
@@ -202,12 +205,12 @@ export type DeepPartialObject<T> = {
|
|
|
202
205
|
export type DeepPartialArray<T> = DeepPartial<T>[];
|
|
203
206
|
export type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | BigInt64Array | BigUint64Array;
|
|
204
207
|
export type BinaryData<T extends ArrayBufferLike = ArrayBufferLike> = ArrayBufferView<T> | T;
|
|
205
|
-
export type
|
|
206
|
-
[K in keyof T]-?: K extends string | number ? `${K}` | `${K}.${
|
|
208
|
+
export type Path<T extends Record> = T extends object ? {
|
|
209
|
+
[K in keyof T]-?: K extends string | number ? `${K}` | `${K}.${Path<T[K]>}` : never;
|
|
207
210
|
}[keyof T] : never;
|
|
208
|
-
export type TypeFromPath<T extends Record,
|
|
209
|
-
[K in
|
|
210
|
-
}[
|
|
211
|
+
export type TypeFromPath<T extends Record, P extends Path<T> | string> = {
|
|
212
|
+
[K in P]: K extends keyof T ? T[K] : K extends `${infer P}.${infer S}` ? T[P] extends Record ? TypeFromPath<T[P], S> : never : never;
|
|
213
|
+
}[P];
|
|
211
214
|
export type ConstructorParameterDecorator = (target: object, propertyKey: undefined, parameterIndex: number) => void;
|
|
212
215
|
export type ReactiveValue<T> = T | Signal<T> | Observable<T>;
|
|
213
216
|
export type PascalCase<Value> = CamelCase<Value> extends string ? Capitalize<CamelCase<Value>> : CamelCase<Value>;
|
package/utils/equals.js
CHANGED
|
@@ -3,7 +3,7 @@ import { toUint8Array } from './binary.js';
|
|
|
3
3
|
import { compareByValue } from './comparison.js';
|
|
4
4
|
import { sort } from './iterable-helpers/sort.js';
|
|
5
5
|
import { objectKeys } from './object/object.js';
|
|
6
|
-
import { isDefined, isNotNull, isNull } from './type-guards.js';
|
|
6
|
+
import { isArray, isDefined, isNotNull, isNull } from './type-guards.js';
|
|
7
7
|
const equalsSymbol = Symbol('equals');
|
|
8
8
|
export const Equals = {
|
|
9
9
|
symbol: equalsSymbol,
|
|
@@ -60,7 +60,7 @@ export function equals(a, b, options = {}, visitedNodes = new Set()) {
|
|
|
60
60
|
return false;
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
-
if (
|
|
63
|
+
if (isArray(a)) {
|
|
64
64
|
return (options.arrayDeep != false && (options.deep == true || options.arrayDeep == true))
|
|
65
65
|
? arrayEquals(a, b, { sort: (options.sortArray == true) ? compareByValue : undefined, comparator: (x, y) => equals(x, y, options, visitedNodes) })
|
|
66
66
|
: a === b;
|
package/utils/format-error.js
CHANGED
|
@@ -2,7 +2,7 @@ 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 { tryChain } from './try-chain.js';
|
|
5
|
-
import { isDefined, isFunction, isObject, isUndefined } from './type-guards.js';
|
|
5
|
+
import { isArray, isDefined, isFunction, isObject, isUndefined } from './type-guards.js';
|
|
6
6
|
/**
|
|
7
7
|
* Enhanced error formatting
|
|
8
8
|
*/
|
|
@@ -66,7 +66,7 @@ export function formatError(error, options = {}) {
|
|
|
66
66
|
const causeString = includeStack && cause
|
|
67
67
|
? formatNestedError('Caused by:', cause, { ...options, depth: depth - 1 })
|
|
68
68
|
: '';
|
|
69
|
-
const aggregateErrorsString =
|
|
69
|
+
const aggregateErrorsString = isArray(aggregateErrors)
|
|
70
70
|
? aggregateErrors.map((err, i) => formatNestedError(`Sub-error #${i + 1}:`, err, { ...options, depth: depth - 1 })).join('')
|
|
71
71
|
: '';
|
|
72
72
|
return `${nameString}${message}${restString}${extraInfoString}${stackString}${causeString}${aggregateErrorsString}`;
|
package/utils/helpers.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { DetailsError } from '../errors/details.error.js';
|
|
2
2
|
import { supportsNotification } from '../supports.js';
|
|
3
3
|
import { decycle } from './object/decycle.js';
|
|
4
|
+
import { isArray } from './type-guards.js';
|
|
4
5
|
/**
|
|
5
6
|
* Create an structured clone of an value using Notification if available, otherwise history state (may alters history)
|
|
6
7
|
*
|
|
@@ -29,13 +30,13 @@ export async function structuredCloneAsync(value, options) {
|
|
|
29
30
|
const { port1, port2 } = new MessageChannel();
|
|
30
31
|
const promise = new Promise((resolve) => (port2.onmessage = (event) => resolve(event.data)));
|
|
31
32
|
port1.postMessage(value, options);
|
|
32
|
-
return promise;
|
|
33
|
+
return await promise;
|
|
33
34
|
}
|
|
34
35
|
export function valueOfType(value) {
|
|
35
36
|
return value;
|
|
36
37
|
}
|
|
37
38
|
export function flatten(array) {
|
|
38
|
-
return array.reduce((acc, item) => (
|
|
39
|
+
return array.reduce((acc, item) => (isArray(item) ? [...(acc), ...flatten(item)] : [...(acc), item]), []);
|
|
39
40
|
}
|
|
40
41
|
export function toError(obj) {
|
|
41
42
|
if (obj instanceof Error) {
|
package/utils/object/object.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { type JsonPathInput } from '../../json-path/json-path.js';
|
|
2
|
-
import type { BaseType, FromEntries, ObjectLiteral, Optionalize, OptionalizeNull, PickBy, Record, SimplifyObject, UnionToIntersection } from '../../types/index.js';
|
|
3
|
-
export declare function hasOwnProperty<T extends
|
|
4
|
-
export declare function hasOwnProperty<T extends
|
|
2
|
+
import type { BaseType, Entries, FromEntries, ObjectLiteral, Optionalize, OptionalizeNull, PickBy, Record, SimplifyObject, UnionToIntersection } from '../../types/index.js';
|
|
3
|
+
export declare function hasOwnProperty<T extends ObjectLiteral, K extends keyof UnionToIntersection<T>>(obj: T, key: K): obj is Extract<T, Partial<Record<K>>>;
|
|
4
|
+
export declare function hasOwnProperty<T extends ObjectLiteral>(obj: T, key: keyof T): boolean;
|
|
5
5
|
/**
|
|
6
6
|
* Returns object entries including those with symbols keys (which Object.entries does not)
|
|
7
7
|
*/
|
|
8
|
-
export declare function objectEntries<T extends ObjectLiteral>(object: T):
|
|
8
|
+
export declare function objectEntries<T extends ObjectLiteral>(object: T): Entries<T>;
|
|
9
9
|
/**
|
|
10
10
|
* Returns object keys including symbols (which Object.keys does not)
|
|
11
11
|
*/
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
CREATE TABLE "test"."test" (
|
|
2
|
-
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
3
|
-
"title" text NOT NULL,
|
|
4
|
-
"content" text NOT NULL,
|
|
5
|
-
"tags" text NOT NULL,
|
|
6
|
-
"language" text NOT NULL
|
|
7
|
-
);
|
|
8
|
-
--> statement-breakpoint
|
|
9
|
-
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')));
|
|
@@ -1,2 +0,0 @@
|
|
|
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')));
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
DROP INDEX "test"."test_title_content_tags_idx";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
ALTER TABLE "test"."test" ADD COLUMN "ftsv_asd" "tsvector" GENERATED ALWAYS AS ((setweight(to_tsvector('simple', "test"."test"."title"), 'A') || setweight(to_tsvector('simple', "test"."test"."content"), 'B') || setweight(to_tsvector('simple', "test"."test"."tags"), 'C'))) STORED;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
CREATE INDEX "ftsv_asd_gin" ON "test"."test" USING gin ("ftsv_asd");
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
CREATE INDEX "ftst_asd_gist" ON "test"."test" USING gist (("title" || "content" || "tags"));
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
DROP INDEX "test"."ftsv_asd_gin";--> statement-breakpoint
|
|
2
|
-
DROP INDEX "test"."ftst_asd_gist";--> statement-breakpoint
|
|
3
|
-
ALTER TABLE "test"."test" ADD COLUMN "fts_v_asd" "tsvector" GENERATED ALWAYS AS ((setweight(to_tsvector('simple', "test"."test"."title"), 'A') || setweight(to_tsvector('simple', "test"."test"."content"), 'B') || setweight(to_tsvector('simple', "test"."test"."tags"), 'C'))) STORED;--> statement-breakpoint
|
|
4
|
-
CREATE INDEX "fts_v_asd_gin" ON "test"."test" USING gin ("fts_v_asd");--> statement-breakpoint
|
|
5
|
-
CREATE INDEX "fts_t_asd_gist" ON "test"."test" USING gist (("title" || "content" || "tags"));--> statement-breakpoint
|
|
6
|
-
ALTER TABLE "test"."test" DROP COLUMN "ftsv_asd";
|
|
@@ -1,79 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"id": "c8eced2f-44d3-46b3-aafa-e8a775549cd0",
|
|
3
|
-
"prevId": "3949ca77-11a4-4ca4-a404-1529e02d058c",
|
|
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
|
-
"foreignKeys": {},
|
|
45
|
-
"compositePrimaryKeys": {},
|
|
46
|
-
"uniqueConstraints": {},
|
|
47
|
-
"policies": {},
|
|
48
|
-
"checkConstraints": {},
|
|
49
|
-
"isRLSEnabled": false
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
|
-
"enums": {},
|
|
53
|
-
"schemas": {},
|
|
54
|
-
"sequences": {},
|
|
55
|
-
"roles": {},
|
|
56
|
-
"policies": {},
|
|
57
|
-
"views": {},
|
|
58
|
-
"_meta": {
|
|
59
|
-
"columns": {},
|
|
60
|
-
"schemas": {},
|
|
61
|
-
"tables": {}
|
|
62
|
-
}
|
|
63
|
-
}
|