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