@routier/core 0.0.1-alpha.1

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 (168) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/package.json +91 -0
  3. package/rspack.config.mjs +65 -0
  4. package/src/assertions/index.ts +37 -0
  5. package/src/codegen/SlotPath.ts +20 -0
  6. package/src/codegen/blocks.ts +578 -0
  7. package/src/codegen/handlers/CloneHandlerBuilder.ts +13 -0
  8. package/src/codegen/handlers/CompareHandlerBuilder.ts +13 -0
  9. package/src/codegen/handlers/DeserializeHandlerBuilder.ts +20 -0
  10. package/src/codegen/handlers/EnableChangeTrackingHandlerBuilder.ts +13 -0
  11. package/src/codegen/handlers/EnrichmentHandlerBuilder.ts +28 -0
  12. package/src/codegen/handlers/FreezeHandlerBuilder.ts +13 -0
  13. package/src/codegen/handlers/HashHandlerBuilder.ts +25 -0
  14. package/src/codegen/handlers/HashTypeHandlerBuilder.ts +11 -0
  15. package/src/codegen/handlers/IdSelectorHandlerBuilder.ts +10 -0
  16. package/src/codegen/handlers/MergeHandlerBuilder.ts +19 -0
  17. package/src/codegen/handlers/PrepareHandlerBuilder.ts +23 -0
  18. package/src/codegen/handlers/SerializeHandlerBuilder.ts +15 -0
  19. package/src/codegen/handlers/StripHandlerBuilder.ts +18 -0
  20. package/src/codegen/handlers/clone/CloneObjectHandler.ts +29 -0
  21. package/src/codegen/handlers/clone/CloneValueHandler.ts +33 -0
  22. package/src/codegen/handlers/compare/CompareObjectHandler.ts +15 -0
  23. package/src/codegen/handlers/compare/CompareValueHandler.ts +27 -0
  24. package/src/codegen/handlers/deserialize/DeserializeComputedValueHandler.ts +16 -0
  25. package/src/codegen/handlers/deserialize/DeserializeDateHandler.ts +45 -0
  26. package/src/codegen/handlers/deserialize/DeserializeFunctionHandler.ts +16 -0
  27. package/src/codegen/handlers/deserialize/DeserializeObjectHandler.ts +29 -0
  28. package/src/codegen/handlers/deserialize/DeserializeValueHandler.ts +33 -0
  29. package/src/codegen/handlers/enableChangeTracking/EnableChangeTrackingObjectHandler.ts +20 -0
  30. package/src/codegen/handlers/enableChangeTracking/EnableChangeTrackingPrimitiveValueHandler.ts +15 -0
  31. package/src/codegen/handlers/enrichment/EnrichmentComputedValueHandler.ts +37 -0
  32. package/src/codegen/handlers/enrichment/EnrichmentDefaultFunctionHandler.ts +50 -0
  33. package/src/codegen/handlers/enrichment/EnrichmentDefaultValueHandler.ts +18 -0
  34. package/src/codegen/handlers/enrichment/EnrichmentFunctionHandler.ts +38 -0
  35. package/src/codegen/handlers/enrichment/EnrichmentNullableObjectHandler.ts +44 -0
  36. package/src/codegen/handlers/enrichment/EnrichmentObjectHandler.ts +29 -0
  37. package/src/codegen/handlers/enrichment/EnrichmentObjectIdentityHandler.ts +16 -0
  38. package/src/codegen/handlers/enrichment/EnrichmentPrimitiveHandler.ts +13 -0
  39. package/src/codegen/handlers/enrichment/EnrichmentPrimitiveIdentityHandler.ts +21 -0
  40. package/src/codegen/handlers/freeze/FreezeObjectHandler.ts +20 -0
  41. package/src/codegen/handlers/freeze/FreezePrimitiveValueHandler.ts +15 -0
  42. package/src/codegen/handlers/hash/HashComputedValueHandler.ts +15 -0
  43. package/src/codegen/handlers/hash/HashDateHandler.ts +26 -0
  44. package/src/codegen/handlers/hash/HashFunctionHandler.ts +16 -0
  45. package/src/codegen/handlers/hash/HashIdentityHandler.ts +15 -0
  46. package/src/codegen/handlers/hash/HashKeyHandler.ts +26 -0
  47. package/src/codegen/handlers/hash/HashValueHandler.ts +26 -0
  48. package/src/codegen/handlers/hashType/HashTypeValueHandler.ts +20 -0
  49. package/src/codegen/handlers/idSelector/IdSelectorValueHandler.ts +28 -0
  50. package/src/codegen/handlers/index.ts +13 -0
  51. package/src/codegen/handlers/merge/MergeComputedValueHandler.ts +37 -0
  52. package/src/codegen/handlers/merge/MergeDefaultFunctionHandler.ts +40 -0
  53. package/src/codegen/handlers/merge/MergeDefaultValueHandler.ts +32 -0
  54. package/src/codegen/handlers/merge/MergeFunctionHandler.ts +16 -0
  55. package/src/codegen/handlers/merge/MergePrimitiveHandler.ts +21 -0
  56. package/src/codegen/handlers/prepare/PrepareComputedValueHandler.ts +16 -0
  57. package/src/codegen/handlers/prepare/PrepareFunctionHandler.ts +16 -0
  58. package/src/codegen/handlers/prepare/PrepareIdentityHandler.ts +21 -0
  59. package/src/codegen/handlers/prepare/PrepareKeyHandler.ts +21 -0
  60. package/src/codegen/handlers/prepare/PrepareObjectHandler.ts +38 -0
  61. package/src/codegen/handlers/prepare/PrepareValueHandler.ts +36 -0
  62. package/src/codegen/handlers/serialize/SerializeDateHandler.ts +45 -0
  63. package/src/codegen/handlers/serialize/SerializeObjectHandler.ts +28 -0
  64. package/src/codegen/handlers/serialize/SerializeValueHandler.ts +33 -0
  65. package/src/codegen/handlers/strip/StripIdentityHandler.ts +15 -0
  66. package/src/codegen/handlers/strip/StripKeyHandler.ts +15 -0
  67. package/src/codegen/handlers/strip/StripObjectHandler.ts +35 -0
  68. package/src/codegen/handlers/strip/StripValueHandler.ts +36 -0
  69. package/src/codegen/handlers/types.ts +119 -0
  70. package/src/codegen/index.ts +2 -0
  71. package/src/codegen/types.ts +2 -0
  72. package/src/codegen/utils.ts +74 -0
  73. package/src/collections/Changes.test.ts +337 -0
  74. package/src/collections/Changes.ts +177 -0
  75. package/src/collections/IdSet.ts +28 -0
  76. package/src/collections/MemoryDataCollection.test.ts +424 -0
  77. package/src/collections/MemoryDataCollection.ts +134 -0
  78. package/src/collections/SchemaCollection.ts +22 -0
  79. package/src/collections/TagCollection.test.ts +443 -0
  80. package/src/collections/TagCollection.ts +62 -0
  81. package/src/collections/index.ts +5 -0
  82. package/src/errors/SchemaError.ts +6 -0
  83. package/src/errors/index.ts +1 -0
  84. package/src/expressions/index.ts +3 -0
  85. package/src/expressions/parser.test.ts +913 -0
  86. package/src/expressions/parser.ts +661 -0
  87. package/src/expressions/types.ts +184 -0
  88. package/src/expressions/utils.test.ts +346 -0
  89. package/src/expressions/utils.ts +59 -0
  90. package/src/index.ts +12 -0
  91. package/src/performance/index.ts +26 -0
  92. package/src/pipeline/SyncronousQueue.test.ts +269 -0
  93. package/src/pipeline/SyncronousQueue.ts +30 -0
  94. package/src/pipeline/TrampolinePipeline.test.ts +374 -0
  95. package/src/pipeline/TrampolinePipeline.ts +437 -0
  96. package/src/pipeline/index.ts +2 -0
  97. package/src/plugins/EphemeralDataPlugin.ts +132 -0
  98. package/src/plugins/capabilities/DbPluginCapability.ts +111 -0
  99. package/src/plugins/capabilities/index.ts +2 -0
  100. package/src/plugins/capabilities/logging/DbPluginLoggingCapability.ts +261 -0
  101. package/src/plugins/capabilities/logging/index.ts +1 -0
  102. package/src/plugins/index.ts +6 -0
  103. package/src/plugins/query/Query.ts +67 -0
  104. package/src/plugins/query/QueryOptionsCollection.test.ts +86 -0
  105. package/src/plugins/query/QueryOptionsCollection.ts +154 -0
  106. package/src/plugins/query/index.ts +3 -0
  107. package/src/plugins/query/types.ts +46 -0
  108. package/src/plugins/replication/OptimisticReplicationDbPlugin.ts +202 -0
  109. package/src/plugins/replication/ReplicationDbPlugin.ts +137 -0
  110. package/src/plugins/replication/index.ts +3 -0
  111. package/src/plugins/replication/types.ts +5 -0
  112. package/src/plugins/translators/DataTranslator.ts +46 -0
  113. package/src/plugins/translators/JsonTranslator.test.ts +618 -0
  114. package/src/plugins/translators/JsonTranslator.ts +211 -0
  115. package/src/plugins/translators/SqlTranslator.ts +45 -0
  116. package/src/plugins/translators/index.ts +3 -0
  117. package/src/plugins/types.ts +114 -0
  118. package/src/results/Result.ts +91 -0
  119. package/src/results/index.ts +3 -0
  120. package/src/results/types.ts +17 -0
  121. package/src/results/utils.ts +15 -0
  122. package/src/schema/PropertyInfo.test.ts +479 -0
  123. package/src/schema/PropertyInfo.ts +374 -0
  124. package/src/schema/SchemaDefinition.ts +626 -0
  125. package/src/schema/builder.ts +18 -0
  126. package/src/schema/index.ts +7 -0
  127. package/src/schema/property/base/SchemaBase.ts +49 -0
  128. package/src/schema/property/base/index.ts +1 -0
  129. package/src/schema/property/modifiers/SchemaDefault.ts +29 -0
  130. package/src/schema/property/modifiers/SchemaDeserialize.ts +23 -0
  131. package/src/schema/property/modifiers/SchemaDistinct.ts +14 -0
  132. package/src/schema/property/modifiers/SchemaFrom.ts +54 -0
  133. package/src/schema/property/modifiers/SchemaIdentity.ts +13 -0
  134. package/src/schema/property/modifiers/SchemaIndex.ts +60 -0
  135. package/src/schema/property/modifiers/SchemaKey.ts +28 -0
  136. package/src/schema/property/modifiers/SchemaNullable.ts +18 -0
  137. package/src/schema/property/modifiers/SchemaOptional.ts +19 -0
  138. package/src/schema/property/modifiers/SchemaReadonly.ts +34 -0
  139. package/src/schema/property/modifiers/SchemaSerialize.ts +18 -0
  140. package/src/schema/property/modifiers/SchemaTracked.ts +14 -0
  141. package/src/schema/property/modifiers/index.ts +12 -0
  142. package/src/schema/property/types/SchemaArray.ts +50 -0
  143. package/src/schema/property/types/SchemaBoolean.ts +59 -0
  144. package/src/schema/property/types/SchemaDate.ts +58 -0
  145. package/src/schema/property/types/SchemaNumber.ts +69 -0
  146. package/src/schema/property/types/SchemaObject.ts +44 -0
  147. package/src/schema/property/types/SchemaString.ts +69 -0
  148. package/src/schema/property/types/index.ts +6 -0
  149. package/src/schema/table/SchemaComputed.ts +20 -0
  150. package/src/schema/table/SchemaFunction.ts +15 -0
  151. package/src/schema/table/index.ts +2 -0
  152. package/src/schema/types.ts +238 -0
  153. package/src/types/index.ts +5 -0
  154. package/src/utilities/arrays.test.ts +312 -0
  155. package/src/utilities/arrays.ts +12 -0
  156. package/src/utilities/dates.test.ts +388 -0
  157. package/src/utilities/dates.ts +11 -0
  158. package/src/utilities/dbPluginEventUtils.ts +44 -0
  159. package/src/utilities/index.ts +10 -0
  160. package/src/utilities/objects.ts +7 -0
  161. package/src/utilities/queryOptionsCollection.ts +16 -0
  162. package/src/utilities/replication.ts +23 -0
  163. package/src/utilities/runtime.ts +3 -0
  164. package/src/utilities/strings.ts +18 -0
  165. package/src/utilities/types.ts +1 -0
  166. package/src/utilities/uuid.ts +56 -0
  167. package/tsconfig.json +28 -0
  168. package/vitest.config.ts +11 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,8 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
