@redocly/framework-plugin-apigee 0.0.1 → 0.1.0-next.1

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 (44) hide show
  1. package/CHANGELOG.md +64 -0
  2. package/README.md +103 -0
  3. package/lib/.tsbuildinfo +1 -0
  4. package/lib/client/ApigeeTemplate.d.ts +24 -0
  5. package/lib/client/ApigeeTemplate.js +1 -0
  6. package/lib/client/Primitives.d.ts +81 -0
  7. package/lib/client/Primitives.js +420 -0
  8. package/lib/client/api.d.ts +28 -0
  9. package/lib/client/api.js +1 -0
  10. package/lib/client/context.d.ts +12 -0
  11. package/lib/client/context.js +1 -0
  12. package/lib/client/hooks.d.ts +21 -0
  13. package/lib/client/hooks.js +1 -0
  14. package/lib/client/views/AdminView.d.ts +2 -0
  15. package/lib/client/views/AdminView.js +20 -0
  16. package/lib/client/views/AppsView.d.ts +15 -0
  17. package/lib/client/views/AppsView.js +5 -0
  18. package/lib/client/views/Dialogs.d.ts +58 -0
  19. package/lib/client/views/Dialogs.js +9 -0
  20. package/lib/client/views/TeamsView.d.ts +10 -0
  21. package/lib/client/views/TeamsView.js +1 -0
  22. package/lib/config.d.ts +31 -0
  23. package/lib/config.js +1 -0
  24. package/lib/constants.d.ts +37 -0
  25. package/lib/constants.js +1 -0
  26. package/lib/contract.d.ts +195 -0
  27. package/lib/contract.js +1 -0
  28. package/lib/plugin.d.ts +10 -0
  29. package/lib/plugin.js +1 -0
  30. package/lib/server/apigee-types.d.ts +72 -0
  31. package/lib/server/apigee-types.js +0 -0
  32. package/lib/server/client.d.ts +60 -0
  33. package/lib/server/client.js +1 -0
  34. package/lib/server/mappers.d.ts +10 -0
  35. package/lib/server/mappers.js +1 -0
  36. package/lib/server/routes.d.ts +25 -0
  37. package/lib/server/routes.js +1 -0
  38. package/lib/server/service.d.ts +98 -0
  39. package/lib/server/service.js +1 -0
  40. package/lib/server/store.d.ts +38 -0
  41. package/lib/server/store.js +1 -0
  42. package/lib/server/token.d.ts +13 -0
  43. package/lib/server/token.js +2 -0
  44. package/package.json +57 -3
