@tstdl/base 0.91.50 → 0.91.52

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 (164) hide show
  1. package/ai/data-extracting.d.ts +1 -0
  2. package/ai/data-extracting.js +62 -0
  3. package/authentication/server/authentication.api-controller.js +4 -4
  4. package/cancellation/token.d.ts +1 -2
  5. package/cancellation/token.js +1 -1
  6. package/core.d.ts +1 -1
  7. package/core.js +1 -1
  8. package/document-management/api/document-management.api.d.ts +753 -0
  9. package/document-management/api/document-management.api.js +222 -0
  10. package/document-management/api/index.d.ts +1 -0
  11. package/document-management/api/index.js +1 -0
  12. package/document-management/drizzle/0000_wakeful_firebrand.sql +228 -0
  13. package/document-management/drizzle/meta/0000_snapshot.json +1538 -0
  14. package/document-management/drizzle/meta/_journal.json +13 -0
  15. package/document-management/drizzle.config.d.ts +2 -0
  16. package/document-management/drizzle.config.js +11 -0
  17. package/document-management/index.d.ts +5 -0
  18. package/document-management/index.js +5 -0
  19. package/document-management/localizations/english.d.ts +2 -0
  20. package/document-management/localizations/english.js +9 -0
  21. package/document-management/localizations/german.d.ts +2 -0
  22. package/document-management/localizations/german.js +9 -0
  23. package/document-management/localizations/index.d.ts +5 -0
  24. package/document-management/localizations/index.js +9 -0
  25. package/document-management/localizations/localization.d.ts +9 -0
  26. package/document-management/localizations/localization.js +2 -0
  27. package/document-management/models/document-category.model.d.ts +4 -0
  28. package/document-management/models/document-category.model.js +18 -0
  29. package/document-management/models/document-collection-document.model.d.ts +7 -0
  30. package/document-management/models/document-collection-document.model.js +33 -0
  31. package/document-management/models/document-collection.model.d.ts +3 -0
  32. package/document-management/models/document-collection.model.js +14 -0
  33. package/document-management/models/document-file.model.d.ts +7 -0
  34. package/document-management/models/document-file.model.js +33 -0
  35. package/document-management/models/document-property-value.model.d.ts +21 -0
  36. package/document-management/models/document-property-value.model.js +58 -0
  37. package/document-management/models/document-property.model.d.ts +11 -0
  38. package/document-management/models/document-property.model.js +30 -0
  39. package/document-management/models/document-request-collection.model.d.ts +6 -0
  40. package/document-management/models/document-request-collection.model.js +28 -0
  41. package/document-management/models/document-request-file.model.d.ts +11 -0
  42. package/document-management/models/document-request-file.model.js +56 -0
  43. package/document-management/models/document-request-template.d.ts +10 -0
  44. package/document-management/models/document-request-template.js +39 -0
  45. package/document-management/models/document-request.model.d.ts +9 -0
  46. package/document-management/models/document-request.model.js +37 -0
  47. package/document-management/models/document-requests-template.d.ts +5 -0
  48. package/document-management/models/document-requests-template.js +23 -0
  49. package/document-management/models/document-type-property.model.d.ts +6 -0
  50. package/document-management/models/document-type-property.model.js +28 -0
  51. package/document-management/models/document-type.model.d.ts +7 -0
  52. package/document-management/models/document-type.model.js +32 -0
  53. package/document-management/models/document.model.d.ts +9 -0
  54. package/document-management/models/document.model.js +44 -0
  55. package/document-management/models/index.d.ts +15 -0
  56. package/document-management/models/index.js +15 -0
  57. package/document-management/models/schemas.d.ts +33 -0
  58. package/document-management/models/schemas.js +34 -0
  59. package/document-management/models/service-models/categories-and-types.view-model.d.ts +6 -0
  60. package/document-management/models/service-models/categories-and-types.view-model.js +24 -0
  61. package/document-management/models/service-models/document-folders.view-model.d.ts +22 -0
  62. package/document-management/models/service-models/document-folders.view-model.js +56 -0
  63. package/document-management/models/service-models/document-requests-template.view-model.d.ts +8 -0
  64. package/document-management/models/service-models/document-requests-template.view-model.js +26 -0
  65. package/document-management/models/service-models/document.service-model.d.ts +262 -0
  66. package/document-management/models/service-models/document.service-model.js +50 -0
  67. package/document-management/models/service-models/document.view-model.d.ts +33 -0
  68. package/document-management/models/service-models/document.view-model.js +99 -0
  69. package/document-management/models/service-models/index.d.ts +8 -0
  70. package/document-management/models/service-models/index.js +8 -0
  71. package/document-management/models/service-models/normalized-document-collection-view.model.d.ts +73 -0
  72. package/document-management/models/service-models/normalized-document-collection-view.model.js +110 -0
  73. package/document-management/models/service-models/normalized-requests-template-data.model.d.ts +16 -0
  74. package/document-management/models/service-models/normalized-requests-template-data.model.js +13 -0
  75. package/document-management/models/service-models/stats.view-model.d.ts +6 -0
  76. package/document-management/models/service-models/stats.view-model.js +32 -0
  77. package/document-management/module.d.ts +11 -0
  78. package/document-management/module.js +27 -0
  79. package/document-management/services/document-management.service.d.ts +65 -0
  80. package/document-management/services/document-management.service.js +376 -0
  81. package/document-management/services/index.d.ts +1 -0
  82. package/document-management/services/index.js +1 -0
  83. package/examples/document-management/main.d.ts +1 -0
  84. package/examples/document-management/main.js +30 -0
  85. package/examples/orm/drizzle.config.js +2 -1
  86. package/examples/orm/schemas.d.ts +1 -1
  87. package/examples/orm/user.model.d.ts +1 -2
  88. package/examples/orm/user.model.js +0 -1
  89. package/http/server/node/node-http-server.js +5 -5
  90. package/injector/injector.d.ts +4 -1
  91. package/injector/injector.js +4 -1
  92. package/injector/interfaces.d.ts +3 -3
  93. package/json-path/json-path.d.ts +2 -0
  94. package/json-path/json-path.js +7 -0
  95. package/message-bus/message-bus.d.ts +4 -6
  96. package/orm/database-schema.d.ts +3 -0
  97. package/orm/database-schema.js +6 -2
  98. package/orm/database.d.ts +6 -0
  99. package/orm/database.js +14 -0
  100. package/orm/decorators.d.ts +25 -2
  101. package/orm/decorators.js +15 -0
  102. package/orm/drizzle/index.d.ts +1 -0
  103. package/orm/drizzle/index.js +1 -0
  104. package/orm/drizzle/schema-converter.d.ts +37 -8
  105. package/orm/drizzle/schema-converter.js +121 -40
  106. package/orm/entity.d.ts +15 -12
  107. package/orm/entity.js +24 -11
  108. package/orm/index.d.ts +3 -2
  109. package/orm/index.js +3 -2
  110. package/orm/module.d.ts +6 -0
  111. package/orm/module.js +15 -0
  112. package/orm/query-converter.d.ts +5 -0
  113. package/orm/query-converter.js +114 -0
  114. package/orm/query.d.ts +15 -13
  115. package/orm/repository.d.ts +90 -31
  116. package/orm/repository.js +357 -55
  117. package/orm/schemas/index.d.ts +3 -0
  118. package/orm/schemas/index.js +3 -0
  119. package/orm/schemas/json.d.ts +9 -0
  120. package/orm/schemas/json.js +19 -0
  121. package/orm/schemas/numeric-date.d.ts +8 -0
  122. package/orm/schemas/numeric-date.js +13 -0
  123. package/orm/schemas/timestamp.d.ts +10 -0
  124. package/orm/schemas/timestamp.js +20 -0
  125. package/orm/transaction.d.ts +29 -0
  126. package/orm/transaction.js +73 -0
  127. package/orm/types.d.ts +15 -8
  128. package/orm/types.js +3 -2
  129. package/package.json +23 -12
  130. package/{rxjs → rxjs-utils}/reject-error.d.ts +1 -1
  131. package/{rxjs → rxjs-utils}/retry-backoff.d.ts +2 -2
  132. package/{rxjs → rxjs-utils}/slow-array.d.ts +7 -7
  133. package/{rxjs → rxjs-utils}/slow-array.js +2 -2
  134. package/{rxjs → rxjs-utils}/start-with-provider.d.ts +1 -1
  135. package/{rxjs → rxjs-utils}/teardown.d.ts +1 -1
  136. package/{rxjs → rxjs-utils}/untrack.d.ts +1 -1
  137. package/schema/decorators/types.d.ts +2 -2
  138. package/schema/schemas/number.d.ts +1 -1
  139. package/signals/pipe.d.ts +1 -1
  140. package/signals/pipe.js +1 -2
  141. package/sse/server-sent-events.d.ts +54 -0
  142. package/sse/server-sent-events.js +54 -0
  143. package/types.d.ts +5 -1
  144. package/utils/comparison.d.ts +2 -1
  145. package/utils/comparison.js +4 -3
  146. package/utils/compression.d.ts +4 -4
  147. package/utils/compression.js +35 -43
  148. package/utils/object/dereference.d.ts +6 -4
  149. package/utils/object/dereference.js +20 -8
  150. package/utils/object/object.d.ts +2 -0
  151. package/utils/object/object.js +20 -0
  152. /package/{rxjs → rxjs-utils}/cast.d.ts +0 -0
  153. /package/{rxjs → rxjs-utils}/cast.js +0 -0
  154. /package/{rxjs → rxjs-utils}/index.d.ts +0 -0
  155. /package/{rxjs → rxjs-utils}/index.js +0 -0
  156. /package/{rxjs → rxjs-utils}/noop.d.ts +0 -0
  157. /package/{rxjs → rxjs-utils}/noop.js +0 -0
  158. /package/{rxjs → rxjs-utils}/reject-error.js +0 -0
  159. /package/{rxjs → rxjs-utils}/retry-backoff.js +0 -0
  160. /package/{rxjs → rxjs-utils}/start-with-provider.js +0 -0
  161. /package/{rxjs → rxjs-utils}/teardown.js +0 -0
  162. /package/{rxjs → rxjs-utils}/timing.d.ts +0 -0
  163. /package/{rxjs → rxjs-utils}/timing.js +0 -0
  164. /package/{rxjs → rxjs-utils}/untrack.js +0 -0
