@valbuild/shared 0.60.17 → 0.60.19
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.
@@ -30,6 +30,15 @@ export declare class ValStore {
|
|
30
30
|
};
|
31
31
|
};
|
32
32
|
}>>;
|
33
|
+
initialize(): Promise<result.Result<ModuleId[], {
|
34
|
+
message: string;
|
35
|
+
details: {
|
36
|
+
fetchError: {
|
37
|
+
message: string;
|
38
|
+
statusCode?: number;
|
39
|
+
};
|
40
|
+
};
|
41
|
+
}>>;
|
33
42
|
private updateTree;
|
34
43
|
subscribe: (moduleIds: ModuleId[]) => (listener: () => void) => () => void;
|
35
44
|
private emitChange;
|
@@ -2065,7 +2065,9 @@ var ValStore = /*#__PURE__*/function () {
|
|
2065
2065
|
return this.api.getTree({
|
2066
2066
|
patch: true,
|
2067
2067
|
treePath: moduleId,
|
2068
|
-
includeSource: true
|
2068
|
+
includeSource: true,
|
2069
|
+
includeSchema: true,
|
2070
|
+
validate: true
|
2069
2071
|
});
|
2070
2072
|
case 5:
|
2071
2073
|
data = _context.sent;
|
@@ -2079,7 +2081,8 @@ var ValStore = /*#__PURE__*/function () {
|
|
2079
2081
|
}
|
2080
2082
|
console.error("Val: could not find the module", {
|
2081
2083
|
moduleIds: Object.keys(data.value.modules),
|
2082
|
-
moduleId: moduleId
|
2084
|
+
moduleId: moduleId,
|
2085
|
+
data: data
|
2083
2086
|
});
|
2084
2087
|
return _context.abrupt("return", fp.result.err({
|
2085
2088
|
message: "Could not fetch data. Could not find the module: " + moduleId + ". Verify that the module id and file name is correct."
|
@@ -2139,7 +2142,9 @@ var ValStore = /*#__PURE__*/function () {
|
|
2139
2142
|
return this.api.getTree({
|
2140
2143
|
patch: true,
|
2141
2144
|
treePath: moduleId,
|
2142
|
-
includeSource: true
|
2145
|
+
includeSource: true,
|
2146
|
+
includeSchema: true,
|
2147
|
+
validate: true
|
2143
2148
|
});
|
2144
2149
|
case 5:
|
2145
2150
|
data = _context2.sent;
|
@@ -2267,39 +2272,96 @@ var ValStore = /*#__PURE__*/function () {
|
|
2267
2272
|
}
|
2268
2273
|
return reset;
|
2269
2274
|
}()
|
2275
|
+
}, {
|
2276
|
+
key: "initialize",
|
2277
|
+
value: function () {
|
2278
|
+
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
2279
|
+
var data, moduleIds, _i2, _arr, moduleId, schema, msg;
|
2280
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
2281
|
+
while (1) switch (_context5.prev = _context5.next) {
|
2282
|
+
case 0:
|
2283
|
+
_context5.next = 2;
|
2284
|
+
return this.api.getTree({
|
2285
|
+
patch: false,
|
2286
|
+
includeSource: false,
|
2287
|
+
includeSchema: true,
|
2288
|
+
validate: false
|
2289
|
+
});
|
2290
|
+
case 2:
|
2291
|
+
data = _context5.sent;
|
2292
|
+
if (!fp.result.isOk(data)) {
|
2293
|
+
_context5.next = 9;
|
2294
|
+
break;
|
2295
|
+
}
|
2296
|
+
moduleIds = [];
|
2297
|
+
for (_i2 = 0, _arr = Object.keys(data.value.modules); _i2 < _arr.length; _i2++) {
|
2298
|
+
moduleId = _arr[_i2];
|
2299
|
+
schema = data.value.modules[moduleId].schema;
|
2300
|
+
if (schema) {
|
2301
|
+
moduleIds.push(moduleId);
|
2302
|
+
this.schema[moduleId] = schema;
|
2303
|
+
}
|
2304
|
+
}
|
2305
|
+
return _context5.abrupt("return", fp.result.ok(moduleIds));
|
2306
|
+
case 9:
|
2307
|
+
msg = "Failed to fetch content. ";
|
2308
|
+
if (data.error.statusCode === 401) {
|
2309
|
+
msg += "Authorization failed - check that you are logged in.";
|
2310
|
+
} else {
|
2311
|
+
msg += "Get a developer to verify that Val is correctly setup.";
|
2312
|
+
}
|
2313
|
+
return _context5.abrupt("return", fp.result.err({
|
2314
|
+
message: msg,
|
2315
|
+
details: {
|
2316
|
+
fetchError: data.error
|
2317
|
+
}
|
2318
|
+
}));
|
2319
|
+
case 12:
|
2320
|
+
case "end":
|
2321
|
+
return _context5.stop();
|
2322
|
+
}
|
2323
|
+
}, _callee5, this);
|
2324
|
+
}));
|
2325
|
+
function initialize() {
|
2326
|
+
return _initialize.apply(this, arguments);
|
2327
|
+
}
|
2328
|
+
return initialize;
|
2329
|
+
}()
|
2270
2330
|
}, {
|
2271
2331
|
key: "updateTree",
|
2272
2332
|
value: function () {
|
2273
|
-
var _updateTree = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
2333
|
+
var _updateTree = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(treePath) {
|
2274
2334
|
var _this3 = this;
|
2275
|
-
var data, moduleIds, updatedSubscriberIds, subscriberIds, _loop,
|
2276
|
-
return _regeneratorRuntime().wrap(function
|
2277
|
-
while (1) switch (
|
2335
|
+
var data, moduleIds, updatedSubscriberIds, subscriberIds, _loop, _i3, _arr2, _i4, _Array$from2, _Array$from2$_i, updatedSubscriberId, _moduleIds, subscriberModules, msg;
|
2336
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context7) {
|
2337
|
+
while (1) switch (_context7.prev = _context7.next) {
|
2278
2338
|
case 0:
|
2279
|
-
|
2339
|
+
_context7.next = 2;
|
2280
2340
|
return this.api.getTree({
|
2281
2341
|
patch: true,
|
2282
2342
|
treePath: treePath,
|
2283
|
-
includeSource: true
|
2343
|
+
includeSource: true,
|
2344
|
+
includeSchema: true,
|
2345
|
+
validate: true
|
2284
2346
|
});
|
2285
2347
|
case 2:
|
2286
|
-
data =
|
2348
|
+
data = _context7.sent;
|
2287
2349
|
moduleIds = [];
|
2288
2350
|
if (!fp.result.isOk(data)) {
|
2289
|
-
|
2351
|
+
_context7.next = 18;
|
2290
2352
|
break;
|
2291
2353
|
}
|
2292
2354
|
updatedSubscriberIds = new Map();
|
2293
2355
|
subscriberIds = Array.from(this.subscribers.keys()); // Figure out which modules have been updated and map to updated subscribed id
|
2294
2356
|
_loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop() {
|
2295
2357
|
var moduleId, source, updatedSubscriberId;
|
2296
|
-
return _regeneratorRuntime().wrap(function _loop$(
|
2297
|
-
while (1) switch (
|
2358
|
+
return _regeneratorRuntime().wrap(function _loop$(_context6) {
|
2359
|
+
while (1) switch (_context6.prev = _context6.next) {
|
2298
2360
|
case 0:
|
2299
|
-
moduleId =
|
2300
|
-
moduleIds.push(moduleId);
|
2361
|
+
moduleId = _arr2[_i3];
|
2301
2362
|
source = data.value.modules[moduleId].source;
|
2302
2363
|
if (typeof source !== "undefined") {
|
2364
|
+
moduleIds.push(moduleId);
|
2303
2365
|
_this3.emitEvent(moduleId, source);
|
2304
2366
|
updatedSubscriberId = subscriberIds.find(function (subscriberId) {
|
2305
2367
|
return subscriberId.includes(moduleId);
|
@@ -2309,27 +2371,27 @@ var ValStore = /*#__PURE__*/function () {
|
|
2309
2371
|
updatedSubscriberIds.set(updatedSubscriberId, (updatedSubscriberIds.get(updatedSubscriberId) || []).concat(moduleId));
|
2310
2372
|
}
|
2311
2373
|
}
|
2312
|
-
case
|
2374
|
+
case 3:
|
2313
2375
|
case "end":
|
2314
|
-
return
|
2376
|
+
return _context6.stop();
|
2315
2377
|
}
|
2316
2378
|
}, _loop);
|
2317
2379
|
});
|
2318
|
-
|
2380
|
+
_i3 = 0, _arr2 = Object.keys(data.value.modules);
|
2319
2381
|
case 9:
|
2320
|
-
if (!(
|
2321
|
-
|
2382
|
+
if (!(_i3 < _arr2.length)) {
|
2383
|
+
_context7.next = 14;
|
2322
2384
|
break;
|
2323
2385
|
}
|
2324
|
-
return
|
2386
|
+
return _context7.delegateYield(_loop(), "t0", 11);
|
2325
2387
|
case 11:
|
2326
|
-
|
2327
|
-
|
2388
|
+
_i3++;
|
2389
|
+
_context7.next = 9;
|
2328
2390
|
break;
|
2329
2391
|
case 14:
|
2330
2392
|
// For all updated subscribers: set new module data and emit change
|
2331
|
-
for (
|
2332
|
-
_Array$from2$_i = _slicedToArray(_Array$from2[
|
2393
|
+
for (_i4 = 0, _Array$from2 = Array.from(updatedSubscriberIds.entries()); _i4 < _Array$from2.length; _i4++) {
|
2394
|
+
_Array$from2$_i = _slicedToArray(_Array$from2[_i4], 2), updatedSubscriberId = _Array$from2$_i[0], _moduleIds = _Array$from2$_i[1];
|
2333
2395
|
subscriberModules = Object.fromEntries(_moduleIds.flatMap(function (moduleId) {
|
2334
2396
|
var source = data.value.modules[moduleId].source;
|
2335
2397
|
if (!source) {
|
@@ -2340,7 +2402,7 @@ var ValStore = /*#__PURE__*/function () {
|
|
2340
2402
|
this.subscribers.set(updatedSubscriberId, subscriberModules);
|
2341
2403
|
this.emitChange(updatedSubscriberId);
|
2342
2404
|
}
|
2343
|
-
return
|
2405
|
+
return _context7.abrupt("return", fp.result.ok(moduleIds));
|
2344
2406
|
case 18:
|
2345
2407
|
msg = "Failed to fetch content. ";
|
2346
2408
|
if (data.error.statusCode === 401) {
|
@@ -2348,7 +2410,7 @@ var ValStore = /*#__PURE__*/function () {
|
|
2348
2410
|
} else {
|
2349
2411
|
msg += "Get a developer to verify that Val is correctly setup.";
|
2350
2412
|
}
|
2351
|
-
return
|
2413
|
+
return _context7.abrupt("return", fp.result.err({
|
2352
2414
|
message: msg,
|
2353
2415
|
details: {
|
2354
2416
|
fetchError: data.error
|
@@ -2356,9 +2418,9 @@ var ValStore = /*#__PURE__*/function () {
|
|
2356
2418
|
}));
|
2357
2419
|
case 21:
|
2358
2420
|
case "end":
|
2359
|
-
return
|
2421
|
+
return _context7.stop();
|
2360
2422
|
}
|
2361
|
-
},
|
2423
|
+
}, _callee6, this);
|
2362
2424
|
}));
|
2363
2425
|
function updateTree(_x5) {
|
2364
2426
|
return _updateTree.apply(this, arguments);
|
@@ -2065,7 +2065,9 @@ var ValStore = /*#__PURE__*/function () {
|
|
2065
2065
|
return this.api.getTree({
|
2066
2066
|
patch: true,
|
2067
2067
|
treePath: moduleId,
|
2068
|
-
includeSource: true
|
2068
|
+
includeSource: true,
|
2069
|
+
includeSchema: true,
|
2070
|
+
validate: true
|
2069
2071
|
});
|
2070
2072
|
case 5:
|
2071
2073
|
data = _context.sent;
|
@@ -2079,7 +2081,8 @@ var ValStore = /*#__PURE__*/function () {
|
|
2079
2081
|
}
|
2080
2082
|
console.error("Val: could not find the module", {
|
2081
2083
|
moduleIds: Object.keys(data.value.modules),
|
2082
|
-
moduleId: moduleId
|
2084
|
+
moduleId: moduleId,
|
2085
|
+
data: data
|
2083
2086
|
});
|
2084
2087
|
return _context.abrupt("return", fp.result.err({
|
2085
2088
|
message: "Could not fetch data. Could not find the module: " + moduleId + ". Verify that the module id and file name is correct."
|
@@ -2139,7 +2142,9 @@ var ValStore = /*#__PURE__*/function () {
|
|
2139
2142
|
return this.api.getTree({
|
2140
2143
|
patch: true,
|
2141
2144
|
treePath: moduleId,
|
2142
|
-
includeSource: true
|
2145
|
+
includeSource: true,
|
2146
|
+
includeSchema: true,
|
2147
|
+
validate: true
|
2143
2148
|
});
|
2144
2149
|
case 5:
|
2145
2150
|
data = _context2.sent;
|
@@ -2267,39 +2272,96 @@ var ValStore = /*#__PURE__*/function () {
|
|
2267
2272
|
}
|
2268
2273
|
return reset;
|
2269
2274
|
}()
|
2275
|
+
}, {
|
2276
|
+
key: "initialize",
|
2277
|
+
value: function () {
|
2278
|
+
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
2279
|
+
var data, moduleIds, _i2, _arr, moduleId, schema, msg;
|
2280
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
2281
|
+
while (1) switch (_context5.prev = _context5.next) {
|
2282
|
+
case 0:
|
2283
|
+
_context5.next = 2;
|
2284
|
+
return this.api.getTree({
|
2285
|
+
patch: false,
|
2286
|
+
includeSource: false,
|
2287
|
+
includeSchema: true,
|
2288
|
+
validate: false
|
2289
|
+
});
|
2290
|
+
case 2:
|
2291
|
+
data = _context5.sent;
|
2292
|
+
if (!fp.result.isOk(data)) {
|
2293
|
+
_context5.next = 9;
|
2294
|
+
break;
|
2295
|
+
}
|
2296
|
+
moduleIds = [];
|
2297
|
+
for (_i2 = 0, _arr = Object.keys(data.value.modules); _i2 < _arr.length; _i2++) {
|
2298
|
+
moduleId = _arr[_i2];
|
2299
|
+
schema = data.value.modules[moduleId].schema;
|
2300
|
+
if (schema) {
|
2301
|
+
moduleIds.push(moduleId);
|
2302
|
+
this.schema[moduleId] = schema;
|
2303
|
+
}
|
2304
|
+
}
|
2305
|
+
return _context5.abrupt("return", fp.result.ok(moduleIds));
|
2306
|
+
case 9:
|
2307
|
+
msg = "Failed to fetch content. ";
|
2308
|
+
if (data.error.statusCode === 401) {
|
2309
|
+
msg += "Authorization failed - check that you are logged in.";
|
2310
|
+
} else {
|
2311
|
+
msg += "Get a developer to verify that Val is correctly setup.";
|
2312
|
+
}
|
2313
|
+
return _context5.abrupt("return", fp.result.err({
|
2314
|
+
message: msg,
|
2315
|
+
details: {
|
2316
|
+
fetchError: data.error
|
2317
|
+
}
|
2318
|
+
}));
|
2319
|
+
case 12:
|
2320
|
+
case "end":
|
2321
|
+
return _context5.stop();
|
2322
|
+
}
|
2323
|
+
}, _callee5, this);
|
2324
|
+
}));
|
2325
|
+
function initialize() {
|
2326
|
+
return _initialize.apply(this, arguments);
|
2327
|
+
}
|
2328
|
+
return initialize;
|
2329
|
+
}()
|
2270
2330
|
}, {
|
2271
2331
|
key: "updateTree",
|
2272
2332
|
value: function () {
|
2273
|
-
var _updateTree = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
2333
|
+
var _updateTree = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(treePath) {
|
2274
2334
|
var _this3 = this;
|
2275
|
-
var data, moduleIds, updatedSubscriberIds, subscriberIds, _loop,
|
2276
|
-
return _regeneratorRuntime().wrap(function
|
2277
|
-
while (1) switch (
|
2335
|
+
var data, moduleIds, updatedSubscriberIds, subscriberIds, _loop, _i3, _arr2, _i4, _Array$from2, _Array$from2$_i, updatedSubscriberId, _moduleIds, subscriberModules, msg;
|
2336
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context7) {
|
2337
|
+
while (1) switch (_context7.prev = _context7.next) {
|
2278
2338
|
case 0:
|
2279
|
-
|
2339
|
+
_context7.next = 2;
|
2280
2340
|
return this.api.getTree({
|
2281
2341
|
patch: true,
|
2282
2342
|
treePath: treePath,
|
2283
|
-
includeSource: true
|
2343
|
+
includeSource: true,
|
2344
|
+
includeSchema: true,
|
2345
|
+
validate: true
|
2284
2346
|
});
|
2285
2347
|
case 2:
|
2286
|
-
data =
|
2348
|
+
data = _context7.sent;
|
2287
2349
|
moduleIds = [];
|
2288
2350
|
if (!fp.result.isOk(data)) {
|
2289
|
-
|
2351
|
+
_context7.next = 18;
|
2290
2352
|
break;
|
2291
2353
|
}
|
2292
2354
|
updatedSubscriberIds = new Map();
|
2293
2355
|
subscriberIds = Array.from(this.subscribers.keys()); // Figure out which modules have been updated and map to updated subscribed id
|
2294
2356
|
_loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop() {
|
2295
2357
|
var moduleId, source, updatedSubscriberId;
|
2296
|
-
return _regeneratorRuntime().wrap(function _loop$(
|
2297
|
-
while (1) switch (
|
2358
|
+
return _regeneratorRuntime().wrap(function _loop$(_context6) {
|
2359
|
+
while (1) switch (_context6.prev = _context6.next) {
|
2298
2360
|
case 0:
|
2299
|
-
moduleId =
|
2300
|
-
moduleIds.push(moduleId);
|
2361
|
+
moduleId = _arr2[_i3];
|
2301
2362
|
source = data.value.modules[moduleId].source;
|
2302
2363
|
if (typeof source !== "undefined") {
|
2364
|
+
moduleIds.push(moduleId);
|
2303
2365
|
_this3.emitEvent(moduleId, source);
|
2304
2366
|
updatedSubscriberId = subscriberIds.find(function (subscriberId) {
|
2305
2367
|
return subscriberId.includes(moduleId);
|
@@ -2309,27 +2371,27 @@ var ValStore = /*#__PURE__*/function () {
|
|
2309
2371
|
updatedSubscriberIds.set(updatedSubscriberId, (updatedSubscriberIds.get(updatedSubscriberId) || []).concat(moduleId));
|
2310
2372
|
}
|
2311
2373
|
}
|
2312
|
-
case
|
2374
|
+
case 3:
|
2313
2375
|
case "end":
|
2314
|
-
return
|
2376
|
+
return _context6.stop();
|
2315
2377
|
}
|
2316
2378
|
}, _loop);
|
2317
2379
|
});
|
2318
|
-
|
2380
|
+
_i3 = 0, _arr2 = Object.keys(data.value.modules);
|
2319
2381
|
case 9:
|
2320
|
-
if (!(
|
2321
|
-
|
2382
|
+
if (!(_i3 < _arr2.length)) {
|
2383
|
+
_context7.next = 14;
|
2322
2384
|
break;
|
2323
2385
|
}
|
2324
|
-
return
|
2386
|
+
return _context7.delegateYield(_loop(), "t0", 11);
|
2325
2387
|
case 11:
|
2326
|
-
|
2327
|
-
|
2388
|
+
_i3++;
|
2389
|
+
_context7.next = 9;
|
2328
2390
|
break;
|
2329
2391
|
case 14:
|
2330
2392
|
// For all updated subscribers: set new module data and emit change
|
2331
|
-
for (
|
2332
|
-
_Array$from2$_i = _slicedToArray(_Array$from2[
|
2393
|
+
for (_i4 = 0, _Array$from2 = Array.from(updatedSubscriberIds.entries()); _i4 < _Array$from2.length; _i4++) {
|
2394
|
+
_Array$from2$_i = _slicedToArray(_Array$from2[_i4], 2), updatedSubscriberId = _Array$from2$_i[0], _moduleIds = _Array$from2$_i[1];
|
2333
2395
|
subscriberModules = Object.fromEntries(_moduleIds.flatMap(function (moduleId) {
|
2334
2396
|
var source = data.value.modules[moduleId].source;
|
2335
2397
|
if (!source) {
|
@@ -2340,7 +2402,7 @@ var ValStore = /*#__PURE__*/function () {
|
|
2340
2402
|
this.subscribers.set(updatedSubscriberId, subscriberModules);
|
2341
2403
|
this.emitChange(updatedSubscriberId);
|
2342
2404
|
}
|
2343
|
-
return
|
2405
|
+
return _context7.abrupt("return", fp.result.ok(moduleIds));
|
2344
2406
|
case 18:
|
2345
2407
|
msg = "Failed to fetch content. ";
|
2346
2408
|
if (data.error.statusCode === 401) {
|
@@ -2348,7 +2410,7 @@ var ValStore = /*#__PURE__*/function () {
|
|
2348
2410
|
} else {
|
2349
2411
|
msg += "Get a developer to verify that Val is correctly setup.";
|
2350
2412
|
}
|
2351
|
-
return
|
2413
|
+
return _context7.abrupt("return", fp.result.err({
|
2352
2414
|
message: msg,
|
2353
2415
|
details: {
|
2354
2416
|
fetchError: data.error
|
@@ -2356,9 +2418,9 @@ var ValStore = /*#__PURE__*/function () {
|
|
2356
2418
|
}));
|
2357
2419
|
case 21:
|
2358
2420
|
case "end":
|
2359
|
-
return
|
2421
|
+
return _context7.stop();
|
2360
2422
|
}
|
2361
|
-
},
|
2423
|
+
}, _callee6, this);
|
2362
2424
|
}));
|
2363
2425
|
function updateTree(_x5) {
|
2364
2426
|
return _updateTree.apply(this, arguments);
|
@@ -2041,7 +2041,9 @@ var ValStore = /*#__PURE__*/function () {
|
|
2041
2041
|
return this.api.getTree({
|
2042
2042
|
patch: true,
|
2043
2043
|
treePath: moduleId,
|
2044
|
-
includeSource: true
|
2044
|
+
includeSource: true,
|
2045
|
+
includeSchema: true,
|
2046
|
+
validate: true
|
2045
2047
|
});
|
2046
2048
|
case 5:
|
2047
2049
|
data = _context.sent;
|
@@ -2055,7 +2057,8 @@ var ValStore = /*#__PURE__*/function () {
|
|
2055
2057
|
}
|
2056
2058
|
console.error("Val: could not find the module", {
|
2057
2059
|
moduleIds: Object.keys(data.value.modules),
|
2058
|
-
moduleId: moduleId
|
2060
|
+
moduleId: moduleId,
|
2061
|
+
data: data
|
2059
2062
|
});
|
2060
2063
|
return _context.abrupt("return", result.err({
|
2061
2064
|
message: "Could not fetch data. Could not find the module: " + moduleId + ". Verify that the module id and file name is correct."
|
@@ -2115,7 +2118,9 @@ var ValStore = /*#__PURE__*/function () {
|
|
2115
2118
|
return this.api.getTree({
|
2116
2119
|
patch: true,
|
2117
2120
|
treePath: moduleId,
|
2118
|
-
includeSource: true
|
2121
|
+
includeSource: true,
|
2122
|
+
includeSchema: true,
|
2123
|
+
validate: true
|
2119
2124
|
});
|
2120
2125
|
case 5:
|
2121
2126
|
data = _context2.sent;
|
@@ -2243,39 +2248,96 @@ var ValStore = /*#__PURE__*/function () {
|
|
2243
2248
|
}
|
2244
2249
|
return reset;
|
2245
2250
|
}()
|
2251
|
+
}, {
|
2252
|
+
key: "initialize",
|
2253
|
+
value: function () {
|
2254
|
+
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
2255
|
+
var data, moduleIds, _i2, _arr, moduleId, schema, msg;
|
2256
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
2257
|
+
while (1) switch (_context5.prev = _context5.next) {
|
2258
|
+
case 0:
|
2259
|
+
_context5.next = 2;
|
2260
|
+
return this.api.getTree({
|
2261
|
+
patch: false,
|
2262
|
+
includeSource: false,
|
2263
|
+
includeSchema: true,
|
2264
|
+
validate: false
|
2265
|
+
});
|
2266
|
+
case 2:
|
2267
|
+
data = _context5.sent;
|
2268
|
+
if (!result.isOk(data)) {
|
2269
|
+
_context5.next = 9;
|
2270
|
+
break;
|
2271
|
+
}
|
2272
|
+
moduleIds = [];
|
2273
|
+
for (_i2 = 0, _arr = Object.keys(data.value.modules); _i2 < _arr.length; _i2++) {
|
2274
|
+
moduleId = _arr[_i2];
|
2275
|
+
schema = data.value.modules[moduleId].schema;
|
2276
|
+
if (schema) {
|
2277
|
+
moduleIds.push(moduleId);
|
2278
|
+
this.schema[moduleId] = schema;
|
2279
|
+
}
|
2280
|
+
}
|
2281
|
+
return _context5.abrupt("return", result.ok(moduleIds));
|
2282
|
+
case 9:
|
2283
|
+
msg = "Failed to fetch content. ";
|
2284
|
+
if (data.error.statusCode === 401) {
|
2285
|
+
msg += "Authorization failed - check that you are logged in.";
|
2286
|
+
} else {
|
2287
|
+
msg += "Get a developer to verify that Val is correctly setup.";
|
2288
|
+
}
|
2289
|
+
return _context5.abrupt("return", result.err({
|
2290
|
+
message: msg,
|
2291
|
+
details: {
|
2292
|
+
fetchError: data.error
|
2293
|
+
}
|
2294
|
+
}));
|
2295
|
+
case 12:
|
2296
|
+
case "end":
|
2297
|
+
return _context5.stop();
|
2298
|
+
}
|
2299
|
+
}, _callee5, this);
|
2300
|
+
}));
|
2301
|
+
function initialize() {
|
2302
|
+
return _initialize.apply(this, arguments);
|
2303
|
+
}
|
2304
|
+
return initialize;
|
2305
|
+
}()
|
2246
2306
|
}, {
|
2247
2307
|
key: "updateTree",
|
2248
2308
|
value: function () {
|
2249
|
-
var _updateTree = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
2309
|
+
var _updateTree = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(treePath) {
|
2250
2310
|
var _this3 = this;
|
2251
|
-
var data, moduleIds, updatedSubscriberIds, subscriberIds, _loop,
|
2252
|
-
return _regeneratorRuntime().wrap(function
|
2253
|
-
while (1) switch (
|
2311
|
+
var data, moduleIds, updatedSubscriberIds, subscriberIds, _loop, _i3, _arr2, _i4, _Array$from2, _Array$from2$_i, updatedSubscriberId, _moduleIds, subscriberModules, msg;
|
2312
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context7) {
|
2313
|
+
while (1) switch (_context7.prev = _context7.next) {
|
2254
2314
|
case 0:
|
2255
|
-
|
2315
|
+
_context7.next = 2;
|
2256
2316
|
return this.api.getTree({
|
2257
2317
|
patch: true,
|
2258
2318
|
treePath: treePath,
|
2259
|
-
includeSource: true
|
2319
|
+
includeSource: true,
|
2320
|
+
includeSchema: true,
|
2321
|
+
validate: true
|
2260
2322
|
});
|
2261
2323
|
case 2:
|
2262
|
-
data =
|
2324
|
+
data = _context7.sent;
|
2263
2325
|
moduleIds = [];
|
2264
2326
|
if (!result.isOk(data)) {
|
2265
|
-
|
2327
|
+
_context7.next = 18;
|
2266
2328
|
break;
|
2267
2329
|
}
|
2268
2330
|
updatedSubscriberIds = new Map();
|
2269
2331
|
subscriberIds = Array.from(this.subscribers.keys()); // Figure out which modules have been updated and map to updated subscribed id
|
2270
2332
|
_loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop() {
|
2271
2333
|
var moduleId, source, updatedSubscriberId;
|
2272
|
-
return _regeneratorRuntime().wrap(function _loop$(
|
2273
|
-
while (1) switch (
|
2334
|
+
return _regeneratorRuntime().wrap(function _loop$(_context6) {
|
2335
|
+
while (1) switch (_context6.prev = _context6.next) {
|
2274
2336
|
case 0:
|
2275
|
-
moduleId =
|
2276
|
-
moduleIds.push(moduleId);
|
2337
|
+
moduleId = _arr2[_i3];
|
2277
2338
|
source = data.value.modules[moduleId].source;
|
2278
2339
|
if (typeof source !== "undefined") {
|
2340
|
+
moduleIds.push(moduleId);
|
2279
2341
|
_this3.emitEvent(moduleId, source);
|
2280
2342
|
updatedSubscriberId = subscriberIds.find(function (subscriberId) {
|
2281
2343
|
return subscriberId.includes(moduleId);
|
@@ -2285,27 +2347,27 @@ var ValStore = /*#__PURE__*/function () {
|
|
2285
2347
|
updatedSubscriberIds.set(updatedSubscriberId, (updatedSubscriberIds.get(updatedSubscriberId) || []).concat(moduleId));
|
2286
2348
|
}
|
2287
2349
|
}
|
2288
|
-
case
|
2350
|
+
case 3:
|
2289
2351
|
case "end":
|
2290
|
-
return
|
2352
|
+
return _context6.stop();
|
2291
2353
|
}
|
2292
2354
|
}, _loop);
|
2293
2355
|
});
|
2294
|
-
|
2356
|
+
_i3 = 0, _arr2 = Object.keys(data.value.modules);
|
2295
2357
|
case 9:
|
2296
|
-
if (!(
|
2297
|
-
|
2358
|
+
if (!(_i3 < _arr2.length)) {
|
2359
|
+
_context7.next = 14;
|
2298
2360
|
break;
|
2299
2361
|
}
|
2300
|
-
return
|
2362
|
+
return _context7.delegateYield(_loop(), "t0", 11);
|
2301
2363
|
case 11:
|
2302
|
-
|
2303
|
-
|
2364
|
+
_i3++;
|
2365
|
+
_context7.next = 9;
|
2304
2366
|
break;
|
2305
2367
|
case 14:
|
2306
2368
|
// For all updated subscribers: set new module data and emit change
|
2307
|
-
for (
|
2308
|
-
_Array$from2$_i = _slicedToArray(_Array$from2[
|
2369
|
+
for (_i4 = 0, _Array$from2 = Array.from(updatedSubscriberIds.entries()); _i4 < _Array$from2.length; _i4++) {
|
2370
|
+
_Array$from2$_i = _slicedToArray(_Array$from2[_i4], 2), updatedSubscriberId = _Array$from2$_i[0], _moduleIds = _Array$from2$_i[1];
|
2309
2371
|
subscriberModules = Object.fromEntries(_moduleIds.flatMap(function (moduleId) {
|
2310
2372
|
var source = data.value.modules[moduleId].source;
|
2311
2373
|
if (!source) {
|
@@ -2316,7 +2378,7 @@ var ValStore = /*#__PURE__*/function () {
|
|
2316
2378
|
this.subscribers.set(updatedSubscriberId, subscriberModules);
|
2317
2379
|
this.emitChange(updatedSubscriberId);
|
2318
2380
|
}
|
2319
|
-
return
|
2381
|
+
return _context7.abrupt("return", result.ok(moduleIds));
|
2320
2382
|
case 18:
|
2321
2383
|
msg = "Failed to fetch content. ";
|
2322
2384
|
if (data.error.statusCode === 401) {
|
@@ -2324,7 +2386,7 @@ var ValStore = /*#__PURE__*/function () {
|
|
2324
2386
|
} else {
|
2325
2387
|
msg += "Get a developer to verify that Val is correctly setup.";
|
2326
2388
|
}
|
2327
|
-
return
|
2389
|
+
return _context7.abrupt("return", result.err({
|
2328
2390
|
message: msg,
|
2329
2391
|
details: {
|
2330
2392
|
fetchError: data.error
|
@@ -2332,9 +2394,9 @@ var ValStore = /*#__PURE__*/function () {
|
|
2332
2394
|
}));
|
2333
2395
|
case 21:
|
2334
2396
|
case "end":
|
2335
|
-
return
|
2397
|
+
return _context7.stop();
|
2336
2398
|
}
|
2337
|
-
},
|
2399
|
+
}, _callee6, this);
|
2338
2400
|
}));
|
2339
2401
|
function updateTree(_x5) {
|
2340
2402
|
return _updateTree.apply(this, arguments);
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@valbuild/shared",
|
3
|
-
"version": "0.60.
|
3
|
+
"version": "0.60.19",
|
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.60.
|
32
|
+
"@valbuild/core": "~0.60.19",
|
33
33
|
"marked": "^9.0.3",
|
34
34
|
"zod": "^3.22.4"
|
35
35
|
},
|