added format command and added trailing commas to reduce conflicts

This commit is contained in:
dswbx
2025-02-26 20:06:03 +01:00
parent 88b5359f1c
commit 7743f71a11
414 changed files with 3622 additions and 3610 deletions

View File

@@ -12,11 +12,11 @@ import { routes, useNavigate } from "ui/lib/routes";
export function AuthIndex() {
const { app } = useBknd();
const {
config: { roles, strategies, entity_name, enabled }
config: { roles, strategies, entity_name, enabled },
} = useBkndAuth();
const users_entity = entity_name;
const $q = useApiQuery((api) => api.data.count(users_entity), {
enabled
enabled,
});
const usersTotal = $q.data?.count ?? 0;
const rolesTotal = Object.keys(roles ?? {}).length ?? 0;
@@ -57,9 +57,9 @@ export function AuthIndex() {
actions={[
{
label: "View all",
href: usersLink
href: usersLink,
},
{ label: "Add new", variant: "default", href: usersLink }
{ label: "Add new", variant: "default", href: usersLink },
]}
/>
<KpiCard
@@ -67,7 +67,7 @@ export function AuthIndex() {
value={!enabled ? 0 : rolesTotal}
actions={[
{ label: "View all", href: rolesLink },
{ label: "Manage", variant: "default", href: rolesLink }
{ label: "Manage", variant: "default", href: rolesLink },
]}
/>
<KpiCard
@@ -75,7 +75,7 @@ export function AuthIndex() {
value={!enabled ? 0 : strategiesTotal}
actions={[
{ label: "View all", href: strategiesLink },
{ label: "Manage", variant: "default", href: strategiesLink }
{ label: "Manage", variant: "default", href: strategiesLink },
]}
/>
</div>
@@ -120,7 +120,7 @@ const Item = ({ title, done = false, to }: { title: string; done?: boolean; to?:
<p
className={clsx(
"font-medium text-primary/80 leading-none",
done ? "line-through" : ""
done ? "line-through" : "",
)}
>
{title}

View File

@@ -54,14 +54,14 @@ function AuthRolesEditInternal({ params }) {
label: "Advanced Settings",
onClick: () =>
navigate(routes.settings.path(["auth", "roles", roleName]), {
absolute: true
})
absolute: true,
}),
},
{
label: "Delete",
onClick: handleDelete,
destructive: true
}
destructive: true,
},
]}
position="bottom-end"
>
@@ -77,7 +77,7 @@ function AuthRolesEditInternal({ params }) {
<Breadcrumbs2
path={[
{ label: "Roles & Permissions", href: routes.auth.roles.list() },
{ label: roleName }
{ label: roleName },
]}
/>
</AppShell.SectionHeader>

View File

@@ -16,8 +16,8 @@ export function AuthRolesList() {
role: name,
permissions: role.permissions,
is_default: role.is_default ?? false,
implicit_allow: role.implicit_allow ?? false
}))
implicit_allow: role.implicit_allow ?? false,
})),
);
function handleClick(row) {
@@ -31,14 +31,14 @@ export function AuthRolesList() {
schema: {
type: "object",
properties: {
name: StringIdentifier
name: StringIdentifier,
},
required: ["name"]
required: ["name"],
},
uiSchema: {
name: {
"ui:title": "Role name"
}
"ui:title": "Role name",
},
},
onSubmit: async (data) => {
if (data.name.length > 0) {
@@ -46,11 +46,11 @@ export function AuthRolesList() {
navigate(routes.auth.roles.edit(data.name));
}
}
}
},
},
{
title: "New Role"
}
title: "New Role",
},
);
}

View File