@@ -0,0 +1,73 @@
1
+ import { DeferredPromise } from '../promise/deferred-promise.js';
2
+ import { Subject } from 'rxjs';
3
+ export class Transaction {
4
+ #afterCommitSubject = new Subject();
5
+ #useCounter = 0;
6
+ #done = false;
7
+ afterCommit$ = this.#afterCommitSubject.asObservable();
8
+ manualCommit = false;
9
+ withManualCommit() {
10
+ this.manualCommit = true;
11
+ }
12
+ /**
13
+ * Enters automatic transaction handling. Transaction will be commited when all use-calls are done or rolled back when one throws.
14
+ */
15
+ async use(handler) {
16
+ this.#useCounter++;
17
+ try {
18
+ return await handler();
19
+ }
20
+ finally {
21
+ this.#useCounter--;
22
+ if ((this.#useCounter == 0) && !this.#done && !this.manualCommit) {
23
+ await this.commit();
24
+ }
25
+ }
26
+ }
27
+ async commit() {
28
+ this.#done = true;
29
+ await this._commit();
30
+ this.#afterCommitSubject.next();
31
+ this.#afterCommitSubject.complete();
32
+ }
33
+ rollback() {
34
+ this.#done = true;
35
+ this._rollback();
36
+ }
37
+ }
38
+ export class DrizzleTransaction extends Transaction {
39
+ transaction;
40
+ deferPromise = new DeferredPromise();
41
+ pgTransactionPromise;
42
+ constructor(transaction, pgTransactionPromise) {
43
+ super();
44
+ this.transaction = transaction;
45
+ this.pgTransactionPromise = pgTransactionPromise;
46
+ }
47
+ static async create(session, config) {
48
+ const transactionPromise = new DeferredPromise();
49
+ const pgTransactionPromise = session.transaction(async (tx) => {
50
+ const transaction = new DrizzleTransaction(tx, pgTransactionPromise);
51
+ transactionPromise.resolve(transaction);
52
+ await transaction.deferPromise;
53
+ }, config);
54
+ pgTransactionPromise.catch((error) => {
55
+ if (transactionPromise.pending) {
56
+ transactionPromise.reject(error);
57
+ }
58
+ });
59
+ return transactionPromise;
60
+ }
61
+ async _commit() {
62
+ this.deferPromise.resolve();
63
+ await this.pgTransactionPromise;
64
+ }
65
+ _rollback() {
66
+ try {
67
+ this.transaction.rollback();
68
+ }
69
+ catch (error) {
70
+ this.deferPromise.reject(error);
71
+ }
72
+ }
73
+ }
package/orm/types.d.ts CHANGED
@@ -1,24 +1,31 @@
1
- import type { HasDefault as DrizzleHasDefault, IsPrimaryKey as DrizzleIsPrimaryKey } from 'drizzle-orm';
2
- import type { boolean, doublePrecision, integer, PgColumnBuilder, PgColumnBuilderBase, PgEnumColumnBuilderInitial, text, uuid } from 'drizzle-orm/pg-core';
1
+ import type { $Type, HasDefault as DrizzleHasDefault, IsPrimaryKey as DrizzleIsPrimaryKey } from 'drizzle-orm';
2
+ import type { boolean, date, doublePrecision, integer, jsonb, PgColumnBuilder, PgColumnBuilderBase, PgEnumColumnBuilderInitial, text, timestamp, uuid } from 'drizzle-orm/pg-core';
3
3
  import type { GetTagMetadata, Tagged, UnwrapTagged } from 'type-fest';
4
4
  import { Array, Integer } from '../schema/index.js';
5
- import type { EnumerationObject, EnumerationValue, ObjectLiteral, Record, UnionToTuple } from '../types.js';
6
- import { Uuid } from './schemas/index.js';
5
+ import type { AbstractConstructor, EnumerationObject, EnumerationValue, ObjectLiteral, UnionToTuple } from '../types.js';
6
+ import { Embedded, Unique } from './decorators.js';
7
+ import { Json, NumericDate, Timestamp, Uuid } from './schemas/index.js';
7
8
  export type IsPrimaryKey<T> = T extends Tagged<unknown, 'column', PgColumnBuilderBase> ? Tagged<UnwrapTagged<T>, 'column', DrizzleIsPrimaryKey<GetTagMetadata<T, 'column'>>> : Tagged<T, 'column', ColumnBuilder<T>>;
8
9
  export type HasDefault<T> = T extends Tagged<unknown, 'column', PgColumnBuilderBase> ? Tagged<UnwrapTagged<T>, 'column', DrizzleHasDefault<GetTagMetadata<T, 'column'>>> : Tagged<T, 'column', ColumnBuilder<T>>;
9
- export type Nested<T extends Record> = Tagged<T, 'column', {
10
- nested: T;
11
- }>;
12
10
  type EnumColumn<T extends EnumerationObject, ColumnName extends string = ''> = PgEnumColumnBuilderInitial<ColumnName, UnionToTuple<`${EnumerationValue<T>}`> extends [string, ...string[]] ? UnionToTuple<`${EnumerationValue<T>}`> : ['NO_VALUES_PROVIDED']>;
13
11
  export type ColumnBuilder<T, ColumnName extends string = never> = T extends Tagged<T, 'column', any> ? GetTagMetadata<T, 'column'> : T extends string ? string extends ColumnName ? ReturnType<typeof text<ColumnName, string, [string, ...string[]]>> : ReturnType<typeof text<string, [string, ...string[]]>> : T extends number ? string extends ColumnName ? ReturnType<typeof doublePrecision<ColumnName>> : ReturnType<typeof doublePrecision> : T extends boolean ? string extends ColumnName ? ReturnType<typeof boolean<ColumnName>> : ReturnType<typeof boolean> : T extends EnumerationObject ? string extends ColumnName ? EnumColumn<T, ColumnName> : EnumColumn<T> : T extends (infer U)[] ? string extends ColumnName ? ReturnType<ColumnBuilder<U, ColumnName>['array']> : ReturnType<ColumnBuilder<U>['array']> : never;
14
12
  export type TypeBuilder<T, ColumnName extends string = never> = [
15
13
  ColumnName
16
14
  ] extends [never] ? T extends Tagged<any, 'column', PgColumnBuilderBase> ? T : T extends infer U ? Tagged<U, 'column', ColumnBuilder<U>> : never : never;
15
+ export declare const embedded: unique symbol;
16
+ export type Embedded<T = AbstractConstructor, P extends string = ''> = T & {
17
+ [embedded]: {
18
+ prefix: P;
19
+ };
20
+ };
17
21
  export type Array<T extends Tagged<ObjectLiteral, 'column', PgColumnBuilder<any>>> = Tagged<UnwrapTagged<T>[], 'column', ReturnType<GetTagMetadata<T, 'column'>['array']>>;
22
+ export type Json<T extends ObjectLiteral = ObjectLiteral> = Tagged<T, 'column', $Type<ReturnType<typeof jsonb>, T>>;
18
23
  export type Enum<T extends EnumerationObject> = Tagged<EnumerationValue<T>, 'column', EnumColumn<T>>;
19
24
  export type Text = Tagged<string, 'column', ReturnType<typeof text<string, [string, ...string[]]>>>;
20
25
  export type Uuid = Tagged<string, 'column', ReturnType<typeof uuid>>;
21
26
  export type Integer = Tagged<number, 'column', ReturnType<typeof integer>>;
22
27
  export type DoublePrecision = Tagged<number, 'column', ReturnType<typeof doublePrecision>>;
23
28
  export type Boolean = Tagged<number, 'column', ReturnType<typeof boolean>>;
24
- export { Array, Integer, Uuid };
29
+ export type NumericDate = Tagged<number, 'column', ReturnType<typeof date>>;
30
+ export type Timestamp = Tagged<number, 'column', ReturnType<typeof timestamp>>;
31
+ export { Array, Embedded, Integer, Json, NumericDate, Timestamp, Unique, Uuid };
package/orm/types.js CHANGED
@@ -1,4 +1,5 @@
1
1
  /* eslint-disable @typescript-eslint/no-redeclare, @typescript-eslint/naming-convention */
2
2
  import { Array, Integer } from '../schema/index.js';
3
- import { Uuid } from './schemas/index.js';
4
- export { Array, Integer, Uuid };
3
+ import { Embedded, Unique } from './decorators.js';
4
+ import { Json, NumericDate, Timestamp, Uuid } from './schemas/index.js';
5
+ export { Array, Embedded, Integer, Json, NumericDate, Timestamp, Unique, Uuid };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tstdl/base",
3
- "version": "0.91.50",
3
+ "version": "0.91.52",
4
4
  "author": "Patrick Hein",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -10,9 +10,11 @@
10
10
  "build": "tsc && tsc-alias",
11
11
  "build:watch": "concurrently --raw --kill-others npm:tsc:watch npm:tsc-alias:watch",
12
12
  "build:production": "rm -rf dist && npm run build && npm run build:production:copy-files",
13
- "build:production:copy-files": "cp package.json .eslintrc.json tsconfig.server.json dist/ && cp tsconfig.base.json dist/tsconfig.json",
13
+ "build:production:copy-files": "cp package.json .eslintrc.json tsconfig.server.json dist/ && cp tsconfig.base.json dist/tsconfig.json && npm run copy:document-management",
14
14
  "build:docs": "typedoc",
15
15
  "build:docs:watch": "typedoc --watch",
16
+ "generate:drizzle": "drizzle-kit generate --config dist/document-management/drizzle.config.js",
17
+ "copy:document-management": "rm -rf ./dist/document-management/drizzle && cp -r ./source/document-management/drizzle ./dist/document-management/",
16
18
  "lint": "eslint --config .eslintrc.json --cache source/",
17
19
  "pub": "npm run build:production && rm -vf dist/test* && rm -vrf dist/tools/ && npm publish dist/",
18
20
  "tsc:watch": "tsc --watch",
@@ -79,7 +81,7 @@
79
81
  "./reflection": "./reflection/index.js",
80
82
  "./rpc": "./rpc/index.js",
81
83
  "./rpc/endpoints": "./rpc/endpoints/index.js",
82
- "./rxjs": "./rxjs/index.js",
84
+ "./rxjs": "./rxjs-utils/index.js",
83
85
  "./schema": "./schema/index.js",
84
86
  "./search-index": "./search-index/index.js",
85
87
  "./search-index/elastic": "./search-index/elastic/index.js",
@@ -115,11 +117,11 @@
115
117
  "luxon": "^3.5",
116
118
  "reflect-metadata": "^0.2",
117
119
  "rxjs": "^7.8",
118
- "type-fest": "4.30"
120
+ "type-fest": "4.31"
119
121
  },
