stellarium-ts 0.1.0 → 0.3.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/LICENSE +201 -0
- package/dist/client/operatorClient.d.ts +20 -0
- package/dist/client/operatorClient.d.ts.map +1 -0
- package/dist/client/operatorClient.js +18 -0
- package/dist/crypto/utils.d.ts +3 -0
- package/dist/crypto/utils.d.ts.map +1 -0
- package/dist/crypto/utils.js +19 -0
- package/dist/db/db.d.ts.map +1 -1
- package/dist/db/db.js +27 -7
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/peer/repository.d.ts +3 -0
- package/dist/peer/repository.d.ts.map +1 -1
- package/dist/peer/repository.js +22 -1
- package/dist/resource/invoker.d.ts +17 -0
- package/dist/resource/invoker.d.ts.map +1 -1
- package/dist/resource/invoker.js +43 -9
- package/dist/resource/repository.d.ts +35 -0
- package/dist/resource/repository.d.ts.map +1 -0
- package/dist/resource/repository.js +168 -0
- package/dist/resource/resolver.d.ts +1 -1
- package/dist/resource/resolver.d.ts.map +1 -1
- package/dist/routes.d.ts.map +1 -1
- package/dist/routes.js +53 -3
- package/dist/server.d.ts +2 -2
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +3 -3
- package/dist/service.d.ts +5 -3
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +6 -2
- package/dist/startup.d.ts +8 -2
- package/dist/startup.d.ts.map +1 -1
- package/dist/startup.js +77 -3
- package/dist/tests/crypto/utils.test.d.ts +2 -0
- package/dist/tests/crypto/utils.test.d.ts.map +1 -0
- package/dist/tests/crypto/utils.test.js +31 -0
- package/package.json +9 -3
- package/README.md +0 -3
- package/dist/resource/resource.d.ts +0 -16
- package/dist/resource/resource.d.ts.map +0 -1
- package/dist/resource/resource.js +0 -78
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
export class ResourceRepository {
|
|
2
|
-
db;
|
|
3
|
-
resources;
|
|
4
|
-
constructor(db, resources = []) {
|
|
5
|
-
this.db = db;
|
|
6
|
-
this.resources = resources;
|
|
7
|
-
}
|
|
8
|
-
async create(resource, baseUrl) {
|
|
9
|
-
const createdAt = new Date().toISOString();
|
|
10
|
-
await this.db.run('INSERT INTO resources (path, name, base_url, created_at, updated_at) VALUES (?, ?, ?, ?, ?)', [resource.path, resource.name, baseUrl, createdAt, createdAt]);
|
|
11
|
-
}
|
|
12
|
-
async getResource(key) {
|
|
13
|
-
const resource = this.resources.find(r => `${r.path}.${r.name}` === key);
|
|
14
|
-
if (resource) {
|
|
15
|
-
return resource;
|
|
16
|
-
}
|
|
17
|
-
// Split the key with format path.path.path.*.Name
|
|
18
|
-
const pathName = key.split('.');
|
|
19
|
-
const name = pathName.pop();
|
|
20
|
-
const path = pathName.join('.');
|
|
21
|
-
const result = await this.db.get('SELECT * FROM resources WHERE path = ? AND name = ?', [path, name]);
|
|
22
|
-
if (!result) {
|
|
23
|
-
return undefined;
|
|
24
|
-
}
|
|
25
|
-
const resourceFunctions = await this.db.all('SELECT * FROM resource_functions WHERE resource_id = ?', [result.id]);
|
|
26
|
-
return {
|
|
27
|
-
path: result.path,
|
|
28
|
-
name: result.name,
|
|
29
|
-
functions: await Promise.all(resourceFunctions.map(async (f) => ({
|
|
30
|
-
name: f.name,
|
|
31
|
-
returnType: f.return_type,
|
|
32
|
-
parameters: await this.getResourceParameters(f.id),
|
|
33
|
-
// The ExternalResourceInvoker will handle the execution of the function
|
|
34
|
-
exec: async () => {
|
|
35
|
-
return void 0;
|
|
36
|
-
}
|
|
37
|
-
}))),
|
|
38
|
-
metadata: {
|
|
39
|
-
baseUrl: result.base_url,
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
async getExternalResources() {
|
|
44
|
-
const results = await this.db.get('SELECT * FROM resources');
|
|
45
|
-
if (!results) {
|
|
46
|
-
return [];
|
|
47
|
-
}
|
|
48
|
-
return Promise.all(results.map(async (r) => ({
|
|
49
|
-
path: r.path,
|
|
50
|
-
name: r.name,
|
|
51
|
-
functions: await Promise.all(r.resource_functions.map(async (f) => ({
|
|
52
|
-
name: f.name,
|
|
53
|
-
returnType: f.return_type,
|
|
54
|
-
parameters: await this.getResourceParameters(f.id),
|
|
55
|
-
}))),
|
|
56
|
-
metadata: {
|
|
57
|
-
baseUrl: r.base_url,
|
|
58
|
-
}
|
|
59
|
-
})));
|
|
60
|
-
}
|
|
61
|
-
async getResourceParameters(resourceFunctionId) {
|
|
62
|
-
return (await this.db.all('SELECT * FROM resource_function_parameters WHERE resource_function_id = ?', [resourceFunctionId])).map(p => ({
|
|
63
|
-
name: p.name,
|
|
64
|
-
type: p.parameter_type,
|
|
65
|
-
}));
|
|
66
|
-
}
|
|
67
|
-
async getAllResources() {
|
|
68
|
-
const externalResources = await this.getExternalResources();
|
|
69
|
-
let resources = [];
|
|
70
|
-
for (const resource of Object.values(this.resources)) {
|
|
71
|
-
resources.push({ ...resource, baseUrl: process.env.BASE_URL });
|
|
72
|
-
}
|
|
73
|
-
for (const resource of externalResources) {
|
|
74
|
-
resources.push({ ...resource, baseUrl: resource.metadata.baseUrl });
|
|
75
|
-
}
|
|
76
|
-
return resources;
|
|
77
|
-
}
|
|
78
|
-
}
|