firstly 0.0.14 → 0.0.15
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/CHANGELOG.md +8 -0
- package/esm/auth/server/AuthController.server.js +2 -1
- package/esm/auth/server/module.d.ts +1 -1
- package/esm/auth/server/module.js +1 -1
- package/esm/auth/static/assets/{Page-UV_hqY7I.d.ts → Page-B1GE_oYi.d.ts} +2 -2
- package/esm/auth/static/assets/{Page-B0XXxe0N.js → Page-B1GE_oYi.js} +1 -1
- package/esm/auth/static/assets/{Page-B0XXxe0N.d.ts → Page-CDHFtYuN.d.ts} +2 -2
- package/esm/auth/static/assets/{Page-UV_hqY7I.js → Page-CDHFtYuN.js} +1 -1
- package/esm/auth/static/assets/{Page-DdKMiUZn.d.ts → Page-Dh8pvAo6.d.ts} +2 -2
- package/esm/auth/static/assets/{Page-DdKMiUZn.js → Page-Dh8pvAo6.js} +5 -5
- package/esm/auth/static/assets/{index-C9jzxOBu.js → index-7Nh2ct-y.js} +2 -2
- package/esm/auth/static/index.html +2 -2
- package/esm/bin/cmd.js +16 -16
- package/esm/changeLog/server/index.d.ts +1 -1
- package/esm/changeLog/server/index.js +1 -1
- package/esm/cron/server/index.d.ts +1 -1
- package/esm/cron/server/index.js +1 -1
- package/esm/feedback/server/index.d.ts +1 -1
- package/esm/feedback/server/index.js +1 -1
- package/esm/mail/server/index.d.ts +2 -2
- package/esm/mail/server/index.js +5 -3
- package/esm/server/index.d.ts +49 -0
- package/esm/server/index.js +109 -1
- package/esm/sveltekit/server/index.d.ts +1 -1
- package/esm/sveltekit/server/index.js +1 -1
- package/package.json +12 -12
- package/esm/api/index.d.ts +0 -49
- package/esm/api/index.js +0 -109
- /package/esm/auth/static/assets/{index-C9jzxOBu.d.ts → index-7Nh2ct-y.d.ts} +0 -0
package/esm/api/index.js
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import {} from 'remult';
|
|
2
|
-
import { remultSveltekit } from 'remult/remult-sveltekit';
|
|
3
|
-
import { Log } from '@kitql/helpers';
|
|
4
|
-
import { building } from '$app/environment';
|
|
5
|
-
import { sveltekit } from '../sveltekit/server';
|
|
6
|
-
export class Module {
|
|
7
|
-
name;
|
|
8
|
-
log;
|
|
9
|
-
priority;
|
|
10
|
-
entities;
|
|
11
|
-
controllers;
|
|
12
|
-
initApi;
|
|
13
|
-
initRequest;
|
|
14
|
-
modules;
|
|
15
|
-
constructor(input) {
|
|
16
|
-
this.name = input.name;
|
|
17
|
-
this.log = new Log(`firstly | ${this.name}`);
|
|
18
|
-
this.priority = input.priority;
|
|
19
|
-
this.entities = input.entities;
|
|
20
|
-
this.controllers = input.controllers;
|
|
21
|
-
this.initApi = input.initApi;
|
|
22
|
-
this.initRequest = input.initRequest;
|
|
23
|
-
this.modules = input.modules;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
export let entities = [];
|
|
27
|
-
/**
|
|
28
|
-
* it's basically `remultSveltekit` with the `modules` option
|
|
29
|
-
* @deprecated will be done directly in remult when modules will be in 😉
|
|
30
|
-
*/
|
|
31
|
-
export const firstly = (o) => {
|
|
32
|
-
const modulesSorted = modulesFlatAndOrdered([
|
|
33
|
-
...[...(o.modules ?? []), sveltekit()],
|
|
34
|
-
new Module({
|
|
35
|
-
name: 'default',
|
|
36
|
-
entities: o.entities ?? [],
|
|
37
|
-
controllers: o.controllers ?? [],
|
|
38
|
-
initRequest: o.initRequest,
|
|
39
|
-
initApi: o.initApi,
|
|
40
|
-
}),
|
|
41
|
-
]);
|
|
42
|
-
entities = modulesSorted.flatMap((m) => m.entities ?? []);
|
|
43
|
-
return remultSveltekit({
|
|
44
|
-
// Changing the default default of remult
|
|
45
|
-
logApiEndPoints: false,
|
|
46
|
-
admin: true,
|
|
47
|
-
defaultGetLimit: 25,
|
|
48
|
-
error: o.error
|
|
49
|
-
? o.error
|
|
50
|
-
: async (e) => {
|
|
51
|
-
// REMULT P2: validation error should probably be 409
|
|
52
|
-
// if 400 we move to 409
|
|
53
|
-
if (e.httpStatusCode == 400) {
|
|
54
|
-
e.sendError(409, e.responseBody);
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
// Add user configuration
|
|
58
|
-
...o,
|
|
59
|
-
// Module part
|
|
60
|
-
entities,
|
|
61
|
-
controllers: modulesSorted.flatMap((m) => m.controllers ?? []),
|
|
62
|
-
initRequest: async (kitEvent, op) => {
|
|
63
|
-
for (let i = 0; i < modulesSorted.length; i++) {
|
|
64
|
-
const f = modulesSorted[i].initRequest;
|
|
65
|
-
if (f) {
|
|
66
|
-
try {
|
|
67
|
-
await f(kitEvent, op);
|
|
68
|
-
}
|
|
69
|
-
catch (error) {
|
|
70
|
-
modulesSorted[i].log.error(error);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
},
|
|
75
|
-
initApi: async (r) => {
|
|
76
|
-
if (!building) {
|
|
77
|
-
for (let i = 0; i < modulesSorted.length; i++) {
|
|
78
|
-
const f = modulesSorted[i].initApi;
|
|
79
|
-
if (f) {
|
|
80
|
-
try {
|
|
81
|
-
await f(r);
|
|
82
|
-
}
|
|
83
|
-
catch (error) {
|
|
84
|
-
modulesSorted[i].log.error(error);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
},
|
|
90
|
-
});
|
|
91
|
-
};
|
|
92
|
-
/**
|
|
93
|
-
* Full flat and ordered list by index and concatenaining the modules name
|
|
94
|
-
*/
|
|
95
|
-
export const modulesFlatAndOrdered = (modules) => {
|
|
96
|
-
const flattenModules = (modules, parentName = '') => {
|
|
97
|
-
return modules.reduce((acc, module) => {
|
|
98
|
-
const fullName = parentName ? `${parentName}-${module.name}` : module.name;
|
|
99
|
-
// Create a new module object without the 'modules' property
|
|
100
|
-
const { modules: _, ...flatModule } = module;
|
|
101
|
-
const newModule = { ...flatModule, name: fullName };
|
|
102
|
-
const subModules = module.modules ? flattenModules(module.modules, fullName) : [];
|
|
103
|
-
return [...acc, newModule, ...subModules];
|
|
104
|
-
}, []);
|
|
105
|
-
};
|
|
106
|
-
const flatModules = flattenModules(modules);
|
|
107
|
-
flatModules.sort((a, b) => (a.priority || 0) - (b.priority || 0));
|
|
108
|
-
return flatModules;
|
|
109
|
-
};
|
|
File without changes
|