120
122
  "devDependencies": {
121
123
  "@mxssfd/typedoc-theme": "1.1",
122
- "@stylistic/eslint-plugin": "2.11",
124
+ "@stylistic/eslint-plugin": "2.12",
123
125
  "@types/chroma-js": "2.4",
124
126
  "@types/koa__router": "12.0",
125
127
  "@types/luxon": "3.4",
@@ -128,19 +130,21 @@
128
130
  "@types/node": "22",
129
131
  "@types/nodemailer": "6.4",
130
132
  "@types/pg": "8.11",
131
- "@typescript-eslint/eslint-plugin": "8.17",
133
+ "@typescript-eslint/eslint-plugin": "8.19",
132
134
  "concurrently": "9.1",
133
- "drizzle-kit": "0.28",
135
+ "drizzle-kit": "0.30",
134
136
  "eslint": "8.57",
135
- "eslint-import-resolver-typescript": "3.6",
137
+ "eslint-import-resolver-typescript": "3.7",
136
138
  "eslint-plugin-import": "2.31",
137
139
  "tsc-alias": "1.8",
140
+ "tsx": "^4.19.2",
138
141
  "typedoc": "0.27",
139
142
  "typedoc-plugin-missing-exports": "3.1",
140
143
  "typescript": "5.6"
141
144
  },
