@babamba2/abap-mcp-adt-powerup 4.6.0 → 4.7.0

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.
Files changed (83) hide show
  1. package/dist/handlers/common/high/handleActivateObjects.d.ts +81 -0
  2. package/dist/handlers/common/high/handleActivateObjects.d.ts.map +1 -0
  3. package/dist/handlers/common/high/handleActivateObjects.js +123 -0
  4. package/dist/handlers/common/high/handleActivateObjects.js.map +1 -0
  5. package/dist/handlers/common/low/handleActivateObject.d.ts.map +1 -1
  6. package/dist/handlers/common/low/handleActivateObject.js +30 -27
  7. package/dist/handlers/common/low/handleActivateObject.js.map +1 -1
  8. package/dist/handlers/gui_status/high/handlePatchGuiStatus.d.ts +57 -0
  9. package/dist/handlers/gui_status/high/handlePatchGuiStatus.d.ts.map +1 -0
  10. package/dist/handlers/gui_status/high/handlePatchGuiStatus.js +216 -0
  11. package/dist/handlers/gui_status/high/handlePatchGuiStatus.js.map +1 -0
  12. package/dist/handlers/gui_status/high/handleUpdateGuiStatus.d.ts +11 -3
  13. package/dist/handlers/gui_status/high/handleUpdateGuiStatus.d.ts.map +1 -1
  14. package/dist/handlers/gui_status/high/handleUpdateGuiStatus.js +39 -6
  15. package/dist/handlers/gui_status/high/handleUpdateGuiStatus.js.map +1 -1
  16. package/dist/handlers/include/high/handleCreateInclude.d.ts +13 -1
  17. package/dist/handlers/include/high/handleCreateInclude.d.ts.map +1 -1
  18. package/dist/handlers/include/high/handleCreateInclude.js +127 -29
  19. package/dist/handlers/include/high/handleCreateInclude.js.map +1 -1
  20. package/dist/handlers/system/readonly/handleRuntimeGetDumpById.d.ts +8 -1
  21. package/dist/handlers/system/readonly/handleRuntimeGetDumpById.d.ts.map +1 -1
  22. package/dist/handlers/system/readonly/handleRuntimeGetDumpById.js +72 -8
  23. package/dist/handlers/system/readonly/handleRuntimeGetDumpById.js.map +1 -1
  24. package/dist/handlers/system/readonly/handleRuntimeGetGatewayErrorLog.d.ts +48 -0
  25. package/dist/handlers/system/readonly/handleRuntimeGetGatewayErrorLog.d.ts.map +1 -0
  26. package/dist/handlers/system/readonly/handleRuntimeGetGatewayErrorLog.js +81 -0
  27. package/dist/handlers/system/readonly/handleRuntimeGetGatewayErrorLog.js.map +1 -0
  28. package/dist/handlers/system/readonly/handleRuntimeListFeeds.d.ts +50 -0
  29. package/dist/handlers/system/readonly/handleRuntimeListFeeds.d.ts.map +1 -0
  30. package/dist/handlers/system/readonly/handleRuntimeListFeeds.js +104 -0
  31. package/dist/handlers/system/readonly/handleRuntimeListFeeds.js.map +1 -0
  32. package/dist/handlers/system/readonly/handleRuntimeListSystemMessages.d.ts +43 -0
  33. package/dist/handlers/system/readonly/handleRuntimeListSystemMessages.d.ts.map +1 -0
  34. package/dist/handlers/system/readonly/handleRuntimeListSystemMessages.js +61 -0
  35. package/dist/handlers/system/readonly/handleRuntimeListSystemMessages.js.map +1 -0
  36. package/dist/handlers/system/readonly/runtimeFeedsHelper.d.ts +165 -0
  37. package/dist/handlers/system/readonly/runtimeFeedsHelper.d.ts.map +1 -0
  38. package/dist/handlers/system/readonly/runtimeFeedsHelper.js +399 -0
  39. package/dist/handlers/system/readonly/runtimeFeedsHelper.js.map +1 -0
  40. package/dist/handlers/text_element/high/handleReadTextElementsBulk.d.ts +41 -0
  41. package/dist/handlers/text_element/high/handleReadTextElementsBulk.d.ts.map +1 -0
  42. package/dist/handlers/text_element/high/handleReadTextElementsBulk.js +104 -0
  43. package/dist/handlers/text_element/high/handleReadTextElementsBulk.js.map +1 -0
  44. package/dist/handlers/text_element/high/handleWriteTextElementsBulk.d.ts +87 -0
  45. package/dist/handlers/text_element/high/handleWriteTextElementsBulk.d.ts.map +1 -0
  46. package/dist/handlers/text_element/high/handleWriteTextElementsBulk.js +210 -0
  47. package/dist/handlers/text_element/high/handleWriteTextElementsBulk.js.map +1 -0
  48. package/dist/lib/cuaSchema.d.ts +113 -0
  49. package/dist/lib/cuaSchema.d.ts.map +1 -0
  50. package/dist/lib/cuaSchema.js +208 -0
  51. package/dist/lib/cuaSchema.js.map +1 -0
  52. package/dist/lib/gatewayRfc.d.ts +1 -1
  53. package/dist/lib/gatewayRfc.d.ts.map +1 -1
  54. package/dist/lib/gatewayRfc.js.map +1 -1
  55. package/dist/lib/handlers/groups/HighLevelHandlersGroup.d.ts.map +1 -1
  56. package/dist/lib/handlers/groups/HighLevelHandlersGroup.js +20 -0
  57. package/dist/lib/handlers/groups/HighLevelHandlersGroup.js.map +1 -1
  58. package/dist/lib/handlers/groups/SystemHandlersGroup.d.ts.map +1 -1
  59. package/dist/lib/handlers/groups/SystemHandlersGroup.js +15 -0
  60. package/dist/lib/handlers/groups/SystemHandlersGroup.js.map +1 -1
  61. package/dist/lib/localGroupActivation.d.ts +88 -0
  62. package/dist/lib/localGroupActivation.d.ts.map +1 -0
  63. package/dist/lib/localGroupActivation.js +271 -0
  64. package/dist/lib/localGroupActivation.js.map +1 -0
  65. package/dist/lib/nativeRfc.d.ts +1 -1
  66. package/dist/lib/nativeRfc.d.ts.map +1 -1
  67. package/dist/lib/nativeRfc.js.map +1 -1
  68. package/dist/lib/odataRfc.d.ts +1 -1
  69. package/dist/lib/odataRfc.d.ts.map +1 -1
  70. package/dist/lib/odataRfc.js.map +1 -1
  71. package/dist/lib/resolveAdtUri.d.ts +35 -0
  72. package/dist/lib/resolveAdtUri.d.ts.map +1 -0
  73. package/dist/lib/resolveAdtUri.js +121 -0
  74. package/dist/lib/resolveAdtUri.js.map +1 -0
  75. package/dist/lib/soapRfc.d.ts +5 -2
  76. package/dist/lib/soapRfc.d.ts.map +1 -1
  77. package/dist/lib/soapRfc.js +4 -1
  78. package/dist/lib/soapRfc.js.map +1 -1
  79. package/dist/lib/textElementsSource.d.ts +81 -0
  80. package/dist/lib/textElementsSource.d.ts.map +1 -0
  81. package/dist/lib/textElementsSource.js +184 -0
  82. package/dist/lib/textElementsSource.js.map +1 -0
  83. package/package.json +1 -1
