@workglow/task-graph 0.2.3 → 0.2.4
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/dist/browser.js +85 -8
- package/dist/browser.js.map +5 -5
- package/dist/bun.js +85 -8
- package/dist/bun.js.map +5 -5
- package/dist/node.js +85 -8
- package/dist/node.js.map +5 -5
- package/dist/task/GraphAsTask.d.ts +16 -0
- package/dist/task/GraphAsTask.d.ts.map +1 -1
- package/dist/task/TaskEntitlements.d.ts +7 -4
- package/dist/task/TaskEntitlements.d.ts.map +1 -1
- package/dist/task/TaskRunner.d.ts +1 -1
- package/dist/task/TaskRunner.d.ts.map +1 -1
- package/package.json +7 -7
package/dist/browser.js
CHANGED
|
@@ -294,16 +294,32 @@ function entitlementCovers(granted, required) {
|
|
|
294
294
|
function resourcePatternMatches(grantPattern, requiredResource) {
|
|
295
295
|
if (grantPattern === requiredResource)
|
|
296
296
|
return true;
|
|
297
|
-
|
|
298
|
-
if (starIdx === -1)
|
|
297
|
+
if (!grantPattern.includes("*"))
|
|
299
298
|
return false;
|
|
300
|
-
const
|
|
301
|
-
const
|
|
302
|
-
|
|
299
|
+
const parts = grantPattern.split("*");
|
|
300
|
+
const first = parts[0];
|
|
301
|
+
const last = parts[parts.length - 1];
|
|
302
|
+
if (!requiredResource.startsWith(first))
|
|
303
303
|
return false;
|
|
304
|
-
if (!requiredResource.endsWith(
|
|
304
|
+
if (!requiredResource.endsWith(last))
|
|
305
305
|
return false;
|
|
306
|
-
|
|
306
|
+
let fixedLength = 0;
|
|
307
|
+
for (const p of parts)
|
|
308
|
+
fixedLength += p.length;
|
|
309
|
+
if (requiredResource.length < fixedLength)
|
|
310
|
+
return false;
|
|
311
|
+
let searchStart = first.length;
|
|
312
|
+
const searchEnd = requiredResource.length - last.length;
|
|
313
|
+
for (let i = 1;i < parts.length - 1; i++) {
|
|
314
|
+
const part = parts[i];
|
|
315
|
+
if (part.length === 0)
|
|
316
|
+
continue;
|
|
317
|
+
const idx = requiredResource.indexOf(part, searchStart);
|
|
318
|
+
if (idx === -1 || idx + part.length > searchEnd)
|
|
319
|
+
return false;
|
|
320
|
+
searchStart = idx + part.length;
|
|
321
|
+
}
|
|
322
|
+
return true;
|
|
307
323
|
}
|
|
308
324
|
function grantCoversResources(grant, required) {
|
|
309
325
|
if (grant.resources === undefined)
|
|
@@ -1371,6 +1387,9 @@ class TaskRunner {
|
|
|
1371
1387
|
signal: this.abortController?.signal
|
|
1372
1388
|
});
|
|
1373
1389
|
}
|
|
1390
|
+
if (this.task.constructor.hasDynamicEntitlements) {
|
|
1391
|
+
this.task.emit("entitlementChange", this.task.entitlements());
|
|
1392
|
+
}
|
|
1374
1393
|
return i;
|
|
1375
1394
|
}
|
|
1376
1395
|
async executeTask(input) {
|
|
@@ -3551,6 +3570,64 @@ class GraphAsTask extends Task {
|
|
|
3551
3570
|
this.events.emit("regenerate");
|
|
3552
3571
|
this.emitEntitlementChange();
|
|
3553
3572
|
}
|
|
3573
|
+
_entitlementUnsub;
|
|
3574
|
+
_subscribeToSubGraphEntitlements(graph) {
|
|
3575
|
+
this._entitlementUnsub?.();
|
|
3576
|
+
this._entitlementUnsub = graph.subscribeToTaskEntitlements(() => {
|
|
3577
|
+
this.emitEntitlementChange();
|
|
3578
|
+
});
|
|
3579
|
+
}
|
|
3580
|
+
_syncSubGraphEntitlementSubscription(graph = this._subGraph) {
|
|
3581
|
+
if ((this._events?.listenerCount("entitlementChange") ?? 0) === 0) {
|
|
3582
|
+
this._entitlementUnsub?.();
|
|
3583
|
+
this._entitlementUnsub = undefined;
|
|
3584
|
+
return;
|
|
3585
|
+
}
|
|
3586
|
+
if (!graph || this._entitlementUnsub) {
|
|
3587
|
+
return;
|
|
3588
|
+
}
|
|
3589
|
+
this._subscribeToSubGraphEntitlements(graph);
|
|
3590
|
+
}
|
|
3591
|
+
subscribe(name, fn) {
|
|
3592
|
+
const unsub = super.subscribe(name, fn);
|
|
3593
|
+
if (name !== "entitlementChange") {
|
|
3594
|
+
return unsub;
|
|
3595
|
+
}
|
|
3596
|
+
this._syncSubGraphEntitlementSubscription();
|
|
3597
|
+
return () => {
|
|
3598
|
+
unsub();
|
|
3599
|
+
this._syncSubGraphEntitlementSubscription();
|
|
3600
|
+
};
|
|
3601
|
+
}
|
|
3602
|
+
on(name, fn) {
|
|
3603
|
+
super.on(name, fn);
|
|
3604
|
+
if (name === "entitlementChange") {
|
|
3605
|
+
this._syncSubGraphEntitlementSubscription();
|
|
3606
|
+
}
|
|
3607
|
+
}
|
|
3608
|
+
off(name, fn) {
|
|
3609
|
+
super.off(name, fn);
|
|
3610
|
+
if (name === "entitlementChange") {
|
|
3611
|
+
this._syncSubGraphEntitlementSubscription();
|
|
3612
|
+
}
|
|
3613
|
+
}
|
|
3614
|
+
once(name, fn) {
|
|
3615
|
+
super.once(name, fn);
|
|
3616
|
+
if (name === "entitlementChange") {
|
|
3617
|
+
this._syncSubGraphEntitlementSubscription();
|
|
3618
|
+
}
|
|
3619
|
+
}
|
|
3620
|
+
set subGraph(subGraph) {
|
|
3621
|
+
this._entitlementUnsub?.();
|
|
3622
|
+
this._entitlementUnsub = undefined;
|
|
3623
|
+
super.subGraph = subGraph;
|
|
3624
|
+
this._syncSubGraphEntitlementSubscription(subGraph);
|
|
3625
|
+
}
|
|
3626
|
+
get subGraph() {
|
|
3627
|
+
const graph = super.subGraph;
|
|
3628
|
+
this._syncSubGraphEntitlementSubscription(graph);
|
|
3629
|
+
return graph;
|
|
3630
|
+
}
|
|
3554
3631
|
toJSON(options) {
|
|
3555
3632
|
let json = super.toJSON(options);
|
|
3556
3633
|
const hasChildren = this.hasChildren();
|
|
@@ -8122,4 +8199,4 @@ export {
|
|
|
8122
8199
|
BROWSER_GRANTS
|
|
8123
8200
|
};
|
|
8124
8201
|
|
|
8125
|
-
//# debugId=
|
|
8202
|
+
//# debugId=8A43A4F12CABDEAB64756E2164756E21
|