@valbuild/shared 0.94.0 → 0.95.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.
@@ -573,6 +573,7 @@ export declare const Api: {
573
573
  type: z.ZodLiteral<"patch">;
574
574
  patchId: z.ZodString & z.ZodType<import("@valbuild/core").PatchId, string, z.core.$ZodTypeInternals<import("@valbuild/core").PatchId, string>>;
575
575
  }, z.core.$strip>]>;
576
+ sessionId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
576
577
  patches: z.ZodArray<z.ZodObject<{
577
578
  path: z.ZodString & z.ZodType<ModuleFilePath, string, z.core.$ZodTypeInternals<ModuleFilePath, string>>;
578
579
  patchId: z.ZodString & z.ZodType<import("@valbuild/core").PatchId, string, z.core.$ZodTypeInternals<import("@valbuild/core").PatchId, string>>;
@@ -833,6 +834,11 @@ export declare const Api: {
833
834
  json: z.ZodObject<{
834
835
  message: z.ZodString;
835
836
  }, z.core.$strip>;
837
+ }, z.core.$strip>, z.ZodObject<{
838
+ status: z.ZodLiteral<500>;
839
+ json: z.ZodObject<{
840
+ message: z.ZodString;
841
+ }, z.core.$strip>;
836
842
  }, z.core.$strip>, z.ZodObject<{
837
843
  status: z.ZodLiteral<200>;
838
844
  json: z.ZodObject<{
@@ -953,6 +959,129 @@ export declare const Api: {
953
959
  }, z.core.$strip>]>;
954
960
  };
955
961
  };
962
+ "/ai/initialize": {
963
+ POST: {
964
+ req: {
965
+ cookies: {
966
+ val_session: z.ZodOptional<z.ZodString>;
967
+ };
968
+ };
969
+ res: z.ZodUnion<readonly [z.ZodObject<{
970
+ status: z.ZodLiteral<401>;
971
+ json: z.ZodObject<{
972
+ message: z.ZodString;
973
+ }, z.core.$strip>;
974
+ }, z.core.$strip>, z.ZodObject<{
975
+ status: z.ZodLiteral<200>;
976
+ json: z.ZodObject<{
977
+ nonce: z.ZodString;
978
+ wsUrl: z.ZodString;
979
+ }, z.core.$strip>;
980
+ }, z.core.$strip>, z.ZodObject<{
981
+ status: z.ZodLiteral<500>;
982
+ json: z.ZodObject<{
983
+ message: z.ZodString;
984
+ }, z.core.$strip>;
985
+ }, z.core.$strip>]>;
986
+ };
987
+ };
988
+ "/ai/sessions": {
989
+ GET: {
990
+ req: {
991
+ query: {
992
+ limit: z.ZodOptional<z.ZodPipe<z.ZodArray<z.ZodString>, z.ZodTransform<string, string[]>>>;
993
+ cursor_updatedAt: z.ZodOptional<z.ZodPipe<z.ZodArray<z.ZodString>, z.ZodTransform<string, string[]>>>;
994
+ cursor_id: z.ZodOptional<z.ZodPipe<z.ZodArray<z.ZodString>, z.ZodTransform<string, string[]>>>;
995
+ };
996
+ cookies: {
997
+ val_session: z.ZodOptional<z.ZodString>;
998
+ };
999
+ };
1000
+ res: z.ZodUnion<readonly [z.ZodObject<{
1001
+ status: z.ZodLiteral<401>;
1002
+ json: z.ZodObject<{
1003
+ message: z.ZodString;
1004
+ }, z.core.$strip>;
1005
+ }, z.core.$strip>, z.ZodObject<{
1006
+ status: z.ZodLiteral<200>;
1007
+ json: z.ZodObject<{
1008
+ sessions: z.ZodArray<z.ZodObject<{
1009
+ id: z.ZodString;
1010
+ name: z.ZodNullable<z.ZodString>;
1011
+ createdAt: z.ZodString;
1012
+ updatedAt: z.ZodString;
1013
+ }, z.core.$strip>>;
1014
+ nextCursor: z.ZodOptional<z.ZodNullable<z.ZodObject<{
1015
+ updatedAt: z.ZodString;
1016
+ id: z.ZodString;
1017
+ }, z.core.$strip>>>;
1018
+ }, z.core.$strip>;
1019
+ }, z.core.$strip>, z.ZodObject<{
1020
+ status: z.ZodLiteral<500>;
1021
+ json: z.ZodObject<{
1022
+ message: z.ZodString;
1023
+ }, z.core.$strip>;
1024
+ }, z.core.$strip>]>;
1025
+ };
1026
+ PATCH: {
1027
+ req: {
1028
+ path: z.ZodString;
1029
+ body: z.ZodObject<{
1030
+ name: z.ZodString;
1031
+ }, z.core.$strip>;
1032
+ cookies: {
1033
+ val_session: z.ZodOptional<z.ZodString>;
1034
+ };
1035
+ };
1036
+ res: z.ZodUnion<readonly [z.ZodObject<{
1037
+ status: z.ZodLiteral<401>;
1038
+ json: z.ZodObject<{
1039
+ message: z.ZodString;
1040
+ }, z.core.$strip>;
1041
+ }, z.core.$strip>, z.ZodObject<{
1042
+ status: z.ZodLiteral<200>;
1043
+ json: z.ZodObject<{}, z.core.$strip>;
1044
+ }, z.core.$strip>, z.ZodObject<{
1045
+ status: z.ZodLiteral<500>;
1046
+ json: z.ZodObject<{
1047
+ message: z.ZodString;
1048
+ }, z.core.$strip>;
1049
+ }, z.core.$strip>]>;
1050
+ };
1051
+ };
1052
+ "/ai/messages": {
1053
+ GET: {
1054
+ req: {
1055
+ path: z.ZodString;
1056
+ cookies: {
1057
+ val_session: z.ZodOptional<z.ZodString>;
1058
+ };
1059
+ };
1060
+ res: z.ZodUnion<readonly [z.ZodObject<{
1061
+ status: z.ZodLiteral<401>;
1062
+ json: z.ZodObject<{
1063
+ message: z.ZodString;
1064
+ }, z.core.$strip>;
1065
+ }, z.core.$strip>, z.ZodObject<{
1066
+ status: z.ZodLiteral<200>;
1067
+ json: z.ZodObject<{
1068
+ messages: z.ZodArray<z.ZodObject<{
1069
+ role: z.ZodString;
1070
+ content: z.ZodString;
1071
+ }, z.core.$strip>>;
1072
+ nextCursor: z.ZodOptional<z.ZodNullable<z.ZodObject<{
1073
+ updatedAt: z.ZodString;
1074
+ id: z.ZodString;
1075
+ }, z.core.$strip>>>;
1076
+ }, z.core.$strip>;
1077
+ }, z.core.$strip>, z.ZodObject<{
1078
+ status: z.ZodLiteral<500>;
1079
+ json: z.ZodObject<{
1080
+ message: z.ZodString;
1081
+ }, z.core.$strip>;
1082
+ }, z.core.$strip>]>;
1083
+ };
1084
+ };
956
1085
  };
