@prismatic-io/spectral 10.21.1-preview.1 → 10.21.1-preview.2
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/types.d.ts +1 -2
- package/dist/generators/componentManifest/createActions.js +5 -2
- package/dist/serverTypes/convertComponent.d.ts +1 -1
- package/dist/serverTypes/convertComponent.js +5 -2
- package/dist/serverTypes/index.d.ts +7 -1
- package/dist/serverTypes/inlineActionCalling.publishWire.spec.js +13 -12
- package/dist/serverTypes/performSafety.d.ts +4 -0
- package/dist/serverTypes/performSafety.js +12 -0
- package/dist/types/ActionDefinition.d.ts +3 -3
- package/dist/types/ActionDefinition.js +3 -3
- package/package.json +7 -7
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type { Action, Component, DataSource, Trigger, TriggerPayload } from "../../serverTypes";
|
|
1
|
+
import type { Action, Component, DataSource, PerformSafety, 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;
|
|
@@ -14,6 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.createActions = void 0;
|
|
16
16
|
const path_1 = __importDefault(require("path"));
|
|
17
|
+
const performSafety_1 = require("../../serverTypes/performSafety");
|
|
17
18
|
const createImport_1 = require("../utils/createImport");
|
|
18
19
|
const createTemplate_1 = require("../utils/createTemplate");
|
|
19
20
|
const createTypeInterface_1 = require("../utils/createTypeInterface");
|
|
@@ -45,8 +46,10 @@ const createActions = (_a) => __awaiter(void 0, [_a], void 0, function* ({ compo
|
|
|
45
46
|
const imports = (0, getImports_1.getImports)({ inputs });
|
|
46
47
|
return yield renderAction({
|
|
47
48
|
action: Object.assign(Object.assign(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 } : {})), (action.examplePerformSafety
|
|
48
|
-
? { examplePerformSafety: action.examplePerformSafety }
|
|
49
|
-
: {})), (action.performSafety
|
|
49
|
+
? { examplePerformSafety: (0, performSafety_1.fromServerPerformSafety)(action.examplePerformSafety) }
|
|
50
|
+
: {})), (action.performSafety
|
|
51
|
+
? { performSafety: (0, performSafety_1.fromServerPerformSafety)(action.performSafety) }
|
|
52
|
+
: {})), { componentKey: component.key }),
|
|
50
53
|
imports,
|
|
51
54
|
dryRun,
|
|
52
55
|
verbose,
|
|
@@ -29,7 +29,7 @@ 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;
|
|
32
|
+
export declare const convertAction: (actionKey: string, { inputs, perform, outputSchema, examplePerform, performSafety, examplePerformSafety, ...action }: ActionDefinition<Inputs, any, boolean, any>, hooks?: ComponentHooks) => ServerAction;
|
|
33
33
|
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
34
|
export declare const convertConnection: ({ inputs, ...connection }: ConnectionDefinition) => ServerConnection;
|
|
35
35
|
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>;
|
|
@@ -19,6 +19,7 @@ const omit_1 = __importDefault(require("lodash/omit"));
|
|
|
19
19
|
const types_1 = require("../types");
|
|
20
20
|
const PollingTriggerDefinition_1 = require("../types/PollingTriggerDefinition");
|
|
21
21
|
const perform_1 = require("./perform");
|
|
22
|
+
const performSafety_1 = require("./performSafety");
|
|
22
23
|
const isPlainObject = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
23
24
|
/** Auto-generated cleaner for structuredObject/dynamicObject containers.
|
|
24
25
|
* Recursively delegates to each child's clean function. Developers do not
|
|
@@ -226,10 +227,10 @@ const convertOutputSchema = (outputSchema) => {
|
|
|
226
227
|
};
|
|
227
228
|
};
|
|
228
229
|
const convertAction = (actionKey, _a, hooks) => {
|
|
229
|
-
var { inputs = {}, perform, outputSchema, examplePerform } = _a, action = __rest(_a, ["inputs", "perform", "outputSchema", "examplePerform"]);
|
|
230
|
+
var { inputs = {}, perform, outputSchema, examplePerform, performSafety, examplePerformSafety } = _a, action = __rest(_a, ["inputs", "perform", "outputSchema", "examplePerform", "performSafety", "examplePerformSafety"]);
|
|
230
231
|
const convertedInputs = Object.entries(inputs).map(([key, value]) => (0, exports.convertInput)(key, value));
|
|
231
232
|
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(Object.assign({}, action), { key: actionKey, inputs: convertedInputs, perform: (0, perform_1.createPerform)(perform, {
|
|
233
|
+
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, action), { key: actionKey, inputs: convertedInputs, perform: (0, perform_1.createPerform)(perform, {
|
|
233
234
|
inputCleaners,
|
|
234
235
|
errorHandler: hooks === null || hooks === void 0 ? void 0 : hooks.error,
|
|
235
236
|
}) }), (outputSchema ? { outputSchema: convertOutputSchema(outputSchema) } : {})), (examplePerform
|
|
@@ -239,6 +240,8 @@ const convertAction = (actionKey, _a, hooks) => {
|
|
|
239
240
|
errorHandler: hooks === null || hooks === void 0 ? void 0 : hooks.error,
|
|
240
241
|
}),
|
|
241
242
|
}
|
|
243
|
+
: {})), (performSafety ? { performSafety: (0, performSafety_1.toServerPerformSafety)(performSafety) } : {})), (examplePerformSafety
|
|
244
|
+
? { examplePerformSafety: (0, performSafety_1.toServerPerformSafety)(examplePerformSafety) }
|
|
242
245
|
: {}));
|
|
243
246
|
};
|
|
244
247
|
exports.convertAction = convertAction;
|
|
@@ -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;
|
|
@@ -62,6 +62,12 @@ export type ServerOutputSchema = {
|
|
|
62
62
|
schema: string;
|
|
63
63
|
}>;
|
|
64
64
|
};
|
|
65
|
+
/**
|
|
66
|
+
* On-the-wire form of the author-facing `PerformSafety`. The platform exposes
|
|
67
|
+
* the field as the `ActionPerformSafety` GraphQL enum, which serializes member
|
|
68
|
+
* names. Converted to and from the author-facing camelCase.
|
|
69
|
+
*/
|
|
70
|
+
export type PerformSafety = "SAFE" | "NOT_ALLOWED";
|
|
65
71
|
export type ActionLoggerFunction = (...args: unknown[]) => void;
|
|
66
72
|
export interface ActionLogger {
|
|
67
73
|
metric: ActionLoggerFunction;
|
|
@@ -18,8 +18,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
18
18
|
*
|
|
19
19
|
* Scope is conversion output only: which fields land on the wire, with what values.
|
|
20
20
|
* It does not verify runtime dispatch (SAFE vs. NOT_ALLOWED choosing
|
|
21
|
-
* which perform runs) — the safety flags are inert metadata
|
|
22
|
-
*
|
|
21
|
+
* which perform runs) — the safety flags are inert metadata, converted from the
|
|
22
|
+
* author-facing camelCase values to the platform's GraphQL enum names, and the
|
|
23
|
+
* runner decides at execution time.
|
|
23
24
|
*/
|
|
24
25
|
const ejs_1 = require("ejs");
|
|
25
26
|
const path_1 = __importDefault(require("path"));
|
|
@@ -106,7 +107,7 @@ const actionsByKey = testComponent.actions;
|
|
|
106
107
|
(0, vitest_1.expect)("examplePerform" in a).toBe(false);
|
|
107
108
|
(0, vitest_1.expect)(a.examplePerformSafety).toBeUndefined();
|
|
108
109
|
});
|
|
109
|
-
(0, vitest_1.it)("D — real-perform
|
|
110
|
+
(0, vitest_1.it)("D — real-perform notAllowed converts to NOT_ALLOWED; no example perform", () => {
|
|
110
111
|
const a = actionsByKey.notAllowedPerformAction;
|
|
111
112
|
(0, vitest_1.expect)(a.performSafety).toBe("NOT_ALLOWED");
|
|
112
113
|
(0, vitest_1.expect)("examplePerform" in a).toBe(false);
|
|
@@ -142,15 +143,15 @@ const actionsByKey = testComponent.actions;
|
|
|
142
143
|
const render = (extra) => (0, ejs_1.renderFile)(templatePath, { action: Object.assign(Object.assign({}, baseAction), extra), helpers: helpers_1.helpers, imports: {} });
|
|
143
144
|
(0, vitest_1.it)("emits both *Safety scalars when present", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
144
145
|
const out = yield render({
|
|
145
|
-
examplePerformSafety: "
|
|
146
|
-
performSafety: "
|
|
146
|
+
examplePerformSafety: "safe",
|
|
147
|
+
performSafety: "notAllowed",
|
|
147
148
|
});
|
|
148
|
-
(0, vitest_1.expect)(out).toContain('examplePerformSafety: "
|
|
149
|
-
(0, vitest_1.expect)(out).toContain('performSafety: "
|
|
149
|
+
(0, vitest_1.expect)(out).toContain('examplePerformSafety: "safe"');
|
|
150
|
+
(0, vitest_1.expect)(out).toContain('performSafety: "notAllowed"');
|
|
150
151
|
}));
|
|
151
|
-
(0, vitest_1.it)("emits a
|
|
152
|
-
const out = yield render({ performSafety: "
|
|
153
|
-
(0, vitest_1.expect)(out).toContain('performSafety: "
|
|
152
|
+
(0, vitest_1.it)("emits a notAllowed performSafety scalar", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
153
|
+
const out = yield render({ performSafety: "notAllowed" });
|
|
154
|
+
(0, vitest_1.expect)(out).toContain('performSafety: "notAllowed"');
|
|
154
155
|
}));
|
|
155
156
|
(0, vitest_1.it)("omits the *Safety scalars when absent (permutation A)", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
156
157
|
const out = yield render({});
|
|
@@ -159,8 +160,8 @@ const actionsByKey = testComponent.actions;
|
|
|
159
160
|
}));
|
|
160
161
|
(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
162
|
const out = yield render({
|
|
162
|
-
examplePerformSafety: "
|
|
163
|
-
performSafety: "
|
|
163
|
+
examplePerformSafety: "safe",
|
|
164
|
+
performSafety: "notAllowed",
|
|
164
165
|
});
|
|
165
166
|
(0, vitest_1.expect)(out).not.toContain("examplePerform:");
|
|
166
167
|
}));
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { PerformSafety } from "../types";
|
|
2
|
+
import type { PerformSafety as ServerPerformSafety } from ".";
|
|
3
|
+
export declare const toServerPerformSafety: (value: PerformSafety) => ServerPerformSafety;
|
|
4
|
+
export declare const fromServerPerformSafety: (value: ServerPerformSafety) => PerformSafety;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.fromServerPerformSafety = exports.toServerPerformSafety = void 0;
|
|
7
|
+
const camelCase_1 = __importDefault(require("lodash/camelCase"));
|
|
8
|
+
const snakeCase_1 = __importDefault(require("lodash/snakeCase"));
|
|
9
|
+
const toServerPerformSafety = (value) => (0, snakeCase_1.default)(value).toUpperCase();
|
|
10
|
+
exports.toServerPerformSafety = toServerPerformSafety;
|
|
11
|
+
const fromServerPerformSafety = (value) => (0, camelCase_1.default)(value);
|
|
12
|
+
exports.fromServerPerformSafety = fromServerPerformSafety;
|
|
@@ -6,11 +6,11 @@ import type { ConfigVarResultCollection, Inputs } from "./Inputs";
|
|
|
6
6
|
import type { OutputSchema } from "./OutputSchema";
|
|
7
7
|
/**
|
|
8
8
|
* Whether a perform is safe to invoke inline (to populate reference data in the Prismatic UI):
|
|
9
|
-
* `
|
|
9
|
+
* `safe` to run as-is, `notAllowed` to opt out.
|
|
10
10
|
*/
|
|
11
11
|
export declare const PerformSafety: {
|
|
12
|
-
readonly SAFE: "
|
|
13
|
-
readonly NOT_ALLOWED: "
|
|
12
|
+
readonly SAFE: "safe";
|
|
13
|
+
readonly NOT_ALLOWED: "notAllowed";
|
|
14
14
|
};
|
|
15
15
|
export type PerformSafety = (typeof PerformSafety)[keyof typeof PerformSafety];
|
|
16
16
|
/**
|
|
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.PerformSafety = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Whether a perform is safe to invoke inline (to populate reference data in the Prismatic UI):
|
|
6
|
-
* `
|
|
6
|
+
* `safe` to run as-is, `notAllowed` to opt out.
|
|
7
7
|
*/
|
|
8
8
|
exports.PerformSafety = {
|
|
9
|
-
SAFE: "
|
|
10
|
-
NOT_ALLOWED: "
|
|
9
|
+
SAFE: "safe",
|
|
10
|
+
NOT_ALLOWED: "notAllowed",
|
|
11
11
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prismatic-io/spectral",
|
|
3
|
-
"version": "10.21.1-preview.
|
|
3
|
+
"version": "10.21.1-preview.2",
|
|
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.1",
|
|
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": "^
|
|
65
|
+
"@types/node": "^26.0.0",
|
|
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
|
}
|