@kumori/aurora-backend-handler 1.0.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.
package/.gitlab-ci.yml ADDED
@@ -0,0 +1,57 @@
1
+ image: node:16-alpine
2
+
3
+ stages:
4
+ - install
5
+ - test
6
+ - release
7
+
8
+ variables:
9
+ GITLAB_NPM_REGISTRY_URL: "https://gitlab.com/api/v4/groups/$KUMORI_GROUP_ID/-/packages/npm/"
10
+
11
+ install:
12
+ stage: install
13
+ tags:
14
+ - docker
15
+ script:
16
+ - npm ci
17
+ artifacts:
18
+ paths:
19
+ - node_modules/
20
+
21
+ # test:
22
+ # stage: test
23
+ # image: node:16-alpine
24
+ # tags:
25
+ # - docker
26
+ # dependencies:
27
+ # - install
28
+ # script:
29
+ # - npm install --no-save jest-junit
30
+ # - npm run test
31
+ # coverage: '/All files.*?\|\s*[\d\.]+\s*\|\s*[\d\.]+\s*\|\s*[\d\.]+\s*\|\s*([\d\.]+)/'
32
+ # artifacts:
33
+ # when: always
34
+ # paths:
35
+ # - report.xml
36
+ # reports:
37
+ # junit: report.xml
38
+ # only:
39
+ # - merge_requests
40
+ # - master
41
+ # - tags
42
+
43
+ release:
44
+ stage: release
45
+ tags:
46
+ - docker
47
+ dependencies:
48
+ - install
49
+ rules:
50
+ - if: '$CI_COMMIT_TAG =~ /^v\d+\.\d+\.\d+$/'
51
+ when: manual
52
+ - when: never
53
+ script:
54
+ - echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > $HOME/.npmrc
55
+ - npm whoami
56
+ - npm publish --access public
57
+
package/README.md ADDED
@@ -0,0 +1,352 @@
1
+ # Backend Handler
2
+
3
+ ## Table of Contents
4
+ - [Overview](#overview)
5
+ - [Usage](#usage)
6
+ - [Architecture](#architecture)
7
+ - [Proposed Data Models](#proposed-data-models)
8
+ - [Repository Tree](#repository-tree)
9
+ - [License](#license)
10
+
11
+ ## Overview
12
+
13
+ The backendHandler is responsible for mediating communication between the Aurora WUI and backend APIs. It listens for frontend events (e.g., updateUser), translates them into API calls, and emits an event back into the UI via the WUIBridge with the corresponding data.
14
+
15
+ This ensures a decoupled, event-driven architecture where WUI components remain agnostic of backend details.
16
+
17
+ ## Usage
18
+
19
+ To install this library ensure you have the following prerequisites installed:
20
+ - [Node.js](https://nodejs.org) (v16 or later recommended)
21
+ - [npm](https://www.npmjs.com) or [Yarn](https://yarnpkg.com)
22
+
23
+ Then you can install the package with the following command:
24
+
25
+ ```bash
26
+ npm install @aurora-backend-handler/backend-handler@latest
27
+ ```
28
+
29
+ This library gives acces to the backendHandler which recives and produces events involving the API.
30
+
31
+ ### Test
32
+
33
+ #### Installation
34
+
35
+ 1. Install dependencies:
36
+
37
+ ```bash
38
+ npm install
39
+ ```
40
+
41
+ #### Running Test
42
+
43
+ The project uses Jest as the testing framework with TypeScript support via ts-jest. To execute the tests, simply run:
44
+
45
+ ```bash
46
+ npm run test
47
+ ```
48
+
49
+ #### Coverage
50
+
51
+ The coverage of the test will be shown on the console where the test have been executed but also in a coverage folder on the repository directory.
52
+
53
+ ## Architecture
54
+
55
+ ### Proposed Data Models
56
+
57
+ ```typescript
58
+ export class User {
59
+ id: string;
60
+ name: string;
61
+ surname: string;
62
+ email: string;
63
+ password: string;
64
+ notificationsEnabled: string;
65
+ organizations: Organization[];
66
+ tokens: Token[];
67
+ tenants: Tenant[];
68
+ axebowPlan: "freemium" | "premium";
69
+ companyName: string;
70
+ rol: string;
71
+ }
72
+
73
+ interface Organization {
74
+ id: string,
75
+ name: string,
76
+ usersIds: string[],
77
+ tenantsIds: string[],
78
+ billingInformation: {
79
+ legalName: string,
80
+ CIFNIF: string,
81
+ email: string,
82
+ language: string,
83
+ country: string,
84
+ region: string,
85
+ city: string,
86
+ address: string,
87
+ zipcode: string,
88
+ }
89
+ invoices: {
90
+ id: string,
91
+ name: string,
92
+ customer: string,
93
+ customerCIF: string,
94
+ cost: number,
95
+ date: string,
96
+ invoiceFile: string,
97
+ }[],
98
+ status?: string,
99
+ }
100
+
101
+ interface Token {
102
+ name: string;
103
+ tenant: string;
104
+ desciprion: string;
105
+ lastUsed: string;
106
+ expiration: string;
107
+ token: string;
108
+ }
109
+
110
+ interface Tenant {
111
+ id: string,
112
+ name: string,
113
+ organizationsIds: string[],
114
+ services: Service[],
115
+ accounts: Account[],
116
+ environments: Environment[],
117
+ marketplaceItems: MarketplaceItem[],
118
+ resources: Resource[],
119
+ role: string,
120
+ status: string,
121
+ users: number;
122
+ }
123
+
124
+ interface Service {
125
+ id: string;
126
+ tenant: string;
127
+ account: string;
128
+ environment: string;
129
+ name: string;
130
+ logo: string;
131
+ description: string;
132
+ revisions: string[];
133
+ status: string;
134
+ role: { name: string; instances: Instance[]; logo?: string, category?: string, version?: string, description?: string, resource?: Resource[] }[];
135
+ links: Link[];
136
+ resources: Resource[];
137
+ usage: Usage;
138
+ minReplicas?: number;
139
+ maxReplicas?: number;
140
+ lastDeployed?: string;
141
+ project: string;
142
+ registry: string;
143
+ imageName: string;
144
+ entrypoint: string;
145
+ cmd: string;
146
+ serverChannels: Channel[];
147
+ clientChannels: Channel[];
148
+ duplexChannels: Channel[];
149
+ cloudProvider: string;
150
+ currentRevision?: string;
151
+ startedAt?: string;
152
+ }
153
+
154
+ interface Instance {
155
+ id: string;
156
+ name: string;
157
+ status: string;
158
+ usage: Usage;
159
+ logs: string[];
160
+ conatiners: Container[];
161
+ }
162
+
163
+ interface Container {
164
+ name: string;
165
+ ready: boolean;
166
+ reestartCount: number;
167
+ metrics: {
168
+ cpu: number;
169
+ memory: number;
170
+ }
171
+ states: any;
172
+ }
173
+
174
+ interface Channel {
175
+ name: string;
176
+ from: string;
177
+ to: string;
178
+ protocol?: "http" | "tcp" | "https";
179
+ port?: number;
180
+ portNum?: number;
181
+ }
182
+
183
+ interface Account {
184
+ id: string;
185
+ name: string;
186
+ tenant: string;
187
+ cloudProvider: {
188
+ name: string;
189
+ region?: string;
190
+ interface?: string;
191
+ apiVersion?: string;
192
+ authType?: string;
193
+ authUrl?: string;
194
+ credentialId?: string;
195
+ credentialSecret?: string;
196
+ };
197
+ logo: string;
198
+ environments: string[];
199
+ services: string[];
200
+ domains: string[];
201
+ status: string;
202
+ usage: Usage;
203
+ flavors?: {
204
+ small: string;
205
+ medium: string;
206
+ large: string;
207
+ volatile: string;
208
+ nonReplicated: string;
209
+ persistent: string;
210
+ };
211
+ organization?: string;
212
+ }
213
+
214
+ interface Usage {
215
+ current: {
216
+ cpu: number;
217
+ memory: number;
218
+ storage: number;
219
+ volatileStorage: number;
220
+ nonReplicatedStorage: number;
221
+ persistentStorage: number;
222
+ };
223
+ limit: {
224
+ cpu: {
225
+ max: number;
226
+ min: number;
227
+ }
228
+ memory: {
229
+ max: number;
230
+ min: number;
231
+ }
232
+ storage: {
233
+ max: number;
234
+ min: number;
235
+ }
236
+ volatileStorage: {
237
+ max: number;
238
+ min: number;
239
+ }
240
+ nonReplicatedStorage: {
241
+ max: number;
242
+ min: number;
243
+ }
244
+ persistentStorage:{
245
+ max: number;
246
+ min: number;
247
+ }
248
+ };
249
+ cost: number;
250
+ }
251
+
252
+ interface Environment {
253
+ id: string;
254
+ name: string;
255
+ account: string;
256
+ tenant: string;
257
+ logo: string;
258
+ services: string[];
259
+ domains: string[];
260
+ status: string;
261
+ usage: Usage;
262
+ organization?: string;
263
+ cloudProvider?: string;
264
+ labels?: string[];
265
+ }
266
+
267
+ interface MarketplaceItem {
268
+ tenant: string,
269
+ name: string,
270
+ logo: string,
271
+ description: string,
272
+ version: string,
273
+ requirements: {
274
+ cpu: number,
275
+ memory: number,
276
+ }
277
+ status: string,
278
+ instances: Instance[],
279
+ links: Link[],
280
+ resources: Resource[],
281
+ domain?: string,
282
+ type?: string,
283
+ }
284
+
285
+ interface Resource {
286
+ type: 'clientChannel' | 'secret' | 'volume' | 'file' | 'string' | 'number' | 'boolean',
287
+ name: string,
288
+ value: string,
289
+ kind?: 'volatile' | 'nonReplicated' | 'persistent',
290
+ maxItems?: number,
291
+ }
292
+
293
+ interface Link {
294
+ name: string,
295
+ origin: string,
296
+ target: string,
297
+ }
298
+
299
+ ```
300
+
301
+ ## Repository Tree
302
+
303
+ ```
304
+ .
305
+ ├── README.md
306
+ ├── backend-handler.ts
307
+ ├── environment.ts
308
+ ├── event-helper.ts
309
+ ├── event-names.ts
310
+ ├── jest.config.ts
311
+ ├── package.lock.json
312
+ ├── package.json
313
+ ├── tsconfig.json
314
+ ├── interfaces
315
+ │ ├── account-interface.ts
316
+ │ ├── channel-interface.ts
317
+ │ ├── container-interface.ts
318
+ │ ├── environment-interface.ts
319
+ │ ├── instance-interface.ts
320
+ │ ├── link-interface.ts
321
+ │ ├── marketplaceItem-interface.ts
322
+ │ ├── organization-interface.ts
323
+ │ ├── resource-interface.ts
324
+ │ ├── service-interface.ts
325
+ │ ├── tenant-interface.ts
326
+ │ ├── token-interface.ts
327
+ │ ├── usage-interface.ts
328
+ │ └── user-interface.ts
329
+
330
+ ├── api
331
+ │ ├── account-api-service.ts
332
+ │ ├── deploy-service-helper.ts
333
+ │ ├── environment-api-service.ts
334
+ │ ├── marketplace-api-service.ts
335
+ │ ├── organizations-api-service.ts
336
+ │ ├── resources-api-service.ts
337
+ │ ├── service-api-service.ts
338
+ │ ├── tenant-api-service.ts
339
+ │ └── user-api-service.ts
340
+
341
+ ├── test
342
+ │ ├── backend-handler.test.ts
343
+ │ ├── deploy-service-helper.ts
344
+ │ └── event-helper.test.ts
345
+
346
+ ├── coverage
347
+ │ └── coverage data...
348
+
349
+ └── LICENSE
350
+
351
+ ```
352
+ ## License