feat(05-01): enrich BACKEND_REGISTRY and update all consumers
- Change BACKEND_REGISTRY shape from Record<BackendType, FieldDef[]> to
Record<BackendType, { displayName, description, fields: FieldDef[] }>
- Add displayName and description to azureblob, s3, s3-compatible entries
- Update schemas/index.ts buildZodSchema to use .fields access
- Update RemoteConfigStep.tsx two .fields accesses (azureblob.find + map)
This commit is contained in:
@@ -55,7 +55,7 @@ export function RemoteConfigStep() {
|
||||
<>
|
||||
{/* Account field via FieldRenderer */}
|
||||
<FieldRenderer
|
||||
field={BACKEND_REGISTRY.azureblob.find(f => f.key === 'account')!}
|
||||
field={BACKEND_REGISTRY.azureblob.fields.find(f => f.key === 'account')!}
|
||||
register={register}
|
||||
error={errors.account as FieldError | undefined}
|
||||
/>
|
||||
@@ -70,7 +70,7 @@ export function RemoteConfigStep() {
|
||||
</>
|
||||
) : (
|
||||
/* S3 and S3-compatible: full registry loop — FieldRenderer handles provider hiding */
|
||||
BACKEND_REGISTRY[backendType].map(field => (
|
||||
BACKEND_REGISTRY[backendType].fields.map(field => (
|
||||
<FieldRenderer
|
||||
key={field.key}
|
||||
field={field}
|
||||
|
||||
@@ -7,7 +7,7 @@ import { z } from 'zod';
|
||||
import { BACKEND_REGISTRY, BackendType } from './registry';
|
||||
|
||||
function buildZodSchema(backendType: BackendType): z.ZodObject<Record<string, z.ZodTypeAny>> {
|
||||
const fields = BACKEND_REGISTRY[backendType];
|
||||
const fields = BACKEND_REGISTRY[backendType].fields;
|
||||
const shape: Record<string, z.ZodTypeAny> = {};
|
||||
for (const field of fields) {
|
||||
shape[field.key] = field.required
|
||||
|
||||
+109
-93
@@ -16,97 +16,113 @@ export interface FieldDef {
|
||||
options?: { value: string; label: string }[]; // for inputType: 'select'
|
||||
}
|
||||
|
||||
export const BACKEND_REGISTRY: Record<BackendType, FieldDef[]> = {
|
||||
azureblob: [
|
||||
{
|
||||
key: 'account',
|
||||
label: 'Storage Account Name',
|
||||
inputType: 'text',
|
||||
required: true,
|
||||
placeholder: 'mystorageaccount',
|
||||
helpText: 'The storage account name (not the full URL)',
|
||||
},
|
||||
{
|
||||
key: 'key',
|
||||
label: 'Access Key',
|
||||
inputType: 'password',
|
||||
required: false,
|
||||
helpText: 'Base64-encoded storage account key. Provide either this or a SAS URL, not both.',
|
||||
},
|
||||
{
|
||||
key: 'sas_url',
|
||||
label: 'SAS URL',
|
||||
inputType: 'password',
|
||||
required: false,
|
||||
placeholder: 'https://mystorageaccount.blob.core.windows.net/?sv=...',
|
||||
helpText: 'Full SAS URL including account and container. Provide either this or an access key, not both.',
|
||||
},
|
||||
],
|
||||
s3: [
|
||||
{
|
||||
key: 'provider',
|
||||
label: 'Provider',
|
||||
inputType: 'select',
|
||||
required: true,
|
||||
options: [{ value: 'AWS', label: 'Amazon S3' }],
|
||||
},
|
||||
{
|
||||
key: 'access_key_id',
|
||||
label: 'Access Key ID',
|
||||
inputType: 'text',
|
||||
required: true,
|
||||
placeholder: 'AKIAIOSFODNN7EXAMPLE',
|
||||
},
|
||||
{
|
||||
key: 'secret_access_key',
|
||||
label: 'Secret Access Key',
|
||||
inputType: 'password',
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
key: 'region',
|
||||
label: 'Region',
|
||||
inputType: 'text',
|
||||
required: true,
|
||||
placeholder: 'us-east-1',
|
||||
},
|
||||
],
|
||||
's3-compatible': [
|
||||
{
|
||||
key: 'provider',
|
||||
label: 'Provider',
|
||||
inputType: 'select',
|
||||
required: true,
|
||||
options: [{ value: 'Other', label: 'S3-Compatible' }],
|
||||
helpText: 'Covers Wasabi, MinIO, Cloudflare R2, and any S3-compatible storage',
|
||||
},
|
||||
{
|
||||
key: 'access_key_id',
|
||||
label: 'Access Key ID',
|
||||
inputType: 'text',
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
key: 'secret_access_key',
|
||||
label: 'Secret Access Key',
|
||||
inputType: 'password',
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
key: 'endpoint',
|
||||
label: 'Endpoint URL',
|
||||
inputType: 'text',
|
||||
required: true,
|
||||
placeholder: 'https://s3.wasabisys.com',
|
||||
helpText: 'The S3-compatible endpoint URL for your storage provider',
|
||||
},
|
||||
{
|
||||
key: 'region',
|
||||
label: 'Region',
|
||||
inputType: 'text',
|
||||
required: false,
|
||||
placeholder: 'us-east-1',
|
||||
helpText: 'Optional for most S3-compatible providers',
|
||||
},
|
||||
],
|
||||
export const BACKEND_REGISTRY: Record<BackendType, {
|
||||
displayName: string;
|
||||
description: string;
|
||||
fields: FieldDef[];
|
||||
}> = {
|
||||
azureblob: {
|
||||
displayName: 'Azure Blob Storage',
|
||||
description: 'Microsoft Azure cloud storage',
|
||||
fields: [
|
||||
{
|
||||
key: 'account',
|
||||
label: 'Storage Account Name',
|
||||
inputType: 'text',
|
||||
required: true,
|
||||
placeholder: 'mystorageaccount',
|
||||
helpText: 'The storage account name (not the full URL)',
|
||||
},
|
||||
{
|
||||
key: 'key',
|
||||
label: 'Access Key',
|
||||
inputType: 'password',
|
||||
required: false,
|
||||
helpText: 'Base64-encoded storage account key. Provide either this or a SAS URL, not both.',
|
||||
},
|
||||
{
|
||||
key: 'sas_url',
|
||||
label: 'SAS URL',
|
||||
inputType: 'password',
|
||||
required: false,
|
||||
placeholder: 'https://mystorageaccount.blob.core.windows.net/?sv=...',
|
||||
helpText: 'Full SAS URL including account and container. Provide either this or an access key, not both.',
|
||||
},
|
||||
],
|
||||
},
|
||||
s3: {
|
||||
displayName: 'Amazon S3',
|
||||
description: 'AWS Simple Storage Service',
|
||||
fields: [
|
||||
{
|
||||
key: 'provider',
|
||||
label: 'Provider',
|
||||
inputType: 'select',
|
||||
required: true,
|
||||
options: [{ value: 'AWS', label: 'Amazon S3' }],
|
||||
},
|
||||
{
|
||||
key: 'access_key_id',
|
||||
label: 'Access Key ID',
|
||||
inputType: 'text',
|
||||
required: true,
|
||||
placeholder: 'AKIAIOSFODNN7EXAMPLE',
|
||||
},
|
||||
{
|
||||
key: 'secret_access_key',
|
||||
label: 'Secret Access Key',
|
||||
inputType: 'password',
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
key: 'region',
|
||||
label: 'Region',
|
||||
inputType: 'text',
|
||||
required: true,
|
||||
placeholder: 'us-east-1',
|
||||
},
|
||||
],
|
||||
},
|
||||
's3-compatible': {
|
||||
displayName: 'S3-Compatible',
|
||||
description: 'Wasabi, MinIO, Cloudflare R2, and others',
|
||||
fields: [
|
||||
{
|
||||
key: 'provider',
|
||||
label: 'Provider',
|
||||
inputType: 'select',
|
||||
required: true,
|
||||
options: [{ value: 'Other', label: 'S3-Compatible' }],
|
||||
helpText: 'Covers Wasabi, MinIO, Cloudflare R2, and any S3-compatible storage',
|
||||
},
|
||||
{
|
||||
key: 'access_key_id',
|
||||
label: 'Access Key ID',
|
||||
inputType: 'text',
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
key: 'secret_access_key',
|
||||
label: 'Secret Access Key',
|
||||
inputType: 'password',
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
key: 'endpoint',
|
||||
label: 'Endpoint URL',
|
||||
inputType: 'text',
|
||||
required: true,
|
||||
placeholder: 'https://s3.wasabisys.com',
|
||||
helpText: 'The S3-compatible endpoint URL for your storage provider',
|
||||
},
|
||||
{
|
||||
key: 'region',
|
||||
label: 'Region',
|
||||
inputType: 'text',
|
||||
required: false,
|
||||
placeholder: 'us-east-1',
|
||||
helpText: 'Optional for most S3-compatible providers',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user