feat(01-02): create Backend Schema Registry with rclone-compatible field definitions

- BackendType union: 'azureblob' | 's3' | 's3-compatible'
- FieldDef interface with key (snake_case rclone key), label, inputType, required, and optional fields
- BACKEND_REGISTRY: azureblob (3 fields), s3 (4 fields), s3-compatible (5 fields)
- All FieldDef.key values match rclone INI config key names exactly
- registry.test.ts: 7 tests all passing (GREEN)
This commit is contained in:
2026-03-26 10:16:49 +01:00
parent 1aebceae55
commit 4c614fc06c
2 changed files with 167 additions and 0 deletions
+55
View File
@@ -0,0 +1,55 @@
import { describe, it, expect } from 'vitest';
import { BACKEND_REGISTRY, BackendType } from './registry';
const EXPECTED_BACKENDS: BackendType[] = ['azureblob', 's3', 's3-compatible'];
describe('Backend Schema Registry', () => {
it('exports all three required backend types', () => {
for (const backend of EXPECTED_BACKENDS) {
expect(BACKEND_REGISTRY[backend]).toBeDefined();
}
});
it('each backend has at least one field definition', () => {
for (const backend of EXPECTED_BACKENDS) {
expect(BACKEND_REGISTRY[backend].length).toBeGreaterThan(0);
}
});
it('each FieldDef has a non-empty key (snake_case, no camelCase)', () => {
for (const backend of EXPECTED_BACKENDS) {
for (const field of BACKEND_REGISTRY[backend]) {
expect(field.key).toBeTruthy();
// Reject camelCase — rclone keys are snake_case or lowercase
expect(field.key).not.toMatch(/[A-Z]/);
}
}
});
it('each FieldDef has a non-empty label', () => {
for (const backend of EXPECTED_BACKENDS) {
for (const field of BACKEND_REGISTRY[backend]) {
expect(field.label).toBeTruthy();
}
}
});
it('Azure Blob has account field (required)', () => {
const accountField = BACKEND_REGISTRY.azureblob.find(f => f.key === 'account');
expect(accountField).toBeDefined();
expect(accountField!.required).toBe(true);
});
it('S3 has access_key_id, secret_access_key, and region fields', () => {
const keys = BACKEND_REGISTRY.s3.map(f => f.key);
expect(keys).toContain('access_key_id');
expect(keys).toContain('secret_access_key');
expect(keys).toContain('region');
});
it('S3-compatible has endpoint field (required)', () => {
const endpointField = BACKEND_REGISTRY['s3-compatible'].find(f => f.key === 'endpoint');
expect(endpointField).toBeDefined();
expect(endpointField!.required).toBe(true);
});
});