@pumped-fn/core-next 0.5.72 → 0.5.73
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 +13 -0
- package/dist/index.cjs +99 -66
- package/dist/index.d.cts +16 -11
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +16 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +99 -66
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/docs/accessor.md +0 -257
- package/docs/api.md +0 -325
- package/docs/authoring.md +0 -375
- package/docs/concepts.md +0 -284
- package/docs/configuration.md +0 -490
- package/docs/core.md +0 -519
- package/docs/extension.md +0 -1107
- package/docs/flow.md +0 -536
- package/docs/index.md +0 -139
- package/docs/meta.md +0 -441
- package/docs/patterns/examples.md +0 -1053
- package/docs/testing.md +0 -845
- package/docs/troubleshooting.md +0 -400
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @pumped-fn/core-next
|
|
2
2
|
|
|
3
|
+
## 0.5.73
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- bdf29a0: Add Promised.create static factory method and make extension API accept both Promise and Promised types
|
|
8
|
+
|
|
9
|
+
- Add `Promised.create()` static method as preferred way to create Promised instances
|
|
10
|
+
- Replace all 43 internal uses of `new Promised` with `Promised.create`
|
|
11
|
+
- Extension API now accepts both `Promise<T>` and `Promised<T>` return types
|
|
12
|
+
- Extension methods (init, initPod, wrap, dispose, disposePod) handle both types seamlessly
|
|
13
|
+
- Internal automatic wrapping to Promised for better ergonomics
|
|
14
|
+
- No breaking changes - fully backward compatible
|
|
15
|
+
|
|
3
16
|
## 0.5.72
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
|
@@ -257,28 +257,31 @@ var Promised = class Promised {
|
|
|
257
257
|
this.promise = promise instanceof Promised ? promise.promise : promise;
|
|
258
258
|
this.executionDataPromise = executionDataPromise;
|
|
259
259
|
}
|
|
260
|
+
static create(promise, executionDataPromise) {
|
|
261
|
+
return new Promised(promise, executionDataPromise);
|
|
262
|
+
}
|
|
260
263
|
map(fn) {
|
|
261
|
-
return
|
|
264
|
+
return Promised.create(this.promise.then(fn), this.executionDataPromise);
|
|
262
265
|
}
|
|
263
266
|
switch(fn) {
|
|
264
|
-
return
|
|
267
|
+
return Promised.create(this.promise.then(fn), this.executionDataPromise);
|
|
265
268
|
}
|
|
266
269
|
mapError(fn) {
|
|
267
|
-
return
|
|
270
|
+
return Promised.create(this.promise.catch((error) => {
|
|
268
271
|
throw fn(error);
|
|
269
272
|
}), this.executionDataPromise);
|
|
270
273
|
}
|
|
271
274
|
switchError(fn) {
|
|
272
|
-
return
|
|
275
|
+
return Promised.create(this.promise.catch(fn), this.executionDataPromise);
|
|
273
276
|
}
|
|
274
277
|
then(onfulfilled, onrejected) {
|
|
275
|
-
return
|
|
278
|
+
return Promised.create(this.promise.then(onfulfilled, onrejected), this.executionDataPromise);
|
|
276
279
|
}
|
|
277
280
|
catch(onrejected) {
|
|
278
|
-
return
|
|
281
|
+
return Promised.create(this.promise.catch(onrejected), this.executionDataPromise);
|
|
279
282
|
}
|
|
280
283
|
finally(onfinally) {
|
|
281
|
-
return
|
|
284
|
+
return Promised.create(this.promise.finally(onfinally), this.executionDataPromise);
|
|
282
285
|
}
|
|
283
286
|
toPromise() {
|
|
284
287
|
return this.promise;
|
|
@@ -308,24 +311,25 @@ var Promised = class Promised {
|
|
|
308
311
|
}
|
|
309
312
|
static all(values) {
|
|
310
313
|
const promises = values.map((v) => v instanceof Promised ? v.toPromise() : Promise.resolve(v));
|
|
311
|
-
return
|
|
314
|
+
return Promised.create(Promise.all(promises));
|
|
312
315
|
}
|
|
313
316
|
static race(values) {
|
|
314
317
|
const promises = values.map((v) => v instanceof Promised ? v.toPromise() : Promise.resolve(v));
|
|
315
|
-
return
|
|
318
|
+
return Promised.create(Promise.race(promises));
|
|
316
319
|
}
|
|
317
320
|
static allSettled(values) {
|
|
318
321
|
const promises = values.map((v) => v instanceof Promised ? v.toPromise() : Promise.resolve(v));
|
|
319
|
-
return
|
|
322
|
+
return Promised.create(Promise.allSettled(promises));
|
|
320
323
|
}
|
|
321
324
|
static try(fn) {
|
|
322
|
-
|
|
325
|
+
const promise = new Promise((resolve, reject) => {
|
|
323
326
|
try {
|
|
324
327
|
resolve(fn());
|
|
325
328
|
} catch (error) {
|
|
326
329
|
reject(error);
|
|
327
330
|
}
|
|
328
|
-
})
|
|
331
|
+
});
|
|
332
|
+
return Promised.create(promise);
|
|
329
333
|
}
|
|
330
334
|
static extractResults(value) {
|
|
331
335
|
if (Array.isArray(value)) return value;
|
|
@@ -634,7 +638,10 @@ function wrapWithExtensions(extensions, baseExecutor, dataStore, operation) {
|
|
|
634
638
|
const extension$1 = extensions[i];
|
|
635
639
|
if (extension$1.wrap) {
|
|
636
640
|
const current = executor;
|
|
637
|
-
executor = () =>
|
|
641
|
+
executor = () => {
|
|
642
|
+
const result = extension$1.wrap(dataStore, current, operation);
|
|
643
|
+
return result instanceof Promised ? result : Promised.create(result);
|
|
644
|
+
};
|
|
638
645
|
}
|
|
639
646
|
}
|
|
640
647
|
return executor;
|
|
@@ -699,7 +706,10 @@ var FlowContext = class FlowContext {
|
|
|
699
706
|
let executor = baseExecutor;
|
|
700
707
|
for (const extension$1 of this.reversedExtensions) if (extension$1.wrap) {
|
|
701
708
|
const current = executor;
|
|
702
|
-
executor = () =>
|
|
709
|
+
executor = () => {
|
|
710
|
+
const result = extension$1.wrap(this, current, operation);
|
|
711
|
+
return result instanceof Promised ? result : Promised.create(result);
|
|
712
|
+
};
|
|
703
713
|
}
|
|
704
714
|
return executor;
|
|
705
715
|
}
|
|
@@ -734,14 +744,14 @@ var FlowContext = class FlowContext {
|
|
|
734
744
|
const flowName = this.find(flowMeta.flowName) || "unknown";
|
|
735
745
|
const depth = this.get(flowMeta.depth);
|
|
736
746
|
const journalKey = `${flowName}:${depth}:${key}`;
|
|
737
|
-
|
|
747
|
+
const promise = (async () => {
|
|
738
748
|
const journal = this.journal;
|
|
739
749
|
const isReplay = journal.has(journalKey);
|
|
740
750
|
const executeCore = () => {
|
|
741
751
|
if (isReplay) {
|
|
742
752
|
const entry = journal.get(journalKey);
|
|
743
753
|
if (isErrorEntry(entry)) throw entry.error;
|
|
744
|
-
return
|
|
754
|
+
return Promised.create(Promise.resolve(entry));
|
|
745
755
|
}
|
|
746
756
|
return Promised.try(async () => {
|
|
747
757
|
const result = params.length > 0 ? await fn(...params) : await fn();
|
|
@@ -764,7 +774,8 @@ var FlowContext = class FlowContext {
|
|
|
764
774
|
pod: this.pod,
|
|
765
775
|
params: params.length > 0 ? params : void 0
|
|
766
776
|
})();
|
|
767
|
-
})()
|
|
777
|
+
})();
|
|
778
|
+
return Promised.create(promise);
|
|
768
779
|
}
|
|
769
780
|
exec(keyOrFlow, flowOrInput, inputOrUndefined) {
|
|
770
781
|
if (typeof keyOrFlow === "string") {
|
|
@@ -775,13 +786,13 @@ var FlowContext = class FlowContext {
|
|
|
775
786
|
const parentFlowName = this.find(flowMeta.flowName);
|
|
776
787
|
const depth = this.get(flowMeta.depth);
|
|
777
788
|
const journalKey = `${this.find(flowMeta.flowName) || "unknown"}:${depth}:${key}`;
|
|
778
|
-
|
|
789
|
+
const promise$1 = (async () => {
|
|
779
790
|
const journal = this.journal;
|
|
780
791
|
const executeCore = () => {
|
|
781
792
|
if (journal.has(journalKey)) {
|
|
782
793
|
const entry = journal.get(journalKey);
|
|
783
794
|
if (isErrorEntry(entry)) throw entry.error;
|
|
784
|
-
return
|
|
795
|
+
return Promised.create(Promise.resolve(entry));
|
|
785
796
|
}
|
|
786
797
|
return Promised.try(async () => {
|
|
787
798
|
const handler = await this.pod.resolve(flow$2);
|
|
@@ -812,11 +823,12 @@ var FlowContext = class FlowContext {
|
|
|
812
823
|
depth,
|
|
813
824
|
pod: this.pod
|
|
814
825
|
})();
|
|
815
|
-
})()
|
|
826
|
+
})();
|
|
827
|
+
return Promised.create(promise$1);
|
|
816
828
|
}
|
|
817
829
|
const flow$1 = keyOrFlow;
|
|
818
830
|
const input = flowOrInput;
|
|
819
|
-
|
|
831
|
+
const promise = (async () => {
|
|
820
832
|
const parentFlowName = this.find(flowMeta.flowName);
|
|
821
833
|
const depth = this.get(flowMeta.depth);
|
|
822
834
|
const executeCore = () => {
|
|
@@ -840,14 +852,15 @@ var FlowContext = class FlowContext {
|
|
|
840
852
|
depth,
|
|
841
853
|
pod: this.pod
|
|
842
854
|
})();
|
|
843
|
-
})()
|
|
855
|
+
})();
|
|
856
|
+
return Promised.create(promise);
|
|
844
857
|
}
|
|
845
858
|
parallel(promises) {
|
|
846
859
|
const parentFlowName = this.find(flowMeta.flowName);
|
|
847
860
|
const depth = this.get(flowMeta.depth);
|
|
848
|
-
|
|
861
|
+
const promise = (async () => {
|
|
849
862
|
const executeCore = () => {
|
|
850
|
-
return
|
|
863
|
+
return Promised.create(Promise.all(promises).then((results) => ({
|
|
851
864
|
results,
|
|
852
865
|
stats: {
|
|
853
866
|
total: results.length,
|
|
@@ -864,14 +877,15 @@ var FlowContext = class FlowContext {
|
|
|
864
877
|
parentFlowName,
|
|
865
878
|
pod: this.pod
|
|
866
879
|
})();
|
|
867
|
-
})()
|
|
880
|
+
})();
|
|
881
|
+
return Promised.create(promise);
|
|
868
882
|
}
|
|
869
883
|
parallelSettled(promises) {
|
|
870
884
|
const parentFlowName = this.find(flowMeta.flowName);
|
|
871
885
|
const depth = this.get(flowMeta.depth);
|
|
872
|
-
|
|
886
|
+
const promise = (async () => {
|
|
873
887
|
const executeCore = () => {
|
|
874
|
-
return
|
|
888
|
+
return Promised.create(Promise.allSettled(promises).then((results) => {
|
|
875
889
|
const succeeded = results.filter((r) => r.status === "fulfilled").length;
|
|
876
890
|
const failed = results.filter((r) => r.status === "rejected").length;
|
|
877
891
|
return {
|
|
@@ -892,10 +906,11 @@ var FlowContext = class FlowContext {
|
|
|
892
906
|
parentFlowName,
|
|
893
907
|
pod: this.pod
|
|
894
908
|
})();
|
|
895
|
-
})()
|
|
909
|
+
})();
|
|
910
|
+
return Promised.create(promise);
|
|
896
911
|
}
|
|
897
912
|
executeWithExtensions(handler, context, flow$1, input) {
|
|
898
|
-
const executeCore = () =>
|
|
913
|
+
const executeCore = () => Promised.create(handler(context));
|
|
899
914
|
const definition = flowDefinitionMeta.find(flow$1);
|
|
900
915
|
if (!definition) throw new Error("Flow definition not found in executor metadata");
|
|
901
916
|
return context.wrapWithExtensions(executeCore, {
|
|
@@ -931,7 +946,10 @@ var FlowContext = class FlowContext {
|
|
|
931
946
|
function execute(flow$1, input, options) {
|
|
932
947
|
const scope = options?.scope || createScope();
|
|
933
948
|
const shouldDisposeScope = !options?.scope;
|
|
934
|
-
const pod = scope.pod({
|
|
949
|
+
const pod = scope.pod({
|
|
950
|
+
initialValues: options?.presets,
|
|
951
|
+
meta: options?.meta
|
|
952
|
+
});
|
|
935
953
|
let resolveSnapshot;
|
|
936
954
|
const snapshotPromise = new Promise((resolve) => {
|
|
937
955
|
resolveSnapshot = resolve;
|
|
@@ -975,24 +993,27 @@ function execute(flow$1, input, options) {
|
|
|
975
993
|
if (shouldDisposeScope) await scope.dispose();
|
|
976
994
|
}
|
|
977
995
|
})();
|
|
978
|
-
if (options?.details)
|
|
979
|
-
const
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
+
if (options?.details) {
|
|
997
|
+
const detailsPromise = Promised.try(async () => {
|
|
998
|
+
const [result, ctx] = await Promise.all([promise, snapshotPromise]);
|
|
999
|
+
if (!ctx) throw new Error("Execution context not available");
|
|
1000
|
+
return {
|
|
1001
|
+
success: true,
|
|
1002
|
+
result,
|
|
1003
|
+
ctx
|
|
1004
|
+
};
|
|
1005
|
+
}).catch(async (error) => {
|
|
1006
|
+
const ctx = await snapshotPromise;
|
|
1007
|
+
if (!ctx) throw new Error("Execution context not available");
|
|
1008
|
+
return {
|
|
1009
|
+
success: false,
|
|
1010
|
+
error,
|
|
1011
|
+
ctx
|
|
1012
|
+
};
|
|
1013
|
+
});
|
|
1014
|
+
return Promised.create(detailsPromise, snapshotPromise);
|
|
1015
|
+
}
|
|
1016
|
+
return Promised.create(promise, snapshotPromise);
|
|
996
1017
|
}
|
|
997
1018
|
function flowImpl(definitionOrConfigOrDepsOrHandler, dependenciesOrHandler, handlerFn) {
|
|
998
1019
|
if (typeof definitionOrConfigOrDepsOrHandler === "function") {
|
|
@@ -1096,7 +1117,7 @@ var AccessorImpl = class {
|
|
|
1096
1117
|
value: {
|
|
1097
1118
|
kind: "resolved",
|
|
1098
1119
|
value: immediateValue,
|
|
1099
|
-
promised:
|
|
1120
|
+
promised: Promised.create(Promise.resolve(immediateValue))
|
|
1100
1121
|
}
|
|
1101
1122
|
});
|
|
1102
1123
|
return immediateValue;
|
|
@@ -1110,7 +1131,7 @@ var AccessorImpl = class {
|
|
|
1110
1131
|
value: {
|
|
1111
1132
|
kind: "resolved",
|
|
1112
1133
|
value: processedResult,
|
|
1113
|
-
promised:
|
|
1134
|
+
promised: Promised.create(Promise.resolve(processedResult))
|
|
1114
1135
|
}
|
|
1115
1136
|
});
|
|
1116
1137
|
this.scope["~removeFromResolutionChain"](this.requestor);
|
|
@@ -1146,7 +1167,7 @@ var AccessorImpl = class {
|
|
|
1146
1167
|
const cached = this.scope["cache"].get(this.requestor)?.value;
|
|
1147
1168
|
if (cached && !force) return this.handleCachedState(cached);
|
|
1148
1169
|
if (this.currentPromise && !force) {
|
|
1149
|
-
if (!this.currentPromised) this.currentPromised =
|
|
1170
|
+
if (!this.currentPromised) this.currentPromised = Promised.create(this.currentPromise);
|
|
1150
1171
|
return this.currentPromised;
|
|
1151
1172
|
}
|
|
1152
1173
|
this.scope["~addToResolutionChain"](this.requestor, this.requestor);
|
|
@@ -1158,18 +1179,18 @@ var AccessorImpl = class {
|
|
|
1158
1179
|
promise: this.currentPromise
|
|
1159
1180
|
}
|
|
1160
1181
|
});
|
|
1161
|
-
this.currentPromised =
|
|
1182
|
+
this.currentPromised = Promised.create(this.currentPromise);
|
|
1162
1183
|
return this.currentPromised;
|
|
1163
1184
|
};
|
|
1164
1185
|
}
|
|
1165
1186
|
handleCachedState(cached) {
|
|
1166
1187
|
if (cached.kind === "resolved") {
|
|
1167
1188
|
if (cached.promised) return cached.promised;
|
|
1168
|
-
if (!this.cachedResolvedPromised) this.cachedResolvedPromised =
|
|
1189
|
+
if (!this.cachedResolvedPromised) this.cachedResolvedPromised = Promised.create(Promise.resolve(cached.value));
|
|
1169
1190
|
return this.cachedResolvedPromised;
|
|
1170
1191
|
}
|
|
1171
1192
|
if (cached.kind === "rejected") throw cached.error;
|
|
1172
|
-
if (!this.currentPromised) this.currentPromised =
|
|
1193
|
+
if (!this.currentPromised) this.currentPromised = Promised.create(cached.promise);
|
|
1173
1194
|
return this.currentPromised;
|
|
1174
1195
|
}
|
|
1175
1196
|
processReplacer() {
|
|
@@ -1412,7 +1433,10 @@ var BaseScope = class BaseScope {
|
|
|
1412
1433
|
let executor = baseExecutor;
|
|
1413
1434
|
for (const extension$1 of this.reversedExtensions) if (extension$1.wrap) {
|
|
1414
1435
|
const current = executor;
|
|
1415
|
-
executor = () =>
|
|
1436
|
+
executor = () => {
|
|
1437
|
+
const result = extension$1.wrap(dataStore, current, operation);
|
|
1438
|
+
return result instanceof Promised ? result : Promised.create(result);
|
|
1439
|
+
};
|
|
1416
1440
|
}
|
|
1417
1441
|
return executor;
|
|
1418
1442
|
}
|
|
@@ -1454,10 +1478,10 @@ var BaseScope = class BaseScope {
|
|
|
1454
1478
|
return accessor$1.resolve(force).map(() => accessor$1);
|
|
1455
1479
|
}
|
|
1456
1480
|
update(e, u) {
|
|
1457
|
-
if (this.isDisposing) return
|
|
1481
|
+
if (this.isDisposing) return Promised.create(Promise.resolve());
|
|
1458
1482
|
this["~ensureNotDisposed"]();
|
|
1459
1483
|
const coreUpdate = () => {
|
|
1460
|
-
return
|
|
1484
|
+
return Promised.create((async () => {
|
|
1461
1485
|
this["~triggerCleanup"](e);
|
|
1462
1486
|
const accessor$1 = this["~makeAccessor"](e);
|
|
1463
1487
|
let value;
|
|
@@ -1473,7 +1497,7 @@ var BaseScope = class BaseScope {
|
|
|
1473
1497
|
value: {
|
|
1474
1498
|
kind: "resolved",
|
|
1475
1499
|
value,
|
|
1476
|
-
promised:
|
|
1500
|
+
promised: Promised.create(Promise.resolve(value))
|
|
1477
1501
|
}
|
|
1478
1502
|
});
|
|
1479
1503
|
await this["~triggerUpdate"](e);
|
|
@@ -1507,12 +1531,12 @@ var BaseScope = class BaseScope {
|
|
|
1507
1531
|
this.onUpdateCallbacks.delete(e);
|
|
1508
1532
|
this.cache.delete(e);
|
|
1509
1533
|
};
|
|
1510
|
-
return
|
|
1534
|
+
return Promised.create(coreRelease());
|
|
1511
1535
|
}
|
|
1512
1536
|
dispose() {
|
|
1513
1537
|
this["~ensureNotDisposed"]();
|
|
1514
1538
|
this.isDisposing = true;
|
|
1515
|
-
return
|
|
1539
|
+
return Promised.create((async () => {
|
|
1516
1540
|
for (const pod of this.pods) await this.disposePod(pod);
|
|
1517
1541
|
const extensionDisposeEvents = this.extensions.map((ext) => ext.dispose?.(this) ?? Promise.resolve());
|
|
1518
1542
|
await Promise.all(extensionDisposeEvents);
|
|
@@ -1620,19 +1644,28 @@ var BaseScope = class BaseScope {
|
|
|
1620
1644
|
}
|
|
1621
1645
|
disposePod(pod) {
|
|
1622
1646
|
this["~ensureNotDisposed"]();
|
|
1623
|
-
if (this.isDisposing) return
|
|
1647
|
+
if (this.isDisposing) return Promised.create(Promise.resolve());
|
|
1624
1648
|
return pod.dispose().map(() => {
|
|
1625
1649
|
this.pods.delete(pod);
|
|
1626
1650
|
});
|
|
1627
1651
|
}
|
|
1628
1652
|
exec(flow$1, input, options) {
|
|
1629
1653
|
this["~ensureNotDisposed"]();
|
|
1654
|
+
if (options?.details === true) return flow.execute(flow$1, input, {
|
|
1655
|
+
scope: this,
|
|
1656
|
+
extensions: options.extensions,
|
|
1657
|
+
initialContext: options.initialContext,
|
|
1658
|
+
presets: options.presets,
|
|
1659
|
+
meta: options.meta,
|
|
1660
|
+
details: true
|
|
1661
|
+
});
|
|
1630
1662
|
return flow.execute(flow$1, input, {
|
|
1631
1663
|
scope: this,
|
|
1632
1664
|
extensions: options?.extensions,
|
|
1633
1665
|
initialContext: options?.initialContext,
|
|
1634
1666
|
presets: options?.presets,
|
|
1635
|
-
|
|
1667
|
+
meta: options?.meta,
|
|
1668
|
+
details: false
|
|
1636
1669
|
});
|
|
1637
1670
|
}
|
|
1638
1671
|
};
|
|
@@ -1665,8 +1698,8 @@ var Pod = class extends BaseScope {
|
|
|
1665
1698
|
});
|
|
1666
1699
|
if (value) {
|
|
1667
1700
|
if (value.kind === "rejected") throw value.error;
|
|
1668
|
-
if (value.kind === "resolved") return
|
|
1669
|
-
if (value.kind === "pending") return
|
|
1701
|
+
if (value.kind === "resolved") return Promised.create(Promise.resolve(value.value));
|
|
1702
|
+
if (value.kind === "pending") return Promised.create(value.promise);
|
|
1670
1703
|
}
|
|
1671
1704
|
}
|
|
1672
1705
|
return super.resolve(executor, force);
|
|
@@ -1689,7 +1722,7 @@ var Pod = class extends BaseScope {
|
|
|
1689
1722
|
return await super["~resolveExecutor"](ie, ref);
|
|
1690
1723
|
}
|
|
1691
1724
|
dispose() {
|
|
1692
|
-
return
|
|
1725
|
+
return Promised.create((async () => {
|
|
1693
1726
|
const extensionDisposeEvents = this.extensions.map((ext) => ext.disposePod?.(this) ?? Promise.resolve());
|
|
1694
1727
|
await Promise.all(extensionDisposeEvents);
|
|
1695
1728
|
await super.dispose();
|
|
@@ -1761,7 +1794,7 @@ var MultiExecutorImpl = class {
|
|
|
1761
1794
|
};
|
|
1762
1795
|
}
|
|
1763
1796
|
release(scope) {
|
|
1764
|
-
return
|
|
1797
|
+
return Promised.create((async () => {
|
|
1765
1798
|
const entries = scope.entries();
|
|
1766
1799
|
for (const [executor] of entries) {
|
|
1767
1800
|
const check = this.poolId.some ? this.poolId.some(executor) : this.poolId.find(executor);
|
package/dist/index.d.cts
CHANGED
|
@@ -4,6 +4,7 @@ declare class Promised<T> implements PromiseLike<T> {
|
|
|
4
4
|
private executionDataPromise?;
|
|
5
5
|
private promise;
|
|
6
6
|
constructor(promise: Promise<T> | Promised<T>, executionDataPromise?: Promise<Flow.ExecutionData | undefined>);
|
|
7
|
+
static create<T>(promise: Promise<T> | Promised<T>, executionDataPromise?: Promise<Flow.ExecutionData | undefined>): Promised<T>;
|
|
7
8
|
map<U>(fn: (value: T) => U | Promise<U>): Promised<U>;
|
|
8
9
|
switch<U>(fn: (value: T) => Promised<U>): Promised<U>;
|
|
9
10
|
mapError(fn: (error: unknown) => unknown): Promised<T>;
|
|
@@ -255,18 +256,20 @@ declare namespace Core {
|
|
|
255
256
|
meta?: Meta.Meta[];
|
|
256
257
|
}): Pod;
|
|
257
258
|
disposePod(scope: Pod): Promised<void>;
|
|
258
|
-
exec<S, I>(flow: Core.Executor<Flow.Handler<S, I>>, input
|
|
259
|
+
exec<S, I = undefined>(flow: Core.Executor<Flow.Handler<S, I>>, input?: I, options?: {
|
|
259
260
|
extensions?: Extension.Extension[];
|
|
260
261
|
initialContext?: Array<[Accessor.Accessor<any> | Accessor.AccessorWithDefault<any>, any]>;
|
|
261
262
|
presets?: Preset<unknown>[];
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
263
|
+
meta?: Meta.Meta[];
|
|
264
|
+
details?: false;
|
|
265
|
+
}): Promised<S>;
|
|
266
|
+
exec<S, I = undefined>(flow: Core.Executor<Flow.Handler<S, I>>, input: I | undefined, options: {
|
|
265
267
|
extensions?: Extension.Extension[];
|
|
266
268
|
initialContext?: Array<[Accessor.Accessor<any> | Accessor.AccessorWithDefault<any>, any]>;
|
|
267
269
|
presets?: Preset<unknown>[];
|
|
268
|
-
|
|
269
|
-
|
|
270
|
+
meta?: Meta.Meta[];
|
|
271
|
+
details: true;
|
|
272
|
+
}): Promised<Flow.ExecutionDetails<S>>;
|
|
270
273
|
}
|
|
271
274
|
}
|
|
272
275
|
declare class FlowError extends Error {
|
|
@@ -405,13 +408,13 @@ declare namespace Extension {
|
|
|
405
408
|
};
|
|
406
409
|
interface Extension {
|
|
407
410
|
name: string;
|
|
408
|
-
init?(scope: Core.Scope): void | Promised<void>;
|
|
409
|
-
initPod?(pod: Core.Pod, context: Accessor.DataStore): void | Promised<void>;
|
|
410
|
-
wrap?<T>(context: Accessor.DataStore, next: () => Promised<T>, operation: Operation): Promised<T>;
|
|
411
|
+
init?(scope: Core.Scope): void | Promise<void> | Promised<void>;
|
|
412
|
+
initPod?(pod: Core.Pod, context: Accessor.DataStore): void | Promise<void> | Promised<void>;
|
|
413
|
+
wrap?<T>(context: Accessor.DataStore, next: () => Promised<T>, operation: Operation): Promise<T> | Promised<T>;
|
|
411
414
|
onError?(error: ExecutorResolutionError | FactoryExecutionError | DependencyResolutionError, scope: Core.Scope): void;
|
|
412
415
|
onPodError?(error: unknown, pod: Core.Pod, context: Accessor.DataStore): void;
|
|
413
|
-
dispose?(scope: Core.Scope): void | Promised<void>;
|
|
414
|
-
disposePod?(pod: Core.Pod): void | Promised<void>;
|
|
416
|
+
dispose?(scope: Core.Scope): void | Promise<void> | Promised<void>;
|
|
417
|
+
disposePod?(pod: Core.Pod): void | Promise<void> | Promised<void>;
|
|
415
418
|
}
|
|
416
419
|
}
|
|
417
420
|
declare namespace Accessor {
|
|
@@ -553,6 +556,7 @@ declare function execute<S, I>(flow: Core.Executor<Flow.Handler<S, I>> | Flow.Fl
|
|
|
553
556
|
extensions?: Extension.Extension[];
|
|
554
557
|
initialContext?: Array<[Accessor.Accessor<any> | Accessor.AccessorWithDefault<any>, any]>;
|
|
555
558
|
presets?: Core.Preset<unknown>[];
|
|
559
|
+
meta?: Meta.Meta[];
|
|
556
560
|
details: true;
|
|
557
561
|
}): Promised<Flow.ExecutionDetails<S>>;
|
|
558
562
|
declare function execute<S, I>(flow: Core.Executor<Flow.Handler<S, I>> | Flow.Flow<I, S>, input: I, options?: {
|
|
@@ -560,6 +564,7 @@ declare function execute<S, I>(flow: Core.Executor<Flow.Handler<S, I>> | Flow.Fl
|
|
|
560
564
|
extensions?: Extension.Extension[];
|
|
561
565
|
initialContext?: Array<[Accessor.Accessor<any> | Accessor.AccessorWithDefault<any>, any]>;
|
|
562
566
|
presets?: Core.Preset<unknown>[];
|
|
567
|
+
meta?: Meta.Meta[];
|
|
563
568
|
details?: false;
|
|
564
569
|
}): Promised<S>;
|
|
565
570
|
declare function flowImpl<I, S>(handler: (ctx: Flow.Context, input: I) => Promise<S> | S): Flow.Flow<I, S>;
|