@@ -11,7 +11,7 @@ import {
type FieldProps,
Form,
FormDebug,
Subscribe
Subscribe,
} from "ui/components/form/json-schema-form";
import { useBrowserTitle } from "ui/hooks/use-browser-title";
import * as AppShell from "ui/layouts/AppShell/AppShell";
@@ -21,17 +21,17 @@ import { combine } from "zustand/middleware";
const useAuthSettingsStore = create(
combine(
{
advanced: [] as string[]
advanced: [] as string[],
},
(set) => ({
toggleAdvanced: (which: string) =>
set((state) => ({
advanced: state.advanced.includes(which)
? state.advanced.filter((w) => w !== which)
: [...state.advanced, which]
}))
})
)
: [...state.advanced, which],
})),
}),
),
);
export function AuthSettings(props) {
@@ -47,7 +47,7 @@ export function AuthSettings(props) {
const formConfig = {
ignoreKeys: ["roles", "strategies"],
options: { keepEmpty: true, debug: isDebug() }
options: { keepEmpty: true, debug: isDebug() },
};
function AuthSettingsInternal() {
@@ -66,7 +66,7 @@ function AuthSettingsInternal() {
selector={(state) => ({
dirty: state.dirty,
errors: state.errors.length > 0,
submitting: state.submitting
submitting: state.submitting,
})}
>
{({ dirty, errors, submitting }) => (

View File

@@ -11,7 +11,7 @@ import {
TbBrandInstagram,
TbBrandOauth,
TbBrandX,
TbSettings
TbSettings,
} from "react-icons/tb";
import { twMerge } from "tailwind-merge";
import { useBknd } from "ui/client/bknd";
@@ -28,7 +28,7 @@ import {
Subscribe,
useDerivedFieldContext,
useFormError,
useFormValue
useFormValue,
} from "ui/components/form/json-schema-form";
import { useBrowserTitle } from "ui/hooks/use-browser-title";
import * as AppShell from "../../layouts/AppShell/AppShell";
@@ -46,7 +46,7 @@ export function AuthStrategiesList(props) {
const formOptions = {
keepEmpty: true,
debug: isDebug()
debug: isDebug(),
};
function AuthStrategiesListInternal() {
@@ -57,8 +57,8 @@ function AuthStrategiesListInternal() {
// @ts-ignore
$auth.schema.properties.strategies.additionalProperties.anyOf.map((s) => [
s.properties.type.const,
s
])
s,
]),
);
async function handleSubmit(data: any) {
@@ -72,7 +72,7 @@ function AuthStrategiesListInternal() {
selector={(state) => ({
dirty: state.dirty,
errors: state.errors.length > 0,
submitting: state.submitting
submitting: state.submitting,
})}
>
{({ dirty, errors, submitting }) => (
@@ -127,8 +127,8 @@ const Strategy = ({ type, name, unavailable }: StrategyProps) => {
// @ts-ignore
$auth.schema.properties.strategies.additionalProperties.anyOf.map((s) => [
s.properties.type.const,
s
])
s,
]),
);
const schema = schemas[type];
const [open, setOpen] = useState(false);
@@ -141,7 +141,7 @@ const Strategy = ({ type, name, unavailable }: StrategyProps) => {
className={twMerge(
"flex flex-col border border-muted rounded bg-background",
unavailable && "opacity-20 pointer-events-none cursor-not-allowed",
errors.length > 0 && "border-red-500"
errors.length > 0 && "border-red-500",
)}
>
<div className="flex flex-row justify-between p-3 gap-3 items-center">
@@ -165,7 +165,7 @@ const Strategy = ({ type, name, unavailable }: StrategyProps) => {
{open && (
<div
className={twMerge(
"flex flex-col border-t border-t-muted px-4 pt-3 pb-4 bg-lightest/50 gap-4"
"flex flex-col border-t border-t-muted px-4 pt-3 pb-4 bg-lightest/50 gap-4",
)}
>
<StrategyForm type={type} />
@@ -216,7 +216,7 @@ const OAUTH_BRANDS = {
x: TbBrandX,
instagram: TbBrandInstagram,
apple: TbBrandAppleFilled,
discord: TbBrandDiscordFilled
discord: TbBrandDiscordFilled,
};
const StrategyForm = ({ type }: Pick<StrategyProps, "type">) => {

View File

@@ -31,16 +31,16 @@ export const AuthRoleForm = forwardRef<
watch,
control,
reset,
getValues
getValues,
} = useForm({
resolver: typeboxResolver(schema),
defaultValues: role
defaultValues: role,
});
useImperativeHandle(ref, () => ({
reset,
getData: () => getValues(),
isValid: () => isValid
isValid: () => isValid,
}));
return (
@@ -82,14 +82,14 @@ export const AuthRoleForm = forwardRef<
const Permissions = ({
control,
permissions
permissions,
}: Omit<UseControllerProps, "name"> & { permissions: string[] }) => {
const {
field: { value, onChange: fieldOnChange, ...field },
fieldState
fieldState,
} = useController<Static<typeof schema>, "permissions">({
name: "permissions",
control
control,
});
const data = value ?? [];
@@ -108,7 +108,7 @@ const Permissions = ({
acc[group].push(permission);
return acc;
},
{} as Record<string, string[]>
{} as Record<string, string[]>,
);
console.log("grouped", grouped);

View File

@@ -6,7 +6,7 @@ import {
IconExternalLink,
IconPhoto,
IconPlus,
IconSettings
IconSettings,
} from "@tabler/icons-react";
import type { Entity, TEntityType } from "data";
import { TbDatabasePlus } from "react-icons/tb";
@@ -26,7 +26,7 @@ export function DataRoot({ children }) {
const entityList: Record<TEntityType, Entity[]> = {
regular: [],
generated: [],
system: []
system: [],
} as const;
const [navigate] = useNavigate();
const context = window.location.href.match(/\/schema/) ? "schema" : "data";
@@ -65,7 +65,7 @@ export function DataRoot({ children }) {
<SegmentedControl
data={[
{ value: "data", label: "Data" },
{ value: "schema", label: "Schema" }
{ value: "schema", label: "Schema" },
]}
value={context}
onChange={handleSegmentChange}
@@ -103,7 +103,7 @@ const EntityLinkList = ({
entities,
title,
context,
suggestCreate = false
suggestCreate = false,
}: { entities: Entity[]; title?: string; context: "data" | "schema"; suggestCreate?: boolean }) => {
const { $data } = useBkndData();
if (entities.length === 0) {
@@ -113,7 +113,7 @@ const EntityLinkList = ({
description="Create your first entity to get started."
secondary={{
children: "Create entity",
onClick: () => $data.modals.createEntity()
onClick: () => $data.modals.createEntity(),
}}
/>
) : null;
@@ -123,7 +123,7 @@ const EntityLinkList = ({
<nav
className={twMerge(
"flex flex-col flex-1 gap-1 px-3",
title && "border-t border-primary/10 pt-2"
title && "border-t border-primary/10 pt-2",
)}
>
{title && <div className="text-sm text-primary/50 ml-3.5 mb-1">{title}</div>}
@@ -148,7 +148,7 @@ const EntityLinkList = ({
const EntityContextMenu = ({
entity,
children,
enabled = true
enabled = true,
}: { entity: Entity; children: DropdownClickableChild; enabled?: boolean }) => {
if (!enabled) return children;
const [navigate] = useNavigate();
@@ -162,41 +162,41 @@ const EntityContextMenu = ({
<Dropdown
className="flex flex-col w-full"
dropdownWrapperProps={{
className: "min-w-fit"
className: "min-w-fit",
}}
title={entity.label + " Actions"}
items={[
href && {
icon: IconExternalLink,
label: "Open in tab",
onClick: () => navigate(href, { target: "_blank" })
onClick: () => navigate(href, { target: "_blank" }),
},
separator,
!$data.system(entity.name).any && {
icon: IconPlus,
label: "Create new",
onClick: () => navigate(routes.data.entity.create(entity.name))
onClick: () => navigate(routes.data.entity.create(entity.name)),
},
{
icon: IconDatabase,
label: "List entries",
onClick: () => navigate(routes.data.entity.list(entity.name))
onClick: () => navigate(routes.data.entity.list(entity.name)),
},
separator,
{
icon: IconAlignJustified,
label: "Manage fields",
onClick: () => navigate(routes.data.schema.entity(entity.name))
onClick: () => navigate(routes.data.schema.entity(entity.name)),
},
{
icon: IconCirclesRelation,
label: "Add relation",
onClick: () => $data.modals.createRelation(entity.name)
onClick: () => $data.modals.createRelation(entity.name),
},
!$data.system(entity.name).media && {
icon: IconPhoto,
label: "Add media",
onClick: () => $data.modals.createMedia(entity.name)
onClick: () => $data.modals.createMedia(entity.name),
},
separator,
{
@@ -204,9 +204,9 @@ const EntityContextMenu = ({
label: "Advanced",
onClick: () =>
navigate(routes.settings.path(["data", "entities", entity.name]), {
absolute: true
})
}
absolute: true,
}),
},
]}
openEvent="onContextMenu"
position="bottom-start"
@@ -232,11 +232,11 @@ export function DataEmpty() {
description="Please select an entity from the left sidebar or create a new one to continue."
secondary={{
children: "Go to schema",
onClick: handleButtonClick
onClick: handleButtonClick,
}}
primary={{
children: "Create entity",
onClick: $data.modals.createEntity
onClick: $data.modals.createEntity,
}}
/>
);

View File

@@ -38,13 +38,13 @@ export function DataEntityUpdate({ params }) {
entity.name,
entityId,
{
with: local_relation_refs
with: local_relation_refs,
},
{
keepPreviousData: false,
revalidateOnFocus: false,
shouldRetryOnError: false
}
shouldRetryOnError: false,
},
);
function goBack() {
@@ -85,7 +85,7 @@ export function DataEntityUpdate({ params }) {
action: "update",
entity,
initialData: $q.data?.toJSON(),
onSubmitted
onSubmitted,
});
if (!data && !$q.isLoading) {
@@ -117,24 +117,24 @@ export function DataEntityUpdate({ params }) {
entity: entity.toJSON(),
schema: entity.toSchema({ clean: true }),
form: Form.state.values,
state: Form.state
}
state: Form.state,
},
});
}
},
},
{
label: "Settings",
onClick: () =>
navigate(routes.settings.path(["data", "entities", entity.name]), {
absolute: true
})
absolute: true,
}),
},
{
label: "Delete",
onClick: handleDelete,
destructive: true,
disabled: fieldsDisabled
}
disabled: fieldsDisabled,
},
]}
>
<IconButton Icon={TbDots} />
@@ -160,7 +160,7 @@ export function DataEntityUpdate({ params }) {
<Breadcrumbs2
path={[
{ label: entity.label, href: routes.data.entity.list(entity.name) },
{ label: `Edit #${entityId}` }
{ label: `Edit #${entityId}` },
]}
/>
</AppShell.SectionHeader>
@@ -191,7 +191,7 @@ export function DataEntityUpdate({ params }) {
function EntityDetailRelations({
id,
entity,
relations
relations,
}: {
id: number;
entity: Entity;
@@ -199,7 +199,7 @@ function EntityDetailRelations({
}) {
const [selected, setSelected] = useState<EntityRelation>(
// @ts-ignore
relations.length > 0 ? relations[0] : undefined
relations.length > 0 ? relations[0] : undefined,
);
function handleClick(relation: EntityRelation) {
@@ -225,7 +225,7 @@ function EntityDetailRelations({
label: ucFirst(other.reference),
onClick: () => handleClick(relation),
active: selected?.other(entity).reference === other.reference,
badge: relation.type()
badge: relation.type(),
};
})}
/>
@@ -239,7 +239,7 @@ function EntityDetailRelations({
function EntityDetailInner({
id,
entity,
relation
relation,
}: {
id: number;
entity: Entity;
@@ -251,11 +251,11 @@ function EntityDetailInner({
const search = {
select: other.entity.getSelect(undefined, "table"),
limit: 10,
offset: 0
offset: 0,
};
// @todo: add custom key for invalidation
const $q = useApiQuery((api) =>
api.data.readManyByReference(entity.name, id, other.reference, search)
api.data.readManyByReference(entity.name, id, other.reference, search),
);
function handleClickRow(row: Record<string, any>) {
@@ -268,7 +268,7 @@ function EntityDetailInner({
const ref = relation.getReferenceQuery(other.entity, id, other.reference);
handleClickNew = () => {
navigate(routes.data.entity.create(other.entity.name), {
query: ref.where
query: ref.where,
});
//navigate(routes.data.entity.create(other.entity.name) + `?${query}`);
};

View File

@@ -52,7 +52,7 @@ export function DataEntityCreate({ params }) {
action: "create",
entity: entity,
initialData: search.value,
onSubmitted
onSubmitted,
});
const fieldsDisabled = $q.isLoading || $q.isValidating || Form.state.isSubmitting;
@@ -83,7 +83,7 @@ export function DataEntityCreate({ params }) {
<Breadcrumbs2
path={[
{ label: entity.label, href: routes.data.entity.list(entity.name) },
{ label: "Create" }
{ label: "Create" },
]}
/>
</AppShell.SectionHeader>

View File

@@ -22,10 +22,10 @@ const searchSchema = Type.Composite(
Type.Pick(querySchema, ["select", "where", "sort"]),
Type.Object({
page: Type.Optional(Type.Number({ default: 1 })),
perPage: Type.Optional(Type.Number({ default: 10 }))
})
perPage: Type.Optional(Type.Number({ default: 10 })),
}),
],
{ additionalProperties: false }
{ additionalProperties: false },
);
const PER_PAGE_OPTIONS = [5, 10, 25];
@@ -41,7 +41,7 @@ export function DataEntityList({ params }) {
const [navigate] = useNavigate();
const search = useSearch(searchSchema, {
select: entity.getSelect(undefined, "table"),
sort: entity.getDefaultSort()
sort: entity.getDefaultSort(),
});
const $q = useApiQuery(
@@ -50,13 +50,13 @@ export function DataEntityList({ params }) {
select: search.value.select,
limit: search.value.perPage,
offset: (search.value.page - 1) * search.value.perPage,
sort: `${search.value.sort.dir === "asc" ? "" : "-"}${search.value.sort.by}`
sort: `${search.value.sort.dir === "asc" ? "" : "-"}${search.value.sort.by}`,
}),
{
enabled: !!entity,
revalidateOnFocus: true,
keepPreviousData: true
}
keepPreviousData: true,
},
);
const data = $q.data?.data;
const meta = $q.data?.body.meta;
@@ -94,19 +94,19 @@ export function DataEntityList({ params }) {
items={[
{
label: "Settings",
onClick: () => navigate(routes.data.schema.entity(entity.name))
onClick: () => navigate(routes.data.schema.entity(entity.name)),
},
{
label: "Data Schema",
onClick: () => navigate(routes.data.schema.root())
onClick: () => navigate(routes.data.schema.root()),
},
{
label: "Advanced Settings",
onClick: () =>
navigate(routes.settings.path(["data", "entities", entity.name]), {
absolute: true
})
}
absolute: true,
}),
},
]}
position="bottom-end"
>
@@ -158,7 +158,7 @@ function EntityCreateButton({ entity }: { entity: Entity }) {
if (entity.type === "system") {
const system = {
users: b.app.config.auth.entity_name,
media: b.app.config.media.entity_name
media: b.app.config.media.entity_name,
};
if (system.users === entity.name) {
return (

View File

@@ -2,7 +2,7 @@ import {
IconAlignJustified,
IconBolt,
IconCirclesRelation,
IconSettings
IconSettings,
} from "@tabler/icons-react";
import { isDebug } from "core";
import type { Entity } from "data";
@@ -14,7 +14,7 @@ import {
TbDots,
TbPhoto,
TbPlus,
TbSitemap
TbSitemap,
} from "react-icons/tb";
import { useBkndData } from "ui/client/schema/data/use-bknd-data";
import { Button } from "ui/components/buttons/Button";
@@ -56,16 +56,16 @@ export function DataSchemaEntity({ params }) {
label: "Data",
onClick: () =>
navigate(routes.data.root() + routes.data.entity.list(entity.name), {
absolute: true
})
absolute: true,
}),
},
{
label: "Advanced Settings",
onClick: () =>
navigate(routes.settings.path(["data", "entities", entity.name]), {
absolute: true
})
}
absolute: true,
}),
},
]}
position="bottom-end"
>
@@ -76,19 +76,19 @@ export function DataSchemaEntity({ params }) {
{
icon: TbCirclesRelation,
label: "Add relation",
onClick: () => $data.modals.createRelation(entity.name)
onClick: () => $data.modals.createRelation(entity.name),
},
{
icon: TbPhoto,
label: "Add media",
onClick: () => $data.modals.createMedia(entity.name)
onClick: () => $data.modals.createMedia(entity.name),
},
() => <div className="h-px my-1 w-full bg-primary/5" />,
{
icon: TbDatabasePlus,
label: "Create Entity",
onClick: () => $data.modals.createEntity()
}
onClick: () => $data.modals.createEntity(),
},
]}
position="bottom-end"
>
@@ -124,7 +124,7 @@ export function DataSchemaEntity({ params }) {
primary={{
children: "Advanced Settings",
onClick: () =>
navigate(routes.settings.path(["data", "relations"]), { absolute: true })
navigate(routes.settings.path(["data", "relations"]), { absolute: true }),
}}
/>
</AppShell.SectionHeaderAccordionItem>
@@ -141,8 +141,8 @@ export function DataSchemaEntity({ params }) {
children: "Advanced Settings",
onClick: () =>
navigate(routes.settings.path(["data", "indices"]), {
absolute: true
})
absolute: true,
}),
}}
/>
</AppShell.SectionHeaderAccordionItem>
@@ -154,7 +154,7 @@ export function DataSchemaEntity({ params }) {
const Fields = ({
entity,
open,
toggle
toggle,
}: { entity: Entity; open: boolean; toggle: () => void }) => {
const [submitting, setSubmitting] = useState(false);
const [updates, setUpdates] = useState(0);
@@ -209,7 +209,7 @@ const Fields = ({
$data.modals.createMedia(entity.name);
break;
}
}
},
}))}
/>
@@ -241,7 +241,7 @@ const Fields = ({
const BasicSettings = ({
entity,
open,
toggle
toggle,
}: { entity: Entity; open: boolean; toggle: () => void }) => {
const d = useBkndData();
const config = d.entities?.[entity.name]?.config;
@@ -249,7 +249,7 @@ const BasicSettings = ({
const schema = cloneDeep(
// @ts-ignore
d.schema.properties.entities.additionalProperties?.properties?.config
d.schema.properties.entities.additionalProperties?.properties?.config,
);
const [_schema, _config] = extractSchema(schema as any, config, ["fields"]);

View File

@@ -5,8 +5,8 @@ import * as AppShell from "ui/layouts/AppShell/AppShell";
const DataSchemaCanvas = lazy(() =>
import("ui/modules/data/components/canvas/DataSchemaCanvas").then((m) => ({
default: m.DataSchemaCanvas
}))
default: m.DataSchemaCanvas,
})),
);
export function DataSchemaIndex() {

View File

@@ -6,12 +6,12 @@ import {
type Static,
StringIdentifier,
objectCleanEmpty,
ucFirstAllSnakeToPascalWithSpaces
ucFirstAllSnakeToPascalWithSpaces,
} from "core/utils";
import { Entity } from "data";
import {
type TAppDataEntityFields,
fieldsSchemaObject as originalFieldsSchemaObject
fieldsSchemaObject as originalFieldsSchemaObject,
} from "data/data-schema";
import { omit } from "lodash-es";
import { forwardRef, memo, useEffect, useImperativeHandle } from "react";
@@ -34,12 +34,12 @@ const fieldsSchema = Type.Union(Object.values(fieldsSchemaObject));
const fieldSchema = Type.Object({
name: StringIdentifier,
new: Type.Optional(Type.Boolean({ const: true })),
field: fieldsSchema
field: fieldsSchema,
});
type TFieldSchema = Static<typeof fieldSchema>;
const schema = Type.Object({
fields: Type.Array(fieldSchema)
fields: Type.Array(fieldSchema),
});
type TFieldsFormSchema = Static<typeof schema>;
@@ -70,7 +70,7 @@ export const EntityFieldsForm = forwardRef<EntityFieldsFormRef, EntityFieldsForm
function EntityFieldsForm({ fields: _fields, sortable, additionalFieldTypes, ...props }, ref) {
const entityFields = Object.entries(_fields).map(([name, field]) => ({
name,
field
field,
}));
const {
@@ -81,22 +81,22 @@ export const EntityFieldsForm = forwardRef<EntityFieldsFormRef, EntityFieldsForm
register,
setValue,
setError,
reset
reset,
} = useForm({
mode: "all",
resolver: typeboxResolver(schema),
defaultValues: {
fields: entityFields
} as TFieldsFormSchema
fields: entityFields,
} as TFieldsFormSchema,
});
const { fields, append, remove, move } = useFieldArray({
control,
name: "fields"
name: "fields",
});
function toCleanValues(formData: TFieldsFormSchema): TAppDataEntityFields {
return Object.fromEntries(
formData.fields.map((field) => [field.name, objectCleanEmpty(field.field)])
formData.fields.map((field) => [field.name, objectCleanEmpty(field.field)]),
);
}
@@ -116,7 +116,7 @@ export const EntityFieldsForm = forwardRef<EntityFieldsFormRef, EntityFieldsForm
getData: () => {
return toCleanValues(getValues());
},
isValid: () => isValid
isValid: () => isValid,
}));
function handleAppend(_type: keyof typeof fieldsSchemaObject) {
@@ -125,8 +125,8 @@ export const EntityFieldsForm = forwardRef<EntityFieldsFormRef, EntityFieldsForm
new: true,
field: {
type: _type,
config: {}
}
config: {},
},
};
append(newField);
}
@@ -137,7 +137,7 @@ export const EntityFieldsForm = forwardRef<EntityFieldsFormRef, EntityFieldsForm
setValue,
getValues,
control,
setError
setError,
};
return (
<>
@@ -197,20 +197,20 @@ export const EntityFieldsForm = forwardRef<EntityFieldsFormRef, EntityFieldsForm
</div>
</>
);
}
},
);
const SelectType = ({
onSelect,
additionalFieldTypes = [],
onSelected
onSelected,
}: {
onSelect: (type: string) => void;
additionalFieldTypes?: (TFieldSpec & { onClick?: () => void })[];
onSelected?: () => void;
}) => {
const types: (TFieldSpec & { onClick?: () => void })[] = fieldSpecs.filter(
(s) => s.addable !== false
(s) => s.addable !== false,
);
if (additionalFieldTypes) {
@@ -266,7 +266,7 @@ function EntityField({
form: { watch, register, setValue, getValues, control, setError },
remove,
errors,
dnd
dnd,
}: {
field: FieldArrayWithId<TFieldsFormSchema, "fields", "id">;
index: number;
@@ -307,7 +307,7 @@ function EntityField({
className={twMerge(
"flex flex-col border border-muted rounded bg-background mb-2",
opened && "mb-6",
hasErrors && "border-red-500 "
hasErrors && "border-red-500 ",
)}
{...dndProps}
>
@@ -331,7 +331,7 @@ function EntityField({
classNames={{
root: "w-full h-full",
wrapper: "font-mono h-full",
input: "pt-px !h-full"
input: "pt-px !h-full",
}}
{...register(`fields.${index}.name`)}
disabled={!field.new}
@@ -416,7 +416,7 @@ function EntityField({
onChange={(value) => {
setValue(`${prefix}.config`, {
...getValues([`fields.${index}.config`])[0],
...value
...value,
});
}}
/>

View File

@@ -7,7 +7,7 @@ import {
StringEnum,
StringIdentifier,
Type,
registerCustomTypeboxKinds
registerCustomTypeboxKinds,
} from "core/utils";
import { TRIGGERS } from "flows/flows-schema";
import { forwardRef, useState } from "react";
@@ -19,7 +19,7 @@ import {
type Modal2Ref,
ModalBody,
ModalFooter,
ModalTitle
ModalTitle,
} from "../../../components/modal/Modal2";
import { Step, Steps, useStepContext } from "../../../components/steps/Steps";
@@ -31,7 +31,7 @@ const triggerNames = Object.keys(TRIGGERS) as unknown as (keyof typeof TRIGGERS)
const schema = Type.Object({
name: StringIdentifier,
trigger: StringEnum(triggerNames),
mode: StringEnum(["async", "sync"])
mode: StringEnum(["async", "sync"]),
});
export const FlowCreateModal = forwardRef<Modal2Ref>(function FlowCreateModal(props, ref) {
@@ -63,15 +63,15 @@ export function StepCreate() {
watch,
control,
register,
formState: { isValid, errors }
formState: { isValid, errors },
} = useForm({
resolver: typeboxResolver(schema),
defaultValues: {
name: "",
trigger: "manual",
mode: "async"
mode: "async",
},
mode: "onSubmit"
mode: "onSubmit",
});
async function onSubmit(data: Static<typeof schema>) {
@@ -80,9 +80,9 @@ export function StepCreate() {
trigger: {
type: data.trigger,
config: {
mode: data.mode
}
}
mode: data.mode,
},
},
});
}
console.log("errors", errors);
@@ -106,7 +106,7 @@ export function StepCreate() {
data={[
{ label: "Manual", value: "manual" },
{ label: "HTTP", value: "http" },
{ label: "Event", value: "event" }
{ label: "Event", value: "event" },
]}
control={control}
/>
@@ -115,7 +115,7 @@ export function StepCreate() {
name="mode"
data={[
{ label: "Async", value: "async" },
{ label: "Sync", value: "sync" }
{ label: "Sync", value: "sync" },
]}
control={control}
/>
@@ -125,7 +125,7 @@ export function StepCreate() {
<ModalFooter
next={{
type: "submit",
disabled: !isValid
disabled: !isValid,
}}
nextLabel="Create"
prev={{ onClick: stepBack }}

View File

@@ -16,7 +16,7 @@ import {
flowToNodes,
useFlowCanvas,
useFlowCanvasState,
useFlowSelector
useFlowSelector,
} from "ui/modules/flows/hooks/use-flow";
import { JsonViewer } from "../../components/code/JsonViewer";
import { routes, useGoBack, useNavigate } from "../../lib/routes";
@@ -59,7 +59,7 @@ function FlowsEditInner() {
const viewport = {
zoom: 1,
x: rect?.width ? rect.width * 0.1 : 0,
y: rect?.height ? rect.height / 2 - triggerHeight / 2 - offset : 0
y: rect?.height ? rect.height / 2 - triggerHeight / 2 - offset : 0,
};
return (
@@ -79,18 +79,18 @@ function FlowsEditInner() {
onDropNewNode={(node) => ({
...node,
type: "select",
data: { label: "" }
data: { label: "" },
})}
onDropNewEdge={(edge) => ({
...edge,
style: {
strokeWidth: 2
strokeWidth: 2,
},
markerEnd: {
type: MarkerType.ArrowClosed,
width: 10,
height: 10
}
height: 10,
},
})}
>
<FlowPanels />
@@ -202,7 +202,7 @@ const Debugger = () => {
title="Context"
json={{
name: $flow.name,
...$flow.data
...$flow.data,
}}
expand={expand}
/>
@@ -211,7 +211,7 @@ const Debugger = () => {
title="State"
json={{
name: state.name,
...state.flow
...state.flow,
}}
expand={expand}
/>
@@ -225,9 +225,9 @@ const Debugger = () => {
(n) =>
_setState((prev) => ({
...prev,
store: { ...prev.store, expand: n }
store: { ...prev.store, expand: n },
})),
250
250,
)}
/>
</Tabs.Panel>

View File

@@ -19,7 +19,7 @@ export function FlowsList() {
trigger: flow.trigger.type,
mode: flow.trigger.config.mode,
tasks: Object.keys(flow.tasks).length,
start_task: flow.startTask?.name
start_task: flow.startTask?.name,
}));
function handleClick(row) {

View File

@@ -57,7 +57,7 @@ export function FlowsEmpty() {
to continue."
primary={{
children: "Create Flow",
onClick: () => navigate(app.getSettingsPath(["flows"]))
onClick: () => navigate(app.getSettingsPath(["flows"])),
}}
/>
</main>

View File

@@ -7,7 +7,7 @@ import {
TbChevronUp,
TbDots,
TbPlayerPlayFilled,
TbSettings
TbSettings,
} from "react-icons/tb";
import { twMerge } from "tailwind-merge";
import FlowCanvas from "ui/modules/flows/components/FlowCanvas";
@@ -48,7 +48,7 @@ export function FlowEdit({ params }) {
await new Promise((resolve) => setTimeout(resolve, 100));
}
},
"sync"
"sync",
);
execution.subscribe(async (event) => {
@@ -67,7 +67,7 @@ export function FlowEdit({ params }) {
onChange: ({ nodes, edges }) => {
setSelectedNodes(nodes);
setSelectedEdges(edges);
}
},
});
return (
@@ -94,8 +94,8 @@ export function FlowEdit({ params }) {
items={[
{
label: "Settings",
onClick: () => navigate(`${prefix}/flows/flows/${flow.name}`)
}
onClick: () => navigate(`${prefix}/flows/flows/${flow.name}`),
},
]}
position="bottom-end"
>
@@ -145,7 +145,7 @@ function Sidebar({ nodes, edges, flow }: { flow: Flow; nodes: Node[]; edges: Edg
<div
className={twMerge(
"flex flex-row pl-5 pr-3 py-3 border-muted border-b cursor-pointer justify-between items-center font-bold",
opened && "bg-primary/5"
opened && "bg-primary/5",
)}
onClick={onClick}
>

View File

@@ -19,7 +19,7 @@ export function MediaIndex() {
description="Please enable media in the settings to continue."
primary={{
children: "Manage Settings",
onClick: () => navigate("/settings")
onClick: () => navigate("/settings"),
}}
/>
);

View File

@@ -16,7 +16,7 @@ import {
FormDebug,
ObjectField,
Subscribe,
useFormError
useFormError,
} from "ui/components/form/json-schema-form";
import { useBrowserTitle } from "ui/hooks/use-browser-title";
import * as AppShell from "ui/layouts/AppShell/AppShell";
@@ -34,7 +34,7 @@ export function MediaSettings(props) {
const formConfig = {
ignoreKeys: ["entity_name", "basepath"],
options: { debug: isDebug(), keepEmpty: true }
options: { debug: isDebug(), keepEmpty: true },
};
function MediaSettingsInternal() {
@@ -57,7 +57,7 @@ function MediaSettingsInternal() {
selector={(state) => ({
dirty: state.dirty,
errors: state.errors.length > 0,
submitting: state.submitting
submitting: state.submitting,
})}
>
{({ dirty, errors, submitting }) => (
@@ -116,7 +116,7 @@ const Icons = {
s3: IconBrandAws,
cloudinary: IconCloud,
local: IconServer,
r2: IconBrandCloudflare
r2: IconBrandCloudflare,
};
const AdapterIcon = ({ type }: { type: string }) => {
@@ -142,7 +142,7 @@ function Adapters() {
variant={ctx.selected === i ? "primary" : "outline"}
className={twMerge(
"flex flex-row items-center justify-center gap-3 border",
ctx.selected === i && "border-primary"
ctx.selected === i && "border-primary",
)}
>
<div>

View File

@@ -21,7 +21,7 @@ import { SettingSchemaModal, type SettingsSchemaModalRef } from "./SettingSchema
export type SettingProps<
Schema extends TObject = TObject,
Props = Schema extends TObject<infer TProperties> ? TProperties : any
Props = Schema extends TObject<infer TProperties> ? TProperties : any,
> = {
schema: Schema;
config: any;
@@ -51,7 +51,7 @@ export function Setting<Schema extends TObject = any>({
prefix = "/",
options,
path = [],
properties
properties,
}: SettingProps<Schema>) {
const [submitting, setSubmitting] = useState(false);
const { actions } = useBknd();
@@ -67,7 +67,7 @@ export function Setting<Schema extends TObject = any>({
e.preventDefault();
onSave();
return false;
}
},
],
[
"e",
@@ -75,7 +75,7 @@ export function Setting<Schema extends TObject = any>({
if (!editing) {
onToggleEdit();
}
}
},
],
[
"Escape",
@@ -83,8 +83,8 @@ export function Setting<Schema extends TObject = any>({
if (editing) {
onToggleEdit();
}
}
]
},
],
]);
const exclude = useMemo(
@@ -94,7 +94,7 @@ export function Setting<Schema extends TObject = any>({
.filter(([, value]) => value.hide || value.extract)
.map(([key]) => key)
: [],
[properties]
[properties],
);
const goBack = useEvent((replace?: boolean) => {
@@ -178,7 +178,7 @@ export function Setting<Schema extends TObject = any>({
description={`Configuration at path ${path.join(".")} doesn't exist.`}
primary={{
children: "Go back",
onClick: () => goBack()
onClick: () => goBack(),
}}
/>
);
@@ -197,19 +197,19 @@ export function Setting<Schema extends TObject = any>({
label: "Inspect local schema",
onClick: () => {
schemaLocalModalRef.current?.open();
}
},
},
{
label: "Inspect schema",
onClick: () => {
schemaModalRef.current?.open();
}
},
},
deleteAllowed && {
label: "Delete",
destructive: true,
onClick: handleDelete
}
onClick: handleDelete,
},
]}
position="bottom-end"
>
@@ -255,7 +255,7 @@ export function Setting<Schema extends TObject = any>({
label: ucFirst(sub),
href: `${prefix}/${sub}`.replace(/\/+/g, "/"),
active: selectedSubKey === sub,
badge: Object.keys(extracted[sub]?.config ?? {}).length
badge: Object.keys(extracted[sub]?.config ?? {}).length,
}))}
/>
<div className="flex flex-grow flex-col gap-3 p-3">
@@ -271,7 +271,7 @@ export function Setting<Schema extends TObject = any>({
if (!value || typeof value !== "object") {
return {
key,
value
value,
};
}
@@ -281,7 +281,7 @@ export function Setting<Schema extends TObject = any>({
return {
key,
[fistValueKey]: firstValueKeyValue,
value: _value
value: _value,
};
});
const newSetting = properties?.[key]?.new;
@@ -331,12 +331,12 @@ export function Setting<Schema extends TObject = any>({
tabs={[
{
title: "Schema",
json: reducedSchema
json: reducedSchema,
},
{
title: "Config",
json: reducedConfig
}
json: reducedConfig,
},
]}
/>
<SettingSchemaModal
@@ -345,12 +345,12 @@ export function Setting<Schema extends TObject = any>({
tabs={[
{
title: "Schema",
json: schema
json: schema,
},
{
title: "Config",
json: config
}
json: config,
},
]}
/>
</>

View File

@@ -26,7 +26,7 @@ export const SettingNewModal = ({
anyOfValues,
path,
prefixPath,
generateKey
generateKey,
}: SettingsNewModalProps) => {
const [location, navigate] = useLocation();
const [formSchema, setFormSchema] = useState(schema);
@@ -44,8 +44,8 @@ export const SettingNewModal = ({
if (generateKey && typeof generateKey === "function") {
handleKeyNameChange({
target: {
value: generateKey(data)
}
value: generateKey(data),
},
});
}
console.log("form change", data);
@@ -69,7 +69,7 @@ export const SettingNewModal = ({
if (await actions.add(module as any, addPath, data)) {
setTimeout(() => {
navigate(prefixPath + newKey, {
replace: true
replace: true,
});
}, 500);
} else {
@@ -92,7 +92,7 @@ export const SettingNewModal = ({
onClick: () => {
setFormSchema(item);
open();
}
},
};
})
: [];

View File

@@ -26,7 +26,7 @@ export const SettingSchemaModal = forwardRef<SettingsSchemaModalRef, SettingSche
useImperativeHandle(ref, () => ({
open,
close,
isOpen: opened
isOpen: opened,
}));
if (!tab) return null;
@@ -69,5 +69,5 @@ export const SettingSchemaModal = forwardRef<SettingsSchemaModalRef, SettingSche
</div>
</Modal>
);
}
},
);

View File

@@ -20,7 +20,7 @@ function SettingsSidebar() {
const modules = Object.keys(schema).map((key) => {
return {
title: schema[key].title ?? ucFirst(key),
key
key,
};
});
@@ -86,25 +86,25 @@ const uiSchema = {
server: {
cors: {
allow_methods: {
"ui:widget": "checkboxes"
"ui:widget": "checkboxes",
},
allow_headers: {
"ui:options": {
orderable: false
}
}
}
orderable: false,
},
},
},
},
media: {
adapter: {
"ui:options": {
label: false
}
label: false,
},
/*type: {
"ui:widget": "hidden"
}*/
}
}
},
},
};
const SettingRoutesRoutes = () => {
@@ -112,7 +112,7 @@ const SettingRoutesRoutes = () => {
console.log("flows", {
schema: schema.flows,
config: config.flows
config: config.flows,
});
return (

View File

@@ -8,37 +8,37 @@ const uiSchema = {
jwt: {
basepath: {
"ui:options": {
label: false
}
label: false,
},
},
fields: {
"ui:options": {
orderable: false
}
}
orderable: false,
},
},
},
strategies: {
additionalProperties: {
"ui:widget": "select",
type: {
"ui:widget": "hidden"
}
"ui:widget": "hidden",
},
},
type: {
"ui:widget": "hidden"
}
"ui:widget": "hidden",
},
},
roles: {
"ui:options": {
orderable: false
orderable: false,
},
permissions: {
items: {
"ui:widget": "checkboxes"
"ui:widget": "checkboxes",
},
"ui:widget": "checkboxes"
}
}
"ui:widget": "checkboxes",
},
},
};
export const AuthSettings = ({ schema: _unsafe_copy, config }) => {
@@ -122,7 +122,7 @@ export const AuthSettings = ({ schema: _unsafe_copy, config }) => {
}
return;
},
reloadOnSave: true
reloadOnSave: true,
}}
properties={{
strategies: {
@@ -131,8 +131,8 @@ export const AuthSettings = ({ schema: _unsafe_copy, config }) => {
return Object.values(
transformObject(strategies, (s, name) => ({
key: name,
type: s.type
}))
type: s.type,
})),
);
},
new: {
@@ -142,16 +142,16 @@ export const AuthSettings = ({ schema: _unsafe_copy, config }) => {
return data.type === "password"
? "password"
: data.config.name?.toLowerCase() || "";
}
}
},
},
},
roles: {
extract: true,
new: {
schema: roleSchema,
uiSchema: uiSchema.roles
}
}
uiSchema: uiSchema.roles,
},
},
}}
prefix={`${prefix}/auth`}
path={["auth"]}

View File

@@ -9,33 +9,33 @@ export const dataFieldsUiSchema = {
config: {
fillable: {
"ui:options": {
wrap: true
wrap: true,
},
anyOf: [
{},
{
"ui:widget": "checkboxes"
}
]
"ui:widget": "checkboxes",
},
],
},
hidden: {
"ui:options": {
wrap: true
wrap: true,
},
anyOf: [
{},
{
"ui:widget": "checkboxes"
}
]
"ui:widget": "checkboxes",
},
],
},
schema: {
"ui:field": "JsonField"
"ui:field": "JsonField",
},
ui_schema: {
"ui:field": "JsonField"
}
}
"ui:field": "JsonField",
},
},
};
const fieldsAnyOfValues = fieldSpecs
@@ -43,29 +43,29 @@ const fieldsAnyOfValues = fieldSpecs
.reduce((acc, s) => {
acc[s.type] = {
label: s.label,
icon: s.icon
icon: s.icon,
};
return acc;
}, {});
const relationAnyOfValues = {
"1:1": {
label: "One-to-One"
label: "One-to-One",
},
"n:1": {
label: "Many-to-One"
label: "Many-to-One",
},
"m:n": {
label: "Many-to-Many"
label: "Many-to-Many",
},
poly: {
label: "Polymorphic"
}
label: "Polymorphic",
},
};
export const DataSettings = ({
schema,
config
config,
}: { schema: ModuleSchemas["data"]; config: ModuleConfigs["data"] }) => {
const { app } = useBknd();
const basepath = app.getAdminConfig().basepath;
@@ -110,7 +110,7 @@ export const DataSettings = ({
return "Modifying the primary field may result in strange behaviors.";
}
return;
}
},
}}
uiSchema={dataFieldsUiSchema}
/>
@@ -128,8 +128,8 @@ export const DataSettings = ({
const fieldsSchema = {
anyOf: editSchema.properties.fields.additionalProperties.anyOf.filter(
(s) => s.properties.type.const !== "primary"
)
(s) => s.properties.type.const !== "primary",
),
} as any;
return (
@@ -142,7 +142,7 @@ export const DataSettings = ({
return "Modifying the system entities may result in strange behaviors.";
}
return;
}
},
}}
properties={{
fields: {
@@ -154,17 +154,17 @@ export const DataSettings = ({
acc.push({
property: key,
type: value.type,
required: value.config?.required ? "Yes" : "No"
required: value.config?.required ? "Yes" : "No",
});
},
[] as any[]
[] as any[],
),
new: {
schema: fieldsSchema,
uiSchema: dataFieldsUiSchema,
anyOfValues: fieldsAnyOfValues
}
}
anyOfValues: fieldsAnyOfValues,
},
},
}}
path={["data", "entities", entity]}
prefix={`${prefix}/data/entities/${entity}`}
@@ -247,22 +247,22 @@ export const DataSettings = ({
acc.push({
name: key,
type: value.type,
fields: Object.keys(value.fields ?? {}).length
fields: Object.keys(value.fields ?? {}).length,
});
},
[] as any[]
[] as any[],
),
new: {
schema: schema.properties.entities.additionalProperties as any,
uiSchema: {
fields: {
"ui:widget": "hidden"
"ui:widget": "hidden",
},
type: {
"ui:widget": "hidden"
}
}
}
"ui:widget": "hidden",
},
},
},
},
relations: {
extract: true,
@@ -276,12 +276,12 @@ export const DataSettings = ({
data.config?.mappedBy,
data.config?.inversedBy,
data.config?.connectionTable,
data.config?.connectionTableMappedName
data.config?.connectionTableMappedName,
].filter(Boolean);
return [...new Set(parts)].join("_");
},
anyOfValues: relationAnyOfValues
anyOfValues: relationAnyOfValues,
},
tableValues: (config: any) =>
transform(
@@ -291,11 +291,11 @@ export const DataSettings = ({
name: key,
type: value.type,
source: value.source,
target: value.target
target: value.target,
});
},
[] as any[]
)
[] as any[],
),
},
indices: {
extract: true,
@@ -307,32 +307,32 @@ export const DataSettings = ({
name: key,
entity: value.entity,
fields: value.fields.join(", "),
unique: value.unique ? "Yes" : "No"
unique: value.unique ? "Yes" : "No",
});
},
[] as any[]
[] as any[],
),
new: {
schema: newIndex,
uiSchema: {
fields: {
"ui:options": {
orderable: false
}
}
orderable: false,
},
},
},
generateKey: (data: any) => {
const parts = [
"idx",
data.entity,
data.unique && "unique",
...data.fields.filter(Boolean)
...data.fields.filter(Boolean),
].filter(Boolean);
return parts.join("_");
}
}
}
},
},
},
}}
prefix={`${prefix}/data`}
path={["data"]}

