mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 18:41:14 +00:00
feat(editor): Display schema preview for unexecuted nodes (#12901)
This commit is contained in:
28
packages/editor-ui/src/api/schemaPreview.ts
Normal file
28
packages/editor-ui/src/api/schemaPreview.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { request } from '@/utils/apiUtils';
|
||||
import type { JSONSchema7 } from 'json-schema';
|
||||
|
||||
export type GetSchemaPreviewOptions = {
|
||||
nodeType: string;
|
||||
version: number;
|
||||
resource?: string;
|
||||
operation?: string;
|
||||
};
|
||||
|
||||
const padVersion = (version: number) => {
|
||||
return version.toString().split('.').concat(['0', '0']).slice(0, 3).join('.');
|
||||
};
|
||||
|
||||
export const getSchemaPreview = async (
|
||||
baseUrl: string,
|
||||
options: GetSchemaPreviewOptions,
|
||||
): Promise<JSONSchema7> => {
|
||||
const { nodeType, version, resource, operation } = options;
|
||||
const versionString = padVersion(version);
|
||||
const path = ['schemas', nodeType, versionString, resource, operation].filter(Boolean).join('/');
|
||||
return await request({
|
||||
method: 'GET',
|
||||
baseURL: baseUrl,
|
||||
endpoint: `${path}.json`,
|
||||
withCredentials: false,
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user