[{"data":1,"prerenderedAt":3827},["ShallowReactive",2],{"navigation_docs":3,"-developers-modules-routes":613,"-developers-modules-routes-surround":3824},[4,39,101,378,540,562,584,606],{"title":5,"icon":6,"path":7,"stem":8,"children":9,"page":38},"Start","i-lucide-rocket","\u002Fstart","1.start",[10,14,18,22,26,30,34],{"title":11,"path":12,"stem":13},"Our approach","\u002Fstart\u002Four-approach","1.start\u002F0.our-approach",{"title":15,"path":16,"stem":17},"Introduction","\u002Fstart\u002Fintroduction","1.start\u002F1.introduction",{"title":19,"path":20,"stem":21},"Concepts","\u002Fstart\u002Fconcepts","1.start\u002F2.concepts",{"title":23,"path":24,"stem":25},"Glossary","\u002Fstart\u002Fglossary","1.start\u002F3.glossary",{"title":27,"path":28,"stem":29},"Try it locally","\u002Fstart\u002Ftry-it-locally","1.start\u002F4.try-it-locally",{"title":31,"path":32,"stem":33},"Features","\u002Fstart\u002Ffeatures","1.start\u002F5.features",{"title":35,"path":36,"stem":37},"Questions","\u002Fstart\u002Ffaq","1.start\u002F6.faq",false,{"title":40,"icon":41,"path":42,"stem":43,"children":44,"page":38},"Run SHADE","i-lucide-server","\u002Frun","2.run",[45,49,53,57,61,65,69,73,77,81,85,89,93,97],{"title":46,"path":47,"stem":48},"Setting up an instance (Coolify)","\u002Frun\u002Fcoolify","2.run\u002F1.coolify",{"title":50,"path":51,"stem":52},"Console commands","\u002Frun\u002Fconsole","2.run\u002F10.console",{"title":54,"path":55,"stem":56},"Rotating APP_SECRET","\u002Frun\u002Frotating-app-secret","2.run\u002F11.rotating-app-secret",{"title":58,"path":59,"stem":60},"Checking an instance","\u002Frun\u002Fdoctor","2.run\u002F12.doctor",{"title":62,"path":63,"stem":64},"Self-hosting by hand","\u002Frun\u002Fown-server-by-hand","2.run\u002F13.own-server-by-hand",{"title":66,"path":67,"stem":68},"NixOS (experimental)","\u002Frun\u002Fnixos","2.run\u002F14.nixos",{"title":70,"path":71,"stem":72},"Self-hosting without Coolify","\u002Frun\u002Fown-server","2.run\u002F2.own-server",{"title":74,"path":75,"stem":76},"Hosting the site on a static host","\u002Frun\u002Fstatic-hosts","2.run\u002F3.static-hosts",{"title":78,"path":79,"stem":80},"Licence","\u002Frun\u002Flicence","2.run\u002F4.licence",{"title":82,"path":83,"stem":84},"Updating and backups","\u002Frun\u002Fupdating-and-backups","2.run\u002F5.updating-and-backups",{"title":86,"path":87,"stem":88},"Troubleshooting","\u002Frun\u002Ftroubleshooting","2.run\u002F6.troubleshooting",{"title":90,"path":91,"stem":92},"Logs, request ids, traces and metrics","\u002Frun\u002Flogs","2.run\u002F7.logs",{"title":94,"path":95,"stem":96},"Maintenance mode","\u002Frun\u002Fmaintenance-mode","2.run\u002F8.maintenance-mode",{"title":98,"path":99,"stem":100},"Usage limits","\u002Frun\u002Fusage-limits","2.run\u002F9.usage-limits",{"title":102,"icon":103,"path":104,"stem":105,"children":106},"Guide","i-lucide-book-open","\u002Fguide","3.guide",[107,109,147,192,210,280,310,364],{"title":102,"path":104,"stem":108},"3.guide\u002Findex",{"title":110,"icon":111,"path":112,"stem":113,"children":114,"page":38},"Content","i-lucide-file-text","\u002Fguide\u002Fcontent","3.guide\u002F1.content",[115,119,123,127,131,135,139,143],{"title":116,"path":117,"stem":118},"Collections and entries","\u002Fguide\u002Fcontent\u002Fcollections","3.guide\u002F1.content\u002F1.collections",{"title":120,"path":121,"stem":122},"Field types","\u002Fguide\u002Fcontent\u002Ffields","3.guide\u002F1.content\u002F2.fields",{"title":124,"path":125,"stem":126},"Drafts, publishing and version history","\u002Fguide\u002Fcontent\u002Fversions","3.guide\u002F1.content\u002F3.versions",{"title":128,"path":129,"stem":130},"Languages","\u002Fguide\u002Fcontent\u002Flanguages","3.guide\u002F1.content\u002F4.languages",{"title":132,"path":133,"stem":134},"Data sources","\u002Fguide\u002Fcontent\u002Fdata-sources","3.guide\u002F1.content\u002F5.data-sources",{"title":136,"path":137,"stem":138},"Media","\u002Fguide\u002Fcontent\u002Fmedia","3.guide\u002F1.content\u002F6.media",{"title":140,"path":141,"stem":142},"Search","\u002Fguide\u002Fcontent\u002Fsearch","3.guide\u002F1.content\u002F7.search",{"title":144,"path":145,"stem":146},"Trash","\u002Fguide\u002Fcontent\u002Ftrash","3.guide\u002F1.content\u002F8.trash",{"title":148,"icon":149,"path":150,"stem":151,"children":152,"page":38},"Website","i-lucide-globe","\u002Fguide\u002Fwebsite","3.guide\u002F2.website",[153,156,160,164,168,172,176,180,184,188],{"title":148,"path":154,"stem":155},"\u002Fguide\u002Fwebsite\u002Fwebsite","3.guide\u002F2.website\u002F1.website",{"title":157,"path":158,"stem":159},"Scroll scenes","\u002Fguide\u002Fwebsite\u002Fscroll-scenes","3.guide\u002F2.website\u002F10.scroll-scenes",{"title":161,"path":162,"stem":163},"Pages and posts","\u002Fguide\u002Fwebsite\u002Fpages","3.guide\u002F2.website\u002F2.pages",{"title":165,"path":166,"stem":167},"The visual editor","\u002Fguide\u002Fwebsite\u002Fvisual-editor","3.guide\u002F2.website\u002F3.visual-editor",{"title":169,"path":170,"stem":171},"Roles and locks","\u002Fguide\u002Fwebsite\u002Froles-and-locks","3.guide\u002F2.website\u002F4.roles-and-locks",{"title":173,"path":174,"stem":175},"Header and footer","\u002Fguide\u002Fwebsite\u002Fheader-and-footer","3.guide\u002F2.website\u002F5.header-and-footer",{"title":177,"path":178,"stem":179},"Theme","\u002Fguide\u002Fwebsite\u002Ftheme","3.guide\u002F2.website\u002F6.theme",{"title":181,"path":182,"stem":183},"Redirects","\u002Fguide\u002Fwebsite\u002Fredirects","3.guide\u002F2.website\u002F7.redirects",{"title":185,"path":186,"stem":187},"Site settings","\u002Fguide\u002Fwebsite\u002Fsite-settings","3.guide\u002F2.website\u002F8.site-settings",{"title":189,"path":190,"stem":191},"The site","\u002Fguide\u002Fwebsite\u002Fthe-site","3.guide\u002F2.website\u002F9.the-site",{"title":193,"icon":194,"path":195,"stem":196,"children":197,"page":38},"Publishing","i-lucide-send","\u002Fguide\u002Fpublishing","3.guide\u002F3.publishing",[198,202,206],{"title":199,"path":200,"stem":201},"Publishing and preview","\u002Fguide\u002Fpublishing\u002Fpublishing","3.guide\u002F3.publishing\u002F1.publishing",{"title":203,"path":204,"stem":205},"Builds","\u002Fguide\u002Fpublishing\u002Fbuilds","3.guide\u002F3.publishing\u002F2.builds",{"title":207,"path":208,"stem":209},"CDN caches","\u002Fguide\u002Fpublishing\u002Fcaches","3.guide\u002F3.publishing\u002F3.caches",{"title":211,"icon":212,"path":213,"stem":214,"children":215,"page":38},"People, security and privacy","i-lucide-shield","\u002Fguide\u002Fpeople-and-security","3.guide\u002F4.people-and-security",[216,220,224,228,232,236,240,244,248,252,256,260,264,268,272,276],{"title":217,"path":218,"stem":219},"People in SHADE","\u002Fguide\u002Fpeople-and-security\u002Fpeople-in-shade","3.guide\u002F4.people-and-security\u002F0.people-in-shade",{"title":221,"path":222,"stem":223},"Team and roles","\u002Fguide\u002Fpeople-and-security\u002Fteam","3.guide\u002F4.people-and-security\u002F1.team",{"title":225,"path":226,"stem":227},"Errors and security alerts","\u002Fguide\u002Fpeople-and-security\u002Ferrors","3.guide\u002F4.people-and-security\u002F10.errors",{"title":229,"path":230,"stem":231},"Exporting an instance","\u002Fguide\u002Fpeople-and-security\u002Fexporting","3.guide\u002F4.people-and-security\u002F11.exporting",{"title":233,"path":234,"stem":235},"Organisations","\u002Fguide\u002Fpeople-and-security\u002Forganisations","3.guide\u002F4.people-and-security\u002F12.organisations",{"title":237,"path":238,"stem":239},"Signing in through an identity provider (team)","\u002Fguide\u002Fpeople-and-security\u002Fidentity-providers","3.guide\u002F4.people-and-security\u002F13.identity-providers",{"title":241,"path":242,"stem":243},"System status","\u002Fguide\u002Fpeople-and-security\u002Fsystem-status","3.guide\u002F4.people-and-security\u002F14.system-status",{"title":245,"path":246,"stem":247},"Appearance","\u002Fguide\u002Fpeople-and-security\u002Fappearance","3.guide\u002F4.people-and-security\u002F15.appearance",{"title":249,"path":250,"stem":251},"Accounts and personal pages","\u002Fguide\u002Fpeople-and-security\u002Faccounts","3.guide\u002F4.people-and-security\u002F2.accounts",{"title":253,"path":254,"stem":255},"Signing in (team)","\u002Fguide\u002Fpeople-and-security\u002Fsign-in","3.guide\u002F4.people-and-security\u002F3.sign-in",{"title":257,"path":258,"stem":259},"API tokens","\u002Fguide\u002Fpeople-and-security\u002Fapi-tokens","3.guide\u002F4.people-and-security\u002F4.api-tokens",{"title":261,"path":262,"stem":263},"Audit log","\u002Fguide\u002Fpeople-and-security\u002Faudit","3.guide\u002F4.people-and-security\u002F5.audit",{"title":265,"path":266,"stem":267},"Request protection","\u002Fguide\u002Fpeople-and-security\u002Fprotection","3.guide\u002F4.people-and-security\u002F6.protection",{"title":269,"path":270,"stem":271},"Personal data per person","\u002Fguide\u002Fpeople-and-security\u002Fprivacy","3.guide\u002F4.people-and-security\u002F7.privacy",{"title":273,"path":274,"stem":275},"Data retention","\u002Fguide\u002Fpeople-and-security\u002Fretention","3.guide\u002F4.people-and-security\u002F8.retention",{"title":277,"path":278,"stem":279},"Consent banner","\u002Fguide\u002Fpeople-and-security\u002Fconsent","3.guide\u002F4.people-and-security\u002F9.consent",{"title":281,"icon":282,"path":283,"stem":284,"children":285,"page":38},"Services","i-lucide-plug","\u002Fguide\u002Fservices","3.guide\u002F5.services",[286,290,294,298,302,306],{"title":287,"path":288,"stem":289},"Email","\u002Fguide\u002Fservices\u002Femail","3.guide\u002F5.services\u002F1.email",{"title":291,"path":292,"stem":293},"Opening hours","\u002Fguide\u002Fservices\u002Fopening-hours","3.guide\u002F5.services\u002F4.opening-hours",{"title":295,"path":296,"stem":297},"Webhooks","\u002Fguide\u002Fservices\u002Fwebhooks","3.guide\u002F5.services\u002F5.webhooks",{"title":299,"path":300,"stem":301},"Locations","\u002Fguide\u002Fservices\u002Flocations","3.guide\u002F5.services\u002F6.locations",{"title":303,"path":304,"stem":305},"VAT rates","\u002Fguide\u002Fservices\u002Fvat-rates","3.guide\u002F5.services\u002F7.vat-rates",{"title":307,"path":308,"stem":309},"Channels","\u002Fguide\u002Fservices\u002Fchannels","3.guide\u002F5.services\u002F8.channels",{"title":311,"icon":312,"path":313,"stem":314,"children":315,"page":38},"InstalledModules","i-lucide-puzzle","\u002Fguide\u002Fmodules","3.guide\u002F6.modules",[316,320,324,328,332,336,340,344,348,352,356,360],{"title":317,"path":318,"stem":319},"Modules","\u002Fguide\u002Fmodules\u002Fmanaging","3.guide\u002F6.modules\u002F1.managing",{"title":321,"path":322,"stem":323},"Dutch services (module)","\u002Fguide\u002Fmodules\u002Fnl","3.guide\u002F6.modules\u002F10.nl",{"title":325,"path":326,"stem":327},"Editorial (module)","\u002Fguide\u002Fmodules\u002Feditorial","3.guide\u002F6.modules\u002F11.editorial",{"title":329,"path":330,"stem":331},"Appointments (module)","\u002Fguide\u002Fmodules\u002Fappointments","3.guide\u002F6.modules\u002F2.appointments",{"title":333,"path":334,"stem":335},"Shop (the commerce module)","\u002Fguide\u002Fmodules\u002Fshop","3.guide\u002F6.modules\u002F3.shop",{"title":337,"path":338,"stem":339},"Untrusted modules","\u002Fguide\u002Fmodules\u002Funtrusted","3.guide\u002F6.modules\u002F4.untrusted",{"title":341,"path":342,"stem":343},"Analytics (module)","\u002Fguide\u002Fmodules\u002Fanalytics","3.guide\u002F6.modules\u002F5.analytics",{"title":345,"path":346,"stem":347},"Error forwarding (module)","\u002Fguide\u002Fmodules\u002Ferror-forwarding","3.guide\u002F6.modules\u002F6.error-forwarding",{"title":349,"path":350,"stem":351},"Client programs","\u002Fguide\u002Fmodules\u002Fprograms","3.guide\u002F6.modules\u002F7.programs",{"title":353,"path":354,"stem":355},"Import and export (module)","\u002Fguide\u002Fmodules\u002Fimport","3.guide\u002F6.modules\u002F8.import",{"title":357,"path":358,"stem":359},"Payments (module)","\u002Fguide\u002Fmodules\u002Fpayments","3.guide\u002F6.modules\u002F8.payments",{"title":361,"path":362,"stem":363},"Forms (module)","\u002Fguide\u002Fmodules\u002Fforms","3.guide\u002F6.modules\u002F9.forms",{"title":365,"icon":366,"path":367,"stem":368,"children":369,"page":38},"AI assistants","i-lucide-bot","\u002Fguide\u002Fai","3.guide\u002F7.ai",[370,374],{"title":371,"path":372,"stem":373},"AI assistants (MCP)","\u002Fguide\u002Fai\u002Fassistants","3.guide\u002F7.ai\u002F1.assistants",{"title":375,"path":376,"stem":377},"Connecting an AI assistant","\u002Fguide\u002Fai\u002Fconnecting","3.guide\u002F7.ai\u002F2.connecting",{"title":379,"icon":380,"path":381,"stem":382,"children":383,"page":38},"Developers","i-lucide-code","\u002Fdevelopers","4.developers",[384,388,392,396,400,404,408,412,416,420,424,428,432,435,489,493,497,501,536],{"title":385,"path":386,"stem":387},"Architecture","\u002Fdevelopers\u002Farchitecture","4.developers\u002F1.architecture",{"title":389,"path":390,"stem":391},"Capabilities","\u002Fdevelopers\u002Fcapabilities","4.developers\u002F10.capabilities",{"title":393,"path":394,"stem":395},"Trust","\u002Fdevelopers\u002Ftrust","4.developers\u002F11.trust",{"title":397,"path":398,"stem":399},"Redis and the ports","\u002Fdevelopers\u002Fredis","4.developers\u002F12.redis",{"title":401,"path":402,"stem":403},"The worker container role","\u002Fdevelopers\u002Fworker","4.developers\u002F13.worker",{"title":405,"path":406,"stem":407},"kv: a module's own key-value storage","\u002Fdevelopers\u002Fkv","4.developers\u002F14.kv",{"title":409,"path":410,"stem":411},"Processes: long-running work on the worker","\u002Fdevelopers\u002Fprocesses","4.developers\u002F15.processes",{"title":413,"path":414,"stem":415},"Network: a module's outgoing calls","\u002Fdevelopers\u002Fnetwork","4.developers\u002F16.network",{"title":417,"path":418,"stem":419},"Realtime","\u002Fdevelopers\u002Frealtime","4.developers\u002F17.realtime",{"title":421,"path":422,"stem":423},"Private files","\u002Fdevelopers\u002Ffiles","4.developers\u002F18.files",{"title":425,"path":426,"stem":427},"Notify","\u002Fdevelopers\u002Fnotify","4.developers\u002F19.notify",{"title":429,"path":430,"stem":431},"Collections","\u002Fdevelopers\u002Fcollections","4.developers\u002F2.collections",{"title":337,"path":433,"stem":434},"\u002Fdevelopers\u002Funtrusted","4.developers\u002F20.untrusted",{"title":436,"icon":312,"path":437,"stem":438,"children":439},"Writing a plugin","\u002Fdevelopers\u002Fmodules","4.developers\u002F3.modules\u002Findex",[440,442,446,450,454,458,462,466,470,473,477,481,485],{"title":441,"path":437,"stem":438},"Writing a module",{"title":443,"path":444,"stem":445},"Module SDK and tooling","\u002Fdevelopers\u002Fmodules\u002Fsdk-and-tooling","4.developers\u002F3.modules\u002F1.sdk-and-tooling",{"title":447,"path":448,"stem":449},"Connecting accounts with OAuth2","\u002Fdevelopers\u002Fmodules\u002Foauth","4.developers\u002F3.modules\u002F10.oauth",{"title":451,"path":452,"stem":453},"Calls between modules","\u002Fdevelopers\u002Fmodules\u002Fcalls-between-modules","4.developers\u002F3.modules\u002F11.calls-between-modules",{"title":455,"path":456,"stem":457},"Experimental parts","\u002Fdevelopers\u002Fmodules\u002Fexperimental-parts","4.developers\u002F3.modules\u002F12.experimental-parts",{"title":459,"path":460,"stem":461},"The manifest","\u002Fdevelopers\u002Fmodules\u002Fmanifest","4.developers\u002F3.modules\u002F2.manifest",{"title":463,"path":464,"stem":465},"Routes","\u002Fdevelopers\u002Fmodules\u002Froutes","4.developers\u002F3.modules\u002F3.routes",{"title":467,"path":468,"stem":469},"Admin screens and the site part","\u002Fdevelopers\u002Fmodules\u002Fadmin-and-site","4.developers\u002F3.modules\u002F4.admin-and-site",{"title":110,"path":471,"stem":472},"\u002Fdevelopers\u002Fmodules\u002Fcontent","4.developers\u002F3.modules\u002F5.content",{"title":474,"path":475,"stem":476},"Background work and services","\u002Fdevelopers\u002Fmodules\u002Fbackground-and-services","4.developers\u002F3.modules\u002F6.background-and-services",{"title":478,"path":479,"stem":480},"SDK reference","\u002Fdevelopers\u002Fmodules\u002Fsdk-reference","4.developers\u002F3.modules\u002F7.sdk-reference",{"title":482,"path":483,"stem":484},"The website module's SDK","\u002Fdevelopers\u002Fmodules\u002Fwebsite-sdk","4.developers\u002F3.modules\u002F8.website-sdk",{"title":486,"path":487,"stem":488},"Incoming webhooks","\u002Fdevelopers\u002Fmodules\u002Fincoming-webhooks","4.developers\u002F3.modules\u002F9.incoming-webhooks",{"title":490,"path":491,"stem":492},"Core and the website module","\u002Fdevelopers\u002Fcore-and-website-module","4.developers\u002F4.core-and-website-module",{"title":494,"path":495,"stem":496},"The API","\u002Fdevelopers\u002Fapi","4.developers\u002F6.api",{"title":498,"path":499,"stem":500},"API reference","\u002Fdevelopers\u002Fapi-reference","4.developers\u002F6.api-reference",{"title":502,"icon":503,"path":504,"stem":505,"children":506},"Sites in other frameworks","i-lucide-layout-template","\u002Fdevelopers\u002Fframeworks","4.developers\u002F7.frameworks\u002Findex",[507,508,512,516,520,524,528,532],{"title":502,"path":504,"stem":505},{"title":509,"path":510,"stem":511},"Accounts: sign-in and modules' routes","\u002Fdevelopers\u002Fframeworks\u002Faccounts","4.developers\u002F7.frameworks\u002F1.accounts",{"title":513,"path":514,"stem":515},"`@shadestack\u002Ftree`","\u002Fdevelopers\u002Fframeworks\u002Ftree","4.developers\u002F7.frameworks\u002F2.tree",{"title":517,"path":518,"stem":519},"Expressions and styles","\u002Fdevelopers\u002Fframeworks\u002Fexpressions-and-styles","4.developers\u002F7.frameworks\u002F3.expressions-and-styles",{"title":521,"path":522,"stem":523},"`@shadestack\u002Frender`","\u002Fdevelopers\u002Fframeworks\u002Frender","4.developers\u002F7.frameworks\u002F4.render",{"title":525,"path":526,"stem":527},"`@shadestack\u002Finteractions`","\u002Fdevelopers\u002Fframeworks\u002Finteractions","4.developers\u002F7.frameworks\u002F5.interactions",{"title":529,"path":530,"stem":531},"`@shadestack\u002Fa11y`","\u002Fdevelopers\u002Fframeworks\u002Fa11y","4.developers\u002F7.frameworks\u002F6.a11y",{"title":533,"path":534,"stem":535},"Your own page for SHADE's links","\u002Fdevelopers\u002Fframeworks\u002Flinks","4.developers\u002F7.frameworks\u002F7.links",{"title":537,"path":538,"stem":539},"Build a client module","\u002Fdevelopers\u002Fclient-module","4.developers\u002F9.client-module",{"title":541,"icon":542,"path":543,"stem":544,"children":545,"page":38},"Security","i-lucide-shield-check","\u002Fsecurity","5.security",[546,550,554,558],{"title":547,"path":548,"stem":549},"Reporting a vulnerability","\u002Fsecurity\u002Freporting","5.security\u002F0.reporting",{"title":551,"path":552,"stem":553},"Security testing","\u002Fsecurity\u002Ftesting","5.security\u002F1.testing",{"title":555,"path":556,"stem":557},"Hardening a production instance","\u002Fsecurity\u002Fhardening","5.security\u002F2.hardening",{"title":559,"path":560,"stem":561},"Manual testing with Kali Linux","\u002Fsecurity\u002Fmanual-testing","5.security\u002F3.manual-testing",{"title":563,"icon":564,"path":565,"stem":566,"children":567,"page":38},"Contributing","i-lucide-git-pull-request","\u002Fcontributing","6.contributing",[568,572,576,580],{"title":569,"path":570,"stem":571},"Reading the code","\u002Fcontributing\u002Freading-the-code","6.contributing\u002F1.reading-the-code",{"title":573,"path":574,"stem":575},"Docs site","\u002Fcontributing\u002Fdocs-site","6.contributing\u002F2.docs-site",{"title":577,"path":578,"stem":579},"Releases","\u002Fcontributing\u002Freleases","6.contributing\u002F3.releases",{"title":581,"path":582,"stem":583},"Load tests","\u002Fcontributing\u002Fload-tests","6.contributing\u002F4.load-tests",{"title":585,"icon":586,"path":587,"stem":588,"children":589,"page":38},"Project","i-lucide-map","\u002Fproject","7.project",[590,594,598,602],{"title":591,"path":592,"stem":593},"Roadmap","\u002Fproject\u002Froadmap","7.project\u002F1.roadmap",{"title":595,"path":596,"stem":597},"Known issues","\u002Fproject\u002Fknown-issues","7.project\u002F2.known-issues",{"title":599,"path":600,"stem":601},"Changelog","\u002Fproject\u002Fchangelog","7.project\u002F3.changelog",{"title":603,"path":604,"stem":605},"Decisions","\u002Fproject\u002Fdecisions","7.project\u002F4.decisions",{"title":607,"path":608,"stem":609,"children":610,"icon":612},"Community","\u002Fcommunity","8.community\u002Findex",[611],{"title":607,"path":608,"stem":609},"i-lucide-users",{"id":614,"title":463,"body":615,"description":889,"extension":3819,"links":3820,"meta":3821,"navigation":970,"path":464,"seo":3822,"stem":465,"__hash__":3823},"docs\u002F4.developers\u002F3.modules\u002F3.routes.md",{"type":616,"value":617,"toc":3811},"minimark",[618,690,856,860,883,1241,1248,1251,1258,1476,1614,1617,1627,2086,2511,2515,2522,3152,3701,3706,3728,3732,3808],[619,620,621,622,626,627,630,631,634,635,638,639,642,643,646,647,650,651,654,655,658,659,662,663,666,667,669,670,672,673,676,677,669,679,681,682,689],"p",{},"A ",[623,624,625],"code",{},":param"," that is ",[623,628,629],{},"."," or ",[623,632,633],{},".."," (also written ",[623,636,637],{},"%2E%2E",") or not valid percent-encoding matches no route: it answers\n404, so a parameter can never step to another path of an untrusted module's worker. Route handlers receive a\n",[623,640,641],{},"ServiceContext"," and a framework-agnostic ",[623,644,645],{},"ModuleRequest","; they parse input with a schema and\ncall the service. ",[623,648,649],{},"auth"," is ",[623,652,653],{},"session"," (admin, default), ",[623,656,657],{},"token"," (read token; it may only do read actions),\n",[623,660,661],{},"public"," (anonymous visitors) or ",[623,664,665],{},"account"," (a visitor who signed in). On ",[623,668,653],{}," and ",[623,671,657],{}," routes\n",[623,674,675],{},"ctx.actor"," is the team member or token, with their own rights; on ",[623,678,661],{},[623,680,665],{}," routes it is the module's own\nactor, with what its ",[683,684,686],"a",{"href":685},"\u002Fdevelopers\u002Fmodules\u002Fmanifest#what-the-module-itself-may-do-uses",[623,687,688],{},"uses"," lists.",[691,692,693,705,716,747,756,783,792,809,826,838],"ul",{},[694,695,696,698,699,701,702,629],"li",{},[623,697,653],{},"\u002F",[623,700,657],{}," routes are served by the API's admin role at ",[623,703,704],{},"\u002Fapi\u002Fpackages\u002F\u003Cname>\u002F…",[694,706,621,707,698,709,711,712,715],{},[623,708,653],{},[623,710,657],{}," route that hands out personal data, such as a CSV of what visitors sent, may set ",[623,713,714],{},"personal: true",": it\nthen answers a signed-in session only, never a token, whatever the token's member may read. The forms module's CSV\ndownload is one.",[694,717,621,718,650,721,724,725,728,729,732,733,736,737,740,741,743,744,746],{},[623,719,720],{},"rateLimit",[623,722,723],{},"{ limit, windowMs, key }",": ",[623,726,727],{},"limit"," a whole number of at least 1, ",[623,730,731],{},"windowMs"," a whole number of\nmilliseconds of at least 1000. ",[623,734,735],{},"key"," is what is counted: ",[623,738,739],{},"ip"," (any route), ",[623,742,657],{}," (session and token routes\nonly), ",[623,745,665],{}," (account routes only). The loader refuses any other.",[694,748,621,749,751,752,755],{},[623,750,653],{}," route may take a larger request body than the API's default of 1 MB: ",[623,753,754],{},"bodyLimit",", in bytes, a whole\nnumber up to 10 MB (experimental; the import module takes a file's text this way). A larger body is refused with 413\nbefore the handler runs. Other routes keep the default.",[694,757,758,760,761,764,765,767,768,771,772,775,776,779,780,782],{},[623,759,661],{}," routes are served by the public role at ",[623,762,763],{},"\u002Fapi\u002Fv1\u002Faccount\u002F\u003Cname>\u002F…",", with CORS for the site origin.\nThey must declare a ",[623,766,720],{},", counted per IP (the loader refuses one without, ",[623,769,770],{},"a public route needs a rate limit",", and one counted per token, since anyone can send a new token each time); use\n",[623,773,774],{},"idempotent: true"," for anything that creates orders or payments and ",[623,777,778],{},"webhook"," for provider callbacks (timestamp,\nsignature and delivery id checked over the raw body before the handler runs: ",[683,781,486],{"href":487},").",[694,784,621,785,787,788,782],{},[623,786,661],{}," route that takes a form from visitors (a booking, a sign-up) uses SHADE's spam check, the one core's\nforms use (experimental in 0.1; see ",[683,789,791],{"href":790},"#spam-checks-on-public-forms","Spam checks on public forms",[694,793,621,794,796,797,800,801,804,805,808],{},[623,795,661],{}," route whose answer other sites load (a script they include) sets ",[623,798,799],{},"crossOrigin: true",": the API then\nsends ",[623,802,803],{},"Cross-Origin-Resource-Policy: cross-origin"," instead of ",[623,806,807],{},"same-origin",". Only public routes\nmay; the loader refuses it elsewhere.",[694,810,621,811,813,814,817,818,821,822,629],{},[623,812,661],{}," ",[623,815,816],{},"GET"," route whose answer may be cached (a card, a script other sites include) declares ",[623,819,820],{},"cache",". See\n",[683,823,825],{"href":824},"#cache-headers-and-svg-answers","Cache headers and SVG answers",[694,827,828,830,831,833,834,629],{},[623,829,665],{}," routes are served next to the public ones, at ",[623,832,763],{},", and never on the admin's\nmount. See ",[683,835,837],{"href":836},"#account-routes","Account routes",[694,839,840,841,844,845,848,849,669,852,855],{},"A public or account route may describe itself for the API's OpenAPI document with ",[623,842,843],{},"doc",": a ",[623,846,847],{},"summary",", and the\n",[623,850,851],{},"query",[623,853,854],{},"body"," schemas its handler parses with. Without one it is listed by method and path.",[857,858,791],"h3",{"id":859},"spam-checks-on-public-forms",[619,861,862,863,866,867,870,871,874,875,878,879,882],{},"The site's islands send two extra fields with every form they post: ",[623,864,865],{},"website",", a hidden field people leave empty\n(the honeypot), and ",[623,868,869],{},"elapsedMs",", how long the form was open. A route that takes a form spreads ",[623,872,873],{},"SpamCheckFields"," into\nits input, declares ",[623,876,877],{},"SPAM_CHECK_RATE_LIMIT"," (5 posts per IP in 10 minutes) and asks ",[623,880,881],{},"isSpam"," before it does anything:",[884,885,890],"pre",{"className":886,"code":887,"language":888,"meta":889,"style":889},"language-ts shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","import { isSpam, parseInput, SPAM_CHECK_RATE_LIMIT, SpamCheckFields } from '@shadestack\u002Fmodule-sdk\u002Fserver'\nimport * as z from 'zod'\n\nconst SignUpInput = z.object({ email: z.email().max(254), ...SpamCheckFields })\n\n{\n  method: 'POST',\n  path: '\u002Fsign-up',\n  auth: 'public',\n  rateLimit: SPAM_CHECK_RATE_LIMIT,\n  handler: async (ctx, request) => {\n    const input = parseInput(SignUpInput, request.body)\n    \u002F\u002F A filled-in honeypot, or a form open under 3 seconds or for an unknown time: answer as if it worked, keep nothing.\n    if (isSpam(input)) return { ok: true }\n    \u002F\u002F …\n  }\n}\n","ts","",[623,891,892,941,965,972,1045,1050,1056,1076,1093,1109,1121,1152,1181,1188,1223,1229,1235],{"__ignoreMap":889},[893,894,897,901,905,909,912,915,917,920,922,925,928,931,934,938],"span",{"class":895,"line":896},"line",1,[893,898,900],{"class":899},"s7zQu","import",[893,902,904],{"class":903},"sMK4o"," {",[893,906,908],{"class":907},"sTEyZ"," isSpam",[893,910,911],{"class":903},",",[893,913,914],{"class":907}," parseInput",[893,916,911],{"class":903},[893,918,919],{"class":907}," SPAM_CHECK_RATE_LIMIT",[893,921,911],{"class":903},[893,923,924],{"class":907}," SpamCheckFields",[893,926,927],{"class":903}," }",[893,929,930],{"class":899}," from",[893,932,933],{"class":903}," '",[893,935,937],{"class":936},"sfazB","@shadestack\u002Fmodule-sdk\u002Fserver",[893,939,940],{"class":903},"'\n",[893,942,944,946,949,952,955,958,960,963],{"class":895,"line":943},2,[893,945,900],{"class":899},[893,947,948],{"class":903}," *",[893,950,951],{"class":899}," as",[893,953,954],{"class":907}," z ",[893,956,957],{"class":899},"from",[893,959,933],{"class":903},[893,961,962],{"class":936},"zod",[893,964,940],{"class":903},[893,966,968],{"class":895,"line":967},3,[893,969,971],{"emptyLinePlaceholder":970},true,"\n",[893,973,975,979,982,985,988,990,994,997,1000,1004,1007,1009,1011,1014,1017,1019,1022,1024,1028,1031,1033,1036,1039,1042],{"class":895,"line":974},4,[893,976,978],{"class":977},"spNyl","const",[893,980,981],{"class":907}," SignUpInput ",[893,983,984],{"class":903},"=",[893,986,987],{"class":907}," z",[893,989,629],{"class":903},[893,991,993],{"class":992},"s2Zo4","object",[893,995,996],{"class":907},"(",[893,998,999],{"class":903},"{",[893,1001,1003],{"class":1002},"swJcz"," email",[893,1005,1006],{"class":903},":",[893,1008,987],{"class":907},[893,1010,629],{"class":903},[893,1012,1013],{"class":992},"email",[893,1015,1016],{"class":907},"()",[893,1018,629],{"class":903},[893,1020,1021],{"class":992},"max",[893,1023,996],{"class":907},[893,1025,1027],{"class":1026},"sbssI","254",[893,1029,1030],{"class":907},")",[893,1032,911],{"class":903},[893,1034,1035],{"class":903}," ...",[893,1037,1038],{"class":907},"SpamCheckFields ",[893,1040,1041],{"class":903},"}",[893,1043,1044],{"class":907},")\n",[893,1046,1048],{"class":895,"line":1047},5,[893,1049,971],{"emptyLinePlaceholder":970},[893,1051,1053],{"class":895,"line":1052},6,[893,1054,1055],{"class":903},"{\n",[893,1057,1059,1063,1065,1067,1070,1073],{"class":895,"line":1058},7,[893,1060,1062],{"class":1061},"sBMFI","  method",[893,1064,1006],{"class":903},[893,1066,933],{"class":903},[893,1068,1069],{"class":936},"POST",[893,1071,1072],{"class":903},"'",[893,1074,1075],{"class":903},",\n",[893,1077,1079,1082,1084,1086,1089,1091],{"class":895,"line":1078},8,[893,1080,1081],{"class":1061},"  path",[893,1083,1006],{"class":903},[893,1085,933],{"class":903},[893,1087,1088],{"class":936},"\u002Fsign-up",[893,1090,1072],{"class":903},[893,1092,1075],{"class":903},[893,1094,1096,1099,1101,1103,1105,1107],{"class":895,"line":1095},9,[893,1097,1098],{"class":1061},"  auth",[893,1100,1006],{"class":903},[893,1102,933],{"class":903},[893,1104,661],{"class":936},[893,1106,1072],{"class":903},[893,1108,1075],{"class":903},[893,1110,1112,1115,1117,1119],{"class":895,"line":1111},10,[893,1113,1114],{"class":1061},"  rateLimit",[893,1116,1006],{"class":903},[893,1118,919],{"class":907},[893,1120,1075],{"class":903},[893,1122,1124,1127,1129,1132,1135,1139,1141,1144,1146,1149],{"class":895,"line":1123},11,[893,1125,1126],{"class":1061},"  handler",[893,1128,1006],{"class":903},[893,1130,1131],{"class":977}," async",[893,1133,1134],{"class":903}," (",[893,1136,1138],{"class":1137},"sHdIc","ctx",[893,1140,911],{"class":903},[893,1142,1143],{"class":1137}," request",[893,1145,1030],{"class":903},[893,1147,1148],{"class":977}," =>",[893,1150,1151],{"class":903}," {\n",[893,1153,1155,1158,1161,1164,1166,1168,1171,1173,1175,1177,1179],{"class":895,"line":1154},12,[893,1156,1157],{"class":977},"    const",[893,1159,1160],{"class":907}," input",[893,1162,1163],{"class":903}," =",[893,1165,914],{"class":992},[893,1167,996],{"class":1002},[893,1169,1170],{"class":907},"SignUpInput",[893,1172,911],{"class":903},[893,1174,1143],{"class":907},[893,1176,629],{"class":903},[893,1178,854],{"class":907},[893,1180,1044],{"class":1002},[893,1182,1184],{"class":895,"line":1183},13,[893,1185,1187],{"class":1186},"sHwdD","    \u002F\u002F A filled-in honeypot, or a form open under 3 seconds or for an unknown time: answer as if it worked, keep nothing.\n",[893,1189,1191,1194,1196,1198,1200,1203,1206,1209,1211,1214,1216,1220],{"class":895,"line":1190},14,[893,1192,1193],{"class":899},"    if",[893,1195,1134],{"class":1002},[893,1197,881],{"class":992},[893,1199,996],{"class":1002},[893,1201,1202],{"class":907},"input",[893,1204,1205],{"class":1002},")) ",[893,1207,1208],{"class":899},"return",[893,1210,904],{"class":903},[893,1212,1213],{"class":1002}," ok",[893,1215,1006],{"class":903},[893,1217,1219],{"class":1218},"sfNiH"," true",[893,1221,1222],{"class":903}," }\n",[893,1224,1226],{"class":895,"line":1225},15,[893,1227,1228],{"class":1186},"    \u002F\u002F …\n",[893,1230,1232],{"class":895,"line":1231},16,[893,1233,1234],{"class":903},"  }\n",[893,1236,1238],{"class":895,"line":1237},17,[893,1239,1240],{"class":903},"}\n",[619,1242,1243,1244,1247],{},"A bot gets the same answer as a person, so it learns nothing. The names are experimental in 0.1 (see\n",[683,1245,1246],{"href":444},"Experimental manifest parts",") until a second module uses them; appointments' bookings are the\nfirst.",[857,1249,825],{"id":1250},"cache-headers-and-svg-answers",[619,1252,1253,1254,1257],{},"SHADE sets the cache and security headers of every module route's answer itself, once the\nanswer is final, for trusted and untrusted modules alike (",[623,1255,1256],{},"apps\u002Fapi\u002Fsrc\u002Fhttp\u002Fmodule-answers.ts","). What a handler sets\nof its own is replaced.",[884,1259,1261],{"className":886,"code":1260,"language":888,"meta":889,"style":889},"{\n  method: 'GET',\n  path: '\u002Fcard.svg',\n  auth: 'public',\n  rateLimit: { limit: 600, windowMs: 60_000, key: 'ip' },\n  \u002F\u002F Caches may keep a 200 answer 5 minutes, and serve it a minute more while they fetch a new one.\n  cache: { maxAgeSeconds: 300, staleWhileRevalidateSeconds: 60 },\n  handler: async (ctx, request) => new Response(await renderCard(ctx, request.query), {\n    headers: { 'content-type': 'image\u002Fsvg+xml' }\n  })\n}\n",[623,1262,1263,1267,1281,1296,1310,1352,1357,1386,1438,1465,1472],{"__ignoreMap":889},[893,1264,1265],{"class":895,"line":896},[893,1266,1055],{"class":903},[893,1268,1269,1271,1273,1275,1277,1279],{"class":895,"line":943},[893,1270,1062],{"class":1061},[893,1272,1006],{"class":903},[893,1274,933],{"class":903},[893,1276,816],{"class":936},[893,1278,1072],{"class":903},[893,1280,1075],{"class":903},[893,1282,1283,1285,1287,1289,1292,1294],{"class":895,"line":967},[893,1284,1081],{"class":1061},[893,1286,1006],{"class":903},[893,1288,933],{"class":903},[893,1290,1291],{"class":936},"\u002Fcard.svg",[893,1293,1072],{"class":903},[893,1295,1075],{"class":903},[893,1297,1298,1300,1302,1304,1306,1308],{"class":895,"line":974},[893,1299,1098],{"class":1061},[893,1301,1006],{"class":903},[893,1303,933],{"class":903},[893,1305,661],{"class":936},[893,1307,1072],{"class":903},[893,1309,1075],{"class":903},[893,1311,1312,1314,1316,1318,1321,1323,1326,1328,1331,1333,1336,1338,1341,1343,1345,1347,1349],{"class":895,"line":1047},[893,1313,1114],{"class":1061},[893,1315,1006],{"class":903},[893,1317,904],{"class":903},[893,1319,1320],{"class":1061}," limit",[893,1322,1006],{"class":903},[893,1324,1325],{"class":1026}," 600",[893,1327,911],{"class":903},[893,1329,1330],{"class":1061}," windowMs",[893,1332,1006],{"class":903},[893,1334,1335],{"class":1026}," 60_000",[893,1337,911],{"class":903},[893,1339,1340],{"class":1061}," key",[893,1342,1006],{"class":903},[893,1344,933],{"class":903},[893,1346,739],{"class":936},[893,1348,1072],{"class":903},[893,1350,1351],{"class":903}," },\n",[893,1353,1354],{"class":895,"line":1052},[893,1355,1356],{"class":1186},"  \u002F\u002F Caches may keep a 200 answer 5 minutes, and serve it a minute more while they fetch a new one.\n",[893,1358,1359,1362,1364,1366,1369,1371,1374,1376,1379,1381,1384],{"class":895,"line":1058},[893,1360,1361],{"class":1061},"  cache",[893,1363,1006],{"class":903},[893,1365,904],{"class":903},[893,1367,1368],{"class":1061}," maxAgeSeconds",[893,1370,1006],{"class":903},[893,1372,1373],{"class":1026}," 300",[893,1375,911],{"class":903},[893,1377,1378],{"class":1061}," staleWhileRevalidateSeconds",[893,1380,1006],{"class":903},[893,1382,1383],{"class":1026}," 60",[893,1385,1351],{"class":903},[893,1387,1388,1390,1392,1394,1396,1398,1400,1402,1404,1406,1409,1412,1414,1417,1420,1422,1424,1426,1428,1430,1432,1434,1436],{"class":895,"line":1078},[893,1389,1126],{"class":1061},[893,1391,1006],{"class":903},[893,1393,1131],{"class":977},[893,1395,1134],{"class":903},[893,1397,1138],{"class":1137},[893,1399,911],{"class":903},[893,1401,1143],{"class":1137},[893,1403,1030],{"class":903},[893,1405,1148],{"class":977},[893,1407,1408],{"class":903}," new",[893,1410,1411],{"class":992}," Response",[893,1413,996],{"class":1002},[893,1415,1416],{"class":899},"await",[893,1418,1419],{"class":992}," renderCard",[893,1421,996],{"class":1002},[893,1423,1138],{"class":907},[893,1425,911],{"class":903},[893,1427,1143],{"class":907},[893,1429,629],{"class":903},[893,1431,851],{"class":907},[893,1433,1030],{"class":1002},[893,1435,911],{"class":903},[893,1437,1151],{"class":903},[893,1439,1440,1443,1445,1447,1449,1452,1454,1456,1458,1461,1463],{"class":895,"line":1095},[893,1441,1442],{"class":1002},"    headers",[893,1444,1006],{"class":903},[893,1446,904],{"class":903},[893,1448,933],{"class":903},[893,1450,1451],{"class":1002},"content-type",[893,1453,1072],{"class":903},[893,1455,1006],{"class":903},[893,1457,933],{"class":903},[893,1459,1460],{"class":936},"image\u002Fsvg+xml",[893,1462,1072],{"class":903},[893,1464,1222],{"class":903},[893,1466,1467,1470],{"class":895,"line":1111},[893,1468,1469],{"class":903},"  }",[893,1471,1044],{"class":1002},[893,1473,1474],{"class":895,"line":1123},[893,1475,1240],{"class":903},[691,1477,1478,1514,1542,1570,1599],{},[694,1479,1480,650,1485,1488,1489,1492,1493,813,1495,1497,1498,1501,1502,1505,1506,1509,1510,1513],{},[1481,1482,1483],"strong",{},[623,1484,820],{},[623,1486,1487],{},"{ maxAgeSeconds, staleWhileRevalidateSeconds? }"," (type ",[623,1490,1491],{},"ModuleRouteCache","), whole seconds from 1\nto 86400 (a day). Only on ",[623,1494,661],{},[623,1496,816],{}," routes: the loader refuses it on account, session and token routes and on\nany other method (",[623,1499,1500],{},"only public GET routes may be cached","), and refuses keys it doesn't know (there is no\n",[623,1503,1504],{},"private","). It is part of the route's ",[623,1507,1508],{},"http"," line, ",[623,1511,1512],{},"GET \u002Fcard.svg (public, cached 300 s, stale 60 s)",", so a\nchanged cache asks the admin again.",[694,1515,1516,650,1521,1524,1525,1528,1529,1531,1532,1535,1536,1538,1539,629],{},[1481,1517,1518],{},[623,1519,1520],{},"Cache-Control",[623,1522,1523],{},"public, max-age=300, stale-while-revalidate=60"," only on a ",[623,1526,1527],{},"200"," answer to a ",[623,1530,816],{}," of such a\nroute that sets no cookie. Everything else is ",[623,1533,1534],{},"no-store",": routes without ",[623,1537,820],{},", account, session and token routes\nalways, errors, refusals and rate limits, other statuses, and answers with ",[623,1540,1541],{},"Set-Cookie",[694,1543,1544,724,1547,1549,1550,1549,1553,1549,1556,1075,1559,1562,1563,1566,1567,1569],{},[1481,1545,1546],{},"The module's own cache headers are dropped",[623,1548,1520],{},", ",[623,1551,1552],{},"Expires",[623,1554,1555],{},"Pragma",[623,1557,1558],{},"Surrogate-Control",[623,1560,1561],{},"X-Accel-Expires"," and the CDNs' ",[623,1564,1565],{},"CDN-Cache-Control"," headers. Only ",[623,1568,820],{}," decides.",[694,1571,1572,1577,1578,1583,1584,1586,1587,1590,1591,1594,1595,1598],{},[1481,1573,1574],{},[623,1575,1576],{},"X-Content-Type-Options: nosniff"," on every answer, and ",[1481,1579,1580],{},[623,1581,1582],{},"Content-Security-Policy"," in place of the\nhandler's: an SVG answer (",[623,1585,1460],{},") gets ",[623,1588,1589],{},"default-src 'none'; style-src 'unsafe-inline'; img-src data:; frame-ancestors 'none'; sandbox",": its own styles and ",[623,1592,1593],{},"data:"," images, no script, nothing\nloaded from elsewhere, and a sandbox, so even an SVG opened on its own never runs in SHADE's origin. Every other\nanswer gets the API's own policy, ",[623,1596,1597],{},"default-src 'none'; frame-ancestors 'none'",", which loads and runs nothing.",[694,1600,1601,1602,1605,1606,1609,1610,1613],{},"Tests: ",[623,1603,1604],{},"apps\u002Fapi\u002Ftest\u002Fhttp\u002Fmodule-answers.test.ts"," (both kinds of module), ",[623,1607,1608],{},"plugins.account-routes.test.ts"," (account and\ntoken routes), e2e ",[623,1611,1612],{},"plugins-untrusted.spec.ts"," (an SVG through the real sandbox).",[857,1615,837],{"id":1616},"account-routes",[619,1618,621,1619,1621,1622,1624,1625,629],{},[623,1620,665],{}," route is for \"my orders\", \"my bookings\", a wishlist: things that belong to one account.\nOnly trusted modules (server packages) may have them; untrusted modules keep ",[623,1623,661],{},"\nand ",[623,1626,653],{},[884,1628,1630],{"className":886,"code":1629,"language":888,"meta":889,"style":889},"import { ownedBy, parseInput, accountReference, type ModuleRoute } from '@shadestack\u002Fmodule-sdk\u002Fserver'\n\nexport const shopWishlist = pgTable('shop_wishlist', {\n  id: id(),\n  accountId: accountReference('account_id').notNull(),   \u002F\u002F goes with the account (on delete cascade)\n  sku: text('sku').notNull()\n})\n\nexport const routes: ModuleRoute[] = [\n  { method: 'GET', path: '\u002Fwishlist', auth: 'account',\n    handler: (ctx, request) => ctx.db.select().from(shopWishlist).where(ownedBy(shopWishlist.accountId, request.account)) },\n  { method: 'POST', path: '\u002Fwishlist', auth: 'account', rateLimit: { limit: 10, windowMs: 60_000, key: 'account' },\n    doc: { summary: 'Adds a product to the wishlist of the account', body: WishlistInput },\n    handler: (ctx, request) => addToWishlist(ctx, request.account, parseInput(WishlistInput, request.body)) }\n]\n",[623,1631,1632,1668,1672,1701,1715,1747,1775,1781,1785,1806,1851,1922,1998,2031,2081],{"__ignoreMap":889},[893,1633,1634,1636,1638,1641,1643,1645,1647,1650,1652,1655,1658,1660,1662,1664,1666],{"class":895,"line":896},[893,1635,900],{"class":899},[893,1637,904],{"class":903},[893,1639,1640],{"class":907}," ownedBy",[893,1642,911],{"class":903},[893,1644,914],{"class":907},[893,1646,911],{"class":903},[893,1648,1649],{"class":907}," accountReference",[893,1651,911],{"class":903},[893,1653,1654],{"class":899}," type",[893,1656,1657],{"class":907}," ModuleRoute",[893,1659,927],{"class":903},[893,1661,930],{"class":899},[893,1663,933],{"class":903},[893,1665,937],{"class":936},[893,1667,940],{"class":903},[893,1669,1670],{"class":895,"line":943},[893,1671,971],{"emptyLinePlaceholder":970},[893,1673,1674,1677,1680,1683,1685,1688,1690,1692,1695,1697,1699],{"class":895,"line":967},[893,1675,1676],{"class":899},"export",[893,1678,1679],{"class":977}," const",[893,1681,1682],{"class":907}," shopWishlist ",[893,1684,984],{"class":903},[893,1686,1687],{"class":992}," pgTable",[893,1689,996],{"class":907},[893,1691,1072],{"class":903},[893,1693,1694],{"class":936},"shop_wishlist",[893,1696,1072],{"class":903},[893,1698,911],{"class":903},[893,1700,1151],{"class":903},[893,1702,1703,1706,1708,1711,1713],{"class":895,"line":974},[893,1704,1705],{"class":1002},"  id",[893,1707,1006],{"class":903},[893,1709,1710],{"class":992}," id",[893,1712,1016],{"class":907},[893,1714,1075],{"class":903},[893,1716,1717,1720,1722,1724,1726,1728,1731,1733,1735,1737,1740,1742,1744],{"class":895,"line":1047},[893,1718,1719],{"class":1002},"  accountId",[893,1721,1006],{"class":903},[893,1723,1649],{"class":992},[893,1725,996],{"class":907},[893,1727,1072],{"class":903},[893,1729,1730],{"class":936},"account_id",[893,1732,1072],{"class":903},[893,1734,1030],{"class":907},[893,1736,629],{"class":903},[893,1738,1739],{"class":992},"notNull",[893,1741,1016],{"class":907},[893,1743,911],{"class":903},[893,1745,1746],{"class":1186},"   \u002F\u002F goes with the account (on delete cascade)\n",[893,1748,1749,1752,1754,1757,1759,1761,1764,1766,1768,1770,1772],{"class":895,"line":1052},[893,1750,1751],{"class":1002},"  sku",[893,1753,1006],{"class":903},[893,1755,1756],{"class":992}," text",[893,1758,996],{"class":907},[893,1760,1072],{"class":903},[893,1762,1763],{"class":936},"sku",[893,1765,1072],{"class":903},[893,1767,1030],{"class":907},[893,1769,629],{"class":903},[893,1771,1739],{"class":992},[893,1773,1774],{"class":907},"()\n",[893,1776,1777,1779],{"class":895,"line":1058},[893,1778,1041],{"class":903},[893,1780,1044],{"class":907},[893,1782,1783],{"class":895,"line":1078},[893,1784,971],{"emptyLinePlaceholder":970},[893,1786,1787,1789,1791,1794,1796,1798,1801,1803],{"class":895,"line":1095},[893,1788,1676],{"class":899},[893,1790,1679],{"class":977},[893,1792,1793],{"class":907}," routes",[893,1795,1006],{"class":903},[893,1797,1657],{"class":1061},[893,1799,1800],{"class":907},"[] ",[893,1802,984],{"class":903},[893,1804,1805],{"class":907}," [\n",[893,1807,1808,1811,1814,1816,1818,1820,1822,1824,1827,1829,1831,1834,1836,1838,1841,1843,1845,1847,1849],{"class":895,"line":1111},[893,1809,1810],{"class":903},"  {",[893,1812,1813],{"class":1002}," method",[893,1815,1006],{"class":903},[893,1817,933],{"class":903},[893,1819,816],{"class":936},[893,1821,1072],{"class":903},[893,1823,911],{"class":903},[893,1825,1826],{"class":1002}," path",[893,1828,1006],{"class":903},[893,1830,933],{"class":903},[893,1832,1833],{"class":936},"\u002Fwishlist",[893,1835,1072],{"class":903},[893,1837,911],{"class":903},[893,1839,1840],{"class":1002}," auth",[893,1842,1006],{"class":903},[893,1844,933],{"class":903},[893,1846,665],{"class":936},[893,1848,1072],{"class":903},[893,1850,1075],{"class":903},[893,1852,1853,1856,1858,1860,1862,1864,1866,1868,1870,1873,1875,1878,1880,1883,1885,1887,1889,1892,1894,1897,1899,1902,1905,1907,1910,1912,1914,1916,1919],{"class":895,"line":1123},[893,1854,1855],{"class":992},"    handler",[893,1857,1006],{"class":903},[893,1859,1134],{"class":903},[893,1861,1138],{"class":1137},[893,1863,911],{"class":903},[893,1865,1143],{"class":1137},[893,1867,1030],{"class":903},[893,1869,1148],{"class":977},[893,1871,1872],{"class":907}," ctx",[893,1874,629],{"class":903},[893,1876,1877],{"class":907},"db",[893,1879,629],{"class":903},[893,1881,1882],{"class":992},"select",[893,1884,1016],{"class":907},[893,1886,629],{"class":903},[893,1888,957],{"class":992},[893,1890,1891],{"class":907},"(shopWishlist)",[893,1893,629],{"class":903},[893,1895,1896],{"class":992},"where",[893,1898,996],{"class":907},[893,1900,1901],{"class":992},"ownedBy",[893,1903,1904],{"class":907},"(shopWishlist",[893,1906,629],{"class":903},[893,1908,1909],{"class":907},"accountId",[893,1911,911],{"class":903},[893,1913,1143],{"class":907},[893,1915,629],{"class":903},[893,1917,1918],{"class":907},"account)) ",[893,1920,1921],{"class":903},"},\n",[893,1923,1924,1926,1928,1930,1932,1934,1936,1938,1940,1942,1944,1946,1948,1950,1952,1954,1956,1958,1960,1962,1965,1967,1969,1971,1973,1976,1978,1980,1982,1984,1986,1988,1990,1992,1994,1996],{"class":895,"line":1154},[893,1925,1810],{"class":903},[893,1927,1813],{"class":1002},[893,1929,1006],{"class":903},[893,1931,933],{"class":903},[893,1933,1069],{"class":936},[893,1935,1072],{"class":903},[893,1937,911],{"class":903},[893,1939,1826],{"class":1002},[893,1941,1006],{"class":903},[893,1943,933],{"class":903},[893,1945,1833],{"class":936},[893,1947,1072],{"class":903},[893,1949,911],{"class":903},[893,1951,1840],{"class":1002},[893,1953,1006],{"class":903},[893,1955,933],{"class":903},[893,1957,665],{"class":936},[893,1959,1072],{"class":903},[893,1961,911],{"class":903},[893,1963,1964],{"class":1002}," rateLimit",[893,1966,1006],{"class":903},[893,1968,904],{"class":903},[893,1970,1320],{"class":1002},[893,1972,1006],{"class":903},[893,1974,1975],{"class":1026}," 10",[893,1977,911],{"class":903},[893,1979,1330],{"class":1002},[893,1981,1006],{"class":903},[893,1983,1335],{"class":1026},[893,1985,911],{"class":903},[893,1987,1340],{"class":1002},[893,1989,1006],{"class":903},[893,1991,933],{"class":903},[893,1993,665],{"class":936},[893,1995,1072],{"class":903},[893,1997,1351],{"class":903},[893,1999,2000,2003,2005,2007,2010,2012,2014,2017,2019,2021,2024,2026,2029],{"class":895,"line":1183},[893,2001,2002],{"class":1002},"    doc",[893,2004,1006],{"class":903},[893,2006,904],{"class":903},[893,2008,2009],{"class":1002}," summary",[893,2011,1006],{"class":903},[893,2013,933],{"class":903},[893,2015,2016],{"class":936},"Adds a product to the wishlist of the account",[893,2018,1072],{"class":903},[893,2020,911],{"class":903},[893,2022,2023],{"class":1002}," body",[893,2025,1006],{"class":903},[893,2027,2028],{"class":907}," WishlistInput ",[893,2030,1921],{"class":903},[893,2032,2033,2035,2037,2039,2041,2043,2045,2047,2049,2052,2055,2057,2059,2061,2063,2065,2067,2070,2072,2074,2076,2079],{"class":895,"line":1190},[893,2034,1855],{"class":992},[893,2036,1006],{"class":903},[893,2038,1134],{"class":903},[893,2040,1138],{"class":1137},[893,2042,911],{"class":903},[893,2044,1143],{"class":1137},[893,2046,1030],{"class":903},[893,2048,1148],{"class":977},[893,2050,2051],{"class":992}," addToWishlist",[893,2053,2054],{"class":907},"(ctx",[893,2056,911],{"class":903},[893,2058,1143],{"class":907},[893,2060,629],{"class":903},[893,2062,665],{"class":907},[893,2064,911],{"class":903},[893,2066,914],{"class":992},[893,2068,2069],{"class":907},"(WishlistInput",[893,2071,911],{"class":903},[893,2073,1143],{"class":907},[893,2075,629],{"class":903},[893,2077,2078],{"class":907},"body)) ",[893,2080,1240],{"class":903},[893,2082,2083],{"class":895,"line":1225},[893,2084,2085],{"class":907},"]\n",[691,2087,2088,2120,2140,2160,2401,2419,2436,2459,2476,2497],{},[694,2089,2090,2093,2094,1134,2097,2100,2101,2104,2105,2109,2110,2113,2114,2116,2117,2119],{},[1481,2091,2092],{},"Who gets through."," Accounts must be on, and the request must carry a session whose address is\nconfirmed; anyone else gets 401. The account reaches the handler as ",[623,2095,2096],{},"request.account",[623,2098,2099],{},"{ id, email, roles }",";\n",[623,2102,2103],{},"roles"," is empty unless the module has ",[683,2106,2108],{"href":2107},"#account-roles","account roles","; each is ",[623,2111,2112],{},"{ role, scope, abilities }","). It is not\nan actor and holds no permissions, so the route decides by ",[623,2115,2096],{},"; ",[623,2118,675],{}," is the module's own\nactor.",[694,2121,2122,813,2125,2128,2129,2132,2133,669,2136,2139],{},[1481,2123,2124],{},"Only their own rows.",[623,2126,2127],{},"ownedBy(column, request.account)"," is the where-clause for the account's own rows; with\n",[623,2130,2131],{},"{ email }"," it finds the rows of the account with that address (a personal data source's ",[623,2134,2135],{},"find",[623,2137,2138],{},"erase",").\nWithout an account it throws UNAUTHORIZED rather than match every row. Look a row up with it, so another account's\nrow is simply not found.",[694,2141,2142,2148,2149,2152,2153,630,2156,2159],{},[1481,2143,2144,2145,629],{},"Account-owned columns use ",[623,2146,2147],{},"accountReference"," It is how SHADE knows a table holds accounts' data: the column\nis a foreign key to the accounts (on delete cascade), so the rows go with the account, the loader checks the\npersonal data below, and the consent screen lists the table. A column referring to a team member uses\n",[623,2150,2151],{},"teamMemberReference"," instead (on delete set null). An account's id kept in a plain ",[623,2154,2155],{},"text",[623,2157,2158],{},"uuid"," column cannot be\ndetected: nothing stops it, nothing erases it, and nothing tells the admin. Never store one that way.",[694,2161,2162,2165,2166,2168,2169,2172,2173,2176,2177,2180,2181,2378,2381,2382,2385,2386,2388,2389,2392,2393,2397,2398,629],{},[1481,2163,2164],{},"Personal data."," A table with a ",[623,2167,2147],{}," column must be in the ",[623,2170,2171],{},"tables"," of one of the module's\n",[623,2174,2175],{},"personalData"," sources that erases, or the module does not load (",[623,2178,2179],{},"table \"shop_wishlist\" refers to account accounts: …","):",[884,2182,2184],{"className":886,"code":2183,"language":888,"meta":889,"style":889},"personalData: [{ key: 'wishlist', label: 'shop.privacy.wishlist', tables: [shopWishlist],\n  find: (ctx, email) => ctx.db.select().from(shopWishlist).where(ownedBy(shopWishlist.accountId, { email })),\n  erase: async (ctx, email) => (await ctx.db.delete(shopWishlist).where(ownedBy(shopWishlist.accountId, { email })).returning()).length }]\n",[623,2185,2186,2234,2299],{"__ignoreMap":889},[893,2187,2188,2190,2192,2195,2197,2199,2201,2203,2206,2208,2210,2213,2215,2217,2220,2222,2224,2227,2229,2232],{"class":895,"line":896},[893,2189,2175],{"class":1061},[893,2191,1006],{"class":903},[893,2193,2194],{"class":907}," [",[893,2196,999],{"class":903},[893,2198,1340],{"class":1002},[893,2200,1006],{"class":903},[893,2202,933],{"class":903},[893,2204,2205],{"class":936},"wishlist",[893,2207,1072],{"class":903},[893,2209,911],{"class":903},[893,2211,2212],{"class":1002}," label",[893,2214,1006],{"class":903},[893,2216,933],{"class":903},[893,2218,2219],{"class":936},"shop.privacy.wishlist",[893,2221,1072],{"class":903},[893,2223,911],{"class":903},[893,2225,2226],{"class":1002}," tables",[893,2228,1006],{"class":903},[893,2230,2231],{"class":907}," [shopWishlist]",[893,2233,1075],{"class":903},[893,2235,2236,2239,2241,2243,2245,2247,2249,2251,2253,2255,2257,2259,2261,2263,2265,2267,2269,2271,2273,2275,2277,2279,2281,2283,2285,2287,2289,2292,2294,2297],{"class":895,"line":943},[893,2237,2238],{"class":992},"  find",[893,2240,1006],{"class":903},[893,2242,1134],{"class":903},[893,2244,1138],{"class":1137},[893,2246,911],{"class":903},[893,2248,1003],{"class":1137},[893,2250,1030],{"class":903},[893,2252,1148],{"class":977},[893,2254,1872],{"class":907},[893,2256,629],{"class":903},[893,2258,1877],{"class":907},[893,2260,629],{"class":903},[893,2262,1882],{"class":992},[893,2264,1016],{"class":907},[893,2266,629],{"class":903},[893,2268,957],{"class":992},[893,2270,1891],{"class":907},[893,2272,629],{"class":903},[893,2274,1896],{"class":992},[893,2276,996],{"class":907},[893,2278,1901],{"class":992},[893,2280,1904],{"class":907},[893,2282,629],{"class":903},[893,2284,1909],{"class":907},[893,2286,911],{"class":903},[893,2288,904],{"class":903},[893,2290,2291],{"class":907}," email ",[893,2293,1041],{"class":903},[893,2295,2296],{"class":907},"))",[893,2298,1075],{"class":903},[893,2300,2301,2304,2306,2308,2310,2312,2314,2316,2318,2320,2322,2324,2326,2328,2330,2332,2335,2337,2339,2341,2343,2345,2347,2349,2351,2353,2355,2357,2359,2361,2363,2366,2369,2371,2374,2376],{"class":895,"line":967},[893,2302,2303],{"class":992},"  erase",[893,2305,1006],{"class":903},[893,2307,1131],{"class":977},[893,2309,1134],{"class":903},[893,2311,1138],{"class":1137},[893,2313,911],{"class":903},[893,2315,1003],{"class":1137},[893,2317,1030],{"class":903},[893,2319,1148],{"class":977},[893,2321,1134],{"class":907},[893,2323,1416],{"class":899},[893,2325,1872],{"class":907},[893,2327,629],{"class":903},[893,2329,1877],{"class":907},[893,2331,629],{"class":903},[893,2333,2334],{"class":992},"delete",[893,2336,1891],{"class":907},[893,2338,629],{"class":903},[893,2340,1896],{"class":992},[893,2342,996],{"class":907},[893,2344,1901],{"class":992},[893,2346,1904],{"class":907},[893,2348,629],{"class":903},[893,2350,1909],{"class":907},[893,2352,911],{"class":903},[893,2354,904],{"class":903},[893,2356,2291],{"class":907},[893,2358,1041],{"class":903},[893,2360,2296],{"class":907},[893,2362,629],{"class":903},[893,2364,2365],{"class":992},"returning",[893,2367,2368],{"class":907},"())",[893,2370,629],{"class":903},[893,2372,2373],{"class":907},"length ",[893,2375,1041],{"class":903},[893,2377,2085],{"class":907},[2379,2380],"br",{},"Rows the law makes you keep (",[623,2383,2384],{},"keepReason",") should not hang off an account: deleting the account deletes them.\nStore what you must keep (an order) without a ",[623,2387,2147],{},": refer to the person's contact instead\n(",[623,2390,2391],{},"contactReference",", see ",[683,2394,2396],{"href":2395},"\u002Fdevelopers\u002Fmodules\u002Fbackground-and-services#contacts","Contacts","), and read a signed-in account's own rows\nwith ",[623,2399,2400],{},"ownedByContact(column, request.account)",[694,2402,2403,2406,2407,2410,2411,2414,2415,2418],{},[1481,2404,2405],{},"Rate limits."," 60 a minute per account unless the route declares its own, counted per account (",[623,2408,2409],{},"key: 'account'",",\nfor account routes only) or per IP (",[623,2412,2413],{},"key: 'ip'","). On top of that, every account route allows 300 requests a\nminute per IP before the session is even read (",[623,2416,2417],{},"USER_ROUTE_IP_LIMIT","), so calls without a session, or with a\nnew forged cookie each time, cannot go on forever.",[694,2420,2421,2424,2425,2428,2429,2432,2433,2435],{},[1481,2422,2423],{},"From the site only."," The browser sends the account's session cookie. SHADE trusts one origin with it, the Site\nURL's, as Better Auth does for sign-in; other frontends are not trusted with it. CORS with\ncredentials allows that origin only; a request that changes something (anything but GET and HEAD) must carry an\n",[623,2426,2427],{},"Origin"," header that is the site's, or it gets 403; and a request the browser marks as coming from another site\n(",[623,2430,2431],{},"Sec-Fetch-Site: cross-site",") gets 403 whatever its method. A server calling an account route with an account's\ncookie sets ",[623,2434,2427],{}," to the site's address.",[694,2437,2438,2441,2442,2444,2445,1549,2447,1549,2450,630,2453,2456,2457,629],{},[1481,2439,2440],{},"GET changes nothing."," The session cookie (SameSite=Lax) rides along when another site links to a GET route,\nso an account ",[623,2443,816],{}," route must only read. Every change is a ",[623,2446,1069],{},[623,2448,2449],{},"PUT",[623,2451,2452],{},"PATCH",[623,2454,2455],{},"DELETE",", which needs the\nsite's ",[623,2458,2427],{},[694,2460,2461,2464,2465,2468,2469,2471,2472,2475],{},[1481,2462,2463],{},"Answers are the account's."," They are sent with ",[623,2466,2467],{},"cache-control: no-store",", whatever the handler sets; an account route\ncannot declare ",[623,2470,820],{},". An ",[623,2473,2474],{},"idempotent"," account route keeps\nits keys per account.",[694,2477,2478,813,2481,2484,2485,2488,2489,2492,2493,2496],{},[1481,2479,2480],{},"From a frontend.",[623,2482,2483],{},"callAccountRoute(plugin, path, options)"," of ",[623,2486,2487],{},"@shadestack\u002Fclient"," sends the cookie; see\n",[683,2490,2491],{"href":504},"Frameworks",". The route is in the OpenAPI document under the ",[623,2494,2495],{},"accountSession"," scheme.",[694,2498,2499,2502,2503,2506,2507,2510],{},[1481,2500,2501],{},"Tests."," Core's ",[623,2504,2505],{},"account-probe"," fixture (",[623,2508,2509],{},"shade\u002Ftest\u002Ftesting\u002Ffixtures\u002Fmodules\u002Faccount-probe",") is a small, complete\nexample: an account's notes, with its personal data and its routes, and account roles.",[857,2512,2514],{"id":2513},"account-roles","Account roles",[619,2516,2517,2518,2521],{},"For the people who work in a client's system on its site: the staff of a location, their managers.\nThe module declares the roles in its ",[623,2519,2520],{},"accounts"," part; SHADE keeps who has which, checks a route's ability before the\nmodule's code runs, and audits every change. Admins give roles on the Accounts screen; a role's members may give lower\nroles themselves.",[884,2523,2525],{"className":886,"code":2524,"language":888,"meta":889,"style":889},"import { assignAccountRole, inScope, parseInput, type ModuleRoute } from '@shadestack\u002Fmodule-sdk\u002Fserver'\n\nexport default defineModule({\n  name: 'repairs',\n  \u002F\u002F …\n  db: { tables: { repairsJobs, repairsWorkshops }, migrationsFolder: 'migrations' },\n  accounts: {\n    roles: {\n      mechanic: { scope: 'workshops', can: ['jobs.read', 'jobs.update'] },\n      foreman: { scope: 'workshops', includes: ['mechanic'], can: ['mechanics.assign', { ability: 'accounts.roles.give', roles: ['mechanic'] }] }\n    }\n  },\n  server: { routes }\n})\n\nexport const routes: ModuleRoute[] = [\n  { method: 'GET', path: '\u002Fworkshop\u002Fjobs', auth: { account: 'jobs.read' },\n    handler: (ctx, request) => ctx.db.select().from(repairsJobs).where(inScope(repairsJobs.workshopId, request.account, 'jobs.read')) },\n  { method: 'POST', path: '\u002Fworkshop\u002Fmechanics', auth: { account: 'mechanics.assign' },\n    handler: (ctx, request) => {\n      const { email, workshop } = parseInput(MechanicInput, request.body)\n      return assignAccountRole(ctx, request.account, { account: { email }, role: 'mechanic', scope: workshop })\n    } }\n]\n",[623,2526,2527,2561,2565,2579,2595,2600,2640,2649,2658,2709,2801,2806,2811,2825,2831,2835,2853,2901,2976,3024,3045,3081,3139,3147],{"__ignoreMap":889},[893,2528,2529,2531,2533,2536,2538,2541,2543,2545,2547,2549,2551,2553,2555,2557,2559],{"class":895,"line":896},[893,2530,900],{"class":899},[893,2532,904],{"class":903},[893,2534,2535],{"class":907}," assignAccountRole",[893,2537,911],{"class":903},[893,2539,2540],{"class":907}," inScope",[893,2542,911],{"class":903},[893,2544,914],{"class":907},[893,2546,911],{"class":903},[893,2548,1654],{"class":899},[893,2550,1657],{"class":907},[893,2552,927],{"class":903},[893,2554,930],{"class":899},[893,2556,933],{"class":903},[893,2558,937],{"class":936},[893,2560,940],{"class":903},[893,2562,2563],{"class":895,"line":943},[893,2564,971],{"emptyLinePlaceholder":970},[893,2566,2567,2569,2572,2575,2577],{"class":895,"line":967},[893,2568,1676],{"class":899},[893,2570,2571],{"class":899}," default",[893,2573,2574],{"class":992}," defineModule",[893,2576,996],{"class":907},[893,2578,1055],{"class":903},[893,2580,2581,2584,2586,2588,2591,2593],{"class":895,"line":974},[893,2582,2583],{"class":1002},"  name",[893,2585,1006],{"class":903},[893,2587,933],{"class":903},[893,2589,2590],{"class":936},"repairs",[893,2592,1072],{"class":903},[893,2594,1075],{"class":903},[893,2596,2597],{"class":895,"line":1047},[893,2598,2599],{"class":1186},"  \u002F\u002F …\n",[893,2601,2602,2605,2607,2609,2611,2613,2615,2618,2620,2623,2626,2629,2631,2633,2636,2638],{"class":895,"line":1052},[893,2603,2604],{"class":1002},"  db",[893,2606,1006],{"class":903},[893,2608,904],{"class":903},[893,2610,2226],{"class":1002},[893,2612,1006],{"class":903},[893,2614,904],{"class":903},[893,2616,2617],{"class":907}," repairsJobs",[893,2619,911],{"class":903},[893,2621,2622],{"class":907}," repairsWorkshops ",[893,2624,2625],{"class":903},"},",[893,2627,2628],{"class":1002}," migrationsFolder",[893,2630,1006],{"class":903},[893,2632,933],{"class":903},[893,2634,2635],{"class":936},"migrations",[893,2637,1072],{"class":903},[893,2639,1351],{"class":903},[893,2641,2642,2645,2647],{"class":895,"line":1058},[893,2643,2644],{"class":1002},"  accounts",[893,2646,1006],{"class":903},[893,2648,1151],{"class":903},[893,2650,2651,2654,2656],{"class":895,"line":1078},[893,2652,2653],{"class":1002},"    roles",[893,2655,1006],{"class":903},[893,2657,1151],{"class":903},[893,2659,2660,2663,2665,2667,2670,2672,2674,2677,2679,2681,2684,2686,2688,2690,2693,2695,2697,2699,2702,2704,2707],{"class":895,"line":1095},[893,2661,2662],{"class":1002},"      mechanic",[893,2664,1006],{"class":903},[893,2666,904],{"class":903},[893,2668,2669],{"class":1002}," scope",[893,2671,1006],{"class":903},[893,2673,933],{"class":903},[893,2675,2676],{"class":936},"workshops",[893,2678,1072],{"class":903},[893,2680,911],{"class":903},[893,2682,2683],{"class":1002}," can",[893,2685,1006],{"class":903},[893,2687,2194],{"class":907},[893,2689,1072],{"class":903},[893,2691,2692],{"class":936},"jobs.read",[893,2694,1072],{"class":903},[893,2696,911],{"class":903},[893,2698,933],{"class":903},[893,2700,2701],{"class":936},"jobs.update",[893,2703,1072],{"class":903},[893,2705,2706],{"class":907},"] ",[893,2708,1921],{"class":903},[893,2710,2711,2714,2716,2718,2720,2722,2724,2726,2728,2730,2733,2735,2737,2739,2742,2744,2747,2749,2751,2753,2755,2757,2760,2762,2764,2766,2769,2771,2773,2776,2778,2780,2783,2785,2787,2789,2791,2793,2795,2797,2799],{"class":895,"line":1111},[893,2712,2713],{"class":1002},"      foreman",[893,2715,1006],{"class":903},[893,2717,904],{"class":903},[893,2719,2669],{"class":1002},[893,2721,1006],{"class":903},[893,2723,933],{"class":903},[893,2725,2676],{"class":936},[893,2727,1072],{"class":903},[893,2729,911],{"class":903},[893,2731,2732],{"class":1002}," includes",[893,2734,1006],{"class":903},[893,2736,2194],{"class":907},[893,2738,1072],{"class":903},[893,2740,2741],{"class":936},"mechanic",[893,2743,1072],{"class":903},[893,2745,2746],{"class":907},"]",[893,2748,911],{"class":903},[893,2750,2683],{"class":1002},[893,2752,1006],{"class":903},[893,2754,2194],{"class":907},[893,2756,1072],{"class":903},[893,2758,2759],{"class":936},"mechanics.assign",[893,2761,1072],{"class":903},[893,2763,911],{"class":903},[893,2765,904],{"class":903},[893,2767,2768],{"class":1002}," ability",[893,2770,1006],{"class":903},[893,2772,933],{"class":903},[893,2774,2775],{"class":936},"accounts.roles.give",[893,2777,1072],{"class":903},[893,2779,911],{"class":903},[893,2781,2782],{"class":1002}," roles",[893,2784,1006],{"class":903},[893,2786,2194],{"class":907},[893,2788,1072],{"class":903},[893,2790,2741],{"class":936},[893,2792,1072],{"class":903},[893,2794,2706],{"class":907},[893,2796,1041],{"class":903},[893,2798,2706],{"class":907},[893,2800,1240],{"class":903},[893,2802,2803],{"class":895,"line":1123},[893,2804,2805],{"class":903},"    }\n",[893,2807,2808],{"class":895,"line":1154},[893,2809,2810],{"class":903},"  },\n",[893,2812,2813,2816,2818,2820,2823],{"class":895,"line":1183},[893,2814,2815],{"class":1002},"  server",[893,2817,1006],{"class":903},[893,2819,904],{"class":903},[893,2821,2822],{"class":907}," routes ",[893,2824,1240],{"class":903},[893,2826,2827,2829],{"class":895,"line":1190},[893,2828,1041],{"class":903},[893,2830,1044],{"class":907},[893,2832,2833],{"class":895,"line":1225},[893,2834,971],{"emptyLinePlaceholder":970},[893,2836,2837,2839,2841,2843,2845,2847,2849,2851],{"class":895,"line":1231},[893,2838,1676],{"class":899},[893,2840,1679],{"class":977},[893,2842,1793],{"class":907},[893,2844,1006],{"class":903},[893,2846,1657],{"class":1061},[893,2848,1800],{"class":907},[893,2850,984],{"class":903},[893,2852,1805],{"class":907},[893,2854,2855,2857,2859,2861,2863,2865,2867,2869,2871,2873,2875,2878,2880,2882,2884,2886,2888,2891,2893,2895,2897,2899],{"class":895,"line":1237},[893,2856,1810],{"class":903},[893,2858,1813],{"class":1002},[893,2860,1006],{"class":903},[893,2862,933],{"class":903},[893,2864,816],{"class":936},[893,2866,1072],{"class":903},[893,2868,911],{"class":903},[893,2870,1826],{"class":1002},[893,2872,1006],{"class":903},[893,2874,933],{"class":903},[893,2876,2877],{"class":936},"\u002Fworkshop\u002Fjobs",[893,2879,1072],{"class":903},[893,2881,911],{"class":903},[893,2883,1840],{"class":1002},[893,2885,1006],{"class":903},[893,2887,904],{"class":903},[893,2889,2890],{"class":1002}," account",[893,2892,1006],{"class":903},[893,2894,933],{"class":903},[893,2896,2692],{"class":936},[893,2898,1072],{"class":903},[893,2900,1351],{"class":903},[893,2902,2904,2906,2908,2910,2912,2914,2916,2918,2920,2922,2924,2926,2928,2930,2932,2934,2936,2939,2941,2943,2945,2948,2951,2953,2956,2958,2960,2962,2964,2966,2968,2970,2972,2974],{"class":895,"line":2903},18,[893,2905,1855],{"class":992},[893,2907,1006],{"class":903},[893,2909,1134],{"class":903},[893,2911,1138],{"class":1137},[893,2913,911],{"class":903},[893,2915,1143],{"class":1137},[893,2917,1030],{"class":903},[893,2919,1148],{"class":977},[893,2921,1872],{"class":907},[893,2923,629],{"class":903},[893,2925,1877],{"class":907},[893,2927,629],{"class":903},[893,2929,1882],{"class":992},[893,2931,1016],{"class":907},[893,2933,629],{"class":903},[893,2935,957],{"class":992},[893,2937,2938],{"class":907},"(repairsJobs)",[893,2940,629],{"class":903},[893,2942,1896],{"class":992},[893,2944,996],{"class":907},[893,2946,2947],{"class":992},"inScope",[893,2949,2950],{"class":907},"(repairsJobs",[893,2952,629],{"class":903},[893,2954,2955],{"class":907},"workshopId",[893,2957,911],{"class":903},[893,2959,1143],{"class":907},[893,2961,629],{"class":903},[893,2963,665],{"class":907},[893,2965,911],{"class":903},[893,2967,933],{"class":903},[893,2969,2692],{"class":936},[893,2971,1072],{"class":903},[893,2973,1205],{"class":907},[893,2975,1921],{"class":903},[893,2977,2979,2981,2983,2985,2987,2989,2991,2993,2995,2997,2999,3002,3004,3006,3008,3010,3012,3014,3016,3018,3020,3022],{"class":895,"line":2978},19,[893,2980,1810],{"class":903},[893,2982,1813],{"class":1002},[893,2984,1006],{"class":903},[893,2986,933],{"class":903},[893,2988,1069],{"class":936},[893,2990,1072],{"class":903},[893,2992,911],{"class":903},[893,2994,1826],{"class":1002},[893,2996,1006],{"class":903},[893,2998,933],{"class":903},[893,3000,3001],{"class":936},"\u002Fworkshop\u002Fmechanics",[893,3003,1072],{"class":903},[893,3005,911],{"class":903},[893,3007,1840],{"class":1002},[893,3009,1006],{"class":903},[893,3011,904],{"class":903},[893,3013,2890],{"class":1002},[893,3015,1006],{"class":903},[893,3017,933],{"class":903},[893,3019,2759],{"class":936},[893,3021,1072],{"class":903},[893,3023,1351],{"class":903},[893,3025,3027,3029,3031,3033,3035,3037,3039,3041,3043],{"class":895,"line":3026},20,[893,3028,1855],{"class":992},[893,3030,1006],{"class":903},[893,3032,1134],{"class":903},[893,3034,1138],{"class":1137},[893,3036,911],{"class":903},[893,3038,1143],{"class":1137},[893,3040,1030],{"class":903},[893,3042,1148],{"class":977},[893,3044,1151],{"class":903},[893,3046,3048,3051,3053,3055,3057,3060,3062,3064,3066,3068,3071,3073,3075,3077,3079],{"class":895,"line":3047},21,[893,3049,3050],{"class":977},"      const",[893,3052,904],{"class":903},[893,3054,1003],{"class":907},[893,3056,911],{"class":903},[893,3058,3059],{"class":907}," workshop",[893,3061,927],{"class":903},[893,3063,1163],{"class":903},[893,3065,914],{"class":992},[893,3067,996],{"class":1002},[893,3069,3070],{"class":907},"MechanicInput",[893,3072,911],{"class":903},[893,3074,1143],{"class":907},[893,3076,629],{"class":903},[893,3078,854],{"class":907},[893,3080,1044],{"class":1002},[893,3082,3084,3087,3089,3091,3093,3095,3097,3099,3101,3103,3105,3107,3109,3111,3113,3116,3119,3121,3123,3125,3127,3129,3131,3133,3135,3137],{"class":895,"line":3083},22,[893,3085,3086],{"class":899},"      return",[893,3088,2535],{"class":992},[893,3090,996],{"class":1002},[893,3092,1138],{"class":907},[893,3094,911],{"class":903},[893,3096,1143],{"class":907},[893,3098,629],{"class":903},[893,3100,665],{"class":907},[893,3102,911],{"class":903},[893,3104,904],{"class":903},[893,3106,2890],{"class":1002},[893,3108,1006],{"class":903},[893,3110,904],{"class":903},[893,3112,1003],{"class":907},[893,3114,3115],{"class":903}," },",[893,3117,3118],{"class":1002}," role",[893,3120,1006],{"class":903},[893,3122,933],{"class":903},[893,3124,2741],{"class":936},[893,3126,1072],{"class":903},[893,3128,911],{"class":903},[893,3130,2669],{"class":1002},[893,3132,1006],{"class":903},[893,3134,3059],{"class":907},[893,3136,927],{"class":903},[893,3138,1044],{"class":1002},[893,3140,3142,3145],{"class":895,"line":3141},23,[893,3143,3144],{"class":903},"    }",[893,3146,1222],{"class":903},[893,3148,3150],{"class":895,"line":3149},24,[893,3151,2085],{"class":907},[691,3153,3154,3198,3219,3242,3423,3462,3486,3496,3507,3531,3545,3581,3591,3619,3628,3633,3691],{},[694,3155,3156,3159,3160,3162,3163,1134,3166,3169,3170,3173,3174,3176,3177,3180,3181,669,3184,3187,3188,3190,3191,3194,3195,3197],{},[1481,3157,3158],{},"Roles"," have short names (",[623,3161,2741],{},"); SHADE stores them as ",[623,3164,3165],{},"\u003Cplugin>:\u003Crole>",[623,3167,3168],{},"repairs:mechanic","), so two\nmodules never share one. Each has only ",[623,3171,3172],{},"can"," (its abilities: short keys joined by dots, ",[623,3175,2692],{},"), ",[623,3178,3179],{},"includes","\n(lower roles whose abilities it has too), ",[623,3182,3183],{},"scope",[623,3185,3186],{},"default",". No names that are prototype members, at\nmost 50 roles, 100 abilities a role and 50 names in ",[623,3189,3179],{}," or in one give grant. ",[623,3192,3193],{},"validateModule"," refuses an unknown\nrole, a cycle of ",[623,3196,3179],{}," and anything else, naming it.",[694,3199,3200,1134,3203,3206,3207,3210,3211,3214,3215,3218],{},[1481,3201,3202],{},"A default role",[623,3204,3205],{},"default: true",") is every signed-in account's, without anyone giving it: every account with a\nconfirmed address has it while the module is loaded. Use it for what any customer may do, such as seeing their own\nbookings (",[623,3208,3209],{},"customer: { default: true, can: ['bookings.own'] }",", with ",[623,3212,3213],{},"auth: { account: 'bookings.own' }"," on the\nroute). It has no scope, gives no roles and includes no role with a scope or one that gives roles; no role gives\nit, and admins don't see it in the roles they can give. Other roles may include it. Making a role the default is a\nnew consent line (",[623,3216,3217],{},"customer for every account","), so the update asks again. Experimental until a second module\nuses it.",[694,3220,3221,3224,3225,3228,3229,3232,3233,3235,3236,3238,3239,3241],{},[1481,3222,3223],{},"A profile table"," keeps what the module knows about an account, one row per account: ",[623,3226,3227],{},"accounts: { profile: { table: 'repairs_profiles', column: 'account_id' } }",". The table is one of the plugin's own (its SQL name, in ",[623,3230,3231],{},"db.tables","),\nand the column a ",[623,3234,2147],{}," that is unique and not null (the primary key, say); the table refers to accounts\nthrough no other column. SHADE finds and exports the row with the account's data and erases it with the account,\nso no ",[623,3237,2175],{}," source of the module's lists it. Read and write it on account routes with ",[623,3240,2127],{},". Never keep sign-in data there, and nothing about people without an account. Experimental until a\nsecond module uses it.",[694,3243,3244,3249,3250,3253,3254,3257,3258,3261,3262,3265,3266,3268,3269,3272,3273],{},[1481,3245,3246],{},[623,3247,3248],{},"scope: 'organisation'"," is SHADE's own scope kind (decision 0009): the role is given in one\n",[683,3251,3252],{"href":234},"organisation",", to one of its members, and leaving the\norganisation ends it. No table of the module's is needed (a table named ",[623,3255,3256],{},"\u003Cplugin>_organisation"," is never the scope).\n",[623,3259,3260],{},"givenByRank: 'manager'"," lets the organisation's owners and managers give and take the role there, ",[623,3263,3264],{},"'owner'"," its\nowners only; without it, only the team (and a role's ",[623,3267,2775],{},") gives it. An owner or manager never\ngives a role to themselves. The site reaches this through the account API's\n",[623,3270,3271],{},"\u002Fapi\u002Fv1\u002Faccount\u002Forganisations\u002F{id}\u002Froles",". Experimental until a second module uses it.",[884,3274,3276],{"className":886,"code":3275,"language":888,"meta":889,"style":889},"accounts: {\n  roles: {\n    viewer: { scope: 'organisation', can: ['orders.read'], givenByRank: 'manager' },\n    approver: { scope: 'organisation', includes: ['viewer'], can: ['orders.approve'], givenByRank: 'owner' }\n  }\n}\n",[623,3277,3278,3286,3295,3347,3415,3419],{"__ignoreMap":889},[893,3279,3280,3282,3284],{"class":895,"line":896},[893,3281,2520],{"class":1061},[893,3283,1006],{"class":903},[893,3285,1151],{"class":903},[893,3287,3288,3291,3293],{"class":895,"line":943},[893,3289,3290],{"class":1061},"  roles",[893,3292,1006],{"class":903},[893,3294,1151],{"class":903},[893,3296,3297,3300,3302,3304,3306,3308,3310,3312,3314,3316,3318,3320,3322,3324,3327,3329,3331,3333,3336,3338,3340,3343,3345],{"class":895,"line":967},[893,3298,3299],{"class":1061},"    viewer",[893,3301,1006],{"class":903},[893,3303,904],{"class":903},[893,3305,2669],{"class":1061},[893,3307,1006],{"class":903},[893,3309,933],{"class":903},[893,3311,3252],{"class":936},[893,3313,1072],{"class":903},[893,3315,911],{"class":903},[893,3317,2683],{"class":1061},[893,3319,1006],{"class":903},[893,3321,2194],{"class":1002},[893,3323,1072],{"class":903},[893,3325,3326],{"class":936},"orders.read",[893,3328,1072],{"class":903},[893,3330,2746],{"class":1002},[893,3332,911],{"class":903},[893,3334,3335],{"class":1061}," givenByRank",[893,3337,1006],{"class":903},[893,3339,933],{"class":903},[893,3341,3342],{"class":936},"manager",[893,3344,1072],{"class":903},[893,3346,1351],{"class":903},[893,3348,3349,3352,3354,3356,3358,3360,3362,3364,3366,3368,3370,3372,3374,3376,3379,3381,3383,3385,3387,3389,3391,3393,3396,3398,3400,3402,3404,3406,3408,3411,3413],{"class":895,"line":974},[893,3350,3351],{"class":1061},"    approver",[893,3353,1006],{"class":903},[893,3355,904],{"class":903},[893,3357,2669],{"class":1061},[893,3359,1006],{"class":903},[893,3361,933],{"class":903},[893,3363,3252],{"class":936},[893,3365,1072],{"class":903},[893,3367,911],{"class":903},[893,3369,2732],{"class":1061},[893,3371,1006],{"class":903},[893,3373,2194],{"class":1002},[893,3375,1072],{"class":903},[893,3377,3378],{"class":936},"viewer",[893,3380,1072],{"class":903},[893,3382,2746],{"class":1002},[893,3384,911],{"class":903},[893,3386,2683],{"class":1061},[893,3388,1006],{"class":903},[893,3390,2194],{"class":1002},[893,3392,1072],{"class":903},[893,3394,3395],{"class":936},"orders.approve",[893,3397,1072],{"class":903},[893,3399,2746],{"class":1002},[893,3401,911],{"class":903},[893,3403,3335],{"class":1061},[893,3405,1006],{"class":903},[893,3407,933],{"class":903},[893,3409,3410],{"class":936},"owner",[893,3412,1072],{"class":903},[893,3414,1222],{"class":903},[893,3416,3417],{"class":895,"line":1047},[893,3418,1234],{"class":903},[893,3420,3421],{"class":895,"line":1052},[893,3422,1240],{"class":903},[694,3424,3425,813,3428,3431,3432,2172,3434,3436,3437,3439,3440,3443,3444,3446,3447,3449,3450,3453,3454,3457,3458,3461],{},[1481,3426,3427],{},"An organisation's rows.",[623,3429,3430],{},"organisationReference(name)"," is a column for a row the organisation owns; it goes with\nthe organisation (on delete cascade), never with one person. The table must be in the ",[623,3433,2171],{},[623,3435,2175],{}," sources, or the module does not load: its ",[623,3438,2135],{}," gives a person the rows of their organisations\n(",[623,3441,3442],{},"ownedByOrganisation(column, { email })","), and its ",[623,3445,2384],{}," says they are the organisation's (or its ",[623,3448,2138],{},"\ndeletes them). For a row the law keeps, such as an order, use ",[623,3451,3452],{},"organisationReference(name, { keep: true })",": the column\nbecomes null when the organisation is deleted, so copy what the row must still say, such as its name. On account routes,\n",[623,3455,3456],{},"ownedByOrganisation(column, request.account, 'orders.read')"," is the where-clause for the rows of the account's\norganisations where its role per organisation gives the ability. Deleting an organisation first shows the team or\nthe owner how many rows each module keeps for it. Core's ",[623,3459,3460],{},"organisation-probe"," fixture is a small, complete example.",[694,3463,3464,3467,3468,3471,3472,3475,3476,3478,3479,3482,3483,3485],{},[1481,3465,3466],{},"A scope"," is one of the module's own tables, named without its prefix: ",[623,3469,3470],{},"scope: 'workshops'"," is\n",[623,3473,3474],{},"repairs_workshops",", which must be in ",[623,3477,3231],{}," and have an ",[623,3480,3481],{},"id"," column. A scoped role is given for one row\n(a workshop), checked to exist. One scope per role, no more nesting. Roles given per different tables never\ninclude each other, and one ability is given per one table only (a role without a scope may give it too), so\n",[623,3484,2947],{}," never reads a team's id as a workshop's.",[694,3487,3488,3491,3492,3495],{},[1481,3489,3490],{},"Changing a scope in an update"," (adding one, naming another table, removing it) leaves existing memberships\nof that role giving nothing: SHADE counts a membership only while it fits the role as declared now. The admin\nsees them marked in the account's Roles dialog and gives the role again. Removing a scope is a new consent line\n(",[623,3493,3494],{},"mechanic everywhere","), so the update asks again.",[694,3497,3498,3503,3504,3506],{},[1481,3499,3500],{},[623,3501,3502],{},"{ ability: 'accounts.roles.give', roles: [...] }"," in ",[623,3505,3172],{}," names the roles its members may give and take: only roles it includes, never itself or a role\nbeside or above it. A scoped role gives roles of the same scope, in the scopes where the member has it. Abilities stay their\nown namespace, apart from core's actions.",[694,3508,3509,3511,3512,3515,3516,3519,3520,3522,3523,3526,3527,3530],{},[1481,3510,463],{}," need an ability with ",[623,3513,3514],{},"auth: { account: '\u003Cability>' }",": SHADE answers 403 (\"Your account roles do not allow\nthis\") unless one of the account's roles gives it, reading the memberships on every request (one query), so a role\ntaken away counts at once. The handler gets ",[623,3517,3518],{},"request.account.roles",": each ",[623,3521,2112],{},", with its scope\n(",[623,3524,3525],{},"null"," without one) and every ability it gives. A plain ",[623,3528,3529],{},"auth: 'account'"," route gets the roles too, without a check.",[694,3532,3533,3538,3539,3541,3542,3544],{},[1481,3534,3535],{},[623,3536,3537],{},"inScope(column, account, ability)"," is the where-clause for rows in the scopes where the account has the\nability, beside ",[623,3540,1901],{},". Use it on every query of a scoped route: the route's ability alone lets a mechanic of\none workshop through, ",[623,3543,2947],{}," keeps them to their workshop's rows. Only memberships with a scope count; without\none it matches no row, without an account it throws UNAUTHORIZED. On a uuid column a scope that is no uuid matches\nno row.",[694,3546,3547,3552,3553,3556,3557,1549,3559,3561,3562,630,3565,3567,3568,669,3570,3573,3574,3576,3577,3580],{},[1481,3548,3549],{},[623,3550,3551],{},"assignAccountRole(ctx, by, { account, role, scope, take })"," is the only way a module gives or takes a role: ",[623,3554,3555],{},"by","\nis ",[623,3558,2096],{},[623,3560,665],{}," names the account (",[623,3563,3564],{},"{ id }",[623,3566,2131],{},"), then the role, its ",[623,3569,3183],{},[623,3571,3572],{},"take",".\nSHADE reads the giver's roles itself and refuses (FORBIDDEN) another module's role, one none of their roles\ncan give, a scope where they don't have that role, and their own roles; an account without a confirmed address is\nNOT_FOUND. It works only on an account route, with the context SHADE gave that request, and only as the account\nwho called it: ",[623,3575,3555],{}," naming anyone else (an id from the request body) is FORBIDDEN, and so is any call from a job,\na public route or a session route. Audited as ",[623,3578,3579],{},"accounts.roles","; giving a role that can give others raises a\nsecurity alert.",[694,3582,3583,3590],{},[1481,3584,3585,3586,3589],{},"Never write ",[623,3587,3588],{},"account_roles"," yourself."," It is core's table, outside the SDK; nothing stops a trusted\nmodule's raw SQL, but nothing then checks, audits or alerts either (\"What this is not\").",[694,3592,3593,3596,3597,1549,3600,3603,3604,3607,3608,3611,3612,3615,3616,629],{},[1481,3594,3595],{},"On the consent",": each role, its scope, every ability (with its included roles') and what it can give, a line\neach (",[623,3598,3599],{},"role foreman per workshops",[623,3601,3602],{},"role foreman can give mechanic","; a role without a scope is\n",[623,3605,3606],{},"role customer everywhere","), and each account route with the ability it needs (",[623,3609,3610],{},"GET \u002Fworkshop\u002Fjobs (jobs.read)","). An\nupdate that adds a role or an ability, changes or removes a scope, or widens what it can give, asks again. Packages signed\nbefore the rename say ",[623,3613,3614],{},"assigns"," on that line; SHADE reads it as ",[623,3617,3618],{},"can give",[694,3620,3621,3624,3625,3627],{},[1481,3622,3623],{},"Admins"," give and take roles on the Accounts screen (",[623,3626,3579],{},"); uninstalling the module removes its\nroles (they are in its backup). Memberships are personal data, registered by SHADE.",[694,3629,3630,3632],{},[1481,3631,337],{}," have no account roles.",[694,3634,3635,3638,3639,1134,3642,3645,3646,669,3648,1549,3651,3654,3655,3657,3658,3660,3661,3664,3665,3668,3669,1549,3672,3675,3676,3679,3680,3682,3683,3686,3687,3690],{},[1481,3636,3637],{},"Tests",": insert memberships with ",[623,3640,3641],{},"tables.accountRoles",[623,3643,3644],{},"@shadestack\u002Fmodule-sdk\u002Ftesting","; a scoped one with\nits ",[623,3647,3183],{},[623,3649,3650],{},"scopeTable",[623,3652,3653],{},"'locations'",") and hand your services a ",[623,3656,2096],{}," with its ",[623,3659,2103],{},"; a service\nthat gives roles gets ",[623,3662,3663],{},"accountRouteContext(moduleContext(ctx, '\u003Cname>'), account)",", the context an account route of\nyour module gets for that account, as the appointments module's ",[623,3666,3667],{},"server\u002Fservice.test.ts"," does. The testing entry is\nfor tests only (",[623,3670,3671],{},"*.test.ts",[623,3673,3674],{},"e2e\u002F",", helpers only they import): ",[623,3677,3678],{},"shade-module build"," refuses a module whose shipped\ncode (the server bundle, the site, shared and admin sources) imports ",[623,3681,3644],{}," or\n",[623,3684,3685],{},"test-database",", and on an instance a server package's ",[623,3688,3689],{},"import()"," of either fails however the name is written\n(the API's module hooks).",[694,3692,3693,3696,3697,3700],{},[1481,3694,3695],{},"Another module's code"," that runs during your account route's request (a save check of an entry it saved) gets no\naccount: the request's account is bound to the module whose route it is, so its ",[623,3698,3699],{},"assignAccountRole"," is FORBIDDEN, as in a job.\nThe events your route causes are heard later, on the worker, with no account either.",[3702,3703,3705],"h2",{"id":3704},"raw-bodies-and-webhooks","Raw bodies and webhooks",[619,3707,3708,3711,3712,3715,3716,630,3719,3721,3722,3725,3726,629],{},[623,3709,3710],{},"request.body"," is the body parsed as JSON when the request says it is JSON (",[623,3713,3714],{},"Content-Type: application\u002Fjson",";\nmalformed JSON is refused with VALIDATION), and undefined otherwise. Routes that need the unparsed body (form-encoded\nwebhooks, signature checks) set ",[623,3717,3718],{},"rawBody: true",[623,3720,778],{},"; the handler then gets ",[623,3723,3724],{},"request.rawBody",". Never trust a webhook body: re-fetch the resource from the provider. How SHADE checks a webhook, and how to verify one a provider\ndoesn't sign by fetching back, is in ",[683,3727,486],{"href":487},[3702,3729,3731],{"id":3730},"outside-hosts","Outside hosts",[619,3733,3734,3735,3738,3739,1549,3742,1549,3745,1549,3748,1549,3751,1549,3754,1075,3757,2116,3760,3763,3764,3767,3768,3770,3771,3774,3775,3777,3778,3781,3782,3785,3786,3789,3790,3793,3794,3797,3798,630,3801,3804,3805,629],{},"The admin and the site only load from SHADE's own origins (Content-Security-Policy). A module that embeds something\nfrom elsewhere declares the hosts, by kind: ",[623,3736,3737],{},"allowedSources: { site: { frame: ['https:\u002F\u002Fmaps.example.com'] }, admin: { img: ['https:\u002F\u002Ftiles.example.com'] } }"," (kinds ",[623,3740,3741],{},"img",[623,3743,3744],{},"media",[623,3746,3747],{},"frame",[623,3749,3750],{},"connect",[623,3752,3753],{},"script",[623,3755,3756],{},"style",[623,3758,3759],{},"font",[623,3761,3762],{},"https:\u002F\u002F"," host names only, ",[623,3765,3766],{},"*."," for subdomains except for ",[623,3769,3753],{},", where a wildcard could be any tenant of a\nshared host such as ",[623,3772,3773],{},"*.github.io","). The site allows them while the module is on; see\n",[683,3776,265],{"href":266},". They are the ",[623,3779,3780],{},"allowedSources"," capability, on the\nconsent. The hosts its server code calls are the ",[623,3783,3784],{},"network"," capability: ",[623,3787,3788],{},"network: { hosts: ['api.example.com'] }",", or\n",[623,3791,3792],{},"fromSettings: ['buildHookUrl']"," for a host an admin sets (trusted modules only). Its server code calls them with\n",[623,3795,3796],{},"moduleFetch(ctx, url, init)",", never Node's ",[623,3799,3800],{},"fetch",[623,3802,3803],{},"node:https",": https only, public addresses only, redirects\nchecked, 10 seconds and 5 MB. See ",[683,3806,3807],{"href":414},"Network",[3756,3809,3810],{},"html pre.shiki code .s7zQu, html code.shiki .s7zQu{--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#89DDFF;--shiki-default-font-style:italic;--shiki-dark:#89DDFF;--shiki-dark-font-style:italic}html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}html pre.shiki code .spNyl, html code.shiki .spNyl{--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA}html pre.shiki code .s2Zo4, html code.shiki .s2Zo4{--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF}html pre.shiki code .swJcz, html code.shiki .swJcz{--shiki-light:#E53935;--shiki-default:#F07178;--shiki-dark:#F07178}html pre.shiki code .sbssI, html code.shiki .sbssI{--shiki-light:#F76D47;--shiki-default:#F78C6C;--shiki-dark:#F78C6C}html pre.shiki code .sBMFI, html code.shiki .sBMFI{--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B}html pre.shiki code .sHdIc, html code.shiki .sHdIc{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#EEFFFF;--shiki-default-font-style:italic;--shiki-dark:#BABED8;--shiki-dark-font-style:italic}html pre.shiki code .sHwdD, html code.shiki .sHwdD{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#546E7A;--shiki-default-font-style:italic;--shiki-dark:#676E95;--shiki-dark-font-style:italic}html pre.shiki code .sfNiH, html code.shiki .sfNiH{--shiki-light:#FF5370;--shiki-default:#FF9CAC;--shiki-dark:#FF9CAC}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":889,"searchDepth":943,"depth":943,"links":3812},[3813,3814,3815,3816,3817,3818],{"id":859,"depth":967,"text":791},{"id":1250,"depth":967,"text":825},{"id":1616,"depth":967,"text":837},{"id":2513,"depth":967,"text":2514},{"id":3704,"depth":943,"text":3705},{"id":3730,"depth":943,"text":3731},"md",null,{},{"title":463,"description":889},"VwUJWty1Bw5Xxczw8tEa7NjrpgivKYTEogw3D2yoNUE",[3825,3826],{"title":459,"path":460,"stem":461,"description":889,"children":-1},{"title":467,"path":468,"stem":469,"description":889,"children":-1},1796500155638]