@valbuild/shared 0.63.1 → 0.63.5

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.
@@ -16,9 +16,12 @@ export declare class ValStore {
16
16
  }> | result.Err<{
17
17
  message: string;
18
18
  }>>;
19
- applyPatch(path: ModuleFilePath, patchIds: PatchId[], patch: Patch): Promise<result.Result<Record<ModuleFilePath, {
20
- patchIds: PatchId[];
21
- }>, PatchError | {
19
+ applyPatch(path: ModuleFilePath, patchIds: PatchId[], patch: Patch): Promise<result.Result<{
20
+ modules: Record<ModuleFilePath, {
21
+ patchIds: PatchId[];
22
+ }>;
23
+ newPatchId: PatchId;
24
+ }, PatchError | {
22
25
  message: string;
23
26
  }>>;
24
27
  private emitEvent;
@@ -1882,7 +1882,10 @@ var ValStore = /*#__PURE__*/function () {
1882
1882
  while (1) switch (_context.prev = _context.next) {
1883
1883
  case 0:
1884
1884
  _context.next = 2;
1885
- return this.api.getPatches();
1885
+ return this.api.getPatches({
1886
+ omitPatches: true,
1887
+ moduleFilePaths: paths
1888
+ });
1886
1889
  case 2:
1887
1890
  patches = _context.sent;
1888
1891
  if (!fp.result.isErr(patches)) {
@@ -1892,18 +1895,7 @@ var ValStore = /*#__PURE__*/function () {
1892
1895
  console.error("Val: failed to get patches", patches.error);
1893
1896
  return _context.abrupt("return");
1894
1897
  case 6:
1895
- filteredPatches = Object.entries(patches.value).flatMap(function (_ref) {
1896
- var _ref2 = _slicedToArray(_ref, 2),
1897
- patchModuleFilePath = _ref2[0],
1898
- mp = _ref2[1];
1899
- if (paths.includes(patchModuleFilePath)) {
1900
- return mp.map(function (p) {
1901
- return p.patch_id;
1902
- });
1903
- } else {
1904
- return [];
1905
- }
1906
- });
1898
+ filteredPatches = Object.keys(patches.value.patches);
1907
1899
  _context.next = 9;
1908
1900
  return this.api.putTree({
1909
1901
  patchIds: filteredPatches
@@ -1960,11 +1952,7 @@ var ValStore = /*#__PURE__*/function () {
1960
1952
  console.error("Val: failed to get patches", patches.error);
1961
1953
  return _context2.abrupt("return");
1962
1954
  case 6:
1963
- allPatches = Object.values(patches.value).flatMap(function (mp) {
1964
- return mp.map(function (p) {
1965
- return p.patch_id;
1966
- });
1967
- });
1955
+ allPatches = Object.keys(patches.value.patches);
1968
1956
  _context2.next = 9;
1969
1957
  return this.api.putTree({
1970
1958
  patchIds: allPatches
@@ -2110,7 +2098,7 @@ var ValStore = /*#__PURE__*/function () {
2110
2098
  key: "applyPatch",
2111
2099
  value: function () {
2112
2100
  var _applyPatch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(path, patchIds, patch) {
2113
- var data, fetchedSource, _data$value$modules$p, _i5, _Array$from3, _Array$from3$_i, subscriberId, subscriberModules;
2101
+ var data, newPatchId, fetchedSource, _data$value$modules$p, _i5, _Array$from3, _Array$from3$_i, subscriberId, subscriberModules;
2114
2102
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
2115
2103
  while (1) switch (_context4.prev = _context4.next) {
2116
2104
  case 0:
@@ -2126,12 +2114,22 @@ var ValStore = /*#__PURE__*/function () {
2126
2114
  case 2:
2127
2115
  data = _context4.sent;
2128
2116
  if (!fp.result.isOk(data)) {
2129
- _context4.next = 16;
2117
+ _context4.next = 20;
2130
2118
  break;
2131
2119
  }
2120
+ newPatchId = data.value.newPatchId;
2121
+ if (newPatchId) {
2122
+ _context4.next = 8;
2123
+ break;
2124
+ }
2125
+ console.error("Val: could create patch", data);
2126
+ return _context4.abrupt("return", fp.result.err({
2127
+ message: "Val: could not create patch."
2128
+ }));
2129
+ case 8:
2132
2130
  fetchedSource = data.value.modules[path].source;
2133
2131
  if (!(fetchedSource !== undefined)) {
2134
- _context4.next = 12;
2132
+ _context4.next = 16;
2135
2133
  break;
2136
2134
  }
2137
2135
  this.drafts[path] = fetchedSource;
@@ -2143,23 +2141,26 @@ var ValStore = /*#__PURE__*/function () {
2143
2141
  this.emitChange(subscriberId);
2144
2142
  }
2145
2143
  }
2146
- return _context4.abrupt("return", fp.result.ok(_defineProperty({}, path, {
2147
- patchIds: ((_data$value$modules$p = data.value.modules[path].patches) === null || _data$value$modules$p === void 0 ? void 0 : _data$value$modules$p.applied) || []
2148
- })));
2149
- case 12:
2144
+ return _context4.abrupt("return", fp.result.ok({
2145
+ newPatchId: newPatchId,
2146
+ modules: _defineProperty({}, path, {
2147
+ patchIds: ((_data$value$modules$p = data.value.modules[path].patches) === null || _data$value$modules$p === void 0 ? void 0 : _data$value$modules$p.applied) || []
2148
+ })
2149
+ }));
2150
+ case 16:
2150
2151
  console.error("Val: could not patch");
2151
2152
  return _context4.abrupt("return", fp.result.err({
2152
2153
  message: "Val: could not fetch data. Verify that the module exists."
2153
2154
  }));
2154
- case 14:
2155
- _context4.next = 18;
2155
+ case 18:
2156
+ _context4.next = 22;
2156
2157
  break;
2157
- case 16:
2158
+ case 20:
2158
2159
  console.error("Val: failed to get module", data.error);
2159
2160
  return _context4.abrupt("return", fp.result.err({
2160
2161
  message: "Val: could not fetch data. Verify that Val is correctly configured."
2161
2162
  }));
2162
- case 18:
2163
+ case 22:
2163
2164
  case "end":
2164
2165
  return _context4.stop();
2165
2166
  }
@@ -1882,7 +1882,10 @@ var ValStore = /*#__PURE__*/function () {
1882
1882
  while (1) switch (_context.prev = _context.next) {
1883
1883
  case 0:
1884
1884
  _context.next = 2;
1885
- return this.api.getPatches();
1885
+ return this.api.getPatches({
1886
+ omitPatches: true,
1887
+ moduleFilePaths: paths
1888
+ });
1886
1889
  case 2:
1887
1890
  patches = _context.sent;
1888
1891
  if (!fp.result.isErr(patches)) {
@@ -1892,18 +1895,7 @@ var ValStore = /*#__PURE__*/function () {
1892
1895
  console.error("Val: failed to get patches", patches.error);
1893
1896
  return _context.abrupt("return");
1894
1897
  case 6:
1895
- filteredPatches = Object.entries(patches.value).flatMap(function (_ref) {
1896
- var _ref2 = _slicedToArray(_ref, 2),
1897
- patchModuleFilePath = _ref2[0],
1898
- mp = _ref2[1];
1899
- if (paths.includes(patchModuleFilePath)) {
1900
- return mp.map(function (p) {
1901
- return p.patch_id;
1902
- });
1903
- } else {
1904
- return [];
1905
- }
1906
- });
1898
+ filteredPatches = Object.keys(patches.value.patches);
1907
1899
  _context.next = 9;
1908
1900
  return this.api.putTree({
1909
1901
  patchIds: filteredPatches
@@ -1960,11 +1952,7 @@ var ValStore = /*#__PURE__*/function () {
1960
1952
  console.error("Val: failed to get patches", patches.error);
1961
1953
  return _context2.abrupt("return");
1962
1954
  case 6:
1963
- allPatches = Object.values(patches.value).flatMap(function (mp) {
1964
- return mp.map(function (p) {
1965
- return p.patch_id;
1966
- });
1967
- });
1955
+ allPatches = Object.keys(patches.value.patches);
1968
1956
  _context2.next = 9;
1969
1957
  return this.api.putTree({
1970
1958
  patchIds: allPatches
@@ -2110,7 +2098,7 @@ var ValStore = /*#__PURE__*/function () {
2110
2098
  key: "applyPatch",
2111
2099
  value: function () {
2112
2100
  var _applyPatch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(path, patchIds, patch) {
2113
- var data, fetchedSource, _data$value$modules$p, _i5, _Array$from3, _Array$from3$_i, subscriberId, subscriberModules;
2101
+ var data, newPatchId, fetchedSource, _data$value$modules$p, _i5, _Array$from3, _Array$from3$_i, subscriberId, subscriberModules;
2114
2102
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
2115
2103
  while (1) switch (_context4.prev = _context4.next) {
2116
2104
  case 0:
@@ -2126,12 +2114,22 @@ var ValStore = /*#__PURE__*/function () {
2126
2114
  case 2:
2127
2115
  data = _context4.sent;
2128
2116
  if (!fp.result.isOk(data)) {
2129
- _context4.next = 16;
2117
+ _context4.next = 20;
2130
2118
  break;
2131
2119
  }
2120
+ newPatchId = data.value.newPatchId;
2121
+ if (newPatchId) {
2122
+ _context4.next = 8;
2123
+ break;
2124
+ }
2125
+ console.error("Val: could create patch", data);
2126
+ return _context4.abrupt("return", fp.result.err({
2127
+ message: "Val: could not create patch."
2128
+ }));
2129
+ case 8:
2132
2130
  fetchedSource = data.value.modules[path].source;
2133
2131
  if (!(fetchedSource !== undefined)) {
2134
- _context4.next = 12;
2132
+ _context4.next = 16;
2135
2133
  break;
2136
2134
  }
2137
2135
  this.drafts[path] = fetchedSource;
@@ -2143,23 +2141,26 @@ var ValStore = /*#__PURE__*/function () {
2143
2141
  this.emitChange(subscriberId);
2144
2142
  }
2145
2143
  }
2146
- return _context4.abrupt("return", fp.result.ok(_defineProperty({}, path, {
2147
- patchIds: ((_data$value$modules$p = data.value.modules[path].patches) === null || _data$value$modules$p === void 0 ? void 0 : _data$value$modules$p.applied) || []
2148
- })));
2149
- case 12:
2144
+ return _context4.abrupt("return", fp.result.ok({
2145
+ newPatchId: newPatchId,
2146
+ modules: _defineProperty({}, path, {
2147
+ patchIds: ((_data$value$modules$p = data.value.modules[path].patches) === null || _data$value$modules$p === void 0 ? void 0 : _data$value$modules$p.applied) || []
2148
+ })
2149
+ }));
2150
+ case 16:
2150
2151
  console.error("Val: could not patch");
2151
2152
  return _context4.abrupt("return", fp.result.err({
2152
2153
  message: "Val: could not fetch data. Verify that the module exists."
2153
2154
  }));
2154
- case 14:
2155
- _context4.next = 18;
2155
+ case 18:
2156
+ _context4.next = 22;
2156
2157
  break;
2157
- case 16:
2158
+ case 20:
2158
2159
  console.error("Val: failed to get module", data.error);
2159
2160
  return _context4.abrupt("return", fp.result.err({
2160
2161
  message: "Val: could not fetch data. Verify that Val is correctly configured."
2161
2162
  }));
2162
- case 18:
2163
+ case 22:
2163
2164
  case "end":
2164
2165
  return _context4.stop();
2165
2166
  }
@@ -1878,7 +1878,10 @@ var ValStore = /*#__PURE__*/function () {
1878
1878
  while (1) switch (_context.prev = _context.next) {
1879
1879
  case 0:
1880
1880
  _context.next = 2;
1881
- return this.api.getPatches();
1881
+ return this.api.getPatches({
1882
+ omitPatches: true,
1883
+ moduleFilePaths: paths
1884
+ });
1882
1885
  case 2:
1883
1886
  patches = _context.sent;
1884
1887
  if (!result.isErr(patches)) {
@@ -1888,18 +1891,7 @@ var ValStore = /*#__PURE__*/function () {
1888
1891
  console.error("Val: failed to get patches", patches.error);
1889
1892
  return _context.abrupt("return");
1890
1893
  case 6:
1891
- filteredPatches = Object.entries(patches.value).flatMap(function (_ref) {
1892
- var _ref2 = _slicedToArray(_ref, 2),
1893
- patchModuleFilePath = _ref2[0],
1894
- mp = _ref2[1];
1895
- if (paths.includes(patchModuleFilePath)) {
1896
- return mp.map(function (p) {
1897
- return p.patch_id;
1898
- });
1899
- } else {
1900
- return [];
1901
- }
1902
- });
1894
+ filteredPatches = Object.keys(patches.value.patches);
1903
1895
  _context.next = 9;
1904
1896
  return this.api.putTree({
1905
1897
  patchIds: filteredPatches
@@ -1956,11 +1948,7 @@ var ValStore = /*#__PURE__*/function () {
1956
1948
  console.error("Val: failed to get patches", patches.error);
1957
1949
  return _context2.abrupt("return");
1958
1950
  case 6:
1959
- allPatches = Object.values(patches.value).flatMap(function (mp) {
1960
- return mp.map(function (p) {
1961
- return p.patch_id;
1962
- });
1963
- });
1951
+ allPatches = Object.keys(patches.value.patches);
1964
1952
  _context2.next = 9;
1965
1953
  return this.api.putTree({
1966
1954
  patchIds: allPatches
@@ -2106,7 +2094,7 @@ var ValStore = /*#__PURE__*/function () {
2106
2094
  key: "applyPatch",
2107
2095
  value: function () {
2108
2096
  var _applyPatch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(path, patchIds, patch) {
2109
- var data, fetchedSource, _data$value$modules$p, _i5, _Array$from3, _Array$from3$_i, subscriberId, subscriberModules;
2097
+ var data, newPatchId, fetchedSource, _data$value$modules$p, _i5, _Array$from3, _Array$from3$_i, subscriberId, subscriberModules;
2110
2098
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
2111
2099
  while (1) switch (_context4.prev = _context4.next) {
2112
2100
  case 0:
@@ -2122,12 +2110,22 @@ var ValStore = /*#__PURE__*/function () {
2122
2110
  case 2:
2123
2111
  data = _context4.sent;
2124
2112
  if (!result.isOk(data)) {
2125
- _context4.next = 16;
2113
+ _context4.next = 20;
2126
2114
  break;
2127
2115
  }
2116
+ newPatchId = data.value.newPatchId;
2117
+ if (newPatchId) {
2118
+ _context4.next = 8;
2119
+ break;
2120
+ }
2121
+ console.error("Val: could create patch", data);
2122
+ return _context4.abrupt("return", result.err({
2123
+ message: "Val: could not create patch."
2124
+ }));
2125
+ case 8:
2128
2126
  fetchedSource = data.value.modules[path].source;
2129
2127
  if (!(fetchedSource !== undefined)) {
2130
- _context4.next = 12;
2128
+ _context4.next = 16;
2131
2129
  break;
2132
2130
  }
2133
2131
  this.drafts[path] = fetchedSource;
@@ -2139,23 +2137,26 @@ var ValStore = /*#__PURE__*/function () {
2139
2137
  this.emitChange(subscriberId);
2140
2138
  }
2141
2139
  }
2142
- return _context4.abrupt("return", result.ok(_defineProperty({}, path, {
2143
- patchIds: ((_data$value$modules$p = data.value.modules[path].patches) === null || _data$value$modules$p === void 0 ? void 0 : _data$value$modules$p.applied) || []
2144
- })));
2145
- case 12:
2140
+ return _context4.abrupt("return", result.ok({
2141
+ newPatchId: newPatchId,
2142
+ modules: _defineProperty({}, path, {
2143
+ patchIds: ((_data$value$modules$p = data.value.modules[path].patches) === null || _data$value$modules$p === void 0 ? void 0 : _data$value$modules$p.applied) || []
2144
+ })
2145
+ }));
2146
+ case 16:
2146
2147
  console.error("Val: could not patch");
2147
2148
  return _context4.abrupt("return", result.err({
2148
2149
  message: "Val: could not fetch data. Verify that the module exists."
2149
2150
  }));
2150
- case 14:
2151
- _context4.next = 18;
2151
+ case 18:
2152
+ _context4.next = 22;
2152
2153
  break;
2153
- case 16:
2154
+ case 20:
2154
2155
  console.error("Val: failed to get module", data.error);
2155
2156
  return _context4.abrupt("return", result.err({
2156
2157
  message: "Val: could not fetch data. Verify that Val is correctly configured."
2157
2158
  }));
2158
- case 18:
2159
+ case 22:
2159
2160
  case "end":
2160
2161
  return _context4.stop();
2161
2162
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@valbuild/shared",
3
- "version": "0.63.1",
3
+ "version": "0.63.5",
4
4
  "private": false,
5
5
  "description": "Val shared types and utilities",
6
6
  "scripts": {
@@ -29,7 +29,7 @@
29
29
  "exports": true
30
30
  },
31
31
  "dependencies": {
32
- "@valbuild/core": "~0.63.1",
32
+ "@valbuild/core": "~0.63.5",
33
33
  "marked": "^9.0.3",
34
34
  "zod": "^3.22.4"
35
35
  },