autoforce 0.1.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.
@@ -0,0 +1,363 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { graphql } from "@octokit/graphql";
11
+ export class GitHubApi {
12
+ constructor(token, owner, repo, projectNumber) {
13
+ this.repoVar = { owner, repo };
14
+ this.projectNumber = projectNumber;
15
+ this.graphqlAuth = graphql.defaults({
16
+ headers: {
17
+ authorization: `Bearer ${token}`,
18
+ "X-Github-Next-Global-ID": 1
19
+ },
20
+ });
21
+ }
22
+ getUser() {
23
+ return __awaiter(this, void 0, void 0, function* () {
24
+ const query = `{
25
+ viewer {
26
+ login
27
+ id
28
+ }
29
+ }`;
30
+ const { viewer } = yield this.graphqlAuth(query);
31
+ return viewer;
32
+ });
33
+ }
34
+ getRepository(label) {
35
+ return __awaiter(this, void 0, void 0, function* () {
36
+ const query = `
37
+ query getRepo($owner:String!, $repo: String!, $projectNumber: Int!, ${label ? '$label: String!' : ''} ) {
38
+ repository(owner: $owner, name: $repo) {
39
+ id
40
+ ${label ?
41
+ `label(name: $label) {
42
+ id
43
+ }` : ''}
44
+ projectV2( number: $projectNumber ) {
45
+ id
46
+ field(name: "Status") {
47
+ ... on ProjectV2SingleSelectField {
48
+ id
49
+ name
50
+ options {
51
+ name
52
+ id
53
+ }
54
+ }
55
+ }
56
+ }
57
+ }
58
+ }
59
+ `;
60
+ const { repository } = yield this.graphqlAuth(query, Object.assign({ label, projectNumber: this.projectNumber }, this.repoVar));
61
+ return repository;
62
+ });
63
+ }
64
+ createPullRequest(branchName, title, body) {
65
+ return __awaiter(this, void 0, void 0, function* () {
66
+ const repository = yield this.getRepository();
67
+ const repositoryId = repository.id;
68
+ const headRefName = 'main';
69
+ const baseRefName = branchName;
70
+ const mutationPullRequest = `
71
+ mutation createPullRequest( $baseRefName: String!, $headRefName: String!, $headRepositoryId: ID, $repositoryId: ID!, $title: String!, $body: String ) {
72
+ createPullRequest(
73
+ input: {
74
+ repositoryId: $repositoryId,
75
+ headRefName: $headRefName,
76
+ headRepositoryId: $headRepositoryId,
77
+ baseRefName: $baseRefName,
78
+ title: $title,
79
+ body: $body
80
+ }
81
+ ) {
82
+ pullRequest {
83
+ id
84
+ }
85
+ }
86
+ }`;
87
+ try {
88
+ const { createPullRequest } = yield this.graphqlAuth(mutationPullRequest, { baseRefName, headRefName, headRepositoryId: repositoryId, repositoryId, title, body });
89
+ return createPullRequest.pullRequest ? true : false;
90
+ }
91
+ catch (error) {
92
+ console.log(error);
93
+ }
94
+ return false;
95
+ });
96
+ }
97
+ getColumnValueMap() {
98
+ return __awaiter(this, void 0, void 0, function* () {
99
+ const query = `
100
+ query getFieldOptions($owner:String!, $repo: String!, $projectNumber: Int!) {
101
+ repository(owner: $owner, name: $repo) {
102
+ projectV2(number: $projectNumber) {
103
+ field(name: "Status") {
104
+ ... on ProjectV2SingleSelectField {
105
+ id
106
+ name
107
+ options {
108
+ name
109
+ id
110
+ }
111
+ }
112
+ }
113
+ }
114
+ }
115
+ }
116
+ `;
117
+ const { repository } = yield this.graphqlAuth(query, Object.assign({ projectNumber: this.projectNumber }, this.repoVar));
118
+ const mapValues = {};
119
+ for (const option of repository.projectV2.field.options) {
120
+ mapValues[option.name] = option.id;
121
+ }
122
+ return mapValues;
123
+ });
124
+ }
125
+ createIssue(title, state, label, milestone, body) {
126
+ var _a;
127
+ return __awaiter(this, void 0, void 0, function* () {
128
+ const user = yield this.getUser();
129
+ const repository = yield this.getRepository(label);
130
+ const repositoryId = repository.id;
131
+ const labelId = (_a = repository.label) === null || _a === void 0 ? void 0 : _a.id;
132
+ const projectId = repository.projectV2.id;
133
+ const mutationIssue = `
134
+ mutation createIssue($repositoryId: ID!, $assignId: ID!, $title: String!, $body: String, ${labelId ? '$labelId: ID!' : ''} , $milestoneId: ID ) {
135
+ createIssue(
136
+ input: {
137
+ repositoryId: $repositoryId,
138
+ assigneeIds: [$assignId],
139
+ ${labelId ? 'labelIds: [$labelId],' : ''}
140
+ title: $title,
141
+ milestoneId: $milestoneId,
142
+ body: $body
143
+ }
144
+ ) {
145
+ issue {
146
+ id
147
+ number
148
+ }
149
+ }
150
+ }`;
151
+ const { createIssue } = yield this.graphqlAuth(mutationIssue, { labelId, body, assignId: user.id, projectId, repositoryId, title, label: label ? [label] : null });
152
+ const issue = createIssue.issue;
153
+ if (!state || !issue.number) {
154
+ return issue.number;
155
+ }
156
+ const mutationItem = `
157
+ mutation addProjectV2ItemById($projectId: ID!, $contentId: ID! ) {
158
+ addProjectV2ItemById(
159
+ input: {
160
+ projectId: $projectId
161
+ contentId: $contentId
162
+ }
163
+ ) {
164
+ clientMutationId,
165
+ item {
166
+ id
167
+ }
168
+ }
169
+ }`;
170
+ const { addProjectV2ItemById } = yield this.graphqlAuth(mutationItem, { projectId, contentId: issue.id });
171
+ const itemId = addProjectV2ItemById.item.id;
172
+ const fieldId = repository.projectV2.field.id;
173
+ const mapValues = yield this.getColumnValueMap();
174
+ const columnValue = mapValues[state];
175
+ const mutationColumn = `
176
+ mutation($projectId: ID!, $itemId: ID!, $fieldId: ID!, $columnValue: String!) {
177
+ updateProjectV2ItemFieldValue(
178
+ input: {
179
+ projectId: $projectId,
180
+ itemId: $itemId,
181
+ fieldId: $fieldId,
182
+ value: {singleSelectOptionId: $columnValue}
183
+ }
184
+ ) {
185
+ clientMutationId
186
+ }
187
+ }`;
188
+ const { updateProjectV2ItemFieldValue } = yield this.graphqlAuth(mutationColumn, { projectId, itemId, fieldId, columnValue });
189
+ if (!updateProjectV2ItemFieldValue.clientMutationId) {
190
+ return 0;
191
+ }
192
+ return issue.number;
193
+ });
194
+ }
195
+ moveIssue(issueNumber, state) {
196
+ return __awaiter(this, void 0, void 0, function* () {
197
+ const issue = yield this.getIssue(issueNumber);
198
+ const itemId = issue.projectItems.nodes[0].id;
199
+ const projectId = issue.projectItems.nodes[0].project.id;
200
+ const fieldId = issue.projectItems.nodes[0].fieldValueByName.field.id;
201
+ const mapValues = yield this.getColumnValueMap();
202
+ const columnValue = mapValues[state];
203
+ const mutation = `
204
+ mutation($projectId: ID!, $itemId: ID!, $fieldId: ID!, $columnValue: String!) {
205
+ updateProjectV2ItemFieldValue(
206
+ input: {
207
+ projectId: $projectId,
208
+ itemId: $itemId,
209
+ fieldId: $fieldId,
210
+ value: {singleSelectOptionId: $columnValue}
211
+ }
212
+ ) {
213
+ projectV2Item {
214
+ id
215
+ }
216
+ }
217
+ }`;
218
+ const { updateProjectV2ItemFieldValue } = yield this.graphqlAuth(mutation, { projectId, itemId, fieldId, columnValue });
219
+ return (updateProjectV2ItemFieldValue === null || updateProjectV2ItemFieldValue === void 0 ? void 0 : updateProjectV2ItemFieldValue.projectV2Item) ? true : false;
220
+ });
221
+ }
222
+ assignIssueToMe(issueNumber) {
223
+ return __awaiter(this, void 0, void 0, function* () {
224
+ const user = yield this.getUser();
225
+ const issue = yield this.getIssue(issueNumber);
226
+ const mutation = `
227
+ mutation assignUser( $issueId: ID!, $userId: ID!) {
228
+ addAssigneesToAssignable(input: {
229
+ assignableId: $issueId
230
+ assigneeIds: [ $userId ]
231
+ }) {
232
+ assignable {
233
+ assignees {
234
+ totalCount
235
+ }
236
+ }
237
+ }
238
+ }
239
+ `;
240
+ const { addAssigneesToAssignable } = yield this.graphqlAuth(mutation, { issueId: issue.id, userId: user.id });
241
+ return addAssigneesToAssignable.assignable.assignees.totalCount > 0;
242
+ });
243
+ }
244
+ getCommit(commitSha) {
245
+ return __awaiter(this, void 0, void 0, function* () {
246
+ const query = `
247
+ query getCommit($owner:String!, $repo: String!, $commitSha: String!) {
248
+ repository(owner: $owner, name: $repo) {
249
+ object(expression: $commitSha) {
250
+ ... on Commit {
251
+ id
252
+ oid
253
+ }
254
+ }
255
+ }
256
+ } `;
257
+ const { repository } = yield this.graphqlAuth(query, Object.assign({ commitSha }, this.repoVar));
258
+ return repository.object;
259
+ });
260
+ }
261
+ assignBranchToIssue(issueNumber, branchName, commitSha) {
262
+ var _a;
263
+ return __awaiter(this, void 0, void 0, function* () {
264
+ const issue = yield this.getIssue(issueNumber);
265
+ const commit = yield this.getCommit(commitSha);
266
+ const mutation = `
267
+ mutation createLinkedBranch( $issueId: ID!, $oid: GitObjectID!, $branchName: String!) {
268
+ createLinkedBranch(input: {
269
+ issueId: $issueId
270
+ oid: $oid
271
+ name: $branchName
272
+ })
273
+ {
274
+ issue {
275
+ id
276
+ }
277
+ }
278
+ }`;
279
+ const { createLinkedBranch } = yield this.graphqlAuth(mutation, { issueId: issue.id, oid: commit.oid, branchName });
280
+ console.log(createLinkedBranch);
281
+ return ((_a = createLinkedBranch === null || createLinkedBranch === void 0 ? void 0 : createLinkedBranch.issue) === null || _a === void 0 ? void 0 : _a.id) ? true : false;
282
+ });
283
+ }
284
+ getIssueState(issueNumber) {
285
+ var _a, _b, _c;
286
+ return __awaiter(this, void 0, void 0, function* () {
287
+ const issue = yield this.getIssue(issueNumber);
288
+ return (_c = (_b = (_a = issue.projectItems) === null || _a === void 0 ? void 0 : _a.nodes[0]) === null || _b === void 0 ? void 0 : _b.fieldValueByName) === null || _c === void 0 ? void 0 : _c.name;
289
+ });
290
+ }
291
+ getIssueName(title) {
292
+ return title.toLowerCase().replaceAll(' ', '-');
293
+ }
294
+ getIssueObject(issueNumber) {
295
+ return __awaiter(this, void 0, void 0, function* () {
296
+ const issue = yield this.getIssue(issueNumber);
297
+ const issueObject = { title: issue.title };
298
+ issueObject.name = this.getIssueName(issue.title);
299
+ if (issue.linkedBranches.nodes.length > 0) {
300
+ issueObject.branch = issue.linkedBranches.nodes[0].ref.name;
301
+ }
302
+ if (issue.projectItems.nodes.length > 0) {
303
+ issueObject.state = issue.projectItems.nodes[0].fieldValueByName.name;
304
+ }
305
+ if (issue.labels.nodes.length > 0) {
306
+ issueObject.labels = [];
307
+ for (const node of issue.labels.nodes) {
308
+ issueObject.labels.push(node.name);
309
+ }
310
+ }
311
+ return issueObject;
312
+ });
313
+ }
314
+ getIssue(issueNumber) {
315
+ return __awaiter(this, void 0, void 0, function* () {
316
+ const query = `
317
+ query getIssue($owner:String!, $repo: String!, $issueNumber: Int!) {
318
+ repository(owner: $owner, name: $repo) {
319
+ issue(number: $issueNumber) {
320
+ title
321
+ id
322
+ labels(first:3, orderBy: { field: CREATED_AT, direction: DESC}) {
323
+ nodes {
324
+ color
325
+ name
326
+ }
327
+ }
328
+ projectItems(last: 1) {
329
+ nodes{
330
+ id,
331
+ project {
332
+ id
333
+ }
334
+ fieldValueByName(name: "Status"){
335
+ ... on ProjectV2ItemFieldSingleSelectValue {
336
+ name
337
+ id
338
+ field {
339
+ ... on ProjectV2SingleSelectField {
340
+ id
341
+ }
342
+ }
343
+ }
344
+ }
345
+ }
346
+ }
347
+ linkedBranches(last:1){
348
+ nodes {
349
+ ref {
350
+ id
351
+ name
352
+ }
353
+ }
354
+ }
355
+ }
356
+ }
357
+ }
358
+ `;
359
+ const { repository } = yield this.graphqlAuth(query, Object.assign({ issueNumber }, this.repoVar));
360
+ return repository.issue;
361
+ });
362
+ }
363
+ }
@@ -0,0 +1,19 @@
1
+ import { GraphQLClient } from 'graphql-request';
2
+ import { AnyValue } from '../types/auto.js';
3
+ export declare class GitLabApi implements IGitApi {
4
+ repoVar: {
5
+ owner: string;
6
+ repo: string;
7
+ };
8
+ projectNumber: number | undefined;
9
+ graphqlAuth: GraphQLClient;
10
+ constructor(token: string, owner: string, repo: string, projectNumber?: number);
11
+ getUser(): Promise<{
12
+ login: string;
13
+ id: number;
14
+ }>;
15
+ graphqlQuery(query: string, vars: Record<string, AnyValue>): Promise<unknown>;
16
+ getRepository(): Promise<void>;
17
+ createPullRequest(branchName: string, title: string, body: string): Promise<boolean>;
18
+ assignBranchToIssue(issueNumber: number, branchName: string, commitSha: string): Promise<boolean>;
19
+ }
@@ -0,0 +1,78 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { GraphQLClient } from 'graphql-request';
11
+ const GITLAB_API = 'https://gitlab.com/api/graphql?remove_deprecated=true';
12
+ export class GitLabApi {
13
+ constructor(token, owner, repo, projectNumber) {
14
+ this.graphqlAuth = new GraphQLClient(GITLAB_API);
15
+ this.repoVar = { owner, repo };
16
+ this.projectNumber = projectNumber;
17
+ this.graphqlAuth.setHeaders({ authorization: `Bearer ${token}` });
18
+ }
19
+ getUser() {
20
+ return __awaiter(this, void 0, void 0, function* () {
21
+ const query = `{
22
+ viewer {
23
+ login
24
+ id
25
+ }
26
+ }`;
27
+ const { viewer } = yield this.graphqlAuth.request(query);
28
+ return viewer;
29
+ });
30
+ }
31
+ // async request ( document: string, variables: Record<string, AnyValue> ) {
32
+ // return await request({
33
+ // url: GITLAB_API,
34
+ // document,
35
+ // variables,
36
+ // headers: this.headers
37
+ // })
38
+ // }
39
+ graphqlQuery(query, vars) {
40
+ return __awaiter(this, void 0, void 0, function* () {
41
+ const result = yield this.graphqlAuth.request(query, vars);
42
+ return result;
43
+ // let toProcess = result[endpoint]
44
+ // let returnVal = toProcess.nodes
45
+ // let pageInfo = toProcess.pageInfo
46
+ // let curPage = pageInfo.endCursor
47
+ // if ( pageInfo.hasNextPage ) {
48
+ // curPage = pageInfo.endCursor
49
+ // result = await this.graphql.request(query, vars)
50
+ // returnVal = returnVal.concat(result[endpoint].nodes)
51
+ // pageInfo = result[endpoint].pageInfo
52
+ // }
53
+ // return returnVal
54
+ });
55
+ }
56
+ getRepository() {
57
+ return __awaiter(this, void 0, void 0, function* () {
58
+ });
59
+ }
60
+ createPullRequest(branchName, title, body) {
61
+ return __awaiter(this, void 0, void 0, function* () {
62
+ const query = `mutation($branchName: ID!, $title: String!, $body: String!) {
63
+
64
+ }`;
65
+ yield this.graphqlQuery(query, { branchName, title, body });
66
+ return true;
67
+ });
68
+ }
69
+ assignBranchToIssue(issueNumber, branchName, commitSha) {
70
+ return __awaiter(this, void 0, void 0, function* () {
71
+ const query = `mutation($branchName: ID!, $issueNumber: Int!, $commitSha: String!) {
72
+
73
+ }`;
74
+ yield this.graphqlQuery(query, { branchName, issueNumber, commitSha });
75
+ return true;
76
+ });
77
+ }
78
+ }
@@ -0,0 +1,3 @@
1
+ import { DocumentationModule } from "../types/auto.js";
2
+ declare const lwcModule: DocumentationModule;
3
+ export default lwcModule;
@@ -0,0 +1,69 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import sf from "./connect.js";
11
+ import templateGenerator from "./template.js";
12
+ const templateEngine = templateGenerator("dictionary", "md");
13
+ import { sortByName, splitFilename, DICTIONARY_FOLDER, DOCS_FOLDER } from "./util.js";
14
+ function getMetadata(lwc) {
15
+ return __awaiter(this, void 0, void 0, function* () {
16
+ try {
17
+ yield sf.connect();
18
+ const lwcRecords = yield sf.getLwc(lwc);
19
+ return Array.isArray(lwcRecords) ? lwcRecords : [lwcRecords];
20
+ }
21
+ catch (e) {
22
+ console.error(e);
23
+ }
24
+ return [];
25
+ });
26
+ }
27
+ function getLwc(files) {
28
+ const items = new Set();
29
+ for (const file of files) {
30
+ if (file.indexOf("/lwc/") > 0) {
31
+ const { filename } = splitFilename(file);
32
+ items.add(filename.split(".")[0]);
33
+ }
34
+ }
35
+ return [...items.values()];
36
+ }
37
+ function executeLwc(items, filename, folder) {
38
+ return __awaiter(this, void 0, void 0, function* () {
39
+ if (items.length === 0) {
40
+ return;
41
+ }
42
+ // Busca la metadata
43
+ const contexts = yield getMetadata(items);
44
+ if (!contexts || contexts.length === 0) {
45
+ return;
46
+ }
47
+ // Arma el diccionario de cada LWC
48
+ templateEngine.read("lwc");
49
+ for (const context of contexts) {
50
+ templateEngine.render(context, {
51
+ helpers: {}
52
+ });
53
+ templateEngine.save(context.Name, DICTIONARY_FOLDER + "/lwc");
54
+ }
55
+ // Arma el documento indice del grupo de lwc
56
+ contexts.sort(sortByName);
57
+ templateEngine.read("lwcs");
58
+ const lwcContext = { lwc: contexts };
59
+ templateEngine.render(lwcContext, {
60
+ helpers: {}
61
+ });
62
+ templateEngine.save(filename, DOCS_FOLDER + "/" + folder);
63
+ });
64
+ }
65
+ const lwcModule = {
66
+ getItems: getLwc,
67
+ execute: executeLwc
68
+ };
69
+ export default lwcModule;
@@ -0,0 +1 @@
1
+ export declare function merge(newContent: string, existingContent: string, cleanNotExistingTags?: boolean): string;
@@ -0,0 +1,81 @@
1
+ /*
2
+ * busca los tags que empiezan <!-- START UNIQUE_KEY --> <!-- END UNIQUE_KEY -->
3
+ * @return matchObject {} Mapa de String a {start, end, text}. Donde la key es UNIQUE_KEY, start es donde empieza el primer <!-- y end donde termina el segundo -->
4
+ */
5
+ function createMatchObject(matches) {
6
+ const matchObject = {}; // mapa de key => { start: indice donde empieza, end: indice donde termina, text: texto entre ambos indices }
7
+ const indices = [];
8
+ for (const match of matches) {
9
+ //const tag = match[0];
10
+ const key = match[2].trim();
11
+ const startOrEnd = match[1].toLowerCase().trim(); // guarda si el match es start o end
12
+ if (startOrEnd !== 'start' && startOrEnd !== 'end') {
13
+ throw new Error(`No se puede hacer un merge porque se esperea un 'start' or'end' en vez de ${startOrEnd} `);
14
+ }
15
+ if (matchObject[key] && matchObject[key][startOrEnd] !== undefined) {
16
+ throw new Error(`No se puede hacer un merge porque hay mas de un ${startOrEnd} de ${key}. Debe haber uno solo por archivo `);
17
+ }
18
+ if (matchObject[key] === undefined) {
19
+ matchObject[key] = {};
20
+ }
21
+ if (typeof match.index !== 'undefined') {
22
+ matchObject[key][startOrEnd] =
23
+ startOrEnd === 'start' ? match.index : match.index + match[0].length;
24
+ }
25
+ const startIndex = matchObject[key].start;
26
+ const endIndex = matchObject[key].end;
27
+ if (startIndex !== undefined && endIndex !== undefined) {
28
+ if (endIndex < startIndex) {
29
+ throw new Error(`No se puede hacer un merge porque el start de ${key} esta despues del end`);
30
+ }
31
+ if (typeof match.input !== 'undefined') {
32
+ indices[startIndex] = endIndex;
33
+ matchObject[key].text = match.input.substring(startIndex, endIndex);
34
+ }
35
+ }
36
+ }
37
+ // Valida entradas incompletas
38
+ for (const key of Object.keys(matchObject)) {
39
+ if (matchObject[key].start === undefined ||
40
+ matchObject[key].end === undefined) {
41
+ throw new Error(`No se puede hacer un merge porque ${key} no tiene una apertura y cierre`);
42
+ }
43
+ }
44
+ // Valida que no haya anidamientos
45
+ let lastEndIndex = 0;
46
+ for (const start of Object.keys(indices).sort((a, b) => parseInt(a) - parseInt(b))) {
47
+ const startAsNumber = parseInt(start);
48
+ if (startAsNumber < lastEndIndex) {
49
+ throw new Error(`No se puede hacer un merge porque estan anidados los start y end tags`);
50
+ }
51
+ lastEndIndex = indices[startAsNumber];
52
+ }
53
+ return matchObject;
54
+ }
55
+ export function merge(newContent, existingContent, cleanNotExistingTags = true) {
56
+ let mergeContent = existingContent;
57
+ const regexp = /<!--[ ]*(start|end)[ ]*([^>]*)-->/gi;
58
+ const newMatches = createMatchObject(newContent.matchAll(regexp));
59
+ const existingMatches = createMatchObject(existingContent.matchAll(regexp));
60
+ const newKeys = Object.keys(newMatches);
61
+ const existingKeys = Object.keys(existingMatches);
62
+ for (const key of newKeys) {
63
+ // Por cada coincidencia reemplaza el texto existente por el texto nuevo
64
+ if (existingKeys.includes(key)) {
65
+ mergeContent = mergeContent.replace(existingMatches[key].text, newMatches[key].text);
66
+ }
67
+ else {
68
+ // Si no esta lo appendea (ideal seria que quede en el lugar)
69
+ mergeContent += newMatches[key].text;
70
+ }
71
+ }
72
+ // Borra los viejos
73
+ if (cleanNotExistingTags) {
74
+ for (const key of existingKeys) {
75
+ if (!newKeys.includes(key)) {
76
+ mergeContent = mergeContent.replace(existingMatches[key].text, "");
77
+ }
78
+ }
79
+ }
80
+ return mergeContent;
81
+ }
@@ -0,0 +1,30 @@
1
+ import type { DocumentationModule } from "../types/auto.js";
2
+ declare const helpers: Record<string, DocumentationModule>;
3
+ export default helpers;
4
+ /**
5
+ * example json
6
+ *
7
+ "process-name": {
8
+ "classes": string:[],
9
+ "objects": string:[]
10
+ },
11
+
12
+
13
+
14
+ [
15
+ {
16
+ "name": "modulo",
17
+ "description": "descripcion del modulo",
18
+ "components": [
19
+ {
20
+ "name": "",
21
+ "description": "descripcion del item",
22
+ "path": "folder-name-only",
23
+ "objects": [ "", ""],
24
+ "classes": [ "", ""],
25
+ "lwc": [ "", ""]
26
+ }
27
+ ]
28
+ }
29
+ ]
30
+ */