headroom-cms 0.1.10 → 0.1.11

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.
Files changed (104) hide show
  1. package/README.md +11 -6
  2. package/admin/assets/{AdminsPage-BIWASote.js → AdminsPage-BnzH9TL3.js} +1 -1
  3. package/admin/assets/{AllContentPage-1gXe2OC7.js → AllContentPage-BtObN6oy.js} +1 -1
  4. package/admin/assets/{ApiKeysPage-BBW4ATBx.js → ApiKeysPage-DEAa8eyC.js} +1 -1
  5. package/admin/assets/{AuditPage-B5GGFWGG.js → AuditPage-BN9yNsxh.js} +1 -1
  6. package/admin/assets/{BlockEditor-ClskiZoX.js → BlockEditor-3wnisTOZ.js} +3 -3
  7. package/admin/assets/{BlockTypeEditPage-CY0gCPei.js → BlockTypeEditPage-C2evAESK.js} +1 -1
  8. package/admin/assets/{BlockTypesPage-D8Me6OeX.js → BlockTypesPage-Dhkho6T_.js} +1 -1
  9. package/admin/assets/{BulkActionBar--35xjnOP.js → BulkActionBar-BxdfUSrN.js} +1 -1
  10. package/admin/assets/CollectionEditPage-lOb4hEZy.js +1 -0
  11. package/admin/assets/{CollectionsPage-BQmGXpvW.js → CollectionsPage-CgtOloa1.js} +1 -1
  12. package/admin/assets/{ContentCreatePage-DlgxamOe.js → ContentCreatePage-LeQjahp_.js} +1 -1
  13. package/admin/assets/ContentEditPage-xczr4d_h.js +1 -0
  14. package/admin/assets/{ContentField-D04Uo1Ov.js → ContentField-pilCbdnA.js} +1 -1
  15. package/admin/assets/{ContentListPage-BDMx7pWb.js → ContentListPage-BAKDn1Xy.js} +1 -1
  16. package/admin/assets/{CustomBlockPreview-Cs9bFDh4.js → CustomBlockPreview-DNnTFM0z.js} +1 -1
  17. package/admin/assets/FieldRenderer-DiOKvkWV.js +2 -0
  18. package/admin/assets/{FilterBar-kFcOLffg.js → FilterBar-BZoa63zh.js} +1 -1
  19. package/admin/assets/{FloatingComposerController-D4uLQfUX-C0Lhbmda.js → FloatingComposerController-D4uLQfUX-BMIvFCoE.js} +1 -1
  20. package/admin/assets/{IconPicker-BrgSAsa_.js → IconPicker-CpIgiQTC.js} +2 -2
  21. package/admin/assets/{LoginPage-Bi7TBzK4.js → LoginPage-D9ZsGLIi.js} +1 -1
  22. package/admin/assets/{MediaField-B-Cz8TlK.js → MediaField-CxccCFGQ.js} +1 -1
  23. package/admin/assets/{MediaPage-C84p9d1U.js → MediaPage-QvMaH2YJ.js} +1 -1
  24. package/admin/assets/{Pagination-CuHwUPHi.js → Pagination-Df9nQ7Z0.js} +1 -1
  25. package/admin/assets/{RelationshipPicker-Dv7GaLcU.js → RelationshipPicker-B3Ftmqxp.js} +1 -1
  26. package/admin/assets/{SiteSettingsPage-nBT7NzkA.js → SiteSettingsPage-6NvH7CiQ.js} +1 -1
  27. package/admin/assets/{SiteUserEditPage-DroUTii9.js → SiteUserEditPage-D5VaQ1Xq.js} +1 -1
  28. package/admin/assets/{SiteUsersPage-iVXPCBPe.js → SiteUsersPage-BYVduiqs.js} +1 -1
  29. package/admin/assets/{SitesPage-BefZeWuJ.js → SitesPage-rfWWE0yK.js} +1 -1
  30. package/admin/assets/{SubmissionDetailPage-ktmzzOE1.js → SubmissionDetailPage-BSUR685F.js} +1 -1
  31. package/admin/assets/{SubmissionEditPage-C-ykTI2t.js → SubmissionEditPage-DjLXHjWU.js} +1 -1
  32. package/admin/assets/{SubmissionListPage-DA-8deUy.js → SubmissionListPage-DBxNEvde.js} +1 -1
  33. package/admin/assets/{TagInput-d-Hw1fkL.js → TagInput-57c4DG1w.js} +1 -1
  34. package/admin/assets/{TagsPage-BZzDvcKa.js → TagsPage-BEO5AwCv.js} +1 -1
  35. package/admin/assets/{UsersPage-CnQAOOGF.js → UsersPage-BpIRorJ1.js} +1 -1
  36. package/admin/assets/{WebhookEditPage-KeS8hmdW.js → WebhookEditPage-D5xgi56h.js} +1 -1
  37. package/admin/assets/{WebhooksPage-CASjmlPN.js → WebhooksPage-BY7AaiGr.js} +1 -1
  38. package/admin/assets/{card-CZTHR2Qa.js → card-C9hfyHXf.js} +1 -1
  39. package/admin/assets/{checkbox-DEgzM8H9.js → checkbox-DVJcwUt1.js} +1 -1
  40. package/admin/assets/{command-CdzYw11U.js → command-Bfmj0MEL.js} +1 -1
  41. package/admin/assets/index-BB9Syqw2.css +1 -0
  42. package/admin/assets/{index-BA3y7HJs.js → index-Ce5pmRMj.js} +2 -2
  43. package/admin/assets/media-url-DdCoIedP.js +1 -0
  44. package/admin/assets/{popover-BFw_h3j6.js → popover-CzaQYEEP.js} +1 -1
  45. package/admin/assets/{select-dX9e6VDt.js → select-CrRhFGIi.js} +1 -1
  46. package/admin/assets/serializeToText-2VrsuRUh.js +2 -0
  47. package/admin/assets/{table-Dk7eeOt2.js → table-_3bMY0_z.js} +1 -1
  48. package/admin/assets/{textarea-CpDSUg2s.js → textarea-6fq0R6VV.js} +1 -1
  49. package/admin/assets/{useAdminResolver-Bljb4XGQ.js → useAdminResolver-BJNPz3OG.js} +1 -1
  50. package/admin/assets/{useContent-CW0tm0FY.js → useContent-Bs7nel7C.js} +1 -1
  51. package/admin/assets/{useContentSearch-_bwacEth.js → useContentSearch-B3aTjuCu.js} +1 -1
  52. package/admin/assets/{useMedia-Cu5N4rY8.js → useMedia-ae3s_ajC.js} +1 -1
  53. package/admin/assets/{usePageTitle-DYvuJQp6.js → usePageTitle-C1r1-C00.js} +1 -1
  54. package/admin/assets/{useSiteUsers-CKtC_8Jc.js → useSiteUsers-DIaqgNSp.js} +1 -1
  55. package/admin/assets/{useTags-ybsMbCst.js → useTags-B-HgMVwo.js} +1 -1
  56. package/admin/assets/{useWebhooks-BAB-3sLa.js → useWebhooks-BvZjUJkJ.js} +1 -1
  57. package/admin/favicon-16x16.png +0 -0
  58. package/admin/favicon-32x32.png +0 -0
  59. package/admin/icons/icon-180x180.png +0 -0
  60. package/admin/icons/icon-192x192.png +0 -0
  61. package/admin/icons/icon-512x512.png +0 -0
  62. package/admin/icons/maskable-icon-512x512.png +0 -0
  63. package/admin/index.html +2 -2
  64. package/admin/sw.js +1 -1
  65. package/dist/admin-site.d.ts +4 -2
  66. package/dist/admin-site.d.ts.map +1 -1
  67. package/dist/admin-site.js +3 -3
  68. package/dist/admin-site.js.map +1 -1
  69. package/dist/cdn-api.d.ts +25 -0
  70. package/dist/cdn-api.d.ts.map +1 -0
  71. package/dist/{cdn.js → cdn-api.js} +7 -139
  72. package/dist/cdn-api.js.map +1 -0
  73. package/dist/cdn-media.d.ts +26 -0
  74. package/dist/cdn-media.d.ts.map +1 -0
  75. package/dist/cdn-media.js +202 -0
  76. package/dist/cdn-media.js.map +1 -0
  77. package/dist/index.d.ts +15 -3
  78. package/dist/index.d.ts.map +1 -1
  79. package/dist/index.js +19 -9
  80. package/dist/index.js.map +1 -1
  81. package/lambda/api/bootstrap +0 -0
  82. package/lambda/image-lambda/node_modules/.package-lock.json +3 -3
  83. package/lambda/image-lambda/node_modules/semver/README.md +19 -4
  84. package/lambda/image-lambda/node_modules/semver/bin/semver.js +14 -10
  85. package/lambda/image-lambda/node_modules/semver/functions/truncate.js +48 -0
  86. package/lambda/image-lambda/node_modules/semver/index.js +2 -0
  87. package/lambda/image-lambda/node_modules/semver/internal/re.js +1 -1
  88. package/lambda/image-lambda/node_modules/semver/package.json +3 -3
  89. package/lambda/image-lambda/node_modules/semver/range.bnf +5 -4
  90. package/lambda/webhook-worker/bootstrap +0 -0
  91. package/package.json +1 -1
  92. package/src/admin-site.ts +7 -5
  93. package/src/{cdn.ts → cdn-api.ts} +8 -161
  94. package/src/cdn-media.ts +250 -0
  95. package/src/index.ts +34 -11
  96. package/admin/assets/CollectionEditPage-y8t0ZO89.js +0 -1
  97. package/admin/assets/ContentEditPage-WkSbCnnG.js +0 -1
  98. package/admin/assets/FieldRenderer-wE-mtqZB.js +0 -2
  99. package/admin/assets/index-c7UygSvP.css +0 -1
  100. package/admin/assets/media-url-DIg_vSyf.js +0 -1
  101. package/admin/assets/serializeToText-Zin3gYPm.js +0 -2
  102. package/dist/cdn.d.ts +0 -27
  103. package/dist/cdn.d.ts.map +0 -1
  104. package/dist/cdn.js.map +0 -1
package/README.md CHANGED
@@ -15,10 +15,11 @@ npx sst deploy --stage production
15
15
  ./scripts/create-admin.sh admin@example.com 'YourPassword123!'
