catalyst-relay 0.5.3 → 0.5.5

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/index.mjs CHANGED
@@ -2276,7 +2276,8 @@ async function countRows(client, objectName, _objectType, parameters = []) {
2276
2276
  }
2277
2277
 
2278
2278
  // src/core/adt/discovery/searchObjects.ts
2279
- async function searchObjects(client, query, types) {
2279
+ async function searchObjects(client, query, options) {
2280
+ const { types, includePackages = true } = options ?? {};
2280
2281
  const searchPattern = query || "*";
2281
2282
  const objectTypes = types && types.length > 0 ? types : getAllTypes();
2282
2283
  const params = [
@@ -2308,8 +2309,30 @@ async function searchObjects(client, query, types) {
2308
2309
  if (parseErr) {
2309
2310
  return err(parseErr);
2310
2311
  }
2312
+ if (includePackages) await enrichWithPackages(client, results);
2311
2313
  return ok(results);
2312
2314
  }
2315
+ async function enrichWithPackages(client, results) {
2316
+ const needsPackage = results.filter((r) => !r.package);
2317
+ if (needsPackage.length === 0) return;
2318
+ const promises = needsPackage.map(async (result) => {
2319
+ const encodedUri = encodeURIComponent(result.uri);
2320
+ const [response, reqErr] = await client.request({
2321
+ method: "GET",
2322
+ path: `/sap/bc/adt/repository/informationsystem/objectproperties/values?uri=${encodedUri}&facet=package`
2323
+ });
2324
+ if (reqErr || !response.ok) return;
2325
+ const text = await response.text();
2326
+ const [doc, parseErr] = safeParseXml(text);
2327
+ if (parseErr) return;
2328
+ const oprNs = "http://www.sap.com/adt/ris/objectProperties";
2329
+ const objEl = doc.getElementsByTagNameNS(oprNs, "object")[0];
2330
+ if (!objEl) return;
2331
+ const pkg = objEl.getAttribute("package");
2332
+ if (pkg) result.package = pkg;
2333
+ });
2334
+ await Promise.all(promises);
2335
+ }
2313
2336
  function parseSearchResults(xml) {
2314
2337
  const [doc, parseErr] = safeParseXml(xml);
2315
2338
  if (parseErr) {
@@ -2322,14 +2345,16 @@ function parseSearchResults(xml) {
2322
2345
  if (!obj) continue;
2323
2346
  const name = obj.getAttributeNS("http://www.sap.com/adt/core", "name") || obj.getAttribute("adtcore:name");
2324
2347
  const type = obj.getAttributeNS("http://www.sap.com/adt/core", "type") || obj.getAttribute("adtcore:type");
2348
+ const uri = obj.getAttributeNS("http://www.sap.com/adt/core", "uri") || obj.getAttribute("adtcore:uri");
2325
2349
  const description = obj.getAttributeNS("http://www.sap.com/adt/core", "description") || obj.getAttribute("adtcore:description");
2326
- if (!name || !type) continue;
2350
+ if (!name || !type || !uri) continue;
2327
2351
  const config = getConfigByType(type);
2328
2352
  if (!config) continue;
2329
2353
  const packageRef = obj.getElementsByTagNameNS("http://www.sap.com/adt/core", "packageRef")[0];
2330
2354
  const packageName = packageRef ? packageRef.getAttributeNS("http://www.sap.com/adt/core", "name") || packageRef.getAttribute("adtcore:name") : "";
2331
2355
  const result = {
2332
2356
  name,
2357
+ uri,
2333
2358
  extension: config.extension,
2334
2359
  package: packageName || "",
2335
2360
  objectType: config.label
@@ -2687,9 +2712,9 @@ async function countRows2(state, requestor, objectName, objectType, parameters =
2687
2712
  }
2688
2713
 
2689
2714
  // src/client/methods/search/search.ts
2690
- async function search(state, requestor, query, types) {
2715
+ async function search(state, requestor, query, options) {
2691
2716
  if (!state.session) return err(new Error("Not logged in"));
2692
- return searchObjects(requestor, query, types);
2717
+ return searchObjects(requestor, query, options);
2693
2718
  }
2694
2719
 
2695
2720
  // src/client/methods/search/whereUsed.ts
@@ -3070,8 +3095,8 @@ var ADTClientImpl = class {
3070
3095
  return countRows2(this.state, this.requestor, objectName, objectType, parameters);
3071
3096
  }
3072
3097
  // --- Search ---
3073
- async search(query, types) {
3074
- return search(this.state, this.requestor, query, types);
3098
+ async search(query, options) {
3099
+ return search(this.state, this.requestor, query, options);
3075
3100
  }
3076
3101
  async whereUsed(object) {
3077
3102
  return whereUsed(this.state, this.requestor, object);