@valbuild/server 0.62.5 → 0.63.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.
@@ -285,17 +285,6 @@ function createValLink(value) {
285
285
  })];
286
286
  return ts__default["default"].factory.createCallExpression(ts__default["default"].factory.createPropertyAccessExpression(ts__default["default"].factory.createPropertyAccessExpression(ts__default["default"].factory.createIdentifier("c"), "rt"), ts__default["default"].factory.createIdentifier("link")), undefined, args);
287
287
  }
288
- function createValRichTextTaggedStringTemplate(value) {
289
- const {
290
- templateStrings: [head, ...others],
291
- exprs
292
- } = value;
293
- const tag = ts__default["default"].factory.createPropertyAccessExpression(ts__default["default"].factory.createIdentifier("c"), ts__default["default"].factory.createIdentifier("richtext"));
294
- if (exprs.length > 0) {
295
- return ts__default["default"].factory.createTaggedTemplateExpression(tag, undefined, ts__default["default"].factory.createTemplateExpression(ts__default["default"].factory.createTemplateHead(head, head), others.map((s, i) => ts__default["default"].factory.createTemplateSpan(toExpression(exprs[i]), i < others.length - 1 ? ts__default["default"].factory.createTemplateMiddle(s, s) : ts__default["default"].factory.createTemplateTail(s, s)))));
296
- }
297
- return ts__default["default"].factory.createTaggedTemplateExpression(tag, undefined, ts__default["default"].factory.createNoSubstitutionTemplateLiteral(head, head));
298
- }
299
288
  function toExpression(value) {
300
289
  if (typeof value === "string") {
301
290
  // TODO: Use configuration/heuristics to determine use of single quote or double quote
@@ -316,8 +305,6 @@ function toExpression(value) {
316
305
  return createValFileReference(value);
317
306
  } else if (isValLinkValue(value)) {
318
307
  return createValLink(value);
319
- } else if (isValRichTextValue(value)) {
320
- return createValRichTextTaggedStringTemplate(value);
321
308
  }
322
309
  return ts__default["default"].factory.createObjectLiteralExpression(Object.entries(value).map(([key, value]) => createPropertyAssignment(key, value)));
323
310
  } else {
@@ -559,9 +546,6 @@ function isValRichTextImageValue(value) {
559
546
  function isValLinkValue(value) {
560
547
  return !!(typeof value === "object" && value && core.VAL_EXTENSION in value && value[core.VAL_EXTENSION] === "link");
561
548
  }
562
- function isValRichTextValue(value) {
563
- return !!(typeof value === "object" && value && core.VAL_EXTENSION in value && value[core.VAL_EXTENSION] === "richtext" && "templateStrings" in value && typeof value.templateStrings === "object" && Array.isArray(value.templateStrings));
564
- }
565
549
  function addToNode(document, node, key, value) {
566
550
  if (ts__default["default"].isArrayLiteralExpression(node)) {
567
551
  return fp.pipe(parseAndValidateArrayInsertIndex(key, node.elements), fp.result.map(index => [insertAt(document, node.elements, index, toExpression(value))]));
@@ -768,13 +752,13 @@ globalThis.valModule = {
768
752
  // if one of these are set it is a Val module, so must validate
769
753
  (valModule === null || valModule === void 0 ? void 0 : valModule.path) !== undefined || (valModule === null || valModule === void 0 ? void 0 : valModule.schema) !== undefined || (valModule === null || valModule === void 0 ? void 0 : valModule.source) !== undefined) {
770
754
  if (valModule.path !== moduleFilePath) {
771
- fatalErrors.push(`Wrong c.define id! Expected: '${moduleFilePath}', found: '${valModule.path}'`);
772
- } else if (encodeURIComponent(valModule.id).replace(/%2F/g, "/") !== valModule.id) {
773
- fatalErrors.push(`Invalid c.define id! Must be a web-safe path without escape characters, found: '${valModule.id}', which was encoded as: '${encodeURIComponent(valModule.id).replace("%2F", "/")}'`);
755
+ fatalErrors.push(`Wrong c.define path! Expected: '${moduleFilePath}', found: '${valModule.path}'`);
756
+ } else if (encodeURIComponent(valModule.path).replace(/%2F/g, "/") !== valModule.path) {
757
+ fatalErrors.push(`Invalid c.define path! Must be a web-safe path without escape characters, found: '${valModule.path}', which was encoded as: '${encodeURIComponent(valModule.path).replace("%2F", "/")}'`);
774
758
  } else if ((valModule === null || valModule === void 0 ? void 0 : valModule.schema) === undefined && options.schema) {
775
- fatalErrors.push(`Expected val id: '${moduleFilePath}' to have a schema`);
759
+ fatalErrors.push(`Expected val path: '${moduleFilePath}' to have a schema`);
776
760
  } else if ((valModule === null || valModule === void 0 ? void 0 : valModule.source) === undefined && options.source) {
777
- fatalErrors.push(`Expected val id: '${moduleFilePath}' to have a source`);
761
+ fatalErrors.push(`Expected val path: '${moduleFilePath}' to have a source`);
778
762
  }
779
763
  }
780
764
  let errors = false;
@@ -793,7 +777,7 @@ globalThis.valModule = {
793
777
  };
794
778
  }
795
779
  return {
796
- path: valModule.id || moduleFilePath,
780
+ path: valModule.path || moduleFilePath,
797
781
  // NOTE: we use path here, since SerializedModuleContent (maybe bad name?) can be used for whole modules as well as subparts of modules
798
782
  source: valModule.source,
799
783
  schema: valModule.schema,
@@ -1569,7 +1553,7 @@ class ValOps {
1569
1553
  // NOTE: overwrite and use last patch_id if multiple patches modify the same file
1570
1554
  fileFixOps[op.path.join("/")] = [{
1571
1555
  op: "add",
1572
- path: op.path.concat("patch_id"),
1556
+ path: op.path.concat(...(op.nestedFilePath || [])).concat("patch_id"),
1573
1557
  value: patchId
1574
1558
  }];
1575
1559
  } else {
@@ -1991,6 +1975,7 @@ class ValOps {
1991
1975
  op: "file",
1992
1976
  path: op.path,
1993
1977
  filePath,
1978
+ nestedFilePath: op.nestedFilePath,
1994
1979
  value: {
1995
1980
  sha256
1996
1981
  }
@@ -2019,7 +2004,8 @@ class ValOps {
2019
2004
  const {
2020
2005
  schema: schemaAtPath
2021
2006
  } = core.Internal.resolvePath(modulePath, source, schema);
2022
- type = schemaAtPath instanceof core.ImageSchema ? "image" : schemaAtPath instanceof core.FileSchema ? "file" : schema.serialize().type;
2007
+ type = schemaAtPath instanceof core.ImageSchema || schemaAtPath instanceof core.RichTextSchema // if it's a rich text schema, we assume it's an image - hope this assumption holds!
2008
+ ? "image" : schemaAtPath instanceof core.FileSchema ? "file" : schemaAtPath.serialize().type;
2023
2009
  } catch (e) {
2024
2010
  if (e instanceof Error) {
2025
2011
  return {
@@ -2250,6 +2236,7 @@ const OperationT = z__default["default"].discriminatedUnion("op", [z__default["d
2250
2236
  op: z__default["default"].literal("file"),
2251
2237
  path: z__default["default"].array(z__default["default"].string()),
2252
2238
  filePath: z__default["default"].string(),
2239
+ nestedFilePath: z__default["default"].array(z__default["default"].string()).optional(),
2253
2240
  value: z__default["default"].union([z__default["default"].string(), z__default["default"].object({
2254
2241
  sha256: z__default["default"].string()
2255
2242
  })])
@@ -3861,19 +3848,20 @@ class ValServer {
3861
3848
  }
3862
3849
  };
3863
3850
  }
3864
- for (const fileRes of createPatchRes.files) {
3865
- if (fileRes.error) {
3866
- // clean up broken patch:
3867
- await this.serverOps.deletePatches([createPatchRes.patchId]);
3868
- return {
3869
- status: 500,
3870
- json: {
3871
- message: "Failed to create patch",
3872
- details: fileRes.error
3873
- }
3874
- };
3875
- }
3876
- }
3851
+ // TODO: evaluate if we need this: seems wrong to delete patches that are not applied
3852
+ // for (const fileRes of createPatchRes.files) {
3853
+ // if (fileRes.error) {
3854
+ // // clean up broken patch:
3855
+ // await this.serverOps.deletePatches([createPatchRes.patchId]);
3856
+ // return {
3857
+ // status: 500,
3858
+ // json: {
3859
+ // message: "Failed to create patch",
3860
+ // details: fileRes.error,
3861
+ // },
3862
+ // };
3863
+ // }
3864
+ // }
3877
3865
  patchOps.patches[createPatchRes.patchId] = {
3878
3866
  path: newPatchModuleFilePath,
3879
3867
  patch: newPatchOps,
@@ -4821,6 +4809,21 @@ async function createFixPatch(config, apply, sourcePath, validationError) {
4821
4809
  }
4822
4810
  });
4823
4811
  }
4812
+ } else if (fix === "fix:deprecated-richtext") {
4813
+ if (!validationError.value) {
4814
+ throw Error("Cannot fix richtext without a value");
4815
+ }
4816
+ patch$1.push({
4817
+ op: "replace",
4818
+ path: patch.sourceToPatchPath(sourcePath),
4819
+ value: validationError.value
4820
+ });
4821
+ } else {
4822
+ remainingErrors.push({
4823
+ ...validationError,
4824
+ message: `Unknown fix: ${fix}`,
4825
+ fixes: undefined
4826
+ });
4824
4827
  }
4825
4828
  }
4826
4829
  if (!validationError.fixes || validationError.fixes.length === 0) {
@@ -285,17 +285,6 @@ function createValLink(value) {
285
285
  })];
286
286
  return ts__default["default"].factory.createCallExpression(ts__default["default"].factory.createPropertyAccessExpression(ts__default["default"].factory.createPropertyAccessExpression(ts__default["default"].factory.createIdentifier("c"), "rt"), ts__default["default"].factory.createIdentifier("link")), undefined, args);
287
287
  }
288
- function createValRichTextTaggedStringTemplate(value) {
289
- const {
290
- templateStrings: [head, ...others],
291
- exprs
292
- } = value;
293
- const tag = ts__default["default"].factory.createPropertyAccessExpression(ts__default["default"].factory.createIdentifier("c"), ts__default["default"].factory.createIdentifier("richtext"));
294
- if (exprs.length > 0) {
295
- return ts__default["default"].factory.createTaggedTemplateExpression(tag, undefined, ts__default["default"].factory.createTemplateExpression(ts__default["default"].factory.createTemplateHead(head, head), others.map((s, i) => ts__default["default"].factory.createTemplateSpan(toExpression(exprs[i]), i < others.length - 1 ? ts__default["default"].factory.createTemplateMiddle(s, s) : ts__default["default"].factory.createTemplateTail(s, s)))));
296
- }
297
- return ts__default["default"].factory.createTaggedTemplateExpression(tag, undefined, ts__default["default"].factory.createNoSubstitutionTemplateLiteral(head, head));
298
- }
299
288
  function toExpression(value) {
300
289
  if (typeof value === "string") {
301
290
  // TODO: Use configuration/heuristics to determine use of single quote or double quote
@@ -316,8 +305,6 @@ function toExpression(value) {
316
305
  return createValFileReference(value);
317
306
  } else if (isValLinkValue(value)) {
318
307
  return createValLink(value);
319
- } else if (isValRichTextValue(value)) {
320
- return createValRichTextTaggedStringTemplate(value);
321
308
  }
322
309
  return ts__default["default"].factory.createObjectLiteralExpression(Object.entries(value).map(([key, value]) => createPropertyAssignment(key, value)));
323
310
  } else {
@@ -559,9 +546,6 @@ function isValRichTextImageValue(value) {
559
546
  function isValLinkValue(value) {
560
547
  return !!(typeof value === "object" && value && core.VAL_EXTENSION in value && value[core.VAL_EXTENSION] === "link");
561
548
  }
562
- function isValRichTextValue(value) {
563
- return !!(typeof value === "object" && value && core.VAL_EXTENSION in value && value[core.VAL_EXTENSION] === "richtext" && "templateStrings" in value && typeof value.templateStrings === "object" && Array.isArray(value.templateStrings));
564
- }
565
549
  function addToNode(document, node, key, value) {
566
550
  if (ts__default["default"].isArrayLiteralExpression(node)) {
567
551
  return fp.pipe(parseAndValidateArrayInsertIndex(key, node.elements), fp.result.map(index => [insertAt(document, node.elements, index, toExpression(value))]));
@@ -768,13 +752,13 @@ globalThis.valModule = {
768
752
  // if one of these are set it is a Val module, so must validate
769
753
  (valModule === null || valModule === void 0 ? void 0 : valModule.path) !== undefined || (valModule === null || valModule === void 0 ? void 0 : valModule.schema) !== undefined || (valModule === null || valModule === void 0 ? void 0 : valModule.source) !== undefined) {
770
754
  if (valModule.path !== moduleFilePath) {
771
- fatalErrors.push(`Wrong c.define id! Expected: '${moduleFilePath}', found: '${valModule.path}'`);
772
- } else if (encodeURIComponent(valModule.id).replace(/%2F/g, "/") !== valModule.id) {
773
- fatalErrors.push(`Invalid c.define id! Must be a web-safe path without escape characters, found: '${valModule.id}', which was encoded as: '${encodeURIComponent(valModule.id).replace("%2F", "/")}'`);
755
+ fatalErrors.push(`Wrong c.define path! Expected: '${moduleFilePath}', found: '${valModule.path}'`);
756
+ } else if (encodeURIComponent(valModule.path).replace(/%2F/g, "/") !== valModule.path) {
757
+ fatalErrors.push(`Invalid c.define path! Must be a web-safe path without escape characters, found: '${valModule.path}', which was encoded as: '${encodeURIComponent(valModule.path).replace("%2F", "/")}'`);
774
758
  } else if ((valModule === null || valModule === void 0 ? void 0 : valModule.schema) === undefined && options.schema) {
775
- fatalErrors.push(`Expected val id: '${moduleFilePath}' to have a schema`);
759
+ fatalErrors.push(`Expected val path: '${moduleFilePath}' to have a schema`);
776
760
  } else if ((valModule === null || valModule === void 0 ? void 0 : valModule.source) === undefined && options.source) {
777
- fatalErrors.push(`Expected val id: '${moduleFilePath}' to have a source`);
761
+ fatalErrors.push(`Expected val path: '${moduleFilePath}' to have a source`);
778
762
  }
779
763
  }
780
764
  let errors = false;
@@ -793,7 +777,7 @@ globalThis.valModule = {
793
777
  };
794
778
  }
795
779
  return {
796
- path: valModule.id || moduleFilePath,
780
+ path: valModule.path || moduleFilePath,
797
781
  // NOTE: we use path here, since SerializedModuleContent (maybe bad name?) can be used for whole modules as well as subparts of modules
798
782
  source: valModule.source,
799
783
  schema: valModule.schema,
@@ -1569,7 +1553,7 @@ class ValOps {
1569
1553
  // NOTE: overwrite and use last patch_id if multiple patches modify the same file
1570
1554
  fileFixOps[op.path.join("/")] = [{
1571
1555
  op: "add",
1572
- path: op.path.concat("patch_id"),
1556
+ path: op.path.concat(...(op.nestedFilePath || [])).concat("patch_id"),
1573
1557
  value: patchId
1574
1558
  }];
1575
1559
  } else {
@@ -1991,6 +1975,7 @@ class ValOps {
1991
1975
  op: "file",
1992
1976
  path: op.path,
1993
1977
  filePath,
1978
+ nestedFilePath: op.nestedFilePath,
1994
1979
  value: {
1995
1980
  sha256
1996
1981
  }
@@ -2019,7 +2004,8 @@ class ValOps {
2019
2004
  const {
2020
2005
  schema: schemaAtPath
2021
2006
  } = core.Internal.resolvePath(modulePath, source, schema);
2022
- type = schemaAtPath instanceof core.ImageSchema ? "image" : schemaAtPath instanceof core.FileSchema ? "file" : schema.serialize().type;
2007
+ type = schemaAtPath instanceof core.ImageSchema || schemaAtPath instanceof core.RichTextSchema // if it's a rich text schema, we assume it's an image - hope this assumption holds!
2008
+ ? "image" : schemaAtPath instanceof core.FileSchema ? "file" : schemaAtPath.serialize().type;
2023
2009
  } catch (e) {
2024
2010
  if (e instanceof Error) {
2025
2011
  return {
@@ -2250,6 +2236,7 @@ const OperationT = z__default["default"].discriminatedUnion("op", [z__default["d
2250
2236
  op: z__default["default"].literal("file"),
2251
2237
  path: z__default["default"].array(z__default["default"].string()),
2252
2238
  filePath: z__default["default"].string(),
2239
+ nestedFilePath: z__default["default"].array(z__default["default"].string()).optional(),
2253
2240
  value: z__default["default"].union([z__default["default"].string(), z__default["default"].object({
2254
2241
  sha256: z__default["default"].string()
2255
2242
  })])
@@ -3861,19 +3848,20 @@ class ValServer {
3861
3848
  }
3862
3849
  };
3863
3850
  }
3864
- for (const fileRes of createPatchRes.files) {
3865
- if (fileRes.error) {
3866
- // clean up broken patch:
3867
- await this.serverOps.deletePatches([createPatchRes.patchId]);
3868
- return {
3869
- status: 500,
3870
- json: {
3871
- message: "Failed to create patch",
3872
- details: fileRes.error
3873
- }
3874
- };
3875
- }
3876
- }
3851
+ // TODO: evaluate if we need this: seems wrong to delete patches that are not applied
3852
+ // for (const fileRes of createPatchRes.files) {
3853
+ // if (fileRes.error) {
3854
+ // // clean up broken patch:
3855
+ // await this.serverOps.deletePatches([createPatchRes.patchId]);
3856
+ // return {
3857
+ // status: 500,
3858
+ // json: {
3859
+ // message: "Failed to create patch",
3860
+ // details: fileRes.error,
3861
+ // },
3862
+ // };
3863
+ // }
3864
+ // }
3877
3865
  patchOps.patches[createPatchRes.patchId] = {
3878
3866
  path: newPatchModuleFilePath,
3879
3867
  patch: newPatchOps,
@@ -4821,6 +4809,21 @@ async function createFixPatch(config, apply, sourcePath, validationError) {
4821
4809
  }
4822
4810
  });
4823
4811
  }
4812
+ } else if (fix === "fix:deprecated-richtext") {
4813
+ if (!validationError.value) {
4814
+ throw Error("Cannot fix richtext without a value");
4815
+ }
4816
+ patch$1.push({
4817
+ op: "replace",
4818
+ path: patch.sourceToPatchPath(sourcePath),
4819
+ value: validationError.value
4820
+ });
4821
+ } else {
4822
+ remainingErrors.push({
4823
+ ...validationError,
4824
+ message: `Unknown fix: ${fix}`,
4825
+ fixes: undefined
4826
+ });
4824
4827
  }
4825
4828
  }
4826
4829
  if (!validationError.fixes || validationError.fixes.length === 0) {
@@ -1,7 +1,7 @@
1
1
  import { newQuickJSWASMModule } from 'quickjs-emscripten';
2
2
  import ts from 'typescript';
3
3
  import { result, pipe } from '@valbuild/core/fp';
4
- import { FILE_REF_PROP, FILE_REF_SUBTYPE_TAG, RT_IMAGE_TAG, VAL_EXTENSION, derefPatch, Internal, Schema, ImageSchema, FileSchema } from '@valbuild/core';
4
+ import { FILE_REF_PROP, FILE_REF_SUBTYPE_TAG, RT_IMAGE_TAG, VAL_EXTENSION, derefPatch, Internal, Schema, ImageSchema, RichTextSchema, FileSchema } from '@valbuild/core';
5
5
  import { deepEqual, isNotRoot, PatchError, parseAndValidateArrayIndex, applyPatch, JSONOps, deepClone, sourceToPatchPath } from '@valbuild/core/patch';
6
6
  import * as fsPath from 'path';
7
7
  import fsPath__default from 'path';
@@ -255,17 +255,6 @@ function createValLink(value) {
255
255
  })];
256
256
  return ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier("c"), "rt"), ts.factory.createIdentifier("link")), undefined, args);
257
257
  }
258
- function createValRichTextTaggedStringTemplate(value) {
259
- const {
260
- templateStrings: [head, ...others],
261
- exprs
262
- } = value;
263
- const tag = ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier("c"), ts.factory.createIdentifier("richtext"));
264
- if (exprs.length > 0) {
265
- return ts.factory.createTaggedTemplateExpression(tag, undefined, ts.factory.createTemplateExpression(ts.factory.createTemplateHead(head, head), others.map((s, i) => ts.factory.createTemplateSpan(toExpression(exprs[i]), i < others.length - 1 ? ts.factory.createTemplateMiddle(s, s) : ts.factory.createTemplateTail(s, s)))));
266
- }
267
- return ts.factory.createTaggedTemplateExpression(tag, undefined, ts.factory.createNoSubstitutionTemplateLiteral(head, head));
268
- }
269
258
  function toExpression(value) {
270
259
  if (typeof value === "string") {
271
260
  // TODO: Use configuration/heuristics to determine use of single quote or double quote
@@ -286,8 +275,6 @@ function toExpression(value) {
286
275
  return createValFileReference(value);
287
276
  } else if (isValLinkValue(value)) {
288
277
  return createValLink(value);
289
- } else if (isValRichTextValue(value)) {
290
- return createValRichTextTaggedStringTemplate(value);
291
278
  }
292
279
  return ts.factory.createObjectLiteralExpression(Object.entries(value).map(([key, value]) => createPropertyAssignment(key, value)));
293
280
  } else {
@@ -529,9 +516,6 @@ function isValRichTextImageValue(value) {
529
516
  function isValLinkValue(value) {
530
517
  return !!(typeof value === "object" && value && VAL_EXTENSION in value && value[VAL_EXTENSION] === "link");
531
518
  }
532
- function isValRichTextValue(value) {
533
- return !!(typeof value === "object" && value && VAL_EXTENSION in value && value[VAL_EXTENSION] === "richtext" && "templateStrings" in value && typeof value.templateStrings === "object" && Array.isArray(value.templateStrings));
534
- }
535
519
  function addToNode(document, node, key, value) {
536
520
  if (ts.isArrayLiteralExpression(node)) {
537
521
  return pipe(parseAndValidateArrayInsertIndex(key, node.elements), result.map(index => [insertAt(document, node.elements, index, toExpression(value))]));
@@ -738,13 +722,13 @@ globalThis.valModule = {
738
722
  // if one of these are set it is a Val module, so must validate
739
723
  (valModule === null || valModule === void 0 ? void 0 : valModule.path) !== undefined || (valModule === null || valModule === void 0 ? void 0 : valModule.schema) !== undefined || (valModule === null || valModule === void 0 ? void 0 : valModule.source) !== undefined) {
740
724
  if (valModule.path !== moduleFilePath) {
741
- fatalErrors.push(`Wrong c.define id! Expected: '${moduleFilePath}', found: '${valModule.path}'`);
742
- } else if (encodeURIComponent(valModule.id).replace(/%2F/g, "/") !== valModule.id) {
743
- fatalErrors.push(`Invalid c.define id! Must be a web-safe path without escape characters, found: '${valModule.id}', which was encoded as: '${encodeURIComponent(valModule.id).replace("%2F", "/")}'`);
725
+ fatalErrors.push(`Wrong c.define path! Expected: '${moduleFilePath}', found: '${valModule.path}'`);
726
+ } else if (encodeURIComponent(valModule.path).replace(/%2F/g, "/") !== valModule.path) {
727
+ fatalErrors.push(`Invalid c.define path! Must be a web-safe path without escape characters, found: '${valModule.path}', which was encoded as: '${encodeURIComponent(valModule.path).replace("%2F", "/")}'`);
744
728
  } else if ((valModule === null || valModule === void 0 ? void 0 : valModule.schema) === undefined && options.schema) {
745
- fatalErrors.push(`Expected val id: '${moduleFilePath}' to have a schema`);
729
+ fatalErrors.push(`Expected val path: '${moduleFilePath}' to have a schema`);
746
730
  } else if ((valModule === null || valModule === void 0 ? void 0 : valModule.source) === undefined && options.source) {
747
- fatalErrors.push(`Expected val id: '${moduleFilePath}' to have a source`);
731
+ fatalErrors.push(`Expected val path: '${moduleFilePath}' to have a source`);
748
732
  }
749
733
  }
750
734
  let errors = false;
@@ -763,7 +747,7 @@ globalThis.valModule = {
763
747
  };
764
748
  }
765
749
  return {
766
- path: valModule.id || moduleFilePath,
750
+ path: valModule.path || moduleFilePath,
767
751
  // NOTE: we use path here, since SerializedModuleContent (maybe bad name?) can be used for whole modules as well as subparts of modules
768
752
  source: valModule.source,
769
753
  schema: valModule.schema,
@@ -1539,7 +1523,7 @@ class ValOps {
1539
1523
  // NOTE: overwrite and use last patch_id if multiple patches modify the same file
1540
1524
  fileFixOps[op.path.join("/")] = [{
1541
1525
  op: "add",
1542
- path: op.path.concat("patch_id"),
1526
+ path: op.path.concat(...(op.nestedFilePath || [])).concat("patch_id"),
1543
1527
  value: patchId
1544
1528
  }];
1545
1529
  } else {
@@ -1961,6 +1945,7 @@ class ValOps {
1961
1945
  op: "file",
1962
1946
  path: op.path,
1963
1947
  filePath,
1948
+ nestedFilePath: op.nestedFilePath,
1964
1949
  value: {
1965
1950
  sha256
1966
1951
  }
@@ -1989,7 +1974,8 @@ class ValOps {
1989
1974
  const {
1990
1975
  schema: schemaAtPath
1991
1976
  } = Internal.resolvePath(modulePath, source, schema);
1992
- type = schemaAtPath instanceof ImageSchema ? "image" : schemaAtPath instanceof FileSchema ? "file" : schema.serialize().type;
1977
+ type = schemaAtPath instanceof ImageSchema || schemaAtPath instanceof RichTextSchema // if it's a rich text schema, we assume it's an image - hope this assumption holds!
1978
+ ? "image" : schemaAtPath instanceof FileSchema ? "file" : schemaAtPath.serialize().type;
1993
1979
  } catch (e) {
1994
1980
  if (e instanceof Error) {
1995
1981
  return {
@@ -2220,6 +2206,7 @@ const OperationT = z$1.discriminatedUnion("op", [z$1.object({
2220
2206
  op: z$1.literal("file"),
2221
2207
  path: z$1.array(z$1.string()),
2222
2208
  filePath: z$1.string(),
2209
+ nestedFilePath: z$1.array(z$1.string()).optional(),
2223
2210
  value: z$1.union([z$1.string(), z$1.object({
2224
2211
  sha256: z$1.string()
2225
2212
  })])
@@ -3831,19 +3818,20 @@ class ValServer {
3831
3818
  }
3832
3819
  };
3833
3820
  }
3834
- for (const fileRes of createPatchRes.files) {
3835
- if (fileRes.error) {
3836
- // clean up broken patch:
3837
- await this.serverOps.deletePatches([createPatchRes.patchId]);
3838
- return {
3839
- status: 500,
3840
- json: {
3841
- message: "Failed to create patch",
3842
- details: fileRes.error
3843
- }
3844
- };
3845
- }
3846
- }
3821
+ // TODO: evaluate if we need this: seems wrong to delete patches that are not applied
3822
+ // for (const fileRes of createPatchRes.files) {
3823
+ // if (fileRes.error) {
3824
+ // // clean up broken patch:
3825
+ // await this.serverOps.deletePatches([createPatchRes.patchId]);
3826
+ // return {
3827
+ // status: 500,
3828
+ // json: {
3829
+ // message: "Failed to create patch",
3830
+ // details: fileRes.error,
3831
+ // },
3832
+ // };
3833
+ // }
3834
+ // }
3847
3835
  patchOps.patches[createPatchRes.patchId] = {
3848
3836
  path: newPatchModuleFilePath,
3849
3837
  patch: newPatchOps,
@@ -4791,6 +4779,21 @@ async function createFixPatch(config, apply, sourcePath, validationError) {
4791
4779
  }
4792
4780
  });
4793
4781
  }
4782
+ } else if (fix === "fix:deprecated-richtext") {
4783
+ if (!validationError.value) {
4784
+ throw Error("Cannot fix richtext without a value");
4785
+ }
4786
+ patch.push({
4787
+ op: "replace",
4788
+ path: sourceToPatchPath(sourcePath),
4789
+ value: validationError.value
4790
+ });
4791
+ } else {
4792
+ remainingErrors.push({
4793
+ ...validationError,
4794
+ message: `Unknown fix: ${fix}`,
4795
+ fixes: undefined
4796
+ });
4794
4797
  }
4795
4798
  }
4796
4799
  if (!validationError.fixes || validationError.fixes.length === 0) {
package/package.json CHANGED
@@ -12,7 +12,7 @@
12
12
  "./package.json": "./package.json"
13
13
  },
14
14
  "types": "dist/valbuild-server.cjs.d.ts",
15
- "version": "0.62.5",
15
+ "version": "0.63.0",
16
16
  "scripts": {
17
17
  "typecheck": "tsc --noEmit",
18
18
  "test": "jest",
@@ -22,9 +22,9 @@
22
22
  "@types/jest": "^29.2.5"
23
23
  },
24
24
  "dependencies": {
25
- "@valbuild/core": "~0.62.5",
26
- "@valbuild/shared": "~0.62.5",
27
- "@valbuild/ui": "~0.62.5",
25
+ "@valbuild/core": "~0.63.0",
26
+ "@valbuild/shared": "~0.63.0",
27
+ "@valbuild/ui": "~0.63.0",
28
28
  "image-size": "^1.0.2",
29
29
  "minimatch": "^3.0.4",
30
30
  "quickjs-emscripten": "^0.21.1",