@valbuild/shared 0.74.0 → 0.75.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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
@@ -1291,6 +1291,16 @@ var SerializedDateSchema = z.object({
|
|
1291
1291
|
});
|
1292
1292
|
var SerializedSchema = z.union([SerializedStringSchema, SerializedLiteralSchema, SerializedBooleanSchema, SerializedNumberSchema, SerializedObjectSchema, SerializedArraySchema, SerializedUnionSchema, SerializedRichTextSchema, SerializedRecordSchema, SerializedKeyOfSchema, SerializedFileSchema, SerializedDateSchema, SerializedImageSchema]);
|
1293
1293
|
|
1294
|
+
var ValCommit = z.object({
|
1295
|
+
commitSha: z.string(),
|
1296
|
+
clientCommitSha: z.string(),
|
1297
|
+
parentCommitSha: z.string(),
|
1298
|
+
branch: z.string(),
|
1299
|
+
creator: z.string(),
|
1300
|
+
createdAt: z.string(),
|
1301
|
+
commitMessage: z.string().nullable()
|
1302
|
+
});
|
1303
|
+
|
1294
1304
|
var ModuleFilePath = z.string().refine(function (_path) {
|
1295
1305
|
return true;
|
1296
1306
|
} // TODO: validation
|
@@ -1569,16 +1579,56 @@ var Api = {
|
|
1569
1579
|
},
|
1570
1580
|
"/logout": {
|
1571
1581
|
GET: {
|
1572
|
-
req: {
|
1582
|
+
req: {
|
1583
|
+
query: {
|
1584
|
+
redirect_to: z.string().optional()
|
1585
|
+
}
|
1586
|
+
},
|
1573
1587
|
// TODO fix req types
|
1574
|
-
res: z.object({
|
1588
|
+
res: z.union([z.object({
|
1575
1589
|
status: z.literal(200),
|
1576
1590
|
cookies: z.object(_defineProperty(_defineProperty({}, VAL_SESSION_COOKIE, z.object({
|
1577
|
-
value: z.
|
1578
|
-
|
1579
|
-
|
1580
|
-
|
1581
|
-
|
1591
|
+
value: z.string(),
|
1592
|
+
options: z.object({
|
1593
|
+
httpOnly: z.literal(true),
|
1594
|
+
sameSite: z.literal("strict"),
|
1595
|
+
path: z.string(),
|
1596
|
+
secure: z.literal(true),
|
1597
|
+
expires: z["instanceof"](Date)
|
1598
|
+
}).optional()
|
1599
|
+
}).optional()), VAL_STATE_COOKIE, z.object({
|
1600
|
+
value: z.string(),
|
1601
|
+
options: z.object({
|
1602
|
+
httpOnly: z.literal(true),
|
1603
|
+
sameSite: z.literal("strict"),
|
1604
|
+
path: z.string(),
|
1605
|
+
secure: z.literal(true),
|
1606
|
+
expires: z["instanceof"](Date)
|
1607
|
+
}).optional()
|
1608
|
+
}).optional()))
|
1609
|
+
}), z.object({
|
1610
|
+
status: z.literal(302),
|
1611
|
+
redirectTo: z.string(),
|
1612
|
+
cookies: z.object(_defineProperty(_defineProperty({}, VAL_SESSION_COOKIE, z.object({
|
1613
|
+
value: z.string(),
|
1614
|
+
options: z.object({
|
1615
|
+
httpOnly: z.literal(true),
|
1616
|
+
sameSite: z.literal("strict"),
|
1617
|
+
path: z.string(),
|
1618
|
+
secure: z.literal(true),
|
1619
|
+
expires: z["instanceof"](Date)
|
1620
|
+
}).optional()
|
1621
|
+
}).optional()), VAL_STATE_COOKIE, z.object({
|
1622
|
+
value: z.string(),
|
1623
|
+
options: z.object({
|
1624
|
+
httpOnly: z.literal(true),
|
1625
|
+
sameSite: z.literal("strict"),
|
1626
|
+
path: z.string(),
|
1627
|
+
secure: z.literal(true),
|
1628
|
+
expires: z["instanceof"](Date)
|
1629
|
+
}).optional()
|
1630
|
+
}).optional()))
|
1631
|
+
})])
|
1582
1632
|
}
|
1583
1633
|
},
|
1584
1634
|
"/remote/settings": {
|
@@ -1621,6 +1671,7 @@ var Api = {
|
|
1621
1671
|
POST: {
|
1622
1672
|
req: {
|
1623
1673
|
body: z.object({
|
1674
|
+
sourcesSha: z.string(),
|
1624
1675
|
schemaSha: z.string(),
|
1625
1676
|
baseSha: z.string(),
|
1626
1677
|
patches: z.array(z.string()).optional()
|
@@ -1644,19 +1695,24 @@ var Api = {
|
|
1644
1695
|
type: z.union([z.literal("request-again"), z.literal("no-change"), z.literal("did-change")]),
|
1645
1696
|
baseSha: z.string(),
|
1646
1697
|
schemaSha: z.string(),
|
1698
|
+
sourcesSha: z.string(),
|
1647
1699
|
patches: z.array(PatchId),
|
1648
1700
|
config: ValConfig,
|
1649
|
-
|
1701
|
+
profileId: z.string().nullable(),
|
1702
|
+
mode: z.union([z.literal("http"), z.literal("fs")])
|
1650
1703
|
}), z.object({
|
1651
1704
|
type: z.literal("use-websocket"),
|
1652
1705
|
url: z.string(),
|
1653
1706
|
nonce: z.string(),
|
1654
1707
|
baseSha: z.string(),
|
1655
1708
|
schemaSha: z.string(),
|
1709
|
+
sourcesSha: z.string(),
|
1656
1710
|
commitSha: z.string(),
|
1657
1711
|
patches: z.array(PatchId),
|
1712
|
+
commits: z.array(ValCommit),
|
1658
1713
|
config: ValConfig,
|
1659
|
-
|
1714
|
+
profileId: z.string().nullable(),
|
1715
|
+
mode: z.union([z.literal("http"), z.literal("fs")])
|
1660
1716
|
})])
|
1661
1717
|
})])
|
1662
1718
|
}
|
@@ -1688,6 +1744,7 @@ var Api = {
|
|
1688
1744
|
parentRef: ParentRef,
|
1689
1745
|
patches: z.array(z.object({
|
1690
1746
|
path: ModuleFilePath,
|
1747
|
+
patchId: PatchId,
|
1691
1748
|
patch: Patch
|
1692
1749
|
}))
|
1693
1750
|
}),
|
@@ -1794,7 +1851,6 @@ var Api = {
|
|
1794
1851
|
req: {
|
1795
1852
|
path: z.string().optional(),
|
1796
1853
|
query: {
|
1797
|
-
validate_all: z["boolean"]().optional(),
|
1798
1854
|
validate_sources: z["boolean"]().optional(),
|
1799
1855
|
validate_binary_files: z["boolean"]().optional()
|
1800
1856
|
},
|
@@ -1826,6 +1882,7 @@ var Api = {
|
|
1826
1882
|
status: z.literal(200),
|
1827
1883
|
json: z.object({
|
1828
1884
|
schemaSha: z.string(),
|
1885
|
+
sourcesSha: z.string(),
|
1829
1886
|
modules: z.record(ModuleFilePath, z.object({
|
1830
1887
|
source: z.any(),
|
1831
1888
|
//.optional(), // TODO: Json zod type
|
@@ -1853,6 +1910,7 @@ var Api = {
|
|
1853
1910
|
profiles: z.array(z.object({
|
1854
1911
|
profileId: z.string(),
|
1855
1912
|
fullName: z.string(),
|
1913
|
+
email: z.string().optional(),
|
1856
1914
|
avatar: z.object({
|
1857
1915
|
url: z.string()
|
1858
1916
|
}).nullable()
|
@@ -1964,13 +2022,14 @@ var Api = {
|
|
1964
2022
|
* Do not change this without updating the ValRouter query parsing logic
|
1965
2023
|
* */
|
1966
2024
|
|
1967
|
-
var createValClient = function createValClient(host
|
2025
|
+
var createValClient = function createValClient(host, config // We want to use this in the future
|
2026
|
+
) {
|
1968
2027
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
1969
2028
|
var anyApi = Api;
|
1970
2029
|
return /*#__PURE__*/function () {
|
1971
2030
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(path, method, req) {
|
1972
2031
|
var _anyApi$path, _apiEndpoint$req$body;
|
1973
|
-
var anyReq, fullPath, params, _i, _Object$keys, _anyReq$query, key, _anyReq$query2, _iterator, _step, value, _anyReq$query3, apiEndpoint, reqBodyResult, res;
|
2032
|
+
var anyReq, fullPath, params, _i, _Object$keys, _anyReq$query, key, _anyReq$query2, _iterator, _step, value, _anyReq$query3, _anyReq$query4, apiEndpoint, reqBodyResult, res;
|
1974
2033
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
1975
2034
|
while (1) switch (_context2.prev = _context2.next) {
|
1976
2035
|
case 0:
|
@@ -1989,7 +2048,9 @@ var createValClient = function createValClient(host) {
|
|
1989
2048
|
try {
|
1990
2049
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
1991
2050
|
value = _step.value;
|
1992
|
-
|
2051
|
+
if (value !== undefined) {
|
2052
|
+
params.push([key, value.toString()]);
|
2053
|
+
}
|
1993
2054
|
}
|
1994
2055
|
} catch (err) {
|
1995
2056
|
_iterator.e(err);
|
@@ -1997,7 +2058,9 @@ var createValClient = function createValClient(host) {
|
|
1997
2058
|
_iterator.f();
|
1998
2059
|
}
|
1999
2060
|
} else {
|
2000
|
-
|
2061
|
+
if (((_anyReq$query3 = anyReq.query) === null || _anyReq$query3 === void 0 ? void 0 : _anyReq$query3[key]) !== undefined) {
|
2062
|
+
params.push([key, anyReq === null || anyReq === void 0 || (_anyReq$query4 = anyReq.query) === null || _anyReq$query4 === void 0 ? void 0 : _anyReq$query4[key].toString()]);
|
2063
|
+
}
|
2001
2064
|
}
|
2002
2065
|
}
|
2003
2066
|
if (anyReq !== null && anyReq !== void 0 && anyReq.query && params.length > 0) {
|
@@ -2063,10 +2126,23 @@ var createValClient = function createValClient(host) {
|
|
2063
2126
|
while (1) switch (_context.prev = _context.next) {
|
2064
2127
|
case 0:
|
2065
2128
|
contentTypeHeaders = res.headers.get("content-type");
|
2066
|
-
if (
|
2129
|
+
if (!(res.status === 413)) {
|
2067
2130
|
_context.next = 3;
|
2068
2131
|
break;
|
2069
2132
|
}
|
2133
|
+
return _context.abrupt("return", {
|
2134
|
+
status: 413,
|
2135
|
+
json: {
|
2136
|
+
message: "Request too large.",
|
2137
|
+
method: method,
|
2138
|
+
path: path
|
2139
|
+
}
|
2140
|
+
});
|
2141
|
+
case 3:
|
2142
|
+
if (contentTypeHeaders !== null && contentTypeHeaders !== void 0 && contentTypeHeaders.includes("application/json")) {
|
2143
|
+
_context.next = 5;
|
2144
|
+
break;
|
2145
|
+
}
|
2070
2146
|
return _context.abrupt("return", {
|
2071
2147
|
status: null,
|
2072
2148
|
json: {
|
@@ -2081,17 +2157,17 @@ var createValClient = function createValClient(host) {
|
|
2081
2157
|
}
|
2082
2158
|
}
|
2083
2159
|
});
|
2084
|
-
case 3:
|
2085
|
-
_context.next = 5;
|
2086
|
-
return res.json();
|
2087
2160
|
case 5:
|
2161
|
+
_context.next = 7;
|
2162
|
+
return res.json();
|
2163
|
+
case 7:
|
2088
2164
|
json = _context.sent;
|
2089
2165
|
valClientResult = {
|
2090
2166
|
status: res.status,
|
2091
2167
|
json: json
|
2092
2168
|
};
|
2093
2169
|
if (!(res.status === 500)) {
|
2094
|
-
_context.next =
|
2170
|
+
_context.next = 12;
|
2095
2171
|
break;
|
2096
2172
|
}
|
2097
2173
|
console.log("Server responded with an error", json);
|
@@ -2102,10 +2178,10 @@ var createValClient = function createValClient(host) {
|
|
2102
2178
|
message: json.message
|
2103
2179
|
}, json)
|
2104
2180
|
});
|
2105
|
-
case
|
2181
|
+
case 12:
|
2106
2182
|
responseResult = (_apiEndpoint$res = apiEndpoint.res) === null || _apiEndpoint$res === void 0 ? void 0 : _apiEndpoint$res.safeParse(valClientResult);
|
2107
2183
|
if (!(responseResult && !responseResult.success)) {
|
2108
|
-
_context.next =
|
2184
|
+
_context.next = 15;
|
2109
2185
|
break;
|
2110
2186
|
}
|
2111
2187
|
return _context.abrupt("return", {
|
@@ -2119,12 +2195,12 @@ var createValClient = function createValClient(host) {
|
|
2119
2195
|
}
|
2120
2196
|
}
|
2121
2197
|
});
|
2122
|
-
case
|
2198
|
+
case 15:
|
2123
2199
|
return _context.abrupt("return", {
|
2124
2200
|
status: res.status,
|
2125
2201
|
json: json
|
2126
2202
|
});
|
2127
|
-
case
|
2203
|
+
case 16:
|
2128
2204
|
case "end":
|
2129
2205
|
return _context.stop();
|
2130
2206
|
}
|
@@ -2234,4 +2310,37 @@ var urlOf = function urlOf() {
|
|
2234
2310
|
return "".concat(route);
|
2235
2311
|
};
|
2236
2312
|
|
2237
|
-
|
2313
|
+
var VAL_CONFIG_LISTENER = "val-config";
|
2314
|
+
var VAL_CONFIG_RECEIVED_LISTENER = "val-config-received";
|
2315
|
+
|
2316
|
+
var SharedValConfig = z.object({
|
2317
|
+
contentHostUrl: z.string().optional(),
|
2318
|
+
appHostUrl: z.string().optional(),
|
2319
|
+
project: z.string().optional(),
|
2320
|
+
root: z.string().optional(),
|
2321
|
+
files: z.object({
|
2322
|
+
directory: z.literal("/public/val")
|
2323
|
+
}).optional(),
|
2324
|
+
gitCommit: z.string().optional(),
|
2325
|
+
gitBranch: z.string().optional(),
|
2326
|
+
defaultTheme: z["enum"](["dark", "light"]).optional(),
|
2327
|
+
ai: z.object({
|
2328
|
+
commitMessages: z.object({
|
2329
|
+
disabled: z["boolean"]().optional()
|
2330
|
+
}).optional()
|
2331
|
+
}).optional()
|
2332
|
+
});
|
2333
|
+
|
2334
|
+
/**
|
2335
|
+
* Config that is shared between the client and server.
|
2336
|
+
*/
|
2337
|
+
|
2338
|
+
var ValDeployment = z.object({
|
2339
|
+
deploymentId: z.string(),
|
2340
|
+
deploymentState: z.string(),
|
2341
|
+
commitSha: z.string(),
|
2342
|
+
updatedAt: z.string(),
|
2343
|
+
createdAt: z.string()
|
2344
|
+
});
|
2345
|
+
|
2346
|
+
export { Api, ParentRef$1 as ParentRef, Patch, PatchBlock, PatchId, PatchJSON, RemirrorBr, RemirrorBulletList, RemirrorHeading, RemirrorImage, RemirrorJSON, RemirrorLinkMark, RemirrorListItem, RemirrorOrderedList, RemirrorParagraph, RemirrorText, RemirrorTextMark, SharedValConfig, VAL_CONFIG_LISTENER, VAL_CONFIG_RECEIVED_LISTENER, VAL_ENABLE_COOKIE_NAME, VAL_SESSION_COOKIE, VAL_STATE_COOKIE, ValCommit, ValDeployment, createValClient, remirrorToRichTextSource, richTextToRemirror, urlOf };
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@valbuild/shared",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.75.1",
|
4
4
|
"private": false,
|
5
5
|
"description": "Val shared types and utilities",
|
6
6
|
"scripts": {
|
@@ -29,7 +29,7 @@
|
|
29
29
|
"exports": true
|
30
30
|
},
|
31
31
|
"dependencies": {
|
32
|
-
"@valbuild/core": "~0.
|
32
|
+
"@valbuild/core": "~0.75.1",
|
33
33
|
"zod": "^3.22.4",
|
34
34
|
"zod-validation-error": "^3.3.0"
|
35
35
|
},
|