firstly 0.0.4 → 0.0.6
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 +21 -0
- package/esm/{KitBaseEnum.d.ts → BaseEnum.d.ts} +18 -9
- package/esm/{KitBaseEnum.js → BaseEnum.js} +2 -13
- package/esm/{KitEntity.d.ts → FF_Entity.d.ts} +1 -1
- package/esm/{KitEntity.js → FF_Entity.js} +9 -9
- package/esm/{KitFields.d.ts → FF_Fields.d.ts} +2 -3
- package/esm/{KitFields.js → FF_Fields.js} +13 -9
- package/esm/ROUTES.d.ts +3 -1
- package/esm/ROUTES.js +2 -1
- package/esm/SqlDatabase/FF_LogToConsole.d.ts +1 -0
- package/esm/SqlDatabase/{LogToConsoleCustom.js → FF_LogToConsole.js} +1 -1
- package/esm/api/index.d.ts +2 -1
- package/esm/auth/AuthController.server.js +59 -18
- package/esm/auth/Entities.d.ts +18 -17
- package/esm/auth/Entities.js +66 -63
- package/esm/auth/RoleHelpers.d.ts +2 -2
- package/esm/auth/RoleHelpers.js +1 -1
- package/esm/auth/client/Auth.js +1 -1
- package/esm/auth/index.d.ts +14 -17
- package/esm/auth/index.js +59 -52
- package/esm/auth/providers/github.d.ts +22 -17
- package/esm/auth/providers/github.js +29 -15
- package/esm/auth/providers/strava.d.ts +22 -17
- package/esm/auth/providers/strava.js +23 -15
- package/esm/auth/static/assets/Page-BGTO8LC5.css +1 -0
- package/esm/auth/static/assets/Page-DBWJjlEQ.d.ts +4 -0
- package/esm/auth/static/assets/Page-DBWJjlEQ.js +1 -0
- package/esm/auth/static/assets/Page-RIbXHuZG.d.ts +4 -0
- package/esm/auth/static/assets/Page-RIbXHuZG.js +1 -0
- package/esm/auth/static/assets/Page-apb_xgZT.d.ts +6 -0
- package/esm/auth/static/assets/Page-apb_xgZT.js +18 -0
- package/esm/auth/static/assets/{index-R27C_TlP.css → index-CR_3yNaJ.css} +1 -1
- package/esm/auth/static/assets/index-qfq98Nyd.d.ts +63 -0
- package/esm/auth/static/assets/index-qfq98Nyd.js +2 -0
- package/esm/auth/static/index.html +2 -2
- package/esm/auth/types.d.ts +16 -22
- package/esm/bin/cmd.js +181 -83
- package/esm/{kitCellsBuildor.d.ts → cellsBuildor.d.ts} +9 -9
- package/esm/{kitCellsBuildor.js → cellsBuildor.js} +9 -9
- package/esm/feedback/ui/DialogIssue.svelte +2 -2
- package/esm/formats/dates.js +2 -2
- package/esm/handle/index.d.ts +1 -0
- package/esm/helper.d.ts +8 -10
- package/esm/helper.js +13 -8
- package/esm/index.d.ts +38 -49
- package/esm/index.js +30 -27
- package/esm/mail/index.d.ts +23 -4
- package/esm/mail/index.js +38 -15
- package/esm/mail/templates/DefaultMail.svelte +66 -0
- package/esm/mail/templates/DefaultMail.svelte.d.ts +28 -0
- package/esm/{kitStoreItem.d.ts → storeItem.d.ts} +1 -1
- package/esm/{kitStoreItem.js → storeItem.js} +1 -1
- package/esm/{kitStoreList.d.ts → storeList.d.ts} +4 -4
- package/esm/{kitStoreList.js → storeList.js} +1 -1
- package/esm/ui/Button.svelte +1 -1
- package/esm/ui/Button.svelte.d.ts +2 -2
- package/esm/ui/Field.svelte.d.ts +2 -2
- package/esm/ui/FieldGroup.svelte +2 -2
- package/esm/ui/FieldGroup.svelte.d.ts +4 -4
- package/esm/ui/Grid.svelte.d.ts +5 -5
- package/esm/ui/dialog/DialogForm.svelte +4 -4
- package/esm/ui/dialog/DialogPrimitive.svelte.d.ts +2 -2
- package/esm/ui/dialog/FormEditAction.svelte.d.ts +2 -2
- package/esm/ui/dialog/dialog.d.ts +5 -5
- package/esm/ui/index.d.ts +2 -2
- package/esm/ui/internals/select/MultiSelectMelt.svelte.d.ts +3 -3
- package/esm/ui/internals/select/SelectMelt.svelte.d.ts +3 -3
- package/esm/ui/internals/select/SelectRadio.svelte.d.ts +2 -2
- package/esm/ui/link/LinkPlus.svelte.d.ts +2 -2
- package/esm/utils/types.d.ts +3 -15
- package/esm/utils/types.js +1 -17
- package/esm/virtual/Customer.js +2 -2
- package/esm/virtual/FilterEntity.js +1 -1
- package/esm/virtual/StateDemoEnum.d.ts +4 -4
- package/esm/virtual/StateDemoEnum.js +2 -2
- package/esm/virtual/UIEntity.js +4 -4
- package/esm/vite/index.js +1 -1
- package/package.json +5 -3
- package/esm/SqlDatabase/LogToConsoleCustom.d.ts +0 -1
- package/esm/auth/static/assets/Page-BYzkK4q3.d.ts +0 -5
- package/esm/auth/static/assets/Page-BYzkK4q3.js +0 -1
- package/esm/auth/static/assets/Page-ByIhtXVt.d.ts +0 -5
- package/esm/auth/static/assets/Page-ByIhtXVt.js +0 -18
- package/esm/auth/static/assets/Page-Do7F0Mzd.d.ts +0 -5
- package/esm/auth/static/assets/Page-Do7F0Mzd.js +0 -1
- package/esm/auth/static/assets/Page-gV58jf2r.css +0 -1
- package/esm/auth/static/assets/index-czJ1PA1n.d.ts +0 -53
- package/esm/auth/static/assets/index-czJ1PA1n.js +0 -2
package/esm/bin/cmd.js
CHANGED
|
@@ -18,7 +18,7 @@ const options = [
|
|
|
18
18
|
},
|
|
19
19
|
{
|
|
20
20
|
value: 'module-demo',
|
|
21
|
-
label: 'module
|
|
21
|
+
label: 'module task',
|
|
22
22
|
hint: 'A default module with a task entity and a controller (you can rename the folder and make it yours)',
|
|
23
23
|
},
|
|
24
24
|
{
|
|
@@ -34,8 +34,9 @@ const res = (await p.multiselect({
|
|
|
34
34
|
const devDependenciesPrepare = {
|
|
35
35
|
'@kitql/eslint-config': '0.3.6',
|
|
36
36
|
'@kitql/helpers': '0.8.9',
|
|
37
|
-
remult: versionFirstly,
|
|
38
37
|
pg: '8.12.0',
|
|
38
|
+
oslo: '^1.2.0',
|
|
39
|
+
remult: versionFirstly,
|
|
39
40
|
...pkg.devDependencies,
|
|
40
41
|
};
|
|
41
42
|
// sort by name
|
|
@@ -58,11 +59,11 @@ if (res.includes('all') || res.includes('dependencies')) {
|
|
|
58
59
|
const obj = {
|
|
59
60
|
'./.eslintrc.cjs': [
|
|
60
61
|
`module.exports = {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
62
|
+
extends: ['@kitql'],
|
|
63
|
+
rules: {
|
|
64
|
+
// Your overrides here
|
|
65
65
|
}
|
|
66
|
+
}
|
|
66
67
|
`,
|
|
67
68
|
],
|
|
68
69
|
'./.prettierignore': [
|
|
@@ -89,59 +90,74 @@ src/lib/ROUTES.ts
|
|
|
89
90
|
],
|
|
90
91
|
'./.prettierrc.cjs': [
|
|
91
92
|
`const {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
93
|
+
//plugins,
|
|
94
|
+
...prettierConfig
|
|
95
|
+
} = require('@kitql/eslint-config/.prettierrc.cjs')
|
|
96
|
+
|
|
97
|
+
module.exports = {
|
|
98
|
+
...prettierConfig,
|
|
99
|
+
// Your overrides here
|
|
100
|
+
}`,
|
|
100
101
|
],
|
|
101
102
|
'.env.example': [
|
|
102
103
|
`# Enable some roles
|
|
103
|
-
#
|
|
104
|
-
#
|
|
104
|
+
# FF_ADMIN = 'JYC'
|
|
105
|
+
# FF_AUTH_ADMIN = ''
|
|
105
106
|
|
|
106
107
|
# Enable GitHub login
|
|
107
|
-
GITHUB_CLIENT_ID = ''
|
|
108
|
-
GITHUB_CLIENT_SECRET = ''
|
|
108
|
+
# GITHUB_CLIENT_ID = ''
|
|
109
|
+
# GITHUB_CLIENT_SECRET = ''
|
|
109
110
|
`,
|
|
110
111
|
],
|
|
111
112
|
'./src/lib/firstly/index.ts': [
|
|
112
|
-
`import {
|
|
113
|
+
`import { FF_Role } from 'firstly'
|
|
114
|
+
import { firstly } from 'firstly/api'
|
|
113
115
|
import { auth } from 'firstly/auth'
|
|
114
|
-
// import { github } from 'firstly/auth/providers'
|
|
115
|
-
// import { GITHUB_CLIENT_ID, GITHUB_CLIENT_SECRET } from '$env/static/private'
|
|
116
116
|
import { Log } from '@kitql/helpers'
|
|
117
117
|
|
|
118
|
-
import {
|
|
118
|
+
import { task } from './modules/task'
|
|
119
119
|
|
|
120
|
-
|
|
120
|
+
//----------------------------------------
|
|
121
|
+
// To switch to postgres (1/2)
|
|
122
|
+
//----------------------------------------
|
|
121
123
|
// import { createPostgresConnection } from 'remult/postgres'
|
|
122
124
|
// import { DATABASE_URL } from '$env/static/private'
|
|
123
125
|
|
|
124
|
-
|
|
126
|
+
//----------------------------------------
|
|
127
|
+
// To enable OAuth via Github (1/2)
|
|
128
|
+
//----------------------------------------
|
|
129
|
+
// import { github } from 'firstly/auth/providers'
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Your roles, use them in your app !
|
|
133
|
+
*/
|
|
125
134
|
export const Role = {
|
|
126
|
-
|
|
127
|
-
SUPER_ADMIN: 'super_admin',
|
|
135
|
+
Boss: 'Boss',
|
|
128
136
|
}
|
|
129
137
|
|
|
130
|
-
/**
|
|
138
|
+
/**
|
|
139
|
+
* Your logs with a nice prefix, use \`log.info("Hello")\` / \`log.success("Yeah")\` / \`log.error("Ho nooo!")\` and see !
|
|
140
|
+
*/
|
|
131
141
|
export const log = new Log('${pkg.name}')
|
|
132
142
|
|
|
133
143
|
export const api = firstly({
|
|
144
|
+
//----------------------------------------
|
|
145
|
+
// To switch to postgres (2/2)
|
|
146
|
+
//----------------------------------------
|
|
134
147
|
// dataProvider: await createPostgresConnection({
|
|
135
148
|
// connectionString: DATABASE_URL,
|
|
136
149
|
// }),
|
|
150
|
+
|
|
137
151
|
modules: [
|
|
138
|
-
|
|
152
|
+
//----------------------------------------
|
|
153
|
+
// Core Module: auth
|
|
154
|
+
//----------------------------------------
|
|
139
155
|
auth({
|
|
140
156
|
providers: {
|
|
141
157
|
demo: [
|
|
142
158
|
{ name: 'Ermin' },
|
|
143
|
-
{ name: 'JYC', roles: [
|
|
144
|
-
{ name: 'Noam', roles: [Role.
|
|
159
|
+
{ name: 'JYC', roles: [FF_Role.Admin] },
|
|
160
|
+
{ name: 'Noam', roles: [FF_Role.Admin, Role.Boss] },
|
|
145
161
|
],
|
|
146
162
|
|
|
147
163
|
// password: {},
|
|
@@ -149,22 +165,23 @@ export const api = firstly({
|
|
|
149
165
|
// otp: {},
|
|
150
166
|
|
|
151
167
|
oAuths: [
|
|
152
|
-
|
|
153
|
-
//
|
|
154
|
-
//
|
|
155
|
-
|
|
156
|
-
//
|
|
157
|
-
// window.location.href = await Auth.signInOAuthGetUrl({ provider: 'github', redirect: window.location.pathname })
|
|
158
|
-
// }
|
|
159
|
-
// github( { GITHUB_CLIENT_ID, GITHUB_CLIENT_SECRET } )
|
|
168
|
+
//----------------------------------------
|
|
169
|
+
// To enable OAuth via Github (2/2)
|
|
170
|
+
// Instructions by hovering the method \`github\`
|
|
171
|
+
//----------------------------------------
|
|
172
|
+
// github(),
|
|
160
173
|
],
|
|
161
174
|
},
|
|
162
175
|
}),
|
|
163
176
|
|
|
177
|
+
//----------------------------------------
|
|
164
178
|
// example of a userland module
|
|
165
|
-
|
|
179
|
+
//----------------------------------------
|
|
180
|
+
task({ specialInfo: 'hello from userland' }),
|
|
166
181
|
|
|
182
|
+
//----------------------------------------
|
|
167
183
|
// example of a userland inline module
|
|
184
|
+
//----------------------------------------
|
|
168
185
|
{
|
|
169
186
|
name: 'app',
|
|
170
187
|
entities: [],
|
|
@@ -210,37 +227,13 @@ export const load = (async () => {
|
|
|
210
227
|
'./src/routes/+layout.svelte': [
|
|
211
228
|
`<script lang="ts">
|
|
212
229
|
import { remult } from 'remult'
|
|
213
|
-
import { isError } from 'firstly'
|
|
214
|
-
import { Auth } from 'firstly/auth/client'
|
|
215
|
-
|
|
216
|
-
import { invalidateAll } from '$app/navigation'
|
|
217
230
|
|
|
218
231
|
import { route } from '${libAlias}/ROUTES'
|
|
232
|
+
import SignIn from '${libAlias}/ui/SignIn.svelte'
|
|
233
|
+
import SignOut from '${libAlias}/ui/SignOut.svelte'
|
|
219
234
|
|
|
220
235
|
import type { LayoutData } from './$types'
|
|
221
236
|
|
|
222
|
-
const login = async (identif: string) => {
|
|
223
|
-
try {
|
|
224
|
-
await Auth.signInDemo(identif)
|
|
225
|
-
invalidateAll()
|
|
226
|
-
} catch (error) {
|
|
227
|
-
if (isError(error)) {
|
|
228
|
-
alert(error.message)
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
const logout = async () => {
|
|
234
|
-
try {
|
|
235
|
-
await Auth.signOut()
|
|
236
|
-
invalidateAll()
|
|
237
|
-
} catch (error) {
|
|
238
|
-
if (isError(error)) {
|
|
239
|
-
alert(error.message)
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
|
|
244
237
|
export let data: LayoutData
|
|
245
238
|
$: remult.user = data.user
|
|
246
239
|
</script>
|
|
@@ -257,13 +250,17 @@ export const load = (async () => {
|
|
|
257
250
|
<h1>${pkg.name}</h1>
|
|
258
251
|
|
|
259
252
|
{#if remult.authenticated()}
|
|
260
|
-
<
|
|
253
|
+
<div style="float:right;">
|
|
254
|
+
<SignOut></SignOut>
|
|
255
|
+
</div>
|
|
261
256
|
<span>{remult.user?.name} ({remult.user?.roles})<br /><br /></span>
|
|
262
257
|
{:else}
|
|
263
|
-
<
|
|
264
|
-
<
|
|
265
|
-
<
|
|
266
|
-
<
|
|
258
|
+
<SignIn demo="Ermin"></SignIn>
|
|
259
|
+
<SignIn demo="JYC"></SignIn>
|
|
260
|
+
<SignIn demo="Noam"></SignIn>
|
|
261
|
+
<br />
|
|
262
|
+
<SignIn ffLink></SignIn>
|
|
263
|
+
<SignIn oauth="github"></SignIn>
|
|
267
264
|
{/if}
|
|
268
265
|
|
|
269
266
|
<hr />
|
|
@@ -272,11 +269,87 @@ export const load = (async () => {
|
|
|
272
269
|
|
|
273
270
|
<hr />
|
|
274
271
|
|
|
275
|
-
<
|
|
276
|
-
|
|
277
|
-
|
|
272
|
+
<div style="float: right; text-align: right;">
|
|
273
|
+
<a href={route('remult_admin')} target="_blank">🚀 admin</a>
|
|
274
|
+
<p style="font-size: small;">
|
|
275
|
+
<i>Login as <b>JYC</b> to get admin rights ☝️</i>
|
|
276
|
+
</p>
|
|
277
|
+
</div>
|
|
278
|
+
<a href={route('github', { owner: 'jycouet', repo: 'firstly' })} target="_blank"> ⭐️ firstly </a>
|
|
278
279
|
|
|
|
279
280
|
<a href={route('github', { owner: 'remult', repo: 'remult' })} target="_blank">⭐️ remult</a>
|
|
281
|
+
`,
|
|
282
|
+
],
|
|
283
|
+
'./src/lib/ui/SignIn.svelte': [
|
|
284
|
+
`<script lang="ts">
|
|
285
|
+
import { isError } from 'firstly'
|
|
286
|
+
import { Auth } from 'firstly/auth/client'
|
|
287
|
+
|
|
288
|
+
import { goto, invalidateAll } from '$app/navigation'
|
|
289
|
+
|
|
290
|
+
import { route } from '../ROUTES'
|
|
291
|
+
|
|
292
|
+
// Examples of signin modes
|
|
293
|
+
export let demo = ''
|
|
294
|
+
export let ffLink = false
|
|
295
|
+
export let oauth: 'github' | undefined = undefined
|
|
296
|
+
|
|
297
|
+
const signinDemo = async (identif: string) => {
|
|
298
|
+
try {
|
|
299
|
+
await Auth.signInDemo(identif)
|
|
300
|
+
invalidateAll()
|
|
301
|
+
} catch (error) {
|
|
302
|
+
if (isError(error)) {
|
|
303
|
+
// TODO: You will probably not leave this alert in production
|
|
304
|
+
alert(error.message)
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
async function signinOAuth(provider: 'github') {
|
|
310
|
+
try {
|
|
311
|
+
window.location.href = await Auth.signInOAuthGetUrl({
|
|
312
|
+
provider,
|
|
313
|
+
redirect: window.location.pathname,
|
|
314
|
+
})
|
|
315
|
+
} catch (error) {
|
|
316
|
+
if (isError(error)) {
|
|
317
|
+
// TODO: You will probably not leave this alert in production
|
|
318
|
+
alert(error.message)
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
</script>
|
|
323
|
+
|
|
324
|
+
{#if demo}
|
|
325
|
+
<button on:click={() => signinDemo(demo)}>Login as {demo}</button>
|
|
326
|
+
{:else if ffLink}
|
|
327
|
+
<button on:click={() => goto(route('firstly_sign_in'))}>Login with Firstly</button>
|
|
328
|
+
{:else if oauth}
|
|
329
|
+
<button on:click={() => signinOAuth(oauth)}>Login With {oauth}</button>
|
|
330
|
+
{/if}
|
|
331
|
+
`,
|
|
332
|
+
],
|
|
333
|
+
'./src/lib/ui/SignOut.svelte': [
|
|
334
|
+
`<script lang="ts">
|
|
335
|
+
import { isError } from 'firstly'
|
|
336
|
+
import { Auth } from 'firstly/auth/client'
|
|
337
|
+
|
|
338
|
+
import { invalidateAll } from '$app/navigation'
|
|
339
|
+
|
|
340
|
+
const logout = async () => {
|
|
341
|
+
try {
|
|
342
|
+
await Auth.signOut()
|
|
343
|
+
invalidateAll()
|
|
344
|
+
} catch (error) {
|
|
345
|
+
if (isError(error)) {
|
|
346
|
+
alert(error.message)
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
</script>
|
|
351
|
+
|
|
352
|
+
<button on:click={logout}>Logout</button>
|
|
280
353
|
`,
|
|
281
354
|
],
|
|
282
355
|
'./tsconfig.json': [
|
|
@@ -313,7 +386,11 @@ export default defineConfig({
|
|
|
313
386
|
plugins: [
|
|
314
387
|
firstly<KIT_ROUTES>({
|
|
315
388
|
kitRoutes: {
|
|
316
|
-
LINKS: {
|
|
389
|
+
LINKS: {
|
|
390
|
+
firstly_sign_in: 'ff/auth/sign-in',
|
|
391
|
+
github: 'https://github.com/[owner]/[repo]',
|
|
392
|
+
remult_admin: 'api/admin',
|
|
393
|
+
},
|
|
317
394
|
}
|
|
318
395
|
}),
|
|
319
396
|
sveltekit(),
|
|
@@ -321,7 +398,28 @@ export default defineConfig({
|
|
|
321
398
|
})
|
|
322
399
|
`,
|
|
323
400
|
],
|
|
324
|
-
'
|
|
401
|
+
'./.gitignore': [
|
|
402
|
+
`node_modules
|
|
403
|
+
|
|
404
|
+
# Output
|
|
405
|
+
/.svelte-kit
|
|
406
|
+
/build
|
|
407
|
+
|
|
408
|
+
# Env
|
|
409
|
+
.env
|
|
410
|
+
.env.*
|
|
411
|
+
!.env.example
|
|
412
|
+
!.env.test
|
|
413
|
+
|
|
414
|
+
# Vite
|
|
415
|
+
vite.config.js.timestamp-*
|
|
416
|
+
vite.config.ts.timestamp-*
|
|
417
|
+
|
|
418
|
+
# Firstly / Remult
|
|
419
|
+
/db
|
|
420
|
+
`,
|
|
421
|
+
],
|
|
422
|
+
'./src/lib/firstly/modules/task/index.ts': [
|
|
325
423
|
`import type { Module } from 'firstly/api'
|
|
326
424
|
|
|
327
425
|
import { log } from '${libAlias}/firstly'
|
|
@@ -329,7 +427,7 @@ import { log } from '${libAlias}/firstly'
|
|
|
329
427
|
import { Task } from './Task'
|
|
330
428
|
import { TaskController } from './TaskController'
|
|
331
429
|
|
|
332
|
-
export const
|
|
430
|
+
export const task: (o: { specialInfo: string }) => Module = ({ specialInfo }) => {
|
|
333
431
|
return {
|
|
334
432
|
name: 'task',
|
|
335
433
|
entities: [Task],
|
|
@@ -340,11 +438,11 @@ export const tasks: (o: { specialInfo: string }) => Module = ({ specialInfo }) =
|
|
|
340
438
|
}
|
|
341
439
|
}`,
|
|
342
440
|
],
|
|
343
|
-
'./src/lib/firstly/modules/
|
|
441
|
+
'./src/lib/firstly/modules/task/Task.ts': [
|
|
344
442
|
`import { Entity, Field, Fields, ValueListFieldType } from 'remult'
|
|
345
|
-
import {
|
|
443
|
+
import { BaseEnum, LibIcon_Add, LibIcon_Delete, type BaseEnumOptions } from 'firstly'
|
|
346
444
|
|
|
347
|
-
@Entity('
|
|
445
|
+
@Entity('task', {
|
|
348
446
|
allowApiCrud: true,
|
|
349
447
|
})
|
|
350
448
|
export class Task {
|
|
@@ -369,7 +467,7 @@ export class Task {
|
|
|
369
467
|
}
|
|
370
468
|
|
|
371
469
|
@ValueListFieldType()
|
|
372
|
-
export class TypeOfTaskEnum extends
|
|
470
|
+
export class TypeOfTaskEnum extends BaseEnum {
|
|
373
471
|
static EASY = new TypeOfTaskEnum('EASY', {
|
|
374
472
|
caption: 'Easy',
|
|
375
473
|
icon: { data: LibIcon_Add },
|
|
@@ -378,13 +476,13 @@ export class TypeOfTaskEnum extends KitBaseEnum {
|
|
|
378
476
|
caption: 'Hard',
|
|
379
477
|
icon: { data: LibIcon_Delete },
|
|
380
478
|
})
|
|
381
|
-
constructor(id: string, o?:
|
|
479
|
+
constructor(id: string, o?: BaseEnumOptions<TypeOfTaskEnum>) {
|
|
382
480
|
super(id, o)
|
|
383
481
|
}
|
|
384
482
|
}
|
|
385
483
|
`,
|
|
386
484
|
],
|
|
387
|
-
'./src/lib/firstly/modules/
|
|
485
|
+
'./src/lib/firstly/modules/task/TaskController.ts': [
|
|
388
486
|
`import { BackendMethod } from 'remult'
|
|
389
487
|
|
|
390
488
|
import { log } from '${libAlias}/firstly'
|
|
@@ -407,7 +505,7 @@ for (const [path, content] of Object.entries(obj)) {
|
|
|
407
505
|
}
|
|
408
506
|
else {
|
|
409
507
|
if (res.includes('module-demo')) {
|
|
410
|
-
if (path.startsWith('./src/lib/firstly/modules/
|
|
508
|
+
if (path.startsWith('./src/lib/firstly/modules/task')) {
|
|
411
509
|
write(path, content);
|
|
412
510
|
}
|
|
413
511
|
}
|
|
@@ -2,7 +2,7 @@ import type { SvelteComponent } from 'svelte';
|
|
|
2
2
|
import { type EntityFilter, type FieldMetadata, type Repository } from 'remult';
|
|
3
3
|
import type { UnArray } from './utils/types.js';
|
|
4
4
|
export type VisibilityMode = 'view' | 'edit' | 'hide';
|
|
5
|
-
type
|
|
5
|
+
type CellInternal<Entity> = {
|
|
6
6
|
col?: keyof Entity;
|
|
7
7
|
kind?: 'field' | 'field_link' | 'entity_link' | 'slot' | 'header' | 'component';
|
|
8
8
|
class?: string;
|
|
@@ -16,19 +16,19 @@ type KitCellInternal<Entity> = {
|
|
|
16
16
|
props?: any;
|
|
17
17
|
rowToProps?: (row: any) => any;
|
|
18
18
|
};
|
|
19
|
-
export type
|
|
19
|
+
export type Cell<Entity> = CellInternal<Entity> & {
|
|
20
20
|
field?: FieldMetadata<any, Entity>;
|
|
21
21
|
};
|
|
22
|
-
export type
|
|
22
|
+
export type CellsInput<Entity> = (keyof Entity | CellInternal<Entity>)[];
|
|
23
23
|
/**
|
|
24
|
-
*
|
|
24
|
+
* cellsBuildor is a function to build cells for a <Grid /> or <FieldGroup /> component.
|
|
25
25
|
*
|
|
26
26
|
* ```html
|
|
27
27
|
* <script lang="ts">
|
|
28
28
|
* import { repo } from 'remult'
|
|
29
29
|
*
|
|
30
|
-
* const cells =
|
|
31
|
-
* const store =
|
|
30
|
+
* const cells = cellsBuildor(repo(Site), ['name', 'description'])
|
|
31
|
+
* const store = storeList( repo(Site) )
|
|
32
32
|
* $: store.fetch()
|
|
33
33
|
* </script>
|
|
34
34
|
*
|
|
@@ -36,9 +36,9 @@ export type KitCellsInput<Entity> = (keyof Entity | KitCellInternal<Entity>)[];
|
|
|
36
36
|
* ```
|
|
37
37
|
*
|
|
38
38
|
*/
|
|
39
|
-
export declare function
|
|
40
|
-
export declare function
|
|
41
|
-
export declare const fieldsOf: <Entity>(b:
|
|
39
|
+
export declare function cellsBuildor<Entity>(repo: Repository<Entity>, inputBuildor: CellsInput<Entity>): Cell<Entity>[];
|
|
40
|
+
export declare function cellBuildor<Entity>(repo: Repository<Entity>, inputBuildor: UnArray<CellsInput<Entity>>): Cell<Entity>;
|
|
41
|
+
export declare const fieldsOf: <Entity>(b: Cell<Entity>[]) => FieldMetadata<any, Entity>[];
|
|
42
42
|
export declare const getPlaceholder: <Entity>(fields: FieldMetadata<any, Entity>[]) => string;
|
|
43
43
|
export declare const buildSearchWhere: <Entity>(entity: Entity | undefined, fields: FieldMetadata<any, Entity>[], search?: string | null) => EntityFilter<Entity>[];
|
|
44
44
|
export declare const buildWhere: <Entity>(entity: Entity | undefined, defaultWhere: EntityFilter<Entity> | undefined, fields_filter: FieldMetadata<any, Entity>[], fields_search: FieldMetadata<any, Entity>[], obj: Record<string, string>) => EntityFilter<Entity>;
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import {} from 'remult';
|
|
2
2
|
import { getRelationFieldInfo } from 'remult/internals';
|
|
3
|
-
import {
|
|
3
|
+
import { BaseEnum } from './BaseEnum.js';
|
|
4
|
+
import { getEnum } from './helper.js';
|
|
4
5
|
/**
|
|
5
|
-
*
|
|
6
|
+
* cellsBuildor is a function to build cells for a <Grid /> or <FieldGroup /> component.
|
|
6
7
|
*
|
|
7
8
|
* ```html
|
|
8
9
|
* <script lang="ts">
|
|
9
10
|
* import { repo } from 'remult'
|
|
10
11
|
*
|
|
11
|
-
* const cells =
|
|
12
|
-
* const store =
|
|
12
|
+
* const cells = cellsBuildor(repo(Site), ['name', 'description'])
|
|
13
|
+
* const store = storeList( repo(Site) )
|
|
13
14
|
* $: store.fetch()
|
|
14
15
|
* </script>
|
|
15
16
|
*
|
|
@@ -17,7 +18,7 @@ import { getEnum, KitBaseEnum } from './KitBaseEnum.js';
|
|
|
17
18
|
* ```
|
|
18
19
|
*
|
|
19
20
|
*/
|
|
20
|
-
export function
|
|
21
|
+
export function cellsBuildor(repo, inputBuildor) {
|
|
21
22
|
const buildor = [];
|
|
22
23
|
for (let i = 0; i < inputBuildor.length; i++) {
|
|
23
24
|
const item = inputBuildor[i];
|
|
@@ -38,8 +39,8 @@ export function kitCellsBuildor(repo, inputBuildor) {
|
|
|
38
39
|
}
|
|
39
40
|
return buildor;
|
|
40
41
|
}
|
|
41
|
-
export function
|
|
42
|
-
return
|
|
42
|
+
export function cellBuildor(repo, inputBuildor) {
|
|
43
|
+
return cellsBuildor(repo, [inputBuildor])[0];
|
|
43
44
|
}
|
|
44
45
|
export const fieldsOf = (b) => {
|
|
45
46
|
return b.filter((c) => c.field).map((c) => c.field) ?? [];
|
|
@@ -96,8 +97,7 @@ export const buildWhere = (entity, defaultWhere, fields_filter, fields_search, o
|
|
|
96
97
|
// @ts-ignore
|
|
97
98
|
const theEnum = getEnum(field, obj[field.key]);
|
|
98
99
|
// Take the where of the enum if it exists, or it's using this selection as a filter
|
|
99
|
-
|
|
100
|
-
const wheretoUse = theEnum?.where ?? new KitBaseEnum(obj[field.key]);
|
|
100
|
+
const wheretoUse = theEnum?.where ?? new BaseEnum(obj[field.key]);
|
|
101
101
|
// @ts-ignore
|
|
102
102
|
and.push({ [field.key]: wheretoUse });
|
|
103
103
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { repo } from "remult";
|
|
3
3
|
import { page } from "$app/stores";
|
|
4
4
|
import { FeedbackController } from "..";
|
|
5
|
-
import { Button, Field, FilterEntity,
|
|
5
|
+
import { Button, cellBuildor, Field, FilterEntity, Loading } from "../..";
|
|
6
6
|
import Textarea from "../../ui/internals/Textarea.svelte";
|
|
7
7
|
export let dialogId;
|
|
8
8
|
const rmvWarning = dialogId;
|
|
@@ -84,7 +84,7 @@ const reOpen = async () => {
|
|
|
84
84
|
</div>
|
|
85
85
|
{:else}
|
|
86
86
|
{#if issueNumber === null}
|
|
87
|
-
<Field cell={
|
|
87
|
+
<Field cell={cellBuildor(repo(FilterEntity), 'title')} bind:value={title} />
|
|
88
88
|
{/if}
|
|
89
89
|
<Textarea bind:value={content}></Textarea>
|
|
90
90
|
<div class="flex justify-between">
|
package/esm/formats/dates.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ff_Log } from '../';
|
|
2
2
|
export const dateISOToPlainDate = (iso) => {
|
|
3
3
|
try {
|
|
4
4
|
// const ti = Temporal.Instant.from(iso)
|
|
@@ -9,7 +9,7 @@ export const dateISOToPlainDate = (iso) => {
|
|
|
9
9
|
}
|
|
10
10
|
catch (error) { }
|
|
11
11
|
const msg = `fn dateISOToPlainDate -> "${iso}" is not valid iso`;
|
|
12
|
-
|
|
12
|
+
ff_Log.error(msg);
|
|
13
13
|
throw new Error(msg);
|
|
14
14
|
};
|
|
15
15
|
export const offsetedToPlainDate = (dt) => {
|
package/esm/handle/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types=".pnpm/@sveltejs+kit@2.5.24_@sveltejs+vite-plugin-svelte@3.1.1_svelte@4.2.18_vite@5.4.1_@types+node@_vtylvkjv5lewhfcl4vq2py4rce/node_modules/@sveltejs/kit" />
|
|
1
2
|
import type { Handle } from '@sveltejs/kit';
|
|
2
3
|
import type { RemultSveltekitServer } from 'remult/remult-sveltekit';
|
|
3
4
|
import type { Module } from '../api';
|
package/esm/helper.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { ErrorInfo, FieldMetadata, Repository } from 'remult';
|
|
2
|
-
import type {
|
|
1
|
+
import type { ClassType, ErrorInfo, FieldMetadata, Repository } from 'remult';
|
|
2
|
+
import type { BaseEnum, BaseItem } from './index.js';
|
|
3
3
|
export declare function isError<T>(object: any): object is ErrorInfo<T>;
|
|
4
4
|
export declare const getFirstInterestingField: <Entity>(repo: Repository<Entity>) => FieldMetadata<any, Entity>;
|
|
5
|
-
export declare const getEntityDisplayValue: <Entity>(repo: Repository<Entity>, row: Entity) =>
|
|
6
|
-
export declare const getFieldLinkDisplayValue: (field: FieldMetadata, row: any) => import("./
|
|
5
|
+
export declare const getEntityDisplayValue: <Entity>(repo: Repository<Entity>, row: Entity) => BaseItem;
|
|
6
|
+
export declare const getFieldLinkDisplayValue: (field: FieldMetadata, row: any) => import("./BaseEnum.js").BaseEnumOptions<any> & {
|
|
7
7
|
id: string;
|
|
8
8
|
captionSub?: string | (string | undefined)[] | undefined;
|
|
9
9
|
href?: string | undefined;
|
|
@@ -16,7 +16,7 @@ export declare const getFieldLinkDisplayValue: (field: FieldMetadata, row: any)
|
|
|
16
16
|
} & {
|
|
17
17
|
href: string;
|
|
18
18
|
};
|
|
19
|
-
export declare const getEntityDisplayValueFromField: (field: FieldMetadata, row: any) =>
|
|
19
|
+
export declare const getEntityDisplayValueFromField: (field: FieldMetadata, row: any) => BaseItem & {
|
|
20
20
|
href: string;
|
|
21
21
|
};
|
|
22
22
|
export type MetaTypeRelation = {
|
|
@@ -28,7 +28,7 @@ export type MetaTypeRelation = {
|
|
|
28
28
|
type MetaTypeEnum = {
|
|
29
29
|
kind: 'enum';
|
|
30
30
|
subKind: 'single' | 'multi';
|
|
31
|
-
values:
|
|
31
|
+
values: BaseItem[];
|
|
32
32
|
field: FieldMetadata;
|
|
33
33
|
};
|
|
34
34
|
type MetaTypePrimitive = {
|
|
@@ -43,8 +43,6 @@ type MetaTypeSlot = {
|
|
|
43
43
|
export type FieldMetaType = MetaTypeRelation | MetaTypeEnum | MetaTypePrimitive | MetaTypeSlot;
|
|
44
44
|
export declare const getFieldMetaType: (field?: FieldMetadata) => FieldMetaType;
|
|
45
45
|
export declare const displayWithDefaultAndSuffix: (field: FieldMetadata<any, any> | undefined, value: any) => string;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
*/
|
|
49
|
-
export declare const kitDbNamesOf: <Entity>(repo: import("remult/src/remult3/RepositoryImplementation.js").EntityMetadataOverloads<Entity>, wrapIdentifierOrOptions?: ((name: string) => string) | import("remult").dbNamesOfOptions | undefined) => Promise<import("remult").EntityDbNames<Entity>>;
|
|
46
|
+
export declare const getEnum: <T extends BaseEnum<any>>(baseEnum: ClassType<T>, id: string | undefined | null) => T | undefined;
|
|
47
|
+
export declare const getEnums: <T extends BaseEnum<any>>(baseEnum: ClassType<T>) => T[];
|
|
50
48
|
export {};
|
package/esm/helper.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getEntityRef, getValueList } from 'remult';
|
|
2
2
|
import { getRelationFieldInfo } from 'remult/internals';
|
|
3
3
|
import { suffixWithS } from './formats/strings.js';
|
|
4
4
|
export function isError(object) {
|
|
@@ -58,8 +58,6 @@ export const getFieldMetaType = (field) => {
|
|
|
58
58
|
return {
|
|
59
59
|
kind: 'enum',
|
|
60
60
|
subKind: 'multi',
|
|
61
|
-
// // @ts-ignore
|
|
62
|
-
// values: getEnums(field.target) as KitBaseItem[],
|
|
63
61
|
// @ts-ignore
|
|
64
62
|
values: field.options.valueConverter.values,
|
|
65
63
|
field,
|
|
@@ -106,9 +104,16 @@ export const displayWithDefaultAndSuffix = (field, value) => {
|
|
|
106
104
|
}
|
|
107
105
|
return toRet.join(' ');
|
|
108
106
|
};
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
107
|
+
// FIXME: to remove ?
|
|
108
|
+
export const getEnum = (baseEnum, id) => {
|
|
109
|
+
if (!id) {
|
|
110
|
+
return undefined;
|
|
111
|
+
}
|
|
112
|
+
// @ts-ignore
|
|
113
|
+
const found = getValueList(baseEnum).find((c) => c.id === id);
|
|
114
|
+
return found;
|
|
115
|
+
};
|
|
116
|
+
// FIXME: to remove ?
|
|
117
|
+
export const getEnums = (baseEnum) => {
|
|
118
|
+
return getValueList(baseEnum) || [];
|
|
114
119
|
};
|