@webstudio-is/trpc-interface 0.90.0 → 0.260.2
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/package.json +26 -25
- package/src/authorize/project.server.test.ts +443 -0
- package/src/authorize/project.server.ts +309 -121
- package/src/authorize/role.ts +18 -0
- package/src/context/context.server.ts +59 -24
- package/src/context/errors.server.ts +16 -0
- package/src/context/router.server.ts +19 -0
- package/src/index.server.ts +15 -3
- package/src/shared/client.ts +0 -2
- package/src/shared/deployment.ts +23 -6
- package/src/shared/domain.ts +3 -3
- package/src/shared/plan-client.server.ts +7 -0
- package/src/shared/plan-features.ts +7 -0
- package/src/shared/shared-router.ts +0 -2
- package/src/shared/trpc.ts +5 -1
- package/src/trpc-caller-link.test.ts +1 -1
- package/src/trpc-caller-link.ts +1 -2
- package/tsconfig.json +3 -0
- package/lib/authorize/authorization-token.server.js +0 -72
- package/lib/authorize/project.server.js +0 -103
- package/lib/cjs/authorize/authorization-token.server.js +0 -92
- package/lib/cjs/authorize/project.server.js +0 -123
- package/lib/cjs/context/context.server.js +0 -16
- package/lib/cjs/context/errors.server.js +0 -29
- package/lib/cjs/index.js +0 -18
- package/lib/cjs/index.server.js +0 -40
- package/lib/cjs/package.json +0 -1
- package/lib/cjs/shared/authorization-router.js +0 -184
- package/lib/cjs/shared/client.js +0 -63
- package/lib/cjs/shared/deployment.js +0 -51
- package/lib/cjs/shared/domain.js +0 -98
- package/lib/cjs/shared/shared-router.js +0 -32
- package/lib/cjs/shared/trpc.js +0 -31
- package/lib/cjs/trpc-caller-link.js +0 -46
- package/lib/context/context.server.js +0 -0
- package/lib/context/errors.server.js +0 -9
- package/lib/index.js +0 -1
- package/lib/index.server.js +0 -10
- package/lib/shared/authorization-router.js +0 -164
- package/lib/shared/client.js +0 -35
- package/lib/shared/deployment.js +0 -31
- package/lib/shared/domain.js +0 -78
- package/lib/shared/shared-router.js +0 -12
- package/lib/shared/trpc.js +0 -11
- package/lib/trpc-caller-link.js +0 -26
- 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 -53
- package/lib/types/context/errors.server.d.ts +0 -1
- package/lib/types/index.d.ts +0 -1
- package/lib/types/index.server.d.ts +0 -7
- package/lib/types/shared/authorization-router.d.ts +0 -276
- package/lib/types/shared/client.d.ts +0 -8
- package/lib/types/shared/deployment.d.ts +0 -45
- package/lib/types/shared/domain.d.ts +0 -119
- package/lib/types/shared/shared-router.d.ts +0 -415
- 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
- package/src/authorize/authorization-token.server.ts +0 -106
- package/src/shared/authorization-router.ts +0 -198
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var authorization_router_exports = {};
|
|
20
|
-
__export(authorization_router_exports, {
|
|
21
|
-
authorizationRouter: () => authorizationRouter
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(authorization_router_exports);
|
|
24
|
-
var import_zod = require("zod");
|
|
25
|
-
var import_trpc = require("./trpc");
|
|
26
|
-
var import_prisma_client = require("@webstudio-is/prisma-client");
|
|
27
|
-
const Relation = import_zod.z.enum(["viewers", "editors", "builders", "owners"]);
|
|
28
|
-
const AuthPermit = import_zod.z.enum(["view", "edit", "build", "own"]);
|
|
29
|
-
const DeleteCreateInput = import_zod.z.discriminatedUnion("namespace", [
|
|
30
|
-
import_zod.z.object({
|
|
31
|
-
namespace: import_zod.z.literal("Project"),
|
|
32
|
-
id: import_zod.z.string(),
|
|
33
|
-
relation: Relation,
|
|
34
|
-
subjectSet: import_zod.z.discriminatedUnion("namespace", [
|
|
35
|
-
import_zod.z.object({
|
|
36
|
-
namespace: import_zod.z.literal("User"),
|
|
37
|
-
id: import_zod.z.string()
|
|
38
|
-
}),
|
|
39
|
-
import_zod.z.object({
|
|
40
|
-
namespace: import_zod.z.literal("Token"),
|
|
41
|
-
id: import_zod.z.string()
|
|
42
|
-
}),
|
|
43
|
-
import_zod.z.object({
|
|
44
|
-
namespace: import_zod.z.literal("Email"),
|
|
45
|
-
id: import_zod.z.string(),
|
|
46
|
-
relation: import_zod.z.literal("owners")
|
|
47
|
-
})
|
|
48
|
-
])
|
|
49
|
-
}),
|
|
50
|
-
import_zod.z.object({
|
|
51
|
-
namespace: import_zod.z.literal("Email"),
|
|
52
|
-
id: import_zod.z.string(),
|
|
53
|
-
relation: import_zod.z.enum(["owners"]),
|
|
54
|
-
subjectSet: import_zod.z.object({
|
|
55
|
-
namespace: import_zod.z.literal("User"),
|
|
56
|
-
id: import_zod.z.string()
|
|
57
|
-
})
|
|
58
|
-
})
|
|
59
|
-
]);
|
|
60
|
-
const authorizationRouter = (0, import_trpc.router)({
|
|
61
|
-
/**
|
|
62
|
-
* Relation expansion in authorize looks like a tree
|
|
63
|
-
*
|
|
64
|
-
* :#@Project:AliceProjectUUID#viewers
|
|
65
|
-
* :#@Email:bob@bob.com#owner
|
|
66
|
-
* :#@User:BobUUID️
|
|
67
|
-
* :#@Token:LinkRandomSequence️
|
|
68
|
-
*
|
|
69
|
-
* We don't need the whole tree in UI and need only the leaf nodes.
|
|
70
|
-
* i.e. @User:BobUUID️, @Token:LinkRandomSequence️ and the root relation i.e "viewers"
|
|
71
|
-
*/
|
|
72
|
-
expandLeafNodes: import_trpc.procedure.input(
|
|
73
|
-
import_zod.z.object({
|
|
74
|
-
namespace: import_zod.z.literal("Project"),
|
|
75
|
-
id: import_zod.z.string()
|
|
76
|
-
})
|
|
77
|
-
).output(
|
|
78
|
-
import_zod.z.array(
|
|
79
|
-
import_zod.z.object({
|
|
80
|
-
// top level relation
|
|
81
|
-
relation: Relation,
|
|
82
|
-
// subjectSet
|
|
83
|
-
namespace: import_zod.z.enum(["Email", "User", "Token"]),
|
|
84
|
-
id: import_zod.z.string()
|
|
85
|
-
})
|
|
86
|
-
)
|
|
87
|
-
).query(async ({ input }) => {
|
|
88
|
-
const { namespace, id } = input;
|
|
89
|
-
if (namespace !== "Project") {
|
|
90
|
-
throw new Error("Not implemented");
|
|
91
|
-
}
|
|
92
|
-
const ownerRow = await import_prisma_client.prisma.project.findUnique({
|
|
93
|
-
where: {
|
|
94
|
-
id
|
|
95
|
-
},
|
|
96
|
-
select: {
|
|
97
|
-
userId: true
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
const tokenRows = await import_prisma_client.prisma.authorizationToken.findMany({
|
|
101
|
-
where: {
|
|
102
|
-
projectId: id
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
const leafSubjectSets = [];
|
|
106
|
-
if (ownerRow !== null && ownerRow.userId !== null) {
|
|
107
|
-
leafSubjectSets.push({
|
|
108
|
-
namespace: "User",
|
|
109
|
-
id: ownerRow.userId,
|
|
110
|
-
relation: "owners"
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
for (const tokenRow of tokenRows) {
|
|
114
|
-
leafSubjectSets.push({
|
|
115
|
-
namespace: "Token",
|
|
116
|
-
id: tokenRow.token,
|
|
117
|
-
relation: tokenRow.relation
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
return leafSubjectSets;
|
|
121
|
-
}),
|
|
122
|
-
/**
|
|
123
|
-
* Check if subject has permit on the resource
|
|
124
|
-
*/
|
|
125
|
-
check: import_trpc.procedure.input(
|
|
126
|
-
import_zod.z.object({
|
|
127
|
-
namespace: import_zod.z.enum(["Project"]),
|
|
128
|
-
id: import_zod.z.string(),
|
|
129
|
-
permit: AuthPermit,
|
|
130
|
-
subjectSet: import_zod.z.object({
|
|
131
|
-
namespace: import_zod.z.enum(["User", "Token"]),
|
|
132
|
-
id: import_zod.z.string()
|
|
133
|
-
})
|
|
134
|
-
})
|
|
135
|
-
).output(import_zod.z.object({ allowed: import_zod.z.boolean() })).query(async ({ input }) => {
|
|
136
|
-
const { subjectSet } = input;
|
|
137
|
-
if (subjectSet.namespace === "User") {
|
|
138
|
-
const row = await import_prisma_client.prisma.project.findFirst({
|
|
139
|
-
where: {
|
|
140
|
-
id: input.id,
|
|
141
|
-
userId: subjectSet.id
|
|
142
|
-
},
|
|
143
|
-
select: {
|
|
144
|
-
id: true
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
return { allowed: row !== null };
|
|
148
|
-
}
|
|
149
|
-
const permitToRelationRewrite = {
|
|
150
|
-
view: ["viewers", "editors", "builders"],
|
|
151
|
-
edit: ["editors", "builders"],
|
|
152
|
-
build: ["builders"]
|
|
153
|
-
};
|
|
154
|
-
if (subjectSet.namespace === "Token" && input.permit !== "own") {
|
|
155
|
-
const row = await import_prisma_client.prisma.authorizationToken.findFirst({
|
|
156
|
-
where: {
|
|
157
|
-
token: subjectSet.id,
|
|
158
|
-
relation: {
|
|
159
|
-
in: [...permitToRelationRewrite[input.permit]]
|
|
160
|
-
}
|
|
161
|
-
},
|
|
162
|
-
select: { token: true }
|
|
163
|
-
});
|
|
164
|
-
return { allowed: row !== null };
|
|
165
|
-
}
|
|
166
|
-
return { allowed: false };
|
|
167
|
-
}),
|
|
168
|
-
/**
|
|
169
|
-
* In OSS we extract owner relation from the Project table, and the rest from the authorizationToken table
|
|
170
|
-
*/
|
|
171
|
-
create: import_trpc.procedure.input(DeleteCreateInput).mutation(async ({ input }) => {
|
|
172
|
-
}),
|
|
173
|
-
delete: import_trpc.procedure.input(DeleteCreateInput).mutation(async ({ input }) => {
|
|
174
|
-
}),
|
|
175
|
-
patch: import_trpc.procedure.input(
|
|
176
|
-
import_zod.z.array(
|
|
177
|
-
import_zod.z.object({
|
|
178
|
-
action: import_zod.z.enum(["insert", "delete"]),
|
|
179
|
-
relationTuple: DeleteCreateInput
|
|
180
|
-
})
|
|
181
|
-
)
|
|
182
|
-
).mutation(async ({ input }) => {
|
|
183
|
-
})
|
|
184
|
-
});
|
package/lib/cjs/shared/client.js
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var client_exports = {};
|
|
30
|
-
__export(client_exports, {
|
|
31
|
-
createTrpcProxyServiceClient: () => createTrpcProxyServiceClient
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(client_exports);
|
|
34
|
-
var import_client = require("@trpc/client");
|
|
35
|
-
var import_shared_router = require("./shared-router");
|
|
36
|
-
var import_trpc_caller_link = require("../trpc-caller-link");
|
|
37
|
-
var import_node_fetch = __toESM(require("node-fetch"), 1);
|
|
38
|
-
const createTrpcProxyServiceClient = (options) => {
|
|
39
|
-
if (options !== void 0) {
|
|
40
|
-
const remoteClient = (0, import_client.createTRPCProxyClient)({
|
|
41
|
-
links: [
|
|
42
|
-
(0, import_client.httpBatchLink)({
|
|
43
|
-
url: options.url,
|
|
44
|
-
fetch: import_node_fetch.default,
|
|
45
|
-
headers: () => ({
|
|
46
|
-
Authorization: options.token,
|
|
47
|
-
// We use this header for SaaS preview service discovery proxy
|
|
48
|
-
"x-branch-name": options.branchName
|
|
49
|
-
})
|
|
50
|
-
})
|
|
51
|
-
]
|
|
52
|
-
});
|
|
53
|
-
return remoteClient;
|
|
54
|
-
}
|
|
55
|
-
const client = (0, import_client.createTRPCProxyClient)({
|
|
56
|
-
links: [
|
|
57
|
-
(0, import_trpc_caller_link.callerLink)({
|
|
58
|
-
appRouter: import_shared_router.sharedRouter
|
|
59
|
-
})
|
|
60
|
-
]
|
|
61
|
-
});
|
|
62
|
-
return client;
|
|
63
|
-
};
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var deployment_exports = {};
|
|
20
|
-
__export(deployment_exports, {
|
|
21
|
-
deploymentRouter: () => deploymentRouter
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(deployment_exports);
|
|
24
|
-
var import_zod = require("zod");
|
|
25
|
-
var import_trpc = require("./trpc");
|
|
26
|
-
const PublishInput = import_zod.z.object({
|
|
27
|
-
// used to load build data from the builder see routes/rest.build.$buildId.ts
|
|
28
|
-
buildId: import_zod.z.string(),
|
|
29
|
-
builderApiOrigin: import_zod.z.string(),
|
|
30
|
-
// preview support
|
|
31
|
-
branchName: import_zod.z.string(),
|
|
32
|
-
// action log helper (not used for deployment, but for action logs readablity)
|
|
33
|
-
projectDomainName: import_zod.z.string()
|
|
34
|
-
});
|
|
35
|
-
const Output = import_zod.z.discriminatedUnion("success", [
|
|
36
|
-
import_zod.z.object({
|
|
37
|
-
success: import_zod.z.literal(true)
|
|
38
|
-
}),
|
|
39
|
-
import_zod.z.object({
|
|
40
|
-
success: import_zod.z.literal(false),
|
|
41
|
-
error: import_zod.z.string()
|
|
42
|
-
})
|
|
43
|
-
]);
|
|
44
|
-
const deploymentRouter = (0, import_trpc.router)({
|
|
45
|
-
publish: import_trpc.procedure.input(PublishInput).output(Output).mutation(async ({ input, ctx }) => {
|
|
46
|
-
return {
|
|
47
|
-
success: false,
|
|
48
|
-
error: `Not implemented, use buildId=${input.buildId}`
|
|
49
|
-
};
|
|
50
|
-
})
|
|
51
|
-
});
|
package/lib/cjs/shared/domain.js
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var domain_exports = {};
|
|
20
|
-
__export(domain_exports, {
|
|
21
|
-
domainRouter: () => domainRouter
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(domain_exports);
|
|
24
|
-
var import_zod = require("zod");
|
|
25
|
-
var import_trpc = require("./trpc");
|
|
26
|
-
const CreateInput = import_zod.z.object({ domain: import_zod.z.string(), txtRecord: import_zod.z.string() });
|
|
27
|
-
const Input = import_zod.z.object({ domain: import_zod.z.string() });
|
|
28
|
-
const createOutput = (data) => import_zod.z.discriminatedUnion("success", [
|
|
29
|
-
import_zod.z.object({ success: import_zod.z.literal(true), data }),
|
|
30
|
-
import_zod.z.object({ success: import_zod.z.literal(false), error: import_zod.z.string() })
|
|
31
|
-
]);
|
|
32
|
-
globalThis.dnsTxtEntries = globalThis.dnsTxtEntries ?? /* @__PURE__ */ new Map();
|
|
33
|
-
globalThis.domainStates = globalThis.domainStates ?? /* @__PURE__ */ new Map();
|
|
34
|
-
const domainRouter = (0, import_trpc.router)({
|
|
35
|
-
/**
|
|
36
|
-
* Verify TXT record and add custom domain entry to DNS
|
|
37
|
-
*/
|
|
38
|
-
create: import_trpc.procedure.input(CreateInput).output(createOutput(import_zod.z.optional(import_zod.z.undefined()))).mutation(async ({ input, ctx }) => {
|
|
39
|
-
const record = dnsTxtEntries.get(input.domain);
|
|
40
|
-
if (record !== input.txtRecord) {
|
|
41
|
-
dnsTxtEntries.set(input.domain, input.txtRecord);
|
|
42
|
-
return {
|
|
43
|
-
success: false,
|
|
44
|
-
error: `TXT record does not match, expected "${input.txtRecord}" but got "${record ?? "undefined"}"`
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
domainStates.set(input.domain, "pending");
|
|
48
|
-
return { success: true };
|
|
49
|
-
}),
|
|
50
|
-
refresh: import_trpc.procedure.input(Input).output(createOutput(import_zod.z.optional(import_zod.z.undefined()))).mutation(async ({ input, ctx }) => {
|
|
51
|
-
return { success: true };
|
|
52
|
-
}),
|
|
53
|
-
/**
|
|
54
|
-
* Get status of verified domain
|
|
55
|
-
*/
|
|
56
|
-
getStatus: import_trpc.procedure.input(Input).output(
|
|
57
|
-
createOutput(
|
|
58
|
-
import_zod.z.discriminatedUnion("status", [
|
|
59
|
-
import_zod.z.object({ status: import_zod.z.enum(["active", "pending"]) }),
|
|
60
|
-
import_zod.z.object({ status: import_zod.z.enum(["error"]), error: import_zod.z.string() })
|
|
61
|
-
])
|
|
62
|
-
)
|
|
63
|
-
).query(async ({ input, ctx }) => {
|
|
64
|
-
const domainState = domainStates.get(input.domain);
|
|
65
|
-
if (domainState === void 0) {
|
|
66
|
-
domainStates.set(input.domain, "pending");
|
|
67
|
-
return {
|
|
68
|
-
success: false,
|
|
69
|
-
error: `Domain ${input.domain} is not active`
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
if (domainState === "active") {
|
|
73
|
-
setTimeout(() => {
|
|
74
|
-
domainStates.set(input.domain, "error");
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
if (domainState === "pending" || domainState === "error") {
|
|
78
|
-
setTimeout(() => {
|
|
79
|
-
domainStates.set(input.domain, "active");
|
|
80
|
-
}, 5e3);
|
|
81
|
-
}
|
|
82
|
-
if (domainState === "error") {
|
|
83
|
-
return {
|
|
84
|
-
success: true,
|
|
85
|
-
data: {
|
|
86
|
-
status: "error",
|
|
87
|
-
error: "Domain cname verification failed"
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
return {
|
|
92
|
-
success: true,
|
|
93
|
-
data: {
|
|
94
|
-
status: domainState
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
})
|
|
98
|
-
});
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var shared_router_exports = {};
|
|
20
|
-
__export(shared_router_exports, {
|
|
21
|
-
sharedRouter: () => sharedRouter
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(shared_router_exports);
|
|
24
|
-
var import_trpc = require("./trpc");
|
|
25
|
-
var import_authorization_router = require("./authorization-router");
|
|
26
|
-
var import_domain = require("./domain");
|
|
27
|
-
var import_deployment = require("./deployment");
|
|
28
|
-
const sharedRouter = (0, import_trpc.router)({
|
|
29
|
-
authorize: import_authorization_router.authorizationRouter,
|
|
30
|
-
domain: import_domain.domainRouter,
|
|
31
|
-
deployment: import_deployment.deploymentRouter
|
|
32
|
-
});
|
package/lib/cjs/shared/trpc.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var trpc_exports = {};
|
|
20
|
-
__export(trpc_exports, {
|
|
21
|
-
createContext: () => createContext,
|
|
22
|
-
middleware: () => middleware,
|
|
23
|
-
procedure: () => procedure,
|
|
24
|
-
router: () => router
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(trpc_exports);
|
|
27
|
-
var import_server = require("@trpc/server");
|
|
28
|
-
const createContext = async () => {
|
|
29
|
-
return {};
|
|
30
|
-
};
|
|
31
|
-
const { router, procedure, middleware } = import_server.initTRPC.context().create();
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var trpc_caller_link_exports = {};
|
|
20
|
-
__export(trpc_caller_link_exports, {
|
|
21
|
-
callerLink: () => callerLink
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(trpc_caller_link_exports);
|
|
24
|
-
var import_observable = require("@trpc/server/observable");
|
|
25
|
-
var import_client = require("@trpc/client");
|
|
26
|
-
const callerLink = (opts) => {
|
|
27
|
-
const { appRouter, createContext } = opts;
|
|
28
|
-
return (runtime) => ({ op }) => (0, import_observable.observable)((observer) => {
|
|
29
|
-
const caller = appRouter.createCaller(createContext?.() ?? {});
|
|
30
|
-
const { path, input } = op;
|
|
31
|
-
const paths = path.split(".");
|
|
32
|
-
let localCaller = caller;
|
|
33
|
-
for (const functionName of paths) {
|
|
34
|
-
localCaller = localCaller[functionName];
|
|
35
|
-
}
|
|
36
|
-
const promise = localCaller(input);
|
|
37
|
-
promise.then((data) => {
|
|
38
|
-
observer.next({
|
|
39
|
-
result: { data }
|
|
40
|
-
});
|
|
41
|
-
observer.complete();
|
|
42
|
-
}).catch((error) => observer.error(import_client.TRPCClientError.from(error)));
|
|
43
|
-
return () => {
|
|
44
|
-
};
|
|
45
|
-
});
|
|
46
|
-
};
|
|
File without changes
|
package/lib/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./index.server";
|
package/lib/index.server.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { createTrpcProxyServiceClient } from "./shared/client";
|
|
2
|
-
import { AuthorizationError } from "./context/errors.server";
|
|
3
|
-
import * as authorizeProject from "./authorize/project.server";
|
|
4
|
-
import * as authorizeAuthorizationToken from "./authorize/authorization-token.server";
|
|
5
|
-
export {
|
|
6
|
-
AuthorizationError,
|
|
7
|
-
authorizeAuthorizationToken,
|
|
8
|
-
authorizeProject,
|
|
9
|
-
createTrpcProxyServiceClient
|
|
10
|
-
};
|