UNPKG

@mindmakr/gs-websdk

Version:

Web SDK for Guru SaaS System - Complete JavaScript/TypeScript SDK for building applications with dynamic schema management

434 lines 14.1 kB
"use strict"; /** * Guru SaaS Web SDK * * A comprehensive JavaScript/TypeScript SDK for building applications * with the Guru SaaS dynamic schema management system. * * @example * ```typescript * import { GuruSaaS } from '@mindmakr/gs-websdk'; * * const client = new GuruSaaS({ * baseUrl: 'https://api.yourdomain.com', * debug: true * }); * * // Authenticate * await client.auth.login('user@example.com', 'password'); * * // Create a schema template * const template = await client.schema.createSchemaTemplate({ * name: 'User Profile', * code: 'user_profile', * category: 'user_management', * schema_definition: { * type: 'object', * properties: { * name: { type: 'string', title: 'Full Name' }, * email: { type: 'string', format: 'email', title: 'Email' } * } * } * }); * * // Generate AI-powered schema * const aiSchema = await client.ai.generateSchema({ * businessDescription: 'Customer registration form for e-commerce', * formType: 'registration' * }); * ``` */ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.fieldTypes = exports.examples = exports.formatValidationErrors = exports.createValidationRules = exports.validateSchema = exports.validateField = exports.NotificationService = exports.AIService = exports.SchemaService = exports.AuthService = exports.GuruSaaSClient = exports.GuruSaaS = void 0; const client_1 = require("./core/client"); const auth_1 = require("./services/auth"); const schema_1 = require("./services/schema"); const ai_1 = require("./services/ai"); const notification_1 = require("./services/notification"); /** * Main SDK class that provides access to all Guru SaaS services */ class GuruSaaS extends client_1.GuruSaaSClient { constructor(config = {}) { super(config); // Initialize services this.auth = new auth_1.AuthService(this); this.schema = new schema_1.SchemaService(this); this.ai = new ai_1.AIService(this); this.notification = new notification_1.NotificationService(this); } /** * Get SDK version */ static getVersion() { return '1.0.0'; } /** * Create a new SDK instance with configuration */ static create(config = {}) { return new GuruSaaS(config); } } exports.GuruSaaS = GuruSaaS; // Export the main class as default exports.default = GuruSaaS; // Export all types and interfaces __exportStar(require("./types"), exports); // Export individual services for advanced usage var client_2 = require("./core/client"); Object.defineProperty(exports, "GuruSaaSClient", { enumerable: true, get: function () { return client_2.GuruSaaSClient; } }); var auth_2 = require("./services/auth"); Object.defineProperty(exports, "AuthService", { enumerable: true, get: function () { return auth_2.AuthService; } }); var schema_2 = require("./services/schema"); Object.defineProperty(exports, "SchemaService", { enumerable: true, get: function () { return schema_2.SchemaService; } }); var ai_2 = require("./services/ai"); Object.defineProperty(exports, "AIService", { enumerable: true, get: function () { return ai_2.AIService; } }); var notification_2 = require("./services/notification"); Object.defineProperty(exports, "NotificationService", { enumerable: true, get: function () { return notification_2.NotificationService; } }); // Export utility functions __exportStar(require("./utils/schema-helpers"), exports); __exportStar(require("./utils/form-helpers"), exports); var validation_helpers_1 = require("./utils/validation-helpers"); Object.defineProperty(exports, "validateField", { enumerable: true, get: function () { return validation_helpers_1.validateField; } }); Object.defineProperty(exports, "validateSchema", { enumerable: true, get: function () { return validation_helpers_1.validateSchema; } }); Object.defineProperty(exports, "createValidationRules", { enumerable: true, get: function () { return validation_helpers_1.createValidationRules; } }); Object.defineProperty(exports, "formatValidationErrors", { enumerable: true, get: function () { return validation_helpers_1.formatValidationErrors; } }); /** * Quick start example schemas and templates */ exports.examples = { schemas: { userProfile: { type: 'object', title: 'User Profile', properties: { firstName: { type: 'string', title: 'First Name', minLength: 1, maxLength: 50 }, lastName: { type: 'string', title: 'Last Name', minLength: 1, maxLength: 50 }, email: { type: 'string', format: 'email', title: 'Email Address' }, phone: { type: 'string', format: 'phone', title: 'Phone Number' }, dateOfBirth: { type: 'string', format: 'date', title: 'Date of Birth' }, avatar: { type: 'string', format: 'image-url-or-upload', title: 'Profile Picture' } }, required: ['firstName', 'lastName', 'email'] }, contactForm: { type: 'object', title: 'Contact Form', properties: { name: { type: 'string', title: 'Full Name', minLength: 2, maxLength: 100 }, email: { type: 'string', format: 'email', title: 'Email Address' }, subject: { type: 'string', title: 'Subject', enum: ['General Inquiry', 'Support', 'Sales', 'Partnership', 'Other'], enumNames: ['General Inquiry', 'Support', 'Sales', 'Partnership', 'Other'] }, message: { type: 'string', format: 'textarea', title: 'Message', minLength: 10, maxLength: 1000 }, priority: { type: 'string', title: 'Priority', enum: ['low', 'normal', 'high'], enumNames: ['Low', 'Normal', 'High'], default: 'normal' } }, required: ['name', 'email', 'subject', 'message'] }, productListing: { type: 'object', title: 'Product Listing', properties: { name: { type: 'string', title: 'Product Name', minLength: 1, maxLength: 200 }, description: { type: 'string', format: 'richtext', title: 'Description' }, price: { type: 'number', title: 'Price', minimum: 0, format: 'currency' }, category: { type: 'string', title: 'Category', enum: ['electronics', 'clothing', 'books', 'home', 'sports', 'other'], enumNames: ['Electronics', 'Clothing', 'Books', 'Home & Garden', 'Sports', 'Other'] }, images: { type: 'array', title: 'Product Images', items: { type: 'string', format: 'image-url-or-upload' }, minItems: 1, maxItems: 10 }, specifications: { type: 'object', title: 'Specifications', properties: { weight: { type: 'number', title: 'Weight (kg)', minimum: 0 }, dimensions: { type: 'string', title: 'Dimensions (L x W x H)', pattern: '^\\d+(\\.\\d+)?\\s*x\\s*\\d+(\\.\\d+)?\\s*x\\s*\\d+(\\.\\d+)?$' }, color: { type: 'string', format: 'color', title: 'Primary Color' } } }, inStock: { type: 'boolean', title: 'In Stock', default: true }, stockQuantity: { type: 'integer', title: 'Stock Quantity', minimum: 0 } }, required: ['name', 'description', 'price', 'category', 'images'] } }, templates: { userRegistration: { name: 'User Registration', code: 'user_registration', category: 'authentication', description: 'Standard user registration form with profile information' }, feedbackForm: { name: 'Customer Feedback', code: 'customer_feedback', category: 'customer_service', description: 'Collect customer feedback and ratings' }, jobApplication: { name: 'Job Application', code: 'job_application', category: 'hr', description: 'Comprehensive job application form with file uploads' } } }; /** * Common field types and their configurations */ exports.fieldTypes = { text: { type: 'string', jsonType: 'string', category: 'basic' }, textarea: { type: 'string', format: 'textarea', jsonType: 'string', category: 'basic' }, email: { type: 'string', format: 'email', jsonType: 'string', category: 'basic' }, phone: { type: 'string', format: 'phone', jsonType: 'string', category: 'basic' }, url: { type: 'string', format: 'url', jsonType: 'string', category: 'basic' }, password: { type: 'string', format: 'password', jsonType: 'string', category: 'basic' }, number: { type: 'number', jsonType: 'number', category: 'basic' }, integer: { type: 'integer', jsonType: 'number', category: 'basic' }, boolean: { type: 'boolean', jsonType: 'boolean', category: 'basic' }, date: { type: 'string', format: 'date', jsonType: 'string', category: 'basic' }, datetime: { type: 'string', format: 'datetime', jsonType: 'string', category: 'basic' }, time: { type: 'string', format: 'time', jsonType: 'string', category: 'basic' }, select: { type: 'string', enum: [], jsonType: 'string', category: 'selection' }, multiselect: { type: 'array', items: { type: 'string', enum: [] }, uniqueItems: true, jsonType: 'array', category: 'selection' }, radio: { type: 'string', enum: [], 'ui:widget': 'radio', jsonType: 'string', category: 'selection' }, checkbox: { type: 'array', items: { type: 'string', enum: [] }, uniqueItems: true, 'ui:widget': 'checkboxes', jsonType: 'array', category: 'selection' }, file: { type: 'string', format: 'data-url', 'ui:widget': 'file', jsonType: 'string', category: 'advanced' }, image: { type: 'string', format: 'image-url-or-upload', 'ui:widget': 'ImageInputWidget', jsonType: 'string', category: 'advanced' }, video: { type: 'string', format: 'video-url-or-upload', 'ui:widget': 'VideoInputWidget', jsonType: 'string', category: 'advanced' }, audio: { type: 'string', format: 'audio-url-or-upload', 'ui:widget': 'AudioInputWidget', jsonType: 'string', category: 'advanced' }, color: { type: 'string', format: 'color', jsonType: 'string', category: 'advanced' }, richtext: { type: 'string', format: 'richtext', 'ui:widget': 'richtext', jsonType: 'string', category: 'advanced' }, reference: { type: 'string', format: 'reference', jsonType: 'string', category: 'advanced' } }; //# sourceMappingURL=index.js.map