Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

feat: crud for configuration parameters

Brad Barbin989e10d2a59e
diff --git a/apps/carbon/app/modules/items/items.models.ts b/apps/carbon/app/modules/items/items.models.ts
index 7d2c2f4f8f..7a3952f07c 100644
--- a/apps/carbon/app/modules/items/items.models.ts
+++ b/apps/carbon/app/modules/items/items.models.ts
@@ -8,10 +8,12 @@ import {
standardFactorType,
} from "../shared";
-export const getMethodValidator = z.object({
- targetId: z.string().min(1, { message: "Please select a target method" }),
- sourceId: z.string().min(1, { message: "Please select a source method" }),
-});
+export const configurationParameterDataTypes = [
+ "text",
+ "numeric",
+ "boolean",
+ "list",
+] as const;
export const itemTrackingTypes = ["Inventory", "Non-Inventory"] as const;
@@ -72,16 +74,40 @@ export const itemValidator = z.object({
active: zfd.checkbox(),
});
-export const supplierPartValidator = z.object({
- id: zfd.text(z.string().optional()),
- itemId: z.string().min(1, { message: "Item ID is required" }),
- supplierId: z.string().min(36, { message: "Supplier ID is required" }),
- supplierPartId: z.string().optional(),
- supplierUnitOfMeasureCode: zfd.text(z.string().optional()),
- minimumOrderQuantity: zfd.numeric(z.number().min(0)),
- conversionFactor: zfd.numeric(z.number().min(0)),
- unitPrice: zfd.numeric(z.number().min(0)),
-});
+export const configurationParameterValidator = z
+ .object({
+ id: zfd.text(z.string().optional()),
+ itemId: z.string().min(1, { message: "Item ID is required" }),
+ key: zfd.text(z.string().optional()),
+ label: z.string().min(1, { message: "Label is required" }),
+ dataType: z.enum(configurationParameterDataTypes),
+ listOptions: z.string().min(1).array().optional(),
+ configurationParameterGroupId: z.string().optional(),
+ })
+ .refine(
+ (data) => {
+ if (data.dataType === "list") {
+ return !!data.listOptions;
+ }
+ return true;
+ },
+ { message: "List options are required", path: ["listOptions"] }
+ )
+ .refine(
+ (data) => {
+ return data.label.match(/^[a-zA-Z0-9 ]+$/);
+ },
+ {
+ message: "Only alphanumeric characters and spaces are allowed",
+ path: ["label"],
+ }
+ )
+ .refine(
+ (data) => {
+ return data.key?.match(/^[a-z]+(_[a-z]+)*$/);
+ },
+ { message: "Key must be lowercase and underscore separated" }
+ );
export const consumableValidator = itemValidator.merge(
z.object({
@@ -100,6 +126,11 @@ export const customerPartValidator = z.object({
customerPartRevision: zfd.text(z.string().optional()),
});
+export const getMethodValidator = z.object({
+ targetId: z.string().min(1, { message: "Please select a target method" }),
+ sourceId: z.string().min(1, { message: "Please select a source method" }),
+});
+
export const materialValidator = itemValidator.merge(
z.object({
id: z.string().min(1, { message: "Material ID is required" }).max(255),
@@ -426,6 +457,17 @@ export const serviceValidator = itemValidator.merge(
})
);
+export const supplierPartValidator = z.object({
+ id: zfd.text(z.string().optional()),
+ itemId: z.string().min(1, { message: "Item ID is required" }),
+ supplierId: z.string().min(36, { message: "Supplier ID is required" }),
+ supplierPartId: z.string().optional(),
+ supplierUnitOfMeasureCode: zfd.text(z.string().optional()),
+ minimumOrderQuantity: zfd.numeric(z.number().min(0)),
+ conversionFactor: zfd.numeric(z.number().min(0)),
+ unitPrice: zfd.numeric(z.number().min(0)),
+});
+
export const toolValidator = itemValidator.merge(
z.object({
id: z.string().min(1, { message: "Tool ID is required" }).max(255),
diff --git a/apps/carbon/app/modules/items/items.service.ts b/apps/carbon/app/modules/items/items.service.ts
index 1955e9b020..8e43b61d8c 100644
--- a/apps/carbon/app/modules/items/items.service.ts
+++ b/apps/carbon/app/modules/items/items.service.ts
@@ -8,6 +8,7 @@ import { setGenericQueryFilters } from "~/utils/query";
import { sanitize } from "~/utils/supabase";
import type { operationToolValidator } from "../shared";
import type {
+ configurationParameterValidator,
consumableValidator,
customerPartValidator,
getMethodValidator,
@@ -49,6 +50,13 @@ export async function copyMakeMethod(
});
}
+export async function deleteConfigurationParameter(
+ client: SupabaseClient<Database>,
+ id: string
+) {
+ return client.from("configurationParameter").delete().eq("id", id);
+}
+
export async function deleteItemCustomerPart(
client: SupabaseClient<Database>,
id: string,
@@ -116,13 +124,13 @@ export async function deleteUnitOfMeasure(
return client.from("unitOfMeasure").delete().eq("id", id);
}
-export async function getConfigurationOptions(
+export async function getConfigurationParameters(
client: SupabaseClient<Database>,
itemId: string,
companyId: string
) {
return client
- .from("configurationOption")
+ .from("configurationParameter")
.select("*")
.eq("itemId", itemId)
.eq("companyId", companyId);
@@ -1047,6 +1055,34 @@ export async function updateOperationOrder(
return Promise.all(updatePromises);
}
+export async function upsertConfigurationParameter(
+ client: SupabaseClient<Database>,
+ configurationParameter: z.infer<typeof configurationParameterValidator> & {
+ companyId: string;
+ userId: string;
+ }
+) {
+ const { userId, ...data } = configurationParameter;
+ if (configurationParameter.id) {
+ return client
+ .from("configurationParameter")
+ .update(
+ sanitize({
+ ...data,
+ updatedBy: userId,
+ updatedAt: new Date().toISOString(),
+ })
+ )
+ .eq("id", configurationParameter.id);
+ }
+
+ return client.from("configurationParameter").insert({
+ ...data,
+ createdBy: userId,
+ configurationParameterGroupId: data.configurationParameterGroupId,
+ });
+}
+
export async function upsertConsumable(
client: SupabaseClient<Database>,
consumable:
diff --git a/apps/carbon/app/modules/items/types.ts b/apps/carbon/app/modules/items/types.ts
index b904b07c21..f17078cd9b 100644
--- a/apps/carbon/app/modules/items/types.ts
+++ b/apps/carbon/app/modules/items/types.ts
@@ -1,6 +1,6 @@
import type { Database } from "@carbon/database";
import type {
- getConfigurationOptions,
+ getConfigurationParameters,
getConsumable,
getConsumables,
getItemCost,
@@ -29,8 +29,8 @@ import type {
getUnitOfMeasuresList,
} from "./items.service";
-export type ConfigurationOption = NonNullable<
- Awaited<ReturnType<typeof getConfigurationOptions>>["data"]
+export type ConfigurationParameter = NonNullable<
+ Awaited<ReturnType<typeof getConfigurationParameters>>["data"]
>[number];
export type Consumable = NonNullable<
diff --git a/apps/carbon/app/modules/settings/ui/CustomFields/CustomFieldForm.tsx b/apps/carbon/app/modules/settings/ui/CustomFields/CustomFieldForm.tsx
index be7e5bef6a..c99b76b6d2 100644
--- a/apps/carbon/app/modules/settings/ui/CustomFields/CustomFieldForm.tsx
+++ b/apps/carbon/app/modules/settings/ui/CustomFields/CustomFieldForm.tsx
@@ -1,5 +1,6 @@
import {
Button,
+ cn,
Drawer,
DrawerBody,
DrawerContent,
@@ -13,6 +14,14 @@ import {
import { ValidatedForm } from "@carbon/form";
import { useParams } from "@remix-run/react";
import { useState } from "react";
+import {
+ LuCalendar,
+ LuHash,
+ LuList,
+ LuToggleLeft,
+ LuType,
+ LuUser,
+} from "react-icons/lu";
import type { z } from "zod";
import { Array, Hidden, Input, Select, Submit, Tags } from "~/components/Form";
import { usePermissions, useRouteData } from "~/hooks";
@@ -43,7 +52,12 @@ const CustomFieldForm = ({
const options =
dataTypes?.map((dt) => ({
value: dt.id.toString(),
- label: dt.label,
+ label: (
+ <HStack className="w-full">
+ <CustomFieldDataTypeIcon type={dt.id} className="mr-2" />
+ {dt.label}
+ </HStack>
+ ),
})) ?? [];
const isEditing = initialValues.id !== undefined;
@@ -133,3 +147,30 @@ const CustomFieldForm = ({
};
export default CustomFieldForm;
+
+function CustomFieldDataTypeIcon({
+ type,
+ className,
+}: {
+ type: DataType;
+ className?: string;
+}) {
+ switch (type) {
+ case DataType.Numeric:
+ return <LuHash className={cn("w-4 h-4 text-blue-600", className)} />;
+ case DataType.Text:
+ return <LuType className={cn("w-4 h-4 text-green-600", className)} />;
+ case DataType.Boolean:
+ return (
+ <LuToggleLeft className={cn("w-4 h-4 text-purple-600", className)} />
+ );
+ case DataType.List:
+ return <LuList className={cn("w-4 h-4 text-orange-600", className)} />;
+ case DataType.Date:
+ return <LuCalendar className={cn("w-4 h-4 text-red-600", className)} />;
+ case DataType.User:
+ return <LuUser className={cn("w-4 h-4 text-yellow-600", className)} />;
+ default:
+ return null;
+ }
+}
diff --git a/apps/carbon/app/routes/x+/part+/$itemId.manufacturing.method.tsx b/apps/carbon/app/routes/x+/part+/$itemId.manufacturing.method.tsx
index 9b814a135d..96045f55be 100644
--- a/apps/carbon/app/routes/x+/part+/$itemId.manufacturing.method.tsx
+++ b/apps/carbon/app/routes/x+/part+/$itemId.manufacturing.method.tsx
@@ -2,6 +2,7 @@ import { assertIsPost, error, success } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
import {
+ Array,
Hidden,
Input,
Select,
@@ -13,25 +14,46 @@ import {
import {
Button,
Card,
- CardAction,
CardContent,
CardHeader,
CardTitle,
+ cn,
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuTrigger,
HStack,
+ IconButton,
+ toast,
+ useDisclosure,
VStack,
} from "@carbon/react";
-import { json, useFetcher, useLoaderData, useParams } from "@remix-run/react";
+import { Await, useFetcher, useLoaderData, useParams } from "@remix-run/react";
import type { ActionFunctionArgs, LoaderFunctionArgs } from "@vercel/remix";
-import { redirect } from "@vercel/remix";
-import { LuPlusCircle } from "react-icons/lu";
+import { defer, redirect } from "@vercel/remix";
+import { Suspense, useEffect, useRef, useState } from "react";
+import {
+ LuGripVertical,
+ LuHash,
+ LuKeySquare,
+ LuList,
+ LuMoreVertical,
+ LuPlusCircle,
+ LuToggleLeft,
+ LuType,
+} from "react-icons/lu";
+import { EmployeeAvatar } from "~/components";
import { useRouteData } from "~/hooks";
import type {
- ConfigurationOption,
+ ConfigurationParameter,
MakeMethod,
Material,
MethodOperation,
} from "~/modules/items";
import {
+ configurationParameterDataTypes,
+ configurationParameterValidator,
+ getConfigurationParameters,
getItemManufacturing,
partManufacturingValidator,
upsertItemManufacturing,
@@ -42,9 +64,13 @@ import {
MakeMethodTools,
} from "~/modules/items/ui/Item";
import { PartManufacturingForm } from "~/modules/items/ui/Parts";
+import type { action as configurationParameterAction } from "~/routes/x+/part+/$itemId.parameter";
import { getCustomFields, setCustomFields } from "~/utils/form";
import { path } from "~/utils/path";
+import { capitalize } from "~/utils/string";
+import { formatRelativeTime } from "@carbon/utils";
+import { ConfirmDelete } from "~/components/Modals";
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
view: "parts",
@@ -67,8 +93,11 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
);
}
- return json({
+ return defer({
partManufacturing: partManufacturing.data,
+ configurationParameters: partManufacturing.data.requiresConfiguration
+ ? getConfigurationParameters(client, itemId, companyId)
+ : Promise.resolve({ data: [], error: null }),
});
}
@@ -116,7 +145,8 @@ export async function action({ request, params }: ActionFunctionArgs) {
}
export default function MakeMethodRoute() {
- const { partManufacturing } = useLoaderData<typeof loader>();
+ const { partManufacturing, configurationParameters } =
+ useLoaderData<typeof loader>();
const { itemId } = useParams();
if (!itemId) throw new Error("Could not find itemId");
@@ -143,7 +173,25 @@ export default function MakeMethodRoute() {
initialValues={manufacturingInitialValues}
/>
{partManufacturing.requiresConfiguration && (
- <ConfigurationOptionsForm options={[]} />
+ <Suspense
+ fallback={
+ <Card>
+ <CardHeader>
+ <CardTitle>Options</CardTitle>
+ </CardHeader>
+ <CardContent className="min-h-[200px]"></CardContent>
+ </Card>
+ }
+ >
+ <Await resolve={configurationParameters}>
+ {(resolvedOptions) => (
+ <ConfigurationParametersForm
+ key={`options:${itemId}`}
+ options={resolvedOptions.data ?? []}
+ />
+ )}
+ </Await>
+ </Suspense>
)}
<BillOfProcess
@@ -164,60 +212,124 @@ export default function MakeMethodRoute() {
);
}
-function ConfigurationOptionsForm({
+function useConfigurationParameters(option?: ConfigurationParameter) {
+ const { itemId } = useParams();
+ if (!itemId) throw new Error("Could not find itemId");
+ const [key, setKey] = useState(option?.key ?? "");
+ const [isList, setIsList] = useState(option?.dataType === "list");
+
+ const onChangeCheckForListType = (
+ newValue: {
+ value: string;
+ label: string | JSX.Element;
+ } | null
+ ) => {
+ if (!newValue) return;
+ const type = newValue.value;
+ setIsList(type === "list");
+ };
+
+ const updateKey = (e: React.ChangeEvent<HTMLInputElement>) => {
+ const label = e.target.value;
+ setKey(label.toLowerCase().replace(/ /g, "_"));
+ };
+
+ return {
+ key,
+ isList,
+ itemId,
+ onChangeCheckForListType,
+ setKey,
+ setIsList,
+ updateKey,
+ };
+}
+
+function ConfigurationParametersForm({
options,
}: {
- options: ConfigurationOption[];
+ options: ConfigurationParameter[];
}) {
- const { itemId } = useParams();
- if (!itemId) throw new Error("Could not find itemId");
+ const {
+ isList,
+ itemId,
+ key,
+ onChangeCheckForListType,
+ setKey,
+ setIsList,
+ updateKey,
+ } = useConfigurationParameters();
- const fetcher = useFetcher();
+ const fetcher = useFetcher<typeof configurationParameterAction>();
+ useEffect(() => {
+ if (fetcher.data?.success === false) {
+ toast.error("Failed to update configuration option");
+ }
+ }, [fetcher.data]);
return (
- <Card>
- <HStack className="w-full justify-between">
- <CardHeader>
- <CardTitle>Options</CardTitle>
- </CardHeader>
- <CardAction>
- <Button variant="secondary">Add Option</Button>
- </CardAction>
- </HStack>
+ <Card isCollapsible>
+ <CardHeader>
+ <CardTitle>Parameters</CardTitle>
+ </CardHeader>
<CardContent>
<div className="flex flex-col gap-6">
<div className="p-6 border rounded-lg">
<ValidatedForm
- action={path.to.newConfigurationOption}
+ action={path.to.configurationParameter(itemId)}
method="post"
- validator={configurationOptionValidator}
+ validator={configurationParameterValidator}
fetcher={fetcher}
resetAfterSubmit
+ onSubmit={() => {
+ setKey("");
+ setIsList(false);
+ }}
defaultValues={{
itemId: itemId,
key: "",
label: "",
dataType: "numeric",
listOptions: [],
- configurationOptionGroupId: undefined,
+ configurationParameterGroupId: undefined,
}}
className="w-full"
>
+ <Hidden name="id" />
<Hidden name="itemId" />
+ <Hidden name="key" value={key} />
<VStack spacing={4}>
- <div className="w-full grid grid-cols-1 lg:grid-cols-3 gap-4 items-start">
- <Input name="key" label="Key" autoFocus />
- <Input name="label" label="Label" />
+ <div className="w-full grid grid-cols-1 lg:grid-cols-2 gap-4 items-start">
+ <VStack>
+ <Input name="label" label="Label" onChange={updateKey} />
+ {key && (
+ <HStack spacing={1}>
+ <LuKeySquare className="w-3 h-3 text-muted-foreground" />
+ <span className="text-sm text-muted-foreground">
+ {key}
+ </span>
+ </HStack>
+ )}
+ </VStack>
+
<Select
name="dataType"
label="Data Type"
- options={[
- { label: "Text", value: "text" },
- { label: "Numeric", value: "numeric" },
- { label: "Boolean", value: "boolean" },
- { label: "List", value: "list" },
- ]}
+ options={configurationParameterDataTypes.map((type) => ({
+ label: (
+ <HStack className="w-full">
+ <ConfigurationParameterDataTypeIcon
+ type={type}
+ className="mr-2"
+ />
+ {capitalize(type)}
+ </HStack>
+ ),
+ value: type,
+ }))}
+ onChange={onChangeCheckForListType}
/>
+ {isList && <Array name="listOptions" label="List Options" />}
</div>
<Submit
@@ -230,8 +342,217 @@ function ConfigurationOptionsForm({
</VStack>
</ValidatedForm>
</div>
+
+ {options.length > 0 && (
+ <div className="border rounded-lg">
+ {options.map((option, index) => (
+ <ConfigurableOption
+ key={option.id}
+ option={option}
+ className={index === options.length - 1 ? "border-none" : ""}
+ />
+ ))}
+ </div>
+ )}
</div>
</CardContent>
</Card>
);
}
+
+function ConfigurableOption({
+ option,
+ className,
+}: {
+ option: ConfigurationParameter;
+ className?: string;
+}) {
+ const { isList, key, onChangeCheckForListType, updateKey } =
+ useConfigurationParameters(option);
+
+ const disclosure = useDisclosure();
+ const deleteModalDisclosure = useDisclosure();
+ const submitted = useRef(false);
+ const fetcher = useFetcher<typeof configurationParameterAction>();
+
+ useEffect(() => {
+ if (submitted.current && fetcher.state === "idle") {
+ disclosure.onClose();
+ submitted.current = false;
+ }
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [fetcher.state]);
+
+ const isUpdated = option.updatedBy !== null;
+ const person = isUpdated ? option.updatedBy : option.createdBy;
+ const date = option.updatedAt ?? option.createdAt;
+
+ return (
+ <div className={cn("border-b p-6", className)}>
+ {disclosure.isOpen ? (
+ <ValidatedForm
+ action={path.to.configurationParameter(option.itemId)}
+ method="post"
+ validator={configurationParameterValidator}
+ fetcher={fetcher}
+ resetAfterSubmit
+ onSubmit={() => {
+ disclosure.onClose();
+ }}
+ defaultValues={{
+ id: option.id,
+ itemId: option.itemId,
+ key: option.key,
+ label: option.label,
+ dataType: option.dataType,
+ listOptions: option.listOptions ?? [],
+ }}
+ >
+ <Hidden name="id" />
+ <Hidden name="itemId" />
+ <Hidden name="key" value={key} />
+ <VStack spacing={4}>
+ <div className="w-full grid grid-cols-1 lg:grid-cols-2 gap-4 items-start">
+ <VStack>
+ <Input
+ name="label"
+ label="Label"
+ onChange={updateKey}
+ autoFocus
+ />
+ {key && (
+ <HStack spacing={1}>
+ <LuKeySquare className="w-3 h-3 text-muted-foreground" />
+ <span className="text-sm text-muted-foreground">{key}</span>
+ </HStack>
+ )}
+ </VStack>
+
+ <Select
+ name="dataType"
+ label="Data Type"
+ options={configurationParameterDataTypes.map((type) => ({
+ label: (
+ <HStack className="w-full">
+ <ConfigurationParameterDataTypeIcon
+ type={type}
+ className="mr-2"
+ />
+ {capitalize(type)}
+ </HStack>
+ ),
+ value: type,
+ }))}
+ onChange={onChangeCheckForListType}
+ />
+ {isList && <Array name="listOptions" label="List Options" />}
+ </div>
+ <HStack className="w-full justify-end" spacing={2}>
+ <Button variant="secondary" onClick={disclosure.onClose}>
+ Cancel
+ </Button>
+ <Submit
+ isDisabled={fetcher.state !== "idle"}
+ isLoading={fetcher.state !== "idle"}
+ >
+ Save
+ </Submit>
+ </HStack>
+ </VStack>
+ </ValidatedForm>
+ ) : (
+ <div className="flex flex-1 justify-between items-center w-full">
+ <HStack spacing={2} className="w-1/2">
+ <IconButton
+ aria-label="Reorder"
+ icon={<LuGripVertical />}
+ variant="ghost"
+ />
+ <HStack spacing={4} className="flex-1">
+ <div className="bg-muted border rounded-full flex items-center justify-center p-2">
+ <ConfigurationParameterDataTypeIcon
+ type={option.dataType}
+ className="w-4 h-4"
+ />
+ </div>
+ <VStack spacing={0}>
+ <span className="text-sm font-medium">{option.label}</span>
+ <span className="text-xs text-muted-foreground">
+ {option.key}
+ </span>
+ </VStack>
+ </HStack>
+ </HStack>
+ <div className="flex items-center justify-end gap-2">
+ <HStack spacing={2}>
+ <span className="text-xs text-muted-foreground">
+ {isUpdated ? "Updated" : "Created"} {formatRelativeTime(date)}
+ </span>
+ <EmployeeAvatar employeeId={person} withName={false} />
+ </HStack>
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <IconButton
+ aria-label="Open menu"
+ icon={<LuMoreVertical />}
+ variant="ghost"
+ />
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end">
+ <DropdownMenuItem onClick={disclosure.onOpen}>
+ Edit
+ </DropdownMenuItem>
+ <DropdownMenuItem
+ destructive
+ onClick={deleteModalDisclosure.onOpen}
+ >
+ Delete
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </div>
+ </div>
+ )}
+ {deleteModalDisclosure.isOpen && (
+ <ConfirmDelete
+ action={path.to.deleteConfigurationParameter(
+ option.itemId,
+ option.id
+ )}
+ isOpen={deleteModalDisclosure.isOpen}
+ name={option.label}
+ text={`Are you sure you want to delete the ${option.label} parameter? This will not update any formulas that are using this parameter.`}
+ onCancel={() => {
+ deleteModalDisclosure.onClose();
+ }}
+ onSubmit={() => {
+ deleteModalDisclosure.onClose();
+ }}
+ />
+ )}
+ </div>
+ );
+}
+
+function ConfigurationParameterDataTypeIcon({
+ type,
+ className,
+}: {
+ type: (typeof configurationParameterDataTypes)[number];
+ className?: string;
+}) {
+ switch (type) {
+ case "numeric":
+ return <LuHash className={cn("w-4 h-4 text-blue-600", className)} />;
+ case "text":
+ return <LuType className={cn("w-4 h-4 text-green-600", className)} />;
+ case "boolean":
+ return (
+ <LuToggleLeft className={cn("w-4 h-4 text-purple-600", className)} />
+ );
+ case "list":
+ return <LuList className={cn("w-4 h-4 text-orange-600", className)} />;
+ default:
+ return null;
+ }
+}
diff --git a/apps/carbon/app/routes/x+/part+/$itemId.parameter.delete.$id.tsx b/apps/carbon/app/routes/x+/part+/$itemId.parameter.delete.$id.tsx
new file mode 100644
index 0000000000..563a54b7c8
--- /dev/null
+++ b/apps/carbon/app/routes/x+/part+/$itemId.parameter.delete.$id.tsx
@@ -0,0 +1,28 @@
+import { assertIsPost, notFound } from "@carbon/auth";
+import { requirePermissions } from "@carbon/auth/auth.server";
+import type { ActionFunctionArgs } from "@vercel/remix";
+import { json } from "@vercel/remix";
+import { deleteConfigurationParameter } from "~/modules/items";
+
+export async function action({ request, params }: ActionFunctionArgs) {
+ assertIsPost(request);
+ const { client } = await requirePermissions(request, {
+ delete: "parts",
+ });
+
+ const { id } = params;
+ if (!id) throw notFound("id not found");
+
+ const remove = await deleteConfigurationParameter(client, id);
+
+ if (remove.error) {
+ return json({
+ success: false,
+ error: "Failed to delete configuration parameter",
+ });
+ }
+
+ return json({
+ success: true,
+ });
+}
diff --git a/apps/carbon/app/routes/x+/part+/$itemId.parameter.tsx b/apps/carbon/app/routes/x+/part+/$itemId.parameter.tsx
new file mode 100644
index 0000000000..4ec1b8620e
--- /dev/null
+++ b/apps/carbon/app/routes/x+/part+/$itemId.parameter.tsx
@@ -0,0 +1,51 @@
+import { assertIsPost } from "@carbon/auth";
+import { requirePermissions } from "@carbon/auth/auth.server";
+import { validator } from "@carbon/form";
+import { json, type ActionFunctionArgs } from "@vercel/remix";
+import {
+ configurationParameterValidator,
+ upsertConfigurationParameter,
+} from "~/modules/items";
+
+export async function action({ request, params }: ActionFunctionArgs) {
+ assertIsPost(request);
+ const { client, companyId, userId } = await requirePermissions(request, {
+ update: "parts",
+ });
+
+ const { itemId } = params;
+ if (!itemId) throw new Error("Could not find itemId");
+
+ const formData = await request.formData();
+ const validation = await validator(configurationParameterValidator).validate(
+ formData
+ );
+
+ if (validation.error) {
+ return json({
+ success: false,
+ error: "Invalid form data",
+ });
+ }
+
+ const { listOptions, ...data } = validation.data;
+
+ const upsert = await upsertConfigurationParameter(client, {
+ ...data,
+ listOptions: data.dataType === "list" ? listOptions : undefined,
+ companyId,
+ userId,
+ });
+
+ if (upsert.error) {
+ console.error(upsert.error);
+ return json({
+ success: false,
+ error: upsert.error.message,
+ });
+ }
+
+ return json({
+ success: true,
+ });
+}
diff --git a/apps/carbon/app/utils/path.ts b/apps/carbon/app/utils/path.ts
index 839c6b27fa..393fd765b3 100644
--- a/apps/carbon/app/utils/path.ts
+++ b/apps/carbon/app/utils/path.ts
@@ -140,6 +140,8 @@ export const path = {
company: `${x}/settings/company`,
companySwitch: (companyId: string) =>
generatePath(`${x}/settings/company/switch/${companyId}`),
+ configurationParameter: (itemId: string) =>
+ generatePath(`${x}/part/${itemId}/parameter`),
contractor: (id: string) =>
generatePath(`${x}/resources/contractors/${id}`),
contractors: `${x}/resources/contractors`,
@@ -222,6 +224,8 @@ export const path = {
generatePath(`${x}/people/attribute/delete/${id}`),
deleteAttributeCategory: (id: string) =>
generatePath(`${x}/people/attributes/delete/${id}`),
+ deleteConfigurationParameter: (itemId: string, id: string) =>
+ generatePath(`${x}/part/${itemId}/parameter/delete/${id}`),
deleteContractor: (id: string) =>
generatePath(`${x}/resources/contractors/delete/${id}`),
deleteCurrency: (id: string) =>
@@ -473,6 +477,7 @@ export const path = {
generatePath(`${x}/people/attributes/list/${id}/new`),
newChartOfAccount: `${x}/accounting/charts/new`,
newCompany: `${x}/settings/company/new`,
+
newConsumable: `${x}/consumable/new`,
newConsumableSupplier: (id: string) =>
generatePath(`${x}/consumable/${id}/purchasing/new`),
diff --git a/packages/database/src/swagger-docs-schema.ts b/packages/database/src/swagger-docs-schema.ts
index 86d8f86499..2b74d76b75 100644
--- a/packages/database/src/swagger-docs-schema.ts
+++ b/packages/database/src/swagger-docs-schema.ts
@@ -2391,6 +2391,213 @@ export default {
tags: ["tag"],
},
},
+ "/configurationParameter": {
+ get: {
+ parameters: [
+ {
+ $ref: "#/parameters/rowFilter.configurationParameter.id",
+ },
+ {
+ $ref: "#/parameters/rowFilter.configurationParameter.itemId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.configurationParameter.label",
+ },
+ {
+ $ref: "#/parameters/rowFilter.configurationParameter.key",
+ },
+ {
+ $ref: "#/parameters/rowFilter.configurationParameter.dataType",
+ },
+ {
+ $ref: "#/parameters/rowFilter.configurationParameter.listOptions",
+ },
+ {
+ $ref: "#/parameters/rowFilter.configurationParameter.configurationParameterGroupId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.configurationParameter.sortOrder",
+ },
+ {
+ $ref: "#/parameters/rowFilter.configurationParameter.companyId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.configurationParameter.createdAt",
+ },
+ {
+ $ref: "#/parameters/rowFilter.configurationParameter.createdBy",
+ },
+ {
+ $ref: "#/parameters/rowFilter.configurationParameter.updatedAt",
+ },
+ {
+ $ref: "#/parameters/rowFilter.configurationParameter.updatedBy",
+ },
+ {
+ $ref: "#/parameters/select",
+ },
+ {
+ $ref: "#/parameters/order",
+ },
+ {
+ $ref: "#/parameters/range",
+ },
+ {
+ $ref: "#/parameters/rangeUnit",
+ },
+ {
+ $ref: "#/parameters/offset",
+ },
+ {
+ $ref: "#/parameters/limit",
+ },
+ {
+ $ref: "#/parameters/preferCount",
+ },
+ ],
+ responses: {
+ "200": {
+ description: "OK",
+ schema: {
+ items: {
+ $ref: "#/definitions/configurationParameter",
+ },
+ type: "array",
+ },
+ },
+ "206": {
+ description: "Partial Content",
+ },
+ },
+ tags: ["configurationParameter"],
+ },
+ post: {
+ parameters: [
+ {
+ $ref: "#/parameters/body.configurationParameter",
+ },
+ {
+ $ref: "#/parameters/select",
+ },
+ {
+ $ref: "#/parameters/preferPost",
+ },
+ ],
+ responses: {
+ "201": {
+ description: "Created",
+ },
+ },
+ tags: ["configurationParameter"],
+ },
+ delete: {
+ parameters: [
+ {
+ $ref: "#/parameters/rowFilter.configurationParameter.id",
+ },
+ {
+ $ref: "#/parameters/rowFilter.configurationParameter.itemId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.configurationParameter.label",
+ },
+ {
+ $ref: "#/parameters/rowFilter.configurationParameter.key",
+ },
+ {
+ $ref: "#/parameters/rowFilter.configurationParameter.dataType",
+ },
+ {
+ $ref: "#/parameters/rowFilter.configurationParameter.listOptions",
+ },
+ {
+ $ref: "#/parameters/rowFilter.configurationParameter.configurationParameterGroupId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.configurationParameter.sortOrder",
+ },
+ {
+ $ref: "#/parameters/rowFilter.configurationParameter.companyId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.configurationParameter.createdAt",
+ },
+ {
+ $ref: "#/parameters/rowFilter.configurationParameter.createdBy",
+ },
+ {
+ $ref: "#/parameters/rowFilter.configurationParameter.updatedAt",
+ },
+ {
+ $ref: "#/parameters/rowFilter.configurationParameter.updatedBy",
+ },
+ {
+ $ref: "#/parameters/preferReturn",
+ },
+ ],
+ responses: {
+ "204": {
+ description: "No Content",
+ },
+ },
+ tags: ["configurationParameter"],
+ },
+ patch: {
+ parameters: [
+ {
+ $ref: "#/parameters/rowFilter.configurationParameter.id",
+ },
+ {
+ $ref: "#/parameters/rowFilter.configurationParameter.itemId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.configurationParameter.label",
+ },
+ {
+ $ref: "#/parameters/rowFilter.configurationParameter.key",
+ },
+ {
+ $ref: "#/parameters/rowFilter.configurationParameter.dataType",
+ },
+ {
+ $ref: "#/parameters/rowFilter.configurationParameter.listOptions",
+ },
+ {
+ $ref: "#/parameters/rowFilter.configurationParameter.configurationParameterGroupId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.configurationParameter.sortOrder",
+ },
+ {
+ $ref: "#/parameters/rowFilter.configurationParameter.companyId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.configurationParameter.createdAt",
+ },
+ {
+ $ref: "#/parameters/rowFilter.configurationParameter.createdBy",
+ },
+ {
+ $ref: "#/parameters/rowFilter.configurationParameter.updatedAt",
+ },
+ {
+ $ref: "#/parameters/rowFilter.configurationParameter.updatedBy",
+ },
+ {
+ $ref: "#/parameters/body.configurationParameter",
+ },
+ {
+ $ref: "#/parameters/preferReturn",
+ },
+ ],
+ responses: {
+ "204": {
+ description: "No Content",
+ },
+ },
+ tags: ["configurationParameter"],
+ },
+ },
"/holiday": {
get: {
parameters: [
@@ -8955,6 +9162,132 @@ export default {
tags: ["supplierQuotes"],
},
},
+ "/configurationParameterGroup": {
+ get: {
+ parameters: [
+ {
+ $ref: "#/parameters/rowFilter.configurationParameterGroup.id",
+ },
+ {
+ $ref: "#/parameters/rowFilter.configurationParameterGroup.itemId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.configurationParameterGroup.name",
+ },
+ {
+ $ref: "#/parameters/rowFilter.configurationParameterGroup.companyId",
+ },
+ {
+ $ref: "#/parameters/select",
+ },
+ {
+ $ref: "#/parameters/order",
+ },
+ {
+ $ref: "#/parameters/range",
+ },
+ {
+ $ref: "#/parameters/rangeUnit",
+ },
+ {
+ $ref: "#/parameters/offset",
+ },
+ {
+ $ref: "#/parameters/limit",
+ },
+ {
+ $ref: "#/parameters/preferCount",
+ },
+ ],
+ responses: {
+ "200": {
+ description: "OK",
+ schema: {
+ items: {
+ $ref: "#/definitions/configurationParameterGroup",
+ },
+ type: "array",
+ },
+ },
+ "206": {
+ description: "Partial Content",
+ },
+ },
+ tags: ["configurationParameterGroup"],
+ },
+ post: {
+ parameters: [
+ {
+ $ref: "#/parameters/body.configurationParameterGroup",
+ },
+ {
+ $ref: "#/parameters/select",
+ },
+ {
+ $ref: "#/parameters/preferPost",
+ },
+ ],
+ responses: {
+ "201": {
+ description: "Created",
+ },
+ },
+ tags: ["configurationParameterGroup"],
+ },
+ delete: {
+ parameters: [
+ {
+ $ref: "#/parameters/rowFilter.configurationParameterGroup.id",
+ },
+ {
+ $ref: "#/parameters/rowFilter.configurationParameterGroup.itemId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.configurationParameterGroup.name",
+ },
+ {
+ $ref: "#/parameters/rowFilter.configurationParameterGroup.companyId",
+ },
+ {
+ $ref: "#/parameters/preferReturn",
+ },
+ ],
+ responses: {
+ "204": {
+ description: "No Content",
+ },
+ },
+ tags: ["configurationParameterGroup"],
+ },
+ patch: {
+ parameters: [
+ {
+ $ref: "#/parameters/rowFilter.configurationParameterGroup.id",
+ },
+ {
+ $ref: "#/parameters/rowFilter.configurationParameterGroup.itemId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.configurationParameterGroup.name",
+ },
+ {
+ $ref: "#/parameters/rowFilter.configurationParameterGroup.companyId",
+ },
+ {
+ $ref: "#/parameters/body.configurationParameterGroup",
+ },
+ {
+ $ref: "#/parameters/preferReturn",
+ },
+ ],
+ responses: {
+ "204": {
+ description: "No Content",
+ },
+ },
+ tags: ["configurationParameterGroup"],
+ },
+ },
"/integration": {
get: {
parameters: [
@@ -15960,132 +16293,6 @@ export default {
tags: ["note"],
},
},
- "/configurationOptionGroup": {
- get: {
- parameters: [
- {
- $ref: "#/parameters/rowFilter.configurationOptionGroup.id",
- },
- {
- $ref: "#/parameters/rowFilter.configurationOptionGroup.itemId",
- },
- {
- $ref: "#/parameters/rowFilter.configurationOptionGroup.name",
- },
- {
- $ref: "#/parameters/rowFilter.configurationOptionGroup.companyId",
- },
- {
- $ref: "#/parameters/select",
- },
- {
- $ref: "#/parameters/order",
- },
- {
- $ref: "#/parameters/range",
- },
- {
- $ref: "#/parameters/rangeUnit",
- },
- {
- $ref: "#/parameters/offset",
- },
- {
- $ref: "#/parameters/limit",
- },
- {
- $ref: "#/parameters/preferCount",
- },
- ],
- responses: {
- "200": {
- description: "OK",
- schema: {
- items: {
- $ref: "#/definitions/configurationOptionGroup",
- },
- type: "array",
- },
- },
- "206": {
- description: "Partial Content",
- },
- },
- tags: ["configurationOptionGroup"],
- },
- post: {
- parameters: [
- {
- $ref: "#/parameters/body.configurationOptionGroup",
- },
- {
- $ref: "#/parameters/select",
- },
- {
- $ref: "#/parameters/preferPost",
- },
- ],
- responses: {
- "201": {
- description: "Created",
- },
- },
- tags: ["configurationOptionGroup"],
- },
- delete: {
- parameters: [
- {
- $ref: "#/parameters/rowFilter.configurationOptionGroup.id",
- },
- {
- $ref: "#/parameters/rowFilter.configurationOptionGroup.itemId",
- },
- {
- $ref: "#/parameters/rowFilter.configurationOptionGroup.name",
- },
- {
- $ref: "#/parameters/rowFilter.configurationOptionGroup.companyId",
- },
- {
- $ref: "#/parameters/preferReturn",
- },
- ],
- responses: {
- "204": {
- description: "No Content",
- },
- },
- tags: ["configurationOptionGroup"],
- },
- patch: {
- parameters: [
- {
- $ref: "#/parameters/rowFilter.configurationOptionGroup.id",
- },
- {
- $ref: "#/parameters/rowFilter.configurationOptionGroup.itemId",
- },
- {
- $ref: "#/parameters/rowFilter.configurationOptionGroup.name",
- },
- {
- $ref: "#/parameters/rowFilter.configurationOptionGroup.companyId",
- },
- {
- $ref: "#/parameters/body.configurationOptionGroup",
- },
- {
- $ref: "#/parameters/preferReturn",
- },
- ],
- responses: {
- "204": {
- description: "No Content",
- },
- },
- tags: ["configurationOptionGroup"],
- },
- },
"/workCenter": {
get: {
parameters: [
@@ -36429,204 +36636,6 @@ export default {
tags: ["supplierProcesses"],
},
},
- "/configurationOption": {
- get: {
- parameters: [
- {
- $ref: "#/parameters/rowFilter.configurationOption.itemId",
- },
- {
- $ref: "#/parameters/rowFilter.configurationOption.key",
- },
- {
- $ref: "#/parameters/rowFilter.configurationOption.label",
- },
- {
- $ref: "#/parameters/rowFilter.configurationOption.dataType",
- },
- {
- $ref: "#/parameters/rowFilter.configurationOption.listOptions",
- },
- {
- $ref: "#/parameters/rowFilter.configurationOption.configurationOptionGroupId",
- },
- {
- $ref: "#/parameters/rowFilter.configurationOption.sortOrder",
- },
- {
- $ref: "#/parameters/rowFilter.configurationOption.companyId",
- },
- {
- $ref: "#/parameters/rowFilter.configurationOption.createdAt",
- },
- {
- $ref: "#/parameters/rowFilter.configurationOption.createdBy",
- },
- {
- $ref: "#/parameters/rowFilter.configurationOption.updatedAt",
- },
- {
- $ref: "#/parameters/rowFilter.configurationOption.updatedBy",
- },
- {
- $ref: "#/parameters/select",
- },
- {
- $ref: "#/parameters/order",
- },
- {
- $ref: "#/parameters/range",
- },
- {
- $ref: "#/parameters/rangeUnit",
- },
- {
- $ref: "#/parameters/offset",
- },
- {
- $ref: "#/parameters/limit",
- },
- {
- $ref: "#/parameters/preferCount",
- },
- ],
- responses: {
- "200": {
- description: "OK",
- schema: {
- items: {
- $ref: "#/definitions/configurationOption",
- },
- type: "array",
- },
- },
- "206": {
- description: "Partial Content",
- },
- },
- tags: ["configurationOption"],
- },
- post: {
- parameters: [
- {
- $ref: "#/parameters/body.configurationOption",
- },
- {
- $ref: "#/parameters/select",
- },
- {
- $ref: "#/parameters/preferPost",
- },
- ],
- responses: {
- "201": {
- description: "Created",
- },
- },
- tags: ["configurationOption"],
- },
- delete: {
- parameters: [
- {
- $ref: "#/parameters/rowFilter.configurationOption.itemId",
- },
- {
- $ref: "#/parameters/rowFilter.configurationOption.key",
- },
- {
- $ref: "#/parameters/rowFilter.configurationOption.label",
- },
- {
- $ref: "#/parameters/rowFilter.configurationOption.dataType",
- },
- {
- $ref: "#/parameters/rowFilter.configurationOption.listOptions",
- },
- {
- $ref: "#/parameters/rowFilter.configurationOption.configurationOptionGroupId",
- },
- {
- $ref: "#/parameters/rowFilter.configurationOption.sortOrder",
- },
- {
- $ref: "#/parameters/rowFilter.configurationOption.companyId",
- },
- {
- $ref: "#/parameters/rowFilter.configurationOption.createdAt",
- },
- {
- $ref: "#/parameters/rowFilter.configurationOption.createdBy",
- },
- {
- $ref: "#/parameters/rowFilter.configurationOption.updatedAt",
- },
- {
- $ref: "#/parameters/rowFilter.configurationOption.updatedBy",
- },
- {
- $ref: "#/parameters/preferReturn",
- },
- ],
- responses: {
- "204": {
- description: "No Content",
- },
- },
- tags: ["configurationOption"],
- },
- patch: {
- parameters: [
- {
- $ref: "#/parameters/rowFilter.configurationOption.itemId",
- },
- {
- $ref: "#/parameters/rowFilter.configurationOption.key",
- },
- {
- $ref: "#/parameters/rowFilter.configurationOption.label",
- },
- {
- $ref: "#/parameters/rowFilter.configurationOption.dataType",
- },
- {
- $ref: "#/parameters/rowFilter.configurationOption.listOptions",
- },
- {
- $ref: "#/parameters/rowFilter.configurationOption.configurationOptionGroupId",
- },
- {
- $ref: "#/parameters/rowFilter.configurationOption.sortOrder",
- },
- {
- $ref: "#/parameters/rowFilter.configurationOption.companyId",
- },
- {
- $ref: "#/parameters/rowFilter.configurationOption.createdAt",
- },
- {
- $ref: "#/parameters/rowFilter.configurationOption.createdBy",
- },
- {
- $ref: "#/parameters/rowFilter.configurationOption.updatedAt",
- },
- {
- $ref: "#/parameters/rowFilter.configurationOption.updatedBy",
- },
- {
- $ref: "#/parameters/body.configurationOption",
- },
- {
- $ref: "#/parameters/preferReturn",
- },
- ],
- responses: {
- "204": {
- description: "No Content",
- },
- },
- tags: ["configurationOption"],
- },
- },
"/postingGroupInventory": {
get: {
parameters: [
@@ -41921,6 +41930,92 @@ export default {
},
type: "object",
},
+ configurationParameter: {
+ required: [
+ "id",
+ "itemId",
+ "label",
+ "key",
+ "dataType",
+ "sortOrder",
+ "companyId",
+ "createdAt",
+ "createdBy",
+ ],
+ properties: {
+ id: {
+ default: "public.xid()",
+ description: "Note:\nThis is a Primary Key.<pk/>",
+ format: "text",
+ type: "string",
+ },
+ itemId: {
+ description:
+ "Note:\nThis is a Foreign Key to `item.id`.<fk table='item' column='id'/>",
+ format: "text",
+ type: "string",
+ },
+ label: {
+ format: "text",
+ type: "string",
+ },
+ key: {
+ format: "text",
+ type: "string",
+ },
+ dataType: {
+ enum: ["text", "numeric", "boolean", "list"],
+ format: 'public."configurationParameterDataType"',
+ type: "string",
+ },
+ listOptions: {
+ format: "text[]",
+ items: {
+ type: "string",
+ },
+ type: "array",
+ },
+ configurationParameterGroupId: {
+ description:
+ "Note:\nThis is a Foreign Key to `configurationParameterGroup.id`.<fk table='configurationParameterGroup' column='id'/>",
+ format: "text",
+ type: "string",
+ },
+ sortOrder: {
+ default: 1,
+ format: "integer",
+ type: "integer",
+ },
+ companyId: {
+ description:
+ "Note:\nThis is a Foreign Key to `company.id`.<fk table='company' column='id'/>",
+ format: "text",
+ type: "string",
+ },
+ createdAt: {
+ default: "now()",
+ format: "timestamp with time zone",
+ type: "string",
+ },
+ createdBy: {
+ description:
+ "Note:\nThis is a Foreign Key to `user.id`.<fk table='user' column='id'/>",
+ format: "text",
+ type: "string",
+ },
+ updatedAt: {
+ format: "timestamp with time zone",
+ type: "string",
+ },
+ updatedBy: {
+ description:
+ "Note:\nThis is a Foreign Key to `user.id`.<fk table='user' column='id'/>",
+ format: "text",
+ type: "string",
+ },
+ },
+ type: "object",
+ },
holiday: {
required: ["id", "name", "date", "companyId", "createdBy", "createdAt"],
properties: {
@@ -45234,6 +45329,34 @@ export default {
},
type: "object",
},
+ configurationParameterGroup: {
+ required: ["id", "itemId", "name", "companyId"],
+ properties: {
+ id: {
+ default: "public.xid()",
+ description: "Note:\nThis is a Primary Key.<pk/>",
+ format: "text",
+ type: "string",
+ },
+ itemId: {
+ description:
+ "Note:\nThis is a Foreign Key to `item.id`.<fk table='item' column='id'/>",
+ format: "text",
+ type: "string",
+ },
+ name: {
+ format: "text",
+ type: "string",
+ },
+ companyId: {
+ description:
+ "Note:\nThis is a Foreign Key to `company.id`.<fk table='company' column='id'/>",
+ format: "text",
+ type: "string",
+ },
+ },
+ type: "object",
+ },
integration: {
required: ["id", "jsonschema"],
properties: {
@@ -48719,34 +48842,6 @@ export default {
},
type: "object",
},
- configurationOptionGroup: {
- required: ["id", "itemId", "name", "companyId"],
- properties: {
- id: {
- default: "public.xid()",
- description: "Note:\nThis is a Primary Key.<pk/>",
- format: "text",
- type: "string",
- },
- itemId: {
- description:
- "Note:\nThis is a Foreign Key to `item.id`.<fk table='item' column='id'/>",
- format: "text",
- type: "string",
- },
- name: {
- format: "text",
- type: "string",
- },
- companyId: {
- description:
- "Note:\nThis is a Foreign Key to `company.id`.<fk table='company' column='id'/>",
- format: "text",
- type: "string",
- },
- },
- type: "object",
- },
workCenter: {
required: [
"id",
@@ -58007,87 +58102,6 @@ export default {
},
type: "object",
},
- configurationOption: {
- required: [
- "itemId",
- "key",
- "label",
- "dataType",
- "configurationOptionGroupId",
- "sortOrder",
- "companyId",
- "createdAt",
- "createdBy",
- ],
- properties: {
- itemId: {
- description:
- "Note:\nThis is a Primary Key.<pk/>\nThis is a Foreign Key to `item.id`.<fk table='item' column='id'/>",
- format: "text",
- type: "string",
- },
- key: {
- description: "Note:\nThis is a Primary Key.<pk/>",
- format: "text",
- type: "string",
- },
- label: {
- format: "text",
- type: "string",
- },
- dataType: {
- enum: ["text", "numeric", "boolean", "list"],
- format: 'public."configurationOptionDataType"',
- type: "string",
- },
- listOptions: {
- format: "text[]",
- items: {
- type: "string",
- },
- type: "array",
- },
- configurationOptionGroupId: {
- description:
- "Note:\nThis is a Foreign Key to `configurationOptionGroup.id`.<fk table='configurationOptionGroup' column='id'/>",
- format: "text",
- type: "string",
- },
- sortOrder: {
- default: 1,
- format: "integer",
- type: "integer",
- },
- companyId: {
- description:
- "Note:\nThis is a Foreign Key to `company.id`.<fk table='company' column='id'/>",
- format: "text",
- type: "string",
- },
- createdAt: {
- default: "now()",
- format: "timestamp with time zone",
- type: "string",
- },
- createdBy: {
- description:
- "Note:\nThis is a Foreign Key to `user.id`.<fk table='user' column='id'/>",
- format: "text",
- type: "string",
- },
- updatedAt: {
- format: "timestamp with time zone",
- type: "string",
- },
- updatedBy: {
- description:
- "Note:\nThis is a Foreign Key to `user.id`.<fk table='user' column='id'/>",
- format: "text",
- type: "string",
- },
- },
- type: "object",
- },
postingGroupInventory: {
required: [
"id",
@@ -60130,6 +60144,106 @@ export default {
in: "query",
type: "string",
},
+ "body.configurationParameter": {
+ name: "configurationParameter",
+ description: "configurationParameter",
+ required: false,
+ in: "body",
+ schema: {
+ $ref: "#/definitions/configurationParameter",
+ },
+ },
+ "rowFilter.configurationParameter.id": {
+ name: "id",
+ required: false,
+ format: "text",
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.configurationParameter.itemId": {
+ name: "itemId",
+ required: false,
+ format: "text",
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.configurationParameter.label": {
+ name: "label",
+ required: false,
+ format: "text",
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.configurationParameter.key": {
+ name: "key",
+ required: false,
+ format: "text",
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.configurationParameter.dataType": {
+ name: "dataType",
+ required: false,
+ format: 'public."configurationParameterDataType"',
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.configurationParameter.listOptions": {
+ name: "listOptions",
+ required: false,
+ format: "text[]",
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.configurationParameter.configurationParameterGroupId": {
+ name: "configurationParameterGroupId",
+ required: false,
+ format: "text",
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.configurationParameter.sortOrder": {
+ name: "sortOrder",
+ required: false,
+ format: "integer",
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.configurationParameter.companyId": {
+ name: "companyId",
+ required: false,
+ format: "text",
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.configurationParameter.createdAt": {
+ name: "createdAt",
+ required: false,
+ format: "timestamp with time zone",
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.configurationParameter.createdBy": {
+ name: "createdBy",
+ required: false,
+ format: "text",
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.configurationParameter.updatedAt": {
+ name: "updatedAt",
+ required: false,
+ format: "timestamp with time zone",
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.configurationParameter.updatedBy": {
+ name: "updatedBy",
+ required: false,
+ format: "text",
+ in: "query",
+ type: "string",
+ },
"body.holiday": {
name: "holiday",
description: "holiday",
@@ -64378,6 +64492,43 @@ export default {
in: "query",
type: "string",
},
+ "body.configurationParameterGroup": {
+ name: "configurationParameterGroup",
+ description: "configurationParameterGroup",
+ required: false,
+ in: "body",
+ schema: {
+ $ref: "#/definitions/configurationParameterGroup",
+ },
+ },
+ "rowFilter.configurationParameterGroup.id": {
+ name: "id",
+ required: false,
+ format: "text",
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.configurationParameterGroup.itemId": {
+ name: "itemId",
+ required: false,
+ format: "text",
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.configurationParameterGroup.name": {
+ name: "name",
+ required: false,
+ format: "text",
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.configurationParameterGroup.companyId": {
+ name: "companyId",
+ required: false,
+ format: "text",
+ in: "query",
+ type: "string",
+ },
"body.integration": {
name: "integration",
description: "integration",
@@ -69067,43 +69218,6 @@ export default {
in: "query",
type: "string",
},
- "body.configurationOptionGroup": {
- name: "configurationOptionGroup",
- description: "configurationOptionGroup",
- required: false,
- in: "body",
- schema: {
- $ref: "#/definitions/configurationOptionGroup",
- },
- },
- "rowFilter.configurationOptionGroup.id": {
- name: "id",
- required: false,
- format: "text",
- in: "query",
- type: "string",
- },
- "rowFilter.configurationOptionGroup.itemId": {
- name: "itemId",
- required: false,
- format: "text",
- in: "query",
- type: "string",
- },
- "rowFilter.configurationOptionGroup.name": {
- name: "name",
- required: false,
- format: "text",
- in: "query",
- type: "string",
- },
- "rowFilter.configurationOptionGroup.companyId": {
- name: "companyId",
- required: false,
- format: "text",
- in: "query",
- type: "string",
- },
"body.workCenter": {
name: "workCenter",
description: "workCenter",
@@ -81173,99 +81287,6 @@ export default {
in: "query",
type: "string",
},
- "body.configurationOption": {
- name: "configurationOption",
- description: "configurationOption",
- required: false,
- in: "body",
- schema: {
- $ref: "#/definitions/configurationOption",
- },
- },
- "rowFilter.configurationOption.itemId": {
- name: "itemId",
- required: false,
- format: "text",
- in: "query",
- type: "string",
- },
- "rowFilter.configurationOption.key": {
- name: "key",
- required: false,
- format: "text",
- in: "query",
- type: "string",
- },
- "rowFilter.configurationOption.label": {
- name: "label",
- required: false,
- format: "text",
- in: "query",
- type: "string",
- },
- "rowFilter.configurationOption.dataType": {
- name: "dataType",
- required: false,
- format: 'public."configurationOptionDataType"',
- in: "query",
- type: "string",
- },
- "rowFilter.configurationOption.listOptions": {
- name: "listOptions",
- required: false,
- format: "text[]",
- in: "query",
- type: "string",
- },
- "rowFilter.configurationOption.configurationOptionGroupId": {
- name: "configurationOptionGroupId",
- required: false,
- format: "text",
- in: "query",
- type: "string",
- },
- "rowFilter.configurationOption.sortOrder": {
- name: "sortOrder",
- required: false,
- format: "integer",
- in: "query",
- type: "string",
- },
- "rowFilter.configurationOption.companyId": {
- name: "companyId",
- required: false,
- format: "text",
- in: "query",
- type: "string",
- },
- "rowFilter.configurationOption.createdAt": {
- name: "createdAt",
- required: false,
- format: "timestamp with time zone",
- in: "query",
- type: "string",
- },
- "rowFilter.configurationOption.createdBy": {
- name: "createdBy",
- required: false,
- format: "text",
- in: "query",
- type: "string",
- },
- "rowFilter.configurationOption.updatedAt": {
- name: "updatedAt",
- required: false,
- format: "timestamp with time zone",
- in: "query",
- type: "string",
- },
- "rowFilter.configurationOption.updatedBy": {
- name: "updatedBy",
- required: false,
- format: "text",
- in: "query",
- type: "string",
- },
"body.postingGroupInventory": {
name: "postingGroupInventory",
description: "postingGroupInventory",
diff --git a/packages/database/src/types.ts b/packages/database/src/types.ts
index 22dba9ccf2..6cf348176d 100644
--- a/packages/database/src/types.ts
+++ b/packages/database/src/types.ts
@@ -1951,13 +1951,14 @@ export type Database = {
},
]
}
- configurationOption: {
+ configurationParameter: {
Row: {
companyId: string
- configurationOptionGroupId: string
+ configurationParameterGroupId: string | null
createdAt: string
createdBy: string
- dataType: Database["public"]["Enums"]["configurationOptionDataType"]
+ dataType: Database["public"]["Enums"]["configurationParameterDataType"]
+ id: string
itemId: string
key: string
label: string
@@ -1968,10 +1969,11 @@ export type Database = {
}
Insert: {
companyId: string
- configurationOptionGroupId: string
+ configurationParameterGroupId?: string | null
createdAt?: string
createdBy: string
- dataType: Database["public"]["Enums"]["configurationOptionDataType"]
+ dataType: Database["public"]["Enums"]["configurationParameterDataType"]
+ id?: string
itemId: string
key: string
label: string
@@ -1982,10 +1984,11 @@ export type Database = {
}
Update: {
companyId?: string
- configurationOptionGroupId?: string
+ configurationParameterGroupId?: string | null
createdAt?: string
createdBy?: string
- dataType?: Database["public"]["Enums"]["configurationOptionDataType"]
+ dataType?: Database["public"]["Enums"]["configurationParameterDataType"]
+ id?: string
itemId?: string
key?: string
label?: string
@@ -1996,112 +1999,112 @@ export type Database = {
}
Relationships: [
{
- foreignKeyName: "configurationOption_companyId_fkey"
+ foreignKeyName: "configurationParameter_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "companies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "configurationOption_companyId_fkey"
+ foreignKeyName: "configurationParameter_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "company"
referencedColumns: ["id"]
},
{
- foreignKeyName: "configurationOption_companyId_fkey"
+ foreignKeyName: "configurationParameter_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "customFieldTables"
referencedColumns: ["companyId"]
},
{
- foreignKeyName: "configurationOption_companyId_fkey"
+ foreignKeyName: "configurationParameter_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "integrations"
referencedColumns: ["companyId"]
},
{
- foreignKeyName: "configurationOption_configurationOptionGroupId_fkey"
- columns: ["configurationOptionGroupId"]
+ foreignKeyName: "configurationParameter_configurationParameterGroupId_fkey"
+ columns: ["configurationParameterGroupId"]
isOneToOne: false
- referencedRelation: "configurationOptionGroup"
+ referencedRelation: "configurationParameterGroup"
referencedColumns: ["id"]
},
{
- foreignKeyName: "configurationOption_createdBy_fkey"
+ foreignKeyName: "configurationParameter_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "employees"
referencedColumns: ["id"]
},
{
- foreignKeyName: "configurationOption_createdBy_fkey"
+ foreignKeyName: "configurationParameter_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "employeesAcrossCompanies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "configurationOption_createdBy_fkey"
+ foreignKeyName: "configurationParameter_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "employeeSummary"
referencedColumns: ["id"]
},
{
- foreignKeyName: "configurationOption_createdBy_fkey"
+ foreignKeyName: "configurationParameter_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "user"
referencedColumns: ["id"]
},
{
- foreignKeyName: "configurationOption_createdBy_fkey"
+ foreignKeyName: "configurationParameter_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
{
- foreignKeyName: "configurationOption_itemId_fkey"
+ foreignKeyName: "configurationParameter_itemId_fkey"
columns: ["itemId"]
isOneToOne: false
referencedRelation: "item"
referencedColumns: ["id"]
},
{
- foreignKeyName: "configurationOption_updatedBy_fkey"
+ foreignKeyName: "configurationParameter_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employees"
referencedColumns: ["id"]
},
{
- foreignKeyName: "configurationOption_updatedBy_fkey"
+ foreignKeyName: "configurationParameter_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employeesAcrossCompanies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "configurationOption_updatedBy_fkey"
+ foreignKeyName: "configurationParameter_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employeeSummary"
referencedColumns: ["id"]
},
{
- foreignKeyName: "configurationOption_updatedBy_fkey"
+ foreignKeyName: "configurationParameter_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "user"
referencedColumns: ["id"]
},
{
- foreignKeyName: "configurationOption_updatedBy_fkey"
+ foreignKeyName: "configurationParameter_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "userDefaults"
@@ -2109,7 +2112,7 @@ export type Database = {
},
]
}
- configurationOptionGroup: {
+ configurationParameterGroup: {
Row: {
companyId: string
id: string
@@ -2130,35 +2133,35 @@ export type Database = {
}
Relationships: [
{
- foreignKeyName: "configurationOptionGroup_companyId_fkey"
+ foreignKeyName: "configurationParameterGroup_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "companies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "configurationOptionGroup_companyId_fkey"
+ foreignKeyName: "configurationParameterGroup_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "company"
referencedColumns: ["id"]
},
{
- foreignKeyName: "configurationOptionGroup_companyId_fkey"
+ foreignKeyName: "configurationParameterGroup_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "customFieldTables"
referencedColumns: ["companyId"]
},
{
- foreignKeyName: "configurationOptionGroup_companyId_fkey"
+ foreignKeyName: "configurationParameterGroup_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "integrations"
referencedColumns: ["companyId"]
},
{
- foreignKeyName: "configurationOptionGroup_itemId_fkey"
+ foreignKeyName: "configurationParameterGroup_itemId_fkey"
columns: ["itemId"]
isOneToOne: false
referencedRelation: "item"
@@ -32393,7 +32396,7 @@ export type Database = {
}
Enums: {
accountingPeriodStatus: "Inactive" | "Active"
- configurationOptionDataType: "text" | "numeric" | "boolean" | "list"
+ configurationParameterDataType: "text" | "numeric" | "boolean" | "list"
costLedgerType:
| "Direct Cost"
| "Revaluation"
diff --git a/packages/database/supabase/functions/lib/types.ts b/packages/database/supabase/functions/lib/types.ts
index 22dba9ccf2..6cf348176d 100644
--- a/packages/database/supabase/functions/lib/types.ts
+++ b/packages/database/supabase/functions/lib/types.ts
@@ -1951,13 +1951,14 @@ export type Database = {
},
]
}
- configurationOption: {
+ configurationParameter: {
Row: {
companyId: string
- configurationOptionGroupId: string
+ configurationParameterGroupId: string | null
createdAt: string
createdBy: string
- dataType: Database["public"]["Enums"]["configurationOptionDataType"]
+ dataType: Database["public"]["Enums"]["configurationParameterDataType"]
+ id: string
itemId: string
key: string
label: string
@@ -1968,10 +1969,11 @@ export type Database = {
}
Insert: {
companyId: string
- configurationOptionGroupId: string
+ configurationParameterGroupId?: string | null
createdAt?: string
createdBy: string
- dataType: Database["public"]["Enums"]["configurationOptionDataType"]
+ dataType: Database["public"]["Enums"]["configurationParameterDataType"]
+ id?: string
itemId: string
key: string
label: string
@@ -1982,10 +1984,11 @@ export type Database = {
}
Update: {
companyId?: string
- configurationOptionGroupId?: string
+ configurationParameterGroupId?: string | null
createdAt?: string
createdBy?: string
- dataType?: Database["public"]["Enums"]["configurationOptionDataType"]
+ dataType?: Database["public"]["Enums"]["configurationParameterDataType"]
+ id?: string
itemId?: string
key?: string
label?: string
@@ -1996,112 +1999,112 @@ export type Database = {
}
Relationships: [
{
- foreignKeyName: "configurationOption_companyId_fkey"
+ foreignKeyName: "configurationParameter_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "companies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "configurationOption_companyId_fkey"
+ foreignKeyName: "configurationParameter_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "company"
referencedColumns: ["id"]
},
{
- foreignKeyName: "configurationOption_companyId_fkey"
+ foreignKeyName: "configurationParameter_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "customFieldTables"
referencedColumns: ["companyId"]
},
{
- foreignKeyName: "configurationOption_companyId_fkey"
+ foreignKeyName: "configurationParameter_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "integrations"
referencedColumns: ["companyId"]
},
{
- foreignKeyName: "configurationOption_configurationOptionGroupId_fkey"
- columns: ["configurationOptionGroupId"]
+ foreignKeyName: "configurationParameter_configurationParameterGroupId_fkey"
+ columns: ["configurationParameterGroupId"]
isOneToOne: false
- referencedRelation: "configurationOptionGroup"
+ referencedRelation: "configurationParameterGroup"
referencedColumns: ["id"]
},
{
- foreignKeyName: "configurationOption_createdBy_fkey"
+ foreignKeyName: "configurationParameter_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "employees"
referencedColumns: ["id"]
},
{
- foreignKeyName: "configurationOption_createdBy_fkey"
+ foreignKeyName: "configurationParameter_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "employeesAcrossCompanies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "configurationOption_createdBy_fkey"
+ foreignKeyName: "configurationParameter_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "employeeSummary"
referencedColumns: ["id"]
},
{
- foreignKeyName: "configurationOption_createdBy_fkey"
+ foreignKeyName: "configurationParameter_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "user"
referencedColumns: ["id"]
},
{
- foreignKeyName: "configurationOption_createdBy_fkey"
+ foreignKeyName: "configurationParameter_createdBy_fkey"
columns: ["createdBy"]
isOneToOne: false
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
{
- foreignKeyName: "configurationOption_itemId_fkey"
+ foreignKeyName: "configurationParameter_itemId_fkey"
columns: ["itemId"]
isOneToOne: false
referencedRelation: "item"
referencedColumns: ["id"]
},
{
- foreignKeyName: "configurationOption_updatedBy_fkey"
+ foreignKeyName: "configurationParameter_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employees"
referencedColumns: ["id"]
},
{
- foreignKeyName: "configurationOption_updatedBy_fkey"
+ foreignKeyName: "configurationParameter_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employeesAcrossCompanies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "configurationOption_updatedBy_fkey"
+ foreignKeyName: "configurationParameter_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "employeeSummary"
referencedColumns: ["id"]
},
{
- foreignKeyName: "configurationOption_updatedBy_fkey"
+ foreignKeyName: "configurationParameter_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "user"
referencedColumns: ["id"]
},
{
- foreignKeyName: "configurationOption_updatedBy_fkey"
+ foreignKeyName: "configurationParameter_updatedBy_fkey"
columns: ["updatedBy"]
isOneToOne: false
referencedRelation: "userDefaults"
@@ -2109,7 +2112,7 @@ export type Database = {
},
]
}
- configurationOptionGroup: {
+ configurationParameterGroup: {
Row: {
companyId: string
id: string
@@ -2130,35 +2133,35 @@ export type Database = {
}
Relationships: [
{
- foreignKeyName: "configurationOptionGroup_companyId_fkey"
+ foreignKeyName: "configurationParameterGroup_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "companies"
referencedColumns: ["id"]
},
{
- foreignKeyName: "configurationOptionGroup_companyId_fkey"
+ foreignKeyName: "configurationParameterGroup_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "company"
referencedColumns: ["id"]
},
{
- foreignKeyName: "configurationOptionGroup_companyId_fkey"
+ foreignKeyName: "configurationParameterGroup_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "customFieldTables"
referencedColumns: ["companyId"]
},
{
- foreignKeyName: "configurationOptionGroup_companyId_fkey"
+ foreignKeyName: "configurationParameterGroup_companyId_fkey"
columns: ["companyId"]
isOneToOne: false
referencedRelation: "integrations"
referencedColumns: ["companyId"]
},
{
- foreignKeyName: "configurationOptionGroup_itemId_fkey"
+ foreignKeyName: "configurationParameterGroup_itemId_fkey"
columns: ["itemId"]
isOneToOne: false
referencedRelation: "item"
@@ -32393,7 +32396,7 @@ export type Database = {
}
Enums: {
accountingPeriodStatus: "Inactive" | "Active"
- configurationOptionDataType: "text" | "numeric" | "boolean" | "list"
+ configurationParameterDataType: "text" | "numeric" | "boolean" | "list"
costLedgerType:
| "Direct Cost"
| "Revaluation"
diff --git a/packages/database/supabase/migrations/20241217184843_configuration-options.sql b/packages/database/supabase/migrations/20241217184843_configuration-options.sql
index 88a0c96312..706104563f 100644
--- a/packages/database/supabase/migrations/20241217184843_configuration-options.sql
+++ b/packages/database/supabase/migrations/20241217184843_configuration-options.sql
@@ -1,21 +1,22 @@
-CREATE TABLE IF NOT EXISTS "configurationOptionGroup" (
+CREATE TABLE IF NOT EXISTS "configurationParameterGroup" (
"id" TEXT NOT NULL DEFAULT xid(),
"itemId" TEXT NOT NULL,
"name" TEXT NOT NULL,
"companyId" TEXT NOT NULL,
- CONSTRAINT "configurationOptionGroup_pkey" PRIMARY KEY ("id"),
- CONSTRAINT "configurationOptionGroup_itemId_fkey" FOREIGN KEY ("itemId") REFERENCES "item"("id"),
- CONSTRAINT "configurationOptionGroup_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "company"("id")
+ CONSTRAINT "configurationParameterGroup_pkey" PRIMARY KEY ("id"),
+ CONSTRAINT "configurationParameterGroup_itemId_fkey" FOREIGN KEY ("itemId") REFERENCES "item"("id"),
+ CONSTRAINT "configurationParameterGroup_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "company"("id")
);
-CREATE TYPE "configurationOptionDataType" AS ENUM ('text', 'numeric', 'boolean', 'list');
-CREATE TABLE IF NOT EXISTS "configurationOption" (
+CREATE TYPE "configurationParameterDataType" AS ENUM ('text', 'numeric', 'boolean', 'list');
+CREATE TABLE IF NOT EXISTS "configurationParameter" (
+ "id" TEXT NOT NULL DEFAULT xid(),
"itemId" TEXT NOT NULL,
- "key" TEXT NOT NULL,
"label" TEXT NOT NULL,
- "dataType" "configurationOptionDataType" NOT NULL,
+ "key" TEXT NOT NULL,
+ "dataType" "configurationParameterDataType" NOT NULL,
"listOptions" TEXT[],
- "configurationOptionGroupId" TEXT NOT NULL,
+ "configurationParameterGroupId" TEXT,
"sortOrder" INTEGER NOT NULL DEFAULT 1,
"companyId" TEXT NOT NULL,
"createdAt" TIMESTAMP WITH TIME ZONE DEFAULT NOW() NOT NULL,
@@ -23,49 +24,49 @@ CREATE TABLE IF NOT EXISTS "configurationOption" (
"updatedAt" TIMESTAMP WITH TIME ZONE,
"updatedBy" TEXT,
- CONSTRAINT "configurationOption_pkey" PRIMARY KEY ("itemId", "key"),
- CONSTRAINT "configurationOption_itemId_label_key" UNIQUE ("itemId", "label"),
- CONSTRAINT "configurationOption_itemId_fkey" FOREIGN KEY ("itemId") REFERENCES "item"("id") ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT "configurationOption_configurationOptionGroupId_fkey" FOREIGN KEY ("configurationOptionGroupId") REFERENCES "configurationOptionGroup"("id") ON DELETE SET NULL ON UPDATE CASCADE,
- CONSTRAINT "configurationOption_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "company"("id") ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT "configurationOption_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user"("id") ON UPDATE CASCADE,
- CONSTRAINT "configurationOption_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user"("id") ON UPDATE CASCADE
+ CONSTRAINT "configurationParameter_pkey" PRIMARY KEY ("id"),
+ CONSTRAINT "configurationParameter_itemId_key_unique" UNIQUE ("itemId", "key"),
+ CONSTRAINT "configurationParameter_itemId_fkey" FOREIGN KEY ("itemId") REFERENCES "item"("id") ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT "configurationParameter_configurationParameterGroupId_fkey" FOREIGN KEY ("configurationParameterGroupId") REFERENCES "configurationParameterGroup"("id") ON DELETE SET NULL ON UPDATE CASCADE,
+ CONSTRAINT "configurationParameter_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "company"("id") ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT "configurationParameter_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user"("id") ON UPDATE CASCADE,
+ CONSTRAINT "configurationParameter_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user"("id") ON UPDATE CASCADE
);
-CREATE INDEX "configurationOption_itemId_idx" ON "configurationOption" ("itemId");
-CREATE INDEX "configurationOption_companyId_idx" ON "configurationOption" ("companyId");
+CREATE INDEX "configurationParameter_itemId_idx" ON "configurationParameter" ("itemId");
+CREATE INDEX "configurationParameter_companyId_idx" ON "configurationParameter" ("companyId");
-ALTER TABLE "configurationOption" ENABLE ROW LEVEL SECURITY;
+ALTER TABLE "configurationParameter" ENABLE ROW LEVEL SECURITY;
-CREATE POLICY "Employees with parts_view can view configuration options" ON "configurationOption"
+CREATE POLICY "Employees with parts_view can view configuration options" ON "configurationParameter"
FOR SELECT
USING (
has_role('employee', "companyId") AND
has_company_permission('parts_view', "companyId")
);
-CREATE POLICY "Employees with parts_create can insert configuration options" ON "configurationOption"
+CREATE POLICY "Employees with parts_create can insert configuration options" ON "configurationParameter"
FOR INSERT
WITH CHECK (
has_role('employee', "companyId") AND
has_company_permission('parts_create', "companyId")
);
-CREATE POLICY "Employees with parts_update can update configuration options" ON "configurationOption"
+CREATE POLICY "Employees with parts_update can update configuration options" ON "configurationParameter"
FOR UPDATE
USING (
has_role('employee', "companyId") AND
has_company_permission('parts_update', "companyId")
);
-CREATE POLICY "Employees with parts_delete can delete configuration options" ON "configurationOption"
+CREATE POLICY "Employees with parts_delete can delete configuration options" ON "configurationParameter"
FOR DELETE
USING (
has_role('employee', "companyId") AND
has_company_permission('parts_delete', "companyId")
);
-CREATE POLICY "Requests with an API key can access configuration options" ON "configurationOption"
+CREATE POLICY "Requests with an API key can access configuration options" ON "configurationParameter"
FOR ALL USING (
has_valid_api_key_for_company("companyId")
);