| 123456789101112131415161718192021222324252627 |
- import 'dotenv/config';
- import { resolve } from 'node:path';
- import { loadConfig } from '../src/config/env.js';
- import { ParseRestClient } from '../src/db/parse-rest.client.js';
- import { ensureVocParseSchemas } from '../src/db/parse-rest.schema.js';
- import { normalizeDemashiWorkbook } from '../src/modules/domestic-voc/importers/demashi-workbook.js';
- import { ParseRestDatasetImportService } from '../src/modules/domestic-voc/services/parse-rest-dataset-import.service.js';
- const inputPath = process.argv[2];
- if (!inputPath) throw new Error('Usage: npm run import:workbook:parse-rest -- <workbook.xlsx> [workspaceId]');
- const config = loadConfig();
- if (config.storageDriver !== 'parse_rest') throw new Error('STORAGE_DRIVER must be parse_rest');
- const workspaceId = process.argv[3] || config.auth.defaultWorkspaceId;
- const client = new ParseRestClient({
- serverUrl: config.parse.serverUrl,
- appId: config.parse.appId,
- masterKey: config.parse.masterKey,
- timeoutMs: config.parse.timeoutMs,
- });
- const dataset = await normalizeDemashiWorkbook(resolve(inputPath));
- await ensureVocParseSchemas(client);
- const imported = await new ParseRestDatasetImportService(client).import(dataset, workspaceId, {
- userId: config.auth.localUserId,
- email: config.auth.localUserEmail,
- displayName: config.auth.localUserName,
- });
- console.log(JSON.stringify({ source: dataset.source, summary: dataset.summary, imported }, null, 2));
|