| 1234567891011121314151617181920212223242526272829303132 |
- import 'dotenv/config';
- import { readFile } from 'node:fs/promises';
- 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 { ParseRestDatasetImportService } from '../src/modules/domestic-voc/services/parse-rest-dataset-import.service.js';
- import type { ImportDataset } from '../src/modules/domestic-voc/services/dataset-import.service.js';
- const inputPath = process.argv[2];
- if (!inputPath) throw new Error('Usage: npm run bootstrap:parse-rest -- <dataset.json> [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 dataset = JSON.parse(await readFile(resolve(inputPath), 'utf8')) as ImportDataset;
- const client = new ParseRestClient({
- serverUrl: config.parse.serverUrl,
- appId: config.parse.appId,
- masterKey: config.parse.masterKey,
- timeoutMs: config.parse.timeoutMs,
- });
- const schema = await ensureVocParseSchemas(client);
- const importer = new ParseRestDatasetImportService(client);
- const imported = await importer.import(dataset, workspaceId, {
- userId: config.auth.localUserId,
- email: config.auth.localUserEmail,
- displayName: config.auth.localUserName,
- });
- console.log(JSON.stringify({ schema, imported }, null, 2));
|