[{"data":1,"prerenderedAt":12062},["ShallowReactive",2],{"navigation_docs":3,"-developers-modules-background-and-services":613,"-developers-modules-background-and-services-surround":12059},[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":474,"body":615,"description":780,"extension":12054,"links":12055,"meta":12056,"navigation":2202,"path":475,"seo":12057,"stem":476,"__hash__":12058},"docs\u002F4.developers\u002F3.modules\u002F6.background-and-services.md",{"type":616,"value":617,"toc":12005},"minimark",[618,623,644,774,962,992,1066,1069,1072,1112,1144,1151,1162,1341,1430,1434,1445,1771,1871,1877,1932,1938,1957,1973,1979,1989,2098,2131,2135,2141,2504,2545,2549,2556,2929,2984,2988,2994,3156,3179,3183,3190,3487,3646,3649,3692,3696,3720,3871,4028,4032,4055,4059,4070,4279,4286,4310,4313,4351,4355,4379,4383,4402,4406,4417,4620,4659,4662,4666,4695,4793,4813,4817,4848,4918,4937,4941,4946,5050,5071,5075,5092,5096,5099,5406,5581,5587,5591,5605,6050,6094,6098,6113,6429,6437,6454,6476,6480,6483,6500,7101,7223,7226,7249,7533,7633,7657,7661,7699,7703,7709,8012,8063,8067,8077,8235,8266,8270,8280,8531,8647,8651,8654,8932,8998,9002,9005,9213,9385,9388,9394,9619,9689,9693,9696,9956,9986,9990,9997,10443,10465,10469,10472,10716,10748,10752,10758,11112,11172,11176,11199,11210,11214,11217,11366,11396,11400,11407,11415,11555,11647,11651,11660,11664,11685,11903,11916,11918,11931,11953,11973,12001],[619,620,622],"h2",{"id":621},"cores-events","Core's events",[624,625,626,627,635,636,639,640,643],"p",{},"A module hears a committed change by listing core's event in the manifest part ",[628,629,631],"a",{"href":630},"#hearing-events-on",[632,633,634],"code",{},"on",", with the ",[632,637,638],{},"subscribe"," capability. A handler gets the event, with its data in ",[632,641,642],{},"event.data",":",[645,646,647,661],"table",{},[648,649,650],"thead",{},[651,652,653,657],"tr",{},[654,655,656],"th",{},"Event",[654,658,659],{},[632,660,642],{},[662,663,664,697,714,732,745,761],"tbody",{},[651,665,666,683],{},[667,668,669,672,673,672,676,672,679,682],"td",{},[632,670,671],{},"entries.entry.saved",", ",[632,674,675],{},".published",[632,677,678],{},".unpublished",[632,680,681],{},".deleted"," (to the trash)",[667,684,685,688,689,692,693,696],{},[632,686,687],{},"{ collection, entry }",": the entry at the version the event is about, or ",[632,690,691],{},"entry: null"," once that version is purged. The entry's id is ",[632,694,695],{},"event.subject.id",". Pages are a collection of the website module, so these cover pages too.",[651,698,699,704],{},[667,700,701],{},[632,702,703],{},"media.file.uploaded",[667,705,706,709,710,713],{},[632,707,708],{},"{ filename, mime, media }","; ",[632,711,712],{},"media"," is null once the item is gone",[651,715,716,721],{},[667,717,718],{},[632,719,720],{},"paths.addresses.moved",[667,722,723,726,727,731],{},[632,724,725],{},"{ moves, live }",": where published entries with an address moved, and the paths that are live now (see ",[628,728,730],{"href":729},"\u002Fdevelopers\u002Fmodules\u002Fcontent#where-entries-live-the-paths-part","Where entries live",")",[651,733,734,739],{},[667,735,736],{},[632,737,738],{},"packages.module.switched",[667,740,741,744],{},[632,742,743],{},"{ plugin, enabled, redirectItemsTo, itemPaths }",": a module was switched on or off, and where the admin sent its item pages while it is off. A module never hears its own switch-off.",[651,746,747,752],{},[667,748,749],{},[632,750,751],{},"team.member.email-changed",[667,753,754,757,758,760],{},[632,755,756],{},"{ from, to }"," (lower case; the member is ",[632,759,695],{},"). For a module whose own records hold the address. Experimental, full view only: there is no webhook view, because addresses are personal data.",[651,762,763,768],{},[667,764,765],{},[632,766,767],{},"packages.module.settings-changed",[667,769,770,773],{},[632,771,772],{},"{ plugin, changed }",": the names of the settings that changed, never their values",[775,776,781],"pre",{"className":777,"code":778,"language":779,"meta":780,"style":780},"language-ts shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","capabilities: { subscribe: {} },\non: {\n  'packages.module.settings-changed': async (ctx, event) => {\n    const { plugin, changed } = event.data\n    if (plugin === 'appointments' && changed.includes('reminderHours')) await replanReminders(ctx)\n  }\n}\n","ts","",[632,782,783,809,819,859,890,950,956],{"__ignoreMap":780},[784,785,788,792,795,798,801,803,806],"span",{"class":786,"line":787},"line",1,[784,789,791],{"class":790},"sBMFI","capabilities",[784,793,643],{"class":794},"sMK4o",[784,796,797],{"class":794}," {",[784,799,800],{"class":790}," subscribe",[784,802,643],{"class":794},[784,804,805],{"class":794}," {}",[784,807,808],{"class":794}," },\n",[784,810,812,814,816],{"class":786,"line":811},2,[784,813,634],{"class":790},[784,815,643],{"class":794},[784,817,818],{"class":794}," {\n",[784,820,822,825,828,831,835,839,842,846,849,852,854,857],{"class":786,"line":821},3,[784,823,824],{"class":794},"  '",[784,826,767],{"class":827},"sfazB",[784,829,830],{"class":794},"'",[784,832,834],{"class":833},"swJcz",": ",[784,836,838],{"class":837},"spNyl","async",[784,840,841],{"class":794}," (",[784,843,845],{"class":844},"sHdIc","ctx",[784,847,848],{"class":794},",",[784,850,851],{"class":844}," event",[784,853,731],{"class":794},[784,855,856],{"class":837}," =>",[784,858,818],{"class":794},[784,860,862,865,867,871,873,876,879,882,884,887],{"class":786,"line":861},4,[784,863,864],{"class":837},"    const",[784,866,797],{"class":794},[784,868,870],{"class":869},"sTEyZ"," plugin",[784,872,848],{"class":794},[784,874,875],{"class":869}," changed",[784,877,878],{"class":794}," }",[784,880,881],{"class":794}," =",[784,883,851],{"class":869},[784,885,886],{"class":794},".",[784,888,889],{"class":869},"data\n",[784,891,893,897,899,902,905,908,911,913,916,918,920,924,927,929,932,934,937,940,943,945,947],{"class":786,"line":892},5,[784,894,896],{"class":895},"s7zQu","    if",[784,898,841],{"class":833},[784,900,901],{"class":869},"plugin",[784,903,904],{"class":794}," ===",[784,906,907],{"class":794}," '",[784,909,910],{"class":827},"appointments",[784,912,830],{"class":794},[784,914,915],{"class":794}," &&",[784,917,875],{"class":869},[784,919,886],{"class":794},[784,921,923],{"class":922},"s2Zo4","includes",[784,925,926],{"class":833},"(",[784,928,830],{"class":794},[784,930,931],{"class":827},"reminderHours",[784,933,830],{"class":794},[784,935,936],{"class":833},")) ",[784,938,939],{"class":895},"await",[784,941,942],{"class":922}," replanReminders",[784,944,926],{"class":833},[784,946,845],{"class":869},[784,948,949],{"class":833},")\n",[784,951,953],{"class":786,"line":952},6,[784,954,955],{"class":794},"  }\n",[784,957,959],{"class":786,"line":958},7,[784,960,961],{"class":794},"}\n",[624,963,964,966,967,970,971,974,975,978,979,841,982,985,986,989,990,643],{},[632,965,642],{}," is typed for these events, so a handler reads it without a cast: ",[632,968,969],{},"EventPayloads"," from ",[632,972,973],{},"@shadestack\u002Fmodule-sdk\u002Fserver"," names each event's data, and ",[632,976,977],{},"EventPayload\u003C'paths.addresses.moved'>"," gives one. Written as an object, an entry names its ",[632,980,981],{},"delivery",[632,983,984],{},"{ handler, delivery: 'durable' }",") for its data to be typed. Another module's event reads as ",[632,987,988],{},"unknown",", unless that module adds its events to ",[632,991,969],{},[775,993,995],{"className":777,"code":994,"language":779,"meta":780,"style":780},"declare module '@shadestack\u002Fmodule-sdk\u002Fserver' {\n  interface EventPayloads {\n    'shop.order.paid': { order: string, totalCents: number }\n  }\n}\n",[632,996,997,1013,1023,1058,1062],{"__ignoreMap":780},[784,998,999,1002,1005,1007,1009,1011],{"class":786,"line":787},[784,1000,1001],{"class":837},"declare",[784,1003,1004],{"class":837}," module",[784,1006,907],{"class":794},[784,1008,973],{"class":827},[784,1010,830],{"class":794},[784,1012,818],{"class":794},[784,1014,1015,1018,1021],{"class":786,"line":811},[784,1016,1017],{"class":837},"  interface",[784,1019,1020],{"class":790}," EventPayloads",[784,1022,818],{"class":794},[784,1024,1025,1028,1031,1033,1035,1037,1040,1042,1045,1047,1050,1052,1055],{"class":786,"line":821},[784,1026,1027],{"class":794},"    '",[784,1029,1030],{"class":827},"shop.order.paid",[784,1032,830],{"class":794},[784,1034,643],{"class":794},[784,1036,797],{"class":794},[784,1038,1039],{"class":833}," order",[784,1041,643],{"class":794},[784,1043,1044],{"class":790}," string",[784,1046,848],{"class":794},[784,1048,1049],{"class":833}," totalCents",[784,1051,643],{"class":794},[784,1053,1054],{"class":790}," number",[784,1056,1057],{"class":794}," }\n",[784,1059,1060],{"class":786,"line":861},[784,1061,955],{"class":794},[784,1063,1064],{"class":786,"line":892},[784,1065,961],{"class":794},[624,1067,1068],{},"The types say what SHADE delivers; nothing checks them at delivery.",[624,1070,1071],{},"How handlers run:",[1073,1074,1075,1083,1099,1105],"ul",{},[1076,1077,1078,1082],"li",{},[1079,1080,1081],"strong",{},"On the worker, after the change."," The event is written with the change; each handler runs later on the worker, retried with backoff when it throws. A change that rolls back is never heard. A request that stops after its commit is still heard.",[1076,1084,1085,1088,1089,1092,1093,1095,1096,886],{},[1079,1086,1087],{},"As the module itself."," A handler acts as the module's own actor, with its ",[632,1090,1091],{},"uses",", never with the rights of the editor who caused the event. List what a handler does in ",[632,1094,1091],{},": a handler that asks for a rebuild needs ",[632,1097,1098],{},"rebuild.request",[1076,1100,1101,1104],{},[1079,1102,1103],{},"While the module is off"," its deliveries wait, and it hears them once it is on again.",[1076,1106,1107,1108,1111],{},"A handler that keeps failing shows on the Errors screen's failed deliveries, where an admin sends it again, and on the module's health card. Tests run deliveries with ",[632,1109,1110],{},"runQueuedJobs(ctx)"," from the testing entry.",[624,1113,1114,1117,1118,1121,1122,970,1125,1128,1129,1132,1133,1135,1136,1139,1140,1143],{},[632,1115,1116],{},"errors.error.reported"," is written right after an error is stored in the error log, without being waited for. Its data is ",[632,1119,1120],{},"{ group, occurrence: 'new' | 'reopened' | 'repeat' }",": the group (",[632,1123,1124],{},"ErrorGroup",[632,1126,1127],{},"@shadestack\u002Fcore\u002Fschema",") with its latest sample, already scrubbed of addresses and query strings. It is for a module that forwards errors to a server the client chose, which should keep site errors (",[632,1130,1131],{},"source: 'site'",") back unless the client turned them on. A handler that fails is only logged, never recorded again, so a broken forwarder cannot feed itself. The event is heard immediately only: in ",[632,1134,634],{},", give it as ",[632,1137,1138],{},"{ handler, delivery: 'immediate', repair }",". Untrusted modules never hear it. For the usual case, use ",[632,1141,1142],{},"errorForwarding"," below.",[1145,1146,1148,1149],"h3",{"id":1147},"forwarding-errors-errorforwarding","Forwarding errors: ",[632,1150,1142],{},[624,1152,1153,1154,1156,1157,1161],{},"The manifest part ",[632,1155,1142],{}," fits with SHADE's own ",[628,1158,1160],{"href":1159},"\u002Frun\u002Flogs#error-reporting","error reporting",": a trusted module answers per error whether it sent it.",[775,1163,1165],{"className":777,"code":1164,"language":779,"meta":780,"style":780},"errorForwarding: {\n  async forward(ctx, error) {\n    \u002F\u002F error: ReportedError — groupId, source, module, name, message, stack, requestId, version, reported, occurrence\n    const project = routeFor(error.source)            \u002F\u002F the module's own routing rules\n    if (!project) return 'declined'                   \u002F\u002F leave it to SHADE's own sending\n    await ctx.fetch(project.envelopeUrl, { method: 'POST', body: envelopeOf(error) })\n    return 'sent'\n  }\n}\n",[632,1166,1167,1175,1198,1204,1232,1259,1318,1331,1336],{"__ignoreMap":780},[784,1168,1169,1171,1173],{"class":786,"line":787},[784,1170,1142],{"class":790},[784,1172,643],{"class":794},[784,1174,818],{"class":794},[784,1176,1177,1180,1183,1185,1187,1189,1192,1195],{"class":786,"line":811},[784,1178,1179],{"class":869},"  async",[784,1181,1182],{"class":922}," forward",[784,1184,926],{"class":833},[784,1186,845],{"class":869},[784,1188,848],{"class":794},[784,1190,1191],{"class":869}," error",[784,1193,1194],{"class":833},") ",[784,1196,1197],{"class":794},"{\n",[784,1199,1200],{"class":786,"line":821},[784,1201,1203],{"class":1202},"sHwdD","    \u002F\u002F error: ReportedError — groupId, source, module, name, message, stack, requestId, version, reported, occurrence\n",[784,1205,1206,1208,1211,1213,1216,1218,1221,1223,1226,1229],{"class":786,"line":861},[784,1207,864],{"class":837},[784,1209,1210],{"class":869}," project",[784,1212,881],{"class":794},[784,1214,1215],{"class":922}," routeFor",[784,1217,926],{"class":833},[784,1219,1220],{"class":869},"error",[784,1222,886],{"class":794},[784,1224,1225],{"class":869},"source",[784,1227,1228],{"class":833},")            ",[784,1230,1231],{"class":1202},"\u002F\u002F the module's own routing rules\n",[784,1233,1234,1236,1238,1241,1244,1246,1249,1251,1254,1256],{"class":786,"line":892},[784,1235,896],{"class":895},[784,1237,841],{"class":833},[784,1239,1240],{"class":794},"!",[784,1242,1243],{"class":869},"project",[784,1245,1194],{"class":833},[784,1247,1248],{"class":895},"return",[784,1250,907],{"class":794},[784,1252,1253],{"class":827},"declined",[784,1255,830],{"class":794},[784,1257,1258],{"class":1202},"                   \u002F\u002F leave it to SHADE's own sending\n",[784,1260,1261,1264,1267,1269,1272,1274,1276,1278,1281,1283,1285,1288,1290,1292,1295,1297,1299,1302,1304,1307,1309,1311,1313,1316],{"class":786,"line":952},[784,1262,1263],{"class":895},"    await",[784,1265,1266],{"class":869}," ctx",[784,1268,886],{"class":794},[784,1270,1271],{"class":922},"fetch",[784,1273,926],{"class":833},[784,1275,1243],{"class":869},[784,1277,886],{"class":794},[784,1279,1280],{"class":869},"envelopeUrl",[784,1282,848],{"class":794},[784,1284,797],{"class":794},[784,1286,1287],{"class":833}," method",[784,1289,643],{"class":794},[784,1291,907],{"class":794},[784,1293,1294],{"class":827},"POST",[784,1296,830],{"class":794},[784,1298,848],{"class":794},[784,1300,1301],{"class":833}," body",[784,1303,643],{"class":794},[784,1305,1306],{"class":922}," envelopeOf",[784,1308,926],{"class":833},[784,1310,1220],{"class":869},[784,1312,1194],{"class":833},[784,1314,1315],{"class":794},"}",[784,1317,949],{"class":833},[784,1319,1320,1323,1325,1328],{"class":786,"line":958},[784,1321,1322],{"class":895},"    return",[784,1324,907],{"class":794},[784,1326,1327],{"class":827},"sent",[784,1329,1330],{"class":794},"'\n",[784,1332,1334],{"class":786,"line":1333},8,[784,1335,955],{"class":794},[784,1337,1339],{"class":786,"line":1338},9,[784,1340,961],{"class":794},[1073,1342,1343,1369,1408],{},[1076,1344,1345,1348,1349,1352,1353,1356,1357,1360,1361,1364,1365,1368],{},[1079,1346,1347],{},"The rule."," SHADE calls ",[632,1350,1351],{},"forward"," first, with a 5 second limit, when the module is on and loaded. ",[632,1354,1355],{},"'sent'"," ends it, and so does ",[632,1358,1359],{},"'kept'",": the module's own settings keep the error in the instance (for example a sample rate leaves it out), and SHADE sends nothing either. ",[632,1362,1363],{},"'declined'",", a throw or a timeout makes SHADE send the error itself to ",[632,1366,1367],{},"SHADE_ERROR_REPORTING_DSN",", when set. With the module off or failed to load, SHADE sends it. An error goes once. With no DSN, a declined error goes nowhere.",[1076,1370,1371,1374,1375,841,1378,1380,1381,1384,1385,1387,1388,1391,1392,1395,1396,1399,1400,1403,1404,1407],{},[1079,1372,1373],{},"What you get."," A ",[632,1376,1377],{},"ReportedError",[632,1379,973],{},"): the group's scrubbed fields and its id. ",[632,1382,1383],{},"error.reported === 'browser'"," means a browser wrote the text. SHADE calls ",[632,1386,1351],{}," for those only when the operator set ",[632,1389,1390],{},"SHADE_ERROR_REPORTING_SITE=true","; a module may narrow that with a setting of its own. To hide more before text leaves, call ",[632,1393,1394],{},"scrub(text, max, { strict: true })"," (experimental, same entry): it applies SHADE's scrubbing and also hides IBANs (",[632,1397,1398],{},"[iban]","), UUIDs (",[632,1401,1402],{},"[id]",") and long numbers such as phone, citizen and customer numbers (",[632,1405,1406],{},"[number:\u003Cdigits>]","), and keeps dates, times and Unix timestamps readable.",[1076,1409,1410,1413,1414,1417,1418,1421,1422,1425,1426,1429],{},[1079,1411,1412],{},"Who may."," One trusted module per instance: two with the part are refused at load, and an untrusted module cannot have it. It has no capability of its own; declare ",[632,1415,1416],{},"network"," for the hosts it calls, and send with ",[632,1419,1420],{},"moduleFetch(ctx, …)",". A host the client picks cannot be listed in the manifest: ",[632,1423,1424],{},"network: { hosts: [], fromSettings: ['server'] }"," allows the origin of that setting's current value (an address without a key in it, so a DSN cannot be that setting). ",[632,1427,1428],{},"shade-plugin-error-forwarding"," is the example. A failure is logged, never recorded again.",[619,1431,1433],{"id":1432},"schedules","Schedules",[624,1435,1436,1437,1440,1441,1444],{},"A schedule (",[632,1438,1439],{},"ModuleSchedule",") is a short name, when it runs, and ",[632,1442,1443],{},"run(ctx, signal)",". It runs by an interval or by a cron expression:",[775,1446,1448],{"className":777,"code":1447,"language":779,"meta":780,"style":780},"export default defineModule({\n  name: 'reports',\n  \u002F\u002F …\n  capabilities: { schedule: {} },\n  schedules: [\n    \u002F\u002F Every 15 minutes, at :00, :15, :30 and :45 on every instance.\n    { name: 'sync', intervalMs: 15 * 60_000, run: ctx => syncOrders(ctx) },\n    \u002F\u002F 03:00 every night in Amsterdam, whatever the site's time zone.\n    { name: 'nightly-report', cron: '0 3 * * *', timeZone: 'Europe\u002FAmsterdam', run: ctx => writeReport(ctx) },\n    \u002F\u002F 08:30 on weekdays, in the site's time zone (Settings → Site → Time zone).\n    { name: 'morning-digest', cron: '30 8 * * mon-fri', run: (ctx, signal) => sendDigest(ctx, signal) },\n    \u002F\u002F The first day of every quarter, at 06:00 in the site's time zone.\n    { name: 'quarterly', cron: '0 6 1 jan,apr,jul,oct *', run: ctx => closeQuarter(ctx) }\n  ]\n})\n",[632,1449,1450,1465,1482,1487,1505,1515,1520,1574,1579,1639,1645,1706,1712,1758,1764],{"__ignoreMap":780},[784,1451,1452,1455,1458,1461,1463],{"class":786,"line":787},[784,1453,1454],{"class":895},"export",[784,1456,1457],{"class":895}," default",[784,1459,1460],{"class":922}," defineModule",[784,1462,926],{"class":869},[784,1464,1197],{"class":794},[784,1466,1467,1470,1472,1474,1477,1479],{"class":786,"line":811},[784,1468,1469],{"class":833},"  name",[784,1471,643],{"class":794},[784,1473,907],{"class":794},[784,1475,1476],{"class":827},"reports",[784,1478,830],{"class":794},[784,1480,1481],{"class":794},",\n",[784,1483,1484],{"class":786,"line":821},[784,1485,1486],{"class":1202},"  \u002F\u002F …\n",[784,1488,1489,1492,1494,1496,1499,1501,1503],{"class":786,"line":861},[784,1490,1491],{"class":833},"  capabilities",[784,1493,643],{"class":794},[784,1495,797],{"class":794},[784,1497,1498],{"class":833}," schedule",[784,1500,643],{"class":794},[784,1502,805],{"class":794},[784,1504,808],{"class":794},[784,1506,1507,1510,1512],{"class":786,"line":892},[784,1508,1509],{"class":833},"  schedules",[784,1511,643],{"class":794},[784,1513,1514],{"class":869}," [\n",[784,1516,1517],{"class":786,"line":952},[784,1518,1519],{"class":1202},"    \u002F\u002F Every 15 minutes, at :00, :15, :30 and :45 on every instance.\n",[784,1521,1522,1525,1528,1530,1532,1535,1537,1539,1542,1544,1548,1551,1554,1556,1559,1561,1563,1565,1568,1571],{"class":786,"line":958},[784,1523,1524],{"class":794},"    {",[784,1526,1527],{"class":833}," name",[784,1529,643],{"class":794},[784,1531,907],{"class":794},[784,1533,1534],{"class":827},"sync",[784,1536,830],{"class":794},[784,1538,848],{"class":794},[784,1540,1541],{"class":833}," intervalMs",[784,1543,643],{"class":794},[784,1545,1547],{"class":1546},"sbssI"," 15",[784,1549,1550],{"class":794}," *",[784,1552,1553],{"class":1546}," 60_000",[784,1555,848],{"class":794},[784,1557,1558],{"class":922}," run",[784,1560,643],{"class":794},[784,1562,1266],{"class":844},[784,1564,856],{"class":837},[784,1566,1567],{"class":922}," syncOrders",[784,1569,1570],{"class":869},"(ctx) ",[784,1572,1573],{"class":794},"},\n",[784,1575,1576],{"class":786,"line":1333},[784,1577,1578],{"class":1202},"    \u002F\u002F 03:00 every night in Amsterdam, whatever the site's time zone.\n",[784,1580,1581,1583,1585,1587,1589,1592,1594,1596,1599,1601,1603,1606,1608,1610,1613,1615,1617,1620,1622,1624,1626,1628,1630,1632,1635,1637],{"class":786,"line":1338},[784,1582,1524],{"class":794},[784,1584,1527],{"class":833},[784,1586,643],{"class":794},[784,1588,907],{"class":794},[784,1590,1591],{"class":827},"nightly-report",[784,1593,830],{"class":794},[784,1595,848],{"class":794},[784,1597,1598],{"class":833}," cron",[784,1600,643],{"class":794},[784,1602,907],{"class":794},[784,1604,1605],{"class":827},"0 3 * * *",[784,1607,830],{"class":794},[784,1609,848],{"class":794},[784,1611,1612],{"class":833}," timeZone",[784,1614,643],{"class":794},[784,1616,907],{"class":794},[784,1618,1619],{"class":827},"Europe\u002FAmsterdam",[784,1621,830],{"class":794},[784,1623,848],{"class":794},[784,1625,1558],{"class":922},[784,1627,643],{"class":794},[784,1629,1266],{"class":844},[784,1631,856],{"class":837},[784,1633,1634],{"class":922}," writeReport",[784,1636,1570],{"class":869},[784,1638,1573],{"class":794},[784,1640,1642],{"class":786,"line":1641},10,[784,1643,1644],{"class":1202},"    \u002F\u002F 08:30 on weekdays, in the site's time zone (Settings → Site → Time zone).\n",[784,1646,1648,1650,1652,1654,1656,1659,1661,1663,1665,1667,1669,1672,1674,1676,1678,1680,1682,1684,1686,1689,1691,1693,1696,1699,1701,1704],{"class":786,"line":1647},11,[784,1649,1524],{"class":794},[784,1651,1527],{"class":833},[784,1653,643],{"class":794},[784,1655,907],{"class":794},[784,1657,1658],{"class":827},"morning-digest",[784,1660,830],{"class":794},[784,1662,848],{"class":794},[784,1664,1598],{"class":833},[784,1666,643],{"class":794},[784,1668,907],{"class":794},[784,1670,1671],{"class":827},"30 8 * * mon-fri",[784,1673,830],{"class":794},[784,1675,848],{"class":794},[784,1677,1558],{"class":922},[784,1679,643],{"class":794},[784,1681,841],{"class":794},[784,1683,845],{"class":844},[784,1685,848],{"class":794},[784,1687,1688],{"class":844}," signal",[784,1690,731],{"class":794},[784,1692,856],{"class":837},[784,1694,1695],{"class":922}," sendDigest",[784,1697,1698],{"class":869},"(ctx",[784,1700,848],{"class":794},[784,1702,1703],{"class":869}," signal) ",[784,1705,1573],{"class":794},[784,1707,1709],{"class":786,"line":1708},12,[784,1710,1711],{"class":1202},"    \u002F\u002F The first day of every quarter, at 06:00 in the site's time zone.\n",[784,1713,1715,1717,1719,1721,1723,1726,1728,1730,1732,1734,1736,1739,1741,1743,1745,1747,1749,1751,1754,1756],{"class":786,"line":1714},13,[784,1716,1524],{"class":794},[784,1718,1527],{"class":833},[784,1720,643],{"class":794},[784,1722,907],{"class":794},[784,1724,1725],{"class":827},"quarterly",[784,1727,830],{"class":794},[784,1729,848],{"class":794},[784,1731,1598],{"class":833},[784,1733,643],{"class":794},[784,1735,907],{"class":794},[784,1737,1738],{"class":827},"0 6 1 jan,apr,jul,oct *",[784,1740,830],{"class":794},[784,1742,848],{"class":794},[784,1744,1558],{"class":922},[784,1746,643],{"class":794},[784,1748,1266],{"class":844},[784,1750,856],{"class":837},[784,1752,1753],{"class":922}," closeQuarter",[784,1755,1570],{"class":869},[784,1757,961],{"class":794},[784,1759,1761],{"class":786,"line":1760},14,[784,1762,1763],{"class":869},"  ]\n",[784,1765,1767,1769],{"class":786,"line":1766},15,[784,1768,1315],{"class":794},[784,1770,949],{"class":869},[1073,1772,1773,1781,1848,1863],{},[1076,1774,1775,1780],{},[1079,1776,1777],{},[632,1778,1779],{},"intervalMs",": a whole number of milliseconds. The schedule is due at the multiples of its interval since 1970, the same moments on every instance: an hourly one at the top of each hour.",[1076,1782,1783,1788,1789,1792,1793,1796,1797,1792,1800,1803,1804,1807,1808,1811,1812,1814,1815,672,1818,1821,1822,1825,1826,1829,1830,672,1833,672,1836,1839,1840,1843,1844,1847],{},[1079,1784,1785],{},[632,1786,1787],{},"cron",": five fields: minute (0–59), hour (0–23), day of month (1–31), month (1–12 or ",[632,1790,1791],{},"jan","–",[632,1794,1795],{},"dec",") and day of week (0–7, 0 and 7 both Sunday, or ",[632,1798,1799],{},"sun",[632,1801,1802],{},"sat","). Each field is ",[632,1805,1806],{},"*",", a value, a range (",[632,1809,1810],{},"8-18","), a step after ",[632,1813,1806],{}," or a range (",[632,1816,1817],{},"*\u002F15",[632,1819,1820],{},"8-18\u002F2",") or a list of those (",[632,1823,1824],{},"1,15","). As in every cron, when both day of month and day of week are limited, either matching is enough. Six or seven fields, aliases such as ",[632,1827,1828],{},"@daily",", and ",[632,1831,1832],{},"L",[632,1834,1835],{},"W",[632,1837,1838],{},"#"," and ",[632,1841,1842],{},"?"," are refused when the module loads, with what is wrong. So is an expression that never runs (",[632,1845,1846],{},"0 0 31 2 *",").",[1076,1849,1850,1855,1856,1858,1859,1862],{},[1079,1851,1852],{},[632,1853,1854],{},"timeZone"," (cron only): an IANA name such as ",[632,1857,1619],{}," or ",[632,1860,1861],{},"UTC",". Without one the schedule runs in the site's time zone and follows a change of that setting from its next due time on. An unknown time zone is refused at load.",[1076,1864,1865,1866,1858,1868,1870],{},"Give ",[632,1867,1779],{},[632,1869,1787],{},", not both.",[624,1872,1873,1876],{},[1079,1874,1875],{},"The nights the clocks change."," A cron schedule runs by the wall clock of its time zone. In Europe\u002FAmsterdam the clocks jump from 02:00 to 03:00 on the last Sunday of March and go back from 03:00 to 02:00 on the last Sunday of October:",[645,1878,1879,1892],{},[648,1880,1881],{},[651,1882,1883,1886,1889],{},[654,1884,1885],{},"Schedule",[654,1887,1888],{},"Spring night (02:00 → 03:00)",[654,1890,1891],{},"Autumn night (03:00 → 02:00)",[662,1893,1894,1907,1919],{},[651,1895,1896,1901,1904],{},[667,1897,1898],{},[632,1899,1900],{},"30 2 * * *",[667,1902,1903],{},"02:30 doesn't exist: runs at 03:00",[667,1905,1906],{},"02:30 happens twice: runs once, the first time",[651,1908,1909,1914,1917],{},[667,1910,1911],{},[632,1912,1913],{},"0 4 * * *",[667,1915,1916],{},"04:00 as always",[667,1918,1916],{},[651,1920,1921,1926,1929],{},[667,1922,1923],{},[632,1924,1925],{},"*\u002F15 * * * *",[667,1927,1928],{},"02:00–02:45 don't exist: one run at 03:00, then 03:15…",[667,1930,1931],{},"02:00–02:45 run in the first hour only; the next run is 03:00 winter time",[624,1933,1934,1935,1937],{},"A schedule that runs every hour or more often pauses for the hour the clocks go back; use ",[632,1936,1779],{}," for work that must keep its pace through that night. A UTC schedule never meets a clock change.",[624,1939,1940,1941,1944,1945,1950,1951,1954,1955,886],{},"Schedules run on the worker container role (never admin or public), one run at a time across every worker container, each run one transaction, with ",[632,1942,1943],{},"via: 'cli'"," and the module's own actor: they may do what the manifest's ",[628,1946,1948],{"href":1947},"\u002Fdevelopers\u002Fmodules\u002Fmanifest#what-the-module-itself-may-do-uses",[632,1949,1091],{}," lists and nothing more. A due time is skipped while the previous run goes on, and a missed one (no worker running) is not caught up. ",[632,1952,1953],{},"signal"," aborts when the run's Redis lease is lost and another worker may take over: the run's transaction is then rolled back, so stop early and keep the work idempotent. See ",[628,1956,401],{"href":402},[624,1958,1959,1960,1963,1964,1966,1967,1970,1971,1847],{},"Schedules are the ",[632,1961,1962],{},"schedule"," capability. An untrusted module's run in its sandbox, at most 5 and never more often than every 15 minutes (",[628,1965,337],{"href":433},"). Declared optional, they skip their ticks while an admin leaves it off. Each schedule is a line of the capability, with its interval or its expression and time zone (",[632,1968,1969],{},"nightly-report (cron 0 3 * * * in Europe\u002FAmsterdam)","), so an update that changes either asks the admin again (",[628,1972,389],{"href":390},[619,1974,1976,1977],{"id":1975},"hearing-events-on","Hearing events: ",[632,1978,634],{},[624,1980,1981,1982,1984,1985,1988],{},"A trusted module hears core's events and other modules' in the manifest part ",[632,1983,634],{},", by their full names: core's events above, and what another module declares in ",[632,1986,1987],{},"emits",". A loyalty module giving points for a paid order:",[775,1990,1992],{"className":777,"code":1991,"language":779,"meta":780,"style":780},"export default defineModule({\n  name: 'points',\n  \u002F\u002F …\n  capabilities: { subscribe: {} },\n  on: {\n    'commerce.order.paid': async (ctx, event) => {\n      \u002F\u002F event: { id, name: 'commerce.order.paid', source: 'commerce', subject, at, causedBy, requestId, data: { … } }\n    }\n  }\n})\n",[632,1993,1994,2006,2021,2025,2041,2050,2078,2083,2088,2092],{"__ignoreMap":780},[784,1995,1996,1998,2000,2002,2004],{"class":786,"line":787},[784,1997,1454],{"class":895},[784,1999,1457],{"class":895},[784,2001,1460],{"class":922},[784,2003,926],{"class":869},[784,2005,1197],{"class":794},[784,2007,2008,2010,2012,2014,2017,2019],{"class":786,"line":811},[784,2009,1469],{"class":833},[784,2011,643],{"class":794},[784,2013,907],{"class":794},[784,2015,2016],{"class":827},"points",[784,2018,830],{"class":794},[784,2020,1481],{"class":794},[784,2022,2023],{"class":786,"line":821},[784,2024,1486],{"class":1202},[784,2026,2027,2029,2031,2033,2035,2037,2039],{"class":786,"line":861},[784,2028,1491],{"class":833},[784,2030,643],{"class":794},[784,2032,797],{"class":794},[784,2034,800],{"class":833},[784,2036,643],{"class":794},[784,2038,805],{"class":794},[784,2040,808],{"class":794},[784,2042,2043,2046,2048],{"class":786,"line":892},[784,2044,2045],{"class":833},"  on",[784,2047,643],{"class":794},[784,2049,818],{"class":794},[784,2051,2052,2054,2057,2059,2061,2064,2066,2068,2070,2072,2074,2076],{"class":786,"line":952},[784,2053,1027],{"class":794},[784,2055,2056],{"class":833},"commerce.order.paid",[784,2058,830],{"class":794},[784,2060,643],{"class":794},[784,2062,2063],{"class":837}," async",[784,2065,841],{"class":794},[784,2067,845],{"class":844},[784,2069,848],{"class":794},[784,2071,851],{"class":844},[784,2073,731],{"class":794},[784,2075,856],{"class":837},[784,2077,818],{"class":794},[784,2079,2080],{"class":786,"line":958},[784,2081,2082],{"class":1202},"      \u002F\u002F event: { id, name: 'commerce.order.paid', source: 'commerce', subject, at, causedBy, requestId, data: { … } }\n",[784,2084,2085],{"class":786,"line":1333},[784,2086,2087],{"class":794},"    }\n",[784,2089,2090],{"class":786,"line":1338},[784,2091,955],{"class":794},[784,2093,2094,2096],{"class":786,"line":1641},[784,2095,1315],{"class":794},[784,2097,949],{"class":869},[1073,2099,2100,2107,2110,2119,2122,2128],{},[1076,2101,2102,2103,2106],{},"Each event it hears is a line of its consent (",[632,2104,2105],{},"hears commerce.order.paid","): a new one asks again.",[1076,2108,2109],{},"It runs on the worker after the sender's change commits, as this module's own actor, retried with backoff (five more tries, from 30 seconds). After those it is on the Errors screen's failed deliveries and counts on its health card.",[1076,2111,2112,2114,2115,2118],{},[632,2113,1138],{}," runs it right after the commit instead, at most once and without a database, for something cheap whose loss ",[632,2116,2117],{},"repair"," says how to put right.",[1076,2120,2121],{},"A module hears at most 50 events, and never its own.",[1076,2123,2124,2125,886],{},"A listener is always optional: while the sender is off or not installed it hears nothing. A module that cannot work without the sender says so with ",[632,2126,2127],{},"requires",[1076,2129,2130],{},"It reaches nothing of the sender's beyond the event: no tables, settings or context.",[619,2132,2134],{"id":2133},"publishing-events","Publishing events",[624,2136,2137,2138,2140],{},"A trusted module says what happened once, for other modules and for webhooks, by declaring its events in the manifest part ",[632,2139,1987],{}," and emitting them in the transaction of the change they are about (experimental while the event bus is built):",[775,2142,2144],{"className":777,"code":2143,"language":779,"meta":780,"style":780},"import * as z from 'zod'\nimport { defineModule, emit, inTransaction } from '@shadestack\u002Fmodule-sdk\u002Fserver'\n\nexport default defineModule({\n  name: 'commerce',\n  \u002F\u002F …\n  emits: {\n    'order.paid': {\n      description: 'An order was paid',\n      data: z.object({ order: z.string(), total: z.number(), email: z.string() }),\n      \u002F\u002F What webhooks send: a public shape, or `true` for the data as it is. Left out: not sent to webhooks.\n      external: z.object({ order: z.string(), total: z.number() })\n    }\n  }\n})\n\nawait inTransaction(ctx, tx => emit(tx, 'order.paid', { type: 'order', id: order.id }, { order: order.number, total, email }))\n",[632,2145,2146,2169,2198,2204,2216,2231,2235,2244,2257,2273,2345,2350,2397,2401,2405,2411,2416],{"__ignoreMap":780},[784,2147,2148,2151,2153,2156,2159,2162,2164,2167],{"class":786,"line":787},[784,2149,2150],{"class":895},"import",[784,2152,1550],{"class":794},[784,2154,2155],{"class":895}," as",[784,2157,2158],{"class":869}," z ",[784,2160,2161],{"class":895},"from",[784,2163,907],{"class":794},[784,2165,2166],{"class":827},"zod",[784,2168,1330],{"class":794},[784,2170,2171,2173,2175,2177,2179,2182,2184,2187,2189,2192,2194,2196],{"class":786,"line":811},[784,2172,2150],{"class":895},[784,2174,797],{"class":794},[784,2176,1460],{"class":869},[784,2178,848],{"class":794},[784,2180,2181],{"class":869}," emit",[784,2183,848],{"class":794},[784,2185,2186],{"class":869}," inTransaction",[784,2188,878],{"class":794},[784,2190,2191],{"class":895}," from",[784,2193,907],{"class":794},[784,2195,973],{"class":827},[784,2197,1330],{"class":794},[784,2199,2200],{"class":786,"line":821},[784,2201,2203],{"emptyLinePlaceholder":2202},true,"\n",[784,2205,2206,2208,2210,2212,2214],{"class":786,"line":861},[784,2207,1454],{"class":895},[784,2209,1457],{"class":895},[784,2211,1460],{"class":922},[784,2213,926],{"class":869},[784,2215,1197],{"class":794},[784,2217,2218,2220,2222,2224,2227,2229],{"class":786,"line":892},[784,2219,1469],{"class":833},[784,2221,643],{"class":794},[784,2223,907],{"class":794},[784,2225,2226],{"class":827},"commerce",[784,2228,830],{"class":794},[784,2230,1481],{"class":794},[784,2232,2233],{"class":786,"line":952},[784,2234,1486],{"class":1202},[784,2236,2237,2240,2242],{"class":786,"line":958},[784,2238,2239],{"class":833},"  emits",[784,2241,643],{"class":794},[784,2243,818],{"class":794},[784,2245,2246,2248,2251,2253,2255],{"class":786,"line":1333},[784,2247,1027],{"class":794},[784,2249,2250],{"class":833},"order.paid",[784,2252,830],{"class":794},[784,2254,643],{"class":794},[784,2256,818],{"class":794},[784,2258,2259,2262,2264,2266,2269,2271],{"class":786,"line":1338},[784,2260,2261],{"class":833},"      description",[784,2263,643],{"class":794},[784,2265,907],{"class":794},[784,2267,2268],{"class":827},"An order was paid",[784,2270,830],{"class":794},[784,2272,1481],{"class":794},[784,2274,2275,2278,2280,2283,2285,2288,2290,2293,2295,2297,2299,2301,2304,2307,2309,2312,2314,2316,2318,2321,2323,2325,2328,2330,2332,2334,2336,2339,2341,2343],{"class":786,"line":1641},[784,2276,2277],{"class":833},"      data",[784,2279,643],{"class":794},[784,2281,2282],{"class":869}," z",[784,2284,886],{"class":794},[784,2286,2287],{"class":922},"object",[784,2289,926],{"class":869},[784,2291,2292],{"class":794},"{",[784,2294,1039],{"class":833},[784,2296,643],{"class":794},[784,2298,2282],{"class":869},[784,2300,886],{"class":794},[784,2302,2303],{"class":922},"string",[784,2305,2306],{"class":869},"()",[784,2308,848],{"class":794},[784,2310,2311],{"class":833}," total",[784,2313,643],{"class":794},[784,2315,2282],{"class":869},[784,2317,886],{"class":794},[784,2319,2320],{"class":922},"number",[784,2322,2306],{"class":869},[784,2324,848],{"class":794},[784,2326,2327],{"class":833}," email",[784,2329,643],{"class":794},[784,2331,2282],{"class":869},[784,2333,886],{"class":794},[784,2335,2303],{"class":922},[784,2337,2338],{"class":869},"() ",[784,2340,1315],{"class":794},[784,2342,731],{"class":869},[784,2344,1481],{"class":794},[784,2346,2347],{"class":786,"line":1647},[784,2348,2349],{"class":1202},"      \u002F\u002F What webhooks send: a public shape, or `true` for the data as it is. Left out: not sent to webhooks.\n",[784,2351,2352,2355,2357,2359,2361,2363,2365,2367,2369,2371,2373,2375,2377,2379,2381,2383,2385,2387,2389,2391,2393,2395],{"class":786,"line":1708},[784,2353,2354],{"class":833},"      external",[784,2356,643],{"class":794},[784,2358,2282],{"class":869},[784,2360,886],{"class":794},[784,2362,2287],{"class":922},[784,2364,926],{"class":869},[784,2366,2292],{"class":794},[784,2368,1039],{"class":833},[784,2370,643],{"class":794},[784,2372,2282],{"class":869},[784,2374,886],{"class":794},[784,2376,2303],{"class":922},[784,2378,2306],{"class":869},[784,2380,848],{"class":794},[784,2382,2311],{"class":833},[784,2384,643],{"class":794},[784,2386,2282],{"class":869},[784,2388,886],{"class":794},[784,2390,2320],{"class":922},[784,2392,2338],{"class":869},[784,2394,1315],{"class":794},[784,2396,949],{"class":869},[784,2398,2399],{"class":786,"line":1714},[784,2400,2087],{"class":794},[784,2402,2403],{"class":786,"line":1760},[784,2404,955],{"class":794},[784,2406,2407,2409],{"class":786,"line":1766},[784,2408,1315],{"class":794},[784,2410,949],{"class":869},[784,2412,2414],{"class":786,"line":2413},16,[784,2415,2203],{"emptyLinePlaceholder":2202},[784,2417,2419,2421,2423,2425,2427,2430,2432,2434,2437,2439,2441,2443,2445,2447,2449,2452,2454,2456,2459,2461,2463,2466,2468,2470,2472,2475,2478,2480,2482,2484,2486,2488,2490,2492,2494,2496,2499,2501],{"class":786,"line":2418},17,[784,2420,939],{"class":895},[784,2422,2186],{"class":922},[784,2424,1698],{"class":869},[784,2426,848],{"class":794},[784,2428,2429],{"class":844}," tx",[784,2431,856],{"class":837},[784,2433,2181],{"class":922},[784,2435,2436],{"class":869},"(tx",[784,2438,848],{"class":794},[784,2440,907],{"class":794},[784,2442,2250],{"class":827},[784,2444,830],{"class":794},[784,2446,848],{"class":794},[784,2448,797],{"class":794},[784,2450,2451],{"class":833}," type",[784,2453,643],{"class":794},[784,2455,907],{"class":794},[784,2457,2458],{"class":827},"order",[784,2460,830],{"class":794},[784,2462,848],{"class":794},[784,2464,2465],{"class":833}," id",[784,2467,643],{"class":794},[784,2469,1039],{"class":869},[784,2471,886],{"class":794},[784,2473,2474],{"class":869},"id ",[784,2476,2477],{"class":794},"},",[784,2479,797],{"class":794},[784,2481,1039],{"class":833},[784,2483,643],{"class":794},[784,2485,1039],{"class":869},[784,2487,886],{"class":794},[784,2489,2320],{"class":869},[784,2491,848],{"class":794},[784,2493,2311],{"class":869},[784,2495,848],{"class":794},[784,2497,2498],{"class":869}," email ",[784,2500,1315],{"class":794},[784,2502,2503],{"class":869},"))\n",[1073,2505,2506,2515,2522,2531,2538],{},[1076,2507,2508,2509,841,2512,2514],{},"It is emitted as ",[632,2510,2511],{},"\u003Cplugin>.\u003Cname>",[632,2513,2056],{},"), with an id, who caused it, the request and when. It exists exactly when the change commits.",[1076,2516,2517,2518,2521],{},"It is refused outside a transaction, for an event the module doesn't declare, for data that doesn't fit ",[632,2519,2520],{},"data"," or is over 64 KB (refer to what is large by its id), and as the ninth in a chain of events that subscribers emit while handling one another's (a loop).",[1076,2523,2524,2527,2528,1847],{},[632,2525,2526],{},"personal: true"," says its external shape holds personal data. Events are found and deleted with a person they name (",[628,2529,2530],{"href":270},"Privacy",[1076,2532,2533,2534,2537],{},"An event goes to webhooks while the module has the ",[632,2535,2536],{},"webhooks"," capability, in its external shape.",[1076,2539,2540,2541,2544],{},"Each event that reaches a durable subscriber counts toward the instance's queued-jobs limit, as a job does: at the limit, ",[632,2542,2543],{},"emit"," is refused (CONFLICT).",[619,2546,2548],{"id":2547},"jobs","Jobs",[624,2550,2551,2552,2555],{},"A job is work done later, once, on the worker, as the module's own actor: an invoice sent to a bookkeeping package after an order, a reminder at a set time. Trusted modules only, with the ",[632,2553,2554],{},"queue"," capability:",[775,2557,2559],{"className":777,"code":2558,"language":779,"meta":780,"style":780},"export default defineModule({\n  name: 'invoices',\n  \u002F\u002F …\n  capabilities: {\n    queue: { queues: { send: { retries: 4, backoffMs: 60_000, concurrency: 2 } }, data: { purpose: 'Invoices to send', personal: 'none' } }\n  },\n  jobs: [{\n    name: 'send',\n    run: async (ctx, { orderId }: { orderId: string }, { attempt, signal }) => { \u002F* throws to be tried again *\u002F },\n    giveUp: async (ctx, { orderId }, error) => { \u002F* say where it failed *\u002F }\n  }]\n})\n\n\u002F\u002F In the change's transaction (`withDb(ctx, tx)`), so it exists exactly when the change commits:\nawait enqueueJob(ctx, 'send', { orderId }, { runAt: inAnHour, key: `order:${orderId}` })\nawait cancelModuleJob(ctx, 'send', `order:${orderId}`)\n",[632,2560,2561,2573,2588,2592,2600,2692,2697,2709,2725,2779,2813,2821,2827,2831,2836,2898],{"__ignoreMap":780},[784,2562,2563,2565,2567,2569,2571],{"class":786,"line":787},[784,2564,1454],{"class":895},[784,2566,1457],{"class":895},[784,2568,1460],{"class":922},[784,2570,926],{"class":869},[784,2572,1197],{"class":794},[784,2574,2575,2577,2579,2581,2584,2586],{"class":786,"line":811},[784,2576,1469],{"class":833},[784,2578,643],{"class":794},[784,2580,907],{"class":794},[784,2582,2583],{"class":827},"invoices",[784,2585,830],{"class":794},[784,2587,1481],{"class":794},[784,2589,2590],{"class":786,"line":821},[784,2591,1486],{"class":1202},[784,2593,2594,2596,2598],{"class":786,"line":861},[784,2595,1491],{"class":833},[784,2597,643],{"class":794},[784,2599,818],{"class":794},[784,2601,2602,2605,2607,2609,2612,2614,2616,2619,2621,2623,2626,2628,2631,2633,2636,2638,2640,2642,2645,2647,2650,2652,2655,2658,2660,2662,2665,2667,2669,2672,2674,2676,2679,2681,2683,2686,2688,2690],{"class":786,"line":892},[784,2603,2604],{"class":833},"    queue",[784,2606,643],{"class":794},[784,2608,797],{"class":794},[784,2610,2611],{"class":833}," queues",[784,2613,643],{"class":794},[784,2615,797],{"class":794},[784,2617,2618],{"class":833}," send",[784,2620,643],{"class":794},[784,2622,797],{"class":794},[784,2624,2625],{"class":833}," retries",[784,2627,643],{"class":794},[784,2629,2630],{"class":1546}," 4",[784,2632,848],{"class":794},[784,2634,2635],{"class":833}," backoffMs",[784,2637,643],{"class":794},[784,2639,1553],{"class":1546},[784,2641,848],{"class":794},[784,2643,2644],{"class":833}," concurrency",[784,2646,643],{"class":794},[784,2648,2649],{"class":1546}," 2",[784,2651,878],{"class":794},[784,2653,2654],{"class":794}," },",[784,2656,2657],{"class":833}," data",[784,2659,643],{"class":794},[784,2661,797],{"class":794},[784,2663,2664],{"class":833}," purpose",[784,2666,643],{"class":794},[784,2668,907],{"class":794},[784,2670,2671],{"class":827},"Invoices to send",[784,2673,830],{"class":794},[784,2675,848],{"class":794},[784,2677,2678],{"class":833}," personal",[784,2680,643],{"class":794},[784,2682,907],{"class":794},[784,2684,2685],{"class":827},"none",[784,2687,830],{"class":794},[784,2689,878],{"class":794},[784,2691,1057],{"class":794},[784,2693,2694],{"class":786,"line":952},[784,2695,2696],{"class":794},"  },\n",[784,2698,2699,2702,2704,2707],{"class":786,"line":958},[784,2700,2701],{"class":833},"  jobs",[784,2703,643],{"class":794},[784,2705,2706],{"class":869}," [",[784,2708,1197],{"class":794},[784,2710,2711,2714,2716,2718,2721,2723],{"class":786,"line":1333},[784,2712,2713],{"class":833},"    name",[784,2715,643],{"class":794},[784,2717,907],{"class":794},[784,2719,2720],{"class":827},"send",[784,2722,830],{"class":794},[784,2724,1481],{"class":794},[784,2726,2727,2730,2732,2734,2736,2738,2740,2742,2745,2748,2750,2752,2754,2756,2758,2760,2763,2765,2767,2770,2772,2774,2777],{"class":786,"line":1338},[784,2728,2729],{"class":922},"    run",[784,2731,643],{"class":794},[784,2733,2063],{"class":837},[784,2735,841],{"class":794},[784,2737,845],{"class":844},[784,2739,848],{"class":794},[784,2741,797],{"class":794},[784,2743,2744],{"class":844}," orderId",[784,2746,2747],{"class":794}," }:",[784,2749,797],{"class":794},[784,2751,2744],{"class":833},[784,2753,643],{"class":794},[784,2755,1044],{"class":790},[784,2757,2654],{"class":794},[784,2759,797],{"class":794},[784,2761,2762],{"class":844}," attempt",[784,2764,848],{"class":794},[784,2766,1688],{"class":844},[784,2768,2769],{"class":794}," })",[784,2771,856],{"class":837},[784,2773,797],{"class":794},[784,2775,2776],{"class":1202}," \u002F* throws to be tried again *\u002F",[784,2778,808],{"class":794},[784,2780,2781,2784,2786,2788,2790,2792,2794,2796,2798,2800,2802,2804,2806,2808,2811],{"class":786,"line":1641},[784,2782,2783],{"class":922},"    giveUp",[784,2785,643],{"class":794},[784,2787,2063],{"class":837},[784,2789,841],{"class":794},[784,2791,845],{"class":844},[784,2793,848],{"class":794},[784,2795,797],{"class":794},[784,2797,2744],{"class":844},[784,2799,2654],{"class":794},[784,2801,1191],{"class":844},[784,2803,731],{"class":794},[784,2805,856],{"class":837},[784,2807,797],{"class":794},[784,2809,2810],{"class":1202}," \u002F* say where it failed *\u002F",[784,2812,1057],{"class":794},[784,2814,2815,2818],{"class":786,"line":1647},[784,2816,2817],{"class":794},"  }",[784,2819,2820],{"class":869},"]\n",[784,2822,2823,2825],{"class":786,"line":1708},[784,2824,1315],{"class":794},[784,2826,949],{"class":869},[784,2828,2829],{"class":786,"line":1714},[784,2830,2203],{"emptyLinePlaceholder":2202},[784,2832,2833],{"class":786,"line":1760},[784,2834,2835],{"class":1202},"\u002F\u002F In the change's transaction (`withDb(ctx, tx)`), so it exists exactly when the change commits:\n",[784,2837,2838,2840,2843,2845,2847,2849,2851,2853,2855,2857,2860,2862,2864,2867,2869,2872,2874,2877,2879,2882,2885,2888,2891,2894,2896],{"class":786,"line":1766},[784,2839,939],{"class":895},[784,2841,2842],{"class":922}," enqueueJob",[784,2844,1698],{"class":869},[784,2846,848],{"class":794},[784,2848,907],{"class":794},[784,2850,2720],{"class":827},[784,2852,830],{"class":794},[784,2854,848],{"class":794},[784,2856,797],{"class":794},[784,2858,2859],{"class":869}," orderId ",[784,2861,2477],{"class":794},[784,2863,797],{"class":794},[784,2865,2866],{"class":833}," runAt",[784,2868,643],{"class":794},[784,2870,2871],{"class":869}," inAnHour",[784,2873,848],{"class":794},[784,2875,2876],{"class":833}," key",[784,2878,643],{"class":794},[784,2880,2881],{"class":794}," `",[784,2883,2884],{"class":827},"order:",[784,2886,2887],{"class":794},"${",[784,2889,2890],{"class":869},"orderId",[784,2892,2893],{"class":794},"}`",[784,2895,878],{"class":794},[784,2897,949],{"class":869},[784,2899,2900,2902,2905,2907,2909,2911,2913,2915,2917,2919,2921,2923,2925,2927],{"class":786,"line":2413},[784,2901,939],{"class":895},[784,2903,2904],{"class":922}," cancelModuleJob",[784,2906,1698],{"class":869},[784,2908,848],{"class":794},[784,2910,907],{"class":794},[784,2912,2720],{"class":827},[784,2914,830],{"class":794},[784,2916,848],{"class":794},[784,2918,2881],{"class":794},[784,2920,2884],{"class":827},[784,2922,2887],{"class":794},[784,2924,2890],{"class":869},[784,2926,2893],{"class":794},[784,2928,949],{"class":869},[1073,2930,2931,2941,2947,2971,2974,2981],{},[1076,2932,2933,2936,2937,2940],{},[632,2934,2935],{},"runAt"," waits until then; ",[632,2938,2939],{},"key"," keeps one waiting job per key (the same key again replaces it).",[1076,2942,2943,2946],{},[632,2944,2945],{},"cancelModuleJob"," takes back a job that waits, including one that waits for its next try. A try running at that moment still ends. A replaced job is skipped the same way.",[1076,2948,2949,2950,2953,2954,2957,2958,2961,2962,2965,2966,2968,2969,886],{},"A try fails by throwing. It is tried again after ",[632,2951,2952],{},"backoffMs",", doubling to an hour, ",[632,2955,2956],{},"retries"," times. Then ",[632,2959,2960],{},"giveUp"," runs, and the job is in the error log and on the module's health card. A try longer than ",[632,2963,2964],{},"timeoutMs"," (default 30 s, at most 55 s) counts as failed: its ",[632,2967,1953],{}," aborts. A try that stopped the worker (out of memory, a crash) counts too, so a job that does that every time ends in ",[632,2970,2960],{},[1076,2972,2973],{},"While the module is switched off its jobs wait, kept and counted toward the queued-jobs limit, and run when it is on again. They are never given up for that.",[1076,2975,2976,2977,2980],{},"A job may run twice (a worker that died): ",[632,2978,2979],{},"run"," must be idempotent.",[1076,2982,2983],{},"Uninstalling the module removes its jobs that had not finished.",[1145,2985,2987],{"id":2986},"finishing-work-as-the-team-member-who-started-it","Finishing work as the team member who started it",[624,2989,2990,2991,2993],{},"A job runs as the module, with what its ",[632,2992,1091],{}," lists. Work a team member starts and a job finishes later, such as the rows of an import, should be done with the member's rights instead. A trusted module starts a member run in its session route and acts as the member from its job (experimental):",[775,2995,2997],{"className":777,"code":2996,"language":779,"meta":780,"style":780},"\u002F\u002F In the session route, for the team member signed in there with the cookie (FORBIDDEN on any other context: a token's\n\u002F\u002F call, a job, a schedule, another module's request).\nconst run = await startMemberRun(ctx)\nawait enqueueJob(ctx, 'batch', { importId, run })\n\n\u002F\u002F In the job, for each step: the member as they are now, with their role now.\nconst as = await actAsTeamMember(ctx, run)        \u002F\u002F FORBIDDEN once they are no longer active\nawait createEntry(as, slug, { data, note: 'Imported' })\n\n\u002F\u002F When the work is done.\nawait endMemberRun(ctx, run)\n",[632,2998,2999,3004,3009,3029,3061,3065,3070,3094,3133,3137,3142],{"__ignoreMap":780},[784,3000,3001],{"class":786,"line":787},[784,3002,3003],{"class":1202},"\u002F\u002F In the session route, for the team member signed in there with the cookie (FORBIDDEN on any other context: a token's\n",[784,3005,3006],{"class":786,"line":811},[784,3007,3008],{"class":1202},"\u002F\u002F call, a job, a schedule, another module's request).\n",[784,3010,3011,3014,3017,3020,3023,3026],{"class":786,"line":821},[784,3012,3013],{"class":837},"const",[784,3015,3016],{"class":869}," run ",[784,3018,3019],{"class":794},"=",[784,3021,3022],{"class":895}," await",[784,3024,3025],{"class":922}," startMemberRun",[784,3027,3028],{"class":869},"(ctx)\n",[784,3030,3031,3033,3035,3037,3039,3041,3044,3046,3048,3050,3053,3055,3057,3059],{"class":786,"line":861},[784,3032,939],{"class":895},[784,3034,2842],{"class":922},[784,3036,1698],{"class":869},[784,3038,848],{"class":794},[784,3040,907],{"class":794},[784,3042,3043],{"class":827},"batch",[784,3045,830],{"class":794},[784,3047,848],{"class":794},[784,3049,797],{"class":794},[784,3051,3052],{"class":869}," importId",[784,3054,848],{"class":794},[784,3056,3016],{"class":869},[784,3058,1315],{"class":794},[784,3060,949],{"class":869},[784,3062,3063],{"class":786,"line":892},[784,3064,2203],{"emptyLinePlaceholder":2202},[784,3066,3067],{"class":786,"line":952},[784,3068,3069],{"class":1202},"\u002F\u002F In the job, for each step: the member as they are now, with their role now.\n",[784,3071,3072,3074,3077,3079,3081,3084,3086,3088,3091],{"class":786,"line":958},[784,3073,3013],{"class":837},[784,3075,3076],{"class":869}," as ",[784,3078,3019],{"class":794},[784,3080,3022],{"class":895},[784,3082,3083],{"class":922}," actAsTeamMember",[784,3085,1698],{"class":869},[784,3087,848],{"class":794},[784,3089,3090],{"class":869}," run)        ",[784,3092,3093],{"class":1202},"\u002F\u002F FORBIDDEN once they are no longer active\n",[784,3095,3096,3098,3101,3104,3106,3109,3111,3113,3115,3117,3120,3122,3124,3127,3129,3131],{"class":786,"line":1333},[784,3097,939],{"class":895},[784,3099,3100],{"class":922}," createEntry",[784,3102,3103],{"class":869},"(as",[784,3105,848],{"class":794},[784,3107,3108],{"class":869}," slug",[784,3110,848],{"class":794},[784,3112,797],{"class":794},[784,3114,2657],{"class":869},[784,3116,848],{"class":794},[784,3118,3119],{"class":833}," note",[784,3121,643],{"class":794},[784,3123,907],{"class":794},[784,3125,3126],{"class":827},"Imported",[784,3128,830],{"class":794},[784,3130,878],{"class":794},[784,3132,949],{"class":869},[784,3134,3135],{"class":786,"line":1338},[784,3136,2203],{"emptyLinePlaceholder":2202},[784,3138,3139],{"class":786,"line":1641},[784,3140,3141],{"class":1202},"\u002F\u002F When the work is done.\n",[784,3143,3144,3146,3149,3151,3153],{"class":786,"line":1647},[784,3145,939],{"class":895},[784,3147,3148],{"class":922}," endMemberRun",[784,3150,1698],{"class":869},[784,3152,848],{"class":794},[784,3154,3155],{"class":869}," run)\n",[1073,3157,3158,3165,3172],{},[1076,3159,3160,3161,3164],{},"Call ",[632,3162,3163],{},"actAsTeamMember"," again for each step: a role changed meanwhile counts at once, so a step is refused exactly as the member's own save would be.",[1076,3166,3167,3168,3171],{},"A run is refused for a module that didn't start it, after ",[632,3169,3170],{},"endMemberRun",", and for an untrusted module. A module's runs go when it is uninstalled, a member's when the member is deleted.",[1076,3173,3174,3175,3178],{},"In a test, ",[632,3176,3177],{},"sessionRouteContext(moduleContext(ctx, name))"," (testing entry) is the context a session route gets.",[619,3180,3182],{"id":3181},"data-migrations","Data migrations",[624,3184,3185,3186,3189],{},"A data migration is work on the module's stored data done once, on the worker, a batch at a time: for example filling a column a new migration added from the old one, before a later version stops reading the old one. Admins see them as background tasks. Trusted modules only; an untrusted module with ",[632,3187,3188],{},"dataMigrations"," is refused. It needs no capability.",[775,3191,3193],{"className":777,"code":3192,"language":779,"meta":780,"style":780},"import { defineModule, type ModuleDataMigration } from '@shadestack\u002Fmodule-sdk\u002Fserver'\n\nconst prices: ModuleDataMigration = {\n  version: 1,\n  run: async (ctx, { cursor, signal }) => {\n    const after = typeof cursor === 'number' ? cursor : 0\n    \u002F\u002F One batch: up to 500 rows after the last one done, in id order.\n    const done = await fillPrices(ctx.db, after, 500)\n    return { cursor: done.lastId, done: done.count \u003C 500, processed: done.count, total: await countProducts(ctx.db) }\n  }\n}\n\nexport default defineModule({\n  name: 'shop',\n  \u002F\u002F …\n  dataMigrations: { prices }\n})\n",[632,3194,3195,3220,3224,3239,3251,3281,3314,3319,3353,3424,3428,3432,3436,3448,3463,3467,3481],{"__ignoreMap":780},[784,3196,3197,3199,3201,3203,3205,3207,3210,3212,3214,3216,3218],{"class":786,"line":787},[784,3198,2150],{"class":895},[784,3200,797],{"class":794},[784,3202,1460],{"class":869},[784,3204,848],{"class":794},[784,3206,2451],{"class":895},[784,3208,3209],{"class":869}," ModuleDataMigration",[784,3211,878],{"class":794},[784,3213,2191],{"class":895},[784,3215,907],{"class":794},[784,3217,973],{"class":827},[784,3219,1330],{"class":794},[784,3221,3222],{"class":786,"line":811},[784,3223,2203],{"emptyLinePlaceholder":2202},[784,3225,3226,3228,3231,3233,3235,3237],{"class":786,"line":821},[784,3227,3013],{"class":837},[784,3229,3230],{"class":869}," prices",[784,3232,643],{"class":794},[784,3234,3209],{"class":790},[784,3236,881],{"class":794},[784,3238,818],{"class":794},[784,3240,3241,3244,3246,3249],{"class":786,"line":861},[784,3242,3243],{"class":833},"  version",[784,3245,643],{"class":794},[784,3247,3248],{"class":1546}," 1",[784,3250,1481],{"class":794},[784,3252,3253,3256,3258,3260,3262,3264,3266,3268,3271,3273,3275,3277,3279],{"class":786,"line":892},[784,3254,3255],{"class":922},"  run",[784,3257,643],{"class":794},[784,3259,2063],{"class":837},[784,3261,841],{"class":794},[784,3263,845],{"class":844},[784,3265,848],{"class":794},[784,3267,797],{"class":794},[784,3269,3270],{"class":844}," cursor",[784,3272,848],{"class":794},[784,3274,1688],{"class":844},[784,3276,2769],{"class":794},[784,3278,856],{"class":837},[784,3280,818],{"class":794},[784,3282,3283,3285,3288,3290,3293,3295,3297,3299,3301,3303,3306,3308,3311],{"class":786,"line":952},[784,3284,864],{"class":837},[784,3286,3287],{"class":869}," after",[784,3289,881],{"class":794},[784,3291,3292],{"class":794}," typeof",[784,3294,3270],{"class":869},[784,3296,904],{"class":794},[784,3298,907],{"class":794},[784,3300,2320],{"class":827},[784,3302,830],{"class":794},[784,3304,3305],{"class":794}," ?",[784,3307,3270],{"class":869},[784,3309,3310],{"class":794}," :",[784,3312,3313],{"class":1546}," 0\n",[784,3315,3316],{"class":786,"line":958},[784,3317,3318],{"class":1202},"    \u002F\u002F One batch: up to 500 rows after the last one done, in id order.\n",[784,3320,3321,3323,3326,3328,3330,3333,3335,3337,3339,3342,3344,3346,3348,3351],{"class":786,"line":1333},[784,3322,864],{"class":837},[784,3324,3325],{"class":869}," done",[784,3327,881],{"class":794},[784,3329,3022],{"class":895},[784,3331,3332],{"class":922}," fillPrices",[784,3334,926],{"class":833},[784,3336,845],{"class":869},[784,3338,886],{"class":794},[784,3340,3341],{"class":869},"db",[784,3343,848],{"class":794},[784,3345,3287],{"class":869},[784,3347,848],{"class":794},[784,3349,3350],{"class":1546}," 500",[784,3352,949],{"class":833},[784,3354,3355,3357,3359,3361,3363,3365,3367,3370,3372,3374,3376,3378,3380,3383,3386,3388,3390,3393,3395,3397,3399,3401,3403,3405,3407,3409,3412,3414,3416,3418,3420,3422],{"class":786,"line":1338},[784,3356,1322],{"class":895},[784,3358,797],{"class":794},[784,3360,3270],{"class":833},[784,3362,643],{"class":794},[784,3364,3325],{"class":869},[784,3366,886],{"class":794},[784,3368,3369],{"class":869},"lastId",[784,3371,848],{"class":794},[784,3373,3325],{"class":833},[784,3375,643],{"class":794},[784,3377,3325],{"class":869},[784,3379,886],{"class":794},[784,3381,3382],{"class":869},"count",[784,3384,3385],{"class":794}," \u003C",[784,3387,3350],{"class":1546},[784,3389,848],{"class":794},[784,3391,3392],{"class":833}," processed",[784,3394,643],{"class":794},[784,3396,3325],{"class":869},[784,3398,886],{"class":794},[784,3400,3382],{"class":869},[784,3402,848],{"class":794},[784,3404,2311],{"class":833},[784,3406,643],{"class":794},[784,3408,3022],{"class":895},[784,3410,3411],{"class":922}," countProducts",[784,3413,926],{"class":833},[784,3415,845],{"class":869},[784,3417,886],{"class":794},[784,3419,3341],{"class":869},[784,3421,1194],{"class":833},[784,3423,961],{"class":794},[784,3425,3426],{"class":786,"line":1641},[784,3427,955],{"class":794},[784,3429,3430],{"class":786,"line":1647},[784,3431,961],{"class":794},[784,3433,3434],{"class":786,"line":1708},[784,3435,2203],{"emptyLinePlaceholder":2202},[784,3437,3438,3440,3442,3444,3446],{"class":786,"line":1714},[784,3439,1454],{"class":895},[784,3441,1457],{"class":895},[784,3443,1460],{"class":922},[784,3445,926],{"class":869},[784,3447,1197],{"class":794},[784,3449,3450,3452,3454,3456,3459,3461],{"class":786,"line":1760},[784,3451,1469],{"class":833},[784,3453,643],{"class":794},[784,3455,907],{"class":794},[784,3457,3458],{"class":827},"shop",[784,3460,830],{"class":794},[784,3462,1481],{"class":794},[784,3464,3465],{"class":786,"line":1766},[784,3466,1486],{"class":1202},[784,3468,3469,3472,3474,3476,3479],{"class":786,"line":2413},[784,3470,3471],{"class":833},"  dataMigrations",[784,3473,643],{"class":794},[784,3475,797],{"class":794},[784,3477,3478],{"class":869}," prices ",[784,3480,961],{"class":794},[784,3482,3483,3485],{"class":786,"line":2418},[784,3484,1315],{"class":794},[784,3486,949],{"class":869},[1073,3488,3489,3499,3517,3526,3536,3544,3550,3553],{},[1076,3490,3491,3494,3495,3498],{},[1079,3492,3493],{},"When it runs."," The worker queues the migration at start when it finds one it has not run, or a higher ",[632,3496,3497],{},"version",". A higher version runs again from the beginning; the same version never runs twice. Each batch runs as the module's own actor.",[1076,3500,3501,3504,3505,3508,3509,3512,3513,3516],{},[1079,3502,3503],{},"One batch, one transaction."," ",[632,3506,3507],{},"ctx.db"," is a transaction that also saves the migration's progress: what a batch writes and the ",[632,3510,3511],{},"cursor"," it answers are kept together or not at all. A batch cut off leaves nothing, and the next try starts from the last cursor. The cursor is any JSON value, ",[632,3514,3515],{},"null"," for the first batch.",[1076,3518,3519,3504,3522,3525],{},[1079,3520,3521],{},"The answer.",[632,3523,3524],{},"{ cursor, done, processed, total? }",": where the next batch starts, whether the migration is done, how many rows this batch did, and how many there are (shown as \"120 of 400 rows done\"). Anything else fails the batch.",[1076,3527,3528,3531,3532,3535],{},[1079,3529,3530],{},"Pace."," One batch of any migration at a time per worker, and one batch of a migration at a time on the whole instance. ",[632,3533,3534],{},"pauseMs"," (0–60000, default 1000) waits between batches; the next one then starts within about 5 seconds. Keep a batch well under its 55 second limit.",[1076,3537,3538,3504,3541,3543],{},[1079,3539,3540],{},"Stopping.",[632,3542,1953],{}," aborts when the worker stops. Whatever the batch did is rolled back, and it runs again on the next worker.",[1076,3545,3546,3549],{},[1079,3547,3548],{},"Failing."," A batch that throws is tried again after 30 seconds, doubling, 4 more times. Then the migration is failed, with its error, until an admin retries it under Settings → Background tasks, where admins also pause and resume it. While the module is off, its migrations wait without using up tries.",[1076,3551,3552],{},"Uninstalling the module forgets its migrations: installed again, they run again.",[1076,3554,3555,3558,3559,643,3562,3635,3638,3641,3642,3645],{},[1079,3556,3557],{},"Before removing what a migration copied."," The version that stops reading the old column (and drops it in its schema migration) names the migration it needs done in ",[632,3560,3561],{},"contractAfter",[775,3563,3565],{"className":777,"code":3564,"language":779,"meta":780,"style":780},"export default defineModule({\n  name: 'shop',\n  version: '2.0.0',\n  \u002F\u002F …\n  contractAfter: { prices: 1 }\n})\n",[632,3566,3567,3579,3593,3608,3612,3629],{"__ignoreMap":780},[784,3568,3569,3571,3573,3575,3577],{"class":786,"line":787},[784,3570,1454],{"class":895},[784,3572,1457],{"class":895},[784,3574,1460],{"class":922},[784,3576,926],{"class":869},[784,3578,1197],{"class":794},[784,3580,3581,3583,3585,3587,3589,3591],{"class":786,"line":811},[784,3582,1469],{"class":833},[784,3584,643],{"class":794},[784,3586,907],{"class":794},[784,3588,3458],{"class":827},[784,3590,830],{"class":794},[784,3592,1481],{"class":794},[784,3594,3595,3597,3599,3601,3604,3606],{"class":786,"line":821},[784,3596,3243],{"class":833},[784,3598,643],{"class":794},[784,3600,907],{"class":794},[784,3602,3603],{"class":827},"2.0.0",[784,3605,830],{"class":794},[784,3607,1481],{"class":794},[784,3609,3610],{"class":786,"line":861},[784,3611,1486],{"class":1202},[784,3613,3614,3617,3619,3621,3623,3625,3627],{"class":786,"line":892},[784,3615,3616],{"class":833},"  contractAfter",[784,3618,643],{"class":794},[784,3620,797],{"class":794},[784,3622,3230],{"class":833},[784,3624,643],{"class":794},[784,3626,3248],{"class":1546},[784,3628,1057],{"class":794},[784,3630,3631,3633],{"class":786,"line":952},[784,3632,1315],{"class":794},[784,3634,949],{"class":869},[3636,3637],"br",{},[632,3639,3640],{},"shade-module build"," signs it into the package. Installing that version is refused while ",[632,3643,3644],{},"prices"," is not done at version 1 or later, so the installed version keeps running and copying; the admin sees which background task to wait for. The API also leaves the module out at start while it is not done (a development folder). A first install has no data to wait for, so nothing is checked. Name only the module's own migrations, and keep the migration in the manifest until every instance has run it. Experimental in 0.1.",[619,3647,3648],{"id":3648},"kv",[624,3650,3651,3652,841,3655,672,3658,3661,3662,672,3665,672,3668,3671,3672,1829,3675,3678,3679,3681,3682,3685,3686,3689,3690,886],{},"A module keeps its own keys and counters with ",[632,3653,3654],{},"moduleKv(ctx)",[632,3656,3657],{},"get",[632,3659,3660],{},"set"," with an optional ",[632,3663,3664],{},"ttlMs",[632,3666,3667],{},"delete",[632,3669,3670],{},"list",", an atomic ",[632,3673,3674],{},"increment",[632,3676,3677],{},"forAccount(id)"," for an account's keys), once it declares the ",[632,3680,3648],{}," capability with what it keeps: ",[632,3683,3684],{},"capabilities: { kv: { data: { purpose, personal, retention? }, maxKeys?, maxValueBytes? } }",". Untrusted modules have the same through ",[632,3687,3688],{},"shade.kv",". See ",[628,3691,3648],{"href":406},[619,3693,3695],{"id":3694},"cache","Cache",[624,3697,3698,3699,3702,3703,3705,3706,3709,3710,3713,3714,3717,3718,1847],{},"A trusted module keeps values it can rebuild (a read model, an answer from an outside service) in its own cache with ",[632,3700,3701],{},"moduleCache(ctx)",", once it declares the ",[632,3704,3694],{}," capability: ",[632,3707,3708],{},"capabilities: { cache: {} }",", optionally with ",[632,3711,3712],{},"maxKeys"," (default 1000, at most 10 000) and ",[632,3715,3716],{},"maxValueBytes"," (default 64 KB, at most 1 MB). The cache is in Redis, so every container sees the same values. It holds nothing that must survive (keep that in ",[628,3719,3648],{"href":406},[775,3721,3723],{"className":777,"code":3722,"language":779,"meta":780,"style":780},"import { moduleCache } from '@shadestack\u002Fmodule-sdk\u002Fserver'\n\nconst cache = moduleCache(ctx)\nconst menu = await cache.wrap(`menu:${locale}`, () => readMenu(ctx, locale), {\n  ttlMs: 10 * 60 * 1000,\n  tags: ['collection:menus', 'site']\n})\n",[632,3724,3725,3744,3748,3761,3816,3838,3865],{"__ignoreMap":780},[784,3726,3727,3729,3731,3734,3736,3738,3740,3742],{"class":786,"line":787},[784,3728,2150],{"class":895},[784,3730,797],{"class":794},[784,3732,3733],{"class":869}," moduleCache",[784,3735,878],{"class":794},[784,3737,2191],{"class":895},[784,3739,907],{"class":794},[784,3741,973],{"class":827},[784,3743,1330],{"class":794},[784,3745,3746],{"class":786,"line":811},[784,3747,2203],{"emptyLinePlaceholder":2202},[784,3749,3750,3752,3755,3757,3759],{"class":786,"line":821},[784,3751,3013],{"class":837},[784,3753,3754],{"class":869}," cache ",[784,3756,3019],{"class":794},[784,3758,3733],{"class":922},[784,3760,3028],{"class":869},[784,3762,3763,3765,3768,3770,3772,3775,3777,3780,3782,3785,3788,3790,3793,3795,3797,3800,3802,3805,3807,3809,3812,3814],{"class":786,"line":861},[784,3764,3013],{"class":837},[784,3766,3767],{"class":869}," menu ",[784,3769,3019],{"class":794},[784,3771,3022],{"class":895},[784,3773,3774],{"class":869}," cache",[784,3776,886],{"class":794},[784,3778,3779],{"class":922},"wrap",[784,3781,926],{"class":869},[784,3783,3784],{"class":794},"`",[784,3786,3787],{"class":827},"menu:",[784,3789,2887],{"class":794},[784,3791,3792],{"class":869},"locale",[784,3794,2893],{"class":794},[784,3796,848],{"class":794},[784,3798,3799],{"class":794}," ()",[784,3801,856],{"class":837},[784,3803,3804],{"class":922}," readMenu",[784,3806,1698],{"class":869},[784,3808,848],{"class":794},[784,3810,3811],{"class":869}," locale)",[784,3813,848],{"class":794},[784,3815,818],{"class":794},[784,3817,3818,3821,3823,3826,3828,3831,3833,3836],{"class":786,"line":892},[784,3819,3820],{"class":833},"  ttlMs",[784,3822,643],{"class":794},[784,3824,3825],{"class":1546}," 10",[784,3827,1550],{"class":794},[784,3829,3830],{"class":1546}," 60",[784,3832,1550],{"class":794},[784,3834,3835],{"class":1546}," 1000",[784,3837,1481],{"class":794},[784,3839,3840,3843,3845,3847,3849,3852,3854,3856,3858,3861,3863],{"class":786,"line":952},[784,3841,3842],{"class":833},"  tags",[784,3844,643],{"class":794},[784,3846,2706],{"class":869},[784,3848,830],{"class":794},[784,3850,3851],{"class":827},"collection:menus",[784,3853,830],{"class":794},[784,3855,848],{"class":794},[784,3857,907],{"class":794},[784,3859,3860],{"class":827},"site",[784,3862,830],{"class":794},[784,3864,2820],{"class":869},[784,3866,3867,3869],{"class":786,"line":958},[784,3868,1315],{"class":794},[784,3870,949],{"class":869},[1073,3872,3873,3905,3908,3926,3991,4002,4023],{},[1076,3874,3875,672,3878,672,3881,672,3884,1839,3887,3890,3891,3893,3894,3897,3898,3900,3901,1839,3903,886],{},[632,3876,3877],{},"get(key)",[632,3879,3880],{},"set(key, value, { ttlMs, tags })",[632,3882,3883],{},"delete(key)",[632,3885,3886],{},"clearTag(tag)",[632,3888,3889],{},"wrap(key, read, { ttlMs, tags })",". ",[632,3892,3779],{}," gives the cached value, or runs ",[632,3895,3896],{},"read"," and keeps what it gives (",[632,3899,3515],{}," too); prefer it to ",[632,3902,3657],{},[632,3904,3660],{},[1076,3906,3907],{},"Keys and the module's own tags are its own: another module can neither read nor clear them.",[1076,3909,3910,3911,3913,3914,3916,3917,3919,3920,3922,3923,3925],{},"Every value expires: an hour by default, a day at most (",[632,3912,3664],{}," from 1000). Values are JSON. A value over ",[632,3915,3716],{}," is refused by ",[632,3918,3660],{}," (VALIDATION); ",[632,3921,3779],{}," gives it but does not keep it. Past ",[632,3924,3712],{}," values the oldest written goes.",[1076,3927,3928,3931,3932,3984,3986,3987,3990],{},[1079,3929,3930],{},"Tags"," say what a value depends on, at most 20 per value. SHADE clears its content tags when that content changes, in every container at once:",[645,3933,3934,3944],{},[648,3935,3936],{},[651,3937,3938,3941],{},[654,3939,3940],{},"Tag",[654,3942,3943],{},"Cleared when",[662,3945,3946,3956,3966,3975],{},[651,3947,3948,3953],{},[667,3949,3950],{},[632,3951,3952],{},"collection:\u003Cslug>",[667,3954,3955],{},"an entry of the collection is saved, published, unpublished, moved to the trash or restored (a version restored too)",[651,3957,3958,3963],{},[667,3959,3960],{},[632,3961,3962],{},"entry:\u003Cslug>:\u003Cid>",[667,3964,3965],{},"that entry is saved, published, unpublished, moved to the trash or restored",[651,3967,3968,3972],{},[667,3969,3970],{},[632,3971,712],{},[667,3973,3974],{},"a media item is uploaded, changed, replaced, cropped, moved to the trash or restored",[651,3976,3977,3981],{},[667,3978,3979],{},[632,3980,3860],{},[667,3982,3983],{},"the site settings change",[3636,3985],{},"Any other tag is the module's own: ",[632,3988,3989],{},"clearTag('prices')"," after it changed what the tagged values came from. Clearing a content tag yourself is refused. Tag a value with everything it reads: a value that misses a tag is served until it expires.",[1076,3992,3993,3995,3996,3998,3999,4001],{},[632,3994,3779],{}," notes the tags' state before it runs ",[632,3997,3896],{},", so content that changes while it reads is never served afterwards. ",[632,4000,3660],{}," notes it when it is called.",[1076,4003,4004,4005,4007,4008,672,4010,4012,4013,1829,4015,672,4017,1839,4019,4022],{},"When Redis does not answer, ",[632,4006,3657],{}," gives ",[632,4009,3515],{},[632,4011,3779],{}," runs ",[632,4014,3896],{},[632,4016,3660],{},[632,4018,3667],{},[632,4020,4021],{},"clearTag"," do nothing; SHADE logs it. A content clear SHADE could not make then is made good once Redis answers again: every cached value reads as a miss once.",[1076,4024,4025,4026,886],{},"Untrusted modules have no cache yet: use kv with ",[632,4027,3664],{},[619,4029,4031],{"id":4030},"webhook-events","Webhook events",[624,4033,4034,4035,635,4037,3705,4039,4042,4043,4046,4047,4050,4051,4054],{},"A trusted module tells other systems what happened by emitting an event it declares in ",[632,4036,1987],{},[632,4038,2536],{},[632,4040,4041],{},"emit(txCtx, 'order.paid', { type: 'order', id }, data)"," in the transaction of the change it is about. Each is sent as ",[632,4044,4045],{},"\u003Cplugin>.\u003Cevent>"," to the addresses an admin picked it for, in its external shape, signed and retried by core, exactly when the change commits. Declared optional and skipped, the event is still emitted (other modules may hear it) and sent nowhere. See Webhooks (",[632,4048,4049],{},"shade\u002Ffeatures\u002Fwebhooks\u002FREADME.md"," in the ",[632,4052,4053],{},"shade"," repository).",[619,4056,4058],{"id":4057},"realtime-updates","Realtime updates",[624,4060,4061,4062,4065,4066,4069],{},"A page that keeps a route's answer can hear when it changes. Give a public or account ",[632,4063,4064],{},"GET"," route that says what it answers a topic per request, and say when that topic changed: in the change's ",[632,4067,4068],{},"inTransaction"," (it goes once that commits) or after it:",[775,4071,4073],{"className":777,"code":4072,"language":779,"meta":780,"style":780},"{\n  method: 'GET', path: '\u002Forder-status', auth: 'public', rateLimit: { limit: 60, windowMs: 60_000, key: 'ip' },\n  answer: OrderStatusAnswer,\n  realtime: request => `order:${request.query.order}`,\n  handler: (ctx, request) => orderStatus(ctx, request.query.order)\n}\n\u002F\u002F in the order's transaction (inTransaction), or after it:\nawait sendRealtimeUpdate(ctx, `order:${id}`)\n",[632,4074,4075,4079,4160,4172,4206,4246,4250,4255],{"__ignoreMap":780},[784,4076,4077],{"class":786,"line":787},[784,4078,1197],{"class":794},[784,4080,4081,4084,4086,4088,4090,4092,4094,4097,4099,4101,4104,4106,4108,4111,4113,4115,4118,4120,4122,4125,4127,4129,4132,4134,4136,4138,4141,4143,4145,4147,4149,4151,4153,4156,4158],{"class":786,"line":811},[784,4082,4083],{"class":790},"  method",[784,4085,643],{"class":794},[784,4087,907],{"class":794},[784,4089,4064],{"class":827},[784,4091,830],{"class":794},[784,4093,848],{"class":794},[784,4095,4096],{"class":790}," path",[784,4098,643],{"class":794},[784,4100,907],{"class":794},[784,4102,4103],{"class":827},"\u002Forder-status",[784,4105,830],{"class":794},[784,4107,848],{"class":794},[784,4109,4110],{"class":790}," auth",[784,4112,643],{"class":794},[784,4114,907],{"class":794},[784,4116,4117],{"class":827},"public",[784,4119,830],{"class":794},[784,4121,848],{"class":794},[784,4123,4124],{"class":790}," rateLimit",[784,4126,643],{"class":794},[784,4128,797],{"class":794},[784,4130,4131],{"class":790}," limit",[784,4133,643],{"class":794},[784,4135,3830],{"class":1546},[784,4137,848],{"class":794},[784,4139,4140],{"class":790}," windowMs",[784,4142,643],{"class":794},[784,4144,1553],{"class":1546},[784,4146,848],{"class":794},[784,4148,2876],{"class":790},[784,4150,643],{"class":794},[784,4152,907],{"class":794},[784,4154,4155],{"class":827},"ip",[784,4157,830],{"class":794},[784,4159,808],{"class":794},[784,4161,4162,4165,4167,4170],{"class":786,"line":821},[784,4163,4164],{"class":790},"  answer",[784,4166,643],{"class":794},[784,4168,4169],{"class":869}," OrderStatusAnswer",[784,4171,1481],{"class":794},[784,4173,4174,4177,4179,4182,4184,4186,4188,4190,4193,4195,4198,4200,4202,4204],{"class":786,"line":861},[784,4175,4176],{"class":790},"  realtime",[784,4178,643],{"class":794},[784,4180,4181],{"class":844}," request",[784,4183,856],{"class":837},[784,4185,2881],{"class":794},[784,4187,2884],{"class":827},[784,4189,2887],{"class":794},[784,4191,4192],{"class":869},"request",[784,4194,886],{"class":794},[784,4196,4197],{"class":869},"query",[784,4199,886],{"class":794},[784,4201,2458],{"class":869},[784,4203,2893],{"class":794},[784,4205,1481],{"class":794},[784,4207,4208,4211,4213,4215,4217,4219,4221,4223,4225,4228,4230,4232,4234,4236,4238,4240,4242,4244],{"class":786,"line":892},[784,4209,4210],{"class":790},"  handler",[784,4212,643],{"class":794},[784,4214,841],{"class":794},[784,4216,845],{"class":844},[784,4218,848],{"class":794},[784,4220,4181],{"class":844},[784,4222,731],{"class":794},[784,4224,856],{"class":837},[784,4226,4227],{"class":922}," orderStatus",[784,4229,926],{"class":833},[784,4231,845],{"class":869},[784,4233,848],{"class":794},[784,4235,4181],{"class":869},[784,4237,886],{"class":794},[784,4239,4197],{"class":869},[784,4241,886],{"class":794},[784,4243,2458],{"class":869},[784,4245,949],{"class":833},[784,4247,4248],{"class":786,"line":952},[784,4249,961],{"class":794},[784,4251,4252],{"class":786,"line":958},[784,4253,4254],{"class":1202},"\u002F\u002F in the order's transaction (inTransaction), or after it:\n",[784,4256,4257,4259,4262,4264,4266,4268,4270,4272,4275,4277],{"class":786,"line":1333},[784,4258,939],{"class":895},[784,4260,4261],{"class":922}," sendRealtimeUpdate",[784,4263,1698],{"class":869},[784,4265,848],{"class":794},[784,4267,2881],{"class":794},[784,4269,2884],{"class":827},[784,4271,2887],{"class":794},[784,4273,4274],{"class":869},"id",[784,4276,2893],{"class":794},[784,4278,949],{"class":869},[624,4280,4281,4282,4285],{},"The island's call sets ",[632,4283,4284],{},"repeat: { every: 30, while: \u003Ccondition>, realtime: true }",". The stream opens only after the route ran for that visitor, and an update says only \"ask again\", so a topic needs no secrets of its own: whoever may read the route hears it.",[624,4287,4288,4289,4292,4293,4296,4297,4300,4301,4303,4304,4307,4308,886],{},"Instead of calling ",[632,4290,4291],{},"sendRealtimeUpdate",", map events to topics in the manifest: ",[632,4294,4295],{},"realtime: { events: { 'commerce.order.paid': event => `order:${event.subject.id}` } }"," tells the topic's pages right after the event's change commits (each mapped event is a line of the consent). The routes with ",[632,4298,4299],{},"realtime"," are the updates channel of the module's ",[632,4302,4299],{}," capability (",[632,4305,4306],{},"realtime: {}","; untrusted modules have it too), whose other channel is a trusted module's sockets. See ",[628,4309,417],{"href":418},[619,4311,421],{"id":4312},"private-files",[624,4314,4315,4316,834,4319,672,4322,672,4324,1839,4326,4329,4330,4333,4334,4337,4338,4341,4342,4345,4346,3689,4349,886],{},"A trusted module keeps files only it reads (an invoice's PDF) with ",[632,4317,4318],{},"moduleFiles(ctx)",[632,4320,4321],{},"put(key, bytes, { contentType })",[632,4323,3877],{},[632,4325,3883],{},[632,4327,4328],{},"list({ prefix })",". SHADE keeps them in Postgres and never serves them: send one to whoever may see it from your own route, after your own check (",[632,4331,4332],{},"return new Response(bytes, { headers })","). Declare the ",[632,4335,4336],{},"files"," capability with the most it may keep together and what it is: ",[632,4339,4340],{},"files: { maxBytes: 1024 ** 3, data: { purpose: 'shop.privacy.invoices', personal: 'person', retention: 'orders' } }"," (a file is at most 25 MB). Put a file in the transaction of the change it belongs to, ",[632,4343,4344],{},"moduleFiles(withDb(ctx, tx))",". Email can carry it: ",[632,4347,4348],{},"attachments: [{ filename, contentType, content: attachmentContent(bytes) }]",[628,4350,421],{"href":422},[619,4352,4354],{"id":4353},"notifications","Notifications",[624,4356,4357,4358,4361,4362,4365,4366,4368,4369,4372,4373,4376,4377,886],{},"A trusted module tells a person something with ",[632,4359,4360],{},"notify(ctx, { to: { email }, subject, text }, { key, at })",": now, or at ",[632,4363,4364],{},"at"," under its own ",[632,4367,2939],{}," (the same key again moves it; ",[632,4370,4371],{},"cancelNotification(ctx, key)"," calls it off). Declare ",[632,4374,4375],{},"capabilities: { notify: { methods: ['email'] } }",". Plan it in the transaction of its change, as the appointments module plans a booking's reminder. It goes through the notification methods the person chose (email when none), decided when it goes. See ",[628,4378,425],{"href":426},[619,4380,4382],{"id":4381},"processes","Processes",[624,4384,4385,4386,4389,4390,3705,4393,4396,4397,4399,4400,886],{},"A trusted module keeps work running with ",[632,4387,4388],{},"processes: [{ name, run(ctx, signal) }]"," and each process's parameters in the ",[632,4391,4392],{},"process",[632,4394,4395],{},"capabilities: { process: { processes: { presence: { mode: 'singleton' } } } }",". The worker container role runs each in a worker thread of its own, as the module's own actor, until ",[632,4398,1953],{}," aborts, and restarts it with backoff when it ends or throws before that. Untrusted modules have none. See ",[628,4401,4382],{"href":410},[619,4403,4405],{"id":4404},"thread-tasks","Thread tasks",[624,4407,4408,4409,4412,4413,4416],{},"A trusted module runs slow work in a worker thread with a time and a memory budget, so a long or runaway run never holds up the API. Declare each task in the manifest part ",[632,4410,4411],{},"threadTasks",", a function of plain data that returns (or resolves to) plain data, and run one with ",[632,4414,4415],{},"runThreadTask"," from the server entry:",[775,4418,4420],{"className":777,"code":4419,"language":779,"meta":780,"style":780},"import { checkAccessibility, type CheckInput } from '@shadestack\u002Fa11y'\nimport { defineModule, runThreadTask } from '@shadestack\u002Fmodule-sdk\u002Fserver'\n\nexport default defineModule({\n  \u002F\u002F …\n  threadTasks: { accessibility: input => checkAccessibility(input as CheckInput) }\n})\n\n\u002F\u002F In the module's own code, with the context SHADE gave it:\nconst result = await runThreadTask(ctx, 'accessibility', input, { timeoutMs: 30_000 })\nif (result.status === 'done') use(result.result)\n",[632,4421,4422,4449,4472,4476,4488,4492,4525,4531,4535,4540,4584],{"__ignoreMap":780},[784,4423,4424,4426,4428,4431,4433,4435,4438,4440,4442,4444,4447],{"class":786,"line":787},[784,4425,2150],{"class":895},[784,4427,797],{"class":794},[784,4429,4430],{"class":869}," checkAccessibility",[784,4432,848],{"class":794},[784,4434,2451],{"class":895},[784,4436,4437],{"class":869}," CheckInput",[784,4439,878],{"class":794},[784,4441,2191],{"class":895},[784,4443,907],{"class":794},[784,4445,4446],{"class":827},"@shadestack\u002Fa11y",[784,4448,1330],{"class":794},[784,4450,4451,4453,4455,4457,4459,4462,4464,4466,4468,4470],{"class":786,"line":811},[784,4452,2150],{"class":895},[784,4454,797],{"class":794},[784,4456,1460],{"class":869},[784,4458,848],{"class":794},[784,4460,4461],{"class":869}," runThreadTask",[784,4463,878],{"class":794},[784,4465,2191],{"class":895},[784,4467,907],{"class":794},[784,4469,973],{"class":827},[784,4471,1330],{"class":794},[784,4473,4474],{"class":786,"line":821},[784,4475,2203],{"emptyLinePlaceholder":2202},[784,4477,4478,4480,4482,4484,4486],{"class":786,"line":861},[784,4479,1454],{"class":895},[784,4481,1457],{"class":895},[784,4483,1460],{"class":922},[784,4485,926],{"class":869},[784,4487,1197],{"class":794},[784,4489,4490],{"class":786,"line":892},[784,4491,1486],{"class":1202},[784,4493,4494,4497,4499,4501,4504,4506,4509,4511,4513,4516,4519,4521,4523],{"class":786,"line":952},[784,4495,4496],{"class":833},"  threadTasks",[784,4498,643],{"class":794},[784,4500,797],{"class":794},[784,4502,4503],{"class":922}," accessibility",[784,4505,643],{"class":794},[784,4507,4508],{"class":844}," input",[784,4510,856],{"class":837},[784,4512,4430],{"class":922},[784,4514,4515],{"class":869},"(input ",[784,4517,4518],{"class":895},"as",[784,4520,4437],{"class":790},[784,4522,1194],{"class":869},[784,4524,961],{"class":794},[784,4526,4527,4529],{"class":786,"line":958},[784,4528,1315],{"class":794},[784,4530,949],{"class":869},[784,4532,4533],{"class":786,"line":1333},[784,4534,2203],{"emptyLinePlaceholder":2202},[784,4536,4537],{"class":786,"line":1338},[784,4538,4539],{"class":1202},"\u002F\u002F In the module's own code, with the context SHADE gave it:\n",[784,4541,4542,4544,4547,4549,4551,4553,4555,4557,4559,4562,4564,4566,4568,4570,4572,4575,4577,4580,4582],{"class":786,"line":1641},[784,4543,3013],{"class":837},[784,4545,4546],{"class":869}," result ",[784,4548,3019],{"class":794},[784,4550,3022],{"class":895},[784,4552,4461],{"class":922},[784,4554,1698],{"class":869},[784,4556,848],{"class":794},[784,4558,907],{"class":794},[784,4560,4561],{"class":827},"accessibility",[784,4563,830],{"class":794},[784,4565,848],{"class":794},[784,4567,4508],{"class":869},[784,4569,848],{"class":794},[784,4571,797],{"class":794},[784,4573,4574],{"class":833}," timeoutMs",[784,4576,643],{"class":794},[784,4578,4579],{"class":1546}," 30_000",[784,4581,878],{"class":794},[784,4583,949],{"class":869},[784,4585,4586,4589,4592,4594,4597,4600,4602,4605,4607,4609,4612,4615,4617],{"class":786,"line":1647},[784,4587,4588],{"class":895},"if",[784,4590,4591],{"class":869}," (result",[784,4593,886],{"class":794},[784,4595,4596],{"class":869},"status ",[784,4598,4599],{"class":794},"===",[784,4601,907],{"class":794},[784,4603,4604],{"class":827},"done",[784,4606,830],{"class":794},[784,4608,1194],{"class":869},[784,4610,4611],{"class":922},"use",[784,4613,4614],{"class":869},"(result",[784,4616,886],{"class":794},[784,4618,4619],{"class":869},"result)\n",[1073,4621,4622,4631,4647,4650,4653,4656],{},[1076,4623,4624,4626,4627,4630],{},[632,4625,2964],{}," is 1 to 60 000; ",[632,4628,4629],{},"memoryMb"," is 64 to 512, 256 when it gives none. The thread loads the module's entry, and with it about 30 MB of SHADE's code.",[1076,4632,4633,4634,672,4637,1858,4640,4643,4644,4646],{},"The result is ",[632,4635,4636],{},"{ status: 'done', result }",[632,4638,4639],{},"{ status: 'timeout', timeoutMs }",[632,4641,4642],{},"{ status: 'failed', error }"," (the task threw, ran out of memory, or returned what can't be cloned). ",[632,4645,4415],{}," never throws for the task; it throws for a context SHADE didn't make for the module, a task its manifest doesn't have, or a budget out of range.",[1076,4648,4649],{},"At most two runs at once in an API process; a run waiting for its turn counts against its budget.",[1076,4651,4652],{},"The thread gets the input and nothing of SHADE's: no database, no context, no Redis and an empty environment. Read what the task needs first and give it in the input; input and result cross as structured clones.",[1076,4654,4655],{},"A module runs only its own tasks. Untrusted modules have none: their code already runs in the sandbox.",[1076,4657,4658],{},"Without the API (a module's tests, scripts) the task runs in the calling thread, its input and result still cloned, and no budget stops it there.",[624,4660,4661],{},"Thread tasks are not a capability: they let a module do nothing it couldn't do in the API's process already.",[619,4663,4665],{"id":4664},"logging","Logging",[624,4667,4668,4669,4672,4673,834,4676,672,4679,672,4682,1839,4684,4687,4688,4691,4692,4694],{},"Every context SHADE gives a trusted module (the events it hears, its routes, schedules, jobs and processes) has ",[632,4670,4671],{},"ctx.log",", a ",[632,4674,4675],{},"ModuleLogger",[632,4677,4678],{},"ctx.log.info(message, fields?)",[632,4680,4681],{},"warn",[632,4683,1220],{},[632,4685,4686],{},"debug",". Each call writes one JSON line to the instance's log with the time, level, message, container role, SHADE version, the ",[1079,4689,4690],{},"request id"," of what is running and ",[632,4693,901],{}," set to your module's name, so the operator can filter by module and follow a request from the API into your job:",[775,4696,4698],{"className":777,"code":4697,"language":779,"meta":780,"style":780},"on: {\n  'entries.entry.published': async (ctx, event) => {\n    ctx.log.info('feed rebuilt', { items: 12, ms: 340 })\n  }\n}\n",[632,4699,4700,4708,4735,4785,4789],{"__ignoreMap":780},[784,4701,4702,4704,4706],{"class":786,"line":787},[784,4703,634],{"class":790},[784,4705,643],{"class":794},[784,4707,818],{"class":794},[784,4709,4710,4712,4715,4717,4719,4721,4723,4725,4727,4729,4731,4733],{"class":786,"line":811},[784,4711,824],{"class":794},[784,4713,4714],{"class":827},"entries.entry.published",[784,4716,830],{"class":794},[784,4718,834],{"class":833},[784,4720,838],{"class":837},[784,4722,841],{"class":794},[784,4724,845],{"class":844},[784,4726,848],{"class":794},[784,4728,851],{"class":844},[784,4730,731],{"class":794},[784,4732,856],{"class":837},[784,4734,818],{"class":794},[784,4736,4737,4740,4742,4745,4747,4750,4752,4754,4757,4759,4761,4763,4766,4768,4771,4773,4776,4778,4781,4783],{"class":786,"line":821},[784,4738,4739],{"class":869},"    ctx",[784,4741,886],{"class":794},[784,4743,4744],{"class":869},"log",[784,4746,886],{"class":794},[784,4748,4749],{"class":922},"info",[784,4751,926],{"class":833},[784,4753,830],{"class":794},[784,4755,4756],{"class":827},"feed rebuilt",[784,4758,830],{"class":794},[784,4760,848],{"class":794},[784,4762,797],{"class":794},[784,4764,4765],{"class":833}," items",[784,4767,643],{"class":794},[784,4769,4770],{"class":1546}," 12",[784,4772,848],{"class":794},[784,4774,4775],{"class":833}," ms",[784,4777,643],{"class":794},[784,4779,4780],{"class":1546}," 340",[784,4782,878],{"class":794},[784,4784,949],{"class":833},[784,4786,4787],{"class":786,"line":861},[784,4788,955],{"class":794},[784,4790,4791],{"class":786,"line":892},[784,4792,961],{"class":794},[624,4794,4795,4798,4799,4802,4803,4806,4807,4809,4810,886],{},[632,4796,4797],{},"fields"," is plain data (numbers, text, booleans, small lists and objects). SHADE takes out what is personal or secret before anything is written, as the error log does: email addresses, IP addresses, query strings, tokens and credentials in texts are replaced, and a field named like a body, headers, a cookie, a token, a password, an email address, an IP address or an account is written as ",[632,4800,4801],{},"[redacted]",". Log decisions and counts, never what a visitor typed. The request id is also ",[632,4804,4805],{},"ctx.requestId",", and a job you queue from a request runs under its id. Untrusted modules have no ",[632,4808,4671],{}," yet: what their code writes to the console is logged under their name. See ",[628,4811,4812],{"href":91},"Logs and request ids",[619,4814,4816],{"id":4815},"tracing","Tracing",[624,4818,4819,4820,834,4822,4825,4826,4828,4829,4832,4833,4836,4837,4839,4840,4843,4844,4847],{},"When the operator has set an OpenTelemetry exporter, SHADE already makes a span for the events you hear, routes' requests, schedules, jobs, processes and thread tasks, and for every call you make through ",[632,4821,845],{},[632,4823,4824],{},"ctx.fetch",", each ",[632,4827,3507],{}," query (the kind of statement only), each ",[632,4830,4831],{},"ctx.kv"," call and ",[632,4834,4835],{},"enqueueJob",". Each has ",[632,4838,901],{}," set to your module's name. For your own steps, ",[632,4841,4842],{},"ctx.trace"," (a ",[632,4845,4846],{},"ModuleTrace",") runs work in a child span:",[775,4849,4851],{"className":777,"code":4850,"language":779,"meta":780,"style":780},"const price = await ctx.trace('price check', async () => quote(order), { items: order.lines.length })\n",[632,4852,4853],{"__ignoreMap":780},[784,4854,4855,4857,4860,4862,4864,4866,4868,4871,4873,4875,4878,4880,4882,4884,4886,4888,4891,4894,4896,4898,4900,4902,4904,4906,4909,4911,4914,4916],{"class":786,"line":787},[784,4856,3013],{"class":837},[784,4858,4859],{"class":869}," price ",[784,4861,3019],{"class":794},[784,4863,3022],{"class":895},[784,4865,1266],{"class":869},[784,4867,886],{"class":794},[784,4869,4870],{"class":922},"trace",[784,4872,926],{"class":869},[784,4874,830],{"class":794},[784,4876,4877],{"class":827},"price check",[784,4879,830],{"class":794},[784,4881,848],{"class":794},[784,4883,2063],{"class":837},[784,4885,3799],{"class":794},[784,4887,856],{"class":837},[784,4889,4890],{"class":922}," quote",[784,4892,4893],{"class":869},"(order)",[784,4895,848],{"class":794},[784,4897,797],{"class":794},[784,4899,4765],{"class":833},[784,4901,643],{"class":794},[784,4903,1039],{"class":869},[784,4905,886],{"class":794},[784,4907,4908],{"class":869},"lines",[784,4910,886],{"class":794},[784,4912,4913],{"class":869},"length ",[784,4915,1315],{"class":794},[784,4917,949],{"class":869},[624,4919,4920,4921,4924,4925,4927,4928,4930,4931,3689,4933,886],{},"It gives back what the work gives back; a throw marks the span failed (its class, never its message) and goes on. The name and the attributes (",[632,4922,4923],{},"ModuleSpanAttributes",": text, numbers and booleans, at most 20) are scrubbed like log lines, and an attribute named like a body, headers, a cookie, a token, a password, an email address, an IP address or an account is left out. Name what the work does, never who it is for. Without an exporter ",[632,4926,4842],{}," runs the work and nothing more, so leave the calls in. A log line written inside a span carries its trace id. Untrusted modules have no ",[632,4929,4842],{}," yet. In a module's own tests, build a context with the testing entry's ",[632,4932,4870],{},[628,4934,4936],{"href":4935},"\u002Frun\u002Flogs#traces-over-opentelemetry","Traces",[619,4938,4940],{"id":4939},"health","Health",[624,4942,4943,4944,643],{},"SHADE measures a module's health itself: its processes, how its schedules' last runs ended and the errors recorded for it. A module adds a check for what only it knows with the manifest part ",[632,4945,4939],{},[775,4947,4949],{"className":777,"code":4948,"language":779,"meta":780,"style":780},"health: async (ctx, signal) => {\n  const key = await readProviderKey(ctx)\n  return key.expired ? { ok: false, note: 'The provider key expired' } : { ok: true }\n}\n",[632,4950,4951,4973,4993,5046],{"__ignoreMap":780},[784,4952,4953,4955,4957,4959,4961,4963,4965,4967,4969,4971],{"class":786,"line":787},[784,4954,4939],{"class":790},[784,4956,643],{"class":794},[784,4958,2063],{"class":837},[784,4960,841],{"class":794},[784,4962,845],{"class":844},[784,4964,848],{"class":794},[784,4966,1688],{"class":844},[784,4968,731],{"class":794},[784,4970,856],{"class":837},[784,4972,818],{"class":794},[784,4974,4975,4978,4980,4982,4984,4987,4989,4991],{"class":786,"line":811},[784,4976,4977],{"class":837},"  const",[784,4979,2876],{"class":869},[784,4981,881],{"class":794},[784,4983,3022],{"class":895},[784,4985,4986],{"class":922}," readProviderKey",[784,4988,926],{"class":833},[784,4990,845],{"class":869},[784,4992,949],{"class":833},[784,4994,4995,4998,5000,5002,5005,5007,5009,5012,5014,5018,5020,5022,5024,5026,5029,5031,5033,5035,5037,5039,5041,5044],{"class":786,"line":821},[784,4996,4997],{"class":895},"  return",[784,4999,2876],{"class":869},[784,5001,886],{"class":794},[784,5003,5004],{"class":869},"expired",[784,5006,3305],{"class":794},[784,5008,797],{"class":794},[784,5010,5011],{"class":833}," ok",[784,5013,643],{"class":794},[784,5015,5017],{"class":5016},"sfNiH"," false",[784,5019,848],{"class":794},[784,5021,3119],{"class":833},[784,5023,643],{"class":794},[784,5025,907],{"class":794},[784,5027,5028],{"class":827},"The provider key expired",[784,5030,830],{"class":794},[784,5032,878],{"class":794},[784,5034,3310],{"class":794},[784,5036,797],{"class":794},[784,5038,5011],{"class":833},[784,5040,643],{"class":794},[784,5042,5043],{"class":5016}," true",[784,5045,1057],{"class":794},[784,5047,5048],{"class":786,"line":861},[784,5049,961],{"class":794},[624,5051,5052,5053,5055,5056,5059,5060,5063,5064,1858,5067,5070],{},"The worker calls it every 5 minutes as the module's own actor, with a 10-second limit (",[632,5054,1953],{}," aborts then). No answer in time, or throwing, counts as unhealthy. Keep it cheap and read-only. The note shows on the Modules page, never in an alert or an email. An untrusted module says ",[632,5057,5058],{},"\"health\": true"," in its sandbox package and answers ",[632,5061,5062],{},"GET \u002F__shade\u002Fhealth"," with ",[632,5065,5066],{},"{ \"ok\": true }",[632,5068,5069],{},"{ \"ok\": false, \"note\": \"…\" }",". Health is not a capability.",[619,5072,5074],{"id":5073},"retention","Retention",[624,5076,5077,5078,5081,5082,5085,5086,5089,5090,886],{},"A module that keeps personal data declares how long: ",[632,5079,5080],{},"retention: [{ key, label, help?, defaultDays, minDays, purge(db, before, now) }]",". Each kind appears in ",[1079,5083,5084],{},"Settings → Data retention"," (key prefixed with the module name, label an admin translation key), and the core's hourly job calls ",[632,5087,5088],{},"purge"," with the cut-off, also while the module is off. See ",[628,5091,273],{"href":274},[619,5093,5095],{"id":5094},"consent","Consent",[624,5097,5098],{},"A module whose site parts need the visitor's consent (an embedded map, a video, a pixel) declares categories. Each says what it is, why, where it loads from, which cookies it sets and for how long, and where the outside party's privacy statement is. Its label, description and purpose are keys in the module's locale files, read in the page's language (else its primary code, the site's default, English). A new or changed language file asks visitors again:",[775,5100,5102],{"className":777,"code":5101,"language":779,"meta":780,"style":780},"export default defineModule({\n  name: 'videos',\n  \u002F\u002F …\n  capabilities: { allowedSources: {}, consent: {} },\n  allowedSources: { site: { frame: ['https:\u002F\u002Fplayer.example.org'] } },\n  consent: {\n    categories: [{\n      key: 'player',\n      \u002F\u002F keys in locales\u002F\u003Clanguage>.json: { \"consent\": { \"player\": { \"label\": \"Videos\", … } } }\n      label: 'consent.player.label',\n      description: 'consent.player.description',\n      purpose: 'consent.player.purpose',\n      hosts: ['https:\u002F\u002Fplayer.example.org'],\n      cookies: [{ name: 'vid_*', firstParty: false, duration: { days: 180 } }],\n      privacyUrl: 'https:\u002F\u002Fplayer.example.org\u002Fprivacy',\n      needsProof: false\n    }]\n  }\n})\n",[632,5103,5104,5116,5131,5135,5160,5197,5206,5217,5233,5238,5254,5269,5285,5305,5361,5377,5387,5394,5399],{"__ignoreMap":780},[784,5105,5106,5108,5110,5112,5114],{"class":786,"line":787},[784,5107,1454],{"class":895},[784,5109,1457],{"class":895},[784,5111,1460],{"class":922},[784,5113,926],{"class":869},[784,5115,1197],{"class":794},[784,5117,5118,5120,5122,5124,5127,5129],{"class":786,"line":811},[784,5119,1469],{"class":833},[784,5121,643],{"class":794},[784,5123,907],{"class":794},[784,5125,5126],{"class":827},"videos",[784,5128,830],{"class":794},[784,5130,1481],{"class":794},[784,5132,5133],{"class":786,"line":821},[784,5134,1486],{"class":1202},[784,5136,5137,5139,5141,5143,5146,5148,5151,5154,5156,5158],{"class":786,"line":861},[784,5138,1491],{"class":833},[784,5140,643],{"class":794},[784,5142,797],{"class":794},[784,5144,5145],{"class":833}," allowedSources",[784,5147,643],{"class":794},[784,5149,5150],{"class":794}," {},",[784,5152,5153],{"class":833}," consent",[784,5155,643],{"class":794},[784,5157,805],{"class":794},[784,5159,808],{"class":794},[784,5161,5162,5165,5167,5169,5172,5174,5176,5179,5181,5183,5185,5188,5190,5193,5195],{"class":786,"line":892},[784,5163,5164],{"class":833},"  allowedSources",[784,5166,643],{"class":794},[784,5168,797],{"class":794},[784,5170,5171],{"class":833}," site",[784,5173,643],{"class":794},[784,5175,797],{"class":794},[784,5177,5178],{"class":833}," frame",[784,5180,643],{"class":794},[784,5182,2706],{"class":869},[784,5184,830],{"class":794},[784,5186,5187],{"class":827},"https:\u002F\u002Fplayer.example.org",[784,5189,830],{"class":794},[784,5191,5192],{"class":869},"] ",[784,5194,1315],{"class":794},[784,5196,808],{"class":794},[784,5198,5199,5202,5204],{"class":786,"line":952},[784,5200,5201],{"class":833},"  consent",[784,5203,643],{"class":794},[784,5205,818],{"class":794},[784,5207,5208,5211,5213,5215],{"class":786,"line":958},[784,5209,5210],{"class":833},"    categories",[784,5212,643],{"class":794},[784,5214,2706],{"class":869},[784,5216,1197],{"class":794},[784,5218,5219,5222,5224,5226,5229,5231],{"class":786,"line":1333},[784,5220,5221],{"class":833},"      key",[784,5223,643],{"class":794},[784,5225,907],{"class":794},[784,5227,5228],{"class":827},"player",[784,5230,830],{"class":794},[784,5232,1481],{"class":794},[784,5234,5235],{"class":786,"line":1338},[784,5236,5237],{"class":1202},"      \u002F\u002F keys in locales\u002F\u003Clanguage>.json: { \"consent\": { \"player\": { \"label\": \"Videos\", … } } }\n",[784,5239,5240,5243,5245,5247,5250,5252],{"class":786,"line":1641},[784,5241,5242],{"class":833},"      label",[784,5244,643],{"class":794},[784,5246,907],{"class":794},[784,5248,5249],{"class":827},"consent.player.label",[784,5251,830],{"class":794},[784,5253,1481],{"class":794},[784,5255,5256,5258,5260,5262,5265,5267],{"class":786,"line":1647},[784,5257,2261],{"class":833},[784,5259,643],{"class":794},[784,5261,907],{"class":794},[784,5263,5264],{"class":827},"consent.player.description",[784,5266,830],{"class":794},[784,5268,1481],{"class":794},[784,5270,5271,5274,5276,5278,5281,5283],{"class":786,"line":1708},[784,5272,5273],{"class":833},"      purpose",[784,5275,643],{"class":794},[784,5277,907],{"class":794},[784,5279,5280],{"class":827},"consent.player.purpose",[784,5282,830],{"class":794},[784,5284,1481],{"class":794},[784,5286,5287,5290,5292,5294,5296,5298,5300,5303],{"class":786,"line":1714},[784,5288,5289],{"class":833},"      hosts",[784,5291,643],{"class":794},[784,5293,2706],{"class":869},[784,5295,830],{"class":794},[784,5297,5187],{"class":827},[784,5299,830],{"class":794},[784,5301,5302],{"class":869},"]",[784,5304,1481],{"class":794},[784,5306,5307,5310,5312,5314,5316,5318,5320,5322,5325,5327,5329,5332,5334,5336,5338,5341,5343,5345,5348,5350,5353,5355,5357,5359],{"class":786,"line":1760},[784,5308,5309],{"class":833},"      cookies",[784,5311,643],{"class":794},[784,5313,2706],{"class":869},[784,5315,2292],{"class":794},[784,5317,1527],{"class":833},[784,5319,643],{"class":794},[784,5321,907],{"class":794},[784,5323,5324],{"class":827},"vid_*",[784,5326,830],{"class":794},[784,5328,848],{"class":794},[784,5330,5331],{"class":833}," firstParty",[784,5333,643],{"class":794},[784,5335,5017],{"class":5016},[784,5337,848],{"class":794},[784,5339,5340],{"class":833}," duration",[784,5342,643],{"class":794},[784,5344,797],{"class":794},[784,5346,5347],{"class":833}," days",[784,5349,643],{"class":794},[784,5351,5352],{"class":1546}," 180",[784,5354,878],{"class":794},[784,5356,878],{"class":794},[784,5358,5302],{"class":869},[784,5360,1481],{"class":794},[784,5362,5363,5366,5368,5370,5373,5375],{"class":786,"line":1766},[784,5364,5365],{"class":833},"      privacyUrl",[784,5367,643],{"class":794},[784,5369,907],{"class":794},[784,5371,5372],{"class":827},"https:\u002F\u002Fplayer.example.org\u002Fprivacy",[784,5374,830],{"class":794},[784,5376,1481],{"class":794},[784,5378,5379,5382,5384],{"class":786,"line":2413},[784,5380,5381],{"class":833},"      needsProof",[784,5383,643],{"class":794},[784,5385,5386],{"class":5016}," false\n",[784,5388,5389,5392],{"class":786,"line":2418},[784,5390,5391],{"class":794},"    }",[784,5393,2820],{"class":869},[784,5395,5397],{"class":786,"line":5396},18,[784,5398,955],{"class":794},[784,5400,5402,5404],{"class":786,"line":5401},19,[784,5403,1315],{"class":794},[784,5405,949],{"class":869},[1073,5407,5408,5442,5452,5489,5518,5530,5539,5552,5567],{},[1076,5409,5410,5413,5414,5417,5418,5421,5422,3890,5425,5428,5429,5432,5433,5435,5436,1858,5439,886],{},[1079,5411,5412],{},"Every site source is covered."," Each host in the module's site ",[632,5415,5416],{},"allowedSources"," is named by a category's ",[632,5419,5420],{},"hosts",", and a category names only those. A category with hosts names their ",[632,5423,5424],{},"privacyUrl",[632,5426,5427],{},"cookies"," lists what it sets: ",[632,5430,5431],{},"firstParty: true"," for a cookie the site itself sets (withdrawing consent expires it), a trailing ",[632,5434,1806],{}," for a prefix, and ",[632,5437,5438],{},"duration: 'session'",[632,5440,5441],{},"{ days }",[1076,5443,5444,5447,5448,5451],{},[1079,5445,5446],{},"Or say why none is needed."," A module whose site parts set no cookie and send nothing elsewhere, such as a head part that counts page views on the instance itself, declares ",[632,5449,5450],{},"consent: { exempt: { reason } }"," instead (10 to 300 characters, shown to admins as written). Not both, unless the owner chooses (below).",[1076,5453,5454,5457,5458,5461,5462,5465,5466,5469,5470,5472,5473,5475,5476,672,5479,672,5482,1839,5485,5488],{},[1079,5455,5456],{},"Or let the owner choose."," A module that needs no consent as built may also declare the categories an owner can put it behind, with ",[632,5459,5460],{},"askWhen(ctx)"," answering, as the module, whether to ask now: analytics asks while its ",[632,5463,5464],{},"askConsent"," setting is on. While it answers false the exemption applies; while it answers true, or fails, the categories do, and gate the head part. Since the site's pages carry the banner as built, ask for a rebuild when the answer changes (",[632,5467,5468],{},"requestRebuild"," when it hears ",[632,5471,767],{},"):",[3636,5474],{},"Declare ",[632,5477,5478],{},"exempt",[632,5480,5481],{},"categories",[632,5483,5484],{},"head",[632,5486,5487],{},"askWhen: async ctx => (await getModuleSettings\u003C{ askConsent?: boolean }>(ctx, 'analytics')).askConsent === true"," together.",[1076,5490,5491,5494,5495,5497,5498,5501,5502,5504,5505,5507,5508,1839,5511,970,5514,5517],{},[1079,5492,5493],{},"Checked twice."," A module with site ",[632,5496,5416],{}," or a site head part (",[632,5499,5500],{},"site\u002Findex.ts"," exporting ",[632,5503,5484],{},") that declares neither is refused by ",[632,5506,3640],{}," and by the API when it loads. In tests, ",[632,5509,5510],{},"validateModule(plugin)",[632,5512,5513],{},"folderProblems(plugin, dir)",[632,5515,5516],{},"@shadestack\u002Fmodule-sdk\u002Ftesting"," run the same checks.",[1076,5519,5520,5523,5524,4303,5526,5529],{},[1079,5521,5522],{},"Shown to admins."," The categories (or the exemption) are lines of the ",[632,5525,5094],{},[632,5527,5528],{},"capabilities: { consent: {} }","): the install consent, the Modules page and the approval list them, and a change asks the admin again.",[1076,5531,5532,5535,5536,5538],{},[1079,5533,5534],{},"Versioned."," The site gets each category with a ",[632,5537,3497],{}," that changes whenever anything in it changes, and asks the visitor again.",[1076,5540,5541,5544,5545,5548,5549,5551],{},[1079,5542,5543],{},"Proof where it is needed."," A category with ",[632,5546,5547],{},"needsProof: true"," (marketing, advertising) gets a receipt on the instance for each choice: a random id the visitor can read, the banner configuration it answered, the answers and the time; no IP address or browser string. Receipts are kept 3 years, in the privacy screen's lookup and erasure (",[628,5550,277],{"href":278},"). The module does nothing more for it.",[1076,5553,5554,5557,5558,5561,5562,841,5564,1847],{},[1079,5555,5556],{},"A head part waits for its category."," A module with categories and a site head part names the category that gates it: ",[632,5559,5560],{},"consent: { categories: [...], head: 'player' }",". The site renders the head part inert until the visitor allows that category, then adds it to the page, so its scripts need not check consent themselves. Its inline scripts run under the site's policy; scripts from an outside host need that host in the module's site ",[632,5563,5416],{},[632,5565,5566],{},"script",[1076,5568,5569,5570,5573,5574,5577,5578,5580],{},"Core shows the banner while the module is on. The module's script checks ",[632,5571,5572],{},"window.shadeConsent?.has('\u003Cplugin>.\u003Ckey>')"," and listens for ",[632,5575,5576],{},"shade:consent"," before loading anything (",[628,5579,277],{"href":278},"). The legal texts (the privacy statement, what the business tells visitors) are the site owner's.",[624,5582,5583,5586],{},[632,5584,5585],{},"shade\u002Ftest\u002Ftesting\u002Ffixtures\u002Fmodules\u002Ftest-consent"," declares one full category, for SHADE's own browser tests. A client's instance never has it.",[619,5588,5590],{"id":5589},"editable-emails","Editable emails",[624,5592,5593,5594,5597,5598,5601,5602,886],{},"Experimental until a second module uses it. A module with the ",[632,5595,5596],{},"email"," capability may let admins edit the wording of its own emails on SHADE's Messages screen: it declares them in the manifest part ",[632,5599,5600],{},"emailTemplates"," and writes them with ",[632,5603,5604],{},"composeModuleEmail",[775,5606,5608],{"className":777,"code":5607,"language":779,"meta":780,"style":780},"defineModule({\n  name: 'shop',\n  capabilities: { email: {} },\n  emailTemplates: {\n    'order-confirmation': {\n      placeholders: [{ name: 'name' }, { name: 'orderNumber' }, { name: 'lines', required: true }]\n    }\n  }\n})\n\n\u002F\u002F locales\u002Fen.json (and one file per other language)\n{ \"emails\": { \"order-confirmation\": {\n  \"title\": \"Order confirmation\",\n  \"description\": \"Sent when an order is paid.\",\n  \"subject\": \"Your order {orderNumber}\",\n  \"body\": \"Dear {name},\\n\\n{lines}\",\n  \"samples\": { \"name\": \"Ann de Vries\", \"orderNumber\": \"2026-000042\", \"lines\": \"2 × Mug\" }\n} } }\n\n\u002F\u002F where the order is paid: the admin's wording, or the default, filled in as plain text\nconst { subject, text } = await composeModuleEmail(ctx, 'order-confirmation', order.locale, { name, orderNumber, lines })\nawait sendEmail(ctx, { to: [email], subject, text })\n",[632,5609,5610,5619,5633,5649,5658,5671,5735,5739,5743,5749,5753,5758,5785,5806,5826,5846,5872,5936,5944,5948,5954,6016],{"__ignoreMap":780},[784,5611,5612,5615,5617],{"class":786,"line":787},[784,5613,5614],{"class":922},"defineModule",[784,5616,926],{"class":869},[784,5618,1197],{"class":794},[784,5620,5621,5623,5625,5627,5629,5631],{"class":786,"line":811},[784,5622,1469],{"class":833},[784,5624,643],{"class":794},[784,5626,907],{"class":794},[784,5628,3458],{"class":827},[784,5630,830],{"class":794},[784,5632,1481],{"class":794},[784,5634,5635,5637,5639,5641,5643,5645,5647],{"class":786,"line":821},[784,5636,1491],{"class":833},[784,5638,643],{"class":794},[784,5640,797],{"class":794},[784,5642,2327],{"class":833},[784,5644,643],{"class":794},[784,5646,805],{"class":794},[784,5648,808],{"class":794},[784,5650,5651,5654,5656],{"class":786,"line":861},[784,5652,5653],{"class":833},"  emailTemplates",[784,5655,643],{"class":794},[784,5657,818],{"class":794},[784,5659,5660,5662,5665,5667,5669],{"class":786,"line":892},[784,5661,1027],{"class":794},[784,5663,5664],{"class":833},"order-confirmation",[784,5666,830],{"class":794},[784,5668,643],{"class":794},[784,5670,818],{"class":794},[784,5672,5673,5676,5678,5680,5682,5684,5686,5688,5691,5693,5695,5697,5699,5701,5703,5706,5708,5710,5712,5714,5716,5718,5720,5722,5724,5727,5729,5731,5733],{"class":786,"line":952},[784,5674,5675],{"class":833},"      placeholders",[784,5677,643],{"class":794},[784,5679,2706],{"class":869},[784,5681,2292],{"class":794},[784,5683,1527],{"class":833},[784,5685,643],{"class":794},[784,5687,907],{"class":794},[784,5689,5690],{"class":827},"name",[784,5692,830],{"class":794},[784,5694,2654],{"class":794},[784,5696,797],{"class":794},[784,5698,1527],{"class":833},[784,5700,643],{"class":794},[784,5702,907],{"class":794},[784,5704,5705],{"class":827},"orderNumber",[784,5707,830],{"class":794},[784,5709,2654],{"class":794},[784,5711,797],{"class":794},[784,5713,1527],{"class":833},[784,5715,643],{"class":794},[784,5717,907],{"class":794},[784,5719,4908],{"class":827},[784,5721,830],{"class":794},[784,5723,848],{"class":794},[784,5725,5726],{"class":833}," required",[784,5728,643],{"class":794},[784,5730,5043],{"class":5016},[784,5732,878],{"class":794},[784,5734,2820],{"class":869},[784,5736,5737],{"class":786,"line":958},[784,5738,2087],{"class":794},[784,5740,5741],{"class":786,"line":1333},[784,5742,955],{"class":794},[784,5744,5745,5747],{"class":786,"line":1338},[784,5746,1315],{"class":794},[784,5748,949],{"class":869},[784,5750,5751],{"class":786,"line":1641},[784,5752,2203],{"emptyLinePlaceholder":2202},[784,5754,5755],{"class":786,"line":1647},[784,5756,5757],{"class":1202},"\u002F\u002F locales\u002Fen.json (and one file per other language)\n",[784,5759,5760,5762,5765,5768,5771,5773,5775,5777,5779,5781,5783],{"class":786,"line":1708},[784,5761,2292],{"class":794},[784,5763,5764],{"class":794}," \"",[784,5766,5767],{"class":827},"emails",[784,5769,5770],{"class":794},"\"",[784,5772,834],{"class":833},[784,5774,2292],{"class":794},[784,5776,5764],{"class":794},[784,5778,5664],{"class":833},[784,5780,5770],{"class":794},[784,5782,643],{"class":794},[784,5784,818],{"class":794},[784,5786,5787,5790,5793,5795,5797,5799,5802,5804],{"class":786,"line":1714},[784,5788,5789],{"class":794},"  \"",[784,5791,5792],{"class":833},"title",[784,5794,5770],{"class":794},[784,5796,643],{"class":794},[784,5798,5764],{"class":794},[784,5800,5801],{"class":827},"Order confirmation",[784,5803,5770],{"class":794},[784,5805,1481],{"class":794},[784,5807,5808,5810,5813,5815,5817,5819,5822,5824],{"class":786,"line":1760},[784,5809,5789],{"class":794},[784,5811,5812],{"class":833},"description",[784,5814,5770],{"class":794},[784,5816,643],{"class":794},[784,5818,5764],{"class":794},[784,5820,5821],{"class":827},"Sent when an order is paid.",[784,5823,5770],{"class":794},[784,5825,1481],{"class":794},[784,5827,5828,5830,5833,5835,5837,5839,5842,5844],{"class":786,"line":1766},[784,5829,5789],{"class":794},[784,5831,5832],{"class":833},"subject",[784,5834,5770],{"class":794},[784,5836,643],{"class":794},[784,5838,5764],{"class":794},[784,5840,5841],{"class":827},"Your order {orderNumber}",[784,5843,5770],{"class":794},[784,5845,1481],{"class":794},[784,5847,5848,5850,5853,5855,5857,5859,5862,5865,5868,5870],{"class":786,"line":2413},[784,5849,5789],{"class":794},[784,5851,5852],{"class":833},"body",[784,5854,5770],{"class":794},[784,5856,643],{"class":794},[784,5858,5764],{"class":794},[784,5860,5861],{"class":827},"Dear {name},",[784,5863,5864],{"class":869},"\\n\\n",[784,5866,5867],{"class":827},"{lines}",[784,5869,5770],{"class":794},[784,5871,1481],{"class":794},[784,5873,5874,5876,5879,5881,5883,5885,5887,5889,5891,5893,5895,5898,5900,5902,5904,5906,5908,5910,5912,5915,5917,5919,5921,5923,5925,5927,5929,5932,5934],{"class":786,"line":2418},[784,5875,5789],{"class":794},[784,5877,5878],{"class":833},"samples",[784,5880,5770],{"class":794},[784,5882,643],{"class":794},[784,5884,797],{"class":794},[784,5886,5764],{"class":794},[784,5888,5690],{"class":833},[784,5890,5770],{"class":794},[784,5892,643],{"class":794},[784,5894,5764],{"class":794},[784,5896,5897],{"class":827},"Ann de Vries",[784,5899,5770],{"class":794},[784,5901,848],{"class":794},[784,5903,5764],{"class":794},[784,5905,5705],{"class":833},[784,5907,5770],{"class":794},[784,5909,643],{"class":794},[784,5911,5764],{"class":794},[784,5913,5914],{"class":827},"2026-000042",[784,5916,5770],{"class":794},[784,5918,848],{"class":794},[784,5920,5764],{"class":794},[784,5922,4908],{"class":833},[784,5924,5770],{"class":794},[784,5926,643],{"class":794},[784,5928,5764],{"class":794},[784,5930,5931],{"class":827},"2 × Mug",[784,5933,5770],{"class":794},[784,5935,1057],{"class":794},[784,5937,5938,5940,5942],{"class":786,"line":5396},[784,5939,1315],{"class":794},[784,5941,878],{"class":794},[784,5943,1057],{"class":794},[784,5945,5946],{"class":786,"line":5401},[784,5947,2203],{"emptyLinePlaceholder":2202},[784,5949,5951],{"class":786,"line":5950},20,[784,5952,5953],{"class":1202},"\u002F\u002F where the order is paid: the admin's wording, or the default, filled in as plain text\n",[784,5955,5957,5959,5961,5964,5966,5969,5971,5973,5975,5978,5980,5982,5984,5986,5988,5990,5992,5994,5996,5998,6000,6002,6004,6007,6009,6012,6014],{"class":786,"line":5956},21,[784,5958,3013],{"class":837},[784,5960,797],{"class":794},[784,5962,5963],{"class":869}," subject",[784,5965,848],{"class":794},[784,5967,5968],{"class":869}," text ",[784,5970,1315],{"class":794},[784,5972,881],{"class":794},[784,5974,3022],{"class":895},[784,5976,5977],{"class":922}," composeModuleEmail",[784,5979,1698],{"class":869},[784,5981,848],{"class":794},[784,5983,907],{"class":794},[784,5985,5664],{"class":827},[784,5987,830],{"class":794},[784,5989,848],{"class":794},[784,5991,1039],{"class":869},[784,5993,886],{"class":794},[784,5995,3792],{"class":869},[784,5997,848],{"class":794},[784,5999,797],{"class":794},[784,6001,1527],{"class":869},[784,6003,848],{"class":794},[784,6005,6006],{"class":869}," orderNumber",[784,6008,848],{"class":794},[784,6010,6011],{"class":869}," lines ",[784,6013,1315],{"class":794},[784,6015,949],{"class":869},[784,6017,6019,6021,6024,6026,6028,6030,6033,6035,6038,6040,6042,6044,6046,6048],{"class":786,"line":6018},22,[784,6020,939],{"class":895},[784,6022,6023],{"class":922}," sendEmail",[784,6025,1698],{"class":869},[784,6027,848],{"class":794},[784,6029,797],{"class":794},[784,6031,6032],{"class":833}," to",[784,6034,643],{"class":794},[784,6036,6037],{"class":869}," [email]",[784,6039,848],{"class":794},[784,6041,5963],{"class":869},[784,6043,848],{"class":794},[784,6045,5968],{"class":869},[784,6047,1315],{"class":794},[784,6049,949],{"class":869},[1073,6051,6052,6063,6075,6078,6084],{},[1076,6053,6054,6055,6058,6059,6062],{},"The id on the Messages screen is ",[632,6056,6057],{},"\u003Cplugin>.\u003Ckey>",". A placeholder is ",[632,6060,6061],{},"{name}","; every declared placeholder needs a value; values are filled in as plain text, never read as placeholders, and the subject is one line. A required placeholder must stay in an edited body.",[1076,6064,6065,6066,6070,6071,6074],{},"The texts are the module's locale files (see ",[628,6067,6069],{"href":6068},"#texts-for-visitors-in-any-language","Texts for visitors","). SHADE checks at load that ",[632,6072,6073],{},"en.json"," has the title, description, subject, body and a sample per placeholder, and that every file's subject and body keep the placeholders.",[1076,6076,6077],{},"The Messages screen shows a tab per language: the site's languages first, then any your files add. A language without a file starts from the site's default text.",[1076,6079,6080,6081,886],{},"Attachments stay in the module's code: appointments' booking confirmation still carries its ",[632,6082,6083],{},".ics",[1076,6085,6086,6087,6090,6091,1847],{},"The modules with emails of their own today are commerce (",[632,6088,6089],{},"commerce.order-confirmation",") and appointments (",[632,6092,6093],{},"appointments.booking-confirmation",[619,6095,6097],{"id":6096},"mailing-lists","Mailing lists",[624,6099,5593,6100,6102,6103,6106,6107,709,6110,6112],{},[632,6101,5596],{}," capability that sends marketing mail uses four functions (and ",[632,6104,6105],{},"importBulkSubscribers",") instead of ",[632,6108,6109],{},"sendEmail",[632,6111,6109],{}," stays for transactional mail and gets no headers. The module owns its public routes and its sign-up form; core owns the rules.",[775,6114,6116],{"className":777,"code":6115,"language":779,"meta":780,"style":780},"import { confirmBulkSubscription, requestBulkSubscription, sendBulkEmail, unsubscribeBulk } from '@shadestack\u002Fmodule-sdk\u002Fserver'\n\n\u002F\u002F POST \u002Fsubscribe: always answer the visitor the same, whatever the status.\nawait requestBulkSubscription(ctx, {\n  list: 'launch',\n  address,\n  consentText: 'I want the launch announcements by email. I can unsubscribe at any time.', \u002F\u002F kept as the proof\n  confirmUrl: 'https:\u002F\u002Fshop.example.org\u002Fapi\u002Fv1\u002Faccount\u002Fnewsletter\u002Fconfirm', \u002F\u002F SHADE adds ?token=\n  subject: 'Please confirm your subscription',\n  text: 'Follow this link to confirm:\\n\\n{confirmUrl}'\n})\n\n\u002F\u002F POST \u002Fconfirm?token=…   (a GET must never change anything: mail scanners follow links)\n\u002F\u002F { list, address, contactId }: the person's contact, confirmed now, for your own rows (contactReference).\nawait confirmBulkSubscription(ctx, { token })\n\n\u002F\u002F POST \u002Funsubscribe?token=…  The mail program's one click posts List-Unsubscribe=One-Click here.\nawait unsubscribeBulk(ctx, { token, via: 'one-click' })\n\n\u002F\u002F One message to one confirmed subscriber, with List-Unsubscribe, List-Unsubscribe-Post and a footer.\nconst result = await sendBulkEmail(ctx, { list: 'launch', to: address, subject, text, unsubscribeUrl: 'https:\u002F\u002Fshop.example.org\u002Fapi\u002Fv1\u002Faccount\u002Fnewsletter\u002Funsubscribe' })\n\u002F\u002F { sent: true } or { sent: false, reason: 'not-subscribed' | 'suppressed' | 'limited' }\n",[632,6117,6118,6152,6156,6161,6173,6189,6196,6215,6234,6250,6269,6275,6279,6284,6289,6308,6312,6317,6350,6354,6359,6424],{"__ignoreMap":780},[784,6119,6120,6122,6124,6127,6129,6132,6134,6137,6139,6142,6144,6146,6148,6150],{"class":786,"line":787},[784,6121,2150],{"class":895},[784,6123,797],{"class":794},[784,6125,6126],{"class":869}," confirmBulkSubscription",[784,6128,848],{"class":794},[784,6130,6131],{"class":869}," requestBulkSubscription",[784,6133,848],{"class":794},[784,6135,6136],{"class":869}," sendBulkEmail",[784,6138,848],{"class":794},[784,6140,6141],{"class":869}," unsubscribeBulk",[784,6143,878],{"class":794},[784,6145,2191],{"class":895},[784,6147,907],{"class":794},[784,6149,973],{"class":827},[784,6151,1330],{"class":794},[784,6153,6154],{"class":786,"line":811},[784,6155,2203],{"emptyLinePlaceholder":2202},[784,6157,6158],{"class":786,"line":821},[784,6159,6160],{"class":1202},"\u002F\u002F POST \u002Fsubscribe: always answer the visitor the same, whatever the status.\n",[784,6162,6163,6165,6167,6169,6171],{"class":786,"line":861},[784,6164,939],{"class":895},[784,6166,6131],{"class":922},[784,6168,1698],{"class":869},[784,6170,848],{"class":794},[784,6172,818],{"class":794},[784,6174,6175,6178,6180,6182,6185,6187],{"class":786,"line":892},[784,6176,6177],{"class":833},"  list",[784,6179,643],{"class":794},[784,6181,907],{"class":794},[784,6183,6184],{"class":827},"launch",[784,6186,830],{"class":794},[784,6188,1481],{"class":794},[784,6190,6191,6194],{"class":786,"line":952},[784,6192,6193],{"class":869},"  address",[784,6195,1481],{"class":794},[784,6197,6198,6201,6203,6205,6208,6210,6212],{"class":786,"line":958},[784,6199,6200],{"class":833},"  consentText",[784,6202,643],{"class":794},[784,6204,907],{"class":794},[784,6206,6207],{"class":827},"I want the launch announcements by email. I can unsubscribe at any time.",[784,6209,830],{"class":794},[784,6211,848],{"class":794},[784,6213,6214],{"class":1202}," \u002F\u002F kept as the proof\n",[784,6216,6217,6220,6222,6224,6227,6229,6231],{"class":786,"line":1333},[784,6218,6219],{"class":833},"  confirmUrl",[784,6221,643],{"class":794},[784,6223,907],{"class":794},[784,6225,6226],{"class":827},"https:\u002F\u002Fshop.example.org\u002Fapi\u002Fv1\u002Faccount\u002Fnewsletter\u002Fconfirm",[784,6228,830],{"class":794},[784,6230,848],{"class":794},[784,6232,6233],{"class":1202}," \u002F\u002F SHADE adds ?token=\n",[784,6235,6236,6239,6241,6243,6246,6248],{"class":786,"line":1338},[784,6237,6238],{"class":833},"  subject",[784,6240,643],{"class":794},[784,6242,907],{"class":794},[784,6244,6245],{"class":827},"Please confirm your subscription",[784,6247,830],{"class":794},[784,6249,1481],{"class":794},[784,6251,6252,6255,6257,6259,6262,6264,6267],{"class":786,"line":1641},[784,6253,6254],{"class":833},"  text",[784,6256,643],{"class":794},[784,6258,907],{"class":794},[784,6260,6261],{"class":827},"Follow this link to confirm:",[784,6263,5864],{"class":869},[784,6265,6266],{"class":827},"{confirmUrl}",[784,6268,1330],{"class":794},[784,6270,6271,6273],{"class":786,"line":1647},[784,6272,1315],{"class":794},[784,6274,949],{"class":869},[784,6276,6277],{"class":786,"line":1708},[784,6278,2203],{"emptyLinePlaceholder":2202},[784,6280,6281],{"class":786,"line":1714},[784,6282,6283],{"class":1202},"\u002F\u002F POST \u002Fconfirm?token=…   (a GET must never change anything: mail scanners follow links)\n",[784,6285,6286],{"class":786,"line":1760},[784,6287,6288],{"class":1202},"\u002F\u002F { list, address, contactId }: the person's contact, confirmed now, for your own rows (contactReference).\n",[784,6290,6291,6293,6295,6297,6299,6301,6304,6306],{"class":786,"line":1766},[784,6292,939],{"class":895},[784,6294,6126],{"class":922},[784,6296,1698],{"class":869},[784,6298,848],{"class":794},[784,6300,797],{"class":794},[784,6302,6303],{"class":869}," token ",[784,6305,1315],{"class":794},[784,6307,949],{"class":869},[784,6309,6310],{"class":786,"line":2413},[784,6311,2203],{"emptyLinePlaceholder":2202},[784,6313,6314],{"class":786,"line":2418},[784,6315,6316],{"class":1202},"\u002F\u002F POST \u002Funsubscribe?token=…  The mail program's one click posts List-Unsubscribe=One-Click here.\n",[784,6318,6319,6321,6323,6325,6327,6329,6332,6334,6337,6339,6341,6344,6346,6348],{"class":786,"line":5396},[784,6320,939],{"class":895},[784,6322,6141],{"class":922},[784,6324,1698],{"class":869},[784,6326,848],{"class":794},[784,6328,797],{"class":794},[784,6330,6331],{"class":869}," token",[784,6333,848],{"class":794},[784,6335,6336],{"class":833}," via",[784,6338,643],{"class":794},[784,6340,907],{"class":794},[784,6342,6343],{"class":827},"one-click",[784,6345,830],{"class":794},[784,6347,878],{"class":794},[784,6349,949],{"class":869},[784,6351,6352],{"class":786,"line":5401},[784,6353,2203],{"emptyLinePlaceholder":2202},[784,6355,6356],{"class":786,"line":5950},[784,6357,6358],{"class":1202},"\u002F\u002F One message to one confirmed subscriber, with List-Unsubscribe, List-Unsubscribe-Post and a footer.\n",[784,6360,6361,6363,6365,6367,6369,6371,6373,6375,6377,6380,6382,6384,6386,6388,6390,6392,6394,6397,6399,6401,6403,6406,6408,6411,6413,6415,6418,6420,6422],{"class":786,"line":5956},[784,6362,3013],{"class":837},[784,6364,4546],{"class":869},[784,6366,3019],{"class":794},[784,6368,3022],{"class":895},[784,6370,6136],{"class":922},[784,6372,1698],{"class":869},[784,6374,848],{"class":794},[784,6376,797],{"class":794},[784,6378,6379],{"class":833}," list",[784,6381,643],{"class":794},[784,6383,907],{"class":794},[784,6385,6184],{"class":827},[784,6387,830],{"class":794},[784,6389,848],{"class":794},[784,6391,6032],{"class":833},[784,6393,643],{"class":794},[784,6395,6396],{"class":869}," address",[784,6398,848],{"class":794},[784,6400,5963],{"class":869},[784,6402,848],{"class":794},[784,6404,6405],{"class":869}," text",[784,6407,848],{"class":794},[784,6409,6410],{"class":833}," unsubscribeUrl",[784,6412,643],{"class":794},[784,6414,907],{"class":794},[784,6416,6417],{"class":827},"https:\u002F\u002Fshop.example.org\u002Fapi\u002Fv1\u002Faccount\u002Fnewsletter\u002Funsubscribe",[784,6419,830],{"class":794},[784,6421,878],{"class":794},[784,6423,949],{"class":869},[784,6425,6426],{"class":786,"line":6018},[784,6427,6428],{"class":1202},"\u002F\u002F { sent: true } or { sent: false, reason: 'not-subscribed' | 'suppressed' | 'limited' }\n",[624,6430,6431,6432,6436],{},"Links must be https (http on localhost while developing). A hard bounce or a complaint ends the address on every list. The lists keep each person as a ",[628,6433,6435],{"href":6434},"#contacts","contact",": a sign-up finds or adds the address's contact, following the confirmation link confirms it, and erasing the person removes their subscriptions before the contact.",[624,6438,6439,6440,6443,6444,6446,6447,6450,6451,886],{},"People who agreed elsewhere (a list moved from another tool) come in with ",[632,6441,6442],{},"importBulkSubscribers(ctx, { list, addresses, consentText, source, confirmedAt? })",": up to 1000 addresses a call, confirmed, without a confirmation mail. The proof is what you pass: the consent text they agreed to, where (",[632,6445,1225],{},"), and when (",[632,6448,6449],{},"confirmedAt",", now when left out). It never adds a blocked address, anyone who left the list, or an erased person who had unsubscribed, and answers counts only: ",[632,6452,6453],{},"{ imported, already, left, blocked, objected }",[624,6455,6456,6457,6460,6461,6464,6465,6468,6469,841,6472,6475],{},"An erased person who had unsubscribed or complained is kept as a keyed hash of the address only: ",[632,6458,6459],{},"sendBulkEmail"," answers ",[632,6462,6463],{},"suppressed"," for them until they confirm a new sign-up themselves. Admins see every module's lists on ",[1079,6466,6467],{},"Email → Lists",". The core fixture ",[632,6470,6471],{},"newsletter-probe",[632,6473,6474],{},"shade\u002Ftest\u002Ftesting\u002Ffixtures\u002Fmodules\u002Fnewsletter-probe",") is a complete example.",[619,6477,6479],{"id":6478},"signed-links-and-codes","Signed links and codes",[624,6481,6482],{},"Experimental until a second module uses them. A link mailed to someone to confirm, cancel or move something, or a code a person types (a ticket's, an invite's), is SHADE's: bound to your module, one purpose and one subject, expiring, used at most as often as you allow, and kept only as a keyed hash.",[624,6484,6485,6486,6489,6490,6493,6494,6497,6498,1847],{},"Declare each purpose in the manifest part ",[632,6487,6488],{},"links",": what a link shows (",[632,6491,6492],{},"view",") and what pressing its button does (",[632,6495,6496],{},"redeem","), as data, never HTML. SHADE checks the token and shows your answer on its own page, or on the frontend's own links page when there is one (",[628,6499,533],{"href":534},[775,6501,6503],{"className":777,"code":6502,"language":779,"meta":780,"style":780},"import { defineModule, issueLink, withDb, type LinkView } from '@shadestack\u002Fmodule-sdk\u002Fserver'\n\nexport default defineModule({\n  \u002F\u002F …\n  links: {\n    purposes: {\n      'booking-cancel': {\n        \u002F\u002F `subject`: what the link opens; `left`: how many uses it has left.\n        view: async (ctx, link): Promise\u003CLinkView> => link.left\n          ? { status: 'open', language: 'en', title: 'Cancel booking', text: ['Cancel it?'], action: { button: 'Cancel' } }\n          : { status: 'closed', language: 'en', title: 'Cancel booking', text: ['It is cancelled already.'] },\n        \u002F\u002F `use(ctx)` uses the link in your transaction: false when it was used meanwhile, and then change nothing.\n        redeem: async (ctx, link) => ctx.db.transaction(async (tx) => {\n          if (!await link.use(withDb(ctx, tx))) return { status: 'closed', language: 'en', title: 'Cancel booking', text: ['It is cancelled already.'] }\n          \u002F\u002F … cancel booking `link.subject` in `tx` …\n          return { status: 'closed', language: 'en', title: 'Cancel booking', text: ['Your booking is cancelled.'] }\n        })\n      }\n    }\n  }\n})\n\n\u002F\u002F In a mail: `url` lands on SHADE's page or the frontend's; null without the API's address.\nconst { url } = await issueLink(ctx, { purpose: 'booking-cancel', subject: booking.id, expiresInMs: 7 * 86_400_000, contactId })\n",[632,6504,6505,6540,6544,6556,6560,6569,6578,6592,6597,6638,6727,6788,6793,6840,6929,6934,6994,7001,7006,7010,7014,7020,7024,7030],{"__ignoreMap":780},[784,6506,6507,6509,6511,6513,6515,6518,6520,6523,6525,6527,6530,6532,6534,6536,6538],{"class":786,"line":787},[784,6508,2150],{"class":895},[784,6510,797],{"class":794},[784,6512,1460],{"class":869},[784,6514,848],{"class":794},[784,6516,6517],{"class":869}," issueLink",[784,6519,848],{"class":794},[784,6521,6522],{"class":869}," withDb",[784,6524,848],{"class":794},[784,6526,2451],{"class":895},[784,6528,6529],{"class":869}," LinkView",[784,6531,878],{"class":794},[784,6533,2191],{"class":895},[784,6535,907],{"class":794},[784,6537,973],{"class":827},[784,6539,1330],{"class":794},[784,6541,6542],{"class":786,"line":811},[784,6543,2203],{"emptyLinePlaceholder":2202},[784,6545,6546,6548,6550,6552,6554],{"class":786,"line":821},[784,6547,1454],{"class":895},[784,6549,1457],{"class":895},[784,6551,1460],{"class":922},[784,6553,926],{"class":869},[784,6555,1197],{"class":794},[784,6557,6558],{"class":786,"line":861},[784,6559,1486],{"class":1202},[784,6561,6562,6565,6567],{"class":786,"line":892},[784,6563,6564],{"class":833},"  links",[784,6566,643],{"class":794},[784,6568,818],{"class":794},[784,6570,6571,6574,6576],{"class":786,"line":952},[784,6572,6573],{"class":833},"    purposes",[784,6575,643],{"class":794},[784,6577,818],{"class":794},[784,6579,6580,6583,6586,6588,6590],{"class":786,"line":958},[784,6581,6582],{"class":794},"      '",[784,6584,6585],{"class":833},"booking-cancel",[784,6587,830],{"class":794},[784,6589,643],{"class":794},[784,6591,818],{"class":794},[784,6593,6594],{"class":786,"line":1333},[784,6595,6596],{"class":1202},"        \u002F\u002F `subject`: what the link opens; `left`: how many uses it has left.\n",[784,6598,6599,6602,6604,6606,6608,6610,6612,6615,6617,6620,6623,6626,6629,6631,6633,6635],{"class":786,"line":1338},[784,6600,6601],{"class":922},"        view",[784,6603,643],{"class":794},[784,6605,2063],{"class":837},[784,6607,841],{"class":794},[784,6609,845],{"class":844},[784,6611,848],{"class":794},[784,6613,6614],{"class":844}," link",[784,6616,5472],{"class":794},[784,6618,6619],{"class":790}," Promise",[784,6621,6622],{"class":794},"\u003C",[784,6624,6625],{"class":790},"LinkView",[784,6627,6628],{"class":794},">",[784,6630,856],{"class":837},[784,6632,6614],{"class":869},[784,6634,886],{"class":794},[784,6636,6637],{"class":869},"left\n",[784,6639,6640,6643,6645,6648,6650,6652,6655,6657,6659,6662,6664,6666,6669,6671,6673,6676,6678,6680,6683,6685,6687,6689,6691,6693,6695,6698,6700,6702,6704,6707,6709,6711,6714,6716,6718,6721,6723,6725],{"class":786,"line":1641},[784,6641,6642],{"class":794},"          ?",[784,6644,797],{"class":794},[784,6646,6647],{"class":833}," status",[784,6649,643],{"class":794},[784,6651,907],{"class":794},[784,6653,6654],{"class":827},"open",[784,6656,830],{"class":794},[784,6658,848],{"class":794},[784,6660,6661],{"class":833}," language",[784,6663,643],{"class":794},[784,6665,907],{"class":794},[784,6667,6668],{"class":827},"en",[784,6670,830],{"class":794},[784,6672,848],{"class":794},[784,6674,6675],{"class":833}," title",[784,6677,643],{"class":794},[784,6679,907],{"class":794},[784,6681,6682],{"class":827},"Cancel booking",[784,6684,830],{"class":794},[784,6686,848],{"class":794},[784,6688,6405],{"class":833},[784,6690,643],{"class":794},[784,6692,2706],{"class":869},[784,6694,830],{"class":794},[784,6696,6697],{"class":827},"Cancel it?",[784,6699,830],{"class":794},[784,6701,5302],{"class":869},[784,6703,848],{"class":794},[784,6705,6706],{"class":833}," action",[784,6708,643],{"class":794},[784,6710,797],{"class":794},[784,6712,6713],{"class":833}," button",[784,6715,643],{"class":794},[784,6717,907],{"class":794},[784,6719,6720],{"class":827},"Cancel",[784,6722,830],{"class":794},[784,6724,878],{"class":794},[784,6726,1057],{"class":794},[784,6728,6729,6732,6734,6736,6738,6740,6743,6745,6747,6749,6751,6753,6755,6757,6759,6761,6763,6765,6767,6769,6771,6773,6775,6777,6779,6782,6784,6786],{"class":786,"line":1647},[784,6730,6731],{"class":794},"          :",[784,6733,797],{"class":794},[784,6735,6647],{"class":833},[784,6737,643],{"class":794},[784,6739,907],{"class":794},[784,6741,6742],{"class":827},"closed",[784,6744,830],{"class":794},[784,6746,848],{"class":794},[784,6748,6661],{"class":833},[784,6750,643],{"class":794},[784,6752,907],{"class":794},[784,6754,6668],{"class":827},[784,6756,830],{"class":794},[784,6758,848],{"class":794},[784,6760,6675],{"class":833},[784,6762,643],{"class":794},[784,6764,907],{"class":794},[784,6766,6682],{"class":827},[784,6768,830],{"class":794},[784,6770,848],{"class":794},[784,6772,6405],{"class":833},[784,6774,643],{"class":794},[784,6776,2706],{"class":869},[784,6778,830],{"class":794},[784,6780,6781],{"class":827},"It is cancelled already.",[784,6783,830],{"class":794},[784,6785,5192],{"class":869},[784,6787,1573],{"class":794},[784,6789,6790],{"class":786,"line":1708},[784,6791,6792],{"class":1202},"        \u002F\u002F `use(ctx)` uses the link in your transaction: false when it was used meanwhile, and then change nothing.\n",[784,6794,6795,6798,6800,6802,6804,6806,6808,6810,6812,6814,6816,6818,6820,6822,6825,6827,6829,6831,6834,6836,6838],{"class":786,"line":1714},[784,6796,6797],{"class":922},"        redeem",[784,6799,643],{"class":794},[784,6801,2063],{"class":837},[784,6803,841],{"class":794},[784,6805,845],{"class":844},[784,6807,848],{"class":794},[784,6809,6614],{"class":844},[784,6811,731],{"class":794},[784,6813,856],{"class":837},[784,6815,1266],{"class":869},[784,6817,886],{"class":794},[784,6819,3341],{"class":869},[784,6821,886],{"class":794},[784,6823,6824],{"class":922},"transaction",[784,6826,926],{"class":869},[784,6828,838],{"class":837},[784,6830,841],{"class":794},[784,6832,6833],{"class":844},"tx",[784,6835,731],{"class":794},[784,6837,856],{"class":837},[784,6839,818],{"class":794},[784,6841,6842,6845,6847,6849,6851,6853,6855,6857,6859,6862,6864,6866,6868,6870,6873,6875,6877,6879,6881,6883,6885,6887,6889,6891,6893,6895,6897,6899,6901,6903,6905,6907,6909,6911,6913,6915,6917,6919,6921,6923,6925,6927],{"class":786,"line":1760},[784,6843,6844],{"class":895},"          if",[784,6846,841],{"class":833},[784,6848,1240],{"class":794},[784,6850,939],{"class":895},[784,6852,6614],{"class":869},[784,6854,886],{"class":794},[784,6856,4611],{"class":922},[784,6858,926],{"class":833},[784,6860,6861],{"class":922},"withDb",[784,6863,926],{"class":833},[784,6865,845],{"class":869},[784,6867,848],{"class":794},[784,6869,2429],{"class":869},[784,6871,6872],{"class":833},"))) ",[784,6874,1248],{"class":895},[784,6876,797],{"class":794},[784,6878,6647],{"class":833},[784,6880,643],{"class":794},[784,6882,907],{"class":794},[784,6884,6742],{"class":827},[784,6886,830],{"class":794},[784,6888,848],{"class":794},[784,6890,6661],{"class":833},[784,6892,643],{"class":794},[784,6894,907],{"class":794},[784,6896,6668],{"class":827},[784,6898,830],{"class":794},[784,6900,848],{"class":794},[784,6902,6675],{"class":833},[784,6904,643],{"class":794},[784,6906,907],{"class":794},[784,6908,6682],{"class":827},[784,6910,830],{"class":794},[784,6912,848],{"class":794},[784,6914,6405],{"class":833},[784,6916,643],{"class":794},[784,6918,2706],{"class":833},[784,6920,830],{"class":794},[784,6922,6781],{"class":827},[784,6924,830],{"class":794},[784,6926,5192],{"class":833},[784,6928,961],{"class":794},[784,6930,6931],{"class":786,"line":1766},[784,6932,6933],{"class":1202},"          \u002F\u002F … cancel booking `link.subject` in `tx` …\n",[784,6935,6936,6939,6941,6943,6945,6947,6949,6951,6953,6955,6957,6959,6961,6963,6965,6967,6969,6971,6973,6975,6977,6979,6981,6983,6985,6988,6990,6992],{"class":786,"line":2413},[784,6937,6938],{"class":895},"          return",[784,6940,797],{"class":794},[784,6942,6647],{"class":833},[784,6944,643],{"class":794},[784,6946,907],{"class":794},[784,6948,6742],{"class":827},[784,6950,830],{"class":794},[784,6952,848],{"class":794},[784,6954,6661],{"class":833},[784,6956,643],{"class":794},[784,6958,907],{"class":794},[784,6960,6668],{"class":827},[784,6962,830],{"class":794},[784,6964,848],{"class":794},[784,6966,6675],{"class":833},[784,6968,643],{"class":794},[784,6970,907],{"class":794},[784,6972,6682],{"class":827},[784,6974,830],{"class":794},[784,6976,848],{"class":794},[784,6978,6405],{"class":833},[784,6980,643],{"class":794},[784,6982,2706],{"class":833},[784,6984,830],{"class":794},[784,6986,6987],{"class":827},"Your booking is cancelled.",[784,6989,830],{"class":794},[784,6991,5192],{"class":833},[784,6993,961],{"class":794},[784,6995,6996,6999],{"class":786,"line":2418},[784,6997,6998],{"class":794},"        }",[784,7000,949],{"class":869},[784,7002,7003],{"class":786,"line":5396},[784,7004,7005],{"class":794},"      }\n",[784,7007,7008],{"class":786,"line":5401},[784,7009,2087],{"class":794},[784,7011,7012],{"class":786,"line":5950},[784,7013,955],{"class":794},[784,7015,7016,7018],{"class":786,"line":5956},[784,7017,1315],{"class":794},[784,7019,949],{"class":869},[784,7021,7022],{"class":786,"line":6018},[784,7023,2203],{"emptyLinePlaceholder":2202},[784,7025,7027],{"class":786,"line":7026},23,[784,7028,7029],{"class":1202},"\u002F\u002F In a mail: `url` lands on SHADE's page or the frontend's; null without the API's address.\n",[784,7031,7033,7035,7037,7040,7042,7044,7046,7048,7050,7052,7054,7056,7058,7060,7062,7064,7066,7068,7070,7073,7075,7077,7079,7082,7084,7087,7089,7092,7094,7097,7099],{"class":786,"line":7032},24,[784,7034,3013],{"class":837},[784,7036,797],{"class":794},[784,7038,7039],{"class":869}," url ",[784,7041,1315],{"class":794},[784,7043,881],{"class":794},[784,7045,3022],{"class":895},[784,7047,6517],{"class":922},[784,7049,1698],{"class":869},[784,7051,848],{"class":794},[784,7053,797],{"class":794},[784,7055,2664],{"class":833},[784,7057,643],{"class":794},[784,7059,907],{"class":794},[784,7061,6585],{"class":827},[784,7063,830],{"class":794},[784,7065,848],{"class":794},[784,7067,5963],{"class":833},[784,7069,643],{"class":794},[784,7071,7072],{"class":869}," booking",[784,7074,886],{"class":794},[784,7076,4274],{"class":869},[784,7078,848],{"class":794},[784,7080,7081],{"class":833}," expiresInMs",[784,7083,643],{"class":794},[784,7085,7086],{"class":1546}," 7",[784,7088,1550],{"class":794},[784,7090,7091],{"class":1546}," 86_400_000",[784,7093,848],{"class":794},[784,7095,7096],{"class":869}," contactId ",[784,7098,1315],{"class":794},[784,7100,949],{"class":869},[1073,7102,7103,7126,7132,7139,7159,7176,7185,7213],{},[1076,7104,7105,7106,5063,7108,7111,7112,7115,7116,7118,7119,3076,7122,7125],{},"A ",[632,7107,6492],{},[632,7109,7110],{},"action.choose"," asks for one choice first (",[632,7113,7114],{},"{ legend, options: [{ value, label }] }","); ",[632,7117,6496],{}," gets the chosen ",[632,7120,7121],{},"value",[632,7123,7124],{},"link.choice",". Check it: anything may come back.",[1076,7127,7128,7131],{},[632,7129,7130],{},"contactId",": the contact the link is sent to. Using the link proves the address, and SHADE confirms the contact.",[1076,7133,7134,7135,7138],{},"Anything that does not work (a wrong or expired token, another module's or purpose's) never reaches your code: SHADE answers the same ",[632,7136,7137],{},"invalid"," view.",[1076,7140,7141,3504,7144,7147,7148,7151,7152,7155,7156,7158],{},[1079,7142,7143],{},"Codes people type:",[632,7145,7146],{},"issueCode(ctx, { purpose, subject, expiresInMs, maxUses?, length? })"," gives a code in a readable alphabet (digits and capitals without I, L, O and U; typing is forgiving). ",[632,7149,7150],{},"peekCode"," says what one opens and how many uses it has left. ",[632,7153,7154],{},"redeemCode"," uses it once, atomically, or answers ",[632,7157,3515],{},", never why. Your route limits how often one can be tried.",[1076,7160,7161,3504,7164,7167,7168,7171,7172,7175],{},[1079,7162,7163],{},"A code with a text you choose:",[632,7165,7166],{},"issueCode(ctx, { …, text: 'SUMMER25' })"," (4 to 32 letters and digits, U too, read back by case only, so ",[632,7169,7170],{},"summer25"," works and ",[632,7173,7174],{},"SUMM3R25"," does not). It is CONFLICT while the same text has not expired for that purpose.",[1076,7177,7178,7181,7182,7184],{},[632,7179,7180],{},"releaseCode(ctx, { purpose, secret, subject })"," gives back one use of a code that ",[632,7183,5832],{}," used, when what used it did not happen (an order never paid). It answers whether a use was given back; call it once per use.",[1076,7186,7187,7190,7191,672,7194,672,7197,672,7200,672,7203,672,7206,672,7209,7212],{},[632,7188,7189],{},"links.theme(ctx)",": CSS variables for SHADE's own link page (",[632,7192,7193],{},"--color-background",[632,7195,7196],{},"--color-text",[632,7198,7199],{},"--color-primary",[632,7201,7202],{},"--color-primary-contrast",[632,7204,7205],{},"--color-border",[632,7207,7208],{},"--font-body",[632,7210,7211],{},"--radius","). The module that styles the site gives it.",[1076,7214,7215,7216,1839,7219,7222],{},"In tests, the testing entry's ",[632,7217,7218],{},"openLink(ctx, url)",[632,7220,7221],{},"followLink(ctx, url, choice?)"," show and use a link from a mail as its page would.",[619,7224,349],{"id":7225},"client-programs",[624,7227,7228,7229,7232,7233,7236,7237,7240,7241,7244,7245,7248],{},"A trusted module may call client programs: the client's own programs in any language that an admin approved on the ",[628,7230,7231],{"href":350},"Programs"," screen and that the instance's host, ",[632,7234,7235],{},"shade-programs",", runs beside it. It never calls one by its address (",[632,7238,7239],{},"moduleFetch"," refuses private addresses): it declares the client programs in its ",[632,7242,7243],{},"programs"," capability and calls them with ",[632,7246,7247],{},"callProgram"," from the server entry, which goes through the host.",[775,7250,7252],{"className":777,"code":7251,"language":779,"meta":780,"style":780},"export default defineModule({\n  name: 'shop',\n  capabilities: { programs: { names: ['price-model'] } },\n  \u002F\u002F …\n})\n\nconst answer = await callProgram(ctx, 'price-model', {\n  method: 'POST',\n  path: '\u002Fpredict',\n  headers: { 'content-type': 'application\u002Fjson' },\n  body: JSON.stringify({ size: 3 })\n})\nif (!answer.ok) throw new Error(`price-model answered ${answer.status}`)\nconst { price } = await answer.json() as { price: number }\n",[632,7253,7254,7266,7280,7315,7319,7325,7329,7357,7371,7387,7414,7445,7451,7496],{"__ignoreMap":780},[784,7255,7256,7258,7260,7262,7264],{"class":786,"line":787},[784,7257,1454],{"class":895},[784,7259,1457],{"class":895},[784,7261,1460],{"class":922},[784,7263,926],{"class":869},[784,7265,1197],{"class":794},[784,7267,7268,7270,7272,7274,7276,7278],{"class":786,"line":811},[784,7269,1469],{"class":833},[784,7271,643],{"class":794},[784,7273,907],{"class":794},[784,7275,3458],{"class":827},[784,7277,830],{"class":794},[784,7279,1481],{"class":794},[784,7281,7282,7284,7286,7288,7291,7293,7295,7298,7300,7302,7304,7307,7309,7311,7313],{"class":786,"line":821},[784,7283,1491],{"class":833},[784,7285,643],{"class":794},[784,7287,797],{"class":794},[784,7289,7290],{"class":833}," programs",[784,7292,643],{"class":794},[784,7294,797],{"class":794},[784,7296,7297],{"class":833}," names",[784,7299,643],{"class":794},[784,7301,2706],{"class":869},[784,7303,830],{"class":794},[784,7305,7306],{"class":827},"price-model",[784,7308,830],{"class":794},[784,7310,5192],{"class":869},[784,7312,1315],{"class":794},[784,7314,808],{"class":794},[784,7316,7317],{"class":786,"line":861},[784,7318,1486],{"class":1202},[784,7320,7321,7323],{"class":786,"line":892},[784,7322,1315],{"class":794},[784,7324,949],{"class":869},[784,7326,7327],{"class":786,"line":952},[784,7328,2203],{"emptyLinePlaceholder":2202},[784,7330,7331,7333,7336,7338,7340,7343,7345,7347,7349,7351,7353,7355],{"class":786,"line":958},[784,7332,3013],{"class":837},[784,7334,7335],{"class":869}," answer ",[784,7337,3019],{"class":794},[784,7339,3022],{"class":895},[784,7341,7342],{"class":922}," callProgram",[784,7344,1698],{"class":869},[784,7346,848],{"class":794},[784,7348,907],{"class":794},[784,7350,7306],{"class":827},[784,7352,830],{"class":794},[784,7354,848],{"class":794},[784,7356,818],{"class":794},[784,7358,7359,7361,7363,7365,7367,7369],{"class":786,"line":1333},[784,7360,4083],{"class":833},[784,7362,643],{"class":794},[784,7364,907],{"class":794},[784,7366,1294],{"class":827},[784,7368,830],{"class":794},[784,7370,1481],{"class":794},[784,7372,7373,7376,7378,7380,7383,7385],{"class":786,"line":1338},[784,7374,7375],{"class":833},"  path",[784,7377,643],{"class":794},[784,7379,907],{"class":794},[784,7381,7382],{"class":827},"\u002Fpredict",[784,7384,830],{"class":794},[784,7386,1481],{"class":794},[784,7388,7389,7392,7394,7396,7398,7401,7403,7405,7407,7410,7412],{"class":786,"line":1641},[784,7390,7391],{"class":833},"  headers",[784,7393,643],{"class":794},[784,7395,797],{"class":794},[784,7397,907],{"class":794},[784,7399,7400],{"class":833},"content-type",[784,7402,830],{"class":794},[784,7404,643],{"class":794},[784,7406,907],{"class":794},[784,7408,7409],{"class":827},"application\u002Fjson",[784,7411,830],{"class":794},[784,7413,808],{"class":794},[784,7415,7416,7419,7421,7424,7426,7429,7431,7433,7436,7438,7441,7443],{"class":786,"line":1647},[784,7417,7418],{"class":833},"  body",[784,7420,643],{"class":794},[784,7422,7423],{"class":869}," JSON",[784,7425,886],{"class":794},[784,7427,7428],{"class":922},"stringify",[784,7430,926],{"class":869},[784,7432,2292],{"class":794},[784,7434,7435],{"class":833}," size",[784,7437,643],{"class":794},[784,7439,7440],{"class":1546}," 3",[784,7442,878],{"class":794},[784,7444,949],{"class":869},[784,7446,7447,7449],{"class":786,"line":1708},[784,7448,1315],{"class":794},[784,7450,949],{"class":869},[784,7452,7453,7455,7457,7459,7462,7464,7467,7470,7473,7476,7478,7480,7483,7485,7487,7489,7492,7494],{"class":786,"line":1714},[784,7454,4588],{"class":895},[784,7456,841],{"class":869},[784,7458,1240],{"class":794},[784,7460,7461],{"class":869},"answer",[784,7463,886],{"class":794},[784,7465,7466],{"class":869},"ok) ",[784,7468,7469],{"class":895},"throw",[784,7471,7472],{"class":794}," new",[784,7474,7475],{"class":922}," Error",[784,7477,926],{"class":869},[784,7479,3784],{"class":794},[784,7481,7482],{"class":827},"price-model answered ",[784,7484,2887],{"class":794},[784,7486,7461],{"class":869},[784,7488,886],{"class":794},[784,7490,7491],{"class":869},"status",[784,7493,2893],{"class":794},[784,7495,949],{"class":869},[784,7497,7498,7500,7502,7504,7506,7508,7510,7513,7515,7518,7520,7522,7524,7527,7529,7531],{"class":786,"line":1760},[784,7499,3013],{"class":837},[784,7501,797],{"class":794},[784,7503,4859],{"class":869},[784,7505,1315],{"class":794},[784,7507,881],{"class":794},[784,7509,3022],{"class":895},[784,7511,7512],{"class":869}," answer",[784,7514,886],{"class":794},[784,7516,7517],{"class":922},"json",[784,7519,2338],{"class":869},[784,7521,4518],{"class":895},[784,7523,797],{"class":794},[784,7525,7526],{"class":833}," price",[784,7528,643],{"class":794},[784,7530,1054],{"class":790},[784,7532,1057],{"class":794},[1073,7534,7535,7602,7627,7630],{},[1076,7536,7537,841,7539,7542,7543,841,7546,7548,7549,672,7552,672,7554,672,7557,672,7560,7563,7564,7567,7568,7563,7571,7574,7575,7578,7579,672,7582,672,7585,672,7587,672,7590,1839,7593,7563,7596,7598,7599,7601],{},[632,7538,4192],{},[632,7540,7541],{},"ProgramRequest","): ",[632,7544,7545],{},"method",[632,7547,4064],{}," by default, or ",[632,7550,7551],{},"HEAD",[632,7553,1294],{},[632,7555,7556],{},"PUT",[632,7558,7559],{},"PATCH",[632,7561,7562],{},"DELETE","), ",[632,7565,7566],{},"path"," on the client program (",[632,7569,7570],{},"\u002Fpredict?x=1",[632,7572,7573],{},"port"," (one it declared; its first by default), ",[632,7576,7577],{},"headers"," (only ",[632,7580,7581],{},"accept",[632,7583,7584],{},"accept-language",[632,7586,7400],{},[632,7588,7589],{},"if-match",[632,7591,7592],{},"if-modified-since",[632,7594,7595],{},"if-none-match",[632,7597,5852],{}," (a string or bytes, at most 1 MB) and ",[632,7600,2964],{}," (10 000 by default, at most 60 000).",[1076,7603,7604,7605,7608,7609,672,7612,672,7615,672,7617,672,7620,1839,7623,7626],{},"The answer is a ",[632,7606,7607],{},"Response",": the client program's status, its ",[632,7610,7611],{},"cache-control",[632,7613,7614],{},"content-language",[632,7616,7400],{},[632,7618,7619],{},"etag",[632,7621,7622],{},"last-modified",[632,7624,7625],{},"location"," headers, and its body (at most 5 MB). A redirect is returned, never followed.",[1076,7628,7629],{},"A client program the capability doesn't name is refused (FORBIDDEN, counted for the module). One that is not approved, an instance without a host, or a client program that is not running is CONFLICT. A host or client program that cannot be reached, fails or is too slow is UNAVAILABLE. Each carries a key the admin translates.",[1076,7631,7632],{},"The client program's own token, not the module's, decides what it may then do on the instance.",[624,7634,7635,7636,7639,7640,3076,7643,7646,7647,709,7650,7653,7654,7656],{},"In tests, ",[632,7637,7638],{},"fakeProgramHost(db, answers)"," from the testing entry stands in for the host. Each client program it names is approved and running, and answers what its function returns (an echo of the method and path when there is none). Pass ",[632,7641,7642],{},"fake.programHost",[632,7644,7645],{},"extra: { programHost }"," to ",[632,7648,7649],{},"shop.ctx(...)",[632,7651,7652],{},"fake.calls"," keeps every call. The ",[632,7655,7243],{}," capability still decides what the module may call.",[619,7658,7660],{"id":7659},"personal-data","Personal data",[624,7662,7663,7664,7667,7668,672,7671,7674,7675,7678,7679,7681,7682,7685,7686,7689,7690,1839,7692,7694,7695,7698],{},"A module that keeps data about people declares where: ",[632,7665,7666],{},"personalData: [{ key, label, tables?, find(ctx, email, accountIds, contactIds), erase?(ctx, email, accountIds, contactIds), keepReason? }]",", with ",[632,7669,7670],{},"erase",[632,7672,7673],{},"keepReason"," or both. Admins then see, export and delete it per email address on the ",[7676,7677,7660],"em",{}," screen, also while the module is off (",[628,7680,269],{"href":270},"). ",[632,7683,7684],{},"accountIds"," are the ids of the accounts with the address and ",[632,7687,7688],{},"contactIds"," the person's contacts (below), both read before anything is erased. A source with both ",[632,7691,7670],{},[632,7693,7673],{}," deletes what may go; what ",[632,7696,7697],{},"find"," still returns afterwards is counted as kept (an order never paid goes, a paid one stays).",[619,7700,7702],{"id":7701},"contacts","Contacts",[624,7704,7705,7706,7708],{},"Experimental. Core keeps one ",[1079,7707,6435],{}," per email address a module met, with or without an account: the address, when the person confirmed it, the language they last used and the account it belongs to. What your module knows about the person stays in your tables, which refer to the contact instead of keeping a bare address:",[775,7710,7712],{"className":777,"code":7711,"language":779,"meta":780,"style":780},"import { contactEmail, contactReference, findOrAddContact, ownedByContact } from '@shadestack\u002Fmodule-sdk\u002Fserver'\n\nexport const shopOrders = pgTable('shop_orders', {\n  id: id(),\n  contactId: contactReference('contact_id').notNull(), \u002F\u002F on delete restrict: an order the law keeps keeps its contact\n  \u002F\u002F …\n})\n\n\u002F\u002F At checkout: the same id whether the contact was new or not, so nobody learns which addresses are known.\nconst contactId = await findOrAddContact(ctx, { email: input.email, language: input.locale })\n\n\u002F\u002F Its address, to send to or show: an SQL expression to select or filter on.\nawait ctx.db.select({ number: shopOrders.number, email: contactEmail(shopOrders.contactId) }).from(shopOrders)\n\n\u002F\u002F A signed-in account's own orders (an account route's `request.account`): their account's contacts and their address's.\nawait ctx.db.select().from(shopOrders).where(ownedByContact(shopOrders.contactId, request.account))\n",[632,7713,7714,7748,7752,7780,7793,7825,7829,7835,7839,7844,7889,7893,7898,7955,7959,7964],{"__ignoreMap":780},[784,7715,7716,7718,7720,7723,7725,7728,7730,7733,7735,7738,7740,7742,7744,7746],{"class":786,"line":787},[784,7717,2150],{"class":895},[784,7719,797],{"class":794},[784,7721,7722],{"class":869}," contactEmail",[784,7724,848],{"class":794},[784,7726,7727],{"class":869}," contactReference",[784,7729,848],{"class":794},[784,7731,7732],{"class":869}," findOrAddContact",[784,7734,848],{"class":794},[784,7736,7737],{"class":869}," ownedByContact",[784,7739,878],{"class":794},[784,7741,2191],{"class":895},[784,7743,907],{"class":794},[784,7745,973],{"class":827},[784,7747,1330],{"class":794},[784,7749,7750],{"class":786,"line":811},[784,7751,2203],{"emptyLinePlaceholder":2202},[784,7753,7754,7756,7759,7762,7764,7767,7769,7771,7774,7776,7778],{"class":786,"line":821},[784,7755,1454],{"class":895},[784,7757,7758],{"class":837}," const",[784,7760,7761],{"class":869}," shopOrders ",[784,7763,3019],{"class":794},[784,7765,7766],{"class":922}," pgTable",[784,7768,926],{"class":869},[784,7770,830],{"class":794},[784,7772,7773],{"class":827},"shop_orders",[784,7775,830],{"class":794},[784,7777,848],{"class":794},[784,7779,818],{"class":794},[784,7781,7782,7785,7787,7789,7791],{"class":786,"line":861},[784,7783,7784],{"class":833},"  id",[784,7786,643],{"class":794},[784,7788,2465],{"class":922},[784,7790,2306],{"class":869},[784,7792,1481],{"class":794},[784,7794,7795,7798,7800,7802,7804,7806,7809,7811,7813,7815,7818,7820,7822],{"class":786,"line":892},[784,7796,7797],{"class":833},"  contactId",[784,7799,643],{"class":794},[784,7801,7727],{"class":922},[784,7803,926],{"class":869},[784,7805,830],{"class":794},[784,7807,7808],{"class":827},"contact_id",[784,7810,830],{"class":794},[784,7812,731],{"class":869},[784,7814,886],{"class":794},[784,7816,7817],{"class":922},"notNull",[784,7819,2306],{"class":869},[784,7821,848],{"class":794},[784,7823,7824],{"class":1202}," \u002F\u002F on delete restrict: an order the law keeps keeps its contact\n",[784,7826,7827],{"class":786,"line":952},[784,7828,1486],{"class":1202},[784,7830,7831,7833],{"class":786,"line":958},[784,7832,1315],{"class":794},[784,7834,949],{"class":869},[784,7836,7837],{"class":786,"line":1333},[784,7838,2203],{"emptyLinePlaceholder":2202},[784,7840,7841],{"class":786,"line":1338},[784,7842,7843],{"class":1202},"\u002F\u002F At checkout: the same id whether the contact was new or not, so nobody learns which addresses are known.\n",[784,7845,7846,7848,7850,7852,7854,7856,7858,7860,7862,7864,7866,7868,7870,7872,7874,7876,7878,7880,7882,7885,7887],{"class":786,"line":1641},[784,7847,3013],{"class":837},[784,7849,7096],{"class":869},[784,7851,3019],{"class":794},[784,7853,3022],{"class":895},[784,7855,7732],{"class":922},[784,7857,1698],{"class":869},[784,7859,848],{"class":794},[784,7861,797],{"class":794},[784,7863,2327],{"class":833},[784,7865,643],{"class":794},[784,7867,4508],{"class":869},[784,7869,886],{"class":794},[784,7871,5596],{"class":869},[784,7873,848],{"class":794},[784,7875,6661],{"class":833},[784,7877,643],{"class":794},[784,7879,4508],{"class":869},[784,7881,886],{"class":794},[784,7883,7884],{"class":869},"locale ",[784,7886,1315],{"class":794},[784,7888,949],{"class":869},[784,7890,7891],{"class":786,"line":1647},[784,7892,2203],{"emptyLinePlaceholder":2202},[784,7894,7895],{"class":786,"line":1708},[784,7896,7897],{"class":1202},"\u002F\u002F Its address, to send to or show: an SQL expression to select or filter on.\n",[784,7899,7900,7902,7904,7906,7908,7910,7913,7915,7917,7919,7921,7924,7926,7928,7930,7932,7934,7936,7939,7941,7944,7946,7948,7950,7952],{"class":786,"line":1714},[784,7901,939],{"class":895},[784,7903,1266],{"class":869},[784,7905,886],{"class":794},[784,7907,3341],{"class":869},[784,7909,886],{"class":794},[784,7911,7912],{"class":922},"select",[784,7914,926],{"class":869},[784,7916,2292],{"class":794},[784,7918,1054],{"class":833},[784,7920,643],{"class":794},[784,7922,7923],{"class":869}," shopOrders",[784,7925,886],{"class":794},[784,7927,2320],{"class":869},[784,7929,848],{"class":794},[784,7931,2327],{"class":833},[784,7933,643],{"class":794},[784,7935,7722],{"class":922},[784,7937,7938],{"class":869},"(shopOrders",[784,7940,886],{"class":794},[784,7942,7943],{"class":869},"contactId) ",[784,7945,1315],{"class":794},[784,7947,731],{"class":869},[784,7949,886],{"class":794},[784,7951,2161],{"class":922},[784,7953,7954],{"class":869},"(shopOrders)\n",[784,7956,7957],{"class":786,"line":1760},[784,7958,2203],{"emptyLinePlaceholder":2202},[784,7960,7961],{"class":786,"line":1766},[784,7962,7963],{"class":1202},"\u002F\u002F A signed-in account's own orders (an account route's `request.account`): their account's contacts and their address's.\n",[784,7965,7966,7968,7970,7972,7974,7976,7978,7980,7982,7984,7987,7989,7992,7994,7997,7999,8001,8003,8005,8007,8009],{"class":786,"line":2413},[784,7967,939],{"class":895},[784,7969,1266],{"class":869},[784,7971,886],{"class":794},[784,7973,3341],{"class":869},[784,7975,886],{"class":794},[784,7977,7912],{"class":922},[784,7979,2306],{"class":869},[784,7981,886],{"class":794},[784,7983,2161],{"class":922},[784,7985,7986],{"class":869},"(shopOrders)",[784,7988,886],{"class":794},[784,7990,7991],{"class":922},"where",[784,7993,926],{"class":869},[784,7995,7996],{"class":922},"ownedByContact",[784,7998,7938],{"class":869},[784,8000,886],{"class":794},[784,8002,7130],{"class":869},[784,8004,848],{"class":794},[784,8006,4181],{"class":869},[784,8008,886],{"class":794},[784,8010,8011],{"class":869},"account))\n",[1073,8013,8014,8038,8048],{},[1076,8015,8016,8019,8020,8023,8024,8027,8028,8031,8032,841,8034,8037],{},[1079,8017,8018],{},"Personal data."," A table with a ",[632,8021,8022],{},"contactReference"," must be in the ",[632,8025,8026],{},"tables"," of a ",[632,8029,8030],{},"personalData"," source that erases, or the module does not load. Find and erase by ",[632,8033,7688],{},[632,8035,8036],{},"inArray(shopOrders.contactId, [...contactIds])","). The contacts themselves are erased after every module's rows; one that rows you keep still refer to stays.",[1076,8039,8040,8043,8044,8047],{},[1079,8041,8042],{},"Confirmed."," A contact is confirmed only when the person proves the address: signing in with it, or a link your module sent to the address and they followed (call ",[632,8045,8046],{},"confirmContact(ctx, contactId)"," then). Only a confirmed address links a contact to an account, and only by signing in.",[1076,8049,8050,8053,8054,8057,8058,8062],{},[1079,8051,8052],{},"The People screen."," Admins see every contact there. Your module shows what it keeps about one in a contact panel (",[632,8055,8056],{},"admin.contactPanels",", see ",[628,8059,8061],{"href":8060},"\u002Fdevelopers\u002Fmodules\u002Fadmin-and-site#where-a-module-appears-in-the-admin","Where a module appears in the admin","), read through a session route of your own that checks your read action.",[619,8064,8066],{"id":8065},"numbering","Numbering",[624,8068,8069,8070,672,8073,8076],{},"Experimental. A gap-free number series per module per year, as Dutch invoice law asks for invoices: ",[632,8071,8072],{},"2026-0001",[632,8074,8075],{},"2026-0002","… Take the next number in the transaction of the change it numbers:",[775,8078,8080],{"className":777,"code":8079,"language":779,"meta":780,"style":780},"import { inTransaction, nextNumber } from '@shadestack\u002Fmodule-sdk\u002Fserver'\n\nawait inTransaction(ctx, async (tx) => {\n  const { number } = await nextNumber(tx, 'invoices', { at: paidAt, digits: 4 }) \u002F\u002F '2026-0001'\n  await tx.db.insert(shopInvoices).values({ number, orderId })\n})\n",[632,8081,8082,8105,8109,8131,8187,8229],{"__ignoreMap":780},[784,8083,8084,8086,8088,8090,8092,8095,8097,8099,8101,8103],{"class":786,"line":787},[784,8085,2150],{"class":895},[784,8087,797],{"class":794},[784,8089,2186],{"class":869},[784,8091,848],{"class":794},[784,8093,8094],{"class":869}," nextNumber",[784,8096,878],{"class":794},[784,8098,2191],{"class":895},[784,8100,907],{"class":794},[784,8102,973],{"class":827},[784,8104,1330],{"class":794},[784,8106,8107],{"class":786,"line":811},[784,8108,2203],{"emptyLinePlaceholder":2202},[784,8110,8111,8113,8115,8117,8119,8121,8123,8125,8127,8129],{"class":786,"line":821},[784,8112,939],{"class":895},[784,8114,2186],{"class":922},[784,8116,1698],{"class":869},[784,8118,848],{"class":794},[784,8120,2063],{"class":837},[784,8122,841],{"class":794},[784,8124,6833],{"class":844},[784,8126,731],{"class":794},[784,8128,856],{"class":837},[784,8130,818],{"class":794},[784,8132,8133,8135,8137,8139,8141,8143,8145,8147,8149,8151,8153,8155,8157,8159,8161,8163,8166,8168,8171,8173,8176,8178,8180,8182,8184],{"class":786,"line":861},[784,8134,4977],{"class":837},[784,8136,797],{"class":794},[784,8138,1054],{"class":869},[784,8140,878],{"class":794},[784,8142,881],{"class":794},[784,8144,3022],{"class":895},[784,8146,8094],{"class":922},[784,8148,926],{"class":833},[784,8150,6833],{"class":869},[784,8152,848],{"class":794},[784,8154,907],{"class":794},[784,8156,2583],{"class":827},[784,8158,830],{"class":794},[784,8160,848],{"class":794},[784,8162,797],{"class":794},[784,8164,8165],{"class":833}," at",[784,8167,643],{"class":794},[784,8169,8170],{"class":869}," paidAt",[784,8172,848],{"class":794},[784,8174,8175],{"class":833}," digits",[784,8177,643],{"class":794},[784,8179,2630],{"class":1546},[784,8181,878],{"class":794},[784,8183,1194],{"class":833},[784,8185,8186],{"class":1202},"\u002F\u002F '2026-0001'\n",[784,8188,8189,8192,8194,8196,8198,8200,8203,8205,8208,8210,8212,8215,8217,8219,8221,8223,8225,8227],{"class":786,"line":892},[784,8190,8191],{"class":895},"  await",[784,8193,2429],{"class":869},[784,8195,886],{"class":794},[784,8197,3341],{"class":869},[784,8199,886],{"class":794},[784,8201,8202],{"class":922},"insert",[784,8204,926],{"class":833},[784,8206,8207],{"class":869},"shopInvoices",[784,8209,731],{"class":833},[784,8211,886],{"class":794},[784,8213,8214],{"class":922},"values",[784,8216,926],{"class":833},[784,8218,2292],{"class":794},[784,8220,1054],{"class":869},[784,8222,848],{"class":794},[784,8224,2744],{"class":869},[784,8226,878],{"class":794},[784,8228,949],{"class":833},[784,8230,8231,8233],{"class":786,"line":952},[784,8232,1315],{"class":794},[784,8234,949],{"class":869},[1073,8236,8237,8243,8260],{},[1076,8238,8239,8242],{},[1079,8240,8241],{},"Only in a transaction",", and only on the context SHADE gave your code: the series' row stays locked until the transaction commits, so a second caller waits, and a rollback gives the number back. No gap, no number twice. A Postgres sequence leaves gaps and is not used.",[1076,8244,8245,8248,8249,8251,8252,8255,8256,8259],{},[1079,8246,8247],{},"The year"," is the year of ",[632,8250,4364],{}," (default now) in the site's time zone: each series starts at 1 every year. The answer is ",[632,8253,8254],{},"{ number, year, sequence }",", the sequence padded to ",[632,8257,8258],{},"digits"," (default 4).",[1076,8261,8262,8265],{},[1079,8263,8264],{},"Your own."," A series is named with small letters, digits and hyphens, and belongs to your module. It stays when the module is removed, so installed again it never repeats a number.",[619,8267,8269],{"id":8268},"holds","Holds",[624,8271,8272,8273,672,8276,8279],{},"Experimental. Hold N of one of your resources until an expiry, or a time range of it, so the last place is never held twice: stock while a customer pays, a time slot, a seat. SHADE keeps no catalogue of your resources: you name them (",[632,8274,8275],{},"sku:MUG-1",[632,8277,8278],{},"slots:default",") and give the capacity with each hold, from your own data.",[775,8281,8283],{"className":777,"code":8282,"language":779,"meta":780,"style":780},"import { confirmHold, heldCount, hold, inTransaction, releaseGroup } from '@shadestack\u002Fmodule-sdk\u002Fserver'\n\nawait inTransaction(ctx, async (tx) => {\n  \u002F\u002F CONFLICT holds.errors.full (with `available`) when fewer than 2 of the 5 are free.\n  await hold(tx, { resource: 'sku:MUG-1', quantity: 2, capacity: 5, expiresAt: inTenMinutes, group: `order:${orderId}` })\n})\nawait heldCount(ctx, 'sku:MUG-1')                               \u002F\u002F 2 while it runs\nawait confirmHold(ctx, holdId)                                  \u002F\u002F counts until released\nawait confirmHold(ctx, holdId, { taken: true })                 \u002F\u002F you took the units off your own count: counts no more\nawait releaseGroup(ctx, `order:${orderId}`)                     \u002F\u002F give an order's holds back\n",[632,8284,8285,8323,8327,8349,8354,8429,8435,8457,8473,8505],{"__ignoreMap":780},[784,8286,8287,8289,8291,8294,8296,8299,8301,8304,8306,8308,8310,8313,8315,8317,8319,8321],{"class":786,"line":787},[784,8288,2150],{"class":895},[784,8290,797],{"class":794},[784,8292,8293],{"class":869}," confirmHold",[784,8295,848],{"class":794},[784,8297,8298],{"class":869}," heldCount",[784,8300,848],{"class":794},[784,8302,8303],{"class":869}," hold",[784,8305,848],{"class":794},[784,8307,2186],{"class":869},[784,8309,848],{"class":794},[784,8311,8312],{"class":869}," releaseGroup",[784,8314,878],{"class":794},[784,8316,2191],{"class":895},[784,8318,907],{"class":794},[784,8320,973],{"class":827},[784,8322,1330],{"class":794},[784,8324,8325],{"class":786,"line":811},[784,8326,2203],{"emptyLinePlaceholder":2202},[784,8328,8329,8331,8333,8335,8337,8339,8341,8343,8345,8347],{"class":786,"line":821},[784,8330,939],{"class":895},[784,8332,2186],{"class":922},[784,8334,1698],{"class":869},[784,8336,848],{"class":794},[784,8338,2063],{"class":837},[784,8340,841],{"class":794},[784,8342,6833],{"class":844},[784,8344,731],{"class":794},[784,8346,856],{"class":837},[784,8348,818],{"class":794},[784,8350,8351],{"class":786,"line":861},[784,8352,8353],{"class":1202},"  \u002F\u002F CONFLICT holds.errors.full (with `available`) when fewer than 2 of the 5 are free.\n",[784,8355,8356,8358,8360,8362,8364,8366,8368,8371,8373,8375,8377,8379,8381,8384,8386,8388,8390,8393,8395,8398,8400,8403,8405,8408,8410,8413,8415,8417,8419,8421,8423,8425,8427],{"class":786,"line":892},[784,8357,8191],{"class":895},[784,8359,8303],{"class":922},[784,8361,926],{"class":833},[784,8363,6833],{"class":869},[784,8365,848],{"class":794},[784,8367,797],{"class":794},[784,8369,8370],{"class":833}," resource",[784,8372,643],{"class":794},[784,8374,907],{"class":794},[784,8376,8275],{"class":827},[784,8378,830],{"class":794},[784,8380,848],{"class":794},[784,8382,8383],{"class":833}," quantity",[784,8385,643],{"class":794},[784,8387,2649],{"class":1546},[784,8389,848],{"class":794},[784,8391,8392],{"class":833}," capacity",[784,8394,643],{"class":794},[784,8396,8397],{"class":1546}," 5",[784,8399,848],{"class":794},[784,8401,8402],{"class":833}," expiresAt",[784,8404,643],{"class":794},[784,8406,8407],{"class":869}," inTenMinutes",[784,8409,848],{"class":794},[784,8411,8412],{"class":833}," group",[784,8414,643],{"class":794},[784,8416,2881],{"class":794},[784,8418,2884],{"class":827},[784,8420,2887],{"class":794},[784,8422,2890],{"class":869},[784,8424,2893],{"class":794},[784,8426,878],{"class":794},[784,8428,949],{"class":833},[784,8430,8431,8433],{"class":786,"line":952},[784,8432,1315],{"class":794},[784,8434,949],{"class":869},[784,8436,8437,8439,8441,8443,8445,8447,8449,8451,8454],{"class":786,"line":958},[784,8438,939],{"class":895},[784,8440,8298],{"class":922},[784,8442,1698],{"class":869},[784,8444,848],{"class":794},[784,8446,907],{"class":794},[784,8448,8275],{"class":827},[784,8450,830],{"class":794},[784,8452,8453],{"class":869},")                               ",[784,8455,8456],{"class":1202},"\u002F\u002F 2 while it runs\n",[784,8458,8459,8461,8463,8465,8467,8470],{"class":786,"line":1333},[784,8460,939],{"class":895},[784,8462,8293],{"class":922},[784,8464,1698],{"class":869},[784,8466,848],{"class":794},[784,8468,8469],{"class":869}," holdId)                                  ",[784,8471,8472],{"class":1202},"\u002F\u002F counts until released\n",[784,8474,8475,8477,8479,8481,8483,8486,8488,8490,8493,8495,8497,8499,8502],{"class":786,"line":1338},[784,8476,939],{"class":895},[784,8478,8293],{"class":922},[784,8480,1698],{"class":869},[784,8482,848],{"class":794},[784,8484,8485],{"class":869}," holdId",[784,8487,848],{"class":794},[784,8489,797],{"class":794},[784,8491,8492],{"class":833}," taken",[784,8494,643],{"class":794},[784,8496,5043],{"class":5016},[784,8498,878],{"class":794},[784,8500,8501],{"class":869},")                 ",[784,8503,8504],{"class":1202},"\u002F\u002F you took the units off your own count: counts no more\n",[784,8506,8507,8509,8511,8513,8515,8517,8519,8521,8523,8525,8528],{"class":786,"line":1641},[784,8508,939],{"class":895},[784,8510,8312],{"class":922},[784,8512,1698],{"class":869},[784,8514,848],{"class":794},[784,8516,2881],{"class":794},[784,8518,2884],{"class":827},[784,8520,2887],{"class":794},[784,8522,2890],{"class":869},[784,8524,2893],{"class":794},[784,8526,8527],{"class":869},")                     ",[784,8529,8530],{"class":1202},"\u002F\u002F give an order's holds back\n",[1073,8532,8533,8539,8553,8582,8606,8623,8638],{},[1076,8534,8535,8538],{},[1079,8536,8537],{},"Atomic."," A hold takes a lock per resource for the rest of the transaction, counts what is held and only then holds. In your transaction it is kept or rolled back with your change.",[1076,8540,8541,8544,8545,8548,8549,8552],{},[1079,8542,8543],{},"What counts",": confirmed holds, and held ones until their ",[632,8546,8547],{},"expiresAt",". A hold past its expiry stops counting at once and can't be confirmed; SHADE's sweep marks it expired every minute. ",[632,8550,8551],{},"taken"," keeps a confirmed hold as proof without counting it, for stock you lowered yourself.",[1076,8554,8555,834,8558,8561,8562,8565,8566,8569,8570,8573,8574,8577,8578,8581],{},[1079,8556,8557],{},"Time ranges",[632,8559,8560],{},"during: { start, end }"," (the end not included) counts the most held at any one moment of it, widened by ",[632,8563,8564],{},"bufferMinutes"," on both sides; ",[632,8567,8568],{},"heldCount"," takes the same options. With a capacity of 2, holds for 09:00–09:30 and 09:30–10:00 use one place at a time, so a hold for 09:00–10:30 still fits. A page of free times reads ",[632,8571,8572],{},"heldRanges"," once and counts each time with ",[632,8575,8576],{},"peakHeld(ranges, { start, end }, bufferMinutes)",", as ",[632,8579,8580],{},"hold"," counts.",[1076,8583,8584,834,8587,8590,8591,1858,8594,8597,8598,8601,8602,8605],{},[1079,8585,8586],{},"A quota per holder",[632,8588,8589],{},"holders"," (your keys, such as ",[632,8592,8593],{},"contact:\u003Cid>",[632,8595,8596],{},"ip:\u003Cvisitor key>",") with ",[632,8599,8600],{},"quota: 3"," refuses a fourth running hold of the resource by any of them (CONFLICT ",[632,8603,8604],{},"holds.errors.quota","). An ended hold keeps nobody's key.",[1076,8607,8608,834,8611,8614,8615,8618,8619,8622],{},[1079,8609,8610],{},"Groups",[632,8612,8613],{},"group"," names holds that go together; ",[632,8616,8617],{},"groupHolds"," reads them and ",[632,8620,8621],{},"releaseGroup"," ends them.",[1076,8624,8625,8628,8629,8632,8633,886],{},[1079,8626,8627],{},"Live counts",": every change tells the realtime topic ",[632,8630,8631],{},"holdsTopic(resource)"," once it commits. A route that shows a count names it in its ",[628,8634,8636],{"href":8635},"#realtime-updates",[632,8637,4299],{},[1076,8639,8640,8642,8643,8646],{},[1079,8641,8264],{}," Only on the context SHADE gave your code, on your module's holds alone. Removing the module backs them up and forgets them; ended holds go a week after they end. ",[632,8644,8645],{},"heldCounts(ctx, resources)"," counts many at once.",[1145,8648,8650],{"id":8649},"waitlists","Waitlists",[624,8652,8653],{},"Experimental. When a resource is full, a holder can wait in line for it. When room comes free, SHADE offers it to the first in line by holding it for them:",[775,8655,8657],{"className":777,"code":8656,"language":779,"meta":780,"style":780},"import { acceptOffer, claim, heldRanges, offerNext, withdrawClaim } from '@shadestack\u002Fmodule-sdk\u002Fserver'\n\nconst place = await claim(ctx, { resource: 'slots:default', during: { start, end }, holder: `contact:${contactId}`, group: `booking:${id}` })\n\n\u002F\u002F When your module hears that a hold was freed (below): offer the room to those in line, in order.\nawait offerNext(ctx, 'slots:default', { capacity: 2, during: { start, end }, bufferMinutes: 10, offerMinutes: 30 })\nawait acceptOffer(ctx, claimId)                 \u002F\u002F the offer's hold is confirmed\nawait withdrawClaim(ctx, claimId)               \u002F\u002F out of line; an offer is given back\nawait heldRanges(ctx, 'slots:default', { during: { start, end } }) \u002F\u002F the ranges held, to cut free times from\n",[632,8658,8659,8698,8702,8787,8791,8796,8859,8875,8891],{"__ignoreMap":780},[784,8660,8661,8663,8665,8668,8670,8673,8675,8678,8680,8683,8685,8688,8690,8692,8694,8696],{"class":786,"line":787},[784,8662,2150],{"class":895},[784,8664,797],{"class":794},[784,8666,8667],{"class":869}," acceptOffer",[784,8669,848],{"class":794},[784,8671,8672],{"class":869}," claim",[784,8674,848],{"class":794},[784,8676,8677],{"class":869}," heldRanges",[784,8679,848],{"class":794},[784,8681,8682],{"class":869}," offerNext",[784,8684,848],{"class":794},[784,8686,8687],{"class":869}," withdrawClaim",[784,8689,878],{"class":794},[784,8691,2191],{"class":895},[784,8693,907],{"class":794},[784,8695,973],{"class":827},[784,8697,1330],{"class":794},[784,8699,8700],{"class":786,"line":811},[784,8701,2203],{"emptyLinePlaceholder":2202},[784,8703,8704,8706,8709,8711,8713,8715,8717,8719,8721,8723,8725,8727,8729,8731,8733,8736,8738,8740,8743,8745,8748,8750,8753,8755,8757,8760,8762,8764,8766,8768,8770,8772,8774,8777,8779,8781,8783,8785],{"class":786,"line":821},[784,8705,3013],{"class":837},[784,8707,8708],{"class":869}," place ",[784,8710,3019],{"class":794},[784,8712,3022],{"class":895},[784,8714,8672],{"class":922},[784,8716,1698],{"class":869},[784,8718,848],{"class":794},[784,8720,797],{"class":794},[784,8722,8370],{"class":833},[784,8724,643],{"class":794},[784,8726,907],{"class":794},[784,8728,8278],{"class":827},[784,8730,830],{"class":794},[784,8732,848],{"class":794},[784,8734,8735],{"class":833}," during",[784,8737,643],{"class":794},[784,8739,797],{"class":794},[784,8741,8742],{"class":869}," start",[784,8744,848],{"class":794},[784,8746,8747],{"class":869}," end ",[784,8749,2477],{"class":794},[784,8751,8752],{"class":833}," holder",[784,8754,643],{"class":794},[784,8756,2881],{"class":794},[784,8758,8759],{"class":827},"contact:",[784,8761,2887],{"class":794},[784,8763,7130],{"class":869},[784,8765,2893],{"class":794},[784,8767,848],{"class":794},[784,8769,8412],{"class":833},[784,8771,643],{"class":794},[784,8773,2881],{"class":794},[784,8775,8776],{"class":827},"booking:",[784,8778,2887],{"class":794},[784,8780,4274],{"class":869},[784,8782,2893],{"class":794},[784,8784,878],{"class":794},[784,8786,949],{"class":869},[784,8788,8789],{"class":786,"line":861},[784,8790,2203],{"emptyLinePlaceholder":2202},[784,8792,8793],{"class":786,"line":892},[784,8794,8795],{"class":1202},"\u002F\u002F When your module hears that a hold was freed (below): offer the room to those in line, in order.\n",[784,8797,8798,8800,8802,8804,8806,8808,8810,8812,8814,8816,8818,8820,8822,8824,8826,8828,8830,8832,8834,8836,8838,8841,8843,8845,8847,8850,8852,8855,8857],{"class":786,"line":952},[784,8799,939],{"class":895},[784,8801,8682],{"class":922},[784,8803,1698],{"class":869},[784,8805,848],{"class":794},[784,8807,907],{"class":794},[784,8809,8278],{"class":827},[784,8811,830],{"class":794},[784,8813,848],{"class":794},[784,8815,797],{"class":794},[784,8817,8392],{"class":833},[784,8819,643],{"class":794},[784,8821,2649],{"class":1546},[784,8823,848],{"class":794},[784,8825,8735],{"class":833},[784,8827,643],{"class":794},[784,8829,797],{"class":794},[784,8831,8742],{"class":869},[784,8833,848],{"class":794},[784,8835,8747],{"class":869},[784,8837,2477],{"class":794},[784,8839,8840],{"class":833}," bufferMinutes",[784,8842,643],{"class":794},[784,8844,3825],{"class":1546},[784,8846,848],{"class":794},[784,8848,8849],{"class":833}," offerMinutes",[784,8851,643],{"class":794},[784,8853,8854],{"class":1546}," 30",[784,8856,878],{"class":794},[784,8858,949],{"class":869},[784,8860,8861,8863,8865,8867,8869,8872],{"class":786,"line":958},[784,8862,939],{"class":895},[784,8864,8667],{"class":922},[784,8866,1698],{"class":869},[784,8868,848],{"class":794},[784,8870,8871],{"class":869}," claimId)                 ",[784,8873,8874],{"class":1202},"\u002F\u002F the offer's hold is confirmed\n",[784,8876,8877,8879,8881,8883,8885,8888],{"class":786,"line":1333},[784,8878,939],{"class":895},[784,8880,8687],{"class":922},[784,8882,1698],{"class":869},[784,8884,848],{"class":794},[784,8886,8887],{"class":869}," claimId)               ",[784,8889,8890],{"class":1202},"\u002F\u002F out of line; an offer is given back\n",[784,8892,8893,8895,8897,8899,8901,8903,8905,8907,8909,8911,8913,8915,8917,8919,8921,8923,8925,8927,8929],{"class":786,"line":1338},[784,8894,939],{"class":895},[784,8896,8677],{"class":922},[784,8898,1698],{"class":869},[784,8900,848],{"class":794},[784,8902,907],{"class":794},[784,8904,8278],{"class":827},[784,8906,830],{"class":794},[784,8908,848],{"class":794},[784,8910,797],{"class":794},[784,8912,8735],{"class":833},[784,8914,643],{"class":794},[784,8916,797],{"class":794},[784,8918,8742],{"class":869},[784,8920,848],{"class":794},[784,8922,8747],{"class":869},[784,8924,1315],{"class":794},[784,8926,878],{"class":794},[784,8928,1194],{"class":869},[784,8930,8931],{"class":1202},"\u002F\u002F the ranges held, to cut free times from\n",[1073,8933,8934,8950,8983,8993],{},[1076,8935,8936,3504,8939,8942,8943,8946,8947,8949],{},[1079,8937,8938],{},"In order.",[632,8940,8941],{},"offerNext"," works under the resource's lock: the first claims that fit each get a hold that expires after ",[632,8944,8945],{},"offerMinutes",", held by the claimant in the claim's ",[632,8948,8613],{},". The first claim that does not fit stops it, so nobody skips the line. A holder has one running claim at a time.",[1076,8951,8952,8955,8956,841,8959,672,8962,672,8965,672,8968,672,8971,8974,8975,8979,8980,8982],{},[1079,8953,8954],{},"The event."," When a hold ends or is released, SHADE tells the module that owned it with ",[632,8957,8958],{},"holds.hold.freed",[632,8960,8961],{},"owner",[632,8963,8964],{},"resource",[632,8966,8967],{},"quantity",[632,8969,8970],{},"start",[632,8972,8973],{},"end","), through the manifest part ",[628,8976,8977],{"href":630},[632,8978,634],{},". No other module hears it. Your handler calls ",[632,8981,8941],{}," and tells the person.",[1076,8984,8985,8988,8989,8992],{},[1079,8986,8987],{},"Ending."," An offer that is not accepted before its hold expires lapses, and its room is freed again, so the next in line is offered it. A claim whose range has started lapses too. Ended claims go a week later. ",[632,8990,8991],{},"groupClaims(ctx, group)"," reads claims that go together.",[1076,8994,8995,8997],{},[1079,8996,8264],{}," Only on the context SHADE gave your code, on your module's claims alone. Removing the module backs them up and forgets them.",[619,8999,9001],{"id":9000},"time-rules","Time rules",[624,9003,9004],{},"Experimental. Core keeps your module's named opening rules in the site's time zone: a week of opening periods and exceptions to it. SHADE works out the open times; your module cuts them into what it sells. No capability is needed.",[775,9006,9008],{"className":777,"code":9007,"language":779,"meta":780,"style":780},"import { ensureTimeRules, saveTimeRules } from '@shadestack\u002Fmodule-sdk\u002Fserver'\nimport { isOpen, openIntervals, withoutPast } from '@shadestack\u002Fmodule-sdk\u002Fshared'\n\nconst { rules, timeZone, updatedAt } = await ensureTimeRules(ctx, 'default') \u002F\u002F closed all week the first time\nawait saveTimeRules(ctx, 'location:7', { rules: withoutPast(next, today), baseUpdatedAt: null }) \u002F\u002F audited as time-rules.update\nconst intervals = openIntervals(rules, from, to, timeZone) \u002F\u002F open stretches as instants, at most 400 days\nisOpen(rules, new Date(), timeZone)\n",[632,9009,9010,9034,9064,9068,9110,9162,9192],{"__ignoreMap":780},[784,9011,9012,9014,9016,9019,9021,9024,9026,9028,9030,9032],{"class":786,"line":787},[784,9013,2150],{"class":895},[784,9015,797],{"class":794},[784,9017,9018],{"class":869}," ensureTimeRules",[784,9020,848],{"class":794},[784,9022,9023],{"class":869}," saveTimeRules",[784,9025,878],{"class":794},[784,9027,2191],{"class":895},[784,9029,907],{"class":794},[784,9031,973],{"class":827},[784,9033,1330],{"class":794},[784,9035,9036,9038,9040,9043,9045,9048,9050,9053,9055,9057,9059,9062],{"class":786,"line":811},[784,9037,2150],{"class":895},[784,9039,797],{"class":794},[784,9041,9042],{"class":869}," isOpen",[784,9044,848],{"class":794},[784,9046,9047],{"class":869}," openIntervals",[784,9049,848],{"class":794},[784,9051,9052],{"class":869}," withoutPast",[784,9054,878],{"class":794},[784,9056,2191],{"class":895},[784,9058,907],{"class":794},[784,9060,9061],{"class":827},"@shadestack\u002Fmodule-sdk\u002Fshared",[784,9063,1330],{"class":794},[784,9065,9066],{"class":786,"line":821},[784,9067,2203],{"emptyLinePlaceholder":2202},[784,9069,9070,9072,9074,9077,9079,9081,9083,9086,9088,9090,9092,9094,9096,9098,9100,9103,9105,9107],{"class":786,"line":861},[784,9071,3013],{"class":837},[784,9073,797],{"class":794},[784,9075,9076],{"class":869}," rules",[784,9078,848],{"class":794},[784,9080,1612],{"class":869},[784,9082,848],{"class":794},[784,9084,9085],{"class":869}," updatedAt ",[784,9087,1315],{"class":794},[784,9089,881],{"class":794},[784,9091,3022],{"class":895},[784,9093,9018],{"class":922},[784,9095,1698],{"class":869},[784,9097,848],{"class":794},[784,9099,907],{"class":794},[784,9101,9102],{"class":827},"default",[784,9104,830],{"class":794},[784,9106,1194],{"class":869},[784,9108,9109],{"class":1202},"\u002F\u002F closed all week the first time\n",[784,9111,9112,9114,9116,9118,9120,9122,9125,9127,9129,9131,9133,9135,9137,9140,9142,9145,9147,9150,9152,9155,9157,9159],{"class":786,"line":892},[784,9113,939],{"class":895},[784,9115,9023],{"class":922},[784,9117,1698],{"class":869},[784,9119,848],{"class":794},[784,9121,907],{"class":794},[784,9123,9124],{"class":827},"location:7",[784,9126,830],{"class":794},[784,9128,848],{"class":794},[784,9130,797],{"class":794},[784,9132,9076],{"class":833},[784,9134,643],{"class":794},[784,9136,9052],{"class":922},[784,9138,9139],{"class":869},"(next",[784,9141,848],{"class":794},[784,9143,9144],{"class":869}," today)",[784,9146,848],{"class":794},[784,9148,9149],{"class":833}," baseUpdatedAt",[784,9151,643],{"class":794},[784,9153,9154],{"class":794}," null",[784,9156,878],{"class":794},[784,9158,1194],{"class":869},[784,9160,9161],{"class":1202},"\u002F\u002F audited as time-rules.update\n",[784,9163,9164,9166,9169,9171,9173,9176,9178,9180,9182,9184,9186,9189],{"class":786,"line":952},[784,9165,3013],{"class":837},[784,9167,9168],{"class":869}," intervals ",[784,9170,3019],{"class":794},[784,9172,9047],{"class":922},[784,9174,9175],{"class":869},"(rules",[784,9177,848],{"class":794},[784,9179,2191],{"class":869},[784,9181,848],{"class":794},[784,9183,6032],{"class":869},[784,9185,848],{"class":794},[784,9187,9188],{"class":869}," timeZone) ",[784,9190,9191],{"class":1202},"\u002F\u002F open stretches as instants, at most 400 days\n",[784,9193,9194,9197,9199,9201,9203,9206,9208,9210],{"class":786,"line":958},[784,9195,9196],{"class":922},"isOpen",[784,9198,9175],{"class":869},[784,9200,848],{"class":794},[784,9202,7472],{"class":794},[784,9204,9205],{"class":922}," Date",[784,9207,2306],{"class":869},[784,9209,848],{"class":794},[784,9211,9212],{"class":869}," timeZone)\n",[1073,9214,9215,9286,9306,9319,9338,9359,9382],{},[1076,9216,9217,3504,9220,9223,9224,9227,9228,9231,9232,1792,9235,9238,9239,9242,9243,9245,9246,9248,9249,9252,9253,841,9256,7542,9259,9262,9263,7563,9266,672,9268,9271,9272,9275,9276,9279,9280,9282,9283,886],{},[1079,9218,9219],{},"The rules.",[632,9221,9222],{},"TimeRules"," is a ",[632,9225,9226],{},"week"," (seven days of at most four non-overlapping ",[632,9229,9230],{},"OpeningPeriod","s, ",[632,9233,9234],{},"09:00",[632,9236,9237],{},"17:00",") and at most 366 ",[632,9240,9241],{},"exceptions",". An exception is ",[632,9244,6742],{}," (the whole day) or ",[632,9247,6654],{}," (at its own periods instead of the week's), from a ",[632,9250,9251],{},"date",", repeating ",[632,9254,9255],{},"every",[632,9257,9258],{},"RECURRENCES",[632,9260,9261],{},"once"," (or each day until ",[632,9264,9265],{},"until",[632,9267,9226],{},[632,9269,9270],{},"month"," (skipped in months without that day), ",[632,9273,9274],{},"month-weekday"," (such as the first Monday) or ",[632,9277,9278],{},"year",". It may have an ",[632,9281,9265],{}," and a ",[632,9284,9285],{},"note",[1076,9287,9288,9291,9292,9294,9295,1839,9298,9301,9302,9305],{},[1079,9289,9290],{},"Which decides."," A dated (",[632,9293,9261],{},") exception beats a repeating one, and a closing beats an opening. ",[632,9296,9297],{},"appliesOn",[632,9299,9300],{},"periodsOn"," answer for one date; ",[632,9303,9304],{},"closedRules()"," gives rules that are never open.",[1076,9307,9308,3504,9311,9314,9315,9318],{},[1079,9309,9310],{},"Open times.",[632,9312,9313],{},"openIntervals"," cuts the open stretches to ",[632,9316,9317],{},"[from, to)",", joins touching ones and handles clock changes. It throws for more than 400 days.",[1076,9320,9321,9324,9325,672,9327,7681,9330,9333,9334,9337],{},[1079,9322,9323],{},"Keys."," Rules are kept per module under a key you choose (",[632,9326,9102],{},[632,9328,9329],{},"location:\u003Cid>",[632,9331,9332],{},"findTimeRules"," answers null when there are none; ",[632,9335,9336],{},"deleteTimeRules"," removes them.",[1076,9339,9340,3504,9343,9346,9347,9350,9351,9354,9355,9358],{},[1079,9341,9342],{},"Saving.",[632,9344,9345],{},"saveTimeRules"," refuses rules that can't hold (VALIDATION) and drops exceptions that are over. With ",[632,9348,9349],{},"baseUpdatedAt"," (the ",[632,9352,9353],{},"updatedAt"," you read, or null when none were stored) a save over a newer one is CONFLICT ",[632,9356,9357],{},"common.errors.changedMeanwhile",". Check your own permission first: SHADE checks none.",[1076,9360,9361,9364,9365,9368,9369,672,9372,1839,9374,9377,9378,9381],{},[1079,9362,9363],{},"Admin."," The component ",[632,9366,9367],{},"OpeningHoursField"," edits the rules with ",[632,9370,9371],{},"v-model",[632,9373,1854],{},[632,9375,9376],{},"disabled",". The ",[628,9379,9380],{"href":292},"opening hours"," guide page shows what an admin sees.",[1076,9383,9384],{},"Rules are your module's alone. Removing the module backs them up and forgets them.",[619,9386,299],{"id":9387},"locations",[624,9389,9390,9391,9393],{},"Experimental. The business's places and their addresses are kept by core, on the ",[628,9392,299],{"href":300}," screen, and so are the rules every module writes an address by:",[775,9395,9397],{"className":777,"code":9396,"language":779,"meta":780,"style":780},"import { mainLocation } from '@shadestack\u002Fmodule-sdk\u002Fserver'\nimport { checkPostcode, formatAddress } from '@shadestack\u002Fmodule-sdk\u002Fshared'\n\nconst seller = await mainLocation(ctx) \u002F\u002F the business's own address; null while no location is added\nconst lines = seller ? [seller.name, ...formatAddress(seller.address, { locale: 'nl-NL' })] : []\n\u002F\u002F A delivery address whose postcode must be its country's:\nconst Delivery = z.object({ line1: z.string(), postalCode: z.string(), city: z.string(), country: z.string() }).superRefine(checkPostcode)\n",[632,9398,9399,9418,9442,9446,9464,9525,9530],{"__ignoreMap":780},[784,9400,9401,9403,9405,9408,9410,9412,9414,9416],{"class":786,"line":787},[784,9402,2150],{"class":895},[784,9404,797],{"class":794},[784,9406,9407],{"class":869}," mainLocation",[784,9409,878],{"class":794},[784,9411,2191],{"class":895},[784,9413,907],{"class":794},[784,9415,973],{"class":827},[784,9417,1330],{"class":794},[784,9419,9420,9422,9424,9427,9429,9432,9434,9436,9438,9440],{"class":786,"line":811},[784,9421,2150],{"class":895},[784,9423,797],{"class":794},[784,9425,9426],{"class":869}," checkPostcode",[784,9428,848],{"class":794},[784,9430,9431],{"class":869}," formatAddress",[784,9433,878],{"class":794},[784,9435,2191],{"class":895},[784,9437,907],{"class":794},[784,9439,9061],{"class":827},[784,9441,1330],{"class":794},[784,9443,9444],{"class":786,"line":821},[784,9445,2203],{"emptyLinePlaceholder":2202},[784,9447,9448,9450,9453,9455,9457,9459,9461],{"class":786,"line":861},[784,9449,3013],{"class":837},[784,9451,9452],{"class":869}," seller ",[784,9454,3019],{"class":794},[784,9456,3022],{"class":895},[784,9458,9407],{"class":922},[784,9460,1570],{"class":869},[784,9462,9463],{"class":1202},"\u002F\u002F the business's own address; null while no location is added\n",[784,9465,9466,9468,9470,9472,9474,9476,9479,9481,9483,9485,9488,9491,9494,9496,9499,9501,9503,9506,9508,9510,9513,9515,9517,9520,9522],{"class":786,"line":892},[784,9467,3013],{"class":837},[784,9469,6011],{"class":869},[784,9471,3019],{"class":794},[784,9473,9452],{"class":869},[784,9475,1842],{"class":794},[784,9477,9478],{"class":869}," [seller",[784,9480,886],{"class":794},[784,9482,5690],{"class":869},[784,9484,848],{"class":794},[784,9486,9487],{"class":794}," ...",[784,9489,9490],{"class":922},"formatAddress",[784,9492,9493],{"class":869},"(seller",[784,9495,886],{"class":794},[784,9497,9498],{"class":869},"address",[784,9500,848],{"class":794},[784,9502,797],{"class":794},[784,9504,9505],{"class":833}," locale",[784,9507,643],{"class":794},[784,9509,907],{"class":794},[784,9511,9512],{"class":827},"nl-NL",[784,9514,830],{"class":794},[784,9516,878],{"class":794},[784,9518,9519],{"class":869},")] ",[784,9521,643],{"class":794},[784,9523,9524],{"class":869}," []\n",[784,9526,9527],{"class":786,"line":952},[784,9528,9529],{"class":1202},"\u002F\u002F A delivery address whose postcode must be its country's:\n",[784,9531,9532,9534,9537,9539,9541,9543,9545,9547,9549,9552,9554,9556,9558,9560,9562,9564,9567,9569,9571,9573,9575,9577,9579,9582,9584,9586,9588,9590,9592,9594,9597,9599,9601,9603,9605,9607,9609,9611,9613,9616],{"class":786,"line":958},[784,9533,3013],{"class":837},[784,9535,9536],{"class":869}," Delivery ",[784,9538,3019],{"class":794},[784,9540,2282],{"class":869},[784,9542,886],{"class":794},[784,9544,2287],{"class":922},[784,9546,926],{"class":869},[784,9548,2292],{"class":794},[784,9550,9551],{"class":833}," line1",[784,9553,643],{"class":794},[784,9555,2282],{"class":869},[784,9557,886],{"class":794},[784,9559,2303],{"class":922},[784,9561,2306],{"class":869},[784,9563,848],{"class":794},[784,9565,9566],{"class":833}," postalCode",[784,9568,643],{"class":794},[784,9570,2282],{"class":869},[784,9572,886],{"class":794},[784,9574,2303],{"class":922},[784,9576,2306],{"class":869},[784,9578,848],{"class":794},[784,9580,9581],{"class":833}," city",[784,9583,643],{"class":794},[784,9585,2282],{"class":869},[784,9587,886],{"class":794},[784,9589,2303],{"class":922},[784,9591,2306],{"class":869},[784,9593,848],{"class":794},[784,9595,9596],{"class":833}," country",[784,9598,643],{"class":794},[784,9600,2282],{"class":869},[784,9602,886],{"class":794},[784,9604,2303],{"class":922},[784,9606,2338],{"class":869},[784,9608,1315],{"class":794},[784,9610,731],{"class":869},[784,9612,886],{"class":794},[784,9614,9615],{"class":922},"superRefine",[784,9617,9618],{"class":869},"(checkPostcode)\n",[1073,9620,9621,9643,9677],{},[1076,9622,9623,3504,9626,9629,9630,9633,9634,672,9637,1829,9640,886],{},[1079,9624,9625],{},"Countries.",[632,9627,9628],{},"COUNTRIES"," (ISO 3166-1 alpha-2), ",[632,9631,9632],{},"EU_COUNTRIES"," (the 27), ",[632,9635,9636],{},"isCountry",[632,9638,9639],{},"isEuCountry",[632,9641,9642],{},"countryName(code, locale)",[1076,9644,9645,3504,9648,9651,9652,9655,9656,9659,9660,7681,9663,9666,9667,3890,9670,9673,9674,886],{},[1079,9646,9647],{},"Postcodes.",[632,9649,9650],{},"isPostcodeOf(country, postcode)"," checks the format for the EU's 27 and the United Kingdom, Switzerland, Norway, Iceland, Liechtenstein, the United States, Canada and Australia; elsewhere any postcode is taken. ",[632,9653,9654],{},"normalizePostcode"," writes it the country's way (",[632,9657,9658],{},"1234ab"," becomes ",[632,9661,9662],{},"1234 AB",[632,9664,9665],{},"checkPostcode"," is the same check for a schema, its issue on ",[632,9668,9669],{},"postalCode",[632,9671,9672],{},"PostalAddress"," is a whole address with the check and an optional ",[632,9675,9676],{},"region",[1076,9678,9679,3504,9682,9685,9686,1847],{},[1079,9680,9681],{},"Writing an address.",[632,9683,9684],{},"formatAddress(address, { locale, country })"," gives lines the way the country writes them, then the country's name (left out with ",[632,9687,9688],{},"country: false",[619,9690,9692],{"id":9691},"fiscal-records","Fiscal records",[624,9694,9695],{},"Experimental. A document the law keeps (an invoice, a credit invoice, a receipt) is a fiscal record, kept by core: numbered from one of your module's series, stored exactly as issued, kept until 1 January of the eighth year after the year it was issued (seven whole years), and then deleted by retention. Issue it in the transaction of the change it belongs to:",[775,9697,9699],{"className":777,"code":9698,"language":779,"meta":780,"style":780},"import { fiscalRecordFile, fiscalRecordReference, issueFiscalRecord, withDb } from '@shadestack\u002Fmodule-sdk\u002Fserver'\n\nexport const shopInvoices = pgTable('shop_invoices', {\n  id: id(),\n  fiscalRecordId: fiscalRecordReference('fiscal_record_id'), \u002F\u002F null once the law no longer keeps it\n  \u002F\u002F …\n})\n\nconst record = await issueFiscalRecord(withDb(ctx, tx), {\n  series: 'invoices', kind: 'invoice', digits: 4, at: paidAt, contactId: order.contactId, contentType: 'application\u002Fpdf',\n  render: ({ number }) => renderPdf(order, number) \u002F\u002F the document names its own number\n})\n\u002F\u002F record: { id, number, issuedAt, keptUntil, body }; later: await fiscalRecordFile(ctx, record.id)\n",[632,9700,9701,9734,9738,9764,9776,9801,9805,9811,9815,9843,9915,9945,9951],{"__ignoreMap":780},[784,9702,9703,9705,9707,9710,9712,9715,9717,9720,9722,9724,9726,9728,9730,9732],{"class":786,"line":787},[784,9704,2150],{"class":895},[784,9706,797],{"class":794},[784,9708,9709],{"class":869}," fiscalRecordFile",[784,9711,848],{"class":794},[784,9713,9714],{"class":869}," fiscalRecordReference",[784,9716,848],{"class":794},[784,9718,9719],{"class":869}," issueFiscalRecord",[784,9721,848],{"class":794},[784,9723,6522],{"class":869},[784,9725,878],{"class":794},[784,9727,2191],{"class":895},[784,9729,907],{"class":794},[784,9731,973],{"class":827},[784,9733,1330],{"class":794},[784,9735,9736],{"class":786,"line":811},[784,9737,2203],{"emptyLinePlaceholder":2202},[784,9739,9740,9742,9744,9747,9749,9751,9753,9755,9758,9760,9762],{"class":786,"line":821},[784,9741,1454],{"class":895},[784,9743,7758],{"class":837},[784,9745,9746],{"class":869}," shopInvoices ",[784,9748,3019],{"class":794},[784,9750,7766],{"class":922},[784,9752,926],{"class":869},[784,9754,830],{"class":794},[784,9756,9757],{"class":827},"shop_invoices",[784,9759,830],{"class":794},[784,9761,848],{"class":794},[784,9763,818],{"class":794},[784,9765,9766,9768,9770,9772,9774],{"class":786,"line":861},[784,9767,7784],{"class":833},[784,9769,643],{"class":794},[784,9771,2465],{"class":922},[784,9773,2306],{"class":869},[784,9775,1481],{"class":794},[784,9777,9778,9781,9783,9785,9787,9789,9792,9794,9796,9798],{"class":786,"line":892},[784,9779,9780],{"class":833},"  fiscalRecordId",[784,9782,643],{"class":794},[784,9784,9714],{"class":922},[784,9786,926],{"class":869},[784,9788,830],{"class":794},[784,9790,9791],{"class":827},"fiscal_record_id",[784,9793,830],{"class":794},[784,9795,731],{"class":869},[784,9797,848],{"class":794},[784,9799,9800],{"class":1202}," \u002F\u002F null once the law no longer keeps it\n",[784,9802,9803],{"class":786,"line":952},[784,9804,1486],{"class":1202},[784,9806,9807,9809],{"class":786,"line":958},[784,9808,1315],{"class":794},[784,9810,949],{"class":869},[784,9812,9813],{"class":786,"line":1333},[784,9814,2203],{"emptyLinePlaceholder":2202},[784,9816,9817,9819,9822,9824,9826,9828,9830,9832,9834,9836,9839,9841],{"class":786,"line":1338},[784,9818,3013],{"class":837},[784,9820,9821],{"class":869}," record ",[784,9823,3019],{"class":794},[784,9825,3022],{"class":895},[784,9827,9719],{"class":922},[784,9829,926],{"class":869},[784,9831,6861],{"class":922},[784,9833,1698],{"class":869},[784,9835,848],{"class":794},[784,9837,9838],{"class":869}," tx)",[784,9840,848],{"class":794},[784,9842,818],{"class":794},[784,9844,9845,9848,9850,9852,9854,9856,9858,9861,9863,9865,9868,9870,9872,9874,9876,9878,9880,9882,9884,9886,9888,9891,9893,9895,9897,9899,9901,9904,9906,9908,9911,9913],{"class":786,"line":1641},[784,9846,9847],{"class":833},"  series",[784,9849,643],{"class":794},[784,9851,907],{"class":794},[784,9853,2583],{"class":827},[784,9855,830],{"class":794},[784,9857,848],{"class":794},[784,9859,9860],{"class":833}," kind",[784,9862,643],{"class":794},[784,9864,907],{"class":794},[784,9866,9867],{"class":827},"invoice",[784,9869,830],{"class":794},[784,9871,848],{"class":794},[784,9873,8175],{"class":833},[784,9875,643],{"class":794},[784,9877,2630],{"class":1546},[784,9879,848],{"class":794},[784,9881,8165],{"class":833},[784,9883,643],{"class":794},[784,9885,8170],{"class":869},[784,9887,848],{"class":794},[784,9889,9890],{"class":833}," contactId",[784,9892,643],{"class":794},[784,9894,1039],{"class":869},[784,9896,886],{"class":794},[784,9898,7130],{"class":869},[784,9900,848],{"class":794},[784,9902,9903],{"class":833}," contentType",[784,9905,643],{"class":794},[784,9907,907],{"class":794},[784,9909,9910],{"class":827},"application\u002Fpdf",[784,9912,830],{"class":794},[784,9914,1481],{"class":794},[784,9916,9917,9920,9922,9925,9927,9929,9931,9934,9937,9939,9942],{"class":786,"line":1647},[784,9918,9919],{"class":922},"  render",[784,9921,643],{"class":794},[784,9923,9924],{"class":794}," ({",[784,9926,1054],{"class":844},[784,9928,2769],{"class":794},[784,9930,856],{"class":837},[784,9932,9933],{"class":922}," renderPdf",[784,9935,9936],{"class":869},"(order",[784,9938,848],{"class":794},[784,9940,9941],{"class":869}," number) ",[784,9943,9944],{"class":1202},"\u002F\u002F the document names its own number\n",[784,9946,9947,9949],{"class":786,"line":1708},[784,9948,1315],{"class":794},[784,9950,949],{"class":869},[784,9952,9953],{"class":786,"line":1714},[784,9954,9955],{"class":1202},"\u002F\u002F record: { id, number, issuedAt, keptUntil, body }; later: await fiscalRecordFile(ctx, record.id)\n",[1073,9957,9958,9964,9970],{},[1076,9959,9960,9963],{},[1079,9961,9962],{},"Once."," A record is never changed: there is no update. A rollback leaves no record and gives the number back.",[1076,9965,9966,9969],{},[1079,9967,9968],{},"Kept by law."," A person's records are listed with their end date on the Personal data screen and counted as kept when the person asks to be erased; their contact stays with them. Neither your module's retention nor uninstalling it removes a record.",[1076,9971,9972,9975,9976,9978,9979,9982,9983,9985],{},[1079,9973,9974],{},"Private files."," Fiscal records follow the ",[632,9977,4336],{}," switch: while it is off, ",[632,9980,9981],{},"issueFiscalRecord"," is NOT_FOUND. You need no ",[632,9984,4336],{}," capability for them.",[619,9987,9989],{"id":9988},"lifecycle-guard","Lifecycle guard",[624,9991,9992,9993,9996],{},"Experimental. A status that moves in steps (an order, a booking) has one table of where it may go; ",[632,9994,9995],{},"defineLifecycle"," keeps every write of it to that table:",[775,9998,10000],{"className":777,"code":9999,"language":779,"meta":780,"style":780},"import { defineLifecycle } from '@shadestack\u002Fmodule-sdk\u002Fserver'\n\nexport const ORDER_LIFECYCLE = defineLifecycle(shopOrders, {\n  pending: ['paid', 'cancelled'], paid: ['shipped', 'refunded'], shipped: ['refunded'], cancelled: [], refunded: []\n})\n\nawait inTransaction(ctx, async (tx) => {\n  const moved = await ORDER_LIFECYCLE.move(tx, eq(shopOrders.id, id), 'shipped', {\n    set: { carrier },\n    audit: row => ({ action: 'shop.orders.ship', targetType: 'order', targetId: row.id, summary: `Order ${row.number} shipped` }),\n    event: row => ({ name: 'order.shipped', subject: { type: 'order', id: row.id }, data: { number: row.number } })\n  })\n  if (!moved) throw conflict('This order changed meanwhile')\n})\n",[632,10001,10002,10021,10025,10044,10134,10140,10144,10166,10221,10235,10321,10401,10407,10437],{"__ignoreMap":780},[784,10003,10004,10006,10008,10011,10013,10015,10017,10019],{"class":786,"line":787},[784,10005,2150],{"class":895},[784,10007,797],{"class":794},[784,10009,10010],{"class":869}," defineLifecycle",[784,10012,878],{"class":794},[784,10014,2191],{"class":895},[784,10016,907],{"class":794},[784,10018,973],{"class":827},[784,10020,1330],{"class":794},[784,10022,10023],{"class":786,"line":811},[784,10024,2203],{"emptyLinePlaceholder":2202},[784,10026,10027,10029,10031,10034,10036,10038,10040,10042],{"class":786,"line":821},[784,10028,1454],{"class":895},[784,10030,7758],{"class":837},[784,10032,10033],{"class":869}," ORDER_LIFECYCLE ",[784,10035,3019],{"class":794},[784,10037,10010],{"class":922},[784,10039,7938],{"class":869},[784,10041,848],{"class":794},[784,10043,818],{"class":794},[784,10045,10046,10049,10051,10053,10055,10058,10060,10062,10064,10067,10069,10071,10073,10076,10078,10080,10082,10085,10087,10089,10091,10094,10096,10098,10100,10103,10105,10107,10109,10111,10113,10115,10117,10120,10122,10125,10127,10130,10132],{"class":786,"line":861},[784,10047,10048],{"class":833},"  pending",[784,10050,643],{"class":794},[784,10052,2706],{"class":869},[784,10054,830],{"class":794},[784,10056,10057],{"class":827},"paid",[784,10059,830],{"class":794},[784,10061,848],{"class":794},[784,10063,907],{"class":794},[784,10065,10066],{"class":827},"cancelled",[784,10068,830],{"class":794},[784,10070,5302],{"class":869},[784,10072,848],{"class":794},[784,10074,10075],{"class":833}," paid",[784,10077,643],{"class":794},[784,10079,2706],{"class":869},[784,10081,830],{"class":794},[784,10083,10084],{"class":827},"shipped",[784,10086,830],{"class":794},[784,10088,848],{"class":794},[784,10090,907],{"class":794},[784,10092,10093],{"class":827},"refunded",[784,10095,830],{"class":794},[784,10097,5302],{"class":869},[784,10099,848],{"class":794},[784,10101,10102],{"class":833}," shipped",[784,10104,643],{"class":794},[784,10106,2706],{"class":869},[784,10108,830],{"class":794},[784,10110,10093],{"class":827},[784,10112,830],{"class":794},[784,10114,5302],{"class":869},[784,10116,848],{"class":794},[784,10118,10119],{"class":833}," cancelled",[784,10121,643],{"class":794},[784,10123,10124],{"class":869}," []",[784,10126,848],{"class":794},[784,10128,10129],{"class":833}," refunded",[784,10131,643],{"class":794},[784,10133,9524],{"class":869},[784,10135,10136,10138],{"class":786,"line":892},[784,10137,1315],{"class":794},[784,10139,949],{"class":869},[784,10141,10142],{"class":786,"line":952},[784,10143,2203],{"emptyLinePlaceholder":2202},[784,10145,10146,10148,10150,10152,10154,10156,10158,10160,10162,10164],{"class":786,"line":958},[784,10147,939],{"class":895},[784,10149,2186],{"class":922},[784,10151,1698],{"class":869},[784,10153,848],{"class":794},[784,10155,2063],{"class":837},[784,10157,841],{"class":794},[784,10159,6833],{"class":844},[784,10161,731],{"class":794},[784,10163,856],{"class":837},[784,10165,818],{"class":794},[784,10167,10168,10170,10173,10175,10177,10180,10182,10185,10187,10189,10191,10194,10196,10199,10201,10203,10205,10207,10209,10211,10213,10215,10217,10219],{"class":786,"line":1333},[784,10169,4977],{"class":837},[784,10171,10172],{"class":869}," moved",[784,10174,881],{"class":794},[784,10176,3022],{"class":895},[784,10178,10179],{"class":869}," ORDER_LIFECYCLE",[784,10181,886],{"class":794},[784,10183,10184],{"class":922},"move",[784,10186,926],{"class":833},[784,10188,6833],{"class":869},[784,10190,848],{"class":794},[784,10192,10193],{"class":922}," eq",[784,10195,926],{"class":833},[784,10197,10198],{"class":869},"shopOrders",[784,10200,886],{"class":794},[784,10202,4274],{"class":869},[784,10204,848],{"class":794},[784,10206,2465],{"class":869},[784,10208,731],{"class":833},[784,10210,848],{"class":794},[784,10212,907],{"class":794},[784,10214,10084],{"class":827},[784,10216,830],{"class":794},[784,10218,848],{"class":794},[784,10220,818],{"class":794},[784,10222,10223,10226,10228,10230,10233],{"class":786,"line":1338},[784,10224,10225],{"class":833},"    set",[784,10227,643],{"class":794},[784,10229,797],{"class":794},[784,10231,10232],{"class":869}," carrier",[784,10234,808],{"class":794},[784,10236,10237,10240,10242,10245,10247,10249,10251,10253,10255,10257,10260,10262,10264,10267,10269,10271,10273,10275,10277,10280,10282,10284,10286,10288,10290,10293,10295,10297,10300,10302,10305,10307,10309,10311,10313,10315,10317,10319],{"class":786,"line":1641},[784,10238,10239],{"class":922},"    audit",[784,10241,643],{"class":794},[784,10243,10244],{"class":844}," row",[784,10246,856],{"class":837},[784,10248,841],{"class":833},[784,10250,2292],{"class":794},[784,10252,6706],{"class":833},[784,10254,643],{"class":794},[784,10256,907],{"class":794},[784,10258,10259],{"class":827},"shop.orders.ship",[784,10261,830],{"class":794},[784,10263,848],{"class":794},[784,10265,10266],{"class":833}," targetType",[784,10268,643],{"class":794},[784,10270,907],{"class":794},[784,10272,2458],{"class":827},[784,10274,830],{"class":794},[784,10276,848],{"class":794},[784,10278,10279],{"class":833}," targetId",[784,10281,643],{"class":794},[784,10283,10244],{"class":869},[784,10285,886],{"class":794},[784,10287,4274],{"class":869},[784,10289,848],{"class":794},[784,10291,10292],{"class":833}," summary",[784,10294,643],{"class":794},[784,10296,2881],{"class":794},[784,10298,10299],{"class":827},"Order ",[784,10301,2887],{"class":794},[784,10303,10304],{"class":869},"row",[784,10306,886],{"class":794},[784,10308,2320],{"class":869},[784,10310,1315],{"class":794},[784,10312,10102],{"class":827},[784,10314,3784],{"class":794},[784,10316,878],{"class":794},[784,10318,731],{"class":833},[784,10320,1481],{"class":794},[784,10322,10323,10326,10328,10330,10332,10334,10336,10338,10340,10342,10345,10347,10349,10351,10353,10355,10357,10359,10361,10363,10365,10367,10369,10371,10373,10375,10377,10379,10381,10383,10385,10387,10389,10391,10393,10395,10397,10399],{"class":786,"line":1647},[784,10324,10325],{"class":922},"    event",[784,10327,643],{"class":794},[784,10329,10244],{"class":844},[784,10331,856],{"class":837},[784,10333,841],{"class":833},[784,10335,2292],{"class":794},[784,10337,1527],{"class":833},[784,10339,643],{"class":794},[784,10341,907],{"class":794},[784,10343,10344],{"class":827},"order.shipped",[784,10346,830],{"class":794},[784,10348,848],{"class":794},[784,10350,5963],{"class":833},[784,10352,643],{"class":794},[784,10354,797],{"class":794},[784,10356,2451],{"class":833},[784,10358,643],{"class":794},[784,10360,907],{"class":794},[784,10362,2458],{"class":827},[784,10364,830],{"class":794},[784,10366,848],{"class":794},[784,10368,2465],{"class":833},[784,10370,643],{"class":794},[784,10372,10244],{"class":869},[784,10374,886],{"class":794},[784,10376,4274],{"class":869},[784,10378,2654],{"class":794},[784,10380,2657],{"class":833},[784,10382,643],{"class":794},[784,10384,797],{"class":794},[784,10386,1054],{"class":833},[784,10388,643],{"class":794},[784,10390,10244],{"class":869},[784,10392,886],{"class":794},[784,10394,2320],{"class":869},[784,10396,878],{"class":794},[784,10398,878],{"class":794},[784,10400,949],{"class":833},[784,10402,10403,10405],{"class":786,"line":1708},[784,10404,2817],{"class":794},[784,10406,949],{"class":833},[784,10408,10409,10412,10414,10416,10419,10421,10423,10426,10428,10430,10433,10435],{"class":786,"line":1714},[784,10410,10411],{"class":895},"  if",[784,10413,841],{"class":833},[784,10415,1240],{"class":794},[784,10417,10418],{"class":869},"moved",[784,10420,1194],{"class":833},[784,10422,7469],{"class":895},[784,10424,10425],{"class":922}," conflict",[784,10427,926],{"class":833},[784,10429,830],{"class":794},[784,10431,10432],{"class":827},"This order changed meanwhile",[784,10434,830],{"class":794},[784,10436,949],{"class":833},[784,10438,10439,10441],{"class":786,"line":1760},[784,10440,1315],{"class":794},[784,10442,949],{"class":869},[1073,10444,10445,10453],{},[1076,10446,10447,10449,10450,10452],{},[632,10448,10184],{}," writes the status only where the row is still in a status it may come from, with ",[632,10451,3660],{},", the audit entry and the event in your transaction. It answers null when another change came first, and writes nothing then.",[1076,10454,10455,672,10458,1839,10461,10464],{},[632,10456,10457],{},"canMove",[632,10459,10460],{},"sourcesOf",[632,10462,10463],{},"assertMove"," (CONFLICT) answer from the same table. It is a guard, not a workflow engine: what happens around a move (stock, emails) stays your code.",[619,10466,10468],{"id":10467},"terms-acceptance","Terms acceptance",[624,10470,10471],{},"Experimental. Keep the proof that a person accepted your terms, or a consent text, in the transaction of what they accepted it for:",[775,10473,10475],{"className":777,"code":10474,"language":779,"meta":780,"style":780},"import { acceptTerms } from '@shadestack\u002Fmodule-sdk\u002Fserver'\nimport { acceptedText, withdrawalUntil } from '@shadestack\u002Fmodule-sdk\u002Fshared'\n\nconst text = acceptedText(settings.termsTexts, input.terms) \u002F\u002F only a text you offer, in any language\nif (!text) throw validation(undefined, [{ path: 'terms', message: 'Accept the terms to order' }])\nawait acceptTerms(tx, { terms: 'checkout', text, contactId, subject: { type: 'order', id: order.id }, withdrawal: 'goods' })\nwithdrawalUntil('goods', '2026-03-01') \u002F\u002F '2026-03-15': 14 days from the day the goods arrived\n",[632,10476,10477,10496,10520,10524,10554,10609,10689],{"__ignoreMap":780},[784,10478,10479,10481,10483,10486,10488,10490,10492,10494],{"class":786,"line":787},[784,10480,2150],{"class":895},[784,10482,797],{"class":794},[784,10484,10485],{"class":869}," acceptTerms",[784,10487,878],{"class":794},[784,10489,2191],{"class":895},[784,10491,907],{"class":794},[784,10493,973],{"class":827},[784,10495,1330],{"class":794},[784,10497,10498,10500,10502,10505,10507,10510,10512,10514,10516,10518],{"class":786,"line":811},[784,10499,2150],{"class":895},[784,10501,797],{"class":794},[784,10503,10504],{"class":869}," acceptedText",[784,10506,848],{"class":794},[784,10508,10509],{"class":869}," withdrawalUntil",[784,10511,878],{"class":794},[784,10513,2191],{"class":895},[784,10515,907],{"class":794},[784,10517,9061],{"class":827},[784,10519,1330],{"class":794},[784,10521,10522],{"class":786,"line":821},[784,10523,2203],{"emptyLinePlaceholder":2202},[784,10525,10526,10528,10530,10532,10534,10537,10539,10542,10544,10546,10548,10551],{"class":786,"line":861},[784,10527,3013],{"class":837},[784,10529,5968],{"class":869},[784,10531,3019],{"class":794},[784,10533,10504],{"class":922},[784,10535,10536],{"class":869},"(settings",[784,10538,886],{"class":794},[784,10540,10541],{"class":869},"termsTexts",[784,10543,848],{"class":794},[784,10545,4508],{"class":869},[784,10547,886],{"class":794},[784,10549,10550],{"class":869},"terms) ",[784,10552,10553],{"class":1202},"\u002F\u002F only a text you offer, in any language\n",[784,10555,10556,10558,10560,10562,10565,10567,10570,10572,10575,10577,10579,10581,10583,10585,10588,10590,10592,10595,10597,10599,10602,10604,10606],{"class":786,"line":892},[784,10557,4588],{"class":895},[784,10559,841],{"class":869},[784,10561,1240],{"class":794},[784,10563,10564],{"class":869},"text) ",[784,10566,7469],{"class":895},[784,10568,10569],{"class":922}," validation",[784,10571,926],{"class":869},[784,10573,10574],{"class":794},"undefined,",[784,10576,2706],{"class":869},[784,10578,2292],{"class":794},[784,10580,4096],{"class":833},[784,10582,643],{"class":794},[784,10584,907],{"class":794},[784,10586,10587],{"class":827},"terms",[784,10589,830],{"class":794},[784,10591,848],{"class":794},[784,10593,10594],{"class":833}," message",[784,10596,643],{"class":794},[784,10598,907],{"class":794},[784,10600,10601],{"class":827},"Accept the terms to order",[784,10603,830],{"class":794},[784,10605,878],{"class":794},[784,10607,10608],{"class":869},"])\n",[784,10610,10611,10613,10615,10617,10619,10621,10624,10626,10628,10631,10633,10635,10637,10639,10641,10643,10645,10647,10649,10651,10653,10655,10657,10659,10661,10663,10665,10667,10669,10671,10673,10676,10678,10680,10683,10685,10687],{"class":786,"line":952},[784,10612,939],{"class":895},[784,10614,10485],{"class":922},[784,10616,2436],{"class":869},[784,10618,848],{"class":794},[784,10620,797],{"class":794},[784,10622,10623],{"class":833}," terms",[784,10625,643],{"class":794},[784,10627,907],{"class":794},[784,10629,10630],{"class":827},"checkout",[784,10632,830],{"class":794},[784,10634,848],{"class":794},[784,10636,6405],{"class":869},[784,10638,848],{"class":794},[784,10640,9890],{"class":869},[784,10642,848],{"class":794},[784,10644,5963],{"class":833},[784,10646,643],{"class":794},[784,10648,797],{"class":794},[784,10650,2451],{"class":833},[784,10652,643],{"class":794},[784,10654,907],{"class":794},[784,10656,2458],{"class":827},[784,10658,830],{"class":794},[784,10660,848],{"class":794},[784,10662,2465],{"class":833},[784,10664,643],{"class":794},[784,10666,1039],{"class":869},[784,10668,886],{"class":794},[784,10670,2474],{"class":869},[784,10672,2477],{"class":794},[784,10674,10675],{"class":833}," withdrawal",[784,10677,643],{"class":794},[784,10679,907],{"class":794},[784,10681,10682],{"class":827},"goods",[784,10684,830],{"class":794},[784,10686,878],{"class":794},[784,10688,949],{"class":869},[784,10690,10691,10694,10696,10698,10700,10702,10704,10706,10709,10711,10713],{"class":786,"line":958},[784,10692,10693],{"class":922},"withdrawalUntil",[784,10695,926],{"class":869},[784,10697,830],{"class":794},[784,10699,10682],{"class":827},[784,10701,830],{"class":794},[784,10703,848],{"class":794},[784,10705,907],{"class":794},[784,10707,10708],{"class":827},"2026-03-01",[784,10710,830],{"class":794},[784,10712,1194],{"class":869},[784,10714,10715],{"class":1202},"\u002F\u002F '2026-03-15': 14 days from the day the goods arrived\n",[1073,10717,10718,10725],{},[1076,10719,10720,10721,10724],{},"What is kept: the text, its version (",[632,10722,10723],{},"termsVersion",": the text's SHA-256), the contact, the subject, the kind of sale and when. It is in the person's data and kept on erasure, for seven years by default under retention.",[1076,10726,10727,10730,10731,10733,10734,1839,10737,10740,10741,10744,10745,10747],{},[632,10728,10729],{},"withdrawal"," is the kind of sale: ",[632,10732,10682],{}," (14 days from receipt), ",[632,10735,10736],{},"services",[632,10738,10739],{},"digital-content"," (14 days from the contract; digital content loses it once the supply starts with consent), ",[632,10742,10743],{},"dated-leisure"," (an event or course on a date: none) and ",[632,10746,2685],{}," (no sale at a distance, such as a consent to how details are used).",[619,10749,10751],{"id":10750},"tax","Tax",[624,10753,10754,10755,10757],{},"Experimental. VAT is the business's, kept once by core: the categories, the dated rates of the EU's 27 with the business's own on Settings, ",[7676,10756,303],{},", VAT numbers, reverse charge and exports. Your module decides its prices and who may order without VAT; core says what is charged:",[775,10759,10761],{"className":777,"code":10760,"language":779,"meta":780,"style":780},"import { checkVatNumber, vatRatesAt } from '@shadestack\u002Fmodule-sdk\u002Fserver'\nimport { chargedRate, isExport, isReverseCharge, vatBreakdown } from '@shadestack\u002Fmodule-sdk\u002Fshared'\n\nconst rates = await vatRatesAt(ctx, now) \u002F\u002F the rates in force at that moment\nconst rate = chargedRate('reduced', { home: 'NL', country: 'DE', oss: true, rates }) \u002F\u002F 7\nif (isReverseCharge({ home: 'NL', country: 'DE', vatNumber })) {\n  \u002F\u002F Before your transaction: VIES may be asked, when the business switched it on.\n  const check = await checkVatNumber(ctx, 'DE', vatNumber) \u002F\u002F { valid, checkedBy: 'vies' | 'format' | 'format-vies-unanswered' }\n  if (!check.valid) throw validation(undefined, [{ path: 'vatNumber', message: 'This VAT number is not valid in VIES' }])\n}\nconst vat = vatBreakdown(lines, shippingCents, rates.NL.standard, 'EUR') \u002F\u002F the VAT per rate, shipping in proportion\n",[632,10762,10763,10787,10821,10825,10848,10917,10963,10968,11003,11061,11065],{"__ignoreMap":780},[784,10764,10765,10767,10769,10772,10774,10777,10779,10781,10783,10785],{"class":786,"line":787},[784,10766,2150],{"class":895},[784,10768,797],{"class":794},[784,10770,10771],{"class":869}," checkVatNumber",[784,10773,848],{"class":794},[784,10775,10776],{"class":869}," vatRatesAt",[784,10778,878],{"class":794},[784,10780,2191],{"class":895},[784,10782,907],{"class":794},[784,10784,973],{"class":827},[784,10786,1330],{"class":794},[784,10788,10789,10791,10793,10796,10798,10801,10803,10806,10808,10811,10813,10815,10817,10819],{"class":786,"line":811},[784,10790,2150],{"class":895},[784,10792,797],{"class":794},[784,10794,10795],{"class":869}," chargedRate",[784,10797,848],{"class":794},[784,10799,10800],{"class":869}," isExport",[784,10802,848],{"class":794},[784,10804,10805],{"class":869}," isReverseCharge",[784,10807,848],{"class":794},[784,10809,10810],{"class":869}," vatBreakdown",[784,10812,878],{"class":794},[784,10814,2191],{"class":895},[784,10816,907],{"class":794},[784,10818,9061],{"class":827},[784,10820,1330],{"class":794},[784,10822,10823],{"class":786,"line":821},[784,10824,2203],{"emptyLinePlaceholder":2202},[784,10826,10827,10829,10832,10834,10836,10838,10840,10842,10845],{"class":786,"line":861},[784,10828,3013],{"class":837},[784,10830,10831],{"class":869}," rates ",[784,10833,3019],{"class":794},[784,10835,3022],{"class":895},[784,10837,10776],{"class":922},[784,10839,1698],{"class":869},[784,10841,848],{"class":794},[784,10843,10844],{"class":869}," now) ",[784,10846,10847],{"class":1202},"\u002F\u002F the rates in force at that moment\n",[784,10849,10850,10852,10855,10857,10859,10861,10863,10866,10868,10870,10872,10875,10877,10879,10882,10884,10886,10888,10890,10892,10895,10897,10899,10902,10904,10906,10908,10910,10912,10914],{"class":786,"line":892},[784,10851,3013],{"class":837},[784,10853,10854],{"class":869}," rate ",[784,10856,3019],{"class":794},[784,10858,10795],{"class":922},[784,10860,926],{"class":869},[784,10862,830],{"class":794},[784,10864,10865],{"class":827},"reduced",[784,10867,830],{"class":794},[784,10869,848],{"class":794},[784,10871,797],{"class":794},[784,10873,10874],{"class":833}," home",[784,10876,643],{"class":794},[784,10878,907],{"class":794},[784,10880,10881],{"class":827},"NL",[784,10883,830],{"class":794},[784,10885,848],{"class":794},[784,10887,9596],{"class":833},[784,10889,643],{"class":794},[784,10891,907],{"class":794},[784,10893,10894],{"class":827},"DE",[784,10896,830],{"class":794},[784,10898,848],{"class":794},[784,10900,10901],{"class":833}," oss",[784,10903,643],{"class":794},[784,10905,5043],{"class":5016},[784,10907,848],{"class":794},[784,10909,10831],{"class":869},[784,10911,1315],{"class":794},[784,10913,1194],{"class":869},[784,10915,10916],{"class":1202},"\u002F\u002F 7\n",[784,10918,10919,10921,10923,10926,10928,10930,10932,10934,10936,10938,10940,10942,10944,10946,10948,10950,10952,10954,10957,10959,10961],{"class":786,"line":952},[784,10920,4588],{"class":895},[784,10922,841],{"class":869},[784,10924,10925],{"class":922},"isReverseCharge",[784,10927,926],{"class":869},[784,10929,2292],{"class":794},[784,10931,10874],{"class":833},[784,10933,643],{"class":794},[784,10935,907],{"class":794},[784,10937,10881],{"class":827},[784,10939,830],{"class":794},[784,10941,848],{"class":794},[784,10943,9596],{"class":833},[784,10945,643],{"class":794},[784,10947,907],{"class":794},[784,10949,10894],{"class":827},[784,10951,830],{"class":794},[784,10953,848],{"class":794},[784,10955,10956],{"class":869}," vatNumber ",[784,10958,1315],{"class":794},[784,10960,936],{"class":869},[784,10962,1197],{"class":794},[784,10964,10965],{"class":786,"line":958},[784,10966,10967],{"class":1202},"  \u002F\u002F Before your transaction: VIES may be asked, when the business switched it on.\n",[784,10969,10970,10972,10975,10977,10979,10981,10983,10985,10987,10989,10991,10993,10995,10998,11000],{"class":786,"line":1333},[784,10971,4977],{"class":837},[784,10973,10974],{"class":869}," check",[784,10976,881],{"class":794},[784,10978,3022],{"class":895},[784,10980,10771],{"class":922},[784,10982,926],{"class":833},[784,10984,845],{"class":869},[784,10986,848],{"class":794},[784,10988,907],{"class":794},[784,10990,10894],{"class":827},[784,10992,830],{"class":794},[784,10994,848],{"class":794},[784,10996,10997],{"class":869}," vatNumber",[784,10999,1194],{"class":833},[784,11001,11002],{"class":1202},"\u002F\u002F { valid, checkedBy: 'vies' | 'format' | 'format-vies-unanswered' }\n",[784,11004,11005,11007,11009,11011,11014,11016,11019,11021,11023,11025,11027,11029,11031,11033,11035,11037,11039,11042,11044,11046,11048,11050,11052,11055,11057,11059],{"class":786,"line":1338},[784,11006,10411],{"class":895},[784,11008,841],{"class":833},[784,11010,1240],{"class":794},[784,11012,11013],{"class":869},"check",[784,11015,886],{"class":794},[784,11017,11018],{"class":869},"valid",[784,11020,1194],{"class":833},[784,11022,7469],{"class":895},[784,11024,10569],{"class":922},[784,11026,926],{"class":833},[784,11028,10574],{"class":794},[784,11030,2706],{"class":833},[784,11032,2292],{"class":794},[784,11034,4096],{"class":833},[784,11036,643],{"class":794},[784,11038,907],{"class":794},[784,11040,11041],{"class":827},"vatNumber",[784,11043,830],{"class":794},[784,11045,848],{"class":794},[784,11047,10594],{"class":833},[784,11049,643],{"class":794},[784,11051,907],{"class":794},[784,11053,11054],{"class":827},"This VAT number is not valid in VIES",[784,11056,830],{"class":794},[784,11058,878],{"class":794},[784,11060,10608],{"class":833},[784,11062,11063],{"class":786,"line":1641},[784,11064,961],{"class":794},[784,11066,11067,11069,11072,11074,11076,11079,11081,11084,11086,11089,11091,11093,11095,11098,11100,11102,11105,11107,11109],{"class":786,"line":1647},[784,11068,3013],{"class":837},[784,11070,11071],{"class":869}," vat ",[784,11073,3019],{"class":794},[784,11075,10810],{"class":922},[784,11077,11078],{"class":869},"(lines",[784,11080,848],{"class":794},[784,11082,11083],{"class":869}," shippingCents",[784,11085,848],{"class":794},[784,11087,11088],{"class":869}," rates",[784,11090,886],{"class":794},[784,11092,10881],{"class":869},[784,11094,886],{"class":794},[784,11096,11097],{"class":869},"standard",[784,11099,848],{"class":794},[784,11101,907],{"class":794},[784,11103,11104],{"class":827},"EUR",[784,11106,830],{"class":794},[784,11108,1194],{"class":869},[784,11110,11111],{"class":1202},"\u002F\u002F the VAT per rate, shipping in proportion\n",[1073,11113,11114,11139,11149,11166],{},[1076,11115,11116,11119,11120,672,11123,672,11126,672,11129,1829,11132,11135,11136,886],{},[1079,11117,11118],{},"The arithmetic"," is exact on the money type: ",[632,11121,11122],{},"vatInGross",[632,11124,11125],{},"netOfGross",[632,11127,11128],{},"vatOnNet",[632,11130,11131],{},"rateTenths",[632,11133,11134],{},"formatVatRate(rate, locale)"," writes ",[632,11137,11138],{},"5,5%",[1076,11140,11141,11144,11145,11148],{},[1079,11142,11143],{},"VIES"," is an outside call the business chooses; keep what ",[632,11146,11147],{},"checkVatNumber"," answered with your record (the order says which check decided). It never throws for VIES's failures.",[1076,11150,11151,11154,11155,11158,11159,4825,11162,11165],{},[1079,11152,11153],{},"The One-Stop-Shop report",": give core your sales and refunds charged at another EU country's VAT under One-Stop-Shop with the manifest part ",[632,11156,11157],{},"taxSales"," (trusted modules): ",[632,11160,11161],{},"(ctx, { from, to }) => TaxSale[]",[632,11163,11164],{},"{ country, rate, grossCents, vatCents, currency }",", a refund negative, dated by your invoice. The report adds up every module that is on, per quarter, country and rate.",[1076,11167,7635,11168,11171],{},[632,11169,11170],{},"stubVies({ send })"," from the testing entry answers for VIES.",[619,11173,11175],{"id":11174},"the-country-of-an-ip-address","The country of an IP address",[624,11177,11178,11179,11182,11183,11186,11187,11190,11191,11194,11195,11198],{},"Experimental. ",[632,11180,11181],{},"countryOfIp(ip)"," gives the two-letter country of an address, looked up on the instance in DB-IP's ",[7676,11184,11185],{},"IP to Country Lite"," (CC BY 4.0), or null. The address is never kept. Credit DB-IP where you show countries, with the month ",[632,11188,11189],{},"ipCountriesMonth()"," gives. In tests, ",[632,11192,11193],{},"stubIpCountries(packIpCountries(csv, month))"," gives your own ranges and ",[632,11196,11197],{},"stubIpCountries(null)"," the shipped data again.",[624,11200,11201,11202,11205,11206,11209],{},"For digital services the EU lets a seller rely on two pieces of evidence of where the customer is. ",[632,11203,11204],{},"customerCountry([{ kind: 'billing-address', country }, { kind: 'ip-address', country: countryOfIp(ip) }])"," settles the country when two kinds agree and no other country has two (",[632,11207,11208],{},"contradicted"," says a piece points elsewhere).",[619,11211,11213],{"id":11212},"visitor-keys-and-bots","Visitor keys and bots",[624,11215,11216],{},"Experimental. To compare visitors without keeping who they are (at most three unpaid orders per address), keep a key for the address, never the address:",[775,11218,11220],{"className":777,"code":11219,"language":779,"meta":780,"style":780},"import { isBot, visitorKey } from '@shadestack\u002Fmodule-sdk\u002Fserver'\n\nconst key = visitorKey(ctx, 'shop.unpaid', request.ip)                \u002F\u002F null without an address or without APP_SECRET\nconst daily = visitorKey(ctx, 'stats', request.ip, { day: '2026-11-18' })\nif (isBot(request.headers['user-agent'])) return                       \u002F\u002F crawlers, link previews, monitors, no user agent\n",[632,11221,11222,11246,11250,11284,11334],{"__ignoreMap":780},[784,11223,11224,11226,11228,11231,11233,11236,11238,11240,11242,11244],{"class":786,"line":787},[784,11225,2150],{"class":895},[784,11227,797],{"class":794},[784,11229,11230],{"class":869}," isBot",[784,11232,848],{"class":794},[784,11234,11235],{"class":869}," visitorKey",[784,11237,878],{"class":794},[784,11239,2191],{"class":895},[784,11241,907],{"class":794},[784,11243,973],{"class":827},[784,11245,1330],{"class":794},[784,11247,11248],{"class":786,"line":811},[784,11249,2203],{"emptyLinePlaceholder":2202},[784,11251,11252,11254,11257,11259,11261,11263,11265,11267,11270,11272,11274,11276,11278,11281],{"class":786,"line":821},[784,11253,3013],{"class":837},[784,11255,11256],{"class":869}," key ",[784,11258,3019],{"class":794},[784,11260,11235],{"class":922},[784,11262,1698],{"class":869},[784,11264,848],{"class":794},[784,11266,907],{"class":794},[784,11268,11269],{"class":827},"shop.unpaid",[784,11271,830],{"class":794},[784,11273,848],{"class":794},[784,11275,4181],{"class":869},[784,11277,886],{"class":794},[784,11279,11280],{"class":869},"ip)                ",[784,11282,11283],{"class":1202},"\u002F\u002F null without an address or without APP_SECRET\n",[784,11285,11286,11288,11291,11293,11295,11297,11299,11301,11304,11306,11308,11310,11312,11314,11316,11318,11321,11323,11325,11328,11330,11332],{"class":786,"line":861},[784,11287,3013],{"class":837},[784,11289,11290],{"class":869}," daily ",[784,11292,3019],{"class":794},[784,11294,11235],{"class":922},[784,11296,1698],{"class":869},[784,11298,848],{"class":794},[784,11300,907],{"class":794},[784,11302,11303],{"class":827},"stats",[784,11305,830],{"class":794},[784,11307,848],{"class":794},[784,11309,4181],{"class":869},[784,11311,886],{"class":794},[784,11313,4155],{"class":869},[784,11315,848],{"class":794},[784,11317,797],{"class":794},[784,11319,11320],{"class":833}," day",[784,11322,643],{"class":794},[784,11324,907],{"class":794},[784,11326,11327],{"class":827},"2026-11-18",[784,11329,830],{"class":794},[784,11331,878],{"class":794},[784,11333,949],{"class":869},[784,11335,11336,11338,11340,11343,11346,11348,11351,11353,11356,11358,11361,11363],{"class":786,"line":892},[784,11337,4588],{"class":895},[784,11339,841],{"class":869},[784,11341,11342],{"class":922},"isBot",[784,11344,11345],{"class":869},"(request",[784,11347,886],{"class":794},[784,11349,11350],{"class":869},"headers[",[784,11352,830],{"class":794},[784,11354,11355],{"class":827},"user-agent",[784,11357,830],{"class":794},[784,11359,11360],{"class":869},"])) ",[784,11362,1248],{"class":895},[784,11364,11365],{"class":1202},"                       \u002F\u002F crawlers, link previews, monitors, no user agent\n",[1073,11367,11368,11383,11390,11393],{},[1076,11369,11370,11371,672,11373,1839,11376,11379,11380,1847],{},"The key is the vault's HMAC of the purpose, the day (when given) and the address. Keys of two purposes or two days never match. A purpose is lower-case letters, digits, ",[632,11372,886],{},[632,11374,11375],{},"-",[632,11377,11378],{},"_","; name it after your module and rule (",[632,11381,11382],{},"commerce.unpaid",[1076,11384,11385,11386,11389],{},"With ",[632,11387,11388],{},"day",", the same address gives another key the next day: for counting visitors without following them.",[1076,11391,11392],{},"Without APP_SECRET (some tests) the key is null: skip the check rather than compare nulls.",[1076,11394,11395],{},"The key is personal data while it can still match: list it in your personal data and drop it when it has done its work.",[619,11397,11399],{"id":11398},"texts-for-visitors-in-any-language","Texts for visitors, in any language",[624,11401,11402,11403,11406],{},"Experimental. What visitors read (emails to them, a page a link opens, an invoice, a starter's words, a consent category) comes from your module's locale files, one per language, never from ",[632,11404,11405],{},"{ en, nl }"," in code. A third language is one more file:",[775,11408,11413],{"className":11409,"code":11411,"language":11412},[11410],"language-text","locales\u002F\n  en.json   { \"cart\": { \"free\": \"free\", \"total\": \"Total: {amount}\" } }\n  nl.json   { \"cart\": { \"free\": \"gratis\", \"total\": \"Totaal: {amount}\" } }\n  de.json   { \"cart\": { \"free\": \"kostenlos\" } }\n","text",[632,11414,11411],{"__ignoreMap":780},[775,11416,11418],{"className":777,"code":11417,"language":779,"meta":780,"style":780},"import { messages, textsIn } from '@shadestack\u002Fmodule-sdk\u002Fserver'\n\nconst texts = await messages(ctx, order.locale)   \u002F\u002F a page's language, an Accept-Language header, or null\ntexts.t('cart.total', { amount: formatMoney(total, formattingLocale(texts.language)) })\nconst everywhere = await textsIn(ctx, 'cart.free') \u002F\u002F { nl: 'gratis', en: 'free', de: 'kostenlos' } for the site's languages\n",[632,11419,11420,11444,11448,11475,11526],{"__ignoreMap":780},[784,11421,11422,11424,11426,11429,11431,11434,11436,11438,11440,11442],{"class":786,"line":787},[784,11423,2150],{"class":895},[784,11425,797],{"class":794},[784,11427,11428],{"class":869}," messages",[784,11430,848],{"class":794},[784,11432,11433],{"class":869}," textsIn",[784,11435,878],{"class":794},[784,11437,2191],{"class":895},[784,11439,907],{"class":794},[784,11441,973],{"class":827},[784,11443,1330],{"class":794},[784,11445,11446],{"class":786,"line":811},[784,11447,2203],{"emptyLinePlaceholder":2202},[784,11449,11450,11452,11455,11457,11459,11461,11463,11465,11467,11469,11472],{"class":786,"line":821},[784,11451,3013],{"class":837},[784,11453,11454],{"class":869}," texts ",[784,11456,3019],{"class":794},[784,11458,3022],{"class":895},[784,11460,11428],{"class":922},[784,11462,1698],{"class":869},[784,11464,848],{"class":794},[784,11466,1039],{"class":869},[784,11468,886],{"class":794},[784,11470,11471],{"class":869},"locale)   ",[784,11473,11474],{"class":1202},"\u002F\u002F a page's language, an Accept-Language header, or null\n",[784,11476,11477,11480,11482,11485,11487,11489,11492,11494,11496,11498,11501,11503,11506,11509,11511,11514,11517,11519,11522,11524],{"class":786,"line":861},[784,11478,11479],{"class":869},"texts",[784,11481,886],{"class":794},[784,11483,11484],{"class":922},"t",[784,11486,926],{"class":869},[784,11488,830],{"class":794},[784,11490,11491],{"class":827},"cart.total",[784,11493,830],{"class":794},[784,11495,848],{"class":794},[784,11497,797],{"class":794},[784,11499,11500],{"class":833}," amount",[784,11502,643],{"class":794},[784,11504,11505],{"class":922}," formatMoney",[784,11507,11508],{"class":869},"(total",[784,11510,848],{"class":794},[784,11512,11513],{"class":922}," formattingLocale",[784,11515,11516],{"class":869},"(texts",[784,11518,886],{"class":794},[784,11520,11521],{"class":869},"language)) ",[784,11523,1315],{"class":794},[784,11525,949],{"class":869},[784,11527,11528,11530,11533,11535,11537,11539,11541,11543,11545,11548,11550,11552],{"class":786,"line":892},[784,11529,3013],{"class":837},[784,11531,11532],{"class":869}," everywhere ",[784,11534,3019],{"class":794},[784,11536,3022],{"class":895},[784,11538,11433],{"class":922},[784,11540,1698],{"class":869},[784,11542,848],{"class":794},[784,11544,907],{"class":794},[784,11546,11547],{"class":827},"cart.free",[784,11549,830],{"class":794},[784,11551,1194],{"class":869},[784,11553,11554],{"class":1202},"\u002F\u002F { nl: 'gratis', en: 'free', de: 'kostenlos' } for the site's languages\n",[1073,11556,11557,11574,11592,11597,11604,11641],{},[1076,11558,11559,11560,11563,11564,11567,11568,11570,11571,11573],{},"SHADE reads ",[632,11561,11562],{},"locales\u002F\u003Clanguage>.json"," (nested objects; ",[632,11565,11566],{},"{ \"cart\": { \"free\": … } }"," is the key ",[632,11569,11547],{},") when the module loads, and ",[632,11572,3640],{}," ships the folder. A broken file stops the load.",[1076,11575,11576,11577,11580,11581,11584,11585,11588,11589,11591],{},"Each key comes from the first of the page's language (",[632,11578,11579],{},"nl-BE","), its primary code (",[632,11582,11583],{},"nl","), the site's default language and English that has it, so ",[632,11586,11587],{},"de.json"," may hold only some keys. ",[632,11590,11484],{}," throws for a key no file has.",[1076,11593,11594,11596],{},[632,11595,6061],{}," is filled in as plain text; a value is never read as a placeholder.",[1076,11598,11599,11600,11603],{},"The admin's own texts stay in ",[632,11601,11602],{},"admin\u002Flocales"," (Dutch and English).",[1076,11605,11606,11607,11610,11611,11614,11615,4007,11618,672,11620,11623,11624,1839,11627,11630,11631,9659,11633,11636,11637,11640],{},"From the shared entry: ",[632,11608,11609],{},"pickLanguage(wanted, available, fallback?)"," (reads an ",[632,11612,11613],{},"Accept-Language"," header too), ",[632,11616,11617],{},"primaryLanguage('en-GB')",[632,11619,6668],{},[632,11621,11622],{},"formattingLocale(language)"," gives what to pass to ",[632,11625,11626],{},"Intl",[632,11628,11629],{},"formatMoney"," (a bare ",[632,11632,6668],{},[632,11634,11635],{},"en-GB","), and ",[632,11638,11639],{},"formatDateRange(start, end, language, { timeZone })"," writes a time from start to end.",[1076,11642,7635,11643,11646],{},[632,11644,11645],{},"setModuleLocales(plugin, dir)"," from the testing entry reads another folder in place of yours.",[619,11648,11650],{"id":11649},"uninstall-hook","Uninstall hook",[624,11652,11653,11656,11657,11659],{},[632,11654,11655],{},"onUninstall(ctx)"," runs when an admin uninstalls the module, after the backup and before its data and settings are removed, in the same transaction (",[632,11658,3507],{},", which reaches the module's own tables). Use it for what core doesn't know about, such as a webhook registered at an outside service. If it throws, the uninstall stops and nothing is removed.",[619,11661,11663],{"id":11662},"sealing-again-after-app_secret-changes","Sealing again after APP_SECRET changes",[624,11665,11666,11667,11670,11671,11674,11675,11678,11679,841,11682,11684],{},"A trusted module that keeps sealed values in its own tables (",[632,11668,11669],{},"ctx.vault.seal",") gives ",[632,11672,11673],{},"onSecretsRotated(ctx)",". When the operator replaces ",[632,11676,11677],{},"APP_SECRET"," and runs ",[632,11680,11681],{},"rotate-secrets",[628,11683,54],{"href":55},"), it runs as the module, on or off, and seals each value again with the new secret:",[775,11686,11688],{"className":777,"code":11687,"language":779,"meta":780,"style":780},"onSecretsRotated: async (ctx) => {\n  let resealed = 0\n  for (const row of await ctx.db.select().from(fleetClients)) {\n    if (ctx.vault!.isCurrent(row.token)) continue\n    await ctx.db.update(fleetClients).set({ token: ctx.vault!.reseal(row.token) }).where(eq(fleetClients.id, row.id))\n    resealed++\n  }\n  return resealed\n}\n",[632,11689,11690,11709,11721,11762,11795,11880,11888,11892,11899],{"__ignoreMap":780},[784,11691,11692,11695,11697,11699,11701,11703,11705,11707],{"class":786,"line":787},[784,11693,11694],{"class":790},"onSecretsRotated",[784,11696,643],{"class":794},[784,11698,2063],{"class":837},[784,11700,841],{"class":794},[784,11702,845],{"class":844},[784,11704,731],{"class":794},[784,11706,856],{"class":837},[784,11708,818],{"class":794},[784,11710,11711,11714,11717,11719],{"class":786,"line":811},[784,11712,11713],{"class":837},"  let",[784,11715,11716],{"class":869}," resealed",[784,11718,881],{"class":794},[784,11720,3313],{"class":1546},[784,11722,11723,11726,11728,11730,11732,11735,11737,11739,11741,11743,11745,11747,11749,11751,11753,11755,11758,11760],{"class":786,"line":821},[784,11724,11725],{"class":895},"  for",[784,11727,841],{"class":833},[784,11729,3013],{"class":837},[784,11731,10244],{"class":869},[784,11733,11734],{"class":794}," of",[784,11736,3022],{"class":895},[784,11738,1266],{"class":869},[784,11740,886],{"class":794},[784,11742,3341],{"class":869},[784,11744,886],{"class":794},[784,11746,7912],{"class":922},[784,11748,2306],{"class":833},[784,11750,886],{"class":794},[784,11752,2161],{"class":922},[784,11754,926],{"class":833},[784,11756,11757],{"class":869},"fleetClients",[784,11759,936],{"class":833},[784,11761,1197],{"class":794},[784,11763,11764,11766,11768,11770,11772,11775,11778,11781,11783,11785,11787,11790,11792],{"class":786,"line":861},[784,11765,896],{"class":895},[784,11767,841],{"class":833},[784,11769,845],{"class":869},[784,11771,886],{"class":794},[784,11773,11774],{"class":869},"vault",[784,11776,11777],{"class":794},"!.",[784,11779,11780],{"class":922},"isCurrent",[784,11782,926],{"class":833},[784,11784,10304],{"class":869},[784,11786,886],{"class":794},[784,11788,11789],{"class":869},"token",[784,11791,936],{"class":833},[784,11793,11794],{"class":895},"continue\n",[784,11796,11797,11799,11801,11803,11805,11807,11810,11812,11814,11816,11818,11820,11822,11824,11826,11828,11830,11832,11834,11836,11839,11841,11843,11845,11847,11849,11851,11853,11855,11857,11859,11862,11864,11866,11868,11870,11872,11874,11876,11878],{"class":786,"line":892},[784,11798,1263],{"class":895},[784,11800,1266],{"class":869},[784,11802,886],{"class":794},[784,11804,3341],{"class":869},[784,11806,886],{"class":794},[784,11808,11809],{"class":922},"update",[784,11811,926],{"class":833},[784,11813,11757],{"class":869},[784,11815,731],{"class":833},[784,11817,886],{"class":794},[784,11819,3660],{"class":922},[784,11821,926],{"class":833},[784,11823,2292],{"class":794},[784,11825,6331],{"class":833},[784,11827,643],{"class":794},[784,11829,1266],{"class":869},[784,11831,886],{"class":794},[784,11833,11774],{"class":869},[784,11835,11777],{"class":794},[784,11837,11838],{"class":922},"reseal",[784,11840,926],{"class":833},[784,11842,10304],{"class":869},[784,11844,886],{"class":794},[784,11846,11789],{"class":869},[784,11848,1194],{"class":833},[784,11850,1315],{"class":794},[784,11852,731],{"class":833},[784,11854,886],{"class":794},[784,11856,7991],{"class":922},[784,11858,926],{"class":833},[784,11860,11861],{"class":922},"eq",[784,11863,926],{"class":833},[784,11865,11757],{"class":869},[784,11867,886],{"class":794},[784,11869,4274],{"class":869},[784,11871,848],{"class":794},[784,11873,10244],{"class":869},[784,11875,886],{"class":794},[784,11877,4274],{"class":869},[784,11879,2503],{"class":833},[784,11881,11882,11885],{"class":786,"line":952},[784,11883,11884],{"class":869},"    resealed",[784,11886,11887],{"class":794},"++\n",[784,11889,11890],{"class":786,"line":958},[784,11891,955],{"class":794},[784,11893,11894,11896],{"class":786,"line":1333},[784,11895,4997],{"class":895},[784,11897,11898],{"class":869}," resealed\n",[784,11900,11901],{"class":786,"line":1338},[784,11902,961],{"class":794},[624,11904,11905,11906,11909,11910,11913,11914,886],{},"It runs on every run of the command, so it leaves current values alone, and resolves to how many it sealed again. Settings marked secret are SHADE's to seal again. A secret in a link the module sent by email (",[632,11907,11908],{},"ctx.vault.hash",") is checked with ",[632,11911,11912],{},"ctx.vault.hashMatches(value, hash)",", which also accepts the hash made with the previous ",[632,11915,11677],{},[619,11917,281],{"id":10736},[624,11919,11920,11921,672,11924,11927,11928,11930],{},"A module that needs email or accounts declares the capability (",[632,11922,11923],{},"capabilities: { email: {} }",[632,11925,11926],{},"accounts","). The manifest has no ",[632,11929,10736],{}," key, and a manifest with one is refused at load. Until the service behind a required capability is ready (set up, and switched on where it has a switch), the module shows \"Needs setup\" on the Modules page, with a link to the service's screen, and cannot be switched on. While the module is on, the service cannot stop working.",[624,11932,11933,11934,11936,11937,1829,11939,11941,11942,11945,11946,11948,11949,11952],{},"Appointments is the example: it sends its confirmations with ",[632,11935,6109],{}," and declares ",[632,11938,5596],{},[632,11940,11926],{}," as optional. Guests book without an account, and its staff routes answer only while the capability is on (",[632,11943,11944],{},"hasCapability(ctx, 'accounts')","). A module context without the capability is refused by the service itself (",[632,11947,6109],{}," starts with ",[632,11950,11951],{},"requireCapability","): FORBIDDEN, counted for the module.",[624,11954,11955,11956,11959,11960,7681,11963,672,11966,1839,11969,11972],{},"The providers behind capabilities with settings are registered in one shape, in the provider registry (",[632,11957,11958],{},"shade\u002Fkernel\u002Fproviders\u002Fregistry.ts","): each says whether it is configured, whether it is on and which others it needs (",[632,11961,11962],{},"registerProviderSetup",[632,11964,11965],{},"readyProviders",[632,11967,11968],{},"missingDependencies",[632,11970,11971],{},"neededBy"," answer the same questions for all of them: accounts need email, and email cannot be switched off while accounts or a module need it.",[624,11974,11975,11978,11979,11981,11982,11985,11986,11989,11990,11993,11994,11996,11997,12000],{},[1079,11976,11977],{},"Payments"," are not a service of core: the official payments module offers them to the modules that require it (",[628,11980,451],{"href":452},"). The module that takes money starts a checkout with ",[632,11983,11984],{},"callModule",", sends the visitor to ",[632,11987,11988],{},"checkoutUrl",", and hears every change of its payments as an event (",[632,11991,11992],{},"payments.payment.\u003Cstatus>",") in its manifest's ",[632,11995,634],{},". Amounts are SHADE's ",[632,11998,11999],{},"Money"," in euros. Refunds and cancelling are calls too, made after the module's own permission check.",[12002,12003,12004],"style",{},"html pre.shiki code .sBMFI, html code.shiki .sBMFI{--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B}html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}html pre.shiki code .swJcz, html code.shiki .swJcz{--shiki-light:#E53935;--shiki-default:#F07178;--shiki-dark:#F07178}html pre.shiki code .spNyl, html code.shiki .spNyl{--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA}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 .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}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 .s2Zo4, html code.shiki .s2Zo4{--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF}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);}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 .sbssI, html code.shiki .sbssI{--shiki-light:#F76D47;--shiki-default:#F78C6C;--shiki-dark:#F78C6C}html pre.shiki code .sfNiH, html code.shiki .sfNiH{--shiki-light:#FF5370;--shiki-default:#FF9CAC;--shiki-dark:#FF9CAC}",{"title":780,"searchDepth":811,"depth":811,"links":12006},[12007,12011,12012,12014,12015,12018,12019,12020,12021,12022,12023,12024,12025,12026,12027,12028,12029,12030,12031,12032,12033,12034,12035,12036,12037,12038,12039,12042,12043,12044,12045,12046,12047,12048,12049,12050,12051,12052,12053],{"id":621,"depth":811,"text":622,"children":12008},[12009],{"id":1147,"depth":821,"text":12010},"Forwarding errors: errorForwarding",{"id":1432,"depth":811,"text":1433},{"id":1975,"depth":811,"text":12013},"Hearing events: on",{"id":2133,"depth":811,"text":2134},{"id":2547,"depth":811,"text":2548,"children":12016},[12017],{"id":2986,"depth":821,"text":2987},{"id":3181,"depth":811,"text":3182},{"id":3648,"depth":811,"text":3648},{"id":3694,"depth":811,"text":3695},{"id":4030,"depth":811,"text":4031},{"id":4057,"depth":811,"text":4058},{"id":4312,"depth":811,"text":421},{"id":4353,"depth":811,"text":4354},{"id":4381,"depth":811,"text":4382},{"id":4404,"depth":811,"text":4405},{"id":4664,"depth":811,"text":4665},{"id":4815,"depth":811,"text":4816},{"id":4939,"depth":811,"text":4940},{"id":5073,"depth":811,"text":5074},{"id":5094,"depth":811,"text":5095},{"id":5589,"depth":811,"text":5590},{"id":6096,"depth":811,"text":6097},{"id":6478,"depth":811,"text":6479},{"id":7225,"depth":811,"text":349},{"id":7659,"depth":811,"text":7660},{"id":7701,"depth":811,"text":7702},{"id":8065,"depth":811,"text":8066},{"id":8268,"depth":811,"text":8269,"children":12040},[12041],{"id":8649,"depth":821,"text":8650},{"id":9000,"depth":811,"text":9001},{"id":9387,"depth":811,"text":299},{"id":9691,"depth":811,"text":9692},{"id":9988,"depth":811,"text":9989},{"id":10467,"depth":811,"text":10468},{"id":10750,"depth":811,"text":10751},{"id":11174,"depth":811,"text":11175},{"id":11212,"depth":811,"text":11213},{"id":11398,"depth":811,"text":11399},{"id":11649,"depth":811,"text":11650},{"id":11662,"depth":811,"text":11663},{"id":10736,"depth":811,"text":281},"md",null,{},{"title":474,"description":780},"xjbuTQnVlfa94oVHTC7kt0kXFwndbnTwd-wCppdMnAg",[12060,12061],{"title":110,"path":471,"stem":472,"description":780,"children":-1},{"title":478,"path":479,"stem":480,"description":780,"children":-1},1796500156098]