142
145
  "peerDependencies": {
143
- "@elastic/elasticsearch": "^8.16",
146
+ "@elastic/elasticsearch": "^8.17",
147
+ "@google/generative-ai": "^0.21",
144
148
  "@koa/router": "^13.1",
145
149
  "@tstdl/angular": "^0.91",
146
150
  "@zxcvbn-ts/core": "^3.0",
@@ -148,23 +152,30 @@
148
152
  "@zxcvbn-ts/language-de": "^3.0",
149
153
  "@zxcvbn-ts/language-en": "^3.0",
150
154
  "chroma-js": "^2.6",
151
- "drizzle-orm": "^0.36",
155
+ "drizzle-orm": "^0.38",
152
156
  "handlebars": "^4.7",
153
157
  "koa": "^2.15",
154
158
  "minio": "^8.0",
155
159
  "mjml": "^4.15",
156
- "mongodb": "^6.11",
160
+ "mongodb": "^6.12",
157
161
  "nodemailer": "^6.9",
158
162
  "pg": "8.13",
159
163
  "playwright": "^1.49",
160
164
  "preact": "^10.25",
161
165
  "preact-render-to-string": "^6.5",
162
- "undici": "^6.21",
166
+ "undici": "^7.2",
163
167
  "urlpattern-polyfill": "^10.0"
164
168
  },