@@ -0,0 +1,20 @@
1
+ var W=function(c,s,u,m){function b(v){return v instanceof u?v:new u(function(h){h(v)})}return new(u||(u=Promise))(function(v,h){function P(a){try{r(m.next(a))}catch(n){h(n)}}function p(a){try{r(m.throw(a))}catch(n){h(n)}}function r(a){a.done?v(a.value):b(a.value).then(P,p)}r((m=m.apply(c,s||[])).next())})};import{Fragment as E,jsx as e,jsxs as i}from"react/jsx-runtime";import{useState as B}from"react";import A from"styled-components";import{Button as _}from"@redocly/theme/components/Button/Button";import{Segmented as F}from"@redocly/theme/components/Segmented/Segmented";import{Tag as y}from"@redocly/theme/components/Tag/Tag";import{breakpoints as H}from"@redocly/theme/core/utils/media-css";import{CDNIcon as V}from"@redocly/theme/icons/CDNIcon/CDNIcon";import{apigeeApi as k}from"../api.js";import{useApigee as G}from"../context.js";import{formatDateTime as C,useAsync as j}from"../hooks.js";import{EmptyState as q,Loading as D,Mono as J,Muted as o,Notice as S,PageHeader as Q,Row as K,Stat as x,Stats as U,StatusTag as X,Table as I,TableWrap as z}from"../Primitives.js";import{ConfirmDialog as Y}from"./Dialogs.js";const Z=A.div`
2
+ margin-bottom: var(--spacing-base);
3
+ `,ee=A.span`
4
+ display: inline-flex;
5
+ align-items: center;
6
+ gap: var(--spacing-xs);
7
+ `,te=A(o)`
8
+ display: inline-block;
9
+ max-width: 200px;
10
+ white-space: normal;
11
+ text-align: left;
12
+ `,ne=A(K)`
13
+ flex-wrap: nowrap;
14
+
15
+ @media (max-width: ${H.small}) {
16
+ > button {
17
+ flex: 1;
18
+ }
19
+ }
20
+ `;function N(c,s){return c.kind==="developer"?{title:c.email,subtitle:"Personal"}:{title:s??c.teamId,subtitle:"Team"}}function ge(){var c,s,u,m,b;const{meta:v}=G(),[h,P]=B("pending"),p=j(()=>k.adminRequests(),"admin-requests"),r=j(()=>k.adminApps(),"admin-apps"),a=j(()=>k.adminAudit(),"admin-audit"),[n,R]=B(null),L=()=>{p.reload(),r.reload(),a.reload()},f=(c=p.data)!==null&&c!==void 0?c:[],w=(s=r.data)!==null&&s!==void 0?s:[],M=w.reduce((t,d)=>t+d.credentials.filter(g=>g.status==="approved").length,0),$=new Set(w.filter(t=>t.owner.kind==="developer").map(t=>t.owner.kind==="developer"&&t.owner.email)).size,O=new Set(w.filter(t=>t.owner.kind==="team").map(t=>t.owner.kind==="team"&&t.owner.teamId)).size;return i("div",{"data-testid":"apigee-admin",children:[e(Q,{title:"Approvals",description:i(E,{children:["Access requests for API products that require manual approval in Apigee organization"," ",e("strong",{children:v.organizationName}),"."]}),actions:e(_,{variant:"outlined",onClick:L,icon:e(V,{name:"arrows-rotate",size:"16px"}),children:"Refresh"})}),i(U,{children:[i(x,{children:[e("strong",{"data-testid":"apigee-stat-pending",children:p.data?f.length:"\u2026"}),e(o,{children:"Pending requests"})]}),i(x,{children:[e("strong",{children:r.data?M:"\u2026"}),e(o,{children:"Approved keys"})]}),i(x,{children:[e("strong",{children:r.data?$:"\u2026"}),e(o,{children:"Developers with apps"})]}),i(x,{children:[e("strong",{children:r.data?O:"\u2026"}),e(o,{children:"Teams with apps"})]})]}),e(Z,{children:e(F,{value:h,onChange:t=>P(t.value),options:[{value:"pending",label:"Pending",element:i(ee,{children:["Pending",f.length>0?e(y,{color:"orange",children:f.length}):null]})},{value:"apps",label:"All apps"},{value:"audit",label:"Audit log"}]})}),h==="pending"?p.loading&&!p.data?e(D,{label:"Loading requests\u2026"}):p.error?e(S,{tone:"danger",children:p.error}):f.length===0?e(q,{icon:"circle-check",title:"Nothing to review",text:"Every request for a manually approved product has been handled."}):e(z,{children:i(I,{"data-testid":"apigee-requests-table",children:[e("thead",{children:i("tr",{children:[e("th",{children:"Requested by"}),e("th",{children:"App"}),e("th",{children:"API product"}),e("th",{children:"Reason"}),e("th",{children:"Requested"}),e("th",{className:"actions"})]})}),e("tbody",{children:f.map(t=>{var d;const g=N(t.owner,t.teamName),l=(d=t.apiProductName)!==null&&d!==void 0?d:t.apiProduct;return i("tr",{"data-testid":"apigee-request-row",children:[i("td",{children:[g.title,e("br",{}),i(o,{children:[g.subtitle,t.requestedBy&&t.requestedBy!==g.title?` \xB7 requested by ${t.requestedBy}`:""]})]}),i("td",{"data-label":"App",children:[t.appName,e("br",{}),e(J,{children:e(o,{children:t.consumerKey})})]}),e("td",{"data-label":"API product",children:e(y,{color:"orange",children:l})}),e("td",{"data-label":"Reason",children:t.note?t.note:e(o,{children:"No reason given"})}),e("td",{"data-label":"Requested",children:C(t.requestedAt)}),e("td",{className:"actions",children:t.canDecide?i(ne,{children:[e(_,{variant:"primary",size:"small",onClick:()=>R({request:t,action:"approve"}),"data-testid":"apigee-approve",children:"Approve"}),e(_,{variant:"outlined",tone:"danger",size:"small",onClick:()=>R({request:t,action:"revoke"}),"data-testid":"apigee-reject",children:"Reject"})]}):i(te,{"data-testid":"apigee-cannot-decide",children:["Only maintainers of ",l," can decide"]})})]},t.id)})})]})}):null,h==="apps"?r.loading&&!r.data?e(D,{label:"Loading apps\u2026"}):r.error?e(S,{tone:"danger",children:r.error}):w.length===0?e(q,{icon:"key",title:"No apps yet",text:"Apps developers register appear here."}):e(z,{children:i(I,{"data-testid":"apigee-admin-apps-table",children:[e("thead",{children:i("tr",{children:[e("th",{children:"App"}),e("th",{children:"Owner"}),e("th",{children:"Keys"}),e("th",{children:"API products"}),e("th",{children:"Created"})]})}),e("tbody",{children:w.map(t=>{const d=N(t.owner,t.teamName),g=[...new Map(t.credentials.flatMap(l=>l.apiProducts).map(l=>[l.id,l])).values()];return i("tr",{children:[i("td",{children:[t.name,t.status==="revoked"?e(y,{color:"red",children:"Revoked"}):null]}),i("td",{"data-label":"Owner",children:[d.title,e("br",{}),e(o,{children:d.subtitle})]}),e("td",{"data-label":"Keys",children:t.credentials.length}),e("td",{"data-label":"API products",children:e(K,{children:g.map(l=>{var T;return e(X,{status:l.status,label:(T=l.name)!==null&&T!==void 0?T:l.id},l.id)})})}),e("td",{"data-label":"Created",children:C(t.createdAt)})]},`${t.owner.kind==="team"?t.owner.teamId:t.owner.email}:${t.id}`)})})]})}):null,h==="audit"?a.loading&&!a.data?e(D,{label:"Loading the audit log\u2026"}):a.error?e(S,{tone:"danger",children:a.error}):((u=a.data)!==null&&u!==void 0?u:[]).length===0?e(q,{icon:"file-lines",title:"No decisions yet",text:"Approvals and rejections made here are recorded with who made them."}):e(z,{children:i(I,{"data-testid":"apigee-audit-table",children:[e("thead",{children:i("tr",{children:[e("th",{children:"When"}),e("th",{children:"Reviewer"}),e("th",{children:"Action"}),e("th",{children:"Target"})]})}),e("tbody",{children:((m=a.data)!==null&&m!==void 0?m:[]).map(t=>{var d;return i("tr",{children:[e("td",{children:C(t.at)}),e("td",{"data-label":"Reviewer",children:t.actor}),e("td",{"data-label":"Action",children:e(y,{color:t.action==="approve"?"green":"red",children:t.action==="approve"?"Approved":"Rejected"})}),i("td",{"data-label":"Target",children:[(d=t.apiProductName)!==null&&d!==void 0?d:t.apiProduct," \xB7 ",t.appName," (",N(t.owner,t.teamName).title,")",t.note?i(o,{children:[" \u2014 \u201C",t.note,"\u201D"]}):null]})]},t.id)})})]})}):null,e(Y,{open:n!==null,onClose:()=>R(null),title:n?.action==="approve"?"Approve access?":"Reject request?",confirmLabel:n?.action==="approve"?"Approve":"Reject",danger:n?.action==="revoke",withNote:!0,noteLabel:"Comment for the developer",notePlaceholder:n?.action==="approve"?"Anything the developer should know before they start":"Why the request is rejected and what would change the decision",onConfirm:t=>W(this,void 0,void 0,function*(){return n&&(yield k.adminDecide(n.request.id,n.action,t),L()),!0}),children:n?i("p",{children:[e("strong",{children:(b=n.request.apiProductName)!==null&&b!==void 0?b:n.request.apiProduct})," for"," ",e("strong",{children:n.request.appName})," (",N(n.request.owner,n.request.teamName).title,").",n.action==="approve"?" The key starts working for this product right away.":" The product stays revoked on this key until it is approved later."]}):null})]})}export{ge as AdminView};
@@ -0,0 +1,15 @@
1
+ import type { ReactElement } from 'react';
2
+ import type { ApiProduct, App, Team } from '../../contract.js';
3
+ export type AppSelection = {
4
+ appId: string;
5
+ teamId?: string;
6
+ } | null;
7
+ export declare function AppsView({ selection, teams, products, }: {
8
+ selection: AppSelection;
9
+ teams: Team[];
10
+ products: ApiProduct[];
11
+ }): ReactElement;
12
+ export declare function AppRow({ app, to }: {
13
+ app: App;
14
+ to: string;
15
+ }): ReactElement;
@@ -0,0 +1,5 @@
1
+ var K=function(n,l,r,d){function u(h){return h instanceof r?h:new r(function(f){f(h)})}return new(r||(r=Promise))(function(h,f){function g(s){try{v(d.next(s))}catch(y){f(y)}}function p(s){try{v(d.throw(s))}catch(y){f(y)}}function v(s){s.done?h(s.value):u(s.value).then(g,p)}v((d=d.apply(n,l||[])).next())})};import{Fragment as z,jsx as e,jsxs as a}from"react/jsx-runtime";import{useEffect as G,useMemo as j,useState as w}from"react";import{useNavigate as V}from"react-router";import W from"styled-components";import{Button as b}from"@redocly/theme/components/Button/Button";import{Dropdown as J}from"@redocly/theme/components/Dropdown/Dropdown";import{DropdownMenu as Q}from"@redocly/theme/components/Dropdown/DropdownMenu";import{Tag as B}from"@redocly/theme/components/Tag/Tag";import{Tooltip as X}from"@redocly/theme/components/Tooltip/Tooltip";import{CDNIcon as k}from"@redocly/theme/icons/CDNIcon/CDNIcon";import{apigeeApi as A}from"../api.js";import{useApigee as Y}from"../context.js";import{maskKey as Z}from"../../contract.js";import{copyText as ee,formatDate as R,useAsync as te}from"../hooks.js";import{EmptyState as E,LinkList as ne,LinkRow as ie,ListTitle as oe,Loading as re,Mono as M,Muted as x,Notice as L,Overview as ae,PageBreadcrumbs as de,PageHeader as U,Row as N,Section as le,SectionHeader as se,SectionTitle as ce,StatusTag as H,Table as ue,TableWrap as pe}from"../Primitives.js";import{AppDialog as O,ConfirmDialog as F,KeyDialog as me}from"./Dialogs.js";function he(n,l){var r,d;return n.kind==="developer"?"Personal":`Team \xB7 ${(d=(r=l.find(u=>u.id===n.teamId))===null||r===void 0?void 0:r.name)!==null&&d!==void 0?d:n.teamId}`}function ve(n){if(n.status==="revoked")return{color:"red",label:"Revoked"};const l=n.credentials.flatMap(u=>u.apiProducts);if(l.length===0)return{color:"grey",label:"No API products"};if(l.some(u=>u.status==="pending"))return{color:"orange",label:"Pending approval"};const r=new Set(l.map(u=>u.id)).size,d=new Set(l.filter(u=>u.status==="approved").map(u=>u.id)).size;return d===r?{color:"green",label:"Approved"}:d===0?{color:"red",label:"Rejected"}:{color:"blue",label:`${d} of ${r} approved`}}function q(n){if(n.status!=="approved")return n.status;const{apiProducts:l}=n;return l.some(r=>r.status==="pending")?"pending":l.length>0&&l.every(r=>r.status==="revoked")?"revoked":"approved"}function Le({selection:n,teams:l,products:r}){var d,u;const{link:h,title:f}=Y(),g=V(),p=te(()=>A.listApps(),"apps"),[v,s]=w(null);G(()=>{var i,t;const c=new URLSearchParams(window.location.search);c.has("createApp")&&(s({product:(i=c.get("apiProduct"))!==null&&i!==void 0?i:void 0,teamId:(t=c.get("team"))!==null&&t!==void 0?t:void 0}),g(h(),{replace:!0}))},[h,g]);const y=j(()=>{var i;return!n||!p.data?null:(i=p.data.find(t=>t.id===n.appId&&(n.teamId?t.owner.kind==="team"&&t.owner.teamId===n.teamId:t.owner.kind==="developer")))!==null&&i!==void 0?i:null},[p.data,n]),I=j(()=>{var i;const t=((i=p.data)!==null&&i!==void 0?i:[]).filter(o=>o.owner.kind==="developer"),c=l.map(o=>{var m;return{team:o,apps:((m=p.data)!==null&&m!==void 0?m:[]).filter(C=>C.owner.kind==="team"&&C.owner.teamId===o.id)}});return{personal:t,byTeam:c}},[p.data,l]),P=i=>h(`/${encodeURIComponent(i.id)}`,i.owner.kind==="team"?{team:i.owner.teamId}:void 0),$=i=>K(this,void 0,void 0,function*(){const t=yield A.createApp(i);return p.reload(),g(P(t)),t});if(p.loading&&!p.data)return e(re,{label:"Loading your apps\u2026"});if(p.error)return e(L,{tone:"danger",children:p.error});const D=(d=p.data)!==null&&d!==void 0?d:[],S=e(O,{open:v!==null,onClose:()=>s(null),onSubmit:$,products:r,teams:l,initialProduct:v?.product,initialTeamId:v?.teamId}),_=e(b,{variant:"primary",onClick:()=>s({}),icon:e(k,{name:"plus",size:"16px"}),"data-testid":"apigee-new-app",children:"New app"});if(n)return a(z,{children:[e(de,{additionalBreadcrumbs:[{label:f,link:h()},{label:(u=y?.name)!==null&&u!==void 0?u:n.appId}]}),y?e(ge,{app:y,teams:l,products:r,onChanged:()=>p.reload(),onDeleted:()=>{p.reload(),g(h())}}):e(L,{tone:"danger",children:"App not found"}),S]});const T=[{key:"personal",title:"Personal",apps:I.personal},...I.byTeam.map(({team:i,apps:t})=>({key:`team:${i.id}`,title:`Team \xB7 ${i.name}`,apps:t}))].filter(i=>i.apps.length>0);return a(z,{children:[e(U,{title:f,description:"Register apps and manage the API keys that call the APIs through Apigee.",actions:D.length>0?_:void 0}),D.length===0?e(E,{icon:"key",title:"Create your first app",text:"An app holds the API keys your software sends. Pick the API products it needs; the keys for approved products work right away.",action:_}):e(ye,{"data-testid":"apigee-app-list",children:T.map(i=>a("div",{children:[e(oe,{children:i.title}),e(ne,{children:i.apps.map(t=>e(fe,{app:t,to:P(t)},t.id))})]},i.key))}),S]})}const ye=W.div`
2
+ display: flex;
3
+ flex-direction: column;
4
+ gap: var(--spacing-lg);
5
+ `;function fe({app:n,to:l}){const r=n.credentials.length,d=ve(n);return e(ie,{to:l,title:n.name,subtitle:`${r} ${r===1?"key":"keys"}${n.description?` \xB7 ${n.description}`:""}`,tag:e(B,{color:d.color,textTransform:"none",children:d.label}),testId:"apigee-app-row"})}function ge({app:n,teams:l,products:r,onChanged:d,onDeleted:u}){const h=n.owner.kind==="team"?n.owner.teamId:void 0,[f,g]=w(!1),[p,v]=w(!1),[s,y]=w(null),[I,P]=w(null),[$,D]=w(new Set),[S,_]=w(null),T=(t,c)=>K(this,void 0,void 0,function*(){(yield ee(t))&&(_(c),setTimeout(()=>_(null),1500))}),i=t=>{var c,o;return(o=(c=r.find(m=>m.id===t))===null||c===void 0?void 0:c.name)!==null&&o!==void 0?o:t};return a("div",{"data-testid":"apigee-app-detail",children:[e(U,{title:a(z,{children:[n.name,n.status==="revoked"?e(B,{color:"red",children:"Revoked"}):null]}),description:n.description||void 0,actions:a(z,{children:[e(b,{variant:"outlined",onClick:()=>g(!0),icon:e(k,{name:"pen",size:"16px"}),"data-testid":"apigee-edit-app",children:"Edit"}),e(X,{tip:"Delete app",placement:"bottom",children:e(b,{variant:"outlined",tone:"danger","aria-label":"Delete app",icon:e(k,{name:"trash-can",size:"16px"}),onClick:()=>v(!0),"data-testid":"apigee-delete-app"})})]})}),a(ae,{children:[a("div",{children:[e("dt",{children:"Owner"}),a("dd",{children:[e(k,{name:n.owner.kind==="team"?"user-group":"user",size:"16px"}),he(n.owner,l)]})]}),a("div",{children:[e("dt",{children:"Created"}),e("dd",{children:R(n.createdAt)})]}),a("div",{className:"wide",children:[e("dt",{children:"Callback URL"}),e("dd",{children:n.callbackUrl||e(x,{children:"Not set"})})]})]}),a(le,{children:[a(se,{children:[e(ce,{children:"API keys"}),e(b,{variant:"outlined",size:"small",onClick:()=>y({}),icon:e(k,{name:"plus",size:"14px"}),"data-testid":"apigee-create-key",children:"Create key"})]}),n.credentials.length===0?e(E,{icon:"key",title:"No keys yet",text:"Create a key and pick the API products it may call."}):e(pe,{children:a(ue,{"data-testid":"apigee-keys-table",children:[e("thead",{children:a("tr",{children:[e("th",{children:"Key"}),e("th",{children:"API products"}),e("th",{children:"Status"}),e("th",{className:"actions"})]})}),e("tbody",{children:n.credentials.map(t=>{const c=$.has(t.consumerKey);return a("tr",{"data-testid":"apigee-key-row",children:[a("td",{className:"key",children:[a(N,{children:[e(M,{"data-testid":"apigee-key-value",children:c?t.consumerKey:Z(t.consumerKey)}),e(b,{variant:"text",size:"small","aria-label":c?"Hide key":"Reveal key",icon:e(k,{name:c?"eye-slash":"eye",size:"14px"}),onClick:()=>D(o=>{const m=new Set(o);return m.has(t.consumerKey)?m.delete(t.consumerKey):m.add(t.consumerKey),m})}),e(b,{variant:"text",size:"small","aria-label":"Copy key",icon:e(k,{name:"copy",size:"14px"}),onClick:()=>T(t.consumerKey,`key:${t.consumerKey}`)}),S===`key:${t.consumerKey}`?e(x,{children:"Copied"}):null]}),t.consumerSecret?a(N,{children:[e(x,{children:"Secret"}),e(M,{children:c?t.consumerSecret:"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022"}),e(b,{variant:"text",size:"small","aria-label":"Copy secret",icon:e(k,{name:"copy",size:"14px"}),onClick:()=>{var o;return T((o=t.consumerSecret)!==null&&o!==void 0?o:"",`secret:${t.consumerKey}`)}}),S===`secret:${t.consumerKey}`?e(x,{children:"Copied"}):null]}):null,a(x,{children:["Issued ",R(t.issuedAt)," \xB7 Expires"," ",t.expiresAt?R(t.expiresAt):"never"]})]}),a("td",{"data-label":"API products",children:[a(N,{children:[t.apiProducts.length===0?e(x,{children:"None"}):null,t.apiProducts.map(o=>e(H,{status:o.status,label:o.status==="approved"?i(o.id):`${i(o.id)} \xB7 ${o.status}`},o.id))]}),t.apiProducts.filter(o=>{var m;return(m=o.decision)===null||m===void 0?void 0:m.note}).map(o=>{var m,C;return a(x,{as:"div","data-testid":"apigee-decision-note",children:[((m=o.decision)===null||m===void 0?void 0:m.action)==="approve"?"Approved":"Rejected"," \xB7"," ",i(o.id),": \u201C",(C=o.decision)===null||C===void 0?void 0:C.note,"\u201D"]},o.id)})]}),e("td",{"data-label":"Status",children:e(H,{status:q(t)})}),e("td",{className:"actions menu",children:e(J,{trigger:e(b,{variant:"text",size:"small","aria-label":"Key actions",icon:e(k,{name:"ellipsis-vertical",size:"14px"}),"data-testid":"apigee-key-menu"}),alignment:"end",portalled:!0,children:e(Q,{items:[{content:"Edit API products",onAction:()=>y({consumerKey:t.consumerKey,products:t.apiProducts.map(o=>o.id)}),dataAttributes:{"data-testid":"apigee-edit-key"}},{content:"Delete key",dangerous:!0,separatorLine:!0,onAction:()=>P(t.consumerKey),dataAttributes:{"data-testid":"apigee-delete-key"}}]})})})]},t.consumerKey)})})]})}),n.credentials.some(t=>q(t)==="approved")?e("div",{style:{marginTop:"var(--spacing-base)"},children:a(L,{tone:"info",children:[e("strong",{children:"Keys are picked up by Try it."})," Open an operation of an approved API product in the API reference and the key is already filled in."]})}):null]}),e(O,{open:f,onClose:()=>g(!1),onSubmit:t=>K(this,void 0,void 0,function*(){const c=yield A.updateApp(n.id,t,h);return d(),c}),products:r,teams:l,initial:n}),e(me,{open:s!==null,onClose:()=>y(null),onSubmit:t=>K(this,void 0,void 0,function*(){const c=s?.consumerKey?yield A.updateKey(n.id,s.consumerKey,t,h):yield A.createKey(n.id,t,h);return d(),c}),products:r,initial:s?.products}),e(F,{open:p,onClose:()=>v(!1),title:"Delete app?",confirmLabel:"Delete app",danger:!0,onConfirm:()=>K(this,void 0,void 0,function*(){return yield A.deleteApp(n.id,h),u(),!0}),children:a("p",{children:[e("strong",{children:n.name})," and all of its keys stop working immediately. This cannot be undone."]})}),e(F,{open:I!==null,onClose:()=>P(null),title:"Delete key?",confirmLabel:"Delete key",danger:!0,onConfirm:()=>K(this,void 0,void 0,function*(){return I&&(yield A.deleteKey(n.id,I,h)),d(),!0}),children:e("p",{children:"Requests that send this key are rejected from now on. This cannot be undone."})})]})}export{fe as AppRow,Le as AppsView};
@@ -0,0 +1,58 @@
1
+ import { type ReactElement, type ReactNode } from 'react';
2
+ import type { SelectOption } from '@redocly/theme/core/types';
3
+ import type { ApiProduct, App, AppInput, KeyInput, Team, TeamInput, TeamMemberInput, TeamRole } from '../../contract.js';
4
+ export declare const ROLE_OPTIONS: SelectOption<TeamRole>[];
5
+ type AppDialogProps = {
6
+ onClose: () => void;
7
+ onSubmit: (input: AppInput) => Promise<unknown>;
8
+ products: ApiProduct[];
9
+ teams: Team[];
10
+ /** The app being edited; a new app otherwise. */
11
+ initial?: App;
12
+ initialProduct?: string;
13
+ initialTeamId?: string;
14
+ };
15
+ export declare function AppDialog({ open, ...props }: AppDialogProps & {
16
+ open: boolean;
17
+ }): ReactElement | null;
18
+ type KeyDialogProps = {
19
+ onClose: () => void;
20
+ onSubmit: (input: KeyInput) => Promise<unknown>;
21
+ products: ApiProduct[];
22
+ /** The products already on the key being edited; a new key otherwise. */
23
+ initial?: string[];
24
+ };
25
+ export declare function KeyDialog({ open, ...props }: KeyDialogProps & {
26
+ open: boolean;
27
+ }): ReactElement | null;
28
+ type TeamDialogProps = {
29
+ onClose: () => void;
30
+ onSubmit: (input: TeamInput) => Promise<unknown>;
31
+ initial?: Team;
32
+ };
33
+ export declare function TeamDialog({ open, ...props }: TeamDialogProps & {
34
+ open: boolean;
35
+ }): ReactElement | null;
36
+ type MemberDialogProps = {
37
+ onClose: () => void;
38
+ onSubmit: (input: TeamMemberInput) => Promise<unknown>;
39
+ };
40
+ export declare function MemberDialog({ open, ...props }: MemberDialogProps & {
41
+ open: boolean;
42
+ }): ReactElement | null;
43
+ type ConfirmDialogProps = {
44
+ onClose: () => void;
45
+ onConfirm: (note?: string) => Promise<unknown>;
46
+ title: ReactNode;
47
+ children?: ReactNode;
48
+ confirmLabel: string;
49
+ danger?: boolean;
50
+ /** Offers a note field, for a decision the other side should hear the reason for. */
51
+ withNote?: boolean;
52
+ noteLabel?: string;
53
+ notePlaceholder?: string;
54
+ };
55
+ export declare function ConfirmDialog({ open, ...props }: ConfirmDialogProps & {
56
+ open: boolean;
57
+ }): ReactElement | null;
58
+ export {};
@@ -0,0 +1,9 @@
1
+ var O=function(t,o,n,r){function a(s){return s instanceof n?s:new n(function(d){d(s)})}return new(n||(n=Promise))(function(s,d){function i(c){try{p(r.next(c))}catch(h){d(h)}}function u(c){try{p(r.throw(c))}catch(h){d(h)}}function p(c){c.done?s(c.value):a(c.value).then(i,u)}p((r=r.apply(t,o||[])).next())})},x=function(t,o){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&o.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,r=Object.getOwnPropertySymbols(t);a<r.length;a++)o.indexOf(r[a])<0&&Object.prototype.propertyIsEnumerable.call(t,r[a])&&(n[r[a]]=t[r[a]]);return n};import{Fragment as I,jsx as e,jsxs as l}from"react/jsx-runtime";import{useState as m}from"react";import q from"styled-components";import{Button as b}from"@redocly/theme/components/Button/Button";import{Select as E}from"@redocly/theme/components/Select/Select";import{Tag as z}from"@redocly/theme/components/Tag/Tag";import{useMutation as D}from"../hooks.js";import{CheckItem as Q,CheckItemTitle as G,CheckList as J,Dialog as T,Field as f,FieldLabel as C,Input as j,Muted as y,Notice as P,RequiredLabel as F,Textarea as S}from"../Primitives.js";const V=[{value:"member",element:"Member"},{value:"owner",element:"Owner"}],X=8,Y=q.div`
2
+ display: flex;
3
+ align-items: baseline;
4
+ justify-content: space-between;
5
+ gap: var(--spacing-sm);
6
+ `,Z=q(J)`
7
+ max-height: 320px;
8
+ overflow-y: auto;
9
+ `;function R({products:t,selected:o,onChange:n}){const[r,a]=m(""),s=r.trim().toLowerCase(),d=t.filter(i=>`${i.name} ${i.description}`.toLowerCase().includes(s));return l(f,{as:"div",children:[l(Y,{children:[e(C,{children:"API products"}),t.length>0?l(y,{"data-testid":"apigee-product-count",children:[o.length," selected"]}):null]}),t.length===0?e(y,{children:"No API products are available to you yet."}):null,t.length>X?e(j,{type:"search",value:r,onChange:i=>a(i.target.value),placeholder:"Search API products","aria-label":"Search API products","data-testid":"apigee-product-search"}):null,t.length>0&&d.length===0?l(y,{children:["No API products match \u201C",r.trim(),"\u201D."]}):null,d.length>0?e(Z,{"data-testid":"apigee-product-picker",children:d.map(i=>{const u=o.includes(i.id);return l(Q,{$checked:u,children:[e("input",{type:"checkbox",checked:u,onChange:p=>n(p.target.checked?[...o,i.id]:o.filter(c=>c!==i.id))}),l("span",{children:[l(G,{children:[i.name,e(z,{color:i.approvalType==="manual"?"orange":"grey",children:i.approvalType==="manual"?"requires approval":"auto-approved"})]}),i.description?e(y,{children:i.description}):null]})]},i.id)})}):null]})}function U(t,o){return t.some(n=>o.includes(n.id)&&n.approvalType==="manual")}function he(t){var{open:o}=t,n=x(t,["open"]);return o?e(ee,Object.assign({},n)):null}function ee({onClose:t,onSubmit:o,products:n,teams:r,initial:a,initialProduct:s,initialTeamId:d}){var i,u,p;const c=!!a,[h,g]=m((i=a?.name)!==null&&i!==void 0?i:""),[k,M]=m((u=a?.description)!==null&&u!==void 0?u:""),[L,W]=m((p=a?.callbackUrl)!==null&&p!==void 0?p:""),[N,H]=m(a?.owner.kind==="team"?a.owner.teamId:d??""),[_,$]=m(s?[s]:[]),[A,B]=m(""),w=D(),K=()=>O(this,void 0,void 0,function*(){(yield w.run(()=>o(Object.assign(Object.assign({name:h.trim(),description:k.trim(),callbackUrl:L.trim(),apiProducts:_},A.trim()?{note:A.trim()}:{}),N?{teamId:N}:{}))))!==void 0&&t()});return l(T,{open:!0,onClose:t,wide:!0,title:c?"Edit app":"New app",testId:"apigee-app-dialog",footer:l(I,{children:[e(b,{variant:"outlined",onClick:t,disabled:w.pending,children:"Cancel"}),e(b,{variant:"primary",onClick:K,disabled:w.pending||!h.trim(),"data-testid":"apigee-app-submit",children:c?"Save":"Create app"})]}),children:[w.error?e(P,{tone:"danger",children:w.error}):null,l(f,{children:[e(F,{children:"Name"}),e(j,{value:h,onChange:v=>g(v.target.value),placeholder:"Ticketing kiosk",required:!0,autoFocus:!0,"data-testid":"apigee-app-name"}),c?null:e(y,{children:"Letters, digits, spaces, dots, dashes and underscores. The name cannot change later."})]}),!c&&r.length>0?l(f,{as:"div",children:[e(C,{children:"Owner"}),e(E,{value:N,options:[{value:"",element:"Personal"},...r.map(v=>({value:v.id,element:`Team \xB7 ${v.name}`}))],onChange:v=>H(v),dataTestId:"apigee-app-owner"}),e(y,{children:"Team apps are shared with every member of the team."})]}):null,c?null:e(R,{products:n,selected:_,onChange:$}),!c&&U(n,_)?l(f,{children:[e(C,{children:"Why do you need access?"}),e(S,{value:A,onChange:v=>B(v.target.value),placeholder:"Sent to the reviewers of the request","data-testid":"apigee-app-note"})]}):null,l(f,{children:[e(C,{children:"Description"}),e(S,{value:k,onChange:v=>M(v.target.value),placeholder:"What does this app do?"})]}),l(f,{children:[e(C,{children:"Callback URL"}),e(j,{value:L,onChange:v=>W(v.target.value),placeholder:"https://example.com/oauth/callback"}),e(y,{children:"Where OAuth 2.0 authorization codes are sent. Separate several URLs with commas."})]})]})}function me(t){var{open:o}=t,n=x(t,["open"]);return o?e(te,Object.assign({},n)):null}function te({onClose:t,onSubmit:o,products:n,initial:r}){const a=r!==void 0,[s,d]=m(r??[]),[i,u]=m(""),p=D(),c=s.filter(g=>!(r??[]).includes(g)),h=()=>O(this,void 0,void 0,function*(){(yield p.run(()=>o(Object.assign({apiProducts:s},i.trim()?{note:i.trim()}:{}))))!==void 0&&t()});return l(T,{open:!0,onClose:t,wide:!0,title:a?"Edit API products":"Create key",testId:"apigee-key-dialog",footer:l(I,{children:[e(b,{variant:"outlined",onClick:t,disabled:p.pending,children:"Cancel"}),e(b,{variant:"primary",onClick:h,disabled:p.pending,"data-testid":"apigee-key-submit",children:a?"Save":"Create key"})]}),children:[p.error?e(P,{tone:"danger",children:p.error}):null,e(R,{products:n,selected:s,onChange:d}),U(n,c)?l(f,{children:[e(C,{children:"Why do you need access?"}),e(S,{value:i,onChange:g=>u(g.target.value),placeholder:"Sent to the reviewers of the request"})]}):null]})}function ge(t){var{open:o}=t,n=x(t,["open"]);return o?e(ne,Object.assign({},n)):null}function ne({onClose:t,onSubmit:o,initial:n}){var r,a;const s=!!n,[d,i]=m((r=n?.name)!==null&&r!==void 0?r:""),[u,p]=m((a=n?.description)!==null&&a!==void 0?a:""),c=D(),h=()=>O(this,void 0,void 0,function*(){(yield c.run(()=>o({name:d.trim(),description:u.trim()})))!==void 0&&t()});return l(T,{open:!0,onClose:t,title:s?"Edit team":"New team",testId:"apigee-team-dialog",footer:l(I,{children:[e(b,{variant:"outlined",onClick:t,disabled:c.pending,children:"Cancel"}),e(b,{variant:"primary",onClick:h,disabled:c.pending||!d.trim(),"data-testid":"apigee-team-submit",children:s?"Save":"Create team"})]}),children:[c.error?e(P,{tone:"danger",children:c.error}):null,l(f,{children:[e(F,{children:"Name"}),e(j,{value:d,onChange:g=>i(g.target.value),placeholder:"Platform squad",required:!0,autoFocus:!0,"data-testid":"apigee-team-name"}),s?null:e(y,{children:"The identifier of the team in Apigee comes from the name and cannot change later."})]}),l(f,{children:[e(C,{children:"Description"}),e(S,{value:u,onChange:g=>p(g.target.value),placeholder:"What does this team build?"})]})]})}function ve(t){var{open:o}=t,n=x(t,["open"]);return o?e(re,Object.assign({},n)):null}function re({onClose:t,onSubmit:o}){const[n,r]=m(""),[a,s]=m("member"),d=D(),i=()=>O(this,void 0,void 0,function*(){(yield d.run(()=>o({email:n.trim(),role:a})))!==void 0&&t()});return l(T,{open:!0,onClose:t,title:"Add member",testId:"apigee-member-dialog",footer:l(I,{children:[e(b,{variant:"outlined",onClick:t,disabled:d.pending,children:"Cancel"}),e(b,{variant:"primary",onClick:i,disabled:d.pending||!n.trim(),"data-testid":"apigee-member-submit",children:"Add member"})]}),children:[d.error?e(P,{tone:"danger",children:d.error}):null,l(f,{children:[e(F,{children:"Email"}),e(j,{type:"email",value:n,onChange:u=>r(u.target.value),placeholder:"colleague@example.com",required:!0,autoFocus:!0,"data-testid":"apigee-member-email"}),e(y,{children:"The member signs in with the portal account that has this email."})]}),l(f,{as:"div",children:[e(C,{children:"Role"}),e(E,{value:a,options:V,onChange:u=>s(u),dataTestId:"apigee-member-role-select"}),e(y,{children:"Owners can add and remove members and delete the team."})]})]})}function fe(t){var{open:o}=t,n=x(t,["open"]);return o?e(ae,Object.assign({},n)):null}function ae({onClose:t,onConfirm:o,title:n,children:r,confirmLabel:a,danger:s,withNote:d,noteLabel:i="Note",notePlaceholder:u="Optional"}){const[p,c]=m(""),h=D(),g=()=>O(this,void 0,void 0,function*(){(yield h.run(()=>o(p.trim()||void 0)))!==void 0&&t()});return l(T,{open:!0,onClose:t,title:n,testId:"apigee-confirm-dialog",footer:l(I,{children:[e(b,{variant:"outlined",onClick:t,disabled:h.pending,children:"Cancel"}),e(b,{variant:"primary",tone:s?"danger":"default",onClick:g,disabled:h.pending,"data-testid":"apigee-confirm",children:a})]}),children:[h.error?e(P,{tone:"danger",children:h.error}):null,r,d?l(f,{children:[e(C,{children:i}),e(S,{value:p,onChange:k=>c(k.target.value),placeholder:u,"data-testid":"apigee-confirm-note"})]}):null]})}export{he as AppDialog,fe as ConfirmDialog,me as KeyDialog,ve as MemberDialog,V as ROLE_OPTIONS,ge as TeamDialog};
@@ -0,0 +1,10 @@
1
+ import type { ReactElement } from 'react';
2
+ import type { Team } from '../../contract.js';
3
+ export declare function TeamsView({ teams, onTeamsChanged, }: {
4
+ teams: Team[];
5
+ onTeamsChanged: () => void;
6
+ }): ReactElement;
7
+ export declare function TeamDetailView({ teamId, onTeamsChanged, }: {
8
+ teamId: string;
9
+ onTeamsChanged: () => void;
10
+ }): ReactElement;
@@ -0,0 +1 @@
1
+ var w=function(p,h,o,s){function u(a){return a instanceof o?a:new o(function(m){m(a)})}return new(o||(o=Promise))(function(a,m){function n(c){try{g(s.next(c))}catch(k){m(k)}}function i(c){try{g(s.throw(c))}catch(k){m(k)}}function g(c){c.done?a(c.value):u(c.value).then(n,i)}g((s=s.apply(p,h||[])).next())})};import{Fragment as z,jsx as e,jsxs as d}from"react/jsx-runtime";import{useState as C}from"react";import{useNavigate as N}from"react-router";import{Button as f}from"@redocly/theme/components/Button/Button";import{Dropdown as I}from"@redocly/theme/components/Dropdown/Dropdown";import{DropdownMenu as O}from"@redocly/theme/components/Dropdown/DropdownMenu";import{Tag as M}from"@redocly/theme/components/Tag/Tag";import{CDNIcon as y}from"@redocly/theme/icons/CDNIcon/CDNIcon";import{apigeeApi as b}from"../api.js";import{useApigee as j}from"../context.js";import{formatDate as Q,useAsync as E,useMutation as X}from"../hooks.js";import{EmptyState as B,LinkList as P,LinkRow as Z,Loading as U,Muted as ee,Notice as L,PageBreadcrumbs as te,PageHeader as Y,Row as ie,Section as F,SectionHeader as H,SectionTitle as V,Table as ae,TableWrap as ne}from"../Primitives.js";import{AppRow as re}from"./AppsView.js";import{ConfirmDialog as W,MemberDialog as oe,ROLE_OPTIONS as q,TeamDialog as G}from"./Dialogs.js";function ke({teams:p,onTeamsChanged:h}){const{link:o}=j(),s=N(),[u,a]=C(!1),m=e(G,{open:u,onClose:()=>a(!1),onSubmit:i=>w(this,void 0,void 0,function*(){const g=yield b.createTeam(i);return h(),s(o(`/teams/${encodeURIComponent(g.id)}`)),g})}),n=e(f,{variant:"primary",onClick:()=>a(!0),icon:e(y,{name:"plus",size:"16px"}),"data-testid":"apigee-new-team",children:"New team"});return d(z,{children:[e(Y,{title:"Teams",description:"Share apps and keys with colleagues. A team is an Apigee app group; its members manage the team's apps together.",actions:p.length>0?n:void 0}),p.length===0?e(B,{icon:"user-group",title:"You are not in a team yet",text:"Create a team to share API keys with your colleagues, or ask a team owner to add your email.",action:n}):e(P,{"data-testid":"apigee-team-list",children:p.map(i=>e(Z,{to:o(`/teams/${encodeURIComponent(i.id)}`),title:i.name,subtitle:`${i.members.length} ${i.members.length===1?"member":"members"}${i.description?` \xB7 ${i.description}`:""}`,tag:i.myRole?e(M,{color:i.myRole==="owner"?"blue":"grey",children:i.myRole}):void 0},i.id))}),m]})}function Ae({teamId:p,onTeamsChanged:h}){var o,s;const{link:u,meta:a}=j(),m=N(),n=E(()=>b.getTeam(p),`team:${p}`),i=E(()=>b.listApps(),`team-apps:${p}`),[g,c]=C(!1),[k,S]=C(!1),[v,D]=C(null),[J,_]=C(!1),T=X();if(n.loading&&!n.data)return e(U,{label:"Loading the team\u2026"});if(n.error||!n.data)return e(L,{tone:"danger",children:(o=n.error)!==null&&o!==void 0?o:"Team not found"});const r=n.data,A=r.myRole==="owner",$=((s=i.data)!==null&&s!==void 0?s:[]).filter(t=>t.owner.kind==="team"&&t.owner.teamId===r.id),K=(t,l)=>w(this,void 0,void 0,function*(){const x=yield T.run(()=>b.setMemberRole(r.id,t,l));x&&n.setData(x)});return d("div",{"data-testid":"apigee-team-detail",children:[e(te,{additionalBreadcrumbs:[{label:"Teams",link:u("/teams")},{label:r.name}]}),e(Y,{title:r.name,description:r.description||"Shared apps and keys for the team.",actions:A?d(z,{children:[e(f,{variant:"outlined",onClick:()=>c(!0),icon:e(y,{name:"pen",size:"16px"}),children:"Edit team"}),e(f,{variant:"primary",onClick:()=>m(u("",{createApp:"",team:r.id})),icon:e(y,{name:"plus",size:"16px"}),"data-testid":"apigee-new-team-app",children:"New team app"}),e(I,{trigger:e(f,{variant:"text","aria-label":"More",icon:e(y,{name:"ellipsis-vertical",size:"16px"}),"data-testid":"apigee-team-menu"}),alignment:"end",children:e(O,{items:[{content:"Leave team",onAction:()=>D(a.viewer.email),dataAttributes:{"data-testid":"apigee-leave-team"}},{content:"Delete team",dangerous:!0,onAction:()=>S(!0),dataAttributes:{"data-testid":"apigee-delete-team"}}]})})]}):e(f,{variant:"outlined",tone:"danger",onClick:()=>D(a.viewer.email),"data-testid":"apigee-leave-team",children:"Leave team"})}),T.error?e(L,{tone:"danger",children:T.error}):null,d(F,{children:[d(H,{children:[e(V,{children:"Members"}),A?e(f,{variant:"outlined",size:"small",onClick:()=>_(!0),icon:e(y,{name:"plus",size:"14px"}),"data-testid":"apigee-add-member",children:"Add member"}):null]}),e(ne,{children:d(ae,{"data-testid":"apigee-members-table",children:[e("thead",{children:d("tr",{children:[e("th",{children:"Member"}),e("th",{children:"Role"}),e("th",{children:"Added"}),A?e("th",{className:"actions"}):null]})}),e("tbody",{children:r.members.map(t=>{var l;const x=t.email===a.viewer.email;return d("tr",{"data-testid":"apigee-member-row",children:[e("td",{children:d(ie,{children:[t.email,x?e(M,{color:"grey",children:"You"}):null]})}),e("td",{"data-label":"Role",children:A?e(I,{trigger:e(f,{variant:"outlined",size:"small",icon:e(y,{name:"chevron-down",size:"12px"}),iconPosition:"right","data-testid":"apigee-member-role",children:(l=q.find(R=>R.value===t.role))===null||l===void 0?void 0:l.element}),portalled:!0,children:e(O,{items:q.map(R=>({content:R.element,active:R.value===t.role,onAction:()=>K(t.email,R.value)}))})}):e(M,{color:t.role==="owner"?"blue":"grey",children:t.role})}),e("td",{"data-label":"Added",children:Q(t.addedAt)}),A?e("td",{className:"actions",children:x?null:e(f,{variant:"text",size:"small",tone:"danger",onClick:()=>D(t.email),"data-testid":"apigee-remove-member",children:"Remove"})}):null]},t.email)})})]})}),e(ee,{as:"p",style:{marginTop:"var(--spacing-xs)"},children:"Members sign in with the portal account that matches their email. Owners can add and remove members and delete the team."})]}),d(F,{children:[e(H,{children:e(V,{children:"Team apps"})}),i.loading&&!i.data?e(U,{label:"Loading apps\u2026"}):i.error?e(L,{tone:"danger",children:i.error}):$.length===0?e(B,{icon:"key",title:"No team apps yet",text:"Create an app for this team so every member can use its keys."}):e(P,{"data-testid":"apigee-team-apps-list",children:$.map(t=>e(re,{app:t,to:u(`/${encodeURIComponent(t.id)}`,{team:r.id})},t.id))})]}),e(oe,{open:J,onClose:()=>_(!1),onSubmit:t=>w(this,void 0,void 0,function*(){const l=yield b.addMember(r.id,t);return n.setData(l),h(),l})}),e(G,{open:g,onClose:()=>c(!1),initial:r,onSubmit:t=>w(this,void 0,void 0,function*(){const l=yield b.updateTeam(r.id,t);return n.setData(l),h(),l})}),e(W,{open:k,onClose:()=>S(!1),title:"Delete team?",confirmLabel:"Delete team",danger:!0,onConfirm:()=>w(this,void 0,void 0,function*(){return yield b.deleteTeam(r.id),h(),m(u("/teams")),!0}),children:d("p",{children:[e("strong",{children:r.name}),", its apps and all of their keys are removed from Apigee. This cannot be undone."]})}),e(W,{open:v!==null,onClose:()=>D(null),title:v===a.viewer.email?"Leave team?":"Remove member?",confirmLabel:v===a.viewer.email?"Leave team":"Remove member",danger:!0,onConfirm:()=>w(this,void 0,void 0,function*(){if(!v)return!0;const t=yield b.removeMember(r.id,v);return v===a.viewer.email?(h(),m(u("/teams"))):n.setData(t),!0}),children:e("p",{children:v===a.viewer.email?"You lose access to the team apps and their keys.":`${v} loses access to the team apps and their keys.`})})]})}export{Ae as TeamDetailView,ke as TeamsView};
@@ -0,0 +1,31 @@
1
+ import { type ApigeeAdapterConfig } from '@redocly/config';
2
+ import { type ConfigSchema, type FinalizeContext } from '@redocly/framework/plugin';
3
+ export type RealmConfig = FinalizeContext['config'];
4
+ /** The plan claim that includes developer onboarding. */
5
+ export declare const APIGEE_PLAN_CLAIM = "devOnboarding";
6
+ /** The `redocly.apigee` key of `redocly.yaml`: one Apigee organization and the page's options. */
7
+ export declare const APIGEE_CONFIG_SCHEMA: ConfigSchema;
8
+ export type ApigeeSettings = {
9
+ organizationName: string;
10
+ apiUrl: string;
11
+ stage: string;
12
+ basePath: string;
13
+ /** The page title, also the label of its link next to the user menu. */
14
+ title: string;
15
+ auth: ApigeeAdapterConfig['auth'];
16
+ apiProducts: {
17
+ include?: string[];
18
+ exclude?: string[];
19
+ allowOutsideCatalog: boolean;
20
+ matchByTitle: boolean;
21
+ };
22
+ teamsEnabled: boolean;
23
+ /** The Approvals page and its routes; off unless `approvals.enabled` is set. */
24
+ approvalsEnabled: boolean;
25
+ };
26
+ /** `redocly.apigee` with the defaults applied, or `null` when the site has no Apigee organization. */
27
+ export declare function readApigeeSettings(config: RealmConfig): ApigeeSettings | null;
28
+ /** The settings while the site has an Apigee organization and its plan includes developer onboarding. */
29
+ export declare function resolveApigeeSettings(config: RealmConfig): ApigeeSettings | null;
30
+ /** Whether `name` passes the `apiProducts.include` and `exclude` lists. */
31
+ export declare function isApiProductOffered(settings: ApigeeSettings, name: string): boolean;
package/lib/config.js ADDED
@@ -0,0 +1 @@
1
+ import{rootRedoclyConfigSchema as E}from"@redocly/config";import{isPlanClaimGranted as f}from"@redocly/framework/plugin";import{APIGEE_DEFAULT_API_URL as h,APIGEE_DEFAULT_BASE_PATH as b,APIGEE_DEFAULT_TITLE as y,APIGEE_PLUGIN_ID as I}from"./constants.js";const T="devOnboarding",[C]=E.properties.developerOnboarding.properties.adapters.items.oneOf,{organizationName:S,apiUrl:G,stage:x,auth:L}=C.properties,m={type:"object",properties:{enabled:{type:"boolean"}},additionalProperties:!1},A={type:"array",items:{type:"string"}},B={type:"object",properties:{organizationName:S,apiUrl:G,stage:x,auth:L,title:{type:"string"},basePath:{type:"string",pattern:"^/[A-Za-z0-9_-][A-Za-z0-9/_-]*$"},approvals:m,teams:m,apiProducts:{type:"object",properties:{include:A,exclude:A,allowOutsideCatalog:{type:"boolean"},matchByTitle:{type:"boolean"}},additionalProperties:!1}},required:["organizationName","auth"],additionalProperties:!1};function N(i){const e=i.trim();if(e===""||e==="/")return"/";const o=(e.startsWith("/")?e:`/${e}`).replaceAll(/\/+/g,"/");return o.length>1&&o.endsWith("/")?o.slice(0,-1):o}function z(i){var e,o,l,a,n,r,s,d,p,u,c,_,v,g,P;const t=(d=i[I])!==null&&d!==void 0?d:{};return!t.organizationName||!t.auth?null:{organizationName:t.organizationName,apiUrl:O((p=t.apiUrl)!==null&&p!==void 0?p:h),stage:(u=t.stage)!==null&&u!==void 0?u:"non-production",basePath:N((c=t.basePath)!==null&&c!==void 0?c:b),title:((e=t.title)===null||e===void 0?void 0:e.trim())||y,auth:t.auth,apiProducts:{include:(o=t.apiProducts)===null||o===void 0?void 0:o.include,exclude:(l=t.apiProducts)===null||l===void 0?void 0:l.exclude,allowOutsideCatalog:(_=(a=t.apiProducts)===null||a===void 0?void 0:a.allowOutsideCatalog)!==null&&_!==void 0?_:!1,matchByTitle:(v=(n=t.apiProducts)===null||n===void 0?void 0:n.matchByTitle)!==null&&v!==void 0?v:!1},teamsEnabled:(g=(r=t.teams)===null||r===void 0?void 0:r.enabled)!==null&&g!==void 0?g:!1,approvalsEnabled:(P=(s=t.approvals)===null||s===void 0?void 0:s.enabled)!==null&&P!==void 0?P:!1}}function F(i){const e=z(i);return e&&f(i,T)?e:null}function R(i,e){const{include:o,exclude:l}=i.apiProducts;return o&&o.length>0&&!o.includes(e)?!1:!l?.includes(e)}function O(i){let e=i.length;for(;e>0&&i[e-1]==="/";)e-=1;return i.slice(0,e)}export{B as APIGEE_CONFIG_SCHEMA,T as APIGEE_PLAN_CLAIM,R as isApiProductOffered,z as readApigeeSettings,F as resolveApigeeSettings};
@@ -0,0 +1,37 @@
1
+ import type { SERVER_ONLY_VALUE_KEY } from '@redocly/framework/plugin';
2
+ export declare const APIGEE_PLUGIN_ID = "redocly.apigee";
3
+ export declare const APIGEE_TEMPLATE_ID = "apigee-apps";
4
+ export declare const APIGEE_DEFAULT_BASE_PATH = "/apps";
5
+ export declare const APIGEE_DEFAULT_TITLE = "Apps";
6
+ export declare const APIGEE_DEFAULT_API_URL = "https://apigee.googleapis.com/v1";
7
+ /** The server-only entity that maps Apigee API product names to the API pages that document them. */
8
+ export declare const APIGEE_PRODUCTS_ENTITY_KEY = "apigee:api-products";
9
+ /**
10
+ * Realm Plus removes this key from an entity value before it serves the value to a browser, and
11
+ * the index names pages the viewer may not open. A type-only import keeps build code out of the
12
+ * runtime, and the type fails the build if the key changes.
13
+ */
14
+ export declare const APIGEE_PRODUCTS_VALUE_KEY: typeof SERVER_ONLY_VALUE_KEY;
15
+ export declare const APIGEE_ROUTES: {
16
+ readonly meta: "/_apigee/meta";
17
+ readonly access: "/_apigee/access";
18
+ readonly apps: "/_apigee/apps";
19
+ readonly app: "/_apigee/apps/:appId";
20
+ readonly appKeys: "/_apigee/apps/:appId/keys";
21
+ readonly appKey: "/_apigee/apps/:appId/keys/:consumerKey";
22
+ readonly teams: "/_apigee/teams";
23
+ readonly team: "/_apigee/teams/:teamId";
24
+ readonly teamMembers: "/_apigee/teams/:teamId/members";
25
+ readonly teamMember: "/_apigee/teams/:teamId/members/:email";
26
+ readonly adminRequests: "/_apigee/admin/requests";
27
+ readonly adminRequestApprove: "/_apigee/admin/requests/:requestId/approve";
28
+ readonly adminRequestRevoke: "/_apigee/admin/requests/:requestId/revoke";
29
+ readonly adminApps: "/_apigee/admin/apps";
30
+ readonly adminAudit: "/_apigee/admin/audit";
31
+ };
32
+ /** The Apigee AppGroup attribute its integrated portal keeps team members in. */
33
+ export declare const APIGEE_TEAM_MEMBERS_ATTRIBUTE = "__apigee_reserved__developer_details";
34
+ export declare const APIGEE_DISPLAY_NAME_ATTRIBUTE = "DisplayName";
35
+ export declare const APIGEE_NOTES_ATTRIBUTE = "Notes";
36
+ /** One year, the key lifetime Apigee gets when a developer does not choose one. */
37
+ export declare const APIGEE_DEFAULT_KEY_LIFETIME_SECONDS: number;
@@ -0,0 +1 @@
1
+ const p="redocly.apigee",s="apigee-apps",a="/apps",t="Apps",E="https://apigee.googleapis.com/v1",_="apigee:api-products",o="__serverOnly",e="/_apigee",I={meta:`${e}/meta`,access:`${e}/access`,apps:`${e}/apps`,app:`${e}/apps/:appId`,appKeys:`${e}/apps/:appId/keys`,appKey:`${e}/apps/:appId/keys/:consumerKey`,teams:`${e}/teams`,team:`${e}/teams/:teamId`,teamMembers:`${e}/teams/:teamId/members`,teamMember:`${e}/teams/:teamId/members/:email`,adminRequests:`${e}/admin/requests`,adminRequestApprove:`${e}/admin/requests/:requestId/approve`,adminRequestRevoke:`${e}/admin/requests/:requestId/revoke`,adminApps:`${e}/admin/apps`,adminAudit:`${e}/admin/audit`},m="__apigee_reserved__developer_details",r="DisplayName",A="Notes",T=3600*24*365;export{E as APIGEE_DEFAULT_API_URL,a as APIGEE_DEFAULT_BASE_PATH,T as APIGEE_DEFAULT_KEY_LIFETIME_SECONDS,t as APIGEE_DEFAULT_TITLE,r as APIGEE_DISPLAY_NAME_ATTRIBUTE,A as APIGEE_NOTES_ATTRIBUTE,p as APIGEE_PLUGIN_ID,_ as APIGEE_PRODUCTS_ENTITY_KEY,o as APIGEE_PRODUCTS_VALUE_KEY,I as APIGEE_ROUTES,m as APIGEE_TEAM_MEMBERS_ATTRIBUTE,s as APIGEE_TEMPLATE_ID};
@@ -0,0 +1,195 @@
1
+ /** The JSON the `/_apigee/*` routes exchange with the browser; no server-only types belong here. */
2
+ export type ApprovalStatus = 'approved' | 'revoked' | 'pending';
3
+ export type AppOwner = {
4
+ kind: 'developer';
5
+ email: string;
6
+ } | {
7
+ kind: 'team';
8
+ teamId: string;
9
+ };
10
+ /** What a reviewer decided about a product on a key, kept for the developer to read. */
11
+ export type Decision = {
12
+ action: 'approve' | 'revoke';
13
+ actor: string;
14
+ at: number;
15
+ note?: string;
16
+ };
17
+ type ApiProductStatus = {
18
+ id: string;
19
+ /** The product's display name; only the reviewer routes send it, and only when Apigee has one. */
20
+ name?: string;
21
+ status: ApprovalStatus;
22
+ decision?: Decision;
23
+ };
24
+ export type Credential = {
25
+ /** The consumer key; the value an `apiKey` security scheme sends. */
26
+ consumerKey: string;
27
+ consumerSecret?: string;
28
+ status: ApprovalStatus;
29
+ /** Milliseconds since the epoch; `null` when the key never expires. */
30
+ issuedAt: number | null;
31
+ expiresAt: number | null;
32
+ apiProducts: ApiProductStatus[];
33
+ scopes: string[];
34
+ };
35
+ export type App = {
36
+ /** The Apigee app name: unique per owner, the identifier in every route. */
37
+ id: string;
38
+ /** The display name developers see; falls back to `id`. */
39
+ name: string;
40
+ description: string;
41
+ callbackUrl?: string;
42
+ owner: AppOwner;
43
+ status: string;
44
+ createdAt: number | null;
45
+ lastModifiedAt: number | null;
46
+ credentials: Credential[];
47
+ };
48
+ export type AppInput = {
49
+ name: string;
50
+ description?: string;
51
+ callbackUrl?: string;
52
+ apiProducts: string[];
53
+ /** Shown to the administrators who review a request for a manually approved product. */
54
+ note?: string;
55
+ /** Create the app in this team instead of the developer's own account. */
56
+ teamId?: string;
57
+ };
58
+ export type AppUpdateInput = Partial<Pick<AppInput, 'name' | 'description' | 'callbackUrl'>>;
59
+ export type KeyInput = {
60
+ apiProducts: string[];
61
+ note?: string;
62
+ };
63
+ export type ApiProduct = {
64
+ id: string;
65
+ name: string;
66
+ description: string;
67
+ approvalType: 'auto' | 'manual';
68
+ /** The API page that documents the product, when the catalog has one the viewer can open. */
69
+ api?: {
70
+ slug: string;
71
+ title: string;
72
+ };
73
+ };
74
+ export type TeamRole = 'owner' | 'member';
75
+ export type TeamMember = {
76
+ email: string;
77
+ role: TeamRole;
78
+ addedAt: number;
79
+ };
80
+ export type Team = {
81
+ /** The Apigee AppGroup name. */
82
+ id: string;
83
+ name: string;
84
+ description: string;
85
+ createdAt: number;
86
+ createdBy: string;
87
+ members: TeamMember[];
88
+ /** The viewer's role, when the viewer is a member. */
89
+ myRole?: TeamRole;
90
+ };
91
+ export type TeamInput = {
92
+ name: string;
93
+ description?: string;
94
+ };
95
+ export type TeamMemberInput = {
96
+ email: string;
97
+ role?: TeamRole;
98
+ };
99
+ export type AccessRequest = {
100
+ /** Opaque; the approve and revoke routes take it back. */
101
+ id: string;
102
+ owner: AppOwner;
103
+ /** The developer who asked, when the request was made through this portal. */
104
+ requestedBy?: string;
105
+ /** The display name of the owning team, when Apigee has one. */
106
+ teamName?: string;
107
+ appId: string;
108
+ appName: string;
109
+ /** Masked: the first and last characters only. */
110
+ consumerKey: string;
111
+ apiProduct: string;
112
+ /** The product's display name, when Apigee has one. */
113
+ apiProductName?: string;
114
+ note?: string;
115
+ requestedAt: number | null;
116
+ /** Whether the viewer may decide this request: `maintain` or `admin` on the product's page or the apps page. */
117
+ canDecide: boolean;
118
+ };
119
+ type AuditAction = 'approve' | 'revoke';
120
+ export type AuditEntry = {
121
+ id: string;
122
+ at: number;
123
+ actor: string;
124
+ action: AuditAction;
125
+ owner: AppOwner;
126
+ /** The display name of the owning team, when Apigee has one; the audit route adds it. */
127
+ teamName?: string;
128
+ appId: string;
129
+ appName: string;
130
+ /** Masked: the first and last characters only. */
131
+ consumerKey: string;
132
+ apiProduct: string;
133
+ /** The product's display name, when Apigee has one; the audit route adds it. */
134
+ apiProductName?: string;
135
+ note?: string;
136
+ };
137
+ /** An app as reviewers see it: its keys without their values. */
138
+ export type AdminApp = Omit<App, 'credentials'> & {
139
+ /** The display name of the owning team, when Apigee has one. */
140
+ teamName?: string;
141
+ credentials: Omit<Credential, 'consumerKey' | 'consumerSecret'>[];
142
+ };
143
+ /** The viewer's standing on the Approvals page, from the rbac roles on the API pages and the apps page. */
144
+ export type ApprovalsSummary = {
145
+ /** `approvals.enabled` in the config. */
146
+ enabled: boolean;
147
+ /** `triage` or higher on at least one offered product. */
148
+ canView: boolean;
149
+ /** `maintain` or higher on at least one offered product. */
150
+ canDecide: boolean;
151
+ };
152
+ export type ApigeeMeta = {
153
+ organizationName: string;
154
+ stage: string;
155
+ basePath: string;
156
+ teamsEnabled: boolean;
157
+ approvals: ApprovalsSummary;
158
+ viewer: {
159
+ email: string;
160
+ name?: string;
161
+ };
162
+ apiProducts: ApiProduct[];
163
+ };
164
+ /** What the API reference reads for one product: the viewer's standing and the Try it credentials. */
165
+ export type ApiAccess = {
166
+ status: 'NONE' | 'PENDING' | 'APPROVED';
167
+ /** Where the sidebar button leads: a site path without the path prefix. */
168
+ link: string;
169
+ /** `security.default` for Replay: the first approved key, the developer's own before a team's. */
170
+ requestValues?: {
171
+ security: {
172
+ default: {
173
+ client_id: string;
174
+ client_secret?: string;
175
+ };
176
+ };
177
+ };
178
+ };
179
+ export type ApigeeError = {
180
+ error: string;
181
+ status?: number;
182
+ };
183
+ /** The `apigee` app-data namespace: only the parts of the Realm Plus app-data protocol the client reads. */
184
+ export type ApigeeAppData = {
185
+ accountLinks: {
186
+ label: string;
187
+ link: string;
188
+ icon: string;
189
+ }[];
190
+ /** Answers `ApiAccess` for the sidebar button and Try it on a page whose metadata has `apiId`. */
191
+ apiAccessRoute: string;
192
+ };
193
+ /** A consumer key with only its first and last four characters: enough to tell keys apart, not to use one. */
194
+ export declare function maskKey(key: string): string;
195
+ export {};
@@ -0,0 +1 @@
1
+ function n(e){return e.length<=8?"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022":`${e.slice(0,4)}\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022${e.slice(-4)}`}export{n as maskKey};
@@ -0,0 +1,10 @@
1
+ import { type ContentPlugin } from '@redocly/framework/plugin';
2
+ export { APIGEE_TEMPLATE_ID } from './constants.js';
3
+ export type { ApigeeAppData } from './contract.js';
4
+ /**
5
+ * The Apigee developer onboarding plugin for Realm Plus: an apps page for signed-in
6
+ * developers, teams through Apigee app groups, reviewer approvals, and the API access protocol
7
+ * that API reference pages follow.
8
+ */
9
+ declare const apigeeContentPlugin: ContentPlugin;
10
+ export default apigeeContentPlugin;
package/lib/plugin.js ADDED
@@ -0,0 +1 @@
1
+ import{createRequire as A}from"node:module";import{createInlineEntity as g,defineContentPlugin as f,isPlanClaimGranted as I,runtimeFile as _,runtimeTemplate as G}from"@redocly/framework/plugin";import{APIGEE_CONFIG_SCHEMA as b,APIGEE_PLAN_CLAIM as S,readApigeeSettings as v,resolveApigeeSettings as y}from"./config.js";import{APIGEE_PLUGIN_ID as C,APIGEE_PRODUCTS_ENTITY_KEY as L,APIGEE_PRODUCTS_VALUE_KEY as D,APIGEE_ROUTES as e,APIGEE_TEMPLATE_ID as c}from"./constants.js";import{APIGEE_TEMPLATE_ID as w}from"./constants.js";const{version:R}=A(import.meta.url)("../package.json");function t(a,i,r){return{path:a,method:r,auth:"manual",handler:{filePath:"./server/routes.ts",importer:import.meta.url,exportName:i}}}const h=[t(e.meta,"meta","GET"),t(e.access,"access","GET"),t(e.apps,"listApps","GET"),t(e.apps,"createApp","POST"),t(e.app,"updateApp",["PUT","PATCH"]),t(e.app,"deleteApp",["DELETE"]),t(e.appKeys,"createKey","POST"),t(e.appKey,"updateKey",["PUT","PATCH"]),t(e.appKey,"deleteKey",["DELETE"]),t(e.teams,"listTeams","GET"),t(e.teams,"createTeam","POST"),t(e.team,"getTeam","GET"),t(e.team,"updateTeam",["PUT","PATCH"]),t(e.team,"deleteTeam",["DELETE"]),t(e.teamMembers,"addTeamMember","POST"),t(e.teamMember,"updateTeamMember",["PUT","PATCH"]),t(e.teamMember,"removeTeamMember",["DELETE"]),t(e.adminRequests,"adminRequests","GET"),t(e.adminRequestApprove,"adminApprove","POST"),t(e.adminRequestRevoke,"adminRevoke","POST"),t(e.adminApps,"adminApps","GET"),t(e.adminAudit,"adminAudit","GET")],O={code:"configuration/ignored",message:"Developer onboarding is not in this project's plan, so the Apigee pages are skipped."};function M(a){return{accountLinks:[{label:a.title,link:a.basePath,icon:"key"}],apiAccessRoute:e.access}}function K(a){var i,r,l;const d=a.routes.metadata("apiId"),T=a.routes.metadata("title"),E=a.routes.metadata("type"),p={},m={};for(const{slug:n,canonicalSlug:P}of a.routes.all()){if(E[n]!=="openapi"||P!=="")continue;const s=d[n],u=T[n],o=typeof u=="string"?u.trim():"";typeof s=="string"&&s!==""&&((i=p[s])!==null&&i!==void 0||(p[s]={slug:n,title:o||s})),o&&((r=m[l=o.toLowerCase()])!==null&&r!==void 0||(m[l]={slug:n,title:o}))}return{byApiId:p,byTitle:m}}const U=f({id:C,version:R,configSchema:b,templates:{[c]:G(_("./client/ApigeeTemplate.tsx",import.meta.url))},server:{routes:h},content:{filter:{match:()=>!1},extractAll(a){const i=y(a.config);return i?{routes:[{routeId:"apps",slug:i.basePath,template:c,wildcardPrefix:!0,metadata:{title:i.title,excludeFromSearch:!0}}]}:null}},finalize(a){const i=v(a.config);if(!i)return{};if(!I(a.config,S))return{problems:[O]};const r=g({[D]:K(a)},{stableKey:L,metadata:{routeSlug:i.basePath}});return{appData:{apigee:M(i)},entities:[r]}}});var F=U;export{w as APIGEE_TEMPLATE_ID,F as default};
@@ -0,0 +1,72 @@
1
+ /** The Apigee management API resources the plugin reads and writes, as the API serializes them. */
2
+ export type ApigeeAttribute = {
3
+ name: string;
4
+ value: string;
5
+ };
6
+ type ApigeeApiProductRef = {
7
+ apiproduct: string;
8
+ status: string;
9
+ };
10
+ export type ApigeeCredential = {
11
+ consumerKey: string;
12
+ consumerSecret?: string;
13
+ status: string;
14
+ issuedAt?: string | number;
15
+ expiresAt?: string | number;
16
+ scopes?: string[];
17
+ attributes?: ApigeeAttribute[];
18
+ apiProducts?: ApigeeApiProductRef[];
19
+ };
20
+ export type ApigeeApp = {
21
+ appId?: string;
22
+ name: string;
23
+ status?: string;
24
+ attributes?: ApigeeAttribute[];
25
+ callbackUrl?: string;
26
+ createdAt?: string;
27
+ lastModifiedAt?: string;
28
+ credentials?: ApigeeCredential[];
29
+ scopes?: string[];
30
+ apiProducts?: string[];
31
+ keyExpiresIn?: string;
32
+ /** Organization-wide listings: the owner of a developer app. */
33
+ developerId?: string;
34
+ developerEmail?: string;
35
+ /** Organization-wide listings: the owner of an AppGroup app. */
36
+ appGroup?: string;
37
+ };
38
+ export type ApigeeApiProduct = {
39
+ name: string;
40
+ displayName?: string;
41
+ description?: string;
42
+ approvalType?: string;
43
+ attributes?: ApigeeAttribute[];
44
+ scopes?: string[];
45
+ createdAt?: string;
46
+ lastModifiedAt?: string;
47
+ };
48
+ export type ApigeeDeveloper = {
49
+ developerId?: string;
50
+ email: string;
51
+ firstName?: string;
52
+ lastName?: string;
53
+ userName?: string;
54
+ status?: string;
55
+ };
56
+ export type ApigeeAppGroup = {
57
+ appGroupId?: string;
58
+ name: string;
59
+ displayName?: string;
60
+ status?: string;
61
+ attributes?: ApigeeAttribute[];
62
+ createdAt?: string;
63
+ lastModifiedAt?: string;
64
+ };
65
+ export type ApigeeAppInput = {
66
+ name: string;
67
+ callbackUrl?: string;
68
+ apiProducts?: string[];
69
+ attributes?: ApigeeAttribute[];
70
+ keyExpiresIn?: string;
71
+ };
72
+ export {};
File without changes