| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- /**
- * @node ocr-limitations
- * @name OCR Limitations
- * @category ocr
- * @version 1.0.1
- * @description Get user limitations and quotas for OCR API
- * @icon info
- */
- const configSchema = {
- type: 'object',
- properties: {
- baseUrl: {
- type: 'string',
- title: 'API Base URL',
- default: 'http://localhost:3000',
- description: 'Base URL of the OCR API'
- },
- credentialId: {
- type: 'string',
- title: 'Credential',
- description: 'Bearer or API Key credential for authentication',
- dynamicOptions: {
- source: 'credentials',
- filter: { type: 'api_key' }
- }
- }
- },
- required: ['baseUrl']
- };
- const inputSchema = {
- type: 'object',
- properties: {}
- };
- const outputSchema = {
- type: 'object',
- properties: {
- limitations: {
- type: 'object',
- properties: {
- allowedFileTypes: {
- type: 'array',
- items: { type: 'string' }
- },
- maxFileSizeMb: { type: 'number' },
- maxPdfPages: { type: 'number' },
- maxConcurrentJobs: { type: 'number' },
- dailyLimit: { type: 'number' },
- monthlyLimit: { type: 'number' }
- }
- }
- }
- };
- const outputs = [
- { name: 'main', displayName: 'Limitations', type: 'object', color: '#14b8a6' }
- ];
- module.exports = {
- configSchema,
- inputSchema,
- outputSchema,
- outputs,
- async execute(config, input, context) {
- const baseUrl = (config.baseUrl || 'http://localhost:3000').replace(/\/$/, '');
- const headers = {};
- if (config.credentialId) {
- const auth = smartbotic.credentials.get(config.credentialId);
- if (!auth.success) {
- throw new Error(`Failed to load credential: ${auth.error}`);
- }
- headers[auth.headerName] = auth.headerValue;
- }
- smartbotic.log.info(`OCR Get Limitations from ${baseUrl}`);
- const response = smartbotic.http.request({
- method: 'GET',
- url: `${baseUrl}/api/ocr/limitations`,
- headers: headers,
- timeout: 30000
- });
- if (response.status < 200 || response.status >= 300) {
- const errorMsg = typeof response.data === 'string' ? response.data : JSON.stringify(response.data);
- if (response.status === 401 && !config.credentialId) { throw new Error('Authentication required - please select a credential in node settings'); } throw new Error(`OCR API error (${response.status}): ${errorMsg}`);
- }
- const data = typeof response.data === 'string' ? JSON.parse(response.data) : response.data;
- return {
- limitations: data.limitations || data
- };
- }
- };
|