@companyio/import-export
v0.2.0
Published
Universal import/export engine for multi-tenant CompanyIO products
Readme
@companyio/import-export
Universal import/export engine for CompanyIO hosts and packages.
Contacts / Catalog / Fuel / …
↓ registerSchema(schema, handlers)
@companyio/import-export
↓ preview / validate / apply / export
JobsPort (@companyio/jobs) → async import + CSV/JSON exportSchemas are opaque. This package never imports vertical types.
Install
pnpm add @companyio/import-exportUsage
import {
createImportExport,
platformSampleImportSchema,
createPlatformSampleHandlers,
} from '@companyio/import-export';
const io = createImportExport({ getContext, jobs });
io.registerSchema(platformSampleImportSchema, createPlatformSampleHandlers());
await io.importExport.preview(ctx, 'platform.sample-contacts', rows);
await io.importExport.apply(ctx, 'platform.sample-contacts', rows, {
idempotencyKey: 'upload-1',
});Host routes (attachImportExport)
| Method | Path | Purpose |
| ------ | ------------------------------------------- | ------------------------------------------- |
| GET | /api/v1/import-export | List schemas |
| GET | /api/v1/import-export/:id | Schema metadata |
| POST | /api/v1/import-export/:id/preview | Preview + errors |
| POST | /api/v1/import-export/:id/validate | Validate (alias of preview) |
| POST | /api/v1/import-export/:id/import | Apply (dryRun, async, idempotencyKey) |
| POST | /api/v1/import-export/:id/export | Export CSV/JSON (async) |
| GET | /api/v1/import-export/jobs/:jobId | Job history |
| GET | /api/v1/import-export/exports/:artifactId | Export artifact |
Boundaries
| Owns | Does not own | | ----------------------------------------------- | ------------------------------------ | | Schema registry, CSV/JSON parse, preview/apply | Vertical persistence / domain models | | Idempotency + partial failure reporting | Excel/PDF (later) | | Job history + export artifacts (memory default) | Durable object storage |
See DEVELOPER_GUIDE.md.
