@cmflow/atlas 3.5.0 → 3.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/atlas.mjs +122 -30
- package/dist/bin/atlas.mjs.map +1 -1
- package/package.json +1 -1
package/dist/bin/atlas.mjs
CHANGED
|
@@ -3087,7 +3087,7 @@ async function ensureOutputLink(client, outputPropertyId, backendPropertyId) {
|
|
|
3087
3087
|
//#endregion
|
|
3088
3088
|
//#region src/services/directus/queries/loadDirectusReferenceData.ts
|
|
3089
3089
|
async function loadDirectusReferenceData(client) {
|
|
3090
|
-
const values = await client.request(n$1("predefined_values", {
|
|
3090
|
+
const [values, documentValues] = await Promise.all([client.request(n$1("predefined_values", {
|
|
3091
3091
|
filter: { type: { _in: [
|
|
3092
3092
|
"backend",
|
|
3093
3093
|
"in_type",
|
|
@@ -3099,19 +3099,33 @@ async function loadDirectusReferenceData(client) {
|
|
|
3099
3099
|
"type"
|
|
3100
3100
|
],
|
|
3101
3101
|
limit: -1
|
|
3102
|
-
}))
|
|
3102
|
+
})), client.request(n$1("predefined_values", {
|
|
3103
|
+
filter: { type: { _starts_with: "document_" } },
|
|
3104
|
+
fields: [
|
|
3105
|
+
"id",
|
|
3106
|
+
"label",
|
|
3107
|
+
"type"
|
|
3108
|
+
],
|
|
3109
|
+
limit: -1
|
|
3110
|
+
}))]);
|
|
3103
3111
|
const backendIds = /* @__PURE__ */ new Map();
|
|
3104
3112
|
const inTypeIds = /* @__PURE__ */ new Map();
|
|
3105
3113
|
const outTypeIds = /* @__PURE__ */ new Map();
|
|
3114
|
+
const documentIds = /* @__PURE__ */ new Map();
|
|
3106
3115
|
for (const value of values) {
|
|
3107
3116
|
const normalizedKeys = [normalizeLookupKey(value.id), normalizeLookupKey(value.label)];
|
|
3108
3117
|
const target = value.type === "backend" ? backendIds : value.type === "in_type" ? inTypeIds : outTypeIds;
|
|
3109
3118
|
for (const key of normalizedKeys) target.set(key, value.id);
|
|
3110
3119
|
}
|
|
3120
|
+
for (const value of documentValues) {
|
|
3121
|
+
const normalizedKeys = [normalizeLookupKey(value.id), normalizeLookupKey(value.label)];
|
|
3122
|
+
for (const key of normalizedKeys) documentIds.set(key, value.id);
|
|
3123
|
+
}
|
|
3111
3124
|
return {
|
|
3112
3125
|
backendIds,
|
|
3113
3126
|
inTypeIds,
|
|
3114
|
-
outTypeIds
|
|
3127
|
+
outTypeIds,
|
|
3128
|
+
documentIds
|
|
3115
3129
|
};
|
|
3116
3130
|
}
|
|
3117
3131
|
|
|
@@ -4449,6 +4463,7 @@ function ensureBackendRouteRecord(backendRoutesByKey, document, candidate) {
|
|
|
4449
4463
|
key,
|
|
4450
4464
|
backend: candidate.backend,
|
|
4451
4465
|
route_key: document.key,
|
|
4466
|
+
resource_type: "http",
|
|
4452
4467
|
route: `${candidate.method || "CALL"} ${candidate.route}`,
|
|
4453
4468
|
source_file: candidate.sourceFile,
|
|
4454
4469
|
provenance: "code_analysis"
|
|
@@ -4711,7 +4726,7 @@ async function upsertBackendProperty(client, property, backendRouteId, typeId) {
|
|
|
4711
4726
|
const path = normalizeDirectusPath(property.field);
|
|
4712
4727
|
const [existing] = await client.request(n$1("backend_properties", {
|
|
4713
4728
|
filter: {
|
|
4714
|
-
|
|
4729
|
+
backend: { _eq: backendRouteId },
|
|
4715
4730
|
path: { _eq: path },
|
|
4716
4731
|
type: { _eq: typeId }
|
|
4717
4732
|
},
|
|
@@ -4720,39 +4735,93 @@ async function upsertBackendProperty(client, property, backendRouteId, typeId) {
|
|
|
4720
4735
|
}));
|
|
4721
4736
|
if (existing) return existing.id;
|
|
4722
4737
|
const created = await client.request(n$2("backend_properties", {
|
|
4723
|
-
|
|
4738
|
+
backend: backendRouteId,
|
|
4724
4739
|
path: path || null,
|
|
4725
4740
|
type: typeId,
|
|
4726
4741
|
source_file: property.source_file || null,
|
|
4742
|
+
provenance: property.provenance,
|
|
4727
4743
|
comments: property.provenance === "ai" ? "Inferred with AI" : null,
|
|
4728
4744
|
content_name: null
|
|
4729
4745
|
}));
|
|
4730
4746
|
return typeof created === "string" ? created : created.id;
|
|
4731
4747
|
}
|
|
4732
4748
|
|
|
4733
|
-
//#endregion
|
|
4734
|
-
//#region src/services/directus/utils/toBackendRouteIdentifier.ts
|
|
4735
|
-
function toBackendRouteIdentifier(route) {
|
|
4736
|
-
return `${route.method} ${route.path}`;
|
|
4737
|
-
}
|
|
4738
|
-
|
|
4739
4749
|
//#endregion
|
|
4740
4750
|
//#region src/services/directus/queries/upsertBackendRoute.ts
|
|
4741
|
-
async function
|
|
4742
|
-
const
|
|
4743
|
-
|
|
4744
|
-
|
|
4751
|
+
async function upsertBackendSource(client, backendRoute, backendValueId, refs) {
|
|
4752
|
+
const isDocument = backendRoute.resource_type === "document";
|
|
4753
|
+
let documentId = isDocument ? refs.documentIds.get(normalizeLookupKey(backendRoute.document || "")) : void 0;
|
|
4754
|
+
if (isDocument && !documentId && backendRoute.document) {
|
|
4755
|
+
const type = `document_${backendRoute.backend.toLowerCase()}`;
|
|
4756
|
+
const created = await client.request(n$2("predefined_values", {
|
|
4757
|
+
label: backendRoute.document,
|
|
4758
|
+
type
|
|
4759
|
+
}));
|
|
4760
|
+
documentId = typeof created === "string" ? created : created.id;
|
|
4761
|
+
refs.documentIds.set(normalizeLookupKey(backendRoute.document), documentId);
|
|
4762
|
+
}
|
|
4763
|
+
const filter = isDocument ? {
|
|
4764
|
+
backend: { _eq: backendValueId },
|
|
4765
|
+
resource_type: { _eq: "document" },
|
|
4766
|
+
document: { _eq: documentId ?? null }
|
|
4767
|
+
} : {
|
|
4768
|
+
backend: { _eq: backendValueId },
|
|
4769
|
+
resource_type: { _eq: "http" },
|
|
4770
|
+
method: { _eq: backendRoute.method ?? null },
|
|
4771
|
+
route: { _eq: backendRoute.route ?? null }
|
|
4772
|
+
};
|
|
4773
|
+
const [existing] = await client.request(n$1("backend_sources", {
|
|
4774
|
+
filter,
|
|
4745
4775
|
fields: ["id"],
|
|
4746
4776
|
limit: 1
|
|
4747
4777
|
}));
|
|
4748
4778
|
if (existing) return existing.id;
|
|
4749
|
-
const
|
|
4750
|
-
|
|
4751
|
-
|
|
4752
|
-
|
|
4779
|
+
const payload = isDocument ? {
|
|
4780
|
+
backend: backendValueId,
|
|
4781
|
+
resource_type: "document",
|
|
4782
|
+
document: documentId ?? null,
|
|
4783
|
+
source_file: backendRoute.source_file || null,
|
|
4784
|
+
provenance: backendRoute.provenance
|
|
4785
|
+
} : {
|
|
4786
|
+
backend: backendValueId,
|
|
4787
|
+
resource_type: "http",
|
|
4788
|
+
method: backendRoute.method ?? null,
|
|
4789
|
+
route: backendRoute.route ?? null,
|
|
4790
|
+
source_file: backendRoute.source_file || null,
|
|
4791
|
+
provenance: backendRoute.provenance
|
|
4792
|
+
};
|
|
4793
|
+
const created = await client.request(n$2("backend_sources", payload));
|
|
4753
4794
|
return typeof created === "string" ? created : created.id;
|
|
4754
4795
|
}
|
|
4755
4796
|
|
|
4797
|
+
//#endregion
|
|
4798
|
+
//#region src/services/directus/queries/upsertMappingEvidence.ts
|
|
4799
|
+
async function upsertMappingEvidence(client, evidence, params) {
|
|
4800
|
+
const [existing] = await client.request(n$1("mapping_evidence", {
|
|
4801
|
+
filter: { atlas_key: { _eq: evidence.key } },
|
|
4802
|
+
fields: ["id"],
|
|
4803
|
+
limit: 1
|
|
4804
|
+
}));
|
|
4805
|
+
const payload = {
|
|
4806
|
+
atlas_key: evidence.key,
|
|
4807
|
+
input_property_id: params.inputPropertyId ?? null,
|
|
4808
|
+
output_property_id: params.outputPropertyId ?? null,
|
|
4809
|
+
backend_property_id: params.backendPropertyId,
|
|
4810
|
+
evidence_type: evidence.evidence_type,
|
|
4811
|
+
status: evidence.status,
|
|
4812
|
+
confidence_score: evidence.confidence_score,
|
|
4813
|
+
comment: evidence.comment || null,
|
|
4814
|
+
source_file: evidence.source_file || null,
|
|
4815
|
+
last_seen_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
4816
|
+
};
|
|
4817
|
+
if (existing) {
|
|
4818
|
+
await client.request(i("mapping_evidence", existing.id, payload));
|
|
4819
|
+
return false;
|
|
4820
|
+
}
|
|
4821
|
+
await client.request(n$2("mapping_evidence", payload));
|
|
4822
|
+
return true;
|
|
4823
|
+
}
|
|
4824
|
+
|
|
4756
4825
|
//#endregion
|
|
4757
4826
|
//#region src/services/directus/queries/upsertInputProperty.ts
|
|
4758
4827
|
async function upsertInputProperty(client, property, routeId, inType) {
|
|
@@ -4812,6 +4881,12 @@ async function upsertOutputProperty(client, property, routeId, outType) {
|
|
|
4812
4881
|
return existing.id;
|
|
4813
4882
|
}
|
|
4814
4883
|
|
|
4884
|
+
//#endregion
|
|
4885
|
+
//#region src/services/directus/utils/toBackendRouteIdentifier.ts
|
|
4886
|
+
function toBackendRouteIdentifier(route) {
|
|
4887
|
+
return `${route.method} ${route.path}`;
|
|
4888
|
+
}
|
|
4889
|
+
|
|
4815
4890
|
//#endregion
|
|
4816
4891
|
//#region src/services/directus/utils/buildTranslationSummary.ts
|
|
4817
4892
|
function buildTranslationSummary(route) {
|
|
@@ -4851,11 +4926,10 @@ async function upsertRoute(client, route) {
|
|
|
4851
4926
|
|
|
4852
4927
|
//#endregion
|
|
4853
4928
|
//#region src/services/directus/utils/groupBackendRoutesForDirectusSync.ts
|
|
4854
|
-
function groupBackendRoutesForDirectusSync(backendRoutes
|
|
4929
|
+
function groupBackendRoutesForDirectusSync(backendRoutes) {
|
|
4855
4930
|
const groups = /* @__PURE__ */ new Map();
|
|
4856
4931
|
for (const backendRoute of backendRoutes) {
|
|
4857
|
-
const
|
|
4858
|
-
const key = apiRoute ? `${backendRoute.backend}\0${apiRoute.method}\0${apiRoute.path}` : `${backendRoute.backend}\0missing-api-route\0${backendRoute.key}`;
|
|
4932
|
+
const key = backendRoute.resource_type === "document" ? `${backendRoute.backend}\0document\0${backendRoute.document || ""}` : `${backendRoute.backend}\0http\0${backendRoute.method || ""}\0${backendRoute.route || ""}`;
|
|
4859
4933
|
const group = groups.get(key);
|
|
4860
4934
|
if (group) group.keys.push(backendRoute.key);
|
|
4861
4935
|
else groups.set(key, {
|
|
@@ -4910,12 +4984,13 @@ async function pushCatalogueToDirectus(catalogue, options) {
|
|
|
4910
4984
|
"routes",
|
|
4911
4985
|
"route_input_properties",
|
|
4912
4986
|
"route_output_properties",
|
|
4913
|
-
"
|
|
4987
|
+
"backend_sources",
|
|
4914
4988
|
"backend_properties",
|
|
4989
|
+
"mapping_evidence",
|
|
4915
4990
|
"route_input_properties_backend_properties",
|
|
4916
4991
|
"route_output_properties_backend_properties"
|
|
4917
4992
|
];
|
|
4918
|
-
const skippedCollections = [
|
|
4993
|
+
const skippedCollections = [];
|
|
4919
4994
|
const catalogueToPush = selectCatalogueForDirectusPush(catalogue, options.routeSelector);
|
|
4920
4995
|
if (options.dryRun) {
|
|
4921
4996
|
taskProgressService.report("Validating reconstructed catalogue (dry-run)");
|
|
@@ -4934,7 +5009,7 @@ async function pushCatalogueToDirectus(catalogue, options) {
|
|
|
4934
5009
|
const warnings = /* @__PURE__ */ new Set();
|
|
4935
5010
|
let pushedItems = 0;
|
|
4936
5011
|
const apiRoutesByKey = new Map(catalogueToPush.routes.map((route) => [route.key, route]));
|
|
4937
|
-
const backendRouteGroups = groupBackendRoutesForDirectusSync(catalogueToPush.backend_routes
|
|
5012
|
+
const backendRouteGroups = groupBackendRoutesForDirectusSync(catalogueToPush.backend_routes);
|
|
4938
5013
|
const backendRouteGroupsByApiRouteKey = /* @__PURE__ */ new Map();
|
|
4939
5014
|
const backendRouteApiRouteKeys = /* @__PURE__ */ new Map();
|
|
4940
5015
|
for (const group of backendRouteGroups) {
|
|
@@ -4962,7 +5037,7 @@ async function pushCatalogueToDirectus(catalogue, options) {
|
|
|
4962
5037
|
continue;
|
|
4963
5038
|
}
|
|
4964
5039
|
if (backendReference.created) pushedItems += 1;
|
|
4965
|
-
const backendRouteId = await
|
|
5040
|
+
const backendRouteId = await upsertBackendSource(client, backendRoute, backendReference.id, refs);
|
|
4966
5041
|
for (const key of keys) backendRouteIds.set(key, backendRouteId);
|
|
4967
5042
|
pushedItems += 1;
|
|
4968
5043
|
}
|
|
@@ -4995,7 +5070,14 @@ async function pushCatalogueToDirectus(catalogue, options) {
|
|
|
4995
5070
|
pushedItems += 1;
|
|
4996
5071
|
for (const evidence of catalogueToPush.mapping_evidence.filter((item) => item.input_property_key === property.key)) {
|
|
4997
5072
|
const backendPropertyId = backendPropertyIds.get(evidence.backend_property_key);
|
|
4998
|
-
if (backendPropertyId
|
|
5073
|
+
if (backendPropertyId) {
|
|
5074
|
+
if (await ensureInputLink(client, inputPropertyId, backendPropertyId)) pushedItems += 1;
|
|
5075
|
+
await upsertMappingEvidence(client, evidence, {
|
|
5076
|
+
inputPropertyId,
|
|
5077
|
+
backendPropertyId
|
|
5078
|
+
});
|
|
5079
|
+
pushedItems += 1;
|
|
5080
|
+
}
|
|
4999
5081
|
}
|
|
5000
5082
|
}
|
|
5001
5083
|
const routeOutputProperties = catalogueToPush.route_output_properties.filter((property) => property.route_key === route.key);
|
|
@@ -5010,7 +5092,14 @@ async function pushCatalogueToDirectus(catalogue, options) {
|
|
|
5010
5092
|
pushedItems += 1;
|
|
5011
5093
|
for (const evidence of catalogueToPush.mapping_evidence.filter((item) => item.output_property_key === property.key)) {
|
|
5012
5094
|
const backendPropertyId = backendPropertyIds.get(evidence.backend_property_key);
|
|
5013
|
-
if (backendPropertyId
|
|
5095
|
+
if (backendPropertyId) {
|
|
5096
|
+
if (await ensureOutputLink(client, outputPropertyId, backendPropertyId)) pushedItems += 1;
|
|
5097
|
+
await upsertMappingEvidence(client, evidence, {
|
|
5098
|
+
outputPropertyId,
|
|
5099
|
+
backendPropertyId
|
|
5100
|
+
});
|
|
5101
|
+
pushedItems += 1;
|
|
5102
|
+
}
|
|
5014
5103
|
}
|
|
5015
5104
|
}
|
|
5016
5105
|
}
|
|
@@ -5121,7 +5210,7 @@ function buildRouteReviewDocument(catalogue, routeKey) {
|
|
|
5121
5210
|
const datasources = backendRoutes.map((backendRoute) => ({
|
|
5122
5211
|
type: backendRoute.backend,
|
|
5123
5212
|
source: backendRoute.source_file,
|
|
5124
|
-
...parseBackendRoute(backendRoute.route) ? { operation: parseBackendRoute(backendRoute.route) } : {},
|
|
5213
|
+
...parseBackendRoute(backendRoute.route ?? "") ? { operation: parseBackendRoute(backendRoute.route ?? "") } : {},
|
|
5125
5214
|
...backendRoute.provenance === "ai" ? { provenance: backendRoute.provenance } : {}
|
|
5126
5215
|
}));
|
|
5127
5216
|
for (const backend of route.backends) if (!datasources.some((datasource) => datasource.type === backend) && !mappedBackendTypes.has(backend)) datasources.push({
|
|
@@ -5243,6 +5332,7 @@ function addBackendMapping(routeKey, direction, apiPropertyKey, mapping, backend
|
|
|
5243
5332
|
key: backendRouteKey,
|
|
5244
5333
|
backend: mapping.backend,
|
|
5245
5334
|
route_key: routeKey,
|
|
5335
|
+
resource_type: "http",
|
|
5246
5336
|
route: `${mapping.method || "CALL"} ${backendRoute}`,
|
|
5247
5337
|
source_file: mapping.source_file,
|
|
5248
5338
|
provenance: "code_analysis"
|
|
@@ -5291,6 +5381,7 @@ function addDatasourceRoute(routeKey, datasource, backendRoutesByKey) {
|
|
|
5291
5381
|
key: backendRouteKey,
|
|
5292
5382
|
backend: datasource.type,
|
|
5293
5383
|
route_key: routeKey,
|
|
5384
|
+
resource_type: "http",
|
|
5294
5385
|
route: `${datasource.operation?.method || "CALL"} ${backendRoute}`,
|
|
5295
5386
|
source_file: datasource.source,
|
|
5296
5387
|
provenance: datasource.provenance || "code_analysis"
|
|
@@ -23082,6 +23173,7 @@ function ensureBackendRoute(catalogue, document, suggestion) {
|
|
|
23082
23173
|
key,
|
|
23083
23174
|
backend: suggestion.candidate.backend,
|
|
23084
23175
|
route_key: document.key,
|
|
23176
|
+
resource_type: "http",
|
|
23085
23177
|
route: `${candidate?.method || "CALL"} ${backendRoutePath}`,
|
|
23086
23178
|
source_file: candidate?.sourceFile || suggestion.candidate.sourceFile,
|
|
23087
23179
|
provenance: "ai"
|
|
@@ -23841,7 +23933,7 @@ async function reportChangedHandler(cwd, options) {
|
|
|
23841
23933
|
backends: catalogueRoute?.backends || [],
|
|
23842
23934
|
backendRoutes: catalogue.backend_routes.filter((br) => br.route_key === catalogueRoute?.key).map((br) => ({
|
|
23843
23935
|
backend: br.backend,
|
|
23844
|
-
route: br.route
|
|
23936
|
+
route: br.route ?? ""
|
|
23845
23937
|
})),
|
|
23846
23938
|
properties: [...catalogue.route_input_properties.map((p) => ({
|
|
23847
23939
|
direction: "input",
|