Skip to content

Commit 3a3882c

Browse files
Merge pull request #64 from foundersandcoders/claude/fix-schema-forge-sync-NZWhO
2 parents 2c7333a + 3368a39 commit 3a3882c

35 files changed

Lines changed: 195 additions & 220 deletions

.github/workflows/sync-engine.yml

Lines changed: 28 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Sync engine to schema-forge
1+
name: Sync schema-forge
22

33
on:
44
push:
@@ -15,76 +15,36 @@ on:
1515
jobs:
1616
sync:
1717
runs-on: ubuntu-latest
18-
1918
steps:
2019
- name: Checkout Iris
2120
uses: actions/checkout@v4
2221
with:
23-
fetch-depth: 2
24-
25-
- name: Check for engine changes
26-
id: changes
27-
run: |
28-
ENGINE_PATHS=(
29-
"src/lib/schema"
30-
"src/lib/types/interpreterTypes.ts"
31-
"src/lib/types/schemaTypes.ts"
32-
"src/lib/transforms"
33-
"src/lib/utils/schema"
34-
"src/lib/utils/csv"
35-
"src/lib/utils/xml"
36-
)
37-
38-
CHANGED=false
39-
for path in "${ENGINE_PATHS[@]}"; do
40-
if git diff --name-only HEAD~1 HEAD -- "$path" | grep -q .; then
41-
CHANGED=true
42-
break
43-
fi
44-
done
45-
46-
echo "changed=$CHANGED" >> "$GITHUB_OUTPUT"
47-
48-
- name: Clone schema-forge
49-
if: steps.changes.outputs.changed == 'true'
50-
run: |
51-
git clone https://x-access-token:${{ secrets.SCHEMA_FORGE_PAT }}@github.com/JasonWarrenUK/schema-forge.git /tmp/schema-forge
52-
53-
- name: Sync engine files
54-
if: steps.changes.outputs.changed == 'true'
55-
run: |
56-
TARGET=/tmp/schema-forge/src
57-
58-
# Clear previous engine content (full replace, not merge)
59-
rm -rf "$TARGET"
60-
mkdir -p "$TARGET"
61-
62-
# Copy engine modules preserving structure
63-
cp -r src/lib/schema "$TARGET/schema"
64-
cp -r src/lib/transforms "$TARGET/transforms"
65-
cp -r src/lib/utils/schema "$TARGET/utils/schema"
66-
cp -r src/lib/utils/csv "$TARGET/utils/csv"
67-
cp -r src/lib/utils/xml "$TARGET/utils/xml"
68-
69-
mkdir -p "$TARGET/types"
70-
cp src/lib/types/interpreterTypes.ts "$TARGET/types/"
71-
cp src/lib/types/schemaTypes.ts "$TARGET/types/"
22+
fetch-depth: 0
7223

73-
- name: Commit and push
74-
if: steps.changes.outputs.changed == 'true'
75-
working-directory: /tmp/schema-forge
24+
- name: Stage engine files
7625
run: |
77-
git config user.name "iris-sync[bot]"
78-
git config user.email "iris-sync[bot]@users.noreply.github.com"
79-
80-
git add -A
81-
if git diff --cached --quiet; then
82-
echo "No changes to commit"
83-
exit 0
84-
fi
85-
86-
COMMIT_SHA="${{ github.sha }}"
87-
git commit -m "sync: update engine from iris@${COMMIT_SHA:0:7}
88-
89-
Source: ${{ github.server_url }}/${{ github.repository }}/commit/${COMMIT_SHA}"
90-
git push
26+
mkdir -p /tmp/engine-stage/schema
27+
mkdir -p /tmp/engine-stage/transforms
28+
mkdir -p /tmp/engine-stage/types
29+
mkdir -p /tmp/engine-stage/utils/schema
30+
mkdir -p /tmp/engine-stage/utils/csv
31+
mkdir -p /tmp/engine-stage/utils/xml
32+
33+
cp -r src/lib/schema/. /tmp/engine-stage/schema/
34+
cp -r src/lib/transforms/. /tmp/engine-stage/transforms/
35+
cp -r src/lib/utils/schema/. /tmp/engine-stage/utils/schema/
36+
cp -r src/lib/utils/csv/. /tmp/engine-stage/utils/csv/
37+
cp -r src/lib/utils/xml/. /tmp/engine-stage/utils/xml/
38+
cp src/lib/types/interpreterTypes.ts /tmp/engine-stage/types/
39+
cp src/lib/types/schemaTypes.ts /tmp/engine-stage/types/
40+
41+
- name: Push engine directory to schema-forge repo
42+
uses: peaceiris/actions-gh-pages@v4
43+
with:
44+
personal_token: ${{ secrets.SCHEMA_FORGE_PAT }}
45+
external_repository: JasonWarrenUK/schema-forge
46+
publish_dir: /tmp/engine-stage
47+
publish_branch: main
48+
destination_dir: src
49+
commit_message: "sync: update from iris@${{ github.sha }}"
50+
enable_jekyll: true

