1import{e as y,y as v,p as f,i as b,b as e,h as i,v as s,n as l,a as r,l as c,t as n,F as d,E as x,A as w,X as k,o}from"./vendor-D3ahWMFY.js";import{M as D}from"./MainLayout-IssbuzrT.js";import{u as M,t as C,_ as S}from"./index-YqUjisW-.js";import{r as A}from"./ChevronDownIcon-C6fBuSZM.js";const q={class:"max-w-3xl mx-auto px-4 sm:px-6 lg:px-8 py-6"},I={class:"mb-8"},_={class:"mb-8 p-4 rounded-2xl bg-gray-50 dark:bg-gray-800/50 border border-gray-200/70 dark:border-gray-700/50"},B={class:"space-y-1.5"},U=["href"],N={class:"space-y-10"},T={id:"faq"},F={class:"space-y-4"},E=["onClick"],O=y({__name:"SparkDocsView",setup(z){const p=M(),u=[{id:"overview",title:"Overview"},{id:"how-it-works",title:"How It Works"},{id:"collections",title:"Collections"},{id:"api-reference",title:"API Reference"},{id:"examples",title:"Example Apps"},{id:"limits",title:"Limits & Constraints"},{id:"security",title:"Security & Scoping"},{id:"faq",title:"FAQ"}],m=v([{q:"Do I need to write any backend code?",a:"No. MiniData handles all server-side storage automatically. Your app is pure HTML/CSS/JavaScript.",open:!1},{q:"What if my app doesn't need storage?",a:"MiniData is auto-injected but completely passive. If your app never calls it, nothing happens. Zero overhead.",open:!1},{q:"Can different users of my app see each other's data?",a:"By default, no. Each user only sees their own records. To make data shared/public, pass { shared: true } to MiniData.list().",open:!1},{q:"What happens when I hit the 10,000 record limit?",a:"New save operations will return an error message. Delete old records or contact support to discuss higher limits.",open:!1},{q:"Can I store images or files?",a:"Not directly in MiniData records. Use the platform's media uploader for files, then store the URL in your data record.",open:!1},{q:"Is the data backed up?",a:"Data is stored in the platform's main database with the same backup and reliability guarantees.",open:!1},{q:"Can I query/filter data server-side?",a:"Currently, the server returns all records in a collection. Filtering and sorting should be done in your app's JavaScript. For most mini apps (under 1,000 records), this is instant.",open:!1},{q:"Does the AI automatically use MiniData?",a:"Yes. When your prompt implies data persistence (forms, lists, tracking, etc.), the AI will generate code that uses MiniData. For static/visual apps, it won't.",open:!1}]);return(h,a)=>(o(),f(D,{"show-category-tabs":!1,"show-floating-actions":!1,"force-login":!l(p).isAuthenticated},{default:b(()=>[e("div",q,[e("div",I,[e("button",{onClick:a[0]||(a[0]=t=>h.$router.push({name:"CreatorDashboard"})),class:"flex items-center gap-1 text-sm text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 mb-4"},[i(l(C),{class:"w-4 h-4"}),a[1]||(a[1]=s(" Creator Dashboard ",-1))]),a[2]||(a[2]=e("div",{class:"flex items-center gap-3 mb-2"},[e("div",{class:"w-10 h-10 rounded-xl flex items-center justify-center bg-gradient-to-br from-[#FF6D00] to-[#FFAB00]"},[e("span",{class:"material-symbols-outlined text-xl text-white"},"bolt")]),e("div",null,[e("h1",{class:"text-2xl font-bold text-gray-900 dark:text-white"},"Spark Documentation"),e("p",{class:"text-sm text-gray-500 dark:text-gray-400"},"Build mini apps with persistent data storage")])],-1))]),e("nav",_,[a[3]||(a[3]=e("h3",{class:"text-sm font-bold text-gray-900 dark:text-white mb-3"},"Contents",-1)),e("ul",B,[(o(),r(d,null,c(u,t=>e("li",{key:t.id},[e("a",{href:"#"+t.id,class:"text-sm text-[#026B63] dark:text-emerald-400 hover:underline"},n(t.title),9,U)])),64))])]),e("div",N,[a[5]||(a[5]=e("section",{id:"overview"},[e("h2",{class:"doc-heading"},"Overview"),e("p",{class:"doc-text"},[s(" Spark is the mini app creator on the platform. You can build fully functional web apps using natural language prompts powered by AI. Every Spark app gets automatic access to "),e("strong",null,"MiniData"),s(" â a persistent server-side data storage SDK that lets your app save, retrieve, and delete data without any backend setup. ")]),e("div",{class:"doc-callout"},[e("span",{class:"material-symbols-outlined text-lg text-amber-500 flex-shrink-0 mt-0.5"},"lightbulb"),e("p",null,[s("MiniData is "),e("strong",null,"automatically available"),s(" in every Spark app. If your app doesn't need storage (e.g. a calculator or visual tool), it's simply ignored â zero overhead.")])])],-1)),a[6]||(a[6]=e("section",{id:"how-it-works"},[e("h2",{class:"doc-heading"},"How It Works"),e("p",{class:"doc-text"}," When you create a Spark app, the AI knows about MiniData and will automatically use it when your prompt implies data persistence (forms, lists, notes, CRM, inventory, etc.). "),e("ol",{class:"doc-list"},[e("li",null,"You describe your app in natural language"),e("li",null,"The AI generates a complete web app with MiniData calls built in"),e("li",null,"Your app is rendered with the SDK auto-injected"),e("li",null,"Users interact with the app â data persists on the server"),e("li",null,"Each user's data is private to them by default")])],-1)),a[7]||(a[7]=e("section",{id:"collections"},[e("h2",{class:"doc-heading"},"Collections"),e("p",{class:"doc-text"}," Collections are like folders for your data. Each collection is a named group of records. You choose the names â they can be anything: "),e("div",{class:"doc-code-block"},[e("code",null,'"notes"'),s(", "),e("code",null,'"customers"'),s(", "),e("code",null,'"orders"'),s(", "),e("code",null,'"inventory"'),s(", "),e("code",null,'"settings"')]),e("p",{class:"doc-text"}," There's no setup required. Collections are created automatically when you first save data to them. Your app can have as many collections as it needs. ")],-1)),a[8]||(a[8]=e("section",{id:"api-reference"},[e("h2",{class:"doc-heading"},"API Reference"),e("div",{class:"doc-api-card"},[e("h3",{class:"doc-api-name"},"MiniData.save(collection, data, recordCode?)"),e("p",{class:"doc-api-desc"},"Create a new record or update an existing one."),e("div",{class:"doc-params"},[e("div",{class:"doc-param"},[e("span",{class:"doc-param-name"},"collection"),e("span",{class:"doc-param-type"},"string"),e("span",{class:"doc-param-desc"}
1,'The collection name (e.g. "notes", "customers")')]),e("div",{class:"doc-param"},[e("span",{class:"doc-param-name"},"data"),e("span",{class:"doc-param-type"},"object"),e("span",{class:"doc-param-desc"},"Any JSON object up to 16KB")]),e("div",{class:"doc-param"},[e("span",{class:"doc-param-name"},"recordCode"),e("span",{class:"doc-param-type"},"string (optional)"),e("span",{class:"doc-param-desc"},"Omit to create new. Pass existing code to update.")])]),e("pre",{class:"doc-code"},`// Create a new note 2const result = await MiniData.save("notes", { 3 title: "Meeting Notes", 4 content: "Discussed Q3 budget...", 5 priority: "high" 6}); 7 8// Update an existing note 9await MiniData.save("notes", { 10 title: "Updated Title", 11 content: "New content..." 12}, "existing_record_code");`)]),e("div",{class:"doc-api-card"},[e("h3",{class:"doc-api-name"},"MiniData.list(collection, options?)"),e("p",{class:"doc-api-desc"},"Retrieve records from a collection."),e("div",{class:"doc-params"},[e("div",{class:"doc-param"},[e("span",{class:"doc-param-name"},"collection"),e("span",{class:"doc-param-type"},"string"),e("span",{class:"doc-param-desc"},"The collection name")]),e("div",{class:"doc-param"},[e("span",{class:"doc-param-name"},"options.shared"),e("span",{class:"doc-param-type"},"boolean (optional)"),e("span",{class:"doc-param-desc"},"Default: false (own records only). Set true to see all users' records.")]),e("div",{class:"doc-param"},[e("span",{class:"doc-param-name"},"options.page_no"),e("span",{class:"doc-param-type"},"number (optional)"),e("span",{class:"doc-param-desc"},"Page number for pagination (default: 0)")]),e("div",{class:"doc-param"},[e("span",{class:"doc-param-name"},"options.page_size"),e("span",{class:"doc-param-type"},"number (optional)"),e("span",{class:"doc-param-desc"},"Records per page (default: 100, max: 500)")])]),e("pre",{class:"doc-code"},`// Get my notes 13const myNotes = await MiniData.list("notes"); 14const records = myNotes.payload; // array of records 15 16// Each record contains: 17// { 18// unique_code: "abc123...", 19// collection_name: "notes", 20// data: { title: "...", content: "..." }, 21// creator_user_code: "user_xyz", 22// created_at: "2026-07-06 12:00:00" 23// } 24 25// Get ALL users' records (shared/public data) 26const allOrders = await MiniData.list("orders", { shared: true }); 27 28// Paginate 29const page2 = await MiniData.list("notes", { page_no: 1, page_size: 20 });`)]),e("div",{class:"doc-api-card"},[e("h3",{class:"doc-api-name"},"MiniData.delete(collection, recordCode)"),e("p",{class:"doc-api-desc"},"Soft-delete a record. Only the creator can delete their own records."),e("div",{class:"doc-params"},[e("div",{class:"doc-param"},[e("span",{class:"doc-param-name"},"collection"),e("span",{class:"doc-param-type"},"string"),e("span",{class:"doc-param-desc"},"The collection name")]),e("div",{class:"doc-param"},[e("span",{class:"doc-param-name"},"recordCode"),e("span",{class:"doc-param-type"},"string"),e("span",{class:"doc-param-desc"},"The unique_code of the record to delete")])]),e("pre",{class:"doc-code"},'await MiniData.delete("notes", "record_unique_code_here");')])],-1)),a[9]||(a[9]=e("section",{id:"examples"},[e("h2",{class:"doc-heading"},"Example Apps"),e("div",{class:"space-y-4"},[e("div",{class:"doc-example"},[e("h4",{class:"doc-example-title"},"Notepad App"),e("p",{class:"doc-example-prompt"},'"Build me a notepad app where I can create, edit, and delete notes"'),e("p",{class:"doc-text text-sm"},[s("The AI will use "),e("code",null,'MiniData.save("notes", ...)'),s(" to persist notes, "),e("code",null,'MiniData.list("notes")'),s(" to load them on startup, and "),e("code",null,'MiniData.delete("notes", code)'),s(" for removal.")])]),e("div",{class:"doc-example"},[e("h4",{class:"doc-example-title"},"Customer CRM"),e("p",{class:"doc-example-prompt"},'"Create a simple CRM to track customers and their orders"'),e("p",{class:"doc-text text-sm"},[s("Uses two collections: "),e("code",null,'"customers"'),s(" and "),e("code",null,'"orders"'),s(". The app links them via a customer reference stored in each order record.")])]),e("div",{class:"doc-example"},[e("h4",{class:"doc-example-title"},"Inventory Tracker"),e("p",{class:"doc-example-prompt"},'"Build an inventory management system with products, stock counts, and categories"'),e("p",{class:"doc-text text-sm"},[s("Uses "),e("code",null,'"products"'),s(" collection with fields like name, SKU, quantity, price, category. All filtering and sorting happens in the app's JavaScript.")])]),e("div",{class:"doc-example"},[e("h4",{class:"doc-example-title"},"Shared Bulletin Board"),e("p",{class:"doc-example-prompt"}
29,'"Create a shared message board where anyone can post and see all messages"'),e("p",{class:"doc-text text-sm"},[s("Uses "),e("code",null,'MiniData.list("messages", { shared: true })'),s(" so all users see everyone's posts, not just their own.")])])])],-1)),a[10]||(a[10]=e("section",{id:"limits"},[e("h2",{class:"doc-heading"},"Limits & Constraints"),e("div",{class:"doc-table-wrap"},[e("table",{class:"doc-table"},[e("tbody",null,[e("tr",null,[e("td",{class:"doc-table-label"},"Max record size"),e("td",{class:"doc-table-value"},"16 KB per record")]),e("tr",null,[e("td",{class:"doc-table-label"},"Max records per app"),e("td",{class:"doc-table-value"},"10,000 records")]),e("tr",null,[e("td",{class:"doc-table-label"},"Max page size"),e("td",{class:"doc-table-value"},"500 records per request")]),e("tr",null,[e("td",{class:"doc-table-label"},"Collections per app"),e("td",{class:"doc-table-value"},"Unlimited")]),e("tr",null,[e("td",{class:"doc-table-label"},"Data format"),e("td",{class:"doc-table-value"},"Any JSON-serializable object")]),e("tr",null,[e("td",{class:"doc-table-label"},"File/binary storage"),e("td",{class:"doc-table-value"},"Not supported in data records. Use the platform's media uploader for files.")])])])])],-1)),a[11]||(a[11]=e("section",{id:"security"},[e("h2",{class:"doc-heading"},"Security & Scoping"),e("ul",{class:"doc-list"},[e("li",null,[e("strong",null,"App isolation"),s(" â Each mini app has its own data space. App A cannot read or write App B's data.")]),e("li",null,[e("strong",null,"User scoping"),s(" â By default, users only see their own records. Use "),e("code",null,"{ shared: true }"),s(" to make data visible across users.")]),e("li",null,[e("strong",null,"Ownership"),s(" â Only the creator of a record can update or delete it.")]),e("li",null,[e("strong",null,"Authentication"),s(" â All data operations require a valid platform login. Unauthenticated users cannot access MiniData.")]),e("li",null,[e("strong",null,"User identity"),s(" â Each record is tagged with the creator's user code (an opaque identifier, not a sequential ID).")])])],-1)),e("section",T,[a[4]||(a[4]=e("h2",{class:"doc-heading"},"FAQ",-1)),e("div",F,[(o(!0),r(d,null,c(m,(t,g)=>(o(),r("div",{key:g,class:"doc-faq"},[e("button",{onClick:L=>t.open=!t.open,class:"doc-faq-q"},[e("span",null,n(t.q),1),i(l(A),{class:w(["w-4 h-4 text-gray-400 transition-transform",t.open?"rotate-180":""])},null,8,["class"])],8,E),x(e("p",{class:"doc-faq-a"},n(t.a),513),[[k,t.open]])]))),128))])])]),a[12]||(a[12]=e("div",{class:"h-16"},null,-1))])]),_:1},8,["force-login"]))}}),J=S(O,[["__scopeId","data-v-0e5c82dd"]]);export{J as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.