@moneypot/hub 1.2.4 → 1.2.6
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/dist/cli/add-casino.js
CHANGED
|
@@ -88,9 +88,9 @@ async function addCasino(input) {
|
|
|
88
88
|
function printUsageExample() {
|
|
89
89
|
console.error("\nUsage example:");
|
|
90
90
|
console.error("add-casino \\");
|
|
91
|
-
console.error(` --name "moneypot.
|
|
92
|
-
console.error(" --base_url https://moneypot.
|
|
93
|
-
console.error(" --graphql_url https://api.moneypot.
|
|
91
|
+
console.error(` --name "moneypot.com" \\`);
|
|
92
|
+
console.error(" --base_url https://moneypot.com \\");
|
|
93
|
+
console.error(" --graphql_url https://api.moneypot.com/graphql \\");
|
|
94
94
|
console.error(" --api_key <uuid>");
|
|
95
95
|
}
|
|
96
96
|
async function main() {
|
|
@@ -176,7 +176,7 @@ attempted value: ${c}
|
|
|
176
176
|
}
|
|
177
177
|
}
|
|
178
178
|
}
|
|
179
|
-
`),Tz={name:"moneypot.
|
|
179
|
+
`),Tz={name:"moneypot.com",baseUrl:"https://moneypot.com",graphqlUrl:"https://api.moneypot.com/graphql",apiKey:""},wz=wo().shape({name:ld().required(),baseUrl:E1().required(),graphqlUrl:b1().required(),apiKey:_z().required()}),Az=zt(({show:e,onHide:t})=>{const r=sn(),[i]=Hx(r,{document:Oz}),u=id({initialValues:Tz,validationSchema:wz,onSubmit:async(c,{setSubmitting:h,setStatus:d})=>(d(null),h(!0),i({variables:{input:{name:c.name,baseUrl:c.baseUrl,graphqlUrl:c.graphqlUrl,apiKey:c.apiKey}}}).then(m=>{var E;((E=m.hubAddCasino)==null?void 0:E.casino)&&(r.refetchCasinos(),t())}).catch(m=>{d(Bn(m))}).finally(()=>{h(!1)}))});return v.jsx(It,{show:e,onHide:t,size:"lg",children:v.jsxs(Ve,{onSubmit:u.handleSubmit,children:[v.jsx(It.Header,{closeButton:!0,children:v.jsx(It.Title,{children:"Add Casino"})}),v.jsxs(It.Body,{children:[u.status&&v.jsx(ur,{variant:"danger",className:"mb-3",children:u.status}),v.jsxs("fieldset",{disabled:u.isSubmitting,children:[v.jsxs(Ve.Group,{children:[v.jsx(Ve.Label,{children:"Name (for your own reference)"}),v.jsx(Ve.Control,{type:"text",name:"name",placeholder:"Ex: moneypot.com",value:u.values.name,onChange:u.handleChange,onBlur:u.handleBlur,isInvalid:u.touched.name&&!!u.errors.name}),v.jsx(Ve.Control.Feedback,{type:"invalid",children:u.errors.name})]}),v.jsxs(Ve.Group,{className:"mt-2",children:[v.jsx(Ve.Label,{children:"Website base URL"}),v.jsx(Ve.Control,{type:"text",name:"baseUrl",placeholder:"Ex: https://moneypot.com",value:u.values.baseUrl,onChange:u.handleChange,onBlur:u.handleBlur,isInvalid:u.touched.baseUrl&&!!u.errors.baseUrl}),v.jsx(Ve.Control.Feedback,{type:"invalid",children:u.errors.baseUrl})]}),v.jsxs(Ve.Group,{className:"mt-2",children:[v.jsx(Ve.Label,{children:"GraphQL URL"}),v.jsx(Ve.Control,{type:"text",name:"graphqlUrl",placeholder:"Ex: https://api.moneypot.com/graphql",value:u.values.graphqlUrl,onChange:u.handleChange,onBlur:u.handleBlur,isInvalid:u.touched.graphqlUrl&&!!u.errors.graphqlUrl}),v.jsx(Ve.Control.Feedback,{type:"invalid",children:u.errors.graphqlUrl})]}),v.jsxs(Ve.Group,{className:"mt-2",children:[v.jsxs(Ve.Label,{children:["Controller API Key"," ",v.jsx(xz,{text:"This should be a valid api key that you created for your controller on the casino website"})]}),v.jsx(Ve.Control,{type:"text",name:"apiKey",placeholder:"Ex: 01234567-89ab-cdef-0123-456789abcdef",value:u.values.apiKey,onChange:u.handleChange,onBlur:u.handleBlur,isInvalid:u.touched.apiKey&&!!u.errors.apiKey}),v.jsx(Ve.Control.Feedback,{type:"invalid",children:u.errors.apiKey})]})]})]}),v.jsx(It.Footer,{children:v.jsx(Qt,{type:"submit",disabled:u.isSubmitting,children:u.isSubmitting?"Testing...":"Test connection and save"})})]})})}),Nz=zt(()=>{var i;const e=sn(),[t,r]=b.useState(!1);return v.jsxs("div",{children:[v.jsx(Az,{show:t,onHide:()=>r(!1)}),v.jsxs("h2",{children:["Casinos",v.jsx(Qt,{className:"float-end",onClick:()=>r(!0),children:"Add casino"})]}),v.jsxs(_i,{striped:!0,bordered:!0,hover:!0,children:[v.jsx("thead",{children:v.jsxs("tr",{children:[v.jsx("th",{children:"ID"}),v.jsx("th",{children:"Name"}),v.jsx("th",{children:"Base URL"}),v.jsx("th",{children:"GraphQL URL"}),v.jsx("th",{children:"Added"})]})}),v.jsx("tbody",{children:(i=e.loggedIn)==null?void 0:i.casinos.map(l=>v.jsxs("tr",{children:[v.jsx("td",{children:v.jsx($n,{to:`/casinos/${l.id}`,children:l.id})}),v.jsx("td",{children:l.name}),v.jsxs("td",{style:{whiteSpace:"nowrap"},children:[v.jsx("span",{className:"user-select-all",children:l.baseUrl})," ",v.jsx("a",{href:l.baseUrl,target:"_blank",rel:"noreferrer",className:"text-decoration-none",children:v.jsx(Gm,{style:{verticalAlign:"baseline"}})})]}),v.jsxs("td",{style:{whiteSpace:"nowrap"},children:[v.jsx("span",{className:"user-select-all",children:l.graphqlUrl})," ",v.jsx("a",{href:l.graphqlUrl,target:"_blank",rel:"noreferrer",className:"text-decoration-none",children:v.jsx(Gm,{style:{verticalAlign:"baseline"}})})]}),v.jsx("td",{children:v.jsx(Da,{date:El(l.id),variant:"long"})})]},l.id))})]})]})});function Oi(){var i,l;const{casinoId:e}=j_(),t=sn();return b.useEffect(()=>{var u;e&&!((u=t.loggedIn)!=null&&u.casinos.find(c=>c.id===e))&&console.warn(`Casino ${e} not found`)},[e,(i=t.loggedIn)==null?void 0:i.casinos]),((l=t.loggedIn)==null?void 0:l.casinos.find(u=>u.id===e))||null}const v_=[{path:"",title:"Casino"},{path:"users",title:"Users"},{path:"experiences",title:"Experiences"},{path:"bankrolls",title:"Bankrolls"},{path:"currencies",title:"Currencies"},{path:"deposits",title:"Deposits"},{path:"withdrawals",title:"Withdrawals"},{path:"jwks",title:"Pubkeys"}];function Cz(e,t){return e.sort((r,i)=>i.length-r.length).find(r=>t.includes("/"+r))}const Rz=zt(()=>{var h;const e=ka(),t=sn(),r=Mf(),i=Oi();if(!t.loggedIn)return v.jsx("div",{children:"You must be logged in"});if(!i)return v.jsx(Yr,{});const l=Cz(v_.map(d=>d.path),e.pathname),u=e.pathname.match(/^\/casinos\/[^/]+/),c=d=>{var E;if(!u)return;const m=d.target.value,y=(E=t.loggedIn)==null?void 0:E.casinos.find(g=>g.id===m);y&&r(e.pathname.replace(/\/casinos\/[^/]+/,`/casinos/${y.id}`))};return v.jsxs("div",{children:[v.jsxs(bT,{direction:"horizontal",style:{alignItems:"baseline"},children:[v.jsxs(Ip,{children:[v.jsx(Ip.Item,{linkAs:$n,linkProps:{to:"/casinos"},children:"Casinos"}),v.jsx(Ip.Item,{active:!0,children:i.name})]}),v.jsxs(Ve.Select,{className:"ms-2 d-inline-block",style:{width:"auto"},size:"sm",value:i.id,onChange:c,children:[v.jsx("option",{disabled:!0,children:"Select casino"}),(h=t.loggedIn)==null?void 0:h.casinos.map(d=>v.jsx("option",{value:d.id,children:d.name},d.id))]})]}),v.jsx("ul",{className:"nav nav-tabs mb-4 ",children:v_.map(d=>v.jsx("li",{className:"nav-item",children:v.jsx($n,{to:d.path,className:`nav-link ${l===d.path?"active":""}`,children:d.title})},d.path))}),v.jsx(M_,{})]})}),vi=({text:e,sourceRef:t,popoverDuration:r=1e3,popoverPlacement:i="top"})=>{const[l,u]=b.useState("idle"),[c,h]=b.useState(!1),[d,m]=b.useState("success"),y=b.useRef(null),E=b.useRef(null),g=b.useRef(null);b.useEffect(()=>()=>{y.current&&clearTimeout(y.current),E.current&&clearTimeout(E.current)},[]);const _=x=>{m(x),h(!0),E.current&&clearTimeout(E.current),E.current=setTimeout(()=>{h(!1)},r)},T=()=>{y.current&&clearTimeout(y.current),navigator.clipboard.writeText(e).then(()=>{u("success"),y.current=setTimeout(()=>u("idle"),r),_("success")}).catch(x=>{console.error("Failed to copy text: ",x),u("error"),y.current=setTimeout(()=>u("idle"),r),_("error")})},N=()=>{switch(l){case"success":return v.jsx(Km,{className:"text-success-emphasis"});case"error":return v.jsx(Jm,{className:"text-danger-emphasis"});default:return v.jsx(u1,{})}},A=()=>d==="success"?"Copied!":"Error";return v.jsxs(v.Fragment,{children:[v.jsx(Qt,{ref:g,variant:"outline-secondary",size:"sm",onClick:T,"aria-label":"Copy to clipboard",children:N()}),v.jsx(Jy,{show:c,target:(t==null?void 0:t.current)||g.current,placement:i,children:v.jsx(Um,{id:"copy-popover",children:v.jsx(Um.Body,{children:d==="success"?v.jsxs("span",{className:"text-success-emphasis",children:[v.jsx(Km,{})," ",A()]}):v.jsxs("span",{className:"text-danger-emphasis",children:[v.jsx(Jm,{})," ",A()]})})})})]})},jz=Cr(`
|
|
180
180
|
query ListCasinoUsers($casinoId: UUID!, $after: Cursor) {
|
|
181
181
|
hubCasinoById(id: $casinoId) {
|
|
182
182
|
id
|
|
@@ -204,7 +204,7 @@ attempted value: ${c}
|
|
|
204
204
|
}
|
|
205
205
|
}
|
|
206
206
|
}
|
|
207
|
-
`),Mz=wo().shape({name:ld().required(),baseUrl:E1().required(),graphqlUrl:b1().required()}),$z=zt(({show:e,onHide:t,casino:r})=>{const i=sn(),l={name:r.name,baseUrl:r.baseUrl,graphqlUrl:r.graphqlUrl},u=id({initialValues:l,validationSchema:Mz,onSubmit:async(c,{setSubmitting:h,setStatus:d})=>{d(null),Os(i,{document:kz,variables:{input:{id:r.id,hubCasinoPatch:{name:c.name,baseUrl:c.baseUrl,graphqlUrl:c.graphqlUrl}}}}).then(m=>{var E;((E=m.updateHubCasinoById)==null?void 0:E.hubCasino)&&(i.refetchCasinos(),t())}).catch(m=>{d(Bn(m))}).finally(()=>{h(!1)})}});return v.jsx(It,{show:e,onHide:t,size:"lg",children:v.jsxs(Ve,{onSubmit:u.handleSubmit,children:[v.jsx(It.Header,{closeButton:!0,children:v.jsx(It.Title,{children:"Edit Casino"})}),v.jsxs(It.Body,{children:[u.status&&v.jsx(ur,{variant:"danger",className:"mb-3",children:u.status}),v.jsxs("fieldset",{disabled:u.isSubmitting,children:[v.jsxs(Ve.Group,{children:[v.jsx(Ve.Label,{children:"Name (for your own reference)"}),v.jsx(Ve.Control,{type:"text",name:"name",placeholder:"Ex: moneypot.
|
|
207
|
+
`),Mz=wo().shape({name:ld().required(),baseUrl:E1().required(),graphqlUrl:b1().required()}),$z=zt(({show:e,onHide:t,casino:r})=>{const i=sn(),l={name:r.name,baseUrl:r.baseUrl,graphqlUrl:r.graphqlUrl},u=id({initialValues:l,validationSchema:Mz,onSubmit:async(c,{setSubmitting:h,setStatus:d})=>{d(null),Os(i,{document:kz,variables:{input:{id:r.id,hubCasinoPatch:{name:c.name,baseUrl:c.baseUrl,graphqlUrl:c.graphqlUrl}}}}).then(m=>{var E;((E=m.updateHubCasinoById)==null?void 0:E.hubCasino)&&(i.refetchCasinos(),t())}).catch(m=>{d(Bn(m))}).finally(()=>{h(!1)})}});return v.jsx(It,{show:e,onHide:t,size:"lg",children:v.jsxs(Ve,{onSubmit:u.handleSubmit,children:[v.jsx(It.Header,{closeButton:!0,children:v.jsx(It.Title,{children:"Edit Casino"})}),v.jsxs(It.Body,{children:[u.status&&v.jsx(ur,{variant:"danger",className:"mb-3",children:u.status}),v.jsxs("fieldset",{disabled:u.isSubmitting,children:[v.jsxs(Ve.Group,{children:[v.jsx(Ve.Label,{children:"Name (for your own reference)"}),v.jsx(Ve.Control,{type:"text",name:"name",placeholder:"Ex: moneypot.com",value:u.values.name,onChange:u.handleChange,onBlur:u.handleBlur,isInvalid:u.touched.name&&!!u.errors.name,isValid:u.touched.name&&!u.errors.name}),v.jsx(Ve.Control.Feedback,{type:"invalid",children:u.errors.name})]}),v.jsxs(Ve.Group,{className:"mt-2",children:[v.jsx(Ve.Label,{children:"Website base URL"}),v.jsx(Ve.Control,{type:"text",name:"baseUrl",placeholder:"Ex: https://moneypot.com",value:u.values.baseUrl,onChange:u.handleChange,onBlur:u.handleBlur,isInvalid:u.touched.baseUrl&&!!u.errors.baseUrl}),v.jsx(Ve.Control.Feedback,{type:"invalid",children:u.errors.baseUrl})]}),v.jsxs(Ve.Group,{className:"mt-2",children:[v.jsx(Ve.Label,{children:"GraphQL URL"}),v.jsx(Ve.Control,{type:"text",name:"graphqlUrl",placeholder:"Ex: https://api.moneypot.com/graphql",value:u.values.graphqlUrl,onChange:u.handleChange,onBlur:u.handleBlur,isInvalid:u.touched.graphqlUrl&&!!u.errors.graphqlUrl}),v.jsx(Ve.Control.Feedback,{type:"invalid",children:u.errors.graphqlUrl})]})]})]}),v.jsx(It.Footer,{children:v.jsx(Qt,{type:"submit",disabled:u.isSubmitting,children:"Save casino"})})]})})}),Uz=zt(()=>{const e=Oi(),[t,r]=b.useState(!1);return v.jsxs("div",{children:[v.jsx($z,{show:t,onHide:()=>r(!1),casino:e}),v.jsxs("h2",{children:["Casino: ",e.name,v.jsx(Qt,{className:"ms-2",onClick:()=>r(!0),children:"Edit"})]}),v.jsxs("ul",{children:[v.jsxs("li",{children:[v.jsx("strong",{children:"Name:"})," ",e.name]}),v.jsxs("li",{children:[v.jsx("strong",{children:"Added:"})," ",v.jsx(Da,{date:El(e.id),variant:"long"})]}),v.jsxs("li",{children:[v.jsx("strong",{children:"Base URL:"})," ",v.jsx("a",{href:e.baseUrl,target:"_blank",rel:"noreferrer",children:e.baseUrl})]}),v.jsxs("li",{children:[v.jsx("strong",{children:"GraphQL URL:"})," ",v.jsx("a",{href:e.graphqlUrl,target:"_blank",rel:"noreferrer",children:e.graphqlUrl})]})]})]})}),Lz=Cr(`
|
|
208
208
|
query GetCasinoExperiences($casinoId: UUID!) {
|
|
209
209
|
hubCasinoById(id: $casinoId) {
|
|
210
210
|
id
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>Dashboard</title>
|
|
7
|
-
<script type="module" crossorigin src="/dashboard/assets/index-
|
|
7
|
+
<script type="module" crossorigin src="/dashboard/assets/index-BhzBHOZb.js"></script>
|
|
8
8
|
<link rel="stylesheet" crossorigin href="/dashboard/assets/index-tK7EUtyc.css">
|
|
9
9
|
</head>
|
|
10
10
|
<body>
|
package/dist/src/db/index.d.ts
CHANGED
|
@@ -8,8 +8,8 @@ export * from "./util.js";
|
|
|
8
8
|
export declare function getPgClient(connectionString: string): pg.Client;
|
|
9
9
|
export declare const postgraphilePool: pg.Pool;
|
|
10
10
|
export declare const superuserPool: pg.Pool;
|
|
11
|
-
interface QueryExecutor {
|
|
12
|
-
query<T extends QueryResultRow =
|
|
11
|
+
export interface QueryExecutor {
|
|
12
|
+
query<T extends QueryResultRow = any>(queryText: string, values?: any[]): Promise<QueryResult<T>>;
|
|
13
13
|
}
|
|
14
14
|
export declare class UserFriendlyError extends Error {
|
|
15
15
|
constructor(userFriendlyMessage: string);
|
|
@@ -89,4 +89,4 @@ export declare function upsertCurrencies(pgClient: QueryExecutor, { casinoId, cu
|
|
|
89
89
|
displayUnitName: string;
|
|
90
90
|
displayUnitScale: number;
|
|
91
91
|
}[];
|
|
92
|
-
}): Promise<pg.QueryResult<
|
|
92
|
+
}): Promise<pg.QueryResult<any>>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { PoolClient } from "pg";
|
|
2
2
|
import { GraphQLClient } from "graphql-request";
|
|
3
|
-
import {
|
|
3
|
+
import { Result } from "../util.js";
|
|
4
|
+
import { QueryExecutor } from "../db/index.js";
|
|
4
5
|
export declare function verifyJwtFromDbCacheAndEnsureNotAlreadyUsed(pgClient: PoolClient, { casinoId, jwt, }: {
|
|
5
6
|
casinoId: string;
|
|
6
7
|
jwt: string;
|
package/dist/src/util.d.ts
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import { QueryResult, QueryResultRow } from "pg";
|
|
2
1
|
export declare function isUuid(input: any): boolean;
|
|
3
|
-
export interface QueryExecutor {
|
|
4
|
-
query<T extends QueryResultRow = any>(queryText: string, values?: any[]): Promise<QueryResult<T>>;
|
|
5
|
-
}
|
|
6
2
|
export type Result<V, E> = {
|
|
7
3
|
ok: true;
|
|
8
4
|
value: V;
|