kempo 4.6.2 → 4.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -0
- package/app-public/account/index.page.html +2 -0
- package/app-public/nav.fragment.html +2 -1
- package/app-templates/emails/email.template.html +14 -0
- package/app-templates/emails/reset-password.page.html +19 -0
- package/app-templates/emails/test.page.html +21 -0
- package/app-templates/emails/verify-email.page.html +18 -0
- package/bin/cli.js +3 -0
- package/dist/admin/components/Dashboard.js +2 -2
- package/dist/admin/components/Dashboard.js.map +1 -1
- package/dist/admin/components/Menus.js +103 -0
- package/dist/admin/components/Menus.js.map +1 -0
- package/dist/admin/content/menus/index.page.html +11 -0
- package/dist/admin/nav.fragment.html +6 -0
- package/dist/kempo/api/fragments/DELETE.js +1 -1
- package/dist/kempo/api/fragments/DELETE.js.map +1 -1
- package/dist/kempo/api/fragments/GET.js +1 -1
- package/dist/kempo/api/fragments/GET.js.map +1 -1
- package/dist/kempo/api/fragments/POST.js +1 -1
- package/dist/kempo/api/fragments/POST.js.map +1 -1
- package/dist/kempo/api/fragments/disable/PUT.js +1 -1
- package/dist/kempo/api/fragments/disable/PUT.js.map +1 -1
- package/dist/kempo/api/fragments/enable/PUT.js +1 -1
- package/dist/kempo/api/fragments/enable/PUT.js.map +1 -1
- package/dist/kempo/api/fragments/file/GET.js +1 -1
- package/dist/kempo/api/fragments/file/GET.js.map +1 -1
- package/dist/kempo/api/fragments/file/PATCH.js +1 -1
- package/dist/kempo/api/fragments/file/PATCH.js.map +1 -1
- package/dist/kempo/api/fragments/file/PUT.js +1 -1
- package/dist/kempo/api/fragments/file/PUT.js.map +1 -1
- package/dist/kempo/api/fragments/lock/PUT.js +1 -1
- package/dist/kempo/api/fragments/lock/PUT.js.map +1 -1
- package/dist/kempo/api/globals/DELETE.js +1 -1
- package/dist/kempo/api/globals/DELETE.js.map +1 -1
- package/dist/kempo/api/globals/GET.js +1 -1
- package/dist/kempo/api/globals/GET.js.map +1 -1
- package/dist/kempo/api/globals/POST.js +1 -1
- package/dist/kempo/api/globals/POST.js.map +1 -1
- package/dist/kempo/api/globals/disable/PUT.js +1 -1
- package/dist/kempo/api/globals/disable/PUT.js.map +1 -1
- package/dist/kempo/api/globals/enable/PUT.js +1 -1
- package/dist/kempo/api/globals/enable/PUT.js.map +1 -1
- package/dist/kempo/api/globals/entry/GET.js +1 -1
- package/dist/kempo/api/globals/entry/GET.js.map +1 -1
- package/dist/kempo/api/globals/entry/PUT.js +1 -1
- package/dist/kempo/api/globals/entry/PUT.js.map +1 -1
- package/dist/kempo/api/globals/lock/PUT.js +1 -1
- package/dist/kempo/api/globals/lock/PUT.js.map +1 -1
- package/dist/kempo/api/menus/DELETE.js +2 -0
- package/dist/kempo/api/menus/DELETE.js.map +1 -0
- package/dist/kempo/api/menus/GET.js +2 -0
- package/dist/kempo/api/menus/GET.js.map +1 -0
- package/dist/kempo/api/menus/POST.js +2 -0
- package/dist/kempo/api/menus/POST.js.map +1 -0
- package/dist/kempo/api/menus/adopt/PUT.js +2 -0
- package/dist/kempo/api/menus/adopt/PUT.js.map +1 -0
- package/dist/kempo/api/menus/items/DELETE.js +2 -0
- package/dist/kempo/api/menus/items/DELETE.js.map +1 -0
- package/dist/kempo/api/menus/items/POST.js +2 -0
- package/dist/kempo/api/menus/items/POST.js.map +1 -0
- package/dist/kempo/api/menus/items/enabled/PUT.js +2 -0
- package/dist/kempo/api/menus/items/enabled/PUT.js.map +1 -0
- package/dist/kempo/api/menus/items/order/PUT.js +2 -0
- package/dist/kempo/api/menus/items/order/PUT.js.map +1 -0
- package/dist/kempo/api/menus/location/PUT.js +2 -0
- package/dist/kempo/api/menus/location/PUT.js.map +1 -0
- package/dist/kempo/api/pages/DELETE.js +1 -1
- package/dist/kempo/api/pages/DELETE.js.map +1 -1
- package/dist/kempo/api/pages/GET.js +1 -1
- package/dist/kempo/api/pages/GET.js.map +1 -1
- package/dist/kempo/api/pages/POST.js +1 -1
- package/dist/kempo/api/pages/POST.js.map +1 -1
- package/dist/kempo/api/pages/directories/GET.js +1 -1
- package/dist/kempo/api/pages/directories/GET.js.map +1 -1
- package/dist/kempo/api/pages/disable/PUT.js +1 -1
- package/dist/kempo/api/pages/disable/PUT.js.map +1 -1
- package/dist/kempo/api/pages/enable/PUT.js +1 -1
- package/dist/kempo/api/pages/enable/PUT.js.map +1 -1
- package/dist/kempo/api/pages/file/GET.js +1 -1
- package/dist/kempo/api/pages/file/GET.js.map +1 -1
- package/dist/kempo/api/pages/file/PATCH.js +1 -1
- package/dist/kempo/api/pages/file/PATCH.js.map +1 -1
- package/dist/kempo/api/pages/file/PUT.js +1 -1
- package/dist/kempo/api/pages/file/PUT.js.map +1 -1
- package/dist/kempo/api/pages/lock/PUT.js +1 -1
- package/dist/kempo/api/pages/lock/PUT.js.map +1 -1
- package/dist/kempo/api/pages/rescan/POST.js +1 -1
- package/dist/kempo/api/pages/rescan/POST.js.map +1 -1
- package/dist/kempo/api/pages/search/GET.js +1 -1
- package/dist/kempo/api/pages/search/GET.js.map +1 -1
- package/dist/kempo/api/pages/templates/GET.js +1 -1
- package/dist/kempo/api/pages/templates/GET.js.map +1 -1
- package/dist/kempo/api/templates/DELETE.js +1 -1
- package/dist/kempo/api/templates/DELETE.js.map +1 -1
- package/dist/kempo/api/templates/GET.js +1 -1
- package/dist/kempo/api/templates/GET.js.map +1 -1
- package/dist/kempo/api/templates/POST.js +1 -1
- package/dist/kempo/api/templates/POST.js.map +1 -1
- package/dist/kempo/api/templates/disable/PUT.js +1 -1
- package/dist/kempo/api/templates/disable/PUT.js.map +1 -1
- package/dist/kempo/api/templates/enable/PUT.js +1 -1
- package/dist/kempo/api/templates/enable/PUT.js.map +1 -1
- package/dist/kempo/api/templates/file/GET.js +1 -1
- package/dist/kempo/api/templates/file/GET.js.map +1 -1
- package/dist/kempo/api/templates/file/PATCH.js +1 -1
- package/dist/kempo/api/templates/file/PATCH.js.map +1 -1
- package/dist/kempo/api/templates/file/PUT.js +1 -1
- package/dist/kempo/api/templates/file/PUT.js.map +1 -1
- package/dist/kempo/api/templates/lock/PUT.js +1 -1
- package/dist/kempo/api/templates/lock/PUT.js.map +1 -1
- package/dist/kempo/components/DashboardWidget.js +4 -4
- package/dist/kempo/components/DashboardWidget.js.map +1 -1
- package/dist/kempo/icons/campaign.svg +1 -0
- package/dist/kempo/icons/fields.svg +1 -0
- package/dist/kempo/icons/open_in_new.svg +1 -0
- package/dist/kempo/sdk.js +1 -1
- package/dist/kempo/sdk.js.map +1 -1
- package/middleware/kempo.js +48 -12
- package/package.json +2 -2
- package/server/db/schema.js +24 -0
- package/server/sdk.js +21 -0
- package/server/utils/auth/requestPasswordReset.js +9 -3
- package/server/utils/auth/verifyEmail.js +10 -1
- package/server/utils/dashboard/coreWidgets.js +1 -0
- package/server/utils/dashboard/helpers.js +6 -0
- package/server/utils/email/renderEmailTemplate.js +63 -0
- package/server/utils/email/sendEmailFromTemplate.js +9 -27
- package/server/utils/extensions/aliases.js +71 -0
- package/server/utils/extensions/checkClaims.js +32 -0
- package/server/utils/extensions/claims.js +54 -0
- package/server/utils/extensions/createTablesFromSchema.js +13 -20
- package/server/utils/extensions/enableExtensionTree.js +8 -0
- package/server/utils/extensions/installExtension.js +32 -0
- package/server/utils/extensions/readKempoConfig.js +2 -2
- package/server/utils/extensions/scopeCache.js +14 -1
- package/server/utils/extensions/scopes.js +72 -0
- package/server/utils/extensions/uninstallExtensionTree.js +2 -1
- package/server/utils/extensions/updateExtension.js +35 -0
- package/server/utils/global-content/createGlobalContent.js +8 -18
- package/server/utils/global-content/deleteGlobalContent.js +1 -16
- package/server/utils/global-content/disableGlobalContent.js +1 -16
- package/server/utils/global-content/enableGlobalContent.js +1 -16
- package/server/utils/global-content/helpers.js +40 -6
- package/server/utils/global-content/listGlobalContent.js +2 -2
- package/server/utils/global-content/setGlobalContentLocked.js +1 -16
- package/server/utils/global-content/updateGlobalContent.js +1 -16
- package/server/utils/menus/adoptMenuItem.js +58 -0
- package/server/utils/menus/assignMenuLocation.js +47 -0
- package/server/utils/menus/deleteMenu.js +27 -0
- package/server/utils/menus/deleteMenuItems.js +27 -0
- package/server/utils/menus/findMenuLocations.js +41 -0
- package/server/utils/menus/findNavItems.js +74 -0
- package/server/utils/menus/findPages.js +73 -0
- package/server/utils/menus/listMenus.js +103 -0
- package/server/utils/menus/markup.js +55 -0
- package/server/utils/menus/reorderMenuItems.js +36 -0
- package/server/utils/menus/saveMenu.js +54 -0
- package/server/utils/menus/saveMenuItem.js +122 -0
- package/server/utils/menus/setMenuItemEnabled.js +31 -0
- package/server/utils/menus/store.js +90 -0
- package/server/utils/scheduler/helpers.js +36 -0
- package/server/utils/scheduler/listJobs.js +11 -0
- package/server/utils/scheduler/registerJobs.js +37 -0
- package/server/utils/scheduler/runJobs.js +90 -0
- package/server/utils/scheduler/scheduler.js +37 -0
- package/server/utils/scheduler/unregisterJobs.js +16 -0
- package/server/utils/settings/ensureEncryptionKey.js +132 -0
- package/server/utils/settings/secretCrypto.js +5 -1
- package/dist/kempo/icons/create_new_folder.svg +0 -1
- package/dist/kempo/icons/credit_card.svg +0 -1
- package/dist/kempo/icons/login.svg +0 -1
- package/dist/kempo/icons/payments.svg +0 -1
- package/dist/kempo/icons/toll.svg +0 -1
- package/dist/kempo/icons/wallet.svg +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"src\\kempo\\api\\templates\\lock\\PUT.js","names":["resolve","join","currentUserHasPermission","setTemplateLocked","rootDir","
|
|
1
|
+
{"version":3,"file":"src\\kempo\\api\\templates\\lock\\PUT.js","names":["existsSync","resolve","join","currentUserHasPermission","setTemplateLocked","rootDir","process","cwd","dirname","async","request","response","token","cookies","session_token","permError","hasPermission","status","code","json","error","msg","file","locked","body","data"],"sources":["0"],"sourcesContent":["import { existsSync } from 'fs';\r\nimport { resolve, join } from 'path';\r\nimport currentUserHasPermission from '../../../../../server/utils/permissions/currentUserHasPermission.js';\r\nimport setTemplateLocked from '../../../../../server/utils/templates/setTemplateLocked.js';\r\n\r\nconst rootDir = existsSync(join(process.cwd(), 'public')) ? join(process.cwd(), 'public') : resolve(import.meta.dirname, '../../../../../app-public');\r\n\r\nexport default async (request, response) => {\r\n\tconst token = request.cookies.session_token;\r\n\tconst [permError, hasPermission] = await currentUserHasPermission(token, 'system:pages:update');\r\n\r\n\tif(permError){\r\n\t\treturn response.status(permError.code).json({ error: permError.msg });\r\n\t}\r\n\r\n\tif(!hasPermission){\r\n\t\treturn response.status(403).json({ error: 'Insufficient permissions' });\r\n\t}\r\n\r\n\tconst { file, locked } = request.body;\r\n\r\n\tif(!file){\r\n\t\treturn response.status(400).json({ error: 'File path is required' });\r\n\t}\r\n\r\n\tif(typeof locked !== 'boolean'){\r\n\t\treturn response.status(400).json({ error: 'locked must be a boolean' });\r\n\t}\r\n\r\n\tconst [error, data] = await setTemplateLocked({ rootDir, file, locked });\r\n\r\n\tif(error){\r\n\t\treturn response.status(error.code).json({ error: error.msg });\r\n\t}\r\n\r\n\tresponse.json(data);\r\n};\r\n"],"mappings":"qBAASA,MAAkB,uBAClBC,UAASC,MAAY,cACvBC,MAA8B,6EAC9BC,MAAuB,6DAE9B,MAAMC,EAAUL,EAAWE,EAAKI,QAAQC,MAAO,WAAaL,EAAKI,QAAQC,MAAO,UAAYN,cAAoBO,QAAS,4CAE1GC,MAAOC,EAASC,KAC9B,MAAMC,EAAQF,EAAQG,QAAQC,eACvBC,EAAWC,SAAuBb,EAAyBS,EAAO,uBAEzE,GAAGG,EACF,OAAOJ,EAASM,OAAOF,EAAUG,MAAMC,KAAK,CAAEC,MAAOL,EAAUM,MAGhE,IAAIL,EACH,OAAOL,EAASM,OAAO,KAAKE,KAAK,CAAEC,MAAO,6BAG3C,MAAME,KAAEA,EAAIC,OAAEA,GAAWb,EAAQc,KAEjC,IAAIF,EACH,OAAOX,EAASM,OAAO,KAAKE,KAAK,CAAEC,MAAO,0BAG3C,GAAqB,kBAAXG,EACT,OAAOZ,EAASM,OAAO,KAAKE,KAAK,CAAEC,MAAO,6BAG3C,MAAOA,EAAOK,SAAcrB,EAAkB,CAAEC,UAASiB,OAAMC,WAE/D,GAAGH,EACF,OAAOT,EAASM,OAAOG,EAAMF,MAAMC,KAAK,CAAEC,MAAOA,EAAMC,MAGxDV,EAASQ,KAAKM","ignoreList":[]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import e from"/kempo-ui/components/LightComponent.js";import{html as t,nothing as i}from"/kempo-ui/lit-all.min.js";import"/kempo-ui/components/Icon.js";import n from"/kempo-ui/components/Dialog.js";import{currentUserHasPermission as s}from"/kempo/sdk.js";export default class
|
|
2
|
-
${this.definition?.icon?t`<k-icon class="mr" name=${this.definition.icon}></k-icon>`:i}
|
|
1
|
+
import e from"/kempo-ui/components/LightComponent.js";import{html as t,nothing as i}from"/kempo-ui/lit-all.min.js";import"/kempo-ui/components/Icon.js";import n from"/kempo-ui/components/Dialog.js";import{currentUserHasPermission as s}from"/kempo/sdk.js";export default class r extends e{static properties={width:{type:Number,reflect:!0},height:{type:Number,reflect:!0},definition:{attribute:!1},loading:{state:!0},failure:{state:!0},ctaAllowed:{state:!0}};constructor(){super(),this.width=2,this.height=1,this.definition=null,this.cta=null,this.loading=!0,this.failure="",this.ctaAllowed=!1}connectedCallback(){super.connectedCallback(),this.classList.add("d-b"),this.style.height="100%",this.refresh(),this.checkCta()}load=async()=>{};refresh=async()=>{try{await this.load(),this.failure=""}catch(e){this.failure=e?.message||"Could not load this widget."}this.loading=!1};getCta(){return this.cta}actions(){return[]}unwrap=async e=>{const[t,i]=await e;if(t)throw new Error(t.msg||"Request failed");return i};openForm=({title:e,fields:t,confirmText:i="Save",submit:s})=>{const r=document.createElement("div");r.className="p";const o={};t.forEach(({name:e,label:t,type:i="text",placeholder:n="",value:s="",options:a=[]})=>{const c=document.createElement("div");c.className="mb";const l=Object.assign(document.createElement("label"),{className:"d-b mbq",textContent:t});let d;"select"===i?(d=document.createElement("select"),d.className="full",a.forEach(e=>d.append(Object.assign(document.createElement("option"),{value:e.value,textContent:e.label,selected:e.value===s})))):d=Object.assign(document.createElement("input"),{type:i,className:"full",placeholder:n,value:s}),o[e]=d,c.append(l,d),r.append(c)});const a=Object.assign(document.createElement("p"),{className:"tc-danger m0",role:"alert"});r.append(a);const c=n.create(r,{title:e,confirmText:i,cancelText:"Cancel",confirmAction:async e=>{e.keepDialogOpen=!0,a.textContent="";const i=Object.fromEntries(t.map(({name:e})=>[e,o[e].value.trim()])),n=t.find(({name:e,required:t=!0})=>t&&!i[e]);if(n)return void(a.textContent=`${n.label} is required.`);const r=await s(i);r?a.textContent=r:c.close()}});return Object.values(o)[0]?.focus(),c};checkCta=async()=>{const e=this.getCta()?.permission;if(!e)return void(this.ctaAllowed=!0);const[t,i]=await s({permission:e});this.ctaAllowed=!t&&!!i?.hasPermission};renderTitle=()=>t`
|
|
2
|
+
${this.definition?.iconSrc?t`<k-icon class="mr" src=${this.definition.iconSrc}></k-icon>`:this.definition?.icon?t`<k-icon class="mr" name=${this.definition.icon}></k-icon>`:i}
|
|
3
3
|
<strong class="flex">${this.definition?.title??""}</strong>
|
|
4
|
-
`;renderActions=()=>{const e=this.width<2;return[...this.definition?.actions??[],...this.actions()].map(({label:n,icon:s,href:
|
|
4
|
+
`;renderActions=()=>{const e=this.width<2;return[...this.definition?.actions??[],...this.actions()].map(({label:n,icon:s,iconSrc:r,href:o,onClick:a,primary:c})=>{const l=r||s?t`${r?t`<k-icon src=${r}></k-icon>`:t`<k-icon name=${s}></k-icon>`}${e?i:t` ${n}`}`:n,d="btn ml "+(c?"primary":"");return o?t`<a class=${d} href=${o} title=${n} aria-label=${n}>${l}</a>`:t`<button class=${d} title=${n} aria-label=${n} @click=${a}>${l}</button>`})};renderHeader(){return t`<header class="d-f px pyh bb" style="align-items: center;">${this.renderTitle()}${this.renderActions()}</header>`}renderContent(){return i}renderBody(){return this.failure?t`
|
|
5
5
|
<p class="tc-danger" role="alert">${this.failure}</p>
|
|
6
6
|
<button @click=${this.refresh}>Try again</button>
|
|
7
|
-
`:this.loading?t`<p class="tc-muted">Loading…</p>`:this.renderContent()}renderFooter=()=>{const e=this.getCta();if(!e||!this.ctaAllowed||this.failure)return i;const n=t`${e.icon?t`<k-icon name=${e.icon}></k-icon> `:i}${e.label}`;return t`
|
|
7
|
+
`:this.loading?t`<p class="tc-muted">Loading…</p>`:this.renderContent()}renderFooter=()=>{const e=this.getCta();if(!e||!this.ctaAllowed||this.failure)return i;const n=t`${e.iconSrc?t`<k-icon src=${e.iconSrc}></k-icon> `:e.icon?t`<k-icon name=${e.icon}></k-icon> `:i}${e.label}`;return t`
|
|
8
8
|
<footer class="d-f px pyh bt" style="justify-content: flex-end;">
|
|
9
9
|
${e.href?t`<a class="btn primary" href=${e.href}>${n}</a>`:t`<button class="primary" @click=${e.onClick}>${n}</button>`}
|
|
10
10
|
</footer>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"src\\kempo\\components\\DashboardWidget.js","names":["LightComponent","html","nothing","Dialog","currentUserHasPermission","DashboardWidget","static","width","type","Number","reflect","height","definition","attribute","loading","state","failure","ctaAllowed","constructor","super","this","cta","connectedCallback","classList","add","style","refresh","checkCta","load","async","error","message","getCta","actions","unwrap","data","request","Error","msg","openForm","title","fields","confirmText","submit","content","document","createElement","className","inputs","forEach","name","label","placeholder","value","options","wrapper","caption","Object","assign","textContent","input","option","append","selected","role","dialog","create","cancelText","confirmAction","event","keepDialogOpen","values","fromEntries","map","trim","missing","find","required","close","focus","permission","hasPermission","renderTitle","icon","renderActions","compact","href","onClick","primary","classes","renderHeader","renderContent","renderBody","renderFooter","renderLightDom"],"sources":["0"],"sourcesContent":["import LightComponent from '/kempo-ui/components/LightComponent.js';\nimport { html, nothing } from '/kempo-ui/lit-all.min.js';\nimport '/kempo-ui/components/Icon.js';\nimport Dialog from '/kempo-ui/components/Dialog.js';\nimport { currentUserHasPermission } from '/kempo/sdk.js';\n\n/*\n The base class for an admin dashboard widget. Extend it, define your element, and register the widget\n with `registerDashboardWidget` (or `kempo.widgets` in package.json).\n\n The dashboard creates the element only when the user has the widget on screen, and sets `width` and\n `height` (in blocks) on it, so a widget never loads data for a tile that is hidden. Override:\n\n `load()` fetch what the widget needs and assign it to reactive properties. Throw to show\n the failure message with a retry button. Runs when the element connects and\n again on `refresh()`.\n `renderContent()` return the markup for a loaded widget. Use `width` and `height` to show more\n when there is room.\n\n Declare your own properties by spreading the base ones:\n `static properties = { ...DashboardWidget.properties, items: { state: true } }`.\n\n The widget fills a bordered tile and owns everything inside it, its header included. `renderHeader()`\n returns the header region; the default is the widget's icon and title from `definition` (the registered\n widget, set by the dashboard). Override it to add buttons, filters or a different title, and use\n `renderTitle()` to keep the default title inside your own header.\n\n Call to action. A widget may offer one primary thing to do, drawn the same way in every tile as a button\n in a footer. It is optional. Set `this.cta` in the constructor (or override `getCta()` when it depends on\n state) to `{ label, icon, href }` for a link, or `{ label, icon, onClick }` for a callback, and add\n `permission` to show it only to people who hold that permission. For a callback that needs input, call\n `openForm()` to get a standard dialog.\n\n Header actions are separate: links declared on the registration (`actions`), or returned from\n `actions()`, appear as small buttons beside the title.\n\n Call `super.updated(changed)` if you override `updated()`.\n*/\nexport default class DashboardWidget extends LightComponent {\n static properties = {\n width: { type: Number, reflect: true },\n height: { type: Number, reflect: true },\n definition: { attribute: false },\n loading: { state: true },\n failure: { state: true },\n ctaAllowed: { state: true }\n };\n\n constructor(){\n super();\n this.width = 2;\n this.height = 1;\n this.definition = null;\n this.cta = null;\n this.loading = true;\n this.failure = '';\n this.ctaAllowed = false;\n }\n\n /*\n Lifecycle Callbacks\n */\n\n connectedCallback(){\n super.connectedCallback();\n this.classList.add('d-b');\n this.style.height = '100%';\n this.refresh();\n this.checkCta();\n }\n\n /*\n Public Methods\n */\n\n load = async () => {};\n\n refresh = async () => {\n try {\n await this.load();\n this.failure = '';\n } catch(error) {\n this.failure = error?.message || 'Could not load this widget.';\n }\n this.loading = false;\n };\n\n getCta(){\n return this.cta;\n }\n\n actions(){\n return [];\n }\n\n /*\n Resolves an SDK call, which returns `[error, data]`, to its data, or throws the error's message so\n `load()` can stay a straight line.\n */\n unwrap = async request => {\n const [error, data] = await request;\n if(error) throw new Error(error.msg || 'Request failed');\n return data;\n };\n\n /*\n Opens a standard dialog with a few fields and a confirm button.\n\n `fields` are `{ name, label, type, placeholder, value, options, required }` where `type` is `text`\n (default), `email`, `password` or `select` (then `options` is `[{ value, label }]`). `submit` receives\n `{ [name]: value }` and returns nothing on success, which closes the dialog, or an error message, which\n is shown in the dialog and keeps it open with what was typed.\n */\n openForm = ({ title, fields, confirmText = 'Save', submit }) => {\n const content = document.createElement('div');\n content.className = 'p';\n const inputs = {};\n\n fields.forEach(({ name, label, type = 'text', placeholder = '', value = '', options = [] }) => {\n const wrapper = document.createElement('div');\n wrapper.className = 'mb';\n const caption = Object.assign(document.createElement('label'), { className: 'd-b mbq', textContent: label });\n let input;\n\n if(type === 'select'){\n input = document.createElement('select');\n input.className = 'full';\n options.forEach(option => input.append(Object.assign(document.createElement('option'), { value: option.value, textContent: option.label, selected: option.value === value })));\n } else {\n input = Object.assign(document.createElement('input'), { type, className: 'full', placeholder, value });\n }\n\n inputs[name] = input;\n wrapper.append(caption, input);\n content.append(wrapper);\n });\n\n const error = Object.assign(document.createElement('p'), { className: 'tc-danger m0', role: 'alert' });\n content.append(error);\n\n const dialog = Dialog.create(content, {\n title,\n confirmText,\n cancelText: 'Cancel',\n confirmAction: async event => {\n event.keepDialogOpen = true;\n error.textContent = '';\n const values = Object.fromEntries(fields.map(({ name }) => [name, inputs[name].value.trim()]));\n const missing = fields.find(({ name, required = true }) => required && !values[name]);\n\n if(missing){\n error.textContent = `${missing.label} is required.`;\n return;\n }\n\n const message = await submit(values);\n\n if(message) error.textContent = message;\n else dialog.close();\n }\n });\n\n Object.values(inputs)[0]?.focus();\n return dialog;\n };\n\n /*\n Utility Functions\n */\n\n checkCta = async () => {\n const permission = this.getCta()?.permission;\n\n if(!permission){\n this.ctaAllowed = true;\n return;\n }\n\n const [error, data] = await currentUserHasPermission({ permission });\n this.ctaAllowed = !error && !!data?.hasPermission;\n };\n\n /*\n Rendering\n */\n\n renderTitle = () => html`\n ${this.definition?.icon ? html`<k-icon class=\"mr\" name=${this.definition.icon}></k-icon>` : nothing}\n <strong class=\"flex\">${this.definition?.title ?? ''}</strong>\n `;\n\n renderActions = () => {\n const compact = this.width < 2;\n return [...(this.definition?.actions ?? []), ...this.actions()].map(({ label, icon, href, onClick, primary }) => {\n const content = icon\n ? html`<k-icon name=${icon}></k-icon>${compact ? nothing : html` ${label}`}`\n : label;\n const classes = `btn ml ${primary ? 'primary' : ''}`;\n return href\n ? html`<a class=${classes} href=${href} title=${label} aria-label=${label}>${content}</a>`\n : html`<button class=${classes} title=${label} aria-label=${label} @click=${onClick}>${content}</button>`;\n });\n };\n\n renderHeader(){\n return html`<header class=\"d-f px pyh bb\" style=\"align-items: center;\">${this.renderTitle()}${this.renderActions()}</header>`;\n }\n\n renderContent(){\n return nothing;\n }\n\n renderBody(){\n if(this.failure){\n return html`\n <p class=\"tc-danger\" role=\"alert\">${this.failure}</p>\n <button @click=${this.refresh}>Try again</button>\n `;\n }\n if(this.loading) return html`<p class=\"tc-muted\">Loading…</p>`;\n return this.renderContent();\n }\n\n renderFooter = () => {\n const cta = this.getCta();\n\n if(!cta || !this.ctaAllowed || this.failure) return nothing;\n\n const content = html`${cta.icon ? html`<k-icon name=${cta.icon}></k-icon> ` : nothing}${cta.label}`;\n\n return html`\n <footer class=\"d-f px pyh bt\" style=\"justify-content: flex-end;\">\n ${cta.href\n ? html`<a class=\"btn primary\" href=${cta.href}>${content}</a>`\n : html`<button class=\"primary\" @click=${cta.onClick}>${content}</button>`}\n </footer>\n `;\n };\n\n renderLightDom(){\n return html`\n <div style=\"display: flex; flex-direction: column; height: 100%; min-height: 0;\">\n ${this.renderHeader()}\n <div class=\"p\" style=\"flex: 1; min-height: 0; overflow: auto;\">${this.renderBody()}</div>\n ${this.renderFooter()}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b","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"src\\kempo\\components\\DashboardWidget.js","names":["LightComponent","html","nothing","Dialog","currentUserHasPermission","DashboardWidget","static","width","type","Number","reflect","height","definition","attribute","loading","state","failure","ctaAllowed","constructor","super","this","cta","connectedCallback","classList","add","style","refresh","checkCta","load","async","error","message","getCta","actions","unwrap","data","request","Error","msg","openForm","title","fields","confirmText","submit","content","document","createElement","className","inputs","forEach","name","label","placeholder","value","options","wrapper","caption","Object","assign","textContent","input","option","append","selected","role","dialog","create","cancelText","confirmAction","event","keepDialogOpen","values","fromEntries","map","trim","missing","find","required","close","focus","permission","hasPermission","renderTitle","iconSrc","icon","renderActions","compact","href","onClick","primary","classes","renderHeader","renderContent","renderBody","renderFooter","renderLightDom"],"sources":["0"],"sourcesContent":["import LightComponent from '/kempo-ui/components/LightComponent.js';\nimport { html, nothing } from '/kempo-ui/lit-all.min.js';\nimport '/kempo-ui/components/Icon.js';\nimport Dialog from '/kempo-ui/components/Dialog.js';\nimport { currentUserHasPermission } from '/kempo/sdk.js';\n\n/*\n The base class for an admin dashboard widget. Extend it, define your element, and register the widget\n with `registerDashboardWidget` (or `kempo.widgets` in package.json).\n\n The dashboard creates the element only when the user has the widget on screen, and sets `width` and\n `height` (in blocks) on it, so a widget never loads data for a tile that is hidden. Override:\n\n `load()` fetch what the widget needs and assign it to reactive properties. Throw to show\n the failure message with a retry button. Runs when the element connects and\n again on `refresh()`.\n `renderContent()` return the markup for a loaded widget. Use `width` and `height` to show more\n when there is room.\n\n Declare your own properties by spreading the base ones:\n `static properties = { ...DashboardWidget.properties, items: { state: true } }`.\n\n The widget fills a bordered tile and owns everything inside it, its header included. `renderHeader()`\n returns the header region; the default is the widget's icon and title from `definition` (the registered\n widget, set by the dashboard). Override it to add buttons, filters or a different title, and use\n `renderTitle()` to keep the default title inside your own header.\n\n Call to action. A widget may offer one primary thing to do, drawn the same way in every tile as a button\n in a footer. It is optional. Set `this.cta` in the constructor (or override `getCta()` when it depends on\n state) to `{ label, icon, href }` for a link, or `{ label, icon, onClick }` for a callback, and add\n `permission` to show it only to people who hold that permission. For a callback that needs input, call\n `openForm()` to get a standard dialog.\n\n Header actions are separate: links declared on the registration (`actions`), or returned from\n `actions()`, appear as small buttons beside the title.\n\n Call `super.updated(changed)` if you override `updated()`.\n*/\nexport default class DashboardWidget extends LightComponent {\n static properties = {\n width: { type: Number, reflect: true },\n height: { type: Number, reflect: true },\n definition: { attribute: false },\n loading: { state: true },\n failure: { state: true },\n ctaAllowed: { state: true }\n };\n\n constructor(){\n super();\n this.width = 2;\n this.height = 1;\n this.definition = null;\n this.cta = null;\n this.loading = true;\n this.failure = '';\n this.ctaAllowed = false;\n }\n\n /*\n Lifecycle Callbacks\n */\n\n connectedCallback(){\n super.connectedCallback();\n this.classList.add('d-b');\n this.style.height = '100%';\n this.refresh();\n this.checkCta();\n }\n\n /*\n Public Methods\n */\n\n load = async () => {};\n\n refresh = async () => {\n try {\n await this.load();\n this.failure = '';\n } catch(error) {\n this.failure = error?.message || 'Could not load this widget.';\n }\n this.loading = false;\n };\n\n getCta(){\n return this.cta;\n }\n\n actions(){\n return [];\n }\n\n /*\n Resolves an SDK call, which returns `[error, data]`, to its data, or throws the error's message so\n `load()` can stay a straight line.\n */\n unwrap = async request => {\n const [error, data] = await request;\n if(error) throw new Error(error.msg || 'Request failed');\n return data;\n };\n\n /*\n Opens a standard dialog with a few fields and a confirm button.\n\n `fields` are `{ name, label, type, placeholder, value, options, required }` where `type` is `text`\n (default), `email`, `password` or `select` (then `options` is `[{ value, label }]`). `submit` receives\n `{ [name]: value }` and returns nothing on success, which closes the dialog, or an error message, which\n is shown in the dialog and keeps it open with what was typed.\n */\n openForm = ({ title, fields, confirmText = 'Save', submit }) => {\n const content = document.createElement('div');\n content.className = 'p';\n const inputs = {};\n\n fields.forEach(({ name, label, type = 'text', placeholder = '', value = '', options = [] }) => {\n const wrapper = document.createElement('div');\n wrapper.className = 'mb';\n const caption = Object.assign(document.createElement('label'), { className: 'd-b mbq', textContent: label });\n let input;\n\n if(type === 'select'){\n input = document.createElement('select');\n input.className = 'full';\n options.forEach(option => input.append(Object.assign(document.createElement('option'), { value: option.value, textContent: option.label, selected: option.value === value })));\n } else {\n input = Object.assign(document.createElement('input'), { type, className: 'full', placeholder, value });\n }\n\n inputs[name] = input;\n wrapper.append(caption, input);\n content.append(wrapper);\n });\n\n const error = Object.assign(document.createElement('p'), { className: 'tc-danger m0', role: 'alert' });\n content.append(error);\n\n const dialog = Dialog.create(content, {\n title,\n confirmText,\n cancelText: 'Cancel',\n confirmAction: async event => {\n event.keepDialogOpen = true;\n error.textContent = '';\n const values = Object.fromEntries(fields.map(({ name }) => [name, inputs[name].value.trim()]));\n const missing = fields.find(({ name, required = true }) => required && !values[name]);\n\n if(missing){\n error.textContent = `${missing.label} is required.`;\n return;\n }\n\n const message = await submit(values);\n\n if(message) error.textContent = message;\n else dialog.close();\n }\n });\n\n Object.values(inputs)[0]?.focus();\n return dialog;\n };\n\n /*\n Utility Functions\n */\n\n checkCta = async () => {\n const permission = this.getCta()?.permission;\n\n if(!permission){\n this.ctaAllowed = true;\n return;\n }\n\n const [error, data] = await currentUserHasPermission({ permission });\n this.ctaAllowed = !error && !!data?.hasPermission;\n };\n\n /*\n Rendering\n */\n\n renderTitle = () => html`\n ${this.definition?.iconSrc ? html`<k-icon class=\"mr\" src=${this.definition.iconSrc}></k-icon>` : this.definition?.icon ? html`<k-icon class=\"mr\" name=${this.definition.icon}></k-icon>` : nothing}\n <strong class=\"flex\">${this.definition?.title ?? ''}</strong>\n `;\n\n renderActions = () => {\n const compact = this.width < 2;\n return [...(this.definition?.actions ?? []), ...this.actions()].map(({ label, icon, iconSrc, href, onClick, primary }) => {\n const content = iconSrc || icon\n ? html`${iconSrc ? html`<k-icon src=${iconSrc}></k-icon>` : html`<k-icon name=${icon}></k-icon>`}${compact ? nothing : html` ${label}`}`\n : label;\n const classes = `btn ml ${primary ? 'primary' : ''}`;\n return href\n ? html`<a class=${classes} href=${href} title=${label} aria-label=${label}>${content}</a>`\n : html`<button class=${classes} title=${label} aria-label=${label} @click=${onClick}>${content}</button>`;\n });\n };\n\n renderHeader(){\n return html`<header class=\"d-f px pyh bb\" style=\"align-items: center;\">${this.renderTitle()}${this.renderActions()}</header>`;\n }\n\n renderContent(){\n return nothing;\n }\n\n renderBody(){\n if(this.failure){\n return html`\n <p class=\"tc-danger\" role=\"alert\">${this.failure}</p>\n <button @click=${this.refresh}>Try again</button>\n `;\n }\n if(this.loading) return html`<p class=\"tc-muted\">Loading…</p>`;\n return this.renderContent();\n }\n\n renderFooter = () => {\n const cta = this.getCta();\n\n if(!cta || !this.ctaAllowed || this.failure) return nothing;\n\n const content = html`${cta.iconSrc ? html`<k-icon src=${cta.iconSrc}></k-icon> ` : cta.icon ? html`<k-icon name=${cta.icon}></k-icon> ` : nothing}${cta.label}`;\n\n return html`\n <footer class=\"d-f px pyh bt\" style=\"justify-content: flex-end;\">\n ${cta.href\n ? html`<a class=\"btn primary\" href=${cta.href}>${content}</a>`\n : html`<button class=\"primary\" @click=${cta.onClick}>${content}</button>`}\n </footer>\n `;\n };\n\n renderLightDom(){\n return html`\n <div style=\"display: flex; flex-direction: column; height: 100%; min-height: 0;\">\n ${this.renderHeader()}\n <div class=\"p\" style=\"flex: 1; min-height: 0; overflow: auto;\">${this.renderBody()}</div>\n ${this.renderFooter()}\n </div>\n `;\n }\n}\n"],"mappings":"OAAOA,MAAoB,wDAClBC,aAAMC,MAAe,iCACvB,sCACAC,MAAY,oEACVC,MAAgC,+BAkC1B,MAAMC,UAAwBL,EAC3CM,kBAAoB,CAClBC,MAAO,CAAEC,KAAMC,OAAQC,SAAS,GAChCC,OAAQ,CAAEH,KAAMC,OAAQC,SAAS,GACjCE,WAAY,CAAEC,WAAW,GACzBC,QAAS,CAAEC,OAAO,GAClBC,QAAS,CAAED,OAAO,GAClBE,WAAY,CAAEF,OAAO,IAGvB,WAAAG,GACEC,QACAC,KAAKb,MAAQ,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AASC,cAC1G,MAAM7C,EAAUuC,GAAWC,EACvBnF,CAAI,GAAGkF,EAAUlF,CAAI,eAAekF,cAAsBlF,CAAI,gBAAgBmF,gBAAmBE,EAAUpF,EAAUD,CAAI,IAAIkD,MAC7HA,EACEuC,EAAU,WAAUD,EAAU,UAAY,IAChD,OAAOF,EACHtF,CAAI,YAAYyF,UAAgBH,WAAcpC,gBAAoBA,KAASP,QAC3E3C,CAAI,iBAAiByF,WAAiBvC,gBAAoBA,YAAgBqC,KAAW5C,gBAI7F,YAAA+C,GACE,OAAO1F,CAAI,8DAA8DmB,KAAK8D,gBAAgB9D,KAAKiE,0BACrG,CAEA,aAAAO,GACE,OAAO1F,CACT,CAEA,UAAA2F,GACE,OAAGzE,KAAKJ,QACCf,CAAI;4CAC2BmB,KAAKJ;yBACxBI,KAAKM;QAGvBN,KAAKN,QAAgBb,CAAI,0CACrBmB,KAAKwE,eACd,CAEAE,aAAe,KACb,MAAMzE,EAAMD,KAAKY,SAEjB,IAAIX,IAAQD,KAAKH,YAAcG,KAAKJ,QAAS,OAAOd,EAEpD,MAAM0C,EAAU3C,CAAI,GAAGoB,EAAI8D,QAAUlF,CAAI,eAAeoB,EAAI8D,qBAAuB9D,EAAI+D,KAAOnF,CAAI,gBAAgBoB,EAAI+D,kBAAoBlF,IAAUmB,EAAI8B,QAExJ,OAAOlD,CAAI;;UAELoB,EAAIkE,KACFtF,CAAI,+BAA+BoB,EAAIkE,QAAQ3C,QAC/C3C,CAAI,kCAAkCoB,EAAImE,WAAW5C;;OAK/D,cAAAmD,GACE,OAAO9F,CAAI;;UAELmB,KAAKuE;yEAC0DvE,KAAKyE;UACpEzE,KAAK0E;;KAGb","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path fill="currentColor" d="M720-440v-80h160v80H720Zm48 280-128-96 48-64 128 96-48 64Zm-80-480-48-64 128-96 48 64-128 96ZM200-200v-160h-40q-33 0-56.5-23.5T80-440v-80q0-33 23.5-56.5T160-600h160l200-120v480L320-360h-40v160h-80Zm240-182v-196l-98 58H160v80h182l98 58Zm120 36v-268q27 24 43.5 58.5T620-480q0 41-16.5 75.5T560-346ZM300-480Z"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path fill="currentColor" d="M360-240h440v-107H360v107ZM160-613h120v-107H160v107Zm0 187h120v-107H160v107Zm0 186h120v-107H160v107Zm200-186h440v-107H360v107Zm0-187h440v-107H360v107ZM160-160q-33 0-56.5-23.5T80-240v-480q0-33 23.5-56.5T160-800h640q33 0 56.5 23.5T880-720v480q0 33-23.5 56.5T800-160H160Z"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path fill="currentColor" d="M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h280v80H200v560h560v-280h80v280q0 33-23.5 56.5T760-120H200Zm188-212-56-56 372-372H560v-80h280v280h-80v-144L388-332Z"/></svg>
|
package/dist/kempo/sdk.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{get as e,post as s,put as o,patch as n,del as t}from"./fetch.js";const a="/kempo/api";export const register=async({email:e,password:o,name:n})=>s(`${a}/auth/register/email`,{email:e,password:o,name:n});export const login=async({email:e,password:o})=>s(`${a}/auth/login/email`,{email:e,password:o});export const logout=async()=>s(`${a}/auth/logout`,{});export const getSession=async()=>e(`${a}/auth/session`);export const forgotPassword=async({email:e})=>s(`${a}/forgot-password`,{email:e});export const resetPassword=async({token:e,password:o,logoutAll:n=!1})=>s(`${a}/auth/reset-password`,{token:e,newPassword:o,logoutAll:n});export const changePassword=async({currentPassword:e,newPassword:o,logoutAll:n})=>s(`${a}/auth/change-password`,{currentPassword:e,newPassword:o,logoutAll:n});export const verifyEmail=async({token:e})=>s(`${a}/auth/verify-email`,{token:e});export const currentUserHasPermission=async({permission:s})=>e(`${a}/user/current/permissions`,{permission:s});export const currentUserHasAllPermissions=async({permissions:s})=>e(`${a}/user/current/permissions/all`,{permissions:s});export const currentUserHasSomePermissions=async({permissions:s})=>e(`${a}/user/current/permissions/some`,{permissions:s});export const getAllCurrentUserPermissions=async()=>e(`${a}/user/current/permissions/list`);export const userHasPermission=async({userid:s,permission:o})=>e(`${a}/user/${s}/permissions`,{permission:o});export const userHasAllPermissions=async({userid:s,permissions:o})=>e(`${a}/user/${s}/permissions/all`,{permissions:o});export const userHasSomePermissions=async({userid:s,permissions:o})=>e(`${a}/user/${s}/permissions/some`,{permissions:o});export const getAllUserPermissions=async({userid:s})=>e(`${a}/user/${s}/permissions/list`);export const getUsers=async({limit:s,offset:o}={})=>e(`${a}/user`,{limit:s,offset:o});export const searchUsers=async({q:s,limit:o,offset:n,inGroup:t,notInGroup:r}={})=>e(`${a}/user/search`,{q:s,limit:o,offset:n,inGroup:t,notInGroup:r});export const createUser=async({name:e,email:o,password:n,emailVerified:t})=>s(`${a}/user/create`,{name:e,email:o,password:n,emailVerified:t});export const deleteUsers=async e=>t(`${a}/user`,{ids:e});export const updateUser=async({id:e,name:s,email:o,emailVerified:t,createdAt:r})=>n(`${a}/user`,{id:e,name:s,email:o,emailVerified:t,createdAt:r});export const getUser=async s=>e(`${a}/user/${s}`);export const getUserSessions=async(s,{limit:o,offset:n}={})=>e(`${a}/user/${s}/sessions`,{limit:o,offset:n});export const deleteUserSession=async(e,s)=>t(`${a}/user/${e}/sessions`,{sessionToken:s});export const deleteExpiredUserSessions=async e=>t(`${a}/user/${e}/sessions/expired`);export const getUserGroups=async(s,{limit:o,offset:n}={})=>e(`${a}/user/${s}/groups`,{limit:o,offset:n});export const addUserToGroup=async(e,o)=>s(`${a}/user/${e}/groups`,{groupName:o});export const removeUserFromGroup=async(e,s)=>t(`${a}/user/${e}/groups`,{groupName:s});export const listGroups=async({limit:s,offset:o,owner:n}={})=>e(`${a}/groups`,{limit:s,offset:o,owner:n});export const createGroup=async({name:e,description:o})=>s(`${a}/groups`,{name:e,description:o});export const updateGroup=async({name:e,newName:s,description:o})=>n(`${a}/groups`,{name:e,newName:s,description:o});export const deleteGroups=async e=>t(`${a}/groups`,{names:e});export const getGroup=async s=>e(`${a}/groups/${encodeURIComponent(s)}`);export const getGroupMembers=async(s,{limit:o,offset:n}={})=>e(`${a}/groups/${encodeURIComponent(s)}/members`,{limit:o,offset:n});export const addMemberToGroup=async(e,o)=>s(`${a}/groups/${encodeURIComponent(e)}/members`,{userId:o});export const removeMemberFromGroup=async(e,s)=>t(`${a}/groups/${encodeURIComponent(e)}/members`,{userId:s});export const getGroupPermissions=async s=>e(`${a}/groups/${encodeURIComponent(s)}/permissions`);export const addPermissionToGroup=async(e,o)=>s(`${a}/groups/${encodeURIComponent(e)}/permissions`,{permissionName:o});export const removePermissionFromGroup=async(e,s)=>t(`${a}/groups/${encodeURIComponent(e)}/permissions`,{permissionName:s});export const listPermissions=async({limit:s,offset:o,owner:n}={})=>e(`${a}/permissions`,{limit:s,offset:o,owner:n});export const createPermissions=async e=>s(`${a}/permissions`,{permissions:e});export const updatePermission=async({name:e,description:s})=>n(`${a}/permissions`,{name:e,description:s});export const deletePermissions=async e=>t(`${a}/permissions`,{names:e});export const getSetting=async(s,o)=>e(`${a}/settings/${encodeURIComponent(s)}/${encodeURIComponent(o)}`);export const listSettings=async({owner:s,limit:o,offset:n}={})=>e(`${a}/settings/${encodeURIComponent(s)}`,{limit:o,offset:n});export const setSetting=async(e,o,n)=>s(`${a}/settings/${encodeURIComponent(e)}/${encodeURIComponent(o)}`,n);export const deleteSetting=async(e,s)=>t(`${a}/settings/${encodeURIComponent(e)}/${encodeURIComponent(s)}`);export const listPages=async({owner:s,showHidden:o,offset:n,limit:t}={})=>e(`${a}/pages`,{owner:s,showHidden:o,offset:n,limit:t});export const rescanPages=async()=>s(`${a}/pages/rescan`,{});export const listTemplates=async()=>e(`${a}/templates`);export const listDirectories=async()=>e(`${a}/pages/directories`);export const getPage=async s=>e(`${a}/pages/file`,{file:s});export const createPage=async({directory:e,name:o,template:n})=>s(`${a}/pages`,{directory:e,name:o,template:n});export const updatePage=async({file:e,name:s,title:n,description:t,author:r,template:i,contents:c,extraMetadata:l})=>o(`${a}/pages/file`,{file:e,name:s,title:n,description:t,author:r,template:i,contents:c,extraMetadata:l});export const deletePages=async e=>t(`${a}/pages`,{files:e});export const disablePage=async e=>o(`${a}/pages/disable`,{file:e});export const enablePage=async e=>o(`${a}/pages/enable`,{file:e});export const movePage=async({file:e,newFile:s})=>n(`${a}/pages/file`,{file:e,newFile:s});export const searchPagesByMetadata=async s=>e(`${a}/pages/search`,{query:JSON.stringify(s)});export const setPageLocked=async({file:e,locked:s})=>o(`${a}/pages/lock`,{file:e,locked:s});export const getTemplate=async s=>e(`${a}/templates/file`,{file:s});export const createTemplate=async({directory:e,name:o,copyFrom:n})=>s(`${a}/templates`,{directory:e,name:o,copyFrom:n});export const updateTemplate=async({file:e,name:s,author:n,markup:t})=>o(`${a}/templates/file`,{file:e,name:s,author:n,markup:t});export const deleteTemplates=async e=>t(`${a}/templates`,{files:e});export const disableTemplate=async e=>o(`${a}/templates/disable`,{file:e});export const enableTemplate=async e=>o(`${a}/templates/enable`,{file:e});export const moveTemplate=async({file:e,newFile:s})=>n(`${a}/templates/file`,{file:e,newFile:s});export const setTemplateLocked=async({file:e,locked:s})=>o(`${a}/templates/lock`,{file:e,locked:s});export const listFragments=async()=>e(`${a}/fragments`);export const getFragment=async s=>e(`${a}/fragments/file`,{file:s});export const createFragment=async({directory:e,name:o})=>s(`${a}/fragments`,{directory:e,name:o});export const updateFragment=async({file:e,author:s,markup:n})=>o(`${a}/fragments/file`,{file:e,author:s,markup:n});export const deleteFragments=async e=>t(`${a}/fragments`,{files:e});export const moveFragment=async({file:e,newFile:s})=>n(`${a}/fragments/file`,{file:e,newFile:s});export const disableFragment=async e=>o(`${a}/fragments/disable`,{file:e});export const enableFragment=async e=>o(`${a}/fragments/enable`,{file:e});export const setFragmentLocked=async({file:e,locked:s})=>o(`${a}/fragments/lock`,{file:e,locked:s});export const listGlobalContent=async()=>e(`${a}/globals`);export const getGlobalContent=async s=>e(`${a}/globals/entry`,{id:s});export const createGlobalContent=async({name:e,location:o,priority:n})=>s(`${a}/globals`,{name:e,location:o,priority:n});export const updateGlobalContent=async({id:e,name:s,location:n,priority:t,markup:r})=>o(`${a}/globals/entry`,{id:e,name:s,location:n,priority:t,markup:r});export const deleteGlobalContent=async e=>t(`${a}/globals`,{ids:e});export const disableGlobalContent=async e=>o(`${a}/globals/disable`,{id:e});export const enableGlobalContent=async e=>o(`${a}/globals/enable`,{id:e});export const setGlobalContentLocked=async({id:e,locked:s})=>o(`${a}/globals/lock`,{id:e,locked:s});export const listExtensions=async({limit:s,offset:o}={})=>e(`${a}/extensions`,{limit:s,offset:o});export const listAvailableExtensions=async()=>e(`${a}/extensions/available`);export const listKnownExtensions=async({search:s,sort:o,limit:n,offset:t}={})=>e(`${a}/extensions/known`,{search:s,sort:o,limit:n,offset:t});export const getKnownExtension=async s=>e(`${a}/extensions/known`,{name:s});export const rateExtension=async(e,s)=>o(`${a}/extensions/rating`,{name:e,rating:s});export const getDashboardWidgets=async()=>e(`${a}/dashboard/widgets`);export const getNotifications=async({unreadOnly:s=!1,limit:o,offset:n}={})=>e(`${a}/notifications`,{unreadOnly:s,limit:o,offset:n});export const getUnreadNotificationCount=async()=>e(`${a}/notifications/count`);export const markNotificationRead=async e=>s(`${a}/notifications/${encodeURIComponent(e)}/read`,{});export const markNotificationHandled=async e=>s(`${a}/notifications/${encodeURIComponent(e)}/handled`,{});export const markAllNotificationsRead=async()=>s(`${a}/notifications/read-all`,{});export const dismissNotification=async e=>t(`${a}/notifications/${encodeURIComponent(e)}`);export const listRealtimeConnections=async()=>e(`${a}/realtime/connections`);export const installExtension=async(e,{withDependencies:o=!1}={})=>s(`${a}/extensions`,{name:e,withDependencies:o});export const uninstallExtension=async(e,s=!1,{cascade:o=!1}={})=>t(`${a}/extensions`,{name:e,purgeData:s,cascade:o});export const enableExtension=async(e,{cascade:o=!1}={})=>s(`${a}/extensions/${encodeURIComponent(e)}/enable`,{cascade:o});export const getExtensionRequirements=async s=>e(`${a}/extensions/${encodeURIComponent(s)}/requirements`);export const disableExtension=async(e,{cascade:o=!1}={})=>s(`${a}/extensions/${encodeURIComponent(e)}/disable`,{cascade:o});export const getExtensionDependents=async(s,{includeDisabled:o=!1}={})=>e(`${a}/extensions/${encodeURIComponent(s)}/dependents`,{includeDisabled:o?"true":void 0});export const listAdminGlobalContent=async()=>e(`${a}/admin-globals`);export const getAdminGlobalContent=async s=>e(`${a}/admin-globals/${encodeURIComponent(s)}`);export const createAdminGlobalContent=async({name:e,location:o,priority:n,owner:t,markup:r})=>s(`${a}/admin-globals`,{name:e,location:o,priority:n,owner:t,markup:r});export const updateAdminGlobalContent=async(e,{name:s,location:n,priority:t,markup:r})=>o(`${a}/admin-globals/${encodeURIComponent(e)}`,{name:s,location:n,priority:t,markup:r});export const deleteAdminGlobalContent=async e=>t(`${a}/admin-globals`,{ids:e});export const enableAdminGlobalContent=async e=>o(`${a}/admin-globals/${encodeURIComponent(e)}/enable`,{});export const disableAdminGlobalContent=async e=>o(`${a}/admin-globals/${encodeURIComponent(e)}/disable`,{});
|
|
1
|
+
import{get as e,post as s,put as n,patch as o,del as t}from"./fetch.js";const a="/kempo/api";export const register=async({email:e,password:n,name:o})=>s(`${a}/auth/register/email`,{email:e,password:n,name:o});export const login=async({email:e,password:n})=>s(`${a}/auth/login/email`,{email:e,password:n});export const logout=async()=>s(`${a}/auth/logout`,{});export const getSession=async()=>e(`${a}/auth/session`);export const forgotPassword=async({email:e})=>s(`${a}/forgot-password`,{email:e});export const resetPassword=async({token:e,password:n,logoutAll:o=!1})=>s(`${a}/auth/reset-password`,{token:e,newPassword:n,logoutAll:o});export const changePassword=async({currentPassword:e,newPassword:n,logoutAll:o})=>s(`${a}/auth/change-password`,{currentPassword:e,newPassword:n,logoutAll:o});export const verifyEmail=async({token:e})=>s(`${a}/auth/verify-email`,{token:e});export const currentUserHasPermission=async({permission:s})=>e(`${a}/user/current/permissions`,{permission:s});export const currentUserHasAllPermissions=async({permissions:s})=>e(`${a}/user/current/permissions/all`,{permissions:s});export const currentUserHasSomePermissions=async({permissions:s})=>e(`${a}/user/current/permissions/some`,{permissions:s});export const getAllCurrentUserPermissions=async()=>e(`${a}/user/current/permissions/list`);export const userHasPermission=async({userid:s,permission:n})=>e(`${a}/user/${s}/permissions`,{permission:n});export const userHasAllPermissions=async({userid:s,permissions:n})=>e(`${a}/user/${s}/permissions/all`,{permissions:n});export const userHasSomePermissions=async({userid:s,permissions:n})=>e(`${a}/user/${s}/permissions/some`,{permissions:n});export const getAllUserPermissions=async({userid:s})=>e(`${a}/user/${s}/permissions/list`);export const getUsers=async({limit:s,offset:n}={})=>e(`${a}/user`,{limit:s,offset:n});export const searchUsers=async({q:s,limit:n,offset:o,inGroup:t,notInGroup:i}={})=>e(`${a}/user/search`,{q:s,limit:n,offset:o,inGroup:t,notInGroup:i});export const createUser=async({name:e,email:n,password:o,emailVerified:t})=>s(`${a}/user/create`,{name:e,email:n,password:o,emailVerified:t});export const deleteUsers=async e=>t(`${a}/user`,{ids:e});export const updateUser=async({id:e,name:s,email:n,emailVerified:t,createdAt:i})=>o(`${a}/user`,{id:e,name:s,email:n,emailVerified:t,createdAt:i});export const getUser=async s=>e(`${a}/user/${s}`);export const getUserSessions=async(s,{limit:n,offset:o}={})=>e(`${a}/user/${s}/sessions`,{limit:n,offset:o});export const deleteUserSession=async(e,s)=>t(`${a}/user/${e}/sessions`,{sessionToken:s});export const deleteExpiredUserSessions=async e=>t(`${a}/user/${e}/sessions/expired`);export const getUserGroups=async(s,{limit:n,offset:o}={})=>e(`${a}/user/${s}/groups`,{limit:n,offset:o});export const addUserToGroup=async(e,n)=>s(`${a}/user/${e}/groups`,{groupName:n});export const removeUserFromGroup=async(e,s)=>t(`${a}/user/${e}/groups`,{groupName:s});export const listGroups=async({limit:s,offset:n,owner:o}={})=>e(`${a}/groups`,{limit:s,offset:n,owner:o});export const createGroup=async({name:e,description:n})=>s(`${a}/groups`,{name:e,description:n});export const updateGroup=async({name:e,newName:s,description:n})=>o(`${a}/groups`,{name:e,newName:s,description:n});export const deleteGroups=async e=>t(`${a}/groups`,{names:e});export const getGroup=async s=>e(`${a}/groups/${encodeURIComponent(s)}`);export const getGroupMembers=async(s,{limit:n,offset:o}={})=>e(`${a}/groups/${encodeURIComponent(s)}/members`,{limit:n,offset:o});export const addMemberToGroup=async(e,n)=>s(`${a}/groups/${encodeURIComponent(e)}/members`,{userId:n});export const removeMemberFromGroup=async(e,s)=>t(`${a}/groups/${encodeURIComponent(e)}/members`,{userId:s});export const getGroupPermissions=async s=>e(`${a}/groups/${encodeURIComponent(s)}/permissions`);export const addPermissionToGroup=async(e,n)=>s(`${a}/groups/${encodeURIComponent(e)}/permissions`,{permissionName:n});export const removePermissionFromGroup=async(e,s)=>t(`${a}/groups/${encodeURIComponent(e)}/permissions`,{permissionName:s});export const listPermissions=async({limit:s,offset:n,owner:o}={})=>e(`${a}/permissions`,{limit:s,offset:n,owner:o});export const createPermissions=async e=>s(`${a}/permissions`,{permissions:e});export const updatePermission=async({name:e,description:s})=>o(`${a}/permissions`,{name:e,description:s});export const deletePermissions=async e=>t(`${a}/permissions`,{names:e});export const getSetting=async(s,n)=>e(`${a}/settings/${encodeURIComponent(s)}/${encodeURIComponent(n)}`);export const listSettings=async({owner:s,limit:n,offset:o}={})=>e(`${a}/settings/${encodeURIComponent(s)}`,{limit:n,offset:o});export const setSetting=async(e,n,o)=>s(`${a}/settings/${encodeURIComponent(e)}/${encodeURIComponent(n)}`,o);export const deleteSetting=async(e,s)=>t(`${a}/settings/${encodeURIComponent(e)}/${encodeURIComponent(s)}`);export const listPages=async({owner:s,showHidden:n,offset:o,limit:t}={})=>e(`${a}/pages`,{owner:s,showHidden:n,offset:o,limit:t});export const rescanPages=async()=>s(`${a}/pages/rescan`,{});export const listTemplates=async()=>e(`${a}/templates`);export const listDirectories=async()=>e(`${a}/pages/directories`);export const getPage=async s=>e(`${a}/pages/file`,{file:s});export const createPage=async({directory:e,name:n,template:o})=>s(`${a}/pages`,{directory:e,name:n,template:o});export const updatePage=async({file:e,name:s,title:o,description:t,author:i,template:r,contents:c,extraMetadata:l})=>n(`${a}/pages/file`,{file:e,name:s,title:o,description:t,author:i,template:r,contents:c,extraMetadata:l});export const deletePages=async e=>t(`${a}/pages`,{files:e});export const disablePage=async e=>n(`${a}/pages/disable`,{file:e});export const enablePage=async e=>n(`${a}/pages/enable`,{file:e});export const movePage=async({file:e,newFile:s})=>o(`${a}/pages/file`,{file:e,newFile:s});export const searchPagesByMetadata=async s=>e(`${a}/pages/search`,{query:JSON.stringify(s)});export const setPageLocked=async({file:e,locked:s})=>n(`${a}/pages/lock`,{file:e,locked:s});export const getTemplate=async s=>e(`${a}/templates/file`,{file:s});export const createTemplate=async({directory:e,name:n,copyFrom:o})=>s(`${a}/templates`,{directory:e,name:n,copyFrom:o});export const updateTemplate=async({file:e,name:s,author:o,markup:t})=>n(`${a}/templates/file`,{file:e,name:s,author:o,markup:t});export const deleteTemplates=async e=>t(`${a}/templates`,{files:e});export const disableTemplate=async e=>n(`${a}/templates/disable`,{file:e});export const enableTemplate=async e=>n(`${a}/templates/enable`,{file:e});export const moveTemplate=async({file:e,newFile:s})=>o(`${a}/templates/file`,{file:e,newFile:s});export const setTemplateLocked=async({file:e,locked:s})=>n(`${a}/templates/lock`,{file:e,locked:s});export const listFragments=async()=>e(`${a}/fragments`);export const getFragment=async s=>e(`${a}/fragments/file`,{file:s});export const createFragment=async({directory:e,name:n})=>s(`${a}/fragments`,{directory:e,name:n});export const updateFragment=async({file:e,author:s,markup:o})=>n(`${a}/fragments/file`,{file:e,author:s,markup:o});export const deleteFragments=async e=>t(`${a}/fragments`,{files:e});export const moveFragment=async({file:e,newFile:s})=>o(`${a}/fragments/file`,{file:e,newFile:s});export const disableFragment=async e=>n(`${a}/fragments/disable`,{file:e});export const enableFragment=async e=>n(`${a}/fragments/enable`,{file:e});export const setFragmentLocked=async({file:e,locked:s})=>n(`${a}/fragments/lock`,{file:e,locked:s});export const listGlobalContent=async()=>e(`${a}/globals`);export const getGlobalContent=async s=>e(`${a}/globals/entry`,{id:s});export const createGlobalContent=async({name:e,location:n,priority:o})=>s(`${a}/globals`,{name:e,location:n,priority:o});export const updateGlobalContent=async({id:e,name:s,location:o,priority:t,markup:i})=>n(`${a}/globals/entry`,{id:e,name:s,location:o,priority:t,markup:i});export const deleteGlobalContent=async e=>t(`${a}/globals`,{ids:e});export const disableGlobalContent=async e=>n(`${a}/globals/disable`,{id:e});export const enableGlobalContent=async e=>n(`${a}/globals/enable`,{id:e});export const setGlobalContentLocked=async({id:e,locked:s})=>n(`${a}/globals/lock`,{id:e,locked:s});export const listMenus=async()=>e(`${a}/menus`);export const saveMenu=async({id:e,name:n})=>s(`${a}/menus`,{id:e,name:n});export const deleteMenu=async e=>t(`${a}/menus`,{id:e});export const assignMenuLocation=async({location:e,menuId:s})=>n(`${a}/menus/location`,{location:e,menuId:s});export const saveMenuItem=async({id:e,menuId:n,location:o,navItem:t,label:i,href:r,icon:c,newTab:l})=>s(`${a}/menus/items`,{id:e,menuId:n,location:o,navItem:t,label:i,href:r,icon:c,newTab:l});export const deleteMenuItems=async e=>t(`${a}/menus/items`,{ids:e});export const setMenuItemEnabled=async({id:e,enabled:s})=>n(`${a}/menus/items/enabled`,{id:e,enabled:s});export const reorderMenuItems=async({menuId:e,ids:s})=>n(`${a}/menus/items/order`,{menuId:e,ids:s});export const adoptMenuItem=async({id:e,menuId:s,menuName:o})=>n(`${a}/menus/adopt`,{id:e,menuId:s,menuName:o});export const listExtensions=async({limit:s,offset:n}={})=>e(`${a}/extensions`,{limit:s,offset:n});export const listAvailableExtensions=async()=>e(`${a}/extensions/available`);export const listKnownExtensions=async({search:s,sort:n,limit:o,offset:t}={})=>e(`${a}/extensions/known`,{search:s,sort:n,limit:o,offset:t});export const getKnownExtension=async s=>e(`${a}/extensions/known`,{name:s});export const rateExtension=async(e,s)=>n(`${a}/extensions/rating`,{name:e,rating:s});export const getDashboardWidgets=async()=>e(`${a}/dashboard/widgets`);export const getNotifications=async({unreadOnly:s=!1,limit:n,offset:o}={})=>e(`${a}/notifications`,{unreadOnly:s,limit:n,offset:o});export const getUnreadNotificationCount=async()=>e(`${a}/notifications/count`);export const markNotificationRead=async e=>s(`${a}/notifications/${encodeURIComponent(e)}/read`,{});export const markNotificationHandled=async e=>s(`${a}/notifications/${encodeURIComponent(e)}/handled`,{});export const markAllNotificationsRead=async()=>s(`${a}/notifications/read-all`,{});export const dismissNotification=async e=>t(`${a}/notifications/${encodeURIComponent(e)}`);export const listRealtimeConnections=async()=>e(`${a}/realtime/connections`);export const installExtension=async(e,{withDependencies:n=!1}={})=>s(`${a}/extensions`,{name:e,withDependencies:n});export const uninstallExtension=async(e,s=!1,{cascade:n=!1}={})=>t(`${a}/extensions`,{name:e,purgeData:s,cascade:n});export const enableExtension=async(e,{cascade:n=!1}={})=>s(`${a}/extensions/${encodeURIComponent(e)}/enable`,{cascade:n});export const getExtensionRequirements=async s=>e(`${a}/extensions/${encodeURIComponent(s)}/requirements`);export const disableExtension=async(e,{cascade:n=!1}={})=>s(`${a}/extensions/${encodeURIComponent(e)}/disable`,{cascade:n});export const getExtensionDependents=async(s,{includeDisabled:n=!1}={})=>e(`${a}/extensions/${encodeURIComponent(s)}/dependents`,{includeDisabled:n?"true":void 0});export const listAdminGlobalContent=async()=>e(`${a}/admin-globals`);export const getAdminGlobalContent=async s=>e(`${a}/admin-globals/${encodeURIComponent(s)}`);export const createAdminGlobalContent=async({name:e,location:n,priority:o,owner:t,markup:i})=>s(`${a}/admin-globals`,{name:e,location:n,priority:o,owner:t,markup:i});export const updateAdminGlobalContent=async(e,{name:s,location:o,priority:t,markup:i})=>n(`${a}/admin-globals/${encodeURIComponent(e)}`,{name:s,location:o,priority:t,markup:i});export const deleteAdminGlobalContent=async e=>t(`${a}/admin-globals`,{ids:e});export const enableAdminGlobalContent=async e=>n(`${a}/admin-globals/${encodeURIComponent(e)}/enable`,{});export const disableAdminGlobalContent=async e=>n(`${a}/admin-globals/${encodeURIComponent(e)}/disable`,{});
|
|
2
2
|
//# sourceMappingURL=C:\Users\dusti\dev\kempo\dist\kempo\sdk.js.map
|
package/dist/kempo/sdk.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"src\\kempo\\sdk.js","names":["get","post","put","patch","del","API_BASE","register","async","email","password","name","login","logout","getSession","forgotPassword","resetPassword","token","logoutAll","newPassword","changePassword","currentPassword","verifyEmail","currentUserHasPermission","permission","currentUserHasAllPermissions","permissions","currentUserHasSomePermissions","getAllCurrentUserPermissions","userHasPermission","userid","userHasAllPermissions","userHasSomePermissions","getAllUserPermissions","getUsers","limit","offset","searchUsers","q","inGroup","notInGroup","createUser","emailVerified","deleteUsers","ids","updateUser","id","createdAt","getUser","getUserSessions","deleteUserSession","sessionToken","deleteExpiredUserSessions","getUserGroups","addUserToGroup","groupName","removeUserFromGroup","listGroups","owner","createGroup","description","updateGroup","newName","deleteGroups","names","getGroup","encodeURIComponent","getGroupMembers","addMemberToGroup","userId","removeMemberFromGroup","getGroupPermissions","addPermissionToGroup","permissionName","removePermissionFromGroup","listPermissions","createPermissions","updatePermission","deletePermissions","getSetting","listSettings","setSetting","data","deleteSetting","listPages","showHidden","rescanPages","listTemplates","listDirectories","getPage","file","createPage","directory","template","updatePage","title","author","contents","extraMetadata","deletePages","files","disablePage","enablePage","movePage","newFile","searchPagesByMetadata","query","JSON","stringify","setPageLocked","locked","getTemplate","createTemplate","copyFrom","updateTemplate","markup","deleteTemplates","disableTemplate","enableTemplate","moveTemplate","setTemplateLocked","listFragments","getFragment","createFragment","updateFragment","deleteFragments","moveFragment","disableFragment","enableFragment","setFragmentLocked","listGlobalContent","getGlobalContent","createGlobalContent","location","priority","updateGlobalContent","deleteGlobalContent","disableGlobalContent","enableGlobalContent","setGlobalContentLocked","listExtensions","listAvailableExtensions","listKnownExtensions","search","sort","getKnownExtension","rateExtension","rating","getDashboardWidgets","getNotifications","unreadOnly","getUnreadNotificationCount","markNotificationRead","markNotificationHandled","markAllNotificationsRead","dismissNotification","listRealtimeConnections","installExtension","withDependencies","uninstallExtension","purgeData","cascade","enableExtension","getExtensionRequirements","disableExtension","getExtensionDependents","includeDisabled","undefined","listAdminGlobalContent","getAdminGlobalContent","createAdminGlobalContent","updateAdminGlobalContent","deleteAdminGlobalContent","enableAdminGlobalContent","disableAdminGlobalContent"],"sources":["0"],"sourcesContent":["import { get, post, put, patch, del } from './fetch.js';\nconst API_BASE = '/kempo/api';\n\nexport const register = async ({ email, password, name }) =>\n post(`${API_BASE}/auth/register/email`, { email, password, name });\n\nexport const login = async ({ email, password }) =>\n post(`${API_BASE}/auth/login/email`, { email, password });\n\nexport const logout = async () => post(`${API_BASE}/auth/logout`, {});\n\nexport const getSession = async () => get(`${API_BASE}/auth/session`);\n\nexport const forgotPassword = async ({ email }) =>\n post(`${API_BASE}/forgot-password`, { email });\n\nexport const resetPassword = async ({ token, password, logoutAll = false }) =>\n post(`${API_BASE}/auth/reset-password`, { token, newPassword: password, logoutAll });\n \nexport const changePassword = async ({ currentPassword, newPassword, logoutAll }) => \n post(`${API_BASE}/auth/change-password`, { currentPassword, newPassword, logoutAll });\n\nexport const verifyEmail = async ({ token }) =>\n post(`${API_BASE}/auth/verify-email`, { token });\n\nexport const currentUserHasPermission = async ({ permission }) =>\n get(`${API_BASE}/user/current/permissions`, { permission });\n\nexport const currentUserHasAllPermissions = async ({ permissions }) =>\n get(`${API_BASE}/user/current/permissions/all`, { permissions });\n\nexport const currentUserHasSomePermissions = async ({ permissions }) =>\n get(`${API_BASE}/user/current/permissions/some`, { permissions });\n\nexport const getAllCurrentUserPermissions = async () =>\n get(`${API_BASE}/user/current/permissions/list`);\n\nexport const userHasPermission = async ({ userid, permission }) =>\n get(`${API_BASE}/user/${userid}/permissions`, { permission });\n\nexport const userHasAllPermissions = async ({ userid, permissions }) =>\n get(`${API_BASE}/user/${userid}/permissions/all`, { permissions });\n\nexport const userHasSomePermissions = async ({ userid, permissions }) =>\n get(`${API_BASE}/user/${userid}/permissions/some`, { permissions });\n\nexport const getAllUserPermissions = async ({ userid }) =>\n get(`${API_BASE}/user/${userid}/permissions/list`);\n\nexport const getUsers = async ({ limit, offset } = {}) =>\n get(`${API_BASE}/user`, { limit, offset });\n\nexport const searchUsers = async ({ q, limit, offset, inGroup, notInGroup } = {}) =>\n get(`${API_BASE}/user/search`, { q, limit, offset, inGroup, notInGroup });\n\nexport const createUser = async ({ name, email, password, emailVerified }) =>\n post(`${API_BASE}/user/create`, { name, email, password, emailVerified });\n\nexport const deleteUsers = async (ids) =>\n del(`${API_BASE}/user`, { ids });\n\nexport const updateUser = async ({ id, name, email, emailVerified, createdAt }) =>\n patch(`${API_BASE}/user`, { id, name, email, emailVerified, createdAt });\n\nexport const getUser = async (userid) =>\n get(`${API_BASE}/user/${userid}`);\n\nexport const getUserSessions = async (userid, { limit, offset } = {}) =>\n get(`${API_BASE}/user/${userid}/sessions`, { limit, offset });\n\nexport const deleteUserSession = async (userid, sessionToken) =>\n del(`${API_BASE}/user/${userid}/sessions`, { sessionToken });\n\nexport const deleteExpiredUserSessions = async (userid) =>\n del(`${API_BASE}/user/${userid}/sessions/expired`);\n\nexport const getUserGroups = async (userid, { limit, offset } = {}) =>\n get(`${API_BASE}/user/${userid}/groups`, { limit, offset });\n\nexport const addUserToGroup = async (userid, groupName) =>\n post(`${API_BASE}/user/${userid}/groups`, { groupName });\n\nexport const removeUserFromGroup = async (userid, groupName) =>\n del(`${API_BASE}/user/${userid}/groups`, { groupName });\n\nexport const listGroups = async ({ limit, offset, owner } = {}) =>\n get(`${API_BASE}/groups`, { limit, offset, owner });\n\nexport const createGroup = async ({ name, description }) =>\n post(`${API_BASE}/groups`, { name, description });\n\nexport const updateGroup = async ({ name, newName, description }) =>\n patch(`${API_BASE}/groups`, { name, newName, description });\n\nexport const deleteGroups = async (names) =>\n del(`${API_BASE}/groups`, { names });\n\nexport const getGroup = async (name) =>\n get(`${API_BASE}/groups/${encodeURIComponent(name)}`);\n\nexport const getGroupMembers = async (name, { limit, offset } = {}) =>\n get(`${API_BASE}/groups/${encodeURIComponent(name)}/members`, { limit, offset });\n\nexport const addMemberToGroup = async (name, userId) =>\n post(`${API_BASE}/groups/${encodeURIComponent(name)}/members`, { userId });\n\nexport const removeMemberFromGroup = async (name, userId) =>\n del(`${API_BASE}/groups/${encodeURIComponent(name)}/members`, { userId });\n\nexport const getGroupPermissions = async (name) =>\n get(`${API_BASE}/groups/${encodeURIComponent(name)}/permissions`);\n\nexport const addPermissionToGroup = async (name, permissionName) =>\n post(`${API_BASE}/groups/${encodeURIComponent(name)}/permissions`, { permissionName });\n\nexport const removePermissionFromGroup = async (name, permissionName) =>\n del(`${API_BASE}/groups/${encodeURIComponent(name)}/permissions`, { permissionName });\n\nexport const listPermissions = async ({ limit, offset, owner } = {}) =>\n get(`${API_BASE}/permissions`, { limit, offset, owner });\n\nexport const createPermissions = async (permissions) =>\n post(`${API_BASE}/permissions`, { permissions });\n\nexport const updatePermission = async ({ name, description }) =>\n patch(`${API_BASE}/permissions`, { name, description });\n\nexport const deletePermissions = async (names) =>\n del(`${API_BASE}/permissions`, { names });\n\nexport const getSetting = async (owner, name) =>\n get(`${API_BASE}/settings/${encodeURIComponent(owner)}/${encodeURIComponent(name)}`);\n\nexport const listSettings = async ({ owner, limit, offset } = {}) =>\n get(`${API_BASE}/settings/${encodeURIComponent(owner)}`, { limit, offset });\n\nexport const setSetting = async (owner, name, data) =>\n post(`${API_BASE}/settings/${encodeURIComponent(owner)}/${encodeURIComponent(name)}`, data);\n\nexport const deleteSetting = async (owner, name) =>\n del(`${API_BASE}/settings/${encodeURIComponent(owner)}/${encodeURIComponent(name)}`);\n\n/*\n Pages\n*/\n\nexport const listPages = async ({ owner, showHidden, offset, limit } = {}) =>\n get(`${API_BASE}/pages`, { owner, showHidden, offset, limit });\n\nexport const rescanPages = async () =>\n post(`${API_BASE}/pages/rescan`, {});\n\nexport const listTemplates = async () =>\n get(`${API_BASE}/templates`);\n\nexport const listDirectories = async () =>\n get(`${API_BASE}/pages/directories`);\n\nexport const getPage = async (file) =>\n get(`${API_BASE}/pages/file`, { file });\n\nexport const createPage = async ({ directory, name, template }) =>\n post(`${API_BASE}/pages`, { directory, name, template });\n\nexport const updatePage = async ({ file, name, title, description, author, template, contents, extraMetadata }) =>\n put(`${API_BASE}/pages/file`, { file, name, title, description, author, template, contents, extraMetadata });\n\nexport const deletePages = async (files) =>\n del(`${API_BASE}/pages`, { files });\n\nexport const disablePage = async (file) =>\n put(`${API_BASE}/pages/disable`, { file });\n\nexport const enablePage = async (file) =>\n put(`${API_BASE}/pages/enable`, { file });\n\nexport const movePage = async ({ file, newFile }) =>\n patch(`${API_BASE}/pages/file`, { file, newFile });\n\nexport const searchPagesByMetadata = async (query) =>\n get(`${API_BASE}/pages/search`, { query: JSON.stringify(query) });\n\nexport const setPageLocked = async ({ file, locked }) =>\n put(`${API_BASE}/pages/lock`, { file, locked });\n\n/*\n Templates\n*/\n\nexport const getTemplate = async (file) =>\n get(`${API_BASE}/templates/file`, { file });\n\nexport const createTemplate = async ({ directory, name, copyFrom }) =>\n post(`${API_BASE}/templates`, { directory, name, copyFrom });\n\nexport const updateTemplate = async ({ file, name, author, markup }) =>\n put(`${API_BASE}/templates/file`, { file, name, author, markup });\n\nexport const deleteTemplates = async (files) =>\n del(`${API_BASE}/templates`, { files });\n\nexport const disableTemplate = async (file) =>\n put(`${API_BASE}/templates/disable`, { file });\n\nexport const enableTemplate = async (file) =>\n put(`${API_BASE}/templates/enable`, { file });\n\nexport const moveTemplate = async ({ file, newFile }) =>\n patch(`${API_BASE}/templates/file`, { file, newFile });\n\nexport const setTemplateLocked = async ({ file, locked }) =>\n put(`${API_BASE}/templates/lock`, { file, locked });\n\n/*\n Fragments\n*/\n\nexport const listFragments = async () =>\n get(`${API_BASE}/fragments`);\n\nexport const getFragment = async (file) =>\n get(`${API_BASE}/fragments/file`, { file });\n\nexport const createFragment = async ({ directory, name }) =>\n post(`${API_BASE}/fragments`, { directory, name });\n\nexport const updateFragment = async ({ file, author, markup }) =>\n put(`${API_BASE}/fragments/file`, { file, author, markup });\n\nexport const deleteFragments = async (files) =>\n del(`${API_BASE}/fragments`, { files });\n\nexport const moveFragment = async ({ file, newFile }) =>\n patch(`${API_BASE}/fragments/file`, { file, newFile });\n\nexport const disableFragment = async (file) =>\n put(`${API_BASE}/fragments/disable`, { file });\n\nexport const enableFragment = async (file) =>\n put(`${API_BASE}/fragments/enable`, { file });\n\nexport const setFragmentLocked = async ({ file, locked }) =>\n put(`${API_BASE}/fragments/lock`, { file, locked });\n\n/*\n Global Content\n*/\n\nexport const listGlobalContent = async () =>\n get(`${API_BASE}/globals`);\n\nexport const getGlobalContent = async (id) =>\n get(`${API_BASE}/globals/entry`, { id });\n\nexport const createGlobalContent = async ({ name, location, priority }) =>\n post(`${API_BASE}/globals`, { name, location, priority });\n\nexport const updateGlobalContent = async ({ id, name, location, priority, markup }) =>\n put(`${API_BASE}/globals/entry`, { id, name, location, priority, markup });\n\nexport const deleteGlobalContent = async (ids) =>\n del(`${API_BASE}/globals`, { ids });\n\nexport const disableGlobalContent = async (id) =>\n put(`${API_BASE}/globals/disable`, { id });\n\nexport const enableGlobalContent = async (id) =>\n put(`${API_BASE}/globals/enable`, { id });\n\nexport const setGlobalContentLocked = async ({ id, locked }) =>\n put(`${API_BASE}/globals/lock`, { id, locked });\n\n/*\n Extensions\n*/\n\nexport const listExtensions = async ({ limit, offset } = {}) =>\n get(`${API_BASE}/extensions`, { limit, offset });\n\nexport const listAvailableExtensions = async () =>\n get(`${API_BASE}/extensions/available`);\n\nexport const listKnownExtensions = async ({ search, sort, limit, offset } = {}) =>\n get(`${API_BASE}/extensions/known`, { search, sort, limit, offset });\n\nexport const getKnownExtension = async (name) =>\n get(`${API_BASE}/extensions/known`, { name });\n\nexport const rateExtension = async (name, rating) =>\n put(`${API_BASE}/extensions/rating`, { name, rating });\n\n/*\n Dashboard\n*/\n\nexport const getDashboardWidgets = async () =>\n get(`${API_BASE}/dashboard/widgets`);\n\n/*\n Notifications\n*/\n\nexport const getNotifications = async ({ unreadOnly = false, limit, offset } = {}) =>\n get(`${API_BASE}/notifications`, { unreadOnly, limit, offset });\n\nexport const getUnreadNotificationCount = async () =>\n get(`${API_BASE}/notifications/count`);\n\nexport const markNotificationRead = async (id) =>\n post(`${API_BASE}/notifications/${encodeURIComponent(id)}/read`, {});\n\nexport const markNotificationHandled = async (id) =>\n post(`${API_BASE}/notifications/${encodeURIComponent(id)}/handled`, {});\n\nexport const markAllNotificationsRead = async () =>\n post(`${API_BASE}/notifications/read-all`, {});\n\nexport const dismissNotification = async (id) =>\n del(`${API_BASE}/notifications/${encodeURIComponent(id)}`);\n\nexport const listRealtimeConnections = async () =>\n get(`${API_BASE}/realtime/connections`);\n\nexport const installExtension = async (name, { withDependencies = false } = {}) =>\n post(`${API_BASE}/extensions`, { name, withDependencies });\n\nexport const uninstallExtension = async (name, purgeData = false, { cascade = false } = {}) =>\n del(`${API_BASE}/extensions`, { name, purgeData, cascade });\n\nexport const enableExtension = async (name, { cascade = false } = {}) =>\n post(`${API_BASE}/extensions/${encodeURIComponent(name)}/enable`, { cascade });\n\nexport const getExtensionRequirements = async (name) =>\n get(`${API_BASE}/extensions/${encodeURIComponent(name)}/requirements`);\n\nexport const disableExtension = async (name, { cascade = false } = {}) =>\n post(`${API_BASE}/extensions/${encodeURIComponent(name)}/disable`, { cascade });\n\nexport const getExtensionDependents = async (name, { includeDisabled = false } = {}) =>\n get(`${API_BASE}/extensions/${encodeURIComponent(name)}/dependents`, { includeDisabled: includeDisabled ? 'true' : undefined });\n\n/*\n Admin Global Content\n*/\n\nexport const listAdminGlobalContent = async () =>\n get(`${API_BASE}/admin-globals`);\n\nexport const getAdminGlobalContent = async (id) =>\n get(`${API_BASE}/admin-globals/${encodeURIComponent(id)}`);\n\nexport const createAdminGlobalContent = async ({ name, location, priority, owner, markup }) =>\n post(`${API_BASE}/admin-globals`, { name, location, priority, owner, markup });\n\nexport const updateAdminGlobalContent = async (id, { name, location, priority, markup }) =>\n put(`${API_BASE}/admin-globals/${encodeURIComponent(id)}`, { name, location, priority, markup });\n\nexport const deleteAdminGlobalContent = async (ids) =>\n del(`${API_BASE}/admin-globals`, { ids });\n\nexport const enableAdminGlobalContent = async (id) =>\n put(`${API_BASE}/admin-globals/${encodeURIComponent(id)}/enable`, {});\n\nexport const disableAdminGlobalContent = async (id) =>\n put(`${API_BASE}/admin-globals/${encodeURIComponent(id)}/disable`, {});\n\n"],"mappings":"cAASA,UAAKC,SAAMC,WAAKC,SAAOC,MAAW,aAC3C,MAAMC,EAAW,oBAEV,MAAMC,SAAWC,OAASC,QAAOC,WAAUC,UAChDT,EAAK,GAAGI,wBAAgC,CAAEG,QAAOC,WAAUC,gBAEtD,MAAMC,MAAQJ,OAASC,QAAOC,cACnCR,EAAK,GAAGI,qBAA6B,CAAEG,QAAOC,oBAEzC,MAAMG,OAASL,SAAYN,EAAK,GAAGI,gBAAwB,CAAC,UAE5D,MAAMQ,WAAaN,SAAYP,EAAI,GAAGK,yBAEtC,MAAMS,eAAiBP,OAASC,WACrCP,EAAK,GAAGI,oBAA4B,CAAEG,iBAEjC,MAAMO,cAAgBR,OAASS,QAAOP,WAAUQ,aAAY,KACjEhB,EAAK,GAAGI,wBAAgC,CAAEW,QAAOE,YAAaT,EAAUQ,qBAEnE,MAAME,eAAiBZ,OAASa,kBAAiBF,cAAaD,eACnEhB,EAAK,GAAGI,yBAAiC,CAAEe,kBAAiBF,cAAaD,qBAEpE,MAAMI,YAAcd,OAASS,WAClCf,EAAK,GAAGI,sBAA8B,CAAEW,iBAEnC,MAAMM,yBAA2Bf,OAASgB,gBAC/CvB,EAAI,GAAGK,6BAAqC,CAAEkB,sB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C,WAAU5E,QAAOyD,YAChFjH,EAAK,GAAGI,kBAA0B,CAAEK,OAAM0H,WAAUC,WAAU5E,QAAOyD,kBAEhE,MAAMwD,yBAA2BnK,MAAOsC,GAAMnC,OAAM0H,WAAUC,WAAUnB,YAC7EhH,EAAI,GAAGG,mBAA0B4D,mBAAmBpB,KAAO,CAAEnC,OAAM0H,WAAUC,WAAUnB,kBAElF,MAAMyD,yBAA2BpK,MAAOoC,GAC7CvC,EAAI,GAAGC,kBAA0B,CAAEsC,eAE9B,MAAMiI,yBAA2BrK,MAAOsC,GAC7C3C,EAAI,GAAGG,mBAA0B4D,mBAAmBpB,YAAc,CAAC,UAE9D,MAAMgI,0BAA4BtK,MAAOsC,GAC9C3C,EAAI,GAAGG,mBAA0B4D,mBAAmBpB,aAAe,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"src\\kempo\\sdk.js","names":["get","post","put","patch","del","API_BASE","register","async","email","password","name","login","logout","getSession","forgotPassword","resetPassword","token","logoutAll","newPassword","changePassword","currentPassword","verifyEmail","currentUserHasPermission","permission","currentUserHasAllPermissions","permissions","currentUserHasSomePermissions","getAllCurrentUserPermissions","userHasPermission","userid","userHasAllPermissions","userHasSomePermissions","getAllUserPermissions","getUsers","limit","offset","searchUsers","q","inGroup","notInGroup","createUser","emailVerified","deleteUsers","ids","updateUser","id","createdAt","getUser","getUserSessions","deleteUserSession","sessionToken","deleteExpiredUserSessions","getUserGroups","addUserToGroup","groupName","removeUserFromGroup","listGroups","owner","createGroup","description","updateGroup","newName","deleteGroups","names","getGroup","encodeURIComponent","getGroupMembers","addMemberToGroup","userId","removeMemberFromGroup","getGroupPermissions","addPermissionToGroup","permissionName","removePermissionFromGroup","listPermissions","createPermissions","updatePermission","deletePermissions","getSetting","listSettings","setSetting","data","deleteSetting","listPages","showHidden","rescanPages","listTemplates","listDirectories","getPage","file","createPage","directory","template","updatePage","title","author","contents","extraMetadata","deletePages","files","disablePage","enablePage","movePage","newFile","searchPagesByMetadata","query","JSON","stringify","setPageLocked","locked","getTemplate","createTemplate","copyFrom","updateTemplate","markup","deleteTemplates","disableTemplate","enableTemplate","moveTemplate","setTemplateLocked","listFragments","getFragment","createFragment","updateFragment","deleteFragments","moveFragment","disableFragment","enableFragment","setFragmentLocked","listGlobalContent","getGlobalContent","createGlobalContent","location","priority","updateGlobalContent","deleteGlobalContent","disableGlobalContent","enableGlobalContent","setGlobalContentLocked","listMenus","saveMenu","deleteMenu","assignMenuLocation","menuId","saveMenuItem","navItem","label","href","icon","newTab","deleteMenuItems","setMenuItemEnabled","enabled","reorderMenuItems","adoptMenuItem","menuName","listExtensions","listAvailableExtensions","listKnownExtensions","search","sort","getKnownExtension","rateExtension","rating","getDashboardWidgets","getNotifications","unreadOnly","getUnreadNotificationCount","markNotificationRead","markNotificationHandled","markAllNotificationsRead","dismissNotification","listRealtimeConnections","installExtension","withDependencies","uninstallExtension","purgeData","cascade","enableExtension","getExtensionRequirements","disableExtension","getExtensionDependents","includeDisabled","undefined","listAdminGlobalContent","getAdminGlobalContent","createAdminGlobalContent","updateAdminGlobalContent","deleteAdminGlobalContent","enableAdminGlobalContent","disableAdminGlobalContent"],"sources":["0"],"sourcesContent":["import { get, post, put, patch, del } from './fetch.js';\nconst API_BASE = '/kempo/api';\n\nexport const register = async ({ email, password, name }) =>\n post(`${API_BASE}/auth/register/email`, { email, password, name });\n\nexport const login = async ({ email, password }) =>\n post(`${API_BASE}/auth/login/email`, { email, password });\n\nexport const logout = async () => post(`${API_BASE}/auth/logout`, {});\n\nexport const getSession = async () => get(`${API_BASE}/auth/session`);\n\nexport const forgotPassword = async ({ email }) =>\n post(`${API_BASE}/forgot-password`, { email });\n\nexport const resetPassword = async ({ token, password, logoutAll = false }) =>\n post(`${API_BASE}/auth/reset-password`, { token, newPassword: password, logoutAll });\n \nexport const changePassword = async ({ currentPassword, newPassword, logoutAll }) => \n post(`${API_BASE}/auth/change-password`, { currentPassword, newPassword, logoutAll });\n\nexport const verifyEmail = async ({ token }) =>\n post(`${API_BASE}/auth/verify-email`, { token });\n\nexport const currentUserHasPermission = async ({ permission }) =>\n get(`${API_BASE}/user/current/permissions`, { permission });\n\nexport const currentUserHasAllPermissions = async ({ permissions }) =>\n get(`${API_BASE}/user/current/permissions/all`, { permissions });\n\nexport const currentUserHasSomePermissions = async ({ permissions }) =>\n get(`${API_BASE}/user/current/permissions/some`, { permissions });\n\nexport const getAllCurrentUserPermissions = async () =>\n get(`${API_BASE}/user/current/permissions/list`);\n\nexport const userHasPermission = async ({ userid, permission }) =>\n get(`${API_BASE}/user/${userid}/permissions`, { permission });\n\nexport const userHasAllPermissions = async ({ userid, permissions }) =>\n get(`${API_BASE}/user/${userid}/permissions/all`, { permissions });\n\nexport const userHasSomePermissions = async ({ userid, permissions }) =>\n get(`${API_BASE}/user/${userid}/permissions/some`, { permissions });\n\nexport const getAllUserPermissions = async ({ userid }) =>\n get(`${API_BASE}/user/${userid}/permissions/list`);\n\nexport const getUsers = async ({ limit, offset } = {}) =>\n get(`${API_BASE}/user`, { limit, offset });\n\nexport const searchUsers = async ({ q, limit, offset, inGroup, notInGroup } = {}) =>\n get(`${API_BASE}/user/search`, { q, limit, offset, inGroup, notInGroup });\n\nexport const createUser = async ({ name, email, password, emailVerified }) =>\n post(`${API_BASE}/user/create`, { name, email, password, emailVerified });\n\nexport const deleteUsers = async (ids) =>\n del(`${API_BASE}/user`, { ids });\n\nexport const updateUser = async ({ id, name, email, emailVerified, createdAt }) =>\n patch(`${API_BASE}/user`, { id, name, email, emailVerified, createdAt });\n\nexport const getUser = async (userid) =>\n get(`${API_BASE}/user/${userid}`);\n\nexport const getUserSessions = async (userid, { limit, offset } = {}) =>\n get(`${API_BASE}/user/${userid}/sessions`, { limit, offset });\n\nexport const deleteUserSession = async (userid, sessionToken) =>\n del(`${API_BASE}/user/${userid}/sessions`, { sessionToken });\n\nexport const deleteExpiredUserSessions = async (userid) =>\n del(`${API_BASE}/user/${userid}/sessions/expired`);\n\nexport const getUserGroups = async (userid, { limit, offset } = {}) =>\n get(`${API_BASE}/user/${userid}/groups`, { limit, offset });\n\nexport const addUserToGroup = async (userid, groupName) =>\n post(`${API_BASE}/user/${userid}/groups`, { groupName });\n\nexport const removeUserFromGroup = async (userid, groupName) =>\n del(`${API_BASE}/user/${userid}/groups`, { groupName });\n\nexport const listGroups = async ({ limit, offset, owner } = {}) =>\n get(`${API_BASE}/groups`, { limit, offset, owner });\n\nexport const createGroup = async ({ name, description }) =>\n post(`${API_BASE}/groups`, { name, description });\n\nexport const updateGroup = async ({ name, newName, description }) =>\n patch(`${API_BASE}/groups`, { name, newName, description });\n\nexport const deleteGroups = async (names) =>\n del(`${API_BASE}/groups`, { names });\n\nexport const getGroup = async (name) =>\n get(`${API_BASE}/groups/${encodeURIComponent(name)}`);\n\nexport const getGroupMembers = async (name, { limit, offset } = {}) =>\n get(`${API_BASE}/groups/${encodeURIComponent(name)}/members`, { limit, offset });\n\nexport const addMemberToGroup = async (name, userId) =>\n post(`${API_BASE}/groups/${encodeURIComponent(name)}/members`, { userId });\n\nexport const removeMemberFromGroup = async (name, userId) =>\n del(`${API_BASE}/groups/${encodeURIComponent(name)}/members`, { userId });\n\nexport const getGroupPermissions = async (name) =>\n get(`${API_BASE}/groups/${encodeURIComponent(name)}/permissions`);\n\nexport const addPermissionToGroup = async (name, permissionName) =>\n post(`${API_BASE}/groups/${encodeURIComponent(name)}/permissions`, { permissionName });\n\nexport const removePermissionFromGroup = async (name, permissionName) =>\n del(`${API_BASE}/groups/${encodeURIComponent(name)}/permissions`, { permissionName });\n\nexport const listPermissions = async ({ limit, offset, owner } = {}) =>\n get(`${API_BASE}/permissions`, { limit, offset, owner });\n\nexport const createPermissions = async (permissions) =>\n post(`${API_BASE}/permissions`, { permissions });\n\nexport const updatePermission = async ({ name, description }) =>\n patch(`${API_BASE}/permissions`, { name, description });\n\nexport const deletePermissions = async (names) =>\n del(`${API_BASE}/permissions`, { names });\n\nexport const getSetting = async (owner, name) =>\n get(`${API_BASE}/settings/${encodeURIComponent(owner)}/${encodeURIComponent(name)}`);\n\nexport const listSettings = async ({ owner, limit, offset } = {}) =>\n get(`${API_BASE}/settings/${encodeURIComponent(owner)}`, { limit, offset });\n\nexport const setSetting = async (owner, name, data) =>\n post(`${API_BASE}/settings/${encodeURIComponent(owner)}/${encodeURIComponent(name)}`, data);\n\nexport const deleteSetting = async (owner, name) =>\n del(`${API_BASE}/settings/${encodeURIComponent(owner)}/${encodeURIComponent(name)}`);\n\n/*\n Pages\n*/\n\nexport const listPages = async ({ owner, showHidden, offset, limit } = {}) =>\n get(`${API_BASE}/pages`, { owner, showHidden, offset, limit });\n\nexport const rescanPages = async () =>\n post(`${API_BASE}/pages/rescan`, {});\n\nexport const listTemplates = async () =>\n get(`${API_BASE}/templates`);\n\nexport const listDirectories = async () =>\n get(`${API_BASE}/pages/directories`);\n\nexport const getPage = async (file) =>\n get(`${API_BASE}/pages/file`, { file });\n\nexport const createPage = async ({ directory, name, template }) =>\n post(`${API_BASE}/pages`, { directory, name, template });\n\nexport const updatePage = async ({ file, name, title, description, author, template, contents, extraMetadata }) =>\n put(`${API_BASE}/pages/file`, { file, name, title, description, author, template, contents, extraMetadata });\n\nexport const deletePages = async (files) =>\n del(`${API_BASE}/pages`, { files });\n\nexport const disablePage = async (file) =>\n put(`${API_BASE}/pages/disable`, { file });\n\nexport const enablePage = async (file) =>\n put(`${API_BASE}/pages/enable`, { file });\n\nexport const movePage = async ({ file, newFile }) =>\n patch(`${API_BASE}/pages/file`, { file, newFile });\n\nexport const searchPagesByMetadata = async (query) =>\n get(`${API_BASE}/pages/search`, { query: JSON.stringify(query) });\n\nexport const setPageLocked = async ({ file, locked }) =>\n put(`${API_BASE}/pages/lock`, { file, locked });\n\n/*\n Templates\n*/\n\nexport const getTemplate = async (file) =>\n get(`${API_BASE}/templates/file`, { file });\n\nexport const createTemplate = async ({ directory, name, copyFrom }) =>\n post(`${API_BASE}/templates`, { directory, name, copyFrom });\n\nexport const updateTemplate = async ({ file, name, author, markup }) =>\n put(`${API_BASE}/templates/file`, { file, name, author, markup });\n\nexport const deleteTemplates = async (files) =>\n del(`${API_BASE}/templates`, { files });\n\nexport const disableTemplate = async (file) =>\n put(`${API_BASE}/templates/disable`, { file });\n\nexport const enableTemplate = async (file) =>\n put(`${API_BASE}/templates/enable`, { file });\n\nexport const moveTemplate = async ({ file, newFile }) =>\n patch(`${API_BASE}/templates/file`, { file, newFile });\n\nexport const setTemplateLocked = async ({ file, locked }) =>\n put(`${API_BASE}/templates/lock`, { file, locked });\n\n/*\n Fragments\n*/\n\nexport const listFragments = async () =>\n get(`${API_BASE}/fragments`);\n\nexport const getFragment = async (file) =>\n get(`${API_BASE}/fragments/file`, { file });\n\nexport const createFragment = async ({ directory, name }) =>\n post(`${API_BASE}/fragments`, { directory, name });\n\nexport const updateFragment = async ({ file, author, markup }) =>\n put(`${API_BASE}/fragments/file`, { file, author, markup });\n\nexport const deleteFragments = async (files) =>\n del(`${API_BASE}/fragments`, { files });\n\nexport const moveFragment = async ({ file, newFile }) =>\n patch(`${API_BASE}/fragments/file`, { file, newFile });\n\nexport const disableFragment = async (file) =>\n put(`${API_BASE}/fragments/disable`, { file });\n\nexport const enableFragment = async (file) =>\n put(`${API_BASE}/fragments/enable`, { file });\n\nexport const setFragmentLocked = async ({ file, locked }) =>\n put(`${API_BASE}/fragments/lock`, { file, locked });\n\n/*\n Global Content\n*/\n\nexport const listGlobalContent = async () =>\n get(`${API_BASE}/globals`);\n\nexport const getGlobalContent = async (id) =>\n get(`${API_BASE}/globals/entry`, { id });\n\nexport const createGlobalContent = async ({ name, location, priority }) =>\n post(`${API_BASE}/globals`, { name, location, priority });\n\nexport const updateGlobalContent = async ({ id, name, location, priority, markup }) =>\n put(`${API_BASE}/globals/entry`, { id, name, location, priority, markup });\n\nexport const deleteGlobalContent = async (ids) =>\n del(`${API_BASE}/globals`, { ids });\n\nexport const disableGlobalContent = async (id) =>\n put(`${API_BASE}/globals/disable`, { id });\n\nexport const enableGlobalContent = async (id) =>\n put(`${API_BASE}/globals/enable`, { id });\n\nexport const setGlobalContentLocked = async ({ id, locked }) =>\n put(`${API_BASE}/globals/lock`, { id, locked });\n\n/*\n Menus\n*/\n\nexport const listMenus = async () =>\n get(`${API_BASE}/menus`);\n\nexport const saveMenu = async ({ id, name }) =>\n post(`${API_BASE}/menus`, { id, name });\n\nexport const deleteMenu = async (id) =>\n del(`${API_BASE}/menus`, { id });\n\nexport const assignMenuLocation = async ({ location, menuId }) =>\n put(`${API_BASE}/menus/location`, { location, menuId });\n\nexport const saveMenuItem = async ({ id, menuId, location, navItem, label, href, icon, newTab }) =>\n post(`${API_BASE}/menus/items`, { id, menuId, location, navItem, label, href, icon, newTab });\n\nexport const deleteMenuItems = async (ids) =>\n del(`${API_BASE}/menus/items`, { ids });\n\nexport const setMenuItemEnabled = async ({ id, enabled }) =>\n put(`${API_BASE}/menus/items/enabled`, { id, enabled });\n\nexport const reorderMenuItems = async ({ menuId, ids }) =>\n put(`${API_BASE}/menus/items/order`, { menuId, ids });\n\nexport const adoptMenuItem = async ({ id, menuId, menuName }) =>\n put(`${API_BASE}/menus/adopt`, { id, menuId, menuName });\n\n/*\n Extensions\n*/\n\nexport const listExtensions = async ({ limit, offset } = {}) =>\n get(`${API_BASE}/extensions`, { limit, offset });\n\nexport const listAvailableExtensions = async () =>\n get(`${API_BASE}/extensions/available`);\n\nexport const listKnownExtensions = async ({ search, sort, limit, offset } = {}) =>\n get(`${API_BASE}/extensions/known`, { search, sort, limit, offset });\n\nexport const getKnownExtension = async (name) =>\n get(`${API_BASE}/extensions/known`, { name });\n\nexport const rateExtension = async (name, rating) =>\n put(`${API_BASE}/extensions/rating`, { name, rating });\n\n/*\n Dashboard\n*/\n\nexport const getDashboardWidgets = async () =>\n get(`${API_BASE}/dashboard/widgets`);\n\n/*\n Notifications\n*/\n\nexport const getNotifications = async ({ unreadOnly = false, limit, offset } = {}) =>\n get(`${API_BASE}/notifications`, { unreadOnly, limit, offset });\n\nexport const getUnreadNotificationCount = async () =>\n get(`${API_BASE}/notifications/count`);\n\nexport const markNotificationRead = async (id) =>\n post(`${API_BASE}/notifications/${encodeURIComponent(id)}/read`, {});\n\nexport const markNotificationHandled = async (id) =>\n post(`${API_BASE}/notifications/${encodeURIComponent(id)}/handled`, {});\n\nexport const markAllNotificationsRead = async () =>\n post(`${API_BASE}/notifications/read-all`, {});\n\nexport const dismissNotification = async (id) =>\n del(`${API_BASE}/notifications/${encodeURIComponent(id)}`);\n\nexport const listRealtimeConnections = async () =>\n get(`${API_BASE}/realtime/connections`);\n\nexport const installExtension = async (name, { withDependencies = false } = {}) =>\n post(`${API_BASE}/extensions`, { name, withDependencies });\n\nexport const uninstallExtension = async (name, purgeData = false, { cascade = false } = {}) =>\n del(`${API_BASE}/extensions`, { name, purgeData, cascade });\n\nexport const enableExtension = async (name, { cascade = false } = {}) =>\n post(`${API_BASE}/extensions/${encodeURIComponent(name)}/enable`, { cascade });\n\nexport const getExtensionRequirements = async (name) =>\n get(`${API_BASE}/extensions/${encodeURIComponent(name)}/requirements`);\n\nexport const disableExtension = async (name, { cascade = false } = {}) =>\n post(`${API_BASE}/extensions/${encodeURIComponent(name)}/disable`, { cascade });\n\nexport const getExtensionDependents = async (name, { includeDisabled = false } = {}) =>\n get(`${API_BASE}/extensions/${encodeURIComponent(name)}/dependents`, { includeDisabled: includeDisabled ? 'true' : undefined });\n\n/*\n Admin Global Content\n*/\n\nexport const listAdminGlobalContent = async () =>\n get(`${API_BASE}/admin-globals`);\n\nexport const getAdminGlobalContent = async (id) =>\n get(`${API_BASE}/admin-globals/${encodeURIComponent(id)}`);\n\nexport const createAdminGlobalContent = async ({ name, location, priority, owner, markup }) =>\n post(`${API_BASE}/admin-globals`, { name, location, priority, owner, markup });\n\nexport const updateAdminGlobalContent = async (id, { name, location, priority, markup }) =>\n put(`${API_BASE}/admin-globals/${encodeURIComponent(id)}`, { name, location, priority, markup });\n\nexport const deleteAdminGlobalContent = async (ids) =>\n del(`${API_BASE}/admin-globals`, { ids });\n\nexport const enableAdminGlobalContent = async (id) =>\n put(`${API_BASE}/admin-globals/${encodeURIComponent(id)}/enable`, {});\n\nexport const disableAdminGlobalContent = async (id) =>\n put(`${API_BASE}/admin-globals/${encodeURIComponent(id)}/disable`, {});\n\n"],"mappings":"cAASA,UAAKC,SAAMC,WAAKC,SAAOC,MAAW,aAC3C,MAAMC,EAAW,oBAEV,MAAMC,SAAWC,OAASC,QAAOC,WAAUC,UAChDT,EAAK,GAAGI,wBAAgC,CAAEG,QAAOC,WAAUC,gBAEtD,MAAMC,MAAQJ,OAASC,QAAOC,cACnCR,EAAK,GAAGI,qBAA6B,CAAEG,QAAOC,oBAEzC,MAAMG,OAASL,SAAYN,EAAK,GAAGI,gBAAwB,CAAC,UAE5D,MAAMQ,WAAaN,SAAYP,EAAI,GAAGK,yBAEtC,MAAMS,eAAiBP,OAASC,WACrCP,EAAK,GAAGI,oBAA4B,CAAEG,iBAEjC,MAAMO,cAAgBR,OAASS,QAAOP,WAAUQ,aAAY,KACjEhB,EAAK,GAAGI,wBAAgC,CAAEW,QAAOE,YAAaT,EAAUQ,qBAEnE,MAAME,eAAiBZ,OAASa,kBAAiBF,cAAaD,eACnEhB,EAAK,GAAGI,yBAAiC,CAAEe,kBAAiBF,cAAaD,qBAEpE,MAAMI,YAAcd,OAASS,WAClCf,EAAK,GAAGI,sBAA8B,CAAEW,iBAEnC,MAAMM,yBAA2Bf,OAASgB,gBAC/CvB,EAAI,GAAGK,6BAAqC,CAAEkB,sBAEzC,MAAMC,6BAA+BjB,OAASkB,iBACnDzB,EAAI,GAAGK,iCAAyC,CAAEoB,uBAE7C,MAAMC,8BAAgCnB,OAASkB,iBACpDzB,EAAI,GAAGK,kCAA0C,CAAEoB,uBAE9C,MAAME,6BAA+BpB,SAC1CP,EAAI,GAAGK,0CAEF,MAAMuB,kBAAoBrB,OAASsB,SAAQN,gBAChDvB,EAAI,GAAGK,UAAiBwB,gBAAsB,CAAEN,sBAE3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K,mBAE/D,MAAME,yBAA2B5K,MAAOG,GAC7CV,EAAI,GAAGK,gBAAuB4D,mBAAmBvD,0BAE5C,MAAM0K,iBAAmB7K,MAAOG,GAAQuK,WAAU,GAAU,CAAC,IAClEhL,EAAK,GAAGI,gBAAuB4D,mBAAmBvD,aAAiB,CAAEuK,mBAEhE,MAAMI,uBAAyB9K,MAAOG,GAAQ4K,mBAAkB,GAAU,CAAC,IAChFtL,EAAI,GAAGK,gBAAuB4D,mBAAmBvD,gBAAoB,CAAE4K,gBAAiBA,EAAkB,YAASC,WAM9G,MAAMC,uBAAyBjL,SACpCP,EAAI,GAAGK,0BAEF,MAAMoL,sBAAwBlL,MAAOsC,GAC1C7C,EAAI,GAAGK,mBAA0B4D,mBAAmBpB,aAE/C,MAAM6I,yBAA2BnL,OAASG,OAAM0H,WAAUC,WAAU5E,QAAOyD,YAChFjH,EAAK,GAAGI,kBAA0B,CAAEK,OAAM0H,WAAUC,WAAU5E,QAAOyD,kBAEhE,MAAMyE,yBAA2BpL,MAAOsC,GAAMnC,OAAM0H,WAAUC,WAAUnB,YAC7EhH,EAAI,GAAGG,mBAA0B4D,mBAAmBpB,KAAO,CAAEnC,OAAM0H,WAAUC,WAAUnB,kBAElF,MAAM0E,yBAA2BrL,MAAOoC,GAC7CvC,EAAI,GAAGC,kBAA0B,CAAEsC,eAE9B,MAAMkJ,yBAA2BtL,MAAOsC,GAC7C3C,EAAI,GAAGG,mBAA0B4D,mBAAmBpB,YAAc,CAAC,UAE9D,MAAMiJ,0BAA4BvL,MAAOsC,GAC9C3C,EAAI,GAAGG,mBAA0B4D,mBAAmBpB,aAAe,CAAC","ignoreList":[]}
|
package/middleware/kempo.js
CHANGED
|
@@ -5,11 +5,16 @@ import { renderExternalPage } from 'kempo-server/templating';
|
|
|
5
5
|
import getSession from '../server/utils/auth/getSession.js';
|
|
6
6
|
import currentUserHasPermission from '../server/utils/permissions/currentUserHasPermission.js';
|
|
7
7
|
import { LEXICAL_BASE, bundleFileName as lexicalBundleFileName } from '../server/utils/lexical/packages.js';
|
|
8
|
-
import { getEnabledExtensions } from '../server/utils/extensions/scopeCache.js';
|
|
8
|
+
import { getEnabledExtensions, onExtensionsChanged } from '../server/utils/extensions/scopeCache.js';
|
|
9
|
+
import { resyncMenus } from '../server/utils/menus/store.js';
|
|
9
10
|
import readKempoConfig from '../server/utils/extensions/readKempoConfig.js';
|
|
10
11
|
import { extensionAdminDirs, extensionPublicDirs } from '../server/utils/extensions/contentDirs.js';
|
|
11
12
|
import triggerHook from '../server/utils/hooks/triggerHook.js';
|
|
12
13
|
import { ADMIN_GLOBALS_DIR } from '../server/utils/admin-global-content/helpers.js';
|
|
14
|
+
import { startScheduler } from '../server/utils/scheduler/scheduler.js';
|
|
15
|
+
import { ensureEncryptionKey } from '../server/utils/settings/ensureEncryptionKey.js';
|
|
16
|
+
import { resolveAlias } from '../server/utils/extensions/aliases.js';
|
|
17
|
+
import { normalizeScopes } from '../server/utils/extensions/scopes.js';
|
|
13
18
|
|
|
14
19
|
const MIME_TYPES = {
|
|
15
20
|
'.js': 'application/javascript',
|
|
@@ -177,10 +182,30 @@ const serveDir = async (dirPath, method, request, response, resolveDir, rootDir,
|
|
|
177
182
|
};
|
|
178
183
|
|
|
179
184
|
export default config => {
|
|
185
|
+
startScheduler();
|
|
186
|
+
|
|
187
|
+
/*
|
|
188
|
+
The key that encrypts stored credentials exists before any request needs it, generated into .env the
|
|
189
|
+
first time when the site has none. Opt out with `autoEncryptionKey: false` in the server config or
|
|
190
|
+
KEMPO_AUTO_ENCRYPTION_KEY=off, and never in the in-memory test database.
|
|
191
|
+
*/
|
|
192
|
+
const encryptionKeyReady = config.autoEncryptionKey === false || process.env.KEMPO_AUTO_ENCRYPTION_KEY === 'off' || process.env.KEMPO_DB === 'pglite'
|
|
193
|
+
? Promise.resolve()
|
|
194
|
+
: ensureEncryptionKey().then(([error]) => {
|
|
195
|
+
if(error) console.error(`[kempo] ${error.msg}`);
|
|
196
|
+
});
|
|
180
197
|
const PROJECT_PUBLIC = config.rootPath || join(process.cwd(), 'public');
|
|
181
198
|
const ADMIN_ROOT = resolveAdminRoot(config.adminRoot);
|
|
182
199
|
|
|
200
|
+
/*
|
|
201
|
+
A menu holds a copy of what an extension supplied, so it is brought up to date whenever extensions are
|
|
202
|
+
installed, enabled, disabled or removed: what an extension supplied leaves the site with it. Not at
|
|
203
|
+
start, when the database may not be answering yet and every extension would look absent.
|
|
204
|
+
*/
|
|
205
|
+
onExtensionsChanged(() => resyncMenus(PROJECT_PUBLIC));
|
|
206
|
+
|
|
183
207
|
return async (request, response, next) => {
|
|
208
|
+
await encryptionKeyReady;
|
|
184
209
|
const { path } = request;
|
|
185
210
|
const url = request.url.split('?')[0];
|
|
186
211
|
|
|
@@ -394,23 +419,34 @@ export default config => {
|
|
|
394
419
|
*/
|
|
395
420
|
const publicContentDirs = await extensionPublicDirs();
|
|
396
421
|
|
|
422
|
+
const loaded = [];
|
|
397
423
|
for(const ext of extensions){
|
|
398
424
|
const extRoot = join(NODE_MODULES, ext.name);
|
|
399
|
-
let kempo;
|
|
400
425
|
try {
|
|
401
|
-
({ kempo
|
|
402
|
-
} catch {
|
|
403
|
-
|
|
404
|
-
}
|
|
426
|
+
loaded.push({ extRoot, kempo: (await readKempoConfig(extRoot)).kempo });
|
|
427
|
+
} catch { /* not readable: nothing to route */ }
|
|
428
|
+
}
|
|
405
429
|
|
|
406
|
-
|
|
407
|
-
|
|
430
|
+
/*
|
|
431
|
+
An extension may answer on a short address it declares in `aliases` (`/cart` for `/commerce/cart`);
|
|
432
|
+
the routing below then treats the request as if it had arrived at the real address. A page the
|
|
433
|
+
site has of its own at that address always wins (see server/utils/extensions/aliases.js).
|
|
434
|
+
*/
|
|
435
|
+
const routedUrl = await resolveAlias(url, loaded, PROJECT_PUBLIC);
|
|
408
436
|
|
|
409
|
-
|
|
410
|
-
|
|
437
|
+
for(const { extRoot, kempo } of loaded){
|
|
438
|
+
/*
|
|
439
|
+
An extension may claim several scopes, each serving a folder of its package ("public-scope" serves
|
|
440
|
+
public/, "public-scopes" names others). Installing or enabling one that claims an address another
|
|
441
|
+
enabled extension has is refused, so at most one extension matches any request.
|
|
442
|
+
*/
|
|
443
|
+
const [, scopes] = normalizeScopes(kempo);
|
|
444
|
+
const claimed = scopes.find(({ scope }) => routedUrl === `/${scope}` || routedUrl.startsWith(`/${scope}/`));
|
|
445
|
+
if(!claimed) continue;
|
|
411
446
|
|
|
412
|
-
const
|
|
413
|
-
const
|
|
447
|
+
const scopePrefix = `/${claimed.scope}`;
|
|
448
|
+
const publicDir = join(extRoot, claimed.dir);
|
|
449
|
+
const subPath = routedUrl.slice(scopePrefix.length) || '/';
|
|
414
450
|
const method = request.method?.toUpperCase() || 'GET';
|
|
415
451
|
const resolveDir = buildResolveDir(PROJECT_PUBLIC, url);
|
|
416
452
|
const segments = subPath.replace(/^\//, '').split('/').filter(Boolean);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kempo",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.7.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A fullstack CMS framework for creating websites with user authentication",
|
|
6
6
|
"scripts": {
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"peerDependencies": {
|
|
61
61
|
"kempo-css": ">=2.2.5",
|
|
62
62
|
"kempo-server": ">=3.4.0",
|
|
63
|
-
"kempo-ui": ">=0.
|
|
63
|
+
"kempo-ui": ">=0.6.0"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
66
|
"@electric-sql/pglite": "^0.5.9",
|
package/server/db/schema.js
CHANGED
|
@@ -115,6 +115,29 @@ export const extension = pgTable('extension', {
|
|
|
115
115
|
updatedAt: timestamp('updatedAt').notNull(),
|
|
116
116
|
});
|
|
117
117
|
|
|
118
|
+
/*
|
|
119
|
+
Scheduled jobs: recurring work an extension declares in its kempo-config.json `jobs`. A row per job
|
|
120
|
+
is the schedule and the lease: `nextRunAt` is when it is next due and `lockedUntil` is held while a
|
|
121
|
+
process runs it, so several server processes sharing one database run each job once per interval.
|
|
122
|
+
`lastStatus` is 'ok' or 'error'.
|
|
123
|
+
*/
|
|
124
|
+
export const scheduledJob = pgTable('scheduledJob', {
|
|
125
|
+
id: text('id').primaryKey(),
|
|
126
|
+
owner: text('owner').notNull(),
|
|
127
|
+
name: text('name').notNull(),
|
|
128
|
+
everyMs: integer('everyMs').notNull(),
|
|
129
|
+
callback: text('callback').notNull(),
|
|
130
|
+
nextRunAt: timestamp('nextRunAt').notNull(),
|
|
131
|
+
lockedUntil: timestamp('lockedUntil'),
|
|
132
|
+
lastRunAt: timestamp('lastRunAt'),
|
|
133
|
+
lastStatus: text('lastStatus'),
|
|
134
|
+
lastError: text('lastError'),
|
|
135
|
+
createdAt: timestamp('createdAt').notNull(),
|
|
136
|
+
}, table => [
|
|
137
|
+
index('scheduledJob_owner_idx').on(table.owner),
|
|
138
|
+
index('scheduledJob_next_idx').on(table.nextRunAt),
|
|
139
|
+
]);
|
|
140
|
+
|
|
118
141
|
/*
|
|
119
142
|
Realtime System
|
|
120
143
|
*/
|
|
@@ -203,6 +226,7 @@ export const dashboardWidget = pgTable('dashboardWidget', {
|
|
|
203
226
|
title: text('title').notNull(),
|
|
204
227
|
description: text('description'),
|
|
205
228
|
icon: text('icon'),
|
|
229
|
+
iconSrc: text('iconSrc'),
|
|
206
230
|
element: text('element').notNull(),
|
|
207
231
|
module: text('module').notNull(),
|
|
208
232
|
defaultWidth: integer('defaultWidth').notNull().default(2),
|
package/server/sdk.js
CHANGED
|
@@ -144,6 +144,16 @@ export { default as enableGlobalContent } from './utils/global-content/enableGlo
|
|
|
144
144
|
export { default as getGlobalContent } from './utils/global-content/getGlobalContent.js';
|
|
145
145
|
export { default as listGlobalContent } from './utils/global-content/listGlobalContent.js';
|
|
146
146
|
export { default as setGlobalContentLocked } from './utils/global-content/setGlobalContentLocked.js';
|
|
147
|
+
export { default as listMenus } from './utils/menus/listMenus.js';
|
|
148
|
+
export { default as findNavItems } from './utils/menus/findNavItems.js';
|
|
149
|
+
export { default as saveMenu } from './utils/menus/saveMenu.js';
|
|
150
|
+
export { default as deleteMenu } from './utils/menus/deleteMenu.js';
|
|
151
|
+
export { default as assignMenuLocation } from './utils/menus/assignMenuLocation.js';
|
|
152
|
+
export { default as saveMenuItem } from './utils/menus/saveMenuItem.js';
|
|
153
|
+
export { default as deleteMenuItems } from './utils/menus/deleteMenuItems.js';
|
|
154
|
+
export { default as setMenuItemEnabled } from './utils/menus/setMenuItemEnabled.js';
|
|
155
|
+
export { default as reorderMenuItems } from './utils/menus/reorderMenuItems.js';
|
|
156
|
+
export { default as adoptMenuItem } from './utils/menus/adoptMenuItem.js';
|
|
147
157
|
export { default as updateGlobalContent } from './utils/global-content/updateGlobalContent.js';
|
|
148
158
|
|
|
149
159
|
/*
|
|
@@ -159,12 +169,23 @@ export { default as getAdminGlobalContent } from './utils/admin-global-content/g
|
|
|
159
169
|
export { default as listAdminGlobalContent } from './utils/admin-global-content/listAdminGlobalContent.js';
|
|
160
170
|
export { default as updateAdminGlobalContent } from './utils/admin-global-content/updateAdminGlobalContent.js';
|
|
161
171
|
|
|
172
|
+
/*
|
|
173
|
+
Scheduled Jobs
|
|
174
|
+
*/
|
|
175
|
+
|
|
176
|
+
export { default as listJobs } from './utils/scheduler/listJobs.js';
|
|
177
|
+
export { default as registerJobs } from './utils/scheduler/registerJobs.js';
|
|
178
|
+
export { default as unregisterJobs } from './utils/scheduler/unregisterJobs.js';
|
|
179
|
+
export { runDueJobs, runJob } from './utils/scheduler/runJobs.js';
|
|
180
|
+
export { startScheduler, stopScheduler } from './utils/scheduler/scheduler.js';
|
|
181
|
+
|
|
162
182
|
/*
|
|
163
183
|
Email
|
|
164
184
|
*/
|
|
165
185
|
|
|
166
186
|
export { default as sendEmail } from './utils/email/sendEmail.js';
|
|
167
187
|
export { default as sendEmailFromTemplate } from './utils/email/sendEmailFromTemplate.js';
|
|
188
|
+
export { default as renderEmailTemplate } from './utils/email/renderEmailTemplate.js';
|
|
168
189
|
|
|
169
190
|
/*
|
|
170
191
|
Filesystem Utilities
|
|
@@ -7,7 +7,13 @@ import getSetting from '../settings/getSetting.js';
|
|
|
7
7
|
|
|
8
8
|
const generateToken = () => crypto.randomBytes(32).toString('hex');
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
/*
|
|
11
|
+
`subject` and `template` let a caller send its own wording with the same link, for example an
|
|
12
|
+
extension that creates an account for someone at checkout and wants the email to say "set your
|
|
13
|
+
password". `template` is a name for sendEmailFromTemplate, including an extension's "owner/name".
|
|
14
|
+
The template receives `name` and `resetLink`.
|
|
15
|
+
*/
|
|
16
|
+
export default async ({ email, subject = 'Reset Your Password', template = 'reset-password' }) => {
|
|
11
17
|
if(!email){
|
|
12
18
|
return [{ code: 400, msg: 'Email is required' }, null];
|
|
13
19
|
}
|
|
@@ -42,8 +48,8 @@ export default async ({ email }) => {
|
|
|
42
48
|
|
|
43
49
|
const [emailError] = await sendEmailFromTemplate({
|
|
44
50
|
to: email,
|
|
45
|
-
subject
|
|
46
|
-
template
|
|
51
|
+
subject,
|
|
52
|
+
template,
|
|
47
53
|
data: {
|
|
48
54
|
name,
|
|
49
55
|
resetLink,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import db from '../../db/index.js';
|
|
2
2
|
import { verificationToken, user } from '../../db/schema.js';
|
|
3
3
|
import { eq, and, gt } from 'drizzle-orm';
|
|
4
|
+
import triggerHook from '../hooks/triggerHook.js';
|
|
4
5
|
|
|
5
6
|
export default async ({ token }) => {
|
|
6
7
|
if(!token){
|
|
@@ -36,7 +37,15 @@ export default async ({ token }) => {
|
|
|
36
37
|
.delete(verificationToken)
|
|
37
38
|
.where(eq(verificationToken.token, token));
|
|
38
39
|
|
|
39
|
-
|
|
40
|
+
/*
|
|
41
|
+
Someone has just proved they own this address, which is what an extension needs before it hands
|
|
42
|
+
them something that was only ever tied to the address (guest orders, say). Fires
|
|
43
|
+
`user:email_verified` with `{ userId, email }`.
|
|
44
|
+
*/
|
|
45
|
+
const [verified] = await db.select({ email: user.email }).from(user).where(eq(user.id, tokenRecord.userId)).limit(1);
|
|
46
|
+
await triggerHook('user:email_verified', { userId: tokenRecord.userId, email: verified?.email ?? null });
|
|
47
|
+
|
|
48
|
+
return [null, {
|
|
40
49
|
success: true,
|
|
41
50
|
userId: tokenRecord.userId
|
|
42
51
|
}];
|