-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathseed-loader-service.ts
More file actions
62 lines (57 loc) · 2.47 KB
/
Copy pathseed-loader-service.ts
File metadata and controls
62 lines (57 loc) · 2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
import type {
SeedLoaderRequest,
SeedLoaderResult,
SeedLoaderConfigInput,
ObjectDependencyGraph,
} from '../data/seed-loader.zod.js';
import type { Seed } from '../data/seed.zod.js';
/**
* ISeedLoaderService — Metadata-driven Seed Data Loader Contract
*
* Responsible for loading seed/demo/config data with:
* - Automatic lookup/master_detail reference resolution via externalId
* - Topological dependency ordering (parents before children)
* - Multi-pass loading for circular references
* - Dry-run validation mode
* - Actionable error reporting
*
* ## Architecture Alignment
* - **Salesforce Data Loader**: External ID-based upsert with relationship resolution
* - **ServiceNow**: Sys ID and display value mapping during import
* - **Airtable**: Linked record resolution via display names
*
* Aligned with CoreServiceName 'seed-loader' and SeedLoaderProtocol in data/seed-loader.zod.ts.
*/
export interface ISeedLoaderService {
/**
* Load one or more datasets with full reference resolution and dependency ordering.
*
* The loader automatically:
* 1. Filters datasets by environment if `config.env` is set
* 2. Builds a dependency graph from object metadata (lookup/master_detail fields)
* 3. Topologically sorts datasets so parent objects are inserted before children
* 4. Resolves references via externalId, with multi-pass for circular dependencies
*
* @param request - Parsed SeedLoaderRequest (datasets + config)
* @returns Structured result with per-object stats, errors, and summary
*/
load(request: SeedLoaderRequest): Promise<SeedLoaderResult>;
/**
* Build the object dependency graph from metadata for the given object names.
* Inspects lookup/master_detail fields to determine dependencies.
*
* @param objectNames - Object names to include in the graph
* @returns Dependency graph with topological insert order and circular dependency detection
*/
buildDependencyGraph(objectNames: string[]): Promise<ObjectDependencyGraph>;
/**
* Validate datasets without writing any data (equivalent to config.dryRun = true).
* Checks reference integrity and reports all broken references.
*
* @param datasets - Seeds to validate
* @param config - Optional loader config overrides
* @returns Structured result with validation errors (no data written)
*/
validate(datasets: Seed[], config?: SeedLoaderConfigInput): Promise<SeedLoaderResult>;
}