@schemavaults/auth-ui 0.5.55 → 0.6.19
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/components/AccountCard/account_card.d.ts +1 -0
- package/dist/components/AccountCard/account_card.js +4 -2
- package/dist/components/AccountCard/account_card.js.map +1 -1
- package/dist/components/AccountCard/index.d.ts +2 -2
- package/dist/components/AccountCard/index.js +1 -1
- package/dist/components/AccountCard/index.js.map +1 -1
- package/dist/components/ApiServersCard/api_servers_card.d.ts +3 -1
- package/dist/components/ApiServersCard/api_servers_card.js +11 -2
- package/dist/components/ApiServersCard/api_servers_card.js.map +1 -1
- package/dist/components/ApiServersCard/index.d.ts +2 -2
- package/dist/components/ApiServersCard/index.js +1 -1
- package/dist/components/ApiServersCard/index.js.map +1 -1
- package/dist/components/ApiServersTable/ApiServersTable.d.ts +1 -1
- package/dist/components/ApiServersTable/ApiServersTable.js +23 -12
- package/dist/components/ApiServersTable/ApiServersTable.js.map +1 -1
- package/dist/components/ApiServersTable/columns.d.ts +2 -2
- package/dist/components/ApiServersTable/columns.js +2 -1
- package/dist/components/ApiServersTable/columns.js.map +1 -1
- package/dist/components/ApiServersTable/index.d.ts +4 -3
- package/dist/components/ApiServersTable/index.js +2 -1
- package/dist/components/ApiServersTable/index.js.map +1 -1
- package/dist/components/ApiServersTable/useApiServersList.d.ts +2 -3
- package/dist/components/ApiServersTable/useApiServersList.js +14 -47
- package/dist/components/ApiServersTable/useApiServersList.js.map +1 -1
- package/dist/components/AppsCard/apps_card.d.ts +3 -1
- package/dist/components/AppsCard/apps_card.js +13 -5
- package/dist/components/AppsCard/apps_card.js.map +1 -1
- package/dist/components/AppsCard/index.d.ts +3 -2
- package/dist/components/AppsCard/index.js +2 -1
- package/dist/components/AppsCard/index.js.map +1 -1
- package/dist/components/AppsTable/AppDomainsList.d.ts +2 -1
- package/dist/components/AppsTable/AppDomainsList.js +11 -5
- package/dist/components/AppsTable/AppDomainsList.js.map +1 -1
- package/dist/components/AppsTable/AppsTable.js +9 -13
- package/dist/components/AppsTable/AppsTable.js.map +1 -1
- package/dist/components/AppsTable/columns.d.ts +1 -1
- package/dist/components/AppsTable/columns.js +1 -1
- package/dist/components/AppsTable/columns.js.map +1 -1
- package/dist/components/AppsTable/frontend_app_actions.js +1 -3
- package/dist/components/AppsTable/frontend_app_actions.js.map +1 -1
- package/dist/components/AppsTable/index.d.ts +4 -3
- package/dist/components/AppsTable/index.js +2 -1
- package/dist/components/AppsTable/index.js.map +1 -1
- package/dist/components/AppsTable/send-authorize-app-request.d.ts +1 -3
- package/dist/components/AppsTable/send-authorize-app-request.js +3 -33
- package/dist/components/AppsTable/send-authorize-app-request.js.map +1 -1
- package/dist/components/AppsTable/useAppDomains.js +2 -43
- package/dist/components/AppsTable/useAppDomains.js.map +1 -1
- package/dist/components/AppsTable/useAppsList.d.ts +3 -24
- package/dist/components/AppsTable/useAppsList.js +12 -46
- package/dist/components/AppsTable/useAppsList.js.map +1 -1
- package/dist/components/ConnectAppToApiDialog/ConnectAppToApiDialog.d.ts +10 -1
- package/dist/components/ConnectAppToApiDialog/ConnectAppToApiDialog.js +24 -36
- package/dist/components/ConnectAppToApiDialog/ConnectAppToApiDialog.js.map +1 -1
- package/dist/components/ConnectAppToApiDialog/ConnectAppToApiDialogOpenDispatchContext.d.ts +2 -0
- package/dist/components/ConnectAppToApiDialog/ConnectAppToApiDialogOpenDispatchContext.js +8 -0
- package/dist/components/ConnectAppToApiDialog/ConnectAppToApiDialogOpenDispatchContext.js.map +1 -0
- package/dist/components/ConnectAppToApiDialog/index.d.ts +3 -2
- package/dist/components/ConnectAppToApiDialog/index.js +2 -1
- package/dist/components/ConnectAppToApiDialog/index.js.map +1 -1
- package/dist/components/CreateApiServerDialog/CreateApiServerDialog.d.ts +8 -1
- package/dist/components/CreateApiServerDialog/CreateApiServerDialog.js +13 -117
- package/dist/components/CreateApiServerDialog/CreateApiServerDialog.js.map +1 -1
- package/dist/components/CreateApiServerDialog/CreateApiServerDialogOpenDispatchContext.d.ts +2 -0
- package/dist/components/CreateApiServerDialog/CreateApiServerDialogOpenDispatchContext.js +8 -0
- package/dist/components/CreateApiServerDialog/CreateApiServerDialogOpenDispatchContext.js.map +1 -0
- package/dist/components/CreateApiServerDialog/CreateApiServerForm.d.ts +11 -0
- package/dist/components/CreateApiServerDialog/CreateApiServerForm.js +86 -0
- package/dist/components/CreateApiServerDialog/CreateApiServerForm.js.map +1 -0
- package/dist/components/CreateApiServerDialog/index.d.ts +3 -2
- package/dist/components/CreateApiServerDialog/index.js +2 -1
- package/dist/components/CreateApiServerDialog/index.js.map +1 -1
- package/dist/components/CreateAppDialog/CreateAppDialog.d.ts +9 -2
- package/dist/components/CreateAppDialog/CreateAppDialog.js +11 -138
- package/dist/components/CreateAppDialog/CreateAppDialog.js.map +1 -1
- package/dist/components/CreateAppDialog/CreateAppDialogOpenDispatchContext.d.ts +2 -0
- package/dist/components/CreateAppDialog/CreateAppDialogOpenDispatchContext.js +8 -0
- package/dist/components/CreateAppDialog/CreateAppDialogOpenDispatchContext.js.map +1 -0
- package/dist/components/CreateAppDialog/CreateAppForm.d.ts +10 -0
- package/dist/components/CreateAppDialog/CreateAppForm.js +119 -0
- package/dist/components/CreateAppDialog/CreateAppForm.js.map +1 -0
- package/dist/components/CreateAppDialog/index.d.ts +3 -2
- package/dist/components/CreateAppDialog/index.js +2 -1
- package/dist/components/CreateAppDialog/index.js.map +1 -1
- package/dist/components/CreateAppDomainDialog/CreateAppDomainDialog.js +3 -33
- package/dist/components/CreateAppDomainDialog/CreateAppDomainDialog.js.map +1 -1
- package/dist/components/CreateInviteCodeDialog/CreateInviteCodeDialog.d.ts +10 -2
- package/dist/components/CreateInviteCodeDialog/CreateInviteCodeDialog.js +11 -121
- package/dist/components/CreateInviteCodeDialog/CreateInviteCodeDialog.js.map +1 -1
- package/dist/components/CreateInviteCodeDialog/CreateInviteCodeDialogDispatchContext.d.ts +2 -0
- package/dist/components/CreateInviteCodeDialog/CreateInviteCodeDialogDispatchContext.js +8 -0
- package/dist/components/CreateInviteCodeDialog/CreateInviteCodeDialogDispatchContext.js.map +1 -0
- package/dist/components/CreateInviteCodeDialog/CreateInviteCodeForm.d.ts +6 -0
- package/dist/components/CreateInviteCodeDialog/CreateInviteCodeForm.js +113 -0
- package/dist/components/CreateInviteCodeDialog/CreateInviteCodeForm.js.map +1 -0
- package/dist/components/CreateInviteCodeDialog/index.d.ts +3 -1
- package/dist/components/CreateInviteCodeDialog/index.js +2 -1
- package/dist/components/CreateInviteCodeDialog/index.js.map +1 -1
- package/dist/components/CreateOrganizationDialog/CreateOrganizationDialog.d.ts +10 -6
- package/dist/components/CreateOrganizationDialog/CreateOrganizationDialog.js +12 -113
- package/dist/components/CreateOrganizationDialog/CreateOrganizationDialog.js.map +1 -1
- package/dist/components/CreateOrganizationDialog/CreateOrganizationDialogDispatchContext.d.ts +2 -0
- package/dist/components/CreateOrganizationDialog/CreateOrganizationDialogDispatchContext.js +8 -0
- package/dist/components/CreateOrganizationDialog/CreateOrganizationDialogDispatchContext.js.map +1 -0
- package/dist/components/CreateOrganizationDialog/CreateOrganizationForm.d.ts +6 -0
- package/dist/components/CreateOrganizationDialog/CreateOrganizationForm.js +113 -0
- package/dist/components/CreateOrganizationDialog/CreateOrganizationForm.js.map +1 -0
- package/dist/components/CreateOrganizationDialog/index.d.ts +3 -2
- package/dist/components/CreateOrganizationDialog/index.js +2 -1
- package/dist/components/CreateOrganizationDialog/index.js.map +1 -1
- package/dist/components/InviteCodesCard/InviteCodesCard.d.ts +2 -2
- package/dist/components/InviteCodesCard/InviteCodesCard.js +4 -65
- package/dist/components/InviteCodesCard/InviteCodesCard.js.map +1 -1
- package/dist/components/InviteCodesTable/InviteCodesTable.d.ts +5 -5
- package/dist/components/InviteCodesTable/InviteCodesTable.js +18 -7
- package/dist/components/InviteCodesTable/InviteCodesTable.js.map +1 -1
- package/dist/components/InviteCodesTable/columns.d.ts +1 -1
- package/dist/components/InviteCodesTable/index.d.ts +2 -0
- package/dist/components/InviteCodesTable/index.js +1 -0
- package/dist/components/InviteCodesTable/index.js.map +1 -1
- package/dist/components/InviteCodesTable/useAllInviteCodes.d.ts +10 -0
- package/dist/components/InviteCodesTable/useAllInviteCodes.js +56 -0
- package/dist/components/InviteCodesTable/useAllInviteCodes.js.map +1 -0
- package/dist/components/InviteMemberDialog/InviteMemberDialog.d.ts +12 -0
- package/dist/components/InviteMemberDialog/InviteMemberDialog.js +79 -0
- package/dist/components/InviteMemberDialog/InviteMemberDialog.js.map +1 -0
- package/dist/components/InviteMemberDialog/index.d.ts +2 -0
- package/dist/components/InviteMemberDialog/index.js +2 -0
- package/dist/components/InviteMemberDialog/index.js.map +1 -0
- package/dist/components/OrganizationMembersCard/OrganizationMembersCard.d.ts +3 -0
- package/dist/components/OrganizationMembersCard/OrganizationMembersCard.js +3 -23
- package/dist/components/OrganizationMembersCard/OrganizationMembersCard.js.map +1 -1
- package/dist/components/OrganizationMembersTable/OrganizationMembersTable.d.ts +4 -1
- package/dist/components/OrganizationMembersTable/OrganizationMembersTable.js +4 -3
- package/dist/components/OrganizationMembersTable/OrganizationMembersTable.js.map +1 -1
- package/dist/components/OrganizationMembersTable/columns.d.ts +1 -1
- package/dist/components/OrganizationMembersTable/columns.js +3 -3
- package/dist/components/OrganizationMembersTable/columns.js.map +1 -1
- package/dist/components/OrganizationsCard/OrganizationsCard.d.ts +2 -2
- package/dist/components/OrganizationsCard/OrganizationsCard.js +4 -65
- package/dist/components/OrganizationsCard/OrganizationsCard.js.map +1 -1
- package/dist/components/OrganizationsTable/OrganizationsTable.d.ts +2 -3
- package/dist/components/OrganizationsTable/OrganizationsTable.js +12 -8
- package/dist/components/OrganizationsTable/OrganizationsTable.js.map +1 -1
- package/dist/components/OrganizationsTable/columns.d.ts +1 -1
- package/dist/components/OrganizationsTable/columns.js.map +1 -1
- package/dist/components/OrganizationsTable/index.d.ts +3 -1
- package/dist/components/OrganizationsTable/index.js +2 -1
- package/dist/components/OrganizationsTable/index.js.map +1 -1
- package/dist/components/OrganizationsTable/useAllOrganizationsList.d.ts +8 -0
- package/dist/components/OrganizationsTable/useAllOrganizationsList.js +58 -0
- package/dist/components/OrganizationsTable/useAllOrganizationsList.js.map +1 -0
- package/dist/components/UsersCard/UsersCard.js +1 -22
- package/dist/components/UsersCard/UsersCard.js.map +1 -1
- package/dist/components/UsersTable/columns.d.ts +1 -1
- package/dist/components/UsersTable/columns.js +1 -1
- package/dist/components/UsersTable/columns.js.map +1 -1
- package/dist/components/index.d.ts +7 -5
- package/dist/components/index.js +3 -2
- package/dist/components/index.js.map +1 -1
- package/package.json +9 -9
|
@@ -1,124 +1,20 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { Button
|
|
4
|
-
import {
|
|
5
|
-
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, useForm, } from "@schemavaults/ui";
|
|
6
|
-
import { useAppEnvironment, useAuth } from "@schemavaults/auth-react-provider";
|
|
7
|
-
import { useSWRConfig } from "swr";
|
|
8
|
-
import { SCHEMAVAULTS_AUTH_APP_DEFINITION, schemaVaultsApiServerDefinitionSchema, } from "@schemavaults/app-definitions";
|
|
9
|
-
import { zodResolver } from "@hookform/resolvers/zod";
|
|
3
|
+
import { Button } from "@schemavaults/ui";
|
|
4
|
+
import { Dialog, DialogContent } from "@schemavaults/ui";
|
|
10
5
|
import { Server } from "lucide-react";
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return "";
|
|
18
|
-
}
|
|
6
|
+
import CreateApiServerForm from "./CreateApiServerForm";
|
|
7
|
+
import { SCHEMAVAULTS_ORGANIZATION_ID } from "@schemavaults/auth-common";
|
|
8
|
+
export function CreateApiServerDialog({ clearApiServersCache, owner_organization_id, open, onOpenChange, uuid, }) {
|
|
9
|
+
return (_jsx(Dialog, { open: open, onOpenChange: onOpenChange, children: _jsx(DialogContent, { id: "create-api-server-dialog-content", className: "sm:max-w-[425px]", children: _jsx(CreateApiServerForm, { clearApiServersCache: clearApiServersCache, owner_organization_id: owner_organization_id
|
|
10
|
+
? owner_organization_id
|
|
11
|
+
: SCHEMAVAULTS_ORGANIZATION_ID, onSuccess: () => onOpenChange(false), uuid: uuid }) }) }));
|
|
19
12
|
}
|
|
20
|
-
export function
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
api_server_id: generateDefaultApiServerId(),
|
|
26
|
-
api_server_description: "",
|
|
27
|
-
public: false,
|
|
28
|
-
created_at: Date.now(),
|
|
29
|
-
hardcoded: false,
|
|
30
|
-
owner_organization_id,
|
|
31
|
-
};
|
|
32
|
-
}, [owner_organization_id]);
|
|
33
|
-
const form = useForm({
|
|
34
|
-
resolver: zodResolver(schemaVaultsApiServerDefinitionSchema),
|
|
35
|
-
defaultValues,
|
|
36
|
-
});
|
|
37
|
-
const auth = useAuth();
|
|
38
|
-
const environment = useAppEnvironment();
|
|
39
|
-
const { mutate } = useSWRConfig();
|
|
40
|
-
async function onSubmit(values) {
|
|
41
|
-
if (environment === "development") {
|
|
42
|
-
console.log("Submitting API creation form...");
|
|
43
|
-
toast({
|
|
44
|
-
variant: "default",
|
|
45
|
-
title: "Submitting API creation form...",
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
const authClient = auth.ready ? auth.client.current : undefined;
|
|
49
|
-
if (!authClient) {
|
|
50
|
-
toast({
|
|
51
|
-
variant: "destructive",
|
|
52
|
-
title: "Auth client not ready",
|
|
53
|
-
description: `Cannot acquire an access token yet`,
|
|
54
|
-
});
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
let auth_access_jwt;
|
|
58
|
-
try {
|
|
59
|
-
const auth_jwt = await authClient.acquireAccessToken({
|
|
60
|
-
token_id: SCHEMAVAULTS_AUTH_APP_DEFINITION.app_id,
|
|
61
|
-
audience: SCHEMAVAULTS_AUTH_APP_DEFINITION.app_id,
|
|
62
|
-
});
|
|
63
|
-
if (!auth_jwt) {
|
|
64
|
-
throw new Error("Failed to acquire auth access token");
|
|
65
|
-
}
|
|
66
|
-
auth_access_jwt = auth_jwt;
|
|
67
|
-
}
|
|
68
|
-
catch (e) {
|
|
69
|
-
toast({
|
|
70
|
-
variant: "destructive",
|
|
71
|
-
title: "Error loading authentication access token",
|
|
72
|
-
description: e instanceof Error ? e.message : `Failed to prepare network request`,
|
|
73
|
-
});
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
try {
|
|
77
|
-
const response = await fetch("/api/apis", {
|
|
78
|
-
method: "POST",
|
|
79
|
-
body: JSON.stringify({
|
|
80
|
-
...values,
|
|
81
|
-
owner_organization_id: owner_organization_id ?? null,
|
|
82
|
-
}),
|
|
83
|
-
headers: {
|
|
84
|
-
Authorization: `Bearer ${auth_access_jwt.token}}`,
|
|
85
|
-
},
|
|
86
|
-
});
|
|
87
|
-
if (!response.ok || response.status !== 200) {
|
|
88
|
-
throw new Error(`API server creation request has bad status: ${response.status}`);
|
|
89
|
-
}
|
|
90
|
-
const body = await response.json();
|
|
91
|
-
if (typeof body !== "object") {
|
|
92
|
-
throw new Error("Expected JSON object response from API server creation attempt");
|
|
93
|
-
}
|
|
94
|
-
if (!Object.hasOwn(body, "success")) {
|
|
95
|
-
throw new Error("No success field in response");
|
|
96
|
-
}
|
|
97
|
-
if (!(typeof body.success === "boolean" &&
|
|
98
|
-
body.success)) {
|
|
99
|
-
console.error(body);
|
|
100
|
-
throw new Error("API server creation response has success flag set to false");
|
|
101
|
-
}
|
|
102
|
-
if (environment === "development") {
|
|
103
|
-
console.log("Received response: ", body);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
catch (e) {
|
|
107
|
-
toast({
|
|
108
|
-
variant: "destructive",
|
|
109
|
-
title: "Failed to create new API server",
|
|
110
|
-
description: e instanceof Error ? e.message : `Failed to send network request`,
|
|
111
|
-
});
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
toast({
|
|
115
|
-
variant: "default",
|
|
116
|
-
title: "Created new API server successfully",
|
|
117
|
-
});
|
|
118
|
-
clearApiServersCache(mutate);
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
return (_jsxs(Dialog, { children: [_jsx(DialogTrigger, { asChild: true, children: _jsxs(Button, { children: [_jsx(Server, { className: "h-4 w-4 mr-2" }), " Create API"] }) }), _jsx(DialogContent, { className: "sm:max-w-[425px]", children: _jsx(Form, { ...form, children: _jsxs("form", { onSubmit: form.handleSubmit(onSubmit, (e) => console.error(e)), className: "flex flex-col justify-start gap-4", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { children: "Create a new API server" }), _jsx(DialogDescription, { children: "Create a new frontend/client application which can access SchemaVaults APIs." })] }), _jsx(FormField, { control: form.control, name: "api_server_name", render: ({ field }) => (_jsxs(FormItem, { children: [_jsx(FormLabel, { children: "API Server Name" }), _jsx(FormControl, { children: _jsx(Input, { placeholder: "My New Resource Server", ...field }) }), _jsx(FormDescription, { children: "Give a user-friendly name to the new backend API server application." }), _jsx(FormMessage, {})] })) }), _jsx(FormField, { control: form.control, name: "api_server_description", render: ({ field }) => (_jsxs(FormItem, { children: [_jsx(FormLabel, { children: "Description" }), _jsx(FormControl, { children: _jsx(Textarea, { placeholder: "This API server provides search functionality to my new app.", ...field }) }), _jsx(FormDescription, { children: "Describe what this API server does." }), _jsx(FormMessage, {})] })) }), _jsx(FormField, { control: form.control, name: "public", render: ({ field }) => (_jsxs(FormItem, { className: "flex flex-row gap-2 items-center flex-wrap", children: [_jsx(FormLabel, { className: "w-full", children: "Public?" }), _jsx(FormControl, { children: _jsx(Checkbox, { checked: field.value, onCheckedChange: field.onChange }) }), _jsx(FormDescription, { className: "w-full", children: "Is this API publicly listed to end-users? I.e. can they find it without having authorized a connected client application first?" }), _jsx(FormMessage, {})] })) }), _jsx(DialogFooter, { children: _jsxs(Button, { type: "submit", children: [_jsx(Server, { className: "h-4 w-4 mr-2" }), "Create Server Application"] }) })] }) }) })] }));
|
|
13
|
+
export function CreateApiServerDialogTrigger({ onOpenChange, }) {
|
|
14
|
+
return (_jsxs(Button, { id: "open-create-api-server-dialog-button", onClick: (e) => {
|
|
15
|
+
e.preventDefault();
|
|
16
|
+
onOpenChange(true);
|
|
17
|
+
}, children: [_jsx(Server, { className: "h-4 w-4 mr-2" }), " Create API"] }));
|
|
122
18
|
}
|
|
123
19
|
export default CreateApiServerDialog;
|
|
124
20
|
//# sourceMappingURL=CreateApiServerDialog.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CreateApiServerDialog.js","sourceRoot":"","sources":["../../../src/components/CreateApiServerDialog/CreateApiServerDialog.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,
|
|
1
|
+
{"version":3,"file":"CreateApiServerDialog.js","sourceRoot":"","sources":["../../../src/components/CreateApiServerDialog/CreateApiServerDialog.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAG1C,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEzD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,mBAAmB,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,4BAA4B,EAAE,MAAM,2BAA2B,CAAC;AAYzE,MAAM,UAAU,qBAAqB,CAAC,EACpC,oBAAoB,EACpB,qBAAqB,EACrB,IAAI,EACJ,YAAY,EACZ,IAAI,GACuB;IAC3B,OAAO,CACL,KAAC,MAAM,IAAC,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,YAAY,YAC5C,KAAC,aAAa,IACZ,EAAE,EAAC,kCAAkC,EACrC,SAAS,EAAC,kBAAkB,YAE5B,KAAC,mBAAmB,IAClB,oBAAoB,EAAE,oBAAoB,EAC1C,qBAAqB,EACnB,qBAAqB;oBACnB,CAAC,CAAC,qBAAqB;oBACvB,CAAC,CAAC,4BAA4B,EAElC,SAAS,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,EACpC,IAAI,EAAE,IAAI,GACV,GACY,GACT,CACV,CAAC;AACJ,CAAC;AAKD,MAAM,UAAU,4BAA4B,CAAC,EAC3C,YAAY,GACsB;IAClC,OAAO,CACL,MAAC,MAAM,IACL,EAAE,EAAC,sCAAsC,EACzC,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE;YACb,CAAC,CAAC,cAAc,EAAE,CAAC;YACnB,YAAY,CAAC,IAAI,CAAC,CAAC;QACrB,CAAC,aAED,KAAC,MAAM,IAAC,SAAS,EAAC,cAAc,GAAG,mBAC5B,CACV,CAAC;AACJ,CAAC;AAED,eAAe,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { createContext } from "react";
|
|
3
|
+
export const CreateApiServerDialogOpenDispatchContext = createContext((val) => {
|
|
4
|
+
void val;
|
|
5
|
+
throw new Error("Not within CreateApiServerDialogOpenDispatchContext.Provider render tree!");
|
|
6
|
+
});
|
|
7
|
+
export default CreateApiServerDialogOpenDispatchContext;
|
|
8
|
+
//# sourceMappingURL=CreateApiServerDialogOpenDispatchContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CreateApiServerDialogOpenDispatchContext.js","sourceRoot":"","sources":["../../../src/components/CreateApiServerDialog/CreateApiServerDialogOpenDispatchContext.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEtC,MAAM,CAAC,MAAM,wCAAwC,GAAG,aAAa,CAEnE,CAAC,GAAY,EAAE,EAAE;IACjB,KAAK,GAAG,CAAC;IACT,MAAM,IAAI,KAAK,CACb,2EAA2E,CAC5E,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,wCAAwC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type ReactElement } from "react";
|
|
2
|
+
import { useSWRConfig } from "swr";
|
|
3
|
+
import type { OrganizationID } from "@schemavaults/auth-common";
|
|
4
|
+
interface CreateApiServerFormProps {
|
|
5
|
+
clearApiServersCache: (mutate: ReturnType<typeof useSWRConfig>["mutate"]) => void;
|
|
6
|
+
owner_organization_id: OrganizationID;
|
|
7
|
+
uuid: () => string;
|
|
8
|
+
onSuccess: () => void;
|
|
9
|
+
}
|
|
10
|
+
export declare function CreateApiServerForm({ clearApiServersCache, owner_organization_id, uuid, onSuccess, }: CreateApiServerFormProps): ReactElement;
|
|
11
|
+
export default CreateApiServerForm;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Button, Checkbox, Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, Input, Textarea, useToast, } from "@schemavaults/ui";
|
|
4
|
+
import { useMemo } from "react";
|
|
5
|
+
import { DialogDescription, DialogFooter, DialogHeader, DialogTitle, useForm, } from "@schemavaults/ui";
|
|
6
|
+
import { useAppEnvironment } from "@schemavaults/auth-react-provider";
|
|
7
|
+
import { useSWRConfig } from "swr";
|
|
8
|
+
import { schemaVaultsApiServerDefinitionSchema, } from "@schemavaults/app-definitions";
|
|
9
|
+
import { zodResolver } from "@hookform/resolvers/zod";
|
|
10
|
+
import { Server } from "lucide-react";
|
|
11
|
+
export function CreateApiServerForm({ clearApiServersCache, owner_organization_id, uuid, onSuccess, }) {
|
|
12
|
+
const { toast } = useToast();
|
|
13
|
+
const defaultValues = useMemo(() => {
|
|
14
|
+
return {
|
|
15
|
+
api_server_name: "",
|
|
16
|
+
api_server_id: uuid(),
|
|
17
|
+
api_server_description: "",
|
|
18
|
+
public: false,
|
|
19
|
+
created_at: Date.now(),
|
|
20
|
+
hardcoded: false,
|
|
21
|
+
owner_organization_id,
|
|
22
|
+
};
|
|
23
|
+
}, [owner_organization_id, uuid]);
|
|
24
|
+
const form = useForm({
|
|
25
|
+
resolver: zodResolver(schemaVaultsApiServerDefinitionSchema),
|
|
26
|
+
defaultValues,
|
|
27
|
+
});
|
|
28
|
+
const environment = useAppEnvironment();
|
|
29
|
+
const { mutate } = useSWRConfig();
|
|
30
|
+
async function onSubmit(values) {
|
|
31
|
+
if (environment === "development") {
|
|
32
|
+
console.log("Submitting API creation form...");
|
|
33
|
+
toast({
|
|
34
|
+
variant: "default",
|
|
35
|
+
title: "Submitting API creation form...",
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
try {
|
|
39
|
+
const response = await fetch("/api/apis", {
|
|
40
|
+
method: "POST",
|
|
41
|
+
body: JSON.stringify({
|
|
42
|
+
...values,
|
|
43
|
+
owner_organization_id: owner_organization_id ?? null,
|
|
44
|
+
}),
|
|
45
|
+
credentials: "include",
|
|
46
|
+
});
|
|
47
|
+
if (!response.ok || response.status !== 200) {
|
|
48
|
+
throw new Error(`API server creation request has bad status: ${response.status}`);
|
|
49
|
+
}
|
|
50
|
+
const body = await response.json();
|
|
51
|
+
if (typeof body !== "object") {
|
|
52
|
+
throw new Error("Expected JSON object response from API server creation attempt");
|
|
53
|
+
}
|
|
54
|
+
if (!Object.hasOwn(body, "success")) {
|
|
55
|
+
throw new Error("No success field in response");
|
|
56
|
+
}
|
|
57
|
+
if (!(typeof body.success === "boolean" &&
|
|
58
|
+
body.success)) {
|
|
59
|
+
console.error(body);
|
|
60
|
+
throw new Error("API server creation response has success flag set to false");
|
|
61
|
+
}
|
|
62
|
+
if (environment === "development") {
|
|
63
|
+
console.log("Received response: ", body);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
catch (e) {
|
|
67
|
+
toast({
|
|
68
|
+
variant: "destructive",
|
|
69
|
+
title: "Failed to create new API server",
|
|
70
|
+
description: e instanceof Error ? e.message : `Failed to send network request`,
|
|
71
|
+
});
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
toast({
|
|
75
|
+
variant: "default",
|
|
76
|
+
title: "Created new API server successfully",
|
|
77
|
+
});
|
|
78
|
+
clearApiServersCache(mutate);
|
|
79
|
+
form.reset();
|
|
80
|
+
onSuccess();
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
return (_jsx(Form, { ...form, children: _jsxs("form", { onSubmit: form.handleSubmit(onSubmit, (e) => console.error(e)), className: "flex flex-col justify-start gap-4", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { children: "Create a new API server" }), _jsx(DialogDescription, { children: "Create a new frontend/client application which can access SchemaVaults APIs." })] }), _jsx(FormField, { control: form.control, name: "api_server_name", render: ({ field }) => (_jsxs(FormItem, { children: [_jsx(FormLabel, { children: "API Server Name" }), _jsx(FormControl, { children: _jsx(Input, { placeholder: "My New Resource Server", ...field }) }), _jsx(FormDescription, { children: "Give a user-friendly name to the new backend API server application." }), _jsx(FormMessage, {})] })) }), _jsx(FormField, { control: form.control, name: "api_server_description", render: ({ field }) => (_jsxs(FormItem, { children: [_jsx(FormLabel, { children: "Description" }), _jsx(FormControl, { children: _jsx(Textarea, { placeholder: "This API server provides search functionality to my new app.", ...field }) }), _jsx(FormDescription, { children: "Describe what this API server does." }), _jsx(FormMessage, {})] })) }), _jsx(FormField, { control: form.control, name: "public", render: ({ field }) => (_jsxs(FormItem, { className: "flex flex-row gap-2 items-center flex-wrap", children: [_jsx(FormLabel, { className: "w-full", children: "Public?" }), _jsx(FormControl, { children: _jsx(Checkbox, { checked: field.value, onCheckedChange: field.onChange }) }), _jsx(FormDescription, { className: "w-full", children: "Is this API publicly listed to end-users? I.e. can they find it without having authorized a connected client application first?" }), _jsx(FormMessage, {})] })) }), _jsx(DialogFooter, { children: _jsxs(Button, { id: "submit-create-api-server-form-button", type: "submit", children: [_jsx(Server, { className: "h-4 w-4 mr-2" }), "Create Server Application"] }) })] }) }));
|
|
84
|
+
}
|
|
85
|
+
export default CreateApiServerForm;
|
|
86
|
+
//# sourceMappingURL=CreateApiServerForm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CreateApiServerForm.js","sourceRoot":"","sources":["../../../src/components/CreateApiServerDialog/CreateApiServerForm.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EACL,MAAM,EACN,QAAQ,EACR,IAAI,EACJ,WAAW,EACX,eAAe,EACf,SAAS,EACT,QAAQ,EACR,SAAS,EACT,WAAW,EACX,KAAK,EACL,QAAQ,EACR,QAAQ,GACT,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAqB,MAAM,OAAO,CAAC;AAEnD,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,OAAO,GACR,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,KAAK,CAAC;AACnC,OAAO,EAEL,qCAAqC,GAEtC,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAYtC,MAAM,UAAU,mBAAmB,CAAC,EAClC,oBAAoB,EACpB,qBAAqB,EACrB,IAAI,EACJ,SAAS,GACgB;IACzB,MAAM,EAAE,KAAK,EAAE,GAAG,QAAQ,EAAE,CAAC;IAE7B,MAAM,aAAa,GACjB,OAAO,CAAC,GAAG,EAAE;QACX,OAAO;YACL,eAAe,EAAE,EAAE;YACnB,aAAa,EAAE,IAAI,EAAE;YACrB,sBAAsB,EAAE,EAAE;YAC1B,MAAM,EAAE,KAAK;YACb,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE;YACtB,SAAS,EAAE,KAAK;YAChB,qBAAqB;SACtB,CAAC;IACJ,CAAC,EAA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
|
|
1
|
+
export { CreateApiServerDialog, CreateApiServerDialog as default, CreateApiServerDialogTrigger, } from "./CreateApiServerDialog";
|
|
2
|
+
export type * from "./CreateApiServerDialog";
|
|
3
|
+
export { CreateApiServerDialogOpenDispatchContext } from "./CreateApiServerDialogOpenDispatchContext";
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export { CreateApiServerDialog } from
|
|
1
|
+
export { CreateApiServerDialog, CreateApiServerDialog as default, CreateApiServerDialogTrigger, } from "./CreateApiServerDialog";
|
|
2
|
+
export { CreateApiServerDialogOpenDispatchContext } from "./CreateApiServerDialogOpenDispatchContext";
|
|
2
3
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/CreateApiServerDialog/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/CreateApiServerDialog/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,qBAAqB,IAAI,OAAO,EAChC,4BAA4B,GAC7B,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EAAE,wCAAwC,EAAE,MAAM,4CAA4C,CAAC"}
|
|
@@ -1,8 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ReactElement } from "react";
|
|
2
2
|
import { useSWRConfig } from "swr";
|
|
3
3
|
interface CreateFrontendAppDialogProps {
|
|
4
4
|
clearFrontendAppsCache: (mutate: ReturnType<typeof useSWRConfig>["mutate"]) => void;
|
|
5
5
|
owner_organization_id?: string | null;
|
|
6
|
+
open: boolean;
|
|
7
|
+
onOpenChange: (val: boolean) => void;
|
|
8
|
+
uuid: () => string;
|
|
6
9
|
}
|
|
7
|
-
export declare function CreateAppDialog({ clearFrontendAppsCache, owner_organization_id, }: CreateFrontendAppDialogProps): ReactElement;
|
|
10
|
+
export declare function CreateAppDialog({ clearFrontendAppsCache, owner_organization_id, ...props }: CreateFrontendAppDialogProps): ReactElement;
|
|
11
|
+
interface CreateFrontendAppDialogTriggerProps {
|
|
12
|
+
onOpenChange: (val: boolean) => void;
|
|
13
|
+
}
|
|
14
|
+
export declare function CreateAppDialogTrigger({ onOpenChange, }: CreateFrontendAppDialogTriggerProps): ReactElement;
|
|
8
15
|
export default CreateAppDialog;
|
|
@@ -1,145 +1,18 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { Button
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { useAppEnvironment, useAuth } from "@schemavaults/auth-react-provider";
|
|
7
|
-
import { useSWRConfig } from "swr";
|
|
8
|
-
import { SCHEMAVAULTS_AUTH_APP_DEFINITION, schemaVaultsAppDefinitionSchema, } from "@schemavaults/app-definitions";
|
|
9
|
-
import { zodResolver } from "@hookform/resolvers/zod";
|
|
3
|
+
import { Button } from "@schemavaults/ui";
|
|
4
|
+
import { Dialog, DialogContent } from "@schemavaults/ui";
|
|
5
|
+
import { SCHEMAVAULTS_ORGANIZATION_ID } from "@schemavaults/auth-common";
|
|
10
6
|
import { AppWindow } from "lucide-react";
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
catch (e) {
|
|
16
|
-
console.error("Failed to generate default APP UUID: ", e);
|
|
17
|
-
return "";
|
|
18
|
-
}
|
|
7
|
+
import CreateAppForm from "./CreateAppForm";
|
|
8
|
+
export function CreateAppDialog({ clearFrontendAppsCache, owner_organization_id, ...props }) {
|
|
9
|
+
return (_jsx(Dialog, { open: props.open, onOpenChange: props.onOpenChange, children: _jsx(DialogContent, { id: "create-app-dialog-content", className: "sm:max-w-[425px]", children: _jsx(CreateAppForm, { owner_organization_id: owner_organization_id ?? SCHEMAVAULTS_ORGANIZATION_ID, clearFrontendAppsCache: clearFrontendAppsCache, onSuccess: () => props.onOpenChange(false), uuid: props.uuid }) }) }));
|
|
19
10
|
}
|
|
20
|
-
export function
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
app_id: generateDefaultAppId(),
|
|
26
|
-
app_description: "Interact with my API",
|
|
27
|
-
public: false,
|
|
28
|
-
created_at: Date.now(),
|
|
29
|
-
hardcoded: false,
|
|
30
|
-
owner_organization_id,
|
|
31
|
-
};
|
|
32
|
-
}, [owner_organization_id]);
|
|
33
|
-
const form = useForm({
|
|
34
|
-
resolver: zodResolver(schemaVaultsAppDefinitionSchema),
|
|
35
|
-
defaultValues,
|
|
36
|
-
});
|
|
37
|
-
const auth = useAuth();
|
|
38
|
-
const environment = useAppEnvironment();
|
|
39
|
-
const { mutate } = useSWRConfig();
|
|
40
|
-
const [submitting, startSubmitting] = useTransition();
|
|
41
|
-
async function onSubmit(values) {
|
|
42
|
-
if (environment === "development") {
|
|
43
|
-
console.log("Submitting frontend app creation form...");
|
|
44
|
-
toast({
|
|
45
|
-
variant: "default",
|
|
46
|
-
title: "Submitting frontend app creation form...",
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
startSubmitting(async () => {
|
|
50
|
-
const authClient = auth.ready ? auth.client.current : undefined;
|
|
51
|
-
if (!authClient) {
|
|
52
|
-
toast({
|
|
53
|
-
variant: "destructive",
|
|
54
|
-
title: "Auth client not ready!",
|
|
55
|
-
description: `Cannot acquire an access token to create app yet.`,
|
|
56
|
-
});
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
let auth_access_jwt;
|
|
60
|
-
try {
|
|
61
|
-
const auth_jwt = await authClient.acquireAccessToken({
|
|
62
|
-
token_id: SCHEMAVAULTS_AUTH_APP_DEFINITION.app_id,
|
|
63
|
-
audience: SCHEMAVAULTS_AUTH_APP_DEFINITION.app_id,
|
|
64
|
-
});
|
|
65
|
-
if (!auth_jwt)
|
|
66
|
-
throw new Error("Failed to acquire auth access token");
|
|
67
|
-
auth_access_jwt = auth_jwt;
|
|
68
|
-
}
|
|
69
|
-
catch (e) {
|
|
70
|
-
toast({
|
|
71
|
-
variant: "destructive",
|
|
72
|
-
title: "Error loading authentication access token",
|
|
73
|
-
description: e instanceof Error
|
|
74
|
-
? e.message
|
|
75
|
-
: `Failed to prepare network request`,
|
|
76
|
-
});
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
const createAppRequestBody = {
|
|
80
|
-
...values,
|
|
81
|
-
};
|
|
82
|
-
if (typeof owner_organization_id === "string") {
|
|
83
|
-
createAppRequestBody["owner_organization_id"] = owner_organization_id;
|
|
84
|
-
}
|
|
85
|
-
// if we're creating it from this form then it must be non-hardcoded/dynamic...
|
|
86
|
-
createAppRequestBody["hardcoded"] = false;
|
|
87
|
-
createAppRequestBody["created_at"] = Date.now();
|
|
88
|
-
const validatedAppRequestBody = await schemaVaultsAppDefinitionSchema.safeParseAsync(createAppRequestBody);
|
|
89
|
-
if (!validatedAppRequestBody.success) {
|
|
90
|
-
console.error("Failed to prepare application creation request:", validatedAppRequestBody.error);
|
|
91
|
-
toast({
|
|
92
|
-
variant: "destructive",
|
|
93
|
-
title: "Failed to prepare application creation request",
|
|
94
|
-
description: "See your console for the full validation error message!",
|
|
95
|
-
});
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
try {
|
|
99
|
-
const response = await fetch("/api/apps", {
|
|
100
|
-
method: "POST",
|
|
101
|
-
body: JSON.stringify(validatedAppRequestBody.data),
|
|
102
|
-
headers: {
|
|
103
|
-
Authorization: `Bearer ${auth_access_jwt.token}}`,
|
|
104
|
-
},
|
|
105
|
-
});
|
|
106
|
-
if (!response.ok || response.status !== 200) {
|
|
107
|
-
throw new Error(`Frontend app creation request has bad status: ${response.status}`);
|
|
108
|
-
}
|
|
109
|
-
const body = await response.json();
|
|
110
|
-
if (typeof body !== "object") {
|
|
111
|
-
throw new Error("Expected JSON object response from frontend app creation attempt");
|
|
112
|
-
}
|
|
113
|
-
if (!Object.hasOwn(body, "success")) {
|
|
114
|
-
throw new Error("No success field in response");
|
|
115
|
-
}
|
|
116
|
-
if (!(typeof body.success === "boolean" &&
|
|
117
|
-
body.success)) {
|
|
118
|
-
console.error(body);
|
|
119
|
-
throw new Error("Frontend app creation response has success flag set to false");
|
|
120
|
-
}
|
|
121
|
-
if (environment === "development") {
|
|
122
|
-
console.log("Received response: ", body);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
catch (e) {
|
|
126
|
-
toast({
|
|
127
|
-
variant: "destructive",
|
|
128
|
-
title: "Failed to create new frontend application",
|
|
129
|
-
description: e instanceof Error ? e.message : `Failed to send network request`,
|
|
130
|
-
});
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
toast({
|
|
134
|
-
variant: "default",
|
|
135
|
-
title: "Created new frontend client application successfully",
|
|
136
|
-
});
|
|
137
|
-
clearFrontendAppsCache(mutate);
|
|
138
|
-
return;
|
|
139
|
-
});
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
return (_jsxs(Dialog, { children: [_jsx(DialogTrigger, { asChild: true, children: _jsxs(Button, { children: [_jsx(AppWindow, { className: "h-4 w-4 mr-2" }), " Create app"] }) }), _jsx(DialogContent, { className: "sm:max-w-[425px]", children: _jsx(Form, { ...form, children: _jsxs("form", { onSubmit: form.handleSubmit(onSubmit), className: "flex flex-col justify-start gap-4", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { children: "Create a new application" }), _jsx(DialogDescription, { children: "Create a new frontend/client application which can access SchemaVaults APIs." })] }), _jsx(FormField, { control: form.control, name: "app_name", render: ({ field }) => (_jsxs(FormItem, { children: [_jsx(FormLabel, { children: "App Name" }), _jsx(FormControl, { children: _jsx(Input, { placeholder: "My New React App", ...field, disabled: submitting }) }), _jsx(FormDescription, { children: "Give a user-friendly name to the new application." }), _jsx(FormMessage, {})] })) }), _jsx(FormField, { control: form.control, name: "app_description", render: ({ field }) => (_jsxs(FormItem, { children: [_jsx(FormLabel, { children: "Description" }), _jsx(FormControl, { children: _jsx(Textarea, { placeholder: "This app connects to my new API", ...field, disabled: submitting }) }), _jsx(FormDescription, { children: "Describe what this app does." }), _jsx(FormMessage, {})] })) }), _jsx(FormField, { control: form.control, name: "public", render: ({ field }) => (_jsxs(FormItem, { className: "flex flex-row gap-2 items-center flex-wrap", children: [_jsx(FormLabel, { className: "w-full", children: "Public?" }), _jsx(FormControl, { children: _jsx(Checkbox, { checked: field.value, onCheckedChange: field.onChange, disabled: submitting, onBlur: field.onBlur }) }), _jsx(FormDescription, { className: "w-full", children: "Is this app publicly listed to end-users? I.e. can they find it without having authorized it first" }), _jsx(FormMessage, {})] })) }), _jsx(DialogFooter, { children: _jsxs(Button, { type: "submit", disabled: submitting, children: [_jsx(AppWindow, { className: "h-4 w-4 mr-2" }), "Create client application"] }) })] }) }) })] }));
|
|
11
|
+
export function CreateAppDialogTrigger({ onOpenChange, }) {
|
|
12
|
+
return (_jsxs(Button, { id: "open-create-app-dialog-button", onClick: (e) => {
|
|
13
|
+
e.preventDefault();
|
|
14
|
+
onOpenChange(true);
|
|
15
|
+
}, children: [_jsx(AppWindow, { className: "h-4 w-4 mr-2" }), " Create app"] }));
|
|
143
16
|
}
|
|
144
17
|
export default CreateAppDialog;
|
|
145
18
|
//# sourceMappingURL=CreateAppDialog.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CreateAppDialog.js","sourceRoot":"","sources":["../../../src/components/CreateAppDialog/CreateAppDialog.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,
|
|
1
|
+
{"version":3,"file":"CreateAppDialog.js","sourceRoot":"","sources":["../../../src/components/CreateAppDialog/CreateAppDialog.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAG1C,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEzD,OAAO,EAAE,4BAA4B,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAY5C,MAAM,UAAU,eAAe,CAAC,EAC9B,sBAAsB,EACtB,qBAAqB,EACrB,GAAG,KAAK,EACqB;IAC7B,OAAO,CACL,KAAC,MAAM,IAAC,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,YAAY,EAAE,KAAK,CAAC,YAAY,YACxD,KAAC,aAAa,IACZ,EAAE,EAAC,2BAA2B,EAC9B,SAAS,EAAC,kBAAkB,YAE5B,KAAC,aAAa,IACZ,qBAAqB,EACnB,qBAAqB,IAAI,4BAA4B,EAEvD,sBAAsB,EAAE,sBAAsB,EAC9C,SAAS,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,EAC1C,IAAI,EAAE,KAAK,CAAC,IAAI,GAChB,GACY,GACT,CACV,CAAC;AACJ,CAAC;AAMD,MAAM,UAAU,sBAAsB,CAAC,EACrC,YAAY,GACwB;IACpC,OAAO,CACL,MAAC,MAAM,IACL,EAAE,EAAC,+BAA+B,EAClC,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE;YACb,CAAC,CAAC,cAAc,EAAE,CAAC;YACnB,YAAY,CAAC,IAAI,CAAC,CAAC;QACrB,CAAC,aAED,KAAC,SAAS,IAAC,SAAS,EAAC,cAAc,GAAG,mBAC/B,CACV,CAAC;AACJ,CAAC;AAED,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { createContext } from "react";
|
|
3
|
+
export const CreateAppDialogOpenDispatchContext = createContext((val) => {
|
|
4
|
+
void val;
|
|
5
|
+
throw new Error("Not within CreateAppDialogOpenDispatchContext.Provider render tree!");
|
|
6
|
+
});
|
|
7
|
+
export default CreateAppDialogOpenDispatchContext;
|
|
8
|
+
//# sourceMappingURL=CreateAppDialogOpenDispatchContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CreateAppDialogOpenDispatchContext.js","sourceRoot":"","sources":["../../../src/components/CreateAppDialog/CreateAppDialogOpenDispatchContext.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEtC,MAAM,CAAC,MAAM,kCAAkC,GAAG,aAAa,CAE7D,CAAC,GAAY,EAAE,EAAE;IACjB,KAAK,GAAG,CAAC;IACT,MAAM,IAAI,KAAK,CACb,qEAAqE,CACtE,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,kCAAkC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type ReactElement } from "react";
|
|
2
|
+
import { useSWRConfig } from "swr";
|
|
3
|
+
import { type OrganizationID } from "@schemavaults/auth-common";
|
|
4
|
+
export interface CreateAppFormProps {
|
|
5
|
+
owner_organization_id: OrganizationID;
|
|
6
|
+
clearFrontendAppsCache: (mutate: ReturnType<typeof useSWRConfig>["mutate"]) => void;
|
|
7
|
+
onSuccess: () => void;
|
|
8
|
+
uuid: () => string;
|
|
9
|
+
}
|
|
10
|
+
export default function CreateAppForm({ owner_organization_id, clearFrontendAppsCache, onSuccess, uuid, }: CreateAppFormProps): ReactElement;
|