165
169
  "peerDependenciesMeta": {
166
170
  "@tstdl/angular": {
167
171
  "optional": true
168
172
  }
173
+ },
174
+ "overrides": {
175
+ "drizzle-kit": {
176
+ "@esbuild-kit/esm-loader": "^2.6",
177
+ "esbuild": "^0.24",
178
+ "esbuild-register": "^3.6"
179
+ }
169
180
  }
170
181
  }
@@ -1,2 +1,2 @@
1
- import type { MonoTypeOperatorFunction } from 'rxjs';
1
+ import { type MonoTypeOperatorFunction } from 'rxjs';
2
2
  export declare function rejectErrors<T>(): MonoTypeOperatorFunction<T>;
@@ -1,4 +1,4 @@
1
- import type { BackoffOptions } from '../utils/backoff.js';
2
- import type { MonoTypeOperatorFunction, ObservableInput } from 'rxjs';
1
+ import { type BackoffOptions } from '../utils/backoff.js';
2
+ import { type MonoTypeOperatorFunction, type ObservableInput } from 'rxjs';
3
3
  export declare function retryBackoff<T>(count: number, options: BackoffOptions): MonoTypeOperatorFunction<T>;
4
4
  export declare function retryBackoffHandled<T>(count: number, options: BackoffOptions, handler: (error: Error, count: number) => void | undefined | ObservableInput<void>): MonoTypeOperatorFunction<T>;
@@ -1,30 +1,30 @@
1
- import type { MonoTypeOperatorFunction, Observable } from 'rxjs';
1
+ import { type MonoTypeOperatorFunction, type Observable } from 'rxjs';
2
2
  export type SlowArrayOptions = {
3
3
  /**
4
- * delay before emitting the first array
4
+ * Delay before emitting the first array
5
5
  */
6
6
  delay?: number;
7
7
  /**
8
- * initial emitted array size
8
+ * Initial emitted array size
9
9
  */
10
10
  initialSize?: number;
11
11
  /**
12
- * interval between each addition of more items
12
+ * Interval between each addition of more items
13
13
  */
14
14
  interval: number;
15
15
  /**
16
- * how many items to add each interval
16
+ * How many items to add each interval
17
17
  */
18
18
  size: number;
19
19
  };
20
20
  /**
21
- * emits arrays
21
+ * Emits arrays
22
22
  * @param array array to take items from
23
23
  * @param options options
24
24
  */
25
25
  export declare function slowArray<T>(array: T[], options: SlowArrayOptions): Observable<T[]>;
26
26
  /**
27
- * emits arrays - keeping length when changing source array
27
+ * Emits arrays - keeping length when changing source array
28
28
  * @param array array observable to take items from
29
29
  * @param options options
30
30
  */
@@ -1,6 +1,6 @@
1
1
  import { map, of, switchMap, takeWhile, timer } from 'rxjs';
2
2
  /**
3
- * emits arrays
3
+ * Emits arrays
4
4
  * @param array array to take items from
5
5
  * @param options options
6
6
  */
@@ -8,7 +8,7 @@ export function slowArray(array, options) {
8
8
  return of(array).pipe(persistentSlowArray(options));
9
9
  }
10
10
  /**
11
- * emits arrays - keeping length when changing source array
11
+ * Emits arrays - keeping length when changing source array
12
12
  * @param array array observable to take items from
13
13
  * @param options options
14
14
  */
@@ -1,2 +1,2 @@
1
- import type { OperatorFunction } from 'rxjs';
1
+ import { type OperatorFunction } from 'rxjs';
2
2
  export declare function startWithProvider<T, D>(valueProvider: () => D): OperatorFunction<T, T | D>;
