mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-20 19:32:15 +00:00
refactor(editor): Move editor-ui and design-system to frontend dir (no-changelog) (#13564)
This commit is contained in:
30
packages/frontend/editor-ui/src/api/schemaPreview.ts
Normal file
30
packages/frontend/editor-ui/src/api/schemaPreview.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
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.replace('@n8n/', ''), 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