@prismatic-io/spectral 7.6.8 → 7.7.0
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.
|
@@ -117,12 +117,19 @@ const evaluate = (expression) => {
|
|
|
117
117
|
const [operator] = expression;
|
|
118
118
|
if (operator in types_1.BooleanOperator) {
|
|
119
119
|
const predicates = expression.slice(1);
|
|
120
|
-
const results = predicates.map(exports.evaluate);
|
|
121
120
|
switch (operator) {
|
|
122
121
|
case types_1.BooleanOperator.and:
|
|
123
|
-
|
|
122
|
+
for (const predicate of predicates) {
|
|
123
|
+
if (!(0, exports.evaluate)(predicate))
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
return true;
|
|
124
127
|
case types_1.BooleanOperator.or:
|
|
125
|
-
|
|
128
|
+
for (const predicate of predicates) {
|
|
129
|
+
if ((0, exports.evaluate)(predicate))
|
|
130
|
+
return true;
|
|
131
|
+
}
|
|
132
|
+
return false;
|
|
126
133
|
default:
|
|
127
134
|
throw new Error(`Invalid operator: '${operator}'`);
|
|
128
135
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ import { convertComponent } from "./serverTypes/convert";
|
|
|
13
13
|
* @param definition A ComponentDefinition type object, including display information, unique key, and a set of actions the component implements.
|
|
14
14
|
* @returns This function returns a component object that has the shape the Prismatic API expects.
|
|
15
15
|
*/
|
|
16
|
-
export declare const component: <
|
|
16
|
+
export declare const component: <TPublic extends boolean, TKey extends string>(definition: ComponentDefinition<TPublic, TKey>) => ReturnType<typeof convertComponent>;
|
|
17
17
|
/**
|
|
18
18
|
* This function creates an action object that can be referenced
|
|
19
19
|
* by a custom component. It helps ensure that the shape of the
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ComponentDefinition } from "../types";
|
|
2
2
|
import { Component as ServerComponent } from ".";
|
|
3
|
-
export declare const convertComponent: <TPublic extends boolean>({ connections, actions, triggers, dataSources, hooks, ...definition }: ComponentDefinition<TPublic>) => ServerComponent;
|
|
3
|
+
export declare const convertComponent: <TPublic extends boolean, TKey extends string>({ connections, actions, triggers, dataSources, hooks, ...definition }: ComponentDefinition<TPublic, TKey>) => ServerComponent;
|
|
@@ -5,9 +5,9 @@ export interface ComponentHooks {
|
|
|
5
5
|
error?: ErrorHandler;
|
|
6
6
|
}
|
|
7
7
|
/** Defines attributes of a Component. */
|
|
8
|
-
export declare type ComponentDefinition<TPublic extends boolean> = {
|
|
8
|
+
export declare type ComponentDefinition<TPublic extends boolean, TKey extends string> = {
|
|
9
9
|
/** Specifies unique key for this Component. */
|
|
10
|
-
key:
|
|
10
|
+
key: TKey;
|
|
11
11
|
/** Specifies if this Component is available for all Organizations or only your own @default false */
|
|
12
12
|
public?: TPublic;
|
|
13
13
|
/** Defines how the Component is displayed in the Prismatic interface. */
|
|
@@ -24,7 +24,7 @@ export declare type ComponentDefinition<TPublic extends boolean> = {
|
|
|
24
24
|
hooks?: ComponentHooks;
|
|
25
25
|
} & (TPublic extends true ? {
|
|
26
26
|
/** Specified the URL for the Component Documentation. */
|
|
27
|
-
documentationUrl:
|
|
27
|
+
documentationUrl: `https://prismatic.io/docs/components/${TKey}/`;
|
|
28
28
|
} : {
|
|
29
29
|
documentationUrl?: string;
|
|
30
30
|
});
|