@envelop/core 4.0.2 → 4.0.3-alpha-20230927224902-6f1e67b4
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/cjs/orchestrator.js +16 -13
- package/esm/orchestrator.js +16 -13
- package/package.json +1 -1
package/cjs/orchestrator.js
CHANGED
|
@@ -193,16 +193,17 @@ function createEnvelopOrchestrator({ plugins, }) {
|
|
|
193
193
|
? initialContext => async (orchestratorCtx) => {
|
|
194
194
|
const afterCalls = [];
|
|
195
195
|
// In order to have access to the "last working" context object we keep this outside of the try block:
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
196
|
+
const context = initialContext;
|
|
197
|
+
if (orchestratorCtx) {
|
|
198
|
+
Object.assign(context, orchestratorCtx);
|
|
199
|
+
}
|
|
199
200
|
try {
|
|
200
201
|
let isBreakingContextBuilding = false;
|
|
201
202
|
for (const onContext of beforeCallbacks.context) {
|
|
202
203
|
const afterHookResult = await onContext({
|
|
203
204
|
context,
|
|
204
205
|
extendContext: extension => {
|
|
205
|
-
context
|
|
206
|
+
Object.assign(context, extension);
|
|
206
207
|
},
|
|
207
208
|
breakContextBuilding: () => {
|
|
208
209
|
isBreakingContextBuilding = true;
|
|
@@ -219,7 +220,7 @@ function createEnvelopOrchestrator({ plugins, }) {
|
|
|
219
220
|
afterCb({
|
|
220
221
|
context,
|
|
221
222
|
extendContext: extension => {
|
|
222
|
-
context
|
|
223
|
+
Object.assign(context, extension);
|
|
223
224
|
},
|
|
224
225
|
});
|
|
225
226
|
}
|
|
@@ -239,14 +240,19 @@ function createEnvelopOrchestrator({ plugins, }) {
|
|
|
239
240
|
throw error;
|
|
240
241
|
}
|
|
241
242
|
}
|
|
242
|
-
: initialContext => orchestratorCtx =>
|
|
243
|
+
: initialContext => orchestratorCtx => {
|
|
244
|
+
if (orchestratorCtx) {
|
|
245
|
+
Object.assign(initialContext, orchestratorCtx);
|
|
246
|
+
}
|
|
247
|
+
return initialContext;
|
|
248
|
+
};
|
|
243
249
|
const useCustomSubscribe = beforeCallbacks.subscribe.length;
|
|
244
250
|
const customSubscribe = useCustomSubscribe
|
|
245
251
|
? (0, utils_js_1.makeSubscribe)(async (args) => {
|
|
246
252
|
let subscribeFn = subscribe;
|
|
247
253
|
const afterCalls = [];
|
|
248
254
|
const subscribeErrorHandlers = [];
|
|
249
|
-
|
|
255
|
+
const context = args.contextValue || {};
|
|
250
256
|
let result;
|
|
251
257
|
for (const onSubscribe of beforeCallbacks.subscribe) {
|
|
252
258
|
const after = await onSubscribe({
|
|
@@ -255,7 +261,7 @@ function createEnvelopOrchestrator({ plugins, }) {
|
|
|
255
261
|
subscribeFn = newSubscribeFn;
|
|
256
262
|
},
|
|
257
263
|
extendContext: extension => {
|
|
258
|
-
context
|
|
264
|
+
Object.assign(context, extension);
|
|
259
265
|
},
|
|
260
266
|
args: args,
|
|
261
267
|
setResultAndStopExecution: stopResult => {
|
|
@@ -346,7 +352,7 @@ function createEnvelopOrchestrator({ plugins, }) {
|
|
|
346
352
|
let executeFn = execute;
|
|
347
353
|
let result;
|
|
348
354
|
const afterCalls = [];
|
|
349
|
-
|
|
355
|
+
const context = args.contextValue || {};
|
|
350
356
|
for (const onExecute of beforeCallbacks.execute) {
|
|
351
357
|
const after = await onExecute({
|
|
352
358
|
executeFn,
|
|
@@ -358,10 +364,7 @@ function createEnvelopOrchestrator({ plugins, }) {
|
|
|
358
364
|
},
|
|
359
365
|
extendContext: extension => {
|
|
360
366
|
if (typeof extension === 'object') {
|
|
361
|
-
context
|
|
362
|
-
...context,
|
|
363
|
-
...extension,
|
|
364
|
-
};
|
|
367
|
+
Object.assign(context, extension);
|
|
365
368
|
}
|
|
366
369
|
else {
|
|
367
370
|
throw new Error(`Invalid context extension provided! Expected "object", got: "${JSON.stringify(extension)}" (${typeof extension})`);
|
package/esm/orchestrator.js
CHANGED
|
@@ -190,16 +190,17 @@ export function createEnvelopOrchestrator({ plugins, }) {
|
|
|
190
190
|
? initialContext => async (orchestratorCtx) => {
|
|
191
191
|
const afterCalls = [];
|
|
192
192
|
// In order to have access to the "last working" context object we keep this outside of the try block:
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
193
|
+
const context = initialContext;
|
|
194
|
+
if (orchestratorCtx) {
|
|
195
|
+
Object.assign(context, orchestratorCtx);
|
|
196
|
+
}
|
|
196
197
|
try {
|
|
197
198
|
let isBreakingContextBuilding = false;
|
|
198
199
|
for (const onContext of beforeCallbacks.context) {
|
|
199
200
|
const afterHookResult = await onContext({
|
|
200
201
|
context,
|
|
201
202
|
extendContext: extension => {
|
|
202
|
-
context
|
|
203
|
+
Object.assign(context, extension);
|
|
203
204
|
},
|
|
204
205
|
breakContextBuilding: () => {
|
|
205
206
|
isBreakingContextBuilding = true;
|
|
@@ -216,7 +217,7 @@ export function createEnvelopOrchestrator({ plugins, }) {
|
|
|
216
217
|
afterCb({
|
|
217
218
|
context,
|
|
218
219
|
extendContext: extension => {
|
|
219
|
-
context
|
|
220
|
+
Object.assign(context, extension);
|
|
220
221
|
},
|
|
221
222
|
});
|
|
222
223
|
}
|
|
@@ -236,14 +237,19 @@ export function createEnvelopOrchestrator({ plugins, }) {
|
|
|
236
237
|
throw error;
|
|
237
238
|
}
|
|
238
239
|
}
|
|
239
|
-
: initialContext => orchestratorCtx =>
|
|
240
|
+
: initialContext => orchestratorCtx => {
|
|
241
|
+
if (orchestratorCtx) {
|
|
242
|
+
Object.assign(initialContext, orchestratorCtx);
|
|
243
|
+
}
|
|
244
|
+
return initialContext;
|
|
245
|
+
};
|
|
240
246
|
const useCustomSubscribe = beforeCallbacks.subscribe.length;
|
|
241
247
|
const customSubscribe = useCustomSubscribe
|
|
242
248
|
? makeSubscribe(async (args) => {
|
|
243
249
|
let subscribeFn = subscribe;
|
|
244
250
|
const afterCalls = [];
|
|
245
251
|
const subscribeErrorHandlers = [];
|
|
246
|
-
|
|
252
|
+
const context = args.contextValue || {};
|
|
247
253
|
let result;
|
|
248
254
|
for (const onSubscribe of beforeCallbacks.subscribe) {
|
|
249
255
|
const after = await onSubscribe({
|
|
@@ -252,7 +258,7 @@ export function createEnvelopOrchestrator({ plugins, }) {
|
|
|
252
258
|
subscribeFn = newSubscribeFn;
|
|
253
259
|
},
|
|
254
260
|
extendContext: extension => {
|
|
255
|
-
context
|
|
261
|
+
Object.assign(context, extension);
|
|
256
262
|
},
|
|
257
263
|
args: args,
|
|
258
264
|
setResultAndStopExecution: stopResult => {
|
|
@@ -343,7 +349,7 @@ export function createEnvelopOrchestrator({ plugins, }) {
|
|
|
343
349
|
let executeFn = execute;
|
|
344
350
|
let result;
|
|
345
351
|
const afterCalls = [];
|
|
346
|
-
|
|
352
|
+
const context = args.contextValue || {};
|
|
347
353
|
for (const onExecute of beforeCallbacks.execute) {
|
|
348
354
|
const after = await onExecute({
|
|
349
355
|
executeFn,
|
|
@@ -355,10 +361,7 @@ export function createEnvelopOrchestrator({ plugins, }) {
|
|
|
355
361
|
},
|
|
356
362
|
extendContext: extension => {
|
|
357
363
|
if (typeof extension === 'object') {
|
|
358
|
-
context
|
|
359
|
-
...context,
|
|
360
|
-
...extension,
|
|
361
|
-
};
|
|
364
|
+
Object.assign(context, extension);
|
|
362
365
|
}
|
|
363
366
|
else {
|
|
364
367
|
throw new Error(`Invalid context extension provided! Expected "object", got: "${JSON.stringify(extension)}" (${typeof extension})`);
|