+
6
+ ## 0.0.1-alpha.1 (2025-09-18)
7
+
8
+ **Note:** Version bump only for package @routier/core
package/package.json ADDED
@@ -0,0 +1,91 @@
1
+ {
2
+ "name": "@routier/core",
3
+ "version": "0.0.1-alpha.1",
4
+ "main": "./dist/index.js",
5
+ "types": "./dist/index.d.ts",
6
+ "source": "./src/index.ts",
7
+ "publishConfig": {
8
+ "access": "public"
9
+ },
10
+ "exports": {
11
+ ".": "./dist/index.js",
12
+ "./utilities": "./dist/utilities/index.js",
13
+ "./results": "./dist/results/index.js",
14
+ "./schema": "./dist/schema/index.js",
15
+ "./pipeline": "./dist/pipeline/index.js",
16
+ "./collections": "./dist/collections/index.js",
17
+ "./assertions": "./dist/assertions/index.js",
18
+ "./plugins": "./dist/plugins/index.js",
19
+ "./expressions": "./dist/expressions/index.js",
20
+ "./errors": "./dist/errors/index.js",
21
+ "./performance": "./dist/performance/index.js",
22
+ "./types": "./dist/types/index.js"
23
+ },
24
+ "typesVersions": {
25
+ "*": {
26
+ "utilities": [
27
+ "./dist/utilities/index.d.ts"
28
+ ],
29
+ "results": [
30
+ "./dist/results/index.d.ts"
31
+ ],
32
+ "schema": [
33
+ "./dist/schema/index.d.ts"
34
+ ],
35
+ "pipeline": [
36
+ "./dist/pipeline/index.d.ts"
37
+ ],
38
+ "collections": [
39
+ "./dist/collections/index.d.ts"
40
+ ],
41
+ "plugins": [
42
+ "./dist/plugins/index.d.ts"
43
+ ],
44
+ "expressions": [
45
+ "./dist/expressions/index.d.ts"
46
+ ],
47
+ "errors": [
48
+ "./dist/errors/index.d.ts"
49
+ ],
50
+ "performance": [
51
+ "./dist/performance/index.d.ts"
52
+ ],
53
+ "assertions": [
54
+ "./dist/assertions/index.d.ts"
55
+ ],
56
+ "types": [
57
+ "./dist/types/index.d.ts"
58
+ ]
59
+ }
60
+ },
61
+ "scripts": {
62
+ "build:types": "tsc --emitDeclarationOnly",
63
+ "build:bundle": "rspack build",
64
+ "build": "npm run build:bundle && npm run build:types",
65
+ "tsc": "tsc",
66
+ "test": "vitest run"
67
+ },
68
+ "sideEffects": false,
69
+ "author": "James DeMeuse <james.demeuse@gmail.com>",
70
+ "license": "MIT",
71
+ "repository": "Agrejus/routier",
72
+ "keywords": [
73
+ "orm",
74
+ "typescript",
75
+ "web",
76
+ "indexeddb",
77
+ "electron",
78
+ "data access layer",
79
+ "entities",
80
+ "entity framework",
81
+ "database"
82
+ ],
83
+ "description": "Core functionality for routier",
84
+ "devDependencies": {
85
+ "@rspack/cli": "^1.1.8",
86
+ "@rspack/core": "^1.1.8",
87
+ "ts-loader": "^9.5.2",
88
+ "typescript": "^5.7.2",
89
+ "vitest": "^3.2.4"
90
+ }
91
+ }
@@ -0,0 +1,65 @@
1
+ import { dirname, resolve } from "node:path";
2
+ import { fileURLToPath } from "node:url";
3
+ import { defineConfig } from "@rspack/cli";
4
+
5
+ const __dirname = dirname(fileURLToPath(import.meta.url));
6
+
7
+ export default defineConfig({
8
+ entry: {
9
+ index: "./src/index.ts",
10
+ "utilities/index": "./src/utilities/index.ts",
11
+ "results/index": "./src/results/index.ts",
12
+ "schema/index": "./src/schema/index.ts",
13
+ "pipeline/index": "./src/pipeline/index.ts",
14
+ "collections/index": "./src/collections/index.ts",
15
+ "assertions/index": "./src/assertions/index.ts",
16
+ "plugins/index": "./src/plugins/index.ts",
17
+ "expressions/index": "./src/expressions/index.ts",
18
+ "errors/index": "./src/errors/index.ts",
19
+ "performance/index": "./src/performance/index.ts",
20
+ "types/index": "./src/types/index.ts"
21
+ },
22
+ output: {
23
+ path: resolve(__dirname, "dist"),
24
+ filename: "[name].js",
25
+ library: {
26
+ type: "module"
27
+ },
28
+ globalObject: "this", // Ensures compatibility with both browser and Node.js
29
+ clean: true, // Cleans the output directory before each build
30
+ },
31
+ experiments: {
32
+ outputModule: true
33
+ },
34
+ module: {
35
+ rules: [
36
+ {
37
+ test: /\.ts$/, // Match TypeScript files
38
+ use: {
39
+ loader: "ts-loader",
40
+ options: {
41
+ transpileOnly: false, // Ensure type-checking is performed
42
+ },
43
+ },
44
+ exclude: [
45
+ /node_modules/,
46
+ /\.test\.ts$/, // Exclude test files
47
+ ],
48
+ },
49
+ ],
50
+ },
51
+ resolve: {
52
+ extensions: [".ts", ".js"], // Resolve TypeScript and JavaScript files
53
+ fallback: {
54
+ "perf_hooks": false
55
+ }
56
+ },
57
+ target: "web", // Compile for both browser and Node.js
58
+ externals: {
59
+ // Define external dependencies to avoid bundling them
60
+ // e.g., for lodash: "lodash": "lodash"
61
+ "perf_hooks": "perf_hooks"
62
+ },
63
+ mode: "development", // Set production mode
64
+ devtool: "source-map"
65
+ });
@@ -0,0 +1,37 @@
1
+ import { isDate } from "../utilities";
2
+
3
+ export function assertDate(data: unknown): asserts data is Date {
4
+ if (isDate(data) === false) {
5
+ throw new TypeError('Value is not a Date');
6
+ }
7
+ }
8
+
9
+ export function assertIsNotNull<T>(data: T | null | undefined, message?: string): asserts data is NonNullable<T> {
10
+ if (data == null) {
11
+ throw new TypeError(message ?? 'Assertion failed, data is null');
12
+ }
13
+ }
14
+
15
+ export function assertIsArray<T>(data: unknown, message?: string): asserts data is T[] {
16
+ if (!Array.isArray(data)) {
17
+ throw new TypeError(message ?? 'Assertion failed, data is not of type Array');
18
+ }
19
+ }
20
+
21
+ export function assertString(data: unknown, message?: string): asserts data is string {
22
+ if (typeof data !== "string") {
23
+ throw new TypeError(message ?? 'Assertion failed, data is not of type String');
24
+ }
25
+ }
26
+
27
+ export function assertInstanceOf<T extends new (...args: any[]) => any>(value: unknown, Instance: T): asserts value is T {
28
+ if (value instanceof Instance) {
29
+ return;
30
+ }
31
+
32
+ if (value != null && typeof value === "object" && "constructor" in value) {
33
+ throw new TypeError(`Value is not instance of type. Type: ${value.constructor.name}`);
34
+ }
35
+
36
+ throw new TypeError(`Value is not instance of type`);
37
+ }
@@ -0,0 +1,20 @@
1
+ export class SlotPath {
2
+
3
+ private _path: string[];
4
+
5
+ get path() {
6
+ return [...this._path]
7
+ }
8
+
9
+ constructor(...pathLike: string[]) {
10
+ this._path = pathLike;
11
+ }
12
+
13
+ push(...pathLike: string[]) {
14
+ this._path.push(...pathLike);
15
+ }
16
+
17
+ get(up: number = 0) {
18
+ return this._path.slice(0, this._path.length - up).join(".")
19
+ }
20
+ }