simplemdg-dev-cli 2.0.4 → 2.4.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/README.md +62 -354
- package/USER_GUIDE.md +55 -376
- package/dist/commands/cds.command.js +69 -60
- package/dist/commands/cds.command.js.map +1 -1
- package/dist/commands/cf-db.command.d.ts +2 -0
- package/dist/commands/cf-db.command.js +606 -0
- package/dist/commands/cf-db.command.js.map +1 -0
- package/dist/commands/cf.command.js +291 -280
- package/dist/commands/cf.command.js.map +1 -1
- package/dist/commands/gitlab.command.d.ts +2 -0
- package/dist/commands/gitlab.command.js +351 -0
- package/dist/commands/gitlab.command.js.map +1 -0
- package/dist/commands/npmrc.command.js +50 -44
- package/dist/commands/npmrc.command.js.map +1 -1
- package/dist/core/cache.d.ts +1 -1
- package/dist/core/cache.js +58 -31
- package/dist/core/cache.js.map +1 -1
- package/dist/core/cds.js +32 -22
- package/dist/core/cds.js.map +1 -1
- package/dist/core/cf-env-parser.d.ts +1 -1
- package/dist/core/cf-env-parser.js +4 -1
- package/dist/core/cf-env-parser.js.map +1 -1
- package/dist/core/cf.d.ts +1 -1
- package/dist/core/cf.js +46 -31
- package/dist/core/cf.js.map +1 -1
- package/dist/core/db/db-btp.d.ts +48 -0
- package/dist/core/db/db-btp.js +162 -0
- package/dist/core/db/db-btp.js.map +1 -0
- package/dist/core/db/db-cache.d.ts +40 -0
- package/dist/core/db/db-cache.js +188 -0
- package/dist/core/db/db-cache.js.map +1 -0
- package/dist/core/db/db-connection.d.ts +22 -0
- package/dist/core/db/db-connection.js +73 -0
- package/dist/core/db/db-connection.js.map +1 -0
- package/dist/core/db/db-crypto.d.ts +3 -0
- package/dist/core/db/db-crypto.js +54 -0
- package/dist/core/db/db-crypto.js.map +1 -0
- package/dist/core/db/db-hana-adapter.d.ts +36 -0
- package/dist/core/db/db-hana-adapter.js +251 -0
- package/dist/core/db/db-hana-adapter.js.map +1 -0
- package/dist/core/db/db-metadata.d.ts +25 -0
- package/dist/core/db/db-metadata.js +150 -0
- package/dist/core/db/db-metadata.js.map +1 -0
- package/dist/core/db/db-postgres-adapter.d.ts +34 -0
- package/dist/core/db/db-postgres-adapter.js +259 -0
- package/dist/core/db/db-postgres-adapter.js.map +1 -0
- package/dist/core/db/db-query-files.d.ts +20 -0
- package/dist/core/db/db-query-files.js +106 -0
- package/dist/core/db/db-query-files.js.map +1 -0
- package/dist/core/db/db-query-history.d.ts +5 -0
- package/dist/core/db/db-query-history.js +49 -0
- package/dist/core/db/db-query-history.js.map +1 -0
- package/dist/core/db/db-row.d.ts +28 -0
- package/dist/core/db/db-row.js +123 -0
- package/dist/core/db/db-row.js.map +1 -0
- package/dist/core/db/db-studio-client.d.ts +1 -0
- package/dist/core/db/db-studio-client.js +401 -0
- package/dist/core/db/db-studio-client.js.map +1 -0
- package/dist/core/db/db-studio-html.d.ts +4 -0
- package/dist/core/db/db-studio-html.js +83 -0
- package/dist/core/db/db-studio-html.js.map +1 -0
- package/dist/core/db/db-studio-server.d.ts +11 -0
- package/dist/core/db/db-studio-server.js +528 -0
- package/dist/core/db/db-studio-server.js.map +1 -0
- package/dist/core/db/db-studio-styles.d.ts +1 -0
- package/dist/core/db/db-studio-styles.js +225 -0
- package/dist/core/db/db-studio-styles.js.map +1 -0
- package/dist/core/db/db-types.d.ts +214 -0
- package/dist/core/db/db-types.js +3 -0
- package/dist/core/db/db-types.js.map +1 -0
- package/dist/core/db/db-vcap-parser.d.ts +7 -0
- package/dist/core/db/db-vcap-parser.js +137 -0
- package/dist/core/db/db-vcap-parser.js.map +1 -0
- package/dist/core/doctor.d.ts +1 -1
- package/dist/core/doctor.js +14 -8
- package/dist/core/doctor.js.map +1 -1
- package/dist/core/guide.js +31 -26
- package/dist/core/guide.js.map +1 -1
- package/dist/core/install.d.ts +1 -1
- package/dist/core/install.js +17 -11
- package/dist/core/install.js.map +1 -1
- package/dist/core/navigator.d.ts +17 -0
- package/dist/core/navigator.js +140 -0
- package/dist/core/navigator.js.map +1 -0
- package/dist/core/npmrc.js +29 -16
- package/dist/core/npmrc.js.map +1 -1
- package/dist/core/process.js +11 -6
- package/dist/core/process.js.map +1 -1
- package/dist/core/prompts.js +16 -8
- package/dist/core/prompts.js.map +1 -1
- package/dist/core/repository.d.ts +1 -1
- package/dist/core/repository.js +16 -9
- package/dist/core/repository.js.map +1 -1
- package/dist/core/scanner.d.ts +1 -1
- package/dist/core/scanner.js +13 -7
- package/dist/core/scanner.js.map +1 -1
- package/dist/core/tooling.d.ts +28 -0
- package/dist/core/tooling.js +168 -0
- package/dist/core/tooling.js.map +1 -0
- package/dist/core/types.js +2 -1
- package/dist/core/version-conflict.d.ts +2 -2
- package/dist/core/version-conflict.js +11 -6
- package/dist/core/version-conflict.js.map +1 -1
- package/dist/index.js +65 -48
- package/dist/index.js.map +1 -1
- package/dist/types-local.js +2 -1
- package/package.json +12 -6
- package/src/commands/cds.command.ts +529 -0
- package/src/commands/cf-db.command.ts +636 -0
- package/src/commands/cf.command.ts +3345 -0
- package/src/commands/gitlab.command.ts +373 -0
- package/src/commands/npmrc.command.ts +581 -0
- package/src/core/cache.ts +332 -0
- package/src/core/cds.ts +278 -0
- package/src/core/cf-env-parser.ts +131 -0
- package/src/core/cf.ts +271 -0
- package/src/core/db/db-btp.ts +207 -0
- package/src/core/db/db-cache.ts +242 -0
- package/src/core/db/db-connection.ts +79 -0
- package/src/core/db/db-crypto.ts +53 -0
- package/src/core/db/db-hana-adapter.ts +306 -0
- package/src/core/db/db-metadata.ts +174 -0
- package/src/core/db/db-postgres-adapter.ts +293 -0
- package/src/core/db/db-query-files.ts +130 -0
- package/src/core/db/db-query-history.ts +53 -0
- package/src/core/db/db-row.ts +157 -0
- package/src/core/db/db-studio-client.ts +397 -0
- package/src/core/db/db-studio-html.ts +85 -0
- package/src/core/db/db-studio-server.ts +626 -0
- package/src/core/db/db-studio-styles.ts +221 -0
- package/src/core/db/db-types.ts +243 -0
- package/src/core/db/db-vcap-parser.ts +182 -0
- package/src/core/doctor.ts +70 -0
- package/src/core/guide.ts +261 -0
- package/src/core/install.ts +91 -0
- package/src/core/navigator.ts +164 -0
- package/src/core/npmrc.ts +171 -0
- package/src/core/process.ts +75 -0
- package/src/core/prompts.ts +225 -0
- package/src/core/repository.ts +36 -0
- package/src/core/scanner.ts +41 -0
- package/src/core/tooling.ts +207 -0
- package/src/core/types.ts +152 -0
- package/src/core/version-conflict.ts +46 -0
- package/src/index.ts +460 -0
- package/src/types/external.d.ts +3 -0
- package/src/types-local.ts +11 -0
- package/tsconfig.json +17 -0
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
IDatabaseAdapter,
|
|
3
|
+
TDatabaseQueryResult,
|
|
4
|
+
TSaveRowResult,
|
|
5
|
+
TSaveTableChangesResult,
|
|
6
|
+
TTableChangeSet,
|
|
7
|
+
} from "./db-types";
|
|
8
|
+
|
|
9
|
+
export type TRowValues = Record<string, unknown>;
|
|
10
|
+
|
|
11
|
+
function ensureKeyColumns(keys: TRowValues): string[] {
|
|
12
|
+
const columns = Object.keys(keys);
|
|
13
|
+
|
|
14
|
+
if (columns.length === 0) {
|
|
15
|
+
throw new Error("Cannot identify the row: the table has no primary key. Edit it from the SQL Console instead.");
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return columns;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Build and run a parameterized UPDATE that targets exactly one row using its
|
|
23
|
+
* key columns. Values are passed as bind parameters, never string-interpolated.
|
|
24
|
+
*/
|
|
25
|
+
export async function updateRow(
|
|
26
|
+
adapter: IDatabaseAdapter,
|
|
27
|
+
options: { schema: string; table: string; changes: TRowValues; keys: TRowValues },
|
|
28
|
+
): Promise<TDatabaseQueryResult> {
|
|
29
|
+
const changeColumns = Object.keys(options.changes);
|
|
30
|
+
|
|
31
|
+
if (changeColumns.length === 0) {
|
|
32
|
+
throw new Error("No changes to save.");
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const keyColumns = ensureKeyColumns(options.keys);
|
|
36
|
+
const params: unknown[] = [];
|
|
37
|
+
let position = 1;
|
|
38
|
+
|
|
39
|
+
const setClause = changeColumns
|
|
40
|
+
.map((column) => {
|
|
41
|
+
params.push(options.changes[column]);
|
|
42
|
+
return `${adapter.quoteIdentifier(column)} = ${adapter.placeholder(position++)}`;
|
|
43
|
+
})
|
|
44
|
+
.join(", ");
|
|
45
|
+
|
|
46
|
+
const whereClause = keyColumns
|
|
47
|
+
.map((column) => {
|
|
48
|
+
params.push(options.keys[column]);
|
|
49
|
+
return `${adapter.quoteIdentifier(column)} = ${adapter.placeholder(position++)}`;
|
|
50
|
+
})
|
|
51
|
+
.join(" AND ");
|
|
52
|
+
|
|
53
|
+
const sql = `UPDATE ${adapter.buildQualifiedName(options.schema, options.table)} SET ${setClause} WHERE ${whereClause}`;
|
|
54
|
+
return adapter.runParameterized(sql, params);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export async function deleteRow(
|
|
58
|
+
adapter: IDatabaseAdapter,
|
|
59
|
+
options: { schema: string; table: string; keys: TRowValues },
|
|
60
|
+
): Promise<TDatabaseQueryResult> {
|
|
61
|
+
const keyColumns = ensureKeyColumns(options.keys);
|
|
62
|
+
const params: unknown[] = [];
|
|
63
|
+
let position = 1;
|
|
64
|
+
|
|
65
|
+
const whereClause = keyColumns
|
|
66
|
+
.map((column) => {
|
|
67
|
+
params.push(options.keys[column]);
|
|
68
|
+
return `${adapter.quoteIdentifier(column)} = ${adapter.placeholder(position++)}`;
|
|
69
|
+
})
|
|
70
|
+
.join(" AND ");
|
|
71
|
+
|
|
72
|
+
const sql = `DELETE FROM ${adapter.buildQualifiedName(options.schema, options.table)} WHERE ${whereClause}`;
|
|
73
|
+
return adapter.runParameterized(sql, params);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export async function insertRow(
|
|
77
|
+
adapter: IDatabaseAdapter,
|
|
78
|
+
options: { schema: string; table: string; values: TRowValues },
|
|
79
|
+
): Promise<TDatabaseQueryResult> {
|
|
80
|
+
const columns = Object.keys(options.values);
|
|
81
|
+
|
|
82
|
+
if (columns.length === 0) {
|
|
83
|
+
throw new Error("No values to insert.");
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const params: unknown[] = [];
|
|
87
|
+
let position = 1;
|
|
88
|
+
|
|
89
|
+
const columnClause = columns.map((column) => adapter.quoteIdentifier(column)).join(", ");
|
|
90
|
+
const valueClause = columns
|
|
91
|
+
.map((column) => {
|
|
92
|
+
params.push(options.values[column]);
|
|
93
|
+
return adapter.placeholder(position++);
|
|
94
|
+
})
|
|
95
|
+
.join(", ");
|
|
96
|
+
|
|
97
|
+
const sql = `INSERT INTO ${adapter.buildQualifiedName(options.schema, options.table)} (${columnClause}) VALUES (${valueClause})`;
|
|
98
|
+
return adapter.runParameterized(sql, params);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function errorMessage(error: unknown): string {
|
|
102
|
+
return error instanceof Error ? error.message : String(error);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Apply a set of pending grid changes. Each change runs independently so a
|
|
107
|
+
* single failing row does not discard the others — the result reports per-row
|
|
108
|
+
* success/failure, and callers keep the failed rows pending.
|
|
109
|
+
*/
|
|
110
|
+
export async function saveTableChanges(
|
|
111
|
+
adapter: IDatabaseAdapter,
|
|
112
|
+
changeSet: TTableChangeSet,
|
|
113
|
+
): Promise<TSaveTableChangesResult> {
|
|
114
|
+
const rowResults: TSaveRowResult[] = [];
|
|
115
|
+
const { schema, table } = changeSet;
|
|
116
|
+
let updated = 0;
|
|
117
|
+
let inserted = 0;
|
|
118
|
+
let deleted = 0;
|
|
119
|
+
|
|
120
|
+
for (const update of changeSet.updates) {
|
|
121
|
+
try {
|
|
122
|
+
await updateRow(adapter, { schema, table, changes: update.changes, keys: update.key });
|
|
123
|
+
updated += 1;
|
|
124
|
+
rowResults.push({ type: "update", success: true, key: update.key });
|
|
125
|
+
} catch (error) {
|
|
126
|
+
rowResults.push({ type: "update", success: false, key: update.key, error: errorMessage(error) });
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
for (const insert of changeSet.inserts) {
|
|
131
|
+
try {
|
|
132
|
+
await insertRow(adapter, { schema, table, values: insert.values });
|
|
133
|
+
inserted += 1;
|
|
134
|
+
rowResults.push({ type: "insert", success: true });
|
|
135
|
+
} catch (error) {
|
|
136
|
+
rowResults.push({ type: "insert", success: false, error: errorMessage(error) });
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
for (const remove of changeSet.deletes) {
|
|
141
|
+
try {
|
|
142
|
+
await deleteRow(adapter, { schema, table, keys: remove.key });
|
|
143
|
+
deleted += 1;
|
|
144
|
+
rowResults.push({ type: "delete", success: true, key: remove.key });
|
|
145
|
+
} catch (error) {
|
|
146
|
+
rowResults.push({ type: "delete", success: false, key: remove.key, error: errorMessage(error) });
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return {
|
|
151
|
+
success: rowResults.every((result) => result.success),
|
|
152
|
+
updated,
|
|
153
|
+
inserted,
|
|
154
|
+
deleted,
|
|
155
|
+
rowResults,
|
|
156
|
+
};
|
|
157
|
+
}
|