@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.
- package/CHANGELOG.md +8 -0
- package/package.json +91 -0
- package/rspack.config.mjs +65 -0
- package/src/assertions/index.ts +37 -0
- package/src/codegen/SlotPath.ts +20 -0
- package/src/codegen/blocks.ts +578 -0
- package/src/codegen/handlers/CloneHandlerBuilder.ts +13 -0
- package/src/codegen/handlers/CompareHandlerBuilder.ts +13 -0
- package/src/codegen/handlers/DeserializeHandlerBuilder.ts +20 -0
- package/src/codegen/handlers/EnableChangeTrackingHandlerBuilder.ts +13 -0
- package/src/codegen/handlers/EnrichmentHandlerBuilder.ts +28 -0
- package/src/codegen/handlers/FreezeHandlerBuilder.ts +13 -0
- package/src/codegen/handlers/HashHandlerBuilder.ts +25 -0
- package/src/codegen/handlers/HashTypeHandlerBuilder.ts +11 -0
- package/src/codegen/handlers/IdSelectorHandlerBuilder.ts +10 -0
- package/src/codegen/handlers/MergeHandlerBuilder.ts +19 -0
- package/src/codegen/handlers/PrepareHandlerBuilder.ts +23 -0
- package/src/codegen/handlers/SerializeHandlerBuilder.ts +15 -0
- package/src/codegen/handlers/StripHandlerBuilder.ts +18 -0
- package/src/codegen/handlers/clone/CloneObjectHandler.ts +29 -0
- package/src/codegen/handlers/clone/CloneValueHandler.ts +33 -0
- package/src/codegen/handlers/compare/CompareObjectHandler.ts +15 -0
- package/src/codegen/handlers/compare/CompareValueHandler.ts +27 -0
- package/src/codegen/handlers/deserialize/DeserializeComputedValueHandler.ts +16 -0
- package/src/codegen/handlers/deserialize/DeserializeDateHandler.ts +45 -0
- package/src/codegen/handlers/deserialize/DeserializeFunctionHandler.ts +16 -0
- package/src/codegen/handlers/deserialize/DeserializeObjectHandler.ts +29 -0
- package/src/codegen/handlers/deserialize/DeserializeValueHandler.ts +33 -0
- package/src/codegen/handlers/enableChangeTracking/EnableChangeTrackingObjectHandler.ts +20 -0
- package/src/codegen/handlers/enableChangeTracking/EnableChangeTrackingPrimitiveValueHandler.ts +15 -0
- package/src/codegen/handlers/enrichment/EnrichmentComputedValueHandler.ts +37 -0
- package/src/codegen/handlers/enrichment/EnrichmentDefaultFunctionHandler.ts +50 -0
- package/src/codegen/handlers/enrichment/EnrichmentDefaultValueHandler.ts +18 -0
- package/src/codegen/handlers/enrichment/EnrichmentFunctionHandler.ts +38 -0
- package/src/codegen/handlers/enrichment/EnrichmentNullableObjectHandler.ts +44 -0
- package/src/codegen/handlers/enrichment/EnrichmentObjectHandler.ts +29 -0
- package/src/codegen/handlers/enrichment/EnrichmentObjectIdentityHandler.ts +16 -0
- package/src/codegen/handlers/enrichment/EnrichmentPrimitiveHandler.ts +13 -0
- package/src/codegen/handlers/enrichment/EnrichmentPrimitiveIdentityHandler.ts +21 -0
- package/src/codegen/handlers/freeze/FreezeObjectHandler.ts +20 -0
- package/src/codegen/handlers/freeze/FreezePrimitiveValueHandler.ts +15 -0
- package/src/codegen/handlers/hash/HashComputedValueHandler.ts +15 -0
- package/src/codegen/handlers/hash/HashDateHandler.ts +26 -0
- package/src/codegen/handlers/hash/HashFunctionHandler.ts +16 -0
- package/src/codegen/handlers/hash/HashIdentityHandler.ts +15 -0
- package/src/codegen/handlers/hash/HashKeyHandler.ts +26 -0
- package/src/codegen/handlers/hash/HashValueHandler.ts +26 -0
- package/src/codegen/handlers/hashType/HashTypeValueHandler.ts +20 -0
- package/src/codegen/handlers/idSelector/IdSelectorValueHandler.ts +28 -0
- package/src/codegen/handlers/index.ts +13 -0
- package/src/codegen/handlers/merge/MergeComputedValueHandler.ts +37 -0
- package/src/codegen/handlers/merge/MergeDefaultFunctionHandler.ts +40 -0
- package/src/codegen/handlers/merge/MergeDefaultValueHandler.ts +32 -0
- package/src/codegen/handlers/merge/MergeFunctionHandler.ts +16 -0
- package/src/codegen/handlers/merge/MergePrimitiveHandler.ts +21 -0
- package/src/codegen/handlers/prepare/PrepareComputedValueHandler.ts +16 -0
- package/src/codegen/handlers/prepare/PrepareFunctionHandler.ts +16 -0
- package/src/codegen/handlers/prepare/PrepareIdentityHandler.ts +21 -0
- package/src/codegen/handlers/prepare/PrepareKeyHandler.ts +21 -0
- package/src/codegen/handlers/prepare/PrepareObjectHandler.ts +38 -0
- package/src/codegen/handlers/prepare/PrepareValueHandler.ts +36 -0
- package/src/codegen/handlers/serialize/SerializeDateHandler.ts +45 -0
- package/src/codegen/handlers/serialize/SerializeObjectHandler.ts +28 -0
- package/src/codegen/handlers/serialize/SerializeValueHandler.ts +33 -0
- package/src/codegen/handlers/strip/StripIdentityHandler.ts +15 -0
- package/src/codegen/handlers/strip/StripKeyHandler.ts +15 -0
- package/src/codegen/handlers/strip/StripObjectHandler.ts +35 -0
- package/src/codegen/handlers/strip/StripValueHandler.ts +36 -0
- package/src/codegen/handlers/types.ts +119 -0
- package/src/codegen/index.ts +2 -0
- package/src/codegen/types.ts +2 -0
- package/src/codegen/utils.ts +74 -0
- package/src/collections/Changes.test.ts +337 -0
- package/src/collections/Changes.ts +177 -0
- package/src/collections/IdSet.ts +28 -0
- package/src/collections/MemoryDataCollection.test.ts +424 -0
- package/src/collections/MemoryDataCollection.ts +134 -0
- package/src/collections/SchemaCollection.ts +22 -0
- package/src/collections/TagCollection.test.ts +443 -0
- package/src/collections/TagCollection.ts +62 -0
- package/src/collections/index.ts +5 -0
- package/src/errors/SchemaError.ts +6 -0
- package/src/errors/index.ts +1 -0
- package/src/expressions/index.ts +3 -0
- package/src/expressions/parser.test.ts +913 -0
- package/src/expressions/parser.ts +661 -0
- package/src/expressions/types.ts +184 -0
- package/src/expressions/utils.test.ts +346 -0
- package/src/expressions/utils.ts +59 -0
- package/src/index.ts +12 -0
- package/src/performance/index.ts +26 -0
- package/src/pipeline/SyncronousQueue.test.ts +269 -0
- package/src/pipeline/SyncronousQueue.ts +30 -0
- package/src/pipeline/TrampolinePipeline.test.ts +374 -0
- package/src/pipeline/TrampolinePipeline.ts +437 -0
- package/src/pipeline/index.ts +2 -0
- package/src/plugins/EphemeralDataPlugin.ts +132 -0
- package/src/plugins/capabilities/DbPluginCapability.ts +111 -0
- package/src/plugins/capabilities/index.ts +2 -0
- package/src/plugins/capabilities/logging/DbPluginLoggingCapability.ts +261 -0
- package/src/plugins/capabilities/logging/index.ts +1 -0
- package/src/plugins/index.ts +6 -0
- package/src/plugins/query/Query.ts +67 -0
- package/src/plugins/query/QueryOptionsCollection.test.ts +86 -0
- package/src/plugins/query/QueryOptionsCollection.ts +154 -0
- package/src/plugins/query/index.ts +3 -0
- package/src/plugins/query/types.ts +46 -0
- package/src/plugins/replication/OptimisticReplicationDbPlugin.ts +202 -0
- package/src/plugins/replication/ReplicationDbPlugin.ts +137 -0
- package/src/plugins/replication/index.ts +3 -0
- package/src/plugins/replication/types.ts +5 -0
- package/src/plugins/translators/DataTranslator.ts +46 -0
- package/src/plugins/translators/JsonTranslator.test.ts +618 -0
- package/src/plugins/translators/JsonTranslator.ts +211 -0
- package/src/plugins/translators/SqlTranslator.ts +45 -0
- package/src/plugins/translators/index.ts +3 -0
- package/src/plugins/types.ts +114 -0
- package/src/results/Result.ts +91 -0
- package/src/results/index.ts +3 -0
- package/src/results/types.ts +17 -0
- package/src/results/utils.ts +15 -0
- package/src/schema/PropertyInfo.test.ts +479 -0
- package/src/schema/PropertyInfo.ts +374 -0
- package/src/schema/SchemaDefinition.ts +626 -0
- package/src/schema/builder.ts +18 -0
- package/src/schema/index.ts +7 -0
- package/src/schema/property/base/SchemaBase.ts +49 -0
- package/src/schema/property/base/index.ts +1 -0
- package/src/schema/property/modifiers/SchemaDefault.ts +29 -0
- package/src/schema/property/modifiers/SchemaDeserialize.ts +23 -0
- package/src/schema/property/modifiers/SchemaDistinct.ts +14 -0
- package/src/schema/property/modifiers/SchemaFrom.ts +54 -0
- package/src/schema/property/modifiers/SchemaIdentity.ts +13 -0
- package/src/schema/property/modifiers/SchemaIndex.ts +60 -0
- package/src/schema/property/modifiers/SchemaKey.ts +28 -0
- package/src/schema/property/modifiers/SchemaNullable.ts +18 -0
- package/src/schema/property/modifiers/SchemaOptional.ts +19 -0
- package/src/schema/property/modifiers/SchemaReadonly.ts +34 -0
- package/src/schema/property/modifiers/SchemaSerialize.ts +18 -0
- package/src/schema/property/modifiers/SchemaTracked.ts +14 -0
- package/src/schema/property/modifiers/index.ts +12 -0
- package/src/schema/property/types/SchemaArray.ts +50 -0
- package/src/schema/property/types/SchemaBoolean.ts +59 -0
- package/src/schema/property/types/SchemaDate.ts +58 -0
- package/src/schema/property/types/SchemaNumber.ts +69 -0
- package/src/schema/property/types/SchemaObject.ts +44 -0
- package/src/schema/property/types/SchemaString.ts +69 -0
- package/src/schema/property/types/index.ts +6 -0
- package/src/schema/table/SchemaComputed.ts +20 -0
- package/src/schema/table/SchemaFunction.ts +15 -0
- package/src/schema/table/index.ts +2 -0
- package/src/schema/types.ts +238 -0
- package/src/types/index.ts +5 -0
- package/src/utilities/arrays.test.ts +312 -0
- package/src/utilities/arrays.ts +12 -0
- package/src/utilities/dates.test.ts +388 -0
- package/src/utilities/dates.ts +11 -0
- package/src/utilities/dbPluginEventUtils.ts +44 -0
- package/src/utilities/index.ts +10 -0
- package/src/utilities/objects.ts +7 -0
- package/src/utilities/queryOptionsCollection.ts +16 -0
- package/src/utilities/replication.ts +23 -0
- package/src/utilities/runtime.ts +3 -0
- package/src/utilities/strings.ts +18 -0
- package/src/utilities/types.ts +1 -0
- package/src/utilities/uuid.ts +56 -0
- package/tsconfig.json +28 -0
- package/vitest.config.ts +11 -0
package/CHANGELOG.md
ADDED
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
|
+
}
|