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.
Files changed (139) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/esm/BaseEnum.d.ts +2 -0
  3. package/esm/BaseEnum.js +2 -0
  4. package/esm/FF_Fields.js +0 -1
  5. package/esm/ROUTES.d.ts +2 -2
  6. package/esm/ROUTES.js +10 -5
  7. package/esm/SqlDatabase/FF_LogToConsole.d.ts +1 -0
  8. package/esm/SqlDatabase/FF_LogToConsole.js +22 -16
  9. package/esm/api/index.d.ts +20 -21
  10. package/esm/api/index.js +74 -62
  11. package/esm/auth/{client/Auth.d.ts → AuthController.d.ts} +18 -25
  12. package/esm/auth/{client/Auth.js → AuthController.js} +48 -44
  13. package/esm/auth/{client/Entities.d.ts → Entities.d.ts} +4 -3
  14. package/esm/auth/{client/Entities.js → Entities.js} +7 -7
  15. package/esm/auth/README.md +0 -10
  16. package/esm/auth/index.d.ts +5 -149
  17. package/esm/auth/index.js +5 -316
  18. package/esm/auth/{AuthController.server.d.ts → server/AuthController.server.d.ts} +10 -10
  19. package/esm/auth/{AuthController.server.js → server/AuthController.server.js} +133 -171
  20. package/esm/auth/server/handleAuth.d.ts +2 -0
  21. package/esm/auth/server/handleAuth.js +140 -0
  22. package/esm/auth/server/handleGuard.d.ts +16 -0
  23. package/esm/auth/server/handleGuard.js +67 -0
  24. package/esm/auth/server/helperDb.d.ts +10 -0
  25. package/esm/auth/server/helperDb.js +56 -0
  26. package/esm/auth/server/helperFirstly.d.ts +1 -0
  27. package/esm/auth/server/helperFirstly.js +8 -0
  28. package/esm/auth/server/helperOslo.d.ts +7 -0
  29. package/esm/auth/server/helperOslo.js +24 -0
  30. package/esm/auth/server/helperRemultServer.d.ts +5 -0
  31. package/esm/auth/server/helperRemultServer.js +44 -0
  32. package/esm/auth/{RoleHelpers.d.ts → server/helperRole.d.ts} +1 -1
  33. package/esm/auth/{RoleHelpers.js → server/helperRole.js} +1 -1
  34. package/esm/auth/server/index.d.ts +7 -0
  35. package/esm/auth/server/index.js +7 -0
  36. package/esm/auth/server/module.d.ts +257 -0
  37. package/esm/auth/server/module.js +197 -0
  38. package/esm/auth/{providers → server/providers}/github.d.ts +6 -4
  39. package/esm/auth/{providers → server/providers}/github.js +29 -20
  40. package/esm/auth/{providers/index.d.ts → server/providers/helperProvider.d.ts} +0 -2
  41. package/esm/auth/{providers/index.js → server/providers/helperProvider.js} +5 -6
  42. package/esm/auth/static/assets/Page-BUfjaN-D.d.ts +5 -0
  43. package/esm/auth/static/assets/Page-BUfjaN-D.js +19 -0
  44. package/esm/auth/static/assets/Page-CJ58H1vl.css +1 -0
  45. package/esm/auth/static/assets/Page-CaDAqmBS.d.ts +5 -0
  46. package/esm/auth/static/assets/Page-CaDAqmBS.js +1 -0
  47. package/esm/auth/static/assets/Page-DhdZddzJ.d.ts +5 -0
  48. package/esm/auth/static/assets/Page-DhdZddzJ.js +1 -0
  49. package/esm/auth/static/assets/index-BDy4A_14.css +4 -0
  50. package/esm/auth/static/assets/index-D-Ztdt2o.d.ts +54 -0
  51. package/esm/auth/static/assets/index-D-Ztdt2o.js +2 -0
  52. package/esm/auth/static/index.html +11 -11
  53. package/esm/auth/types.d.ts +5 -0
  54. package/esm/bin/cmd.js +122 -54
  55. package/esm/cellsBuildor.js +7 -7
  56. package/esm/changeLog/index.d.ts +0 -36
  57. package/esm/changeLog/index.js +3 -43
  58. package/esm/changeLog/server/index.d.ts +36 -0
  59. package/esm/changeLog/server/index.js +42 -0
  60. package/esm/common.d.ts +5 -0
  61. package/esm/common.js +8 -0
  62. package/esm/cron/{index.d.ts → server/index.d.ts} +1 -1
  63. package/esm/cron/server/index.js +103 -0
  64. package/esm/feedback/FeedbackController.js +4 -5
  65. package/esm/feedback/index.d.ts +0 -16
  66. package/esm/feedback/index.js +0 -11
  67. package/esm/feedback/server/index.d.ts +17 -0
  68. package/esm/feedback/server/index.js +13 -0
  69. package/esm/feedback/ui/DialogIssue.svelte +52 -56
  70. package/esm/feedback/ui/DialogIssues.svelte +71 -71
  71. package/esm/feedback/ui/DialogMilestones.svelte +22 -22
  72. package/esm/helper.js +3 -3
  73. package/esm/index.d.ts +3 -20
  74. package/esm/index.js +3 -10
  75. package/esm/mail/index.d.ts +2 -30
  76. package/esm/mail/index.js +2 -79
  77. package/esm/mail/server/index.d.ts +31 -0
  78. package/esm/mail/server/index.js +88 -0
  79. package/esm/mail/templates/DefaultMail.svelte +17 -17
  80. package/esm/storeItem.js +8 -2
  81. package/esm/storeList.d.ts +1 -1
  82. package/esm/storeList.js +1 -1
  83. package/esm/sveltekit/server/index.d.ts +14 -0
  84. package/esm/sveltekit/server/index.js +24 -0
  85. package/esm/ui/Button.svelte +33 -33
  86. package/esm/ui/Button.svelte.d.ts +2 -2
  87. package/esm/ui/Clipboardable.svelte +11 -8
  88. package/esm/ui/Clipboardable.svelte.d.ts +4 -4
  89. package/esm/ui/Field.svelte +142 -149
  90. package/esm/ui/Field.svelte.d.ts +2 -2
  91. package/esm/ui/FieldGroup.svelte +38 -38
  92. package/esm/ui/Grid.svelte +212 -222
  93. package/esm/ui/GridLoading.svelte +18 -22
  94. package/esm/ui/GridPaginate.svelte +38 -38
  95. package/esm/ui/Icon.svelte +50 -49
  96. package/esm/ui/Icon.svelte.d.ts +18 -18
  97. package/esm/ui/Loading.svelte +5 -2
  98. package/esm/ui/Tooltip.svelte +16 -16
  99. package/esm/ui/dialog/DialogForm.svelte +23 -23
  100. package/esm/ui/dialog/DialogManagement.svelte +74 -74
  101. package/esm/ui/dialog/DialogPrimitive.svelte +50 -51
  102. package/esm/ui/dialog/FormEditAction.svelte +34 -34
  103. package/esm/ui/dialog/dialog.d.ts +2 -2
  104. package/esm/ui/dialog/dialog.js +1 -1
  105. package/esm/ui/internals/FieldContainer.svelte +11 -12
  106. package/esm/ui/internals/FieldContainer.svelte.d.ts +3 -3
  107. package/esm/ui/internals/Input.svelte +25 -25
  108. package/esm/ui/internals/Input.svelte.d.ts +1 -1
  109. package/esm/ui/internals/Textarea.svelte +21 -21
  110. package/esm/ui/internals/Textarea.svelte.d.ts +2 -2
  111. package/esm/ui/internals/select/MultiSelectMelt.svelte +69 -73
  112. package/esm/ui/internals/select/SelectMelt.svelte +86 -86
  113. package/esm/ui/internals/select/SelectRadio.svelte +22 -22
  114. package/esm/ui/link/Link.svelte +14 -14
  115. package/esm/ui/link/Link.svelte.d.ts +3 -4
  116. package/esm/ui/link/LinkPlus.svelte +33 -35
  117. package/esm/vite/index.js +24 -25
  118. package/package.json +50 -42
  119. package/esm/auth/Adapter.d.ts +0 -10
  120. package/esm/auth/Adapter.js +0 -50
  121. package/esm/auth/client/index.d.ts +0 -7
  122. package/esm/auth/client/index.js +0 -7
  123. package/esm/auth/helper.d.ts +0 -6
  124. package/esm/auth/helper.js +0 -14
  125. package/esm/auth/providers/strava.d.ts +0 -30
  126. package/esm/auth/providers/strava.js +0 -60
  127. package/esm/auth/static/assets/Page-BEFYPjis.d.ts +0 -4
  128. package/esm/auth/static/assets/Page-BEFYPjis.js +0 -1
  129. package/esm/auth/static/assets/Page-BGTO8LC5.css +0 -1
  130. package/esm/auth/static/assets/Page-Cfysx_UV.d.ts +0 -6
  131. package/esm/auth/static/assets/Page-Cfysx_UV.js +0 -18
  132. package/esm/auth/static/assets/Page-DtgkOCJs.d.ts +0 -4
  133. package/esm/auth/static/assets/Page-DtgkOCJs.js +0 -1
  134. package/esm/auth/static/assets/index-CR_3yNaJ.css +0 -4
  135. package/esm/auth/static/assets/index-QypqCYwC.d.ts +0 -63
  136. package/esm/auth/static/assets/index-QypqCYwC.js +0 -2
  137. package/esm/cron/index.js +0 -102
  138. package/esm/handle/index.d.ts +0 -7
  139. 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.3.7',