src/lib/mappings/aimUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export function generateAimMappings(templates: AimFieldTemplate[]): ColumnMappin
3333
csvColumn: template.csv.replace('{n}', String(aimNumber)),
3434
xsdPath: template.xsd,
3535
transform: template.transform,
36-
aimNumber,
36+
group: aimNumber,
3737
});
3838
}
3939
}

src/lib/mappings/builders.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import type {
99
AppFinTemplate,
1010
EmploymentStatusConfig,
1111
EsmField,
12-
} from '../types/schemaTypes';
12+
} from '../types/ilrMappingTypes';
1313
import { getTransform } from '../transforms/registry';
1414

1515
/**

src/lib/mappings/compatibility.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Loads schema, builds registry, and validates compatibility in one call.
44
*/
55

6-
import type { MappingConfig } from '../types/schemaTypes';
6+
import type { IlrMappingConfig } from '../types/ilrMappingTypes';
77
import type { IrisStorage } from '../storage';
88
import { buildSchemaRegistry } from '../schema/registryBuilder';
99
import { validateSchemaCompatibility, type CompatibilityResult } from '../schema/schemaCompatibility';
@@ -20,7 +20,7 @@ export interface MappingCompatibilityResult {
2020
* Loads the schema, builds registry, and checks compatibility.
2121
*/
2222
export async function validateMappingCompatibility(params: {
23-
mapping: MappingConfig;
23+
mapping: IlrMappingConfig;
2424
schemaFile: string;
2525
storage: IrisStorage;
2626
}): Promise<MappingCompatibilityResult> {

src/lib/mappings/fac-airtable-2025.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
* |================================================================|
55
*/
66

7-
import type { MappingConfig } from '../types/schemaTypes';
7+
import type { IlrMappingConfig } from '../types/ilrMappingTypes';
88
import { generateAimMappings } from './aimUtils';
99

10-
export const facAirtableMapping: MappingConfig = {
10+
export const facAirtableMapping: IlrMappingConfig = {
1111
id: 'fac-airtable-2025',
1212
name: 'Founders and Coders Airtable Export (2025-26)',
1313
mappingVersion: '2.0.0',

src/lib/mappings/ilrColumnMapper.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import type { ColumnMapping, MappingConfig } from '../types/schemaTypes';
1+
import type { ColumnMapping } from '../types/schemaTypes';
2+
import type { IlrMappingConfig } from '../types/ilrMappingTypes';
23
import type { SchemaRegistry } from '../types/interpreterTypes';
34
import { mapCsvToSchema } from '../schema/columnMapper';
45
import { getTransform } from '../transforms/registry';
@@ -24,21 +25,21 @@ import { generateUUID } from '../utils/uuid';
2425
*/
2526
export function mapCsvToSchemaWithAims(
2627
csvRow: Record<string, string>,
27-
config: MappingConfig,
28+
config: IlrMappingConfig,
2829
registry: SchemaRegistry
2930
): Record<string, unknown> {
3031
// Separate learner-level and aim-specific mappings
31-
const learnerMappings = config.mappings.filter((m) => !m.aimNumber);
32-
const aimMappings = config.mappings.filter((m) => m.aimNumber);
32+
const learnerMappings = config.mappings.filter((m) => !m.group);
33+
const aimMappings = config.mappings.filter((m) => m.group);
3334

3435
// Group aim mappings by aim number
3536
const aimGroups = new Map<number, ColumnMapping[]>();
3637
for (const mapping of aimMappings) {
37-
if (!mapping.aimNumber) continue;
38-
if (!aimGroups.has(mapping.aimNumber)) {
39-
aimGroups.set(mapping.aimNumber, []);
38+
if (!mapping.group) continue;
39+
if (!aimGroups.has(mapping.group)) {
40+
aimGroups.set(mapping.group, []);
4041
}
41-
aimGroups.get(mapping.aimNumber)!.push(mapping);
42+
aimGroups.get(mapping.group)!.push(mapping);
4243
}
4344

4445
// Apply learner-level mappings using generic mapper

src/lib/mappings/ilrValidation.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import { hasAimData } from './aimUtils';
1111
*/
1212
export function createAimSkipFilter(detectionField: string = 'Programme aim {n} Learning ref') {
1313
return (mapping: ColumnMapping, row?: Record<string, string>): boolean => {
14-
if (!mapping.aimNumber) return false;
14+
if (!mapping.group) return false;
1515
if (!row) return true; // header-level: skip all aim mappings
16-
return !hasAimData(row, mapping.aimNumber, detectionField);
16+
return !hasAimData(row, mapping.group, detectionField);
1717
};
1818
}
File renamed without changes.

src/lib/mappings/validate.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export function validateMappingStructure(mapping: unknown): MappingValidationRes
8686
if (typeof e.xsdPath !== 'string' || e.xsdPath.trim() === '') {
8787
issues.push({ field: `mappings[${index}].xsdPath`, message: 'Must be a non-empty string' });
8888
}
89-
// transform and aimNumber are optional, no validation needed
89+
// transform and group are optional, no validation needed
9090
});
9191
}
9292

0 commit comments

Comments
 (0)