@prismatic-io/spectral 10.21.1-preview.0 → 10.22.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.
- package/dist/generators/cniComponentManifest/index.js +7 -4
- package/dist/generators/cniComponentManifest/types.d.ts +1 -4
- package/dist/generators/componentManifest/createActions.js +1 -3
- package/dist/generators/componentManifest/templates/actions/action.ts.ejs +0 -6
- package/dist/serverTypes/convertComponent.d.ts +2 -3
- package/dist/serverTypes/convertComponent.js +5 -13
- package/dist/serverTypes/index.d.ts +1 -4
- package/dist/types/ActionDefinition.d.ts +0 -13
- package/dist/types/ActionDefinition.js +0 -10
- package/dist/types/ComponentManifest.d.ts +0 -4
- package/package.json +7 -7
- package/dist/serverTypes/inlineActionCalling.publishWire.spec.d.ts +0 -1
- package/dist/serverTypes/inlineActionCalling.publishWire.spec.js +0 -167
|
@@ -134,10 +134,15 @@ const fetchComponentDataForManifest = (_a) => __awaiter(void 0, [_a], void 0, fu
|
|
|
134
134
|
};
|
|
135
135
|
}
|
|
136
136
|
else {
|
|
137
|
-
actions[node.key] =
|
|
137
|
+
actions[node.key] = {
|
|
138
|
+
key: node.key,
|
|
139
|
+
display: {
|
|
138
140
|
label: node.label,
|
|
139
141
|
description: node.description,
|
|
140
|
-
},
|
|
142
|
+
},
|
|
143
|
+
inputs: transformInputNodes(node.inputs.nodes),
|
|
144
|
+
examplePayload: node.examplePayload,
|
|
145
|
+
};
|
|
141
146
|
}
|
|
142
147
|
});
|
|
143
148
|
const connections = component.connections.nodes.map((node) => {
|
|
@@ -240,8 +245,6 @@ function getComponentActions(componentId, prismaticUrl, accessToken) {
|
|
|
240
245
|
}
|
|
241
246
|
}
|
|
242
247
|
examplePayload
|
|
243
|
-
examplePerformSafety
|
|
244
|
-
performSafety
|
|
245
248
|
}
|
|
246
249
|
pageInfo {
|
|
247
250
|
hasNextPage
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { Action, Component, DataSource, Trigger, TriggerPayload } from "../../serverTypes";
|
|
2
2
|
import type { ConfigVarResultCollection, Inputs } from "../../types";
|
|
3
|
-
import type { PerformSafety } from "../../types/ActionDefinition";
|
|
4
3
|
import type { TriggerResult } from "../../types/TriggerResult";
|
|
5
4
|
export interface ComponentNode {
|
|
6
5
|
id: string;
|
|
@@ -29,8 +28,6 @@ export interface ActionNode {
|
|
|
29
28
|
nodes: InputNode[];
|
|
30
29
|
};
|
|
31
30
|
examplePayload: string | null;
|
|
32
|
-
examplePerformSafety: PerformSafety | null;
|
|
33
|
-
performSafety: PerformSafety | null;
|
|
34
31
|
}
|
|
35
32
|
export interface ConnectionNode {
|
|
36
33
|
key: string;
|
|
@@ -50,7 +47,7 @@ export interface InputNode {
|
|
|
50
47
|
shown: boolean;
|
|
51
48
|
onPremiseControlled: boolean;
|
|
52
49
|
}
|
|
53
|
-
export type FormattedAction = Pick<Action, "key" | "display" | "inputs" | "examplePayload"
|
|
50
|
+
export type FormattedAction = Pick<Action, "key" | "display" | "inputs" | "examplePayload"> & {
|
|
54
51
|
/** Emitted verbatim into the generated manifest; shape mirrors `examplePayload`. */
|
|
55
52
|
outputSchema?: unknown;
|
|
56
53
|
};
|
|
@@ -44,9 +44,7 @@ const createActions = (_a) => __awaiter(void 0, [_a], void 0, function* ({ compo
|
|
|
44
44
|
});
|
|
45
45
|
const imports = (0, getImports_1.getImports)({ inputs });
|
|
46
46
|
return yield renderAction({
|
|
47
|
-
action: Object.assign(Object.assign(Object.assign(
|
|
48
|
-
? { examplePerformSafety: action.examplePerformSafety }
|
|
49
|
-
: {})), (action.performSafety ? { performSafety: action.performSafety } : {})), { componentKey: component.key }),
|
|
47
|
+
action: Object.assign(Object.assign(Object.assign({ typeInterface: (0, createTypeInterface_1.createTypeInterface)((_b = action.key) !== null && _b !== void 0 ? _b : actionKey), import: (0, createImport_1.createImport)((_c = action.key) !== null && _c !== void 0 ? _c : actionKey), key: action.key || actionKey, label: action.display.label, description: action.display.description, inputs }, (action.examplePayload ? { examplePayload: action.examplePayload } : {})), (action.outputSchema ? { outputSchema: action.outputSchema } : {})), { componentKey: component.key }),
|
|
50
48
|
imports,
|
|
51
49
|
dryRun,
|
|
52
50
|
verbose,
|
|
@@ -28,10 +28,4 @@ export const <%= action.import %> = {
|
|
|
28
28
|
<%_ if (action.outputSchema) { -%>
|
|
29
29
|
outputSchema: <%- typeof action.outputSchema === 'string' ? action.outputSchema : JSON.stringify(action.outputSchema, null, 2) %>,
|
|
30
30
|
<%_ } -%>
|
|
31
|
-
<%_ if (action.examplePerformSafety) { -%>
|
|
32
|
-
examplePerformSafety: "<%= action.examplePerformSafety %>",
|
|
33
|
-
<%_ } -%>
|
|
34
|
-
<%_ if (action.performSafety) { -%>
|
|
35
|
-
performSafety: "<%= action.performSafety %>",
|
|
36
|
-
<%_ } -%>
|
|
37
31
|
} as const;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type ComponentDefinition, type ComponentHooks, type ConfigVarResultCollection, type ConnectionDefinition, type ConnectionInput, type ConnectionTemplateInputField, type InputFieldDefinition, type Inputs, type OnPremConnectionInput, type TriggerDefinition, type TriggerPayload, type TriggerResult } from "../types";
|
|
2
2
|
import { type PollingTriggerDefinition } from "../types/PollingTriggerDefinition";
|
|
3
|
-
import type {
|
|
3
|
+
import type { Component as ServerComponent, Connection as ServerConnection, Input as ServerInput, Trigger as ServerTrigger } from ".";
|
|
4
4
|
import { type CleanFn } from "./perform";
|
|
5
5
|
/** Auto-generated cleaner for structuredObject/dynamicObject containers.
|
|
6
6
|
* Recursively delegates to each child's clean function. Developers do not
|
|
@@ -29,7 +29,6 @@ export declare const _isValidTemplateValue: (template: string, inputs: {
|
|
|
29
29
|
export declare const convertTemplateInput: (key: string, { templateValue, label, ...rest }: ConnectionTemplateInputField, inputs: {
|
|
30
30
|
[key: string]: ConnectionInput | ConnectionTemplateInputField;
|
|
31
31
|
}) => ServerInput;
|
|
32
|
-
export declare const convertAction: (actionKey: string, { inputs, perform, outputSchema, examplePerform, ...action }: ActionDefinition<Inputs, any, boolean, any>, hooks?: ComponentHooks) => ServerAction;
|
|
33
32
|
export declare const convertTrigger: <TInputs extends Inputs, TActionInputs extends Inputs, TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection, TPayload extends TriggerPayload = TriggerPayload, TAllowsBranching extends boolean = boolean, TResult extends TriggerResult<TAllowsBranching, TPayload> = TriggerResult<TAllowsBranching, TPayload>>(triggerKey: string, trigger: TriggerDefinition<any> | PollingTriggerDefinition<any, ConfigVarResultCollection, TriggerPayload, boolean, any, any>, hooks?: ComponentHooks) => ServerTrigger<TInputs, TActionInputs, TConfigVars, TPayload, TAllowsBranching, TResult>;
|
|
34
33
|
export declare const convertConnection: ({ inputs, ...connection }: ConnectionDefinition) => ServerConnection;
|
|
35
34
|
export declare const convertComponent: <TPublic extends boolean, TKey extends string, TInputs extends Inputs, TActionInputs extends Inputs, TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection, TPayload extends TriggerPayload = TriggerPayload, TAllowsBranching extends boolean = boolean, TResult extends TriggerResult<TAllowsBranching, TPayload> = TriggerResult<TAllowsBranching, TPayload>>({ connections, actions, triggers, dataSources, hooks, ...definition }: ComponentDefinition<TPublic, TKey>) => ServerComponent<TInputs, TActionInputs, TConfigVars, TPayload, TAllowsBranching, TResult>;
|
|
@@ -14,7 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.convertComponent = exports.convertConnection = exports.convertTrigger = exports.
|
|
17
|
+
exports.convertComponent = exports.convertConnection = exports.convertTrigger = exports.convertTemplateInput = exports._isValidTemplateValue = exports.convertInput = exports.validateConcurrentBatchLimit = exports.validateBatchSize = exports.cleanerFor = void 0;
|
|
18
18
|
const omit_1 = __importDefault(require("lodash/omit"));
|
|
19
19
|
const types_1 = require("../types");
|
|
20
20
|
const PollingTriggerDefinition_1 = require("../types/PollingTriggerDefinition");
|
|
@@ -226,22 +226,14 @@ const convertOutputSchema = (outputSchema) => {
|
|
|
226
226
|
};
|
|
227
227
|
};
|
|
228
228
|
const convertAction = (actionKey, _a, hooks) => {
|
|
229
|
-
var { inputs = {}, perform, outputSchema
|
|
229
|
+
var { inputs = {}, perform, outputSchema } = _a, action = __rest(_a, ["inputs", "perform", "outputSchema"]);
|
|
230
230
|
const convertedInputs = Object.entries(inputs).map(([key, value]) => (0, exports.convertInput)(key, value));
|
|
231
231
|
const inputCleaners = Object.entries(inputs).reduce((result, [key, value]) => (Object.assign(Object.assign({}, result), { [key]: (0, exports.cleanerFor)(value) })), {});
|
|
232
|
-
return Object.assign(Object.assign(Object.assign(
|
|
232
|
+
return Object.assign(Object.assign(Object.assign({}, action), { key: actionKey, inputs: convertedInputs, perform: (0, perform_1.createPerform)(perform, {
|
|
233
233
|
inputCleaners,
|
|
234
234
|
errorHandler: hooks === null || hooks === void 0 ? void 0 : hooks.error,
|
|
235
|
-
}) }), (outputSchema ? { outputSchema: convertOutputSchema(outputSchema) } : {}))
|
|
236
|
-
? {
|
|
237
|
-
examplePerform: (0, perform_1.createPerform)(examplePerform, {
|
|
238
|
-
inputCleaners,
|
|
239
|
-
errorHandler: hooks === null || hooks === void 0 ? void 0 : hooks.error,
|
|
240
|
-
}),
|
|
241
|
-
}
|
|
242
|
-
: {}));
|
|
235
|
+
}) }), (outputSchema ? { outputSchema: convertOutputSchema(outputSchema) } : {}));
|
|
243
236
|
};
|
|
244
|
-
exports.convertAction = convertAction;
|
|
245
237
|
const convertTrigger = (triggerKey,
|
|
246
238
|
// `any` is load-bearing: the user-facing TriggerDefinition / PollingTriggerDefinition
|
|
247
239
|
// type their event-function fields (onInstanceDeploy, webhookLifecycleHandlers, etc.) over
|
|
@@ -374,7 +366,7 @@ const convertConnection = (_a) => {
|
|
|
374
366
|
exports.convertConnection = convertConnection;
|
|
375
367
|
const convertComponent = (_a) => {
|
|
376
368
|
var { connections = [], actions = {}, triggers = {}, dataSources = {}, hooks } = _a, definition = __rest(_a, ["connections", "actions", "triggers", "dataSources", "hooks"]);
|
|
377
|
-
const convertedActions = Object.entries(actions).reduce((result, [actionKey, action]) => (Object.assign(Object.assign({}, result), { [actionKey]:
|
|
369
|
+
const convertedActions = Object.entries(actions).reduce((result, [actionKey, action]) => (Object.assign(Object.assign({}, result), { [actionKey]: convertAction(actionKey, action, hooks) })), {});
|
|
378
370
|
const convertedTriggers = Object.entries(triggers).reduce((result, [triggerKey, trigger]) => (Object.assign(Object.assign({}, result), { [triggerKey]: (0, exports.convertTrigger)(triggerKey, trigger, hooks) })), {});
|
|
379
371
|
const convertedDataSources = Object.entries(dataSources).reduce((result, [dataSourceKey, dataSource]) => (Object.assign(Object.assign({}, result), { [dataSourceKey]: convertDataSource(dataSourceKey, dataSource, hooks) })), {});
|
|
380
372
|
return Object.assign(Object.assign({}, definition), { connections: connections.map(exports.convertConnection), actions: convertedActions, triggers: convertedTriggers, dataSources: convertedDataSources });
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ComponentManifest, ConfigVarResultCollection, CustomerAttributes, DataSourceResultType, DataSourceType, DebugContext, ExecutionFrame, FlowAttributes, FlowInvoker, FlowSchemas, Inputs, InstanceAttributes, IntegrationAttributes,
|
|
1
|
+
import type { ComponentManifest, ConfigVarResultCollection, CustomerAttributes, DataSourceResultType, DataSourceType, DebugContext, ExecutionFrame, FlowAttributes, FlowInvoker, FlowSchemas, Inputs, InstanceAttributes, IntegrationAttributes, PollingTriggerPerformFunction, TriggerEventFunctionReturn, TriggerPerformFunction, TriggerResult as TriggerPerformResult, UserAttributes } from "../types";
|
|
2
2
|
import type { CNIPollingPerformFunction, ComponentRefTriggerPerformFunction } from "./triggerTypes";
|
|
3
3
|
interface DisplayDefinition {
|
|
4
4
|
label: string;
|
|
@@ -48,9 +48,6 @@ export interface Action {
|
|
|
48
48
|
* from the author-facing `OutputSchema`.
|
|
49
49
|
*/
|
|
50
50
|
outputSchema?: ServerOutputSchema;
|
|
51
|
-
examplePerform?: ActionPerformFunction;
|
|
52
|
-
examplePerformSafety?: PerformSafety;
|
|
53
|
-
performSafety?: PerformSafety;
|
|
54
51
|
}
|
|
55
52
|
export type ServerOutputSchema = {
|
|
56
53
|
type: "actionOutput";
|
|
@@ -4,16 +4,6 @@ import type { ComponentManifestAction } from "./ComponentManifest";
|
|
|
4
4
|
import type { ActionDisplayDefinition } from "./DisplayDefinition";
|
|
5
5
|
import type { ConfigVarResultCollection, Inputs } from "./Inputs";
|
|
6
6
|
import type { OutputSchema } from "./OutputSchema";
|
|
7
|
-
/**
|
|
8
|
-
* Whether a perform is safe to invoke inline (to populate reference data in the Prismatic UI):
|
|
9
|
-
* `SAFE` to run as-is, `UNSAFE` if running has side effects, `NOT_ALLOWED` to opt out.
|
|
10
|
-
*/
|
|
11
|
-
export declare const PerformSafety: {
|
|
12
|
-
readonly SAFE: "SAFE";
|
|
13
|
-
readonly UNSAFE: "UNSAFE";
|
|
14
|
-
readonly NOT_ALLOWED: "NOT_ALLOWED";
|
|
15
|
-
};
|
|
16
|
-
export type PerformSafety = (typeof PerformSafety)[keyof typeof PerformSafety];
|
|
17
7
|
/**
|
|
18
8
|
* ActionDefinition is the type of the object that is passed in to `action` function to
|
|
19
9
|
* define a component action. See
|
|
@@ -24,9 +14,6 @@ export interface ActionDefinition<TInputs extends Inputs = Inputs, TConfigVars e
|
|
|
24
14
|
display: ActionDisplayDefinition;
|
|
25
15
|
/** The function to perform when this action is invoked. */
|
|
26
16
|
perform: ActionPerformFunction<TInputs, TConfigVars, Record<string, Record<string, ComponentManifestAction>>, TAllowsBranching, TReturn>;
|
|
27
|
-
examplePerform?: ActionPerformFunction<TInputs, TConfigVars, Record<string, Record<string, ComponentManifestAction>>, TAllowsBranching, TReturn>;
|
|
28
|
-
examplePerformSafety?: PerformSafety;
|
|
29
|
-
performSafety?: PerformSafety;
|
|
30
17
|
/**
|
|
31
18
|
* The inputs to present a low-code integration builder. Values of these inputs
|
|
32
19
|
* are passed to the `perform` function when the action is invoked.
|
|
@@ -1,12 +1,2 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PerformSafety = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Whether a perform is safe to invoke inline (to populate reference data in the Prismatic UI):
|
|
6
|
-
* `SAFE` to run as-is, `UNSAFE` if running has side effects, `NOT_ALLOWED` to opt out.
|
|
7
|
-
*/
|
|
8
|
-
exports.PerformSafety = {
|
|
9
|
-
SAFE: "SAFE",
|
|
10
|
-
UNSAFE: "UNSAFE",
|
|
11
|
-
NOT_ALLOWED: "NOT_ALLOWED",
|
|
12
|
-
};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { PerformSafety } from "./ActionDefinition";
|
|
2
1
|
import type { CollectionType } from "./ConfigVars";
|
|
3
2
|
import type { DataSourceType } from "./DataSourceResult";
|
|
4
3
|
import type { InputFieldType } from "./Inputs";
|
|
@@ -21,9 +20,6 @@ interface BaseInput {
|
|
|
21
20
|
export interface ComponentManifestAction {
|
|
22
21
|
key?: string;
|
|
23
22
|
perform: (values: any) => Promise<unknown>;
|
|
24
|
-
examplePerform?: (values: any) => Promise<unknown>;
|
|
25
|
-
examplePerformSafety?: PerformSafety;
|
|
26
|
-
performSafety?: PerformSafety;
|
|
27
23
|
inputs: Record<string, BaseInput>;
|
|
28
24
|
examplePayload?: unknown;
|
|
29
25
|
/** Declares the shape of this action's output `data` as a JSON Schema (discriminated union: actionOutput | branchingOutput). */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prismatic-io/spectral",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.22.0",
|
|
4
4
|
"description": "Utility library for building Prismatic connectors and code-native integrations",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"prismatic"
|
|
@@ -42,16 +42,16 @@
|
|
|
42
42
|
"dist/"
|
|
43
43
|
],
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"axios": "^1.
|
|
45
|
+
"axios": "^1.18.0",
|
|
46
46
|
"axios-retry": "^4.5.0",
|
|
47
47
|
"date-fns": "^4.4.0",
|
|
48
48
|
"ejs": "^6.0.1",
|
|
49
|
-
"form-data": "^4.0.
|
|
49
|
+
"form-data": "^4.0.6",
|
|
50
50
|
"fs-extra": "^11.3.5",
|
|
51
51
|
"jest-mock": "^30.4.1",
|
|
52
52
|
"lodash": "^4.18.1",
|
|
53
53
|
"object-sizeof": "^2.6.4",
|
|
54
|
-
"prettier": "^3.8.
|
|
54
|
+
"prettier": "^3.8.4",
|
|
55
55
|
"safe-stable-stringify": "^2.5.0",
|
|
56
56
|
"valid-url": "1.0.9",
|
|
57
57
|
"yaml": "^2.9.0"
|
|
@@ -62,14 +62,14 @@
|
|
|
62
62
|
"@types/ejs": "3.1.5",
|
|
63
63
|
"@types/fs-extra": "11.0.4",
|
|
64
64
|
"@types/lodash": "^4.17.24",
|
|
65
|
-
"@types/node": "^25.9.
|
|
65
|
+
"@types/node": "^25.9.3",
|
|
66
66
|
"@types/prettier": "^3.0.0",
|
|
67
67
|
"@types/sax": "^1.2.7",
|
|
68
68
|
"@types/valid-url": "^1.0.7",
|
|
69
|
-
"@vitest/ui": "^4.1.
|
|
69
|
+
"@vitest/ui": "^4.1.9",
|
|
70
70
|
"copyfiles": "2.4.1",
|
|
71
71
|
"fast-check": "^4.8.0",
|
|
72
72
|
"typescript": "6.0.3",
|
|
73
|
-
"vitest": "^4.1.
|
|
73
|
+
"vitest": "^4.1.9"
|
|
74
74
|
}
|
|
75
75
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
/**
|
|
16
|
-
* Verifies what spectral serializes for the inline-action example-perform fields
|
|
17
|
-
* on publish — the converted server component `prism component publish` sends.
|
|
18
|
-
*
|
|
19
|
-
* Scope is conversion output only: which fields land on the wire, with what values.
|
|
20
|
-
* It does not verify runtime dispatch (SAFE vs. UNSAFE vs. NOT_ALLOWED choosing
|
|
21
|
-
* which perform runs) — the safety flags are inert metadata spectral passes through
|
|
22
|
-
* verbatim, and the runner decides at execution time.
|
|
23
|
-
*/
|
|
24
|
-
const ejs_1 = require("ejs");
|
|
25
|
-
const path_1 = __importDefault(require("path"));
|
|
26
|
-
const vitest_1 = require("vitest");
|
|
27
|
-
const helpers_1 = require("../generators/componentManifest/helpers");
|
|
28
|
-
const index_1 = require("../index");
|
|
29
|
-
const display = (label) => ({ label, description: label });
|
|
30
|
-
// Three input shapes exercised on every permutation.
|
|
31
|
-
const connectionInput = (0, index_1.input)({ label: "Connection", type: "connection", required: true });
|
|
32
|
-
const structuredInput = (0, index_1.structuredObjectInput)({
|
|
33
|
-
label: "Name",
|
|
34
|
-
inputs: {
|
|
35
|
-
first: (0, index_1.input)({ type: "string", label: "First", required: true }),
|
|
36
|
-
last: (0, index_1.input)({ type: "string", label: "Last", required: true }),
|
|
37
|
-
},
|
|
38
|
-
});
|
|
39
|
-
const collectionInput = (0, index_1.input)({ label: "Tags", type: "string", collection: "valuelist" });
|
|
40
|
-
const sharedInputs = {
|
|
41
|
-
connection: connectionInput,
|
|
42
|
-
name: structuredInput,
|
|
43
|
-
tags: collectionInput,
|
|
44
|
-
};
|
|
45
|
-
const noop = () => __awaiter(void 0, void 0, void 0, function* () { return ({ data: null }); });
|
|
46
|
-
const echo = (_ctx, params) => __awaiter(void 0, void 0, void 0, function* () { return ({ data: params }); });
|
|
47
|
-
// Action permutations.
|
|
48
|
-
const testComponent = (0, index_1.component)({
|
|
49
|
-
key: "inline-action-testbed",
|
|
50
|
-
public: false,
|
|
51
|
-
display: Object.assign(Object.assign({}, display("Inline Action Testbed")), { iconPath: "icon.png" }),
|
|
52
|
-
actions: {
|
|
53
|
-
// A — no inline-calling fields.
|
|
54
|
-
plainAction: (0, index_1.action)({
|
|
55
|
-
display: display("Plain Action"),
|
|
56
|
-
inputs: sharedInputs,
|
|
57
|
-
perform: noop,
|
|
58
|
-
}),
|
|
59
|
-
// B — example perform + its safety flag.
|
|
60
|
-
examplePerformAction: (0, index_1.action)({
|
|
61
|
-
display: display("Example Perform Action"),
|
|
62
|
-
inputs: sharedInputs,
|
|
63
|
-
perform: noop,
|
|
64
|
-
examplePerform: echo,
|
|
65
|
-
examplePerformSafety: index_1.PerformSafety.SAFE,
|
|
66
|
-
}),
|
|
67
|
-
// C — real perform marked runnable.
|
|
68
|
-
runnablePerformAction: (0, index_1.action)({
|
|
69
|
-
display: display("Runnable Perform Action"),
|
|
70
|
-
inputs: sharedInputs,
|
|
71
|
-
perform: noop,
|
|
72
|
-
performSafety: index_1.PerformSafety.UNSAFE,
|
|
73
|
-
}),
|
|
74
|
-
// D — real perform marked not runnable.
|
|
75
|
-
notAllowedPerformAction: (0, index_1.action)({
|
|
76
|
-
display: display("Not Allowed Perform Action"),
|
|
77
|
-
inputs: sharedInputs,
|
|
78
|
-
perform: noop,
|
|
79
|
-
performSafety: index_1.PerformSafety.NOT_ALLOWED,
|
|
80
|
-
}),
|
|
81
|
-
},
|
|
82
|
-
});
|
|
83
|
-
// Converted actions are keyed by action key.
|
|
84
|
-
const actionsByKey = testComponent.actions;
|
|
85
|
-
(0, vitest_1.describe)("inline action calling: publish-wire conversion output", () => {
|
|
86
|
-
(0, vitest_1.it)("A — plain action: no inline-calling fields leak onto the wire", () => {
|
|
87
|
-
const a = actionsByKey.plainAction;
|
|
88
|
-
(0, vitest_1.expect)("examplePerform" in a).toBe(false);
|
|
89
|
-
(0, vitest_1.expect)(a.examplePerformSafety).toBeUndefined();
|
|
90
|
-
(0, vitest_1.expect)(a.performSafety).toBeUndefined();
|
|
91
|
-
});
|
|
92
|
-
(0, vitest_1.it)("B — example perform is wrapped (invokable) and its safety flag is carried", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
93
|
-
var _a;
|
|
94
|
-
const a = actionsByKey.examplePerformAction;
|
|
95
|
-
(0, vitest_1.expect)(typeof a.examplePerform).toBe("function");
|
|
96
|
-
(0, vitest_1.expect)(a.examplePerformSafety).toBe("SAFE");
|
|
97
|
-
// Only the field the author set is carried; no performSafety leaks in.
|
|
98
|
-
(0, vitest_1.expect)(a.performSafety).toBeUndefined();
|
|
99
|
-
// Wrapped fn is invokable and passes params through.
|
|
100
|
-
const result = yield ((_a = a.examplePerform) === null || _a === void 0 ? void 0 : _a.call(a, {}, { tags: ["x"] }));
|
|
101
|
-
(0, vitest_1.expect)(result.data.tags).toStrictEqual(["x"]);
|
|
102
|
-
}));
|
|
103
|
-
(0, vitest_1.it)("C — real-perform UNSAFE flag carried; no separate example perform", () => {
|
|
104
|
-
const a = actionsByKey.runnablePerformAction;
|
|
105
|
-
(0, vitest_1.expect)(a.performSafety).toBe("UNSAFE");
|
|
106
|
-
(0, vitest_1.expect)("examplePerform" in a).toBe(false);
|
|
107
|
-
(0, vitest_1.expect)(a.examplePerformSafety).toBeUndefined();
|
|
108
|
-
});
|
|
109
|
-
(0, vitest_1.it)("D — real-perform NOT_ALLOWED flag carried verbatim; no example perform", () => {
|
|
110
|
-
const a = actionsByKey.notAllowedPerformAction;
|
|
111
|
-
(0, vitest_1.expect)(a.performSafety).toBe("NOT_ALLOWED");
|
|
112
|
-
(0, vitest_1.expect)("examplePerform" in a).toBe(false);
|
|
113
|
-
(0, vitest_1.expect)(a.examplePerformSafety).toBeUndefined();
|
|
114
|
-
});
|
|
115
|
-
(0, vitest_1.it)("the three input shapes survive conversion on every permutation", () => {
|
|
116
|
-
for (const key of [
|
|
117
|
-
"plainAction",
|
|
118
|
-
"examplePerformAction",
|
|
119
|
-
"runnablePerformAction",
|
|
120
|
-
"notAllowedPerformAction",
|
|
121
|
-
]) {
|
|
122
|
-
const inputs = actionsByKey[key].inputs;
|
|
123
|
-
const byKey = Object.fromEntries(inputs.map((i) => [i.key, i]));
|
|
124
|
-
(0, vitest_1.expect)(byKey.connection.type).toBe("connection");
|
|
125
|
-
(0, vitest_1.expect)(byKey.name.type).toBe("structuredObject");
|
|
126
|
-
(0, vitest_1.expect)(byKey.name.inputs).toHaveLength(2); // nested children survived
|
|
127
|
-
(0, vitest_1.expect)(byKey.tags.collection).toBe("valuelist");
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
});
|
|
131
|
-
(0, vitest_1.describe)("inline action calling: component-manifest emit", () => {
|
|
132
|
-
const templatePath = path_1.default.join(__dirname, "../generators/componentManifest/templates/actions/action.ts.ejs");
|
|
133
|
-
const baseAction = {
|
|
134
|
-
typeInterface: "DoThing",
|
|
135
|
-
import: "doThing",
|
|
136
|
-
key: "doThing",
|
|
137
|
-
label: "Do Thing",
|
|
138
|
-
description: "Does a thing.",
|
|
139
|
-
inputs: [],
|
|
140
|
-
componentKey: "testbed",
|
|
141
|
-
};
|
|
142
|
-
const render = (extra) => (0, ejs_1.renderFile)(templatePath, { action: Object.assign(Object.assign({}, baseAction), extra), helpers: helpers_1.helpers, imports: {} });
|
|
143
|
-
(0, vitest_1.it)("emits both *Safety scalars when present", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
144
|
-
const out = yield render({
|
|
145
|
-
examplePerformSafety: "SAFE",
|
|
146
|
-
performSafety: "UNSAFE",
|
|
147
|
-
});
|
|
148
|
-
(0, vitest_1.expect)(out).toContain('examplePerformSafety: "SAFE"');
|
|
149
|
-
(0, vitest_1.expect)(out).toContain('performSafety: "UNSAFE"');
|
|
150
|
-
}));
|
|
151
|
-
(0, vitest_1.it)("emits a NOT_ALLOWED performSafety scalar verbatim", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
152
|
-
const out = yield render({ performSafety: "NOT_ALLOWED" });
|
|
153
|
-
(0, vitest_1.expect)(out).toContain('performSafety: "NOT_ALLOWED"');
|
|
154
|
-
}));
|
|
155
|
-
(0, vitest_1.it)("omits the *Safety scalars when absent (permutation A)", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
156
|
-
const out = yield render({});
|
|
157
|
-
(0, vitest_1.expect)(out).not.toContain("examplePerformSafety");
|
|
158
|
-
(0, vitest_1.expect)(out).not.toContain("performSafety");
|
|
159
|
-
}));
|
|
160
|
-
(0, vitest_1.it)("never emits an examplePerform stub (invoked via the server action, not the manifest)", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
161
|
-
const out = yield render({
|
|
162
|
-
examplePerformSafety: "SAFE",
|
|
163
|
-
performSafety: "UNSAFE",
|
|
164
|
-
});
|
|
165
|
-
(0, vitest_1.expect)(out).not.toContain("examplePerform:");
|
|
166
|
-
}));
|
|
167
|
-
});
|