@@ -1,2 +1,2 @@
1
- import type { OperatorFunction } from 'rxjs';
1
+ import { type OperatorFunction } from 'rxjs';
2
2
  export declare function teardown<T>(teardownFn: (lastValue: T | undefined, lastError: any) => unknown): OperatorFunction<T, T>;
@@ -1,2 +1,2 @@
1
- import type { MonoTypeOperatorFunction } from 'rxjs';
1
+ import { type MonoTypeOperatorFunction } from 'rxjs';
2
2
  export declare function untrack<T>(): MonoTypeOperatorFunction<T>;
@@ -1,11 +1,11 @@
1
1
  import type { Decorator } from '../../reflection/types.js';
2
2
  import type { SchemaTestable } from '../schema.js';
3
- import type { ObjectSchemaFactoryFunction, ObjectSchemaOptions } from '../schemas/object.js';
3
+ import type { ObjectSchemaFactory, ObjectSchemaOptions } from '../schemas/object.js';
4
4
  export type SchemaClassDecorator = Decorator<'class'>;
5
5
  export type SchemaPropertyDecorator = Decorator<'property' | 'accessor'>;
6
6
  export type SchemaTypeReflectionData = Partial<Pick<ObjectSchemaOptions, 'mask' | 'unknownProperties' | 'unknownPropertiesKey'>> & {
7
7
  schema?: SchemaTestable;
8
- factory?: ObjectSchemaFactoryFunction<any>;
8
+ factory?: ObjectSchemaFactory<any>;
9
9
  };