51
- '@kitql/helpers': '0.8.10',
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
- './.eslintrc.cjs': [
69
- `module.exports = {
70
- extends: ['@kitql'],
71
- rules: {
72
- // Your overrides here
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.cjs': [
100
- `const {
101
- //plugins,
102
- ...prettierConfig
103
- } = require('@kitql/eslint-config/.prettierrc.cjs')
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.Admin] },
161
- { name: 'Noam', roles: [FF_Role.Admin, Role.Boss] },
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/providers'
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
- import { firstly } from 'firstly/handle'
209
-
210
- import { api } from '${libAlias}/firstly'
211
-
212
- export const handle = sequence(firstly(api))
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.server.GET
219
- export const POST = api.server.POST
220
- export const PUT = api.server.PUT
221
- export const DELETE = api.server.DELETE
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 { Auth } from 'firstly/auth/client'
361
+ import { AuthController } from 'firstly/auth/client'
295
362
 
296
363
  import { goto, invalidateAll } from '$app/navigation'
297
364
 
298
- import { route } from '../ROUTES'
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 Auth.signInDemo(identif)
374
+ await AuthController.signInDemo(identif)
308
375
  invalidateAll()
309
376
  } catch (error) {
310
377
  if (isError(error)) {
311
- // TODO: You will probably not leave this alert in production
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 Auth.signInOAuthGetUrl({
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
- // TODO: You will probably not leave this alert in production
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('firstly_sign_in'))}>Login with Firstly</button>
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 { Auth } from 'firstly/auth/client'
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 Auth.signOut()
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
- firstly_sign_in: 'ff/auth/sign-in',
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 type { Module } from 'firstly/api'
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': [
@@ -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
- $or: fields.map((f) => {
88
- return { $and: sSplitted.map((s) => ({ [f.key]: { $contains: s } })) };
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
@@ -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;
@@ -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 remult.repo(ChangeLog).insert({
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 remult.repo(ChangeLog).insert({
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
+ };
@@ -0,0 +1,5 @@
1
+ import { Log } from '@kitql/helpers';
2
+ export declare const ff_Log: Log;
3
+ export declare const FF_Role: {
4
+ readonly FF_Role_Admin: "FF_Role.Admin";
5
+ };
package/esm/common.js ADDED
@@ -0,0 +1,8 @@
1
+ // ******************************
2
+ // Objects
3
+ import { Log } from '@kitql/helpers';
4
+ // ******************************
5
+ export const ff_Log = new Log('firstly');
6
+ export const FF_Role = {
7
+ FF_Role_Admin: 'FF_Role.Admin',
8
+ };
@@ -1,5 +1,5 @@
1
1
  import { CronJob } from 'cron';
2
- import type { Module } from '../api';
2
+ import { Module } from '../../api';
3
3
  export declare const jobs: Record<string, {
4
4
  job: CronJob<null, unknown> | null;
5
5
  concurrentInProgress: number;