autoforce 0.1.18 → 0.1.20

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.
@@ -1,88 +1,60 @@
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
1
  import { GraphQLClient } from 'graphql-request';
11
2
  const GITLAB_API = 'https://gitlab.com/api/graphql?remove_deprecated=true';
12
3
  export class GitLabApi {
4
+ repoVar;
5
+ projectNumber;
6
+ graphqlAuth;
13
7
  constructor(token, owner, repo, projectNumber) {
14
8
  this.graphqlAuth = new GraphQLClient(GITLAB_API);
15
9
  this.repoVar = { owner, repo };
16
10
  this.projectNumber = projectNumber;
17
11
  this.graphqlAuth.setHeaders({ authorization: `Bearer ${token}` });
18
12
  }
19
- getLabels() {
20
- return __awaiter(this, void 0, void 0, function* () {
21
- return [];
22
- });
23
- }
24
- getMilestones() {
25
- return __awaiter(this, void 0, void 0, function* () {
26
- return [];
27
- });
28
- }
29
- getIssue(issueNumber) {
30
- return __awaiter(this, void 0, void 0, function* () {
31
- console.log(issueNumber);
32
- return {};
33
- });
34
- }
35
- getIssues() {
36
- return __awaiter(this, void 0, void 0, function* () {
37
- return [];
38
- });
39
- }
40
- getIssuesWithFilter(filter) {
41
- return __awaiter(this, void 0, void 0, function* () {
42
- return [];
43
- });
44
- }
45
- createLabel(name_1) {
46
- return __awaiter(this, arguments, void 0, function* (name, color = 'random') {
47
- console.log(name, color);
48
- return { id: '', name, color };
49
- });
50
- }
51
- createMilestone(title_1) {
52
- return __awaiter(this, arguments, void 0, function* (title, state = 'open', description, dueOn) {
53
- console.log(title, state, description, dueOn);
54
- return { id: '', title: '', state: '', url: '' };
55
- });
56
- }
57
- createIssue(title, state, label, body, milestone) {
58
- return __awaiter(this, void 0, void 0, function* () {
59
- console.log(title, state, label, body, milestone);
60
- return { number: 1 };
61
- });
62
- }
63
- moveIssue(issueNumber, state) {
64
- return __awaiter(this, void 0, void 0, function* () {
65
- console.log(issueNumber, state);
66
- return true;
67
- });
68
- }
69
- assignIssueToMe(issueNumber) {
70
- return __awaiter(this, void 0, void 0, function* () {
71
- console.log(issueNumber);
72
- return true;
73
- });
74
- }
75
- getUser() {
76
- return __awaiter(this, void 0, void 0, function* () {
77
- const query = `{
13
+ async getLabels() {
14
+ return [];
15
+ }
16
+ async getMilestones() {
17
+ return [];
18
+ }
19
+ async getIssue(issueNumber) {
20
+ console.log(issueNumber);
21
+ return {};
22
+ }
23
+ async getIssues() {
24
+ return [];
25
+ }
26
+ async getIssuesWithFilter(filter) {
27
+ return [];
28
+ }
29
+ async createLabel(name, color = 'random') {
30
+ console.log(name, color);
31
+ return { id: '', name, color };
32
+ }
33
+ async createMilestone(title, state = 'open', description, dueOn) {
34
+ console.log(title, state, description, dueOn);
35
+ return { id: '', title: '', state: '', url: '' };
36
+ }
37
+ async createIssue(title, state, label, body, milestone) {
38
+ console.log(title, state, label, body, milestone);
39
+ return { number: 1 };
40
+ }
41
+ async moveIssue(issueNumber, state) {
42
+ console.log(issueNumber, state);
43
+ return true;
44
+ }
45
+ async assignIssueToMe(issueNumber) {
46
+ console.log(issueNumber);
47
+ return true;
48
+ }
49
+ async getUser() {
50
+ const query = `{
78
51
  viewer {
79
52
  login
80
53
  id
81
54
  }
82
55
  }`;
83
- const { viewer } = yield this.graphqlAuth.request(query);
84
- return viewer;
85
- });
56
+ const { viewer } = await this.graphqlAuth.request(query);
57
+ return viewer;
86
58
  }
87
59
  // async request ( document: string, variables: Record<string, AnyValue> ) {
88
60
  // return await request({
@@ -92,43 +64,35 @@ export class GitLabApi {
92
64
  // headers: this.headers
93
65
  // })
94
66
  // }
95
- graphqlQuery(query, vars) {
96
- return __awaiter(this, void 0, void 0, function* () {
97
- const result = yield this.graphqlAuth.request(query, vars);
98
- return result;
99
- // let toProcess = result[endpoint]
100
- // let returnVal = toProcess.nodes
101
- // let pageInfo = toProcess.pageInfo
102
- // let curPage = pageInfo.endCursor
103
- // if ( pageInfo.hasNextPage ) {
104
- // curPage = pageInfo.endCursor
105
- // result = await this.graphql.request(query, vars)
106
- // returnVal = returnVal.concat(result[endpoint].nodes)
107
- // pageInfo = result[endpoint].pageInfo
108
- // }
109
- // return returnVal
110
- });
111
- }
112
- getRepository() {
113
- return __awaiter(this, void 0, void 0, function* () {
114
- });
115
- }
116
- createPullRequest(branchName, title, body) {
117
- return __awaiter(this, void 0, void 0, function* () {
118
- const query = `mutation($branchName: ID!, $title: String!, $body: String!) {
67
+ async graphqlQuery(query, vars) {
68
+ const result = await this.graphqlAuth.request(query, vars);
69
+ return result;
70
+ // let toProcess = result[endpoint]
71
+ // let returnVal = toProcess.nodes
72
+ // let pageInfo = toProcess.pageInfo
73
+ // let curPage = pageInfo.endCursor
74
+ // if ( pageInfo.hasNextPage ) {
75
+ // curPage = pageInfo.endCursor
76
+ // result = await this.graphql.request(query, vars)
77
+ // returnVal = returnVal.concat(result[endpoint].nodes)
78
+ // pageInfo = result[endpoint].pageInfo
79
+ // }
80
+ // return returnVal
81
+ }
82
+ async getRepository() {
83
+ }
84
+ async createPullRequest(branchName, title, body) {
85
+ const query = `mutation($branchName: ID!, $title: String!, $body: String!) {
119
86
 
120
87
  }`;
121
- yield this.graphqlQuery(query, { branchName, title, body });
122
- return true;
123
- });
88
+ await this.graphqlQuery(query, { branchName, title, body });
89
+ return true;
124
90
  }
125
- assignBranchToIssue(issueNumber, branchName, commitSha) {
126
- return __awaiter(this, void 0, void 0, function* () {
127
- const query = `mutation($branchName: ID!, $issueNumber: Int!, $commitSha: String!) {
91
+ async assignBranchToIssue(issueNumber, branchName, commitSha) {
92
+ const query = `mutation($branchName: ID!, $issueNumber: Int!, $commitSha: String!) {
128
93
 
129
94
  }`;
130
- yield this.graphqlQuery(query, { branchName, issueNumber: Number.parseInt(issueNumber), commitSha });
131
- return true;
132
- });
95
+ await this.graphqlQuery(query, { branchName, issueNumber: Number.parseInt(issueNumber), commitSha });
96
+ return true;
133
97
  }
134
98
  }
@@ -1,12 +1,3 @@
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
1
  import sf from "./connect.js";
11
2
  import { default as templateGenerator } from "./template.js";
12
3
  import { DICTIONARY_FOLDER, getModelFolders } from "./util.js";
@@ -18,18 +9,16 @@ function getTemplateEngine() {
18
9
  return _templateEngine;
19
10
  }
20
11
  import { sortByName, splitFilename } from "./util.js";
21
- function getMetadata(lwc) {
22
- return __awaiter(this, void 0, void 0, function* () {
23
- try {
24
- yield sf.connect();
25
- const lwcRecords = yield sf.getLwc(lwc);
26
- return Array.isArray(lwcRecords) ? lwcRecords : [lwcRecords];
27
- }
28
- catch (e) {
29
- console.error(e);
30
- }
31
- return [];
32
- });
12
+ async function getMetadata(lwc) {
13
+ try {
14
+ await sf.connect();
15
+ const lwcRecords = await sf.getLwc(lwc);
16
+ return Array.isArray(lwcRecords) ? lwcRecords : [lwcRecords];
17
+ }
18
+ catch (e) {
19
+ console.error(e);
20
+ }
21
+ return [];
33
22
  }
34
23
  function getLwc(files) {
35
24
  const items = new Set();
@@ -41,34 +30,32 @@ function getLwc(files) {
41
30
  }
42
31
  return [...items.values()];
43
32
  }
44
- function executeLwc(items, filename, folder) {
45
- return __awaiter(this, void 0, void 0, function* () {
46
- const templateEngine = getTemplateEngine();
47
- if (items.length === 0) {
48
- return;
49
- }
50
- // Busca la metadata
51
- const contexts = yield getMetadata(items);
52
- if (!contexts || contexts.length === 0) {
53
- return;
54
- }
55
- // Arma el diccionario de cada LWC
56
- templateEngine.read("lwc");
57
- for (const context of contexts) {
58
- templateEngine.render(context, {
59
- helpers: {}
60
- });
61
- templateEngine.save(context.Name, DICTIONARY_FOLDER + "/lwc");
62
- }
63
- // Arma el documento indice del grupo de lwc
64
- contexts.sort(sortByName);
65
- templateEngine.read("lwcs");
66
- const lwcContext = { lwc: contexts };
67
- templateEngine.render(lwcContext, {
33
+ async function executeLwc(items, filename, folder) {
34
+ const templateEngine = getTemplateEngine();
35
+ if (items.length === 0) {
36
+ return;
37
+ }
38
+ // Busca la metadata
39
+ const contexts = await getMetadata(items);
40
+ if (!contexts || contexts.length === 0) {
41
+ return;
42
+ }
43
+ // Arma el diccionario de cada LWC
44
+ templateEngine.read("lwc");
45
+ for (const context of contexts) {
46
+ templateEngine.render(context, {
68
47
  helpers: {}
69
48
  });
70
- templateEngine.save(filename, folder);
49
+ templateEngine.save(context.Name, DICTIONARY_FOLDER + "/lwc");
50
+ }
51
+ // Arma el documento indice del grupo de lwc
52
+ contexts.sort(sortByName);
53
+ templateEngine.read("lwcs");
54
+ const lwcContext = { lwc: contexts };
55
+ templateEngine.render(lwcContext, {
56
+ helpers: {}
71
57
  });
58
+ templateEngine.save(filename, folder);
72
59
  }
73
60
  const lwcModule = {
74
61
  getItems: getLwc,
@@ -1,12 +1,3 @@
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
1
  import sf from "./connect.js";
11
2
  import { default as templateGenerator } from "./template.js";
12
3
  import { DICTIONARY_FOLDER, getModelFolders } from "./util.js";
@@ -18,29 +9,25 @@ function getTemplateEngine() {
18
9
  return _templateEngine;
19
10
  }
20
11
  import { sortByLabel } from "./util.js";
21
- function getMetadata(objetos) {
22
- return __awaiter(this, void 0, void 0, function* () {
23
- try {
24
- yield sf.connect();
25
- const objects = yield sf.customObjects(objetos);
26
- return Array.isArray(objects) ? objects : [objects];
27
- }
28
- catch (e) {
29
- console.error(e);
30
- }
31
- return [];
32
- });
12
+ async function getMetadata(objetos) {
13
+ try {
14
+ await sf.connect();
15
+ const objects = await sf.customObjects(objetos);
16
+ return Array.isArray(objects) ? objects : [objects];
17
+ }
18
+ catch (e) {
19
+ console.error(e);
20
+ }
21
+ return [];
33
22
  }
34
23
  function descriptionFormula() {
35
- var _a;
36
- return (_a = this.description) === null || _a === void 0 ? void 0 : _a.replaceAll(/[\n\r]/g, "<br/>");
24
+ return this.description?.replaceAll(/[\n\r]/g, "<br/>");
37
25
  }
38
26
  function isManaged() {
39
27
  return this.fullName.split("__").length == 3;
40
28
  }
41
29
  function isMetadataFormula() {
42
- var _a;
43
- return ((_a = this.fullName) === null || _a === void 0 ? void 0 : _a.endsWith("__mdt")) || this.customSettingsType;
30
+ return this.fullName?.endsWith("__mdt") || this.customSettingsType;
44
31
  }
45
32
  function attributesFormula() {
46
33
  const attributes = [];
@@ -103,36 +90,34 @@ function getObjects(files) {
103
90
  }
104
91
  return [...items.values()];
105
92
  }
106
- function executeObjects(items, filename, folder) {
107
- return __awaiter(this, void 0, void 0, function* () {
108
- const templateEngine = getTemplateEngine();
109
- if (items.length === 0) {
110
- return;
111
- }
112
- // Busca la metadata
113
- const contexts = yield getMetadata(items);
114
- if (!contexts || contexts.length === 0) {
115
- return;
116
- }
117
- // Arma el diccionario de cada Objeto
118
- templateEngine.read("object");
119
- for (const context of contexts) {
120
- if (context.fullName) {
121
- templateEngine.render(context, {
122
- helpers: { isManaged, descriptionFormula, typeFormula, attributesFormula }
123
- });
124
- templateEngine.save(context.fullName, DICTIONARY_FOLDER + "/objects");
125
- }
93
+ async function executeObjects(items, filename, folder) {
94
+ const templateEngine = getTemplateEngine();
95
+ if (items.length === 0) {
96
+ return;
97
+ }
98
+ // Busca la metadata
99
+ const contexts = await getMetadata(items);
100
+ if (!contexts || contexts.length === 0) {
101
+ return;
102
+ }
103
+ // Arma el diccionario de cada Objeto
104
+ templateEngine.read("object");
105
+ for (const context of contexts) {
106
+ if (context.fullName) {
107
+ templateEngine.render(context, {
108
+ helpers: { isManaged, descriptionFormula, typeFormula, attributesFormula }
109
+ });
110
+ templateEngine.save(context.fullName, DICTIONARY_FOLDER + "/objects");
126
111
  }
127
- // Arma el documento indice del grupo de objetos
128
- contexts.sort(sortByLabel);
129
- templateEngine.read("objects");
130
- const objectContext = { objects: contexts };
131
- templateEngine.render(objectContext, {
132
- helpers: { isManaged, isMetadataFormula, attributesFormula }
133
- });
134
- templateEngine.save(filename, folder);
112
+ }
113
+ // Arma el documento indice del grupo de objetos
114
+ contexts.sort(sortByLabel);
115
+ templateEngine.read("objects");
116
+ const objectContext = { objects: contexts };
117
+ templateEngine.render(objectContext, {
118
+ helpers: { isManaged, isMetadataFormula, attributesFormula }
135
119
  });
120
+ templateEngine.save(filename, folder);
136
121
  }
137
122
  const objectModule = {
138
123
  getItems: getObjects,
@@ -1,29 +1,17 @@
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
1
  import OpenAI from 'openai';
11
2
  const client = new OpenAI({
12
3
  apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted
13
4
  });
14
- export function getCommitMessage() {
15
- return __awaiter(this, void 0, void 0, function* () {
16
- var _a;
17
- if (process.env['OPENAI_API_KEY']) {
18
- const params = {
19
- messages: [{ role: 'user', content: 'Say this is a test' }],
20
- model: 'gpt-3.5-turbo',
21
- };
22
- const chatCompletion = yield client.chat.completions.create(params);
23
- return (_a = chatCompletion.choices[0].message) === null || _a === void 0 ? void 0 : _a.content;
24
- }
25
- return null;
26
- });
5
+ export async function getCommitMessage() {
6
+ if (process.env['OPENAI_API_KEY']) {
7
+ const params = {
8
+ messages: [{ role: 'user', content: 'Say this is a test' }],
9
+ model: 'gpt-3.5-turbo',
10
+ };
11
+ const chatCompletion = await client.chat.completions.create(params);
12
+ return chatCompletion.choices[0].message?.content;
13
+ }
14
+ return null;
27
15
  }
28
16
  /*
29
17
  // getCommitMessage();