@@ -0,0 +1,104 @@
1
+ "use strict";
2
+ /**
3
+ * ReadTextElementsBulk — return every text element of a program in ONE call.
4
+ *
5
+ * Matches WriteTextElementsBulk semantics: we read the whole TPOOL via the
6
+ * `ZMCP_ADT_TEXTPOOL` RFC (single SAP round-trip) and partition the rows
7
+ * by ID (R / I / S / H). The native /textelements subsource endpoints
8
+ * exist but only surface the editor-view of I/S/H and don't expose R at
9
+ * all, so using TPOOL RFC directly keeps this tool aligned with the
10
+ * WriteTextElementsBulk storage path and exposes every type uniformly.
11
+ *
12
+ * Existing single-row GetTextElement stays row-by-row for callers that
13
+ * want one entry.
14
+ */
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.TOOL_DEFINITION = void 0;
17
+ exports.handleReadTextElementsBulk = handleReadTextElementsBulk;
18
+ const rfcBackend_1 = require("../../../lib/rfcBackend");
19
+ const utils_1 = require("../../../lib/utils");
20
+ exports.TOOL_DEFINITION = {
21
+ name: 'ReadTextElementsBulk',
22
+ available_in: ['onprem', 'legacy'],
23
+ description: 'Read every text element (R/I/S/H) of a program in ONE call via the TPOOL RFC. Partitions rows by type and returns structured arrays. Use this instead of calling GetTextElement per row.',
24
+ inputSchema: {
25
+ type: 'object',
26
+ properties: {
27
+ program_name: { type: 'string', description: 'Program name.' },
28
+ language: {
29
+ type: 'string',
30
+ description: '1-char language. Defaults to SAP logon language.',
31
+ },
32
+ },
33
+ required: ['program_name'],
34
+ },
35
+ };
36
+ async function handleReadTextElementsBulk(context, params) {
37
+ const { connection, logger } = context;
38
+ const args = params;
39
+ if (!args?.program_name) {
40
+ return (0, utils_1.return_error)(new Error('program_name is required'));
41
+ }
42
+ if ((0, utils_1.isCloudConnection)()) {
43
+ return (0, utils_1.return_error)(new Error('Text elements are not available on ABAP Cloud'));
44
+ }
45
+ const programName = args.program_name.toUpperCase();
46
+ const language = (args.language || '').toUpperCase();
47
+ logger?.info(`ReadTextElementsBulk: ${programName}`);
48
+ try {
49
+ const { result: fetched } = await (0, rfcBackend_1.callTextpool)(connection, 'READ', {
50
+ program: programName,
51
+ language,
52
+ });
53
+ const raw = Array.isArray(fetched) ? fetched : [];
54
+ const bucket = {
55
+ R: [],
56
+ I: [],
57
+ S: [],
58
+ H: [],
59
+ };
60
+ let rEntry = null;
61
+ for (const r of raw) {
62
+ const id = String(r?.ID ?? r?.id ?? '').toUpperCase();
63
+ const key = String(r?.KEY ?? r?.key ?? '');
64
+ const text = String(r?.ENTRY ?? r?.entry ?? '');
65
+ const length = Number(r?.LENGTH ?? r?.length ?? 0);
66
+ if (id !== 'R' && id !== 'I' && id !== 'S' && id !== 'H')
67
+ continue;
68
+ bucket[id].push({ type: id, key, text, length });
69
+ if (id === 'R')
70
+ rEntry = { text, length };
71
+ }
72
+ return (0, utils_1.return_response)({
73
+ data: JSON.stringify({
74
+ success: true,
75
+ program_name: programName,
76
+ language: language || null,
77
+ counts: {
78
+ R: bucket.R.length,
79
+ I: bucket.I.length,
80
+ S: bucket.S.length,
81
+ H: bucket.H.length,
82
+ total: raw.length,
83
+ },
84
+ r: rEntry,
85
+ symbols: bucket.I.map((e) => ({ key: e.key, text: e.text })),
86
+ selections: bucket.S.map((e) => ({
87
+ key: e.key.trim(),
88
+ text: e.text,
89
+ })),
90
+ headings: bucket.H.map((e) => ({ key: e.key, text: e.text })),
91
+ }, null, 2),
92
+ status: 200,
93
+ statusText: 'OK',
94
+ headers: {},
95
+ config: {},
96
+ });
97
+ }
98
+ catch (error) {
99
+ const errorMessage = error instanceof Error ? error.message : String(error);
100
+ logger?.error(`ReadTextElementsBulk failed: ${errorMessage}`);
101
+ return (0, utils_1.return_error)(new Error(`ReadTextElementsBulk failed: ${errorMessage}`));
102
+ }
103
+ }
104
+ //# sourceMappingURL=handleReadTextElementsBulk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handleReadTextElementsBulk.js","sourceRoot":"","sources":["../../../../src/handlers/text_element/high/handleReadTextElementsBulk.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;;AAyCH,gEAkFC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AAgC,YAAY,EAAE,CAAC,CAAC;QAC9D,OAAO,IAAA,oBAAY,EACjB,IAAI,KAAK,CAAC,gCAAgC,YAAY,EAAE,CAAC,CAC1D,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -0,0 +1,87 @@
1
+ /**
2
+ * WriteTextElementsBulk — register many text elements in a SINGLE call.
3
+ *
4
+ * Previously a 40-element load meant 40 separate tool invocations of
5
+ * CreateTextElement, each doing its own LOCK / RFC READ / RFC WRITE /
6
+ * UNLOCK cycle → 160+ round-trips and a read-then-write race when
7
+ * parallelized. This handler folds every entry (R / I / S / H) into a
8
+ * single `ZMCP_ADT_TEXTPOOL` RFC call.
9
+ *
10
+ * SAP's native pattern for TPOOL is a whole-pool INSERT (what SE38 → GoTo
11
+ * → Text Elements does internally). We follow the same pattern:
12
+ *
13
+ * activate=true → RFC action 'WRITE' (INSERT TEXTPOOL STATE 'A')
14
+ * Pool is written active immediately.
15
+ * activate=false → RFC action 'WRITE_INACTIVE' (INSERT TEXTPOOL STATE 'I')
16
+ * Pool is staged inactive; the next activation of the
17
+ * parent program promotes it atomically — every R / I /
18
+ * S / H entry goes live together, matching the user's
19
+ * "register 40 now, activate program later" flow.
20
+ *
21
+ * replace_existing=false re-reads the current pool first and merges the
22
+ * caller's entries by (ID, KEY) so nothing outside the caller's set is
23
+ * wiped.
24
+ *
25
+ * Existing CreateTextElement / UpdateTextElement tools remain untouched.
26
+ */
27
+ import type { HandlerContext } from '../../../lib/handlers/interfaces';
28
+ export declare const TOOL_DEFINITION: {
29
+ readonly name: "WriteTextElementsBulk";
30
+ readonly available_in: readonly ["onprem", "legacy"];
31
+ readonly description: "Register many ABAP text elements (R/I/S/H) in ONE tool call via a single TPOOL RFC write. Use instead of calling CreateTextElement N times. With activate=false (default) the pool is staged INACTIVE — the parent program's next activation promotes every entry atomically, which is the correct flow for \"register 40 now, activate program later\". With activate=true the pool is written ACTIVE immediately. Set replace_existing=false to merge into the current pool instead of replacing it.";
32
+ readonly inputSchema: {
33
+ readonly type: "object";
34
+ readonly properties: {
35
+ readonly program_name: {
36
+ readonly type: "string";
37
+ readonly description: "Parent program name.";
38
+ };
39
+ readonly language: {
40
+ readonly type: "string";
41
+ readonly description: "1-char language key (e.g. \"K\" for Korean). Defaults to SAP logon language.";
42
+ };
43
+ readonly text_elements: {
44
+ readonly type: "array";
45
+ readonly minItems: 1;
46
+ readonly description: "Array of entries. Each: { type: \"R\"|\"I\"|\"S\"|\"H\", key?: string, text: string }. R ignores key (single-row program title — key defaults to program name). I requires a 3-char key. S requires a parameter / select-option name (max 8 chars). H requires one of \"listHeader\" or \"columnHeader_N\".";
47
+ readonly items: {
48
+ readonly type: "object";
49
+ readonly properties: {
50
+ readonly type: {
51
+ readonly type: "string";
52
+ readonly enum: readonly ["R", "I", "S", "H"];
53
+ };
54
+ readonly key: {
55
+ readonly type: "string";
56
+ };
57
+ readonly text: {
58
+ readonly type: "string";
59
+ };
60
+ };
61
+ readonly required: readonly ["type", "text"];
62
+ };
63
+ };
64
+ readonly replace_existing: {
65
+ readonly type: "boolean";
66
+ readonly description: "If true (default), the TPOOL is replaced with the provided entries only. If false, existing rows are preserved and provided rows merge by (type, key).";
67
+ };
68
+ readonly transport_request: {
69
+ readonly type: "string";
70
+ readonly description: "Transport request number (informational).";
71
+ };
72
+ readonly activate: {
73
+ readonly type: "boolean";
74
+ readonly description: "false (default) — stage as INACTIVE (program activation promotes). true — write ACTIVE immediately.";
75
+ };
76
+ };
77
+ readonly required: readonly ["program_name", "text_elements"];
78
+ };
79
+ };
80
+ export declare function handleWriteTextElementsBulk(context: HandlerContext, params: any): Promise<{
81
+ isError: boolean;
82
+ content: {
83
+ type: string;
84
+ text: any;
85
+ }[];
86
+ }>;
87
+ //# sourceMappingURL=handleWriteTextElementsBulk.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handleWriteTextElementsBulk.d.ts","sourceRoot":"","sources":["../../../../src/handlers/text_element/high/handleWriteTextElementsBulk.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAWvE,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiDlB,CAAC;AA6CX,wBAAsB,2BAA2B,CAC/C,OAAO,EAAE,cAAc,EACvB,MAAM,EAAE,GAAG;;;;;;GAqJZ"}
@@ -0,0 +1,210 @@
1
+ "use strict";
2
+ /**
3
+ * WriteTextElementsBulk — register many text elements in a SINGLE call.
4
+ *
5
+ * Previously a 40-element load meant 40 separate tool invocations of
6
+ * CreateTextElement, each doing its own LOCK / RFC READ / RFC WRITE /
7
+ * UNLOCK cycle → 160+ round-trips and a read-then-write race when
8
+ * parallelized. This handler folds every entry (R / I / S / H) into a
9
+ * single `ZMCP_ADT_TEXTPOOL` RFC call.
10
+ *
11
+ * SAP's native pattern for TPOOL is a whole-pool INSERT (what SE38 → GoTo
12
+ * → Text Elements does internally). We follow the same pattern:
13
+ *
14
+ * activate=true → RFC action 'WRITE' (INSERT TEXTPOOL STATE 'A')
15
+ * Pool is written active immediately.
16
+ * activate=false → RFC action 'WRITE_INACTIVE' (INSERT TEXTPOOL STATE 'I')
17
+ * Pool is staged inactive; the next activation of the
18
+ * parent program promotes it atomically — every R / I /
19
+ * S / H entry goes live together, matching the user's
20
+ * "register 40 now, activate program later" flow.
21
+ *
22
+ * replace_existing=false re-reads the current pool first and merges the
23
+ * caller's entries by (ID, KEY) so nothing outside the caller's set is
24
+ * wiped.
25
+ *
26
+ * Existing CreateTextElement / UpdateTextElement tools remain untouched.
27
+ */
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.TOOL_DEFINITION = void 0;
30
+ exports.handleWriteTextElementsBulk = handleWriteTextElementsBulk;
31
+ const rfcBackend_1 = require("../../../lib/rfcBackend");
32
+ const utils_1 = require("../../../lib/utils");
33
+ const MAX_ENTRY_LEN = 132;
34
+ exports.TOOL_DEFINITION = {
35
+ name: 'WriteTextElementsBulk',
36
+ available_in: ['onprem', 'legacy'],
37
+ description: 'Register many ABAP text elements (R/I/S/H) in ONE tool call via a single TPOOL RFC write. Use instead of calling CreateTextElement N times. With activate=false (default) the pool is staged INACTIVE — the parent program\'s next activation promotes every entry atomically, which is the correct flow for "register 40 now, activate program later". With activate=true the pool is written ACTIVE immediately. Set replace_existing=false to merge into the current pool instead of replacing it.',
38
+ inputSchema: {
39
+ type: 'object',
40
+ properties: {
41
+ program_name: {
42
+ type: 'string',
43
+ description: 'Parent program name.',
44
+ },
45
+ language: {
46
+ type: 'string',
47
+ description: '1-char language key (e.g. "K" for Korean). Defaults to SAP logon language.',
48
+ },
49
+ text_elements: {
50
+ type: 'array',
51
+ minItems: 1,
52
+ description: 'Array of entries. Each: { type: "R"|"I"|"S"|"H", key?: string, text: string }. R ignores key (single-row program title — key defaults to program name). I requires a 3-char key. S requires a parameter / select-option name (max 8 chars). H requires one of "listHeader" or "columnHeader_N".',
53
+ items: {
54
+ type: 'object',
55
+ properties: {
56
+ type: { type: 'string', enum: ['R', 'I', 'S', 'H'] },
57
+ key: { type: 'string' },
58
+ text: { type: 'string' },
59
+ },
60
+ required: ['type', 'text'],
61
+ },
62
+ },
63
+ replace_existing: {
64
+ type: 'boolean',
65
+ description: 'If true (default), the TPOOL is replaced with the provided entries only. If false, existing rows are preserved and provided rows merge by (type, key).',
66
+ },
67
+ transport_request: {
68
+ type: 'string',
69
+ description: 'Transport request number (informational).',
70
+ },
71
+ activate: {
72
+ type: 'boolean',
73
+ description: 'false (default) — stage as INACTIVE (program activation promotes). true — write ACTIVE immediately.',
74
+ },
75
+ },
76
+ required: ['program_name', 'text_elements'],
77
+ },
78
+ };
79
+ function rowKey(row) {
80
+ return `${row.ID.toUpperCase()}::${row.KEY.trim().toUpperCase()}`;
81
+ }
82
+ function normalizeEntry(e, programName) {
83
+ const id = e.type.toUpperCase();
84
+ let key;
85
+ if (id === 'R') {
86
+ // Single program-title row — ABAP stores KEY = programName (uppercased).
87
+ key = (e.key?.trim() || programName).toUpperCase();
88
+ }
89
+ else {
90
+ key = (e.key ?? '').trim();
91
+ }
92
+ return {
93
+ ID: id,
94
+ KEY: key,
95
+ ENTRY: e.text ?? '',
96
+ LENGTH: (e.text ?? '').length,
97
+ };
98
+ }
99
+ async function handleWriteTextElementsBulk(context, params) {
100
+ const { connection, logger } = context;
101
+ const args = params;
102
+ if (!args?.program_name) {
103
+ return (0, utils_1.return_error)(new Error('program_name is required'));
104
+ }
105
+ if (!Array.isArray(args?.text_elements) || args.text_elements.length === 0) {
106
+ return (0, utils_1.return_error)(new Error('text_elements must be a non-empty array'));
107
+ }
108
+ if ((0, utils_1.isCloudConnection)()) {
109
+ return (0, utils_1.return_error)(new Error('Text elements are not available on ABAP Cloud'));
110
+ }
111
+ // Input validation — fail before any SAP round-trip.
112
+ const perTypeCount = {};
113
+ const rRows = [];
114
+ for (const [i, e] of args.text_elements.entries()) {
115
+ if (!e?.type || !['R', 'I', 'S', 'H'].includes(e.type)) {
116
+ return (0, utils_1.return_error)(new Error(`text_elements[${i}] has missing or unsupported type "${e?.type}"`));
117
+ }
118
+ if (typeof e.text !== 'string') {
119
+ return (0, utils_1.return_error)(new Error(`text_elements[${i}] "text" must be a string`));
120
+ }
121
+ if (e.text.length > MAX_ENTRY_LEN) {
122
+ return (0, utils_1.return_error)(new Error(`text_elements[${i}] text exceeds ${MAX_ENTRY_LEN} chars (${e.text.length})`));
123
+ }
124
+ if (e.type === 'I' || e.type === 'S' || e.type === 'H') {
125
+ if (!e.key) {
126
+ return (0, utils_1.return_error)(new Error(`text_elements[${i}] type "${e.type}" requires "key"`));
127
+ }
128
+ if (e.type === 'S' && e.key.length > 8) {
129
+ return (0, utils_1.return_error)(new Error(`text_elements[${i}] selection key "${e.key}" exceeds 8 chars`));
130
+ }
131
+ }
132
+ perTypeCount[e.type] = (perTypeCount[e.type] ?? 0) + 1;
133
+ if (e.type === 'R')
134
+ rRows.push(e);
135
+ }
136
+ if (rRows.length > 1) {
137
+ return (0, utils_1.return_error)(new Error('Only one R-type entry is allowed per program'));
138
+ }
139
+ const programName = args.program_name.toUpperCase();
140
+ const language = (args.language || '').toUpperCase();
141
+ const replaceExisting = args.replace_existing !== false;
142
+ const shouldActivate = args.activate === true;
143
+ const action = shouldActivate
144
+ ? 'WRITE'
145
+ : 'WRITE_INACTIVE';
146
+ const steps = [];
147
+ logger?.info(`WriteTextElementsBulk: ${programName} — ${args.text_elements.length} entries (${JSON.stringify(perTypeCount)}); replace_existing=${replaceExisting}; action=${action}`);
148
+ try {
149
+ // Normalize caller input into TPOOL rows.
150
+ const caller = args.text_elements.map((e) => normalizeEntry(e, programName));
151
+ let finalRows;
152
+ if (replaceExisting) {
153
+ finalRows = caller;
154
+ }
155
+ else {
156
+ // Read current pool, merge caller on top by (ID, KEY).
157
+ const { result: fetched } = await (0, rfcBackend_1.callTextpool)(connection, 'READ', {
158
+ program: programName,
159
+ language,
160
+ });
161
+ const existing = (Array.isArray(fetched) ? fetched : []).map((r) => ({
162
+ ID: String(r?.ID ?? r?.id ?? '').toUpperCase(),
163
+ KEY: String(r?.KEY ?? r?.key ?? ''),
164
+ ENTRY: String(r?.ENTRY ?? r?.entry ?? ''),
165
+ LENGTH: Number(r?.LENGTH ?? r?.length ?? 0),
166
+ }));
167
+ const map = new Map();
168
+ for (const row of existing)
169
+ map.set(rowKey(row), row);
170
+ for (const row of caller)
171
+ map.set(rowKey(row), row);
172
+ finalRows = [...map.values()];
173
+ steps.push('read_existing_for_merge');
174
+ }
175
+ // Single RFC write — regardless of entry count.
176
+ await (0, rfcBackend_1.callTextpool)(connection, action, {
177
+ program: programName,
178
+ language,
179
+ textpool_json: JSON.stringify(finalRows),
180
+ });
181
+ steps.push(action === 'WRITE' ? 'write_active' : 'write_inactive');
182
+ return (0, utils_1.return_response)({
183
+ data: JSON.stringify({
184
+ success: true,
185
+ program_name: programName,
186
+ total_entries: args.text_elements.length,
187
+ per_type: perTypeCount,
188
+ total_rows_written: finalRows.length,
189
+ replace_existing: replaceExisting,
190
+ language_used: language || null,
191
+ activate: shouldActivate,
192
+ rfc_action: action,
193
+ steps_completed: steps,
194
+ message: shouldActivate
195
+ ? `Wrote ${finalRows.length} active text element row(s) for ${programName}.`
196
+ : `Staged ${finalRows.length} INACTIVE text element row(s) for ${programName}. Activate the parent program to promote.`,
197
+ }, null, 2),
198
+ status: 200,
199
+ statusText: 'OK',
200
+ headers: {},
201
+ config: {},
202
+ });
203
+ }
204
+ catch (error) {
205
+ const errorMessage = error instanceof Error ? error.message : String(error);
206
+ logger?.error(`WriteTextElementsBulk failed: ${errorMessage}`);
207
+ return (0, utils_1.return_error)(new Error(`WriteTextElementsBulk failed: ${errorMessage}`));
208
+ }
209
+ }
210
+ //# sourceMappingURL=handleWriteTextElementsBulk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handleWriteTextElementsBulk.js","sourceRoot":"","sources":["../../../../src/handlers/text_element/high/handleWriteTextElementsBulk.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;;;AA2GH,kEAuJC;AA/PD,wDAAuD;AACvD,8CAK4B;AAE5B,MAAM,aAAa,GAAG,GAAG,CAAC;AAEb,QAAA,eAAe,GAAG;IAC7B,IAAI,EAAE,uBAAuB;IAC7B,YAAY,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAU;IAC3C,WAAW,EACT,ueAAue;IACze,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,YAAY,EAAE;gBACZ,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,sBAAsB;aACpC;YACD,QAAQ,EAAE;gBACR,IAAI,EAAE,QAAQ;gBACd,WAAW,EACT,4EAA4E;aAC/E;YACD,aAAa,EAAE;gBACb,IAAI,EAAE,OAAO;gBACb,QAAQ,EAAE,CAAC;gBACX,WAAW,EACT,iSAAiS;gBACnS,KAA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ACrB,IAAI,EAAE,IAAI,CAAC,SAAS,CAClB;gBACE,OAAO,EAAE,IAAI;gBACb,YAAY,EAAE,WAAW;gBACzB,aAAa,EAAE,IAAI,CAAC,aAAa,CAAC,MAAM;gBACxC,QAAQ,EAAE,YAAY;gBACtB,kBAAkB,EAAE,SAAS,CAAC,MAAM;gBACpC,gBAAgB,EAAE,eAAe;gBACjC,aAAa,EAAE,QAAQ,IAAI,IAAI;gBAC/B,QAAQ,EAAE,cAAc;gBACxB,UAAU,EAAE,MAAM;gBAClB,eAAe,EAAE,KAAK;gBACtB,OAAO,EAAE,cAAc;oBACrB,CAAC,CAAC,SAAS,SAAS,CAAC,MAAM,mCAAmC,WAAW,GAAG;oBAC5E,CAAC,CAAC,UAAU,SAAS,CAAC,MAAM,qCAAqC,WAAW,2CAA2C;aAC1H,EACD,IAAI,EACJ,CAAC,CACF;YACD,MAAM,EAAE,GAAG;YACX,UAAU,EAAE,IAAI;YAChB,OAAO,EAAE,EAAE;YACX,MAAM,EAAE,EAAS;SACD,CAAC,CAAC;IACtB,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC5E,MAAM,EAAE,KAAK,CAAC,iCAAiC,YAAY,EAAE,CAAC,CAAC;QAC/D,OAAO,IAAA,oBAAY,EACjB,IAAI,KAAK,CAAC,iCAAiC,YAAY,EAAE,CAAC,CAC3D,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -0,0 +1,113 @@
1
+ /**
2
+ * CUA (SAP GUI Status) schema helpers.
3
+ *
4
+ * SAP's RS_CUA_INTERNAL_WRITE overwrites the entire GUI status definition of
5
+ * a program atomically — every row of every table (STA/FUN/PFK/BUT/MEN/…).
6
+ * Missing rows and missing fields become empty. This module provides:
7
+ *
8
+ * 1. A typed representation (`CuaData`) that matches what
9
+ * /ui2/cl_json=>serialize returns for ABAP structures rsmpe_*.
10
+ * 2. `normalizeCuaInput` — accepts either a JSON string (back-compat with
11
+ * the historical `cua_data: string` tool surface) or an already-parsed
12
+ * object, and returns a normalized `CuaData`.
13
+ * 3. `validateCuaData` — checks required fields per table so the tool
14
+ * layer catches obviously-broken payloads (e.g. STA row without CODE,
15
+ * FUN row without FUN_TEXT) BEFORE they blow the production GUI
16
+ * status away. Returns the list of problems or null on success.
17
+ * 4. `mergeCuaData` — row-level shallow merge with stable keys per table:
18
+ * STA → CODE
19
+ * FUN → CODE
20
+ * PFK → CODE + PFNO
21
+ * BUT → PFK_CODE + CODE + NO
22
+ * TIT → CODE
23
+ * MEN → CODE + NO
24
+ * MTX → CODE
25
+ * ACT → CODE + NO
26
+ * SET → STATUS + FUNCTION
27
+ * DOC → OBJ_TYPE + OBJ_CODE
28
+ * BIV → CODE + POS (best guess — rarely used)
29
+ * A row present in `changes` overwrites the matching key in `base`;
30
+ * any row in `base` without a match is kept. Enables Read→merge→Write
31
+ * semantics for PatchGuiStatus.
32
+ */
33
+ export interface CuaAdm {
34
+ ACTCODE?: string;
35
+ MENCODE?: string;
36
+ PFKCODE?: string;
37
+ MOD_LANGU?: string;
38
+ [k: string]: unknown;
39
+ }
40
+ export interface CuaStaRow {
41
+ CODE: string;
42
+ MODAL?: string;
43
+ ACTCODE?: string;
44
+ PFKCODE?: string;
45
+ BUTCODE?: string;
46
+ INT_NOTE?: string;
47
+ [k: string]: unknown;
48
+ }
49
+ export interface CuaFunRow {
50
+ CODE: string;
51
+ TEXTNO?: string;
52
+ TEXT_TYPE?: string;
53
+ FUN_TEXT?: string;
54
+ TEXT_NAME?: string;
55
+ ICON_ID?: string;
56
+ PATH?: string;
57
+ [k: string]: unknown;
58
+ }
59
+ export interface CuaPfkRow {
60
+ CODE: string;
61
+ PFNO: string;
62
+ FUNCODE: string;
63
+ FUNNO?: string;
64
+ [k: string]: unknown;
65
+ }
66
+ export interface CuaButRow {
67
+ PFK_CODE: string;
68
+ CODE: string;
69
+ NO: string;
70
+ PFNO: string;
71
+ [k: string]: unknown;
72
+ }
73
+ export interface CuaTitRow {
74
+ CODE: string;
75
+ TEXT?: string;
76
+ [k: string]: unknown;
77
+ }
78
+ export interface CuaData {
79
+ ADM?: CuaAdm;
80
+ STA?: CuaStaRow[];
81
+ FUN?: CuaFunRow[];
82
+ MEN?: Array<Record<string, unknown>>;
83
+ MTX?: Array<Record<string, unknown>>;
84
+ ACT?: Array<Record<string, unknown>>;
85
+ BUT?: CuaButRow[];
86
+ PFK?: CuaPfkRow[];
87
+ SET?: Array<Record<string, unknown>>;
88
+ DOC?: Array<Record<string, unknown>>;
89
+ TIT?: CuaTitRow[];
90
+ BIV?: Array<Record<string, unknown>>;
91
+ [k: string]: unknown;
92
+ }
93
+ export declare function normalizeCuaInput(input: string | CuaData | unknown): CuaData;
94
+ export interface CuaValidationProblem {
95
+ table: string;
96
+ rowIndex?: number;
97
+ field?: string;
98
+ message: string;
99
+ }
100
+ /**
101
+ * Per-table required-field checks that a sane caller would pass.
102
+ * Fails early so a half-written JSON can never wipe production.
103
+ */
104
+ export declare function validateCuaData(data: CuaData): CuaValidationProblem[];
105
+ /**
106
+ * Row-level merge. Returns a new CuaData where every table in `changes`
107
+ * is merged into the matching `base` table; rows in `base` without a
108
+ * matching change are kept as-is. Fields within a matched row are shallow-
109
+ * merged (changes win). Tables absent from `changes` keep `base`'s array.
110
+ */
111
+ export declare function mergeCuaData(base: CuaData, changes: CuaData): CuaData;
112
+ export declare function serializeCuaForRfc(data: CuaData): string;
113
+ //# sourceMappingURL=cuaSchema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cuaSchema.d.ts","sourceRoot":"","sources":["../../src/lib/cuaSchema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,MAAM,WAAW,MAAM;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAA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