qcobjectsnewapp 2.5.22-ts → 2.5.23-ts

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.
@@ -33,156 +33,181 @@ type ItemProject = {
33
33
  };
34
34
  type ItemsProject = Array<ItemProject>;
35
35
 
36
- Package("com.qcobjects.services.github", [
37
- class GitHubService extends JSONService {
38
- /**
39
- * Name of the service
40
- * @date 18/04/2023 - 22:30:07
41
- *
42
- * @type {string}
43
- */
44
- name = "myservice";
45
-
46
- /**
47
- * It specifies if the service has a external url. If true, you can pass absolute urls in url property
48
- * @date 18/04/2023 - 22:30:37
49
- *
50
- * @type {boolean}
51
- */
52
- external = true;
53
-
54
- /**
55
- * If it is true, the service call will be cached
56
- * @date 18/04/2023 - 22:31:41
57
- *
58
- * @type {boolean}
59
- */
60
- cached = false;
61
-
62
- /**
63
- * It can be GET, POST, PUT
64
- * @date 18/04/2023 - 22:32:29
65
- *
66
- * @type {string}
67
- */
68
- method = "GET";
69
-
70
- /**
71
- * You can add special headers using this property
72
- * @date 18/04/2023 - 22:33:20
73
- *
74
- * @type {{ "Content-Type": string; }}
75
- */
76
- headers = { "Content-Type": "application/json" };
77
-
78
- /**
79
- * URL for the service call
80
- * @date 18/04/2023 - 22:34:09
81
- *
82
- * @type {string}
83
- */
84
- url = "https://api.github.com/orgs/QuickCorp/repos";
85
-
86
- /**
87
- * This is used internally for XHR requests. Default value is false.
88
- * @date 18/04/2023 - 22:34:29
89
- *
90
- * @type {boolean}
91
- */
92
- withCredentials = false;
93
-
94
- /**
95
- * It is called once the service call is done
96
- * @param param0 this param has two properties, one is the native request call (XHR or Fetch object). The second property is the service object.
97
- * @returns Promise
98
- */
99
- done({ request, service }: StandardResponse) {
100
-
101
- const result:ItemsProject = (JSON.parse(service.template as string) as Array<Project>)
102
- .reverse().map(function (project: Project) {
103
- return {
104
- id: project.id,
105
- description: project.description,
106
- title: project.name,
107
- url: project.html_url,
108
- repo_stargazers_count: project.stargazers_count,
109
- repo_watchers_count: project.watchers_count
110
- };
111
- });
112
-
113
- service.template = JSON.stringify({
114
- result
115
- });
116
- return super.done({ request, service });
117
- }
118
- },
119
-
120
- class GitHubTagService extends JSONService {
121
- name = "myservice";
122
- external = true;
123
- cached = false;
124
- method = "GET";
125
- headers = { "Content-Type": "application/json" };
126
- url = "https://api.github.com/search/repositories?q=qcobjects";
127
- withCredentials = false;
128
-
129
- done({ request, service }: StandardResponse) {
130
- logger.debug(String(request));
131
- const result:ItemsProject = (JSON.parse(service.template as string) as GitHubTagServiceResponse)
132
- .items.map(function (project: Project) {
133
- return {
134
- id: project.id,
135
- description: project.description,
136
- title: project.name,
137
- url: project.html_url,
138
- repo_stargazers_count: project.stargazers_count,
139
- repo_watchers_count: project.watchers_count
140
- };
141
- });
142
-
143
- service.template = JSON.stringify({
144
- result
145
- });
146
- return super.done({ request, service });
147
- }
148
- },
149
-
150
- class QCObjectsVersionService extends Service {
151
- name = "qcobjects_version_service";
152
- external = true;
153
- cached = false;
154
- method = "GET";
155
- headers = { "Content-Type": "application/json" };
156
- url = "https://api.github.com/repos/QuickCorp/QCObjects/tags";
157
- withCredentials = false;
158
-
159
- done({ service }: StandardResponse) {
160
- const latest = JSON.parse(service.template as string)[0];
161
- service.template = {
162
- version: latest.name
36
+ export class GitHubService extends JSONService {
37
+ /**
38
+ * Name of the service
39
+ * @date 18/04/2023 - 22:30:07
40
+ *
41
+ * @type {string}
42
+ */
43
+ name = "myservice";
44
+
45
+ /**
46
+ * It specifies if the service has a external url. If true, you can pass absolute urls in url property
47
+ * @date 18/04/2023 - 22:30:37
48
+ *
49
+ * @type {boolean}
50
+ */
51
+ external = true;
52
+
53
+ /**
54
+ * If it is true, the service call will be cached
55
+ * @date 18/04/2023 - 22:31:41
56
+ *
57
+ * @type {boolean}
58
+ */
59
+ cached = false;
60
+
61
+ /**
62
+ * It can be GET, POST, PUT
63
+ * @date 18/04/2023 - 22:32:29
64
+ *
65
+ * @type {string}
66
+ */
67
+ method = "GET";
68
+
69
+ /**
70
+ * You can add special headers using this property
71
+ * @date 18/04/2023 - 22:33:20
72
+ *
73
+ * @type {{ "Content-Type": string; }}
74
+ */
75
+ headers = { "Content-Type": "application/json", "charset": "utf-8" };
76
+
77
+ /**
78
+ * URL for the service call
79
+ * @date 18/04/2023 - 22:34:09
80
+ *
81
+ * @type {string}
82
+ */
83
+ url = "https://api.github.com/orgs/QuickCorp/repos";
84
+
85
+ /**
86
+ * This is used internally for XHR requests. Default value is false.
87
+ * @date 18/04/2023 - 22:34:29
88
+ *
89
+ * @type {boolean}
90
+ */
91
+ withCredentials = false;
92
+
93
+ constructor() {
94
+ super();
95
+ // Remove charset header to avoid CORS preflight issues with external APIs
96
+ // (charset is not a CORS-safelisted request header)
97
+ delete this.headers.charset;
98
+ }
99
+
100
+ /**
101
+ * It is called once the service call is done
102
+ * @param param0 this param has two properties, one is the native request call (XHR or Fetch object). The second property is the service object.
103
+ * @returns Promise
104
+ */
105
+ done({ request, service }: StandardResponse) {
106
+
107
+ const result:ItemsProject = (JSON.parse(service.template as string) as Array<Project>)
108
+ .reverse().map(function (project: Project) {
109
+ return {
110
+ id: project.id,
111
+ description: project.description,
112
+ title: project.name,
113
+ url: project.html_url,
114
+ repo_stargazers_count: project.stargazers_count,
115
+ repo_watchers_count: project.watchers_count
163
116
  };
164
- }
165
-
166
- },
167
-
168
- class QCObjectsStarsForksService extends Service {
169
- name = "qcobjects_stars_forks_service";
170
- external = true;
171
- cached = false;
172
- method = "GET";
173
- headers = { "Content-Type": "application/json" };
174
- url = "https://api.github.com/repos/QuickCorp/QCObjects";
175
- withCredentials = false;
176
-
177
- done({ service }: StandardResponse) {
178
- const repo:Project = (JSON.parse(service.template as string) as Project);
179
- service.template = {
180
- forks: repo.forks_count,
181
- stars: repo.stargazers_count,
182
- watchers: repo.watchers_count,
183
- size: Math.round(repo.size / 1000)
117
+ });
118
+
119
+ service.template = JSON.stringify({
120
+ result
121
+ });
122
+ return super.done({ request, service });
123
+ }
124
+ }
125
+
126
+ export class GitHubTagService extends JSONService {
127
+ name = "myservice";
128
+ external = true;
129
+ cached = false;
130
+ method = "GET";
131
+ headers = { "Content-Type": "application/json", "charset": "utf-8" };
132
+ url = "https://api.github.com/search/repositories?q=qcobjects";
133
+ withCredentials = false;
134
+
135
+ constructor() {
136
+ super();
137
+ delete this.headers.charset;
138
+ }
139
+
140
+ done({ request, service }: StandardResponse) {
141
+ logger.debug(String(request));
142
+ const result:ItemsProject = (JSON.parse(service.template as string) as GitHubTagServiceResponse)
143
+ .items.map(function (project: Project) {
144
+ return {
145
+ id: project.id,
146
+ description: project.description,
147
+ title: project.name,
148
+ url: project.html_url,
149
+ repo_stargazers_count: project.stargazers_count,
150
+ repo_watchers_count: project.watchers_count
184
151
  };
185
- }
152
+ });
153
+
154
+ service.template = JSON.stringify({
155
+ result
156
+ });
157
+ return super.done({ request, service });
158
+ }
159
+ }
160
+
161
+ export class QCObjectsVersionService extends Service {
162
+ name = "qcobjects_version_service";
163
+ external = true;
164
+ cached = false;
165
+ method = "GET";
166
+ headers = { "Content-Type": "application/json", "charset": "utf-8" };
167
+ url = "https://api.github.com/repos/QuickCorp/QCObjects/tags";
168
+ withCredentials = false;
169
+
170
+ constructor() {
171
+ super();
172
+ delete this.headers.charset;
173
+ }
174
+
175
+ done({ service }: StandardResponse) {
176
+ const latest = JSON.parse(service.template as string)[0];
177
+ service.template = {
178
+ version: latest.name
179
+ };
180
+ }
181
+ }
186
182
 
183
+ export class QCObjectsStarsForksService extends Service {
184
+ name = "qcobjects_stars_forks_service";
185
+ external = true;
186
+ cached = false;
187
+ method = "GET";
188
+ headers = { "Content-Type": "application/json", "charset": "utf-8" };
189
+ url = "https://api.github.com/repos/QuickCorp/QCObjects";
190
+ withCredentials = false;
191
+
192
+ constructor() {
193
+ super();
194
+ delete this.headers.charset;
187
195
  }
196
+
197
+ done({ service }: StandardResponse) {
198
+ const repo:Project = (JSON.parse(service.template as string) as Project);
199
+ service.template = {
200
+ forks: repo.forks_count,
201
+ stars: repo.stargazers_count,
202
+ watchers: repo.watchers_count,
203
+ size: Math.round(repo.size / 1000)
204
+ };
205
+ }
206
+ }
207
+
208
+ Package("com.qcobjects.services.github", [
209
+ GitHubService,
210
+ GitHubTagService,
211
+ QCObjectsVersionService,
212
+ QCObjectsStarsForksService
188
213
  ]);