@prismatic-io/spectral 10.6.7 → 10.8.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.
@@ -123,7 +123,7 @@ const fetchComponentDataForManifest = (_a) => __awaiter(void 0, [_a], void 0, fu
123
123
  };
124
124
  });
125
125
  return {
126
- key: componentKey,
126
+ key: component.key,
127
127
  signature: component.signature,
128
128
  public: !isPrivate,
129
129
  display: {
@@ -49,6 +49,7 @@ const createTriggers = (_a) => __awaiter(void 0, [_a], void 0, function* ({ comp
49
49
  label: trigger.display.description,
50
50
  description: trigger.display.description,
51
51
  inputs,
52
+ componentKey: component.key,
52
53
  },
53
54
  dryRun,
54
55
  imports,
@@ -17,7 +17,7 @@ export const <%= action.import %> = {
17
17
  values: <%= action.typeInterface %>Values
18
18
  ): Promise<TReturn> => {
19
19
  const context = requireContext();
20
- return await context.components.<%= helpers.camelCase(action.componentKey) %>.<%= action.key %>({ ...values }) as TReturn;
20
+ return await context.components.<%= helpers.camelCase(action.componentKey) %>.<%= action.import %>({ ...values }) as TReturn;
21
21
  },
22
22
  inputs: {
23
23
  <%- include('../partials/inputs.ejs', { inputs: action.inputs, helpers }) -%>
@@ -10,6 +10,7 @@ export interface <%= connection.typeInterface %>Values {
10
10
  * <%= connection.label %>
11
11
  *
12
12
  * @comments <%- connection.comments %>
13
+ * This object is used to support type hinting.
13
14
  */
14
15
  export const <%= connection.import %> = {
15
16
  key: "<%= connection.key %>",
@@ -27,7 +28,7 @@ export const <%= connection.import %> = {
27
28
  /**
28
29
  * <%= connection.label %> Connection Helper
29
30
  *
30
- * @comments Helper for direct usage in config wizard definitions.
31
+ * @comments This wrapper function can be used directly in config wizard definitions.
31
32
  */
32
33
  export const <%= helpers.camelCase(connection.componentKey) %><%= helpers.capitalizeFirstLetter(helpers.camelCase(connection.key)) %> = (
33
34
  stableKey: string,
@@ -10,6 +10,7 @@ export interface <%= dataSource.typeInterface %>Values {
10
10
  * <%= dataSource.label %>
11
11
  *
12
12
  * @description <%- dataSource.description %>
13
+ * This object is used to support type hinting.
13
14
  */
14
15
  export const <%= dataSource.import %> = {
15
16
  key: "<%= dataSource.key %>",
@@ -25,7 +26,7 @@ export const <%= dataSource.import %> = {
25
26
  /**
26
27
  * <%= dataSource.label %> DataSource Helper
27
28
  *
28
- * @comments Helper for direct usage in config wizard definitions.
29
+ * @comments This wrapper function can be used directly in config wizard definitions.
29
30
  */
30
31
  export const <%= helpers.camelCase(dataSource.componentKey) %><%= helpers.capitalizeFirstLetter(helpers.camelCase(dataSource.key)) %> = (
31
32
  stableKey: string,
@@ -1,5 +1,6 @@
1
1
  <%- include('../partials/generatedHeader.ejs') -%>
2
2
  <%- include('../partials/imports.ejs', { imports, helpers }) %>
3
+ import { ConfigVarExpression } from "@prismatic-io/spectral";
3
4
 
4
5
  export interface <%= trigger.typeInterface %>Values {
5
6
  <%- include('../partials/performArgs.ejs', { inputs: trigger.inputs, helpers }) -%>
@@ -9,6 +10,7 @@ export interface <%= trigger.typeInterface %>Values {
9
10
  * <%= trigger.label %>
10
11
  *
11
12
  * @description <%- trigger.description %>
13
+ * This object is used to support type hinting.
12
14
  */
13
15
  export const <%= trigger.import %> = {
14
16
  key: "<%= trigger.key %>",
@@ -18,4 +20,23 @@ export const <%= trigger.import %> = {
18
20
  inputs: {
19
21
  <%- include('../partials/inputs.ejs', { inputs: trigger.inputs, helpers }) -%>
20
22
  }
21
- } as const;
23
+ } as const;
24
+
25
+ /**
26
+ * <%= trigger.label %> Trigger Helper
27
+ *
28
+ * @comments This wrapper function can be used directly in flow definitions.
29
+ */
30
+ export const <%= helpers.camelCase(trigger.componentKey) %><%= helpers.capitalizeFirstLetter(trigger.import) %> = (values: {
31
+ <% trigger.inputs.forEach((input) => { -%>
32
+ <%- helpers.formatType(input.key) %><%= input.required ? "" : "?" %>: ({
33
+ value: <%- input.valueType.type ? input.valueType.type : input.valueType %>;
34
+ } | ConfigVarExpression);
35
+ <% }); -%>
36
+ }) => {
37
+ return {
38
+ component: "<%= helpers.camelCase(trigger.componentKey) %>",
39
+ key: "<%= trigger.key %>",
40
+ values,
41
+ } as const;
42
+ };
@@ -82,6 +82,7 @@ const convertAction = (actionKey, _a, hooks) => {
82
82
  const convertTrigger = (triggerKey, trigger, hooks) => {
83
83
  var _a;
84
84
  const { onInstanceDeploy, onInstanceDelete } = trigger;
85
+ const webhookLifecycleHandlers = "webhookLifecycleHandlers" in trigger ? trigger.webhookLifecycleHandlers : undefined;
85
86
  const inputs = (_a = trigger.inputs) !== null && _a !== void 0 ? _a : {};
86
87
  const isPollingTrigger = (0, PollingTriggerDefinition_1.isPollingTriggerDefinition)(trigger);
87
88
  const triggerInputKeys = Object.keys(inputs);
@@ -119,11 +120,11 @@ const convertTrigger = (triggerKey, trigger, hooks) => {
119
120
  errorHandler: hooks === null || hooks === void 0 ? void 0 : hooks.error,
120
121
  });
121
122
  }
122
- const result = Object.assign(Object.assign({}, trigger), { key: triggerKey, inputs: convertedTriggerInputs.concat(convertedActionInputs), perform: performToUse, scheduleSupport, synchronousResponseSupport: "synchronousResponseSupport" in trigger
123
+ const result = Object.assign(Object.assign(Object.assign({}, trigger), { key: triggerKey, inputs: convertedTriggerInputs.concat(convertedActionInputs), perform: performToUse, scheduleSupport, synchronousResponseSupport: "synchronousResponseSupport" in trigger
123
124
  ? trigger.synchronousResponseSupport
124
125
  : scheduleSupport === "invalid"
125
126
  ? "valid"
126
- : "invalid" });
127
+ : "invalid" }), (isPollingTrigger ? { isPollingTrigger: true } : {}));
127
128
  if (onInstanceDeploy) {
128
129
  result.onInstanceDeploy = (0, perform_1.createPerform)(onInstanceDeploy, {
129
130
  inputCleaners: triggerInputCleaners,
@@ -138,7 +139,19 @@ const convertTrigger = (triggerKey, trigger, hooks) => {
138
139
  });
139
140
  result.hasOnInstanceDelete = true;
140
141
  }
141
- const { pollAction, triggerType } = result, resultTrigger = __rest(result, ["pollAction", "triggerType"]);
142
+ if (webhookLifecycleHandlers) {
143
+ result.webhookCreate = (0, perform_1.createPerform)(webhookLifecycleHandlers.create, {
144
+ inputCleaners: triggerInputCleaners,
145
+ errorHandler: hooks === null || hooks === void 0 ? void 0 : hooks.error,
146
+ });
147
+ result.webhookDelete = (0, perform_1.createPerform)(webhookLifecycleHandlers.delete, {
148
+ inputCleaners: triggerInputCleaners,
149
+ errorHandler: hooks === null || hooks === void 0 ? void 0 : hooks.error,
150
+ });
151
+ result.hasWebhookCreateFunction = true;
152
+ result.hasWebhookDeleteFunction = true;
153
+ }
154
+ const { pollAction, triggerType, webhookLifecycleHandlers: _ } = result, resultTrigger = __rest(result, ["pollAction", "triggerType", "webhookLifecycleHandlers"]);
142
155
  return resultTrigger;
143
156
  };
144
157
  exports.convertTrigger = convertTrigger;
@@ -287,13 +287,8 @@ const flowUsesWrapperTrigger = (flow) => {
287
287
  };
288
288
  const convertFlowSchemas = (flowKey, schemas) => {
289
289
  return Object.entries(schemas).reduce((acc, [key, value]) => {
290
- acc[key] = {
291
- title: value.title || `${flowKey}-${key}`,
292
- type: "object",
293
- $comment: value.$comment,
294
- properties: value.properties,
295
- $schema: value.$schema || types_1.DEFAULT_JSON_SCHEMA_VERSION,
296
- };
290
+ var _a;
291
+ acc[key] = Object.assign({ title: value.title || `${flowKey}-${key}`, type: "object", $comment: value.$comment, properties: value.properties, $schema: value.$schema || types_1.DEFAULT_JSON_SCHEMA_VERSION }, (((_a = value.required) === null || _a === void 0 ? void 0 : _a.length) ? { required: value.required } : {}));
297
292
  return acc;
298
293
  }, {});
299
294
  };
@@ -143,10 +143,19 @@ export interface Trigger {
143
143
  hasOnInstanceDeploy?: boolean;
144
144
  onInstanceDelete?: TriggerEventFunction;
145
145
  hasOnInstanceDelete?: boolean;
146
+ webhookLifecycleHandlers?: {
147
+ create: TriggerEventFunction;
148
+ delete: TriggerEventFunction;
149
+ };
150
+ webhookCreate?: TriggerEventFunction;
151
+ hasWebhookCreateFunction?: boolean;
152
+ webhookDelete?: TriggerEventFunction;
153
+ hasWebhookDeleteFunction?: boolean;
146
154
  scheduleSupport: TriggerOptionChoice;
147
155
  synchronousResponseSupport: TriggerOptionChoice;
148
156
  examplePayload?: unknown;
149
157
  isCommonTrigger?: boolean;
158
+ isPollingTrigger?: boolean;
150
159
  }
151
160
  export interface DataSourceContext<TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection> {
152
161
  logger: ActionLogger;
@@ -1,6 +1,6 @@
1
1
  interface FlowSchemaProperty {
2
2
  description: string;
3
- type: string;
3
+ type?: string;
4
4
  }
5
5
  export declare const DEFAULT_JSON_SCHEMA_VERSION = "https://json-schema.org/draft/2020-12/schema";
6
6
  /** Flow definition schemas require fewer fields than the actual FlowSchema
@@ -10,6 +10,7 @@ export type FlowDefinitionFlowSchema = {
10
10
  $comment?: string;
11
11
  $schema?: string;
12
12
  properties: Record<string, FlowSchemaProperty>;
13
+ required?: string[];
13
14
  };
14
15
  export interface FlowSchema {
15
16
  title: string;
@@ -17,6 +18,7 @@ export interface FlowSchema {
17
18
  $schema: string;
18
19
  type: string;
19
20
  properties: Record<string, FlowSchemaProperty>;
21
+ required?: string[];
20
22
  }
21
23
  export interface FlowSchemas {
22
24
  [key: string]: {
@@ -26,6 +26,13 @@ export interface TriggerDefinition<TInputs extends Inputs = Inputs, TConfigVars
26
26
  * https://prismatic.io/docs/custom-connectors/triggers/#instance-deploy-and-delete-events-for-triggers
27
27
  */
28
28
  onInstanceDelete?: TriggerEventFunction<TInputs, TConfigVars>;
29
+ /** Optional webhook lifecycle handlers for create, read, and delete operations. */
30
+ webhookLifecycleHandlers?: {
31
+ /** Function to execute to configure a webhook. */
32
+ create: TriggerEventFunction<TInputs, TConfigVars>;
33
+ /** Function to execute for webhook teardown. */
34
+ delete: TriggerEventFunction<TInputs, TConfigVars>;
35
+ };
29
36
  /**
30
37
  * The inputs to present a low-code integration builder. Values of these inputs
31
38
  * are passed to the `perform` function when the trigger is invoked.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prismatic-io/spectral",
3
- "version": "10.6.7",
3
+ "version": "10.8.0",
4
4
  "description": "Utility library for building Prismatic connectors and code-native integrations",
5
5
  "keywords": ["prismatic"],
6
6
  "main": "dist/index.js",
@@ -38,7 +38,7 @@
38
38
  },
39
39
  "files": ["dist/"],
40
40
  "dependencies": {
41
- "axios": "1.8.3",
41
+ "axios": "1.12.2",
42
42
  "axios-retry": "4.5.0",
43
43
  "date-fns": "2.30.0",
44
44
  "ejs": "^3.1.10",