firstly 0.0.11 → 0.0.13
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 +16 -0
- package/esm/BaseEnum.d.ts +2 -0
- package/esm/BaseEnum.js +2 -0
- package/esm/FF_Fields.js +0 -1
- package/esm/ROUTES.d.ts +2 -2
- package/esm/ROUTES.js +10 -5
- package/esm/SqlDatabase/FF_LogToConsole.d.ts +1 -0
- package/esm/SqlDatabase/FF_LogToConsole.js +22 -16
- package/esm/api/index.d.ts +20 -21
- package/esm/api/index.js +74 -62
- package/esm/auth/{client/Auth.d.ts → AuthController.d.ts} +18 -25
- package/esm/auth/{client/Auth.js → AuthController.js} +48 -44
- package/esm/auth/{client/Entities.d.ts → Entities.d.ts} +4 -3
- package/esm/auth/{client/Entities.js → Entities.js} +7 -7
- package/esm/auth/README.md +0 -10
- package/esm/auth/index.d.ts +5 -149
- package/esm/auth/index.js +5 -316
- package/esm/auth/{AuthController.server.d.ts → server/AuthController.server.d.ts} +10 -10
- package/esm/auth/{AuthController.server.js → server/AuthController.server.js} +133 -171
- package/esm/auth/server/handleAuth.d.ts +2 -0
- package/esm/auth/server/handleAuth.js +140 -0
- package/esm/auth/server/handleGuard.d.ts +16 -0
- package/esm/auth/server/handleGuard.js +67 -0
- package/esm/auth/server/helperDb.d.ts +10 -0
- package/esm/auth/server/helperDb.js +56 -0
- package/esm/auth/server/helperFirstly.d.ts +1 -0
- package/esm/auth/server/helperFirstly.js +8 -0
- package/esm/auth/server/helperOslo.d.ts +7 -0
- package/esm/auth/server/helperOslo.js +24 -0
- package/esm/auth/server/helperRemultServer.d.ts +5 -0
- package/esm/auth/server/helperRemultServer.js +44 -0
- package/esm/auth/{RoleHelpers.d.ts → server/helperRole.d.ts} +1 -1
- package/esm/auth/{RoleHelpers.js → server/helperRole.js} +1 -1
- package/esm/auth/server/index.d.ts +7 -0
- package/esm/auth/server/index.js +7 -0
- package/esm/auth/server/module.d.ts +257 -0
- package/esm/auth/server/module.js +197 -0
- package/esm/auth/{providers → server/providers}/github.d.ts +6 -4
- package/esm/auth/{providers → server/providers}/github.js +29 -20
- package/esm/auth/{providers/index.d.ts → server/providers/helperProvider.d.ts} +0 -2
- package/esm/auth/{providers/index.js → server/providers/helperProvider.js} +5 -6
- package/esm/auth/static/assets/Page-BUfjaN-D.d.ts +5 -0
- package/esm/auth/static/assets/Page-BUfjaN-D.js +19 -0
- package/esm/auth/static/assets/Page-CJ58H1vl.css +1 -0
- package/esm/auth/static/assets/Page-CaDAqmBS.d.ts +5 -0
- package/esm/auth/static/assets/Page-CaDAqmBS.js +1 -0
- package/esm/auth/static/assets/Page-DhdZddzJ.d.ts +5 -0
- package/esm/auth/static/assets/Page-DhdZddzJ.js +1 -0
- package/esm/auth/static/assets/index-BDy4A_14.css +4 -0
- package/esm/auth/static/assets/index-D-Ztdt2o.d.ts +54 -0
- package/esm/auth/static/assets/index-D-Ztdt2o.js +2 -0
- package/esm/auth/static/index.html +11 -11
- package/esm/auth/types.d.ts +5 -0
- package/esm/bin/cmd.js +122 -54
- package/esm/cellsBuildor.js +7 -7
- package/esm/changeLog/index.d.ts +0 -36
- package/esm/changeLog/index.js +3 -43
- package/esm/changeLog/server/index.d.ts +36 -0
- package/esm/changeLog/server/index.js +42 -0
- package/esm/common.d.ts +5 -0
- package/esm/common.js +8 -0
- package/esm/cron/{index.d.ts → server/index.d.ts} +1 -1
- package/esm/cron/server/index.js +103 -0
- package/esm/feedback/FeedbackController.js +4 -5
- package/esm/feedback/index.d.ts +0 -16
- package/esm/feedback/index.js +0 -11
- package/esm/feedback/server/index.d.ts +17 -0
- package/esm/feedback/server/index.js +13 -0
- package/esm/feedback/ui/DialogIssue.svelte +52 -56
- package/esm/feedback/ui/DialogIssues.svelte +71 -71
- package/esm/feedback/ui/DialogMilestones.svelte +22 -22
- package/esm/helper.js +3 -3
- package/esm/index.d.ts +3 -20
- package/esm/index.js +3 -10
- package/esm/mail/index.d.ts +2 -30
- package/esm/mail/index.js +2 -79
- package/esm/mail/server/index.d.ts +31 -0
- package/esm/mail/server/index.js +88 -0
- package/esm/mail/templates/DefaultMail.svelte +17 -17
- package/esm/storeItem.js +8 -2
- package/esm/storeList.d.ts +1 -1
- package/esm/storeList.js +1 -1
- package/esm/sveltekit/server/index.d.ts +14 -0
- package/esm/sveltekit/server/index.js +24 -0
- package/esm/ui/Button.svelte +33 -33
- package/esm/ui/Button.svelte.d.ts +2 -2
- package/esm/ui/Clipboardable.svelte +11 -8
- package/esm/ui/Clipboardable.svelte.d.ts +4 -4
- package/esm/ui/Field.svelte +142 -149
- package/esm/ui/Field.svelte.d.ts +2 -2
- package/esm/ui/FieldGroup.svelte +38 -38
- package/esm/ui/Grid.svelte +212 -222
- package/esm/ui/GridLoading.svelte +18 -22
- package/esm/ui/GridPaginate.svelte +38 -38
- package/esm/ui/Icon.svelte +50 -49
- package/esm/ui/Icon.svelte.d.ts +18 -18
- package/esm/ui/Loading.svelte +5 -2
- package/esm/ui/Tooltip.svelte +16 -16
- package/esm/ui/dialog/DialogForm.svelte +23 -23
- package/esm/ui/dialog/DialogManagement.svelte +74 -74
- package/esm/ui/dialog/DialogPrimitive.svelte +50 -51
- package/esm/ui/dialog/FormEditAction.svelte +34 -34
- package/esm/ui/dialog/dialog.d.ts +2 -2
- package/esm/ui/dialog/dialog.js +1 -1
- package/esm/ui/internals/FieldContainer.svelte +11 -12
- package/esm/ui/internals/FieldContainer.svelte.d.ts +3 -3
- package/esm/ui/internals/Input.svelte +25 -25
- package/esm/ui/internals/Input.svelte.d.ts +1 -1
- package/esm/ui/internals/Textarea.svelte +21 -21
- package/esm/ui/internals/Textarea.svelte.d.ts +2 -2
- package/esm/ui/internals/select/MultiSelectMelt.svelte +69 -73
- package/esm/ui/internals/select/SelectMelt.svelte +86 -86
- package/esm/ui/internals/select/SelectRadio.svelte +22 -22
- package/esm/ui/link/Link.svelte +14 -14
- package/esm/ui/link/Link.svelte.d.ts +3 -4
- package/esm/ui/link/LinkPlus.svelte +33 -35
- package/esm/vite/index.js +24 -25
- package/package.json +50 -42
- package/esm/auth/Adapter.d.ts +0 -10
- package/esm/auth/Adapter.js +0 -50
- package/esm/auth/client/index.d.ts +0 -7
- package/esm/auth/client/index.js +0 -7
- package/esm/auth/helper.d.ts +0 -6
- package/esm/auth/helper.js +0 -14
- package/esm/auth/providers/strava.d.ts +0 -30
- package/esm/auth/providers/strava.js +0 -60
- package/esm/auth/static/assets/Page-BEFYPjis.d.ts +0 -4
- package/esm/auth/static/assets/Page-BEFYPjis.js +0 -1
- package/esm/auth/static/assets/Page-BGTO8LC5.css +0 -1
- package/esm/auth/static/assets/Page-Cfysx_UV.d.ts +0 -6
- package/esm/auth/static/assets/Page-Cfysx_UV.js +0 -18
- package/esm/auth/static/assets/Page-DtgkOCJs.d.ts +0 -4
- package/esm/auth/static/assets/Page-DtgkOCJs.js +0 -1
- package/esm/auth/static/assets/index-CR_3yNaJ.css +0 -4
- package/esm/auth/static/assets/index-QypqCYwC.d.ts +0 -63
- package/esm/auth/static/assets/index-QypqCYwC.js +0 -2
- package/esm/cron/index.js +0 -102
- package/esm/handle/index.d.ts +0 -7
- package/esm/handle/index.js +0 -40
package/esm/bin/cmd.js
CHANGED
|
@@ -47,14 +47,12 @@ function mergeAndSort(deps, depsToAdd) {
|
|
|
47
47
|
return sorted;
|
|
48
48
|
}
|
|
49
49
|
pkg.devDependencies = mergeAndSort(pkg.devDependencies, {
|
|
50
|
-
'@kitql/eslint-config': '0.
|
|
51
|
-
'@kitql/helpers': '0.8.
|
|
50
|
+
'@kitql/eslint-config': '0.5.8',
|
|
51
|
+
'@kitql/helpers': '0.8.12',
|
|
52
52
|
pg: '8.12.0',
|
|
53
53
|
remult: versionFirstly,
|
|
54
54
|
});
|
|
55
|
-
pkg.dependencies = mergeAndSort(pkg.dependencies, {
|
|
56
|
-
oslo: '^1.2.1',
|
|
57
|
-
});
|
|
55
|
+
pkg.dependencies = mergeAndSort(pkg.dependencies, {});
|
|
58
56
|
pkg.scripts = {
|
|
59
57
|
...pkg.scripts,
|
|
60
58
|
'//// ---- BEST PRACTICES ---- ////': '',
|
|
@@ -65,14 +63,26 @@ if (res.includes('all') || res.includes('dependencies')) {
|
|
|
65
63
|
write('./package.json', [JSON.stringify(pkg, null, 2)]);
|
|
66
64
|
}
|
|
67
65
|
const obj = {
|
|
68
|
-
'./.
|
|
69
|
-
`
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
66
|
+
'./.npmrc': [
|
|
67
|
+
`engine-strict=true
|
|
68
|
+
|
|
69
|
+
public-hoist-pattern[]=*eslint*
|
|
70
|
+
public-hoist-pattern[]=*prettier*
|
|
71
|
+
public-hoist-pattern[]=*globals*
|
|
72
|
+
`,
|
|
73
|
+
],
|
|
74
|
+
'./eslint.config.js': [
|
|
75
|
+
`import { kitql } from '@kitql/eslint-config'
|
|
76
|
+
|
|
77
|
+
/** @type { import("eslint").Linter.Config[] } */
|
|
78
|
+
export default [
|
|
79
|
+
...kitql({ pnpmCatalogs: { enable: false } }),
|
|
80
|
+
{
|
|
81
|
+
name: 'APP:ignores',
|
|
82
|
+
ignores: ['**/*.svelte.ts'],
|
|
83
|
+
},
|
|
84
|
+
]
|
|
85
|
+
`,
|
|
76
86
|
],
|
|
77
87
|
'./.prettierignore': [
|
|
78
88
|
`node_modules/
|
|
@@ -96,16 +106,14 @@ db/
|
|
|
96
106
|
src/lib/ROUTES.ts
|
|
97
107
|
`,
|
|
98
108
|
],
|
|
99
|
-
'./.prettierrc.
|
|
100
|
-
`
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
module.exports = {
|
|
106
|
-
...prettierConfig,
|
|
109
|
+
'./.prettierrc.mjs': [
|
|
110
|
+
`import { kitql } from '@kitql/eslint-config/.prettierrc.mjs'
|
|
111
|
+
|
|
112
|
+
export default {
|
|
113
|
+
...kitql(),
|
|
107
114
|
// Your overrides here
|
|
108
|
-
}
|
|
115
|
+
}
|
|
116
|
+
`,
|
|
109
117
|
],
|
|
110
118
|
'.env.example': [
|
|
111
119
|
`# Enable some roles
|
|
@@ -119,9 +127,9 @@ module.exports = {
|
|
|
119
127
|
],
|
|
120
128
|
'./src/lib/firstly/index.ts': [
|
|
121
129
|
`import { FF_Role } from 'firstly'
|
|
122
|
-
import { firstly } from 'firstly/api'
|
|
123
|
-
import { auth } from 'firstly/auth'
|
|
124
|
-
import { changeLog } from 'firstly/changeLog'
|
|
130
|
+
import { firstly, Module } from 'firstly/api'
|
|
131
|
+
import { auth } from 'firstly/auth/server'
|
|
132
|
+
import { changeLog } from 'firstly/changeLog/server'
|
|
125
133
|
import { Log } from '@kitql/helpers'
|
|
126
134
|
|
|
127
135
|
import { task } from './modules/task'
|
|
@@ -157,8 +165,8 @@ export const api = firstly({
|
|
|
157
165
|
providers: {
|
|
158
166
|
demo: [
|
|
159
167
|
{ name: 'Ermin' },
|
|
160
|
-
{ name: 'JYC', roles: [FF_Role.
|
|
161
|
-
{ name: 'Noam', roles: [FF_Role.
|
|
168
|
+
{ name: 'JYC', roles: [FF_Role.FF_Role_Admin] },
|
|
169
|
+
{ name: 'Noam', roles: [FF_Role.FF_Role_Admin, Role.Boss] },
|
|
162
170
|
],
|
|
163
171
|
|
|
164
172
|
// password: {},
|
|
@@ -170,7 +178,7 @@ export const api = firstly({
|
|
|
170
178
|
// To enable OAuth via Github
|
|
171
179
|
// Instructions by hovering the method \`github\`
|
|
172
180
|
// NEEDS ON TOP OF THE FILE:
|
|
173
|
-
// import { github } from 'firstly/auth/
|
|
181
|
+
// import { github } from 'firstly/auth/server'
|
|
174
182
|
//----------------------------------------
|
|
175
183
|
// github(),
|
|
176
184
|
],
|
|
@@ -185,14 +193,14 @@ export const api = firstly({
|
|
|
185
193
|
//----------------------------------------
|
|
186
194
|
// example of a userland inline module
|
|
187
195
|
//----------------------------------------
|
|
188
|
-
{
|
|
196
|
+
new Module({
|
|
189
197
|
name: 'app',
|
|
190
198
|
entities: [],
|
|
191
199
|
controllers: [],
|
|
192
200
|
initApi: async () => {
|
|
193
201
|
log.success('App is ready! 🚀')
|
|
194
202
|
},
|
|
195
|
-
},
|
|
203
|
+
}),
|
|
196
204
|
|
|
197
205
|
//----------------------------------------
|
|
198
206
|
// Replace @Entity by @FF_Entity in your entities to enable changeLog on this entity
|
|
@@ -204,24 +212,50 @@ export const api = firstly({
|
|
|
204
212
|
],
|
|
205
213
|
'./src/hooks.server.ts': [
|
|
206
214
|
`import { sequence } from '@sveltejs/kit/hooks'
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
import { api } from '${libAlias}/firstly'
|
|
211
|
-
|
|
212
|
-
|
|
215
|
+
import { redirect } from '@sveltejs/kit'
|
|
216
|
+
|
|
217
|
+
import { handleAuth, handleGuard } from 'firstly/auth/server'
|
|
218
|
+
import { api as handleRemult } from '${libAlias}/firstly'
|
|
219
|
+
import { route } from '${libAlias}/ROUTES'
|
|
220
|
+
|
|
221
|
+
export const handle = sequence(
|
|
222
|
+
//
|
|
223
|
+
handleRemult,
|
|
224
|
+
handleAuth,
|
|
225
|
+
// client side guard is not here!
|
|
226
|
+
handleGuard({
|
|
227
|
+
authenticated: ['/app*'],
|
|
228
|
+
redirectToLogin: route('/'),
|
|
229
|
+
// You want to redirect to the firstly UI ? change redirectToLogin to this 👇
|
|
230
|
+
// redirectToLogin: route('login'),
|
|
231
|
+
redirectAuthenticated: route('/app'),
|
|
232
|
+
redirect,
|
|
233
|
+
})
|
|
234
|
+
)
|
|
213
235
|
`,
|
|
214
236
|
],
|
|
215
237
|
'./src/routes/api/[...remult]/+server.ts': [
|
|
216
238
|
`import { api } from '${libAlias}/firstly'
|
|
217
239
|
|
|
218
|
-
export const GET = api
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
240
|
+
export const { GET, POST, PUT, DELETE } = api
|
|
241
|
+
`,
|
|
242
|
+
],
|
|
243
|
+
'./src/routes/+page.svelte': [
|
|
244
|
+
`<h1>Home</h1>
|
|
245
|
+
|
|
246
|
+
<p>
|
|
247
|
+
Welcome here
|
|
248
|
+
</p>`,
|
|
249
|
+
],
|
|
250
|
+
'./src/routes/app/+page.svelte': [
|
|
251
|
+
`<h1>App</h1>
|
|
252
|
+
|
|
253
|
+
<p>
|
|
254
|
+
Only autenticated users can see this page!
|
|
255
|
+
</p>
|
|
256
|
+
|
|
222
257
|
`,
|
|
223
258
|
],
|
|
224
|
-
'./src/routes/+page.svelte': [`Home 👋`, ``],
|
|
225
259
|
'./src/routes/+layout.server.ts': [
|
|
226
260
|
`import { remult } from 'remult'
|
|
227
261
|
|
|
@@ -230,6 +264,31 @@ import type { LayoutServerLoad } from './$types'
|
|
|
230
264
|
export const load = (async () => {
|
|
231
265
|
return { user: remult.user }
|
|
232
266
|
}) satisfies LayoutServerLoad
|
|
267
|
+
`,
|
|
268
|
+
],
|
|
269
|
+
'./src/routes/+layout.ts': [
|
|
270
|
+
`import { remult } from 'remult'
|
|
271
|
+
import type { LayoutLoad } from './$types'
|
|
272
|
+
|
|
273
|
+
export const load = (async (event) => {
|
|
274
|
+
// Instruct remult to use the special svelte fetch
|
|
275
|
+
// Like this univeral load will work in SSR & CSR
|
|
276
|
+
remult.useFetch(event.fetch)
|
|
277
|
+
// return repo(Task).find()
|
|
278
|
+
return { ...event.data }
|
|
279
|
+
}) satisfies LayoutLoad
|
|
280
|
+
`,
|
|
281
|
+
],
|
|
282
|
+
'./src/routes/+page.ts': [
|
|
283
|
+
`import { remult } from 'remult'
|
|
284
|
+
import type { PageLoad } from './$types'
|
|
285
|
+
|
|
286
|
+
export const load = (async (event) => {
|
|
287
|
+
// Instruct remult to use the special svelte fetch
|
|
288
|
+
// Like this univeral load will work in SSR & CSR
|
|
289
|
+
remult.useFetch(event.fetch)
|
|
290
|
+
// return repo(Task).find()
|
|
291
|
+
}) satisfies PageLoad
|
|
233
292
|
`,
|
|
234
293
|
],
|
|
235
294
|
'./src/routes/+layout.svelte': [
|
|
@@ -268,11 +327,19 @@ export const load = (async () => {
|
|
|
268
327
|
<SignIn demo="Noam"></SignIn>
|
|
269
328
|
<br />
|
|
270
329
|
<SignIn ffLink></SignIn>
|
|
330
|
+
<br />
|
|
271
331
|
<SignIn oauth="github"></SignIn>
|
|
272
332
|
{/if}
|
|
273
333
|
|
|
274
334
|
<hr />
|
|
275
335
|
|
|
336
|
+
<a href={route('/')}>Home</a> |
|
|
337
|
+
{#if remult.authenticated()}
|
|
338
|
+
<a href={route('/app')}>App (Protected route)</a>
|
|
339
|
+
{/if}
|
|
340
|
+
|
|
341
|
+
<hr />
|
|
342
|
+
|
|
276
343
|
<slot />
|
|
277
344
|
|
|
278
345
|
<hr />
|
|
@@ -291,11 +358,11 @@ export const load = (async () => {
|
|
|
291
358
|
'./src/lib/ui/SignIn.svelte': [
|
|
292
359
|
`<script lang="ts">
|
|
293
360
|
import { isError } from 'firstly'
|
|
294
|
-
import {
|
|
361
|
+
import { AuthController } from 'firstly/auth/client'
|
|
295
362
|
|
|
296
363
|
import { goto, invalidateAll } from '$app/navigation'
|
|
297
364
|
|
|
298
|
-
import { route } from '
|
|
365
|
+
import { route } from '${libAlias}/ROUTES'
|
|
299
366
|
|
|
300
367
|
// Examples of signin modes
|
|
301
368
|
export let demo = ''
|
|
@@ -304,11 +371,11 @@ export const load = (async () => {
|
|
|
304
371
|
|
|
305
372
|
const signinDemo = async (identif: string) => {
|
|
306
373
|
try {
|
|
307
|
-
await
|
|
374
|
+
await AuthController.signInDemo(identif)
|
|
308
375
|
invalidateAll()
|
|
309
376
|
} catch (error) {
|
|
310
377
|
if (isError(error)) {
|
|
311
|
-
//
|
|
378
|
+
// You will probably not leave this alert in production
|
|
312
379
|
alert(error.message)
|
|
313
380
|
}
|
|
314
381
|
}
|
|
@@ -316,13 +383,13 @@ export const load = (async () => {
|
|
|
316
383
|
|
|
317
384
|
async function signinOAuth(provider: 'github') {
|
|
318
385
|
try {
|
|
319
|
-
window.location.href = await
|
|
386
|
+
window.location.href = await AuthController.signInOAuthGetUrl({
|
|
320
387
|
provider,
|
|
321
388
|
redirect: window.location.pathname,
|
|
322
389
|
})
|
|
323
390
|
} catch (error) {
|
|
324
391
|
if (isError(error)) {
|
|
325
|
-
//
|
|
392
|
+
// You will probably not leave this alert in production
|
|
326
393
|
alert(error.message)
|
|
327
394
|
}
|
|
328
395
|
}
|
|
@@ -332,7 +399,7 @@ export const load = (async () => {
|
|
|
332
399
|
{#if demo}
|
|
333
400
|
<button on:click={() => signinDemo(demo)}>Login as {demo}</button>
|
|
334
401
|
{:else if ffLink}
|
|
335
|
-
<button on:click={() => goto(route('
|
|
402
|
+
<button on:click={() => goto(route('login'))}>Login with Firstly UI</button>
|
|
336
403
|
{:else if oauth}
|
|
337
404
|
<button on:click={() => signinOAuth(oauth)}>Login With {oauth}</button>
|
|
338
405
|
{/if}
|
|
@@ -341,13 +408,13 @@ export const load = (async () => {
|
|
|
341
408
|
'./src/lib/ui/SignOut.svelte': [
|
|
342
409
|
`<script lang="ts">
|
|
343
410
|
import { isError } from 'firstly'
|
|
344
|
-
import {
|
|
411
|
+
import { AuthController } from 'firstly/auth/client'
|
|
345
412
|
|
|
346
413
|
import { invalidateAll } from '$app/navigation'
|
|
347
414
|
|
|
348
415
|
const logout = async () => {
|
|
349
416
|
try {
|
|
350
|
-
await
|
|
417
|
+
await AuthController.signOut()
|
|
351
418
|
invalidateAll()
|
|
352
419
|
} catch (error) {
|
|
353
420
|
if (isError(error)) {
|
|
@@ -392,10 +459,11 @@ import type { KIT_ROUTES } from '${libAlias}/ROUTES'
|
|
|
392
459
|
|
|
393
460
|
export default defineConfig({
|
|
394
461
|
plugins: [
|
|
462
|
+
// @ts-ignore JYC TODO (vite 5 / vite 6...)
|
|
395
463
|
firstly<KIT_ROUTES>({
|
|
396
464
|
kitRoutes: {
|
|
397
465
|
LINKS: {
|
|
398
|
-
|
|
466
|
+
login: 'ff/auth/sign-in',
|
|
399
467
|
github: 'https://github.com/[owner]/[repo]',
|
|
400
468
|
remult_admin: 'api/admin',
|
|
401
469
|
},
|
|
@@ -428,7 +496,7 @@ vite.config.ts.timestamp-*
|
|
|
428
496
|
`,
|
|
429
497
|
],
|
|
430
498
|
'./src/lib/firstly/modules/task/index.ts': [
|
|
431
|
-
`import
|
|
499
|
+
`import { Module } from 'firstly/api'
|
|
432
500
|
|
|
433
501
|
import { log } from '${libAlias}/firstly'
|
|
434
502
|
|
|
@@ -436,14 +504,14 @@ import { Task } from './Task'
|
|
|
436
504
|
import { TaskController } from './TaskController'
|
|
437
505
|
|
|
438
506
|
export const task: (o: { specialInfo: string }) => Module = ({ specialInfo }) => {
|
|
439
|
-
return {
|
|
507
|
+
return new Module({
|
|
440
508
|
name: 'task',
|
|
441
509
|
entities: [Task],
|
|
442
510
|
controllers: [TaskController],
|
|
443
511
|
initApi: async () => {
|
|
444
512
|
log.success(\`Task module is ready! 🚀 (specialInfo: \${specialInfo})\`)
|
|
445
513
|
},
|
|
446
|
-
}
|
|
514
|
+
})
|
|
447
515
|
}`,
|
|
448
516
|
],
|
|
449
517
|
'./src/lib/firstly/modules/task/Task.ts': [
|
package/esm/cellsBuildor.js
CHANGED
|
@@ -55,9 +55,6 @@ export const buildSearchWhere = (entity, fields, search) => {
|
|
|
55
55
|
const f = [
|
|
56
56
|
{
|
|
57
57
|
$or: fields.map((f) => {
|
|
58
|
-
// REMULT P1: isServerExpression is false when sqlExpression there ?!
|
|
59
|
-
// if (f.isServerExpression || f.options.sqlExpression) {
|
|
60
|
-
// check if this field has a specific filter function
|
|
61
58
|
const fnName = f.key + 'Filter';
|
|
62
59
|
// @ts-ignore
|
|
63
60
|
if (entity && entity[fnName]) {
|
|
@@ -77,6 +74,9 @@ export const buildSearchWhere = (entity, fields, search) => {
|
|
|
77
74
|
return f;
|
|
78
75
|
};
|
|
79
76
|
export const containsWords = (fields, search) => {
|
|
77
|
+
if (!search) {
|
|
78
|
+
return {};
|
|
79
|
+
}
|
|
80
80
|
const sSplitted = search.split(' ').filter((s) => s.length > 0);
|
|
81
81
|
if (fields.length === 1) {
|
|
82
82
|
return {
|
|
@@ -84,8 +84,8 @@ export const containsWords = (fields, search) => {
|
|
|
84
84
|
};
|
|
85
85
|
}
|
|
86
86
|
return {
|
|
87
|
-
$
|
|
88
|
-
return { $
|
|
87
|
+
$and: sSplitted.map((s) => {
|
|
88
|
+
return { $or: fields.map((f) => ({ [f.key]: { $contains: s } })) };
|
|
89
89
|
}),
|
|
90
90
|
};
|
|
91
91
|
};
|
|
@@ -94,12 +94,12 @@ export const buildWhere = (entity, defaultWhere, fields_filter, fields_search, o
|
|
|
94
94
|
if (defaultWhere) {
|
|
95
95
|
and.push(defaultWhere);
|
|
96
96
|
}
|
|
97
|
-
if (obj.search) {
|
|
97
|
+
if (obj && obj.search) {
|
|
98
98
|
and.push(...buildSearchWhere(entity, fields_search, obj.search));
|
|
99
99
|
}
|
|
100
100
|
for (const field of fields_filter) {
|
|
101
101
|
// if there is a value
|
|
102
|
-
if (obj[field.key]) {
|
|
102
|
+
if (obj && obj[field.key]) {
|
|
103
103
|
const rfi = getRelationFieldInfo(field);
|
|
104
104
|
if (field.inputType === 'checkbox') {
|
|
105
105
|
// @ts-ignore
|
package/esm/changeLog/index.d.ts
CHANGED
|
@@ -1,40 +1,4 @@
|
|
|
1
1
|
import { type FieldRef, type FieldsRef, type LifecycleEvent } from 'remult';
|
|
2
|
-
import type { Module } from '../api';
|
|
3
|
-
/**
|
|
4
|
-
* ## Default way
|
|
5
|
-
* The easiest is to switch from `@Entity` to `@FF_Entity` to the entities where you want to log changes.
|
|
6
|
-
*
|
|
7
|
-
* ```ts
|
|
8
|
-
* \@FF_Entity<User>('users', {
|
|
9
|
-
*
|
|
10
|
-
* // Optional => To disable change logs
|
|
11
|
-
* // changeLog: false,
|
|
12
|
-
*
|
|
13
|
-
* // Optional => To disable some columns from being logged
|
|
14
|
-
* // changeLog: {
|
|
15
|
-
* // excludeColumns: (e) => {
|
|
16
|
-
* // return [e.password]
|
|
17
|
-
* // },
|
|
18
|
-
* // },
|
|
19
|
-
* })
|
|
20
|
-
* export class User {}
|
|
21
|
-
* ```
|
|
22
|
-
*
|
|
23
|
-
* ## Manual way
|
|
24
|
-
* If you want to go more manual, you can import these functions and call them in your entity's lifecycle events.
|
|
25
|
-
* ```ts
|
|
26
|
-
* \@Entity<User>('users', {
|
|
27
|
-
* saved: async (entity, e) => {
|
|
28
|
-
* await recordSaved(entity, e)
|
|
29
|
-
* },
|
|
30
|
-
* deleted: async (entity, e) => {
|
|
31
|
-
* await recordDeleted(entity, e)
|
|
32
|
-
* },
|
|
33
|
-
* })
|
|
34
|
-
* export class User {}
|
|
35
|
-
* ```
|
|
36
|
-
*/
|
|
37
|
-
export declare const changeLog: () => Module;
|
|
38
2
|
export declare class ChangeLog {
|
|
39
3
|
id: string;
|
|
40
4
|
entity: string;
|
package/esm/changeLog/index.js
CHANGED
|
@@ -4,47 +4,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import { Entity, Fields, getEntityRef, IdEntity, isBackend, remult, } from 'remult';
|
|
8
|
-
/**
|
|
9
|
-
* ## Default way
|
|
10
|
-
* The easiest is to switch from `@Entity` to `@FF_Entity` to the entities where you want to log changes.
|
|
11
|
-
*
|
|
12
|
-
* ```ts
|
|
13
|
-
* \@FF_Entity<User>('users', {
|
|
14
|
-
*
|
|
15
|
-
* // Optional => To disable change logs
|
|
16
|
-
* // changeLog: false,
|
|
17
|
-
*
|
|
18
|
-
* // Optional => To disable some columns from being logged
|
|
19
|
-
* // changeLog: {
|
|
20
|
-
* // excludeColumns: (e) => {
|
|
21
|
-
* // return [e.password]
|
|
22
|
-
* // },
|
|
23
|
-
* // },
|
|
24
|
-
* })
|
|
25
|
-
* export class User {}
|
|
26
|
-
* ```
|
|
27
|
-
*
|
|
28
|
-
* ## Manual way
|
|
29
|
-
* If you want to go more manual, you can import these functions and call them in your entity's lifecycle events.
|
|
30
|
-
* ```ts
|
|
31
|
-
* \@Entity<User>('users', {
|
|
32
|
-
* saved: async (entity, e) => {
|
|
33
|
-
* await recordSaved(entity, e)
|
|
34
|
-
* },
|
|
35
|
-
* deleted: async (entity, e) => {
|
|
36
|
-
* await recordDeleted(entity, e)
|
|
37
|
-
* },
|
|
38
|
-
* })
|
|
39
|
-
* export class User {}
|
|
40
|
-
* ```
|
|
41
|
-
*/
|
|
42
|
-
export const changeLog = () => {
|
|
43
|
-
return {
|
|
44
|
-
name: 'changeLog',
|
|
45
|
-
entities: [ChangeLog],
|
|
46
|
-
};
|
|
47
|
-
};
|
|
7
|
+
import { Entity, Fields, getEntityRef, IdEntity, isBackend, remult, repo, } from 'remult';
|
|
48
8
|
let ChangeLog = class ChangeLog {
|
|
49
9
|
id = '';
|
|
50
10
|
entity = '';
|
|
@@ -120,7 +80,7 @@ export async function recordSaved(entity, e, options) {
|
|
|
120
80
|
}
|
|
121
81
|
}
|
|
122
82
|
if (changes.length > 0) {
|
|
123
|
-
await
|
|
83
|
+
await repo(ChangeLog).insert({
|
|
124
84
|
changeDate,
|
|
125
85
|
changes,
|
|
126
86
|
entity: e.metadata.key,
|
|
@@ -153,7 +113,7 @@ export async function recordDeleted(entity, e, options) {
|
|
|
153
113
|
throw err;
|
|
154
114
|
}
|
|
155
115
|
}
|
|
156
|
-
await
|
|
116
|
+
await repo(ChangeLog).insert({
|
|
157
117
|
changeDate,
|
|
158
118
|
changes,
|
|
159
119
|
entity: e.metadata.key,
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Module } from '../../api';
|
|
2
|
+
/**
|
|
3
|
+
* ## Default way
|
|
4
|
+
* The easiest is to switch from `@Entity` to `@FF_Entity` to the entities where you want to log changes.
|
|
5
|
+
*
|
|
6
|
+
* ```ts
|
|
7
|
+
* \@FF_Entity<User>('users', {
|
|
8
|
+
*
|
|
9
|
+
* // Optional => To disable change logs
|
|
10
|
+
* // changeLog: false,
|
|
11
|
+
*
|
|
12
|
+
* // Optional => To disable some columns from being logged
|
|
13
|
+
* // changeLog: {
|
|
14
|
+
* // excludeColumns: (e) => {
|
|
15
|
+
* // return [e.password]
|
|
16
|
+
* // },
|
|
17
|
+
* // },
|
|
18
|
+
* })
|
|
19
|
+
* export class User {}
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* ## Manual way
|
|
23
|
+
* If you want to go more manual, you can import these functions and call them in your entity's lifecycle events.
|
|
24
|
+
* ```ts
|
|
25
|
+
* \@Entity<User>('users', {
|
|
26
|
+
* saved: async (entity, e) => {
|
|
27
|
+
* await recordSaved(entity, e)
|
|
28
|
+
* },
|
|
29
|
+
* deleted: async (entity, e) => {
|
|
30
|
+
* await recordDeleted(entity, e)
|
|
31
|
+
* },
|
|
32
|
+
* })
|
|
33
|
+
* export class User {}
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare const changeLog: () => Module;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Module } from '../../api';
|
|
2
|
+
import { ChangeLog } from '../index';
|
|
3
|
+
/**
|
|
4
|
+
* ## Default way
|
|
5
|
+
* The easiest is to switch from `@Entity` to `@FF_Entity` to the entities where you want to log changes.
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* \@FF_Entity<User>('users', {
|
|
9
|
+
*
|
|
10
|
+
* // Optional => To disable change logs
|
|
11
|
+
* // changeLog: false,
|
|
12
|
+
*
|
|
13
|
+
* // Optional => To disable some columns from being logged
|
|
14
|
+
* // changeLog: {
|
|
15
|
+
* // excludeColumns: (e) => {
|
|
16
|
+
* // return [e.password]
|
|
17
|
+
* // },
|
|
18
|
+
* // },
|
|
19
|
+
* })
|
|
20
|
+
* export class User {}
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* ## Manual way
|
|
24
|
+
* If you want to go more manual, you can import these functions and call them in your entity's lifecycle events.
|
|
25
|
+
* ```ts
|
|
26
|
+
* \@Entity<User>('users', {
|
|
27
|
+
* saved: async (entity, e) => {
|
|
28
|
+
* await recordSaved(entity, e)
|
|
29
|
+
* },
|
|
30
|
+
* deleted: async (entity, e) => {
|
|
31
|
+
* await recordDeleted(entity, e)
|
|
32
|
+
* },
|
|
33
|
+
* })
|
|
34
|
+
* export class User {}
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export const changeLog = () => {
|
|
38
|
+
return new Module({
|
|
39
|
+
name: 'changeLog',
|
|
40
|
+
entities: [ChangeLog],
|
|
41
|
+
});
|
|
42
|
+
};
|
package/esm/common.d.ts
ADDED
package/esm/common.js
ADDED