Skip to content

Commit f482003

Browse files
committed
context._components fallbacks for testing use cases
1 parent 5dbf763 commit f482003

3 files changed

Lines changed: 4 additions & 6 deletions

File tree

packages/spectral/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@prismatic-io/spectral",
3-
"version": "10.5.15",
3+
"version": "10.5.16",
44
"description": "Utility library for building Prismatic connectors and code-native integrations",
55
"keywords": ["prismatic"],
66
"main": "dist/index.js",

packages/spectral/src/serverTypes/context.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ export function createCNIContext(
3232
// They are added to the context via spectral, here.
3333

3434
// @ts-expect-error _components isn't part of the public API
35-
const { _components } = context;
36-
35+
const _components = context._components ?? { invoke: () => {} };
3736
const invoke = (_components as { invoke: ComponentActionInvokeFunction }).invoke;
3837

3938
// Construct the component methods from the component registry

packages/spectral/src/serverTypes/convertIntegration.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,7 @@ const generateTriggerPerformFn = (
878878
componentRef && typeof onTrigger !== "function"
879879
? async (context, payload, params) => {
880880
// @ts-expect-error: _components isn't part of the public API
881-
const { _components } = context;
881+
const _components = context._components ?? { invokeTrigger: () => {} };
882882
const invokeTrigger: TriggerActionInvokeFunction = _components.invokeTrigger;
883883
const cniContext = createCNIContext(context, componentRegistry);
884884

@@ -923,8 +923,7 @@ const generateOnInstanceWrapperFn = (
923923
componentRef && typeof onTrigger !== "function"
924924
? async (context, params) => {
925925
// @ts-expect-error: _components isn't part of the public API
926-
const { _components } = context;
927-
926+
const _components = context._components ?? { invokeTrigger: () => {} };
928927
const invokeTrigger: TriggerActionInvokeFunction = _components.invokeTrigger;
929928
const cniContext = createCNIContext(context, componentRegistry);
930929
const invokeResponse =

0 commit comments

Comments
 (0)