View File

@@ -7,26 +7,26 @@ const uiSchema = {
jwt: {
basepath: {
"ui:options": {
label: false
}
label: false,
},
},
fields: {
"ui:options": {
orderable: false
}
}
orderable: false,
},
},
},
strategies: {
additionalProperties: {
"ui:widget": "select",
type: {
"ui:widget": "hidden"
}
"ui:widget": "hidden",
},
},
type: {
"ui:widget": "hidden"
}
}
"ui:widget": "hidden",
},
},
};
export const FlowsSettings = ({ schema, config }) => {
@@ -91,9 +91,9 @@ export const FlowsSettings = ({ schema, config }) => {
uiSchema={{
params: {
render: {
"ui:field": "LiquidJsField"
}
}
"ui:field": "LiquidJsField",
},
},
}}
/>
);
@@ -124,7 +124,7 @@ export const FlowsSettings = ({ schema, config }) => {
tasks: {
extract: true,
new: {
schema: newTask
schema: newTask,
},
tableValues: (config: any) =>
transform(
@@ -132,17 +132,17 @@ export const FlowsSettings = ({ schema, config }) => {
(acc, value, key) => {
acc.push({
name: key,
type: value.type
type: value.type,
});
},
[] as any[]
)
[] as any[],
),
},
connections: {
extract: true,
new: {
schema: newConnection,
generateKey: crypto.randomUUID() as string
generateKey: crypto.randomUUID() as string,
},
tableValues: (config: any) =>
transform(
@@ -152,12 +152,12 @@ export const FlowsSettings = ({ schema, config }) => {
id: key,
source: value.source,
target: value.target,
condition: value.config.condition?.type
condition: value.config.condition?.type,
});
},
[] as any[]
)
}
[] as any[],
),
},
}}
/>
);
@@ -176,7 +176,7 @@ export const FlowsSettings = ({ schema, config }) => {
flows: {
extract: true,
new: {
schema: schema.properties.flows.additionalProperties as any
schema: schema.properties.flows.additionalProperties as any,
/*uiSchema: {
fields: {
@@ -193,12 +193,12 @@ export const FlowsSettings = ({ schema, config }) => {
trigger: value.trigger.type,
mode: value.trigger.config.mode,
start_task: value.start_task,
responding_task: value.responding_task
responding_task: value.responding_task,
});
},
[] as any[]
)
}
[] as any[],
),
},
}}
prefix={`${prefix}/flows`}
path={["flows"]}

View File

@@ -6,14 +6,14 @@ import { Route } from "wouter";
const uiSchema = {
cors: {
allow_methods: {
"ui:widget": "checkboxes"
"ui:widget": "checkboxes",
},
allow_headers: {
"ui:options": {
orderable: false
}
}
}
orderable: false,
},
},
},
};
export const ServerSettings = ({ schema: _unsafe_copy, config }) => {
@@ -39,7 +39,7 @@ export const ServerSettings = ({ schema: _unsafe_copy, config }) => {
return "The admin settings are read-only as they are overriden. Remaining server configuration can be edited.";
}
return;
}
},
}}
schema={schema}
uiSchema={uiSchema}

View File

@@ -5,11 +5,11 @@ import { cloneDeep, omit, pick } from "lodash-es";
export function extractSchema<
Schema extends TObject,
Keys extends keyof Schema["properties"],
Config extends Static<Schema>
Config extends Static<Schema>,
>(
schema: Schema,
config: Config,
keys: Keys[]
keys: Keys[],
): [
JSONSchema7,
Partial<Config>,
@@ -19,7 +19,7 @@ export function extractSchema<
config: Config[K];
schema: Schema["properties"][K];
};
}
},
] {
if (!schema.properties) {
return [{ ...schema }, config, {} as any];
@@ -28,7 +28,7 @@ export function extractSchema<
const newSchema = cloneDeep(schema);
const updated = {
...newSchema,
properties: omit(newSchema.properties, keys)
properties: omit(newSchema.properties, keys),
};
if (updated.required) {
updated.required = updated.required.filter((key) => !keys.includes(key as any));
@@ -40,7 +40,7 @@ export function extractSchema<
// @ts-ignore
config: config[key],
// @ts-ignore
schema: newSchema.properties[key]
schema: newSchema.properties[key],
};
}

View File

@@ -52,7 +52,7 @@ const tests = {
JsonSchemaFormReactTest,
JsonSchemaForm3,
FormyTest,
HtmlFormTest
HtmlFormTest,
} as const;
export default function TestRoutes() {

View File

@@ -5,7 +5,7 @@ import {
IconChevronUp,
IconCirclesRelation,
IconSettings,
IconUser
IconUser,
} from "@tabler/icons-react";
import { useState } from "react";
import { TbDots } from "react-icons/tb";
@@ -23,7 +23,7 @@ const Item = ({
toggle,
ActiveIcon = IconChevronUp,
children,
renderHeaderRight
renderHeaderRight,
}: {
title: string;
open: boolean;
@@ -38,12 +38,12 @@ const Item = ({
"flex flex-col flex-animate overflow-hidden",
open
? "flex-open border-b border-b-muted"
: "flex-initial cursor-pointer hover:bg-primary/5"
: "flex-initial cursor-pointer hover:bg-primary/5",
)}
>
<div
className={twMerge(
"flex flex-row border-muted border-b h-14 py-4 pr-4 pl-2 items-center gap-2"
"flex flex-row border-muted border-b h-14 py-4 pr-4 pl-2 items-center gap-2",
)}
onClick={toggle}
>
@@ -55,7 +55,7 @@ const Item = ({
<div
className={twMerge(
"overflow-y-scroll transition-all",
open ? " flex-grow" : "h-0 opacity-0"
open ? " flex-grow" : "h-0 opacity-0",
)}
>
<div className="flex flex-col gap-5 p-4 ">{children}</div>
@@ -77,8 +77,8 @@ export default function AppShellAccordionsTest() {
<Dropdown
items={[
{
label: "Settings"
}
label: "Settings",
},
]}
position="bottom-end"
>

View File

@@ -57,7 +57,7 @@ function CustomUserAvatarDropzone() {
wrapperRef,
inputProps,
state: { files, isOver, isOverAccepted, showPlaceholder },
actions: { openFileInput }
actions: { openFileInput },
} = Media.useDropzone();
const file = files[0];

View File

@@ -12,7 +12,7 @@ import {
type UseFormReturn,
useController,
useFieldArray,
useForm
useForm,
} from "react-hook-form";
import { TbChevronDown, TbChevronUp, TbGripVertical, TbTrash } from "react-icons/tb";
import { Button } from "../../../components/buttons/Button";
@@ -26,21 +26,21 @@ const fieldSchema = Type.Union(
{
type: Type.Const(type),
name: StringIdentifier,
config: Type.Optional(schema)
config: Type.Optional(schema),
},
{
additionalProperties: false
}
)
)
additionalProperties: false,
},
),
),
);
const schema = Type.Object({
fields: Type.Array(fieldSchema)
fields: Type.Array(fieldSchema),
});
const fieldSchema2 = Type.Object({
type: StringEnum(Object.keys(fieldSchemas)),
name: StringIdentifier
name: StringIdentifier,
});
function specificFieldSchema(type: keyof typeof fieldSchemas) {
@@ -50,7 +50,7 @@ function specificFieldSchema(type: keyof typeof fieldSchemas) {
"required",
"fillable",
"hidden",
"virtual"
"virtual",
]);
}
@@ -62,19 +62,19 @@ export default function EntityFieldsForm() {
handleSubmit,
watch,
register,
setValue
setValue,
} = useForm({
mode: "onTouched",
resolver: typeboxResolver(schema),
defaultValues: {
fields: [{ type: "text", name: "", config: {} }],
sort: { by: "-1", dir: "asc" }
}
sort: { by: "-1", dir: "asc" },
},
});
const defaultType = Object.keys(fieldSchemas)[0];
const { fields, append, prepend, remove, swap, move, insert, update } = useFieldArray({
control, // control props comes from useForm (optional: if you are using FormProvider)
name: "fields" // unique name for your Field Array
name: "fields", // unique name for your Field Array
});
function handleAppend() {
@@ -113,16 +113,16 @@ function EntityFieldForm({ update, index, value }) {
register,
handleSubmit,
control,
formState: { errors }
formState: { errors },
} = useForm({
mode: "onBlur",
resolver: typeboxResolver(
Type.Object({
type: StringEnum(Object.keys(fieldSchemas)),
name: Type.String({ minLength: 1, maxLength: 3 })
})
name: Type.String({ minLength: 1, maxLength: 3 }),
}),
),
defaultValues: value
defaultValues: value,
});
function handleUpdate({ id, ...data }) {
@@ -153,19 +153,19 @@ function EntityFieldController({
control,
defaultValue,
rules,
shouldUnregister
shouldUnregister,
}: UseControllerProps & {
index: number;
}) {
const {
field: { value, onChange: fieldOnChange, ...field },
fieldState
fieldState,
} = useController({
name,
control,
defaultValue,
rules,
shouldUnregister
shouldUnregister,
});
return <div>field</div>;
@@ -176,7 +176,7 @@ function EntityField({
index,
form: { watch, register, setValue, getValues, control },
remove,
defaultType
defaultType,
}: {
field: FieldArrayWithId;
index: number;

View File

@@ -6,7 +6,7 @@ export default function FlowFormTest() {
const [data, setData] = useState(null);
const task = new FetchTask("Fetch Something", {
url: "https://jsonplaceholder.typicode.com/todos/1",
method: "{{ input.mode }}"
method: "{{ input.mode }}",
});
return (

View File

@@ -9,7 +9,7 @@ import {
IconPlayerPlay,
IconPlus,
IconTrash,
IconWorld
IconWorld,
} from "@tabler/icons-react";
import { useState } from "react";
import { TbPlayerPlayFilled } from "react-icons/tb";
@@ -30,9 +30,9 @@ const TRIGGERS = {
mode: "sync",
method: "GET",
response_type: "json",
path: "/trigger_http"
}
}
path: "/trigger_http",
},
},
};
const TASKS = {
@@ -41,9 +41,9 @@ const TASKS = {
params: {
method: "GET",
headers: [],
url: "https://jsonplaceholder.typicode.com/todos/1"
}
}
url: "https://jsonplaceholder.typicode.com/todos/1",
},
},
};
export default function FlowsTest() {
@@ -63,7 +63,7 @@ const NodeHeader = ({
iconProps,
rightSection,
initialValue,
onChange
onChange,
}: {
Icon: React.FC<any>;
iconProps?: ElementProps<"svg">;
@@ -100,7 +100,7 @@ const TriggerComponent = () => {
data={[
{ label: "Manual", value: "manual" },
{ label: "HTTP", value: "http" },
{ label: "Event", value: "event", disabled: true }
{ label: "Event", value: "event", disabled: true },
]}
/>
<SegmentedControl
@@ -108,7 +108,7 @@ const TriggerComponent = () => {
defaultValue="async"
data={[
{ label: "Async", value: "async" },
{ label: "Sync", value: "sync" }
{ label: "Sync", value: "sync" },
]}
/>
</div>
@@ -134,7 +134,7 @@ const TriggerComponent = () => {
data={[
{ label: "JSON", value: "json" },
{ label: "HTML", value: "html" },
{ label: "Text", value: "text" }
{ label: "Text", value: "text" },
]}
/>
</div>

View File

@@ -13,7 +13,7 @@ const validator = new TypeboxValidator();
const schema = Type.Object({
name: Type.String(),
age: Type.Optional(Type.Number())
age: Type.Optional(Type.Number()),
});
export default function JsonSchemaFormReactTest() {

View File

@@ -9,7 +9,7 @@ import {
FormContextOverride,
FormDebug,
ObjectField,
useFormError
useFormError,
} from "ui/components/form/json-schema-form";
import { Scrollable } from "ui/layouts/AppShell/AppShell";
@@ -20,16 +20,16 @@ const schema2 = {
age: { type: "number" },
gender: {
type: "string",
enum: ["male", "female", "uni"]
enum: ["male", "female", "uni"],
},
deep: {
type: "object",
properties: {
nested: { type: "string" }
}
}
nested: { type: "string" },
},
},
},
required: ["age"]
required: ["age"],
} as const satisfies JSONSchema;
const authSchema = {
@@ -38,8 +38,8 @@ const authSchema = {
what: {
type: "array",
items: {
type: "string"
}
type: "string",
},
},
jwt: {
type: "object",
@@ -47,16 +47,16 @@ const authSchema = {
fields: {
type: "array",
items: {
type: "string"
}
}
}
}
}
type: "string",
},
},
},
},
},
} as const satisfies JSONSchema;
const formOptions = {
debug: true
debug: true,
};
export default function JsonSchemaForm3() {
@@ -314,7 +314,7 @@ const ss = {
interested: { type: "boolean" },
bla: {
type: "string",
enum: ["small", "medium", "large"]
enum: ["small", "medium", "large"],
},
password: { type: "string", format: "password" },
birthdate: { type: "string", format: "date" },
@@ -323,18 +323,18 @@ const ss = {
tags: {
type: "array",
items: {
type: "string"
}
type: "string",
},
},
config: {
type: "object",
properties: {
min: { type: "number" }
}
}
min: { type: "number" },
},
},
},
required: ["name"],
additionalProperties: false
additionalProperties: false,
} as const satisfies JSONSchema;
function CustomMediaForm() {

View File

@@ -16,12 +16,12 @@ export default function JsonFormTest() {
name: {
type: "string",
title: "Name",
minLength: 3
minLength: 3,
},
variants: {
anyOf: [{ type: "string" }, { type: "number" }]
}
}
anyOf: [{ type: "string" }, { type: "number" }],
},
},
};
const ref = useRef<JsonSchemaFormRef>(null);

View File

@@ -9,52 +9,52 @@ const schema: Schema = {
anyOf: [
{
title: "String",
type: "string"
type: "string",
},
{
title: "Number",
type: "number"
type: "number",
},
{
title: "Boolean",
type: "boolean"
}
]
type: "boolean",
},
],
},
numeric: {
anyOf: [
{
title: "Number",
type: "number"
type: "number",
},
{
title: "Datetime",
type: "string",
format: "date-time"
format: "date-time",
},
{
title: "Date",
type: "string",
format: "date"
format: "date",
},
{
title: "Time",
type: "string",
format: "time"
}
]
format: "time",
},
],
},
boolean: {
title: "Boolean",
type: "boolean"
}
type: "boolean",
},
},
type: "object",
properties: {
operand: {
enum: ["$and", "$or"],
default: "$and",
type: "string"
type: "string",
},
conditions: {
type: "array",
@@ -64,10 +64,10 @@ const schema: Schema = {
operand: {
enum: ["$and", "$or"],
default: "$and",
type: "string"
type: "string",
},
key: {
type: "string"
type: "string",
},
operator: {
type: "array",
@@ -78,30 +78,30 @@ const schema: Schema = {
type: "object",
properties: {
$eq: {
$ref: "#/definitions/primitive"
}
$ref: "#/definitions/primitive",
},
},
required: ["$eq"]
required: ["$eq"],
},
{
title: "Lower than",
type: "object",
properties: {
$lt: {
$ref: "#/definitions/numeric"
}
$ref: "#/definitions/numeric",
},
},
required: ["$lt"]
required: ["$lt"],
},
{
title: "Greather than",
type: "object",
properties: {
$gt: {
$ref: "#/definitions/numeric"
}
$ref: "#/definitions/numeric",
},
},
required: ["$gt"]
required: ["$gt"],
},
{
title: "Between",
@@ -110,13 +110,13 @@ const schema: Schema = {
$between: {
type: "array",
items: {
$ref: "#/definitions/numeric"
$ref: "#/definitions/numeric",
},
minItems: 2,
maxItems: 2
}
maxItems: 2,
},
},
required: ["$between"]
required: ["$between"],
},
{
title: "In",
@@ -125,23 +125,23 @@ const schema: Schema = {
$in: {
type: "array",
items: {
$ref: "#/definitions/primitive"
$ref: "#/definitions/primitive",
},
minItems: 1
}
}
}
]
minItems: 1,
},
},
},
],
},
minItems: 1
}
minItems: 1,
},
},
required: ["key", "operator"]
required: ["key", "operator"],
},
minItems: 1
}
minItems: 1,
},
},
required: ["operand", "conditions"]
required: ["operand", "conditions"],
};
export default function QueryJsonFormTest() {

View File

@@ -5,7 +5,7 @@ import { useForm } from "react-hook-form";
const schema = Type.Object({
example: Type.Optional(Type.String()),
exampleRequired: Type.String({ minLength: 2 })
exampleRequired: Type.String({ minLength: 2 }),
});
export default function ReactHookErrors() {
@@ -13,9 +13,9 @@ export default function ReactHookErrors() {
register,
handleSubmit,
watch,
formState: { errors }
formState: { errors },
} = useForm({
resolver: typeboxResolver(schema)
resolver: typeboxResolver(schema),
});
const onSubmit = (data) => console.log(data);

View File

@@ -2,7 +2,7 @@ import { ReactFlow } from "@xyflow/react";
const initialNodes = [
{ id: "1", position: { x: 0, y: 0 }, data: { label: "1" } },
{ id: "2", position: { x: 0, y: 100 }, data: { label: "2" } }
{ id: "2", position: { x: 0, y: 100 }, data: { label: "2" } },
];
const initialEdges = [{ id: "e1-2", source: "1", target: "2" }];

View File

@@ -23,50 +23,50 @@ const uiSchema = {
jwt: {
basepath: {
"ui:options": {
label: false
}
label: false,
},
},
fields: {
"ui:options": {
label: false,
orderable: false
}
}
orderable: false,
},
},
},
strategies: {
additionalProperties: {
"ui:widget": "select",
type: {
"ui:widget": "hidden"
}
"ui:widget": "hidden",
},
},
type: {
"ui:widget": "hidden"
}
}
"ui:widget": "hidden",
},
},
},
server: {
cors: {
allow_methods: {
"ui:widget": "checkboxes"
"ui:widget": "checkboxes",
},
allow_headers: {
"ui:options": {
orderable: false
}
}
}
orderable: false,
},
},
},
},
media: {
adapter: {
"ui:options": {
label: false
label: false,
},
type: {
"ui:widget": "hidden"
}
}
}
"ui:widget": "hidden",
},
},
},
};
export default function SchemaTest() {
@@ -81,7 +81,7 @@ export default function SchemaTest() {
key: tab,
schema: schema[tab],
uiSchema: uiSchema[tab] || {},
config: app.config[tab]
config: app.config[tab],
};
console.log("current", current);

View File

@@ -5,7 +5,7 @@ import {
type DraggableRubric,
type DraggableStateSnapshot,
Droppable,
type DroppableProps
type DroppableProps,
} from "@hello-pangea/dnd";
import { useListState } from "@mantine/hooks";
import { IconGripVertical } from "@tabler/icons-react";
@@ -24,7 +24,7 @@ export default function SortableTest() {
{ id: "N", name: "Nitrogen" },
{ id: "Y", name: "Yttrium" },
{ id: "Ba", name: "Barium" },
{ id: "Ce", name: "Cerium" }
{ id: "Ce", name: "Cerium" },
]}
onReordered={(...args) => console.log("reordered", args)}
onChange={(data) => console.log("changed", data)}
@@ -54,7 +54,7 @@ export function SortableList({
renderItem,
dndProps = { droppableId: "sortable-list", direction: "vertical" },
onReordered,
onChange
onChange,
}: SortableListProps) {
const [state, handlers] = useListState(data);

View File

@@ -16,7 +16,7 @@ function SwaggerUI() {
// @ts-ignore
window.ui = window.SwaggerUIBundle({
url: "http://localhost:28623/api/system/openapi.json",
dom_id: "#swagger-ui"
dom_id: "#swagger-ui",
});
}
};

View File

@@ -19,7 +19,7 @@ export default function SWRAndAPI() {
const [text, setText] = useState("");
const { data, ...r } = useApiQuery((api) => api.data.readOne("comments", 1), {
refine: (data) => data.data,
revalidateOnFocus: true
revalidateOnFocus: true,
});
const comment = data ? data : null;

View File

@@ -16,7 +16,7 @@ export default function SwrAndDataApi() {
function QueryMutateDataApi() {
const { mutate } = useEntityMutate("comments");
const { data, ...r } = useEntityQuery("comments", undefined, {
limit: 2
limit: 2,
});
return (
@@ -48,7 +48,7 @@ function QueryMutateDataApi() {
function QueryDataApi() {
const { data, update, ...r } = useEntityQuery("comments", undefined, {
sort: { by: "id", dir: "asc" },
limit: 3
limit: 3,
});
return (