@valbuild/shared 0.74.0 → 0.75.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/dist/declarations/src/internal/ApiRoutes.d.ts +303 -31
- package/dist/declarations/src/internal/SharedValConfig.d.ts +9 -0
- package/dist/declarations/src/internal/ValClient.d.ts +2 -1
- package/dist/declarations/src/internal/index.d.ts +4 -0
- package/dist/declarations/src/internal/listeners.d.ts +2 -0
- package/dist/declarations/src/internal/zod/ValCommit.d.ts +27 -0
- package/dist/declarations/src/internal/zod/ValDeployment.d.ts +21 -0
- package/internal/dist/valbuild-shared-internal.cjs.dev.js +137 -23
- package/internal/dist/valbuild-shared-internal.cjs.prod.js +137 -23
- package/internal/dist/valbuild-shared-internal.esm.js +133 -24
- package/package.json +2 -2
@@ -0,0 +1,27 @@
|
|
1
|
+
import { z } from "zod";
|
2
|
+
export declare const ValCommit: z.ZodObject<{
|
3
|
+
commitSha: z.ZodString;
|
4
|
+
clientCommitSha: z.ZodString;
|
5
|
+
parentCommitSha: z.ZodString;
|
6
|
+
branch: z.ZodString;
|
7
|
+
creator: z.ZodString;
|
8
|
+
createdAt: z.ZodString;
|
9
|
+
commitMessage: z.ZodNullable<z.ZodString>;
|
10
|
+
}, "strip", z.ZodTypeAny, {
|
11
|
+
commitSha: string;
|
12
|
+
clientCommitSha: string;
|
13
|
+
parentCommitSha: string;
|
14
|
+
branch: string;
|
15
|
+
creator: string;
|
16
|
+
createdAt: string;
|
17
|
+
commitMessage: string | null;
|
18
|
+
}, {
|
19
|
+
commitSha: string;
|
20
|
+
clientCommitSha: string;
|
21
|
+
parentCommitSha: string;
|
22
|
+
branch: string;
|
23
|
+
creator: string;
|
24
|
+
createdAt: string;
|
25
|
+
commitMessage: string | null;
|
26
|
+
}>;
|
27
|
+
export type ValCommit = z.infer<typeof ValCommit>;
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import { z } from "zod";
|
2
|
+
export declare const ValDeployment: z.ZodObject<{
|
3
|
+
deploymentId: z.ZodString;
|
4
|
+
deploymentState: z.ZodString;
|
5
|
+
commitSha: z.ZodString;
|
6
|
+
updatedAt: z.ZodString;
|
7
|
+
createdAt: z.ZodString;
|
8
|
+
}, "strip", z.ZodTypeAny, {
|
9
|
+
commitSha: string;
|
10
|
+
createdAt: string;
|
11
|
+
deploymentId: string;
|
12
|
+
deploymentState: string;
|
13
|
+
updatedAt: string;
|
14
|
+
}, {
|
15
|
+
commitSha: string;
|
16
|
+
createdAt: string;
|
17
|
+
deploymentId: string;
|
18
|
+
deploymentState: string;
|
19
|
+
updatedAt: string;
|
20
|
+
}>;
|
21
|
+
export type ValDeployment = z.infer<typeof ValDeployment>;
|
@@ -1295,6 +1295,16 @@ var SerializedDateSchema = zod.z.object({
|
|
1295
1295
|
});
|
1296
1296
|
var SerializedSchema = zod.z.union([SerializedStringSchema, SerializedLiteralSchema, SerializedBooleanSchema, SerializedNumberSchema, SerializedObjectSchema, SerializedArraySchema, SerializedUnionSchema, SerializedRichTextSchema, SerializedRecordSchema, SerializedKeyOfSchema, SerializedFileSchema, SerializedDateSchema, SerializedImageSchema]);
|
1297
1297
|
|
1298
|
+
var ValCommit = zod.z.object({
|
1299
|
+
commitSha: zod.z.string(),
|
1300
|
+
clientCommitSha: zod.z.string(),
|
1301
|
+
parentCommitSha: zod.z.string(),
|
1302
|
+
branch: zod.z.string(),
|
1303
|
+
creator: zod.z.string(),
|
1304
|
+
createdAt: zod.z.string(),
|
1305
|
+
commitMessage: zod.z.string().nullable()
|
1306
|
+
});
|
1307
|
+
|
1298
1308
|
var ModuleFilePath = zod.z.string().refine(function (_path) {
|
1299
1309
|
return true;
|
1300
1310
|
} // TODO: validation
|
@@ -1573,16 +1583,56 @@ var Api = {
|
|
1573
1583
|
},
|
1574
1584
|
"/logout": {
|
1575
1585
|
GET: {
|
1576
|
-
req: {
|
1586
|
+
req: {
|
1587
|
+
query: {
|
1588
|
+
redirect_to: zod.z.string().optional()
|
1589
|
+
}
|
1590
|
+
},
|
1577
1591
|
// TODO fix req types
|
1578
|
-
res: zod.z.object({
|
1592
|
+
res: zod.z.union([zod.z.object({
|
1579
1593
|
status: zod.z.literal(200),
|
1580
1594
|
cookies: zod.z.object(_defineProperty(_defineProperty({}, VAL_SESSION_COOKIE, zod.z.object({
|
1581
|
-
value: zod.z.
|
1582
|
-
|
1583
|
-
|
1584
|
-
|
1585
|
-
|
1595
|
+
value: zod.z.string(),
|
1596
|
+
options: zod.z.object({
|
1597
|
+
httpOnly: zod.z.literal(true),
|
1598
|
+
sameSite: zod.z.literal("strict"),
|
1599
|
+
path: zod.z.string(),
|
1600
|
+
secure: zod.z.literal(true),
|
1601
|
+
expires: zod.z["instanceof"](Date)
|
1602
|
+
}).optional()
|
1603
|
+
}).optional()), VAL_STATE_COOKIE, zod.z.object({
|
1604
|
+
value: zod.z.string(),
|
1605
|
+
options: zod.z.object({
|
1606
|
+
httpOnly: zod.z.literal(true),
|
1607
|
+
sameSite: zod.z.literal("strict"),
|
1608
|
+
path: zod.z.string(),
|
1609
|
+
secure: zod.z.literal(true),
|
1610
|
+
expires: zod.z["instanceof"](Date)
|
1611
|
+
}).optional()
|
1612
|
+
}).optional()))
|
1613
|
+
}), zod.z.object({
|
1614
|
+
status: zod.z.literal(302),
|
1615
|
+
redirectTo: zod.z.string(),
|
1616
|
+
cookies: zod.z.object(_defineProperty(_defineProperty({}, VAL_SESSION_COOKIE, zod.z.object({
|
1617
|
+
value: zod.z.string(),
|
1618
|
+
options: zod.z.object({
|
1619
|
+
httpOnly: zod.z.literal(true),
|
1620
|
+
sameSite: zod.z.literal("strict"),
|
1621
|
+
path: zod.z.string(),
|
1622
|
+
secure: zod.z.literal(true),
|
1623
|
+
expires: zod.z["instanceof"](Date)
|
1624
|
+
}).optional()
|
1625
|
+
}).optional()), VAL_STATE_COOKIE, zod.z.object({
|
1626
|
+
value: zod.z.string(),
|
1627
|
+
options: zod.z.object({
|
1628
|
+
httpOnly: zod.z.literal(true),
|
1629
|
+
sameSite: zod.z.literal("strict"),
|
1630
|
+
path: zod.z.string(),
|
1631
|
+
secure: zod.z.literal(true),
|
1632
|
+
expires: zod.z["instanceof"](Date)
|
1633
|
+
}).optional()
|
1634
|
+
}).optional()))
|
1635
|
+
})])
|
1586
1636
|
}
|
1587
1637
|
},
|
1588
1638
|
"/remote/settings": {
|
@@ -1625,6 +1675,7 @@ var Api = {
|
|
1625
1675
|
POST: {
|
1626
1676
|
req: {
|
1627
1677
|
body: zod.z.object({
|
1678
|
+
sourcesSha: zod.z.string(),
|
1628
1679
|
schemaSha: zod.z.string(),
|
1629
1680
|
baseSha: zod.z.string(),
|
1630
1681
|
patches: zod.z.array(zod.z.string()).optional()
|
@@ -1648,19 +1699,24 @@ var Api = {
|
|
1648
1699
|
type: zod.z.union([zod.z.literal("request-again"), zod.z.literal("no-change"), zod.z.literal("did-change")]),
|
1649
1700
|
baseSha: zod.z.string(),
|
1650
1701
|
schemaSha: zod.z.string(),
|
1702
|
+
sourcesSha: zod.z.string(),
|
1651
1703
|
patches: zod.z.array(PatchId),
|
1652
1704
|
config: ValConfig,
|
1653
|
-
|
1705
|
+
profileId: zod.z.string().nullable(),
|
1706
|
+
mode: zod.z.union([zod.z.literal("http"), zod.z.literal("fs")])
|
1654
1707
|
}), zod.z.object({
|
1655
1708
|
type: zod.z.literal("use-websocket"),
|
1656
1709
|
url: zod.z.string(),
|
1657
1710
|
nonce: zod.z.string(),
|
1658
1711
|
baseSha: zod.z.string(),
|
1659
1712
|
schemaSha: zod.z.string(),
|
1713
|
+
sourcesSha: zod.z.string(),
|
1660
1714
|
commitSha: zod.z.string(),
|
1661
1715
|
patches: zod.z.array(PatchId),
|
1716
|
+
commits: zod.z.array(ValCommit),
|
1662
1717
|
config: ValConfig,
|
1663
|
-
|
1718
|
+
profileId: zod.z.string().nullable(),
|
1719
|
+
mode: zod.z.union([zod.z.literal("http"), zod.z.literal("fs")])
|
1664
1720
|
})])
|
1665
1721
|
})])
|
1666
1722
|
}
|
@@ -1692,6 +1748,7 @@ var Api = {
|
|
1692
1748
|
parentRef: ParentRef,
|
1693
1749
|
patches: zod.z.array(zod.z.object({
|
1694
1750
|
path: ModuleFilePath,
|
1751
|
+
patchId: PatchId,
|
1695
1752
|
patch: Patch
|
1696
1753
|
}))
|
1697
1754
|
}),
|
@@ -1798,7 +1855,6 @@ var Api = {
|
|
1798
1855
|
req: {
|
1799
1856
|
path: zod.z.string().optional(),
|
1800
1857
|
query: {
|
1801
|
-
validate_all: zod.z["boolean"]().optional(),
|
1802
1858
|
validate_sources: zod.z["boolean"]().optional(),
|
1803
1859
|
validate_binary_files: zod.z["boolean"]().optional()
|
1804
1860
|
},
|
@@ -1830,6 +1886,7 @@ var Api = {
|
|
1830
1886
|
status: zod.z.literal(200),
|
1831
1887
|
json: zod.z.object({
|
1832
1888
|
schemaSha: zod.z.string(),
|
1889
|
+
sourcesSha: zod.z.string(),
|
1833
1890
|
modules: zod.z.record(ModuleFilePath, zod.z.object({
|
1834
1891
|
source: zod.z.any(),
|
1835
1892
|
//.optional(), // TODO: Json zod type
|
@@ -1857,6 +1914,7 @@ var Api = {
|
|
1857
1914
|
profiles: zod.z.array(zod.z.object({
|
1858
1915
|
profileId: zod.z.string(),
|
1859
1916
|
fullName: zod.z.string(),
|
1917
|
+
email: zod.z.string().optional(),
|
1860
1918
|
avatar: zod.z.object({
|
1861
1919
|
url: zod.z.string()
|
1862
1920
|
}).nullable()
|
@@ -1968,13 +2026,14 @@ var Api = {
|
|
1968
2026
|
* Do not change this without updating the ValRouter query parsing logic
|
1969
2027
|
* */
|
1970
2028
|
|
1971
|
-
var createValClient = function createValClient(host
|
2029
|
+
var createValClient = function createValClient(host, config // We want to use this in the future
|
2030
|
+
) {
|
1972
2031
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
1973
2032
|
var anyApi = Api;
|
1974
2033
|
return /*#__PURE__*/function () {
|
1975
2034
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(path, method, req) {
|
1976
2035
|
var _anyApi$path, _apiEndpoint$req$body;
|
1977
|
-
var anyReq, fullPath, params, _i, _Object$keys, _anyReq$query, key, _anyReq$query2, _iterator, _step, value, _anyReq$query3, apiEndpoint, reqBodyResult, res;
|
2036
|
+
var anyReq, fullPath, params, _i, _Object$keys, _anyReq$query, key, _anyReq$query2, _iterator, _step, value, _anyReq$query3, _anyReq$query4, apiEndpoint, reqBodyResult, res;
|
1978
2037
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
1979
2038
|
while (1) switch (_context2.prev = _context2.next) {
|
1980
2039
|
case 0:
|
@@ -1993,7 +2052,9 @@ var createValClient = function createValClient(host) {
|
|
1993
2052
|
try {
|
1994
2053
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
1995
2054
|
value = _step.value;
|
1996
|
-
|
2055
|
+
if (value !== undefined) {
|
2056
|
+
params.push([key, value.toString()]);
|
2057
|
+
}
|
1997
2058
|
}
|
1998
2059
|
} catch (err) {
|
1999
2060
|
_iterator.e(err);
|
@@ -2001,7 +2062,9 @@ var createValClient = function createValClient(host) {
|
|
2001
2062
|
_iterator.f();
|
2002
2063
|
}
|
2003
2064
|
} else {
|
2004
|
-
|
2065
|
+
if (((_anyReq$query3 = anyReq.query) === null || _anyReq$query3 === void 0 ? void 0 : _anyReq$query3[key]) !== undefined) {
|
2066
|
+
params.push([key, anyReq === null || anyReq === void 0 || (_anyReq$query4 = anyReq.query) === null || _anyReq$query4 === void 0 ? void 0 : _anyReq$query4[key].toString()]);
|
2067
|
+
}
|
2005
2068
|
}
|
2006
2069
|
}
|
2007
2070
|
if (anyReq !== null && anyReq !== void 0 && anyReq.query && params.length > 0) {
|
@@ -2067,10 +2130,23 @@ var createValClient = function createValClient(host) {
|
|
2067
2130
|
while (1) switch (_context.prev = _context.next) {
|
2068
2131
|
case 0:
|
2069
2132
|
contentTypeHeaders = res.headers.get("content-type");
|
2070
|
-
if (
|
2133
|
+
if (!(res.status === 413)) {
|
2071
2134
|
_context.next = 3;
|
2072
2135
|
break;
|
2073
2136
|
}
|
2137
|
+
return _context.abrupt("return", {
|
2138
|
+
status: 413,
|
2139
|
+
json: {
|
2140
|
+
message: "Request too large.",
|
2141
|
+
method: method,
|
2142
|
+
path: path
|
2143
|
+
}
|
2144
|
+
});
|
2145
|
+
case 3:
|
2146
|
+
if (contentTypeHeaders !== null && contentTypeHeaders !== void 0 && contentTypeHeaders.includes("application/json")) {
|
2147
|
+
_context.next = 5;
|
2148
|
+
break;
|
2149
|
+
}
|
2074
2150
|
return _context.abrupt("return", {
|
2075
2151
|
status: null,
|
2076
2152
|
json: {
|
@@ -2085,17 +2161,17 @@ var createValClient = function createValClient(host) {
|
|
2085
2161
|
}
|
2086
2162
|
}
|
2087
2163
|
});
|
2088
|
-
case 3:
|
2089
|
-
_context.next = 5;
|
2090
|
-
return res.json();
|
2091
2164
|
case 5:
|
2165
|
+
_context.next = 7;
|
2166
|
+
return res.json();
|
2167
|
+
case 7:
|
2092
2168
|
json = _context.sent;
|
2093
2169
|
valClientResult = {
|
2094
2170
|
status: res.status,
|
2095
2171
|
json: json
|
2096
2172
|
};
|
2097
2173
|
if (!(res.status === 500)) {
|
2098
|
-
_context.next =
|
2174
|
+
_context.next = 12;
|
2099
2175
|
break;
|
2100
2176
|
}
|
2101
2177
|
console.log("Server responded with an error", json);
|
@@ -2106,10 +2182,10 @@ var createValClient = function createValClient(host) {
|
|
2106
2182
|
message: json.message
|
2107
2183
|
}, json)
|
2108
2184
|
});
|
2109
|
-
case
|
2185
|
+
case 12:
|
2110
2186
|
responseResult = (_apiEndpoint$res = apiEndpoint.res) === null || _apiEndpoint$res === void 0 ? void 0 : _apiEndpoint$res.safeParse(valClientResult);
|
2111
2187
|
if (!(responseResult && !responseResult.success)) {
|
2112
|
-
_context.next =
|
2188
|
+
_context.next = 15;
|
2113
2189
|
break;
|
2114
2190
|
}
|
2115
2191
|
return _context.abrupt("return", {
|
@@ -2123,12 +2199,12 @@ var createValClient = function createValClient(host) {
|
|
2123
2199
|
}
|
2124
2200
|
}
|
2125
2201
|
});
|
2126
|
-
case
|
2202
|
+
case 15:
|
2127
2203
|
return _context.abrupt("return", {
|
2128
2204
|
status: res.status,
|
2129
2205
|
json: json
|
2130
2206
|
});
|
2131
|
-
case
|
2207
|
+
case 16:
|
2132
2208
|
case "end":
|
2133
2209
|
return _context.stop();
|
2134
2210
|
}
|
@@ -2238,6 +2314,39 @@ var urlOf = function urlOf() {
|
|
2238
2314
|
return "".concat(route);
|
2239
2315
|
};
|
2240
2316
|
|
2317
|
+
var VAL_CONFIG_LISTENER = "val-config";
|
2318
|
+
var VAL_CONFIG_RECEIVED_LISTENER = "val-config-received";
|
2319
|
+
|
2320
|
+
var SharedValConfig = zod.z.object({
|
2321
|
+
contentHostUrl: zod.z.string().optional(),
|
2322
|
+
appHostUrl: zod.z.string().optional(),
|
2323
|
+
project: zod.z.string().optional(),
|
2324
|
+
root: zod.z.string().optional(),
|
2325
|
+
files: zod.z.object({
|
2326
|
+
directory: zod.z.literal("/public/val")
|
2327
|
+
}).optional(),
|
2328
|
+
gitCommit: zod.z.string().optional(),
|
2329
|
+
gitBranch: zod.z.string().optional(),
|
2330
|
+
defaultTheme: zod.z["enum"](["dark", "light"]).optional(),
|
2331
|
+
ai: zod.z.object({
|
2332
|
+
commitMessages: zod.z.object({
|
2333
|
+
disabled: zod.z["boolean"]().optional()
|
2334
|
+
}).optional()
|
2335
|
+
}).optional()
|
2336
|
+
});
|
2337
|
+
|
2338
|
+
/**
|
2339
|
+
* Config that is shared between the client and server.
|
2340
|
+
*/
|
2341
|
+
|
2342
|
+
var ValDeployment = zod.z.object({
|
2343
|
+
deploymentId: zod.z.string(),
|
2344
|
+
deploymentState: zod.z.string(),
|
2345
|
+
commitSha: zod.z.string(),
|
2346
|
+
updatedAt: zod.z.string(),
|
2347
|
+
createdAt: zod.z.string()
|
2348
|
+
});
|
2349
|
+
|
2241
2350
|
exports.Api = Api;
|
2242
2351
|
exports.ParentRef = ParentRef$1;
|
2243
2352
|
exports.Patch = Patch;
|
@@ -2255,9 +2364,14 @@ exports.RemirrorOrderedList = RemirrorOrderedList;
|
|
2255
2364
|
exports.RemirrorParagraph = RemirrorParagraph;
|
2256
2365
|
exports.RemirrorText = RemirrorText;
|
2257
2366
|
exports.RemirrorTextMark = RemirrorTextMark;
|
2367
|
+
exports.SharedValConfig = SharedValConfig;
|
2368
|
+
exports.VAL_CONFIG_LISTENER = VAL_CONFIG_LISTENER;
|
2369
|
+
exports.VAL_CONFIG_RECEIVED_LISTENER = VAL_CONFIG_RECEIVED_LISTENER;
|
2258
2370
|
exports.VAL_ENABLE_COOKIE_NAME = VAL_ENABLE_COOKIE_NAME;
|
2259
2371
|
exports.VAL_SESSION_COOKIE = VAL_SESSION_COOKIE;
|
2260
2372
|
exports.VAL_STATE_COOKIE = VAL_STATE_COOKIE;
|
2373
|
+
exports.ValCommit = ValCommit;
|
2374
|
+
exports.ValDeployment = ValDeployment;
|
2261
2375
|
exports.createValClient = createValClient;
|
2262
2376
|
exports.remirrorToRichTextSource = remirrorToRichTextSource;
|
2263
2377
|
exports.richTextToRemirror = richTextToRemirror;
|
@@ -1295,6 +1295,16 @@ var SerializedDateSchema = zod.z.object({
|
|
1295
1295
|
});
|
1296
1296
|
var SerializedSchema = zod.z.union([SerializedStringSchema, SerializedLiteralSchema, SerializedBooleanSchema, SerializedNumberSchema, SerializedObjectSchema, SerializedArraySchema, SerializedUnionSchema, SerializedRichTextSchema, SerializedRecordSchema, SerializedKeyOfSchema, SerializedFileSchema, SerializedDateSchema, SerializedImageSchema]);
|
1297
1297
|
|
1298
|
+
var ValCommit = zod.z.object({
|
1299
|
+
commitSha: zod.z.string(),
|
1300
|
+
clientCommitSha: zod.z.string(),
|
1301
|
+
parentCommitSha: zod.z.string(),
|
1302
|
+
branch: zod.z.string(),
|
1303
|
+
creator: zod.z.string(),
|
1304
|
+
createdAt: zod.z.string(),
|
1305
|
+
commitMessage: zod.z.string().nullable()
|
1306
|
+
});
|
1307
|
+
|
1298
1308
|
var ModuleFilePath = zod.z.string().refine(function (_path) {
|
1299
1309
|
return true;
|
1300
1310
|
} // TODO: validation
|
@@ -1573,16 +1583,56 @@ var Api = {
|
|
1573
1583
|
},
|
1574
1584
|
"/logout": {
|
1575
1585
|
GET: {
|
1576
|
-
req: {
|
1586
|
+
req: {
|
1587
|
+
query: {
|
1588
|
+
redirect_to: zod.z.string().optional()
|
1589
|
+
}
|
1590
|
+
},
|
1577
1591
|
// TODO fix req types
|
1578
|
-
res: zod.z.object({
|
1592
|
+
res: zod.z.union([zod.z.object({
|
1579
1593
|
status: zod.z.literal(200),
|
1580
1594
|
cookies: zod.z.object(_defineProperty(_defineProperty({}, VAL_SESSION_COOKIE, zod.z.object({
|
1581
|
-
value: zod.z.
|
1582
|
-
|
1583
|
-
|
1584
|
-
|
1585
|
-
|
1595
|
+
value: zod.z.string(),
|
1596
|
+
options: zod.z.object({
|
1597
|
+
httpOnly: zod.z.literal(true),
|
1598
|
+
sameSite: zod.z.literal("strict"),
|
1599
|
+
path: zod.z.string(),
|
1600
|
+
secure: zod.z.literal(true),
|
1601
|
+
expires: zod.z["instanceof"](Date)
|
1602
|
+
}).optional()
|
1603
|
+
}).optional()), VAL_STATE_COOKIE, zod.z.object({
|
1604
|
+
value: zod.z.string(),
|
1605
|
+
options: zod.z.object({
|
1606
|
+
httpOnly: zod.z.literal(true),
|
1607
|
+
sameSite: zod.z.literal("strict"),
|
1608
|
+
path: zod.z.string(),
|
1609
|
+
secure: zod.z.literal(true),
|
1610
|
+
expires: zod.z["instanceof"](Date)
|
1611
|
+
}).optional()
|
1612
|
+
}).optional()))
|
1613
|
+
}), zod.z.object({
|
1614
|
+
status: zod.z.literal(302),
|
1615
|
+
redirectTo: zod.z.string(),
|
1616
|
+
cookies: zod.z.object(_defineProperty(_defineProperty({}, VAL_SESSION_COOKIE, zod.z.object({
|
1617
|
+
value: zod.z.string(),
|
1618
|
+
options: zod.z.object({
|
1619
|
+
httpOnly: zod.z.literal(true),
|
1620
|
+
sameSite: zod.z.literal("strict"),
|
1621
|
+
path: zod.z.string(),
|
1622
|
+
secure: zod.z.literal(true),
|
1623
|
+
expires: zod.z["instanceof"](Date)
|
1624
|
+
}).optional()
|
1625
|
+
}).optional()), VAL_STATE_COOKIE, zod.z.object({
|
1626
|
+
value: zod.z.string(),
|
1627
|
+
options: zod.z.object({
|
1628
|
+
httpOnly: zod.z.literal(true),
|
1629
|
+
sameSite: zod.z.literal("strict"),
|
1630
|
+
path: zod.z.string(),
|
1631
|
+
secure: zod.z.literal(true),
|
1632
|
+
expires: zod.z["instanceof"](Date)
|
1633
|
+
}).optional()
|
1634
|
+
}).optional()))
|
1635
|
+
})])
|
1586
1636
|
}
|
1587
1637
|
},
|
1588
1638
|
"/remote/settings": {
|
@@ -1625,6 +1675,7 @@ var Api = {
|
|
1625
1675
|
POST: {
|
1626
1676
|
req: {
|
1627
1677
|
body: zod.z.object({
|
1678
|
+
sourcesSha: zod.z.string(),
|
1628
1679
|
schemaSha: zod.z.string(),
|
1629
1680
|
baseSha: zod.z.string(),
|
1630
1681
|
patches: zod.z.array(zod.z.string()).optional()
|
@@ -1648,19 +1699,24 @@ var Api = {
|
|
1648
1699
|
type: zod.z.union([zod.z.literal("request-again"), zod.z.literal("no-change"), zod.z.literal("did-change")]),
|
1649
1700
|
baseSha: zod.z.string(),
|
1650
1701
|
schemaSha: zod.z.string(),
|
1702
|
+
sourcesSha: zod.z.string(),
|
1651
1703
|
patches: zod.z.array(PatchId),
|
1652
1704
|
config: ValConfig,
|
1653
|
-
|
1705
|
+
profileId: zod.z.string().nullable(),
|
1706
|
+
mode: zod.z.union([zod.z.literal("http"), zod.z.literal("fs")])
|
1654
1707
|
}), zod.z.object({
|
1655
1708
|
type: zod.z.literal("use-websocket"),
|
1656
1709
|
url: zod.z.string(),
|
1657
1710
|
nonce: zod.z.string(),
|
1658
1711
|
baseSha: zod.z.string(),
|
1659
1712
|
schemaSha: zod.z.string(),
|
1713
|
+
sourcesSha: zod.z.string(),
|
1660
1714
|
commitSha: zod.z.string(),
|
1661
1715
|
patches: zod.z.array(PatchId),
|
1716
|
+
commits: zod.z.array(ValCommit),
|
1662
1717
|
config: ValConfig,
|
1663
|
-
|
1718
|
+
profileId: zod.z.string().nullable(),
|
1719
|
+
mode: zod.z.union([zod.z.literal("http"), zod.z.literal("fs")])
|
1664
1720
|
})])
|
1665
1721
|
})])
|
1666
1722
|
}
|
@@ -1692,6 +1748,7 @@ var Api = {
|
|
1692
1748
|
parentRef: ParentRef,
|
1693
1749
|
patches: zod.z.array(zod.z.object({
|
1694
1750
|
path: ModuleFilePath,
|
1751
|
+
patchId: PatchId,
|
1695
1752
|
patch: Patch
|
1696
1753
|
}))
|
1697
1754
|
}),
|
@@ -1798,7 +1855,6 @@ var Api = {
|
|
1798
1855
|
req: {
|
1799
1856
|
path: zod.z.string().optional(),
|
1800
1857
|
query: {
|
1801
|
-
validate_all: zod.z["boolean"]().optional(),
|
1802
1858
|
validate_sources: zod.z["boolean"]().optional(),
|
1803
1859
|
validate_binary_files: zod.z["boolean"]().optional()
|
1804
1860
|
},
|
@@ -1830,6 +1886,7 @@ var Api = {
|
|
1830
1886
|
status: zod.z.literal(200),
|
1831
1887
|
json: zod.z.object({
|
1832
1888
|
schemaSha: zod.z.string(),
|
1889
|
+
sourcesSha: zod.z.string(),
|
1833
1890
|
modules: zod.z.record(ModuleFilePath, zod.z.object({
|
1834
1891
|
source: zod.z.any(),
|
1835
1892
|
//.optional(), // TODO: Json zod type
|
@@ -1857,6 +1914,7 @@ var Api = {
|
|
1857
1914
|
profiles: zod.z.array(zod.z.object({
|
1858
1915
|
profileId: zod.z.string(),
|
1859
1916
|
fullName: zod.z.string(),
|
1917
|
+
email: zod.z.string().optional(),
|
1860
1918
|
avatar: zod.z.object({
|
1861
1919
|
url: zod.z.string()
|
1862
1920
|
}).nullable()
|
@@ -1968,13 +2026,14 @@ var Api = {
|
|
1968
2026
|
* Do not change this without updating the ValRouter query parsing logic
|
1969
2027
|
* */
|
1970
2028
|
|
1971
|
-
var createValClient = function createValClient(host
|
2029
|
+
var createValClient = function createValClient(host, config // We want to use this in the future
|
2030
|
+
) {
|
1972
2031
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
1973
2032
|
var anyApi = Api;
|
1974
2033
|
return /*#__PURE__*/function () {
|
1975
2034
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(path, method, req) {
|
1976
2035
|
var _anyApi$path, _apiEndpoint$req$body;
|
1977
|
-
var anyReq, fullPath, params, _i, _Object$keys, _anyReq$query, key, _anyReq$query2, _iterator, _step, value, _anyReq$query3, apiEndpoint, reqBodyResult, res;
|
2036
|
+
var anyReq, fullPath, params, _i, _Object$keys, _anyReq$query, key, _anyReq$query2, _iterator, _step, value, _anyReq$query3, _anyReq$query4, apiEndpoint, reqBodyResult, res;
|
1978
2037
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
1979
2038
|
while (1) switch (_context2.prev = _context2.next) {
|
1980
2039
|
case 0:
|
@@ -1993,7 +2052,9 @@ var createValClient = function createValClient(host) {
|
|
1993
2052
|
try {
|
1994
2053
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
1995
2054
|
value = _step.value;
|
1996
|
-
|
2055
|
+
if (value !== undefined) {
|
2056
|
+
params.push([key, value.toString()]);
|
2057
|
+
}
|
1997
2058
|
}
|
1998
2059
|
} catch (err) {
|
1999
2060
|
_iterator.e(err);
|
@@ -2001,7 +2062,9 @@ var createValClient = function createValClient(host) {
|
|
2001
2062
|
_iterator.f();
|
2002
2063
|
}
|
2003
2064
|
} else {
|
2004
|
-
|
2065
|
+
if (((_anyReq$query3 = anyReq.query) === null || _anyReq$query3 === void 0 ? void 0 : _anyReq$query3[key]) !== undefined) {
|
2066
|
+
params.push([key, anyReq === null || anyReq === void 0 || (_anyReq$query4 = anyReq.query) === null || _anyReq$query4 === void 0 ? void 0 : _anyReq$query4[key].toString()]);
|
2067
|
+
}
|
2005
2068
|
}
|
2006
2069
|
}
|
2007
2070
|
if (anyReq !== null && anyReq !== void 0 && anyReq.query && params.length > 0) {
|
@@ -2067,10 +2130,23 @@ var createValClient = function createValClient(host) {
|
|
2067
2130
|
while (1) switch (_context.prev = _context.next) {
|
2068
2131
|
case 0:
|
2069
2132
|
contentTypeHeaders = res.headers.get("content-type");
|
2070
|
-
if (
|
2133
|
+
if (!(res.status === 413)) {
|
2071
2134
|
_context.next = 3;
|
2072
2135
|
break;
|
2073
2136
|
}
|
2137
|
+
return _context.abrupt("return", {
|
2138
|
+
status: 413,
|
2139
|
+
json: {
|
2140
|
+
message: "Request too large.",
|
2141
|
+
method: method,
|
2142
|
+
path: path
|
2143
|
+
}
|
2144
|
+
});
|
2145
|
+
case 3:
|
2146
|
+
if (contentTypeHeaders !== null && contentTypeHeaders !== void 0 && contentTypeHeaders.includes("application/json")) {
|
2147
|
+
_context.next = 5;
|
2148
|
+
break;
|
2149
|
+
}
|
2074
2150
|
return _context.abrupt("return", {
|
2075
2151
|
status: null,
|
2076
2152
|
json: {
|
@@ -2085,17 +2161,17 @@ var createValClient = function createValClient(host) {
|
|
2085
2161
|
}
|
2086
2162
|
}
|
2087
2163
|
});
|
2088
|
-
case 3:
|
2089
|
-
_context.next = 5;
|
2090
|
-
return res.json();
|
2091
2164
|
case 5:
|
2165
|
+
_context.next = 7;
|
2166
|
+
return res.json();
|
2167
|
+
case 7:
|
2092
2168
|
json = _context.sent;
|
2093
2169
|
valClientResult = {
|
2094
2170
|
status: res.status,
|
2095
2171
|
json: json
|
2096
2172
|
};
|
2097
2173
|
if (!(res.status === 500)) {
|
2098
|
-
_context.next =
|
2174
|
+
_context.next = 12;
|
2099
2175
|
break;
|
2100
2176
|
}
|
2101
2177
|
console.log("Server responded with an error", json);
|
@@ -2106,10 +2182,10 @@ var createValClient = function createValClient(host) {
|
|
2106
2182
|
message: json.message
|
2107
2183
|
}, json)
|
2108
2184
|
});
|
2109
|
-
case
|
2185
|
+
case 12:
|
2110
2186
|
responseResult = (_apiEndpoint$res = apiEndpoint.res) === null || _apiEndpoint$res === void 0 ? void 0 : _apiEndpoint$res.safeParse(valClientResult);
|
2111
2187
|
if (!(responseResult && !responseResult.success)) {
|
2112
|
-
_context.next =
|
2188
|
+
_context.next = 15;
|
2113
2189
|
break;
|
2114
2190
|
}
|
2115
2191
|
return _context.abrupt("return", {
|
@@ -2123,12 +2199,12 @@ var createValClient = function createValClient(host) {
|
|
2123
2199
|
}
|
2124
2200
|
}
|
2125
2201
|
});
|
2126
|
-
case
|
2202
|
+
case 15:
|
2127
2203
|
return _context.abrupt("return", {
|
2128
2204
|
status: res.status,
|
2129
2205
|
json: json
|
2130
2206
|
});
|
2131
|
-
case
|
2207
|
+
case 16:
|
2132
2208
|
case "end":
|
2133
2209
|
return _context.stop();
|
2134
2210
|
}
|
@@ -2238,6 +2314,39 @@ var urlOf = function urlOf() {
|
|
2238
2314
|
return "".concat(route);
|
2239
2315
|
};
|
2240
2316
|
|
2317
|
+
var VAL_CONFIG_LISTENER = "val-config";
|
2318
|
+
var VAL_CONFIG_RECEIVED_LISTENER = "val-config-received";
|
2319
|
+
|
2320
|
+
var SharedValConfig = zod.z.object({
|
2321
|
+
contentHostUrl: zod.z.string().optional(),
|
2322
|
+
appHostUrl: zod.z.string().optional(),
|
2323
|
+
project: zod.z.string().optional(),
|
2324
|
+
root: zod.z.string().optional(),
|
2325
|
+
files: zod.z.object({
|
2326
|
+
directory: zod.z.literal("/public/val")
|
2327
|
+
}).optional(),
|
2328
|
+
gitCommit: zod.z.string().optional(),
|
2329
|
+
gitBranch: zod.z.string().optional(),
|
2330
|
+
defaultTheme: zod.z["enum"](["dark", "light"]).optional(),
|
2331
|
+
ai: zod.z.object({
|
2332
|
+
commitMessages: zod.z.object({
|
2333
|
+
disabled: zod.z["boolean"]().optional()
|
2334
|
+
}).optional()
|
2335
|
+
}).optional()
|
2336
|
+
});
|
2337
|
+
|
2338
|
+
/**
|
2339
|
+
* Config that is shared between the client and server.
|
2340
|
+
*/
|
2341
|
+
|
2342
|
+
var ValDeployment = zod.z.object({
|
2343
|
+
deploymentId: zod.z.string(),
|
2344
|
+
deploymentState: zod.z.string(),
|
2345
|
+
commitSha: zod.z.string(),
|
2346
|
+
updatedAt: zod.z.string(),
|
2347
|
+
createdAt: zod.z.string()
|
2348
|
+
});
|
2349
|
+
|
2241
2350
|
exports.Api = Api;
|
2242
2351
|
exports.ParentRef = ParentRef$1;
|
2243
2352
|
exports.Patch = Patch;
|
@@ -2255,9 +2364,14 @@ exports.RemirrorOrderedList = RemirrorOrderedList;
|
|
2255
2364
|
exports.RemirrorParagraph = RemirrorParagraph;
|
2256
2365
|
exports.RemirrorText = RemirrorText;
|
2257
2366
|
exports.RemirrorTextMark = RemirrorTextMark;
|
2367
|
+
exports.SharedValConfig = SharedValConfig;
|
2368
|
+
exports.VAL_CONFIG_LISTENER = VAL_CONFIG_LISTENER;
|
2369
|
+
exports.VAL_CONFIG_RECEIVED_LISTENER = VAL_CONFIG_RECEIVED_LISTENER;
|
2258
2370
|
exports.VAL_ENABLE_COOKIE_NAME = VAL_ENABLE_COOKIE_NAME;
|
2259
2371
|
exports.VAL_SESSION_COOKIE = VAL_SESSION_COOKIE;
|
2260
2372
|
exports.VAL_STATE_COOKIE = VAL_STATE_COOKIE;
|
2373
|
+
exports.ValCommit = ValCommit;
|
2374
|
+
exports.ValDeployment = ValDeployment;
|
2261
2375
|
exports.createValClient = createValClient;
|
2262
2376
|
exports.remirrorToRichTextSource = remirrorToRichTextSource;
|
2263
2377
|
exports.richTextToRemirror = richTextToRemirror;
|