10
10
  export type SchemaPropertyReflectionData = {
11
11
  schema?: SchemaTestable;
@@ -6,7 +6,7 @@ export type NumberSchemaOptions = SimpleSchemaOptions & {
6
6
  maximum?: number;
7
7
  };
8
8
  export declare class NumberSchema extends SimpleSchema<number> {
9
- readonly name = "number";
9
+ readonly name: string;
10
10
  readonly integer: boolean;
11
11
  readonly minimum: number | null;
12
12
  readonly maximum: number | null;
package/signals/pipe.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { type OperatorFunction } from 'rxjs';
2
- import type { Signal } from './api.js';
2
+ import { type Signal } from './api.js';
3
3
  /**
4
4
  * As we need an synchronous value for the resulting signal and effect scheduling is async, it uses the source signals value as the initial value for the pipe.
5
5
  * This would normally result in double emission inside the pipe, but is mitigated by using {@link SignalPipeOptions.distinctUntilChanged}. Because of this, mutating source signals are not supported.
package/signals/pipe.js CHANGED
@@ -1,6 +1,5 @@
1
1
  import { distinctUntilChanged } from 'rxjs';
2
- import { startWithProvider } from '../rxjs/start-with-provider.js';
3
- import { untrack } from '../rxjs/untrack.js';
2
+ import { startWithProvider, untrack } from '../rxjs-utils/index.js';
4
3
  import { toObservable, toSignal } from './api.js';
5
4
  export function pipe(source, ...operators) {
6
5
  return rawPipe(source, startWithProvider(source), distinctUntilChanged(), ...operators);
@@ -1,21 +1,75 @@
1
1
  import { type Observable } from 'rxjs';
2
+ /**
3
+ * Represents the possible states of a Server-Sent Events connection.
4
+ */
2
5
  export declare enum ServerSentEventsState {
6
+ /**
7
+ * The connection is currently being established.
8
+ */
3
9
  Connecting = 0,
10
+ /**
11
+ * The connection is open and ready to receive events.
12
+ */
4
13
  Open = 1,
14
+ /**
15
+ * The connection is closed.
16
+ */
5
17
  Closed = 2
6
18
  }
19
+ /**
20
+ * A wrapper around the EventSource API, providing an RxJS-friendly interface for Server-Sent Events.
21
+ */
7
22
  export declare class ServerSentEvents {
8
23
  private readonly eventSource;
9
24
  private readonly closeSubject;
25
+ /**
26
+ * An observable that emits when the connection is open.
27
+ */
10
28
  readonly open$: Observable<void>;
29
+ /**
30
+ * An observable that emits when the connection is closed.
31
+ */
11
32
  readonly close$: Observable<void>;
33
+ /**
34
+ * An observable that emits when an error occurs with the connection.
35
+ */
12
36
  readonly error$: Observable<Event>;
37
+ /**
38
+ * An observable that emits the current state of the connection.
39
+ */
13
40
  readonly state$: Observable<ServerSentEventsState>;
41
+ /**
42
+ * An observable that emits `true` when the connection is in the 'Connecting' state, `false` otherwise.
43
+ */
14
44
  readonly isConnecting$: Observable<boolean>;
45
+ /**
46
+ * An observable that emits `true` when the connection is in the 'Open' state, `false` otherwise.
47
+ */
15
48
  readonly isOpen$: Observable<boolean>;
49
+ /**
50
+ * An observable that emits `true` when the connection is in the 'Closed' state, `false` otherwise.
51
+ */
16
52
  readonly isClosed$: Observable<boolean>;
53
+ /**
54
+ * Gets the current state of the Server-Sent Events connection.
55
+ * @returns The current state.
56
+ * @throws If the readyState of the EventSource is unknown.
57
+ */
17
58
  get state(): ServerSentEventsState;
59
+ /**
60
+ * Creates a new ServerSentEvents instance.
61
+ * @param url The URL of the server-sent events endpoint.
62
+ * @param options Optional EventSource initialization options.
63
+ */
18
64
  constructor(url: string, options?: EventSourceInit);
65
+ /**
66
+ * Returns an observable of message events for a specific event type or default to 'message' event.
67
+ * @param event The event type to listen for. Defaults to 'message'.
68
+ * @returns An observable of message events.
69
+ */
19
70
  message$(event?: string): Observable<MessageEvent<string>>;
71
+ /**
72
+ * Closes the Server-Sent Events connection.
73
+ */
20
74
  close(): void;
21
75
  }
@@ -1,21 +1,62 @@
1
1
  import { NotSupportedError } from '../errors/not-supported.error.js';
2
2
  import { ReplaySubject, distinctUntilChanged, filter, fromEvent, map, merge, share, shareReplay, startWith, takeUntil } from 'rxjs';
3
+ /**
4
+ * Represents the possible states of a Server-Sent Events connection.
5
+ */
3
6
  export var ServerSentEventsState;
4
7
  (function (ServerSentEventsState) {
8
+ /**
9
+ * The connection is currently being established.
10
+ */
5
11
  ServerSentEventsState[ServerSentEventsState["Connecting"] = 0] = "Connecting";
12
+ /**
13
+ * The connection is open and ready to receive events.
14
+ */
6
15
  ServerSentEventsState[ServerSentEventsState["Open"] = 1] = "Open";
16
+ /**
17
+ * The connection is closed.
18
+ */
7
19
  ServerSentEventsState[ServerSentEventsState["Closed"] = 2] = "Closed";
8
20
  })(ServerSentEventsState || (ServerSentEventsState = {}));
21
+ /**
22
+ * A wrapper around the EventSource API, providing an RxJS-friendly interface for Server-Sent Events.
23
+ */
9
24
  export class ServerSentEvents {
10
25
  eventSource;
11
26
  closeSubject;
27
+ /**
28
+ * An observable that emits when the connection is open.
29
+ */
12
30
  open$;
31
+ /**
32
+ * An observable that emits when the connection is closed.
33
+ */
13
34
  close$;
35
+ /**
36
+ * An observable that emits when an error occurs with the connection.
37
+ */
14
38
  error$;
39
+ /**
40
+ * An observable that emits the current state of the connection.
41
+ */
15
42
  state$;
43
+ /**
44
+ * An observable that emits `true` when the connection is in the 'Connecting' state, `false` otherwise.
45
+ */
16
46
  isConnecting$;
47
+ /**
48
+ * An observable that emits `true` when the connection is in the 'Open' state, `false` otherwise.
49
+ */
17
50
  isOpen$;
51
+ /**
52
+ * An observable that emits `true` when the connection is in the 'Closed' state, `false` otherwise.
53
+ */
18
54
  isClosed$;
55
+ /**
56
+ * Gets the current state of the Server-Sent Events connection.
57
+ * @returns The current state.
58
+ * @throws If the readyState of the EventSource is unknown.
59
+ */
19
60
  get state() {
20
61
  switch (this.eventSource.readyState) {
21
62
  case EventSource.CONNECTING:
@@ -28,6 +69,11 @@ export class ServerSentEvents {
28
69
  throw new NotSupportedError(`Unknown EventSource readyState ${this.eventSource.readyState}`);
29
70
  }
30
71
  }
72
+ /**
73
+ * Creates a new ServerSentEvents instance.
74
+ * @param url The URL of the server-sent events endpoint.
75
+ * @param options Optional EventSource initialization options.
76
+ */
31
77
  constructor(url, options) {
32
78
  this.eventSource = new EventSource(url, options);
33
79
  this.closeSubject = new ReplaySubject(1);
@@ -40,9 +86,17 @@ export class ServerSentEvents {
40
86
  this.isClosed$ = this.state$.pipe(map((state) => state == ServerSentEventsState.Closed), shareReplay({ bufferSize: 1, refCount: true }));
41
87
  this.open$ = this.isOpen$.pipe(filter((open) => open), map(() => undefined), takeUntil(this.close$), share());
42
88
  }
89
+ /**
90
+ * Returns an observable of message events for a specific event type or default to 'message' event.
91
+ * @param event The event type to listen for. Defaults to 'message'.
92
+ * @returns An observable of message events.
93
+ */
43
94
  message$(event) {
44
95
  return fromEvent(this.eventSource, event ?? 'message').pipe(takeUntil(this.close$));
45
96
  }
97
+ /**
98
+ * Closes the Server-Sent Events connection.
99
+ */
46
100
  close() {
47
101
  this.eventSource.close();
48
102
  this.closeSubject.next();
package/types.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { Observable } from 'rxjs';
2
- import type { CamelCase, Except, IsEqual, LiteralUnion } from 'type-fest';
2
+ import type { CamelCase, Except, IsEqual, LiteralUnion, Tagged, UnwrapTagged } from 'type-fest';
3
3
  import type { Signal } from './signals/api.js';
4
4
  export type ObjectLiteral = {};
5
5
  export type PrimitiveTypeMap = {
@@ -210,5 +210,9 @@ export type OmitDeep<T, S extends OmitDeepSelection<T>> = T extends Record<any>
210
210
  S[Extract<P, keyof S>]
211
211
  ] extends ([false] | [never]) ? T[P] : S[Extract<P, keyof S>] extends Record<any> ? T[P] extends (infer U)[] ? S[Extract<P, keyof S>] extends OmitDeepSelection<U> ? OmitDeep<U, S[Extract<P, keyof S>]>[] : never : S[Extract<P, keyof S>] extends OmitDeepSelection<T[P]> ? OmitDeep<T[P], S[Extract<P, keyof S>]> : never : never;
212
212
  }> : T;
213
+ export type Untagged<T> = T extends Tagged<unknown, any, any> ? UnwrapTagged<T> : T;
214
+ export type UntaggedDeep<T> = T extends Tagged<unknown, any, any> ? UnwrapTagged<T> : T extends readonly (infer U)[] ? UntaggedDeep<U>[] : T extends Record ? {
215
+ [P in keyof T]: UntaggedDeep<T[P]>;
216
+ } : Untagged<T>;
213
217
  export type AnyFunction = Function;
214
218
  export {};
@@ -2,6 +2,7 @@ export declare function compareByValueSelection<T>(...selectors: ((item: T) => u
2
2
  export declare function compareByValueSelectionDescending<T>(...selectors: ((item: T) => unknown)[]): (a: T, b: T) => number;
3
3
  export declare function compareByValueSelectionOrdered<T>(...selectors: (readonly [(item: T) => unknown, 1 | -1])[]): (a: T, b: T) => number;
4
4
  export declare function compareByValueToOrder<T>(order: T[]): (a: T, b: T) => number;
5
- export declare function compareByValueSelectionToOrder<T, TSelect>(order: TSelect[], selector: (item: T) => TSelect): (a: T, b: T) => number;
5
+ export declare const orderRest: unique symbol;
6
+ export declare function compareByValueSelectionToOrder<T, TSelect>(order: (TSelect | typeof orderRest)[], selector: (item: T) => TSelect): (a: T, b: T) => number;
6
7
  export declare function compareByValue<T>(a: T, b: T): number;
7
8
  export declare function compareByValueDescending<T>(a: T, b: T): number;
@@ -42,6 +42,7 @@ export function compareByValueSelectionOrdered(...selectors) {
42
42
  export function compareByValueToOrder(order) {
43
43
  return compareByValueSelectionToOrder(order, (item) => item);
44
44
  }
45
+ export const orderRest = Symbol('Order rest');
45
46
  export function compareByValueSelectionToOrder(order, selector) {
46
47
  const indexMapEntries = order.map((orderItem, index) => [orderItem, index]);
47
48
  const indexMap = new Map(indexMapEntries);
@@ -49,10 +50,10 @@ export function compareByValueSelectionToOrder(order, selector) {
49
50
  return function compareByValueSelectionToOrder(a, b) {
50
51
  const selectedA = selector(a);
51
52
  const selectedB = selector(b);
52
- const indexA = indexMap.get(selectedA);
53
- const indexB = indexMap.get(selectedB);
53
+ const indexA = indexMap.get(selectedA) ?? indexMap.get(orderRest);
54
+ const indexB = indexMap.get(selectedB) ?? indexMap.get(orderRest);
54
55
  if (indexA == undefined || indexB == undefined) {
55
- throw new Error('value not defined in order');
56
+ throw new Error('Value not defined in order.');
56
57
  }
57
58
  return compareByValue(indexA, indexB);
58
59
  };
@@ -1,4 +1,4 @@
1
- import type { Stream } from 'node:stream';
1
+ import type * as NodeStream from 'node:stream';
2
2
  import type * as NodeZlib from 'node:zlib';
3
3
  export interface CompressionResult {
4
4
  toBuffer(): Promise<Uint8Array>;
@@ -23,6 +23,6 @@ export declare function decompressString(input: string, encoding: BufferEncoding
23
23
  export declare function decompress(buffer: NodeZlib.InputType, algorithm: 'gzip' | 'deflate' | 'deflate-raw', options?: NodeZlib.ZlibOptions): DecompressionResult;
24
24
  export declare function decompress(buffer: NodeZlib.InputType, algorithm: 'brotli', options?: NodeZlib.BrotliOptions): DecompressionResult;
25
25
  export declare function decompress(buffer: NodeZlib.InputType, algorithm: CompressionAlgorithm, options?: NodeZlib.ZlibOptions | NodeZlib.BrotliOptions): DecompressionResult;
26
- export declare function decompressStream(stream: Stream | ReadableStream, algorithm: 'gzip' | 'deflate' | 'deflate-raw', options?: NodeZlib.ZlibOptions): ReadableStream<Uint8Array>;
27
- export declare function decompressStream(stream: Stream | ReadableStream, algorithm: 'brotli', options?: NodeZlib.BrotliOptions): ReadableStream<Uint8Array>;
28
- export declare function decompressStream(stream: Stream | ReadableStream, algorithm: CompressionAlgorithm, options?: NodeZlib.ZlibOptions | NodeZlib.BrotliOptions): ReadableStream<Uint8Array>;
26
+ export declare function decompressStream(stream: NodeStream.Readable | ReadableStream, algorithm: 'gzip' | 'deflate' | 'deflate-raw', options?: NodeZlib.ZlibOptions): ReadableStream<Uint8Array>;
27
+ export declare function decompressStream(stream: NodeStream.Readable | ReadableStream, algorithm: 'brotli', options?: NodeZlib.BrotliOptions): ReadableStream<Uint8Array>;
28
+ export declare function decompressStream(stream: NodeStream.Readable | ReadableStream, algorithm: CompressionAlgorithm, options?: NodeZlib.ZlibOptions | NodeZlib.BrotliOptions): ReadableStream<Uint8Array>;