@valbuild/server 0.150.21 → 0.150.23
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/CHANGELOG.md +18 -0
- package/browser/dist/valbuild-server-browser.cjs.dev.js +1 -1
- package/browser/dist/valbuild-server-browser.cjs.prod.js +1 -1
- package/browser/dist/valbuild-server-browser.esm.js +1 -1
- package/dist/{ValRouterCore-499077da.cjs.prod.js → ValRouterCore-0c7ae881.cjs.prod.js} +3 -3
- package/dist/{ValRouterCore-f8afc4c6.esm.js → ValRouterCore-5b6cccd4.esm.js} +3 -3
- package/dist/{ValRouterCore-d37b85cf.cjs.dev.js → ValRouterCore-cfa7b001.cjs.dev.js} +3 -3
- package/dist/{getJsonEntryAtCommit-5718bbed.esm.js → getJsonEntryAtCommit-8ff81ef5.esm.js} +2 -2
- package/dist/{getJsonEntryAtCommit-18cac885.cjs.prod.js → getJsonEntryAtCommit-acf8c269.cjs.prod.js} +2 -2
- package/dist/{getJsonEntryAtCommit-3907580e.cjs.dev.js → getJsonEntryAtCommit-d9b5f753.cjs.dev.js} +2 -2
- package/dist/{jsonValuesModule-8ae503a8.cjs.dev.js → jsonValuesModule-235bd751.cjs.dev.js} +38 -0
- package/dist/{jsonValuesModule-427d68c8.esm.js → jsonValuesModule-23eb6f53.esm.js} +39 -2
- package/dist/{jsonValuesModule-d1bb8d8f.cjs.prod.js → jsonValuesModule-625ebae8.cjs.prod.js} +38 -0
- package/dist/{ops-b15239ac.cjs.prod.js → ops-0e54b388.cjs.prod.js} +1 -1
- package/dist/{ops-f37d18c6.cjs.dev.js → ops-9ca2ef2a.cjs.dev.js} +1 -1
- package/dist/{ops-0d05feaf.esm.js → ops-b904007e.esm.js} +1 -1
- package/dist/{publishKit-3c7f44cb.cjs.dev.js → publishKit-34f71e50.cjs.dev.js} +3 -3
- package/dist/{publishKit-a3533ffe.cjs.prod.js → publishKit-65e9e564.cjs.prod.js} +3 -3
- package/dist/{publishKit-bc7c9a0c.esm.js → publishKit-7441c0fd.esm.js} +4 -4
- package/dist/valbuild-server.cjs.dev.js +140 -18
- package/dist/valbuild-server.cjs.prod.js +140 -18
- package/dist/valbuild-server.esm.js +142 -20
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @valbuild/server
|
|
2
2
|
|
|
3
|
+
## 0.150.23
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`41b73af`](https://github.com/valbuild/val/commit/41b73af5db02ec2fef3f8b3884be453712d9ada3), [`e46c34a`](https://github.com/valbuild/val/commit/e46c34a7eb6080e2286a85cc70f1e98d3989b8a9), [`1970507`](https://github.com/valbuild/val/commit/19705071884f8dddabd0a1319a8a4bdb4b9cdfed)]:
|
|
8
|
+
- @valbuild/ui@0.150.23
|
|
9
|
+
|
|
10
|
+
## 0.150.22
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- [#1002](https://github.com/valbuild/val/pull/1002) [`14a9864`](https://github.com/valbuild/val/commit/14a986486ca921b5aa4992caf1b452671b5eb97f) Thanks [@freekh](https://github.com/freekh)! - **Entries the design tab adds to a `.jsonValues()` record no longer revert.** When the design tab added an entry to a record that keeps its entries in `.val.json` files, the proposal's stored content didn't list the new entry, so edits to it went back. A staged `.val.ts` now sends the record's entries with it, as the stored content lists them.
|
|
15
|
+
|
|
16
|
+
**The design tab's `create_patch` can edit inside a `.jsonValues()` entry.** A patch into an entry is written into that entry's own `.val.json`, formatted the way a save writes it, so the assistant no longer rewrites the whole file to change one field. Adding, replacing or removing a whole entry still goes through `write_files`.
|
|
17
|
+
|
|
18
|
+
- Updated dependencies [[`14a9864`](https://github.com/valbuild/val/commit/14a986486ca921b5aa4992caf1b452671b5eb97f)]:
|
|
19
|
+
- @valbuild/ui@0.150.22
|
|
20
|
+
|
|
3
21
|
## 0.150.21
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var core = require('@valbuild/core');
|
|
6
|
-
var ValRouterCore = require('../../dist/ValRouterCore-
|
|
6
|
+
var ValRouterCore = require('../../dist/ValRouterCore-cfa7b001.cjs.dev.js');
|
|
7
7
|
require('@valbuild/shared/internal');
|
|
8
8
|
require('zod');
|
|
9
9
|
require('zod-validation-error');
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var core = require('@valbuild/core');
|
|
6
|
-
var ValRouterCore = require('../../dist/ValRouterCore-
|
|
6
|
+
var ValRouterCore = require('../../dist/ValRouterCore-0c7ae881.cjs.prod.js');
|
|
7
7
|
require('@valbuild/shared/internal');
|
|
8
8
|
require('zod');
|
|
9
9
|
require('zod-validation-error');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DEFAULT_CONTENT_HOST } from '@valbuild/core';
|
|
2
|
-
import { o as ValOpsMemory, M as bytesToBase64, F as ValServer, G as createValRequestHandler } from '../../dist/ValRouterCore-
|
|
2
|
+
import { o as ValOpsMemory, M as bytesToBase64, F as ValServer, G as createValRequestHandler } from '../../dist/ValRouterCore-5b6cccd4.esm.js';
|
|
3
3
|
import '@valbuild/shared/internal';
|
|
4
4
|
import 'zod';
|
|
5
5
|
import 'zod-validation-error';
|
|
@@ -3606,7 +3606,7 @@ class ValOps {
|
|
|
3606
3606
|
jsonValuesRecordKeys,
|
|
3607
3607
|
insertValJsonEntry,
|
|
3608
3608
|
removeValJsonEntry
|
|
3609
|
-
} = await Promise.resolve().then(function () { return require('./publishKit-
|
|
3609
|
+
} = await Promise.resolve().then(function () { return require('./publishKit-65e9e564.cjs.prod.js'); });
|
|
3610
3610
|
const {
|
|
3611
3611
|
patchesByModule,
|
|
3612
3612
|
fileLastUpdatedByPatchId
|
|
@@ -5509,7 +5509,7 @@ var packageJson = {
|
|
|
5509
5509
|
],
|
|
5510
5510
|
exports: true
|
|
5511
5511
|
},
|
|
5512
|
-
version: "0.150.
|
|
5512
|
+
version: "0.150.23",
|
|
5513
5513
|
scripts: {
|
|
5514
5514
|
typecheck: "tsc --noEmit",
|
|
5515
5515
|
test: "jest",
|
|
@@ -9695,7 +9695,7 @@ const ValServer = (valModules, options, callbacks, platform) => {
|
|
|
9695
9695
|
// TypeScript compiler. See `patch/ts/publishKit.ts`.
|
|
9696
9696
|
const {
|
|
9697
9697
|
getJsonEntryAtCommit
|
|
9698
|
-
} = await Promise.resolve().then(function () { return require('./getJsonEntryAtCommit-
|
|
9698
|
+
} = await Promise.resolve().then(function () { return require('./getJsonEntryAtCommit-acf8c269.cjs.prod.js'); });
|
|
9699
9699
|
const res = await getJsonEntryAtCommit(serverOps, req.query.commit_sha, req.query.path, req.query.key);
|
|
9700
9700
|
if (fp.result.isErr(res)) {
|
|
9701
9701
|
return historyErrorResponse(res.error);
|
|
@@ -3600,7 +3600,7 @@ class ValOps {
|
|
|
3600
3600
|
jsonValuesRecordKeys,
|
|
3601
3601
|
insertValJsonEntry,
|
|
3602
3602
|
removeValJsonEntry
|
|
3603
|
-
} = await import('./publishKit-
|
|
3603
|
+
} = await import('./publishKit-7441c0fd.esm.js');
|
|
3604
3604
|
const {
|
|
3605
3605
|
patchesByModule,
|
|
3606
3606
|
fileLastUpdatedByPatchId
|
|
@@ -5503,7 +5503,7 @@ var packageJson = {
|
|
|
5503
5503
|
],
|
|
5504
5504
|
exports: true
|
|
5505
5505
|
},
|
|
5506
|
-
version: "0.150.
|
|
5506
|
+
version: "0.150.23",
|
|
5507
5507
|
scripts: {
|
|
5508
5508
|
typecheck: "tsc --noEmit",
|
|
5509
5509
|
test: "jest",
|
|
@@ -9689,7 +9689,7 @@ const ValServer = (valModules, options, callbacks, platform) => {
|
|
|
9689
9689
|
// TypeScript compiler. See `patch/ts/publishKit.ts`.
|
|
9690
9690
|
const {
|
|
9691
9691
|
getJsonEntryAtCommit
|
|
9692
|
-
} = await import('./getJsonEntryAtCommit-
|
|
9692
|
+
} = await import('./getJsonEntryAtCommit-8ff81ef5.esm.js');
|
|
9693
9693
|
const res = await getJsonEntryAtCommit(serverOps, req.query.commit_sha, req.query.path, req.query.key);
|
|
9694
9694
|
if (result.isErr(res)) {
|
|
9695
9695
|
return historyErrorResponse(res.error);
|
|
@@ -3606,7 +3606,7 @@ class ValOps {
|
|
|
3606
3606
|
jsonValuesRecordKeys,
|
|
3607
3607
|
insertValJsonEntry,
|
|
3608
3608
|
removeValJsonEntry
|
|
3609
|
-
} = await Promise.resolve().then(function () { return require('./publishKit-
|
|
3609
|
+
} = await Promise.resolve().then(function () { return require('./publishKit-34f71e50.cjs.dev.js'); });
|
|
3610
3610
|
const {
|
|
3611
3611
|
patchesByModule,
|
|
3612
3612
|
fileLastUpdatedByPatchId
|
|
@@ -5509,7 +5509,7 @@ var packageJson = {
|
|
|
5509
5509
|
],
|
|
5510
5510
|
exports: true
|
|
5511
5511
|
},
|
|
5512
|
-
version: "0.150.
|
|
5512
|
+
version: "0.150.23",
|
|
5513
5513
|
scripts: {
|
|
5514
5514
|
typecheck: "tsc --noEmit",
|
|
5515
5515
|
test: "jest",
|
|
@@ -9695,7 +9695,7 @@ const ValServer = (valModules, options, callbacks, platform) => {
|
|
|
9695
9695
|
// TypeScript compiler. See `patch/ts/publishKit.ts`.
|
|
9696
9696
|
const {
|
|
9697
9697
|
getJsonEntryAtCommit
|
|
9698
|
-
} = await Promise.resolve().then(function () { return require('./getJsonEntryAtCommit-
|
|
9698
|
+
} = await Promise.resolve().then(function () { return require('./getJsonEntryAtCommit-d9b5f753.cjs.dev.js'); });
|
|
9699
9699
|
const res = await getJsonEntryAtCommit(serverOps, req.query.commit_sha, req.query.path, req.query.key);
|
|
9700
9700
|
if (fp.result.isErr(res)) {
|
|
9701
9701
|
return historyErrorResponse(res.error);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
import { N as bytesToUtf8, O as posixPath } from './ValRouterCore-
|
|
2
|
+
import { N as bytesToUtf8, O as posixPath } from './ValRouterCore-5b6cccd4.esm.js';
|
|
3
3
|
import { result } from '@valbuild/core/fp';
|
|
4
|
-
import { a as analyzeValModule, c as analyzeJsonValuesEntries } from './jsonValuesModule-
|
|
4
|
+
import { a as analyzeValModule, c as analyzeJsonValuesEntries } from './jsonValuesModule-23eb6f53.esm.js';
|
|
5
5
|
import '@valbuild/core';
|
|
6
6
|
import '@valbuild/shared/internal';
|
|
7
7
|
import 'zod';
|
package/dist/{getJsonEntryAtCommit-18cac885.cjs.prod.js → getJsonEntryAtCommit-acf8c269.cjs.prod.js}
RENAMED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var ts = require('typescript');
|
|
4
|
-
var ValRouterCore = require('./ValRouterCore-
|
|
4
|
+
var ValRouterCore = require('./ValRouterCore-0c7ae881.cjs.prod.js');
|
|
5
5
|
var fp = require('@valbuild/core/fp');
|
|
6
|
-
var jsonValuesModule = require('./jsonValuesModule-
|
|
6
|
+
var jsonValuesModule = require('./jsonValuesModule-625ebae8.cjs.prod.js');
|
|
7
7
|
require('@valbuild/core');
|
|
8
8
|
require('@valbuild/shared/internal');
|
|
9
9
|
require('zod');
|
package/dist/{getJsonEntryAtCommit-3907580e.cjs.dev.js → getJsonEntryAtCommit-d9b5f753.cjs.dev.js}
RENAMED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var ts = require('typescript');
|
|
4
|
-
var ValRouterCore = require('./ValRouterCore-
|
|
4
|
+
var ValRouterCore = require('./ValRouterCore-cfa7b001.cjs.dev.js');
|
|
5
5
|
var fp = require('@valbuild/core/fp');
|
|
6
|
-
var jsonValuesModule = require('./jsonValuesModule-
|
|
6
|
+
var jsonValuesModule = require('./jsonValuesModule-235bd751.cjs.dev.js');
|
|
7
7
|
require('@valbuild/core');
|
|
8
8
|
require('@valbuild/shared/internal');
|
|
9
9
|
require('zod');
|
|
@@ -216,6 +216,43 @@ function jsonValuesRecordKeys(source) {
|
|
|
216
216
|
}
|
|
217
217
|
return keys;
|
|
218
218
|
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* The Source a `c.define(...)` literal declares, as a module's Source is
|
|
222
|
+
* stored: each `.jsonValues()` entry's `c.json(() => import("..."))` as the
|
|
223
|
+
* marker `{ _type: "json" }` its content stands behind, and every other value
|
|
224
|
+
* as written. An error for anything that is not a literal.
|
|
225
|
+
*
|
|
226
|
+
* What a staging records for a module (`stagedModuleSources`): without the
|
|
227
|
+
* markers, an entry the design tab added to a record was in the module's code
|
|
228
|
+
* and not in its Source, and an edit into it was undone.
|
|
229
|
+
*/
|
|
230
|
+
function evaluateModuleSource(source) {
|
|
231
|
+
const entries = analyzeJsonValuesEntries(source);
|
|
232
|
+
if (entries.size === 0 || !ts__default["default"].isObjectLiteralExpression(source)) {
|
|
233
|
+
return evaluateExpression(source);
|
|
234
|
+
}
|
|
235
|
+
const value = {};
|
|
236
|
+
for (const prop of source.properties) {
|
|
237
|
+
if (!ts__default["default"].isPropertyAssignment(prop)) {
|
|
238
|
+
return fp.result.err(new ValSyntaxError("Expected a property assignment", prop));
|
|
239
|
+
}
|
|
240
|
+
const key = getPropertyKey(prop.name);
|
|
241
|
+
if (key === null) {
|
|
242
|
+
return fp.result.err(new ValSyntaxError("Expected a literal key", prop.name));
|
|
243
|
+
}
|
|
244
|
+
if (entries.has(key)) {
|
|
245
|
+
value[key] = {
|
|
246
|
+
_type: "json"
|
|
247
|
+
};
|
|
248
|
+
continue;
|
|
249
|
+
}
|
|
250
|
+
const evaluated = evaluateExpression(prop.initializer);
|
|
251
|
+
if (fp.result.isErr(evaluated)) return evaluated;
|
|
252
|
+
value[key] = evaluated.value;
|
|
253
|
+
}
|
|
254
|
+
return fp.result.ok(value);
|
|
255
|
+
}
|
|
219
256
|
function getPropertyKey(name) {
|
|
220
257
|
if (ts__default["default"].isStringLiteralLike(name)) {
|
|
221
258
|
return name.text;
|
|
@@ -279,6 +316,7 @@ function getImportPathFromThunk(thunk) {
|
|
|
279
316
|
exports.analyzeJsonValuesEntries = analyzeJsonValuesEntries;
|
|
280
317
|
exports.analyzeValModule = analyzeValModule;
|
|
281
318
|
exports.evaluateExpression = evaluateExpression;
|
|
319
|
+
exports.evaluateModuleSource = evaluateModuleSource;
|
|
282
320
|
exports.findObjectPropertyAssignment = findObjectPropertyAssignment;
|
|
283
321
|
exports.flatMapErrors = flatMapErrors;
|
|
284
322
|
exports.formatSyntaxError = formatSyntaxError;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
import {
|
|
2
|
+
import { pipe, result } from '@valbuild/core/fp';
|
|
3
3
|
|
|
4
4
|
class ValSyntaxError {
|
|
5
5
|
constructor(message, node) {
|
|
@@ -210,6 +210,43 @@ function jsonValuesRecordKeys(source) {
|
|
|
210
210
|
}
|
|
211
211
|
return keys;
|
|
212
212
|
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* The Source a `c.define(...)` literal declares, as a module's Source is
|
|
216
|
+
* stored: each `.jsonValues()` entry's `c.json(() => import("..."))` as the
|
|
217
|
+
* marker `{ _type: "json" }` its content stands behind, and every other value
|
|
218
|
+
* as written. An error for anything that is not a literal.
|
|
219
|
+
*
|
|
220
|
+
* What a staging records for a module (`stagedModuleSources`): without the
|
|
221
|
+
* markers, an entry the design tab added to a record was in the module's code
|
|
222
|
+
* and not in its Source, and an edit into it was undone.
|
|
223
|
+
*/
|
|
224
|
+
function evaluateModuleSource(source) {
|
|
225
|
+
const entries = analyzeJsonValuesEntries(source);
|
|
226
|
+
if (entries.size === 0 || !ts.isObjectLiteralExpression(source)) {
|
|
227
|
+
return evaluateExpression(source);
|
|
228
|
+
}
|
|
229
|
+
const value = {};
|
|
230
|
+
for (const prop of source.properties) {
|
|
231
|
+
if (!ts.isPropertyAssignment(prop)) {
|
|
232
|
+
return result.err(new ValSyntaxError("Expected a property assignment", prop));
|
|
233
|
+
}
|
|
234
|
+
const key = getPropertyKey(prop.name);
|
|
235
|
+
if (key === null) {
|
|
236
|
+
return result.err(new ValSyntaxError("Expected a literal key", prop.name));
|
|
237
|
+
}
|
|
238
|
+
if (entries.has(key)) {
|
|
239
|
+
value[key] = {
|
|
240
|
+
_type: "json"
|
|
241
|
+
};
|
|
242
|
+
continue;
|
|
243
|
+
}
|
|
244
|
+
const evaluated = evaluateExpression(prop.initializer);
|
|
245
|
+
if (result.isErr(evaluated)) return evaluated;
|
|
246
|
+
value[key] = evaluated.value;
|
|
247
|
+
}
|
|
248
|
+
return result.ok(value);
|
|
249
|
+
}
|
|
213
250
|
function getPropertyKey(name) {
|
|
214
251
|
if (ts.isStringLiteralLike(name)) {
|
|
215
252
|
return name.text;
|
|
@@ -270,4 +307,4 @@ function getImportPathFromThunk(thunk) {
|
|
|
270
307
|
return null;
|
|
271
308
|
}
|
|
272
309
|
|
|
273
|
-
export { analyzeValModule as a, formatSyntaxError as b, analyzeJsonValuesEntries as c, formatSyntaxErrorTree as d, findObjectPropertyAssignment as e, flatMapErrors as f, evaluateExpression as g, jsonValuesRecordKeys as j, shallowValidateExpression as s, validateInitializers as v };
|
|
310
|
+
export { analyzeValModule as a, formatSyntaxError as b, analyzeJsonValuesEntries as c, formatSyntaxErrorTree as d, findObjectPropertyAssignment as e, flatMapErrors as f, evaluateExpression as g, evaluateModuleSource as h, jsonValuesRecordKeys as j, shallowValidateExpression as s, validateInitializers as v };
|
package/dist/{jsonValuesModule-d1bb8d8f.cjs.prod.js → jsonValuesModule-625ebae8.cjs.prod.js}
RENAMED
|
@@ -216,6 +216,43 @@ function jsonValuesRecordKeys(source) {
|
|
|
216
216
|
}
|
|
217
217
|
return keys;
|
|
218
218
|
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* The Source a `c.define(...)` literal declares, as a module's Source is
|
|
222
|
+
* stored: each `.jsonValues()` entry's `c.json(() => import("..."))` as the
|
|
223
|
+
* marker `{ _type: "json" }` its content stands behind, and every other value
|
|
224
|
+
* as written. An error for anything that is not a literal.
|
|
225
|
+
*
|
|
226
|
+
* What a staging records for a module (`stagedModuleSources`): without the
|
|
227
|
+
* markers, an entry the design tab added to a record was in the module's code
|
|
228
|
+
* and not in its Source, and an edit into it was undone.
|
|
229
|
+
*/
|
|
230
|
+
function evaluateModuleSource(source) {
|
|
231
|
+
const entries = analyzeJsonValuesEntries(source);
|
|
232
|
+
if (entries.size === 0 || !ts__default["default"].isObjectLiteralExpression(source)) {
|
|
233
|
+
return evaluateExpression(source);
|
|
234
|
+
}
|
|
235
|
+
const value = {};
|
|
236
|
+
for (const prop of source.properties) {
|
|
237
|
+
if (!ts__default["default"].isPropertyAssignment(prop)) {
|
|
238
|
+
return fp.result.err(new ValSyntaxError("Expected a property assignment", prop));
|
|
239
|
+
}
|
|
240
|
+
const key = getPropertyKey(prop.name);
|
|
241
|
+
if (key === null) {
|
|
242
|
+
return fp.result.err(new ValSyntaxError("Expected a literal key", prop.name));
|
|
243
|
+
}
|
|
244
|
+
if (entries.has(key)) {
|
|
245
|
+
value[key] = {
|
|
246
|
+
_type: "json"
|
|
247
|
+
};
|
|
248
|
+
continue;
|
|
249
|
+
}
|
|
250
|
+
const evaluated = evaluateExpression(prop.initializer);
|
|
251
|
+
if (fp.result.isErr(evaluated)) return evaluated;
|
|
252
|
+
value[key] = evaluated.value;
|
|
253
|
+
}
|
|
254
|
+
return fp.result.ok(value);
|
|
255
|
+
}
|
|
219
256
|
function getPropertyKey(name) {
|
|
220
257
|
if (ts__default["default"].isStringLiteralLike(name)) {
|
|
221
258
|
return name.text;
|
|
@@ -279,6 +316,7 @@ function getImportPathFromThunk(thunk) {
|
|
|
279
316
|
exports.analyzeJsonValuesEntries = analyzeJsonValuesEntries;
|
|
280
317
|
exports.analyzeValModule = analyzeValModule;
|
|
281
318
|
exports.evaluateExpression = evaluateExpression;
|
|
319
|
+
exports.evaluateModuleSource = evaluateModuleSource;
|
|
282
320
|
exports.findObjectPropertyAssignment = findObjectPropertyAssignment;
|
|
283
321
|
exports.flatMapErrors = flatMapErrors;
|
|
284
322
|
exports.formatSyntaxError = formatSyntaxError;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var ts = require('typescript');
|
|
4
4
|
var fp = require('@valbuild/core/fp');
|
|
5
|
-
var jsonValuesModule = require('./jsonValuesModule-
|
|
5
|
+
var jsonValuesModule = require('./jsonValuesModule-625ebae8.cjs.prod.js');
|
|
6
6
|
var patch = require('@valbuild/core/patch');
|
|
7
7
|
|
|
8
8
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var ts = require('typescript');
|
|
4
4
|
var fp = require('@valbuild/core/fp');
|
|
5
|
-
var jsonValuesModule = require('./jsonValuesModule-
|
|
5
|
+
var jsonValuesModule = require('./jsonValuesModule-235bd751.cjs.dev.js');
|
|
6
6
|
var patch = require('@valbuild/core/patch');
|
|
7
7
|
|
|
8
8
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
2
|
import { pipe, result } from '@valbuild/core/fp';
|
|
3
|
-
import { a as analyzeValModule, e as findObjectPropertyAssignment, s as shallowValidateExpression, g as evaluateExpression, v as validateInitializers } from './jsonValuesModule-
|
|
3
|
+
import { a as analyzeValModule, e as findObjectPropertyAssignment, s as shallowValidateExpression, g as evaluateExpression, v as validateInitializers } from './jsonValuesModule-23eb6f53.esm.js';
|
|
4
4
|
import { PatchError, deepEqual, parseAndValidateArrayIndex, isNotRoot } from '@valbuild/core/patch';
|
|
5
5
|
|
|
6
6
|
function isValidIdentifier(text) {
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
var ts = require('typescript');
|
|
4
4
|
var fp = require('@valbuild/core/fp');
|
|
5
|
-
var ops = require('./ops-
|
|
6
|
-
var jsonValuesModule = require('./jsonValuesModule-
|
|
5
|
+
var ops = require('./ops-9ca2ef2a.cjs.dev.js');
|
|
6
|
+
var jsonValuesModule = require('./jsonValuesModule-235bd751.cjs.dev.js');
|
|
7
7
|
require('@valbuild/core/patch');
|
|
8
8
|
|
|
9
9
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
@@ -36,7 +36,7 @@ exports.insertValJsonEntry = ops.insertValJsonEntry;
|
|
|
36
36
|
exports.removeValJsonEntry = ops.removeValJsonEntry;
|
|
37
37
|
exports.analyzeJsonValuesEntries = jsonValuesModule.analyzeJsonValuesEntries;
|
|
38
38
|
exports.analyzeValModule = jsonValuesModule.analyzeValModule;
|
|
39
|
-
exports.
|
|
39
|
+
exports.evaluateModuleSource = jsonValuesModule.evaluateModuleSource;
|
|
40
40
|
exports.jsonValuesRecordKeys = jsonValuesModule.jsonValuesRecordKeys;
|
|
41
41
|
exports.parseValFile = parseValFile;
|
|
42
42
|
exports.tsOps = tsOps;
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
var ts = require('typescript');
|
|
4
4
|
var fp = require('@valbuild/core/fp');
|
|
5
|
-
var ops = require('./ops-
|
|
6
|
-
var jsonValuesModule = require('./jsonValuesModule-
|
|
5
|
+
var ops = require('./ops-0e54b388.cjs.prod.js');
|
|
6
|
+
var jsonValuesModule = require('./jsonValuesModule-625ebae8.cjs.prod.js');
|
|
7
7
|
require('@valbuild/core/patch');
|
|
8
8
|
|
|
9
9
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
@@ -36,7 +36,7 @@ exports.insertValJsonEntry = ops.insertValJsonEntry;
|
|
|
36
36
|
exports.removeValJsonEntry = ops.removeValJsonEntry;
|
|
37
37
|
exports.analyzeJsonValuesEntries = jsonValuesModule.analyzeJsonValuesEntries;
|
|
38
38
|
exports.analyzeValModule = jsonValuesModule.analyzeValModule;
|
|
39
|
-
exports.
|
|
39
|
+
exports.evaluateModuleSource = jsonValuesModule.evaluateModuleSource;
|
|
40
40
|
exports.jsonValuesRecordKeys = jsonValuesModule.jsonValuesRecordKeys;
|
|
41
41
|
exports.parseValFile = parseValFile;
|
|
42
42
|
exports.tsOps = tsOps;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
2
|
import { pipe, result } from '@valbuild/core/fp';
|
|
3
|
-
import { T as TSOps } from './ops-
|
|
4
|
-
export { i as insertValJsonEntry, r as removeValJsonEntry } from './ops-
|
|
5
|
-
import { a as analyzeValModule } from './jsonValuesModule-
|
|
6
|
-
export { c as analyzeJsonValuesEntries, a as analyzeValModule,
|
|
3
|
+
import { T as TSOps } from './ops-b904007e.esm.js';
|
|
4
|
+
export { i as insertValJsonEntry, r as removeValJsonEntry } from './ops-b904007e.esm.js';
|
|
5
|
+
import { a as analyzeValModule } from './jsonValuesModule-23eb6f53.esm.js';
|
|
6
|
+
export { c as analyzeJsonValuesEntries, a as analyzeValModule, h as evaluateModuleSource, j as jsonValuesRecordKeys } from './jsonValuesModule-23eb6f53.esm.js';
|
|
7
7
|
import '@valbuild/core/patch';
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var jsonValuesModule = require('./jsonValuesModule-
|
|
5
|
+
var jsonValuesModule = require('./jsonValuesModule-235bd751.cjs.dev.js');
|
|
6
6
|
var patch = require('@valbuild/core/patch');
|
|
7
|
-
var ops$1 = require('./ops-
|
|
7
|
+
var ops$1 = require('./ops-9ca2ef2a.cjs.dev.js');
|
|
8
8
|
var fp = require('@valbuild/core/fp');
|
|
9
9
|
var core = require('@valbuild/core');
|
|
10
10
|
var ts = require('typescript');
|
|
@@ -12,7 +12,7 @@ var path = require('path');
|
|
|
12
12
|
var fs = require('fs');
|
|
13
13
|
var vm = require('node:vm');
|
|
14
14
|
var node_module = require('node:module');
|
|
15
|
-
var ValRouterCore = require('./ValRouterCore-
|
|
15
|
+
var ValRouterCore = require('./ValRouterCore-cfa7b001.cjs.dev.js');
|
|
16
16
|
var server = require('@valbuild/ui/server');
|
|
17
17
|
var z = require('zod');
|
|
18
18
|
var zodValidationError = require('zod-validation-error');
|
|
@@ -5083,7 +5083,7 @@ async function patchModuleText(text, patch$1) {
|
|
|
5083
5083
|
const {
|
|
5084
5084
|
tsOps,
|
|
5085
5085
|
parseValFile
|
|
5086
|
-
} = await Promise.resolve().then(function () { return require('./publishKit-
|
|
5086
|
+
} = await Promise.resolve().then(function () { return require('./publishKit-34f71e50.cjs.dev.js'); });
|
|
5087
5087
|
const applied = patch.applyPatch(parseValFile(text), tsOps, patch$1);
|
|
5088
5088
|
if (fp.result.isErr(applied)) {
|
|
5089
5089
|
const reason = messagesOf(applied.error).join(" ");
|
|
@@ -5094,6 +5094,106 @@ async function patchModuleText(text, patch$1) {
|
|
|
5094
5094
|
return fp.result.ok(unescape(sourceFile.getText(sourceFile).replace(/\\u/g, "%u")));
|
|
5095
5095
|
}
|
|
5096
5096
|
|
|
5097
|
+
/**
|
|
5098
|
+
* A patch written into a module's files: {@link patchModuleText}, and an op
|
|
5099
|
+
* that reaches INTO a `.jsonValues()` entry written into that entry's own
|
|
5100
|
+
* `*.val.json`, as a save routes it (`ValOps.prepare`).
|
|
5101
|
+
*
|
|
5102
|
+
* The design tab's `create_patch` used to refuse those, and the assistant
|
|
5103
|
+
* rewrote the whole entry file to change one field -- over whatever had been
|
|
5104
|
+
* saved into it since it read it.
|
|
5105
|
+
*
|
|
5106
|
+
* Only into an entry that is already there. Adding, replacing or removing a
|
|
5107
|
+
* whole entry is a key in the `.val.ts` and a file beside it, which a save
|
|
5108
|
+
* writes from the record's schema; here that is still `write_files`, and the
|
|
5109
|
+
* error says so.
|
|
5110
|
+
*
|
|
5111
|
+
* `readFile` answers a file by its path without a leading slash: the
|
|
5112
|
+
* proposal's copy, else the build's, `null` for one the proposal deleted.
|
|
5113
|
+
* `moduleText` is `null` when no op is the module file's own; `entries` is
|
|
5114
|
+
* each entry file written, by the same kind of path.
|
|
5115
|
+
*/
|
|
5116
|
+
async function patchModuleFiles(moduleFilePath, text, readFile, patch$1) {
|
|
5117
|
+
const entryFiles = await jsonEntryFilesOf(moduleFilePath, text);
|
|
5118
|
+
const textOps = [];
|
|
5119
|
+
const entryOps = new Map();
|
|
5120
|
+
for (const op of patch$1) {
|
|
5121
|
+
const key = op.path[0];
|
|
5122
|
+
// The record itself, or one of its entries as a whole -- a new one too,
|
|
5123
|
+
// which would otherwise be written into the record's text inline.
|
|
5124
|
+
if (entryFiles.size > 0 && op.path.length <= 1) {
|
|
5125
|
+
return fp.result.err(`${key !== undefined ? `"${key}" is a whole entry` : "This is the whole record"} of a .jsonValues() record: add, replace or remove an entry by writing ${moduleFilePath} and the entry's .val.json with write_files.`);
|
|
5126
|
+
}
|
|
5127
|
+
const entryFile = key !== undefined ? entryFiles.get(key) : undefined;
|
|
5128
|
+
if (key === undefined || entryFile === undefined) {
|
|
5129
|
+
textOps.push(op);
|
|
5130
|
+
continue;
|
|
5131
|
+
}
|
|
5132
|
+
if (op.op === "file") {
|
|
5133
|
+
return fp.result.err(`A file in a .jsonValues() entry is uploaded by the Studio, not written here.`);
|
|
5134
|
+
}
|
|
5135
|
+
if ((op.op === "move" || op.op === "copy") && op.from[0] !== key) {
|
|
5136
|
+
return fp.result.err(`An op from one .jsonValues() entry into another is not written here: write the entries' .val.json files with write_files.`);
|
|
5137
|
+
}
|
|
5138
|
+
const rebased = ValRouterCore.rebaseContentOp(op, 1);
|
|
5139
|
+
if (fp.result.isErr(rebased)) return fp.result.err(rebased.error.message);
|
|
5140
|
+
entryOps.set(entryFile, [...(entryOps.get(entryFile) ?? []), rebased.value]);
|
|
5141
|
+
}
|
|
5142
|
+
let moduleText = null;
|
|
5143
|
+
if (textOps.length > 0) {
|
|
5144
|
+
const patched = await patchModuleText(text, textOps);
|
|
5145
|
+
if (fp.result.isErr(patched)) return patched;
|
|
5146
|
+
moduleText = patched.value;
|
|
5147
|
+
}
|
|
5148
|
+
const entries = {};
|
|
5149
|
+
for (const [entryFile, ops] of entryOps) {
|
|
5150
|
+
const raw = readFile(entryFile);
|
|
5151
|
+
if (raw === null || raw === undefined) {
|
|
5152
|
+
return fp.result.err(`${entryFile} is ${raw === null ? "deleted in this proposal" : "not in this proposal or on the site"}.`);
|
|
5153
|
+
}
|
|
5154
|
+
let content;
|
|
5155
|
+
try {
|
|
5156
|
+
content = JSON.parse(raw);
|
|
5157
|
+
} catch {
|
|
5158
|
+
return fp.result.err(`${entryFile} is not JSON.`);
|
|
5159
|
+
}
|
|
5160
|
+
const applied = patch.applyPatch(patch.deepClone(content), new patch.JSONOps(), ops);
|
|
5161
|
+
if (fp.result.isErr(applied)) {
|
|
5162
|
+
return fp.result.err(`${entryFile}: ${messagesOf(applied.error).join(" ")}`);
|
|
5163
|
+
}
|
|
5164
|
+
entries[entryFile] = applied.value;
|
|
5165
|
+
}
|
|
5166
|
+
return fp.result.ok({
|
|
5167
|
+
moduleText,
|
|
5168
|
+
entries
|
|
5169
|
+
});
|
|
5170
|
+
}
|
|
5171
|
+
|
|
5172
|
+
/**
|
|
5173
|
+
* Each `.jsonValues()` entry's file, by key, without a leading slash: from the
|
|
5174
|
+
* `c.json(() => import("..."))` thunks in the module's text. Empty for a
|
|
5175
|
+
* module that has none, or whose text cannot be read that way.
|
|
5176
|
+
*/
|
|
5177
|
+
async function jsonEntryFilesOf(moduleFilePath, text) {
|
|
5178
|
+
const files = new Map();
|
|
5179
|
+
if (!text.includes(".jsonValues(")) return files;
|
|
5180
|
+
const {
|
|
5181
|
+
parseValFile,
|
|
5182
|
+
analyzeValModule,
|
|
5183
|
+
analyzeJsonValuesEntries
|
|
5184
|
+
} = await Promise.resolve().then(function () { return require('./publishKit-34f71e50.cjs.dev.js'); });
|
|
5185
|
+
try {
|
|
5186
|
+
const analysis = analyzeValModule(parseValFile(text));
|
|
5187
|
+
if (fp.result.isErr(analysis)) return files;
|
|
5188
|
+
for (const [key, entry] of analyzeJsonValuesEntries(analysis.value.source)) {
|
|
5189
|
+
files.set(key, ValRouterCore.resolveExistingJsonPath(moduleFilePath, entry.importPath).replace(/^\/+/, ""));
|
|
5190
|
+
}
|
|
5191
|
+
} catch {
|
|
5192
|
+
// No `c.define` (`analyzeValModule` throws): no entries.
|
|
5193
|
+
}
|
|
5194
|
+
return files;
|
|
5195
|
+
}
|
|
5196
|
+
|
|
5097
5197
|
/**
|
|
5098
5198
|
* A patch error, or a tree of syntax errors, as sentences. Walked here rather
|
|
5099
5199
|
* than with `syntax.ts`'s `flattenErrors`, which would bring the compiler in
|
|
@@ -5118,9 +5218,11 @@ function messagesOf(error) {
|
|
|
5118
5218
|
* canvas showed it, and then it was gone.
|
|
5119
5219
|
*
|
|
5120
5220
|
* Only what can be read without running anything: a `c.define(...)` whose
|
|
5121
|
-
* Source is a literal
|
|
5122
|
-
*
|
|
5123
|
-
* the
|
|
5221
|
+
* Source is a literal, a `.jsonValues()` record's entries as the markers its
|
|
5222
|
+
* stored Source holds (`evaluateModuleSource`) -- so an entry the design tab
|
|
5223
|
+
* adds is one the proposal has. Anything else -- a Source built by code, a
|
|
5224
|
+
* file of shared schemas -- is left out, and content keeps the Source it has
|
|
5225
|
+
* for it, as before this existed.
|
|
5124
5226
|
*/
|
|
5125
5227
|
async function stagedModuleSources(files) {
|
|
5126
5228
|
const modules = Object.entries(files).flatMap(([path, text]) => text !== null && /\.val\.(ts|js)$/.test(path) ? [{
|
|
@@ -5132,8 +5234,8 @@ async function stagedModuleSources(files) {
|
|
|
5132
5234
|
const {
|
|
5133
5235
|
parseValFile,
|
|
5134
5236
|
analyzeValModule,
|
|
5135
|
-
|
|
5136
|
-
} = await Promise.resolve().then(function () { return require('./publishKit-
|
|
5237
|
+
evaluateModuleSource
|
|
5238
|
+
} = await Promise.resolve().then(function () { return require('./publishKit-34f71e50.cjs.dev.js'); });
|
|
5137
5239
|
const sources = {};
|
|
5138
5240
|
for (const {
|
|
5139
5241
|
path,
|
|
@@ -5142,7 +5244,7 @@ async function stagedModuleSources(files) {
|
|
|
5142
5244
|
try {
|
|
5143
5245
|
const analysis = analyzeValModule(parseValFile(text));
|
|
5144
5246
|
if (fp.result.isErr(analysis)) continue;
|
|
5145
|
-
const source =
|
|
5247
|
+
const source = evaluateModuleSource(analysis.value.source);
|
|
5146
5248
|
if (fp.result.isErr(source)) continue;
|
|
5147
5249
|
sources[`/${path.replace(/^\/+/, "")}`] = source.value;
|
|
5148
5250
|
} catch {
|
|
@@ -6411,25 +6513,45 @@ class ValOpsHttp extends ValRouterCore.ValOps {
|
|
|
6411
6513
|
message: `There is no module file ${moduleFilePath} in this proposal or on the site.`
|
|
6412
6514
|
});
|
|
6413
6515
|
}
|
|
6414
|
-
const patched = await
|
|
6516
|
+
const patched = await patchModuleFiles(moduleFilePath, text, path => {
|
|
6517
|
+
var _this$projectSource2;
|
|
6518
|
+
const proposalCopy = files.data.files[path];
|
|
6519
|
+
return proposalCopy !== undefined ? proposalCopy : (_this$projectSource2 = this.projectSource) === null || _this$projectSource2 === void 0 ? void 0 : _this$projectSource2[path];
|
|
6520
|
+
}, patch);
|
|
6415
6521
|
if (fp.result.isErr(patched)) {
|
|
6416
6522
|
return answer(422, {
|
|
6417
6523
|
message: `The patch does not apply to ${moduleFilePath}: ${patched.error}`
|
|
6418
6524
|
});
|
|
6419
6525
|
}
|
|
6420
|
-
|
|
6421
|
-
|
|
6526
|
+
const formatter = (_this$options = this.options) === null || _this$options === void 0 ? void 0 : _this$options.formatter;
|
|
6527
|
+
const format = async (written, path) => {
|
|
6528
|
+
if (!formatter) return fp.result.ok(written);
|
|
6422
6529
|
try {
|
|
6423
|
-
|
|
6530
|
+
return fp.result.ok(await formatter(written, path));
|
|
6424
6531
|
} catch (error) {
|
|
6532
|
+
return fp.result.err(`The patched ${path} could not be formatted: ${error instanceof Error ? error.message : String(error)}`);
|
|
6533
|
+
}
|
|
6534
|
+
};
|
|
6535
|
+
const staging = {};
|
|
6536
|
+
if (patched.value.moduleText !== null) {
|
|
6537
|
+
const formatted = await format(patched.value.moduleText, moduleFilePath);
|
|
6538
|
+
if (fp.result.isErr(formatted)) {
|
|
6425
6539
|
return answer(422, {
|
|
6426
|
-
message:
|
|
6540
|
+
message: formatted.error
|
|
6427
6541
|
});
|
|
6428
6542
|
}
|
|
6543
|
+
staging[filePath] = formatted.value;
|
|
6544
|
+
}
|
|
6545
|
+
// An entry's file as a save writes it: see `ValOps.prepare`.
|
|
6546
|
+
for (const [entryFile, content] of Object.entries(patched.value.entries)) {
|
|
6547
|
+
const formatted = await format(JSON.stringify(content, null, 2), `/${entryFile}`);
|
|
6548
|
+
if (fp.result.isErr(formatted)) {
|
|
6549
|
+
return answer(422, {
|
|
6550
|
+
message: formatted.error
|
|
6551
|
+
});
|
|
6552
|
+
}
|
|
6553
|
+
staging[entryFile] = formatted.value;
|
|
6429
6554
|
}
|
|
6430
|
-
const staging = {
|
|
6431
|
-
[filePath]: formatted
|
|
6432
|
-
};
|
|
6433
6555
|
const modules = await stagedModuleSources(staging);
|
|
6434
6556
|
const staged = await content("/files", {
|
|
6435
6557
|
method: "POST",
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var jsonValuesModule = require('./jsonValuesModule-
|
|
5
|
+
var jsonValuesModule = require('./jsonValuesModule-625ebae8.cjs.prod.js');
|
|
6
6
|
var patch = require('@valbuild/core/patch');
|
|
7
|
-
var ops$1 = require('./ops-
|
|
7
|
+
var ops$1 = require('./ops-0e54b388.cjs.prod.js');
|
|
8
8
|
var fp = require('@valbuild/core/fp');
|
|
9
9
|
var core = require('@valbuild/core');
|
|
10
10
|
var ts = require('typescript');
|
|
@@ -12,7 +12,7 @@ var path = require('path');
|
|
|
12
12
|
var fs = require('fs');
|
|
13
13
|
var vm = require('node:vm');
|
|
14
14
|
var node_module = require('node:module');
|
|
15
|
-
var ValRouterCore = require('./ValRouterCore-
|
|
15
|
+
var ValRouterCore = require('./ValRouterCore-0c7ae881.cjs.prod.js');
|
|
16
16
|
var server = require('@valbuild/ui/server');
|
|
17
17
|
var z = require('zod');
|
|
18
18
|
var zodValidationError = require('zod-validation-error');
|
|
@@ -5083,7 +5083,7 @@ async function patchModuleText(text, patch$1) {
|
|
|
5083
5083
|
const {
|
|
5084
5084
|
tsOps,
|
|
5085
5085
|
parseValFile
|
|
5086
|
-
} = await Promise.resolve().then(function () { return require('./publishKit-
|
|
5086
|
+
} = await Promise.resolve().then(function () { return require('./publishKit-65e9e564.cjs.prod.js'); });
|
|
5087
5087
|
const applied = patch.applyPatch(parseValFile(text), tsOps, patch$1);
|
|
5088
5088
|
if (fp.result.isErr(applied)) {
|
|
5089
5089
|
const reason = messagesOf(applied.error).join(" ");
|
|
@@ -5094,6 +5094,106 @@ async function patchModuleText(text, patch$1) {
|
|
|
5094
5094
|
return fp.result.ok(unescape(sourceFile.getText(sourceFile).replace(/\\u/g, "%u")));
|
|
5095
5095
|
}
|
|
5096
5096
|
|
|
5097
|
+
/**
|
|
5098
|
+
* A patch written into a module's files: {@link patchModuleText}, and an op
|
|
5099
|
+
* that reaches INTO a `.jsonValues()` entry written into that entry's own
|
|
5100
|
+
* `*.val.json`, as a save routes it (`ValOps.prepare`).
|
|
5101
|
+
*
|
|
5102
|
+
* The design tab's `create_patch` used to refuse those, and the assistant
|
|
5103
|
+
* rewrote the whole entry file to change one field -- over whatever had been
|
|
5104
|
+
* saved into it since it read it.
|
|
5105
|
+
*
|
|
5106
|
+
* Only into an entry that is already there. Adding, replacing or removing a
|
|
5107
|
+
* whole entry is a key in the `.val.ts` and a file beside it, which a save
|
|
5108
|
+
* writes from the record's schema; here that is still `write_files`, and the
|
|
5109
|
+
* error says so.
|
|
5110
|
+
*
|
|
5111
|
+
* `readFile` answers a file by its path without a leading slash: the
|
|
5112
|
+
* proposal's copy, else the build's, `null` for one the proposal deleted.
|
|
5113
|
+
* `moduleText` is `null` when no op is the module file's own; `entries` is
|
|
5114
|
+
* each entry file written, by the same kind of path.
|
|
5115
|
+
*/
|
|
5116
|
+
async function patchModuleFiles(moduleFilePath, text, readFile, patch$1) {
|
|
5117
|
+
const entryFiles = await jsonEntryFilesOf(moduleFilePath, text);
|
|
5118
|
+
const textOps = [];
|
|
5119
|
+
const entryOps = new Map();
|
|
5120
|
+
for (const op of patch$1) {
|
|
5121
|
+
const key = op.path[0];
|
|
5122
|
+
// The record itself, or one of its entries as a whole -- a new one too,
|
|
5123
|
+
// which would otherwise be written into the record's text inline.
|
|
5124
|
+
if (entryFiles.size > 0 && op.path.length <= 1) {
|
|
5125
|
+
return fp.result.err(`${key !== undefined ? `"${key}" is a whole entry` : "This is the whole record"} of a .jsonValues() record: add, replace or remove an entry by writing ${moduleFilePath} and the entry's .val.json with write_files.`);
|
|
5126
|
+
}
|
|
5127
|
+
const entryFile = key !== undefined ? entryFiles.get(key) : undefined;
|
|
5128
|
+
if (key === undefined || entryFile === undefined) {
|
|
5129
|
+
textOps.push(op);
|
|
5130
|
+
continue;
|
|
5131
|
+
}
|
|
5132
|
+
if (op.op === "file") {
|
|
5133
|
+
return fp.result.err(`A file in a .jsonValues() entry is uploaded by the Studio, not written here.`);
|
|
5134
|
+
}
|
|
5135
|
+
if ((op.op === "move" || op.op === "copy") && op.from[0] !== key) {
|
|
5136
|
+
return fp.result.err(`An op from one .jsonValues() entry into another is not written here: write the entries' .val.json files with write_files.`);
|
|
5137
|
+
}
|
|
5138
|
+
const rebased = ValRouterCore.rebaseContentOp(op, 1);
|
|
5139
|
+
if (fp.result.isErr(rebased)) return fp.result.err(rebased.error.message);
|
|
5140
|
+
entryOps.set(entryFile, [...(entryOps.get(entryFile) ?? []), rebased.value]);
|
|
5141
|
+
}
|
|
5142
|
+
let moduleText = null;
|
|
5143
|
+
if (textOps.length > 0) {
|
|
5144
|
+
const patched = await patchModuleText(text, textOps);
|
|
5145
|
+
if (fp.result.isErr(patched)) return patched;
|
|
5146
|
+
moduleText = patched.value;
|
|
5147
|
+
}
|
|
5148
|
+
const entries = {};
|
|
5149
|
+
for (const [entryFile, ops] of entryOps) {
|
|
5150
|
+
const raw = readFile(entryFile);
|
|
5151
|
+
if (raw === null || raw === undefined) {
|
|
5152
|
+
return fp.result.err(`${entryFile} is ${raw === null ? "deleted in this proposal" : "not in this proposal or on the site"}.`);
|
|
5153
|
+
}
|
|
5154
|
+
let content;
|
|
5155
|
+
try {
|
|
5156
|
+
content = JSON.parse(raw);
|
|
5157
|
+
} catch {
|
|
5158
|
+
return fp.result.err(`${entryFile} is not JSON.`);
|
|
5159
|
+
}
|
|
5160
|
+
const applied = patch.applyPatch(patch.deepClone(content), new patch.JSONOps(), ops);
|
|
5161
|
+
if (fp.result.isErr(applied)) {
|
|
5162
|
+
return fp.result.err(`${entryFile}: ${messagesOf(applied.error).join(" ")}`);
|
|
5163
|
+
}
|
|
5164
|
+
entries[entryFile] = applied.value;
|
|
5165
|
+
}
|
|
5166
|
+
return fp.result.ok({
|
|
5167
|
+
moduleText,
|
|
5168
|
+
entries
|
|
5169
|
+
});
|
|
5170
|
+
}
|
|
5171
|
+
|
|
5172
|
+
/**
|
|
5173
|
+
* Each `.jsonValues()` entry's file, by key, without a leading slash: from the
|
|
5174
|
+
* `c.json(() => import("..."))` thunks in the module's text. Empty for a
|
|
5175
|
+
* module that has none, or whose text cannot be read that way.
|
|
5176
|
+
*/
|
|
5177
|
+
async function jsonEntryFilesOf(moduleFilePath, text) {
|
|
5178
|
+
const files = new Map();
|
|
5179
|
+
if (!text.includes(".jsonValues(")) return files;
|
|
5180
|
+
const {
|
|
5181
|
+
parseValFile,
|
|
5182
|
+
analyzeValModule,
|
|
5183
|
+
analyzeJsonValuesEntries
|
|
5184
|
+
} = await Promise.resolve().then(function () { return require('./publishKit-65e9e564.cjs.prod.js'); });
|
|
5185
|
+
try {
|
|
5186
|
+
const analysis = analyzeValModule(parseValFile(text));
|
|
5187
|
+
if (fp.result.isErr(analysis)) return files;
|
|
5188
|
+
for (const [key, entry] of analyzeJsonValuesEntries(analysis.value.source)) {
|
|
5189
|
+
files.set(key, ValRouterCore.resolveExistingJsonPath(moduleFilePath, entry.importPath).replace(/^\/+/, ""));
|
|
5190
|
+
}
|
|
5191
|
+
} catch {
|
|
5192
|
+
// No `c.define` (`analyzeValModule` throws): no entries.
|
|
5193
|
+
}
|
|
5194
|
+
return files;
|
|
5195
|
+
}
|
|
5196
|
+
|
|
5097
5197
|
/**
|
|
5098
5198
|
* A patch error, or a tree of syntax errors, as sentences. Walked here rather
|
|
5099
5199
|
* than with `syntax.ts`'s `flattenErrors`, which would bring the compiler in
|
|
@@ -5118,9 +5218,11 @@ function messagesOf(error) {
|
|
|
5118
5218
|
* canvas showed it, and then it was gone.
|
|
5119
5219
|
*
|
|
5120
5220
|
* Only what can be read without running anything: a `c.define(...)` whose
|
|
5121
|
-
* Source is a literal
|
|
5122
|
-
*
|
|
5123
|
-
* the
|
|
5221
|
+
* Source is a literal, a `.jsonValues()` record's entries as the markers its
|
|
5222
|
+
* stored Source holds (`evaluateModuleSource`) -- so an entry the design tab
|
|
5223
|
+
* adds is one the proposal has. Anything else -- a Source built by code, a
|
|
5224
|
+
* file of shared schemas -- is left out, and content keeps the Source it has
|
|
5225
|
+
* for it, as before this existed.
|
|
5124
5226
|
*/
|
|
5125
5227
|
async function stagedModuleSources(files) {
|
|
5126
5228
|
const modules = Object.entries(files).flatMap(([path, text]) => text !== null && /\.val\.(ts|js)$/.test(path) ? [{
|
|
@@ -5132,8 +5234,8 @@ async function stagedModuleSources(files) {
|
|
|
5132
5234
|
const {
|
|
5133
5235
|
parseValFile,
|
|
5134
5236
|
analyzeValModule,
|
|
5135
|
-
|
|
5136
|
-
} = await Promise.resolve().then(function () { return require('./publishKit-
|
|
5237
|
+
evaluateModuleSource
|
|
5238
|
+
} = await Promise.resolve().then(function () { return require('./publishKit-65e9e564.cjs.prod.js'); });
|
|
5137
5239
|
const sources = {};
|
|
5138
5240
|
for (const {
|
|
5139
5241
|
path,
|
|
@@ -5142,7 +5244,7 @@ async function stagedModuleSources(files) {
|
|
|
5142
5244
|
try {
|
|
5143
5245
|
const analysis = analyzeValModule(parseValFile(text));
|
|
5144
5246
|
if (fp.result.isErr(analysis)) continue;
|
|
5145
|
-
const source =
|
|
5247
|
+
const source = evaluateModuleSource(analysis.value.source);
|
|
5146
5248
|
if (fp.result.isErr(source)) continue;
|
|
5147
5249
|
sources[`/${path.replace(/^\/+/, "")}`] = source.value;
|
|
5148
5250
|
} catch {
|
|
@@ -6411,25 +6513,45 @@ class ValOpsHttp extends ValRouterCore.ValOps {
|
|
|
6411
6513
|
message: `There is no module file ${moduleFilePath} in this proposal or on the site.`
|
|
6412
6514
|
});
|
|
6413
6515
|
}
|
|
6414
|
-
const patched = await
|
|
6516
|
+
const patched = await patchModuleFiles(moduleFilePath, text, path => {
|
|
6517
|
+
var _this$projectSource2;
|
|
6518
|
+
const proposalCopy = files.data.files[path];
|
|
6519
|
+
return proposalCopy !== undefined ? proposalCopy : (_this$projectSource2 = this.projectSource) === null || _this$projectSource2 === void 0 ? void 0 : _this$projectSource2[path];
|
|
6520
|
+
}, patch);
|
|
6415
6521
|
if (fp.result.isErr(patched)) {
|
|
6416
6522
|
return answer(422, {
|
|
6417
6523
|
message: `The patch does not apply to ${moduleFilePath}: ${patched.error}`
|
|
6418
6524
|
});
|
|
6419
6525
|
}
|
|
6420
|
-
|
|
6421
|
-
|
|
6526
|
+
const formatter = (_this$options = this.options) === null || _this$options === void 0 ? void 0 : _this$options.formatter;
|
|
6527
|
+
const format = async (written, path) => {
|
|
6528
|
+
if (!formatter) return fp.result.ok(written);
|
|
6422
6529
|
try {
|
|
6423
|
-
|
|
6530
|
+
return fp.result.ok(await formatter(written, path));
|
|
6424
6531
|
} catch (error) {
|
|
6532
|
+
return fp.result.err(`The patched ${path} could not be formatted: ${error instanceof Error ? error.message : String(error)}`);
|
|
6533
|
+
}
|
|
6534
|
+
};
|
|
6535
|
+
const staging = {};
|
|
6536
|
+
if (patched.value.moduleText !== null) {
|
|
6537
|
+
const formatted = await format(patched.value.moduleText, moduleFilePath);
|
|
6538
|
+
if (fp.result.isErr(formatted)) {
|
|
6425
6539
|
return answer(422, {
|
|
6426
|
-
message:
|
|
6540
|
+
message: formatted.error
|
|
6427
6541
|
});
|
|
6428
6542
|
}
|
|
6543
|
+
staging[filePath] = formatted.value;
|
|
6544
|
+
}
|
|
6545
|
+
// An entry's file as a save writes it: see `ValOps.prepare`.
|
|
6546
|
+
for (const [entryFile, content] of Object.entries(patched.value.entries)) {
|
|
6547
|
+
const formatted = await format(JSON.stringify(content, null, 2), `/${entryFile}`);
|
|
6548
|
+
if (fp.result.isErr(formatted)) {
|
|
6549
|
+
return answer(422, {
|
|
6550
|
+
message: formatted.error
|
|
6551
|
+
});
|
|
6552
|
+
}
|
|
6553
|
+
staging[entryFile] = formatted.value;
|
|
6429
6554
|
}
|
|
6430
|
-
const staging = {
|
|
6431
|
-
[filePath]: formatted
|
|
6432
|
-
};
|
|
6433
6555
|
const modules = await stagedModuleSources(staging);
|
|
6434
6556
|
const staged = await content("/files", {
|
|
6435
6557
|
method: "POST",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { a as analyzeValModule, f as flatMapErrors, b as formatSyntaxError, c as analyzeJsonValuesEntries } from './jsonValuesModule-
|
|
2
|
-
export { a as analyzeValModule, d as formatSyntaxErrorTree } from './jsonValuesModule-
|
|
1
|
+
import { a as analyzeValModule, f as flatMapErrors, b as formatSyntaxError, c as analyzeJsonValuesEntries } from './jsonValuesModule-23eb6f53.esm.js';
|
|
2
|
+
export { a as analyzeValModule, d as formatSyntaxErrorTree } from './jsonValuesModule-23eb6f53.esm.js';
|
|
3
3
|
import { applyPatch, PatchError, JSONOps, deepClone, deepEqual, sourceToPatchPath, isNotRoot } from '@valbuild/core/patch';
|
|
4
|
-
import { T as TSOps, r as removeValJsonEntry, i as insertValJsonEntry } from './ops-
|
|
4
|
+
import { T as TSOps, r as removeValJsonEntry, i as insertValJsonEntry } from './ops-b904007e.esm.js';
|
|
5
5
|
import { pipe, result } from '@valbuild/core/fp';
|
|
6
6
|
import { derefPatch, Internal, extractValModules, deserializeSchema, DEFAULT_CONTENT_HOST, DEFAULT_VAL_REMOTE_HOST } from '@valbuild/core';
|
|
7
7
|
export { hasRemoteFileSchema } from '@valbuild/core';
|
|
@@ -10,8 +10,8 @@ import path from 'path';
|
|
|
10
10
|
import fs from 'fs';
|
|
11
11
|
import vm from 'node:vm';
|
|
12
12
|
import { Module } from 'node:module';
|
|
13
|
-
import { r as resolveExistingJsonPath, f as findNestedJsonValuesRecords, v as validateJsonValuesEntries, i as isJsonValuesRootOp, a as rebaseContentOp, c as classifyJsonValuesOp, s as summaryOf, m as matchesFilter, b as byUpdatedAt, n as newSketchpad, d as isSketchpadId, e as applySketchpadChange, V as ValOps, g as bufferFromDataUrl, h as getFieldsForType, u as uploadRemoteFile, j as getFileExt, k as guessMimeTypeFromPath, l as createMetadataFromBuffer, D as DEFAULT_ANALYTICS_INGEST_URL, o as ValOpsMemory, p as isHlsMasterPlaylist, q as sumHlsSegmentDurations, t as parseHlsMasterVariants, w as largestHlsVariant, x as fallbackRefOf, y as mapHlsUris, z as movedRemoteHost, A as needsHostCheck, B as rewriteRefHost, C as fallbackRemoteHost, E as checkRemoteFiles, F as ValServer, G as createValRequestHandler, H as getNewJsonEntryPaths, I as formatPatchSourceError } from './ValRouterCore-
|
|
14
|
-
export { L as InMemoryPatchStore, o as ValOpsMemory, J as askOncePerHost, c as classifyJsonValuesOp, I as formatPatchSourceError, j as getFileExt, K as getSettings, a as rebaseContentOp, u as uploadRemoteFile } from './ValRouterCore-
|
|
13
|
+
import { r as resolveExistingJsonPath, f as findNestedJsonValuesRecords, v as validateJsonValuesEntries, i as isJsonValuesRootOp, a as rebaseContentOp, c as classifyJsonValuesOp, s as summaryOf, m as matchesFilter, b as byUpdatedAt, n as newSketchpad, d as isSketchpadId, e as applySketchpadChange, V as ValOps, g as bufferFromDataUrl, h as getFieldsForType, u as uploadRemoteFile, j as getFileExt, k as guessMimeTypeFromPath, l as createMetadataFromBuffer, D as DEFAULT_ANALYTICS_INGEST_URL, o as ValOpsMemory, p as isHlsMasterPlaylist, q as sumHlsSegmentDurations, t as parseHlsMasterVariants, w as largestHlsVariant, x as fallbackRefOf, y as mapHlsUris, z as movedRemoteHost, A as needsHostCheck, B as rewriteRefHost, C as fallbackRemoteHost, E as checkRemoteFiles, F as ValServer, G as createValRequestHandler, H as getNewJsonEntryPaths, I as formatPatchSourceError } from './ValRouterCore-5b6cccd4.esm.js';
|
|
14
|
+
export { L as InMemoryPatchStore, o as ValOpsMemory, J as askOncePerHost, c as classifyJsonValuesOp, I as formatPatchSourceError, j as getFileExt, K as getSettings, a as rebaseContentOp, u as uploadRemoteFile } from './ValRouterCore-5b6cccd4.esm.js';
|
|
15
15
|
import { createUIRequestHandler } from '@valbuild/ui/server';
|
|
16
16
|
import z$1, { z } from 'zod';
|
|
17
17
|
import { fromError } from 'zod-validation-error';
|
|
@@ -5047,7 +5047,7 @@ async function patchModuleText(text, patch) {
|
|
|
5047
5047
|
const {
|
|
5048
5048
|
tsOps,
|
|
5049
5049
|
parseValFile
|
|
5050
|
-
} = await import('./publishKit-
|
|
5050
|
+
} = await import('./publishKit-7441c0fd.esm.js');
|
|
5051
5051
|
const applied = applyPatch(parseValFile(text), tsOps, patch);
|
|
5052
5052
|
if (result.isErr(applied)) {
|
|
5053
5053
|
const reason = messagesOf(applied.error).join(" ");
|
|
@@ -5058,6 +5058,106 @@ async function patchModuleText(text, patch) {
|
|
|
5058
5058
|
return result.ok(unescape(sourceFile.getText(sourceFile).replace(/\\u/g, "%u")));
|
|
5059
5059
|
}
|
|
5060
5060
|
|
|
5061
|
+
/**
|
|
5062
|
+
* A patch written into a module's files: {@link patchModuleText}, and an op
|
|
5063
|
+
* that reaches INTO a `.jsonValues()` entry written into that entry's own
|
|
5064
|
+
* `*.val.json`, as a save routes it (`ValOps.prepare`).
|
|
5065
|
+
*
|
|
5066
|
+
* The design tab's `create_patch` used to refuse those, and the assistant
|
|
5067
|
+
* rewrote the whole entry file to change one field -- over whatever had been
|
|
5068
|
+
* saved into it since it read it.
|
|
5069
|
+
*
|
|
5070
|
+
* Only into an entry that is already there. Adding, replacing or removing a
|
|
5071
|
+
* whole entry is a key in the `.val.ts` and a file beside it, which a save
|
|
5072
|
+
* writes from the record's schema; here that is still `write_files`, and the
|
|
5073
|
+
* error says so.
|
|
5074
|
+
*
|
|
5075
|
+
* `readFile` answers a file by its path without a leading slash: the
|
|
5076
|
+
* proposal's copy, else the build's, `null` for one the proposal deleted.
|
|
5077
|
+
* `moduleText` is `null` when no op is the module file's own; `entries` is
|
|
5078
|
+
* each entry file written, by the same kind of path.
|
|
5079
|
+
*/
|
|
5080
|
+
async function patchModuleFiles(moduleFilePath, text, readFile, patch) {
|
|
5081
|
+
const entryFiles = await jsonEntryFilesOf(moduleFilePath, text);
|
|
5082
|
+
const textOps = [];
|
|
5083
|
+
const entryOps = new Map();
|
|
5084
|
+
for (const op of patch) {
|
|
5085
|
+
const key = op.path[0];
|
|
5086
|
+
// The record itself, or one of its entries as a whole -- a new one too,
|
|
5087
|
+
// which would otherwise be written into the record's text inline.
|
|
5088
|
+
if (entryFiles.size > 0 && op.path.length <= 1) {
|
|
5089
|
+
return result.err(`${key !== undefined ? `"${key}" is a whole entry` : "This is the whole record"} of a .jsonValues() record: add, replace or remove an entry by writing ${moduleFilePath} and the entry's .val.json with write_files.`);
|
|
5090
|
+
}
|
|
5091
|
+
const entryFile = key !== undefined ? entryFiles.get(key) : undefined;
|
|
5092
|
+
if (key === undefined || entryFile === undefined) {
|
|
5093
|
+
textOps.push(op);
|
|
5094
|
+
continue;
|
|
5095
|
+
}
|
|
5096
|
+
if (op.op === "file") {
|
|
5097
|
+
return result.err(`A file in a .jsonValues() entry is uploaded by the Studio, not written here.`);
|
|
5098
|
+
}
|
|
5099
|
+
if ((op.op === "move" || op.op === "copy") && op.from[0] !== key) {
|
|
5100
|
+
return result.err(`An op from one .jsonValues() entry into another is not written here: write the entries' .val.json files with write_files.`);
|
|
5101
|
+
}
|
|
5102
|
+
const rebased = rebaseContentOp(op, 1);
|
|
5103
|
+
if (result.isErr(rebased)) return result.err(rebased.error.message);
|
|
5104
|
+
entryOps.set(entryFile, [...(entryOps.get(entryFile) ?? []), rebased.value]);
|
|
5105
|
+
}
|
|
5106
|
+
let moduleText = null;
|
|
5107
|
+
if (textOps.length > 0) {
|
|
5108
|
+
const patched = await patchModuleText(text, textOps);
|
|
5109
|
+
if (result.isErr(patched)) return patched;
|
|
5110
|
+
moduleText = patched.value;
|
|
5111
|
+
}
|
|
5112
|
+
const entries = {};
|
|
5113
|
+
for (const [entryFile, ops] of entryOps) {
|
|
5114
|
+
const raw = readFile(entryFile);
|
|
5115
|
+
if (raw === null || raw === undefined) {
|
|
5116
|
+
return result.err(`${entryFile} is ${raw === null ? "deleted in this proposal" : "not in this proposal or on the site"}.`);
|
|
5117
|
+
}
|
|
5118
|
+
let content;
|
|
5119
|
+
try {
|
|
5120
|
+
content = JSON.parse(raw);
|
|
5121
|
+
} catch {
|
|
5122
|
+
return result.err(`${entryFile} is not JSON.`);
|
|
5123
|
+
}
|
|
5124
|
+
const applied = applyPatch(deepClone(content), new JSONOps(), ops);
|
|
5125
|
+
if (result.isErr(applied)) {
|
|
5126
|
+
return result.err(`${entryFile}: ${messagesOf(applied.error).join(" ")}`);
|
|
5127
|
+
}
|
|
5128
|
+
entries[entryFile] = applied.value;
|
|
5129
|
+
}
|
|
5130
|
+
return result.ok({
|
|
5131
|
+
moduleText,
|
|
5132
|
+
entries
|
|
5133
|
+
});
|
|
5134
|
+
}
|
|
5135
|
+
|
|
5136
|
+
/**
|
|
5137
|
+
* Each `.jsonValues()` entry's file, by key, without a leading slash: from the
|
|
5138
|
+
* `c.json(() => import("..."))` thunks in the module's text. Empty for a
|
|
5139
|
+
* module that has none, or whose text cannot be read that way.
|
|
5140
|
+
*/
|
|
5141
|
+
async function jsonEntryFilesOf(moduleFilePath, text) {
|
|
5142
|
+
const files = new Map();
|
|
5143
|
+
if (!text.includes(".jsonValues(")) return files;
|
|
5144
|
+
const {
|
|
5145
|
+
parseValFile,
|
|
5146
|
+
analyzeValModule,
|
|
5147
|
+
analyzeJsonValuesEntries
|
|
5148
|
+
} = await import('./publishKit-7441c0fd.esm.js');
|
|
5149
|
+
try {
|
|
5150
|
+
const analysis = analyzeValModule(parseValFile(text));
|
|
5151
|
+
if (result.isErr(analysis)) return files;
|
|
5152
|
+
for (const [key, entry] of analyzeJsonValuesEntries(analysis.value.source)) {
|
|
5153
|
+
files.set(key, resolveExistingJsonPath(moduleFilePath, entry.importPath).replace(/^\/+/, ""));
|
|
5154
|
+
}
|
|
5155
|
+
} catch {
|
|
5156
|
+
// No `c.define` (`analyzeValModule` throws): no entries.
|
|
5157
|
+
}
|
|
5158
|
+
return files;
|
|
5159
|
+
}
|
|
5160
|
+
|
|
5061
5161
|
/**
|
|
5062
5162
|
* A patch error, or a tree of syntax errors, as sentences. Walked here rather
|
|
5063
5163
|
* than with `syntax.ts`'s `flattenErrors`, which would bring the compiler in
|
|
@@ -5082,9 +5182,11 @@ function messagesOf(error) {
|
|
|
5082
5182
|
* canvas showed it, and then it was gone.
|
|
5083
5183
|
*
|
|
5084
5184
|
* Only what can be read without running anything: a `c.define(...)` whose
|
|
5085
|
-
* Source is a literal
|
|
5086
|
-
*
|
|
5087
|
-
* the
|
|
5185
|
+
* Source is a literal, a `.jsonValues()` record's entries as the markers its
|
|
5186
|
+
* stored Source holds (`evaluateModuleSource`) -- so an entry the design tab
|
|
5187
|
+
* adds is one the proposal has. Anything else -- a Source built by code, a
|
|
5188
|
+
* file of shared schemas -- is left out, and content keeps the Source it has
|
|
5189
|
+
* for it, as before this existed.
|
|
5088
5190
|
*/
|
|
5089
5191
|
async function stagedModuleSources(files) {
|
|
5090
5192
|
const modules = Object.entries(files).flatMap(([path, text]) => text !== null && /\.val\.(ts|js)$/.test(path) ? [{
|
|
@@ -5096,8 +5198,8 @@ async function stagedModuleSources(files) {
|
|
|
5096
5198
|
const {
|
|
5097
5199
|
parseValFile,
|
|
5098
5200
|
analyzeValModule,
|
|
5099
|
-
|
|
5100
|
-
} = await import('./publishKit-
|
|
5201
|
+
evaluateModuleSource
|
|
5202
|
+
} = await import('./publishKit-7441c0fd.esm.js');
|
|
5101
5203
|
const sources = {};
|
|
5102
5204
|
for (const {
|
|
5103
5205
|
path,
|
|
@@ -5106,7 +5208,7 @@ async function stagedModuleSources(files) {
|
|
|
5106
5208
|
try {
|
|
5107
5209
|
const analysis = analyzeValModule(parseValFile(text));
|
|
5108
5210
|
if (result.isErr(analysis)) continue;
|
|
5109
|
-
const source =
|
|
5211
|
+
const source = evaluateModuleSource(analysis.value.source);
|
|
5110
5212
|
if (result.isErr(source)) continue;
|
|
5111
5213
|
sources[`/${path.replace(/^\/+/, "")}`] = source.value;
|
|
5112
5214
|
} catch {
|
|
@@ -6375,25 +6477,45 @@ class ValOpsHttp extends ValOps {
|
|
|
6375
6477
|
message: `There is no module file ${moduleFilePath} in this proposal or on the site.`
|
|
6376
6478
|
});
|
|
6377
6479
|
}
|
|
6378
|
-
const patched = await
|
|
6480
|
+
const patched = await patchModuleFiles(moduleFilePath, text, path => {
|
|
6481
|
+
var _this$projectSource2;
|
|
6482
|
+
const proposalCopy = files.data.files[path];
|
|
6483
|
+
return proposalCopy !== undefined ? proposalCopy : (_this$projectSource2 = this.projectSource) === null || _this$projectSource2 === void 0 ? void 0 : _this$projectSource2[path];
|
|
6484
|
+
}, patch);
|
|
6379
6485
|
if (result.isErr(patched)) {
|
|
6380
6486
|
return answer(422, {
|
|
6381
6487
|
message: `The patch does not apply to ${moduleFilePath}: ${patched.error}`
|
|
6382
6488
|
});
|
|
6383
6489
|
}
|
|
6384
|
-
|
|
6385
|
-
|
|
6490
|
+
const formatter = (_this$options = this.options) === null || _this$options === void 0 ? void 0 : _this$options.formatter;
|
|
6491
|
+
const format = async (written, path) => {
|
|
6492
|
+
if (!formatter) return result.ok(written);
|
|
6386
6493
|
try {
|
|
6387
|
-
|
|
6494
|
+
return result.ok(await formatter(written, path));
|
|
6388
6495
|
} catch (error) {
|
|
6496
|
+
return result.err(`The patched ${path} could not be formatted: ${error instanceof Error ? error.message : String(error)}`);
|
|
6497
|
+
}
|
|
6498
|
+
};
|
|
6499
|
+
const staging = {};
|
|
6500
|
+
if (patched.value.moduleText !== null) {
|
|
6501
|
+
const formatted = await format(patched.value.moduleText, moduleFilePath);
|
|
6502
|
+
if (result.isErr(formatted)) {
|
|
6389
6503
|
return answer(422, {
|
|
6390
|
-
message:
|
|
6504
|
+
message: formatted.error
|
|
6391
6505
|
});
|
|
6392
6506
|
}
|
|
6507
|
+
staging[filePath] = formatted.value;
|
|
6508
|
+
}
|
|
6509
|
+
// An entry's file as a save writes it: see `ValOps.prepare`.
|
|
6510
|
+
for (const [entryFile, content] of Object.entries(patched.value.entries)) {
|
|
6511
|
+
const formatted = await format(JSON.stringify(content, null, 2), `/${entryFile}`);
|
|
6512
|
+
if (result.isErr(formatted)) {
|
|
6513
|
+
return answer(422, {
|
|
6514
|
+
message: formatted.error
|
|
6515
|
+
});
|
|
6516
|
+
}
|
|
6517
|
+
staging[entryFile] = formatted.value;
|
|
6393
6518
|
}
|
|
6394
|
-
const staging = {
|
|
6395
|
-
[filePath]: formatted
|
|
6396
|
-
};
|
|
6397
6519
|
const modules = await stagedModuleSources(staging);
|
|
6398
6520
|
const staged = await content("/files", {
|
|
6399
6521
|
method: "POST",
|
package/package.json
CHANGED
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
],
|
|
28
28
|
"exports": true
|
|
29
29
|
},
|
|
30
|
-
"version": "0.150.
|
|
30
|
+
"version": "0.150.23",
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@prettier/sync": "^0.6.1",
|
|
33
33
|
"@types/jest": "^30.0.0",
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
"zod": "^4.4.3",
|
|
43
43
|
"zod-validation-error": "^5.0.0",
|
|
44
44
|
"@valbuild/core": "0.150.3",
|
|
45
|
-
"@valbuild/
|
|
46
|
-
"@valbuild/
|
|
45
|
+
"@valbuild/shared": "0.150.20",
|
|
46
|
+
"@valbuild/ui": "0.150.23"
|
|
47
47
|
},
|
|
48
48
|
"engines": {
|
|
49
49
|
"node": "^20.19.0 || >=22"
|