16
16
  ```
17
17
 
18
- After deploying, the CLI prints three URLs:
18
+ After deploying, the CLI prints four URLs:
19
19
 
20
20
  - **API** — the Lambda function URL for the content API
21
- - **CDN** — the CloudFront distribution (cached, edge-authenticated)
21
+ - **API CDN** — the CloudFront distribution for `/v1/*` and `/health` (cached, edge-authenticated)
22
+ - **Media CDN** — the CloudFront distribution for `/media/*` and `/img/*` (public assets)
22
23
  - **Admin** — the admin UI
23
24
 
24
25
  Open the Admin URL and sign in with the credentials you just created.
@@ -82,7 +83,8 @@ export default $config({
82
83
  | Option | Type | Default | Description |
83
84
  |--------|------|---------|-------------|
84
85
  | `senderEmail` | `string` | **(required)** | Email for admin invitations and password resets. Must be verified in SES (see [Troubleshooting](#troubleshooting)). |
85
- | `domain` | `{ name, certificateArn }` | CloudFront default | Custom domain for the CDN / API endpoint. |
86
+ | `domain` | `{ name, certificateArn }` | CloudFront default | Custom domain for the API CDN (`/v1/*`, `/health`). |
87
+ | `mediaDomain` | `{ name, certificateArn }` | CloudFront default | Custom domain for the media CDN (`/media/*`, `/img/*`). |
86
88
  | `adminDomain` | `{ name, certificateArn }` | CloudFront default | Custom domain for the admin UI. |
87
89
  | `priceClass` | `"PriceClass_100"` \| `"PriceClass_200"` \| `"PriceClass_All"` | `"PriceClass_100"` | CloudFront price class. `100` = US/Canada/Europe, `200` adds Asia/Africa, `All` = global. |
88
90
  | `apiCacheTtl` | `number` | `3600` | API response cache TTL in seconds at the CloudFront edge. |
@@ -105,14 +107,17 @@ The component returns these outputs (available in `.sst/outputs.json` after depl
105
107
  | Output | Description |
106
108
  |--------|-------------|
107
109
  | `api` | Lambda function URL for the Go API |
108
- | `cdn` | CloudFront distribution URL (cached, edge-authenticated) |
110
+ | `apiCdn` | API CloudFront distribution URL (`/v1/*`, `/health` — cached, edge-authenticated) |
111
+ | `mediaCdn` | Media CloudFront distribution URL (`/media/*`, `/img/*` — public assets). Use this in public HTML so the API host stays out of `<img src>` and `og:image` tags. |
109
112
  | `admin` | Admin UI URL |
110
113
  | `userPoolId` | Cognito User Pool ID |
111
114
  | `userPoolClientId` | Cognito User Pool Client ID |
112
115
 
116
+ The API and media CDNs are deliberately split. `apiCdn` is the host your server-to-server code calls for `/v1/*` reads and writes; `mediaCdn` is the host that should appear in any public HTML, RSS feed, or `og:image` meta tag your site emits. Keeping the API host out of casually-scraped public content makes scraping, key probing, and accidental reverse-engineering of the admin endpoints noticeably harder.
117
+
113
118
  ## Custom Domains
114
119
 
115
- To use custom domains for the CDN or admin UI:
120
+ To use custom domains for the API CDN, media CDN, or admin UI:
116
121
 
117
122
  1. **Request an ACM certificate** in **us-east-1** (required for CloudFront):
118
123
 
@@ -139,7 +144,7 @@ To use custom domains for the CDN or admin UI:
139
144
 
140
145
  4. **Deploy**, then create a **CNAME** (or alias) DNS record pointing your domain to the CloudFront distribution domain shown in the deploy output.
141
146
 
142
- Repeat for `adminDomain` if you want a custom domain for the admin UI.
147
+ Repeat for `mediaDomain` (media CDN, serves `/media/*` and `/img/*`) and `adminDomain` (admin UI) if you want custom domains for those. Each certificate must be in us-east-1.
143
148
 
144
149
  ## Updating
145
150
 
@@ -1 +1 @@
1
- import{j as e}from"./tanstack-Bs3zYPPV.js";import{u as H,r as x}from"./react-vendor-C2CvUxFh.js";import{u as L,aN as M,aO as q,p as z,aP as V,aQ as G,x as Q,S as b,D as _,i as $,B as l,aR as J,k as K,l as W,m as X,n as Y,I as Z,o as ee,P as se,T as ae,v as i}from"./index-BA3y7HJs.js";import{u as ie}from"./useAdminResolver-Bljb4XGQ.js";import{T as te,a as ne,b as y,c as p,d as re,e as j}from"./table-Dk7eeOt2.js";import{P as oe,a as le,b as de}from"./popover-BFw_h3j6.js";import{C as ce,a as me,b as ue,c as he,d as xe,e as pe}from"./command-CdzYw11U.js";import{S as je,a as ve,b as ge,c as fe,d as A}from"./select-dX9e6VDt.js";import{u as be}from"./usePageTitle-DYvuJQp6.js";import"./radix-C5ZmWuuL.js";function De(){const{host:d}=H(),{user:C}=L(),N=M(),{data:S,isLoading:I}=q(d),{data:T}=z(),c=V(d),m=G(d),n=S?.admins??[],E=T?.items??[],r=N==="admin",v=n.map(s=>s.id),{resolve:w}=ie(v),[P,g]=x.useState(!1),[D,f]=x.useState(!1),[u,h]=x.useState(""),R=Q();if(be({title:"Admins"}),I)return e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{className:"h-8 w-64"}),Array.from({length:3}).map((s,a)=>e.jsx(b,{className:"h-12 w-full"},a))]});const O=E.filter(s=>!v.includes(s.sub));async function U(s){try{await c.mutateAsync({admins:[...n,{id:s,role:"editor"}]}),i.success("Admin added"),g(!1)}catch(a){i.error("Failed to add admin",{description:a instanceof Error?a.message:void 0})}}async function F(s){if(s.preventDefault(),!!u.trim())try{const a=await m.mutateAsync({email:u.trim()});a.existed?i.success("Existing user added to site"):i.success("Invite email sent",{description:`An invite has been sent to ${a.email}`}),h(""),f(!1)}catch(a){i.error("Failed to invite user",{description:a instanceof Error?a.message:void 0})}}async function k(s){try{await c.mutateAsync({admins:n.filter(a=>a.id!==s)}),i.success("Admin removed")}catch(a){i.error("Failed to remove admin",{description:a instanceof Error?a.message:void 0})}}async function B(s,a){const o=n.map(t=>t.id===s?{...t,role:a}:t);if(!o.some(t=>t.role==="admin")){i.error("At least one admin role is required");return}try{await c.mutateAsync({admins:o}),i.success("Role updated")}catch(t){i.error("Failed to update role",{description:t instanceof Error?t.message:void 0})}}return e.jsxs("div",{children:[!R&&e.jsx("h1",{className:"mb-6 text-2xl font-semibold",children:"Admins"}),r&&e.jsxs("div",{className:"mb-6 flex gap-2",children:[e.jsxs(_,{open:D,onOpenChange:s=>{f(s),s||h("")},children:[e.jsx($,{asChild:!0,children:e.jsxs(l,{children:[e.jsx(J,{className:"mr-2 h-4 w-4"}),"Invite by email"]})}),e.jsxs(K,{children:[e.jsxs(W,{children:[e.jsx(X,{children:"Invite User to Site"}),e.jsx(Y,{className:"sr-only",children:"Send an invite email to add a user to this site"})]}),e.jsxs("form",{onSubmit:F,className:"space-y-4",children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:"Enter an email address. If the user doesn't have an account yet, they'll receive an invite email."}),e.jsx(Z,{type:"email",value:u,onChange:s=>h(s.target.value),placeholder:"email@example.com",required:!0}),e.jsx(ee,{children:e.jsx(l,{type:"submit",disabled:m.isPending,children:m.isPending?"Inviting...":"Send Invite"})})]})]})]}),e.jsxs(oe,{open:P,onOpenChange:g,children:[e.jsx(le,{asChild:!0,children:e.jsxs(l,{variant:"outline",children:[e.jsx(se,{className:"mr-2 h-4 w-4"}),"Add existing user"]})}),e.jsx(de,{className:"w-72 p-0",align:"start",children:e.jsxs(ce,{children:[e.jsx(me,{placeholder:"Search users..."}),e.jsxs(ue,{children:[e.jsx(he,{children:"No users found."}),e.jsx(xe,{children:O.map(s=>e.jsx(pe,{value:s.email,onSelect:()=>U(s.sub),children:s.email},s.sub))})]})]})})]})]}),n.length===0?e.jsx("p",{className:"text-muted-foreground",children:"No admins configured."}):e.jsxs(te,{children:[e.jsx(ne,{children:e.jsxs(y,{children:[e.jsx(p,{children:"Email"}),e.jsx(p,{children:"Role"}),r&&e.jsx(p,{})]})}),e.jsx(re,{children:n.map(s=>{const a=s.id===C?.sub;return e.jsxs(y,{children:[e.jsxs(j,{className:"text-sm",children:[w(s.id),a&&e.jsx("span",{className:"ml-2 text-muted-foreground",children:"(you)"})]}),e.jsx(j,{children:r&&!a?e.jsxs(je,{value:s.role,onValueChange:o=>B(s.id,o),children:[e.jsx(ve,{className:"w-28",children:e.jsx(ge,{})}),e.jsxs(fe,{children:[e.jsx(A,{value:"admin",children:"Admin"}),e.jsx(A,{value:"editor",children:"Editor"})]})]}):e.jsx("span",{className:"text-sm capitalize",children:s.role})}),r&&e.jsx(j,{className:"text-right",children:!a&&e.jsx(l,{variant:"ghost",size:"sm",onClick:()=>k(s.id),title:"Remove from site",children:e.jsx(ae,{className:"h-4 w-4"})})})]},s.id)})})]})]})}export{De as AdminsPage};
1
+ import{j as e}from"./tanstack-Bs3zYPPV.js";import{u as H,r as x}from"./react-vendor-C2CvUxFh.js";import{u as L,aN as M,aO as q,p as z,aP as V,aQ as G,x as Q,S as b,D as _,i as $,B as l,aR as J,k as K,l as W,m as X,n as Y,I as Z,o as ee,P as se,T as ae,v as i}from"./index-Ce5pmRMj.js";import{u as ie}from"./useAdminResolver-BJNPz3OG.js";import{T as te,a as ne,b as y,c as p,d as re,e as j}from"./table-_3bMY0_z.js";import{P as oe,a as le,b as de}from"./popover-CzaQYEEP.js";import{C as ce,a as me,b as ue,c as he,d as xe,e as pe}from"./command-Bfmj0MEL.js";import{S as je,a as ve,b as ge,c as fe,d as A}from"./select-CrRhFGIi.js";import{u as be}from"./usePageTitle-C1r1-C00.js";import"./radix-C5ZmWuuL.js";function De(){const{host:d}=H(),{user:C}=L(),N=M(),{data:S,isLoading:I}=q(d),{data:T}=z(),c=V(d),m=G(d),n=S?.admins??[],E=T?.items??[],r=N==="admin",v=n.map(s=>s.id),{resolve:w}=ie(v),[P,g]=x.useState(!1),[D,f]=x.useState(!1),[u,h]=x.useState(""),R=Q();if(be({title:"Admins"}),I)return e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{className:"h-8 w-64"}),Array.from({length:3}).map((s,a)=>e.jsx(b,{className:"h-12 w-full"},a))]});const O=E.filter(s=>!v.includes(s.sub));async function U(s){try{await c.mutateAsync({admins:[...n,{id:s,role:"editor"}]}),i.success("Admin added"),g(!1)}catch(a){i.error("Failed to add admin",{description:a instanceof Error?a.message:void 0})}}async function F(s){if(s.preventDefault(),!!u.trim())try{const a=await m.mutateAsync({email:u.trim()});a.existed?i.success("Existing user added to site"):i.success("Invite email sent",{description:`An invite has been sent to ${a.email}`}),h(""),f(!1)}catch(a){i.error("Failed to invite user",{description:a instanceof Error?a.message:void 0})}}async function k(s){try{await c.mutateAsync({admins:n.filter(a=>a.id!==s)}),i.success("Admin removed")}catch(a){i.error("Failed to remove admin",{description:a instanceof Error?a.message:void 0})}}async function B(s,a){const o=n.map(t=>t.id===s?{...t,role:a}:t);if(!o.some(t=>t.role==="admin")){i.error("At least one admin role is required");return}try{await c.mutateAsync({admins:o}),i.success("Role updated")}catch(t){i.error("Failed to update role",{description:t instanceof Error?t.message:void 0})}}return e.jsxs("div",{children:[!R&&e.jsx("h1",{className:"mb-6 text-2xl font-semibold",children:"Admins"}),r&&e.jsxs("div",{className:"mb-6 flex gap-2",children:[e.jsxs(_,{open:D,onOpenChange:s=>{f(s),s||h("")},children:[e.jsx($,{asChild:!0,children:e.jsxs(l,{children:[e.jsx(J,{className:"mr-2 h-4 w-4"}),"Invite by email"]})}),e.jsxs(K,{children:[e.jsxs(W,{children:[e.jsx(X,{children:"Invite User to Site"}),e.jsx(Y,{className:"sr-only",children:"Send an invite email to add a user to this site"})]}),e.jsxs("form",{onSubmit:F,className:"space-y-4",children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:"Enter an email address. If the user doesn't have an account yet, they'll receive an invite email."}),e.jsx(Z,{type:"email",value:u,onChange:s=>h(s.target.value),placeholder:"email@example.com",required:!0}),e.jsx(ee,{children:e.jsx(l,{type:"submit",disabled:m.isPending,children:m.isPending?"Inviting...":"Send Invite"})})]})]})]}),e.jsxs(oe,{open:P,onOpenChange:g,children:[e.jsx(le,{asChild:!0,children:e.jsxs(l,{variant:"outline",children:[e.jsx(se,{className:"mr-2 h-4 w-4"}),"Add existing user"]})}),e.jsx(de,{className:"w-72 p-0",align:"start",children:e.jsxs(ce,{children:[e.jsx(me,{placeholder:"Search users..."}),e.jsxs(ue,{children:[e.jsx(he,{children:"No users found."}),e.jsx(xe,{children:O.map(s=>e.jsx(pe,{value:s.email,onSelect:()=>U(s.sub),children:s.email},s.sub))})]})]})})]})]}),n.length===0?e.jsx("p",{className:"text-muted-foreground",children:"No admins configured."}):e.jsxs(te,{children:[e.jsx(ne,{children:e.jsxs(y,{children:[e.jsx(p,{children:"Email"}),e.jsx(p,{children:"Role"}),r&&e.jsx(p,{})]})}),e.jsx(re,{children:n.map(s=>{const a=s.id===C?.sub;return e.jsxs(y,{children:[e.jsxs(j,{className:"text-sm",children:[w(s.id),a&&e.jsx("span",{className:"ml-2 text-muted-foreground",children:"(you)"})]}),e.jsx(j,{children:r&&!a?e.jsxs(je,{value:s.role,onValueChange:o=>B(s.id,o),children:[e.jsx(ve,{className:"w-28",children:e.jsx(ge,{})}),e.jsxs(fe,{children:[e.jsx(A,{value:"admin",children:"Admin"}),e.jsx(A,{value:"editor",children:"Editor"})]})]}):e.jsx("span",{className:"text-sm capitalize",children:s.role})}),r&&e.jsx(j,{className:"text-right",children:!a&&e.jsx(l,{variant:"ghost",size:"sm",onClick:()=>k(s.id),title:"Remove from site",children:e.jsx(ae,{className:"h-4 w-4"})})})]},s.id)})})]})]})}export{De as AdminsPage};
@@ -1 +1 @@
1
- import{j as s}from"./tanstack-Bs3zYPPV.js";import{u as H,f as F,m as V,r as j}from"./react-vendor-C2CvUxFh.js";import{u as _,a as q,b as G,c as J}from"./useContent-CW0tm0FY.js";import{m as U}from"./media-url-DIg_vSyf.js";import{w as K,x as O,v as u,S as Q,j as g,y as W}from"./index-BA3y7HJs.js";import{u as X}from"./usePageTitle-DYvuJQp6.js";import{C as Y,c as Z}from"./card-CZTHR2Qa.js";import{C as b}from"./checkbox-DEgzM8H9.js";import{T as ee,a as se,b as T,c as h,d as te,e as m}from"./table-Dk7eeOt2.js";import{f as B}from"./format-C88SDH8g.js";import{B as ne}from"./BulkActionBar--35xjnOP.js";import{P as ae}from"./Pagination-CuHwUPHi.js";import"./radix-C5ZmWuuL.js";import"./select-dX9e6VDt.js";function be(){const{host:i}=H(),P=F(),{collections:R}=K(),w=O();X({title:"Recent"});const[x,d]=V(),r=Number(x.get("page"))||1,N=Number(x.get("perPage"))||20,S=j.useMemo(()=>{const e=x.get("after")||"";return e?e.split(","):[]},[x]),[a,c]=j.useState(new Set),p=j.useCallback(()=>{d(e=>{const n=new URLSearchParams(e);return n.delete("page"),n.delete("perPage"),n.delete("after"),n},{replace:!0}),c(new Set)},[d]),L=r>1?S[r-2]:void 0,{data:o,isLoading:D}=_(i,L,N),v=q(i),C=G(i),k=J(i),I=new Map(R.map(e=>[e.name,e.label])),f=o?.items.map(e=>e.contentId)??[],y=f.length>0&&f.every(e=>a.has(e));function A(e){c(n=>{const t=new Set(n);return t.has(e)?t.delete(e):t.add(e),t})}function M(){c(y?new Set:new Set(f))}const z=v.isPending||C.isPending||k.isPending;function $(e){d(n=>{const t=new URLSearchParams(n);return e===1?t.delete("page"):t.set("page",String(e)),t},{replace:!0})}function E(e){d(n=>{const t=new URLSearchParams(n);return t.delete("page"),t.delete("after"),e===20?t.delete("perPage"):t.set("perPage",String(e)),t},{replace:!0}),c(new Set)}return s.jsxs("div",{children:[!w&&s.jsxs("div",{className:"mb-6",children:[s.jsx("h1",{className:"text-2xl font-semibold",children:"All Content"}),s.jsx("p",{className:"text-muted-foreground text-sm",children:"Recently updated content across all collections."})]}),a.size>0&&s.jsx(ne,{selectedCount:a.size,onPublish:async()=>{const e=[...a],t=(await v.mutateAsync(e)).filter(l=>l.status==="rejected").length;t?u.error(`${t} of ${e.length} failed to publish`):u.success(`${e.length} item(s) published`),p()},onUnpublish:async()=>{const e=[...a],t=(await C.mutateAsync(e)).filter(l=>l.status==="rejected").length;t?u.error(`${t} of ${e.length} failed to unpublish`):u.success(`${e.length} item(s) unpublished`),p()},onDelete:async()=>{const e=[...a],t=(await k.mutateAsync(e)).filter(l=>l.status==="rejected").length;t?u.error(`${t} of ${e.length} failed to delete`):u.success(`${e.length} item(s) deleted`),p()},onClear:()=>c(new Set),isPending:z}),D?s.jsx("div",{className:"space-y-2",children:Array.from({length:5}).map((e,n)=>s.jsx(Q,{className:"h-12 w-full"},n))}):o?.items.length?s.jsxs(s.Fragment,{children:[w?s.jsx("div",{className:"grid gap-3","data-testid":"all-content-card-view",children:o.items.map(e=>{const n=e.cover;return s.jsx(Y,{className:W("cursor-pointer gap-0 overflow-hidden py-0 transition-shadow hover:shadow-md",a.has(e.contentId)&&"ring-2 ring-primary"),onClick:()=>P(`/sites/${i}/content/${e.collection}/${e.contentId}?from=recent`),children:s.jsx(Z,{className:"p-3",children:s.jsxs("div",{className:"flex items-start gap-3 min-w-0",children:[n?.url&&s.jsx("img",{src:U(n.url),alt:n.alt??"",className:"h-12 w-12 rounded object-cover flex-shrink-0"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx("span",{className:"font-medium truncate",children:e.title||"Untitled"}),s.jsx(g,{variant:e.publishedAt?"default":"secondary",className:"shrink-0",children:e.publishedAt?"Published":"Draft"})]}),e.slug&&s.jsxs("p",{className:"text-xs text-muted-foreground truncate mt-0.5",children:["/",e.slug]}),s.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[s.jsx(g,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:I.get(e.collection)??e.collection}),s.jsx("span",{className:"text-xs text-muted-foreground",children:e.publishedAt?B(e.publishedAt):"—"})]})]}),s.jsx(b,{checked:a.has(e.contentId),onCheckedChange:()=>A(e.contentId),onClick:t=>t.stopPropagation(),className:"mt-1"})]})})},e.contentId)})}):s.jsxs(ee,{children:[s.jsx(se,{children:s.jsxs(T,{children:[s.jsx(h,{className:"w-10",children:s.jsx(b,{checked:y,onCheckedChange:M,"aria-label":"Select all"})}),s.jsx(h,{children:"Title"}),s.jsx(h,{children:"Slug"}),s.jsx(h,{children:"Collection"}),s.jsx(h,{children:"Status"}),s.jsx(h,{children:"Updated"})]})}),s.jsx(te,{children:o.items.map(e=>s.jsxs(T,{className:"cursor-pointer",onClick:()=>P(`/sites/${i}/content/${e.collection}/${e.contentId}?from=recent`),children:[s.jsx(m,{onClick:n=>n.stopPropagation(),children:s.jsx(b,{checked:a.has(e.contentId),onCheckedChange:()=>A(e.contentId),"aria-label":`Select ${e.title||"Untitled"}`})}),s.jsx(m,{className:"font-medium",children:s.jsxs("div",{className:"flex items-center gap-3",children:[(()=>{const n=e.cover;return n?.url?s.jsx("img",{src:U(n.url),alt:n.alt??"",className:"h-8 w-8 rounded object-cover flex-shrink-0"}):null})(),s.jsx("span",{children:e.title||"Untitled"})]})}),s.jsx(m,{className:"text-muted-foreground text-sm",children:e.slug||"—"}),s.jsx(m,{children:s.jsx(g,{variant:"outline",children:I.get(e.collection)??e.collection})}),s.jsx(m,{children:s.jsx(g,{variant:e.publishedAt?"default":"secondary",children:e.publishedAt?"Published":"Draft"})}),s.jsx(m,{className:"text-muted-foreground",children:e.publishedAt?B(e.publishedAt):"—"})]},e.contentId))})]}),s.jsx(ae,{page:r,hasNext:!!o?.hasMore,hasPrevious:r>1,onNext:()=>{if(o?.items.length){const e=o.items[o.items.length-1].contentId,n=[...S.slice(0,r-1),e];d(t=>{const l=new URLSearchParams(t);return l.set("page",String(r+1)),l.set("after",n.join(",")),l},{replace:!0})}else $(r+1);c(new Set)},onPrevious:()=>{const e=r-1;e<=1?d(n=>{const t=new URLSearchParams(n);return t.delete("page"),t.delete("after"),t},{replace:!0}):$(e),c(new Set)},perPage:N,onPerPageChange:E})]}):s.jsx("p",{className:"text-muted-foreground",children:"No content yet."})]})}export{be as AllContentPage};
1
+ import{j as s}from"./tanstack-Bs3zYPPV.js";import{u as H,f as F,m as V,r as j}from"./react-vendor-C2CvUxFh.js";import{u as _,a as q,b as G,c as J}from"./useContent-Bs7nel7C.js";import{m as U}from"./media-url-DdCoIedP.js";import{w as K,x as O,v as u,S as Q,j as g,y as W}from"./index-Ce5pmRMj.js";import{u as X}from"./usePageTitle-C1r1-C00.js";import{C as Y,c as Z}from"./card-C9hfyHXf.js";import{C as b}from"./checkbox-DVJcwUt1.js";import{T as ee,a as se,b as T,c as h,d as te,e as m}from"./table-_3bMY0_z.js";import{f as B}from"./format-C88SDH8g.js";import{B as ne}from"./BulkActionBar-BxdfUSrN.js";import{P as ae}from"./Pagination-Df9nQ7Z0.js";import"./radix-C5ZmWuuL.js";import"./select-CrRhFGIi.js";function be(){const{host:i}=H(),P=F(),{collections:R}=K(),w=O();X({title:"Recent"});const[x,d]=V(),r=Number(x.get("page"))||1,N=Number(x.get("perPage"))||20,S=j.useMemo(()=>{const e=x.get("after")||"";return e?e.split(","):[]},[x]),[a,c]=j.useState(new Set),p=j.useCallback(()=>{d(e=>{const n=new URLSearchParams(e);return n.delete("page"),n.delete("perPage"),n.delete("after"),n},{replace:!0}),c(new Set)},[d]),L=r>1?S[r-2]:void 0,{data:o,isLoading:D}=_(i,L,N),v=q(i),C=G(i),k=J(i),I=new Map(R.map(e=>[e.name,e.label])),f=o?.items.map(e=>e.contentId)??[],y=f.length>0&&f.every(e=>a.has(e));function A(e){c(n=>{const t=new Set(n);return t.has(e)?t.delete(e):t.add(e),t})}function M(){c(y?new Set:new Set(f))}const z=v.isPending||C.isPending||k.isPending;function $(e){d(n=>{const t=new URLSearchParams(n);return e===1?t.delete("page"):t.set("page",String(e)),t},{replace:!0})}function E(e){d(n=>{const t=new URLSearchParams(n);return t.delete("page"),t.delete("after"),e===20?t.delete("perPage"):t.set("perPage",String(e)),t},{replace:!0}),c(new Set)}return s.jsxs("div",{children:[!w&&s.jsxs("div",{className:"mb-6",children:[s.jsx("h1",{className:"text-2xl font-semibold",children:"All Content"}),s.jsx("p",{className:"text-muted-foreground text-sm",children:"Recently updated content across all collections."})]}),a.size>0&&s.jsx(ne,{selectedCount:a.size,onPublish:async()=>{const e=[...a],t=(await v.mutateAsync(e)).filter(l=>l.status==="rejected").length;t?u.error(`${t} of ${e.length} failed to publish`):u.success(`${e.length} item(s) published`),p()},onUnpublish:async()=>{const e=[...a],t=(await C.mutateAsync(e)).filter(l=>l.status==="rejected").length;t?u.error(`${t} of ${e.length} failed to unpublish`):u.success(`${e.length} item(s) unpublished`),p()},onDelete:async()=>{const e=[...a],t=(await k.mutateAsync(e)).filter(l=>l.status==="rejected").length;t?u.error(`${t} of ${e.length} failed to delete`):u.success(`${e.length} item(s) deleted`),p()},onClear:()=>c(new Set),isPending:z}),D?s.jsx("div",{className:"space-y-2",children:Array.from({length:5}).map((e,n)=>s.jsx(Q,{className:"h-12 w-full"},n))}):o?.items.length?s.jsxs(s.Fragment,{children:[w?s.jsx("div",{className:"grid gap-3","data-testid":"all-content-card-view",children:o.items.map(e=>{const n=e.cover;return s.jsx(Y,{className:W("cursor-pointer gap-0 overflow-hidden py-0 transition-shadow hover:shadow-md",a.has(e.contentId)&&"ring-2 ring-primary"),onClick:()=>P(`/sites/${i}/content/${e.collection}/${e.contentId}?from=recent`),children:s.jsx(Z,{className:"p-3",children:s.jsxs("div",{className:"flex items-start gap-3 min-w-0",children:[n?.url&&s.jsx("img",{src:U(n.url),alt:n.alt??"",className:"h-12 w-12 rounded object-cover flex-shrink-0"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx("span",{className:"font-medium truncate",children:e.title||"Untitled"}),s.jsx(g,{variant:e.publishedAt?"default":"secondary",className:"shrink-0",children:e.publishedAt?"Published":"Draft"})]}),e.slug&&s.jsxs("p",{className:"text-xs text-muted-foreground truncate mt-0.5",children:["/",e.slug]}),s.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[s.jsx(g,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:I.get(e.collection)??e.collection}),s.jsx("span",{className:"text-xs text-muted-foreground",children:e.publishedAt?B(e.publishedAt):"—"})]})]}),s.jsx(b,{checked:a.has(e.contentId),onCheckedChange:()=>A(e.contentId),onClick:t=>t.stopPropagation(),className:"mt-1"})]})})},e.contentId)})}):s.jsxs(ee,{children:[s.jsx(se,{children:s.jsxs(T,{children:[s.jsx(h,{className:"w-10",children:s.jsx(b,{checked:y,onCheckedChange:M,"aria-label":"Select all"})}),s.jsx(h,{children:"Title"}),s.jsx(h,{children:"Slug"}),s.jsx(h,{children:"Collection"}),s.jsx(h,{children:"Status"}),s.jsx(h,{children:"Updated"})]})}),s.jsx(te,{children:o.items.map(e=>s.jsxs(T,{className:"cursor-pointer",onClick:()=>P(`/sites/${i}/content/${e.collection}/${e.contentId}?from=recent`),children:[s.jsx(m,{onClick:n=>n.stopPropagation(),children:s.jsx(b,{checked:a.has(e.contentId),onCheckedChange:()=>A(e.contentId),"aria-label":`Select ${e.title||"Untitled"}`})}),s.jsx(m,{className:"font-medium",children:s.jsxs("div",{className:"flex items-center gap-3",children:[(()=>{const n=e.cover;return n?.url?s.jsx("img",{src:U(n.url),alt:n.alt??"",className:"h-8 w-8 rounded object-cover flex-shrink-0"}):null})(),s.jsx("span",{children:e.title||"Untitled"})]})}),s.jsx(m,{className:"text-muted-foreground text-sm",children:e.slug||"—"}),s.jsx(m,{children:s.jsx(g,{variant:"outline",children:I.get(e.collection)??e.collection})}),s.jsx(m,{children:s.jsx(g,{variant:e.publishedAt?"default":"secondary",children:e.publishedAt?"Published":"Draft"})}),s.jsx(m,{className:"text-muted-foreground",children:e.publishedAt?B(e.publishedAt):"—"})]},e.contentId))})]}),s.jsx(ae,{page:r,hasNext:!!o?.hasMore,hasPrevious:r>1,onNext:()=>{if(o?.items.length){const e=o.items[o.items.length-1].contentId,n=[...S.slice(0,r-1),e];d(t=>{const l=new URLSearchParams(t);return l.set("page",String(r+1)),l.set("after",n.join(",")),l},{replace:!0})}else $(r+1);c(new Set)},onPrevious:()=>{const e=r-1;e<=1?d(n=>{const t=new URLSearchParams(n);return t.delete("page"),t.delete("after"),t},{replace:!0}):$(e),c(new Set)},perPage:N,onPerPageChange:E})]}):s.jsx("p",{className:"text-muted-foreground",children:"No content yet."})]})}export{be as AllContentPage};
@@ -1 +1 @@
1
- import{u as E,a as A,b as K,j as e}from"./tanstack-Bs3zYPPV.js";import{u as O,r as m}from"./react-vendor-C2CvUxFh.js";import{e as f,x as G,B as i,P as g,S as Q,T as R,D,k as I,l as w,m as P,n as T,I as k,ak as $,o as p,L as z,v as x}from"./index-BA3y7HJs.js";import{T as B,a as H,b as C,c as d,d as M,e as u}from"./table-Dk7eeOt2.js";import{f as N}from"./format-C88SDH8g.js";import{u as U}from"./usePageTitle-DYvuJQp6.js";import"./radix-C5ZmWuuL.js";function J(s){const t=f();return E({queryKey:["sites",s,"api-keys"],queryFn:async()=>({items:(await t.apiFetch(`/v1/admin/sites/${s}/api-keys`)).keys}),enabled:!!s})}function Y(s){const t=f(),n=A();return K({mutationFn:l=>t.apiFetch(`/v1/admin/sites/${s}/api-keys`,{method:"POST",body:JSON.stringify(l)}),onSuccess:()=>n.invalidateQueries({queryKey:["sites",s,"api-keys"]})})}function _(s,t){const n=f(),l=A();return K({mutationFn:()=>n.apiFetch(`/v1/admin/sites/${s}/api-keys/${t}`,{method:"DELETE"}),onSuccess:()=>l.invalidateQueries({queryKey:["sites",s,"api-keys"]})})}function ne(){const{host:s}=O(),{data:t,isLoading:n}=J(s),l=Y(s),[h,r]=m.useState(!1),[b,y]=m.useState(""),[o,j]=m.useState(null),[F,v]=m.useState(null),S=G();U({title:"API Keys",actions:e.jsx(i,{size:"sm",onClick:()=>r(!0),children:e.jsx(g,{className:"h-4 w-4"})})});async function L(a){a.preventDefault();try{const c=await l.mutateAsync({label:b});j(c.key),y("")}catch(c){x.error("Failed to create API key",{description:c instanceof Error?c.message:void 0})}}function q(){o&&(navigator.clipboard.writeText(o),x.success("Copied to clipboard"))}return e.jsxs("div",{children:[!S&&e.jsxs("div",{className:"mb-6 flex items-center justify-between",children:[e.jsx("h1",{className:"text-2xl font-semibold",children:"API Keys"}),e.jsxs(i,{onClick:()=>r(!0),children:[e.jsx(g,{className:"mr-2 h-4 w-4"}),"Generate Key"]})]}),n?e.jsx("div",{className:"space-y-2",children:Array.from({length:3}).map((a,c)=>e.jsx(Q,{className:"h-12 w-full"},c))}):t?.items.length?e.jsxs(B,{children:[e.jsx(H,{children:e.jsxs(C,{children:[e.jsx(d,{children:"Label"}),e.jsx(d,{children:"Key ID"}),e.jsx(d,{children:"Created"}),e.jsx(d,{children:"Last Used"}),e.jsx(d,{})]})}),e.jsx(M,{children:t.items.map(a=>e.jsxs(C,{children:[e.jsx(u,{className:"font-medium",children:a.label}),e.jsx(u,{className:"font-mono text-xs",children:a.keyId}),e.jsx(u,{className:"text-muted-foreground",children:N(a.createdAt)}),e.jsx(u,{className:"text-muted-foreground",children:a.lastUsedAt?N(a.lastUsedAt):"Never"}),e.jsx(u,{children:e.jsx(i,{variant:"ghost",size:"sm",onClick:()=>v(a.keyId),children:e.jsx(R,{className:"h-4 w-4"})})})]},a.keyId))})]}):e.jsx("p",{className:"text-muted-foreground",children:"No API keys."}),e.jsx(D,{open:h,onOpenChange:a=>{r(a),a||(j(null),y(""))},children:e.jsxs(I,{children:[e.jsxs(w,{children:[e.jsx(P,{children:o?"API Key Generated":"Generate API Key"}),e.jsx(T,{className:"sr-only",children:"Create a new API key for site access"})]}),o?e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Copy this key now. You won't be able to see it again."}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(k,{value:o,readOnly:!0,className:"font-mono text-xs"}),e.jsx(i,{variant:"outline",size:"icon",onClick:q,children:e.jsx($,{className:"h-4 w-4"})})]}),e.jsx(p,{children:e.jsx(i,{onClick:()=>{r(!1),j(null)},children:"Done"})})]}):e.jsxs("form",{onSubmit:L,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(z,{htmlFor:"key-label",children:"Label"}),e.jsx(k,{id:"key-label",value:b,onChange:a=>y(a.target.value),required:!0,autoFocus:!0})]}),e.jsxs(p,{children:[e.jsx(i,{variant:"outline",onClick:()=>r(!1),children:"Cancel"}),e.jsx(i,{type:"submit",disabled:l.isPending,children:"Generate"})]})]})]})}),e.jsx(V,{host:s,keyId:F,onClose:()=>v(null)})]})}function V({host:s,keyId:t,onClose:n}){const l=_(s,t??"");async function h(){try{await l.mutateAsync(),x.success("API key revoked"),n()}catch(r){x.error("Failed to revoke",{description:r instanceof Error?r.message:void 0})}}return e.jsx(D,{open:!!t,onOpenChange:()=>n(),children:e.jsxs(I,{children:[e.jsxs(w,{children:[e.jsx(P,{children:"Revoke API key?"}),e.jsx(T,{children:"This action cannot be undone. Any applications using this key will lose access."})]}),e.jsxs(p,{children:[e.jsx(i,{variant:"outline",onClick:n,children:"Cancel"}),e.jsx(i,{variant:"destructive",onClick:h,children:"Revoke"})]})]})})}export{ne as ApiKeysPage};
1
+ import{u as E,a as A,b as K,j as e}from"./tanstack-Bs3zYPPV.js";import{u as O,r as m}from"./react-vendor-C2CvUxFh.js";import{e as f,x as G,B as i,P as g,S as Q,T as R,D,k as I,l as w,m as P,n as T,I as k,ak as $,o as p,L as z,v as x}from"./index-Ce5pmRMj.js";import{T as B,a as H,b as C,c as d,d as M,e as u}from"./table-_3bMY0_z.js";import{f as N}from"./format-C88SDH8g.js";import{u as U}from"./usePageTitle-C1r1-C00.js";import"./radix-C5ZmWuuL.js";function J(s){const t=f();return E({queryKey:["sites",s,"api-keys"],queryFn:async()=>({items:(await t.apiFetch(`/v1/admin/sites/${s}/api-keys`)).keys}),enabled:!!s})}function Y(s){const t=f(),n=A();return K({mutationFn:l=>t.apiFetch(`/v1/admin/sites/${s}/api-keys`,{method:"POST",body:JSON.stringify(l)}),onSuccess:()=>n.invalidateQueries({queryKey:["sites",s,"api-keys"]})})}function _(s,t){const n=f(),l=A();return K({mutationFn:()=>n.apiFetch(`/v1/admin/sites/${s}/api-keys/${t}`,{method:"DELETE"}),onSuccess:()=>l.invalidateQueries({queryKey:["sites",s,"api-keys"]})})}function ne(){const{host:s}=O(),{data:t,isLoading:n}=J(s),l=Y(s),[h,r]=m.useState(!1),[b,y]=m.useState(""),[o,j]=m.useState(null),[F,v]=m.useState(null),S=G();U({title:"API Keys",actions:e.jsx(i,{size:"sm",onClick:()=>r(!0),children:e.jsx(g,{className:"h-4 w-4"})})});async function L(a){a.preventDefault();try{const c=await l.mutateAsync({label:b});j(c.key),y("")}catch(c){x.error("Failed to create API key",{description:c instanceof Error?c.message:void 0})}}function q(){o&&(navigator.clipboard.writeText(o),x.success("Copied to clipboard"))}return e.jsxs("div",{children:[!S&&e.jsxs("div",{className:"mb-6 flex items-center justify-between",children:[e.jsx("h1",{className:"text-2xl font-semibold",children:"API Keys"}),e.jsxs(i,{onClick:()=>r(!0),children:[e.jsx(g,{className:"mr-2 h-4 w-4"}),"Generate Key"]})]}),n?e.jsx("div",{className:"space-y-2",children:Array.from({length:3}).map((a,c)=>e.jsx(Q,{className:"h-12 w-full"},c))}):t?.items.length?e.jsxs(B,{children:[e.jsx(H,{children:e.jsxs(C,{children:[e.jsx(d,{children:"Label"}),e.jsx(d,{children:"Key ID"}),e.jsx(d,{children:"Created"}),e.jsx(d,{children:"Last Used"}),e.jsx(d,{})]})}),e.jsx(M,{children:t.items.map(a=>e.jsxs(C,{children:[e.jsx(u,{className:"font-medium",children:a.label}),e.jsx(u,{className:"font-mono text-xs",children:a.keyId}),e.jsx(u,{className:"text-muted-foreground",children:N(a.createdAt)}),e.jsx(u,{className:"text-muted-foreground",children:a.lastUsedAt?N(a.lastUsedAt):"Never"}),e.jsx(u,{children:e.jsx(i,{variant:"ghost",size:"sm",onClick:()=>v(a.keyId),children:e.jsx(R,{className:"h-4 w-4"})})})]},a.keyId))})]}):e.jsx("p",{className:"text-muted-foreground",children:"No API keys."}),e.jsx(D,{open:h,onOpenChange:a=>{r(a),a||(j(null),y(""))},children:e.jsxs(I,{children:[e.jsxs(w,{children:[e.jsx(P,{children:o?"API Key Generated":"Generate API Key"}),e.jsx(T,{className:"sr-only",children:"Create a new API key for site access"})]}),o?e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Copy this key now. You won't be able to see it again."}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(k,{value:o,readOnly:!0,className:"font-mono text-xs"}),e.jsx(i,{variant:"outline",size:"icon",onClick:q,children:e.jsx($,{className:"h-4 w-4"})})]}),e.jsx(p,{children:e.jsx(i,{onClick:()=>{r(!1),j(null)},children:"Done"})})]}):e.jsxs("form",{onSubmit:L,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(z,{htmlFor:"key-label",children:"Label"}),e.jsx(k,{id:"key-label",value:b,onChange:a=>y(a.target.value),required:!0,autoFocus:!0})]}),e.jsxs(p,{children:[e.jsx(i,{variant:"outline",onClick:()=>r(!1),children:"Cancel"}),e.jsx(i,{type:"submit",disabled:l.isPending,children:"Generate"})]})]})]})}),e.jsx(V,{host:s,keyId:F,onClose:()=>v(null)})]})}function V({host:s,keyId:t,onClose:n}){const l=_(s,t??"");async function h(){try{await l.mutateAsync(),x.success("API key revoked"),n()}catch(r){x.error("Failed to revoke",{description:r instanceof Error?r.message:void 0})}}return e.jsx(D,{open:!!t,onOpenChange:()=>n(),children:e.jsxs(I,{children:[e.jsxs(w,{children:[e.jsx(P,{children:"Revoke API key?"}),e.jsx(T,{children:"This action cannot be undone. Any applications using this key will lose access."})]}),e.jsxs(p,{children:[e.jsx(i,{variant:"outline",onClick:n,children:"Cancel"}),e.jsx(i,{variant:"destructive",onClick:h,children:"Revoke"})]})]})})}export{ne as ApiKeysPage};
@@ -1 +1 @@
1
- import{u as q,j as e}from"./tanstack-Bs3zYPPV.js";import{L as $,r as u,u as H,m as z}from"./react-vendor-C2CvUxFh.js";import{e as J,J as X,K as G,M as Q,N as Y,B as Z,ay as ee,S as N,x as te,aS as se,aR as A,aT as ae,aU as le,aV as re,aW as ne,aX as oe,aY as de,aZ as ce,a_ as ie,aq as _,a$ as ue,T as x,a3 as m,aM as me,P as T,b0 as D,an as he,b1 as be,b2 as pe,b3 as xe,a8 as fe,b4 as ge,b5 as je}from"./index-BA3y7HJs.js";import{u as ke}from"./useAdminResolver-Bljb4XGQ.js";import{s as L,T as Ie}from"./serializeToText-Zin3gYPm.js";import{h as R}from"./useContent-CW0tm0FY.js";import{f as B,a as ye}from"./format-C88SDH8g.js";import{S as we,a as Ce,b as Ne,c as Se,d as Pe}from"./select-dX9e6VDt.js";import{T as ve,a as Ue,b as M,c as I,d as Ae,e as y}from"./table-Dk7eeOt2.js";import{u as _e}from"./usePageTitle-DYvuJQp6.js";import{P as Te}from"./Pagination-CuHwUPHi.js";import"./radix-C5ZmWuuL.js";function De(s,l){const r=J(),n=new URLSearchParams;l?.action&&n.set("action",l.action),l?.before&&n.set("before",String(l.before)),n.set("limit",String(l.limit));const c=n.toString();return q({queryKey:["sites",s,"audit",l?.action??"",l?.before??"",l?.limit??""],queryFn:()=>r.apiFetch(`/v1/admin/sites/${s}/audit${c?`?${c}`:""}`),enabled:!!s})}const Le={"content.create":"Content Created","content.update":"Content Updated","content.publish":"Content Published","content.unpublish":"Content Unpublished","content.delete":"Content Deleted","content.schedule":"Content Scheduled","content.unschedule":"Content Unscheduled","content.update_publish_date":"Publish Date Changed","content.discard":"Draft Discarded","media.create":"Media Uploaded","media.update":"Media Updated","media.delete":"Media Deleted","media.bulk":"Bulk Media Operation","media.folder.create":"Folder Created","media.folder.update":"Folder Renamed","media.folder.delete":"Folder Deleted","collection.create":"Collection Created","collection.update":"Collection Updated","collection.delete":"Collection Deleted","blocktype.create":"Block Type Created","blocktype.update":"Block Type Updated","blocktype.delete":"Block Type Deleted","webhook.create":"Webhook Created","webhook.update":"Webhook Updated","webhook.delete":"Webhook Deleted","webhook.rotate_secret":"Webhook Secret Rotated","webhook.retry_delivery":"Delivery Retried","apikey.create":"API Key Created","apikey.revoke":"API Key Revoked","site.archived":"Site Archived","site.unarchived":"Site Unarchived","site.purged":"Site Purged","site_user.create":"User Created","site_user.update":"User Updated","site_user.delete":"User Deleted","site_user.change_email":"User Email Changed","site_user.self_register":"User Self-Registered","site_user.self_update":"User Updated Profile"};function Re(s){return!!s?.blockId&&!!s?.prevBlockId&&!!s?.resourceId}function Me({host:s,details:l}){const r=l.resourceId,n=l.collection??"",{data:c}=ee(s,n),{data:a,isLoading:f}=R(s,r,l.blockId??null),{data:i,isLoading:h}=R(s,r,l.prevBlockId??null),b=u.useMemo(()=>c?.fields??[],[c?.fields]),w=u.useMemo(()=>{if(!a)return[];const g={title:a.title,slug:a.slug,snippet:a.snippet,tags:a.tags};return L(b,a.body??{},g)},[a,b]),C=u.useMemo(()=>{if(!i)return[];const g={title:i.title,slug:i.slug,snippet:i.snippet,tags:i.tags};return L(b,i.body??{},g)},[i,b]);return f||h?e.jsxs("div",{className:"space-y-2","data-testid":"diff-loading",children:[e.jsx(N,{className:"h-6 w-24"}),e.jsx(N,{className:"h-40 w-full"})]}):!a||!i?e.jsx("p",{className:"text-muted-foreground text-sm","data-testid":"diff-unavailable",children:"Version data unavailable."}):e.jsxs("div",{"data-testid":"diff-view",children:[e.jsx("h3",{className:"mb-2 text-sm font-medium",children:"Changes"}),e.jsx(Ie,{left:C,right:w,leftLabel:"Before",rightLabel:"After"})]})}function $e({open:s,onOpenChange:l,event:r,host:n,resolveAdmin:c}){if(!r)return null;const a=r.details,f=Le[r.action]??r.action,i=Re(a),h=a?.resourceType==="content"&&a?.resourceId&&a?.collection?`/sites/${n}/content/${a.collection}/${a.resourceId}`:null;return e.jsx(X,{open:s,onOpenChange:l,children:e.jsxs(G,{className:"w-full overflow-y-auto px-6 sm:max-w-lg","data-testid":"audit-drawer",children:[e.jsx(Q,{children:e.jsx(Y,{children:f})}),e.jsxs("div",{className:"mt-4 space-y-4",children:[e.jsxs("dl",{className:"grid grid-cols-[auto_1fr] gap-x-4 gap-y-2 text-sm",children:[a?.title&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{className:"text-muted-foreground",children:"Resource"}),e.jsx("dd",{className:"font-medium","data-testid":"drawer-resource",children:a.title})]}),a?.collection&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{className:"text-muted-foreground",children:"Collection"}),e.jsx("dd",{children:a.collection})]}),e.jsx("dt",{className:"text-muted-foreground",children:"Admin"}),e.jsx("dd",{children:c(r.adminId)}),e.jsx("dt",{className:"text-muted-foreground",children:"Time"}),e.jsx("dd",{children:B(r.createdAt)}),e.jsx("dt",{className:"text-muted-foreground",children:"Status"}),e.jsx("dd",{children:e.jsx("span",{className:r.status==="success"?"text-green-600":r.status==="failed"?"text-red-600":"text-yellow-600",children:r.status})}),a?.ipAddress&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{className:"text-muted-foreground",children:"IP Address"}),e.jsx("dd",{className:"font-mono text-xs",children:a.ipAddress})]}),a?.extra&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{className:"text-muted-foreground",children:"Details"}),e.jsx("dd",{className:"text-muted-foreground",children:a.extra})]})]}),a&&e.jsxs("details",{className:"text-sm","data-testid":"drawer-json",children:[e.jsx("summary",{className:"text-muted-foreground cursor-pointer select-none",children:"Raw details"}),e.jsx("pre",{className:"bg-muted mt-2 overflow-x-auto rounded p-3 text-xs",children:JSON.stringify(a,null,2)})]}),r.errorMsg&&e.jsx("div",{className:"rounded border border-red-200 bg-red-50 p-3 text-sm text-red-800 dark:border-red-900 dark:bg-red-950 dark:text-red-300","data-testid":"drawer-error",children:r.errorMsg}),h&&e.jsx(Z,{variant:"outline",size:"sm",asChild:!0,children:e.jsx($,{to:h,children:"View content"})}),i&&a&&e.jsx("div",{className:"border-t pt-4",children:e.jsx(Me,{host:n,details:a})}),!i&&a?.resourceType==="content"&&e.jsx("p",{className:"text-muted-foreground text-sm","data-testid":"no-changes",children:"No change comparison available for this event."})]})]})})}const Be={"content.create":{label:"Created content",Icon:T},"content.update":{label:"Updated content",Icon:m},"content.publish":{label:"Published content",Icon:je},"content.unpublish":{label:"Unpublished content",Icon:ge},"content.delete":{label:"Deleted content",Icon:x},"content.schedule":{label:"Scheduled content",Icon:fe},"content.unschedule":{label:"Unscheduled content",Icon:xe},"content.update_publish_date":{label:"Changed publish date",Icon:pe},"content.discard":{label:"Discarded draft",Icon:be},"media.create":{label:"Uploaded media",Icon:he},"media.update":{label:"Updated media",Icon:m},"media.delete":{label:"Deleted media",Icon:x},"media.bulk":{label:"Bulk media operation",Icon:_},"media.folder.create":{label:"Created folder",Icon:D},"media.folder.update":{label:"Renamed folder",Icon:m},"media.folder.delete":{label:"Deleted folder",Icon:x},"collection.create":{label:"Created collection",Icon:D},"collection.update":{label:"Updated collection",Icon:m},"collection.delete":{label:"Deleted collection",Icon:x},"blocktype.create":{label:"Created block type",Icon:T},"blocktype.update":{label:"Updated block type",Icon:m},"blocktype.delete":{label:"Deleted block type",Icon:x},"webhook.create":{label:"Created webhook",Icon:me},"webhook.update":{label:"Updated webhook",Icon:m},"webhook.delete":{label:"Deleted webhook",Icon:x},"webhook.rotate_secret":{label:"Rotated webhook secret",Icon:ue},"webhook.retry_delivery":{label:"Retried delivery",Icon:_},"apikey.create":{label:"Created API key",Icon:ie},"apikey.revoke":{label:"Revoked API key",Icon:ce},"site.archived":{label:"Archived site",Icon:de},"site.unarchived":{label:"Unarchived site",Icon:oe},"site.purged":{label:"Purged site",Icon:ne},"site_user.create":{label:"Created user",Icon:A},"site_user.update":{label:"Updated user",Icon:re},"site_user.delete":{label:"Deleted user",Icon:le},"site_user.change_email":{label:"Changed user email",Icon:ae},"site_user.self_register":{label:"User registered",Icon:A},"site_user.self_update":{label:"User updated profile",Icon:se}},Fe=[{label:"All",value:"all"},{label:"Content",value:"content."},{label:"Media",value:"media."},{label:"Collections",value:"collection."},{label:"Block Types",value:"blocktype."},{label:"Webhooks",value:"webhook."},{label:"API Keys",value:"apikey."},{label:"Sites",value:"site."},{label:"Site Users",value:"site_user."}];function Ee(s){return Be[s]??{label:s,Icon:m}}function Oe(s,l){const r=l.resourceType??l.details?.resourceType,n=l.resourceId??l.details?.resourceId;if(!r||!n)return null;switch(r){case"content":{const c=l.details?.collection;return c?`/sites/${s}/content/${c}/${n}`:`/sites/${s}/content`}case"media":return`/sites/${s}/media`;case"collection":return`/sites/${s}/settings/collections`;case"webhook":return`/sites/${s}/settings/webhooks`;case"site_user":return`/sites/${s}/settings/site-users/${n}`;default:return null}}function Ve({status:s}){const l=s==="success"?"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400":s==="failed"?"bg-red-100 text-red-800 dark:bg-red-900/30 dark:text-red-400":"bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-400";return e.jsx("span",{className:`inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium ${l}`,children:s})}function tt(){const{host:s}=H(),[l,r]=z(),n=Number(l.get("page"))||1,c=Number(l.get("perPage"))||20,[a,f]=u.useState("all"),[i,h]=u.useState(null),[b,w]=u.useState(!1),C=u.useMemo(()=>{const t=l.get("before")||"";return t?t.split(","):[]},[l]),g=n>1&&Number(C[n-2])||0,{data:j,isLoading:F}=De(s,{before:g,limit:c}),E=j?.items.map(t=>t.adminId)??[],{resolve:S}=ke(E),O=te(),V=u.useCallback(t=>{h(t),w(!0)},[]);_e({title:"Audit Log"});const K=u.useCallback(()=>{r(t=>{const d=new URLSearchParams(t);return d.delete("page"),d.delete("perPage"),d.delete("before"),d},{replace:!0})},[r]),P=a!=="all"?j?.items.filter(t=>t.action.startsWith(a)):j?.items;function v(t){r(d=>{const o=new URLSearchParams(d);return t===1?o.delete("page"):o.set("page",String(t)),o},{replace:!0})}function W(t){r(d=>{const o=new URLSearchParams(d);return o.delete("page"),o.delete("before"),t===20?o.delete("perPage"):o.set("perPage",String(t)),o},{replace:!0})}return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-6 flex items-center justify-between gap-4",children:[!O&&e.jsx("h1",{className:"text-2xl font-semibold",children:"Audit Log"}),e.jsxs(we,{value:a,onValueChange:t=>{f(t),K()},children:[e.jsx(Ce,{className:"w-[180px]","data-testid":"action-filter",children:e.jsx(Ne,{placeholder:"Filter by type"})}),e.jsx(Se,{children:Fe.map(t=>e.jsx(Pe,{value:t.value,children:t.label},t.value))})]})]}),F?e.jsx("div",{className:"space-y-2",children:Array.from({length:5}).map((t,d)=>e.jsx(N,{className:"h-12 w-full"},d))}):P?.length?e.jsxs(e.Fragment,{children:[e.jsxs(ve,{children:[e.jsx(Ue,{children:e.jsxs(M,{children:[e.jsx(I,{children:"Action"}),e.jsx(I,{children:"Resource"}),e.jsx(I,{children:"Admin"}),e.jsx(I,{children:"Status"}),e.jsx(I,{children:"Time"})]})}),e.jsx(Ae,{children:P.map(t=>{const{label:d,Icon:o}=Ee(t.action),k=t.details?.title,p=t.details?.collection,U=s?Oe(s,t):null;return e.jsxs(M,{"data-testid":"audit-row",className:"cursor-pointer",onClick:()=>V(t),children:[e.jsx(y,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(o,{className:"text-muted-foreground h-4 w-4 shrink-0"}),e.jsx("span",{className:"font-medium",children:d})]})}),e.jsx(y,{children:k?e.jsxs("div",{className:"flex items-center gap-2",children:[U?e.jsx($,{to:U,className:"text-primary hover:underline",children:k}):e.jsx("span",{children:k}),p&&e.jsx("span",{className:"bg-muted text-muted-foreground rounded px-1.5 py-0.5 text-xs",children:p})]}):e.jsx("span",{className:"text-muted-foreground",children:"-"})}),e.jsx(y,{className:"text-sm",children:S(t.adminId)}),e.jsx(y,{children:e.jsx(Ve,{status:t.status})}),e.jsx(y,{className:"text-muted-foreground",title:B(t.createdAt),children:ye(t.createdAt)})]},t.eventId)})})]}),e.jsx(Te,{page:n,hasNext:!!j?.hasMore,hasPrevious:n>1,onNext:()=>{const t=j?.items;if(t?.length){const d=t[t.length-1].createdAt,o=[...C.slice(0,n-1),String(d)];r(k=>{const p=new URLSearchParams(k);return p.set("page",String(n+1)),p.set("before",o.join(",")),p},{replace:!0})}else v(n+1)},onPrevious:()=>{const t=n-1;t<=1?r(d=>{const o=new URLSearchParams(d);return o.delete("page"),o.delete("before"),o},{replace:!0}):v(t)},perPage:c,onPerPageChange:W})]}):e.jsx("p",{className:"text-muted-foreground",children:"No audit events."}),e.jsx($e,{open:b,onOpenChange:w,event:i,host:s,resolveAdmin:S})]})}export{tt as AuditPage};
1
+ import{u as q,j as e}from"./tanstack-Bs3zYPPV.js";import{L as $,r as u,u as H,m as z}from"./react-vendor-C2CvUxFh.js";import{e as J,J as X,K as G,M as Q,N as Y,B as Z,ay as ee,S as N,x as te,aS as se,aR as A,aT as ae,aU as le,aV as re,aW as ne,aX as oe,aY as de,aZ as ce,a_ as ie,aq as _,a$ as ue,T as x,a3 as m,aM as me,P as T,b0 as D,an as he,b1 as be,b2 as pe,b3 as xe,a8 as fe,b4 as ge,b5 as je}from"./index-Ce5pmRMj.js";import{u as ke}from"./useAdminResolver-BJNPz3OG.js";import{s as L,T as Ie}from"./serializeToText-2VrsuRUh.js";import{h as R}from"./useContent-Bs7nel7C.js";import{f as B,a as ye}from"./format-C88SDH8g.js";import{S as we,a as Ce,b as Ne,c as Se,d as Pe}from"./select-CrRhFGIi.js";import{T as ve,a as Ue,b as M,c as I,d as Ae,e as y}from"./table-_3bMY0_z.js";import{u as _e}from"./usePageTitle-C1r1-C00.js";import{P as Te}from"./Pagination-Df9nQ7Z0.js";import"./radix-C5ZmWuuL.js";function De(s,l){const r=J(),n=new URLSearchParams;l?.action&&n.set("action",l.action),l?.before&&n.set("before",String(l.before)),n.set("limit",String(l.limit));const c=n.toString();return q({queryKey:["sites",s,"audit",l?.action??"",l?.before??"",l?.limit??""],queryFn:()=>r.apiFetch(`/v1/admin/sites/${s}/audit${c?`?${c}`:""}`),enabled:!!s})}const Le={"content.create":"Content Created","content.update":"Content Updated","content.publish":"Content Published","content.unpublish":"Content Unpublished","content.delete":"Content Deleted","content.schedule":"Content Scheduled","content.unschedule":"Content Unscheduled","content.update_publish_date":"Publish Date Changed","content.discard":"Draft Discarded","media.create":"Media Uploaded","media.update":"Media Updated","media.delete":"Media Deleted","media.bulk":"Bulk Media Operation","media.folder.create":"Folder Created","media.folder.update":"Folder Renamed","media.folder.delete":"Folder Deleted","collection.create":"Collection Created","collection.update":"Collection Updated","collection.delete":"Collection Deleted","blocktype.create":"Block Type Created","blocktype.update":"Block Type Updated","blocktype.delete":"Block Type Deleted","webhook.create":"Webhook Created","webhook.update":"Webhook Updated","webhook.delete":"Webhook Deleted","webhook.rotate_secret":"Webhook Secret Rotated","webhook.retry_delivery":"Delivery Retried","apikey.create":"API Key Created","apikey.revoke":"API Key Revoked","site.archived":"Site Archived","site.unarchived":"Site Unarchived","site.purged":"Site Purged","site_user.create":"User Created","site_user.update":"User Updated","site_user.delete":"User Deleted","site_user.change_email":"User Email Changed","site_user.self_register":"User Self-Registered","site_user.self_update":"User Updated Profile"};function Re(s){return!!s?.blockId&&!!s?.prevBlockId&&!!s?.resourceId}function Me({host:s,details:l}){const r=l.resourceId,n=l.collection??"",{data:c}=ee(s,n),{data:a,isLoading:f}=R(s,r,l.blockId??null),{data:i,isLoading:h}=R(s,r,l.prevBlockId??null),b=u.useMemo(()=>c?.fields??[],[c?.fields]),w=u.useMemo(()=>{if(!a)return[];const g={title:a.title,slug:a.slug,snippet:a.snippet,tags:a.tags};return L(b,a.body??{},g)},[a,b]),C=u.useMemo(()=>{if(!i)return[];const g={title:i.title,slug:i.slug,snippet:i.snippet,tags:i.tags};return L(b,i.body??{},g)},[i,b]);return f||h?e.jsxs("div",{className:"space-y-2","data-testid":"diff-loading",children:[e.jsx(N,{className:"h-6 w-24"}),e.jsx(N,{className:"h-40 w-full"})]}):!a||!i?e.jsx("p",{className:"text-muted-foreground text-sm","data-testid":"diff-unavailable",children:"Version data unavailable."}):e.jsxs("div",{"data-testid":"diff-view",children:[e.jsx("h3",{className:"mb-2 text-sm font-medium",children:"Changes"}),e.jsx(Ie,{left:C,right:w,leftLabel:"Before",rightLabel:"After"})]})}function $e({open:s,onOpenChange:l,event:r,host:n,resolveAdmin:c}){if(!r)return null;const a=r.details,f=Le[r.action]??r.action,i=Re(a),h=a?.resourceType==="content"&&a?.resourceId&&a?.collection?`/sites/${n}/content/${a.collection}/${a.resourceId}`:null;return e.jsx(X,{open:s,onOpenChange:l,children:e.jsxs(G,{className:"w-full overflow-y-auto px-6 sm:max-w-lg","data-testid":"audit-drawer",children:[e.jsx(Q,{children:e.jsx(Y,{children:f})}),e.jsxs("div",{className:"mt-4 space-y-4",children:[e.jsxs("dl",{className:"grid grid-cols-[auto_1fr] gap-x-4 gap-y-2 text-sm",children:[a?.title&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{className:"text-muted-foreground",children:"Resource"}),e.jsx("dd",{className:"font-medium","data-testid":"drawer-resource",children:a.title})]}),a?.collection&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{className:"text-muted-foreground",children:"Collection"}),e.jsx("dd",{children:a.collection})]}),e.jsx("dt",{className:"text-muted-foreground",children:"Admin"}),e.jsx("dd",{children:c(r.adminId)}),e.jsx("dt",{className:"text-muted-foreground",children:"Time"}),e.jsx("dd",{children:B(r.createdAt)}),e.jsx("dt",{className:"text-muted-foreground",children:"Status"}),e.jsx("dd",{children:e.jsx("span",{className:r.status==="success"?"text-green-600":r.status==="failed"?"text-red-600":"text-yellow-600",children:r.status})}),a?.ipAddress&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{className:"text-muted-foreground",children:"IP Address"}),e.jsx("dd",{className:"font-mono text-xs",children:a.ipAddress})]}),a?.extra&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{className:"text-muted-foreground",children:"Details"}),e.jsx("dd",{className:"text-muted-foreground",children:a.extra})]})]}),a&&e.jsxs("details",{className:"text-sm","data-testid":"drawer-json",children:[e.jsx("summary",{className:"text-muted-foreground cursor-pointer select-none",children:"Raw details"}),e.jsx("pre",{className:"bg-muted mt-2 overflow-x-auto rounded p-3 text-xs",children:JSON.stringify(a,null,2)})]}),r.errorMsg&&e.jsx("div",{className:"rounded border border-red-200 bg-red-50 p-3 text-sm text-red-800 dark:border-red-900 dark:bg-red-950 dark:text-red-300","data-testid":"drawer-error",children:r.errorMsg}),h&&e.jsx(Z,{variant:"outline",size:"sm",asChild:!0,children:e.jsx($,{to:h,children:"View content"})}),i&&a&&e.jsx("div",{className:"border-t pt-4",children:e.jsx(Me,{host:n,details:a})}),!i&&a?.resourceType==="content"&&e.jsx("p",{className:"text-muted-foreground text-sm","data-testid":"no-changes",children:"No change comparison available for this event."})]})]})})}const Be={"content.create":{label:"Created content",Icon:T},"content.update":{label:"Updated content",Icon:m},"content.publish":{label:"Published content",Icon:je},"content.unpublish":{label:"Unpublished content",Icon:ge},"content.delete":{label:"Deleted content",Icon:x},"content.schedule":{label:"Scheduled content",Icon:fe},"content.unschedule":{label:"Unscheduled content",Icon:xe},"content.update_publish_date":{label:"Changed publish date",Icon:pe},"content.discard":{label:"Discarded draft",Icon:be},"media.create":{label:"Uploaded media",Icon:he},"media.update":{label:"Updated media",Icon:m},"media.delete":{label:"Deleted media",Icon:x},"media.bulk":{label:"Bulk media operation",Icon:_},"media.folder.create":{label:"Created folder",Icon:D},"media.folder.update":{label:"Renamed folder",Icon:m},"media.folder.delete":{label:"Deleted folder",Icon:x},"collection.create":{label:"Created collection",Icon:D},"collection.update":{label:"Updated collection",Icon:m},"collection.delete":{label:"Deleted collection",Icon:x},"blocktype.create":{label:"Created block type",Icon:T},"blocktype.update":{label:"Updated block type",Icon:m},"blocktype.delete":{label:"Deleted block type",Icon:x},"webhook.create":{label:"Created webhook",Icon:me},"webhook.update":{label:"Updated webhook",Icon:m},"webhook.delete":{label:"Deleted webhook",Icon:x},"webhook.rotate_secret":{label:"Rotated webhook secret",Icon:ue},"webhook.retry_delivery":{label:"Retried delivery",Icon:_},"apikey.create":{label:"Created API key",Icon:ie},"apikey.revoke":{label:"Revoked API key",Icon:ce},"site.archived":{label:"Archived site",Icon:de},"site.unarchived":{label:"Unarchived site",Icon:oe},"site.purged":{label:"Purged site",Icon:ne},"site_user.create":{label:"Created user",Icon:A},"site_user.update":{label:"Updated user",Icon:re},"site_user.delete":{label:"Deleted user",Icon:le},"site_user.change_email":{label:"Changed user email",Icon:ae},"site_user.self_register":{label:"User registered",Icon:A},"site_user.self_update":{label:"User updated profile",Icon:se}},Fe=[{label:"All",value:"all"},{label:"Content",value:"content."},{label:"Media",value:"media."},{label:"Collections",value:"collection."},{label:"Block Types",value:"blocktype."},{label:"Webhooks",value:"webhook."},{label:"API Keys",value:"apikey."},{label:"Sites",value:"site."},{label:"Site Users",value:"site_user."}];function Ee(s){return Be[s]??{label:s,Icon:m}}function Oe(s,l){const r=l.resourceType??l.details?.resourceType,n=l.resourceId??l.details?.resourceId;if(!r||!n)return null;switch(r){case"content":{const c=l.details?.collection;return c?`/sites/${s}/content/${c}/${n}`:`/sites/${s}/content`}case"media":return`/sites/${s}/media`;case"collection":return`/sites/${s}/settings/collections`;case"webhook":return`/sites/${s}/settings/webhooks`;case"site_user":return`/sites/${s}/settings/site-users/${n}`;default:return null}}function Ve({status:s}){const l=s==="success"?"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400":s==="failed"?"bg-red-100 text-red-800 dark:bg-red-900/30 dark:text-red-400":"bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-400";return e.jsx("span",{className:`inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium ${l}`,children:s})}function tt(){const{host:s}=H(),[l,r]=z(),n=Number(l.get("page"))||1,c=Number(l.get("perPage"))||20,[a,f]=u.useState("all"),[i,h]=u.useState(null),[b,w]=u.useState(!1),C=u.useMemo(()=>{const t=l.get("before")||"";return t?t.split(","):[]},[l]),g=n>1&&Number(C[n-2])||0,{data:j,isLoading:F}=De(s,{before:g,limit:c}),E=j?.items.map(t=>t.adminId)??[],{resolve:S}=ke(E),O=te(),V=u.useCallback(t=>{h(t),w(!0)},[]);_e({title:"Audit Log"});const K=u.useCallback(()=>{r(t=>{const d=new URLSearchParams(t);return d.delete("page"),d.delete("perPage"),d.delete("before"),d},{replace:!0})},[r]),P=a!=="all"?j?.items.filter(t=>t.action.startsWith(a)):j?.items;function v(t){r(d=>{const o=new URLSearchParams(d);return t===1?o.delete("page"):o.set("page",String(t)),o},{replace:!0})}function W(t){r(d=>{const o=new URLSearchParams(d);return o.delete("page"),o.delete("before"),t===20?o.delete("perPage"):o.set("perPage",String(t)),o},{replace:!0})}return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-6 flex items-center justify-between gap-4",children:[!O&&e.jsx("h1",{className:"text-2xl font-semibold",children:"Audit Log"}),e.jsxs(we,{value:a,onValueChange:t=>{f(t),K()},children:[e.jsx(Ce,{className:"w-[180px]","data-testid":"action-filter",children:e.jsx(Ne,{placeholder:"Filter by type"})}),e.jsx(Se,{children:Fe.map(t=>e.jsx(Pe,{value:t.value,children:t.label},t.value))})]})]}),F?e.jsx("div",{className:"space-y-2",children:Array.from({length:5}).map((t,d)=>e.jsx(N,{className:"h-12 w-full"},d))}):P?.length?e.jsxs(e.Fragment,{children:[e.jsxs(ve,{children:[e.jsx(Ue,{children:e.jsxs(M,{children:[e.jsx(I,{children:"Action"}),e.jsx(I,{children:"Resource"}),e.jsx(I,{children:"Admin"}),e.jsx(I,{children:"Status"}),e.jsx(I,{children:"Time"})]})}),e.jsx(Ae,{children:P.map(t=>{const{label:d,Icon:o}=Ee(t.action),k=t.details?.title,p=t.details?.collection,U=s?Oe(s,t):null;return e.jsxs(M,{"data-testid":"audit-row",className:"cursor-pointer",onClick:()=>V(t),children:[e.jsx(y,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(o,{className:"text-muted-foreground h-4 w-4 shrink-0"}),e.jsx("span",{className:"font-medium",children:d})]})}),e.jsx(y,{children:k?e.jsxs("div",{className:"flex items-center gap-2",children:[U?e.jsx($,{to:U,className:"text-primary hover:underline",children:k}):e.jsx("span",{children:k}),p&&e.jsx("span",{className:"bg-muted text-muted-foreground rounded px-1.5 py-0.5 text-xs",children:p})]}):e.jsx("span",{className:"text-muted-foreground",children:"-"})}),e.jsx(y,{className:"text-sm",children:S(t.adminId)}),e.jsx(y,{children:e.jsx(Ve,{status:t.status})}),e.jsx(y,{className:"text-muted-foreground",title:B(t.createdAt),children:ye(t.createdAt)})]},t.eventId)})})]}),e.jsx(Te,{page:n,hasNext:!!j?.hasMore,hasPrevious:n>1,onNext:()=>{const t=j?.items;if(t?.length){const d=t[t.length-1].createdAt,o=[...C.slice(0,n-1),String(d)];r(k=>{const p=new URLSearchParams(k);return p.set("page",String(n+1)),p.set("before",o.join(",")),p},{replace:!0})}else v(n+1)},onPrevious:()=>{const t=n-1;t<=1?r(d=>{const o=new URLSearchParams(d);return o.delete("page"),o.delete("before"),o},{replace:!0}):v(t)},perPage:c,onPerPageChange:W})]}):e.jsx("p",{className:"text-muted-foreground",children:"No audit events."}),e.jsx($e,{open:b,onOpenChange:w,event:i,host:s,resolveAdmin:S})]})}export{tt as AuditPage};