@prismatic-io/spectral 10.8.1 → 10.10.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/cli.js +1 -1
- package/dist/generators/cniComponentManifest/index.js +1 -1
- package/dist/generators/cniComponentManifest/types.d.ts +1 -0
- package/dist/generators/componentManifest/createConnections.js +1 -0
- package/dist/generators/componentManifest/createDataSources.js +1 -0
- package/dist/generators/componentManifest/createTriggers.js +1 -0
- package/dist/generators/componentManifest/templates/connections/connection.ts.ejs +12 -1
- package/dist/generators/componentManifest/templates/dataSources/dataSource.ts.ejs +12 -1
- package/dist/generators/componentManifest/templates/triggers/trigger.ts.ejs +13 -2
- package/dist/index.js +4 -1
- package/dist/serverTypes/asyncContext.d.ts +9 -0
- package/dist/serverTypes/asyncContext.js +32 -1
- package/dist/types/IntegrationDefinition.d.ts +2 -0
- package/dist/util.js +0 -2
- package/package.json +1 -1
|
@@ -130,6 +130,6 @@ const runMain = (process) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
130
130
|
sourceDir: templatesDir,
|
|
131
131
|
destinationDir,
|
|
132
132
|
});
|
|
133
|
-
console.info(`Component manifest created successfully for ${component.display.label} in ${destinationDir}
|
|
133
|
+
console.info(`Component manifest created successfully for ${component.display.label} in ${destinationDir}!\nEnsure that you update your componentRegistry file accordingly.`);
|
|
134
134
|
});
|
|
135
135
|
exports.runMain = runMain;
|
|
@@ -138,7 +138,7 @@ const fetchComponentDataForManifest = (_a) => __awaiter(void 0, [_a], void 0, fu
|
|
|
138
138
|
};
|
|
139
139
|
}
|
|
140
140
|
catch (error) {
|
|
141
|
-
throw new Error(
|
|
141
|
+
throw new Error(error instanceof Error ? error.message : String(error));
|
|
142
142
|
}
|
|
143
143
|
});
|
|
144
144
|
exports.fetchComponentDataForManifest = fetchComponentDataForManifest;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
<%- include('../partials/generatedHeader.ejs') -%>
|
|
2
2
|
import { connectionConfigVar } from "@prismatic-io/spectral/dist/integration";
|
|
3
|
+
import {
|
|
4
|
+
findUserDefinedComponentKey,
|
|
5
|
+
requireIntegrationContext,
|
|
6
|
+
} from "@prismatic-io/spectral/dist/serverTypes";
|
|
3
7
|
<%- include('../partials/imports.ejs', { imports, helpers }) %>
|
|
4
8
|
|
|
5
9
|
export interface <%= connection.typeInterface %>Values {
|
|
@@ -44,7 +48,14 @@ export const <%= helpers.camelCase(connection.componentKey) %><%= helpers.capita
|
|
|
44
48
|
dataType: "connection",
|
|
45
49
|
stableKey,
|
|
46
50
|
connection: {
|
|
47
|
-
component
|
|
51
|
+
get component() {
|
|
52
|
+
const context = requireIntegrationContext();
|
|
53
|
+
return findUserDefinedComponentKey(
|
|
54
|
+
"<%= connection.componentKey %>",
|
|
55
|
+
<%= connection.componentIsPublic %>,
|
|
56
|
+
context.componentRegistry,
|
|
57
|
+
);
|
|
58
|
+
},
|
|
48
59
|
key: "<%= helpers.camelCase(connection.key) %>",
|
|
49
60
|
values,
|
|
50
61
|
},
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
<%- include('../partials/generatedHeader.ejs') -%>
|
|
2
2
|
import { dataSourceConfigVar } from "@prismatic-io/spectral/dist/integration";
|
|
3
|
+
import {
|
|
4
|
+
findUserDefinedComponentKey,
|
|
5
|
+
requireIntegrationContext,
|
|
6
|
+
} from "@prismatic-io/spectral/dist/serverTypes";
|
|
3
7
|
<%- include('../partials/imports.ejs', { imports, helpers }) %>
|
|
4
8
|
|
|
5
9
|
export interface <%= dataSource.typeInterface %>Values {
|
|
@@ -43,7 +47,14 @@ export const <%= helpers.camelCase(dataSource.componentKey) %><%= helpers.capita
|
|
|
43
47
|
return dataSourceConfigVar({
|
|
44
48
|
stableKey,
|
|
45
49
|
dataSource: {
|
|
46
|
-
component
|
|
50
|
+
get component() {
|
|
51
|
+
const context = requireIntegrationContext();
|
|
52
|
+
return findUserDefinedComponentKey(
|
|
53
|
+
"<%= dataSource.componentKey %>",
|
|
54
|
+
<%= dataSource.componentIsPublic %>,
|
|
55
|
+
context.componentRegistry,
|
|
56
|
+
);
|
|
57
|
+
},
|
|
47
58
|
key: "<%= helpers.camelCase(dataSource.key) %>",
|
|
48
59
|
values,
|
|
49
60
|
},
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
<%- include('../partials/generatedHeader.ejs') -%>
|
|
2
|
-
<%- include('../partials/imports.ejs', { imports, helpers }) %>
|
|
3
2
|
import { ConfigVarExpression } from "@prismatic-io/spectral";
|
|
3
|
+
import {
|
|
4
|
+
findUserDefinedComponentKey,
|
|
5
|
+
requireIntegrationContext,
|
|
6
|
+
} from "@prismatic-io/spectral/dist/serverTypes";
|
|
7
|
+
<%- include('../partials/imports.ejs', { imports, helpers }) %>
|
|
4
8
|
|
|
5
9
|
export interface <%= trigger.typeInterface %>Values {
|
|
6
10
|
<%- include('../partials/performArgs.ejs', { inputs: trigger.inputs, helpers }) -%>
|
|
@@ -35,7 +39,14 @@ export const <%= helpers.camelCase(trigger.componentKey) %><%= helpers.capitaliz
|
|
|
35
39
|
<% }); -%>
|
|
36
40
|
}) => {
|
|
37
41
|
return {
|
|
38
|
-
component
|
|
42
|
+
get component() {
|
|
43
|
+
const context = requireIntegrationContext();
|
|
44
|
+
return findUserDefinedComponentKey(
|
|
45
|
+
"<%= trigger.componentKey %>",
|
|
46
|
+
<%= trigger.componentIsPublic %>,
|
|
47
|
+
context.componentRegistry,
|
|
48
|
+
);
|
|
49
|
+
},
|
|
39
50
|
key: "<%= trigger.key %>",
|
|
40
51
|
values,
|
|
41
52
|
} as const;
|
package/dist/index.js
CHANGED
|
@@ -25,6 +25,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
25
25
|
exports.testing = exports.util = exports.componentManifests = exports.oauth2Connection = exports.onPremConnection = exports.connection = exports.input = exports.dataSource = exports.pollingTrigger = exports.trigger = exports.action = exports.component = exports.componentManifest = exports.organizationActivatedConnection = exports.customerActivatedConnection = exports.connectionConfigVar = exports.dataSourceConfigVar = exports.configVar = exports.configPage = exports.flow = exports.integration = void 0;
|
|
26
26
|
const convertComponent_1 = require("./serverTypes/convertComponent");
|
|
27
27
|
const convertIntegration_1 = require("./serverTypes/convertIntegration");
|
|
28
|
+
const serverTypes_1 = require("./serverTypes");
|
|
28
29
|
/**
|
|
29
30
|
* This function creates a code-native integration object that can be
|
|
30
31
|
* imported into Prismatic. For information on using this function to
|
|
@@ -36,7 +37,9 @@ const convertIntegration_1 = require("./serverTypes/convertIntegration");
|
|
|
36
37
|
*/
|
|
37
38
|
const integration = (definition) => {
|
|
38
39
|
var _a;
|
|
39
|
-
const integrationDefinition = (0,
|
|
40
|
+
const integrationDefinition = (0, serverTypes_1.runWithIntegrationContext)(definition, () => {
|
|
41
|
+
return (0, convertIntegration_1.convertIntegration)(definition);
|
|
42
|
+
});
|
|
40
43
|
if (((_a = process.env) === null || _a === void 0 ? void 0 : _a.DEBUG) === "true") {
|
|
41
44
|
console.info(integrationDefinition.codeNativeIntegrationYAML);
|
|
42
45
|
}
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
import { ComponentRegistry, IntegrationDefinition } from "../types";
|
|
1
2
|
import type { ActionContext } from "../types/ActionPerformFunction";
|
|
2
3
|
export declare function runWithContext<T>(context: ActionContext, fn: () => T | Promise<T>): T | Promise<T>;
|
|
3
4
|
export declare function requireContext(): ActionContext;
|
|
5
|
+
export declare function runWithIntegrationContext<T extends IntegrationDefinition, U>(context: T, fn: () => U): U;
|
|
6
|
+
export declare function requireIntegrationContext<T extends IntegrationDefinition>(): T;
|
|
7
|
+
type GetUserDefinedKeyByComponentKey<K extends string, T extends ComponentRegistry, TPublic extends boolean> = keyof T extends infer UserKey ? UserKey extends keyof T ? T[UserKey] extends {
|
|
8
|
+
key: string;
|
|
9
|
+
public: boolean;
|
|
10
|
+
} ? T[UserKey]["key"] extends K ? T[UserKey]["public"] extends TPublic ? UserKey : never : never : never : never : never;
|
|
11
|
+
export declare const findUserDefinedComponentKey: <K extends string, T extends ComponentRegistry, TPublic extends boolean>(componentKey: K, isPublic: TPublic, registry?: T) => GetUserDefinedKeyByComponentKey<K, T, TPublic>;
|
|
12
|
+
export {};
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.findUserDefinedComponentKey = void 0;
|
|
3
4
|
exports.runWithContext = runWithContext;
|
|
4
5
|
exports.requireContext = requireContext;
|
|
6
|
+
exports.runWithIntegrationContext = runWithIntegrationContext;
|
|
7
|
+
exports.requireIntegrationContext = requireIntegrationContext;
|
|
5
8
|
// Only import async_hooks in Node.js environments
|
|
6
9
|
const asyncHooks = typeof window === "undefined" ? require("node:async_hooks") : null;
|
|
7
10
|
const actionContextStorage = asyncHooks ? new asyncHooks.AsyncLocalStorage() : null;
|
|
11
|
+
const integrationContextStorage = asyncHooks ? new asyncHooks.AsyncLocalStorage() : null;
|
|
8
12
|
function runWithContext(context, fn) {
|
|
9
13
|
if (!actionContextStorage) {
|
|
10
|
-
// This shouldn't be running in a browser environment anyway.
|
|
11
14
|
return fn();
|
|
12
15
|
}
|
|
13
16
|
return actionContextStorage.run(context, fn);
|
|
@@ -19,3 +22,31 @@ function requireContext() {
|
|
|
19
22
|
}
|
|
20
23
|
return context;
|
|
21
24
|
}
|
|
25
|
+
function runWithIntegrationContext(context, fn) {
|
|
26
|
+
if (!integrationContextStorage) {
|
|
27
|
+
console.warn("Creating integration without context. This may result in errors when generating component manifests.");
|
|
28
|
+
return fn();
|
|
29
|
+
}
|
|
30
|
+
return integrationContextStorage.run(context, fn);
|
|
31
|
+
}
|
|
32
|
+
function requireIntegrationContext() {
|
|
33
|
+
const context = integrationContextStorage.getStore();
|
|
34
|
+
if (!context) {
|
|
35
|
+
console.trace();
|
|
36
|
+
throw new Error("IntegrationContext not found. Ensure this code is wrapped via runWithIntegrationContext.");
|
|
37
|
+
}
|
|
38
|
+
return context;
|
|
39
|
+
}
|
|
40
|
+
const findUserDefinedComponentKey = (componentKey, isPublic, registry) => {
|
|
41
|
+
if (!registry) {
|
|
42
|
+
throw new Error("Error locating component registry. Is there a component registry defined on your integration?");
|
|
43
|
+
}
|
|
44
|
+
const userKey = Object.keys(registry).find((userKey) => {
|
|
45
|
+
return registry[userKey].key === componentKey && registry[userKey].public === isPublic;
|
|
46
|
+
});
|
|
47
|
+
if (!userKey) {
|
|
48
|
+
throw new Error(`Error locating component ${componentKey} with custom key ${userKey} in the component registry. Is this component properly installed with a correct public/private setting?`);
|
|
49
|
+
}
|
|
50
|
+
return userKey;
|
|
51
|
+
};
|
|
52
|
+
exports.findUserDefinedComponentKey = findUserDefinedComponentKey;
|
|
@@ -99,6 +99,8 @@ export interface Flow<TTriggerPayload extends TriggerPayload = TriggerPayload> {
|
|
|
99
99
|
preprocessFlowConfig?: PreprocessFlowConfig;
|
|
100
100
|
/** Value that specifies whether this flow is synchronous. @default `false` */
|
|
101
101
|
isSynchronous?: boolean;
|
|
102
|
+
/** Value that specifies whether this flow is an AI agent flow on the integrations MCP server. @default `false` */
|
|
103
|
+
isAgentFlow?: boolean;
|
|
102
104
|
/** Retry Configuration for this flow. */
|
|
103
105
|
retryConfig?: RetryConfig;
|
|
104
106
|
/** Queue Configuration for this flow. */
|
package/dist/util.js
CHANGED
|
@@ -451,8 +451,6 @@ const isConnection = (value) => {
|
|
|
451
451
|
/**
|
|
452
452
|
* This function returns true if `value` resembles the shape of JSON, and false otherwise.
|
|
453
453
|
*
|
|
454
|
-
* - `isJSON(undefined) will return `false`
|
|
455
|
-
* - `isJSON(null) will return `true`
|
|
456
454
|
* - `isJSON("") will return `false`
|
|
457
455
|
* - `isJSON(5) will return `true`
|
|
458
456
|
* - `isJSON('{"name":"John", "age":30, "car":null}') will return `true`
|
package/package.json
CHANGED