relation-matcher 1.0.10 → 1.0.12
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/.vscode/settings.json +2 -1
- package/.yarn/install-state.gz +0 -0
- package/.yarn/releases/yarn-4.13.0.cjs +940 -0
- package/.yarnrc.yml +2 -0
- package/dist/src/testing/test-data.d.ts +32 -2
- package/dist/src/types/return.d.ts +2 -4
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +10 -5
- package/src/testing/file-output.ts +15 -15
- package/src/testing/test-data.ts +172 -172
- package/src/types/generic-bases.ts +9 -9
- package/src/types/generic-less.ts +14 -14
- package/src/types/index.ts +5 -5
- package/src/types/inputs.ts +30 -30
- package/src/types/return.ts +67 -71
- package/src/types/typetest.ts +8 -0
- package/src/types/utils.ts +28 -28
- package/src/utils/invertInput.ts +28 -28
- package/src/utils/keys.ts +1 -1
- package/src/utils/matcher.ts +8 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "relation-matcher",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.12",
|
|
4
4
|
"description": "A utility to convert table data (such as out of a SQL query) into structured JSON.",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "",
|
|
@@ -8,19 +8,24 @@
|
|
|
8
8
|
"main": "dist/src/index.js",
|
|
9
9
|
"types": "dist/src/index.d.ts",
|
|
10
10
|
"exports": {
|
|
11
|
-
".":
|
|
12
|
-
|
|
11
|
+
".": {
|
|
12
|
+
"default": "./dist/src/index.js",
|
|
13
|
+
"types": "./dist/src/index.d.ts"
|
|
14
|
+
},
|
|
15
|
+
"./types": {
|
|
16
|
+
"default": "./dist/src/types/index.js",
|
|
17
|
+
"types": "./dist/src/types/index.d.ts"
|
|
18
|
+
},
|
|
13
19
|
"./source": "./src/index.ts",
|
|
14
20
|
"./source/types": "./src/types/index.ts"
|
|
15
21
|
},
|
|
16
|
-
"private": false,
|
|
17
22
|
"scripts": {
|
|
18
23
|
"test": "jest && tsc --noEmit",
|
|
19
24
|
"file-output": "tsx --watch src/file-output.ts",
|
|
20
25
|
"build": "tsc",
|
|
21
26
|
"build:publish": "yarn run test && yarn run build && npm publish"
|
|
22
27
|
},
|
|
23
|
-
"packageManager": "yarn@4.
|
|
28
|
+
"packageManager": "yarn@4.13.0",
|
|
24
29
|
"devDependencies": {
|
|
25
30
|
"@types/jest": "^30.0.0",
|
|
26
31
|
"@types/node": "^25.0.10",
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import fs from "fs/promises";
|
|
2
|
-
import path from "path";
|
|
3
|
-
import { relationMatcherRoot } from "..";
|
|
4
|
-
import { testData, testSchema } from "./test-data";
|
|
5
|
-
|
|
6
|
-
const main = async () => {
|
|
7
|
-
const result = relationMatcherRoot(testData, testSchema);
|
|
8
|
-
|
|
9
|
-
await fs.writeFile(
|
|
10
|
-
path.join(process.cwd(), "/result.json"),
|
|
11
|
-
JSON.stringify(result, null, "\t"),
|
|
12
|
-
);
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
void main();
|
|
1
|
+
import fs from "fs/promises";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { relationMatcherRoot } from "..";
|
|
4
|
+
import { testData, testSchema } from "./test-data";
|
|
5
|
+
|
|
6
|
+
const main = async () => {
|
|
7
|
+
const result = relationMatcherRoot(testData, testSchema);
|
|
8
|
+
|
|
9
|
+
await fs.writeFile(
|
|
10
|
+
path.join(process.cwd(), "/result.json"),
|
|
11
|
+
JSON.stringify(result, null, "\t"),
|
|
12
|
+
);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
void main();
|
package/src/testing/test-data.ts
CHANGED
|
@@ -1,172 +1,172 @@
|
|
|
1
|
-
import type { RelationMapRoot } from "~/types/inputs";
|
|
2
|
-
import type { Simplify } from "~/types/utils";
|
|
3
|
-
|
|
4
|
-
export const testData = [
|
|
5
|
-
{
|
|
6
|
-
users: {
|
|
7
|
-
id: "c7a2c1c8-9f4c-4f89-9d72-6b5a2f0c1e01",
|
|
8
|
-
clerkId: "user_abc123",
|
|
9
|
-
email: "alice@example.com",
|
|
10
|
-
createdAt: "2025-01-12T09:41:22.000Z",
|
|
11
|
-
},
|
|
12
|
-
teamToUser: {
|
|
13
|
-
teamId: "a2e5a3de-6d14-4e9b-9c9f-3cbb2cdb8a10",
|
|
14
|
-
userId: "c7a2c1c8-9f4c-4f89-9d72-6b5a2f0c1e01",
|
|
15
|
-
role: "admin",
|
|
16
|
-
},
|
|
17
|
-
teams: {
|
|
18
|
-
id: "a2e5a3de-6d14-4e9b-9c9f-3cbb2cdb8a10",
|
|
19
|
-
name: "Red Dragons",
|
|
20
|
-
},
|
|
21
|
-
posts: {
|
|
22
|
-
id: "f13d8f22-0b61-4d6a-8b1e-5b6b3d0c8a21",
|
|
23
|
-
userId: "c7a2c1c8-9f4c-4f89-9d72-6b5a2f0c1e01",
|
|
24
|
-
title: "First post",
|
|
25
|
-
published: true,
|
|
26
|
-
},
|
|
27
|
-
comments: {
|
|
28
|
-
id: "9d1a7c3b-2f6a-4f7c-bf4b-8f6e3c5d9e01",
|
|
29
|
-
postId: "f13d8f22-0b61-4d6a-8b1e-5b6b3d0c8a21",
|
|
30
|
-
body: "Nice post!",
|
|
31
|
-
authorEmail: "bob@example.com",
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
users: {
|
|
36
|
-
id: "c7a2c1c8-9f4c-4f89-9d72-6b5a2f0c1e01",
|
|
37
|
-
clerkId: "user_abc123",
|
|
38
|
-
email: "alice@example.com",
|
|
39
|
-
createdAt: "2025-01-12T09:41:22.000Z",
|
|
40
|
-
},
|
|
41
|
-
teamToUser: {
|
|
42
|
-
teamId: "a2e5a3de-6d14-4e9b-9c9f-3cbb2cdb8a10",
|
|
43
|
-
userId: "c7a2c1c8-9f4c-4f89-9d72-6b5a2f0c1e01",
|
|
44
|
-
role: "admin",
|
|
45
|
-
},
|
|
46
|
-
teams: {
|
|
47
|
-
id: "a2e5a3de-6d14-4e9b-9c9f-3cbb2cdb8a10",
|
|
48
|
-
name: "Red Dragons",
|
|
49
|
-
},
|
|
50
|
-
posts: {
|
|
51
|
-
id: "f13d8f22-0b61-4d6a-8b1e-5b6b3d0c8a21",
|
|
52
|
-
userId: "c7a2c1c8-9f4c-4f89-9d72-6b5a2f0c1e01",
|
|
53
|
-
title: "First post",
|
|
54
|
-
published: true,
|
|
55
|
-
},
|
|
56
|
-
comments: {
|
|
57
|
-
id: "e3c9b5a2-7f42-4b7e-9e3d-4a6f1d8b2c44",
|
|
58
|
-
postId: "f13d8f22-0b61-4d6a-8b1e-5b6b3d0c8a21",
|
|
59
|
-
body: "Thanks for sharing",
|
|
60
|
-
authorEmail: "charlie@example.com",
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
users: {
|
|
65
|
-
id: "c7a2c1c8-9f4c-4f89-9d72-6b5a2f0c1e01",
|
|
66
|
-
clerkId: "user_abc123",
|
|
67
|
-
email: "alice@example.com",
|
|
68
|
-
createdAt: "2025-01-12T09:41:22.000Z",
|
|
69
|
-
},
|
|
70
|
-
teamToUser: {
|
|
71
|
-
teamId: "a2e5a3de-6d14-4e9b-9c9f-3cbb2cdb8a10",
|
|
72
|
-
userId: "c7a2c1c8-9f4c-4f89-9d72-6b5a2f0c1e01",
|
|
73
|
-
role: "admin",
|
|
74
|
-
},
|
|
75
|
-
teams: {
|
|
76
|
-
id: "a2e5a3de-6d14-4e9b-9c9f-3cbb2cdb8a10",
|
|
77
|
-
name: "Red Dragons",
|
|
78
|
-
},
|
|
79
|
-
posts: {
|
|
80
|
-
id: "6bcb2b74-9b2f-4b38-bdb5-77c2e63d9c10",
|
|
81
|
-
userId: "c7a2c1c8-9f4c-4f89-9d72-6b5a2f0c1e01",
|
|
82
|
-
title: "Second post",
|
|
83
|
-
published: false,
|
|
84
|
-
},
|
|
85
|
-
comments: null,
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
users: {
|
|
89
|
-
id: "c7a2c1c8-9f4c-4f89-9d72-6b5a2f0c1e01",
|
|
90
|
-
clerkId: "user_abc123",
|
|
91
|
-
email: "alice@example.com",
|
|
92
|
-
createdAt: "2025-01-12T09:41:22.000Z",
|
|
93
|
-
},
|
|
94
|
-
teamToUser: {
|
|
95
|
-
teamId: "d91f42a6-8cbb-4e63-9b5c-8d1b4f2a7e77",
|
|
96
|
-
userId: "c7a2c1c8-9f4c-4f89-9d72-6b5a2f0c1e01",
|
|
97
|
-
role: "member",
|
|
98
|
-
},
|
|
99
|
-
teams: {
|
|
100
|
-
id: "d91f42a6-8cbb-4e63-9b5c-8d1b4f2a7e77",
|
|
101
|
-
name: "Blue Sharks",
|
|
102
|
-
},
|
|
103
|
-
posts: {
|
|
104
|
-
id: "f13d8f22-0b61-4d6a-8b1e-5b6b3d0c8a21",
|
|
105
|
-
userId: "c7a2c1c8-9f4c-4f89-9d72-6b5a2f0c1e01",
|
|
106
|
-
title: "First post",
|
|
107
|
-
published: true,
|
|
108
|
-
},
|
|
109
|
-
comments: {
|
|
110
|
-
id: "9d1a7c3b-2f6a-4f7c-bf4b-8f6e3c5d9e01",
|
|
111
|
-
postId: "f13d8f22-0b61-4d6a-8b1e-5b6b3d0c8a21",
|
|
112
|
-
body: "Nice post!",
|
|
113
|
-
authorEmail: "bob@example.com",
|
|
114
|
-
},
|
|
115
|
-
},
|
|
116
|
-
{
|
|
117
|
-
users: {
|
|
118
|
-
id: "f44a8c17-3c6d-4e38-9f61-0a9f2b1c8d55",
|
|
119
|
-
clerkId: "user_xyz789",
|
|
120
|
-
email: "dave@example.com",
|
|
121
|
-
createdAt: "2025-02-03T14:18:10.000Z",
|
|
122
|
-
},
|
|
123
|
-
teamToUser: {
|
|
124
|
-
teamId: "d91f42a6-8cbb-4e63-9b5c-8d1b4f2a7e77",
|
|
125
|
-
userId: "f44a8c17-3c6d-4e38-9f61-0a9f2b1c8d55",
|
|
126
|
-
role: "admin",
|
|
127
|
-
},
|
|
128
|
-
teams: {
|
|
129
|
-
id: "d91f42a6-8cbb-4e63-9b5c-8d1b4f2a7e77",
|
|
130
|
-
name: "Blue Sharks",
|
|
131
|
-
},
|
|
132
|
-
posts: null,
|
|
133
|
-
comments: null,
|
|
134
|
-
},
|
|
135
|
-
];
|
|
136
|
-
|
|
137
|
-
export const testSchema
|
|
138
|
-
base: "users",
|
|
139
|
-
id: "id",
|
|
140
|
-
|
|
141
|
-
_teamToUsers: {
|
|
142
|
-
base: "teamToUser",
|
|
143
|
-
id: "teamId",
|
|
144
|
-
joinsFrom: "id",
|
|
145
|
-
joinsTo: "userId",
|
|
146
|
-
joinType: "array",
|
|
147
|
-
|
|
148
|
-
_team: {
|
|
149
|
-
base: "teams",
|
|
150
|
-
id: "id",
|
|
151
|
-
joinsFrom: "teamId",
|
|
152
|
-
joinsTo: "id",
|
|
153
|
-
joinType: "single",
|
|
154
|
-
},
|
|
155
|
-
},
|
|
156
|
-
|
|
157
|
-
_posts: {
|
|
158
|
-
base: "posts",
|
|
159
|
-
id: "id",
|
|
160
|
-
joinsFrom: "id",
|
|
161
|
-
joinsTo: "userId",
|
|
162
|
-
joinType: "array",
|
|
163
|
-
|
|
164
|
-
_comments: {
|
|
165
|
-
base: "comments",
|
|
166
|
-
id: "id",
|
|
167
|
-
joinsFrom: "id",
|
|
168
|
-
joinsTo: "postId",
|
|
169
|
-
joinType: "array",
|
|
170
|
-
},
|
|
171
|
-
},
|
|
172
|
-
}
|
|
1
|
+
import type { RelationMapRoot } from "~/types/inputs";
|
|
2
|
+
import type { Simplify } from "~/types/utils";
|
|
3
|
+
|
|
4
|
+
export const testData = [
|
|
5
|
+
{
|
|
6
|
+
users: {
|
|
7
|
+
id: "c7a2c1c8-9f4c-4f89-9d72-6b5a2f0c1e01",
|
|
8
|
+
clerkId: "user_abc123",
|
|
9
|
+
email: "alice@example.com",
|
|
10
|
+
createdAt: "2025-01-12T09:41:22.000Z",
|
|
11
|
+
},
|
|
12
|
+
teamToUser: {
|
|
13
|
+
teamId: "a2e5a3de-6d14-4e9b-9c9f-3cbb2cdb8a10",
|
|
14
|
+
userId: "c7a2c1c8-9f4c-4f89-9d72-6b5a2f0c1e01",
|
|
15
|
+
role: "admin",
|
|
16
|
+
},
|
|
17
|
+
teams: {
|
|
18
|
+
id: "a2e5a3de-6d14-4e9b-9c9f-3cbb2cdb8a10",
|
|
19
|
+
name: "Red Dragons",
|
|
20
|
+
},
|
|
21
|
+
posts: {
|
|
22
|
+
id: "f13d8f22-0b61-4d6a-8b1e-5b6b3d0c8a21",
|
|
23
|
+
userId: "c7a2c1c8-9f4c-4f89-9d72-6b5a2f0c1e01",
|
|
24
|
+
title: "First post",
|
|
25
|
+
published: true,
|
|
26
|
+
},
|
|
27
|
+
comments: {
|
|
28
|
+
id: "9d1a7c3b-2f6a-4f7c-bf4b-8f6e3c5d9e01",
|
|
29
|
+
postId: "f13d8f22-0b61-4d6a-8b1e-5b6b3d0c8a21",
|
|
30
|
+
body: "Nice post!",
|
|
31
|
+
authorEmail: "bob@example.com",
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
users: {
|
|
36
|
+
id: "c7a2c1c8-9f4c-4f89-9d72-6b5a2f0c1e01",
|
|
37
|
+
clerkId: "user_abc123",
|
|
38
|
+
email: "alice@example.com",
|
|
39
|
+
createdAt: "2025-01-12T09:41:22.000Z",
|
|
40
|
+
},
|
|
41
|
+
teamToUser: {
|
|
42
|
+
teamId: "a2e5a3de-6d14-4e9b-9c9f-3cbb2cdb8a10",
|
|
43
|
+
userId: "c7a2c1c8-9f4c-4f89-9d72-6b5a2f0c1e01",
|
|
44
|
+
role: "admin",
|
|
45
|
+
},
|
|
46
|
+
teams: {
|
|
47
|
+
id: "a2e5a3de-6d14-4e9b-9c9f-3cbb2cdb8a10",
|
|
48
|
+
name: "Red Dragons",
|
|
49
|
+
},
|
|
50
|
+
posts: {
|
|
51
|
+
id: "f13d8f22-0b61-4d6a-8b1e-5b6b3d0c8a21",
|
|
52
|
+
userId: "c7a2c1c8-9f4c-4f89-9d72-6b5a2f0c1e01",
|
|
53
|
+
title: "First post",
|
|
54
|
+
published: true,
|
|
55
|
+
},
|
|
56
|
+
comments: {
|
|
57
|
+
id: "e3c9b5a2-7f42-4b7e-9e3d-4a6f1d8b2c44",
|
|
58
|
+
postId: "f13d8f22-0b61-4d6a-8b1e-5b6b3d0c8a21",
|
|
59
|
+
body: "Thanks for sharing",
|
|
60
|
+
authorEmail: "charlie@example.com",
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
users: {
|
|
65
|
+
id: "c7a2c1c8-9f4c-4f89-9d72-6b5a2f0c1e01",
|
|
66
|
+
clerkId: "user_abc123",
|
|
67
|
+
email: "alice@example.com",
|
|
68
|
+
createdAt: "2025-01-12T09:41:22.000Z",
|
|
69
|
+
},
|
|
70
|
+
teamToUser: {
|
|
71
|
+
teamId: "a2e5a3de-6d14-4e9b-9c9f-3cbb2cdb8a10",
|
|
72
|
+
userId: "c7a2c1c8-9f4c-4f89-9d72-6b5a2f0c1e01",
|
|
73
|
+
role: "admin",
|
|
74
|
+
},
|
|
75
|
+
teams: {
|
|
76
|
+
id: "a2e5a3de-6d14-4e9b-9c9f-3cbb2cdb8a10",
|
|
77
|
+
name: "Red Dragons",
|
|
78
|
+
},
|
|
79
|
+
posts: {
|
|
80
|
+
id: "6bcb2b74-9b2f-4b38-bdb5-77c2e63d9c10",
|
|
81
|
+
userId: "c7a2c1c8-9f4c-4f89-9d72-6b5a2f0c1e01",
|
|
82
|
+
title: "Second post",
|
|
83
|
+
published: false,
|
|
84
|
+
},
|
|
85
|
+
comments: null,
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
users: {
|
|
89
|
+
id: "c7a2c1c8-9f4c-4f89-9d72-6b5a2f0c1e01",
|
|
90
|
+
clerkId: "user_abc123",
|
|
91
|
+
email: "alice@example.com",
|
|
92
|
+
createdAt: "2025-01-12T09:41:22.000Z",
|
|
93
|
+
},
|
|
94
|
+
teamToUser: {
|
|
95
|
+
teamId: "d91f42a6-8cbb-4e63-9b5c-8d1b4f2a7e77",
|
|
96
|
+
userId: "c7a2c1c8-9f4c-4f89-9d72-6b5a2f0c1e01",
|
|
97
|
+
role: "member",
|
|
98
|
+
},
|
|
99
|
+
teams: {
|
|
100
|
+
id: "d91f42a6-8cbb-4e63-9b5c-8d1b4f2a7e77",
|
|
101
|
+
name: "Blue Sharks",
|
|
102
|
+
},
|
|
103
|
+
posts: {
|
|
104
|
+
id: "f13d8f22-0b61-4d6a-8b1e-5b6b3d0c8a21",
|
|
105
|
+
userId: "c7a2c1c8-9f4c-4f89-9d72-6b5a2f0c1e01",
|
|
106
|
+
title: "First post",
|
|
107
|
+
published: true,
|
|
108
|
+
},
|
|
109
|
+
comments: {
|
|
110
|
+
id: "9d1a7c3b-2f6a-4f7c-bf4b-8f6e3c5d9e01",
|
|
111
|
+
postId: "f13d8f22-0b61-4d6a-8b1e-5b6b3d0c8a21",
|
|
112
|
+
body: "Nice post!",
|
|
113
|
+
authorEmail: "bob@example.com",
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
users: {
|
|
118
|
+
id: "f44a8c17-3c6d-4e38-9f61-0a9f2b1c8d55",
|
|
119
|
+
clerkId: "user_xyz789",
|
|
120
|
+
email: "dave@example.com",
|
|
121
|
+
createdAt: "2025-02-03T14:18:10.000Z",
|
|
122
|
+
},
|
|
123
|
+
teamToUser: {
|
|
124
|
+
teamId: "d91f42a6-8cbb-4e63-9b5c-8d1b4f2a7e77",
|
|
125
|
+
userId: "f44a8c17-3c6d-4e38-9f61-0a9f2b1c8d55",
|
|
126
|
+
role: "admin",
|
|
127
|
+
},
|
|
128
|
+
teams: {
|
|
129
|
+
id: "d91f42a6-8cbb-4e63-9b5c-8d1b4f2a7e77",
|
|
130
|
+
name: "Blue Sharks",
|
|
131
|
+
},
|
|
132
|
+
posts: null,
|
|
133
|
+
comments: null,
|
|
134
|
+
},
|
|
135
|
+
];
|
|
136
|
+
|
|
137
|
+
export const testSchema = {
|
|
138
|
+
base: "users",
|
|
139
|
+
id: "id",
|
|
140
|
+
|
|
141
|
+
_teamToUsers: {
|
|
142
|
+
base: "teamToUser",
|
|
143
|
+
id: "teamId",
|
|
144
|
+
joinsFrom: "id",
|
|
145
|
+
joinsTo: "userId",
|
|
146
|
+
joinType: "array",
|
|
147
|
+
|
|
148
|
+
_team: {
|
|
149
|
+
base: "teams",
|
|
150
|
+
id: "id",
|
|
151
|
+
joinsFrom: "teamId",
|
|
152
|
+
joinsTo: "id",
|
|
153
|
+
joinType: "single",
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
|
|
157
|
+
_posts: {
|
|
158
|
+
base: "posts",
|
|
159
|
+
id: "id",
|
|
160
|
+
joinsFrom: "id",
|
|
161
|
+
joinsTo: "userId",
|
|
162
|
+
joinType: "array",
|
|
163
|
+
|
|
164
|
+
_comments: {
|
|
165
|
+
base: "comments",
|
|
166
|
+
id: "id",
|
|
167
|
+
joinsFrom: "id",
|
|
168
|
+
joinsTo: "postId",
|
|
169
|
+
joinType: "array",
|
|
170
|
+
},
|
|
171
|
+
},
|
|
172
|
+
} satisfies RelationMapRoot<(typeof testData)[number]>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { RelationMapBase, RelationMapJoiner } from "./inputs";
|
|
2
|
-
|
|
3
|
-
export type TInputBase = Record<string, Record<string, unknown> | null>;
|
|
4
|
-
export type TJoinedFromBase = TInputBase[keyof TInputBase];
|
|
5
|
-
export type TOutputBase<
|
|
6
|
-
TInput extends TInputBase,
|
|
7
|
-
TJoinedFrom extends TJoinedFromBase,
|
|
8
|
-
> = RelationMapBase<TInput, TJoinedFrom> &
|
|
9
|
-
RelationMapJoiner<TInput, TJoinedFrom>;
|
|
1
|
+
import type { RelationMapBase, RelationMapJoiner } from "./inputs";
|
|
2
|
+
|
|
3
|
+
export type TInputBase = Record<string, Record<string, unknown> | null>;
|
|
4
|
+
export type TJoinedFromBase = TInputBase[keyof TInputBase];
|
|
5
|
+
export type TOutputBase<
|
|
6
|
+
TInput extends TInputBase,
|
|
7
|
+
TJoinedFrom extends TJoinedFromBase,
|
|
8
|
+
> = RelationMapBase<TInput, TJoinedFrom> &
|
|
9
|
+
RelationMapJoiner<TInput, TJoinedFrom>;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import type { TInputBase } from "./generic-bases";
|
|
2
|
-
|
|
3
|
-
export type Output<TJoinType extends "single" | "array" = "single" | "array"> =
|
|
4
|
-
OutputJoins & {
|
|
5
|
-
base: keyof TInputBase;
|
|
6
|
-
id: string;
|
|
7
|
-
joinsTo: string;
|
|
8
|
-
joinsFrom: string;
|
|
9
|
-
joinType: TJoinType;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export type OutputJoins = {
|
|
13
|
-
[k: `_${string}`]: Output;
|
|
14
|
-
};
|
|
1
|
+
import type { TInputBase } from "./generic-bases";
|
|
2
|
+
|
|
3
|
+
export type Output<TJoinType extends "single" | "array" = "single" | "array"> =
|
|
4
|
+
OutputJoins & {
|
|
5
|
+
base: keyof TInputBase;
|
|
6
|
+
id: string;
|
|
7
|
+
joinsTo: string;
|
|
8
|
+
joinsFrom: string;
|
|
9
|
+
joinType: TJoinType;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export type OutputJoins = {
|
|
13
|
+
[k: `_${string}`]: Output;
|
|
14
|
+
};
|
package/src/types/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export type * from "./generic-bases";
|
|
2
|
-
export type * from "./generic-less";
|
|
3
|
-
export type * from "./return";
|
|
4
|
-
export type * from "./typetest";
|
|
5
|
-
export type * from "./utils";
|
|
1
|
+
export type * from "./generic-bases";
|
|
2
|
+
export type * from "./generic-less";
|
|
3
|
+
export type * from "./return";
|
|
4
|
+
export type * from "./typetest";
|
|
5
|
+
export type * from "./utils";
|
package/src/types/inputs.ts
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import type { TInputBase, TJoinedFromBase } from "./generic-bases";
|
|
2
|
-
|
|
3
|
-
export type RelationMapRoot<TInput extends TInputBase> = {
|
|
4
|
-
[k in keyof TInput]: {
|
|
5
|
-
base: k;
|
|
6
|
-
id: keyof NonNullable<TInput[k]>;
|
|
7
|
-
} & RelationMapJoiner<TInput, NonNullable<TInput[k]>>;
|
|
8
|
-
}[keyof TInput];
|
|
9
|
-
|
|
10
|
-
export type RelationMapBase<
|
|
11
|
-
TInput extends TInputBase,
|
|
12
|
-
TJoinedFrom extends TJoinedFromBase,
|
|
13
|
-
> = {
|
|
14
|
-
[k in keyof TInput]: {
|
|
15
|
-
base: k;
|
|
16
|
-
/** The id that uniqueness is checked against. Either the primary key of the table, or the id you are joining **to** on a join table. */
|
|
17
|
-
id: keyof NonNullable<TInput[k]>;
|
|
18
|
-
joinsTo: keyof NonNullable<TInput[k]>;
|
|
19
|
-
joinsFrom: keyof NonNullable<TJoinedFrom>;
|
|
20
|
-
joinType: "single" | "array";
|
|
21
|
-
} & RelationMapJoiner<TInput, TInput[k]>;
|
|
22
|
-
}[keyof TInput];
|
|
23
|
-
|
|
24
|
-
export type RelationMapJoiner<
|
|
25
|
-
TInput extends TInputBase,
|
|
26
|
-
TJoinedFrom extends TJoinedFromBase,
|
|
27
|
-
> = {
|
|
28
|
-
[k: `_${string}`]: RelationMapBase<TInput, TJoinedFrom> &
|
|
29
|
-
RelationMapJoiner<TInput, TJoinedFrom>;
|
|
30
|
-
};
|
|
1
|
+
import type { TInputBase, TJoinedFromBase } from "./generic-bases";
|
|
2
|
+
|
|
3
|
+
export type RelationMapRoot<TInput extends TInputBase> = {
|
|
4
|
+
[k in keyof TInput]: {
|
|
5
|
+
base: k;
|
|
6
|
+
id: keyof NonNullable<TInput[k]>;
|
|
7
|
+
} & RelationMapJoiner<TInput, NonNullable<TInput[k]>>;
|
|
8
|
+
}[keyof TInput];
|
|
9
|
+
|
|
10
|
+
export type RelationMapBase<
|
|
11
|
+
TInput extends TInputBase,
|
|
12
|
+
TJoinedFrom extends TJoinedFromBase,
|
|
13
|
+
> = {
|
|
14
|
+
[k in keyof TInput]: {
|
|
15
|
+
base: k;
|
|
16
|
+
/** The id that uniqueness is checked against. Either the primary key of the table, or the id you are joining **to** on a join table. */
|
|
17
|
+
id: keyof NonNullable<TInput[k]>;
|
|
18
|
+
joinsTo: keyof NonNullable<TInput[k]>;
|
|
19
|
+
joinsFrom: keyof NonNullable<TJoinedFrom>;
|
|
20
|
+
joinType: "single" | "array";
|
|
21
|
+
} & RelationMapJoiner<TInput, TInput[k]>;
|
|
22
|
+
}[keyof TInput];
|
|
23
|
+
|
|
24
|
+
export type RelationMapJoiner<
|
|
25
|
+
TInput extends TInputBase,
|
|
26
|
+
TJoinedFrom extends TJoinedFromBase,
|
|
27
|
+
> = {
|
|
28
|
+
[k: `_${string}`]: RelationMapBase<TInput, TJoinedFrom> &
|
|
29
|
+
RelationMapJoiner<TInput, TJoinedFrom>;
|
|
30
|
+
};
|