957
1086
  /**
958
1087
  * Extracts the keys of an object where the value is not undefined.
@@ -1002,7 +1131,7 @@ export type ApiEndpoint = {
1002
1131
  redirectTo: string;
1003
1132
  }>;
1004
1133
  };
1005
- type ApiGuard = Record<`/${string}`, Partial<Record<"PUT" | "GET" | "POST" | "DELETE", ApiEndpoint>>>;
1134
+ type ApiGuard = Record<`/${string}`, Partial<Record<"PUT" | "GET" | "POST" | "DELETE" | "PATCH", ApiEndpoint>>>;
1006
1135
  export type ServerOf<Api extends ApiGuard> = {
1007
1136
  [Route in keyof Api]: {
1008
1137
  [Method in keyof Api[Route]]: Api[Route][Method] extends ApiEndpoint ? (req: DefinedObject<{
@@ -13,3 +13,4 @@ export * from "./parseRoutePattern.js";
13
13
  export * from "./getNextAppRouterSourceFolder.js";
14
14
  export * from "./routeValidation.js";
15
15
  export * from "./getErrorMessageFromUnknownJson.js";
16
+ export * from "./zod/SerializedSchema.js";
@@ -14,7 +14,7 @@ export declare const RemirrorLinkMark: z.ZodObject<{
14
14
  export type RemirrorLinkMark = z.infer<typeof RemirrorLinkMark>;
15
15
  export declare const RemirrorText: z.ZodIntersection<z.ZodObject<{
16
16
  type: z.ZodLiteral<"text">;
17
- text: z.ZodString;
17
+ text: z.ZodOptional<z.ZodString>;
18
18
  }, z.core.$strip>, z.ZodObject<{
19
19
  marks: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
20
20
  type: z.ZodUnion<readonly [z.ZodLiteral<"bold">, z.ZodLiteral<"strike">, z.ZodLiteral<"italic">]>;
@@ -60,7 +60,7 @@ export declare const RemirrorHeading: z.ZodIntersection<z.ZodObject<{
60
60
  }, z.core.$strip>>;
61
61
  content: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodIntersection<z.ZodObject<{
62
62
  type: z.ZodLiteral<"text">;
63
- text: z.ZodString;
63
+ text: z.ZodOptional<z.ZodString>;
64
64
  }, z.core.$strip>, z.ZodObject<{
65
65
  marks: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
66
66
  type: z.ZodUnion<readonly [z.ZodLiteral<"bold">, z.ZodLiteral<"strike">, z.ZodLiteral<"italic">]>;
@@ -135,7 +135,7 @@ export declare const RemirrorJSON: z.ZodObject<{
135
135
  }, z.core.$strip>>;
136
136
  content: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodIntersection<z.ZodObject<{
137
137
  type: z.ZodLiteral<"text">;
138
- text: z.ZodString;
138
+ text: z.ZodOptional<z.ZodString>;
139
139
  }, z.core.$strip>, z.ZodObject<{
140
140
  marks: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
141
141
  type: z.ZodUnion<readonly [z.ZodLiteral<"bold">, z.ZodLiteral<"strike">, z.ZodLiteral<"italic">]>;
@@ -0,0 +1,27 @@
1
+ import { z } from "zod";
2
+ import { type SerializedSchema as SerializedSchemaT, type SerializedStringSchema as SerializedStringSchemaT, type SerializedLiteralSchema as SerializedLiteralSchemaT, type SerializedBooleanSchema as SerializedBooleanSchemaT, type SerializedNumberSchema as SerializedNumberSchemaT, type SerializedObjectSchema as SerializedObjectSchemaT, type SerializedArraySchema as SerializedArraySchemaT, type SerializedUnionSchema as SerializedUnionSchemaT, type SerializedRichTextSchema as SerializedRichTextSchemaT, type SerializedRichTextOptions as SerializedRichTextOptionsT, type SerializedRecordSchema as SerializedRecordSchemaT, type SerializedKeyOfSchema as SerializedKeyOfSchemaT, type SerializedRouteSchema as SerializedRouteSchemaT, type SerializedFileSchema as SerializedFileSchemaT, type SerializedDateSchema as SerializedDateSchemaT, type SerializedImageSchema as SerializedImageSchemaT } from "@valbuild/core";
3
+ export declare const SerializedStringSchema: z.ZodType<SerializedStringSchemaT>;
4
+ export declare const SerializedLiteralSchema: z.ZodType<SerializedLiteralSchemaT>;
5
+ export declare const SerializedBooleanSchema: z.ZodType<SerializedBooleanSchemaT>;
6
+ export declare const SerializedNumberSchema: z.ZodType<SerializedNumberSchemaT>;
7
+ export declare const SerializedObjectSchema: z.ZodType<SerializedObjectSchemaT>;
8
+ export declare const SerializedArraySchema: z.ZodType<SerializedArraySchemaT>;
9
+ export declare const SerializedUnionSchema: z.ZodType<SerializedUnionSchemaT>;
10
+ export declare const ImageOptions: z.ZodObject<{
11
+ ext: z.ZodOptional<z.ZodUnion<readonly [z.ZodTuple<[z.ZodLiteral<"jpg">], null>, z.ZodTuple<[z.ZodLiteral<"webp">], null>]>>;
12
+ directory: z.ZodOptional<z.ZodString>;
13
+ prefix: z.ZodOptional<z.ZodString>;
14
+ accept: z.ZodOptional<z.ZodString>;
15
+ }, z.core.$strip>;
16
+ export declare const SerializedImageSchema: z.ZodType<SerializedImageSchemaT>;
17
+ export declare const RichTextOptions: z.ZodType<SerializedRichTextOptionsT>;
18
+ export declare const SerializedRichTextSchema: z.ZodType<SerializedRichTextSchemaT>;
19
+ export declare const SerializedRecordSchema: z.ZodType<SerializedRecordSchemaT>;
20
+ export declare const SerializedKeyOfSchema: z.ZodType<SerializedKeyOfSchemaT>;
21
+ export declare const FileOptions: z.ZodObject<{
22
+ accept: z.ZodOptional<z.ZodString>;
23
+ }, z.core.$strip>;
24
+ export declare const SerializedFileSchema: z.ZodType<SerializedFileSchemaT>;
25
+ export declare const SerializedDateSchema: z.ZodType<SerializedDateSchemaT>;
26
+ export declare const SerializedRouteSchema: z.ZodType<SerializedRouteSchemaT>;
27
+ export declare const SerializedSchema: z.ZodType<SerializedSchemaT>;
@@ -198,7 +198,8 @@ function convertParagraph(path, child, files, configDirectory, remoteOptions) {
198
198
  }
199
199
  function convertTextNode(node) {
200
200
  if (node.type === "text") {
201
- var _node$marks, _node$marks2;
201
+ var _node$text, _node$marks, _node$marks2;
202
+ var text = (_node$text = node.text) !== null && _node$text !== void 0 ? _node$text : "";
202
203
  var styles = ((_node$marks = node.marks) === null || _node$marks === void 0 ? void 0 : _node$marks.flatMap(function (mark) {
203
204
  if (mark.type !== "link") {
204
205
  if (mark.type === "strike") {
@@ -223,7 +224,7 @@ function convertTextNode(node) {
223
224
  children: [{
224
225
  tag: "span",
225
226
  styles: styles,
226
- children: [node.text]
227
+ children: [text]
227
228
  }]
228
229
  };
229
230
  }
@@ -232,17 +233,17 @@ function convertTextNode(node) {
232
233
  href: ((_node$marks$find2 = node.marks.find(function (mark) {
233
234
  return mark.type === "link";
234
235
  })) === null || _node$marks$find2 === void 0 ? void 0 : _node$marks$find2.attrs.href) || "",
235
- children: [node.text]
236
+ children: [text]
236
237
  };
237
238
  }
238
239
  if (styles.length > 0) {
239
240
  return {
240
241
  tag: "span",
241
242
  styles: styles,
242
- children: [node.text]
243
+ children: [text]
243
244
  };
244
245
  }
245
- return node.text;
246
+ return text;
246
247
  } else {
247
248
  var exhaustiveCheck = node.type;
248
249
  throw new Error("Unexpected node type: ".concat(exhaustiveCheck));
@@ -429,7 +430,7 @@ var RemirrorLinkMark = zod.z.object({
429
430
  });
430
431
  var RemirrorText = zod.z.intersection(zod.z.object({
431
432
  type: zod.z.literal("text"),
432
- text: zod.z.string()
433
+ text: zod.z.string().optional()
433
434
  }), zod.z.object({
434
435
  marks: zod.z.array(zod.z.union([RemirrorTextMark, RemirrorLinkMark]))
435
436
  }).partial());
@@ -559,6 +560,11 @@ function convertHeadingToRemirror(level, children) {
559
560
  };
560
561
  }
561
562
  function convertStringToRemirror(child) {
563
+ if (!child) {
564
+ return {
565
+ type: "text"
566
+ };
567
+ }
562
568
  return {
563
569
  type: "text",
564
570
  text: child
@@ -622,6 +628,9 @@ function convertParagraphToRemirror(children) {
622
628
  type: "paragraph",
623
629
  content: children.flatMap(function (child) {
624
630
  if (typeof child === "string") {
631
+ if (!child) {
632
+ return [];
633
+ }
625
634
  return [convertStringToRemirror(child)];
626
635
  }
627
636
  switch (child.tag) {
@@ -1672,6 +1681,7 @@ var Api = {
1672
1681
  req: {
1673
1682
  body: zod.z.object({
1674
1683
  parentRef: ParentRef,
1684
+ sessionId: zod.z.string().nullish(),
1675
1685
  patches: zod.z.array(zod.z.object({
1676
1686
  path: ModuleFilePath,
1677
1687
  patchId: PatchId,
@@ -1838,6 +1848,9 @@ var Api = {
1838
1848
  }
1839
1849
  },
1840
1850
  res: zod.z.union([unauthorizedResponse, zod.z.object({
1851
+ status: zod.z.literal(500),
1852
+ json: GenericError
1853
+ }), zod.z.object({
1841
1854
  status: zod.z.literal(200),
1842
1855
  json: zod.z.object({
1843
1856
  profiles: zod.z.array(zod.z.object({
@@ -1928,6 +1941,93 @@ var Api = {
1928
1941
  body: zod.z["instanceof"](ReadableStream)
1929
1942
  })])
1930
1943
  }
1944
+ },
1945
+ "/ai/initialize": {
1946
+ POST: {
1947
+ req: {
1948
+ cookies: _defineProperty({}, VAL_SESSION_COOKIE, zod.z.string().optional())
1949
+ },
1950
+ res: zod.z.union([unauthorizedResponse, zod.z.object({
1951
+ status: zod.z.literal(200),
1952
+ json: zod.z.object({
1953
+ nonce: zod.z.string(),
1954
+ wsUrl: zod.z.string()
1955
+ })
1956
+ }), zod.z.object({
1957
+ status: zod.z.literal(500),
1958
+ json: GenericError
1959
+ })])
1960
+ }
1961
+ },
1962
+ "/ai/sessions": {
1963
+ GET: {
1964
+ req: {
1965
+ query: {
1966
+ limit: onlyOneStringQueryParam.optional(),
1967
+ cursor_updatedAt: onlyOneStringQueryParam.optional(),
1968
+ cursor_id: onlyOneStringQueryParam.optional()
1969
+ },
1970
+ cookies: _defineProperty({}, VAL_SESSION_COOKIE, zod.z.string().optional())
1971
+ },
1972
+ res: zod.z.union([unauthorizedResponse, zod.z.object({
1973
+ status: zod.z.literal(200),
1974
+ json: zod.z.object({
1975
+ sessions: zod.z.array(zod.z.object({
1976
+ id: zod.z.string(),
1977
+ name: zod.z.string().nullable(),
1978
+ createdAt: zod.z.string(),
1979
+ updatedAt: zod.z.string()
1980
+ })),
1981
+ nextCursor: zod.z.object({
1982
+ updatedAt: zod.z.string(),
1983
+ id: zod.z.string()
1984
+ }).nullable().optional()
1985
+ })
1986
+ }), zod.z.object({
1987
+ status: zod.z.literal(500),
1988
+ json: GenericError
1989
+ })])
1990
+ },
1991
+ PATCH: {
1992
+ req: {
1993
+ path: zod.z.string(),
1994
+ body: zod.z.object({
1995
+ name: zod.z.string()
1996
+ }),
1997
+ cookies: _defineProperty({}, VAL_SESSION_COOKIE, zod.z.string().optional())
1998
+ },
1999
+ res: zod.z.union([unauthorizedResponse, zod.z.object({
2000
+ status: zod.z.literal(200),
2001
+ json: zod.z.object({})
2002
+ }), zod.z.object({
2003
+ status: zod.z.literal(500),
2004
+ json: GenericError
2005
+ })])
2006
+ }
2007
+ },
2008
+ "/ai/messages": {
2009
+ GET: {
2010
+ req: {
2011
+ path: zod.z.string(),
2012
+ cookies: _defineProperty({}, VAL_SESSION_COOKIE, zod.z.string().optional())
2013
+ },
2014
+ res: zod.z.union([unauthorizedResponse, zod.z.object({
2015
+ status: zod.z.literal(200),
2016
+ json: zod.z.object({
2017
+ messages: zod.z.array(zod.z.object({
2018
+ role: zod.z.string(),
2019
+ content: zod.z.string()
2020
+ })),
2021
+ nextCursor: zod.z.object({
2022
+ updatedAt: zod.z.string(),
2023
+ id: zod.z.string()
2024
+ }).nullable().optional()
2025
+ })
2026
+ }), zod.z.object({
2027
+ status: zod.z.literal(500),
2028
+ json: GenericError
2029
+ })])
2030
+ }
1931
2031
  }
1932
2032
  };
1933
2033
 
@@ -2277,6 +2377,14 @@ var SharedValConfig = zod.z.object({
2277
2377
  ai: zod.z.object({
2278
2378
  commitMessages: zod.z.object({
2279
2379
  disabled: zod.z["boolean"]().optional()
2380
+ }).optional(),
2381
+ chat: zod.z.object({
2382
+ experimental: zod.z.object({
2383
+ enable: zod.z["boolean"]().optional()
2384
+ }).optional(),
2385
+ suggestions: zod.z.array(zod.z.string()).optional(),
2386
+ title: zod.z.string().optional(),
2387
+ description: zod.z.string().optional()
2280
2388
  }).optional()
2281
2389
  }).optional()
2282
2390
  });
@@ -2565,6 +2673,8 @@ function createRegExpFromPattern(pattern) {
2565
2673
 
2566
2674
  exports.Api = Api;
2567
2675
  exports.DEFAULT_ERROR_MESSAGE = DEFAULT_ERROR_MESSAGE;
2676
+ exports.FileOptions = FileOptions;
2677
+ exports.ImageOptions = ImageOptions;
2568
2678
  exports.ParentRef = ParentRef$1;
2569
2679
  exports.Patch = Patch;
2570
2680
  exports.PatchBlock = PatchBlock;
@@ -2581,6 +2691,22 @@ exports.RemirrorOrderedList = RemirrorOrderedList;
2581
2691
  exports.RemirrorParagraph = RemirrorParagraph;
2582
2692
  exports.RemirrorText = RemirrorText;
2583
2693
  exports.RemirrorTextMark = RemirrorTextMark;
2694
+ exports.RichTextOptions = RichTextOptions;
2695
+ exports.SerializedArraySchema = SerializedArraySchema;
2696
+ exports.SerializedBooleanSchema = SerializedBooleanSchema;
2697
+ exports.SerializedDateSchema = SerializedDateSchema;
2698
+ exports.SerializedFileSchema = SerializedFileSchema;
2699
+ exports.SerializedImageSchema = SerializedImageSchema;
2700
+ exports.SerializedKeyOfSchema = SerializedKeyOfSchema;
2701
+ exports.SerializedLiteralSchema = SerializedLiteralSchema;
2702
+ exports.SerializedNumberSchema = SerializedNumberSchema;
2703
+ exports.SerializedObjectSchema = SerializedObjectSchema;
2704
+ exports.SerializedRecordSchema = SerializedRecordSchema;
2705
+ exports.SerializedRichTextSchema = SerializedRichTextSchema;
2706
+ exports.SerializedRouteSchema = SerializedRouteSchema;
2707
+ exports.SerializedSchema = SerializedSchema;
2708
+ exports.SerializedStringSchema = SerializedStringSchema;
2709
+ exports.SerializedUnionSchema = SerializedUnionSchema;
2584
2710
  exports.SharedValConfig = SharedValConfig;
2585
2711
  exports.VAL_CONFIG_SESSION_STORAGE_KEY = VAL_CONFIG_SESSION_STORAGE_KEY;
2586
2712
  exports.VAL_ENABLE_COOKIE_NAME = VAL_ENABLE_COOKIE_NAME;
@@ -198,7 +198,8 @@ function convertParagraph(path, child, files, configDirectory, remoteOptions) {
198
198
  }
199
199
  function convertTextNode(node) {
200
200
  if (node.type === "text") {
201
- var _node$marks, _node$marks2;
201
+ var _node$text, _node$marks, _node$marks2;
202
+ var text = (_node$text = node.text) !== null && _node$text !== void 0 ? _node$text : "";
202
203
  var styles = ((_node$marks = node.marks) === null || _node$marks === void 0 ? void 0 : _node$marks.flatMap(function (mark) {
203
204
  if (mark.type !== "link") {
204
205
  if (mark.type === "strike") {
@@ -223,7 +224,7 @@ function convertTextNode(node) {
223
224
  children: [{
224
225
  tag: "span",
225
226
  styles: styles,
226
- children: [node.text]
227
+ children: [text]
227
228
  }]
228
229
  };
229
230
  }
@@ -232,17 +233,17 @@ function convertTextNode(node) {
232
233
  href: ((_node$marks$find2 = node.marks.find(function (mark) {
233
234
  return mark.type === "link";
234
235
  })) === null || _node$marks$find2 === void 0 ? void 0 : _node$marks$find2.attrs.href) || "",
235
- children: [node.text]
236
+ children: [text]
236
237
  };
237
238
  }
238
239
  if (styles.length > 0) {
239
240
  return {
240
241
  tag: "span",
241
242
  styles: styles,
242
- children: [node.text]
243
+ children: [text]
243
244
  };
244
245
  }
245
- return node.text;
246
+ return text;
246
247
  } else {
247
248
  var exhaustiveCheck = node.type;
248
249
  throw new Error("Unexpected node type: ".concat(exhaustiveCheck));
@@ -429,7 +430,7 @@ var RemirrorLinkMark = zod.z.object({
429
430
  });
430
431
  var RemirrorText = zod.z.intersection(zod.z.object({
431
432
  type: zod.z.literal("text"),
432
- text: zod.z.string()
433
+ text: zod.z.string().optional()
433
434
  }), zod.z.object({
434
435
  marks: zod.z.array(zod.z.union([RemirrorTextMark, RemirrorLinkMark]))
435
436
  }).partial());
@@ -559,6 +560,11 @@ function convertHeadingToRemirror(level, children) {
559
560
  };
560
561
  }
561
562
  function convertStringToRemirror(child) {
563
+ if (!child) {
564
+ return {
565
+ type: "text"
566
+ };
567
+ }
562
568
  return {
563
569
  type: "text",
564
570
  text: child
@@ -622,6 +628,9 @@ function convertParagraphToRemirror(children) {
622
628
  type: "paragraph",
623
629
  content: children.flatMap(function (child) {
624
630
  if (typeof child === "string") {
631
+ if (!child) {
632
+ return [];
633
+ }
625
634
  return [convertStringToRemirror(child)];
626
635
  }
627
636
  switch (child.tag) {
@@ -1672,6 +1681,7 @@ var Api = {
1672
1681
  req: {
1673
1682
  body: zod.z.object({
1674
1683
  parentRef: ParentRef,
1684
+ sessionId: zod.z.string().nullish(),
1675
1685
  patches: zod.z.array(zod.z.object({
1676
1686
  path: ModuleFilePath,
1677
1687
  patchId: PatchId,
@@ -1838,6 +1848,9 @@ var Api = {
1838
1848
  }
1839
1849
  },
1840
1850
  res: zod.z.union([unauthorizedResponse, zod.z.object({
1851
+ status: zod.z.literal(500),
1852
+ json: GenericError
1853
+ }), zod.z.object({
1841
1854
  status: zod.z.literal(200),
1842
1855
  json: zod.z.object({
1843
1856
  profiles: zod.z.array(zod.z.object({
@@ -1928,6 +1941,93 @@ var Api = {
1928
1941
  body: zod.z["instanceof"](ReadableStream)
1929
1942
  })])
1930
1943
  }
1944
+ },
1945
+ "/ai/initialize": {
1946
+ POST: {
1947
+ req: {
1948
+ cookies: _defineProperty({}, VAL_SESSION_COOKIE, zod.z.string().optional())
1949
+ },
1950
+ res: zod.z.union([unauthorizedResponse, zod.z.object({
1951
+ status: zod.z.literal(200),
1952
+ json: zod.z.object({
1953
+ nonce: zod.z.string(),
1954
+ wsUrl: zod.z.string()
1955
+ })
1956
+ }), zod.z.object({
1957
+ status: zod.z.literal(500),
1958
+ json: GenericError
1959
+ })])
1960
+ }
1961
+ },
1962
+ "/ai/sessions": {
1963
+ GET: {
1964
+ req: {
1965
+ query: {
1966
+ limit: onlyOneStringQueryParam.optional(),
1967
+ cursor_updatedAt: onlyOneStringQueryParam.optional(),
1968
+ cursor_id: onlyOneStringQueryParam.optional()
1969
+ },
1970
+ cookies: _defineProperty({}, VAL_SESSION_COOKIE, zod.z.string().optional())
1971
+ },
1972
+ res: zod.z.union([unauthorizedResponse, zod.z.object({
1973
+ status: zod.z.literal(200),
1974
+ json: zod.z.object({
1975
+ sessions: zod.z.array(zod.z.object({
1976
+ id: zod.z.string(),
1977
+ name: zod.z.string().nullable(),
1978
+ createdAt: zod.z.string(),
1979
+ updatedAt: zod.z.string()
1980
+ })),
1981
+ nextCursor: zod.z.object({
1982
+ updatedAt: zod.z.string(),
1983
+ id: zod.z.string()
1984
+ }).nullable().optional()
1985
+ })
1986
+ }), zod.z.object({
1987
+ status: zod.z.literal(500),
1988
+ json: GenericError
1989
+ })])
1990
+ },
1991
+ PATCH: {
1992
+ req: {
1993
+ path: zod.z.string(),
1994
+ body: zod.z.object({
1995
+ name: zod.z.string()
1996
+ }),
1997
+ cookies: _defineProperty({}, VAL_SESSION_COOKIE, zod.z.string().optional())
1998
+ },
1999
+ res: zod.z.union([unauthorizedResponse, zod.z.object({
2000
+ status: zod.z.literal(200),
2001
+ json: zod.z.object({})
2002
+ }), zod.z.object({
2003
+ status: zod.z.literal(500),
2004
+ json: GenericError
2005
+ })])
2006
+ }
2007
+ },
2008
+ "/ai/messages": {
2009
+ GET: {
2010
+ req: {
2011
+ path: zod.z.string(),
2012
+ cookies: _defineProperty({}, VAL_SESSION_COOKIE, zod.z.string().optional())
2013
+ },
2014
+ res: zod.z.union([unauthorizedResponse, zod.z.object({
2015
+ status: zod.z.literal(200),
2016
+ json: zod.z.object({
2017
+ messages: zod.z.array(zod.z.object({
2018
+ role: zod.z.string(),
2019
+ content: zod.z.string()
2020
+ })),
2021
+ nextCursor: zod.z.object({
2022
+ updatedAt: zod.z.string(),
2023
+ id: zod.z.string()
2024
+ }).nullable().optional()
2025
+ })
2026
+ }), zod.z.object({
2027
+ status: zod.z.literal(500),
2028
+ json: GenericError
2029
+ })])
2030
+ }
1931
2031
  }
1932
2032
  };
1933
2033
 
@@ -2277,6 +2377,14 @@ var SharedValConfig = zod.z.object({
2277
2377
  ai: zod.z.object({
2278
2378
  commitMessages: zod.z.object({
2279
2379
  disabled: zod.z["boolean"]().optional()
2380
+ }).optional(),
2381
+ chat: zod.z.object({
2382
+ experimental: zod.z.object({
2383
+ enable: zod.z["boolean"]().optional()
2384
+ }).optional(),
2385
+ suggestions: zod.z.array(zod.z.string()).optional(),
2386
+ title: zod.z.string().optional(),
2387
+ description: zod.z.string().optional()
2280
2388
  }).optional()
2281
2389
  }).optional()
2282
2390
  });
@@ -2565,6 +2673,8 @@ function createRegExpFromPattern(pattern) {
2565
2673
 
2566
2674
  exports.Api = Api;
2567
2675
  exports.DEFAULT_ERROR_MESSAGE = DEFAULT_ERROR_MESSAGE;
2676
+ exports.FileOptions = FileOptions;
2677
+ exports.ImageOptions = ImageOptions;
2568
2678
  exports.ParentRef = ParentRef$1;
2569
2679
  exports.Patch = Patch;
2570
2680
  exports.PatchBlock = PatchBlock;
@@ -2581,6 +2691,22 @@ exports.RemirrorOrderedList = RemirrorOrderedList;
2581
2691
  exports.RemirrorParagraph = RemirrorParagraph;
2582
2692
  exports.RemirrorText = RemirrorText;
2583
2693
  exports.RemirrorTextMark = RemirrorTextMark;
2694
+ exports.RichTextOptions = RichTextOptions;
2695
+ exports.SerializedArraySchema = SerializedArraySchema;
2696
+ exports.SerializedBooleanSchema = SerializedBooleanSchema;
2697
+ exports.SerializedDateSchema = SerializedDateSchema;
2698
+ exports.SerializedFileSchema = SerializedFileSchema;
2699
+ exports.SerializedImageSchema = SerializedImageSchema;
2700
+ exports.SerializedKeyOfSchema = SerializedKeyOfSchema;
2701
+ exports.SerializedLiteralSchema = SerializedLiteralSchema;
2702
+ exports.SerializedNumberSchema = SerializedNumberSchema;
2703
+ exports.SerializedObjectSchema = SerializedObjectSchema;
2704
+ exports.SerializedRecordSchema = SerializedRecordSchema;
2705
+ exports.SerializedRichTextSchema = SerializedRichTextSchema;
2706
+ exports.SerializedRouteSchema = SerializedRouteSchema;
2707
+ exports.SerializedSchema = SerializedSchema;
2708
+ exports.SerializedStringSchema = SerializedStringSchema;
2709
+ exports.SerializedUnionSchema = SerializedUnionSchema;
2584
2710
  exports.SharedValConfig = SharedValConfig;
2585
2711
  exports.VAL_CONFIG_SESSION_STORAGE_KEY = VAL_CONFIG_SESSION_STORAGE_KEY;
2586
2712
  exports.VAL_ENABLE_COOKIE_NAME = VAL_ENABLE_COOKIE_NAME;
@@ -194,7 +194,8 @@ function convertParagraph(path, child, files, configDirectory, remoteOptions) {
194
194
  }
195
195
  function convertTextNode(node) {
196
196
  if (node.type === "text") {
197
- var _node$marks, _node$marks2;
197
+ var _node$text, _node$marks, _node$marks2;
198
+ var text = (_node$text = node.text) !== null && _node$text !== void 0 ? _node$text : "";
198
199
  var styles = ((_node$marks = node.marks) === null || _node$marks === void 0 ? void 0 : _node$marks.flatMap(function (mark) {
199
200
  if (mark.type !== "link") {
200
201
  if (mark.type === "strike") {
@@ -219,7 +220,7 @@ function convertTextNode(node) {
219
220
  children: [{
220
221
  tag: "span",
221
222
  styles: styles,
222
- children: [node.text]
223
+ children: [text]
223
224
  }]
224
225
  };
225
226
  }
@@ -228,17 +229,17 @@ function convertTextNode(node) {
228
229
  href: ((_node$marks$find2 = node.marks.find(function (mark) {
229
230
  return mark.type === "link";
230
231
  })) === null || _node$marks$find2 === void 0 ? void 0 : _node$marks$find2.attrs.href) || "",
231
- children: [node.text]
232
+ children: [text]
232
233
  };
233
234
  }
234
235
  if (styles.length > 0) {
235
236
  return {
236
237
  tag: "span",
237
238
  styles: styles,
238
- children: [node.text]
239
+ children: [text]
239
240
  };
240
241
  }
241
- return node.text;
242
+ return text;
242
243
  } else {
243
244
  var exhaustiveCheck = node.type;
244
245
  throw new Error("Unexpected node type: ".concat(exhaustiveCheck));
@@ -425,7 +426,7 @@ var RemirrorLinkMark = z.object({
425
426
  });
426
427
  var RemirrorText = z.intersection(z.object({
427
428
  type: z.literal("text"),
428
- text: z.string()
429
+ text: z.string().optional()
429
430
  }), z.object({
430
431
  marks: z.array(z.union([RemirrorTextMark, RemirrorLinkMark]))
431
432
  }).partial());
@@ -555,6 +556,11 @@ function convertHeadingToRemirror(level, children) {
555
556
  };
556
557
  }
557
558
  function convertStringToRemirror(child) {
559
+ if (!child) {
560
+ return {
561
+ type: "text"
562
+ };
563
+ }
558
564
  return {
559
565
  type: "text",
560
566
  text: child
@@ -618,6 +624,9 @@ function convertParagraphToRemirror(children) {
618
624
  type: "paragraph",
619
625
  content: children.flatMap(function (child) {
620
626
  if (typeof child === "string") {
627
+ if (!child) {
628
+ return [];
629
+ }
621
630
  return [convertStringToRemirror(child)];
622
631
  }
623
632
  switch (child.tag) {
@@ -1668,6 +1677,7 @@ var Api = {
1668
1677
  req: {
1669
1678
  body: z.object({
1670
1679
  parentRef: ParentRef,
1680
+ sessionId: z.string().nullish(),
1671
1681
  patches: z.array(z.object({
1672
1682
  path: ModuleFilePath,
1673
1683
  patchId: PatchId,
@@ -1834,6 +1844,9 @@ var Api = {
1834
1844
  }
1835
1845
  },
1836
1846
  res: z.union([unauthorizedResponse, z.object({
1847
+ status: z.literal(500),
1848
+ json: GenericError
1849
+ }), z.object({
1837
1850
  status: z.literal(200),
1838
1851
  json: z.object({
1839
1852
  profiles: z.array(z.object({
@@ -1924,6 +1937,93 @@ var Api = {
1924
1937
  body: z["instanceof"](ReadableStream)
1925
1938
  })])
1926
1939
  }
1940
+ },
1941
+ "/ai/initialize": {
1942
+ POST: {
1943
+ req: {
1944
+ cookies: _defineProperty({}, VAL_SESSION_COOKIE, z.string().optional())
1945
+ },
1946
+ res: z.union([unauthorizedResponse, z.object({
1947
+ status: z.literal(200),
1948
+ json: z.object({
1949
+ nonce: z.string(),
1950
+ wsUrl: z.string()
1951
+ })
1952
+ }), z.object({
1953
+ status: z.literal(500),
1954
+ json: GenericError
1955
+ })])
1956
+ }
1957
+ },
1958
+ "/ai/sessions": {
1959
+ GET: {
1960
+ req: {
1961
+ query: {
1962
+ limit: onlyOneStringQueryParam.optional(),
1963
+ cursor_updatedAt: onlyOneStringQueryParam.optional(),
1964
+ cursor_id: onlyOneStringQueryParam.optional()
1965
+ },
1966
+ cookies: _defineProperty({}, VAL_SESSION_COOKIE, z.string().optional())
1967
+ },
1968
+ res: z.union([unauthorizedResponse, z.object({
1969
+ status: z.literal(200),
1970
+ json: z.object({
1971
+ sessions: z.array(z.object({
1972
+ id: z.string(),
1973
+ name: z.string().nullable(),
1974
+ createdAt: z.string(),
1975
+ updatedAt: z.string()
1976
+ })),
1977
+ nextCursor: z.object({
1978
+ updatedAt: z.string(),
1979
+ id: z.string()
1980
+ }).nullable().optional()
1981
+ })
1982
+ }), z.object({
1983
+ status: z.literal(500),
1984
+ json: GenericError
1985
+ })])
1986
+ },
1987
+ PATCH: {
1988
+ req: {
1989
+ path: z.string(),
1990
+ body: z.object({
1991
+ name: z.string()
1992
+ }),
1993
+ cookies: _defineProperty({}, VAL_SESSION_COOKIE, z.string().optional())
1994
+ },
1995
+ res: z.union([unauthorizedResponse, z.object({
1996
+ status: z.literal(200),
1997
+ json: z.object({})
1998
+ }), z.object({
1999
+ status: z.literal(500),
2000
+ json: GenericError
2001
+ })])
2002
+ }
2003
+ },
2004
+ "/ai/messages": {
2005
+ GET: {
2006
+ req: {
2007
+ path: z.string(),
2008
+ cookies: _defineProperty({}, VAL_SESSION_COOKIE, z.string().optional())
2009
+ },
2010
+ res: z.union([unauthorizedResponse, z.object({
2011
+ status: z.literal(200),
2012
+ json: z.object({
2013
+ messages: z.array(z.object({
2014
+ role: z.string(),
2015
+ content: z.string()
2016
+ })),
2017
+ nextCursor: z.object({
2018
+ updatedAt: z.string(),
2019
+ id: z.string()
2020
+ }).nullable().optional()
2021
+ })
2022
+ }), z.object({
2023
+ status: z.literal(500),
2024
+ json: GenericError
2025
+ })])
2026
+ }
1927
2027
  }
1928
2028
  };
1929
2029
 
@@ -2273,6 +2373,14 @@ var SharedValConfig = z.object({
2273
2373
  ai: z.object({
2274
2374
  commitMessages: z.object({
2275
2375
  disabled: z["boolean"]().optional()
2376
+ }).optional(),
2377
+ chat: z.object({
2378
+ experimental: z.object({
2379
+ enable: z["boolean"]().optional()
2380
+ }).optional(),
2381
+ suggestions: z.array(z.string()).optional(),
2382
+ title: z.string().optional(),
2383
+ description: z.string().optional()
2276
2384
  }).optional()
2277
2385
  }).optional()
2278
2386
  });
@@ -2559,4 +2667,4 @@ function createRegExpFromPattern(pattern) {
2559
2667
  }
2560
2668
  }
2561
2669
 
2562
- export { Api, DEFAULT_ERROR_MESSAGE, ParentRef$1 as ParentRef, Patch, PatchBlock, PatchId, PatchJSON, RemirrorBr, RemirrorBulletList, RemirrorHeading, RemirrorImage, RemirrorJSON, RemirrorLinkMark, RemirrorListItem, RemirrorOrderedList, RemirrorParagraph, RemirrorText, RemirrorTextMark, SharedValConfig, VAL_CONFIG_SESSION_STORAGE_KEY, VAL_ENABLE_COOKIE_NAME, VAL_SESSION_COOKIE, VAL_STATE_COOKIE, VAL_THEME_SESSION_STORAGE_KEY, ValCommit, ValDeployment, createRegExpFromPattern, createValClient, filterRoutesByPatterns, getErrorMessageFromUnknownJson, getNextAppRouterSitemapTree, getNextAppRouterSourceFolder, getPatternFromModuleFilePath, parseRoutePattern, remirrorToRichTextSource, richTextToRemirror, urlOf, validateRoutePatterns };
2670
+ export { Api, DEFAULT_ERROR_MESSAGE, FileOptions, ImageOptions, ParentRef$1 as ParentRef, Patch, PatchBlock, PatchId, PatchJSON, RemirrorBr, RemirrorBulletList, RemirrorHeading, RemirrorImage, RemirrorJSON, RemirrorLinkMark, RemirrorListItem, RemirrorOrderedList, RemirrorParagraph, RemirrorText, RemirrorTextMark, RichTextOptions, SerializedArraySchema, SerializedBooleanSchema, SerializedDateSchema, SerializedFileSchema, SerializedImageSchema, SerializedKeyOfSchema, SerializedLiteralSchema, SerializedNumberSchema, SerializedObjectSchema, SerializedRecordSchema, SerializedRichTextSchema, SerializedRouteSchema, SerializedSchema, SerializedStringSchema, SerializedUnionSchema, SharedValConfig, VAL_CONFIG_SESSION_STORAGE_KEY, VAL_ENABLE_COOKIE_NAME, VAL_SESSION_COOKIE, VAL_STATE_COOKIE, VAL_THEME_SESSION_STORAGE_KEY, ValCommit, ValDeployment, createRegExpFromPattern, createValClient, filterRoutesByPatterns, getErrorMessageFromUnknownJson, getNextAppRouterSitemapTree, getNextAppRouterSourceFolder, getPatternFromModuleFilePath, parseRoutePattern, remirrorToRichTextSource, richTextToRemirror, urlOf, validateRoutePatterns };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@valbuild/shared",
3
- "version": "0.94.0",
3
+ "version": "0.95.0",
4
4
  "private": false,
5
5
  "description": "Val shared types and utilities",
6
6
  "repository": {
@@ -31,7 +31,7 @@
31
31
  "dependencies": {
32
32
  "zod": "^4.3.5",
33
33
  "zod-validation-error": "^5.0.0",
34
- "@valbuild/core": "0.94.0"
34
+ "@valbuild/core": "0.95.0"
35
35
  },
36
36
  "files": [
37
37
  "dist",