@webstudio-is/trpc-interface 0.55.0 → 0.57.0
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/lib/authorize/project.server.js +71 -59
- package/lib/cjs/authorize/project.server.js +71 -59
- package/package.json +6 -6
- package/src/authorize/project.server.ts +90 -72
- package/lib/types/authorize/authorization-token.server.d.ts +0 -21
- package/lib/types/authorize/project.server.d.ts +0 -25
- package/lib/types/context/context.server.d.ts +0 -28
- package/lib/types/index.d.ts +0 -1
- package/lib/types/index.server.d.ts +0 -6
- package/lib/types/shared/authorization-router.d.ts +0 -276
- package/lib/types/shared/client.d.ts +0 -8
- package/lib/types/shared/shared-router.d.ts +0 -265
- package/lib/types/shared/trpc.d.ts +0 -48
- package/lib/types/trpc-caller-link.d.ts +0 -16
- package/lib/types/trpc-caller-link.test.d.ts +0 -49
|
@@ -15,70 +15,82 @@ const registerProjectOwner = async (props, context) => {
|
|
|
15
15
|
});
|
|
16
16
|
};
|
|
17
17
|
const hasProjectPermit = async (props, context) => {
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return true;
|
|
27
|
-
}
|
|
28
|
-
if (authorization.userId !== void 0) {
|
|
29
|
-
checks.push(
|
|
30
|
-
authorizeTrpc.check.query({
|
|
31
|
-
subjectSet: {
|
|
32
|
-
namespace: "User",
|
|
33
|
-
id: authorization.userId
|
|
34
|
-
},
|
|
35
|
-
namespace,
|
|
36
|
-
id: props.projectId,
|
|
37
|
-
permit: props.permit
|
|
38
|
-
})
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
if (authorization.authToken !== void 0 && props.permit !== "own") {
|
|
42
|
-
checks.push(
|
|
43
|
-
authorizeTrpc.check.query({
|
|
44
|
-
namespace,
|
|
45
|
-
id: props.projectId,
|
|
46
|
-
subjectSet: {
|
|
47
|
-
id: authorization.authToken,
|
|
48
|
-
namespace: "Token"
|
|
49
|
-
},
|
|
50
|
-
permit: props.permit
|
|
51
|
-
})
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
if (checks.length === 0) {
|
|
55
|
-
return false;
|
|
56
|
-
}
|
|
57
|
-
const authResults = await Promise.allSettled(checks);
|
|
58
|
-
for (const authResult of authResults) {
|
|
59
|
-
if (authResult.status === "rejected") {
|
|
60
|
-
throw new Error(`Authorization call failed ${authResult.reason}`);
|
|
18
|
+
const start = Date.now();
|
|
19
|
+
try {
|
|
20
|
+
const { authorization } = context;
|
|
21
|
+
const { authorizeTrpc } = authorization;
|
|
22
|
+
const checks = [];
|
|
23
|
+
const namespace = "Project";
|
|
24
|
+
if (props.permit === "view" && context.authorization.buildEnv === "prod") {
|
|
25
|
+
return true;
|
|
61
26
|
}
|
|
27
|
+
if (props.permit === "view" && props.projectId === "62154aaef0cb0860ccf85d6e") {
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
if (authorization.userId !== void 0) {
|
|
31
|
+
checks.push(
|
|
32
|
+
authorizeTrpc.check.query({
|
|
33
|
+
subjectSet: {
|
|
34
|
+
namespace: "User",
|
|
35
|
+
id: authorization.userId
|
|
36
|
+
},
|
|
37
|
+
namespace,
|
|
38
|
+
id: props.projectId,
|
|
39
|
+
permit: props.permit
|
|
40
|
+
})
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
if (authorization.authToken !== void 0 && props.permit !== "own") {
|
|
44
|
+
checks.push(
|
|
45
|
+
authorizeTrpc.check.query({
|
|
46
|
+
namespace,
|
|
47
|
+
id: props.projectId,
|
|
48
|
+
subjectSet: {
|
|
49
|
+
id: authorization.authToken,
|
|
50
|
+
namespace: "Token"
|
|
51
|
+
},
|
|
52
|
+
permit: props.permit
|
|
53
|
+
})
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
if (checks.length === 0) {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
const authResults = await Promise.allSettled(checks);
|
|
60
|
+
for (const authResult of authResults) {
|
|
61
|
+
if (authResult.status === "rejected") {
|
|
62
|
+
throw new Error(`Authorization call failed ${authResult.reason}`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
const allowed = authResults.some(
|
|
66
|
+
(authResult) => authResult.status === "fulfilled" && authResult.value.allowed
|
|
67
|
+
);
|
|
68
|
+
return allowed;
|
|
69
|
+
} finally {
|
|
70
|
+
const diff = Date.now() - start;
|
|
71
|
+
console.log(`hasProjectPermit execution ${diff}ms`);
|
|
62
72
|
}
|
|
63
|
-
const allowed = authResults.some(
|
|
64
|
-
(authResult) => authResult.status === "fulfilled" && authResult.value.allowed
|
|
65
|
-
);
|
|
66
|
-
return allowed;
|
|
67
73
|
};
|
|
68
74
|
const getProjectPermit = async (props, context) => {
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
permitToCheck.
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
75
|
+
const start = Date.now();
|
|
76
|
+
try {
|
|
77
|
+
const permitToCheck = props.permits;
|
|
78
|
+
const permits = await Promise.allSettled(
|
|
79
|
+
permitToCheck.map(
|
|
80
|
+
(permit) => hasProjectPermit({ projectId: props.projectId, permit }, context)
|
|
81
|
+
)
|
|
82
|
+
);
|
|
83
|
+
for (const permit of permits) {
|
|
84
|
+
if (permit.status === "rejected") {
|
|
85
|
+
throw new Error(`Authorization call failed ${permit.reason}`);
|
|
86
|
+
}
|
|
87
|
+
if (permit.value === true) {
|
|
88
|
+
return permitToCheck[permits.indexOf(permit)];
|
|
89
|
+
}
|
|
81
90
|
}
|
|
91
|
+
} finally {
|
|
92
|
+
const diff = Date.now() - start;
|
|
93
|
+
console.log(`getProjectPermit execution ${diff}ms`);
|
|
82
94
|
}
|
|
83
95
|
};
|
|
84
96
|
export {
|
|
@@ -40,69 +40,81 @@ const registerProjectOwner = async (props, context) => {
|
|
|
40
40
|
});
|
|
41
41
|
};
|
|
42
42
|
const hasProjectPermit = async (props, context) => {
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
return true;
|
|
52
|
-
}
|
|
53
|
-
if (authorization.userId !== void 0) {
|
|
54
|
-
checks.push(
|
|
55
|
-
authorizeTrpc.check.query({
|
|
56
|
-
subjectSet: {
|
|
57
|
-
namespace: "User",
|
|
58
|
-
id: authorization.userId
|
|
59
|
-
},
|
|
60
|
-
namespace,
|
|
61
|
-
id: props.projectId,
|
|
62
|
-
permit: props.permit
|
|
63
|
-
})
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
if (authorization.authToken !== void 0 && props.permit !== "own") {
|
|
67
|
-
checks.push(
|
|
68
|
-
authorizeTrpc.check.query({
|
|
69
|
-
namespace,
|
|
70
|
-
id: props.projectId,
|
|
71
|
-
subjectSet: {
|
|
72
|
-
id: authorization.authToken,
|
|
73
|
-
namespace: "Token"
|
|
74
|
-
},
|
|
75
|
-
permit: props.permit
|
|
76
|
-
})
|
|
77
|
-
);
|
|
78
|
-
}
|
|
79
|
-
if (checks.length === 0) {
|
|
80
|
-
return false;
|
|
81
|
-
}
|
|
82
|
-
const authResults = await Promise.allSettled(checks);
|
|
83
|
-
for (const authResult of authResults) {
|
|
84
|
-
if (authResult.status === "rejected") {
|
|
85
|
-
throw new Error(`Authorization call failed ${authResult.reason}`);
|
|
43
|
+
const start = Date.now();
|
|
44
|
+
try {
|
|
45
|
+
const { authorization } = context;
|
|
46
|
+
const { authorizeTrpc } = authorization;
|
|
47
|
+
const checks = [];
|
|
48
|
+
const namespace = "Project";
|
|
49
|
+
if (props.permit === "view" && context.authorization.buildEnv === "prod") {
|
|
50
|
+
return true;
|
|
86
51
|
}
|
|
52
|
+
if (props.permit === "view" && props.projectId === "62154aaef0cb0860ccf85d6e") {
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
if (authorization.userId !== void 0) {
|
|
56
|
+
checks.push(
|
|
57
|
+
authorizeTrpc.check.query({
|
|
58
|
+
subjectSet: {
|
|
59
|
+
namespace: "User",
|
|
60
|
+
id: authorization.userId
|
|
61
|
+
},
|
|
62
|
+
namespace,
|
|
63
|
+
id: props.projectId,
|
|
64
|
+
permit: props.permit
|
|
65
|
+
})
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
if (authorization.authToken !== void 0 && props.permit !== "own") {
|
|
69
|
+
checks.push(
|
|
70
|
+
authorizeTrpc.check.query({
|
|
71
|
+
namespace,
|
|
72
|
+
id: props.projectId,
|
|
73
|
+
subjectSet: {
|
|
74
|
+
id: authorization.authToken,
|
|
75
|
+
namespace: "Token"
|
|
76
|
+
},
|
|
77
|
+
permit: props.permit
|
|
78
|
+
})
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
if (checks.length === 0) {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
const authResults = await Promise.allSettled(checks);
|
|
85
|
+
for (const authResult of authResults) {
|
|
86
|
+
if (authResult.status === "rejected") {
|
|
87
|
+
throw new Error(`Authorization call failed ${authResult.reason}`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
const allowed = authResults.some(
|
|
91
|
+
(authResult) => authResult.status === "fulfilled" && authResult.value.allowed
|
|
92
|
+
);
|
|
93
|
+
return allowed;
|
|
94
|
+
} finally {
|
|
95
|
+
const diff = Date.now() - start;
|
|
96
|
+
console.log(`hasProjectPermit execution ${diff}ms`);
|
|
87
97
|
}
|
|
88
|
-
const allowed = authResults.some(
|
|
89
|
-
(authResult) => authResult.status === "fulfilled" && authResult.value.allowed
|
|
90
|
-
);
|
|
91
|
-
return allowed;
|
|
92
98
|
};
|
|
93
99
|
const getProjectPermit = async (props, context) => {
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
permitToCheck.
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
100
|
+
const start = Date.now();
|
|
101
|
+
try {
|
|
102
|
+
const permitToCheck = props.permits;
|
|
103
|
+
const permits = await Promise.allSettled(
|
|
104
|
+
permitToCheck.map(
|
|
105
|
+
(permit) => hasProjectPermit({ projectId: props.projectId, permit }, context)
|
|
106
|
+
)
|
|
107
|
+
);
|
|
108
|
+
for (const permit of permits) {
|
|
109
|
+
if (permit.status === "rejected") {
|
|
110
|
+
throw new Error(`Authorization call failed ${permit.reason}`);
|
|
111
|
+
}
|
|
112
|
+
if (permit.value === true) {
|
|
113
|
+
return permitToCheck[permits.indexOf(permit)];
|
|
114
|
+
}
|
|
106
115
|
}
|
|
116
|
+
} finally {
|
|
117
|
+
const diff = Date.now() - start;
|
|
118
|
+
console.log(`getProjectPermit execution ${diff}ms`);
|
|
107
119
|
}
|
|
108
120
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webstudio-is/trpc-interface",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.57.0",
|
|
4
4
|
"description": "Webstudio TRPC Interface",
|
|
5
5
|
"author": "Webstudio <github@webstudio.is>",
|
|
6
6
|
"homepage": "https://webstudio.is",
|
|
@@ -10,14 +10,14 @@
|
|
|
10
10
|
"@trpc/server": "^10.9.0",
|
|
11
11
|
"uuid": "^9.0.0",
|
|
12
12
|
"zod": "^3.19.1",
|
|
13
|
-
"@webstudio-is/prisma-client": "^0.
|
|
13
|
+
"@webstudio-is/prisma-client": "^0.57.0"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"@types/node": "^18.11.18",
|
|
17
17
|
"typescript": "5.0.3",
|
|
18
|
-
"@webstudio-is/jest-config": "^1.0.
|
|
18
|
+
"@webstudio-is/jest-config": "^1.0.4",
|
|
19
19
|
"@webstudio-is/scripts": "^0.0.0",
|
|
20
|
-
"@webstudio-is/tsconfig": "^1.0.
|
|
20
|
+
"@webstudio-is/tsconfig": "^1.0.4"
|
|
21
21
|
},
|
|
22
22
|
"exports": {
|
|
23
23
|
"./server": {
|
|
@@ -34,12 +34,12 @@
|
|
|
34
34
|
"private": false,
|
|
35
35
|
"sideEffects": false,
|
|
36
36
|
"scripts": {
|
|
37
|
-
"typecheck": "tsc --noEmit",
|
|
37
|
+
"typecheck": "tsc --noEmit --emitDeclarationOnly false",
|
|
38
38
|
"test": "NODE_OPTIONS=--experimental-vm-modules jest",
|
|
39
39
|
"checks": "pnpm typecheck && pnpm lint",
|
|
40
40
|
"dev": "build-package --watch",
|
|
41
41
|
"build": "build-package",
|
|
42
|
-
"dts": "tsc
|
|
42
|
+
"dts": "tsc",
|
|
43
43
|
"lint": "eslint ./src --ext .ts,.tsx --max-warnings 0"
|
|
44
44
|
}
|
|
45
45
|
}
|
|
@@ -37,77 +37,86 @@ export const hasProjectPermit = async (
|
|
|
37
37
|
},
|
|
38
38
|
context: AppContext
|
|
39
39
|
) => {
|
|
40
|
-
const
|
|
41
|
-
const { authorizeTrpc } = authorization;
|
|
40
|
+
const start = Date.now();
|
|
42
41
|
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
try {
|
|
43
|
+
const { authorization } = context;
|
|
44
|
+
const { authorizeTrpc } = authorization;
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
return true;
|
|
49
|
-
}
|
|
46
|
+
const checks = [];
|
|
47
|
+
const namespace = "Project";
|
|
50
48
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
if (
|
|
56
|
-
props.permit === "view" &&
|
|
57
|
-
props.projectId === "62154aaef0cb0860ccf85d6e"
|
|
58
|
-
) {
|
|
59
|
-
return true;
|
|
60
|
-
}
|
|
49
|
+
// Allow load production build env i.e. "published" site
|
|
50
|
+
if (props.permit === "view" && context.authorization.buildEnv === "prod") {
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
61
53
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
permit: props.permit,
|
|
73
|
-
})
|
|
74
|
-
);
|
|
75
|
-
}
|
|
54
|
+
// Allow load webstudiois for clone
|
|
55
|
+
// @todo Rethink permissions for this use-case
|
|
56
|
+
// The plan is to make new permission for projects which are allowed to be publicly clonable by anyone
|
|
57
|
+
// https://github.com/webstudio-is/webstudio-builder/issues/1038
|
|
58
|
+
if (
|
|
59
|
+
props.permit === "view" &&
|
|
60
|
+
props.projectId === "62154aaef0cb0860ccf85d6e"
|
|
61
|
+
) {
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
76
64
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
65
|
+
// Check if the user is allowed to access the project
|
|
66
|
+
if (authorization.userId !== undefined) {
|
|
67
|
+
checks.push(
|
|
68
|
+
authorizeTrpc.check.query({
|
|
69
|
+
subjectSet: {
|
|
70
|
+
namespace: "User",
|
|
71
|
+
id: authorization.userId,
|
|
72
|
+
},
|
|
73
|
+
namespace,
|
|
74
|
+
id: props.projectId,
|
|
75
|
+
permit: props.permit,
|
|
76
|
+
})
|
|
77
|
+
);
|
|
78
|
+
}
|
|
92
79
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
80
|
+
// Check if the special link with a token allows to access the project
|
|
81
|
+
// Token doesn't have own permit, do not check it
|
|
82
|
+
if (authorization.authToken !== undefined && props.permit !== "own") {
|
|
83
|
+
checks.push(
|
|
84
|
+
authorizeTrpc.check.query({
|
|
85
|
+
namespace,
|
|
86
|
+
id: props.projectId,
|
|
87
|
+
subjectSet: {
|
|
88
|
+
id: authorization.authToken,
|
|
89
|
+
namespace: "Token",
|
|
90
|
+
},
|
|
91
|
+
permit: props.permit,
|
|
92
|
+
})
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (checks.length === 0) {
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
96
99
|
|
|
97
|
-
|
|
100
|
+
const authResults = await Promise.allSettled(checks);
|
|
98
101
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
+
for (const authResult of authResults) {
|
|
103
|
+
if (authResult.status === "rejected") {
|
|
104
|
+
throw new Error(`Authorization call failed ${authResult.reason}`);
|
|
105
|
+
}
|
|
102
106
|
}
|
|
103
|
-
}
|
|
104
107
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
108
|
+
const allowed = authResults.some(
|
|
109
|
+
(authResult) =>
|
|
110
|
+
authResult.status === "fulfilled" && authResult.value.allowed
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
return allowed;
|
|
114
|
+
} finally {
|
|
115
|
+
const diff = Date.now() - start;
|
|
109
116
|
|
|
110
|
-
|
|
117
|
+
// eslint-disable-next-line no-console
|
|
118
|
+
console.log(`hasProjectPermit execution ${diff}ms`);
|
|
119
|
+
}
|
|
111
120
|
};
|
|
112
121
|
|
|
113
122
|
/**
|
|
@@ -122,21 +131,30 @@ export const getProjectPermit = async <T extends AuthPermit>(
|
|
|
122
131
|
},
|
|
123
132
|
context: AppContext
|
|
124
133
|
): Promise<T | undefined> => {
|
|
125
|
-
const
|
|
134
|
+
const start = Date.now();
|
|
126
135
|
|
|
127
|
-
|
|
128
|
-
permitToCheck.
|
|
129
|
-
hasProjectPermit({ projectId: props.projectId, permit }, context)
|
|
130
|
-
)
|
|
131
|
-
);
|
|
136
|
+
try {
|
|
137
|
+
const permitToCheck = props.permits;
|
|
132
138
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
139
|
+
const permits = await Promise.allSettled(
|
|
140
|
+
permitToCheck.map((permit) =>
|
|
141
|
+
hasProjectPermit({ projectId: props.projectId, permit }, context)
|
|
142
|
+
)
|
|
143
|
+
);
|
|
137
144
|
|
|
138
|
-
|
|
139
|
-
|
|
145
|
+
for (const permit of permits) {
|
|
146
|
+
if (permit.status === "rejected") {
|
|
147
|
+
throw new Error(`Authorization call failed ${permit.reason}`);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (permit.value === true) {
|
|
151
|
+
return permitToCheck[permits.indexOf(permit)];
|
|
152
|
+
}
|
|
140
153
|
}
|
|
154
|
+
} finally {
|
|
155
|
+
const diff = Date.now() - start;
|
|
156
|
+
|
|
157
|
+
// eslint-disable-next-line no-console
|
|
158
|
+
console.log(`getProjectPermit execution ${diff}ms`);
|
|
141
159
|
}
|
|
142
160
|
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { AppContext } from "../context/context.server";
|
|
2
|
-
/**
|
|
3
|
-
* For 3rd party authorization systems like Ory we need to register token for the project.
|
|
4
|
-
*
|
|
5
|
-
* We do that before the authorizationToken create (and out of the transaction),
|
|
6
|
-
* so in case of an error we will have just stale records of non existed projects in authorization system.
|
|
7
|
-
*/
|
|
8
|
-
export declare const registerToken: (props: {
|
|
9
|
-
projectId: string;
|
|
10
|
-
tokenId: string;
|
|
11
|
-
relation: "viewers" | "editors" | "builders";
|
|
12
|
-
}, context: AppContext) => Promise<void>;
|
|
13
|
-
export declare const patchToken: (props: {
|
|
14
|
-
projectId: string;
|
|
15
|
-
tokenId: string;
|
|
16
|
-
}, prevRelation: "viewers" | "editors" | "builders", nextRelation: "viewers" | "editors" | "builders", context: AppContext) => Promise<void>;
|
|
17
|
-
export declare const unregisterToken: (props: {
|
|
18
|
-
projectId: string;
|
|
19
|
-
tokenId: string;
|
|
20
|
-
relation: "viewers" | "editors";
|
|
21
|
-
}, context: AppContext) => Promise<void>;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { Project } from "@webstudio-is/prisma-client";
|
|
2
|
-
import type { AuthPermit } from "../shared/authorization-router";
|
|
3
|
-
import type { AppContext } from "../context/context.server";
|
|
4
|
-
/**
|
|
5
|
-
* For 3rd party authorization systems like Ory we need to register the project owner.
|
|
6
|
-
*
|
|
7
|
-
* We do that before the project create (and out of the transaction),
|
|
8
|
-
* so in case of an error we will have just stale records of non existed projects in authorization system.
|
|
9
|
-
*/
|
|
10
|
-
export declare const registerProjectOwner: (props: {
|
|
11
|
-
projectId: string;
|
|
12
|
-
}, context: AppContext) => Promise<void>;
|
|
13
|
-
export declare const hasProjectPermit: (props: {
|
|
14
|
-
projectId: Project["id"];
|
|
15
|
-
permit: AuthPermit;
|
|
16
|
-
}, context: AppContext) => Promise<boolean>;
|
|
17
|
-
/**
|
|
18
|
-
* Returns the first allowed permit from the list or undefined if none is allowed
|
|
19
|
-
* @todo think about caching to authorizeTrpc.check.query
|
|
20
|
-
* batching check queries would help too https://github.com/ory/keto/issues/812
|
|
21
|
-
*/
|
|
22
|
-
export declare const getProjectPermit: <T extends "build" | "view" | "edit" | "own">(props: {
|
|
23
|
-
projectId: string;
|
|
24
|
-
permits: readonly T[];
|
|
25
|
-
}, context: AppContext) => Promise<T | undefined>;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { TrpcInterfaceClient } from "../shared/shared-router";
|
|
2
|
-
/**
|
|
3
|
-
* All necessary parameters for Authorization
|
|
4
|
-
*/
|
|
5
|
-
type AuthorizationContext = {
|
|
6
|
-
/**
|
|
7
|
-
* userId of the current authenticated user
|
|
8
|
-
*/
|
|
9
|
-
userId: string | undefined;
|
|
10
|
-
/**
|
|
11
|
-
* token URLSearchParams or hostname
|
|
12
|
-
*/
|
|
13
|
-
authToken: string | undefined;
|
|
14
|
-
/**
|
|
15
|
-
* buildEnv==="prod" only if we are loading project with production build
|
|
16
|
-
*/
|
|
17
|
-
buildEnv: "dev" | "prod";
|
|
18
|
-
authorizeTrpc: TrpcInterfaceClient["authorize"];
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* AppContext is a global context that is passed to all trpc/api queries/mutations
|
|
22
|
-
* "authorization" is made inside the namespace because eventually there will be
|
|
23
|
-
* logging parameters, potentially "request" cache, etc.
|
|
24
|
-
*/
|
|
25
|
-
export type AppContext = {
|
|
26
|
-
authorization: AuthorizationContext;
|
|
27
|
-
};
|
|
28
|
-
export {};
|
package/lib/types/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./index.server";
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export type { SharedRouter } from "./shared/shared-router";
|
|
2
|
-
export { createTrpcProxyServiceClient } from "./shared/client";
|
|
3
|
-
export type { AppContext } from "./context/context.server";
|
|
4
|
-
export * as authorizeProject from "./authorize/project.server";
|
|
5
|
-
export * as authorizeAuthorizationToken from "./authorize/authorization-token.server";
|
|
6
|
-
export type { AuthPermit } from "./shared/authorization-router";
|
|
@@ -1,276 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
declare const AuthPermit: z.ZodEnum<["view", "edit", "build", "own"]>;
|
|
3
|
-
export type AuthPermit = z.infer<typeof AuthPermit>;
|
|
4
|
-
export declare const authorizationRouter: import("@trpc/server").CreateRouterInner<import("@trpc/server").RootConfig<{
|
|
5
|
-
ctx: {};
|
|
6
|
-
meta: object;
|
|
7
|
-
errorShape: import("@trpc/server").DefaultErrorShape;
|
|
8
|
-
transformer: import("@trpc/server").DefaultDataTransformer;
|
|
9
|
-
}>, {
|
|
10
|
-
/**
|
|
11
|
-
* Relation expansion in authorize looks like a tree
|
|
12
|
-
*
|
|
13
|
-
* :#@Project:AliceProjectUUID#viewers
|
|
14
|
-
* :#@Email:bob@bob.com#owner
|
|
15
|
-
* :#@User:BobUUID️
|
|
16
|
-
* :#@Token:LinkRandomSequence️
|
|
17
|
-
*
|
|
18
|
-
* We don't need the whole tree in UI and need only the leaf nodes.
|
|
19
|
-
* i.e. @User:BobUUID️, @Token:LinkRandomSequence️ and the root relation i.e "viewers"
|
|
20
|
-
*/
|
|
21
|
-
expandLeafNodes: import("@trpc/server").BuildProcedure<"query", {
|
|
22
|
-
_config: import("@trpc/server").RootConfig<{
|
|
23
|
-
ctx: {};
|
|
24
|
-
meta: object;
|
|
25
|
-
errorShape: import("@trpc/server").DefaultErrorShape;
|
|
26
|
-
transformer: import("@trpc/server").DefaultDataTransformer;
|
|
27
|
-
}>;
|
|
28
|
-
_meta: object;
|
|
29
|
-
_ctx_out: {};
|
|
30
|
-
_input_in: {
|
|
31
|
-
id: string;
|
|
32
|
-
namespace: "Project";
|
|
33
|
-
};
|
|
34
|
-
_input_out: {
|
|
35
|
-
id: string;
|
|
36
|
-
namespace: "Project";
|
|
37
|
-
};
|
|
38
|
-
_output_in: {
|
|
39
|
-
id: string;
|
|
40
|
-
relation: "viewers" | "editors" | "builders" | "owners";
|
|
41
|
-
namespace: "User" | "Token" | "Email";
|
|
42
|
-
}[];
|
|
43
|
-
_output_out: {
|
|
44
|
-
id: string;
|
|
45
|
-
relation: "viewers" | "editors" | "builders" | "owners";
|
|
46
|
-
namespace: "User" | "Token" | "Email";
|
|
47
|
-
}[];
|
|
48
|
-
}, unknown>;
|
|
49
|
-
/**
|
|
50
|
-
* Check if subject has permit on the resource
|
|
51
|
-
*/
|
|
52
|
-
check: import("@trpc/server").BuildProcedure<"query", {
|
|
53
|
-
_config: import("@trpc/server").RootConfig<{
|
|
54
|
-
ctx: {};
|
|
55
|
-
meta: object;
|
|
56
|
-
errorShape: import("@trpc/server").DefaultErrorShape;
|
|
57
|
-
transformer: import("@trpc/server").DefaultDataTransformer;
|
|
58
|
-
}>;
|
|
59
|
-
_meta: object;
|
|
60
|
-
_ctx_out: {};
|
|
61
|
-
_input_in: {
|
|
62
|
-
id: string;
|
|
63
|
-
namespace: "Project";
|
|
64
|
-
subjectSet: {
|
|
65
|
-
id: string;
|
|
66
|
-
namespace: "User" | "Token";
|
|
67
|
-
};
|
|
68
|
-
permit: "build" | "view" | "edit" | "own";
|
|
69
|
-
};
|
|
70
|
-
_input_out: {
|
|
71
|
-
id: string;
|
|
72
|
-
namespace: "Project";
|
|
73
|
-
subjectSet: {
|
|
74
|
-
id: string;
|
|
75
|
-
namespace: "User" | "Token";
|
|
76
|
-
};
|
|
77
|
-
permit: "build" | "view" | "edit" | "own";
|
|
78
|
-
};
|
|
79
|
-
_output_in: {
|
|
80
|
-
allowed: boolean;
|
|
81
|
-
};
|
|
82
|
-
_output_out: {
|
|
83
|
-
allowed: boolean;
|
|
84
|
-
};
|
|
85
|
-
}, unknown>;
|
|
86
|
-
/**
|
|
87
|
-
* In OSS we extract owner relation from the Project table, and the rest from the authorizationToken table
|
|
88
|
-
*/
|
|
89
|
-
create: import("@trpc/server").BuildProcedure<"mutation", {
|
|
90
|
-
_config: import("@trpc/server").RootConfig<{
|
|
91
|
-
ctx: {};
|
|
92
|
-
meta: object;
|
|
93
|
-
errorShape: import("@trpc/server").DefaultErrorShape;
|
|
94
|
-
transformer: import("@trpc/server").DefaultDataTransformer;
|
|
95
|
-
}>;
|
|
96
|
-
_meta: object;
|
|
97
|
-
_ctx_out: {};
|
|
98
|
-
_input_in: {
|
|
99
|
-
id: string;
|
|
100
|
-
relation: "viewers" | "editors" | "builders" | "owners";
|
|
101
|
-
namespace: "Project";
|
|
102
|
-
subjectSet: {
|
|
103
|
-
id: string;
|
|
104
|
-
namespace: "User";
|
|
105
|
-
} | {
|
|
106
|
-
id: string;
|
|
107
|
-
namespace: "Token";
|
|
108
|
-
} | {
|
|
109
|
-
id: string;
|
|
110
|
-
relation: "owners";
|
|
111
|
-
namespace: "Email";
|
|
112
|
-
};
|
|
113
|
-
} | {
|
|
114
|
-
id: string;
|
|
115
|
-
relation: "owners";
|
|
116
|
-
namespace: "Email";
|
|
117
|
-
subjectSet: {
|
|
118
|
-
id: string;
|
|
119
|
-
namespace: "User";
|
|
120
|
-
};
|
|
121
|
-
};
|
|
122
|
-
_input_out: {
|
|
123
|
-
id: string;
|
|
124
|
-
relation: "viewers" | "editors" | "builders" | "owners";
|
|
125
|
-
namespace: "Project";
|
|
126
|
-
subjectSet: {
|
|
127
|
-
id: string;
|
|
128
|
-
namespace: "User";
|
|
129
|
-
} | {
|
|
130
|
-
id: string;
|
|
131
|
-
namespace: "Token";
|
|
132
|
-
} | {
|
|
133
|
-
id: string;
|
|
134
|
-
relation: "owners";
|
|
135
|
-
namespace: "Email";
|
|
136
|
-
};
|
|
137
|
-
} | {
|
|
138
|
-
id: string;
|
|
139
|
-
relation: "owners";
|
|
140
|
-
namespace: "Email";
|
|
141
|
-
subjectSet: {
|
|
142
|
-
id: string;
|
|
143
|
-
namespace: "User";
|
|
144
|
-
};
|
|
145
|
-
};
|
|
146
|
-
_output_in: typeof import("@trpc/server").unsetMarker;
|
|
147
|
-
_output_out: typeof import("@trpc/server").unsetMarker;
|
|
148
|
-
}, void>;
|
|
149
|
-
delete: import("@trpc/server").BuildProcedure<"mutation", {
|
|
150
|
-
_config: import("@trpc/server").RootConfig<{
|
|
151
|
-
ctx: {};
|
|
152
|
-
meta: object;
|
|
153
|
-
errorShape: import("@trpc/server").DefaultErrorShape;
|
|
154
|
-
transformer: import("@trpc/server").DefaultDataTransformer;
|
|
155
|
-
}>;
|
|
156
|
-
_meta: object;
|
|
157
|
-
_ctx_out: {};
|
|
158
|
-
_input_in: {
|
|
159
|
-
id: string;
|
|
160
|
-
relation: "viewers" | "editors" | "builders" | "owners";
|
|
161
|
-
namespace: "Project";
|
|
162
|
-
subjectSet: {
|
|
163
|
-
id: string;
|
|
164
|
-
namespace: "User";
|
|
165
|
-
} | {
|
|
166
|
-
id: string;
|
|
167
|
-
namespace: "Token";
|
|
168
|
-
} | {
|
|
169
|
-
id: string;
|
|
170
|
-
relation: "owners";
|
|
171
|
-
namespace: "Email";
|
|
172
|
-
};
|
|
173
|
-
} | {
|
|
174
|
-
id: string;
|
|
175
|
-
relation: "owners";
|
|
176
|
-
namespace: "Email";
|
|
177
|
-
subjectSet: {
|
|
178
|
-
id: string;
|
|
179
|
-
namespace: "User";
|
|
180
|
-
};
|
|
181
|
-
};
|
|
182
|
-
_input_out: {
|
|
183
|
-
id: string;
|
|
184
|
-
relation: "viewers" | "editors" | "builders" | "owners";
|
|
185
|
-
namespace: "Project";
|
|
186
|
-
subjectSet: {
|
|
187
|
-
id: string;
|
|
188
|
-
namespace: "User";
|
|
189
|
-
} | {
|
|
190
|
-
id: string;
|
|
191
|
-
namespace: "Token";
|
|
192
|
-
} | {
|
|
193
|
-
id: string;
|
|
194
|
-
relation: "owners";
|
|
195
|
-
namespace: "Email";
|
|
196
|
-
};
|
|
197
|
-
} | {
|
|
198
|
-
id: string;
|
|
199
|
-
relation: "owners";
|
|
200
|
-
namespace: "Email";
|
|
201
|
-
subjectSet: {
|
|
202
|
-
id: string;
|
|
203
|
-
namespace: "User";
|
|
204
|
-
};
|
|
205
|
-
};
|
|
206
|
-
_output_in: typeof import("@trpc/server").unsetMarker;
|
|
207
|
-
_output_out: typeof import("@trpc/server").unsetMarker;
|
|
208
|
-
}, void>;
|
|
209
|
-
patch: import("@trpc/server").BuildProcedure<"mutation", {
|
|
210
|
-
_config: import("@trpc/server").RootConfig<{
|
|
211
|
-
ctx: {};
|
|
212
|
-
meta: object;
|
|
213
|
-
errorShape: import("@trpc/server").DefaultErrorShape;
|
|
214
|
-
transformer: import("@trpc/server").DefaultDataTransformer;
|
|
215
|
-
}>;
|
|
216
|
-
_meta: object;
|
|
217
|
-
_ctx_out: {};
|
|
218
|
-
_input_in: {
|
|
219
|
-
action: "delete" | "insert";
|
|
220
|
-
relationTuple: {
|
|
221
|
-
id: string;
|
|
222
|
-
relation: "viewers" | "editors" | "builders" | "owners";
|
|
223
|
-
namespace: "Project";
|
|
224
|
-
subjectSet: {
|
|
225
|
-
id: string;
|
|
226
|
-
namespace: "User";
|
|
227
|
-
} | {
|
|
228
|
-
id: string;
|
|
229
|
-
namespace: "Token";
|
|
230
|
-
} | {
|
|
231
|
-
id: string;
|
|
232
|
-
relation: "owners";
|
|
233
|
-
namespace: "Email";
|
|
234
|
-
};
|
|
235
|
-
} | {
|
|
236
|
-
id: string;
|
|
237
|
-
relation: "owners";
|
|
238
|
-
namespace: "Email";
|
|
239
|
-
subjectSet: {
|
|
240
|
-
id: string;
|
|
241
|
-
namespace: "User";
|
|
242
|
-
};
|
|
243
|
-
};
|
|
244
|
-
}[];
|
|
245
|
-
_input_out: {
|
|
246
|
-
action: "delete" | "insert";
|
|
247
|
-
relationTuple: {
|
|
248
|
-
id: string;
|
|
249
|
-
relation: "viewers" | "editors" | "builders" | "owners";
|
|
250
|
-
namespace: "Project";
|
|
251
|
-
subjectSet: {
|
|
252
|
-
id: string;
|
|
253
|
-
namespace: "User";
|
|
254
|
-
} | {
|
|
255
|
-
id: string;
|
|
256
|
-
namespace: "Token";
|
|
257
|
-
} | {
|
|
258
|
-
id: string;
|
|
259
|
-
relation: "owners";
|
|
260
|
-
namespace: "Email";
|
|
261
|
-
};
|
|
262
|
-
} | {
|
|
263
|
-
id: string;
|
|
264
|
-
relation: "owners";
|
|
265
|
-
namespace: "Email";
|
|
266
|
-
subjectSet: {
|
|
267
|
-
id: string;
|
|
268
|
-
namespace: "User";
|
|
269
|
-
};
|
|
270
|
-
};
|
|
271
|
-
}[];
|
|
272
|
-
_output_in: typeof import("@trpc/server").unsetMarker;
|
|
273
|
-
_output_out: typeof import("@trpc/server").unsetMarker;
|
|
274
|
-
}, void>;
|
|
275
|
-
}>;
|
|
276
|
-
export {};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { type TrpcInterfaceClient } from "./shared-router";
|
|
2
|
-
type SharedClientOptions = {
|
|
3
|
-
url: string;
|
|
4
|
-
token: string;
|
|
5
|
-
branchName: string | undefined;
|
|
6
|
-
};
|
|
7
|
-
export declare const createTrpcProxyServiceClient: (options?: SharedClientOptions | undefined) => TrpcInterfaceClient;
|
|
8
|
-
export {};
|
|
@@ -1,265 +0,0 @@
|
|
|
1
|
-
import type { createTRPCProxyClient } from "@trpc/client";
|
|
2
|
-
export declare const sharedRouter: import("@trpc/server").CreateRouterInner<import("@trpc/server").RootConfig<{
|
|
3
|
-
ctx: {};
|
|
4
|
-
meta: object;
|
|
5
|
-
errorShape: import("@trpc/server").DefaultErrorShape;
|
|
6
|
-
transformer: import("@trpc/server").DefaultDataTransformer;
|
|
7
|
-
}>, {
|
|
8
|
-
authorize: import("@trpc/server").CreateRouterInner<import("@trpc/server").RootConfig<{
|
|
9
|
-
ctx: {};
|
|
10
|
-
meta: object;
|
|
11
|
-
errorShape: import("@trpc/server").DefaultErrorShape;
|
|
12
|
-
transformer: import("@trpc/server").DefaultDataTransformer;
|
|
13
|
-
}>, {
|
|
14
|
-
expandLeafNodes: import("@trpc/server").BuildProcedure<"query", {
|
|
15
|
-
_config: import("@trpc/server").RootConfig<{
|
|
16
|
-
ctx: {};
|
|
17
|
-
meta: object;
|
|
18
|
-
errorShape: import("@trpc/server").DefaultErrorShape;
|
|
19
|
-
transformer: import("@trpc/server").DefaultDataTransformer;
|
|
20
|
-
}>;
|
|
21
|
-
_meta: object;
|
|
22
|
-
_ctx_out: {};
|
|
23
|
-
_input_in: {
|
|
24
|
-
id: string;
|
|
25
|
-
namespace: "Project";
|
|
26
|
-
};
|
|
27
|
-
_input_out: {
|
|
28
|
-
id: string;
|
|
29
|
-
namespace: "Project";
|
|
30
|
-
};
|
|
31
|
-
_output_in: {
|
|
32
|
-
id: string;
|
|
33
|
-
relation: "viewers" | "editors" | "builders" | "owners";
|
|
34
|
-
namespace: "User" | "Token" | "Email";
|
|
35
|
-
}[];
|
|
36
|
-
_output_out: {
|
|
37
|
-
id: string;
|
|
38
|
-
relation: "viewers" | "editors" | "builders" | "owners";
|
|
39
|
-
namespace: "User" | "Token" | "Email";
|
|
40
|
-
}[];
|
|
41
|
-
}, unknown>;
|
|
42
|
-
check: import("@trpc/server").BuildProcedure<"query", {
|
|
43
|
-
_config: import("@trpc/server").RootConfig<{
|
|
44
|
-
ctx: {};
|
|
45
|
-
meta: object;
|
|
46
|
-
errorShape: import("@trpc/server").DefaultErrorShape;
|
|
47
|
-
transformer: import("@trpc/server").DefaultDataTransformer;
|
|
48
|
-
}>;
|
|
49
|
-
_meta: object;
|
|
50
|
-
_ctx_out: {};
|
|
51
|
-
_input_in: {
|
|
52
|
-
id: string;
|
|
53
|
-
namespace: "Project";
|
|
54
|
-
subjectSet: {
|
|
55
|
-
id: string;
|
|
56
|
-
namespace: "User" | "Token";
|
|
57
|
-
};
|
|
58
|
-
permit: "build" | "view" | "edit" | "own";
|
|
59
|
-
};
|
|
60
|
-
_input_out: {
|
|
61
|
-
id: string;
|
|
62
|
-
namespace: "Project";
|
|
63
|
-
subjectSet: {
|
|
64
|
-
id: string;
|
|
65
|
-
namespace: "User" | "Token";
|
|
66
|
-
};
|
|
67
|
-
permit: "build" | "view" | "edit" | "own";
|
|
68
|
-
};
|
|
69
|
-
_output_in: {
|
|
70
|
-
allowed: boolean;
|
|
71
|
-
};
|
|
72
|
-
_output_out: {
|
|
73
|
-
allowed: boolean;
|
|
74
|
-
};
|
|
75
|
-
}, unknown>;
|
|
76
|
-
create: import("@trpc/server").BuildProcedure<"mutation", {
|
|
77
|
-
_config: import("@trpc/server").RootConfig<{
|
|
78
|
-
ctx: {};
|
|
79
|
-
meta: object;
|
|
80
|
-
errorShape: import("@trpc/server").DefaultErrorShape;
|
|
81
|
-
transformer: import("@trpc/server").DefaultDataTransformer;
|
|
82
|
-
}>;
|
|
83
|
-
_meta: object;
|
|
84
|
-
_ctx_out: {};
|
|
85
|
-
_input_in: {
|
|
86
|
-
id: string;
|
|
87
|
-
relation: "viewers" | "editors" | "builders" | "owners";
|
|
88
|
-
namespace: "Project";
|
|
89
|
-
subjectSet: {
|
|
90
|
-
id: string;
|
|
91
|
-
namespace: "User";
|
|
92
|
-
} | {
|
|
93
|
-
id: string;
|
|
94
|
-
namespace: "Token";
|
|
95
|
-
} | {
|
|
96
|
-
id: string;
|
|
97
|
-
relation: "owners";
|
|
98
|
-
namespace: "Email";
|
|
99
|
-
};
|
|
100
|
-
} | {
|
|
101
|
-
id: string;
|
|
102
|
-
relation: "owners";
|
|
103
|
-
namespace: "Email";
|
|
104
|
-
subjectSet: {
|
|
105
|
-
id: string;
|
|
106
|
-
namespace: "User";
|
|
107
|
-
};
|
|
108
|
-
};
|
|
109
|
-
_input_out: {
|
|
110
|
-
id: string;
|
|
111
|
-
relation: "viewers" | "editors" | "builders" | "owners";
|
|
112
|
-
namespace: "Project";
|
|
113
|
-
subjectSet: {
|
|
114
|
-
id: string;
|
|
115
|
-
namespace: "User";
|
|
116
|
-
} | {
|
|
117
|
-
id: string;
|
|
118
|
-
namespace: "Token";
|
|
119
|
-
} | {
|
|
120
|
-
id: string;
|
|
121
|
-
relation: "owners";
|
|
122
|
-
namespace: "Email";
|
|
123
|
-
};
|
|
124
|
-
} | {
|
|
125
|
-
id: string;
|
|
126
|
-
relation: "owners";
|
|
127
|
-
namespace: "Email";
|
|
128
|
-
subjectSet: {
|
|
129
|
-
id: string;
|
|
130
|
-
namespace: "User";
|
|
131
|
-
};
|
|
132
|
-
};
|
|
133
|
-
_output_in: typeof import("@trpc/server").unsetMarker;
|
|
134
|
-
_output_out: typeof import("@trpc/server").unsetMarker;
|
|
135
|
-
}, void>;
|
|
136
|
-
delete: import("@trpc/server").BuildProcedure<"mutation", {
|
|
137
|
-
_config: import("@trpc/server").RootConfig<{
|
|
138
|
-
ctx: {};
|
|
139
|
-
meta: object;
|
|
140
|
-
errorShape: import("@trpc/server").DefaultErrorShape;
|
|
141
|
-
transformer: import("@trpc/server").DefaultDataTransformer;
|
|
142
|
-
}>;
|
|
143
|
-
_meta: object;
|
|
144
|
-
_ctx_out: {};
|
|
145
|
-
_input_in: {
|
|
146
|
-
id: string;
|
|
147
|
-
relation: "viewers" | "editors" | "builders" | "owners";
|
|
148
|
-
namespace: "Project";
|
|
149
|
-
subjectSet: {
|
|
150
|
-
id: string;
|
|
151
|
-
namespace: "User";
|
|
152
|
-
} | {
|
|
153
|
-
id: string;
|
|
154
|
-
namespace: "Token";
|
|
155
|
-
} | {
|
|
156
|
-
id: string;
|
|
157
|
-
relation: "owners";
|
|
158
|
-
namespace: "Email";
|
|
159
|
-
};
|
|
160
|
-
} | {
|
|
161
|
-
id: string;
|
|
162
|
-
relation: "owners";
|
|
163
|
-
namespace: "Email";
|
|
164
|
-
subjectSet: {
|
|
165
|
-
id: string;
|
|
166
|
-
namespace: "User";
|
|
167
|
-
};
|
|
168
|
-
};
|
|
169
|
-
_input_out: {
|
|
170
|
-
id: string;
|
|
171
|
-
relation: "viewers" | "editors" | "builders" | "owners";
|
|
172
|
-
namespace: "Project";
|
|
173
|
-
subjectSet: {
|
|
174
|
-
id: string;
|
|
175
|
-
namespace: "User";
|
|
176
|
-
} | {
|
|
177
|
-
id: string;
|
|
178
|
-
namespace: "Token";
|
|
179
|
-
} | {
|
|
180
|
-
id: string;
|
|
181
|
-
relation: "owners";
|
|
182
|
-
namespace: "Email";
|
|
183
|
-
};
|
|
184
|
-
} | {
|
|
185
|
-
id: string;
|
|
186
|
-
relation: "owners";
|
|
187
|
-
namespace: "Email";
|
|
188
|
-
subjectSet: {
|
|
189
|
-
id: string;
|
|
190
|
-
namespace: "User";
|
|
191
|
-
};
|
|
192
|
-
};
|
|
193
|
-
_output_in: typeof import("@trpc/server").unsetMarker;
|
|
194
|
-
_output_out: typeof import("@trpc/server").unsetMarker;
|
|
195
|
-
}, void>;
|
|
196
|
-
patch: import("@trpc/server").BuildProcedure<"mutation", {
|
|
197
|
-
_config: import("@trpc/server").RootConfig<{
|
|
198
|
-
ctx: {};
|
|
199
|
-
meta: object;
|
|
200
|
-
errorShape: import("@trpc/server").DefaultErrorShape;
|
|
201
|
-
transformer: import("@trpc/server").DefaultDataTransformer;
|
|
202
|
-
}>;
|
|
203
|
-
_meta: object;
|
|
204
|
-
_ctx_out: {};
|
|
205
|
-
_input_in: {
|
|
206
|
-
action: "delete" | "insert";
|
|
207
|
-
relationTuple: {
|
|
208
|
-
id: string;
|
|
209
|
-
relation: "viewers" | "editors" | "builders" | "owners";
|
|
210
|
-
namespace: "Project";
|
|
211
|
-
subjectSet: {
|
|
212
|
-
id: string;
|
|
213
|
-
namespace: "User";
|
|
214
|
-
} | {
|
|
215
|
-
id: string;
|
|
216
|
-
namespace: "Token";
|
|
217
|
-
} | {
|
|
218
|
-
id: string;
|
|
219
|
-
relation: "owners";
|
|
220
|
-
namespace: "Email";
|
|
221
|
-
};
|
|
222
|
-
} | {
|
|
223
|
-
id: string;
|
|
224
|
-
relation: "owners";
|
|
225
|
-
namespace: "Email";
|
|
226
|
-
subjectSet: {
|
|
227
|
-
id: string;
|
|
228
|
-
namespace: "User";
|
|
229
|
-
};
|
|
230
|
-
};
|
|
231
|
-
}[];
|
|
232
|
-
_input_out: {
|
|
233
|
-
action: "delete" | "insert";
|
|
234
|
-
relationTuple: {
|
|
235
|
-
id: string;
|
|
236
|
-
relation: "viewers" | "editors" | "builders" | "owners";
|
|
237
|
-
namespace: "Project";
|
|
238
|
-
subjectSet: {
|
|
239
|
-
id: string;
|
|
240
|
-
namespace: "User";
|
|
241
|
-
} | {
|
|
242
|
-
id: string;
|
|
243
|
-
namespace: "Token";
|
|
244
|
-
} | {
|
|
245
|
-
id: string;
|
|
246
|
-
relation: "owners";
|
|
247
|
-
namespace: "Email";
|
|
248
|
-
};
|
|
249
|
-
} | {
|
|
250
|
-
id: string;
|
|
251
|
-
relation: "owners";
|
|
252
|
-
namespace: "Email";
|
|
253
|
-
subjectSet: {
|
|
254
|
-
id: string;
|
|
255
|
-
namespace: "User";
|
|
256
|
-
};
|
|
257
|
-
};
|
|
258
|
-
}[];
|
|
259
|
-
_output_in: typeof import("@trpc/server").unsetMarker;
|
|
260
|
-
_output_out: typeof import("@trpc/server").unsetMarker;
|
|
261
|
-
}, void>;
|
|
262
|
-
}>;
|
|
263
|
-
}>;
|
|
264
|
-
export type SharedRouter = typeof sharedRouter;
|
|
265
|
-
export type TrpcInterfaceClient = ReturnType<typeof createTRPCProxyClient<SharedRouter>>;
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { type inferAsyncReturnType } from "@trpc/server";
|
|
2
|
-
export declare const createContext: () => Promise<{}>;
|
|
3
|
-
export type Context = inferAsyncReturnType<typeof createContext>;
|
|
4
|
-
export declare const router: <TProcRouterRecord extends import("@trpc/server").ProcedureRouterRecord>(procedures: TProcRouterRecord) => import("@trpc/server").CreateRouterInner<import("@trpc/server").RootConfig<{
|
|
5
|
-
ctx: {};
|
|
6
|
-
meta: object;
|
|
7
|
-
errorShape: import("@trpc/server").DefaultErrorShape;
|
|
8
|
-
transformer: import("@trpc/server").DefaultDataTransformer;
|
|
9
|
-
}>, TProcRouterRecord>, procedure: import("@trpc/server").ProcedureBuilder<{
|
|
10
|
-
_config: import("@trpc/server").RootConfig<{
|
|
11
|
-
ctx: {};
|
|
12
|
-
meta: object;
|
|
13
|
-
errorShape: import("@trpc/server").DefaultErrorShape;
|
|
14
|
-
transformer: import("@trpc/server").DefaultDataTransformer;
|
|
15
|
-
}>;
|
|
16
|
-
_ctx_out: {};
|
|
17
|
-
_input_in: typeof import("@trpc/server").unsetMarker;
|
|
18
|
-
_input_out: typeof import("@trpc/server").unsetMarker;
|
|
19
|
-
_output_in: typeof import("@trpc/server").unsetMarker;
|
|
20
|
-
_output_out: typeof import("@trpc/server").unsetMarker;
|
|
21
|
-
_meta: object;
|
|
22
|
-
}>, middleware: <TNewParams extends import("@trpc/server").ProcedureParams<import("@trpc/server").AnyRootConfig, unknown, unknown, unknown, unknown, unknown, unknown>>(fn: import("@trpc/server").MiddlewareFunction<{
|
|
23
|
-
_config: import("@trpc/server").RootConfig<{
|
|
24
|
-
ctx: {};
|
|
25
|
-
meta: object;
|
|
26
|
-
errorShape: import("@trpc/server").DefaultErrorShape;
|
|
27
|
-
transformer: import("@trpc/server").DefaultDataTransformer;
|
|
28
|
-
}>;
|
|
29
|
-
_ctx_out: {};
|
|
30
|
-
_input_out: unknown;
|
|
31
|
-
_input_in: unknown;
|
|
32
|
-
_output_in: unknown;
|
|
33
|
-
_output_out: unknown;
|
|
34
|
-
_meta: object;
|
|
35
|
-
}, TNewParams>) => import("@trpc/server").MiddlewareFunction<{
|
|
36
|
-
_config: import("@trpc/server").RootConfig<{
|
|
37
|
-
ctx: {};
|
|
38
|
-
meta: object;
|
|
39
|
-
errorShape: import("@trpc/server").DefaultErrorShape;
|
|
40
|
-
transformer: import("@trpc/server").DefaultDataTransformer;
|
|
41
|
-
}>;
|
|
42
|
-
_ctx_out: {};
|
|
43
|
-
_input_out: unknown;
|
|
44
|
-
_input_in: unknown;
|
|
45
|
-
_output_in: unknown;
|
|
46
|
-
_output_out: unknown;
|
|
47
|
-
_meta: object;
|
|
48
|
-
}, TNewParams>;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { AnyRouter } from "@trpc/server";
|
|
2
|
-
import { type TRPCLink } from "@trpc/client";
|
|
3
|
-
type MemoryLinkOptions<TemplateRouter extends AnyRouter> = {
|
|
4
|
-
appRouter: TemplateRouter;
|
|
5
|
-
createContext?: () => TemplateRouter["_def"]["_config"]["$types"]["ctx"];
|
|
6
|
-
};
|
|
7
|
-
/**
|
|
8
|
-
* https://github.com/trpc/trpc/issues/3335
|
|
9
|
-
*
|
|
10
|
-
* createCaller and createTRPCProxyClient provides different interfaces,
|
|
11
|
-
* here we provide callerLink which can be used as a [trpc client link](https://trpc.io/docs/links)
|
|
12
|
-
* Allowing us to call router api without http but through createTRPCProxyClient interface
|
|
13
|
-
* See trpc-caller-link.test.ts for details
|
|
14
|
-
**/
|
|
15
|
-
export declare const callerLink: <TemplateRouter extends AnyRouter>(opts: MemoryLinkOptions<TemplateRouter>) => TRPCLink<TemplateRouter>;
|
|
16
|
-
export {};
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
type Context = {
|
|
2
|
-
someCtx: string;
|
|
3
|
-
};
|
|
4
|
-
export declare const router: <TProcRouterRecord extends import("@trpc/server").ProcedureRouterRecord>(procedures: TProcRouterRecord) => import("@trpc/server").CreateRouterInner<import("@trpc/server").RootConfig<{
|
|
5
|
-
ctx: Context;
|
|
6
|
-
meta: object;
|
|
7
|
-
errorShape: import("@trpc/server").DefaultErrorShape;
|
|
8
|
-
transformer: import("@trpc/server").DefaultDataTransformer;
|
|
9
|
-
}>, TProcRouterRecord>, procedure: import("@trpc/server").ProcedureBuilder<{
|
|
10
|
-
_config: import("@trpc/server").RootConfig<{
|
|
11
|
-
ctx: Context;
|
|
12
|
-
meta: object;
|
|
13
|
-
errorShape: import("@trpc/server").DefaultErrorShape;
|
|
14
|
-
transformer: import("@trpc/server").DefaultDataTransformer;
|
|
15
|
-
}>;
|
|
16
|
-
_ctx_out: Context;
|
|
17
|
-
_input_in: typeof import("@trpc/server").unsetMarker;
|
|
18
|
-
_input_out: typeof import("@trpc/server").unsetMarker;
|
|
19
|
-
_output_in: typeof import("@trpc/server").unsetMarker;
|
|
20
|
-
_output_out: typeof import("@trpc/server").unsetMarker;
|
|
21
|
-
_meta: object;
|
|
22
|
-
}>, middleware: <TNewParams extends import("@trpc/server").ProcedureParams<import("@trpc/server").AnyRootConfig, unknown, unknown, unknown, unknown, unknown, unknown>>(fn: import("@trpc/server").MiddlewareFunction<{
|
|
23
|
-
_config: import("@trpc/server").RootConfig<{
|
|
24
|
-
ctx: Context;
|
|
25
|
-
meta: object;
|
|
26
|
-
errorShape: import("@trpc/server").DefaultErrorShape;
|
|
27
|
-
transformer: import("@trpc/server").DefaultDataTransformer;
|
|
28
|
-
}>;
|
|
29
|
-
_ctx_out: Context;
|
|
30
|
-
_input_out: unknown;
|
|
31
|
-
_input_in: unknown;
|
|
32
|
-
_output_in: unknown;
|
|
33
|
-
_output_out: unknown;
|
|
34
|
-
_meta: object;
|
|
35
|
-
}, TNewParams>) => import("@trpc/server").MiddlewareFunction<{
|
|
36
|
-
_config: import("@trpc/server").RootConfig<{
|
|
37
|
-
ctx: Context;
|
|
38
|
-
meta: object;
|
|
39
|
-
errorShape: import("@trpc/server").DefaultErrorShape;
|
|
40
|
-
transformer: import("@trpc/server").DefaultDataTransformer;
|
|
41
|
-
}>;
|
|
42
|
-
_ctx_out: Context;
|
|
43
|
-
_input_out: unknown;
|
|
44
|
-
_input_in: unknown;
|
|
45
|
-
_output_in: unknown;
|
|
46
|
-
_output_out: unknown;
|
|
47
|
-
_meta: object;
|
|
48
|
-
}, TNewParams>;
|
|
49
|
-
export {};
|