@1c-odata/cli
v0.6.0
Published
CLI for @1c-odata/client: fetch 1С EDMX metadata and generate TypeScript types.
Downloads
773
Maintainers
Readme
@1c-odata/cli
Two binaries for @1c-odata/client:
1c-odata fetch— downloads$metadata(EDMX) from a 1С:Enterprise OData V3 endpoint and saves it locally.1c-odata generate— generates TypeScript types from the saved EDMX (per-target output undergenerated/<target>/).
Codegen library is also exposed at @1c-odata/cli/codegen for programmatic use.
Pure ESM. Node ≥ 22.21.0.
⚠️ v0.x — pre-release. API is unstable; see STABILITY.md.
Install
pnpm add -D @1c-odata/cli @1c-odata/clientQuick start
1c-odata.config.ts:
import { parseConnectionUrl } from '@1c-odata/client'
import { defineCodegenConfig } from '@1c-odata/cli'
const url = process.env.ONEC_URL
if (!url) throw new Error('Set ONEC_URL (format: http://user:pwd@host/path)')
export default defineCodegenConfig({
targets: {
trade: {
connection: {
...parseConnectionUrl(url),
serverTimezone: 'Europe/Moscow',
},
include: ['Catalog_*', 'Document_*'],
},
},
})Fetch + generate:
export ONEC_URL=http://u:[email protected]/odata/standard.odata
pnpm 1c-odata fetch
pnpm 1c-odata generateloadConfig auto-sources .env then .env.local (relative to cwd) before evaluating 1c-odata.config.ts, so process.env.ONEC_URL resolves at config-eval time without a manual export.
Commands & flags
Both commands default to all targets; pass -t to pick one.
| Command | Flags |
|---|---|
| 1c-odata fetch | -t, --target <name>, --config <path> |
| 1c-odata generate | -t, --target <name>, --config <path>, -f, --force (regenerate even when inputs are unchanged), --metadata-only (emit only __metadata.json; skips TS generation — existing .ts files are left untouched) |
Config options
defineCodegenConfig accepts, alongside targets:
| Option | Default | Purpose |
|---|---|---|
| metadataDir | ./metadata | where <target>.xml snapshots are written / read |
| generatedDir | ./generated | where generated TS lands (<target>/<kind>/<Name>.ts) |
| fetchTimeout | 120_000 | 1c-odata fetch timeout in ms (per-target override available) |
Each target is { connection, include?, fetchTimeout? } — include is a glob whitelist of entity-type names (Catalog_*), and the dependency closure auto-expands.
Programmatic use
runFetch / runGenerate / loadConfig are exported from @1c-odata/cli (and generate from @1c-odata/cli/codegen) for scripting the pipeline without the bin.
See the repo README for project-wide setup and examples/basic for a runnable consumer.
