@redocly/framework-plugin-apigee 0.0.0-stage → 0.1.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/README.md +102 -2
- package/lib/.tsbuildinfo +1 -0
- package/lib/client/ApigeeTemplate.d.ts +24 -0
- package/lib/client/ApigeeTemplate.js +1 -0
- package/lib/client/Primitives.d.ts +84 -0
- package/lib/client/Primitives.js +372 -0
- package/lib/client/api.d.ts +28 -0
- package/lib/client/api.js +1 -0
- package/lib/client/context.d.ts +12 -0
- package/lib/client/context.js +1 -0
- package/lib/client/hooks.d.ts +21 -0
- package/lib/client/hooks.js +1 -0
- package/lib/client/views/AdminView.d.ts +2 -0
- package/lib/client/views/AdminView.js +21 -0
- package/lib/client/views/AppsView.d.ts +11 -0
- package/lib/client/views/AppsView.js +1 -0
- package/lib/client/views/Dialogs.d.ts +49 -0
- package/lib/client/views/Dialogs.js +1 -0
- package/lib/client/views/TeamsView.d.ts +10 -0
- package/lib/client/views/TeamsView.js +1 -0
- package/lib/config.d.ts +31 -0
- package/lib/config.js +1 -0
- package/lib/constants.d.ts +37 -0
- package/lib/constants.js +1 -0
- package/lib/contract.d.ts +182 -0
- package/lib/contract.js +1 -0
- package/lib/plugin.d.ts +10 -0
- package/lib/plugin.js +1 -0
- package/lib/server/apigee-types.d.ts +72 -0
- package/lib/server/apigee-types.js +0 -0
- package/lib/server/client.d.ts +60 -0
- package/lib/server/client.js +1 -0
- package/lib/server/mappers.d.ts +10 -0
- package/lib/server/mappers.js +1 -0
- package/lib/server/routes.d.ts +25 -0
- package/lib/server/routes.js +1 -0
- package/lib/server/service.d.ts +93 -0
- package/lib/server/service.js +1 -0
- package/lib/server/store.d.ts +38 -0
- package/lib/server/store.js +1 -0
- package/lib/server/token.d.ts +13 -0
- package/lib/server/token.js +2 -0
- package/package.json +56 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var D=function(t,l,a,s){function w(m){return m instanceof a?m:new a(function(y){y(m)})}return new(a||(a=Promise))(function(m,y){function c(d){try{g(s.next(d))}catch(k){y(k)}}function f(d){try{g(s.throw(d))}catch(k){y(k)}}function g(d){d.done?m(d.value):w(d.value).then(c,f)}g((s=s.apply(t,l||[])).next())})};import{Fragment as T,jsx as e,jsxs as n}from"react/jsx-runtime";import{useEffect as J,useMemo as E,useState as K}from"react";import{useNavigate as Q}from"react-router";import{Button as b}from"@redocly/theme/components/Button/Button";import{Dropdown as M}from"@redocly/theme/components/Dropdown/Dropdown";import{DropdownMenu as B}from"@redocly/theme/components/Dropdown/DropdownMenu";import{Tag as X}from"@redocly/theme/components/Tag/Tag";import{CDNIcon as A}from"@redocly/theme/icons/CDNIcon/CDNIcon";import{apigeeApi as P}from"../api.js";import{useApigee as Y}from"../context.js";import{maskKey as Z}from"../../contract.js";import{copyText as ee,formatDate as $,useAsync as te}from"../hooks.js";import{Dot as ie,EmptyState as L,ListItem as ne,ListTitle as U,Loading as re,Mono as H,Muted as C,Notice as O,Overview as ae,PageHeader as R,Row as j,Section as oe,SectionHeader as de,SectionTitle as le,SplitLayout as se,StatusTag as F,Table as ce,TableWrap as ue}from"../Primitives.js";import{AppDialog as q,ConfirmDialog as V,KeyDialog as pe}from"./Dialogs.js";function me(t,l){var a,s;return t.kind==="developer"?"Personal":`Team \xB7 ${(s=(a=l.find(w=>w.id===t.teamId))===null||a===void 0?void 0:a.name)!==null&&s!==void 0?s:t.teamId}`}function he(t){if(t.status==="revoked")return"red";const l=t.credentials.flatMap(a=>a.apiProducts);return l.some(a=>a.status==="pending")?"orange":l.some(a=>a.status==="approved")?"green":"grey"}function W(t){if(t.status!=="approved")return t.status;const{apiProducts:l}=t;return l.some(a=>a.status==="pending")?"pending":l.length>0&&l.every(a=>a.status==="revoked")?"revoked":"approved"}function _e({selection:t,teams:l,products:a}){var s;const{link:w,title:m}=Y(),y=Q(),c=te(()=>P.listApps(),"apps"),[f,g]=K(null);J(()=>{var r,u;const v=new URLSearchParams(window.location.search);v.has("createApp")&&(g({product:(r=v.get("apiProduct"))!==null&&r!==void 0?r:void 0,teamId:(u=v.get("team"))!==null&&u!==void 0?u:void 0}),y(w(),{replace:!0}))},[w,y]);const d=E(()=>{var r;return!t||!c.data?null:(r=c.data.find(u=>u.id===t.appId&&(t.teamId?u.owner.kind==="team"&&u.owner.teamId===t.teamId:u.owner.kind==="developer")))!==null&&r!==void 0?r:null},[c.data,t]),k=E(()=>{var r;const u=((r=c.data)!==null&&r!==void 0?r:[]).filter(x=>x.owner.kind==="developer"),v=l.map(x=>{var i;return{team:x,apps:((i=c.data)!==null&&i!==void 0?i:[]).filter(p=>p.owner.kind==="team"&&p.owner.teamId===x.id)}});return{personal:u,byTeam:v}},[c.data,l]),I=r=>w(`/${encodeURIComponent(r.id)}`,r.owner.kind==="team"?{team:r.owner.teamId}:void 0),S=r=>D(this,void 0,void 0,function*(){const u=yield P.createApp(r);return c.reload(),y(I(u)),u});if(c.loading&&!c.data)return e(re,{children:"Loading your apps\u2026"});if(c.error)return e(O,{tone:"danger",children:c.error});const z=(s=c.data)!==null&&s!==void 0?s:[],_=e(q,{open:f!==null,onClose:()=>g(null),onSubmit:S,products:a,teams:l,initialProduct:f?.product,initialTeamId:f?.teamId});return z.length===0?n(T,{children:[e(R,{title:m,description:"Register applications and manage the API keys that call the APIs through Apigee."}),e(L,{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(b,{variant:"primary",onClick:()=>g({}),icon:e(A,{name:"plus",size:"16px"}),"data-testid":"apigee-new-app",children:"New application"})}),_]}):n(T,{children:[e(R,{title:m,description:"Register applications and manage the API keys that call the APIs through Apigee.",actions:e(b,{variant:"primary",onClick:()=>g({}),icon:e(A,{name:"plus",size:"16px"}),"data-testid":"apigee-new-app",children:"New application"})}),n(se,{children:[n("aside",{"data-testid":"apigee-app-list",children:[k.personal.length>0?e(U,{children:"Personal"}):null,k.personal.map(r=>e(G,{app:r,to:I(r),active:d===r},`dev:${r.id}`)),k.byTeam.map(({team:r,apps:u})=>u.length>0?n("div",{style:{marginTop:"var(--spacing-base)"},children:[n(U,{children:["Team \xB7 ",r.name]}),u.map(v=>e(G,{app:v,to:I(v),active:d===v},`team:${r.id}:${v.id}`))]},r.id):null)]}),e("div",{children:d?e(ve,{app:d,teams:l,products:a,onChanged:()=>c.reload(),onDeleted:()=>{c.reload(),y(w())}}):e(L,{icon:"arrow-left",title:"Select an app",text:"Choose an app on the left to see its keys, or create a new one."})})]}),_]})}function G({app:t,to:l,active:a}){const s=t.credentials.length;return n(ne,{to:l,$active:a,"data-testid":"apigee-app-row",children:[n("span",{children:[t.name,e("br",{}),n(C,{children:[s," ",s===1?"key":"keys"]})]}),e(ie,{$color:he(t)})]})}function ve({app:t,teams:l,products:a,onChanged:s,onDeleted:w}){const m=t.owner.kind==="team"?t.owner.teamId:void 0,[y,c]=K(!1),[f,g]=K(!1),[d,k]=K(null),[I,S]=K(null),[z,_]=K(new Set),[r,u]=K(null),v=(i,p)=>D(this,void 0,void 0,function*(){(yield ee(i))&&(u(p),setTimeout(()=>u(null),1500))}),x=i=>{var p,o;return(o=(p=a.find(h=>h.id===i))===null||p===void 0?void 0:p.name)!==null&&o!==void 0?o:i};return n("div",{"data-testid":"apigee-app-detail",children:[e(R,{title:n(T,{children:[t.name,t.status==="revoked"?e(X,{color:"red",children:"Revoked"}):null]}),description:t.description||void 0,actions:n(T,{children:[e(b,{variant:"outlined",onClick:()=>c(!0),icon:e(A,{name:"pen",size:"16px"}),"data-testid":"apigee-edit-app",children:"Edit"}),e(M,{trigger:e(b,{variant:"text","aria-label":"More",icon:e(A,{name:"ellipsis-vertical",size:"16px"}),"data-testid":"apigee-app-menu"}),alignment:"end",children:e(B,{items:[{content:"Delete application",dangerous:!0,onAction:()=>g(!0),dataAttributes:{"data-testid":"apigee-delete-app"}}]})})]})}),n(ae,{children:[n("div",{children:[e("dt",{children:"Owner"}),n("dd",{children:[e(A,{name:t.owner.kind==="team"?"user-group":"user",size:"16px"}),me(t.owner,l)]})]}),n("div",{children:[e("dt",{children:"Created"}),e("dd",{children:$(t.createdAt)})]}),n("div",{className:"wide",children:[e("dt",{children:"Callback URL"}),e("dd",{children:t.callbackUrl||e(C,{children:"Not set"})})]})]}),n(oe,{children:[n(de,{children:[e(le,{children:"API keys"}),e(b,{variant:"outlined",size:"small",onClick:()=>k({}),icon:e(A,{name:"plus",size:"14px"}),"data-testid":"apigee-create-key",children:"Create key"})]}),t.credentials.length===0?e(L,{icon:"key",title:"No keys yet",text:"Create a key and pick the API products it may call."}):e(ue,{children:n(ce,{"data-testid":"apigee-keys-table",children:[e("thead",{children:n("tr",{children:[e("th",{children:"Key"}),e("th",{children:"API products"}),e("th",{children:"Status"}),e("th",{className:"actions"})]})}),e("tbody",{children:t.credentials.map(i=>{const p=z.has(i.consumerKey);return n("tr",{"data-testid":"apigee-key-row",children:[n("td",{className:"key",children:[n(j,{children:[e(H,{"data-testid":"apigee-key-value",children:p?i.consumerKey:Z(i.consumerKey)}),e(b,{variant:"text",size:"small","aria-label":p?"Hide key":"Reveal key",icon:e(A,{name:p?"eye-slash":"eye",size:"14px"}),onClick:()=>_(o=>{const h=new Set(o);return h.has(i.consumerKey)?h.delete(i.consumerKey):h.add(i.consumerKey),h})}),e(b,{variant:"text",size:"small","aria-label":"Copy key",icon:e(A,{name:"copy",size:"14px"}),onClick:()=>v(i.consumerKey,`key:${i.consumerKey}`)}),r===`key:${i.consumerKey}`?e(C,{children:"Copied"}):null]}),i.consumerSecret?n(j,{children:[e(C,{children:"Secret"}),e(H,{children:p?i.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(A,{name:"copy",size:"14px"}),onClick:()=>{var o;return v((o=i.consumerSecret)!==null&&o!==void 0?o:"",`secret:${i.consumerKey}`)}}),r===`secret:${i.consumerKey}`?e(C,{children:"Copied"}):null]}):null,n(C,{children:["Issued ",$(i.issuedAt)," \xB7 Expires"," ",i.expiresAt?$(i.expiresAt):"never"]})]}),n("td",{children:[n(j,{children:[i.apiProducts.length===0?e(C,{children:"None"}):null,i.apiProducts.map(o=>e(F,{status:o.status,label:o.status==="approved"?x(o.id):`${x(o.id)} \xB7 ${o.status}`},o.id))]}),i.apiProducts.filter(o=>{var h;return(h=o.decision)===null||h===void 0?void 0:h.note}).map(o=>{var h,N;return n(C,{as:"div","data-testid":"apigee-decision-note",children:[((h=o.decision)===null||h===void 0?void 0:h.action)==="approve"?"Approved":"Rejected"," \xB7"," ",x(o.id),": \u201C",(N=o.decision)===null||N===void 0?void 0:N.note,"\u201D"]},o.id)})]}),e("td",{children:e(F,{status:W(i)})}),e("td",{className:"actions",children:e(M,{trigger:e(b,{variant:"text",size:"small","aria-label":"Key actions",icon:e(A,{name:"ellipsis-vertical",size:"14px"}),"data-testid":"apigee-key-menu"}),alignment:"end",portalled:!0,children:e(B,{items:[{content:"Edit API products",onAction:()=>k({consumerKey:i.consumerKey,products:i.apiProducts.map(o=>o.id)}),dataAttributes:{"data-testid":"apigee-edit-key"}},{content:"Delete key",dangerous:!0,separatorLine:!0,onAction:()=>S(i.consumerKey),dataAttributes:{"data-testid":"apigee-delete-key"}}]})})})]},i.consumerKey)})})]})}),t.credentials.some(i=>W(i)==="approved")?e("div",{style:{marginTop:"var(--spacing-base)"},children:n(O,{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(q,{open:y,onClose:()=>c(!1),onSubmit:i=>D(this,void 0,void 0,function*(){const p=yield P.updateApp(t.id,i,m);return s(),p}),products:a,teams:l,initial:t}),e(pe,{open:d!==null,onClose:()=>k(null),onSubmit:i=>D(this,void 0,void 0,function*(){const p=d?.consumerKey?yield P.updateKey(t.id,d.consumerKey,i,m):yield P.createKey(t.id,i,m);return s(),p}),products:a,initial:d?.products}),e(V,{open:f,onClose:()=>g(!1),title:"Delete application?",confirmLabel:"Delete application",danger:!0,onConfirm:()=>D(this,void 0,void 0,function*(){return yield P.deleteApp(t.id,m),w(),!0}),children:n("p",{children:[e("strong",{children:t.name})," and all of its keys stop working immediately. This cannot be undone."]})}),e(V,{open:I!==null,onClose:()=>S(null),title:"Delete key?",confirmLabel:"Delete key",danger:!0,onConfirm:()=>D(this,void 0,void 0,function*(){return I&&(yield P.deleteKey(t.id,I,m)),s(),!0}),children:e("p",{children:"Requests that send this key are rejected from now on. This cannot be undone."})})]})}export{_e as AppsView};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { type ReactElement, type ReactNode } from 'react';
|
|
2
|
+
import type { ApiProduct, App, AppInput, KeyInput, Team, TeamInput } from '../../contract.js';
|
|
3
|
+
type AppDialogProps = {
|
|
4
|
+
onClose: () => void;
|
|
5
|
+
onSubmit: (input: AppInput) => Promise<unknown>;
|
|
6
|
+
products: ApiProduct[];
|
|
7
|
+
teams: Team[];
|
|
8
|
+
/** The app being edited; a new app otherwise. */
|
|
9
|
+
initial?: App;
|
|
10
|
+
initialProduct?: string;
|
|
11
|
+
initialTeamId?: string;
|
|
12
|
+
};
|
|
13
|
+
export declare function AppDialog({ open, ...props }: AppDialogProps & {
|
|
14
|
+
open: boolean;
|
|
15
|
+
}): ReactElement | null;
|
|
16
|
+
type KeyDialogProps = {
|
|
17
|
+
onClose: () => void;
|
|
18
|
+
onSubmit: (input: KeyInput) => Promise<unknown>;
|
|
19
|
+
products: ApiProduct[];
|
|
20
|
+
/** The products already on the key being edited; a new key otherwise. */
|
|
21
|
+
initial?: string[];
|
|
22
|
+
};
|
|
23
|
+
export declare function KeyDialog({ open, ...props }: KeyDialogProps & {
|
|
24
|
+
open: boolean;
|
|
25
|
+
}): ReactElement | null;
|
|
26
|
+
type TeamDialogProps = {
|
|
27
|
+
onClose: () => void;
|
|
28
|
+
onSubmit: (input: TeamInput) => Promise<unknown>;
|
|
29
|
+
initial?: Team;
|
|
30
|
+
};
|
|
31
|
+
export declare function TeamDialog({ open, ...props }: TeamDialogProps & {
|
|
32
|
+
open: boolean;
|
|
33
|
+
}): ReactElement | null;
|
|
34
|
+
type ConfirmDialogProps = {
|
|
35
|
+
onClose: () => void;
|
|
36
|
+
onConfirm: (note?: string) => Promise<unknown>;
|
|
37
|
+
title: ReactNode;
|
|
38
|
+
children?: ReactNode;
|
|
39
|
+
confirmLabel: string;
|
|
40
|
+
danger?: boolean;
|
|
41
|
+
/** Offers a note field, for a decision the other side should hear the reason for. */
|
|
42
|
+
withNote?: boolean;
|
|
43
|
+
noteLabel?: string;
|
|
44
|
+
notePlaceholder?: string;
|
|
45
|
+
};
|
|
46
|
+
export declare function ConfirmDialog({ open, ...props }: ConfirmDialogProps & {
|
|
47
|
+
open: boolean;
|
|
48
|
+
}): ReactElement | null;
|
|
49
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var j=function(n,a,r,t){function o(d){return d instanceof r?d:new r(function(c){c(d)})}return new(r||(r=Promise))(function(d,c){function h(i){try{s(t.next(i))}catch(u){c(u)}}function g(i){try{s(t.throw(i))}catch(u){c(u)}}function s(i){i.done?d(i.value):o(i.value).then(h,g)}s((t=t.apply(n,a||[])).next())})},x=function(n,a){var r={};for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&a.indexOf(t)<0&&(r[t]=n[t]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,t=Object.getOwnPropertySymbols(n);o<t.length;o++)a.indexOf(t[o])<0&&Object.prototype.propertyIsEnumerable.call(n,t[o])&&(r[t[o]]=n[t[o]]);return r};import{Fragment as N,jsx as e,jsxs as l}from"react/jsx-runtime";import{useState as v}from"react";import{Button as y}from"@redocly/theme/components/Button/Button";import{Tag as R}from"@redocly/theme/components/Tag/Tag";import{useMutation as D}from"../hooks.js";import{CheckItem as z,CheckItemTitle as $,CheckList as G,Dialog as I,Field as f,FieldLabel as b,Input as P,Muted as k,NativeSelect as H,Notice as S,Textarea as O}from"../Primitives.js";function U({products:n,selected:a,onChange:r}){return n.length===0?e(k,{children:"No API products are available to you yet."}):e(G,{"data-testid":"apigee-product-picker",children:n.map(t=>{const o=a.includes(t.id);return l(z,{$checked:o,children:[e("input",{type:"checkbox",checked:o,onChange:d=>r(d.target.checked?[...a,t.id]:a.filter(c=>c!==t.id))}),l("span",{children:[l($,{children:[t.name,e(R,{color:t.approvalType==="manual"?"orange":"grey",children:t.approvalType==="manual"?"requires approval":"auto-approved"})]}),t.description?e(k,{children:t.description}):null]})]},t.id)})})}function L(n,a){return n.some(r=>a.includes(r.id)&&r.approvalType==="manual")}function oe(n){var{open:a}=n,r=x(n,["open"]);return a?e(J,Object.assign({},r)):null}function J({onClose:n,onSubmit:a,products:r,teams:t,initial:o,initialProduct:d,initialTeamId:c}){var h,g,s;const i=!!o,[u,m]=v((h=o?.name)!==null&&h!==void 0?h:""),[C,W]=v((g=o?.description)!==null&&g!==void 0?g:""),[A,q]=v((s=o?.callbackUrl)!==null&&s!==void 0?s:""),[T,B]=v(o?.owner.kind==="team"?o.owner.teamId:c??""),[_,E]=v(d?[d]:[]),[F,K]=v(""),w=D(),M=()=>j(this,void 0,void 0,function*(){(yield w.run(()=>a(Object.assign(Object.assign({name:u.trim(),description:C.trim(),callbackUrl:A.trim(),apiProducts:_},F.trim()?{note:F.trim()}:{}),T?{teamId:T}:{}))))!==void 0&&n()});return l(I,{open:!0,onClose:n,wide:!0,title:i?"Edit application":"New application",testId:"apigee-app-dialog",footer:l(N,{children:[e(y,{variant:"outlined",onClick:n,disabled:w.pending,children:"Cancel"}),e(y,{variant:"primary",onClick:M,disabled:w.pending||!u.trim(),"data-testid":"apigee-app-submit",children:i?"Save":"Create application"})]}),children:[w.error?e(S,{tone:"danger",children:w.error}):null,l(f,{children:[e(b,{children:"Name"}),e(P,{value:u,onChange:p=>m(p.target.value),placeholder:"Ticketing kiosk",autoFocus:!0,"data-testid":"apigee-app-name"}),i?null:e(k,{children:"Letters, digits, spaces, dots, dashes and underscores. The name cannot change later."})]}),!i&&t.length>0?l(f,{children:[e(b,{children:"Owner"}),l(H,{value:T,onChange:p=>B(p.target.value),"data-testid":"apigee-app-owner",children:[e("option",{value:"",children:"Personal"}),t.map(p=>l("option",{value:p.id,children:["Team \xB7 ",p.name]},p.id))]}),e(k,{children:"Team apps are shared with every member of the team."})]}):null,i?null:l(f,{as:"div",children:[e(b,{children:"API products"}),e(U,{products:r,selected:_,onChange:E})]}),!i&&L(r,_)?l(f,{children:[e(b,{children:"Why do you need access?"}),e(O,{value:F,onChange:p=>K(p.target.value),placeholder:"Sent to the reviewers of the request","data-testid":"apigee-app-note"})]}):null,l(f,{children:[e(b,{children:"Description"}),e(O,{value:C,onChange:p=>W(p.target.value),placeholder:"What does this application do?"})]}),l(f,{children:[e(b,{children:"Callback URL"}),e(P,{value:A,onChange:p=>q(p.target.value),placeholder:"https://example.com/oauth/callback"}),e(k,{children:"Where OAuth 2.0 authorization codes are sent. Separate several URLs with commas."})]})]})}function ae(n){var{open:a}=n,r=x(n,["open"]);return a?e(Q,Object.assign({},r)):null}function Q({onClose:n,onSubmit:a,products:r,initial:t}){const o=t!==void 0,[d,c]=v(t??[]),[h,g]=v(""),s=D(),i=d.filter(m=>!(t??[]).includes(m)),u=()=>j(this,void 0,void 0,function*(){(yield s.run(()=>a(Object.assign({apiProducts:d},h.trim()?{note:h.trim()}:{}))))!==void 0&&n()});return l(I,{open:!0,onClose:n,wide:!0,title:o?"Edit API products":"Create key",testId:"apigee-key-dialog",footer:l(N,{children:[e(y,{variant:"outlined",onClick:n,disabled:s.pending,children:"Cancel"}),e(y,{variant:"primary",onClick:u,disabled:s.pending,"data-testid":"apigee-key-submit",children:o?"Save":"Create key"})]}),children:[s.error?e(S,{tone:"danger",children:s.error}):null,l(f,{as:"div",children:[e(b,{children:"API products"}),e(U,{products:r,selected:d,onChange:c})]}),L(r,i)?l(f,{children:[e(b,{children:"Why do you need access?"}),e(O,{value:h,onChange:m=>g(m.target.value),placeholder:"Sent to the reviewers of the request"})]}):null]})}function ie(n){var{open:a}=n,r=x(n,["open"]);return a?e(V,Object.assign({},r)):null}function V({onClose:n,onSubmit:a,initial:r}){var t,o;const d=!!r,[c,h]=v((t=r?.name)!==null&&t!==void 0?t:""),[g,s]=v((o=r?.description)!==null&&o!==void 0?o:""),i=D(),u=()=>j(this,void 0,void 0,function*(){(yield i.run(()=>a({name:c.trim(),description:g.trim()})))!==void 0&&n()});return l(I,{open:!0,onClose:n,title:d?"Edit team":"New team",testId:"apigee-team-dialog",footer:l(N,{children:[e(y,{variant:"outlined",onClick:n,disabled:i.pending,children:"Cancel"}),e(y,{variant:"primary",onClick:u,disabled:i.pending||!c.trim(),"data-testid":"apigee-team-submit",children:d?"Save":"Create team"})]}),children:[i.error?e(S,{tone:"danger",children:i.error}):null,l(f,{children:[e(b,{children:"Name"}),e(P,{value:c,onChange:m=>h(m.target.value),placeholder:"Platform squad",autoFocus:!0,"data-testid":"apigee-team-name"}),d?null:e(k,{children:"The identifier of the team in Apigee comes from the name and cannot change later."})]}),l(f,{children:[e(b,{children:"Description"}),e(O,{value:g,onChange:m=>s(m.target.value),placeholder:"What does this team build?"})]})]})}function le(n){var{open:a}=n,r=x(n,["open"]);return a?e(X,Object.assign({},r)):null}function X({onClose:n,onConfirm:a,title:r,children:t,confirmLabel:o,danger:d,withNote:c,noteLabel:h="Note",notePlaceholder:g="Optional"}){const[s,i]=v(""),u=D(),m=()=>j(this,void 0,void 0,function*(){(yield u.run(()=>a(s.trim()||void 0)))!==void 0&&n()});return l(I,{open:!0,onClose:n,title:r,testId:"apigee-confirm-dialog",footer:l(N,{children:[e(y,{variant:"outlined",onClick:n,disabled:u.pending,children:"Cancel"}),e(y,{variant:"primary",tone:d?"danger":"default",onClick:m,disabled:u.pending,"data-testid":"apigee-confirm",children:o})]}),children:[u.error?e(S,{tone:"danger",children:u.error}):null,t,c?l(f,{children:[e(b,{children:h}),e(O,{value:s,onChange:C=>i(C.target.value),placeholder:g,"data-testid":"apigee-confirm-note"})]}):null]})}export{oe as AppDialog,le as ConfirmDialog,ae as KeyDialog,ie 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 y=function(h,u,d,c){function p(r){return r instanceof d?r:new d(function(s){s(r)})}return new(d||(d=Promise))(function(r,s){function l(m){try{g(c.next(m))}catch(x){s(x)}}function n(m){try{g(c.throw(m))}catch(x){s(x)}}function g(m){m.done?r(m.value):p(m.value).then(l,n)}g((c=c.apply(h,u||[])).next())})};import{Fragment as R,jsx as e,jsxs as i}from"react/jsx-runtime";import{useState as w}from"react";import{useNavigate as U}from"react-router";import{Button as b}from"@redocly/theme/components/Button/Button";import{Dropdown as ne}from"@redocly/theme/components/Dropdown/Dropdown";import{DropdownMenu as ae}from"@redocly/theme/components/Dropdown/DropdownMenu";import{Link as L}from"@redocly/theme/components/Link/Link";import{Tag as S}from"@redocly/theme/components/Tag/Tag";import{CDNIcon as M}from"@redocly/theme/icons/CDNIcon/CDNIcon";import{apigeeApi as v}from"../api.js";import{useApigee as Y}from"../context.js";import{formatDate as B,useAsync as H,useMutation as re}from"../hooks.js";import{Breadcrumb as le,EmptyState as P,Field as V,FieldLabel as K,Input as oe,Loading as W,Muted as N,NativeSelect as q,Notice as _,PageHeader as G,Row as I,Section as J,SectionHeader as de,SectionTitle as Q,StatusTag as ce,Table as $,TableWrap as z}from"../Primitives.js";import{ConfirmDialog as X,TeamDialog as Z}from"./Dialogs.js";function Ae({teams:h,onTeamsChanged:u}){const{link:d}=Y(),c=U(),[p,r]=w(!1),s=e(Z,{open:p,onClose:()=>r(!1),onSubmit:n=>y(this,void 0,void 0,function*(){const g=yield v.createTeam(n);return u(),c(d(`/teams/${encodeURIComponent(g.id)}`)),g})}),l=e(b,{variant:"primary",onClick:()=>r(!0),icon:e(M,{name:"plus",size:"16px"}),"data-testid":"apigee-new-team",children:"New team"});return i(R,{children:[e(G,{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:h.length>0?l:void 0}),h.length===0?e(P,{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:l}):e(z,{children:i($,{"data-testid":"apigee-teams-table",children:[e("thead",{children:i("tr",{children:[e("th",{children:"Team"}),e("th",{children:"Members"}),e("th",{children:"Your role"}),e("th",{children:"Created"})]})}),e("tbody",{children:h.map(n=>i("tr",{children:[i("td",{children:[e(L,{to:d(`/teams/${encodeURIComponent(n.id)}`),children:n.name}),n.description?i(R,{children:[e("br",{}),e(N,{children:n.description})]}):null]}),e("td",{children:n.members.length}),e("td",{children:n.myRole?e(S,{color:n.myRole==="owner"?"blue":"grey",children:n.myRole}):null}),e("td",{children:B(n.createdAt)})]},n.id))})]})}),s]})}function Re({teamId:h,onTeamsChanged:u}){var d,c;const{link:p,meta:r}=Y(),s=U(),l=H(()=>v.getTeam(h),`team:${h}`),n=H(()=>v.listApps(),`team-apps:${h}`),[g,m]=w(!1),[x,j]=w(!1),[f,T]=w(null),[D,E]=w(""),[F,ee]=w("member"),C=re();if(l.loading&&!l.data)return e(W,{children:"Loading the team\u2026"});if(l.error||!l.data)return e(_,{tone:"danger",children:(d=l.error)!==null&&d!==void 0?d:"Team not found"});const o=l.data,k=o.myRole==="owner",O=((c=n.data)!==null&&c!==void 0?c:[]).filter(t=>t.owner.kind==="team"&&t.owner.teamId===o.id),te=()=>y(this,void 0,void 0,function*(){const t=yield C.run(()=>v.addMember(o.id,{email:D.trim(),role:F}));t&&(l.setData(t),E(""),u())}),ie=(t,a)=>y(this,void 0,void 0,function*(){const A=yield C.run(()=>v.setMemberRole(o.id,t,a));A&&l.setData(A)});return i("div",{"data-testid":"apigee-team-detail",children:[i(le,{children:[e(L,{to:p("/teams"),children:"Teams"}),e("span",{children:"/"}),e("span",{children:o.name})]}),e(G,{title:o.name,description:o.description||"Shared apps and keys for the team.",actions:k?i(R,{children:[e(b,{variant:"outlined",onClick:()=>m(!0),icon:e(M,{name:"pen",size:"16px"}),children:"Edit team"}),e(b,{variant:"primary",onClick:()=>s(p("",{createApp:"",team:o.id})),icon:e(M,{name:"plus",size:"16px"}),"data-testid":"apigee-new-team-app",children:"New team app"}),e(ne,{trigger:e(b,{variant:"text","aria-label":"More",icon:e(M,{name:"ellipsis-vertical",size:"16px"})}),alignment:"end",children:e(ae,{items:[{content:"Delete team",dangerous:!0,onAction:()=>j(!0),dataAttributes:{"data-testid":"apigee-delete-team"}}]})})]}):e(b,{variant:"outlined",tone:"danger",onClick:()=>T(r.viewer.email),children:"Leave team"})}),C.error?e(_,{tone:"danger",children:C.error}):null,i(J,{children:[e(Q,{children:"Members"}),e(z,{children:i($,{"data-testid":"apigee-members-table",children:[e("thead",{children:i("tr",{children:[e("th",{children:"Member"}),e("th",{children:"Role"}),e("th",{children:"Added"}),e("th",{className:"actions"})]})}),e("tbody",{children:o.members.map(t=>{const a=t.email===r.viewer.email;return i("tr",{"data-testid":"apigee-member-row",children:[e("td",{children:i(I,{children:[t.email,a?e(S,{color:"grey",children:"you"}):null]})}),e("td",{children:k?i(q,{value:t.role,onChange:A=>ie(t.email,A.target.value),style:{width:"auto"},"aria-label":`Role of ${t.email}`,children:[e("option",{value:"member",children:"Member"}),e("option",{value:"owner",children:"Owner"})]}):e(S,{color:t.role==="owner"?"blue":"grey",children:t.role})}),e("td",{children:B(t.addedAt)}),e("td",{className:"actions",children:k||a?e(b,{variant:"text",size:"small",tone:"danger",onClick:()=>T(t.email),"data-testid":"apigee-remove-member",children:a?"Leave":"Remove"}):null})]},t.email)})})]})}),k?i(I,{style:{alignItems:"flex-end",marginTop:"var(--spacing-base)"},"data-testid":"apigee-add-member-form",children:[i(V,{style:{flex:"1 1 260px"},children:[e(K,{children:"Add a member"}),e(oe,{type:"email",value:D,onChange:t=>E(t.target.value),placeholder:"colleague@example.com","data-testid":"apigee-member-email"})]}),i(V,{style:{width:140},children:[e(K,{children:"Role"}),i(q,{value:F,onChange:t=>ee(t.target.value),children:[e("option",{value:"member",children:"Member"}),e("option",{value:"owner",children:"Owner"})]})]}),e(b,{variant:"outlined",onClick:te,disabled:C.pending||!D.trim(),"data-testid":"apigee-add-member",children:"Add"})]}):null,e(N,{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."})]}),i(J,{children:[e(de,{children:e(Q,{children:"Team apps"})}),n.loading&&!n.data?e(W,{children:"Loading apps\u2026"}):n.error?e(_,{tone:"danger",children:n.error}):O.length===0?e(P,{icon:"key",title:"No team apps yet",text:"Create an app for this team so every member can use its keys."}):e(z,{children:i($,{"data-testid":"apigee-team-apps-table",children:[e("thead",{children:i("tr",{children:[e("th",{children:"App"}),e("th",{children:"API products"}),e("th",{children:"Keys"})]})}),e("tbody",{children:O.map(t=>i("tr",{children:[i("td",{children:[e(L,{to:p(`/${encodeURIComponent(t.id)}`,{team:o.id}),children:t.name}),t.description?i(R,{children:[e("br",{}),e(N,{children:t.description})]}):null]}),e("td",{children:e(I,{children:[...new Map(t.credentials.flatMap(a=>a.apiProducts).map(a=>[a.id,a])).values()].map(a=>e(ce,{status:a.status,label:a.id},a.id))})}),e("td",{children:t.credentials.length})]},t.id))})]})})]}),e(Z,{open:g,onClose:()=>m(!1),initial:o,onSubmit:t=>y(this,void 0,void 0,function*(){const a=yield v.updateTeam(o.id,t);return l.setData(a),u(),a})}),e(X,{open:x,onClose:()=>j(!1),title:"Delete team?",confirmLabel:"Delete team",danger:!0,onConfirm:()=>y(this,void 0,void 0,function*(){return yield v.deleteTeam(o.id),u(),s(p("/teams")),!0}),children:i("p",{children:[e("strong",{children:o.name}),", its apps and all of their keys are removed from Apigee. This cannot be undone."]})}),e(X,{open:f!==null,onClose:()=>T(null),title:f===r.viewer.email?"Leave team?":"Remove member?",confirmLabel:f===r.viewer.email?"Leave team":"Remove member",danger:!0,onConfirm:()=>y(this,void 0,void 0,function*(){if(!f)return!0;const t=yield v.removeMember(o.id,f);return f===r.viewer.email?(u(),s(p("/teams"))):l.setData(t),!0}),children:e("p",{children:f===r.viewer.email?"You lose access to the team apps and their keys.":`${f} loses access to the team apps and their keys.`})})]})}export{Re as TeamDetailView,Ae as TeamsView};
|
package/lib/config.d.ts
ADDED
|
@@ -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 = "API keys";
|
|
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;
|
package/lib/constants.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const s="redocly.apigee",p="apigee-apps",a="/apps",t="API keys",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,s 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,p as APIGEE_TEMPLATE_ID};
|
|
@@ -0,0 +1,182 @@
|
|
|
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
|
+
status: ApprovalStatus;
|
|
20
|
+
decision?: Decision;
|
|
21
|
+
};
|
|
22
|
+
export type Credential = {
|
|
23
|
+
/** The consumer key; the value an `apiKey` security scheme sends. */
|
|
24
|
+
consumerKey: string;
|
|
25
|
+
consumerSecret?: string;
|
|
26
|
+
status: ApprovalStatus;
|
|
27
|
+
/** Milliseconds since the epoch; `null` when the key never expires. */
|
|
28
|
+
issuedAt: number | null;
|
|
29
|
+
expiresAt: number | null;
|
|
30
|
+
apiProducts: ApiProductStatus[];
|
|
31
|
+
scopes: string[];
|
|
32
|
+
};
|
|
33
|
+
export type App = {
|
|
34
|
+
/** The Apigee app name: unique per owner, the identifier in every route. */
|
|
35
|
+
id: string;
|
|
36
|
+
/** The display name developers see; falls back to `id`. */
|
|
37
|
+
name: string;
|
|
38
|
+
description: string;
|
|
39
|
+
callbackUrl?: string;
|
|
40
|
+
owner: AppOwner;
|
|
41
|
+
status: string;
|
|
42
|
+
createdAt: number | null;
|
|
43
|
+
lastModifiedAt: number | null;
|
|
44
|
+
credentials: Credential[];
|
|
45
|
+
};
|
|
46
|
+
export type AppInput = {
|
|
47
|
+
name: string;
|
|
48
|
+
description?: string;
|
|
49
|
+
callbackUrl?: string;
|
|
50
|
+
apiProducts: string[];
|
|
51
|
+
/** Shown to the administrators who review a request for a manually approved product. */
|
|
52
|
+
note?: string;
|
|
53
|
+
/** Create the app in this team instead of the developer's own account. */
|
|
54
|
+
teamId?: string;
|
|
55
|
+
};
|
|
56
|
+
export type AppUpdateInput = Partial<Pick<AppInput, 'name' | 'description' | 'callbackUrl'>>;
|
|
57
|
+
export type KeyInput = {
|
|
58
|
+
apiProducts: string[];
|
|
59
|
+
note?: string;
|
|
60
|
+
};
|
|
61
|
+
export type ApiProduct = {
|
|
62
|
+
id: string;
|
|
63
|
+
name: string;
|
|
64
|
+
description: string;
|
|
65
|
+
approvalType: 'auto' | 'manual';
|
|
66
|
+
/** The API page that documents the product, when the catalog has one the viewer can open. */
|
|
67
|
+
api?: {
|
|
68
|
+
slug: string;
|
|
69
|
+
title: string;
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
export type TeamRole = 'owner' | 'member';
|
|
73
|
+
export type TeamMember = {
|
|
74
|
+
email: string;
|
|
75
|
+
role: TeamRole;
|
|
76
|
+
addedAt: number;
|
|
77
|
+
};
|
|
78
|
+
export type Team = {
|
|
79
|
+
/** The Apigee AppGroup name. */
|
|
80
|
+
id: string;
|
|
81
|
+
name: string;
|
|
82
|
+
description: string;
|
|
83
|
+
createdAt: number;
|
|
84
|
+
createdBy: string;
|
|
85
|
+
members: TeamMember[];
|
|
86
|
+
/** The viewer's role, when the viewer is a member. */
|
|
87
|
+
myRole?: TeamRole;
|
|
88
|
+
};
|
|
89
|
+
export type TeamInput = {
|
|
90
|
+
name: string;
|
|
91
|
+
description?: string;
|
|
92
|
+
};
|
|
93
|
+
export type TeamMemberInput = {
|
|
94
|
+
email: string;
|
|
95
|
+
role?: TeamRole;
|
|
96
|
+
};
|
|
97
|
+
export type AccessRequest = {
|
|
98
|
+
/** Opaque; the approve and revoke routes take it back. */
|
|
99
|
+
id: string;
|
|
100
|
+
owner: AppOwner;
|
|
101
|
+
/** The developer who asked, when the request was made through this portal. */
|
|
102
|
+
requestedBy?: string;
|
|
103
|
+
appId: string;
|
|
104
|
+
appName: string;
|
|
105
|
+
/** Masked: the first and last characters only. */
|
|
106
|
+
consumerKey: string;
|
|
107
|
+
apiProduct: string;
|
|
108
|
+
note?: string;
|
|
109
|
+
requestedAt: number | null;
|
|
110
|
+
/** Whether the viewer may decide this request: `maintain` or `admin` on the product's page or the apps page. */
|
|
111
|
+
canDecide: boolean;
|
|
112
|
+
};
|
|
113
|
+
type AuditAction = 'approve' | 'revoke';
|
|
114
|
+
export type AuditEntry = {
|
|
115
|
+
id: string;
|
|
116
|
+
at: number;
|
|
117
|
+
actor: string;
|
|
118
|
+
action: AuditAction;
|
|
119
|
+
owner: AppOwner;
|
|
120
|
+
appId: string;
|
|
121
|
+
appName: string;
|
|
122
|
+
/** Masked: the first and last characters only. */
|
|
123
|
+
consumerKey: string;
|
|
124
|
+
apiProduct: string;
|
|
125
|
+
note?: string;
|
|
126
|
+
};
|
|
127
|
+
/** An app as reviewers see it: its keys without their values. */
|
|
128
|
+
export type AdminApp = Omit<App, 'credentials'> & {
|
|
129
|
+
credentials: Omit<Credential, 'consumerKey' | 'consumerSecret'>[];
|
|
130
|
+
};
|
|
131
|
+
/** The viewer's standing on the Approvals page, from the rbac roles on the API pages and the apps page. */
|
|
132
|
+
export type ApprovalsSummary = {
|
|
133
|
+
/** `approvals.enabled` in the config. */
|
|
134
|
+
enabled: boolean;
|
|
135
|
+
/** `triage` or higher on at least one offered product. */
|
|
136
|
+
canView: boolean;
|
|
137
|
+
/** `maintain` or higher on at least one offered product. */
|
|
138
|
+
canDecide: boolean;
|
|
139
|
+
};
|
|
140
|
+
export type ApigeeMeta = {
|
|
141
|
+
organizationName: string;
|
|
142
|
+
stage: string;
|
|
143
|
+
basePath: string;
|
|
144
|
+
teamsEnabled: boolean;
|
|
145
|
+
approvals: ApprovalsSummary;
|
|
146
|
+
viewer: {
|
|
147
|
+
email: string;
|
|
148
|
+
name?: string;
|
|
149
|
+
};
|
|
150
|
+
apiProducts: ApiProduct[];
|
|
151
|
+
};
|
|
152
|
+
/** What the API reference reads for one product: the viewer's standing and the Try it credentials. */
|
|
153
|
+
export type ApiAccess = {
|
|
154
|
+
status: 'NONE' | 'PENDING' | 'APPROVED';
|
|
155
|
+
/** Where the sidebar button leads: a site path without the path prefix. */
|
|
156
|
+
link: string;
|
|
157
|
+
/** `security.default` for Replay: the first approved key, the developer's own before a team's. */
|
|
158
|
+
requestValues?: {
|
|
159
|
+
security: {
|
|
160
|
+
default: {
|
|
161
|
+
client_id: string;
|
|
162
|
+
client_secret?: string;
|
|
163
|
+
};
|
|
164
|
+
};
|
|
165
|
+
};
|
|
166
|
+
};
|
|
167
|
+
export type ApigeeError = {
|
|
168
|
+
error: string;
|
|
169
|
+
status?: number;
|
|
170
|
+
};
|
|
171
|
+
/** The `apigee` app-data namespace: only the parts of the Realm Plus app-data protocol the client reads. */
|
|
172
|
+
export type ApigeeAppData = {
|
|
173
|
+
accountLinks: {
|
|
174
|
+
label: string;
|
|
175
|
+
link: string;
|
|
176
|
+
}[];
|
|
177
|
+
/** Answers `ApiAccess` for the sidebar button and Try it on a page whose metadata has `apiId`. */
|
|
178
|
+
apiAccessRoute: string;
|
|
179
|
+
};
|
|
180
|
+
/** A consumer key with only its first and last four characters: enough to tell keys apart, not to use one. */
|
|
181
|
+
export declare function maskKey(key: string): string;
|
|
182
|
+
export {};
|
package/lib/contract.js
ADDED
|
@@ -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};
|
package/lib/plugin.d.ts
ADDED
|
@@ -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 API keys 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}],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
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { ApigeeSettings } from '../config.js';
|
|
2
|
+
import type { ApigeeApiProduct, ApigeeApp, ApigeeAppGroup, ApigeeAppInput, ApigeeAttribute, ApigeeCredential, ApigeeDeveloper } from './apigee-types.js';
|
|
3
|
+
import type { TokenProvider } from './token.js';
|
|
4
|
+
/** Who an app belongs to in Apigee: a developer (by email) or an AppGroup (by name). */
|
|
5
|
+
export type AppOwnerPath = {
|
|
6
|
+
kind: 'developer';
|
|
7
|
+
email: string;
|
|
8
|
+
} | {
|
|
9
|
+
kind: 'appgroup';
|
|
10
|
+
name: string;
|
|
11
|
+
};
|
|
12
|
+
export type KeyAction = 'approve' | 'revoke';
|
|
13
|
+
export declare class ApigeeApiError extends Error {
|
|
14
|
+
readonly status: number;
|
|
15
|
+
readonly code?: string | undefined;
|
|
16
|
+
name: string;
|
|
17
|
+
constructor(status: number, message: string, code?: string | undefined);
|
|
18
|
+
}
|
|
19
|
+
export declare class ApigeeClient {
|
|
20
|
+
private readonly settings;
|
|
21
|
+
private readonly getToken;
|
|
22
|
+
private readonly fetchImpl;
|
|
23
|
+
readonly organizationUrl: string;
|
|
24
|
+
constructor(settings: ApigeeSettings, getToken: TokenProvider, fetchImpl?: typeof fetch);
|
|
25
|
+
ownerUrl(owner: AppOwnerPath): string;
|
|
26
|
+
request<T>(path: string, init?: RequestInit & {
|
|
27
|
+
json?: unknown;
|
|
28
|
+
}): Promise<T>;
|
|
29
|
+
listApiProducts(): Promise<ApigeeApiProduct[]>;
|
|
30
|
+
getDeveloper(idOrEmail: string): Promise<ApigeeDeveloper | null>;
|
|
31
|
+
createDeveloper(developer: ApigeeDeveloper): Promise<ApigeeDeveloper>;
|
|
32
|
+
/** Apigee only knows a developer once a record exists; the first app creates it from the session. */
|
|
33
|
+
ensureDeveloper(developer: ApigeeDeveloper): Promise<void>;
|
|
34
|
+
listApps(owner: AppOwnerPath): Promise<ApigeeApp[]>;
|
|
35
|
+
getApp(owner: AppOwnerPath, name: string): Promise<ApigeeApp | null>;
|
|
36
|
+
createApp(owner: AppOwnerPath, input: ApigeeAppInput): Promise<ApigeeApp>;
|
|
37
|
+
updateApp(owner: AppOwnerPath, name: string, input: Partial<ApigeeAppInput> & {
|
|
38
|
+
attributes: ApigeeAttribute[];
|
|
39
|
+
}): Promise<ApigeeApp>;
|
|
40
|
+
deleteApp(owner: AppOwnerPath, name: string): Promise<void>;
|
|
41
|
+
private keyUrl;
|
|
42
|
+
createKey(owner: AppOwnerPath, app: string, key: {
|
|
43
|
+
consumerKey: string;
|
|
44
|
+
consumerSecret: string;
|
|
45
|
+
expiresInSeconds: number;
|
|
46
|
+
}): Promise<ApigeeCredential>;
|
|
47
|
+
getKey(owner: AppOwnerPath, app: string, key: string): Promise<ApigeeCredential | null>;
|
|
48
|
+
/** Associates `apiProducts` with the key; products already on the key stay. */
|
|
49
|
+
addKeyProducts(owner: AppOwnerPath, app: string, key: string, apiProducts: string[], attributes: ApigeeAttribute[] | undefined): Promise<ApigeeCredential>;
|
|
50
|
+
removeKeyProduct(owner: AppOwnerPath, app: string, key: string, apiProduct: string): Promise<void>;
|
|
51
|
+
deleteKey(owner: AppOwnerPath, app: string, key: string): Promise<void>;
|
|
52
|
+
setKeyProductStatus(owner: AppOwnerPath, app: string, key: string, apiProduct: string, action: KeyAction): Promise<void>;
|
|
53
|
+
listAppGroups(): Promise<ApigeeAppGroup[]>;
|
|
54
|
+
getAppGroup(name: string): Promise<ApigeeAppGroup | null>;
|
|
55
|
+
createAppGroup(group: ApigeeAppGroup): Promise<ApigeeAppGroup>;
|
|
56
|
+
updateAppGroup(name: string, group: ApigeeAppGroup): Promise<ApigeeAppGroup>;
|
|
57
|
+
deleteAppGroup(name: string): Promise<void>;
|
|
58
|
+
/** Every app in the organization with its credentials, developer and AppGroup apps alike. */
|
|
59
|
+
listOrganizationApps(): Promise<ApigeeApp[]>;
|
|
60
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var i=function(s,e,t,r){function n(o){return o instanceof t?o:new t(function(a){a(o)})}return new(t||(t=Promise))(function(o,a){function d(u){try{c(r.next(u))}catch(l){a(l)}}function p(u){try{c(r.throw(u))}catch(l){a(l)}}function c(u){u.done?o(u.value):n(u.value).then(d,p)}c((r=r.apply(s,e||[])).next())})};class h extends Error{constructor(e,t,r){super(t),Object.defineProperty(this,"status",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ApigeeApiError"})}}const U="developer.service.DeveloperDoesNotExist",f=1e3;function b(s){var e,t,r,n,o,a,d,p,c,u,l;try{const v=JSON.parse(s),m=(o=(n=(r=(t=(e=v.error)===null||e===void 0?void 0:e.details)===null||t===void 0?void 0:t[0])===null||r===void 0?void 0:r.violations)===null||n===void 0?void 0:n[0])===null||o===void 0?void 0:o.type;return{message:(c=(p=(a=v.error)===null||a===void 0?void 0:a.message)!==null&&p!==void 0?p:v.message)!==null&&c!==void 0?c:s,code:(l=(u=v.code)!==null&&u!==void 0?u:m)!==null&&l!==void 0?l:(d=v.error)===null||d===void 0?void 0:d.status}}catch{return{message:s||"Apigee request failed"}}}function y(s){return encodeURIComponent(s)}class ${constructor(e,t,r=fetch){Object.defineProperty(this,"settings",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"getToken",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"fetchImpl",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"organizationUrl",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.organizationUrl=`${e.apiUrl}/organizations/${encodeURIComponent(e.organizationName)}`}ownerUrl(e){return e.kind==="developer"?`/developers/${y(e.email)}`:`/appgroups/${encodeURIComponent(e.name)}`}request(e){return i(this,arguments,void 0,function*(t,r={}){const n=`${this.organizationUrl}${t}`,o=Object.assign(Object.assign({Accept:"application/json",Authorization:`Bearer ${yield this.getToken()}`},this.settings.auth.type==="OAUTH2"?{"X-Api-Key":this.settings.auth.clientId}:{}),r.headers);let a=r.body;r.json!==void 0&&(o["Content-Type"]="application/json",a=JSON.stringify(r.json));const d=yield this.fetchImpl(n,Object.assign(Object.assign({},r),{headers:o,body:a})),p=yield d.text();if(!d.ok){const{message:c,code:u}=b(p);throw new h(d.status,c,u)}return p?JSON.parse(p):void 0})}listApiProducts(){return i(this,void 0,void 0,function*(){var e;return(e=(yield this.request("/apiproducts?expand=true")).apiProduct)!==null&&e!==void 0?e:[]})}getDeveloper(e){return i(this,void 0,void 0,function*(){try{return yield this.request(`/developers/${y(e)}`)}catch(t){if(t instanceof h&&t.status===404)return null;throw t}})}createDeveloper(e){return i(this,void 0,void 0,function*(){return this.request("/developers",{method:"POST",json:e})})}ensureDeveloper(e){return i(this,void 0,void 0,function*(){if(!(yield this.getDeveloper(e.email)))try{yield this.createDeveloper(e)}catch(t){if(t instanceof h&&t.status===409)return;throw t}})}listApps(e){return i(this,void 0,void 0,function*(){var t,r;try{return e.kind==="appgroup"?(t=(yield this.request(`${this.ownerUrl(e)}/apps`)).appGroupApps)!==null&&t!==void 0?t:[]:(r=(yield this.request(`${this.ownerUrl(e)}/apps?expand=true`)).app)!==null&&r!==void 0?r:[]}catch(n){if(g(n))return[];throw n}})}getApp(e,t){return i(this,void 0,void 0,function*(){try{return yield this.request(`${this.ownerUrl(e)}/apps/${encodeURIComponent(t)}`)}catch(r){if(r instanceof h&&r.status===404||g(r))return null;throw r}})}createApp(e,t){return i(this,void 0,void 0,function*(){return this.request(`${this.ownerUrl(e)}/apps`,{method:"POST",json:t})})}updateApp(e,t,r){return i(this,void 0,void 0,function*(){return this.request(`${this.ownerUrl(e)}/apps/${encodeURIComponent(t)}`,{method:"PUT",json:Object.assign({name:t},r)})})}deleteApp(e,t){return i(this,void 0,void 0,function*(){yield this.request(`${this.ownerUrl(e)}/apps/${encodeURIComponent(t)}`,{method:"DELETE"})})}keyUrl(e,t,r){return`${this.ownerUrl(e)}/apps/${encodeURIComponent(t)}/keys/${encodeURIComponent(r)}`}createKey(e,t,r){return i(this,void 0,void 0,function*(){const n=e.kind==="appgroup"?"keys":"keys/create";return this.request(`${this.ownerUrl(e)}/apps/${encodeURIComponent(t)}/${n}`,{method:"POST",json:{consumerKey:r.consumerKey,consumerSecret:r.consumerSecret,expiresInSeconds:String(r.expiresInSeconds)}})})}getKey(e,t,r){return i(this,void 0,void 0,function*(){try{return yield this.request(this.keyUrl(e,t,r))}catch(n){if(n instanceof h&&n.status===404)return null;throw n}})}addKeyProducts(e,t,r,n,o){return i(this,void 0,void 0,function*(){return this.request(this.keyUrl(e,t,r),{method:"POST",json:{apiProducts:n,attributes:o}})})}removeKeyProduct(e,t,r,n){return i(this,void 0,void 0,function*(){yield this.request(`${this.keyUrl(e,t,r)}/apiproducts/${encodeURIComponent(n)}`,{method:"DELETE"})})}deleteKey(e,t,r){return i(this,void 0,void 0,function*(){yield this.request(this.keyUrl(e,t,r),{method:"DELETE"})})}setKeyProductStatus(e,t,r,n,o){return i(this,void 0,void 0,function*(){yield this.request(`${this.keyUrl(e,t,r)}/apiproducts/${encodeURIComponent(n)}?action=${o}`,{method:"POST",headers:{"Content-Type":"application/octet-stream"}})})}listAppGroups(){return i(this,void 0,void 0,function*(){var e;const t=[];let r;do{const n=new URLSearchParams({pageSize:String(f)});r&&n.set("pageToken",r);const o=yield this.request(`/appgroups?${n}`);t.push(...(e=o.appGroups)!==null&&e!==void 0?e:[]),r=o.nextPageToken}while(r);return t})}getAppGroup(e){return i(this,void 0,void 0,function*(){try{return yield this.request(`/appgroups/${encodeURIComponent(e)}`)}catch(t){if(t instanceof h&&t.status===404)return null;throw t}})}createAppGroup(e){return i(this,void 0,void 0,function*(){return this.request("/appgroups",{method:"POST",json:e})})}updateAppGroup(e,t){return i(this,void 0,void 0,function*(){return this.request(`/appgroups/${encodeURIComponent(e)}`,{method:"PUT",json:t})})}deleteAppGroup(e){return i(this,void 0,void 0,function*(){yield this.request(`/appgroups/${encodeURIComponent(e)}`,{method:"DELETE"})})}listOrganizationApps(){return i(this,void 0,void 0,function*(){var e;const t=[];let r;do{const n=new URLSearchParams({expand:"true",includeCred:"true",pageSize:String(f)});r&&n.set("pageToken",r);const o=yield this.request(`/apps?${n}`);t.push(...(e=o.app)!==null&&e!==void 0?e:[]),r=o.nextPageToken}while(r);return t})}}function g(s){return s instanceof h&&(s.code===U||s.status===404)}export{h as ApigeeApiError,$ as ApigeeClient};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ApiProduct, App, AppOwner, Credential } from '../contract.js';
|
|
2
|
+
import type { ApigeeApiProduct, ApigeeApp, ApigeeAttribute, ApigeeCredential } from './apigee-types.js';
|
|
3
|
+
export declare function attributesToRecord(attributes: ApigeeAttribute[] | undefined): Record<string, string>;
|
|
4
|
+
export declare function recordToAttributes(record: Record<string, string | undefined>): ApigeeAttribute[];
|
|
5
|
+
export declare function toCredential(credential: ApigeeCredential): Credential;
|
|
6
|
+
export declare function toApp(app: ApigeeApp, owner: AppOwner): App;
|
|
7
|
+
export declare function toApiProduct(product: ApigeeApiProduct, api?: {
|
|
8
|
+
slug: string;
|
|
9
|
+
title: string;
|
|
10
|
+
}): ApiProduct;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{APIGEE_DISPLAY_NAME_ATTRIBUTE as a,APIGEE_NOTES_ATTRIBUTE as l}from"../constants.js";function u(t){return Object.fromEntries((t??[]).map(e=>[e.name,e.value]))}function p(t){return Object.entries(t).flatMap(([e,n])=>n===void 0?[]:[{name:e,value:n}])}function r(t){const e=Number(t);return Number.isFinite(e)&&e>0?e:null}function c(t){return t==="approved"||t==="revoked"||t==="pending"?t:"pending"}function d(t){var e,n;return{consumerKey:t.consumerKey,consumerSecret:t.consumerSecret,status:c(t.status),issuedAt:r(t.issuedAt),expiresAt:r(t.expiresAt),apiProducts:((e=t.apiProducts)!==null&&e!==void 0?e:[]).map(s=>({id:s.apiproduct,status:c(s.status)})),scopes:(n=t.scopes)!==null&&n!==void 0?n:[]}}function A(t,e){var n,s,o;const i=u(t.attributes);return Object.assign(Object.assign({id:t.name,name:i[a]||t.name,description:(n=i[l])!==null&&n!==void 0?n:""},t.callbackUrl?{callbackUrl:t.callbackUrl}:{}),{owner:e,status:(s=t.status)!==null&&s!==void 0?s:"approved",createdAt:r(t.createdAt),lastModifiedAt:r(t.lastModifiedAt),credentials:((o=t.credentials)!==null&&o!==void 0?o:[]).map(d)})}function b(t,e){var n;const s=u(t.attributes);return Object.assign({id:t.name,name:t.displayName||s[a]||t.name,description:(n=t.description)!==null&&n!==void 0?n:"",approvalType:t.approvalType==="manual"?"manual":"auto"},e?{api:e}:{})}export{u as attributesToRecord,p as recordToAttributes,b as toApiProduct,A as toApp,d as toCredential};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ServerRouteContext, ServerRouteHandler } from '@redocly/framework/plugin';
|
|
2
|
+
type Context = Parameters<ServerRouteHandler>[0];
|
|
3
|
+
export declare const meta: (c: Context, ctx: ServerRouteContext) => Promise<Response>;
|
|
4
|
+
export declare const access: (c: Context, ctx: ServerRouteContext) => Promise<Response>;
|
|
5
|
+
export declare const listApps: (c: Context, ctx: ServerRouteContext) => Promise<Response>;
|
|
6
|
+
export declare const createApp: (c: Context, ctx: ServerRouteContext) => Promise<Response>;
|
|
7
|
+
export declare const updateApp: (c: Context, ctx: ServerRouteContext) => Promise<Response>;
|
|
8
|
+
export declare const deleteApp: (c: Context, ctx: ServerRouteContext) => Promise<Response>;
|
|
9
|
+
export declare const createKey: (c: Context, ctx: ServerRouteContext) => Promise<Response>;
|
|
10
|
+
export declare const updateKey: (c: Context, ctx: ServerRouteContext) => Promise<Response>;
|
|
11
|
+
export declare const deleteKey: (c: Context, ctx: ServerRouteContext) => Promise<Response>;
|
|
12
|
+
export declare const listTeams: (c: Context, ctx: ServerRouteContext) => Promise<Response>;
|
|
13
|
+
export declare const createTeam: (c: Context, ctx: ServerRouteContext) => Promise<Response>;
|
|
14
|
+
export declare const getTeam: (c: Context, ctx: ServerRouteContext) => Promise<Response>;
|
|
15
|
+
export declare const updateTeam: (c: Context, ctx: ServerRouteContext) => Promise<Response>;
|
|
16
|
+
export declare const deleteTeam: (c: Context, ctx: ServerRouteContext) => Promise<Response>;
|
|
17
|
+
export declare const addTeamMember: (c: Context, ctx: ServerRouteContext) => Promise<Response>;
|
|
18
|
+
export declare const updateTeamMember: (c: Context, ctx: ServerRouteContext) => Promise<Response>;
|
|
19
|
+
export declare const removeTeamMember: (c: Context, ctx: ServerRouteContext) => Promise<Response>;
|
|
20
|
+
export declare const adminRequests: (c: Context, ctx: ServerRouteContext) => Promise<Response>;
|
|
21
|
+
export declare const adminApprove: (c: Context, ctx: ServerRouteContext) => Promise<Response>;
|
|
22
|
+
export declare const adminRevoke: (c: Context, ctx: ServerRouteContext) => Promise<Response>;
|
|
23
|
+
export declare const adminApps: (c: Context, ctx: ServerRouteContext) => Promise<Response>;
|
|
24
|
+
export declare const adminAudit: (c: Context, ctx: ServerRouteContext) => Promise<Response>;
|
|
25
|
+
export {};
|