catalyst-relay 0.2.2 → 0.2.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.d.mts +52 -5
- package/dist/index.d.ts +52 -5
- package/dist/index.js +119 -37
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +118 -37
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -108,7 +108,7 @@ interface TreeQuery {
|
|
|
108
108
|
/**
|
|
109
109
|
* Data preview query
|
|
110
110
|
*/
|
|
111
|
-
interface
|
|
111
|
+
interface PreviewSQL {
|
|
112
112
|
/** Object name (table or CDS view) */
|
|
113
113
|
objectName: string;
|
|
114
114
|
/** Object type ('table' or 'view') */
|
|
@@ -311,6 +311,53 @@ interface ColumnInfo {
|
|
|
311
311
|
label?: string;
|
|
312
312
|
}
|
|
313
313
|
|
|
314
|
+
/**
|
|
315
|
+
* Query Builder — Optional helper for building SQL queries for data preview
|
|
316
|
+
*/
|
|
317
|
+
|
|
318
|
+
type BasicFilter = {
|
|
319
|
+
type: "basic";
|
|
320
|
+
field: string;
|
|
321
|
+
value: string | number;
|
|
322
|
+
operator: "=" | "<>" | "<" | "<=" | ">" | ">=" | "like" | "not like";
|
|
323
|
+
};
|
|
324
|
+
type BetweenFilter = {
|
|
325
|
+
type: "between";
|
|
326
|
+
field: string;
|
|
327
|
+
minimum: string | number;
|
|
328
|
+
maximum: string | number;
|
|
329
|
+
};
|
|
330
|
+
type ListFilter = {
|
|
331
|
+
type: "list";
|
|
332
|
+
field: string;
|
|
333
|
+
values: (string | number)[];
|
|
334
|
+
include: boolean;
|
|
335
|
+
};
|
|
336
|
+
type QueryFilter = BasicFilter | BetweenFilter | ListFilter;
|
|
337
|
+
type Sorting = {
|
|
338
|
+
field: string;
|
|
339
|
+
direction: "ascending" | "descending";
|
|
340
|
+
};
|
|
341
|
+
type Aggregation = {
|
|
342
|
+
field: string;
|
|
343
|
+
function: "count" | "sum" | "avg" | "min" | "max";
|
|
344
|
+
};
|
|
345
|
+
type Parameter = {
|
|
346
|
+
name: string;
|
|
347
|
+
value: string | number;
|
|
348
|
+
};
|
|
349
|
+
type DataPreviewQuery = {
|
|
350
|
+
objectName: string;
|
|
351
|
+
objectType: 'table' | 'view';
|
|
352
|
+
limit?: number;
|
|
353
|
+
fields: string[];
|
|
354
|
+
parameters?: Parameter[];
|
|
355
|
+
filters?: QueryFilter[];
|
|
356
|
+
sortings?: Sorting[];
|
|
357
|
+
aggregations?: Aggregation[];
|
|
358
|
+
};
|
|
359
|
+
declare function buildSQLQuery(query: DataPreviewQuery): Result<PreviewSQL>;
|
|
360
|
+
|
|
314
361
|
/**
|
|
315
362
|
* Distinct Values — Get distinct column values with counts
|
|
316
363
|
*/
|
|
@@ -430,11 +477,11 @@ interface ADTClient {
|
|
|
430
477
|
upsert(objects: ObjectContent[], packageName: string, transport?: string): AsyncResult<UpsertResult[]>;
|
|
431
478
|
activate(objects: ObjectRef[]): AsyncResult<ActivationResult[]>;
|
|
432
479
|
delete(objects: ObjectRef[], transport?: string): AsyncResult<void>;
|
|
433
|
-
getPackages(): AsyncResult<Package[]>;
|
|
480
|
+
getPackages(filter?: string): AsyncResult<Package[]>;
|
|
434
481
|
getTree(query: TreeQuery): AsyncResult<TreeNode[]>;
|
|
435
482
|
getTransports(packageName: string): AsyncResult<Transport[]>;
|
|
436
|
-
previewData(query:
|
|
437
|
-
getDistinctValues(objectName: string, column: string, objectType?: 'table' | 'view'): AsyncResult<DistinctResult>;
|
|
483
|
+
previewData(query: PreviewSQL): AsyncResult<DataFrame>;
|
|
484
|
+
getDistinctValues(objectName: string, parameters: Parameter[], column: string, objectType?: 'table' | 'view'): AsyncResult<DistinctResult>;
|
|
438
485
|
countRows(objectName: string, objectType: 'table' | 'view'): AsyncResult<number>;
|
|
439
486
|
search(query: string, types?: string[]): AsyncResult<SearchResult[]>;
|
|
440
487
|
whereUsed(object: ObjectRef): AsyncResult<Dependency[]>;
|
|
@@ -444,4 +491,4 @@ interface ADTClient {
|
|
|
444
491
|
}
|
|
445
492
|
declare function createClient(config: ClientConfig): Result<ADTClient, Error>;
|
|
446
493
|
|
|
447
|
-
export { type ADTClient, type ActivationMessage, type ActivationResult, type ApiResponse, type AsyncResult, type AuthConfig, type AuthType, type BasicAuthConfig, type ClientConfig, type ColumnInfo, type DataFrame, type Dependency, type DiffResult, type DistinctResult, type ErrorCode, type ErrorResponse, type ObjectConfig, type ObjectContent, type ObjectMetadata, type ObjectRef, type ObjectWithContent, type Package, type
|
|
494
|
+
export { type ADTClient, type ActivationMessage, type ActivationResult, type Aggregation, type ApiResponse, type AsyncResult, type AuthConfig, type AuthType, type BasicAuthConfig, type BasicFilter, type BetweenFilter, type ClientConfig, type ColumnInfo, type DataFrame, type DataPreviewQuery, type Dependency, type DiffResult, type DistinctResult, type ErrorCode, type ErrorResponse, type ListFilter, type ObjectConfig, type ObjectContent, type ObjectMetadata, type ObjectRef, type ObjectWithContent, type Package, type Parameter, type PreviewSQL, type QueryFilter, type Result, type SamlAuthConfig, type SearchResult, type Session, type Sorting, type SsoAuthConfig, type SuccessResponse, type Transport, type TransportConfig, type TreeNode, type TreeQuery, type UpsertResult, buildSQLQuery, createClient, err, ok };
|
package/dist/index.d.ts
CHANGED
|
@@ -108,7 +108,7 @@ interface TreeQuery {
|
|
|
108
108
|
/**
|
|
109
109
|
* Data preview query
|
|
110
110
|
*/
|
|
111
|
-
interface
|
|
111
|
+
interface PreviewSQL {
|
|
112
112
|
/** Object name (table or CDS view) */
|
|
113
113
|
objectName: string;
|
|
114
114
|
/** Object type ('table' or 'view') */
|
|
@@ -311,6 +311,53 @@ interface ColumnInfo {
|
|
|
311
311
|
label?: string;
|
|
312
312
|
}
|
|
313
313
|
|
|
314
|
+
/**
|
|
315
|
+
* Query Builder — Optional helper for building SQL queries for data preview
|
|
316
|
+
*/
|
|
317
|
+
|
|
318
|
+
type BasicFilter = {
|
|
319
|
+
type: "basic";
|
|
320
|
+
field: string;
|
|
321
|
+
value: string | number;
|
|
322
|
+
operator: "=" | "<>" | "<" | "<=" | ">" | ">=" | "like" | "not like";
|
|
323
|
+
};
|
|
324
|
+
type BetweenFilter = {
|
|
325
|
+
type: "between";
|
|
326
|
+
field: string;
|
|
327
|
+
minimum: string | number;
|
|
328
|
+
maximum: string | number;
|
|
329
|
+
};
|
|
330
|
+
type ListFilter = {
|
|
331
|
+
type: "list";
|
|
332
|
+
field: string;
|
|
333
|
+
values: (string | number)[];
|
|
334
|
+
include: boolean;
|
|
335
|
+
};
|
|
336
|
+
type QueryFilter = BasicFilter | BetweenFilter | ListFilter;
|
|
337
|
+
type Sorting = {
|
|
338
|
+
field: string;
|
|
339
|
+
direction: "ascending" | "descending";
|
|
340
|
+
};
|
|
341
|
+
type Aggregation = {
|
|
342
|
+
field: string;
|
|
343
|
+
function: "count" | "sum" | "avg" | "min" | "max";
|
|
344
|
+
};
|
|
345
|
+
type Parameter = {
|
|
346
|
+
name: string;
|
|
347
|
+
value: string | number;
|
|
348
|
+
};
|
|
349
|
+
type DataPreviewQuery = {
|
|
350
|
+
objectName: string;
|
|
351
|
+
objectType: 'table' | 'view';
|
|
352
|
+
limit?: number;
|
|
353
|
+
fields: string[];
|
|
354
|
+
parameters?: Parameter[];
|
|
355
|
+
filters?: QueryFilter[];
|
|
356
|
+
sortings?: Sorting[];
|
|
357
|
+
aggregations?: Aggregation[];
|
|
358
|
+
};
|
|
359
|
+
declare function buildSQLQuery(query: DataPreviewQuery): Result<PreviewSQL>;
|
|
360
|
+
|
|
314
361
|
/**
|
|
315
362
|
* Distinct Values — Get distinct column values with counts
|
|
316
363
|
*/
|
|
@@ -430,11 +477,11 @@ interface ADTClient {
|
|
|
430
477
|
upsert(objects: ObjectContent[], packageName: string, transport?: string): AsyncResult<UpsertResult[]>;
|
|
431
478
|
activate(objects: ObjectRef[]): AsyncResult<ActivationResult[]>;
|
|
432
479
|
delete(objects: ObjectRef[], transport?: string): AsyncResult<void>;
|
|
433
|
-
getPackages(): AsyncResult<Package[]>;
|
|
480
|
+
getPackages(filter?: string): AsyncResult<Package[]>;
|
|
434
481
|
getTree(query: TreeQuery): AsyncResult<TreeNode[]>;
|
|
435
482
|
getTransports(packageName: string): AsyncResult<Transport[]>;
|
|
436
|
-
previewData(query:
|
|
437
|
-
getDistinctValues(objectName: string, column: string, objectType?: 'table' | 'view'): AsyncResult<DistinctResult>;
|
|
483
|
+
previewData(query: PreviewSQL): AsyncResult<DataFrame>;
|
|
484
|
+
getDistinctValues(objectName: string, parameters: Parameter[], column: string, objectType?: 'table' | 'view'): AsyncResult<DistinctResult>;
|
|
438
485
|
countRows(objectName: string, objectType: 'table' | 'view'): AsyncResult<number>;
|
|
439
486
|
search(query: string, types?: string[]): AsyncResult<SearchResult[]>;
|
|
440
487
|
whereUsed(object: ObjectRef): AsyncResult<Dependency[]>;
|
|
@@ -444,4 +491,4 @@ interface ADTClient {
|
|
|
444
491
|
}
|
|
445
492
|
declare function createClient(config: ClientConfig): Result<ADTClient, Error>;
|
|
446
493
|
|
|
447
|
-
export { type ADTClient, type ActivationMessage, type ActivationResult, type ApiResponse, type AsyncResult, type AuthConfig, type AuthType, type BasicAuthConfig, type ClientConfig, type ColumnInfo, type DataFrame, type Dependency, type DiffResult, type DistinctResult, type ErrorCode, type ErrorResponse, type ObjectConfig, type ObjectContent, type ObjectMetadata, type ObjectRef, type ObjectWithContent, type Package, type
|
|
494
|
+
export { type ADTClient, type ActivationMessage, type ActivationResult, type Aggregation, type ApiResponse, type AsyncResult, type AuthConfig, type AuthType, type BasicAuthConfig, type BasicFilter, type BetweenFilter, type ClientConfig, type ColumnInfo, type DataFrame, type DataPreviewQuery, type Dependency, type DiffResult, type DistinctResult, type ErrorCode, type ErrorResponse, type ListFilter, type ObjectConfig, type ObjectContent, type ObjectMetadata, type ObjectRef, type ObjectWithContent, type Package, type Parameter, type PreviewSQL, type QueryFilter, type Result, type SamlAuthConfig, type SearchResult, type Session, type Sorting, type SsoAuthConfig, type SuccessResponse, type Transport, type TransportConfig, type TreeNode, type TreeQuery, type UpsertResult, buildSQLQuery, createClient, err, ok };
|
package/dist/index.js
CHANGED
|
@@ -30,6 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
|
+
buildSQLQuery: () => buildSQLQuery,
|
|
33
34
|
createClient: () => createClient,
|
|
34
35
|
err: () => err,
|
|
35
36
|
ok: () => ok
|
|
@@ -173,6 +174,11 @@ function debugError(message, cause) {
|
|
|
173
174
|
}
|
|
174
175
|
}
|
|
175
176
|
|
|
177
|
+
// src/core/utils/content.ts
|
|
178
|
+
function normalizeContent(content) {
|
|
179
|
+
return content.replace(/\s+/g, " ").trim();
|
|
180
|
+
}
|
|
181
|
+
|
|
176
182
|
// src/types/config.ts
|
|
177
183
|
var import_zod = require("zod");
|
|
178
184
|
var samlFormSelectorsSchema = import_zod.z.object({
|
|
@@ -404,7 +410,7 @@ function requireConfig(extension) {
|
|
|
404
410
|
return [config, null];
|
|
405
411
|
}
|
|
406
412
|
|
|
407
|
-
// src/core/adt/read.ts
|
|
413
|
+
// src/core/adt/craud/read.ts
|
|
408
414
|
async function readObject(client, object) {
|
|
409
415
|
const [config, configErr] = requireConfig(object.extension);
|
|
410
416
|
if (configErr) return err(configErr);
|
|
@@ -428,7 +434,7 @@ async function readObject(client, object) {
|
|
|
428
434
|
return ok(result);
|
|
429
435
|
}
|
|
430
436
|
|
|
431
|
-
// src/core/adt/lock.ts
|
|
437
|
+
// src/core/adt/craud/lock.ts
|
|
432
438
|
async function lockObject(client, object) {
|
|
433
439
|
const [config, configErr] = requireConfig(object.extension);
|
|
434
440
|
if (configErr) return err(configErr);
|
|
@@ -476,7 +482,7 @@ async function unlockObject(client, object, lockHandle) {
|
|
|
476
482
|
return ok(void 0);
|
|
477
483
|
}
|
|
478
484
|
|
|
479
|
-
// src/core/adt/create.ts
|
|
485
|
+
// src/core/adt/craud/create.ts
|
|
480
486
|
async function createObject(client, object, packageName, transport, username) {
|
|
481
487
|
const [config, configErr] = requireConfig(object.extension);
|
|
482
488
|
if (configErr) return err(configErr);
|
|
@@ -513,7 +519,7 @@ async function createObject(client, object, packageName, transport, username) {
|
|
|
513
519
|
return ok(void 0);
|
|
514
520
|
}
|
|
515
521
|
|
|
516
|
-
// src/core/adt/update.ts
|
|
522
|
+
// src/core/adt/craud/update.ts
|
|
517
523
|
async function updateObject(client, object, lockHandle, transport) {
|
|
518
524
|
const [config, configErr] = requireConfig(object.extension);
|
|
519
525
|
if (configErr) return err(configErr);
|
|
@@ -541,7 +547,7 @@ async function updateObject(client, object, lockHandle, transport) {
|
|
|
541
547
|
return ok(void 0);
|
|
542
548
|
}
|
|
543
549
|
|
|
544
|
-
// src/core/adt/delete.ts
|
|
550
|
+
// src/core/adt/craud/delete.ts
|
|
545
551
|
async function deleteObject(client, object, lockHandle, transport) {
|
|
546
552
|
const [config, configErr] = requireConfig(object.extension);
|
|
547
553
|
if (configErr) return err(configErr);
|
|
@@ -566,7 +572,7 @@ async function deleteObject(client, object, lockHandle, transport) {
|
|
|
566
572
|
return ok(void 0);
|
|
567
573
|
}
|
|
568
574
|
|
|
569
|
-
// src/core/adt/activation.ts
|
|
575
|
+
// src/core/adt/craud/activation.ts
|
|
570
576
|
async function activateObjects(client, objects) {
|
|
571
577
|
if (objects.length === 0) {
|
|
572
578
|
return ok([]);
|
|
@@ -676,7 +682,7 @@ function extractActivationErrors(objects, xml, _extension) {
|
|
|
676
682
|
return ok(results);
|
|
677
683
|
}
|
|
678
684
|
|
|
679
|
-
// src/core/adt/tree.ts
|
|
685
|
+
// src/core/adt/discovery/tree.ts
|
|
680
686
|
async function getTree(client, query) {
|
|
681
687
|
const internalQuery = {};
|
|
682
688
|
if (query.package) {
|
|
@@ -793,16 +799,16 @@ function parseTreeResponse(xml) {
|
|
|
793
799
|
return ok({ nodes, packages });
|
|
794
800
|
}
|
|
795
801
|
|
|
796
|
-
// src/core/adt/packages.ts
|
|
797
|
-
async function getPackages(client) {
|
|
798
|
-
const [treeResult, treeErr] = await getTreeInternal(client, {},
|
|
802
|
+
// src/core/adt/discovery/packages.ts
|
|
803
|
+
async function getPackages(client, filter = "*") {
|
|
804
|
+
const [treeResult, treeErr] = await getTreeInternal(client, {}, filter);
|
|
799
805
|
if (treeErr) {
|
|
800
806
|
return err(treeErr);
|
|
801
807
|
}
|
|
802
808
|
return ok(treeResult.packages);
|
|
803
809
|
}
|
|
804
810
|
|
|
805
|
-
// src/core/adt/transports.ts
|
|
811
|
+
// src/core/adt/transports/transports.ts
|
|
806
812
|
async function getTransports(client, packageName) {
|
|
807
813
|
const contentType = "application/vnd.sap.as+xml; charset=UTF-8; dataname=com.sap.adt.transport.service.checkData";
|
|
808
814
|
const body = `<?xml version="1.0" encoding="UTF-8"?>
|
|
@@ -871,7 +877,7 @@ function extractTransports(xml) {
|
|
|
871
877
|
return ok(transports);
|
|
872
878
|
}
|
|
873
879
|
|
|
874
|
-
// src/core/adt/previewParser.ts
|
|
880
|
+
// src/core/adt/data_extraction/previewParser.ts
|
|
875
881
|
function parseDataPreview(xml, maxRows, isTable) {
|
|
876
882
|
const [doc, parseErr] = safeParseXml(xml);
|
|
877
883
|
if (parseErr) {
|
|
@@ -930,7 +936,7 @@ function parseDataPreview(xml, maxRows, isTable) {
|
|
|
930
936
|
return ok(dataFrame);
|
|
931
937
|
}
|
|
932
938
|
|
|
933
|
-
// src/core/adt/dataPreview.ts
|
|
939
|
+
// src/core/adt/data_extraction/dataPreview.ts
|
|
934
940
|
async function previewData(client, query) {
|
|
935
941
|
const extension = query.objectType === "table" ? "astabldt" : "asddls";
|
|
936
942
|
const config = getConfigByExtension(extension);
|
|
@@ -970,11 +976,83 @@ async function previewData(client, query) {
|
|
|
970
976
|
return ok(dataFrame);
|
|
971
977
|
}
|
|
972
978
|
|
|
973
|
-
// src/core/adt/
|
|
979
|
+
// src/core/adt/data_extraction/queryBuilder.ts
|
|
980
|
+
function quoteString(value) {
|
|
981
|
+
return typeof value == "string" ? "'" + value + "'" : "" + value;
|
|
982
|
+
}
|
|
983
|
+
function basicFilterToWhere(filter) {
|
|
984
|
+
return `${filter.field} ${filter.operator} ${quoteString(filter.value)}`;
|
|
985
|
+
}
|
|
986
|
+
function betweenFilterToWhere(filter) {
|
|
987
|
+
return `${filter.field} between ${quoteString(filter.minimum)} and ${quoteString(filter.maximum)}`;
|
|
988
|
+
}
|
|
989
|
+
function listFilterToWhere(filter) {
|
|
990
|
+
return `${filter.field} ${filter.include ? "" : "not "}in ( ${filter.values.map(quoteString).join(", ")} )`;
|
|
991
|
+
}
|
|
992
|
+
function queryFilterToWhere(filter) {
|
|
993
|
+
if (filter.type === "list") return listFilterToWhere(filter);
|
|
994
|
+
if (filter.type === "between") return betweenFilterToWhere(filter);
|
|
995
|
+
return basicFilterToWhere(filter);
|
|
996
|
+
}
|
|
997
|
+
function queryFiltersToWhere(filters) {
|
|
998
|
+
if (filters.length === 0) return "";
|
|
999
|
+
return `
|
|
1000
|
+
where ${filters.map(queryFilterToWhere).join(" and ")}`;
|
|
1001
|
+
}
|
|
1002
|
+
function sortingsToOrderBy(sortings) {
|
|
1003
|
+
if (sortings.length === 0) return "";
|
|
1004
|
+
return `
|
|
1005
|
+
order by ${sortings.map((s) => `${s.field} ${s.direction}`).join(", ")}`;
|
|
1006
|
+
}
|
|
1007
|
+
function fieldsToGroupbyClause(fields) {
|
|
1008
|
+
if (fields.length === 0) return "";
|
|
1009
|
+
return `
|
|
1010
|
+
group by ${fields.join(", ")}`;
|
|
1011
|
+
}
|
|
1012
|
+
function aggregationToFieldDefinition(aggregation) {
|
|
1013
|
+
if (aggregation.function === "count") {
|
|
1014
|
+
return `count( distinct main~${aggregation.field} ) as ${aggregation.field}`;
|
|
1015
|
+
}
|
|
1016
|
+
return `${aggregation.function}( main~${aggregation.field} ) as ${aggregation.field}`;
|
|
1017
|
+
}
|
|
1018
|
+
function parametersToSQLParams(params) {
|
|
1019
|
+
if (params.length === 0) return "";
|
|
1020
|
+
return `( ${params.map((p) => `${p.name} = ${quoteString(p.value)}`).join(", ")})`;
|
|
1021
|
+
}
|
|
1022
|
+
function buildSQLQuery(query) {
|
|
1023
|
+
const [parameters, filters, sortings, aggregations] = [query.parameters ?? [], query.filters ?? [], query.sortings ?? [], query.aggregations ?? []];
|
|
1024
|
+
const groupingFields = query.fields.filter((f) => !aggregations.find((a) => a.field === f));
|
|
1025
|
+
if (sortings.filter((s) => !query.fields.includes(s.field)).length > 0) {
|
|
1026
|
+
return err(new Error("Sorting fields must be included in the selected fields."));
|
|
1027
|
+
}
|
|
1028
|
+
let selectClause = "select\n";
|
|
1029
|
+
const fieldSelections = [];
|
|
1030
|
+
for (const field of query.fields) {
|
|
1031
|
+
const aggregation = aggregations.find((a) => a.field === field);
|
|
1032
|
+
if (aggregation) {
|
|
1033
|
+
fieldSelections.push(` ${aggregationToFieldDefinition(aggregation)}`);
|
|
1034
|
+
continue;
|
|
1035
|
+
}
|
|
1036
|
+
fieldSelections.push(` main~${field}`);
|
|
1037
|
+
}
|
|
1038
|
+
selectClause += fieldSelections.join(",\n") + `
|
|
1039
|
+
from ${query.objectName}${parametersToSQLParams(parameters)} as main
|
|
1040
|
+
`;
|
|
1041
|
+
const [whereClause, groupbyClause, orderbyClause] = [queryFiltersToWhere(filters), aggregations.length ? fieldsToGroupbyClause(groupingFields) : "", sortingsToOrderBy(sortings)];
|
|
1042
|
+
const result = {
|
|
1043
|
+
objectName: query.objectName,
|
|
1044
|
+
objectType: query.objectType,
|
|
1045
|
+
sqlQuery: `${selectClause}${whereClause}${groupbyClause}${orderbyClause}`
|
|
1046
|
+
};
|
|
1047
|
+
if (query.limit !== void 0) result.limit = query.limit;
|
|
1048
|
+
return ok(result);
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
// src/core/adt/data_extraction/distinct.ts
|
|
974
1052
|
var MAX_ROW_COUNT = 5e4;
|
|
975
|
-
async function getDistinctValues(client, objectName, column, objectType = "view") {
|
|
1053
|
+
async function getDistinctValues(client, objectName, parameters, column, objectType = "view") {
|
|
976
1054
|
const columnName = column.toUpperCase();
|
|
977
|
-
const sqlQuery = `SELECT ${columnName} AS value, COUNT(*) AS
|
|
1055
|
+
const sqlQuery = `SELECT ${columnName} AS value, COUNT(*) AS ValueCount FROM ${objectName}${parametersToSQLParams(parameters)} GROUP BY ${columnName} ORDER BY ValueCount DESCENDING`;
|
|
978
1056
|
const [dataFrame, error] = await previewData(client, {
|
|
979
1057
|
objectName,
|
|
980
1058
|
objectType,
|
|
@@ -991,7 +1069,7 @@ async function getDistinctValues(client, objectName, column, objectType = "view"
|
|
|
991
1069
|
return ok({ column, values });
|
|
992
1070
|
}
|
|
993
1071
|
|
|
994
|
-
// src/core/adt/count.ts
|
|
1072
|
+
// src/core/adt/data_extraction/count.ts
|
|
995
1073
|
async function countRows(client, objectName, objectType) {
|
|
996
1074
|
const sqlQuery = `SELECT COUNT(*) AS count FROM ${objectName}`;
|
|
997
1075
|
const [dataFrame, error] = await previewData(client, {
|
|
@@ -1014,7 +1092,7 @@ async function countRows(client, objectName, objectType) {
|
|
|
1014
1092
|
return ok(count);
|
|
1015
1093
|
}
|
|
1016
1094
|
|
|
1017
|
-
// src/core/adt/searchObjects.ts
|
|
1095
|
+
// src/core/adt/discovery/searchObjects.ts
|
|
1018
1096
|
async function searchObjects(client, query, types) {
|
|
1019
1097
|
const searchPattern = query || "*";
|
|
1020
1098
|
const objectTypes = types && types.length > 0 ? types : getAllTypes();
|
|
@@ -1081,7 +1159,7 @@ function parseSearchResults(xml) {
|
|
|
1081
1159
|
return ok(results);
|
|
1082
1160
|
}
|
|
1083
1161
|
|
|
1084
|
-
// src/core/adt/whereUsed.ts
|
|
1162
|
+
// src/core/adt/discovery/whereUsed.ts
|
|
1085
1163
|
async function findWhereUsed(client, object) {
|
|
1086
1164
|
const config = getConfigByExtension(object.extension);
|
|
1087
1165
|
if (!config) {
|
|
@@ -1155,7 +1233,7 @@ function parseWhereUsed(xml) {
|
|
|
1155
1233
|
return ok(dependencies);
|
|
1156
1234
|
}
|
|
1157
1235
|
|
|
1158
|
-
// src/core/adt/createTransport.ts
|
|
1236
|
+
// src/core/adt/transports/createTransport.ts
|
|
1159
1237
|
async function createTransport(client, config) {
|
|
1160
1238
|
const body = dictToAbapXml({
|
|
1161
1239
|
DEVCLASS: config.package,
|
|
@@ -1186,7 +1264,7 @@ async function createTransport(client, config) {
|
|
|
1186
1264
|
return ok(transportId);
|
|
1187
1265
|
}
|
|
1188
1266
|
|
|
1189
|
-
// src/core/adt/gitDiff.ts
|
|
1267
|
+
// src/core/adt/craud/gitDiff.ts
|
|
1190
1268
|
var import_diff = require("diff");
|
|
1191
1269
|
function computeDiff(serverLines, localLines) {
|
|
1192
1270
|
const changes = (0, import_diff.diffArrays)(serverLines, localLines);
|
|
@@ -1947,6 +2025,9 @@ var ADTClientImpl = class {
|
|
|
1947
2025
|
if (this.agent) {
|
|
1948
2026
|
fetchOptions.dispatcher = this.agent;
|
|
1949
2027
|
}
|
|
2028
|
+
if (config.insecure) {
|
|
2029
|
+
fetchOptions.tls = { rejectUnauthorized: false };
|
|
2030
|
+
}
|
|
1950
2031
|
if (body) {
|
|
1951
2032
|
fetchOptions.body = body;
|
|
1952
2033
|
}
|
|
@@ -2087,6 +2168,18 @@ var ADTClientImpl = class {
|
|
|
2087
2168
|
results.push(result2);
|
|
2088
2169
|
continue;
|
|
2089
2170
|
}
|
|
2171
|
+
const serverContent = normalizeContent(existing.content);
|
|
2172
|
+
const localContent = normalizeContent(obj.content);
|
|
2173
|
+
if (serverContent === localContent) {
|
|
2174
|
+
const result2 = {
|
|
2175
|
+
name: obj.name,
|
|
2176
|
+
extension: obj.extension,
|
|
2177
|
+
status: "unchanged"
|
|
2178
|
+
};
|
|
2179
|
+
if (transport) result2.transport = transport;
|
|
2180
|
+
results.push(result2);
|
|
2181
|
+
continue;
|
|
2182
|
+
}
|
|
2090
2183
|
const [, updateErr] = await this.update(obj, transport);
|
|
2091
2184
|
if (updateErr) return err(updateErr);
|
|
2092
2185
|
const result = {
|
|
@@ -2117,9 +2210,9 @@ var ADTClientImpl = class {
|
|
|
2117
2210
|
return ok(void 0);
|
|
2118
2211
|
}
|
|
2119
2212
|
// --- Discovery ---
|
|
2120
|
-
async getPackages() {
|
|
2213
|
+
async getPackages(filter) {
|
|
2121
2214
|
if (!this.state.session) return err(new Error("Not logged in"));
|
|
2122
|
-
return getPackages(this.requestor);
|
|
2215
|
+
return getPackages(this.requestor, filter);
|
|
2123
2216
|
}
|
|
2124
2217
|
async getTree(query) {
|
|
2125
2218
|
if (!this.state.session) return err(new Error("Not logged in"));
|
|
@@ -2134,9 +2227,9 @@ var ADTClientImpl = class {
|
|
|
2134
2227
|
if (!this.state.session) return err(new Error("Not logged in"));
|
|
2135
2228
|
return previewData(this.requestor, query);
|
|
2136
2229
|
}
|
|
2137
|
-
async getDistinctValues(objectName, column, objectType = "view") {
|
|
2230
|
+
async getDistinctValues(objectName, parameters, column, objectType = "view") {
|
|
2138
2231
|
if (!this.state.session) return err(new Error("Not logged in"));
|
|
2139
|
-
return getDistinctValues(this.requestor, objectName, column, objectType);
|
|
2232
|
+
return getDistinctValues(this.requestor, objectName, parameters, column, objectType);
|
|
2140
2233
|
}
|
|
2141
2234
|
async countRows(objectName, objectType) {
|
|
2142
2235
|
if (!this.state.session) return err(new Error("Not logged in"));
|
|
@@ -2181,20 +2274,9 @@ function createClient(config) {
|
|
|
2181
2274
|
}
|
|
2182
2275
|
return ok(new ADTClientImpl(config));
|
|
2183
2276
|
}
|
|
2184
|
-
|
|
2185
|
-
// src/core/config.ts
|
|
2186
|
-
var import_node_fs = require("fs");
|
|
2187
|
-
var import_zod2 = require("zod");
|
|
2188
|
-
var systemConfigSchema = import_zod2.z.record(
|
|
2189
|
-
import_zod2.z.string(),
|
|
2190
|
-
import_zod2.z.object({
|
|
2191
|
-
adt: import_zod2.z.string().url().optional(),
|
|
2192
|
-
odata: import_zod2.z.string().url().optional(),
|
|
2193
|
-
instance_num: import_zod2.z.string().optional()
|
|
2194
|
-
})
|
|
2195
|
-
);
|
|
2196
2277
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2197
2278
|
0 && (module.exports = {
|
|
2279
|
+
buildSQLQuery,
|
|
2198
2280
|
createClient,
|
|
2199
2281
|
err,
|
|
2200
2282
|
ok
|